@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.
Files changed (53) hide show
  1. package/CLA.md +26 -0
  2. package/CONTRIBUTING.md +28 -0
  3. package/LICENSE.md +31 -0
  4. package/README.md +149 -0
  5. package/dist/src/buttons.d.ts +2 -0
  6. package/dist/src/buttons.d.ts.map +1 -0
  7. package/dist/src/buttons.js +2 -0
  8. package/dist/src/buttons.js.map +1 -0
  9. package/dist/src/data.d.ts +241 -0
  10. package/dist/src/data.d.ts.map +1 -0
  11. package/dist/src/data.js +195 -0
  12. package/dist/src/data.js.map +1 -0
  13. package/dist/src/derive.d.ts +33 -0
  14. package/dist/src/derive.d.ts.map +1 -0
  15. package/dist/src/derive.js +64 -0
  16. package/dist/src/derive.js.map +1 -0
  17. package/dist/src/diff.d.ts +335 -0
  18. package/dist/src/diff.d.ts.map +1 -0
  19. package/dist/src/diff.js +197 -0
  20. package/dist/src/diff.js.map +1 -0
  21. package/dist/src/index.d.ts +25 -0
  22. package/dist/src/index.d.ts.map +1 -0
  23. package/dist/src/index.js +25 -0
  24. package/dist/src/index.js.map +1 -0
  25. package/dist/src/manifest.d.ts +27 -0
  26. package/dist/src/manifest.d.ts.map +1 -0
  27. package/dist/src/manifest.js +29 -0
  28. package/dist/src/manifest.js.map +1 -0
  29. package/dist/src/ontology.d.ts +517 -0
  30. package/dist/src/ontology.d.ts.map +1 -0
  31. package/dist/src/ontology.js +311 -0
  32. package/dist/src/ontology.js.map +1 -0
  33. package/dist/src/ui.d.ts +57 -0
  34. package/dist/src/ui.d.ts.map +1 -0
  35. package/dist/src/ui.js +72 -0
  36. package/dist/src/ui.js.map +1 -0
  37. package/dist/src/utils.d.ts +21 -0
  38. package/dist/src/utils.d.ts.map +1 -0
  39. package/dist/src/utils.js +24 -0
  40. package/dist/src/utils.js.map +1 -0
  41. package/dist/test/data.examples.d.ts +20 -0
  42. package/dist/test/data.examples.d.ts.map +1 -0
  43. package/dist/test/data.examples.js +156 -0
  44. package/dist/test/data.examples.js.map +1 -0
  45. package/dist/test/diff.examples.d.ts +138 -0
  46. package/dist/test/diff.examples.d.ts.map +1 -0
  47. package/dist/test/diff.examples.js +964 -0
  48. package/dist/test/diff.examples.js.map +1 -0
  49. package/dist/test/ontology.examples.d.ts +412 -0
  50. package/dist/test/ontology.examples.d.ts.map +1 -0
  51. package/dist/test/ontology.examples.js +298 -0
  52. package/dist/test/ontology.examples.js.map +1 -0
  53. package/package.json +80 -0
