@elaraai/east-ui 0.0.1-beta.21 → 0.0.1-beta.23

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.
@@ -3,201 +3,46 @@
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
5
  /**
6
- * State management platform functions for East UI.
6
+ * State management platform function signatures.
7
7
  *
8
- * Provides reactive state operations for East UI programs.
9
- * State is stored as Beast2-encoded blobs, allowing any East type to be stored.
8
+ * @remarks
9
+ * This module contains only platform function definitions created with `East.platform()`.
10
+ * All runtime implementations are in `@elaraai/east-ui-components`.
10
11
  *
11
12
  * @packageDocumentation
12
13
  */
13
- import { StringType, BlobType, NullType, type SubtypeExprOrValue, type EastType, type CallableFunctionExpr, BooleanType } from "@elaraai/east";
14
- import { type PlatformFunction, OptionType } from "@elaraai/east/internal";
15
- import { UIStore } from "./store.js";
14
+ import { StringType, NullType, BooleanType } from "@elaraai/east";
16
15
  /**
17
- * Enable dependency tracking for reactive components.
18
- *
19
- * @remarks
20
- * Call this before executing a reactive component's render function.
21
- * All subsequent `state_read` calls will record their keys to the tracking set.
22
- * Call {@link disableTracking} when done to get the collected keys.
16
+ * Reads a Beast2-encoded value from state storage.
23
17
  *
24
- * @returns The Set that will collect accessed keys
25
- *
26
- * @example
27
- * ```ts
28
- * enableTracking();
29
- * try {
30
- * const result = renderFn();
31
- * const deps = disableTracking();
32
- * // deps contains all state keys read during renderFn()
33
- * } catch (e) {
34
- * disableTracking();
35
- * throw e;
36
- * }
37
- * ```
38
- */
39
- export declare function enableTracking(): Set<string>;
40
- /**
41
- * Disable dependency tracking and return collected keys.
18
+ * @param key - The state key to read from
19
+ * @returns Option of Beast2-encoded blob (some if exists, none if not found)
42
20
  *
43
21
  * @remarks
44
- * Call this after executing a reactive component's render function.
45
- * Returns all keys that were accessed via `state_read` since {@link enableTracking} was called.
46
- *
47
- * @returns Array of state keys that were read during tracking
22
+ * Returns `none` if the key does not exist, `some(blob)` if it does.
23
+ * Implementation provided by `StateImpl` in `@elaraai/east-ui-components`.
48
24
  */
49
- export declare function disableTracking(): string[];
25
+ export declare const state_read: import("@elaraai/east").GenericPlatformDefinition<readonly ["T"], readonly [StringType], "T">;
50
26
  /**
51
- * Check if dependency tracking is currently enabled.
27
+ * Writes a Beast2-encoded value to state storage.
52
28
  *
53
- * @returns True if tracking is active
54
- */
55
- export declare function isTracking(): boolean;
56
- /**
57
- * Record a key access during dependency tracking.
58
- *
59
- * @remarks
60
- * Called internally by the `state_read` implementation.
61
- * Only records if tracking is enabled via {@link enableTracking}.
62
- *
63
- * @param key - The state key being accessed
64
- */
65
- export declare function trackKey(key: string): void;
66
- /**
67
- * Platform function to write a Beast2-encoded value to the state store.
68
- *
69
- * @remarks
70
- * Writes a blob to state, or deletes the key if `none` is passed.
71
- * Triggers re-render in reactive contexts.
72
- *
73
- * @param key - The string key to write to
74
- * @param value - The Beast2-encoded blob value (some to write, none to delete)
29
+ * @param key - The state key to write to
30
+ * @param value - The value to write (some to set, none to delete)
75
31
  * @returns Null
76
- */
77
- export declare const state_write: import("@elaraai/east").PlatformDefinition<[StringType, OptionType<BlobType>], NullType>;
78
- /**
79
- * Platform function to read a Beast2-encoded value from the state store.
80
- *
81
- * @remarks
82
- * Returns `some(blob)` if the key exists, `none` if not.
83
- * Use `.match()` to handle both cases.
84
- *
85
- * @param key - The string key to read from
86
- * @returns Option of Beast2-encoded blob (some if exists, none if not)
87
- */
88
- export declare const state_read: import("@elaraai/east").PlatformDefinition<[StringType], OptionType<BlobType>>;
89
- /**
90
- * Platform function to check if a key exists in the state store.
91
- *
92
- * @remarks
93
- * Returns true if the key exists, false otherwise.
94
- *
95
- * @param key - The string key to check
96
- * @returns Boolean indicating existence of the key
97
- */
98
- export declare const state_has: import("@elaraai/east").PlatformDefinition<[StringType], BooleanType>;
99
- /**
100
- * Singleton UI store instance for state management.
101
32
  *
102
33
  * @remarks
103
- * This is the global store used by {@link StateImpl}. Access directly
104
- * for React integration, subscriptions, or debugging.
34
+ * Pass `none` to delete the key from state.
35
+ * Implementation provided by `StateImpl` in `@elaraai/east-ui-components`.
105
36
  */
