@signaltree/core 5.1.6 → 6.0.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/README.md +76 -76
- package/dist/enhancers/batching/{lib/batching.js → batching.js} +45 -17
- package/dist/enhancers/devtools/{lib/devtools.js → devtools.js} +83 -98
- package/dist/enhancers/effects/effects.js +66 -0
- package/dist/enhancers/entities/entities.js +51 -0
- package/dist/enhancers/memoization/{lib/memoization.js → memoization.js} +33 -23
- package/dist/enhancers/presets/lib/presets.js +5 -65
- package/dist/enhancers/serialization/{lib/serialization.js → serialization.js} +12 -18
- package/dist/enhancers/time-travel/{lib/time-travel.js → time-travel.js} +62 -24
- package/dist/enhancers/time-travel/utils.js +11 -0
- package/dist/index.js +8 -8
- package/dist/lib/async-helpers.js +6 -6
- package/dist/lib/presets.js +21 -0
- package/dist/lib/signal-tree.js +156 -496
- package/dist/lib/types.js +1 -1
- package/dist/lib/utils.js +40 -2
- package/package.json +1 -6
- package/src/enhancers/batching/batching.d.ts +11 -0
- package/src/enhancers/batching/index.d.ts +1 -1
- package/src/enhancers/devtools/{lib/devtools.d.ts → devtools.d.ts} +10 -19
- package/src/enhancers/devtools/devtools.types.d.ts +1 -0
- package/src/enhancers/devtools/index.d.ts +1 -1
- package/src/enhancers/effects/effects.d.ts +9 -0
- package/src/enhancers/effects/effects.types.d.ts +1 -0
- package/src/enhancers/effects/index.d.ts +1 -0
- package/src/enhancers/entities/entities.d.ts +11 -0
- package/src/enhancers/entities/entities.types.d.ts +1 -0
- package/src/enhancers/entities/index.d.ts +1 -1
- package/src/enhancers/index.d.ts +3 -3
- package/src/enhancers/memoization/index.d.ts +1 -1
- package/src/enhancers/memoization/memoization.d.ts +54 -0
- package/src/enhancers/memoization/memoization.types.d.ts +1 -0
- package/src/enhancers/presets/lib/presets.d.ts +3 -6
- package/src/enhancers/serialization/index.d.ts +1 -1
- package/src/{serialization.d.ts → enhancers/serialization/serialization.d.ts} +17 -8
- package/src/enhancers/test-helpers/types-equals.d.ts +2 -0
- package/src/enhancers/time-travel/index.d.ts +1 -1
- package/src/enhancers/time-travel/time-travel.d.ts +10 -0
- package/src/enhancers/time-travel/time-travel.types.d.ts +1 -0
- package/src/enhancers/time-travel/utils.d.ts +2 -0
- package/src/enhancers/types.d.ts +1 -74
- package/src/enhancers/typing/helpers-types.d.ts +2 -0
- package/src/index.d.ts +7 -8
- package/src/lib/async-helpers.d.ts +2 -2
- package/src/lib/dev-proxy.d.ts +3 -0
- package/src/lib/presets.d.ts +34 -0
- package/src/lib/signal-tree.d.ts +2 -7
- package/src/lib/types.d.ts +121 -90
- package/src/lib/utils.d.ts +4 -0
- package/dist/deep-clone.js +0 -80
- package/dist/enhancers/computed/lib/computed.js +0 -21
- package/dist/enhancers/entities/lib/entities.js +0 -66
- 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/src/async-helpers.d.ts +0 -8
- package/src/batching.d.ts +0 -16
- package/src/computed.d.ts +0 -12
- package/src/constants.d.ts +0 -14
- package/src/devtools.d.ts +0 -77
- package/src/diff-engine.d.ts +0 -33
- package/src/enhancers/batching/lib/batching.d.ts +0 -16
- package/src/enhancers/computed/index.d.ts +0 -1
- package/src/enhancers/computed/lib/computed.d.ts +0 -12
- package/src/enhancers/entities/lib/entities.d.ts +0 -17
- package/src/enhancers/memoization/lib/memoization.d.ts +0 -65
- package/src/enhancers/presets/test-setup.d.ts +0 -3
- package/src/enhancers/serialization/lib/serialization.d.ts +0 -59
- 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/entities.d.ts +0 -28
- package/src/memoization.d.ts +0 -65
- package/src/memory-manager.d.ts +0 -30
- package/src/path-index.d.ts +0 -25
- package/src/path-notifier.d.ts +0 -12
- package/src/presets.d.ts +0 -11
- package/src/security-validator.d.ts +0 -33
- package/src/signal-tree.d.ts +0 -8
- package/src/test-setup.d.ts +0 -3
- package/src/time-travel.d.ts +0 -36
- package/src/types.d.ts +0 -436
- package/src/update-engine.d.ts +0 -32
- package/src/utils.d.ts +0 -1
- /package/src/{entity-signal.d.ts → enhancers/batching/batching.types.d.ts} +0 -0
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { isSignal } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
class TrieNode {
|
|
4
|
-
value = null;
|
|
5
|
-
children = new Map();
|
|
6
|
-
}
|
|
7
|
-
class PathIndex {
|
|
8
|
-
root = new TrieNode();
|
|
9
|
-
pathCache = new Map();
|
|
10
|
-
stats = {
|
|
11
|
-
hits: 0,
|
|
12
|
-
misses: 0,
|
|
13
|
-
sets: 0,
|
|
14
|
-
cleanups: 0
|
|
15
|
-
};
|
|
16
|
-
set(path, signal) {
|
|
17
|
-
const pathStr = this.pathToString(path);
|
|
18
|
-
const ref = new WeakRef(signal);
|
|
19
|
-
let node = this.root;
|
|
20
|
-
for (const segment of path) {
|
|
21
|
-
const key = String(segment);
|
|
22
|
-
if (!node.children.has(key)) {
|
|
23
|
-
node.children.set(key, new TrieNode());
|
|
24
|
-
}
|
|
25
|
-
const nextNode = node.children.get(key);
|
|
26
|
-
if (!nextNode) {
|
|
27
|
-
throw new Error(`Failed to get node for key: ${key}`);
|
|
28
|
-
}
|
|
29
|
-
node = nextNode;
|
|
30
|
-
}
|
|
31
|
-
node.value = ref;
|
|
32
|
-
this.pathCache.set(pathStr, ref);
|
|
33
|
-
this.stats.sets++;
|
|
34
|
-
}
|
|
35
|
-
get(path) {
|
|
36
|
-
const pathStr = this.pathToString(path);
|
|
37
|
-
const cached = this.pathCache.get(pathStr);
|
|
38
|
-
if (cached) {
|
|
39
|
-
const value = cached.deref();
|
|
40
|
-
if (value) {
|
|
41
|
-
this.stats.hits++;
|
|
42
|
-
return value;
|
|
43
|
-
}
|
|
44
|
-
this.pathCache.delete(pathStr);
|
|
45
|
-
this.stats.cleanups++;
|
|
46
|
-
}
|
|
47
|
-
let node = this.root;
|
|
48
|
-
for (const segment of path) {
|
|
49
|
-
const key = String(segment);
|
|
50
|
-
node = node.children.get(key);
|
|
51
|
-
if (!node) {
|
|
52
|
-
this.stats.misses++;
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (node.value) {
|
|
57
|
-
const value = node.value.deref();
|
|
58
|
-
if (value) {
|
|
59
|
-
this.pathCache.set(pathStr, node.value);
|
|
60
|
-
this.stats.hits++;
|
|
61
|
-
return value;
|
|
62
|
-
}
|
|
63
|
-
node.value = null;
|
|
64
|
-
this.stats.cleanups++;
|
|
65
|
-
}
|
|
66
|
-
this.stats.misses++;
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
has(path) {
|
|
70
|
-
return this.get(path) !== null;
|
|
71
|
-
}
|
|
72
|
-
getByPrefix(prefix) {
|
|
73
|
-
const results = new Map();
|
|
74
|
-
let node = this.root;
|
|
75
|
-
for (const segment of prefix) {
|
|
76
|
-
const key = String(segment);
|
|
77
|
-
node = node.children.get(key);
|
|
78
|
-
if (!node) {
|
|
79
|
-
return results;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
this.collectDescendants(node, [], results);
|
|
83
|
-
return results;
|
|
84
|
-
}
|
|
85
|
-
delete(path) {
|
|
86
|
-
const pathStr = this.pathToString(path);
|
|
87
|
-
this.pathCache.delete(pathStr);
|
|
88
|
-
let node = this.root;
|
|
89
|
-
const nodes = [node];
|
|
90
|
-
for (const segment of path) {
|
|
91
|
-
const key = String(segment);
|
|
92
|
-
node = node.children.get(key);
|
|
93
|
-
if (!node) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
nodes.push(node);
|
|
97
|
-
}
|
|
98
|
-
const hadValue = node.value !== null;
|
|
99
|
-
node.value = null;
|
|
100
|
-
for (let i = nodes.length - 1; i > 0; i--) {
|
|
101
|
-
const current = nodes[i];
|
|
102
|
-
if (current.value === null && current.children.size === 0) {
|
|
103
|
-
const parent = nodes[i - 1];
|
|
104
|
-
const segment = path[i - 1];
|
|
105
|
-
parent.children.delete(String(segment));
|
|
106
|
-
} else {
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return hadValue;
|
|
111
|
-
}
|
|
112
|
-
clear() {
|
|
113
|
-
this.root = new TrieNode();
|
|
114
|
-
this.pathCache.clear();
|
|
115
|
-
}
|
|
116
|
-
getStats() {
|
|
117
|
-
const total = this.stats.hits + this.stats.misses;
|
|
118
|
-
const hitRate = total > 0 ? this.stats.hits / total : 0;
|
|
119
|
-
return {
|
|
120
|
-
...this.stats,
|
|
121
|
-
hitRate,
|
|
122
|
-
cacheSize: this.pathCache.size
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
buildFromTree(tree, path = []) {
|
|
126
|
-
if (!tree) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (isSignal(tree)) {
|
|
130
|
-
this.set(path, tree);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (typeof tree !== 'object') {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
for (const [key, value] of Object.entries(tree)) {
|
|
137
|
-
this.buildFromTree(value, [...path, key]);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
pathToString(path) {
|
|
141
|
-
return path.join('.');
|
|
142
|
-
}
|
|
143
|
-
collectDescendants(node, currentPath, results) {
|
|
144
|
-
if (node.value) {
|
|
145
|
-
const value = node.value.deref();
|
|
146
|
-
if (value) {
|
|
147
|
-
results.set(this.pathToString(currentPath), value);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
for (const [key, child] of node.children) {
|
|
151
|
-
this.collectDescendants(child, [...currentPath, key], results);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export { PathIndex };
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { isSignal } from '@angular/core';
|
|
2
|
-
import { DiffEngine, ChangeType } from './diff-engine.js';
|
|
3
|
-
import { PathIndex } from './path-index.js';
|
|
4
|
-
|
|
5
|
-
class OptimizedUpdateEngine {
|
|
6
|
-
pathIndex;
|
|
7
|
-
diffEngine;
|
|
8
|
-
constructor(tree) {
|
|
9
|
-
this.pathIndex = new PathIndex();
|
|
10
|
-
this.diffEngine = new DiffEngine();
|
|
11
|
-
this.pathIndex.buildFromTree(tree);
|
|
12
|
-
}
|
|
13
|
-
update(tree, updates, options = {}) {
|
|
14
|
-
const startTime = performance.now();
|
|
15
|
-
const diffOptions = {};
|
|
16
|
-
if (options.maxDepth !== undefined) diffOptions.maxDepth = options.maxDepth;
|
|
17
|
-
if (options.ignoreArrayOrder !== undefined) diffOptions.ignoreArrayOrder = options.ignoreArrayOrder;
|
|
18
|
-
if (options.equalityFn !== undefined) diffOptions.equalityFn = options.equalityFn;
|
|
19
|
-
const diff = this.diffEngine.diff(tree, updates, diffOptions);
|
|
20
|
-
if (diff.changes.length === 0) {
|
|
21
|
-
return {
|
|
22
|
-
changed: false,
|
|
23
|
-
duration: performance.now() - startTime,
|
|
24
|
-
changedPaths: []
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
const patches = this.createPatches(diff.changes);
|
|
28
|
-
const sortedPatches = this.sortPatches(patches);
|
|
29
|
-
const result = options.batch ? this.batchApplyPatches(tree, sortedPatches, options.batchSize) : this.applyPatches(tree, sortedPatches);
|
|
30
|
-
const duration = performance.now() - startTime;
|
|
31
|
-
return {
|
|
32
|
-
changed: true,
|
|
33
|
-
duration,
|
|
34
|
-
changedPaths: result.appliedPaths,
|
|
35
|
-
stats: {
|
|
36
|
-
totalPaths: diff.changes.length,
|
|
37
|
-
optimizedPaths: patches.length,
|
|
38
|
-
batchedUpdates: result.batchCount
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
rebuildIndex(tree) {
|
|
43
|
-
this.pathIndex.clear();
|
|
44
|
-
this.pathIndex.buildFromTree(tree);
|
|
45
|
-
}
|
|
46
|
-
getIndexStats() {
|
|
47
|
-
return this.pathIndex.getStats();
|
|
48
|
-
}
|
|
49
|
-
createPatches(changes) {
|
|
50
|
-
const patches = [];
|
|
51
|
-
const processedPaths = new Set();
|
|
52
|
-
for (const change of changes) {
|
|
53
|
-
const pathStr = change.path.join('.');
|
|
54
|
-
let skipPath = false;
|
|
55
|
-
for (const processed of processedPaths) {
|
|
56
|
-
if (pathStr.startsWith(processed + '.')) {
|
|
57
|
-
skipPath = true;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (skipPath) {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
const patch = this.createPatch(change);
|
|
65
|
-
patches.push(patch);
|
|
66
|
-
processedPaths.add(pathStr);
|
|
67
|
-
if (change.type === ChangeType.REPLACE && typeof change.value === 'object') {
|
|
68
|
-
processedPaths.add(pathStr);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return patches;
|
|
72
|
-
}
|
|
73
|
-
createPatch(change) {
|
|
74
|
-
return {
|
|
75
|
-
type: change.type,
|
|
76
|
-
path: change.path,
|
|
77
|
-
value: change.value,
|
|
78
|
-
oldValue: change.oldValue,
|
|
79
|
-
priority: this.calculatePriority(change),
|
|
80
|
-
signal: this.pathIndex.get(change.path)
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
calculatePriority(change) {
|
|
84
|
-
let priority = 0;
|
|
85
|
-
priority += (10 - change.path.length) * 10;
|
|
86
|
-
if (change.path.some(p => typeof p === 'number')) {
|
|
87
|
-
priority -= 20;
|
|
88
|
-
}
|
|
89
|
-
if (change.type === ChangeType.REPLACE) {
|
|
90
|
-
priority += 30;
|
|
91
|
-
}
|
|
92
|
-
return priority;
|
|
93
|
-
}
|
|
94
|
-
sortPatches(patches) {
|
|
95
|
-
return patches.sort((a, b) => {
|
|
96
|
-
if (a.priority !== b.priority) {
|
|
97
|
-
return b.priority - a.priority;
|
|
98
|
-
}
|
|
99
|
-
return a.path.length - b.path.length;
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
applyPatches(tree, patches) {
|
|
103
|
-
const appliedPaths = [];
|
|
104
|
-
let updateCount = 0;
|
|
105
|
-
for (const patch of patches) {
|
|
106
|
-
if (this.applyPatch(patch, tree)) {
|
|
107
|
-
appliedPaths.push(patch.path.join('.'));
|
|
108
|
-
updateCount++;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
appliedPaths,
|
|
113
|
-
updateCount,
|
|
114
|
-
batchCount: 1
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
batchApplyPatches(tree, patches, batchSize = 50) {
|
|
118
|
-
const batches = [];
|
|
119
|
-
for (let i = 0; i < patches.length; i += batchSize) {
|
|
120
|
-
batches.push(patches.slice(i, i + batchSize));
|
|
121
|
-
}
|
|
122
|
-
const appliedPaths = [];
|
|
123
|
-
let updateCount = 0;
|
|
124
|
-
for (const currentBatch of batches) {
|
|
125
|
-
for (const patch of currentBatch) {
|
|
126
|
-
if (this.applyPatch(patch, tree)) {
|
|
127
|
-
appliedPaths.push(patch.path.join('.'));
|
|
128
|
-
updateCount++;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
appliedPaths,
|
|
134
|
-
updateCount,
|
|
135
|
-
batchCount: batches.length
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
applyPatch(patch, tree) {
|
|
139
|
-
try {
|
|
140
|
-
if (patch.signal && isSignal(patch.signal) && 'set' in patch.signal) {
|
|
141
|
-
const currentValue = patch.signal();
|
|
142
|
-
if (this.isEqual(currentValue, patch.value)) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
patch.signal.set(patch.value);
|
|
146
|
-
if (patch.type === ChangeType.ADD && patch.value !== undefined) {
|
|
147
|
-
this.pathIndex.set(patch.path, patch.signal);
|
|
148
|
-
}
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
let current = tree;
|
|
152
|
-
for (let i = 0; i < patch.path.length - 1; i++) {
|
|
153
|
-
const key = patch.path[i];
|
|
154
|
-
current = current[key];
|
|
155
|
-
if (!current || typeof current !== 'object') {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const lastKey = patch.path[patch.path.length - 1];
|
|
160
|
-
if (this.isEqual(current[lastKey], patch.value)) {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
current[lastKey] = patch.value;
|
|
164
|
-
return true;
|
|
165
|
-
} catch (error) {
|
|
166
|
-
console.error(`Failed to apply patch at ${patch.path.join('.')}:`, error);
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
isEqual(a, b) {
|
|
171
|
-
if (a === b) {
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
if (typeof a !== typeof b) {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
if (typeof a !== 'object' || a === null || b === null) {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
try {
|
|
181
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
182
|
-
} catch {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export { OptimizedUpdateEngine };
|
package/src/async-helpers.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SignalTree } from './types';
|
|
2
|
-
export declare function createAsyncOperation<T, TResult>(name: string, operation: () => Promise<TResult>): (tree: SignalTree<T>) => Promise<TResult>;
|
|
3
|
-
export declare function trackAsync<T>(operation: () => Promise<T>): {
|
|
4
|
-
pending: import("@angular/core").Signal<boolean>;
|
|
5
|
-
error: import("@angular/core").Signal<Error | null>;
|
|
6
|
-
result: import("@angular/core").Signal<T | null>;
|
|
7
|
-
execute: () => Promise<T>;
|
|
8
|
-
};
|
package/src/batching.d.ts
DELETED
|
@@ -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 {};
|
package/src/computed.d.ts
DELETED
|
@@ -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>;
|
package/src/constants.d.ts
DELETED
|
@@ -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
|
-
};
|
package/src/devtools.d.ts
DELETED
|
@@ -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
|
-
};
|
package/src/diff-engine.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Path } from './path-index';
|
|
2
|
-
export declare enum ChangeType {
|
|
3
|
-
ADD = "add",
|
|
4
|
-
UPDATE = "update",
|
|
5
|
-
DELETE = "delete",
|
|
6
|
-
REPLACE = "replace"
|
|
7
|
-
}
|
|
8
|
-
export interface Change {
|
|
9
|
-
type: ChangeType;
|
|
10
|
-
path: Path;
|
|
11
|
-
value?: unknown;
|
|
12
|
-
oldValue?: unknown;
|
|
13
|
-
}
|
|
14
|
-
export interface Diff {
|
|
15
|
-
changes: Change[];
|
|
16
|
-
hasChanges: boolean;
|
|
17
|
-
}
|
|
18
|
-
export interface DiffOptions {
|
|
19
|
-
maxDepth?: number;
|
|
20
|
-
detectDeletions?: boolean;
|
|
21
|
-
ignoreArrayOrder?: boolean;
|
|
22
|
-
equalityFn?: (a: unknown, b: unknown) => boolean;
|
|
23
|
-
keyValidator?: (key: string) => boolean;
|
|
24
|
-
}
|
|
25
|
-
export declare class DiffEngine {
|
|
26
|
-
private defaultOptions;
|
|
27
|
-
diff(current: unknown, updates: unknown, options?: DiffOptions): Diff;
|
|
28
|
-
private traverse;
|
|
29
|
-
private diffArrays;
|
|
30
|
-
private diffArraysOrdered;
|
|
31
|
-
private diffArraysUnordered;
|
|
32
|
-
private stringify;
|
|
33
|
-
}
|
|
@@ -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,17 +0,0 @@
|
|
|
1
|
-
import type { 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
|
-
};
|
|
9
|
-
export declare function enableEntities(): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
|
|
10
|
-
state: EntityAwareTreeNode<T>;
|
|
11
|
-
$: EntityAwareTreeNode<T>;
|
|
12
|
-
};
|
|
13
|
-
export declare function withHighPerformanceEntities(): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
|
|
14
|
-
state: EntityAwareTreeNode<T>;
|
|
15
|
-
$: EntityAwareTreeNode<T>;
|
|
16
|
-
};
|
|
17
|
-
export {};
|
|
@@ -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
|
-
};
|