mutts 1.0.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 (82) hide show
  1. package/README.md +150 -0
  2. package/dist/chunks/decorator-BXsign4Z.js +176 -0
  3. package/dist/chunks/decorator-BXsign4Z.js.map +1 -0
  4. package/dist/chunks/decorator-CPbZNnsX.esm.js +168 -0
  5. package/dist/chunks/decorator-CPbZNnsX.esm.js.map +1 -0
  6. package/dist/decorator.d.ts +50 -0
  7. package/dist/decorator.esm.js +2 -0
  8. package/dist/decorator.esm.js.map +1 -0
  9. package/dist/decorator.js +11 -0
  10. package/dist/decorator.js.map +1 -0
  11. package/dist/destroyable.d.ts +48 -0
  12. package/dist/destroyable.esm.js +91 -0
  13. package/dist/destroyable.esm.js.map +1 -0
  14. package/dist/destroyable.js +98 -0
  15. package/dist/destroyable.js.map +1 -0
  16. package/dist/eventful.d.ts +11 -0
  17. package/dist/eventful.esm.js +88 -0
  18. package/dist/eventful.esm.js.map +1 -0
  19. package/dist/eventful.js +90 -0
  20. package/dist/eventful.js.map +1 -0
  21. package/dist/index.d.ts +15 -0
  22. package/dist/index.esm.js +7 -0
  23. package/dist/index.esm.js.map +1 -0
  24. package/dist/index.js +52 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/indexable.d.ts +31 -0
  27. package/dist/indexable.esm.js +85 -0
  28. package/dist/indexable.esm.js.map +1 -0
  29. package/dist/indexable.js +89 -0
  30. package/dist/indexable.js.map +1 -0
  31. package/dist/mutts.umd.js +2 -0
  32. package/dist/mutts.umd.js.map +1 -0
  33. package/dist/mutts.umd.min.js +2 -0
  34. package/dist/mutts.umd.min.js.map +1 -0
  35. package/dist/promiseChain.d.ts +11 -0
  36. package/dist/promiseChain.esm.js +72 -0
  37. package/dist/promiseChain.esm.js.map +1 -0
  38. package/dist/promiseChain.js +74 -0
  39. package/dist/promiseChain.js.map +1 -0
  40. package/dist/reactive.d.ts +114 -0
  41. package/dist/reactive.esm.js +1455 -0
  42. package/dist/reactive.esm.js.map +1 -0
  43. package/dist/reactive.js +1472 -0
  44. package/dist/reactive.js.map +1 -0
  45. package/dist/std-decorators.d.ts +17 -0
  46. package/dist/std-decorators.esm.js +161 -0
  47. package/dist/std-decorators.esm.js.map +1 -0
  48. package/dist/std-decorators.js +169 -0
  49. package/dist/std-decorators.js.map +1 -0
  50. package/docs/decorator.md +300 -0
  51. package/docs/destroyable.md +294 -0
  52. package/docs/events.md +225 -0
  53. package/docs/indexable.md +561 -0
  54. package/docs/promiseChain.md +218 -0
  55. package/docs/reactive.md +2072 -0
  56. package/docs/std-decorators.md +558 -0
  57. package/package.json +132 -0
  58. package/src/decorator.test.ts +495 -0
  59. package/src/decorator.ts +205 -0
  60. package/src/destroyable.test.ts +155 -0
  61. package/src/destroyable.ts +158 -0
  62. package/src/eventful.test.ts +380 -0
  63. package/src/eventful.ts +69 -0
  64. package/src/index.ts +7 -0
  65. package/src/indexable.test.ts +388 -0
  66. package/src/indexable.ts +124 -0
  67. package/src/promiseChain.test.ts +201 -0
  68. package/src/promiseChain.ts +99 -0
  69. package/src/reactive/array.test.ts +923 -0
  70. package/src/reactive/array.ts +352 -0
  71. package/src/reactive/core.test.ts +1663 -0
  72. package/src/reactive/core.ts +866 -0
  73. package/src/reactive/index.ts +28 -0
  74. package/src/reactive/interface.test.ts +1477 -0
  75. package/src/reactive/interface.ts +231 -0
  76. package/src/reactive/map.test.ts +866 -0
  77. package/src/reactive/map.ts +162 -0
  78. package/src/reactive/set.test.ts +289 -0
  79. package/src/reactive/set.ts +142 -0
  80. package/src/std-decorators.test.ts +679 -0
  81. package/src/std-decorators.ts +182 -0
  82. package/src/utils.ts +52 -0
