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.
Files changed (175) hide show
  1. package/CHANGELOG-ch.md +96 -0
  2. package/CHANGELOG.md +96 -40
  3. package/CONTRIBUTING-ch.md +62 -0
  4. package/CONTRIBUTING.md +64 -61
  5. package/README-ch.md +122 -0
  6. package/README-en.md +146 -0
  7. package/README.md +146 -88
  8. package/SECURITY-ch.md +80 -0
  9. package/SECURITY.md +80 -68
  10. package/THIRD_PARTY_NOTICES.md +85 -1
  11. package/bin/reactive-md.mjs +40 -0
  12. package/cli/args.mjs +181 -0
  13. package/cli/assets.mjs +390 -0
  14. package/cli/build.mjs +268 -0
  15. package/cli/document.mjs +130 -0
  16. package/cli/errors.mjs +61 -0
  17. package/cli/fs-utils.mjs +133 -0
  18. package/cli/glob.mjs +203 -0
  19. package/cli/help.mjs +138 -0
  20. package/cli/lint.mjs +177 -0
  21. package/cli/main.mjs +55 -0
  22. package/cli/migrate.mjs +368 -0
  23. package/cli/package.mjs +209 -0
  24. package/dist-library/reactive-md-react.js +3603 -1690
  25. package/dist-library/reactive-md.css +1 -1
  26. package/dist-library/reactive-md.js +1798 -4
  27. package/dist-library/runtime-DtjdPXxJ.js +15410 -0
  28. package/dist-library/types/index.d.ts +1 -0
  29. package/dist-library/types/local/LocalDocumentView.d.ts +66 -3
  30. package/dist-library/types/local/authoring.d.ts +63 -0
  31. package/dist-library/types/local/collection-functions.d.ts +4 -0
  32. package/dist-library/types/local/colors.d.ts +2 -0
  33. package/dist-library/types/local/compiler.d.ts +3 -3
  34. package/dist-library/types/local/computations.d.ts +53 -0
  35. package/dist-library/types/local/data-functions.d.ts +22 -0
  36. package/dist-library/types/local/data-table.d.ts +65 -0
  37. package/dist-library/types/local/dates.d.ts +2 -0
  38. package/dist-library/types/local/dependencies.d.ts +31 -0
  39. package/dist-library/types/local/diagnostics.d.ts +1450 -0
  40. package/dist-library/types/local/expression.d.ts +13 -3
  41. package/dist-library/types/local/formatting.d.ts +41 -0
  42. package/dist-library/types/local/heading-anchors.d.ts +17 -0
  43. package/dist-library/types/local/i18n.d.ts +18 -0
  44. package/dist-library/types/local/index.d.ts +18 -1
  45. package/dist-library/types/local/limits.d.ts +33 -1
  46. package/dist-library/types/local/locale.d.ts +1 -0
  47. package/dist-library/types/local/math.d.ts +6 -1
  48. package/dist-library/types/local/parser.d.ts +10 -4
  49. package/dist-library/types/local/render-types.d.ts +5 -1
  50. package/dist-library/types/local/retention.d.ts +23 -0
  51. package/dist-library/types/local/schema.d.ts +25 -3
  52. package/dist-library/types/local/source-migration.d.ts +35 -0
  53. package/dist-library/types/local/state.d.ts +80 -0
  54. package/dist-library/types/local/text-length.d.ts +13 -0
  55. package/dist-library/types/local/theme.d.ts +30 -0
  56. package/dist-library/types/local/types.d.ts +120 -4
  57. package/dist-library/types/local/validation.d.ts +32 -0
  58. package/dist-library/types/local/version.d.ts +1 -1
  59. package/dist-library/types/local/worker.d.ts +82 -0
  60. package/dist-library/types/react/index.d.ts +4 -1
  61. package/dist-library/types/shareable.d.ts +64 -0
  62. package/dist-standalone/reactive-md-standalone.css +2 -0
  63. package/dist-standalone/reactive-md-standalone.js +57 -0
  64. package/docs/author-tools-ch.md +56 -0
  65. package/docs/author-tools-en.md +56 -0
  66. package/docs/compatibility-ch.md +103 -0
  67. package/docs/compatibility-en.md +103 -0
  68. package/docs/component-development-ch.md +210 -0
  69. package/docs/component-development-en.md +210 -0
  70. package/docs/component-protocol-ch.md +710 -0
  71. package/docs/component-protocol-en.md +710 -0
  72. package/docs/computations-formatting-ch.md +87 -0
  73. package/docs/computations-formatting-en.md +87 -0
  74. package/docs/constraints-collections-ch.md +84 -0
  75. package/docs/constraints-collections-en.md +84 -0
  76. package/docs/diagnostics-counting-ch.md +84 -0
  77. package/docs/diagnostics-counting-en.md +84 -0
  78. package/docs/local-components-v2-ch.md +138 -0
  79. package/docs/local-components-v2-en.md +104 -0
  80. package/docs/{local-guide.md → local-guide-ch.md} +961 -936
  81. package/docs/local-guide-en.md +961 -0
  82. package/docs/local-integration-ch.md +363 -0
  83. package/docs/local-integration-en.md +363 -0
  84. package/docs/{local-interaction-syntax.md → local-interaction-syntax-ch.md} +485 -437
  85. package/docs/local-interaction-syntax-en.md +483 -0
  86. package/docs/performance-ch.md +76 -0
  87. package/docs/performance-en.md +76 -0
  88. package/docs/release-0.4.0-ch.md +89 -0
  89. package/docs/release-0.4.0-en.md +89 -0
  90. package/docs/releasing-ch.md +101 -0
  91. package/docs/releasing-en.md +101 -0
  92. package/docs/shareable-export-ch.md +205 -0
  93. package/docs/shareable-export-en.md +207 -0
  94. package/docs/source-versioning-ch.md +159 -0
  95. package/docs/source-versioning-en.md +159 -0
  96. package/docs/theme-protocol-ch.md +107 -0
  97. package/docs/theme-protocol-en.md +107 -0
  98. package/examples/conformance/README.md +53 -11
  99. package/examples/conformance/component-protocol-1.json +482 -0
  100. package/examples/conformance/component-protocol-1.schema.json +76 -0
  101. package/examples/conformance/history/v0.3.1/catalog.reactive.md +20 -0
  102. package/examples/conformance/history/v0.3.1/charts.reactive.md +73 -0
  103. package/examples/conformance/history/v0.3.1/checklist.reactive.md +32 -0
  104. package/examples/conformance/history/v0.3.1/comparison.reactive.md +47 -0
  105. package/examples/conformance/history/v0.3.1/components.reactive.md +44 -0
  106. package/examples/conformance/history/v0.3.1/counter.reactive.md +7 -0
  107. package/examples/conformance/history/v0.3.1/diagnostics.reactive.md +54 -0
  108. package/examples/conformance/history/v0.3.1/diagram.reactive.md +44 -0
  109. package/examples/conformance/history/v0.3.1/gallery.reactive.md +61 -0
  110. package/examples/conformance/history/v0.3.1/local-draft-1.json +50 -0
  111. package/examples/conformance/history/v0.3.1/parameters.reactive.md +36 -0
  112. package/examples/conformance/history/v0.3.1/planning.reactive.md +24 -0
  113. package/examples/conformance/history/v0.3.1/pricing.reactive.md +20 -0
  114. package/examples/conformance/history/v0.3.1/provenance.json +72 -0
  115. package/examples/conformance/local-draft-1.json +50 -49
  116. package/examples/conformance/local-draft-2.json +212 -0
  117. package/examples/integration/README.md +45 -29
  118. package/examples/integration/core/index.mjs +32 -19
  119. package/examples/integration/react/index.html +1 -1
  120. package/examples/integration/react/main.jsx +5 -5
  121. package/examples/integration/worker/index.html +19 -0
  122. package/examples/integration/worker/main.js +61 -0
  123. package/examples/integration/worker/package.json +13 -0
  124. package/examples/integration/worker/worker.js +3 -0
  125. package/examples/local/README.md +72 -66
  126. package/examples/local/catalog.reactive.md +14 -14
  127. package/examples/local/charts.reactive.md +73 -73
  128. package/examples/local/checklist.reactive.md +19 -19
  129. package/examples/local/comparison.reactive.md +23 -23
  130. package/examples/local/components.reactive.md +20 -20
  131. package/examples/local/counter.reactive.md +4 -4
  132. package/examples/local/diagnostics.reactive.md +25 -25
  133. package/examples/local/diagram.reactive.md +20 -20
  134. package/examples/local/gallery.reactive.md +31 -31
  135. package/examples/local/parameters.reactive.md +19 -19
  136. package/examples/local/planning.reactive.md +15 -15
  137. package/examples/local/pricing.reactive.md +10 -10
  138. package/examples/local/recipes/invoice-zh.reactive.md +36 -0
  139. package/examples/local/recipes/invoice.reactive.md +36 -0
  140. package/examples/local/recipes/workshop-zh.reactive.md +33 -0
  141. package/examples/local/recipes/workshop.reactive.md +33 -0
  142. package/examples/local/showcase/README.md +25 -0
  143. package/examples/local/showcase/explore.reactive.md +102 -0
  144. package/examples/local/showcase/flow.reactive.md +86 -0
  145. package/examples/local/showcase/forms.reactive.md +126 -0
  146. package/examples/local/showcase/functions.reactive.md +119 -0
  147. package/examples/local/showcase/layout.reactive.md +100 -0
  148. package/examples/local/showcase/statistics.reactive.md +108 -0
  149. package/examples/local/showcase/tasks.reactive.md +89 -0
  150. package/examples/local/showcase/zh/explore.reactive.md +102 -0
  151. package/examples/local/showcase/zh/flow.reactive.md +86 -0
  152. package/examples/local/showcase/zh/forms.reactive.md +126 -0
  153. package/examples/local/showcase/zh/functions.reactive.md +119 -0
  154. package/examples/local/showcase/zh/layout.reactive.md +100 -0
  155. package/examples/local/showcase/zh/statistics.reactive.md +108 -0
  156. package/examples/local/showcase/zh/tasks.reactive.md +89 -0
  157. package/examples/local/zh/catalog.reactive.md +20 -0
  158. package/examples/local/zh/charts.reactive.md +73 -0
  159. package/examples/local/zh/checklist.reactive.md +32 -0
  160. package/examples/local/zh/comparison.reactive.md +47 -0
  161. package/examples/local/zh/components.reactive.md +44 -0
  162. package/examples/local/zh/counter.reactive.md +7 -0
  163. package/examples/local/zh/diagnostics.reactive.md +54 -0
  164. package/examples/local/zh/diagram.reactive.md +44 -0
  165. package/examples/local/zh/gallery.reactive.md +61 -0
  166. package/examples/local/zh/parameters.reactive.md +36 -0
  167. package/examples/local/zh/planning.reactive.md +24 -0
  168. package/examples/local/zh/pricing.reactive.md +20 -0
  169. package/package.json +90 -75
  170. package/README.en.md +0 -75
  171. package/dist-library/runtime-D4phFXOr.js +0 -10937
  172. package/docs/compatibility.md +0 -67
  173. package/docs/local-integration.md +0 -193
  174. package/docs/performance.md +0 -30
  175. package/docs/releasing.md +0 -92