@@ -0,0 +1,311 @@
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
+ * Ontology component — graph editor for an `OntologyType`-bound dataset.
7
+ *
8
+ * @remarks
9
+ * The Ontology card surfaces a ReactFlow-driven node/link graph editor over
10
+ * the value of a single {@link Data.bind} binding whose source dataset is
11
+ * typed as {@link OntologyType}. Mutations (add / delete / reconnect /
12
+ * update node) write the whole next-ontology back through `binding.write`,
13
+ * so the same staged-buffer + commit / discard / merge machinery that
14
+ * powers `Diff` is reused unchanged.
15
+ *
16
+ * Declared via the `EastUI.component` extension API — the React renderer
17
+ * lives in `@elaraai/e3-ui-components` and is wired via
18
+ * `implementUIComponent(OntologyComponent, EastChakraOntology)` at module
19
+ * load time.
20
+ *
21
+ * @packageDocumentation
22
+ */
23
+ import { East, NullType, StringType, DateTimeType, BooleanType, ArrayType, StructType, VariantType, OptionType, FunctionType, none, some, variant, } from '@elaraai/east';
24
+ import { EastUI, DensityType } from '@elaraai/east-ui';
25
+ import { DiffBindingType } from './data.js';
26
+ // ============================================================================
27
+ // Ontology value schema — nodes, links, metadata.
28
+ // ============================================================================
29
+ /**
30
+ * Discriminator for the kind of business element a node represents.
31
+ *
32
+ * @property process - A unit of execution / activity.
33
+ * @property resource - A consumable or capacity tracked by the business.
34
+ * @property kpi - A measurable indicator.
35
+ * @property decision - A point at which the business chooses among options.
36
+ * @property data - A dataset or signal flowing through the business.
37
+ * @property objective - A strategic goal the business pursues.
38
+ * @property policy - A rule constraining other elements.
39
+ * @property document - Reference material — a procedure, contract, spec.
40
+ * @property computation - A derived quantity / model output.
41
+ * @property group - A visual container for related nodes (no semantics).
42
+ */
43
+ export const NodeKindType = VariantType({
44
+ process: NullType,
45
+ resource: NullType,
46
+ kpi: NullType,
47
+ decision: NullType,
48
+ data: NullType,
49
+ objective: NullType,
50
+ policy: NullType,
51
+ document: NullType,
52
+ computation: NullType,
53
+ group: NullType,
54
+ });
55
+ /**
56
+ * Discriminator for the relationship semantics between two nodes.
57
+ *
58
+ * @property uses - Source uses target as input.
59
+ * @property produces - Source produces target as output.
60
+ * @property results_in - Source's outcome culminates in target.
61
+ * @property gets_data_from - Source reads data from target.
62
+ * @property inserts_data_into - Source writes data into target.
63
+ * @property informs - Source provides context that shapes target.
64
+ * @property drives - Source motivates / triggers target.
65
+ * @property constrains - Source limits the behaviour of target.
66
+ * @property defines - Source specifies the definition of target.
67
+ * @property executes - Source carries out target.
68
+ * @property references - Source points at target for documentation.
69
+ * @property validates - Source checks target for correctness.
70
+ * @property measures - Source quantifies target.
71
+ * @property simulates - Source models target.
72
+ * @property contains - Source visually groups target (for `group` nodes).
73
+ * @property used_by - Inverse of `uses`.
74
+ */
75
+ export const LinkKindType = VariantType({
76
+ uses: NullType,
77
+ produces: NullType,
78
+ results_in: NullType,
79
+ gets_data_from: NullType,
80
+ inserts_data_into: NullType,
81
+ informs: NullType,
82
+ drives: NullType,
83
+ constrains: NullType,
84
+ defines: NullType,
85
+ executes: NullType,
86
+ references: NullType,
87
+ validates: NullType,
88
+ measures: NullType,
89
+ simulates: NullType,
90
+ contains: NullType,
91
+ used_by: NullType,
92
+ });
93
+ /**
94
+ * A directed relationship between two nodes.
95
+ *
96
+ * @property id - Stable identifier for the link.
97
+ * @property source - `id` of the source node.
98
+ * @property target - `id` of the target node.
99
+ * @property type - The relationship semantics — see {@link LinkKindType}.
100
+ */
101
+ export const LinkType = StructType({
102
+ id: StringType,
103
+ source: StringType,
104
+ target: StringType,
105
+ type: LinkKindType,
106
+ });
107
+ /**
108
+ * A node in the ontology graph.
109
+ *
110
+ * @property id - Stable identifier for the node.
111
+ * @property name - Display name.
112
+ * @property description - Optional long-form description.
113
+ * @property type - Discriminator — see {@link NodeKindType}.
114
+ */
115
+ export const NodeType = StructType({
116
+ id: StringType,
117
+ name: StringType,
118
+ description: OptionType(StringType),
119
+ type: NodeKindType,
120
+ });
121
+ /**
122
+ * Versioning + provenance metadata attached to an ontology value.
123
+ *
124
+ * @property version - Semver string identifying the schema revision.
125
+ * @property created - Timestamp when this ontology was first written.
126
+ * @property updated - Timestamp of the most recent edit.
127
+ * @property description - Optional caption shown beside the editor header.
128
+ */
129
+ export const OntologyMetadataType = StructType({
130
+ version: StringType,
131
+ created: DateTimeType,
132
+ updated: DateTimeType,
133
+ description: OptionType(StringType),
134
+ });
135
+ /**
136
+ * The full ontology value carried by an `OntologyType`-typed dataset.
137
+ *
138
+ * @property nodes - Every node in the graph.
139
+ * @property links - Every relationship between nodes. Each link's `source`
140
+ * and `target` must match a node's `id`; orphaned links are surfaced as
141
+ * warnings in the editor.
142
+ * @property metadata - Optional versioning + provenance metadata.
143
+ */
144
+ export const OntologyType = StructType({
145
+ nodes: ArrayType(NodeType),
146
+ links: ArrayType(LinkType),
147
+ metadata: OptionType(OntologyMetadataType),
148
+ });
149
+ // ============================================================================
150
+ // Sub-types — visual style escape hatches.
151
+ // ============================================================================
152
+ /**
153
+ * Visual style escape hatches for the Ontology editor. Every visible surface
154
+ * is tokenable; defaults come from the host's design system (Elara AI bsys
155
+ * tokens — see the renderer in `@elaraai/e3-ui-components`).
156
+ *
157
+ * @property nodeBackground - Card background for non-selected nodes.
158
+ * @property nodeBorderColor - Card border colour for non-selected nodes.
159
+ * @property nodeSelectedBackground - Card background when a node is
160
+ * focused / selected.
161
+ * @property nodeSelectedBorderColor - Card border colour when a node is
162
+ * focused / selected.
163
+ * @property nodeAccentColor - Default colour for the 2px top stripe when no
164
+ * kind-specific accent is defined. Per-kind accents come from the
165
+ * renderer's bsys palette and are not exposed here.
166
+ * @property edgeColor - Default stroke for edges.
167
+ * @property edgeEmphasizedColor - Stroke for edges in the hover / selected /
168
+ * focused states.
169
+ * @property labelBackground - Background for edge label pills.
170
+ * @property labelBorderColor - Border for edge label pills.
171
+ * @property panelBackground - Background for the outer editor frame.
172
+ * @property panelBorderColor - Border for the outer editor frame.
173
+ * @property headerBackground - Background for the eyebrow header strip.
174
+ * @property footerBackground - Background for the commit-bar footer.
175
+ * @property gridColor - Canvas grid line colour (major + minor).
176
+ * @property minimapMaskColor - Mask colour for the off-screen region in
177
+ * the minimap.
178
+ */
179
+ export const OntologyStyleType = StructType({
180
+ nodeBackground: OptionType(StringType),
181
+ nodeBorderColor: OptionType(StringType),
182
+ nodeSelectedBackground: OptionType(StringType),
183
+ nodeSelectedBorderColor: OptionType(StringType),
184
+ nodeAccentColor: OptionType(StringType),
185
+ edgeColor: OptionType(StringType),
186
+ edgeEmphasizedColor: OptionType(StringType),
187
+ labelBackground: OptionType(StringType),
188
+ labelBorderColor: OptionType(StringType),
189
+ panelBackground: OptionType(StringType),
190
+ panelBorderColor: OptionType(StringType),
191
+ headerBackground: OptionType(StringType),
192
+ footerBackground: OptionType(StringType),
193
+ gridColor: OptionType(StringType),
194
+ minimapMaskColor: OptionType(StringType),
195
+ });
196
+ // ============================================================================
197
+ // Re-export the binding descriptor — same opaque carrier the Diff card uses.
198
+ // ============================================================================
199
+ /** Re-exported from {@link Data}; see {@link DiffBindingType}. */
200
+ export { DiffBindingType } from './data.js';
201
+ // ============================================================================
202
+ // Ontology payload — IR shape consumed by the renderer.
203
+ // ============================================================================
204
+ /**
205
+ * Schema for the `Ontology` extension component. Internal IR shape — the
206
+ * developer-facing factory `Ontology.Root` accepts a {@link Data.bind}
207
+ * handle's `binding` field and forwards it as `binding`.
208
+ *
209
+ * @property binding - The binding the editor reads + writes. The
210
+ * underlying source dataset must be typed as {@link OntologyType};
211
+ * this is a developer-side contract (the IR carrier itself is type-erased).
212
+ * @property readonly - Render without per-node / per-link mutation
213
+ * surfaces. The footer commit-bar and the property drawer still render
214
+ * but Save / Delete / Add-node are hidden, and the canvas blocks
215
+ * drag-handles + context menus. Default `false`.
216
+ * @property hideMiniMap - Suppress the minimap overlay. None ⇒ false.
217
+ * @property hideSearch - Suppress the search field in the toolbar.
218
+ * None ⇒ false.
219
+ * @property density - Information-density preset (`comfortable` | `compact`
220
+ * | `condensed`). Defaults to `comfortable`.
221
+ * @property onCommitted - Fired after a successful commit (the bound
222
+ * dataset has been updated).
223
+ * @property onDiscarded - Fired after a successful discard (the staging
224
+ * buffer was dropped).
225
+ * @property style - Visual style escape hatches — see
226
+ * {@link OntologyStyleType}.
227
+ */
228
+ export const OntologyPayloadType = StructType({
229
+ binding: DiffBindingType,
230
+ readonly: OptionType(BooleanType),
231
+ hideMiniMap: OptionType(BooleanType),
232
+ hideSearch: OptionType(BooleanType),
233
+ density: OptionType(DensityType),
234
+ onCommitted: OptionType(FunctionType([], NullType)),
235
+ onDiscarded: OptionType(FunctionType([], NullType)),
236
+ style: OptionType(OntologyStyleType),
237
+ });
238
+ /**
239
+ * Internal `EastUI.component` carrier. Renderers register against this in
240
+ * `@elaraai/e3-ui-components`. Most callers should use {@link Ontology.Root}
241
+ * (which wraps this with the handle-friendly API) rather than touching
242
+ * `OntologyComponent` directly.
243
+ */
244
+ export const OntologyComponent = EastUI.component('Ontology', OntologyPayloadType, { optional: true });
245
+ /**
246
+ * The Ontology component namespace. Surfaces a graph editor over an
247
+ * `OntologyType`-bound dataset, with the same staged-buffer + merge-aware
248
+ * commit pipeline that powers {@link Diff}.
249
+ *
250
+ * @remarks
251
+ * Use `Ontology.Root({ binding: view.binding })` to render the editor.
252
+ * The `Component` property is the internal {@link EastUI.component}
253
+ * carrier that renderers register against — most callers shouldn't need
254
+ * it.
255
+ */
256
+ export const Ontology = {
257
+ /**
258
+ * Build an Ontology editor. Renders the bound graph as a ReactFlow
259
+ * canvas with node/link mutation surfaces wired through the binding.
260
+ *
261
+ * @param options - {@link OntologyOptions}. Only `binding` is required;
262
+ * the rest default to absent / interactive.
263
+ * @returns An East expression of {@link UIComponentType} representing
264
+ * the Ontology editor.
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * import { East } from '@elaraai/east';
269
+ * import { Reactive, UIComponentType } from '@elaraai/east-ui';
270
+ * import { Data, Ontology, OntologyType } from '@elaraai/e3-ui';
271
+ * import * as e3 from '@elaraai/e3';
272
+ *
273
+ * const ontologyInput = e3.input('supply_chain', OntologyType, {
274
+ * nodes: [], links: [], metadata: { type: 'none', value: null },
275
+ * });
276
+ *
277
+ * const editor = East.function([], UIComponentType, (_$) =>
278
+ * Reactive.Root(East.function([], UIComponentType, $ => {
279
+ * const view = $.let(Data.bind([OntologyType], ontologyInput.path));
280
+ * return Ontology.Root({ binding: view.binding });
281
+ * })),
282
+ * );
283
+ * ```
284
+ */
285
+ Root(options) {
286
+ const density = options.density === undefined
287
+ ? none
288
+ : typeof options.density === 'string'
289
+ ? some(East.value(variant(options.density, null), DensityType))
290
+ : options.density;
291
+ return OntologyComponent.Root({
292
+ binding: options.binding,
293
+ readonly: options.readonly ?? none,
294
+ hideMiniMap: options.hideMiniMap ?? none,
295
+ hideSearch: options.hideSearch ?? none,
296
+ density,
297
+ onCommitted: options.onCommitted ?? none,
298
+ onDiscarded: options.onDiscarded ?? none,
299
+ style: options.style ?? none,
300
+ });
301
+ },
302
+ /**
303
+ * The internal {@link EastUI.component} carrier. Renderers register
304
+ * against this in `@elaraai/e3-ui-components` via
305
+ * `implementUIComponent(Ontology.Component, EastChakraOntology)`.
306
+ * Most callers should use {@link Ontology.Root} (the handle-friendly
307
+ * factory) and never touch this directly.
308
+ */
309
+ Component: OntologyComponent,
310
+ };
311
+ //# sourceMappingURL=ontology.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ontology.js","sourceR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AI,EAAE,CAAC,CAAC;AA2CvG;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,IAAI,CAAC,OAAwB;QACzB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,KAAK,SAAS;YACzC,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;gBACjC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC;gBAC/D,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;QAC1B,OAAO,iBAAiB,CAAC,IAAI,CAAC;YAC1B,OAAO,EAAM,OAAO,CAAC,OAAO;YAC5B,QAAQ,EAAK,OAAO,CAAC,QAAQ,IAAO,IAAI;YACxC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI;YACxC,UAAU,EAAG,OAAO,CAAC,UAAU,IAAK,IAAI;YACxC,OAAO;YACP,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI;YACxC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI;YACxC,KAAK,EAAQ,OAAO,CAAC,KAAK,IAAU,IAAI;SAC3C,CAAC,CAAC;IACP,CAAC;IACD;;;;;;OAMG;IACH,SAAS,EAAE,iBAAiB;CACtB,CAAC"}
@@ -0,0 +1,57 @@
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
+ * `ui()` — first-class UI task for e3.
7
+ *
8
+ * Wraps `e3.task()` with `kind: "ui"` and a manifest auto-derived from the
9
+ * IR by inspecting `Data.bind` calls. Compute-time inputs (passed to the fn
10
+ * by the runner) are also added to the manifest's reads.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ import { type DatasetDef, type TaskDef } from '@elaraai/e3';
15
+ import type { UIComponentType } from '@elaraai/east-ui';
16
+ import type { EastType, CallableFunctionExpr, CallableAsyncFunctionExpr } from '@elaraai/east';
17
+ /**
18
+ * Create a UI task — an e3 task that produces a UIComponentType value.
19
+ *
20
+ * The task's manifest combines:
21
+ * - **Compute-time reads** — every dataset in `inputs` (the runner passes
22
+ * their values to `fn` as positional args).
23
+ * - **Reactive reads** — every `Data.bind(path).read()` / `.has()` call in
24
+ * the IR (paths derived by static analysis).
25
+ * - **Reactive writes** — every `Data.bind(path).write()` call in the IR.
26
+ *
27
+ * Paths used in `Data.bind` must be JS-side constants captured at IR-build
28
+ * time (typically `e3.input(name, T).path`). Dynamic paths throw.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import e3 from '@elaraai/e3';
33
+ * import { ui, Data } from '@elaraai/e3-ui';
34
+ * import { FloatType, East } from '@elaraai/east';
35
+ * import { Reactive, Slider, Stat, Text, UIComponentType } from '@elaraai/east-ui';
36
+ *
37
+ * const threshold = e3.input('threshold', FloatType, 50.0);
38
+ *
39
+ * // No compute-time inputs (fn arg list is []), reactive bindings only:
40
+ * const dashboard = ui('dashboard', [], East.function([], UIComponentType, (_$) =>
41
+ * Reactive.Root(East.function([], UIComponentType, $ => {
42
+ * const t = $.let(Data.bind([FloatType], threshold.path));
43
+ * return Slider.Root($.let(t.read()), { onChange: t.write });
44
+ * }))
45
+ * ));
46
+ * // Manifest derived: { reads: [threshold.path], writes: [threshold.path] }
47
+ *
48
+ * // With a compute-time input that fn receives at start:
49
+ * const greeting = ui('greeting', [name], East.function([StringType], UIComponentType,
50
+ * ($, n) => Text.Root(East.str`Hello, ${n}!`)));
51
+ * // Manifest: { reads: [name.path], writes: [] }
52
+ * ```
53
+ */
54
+ export declare function ui<Inputs extends readonly DatasetDef[], O extends EastType = typeof UIComponentType>(name: string, inputs: [...Inputs], fn: CallableFunctionExpr<any, O> | CallableAsyncFunctionExpr<any, O>, options?: {
55
+ runner?: string[];
56
+ }): TaskDef;
57
+ //# sourceMappingURL=ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/ui.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAAQ,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,eAAe,CAAC;AAKvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,EAAE,CAChB,MAAM,SAAS,SAAS,UAAU,EAAE,EACpC,CAAC,SAAS,QAAQ,GAAG,OAAO,eAAe,EAE3C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,EACnB,EAAE,EAAE,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,yBAAyB,CAAC,GAAG,EAAE,CAAC,CAAC,EACpE,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,GACA,OAAO,CAgBT"}
package/dist/src/ui.js ADDED
@@ -0,0 +1,72 @@
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
+ * `ui()` — first-class UI task for e3.
7
+ *
8
+ * Wraps `e3.task()` with `kind: "ui"` and a manifest auto-derived from the
9
+ * IR by inspecting `Data.bind` calls. Compute-time inputs (passed to the fn
10
+ * by the runner) are also added to the manifest's reads.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ import { task } from '@elaraai/e3';
15
+ import { encodeManifest } from './manifest.js';
16
+ import { deriveManifest } from './derive.js';
17
+ /**
18
+ * Create a UI task — an e3 task that produces a UIComponentType value.
19
+ *
20
+ * The task's manifest combines:
21
+ * - **Compute-time reads** — every dataset in `inputs` (the runner passes
22
+ * their values to `fn` as positional args).
23
+ * - **Reactive reads** — every `Data.bind(path).read()` / `.has()` call in
24
+ * the IR (paths derived by static analysis).
25
+ * - **Reactive writes** — every `Data.bind(path).write()` call in the IR.
26
+ *
27
+ * Paths used in `Data.bind` must be JS-side constants captured at IR-build
28
+ * time (typically `e3.input(name, T).path`). Dynamic paths throw.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import e3 from '@elaraai/e3';
33
+ * import { ui, Data } from '@elaraai/e3-ui';
34
+ * import { FloatType, East } from '@elaraai/east';
35
+ * import { Reactive, Slider, Stat, Text, UIComponentType } from '@elaraai/east-ui';
36
+ *
37
+ * const threshold = e3.input('threshold', FloatType, 50.0);
38
+ *
39
+ * // No compute-time inputs (fn arg list is []), reactive bindings only:
40
+ * const dashboard = ui('dashboard', [], East.function([], UIComponentType, (_$) =>
41
+ * Reactive.Root(East.function([], UIComponentType, $ => {
42
+ * const t = $.let(Data.bind([FloatType], threshold.path));
43
+ * return Slider.Root($.let(t.read()), { onChange: t.write });
44
+ * }))
45
+ * ));
46
+ * // Manifest derived: { reads: [threshold.path], writes: [threshold.path] }
47
+ *
48
+ * // With a compute-time input that fn receives at start:
49
+ * const greeting = ui('greeting', [name], East.function([StringType], UIComponentType,
50
+ * ($, n) => Text.Root(East.str`Hello, ${n}!`)));
51
+ * // Manifest: { reads: [name.path], writes: [] }
52
+ * ```
53
+ */
54
+ export function ui(name, inputs, fn, options) {
55
+ const derived = deriveManifest(fn);
56
+ const inputPaths = inputs.map(i => i.path);
57
+ const seen = new Set();
58
+ const paths = [];
59
+ for (const p of [...inputPaths, ...derived.paths]) {
60
+ const k = p.map(s => `${s.type}:${s.value}`).join('/');
61
+ if (seen.has(k))
62
+ continue;
63
+ seen.add(k);
64
+ paths.push(p);
65
+ }
66
+ return task(name, inputs, fn, {
67
+ runner: options?.runner ?? ['east-c', 'run'],
68
+ kind: 'ui',
69
+ metadata: encodeManifest({ paths }),
70
+ });
71
+ }
72
+ //# sourceMappingURL=ui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/ui.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAiC,MAAM,aAAa,CAAC;AAQlE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,EAAE,CAIhB,IAAY,EACZ,MAAmB,EACnB,EAAoE,EACpE,OAEC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,EAAE,CAAC,CAAC;IACnC,MAAM,UAAU,GAAe,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,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,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,EAAE,MAAa,EAAE,EAAS,EAAE;QAC1C,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC;QAC5C,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,cAAc,CAAC,EAAE,KAAK,EAAE,CAAC;KACpC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,21 @@
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
+ * Shared JS-side utilities for e3-ui task factories.
7
+ *
8
+ * These run at IR-build time, never inside East function bodies.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ import type { TreePath } from '@elaraai/e3-types';
13
+ /**
14
+ * Deduplicate a list of `TreePath`s, preserving first-seen order.
15
+ *
16
+ * Two paths are equal iff their segments match by both `type` and `value`.
17
+ * Used by task factories to merge compute-time input paths with reactive
18
+ * paths derived from the IR without double-counting overlaps.
19
+ */
20
+ export declare function dedupePaths(paths: TreePath[]): TreePath[];
21
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAUzD"}
@@ -0,0 +1,24 @@
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
+ * Deduplicate a list of `TreePath`s, preserving first-seen order.
7
+ *
8
+ * Two paths are equal iff their segments match by both `type` and `value`.
9
+ * Used by task factories to merge compute-time input paths with reactive
10
+ * paths derived from the IR without double-counting overlaps.
11
+ */
12
+ export function dedupePaths(paths) {
13
+ const seen = new Set();
14
+ const result = [];
15
+ for (const p of paths) {
16
+ const k = p.map(s => `${s.type}:${s.value}`).join('/');
17
+ if (seen.has(k))
18
+ continue;
19
+ seen.add(k);
20
+ result.push(p);
21
+ }
22
+ return result;
23
+ }
24
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAiB;IACzC,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,20 @@
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 { FloatType, IntegerType, StringType, variant } from "@elaraai/east";
6
+ import * as e3 from "@elaraai/e3";
7
+ export declare const thresholdInput: e3.DatasetDef<FloatType, [variant<"field", "inputs">, variant<"field", "threshold">]>;
8
+ export declare const thresholdPatchInput: e3.DatasetDef<import("@elaraai/east").EastType, [variant<"field", "inputs">, variant<"field", "threshold_patch">]>;
9
+ export declare const countInput: e3.DatasetDef<IntegerType, [variant<"field", "inputs">, variant<"field", "count">]>;
10
+ export declare const nameInput: e3.DatasetDef<StringType, [variant<"field", "inputs">, variant<"field", "name">]>;
11
+ export declare const dataBindFloat: import("@elaraai/east").ExampleDef<[], any>;
12
+ export declare const dataBindSliderWriteback: import("@elaraai/east").ExampleDef<[], any>;
13
+ export declare const dataBindInteger: import("@elaraai/east").ExampleDef<[], any>;
14
+ export declare const dataBindStringReset: import("@elaraai/east").ExampleDef<[], any>;
15
+ export declare const dataBindHasGuard: import("@elaraai/east").ExampleDef<[], any>;
16
+ export declare const dataBindStagedFloat: import("@elaraai/east").ExampleDef<[], any>;
17
+ export declare const dataBindStagedSliderWrite: import("@elaraai/east").ExampleDef<[], any>;
18
+ export declare const dataBindStagedCommitDiscard: import("@elaraai/east").ExampleDef<[], any>;
19
+ export declare const dataBindStagedOriginalVsRead: import("@elaraai/east").ExampleDef<[], any>;
20
+ //# sourceMappingURL=data.examples.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.examples.d.ts","sourceRoot":"","sources":["../../test/data.examples.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,SAAS,EAAgB,WAAW,EAAY,UAAU,EAAa,OAAO,EAAW,MAAM,eAAe,CAAC;AAG9H,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAElC,eAAO,MAAM,cAAc,uFAAoD,CAAC;AAChF,eAAO,MAAM,mBAAmB,oHAAgF,CAAC;AACjH,eAAO,MAAM,UAAU,qFAA8C,CAAC;AACtE,eAAO,MAAM,SAAS,mFAA+C,CAAC;AAEtE,eAAO,MAAM,aAAa,6CAWxB,CAAC;AAEH,eAAO,MAAM,uBAAuB,6CAiBlC,CAAC;AAEH,eAAO,MAAM,eAAe,6CAW1B,CAAC;AAEH,eAAO,MAAM,mBAAmB,6CAiB9B,CAAC;AAEH,eAAO,MAAM,gBAAgB,6CAe3B,CAAC;AAEH,eAAO,MAAM,mBAAmB,6CAW9B,CAAC;AAEH,eAAO,MAAM,yBAAyB,6CAepC,CAAC;AAEH,eAAO,MAAM,2BAA2B,6CAuBtC,CAAC;AAEH,eAAO,MAAM,4BAA4B,6CAevC,CAAC"}