@elaraai/e3-ui 1.0.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/CLA.md +26 -0
- package/CONTRIBUTING.md +28 -0
- package/LICENSE.md +31 -0
- package/README.md +149 -0
- package/dist/src/buttons.d.ts +2 -0
- package/dist/src/buttons.d.ts.map +1 -0
- package/dist/src/buttons.js +2 -0
- package/dist/src/buttons.js.map +1 -0
- package/dist/src/data.d.ts +241 -0
- package/dist/src/data.d.ts.map +1 -0
- package/dist/src/data.js +195 -0
- package/dist/src/data.js.map +1 -0
- package/dist/src/derive.d.ts +33 -0
- package/dist/src/derive.d.ts.map +1 -0
- package/dist/src/derive.js +64 -0
- package/dist/src/derive.js.map +1 -0
- package/dist/src/diff.d.ts +335 -0
- package/dist/src/diff.d.ts.map +1 -0
- package/dist/src/diff.js +197 -0
- package/dist/src/diff.js.map +1 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/manifest.d.ts +27 -0
- package/dist/src/manifest.d.ts.map +1 -0
- package/dist/src/manifest.js +29 -0
- package/dist/src/manifest.js.map +1 -0
- package/dist/src/ontology.d.ts +517 -0
- package/dist/src/ontology.d.ts.map +1 -0
- package/dist/src/ontology.js +311 -0
- package/dist/src/ontology.js.map +1 -0
- package/dist/src/ui.d.ts +57 -0
- package/dist/src/ui.d.ts.map +1 -0
- package/dist/src/ui.js +72 -0
- package/dist/src/ui.js.map +1 -0
- package/dist/src/utils.d.ts +21 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +24 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/test/data.examples.d.ts +20 -0
- package/dist/test/data.examples.d.ts.map +1 -0
- package/dist/test/data.examples.js +156 -0
- package/dist/test/data.examples.js.map +1 -0
- package/dist/test/diff.examples.d.ts +138 -0
- package/dist/test/diff.examples.d.ts.map +1 -0
- package/dist/test/diff.examples.js +964 -0
- package/dist/test/diff.examples.js.map +1 -0
- package/dist/test/ontology.examples.d.ts +412 -0
- package/dist/test/ontology.examples.d.ts.map +1 -0
- package/dist/test/ontology.examples.js +298 -0
- package/dist/test/ontology.examples.js.map +1 -0
- package/package.json +80 -0
package/dist/src/data.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Reactive dataset binding for e3 UI tasks.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import { East, NullType, BooleanType, FunctionType, StructType, VariantType, OptionType, none, some, variant, } from '@elaraai/east';
|
|
11
|
+
import { TreePathType, DatasetStatusType } from '@elaraai/e3-types';
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Mode + binding descriptor types — shared with the Diff component.
|
|
14
|
+
// ============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* The two operating modes for {@link Data.bind}.
|
|
17
|
+
*
|
|
18
|
+
* @property staged - Edits are buffered locally (in-memory + IndexedDB) and
|
|
19
|
+
* only flushed on `commit()`. Use for editor flows where the user reviews
|
|
20
|
+
* pending changes before publishing.
|
|
21
|
+
* @property direct - Every `write()` immediately mutates the destination
|
|
22
|
+
* (the source dataset, or the patch dataset when `patch` is set). Use for
|
|
23
|
+
* live shared cursors and other no-staging surfaces.
|
|
24
|
+
*/
|
|
25
|
+
export const DataBindModeType = VariantType({
|
|
26
|
+
staged: NullType,
|
|
27
|
+
direct: NullType,
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Descriptor for a single binding the {@link Diff.Root} component displays.
|
|
31
|
+
*
|
|
32
|
+
* Every {@link Data.bind} call exposes this descriptor as its `binding`
|
|
33
|
+
* field, so callers can wire a Diff card via `Diff.Root({ bindings:
|
|
34
|
+
* [view.binding, ...] })` without re-spelling the source / patch paths.
|
|
35
|
+
*
|
|
36
|
+
* @property source - The dataset path of the source value the binding
|
|
37
|
+
* reads from.
|
|
38
|
+
* @property patch - When the binding writes through a separate patch
|
|
39
|
+
* dataset, this is its path. `none` means the binding writes directly to
|
|
40
|
+
* the source on commit (or to the staging buffer in staged mode).
|
|
41
|
+
* @property mode - The binding's operating mode — see {@link DataBindModeType}.
|
|
42
|
+
*/
|
|
43
|
+
export const DiffBindingType = StructType({
|
|
44
|
+
source: TreePathType,
|
|
45
|
+
patch: OptionType(TreePathType),
|
|
46
|
+
mode: DataBindModeType,
|
|
47
|
+
});
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// Bind handle — return type of `Data.bind`.
|
|
50
|
+
// ============================================================================
|
|
51
|
+
/**
|
|
52
|
+
* The struct returned by every {@link Data.bind} call. Every field is
|
|
53
|
+
* present regardless of `mode` / `patch` — the per-mode semantics are
|
|
54
|
+
* captured in the property docs of {@link Data.bind}.
|
|
55
|
+
*
|
|
56
|
+
* @property read - Reactive accessor for the binding's view of the source.
|
|
57
|
+
* @property write - Update the binding (buffer in staged mode, dataset in
|
|
58
|
+
* direct mode). Always returns null.
|
|
59
|
+
* @property writeAndStart - Like `write`, but kicks the workspace dataflow
|
|
60
|
+
* so downstream tasks recompute. Only meaningful when `mode = "direct"`
|
|
61
|
+
* and `patch` is absent — in other modes it falls back to `write`.
|
|
62
|
+
* @property source - Read the raw source value with no overlay applied.
|
|
63
|
+
* @property pending - True when there is an in-flight change waiting to be
|
|
64
|
+
* committed. Always false in `mode = "direct"` without a `patch` dataset.
|
|
65
|
+
* @property commit - Resolve the in-flight change. The destination depends
|
|
66
|
+
* on `mode` / `patch` — see {@link Data.bind} for the full matrix.
|
|
67
|
+
* @property discard - Drop the in-flight change.
|
|
68
|
+
* @property has - True iff the source dataset has a value.
|
|
69
|
+
* @property status - Per-dataset freshness signal — see
|
|
70
|
+
* {@link DatasetStatusType}.
|
|
71
|
+
* @property binding - Descriptor for this binding — pass directly to
|
|
72
|
+
* {@link Diff.Root}'s `bindings` array.
|
|
73
|
+
*/
|
|
74
|
+
export const DataBindHandleType = (t) => StructType({
|
|
75
|
+
read: FunctionType([], t),
|
|
76
|
+
write: FunctionType([t], NullType),
|
|
77
|
+
writeAndStart: FunctionType([t], NullType),
|
|
78
|
+
source: FunctionType([], t),
|
|
79
|
+
pending: FunctionType([], BooleanType),
|
|
80
|
+
commit: FunctionType([], NullType),
|
|
81
|
+
discard: FunctionType([], NullType),
|
|
82
|
+
has: FunctionType([], BooleanType),
|
|
83
|
+
status: FunctionType([], DatasetStatusType),
|
|
84
|
+
binding: DiffBindingType,
|
|
85
|
+
});
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// Platform function — single unified definition.
|
|
88
|
+
// ============================================================================
|
|
89
|
+
/**
|
|
90
|
+
* The underlying `Data.bind` platform-function definition. End-users
|
|
91
|
+
* should call {@link Data.bind} (the typed factory in this module);
|
|
92
|
+
* runtime implementations register against this raw definition via
|
|
93
|
+
* `bindPlatformFn.implement(...)`.
|
|
94
|
+
*/
|
|
95
|
+
export const bindPlatformFn = East.genericPlatform("data_bind", ["T"], [TreePathType, OptionType(TreePathType), DataBindModeType], StructType({
|
|
96
|
+
read: FunctionType([], "T"),
|
|
97
|
+
write: FunctionType(["T"], NullType),
|
|
98
|
+
writeAndStart: FunctionType(["T"], NullType),
|
|
99
|
+
source: FunctionType([], "T"),
|
|
100
|
+
pending: FunctionType([], BooleanType),
|
|
101
|
+
commit: FunctionType([], NullType),
|
|
102
|
+
discard: FunctionType([], NullType),
|
|
103
|
+
has: FunctionType([], BooleanType),
|
|
104
|
+
status: FunctionType([], DatasetStatusType),
|
|
105
|
+
binding: DiffBindingType,
|
|
106
|
+
}), { optional: true });
|
|
107
|
+
/**
|
|
108
|
+
* The Data namespace — reactive dataset binding for e3 UI tasks.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* `Data.bind` exposes a single binding handle that adapts to four
|
|
112
|
+
* combinations of `mode` (staged | direct) and `patch` (absent | present).
|
|
113
|
+
* The full per-mode semantics matrix is documented on {@link Data.bind}.
|
|
114
|
+
*
|
|
115
|
+
* Use inside `Reactive.Root` for reactive re-rendering when the underlying
|
|
116
|
+
* datasets change.
|
|
117
|
+
*/
|
|
118
|
+
export const Data = {
|
|
119
|
+
/**
|
|
120
|
+
* Bind a dataset path to a reactive view of its current value, with
|
|
121
|
+
* optional local staging or a separate server-backed patch dataset.
|
|
122
|
+
*
|
|
123
|
+
* @typeParam T - The East type of the source dataset value.
|
|
124
|
+
* @param types - Single-element type-args tuple `[T]`.
|
|
125
|
+
* @param source - The source dataset path.
|
|
126
|
+
* @param options - {@link DataBindOptions}. When omitted, defaults to
|
|
127
|
+
* `{ mode: "staged" }` (no separate patch dataset, edits buffered
|
|
128
|
+
* locally until commit).
|
|
129
|
+
* @returns A handle struct described by {@link DataBindHandleType} —
|
|
130
|
+
* `read` / `write` / `writeAndStart` / `source` / `pending` /
|
|
131
|
+
* `commit` / `discard` / `has` / `status` / `binding`.
|
|
132
|
+
*
|
|
133
|
+
* @remarks
|
|
134
|
+
* Per-mode semantics matrix (rows are `mode × patch`, columns are
|
|
135
|
+
* methods):
|
|
136
|
+
*
|
|
137
|
+
* | mode | patch | `read()` | `write(v)` | `commit()` | `discard()` | `pending()` |
|
|
138
|
+
* |---------|---------|-------------------------------------|-----------------------------------------|-----------------------------------------------------|------------------------------|---------------------|
|
|
139
|
+
* | direct | absent | source | dataset write | no-op | no-op | always false |
|
|
140
|
+
* | direct | present | apply(source, patch dataset) | write diff(source, v) → patch dataset | apply patch → source; clear patch dataset | clear patch dataset | patch non-trivial |
|
|
141
|
+
* | staged | absent | buffered ?? source | update buffer (pin snapshot first time) | apply buffer → source; drop buffer | drop buffer | buffer non-empty |
|
|
142
|
+
* | staged | present | buffered ?? apply(source, patch) | update buffer | write diff(source, buffer) → patch dataset; drop buffer | drop buffer (patch intact) | buffer non-empty |
|
|
143
|
+
*
|
|
144
|
+
* `writeAndStart(v)` kicks the workspace dataflow after the write — only
|
|
145
|
+
* meaningful for `mode = "direct"` without a `patch` dataset; in other
|
|
146
|
+
* modes it falls back to `write(v)` (the workspace dataflow is triggered
|
|
147
|
+
* on `commit` instead).
|
|
148
|
+
*
|
|
149
|
+
* The `binding` field surfaces this binding's descriptor as a
|
|
150
|
+
* {@link DiffBindingType} value — pass it directly to
|
|
151
|
+
* {@link Diff.Root}'s `bindings` array to surface the in-flight change
|
|
152
|
+
* in a Diff card.
|
|
153
|
+
*
|
|
154
|
+
* Use inside `Reactive.Root` so `read` / `pending` / `status` re-fire
|
|
155
|
+
* on every dataset or staging-buffer change.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* import { East, FloatType, NullType } from "@elaraai/east";
|
|
160
|
+
* import { Reactive, Slider, UIComponentType } from "@elaraai/east-ui";
|
|
161
|
+
* import { Data, Diff } from "@elaraai/e3-ui";
|
|
162
|
+
* import * as e3 from "@elaraai/e3";
|
|
163
|
+
*
|
|
164
|
+
* const thresholdInput = e3.input("threshold", FloatType, 38.0);
|
|
165
|
+
*
|
|
166
|
+
* // Mirrors `dataBindStaged` in test/data.examples.ts.
|
|
167
|
+
* const dataBindStaged = East.function([], UIComponentType, _$ => {
|
|
168
|
+
* return Reactive.Root(East.function([], UIComponentType, $ => {
|
|
169
|
+
* const view = $.let(Data.bind([FloatType], thresholdInput.path));
|
|
170
|
+
* const value = $.let(view.read(), FloatType);
|
|
171
|
+
* return Slider.Root(value, {
|
|
172
|
+
* min: 30.0, max: 60.0, step: 1.0,
|
|
173
|
+
* onChangeEnd: East.function([FloatType], NullType, ($, v) => {
|
|
174
|
+
* $(view.write(v));
|
|
175
|
+
* }),
|
|
176
|
+
* });
|
|
177
|
+
* }));
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
bind(types, source, options) {
|
|
182
|
+
// Source / patch paths must be statically known so manifest
|
|
183
|
+
// derivation (`deriveManifest`) can preload them. We wrap each
|
|
184
|
+
// explicitly via `East.value(...)` to force a single literal
|
|
185
|
+
// `Value` IR node — the only IR shape `derive.ts` needs to
|
|
186
|
+
// handle.
|
|
187
|
+
const sourceValue = East.value(source, TreePathType);
|
|
188
|
+
const modeValue = East.value(variant(options?.mode ?? "staged", null), DataBindModeType);
|
|
189
|
+
const patchValue = options?.patch === undefined
|
|
190
|
+
? East.value(none, OptionType(TreePathType))
|
|
191
|
+
: East.value(some(options.patch), OptionType(TreePathType));
|
|
192
|
+
return bindPlatformFn(types, sourceValue, patchValue, modeValue);
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/data.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACH,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,OAAO,GAKV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAiB,MAAM,mBAAmB,CAAC;AAEnF,+EAA+E;AAC/E,oEAAoE;AACpE,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;IACxC,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACnB,CAAC,CAAC;AAOH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;IACtC,MAAM,EAAE,YAAY;IACpB,KAAK,EAAG,UAAU,CAAC,YAAY,CAAC;IAChC,IAAI,EAAI,gBAAgB;CAC3B,CAAC,CAAC;AAIH,+EAA+E;AAC/E,4CAA4C;AAC5C,+EAA+E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Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Derive a `DataManifest` by walking an East function's IR.
|
|
7
|
+
*
|
|
8
|
+
* Finds every `Data.bind(...)` platform call (the walker recurses into
|
|
9
|
+
* nested `FunctionIR` bodies) and reads its source + (optional) patch
|
|
10
|
+
* path arguments.
|
|
11
|
+
*
|
|
12
|
+
* Both arguments are required to be statically known JS-side
|
|
13
|
+
* `TreePath`s — the public `Data.bind` factory enforces this through
|
|
14
|
+
* its TS signature. Each path arrives as East-compiled structured IR:
|
|
15
|
+
*
|
|
16
|
+
* - source: `NewArray` of `Variant("field", Value(string))` (the
|
|
17
|
+
* TreePath array literal)
|
|
18
|
+
* - patch: `Variant("some"|"none", inner)` where `inner` for
|
|
19
|
+
* `some` is the same `NewArray` shape as a source path
|
|
20
|
+
*
|
|
21
|
+
* Anything else is a programmer error and throws.
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
25
|
+
import type { IR } from '@elaraai/east';
|
|
26
|
+
import type { DataManifest } from './manifest.js';
|
|
27
|
+
/** Walk `fn`'s IR and derive its bound-path manifest. */
|
|
28
|
+
export declare function deriveManifest(fn: {
|
|
29
|
+
toIR(): {
|
|
30
|
+
ir: IR;
|
|
31
|
+
};
|
|
32
|
+
}): DataManifest;
|
|
33
|
+
//# sourceMappingURL=derive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../src/derive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,EAAE,EAA8C,MAAM,eAAe,CAAC;AAGpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAKlD,yDAAyD;AACzD,wBAAgB,cAAc,CAC1B,EAAE,EAAE;IAAE,IAAI,IAAI;QAAE,EAAE,EAAE,EAAE,CAAA;KAAE,CAAA;CAAE,GAC3B,YAAY,CA4Bd"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { variant, walkIR, literalValueOf } from '@elaraai/east';
|
|
6
|
+
/** Platform-fn name we extract paths from. */
|
|
7
|
+
const DATA_BIND = "data_bind";
|
|
8
|
+
/** Walk `fn`'s IR and derive its bound-path manifest. */
|
|
9
|
+
export function deriveManifest(fn) {
|
|
10
|
+
const paths = [];
|
|
11
|
+
walkIR(fn.toIR().ir, (node) => {
|
|
12
|
+
if (node.type !== 'Platform')
|
|
13
|
+
return;
|
|
14
|
+
const platform = node;
|
|
15
|
+
if (platform.value.name !== DATA_BIND)
|
|
16
|
+
return;
|
|
17
|
+
// arg[0] — source: always a NewArray of Variant("field", Value(string)).
|
|
18
|
+
paths.push(readTreePath(platform.value.arguments[0]));
|
|
19
|
+
// arg[1] — patch: Option<TreePath>, encoded as a Variant IR with
|
|
20
|
+
// case "some" (carrying a NewArray inner) or "none".
|
|
21
|
+
const patchArg = platform.value.arguments[1];
|
|
22
|
+
if (patchArg.type !== 'Variant') {
|
|
23
|
+
throw new Error(`Data.bind: patch must be a literal Option<TreePath>; got dynamic IR (${patchArg.type}).`);
|
|
24
|
+
}
|
|
25
|
+
const patchVariant = patchArg.value;
|
|
26
|
+
if (patchVariant.case === 'some') {
|
|
27
|
+
paths.push(readTreePath(patchVariant.value));
|
|
28
|
+
}
|
|
29
|
+
else if (patchVariant.case !== 'none') {
|
|
30
|
+
throw new Error(`Data.bind: patch variant tag must be "some" or "none"; got "${patchVariant.case}".`);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return { paths: dedupePaths(paths) };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Read a literal `TreePath` from a `NewArray` IR node. Each element is
|
|
37
|
+
* a `Variant("field", Value(string))` produced by East.value-wrapping a
|
|
38
|
+
* `TreePath` JS literal. Used for both the source path arg and the
|
|
39
|
+
* inner of a `some(path)` patch variant.
|
|
40
|
+
*/
|
|
41
|
+
function readTreePath(ir) {
|
|
42
|
+
if (ir.type !== 'NewArray') {
|
|
43
|
+
throw new Error(`Data.bind: path must be a literal TreePath; got dynamic IR (${ir.type}). ` +
|
|
44
|
+
`Pass a JS TreePath (e.g. someInput.path), not a computed expression.`);
|
|
45
|
+
}
|
|
46
|
+
return ir.value.values.map((segIR) => {
|
|
47
|
+
const v = segIR;
|
|
48
|
+
const fieldName = literalValueOf(v.value.value);
|
|
49
|
+
return variant('field', fieldName);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function dedupePaths(paths) {
|
|
53
|
+
const seen = new Set();
|
|
54
|
+
const result = [];
|
|
55
|
+
for (const p of paths) {
|
|
56
|
+
const k = p.map(s => `${s.type}:${s.value}`).join('/');
|
|
57
|
+
if (seen.has(k))
|
|
58
|
+
continue;
|
|
59
|
+
seen.add(k);
|
|
60
|
+
result.push(p);
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=derive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive.js","sourceRoot":"","sources":["../../src/derive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwBH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIhE,8CAA8C;AAC9C,MAAM,SAAS,GAAG,WAAW,CAAC;AAE9B,yDAAyD;AACzD,MAAM,UAAU,cAAc,CAC1B,EAA0B;IAE1B,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;QAC1B,IA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S,EAAE,EAAE;QACrD,MAAM,CAAC,GAAG,KAAkB,CAAC;QAC7B,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,KAAgB,CAAW,CAAC;QACrE,OAAO,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,WAAW,CAAC,KAAiB;IAClC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACpB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvD,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,SAAS;QAC1B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Diff component — transactional review of pending changes for any
|
|
7
|
+
* combination of {@link Data.bind} bindings.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* The Diff card surfaces the in-flight change for each binding the caller
|
|
11
|
+
* lists in `bindings`. Per-leaf Discard, per-group Discard-all, and a
|
|
12
|
+
* footer Apply button drive the binding's commit flow. Conflicts surface
|
|
13
|
+
* inline as orange chooser rows (staged-mode 3-way drift) and as orange
|
|
14
|
+
* "stale" warning badges (drift between a patch dataset's expectations
|
|
15
|
+
* and the current source).
|
|
16
|
+
*
|
|
17
|
+
* Declared via the `EastUI.component` extension API — the React renderer
|
|
18
|
+
* lives in `@elaraai/e3-ui-components` and is wired via
|
|
19
|
+
* `implementUIComponent(DiffComponent, EastChakraDiff)` at module load
|
|
20
|
+
* time.
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
import { StringType, BooleanType, NullType, IntegerType, StructType, OptionType, ArrayType, FunctionType, type ExprType, type SubtypeExprOrValue } from "@elaraai/east";
|
|
25
|
+
import { DensityType, type DensityLiteral, type UIComponentType } from "@elaraai/east-ui";
|
|
26
|
+
import { DiffBindingType } from "./data.js";
|
|
27
|
+
/**
|
|
28
|
+
* Visual style escape hatches for the Diff component. Every visible surface
|
|
29
|
+
* is tokenable; defaults come from the host's Chakra theme (Elara AI brand).
|
|
30
|
+
*
|
|
31
|
+
* @property addedBackground - Soft-tint background for added / inserted leaves.
|
|
32
|
+
* @property addedColor - Foreground for added leaves.
|
|
33
|
+
* @property addedBorderColor - Border for added chips.
|
|
34
|
+
* @property removedBackground - Soft-tint background for removed / deleted leaves.
|
|
35
|
+
* @property removedColor - Foreground for removed leaves.
|
|
36
|
+
* @property removedBorderColor - Border for removed chips.
|
|
37
|
+
* @property changedBackground - Soft-tint background for updated leaves.
|
|
38
|
+
* @property changedColor - Foreground for updated leaves.
|
|
39
|
+
* @property changedBorderColor - Border for updated chips.
|
|
40
|
+
* @property unchangedColor - Foreground for unchanged rows when shown.
|
|
41
|
+
* @property acceptedBackground - Lane background for accepted-row indicator.
|
|
42
|
+
* @property acceptedBorderColor - Left-edge accent stripe for accepted rows.
|
|
43
|
+
* @property rejectedBackground - Lane background for rejected rows.
|
|
44
|
+
* @property rejectedBorderColor - Border for rejected rows.
|
|
45
|
+
* @property headerBackground - Card header background.
|
|
46
|
+
* @property summaryBackground - Stats bar background.
|
|
47
|
+
* @property background - Card body background.
|
|
48
|
+
* @property borderColor - Card outer border.
|
|
49
|
+
* @property indentGuideColor - Vertical guide line for nested rows.
|
|
50
|
+
* @property lineNumberColor - Gutter line numbers in unified mode.
|
|
51
|
+
*/
|
|
52
|
+
export declare const DiffStyleType: StructType<{
|
|
53
|
+
readonly addedBackground: OptionType<StringType>;
|
|
54
|
+
readonly addedColor: OptionType<StringType>;
|
|
55
|
+
readonly addedBorderColor: OptionType<StringType>;
|
|
56
|
+
readonly removedBackground: OptionType<StringType>;
|
|
57
|
+
readonly removedColor: OptionType<StringType>;
|
|
58
|
+
readonly removedBorderColor: OptionType<StringType>;
|
|
59
|
+
readonly changedBackground: OptionType<StringType>;
|
|
60
|
+
readonly changedColor: OptionType<StringType>;
|
|
61
|
+
readonly changedBorderColor: OptionType<StringType>;
|
|
62
|
+
readonly unchangedColor: OptionType<StringType>;
|
|
63
|
+
readonly acceptedBackground: OptionType<StringType>;
|
|
64
|
+
readonly acceptedBorderColor: OptionType<StringType>;
|
|
65
|
+
readonly rejectedBackground: OptionType<StringType>;
|
|
66
|
+
readonly rejectedBorderColor: OptionType<StringType>;
|
|
67
|
+
readonly headerBackground: OptionType<StringType>;
|
|
68
|
+
readonly summaryBackground: OptionType<StringType>;
|
|
69
|
+
readonly background: OptionType<StringType>;
|
|
70
|
+
readonly borderColor: OptionType<StringType>;
|
|
71
|
+
readonly indentGuideColor: OptionType<StringType>;
|
|
72
|
+
readonly lineNumberColor: OptionType<StringType>;
|
|
73
|
+
}>;
|
|
74
|
+
/** Type alias for {@link DiffStyleType}. */
|
|
75
|
+
export type DiffStyleType = typeof DiffStyleType;
|
|
76
|
+
export { DiffBindingType } from "./data.js";
|
|
77
|
+
/**
|
|
78
|
+
* Schema for the `Diff` extension component. Internal IR shape — the
|
|
79
|
+
* developer-facing factory `Diff.Root` accepts {@link DataBindHandleType}
|
|
80
|
+
* descriptors and forwards them as `bindings`.
|
|
81
|
+
*
|
|
82
|
+
* @property bindings - The set of bindings to surface in the card. Each
|
|
83
|
+
* entry is a {@link DiffBindingType} value (typically obtained via the
|
|
84
|
+
* `binding` field of a {@link Data.bind} handle).
|
|
85
|
+
* @property readonly - Render the Diff without per-leaf or per-group Discard
|
|
86
|
+
* buttons. The footer Apply / Discard-all still render. Default `false`
|
|
87
|
+
* (interactive review).
|
|
88
|
+
* @property hideUnchanged - Elide unchanged rows. None ⇒ false.
|
|
89
|
+
* @property maxDepth - Cap nesting depth before "Show more" collapses. None ⇒ no cap.
|
|
90
|
+
* @property density - Information-density preset (`comfortable` | `compact`
|
|
91
|
+
* | `condensed`). Defaults to `comfortable`.
|
|
92
|
+
* @property onCommitted - Fired after a successful commit (post-merge).
|
|
93
|
+
* @property onDiscarded - Fired after a successful discard.
|
|
94
|
+
* @property style - Visual style escape hatches.
|
|
95
|
+
*/
|
|
96
|
+
export declare const DiffPayloadType: StructType<{
|
|
97
|
+
readonly bindings: ArrayType<StructType<{
|
|
98
|
+
readonly source: ArrayType<import("@elaraai/east").VariantType<{
|
|
99
|
+
readonly field: StringType;
|
|
100
|
+
}>>;
|
|
101
|
+
readonly patch: OptionType<ArrayType<import("@elaraai/east").VariantType<{
|
|
102
|
+
readonly field: StringType;
|
|
103
|
+
}>>>;
|
|
104
|
+
readonly mode: import("@elaraai/east").VariantType<{
|
|
105
|
+
readonly staged: NullType;
|
|
106
|
+
readonly direct: NullType;
|
|
107
|
+
}>;
|
|
108
|
+
}>>;
|
|
109
|
+
readonly readonly: OptionType<BooleanType>;
|
|
110
|
+
readonly hideUnchanged: OptionType<BooleanType>;
|
|
111
|
+
readonly maxDepth: OptionType<IntegerType>;
|
|
112
|
+
readonly density: OptionType<import("@elaraai/east").VariantType<{
|
|
113
|
+
readonly comfortable: NullType;
|
|
114
|
+
readonly compact: NullType;
|
|
115
|
+
readonly condensed: NullType;
|
|
116
|
+
}>>;
|
|
117
|
+
readonly onCommitted: OptionType<FunctionType<[], NullType>>;
|
|
118
|
+
readonly onDiscarded: OptionType<FunctionType<[], NullType>>;
|
|
119
|
+
readonly style: OptionType<StructType<{
|
|
120
|
+
readonly addedBackground: OptionType<StringType>;
|
|
121
|
+
readonly addedColor: OptionType<StringType>;
|
|
122
|
+
readonly addedBorderColor: OptionType<StringType>;
|
|
123
|
+
readonly removedBackground: OptionType<StringType>;
|
|
124
|
+
readonly removedColor: OptionType<StringType>;
|
|
125
|
+
readonly removedBorderColor: OptionType<StringType>;
|
|
126
|
+
readonly changedBackground: OptionType<StringType>;
|
|
127
|
+
readonly changedColor: OptionType<StringType>;
|
|
128
|
+
readonly changedBorderColor: OptionType<StringType>;
|
|
129
|
+
readonly unchangedColor: OptionType<StringType>;
|
|
130
|
+
readonly acceptedBackground: OptionType<StringType>;
|
|
131
|
+
readonly acceptedBorderColor: OptionType<StringType>;
|
|
132
|
+
readonly rejectedBackground: OptionType<StringType>;
|
|
133
|
+
readonly rejectedBorderColor: OptionType<StringType>;
|
|
134
|
+
readonly headerBackground: OptionType<StringType>;
|
|
135
|
+
readonly summaryBackground: OptionType<StringType>;
|
|
136
|
+
readonly background: OptionType<StringType>;
|
|
137
|
+
readonly borderColor: OptionType<StringType>;
|
|
138
|
+
readonly indentGuideColor: OptionType<StringType>;
|
|
139
|
+
readonly lineNumberColor: OptionType<StringType>;
|
|
140
|
+
}>>;
|
|
141
|
+
}>;
|
|
142
|
+
/** Type alias for {@link DiffPayloadType}. */
|
|
143
|
+
export type DiffPayloadType = typeof DiffPayloadType;
|
|
144
|
+
/**
|
|
145
|
+
* Internal `EastUI.component` carrier. Renderers register against this in
|
|
146
|
+
* `@elaraai/e3-ui-components`. Most callers should use {@link Diff.Root}
|
|
147
|
+
* (which wraps this with the handle-friendly API) rather than touching
|
|
148
|
+
* `DiffComponent` directly.
|
|
149
|
+
*/
|
|
150
|
+
export declare const DiffComponent: import("@elaraai/east-ui").UIComponentDef<StructType<{
|
|
151
|
+
readonly bindings: ArrayType<StructType<{
|
|
152
|
+
readonly source: ArrayType<import("@elaraai/east").VariantType<{
|
|
153
|
+
readonly field: StringType;
|
|
154
|
+
}>>;
|
|
155
|
+
readonly patch: OptionType<ArrayType<import("@elaraai/east").VariantType<{
|
|
156
|
+
readonly field: StringType;
|
|
157
|
+
}>>>;
|
|
158
|
+
readonly mode: import("@elaraai/east").VariantType<{
|
|
159
|
+
readonly staged: NullType;
|
|
160
|
+
readonly direct: NullType;
|
|
161
|
+
}>;
|
|
162
|
+
}>>;
|
|
163
|
+
readonly readonly: OptionType<BooleanType>;
|
|
164
|
+
readonly hideUnchanged: OptionType<BooleanType>;
|
|
165
|
+
readonly maxDepth: OptionType<IntegerType>;
|
|
166
|
+
readonly density: OptionType<import("@elaraai/east").VariantType<{
|
|
167
|
+
readonly comfortable: NullType;
|
|
168
|
+
readonly compact: NullType;
|
|
169
|
+
readonly condensed: NullType;
|
|
170
|
+
}>>;
|
|
171
|
+
readonly onCommitted: OptionType<FunctionType<[], NullType>>;
|
|
172
|
+
readonly onDiscarded: OptionType<FunctionType<[], NullType>>;
|
|
173
|
+
readonly style: OptionType<StructType<{
|
|
174
|
+
readonly addedBackground: OptionType<StringType>;
|
|
175
|
+
readonly addedColor: OptionType<StringType>;
|
|
176
|
+
readonly addedBorderColor: OptionType<StringType>;
|
|
177
|
+
readonly removedBackground: OptionType<StringType>;
|
|
178
|
+
readonly removedColor: OptionType<StringType>;
|
|
179
|
+
readonly removedBorderColor: OptionType<StringType>;
|
|
180
|
+
readonly changedBackground: OptionType<StringType>;
|
|
181
|
+
readonly changedColor: OptionType<StringType>;
|
|
182
|
+
readonly changedBorderColor: OptionType<StringType>;
|
|
183
|
+
readonly unchangedColor: OptionType<StringType>;
|
|
184
|
+
readonly acceptedBackground: OptionType<StringType>;
|
|
185
|
+
readonly acceptedBorderColor: OptionType<StringType>;
|
|
186
|
+
readonly rejectedBackground: OptionType<StringType>;
|
|
187
|
+
readonly rejectedBorderColor: OptionType<StringType>;
|
|
188
|
+
readonly headerBackground: OptionType<StringType>;
|
|
189
|
+
readonly summaryBackground: OptionType<StringType>;
|
|
190
|
+
readonly background: OptionType<StringType>;
|
|
191
|
+
readonly borderColor: OptionType<StringType>;
|
|
192
|
+
readonly indentGuideColor: OptionType<StringType>;
|
|
193
|
+
readonly lineNumberColor: OptionType<StringType>;
|
|
194
|
+
}>>;
|
|
195
|
+
}>>;
|
|
196
|
+
/**
|
|
197
|
+
* Options for {@link Diff.Root}.
|
|
198
|
+
*
|
|
199
|
+
* @property bindings - The set of bindings to surface. Pass `view.binding`
|
|
200
|
+
* from each {@link Data.bind} handle, or hand-build descriptors of shape
|
|
201
|
+
* {@link DiffBindingType}.
|
|
202
|
+
* @property readonly - Render without per-leaf / per-group Discard buttons.
|
|
203
|
+
* The footer Apply / Discard-all still render. Defaults to false.
|
|
204
|
+
* @property hideUnchanged - Elide unchanged rows. Defaults to false.
|
|
205
|
+
* @property maxDepth - Cap nesting depth. Defaults to no cap.
|
|
206
|
+
* @property density - Information-density preset (`comfortable` | `compact`
|
|
207
|
+
* | `condensed`). Defaults to `comfortable`.
|
|
208
|
+
* @property onCommitted - Fired after the user commits.
|
|
209
|
+
* @property onDiscarded - Fired after the user discards.
|
|
210
|
+
* @property style - Visual style escape hatches.
|
|
211
|
+
*/
|
|
212
|
+
export interface DiffOptions {
|
|
213
|
+
/** Bindings to surface. Typically `[view.binding, ...]`. */
|
|
214
|
+
bindings: SubtypeExprOrValue<ArrayType<DiffBindingType>>;
|
|
215
|
+
/** Render without per-leaf / per-group Discard buttons. Defaults to false (interactive). */
|
|
216
|
+
readonly?: SubtypeExprOrValue<OptionType<BooleanType>>;
|
|
217
|
+
/** Elide unchanged rows. Defaults to false. */
|
|
218
|
+
hideUnchanged?: SubtypeExprOrValue<OptionType<BooleanType>>;
|
|
219
|
+
/** Cap nesting depth before "Show more" collapses. Defaults to no cap. */
|
|
220
|
+
maxDepth?: SubtypeExprOrValue<OptionType<IntegerType>>;
|
|
221
|
+
/** Information-density preset. */
|
|
222
|
+
density?: SubtypeExprOrValue<OptionType<DensityType>> | DensityLiteral;
|
|
223
|
+
/** Fired after a successful commit (post-merge). */
|
|
224
|
+
onCommitted?: SubtypeExprOrValue<OptionType<FunctionType<[], NullType>>>;
|
|
225
|
+
/** Fired after a successful discard. */
|
|
226
|
+
onDiscarded?: SubtypeExprOrValue<OptionType<FunctionType<[], NullType>>>;
|
|
227
|
+
/** Visual style escape hatches — see {@link DiffStyleType}. */
|
|
228
|
+
style?: SubtypeExprOrValue<OptionType<DiffStyleType>>;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The Diff component namespace. Surfaces transactional pending edits for
|
|
232
|
+
* review and commit, with merge-aware conflict resolution and stale-patch
|
|
233
|
+
* drift detection.
|
|
234
|
+
*
|
|
235
|
+
* @remarks
|
|
236
|
+
* Use `Diff.Root({ bindings: [view.binding, ...] })` to render the panel.
|
|
237
|
+
* The `Component` property is the internal {@link EastUI.component}
|
|
238
|
+
* carrier that renderers register against — most callers shouldn't need
|
|
239
|
+
* it.
|
|
240
|
+
*/
|
|
241
|
+
export declare const Diff: {
|
|
242
|
+
/**
|
|
243
|
+
* Build a Diff component. Surfaces every binding's in-flight change in
|
|
244
|
+
* a single review card, with per-leaf accept / reject and a footer
|
|
245
|
+
* Apply that runs the right commit per binding.
|
|
246
|
+
*
|
|
247
|
+
* @param options - {@link DiffOptions}. Only `bindings` is required;
|
|
248
|
+
* the rest default to absent / interactive.
|
|
249
|
+
* @returns An East expression of {@link UIComponentType} representing
|
|
250
|
+
* the Diff panel.
|
|
251
|
+
*
|
|
252
|
+
* @remarks
|
|
253
|
+
* The renderer reads each binding's IR descriptor (`source`, optional
|
|
254
|
+
* `patch`, `mode`), looks up the runtime types in the binding
|
|
255
|
+
* registry, and derives the in-flight change to display. Apply's
|
|
256
|
+
* commit code path depends on the binding's mode and patch presence —
|
|
257
|
+
* staged + no patch applies the buffer to source; staged + patch
|
|
258
|
+
* publishes the buffer as a fresh patch to the patch dataset; direct
|
|
259
|
+
* + patch applies the existing patch dataset to the source. Discard
|
|
260
|
+
* always drops the in-flight change in place.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* import { East, FloatType } from "@elaraai/east";
|
|
265
|
+
* import { Reactive, UIComponentType } from "@elaraai/east-ui";
|
|
266
|
+
* import { Data, Diff } from "@elaraai/e3-ui";
|
|
267
|
+
* import * as e3 from "@elaraai/e3";
|
|
268
|
+
*
|
|
269
|
+
* const maxWeeklyHoursInput = e3.input("max_weekly_hours", FloatType, 38.0);
|
|
270
|
+
*
|
|
271
|
+
* // Mirrors `diffDefaults` in test/diff.examples.ts (wired via Assert.examples).
|
|
272
|
+
* const diffDefaults = East.function([], UIComponentType, _$ => {
|
|
273
|
+
* return Reactive.Root(East.function([], UIComponentType, $ => {
|
|
274
|
+
* const view = $.let(Data.bind([FloatType], maxWeeklyHoursInput.path));
|
|
275
|
+
* return Diff.Root({ bindings: [view.binding] });
|
|
276
|
+
* }));
|
|
277
|
+
* });
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
readonly Root: (options: DiffOptions) => ExprType<UIComponentType>;
|
|
281
|
+
/**
|
|
282
|
+
* The internal {@link EastUI.component} carrier. Renderers register
|
|
283
|
+
* against this in `@elaraai/e3-ui-components` via
|
|
284
|
+
* `implementUIComponent(Diff.Component, EastChakraDiff)`. Most callers
|
|
285
|
+
* should use {@link Diff.Root} (the handle-friendly factory) and never
|
|
286
|
+
* touch this directly.
|
|
287
|
+
*/
|
|
288
|
+
readonly Component: import("@elaraai/east-ui").UIComponentDef<StructType<{
|
|
289
|
+
readonly bindings: ArrayType<StructType<{
|
|
290
|
+
readonly source: ArrayType<import("@elaraai/east").VariantType<{
|
|
291
|
+
readonly field: StringType;
|
|
292
|
+
}>>;
|
|
293
|
+
readonly patch: OptionType<ArrayType<import("@elaraai/east").VariantType<{
|
|
294
|
+
readonly field: StringType;
|
|
295
|
+
}>>>;
|
|
296
|
+
readonly mode: import("@elaraai/east").VariantType<{
|
|
297
|
+
readonly staged: NullType;
|
|
298
|
+
readonly direct: NullType;
|
|
299
|
+
}>;
|
|
300
|
+
}>>;
|
|
301
|
+
readonly readonly: OptionType<BooleanType>;
|
|
302
|
+
readonly hideUnchanged: OptionType<BooleanType>;
|
|
303
|
+
readonly maxDepth: OptionType<IntegerType>;
|
|
304
|
+
readonly density: OptionType<import("@elaraai/east").VariantType<{
|
|
305
|
+
readonly comfortable: NullType;
|
|
306
|
+
readonly compact: NullType;
|
|
307
|
+
readonly condensed: NullType;
|
|
308
|
+
}>>;
|
|
309
|
+
readonly onCommitted: OptionType<FunctionType<[], NullType>>;
|
|
310
|
+
readonly onDiscarded: OptionType<FunctionType<[], NullType>>;
|
|
311
|
+
readonly style: OptionType<StructType<{
|
|
312
|
+
readonly addedBackground: OptionType<StringType>;
|
|
313
|
+
readonly addedColor: OptionType<StringType>;
|
|
314
|
+
readonly addedBorderColor: OptionType<StringType>;
|
|
315
|
+
readonly removedBackground: OptionType<StringType>;
|
|
316
|
+
readonly removedColor: OptionType<StringType>;
|
|
317
|
+
readonly removedBorderColor: OptionType<StringType>;
|
|
318
|
+
readonly changedBackground: OptionType<StringType>;
|
|
319
|
+
readonly changedColor: OptionType<StringType>;
|
|
320
|
+
readonly changedBorderColor: OptionType<StringType>;
|
|
321
|
+
readonly unchangedColor: OptionType<StringType>;
|
|
322
|
+
readonly acceptedBackground: OptionType<StringType>;
|
|
323
|
+
readonly acceptedBorderColor: OptionType<StringType>;
|
|
324
|
+
readonly rejectedBackground: OptionType<StringType>;
|
|
325
|
+
readonly rejectedBorderColor: OptionType<StringType>;
|
|
326
|
+
readonly headerBackground: OptionType<StringType>;
|
|
327
|
+
readonly summaryBackground: OptionType<StringType>;
|
|
328
|
+
readonly background: OptionType<StringType>;
|
|
329
|
+
readonly borderColor: OptionType<StringType>;
|
|
330
|
+
readonly indentGuideColor: OptionType<StringType>;
|
|
331
|
+
readonly lineNumberColor: OptionType<StringType>;
|
|
332
|
+
}>>;
|
|
333
|
+
}>>;
|
|
334
|
+
};
|
|
335
|
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