@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.
@@ -32,8 +32,5 @@ export { Accordion, Carousel, Tabs } from "./disclosure/index.js";
32
32
  export { Tooltip, Menu, Dialog, dialog_open, Drawer, drawer_open, Popover, HoverCard, ActionBar, ToggleTip } from "./overlays/index.js";
33
33
  export { Reactive } from "./reactive/index.js";
34
34
  export { UIComponentType } from "./component.js";
35
- export { State } from "./platform/index.js";
36
- export { UIStore, createUIStore } from "./platform/index.js";
37
- export type { UIStoreInterface, UIStoreOptions } from "./platform/index.js";
38
- export { enableTracking, disableTracking, isTracking, trackKey } from "./platform/index.js";
35
+ export { State, state_read, state_write, state_has } from "./platform/index.js";
39
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGpG,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGhF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGnH,OAAO,EA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AAE,SAAS,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/src/index.js CHANGED
@@ -47,9 +47,6 @@ export { Tooltip, Menu, Dialog, dialog_open, Drawer, drawer_open, Popover, Hover
47
47
  export { Reactive } from "./reactive/index.js";
48
48
  // Component Types
49
49
  export { UIComponentType } from "./component.js";
50
- // Platform (state management)
51
- export { State } from "./platform/index.js";
52
- export { UIStore, createUIStore } from "./platform/index.js";
53
- // Tracking functions for reactive components (used by east-ui-components)
54
- export { enableTracking, disableTracking, isTracking, trackKey } from "./platform/index.js";
50
+ // Platform (state management - signatures only)
51
+ export { State, state_read, state_write, state_has } from "./platform/index.js";
55
52
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,8CAA8C;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,eAAe;AACf,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,aAAa;AACb,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEpG,SAAS;AACT,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEhF,UAAU;AACV,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAExD,QAAQ;AACR,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEnH,WAAW;AACX,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,M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AAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,kBAAkB;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,gDAAgD;AAChD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC"}
@@ -5,223 +5,48 @@
5
5
  /**
6
6
  * Platform functions for East UI state management.
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
+ * Contains platform function signatures only. For runtime implementations,
10
+ * typed helpers, and store classes, import from `@elaraai/east-ui-components`.
10
11
  *
11
12
  * @packageDocumentation
12
13
  */
13
- export { state_read, state_write, state_has, state_read_typed, state_write_typed, state_init_typed, store, StateImpl } from "./state.js";
14
- export { enableTracking, disableTracking, isTracking, trackKey } from "./state.js";
15
- export { UIStore, type UIStoreInterface, type UIStoreOptions, createUIStore } from "./store.js";
14
+ export { state_read, state_write, state_has } from "./state.js";
16
15
  /**
17
16
  * State management platform functions for East UI.
18
17
  *
19
18
  * @remarks
20
- * Use `State.read(key)` and `State.write(key, value)` for reactive state operations.
21
- * Pass `State.Implementation` to `ir.compile()` to enable state functionality.
19
+ * Contains platform function signatures only. For implementations,
20
+ * typed helpers, and store access, import from `@elaraai/east-ui-components`.
22
21
  *
23
22
  * @example
24
23
  * ```ts
25
- * import { East, IntegerType, NullType, some } from "@elaraai/east";
26
- * import { State, UIComponentType, Button } from "@elaraai/east-ui";
27
- *
28
- * const counter = East.function([], UIComponentType, $ => {
29
- * const count = $.let(0n);
30
- * $.match($(State.read("counter")), {
31
- * some: ($, v) => $.assign(count, v.decodeBeast(IntegerType, "v2")),
32
- * });
24
+ * import { East, NullType } from "@elaraai/east";
25
+ * import { State } from "@elaraai/east-ui";
26
+ * import { StateRuntime } from "@elaraai/east-ui-components";
33
27
  *
34
- * return Button.Root(East.str`Count: ${count}`, {
35
- * onClick: East.function([], NullType, $ => {
36
- * const count = $.let(0n);
37
- * $.match($(State.read("counter")), {
38
- * some: ($, v) => $.assign(count, v.decodeBeast(IntegerType, "v2")),
39
- * });
40
- * const newBlob = East.Blob.encodeBeast(count.add(1n), "v2");
41
- * $(State.write("counter", some(newBlob)));
42
- * })
43
- * });
28
+ * const fn = East.function([], NullType, $ => {
29
+ * $(State.read("key"));
44
30
  * });
45
31
  *
46
- * const compiled = counter.toIR().compile(State.Implementation);
47
- * const ui = compiled();
32
+ * const compiled = fn.toIR().compile(StateRuntime.Implementation);
48
33
  * ```
49
34
  */
50
35
  export declare const State: {
51
36
  /**
52
- * Reads a Beast2-encoded blob from the state store.
53
- *
54
- * @remarks
55
- * Returns `some(blob)` if the key exists, `none` if not.
56
- * Use `$.match()` to handle both cases and decode with `.decodeBeast()`.
57
- *
58
- * @example
59
- * ```ts
60
- * import { East, IntegerType } from "@elaraai/east";
61
- * import { State } from "@elaraai/east-ui";
62
- *
63
- * const readCounter = East.function([], IntegerType, $ => {
64
- * const count = $.let(0n);
65
- * $.match($(State.read("counter")), {
66
- * some: ($, v) => $.assign(count, v.decodeBeast(IntegerType, "v2")),
67
- * });
68
- * return count;
69
- * });
70
- * ```
71
- */
72
- readonly read: import("@elaraai/east").PlatformDefinition<[import("@elaraai/east").StringType], import("@elaraai/east").OptionType<import("@elaraai/east").BlobType>>;
73
- /**
74
- * Writes a Beast2-encoded blob to the state store.
75
- *
76
- * @remarks
77
- * Pass `some(blob)` to write a value, or `none` to delete the key.
78
- * Use `East.Blob.encodeBeast(value, "v2")` to encode values.
79
- *
80
- * @example
81
- * ```ts
82
- * import { East, NullType, some } from "@elaraai/east";
83
- * import { State } from "@elaraai/east-ui";
84
- *
85
- * const writeCounter = East.function([], NullType, $ => {
86
- * const blob = East.Blob.encodeBeast(East.value(42n), "v2");
87
- * $(State.write("counter", some(blob)));
88
- * });
89
- * ```
90
- */
91
- readonly write: import("@elaraai/east").PlatformDefinition<[import("@elaraai/east").StringType, import("@elaraai/east").OptionType<import("@elaraai/east").BlobType>], import("@elaraai/east").NullType>;
92
- /**
93
- * Platform implementation for state management operations.
94
- *
95
- * @remarks
96
- * Pass this to `ir.compile()` to enable state functionality.
97
- * Bound to the singleton {@link State.store}.
98
- *
99
- * @example
100
- * ```ts
101
- * import { East, NullType } from "@elaraai/east";
102
- * import { State } from "@elaraai/east-ui";
103
- *
104
- * const myFunction = East.function([], NullType, $ => {
105
- * // Use State.read and State.write here
106
- * });
107
- *
108
- * const compiled = myFunction.toIR().compile(State.Implementation);
109
- * compiled();
110
- * ```
37
+ * Reads a value from state storage.
38
+ * Returns `none` if key not found, `some(blob)` if found.
111
39
  */
112
- readonly Implementation: import("@elaraai/east/internal").PlatformFunction[];
40
+ readonly read: import("@elaraai/east").GenericPlatformDefinition<readonly ["T"], readonly [import("@elaraai/east").StringType], "T">;
113
41
  /**
114
- * Singleton UI store instance.
115
- *
116
- * @remarks
117
- * Access directly for React integration, subscriptions, or debugging.
118
- * This is the backing store for {@link State.Implementation}.
42
+ * Writes a value to state storage.
43
+ * Pass `none` as value to delete the key.
119
44
  */
120
- readonly store: import("./store.js").UIStore;
45
+ readonly write: import("@elaraai/east").GenericPlatformDefinition<readonly ["T"], readonly [import("@elaraai/east").StringType, "T"], import("@elaraai/east").NullType>;
121
46
  /**
122
- * Creates a typed state read function that handles Beast2 encoding automatically.
123
- *
124
- * @remarks
125
- * Returns an East function that reads and decodes a typed value from state.
126
- * Returns `some(value)` if the key exists, `none` if not. This is a convenience
127
- * wrapper around {@link State.read} that handles Beast2 decoding.
128
- *
129
- * **Important:** The returned function must be invoked with `()` inside `$()`:
130
- * ```ts
131
- * const value = $(State.readTyped("key", IntegerType)()); // Note: () inside $()
132
- * ```
133
- *
134
- * @example
135
- * ```ts
136
- * import { East, IntegerType } from "@elaraai/east";
137
- * import { State, UIComponentType, Text } from "@elaraai/east-ui";
138
- *
139
- * const display = East.function([], UIComponentType, $ => {
140
- * // Read typed value - returns Option<Integer>
141
- * const count = $(State.readTyped("counter", IntegerType)());
142
- *
143
- * // Unwrap if you know it exists
144
- * return Text.Root(East.str`Count: ${count.unwrap("some")}`);
145
- * });
146
- * ```
147
- */
148
- readonly readTyped: <T extends import("@elaraai/east").EastType>(key: import("@elaraai/east").SubtypeExprOrValue<import("@elaraai/east").StringType>, type: T) => import("@elaraai/east").CallableFunctionExpr<[], import("@elaraai/east").OptionType<T>>;
149
- /**
150
- * Creates a typed state write function that handles Beast2 encoding automatically.
151
- *
152
- * @remarks
153
- * Returns an East function that encodes and writes a typed value to state.
154
- * Pass `some(value)` to write or `none` to delete. This is a convenience
155
- * wrapper around {@link State.write} that handles Beast2 encoding.
156
- *
157
- * **Important:** The returned function must be invoked with `()` inside `$()`:
158
- * ```ts
159
- * $(State.writeTyped("key", some(42n), IntegerType)()); // Note: () inside $()
160
- * ```
161
- *
162
- * @example
163
- * ```ts
164
- * import { East, IntegerType, NullType, some, none } from "@elaraai/east";
165
- * import { State } from "@elaraai/east-ui";
166
- *
167
- * const writer = East.function([], NullType, $ => {
168
- * // Write a typed value
169
- * $(State.writeTyped("counter", some(42n), IntegerType)());
170
- *
171
- * // Delete the key
172
- * $(State.writeTyped("counter", none, IntegerType)());
173
- * });
174
- * ```
175
- */
176
- readonly writeTyped: <T extends import("@elaraai/east").EastType>(key: import("@elaraai/east").SubtypeExprOrValue<import("@elaraai/east").StringType>, value: import("@elaraai/east").SubtypeExprOrValue<import("@elaraai/east").OptionType<T>>, type: T) => import("@elaraai/east").CallableFunctionExpr<[], import("@elaraai/east").NullType>;
177
- /**
178
- * Checks if a key exists in the state store.
179
- *
180
- * @remarks
181
- * Returns a boolean indicating whether the key is set.
182
- * Useful for conditional logic based on state existence.
183
- *
184
- * @example
185
- * ```ts
186
- * import { East, NullType } from "@elaraai/east";
187
- * import { State } from "@elaraai/east-ui";
188
- *
189
- * const checker = East.function([], NullType, $ => {
190
- * $.if($(State.has("counter")), $ => {
191
- * // Key exists, do something
192
- * });
193
- * });
194
- * ```
47
+ * Checks if a key exists in state storage.
48
+ * Returns boolean indicating existence.
195
49
  */
196
50
  readonly has: import("@elaraai/east").PlatformDefinition<[import("@elaraai/east").StringType], import("@elaraai/east").BooleanType>;
197
- /**
198
- * Creates a typed state initialization function that only writes if the key doesn't exist.
199
- *
200
- * @remarks
201
- * Returns an East function that initializes a state key with a default value.
202
- * The write only occurs if the key is not already set, preventing overwrites
203
- * on re-renders. Use this for setting up initial state in components.
204
- *
205
- * **Important:** The returned function must be invoked with `()` inside `$()`:
206
- * ```ts
207
- * $(State.initTyped("key", 0n, IntegerType)()); // Note: () inside $()
208
- * ```
209
- *
210
- * @example
211
- * ```ts
212
- * import { East, IntegerType } from "@elaraai/east";
213
- * import { State, UIComponentType, Text } from "@elaraai/east-ui";
214
- *
215
- * const counter = East.function([], UIComponentType, $ => {
216
- * // Initialize to 0 only if not already set (safe for re-renders)
217
- * $(State.initTyped("counter", 0n, IntegerType)());
218
- *
219
- * // Read and display
220
- * const count = $(State.readTyped("counter", IntegerType)());
221
- * return Text.Root(East.str`Count: ${count.unwrap("some")}`);
222
- * });
223
- * ```
224
- */
225
- readonly initTyped: <T extends import("@elaraai/east").EastType>(key: import("@elaraai/east").SubtypeExprOrValue<import("@elaraai/east").StringType>, value: import("@elaraai/east").SubtypeExprOrValue<T>, type: T) => import("@elaraai/east").CallableFunctionExpr<[], import("@elaraai/east").NullType>;
226
51
  };
227
52
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGzI,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGnF,OAAO,EAAE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,KAAK;IACd;;;;;;;;;;;;;;;;;;;;OAoBG;;IAGH;;;;;;;;;;;;;;;;;OAiBG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;;IAGH;;;;;;;;;;;;;;;;;;OAkBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;;CAEG,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAGH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK;IACd;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;CAEG,CAAC"}
@@ -5,228 +5,51 @@
5
5
  /**
6
6
  * Platform functions for East UI state management.
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
+ * Contains platform function signatures only. For runtime implementations,
10
+ * typed helpers, and store classes, import from `@elaraai/east-ui-components`.
10
11
  *
11
12
  * @packageDocumentation
12
13
  */
13
- // Export platform functions and implementation
14
- export { state_read, state_write, state_has, state_read_typed, state_write_typed, state_init_typed, store, StateImpl } from "./state.js";
15
- // Export tracking functions for reactive components
16
- export { enableTracking, disableTracking, isTracking, trackKey } from "./state.js";
17
- // Export store types
18
- export { UIStore, createUIStore } from "./store.js";
14
+ // Export platform function signatures
15
+ export { state_read, state_write, state_has } from "./state.js";
19
16
  // Import for grouped exports
20
- import { state_read, state_write, state_has, state_read_typed, state_write_typed, state_init_typed, store, StateImpl } from "./state.js";
17
+ import { state_read, state_write, state_has } from "./state.js";
21
18
  /**
22
19
  * State management platform functions for East UI.
23
20
  *
24
21
  * @remarks
25
- * Use `State.read(key)` and `State.write(key, value)` for reactive state operations.
26
- * Pass `State.Implementation` to `ir.compile()` to enable state functionality.
22
+ * Contains platform function signatures only. For implementations,
23
+ * typed helpers, and store access, import from `@elaraai/east-ui-components`.
27
24
  *
28
25
  * @example
29
26
  * ```ts
30
- * import { East, IntegerType, NullType, some } from "@elaraai/east";
31
- * import { State, UIComponentType, Button } from "@elaraai/east-ui";
32
- *
33
- * const counter = East.function([], UIComponentType, $ => {
34
- * const count = $.let(0n);
35
- * $.match($(State.read("counter")), {
36
- * some: ($, v) => $.assign(count, v.decodeBeast(IntegerType, "v2")),
37
- * });
27
+ * import { East, NullType } from "@elaraai/east";
28
+ * import { State } from "@elaraai/east-ui";
29
+ * import { StateRuntime } from "@elaraai/east-ui-components";
38
30
  *
39
- * return Button.Root(East.str`Count: ${count}`, {
40
- * onClick: East.function([], NullType, $ => {
41
- * const count = $.let(0n);
42
- * $.match($(State.read("counter")), {
43
- * some: ($, v) => $.assign(count, v.decodeBeast(IntegerType, "v2")),
44
- * });
45
- * const newBlob = East.Blob.encodeBeast(count.add(1n), "v2");
46
- * $(State.write("counter", some(newBlob)));
47
- * })
48
- * });
31
+ * const fn = East.function([], NullType, $ => {
32
+ * $(State.read("key"));
49
33
  * });
50
34
  *
51
- * const compiled = counter.toIR().compile(State.Implementation);
52
- * const ui = compiled();
35
+ * const compiled = fn.toIR().compile(StateRuntime.Implementation);
53
36
  * ```
54
37
  */
55
38
  export const State = {
56
39
  /**
57
- * Reads a Beast2-encoded blob from the state store.
58
- *
59
- * @remarks
60
- * Returns `some(blob)` if the key exists, `none` if not.
61
- * Use `$.match()` to handle both cases and decode with `.decodeBeast()`.
62
- *
63
- * @example
64
- * ```ts
65
- * import { East, IntegerType } from "@elaraai/east";
66
- * import { State } from "@elaraai/east-ui";
67
- *
68
- * const readCounter = East.function([], IntegerType, $ => {
69
- * const count = $.let(0n);
70
- * $.match($(State.read("counter")), {
71
- * some: ($, v) => $.assign(count, v.decodeBeast(IntegerType, "v2")),
72
- * });
73
- * return count;
74
- * });
75
- * ```
40
+ * Reads a value from state storage.
41
+ * Returns `none` if key not found, `some(blob)` if found.
76
42
  */
77
43
  read: state_read,
78
44
  /**
79
- * Writes a Beast2-encoded blob to the state store.
80
- *
81
- * @remarks
82
- * Pass `some(blob)` to write a value, or `none` to delete the key.
83
- * Use `East.Blob.encodeBeast(value, "v2")` to encode values.
84
- *
85
- * @example
86
- * ```ts
87
- * import { East, NullType, some } from "@elaraai/east";
88
- * import { State } from "@elaraai/east-ui";
89
- *
90
- * const writeCounter = East.function([], NullType, $ => {
91
- * const blob = East.Blob.encodeBeast(East.value(42n), "v2");
92
- * $(State.write("counter", some(blob)));
93
- * });
94
- * ```
45
+ * Writes a value to state storage.
46
+ * Pass `none` as value to delete the key.
95
47
  */
96
48
  write: state_write,
97
49
  /**
98
- * Platform implementation for state management operations.
99
- *
100
- * @remarks
101
- * Pass this to `ir.compile()` to enable state functionality.
102
- * Bound to the singleton {@link State.store}.
103
- *
104
- * @example
105
- * ```ts
106
- * import { East, NullType } from "@elaraai/east";
107
- * import { State } from "@elaraai/east-ui";
108
- *
109
- * const myFunction = East.function([], NullType, $ => {
110
- * // Use State.read and State.write here
111
- * });
112
- *
113
- * const compiled = myFunction.toIR().compile(State.Implementation);
114
- * compiled();
115
- * ```
116
- */
117
- Implementation: StateImpl,
118
- /**
119
- * Singleton UI store instance.
120
- *
121
- * @remarks
122
- * Access directly for React integration, subscriptions, or debugging.
123
- * This is the backing store for {@link State.Implementation}.
124
- */
125
- store: store,
126
- /**
127
- * Creates a typed state read function that handles Beast2 encoding automatically.
128
- *
129
- * @remarks
130
- * Returns an East function that reads and decodes a typed value from state.
131
- * Returns `some(value)` if the key exists, `none` if not. This is a convenience
132
- * wrapper around {@link State.read} that handles Beast2 decoding.
133
- *
134
- * **Important:** The returned function must be invoked with `()` inside `$()`:
135
- * ```ts
136
- * const value = $(State.readTyped("key", IntegerType)()); // Note: () inside $()
137
- * ```
138
- *
139
- * @example
140
- * ```ts
141
- * import { East, IntegerType } from "@elaraai/east";
142
- * import { State, UIComponentType, Text } from "@elaraai/east-ui";
143
- *
144
- * const display = East.function([], UIComponentType, $ => {
145
- * // Read typed value - returns Option<Integer>
146
- * const count = $(State.readTyped("counter", IntegerType)());
147
- *
148
- * // Unwrap if you know it exists
149
- * return Text.Root(East.str`Count: ${count.unwrap("some")}`);
150
- * });
151
- * ```
152
- */
153
- readTyped: state_read_typed,
154
- /**
155
- * Creates a typed state write function that handles Beast2 encoding automatically.
156
- *
157
- * @remarks
158
- * Returns an East function that encodes and writes a typed value to state.
159
- * Pass `some(value)` to write or `none` to delete. This is a convenience
160
- * wrapper around {@link State.write} that handles Beast2 encoding.
161
- *
162
- * **Important:** The returned function must be invoked with `()` inside `$()`:
163
- * ```ts
164
- * $(State.writeTyped("key", some(42n), IntegerType)()); // Note: () inside $()
165
- * ```
166
- *
167
- * @example
168
- * ```ts
169
- * import { East, IntegerType, NullType, some, none } from "@elaraai/east";
170
- * import { State } from "@elaraai/east-ui";
171
- *
172
- * const writer = East.function([], NullType, $ => {
173
- * // Write a typed value
174
- * $(State.writeTyped("counter", some(42n), IntegerType)());
175
- *
176
- * // Delete the key
177
- * $(State.writeTyped("counter", none, IntegerType)());
178
- * });
179
- * ```
180
- */
181
- writeTyped: state_write_typed,
182
- /**
183
- * Checks if a key exists in the state store.
184
- *
185
- * @remarks
186
- * Returns a boolean indicating whether the key is set.
187
- * Useful for conditional logic based on state existence.
188
- *
189
- * @example
190
- * ```ts
191
- * import { East, NullType } from "@elaraai/east";
192
- * import { State } from "@elaraai/east-ui";
193
- *
194
- * const checker = East.function([], NullType, $ => {
195
- * $.if($(State.has("counter")), $ => {
196
- * // Key exists, do something
197
- * });
198
- * });
199
- * ```
50
+ * Checks if a key exists in state storage.
51
+ * Returns boolean indicating existence.
200
52
  */
201
53
  has: state_has,
202
- /**
203
- * Creates a typed state initialization function that only writes if the key doesn't exist.
204
- *
205
- * @remarks
206
- * Returns an East function that initializes a state key with a default value.
207
- * The write only occurs if the key is not already set, preventing overwrites
208
- * on re-renders. Use this for setting up initial state in components.
209
- *
210
- * **Important:** The returned function must be invoked with `()` inside `$()`:
211
- * ```ts
212
- * $(State.initTyped("key", 0n, IntegerType)()); // Note: () inside $()
213
- * ```
214
- *
215
- * @example
216
- * ```ts
217
- * import { East, IntegerType } from "@elaraai/east";
218
- * import { State, UIComponentType, Text } from "@elaraai/east-ui";
219
- *
220
- * const counter = East.function([], UIComponentType, $ => {
221
- * // Initialize to 0 only if not already set (safe for re-renders)
222
- * $(State.initTyped("counter", 0n, IntegerType)());
223
- *
224
- * // Read and display
225
- * const count = $(State.readTyped("counter", IntegerType)());
226
- * return Text.Root(East.str`Count: ${count.unwrap("some")}`);
227
- * });
228
- * ```
229
- */
230
- initTyped: state_init_typed,
231
54
  };
232
55
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,+CAA+C;AAC/C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzI,oDAAoD;AACpD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnF,qBAAqB;AACrB,OAAO,EAAE,OAAO,EAA8C,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhG,6BAA6B;AAC7B,OAAO,EAA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