@oscarpalmer/mora 0.37.0 → 0.39.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 (57) hide show
  1. package/dist/batch.d.mts +1 -3
  2. package/dist/batch.mjs +3 -3
  3. package/dist/constants.d.mts +16 -12
  4. package/dist/constants.mjs +12 -6
  5. package/dist/effect.d.mts +2 -4
  6. package/dist/effect.mjs +27 -7
  7. package/dist/helpers/is.d.mts +1 -3
  8. package/dist/helpers/is.mjs +8 -5
  9. package/dist/helpers/misc.d.mts +8 -4
  10. package/dist/helpers/misc.mjs +66 -4
  11. package/dist/helpers/proxy.d.mts +3 -4
  12. package/dist/helpers/proxy.mjs +26 -10
  13. package/dist/helpers/subscription.d.mts +1 -3
  14. package/dist/helpers/subscription.mjs +15 -7
  15. package/dist/helpers/value.d.mts +4 -5
  16. package/dist/helpers/value.mjs +19 -12
  17. package/dist/models.d.mts +39 -7
  18. package/dist/mora.full.mjs +565 -234
  19. package/dist/value/array.d.mts +1 -4
  20. package/dist/value/array.mjs +47 -23
  21. package/dist/value/computed.d.mts +1 -4
  22. package/dist/value/computed.mjs +17 -11
  23. package/dist/value/readonly.d.mts +2 -5
  24. package/dist/value/readonly.mjs +24 -16
  25. package/dist/value/signal.d.mts +1 -4
  26. package/dist/value/signal.mjs +9 -6
  27. package/dist/value/store.d.mts +1 -4
  28. package/dist/value/store.mjs +9 -6
  29. package/package.json +7 -10
  30. package/src/batch.ts +8 -3
  31. package/src/constants.ts +31 -20
  32. package/src/effect.ts +37 -6
  33. package/src/helpers/is.ts +18 -8
  34. package/src/helpers/misc.ts +121 -2
  35. package/src/helpers/proxy.ts +59 -8
  36. package/src/helpers/subscription.ts +34 -4
  37. package/src/helpers/value.ts +49 -14
  38. package/src/models.ts +43 -4
  39. package/src/value/array.ts +103 -24
  40. package/src/value/computed.ts +30 -11
  41. package/src/value/readonly.ts +38 -33
  42. package/src/value/signal.ts +12 -6
  43. package/src/value/store.ts +13 -7
  44. package/types/batch.d.ts +0 -11
  45. package/types/constants.d.ts +0 -16
  46. package/types/effect.d.ts +0 -13
  47. package/types/helpers/is.d.ts +0 -43
  48. package/types/helpers/proxy.d.ts +0 -11
  49. package/types/helpers/value.d.ts +0 -4
  50. package/types/index.d.ts +0 -9
  51. package/types/models.d.ts +0 -56
  52. package/types/subscription.d.ts +0 -11
  53. package/types/value/array.d.ts +0 -137
  54. package/types/value/computed.d.ts +0 -14
  55. package/types/value/reactive.d.ts +0 -36
  56. package/types/value/signal.d.ts +0 -26
  57. package/types/value/store.d.ts +0 -94
package/dist/models.d.mts CHANGED
@@ -1,7 +1,6 @@
1
- import { PROPERTY_LENGTH, SYMBOL_EFFECT, SYMBOL_STATE } from "./constants.mjs";
1
+ import { PROPERTY_LENGTH, SYMBOL_EFFECT, SYMBOL_READONLY, SYMBOL_STATE } from "./constants.mjs";
2
2
  import { Subscription, Subscriptions } from "@oscarpalmer/atoms/subscription";
3
3
  import { GenericCallback, Key, PlainObject } from "@oscarpalmer/atoms/models";