106
- export declare const store: UIStore;
37
+ export declare const state_write: import("@elaraai/east").GenericPlatformDefinition<readonly ["T"], readonly [StringType, "T"], NullType>;
107
38
  /**
108
- * Platform implementation for state management operations.
39
+ * Checks if a key exists in state storage.
109
40
  *
110
- * @remarks
111
- * Provides the runtime implementations for state read/write operations
112
- * bound to the singleton {@link store}. Pass this to `ir.compile()` to enable
113
- * state functionality.
114
- */
115
- export declare const StateImpl: PlatformFunction[];
116
- /**
117
- * Creates a typed state write function for a given key and type.
41
+ * @param key - The state key to check
42
+ * @returns Boolean indicating whether the key exists
118
43
  *
119
44
  * @remarks
120
- * Returns an East function that writes a typed value to state. The value is
121
- * automatically Beast2-encoded before storage. Pass `some(value)` to write
122
- * or `none` to delete the key.
123
- *
124
- * @typeParam T - The East type of the value to write
125
- * @param key - The string key to write to
126
- * @param value - The value wrapped in an option (some to write, none to delete)
127
- * @param type - The East type descriptor for the value
128
- * @returns A callable East function that performs the write
129
- *
130
- * @example
131
- * ```ts
132
- * import { East, IntegerType, NullType, some } from "@elaraai/east";
133
- * import { State, UIComponentType } from "@elaraai/east-ui";
134
- *
135
- * const counter = East.function([], UIComponentType, $ => {
136
- * // Write 42 to "counter" key
137
- * $(State.writeTyped("counter", some(42n), IntegerType)());
138
- *
139
- * // Delete the key
140
- * $(State.writeTyped("counter", none, IntegerType)());
141
- * });
142
- * ```
45
+ * Implementation provided by `StateImpl` in `@elaraai/east-ui-components`.
143
46
  */
