heavy-reactive 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 (55) hide show
  1. package/.commitlintrc +2 -0
  2. package/.editorconfig +17 -0
  3. package/.gitattributes +2 -0
  4. package/.github/workflows/check-code.yml +48 -0
  5. package/.github/workflows/lint-commit.yml +15 -0
  6. package/.github/workflows/lint-request.yml +19 -0
  7. package/.github/workflows/release-job.yml +62 -0
  8. package/.husky/commit-msg +18 -0
  9. package/.husky/pre-commit +18 -0
  10. package/.prettierignore +2 -0
  11. package/.prettierrc +9 -0
  12. package/.vscode/extensions.json +3 -0
  13. package/.vscode/settings.json +27 -0
  14. package/.vscode/tasks.json +25 -0
  15. package/CHANGELOG.md +1 -0
  16. package/CONTRIBUTING.md +116 -0
  17. package/GLOSSARY.md +144 -0
  18. package/LICENSE +21 -0
  19. package/README.md +198 -0
  20. package/feature.reactivity/_common/changes.interface.ts +44 -0
  21. package/feature.reactivity/_common/dictionary-changes.interface.ts +54 -0
  22. package/feature.reactivity/_common/observable.interface.ts +22 -0
  23. package/feature.reactivity/_common/set-changes.interface.ts +50 -0
  24. package/feature.reactivity/_common/value-change.interface.ts +54 -0
  25. package/feature.reactivity/_common/value-container.interface.ts +12 -0
  26. package/feature.reactivity/dictionary/reactive-array.class.ts +0 -0
  27. package/feature.reactivity/dictionary/reactive-map.class.ts +0 -0
  28. package/feature.reactivity/dictionary/reactive-object.class.ts +0 -0
  29. package/feature.reactivity/reactivity-disabled.error.ts +11 -0
  30. package/feature.reactivity/reactivity.module.ts +458 -0
  31. package/feature.reactivity/readonly-access.error.ts +13 -0
  32. package/feature.reactivity/set/$difference.class.ts +272 -0
  33. package/feature.reactivity/set/$intersection.class.ts +137 -0
  34. package/feature.reactivity/set/$set.class.ts +1022 -0
  35. package/feature.reactivity/set/$union.class.ts +74 -0
  36. package/feature.reactivity/set/_combination/$combination.class.ts +179 -0
  37. package/feature.reactivity/set/_combination/$variadic-combination.class.ts +235 -0
  38. package/feature.reactivity/set/feature.projection-sets/$complement-via-set.class.ts +159 -0
  39. package/feature.reactivity/set/feature.projection-sets/$complement-via-val.class.ts +126 -0
  40. package/feature.reactivity/set/feature.projection-sets/$set-from-any.class.ts +382 -0
  41. package/feature.reactivity/set/feature.projection-sets/$set-from-set.class.ts +90 -0
  42. package/feature.reactivity/set/feature.projection-sets/$subset-via-set.class.ts +123 -0
  43. package/feature.reactivity/set/feature.projection-sets/$subset-via-val.class.ts +114 -0
  44. package/feature.reactivity/set/feature.projection-sets/feature.reactive-delta-buffer/delta-buffer-for-set.class.ts +235 -0
  45. package/feature.reactivity/set/feature.projection-sets/feature.reactive-delta-buffer/delta-buffer-for-value.class.ts +193 -0
  46. package/feature.reactivity/set/feature.projection-sets/types/dependency-set-resolver.type.ts +19 -0
  47. package/feature.reactivity/set/feature.projection-sets/types/dependency-value-resolver.type.ts +20 -0
  48. package/feature.reactivity/value/$value.class.ts +237 -0
  49. package/feature.set/index.ts +3 -0
  50. package/feature.set/set.prototype.difference.polyfill.ts +7 -0
  51. package/feature.set/set.prototype.intersection.polyfill.ts +6 -0
  52. package/feature.set/set.prototype.union.polyfill.ts +11 -0
  53. package/feature.typescript/maybe-promise.type.ts +1 -0
  54. package/package.json +51 -0
  55. package/tsconfig.json +116 -0
