@oscarpalmer/mora 0.18.2 → 0.19.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.
@@ -1,7 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const batch = require("../batch.cjs");
4
+ const value_computed = require("../value/computed.cjs");
4
5
  const helpers_value = require("./value.cjs");
6
+ function getReactiveValueInProxy(reactive, mapped, key, isArray) {
7
+ let item = mapped.get(key);
8
+ if (item == null) {
9
+ item = value_computed.computed(() => {
10
+ const value = reactive.get();
11
+ return isArray ? value.at(key) : value[key];
12
+ });
13
+ mapped.set(key, item);
14
+ }
15
+ return item.get();
16
+ }
5
17
  function setProxyValue(proxy, value) {
6
18
  batch.startBatch();
7
19
  const proxyKeys = Object.keys(proxy);
@@ -39,5 +51,6 @@ function setValueInProxy(target, property, value, state, isArray, length) {
39
51
  }
40
52
  return true;
41
53
  }
54
+ exports.getReactiveValueInProxy = getReactiveValueInProxy;
42
55
  exports.setProxyValue = setProxyValue;
43
56
  exports.setValueInProxy = setValueInProxy;
@@ -1,5 +1,17 @@
1
1
  import { startBatch, stopBatch } from "../batch.js";
2
+ import { computed } from "../value/computed.js";
2
3
  import { emitValue } from "./value.js";