144
- export declare const state_write_typed: <T extends EastType>(key: SubtypeExprOrValue<StringType>, value: SubtypeExprOrValue<OptionType<T>>, type: T) => CallableFunctionExpr<[], NullType>;
145
- /**
146
- * Creates a typed state read function for a given key and type.
147
- *
148
- * @remarks
149
- * Returns an East function that reads a typed value from state. The value is
150
- * automatically Beast2-decoded after retrieval. Returns `some(value)` if the
151
- * key exists, `none` if not.
152
- *
153
- * @typeParam T - The East type of the value to read
154
- * @param key - The string key to read from
155
- * @param type - The East type descriptor for the value
156
- * @returns A callable East function that returns an option of the typed value
157
- *
158
- * @example
159
- * ```ts
160
- * import { East, IntegerType, NullType } from "@elaraai/east";
161
- * import { State, UIComponentType, Text } from "@elaraai/east-ui";
162
- *
163
- * const display = East.function([], UIComponentType, $ => {
164
- * // Read typed value from state
165
- * const count = $.let(State.readTyped("counter", IntegerType)());
166
- *
167
- * // Use the value (unwrap if you know it exists)
168
- * return Text.Root(East.str`Count: ${count.unwrap("some")}`);
169
- * });
170
- * ```
171
- */
172
- export declare const state_read_typed: <T extends EastType>(key: SubtypeExprOrValue<StringType>, type: T) => CallableFunctionExpr<[], OptionType<T>>;
173
- /**
174
- * Creates a typed state initialization function that only writes if the key doesn't exist.
175
- *
176
- * @remarks
177
- * Returns an East function that initializes a state key with a default value.
178
- * The write only occurs if the key is not already set, preventing overwrites
179
- * on re-renders. Use this for setting up initial state in components.
180
- *
181
- * @typeParam T - The East type of the value to initialize
182
- * @param key - The string key to initialize
183
- * @param value - The default value to write (not wrapped in option)
184
- * @param type - The East type descriptor for the value
185
- * @returns A callable East function that performs the conditional initialization
186
- *
187
- * @example
188
- * ```ts
189
- * import { East, IntegerType } from "@elaraai/east";
190
- * import { State, UIComponentType, Button } from "@elaraai/east-ui";
191
- *
192
- * const counter = East.function([], UIComponentType, $ => {
193
- * // Initialize to 0 only if not already set
194
- * $(State.initTyped("counter", 0n, IntegerType)());
195
- *
196
- * // Read and display
197
- * const count = $.let(State.readTyped("counter", IntegerType)());
198
- * // ...
199
- * });
200
- * ```
201
- */
202
- export declare const state_init_typed: <T extends EastType>(key: SubtypeExprOrValue<StringType>, value: SubtypeExprOrValue<T>, type: T) => CallableFunctionExpr<[], NullType>;
47
+ export declare const state_has: import("@elaraai/east").PlatformDefinition<[StringType], BooleanType>;
203
48
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file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;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,QAAQ,EAC/C,KAAK,kBAAkB,CAAC,UAAU,CAAC,EACnC,MAAM,CAAC,KACR,oBAAoB,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAiBxC,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,QAAQ,EAC/C,KAAK,kBAAkB,CAAC,UAAU,CAAC,EACnC,OAAO,kBAAkB,CAAC,CAAC,CAAC,EAC5B,MAAM,CAAC,KACR,oBAAoB,CAAC,EAAE,EAAE,QAAQ,CAWnC,CAAC"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/platform/state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAAQ,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAExE;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,+FAKtB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,yGAKvB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,uEAAwD,CAAC"}
@@ -3,284 +3,46 @@
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
5
  /**
6
- * State management platform functions for East UI.
7
- *
8
- * Provides reactive state operations for East UI programs.
9
- * State is stored as Beast2-encoded blobs, allowing any East type to be stored.
10
- *
11
- * @packageDocumentation
12
- */
13
- import { East, StringType, BlobType, NullType, none, some, BooleanType, } from "@elaraai/east";
14
- import { OptionType } from "@elaraai/east/internal";
15
- import { UIStore } from "./store.js";
16
- // =============================================================================
17
- // Reactive Dependency Tracking
18
- // =============================================================================
19
- /**
20
- * Tracking context for reactive dependency collection.
21
- * When set, state_read calls will record their keys here.
22
- */
23
- let trackingContext = null;
24
- /**
25
- * Enable dependency tracking for reactive components.
6
+ * State management platform function signatures.
26
7
  *
27
8
  * @remarks
28
- * Call this before executing a reactive component's render function.
29
- * All subsequent `state_read` calls will record their keys to the tracking set.
30
- * Call {@link disableTracking} when done to get the collected keys.
9
+ * This module contains only platform function definitions created with `East.platform()`.
10
+ * All runtime implementations are in `@elaraai/east-ui-components`.
31
11
  *
32
- * @returns The Set that will collect accessed keys
33
- *
34
- * @example
35
- * ```ts
36
- * enableTracking();
37
- * try {
38
- * const result = renderFn();
39
- * const deps = disableTracking();
40
- * // deps contains all state keys read during renderFn()
41
- * } catch (e) {
42
- * disableTracking();
43
- * throw e;
44
- * }
45
- * ```
46
- */
47
- export function enableTracking() {
48
- trackingContext = new Set();
49
- return trackingContext;
50
- }
51
- /**
52
- * Disable dependency tracking and return collected keys.
53
- *
54
- * @remarks
55
- * Call this after executing a reactive component's render function.
56
- * Returns all keys that were accessed via `state_read` since {@link enableTracking} was called.
57
- *
58
- * @returns Array of state keys that were read during tracking
12
+ * @packageDocumentation
59
13
  */