@@ -0,0 +1,458 @@
1
+ import { $ComplementViaSet } from "./set/feature.projection-sets/$complement-via-set.class.js"
2
+ import { $ComplementViaVal } from "./set/feature.projection-sets/$complement-via-val.class.js"
3
+ import { $SetFromAny, TDependenciesMap } from "./set/feature.projection-sets/$set-from-any.class.js"
4
+ import { $SetFromSet } from "./set/feature.projection-sets/$set-from-set.class.js"
5
+ import { $Set } from "./set/$set.class.js"
6
+ import { $Combination } from "./set/_combination/$combination.class.js"
7
+ import { $Value } from "./value/$value.class.js"
8
+ import { $VariadicCombination } from "./set/_combination/$variadic-combination.class.js"
9
+ import { $Difference } from "./set/$difference.class.js"
10
+ import { $Intersection } from "./set/$intersection.class.js"
11
+ import { $SubsetViaSet } from "./set/feature.projection-sets/$subset-via-set.class.js"
12
+ import { $Union } from "./set/$union.class.js"
13
+ import { $SubsetViaVal } from "./set/feature.projection-sets/$subset-via-val.class.js"
14
+
15
+ export { $Value } from "./value/$value.class.js"
16
+
17
+ /**
18
+ * Creates a new reactive scalar value container.
19
+ *
20
+ * `$value()` is the primary entry point for working with simple reactive values.
21
+ * It wraps a single value in a reactive container, exposing:
22
+ * - `.value` for reading/writing the current value;
23
+ * - `.onChange` for subscribing to updates (using signals);
24
+ * - transaction support (`openTransaction`, `closeTransaction`) for batching changes.
25
+ *
26
+ * This function returns an instance of `$Value<T>`, and is typically used to track
27
+ * reactive primitives or objects in a lightweight and observable manner.
28
+ *
29
+ * @template TValue The type of the stored value.
30
+ *
31
+ * @param args Constructor arguments matching `$Value<T>`:
32
+ * - `{ value: TValue; label?: string }` — initial value and optional debug label.
33
+ *
34
+ * @returns A new `$Value<T>` instance.
35
+ *
36
+ * @example Reactive counter:
37
+ * ```ts
38
+ * const counter = $value({ value: 0 })
39
+ * counter.onChange.subscribe(({ increment }) => {
40
+ * console.log('New value:', increment?.value)
41
+ * })
42
+ *
43
+ * counter.value = counter.value + 1
44
+ * ```
45
+ *
46
+ * @example Batching with transaction:
47
+ * ```ts
48
+ * const state = $value({ value: { count: 0 } })
49
+ *
50
+ * state.openTransaction()
51
+ * state.value = { count: 1 }
52
+ * state.value = { count: 2 }
53
+ * state.closeTransaction() // onChange emitted once with final state
54
+ * ```
55
+ */
56
+ export function $value<TValue>(...args: ConstructorParameters<typeof $Value<TValue>>): $Value<TValue> {
57
+ return new $Value(...args)
58
+ }
59
+
60
+ export { $Set } from "./set/$set.class.js"
61
+
62
+ /**
63
+ * Creates a new reactive set.
64
+ *
65
+ * `$set()` wraps a native `Set<T>` with a reactive interface:
66
+ * - Emits `onChange` signals when the contents are updated;
67
+ * - Supports granular mutations (`add`, `delete`, `clear`);
68
+ * - Supports batch operations (`batchAdd`, `batchDelete`, `applyChanges`);
69
+ * - Allows transactional grouping via `openTransaction` / `closeTransaction`;
70
+ * - Enforces immutability when disabled.
71
+ *
72
+ * @remarks
73
+ * ### Batching changes
74
+ * The set provides multiple ways to apply changes in bulk:
75
+ *
76
+ * - Use `batchAdd(values)` or `batchDelete(values)` to efficiently add/remove multiple items.
77
+ * - Use `applyChanges({ increment, decrement })` to apply both in a single call.
78
+ * - Use transactions (`openTransaction()` / `closeTransaction()`) to delay signaling until all operations are complete.
79
+ *
80
+ * @template TValue The type of values held in the set.
81
+ *
82
+ * @param args Constructor arguments matching `$Set<T>`:
83
+ * - `{ values?: Iterable<TValue>; label?: string }`
84
+ *
85
+ * @returns A new `$Set<T>` instance.
86
+ *
87
+ * @example Basic usage:
88
+ * ```ts
89
+ * const $tags = $set({ values: ['a', 'b'] })
90
+ *
91
+ * $tags.onChange.subscribe(({ increment, decrement }) => {
92
+ * console.log('Added:', [...(increment ?? [])])
93
+ * console.log('Removed:', [...(decrement ?? [])])
94
+ * })
95
+ *
96
+ * $tags.add('c') // emits: increment = Set { 'c' }
97
+ * $tags.delete('a') // emits: decrement = Set { 'a' }
98
+ * ```
99
+ *
100
+ * @example Using batch methods:
101
+ * ```ts
102
+ * $tags.batchAdd(['x', 'y']) // emits: increment = Set { 'x', 'y' }
103
+ * $tags.batchDelete(['b']) // emits: decrement = Set { 'b' }
104
+ * ```
105
+ *
106
+ * @example Using applyChanges:
107
+ * ```ts
108
+ * $tags.applyChanges({
109
+ * increment: new Set(['m']),
110
+ * decrement: new Set(['a'])
111
+ * }) // emits both additions and removals together
112
+ * ```
113
+ *
114
+ * @example Transactional update:
115
+ * ```ts
116
+ * $tags.openTransaction()
117
+ * $tags.add('p')
118
+ * $tags.delete('y')
119
+ * $tags.closeTransaction() // emits a single signal for all changes
120
+ * ```
121
+ */
122
+ export function $set<TValue>(...args: ConstructorParameters<typeof $Set<TValue>>): $Set<TValue> {
123
+ return new $Set<TValue>(...args)
124
+ }
125
+
126
+ export { $Combination } from "./set/_combination/$combination.class.js"
127
+
128
+ /**
129
+ * Creates a `$ComplementViaSet` instance.
130
+ *
131
+ * This factory produces a derived reactive set that excludes values from the given `superset`
132
+ * by projecting items from a `relation` set into the superset using a custom `resolver()` function.
133
+ *
134
+ * Each key in the `relation` set is mapped to values that should be excluded from the result.
135
+ * The final result is `superset − projection`.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const $all = $set({ values: ["a", "b", "c"] })
140
+ * const $exclude = $set({ values: ["b"] })
141
+ *
142
+ * const $visible = $complementViaSet({
143
+ * superset: $all,
144
+ * relation: $exclude,
145
+ * resolver: (all, keys) => [...all].filter(x => keys.has(x)),
146
+ * })
147
+ * ```
148
+ *
149
+ * @returns A readonly reactive `$Combination<T>` representing the complement set.
150
+ */
151
+ export function $complementViaSet<TSupersetValue, TRelationValue>(
152
+ ...args: ConstructorParameters<typeof $ComplementViaSet<TSupersetValue, TRelationValue>>
153
+ ): $Combination<TSupersetValue> {
154
+ return new $ComplementViaSet(...args)
155
+ }
156
+
157
+ /**
158
+ * Creates a `$ComplementViaVal` instance.
159
+ *
160
+ * Produces a derived reactive set that excludes projected values based on a single
161
+ * reactive relation key stored in a `$Value`. The `resolver()` maps the relation
162
+ * key to values in the superset that should be excluded.
163
+ *
164
+ * The result is `superset − projection(relation)`.
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * const $all = $set({ values: ["a", "b", "c"] })
169
+ * const $mode = $value({ value: "b" })
170
+ *
171
+ * const $visible = $complementViaVal({
172
+ * superset: $all,
173
+ * relation: $mode,
174
+ * resolver: (all, key) => [...all].filter(x => x === key.value),
175
+ * })
176
+ * ```
177
+ *
178
+ * @returns A readonly reactive `$Combination<T>` representing the complement set.
179
+ */
180
+ export function $complementViaVal<TSupersetValue, TRelationValue>(
181
+ ...args: ConstructorParameters<typeof $ComplementViaVal<TSupersetValue, TRelationValue>>
182
+ ): $Combination<TSupersetValue> {
183
+ return new $ComplementViaVal(...args)
184
+ }
185
+
186
+ /**
187
+ * Creates a `$SubsetViaSet` instance.
188
+ *
189
+ * Produces a derived reactive set that includes values from the given `superset`
190
+ * based on a set of relation keys. Each key is projected into the superset
191
+ * using a custom `resolver()` function, and the result is the union of all projections.
192
+ *
193
+ * This is commonly used for:
194
+ * - tag-based filtering,
195
+ * - parent → children projections,
196
+ * - resolving references dynamically.
197
+ *
198
+ * @example
199
+ * ```ts
200
+ * const $all = $set({ values: ["a", "b", "c", "d"] })
201
+ * const $tags = $set({ values: ["a", "d"] })
202
+ *
203
+ * const $selected = $subsetViaSet({
204
+ * superset: $all,
205
+ * relation: $tags,
206
+ * resolver: (all, keys) => [...all].filter(x => keys.has(x)),
207
+ * })
208
+ * ```
209
+ *
210
+ * @returns A readonly reactive `$Combination<T>` representing the projected subset.
211
+ */
212
+ export function $subsetViaSet<TSupersetValue, TRelationValue>(
213
+ ...args: ConstructorParameters<typeof $SubsetViaSet<TSupersetValue, TRelationValue>>
214
+ ): $Combination<TSupersetValue> {
215
+ return new $SubsetViaSet(...args)
216
+ }
217
+
218
+ /**
219
+ * Creates a `$SubsetViaVal` instance.
220
+ *
221
+ * Produces a derived reactive set by projecting a single reactive relation key
222
+ * into a subset of values from the `superset`. The `resolver()` defines the
223
+ * projection from the relation key to included superset values.
224
+ *
225
+ * The result is replaced (overwrite) when the key changes.
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * const $all = $set({ values: ["a", "b", "c"] })
230
+ * const $selectedTag = $value({ value: "b" })
231
+ *
232
+ * const $visible = $subsetViaVal({
233
+ * superset: $all,
234
+ * relation: $selectedTag,
235
+ * resolver: (all, key) => [...all].filter(x => x === key.value),
236
+ * })
237
+ * ```
238
+ *
239
+ * @returns A readonly reactive `$Combination<T>` representing the projected subset.
240
+ */
241
+ export function $subsetViaVal<TSupersetValue, TRelationValue>(
242
+ ...args: ConstructorParameters<typeof $SubsetViaVal<TSupersetValue, TRelationValue>>
243
+ ): $Combination<TSupersetValue> {
244
+ return new $SubsetViaVal(...args)
245
+ }
246
+
247
+ /**
248
+ * Creates a highly customizable reactive derived set from arbitrary dependencies.
249
+ *
250
+ * `$deriveSetFromAny<T>()` returns a curried factory function that accepts a configuration
251
+ * for constructing a `$SetFromAny<T, TDependencies>` instance — a general-purpose reactive
252
+ * combinator that derives its content from multiple `$Set` and/or `$Value` sources.
253
+ *
254
+ * Each source is registered by name, and a corresponding `resolver()` must be provided
255
+ * to transform changes in that source into incremental or overwrite-level changes in the result set.
256
+ *
257
+ * This low-level primitive powers all higher-order derived constructs such as:
258
+ * - `$SubsetViaSet`
259
+ * - `$ComplementViaVal`
260
+ * - `$SetFromSet`
261
+ *
262
+ * @template TValue The type of values in the resulting derived set.
263
+ *
264
+ * @returns A factory function that creates a `$SetFromAny<T>` with typed dependencies.
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * const $items = $set(["apple", "banana", "cherry"])
269
+ * const $hide = $value("a")
270
+ *
271
+ * const $filtered = $deriveSetFromAny<string>()({
272
+ * label: "filteredItems",
273
+ * dependencies: { source: $items, mask: $hide },
274
+ * resolvers: {
275
+ * source: async ({ mask }, { increment, decrement }) => ({
276
+ * increment: new Set([...increment ?? []].filter(i => !i.startsWith(mask?.value ?? ""))),
277
+ * decrement,
278
+ * }),
279
+ * mask: async ({ source }, { increment }) => {
280
+ * const excluded = new Set([...source ?? []].filter(i => i.startsWith(increment?.value ?? "")))
281
+ * return { overwrite: new Set([...source ?? []].filter(i => !excluded.has(i))) }
282
+ * },
283
+ * },
284
+ * })
285
+ * ```
286
+ */
287
+ export function $deriveSetFromAny<TValue>() {
288
+ return <TDependencies extends TDependenciesMap>(...args: ConstructorParameters<typeof $SetFromAny<TValue, TDependencies>>): $Combination<TValue> =>
289
+ new $SetFromAny(...args)
290
+ }
291
+
292
+ /**
293
+ * Creates a `$SetFromSet` instance.
294
+ *
295
+ * Produces a reactive derived set by transforming incremental changes
296
+ * from a source `$Set<TSource>` into corresponding changes in a target set.
297
+ *
298
+ * Unlike projection-based sets, this factory doesn't use relation keys or masking.
299
+ * Instead, it applies a user-defined `resolver()` function to each incoming delta,
300
+ * allowing for freeform transformation: filtering, remapping, expanding, etc.
301
+ *
302
+ * Useful for:
303
+ * - mapping IDs to objects,
304
+ * - type conversions (e.g. `Point → Zone`),
305
+ * - building enriched views of a changing set.
306
+ *
307
+ * @example
308
+ * ```ts
309
+ * const $ids = $set({ values: [1, 2, 3] })
310
+ *
311
+ * const $objects = $deriveSetFromSet({
312
+ * source: $ids,
313
+ * resolver: async ({ increment, decrement }) => ({
314
+ * increment: new Set((increment ?? []).map(id => ({ id, label: `Item ${id}` }))),
315
+ * decrement: new Set((decrement ?? []).map(id => ({ id, label: `Item ${id}` }))),
316
+ * }),
317
+ * })
318
+ * ```
319
+ *
320
+ * @returns A readonly reactive `$Combination<T>` that reflects transformed deltas.
321
+ */
322
+ export function $deriveSetFromSet<TValue, TSourceValue>(...args: ConstructorParameters<typeof $SetFromSet<TValue, TSourceValue>>): $Combination<TValue> {
323
+ return new $SetFromSet(...args)
324
+ }
325
+ export { $VariadicCombination } from "./set/_combination/$variadic-combination.class.js"
326
+
327
+ /**
328
+ * Creates a reactive set that represents the difference between a superset and one or more subsets.
329
+ *
330
+ * `$differenceSets()` returns a reactive set that includes all items from the `superset`
331
+ * that are **not** present in any of the provided `subsets`. It automatically reacts to changes
332
+ * in both the superset and the subsets — updating its own contents accordingly.
333
+ *
334
+ * This is one of three core combination factories:
335
+ * - `$unionSets()` – merges multiple sets into a single set of unique values;
336
+ * - `$intersectionSets()` – includes only values present in *all* subsets;
337
+ * - `$differenceSets()` – removes all values from the superset that appear in *any* subset.
338
+ *
339
+ * @template TValue The type of values within the sets.
340
+ *
341
+ * @param args Constructor arguments matching `$Difference<T>`:
342
+ * - `{ superset: $Set<TValue>; subsets: Array<$Set<TValue>>; label?: string; enabled?: boolean }`
343
+ *
344
+ * @returns A reactive `$Set<T>` representing the dynamic difference.
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * const $allUsers = $set({ values: [1, 2, 3, 4, 5] })
349
+ * const $banned = $set({ values: [2, 4] })
350
+ *
351
+ * const $activeUsers = $differenceSets({
352
+ * superset: $allUsers,
353
+ * subsets: [$banned],
354
+ * label: 'Active users'
355
+ * })
356
+ *
357
+ * console.log([...$activeUsers]) // → [1, 3, 5]
358
+ *
359
+ * $banned.add(5)
360
+ * console.log([...$activeUsers]) // → [1, 3]
361
+ *
362
+ * $allUsers.delete(1)
363
+ * console.log([...$activeUsers]) // → [3]
364
+ * ```
365
+ *
366
+ * @see {@link $unionSets}
367
+ * @see {@link $intersectionSets}
368
+ */
369
+ export function $differenceSets<TValue>(...args: ConstructorParameters<typeof $Difference<TValue>>): $VariadicCombination<TValue> {
370
+ return new $Difference(...args)
371
+ }
372
+
373
+ /**
374
+ * Creates a reactive set representing the intersection of multiple reactive sets.
375
+ *
376
+ * `$intersectionSets()` returns a derived `$Set<T>` that includes only those values
377
+ * which are present in **every** of the provided subsets. Whenever any of the input sets
378
+ * changes, the intersection is recalculated and updated automatically.
379
+ *
380
+ * This is one of three core combination factories:
381
+ * - `$unionSets()` – merges all values from all subsets;
382
+ * - `$intersectionSets()` – keeps only values shared by all subsets;
383
+ * - `$differenceSets()` – removes values from a superset that exist in subsets.
384
+ *
385
+ * @template TValue The type of values within the sets.
386
+ *
387
+ * @param args Constructor arguments matching `$Intersection<T>`:
388
+ * - `{ subsets: Array<$Set<TValue>>; label?: string; enabled?: boolean }`
389
+ *
390
+ * @returns A reactive set representing the dynamic intersection of all input sets.
391
+ *
392
+ * @example
393
+ * ```ts
394
+ * const $onlineUsers = $set({ values: [1, 2, 3] })
395
+ * const $premiumUsers = $set({ values: [2, 3, 4] })
396
+ *
397
+ * const $onlinePremium = $intersectionSets({
398
+ * subsets: [$onlineUsers, $premiumUsers],
399
+ * label: 'Online + Premium'
400
+ * })
401
+ *
402
+ * console.log([...$onlinePremium]) // → [2, 3]
403
+ *
404
+ * $onlineUsers.delete(2)
405
+ * console.log([...$onlinePremium]) // → [3]
406
+ *
407
+ * $premiumUsers.delete(3)
408
+ * console.log([...$onlinePremium]) // → []
409
+ * ```
410
+ *
411
+ * @see {@link $unionSets}
412
+ * @see {@link $differenceSets}
413
+ */
414
+ export function $intersectionSets<TValue>(...args: ConstructorParameters<typeof $Intersection<TValue>>): $VariadicCombination<TValue> {
415
+ return new $Intersection(...args)
416
+ }
417
+
418
+ /**
419
+ * Creates a reactive set that represents the union of multiple reactive sets.
420
+ *
421
+ * `$unionSets()` returns a derived `$Set<T>` that includes **all unique values**
422
+ * present in any of the provided subsets. Whenever any input set changes,
423
+ * the union is automatically updated to reflect the current collective contents.
424
+ *
425
+ * This is one of three core combination factories:
426
+ * - `$intersectionSets()` – keeps only values present in all subsets;
427
+ * - `$unionSets()` – merges all values from all subsets;
428
+ * - `$differenceSets()` – excludes values from a superset that appear in subsets.
429
+ *
430
+ * @template TValue The type of values within the sets.
431
+ *
432
+ * @param args Constructor arguments matching `$Union<T>`:
433
+ * - `{ subsets: Array<$Set<TValue>>; label?: string; enabled?: boolean }`
434
+ *
435
+ * @returns A reactive set representing the dynamic union of all input sets.
436
+ *
437
+ * @example
438
+ * ```ts
439
+ * const $visibleToAdmin = $set({ values: ['a', 'b'] })
440
+ * const $visibleToEditor = $set({ values: ['b', 'c'] })
441
+ *
442
+ * const $visibleToAnyone = $unionSets({
443
+ * subsets: [$visibleToAdmin, $visibleToEditor],
444
+ * label: 'Visible content'
445
+ * })
446
+ *
447
+ * console.log([...$visibleToAnyone]) // → ['a', 'b', 'c']
448
+ *
449
+ * $visibleToEditor.add('d')
450
+ * console.log([...$visibleToAnyone]) // → ['a', 'b', 'c', 'd']
451
+ * ```
452
+ *
453
+ * @see {@link $intersectionSets}
454
+ * @see {@link $differenceSets}
455
+ */
456
+ export function $unionSets<TValue>(...args: ConstructorParameters<typeof $Union<TValue>>): $VariadicCombination<TValue> {
457
+ return new $Union(...args)
458
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Thrown when a reactive value or collection is marked as `readonly`
3
+ * and a user attempts to mutate it directly.
4
+ *
5
+ * This typically happens when the data is derived from computed state
6
+ * and must not be altered externally.
7
+ */
8
+ export class ReadonlyAccessError extends Error {
9
+ constructor(message = "This reactive value is readonly and cannot be modified.") {
10
+ super(message)
11
+ this.name = "ReadonlyAccessError"
12
+ }
13
+ }