@oscarpalmer/mora 0.17.0 → 0.18.1

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 (40) hide show
  1. package/dist/helpers/is.cjs +7 -1
  2. package/dist/helpers/is.js +8 -2
  3. package/dist/helpers/proxy.cjs +43 -0
  4. package/dist/helpers/proxy.js +43 -0
  5. package/dist/helpers/value.cjs +20 -24
  6. package/dist/helpers/value.js +20 -24
  7. package/dist/index.cjs +2 -0
  8. package/dist/index.js +3 -1
  9. package/dist/mora.full.js +107 -43
  10. package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.cjs +17 -0
  11. package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.js +17 -0
  12. package/dist/value/array.cjs +10 -16
  13. package/dist/value/array.js +11 -17
  14. package/dist/value/signal.cjs +1 -1
  15. package/dist/value/signal.js +2 -2
  16. package/dist/value/store.cjs +36 -0
  17. package/dist/value/store.js +36 -0
  18. package/package.json +1 -1
  19. package/src/helpers/is.ts +7 -1
  20. package/src/helpers/proxy.ts +71 -0
  21. package/src/helpers/value.ts +23 -33
  22. package/src/index.ts +1 -0
  23. package/src/value/array.ts +11 -30
  24. package/src/value/signal.ts +2 -2
  25. package/src/value/store.ts +90 -0
  26. package/types/helpers/is.d.ts +3 -0
  27. package/types/helpers/proxy.d.ts +5 -0
  28. package/types/helpers/value.d.ts +1 -2
  29. package/types/index.d.ts +1 -0
  30. package/types/value/store.d.ts +45 -0
  31. package/types/batch.d.cts +0 -79
  32. package/types/effect.d.cts +0 -16
  33. package/types/helpers/is.d.cts +0 -176
  34. package/types/helpers/value.d.cts +0 -72
  35. package/types/index.d.cts +0 -196
  36. package/types/subscription.d.cts +0 -71
  37. package/types/value/array.d.cts +0 -144
  38. package/types/value/computed.d.cts +0 -81
  39. package/types/value/reactive.d.cts +0 -68
  40. package/types/value/signal.d.cts +0 -87
