reactive-md 0.3.0 → 0.4.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 +96 -0
- package/CHANGELOG.md +96 -40
- package/CONTRIBUTING-ch.md +62 -0
- package/CONTRIBUTING.md +64 -61
- package/README-ch.md +122 -0
- package/README-en.md +146 -0
- package/README.md +146 -88
- package/SECURITY-ch.md +80 -0
- package/SECURITY.md +80 -68
- package/THIRD_PARTY_NOTICES.md +85 -1
- package/bin/reactive-md.mjs +40 -0
- package/cli/args.mjs +181 -0
- package/cli/assets.mjs +390 -0
- package/cli/build.mjs +268 -0
- package/cli/document.mjs +130 -0
- package/cli/errors.mjs +61 -0
- package/cli/fs-utils.mjs +133 -0
- package/cli/glob.mjs +203 -0
- package/cli/help.mjs +138 -0
- package/cli/lint.mjs +177 -0
- package/cli/main.mjs +55 -0
- package/cli/migrate.mjs +368 -0
- package/cli/package.mjs +209 -0
- package/dist-library/reactive-md-react.js +3603 -1690
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +1798 -4
- package/dist-library/runtime-DtjdPXxJ.js +15410 -0
- package/dist-library/types/index.d.ts +1 -0
- package/dist-library/types/local/LocalDocumentView.d.ts +66 -3
- package/dist-library/types/local/authoring.d.ts +63 -0
- package/dist-library/types/local/collection-functions.d.ts +4 -0
- package/dist-library/types/local/colors.d.ts +2 -0
- package/dist-library/types/local/compiler.d.ts +3 -3
- package/dist-library/types/local/computations.d.ts +53 -0
- package/dist-library/types/local/data-functions.d.ts +22 -0
- package/dist-library/types/local/data-table.d.ts +65 -0
- package/dist-library/types/local/dates.d.ts +2 -0
- package/dist-library/types/local/dependencies.d.ts +31 -0
- package/dist-library/types/local/diagnostics.d.ts +1450 -0
- package/dist-library/types/local/expression.d.ts +13 -3
- package/dist-library/types/local/formatting.d.ts +41 -0
- package/dist-library/types/local/heading-anchors.d.ts +17 -0
- package/dist-library/types/local/i18n.d.ts +18 -0
- package/dist-library/types/local/index.d.ts +18 -1
- package/dist-library/types/local/limits.d.ts +33 -1
- package/dist-library/types/local/locale.d.ts +1 -0
- package/dist-library/types/local/math.d.ts +6 -1
- package/dist-library/types/local/parser.d.ts +10 -4
- package/dist-library/types/local/render-types.d.ts +5 -1
- package/dist-library/types/local/retention.d.ts +23 -0
- package/dist-library/types/local/schema.d.ts +25 -3
- package/dist-library/types/local/source-migration.d.ts +35 -0
- package/dist-library/types/local/state.d.ts +80 -0
- package/dist-library/types/local/text-length.d.ts +13 -0
- package/dist-library/types/local/theme.d.ts +30 -0
- package/dist-library/types/local/types.d.ts +120 -4
- package/dist-library/types/local/validation.d.ts +32 -0
- package/dist-library/types/local/version.d.ts +1 -1
- package/dist-library/types/local/worker.d.ts +82 -0
- package/dist-library/types/react/index.d.ts +4 -1
- package/dist-library/types/shareable.d.ts +64 -0
- package/dist-standalone/reactive-md-standalone.css +2 -0
- package/dist-standalone/reactive-md-standalone.js +57 -0
- package/docs/author-tools-ch.md +56 -0
- package/docs/author-tools-en.md +56 -0
- package/docs/compatibility-ch.md +103 -0
- package/docs/compatibility-en.md +103 -0
- package/docs/component-development-ch.md +210 -0
- package/docs/component-development-en.md +210 -0
- package/docs/component-protocol-ch.md +710 -0
- package/docs/component-protocol-en.md +710 -0
- package/docs/computations-formatting-ch.md +87 -0
- package/docs/computations-formatting-en.md +87 -0
- package/docs/constraints-collections-ch.md +84 -0
- package/docs/constraints-collections-en.md +84 -0
- package/docs/diagnostics-counting-ch.md +84 -0
- package/docs/diagnostics-counting-en.md +84 -0
- package/docs/local-components-v2-ch.md +138 -0
- package/docs/local-components-v2-en.md +104 -0
- package/docs/{local-guide.md → local-guide-ch.md} +961 -936
- package/docs/local-guide-en.md +961 -0
- package/docs/local-integration-ch.md +363 -0
- package/docs/local-integration-en.md +363 -0
- package/docs/{local-interaction-syntax.md → local-interaction-syntax-ch.md} +485 -437
- package/docs/local-interaction-syntax-en.md +483 -0
- package/docs/performance-ch.md +76 -0
- package/docs/performance-en.md +76 -0
- package/docs/release-0.4.0-ch.md +89 -0
- package/docs/release-0.4.0-en.md +89 -0
- package/docs/releasing-ch.md +101 -0
- package/docs/releasing-en.md +101 -0
- package/docs/shareable-export-ch.md +205 -0
- package/docs/shareable-export-en.md +207 -0
- package/docs/source-versioning-ch.md +159 -0
- package/docs/source-versioning-en.md +159 -0
- package/docs/theme-protocol-ch.md +107 -0
- package/docs/theme-protocol-en.md +107 -0
- package/examples/conformance/README.md +53 -11
- package/examples/conformance/component-protocol-1.json +482 -0
- package/examples/conformance/component-protocol-1.schema.json +76 -0
- package/examples/conformance/history/v0.3.1/catalog.reactive.md +20 -0
- package/examples/conformance/history/v0.3.1/charts.reactive.md +73 -0
- package/examples/conformance/history/v0.3.1/checklist.reactive.md +32 -0
- package/examples/conformance/history/v0.3.1/comparison.reactive.md +47 -0
- package/examples/conformance/history/v0.3.1/components.reactive.md +44 -0
- package/examples/conformance/history/v0.3.1/counter.reactive.md +7 -0
- package/examples/conformance/history/v0.3.1/diagnostics.reactive.md +54 -0
- package/examples/conformance/history/v0.3.1/diagram.reactive.md +44 -0
- package/examples/conformance/history/v0.3.1/gallery.reactive.md +61 -0
- package/examples/conformance/history/v0.3.1/local-draft-1.json +50 -0
- package/examples/conformance/history/v0.3.1/parameters.reactive.md +36 -0
- package/examples/conformance/history/v0.3.1/planning.reactive.md +24 -0
- package/examples/conformance/history/v0.3.1/pricing.reactive.md +20 -0
- package/examples/conformance/history/v0.3.1/provenance.json +72 -0
- package/examples/conformance/local-draft-1.json +50 -49
- package/examples/conformance/local-draft-2.json +212 -0
- package/examples/integration/README.md +45 -29
- package/examples/integration/core/index.mjs +32 -19
- package/examples/integration/react/index.html +1 -1
- package/examples/integration/react/main.jsx +5 -5
- package/examples/integration/worker/index.html +19 -0
- package/examples/integration/worker/main.js +61 -0
- package/examples/integration/worker/package.json +13 -0
- package/examples/integration/worker/worker.js +3 -0
- package/examples/local/README.md +72 -66
- package/examples/local/catalog.reactive.md +14 -14
- package/examples/local/charts.reactive.md +73 -73
- package/examples/local/checklist.reactive.md +19 -19
- package/examples/local/comparison.reactive.md +23 -23
- package/examples/local/components.reactive.md +20 -20
- package/examples/local/counter.reactive.md +4 -4
- package/examples/local/diagnostics.reactive.md +25 -25
- package/examples/local/diagram.reactive.md +20 -20
- package/examples/local/gallery.reactive.md +31 -31
- package/examples/local/parameters.reactive.md +19 -19
- package/examples/local/planning.reactive.md +15 -15
- package/examples/local/pricing.reactive.md +10 -10
- package/examples/local/recipes/invoice-zh.reactive.md +36 -0
- package/examples/local/recipes/invoice.reactive.md +36 -0
- package/examples/local/recipes/workshop-zh.reactive.md +33 -0
- package/examples/local/recipes/workshop.reactive.md +33 -0
- package/examples/local/showcase/README.md +25 -0
- package/examples/local/showcase/explore.reactive.md +102 -0
- package/examples/local/showcase/flow.reactive.md +86 -0
- package/examples/local/showcase/forms.reactive.md +126 -0
- package/examples/local/showcase/functions.reactive.md +119 -0
- package/examples/local/showcase/layout.reactive.md +100 -0
- package/examples/local/showcase/statistics.reactive.md +108 -0
- package/examples/local/showcase/tasks.reactive.md +89 -0
- package/examples/local/showcase/zh/explore.reactive.md +102 -0
- package/examples/local/showcase/zh/flow.reactive.md +86 -0
- package/examples/local/showcase/zh/forms.reactive.md +126 -0
- package/examples/local/showcase/zh/functions.reactive.md +119 -0
- package/examples/local/showcase/zh/layout.reactive.md +100 -0
- package/examples/local/showcase/zh/statistics.reactive.md +108 -0
- package/examples/local/showcase/zh/tasks.reactive.md +89 -0
- package/examples/local/zh/catalog.reactive.md +20 -0
- package/examples/local/zh/charts.reactive.md +73 -0
- package/examples/local/zh/checklist.reactive.md +32 -0
- package/examples/local/zh/comparison.reactive.md +47 -0
- package/examples/local/zh/components.reactive.md +44 -0
- package/examples/local/zh/counter.reactive.md +7 -0
- package/examples/local/zh/diagnostics.reactive.md +54 -0
- package/examples/local/zh/diagram.reactive.md +44 -0
- package/examples/local/zh/gallery.reactive.md +61 -0
- package/examples/local/zh/parameters.reactive.md +36 -0
- package/examples/local/zh/planning.reactive.md +24 -0
- package/examples/local/zh/pricing.reactive.md +20 -0
- package/package.json +90 -75
- package/README.en.md +0 -75
- package/dist-library/runtime-D4phFXOr.js +0 -10937
- package/docs/compatibility.md +0 -67
- package/docs/local-integration.md +0 -193
- package/docs/performance.md +0 -30
- package/docs/releasing.md +0 -92
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LocalDiagnosticDetails } from './diagnostics.js';
|
|
1
2
|
import type { LocalValue, LocalValueKind } from './types.js';
|
|
2
3
|
/**
|
|
3
4
|
* The local-draft expression language.
|
|
@@ -22,10 +23,13 @@ export interface LocalExpression {
|
|
|
22
23
|
export declare const RESERVED_NAMES: Set<string>;
|
|
23
24
|
/**
|
|
24
25
|
* Allocation-free budget check for a value stored in the runtime or read from
|
|
25
|
-
* an expression environment. Returns
|
|
26
|
-
* fits.
|
|
27
|
-
*
|
|
26
|
+
* an expression environment. Returns structured metadata, or null when the
|
|
27
|
+
* value fits. These are defensive resource budgets: string lengths are UTF-16
|
|
28
|
+
* code units (matching allocation cost), while author-visible text constraints
|
|
29
|
+
* use `countLocalCodePoints`. `len()` keeps counting code points.
|
|
28
30
|
*/
|
|
31
|
+
export declare function localValueBudgetIssue(value: LocalValue): LocalDiagnosticDetails | null;
|
|
32
|
+
/** English message form kept for existing callers and error construction. */
|
|
29
33
|
export declare function localValueBudgetError(value: LocalValue): string | null;
|
|
30
34
|
export declare function compileExpression(source: string): LocalExpression;
|
|
31
35
|
/** Render a template to scalar text. Arrays are rejected rather than serialized. */
|
|
@@ -35,3 +39,9 @@ export declare function interpolate(template: string, env: Record<string, LocalV
|
|
|
35
39
|
* Mixed templates and plain text fall back to text rendering.
|
|
36
40
|
*/
|
|
37
41
|
export declare function expressionValue(template: string, env: Record<string, LocalValue>): LocalValue;
|
|
42
|
+
/**
|
|
43
|
+
* Binding keys read by the `{{ }}` expressions of a template, deduplicated in
|
|
44
|
+
* first-occurrence order. Malformed templates or expressions throw; callers
|
|
45
|
+
* that only need a static scan treat a throw as undecidable.
|
|
46
|
+
*/
|
|
47
|
+
export declare function templateDependencies(template: string): string[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic number formatting for the local expression language.
|
|
3
|
+
*
|
|
4
|
+
* Every formatter receives an explicit supported locale and explicit
|
|
5
|
+
* `Intl.NumberFormat` options. It never falls back to the host default locale,
|
|
6
|
+
* and half-way values round away from zero (`halfExpand`). Helpers raise
|
|
7
|
+
* `LocalFunctionError` without a source offset; the evaluator converts these
|
|
8
|
+
* to `LocalExpressionError` at the call site.
|
|
9
|
+
*/
|
|
10
|
+
export declare class LocalFunctionError extends Error {
|
|
11
|
+
readonly code: string;
|
|
12
|
+
constructor(code: string, message: string);
|
|
13
|
+
}
|
|
14
|
+
export declare const SUPPORTED_LOCALES: readonly string[];
|
|
15
|
+
/** Enforce the shared string budget for a formatting or data result. */
|
|
16
|
+
export declare function ensureStringBudget(value: string, label: string): string;
|
|
17
|
+
/** Restrict locales to the explicitly supported set; no host fallback. */
|
|
18
|
+
export declare function requireLocale(locale: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Fixed-point decimal text with optional digit grouping.
|
|
21
|
+
* `value === null` renders an empty string after the options are validated.
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatNumber(value: number | null, digits?: number, locale?: string, grouping?: boolean): string;
|
|
24
|
+
/**
|
|
25
|
+
* Percent text for a ratio: `0.125` with zero digits renders `13%`.
|
|
26
|
+
* `value === null` renders an empty string after the options are validated.
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatPercent(value: number | null, digits?: number, locale?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Scientific-notation text with a fixed number of fraction digits.
|
|
31
|
+
* `value === null` renders an empty string after the options are validated.
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatScientific(value: number | null, digits?: number, locale?: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Currency text. `currency` must be an uppercase three-letter code. Codes that
|
|
36
|
+
* Intl accepts are allowed even when they are not assigned to a real currency;
|
|
37
|
+
* Intl then displays the code itself. The explicit `digits` override applies to
|
|
38
|
+
* every currency, including currencies such as JPY whose default is zero.
|
|
39
|
+
* `value === null` renders an empty string after the options are validated.
|
|
40
|
+
*/
|
|
41
|
+
export declare function formatCurrency(value: number | null, currency?: string, digits?: number, locale?: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LocalDocument, LocalNode } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Heading slugs and explicit `<anchor>` ids share one per-render-instance
|
|
4
|
+
* namespace. Author fragments (`#result`) resolve against either kind of
|
|
5
|
+
* target, and `<jump to="result">` asks for the already-namespaced DOM id via
|
|
6
|
+
* `targetId`, so the renderer never has to query the global document.
|
|
7
|
+
*
|
|
8
|
+
* Fragments use source initial values, so editing parameters preserves
|
|
9
|
+
* navigation.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createHeadingAnchors(document: LocalDocument, namespace: string, includeExplicitAnchors?: boolean): {
|
|
12
|
+
ids: Map<LocalNode, string>;
|
|
13
|
+
anchorIds: Map<LocalNode, string>;
|
|
14
|
+
/** Namespaced DOM id for a static jump/anchor target slug, if it exists. */
|
|
15
|
+
targetId(to: string): string | undefined;
|
|
16
|
+
resolve(href: string): string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { LocalLocale } from './locale.js';
|
|
3
|
+
export type { LocalLocale } from './locale.js';
|
|
4
|
+
/**
|
|
5
|
+
* A localizer pair supplied at the call site. The English half is returned for
|
|
6
|
+
* `en`, so the default renderer output stays byte-identical to the original
|
|
7
|
+
* English strings.
|
|
8
|
+
*/
|
|
9
|
+
export type Localize = (en: string, zh: string) => string;
|
|
10
|
+
/** The English-only localizer used by helpers outside a React render. */
|
|
11
|
+
export declare const defaultLocalize: Localize;
|
|
12
|
+
export declare function LocalLocaleProvider({ locale, children, }: {
|
|
13
|
+
locale?: LocalLocale;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
export declare function useLocalLocale(): LocalLocale;
|
|
17
|
+
export declare function localize(locale: LocalLocale, en: string, zh: string): string;
|
|
18
|
+
export declare function useLocalize(): Localize;
|
|
@@ -1,6 +1,23 @@
|
|
|
1
|
+
export { analyzeLocalSource, completeLocalSource, renameLocalBinding, formatLocalSource } from './authoring.js';
|
|
2
|
+
export type { AuthorToken, AuthorBinding, AuthorAnalysis, AuthorCompletion, AuthorCompletionKind, AuthorRename } from './authoring.js';
|
|
1
3
|
export { compileLocal } from './compiler.js';
|
|
4
|
+
export { formatLocalDiagnostic, LOCAL_DIAGNOSTIC_CODES, isLocalDiagnosticCode, localDiagnosticTemplate, localDiagnosticTemplateKeys, } from './diagnostics.js';
|
|
5
|
+
export type { LocalDiagnosticDetails } from './diagnostics.js';
|
|
6
|
+
export { countLocalCodePoints } from './text-length.js';
|
|
2
7
|
export { createLocalRuntime } from './runtime.js';
|
|
3
8
|
export { compileExpression, LocalExpressionError } from './expression.js';
|
|
4
9
|
export { compileLatex, samplePlot } from './math.js';
|
|
5
10
|
export { LOCAL_SYNTAX_VERSION } from './version.js';
|
|
6
|
-
export
|
|
11
|
+
export { inspectLocalSourceVersion, checkLocalUpgrade, migrateLocalSource } from './source-migration.js';
|
|
12
|
+
export type { LocalSourceVersion, LocalUpgradeOptions, LocalUpgradeReport, LocalMigrationResult } from './source-migration.js';
|
|
13
|
+
export type { LocalVersionDeclaration } from './types.js';
|
|
14
|
+
export type { LocalLocale } from './locale.js';
|
|
15
|
+
export { LOCAL_THEME_PROTOCOL, DEFAULT_LOCAL_THEME, resolveLocalTheme, isLocalThemeName } from './theme.js';
|
|
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';
|
|
18
|
+
export { LOCAL_STATE_FORMAT, localSourceDigest, createLocalStateFile, parseLocalState, resolveLocalState, applyLocalState, exportLocalState, importLocalState, serializeLocalState, } from './state.js';
|
|
19
|
+
export type { LocalStateGenerator, LocalStateFile, LocalStateParseResult, LocalStateResolution, } from './state.js';
|
|
20
|
+
export { planLocalStateRetention, applyLocalStateRetention } from './retention.js';
|
|
21
|
+
export type { LocalStateRetentionReason, LocalStateRetentionDrop, LocalStateRetentionInput, LocalRetainedState, LocalStateRetentionResult, } from './retention.js';
|
|
22
|
+
export { LOCAL_COMPILE_DELAY_MS, LocalCompileScheduler, compileFailureDiagnostic, startLocalCompileWorker, } from './worker.js';
|
|
23
|
+
export type { LocalCompileRequest, LocalCompileResponse, LocalCompileWorker, LocalCompileMode, LocalCompileOutcome, LocalCompileSchedulerOptions, LocalCompileWorkerScope, } from './worker.js';
|
|
@@ -1,13 +1,45 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Shared defensive limits for source compilation, runtime values and visual work.
|
|
3
|
+
*
|
|
4
|
+
* Units matter:
|
|
5
|
+
* - Source text, names, string values/templates, diagnostic text and JSON-ish
|
|
6
|
+
* lengths are UTF-16 code units (JavaScript `string.length`). These are
|
|
7
|
+
* allocation/CPU guards, not author-visible character counts.
|
|
8
|
+
* - Author-visible `len()` text and text-control `min-length`/`max-length` use
|
|
9
|
+
* Unicode code points via `countLocalCodePoints`.
|
|
10
|
+
* - Arrays and plot sample counts are element counts.
|
|
11
|
+
*
|
|
12
|
+
* Each limit is inclusive: a value equal to the limit is accepted, a larger
|
|
13
|
+
* value is rejected. Limits are intentionally not configurable except for the
|
|
14
|
+
* per-compilation syntax-node budget (`limits.maxSyntaxNodes`).
|
|
15
|
+
*/
|
|
16
|
+
/** Original source length for one compilation, in UTF-16 code units. */
|
|
2
17
|
export declare const MAX_LOCAL_DOCUMENT_LENGTH = 1000000;
|
|
18
|
+
/** Cumulative `LocalNode` constructions during one parse, including intermediates. */
|
|
19
|
+
export declare const DEFAULT_MAX_LOCAL_SYNTAX_NODES = 10000;
|
|
20
|
+
/** One string value, attribute, template or concatenation result, in UTF-16 code units. */
|
|
3
21
|
export declare const MAX_LOCAL_STRING_LENGTH = 100000;
|
|
22
|
+
/** Number of elements in one array value or selection. */
|
|
4
23
|
export declare const MAX_LOCAL_ARRAY_LENGTH = 10000;
|
|
24
|
+
/** Sum of UTF-16 lengths of all string members in one array. */
|
|
5
25
|
export declare const MAX_LOCAL_VALUE_CHARACTERS = 100000;
|
|
26
|
+
/** Diagnostics retained per parse/compile; new errors may displace warnings. */
|
|
6
27
|
export declare const MAX_LOCAL_DIAGNOSTICS = 100;
|
|
28
|
+
/** Displayed diagnostic message length, in UTF-16 code units. */
|
|
7
29
|
export declare const MAX_LOCAL_DIAGNOSTIC_LENGTH = 2000;
|
|
30
|
+
/** Curves allowed in one `<plot>` component. */
|
|
8
31
|
export declare const MAX_LOCAL_PLOT_CURVES = 16;
|
|
32
|
+
/** Curve sample points requested across one document compilation. */
|
|
9
33
|
export declare const MAX_LOCAL_PLOT_POINTS = 20000;
|
|
34
|
+
/** Shared node-visit budget for all plot sampling in one runtime revision. */
|
|
10
35
|
export declare const MAX_LOCAL_PLOT_STEPS = 2000000;
|
|
36
|
+
/** Email address guard, in UTF-16 code units; validated in linear time. */
|
|
11
37
|
export declare const MAX_LOCAL_EMAIL_LENGTH = 254;
|
|
38
|
+
export declare const MAX_LOCAL_VALIDATIONS = 100;
|
|
39
|
+
export declare const MAX_LOCAL_DATA_TABLE_ROWS = 1000;
|
|
40
|
+
export declare const DEFAULT_LOCAL_DATA_TABLE_ROWS = 100;
|
|
41
|
+
export declare const MAX_LOCAL_DATA_TABLE_COLUMNS = 20;
|
|
42
|
+
export declare const MAX_LOCAL_DATA_DOCUMENT_ROWS = 2000;
|
|
43
|
+
export declare const MAX_LOCAL_DATA_DOCUMENT_CELLS = 10000;
|
|
12
44
|
/** Linear validation; the final dot must have text on both sides in the domain. */
|
|
13
45
|
export declare function isLocalEmail(value: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type LocalLocale = 'en' | 'zh';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LocalValue } from './types.js';
|
|
1
|
+
import type { LocalValue, SourceRange } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Computable LaTeX for local plots.
|
|
4
4
|
*
|
|
@@ -30,6 +30,11 @@ export interface PlotSample {
|
|
|
30
30
|
points: PlotPoint[];
|
|
31
31
|
endpoint: number | null;
|
|
32
32
|
}
|
|
33
|
+
/** Internal authoring support: only AST variable nodes represent plot reads. */
|
|
34
|
+
export declare function localLatexReferences(source: string): {
|
|
35
|
+
name: string;
|
|
36
|
+
range: SourceRange;
|
|
37
|
+
}[];
|
|
33
38
|
export declare function compileLatex(source: string): LatexExpression;
|
|
34
39
|
/**
|
|
35
40
|
* Samples y(x) across [min, max]. Undefined points and the sample after a
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { Diagnostic } from './types.js';
|
|
2
|
-
import type { LocalNode } from './types.js';
|
|
3
|
-
|
|
4
|
-
export declare function parseLocal(source: string): {
|
|
2
|
+
import type { LocalCompileOptions, LocalNode, LocalVersionDeclaration, SourceRange } from './types.js';
|
|
3
|
+
export interface ParsedLocal {
|
|
5
4
|
nodes: LocalNode[];
|
|
6
5
|
diagnostics: Diagnostic[];
|
|
7
|
-
|
|
6
|
+
versionDeclaration?: LocalVersionDeclaration;
|
|
7
|
+
/** Declared theme name, when the leading declaration is valid. */
|
|
8
|
+
theme?: string;
|
|
9
|
+
/** Source range of the first leading theme declaration, valid or not. */
|
|
10
|
+
themeRange?: SourceRange;
|
|
11
|
+
}
|
|
12
|
+
/** A lexical pass shields code before recognizing local tags, interpolation and math. */
|
|
13
|
+
export declare function parseLocal(source: string, options?: LocalCompileOptions): ParsedLocal;
|
|
@@ -2,11 +2,15 @@ import type { ReactNode } from 'react';
|
|
|
2
2
|
import type { LocalNode, LocalRuntime } from './types.js';
|
|
3
3
|
/** Rendering contract shared by the React views. Kept out of types.ts so the
|
|
4
4
|
* core compiler and runtime types never depend on React. */
|
|
5
|
+
export type LocalRenderMode = 'interactive' | 'static';
|
|
5
6
|
export interface LocalRenderContext {
|
|
6
7
|
runtime: LocalRuntime;
|
|
7
8
|
render(nodes?: LocalNode[], visible?: boolean): ReactNode;
|
|
8
9
|
visible: boolean;
|
|
10
|
+
mode: LocalRenderMode;
|
|
9
11
|
}
|
|
10
|
-
export interface LocalVisualProps extends LocalRenderContext {
|
|
12
|
+
export interface LocalVisualProps extends Omit<LocalRenderContext, 'mode'> {
|
|
11
13
|
node: LocalNode;
|
|
14
|
+
/** Defaults to interactive so hand-built visual fixtures stay compatible. */
|
|
15
|
+
mode?: LocalRenderMode;
|
|
12
16
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Diagnostic, LocalDocument, LocalRuntime, LocalValue } from './types.js';
|
|
2
|
+
export type LocalStateRetentionReason = 'internal' | 'unknown' | 'unretainable' | 'type' | 'initial' | 'invalid';
|
|
3
|
+
export interface LocalStateRetentionDrop {
|
|
4
|
+
name: string;
|
|
5
|
+
reason: LocalStateRetentionReason;
|
|
6
|
+
}
|
|
7
|
+
export interface LocalStateRetentionInput {
|
|
8
|
+
previous: LocalDocument;
|
|
9
|
+
state: Readonly<Record<string, LocalValue>>;
|
|
10
|
+
next: LocalDocument;
|
|
11
|
+
}
|
|
12
|
+
export interface LocalRetainedState {
|
|
13
|
+
values: Readonly<Record<string, LocalValue>>;
|
|
14
|
+
retained: readonly string[];
|
|
15
|
+
dropped: readonly LocalStateRetentionDrop[];
|
|
16
|
+
}
|
|
17
|
+
export interface LocalStateRetentionResult {
|
|
18
|
+
retained: readonly string[];
|
|
19
|
+
dropped: readonly LocalStateRetentionDrop[];
|
|
20
|
+
diagnostics: readonly Diagnostic[];
|
|
21
|
+
}
|
|
22
|
+
export declare function planLocalStateRetention(input: LocalStateRetentionInput): LocalRetainedState;
|
|
23
|
+
export declare function applyLocalStateRetention(runtime: LocalRuntime, retained: LocalRetainedState): LocalStateRetentionResult;
|
|
@@ -5,7 +5,7 @@ import type { LocalValue, LocalValueKind } from './types.js';
|
|
|
5
5
|
* to know which props are dynamic and which controls own public state.
|
|
6
6
|
*/
|
|
7
7
|
export type LocalComponentForm = 'leaf' | 'inline' | 'container';
|
|
8
|
-
export type LocalChildRule = 'none' | 'any' | 'inline' | 'options' | 'tabs' | 'disclosures' | 'cards' | 'diagram' | 'table' | 'plot' | 'content';
|
|
8
|
+
export type LocalChildRule = 'none' | 'any' | 'inline' | 'options' | 'tabs' | 'disclosures' | 'cards' | 'diagram' | 'table' | 'plot' | 'content' | 'steps' | 'quiz' | 'columns';
|
|
9
9
|
export type LocalPropKind = 'string' | 'number' | 'boolean' | 'enum';
|
|
10
10
|
export interface LocalPropSchema {
|
|
11
11
|
kind: LocalPropKind;
|
|
@@ -20,8 +20,10 @@ export interface LocalPropSchema {
|
|
|
20
20
|
positive?: boolean;
|
|
21
21
|
min?: number;
|
|
22
22
|
max?: number;
|
|
23
|
+
/** Reject anything but a bounded named CSS color or #RGB/#RRGGBB. */
|
|
24
|
+
color?: boolean;
|
|
23
25
|
}
|
|
24
|
-
export type LocalBindingFamily = 'text' | 'number' | 'boolean' | 'choice' | 'date' | 'timer' | 'checklist' | 'tabs' | 'diagram';
|
|
26
|
+
export type LocalBindingFamily = 'text' | 'number' | 'boolean' | 'choice' | 'date' | 'timer' | 'checklist' | 'tabs' | 'diagram' | 'multi-select' | 'selection' | 'steps';
|
|
25
27
|
export interface LocalBindingSchema {
|
|
26
28
|
kind: LocalValueKind;
|
|
27
29
|
required: boolean;
|
|
@@ -29,12 +31,28 @@ export interface LocalBindingSchema {
|
|
|
29
31
|
/** Only one component may own this binding, and its state cannot be shared. */
|
|
30
32
|
exclusive?: boolean;
|
|
31
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* One independently bound value of a multi-slot component. Each slot has its
|
|
36
|
+
* own public binding name (or an internal `@node:slot` key) and is exclusive in
|
|
37
|
+
* the first revision of the slot API.
|
|
38
|
+
*/
|
|
39
|
+
export interface LocalBindingSlotSchema {
|
|
40
|
+
name: string;
|
|
41
|
+
/** Attribute that names the public binding, e.g. `bind-start`. */
|
|
42
|
+
bind: string;
|
|
43
|
+
/** Attribute that provides an explicit initial value, e.g. `initial-start`. */
|
|
44
|
+
initial: string;
|
|
45
|
+
kind: LocalValueKind;
|
|
46
|
+
family: LocalBindingFamily;
|
|
47
|
+
exclusive: boolean;
|
|
48
|
+
initialRule: 'min' | 'max-step' | 'nearest-zero';
|
|
49
|
+
}
|
|
32
50
|
/**
|
|
33
51
|
* `default` is the schema default for an ordinary property. `initialRule`
|
|
34
52
|
* describes how a component produces the value of a binding when the author
|
|
35
53
|
* omits `initial`.
|
|
36
54
|
*/
|
|
37
|
-
export type LocalInitialRule = 'empty' | 'false' | 'min' | 'nearest-zero' | 'first-option' | 'first-tab' | 'first-node' | 'checked' | 'duration';
|
|
55
|
+
export type LocalInitialRule = 'empty' | 'false' | 'min' | 'nearest-zero' | 'first-option' | 'first-tab' | 'first-step' | 'first-node' | 'checked' | 'duration' | 'empty-array' | 'none';
|
|
38
56
|
export interface LocalComponentSchema {
|
|
39
57
|
name: string;
|
|
40
58
|
form: LocalComponentForm;
|
|
@@ -44,10 +62,14 @@ export interface LocalComponentSchema {
|
|
|
44
62
|
parent?: readonly string[];
|
|
45
63
|
props: Record<string, LocalPropSchema>;
|
|
46
64
|
binding?: LocalBindingSchema;
|
|
65
|
+
/** Independent bindings owned by a leaf component (range-slider, coordinate). */
|
|
66
|
+
slots?: readonly LocalBindingSlotSchema[];
|
|
47
67
|
initialRule?: LocalInitialRule;
|
|
48
68
|
}
|
|
49
69
|
export declare const LOCAL_COMPONENTS: Readonly<Record<string, LocalComponentSchema>>;
|
|
50
70
|
export declare const LOCAL_COMPONENT_NAMES: readonly string[];
|
|
71
|
+
/** Component names with the given tag shape, in declaration order. */
|
|
72
|
+
export declare function localComponentNames(form: LocalComponentForm): readonly string[];
|
|
51
73
|
export declare function getLocalComponent(name: string): LocalComponentSchema | undefined;
|
|
52
74
|
export declare function getPropDefault(component: LocalComponentSchema, prop: string): LocalValue | undefined;
|
|
53
75
|
export declare function closestName(name: string, candidates: readonly string[]): string | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LOCAL_SYNTAX_VERSION } from './version.js';
|
|
2
|
+
import type { Diagnostic, SourceRange } from './types.js';
|
|
3
|
+
export interface LocalSourceVersion {
|
|
4
|
+
declaredVersion: string | null;
|
|
5
|
+
effectiveVersion: string;
|
|
6
|
+
supported: boolean;
|
|
7
|
+
range: SourceRange | null;
|
|
8
|
+
diagnostics: Diagnostic[];
|
|
9
|
+
}
|
|
10
|
+
export interface LocalUpgradeOptions {
|
|
11
|
+
fromVersion?: string;
|
|
12
|
+
/** Accept the documented UTF-16 -> code-point text-constraint change. */
|
|
13
|
+
allowSemanticChanges?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface LocalUpgradeReport {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
fromVersion: string;
|
|
18
|
+
toVersion: typeof LOCAL_SYNTAX_VERSION;
|
|
19
|
+
needsMigration: boolean;
|
|
20
|
+
diagnostics: Diagnostic[];
|
|
21
|
+
}
|
|
22
|
+
export interface LocalMigrationResult extends LocalUpgradeReport {
|
|
23
|
+
source: string;
|
|
24
|
+
changed: boolean;
|
|
25
|
+
edits: {
|
|
26
|
+
range: SourceRange;
|
|
27
|
+
text: string;
|
|
28
|
+
}[];
|
|
29
|
+
}
|
|
30
|
+
/** Inspect source metadata without constructing a runtime or evaluating declarations. */
|
|
31
|
+
export declare function inspectLocalSourceVersion(source: string): LocalSourceVersion;
|
|
32
|
+
/** Report blockers and declared compatibility exceptions before editing source. */
|
|
33
|
+
export declare function checkLocalUpgrade(source: string, options?: LocalUpgradeOptions): LocalUpgradeReport;
|
|
34
|
+
/** Pure, idempotent metadata migration. Failure returns the original source. */
|
|
35
|
+
export declare function migrateLocalSource(source: string, options?: LocalUpgradeOptions): LocalMigrationResult;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Diagnostic, LocalDocument, LocalRuntime, LocalValue } from './types.js';
|
|
2
|
+
/** Version tag for the portable, shareable parameter state format. */
|
|
3
|
+
export declare const LOCAL_STATE_FORMAT: 'reactive-md-state/v1';
|
|
4
|
+
export interface LocalStateGenerator {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LocalStateFile {
|
|
9
|
+
format: typeof LOCAL_STATE_FORMAT;
|
|
10
|
+
/** Syntax revision the state was produced for (`local-draft-2`). */
|
|
11
|
+
syntax: string;
|
|
12
|
+
/** Deterministic digest of the document source. */
|
|
13
|
+
sourceDigest: string;
|
|
14
|
+
/** Public binding name -> serializable value. */
|
|
15
|
+
parameters: Record<string, LocalValue>;
|
|
16
|
+
generator?: LocalStateGenerator;
|
|
17
|
+
}
|
|
18
|
+
export type LocalStateParseResult = {
|
|
19
|
+
ok: true;
|
|
20
|
+
file: LocalStateFile;
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
diagnostics: Diagnostic[];
|
|
24
|
+
};
|
|
25
|
+
export type LocalStateResolution = {
|
|
26
|
+
ok: true;
|
|
27
|
+
file: LocalStateFile;
|
|
28
|
+
state: Readonly<Record<string, LocalValue>>;
|
|
29
|
+
} | {
|
|
30
|
+
ok: false;
|
|
31
|
+
diagnostics: Diagnostic[];
|
|
32
|
+
};
|
|
33
|
+
/** FNV-1a over the UTF-8 bytes of the source. */
|
|
34
|
+
export declare function localSourceDigest(source: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Capture every public binding from a runtime state. Internal `@...` binding
|
|
37
|
+
* keys and declared read-only values are ignored so a full snapshot can be passed in;
|
|
38
|
+
* unknown keys, missing public keys and non-serializable values are rejected.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createLocalStateFile(document: LocalDocument, state: Readonly<Record<string, LocalValue>>, generator?: LocalStateGenerator): LocalStateFile;
|
|
41
|
+
/**
|
|
42
|
+
* Parse a serialized state file (or an already parsed value). Malformed input
|
|
43
|
+
* never throws; it produces diagnostics under `local.state.*` at 1:1.
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseLocalState(input: string | unknown, options?: {
|
|
46
|
+
maxLength?: number;
|
|
47
|
+
}): LocalStateParseResult;
|
|
48
|
+
/**
|
|
49
|
+
* Verify a state file against a compiled document and normalize its values
|
|
50
|
+
* through a throwaway runtime. No live runtime is created or mutated.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveLocalState(document: LocalDocument, input: string | unknown, options?: {
|
|
53
|
+
maxLength?: number;
|
|
54
|
+
}): LocalStateResolution;
|
|
55
|
+
/**
|
|
56
|
+
* Validate the file against the document (using the runtime's current state as
|
|
57
|
+
* the baseline) and then write the normalized public values. Multi-slot
|
|
58
|
+
* components are written atomically with `setMany`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function applyLocalState(runtime: LocalRuntime, file: LocalStateFile, options?: {
|
|
61
|
+
maxLength?: number;
|
|
62
|
+
}): Diagnostic[];
|
|
63
|
+
/**
|
|
64
|
+
* Capture the live runtime's public parameters in the portable state format.
|
|
65
|
+
* The runtime snapshot may contain internal bindings; the state file never does.
|
|
66
|
+
*/
|
|
67
|
+
export declare function exportLocalState(runtime: LocalRuntime, generator?: LocalStateGenerator): LocalStateFile;
|
|
68
|
+
/**
|
|
69
|
+
* Parse a serialized or already-parsed state payload and apply it to a live
|
|
70
|
+
* runtime. Returns diagnostics and never throws for malformed input; a failed
|
|
71
|
+
* import leaves the runtime state untouched.
|
|
72
|
+
*/
|
|
73
|
+
export declare function importLocalState(runtime: LocalRuntime, input: string | unknown, options?: {
|
|
74
|
+
maxLength?: number;
|
|
75
|
+
}): Diagnostic[];
|
|
76
|
+
/**
|
|
77
|
+
* Produce stable JSON in a canonical key order. The CLI is responsible for
|
|
78
|
+
* wrapping the result in an HTML/script context; no HTML escaping happens here.
|
|
79
|
+
*/
|
|
80
|
+
export declare function serializeLocalState(file: LocalStateFile): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Author-visible character counting.
|
|
3
|
+
*
|
|
4
|
+
* Unicode code points are the unit authors see: `len()` in expressions,
|
|
5
|
+
* `min-length`/`max-length` on text controls and initial-value checks all use
|
|
6
|
+
* this function. Combining marks are not merged into grapheme clusters, and an
|
|
7
|
+
* unpaired surrogate counts as one code point.
|
|
8
|
+
*
|
|
9
|
+
* Source offsets, line/column positions and defensive resource budgets remain
|
|
10
|
+
* UTF-16 code units (see `limits.ts`); those are machine limits, not counts
|
|
11
|
+
* authors compare against visible text.
|
|
12
|
+
*/
|
|
13
|
+
export declare function countLocalCodePoints(value: string): number;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Diagnostic, SourceRange } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Versioned theme contract. A host registers CSS for a theme name and declares
|
|
4
|
+
* that contract here; the document only carries a name, never CSS or a URL.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LOCAL_THEME_PROTOCOL: 'reactive-md-theme-1';
|
|
7
|
+
export type LocalColorScheme = 'light' | 'dark' | 'auto';
|
|
8
|
+
export interface LocalThemeDefinition {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly protocol: typeof LOCAL_THEME_PROTOCOL;
|
|
11
|
+
readonly colorSchemes: readonly ('light' | 'dark')[];
|
|
12
|
+
}
|
|
13
|
+
/** Built-in theme supplied by the package, so old documents keep working. */
|
|
14
|
+
export declare const DEFAULT_LOCAL_THEME: LocalThemeDefinition;
|
|
15
|
+
/** Bounded, URL-free theme identifier used by documents and host manifests. */
|
|
16
|
+
export declare function isLocalThemeName(value: unknown): value is string;
|
|
17
|
+
export interface LocalThemeResolution {
|
|
18
|
+
name: string;
|
|
19
|
+
diagnostics: Diagnostic[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the document-selected theme against a host-supplied manifest.
|
|
23
|
+
*
|
|
24
|
+
* This is a pure validation step: it never mutates the registry, loads CSS,
|
|
25
|
+
* runs host code or throws. Any malformed selection or manifest degrades to
|
|
26
|
+
* the built-in `default` theme with a warning so healthy controls keep working.
|
|
27
|
+
* Unknown names are not compiler errors; this function is called where the
|
|
28
|
+
* renderer actually chooses a theme.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveLocalTheme(requested?: string, themes?: readonly LocalThemeDefinition[], range?: SourceRange, source?: string): LocalThemeResolution;
|