@oscarpalmer/mora 0.18.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 (44) 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 +22 -26
  6. package/dist/helpers/value.js +22 -26
  7. package/dist/index.cjs +2 -0
  8. package/dist/index.js +3 -1
  9. package/dist/mora.full.js +127 -59
  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 +15 -20
  13. package/dist/value/array.js +16 -21
  14. package/dist/value/computed.cjs +5 -5
  15. package/dist/value/computed.js +5 -5
  16. package/dist/value/reactive.cjs +5 -1
  17. package/dist/value/reactive.js +5 -1
  18. package/dist/value/signal.cjs +5 -5
  19. package/dist/value/signal.js +6 -6
  20. package/dist/value/store.cjs +36 -0
  21. package/dist/value/store.js +36 -0
  22. package/package.json +1 -1
  23. package/src/helpers/is.ts +1 -1
  24. package/src/helpers/proxy.ts +0 -1
  25. package/types/helpers/is.d.ts +3 -0
  26. package/types/helpers/proxy.d.ts +5 -0
  27. package/types/helpers/value.d.ts +3 -4
  28. package/types/index.d.ts +1 -0
  29. package/types/subscription.d.ts +4 -4
  30. package/types/value/array.d.ts +4 -4
  31. package/types/value/computed.d.ts +4 -4
  32. package/types/value/reactive.d.ts +11 -4
  33. package/types/value/signal.d.ts +3 -3
  34. package/types/value/store.d.ts +45 -0
  35. package/types/batch.d.cts +0 -72
  36. package/types/effect.d.cts +0 -16
  37. package/types/helpers/is.d.cts +0 -169
  38. package/types/helpers/value.d.cts +0 -65
  39. package/types/index.d.cts +0 -189
  40. package/types/subscription.d.cts +0 -64
  41. package/types/value/array.d.cts +0 -137
  42. package/types/value/computed.d.cts +0 -74
  43. package/types/value/reactive.d.cts +0 -61
  44. package/types/value/signal.d.cts +0 -80
