reactive-md 0.5.0 → 0.5.2
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 +34 -0
- package/CHANGELOG.md +34 -0
- package/README-ch.md +10 -7
- package/README-en.md +12 -7
- package/README.md +12 -7
- package/SECURITY-ch.md +4 -3
- package/SECURITY.md +4 -3
- package/THIRD_PARTY_NOTICES.md +45 -1
- package/dist-library/reactive-md-editor.css +1 -1
- package/dist-library/reactive-md-editor.js +739 -615
- package/dist-library/reactive-md-react.js +2111 -1903
- package/dist-library/reactive-md.js +462 -326
- package/dist-library/{runtime-DPuMxM_y.js → runtime-UiQPz5ZV.js} +8780 -2718
- package/dist-library/types/editor/editor-i18n.d.ts +7 -0
- package/dist-library/types/editor/editor-view-bar.d.ts +11 -0
- package/dist-library/types/editor/index.d.ts +1 -1
- package/dist-library/types/editor/types.d.ts +8 -1
- package/dist-library/types/local/LocalDocumentView.d.ts +19 -4
- package/dist-library/types/local/code-block.d.ts +3 -1
- package/dist-library/types/local/diagnostics.d.ts +65 -0
- package/dist-library/types/local/heading-anchors.d.ts +2 -0
- package/dist-library/types/local/html-names.d.ts +6 -0
- package/dist-library/types/local/html.d.ts +16 -0
- package/dist-library/types/local/image-view.d.ts +3 -1
- package/dist-library/types/local/index.d.ts +1 -1
- package/dist-library/types/local/limits.d.ts +8 -0
- package/dist-library/types/local/options.d.ts +34 -0
- package/dist-library/types/local/render-types.d.ts +11 -0
- package/dist-library/types/local/types.d.ts +53 -1
- package/dist-library/types/local/worker.d.ts +21 -6
- package/dist-library/types/react/index.d.ts +1 -1
- package/dist-library/types/shareable.d.ts +9 -1
- package/dist-standalone/reactive-md-standalone.js +49 -49
- package/docs/compatibility-ch.md +8 -6
- package/docs/compatibility-en.md +8 -6
- 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 +235 -216
- package/docs/editor-en.md +235 -216
- package/docs/html-compatibility-ch.md +98 -0
- package/docs/html-compatibility-en.md +98 -0
- package/docs/local-integration-ch.md +29 -2
- package/docs/local-integration-en.md +29 -2
- package/docs/local-interaction-syntax-ch.md +3 -1
- package/docs/local-interaction-syntax-en.md +1 -1
- package/docs/release-0.5.1-ch.md +39 -0
- package/docs/release-0.5.1-en.md +39 -0
- package/docs/release-0.5.2-ch.md +35 -0
- package/docs/release-0.5.2-en.md +35 -0
- package/docs/releasing-ch.md +7 -7
- package/docs/releasing-en.md +8 -8
- package/docs/shareable-export-ch.md +2 -0
- package/docs/shareable-export-en.md +2 -0
- package/examples/conformance/README.md +1 -1
- package/examples/local/README.md +2 -0
- package/examples/local/html-compat.reactive.md +24 -0
- package/package.json +3 -1
|
@@ -95,6 +95,13 @@ export interface EditorChromeCopy {
|
|
|
95
95
|
/** Accessible name for the textarea when the host passes no ariaLabel. */
|
|
96
96
|
sourceLabel: string;
|
|
97
97
|
region: string;
|
|
98
|
+
previewRegion: string;
|
|
99
|
+
viewLabel: string;
|
|
100
|
+
count(value: string): string;
|
|
101
|
+
keyboardHint: string;
|
|
102
|
+
edit: string;
|
|
103
|
+
split: string;
|
|
104
|
+
preview: string;
|
|
98
105
|
}
|
|
99
106
|
export declare const EDITOR_CHROME_COPY: Record<EditorLocale, EditorChromeCopy>;
|
|
100
107
|
export declare const EDITOR_COMMAND_COPY: Record<EditorLocale, EditorCommandCopy>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EditorViewMode } from './types.js';
|
|
2
|
+
export declare function EditorViewBar({ source, mode, onModeChange, sourceId, previewId, hasPreview, allowSplit, toolbar }: {
|
|
3
|
+
source: string;
|
|
4
|
+
mode: EditorViewMode;
|
|
5
|
+
onModeChange(mode: EditorViewMode): void;
|
|
6
|
+
sourceId: string;
|
|
7
|
+
previewId: string;
|
|
8
|
+
hasPreview: boolean;
|
|
9
|
+
allowSplit: boolean;
|
|
10
|
+
toolbar: boolean;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* for the stylesheet, or use `./library` for the CSS-included bundle.
|
|
7
7
|
*/
|
|
8
8
|
export { ReactiveMarkdownEditor } from './ReactiveMarkdownEditor.js';
|
|
9
|
-
export type { EditorEdit, EditorLocale, EditorSelection, EditorTheme, ReactiveMarkdownEditorHandle, ReactiveMarkdownEditorProps, } from './types.js';
|
|
9
|
+
export type { EditorEdit, EditorLocale, EditorSelection, EditorTheme, EditorViewMode, ReactiveMarkdownEditorHandle, ReactiveMarkdownEditorProps, } from './types.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { CSSProperties, RefObject } from 'react';
|
|
1
|
+
import type { CSSProperties, ReactNode, RefObject } from 'react';
|
|
2
2
|
import type { Diagnostic, LocalDocument, SourceRange } from '../local/types.js';
|
|
3
3
|
export type EditorLocale = 'en' | 'zh';
|
|
4
4
|
export type EditorTheme = 'light' | 'dark' | 'auto';
|
|
5
|
+
export type EditorViewMode = 'edit' | 'split' | 'preview';
|
|
5
6
|
export interface EditorSelection {
|
|
6
7
|
start: number;
|
|
7
8
|
end: number;
|
|
@@ -15,6 +16,12 @@ export interface ReactiveMarkdownEditorProps {
|
|
|
15
16
|
onChange(value: string): void;
|
|
16
17
|
locale?: EditorLocale;
|
|
17
18
|
theme?: EditorTheme;
|
|
19
|
+
/** Preview content rendered inside the editor frame. Enables view switching. */
|
|
20
|
+
preview?: ReactNode;
|
|
21
|
+
/** Controlled view mode; omit to let the editor manage its own mode. */
|
|
22
|
+
viewMode?: EditorViewMode;
|
|
23
|
+
defaultViewMode?: EditorViewMode;
|
|
24
|
+
onViewModeChange?(mode: EditorViewMode): void;
|
|
18
25
|
id?: string;
|
|
19
26
|
className?: string;
|
|
20
27
|
style?: CSSProperties;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import type { Diagnostic, LocalDocument, LocalNode, LocalRuntime } from './types.js';
|
|
3
|
-
import type { LocalRenderMode } from './render-types.js';
|
|
2
|
+
import type { Diagnostic, LocalCompileOptions, LocalDocument, LocalNode, LocalRuntime } from './types.js';
|
|
3
|
+
import type { LocalHostData, LocalHostRenderer, LocalRenderMode } from './render-types.js';
|
|
4
4
|
import { type LocalColorScheme, type LocalThemeDefinition } from './theme.js';
|
|
5
5
|
import { type LocalLocale, type Localize } from './i18n.js';
|
|
6
6
|
/**
|
|
@@ -42,6 +42,10 @@ export interface LocalDocumentViewProps {
|
|
|
42
42
|
staticFirst?: boolean;
|
|
43
43
|
/** Trusted image URL mapping; only called after the image URL passed validation. */
|
|
44
44
|
imageResolver?: LocalImageResolver;
|
|
45
|
+
/** JSON-safe host data keyed by `${kind}:${ref}`; never enters the worker. */
|
|
46
|
+
hostData?: LocalHostData;
|
|
47
|
+
/** Client-only renderer for hostComponent nodes; never enters the worker. */
|
|
48
|
+
hostRenderer?: LocalHostRenderer;
|
|
45
49
|
}
|
|
46
50
|
export interface LocalReactiveDocumentProps {
|
|
47
51
|
source: string;
|
|
@@ -59,6 +63,16 @@ export interface LocalReactiveDocumentProps {
|
|
|
59
63
|
staticFirst?: boolean;
|
|
60
64
|
/** Trusted image URL mapping forwarded to `LocalDocumentView`. */
|
|
61
65
|
imageResolver?: LocalImageResolver;
|
|
66
|
+
/** JSON-safe host data keyed by `${kind}:${ref}`; never enters the worker. */
|
|
67
|
+
hostData?: LocalHostData;
|
|
68
|
+
/** Client-only renderer for hostComponent nodes; never enters the worker. */
|
|
69
|
+
hostRenderer?: LocalHostRenderer;
|
|
70
|
+
/**
|
|
71
|
+
* Host-owned compile options. HTML capability flags select the temporary
|
|
72
|
+
* whole-document native branch; the component recompiles when a flag or the
|
|
73
|
+
* node budget changes, but not when an equal object is recreated.
|
|
74
|
+
*/
|
|
75
|
+
compileOptions?: LocalCompileOptions;
|
|
62
76
|
}
|
|
63
77
|
interface LocalComponentProps {
|
|
64
78
|
node: LocalNode;
|
|
@@ -77,6 +91,7 @@ export declare function textProblem(value: string, options: {
|
|
|
77
91
|
email?: boolean;
|
|
78
92
|
}, t?: Localize): string | null;
|
|
79
93
|
export declare const COMPONENTS: Record<string, (props: LocalComponentProps) => ReactNode>;
|
|
80
|
-
|
|
81
|
-
export declare function
|
|
94
|
+
/** Keep the two render paths in separate components so mode changes obey hook ordering. */
|
|
95
|
+
export declare function LocalDocumentView(props: LocalDocumentViewProps): import("react").JSX.Element;
|
|
96
|
+
export declare function LocalReactiveDocument({ source, onDiagnostics, urlPolicy, locale, themes, colorScheme, mode, staticFirst, imageResolver, hostData, hostRenderer, compileOptions, }: LocalReactiveDocumentProps): import("react").JSX.Element;
|
|
82
97
|
export {};
|
|
@@ -20,5 +20,7 @@ export interface CodeBlockViewProps {
|
|
|
20
20
|
value: string;
|
|
21
21
|
language?: string;
|
|
22
22
|
mode: 'interactive' | 'static';
|
|
23
|
+
/** Renderer-validated P0 HTML attributes, never raw source attributes. */
|
|
24
|
+
htmlProps?: Record<string, string>;
|
|
23
25
|
}
|
|
24
|
-
export declare function CodeBlockView({ value, language, mode }: CodeBlockViewProps): ReactElement;
|
|
26
|
+
export declare function CodeBlockView({ value, language, mode, htmlProps }: CodeBlockViewProps): ReactElement;
|
|
@@ -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: '主题名称必须是静态文本,不能是表达式。';
|
|
@@ -226,6 +230,26 @@ export declare const LOCAL_DIAGNOSTIC_MESSAGES: {
|
|
|
226
230
|
readonly en: 'Raw HTML is not part of the local interaction syntax.';
|
|
227
231
|
readonly zh: '原始 HTML 不属于本地交互语法。';
|
|
228
232
|
};
|
|
233
|
+
readonly 'html.extended': {
|
|
234
|
+
readonly en: 'HTML element <{name}> requires enableExtendedHtml in this mode; it is shown as source.';
|
|
235
|
+
readonly zh: '此模式下 HTML 元素 <{name}> 需要启用 enableExtendedHtml;已按源码显示。';
|
|
236
|
+
};
|
|
237
|
+
readonly 'html.attribute': {
|
|
238
|
+
readonly en: 'HTML attribute {name} on <{tag}> is not supported; the element is shown as source.';
|
|
239
|
+
readonly zh: '<{tag}> 上的 HTML 属性 {name} 不受支持;该元素已按源码显示。';
|
|
240
|
+
};
|
|
241
|
+
readonly 'html.unsafeUrl': {
|
|
242
|
+
readonly en: 'Unsafe URL in attribute {name} was removed.';
|
|
243
|
+
readonly zh: '属性 {name} 中的不安全 URL 已移除。';
|
|
244
|
+
};
|
|
245
|
+
readonly 'html.capability': {
|
|
246
|
+
readonly en: 'Author {feature} was disabled by the compile options.';
|
|
247
|
+
readonly zh: '编译选项已禁用作者提供的{feature}。';
|
|
248
|
+
};
|
|
249
|
+
readonly 'options.htmlFlag': {
|
|
250
|
+
readonly en: 'Compile option {name} must be a boolean.';
|
|
251
|
+
readonly zh: '编译选项 {name} 必须是布尔值。';
|
|
252
|
+
};
|
|
229
253
|
readonly 'component.unknownSuggestion': {
|
|
230
254
|
readonly en: 'Unknown component <{name}>. Did you mean <{suggestion}>?';
|
|
231
255
|
readonly zh: '未知组件 <{name}>。是否想使用 <{suggestion}>?';
|
|
@@ -270,6 +294,34 @@ export declare const LOCAL_DIAGNOSTIC_MESSAGES: {
|
|
|
270
294
|
readonly en: 'Attribute {name} is static and cannot contain interpolations.';
|
|
271
295
|
readonly zh: '属性 {name} 是静态的,不能包含插值。';
|
|
272
296
|
};
|
|
297
|
+
readonly 'host.attributeUnknown': {
|
|
298
|
+
readonly en: 'Component <{component}> does not support attribute {name}.';
|
|
299
|
+
readonly zh: '组件 <{component}> 不支持属性 {name}。';
|
|
300
|
+
};
|
|
301
|
+
readonly 'host.attributeRequired': {
|
|
302
|
+
readonly en: 'Component <{component}> is missing required attribute {name}.';
|
|
303
|
+
readonly zh: '组件 <{component}> 缺少必需属性 {name}。';
|
|
304
|
+
};
|
|
305
|
+
readonly 'host.attributeStatic': {
|
|
306
|
+
readonly en: 'Attribute {name} is static and cannot contain interpolations.';
|
|
307
|
+
readonly zh: '属性 {name} 是静态的,不能包含插值。';
|
|
308
|
+
};
|
|
309
|
+
readonly 'host.attributeType': {
|
|
310
|
+
readonly en: 'Attribute {name} requires a {kind}, got "{value}".';
|
|
311
|
+
readonly zh: '属性 {name} 需要 {kind},当前为“{value}”。';
|
|
312
|
+
};
|
|
313
|
+
readonly 'host.attributeEnum': {
|
|
314
|
+
readonly en: 'Attribute {name} must be one of {values}, got "{value}".';
|
|
315
|
+
readonly zh: '属性 {name} 必须是 {values} 之一,当前为“{value}”。';
|
|
316
|
+
};
|
|
317
|
+
readonly 'host.attributePattern': {
|
|
318
|
+
readonly en: 'Attribute {name} must match pattern {pattern}.';
|
|
319
|
+
readonly zh: '属性 {name} 必须匹配模式 {pattern}。';
|
|
320
|
+
};
|
|
321
|
+
readonly 'host.attributeInterpolation': {
|
|
322
|
+
readonly en: 'Attribute {name} must be a literal matching {pattern} or one full interpolation.';
|
|
323
|
+
readonly zh: '属性 {name} 必须是匹配 {pattern} 的字面值,或一个完整插值。';
|
|
324
|
+
};
|
|
273
325
|
readonly 'expression.emptyAttribute': {
|
|
274
326
|
readonly en: 'Attribute {name} interpolation cannot be empty.';
|
|
275
327
|
readonly zh: '属性 {name} 的插值不能为空。';
|
|
@@ -1189,6 +1241,7 @@ declare const LOCAL_DIAGNOSTIC_TEMPLATE_ALIASES: {
|
|
|
1189
1241
|
readonly 'local.options.invalid.object': 'options.notObject';
|
|
1190
1242
|
readonly 'local.options.invalid.limits': 'options.limitsNotObject';
|
|
1191
1243
|
readonly 'local.options.invalid.max-syntax-nodes': 'options.maxSyntaxNodes';
|
|
1244
|
+
readonly 'local.options.invalid.host-components': 'options.hostComponents';
|
|
1192
1245
|
readonly 'local.budget.document': 'budget.document';
|
|
1193
1246
|
readonly 'local.budget.nodes': 'budget.syntaxNodes';
|
|
1194
1247
|
readonly 'local.budget.nesting': 'budget.nesting';
|
|
@@ -1241,6 +1294,11 @@ declare const LOCAL_DIAGNOSTIC_TEMPLATE_ALIASES: {
|
|
|
1241
1294
|
readonly 'local.math.whitespace': 'math.whitespace';
|
|
1242
1295
|
readonly 'local.footnote.unsupported': 'footnote.unsupported';
|
|
1243
1296
|
readonly 'local.html': 'html.raw';
|
|
1297
|
+
readonly 'local.html.extended': 'html.extended';
|
|
1298
|
+
readonly 'local.html.attribute': 'html.attribute';
|
|
1299
|
+
readonly 'local.html.unsafe-url': 'html.unsafeUrl';
|
|
1300
|
+
readonly 'local.html.capability': 'html.capability';
|
|
1301
|
+
readonly 'local.options.invalid.html-flag': 'options.htmlFlag';
|
|
1244
1302
|
readonly 'local.component.unknown.suggestion': 'component.unknownSuggestion';
|
|
1245
1303
|
readonly 'local.component.unknown': 'component.unknownPlain';
|
|
1246
1304
|
readonly 'local.attribute.format': 'attribute.lowercase';
|
|
@@ -1254,6 +1312,13 @@ declare const LOCAL_DIAGNOSTIC_TEMPLATE_ALIASES: {
|
|
|
1254
1312
|
readonly 'local.attribute.color': 'attribute.color';
|
|
1255
1313
|
readonly 'local.attribute.required': 'attribute.required';
|
|
1256
1314
|
readonly 'local.attribute.static': 'attribute.static';
|
|
1315
|
+
readonly 'local.host.attribute.unknown': 'host.attributeUnknown';
|
|
1316
|
+
readonly 'local.host.attribute.required': 'host.attributeRequired';
|
|
1317
|
+
readonly 'local.host.attribute.static': 'host.attributeStatic';
|
|
1318
|
+
readonly 'local.host.attribute.type': 'host.attributeType';
|
|
1319
|
+
readonly 'local.host.attribute.enum': 'host.attributeEnum';
|
|
1320
|
+
readonly 'local.host.attribute.pattern': 'host.attributePattern';
|
|
1321
|
+
readonly 'local.host.attribute.interpolation': 'host.attributeInterpolation';
|
|
1257
1322
|
readonly 'local.attribute.type.number': 'attribute.numberInvalid';
|
|
1258
1323
|
readonly 'local.attribute.type.number-interpolation': 'attribute.numberInterpolationInvalid';
|
|
1259
1324
|
readonly 'local.attribute.type.integer': 'attribute.integer';
|
|
@@ -11,7 +11,9 @@ import type { LocalDocument, LocalNode } from './types.js';
|
|
|
11
11
|
export declare function createHeadingAnchors(document: LocalDocument, namespace: string, includeExplicitAnchors?: boolean): {
|
|
12
12
|
ids: Map<LocalNode, string>;
|
|
13
13
|
anchorIds: Map<LocalNode, string>;
|
|
14
|
+
htmlIds: Map<LocalNode, string>;
|
|
14
15
|
/** Namespaced DOM id for a static jump/anchor target slug, if it exists. */
|
|
15
16
|
targetId(to: string): string | undefined;
|
|
17
|
+
referenceId(to: string): string;
|
|
16
18
|
resolve(href: string): string;
|
|
17
19
|
};
|
|
@@ -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>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Diagnostic, LocalHtmlPolicy } from './types.js';
|
|
2
|
+
export interface LocalHtmlSanitizeResult {
|
|
3
|
+
markup: string;
|
|
4
|
+
diagnostics: Diagnostic[];
|
|
5
|
+
}
|
|
6
|
+
/** The sandbox always keeps author documents separate from their host. */
|
|
7
|
+
export declare function localHtmlSandbox(policy: LocalHtmlPolicy): string;
|
|
8
|
+
/** Resources stay offline; extended HTML permits explicit HTTP(S) form submissions. */
|
|
9
|
+
export declare function localHtmlContentSecurityPolicy(policy: LocalHtmlPolicy): string;
|
|
10
|
+
/**
|
|
11
|
+
* Parse, sanitize and serialize a whole native HTML document. The result is a
|
|
12
|
+
* complete document string suitable for a sandboxed `srcdoc` iframe.
|
|
13
|
+
*/
|
|
14
|
+
export declare function sanitizeLocalHtmlDocument(source: string, policy: LocalHtmlPolicy, maxSyntaxNodes: number): LocalHtmlSanitizeResult;
|
|
15
|
+
export declare const LOCAL_HTML_P0_ELEMENTS: Set<string>;
|
|
16
|
+
export declare const LOCAL_HTML_VOID_ELEMENTS: Set<string>;
|
|
@@ -12,10 +12,12 @@ import { type RefObject } from 'react';
|
|
|
12
12
|
* is a button only when it is not already wrapped in a Markdown link; a
|
|
13
13
|
* link-wrapped image keeps the anchor's navigation and has no extra tab stop.
|
|
14
14
|
*/
|
|
15
|
-
export declare function ZoomableImage({ src, alt, title, mode, rootRef, }: {
|
|
15
|
+
export declare function ZoomableImage({ src, alt, title, mode, rootRef, imageProps, }: {
|
|
16
16
|
src: string;
|
|
17
17
|
alt: string;
|
|
18
18
|
title?: string;
|
|
19
19
|
mode: 'interactive' | 'static';
|
|
20
20
|
rootRef: RefObject<HTMLElement | null>;
|
|
21
|
+
/** Validated source attributes for P0 HTML images; zoom behaviour is shared. */
|
|
22
|
+
imageProps?: Record<string, string | number | undefined>;
|
|
21
23
|
}): import("react").JSX.Element;
|
|
@@ -14,7 +14,7 @@ export type { LocalVersionDeclaration } from './types.js';
|
|
|
14
14
|
export type { LocalLocale } from './locale.js';
|
|
15
15
|
export { LOCAL_THEME_PROTOCOL, DEFAULT_LOCAL_THEME, resolveLocalTheme, isLocalThemeName } from './theme.js';
|
|
16
16
|
export type { LocalColorScheme, LocalThemeDefinition, LocalThemeResolution } from './theme.js';
|
|
17
|
-
export type { Diagnostic, LocalDiagnosticParam, LocalDiagnosticParams, SourceRange, LocalValue, LocalValueKind, LocalNode, LocalBinding, LocalComputation, LocalValidation, LocalDocument, LocalCompileLimits, LocalCompileOptions, LocalCompileResult, LocalRuntime, LocalSnapshot } from './types.js';
|
|
17
|
+
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
18
|
export { LOCAL_STATE_FORMAT, localSourceDigest, createLocalStateFile, parseLocalState, resolveLocalState, applyLocalState, exportLocalState, importLocalState, serializeLocalState, } from './state.js';
|
|
19
19
|
export type { LocalStateGenerator, LocalStateFile, LocalStateParseResult, LocalStateResolution, } from './state.js';
|
|
20
20
|
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,34 @@
|
|
|
1
|
+
import type { LocalCompileOptions, LocalHostComponentSchema, LocalHtmlPolicy } from './types.js';
|
|
2
|
+
/** Capability flags that select the temporary whole-document HTML branch. */
|
|
3
|
+
export declare const LOCAL_HTML_FLAGS: readonly ['enableCss', 'enableJavaScript', 'enableExtendedHtml'];
|
|
4
|
+
export type LocalHtmlFlag = (typeof LOCAL_HTML_FLAGS)[number];
|
|
5
|
+
export type LocalOptionCheck = {
|
|
6
|
+
ok: true;
|
|
7
|
+
/** Validated syntax-node budget for this compilation. */
|
|
8
|
+
maxSyntaxNodes: number;
|
|
9
|
+
/** Effective HTML policy; every flag is false by default. */
|
|
10
|
+
html: LocalHtmlPolicy;
|
|
11
|
+
/** True when at least one capability flag is enabled. */
|
|
12
|
+
htmlActive: boolean;
|
|
13
|
+
/** Validated host component schemas; empty when the option is absent. */
|
|
14
|
+
hostComponents: readonly LocalHostComponentSchema[];
|
|
15
|
+
/** Host tag name lookup; names are already lowercase kebab-case. */
|
|
16
|
+
hostByName: ReadonlyMap<string, LocalHostComponentSchema>;
|
|
17
|
+
} | {
|
|
18
|
+
ok: false;
|
|
19
|
+
message: string;
|
|
20
|
+
key: string;
|
|
21
|
+
detail?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Read and validate host compile options once. Every call site (Markdown
|
|
25
|
+
* parser, HTML compiler, worker and React component) uses the same rules so a
|
|
26
|
+
* malformed flag can never silently fall back to the Markdown pipeline.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readLocalCompileOptions(options: LocalCompileOptions | undefined): LocalOptionCheck;
|
|
29
|
+
/**
|
|
30
|
+
* Stable signature of the option values that affect compilation. Used to
|
|
31
|
+
* recompile on flag/limit changes and to keep worker races keyed by more than
|
|
32
|
+
* the source text. Unknown keys are deliberately ignored.
|
|
33
|
+
*/
|
|
34
|
+
export declare function localCompileOptionsKey(options: LocalCompileOptions | undefined): 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;
|
|
@@ -44,6 +44,10 @@ export interface LocalNode {
|
|
|
44
44
|
url?: string;
|
|
45
45
|
title?: string | null;
|
|
46
46
|
alt?: string;
|
|
47
|
+
/** Rendered width of an HTML `<img>`, in CSS pixels. */
|
|
48
|
+
width?: number;
|
|
49
|
+
/** Rendered height of an HTML `<img>`, in CSS pixels. */
|
|
50
|
+
height?: number;
|
|
47
51
|
lang?: string;
|
|
48
52
|
align?: ('left' | 'center' | 'right' | null)[];
|
|
49
53
|
/**
|
|
@@ -104,6 +108,13 @@ export interface LocalDocument {
|
|
|
104
108
|
source: string;
|
|
105
109
|
/** Effective syntax revision; absent on older hand-built runtime documents. */
|
|
106
110
|
syntaxVersion?: 'local-draft-2';
|
|
111
|
+
/**
|
|
112
|
+
* Present only when at least one HTML capability flag was enabled. Its
|
|
113
|
+
* presence routes rendering to the isolated native-HTML branch; the
|
|
114
|
+
* original source is preserved and `nodes` carries one `htmlDocument` node
|
|
115
|
+
* whose `value` is the sanitized, complete iframe document.
|
|
116
|
+
*/
|
|
117
|
+
html?: LocalHtmlPolicy;
|
|
107
118
|
versionDeclaration?: LocalVersionDeclaration;
|
|
108
119
|
nodes: LocalNode[];
|
|
109
120
|
initialState: Record<string, LocalValue>;
|
|
@@ -153,8 +164,49 @@ export interface LocalCompileLimits {
|
|
|
153
164
|
/** Positive safe integer; defaults to 10,000 cumulative LocalNode creations. */
|
|
154
165
|
readonly maxSyntaxNodes?: number;
|
|
155
166
|
}
|
|
156
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Host-owned capability flags for the temporary whole-document HTML mode.
|
|
169
|
+
*
|
|
170
|
+
* All flags default to `false`. When every flag is false the existing
|
|
171
|
+
* Markdown/ReactiveMD pipeline runs unchanged. When any flag is true the whole
|
|
172
|
+
* source is interpreted as native HTML and rendered inside a sandboxed iframe;
|
|
173
|
+
* Markdown, interpolation, bindings, formulas and ReactiveMD components are not
|
|
174
|
+
* interpreted in that mode.
|
|
175
|
+
*/
|
|
176
|
+
export interface LocalHtmlOptions {
|
|
177
|
+
/** Allow authored CSS; external resources remain subject to the native CSP. */
|
|
178
|
+
readonly enableCss?: boolean;
|
|
179
|
+
/** Allow authored scripts and inline event handlers. */
|
|
180
|
+
readonly enableJavaScript?: boolean;
|
|
181
|
+
/** Allow HTML beyond the safe P0 subset (tables, forms, SVG/MathML, ...). */
|
|
182
|
+
readonly enableExtendedHtml?: boolean;
|
|
183
|
+
}
|
|
184
|
+
/** Effective, non-optional policy recorded on a compiled HTML-branch document. */
|
|
185
|
+
export interface LocalHtmlPolicy {
|
|
186
|
+
readonly enableCss: boolean;
|
|
187
|
+
readonly enableJavaScript: boolean;
|
|
188
|
+
readonly enableExtendedHtml: boolean;
|
|
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
|
+
}
|
|
206
|
+
export interface LocalCompileOptions extends LocalHtmlOptions {
|
|
157
207
|
readonly limits?: LocalCompileLimits;
|
|
208
|
+
/** Host-defined leaf components recognized alongside the built-in schema. */
|
|
209
|
+
readonly hostComponents?: readonly LocalHostComponentSchema[];
|
|
158
210
|
}
|
|
159
211
|
export type LocalCompileResult = {
|
|
160
212
|
ok: true;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import type { Diagnostic, LocalCompileResult } from './types.js';
|
|
1
|
+
import type { Diagnostic, LocalCompileOptions, LocalCompileResult } from './types.js';
|
|
2
2
|
/** Editors are coalesced for this long before a compile is dispatched. */
|
|
3
3
|
export declare const LOCAL_COMPILE_DELAY_MS = 150;
|
|
4
4
|
export interface LocalCompileRequest {
|
|
5
5
|
id: number;
|
|
6
6
|
source: string;
|
|
7
|
+
/**
|
|
8
|
+
* Capability flags, limits and host component schemas for this compile.
|
|
9
|
+
* `hostComponents` selects the host leaf tags the parser may build.
|
|
10
|
+
*/
|
|
11
|
+
options?: LocalCompileOptions;
|
|
7
12
|
}
|
|
8
13
|
export type LocalCompileResponse = {
|
|
9
14
|
id: number;
|
|
@@ -32,11 +37,16 @@ export interface LocalCompileOutcome {
|
|
|
32
37
|
result: LocalCompileResult;
|
|
33
38
|
duration: number;
|
|
34
39
|
mode: LocalCompileMode;
|
|
40
|
+
/** Snapshot of the options this result was compiled with, when supplied. */
|
|
41
|
+
options?: LocalCompileOptions;
|
|
35
42
|
}
|
|
36
43
|
export interface LocalCompileSchedulerOptions {
|
|
37
44
|
createWorker(): LocalCompileWorker;
|
|
38
|
-
/**
|
|
39
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Defaults to compileLocal. Runs on the main thread only when the worker is
|
|
47
|
+
* unavailable or failed. One-argument callbacks remain supported.
|
|
48
|
+
*/
|
|
49
|
+
fallbackCompile?(source: string, options?: LocalCompileOptions): LocalCompileResult;
|
|
40
50
|
onResult(outcome: LocalCompileOutcome): void;
|
|
41
51
|
onPendingChange?(pending: boolean): void;
|
|
42
52
|
onModeChange?(mode: LocalCompileMode, detail?: string): void;
|
|
@@ -52,14 +62,19 @@ export declare class LocalCompileScheduler {
|
|
|
52
62
|
private readonly delay;
|
|
53
63
|
private worker;
|
|
54
64
|
private timer;
|
|
55
|
-
private
|
|
65
|
+
private queued;
|
|
56
66
|
private inFlight;
|
|
57
67
|
private nextId;
|
|
58
68
|
private pending;
|
|
59
69
|
private disposed;
|
|
60
70
|
constructor(options: LocalCompileSchedulerOptions);
|
|
61
|
-
/**
|
|
62
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Queue the newest source and its compile options; the previous timer, if
|
|
73
|
+
* any, is replaced. Options are copied so a later mutation cannot change the
|
|
74
|
+
* permissions of an in-flight compile. An options-only edit still supersedes
|
|
75
|
+
* an older result for the same source.
|
|
76
|
+
*/
|
|
77
|
+
schedule(source: string, options?: LocalCompileOptions): void;
|
|
63
78
|
/** Stop the timer and terminate the worker. No callbacks fire afterwards. */
|
|
64
79
|
dispose(): void;
|
|
65
80
|
private drain;
|
|
@@ -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, 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';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type LocalStateFile, type LocalStateGenerator } from './local/state.js';
|
|
2
|
-
import type { Diagnostic, LocalDocument, LocalValue } from './local/types.js';
|
|
2
|
+
import type { Diagnostic, LocalCompileOptions, LocalDocument, LocalValue } from './local/types.js';
|
|
3
3
|
/** Version of the single-file HTML envelope, not of the document syntax. */
|
|
4
4
|
export declare const SHAREABLE_HTML_FORMAT: 'reactive-md-html/v1';
|
|
5
5
|
export type ShareableHtmlMode = 'interactive' | 'static';
|
|
@@ -12,6 +12,8 @@ export interface ShareableMountPayload {
|
|
|
12
12
|
locale: 'en' | 'zh';
|
|
13
13
|
colorScheme: 'light' | 'dark' | 'auto';
|
|
14
14
|
hydrate: boolean;
|
|
15
|
+
/** Capability flags and limits the document was compiled with. */
|
|
16
|
+
compileOptions?: LocalCompileOptions;
|
|
15
17
|
/** Verified relative image URL -> inline raster data URL. */
|
|
16
18
|
images?: Readonly<Record<string, string>>;
|
|
17
19
|
}
|
|
@@ -37,6 +39,12 @@ export interface ShareableHtmlOptions {
|
|
|
37
39
|
images?: Readonly<Record<string, string>>;
|
|
38
40
|
notices?: string;
|
|
39
41
|
targetId?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Routing capabilities granted by the host and used to compile this exact
|
|
44
|
+
* document. Interactive exports replay them; static native exports are
|
|
45
|
+
* re-sanitized with author JavaScript forced off.
|
|
46
|
+
*/
|
|
47
|
+
compileOptions?: LocalCompileOptions;
|
|
40
48
|
}
|
|
41
49
|
export interface LocalStateBaselineResult {
|
|
42
50
|
document: LocalDocument;
|