reactive-md 0.5.1 → 0.5.3
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 +29 -0
- package/CHANGELOG.md +29 -0
- package/README-ch.md +7 -6
- package/README-en.md +8 -6
- package/README.md +8 -6
- package/cli/build.mjs +1 -1
- package/cli/package.mjs +1 -0
- package/dist-library/authoring-DJJjKYg9.js +842 -0
- package/dist-library/{runtime-CXBdLQ3A.js → compiler-UyPwGzJZ.js} +4374 -3730
- package/dist-library/react-fizgU3i8.js +12764 -0
- package/dist-library/reactive-md-authoring.js +1514 -0
- package/dist-library/reactive-md-editor.js +577 -571
- 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 -13177
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +260 -1062
- package/dist-library/runtime-DXtle_6c.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 +5 -10
- package/dist-library/types/local/LocalDocumentView.d.ts +14 -4
- package/dist-library/types/local/authoring.d.ts +9 -5
- package/dist-library/types/local/diagnostics.d.ts +80 -0
- package/dist-library/types/local/html-names.d.ts +6 -0
- package/dist-library/types/local/index.d.ts +2 -1
- package/dist-library/types/local/limits.d.ts +8 -0
- package/dist-library/types/local/math-display.d.ts +72 -0
- package/dist-library/types/local/math-view.d.ts +2 -0
- package/dist-library/types/local/options.d.ts +9 -2
- package/dist-library/types/local/render-types.d.ts +11 -0
- package/dist-library/types/local/types.d.ts +28 -0
- package/dist-library/types/local/worker.d.ts +5 -1
- package/dist-library/types/react/index.d.ts +1 -1
- package/dist-standalone/reactive-md-standalone.js +54 -50
- package/docs/author-tools-ch.md +11 -5
- package/docs/author-tools-en.md +11 -5
- package/docs/compatibility-ch.md +7 -5
- package/docs/compatibility-en.md +7 -5
- package/docs/component-development-ch.md +4 -4
- package/docs/component-development-en.md +3 -3
- package/docs/component-protocol-ch.md +48 -11
- package/docs/component-protocol-en.md +48 -11
- package/docs/editor-ch.md +237 -235
- package/docs/editor-en.md +237 -235
- package/docs/local-integration-ch.md +392 -366
- package/docs/local-integration-en.md +392 -366
- package/docs/release-0.5.2-ch.md +35 -0
- package/docs/release-0.5.2-en.md +35 -0
- package/docs/release-0.5.3-ch.md +25 -0
- package/docs/release-0.5.3-en.md +25 -0
- package/docs/releasing-ch.md +7 -7
- package/docs/releasing-en.md +8 -8
- package/examples/conformance/README.md +1 -1
- package/package.json +12 -2
|
@@ -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;
|
|
@@ -98,6 +98,10 @@ export declare const LOCAL_DIAGNOSTIC_MESSAGES: {
|
|
|
98
98
|
readonly en: 'Compile option limits.maxSyntaxNodes must be a positive safe integer.';
|
|
99
99
|
readonly zh: '编译选项 limits.maxSyntaxNodes 必须是正安全整数。';
|
|
100
100
|
};
|
|
101
|
+
readonly 'options.hostComponents': {
|
|
102
|
+
readonly en: 'Compile option hostComponents is invalid: {detail}';
|
|
103
|
+
readonly zh: '编译选项 hostComponents 无效:{detail}';
|
|
104
|
+
};
|
|
101
105
|
readonly 'theme.expression': {
|
|
102
106
|
readonly en: 'Theme names must be static text, not expressions.';
|
|
103
107
|
readonly zh: '主题名称必须是静态文本,不能是表达式。';
|
|
@@ -246,6 +250,10 @@ export declare const LOCAL_DIAGNOSTIC_MESSAGES: {
|
|
|
246
250
|
readonly en: 'Compile option {name} must be a boolean.';
|
|
247
251
|
readonly zh: '编译选项 {name} 必须是布尔值。';
|
|
248
252
|
};
|
|
253
|
+
readonly 'options.markdownBreaks': {
|
|
254
|
+
readonly en: 'Compile option markdownBreaks must be a boolean.';
|
|
255
|
+
readonly zh: '编译选项 markdownBreaks 必须为布尔值。';
|
|
256
|
+
};
|
|
249
257
|
readonly 'component.unknownSuggestion': {
|
|
250
258
|
readonly en: 'Unknown component <{name}>. Did you mean <{suggestion}>?';
|
|
251
259
|
readonly zh: '未知组件 <{name}>。是否想使用 <{suggestion}>?';
|
|
@@ -290,6 +298,34 @@ export declare const LOCAL_DIAGNOSTIC_MESSAGES: {
|
|
|
290
298
|
readonly en: 'Attribute {name} is static and cannot contain interpolations.';
|
|
291
299
|
readonly zh: '属性 {name} 是静态的,不能包含插值。';
|
|
292
300
|
};
|
|
301
|
+
readonly 'host.attributeUnknown': {
|
|
302
|
+
readonly en: 'Component <{component}> does not support attribute {name}.';
|
|
303
|
+
readonly zh: '组件 <{component}> 不支持属性 {name}。';
|
|
304
|
+
};
|
|
305
|
+
readonly 'host.attributeRequired': {
|
|
306
|
+
readonly en: 'Component <{component}> is missing required attribute {name}.';
|
|
307
|
+
readonly zh: '组件 <{component}> 缺少必需属性 {name}。';
|
|
308
|
+
};
|
|
309
|
+
readonly 'host.attributeStatic': {
|
|
310
|
+
readonly en: 'Attribute {name} is static and cannot contain interpolations.';
|
|
311
|
+
readonly zh: '属性 {name} 是静态的,不能包含插值。';
|
|
312
|
+
};
|
|
313
|
+
readonly 'host.attributeType': {
|
|
314
|
+
readonly en: 'Attribute {name} requires a {kind}, got "{value}".';
|
|
315
|
+
readonly zh: '属性 {name} 需要 {kind},当前为“{value}”。';
|
|
316
|
+
};
|
|
317
|
+
readonly 'host.attributeEnum': {
|
|
318
|
+
readonly en: 'Attribute {name} must be one of {values}, got "{value}".';
|
|
319
|
+
readonly zh: '属性 {name} 必须是 {values} 之一,当前为“{value}”。';
|
|
320
|
+
};
|
|
321
|
+
readonly 'host.attributePattern': {
|
|
322
|
+
readonly en: 'Attribute {name} must match pattern {pattern}.';
|
|
323
|
+
readonly zh: '属性 {name} 必须匹配模式 {pattern}。';
|
|
324
|
+
};
|
|
325
|
+
readonly 'host.attributeInterpolation': {
|
|
326
|
+
readonly en: 'Attribute {name} must be a literal matching {pattern} or one full interpolation.';
|
|
327
|
+
readonly zh: '属性 {name} 必须是匹配 {pattern} 的字面值,或一个完整插值。';
|
|
328
|
+
};
|
|
293
329
|
readonly 'expression.emptyAttribute': {
|
|
294
330
|
readonly en: 'Attribute {name} interpolation cannot be empty.';
|
|
295
331
|
readonly zh: '属性 {name} 的插值不能为空。';
|
|
@@ -774,6 +810,34 @@ export declare const LOCAL_DIAGNOSTIC_MESSAGES: {
|
|
|
774
810
|
readonly en: 'Plot parameter "{name}" must be a number, but is {kind}.';
|
|
775
811
|
readonly zh: '绘图参数“{name}”必须是数字,但当前为 {kind}。';
|
|
776
812
|
};
|
|
813
|
+
readonly 'math.displayUnsupportedCommand': {
|
|
814
|
+
readonly en: 'Formula command \\{name} is not supported; it is displayed as literal text.';
|
|
815
|
+
readonly zh: '公式命令 \\{name} 不受支持;已按原文显示。';
|
|
816
|
+
};
|
|
817
|
+
readonly 'math.displayUnsupportedEnvironment': {
|
|
818
|
+
readonly en: 'Formula environment {name} is not supported; it is displayed as literal text.';
|
|
819
|
+
readonly zh: '公式环境 {name} 不受支持;已按原文显示。';
|
|
820
|
+
};
|
|
821
|
+
readonly 'math.displayBudget': {
|
|
822
|
+
readonly en: 'Formula exceeds a display resource limit ({limit}); it is displayed as literal text.';
|
|
823
|
+
readonly zh: '公式超过显示资源上限({limit});已按原文显示。';
|
|
824
|
+
};
|
|
825
|
+
readonly 'math.displayStrayEnd': {
|
|
826
|
+
readonly en: 'Formula has an unmatched \\end; it is displayed as literal text.';
|
|
827
|
+
readonly zh: '公式中存在未匹配的 \\end;已按原文显示。';
|
|
828
|
+
};
|
|
829
|
+
readonly 'math.displayEnvironmentUnclosed': {
|
|
830
|
+
readonly en: 'Formula environment {name} is missing its closing brace; it is displayed as literal text.';
|
|
831
|
+
readonly zh: '公式环境 {name} 缺少结束花括号;已按原文显示。';
|
|
832
|
+
};
|
|
833
|
+
readonly 'math.displayEnvironmentMissingName': {
|
|
834
|
+
readonly en: 'Formula environment is missing its name; \\begin is displayed as literal text.';
|
|
835
|
+
readonly zh: '公式环境缺少名称;\\begin 已按原文显示。';
|
|
836
|
+
};
|
|
837
|
+
readonly 'math.displaySyntax': {
|
|
838
|
+
readonly en: 'Formula structure cannot be displayed and is shown as literal text.';
|
|
839
|
+
readonly zh: '公式结构无法显示,已按原文显示。';
|
|
840
|
+
};
|
|
777
841
|
readonly 'table.missingHeader': {
|
|
778
842
|
readonly en: 'The table for <{name}> is missing a header.';
|
|
779
843
|
readonly zh: '<{name}> 的表格缺少表头。';
|
|
@@ -1209,6 +1273,7 @@ declare const LOCAL_DIAGNOSTIC_TEMPLATE_ALIASES: {
|
|
|
1209
1273
|
readonly 'local.options.invalid.object': 'options.notObject';
|
|
1210
1274
|
readonly 'local.options.invalid.limits': 'options.limitsNotObject';
|
|
1211
1275
|
readonly 'local.options.invalid.max-syntax-nodes': 'options.maxSyntaxNodes';
|
|
1276
|
+
readonly 'local.options.invalid.host-components': 'options.hostComponents';
|
|
1212
1277
|
readonly 'local.budget.document': 'budget.document';
|
|
1213
1278
|
readonly 'local.budget.nodes': 'budget.syntaxNodes';
|
|
1214
1279
|
readonly 'local.budget.nesting': 'budget.nesting';
|
|
@@ -1266,6 +1331,7 @@ declare const LOCAL_DIAGNOSTIC_TEMPLATE_ALIASES: {
|
|
|
1266
1331
|
readonly 'local.html.unsafe-url': 'html.unsafeUrl';
|
|
1267
1332
|
readonly 'local.html.capability': 'html.capability';
|
|
1268
1333
|
readonly 'local.options.invalid.html-flag': 'options.htmlFlag';
|
|
1334
|
+
readonly 'local.options.invalid.markdown-breaks': 'options.markdownBreaks';
|
|
1269
1335
|
readonly 'local.component.unknown.suggestion': 'component.unknownSuggestion';
|
|
1270
1336
|
readonly 'local.component.unknown': 'component.unknownPlain';
|
|
1271
1337
|
readonly 'local.attribute.format': 'attribute.lowercase';
|
|
@@ -1279,6 +1345,13 @@ declare const LOCAL_DIAGNOSTIC_TEMPLATE_ALIASES: {
|
|
|
1279
1345
|
readonly 'local.attribute.color': 'attribute.color';
|
|
1280
1346
|
readonly 'local.attribute.required': 'attribute.required';
|
|
1281
1347
|
readonly 'local.attribute.static': 'attribute.static';
|
|
1348
|
+
readonly 'local.host.attribute.unknown': 'host.attributeUnknown';
|
|
1349
|
+
readonly 'local.host.attribute.required': 'host.attributeRequired';
|
|
1350
|
+
readonly 'local.host.attribute.static': 'host.attributeStatic';
|
|
1351
|
+
readonly 'local.host.attribute.type': 'host.attributeType';
|
|
1352
|
+
readonly 'local.host.attribute.enum': 'host.attributeEnum';
|
|
1353
|
+
readonly 'local.host.attribute.pattern': 'host.attributePattern';
|
|
1354
|
+
readonly 'local.host.attribute.interpolation': 'host.attributeInterpolation';
|
|
1282
1355
|
readonly 'local.attribute.type.number': 'attribute.numberInvalid';
|
|
1283
1356
|
readonly 'local.attribute.type.number-interpolation': 'attribute.numberInterpolationInvalid';
|
|
1284
1357
|
readonly 'local.attribute.type.integer': 'attribute.integer';
|
|
@@ -1404,6 +1477,13 @@ declare const LOCAL_DIAGNOSTIC_TEMPLATE_ALIASES: {
|
|
|
1404
1477
|
readonly 'local.math.compute': 'math.computeFailed';
|
|
1405
1478
|
readonly 'local.math.binding.unknown': 'math.bindingUnknown';
|
|
1406
1479
|
readonly 'local.math.binding.type': 'math.bindingType';
|
|
1480
|
+
readonly 'local.math.display.unsupported-command': 'math.displayUnsupportedCommand';
|
|
1481
|
+
readonly 'local.math.display.unsupported-environment': 'math.displayUnsupportedEnvironment';
|
|
1482
|
+
readonly 'local.math.display.budget': 'math.displayBudget';
|
|
1483
|
+
readonly 'local.math.display.stray-end': 'math.displayStrayEnd';
|
|
1484
|
+
readonly 'local.math.display.environment-unclosed': 'math.displayEnvironmentUnclosed';
|
|
1485
|
+
readonly 'local.math.display.environment-missing-name': 'math.displayEnvironmentMissingName';
|
|
1486
|
+
readonly 'local.math.display.syntax': 'math.displaySyntax';
|
|
1407
1487
|
readonly 'local.table.header.missing': 'table.missingHeader';
|
|
1408
1488
|
readonly 'local.table.header.interpolation': 'table.headerInterpolation';
|
|
1409
1489
|
readonly 'local.table.header.empty': 'table.headerEmpty';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P0 native HTML tag names. The parser handles these before component tags, and
|
|
3
|
+
* host component schemas may not reuse them because document parsing would
|
|
4
|
+
* never dispatch such a tag to a host component.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LOCAL_HTML_NAMES: ReadonlySet<string>;
|
|
@@ -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';
|
|
@@ -14,7 +15,7 @@ export type { LocalVersionDeclaration } from './types.js';
|
|
|
14
15
|
export type { LocalLocale } from './locale.js';
|
|
15
16
|
export { LOCAL_THEME_PROTOCOL, DEFAULT_LOCAL_THEME, resolveLocalTheme, isLocalThemeName } from './theme.js';
|
|
16
17
|
export type { LocalColorScheme, LocalThemeDefinition, LocalThemeResolution } from './theme.js';
|
|
17
|
-
export type { Diagnostic, LocalDiagnosticParam, LocalDiagnosticParams, SourceRange, LocalValue, LocalValueKind, LocalNode, LocalBinding, LocalComputation, LocalValidation, LocalDocument, LocalHtmlOptions, LocalHtmlPolicy, LocalCompileLimits, LocalCompileOptions, LocalCompileResult, LocalRuntime, LocalSnapshot } from './types.js';
|
|
18
|
+
export type { Diagnostic, LocalDiagnosticParam, LocalDiagnosticParams, SourceRange, LocalValue, LocalValueKind, LocalNode, LocalBinding, LocalComputation, LocalValidation, LocalDocument, LocalHtmlOptions, LocalHtmlPolicy, LocalCompileLimits, LocalCompileOptions, LocalCompileResult, LocalRuntime, LocalSnapshot, LocalHostPropKind, LocalHostPropSchema, LocalHostComponentSchema } from './types.js';
|
|
18
19
|
export { LOCAL_STATE_FORMAT, localSourceDigest, createLocalStateFile, parseLocalState, resolveLocalState, applyLocalState, exportLocalState, importLocalState, serializeLocalState, } from './state.js';
|
|
19
20
|
export type { LocalStateGenerator, LocalStateFile, LocalStateParseResult, LocalStateResolution, } from './state.js';
|
|
20
21
|
export { planLocalStateRetention, applyLocalStateRetention } from './retention.js';
|
|
@@ -41,5 +41,13 @@ export declare const DEFAULT_LOCAL_DATA_TABLE_ROWS = 100;
|
|
|
41
41
|
export declare const MAX_LOCAL_DATA_TABLE_COLUMNS = 20;
|
|
42
42
|
export declare const MAX_LOCAL_DATA_DOCUMENT_ROWS = 2000;
|
|
43
43
|
export declare const MAX_LOCAL_DATA_DOCUMENT_CELLS = 10000;
|
|
44
|
+
/** Host component schemas accepted in one compilation. */
|
|
45
|
+
export declare const MAX_LOCAL_HOST_COMPONENTS = 32;
|
|
46
|
+
/** Host component and property name length, in UTF-16 code units. */
|
|
47
|
+
export declare const MAX_LOCAL_HOST_NAME_LENGTH = 128;
|
|
48
|
+
/** Host property RegExp source length, in UTF-16 code units. */
|
|
49
|
+
export declare const MAX_LOCAL_HOST_PATTERN_LENGTH = 512;
|
|
50
|
+
/** Allowed literals in one host enum property. */
|
|
51
|
+
export declare const MAX_LOCAL_HOST_ENUM_VALUES = 64;
|
|
44
52
|
/** Linear validation; the final dot must have text on both sides in the domain. */
|
|
45
53
|
export declare function isLocalEmail(value: string): boolean;
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
text?: string;
|
|
34
|
+
children?: MathNode[];
|
|
35
|
+
}
|
|
36
|
+
export interface LocalMathDisplayParse {
|
|
37
|
+
/** `null` means the whole formula must be shown as bounded literal text. */
|
|
38
|
+
node: MathNode | null;
|
|
39
|
+
issues: LocalMathDisplayIssue[];
|
|
40
|
+
}
|
|
41
|
+
/** Diagnostic code emitted for every display-compatibility issue. */
|
|
42
|
+
export declare const MATH_DISPLAY_DIAGNOSTIC_CODE = "local.math.display";
|
|
43
|
+
export declare const MATH_DISPLAY_MESSAGE_KEYS: {
|
|
44
|
+
readonly 'unsupported-command': 'local.math.display.unsupported-command';
|
|
45
|
+
readonly 'unsupported-environment': 'local.math.display.unsupported-environment';
|
|
46
|
+
readonly budget: 'local.math.display.budget';
|
|
47
|
+
readonly 'stray-end': 'local.math.display.stray-end';
|
|
48
|
+
readonly 'environment-unclosed': 'local.math.display.environment-unclosed';
|
|
49
|
+
readonly 'environment-missing-name': 'local.math.display.environment-missing-name';
|
|
50
|
+
readonly syntax: 'local.math.display.syntax';
|
|
51
|
+
};
|
|
52
|
+
export declare const MAX_LOCAL_MATH_DISPLAY_SOURCE = 50000;
|
|
53
|
+
export declare const MAX_LOCAL_MATH_DISPLAY_TOKENS = 20000;
|
|
54
|
+
export declare const MAX_LOCAL_MATH_DISPLAY_DEPTH = 120;
|
|
55
|
+
export declare const MAX_LOCAL_MATH_DISPLAY_FALLBACK = 2000;
|
|
56
|
+
/** Bounded literal text used when the whole formula cannot be rendered. */
|
|
57
|
+
export declare function boundedLocalMathLiteral(source: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Parse the formula body once for both rendering and diagnostics.
|
|
60
|
+
*
|
|
61
|
+
* `node === null` means the renderer must fall back to bounded literal text;
|
|
62
|
+
* `issues` then contains exactly one budget or syntax issue.
|
|
63
|
+
*/
|
|
64
|
+
export declare function parseLocalMathDisplay(source: string): LocalMathDisplayParse;
|
|
65
|
+
/**
|
|
66
|
+
* Report every construct that the display renderer degrades to literal text.
|
|
67
|
+
*
|
|
68
|
+
* Offsets are relative to the formula body (`LocalNode.value`). Compute-only
|
|
69
|
+
* limitations (for example `\int` in `<plot>`) are intentionally not reported:
|
|
70
|
+
* they do not affect display.
|
|
71
|
+
*/
|
|
72
|
+
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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LocalCompileOptions, LocalHtmlPolicy } from './types.js';
|
|
1
|
+
import type { LocalCompileOptions, LocalHostComponentSchema, LocalHtmlPolicy } from './types.js';
|
|
2
2
|
/** Capability flags that select the temporary whole-document HTML branch. */
|
|
3
3
|
export declare const LOCAL_HTML_FLAGS: readonly ['enableCss', 'enableJavaScript', 'enableExtendedHtml'];
|
|
4
4
|
export type LocalHtmlFlag = (typeof LOCAL_HTML_FLAGS)[number];
|
|
@@ -10,10 +10,17 @@ 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;
|
|
15
|
+
/** Validated host component schemas; empty when the option is absent. */
|
|
16
|
+
hostComponents: readonly LocalHostComponentSchema[];
|
|
17
|
+
/** Host tag name lookup; names are already lowercase kebab-case. */
|
|
18
|
+
hostByName: ReadonlyMap<string, LocalHostComponentSchema>;
|
|
13
19
|
} | {
|
|
14
20
|
ok: false;
|
|
15
21
|
message: string;
|
|
16
22
|
key: string;
|
|
23
|
+
detail?: string;
|
|
17
24
|
};
|
|
18
25
|
/**
|
|
19
26
|
* Read and validate host compile options once. Every call site (Markdown
|
|
@@ -26,4 +33,4 @@ export declare function readLocalCompileOptions(options: LocalCompileOptions | u
|
|
|
26
33
|
* recompile on flag/limit changes and to keep worker races keyed by more than
|
|
27
34
|
* the source text. Unknown keys are deliberately ignored.
|
|
28
35
|
*/
|
|
29
|
-
export declare function localCompileOptionsKey(options
|
|
36
|
+
export declare function localCompileOptionsKey(options?: LocalCompileOptions): string;
|
|
@@ -14,3 +14,14 @@ export interface LocalVisualProps extends Omit<LocalRenderContext, 'mode'> {
|
|
|
14
14
|
/** Defaults to interactive so hand-built visual fixtures stay compatible. */
|
|
15
15
|
mode?: LocalRenderMode;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* JSON-safe host data indexed by `${kind}:${ref}` for `hostComponent` nodes.
|
|
19
|
+
* It is read only by the client renderer and never enters the worker.
|
|
20
|
+
*/
|
|
21
|
+
export type LocalHostData = Readonly<Record<string, unknown>>;
|
|
22
|
+
/**
|
|
23
|
+
* Client-only renderer for `hostComponent` nodes. Receiving `unknown` keeps the
|
|
24
|
+
* contract loose; a synchronous throw falls back to the inert placeholder, so
|
|
25
|
+
* a bad renderer never blanks the whole document.
|
|
26
|
+
*/
|
|
27
|
+
export type LocalHostRenderer = (node: LocalNode, data: unknown, ctx: LocalRenderContext) => ReactNode;
|
|
@@ -187,8 +187,36 @@ export interface LocalHtmlPolicy {
|
|
|
187
187
|
readonly enableJavaScript: boolean;
|
|
188
188
|
readonly enableExtendedHtml: boolean;
|
|
189
189
|
}
|
|
190
|
+
export type LocalHostPropKind = 'string' | 'number' | 'boolean' | 'enum';
|
|
191
|
+
export interface LocalHostPropSchema {
|
|
192
|
+
readonly kind: LocalHostPropKind;
|
|
193
|
+
readonly required?: boolean;
|
|
194
|
+
/** Reject `{{ ... }}` in this property. */
|
|
195
|
+
readonly static?: boolean;
|
|
196
|
+
/** Allowed literals for kind 'enum'; required and non-empty for enums. */
|
|
197
|
+
readonly enum?: readonly string[];
|
|
198
|
+
/** RegExp source applied to literal string values; restricted to a linear-time-safe subset. */
|
|
199
|
+
readonly pattern?: string;
|
|
200
|
+
}
|
|
201
|
+
export interface LocalHostComponentSchema {
|
|
202
|
+
readonly name: string;
|
|
203
|
+
readonly form: 'leaf';
|
|
204
|
+
readonly props: Readonly<Record<string, LocalHostPropSchema>>;
|
|
205
|
+
}
|
|
190
206
|
export interface LocalCompileOptions extends LocalHtmlOptions {
|
|
191
207
|
readonly limits?: LocalCompileLimits;
|
|
208
|
+
/**
|
|
209
|
+
* Render ordinary Markdown soft line breaks as `<br>`.
|
|
210
|
+
*
|
|
211
|
+
* Defaults to `false`, which keeps the historical behavior where a soft
|
|
212
|
+
* break is ordinary collapsible whitespace. When `true`, each source soft
|
|
213
|
+
* break becomes a `break` node; explicit hard breaks, code, formulas and
|
|
214
|
+
* native HTML are left untouched. The source text is never rewritten, so
|
|
215
|
+
* every node keeps its original offsets.
|
|
216
|
+
*/
|
|
217
|
+
readonly markdownBreaks?: boolean;
|
|
218
|
+
/** Host-defined leaf components recognized alongside the built-in schema. */
|
|
219
|
+
readonly hostComponents?: readonly LocalHostComponentSchema[];
|
|
192
220
|
}
|
|
193
221
|
export type LocalCompileResult = {
|
|
194
222
|
ok: true;
|
|
@@ -4,7 +4,11 @@ export declare const LOCAL_COMPILE_DELAY_MS = 150;
|
|
|
4
4
|
export interface LocalCompileRequest {
|
|
5
5
|
id: number;
|
|
6
6
|
source: string;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
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.
|
|
11
|
+
*/
|
|
8
12
|
options?: LocalCompileOptions;
|
|
9
13
|
}
|
|
10
14
|
export type LocalCompileResponse = {
|
|
@@ -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 } 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';
|