@@ -18,11 +18,15 @@ function isReactive(value) {
18
18
  function isSignal(value) {
19
19
  return isMora(value, signalName);
20
20
  }
21
+ function isStore(value) {
22
+ return isMora(value, storeName);
23
+ }
21
24
  const arrayName = "array";
22
25
  const computedName = "computed";
23
26
  const effectName = "effect";
24
27
  const signalName = "signal";
25
- const reactiveNames = /* @__PURE__ */ new Set([arrayName, computedName, signalName]);
28
+ const storeName = "store";
29
+ const reactiveNames = /* @__PURE__ */ new Set([arrayName, computedName, signalName, storeName]);
26
30
  exports.arrayName = arrayName;
27
31
  exports.computedName = computedName;
28
32
  exports.effectName = effectName;
@@ -31,4 +35,6 @@ exports.isComputed = isComputed;
31
35
  exports.isEffect = isEffect;
32
36
  exports.isReactive = isReactive;
33
37
  exports.isSignal = isSignal;
38
+ exports.isStore = isStore;
34
39
  exports.signalName = signalName;
40
+ exports.storeName = storeName;
@@ -16,11 +16,15 @@ function isReactive(value) {
16
16
  function isSignal(value) {
17
17
  return isMora(value, signalName);
18
18
  }
19
+ function isStore(value) {
20
+ return isMora(value, storeName);
21
+ }
19
22
  const arrayName = "array";
20
23
  const computedName = "computed";
21
24
  const effectName = "effect";
22
25
  const signalName = "signal";
23
- const reactiveNames = /* @__PURE__ */ new Set([arrayName, computedName, signalName]);
26
+ const storeName = "store";
27
+ const reactiveNames = /* @__PURE__ */ new Set([arrayName, computedName, signalName, storeName]);
24
28
  export {
25
29
  arrayName,
26
30
  computedName,
@@ -30,5 +34,7 @@ export {
30
34
  isEffect,
31
35
  isReactive,
32
36
  isSignal,
33
- signalName
37
+ isStore,
38
+ signalName,
39
+ storeName
34
40
  };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const batch = require("../batch.cjs");
4
+ const helpers_value = require("./value.cjs");
5
+ function setProxyValue(proxy, value) {
6
+ batch.startBatch();
7
+ const proxyKeys = Object.keys(proxy);
8
+ const valueKeys = Object.keys(value);
9
+ let { length } = proxyKeys;
10
+ for (let index = 0; index < length; index += 1) {
11
+ const key = proxyKeys[index];
12
+ proxy[key] = valueKeys.includes(key) ? value[key] : void 0;
13
+ }
14
+ length = valueKeys.length;
15
+ for (let index = 0; index < length; index += 1) {
16
+ const key = valueKeys[index];
17
+ if (!proxyKeys.includes(key)) {
18
+ const keyedValue = value[key];
19
+ proxy[key] = keyedValue;
20
+ }
21
+ }
22
+ batch.stopBatch();
23
+ }
24
+ function setValueInProxy(target, property, value, state, isArray, length) {
25
+ if (isArray) {
26
+ const isIndex = !Number.isNaN(Number(property));
27
+ const isLength = property === "length";
28
+ if (!isIndex && !isLength) {
29
+ return Reflect.set(target, property, value);
30
+ }
31
+ }
32
+ const previous = Reflect.get(target, property);
33
+ if (!state.equal(previous, value)) {
34
+ Reflect.set(target, property, value);
35
+ helpers_value.emitValue(state);
36
+ if (isArray) {
37
+ length == null ? void 0 : length.set(target.length);
38
+ }
39
+ }
40
+ return true;
41
+ }
42
+ exports.setProxyValue = setProxyValue;
43
+ exports.setValueInProxy = setValueInProxy;
@@ -0,0 +1,43 @@
1
+ import { startBatch, stopBatch } from "../batch.js";
2
+ import { emitValue } from "./value.js";
3
+ function setProxyValue(proxy, value) {
4
+ startBatch();
5
+ const proxyKeys = Object.keys(proxy);
6
+ const valueKeys = Object.keys(value);
7
+ let { length } = proxyKeys;
8
+ for (let index = 0; index < length; index += 1) {
9
+ const key = proxyKeys[index];
10
+ proxy[key] = valueKeys.includes(key) ? value[key] : void 0;
11
+ }
12
+ length = valueKeys.length;
13
+ for (let index = 0; index < length; index += 1) {
14
+ const key = valueKeys[index];
15
+ if (!proxyKeys.includes(key)) {
16
+ const keyedValue = value[key];
17
+ proxy[key] = keyedValue;
18
+ }
19
+ }
20
+ stopBatch();
21
+ }
22
+ function setValueInProxy(target, property, value, state, isArray, length) {
23
+ if (isArray) {
24
+ const isIndex = !Number.isNaN(Number(property));
25
+ const isLength = property === "length";
26
+ if (!isIndex && !isLength) {
27
+ return Reflect.set(target, property, value);
28
+ }
29
+ }
30
+ const previous = Reflect.get(target, property);
31
+ if (!state.equal(previous, value)) {
32
+ Reflect.set(target, property, value);
33
+ emitValue(state);
34
+ if (isArray) {
35
+ length == null ? void 0 : length.set(target.length);
36
+ }
37
+ }
38
+ return true;
39
+ }
40
+ export {
41
+ setProxyValue,
42
+ setValueInProxy
43
+ };
@@ -3,10 +3,24 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const batch = require("../batch.cjs");
4
4
  const effect = require("../effect.cjs");
5
5
  const value_computed = require("../value/computed.cjs");
6
- function differentArrays(state, first, second) {
6
+ function emitValue(state) {
7
+ for (const computed of state.computeds) {
8
+ computed.effect.dirty = true;
9
+ }
10
+ for (const effect2 of state.effects) {
11
+ batch.batchedHandlers.add(effect2);
12
+ }
13
+ for (const [, subscription] of state.subscriptions) {
14
+ batch.batchedHandlers.add(subscription);
15
+ }
16
+ if (batch.batchDepth === 0) {
17
+ batch.flushHandlers();
18
+ }
19
+ }
20
+ function equalArrays(state, first, second) {
7
21
  let { length } = first;
8
22
  if (length !== second.length) {
9
- return true;
23
+ return false;
10
24
  }
11
25
  let offset = 0;
12
26
  if (length >= 100) {
@@ -14,34 +28,17 @@ function differentArrays(state, first, second) {
14
28
  offset = offset > 25 ? 25 : offset;
15
29
  for (let index = 0; index < offset; index += 1) {
16
30
  if (!state.equal(first[index], second[index])) {
17
- return true;
31
+ return false;
18
32
  }
19
33
  }
20
34
  }
21
35
  length -= offset;
22
36
  for (let index = offset; index < length; index += 1) {
23
37
  if (!state.equal(first[index], second[index])) {
24
- return true;
38
+ return false;
25
39
  }
26
40
  }
27
- return false;
28
- }
29
- function differentValues(state, first, second) {
30
- return Array.isArray(first) && Array.isArray(second) ? differentArrays(state, first, second) : !state.equal(first, second);
31
- }
32
- function emitValue(state) {
33
- for (const computed of state.computeds) {
34
- computed.effect.dirty = true;
35
- }
36
- for (const effect2 of state.effects) {
37
- batch.batchedHandlers.add(effect2);
38
- }
39
- for (const [, subscription] of state.subscriptions) {
40
- batch.batchedHandlers.add(subscription);
41
- }
42
- if (batch.batchDepth === 0) {
43
- batch.flushHandlers();
44
- }
41
+ return true;
45
42
  }
46
43
  function getValue(state) {
47
44
  if (value_computed.activeComputed != null) {
@@ -52,7 +49,6 @@ function getValue(state) {
52
49
  }
53
50
  return state.value;
54
51
  }
55
- exports.differentArrays = differentArrays;
56
- exports.differentValues = differentValues;
57
52
  exports.emitValue = emitValue;
53
+ exports.equalArrays = equalArrays;
58
54
  exports.getValue = getValue;
@@ -1,10 +1,24 @@
1
1
  import { batchedHandlers, batchDepth, flushHandlers } from "../batch.js";
2
2
  import { activeEffect } from "../effect.js";
3
3
  import { activeComputed } from "../value/computed.js";
4
- function differentArrays(state, first, second) {
4
+ function emitValue(state) {
5
+ for (const computed of state.computeds) {
6
+ computed.effect.dirty = true;
7
+ }
8
+ for (const effect of state.effects) {
9
+ batchedHandlers.add(effect);
10
+ }
11
+ for (const [, subscription] of state.subscriptions) {
12
+ batchedHandlers.add(subscription);
13
+ }
14
+ if (batchDepth === 0) {
15
+ flushHandlers();
16
+ }
17
+ }
18
+ function equalArrays(state, first, second) {
5
19
  let { length } = first;
6
20
  if (length !== second.length) {
7
- return true;
21
+ return false;
8
22
  }
9
23
  let offset = 0;
10
24
  if (length >= 100) {
@@ -12,34 +26,17 @@ function differentArrays(state, first, second) {
12
26
  offset = offset > 25 ? 25 : offset;
13
27
  for (let index = 0; index < offset; index += 1) {
14
28
  if (!state.equal(first[index], second[index])) {
15
- return true;
29
+ return false;
16
30
  }
17
31
  }
18
32
  }
19
33
  length -= offset;
20
34
  for (let index = offset; index < length; index += 1) {
21
35
  if (!state.equal(first[index], second[index])) {
22
- return true;
36
+ return false;
23
37
  }
24
38
  }
25
- return false;
26
- }
27
- function differentValues(state, first, second) {
28
- return Array.isArray(first) && Array.isArray(second) ? differentArrays(state, first, second) : !state.equal(first, second);
29
- }
30
- function emitValue(state) {
31
- for (const computed of state.computeds) {
32
- computed.effect.dirty = true;
33
- }
34
- for (const effect of state.effects) {
35
- batchedHandlers.add(effect);
36
- }
37
- for (const [, subscription] of state.subscriptions) {
38
- batchedHandlers.add(subscription);
39
- }
40
- if (batchDepth === 0) {
41
- flushHandlers();
42
- }
39
+ return true;
43
40
  }
44
41
  function getValue(state) {
45
42
  if (activeComputed != null) {
@@ -51,8 +48,7 @@ function getValue(state) {
51
48
  return state.value;
52
49
  }
53
50
  export {
54
- differentArrays,
55
- differentValues,
56
51
  emitValue,
52
+ equalArrays,
57
53
  getValue
58
54
  };
package/dist/index.cjs CHANGED
@@ -6,6 +6,7 @@ const helpers_is = require("./helpers/is.cjs");
6
6
  const value_array = require("./value/array.cjs");
7
7
  const value_computed = require("./value/computed.cjs");
8
8
  const value_signal = require("./value/signal.cjs");
9
+ const value_store = require("./value/store.cjs");
9
10
  exports.startBatch = batch.startBatch;
10
11
  exports.stopBatch = batch.stopBatch;
11
12
  exports.effect = effect.effect;
@@ -17,3 +18,4 @@ exports.isSignal = helpers_is.isSignal;
17
18
  exports.array = value_array.array;
18
19
  exports.computed = value_computed.computed;
19
20
  exports.signal = value_signal.signal;
21
+ exports.store = value_store.store;
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import { isArray, isComputed, isEffect, isReactive, isSignal } from "./helpers/i
4
4
  import { array } from "./value/array.js";
5
5
  import { computed } from "./value/computed.js";
6
6
  import { signal } from "./value/signal.js";
7
+ import { store } from "./value/store.js";
7
8
  export {
8
9
  array,
9
10
  computed,
@@ -15,5 +16,6 @@ export {
15
16
  isSignal,
16
17
  signal,
17
18
  startBatch,
18
- stopBatch
19
+ stopBatch,
20
+ store
19
21
  };
package/dist/mora.full.js CHANGED
@@ -37,7 +37,8 @@ const arrayName = 'array';
37
37
  const computedName = 'computed';
38
38
  const effectName = 'effect';
39
39
  const signalName = 'signal';
40
- const reactiveNames = new Set([arrayName, computedName, signalName]);
40
+ const storeName = 'store';
41
+ const reactiveNames = new Set([arrayName, computedName, signalName, storeName]);
41
42
 
42
43
  class Effect {
43
44
  constructor(callback) {
@@ -230,10 +231,24 @@ function computed(callback, options) {
230
231
  return new Computed(callback, options);
231
232
  }
232
233
 
233
- function differentArrays(state, first, second) {
234
+ function emitValue(state) {
235
+ for (const computed of state.computeds) {
236
+ computed.effect.dirty = true;
237
+ }
238
+ for (const effect of state.effects) {
239
+ batchedHandlers.add(effect);
240
+ }
241
+ for (const [, subscription] of state.subscriptions) {
242
+ batchedHandlers.add(subscription);
243
+ }
244
+ if (batchDepth === 0) {
245
+ flushHandlers();
246
+ }
247
+ }
248
+ function equalArrays(state, first, second) {
234
249
  let { length } = first;
235
250
  if (length !== second.length) {
236
- return true;
251
+ return false;
237
252
  }
238
253
  let offset = 0;
239
254
  if (length >= 100) {
@@ -241,36 +256,17 @@ function differentArrays(state, first, second) {
241
256
  offset = offset > 25 ? 25 : offset;
242
257
  for (let index = 0; index < offset; index += 1) {
243
258
  if (!state.equal(first[index], second[index])) {
244
- return true;
259
+ return false;
245
260
  }
246
261
  }
247
262
  }
248
263
  length -= offset;
249
264
  for (let index = offset; index < length; index += 1) {
250
265
  if (!state.equal(first[index], second[index])) {
251
- return true;
266
+ return false;
252
267
  }
253
268
  }
254
- return false;
255
- }
256
- function differentValues(state, first, second) {
257
- return Array.isArray(first) && Array.isArray(second)
258
- ? differentArrays(state, first, second)
259
- : !state.equal(first, second);
260
- }
261
- function emitValue(state) {
262
- for (const computed of state.computeds) {
263
- computed.effect.dirty = true;
264
- }
265
- for (const effect of state.effects) {
266
- batchedHandlers.add(effect);
267
- }
268
- for (const [, subscription] of state.subscriptions) {
269
- batchedHandlers.add(subscription);
270
- }
271
- if (batchDepth === 0) {
272
- flushHandlers();
273
- }
269
+ return true;
274
270
  }
275
271
  function getValue(state) {
276
272
  if (activeComputed != null) {
@@ -282,6 +278,46 @@ function getValue(state) {
282
278
  return state.value;
283
279
  }
284
280
 
281
+ function setProxyValue(proxy, value) {
282
+ startBatch();
283
+ const proxyKeys = Object.keys(proxy);
284
+ const valueKeys = Object.keys(value);
285
+ let { length } = proxyKeys;
286
+ for (let index = 0; index < length; index += 1) {
287
+ const key = proxyKeys[index];
288
+ proxy[key] = valueKeys.includes(key)
289
+ ? value[key]
290
+ : undefined;
291
+ }
292
+ length = valueKeys.length;
293
+ for (let index = 0; index < length; index += 1) {
294
+ const key = valueKeys[index];
295
+ if (!proxyKeys.includes(key)) {
296
+ const keyedValue = value[key];
297
+ proxy[key] = keyedValue;
298
+ }
299
+ }
300
+ stopBatch();
301
+ }
302
+ function setValueInProxy(target, property, value, state, isArray, length) {
303
+ if (isArray) {
304
+ const isIndex = !Number.isNaN(Number(property));
305
+ const isLength = property === 'length';
306
+ if (!isIndex && !isLength) {
307
+ return Reflect.set(target, property, value);
308
+ }
309
+ }
310
+ const previous = Reflect.get(target, property);
311
+ if (!state.equal(previous, value)) {
312
+ Reflect.set(target, property, value);
313
+ emitValue(state);
314
+ if (isArray) {
315
+ length?.set(target.length);
316
+ }
317
+ }
318
+ return true;
319
+ }
320
+
285
321
  class Signal extends Reactive {
286
322
  constructor(value, options) {
287
323
  super(signalName, value, options);
@@ -296,7 +332,7 @@ class Signal extends Reactive {
296
332
  * Set the value
297
333
  */
298
334
  set(value) {
299
- if (differentValues(this.state, this.state.value, value)) {
335
+ if (!this.state.equal(this.state.value, value)) {
300
336
  this.state.value = value;
301
337
  emitValue(this.state);
302
338
  }
@@ -338,7 +374,7 @@ class ReactiveArray extends Reactive {
338
374
  get: (target, property) => updateMethods.has(property)
339
375
  ? updateArray(property, target, this.state, this.#size)
340
376
  : Reflect.get(target, property),
341
- set: (target, property, value) => setValue(target, property, value, this.state, this.#size),
377
+ set: (target, property, value) => setValueInProxy(target, property, value, this.state, true, this.#size),
342
378
  }), options);
343
379
  this.#size.set(value.length);
344
380
  }
@@ -423,20 +459,6 @@ class ReactiveArray extends Reactive {
423
459
  function array(value, options) {
424
460
  return new ReactiveArray(Array.isArray(value) ? value : [], options);
425
461
  }
426
- function setValue(target, property, value, state, length) {
427
- const isIndex = !Number.isNaN(Number(property));
428
- const isLength = property === 'length';
429
- if (!isIndex && !isLength) {
430
- return Reflect.set(target, property, value);
431
- }
432
- const previous = Reflect.get(target, property);
433
- if (!state.equal(previous, value)) {
434
- Reflect.set(target, property, value);
435
- emitValue(state);
436
- length.set(target.length);
437
- }
438
- return true;
439
- }
440
462
  function updateArray(type, array, state, length) {
441
463
  const affectsLength = lengthAffectingMethods.has(type);
442
464
  const previousArray = affectsLength ? [] : [...array];
@@ -445,7 +467,7 @@ function updateArray(type, array, state, length) {
445
467
  const result = array[type](...args);
446
468
  if (affectsLength
447
469
  ? array.length !== previousLength
448
- : differentArrays(state, previousArray, array)) {
470
+ : !equalArrays(state, previousArray, array)) {
449
471
  emitValue(state);
450
472
  length.set(array.length);
451
473
  }
@@ -467,4 +489,46 @@ const updateMethods = new Set([
467
489
  'splice',
468
490
  ]);
469
491
 
470
- export { array, computed, effect, isArray, isComputed, isEffect, isReactive, isSignal, signal, startBatch, stopBatch };
492
+ function isKey(value) {
493
+ return typeof value === "number" || typeof value === "string";
494
+ }
495
+ function isPlainObject(value) {
496
+ if (value === null || typeof value !== "object") {
497
+ return false;
498
+ }
499
+ if (Symbol.toStringTag in value || Symbol.iterator in value) {
500
+ return false;
501
+ }
502
+ const prototype = Object.getPrototypeOf(value);
503
+ return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
504
+ }
505
+
506
+ class Store extends Reactive {
507
+ constructor(value, options) {
508
+ super(storeName, new Proxy(value, {
509
+ set: (target, property, value) => setValueInProxy(target, property, value, this.state, false),
510
+ }), options);
511
+ }
512
+ get(key) {
513
+ return isKey(key) ? this.state.value[key] : getValue(this.state);
514
+ }
515
+ peek(key) {
516
+ return isKey(key) ? this.state.value[key] : { ...this.state.value };
517
+ }
518
+ set(first, second) {
519
+ if (isKey(first)) {
520
+ this.state.value[first] = second;
521
+ }
522
+ else if (first == null || isPlainObject(first)) {
523
+ setProxyValue(this.state.value, first ?? {});
524
+ }
525
+ }
526
+ }
527
+ /**
528
+ * Create a reactive store
529
+ */
530
+ function store(value, options) {
531
+ return new Store((isPlainObject(value) ? value : {}), options);
532
+ }
533
+
534
+ export { array, computed, effect, isArray, isComputed, isEffect, isReactive, isSignal, signal, startBatch, stopBatch, store };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function isKey(value) {
4
+ return typeof value === "number" || typeof value === "string";
5
+ }
6
+ function isPlainObject(value) {
7
+ if (value === null || typeof value !== "object") {
8
+ return false;
9
+ }
10
+ if (Symbol.toStringTag in value || Symbol.iterator in value) {
11
+ return false;
12
+ }
13
+ const prototype = Object.getPrototypeOf(value);
14
+ return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
15
+ }
16
+ exports.isKey = isKey;
17
+ exports.isPlainObject = isPlainObject;
@@ -0,0 +1,17 @@
1
+ function isKey(value) {
2
+ return typeof value === "number" || typeof value === "string";
3
+ }
4
+ function isPlainObject(value) {
5
+ if (value === null || typeof value !== "object") {
6
+ return false;
7
+ }
8
+ if (Symbol.toStringTag in value || Symbol.iterator in value) {
9
+ return false;
10
+ }
11
+ const prototype = Object.getPrototypeOf(value);
12
+ return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
13
+ }
14
+ export {
15
+ isKey,
16
+ isPlainObject
17
+ };
@@ -8,6 +8,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
8
8
  var _size;
9
9
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
10
10
  const helpers_is = require("../helpers/is.cjs");
11
+ const helpers_proxy = require("../helpers/proxy.cjs");
11
12
  const helpers_value = require("../helpers/value.cjs");
12
13
  const value_computed = require("./computed.cjs");
13
14
  const value_reactive = require("./reactive.cjs");
@@ -18,7 +19,14 @@ class ReactiveArray extends value_reactive.Reactive {
18
19
  helpers_is.arrayName,
19
20
  new Proxy(value, {
20
21
  get: (target, property) => updateMethods.has(property) ? updateArray(property, target, this.state, __privateGet(this, _size)) : Reflect.get(target, property),
21
- set: (target, property, value2) => setValue(target, property, value2, this.state, __privateGet(this, _size))
22
+ set: (target, property, value2) => helpers_proxy.setValueInProxy(
23
+ target,
24
+ property,
25
+ value2,
26
+ this.state,
27
+ true,
28
+ __privateGet(this, _size)
29
+ )
22
30
  }),
23
31
  options
24
32
  );
@@ -120,20 +128,6 @@ _size = new WeakMap();
120
128
  function array(value, options) {
121
129
  return new ReactiveArray(Array.isArray(value) ? value : [], options);
122
130
  }
123
- function setValue(target, property, value, state, length) {
124
- const isIndex = !Number.isNaN(Number(property));
125
- const isLength = property === "length";
126
- if (!isIndex && !isLength) {
127
- return Reflect.set(target, property, value);
128
- }
129
- const previous = Reflect.get(target, property);
130
- if (!state.equal(previous, value)) {
131
- Reflect.set(target, property, value);
132
- helpers_value.emitValue(state);
133
- length.set(target.length);
134
- }
135
- return true;
136
- }
137
131
  function updateArray(type, array2, state, length) {
138
132
  const affectsLength = lengthAffectingMethods.has(type);
139
133
  const previousArray = affectsLength ? [] : [...array2];
@@ -142,7 +136,7 @@ function updateArray(type, array2, state, length) {
142
136
  const result = array2[type](
143
137
  ...args
144
138
  );
145
- if (affectsLength ? array2.length !== previousLength : helpers_value.differentArrays(state, previousArray, array2)) {
139
+ if (affectsLength ? array2.length !== previousLength : !helpers_value.equalArrays(state, previousArray, array2)) {
146
140
  helpers_value.emitValue(state);
147
141
  length.set(array2.length);
148
142
  }
@@ -6,7 +6,8 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
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
7
  var _size;
8
8
  import { arrayName } from "../helpers/is.js";
9
- import { getValue, emitValue, differentArrays } from "../helpers/value.js";
9
+ import { setValueInProxy } from "../helpers/proxy.js";
10
+ import { getValue, equalArrays, emitValue } from "../helpers/value.js";
10
11
  import { computed } from "./computed.js";
11
12
  import { Reactive } from "./reactive.js";
12
13
  import { signal } from "./signal.js";
@@ -16,7 +17,14 @@ class ReactiveArray extends Reactive {
16
17
  arrayName,
17
18
  new Proxy(value, {
18
19
  get: (target, property) => updateMethods.has(property) ? updateArray(property, target, this.state, __privateGet(this, _size)) : Reflect.get(target, property),
19
- set: (target, property, value2) => setValue(target, property, value2, this.state, __privateGet(this, _size))
20
+ set: (target, property, value2) => setValueInProxy(
21
+ target,
22
+ property,
23
+ value2,
24
+ this.state,
25
+ true,
26
+ __privateGet(this, _size)
27
+ )
20
28
  }),
21
29
  options
22
30
  );
@@ -118,20 +126,6 @@ _size = new WeakMap();
118
126
  function array(value, options) {
119
127
  return new ReactiveArray(Array.isArray(value) ? value : [], options);
120
128
  }
121
- function setValue(target, property, value, state, length) {
122
- const isIndex = !Number.isNaN(Number(property));
123
- const isLength = property === "length";
124
- if (!isIndex && !isLength) {
125
- return Reflect.set(target, property, value);
126
- }
127
- const previous = Reflect.get(target, property);
128
- if (!state.equal(previous, value)) {
129
- Reflect.set(target, property, value);
130
- emitValue(state);
131
- length.set(target.length);
132
- }
133
- return true;
134
- }
135
129
  function updateArray(type, array2, state, length) {
136
130
  const affectsLength = lengthAffectingMethods.has(type);
137
131
  const previousArray = affectsLength ? [] : [...array2];
@@ -140,7 +134,7 @@ function updateArray(type, array2, state, length) {
140
134
  const result = array2[type](
141
135
  ...args
142
136
  );
143
- if (affectsLength ? array2.length !== previousLength : differentArrays(state, previousArray, array2)) {
137
+ if (affectsLength ? array2.length !== previousLength : !equalArrays(state, previousArray, array2)) {
144
138
  emitValue(state);
145
139
  length.set(array2.length);
146
140
  }
@@ -17,7 +17,7 @@ class Signal extends value_reactive.Reactive {
17
17
  * Set the value
18
18
  */
19
19
  set(value) {
20
- if (helpers_value.differentValues(this.state, this.state.value, value)) {
20
+ if (!this.state.equal(this.state.value, value)) {
21
21
  this.state.value = value;
22
22
  helpers_value.emitValue(this.state);
23
23
  }