60
- export function disableTracking() {
61
- const keys = trackingContext ? [...trackingContext] : [];
62
- trackingContext = null;
63
- return keys;
64
- }
14
+ import { East, StringType, NullType, BooleanType } from "@elaraai/east";
65
15
  /**
66
- * Check if dependency tracking is currently enabled.
16
+ * Reads a Beast2-encoded value from state storage.
67
17
  *
68
- * @returns True if tracking is active
69
- */
70
- export function isTracking() {
71
- return trackingContext !== null;
72
- }
73
- /**
74
- * Record a key access during dependency tracking.
18
+ * @param key - The state key to read from
19
+ * @returns Option of Beast2-encoded blob (some if exists, none if not found)
75
20
  *
76
21
  * @remarks
77
- * Called internally by the `state_read` implementation.
78
- * Only records if tracking is enabled via {@link enableTracking}.
79
- *
80
- * @param key - The state key being accessed
22
+ * Returns `none` if the key does not exist, `some(blob)` if it does.
23
+ * Implementation provided by `StateImpl` in `@elaraai/east-ui-components`.
81
24
  */
82
- export function trackKey(key) {
83
- if (trackingContext) {
84
- trackingContext.add(key);
85
- }
86
- }
87
- // =============================================================================
88
- // Platform Functions
89
- // =============================================================================
25
+ export const state_read = East.genericPlatform("state_read", ["T"], [StringType], "T");
90
26
  /**
91
- * Platform function to write a Beast2-encoded value to the state store.
27
+ * Writes a Beast2-encoded value to state storage.
92
28
  *
93
- * @remarks
94
- * Writes a blob to state, or deletes the key if `none` is passed.
95
- * Triggers re-render in reactive contexts.
96
- *
97
- * @param key - The string key to write to
98
- * @param value - The Beast2-encoded blob value (some to write, none to delete)
29
+ * @param key - The state key to write to
30
+ * @param value - The value to write (some to set, none to delete)
99
31
  * @returns Null
100
- */
101
- export const state_write = East.platform("state_write", [StringType, OptionType(BlobType)], NullType);
102
- /**
103
- * Platform function to read a Beast2-encoded value from the state store.
104
- *
105
- * @remarks
106
- * Returns `some(blob)` if the key exists, `none` if not.
107
- * Use `.match()` to handle both cases.
108
- *
109
- * @param key - The string key to read from
110
- * @returns Option of Beast2-encoded blob (some if exists, none if not)
111
- */
112
- export const state_read = East.platform("state_read", [StringType], OptionType(BlobType));
113
- /**
114
- * Platform function to check if a key exists in the state store.
115
- *
116
- * @remarks
117
- * Returns true if the key exists, false otherwise.
118
- *
119
- * @param key - The string key to check
120
- * @returns Boolean indicating existence of the key
121
- */
122
- export const state_has = East.platform("state_has", [StringType], BooleanType);
123
- /**
124
- * Singleton UI store instance for state management.
125
- *
126
- * @remarks
127
- * This is the global store used by {@link StateImpl}. Access directly
128
- * for React integration, subscriptions, or debugging.
129
- */
130
- export const store = new UIStore();
131
- /**
132
- * Platform implementation for state management operations.
133
32
  *
134
33
  * @remarks
135
- * Provides the runtime implementations for state read/write operations
136
- * bound to the singleton {@link store}. Pass this to `ir.compile()` to enable
137
- * state functionality.
138
- */
139
- export const StateImpl = [
140
- state_write.implement((key, value) => {
141
- if (value.type === 'none') {
142
- store.write(key, undefined);
143
- }
144
- else {
145
- store.write(key, value.value);
146
- }
147
- }),
148
- state_read.implement((key) => {
149
- // Track the key if in tracking mode (for reactive dependency collection)
150
- trackKey(key);
151
- const ret = store.read(key);
152
- if (ret === undefined) {
153
- return none;
154
- }
155
- else {
156
- return some(ret);
157
- }
158
- }),
159
- state_has.implement((key) => {
160
- return store.has(key);
161
- }),
162
- ];
163
- /**
164
- * Creates a typed state write function for a given key and type.
165
- *
166
- * @remarks
167
- * Returns an East function that writes a typed value to state. The value is
168
- * automatically Beast2-encoded before storage. Pass `some(value)` to write
169
- * or `none` to delete the key.
170
- *
171
- * @typeParam T - The East type of the value to write
172
- * @param key - The string key to write to
173
- * @param value - The value wrapped in an option (some to write, none to delete)
174
- * @param type - The East type descriptor for the value
175
- * @returns A callable East function that performs the write
176
- *
177
- * @example
178
- * ```ts
179
- * import { East, IntegerType, NullType, some } from "@elaraai/east";
180
- * import { State, UIComponentType } from "@elaraai/east-ui";
181
- *
182
- * const counter = East.function([], UIComponentType, $ => {
183
- * // Write 42 to "counter" key
184
- * $(State.writeTyped("counter", some(42n), IntegerType)());
185
- *
186
- * // Delete the key
187
- * $(State.writeTyped("counter", none, IntegerType)());
188
- * });
189
- * ```
34
+ * Pass `none` to delete the key from state.
35
+ * Implementation provided by `StateImpl` in `@elaraai/east-ui-components`.
190
36
  */