4
- //#region src/models.d.ts
5
4
  export type Active = {
6
5
  computed?: ComputedEffect;
7
6
  effect?: EffectState;
@@ -17,19 +16,35 @@ export type ComputedEffect = {
17
16
  instance: EffectState;
18
17
  notify: boolean;
19
18
  };
20
- export type Effect = {};
19
+ export type Effect = {
20
+ /**
21
+ * Is the effect active?
22
+ */
23
+ get active(): boolean;
24
+ /**
25
+ * Stop the effect
26
+ */
27
+ stop(): void;
28
+ };
21
29
  export type EffectState = {
30
+ active: boolean;
22
31
  callback: GenericCallback;
32
+ name: string;
23
33
  };
24
34
  export type InternalArray = {
25
35
  [SYMBOL_STATE]: ReactiveProxyState;
26
36
  } & ReactiveArray<unknown>;
27
37
  export type InternalComputed = {
28
38
  [SYMBOL_EFFECT]: ComputedEffect;
39
+ } & Computed<unknown> & InternalStateful;
40
+ export type InternalEffect = {
41
+ [SYMBOL_STATE]: EffectState;
42
+ } & Effect;
43
+ export type InternalReactive = {
29
44
  [SYMBOL_STATE]: SignalState;
30
- } & Computed<unknown>;
45
+ } & Reactive<unknown>;
31
46
  export type InternalReadonly = {
32
- frozen: boolean;
47
+ [SYMBOL_READONLY]: ReadonlyState;
33
48
  } & InternalStateful & ReadonlySignal<unknown>;
34
49
  export type InternalSignal = InternalStateful & Signal<unknown>;
35
50
  export type InternalStateful = {
@@ -39,6 +54,14 @@ export type InternalStore = {
39
54
  [SYMBOL_STATE]: ReactiveProxyState;
40
55
  } & ReactiveStore<PlainObject>;
41
56
  export type Reactive<Value> = {
57
+ /**
58
+ * Is the signal active?
59
+ */
60
+ get active(): boolean;
61
+ /**
62
+ * Deactivate the signal, preventing further updates
63
+ */
64
+ deactivate(): void;
42
65
  /**
43
66
  * Get the value
44
67
  *
@@ -265,14 +288,17 @@ export type ReactiveOptions<Value> = {
265
288
  equal?: (first: Value, second: Value) => boolean;
266
289
  };
267
290
  export type ReactiveProxyState = {
291
+ derived?: Set<Computed<unknown>>;
268
292
  isArray: boolean;
269
293
  length?: Signal<number>;
270
294
  mapped?: Map<string, InternalComputed>;
271
295
  } & SignalState;
272
296
  export type ReactiveState<Value = unknown, Item = Value> = {
297
+ active: boolean;
273
298
  computeds?: Set<ComputedEffect>;
274
299
  effects?: Set<EffectState>;
275
300
  equal?: (first: Item, second: Item) => boolean;
301
+ name: string;
276
302
  promise?: Promise<unknown>;
277
303
  promises?: Map<Key, Promise<never>>;
278
304
  subscriptions?: Subscriptions<GenericCallback>;
@@ -408,6 +434,12 @@ export type ReadonlySignal<Value> = {
408
434
  get frozen(): boolean;
409
435
  } & Reactive<Value>;
410
436
  export type ReadonlySignalValue<Value> = Value extends unknown[] ? Readonly<Value> : Value extends PlainObject ? Readonly<Value> : Value;
437
+ export type ReadonlyState = {
438
+ active: boolean;
439
+ name: string;
440
+ subscriptions?: Set<Subscription>;
441
+ value?: unknown;
442
+ };
411
443
  export type Signal<Value> = {
412
444
  /**
413
445
  * Get a readonly version of the signal
@@ -447,5 +479,5 @@ export type StoredSubscription = {
447
479
  state: SignalState;
448
480
  };
449
481
  export type Subscriber<Value> = (value: Value, subscription: Subscription) => void;
450
- export type SubscriptionType = 'copy' | 'frozen' | 'original' | 'readonly';
451
- //#endregion
482
+ export type SubscriptionType = "copy" | "frozen" | "original" | "readonly";
483
+ export {};