@@ -1 +1,2 @@
1
1
  export * from './local/index.js';
2
+ export * from './shareable.js';
@@ -1,19 +1,82 @@
1
- import type { Diagnostic, LocalDocument, LocalRuntime } from './types.js';
1
+ import { type ReactNode } from 'react';
2
+ import type { Diagnostic, LocalDocument, LocalNode, LocalRuntime } from './types.js';
3
+ import type { LocalRenderMode } from './render-types.js';
4
+ import { type LocalColorScheme, type LocalThemeDefinition } from './theme.js';
5
+ import { type LocalLocale, type Localize } from './i18n.js';
2
6
  /**
3
7
  * Host-owned URL allowlist. It runs only after the renderer has validated the
4
8
  * protocol, and a thrown error denies the URL.
5
9
  */
6
10
  export type LocalUrlPolicy = (url: string, kind: 'image' | 'link') => boolean;
11
+ /**
12
+ * Trusted host mapping applied to an image URL that already passed the
13
+ * protocol check and the host URL policy. It commonly turns a fetchable image
14
+ * into a self-contained `data:` URL for export. Returning anything other than
15
+ * a non-empty string rejects the image; links never reach this callback.
16
+ */
17
+ export type LocalImageResolver = (url: string) => string | null;
7
18
  export interface LocalDocumentViewProps {
8
19
  document: LocalDocument;
9
20
  runtime: LocalRuntime;
10
21
  onDiagnostics?: (diagnostics: Diagnostic[]) => void;
11
22
  urlPolicy?: LocalUrlPolicy;
23
+ /** UI language for built-in labels and validation messages; defaults to English. */
24
+ locale?: LocalLocale;
25
+ /**
26
+ * Trusted theme manifests. Their CSS is imported by the host separately; the
27
+ * renderer only resolves names to a root attribute and never loads CSS.
28
+ */
29
+ themes?: readonly LocalThemeDefinition[];
30
+ /** Document mode; `auto` follows the nearest host attribute or the OS. */
31
+ colorScheme?: LocalColorScheme;
32
+ /**
33
+ * `interactive` (default) renders form controls; `static` renders read-only
34
+ * values suitable for export while still evaluating the runtime.
35
+ */
36
+ mode?: LocalRenderMode;
37
+ /**
38
+ * Render static controls for the first pass, then switch to `mode` after
39
+ * mount. The first client render matches static server markup during
40
+ * hydration, and JavaScript-disabled readers keep the static document.
41
+ */
42
+ staticFirst?: boolean;
43
+ /** Trusted image URL mapping; only called after the image URL passed validation. */
44
+ imageResolver?: LocalImageResolver;
12
45
  }
