@oscarpalmer/mora 0.38.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 -4
  3. package/dist/constants.d.mts +16 -10
  4. package/dist/constants.mjs +12 -6
  5. package/dist/effect.d.mts +2 -3
  6. package/dist/effect.mjs +27 -8
  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 -11
  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 +18 -13
  17. package/dist/models.d.mts +38 -5
  18. package/dist/mora.full.mjs +555 -276
  19. package/dist/value/array.d.mts +1 -3
  20. package/dist/value/array.mjs +46 -22
  21. package/dist/value/computed.d.mts +1 -3
  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 -3
  26. package/dist/value/signal.mjs +9 -6
  27. package/dist/value/store.d.mts +1 -3
  28. package/dist/value/store.mjs +9 -6
  29. package/package.json +5 -12
  30. package/src/batch.ts +8 -4
  31. package/src/constants.ts +26 -16
  32. package/src/effect.ts +37 -7
  33. package/src/helpers/is.ts +18 -8
  34. package/src/helpers/misc.ts +121 -2
  35. package/src/helpers/proxy.ts +59 -9
  36. package/src/helpers/subscription.ts +34 -4
  37. package/src/helpers/value.ts +48 -15
  38. package/src/models.ts +42 -3
  39. package/src/value/array.ts +100 -21
  40. package/src/value/computed.ts +29 -10
  41. package/src/value/readonly.ts +38 -33
  42. package/src/value/signal.ts +11 -5
  43. package/src/value/store.ts +11 -5
  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,9 +16,20 @@ 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;
@@ -27,8 +37,14 @@ export type InternalArray = {
27
37
  export type InternalComputed = {
28
38
  [SYMBOL_EFFECT]: ComputedEffect;
29
39
  } & Computed<unknown> & InternalStateful;
40
+ export type InternalEffect = {
41
+ [SYMBOL_STATE]: EffectState;
42
+ } & Effect;
43
+ export type InternalReactive = {
44
+ [SYMBOL_STATE]: SignalState;
45
+ } & Reactive<unknown>;
30
46
  export type InternalReadonly = {
31
- frozen: boolean;
47
+ [SYMBOL_READONLY]: ReadonlyState;
32
48
  } & InternalStateful & ReadonlySignal<unknown>;
33
49
  export type InternalSignal = InternalStateful & Signal<unknown>;
34
50
  export type InternalStateful = {
@@ -38,6 +54,14 @@ export type InternalStore = {
38
54
  [SYMBOL_STATE]: ReactiveProxyState;
39
55
  } & ReactiveStore<PlainObject>;
40
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;
41
65
  /**
42
66
  * Get the value
43
67
  *
@@ -264,14 +288,17 @@ export type ReactiveOptions<Value> = {
264
288
  equal?: (first: Value, second: Value) => boolean;
265
289
  };
266
290
  export type ReactiveProxyState = {
291
+ derived?: Set<Computed<unknown>>;
267
292
  isArray: boolean;
268
293
  length?: Signal<number>;
269
294
  mapped?: Map<string, InternalComputed>;
270
295
  } & SignalState;
271
296
  export type ReactiveState<Value = unknown, Item = Value> = {
297
+ active: boolean;
272
298
  computeds?: Set<ComputedEffect>;
273
299
  effects?: Set<EffectState>;
274
300
  equal?: (first: Item, second: Item) => boolean;
301
+ name: string;
275
302
  promise?: Promise<unknown>;
276
303
  promises?: Map<Key, Promise<never>>;
277
304
  subscriptions?: Subscriptions<GenericCallback>;
@@ -407,6 +434,12 @@ export type ReadonlySignal<Value> = {
407
434
  get frozen(): boolean;
408
435
  } & Reactive<Value>;
409
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
+ };
410
443
  export type Signal<Value> = {
411
444
  /**
412
445
  * Get a readonly version of the signal
@@ -447,4 +480,4 @@ export type StoredSubscription = {
447
480
  };
448
481
  export type Subscriber<Value> = (value: Value, subscription: Subscription) => void;
449
482
  export type SubscriptionType = "copy" | "frozen" | "original" | "readonly";
450
- //#endregion
483
+ export {};