4
+ function getReactiveValueInProxy(reactive, mapped, key, isArray) {
5
+ let item = mapped.get(key);
6
+ if (item == null) {
7
+ item = computed(() => {
8
+ const value = reactive.get();
9
+ return isArray ? value.at(key) : value[key];
10
+ });
11
+ mapped.set(key, item);
12
+ }
13
+ return item.get();
14
+ }
3
15
  function setProxyValue(proxy, value) {
4
16
  startBatch();
5
17
  const proxyKeys = Object.keys(proxy);
@@ -38,6 +50,7 @@ function setValueInProxy(target, property, value, state, isArray, length) {
38
50
  return true;
39
51
  }
40
52
  export {
53
+ getReactiveValueInProxy,
41
54
  setProxyValue,
42
55
  setValueInProxy
43
56
  };
package/dist/mora.full.js CHANGED
@@ -278,6 +278,19 @@ function getValue(state) {
278
278
  return state.value;
279
279
  }
280
280
 
281
+ function getReactiveValueInProxy(reactive, mapped, key, isArray) {
282
+ let item = mapped.get(key);
283
+ if (item == null) {
284
+ item = computed(() => {
285
+ const value = reactive.get();
286
+ return isArray
287
+ ? value.at(key)
288
+ : value[key];
289
+ });
290
+ mapped.set(key, item);
291
+ }
292
+ return item.get();
293
+ }
281
294
  function setProxyValue(proxy, value) {
282
295
  startBatch();
283
296
  const proxyKeys = Object.keys(proxy);
@@ -352,6 +365,7 @@ function signal(value, options) {
352
365
  }
353
366
 
354
367
  class ReactiveArray extends Reactive {
368
+ #indiced = new Map();
355
369
  #size = signal(0);
356
370
  /**
357
371
  * The length of the array
@@ -378,22 +392,19 @@ class ReactiveArray extends Reactive {
378
392
  }), options);
379
393
  this.#size.set(value.length);
380
394
  }
381
- /**
382
- * Get an indexed item
383
- */
384
- at(index) {
385
- return this.get().at(index);
386
- }
387
395
  /**
388
396
  * Clear the array
389
397
  */
390
398
  clear() {
391
399
  this.length = 0;
392
400
  }
393
- /**
394
- * @inheritdoc
395
- */
396
- get() {
401
+ get(first) {
402
+ if (typeof first === 'number') {
403
+ return getReactiveValueInProxy(this, this.#indiced, first, true);
404
+ }
405
+ if (first === 'length') {
406
+ return this.length;
407
+ }
397
408
  return getValue(this.state);
398
409
  }
399
410
  /**
@@ -504,13 +515,16 @@ function isPlainObject(value) {
504
515
  }
505
516
 
506
517
  class Store extends Reactive {
518
+ #keyed = new Map();
507
519
  constructor(value, options) {
508
520
  super(storeName, new Proxy(value, {
509
521
  set: (target, property, value) => setValueInProxy(target, property, value, this.state, false),
510
522
  }), options);
511
523
  }
512
524
  get(key) {
513
- return isKey(key) ? this.state.value[key] : getValue(this.state);
525
+ return isKey(key)
526
+ ? getReactiveValueInProxy(this, this.#keyed, key, false)
527
+ : getValue(this.state);
514
528
  }
515
529
  peek(key) {
516
530
  return isKey(key) ? this.state.value[key] : { ...this.state.value };
@@ -5,7 +5,7 @@ var __typeError = (msg) => {
5
5
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
6
6
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
7
7
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
8
- var _size;
8
+ var _indiced, _size;
9
9
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
10
10
  const helpers_is = require("../helpers/is.cjs");
11
11
  const helpers_proxy = require("../helpers/proxy.cjs");
@@ -30,6 +30,7 @@ class ReactiveArray extends value_reactive.Reactive {
30
30
  }),
31
31
  options
32
32
  );
33
+ __privateAdd(this, _indiced, /* @__PURE__ */ new Map());
33
34
  __privateAdd(this, _size, value_signal.signal(0));
34
35
  __privateGet(this, _size).set(value.length);
35
36
  }
@@ -47,22 +48,19 @@ class ReactiveArray extends value_reactive.Reactive {
47
48
  this.get().length = value;
48
49
  }
49
50
  }
50
- /**
51
- * Get an indexed item
52
- */
53
- at(index) {
54
- return this.get().at(index);
55
- }
56
51
  /**
57
52
  * Clear the array
58
53
  */
59
54
  clear() {
60
55
  this.length = 0;
61
56
  }
62
- /**
63
- * @inheritdoc
64
- */
65
- get() {
57
+ get(first) {
58
+ if (typeof first === "number") {
59
+ return helpers_proxy.getReactiveValueInProxy(this, __privateGet(this, _indiced), first, true);
60
+ }
61
+ if (first === "length") {
62
+ return this.length;
63
+ }
66
64
  return helpers_value.getValue(this.state);
67
65
  }
68
66
  /**
@@ -124,6 +122,7 @@ class ReactiveArray extends value_reactive.Reactive {
124
122
  return this.state.value.unshift(...items);
125
123
  }
126
124
  }
125
+ _indiced = new WeakMap();
127
126
  _size = new WeakMap();
128
127
  function array(value, options) {
129
128
  return new ReactiveArray(Array.isArray(value) ? value : [], options);
@@ -4,9 +4,9 @@ var __typeError = (msg) => {
4
4
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
5
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
6
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
- var _size;
7
+ var _indiced, _size;
8
8
  import { arrayName } from "../helpers/is.js";
9
- import { setValueInProxy } from "../helpers/proxy.js";
9
+ import { setValueInProxy, getReactiveValueInProxy } from "../helpers/proxy.js";
10
10
  import { getValue, equalArrays, emitValue } from "../helpers/value.js";
11
11
  import { computed } from "./computed.js";
12
12
  import { Reactive } from "./reactive.js";
@@ -28,6 +28,7 @@ class ReactiveArray extends Reactive {
28
28
  }),
29
29
  options
30
30
  );
31
+ __privateAdd(this, _indiced, /* @__PURE__ */ new Map());
31
32
  __privateAdd(this, _size, signal(0));
32
33
  __privateGet(this, _size).set(value.length);
33
34
  }
@@ -45,22 +46,19 @@ class ReactiveArray extends Reactive {
45
46
  this.get().length = value;
46
47
  }
47
48
  }
48
- /**
49
- * Get an indexed item
50
- */
51
- at(index) {
52
- return this.get().at(index);
53
- }
54
49
  /**
55
50
  * Clear the array
56
51
  */