191
- export const state_write_typed = (key, value, type) => {
192
- return East.function([], NullType, $ => {
193
- const key_expr = East.value(key);
194
- const value_expr = East.value(value, OptionType(type));
195
- $.match(value_expr, {
196
- some: ($, v) => {
197
- $(state_write(key_expr, some(East.Blob.encodeBeast(v, "v2"))));
198
- },
199
- none: ($) => {
200
- $(state_write(key_expr, none));
201
- }
202
- });
203
- return null;
204
- });
205
- };
37
+ export const state_write = East.genericPlatform("state_write", ["T"], [StringType, "T"], NullType);
206
38
  /**
207
- * Creates a typed state read function for a given key and type.
208
- *
209
- * @remarks
210
- * Returns an East function that reads a typed value from state. The value is
211
- * automatically Beast2-decoded after retrieval. Returns `some(value)` if the
212
- * key exists, `none` if not.
213
- *
214
- * @typeParam T - The East type of the value to read
215
- * @param key - The string key to read from
216
- * @param type - The East type descriptor for the value
217
- * @returns A callable East function that returns an option of the typed value
218
- *
219
- * @example
220
- * ```ts
221
- * import { East, IntegerType, NullType } from "@elaraai/east";
222
- * import { State, UIComponentType, Text } from "@elaraai/east-ui";
223
- *
224
- * const display = East.function([], UIComponentType, $ => {
225
- * // Read typed value from state
226
- * const count = $.let(State.readTyped("counter", IntegerType)());
39
+ * Checks if a key exists in state storage.
227
40
  *
228
- * // Use the value (unwrap if you know it exists)
229
- * return Text.Root(East.str`Count: ${count.unwrap("some")}`);
230
- * });
231
- * ```
232
- */
233
- export const state_read_typed = (key, type) => {
234
- return East.function([], OptionType(type), $ => {
235
- const key_expr = East.value(key);
236
- const ret = $.let(none, OptionType(type));
237
- $.match(state_read(key_expr), {
238
- some: ($, v) => {
239
- $.assign(ret, East.value(some(v.decodeBeast(type, "v2")), OptionType(type)));
240
- },
241
- });
242
- return ret;
243
- });
244
- };
245
- /**
246
- * Creates a typed state initialization function that only writes if the key doesn't exist.
41
+ * @param key - The state key to check
42
+ * @returns Boolean indicating whether the key exists
247
43
  *
248
44
  * @remarks
249
- * Returns an East function that initializes a state key with a default value.
250
- * The write only occurs if the key is not already set, preventing overwrites
251
- * on re-renders. Use this for setting up initial state in components.
252
- *
253
- * @typeParam T - The East type of the value to initialize
254
- * @param key - The string key to initialize
255
- * @param value - The default value to write (not wrapped in option)
256
- * @param type - The East type descriptor for the value
257
- * @returns A callable East function that performs the conditional initialization
258
- *
259
- * @example
260
- * ```ts
261
- * import { East, IntegerType } from "@elaraai/east";
262
- * import { State, UIComponentType, Button } from "@elaraai/east-ui";
263
- *
264
- * const counter = East.function([], UIComponentType, $ => {
265
- * // Initialize to 0 only if not already set
266
- * $(State.initTyped("counter", 0n, IntegerType)());
267
- *
268
- * // Read and display
269
- * const count = $.let(State.readTyped("counter", IntegerType)());
270
- * // ...
271
- * });
272
- * ```
45
+ * Implementation provided by `StateImpl` in `@elaraai/east-ui-components`.
273
46
  */