@@ -0,0 +1,114 @@
1
+ import { LegacyClassDecorator, ModernClassDecorator, LegacyPropertyDecorator, ModernGetterDecorator, ModernAccessorDecorator, GenericClassDecorator } from './decorator.js';
2
+
3
+ type DependencyFunction = <T>(cb: () => T) => T;
4
+ type ScopedCallback = () => void;
5
+ type PropEvolution = {
6
+ type: 'set' | 'del' | 'add';
7
+ prop: any;
8
+ };
9
+ type BunchEvolution = {
10
+ type: 'bunch';
11
+ method: string;
12
+ };
13
+ type Evolution = PropEvolution | BunchEvolution;
14
+ type State = {
15
+ evolution: Evolution;
16
+ next: State;
17
+ } | {};
18
+ declare const profileInfo: any;
19
+ declare class ReactiveError extends Error {
20
+ constructor(message: string);
21
+ }
22
+ /**
23
+ * Options for the reactive system, can be configured at runtime
24
+ */
25
+ declare const options: {
26
+ /**
27
+ * Debug purpose: called when an effect is entered
28
+ * @param effect - The effect that is entered
29
+ */
30
+ enter: (effect: Function) => void;
31
+ /**
32
+ * Debug purpose: called when an effect is left
33
+ * @param effect - The effect that is left
34
+ */
35
+ leave: (effect: Function) => void;
36
+ /**
37
+ * Debug purpose: called when an effect is chained
38
+ * @param target - The effect that is being triggered
39
+ * @param caller - The effect that is calling the target
40
+ */
41
+ chain: (target: Function, caller?: Function) => void;
42
+ /**
43
+ * Debug purpose: maximum effect chain (like call stack max depth)
44
+ * Used to prevent infinite loops
45
+ * @default 100
46
+ */
47
+ maxEffectChain: number;
48
+ /**
49
+ * Maximum depth for deep watching traversal
50
+ * Used to prevent infinite recursion in circular references
51
+ * @default 100
52
+ */
53
+ maxDeepWatchDepth: number;
54
+ /**
55
+ * Only react on instance members modification (not inherited properties)
56
+ * For instance, do not track class methods
57
+ * @default true
58
+ */
59
+ instanceMembers: boolean;
60
+ warn: (...args: any[]) => void;
61
+ };
62
+ declare function getState(obj: any): State;
63
+ declare class ReactiveBase {
64
+ constructor();
65
+ }
66
+ declare function reactiveObject<T>(anyTarget: T): T;
67
+ declare const reactive: LegacyClassDecorator<new (...args: any[]) => any> & ModernClassDecorator<new (...args: any[]) => any> & typeof reactiveObject;
68
+ declare function unwrap<T>(proxy: T): T;
69
+ declare function isReactive(obj: any): boolean;
70
+ declare function untracked(fn: () => ScopedCallback | undefined | void): void;
71
+ /**
72
+ * @param fn - The effect function to run - provides the cleaner
73
+ * @returns The cleanup function
74
+ */
75
+ declare function effect<Args extends any[]>(fn: (dep: DependencyFunction, ...args: Args) => ScopedCallback | undefined | void, ...args: Args): ScopedCallback;
76
+ /**
77
+ * Set of functions to test if an object is immutable
78
+ */
79
+ declare const immutables: Set<(tested: any) => boolean>;
80
+ /**
81
+ * Check if an object is marked as non-reactive (for testing purposes)
82
+ * @param obj - The object to check
83
+ * @returns true if the object is marked as non-reactive
84
+ */
85
+ declare function isNonReactive(obj: any): boolean;
86
+
87
+ /**
88
+ * When used in a computed property computation, it will register the callback to be called when the computed property is invalidated
89
+ * @param cb - The callback to register
90
+ * @param warn - Whether to warn if used outside of a computed property
91
+ */
92
+ declare function invalidateComputed(cb: () => void, warn?: boolean): void;
93
+ type ComputedFunction<T> = (dep: DependencyFunction) => T;
94
+ /**
95
+ * Get the cached value of a computed function - cache is invalidated when the dependencies change
96
+ */
97
+ declare const computed: LegacyPropertyDecorator<any> & ModernGetterDecorator<any> & ModernAccessorDecorator<any> & (<T>(getter: ComputedFunction<T>) => T);
98
+ interface WatchOptions {
99
+ immediate?: boolean;
100
+ deep?: boolean;
101
+ }
102
+ declare function watch<T>(value: (dep: DependencyFunction) => T, changed: (value: T, oldValue?: T) => void, options?: Omit<WatchOptions, 'deep'> & {
103
+ deep?: false;
104
+ }): ScopedCallback;
105
+ declare function watch<T extends object | any[]>(value: (dep: DependencyFunction) => T, changed: (value: T, oldValue?: T) => void, options?: Omit<WatchOptions, 'deep'> & {
106
+ deep: true;
107
+ }): ScopedCallback;
108
+ declare function watch<T extends object | any[]>(value: T, changed: (value: T) => void, options?: WatchOptions): ScopedCallback;
109
+ declare function unreactiveApplication<T extends object>(...args: (keyof T)[]): GenericClassDecorator<T>;
110
+ declare function unreactiveApplication<T extends object>(obj: T): T;
111
+ declare const unreactive: LegacyClassDecorator<new (...args: any[]) => any> & ModernClassDecorator<new (...args: any[]) => any> & typeof unreactiveApplication;
112
+
113
+ export { ReactiveBase, ReactiveError, computed, effect, getState, immutables, invalidateComputed, isNonReactive, isReactive, profileInfo, reactive, options as reactiveOptions, unreactive, untracked, unwrap, watch };
114
+ export type { ScopedCallback };