@signaltree/core 5.1.0 → 5.1.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.
- package/package.json +1 -1
- package/dist/constants.js +0 -6
- package/dist/deep-clone.js +0 -80
- package/dist/deep-equal.js +0 -41
- package/dist/enhancers/batching/lib/batching.js +0 -161
- package/dist/enhancers/computed/lib/computed.js +0 -21
- package/dist/enhancers/devtools/lib/devtools.js +0 -321
- package/dist/enhancers/entities/lib/entities.js +0 -93
- package/dist/enhancers/index.js +0 -72
- package/dist/enhancers/memoization/lib/memoization.js +0 -410
- package/dist/enhancers/presets/lib/presets.js +0 -87
- package/dist/enhancers/serialization/constants.js +0 -15
- package/dist/enhancers/serialization/lib/serialization.js +0 -662
- package/dist/enhancers/time-travel/lib/time-travel.js +0 -193
- package/dist/index.js +0 -19
- package/dist/is-built-in-object.js +0 -23
- package/dist/lib/async-helpers.js +0 -77
- package/dist/lib/constants.js +0 -56
- package/dist/lib/entity-signal.js +0 -280
- package/dist/lib/memory/memory-manager.js +0 -164
- package/dist/lib/path-notifier.js +0 -106
- package/dist/lib/performance/diff-engine.js +0 -156
- package/dist/lib/performance/path-index.js +0 -156
- package/dist/lib/performance/update-engine.js +0 -188
- package/dist/lib/security/security-validator.js +0 -121
- package/dist/lib/signal-tree.js +0 -625
- package/dist/lib/types.js +0 -9
- package/dist/lib/utils.js +0 -254
- package/dist/lru-cache.js +0 -64
- package/dist/parse-path.js +0 -13
- package/src/enhancers/batching/index.d.ts +0 -1
- package/src/enhancers/batching/lib/batching.d.ts +0 -16
- package/src/enhancers/batching/test-setup.d.ts +0 -3
- package/src/enhancers/computed/index.d.ts +0 -1
- package/src/enhancers/computed/lib/computed.d.ts +0 -12
- package/src/enhancers/devtools/index.d.ts +0 -1
- package/src/enhancers/devtools/lib/devtools.d.ts +0 -77
- package/src/enhancers/devtools/test-setup.d.ts +0 -3
- package/src/enhancers/entities/index.d.ts +0 -1
- package/src/enhancers/entities/lib/entities.d.ts +0 -20
- package/src/enhancers/entities/test-setup.d.ts +0 -3
- package/src/enhancers/index.d.ts +0 -3
- package/src/enhancers/memoization/index.d.ts +0 -1
- package/src/enhancers/memoization/lib/memoization.d.ts +0 -65
- package/src/enhancers/memoization/test-setup.d.ts +0 -3
- package/src/enhancers/presets/index.d.ts +0 -1
- package/src/enhancers/presets/lib/presets.d.ts +0 -11
- package/src/enhancers/presets/test-setup.d.ts +0 -3
- package/src/enhancers/serialization/constants.d.ts +0 -14
- package/src/enhancers/serialization/index.d.ts +0 -2
- package/src/enhancers/serialization/lib/serialization.d.ts +0 -59
- package/src/enhancers/serialization/test-setup.d.ts +0 -3
- package/src/enhancers/time-travel/index.d.ts +0 -1
- package/src/enhancers/time-travel/lib/time-travel.d.ts +0 -36
- package/src/enhancers/time-travel/lib/utils.d.ts +0 -1
- package/src/enhancers/time-travel/test-setup.d.ts +0 -3
- package/src/enhancers/types.d.ts +0 -74
- package/src/index.d.ts +0 -18
- package/src/lib/async-helpers.d.ts +0 -8
- package/src/lib/constants.d.ts +0 -41
- package/src/lib/entity-signal.d.ts +0 -1
- package/src/lib/memory/memory-manager.d.ts +0 -30
- package/src/lib/path-notifier.d.ts +0 -4
- package/src/lib/performance/diff-engine.d.ts +0 -33
- package/src/lib/performance/path-index.d.ts +0 -25
- package/src/lib/performance/update-engine.d.ts +0 -32
- package/src/lib/security/security-validator.d.ts +0 -33
- package/src/lib/signal-tree.d.ts +0 -8
- package/src/lib/types.d.ts +0 -278
- package/src/lib/utils.d.ts +0 -28
package/dist/lib/utils.js
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { isSignal, signal, runInInjectionContext, effect } from '@angular/core';
|
|
2
|
-
import { isBuiltInObject } from '../is-built-in-object.js';
|
|
3
|
-
|
|
4
|
-
const CALLABLE_SIGNAL_SYMBOL = Symbol.for('NodeAccessor');
|
|
5
|
-
function isNodeAccessor(value) {
|
|
6
|
-
return typeof value === 'function' && value && CALLABLE_SIGNAL_SYMBOL in value;
|
|
7
|
-
}
|
|
8
|
-
function isAnySignal(value) {
|
|
9
|
-
return isSignal(value) || isNodeAccessor(value);
|
|
10
|
-
}
|
|
11
|
-
function toWritableSignal(node, injector) {
|
|
12
|
-
const sig = signal(node());
|
|
13
|
-
const originalSet = sig.set.bind(sig);
|
|
14
|
-
const runner = () => {
|
|
15
|
-
originalSet(node());
|
|
16
|
-
};
|
|
17
|
-
if (injector) {
|
|
18
|
-
runInInjectionContext(injector, () => effect(runner));
|
|
19
|
-
} else {
|
|
20
|
-
try {
|
|
21
|
-
effect(runner);
|
|
22
|
-
} catch {
|
|
23
|
-
console.warn('[SignalTree] toWritableSignal called without injection context; pass Injector for reactivity.');
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
sig.set = value => {
|
|
27
|
-
node(value);
|
|
28
|
-
originalSet(value);
|
|
29
|
-
};
|
|
30
|
-
sig.update = updater => {
|
|
31
|
-
sig.set(updater(sig()));
|
|
32
|
-
};
|
|
33
|
-
return sig;
|
|
34
|
-
}
|
|
35
|
-
function composeEnhancers(...enhancers) {
|
|
36
|
-
return tree => enhancers.reduce((t, e) => e(t), tree);
|
|
37
|
-
}
|
|
38
|
-
function createLazySignalTree(obj, equalityFn, basePath = '', memoryManager) {
|
|
39
|
-
const signalCache = new Map();
|
|
40
|
-
const nestedProxies = new Map();
|
|
41
|
-
const nestedCleanups = new Map();
|
|
42
|
-
const cleanup = () => {
|
|
43
|
-
nestedCleanups.forEach(fn => {
|
|
44
|
-
try {
|
|
45
|
-
fn();
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.warn('Error during nested cleanup:', error);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
nestedCleanups.clear();
|
|
51
|
-
signalCache.clear();
|
|
52
|
-
nestedProxies.clear();
|
|
53
|
-
if (memoryManager) {
|
|
54
|
-
memoryManager.dispose();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const proxy = new Proxy(obj, {
|
|
58
|
-
get(target, prop) {
|
|
59
|
-
if (prop === '__cleanup__') return cleanup;
|
|
60
|
-
if (typeof prop === 'symbol') {
|
|
61
|
-
return target[prop];
|
|
62
|
-
}
|
|
63
|
-
if (prop === 'valueOf' || prop === 'toString') {
|
|
64
|
-
return target[prop];
|
|
65
|
-
}
|
|
66
|
-
const key = prop;
|
|
67
|
-
const path = basePath ? `${basePath}.${key}` : key;
|
|
68
|
-
if (!(key in target)) return undefined;
|
|
69
|
-
const value = target[key];
|
|
70
|
-
if (isSignal(value)) return value;
|
|
71
|
-
if (memoryManager) {
|
|
72
|
-
const cached = memoryManager.getSignal(path);
|
|
73
|
-
if (cached) return cached;
|
|
74
|
-
}
|
|
75
|
-
if (signalCache.has(path)) return signalCache.get(path);
|
|
76
|
-
if (nestedProxies.has(path)) return nestedProxies.get(path);
|
|
77
|
-
if (value && typeof value === 'object' && !Array.isArray(value) && !isSignal(value) && !isBuiltInObject(value)) {
|
|
78
|
-
try {
|
|
79
|
-
const nestedProxy = createLazySignalTree(value, equalityFn, path, memoryManager);
|
|
80
|
-
nestedProxies.set(path, nestedProxy);
|
|
81
|
-
const proxyWithCleanup = nestedProxy;
|
|
82
|
-
if (typeof proxyWithCleanup.__cleanup__ === 'function') {
|
|
83
|
-
nestedCleanups.set(path, proxyWithCleanup.__cleanup__);
|
|
84
|
-
}
|
|
85
|
-
return nestedProxy;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.warn(`Failed to create lazy proxy for path "${path}":`, error);
|
|
88
|
-
const fallbackSignal = signal(value, {
|
|
89
|
-
equal: equalityFn
|
|
90
|
-
});
|
|
91
|
-
signalCache.set(path, fallbackSignal);
|
|
92
|
-
if (memoryManager) {
|
|
93
|
-
memoryManager.cacheSignal(path, fallbackSignal);
|
|
94
|
-
}
|
|
95
|
-
return fallbackSignal;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
const newSignal = signal(value, {
|
|
100
|
-
equal: equalityFn
|
|
101
|
-
});
|
|
102
|
-
signalCache.set(path, newSignal);
|
|
103
|
-
if (memoryManager) {
|
|
104
|
-
memoryManager.cacheSignal(path, newSignal);
|
|
105
|
-
}
|
|
106
|
-
return newSignal;
|
|
107
|
-
} catch (error) {
|
|
108
|
-
console.warn(`Failed to create signal for path "${path}":`, error);
|
|
109
|
-
return value;
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
set(target, prop, value) {
|
|
113
|
-
if (typeof prop === 'symbol') {
|
|
114
|
-
target[prop] = value;
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
const key = prop;
|
|
118
|
-
const path = basePath ? `${basePath}.${key}` : key;
|
|
119
|
-
try {
|
|
120
|
-
target[key] = value;
|
|
121
|
-
const cachedSignal = signalCache.get(path);
|
|
122
|
-
if (cachedSignal && 'set' in cachedSignal) {
|
|
123
|
-
cachedSignal.set(value);
|
|
124
|
-
}
|
|
125
|
-
if (nestedProxies.has(path)) {
|
|
126
|
-
const nestedCleanup = nestedCleanups.get(path);
|
|
127
|
-
if (nestedCleanup) {
|
|
128
|
-
nestedCleanup();
|
|
129
|
-
nestedCleanups.delete(path);
|
|
130
|
-
}
|
|
131
|
-
nestedProxies.delete(path);
|
|
132
|
-
}
|
|
133
|
-
return true;
|
|
134
|
-
} catch (error) {
|
|
135
|
-
console.warn(`Failed to set value for path "${path}":`, error);
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
has(target, prop) {
|
|
140
|
-
return prop in target;
|
|
141
|
-
},
|
|
142
|
-
ownKeys(target) {
|
|
143
|
-
return Reflect.ownKeys(target);
|
|
144
|
-
},
|
|
145
|
-
getOwnPropertyDescriptor(target, prop) {
|
|
146
|
-
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
return proxy;
|
|
150
|
-
}
|
|
151
|
-
function unwrap(node) {
|
|
152
|
-
if (node === null || node === undefined) {
|
|
153
|
-
return node;
|
|
154
|
-
}
|
|
155
|
-
if (isNodeAccessor(node)) {
|
|
156
|
-
const result = {};
|
|
157
|
-
for (const key in node) {
|
|
158
|
-
if (!Object.prototype.hasOwnProperty.call(node, key)) continue;
|
|
159
|
-
if (key === 'length' || key === 'prototype') continue;
|
|
160
|
-
if (key === 'name') {
|
|
161
|
-
const value = node[key];
|
|
162
|
-
if (!isSignal(value) && !isNodeAccessor(value)) {
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const value = node[key];
|
|
167
|
-
if (isNodeAccessor(value)) {
|
|
168
|
-
result[key] = unwrap(value);
|
|
169
|
-
} else if (isSignal(value)) {
|
|
170
|
-
const unwrappedValue = value();
|
|
171
|
-
if (typeof unwrappedValue === 'object' && unwrappedValue !== null && !Array.isArray(unwrappedValue) && !isBuiltInObject(unwrappedValue)) {
|
|
172
|
-
result[key] = unwrap(unwrappedValue);
|
|
173
|
-
} else {
|
|
174
|
-
result[key] = unwrappedValue;
|
|
175
|
-
}
|
|
176
|
-
} else if (typeof value === 'object' && value !== null && !Array.isArray(value) && !isBuiltInObject(value)) {
|
|
177
|
-
result[key] = unwrap(value);
|
|
178
|
-
} else {
|
|
179
|
-
result[key] = value;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return result;
|
|
183
|
-
}
|
|
184
|
-
if (isSignal(node)) {
|
|
185
|
-
const value = node();
|
|
186
|
-
if (typeof value === 'object' && value !== null && !Array.isArray(value) && !isBuiltInObject(value)) {
|
|
187
|
-
return unwrap(value);
|
|
188
|
-
}
|
|
189
|
-
return value;
|
|
190
|
-
}
|
|
191
|
-
if (typeof node !== 'object') {
|
|
192
|
-
return node;
|
|
193
|
-
}
|
|
194
|
-
if (Array.isArray(node)) {
|
|
195
|
-
return node;
|
|
196
|
-
}
|
|
197
|
-
if (isBuiltInObject(node)) {
|
|
198
|
-
return node;
|
|
199
|
-
}
|
|
200
|
-
const result = {};
|
|
201
|
-
for (const key in node) {
|
|
202
|
-
if (!Object.prototype.hasOwnProperty.call(node, key)) continue;
|
|
203
|
-
if (key === 'set' || key === 'update') {
|
|
204
|
-
const v = node[key];
|
|
205
|
-
if (typeof v === 'function') continue;
|
|
206
|
-
}
|
|
207
|
-
const value = node[key];
|
|
208
|
-
if (isNodeAccessor(value)) {
|
|
209
|
-
const unwrappedValue = value();
|
|
210
|
-
if (typeof unwrappedValue === 'object' && unwrappedValue !== null && !Array.isArray(unwrappedValue) && !isBuiltInObject(unwrappedValue)) {
|
|
211
|
-
result[key] = unwrap(unwrappedValue);
|
|
212
|
-
} else {
|
|
213
|
-
result[key] = unwrappedValue;
|
|
214
|
-
}
|
|
215
|
-
} else if (isSignal(value)) {
|
|
216
|
-
const unwrappedValue = value();
|
|
217
|
-
if (typeof unwrappedValue === 'object' && unwrappedValue !== null && !Array.isArray(unwrappedValue) && !isBuiltInObject(unwrappedValue)) {
|
|
218
|
-
result[key] = unwrap(unwrappedValue);
|
|
219
|
-
} else {
|
|
220
|
-
result[key] = unwrappedValue;
|
|
221
|
-
}
|
|
222
|
-
} else if (typeof value === 'object' && value !== null && !Array.isArray(value) && !isBuiltInObject(value)) {
|
|
223
|
-
result[key] = unwrap(value);
|
|
224
|
-
} else {
|
|
225
|
-
result[key] = value;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
const symbols = Object.getOwnPropertySymbols(node);
|
|
229
|
-
for (const sym of symbols) {
|
|
230
|
-
const value = node[sym];
|
|
231
|
-
if (isNodeAccessor(value)) {
|
|
232
|
-
const unwrappedValue = value();
|
|
233
|
-
if (typeof unwrappedValue === 'object' && unwrappedValue !== null && !Array.isArray(unwrappedValue) && !isBuiltInObject(unwrappedValue)) {
|
|
234
|
-
result[sym] = unwrap(unwrappedValue);
|
|
235
|
-
} else {
|
|
236
|
-
result[sym] = unwrappedValue;
|
|
237
|
-
}
|
|
238
|
-
} else if (isSignal(value)) {
|
|
239
|
-
const unwrappedValue = value();
|
|
240
|
-
if (typeof unwrappedValue === 'object' && unwrappedValue !== null && !Array.isArray(unwrappedValue) && !isBuiltInObject(unwrappedValue)) {
|
|
241
|
-
result[sym] = unwrap(unwrappedValue);
|
|
242
|
-
} else {
|
|
243
|
-
result[sym] = unwrappedValue;
|
|
244
|
-
}
|
|
245
|
-
} else if (typeof value === 'object' && value !== null && !Array.isArray(value) && !isBuiltInObject(value)) {
|
|
246
|
-
result[sym] = unwrap(value);
|
|
247
|
-
} else {
|
|
248
|
-
result[sym] = value;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return result;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export { composeEnhancers, createLazySignalTree, isAnySignal, isBuiltInObject, isNodeAccessor, toWritableSignal, unwrap };
|
package/dist/lru-cache.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
class LRUCache {
|
|
2
|
-
constructor(maxSize) {
|
|
3
|
-
this.maxSize = maxSize;
|
|
4
|
-
this.cache = new Map();
|
|
5
|
-
if (!Number.isFinite(maxSize) || maxSize <= 0) {
|
|
6
|
-
throw new Error('LRUCache maxSize must be a positive, finite number');
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
set(key, value) {
|
|
10
|
-
if (this.cache.has(key)) {
|
|
11
|
-
this.cache.delete(key);
|
|
12
|
-
}
|
|
13
|
-
this.cache.set(key, value);
|
|
14
|
-
if (this.cache.size > this.maxSize) {
|
|
15
|
-
const oldestKey = this.cache.keys().next().value;
|
|
16
|
-
if (oldestKey !== undefined) {
|
|
17
|
-
this.cache.delete(oldestKey);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
get(key) {
|
|
22
|
-
if (!this.cache.has(key)) return undefined;
|
|
23
|
-
const value = this.cache.get(key);
|
|
24
|
-
if (value !== undefined) {
|
|
25
|
-
this.cache.delete(key);
|
|
26
|
-
this.cache.set(key, value);
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
delete(key) {
|
|
31
|
-
this.cache.delete(key);
|
|
32
|
-
}
|
|
33
|
-
has(key) {
|
|
34
|
-
return this.cache.has(key);
|
|
35
|
-
}
|
|
36
|
-
clear() {
|
|
37
|
-
this.cache.clear();
|
|
38
|
-
}
|
|
39
|
-
size() {
|
|
40
|
-
return this.cache.size;
|
|
41
|
-
}
|
|
42
|
-
forEach(callback) {
|
|
43
|
-
this.cache.forEach((value, key) => callback(value, key));
|
|
44
|
-
}
|
|
45
|
-
entries() {
|
|
46
|
-
return this.cache.entries();
|
|
47
|
-
}
|
|
48
|
-
keys() {
|
|
49
|
-
return this.cache.keys();
|
|
50
|
-
}
|
|
51
|
-
resize(newSize) {
|
|
52
|
-
if (!Number.isFinite(newSize) || newSize <= 0) {
|
|
53
|
-
throw new Error('LRUCache newSize must be a positive, finite number');
|
|
54
|
-
}
|
|
55
|
-
this.maxSize = newSize;
|
|
56
|
-
while (this.cache.size > this.maxSize) {
|
|
57
|
-
const oldestKey = this.cache.keys().next().value;
|
|
58
|
-
if (oldestKey === undefined) break;
|
|
59
|
-
this.cache.delete(oldestKey);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { LRUCache };
|
package/dist/parse-path.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_PATH_CACHE_SIZE } from './constants.js';
|
|
2
|
-
import { LRUCache } from './lru-cache.js';
|
|
3
|
-
|
|
4
|
-
const pathCache = new LRUCache(DEFAULT_PATH_CACHE_SIZE);
|
|
5
|
-
function parsePath(path) {
|
|
6
|
-
const cached = pathCache.get(path);
|
|
7
|
-
if (cached) return cached;
|
|
8
|
-
const segments = path.split('.');
|
|
9
|
-
pathCache.set(path, segments);
|
|
10
|
-
return segments;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { parsePath };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/batching';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { SignalTree } from '../../../lib/types';
|
|
2
|
-
interface BatchingConfig {
|
|
3
|
-
enabled?: boolean;
|
|
4
|
-
maxBatchSize?: number;
|
|
5
|
-
autoFlushDelay?: number;
|
|
6
|
-
batchTimeoutMs?: number;
|
|
7
|
-
}
|
|
8
|
-
interface BatchingSignalTree<T> extends SignalTree<T> {
|
|
9
|
-
batchUpdate(updater: (current: T) => Partial<T>): void;
|
|
10
|
-
}
|
|
11
|
-
export declare function withBatching<T>(config?: BatchingConfig): (tree: SignalTree<T>) => BatchingSignalTree<T>;
|
|
12
|
-
export declare function withHighPerformanceBatching<T>(): (tree: SignalTree<T>) => BatchingSignalTree<T>;
|
|
13
|
-
export declare function flushBatchedUpdates(): void;
|
|
14
|
-
export declare function hasPendingUpdates(): boolean;
|
|
15
|
-
export declare function getBatchQueueSize(): number;
|
|
16
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/computed';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Signal } from '@angular/core';
|
|
2
|
-
import type { TreeNode, SignalTree } from '../../../lib/types';
|
|
3
|
-
export interface ComputedConfig {
|
|
4
|
-
lazy?: boolean;
|
|
5
|
-
memoize?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export type ComputedSignal<T> = Signal<T>;
|
|
8
|
-
export interface ComputedSignalTree<T extends Record<string, unknown>> extends SignalTree<T> {
|
|
9
|
-
computed<U>(computeFn: (tree: TreeNode<T>) => U): ComputedSignal<U>;
|
|
10
|
-
}
|
|
11
|
-
export declare function computedEnhancer(_config?: ComputedConfig): import("../../../lib/types").EnhancerWithMeta<SignalTree<Record<string, unknown>>, ComputedSignalTree<Record<string, unknown>>>;
|
|
12
|
-
export declare function createComputed<T>(dependencies: readonly Signal<unknown>[], computeFn: () => T): ComputedSignal<T>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/devtools';
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Signal } from '@angular/core';
|
|
2
|
-
import type { SignalTree } from '../../../lib/types';
|
|
3
|
-
export interface ModuleMetadata {
|
|
4
|
-
name: string;
|
|
5
|
-
methods: string[];
|
|
6
|
-
addedAt: Date;
|
|
7
|
-
lastActivity: Date;
|
|
8
|
-
operationCount: number;
|
|
9
|
-
averageExecutionTime: number;
|
|
10
|
-
errorCount: number;
|
|
11
|
-
}
|
|
12
|
-
export interface ModularPerformanceMetrics {
|
|
13
|
-
totalUpdates: number;
|
|
14
|
-
moduleUpdates: Record<string, number>;
|
|
15
|
-
modulePerformance: Record<string, number>;
|
|
16
|
-
compositionChain: string[];
|
|
17
|
-
signalGrowth: Record<string, number>;
|
|
18
|
-
memoryDelta: Record<string, number>;
|
|
19
|
-
moduleCacheStats: Record<string, {
|
|
20
|
-
hits: number;
|
|
21
|
-
misses: number;
|
|
22
|
-
}>;
|
|
23
|
-
}
|
|
24
|
-
export interface ModuleActivityTracker {
|
|
25
|
-
trackMethodCall: (module: string, method: string, duration: number) => void;
|
|
26
|
-
trackError: (module: string, error: Error, context?: string) => void;
|
|
27
|
-
getModuleActivity: (module: string) => ModuleMetadata | undefined;
|
|
28
|
-
getAllModules: () => ModuleMetadata[];
|
|
29
|
-
}
|
|
30
|
-
export interface CompositionLogger {
|
|
31
|
-
logComposition: (modules: string[], action: 'with' | 'enhance') => void;
|
|
32
|
-
logMethodExecution: (module: string, method: string, args: unknown[], result: unknown) => void;
|
|
33
|
-
logStateChange: (module: string, path: string, oldValue: unknown, newValue: unknown) => void;
|
|
34
|
-
logPerformanceWarning: (module: string, operation: string, duration: number, threshold: number) => void;
|
|
35
|
-
exportLogs: () => Array<{
|
|
36
|
-
timestamp: Date;
|
|
37
|
-
module: string;
|
|
38
|
-
type: 'composition' | 'method' | 'state' | 'performance';
|
|
39
|
-
data: unknown;
|
|
40
|
-
}>;
|
|
41
|
-
}
|
|
42
|
-
export interface ModularDevToolsInterface<_T = unknown> {
|
|
43
|
-
activityTracker: ModuleActivityTracker;
|
|
44
|
-
logger: CompositionLogger;
|
|
45
|
-
metrics: Signal<ModularPerformanceMetrics>;
|
|
46
|
-
trackComposition: (modules: string[]) => void;
|
|
47
|
-
startModuleProfiling: (module: string) => string;
|
|
48
|
-
endModuleProfiling: (profileId: string) => void;
|
|
49
|
-
connectDevTools: (treeName: string) => void;
|
|
50
|
-
exportDebugSession: () => {
|
|
51
|
-
metrics: ModularPerformanceMetrics;
|
|
52
|
-
modules: ModuleMetadata[];
|
|
53
|
-
logs: Array<unknown>;
|
|
54
|
-
compositionHistory: Array<{
|
|
55
|
-
timestamp: Date;
|
|
56
|
-
chain: string[];
|
|
57
|
-
}>;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export declare function withDevTools<T>(config?: {
|
|
61
|
-
enabled?: boolean;
|
|
62
|
-
treeName?: string;
|
|
63
|
-
enableBrowserDevTools?: boolean;
|
|
64
|
-
enableLogging?: boolean;
|
|
65
|
-
performanceThreshold?: number;
|
|
66
|
-
}): (tree: SignalTree<T>) => SignalTree<T> & {
|
|
67
|
-
__devTools: ModularDevToolsInterface<T>;
|
|
68
|
-
};
|
|
69
|
-
export declare function enableDevTools<T>(treeName?: string): (tree: SignalTree<T>) => SignalTree<T> & {
|
|
70
|
-
__devTools: ModularDevToolsInterface<T>;
|
|
71
|
-
};
|
|
72
|
-
export declare function withFullDevTools<T>(treeName?: string): (tree: SignalTree<T>) => SignalTree<T> & {
|
|
73
|
-
__devTools: ModularDevToolsInterface<T>;
|
|
74
|
-
};
|
|
75
|
-
export declare function withProductionDevTools<T>(): (tree: SignalTree<T>) => SignalTree<T> & {
|
|
76
|
-
__devTools: ModularDevToolsInterface<T>;
|
|
77
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/entities';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { EntitySignal, SignalTree, EntityAwareTreeNode } from '../../../lib/types';
|
|
2
|
-
interface EntitiesEnhancerConfig {
|
|
3
|
-
enabled?: boolean;
|
|
4
|
-
}
|
|
5
|
-
export declare function withEntities(config?: EntitiesEnhancerConfig): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
|
|
6
|
-
state: EntityAwareTreeNode<T>;
|
|
7
|
-
$: EntityAwareTreeNode<T>;
|
|
8
|
-
entities<E, K extends string | number>(path: keyof T | string): EntitySignal<E, K>;
|
|
9
|
-
};
|
|
10
|
-
export declare function enableEntities(): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
|
|
11
|
-
state: EntityAwareTreeNode<T>;
|
|
12
|
-
$: EntityAwareTreeNode<T>;
|
|
13
|
-
entities<E, K extends string | number>(path: keyof T | string): EntitySignal<E, K>;
|
|
14
|
-
};
|
|
15
|
-
export declare function withHighPerformanceEntities(): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
|
|
16
|
-
state: EntityAwareTreeNode<T>;
|
|
17
|
-
$: EntityAwareTreeNode<T>;
|
|
18
|
-
entities<E, K extends string | number>(path: keyof T | string): EntitySignal<E, K>;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
package/src/enhancers/index.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { EnhancerMeta, EnhancerWithMeta } from '../lib/types';
|
|
2
|
-
export declare function createEnhancer<I = unknown, O = unknown>(meta: EnhancerMeta, enhancerFn: (input: I) => O): EnhancerWithMeta<I, O>;
|
|
3
|
-
export declare function resolveEnhancerOrder(enhancers: EnhancerWithMeta<unknown, unknown>[], availableCapabilities?: Set<string>, debugMode?: boolean): EnhancerWithMeta<unknown, unknown>[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/memoization';
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { SignalTree } from '../../../lib/types';
|
|
2
|
-
export interface MemoizedSignalTree<T> extends SignalTree<T> {
|
|
3
|
-
memoizedUpdate: (updater: (current: T) => Partial<T>, cacheKey?: string) => void;
|
|
4
|
-
clearMemoCache: (key?: string) => void;
|
|
5
|
-
getCacheStats: () => {
|
|
6
|
-
size: number;
|
|
7
|
-
hitRate: number;
|
|
8
|
-
totalHits: number;
|
|
9
|
-
totalMisses: number;
|
|
10
|
-
keys: string[];
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export declare function cleanupMemoizationCache(): void;
|
|
14
|
-
export interface MemoizationConfig {
|
|
15
|
-
enabled?: boolean;
|
|
16
|
-
maxCacheSize?: number;
|
|
17
|
-
ttl?: number;
|
|
18
|
-
equality?: 'deep' | 'shallow' | 'reference';
|
|
19
|
-
enableLRU?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export declare function memoize<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn, keyFn?: (...args: TArgs) => string, config?: MemoizationConfig): (...args: TArgs) => TReturn;
|
|
22
|
-
export declare function memoizeShallow<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn, keyFn?: (...args: TArgs) => string): (...args: TArgs) => TReturn;
|
|
23
|
-
export declare function memoizeReference<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn, keyFn?: (...args: TArgs) => string): (...args: TArgs) => TReturn;
|
|
24
|
-
export declare const MEMOIZATION_PRESETS: {
|
|
25
|
-
readonly selector: {
|
|
26
|
-
readonly equality: "reference";
|
|
27
|
-
readonly maxCacheSize: 10;
|
|
28
|
-
readonly enableLRU: false;
|
|
29
|
-
readonly ttl: undefined;
|
|
30
|
-
};
|
|
31
|
-
readonly computed: {
|
|
32
|
-
readonly equality: "shallow";
|
|
33
|
-
readonly maxCacheSize: 100;
|
|
34
|
-
readonly enableLRU: false;
|
|
35
|
-
readonly ttl: undefined;
|
|
36
|
-
};
|
|
37
|
-
readonly deepState: {
|
|
38
|
-
readonly equality: "deep";
|
|
39
|
-
readonly maxCacheSize: 1000;
|
|
40
|
-
readonly enableLRU: true;
|
|
41
|
-
readonly ttl: number;
|
|
42
|
-
};
|
|
43
|
-
readonly highFrequency: {
|
|
44
|
-
readonly equality: "reference";
|
|
45
|
-
readonly maxCacheSize: 5;
|
|
46
|
-
readonly enableLRU: false;
|
|
47
|
-
readonly ttl: undefined;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
export declare function withSelectorMemoization<T>(): (tree: SignalTree<T>) => MemoizedSignalTree<T>;
|
|
51
|
-
export declare function withComputedMemoization<T>(): (tree: SignalTree<T>) => MemoizedSignalTree<T>;
|
|
52
|
-
export declare function withDeepStateMemoization<T>(): (tree: SignalTree<T>) => MemoizedSignalTree<T>;
|
|
53
|
-
export declare function withHighFrequencyMemoization<T>(): (tree: SignalTree<T>) => MemoizedSignalTree<T>;
|
|
54
|
-
export declare function withMemoization<T>(config?: MemoizationConfig): (tree: SignalTree<T>) => MemoizedSignalTree<T>;
|
|
55
|
-
export declare function enableMemoization<T>(): (tree: SignalTree<T>) => MemoizedSignalTree<T>;
|
|
56
|
-
export declare function withHighPerformanceMemoization<T>(): (tree: SignalTree<T>) => MemoizedSignalTree<T>;
|
|
57
|
-
export declare function withLightweightMemoization<T>(): (tree: SignalTree<T>) => MemoizedSignalTree<T>;
|
|
58
|
-
export declare function withShallowMemoization<T>(): (tree: SignalTree<T>) => MemoizedSignalTree<T>;
|
|
59
|
-
export declare function clearAllCaches(): void;
|
|
60
|
-
export declare function getGlobalCacheStats(): {
|
|
61
|
-
treeCount: number;
|
|
62
|
-
totalSize: number;
|
|
63
|
-
totalHits: number;
|
|
64
|
-
averageCacheSize: number;
|
|
65
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/presets';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TreeConfig } from '../../../lib/types';
|
|
2
|
-
export type TreePreset = 'basic' | 'performance' | 'development' | 'production';
|
|
3
|
-
export declare const TREE_PRESETS: Record<TreePreset, Partial<TreeConfig>>;
|
|
4
|
-
export declare function createPresetConfig(preset: TreePreset, overrides?: Partial<TreeConfig>): TreeConfig;
|
|
5
|
-
export declare function validatePreset(preset: TreePreset): boolean;
|
|
6
|
-
export declare function getAvailablePresets(): TreePreset[];
|
|
7
|
-
export declare function combinePresets(presets: TreePreset[], overrides?: Partial<TreeConfig>): TreeConfig;
|
|
8
|
-
export declare function createDevTree(overrides?: Partial<TreeConfig>): {
|
|
9
|
-
readonly config: TreeConfig;
|
|
10
|
-
readonly enhancer: (tree: import("../../memoization/lib/memoization").MemoizedSignalTree<unknown>) => import("../../memoization/lib/memoization").MemoizedSignalTree<unknown>;
|
|
11
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const TYPE_MARKERS: {
|
|
2
|
-
readonly DATE: "§d";
|
|
3
|
-
readonly REGEXP: "§r";
|
|
4
|
-
readonly MAP: "§m";
|
|
5
|
-
readonly SET: "§s";
|
|
6
|
-
readonly UNDEFINED: "§u";
|
|
7
|
-
readonly NAN: "§n";
|
|
8
|
-
readonly INFINITY: "§i";
|
|
9
|
-
readonly NEG_INFINITY: "§-i";
|
|
10
|
-
readonly BIGINT: "§b";
|
|
11
|
-
readonly SYMBOL: "§y";
|
|
12
|
-
readonly FUNCTION: "§f";
|
|
13
|
-
readonly CIRCULAR: "§c";
|
|
14
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { SignalTree } from '../../../lib/types';
|
|
2
|
-
import type { EnhancerWithMeta } from '../../../lib/types';
|
|
3
|
-
export interface SerializationConfig {
|
|
4
|
-
includeMetadata?: boolean;
|
|
5
|
-
replacer?: (key: string, value: unknown) => unknown;
|
|
6
|
-
reviver?: (key: string, value: unknown) => unknown;
|
|
7
|
-
preserveTypes?: boolean;
|
|
8
|
-
maxDepth?: number;
|
|
9
|
-
handleCircular?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface SerializedState<T = unknown> {
|
|
12
|
-
data: T;
|
|
13
|
-
metadata?: {
|
|
14
|
-
timestamp: number;
|
|
15
|
-
version: string;
|
|
16
|
-
appVersion?: string;
|
|
17
|
-
types?: Record<string, string>;
|
|
18
|
-
circularRefs?: Array<{
|
|
19
|
-
path: string;
|
|
20
|
-
targetPath: string;
|
|
21
|
-
}>;
|
|
22
|
-
nodeMap?: Record<string, 'b' | 'r'>;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export interface SerializableSignalTree<T> extends SignalTree<T> {
|
|
26
|
-
$: any;
|
|
27
|
-
serialize(config?: SerializationConfig): string;
|
|
28
|
-
deserialize(json: string, config?: SerializationConfig): void;
|
|
29
|
-
toJSON(): T;
|
|
30
|
-
fromJSON(data: T, metadata?: SerializedState<T>['metadata']): void;
|
|
31
|
-
snapshot(): SerializedState<T>;
|
|
32
|
-
restore(snapshot: SerializedState<T>): void;
|
|
33
|
-
}
|
|
34
|
-
export interface PersistenceMethods {
|
|
35
|
-
save(): Promise<void>;
|
|
36
|
-
load(): Promise<void>;
|
|
37
|
-
clear(): Promise<void>;
|
|
38
|
-
__flushAutoSave?: () => Promise<void>;
|
|
39
|
-
}
|
|
40
|
-
export declare function withSerialization<T extends Record<string, unknown> = Record<string, unknown>>(defaultConfig?: SerializationConfig): EnhancerWithMeta<SignalTree<T>, SerializableSignalTree<T>>;
|
|
41
|
-
export declare function enableSerialization<T extends Record<string, unknown> = Record<string, unknown>>(): EnhancerWithMeta<SignalTree<T>, SerializableSignalTree<T>>;
|
|
42
|
-
export interface StorageAdapter {
|
|
43
|
-
getItem(key: string): string | null | Promise<string | null>;
|
|
44
|
-
setItem(key: string, value: string): void | Promise<void>;
|
|
45
|
-
removeItem(key: string): void | Promise<void>;
|
|
46
|
-
}
|
|
47
|
-
export interface PersistenceConfig extends SerializationConfig {
|
|
48
|
-
key: string;
|
|
49
|
-
storage?: StorageAdapter;
|
|
50
|
-
autoSave?: boolean;
|
|
51
|
-
debounceMs?: number;
|
|
52
|
-
autoLoad?: boolean;
|
|
53
|
-
skipCache?: boolean;
|
|
54
|
-
}
|
|
55
|
-
export declare function withPersistence<T extends Record<string, unknown> = Record<string, unknown>>(config: PersistenceConfig): EnhancerWithMeta<SignalTree<T>, SerializableSignalTree<T> & PersistenceMethods>;
|
|
56
|
-
export declare function createStorageAdapter(getItem: (key: string) => string | null | Promise<string | null>, setItem: (key: string, value: string) => void | Promise<void>, removeItem: (key: string) => void | Promise<void>): StorageAdapter;
|
|
57
|
-
export declare function createIndexedDBAdapter(dbName?: string, storeName?: string): StorageAdapter;
|
|
58
|
-
export declare function applySerialization<T extends Record<string, unknown>>(tree: SignalTree<T>): SerializableSignalTree<T>;
|
|
59
|
-
export declare function applyPersistence<T extends Record<string, unknown>>(tree: SignalTree<T>, cfg: PersistenceConfig): SerializableSignalTree<T> & PersistenceMethods;
|