@signaltree/core 4.0.15 → 4.1.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.
- package/README.md +106 -38
- package/dist/constants.js +6 -0
- package/dist/deep-clone.js +80 -0
- package/dist/deep-equal.js +41 -0
- package/dist/enhancers/batching/lib/batching.js +141 -135
- package/dist/enhancers/computed/lib/computed.js +18 -16
- package/dist/enhancers/devtools/lib/devtools.js +303 -260
- package/dist/enhancers/entities/lib/entities.js +109 -104
- package/dist/enhancers/index.js +65 -77
- package/dist/enhancers/memoization/lib/memoization.js +339 -351
- package/dist/enhancers/middleware/lib/async-helpers.js +71 -79
- package/dist/enhancers/middleware/lib/middleware.js +126 -169
- package/dist/enhancers/presets/lib/presets.js +82 -71
- package/dist/enhancers/serialization/constants.js +14 -13
- package/dist/enhancers/serialization/lib/serialization.js +615 -623
- package/dist/enhancers/time-travel/lib/time-travel.js +178 -177
- package/dist/index.d.ts +1 -17
- package/dist/index.js +19 -16
- package/dist/is-built-in-object.js +23 -0
- package/dist/lib/constants.js +51 -55
- package/dist/lib/memory/memory-manager.js +152 -154
- package/dist/lib/performance/diff-engine.js +141 -141
- package/dist/lib/performance/path-index.js +139 -137
- package/dist/lib/performance/update-engine.js +171 -176
- package/dist/lib/security/security-validator.js +110 -128
- package/dist/lib/signal-tree.js +577 -611
- package/dist/lib/types.js +3 -9
- package/dist/lib/utils.js +236 -268
- package/dist/lru-cache.js +64 -0
- package/dist/parse-path.js +13 -0
- package/package.json +30 -16
- package/src/index.d.ts +17 -0
- package/{dist → src}/lib/utils.d.ts +1 -0
- package/dist/enhancers/batching/index.js +0 -1
- package/dist/enhancers/batching/jest.config.js +0 -21
- package/dist/enhancers/batching/test-setup.js +0 -5
- package/dist/enhancers/computed/index.js +0 -1
- package/dist/enhancers/computed/jest.config.js +0 -21
- package/dist/enhancers/devtools/index.js +0 -1
- package/dist/enhancers/devtools/jest.config.js +0 -21
- package/dist/enhancers/devtools/test-setup.js +0 -5
- package/dist/enhancers/entities/index.js +0 -1
- package/dist/enhancers/entities/jest.config.js +0 -21
- package/dist/enhancers/entities/test-setup.js +0 -5
- package/dist/enhancers/memoization/index.js +0 -1
- package/dist/enhancers/memoization/jest.config.js +0 -21
- package/dist/enhancers/memoization/test-setup.js +0 -5
- package/dist/enhancers/middleware/index.js +0 -2
- package/dist/enhancers/middleware/jest.config.js +0 -21
- package/dist/enhancers/middleware/test-setup.js +0 -5
- package/dist/enhancers/presets/index.js +0 -1
- package/dist/enhancers/presets/jest.config.js +0 -21
- package/dist/enhancers/presets/test-setup.js +0 -5
- package/dist/enhancers/serialization/index.js +0 -2
- package/dist/enhancers/serialization/jest.config.js +0 -21
- package/dist/enhancers/serialization/test-setup.js +0 -5
- package/dist/enhancers/time-travel/index.js +0 -1
- package/dist/enhancers/time-travel/jest.config.js +0 -21
- package/dist/enhancers/time-travel/lib/utils.js +0 -1
- package/dist/enhancers/time-travel/test-setup.js +0 -5
- package/dist/enhancers/types.js +0 -0
- /package/{dist → src}/enhancers/batching/index.d.ts +0 -0
- /package/{dist → src}/enhancers/batching/jest.config.d.ts +0 -0
- /package/{dist → src}/enhancers/batching/lib/batching.d.ts +0 -0
- /package/{dist → src}/enhancers/batching/test-setup.d.ts +0 -0
- /package/{dist → src}/enhancers/computed/index.d.ts +0 -0
- /package/{dist → src}/enhancers/computed/jest.config.d.ts +0 -0
- /package/{dist → src}/enhancers/computed/lib/computed.d.ts +0 -0
- /package/{dist → src}/enhancers/devtools/index.d.ts +0 -0
- /package/{dist → src}/enhancers/devtools/jest.config.d.ts +0 -0
- /package/{dist → src}/enhancers/devtools/lib/devtools.d.ts +0 -0
- /package/{dist → src}/enhancers/devtools/test-setup.d.ts +0 -0
- /package/{dist → src}/enhancers/entities/index.d.ts +0 -0
- /package/{dist → src}/enhancers/entities/jest.config.d.ts +0 -0
- /package/{dist → src}/enhancers/entities/lib/entities.d.ts +0 -0
- /package/{dist → src}/enhancers/entities/test-setup.d.ts +0 -0
- /package/{dist → src}/enhancers/index.d.ts +0 -0
- /package/{dist → src}/enhancers/memoization/index.d.ts +0 -0
- /package/{dist → src}/enhancers/memoization/jest.config.d.ts +0 -0
- /package/{dist → src}/enhancers/memoization/lib/memoization.d.ts +0 -0
- /package/{dist → src}/enhancers/memoization/test-setup.d.ts +0 -0
- /package/{dist → src}/enhancers/middleware/index.d.ts +0 -0
- /package/{dist → src}/enhancers/middleware/jest.config.d.ts +0 -0
- /package/{dist → src}/enhancers/middleware/lib/async-helpers.d.ts +0 -0
- /package/{dist → src}/enhancers/middleware/lib/middleware.d.ts +0 -0
- /package/{dist → src}/enhancers/middleware/test-setup.d.ts +0 -0
- /package/{dist → src}/enhancers/presets/index.d.ts +0 -0
- /package/{dist → src}/enhancers/presets/jest.config.d.ts +0 -0
- /package/{dist → src}/enhancers/presets/lib/presets.d.ts +0 -0
- /package/{dist → src}/enhancers/presets/test-setup.d.ts +0 -0
- /package/{dist → src}/enhancers/serialization/constants.d.ts +0 -0
- /package/{dist → src}/enhancers/serialization/index.d.ts +0 -0
- /package/{dist → src}/enhancers/serialization/jest.config.d.ts +0 -0
- /package/{dist → src}/enhancers/serialization/lib/serialization.d.ts +0 -0
- /package/{dist → src}/enhancers/serialization/test-setup.d.ts +0 -0
- /package/{dist → src}/enhancers/time-travel/index.d.ts +0 -0
- /package/{dist → src}/enhancers/time-travel/jest.config.d.ts +0 -0
- /package/{dist → src}/enhancers/time-travel/lib/time-travel.d.ts +0 -0
- /package/{dist → src}/enhancers/time-travel/lib/utils.d.ts +0 -0
- /package/{dist → src}/enhancers/time-travel/test-setup.d.ts +0 -0
- /package/{dist → src}/enhancers/types.d.ts +0 -0
- /package/{dist → src}/lib/constants.d.ts +0 -0
- /package/{dist → src}/lib/memory/memory-manager.d.ts +0 -0
- /package/{dist → src}/lib/performance/diff-engine.d.ts +0 -0
- /package/{dist → src}/lib/performance/path-index.d.ts +0 -0
- /package/{dist → src}/lib/performance/update-engine.d.ts +0 -0
- /package/{dist → src}/lib/security/security-validator.d.ts +0 -0
- /package/{dist → src}/lib/signal-tree.d.ts +0 -0
- /package/{dist → src}/lib/types.d.ts +0 -0
|
@@ -1,192 +1,193 @@
|
|
|
1
|
-
import { deepClone
|
|
1
|
+
import { deepClone } from '../../../deep-clone.js';
|
|
2
|
+
import { deepEqual } from '../../../deep-equal.js';
|
|
3
|
+
|
|
2
4
|
class TimeTravelManager {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
const entry = {
|
|
30
|
-
state: deepClone(state),
|
|
31
|
-
timestamp: Date.now(),
|
|
32
|
-
action: this.actionNames[action] || action,
|
|
33
|
-
...(this.includePayload && payload !== undefined && { payload }),
|
|
34
|
-
};
|
|
35
|
-
this.history.push(entry);
|
|
36
|
-
this.currentIndex = this.history.length - 1;
|
|
37
|
-
if (this.history.length > this.maxHistorySize) {
|
|
38
|
-
this.history.shift();
|
|
39
|
-
this.currentIndex--;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
undo() {
|
|
43
|
-
if (!this.canUndo()) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
this.currentIndex--;
|
|
47
|
-
const entry = this.history[this.currentIndex];
|
|
48
|
-
this.restoreState(entry.state);
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
redo() {
|
|
52
|
-
if (!this.canRedo()) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
this.currentIndex++;
|
|
56
|
-
const entry = this.history[this.currentIndex];
|
|
57
|
-
this.restoreState(entry.state);
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
getHistory() {
|
|
61
|
-
return this.history.map((entry) => ({
|
|
62
|
-
...entry,
|
|
63
|
-
state: deepClone(entry.state),
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
resetHistory() {
|
|
67
|
-
const currentState = this.tree();
|
|
68
|
-
this.history = [];
|
|
69
|
-
this.currentIndex = -1;
|
|
70
|
-
this.addEntry('RESET', currentState);
|
|
5
|
+
tree;
|
|
6
|
+
config;
|
|
7
|
+
restoreStateFn;
|
|
8
|
+
history = [];
|
|
9
|
+
currentIndex = -1;
|
|
10
|
+
maxHistorySize;
|
|
11
|
+
includePayload;
|
|
12
|
+
actionNames;
|
|
13
|
+
constructor(tree, config = {}, restoreStateFn) {
|
|
14
|
+
this.tree = tree;
|
|
15
|
+
this.config = config;
|
|
16
|
+
this.restoreStateFn = restoreStateFn;
|
|
17
|
+
this.maxHistorySize = config.maxHistorySize ?? 50;
|
|
18
|
+
this.includePayload = config.includePayload ?? true;
|
|
19
|
+
this.actionNames = {
|
|
20
|
+
update: 'UPDATE',
|
|
21
|
+
set: 'SET',
|
|
22
|
+
batch: 'BATCH',
|
|
23
|
+
...config.actionNames
|
|
24
|
+
};
|
|
25
|
+
this.addEntry('INIT', this.tree());
|
|
26
|
+
}
|
|
27
|
+
addEntry(action, state, payload) {
|
|
28
|
+
if (this.currentIndex < this.history.length - 1) {
|
|
29
|
+
this.history = this.history.slice(0, this.currentIndex + 1);
|
|
71
30
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
31
|
+
const entry = {
|
|
32
|
+
state: deepClone(state),
|
|
33
|
+
timestamp: Date.now(),
|
|
34
|
+
action: this.actionNames[action] || action,
|
|
35
|
+
...(this.includePayload && payload !== undefined && {
|
|
36
|
+
payload
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
this.history.push(entry);
|
|
40
|
+
this.currentIndex = this.history.length - 1;
|
|
41
|
+
if (this.history.length > this.maxHistorySize) {
|
|
42
|
+
this.history.shift();
|
|
43
|
+
this.currentIndex--;
|
|
80
44
|
}
|
|
81
|
-
|
|
82
|
-
|
|
45
|
+
}
|
|
46
|
+
undo() {
|
|
47
|
+
if (!this.canUndo()) {
|
|
48
|
+
return false;
|
|
83
49
|
}
|
|
84
|
-
|
|
85
|
-
|
|
50
|
+
this.currentIndex--;
|
|
51
|
+
const entry = this.history[this.currentIndex];
|
|
52
|
+
this.restoreState(entry.state);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
redo() {
|
|
56
|
+
if (!this.canRedo()) {
|
|
57
|
+
return false;
|
|
86
58
|
}
|
|
87
|
-
|
|
88
|
-
|
|
59
|
+
this.currentIndex++;
|
|
60
|
+
const entry = this.history[this.currentIndex];
|
|
61
|
+
this.restoreState(entry.state);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
getHistory() {
|
|
65
|
+
return this.history.map(entry => ({
|
|
66
|
+
...entry,
|
|
67
|
+
state: deepClone(entry.state)
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
resetHistory() {
|
|
71
|
+
const currentState = this.tree();
|
|
72
|
+
this.history = [];
|
|
73
|
+
this.currentIndex = -1;
|
|
74
|
+
this.addEntry('RESET', currentState);
|
|
75
|
+
}
|
|
76
|
+
jumpTo(index) {
|
|
77
|
+
if (index < 0 || index >= this.history.length) {
|
|
78
|
+
return false;
|
|
89
79
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
80
|
+
this.currentIndex = index;
|
|
81
|
+
const entry = this.history[index];
|
|
82
|
+
this.restoreState(entry.state);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
getCurrentIndex() {
|
|
86
|
+
return this.currentIndex;
|
|
87
|
+
}
|
|
88
|
+
canUndo() {
|
|
89
|
+
return this.currentIndex > 0;
|
|
90
|
+
}
|
|
91
|
+
canRedo() {
|
|
92
|
+
return this.currentIndex < this.history.length - 1;
|
|
93
|
+
}
|
|
94
|
+
restoreState(state) {
|
|
95
|
+
if (this.restoreStateFn) {
|
|
96
|
+
this.restoreStateFn(state);
|
|
97
|
+
} else {
|
|
98
|
+
this.tree(state);
|
|
97
99
|
}
|
|
100
|
+
}
|
|
98
101
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
function withTimeTravel(config = {}) {
|
|
103
|
+
return tree => {
|
|
104
|
+
const originalTreeCall = tree.bind(tree);
|
|
105
|
+
let isRestoring = false;
|
|
106
|
+
const timeTravelManager = new TimeTravelManager(tree, config, state => {
|
|
107
|
+
isRestoring = true;
|
|
108
|
+
try {
|
|
109
|
+
originalTreeCall(state);
|
|
110
|
+
} finally {
|
|
111
|
+
isRestoring = false;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const enhancedTree = function (...args) {
|
|
115
|
+
if (args.length === 0) {
|
|
116
|
+
return originalTreeCall();
|
|
117
|
+
} else {
|
|
118
|
+
if (isRestoring) {
|
|
119
|
+
if (args.length === 1) {
|
|
120
|
+
const arg = args[0];
|
|
121
|
+
if (typeof arg === 'function') {
|
|
122
|
+
return originalTreeCall(arg);
|
|
123
|
+
} else {
|
|
124
|
+
return originalTreeCall(arg);
|
|
110
125
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
else {
|
|
124
|
-
return originalTreeCall(arg);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const beforeState = originalTreeCall();
|
|
130
|
-
let result;
|
|
131
|
-
if (args.length === 1) {
|
|
132
|
-
const arg = args[0];
|
|
133
|
-
if (typeof arg === 'function') {
|
|
134
|
-
result = originalTreeCall(arg);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
result = originalTreeCall(arg);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const afterState = originalTreeCall();
|
|
141
|
-
const statesEqual = deepEqual(beforeState, afterState);
|
|
142
|
-
if (!statesEqual) {
|
|
143
|
-
timeTravelManager.addEntry('update', afterState);
|
|
144
|
-
}
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
Object.setPrototypeOf(enhancedTree, Object.getPrototypeOf(tree));
|
|
149
|
-
Object.assign(enhancedTree, tree);
|
|
150
|
-
if ('state' in tree) {
|
|
151
|
-
Object.defineProperty(enhancedTree, 'state', {
|
|
152
|
-
value: tree.state,
|
|
153
|
-
enumerable: false,
|
|
154
|
-
configurable: true,
|
|
155
|
-
});
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const beforeState = originalTreeCall();
|
|
130
|
+
let result;
|
|
131
|
+
if (args.length === 1) {
|
|
132
|
+
const arg = args[0];
|
|
133
|
+
if (typeof arg === 'function') {
|
|
134
|
+
result = originalTreeCall(arg);
|
|
135
|
+
} else {
|
|
136
|
+
result = originalTreeCall(arg);
|
|
137
|
+
}
|
|
156
138
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
configurable: true,
|
|
162
|
-
});
|
|
139
|
+
const afterState = originalTreeCall();
|
|
140
|
+
const statesEqual = deepEqual(beforeState, afterState);
|
|
141
|
+
if (!statesEqual) {
|
|
142
|
+
timeTravelManager.addEntry('update', afterState);
|
|
163
143
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
Object.setPrototypeOf(enhancedTree, Object.getPrototypeOf(tree));
|
|
148
|
+
Object.assign(enhancedTree, tree);
|
|
149
|
+
if ('state' in tree) {
|
|
150
|
+
Object.defineProperty(enhancedTree, 'state', {
|
|
151
|
+
value: tree.state,
|
|
152
|
+
enumerable: false,
|
|
153
|
+
configurable: true
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if ('$' in tree) {
|
|
157
|
+
Object.defineProperty(enhancedTree, '$', {
|
|
158
|
+
value: tree['$'],
|
|
159
|
+
enumerable: false,
|
|
160
|
+
configurable: true
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
enhancedTree.undo = () => {
|
|
164
|
+
timeTravelManager.undo();
|
|
165
|
+
};
|
|
166
|
+
enhancedTree.redo = () => {
|
|
167
|
+
timeTravelManager.redo();
|
|
168
|
+
};
|
|
169
|
+
enhancedTree.getHistory = () => timeTravelManager.getHistory();
|
|
170
|
+
enhancedTree.resetHistory = () => {
|
|
171
|
+
timeTravelManager.resetHistory();
|
|
172
|
+
};
|
|
173
|
+
enhancedTree.jumpTo = index => {
|
|
174
|
+
timeTravelManager.jumpTo(index);
|
|
185
175
|
};
|
|
176
|
+
enhancedTree.canUndo = () => timeTravelManager.canUndo();
|
|
177
|
+
enhancedTree.canRedo = () => timeTravelManager.canRedo();
|
|
178
|
+
enhancedTree.getCurrentIndex = () => timeTravelManager.getCurrentIndex();
|
|
179
|
+
return Object.assign(enhancedTree, {
|
|
180
|
+
__timeTravel: timeTravelManager
|
|
181
|
+
});
|
|
182
|
+
};
|
|
186
183
|
}
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
function enableTimeTravel(maxHistorySize) {
|
|
185
|
+
return withTimeTravel({
|
|
186
|
+
maxHistorySize
|
|
187
|
+
});
|
|
189
188
|
}
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
function getTimeTravel(tree) {
|
|
190
|
+
return tree.__timeTravel;
|
|
192
191
|
}
|
|
192
|
+
|
|
193
|
+
export { enableTimeTravel, getTimeTravel, withTimeTravel };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type { SignalTree, TreeNode, RemoveSignalMethods, Primitive, BuiltInObject, NotFn, TreeConfig, TreePreset, Enhancer, EnhancerMeta, EnhancerWithMeta, ChainResult, WithMethod, Middleware, PerformanceMetrics, EntityHelpers, AsyncActionConfig, AsyncAction, TimeTravelEntry, } from './lib/types';
|
|
3
|
-
export { equal, deepEqual, isNodeAccessor, isAnySignal, parsePath, composeEnhancers, isBuiltInObject, createLazySignalTree, } from './lib/utils';
|
|
4
|
-
export { SecurityValidator, SecurityPresets, type SecurityEvent, type SecurityEventType, type SecurityValidatorConfig, } from './lib/security/security-validator';
|
|
5
|
-
export { createEnhancer, resolveEnhancerOrder } from './enhancers/index';
|
|
6
|
-
export { ENHANCER_META } from './lib/types';
|
|
7
|
-
export { withBatching, withHighPerformanceBatching, flushBatchedUpdates, hasPendingUpdates, getBatchQueueSize, } from './enhancers/batching/lib/batching';
|
|
8
|
-
export { withMemoization, withSelectorMemoization, withComputedMemoization, withDeepStateMemoization, withHighFrequencyMemoization, withHighPerformanceMemoization, withLightweightMemoization, withShallowMemoization, memoize, memoizeShallow, memoizeReference, cleanupMemoizationCache, clearAllCaches, getGlobalCacheStats, } from './enhancers/memoization/lib/memoization';
|
|
9
|
-
export { withTimeTravel, enableTimeTravel, getTimeTravel, type TimeTravelInterface, } from './enhancers/time-travel/lib/time-travel';
|
|
10
|
-
export { withEntities, enableEntities, withHighPerformanceEntities, } from './enhancers/entities/lib/entities';
|
|
11
|
-
export { withSerialization, enableSerialization, withPersistence, createStorageAdapter, createIndexedDBAdapter, applySerialization, applyPersistence, } from './enhancers/serialization/lib/serialization';
|
|
12
|
-
export { withDevTools, enableDevTools, withFullDevTools, withProductionDevTools, } from './enhancers/devtools/lib/devtools';
|
|
13
|
-
export { withMiddleware, createLoggingMiddleware, createValidationMiddleware, } from './enhancers/middleware/lib/middleware';
|
|
14
|
-
export { createAsyncOperation, trackAsync, } from './enhancers/middleware/lib/async-helpers';
|
|
15
|
-
export { TREE_PRESETS, createPresetConfig, validatePreset, getAvailablePresets, combinePresets, createDevTree, } from './enhancers/presets/lib/presets';
|
|
16
|
-
export { computedEnhancer, createComputed, type ComputedConfig, type ComputedSignal, type ComputedSignalTree, } from './enhancers/computed/lib/computed';
|
|
17
|
-
export { SIGNAL_TREE_CONSTANTS, SIGNAL_TREE_MESSAGES } from './lib/constants';
|
|
1
|
+
export * from "./src/index";
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
export { signalTree } from './lib/signal-tree';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { createEnhancer, resolveEnhancerOrder } from './enhancers/index';
|
|
5
|
-
export { ENHANCER_META } from './lib/types';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { createAsyncOperation, trackAsync
|
|
14
|
-
export { TREE_PRESETS,
|
|
15
|
-
export { computedEnhancer, createComputed
|
|
16
|
-
export { SIGNAL_TREE_CONSTANTS, SIGNAL_TREE_MESSAGES } from './lib/constants';
|
|
1
|
+
export { signalTree } from './lib/signal-tree.js';
|
|
2
|
+
export { composeEnhancers, createLazySignalTree, isAnySignal, isNodeAccessor, toWritableSignal } from './lib/utils.js';
|
|
3
|
+
export { SecurityPresets, SecurityValidator } from './lib/security/security-validator.js';
|
|
4
|
+
export { createEnhancer, resolveEnhancerOrder } from './enhancers/index.js';
|
|
5
|
+
export { ENHANCER_META } from './lib/types.js';
|
|
6
|
+
export { flushBatchedUpdates, getBatchQueueSize, hasPendingUpdates, withBatching, withHighPerformanceBatching } from './enhancers/batching/lib/batching.js';
|
|
7
|
+
export { cleanupMemoizationCache, clearAllCaches, getGlobalCacheStats, memoize, memoizeReference, memoizeShallow, withComputedMemoization, withDeepStateMemoization, withHighFrequencyMemoization, withHighPerformanceMemoization, withLightweightMemoization, withMemoization, withSelectorMemoization, withShallowMemoization } from './enhancers/memoization/lib/memoization.js';
|
|
8
|
+
export { enableTimeTravel, getTimeTravel, withTimeTravel } from './enhancers/time-travel/lib/time-travel.js';
|
|
9
|
+
export { enableEntities, withEntities, withHighPerformanceEntities } from './enhancers/entities/lib/entities.js';
|
|
10
|
+
export { applyPersistence, applySerialization, createIndexedDBAdapter, createStorageAdapter, enableSerialization, withPersistence, withSerialization } from './enhancers/serialization/lib/serialization.js';
|
|
11
|
+
export { enableDevTools, withDevTools, withFullDevTools, withProductionDevTools } from './enhancers/devtools/lib/devtools.js';
|
|
12
|
+
export { createLoggingMiddleware, createValidationMiddleware, withMiddleware } from './enhancers/middleware/lib/middleware.js';
|
|
13
|
+
export { createAsyncOperation, trackAsync } from './enhancers/middleware/lib/async-helpers.js';
|
|
14
|
+
export { TREE_PRESETS, combinePresets, createDevTree, createPresetConfig, getAvailablePresets, validatePreset } from './enhancers/presets/lib/presets.js';
|
|
15
|
+
export { computedEnhancer, createComputed } from './enhancers/computed/lib/computed.js';
|
|
16
|
+
export { SIGNAL_TREE_CONSTANTS, SIGNAL_TREE_MESSAGES } from './lib/constants.js';
|
|
17
|
+
export { deepEqual, deepEqual as equal } from './deep-equal.js';
|
|
18
|
+
export { parsePath } from './parse-path.js';
|
|
19
|
+
export { isBuiltInObject } from './is-built-in-object.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function isBuiltInObject(value) {
|
|
2
|
+
if (value === null || value === undefined) return false;
|
|
3
|
+
if (value instanceof Date || value instanceof RegExp || typeof value === 'function' || value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet || value instanceof ArrayBuffer || value instanceof DataView || value instanceof Error || value instanceof Promise) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
if (value instanceof Int8Array || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int16Array || value instanceof Uint16Array || value instanceof Int32Array || value instanceof Uint32Array || value instanceof Float32Array || value instanceof Float64Array || value instanceof BigInt64Array || value instanceof BigUint64Array) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (typeof window !== 'undefined') {
|
|
10
|
+
if (value instanceof URL || value instanceof URLSearchParams || value instanceof FormData || value instanceof Blob || typeof File !== 'undefined' && value instanceof File || typeof FileList !== 'undefined' && value instanceof FileList || typeof Headers !== 'undefined' && value instanceof Headers || typeof Request !== 'undefined' && value instanceof Request || typeof Response !== 'undefined' && value instanceof Response || typeof AbortController !== 'undefined' && value instanceof AbortController || typeof AbortSignal !== 'undefined' && value instanceof AbortSignal) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const NodeBuffer = globalThis === null || globalThis === void 0 ? void 0 : globalThis.Buffer;
|
|
16
|
+
if (NodeBuffer && value instanceof NodeBuffer) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
} catch (_a) {}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { isBuiltInObject };
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,61 +1,57 @@
|
|
|
1
|
-
import { DEFAULT_PATH_CACHE_SIZE } from '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { DEFAULT_PATH_CACHE_SIZE } from '../constants.js';
|
|
2
|
+
|
|
3
|
+
const SIGNAL_TREE_CONSTANTS = {
|
|
4
|
+
MAX_PATH_CACHE_SIZE: DEFAULT_PATH_CACHE_SIZE,
|
|
5
|
+
LAZY_THRESHOLD: 50,
|
|
6
|
+
ESTIMATE_MAX_DEPTH: 3,
|
|
7
|
+
ESTIMATE_SAMPLE_SIZE_ARRAY: 3,
|
|
8
|
+
ESTIMATE_SAMPLE_SIZE_OBJECT: 5,
|
|
9
|
+
DEFAULT_CACHE_SIZE: 100,
|
|
10
|
+
DEFAULT_BATCH_SIZE: 10
|
|
10
11
|
};
|
|
11
12
|
const DEV_MESSAGES = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
13
|
+
NULL_OR_UNDEFINED: 'null/undefined',
|
|
14
|
+
CIRCULAR_REF: 'circular ref',
|
|
15
|
+
UPDATER_INVALID: 'updater invalid',
|
|
16
|
+
LAZY_FALLBACK: 'lazy fallback',
|
|
17
|
+
SIGNAL_CREATION_FAILED: 'signal creation failed',
|
|
18
|
+
UPDATE_PATH_NOT_FOUND: 'update path not found',
|
|
19
|
+
UPDATE_FAILED: 'update failed',
|
|
20
|
+
ROLLBACK_FAILED: 'rollback failed',
|
|
21
|
+
CLEANUP_ERROR: 'cleanup error',
|
|
22
|
+
PRESET_UNKNOWN: 'unknown preset',
|
|
23
|
+
STRATEGY_SELECTION: 'strategy select',
|
|
24
|
+
TREE_DESTROYED: 'destroyed',
|
|
25
|
+
UPDATE_TRANSACTION: 'update tx',
|
|
26
|
+
BATCH_NOT_ENABLED: 'batching disabled',
|
|
27
|
+
MEMOIZE_NOT_ENABLED: 'memoize disabled',
|
|
28
|
+
MIDDLEWARE_NOT_AVAILABLE: 'middleware missing',
|
|
29
|
+
ENTITY_HELPERS_NOT_AVAILABLE: 'entity helpers missing',
|
|
30
|
+
ASYNC_ACTIONS_NOT_AVAILABLE: 'async actions missing',
|
|
31
|
+
TIME_TRAVEL_NOT_AVAILABLE: 'time travel missing',
|
|
32
|
+
OPTIMIZE_NOT_AVAILABLE: 'optimize missing',
|
|
33
|
+
UPDATE_OPTIMIZED_NOT_AVAILABLE: 'update optimized missing',
|
|
34
|
+
CACHE_NOT_AVAILABLE: 'cache missing',
|
|
35
|
+
PERFORMANCE_NOT_ENABLED: 'performance disabled',
|
|
36
|
+
ENHANCER_ORDER_FAILED: 'enhancer order failed',
|
|
37
|
+
ENHANCER_CYCLE_DETECTED: 'enhancer cycle',
|
|
38
|
+
ENHANCER_REQUIREMENT_MISSING: 'enhancer req missing',
|
|
39
|
+
ENHANCER_PROVIDES_MISSING: 'enhancer provides missing',
|
|
40
|
+
ENHANCER_FAILED: 'enhancer failed',
|
|
41
|
+
ENHANCER_NOT_FUNCTION: 'enhancer not function',
|
|
42
|
+
EFFECT_NO_CONTEXT: 'no angular context',
|
|
43
|
+
SUBSCRIBE_NO_CONTEXT: 'no angular context'
|
|
43
44
|
};
|
|
44
45
|
const PROD_MESSAGES = (() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
const out = {};
|
|
47
|
+
let i = 0;
|
|
48
|
+
for (const k of Object.keys(DEV_MESSAGES)) {
|
|
49
|
+
out[k] = String(i++);
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
51
52
|
})();
|
|
52
|
-
const _isProdByEnv = Boolean(typeof globalThis === 'object' &&
|
|
53
|
-
globalThis !== null &&
|
|
54
|
-
'process' in globalThis &&
|
|
55
|
-
typeof globalThis.process === 'object' &&
|
|
56
|
-
'env' in globalThis.process &&
|
|
57
|
-
globalThis.process.env.NODE_ENV === 'production');
|
|
53
|
+
const _isProdByEnv = Boolean(typeof globalThis === 'object' && globalThis !== null && 'process' in globalThis && typeof globalThis.process === 'object' && 'env' in globalThis.process && globalThis.process.env.NODE_ENV === 'production');
|
|
58
54
|
const _isDev = typeof ngDevMode !== 'undefined' ? Boolean(ngDevMode) : !_isProdByEnv;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
const SIGNAL_TREE_MESSAGES = Object.freeze(_isDev ? DEV_MESSAGES : PROD_MESSAGES);
|
|
56
|
+
|
|
57
|
+
export { SIGNAL_TREE_CONSTANTS, SIGNAL_TREE_MESSAGES };
|