13
46
  export interface LocalReactiveDocumentProps {
14
47
  source: string;
15
48
  onDiagnostics?: (diagnostics: Diagnostic[]) => void;
16
49
  urlPolicy?: LocalUrlPolicy;
50
+ /** UI language for built-in labels and validation messages; defaults to English. */
51
+ locale?: LocalLocale;
52
+ /** Trusted theme manifests; their CSS stays host-owned. */
53
+ themes?: readonly LocalThemeDefinition[];
54
+ /** Document mode; `auto` follows the nearest host attribute or the OS. */
55
+ colorScheme?: LocalColorScheme;
56
+ /** Rendering mode forwarded to `LocalDocumentView`; defaults to `interactive`. */
57
+ mode?: LocalRenderMode;
58
+ /** Static-first hydration behavior forwarded to `LocalDocumentView`. */
59
+ staticFirst?: boolean;
60
+ /** Trusted image URL mapping forwarded to `LocalDocumentView`. */
61
+ imageResolver?: LocalImageResolver;
62
+ }
63
+ interface LocalComponentProps {
64
+ node: LocalNode;
65
+ visible: boolean;
17
66
  }
18
- export declare function LocalDocumentView({ document, runtime, onDiagnostics, urlPolicy, }: LocalDocumentViewProps): import("react").JSX.Element;
19
- export declare function LocalReactiveDocument({ source, onDiagnostics, urlPolicy, }: LocalReactiveDocumentProps): import("react").JSX.Element;
67
+ export declare const VISUAL_COMPONENTS: Set<string>;
68
+ /**
69
+ * Author-facing length validation. The defensive resource limit stays in
70
+ * UTF-16 units (`value.length`), but `min-length`/`max-length` are code-point
71
+ * counts, matching `len()` and the runtime write validator.
72
+ */
73
+ export declare function textProblem(value: string, options: {
74
+ required: boolean;
75
+ minLength?: number;
76
+ maxLength?: number;
77
+ email?: boolean;
78
+ }, t?: Localize): string | null;
79
+ export declare const COMPONENTS: Record<string, (props: LocalComponentProps) => ReactNode>;
80
+ export declare function LocalDocumentView({ document, runtime, onDiagnostics, urlPolicy, locale, themes, colorScheme, mode, staticFirst, imageResolver, }: LocalDocumentViewProps): import("react").JSX.Element;
81
+ export declare function LocalReactiveDocument({ source, onDiagnostics, urlPolicy, locale, themes, colorScheme, mode, staticFirst, imageResolver, }: LocalReactiveDocumentProps): import("react").JSX.Element;
82
+ export {};
@@ -0,0 +1,63 @@
1
+ import type { Diagnostic, SourceRange } from './types.js';
2
+ /**
3
+ * DOM-free authoring services for the local interaction syntax.
4
+ *
5
+ * Everything here works from the same source offsets as the parser and the
6
+ * compiler: positions are UTF-16 code units into the original document. Active
7
+ * syntax is taken from `parseLocal`. Code, display math, comments, escaped
8
+ * syntax, footnotes and unknown/fallback regions produce no binding reads or
9
+ * formatting edits; computable plot parameters use the LaTeX AST.
10
+ */
11
+ export interface AuthorToken {
12
+ kind: string;
13
+ range: SourceRange;
14
+ }
15
+ export interface AuthorBinding {
16
+ name: string;
17
+ declarations: SourceRange[];
18
+ references: SourceRange[];
19
+ }
20
+ export interface AuthorAnalysis {
21
+ tokens: AuthorToken[];
22
+ bindings: AuthorBinding[];
23
+ diagnostics: Diagnostic[];
24
+ }
25
+ export type AuthorCompletionKind = 'tag' | 'attribute' | 'binding' | 'value';
26
+ export interface AuthorCompletion {
27
+ label: string;
28
+ insertText: string;
29
+ range: SourceRange;
30
+ kind: AuthorCompletionKind;
31
+ detail?: string;
32
+ }
33
+ export interface AuthorRename {
34
+ source: string;
35
+ edits: {
36
+ range: SourceRange;
37
+ text: string;
38
+ }[];
39
+ }
40
+ /** Analyze active syntax, binding declarations/references and compile diagnostics. */
41
+ export declare function analyzeLocalSource(source: string): AuthorAnalysis;
42
+ /**
43
+ * Complete tags, schema attributes, enum values and declared binding names at
44
+ * `offset`. Replacement ranges cover an already-typed valid suffix so applying
45
+ * a suggestion never duplicates letters. Inactive regions yield no results.
46
+ */
47
+ export declare function completeLocalSource(source: string, offset: number): AuthorCompletion[];
48
+ /**
49
+ * Rename a declared binding and every active reference. Literal attribute
50
+ * text, Markdown text, strings inside expressions, code, display math, comments
51
+ * and fallback regions are preserved. Plot parameters retain their computed
52
+ * meaning. Invalid names, collisions and structural
53
+ * parse failures are rejected.
54
+ */
55
+ export declare function renameLocalBinding(source: string, oldName: string, newName: string): AuthorRename;
56
+ /**
57
+ * Conservatively normalize whitespace inside recognized reactive tags:
58
+ * single spaces between attributes, no spaces around `=`, no space before `>`,
59
+ * canonical closing tags. Quotes, attribute order and values are untouched.
60
+ * Markdown, newlines, indentation, code, math and fallback regions are not
61
+ * modified. Any compile error leaves the document unchanged.
62
+ */
63
+ export declare function formatLocalSource(source: string): string;
@@ -0,0 +1,4 @@
1
+ export declare function sumNumberArray(values: readonly number[]): number;
2
+ export declare function averageNumberArray(values: readonly number[]): number | null;
3
+ export declare function minNumberArray(values: readonly number[]): number | null;
4
+ export declare function maxNumberArray(values: readonly number[]): number | null;
@@ -0,0 +1,2 @@
1
+ /** True only for a standard CSS named color or #RGB / #RRGGBB. */
2
+ export declare function isLocalColor(value: string): boolean;
@@ -1,3 +1,3 @@
1
- import type { LocalCompileResult } from './types.js';
2
- export declare function compileLocal(source: string): LocalCompileResult;
3
- export declare function compileLocalDocument(source: string): LocalCompileResult;
1
+ import type { LocalCompileOptions, LocalCompileResult } from './types.js';
2
+ export declare function compileLocal(source: string, options?: LocalCompileOptions): LocalCompileResult;
3
+ export declare function compileLocalDocument(source: string, options?: LocalCompileOptions): LocalCompileResult;
@@ -0,0 +1,53 @@
1
+ import { LocalExpressionError, type LocalExpression } from './expression.js';
2
+ import type { LocalComputation, LocalValue, LocalValueKind } from './types.js';
3
+ /**
4
+ * Declarations are resolved in one bounded pass: every expression is compiled
5
+ * once, the dependency graph is topologically ordered with an iterative Kahn
6
+ * walk (no recursion over long chains), and types are inferred once per node.
7
+ * `const` values are evaluated statically so authors see domain errors at
8
+ * compile time; the runtime evaluates `computed` values once per revision.
9
+ */
10
+ export interface ComputationInput {
11
+ name: string;
12
+ kind: 'computed' | 'const';
13
+ /** Trimmed expression between `{{` and `}}`. */
14
+ source: string;
15
+ /** Absolute source offset of the expression, used for diagnostics. */
16
+ expressionOffset: number;
17
+ nodeId: string;
18
+ range: {
19
+ start: number;
20
+ end: number;
21
+ };
22
+ }
23
+ export type ComputationReport = (code: string, message: string, start: number, end?: number) => void;
24
+ export interface ResolvedComputations {
25
+ computations: Record<string, LocalComputation>;
26
+ kinds: Record<string, LocalValueKind>;
27
+ /** Dependency-safe order, excluding declarations that could not resolve. */
28
+ order: string[];
29
+ expressions: Map<string, LocalExpression>;
30
+ constValues: Record<string, LocalValue>;
31
+ }
32
+ /**
33
+ * Topological order for metadata that has already been validated. The runtime
34
+ * uses this to evaluate a hand-built document without trusting declaration
35
+ * order; unresolved names are reported through `cyclic`.
36
+ */
37
+ export declare function orderComputations(computations: Record<string, LocalComputation>): {
38
+ order: string[];
39
+ cyclic: string[];
40
+ };
41
+ export declare function resolveComputationGraph(inputs: ComputationInput[], controls: Record<string, LocalValueKind>, report: ComputationReport): ResolvedComputations;
42
+ export interface ComputationEvaluation {
43
+ values: Record<string, LocalValue>;
44
+ errors: Map<string, LocalExpressionError>;
45
+ }
46
+ /**
47
+ * Evaluate `computed` declarations against a control snapshot. Constants are
48
+ * supplied from their static values and are never recalculated. Failures are
49
+ * recorded rather than thrown; later declarations see a getter that rethrows
50
+ * the original error only when the failing name is actually read, which keeps
51
+ * short-circuited branches and independent consumers working.
52
+ */
53
+ export declare function evaluateComputations(computations: Record<string, LocalComputation>, order: string[], expressions: Map<string, LocalExpression>, controls: Record<string, LocalValue>, constValues: Record<string, LocalValue>): ComputationEvaluation;
@@ -0,0 +1,22 @@
1
+ export declare function trimText(text: string): string;
2
+ /** Unicode default lower-case mapping; not tailored to a locale. */
3
+ export declare function lowerText(text: string): string;
4
+ /** Unicode default upper-case mapping; not tailored to a locale. */
5
+ export declare function upperText(text: string): string;
6
+ export declare function startsWithText(text: string, search: string): boolean;
7
+ export declare function endsWithText(text: string, search: string): boolean;
8
+ /**
9
+ * Replace every non-overlapping literal occurrence. There is no pattern or
10
+ * replacement-template interpretation, so `$&` and friends stay literal.
11
+ * The exact output size is counted before building any result.
12
+ */
13
+ export declare function replaceLiteral(text: string, search: string, replacement: string): string;
14
+ /**
15
+ * Slice by Unicode code point, matching `len()` rather than UTF-16 units.
16
+ * Negative indexes count from the end and out-of-range indexes are clamped.
17
+ */
18
+ export declare function sliceCodePoints(text: string, start: number, end: number | undefined): string;
19
+ /** Compare two calendar dates: -1 when `left` is earlier, 0 when equal, 1 later. */
20
+ export declare function compareDates(left: string, right: string): number;
21
+ /** Signed `left - right` difference in the requested unit. */
22
+ export declare function diffDates(left: string, right: string, unit?: string): number;
@@ -0,0 +1,65 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { Localize } from './i18n.js';
3
+ import type { LocalNode, LocalRuntime, LocalValue } from './types.js';
4
+ /**
5
+ * `<data-table>` renders generated rows from a list expression. Everything in
6
+ * this module is deterministic and renderer-only: rows come from the runtime,
7
+ * the row scope exposes `item`/`index`, and keys are validated before any row
8
+ * markup is allocated. Compilation performs the same checks independently.
9
+ */
10
+ export type DataTableFailure = 'label' | 'columns' | 'max-rows' | 'rows' | 'rows-budget' | 'key' | 'text-budget';
11
+ export interface DataTableCell {
12
+ ok: boolean;
13
+ text: string;
14
+ }
15
+ export interface DataTableRow {
16
+ /** Encoded primitive identity; React never sees a positional key. */
17
+ key: string;
18
+ cells: DataTableCell[];
19
+ }
20
+ export interface DataTableColumnSpec {
21
+ label: string;
22
+ /** Full expression source (the part between `{{` and `}}`). */
23
+ value: string;
24
+ }
25
+ export interface DataTableModel {
26
+ columns: string[];
27
+ rows: DataTableRow[];
28
+ empty: boolean;
29
+ }
30
+ export type DataTableBuildResult = {
31
+ ok: true;
32
+ model: DataTableModel;
33
+ } | {
34
+ ok: false;
35
+ failure: DataTableFailure;
36
+ };
37
+ export interface DataTableBuildOptions {
38
+ readonly rows: readonly LocalValue[];
39
+ readonly columns: readonly DataTableColumnSpec[];
40
+ readonly keyExpression: string;
41
+ readonly runtime: Pick<LocalRuntime, 'evaluate'>;
42
+ readonly maxRows?: number;
43
+ readonly budget?: number;
44
+ }
45
+ /**
46
+ * Encode a primitive key with its type so numeric `1` and string `"1"` remain
47
+ * distinct. `-0` and `0` share one identity. `null` marks an invalid key.
48
+ */
49
+ export declare function encodeDataTableKey(value: LocalValue): string | null;
50
+ /** Evaluate `rows` in the ordinary global scope and validate its shape. */
51
+ export declare function evaluateDataTableRows(runtime: Pick<LocalRuntime, 'evaluate'>, expression: string): LocalValue[];
52
+ /**
53
+ * Build row keys and cell text before rendering. Row count, column count and
54
+ * the cumulative text budget are enforced up front; any breach returns a
55
+ * whole-table failure instead of a partial model.
56
+ */
57
+ export declare function buildDataTableModel(options: DataTableBuildOptions): DataTableBuildResult;
58
+ export declare function dataTableFailureMessage(t: Localize, failure: DataTableFailure): string;
59
+ export interface DataTableViewProps {
60
+ node: LocalNode;
61
+ visible: boolean;
62
+ runtime: Pick<LocalRuntime, 'evaluate'>;
63
+ t: Localize;
64
+ }
65
+ export declare function DataTableView({ node, runtime, t }: DataTableViewProps): ReactNode;
@@ -0,0 +1,2 @@
1
+ /** Shared Gregorian date-only calendar, compatible with native date inputs. */
2
+ export declare function localDateTimestamp(text: string): number | null;
@@ -0,0 +1,31 @@
1
+ import type { LocalDocument, LocalRuntime } from './types.js';
2
+ /**
3
+ * Binding keys a node subtree reads. `null` marks nodes whose reads cannot be
4
+ * decided statically; their memo boundary must re-render on every revision.
5
+ */
6
+ export type NodeDependencies = readonly string[] | null;
7
+ export type DependencyIndex = ReadonlyMap<string, NodeDependencies>;
8
+ /**
9
+ * Wildcard index used when no analysis is available: a missing entry means the
10
+ * node reads cannot be decided, so it must re-render on every revision.
11
+ */
12
+ export declare const EMPTY_DEPENDENCY_INDEX: DependencyIndex;
13
+ /**
14
+ * Memo boundaries must observe resets anywhere below them. Keep these sums
15
+ * separate from runtime.resetToken: a descendant reset must not reset the
16
+ * ancestor's own UI state. One traversal per revision also keeps nested block
17
+ * rendering from repeatedly walking the same subtrees.
18
+ */
19
+ export declare function collectSubtreeResetTokens(runtime: LocalRuntime): ReadonlyMap<string, number>;
20
+ /**
21
+ * Collects, for every node, the union of binding keys read by the node and its
22
+ * descendants. `null` marks a subtree whose reads cannot be decided statically
23
+ * (own analysis failure or any undecidable descendant).
24
+ */
25
+ export declare function collectNodeDependencies(document: LocalDocument): DependencyIndex;
26
+ /**
27
+ * Persists the dependency index on the document so compiled documents carry
28
+ * the analysis as data. Documents built by hand keep working: the renderer
29
+ * falls back to running the same analysis on first use.
30
+ */
31
+ export declare function attachNodeDependencies(document: LocalDocument): void;