57
52
  clear() {
58
53
  this.length = 0;
59
54
  }
60
- /**
61
- * @inheritdoc
62
- */
63
- get() {
55
+ get(first) {
56
+ if (typeof first === "number") {
57
+ return getReactiveValueInProxy(this, __privateGet(this, _indiced), first, true);
58
+ }
59
+ if (first === "length") {
60
+ return this.length;
61
+ }
64
62
  return getValue(this.state);
65
63
  }
66
64
  /**
@@ -122,6 +120,7 @@ class ReactiveArray extends Reactive {
122
120
  return this.state.value.unshift(...items);
123
121
  }
124
122
  }
123
+ _indiced = new WeakMap();
125
124
  _size = new WeakMap();
126
125
  function array(value, options) {
127
126
  return new ReactiveArray(Array.isArray(value) ? value : [], options);
@@ -1,4 +1,11 @@
1
1
  "use strict";
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
6
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
7
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
8
+ var _keyed;
2
9
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
10
  const is = require("../node_modules/@oscarpalmer/atoms/dist/internal/is.cjs");
4
11
  const helpers_is = require("../helpers/is.cjs");
@@ -14,9 +21,10 @@ class Store extends value_reactive.Reactive {
14
21
  }),
15
22
  options
16
23
  );
24
+ __privateAdd(this, _keyed, /* @__PURE__ */ new Map());
17
25
  }
18
26
  get(key) {
19
- return is.isKey(key) ? this.state.value[key] : helpers_value.getValue(this.state);
27
+ return is.isKey(key) ? helpers_proxy.getReactiveValueInProxy(this, __privateGet(this, _keyed), key, false) : helpers_value.getValue(this.state);
20
28
  }
21
29
  peek(key) {
22
30
  return is.isKey(key) ? this.state.value[key] : { ...this.state.value };
@@ -29,6 +37,7 @@ class Store extends value_reactive.Reactive {
29
37
  }
30
38
  }
31
39
  }
40
+ _keyed = new WeakMap();
32
41
  function store(value, options) {
33
42
  return new Store(is.isPlainObject(value) ? value : {}, options);
34
43
  }
@@ -1,6 +1,13 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var _keyed;
1
8
  import { isPlainObject, isKey } from "../node_modules/@oscarpalmer/atoms/dist/internal/is.js";
2
9
  import { storeName } from "../helpers/is.js";
3
- import { setValueInProxy, setProxyValue } from "../helpers/proxy.js";
10
+ import { setValueInProxy, getReactiveValueInProxy, setProxyValue } from "../helpers/proxy.js";
4
11
  import { getValue } from "../helpers/value.js";
5
12
  import { Reactive } from "./reactive.js";
6
13
  class Store extends Reactive {
@@ -12,9 +19,10 @@ class Store extends Reactive {
12
19
  }),
13
20
  options
14
21
  );
22
+ __privateAdd(this, _keyed, /* @__PURE__ */ new Map());
15
23
  }
16
24
  get(key) {
17
- return isKey(key) ? this.state.value[key] : getValue(this.state);
25
+ return isKey(key) ? getReactiveValueInProxy(this, __privateGet(this, _keyed), key, false) : getValue(this.state);
18
26
  }
19
27
  peek(key) {
20
28
  return isKey(key) ? this.state.value[key] : { ...this.state.value };
@@ -27,6 +35,7 @@ class Store extends Reactive {
27
35
  }
28
36
  }
29
37
  }
38
+ _keyed = new WeakMap();
30
39
  function store(value, options) {
31
40
  return new Store(isPlainObject(value) ? value : {}, options);
32
41
  }
package/package.json CHANGED
@@ -54,5 +54,5 @@
54
54
  },
55
55
  "type": "module",
56
56
  "types": "./types/index.d.ts",
57
- "version": "0.18.2"
57
+ "version": "0.19.0"
58
58
  }
@@ -1,9 +1,53 @@
1
- import type {ArrayOrPlainObject, PlainObject} from '@oscarpalmer/atoms/models';
1
+ import type {
2
+ ArrayOrPlainObject,
3
+ Key,
4
+ PlainObject,
5
+ } from '@oscarpalmer/atoms/models';
2
6
  import {startBatch, stopBatch} from '../batch';