274
- export const state_init_typed = (key, value, type) => {
275
- return East.function([], NullType, $ => {
276
- const key_expr = East.value(key);
277
- const value_expr = East.value(value, type);
278
- $.match(state_read(key_expr), {
279
- none: ($) => {
280
- $(state_write(key_expr, some(East.Blob.encodeBeast(value_expr, "v2"))));
281
- },
282
- });
283
- return null;
284
- });
285
- };
47
+ export const state_has = East.platform("state_has", [StringType], BooleanType);
286
48
  //# sourceMappingURL=state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/platform/state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EACH,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,IAAI,EAIJ,WAAW,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAyB,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,gFAAgF;AAChF,+BAA+B;AAC/B,gFAAgF;AAEhF;;;GAGG;AACH,IAAI,eAAe,GAAuB,IAAI,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,cAAc;IAC1B,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;IAC5B,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe;IAC3B,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,eAAe,GAAG,IAAI,CAAC;IACvB,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACtB,OAAO,eAAe,KAAK,IAAI,CAAC;AACpC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW;IAChC,IAAI,eAAe,EAAE,CAAC;QAClB,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,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AAI,CAAC;IAChB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/platform/state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAExE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAC1C,YAAY,EACZ,CAAC,GAAG,CAAC,EACL,CAAC,UAAU,CAAC,EACZ,GAAG,CACN,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAC3C,aAAa,EACb,CAAC,GAAG,CAAC,EACL,CAAC,UAAU,EAAE,GAAG,CAAC,EACjB,QAAQ,CACX,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2025 Elara AI Pty Ltd
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
- import { type ExprType, type BlockBuilder } from "@elaraai/east";
5
+ import { type ExprType, type CallableFunctionExpr } from "@elaraai/east";
6
6
  import { UIComponentType } from "../component.js";
7
7
  /**
8
8
  * Creates a reactive component that re-renders independently when its dependencies change.
@@ -44,7 +44,7 @@ import { UIComponentType } from "../component.js";
44
44
  * });
45
45
  * ```
46
46
  */