@@ -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,45 +3,42 @@ 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(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) {
13
27
  offset = Math.round(length / 10);
14
28
  offset = offset > 25 ? 25 : offset;
15
29
  for (let index = 0; index < offset; index += 1) {
16
- if (!Object.is(first[index], second[index])) {
17
- return true;
30
+ if (!state.equal(first[index], second[index])) {
31
+ return false;
18
32
  }
19
33
  }
20
34
  }
21
35
  length -= offset;
22
36
  for (let index = offset; index < length; index += 1) {
23
- if (!Object.is(first[index], second[index])) {
24
- return true;
37
+ if (!state.equal(first[index], second[index])) {
38
+ return false;
25
39
  }
26
40
  }
27
- return false;
28
- }
29
- function differentValues(first, second) {
30
- return Array.isArray(first) && Array.isArray(second) ? differentArrays(first, second) : !Object.is(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,45 +1,42 @@
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(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) {
11
25
  offset = Math.round(length / 10);
12
26
  offset = offset > 25 ? 25 : offset;
13
27
  for (let index = 0; index < offset; index += 1) {
14
- if (!Object.is(first[index], second[index])) {
15
- return true;
28
+ if (!state.equal(first[index], second[index])) {
29
+ return false;
16
30
  }
17
31
  }
18
32
  }
19
33
  length -= offset;
20
34
  for (let index = offset; index < length; index += 1) {
21
- if (!Object.is(first[index], second[index])) {
22
- return true;
35
+ if (!state.equal(first[index], second[index])) {
36
+ return false;
23
37
  }
24
38
  }
25
- return false;
26
- }
27
- function differentValues(first, second) {
28
- return Array.isArray(first) && Array.isArray(second) ? differentArrays(first, second) : !Object.is(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) {
@@ -132,11 +133,15 @@ class Reactive {
132
133
  state = {
133
134
  computeds: new Set(),
134
135
  effects: new Set(),
136
+ equal: Object.is,
135
137
  subscriptions: new Map(),
136
138
  value: undefined,
137
139
  };
138
- constructor(name, value) {
140
+ constructor(name, value, options) {
139
141
  this.state.value = value;
142
+ if (typeof options === 'object' && typeof options.equal === 'function') {
143
+ this.state.equal = options.equal;
144
+ }
140
145
  Object.defineProperty(this, '$mora', {
141
146
  value: name,
142
147
  });
@@ -179,15 +184,15 @@ class Computed extends Reactive {
179
184
  dirty: true,
180
185
  instance: undefined,
181
186
  };
182
- constructor(callback) {
183
- super(computedName, undefined);
187
+ constructor(callback, options) {
188
+ super(computedName, undefined, options);
184
189
  this.effect.instance = effect(() => {
185
190
  if (this.effect.dirty) {
186
191
  const previousComputed = activeComputed;
187
192
  activeComputed = this;
188
193
  const value = callback();
189
194
  activeComputed = previousComputed;
190
- if (!Object.is(this.state.value, value)) {
195
+ if (!this.state.equal(this.state.value, value)) {
191
196
  this.state.value = value;
192
197
  for (const computed of this.state.computeds) {
193
198
  computed.effect.dirty = true;
@@ -222,51 +227,46 @@ class Computed extends Reactive {
222
227
  /**
223
228
  * Create a computed value
224
229
  */
225
- function computed(callback) {
226
- return new Computed(callback);
230
+ function computed(callback, options) {
231
+ return new Computed(callback, options);
227
232
  }
228
233
 
229
- function differentArrays(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) {
230
249
  let { length } = first;
231
250
  if (length !== second.length) {
232
- return true;
251
+ return false;
233
252
  }
234
253
  let offset = 0;
235
254
  if (length >= 100) {
236
255
  offset = Math.round(length / 10);
237
256
  offset = offset > 25 ? 25 : offset;
238
257
  for (let index = 0; index < offset; index += 1) {
239
- if (!Object.is(first[index], second[index])) {
240
- return true;
258
+ if (!state.equal(first[index], second[index])) {
259
+ return false;
241
260
  }
242
261
  }
243
262
  }
244
263
  length -= offset;
245
264
  for (let index = offset; index < length; index += 1) {
246
- if (!Object.is(first[index], second[index])) {
247
- return true;
265
+ if (!state.equal(first[index], second[index])) {
266
+ return false;
248
267
  }
249
268
  }
250
- return false;
251
- }
252
- function differentValues(first, second) {
253
- return Array.isArray(first) && Array.isArray(second)
254
- ? differentArrays(first, second)
255
- : !Object.is(first, second);
256
- }
257
- function emitValue(state) {
258
- for (const computed of state.computeds) {
259
- computed.effect.dirty = true;
260
- }
261
- for (const effect of state.effects) {
262
- batchedHandlers.add(effect);
263
- }
264
- for (const [, subscription] of state.subscriptions) {
265
- batchedHandlers.add(subscription);
266
- }
267
- if (batchDepth === 0) {
268
- flushHandlers();
269
- }
269
+ return true;
270
270
  }
271
271
  function getValue(state) {
272
272
  if (activeComputed != null) {
@@ -278,9 +278,49 @@ function getValue(state) {
278
278
  return state.value;
279
279
  }
280
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
+
281
321
  class Signal extends Reactive {
282
- constructor(value) {
283
- super(signalName, value);
322
+ constructor(value, options) {
323
+ super(signalName, value, options);
284
324
  }
285
325
  /**
286
326
  * @inheritdoc
@@ -292,7 +332,7 @@ class Signal extends Reactive {
292
332
  * Set the value
293
333
  */
294
334
  set(value) {
295
- if (differentValues(this.state.value, value)) {
335
+ if (!this.state.equal(this.state.value, value)) {
296
336
  this.state.value = value;
297
337
  emitValue(this.state);
298
338
  }
@@ -307,8 +347,8 @@ class Signal extends Reactive {
307
347
  /**
308
348
  * Create a reactive value
309
349
  */
310
- function signal(value) {
311
- return new Signal(value);
350
+ function signal(value, options) {
351
+ return new Signal(value, options);
312
352
  }
313
353
 
314
354
  class ReactiveArray extends Reactive {
@@ -329,13 +369,13 @@ class ReactiveArray extends Reactive {
329
369
  this.get().length = value;
330
370
  }
331
371
  }
332
- constructor(value) {
372
+ constructor(value, options) {
333
373
  super(arrayName, new Proxy(value, {
334
374
  get: (target, property) => updateMethods.has(property)
335
375
  ? updateArray(property, target, this.state, this.#size)
336
376
  : Reflect.get(target, property),
337
- set: (target, property, value) => setValue(target, property, value, this.state, this.#size),
338
- }));
377
+ set: (target, property, value) => setValueInProxy(target, property, value, this.state, true, this.#size),
378
+ }), options);
339
379
  this.#size.set(value.length);
340
380
  }
341
381
  /**
@@ -416,22 +456,8 @@ class ReactiveArray extends Reactive {
416
456
  /**
417
457
  * Create a reactive array
418
458
  */
419
- function array(value) {
420
- return new ReactiveArray(Array.isArray(value) ? value : []);
421
- }
422
- function setValue(target, property, value, state, length) {
423
- const isIndex = !Number.isNaN(Number(property));
424
- const isLength = property === 'length';
425
- if (!isIndex && !isLength) {
426
- return Reflect.set(target, property, value);
427
- }
428
- const previous = Reflect.get(target, property);
429
- if (!Object.is(previous, value)) {
430
- Reflect.set(target, property, value);
431
- emitValue(state);
432
- length.set(target.length);
433
- }
434
- return true;
459
+ function array(value, options) {
460
+ return new ReactiveArray(Array.isArray(value) ? value : [], options);
435
461
  }
436
462
  function updateArray(type, array, state, length) {
437
463
  const affectsLength = lengthAffectingMethods.has(type);
@@ -441,7 +467,7 @@ function updateArray(type, array, state, length) {
441
467
  const result = array[type](...args);
442
468
  if (affectsLength
443
469
  ? array.length !== previousLength
444
- : differentArrays(previousArray, array)) {
470
+ : !equalArrays(state, previousArray, array)) {
445
471
  emitValue(state);
446
472
  length.set(array.length);
447
473
  }
@@ -463,4 +489,46 @@ const updateMethods = new Set([
463
489
  'splice',
464
490
  ]);
465
491
 
466
- 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
+ };