7
+ import type {ReactiveArray} from '../value/array';
8
+ import {type Computed, computed} from '../value/computed';
3
9
  import type {ReactiveState} from '../value/reactive';
4
10
  import type {Signal} from '../value/signal';
11
+ import type {Store} from '../value/store';
5
12
  import {emitValue} from './value';
6
13
 
14
+ export function getReactiveValueInProxy<Value>(
15
+ array: ReactiveArray<Value>,
16
+ mapped: Map<Key, Computed<unknown>>,
17
+ index: number,
18
+ isArray: true,
19
+ ): unknown;
20
+
21
+ export function getReactiveValueInProxy<Value extends PlainObject>(
22
+ store: Store<Value>,
23
+ mapped: Map<Key, Computed<unknown>>,
24
+ key: Key,
25
+ isArray: false,
26
+ ): unknown;
27
+
28
+ export function getReactiveValueInProxy(
29
+ reactive: ReactiveArray<unknown> | Store<PlainObject>,
30
+ mapped: Map<Key, Computed<unknown>>,
31
+ key: Key,
32
+ isArray: boolean,
33
+ ): unknown {
34
+ let item = mapped.get(key);
35
+
36
+ if (item == null) {
37
+ item = computed(() => {
38
+ const value = reactive.get();
39
+
40
+ return isArray
41
+ ? (value as unknown[]).at(key as number)
42
+ : (value as PlainObject)[key];
43
+ }) as Computed<unknown>;
44
+
45
+ mapped.set(key, item);
46
+ }
47
+
48
+ return item.get();
49
+ }
50
+
7
51
  export function setProxyValue(
8
52
  proxy: ArrayOrPlainObject,
9
53
  value: ArrayOrPlainObject,
package/src/index.ts CHANGED
@@ -12,3 +12,4 @@ export {computed, type Computed} from './value/computed';
12
12
  export type {Reactive} from './value/reactive';
13
13
  export {signal, type Signal} from './value/signal';
14
14
  export {store, type Store} from './value/store';
15
+
@@ -1,11 +1,12 @@
1
1
  import {arrayName} from '../helpers/is';
2
- import {setValueInProxy} from '../helpers/proxy';
2
+ import {getReactiveValueInProxy, setValueInProxy} from '../helpers/proxy';
3
3
  import {emitValue, equalArrays, getValue} from '../helpers/value';
4
4
  import {type Computed, computed} from './computed';
5
5
  import {Reactive, type ReactiveOptions, type ReactiveState} from './reactive';
6
6
  import {type Signal, signal} from './signal';
7
7
 
8
8
  export class ReactiveArray<Item> extends Reactive<Item[], Item> {
9
+ #indiced = new Map<number, Computed<unknown>>();
9
10
  #size = signal(0);
10
11
 
11
12
  /**
@@ -52,13 +53,6 @@ export class ReactiveArray<Item> extends Reactive<Item[], Item> {
52
53
  this.#size.set(value.length);
53
54
  }
54
55
 
55
- /**
56
- * Get an indexed item
57
- */
58
- at(index: number): Item | undefined {
59
- return this.get().at(index);
60
- }
61
-
62
56
  /**
63
57
  * Clear the array
64
58
  */
@@ -69,7 +63,21 @@ export class ReactiveArray<Item> extends Reactive<Item[], Item> {
69
63
  /**
70
64
  * @inheritdoc
71
65
  */
72
- get(): Item[] {
66
+ get(): Item[];
67
+
68
+ get(index: number): Item | undefined;
69
+
70
+ get(property: 'length'): number;
71
+
72
+ get(first?: unknown): unknown {
73
+ if (typeof first === 'number') {
74
+ return getReactiveValueInProxy(this, this.#indiced, first, true);
75
+ }
76
+
77
+ if (first === 'length') {
78
+ return this.length;
79
+ }
80
+
73
81
  return getValue(this.state);
74
82
  }
75
83
 
@@ -1,11 +1,18 @@
1
1
  import {isKey, isPlainObject} from '@oscarpalmer/atoms/is';
2
2
  import type {Key, PlainObject} from '@oscarpalmer/atoms/models';
3
3
  import {storeName} from '../helpers/is';
4
- import {setProxyValue, setValueInProxy} from '../helpers/proxy';
4
+ import {
5
+ getReactiveValueInProxy,
6
+ setProxyValue,
7
+ setValueInProxy,
8
+ } from '../helpers/proxy';
5
9
  import {getValue} from '../helpers/value';
10
+ import type {Computed} from './computed';
6
11
  import {Reactive, type ReactiveOptions} from './reactive';
7
12
 
8
13
  export class Store<Value extends PlainObject> extends Reactive<Value, Value> {
14
+ #keyed = new Map<Key, Computed<unknown>>();
15
+
9
16
  constructor(value: Value, options?: ReactiveOptions<Value>) {
10
17
  super(
11
18
  storeName,
@@ -33,7 +40,9 @@ export class Store<Value extends PlainObject> extends Reactive<Value, Value> {
33
40
  get(key: Key): unknown;
34
41
 
35
42
  get(key?: unknown): unknown {
36
- return isKey(key) ? this.state.value[key] : getValue(this.state);
43
+ return isKey(key)
44
+ ? getReactiveValueInProxy(this, this.#keyed, key, false)
45
+ : getValue(this.state);
37
46
  }
38
47
 
39
48
  /**
@@ -83,10 +83,6 @@ declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
83
83
  */
84
84
  set length(value: number);
85
85
  constructor(value: Item[], options?: ReactiveOptions<Item>);
86
- /**
87
- * Get an indexed item
88
- */
89
- at(index: number): Item | undefined;
90
86
  /**
91
87
  * Clear the array
92
88
  */
@@ -95,6 +91,8 @@ declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
95
91
  * @inheritdoc
96
92
  */
97
93
  get(): Item[];
94
+ get(index: number): Item | undefined;
95
+ get(property: "length"): number;
98
96
  /**
99
97
  * Create a computed, filtered array
100
98
  */
@@ -160,6 +158,7 @@ declare class Signal<Value> extends Reactive<Value> {
160
158
  update(callback: (value: Value) => Value): void;
161
159
  }
162
160
  declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
161
+ #private;
163
162
  constructor(value: Value, options?: ReactiveOptions<Value>);
164
163
  /**
165
164
  * @inheritdoc
@@ -5,6 +5,14 @@
5
5
  */
6
6
  export type ArrayOrPlainObject = unknown[] | Record<PropertyKey, unknown>;
7
7
  export type GenericCallback = (...args: any[]) => any;
8
+ /**
9
+ * A useful key type
10
+ */
11
+ export type Key = number | string;
12
+ /**
13
+ * A generic object
14
+ */
15
+ export type PlainObject = Record<PropertyKey, unknown>;
8
16
  declare class Effect {
9
17
  private readonly $mora;
10
18
  private readonly state;
@@ -68,6 +76,76 @@ declare class Subscription<Value> {
68
76
  * Unsubscribe from changes
69
77
  */
70
78
  export type Unsubscribe = () => void;
79
+ declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
80
+ #private;
81
+ /**
82
+ * The length of the array
83
+ */
84
+ get length(): number;
85
+ /**
86
+ * Set the length of the array
87
+ */
88
+ set length(value: number);
89
+ constructor(value: Item[], options?: ReactiveOptions<Item>);
90
+ /**
91
+ * Clear the array
92
+ */
93
+ clear(): void;
94
+ /**
95
+ * @inheritdoc
96
+ */
97
+ get(): Item[];
98
+ get(index: number): Item | undefined;
99
+ get(property: "length"): number;
100
+ /**
101
+ * Create a computed, filtered array
102
+ */
103
+ filter(callback: (item: Item, index: number, array: Item[]) => boolean): Computed<Item[]>;
104
+ /**
105
+ * Create a computed, mapped array
106
+ */
107
+ map<Mapped>(callback: (item: Item, index: number, array: Item[]) => Mapped): Computed<Mapped[]>;
108
+ /**
109
+ * @inheritdoc
110
+ */
111
+ peek(): Item[];
112
+ /**
113
+ * Get the length of the array _(without reactivity)_
114
+ */
115
+ peek(length: true): number;
116
+ /**
117
+ * Remove and return the last item of the array
118
+ */
119
+ pop(): Item | undefined;
120
+ /**
121
+ * Add items to the end of the array
122
+ */
123
+ push(...items: Item[]): number;
124
+ /**
125
+ * Set the value
126
+ */
127
+ set(value: Item[]): void;
128
+ /**
129
+ * Set the value at an index
130
+ */
131
+ set(index: number, value: Item): void;
132
+ /**
133
+ * Set the length of the array
134
+ */
135
+ set(property: "length", value: number): void;
136
+ /**
137
+ * Remove and return the first item of the array
138
+ */
139
+ shift(): Item | undefined;
140
+ /**
141
+ * Remove and return items from the array _(and optionally add new items)_
142
+ */
143
+ splice(from: number, to?: number, ...items: Item[]): Item[];
144
+ /**
145
+ * Add items to the beginning of the array
146
+ */
147
+ unshift(...items: Item[]): number;
148
+ }
71
149
  declare class Signal<Value> extends Reactive<Value> {
72
150
  constructor(value: Value, options?: ReactiveOptions<Value>);
73
151
  /**
@@ -83,6 +161,48 @@ declare class Signal<Value> extends Reactive<Value> {
83
161
  */
84
162
  update(callback: (value: Value) => Value): void;
85
163
  }
164
+ declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
165
+ #private;
166
+ constructor(value: Value, options?: ReactiveOptions<Value>);
167
+ /**
168
+ * @inheritdoc
169
+ */
170
+ get(): Value;
171
+ /**
172
+ * Get a value by key _(without reactivity)_
173
+ */
174
+ get(key: keyof Value): Value[keyof Value];
175
+ /**
176
+ * Get a value by key _(without reactivity)_
177
+ */
178
+ get(key: Key): unknown;
179
+ /**
180
+ * Get the value _(without reactivity)_
181
+ */
182
+ peek(): Value;
183
+ /**
184
+ * Get a value by key _(without reactivity)_
185
+ */
186
+ peek(key: keyof Value): Value[keyof Value];
187
+ /**
188
+ * Get a value by key _(without reactivity)_
189
+ */
190
+ peek(key: Key): unknown;
191
+ /**
192
+ * Set the value
193
+ */
194
+ set(value?: Value): void;
195
+ /**
196
+ * Set a value by key
197
+ */
198
+ set(key: keyof Value, value: Value[keyof Value]): void;
199
+ /**
200
+ * Set a value by key
201
+ */
202
+ set(key: Key, value: unknown): void;
203
+ }
204
+ export declare function getReactiveValueInProxy<Value>(array: ReactiveArray<Value>, mapped: Map<Key, Computed<unknown>>, index: number, isArray: true): unknown;
205
+ export declare function getReactiveValueInProxy<Value extends PlainObject>(store: Store<Value>, mapped: Map<Key, Computed<unknown>>, key: Key, isArray: false): unknown;
86
206
  export declare function setProxyValue(proxy: ArrayOrPlainObject, value: ArrayOrPlainObject): void;
87
207
  export declare function setValueInProxy<Value extends ArrayOrPlainObject, Equal>(target: Value, property: PropertyKey, value: unknown, state: ReactiveState<Value, Equal>, isArray: boolean, length?: Signal<number>): boolean;
88
208
 
@@ -1,5 +1,10 @@
1
- import type { ArrayOrPlainObject } from '@oscarpalmer/atoms/models';
1
+ import type { ArrayOrPlainObject, Key, PlainObject } from '@oscarpalmer/atoms/models';
2
+ import type { ReactiveArray } from '../value/array';
3
+ import { type Computed } from '../value/computed';
2
4
  import type { ReactiveState } from '../value/reactive';
3
5
  import type { Signal } from '../value/signal';
6
+ import type { Store } from '../value/store';
7
+ export declare function getReactiveValueInProxy<Value>(array: ReactiveArray<Value>, mapped: Map<Key, Computed<unknown>>, index: number, isArray: true): unknown;
8
+ export declare function getReactiveValueInProxy<Value extends PlainObject>(store: Store<Value>, mapped: Map<Key, Computed<unknown>>, key: Key, isArray: false): unknown;
4
9
  export declare function setProxyValue(proxy: ArrayOrPlainObject, value: ArrayOrPlainObject): void;
5
10
  export declare function setValueInProxy<Value extends ArrayOrPlainObject, Equal>(target: Value, property: PropertyKey, value: unknown, state: ReactiveState<Value, Equal>, isArray: boolean, length?: Signal<number>): boolean;
package/types/index.d.cts CHANGED
@@ -99,10 +99,6 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
99
99
  */
100
100
  set length(value: number);
101
101
  constructor(value: Item[], options?: ReactiveOptions<Item>);
102
- /**
103
- * Get an indexed item
104
- */
105
- at(index: number): Item | undefined;
106
102
  /**
107
103
  * Clear the array
108
104
  */
@@ -111,6 +107,8 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
111
107
  * @inheritdoc
112
108
  */
113
109
  get(): Item[];
110
+ get(index: number): Item | undefined;
111
+ get(property: "length"): number;
114
112
  /**
115
113
  * Create a computed, filtered array
116
114
  */
@@ -184,6 +182,7 @@ export declare class Signal<Value> extends Reactive<Value> {
184
182
  */
185
183
  export declare function signal<Value>(value: Value, options?: ReactiveOptions<Value>): Signal<Value>;
186
184
  export declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
185
+ #private;
187
186
  constructor(value: Value, options?: ReactiveOptions<Value>);
188
187
  /**
189
188
  * @inheritdoc
@@ -75,10 +75,6 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
75
75
  */
76
76
  set length(value: number);
77
77
  constructor(value: Item[], options?: ReactiveOptions<Item>);
78
- /**
79
- * Get an indexed item
80
- */
81
- at(index: number): Item | undefined;
82
78
  /**
83
79
  * Clear the array
84
80
  */
@@ -87,6 +83,8 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
87
83
  * @inheritdoc
88
84
  */
89
85
  get(): Item[];
86
+ get(index: number): Item | undefined;
87
+ get(property: "length"): number;
90
88
  /**
91
89
  * Create a computed, filtered array
92
90
  */
@@ -11,10 +11,6 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
11
11
  */
12
12
  set length(value: number);
13
13
  constructor(value: Item[], options?: ReactiveOptions<Item>);
14
- /**
15
- * Get an indexed item
16
- */
17
- at(index: number): Item | undefined;
18
14
  /**
19
15
  * Clear the array
20
16
  */
@@ -23,6 +19,8 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
23
19
  * @inheritdoc
24
20
  */
25
21
  get(): Item[];
22
+ get(index: number): Item | undefined;
23
+ get(property: 'length'): number;
26
24
  /**
27
25
  * Create a computed, filtered array
28
26
  */
@@ -73,6 +73,7 @@ declare class Subscription<Value> {
73
73
  */
74
74
  export type Unsubscribe = () => void;
75
75
  export declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
76
+ #private;
76
77
  constructor(value: Value, options?: ReactiveOptions<Value>);
77
78
  /**
78
79
  * @inheritdoc
@@ -1,6 +1,7 @@
1
1
  import type { Key, PlainObject } from '@oscarpalmer/atoms/models';
2
2
  import { Reactive, type ReactiveOptions } from './reactive';
3
3
  export declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
4
+ #private;
4
5
  constructor(value: Value, options?: ReactiveOptions<Value>);
5
6
  /**
6
7
  * @inheritdoc