47
- declare function createReactive(body: ($: BlockBuilder<typeof UIComponentType>) => ExprType<typeof UIComponentType> | void): ExprType<typeof UIComponentType>;
47
+ declare function createReactive(body: CallableFunctionExpr<[], typeof UIComponentType>): ExprType<typeof UIComponentType>;
48
48
  /**
49
49
  * Reactive component for selective re-rendering.
50
50
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reactive/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,KAAK,QAAQ,EACb,KAAK,YAAY,EAGpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAOlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,iBAAS,cAAc,CACnB,IAAI,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,OAAO,eAAe,CAAC,KAAK,QAAQ,CAAC,OAAO,eAAe,CAAC,GAAG,IAAI,GAC3F,QAAQ,CAAC,OAAO,eAAe,CAAC,CAuBlC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;IACjB;;;;;;;OAOG;;CAEG,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reactive/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,KAAK,QAAQ,EAAW,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAExF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,iBAAS,cAAc,CACnB,IAAI,EAAE,oBAAoB,CAAC,EAAE,EAAE,OAAO,eAAe,CAAC,GACvD,QAAQ,CAAC,OAAO,eAAe,CAAC,CAMlC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;IACjB;;;;;;;OAOG;;CAEG,CAAC"}
@@ -2,9 +2,8 @@
2
2
  * Copyright (c) 2025 Elara AI Pty Ltd
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
- import { East, variant, printLocations } from "@elaraai/east";
5
+ import { East, variant } from "@elaraai/east";
6
6
  import { UIComponentType } from "../component.js";
7
- import { OutOfScopeException } from "@elaraai/east/internal";
8
7
  // ============================================================================
9
8
  // Reactive Component Builder
10
9
  // ============================================================================
@@ -49,25 +48,10 @@ import { OutOfScopeException } from "@elaraai/east/internal";
49
48
  * ```
50
49
  */
51
50
  function createReactive(body) {
52
- // Create the inner render function
53
- const renderFn = East.function([], UIComponentType, body);
54
51
  // Get the IR and validate no captures from parent scope
55
- try {
56
- renderFn.toIR();
57
- }
58
- catch (e) {
59
- if (e instanceof OutOfScopeException) {
60
- throw new Error(`Reactive.Root body must be a free function with no captures from parent scope. ` +
61
- `Found capture from variable defined at ${printLocations(e.definedLocation)}. ` +
62
- `Move state reads inside the Reactive body or use State for shared data.`);
63
- }
64
- else {
65
- throw e;
66
- }
67
- }
68
52
  // Return the ReactiveComponent variant
69
53
  return East.value(variant("ReactiveComponent", {
70
- render: renderFn
54
+ render: body
71
55
  }), UIComponentType);
72
56
  }
73
57
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reactive/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,IAAI,EAGJ,OAAO,EACP,cAAc,EACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAS,cAAc,CACnB,IAA0F;IAE1F,mCAAmC;IACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;IAE1D,wDAAwD;IACxD,IAAI,CAAC;QACD,QAAQ,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,IAAI,CAAC,YAAY,mBAAmB,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CACX,iFAAiF;gBACjF,0CAA0C,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI;gBAC/E,yEAAyE,CAC5E,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,CAAC;QACZ,CAAC;IACL,CAAC;IAED,uCAAuC;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE;QAC3C,MAAM,EAAE,QAAQ;KACnB,CAAC,EAAE,eAAe,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB;;;;;;;OAOG;IACH,IAAI,EAAE,cAAc;CACd,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reactive/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAiB,OAAO,EAA6B,MAAM,eAAe,CAAC;AAExF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAS,cAAc,CACnB,IAAsD;IAEtD,wDAAwD;IACxD,uCAAuC;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE;QAC3C,MAAM,EAAE,IAAI;KACf,CAAC,EAAE,eAAe,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB;;;;;;;OAOG;IACH,IAAI,EAAE,cAAc;CACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elaraai/east-ui",
3
- "version": "0.0.1-beta.21",
3
+ "version": "0.0.1-beta.23",
4
4
  "description": "East UI - UI components for East language",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -72,6 +72,7 @@
72
72
  "node": ">=22.0.0"
73
73
  },
74
74
  "devDependencies": {
75
+ "@elaraai/east-node-std": "^0.0.1-beta.19",
75
76
  "@fortawesome/fontawesome-common-types": "^7.1.0",
76
77
  "@types/node": "^22.18.1",
77
78
  "@typescript-eslint/eslint-plugin": "^8.42.0",