@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.
Files changed (109) hide show
  1. package/README.md +106 -38
  2. package/dist/constants.js +6 -0
  3. package/dist/deep-clone.js +80 -0
  4. package/dist/deep-equal.js +41 -0
  5. package/dist/enhancers/batching/lib/batching.js +141 -135
  6. package/dist/enhancers/computed/lib/computed.js +18 -16
  7. package/dist/enhancers/devtools/lib/devtools.js +303 -260
  8. package/dist/enhancers/entities/lib/entities.js +109 -104
  9. package/dist/enhancers/index.js +65 -77
  10. package/dist/enhancers/memoization/lib/memoization.js +339 -351
  11. package/dist/enhancers/middleware/lib/async-helpers.js +71 -79
  12. package/dist/enhancers/middleware/lib/middleware.js +126 -169
  13. package/dist/enhancers/presets/lib/presets.js +82 -71
  14. package/dist/enhancers/serialization/constants.js +14 -13
  15. package/dist/enhancers/serialization/lib/serialization.js +615 -623
  16. package/dist/enhancers/time-travel/lib/time-travel.js +178 -177
  17. package/dist/index.d.ts +1 -17
  18. package/dist/index.js +19 -16
  19. package/dist/is-built-in-object.js +23 -0
  20. package/dist/lib/constants.js +51 -55
  21. package/dist/lib/memory/memory-manager.js +152 -154
  22. package/dist/lib/performance/diff-engine.js +141 -141
  23. package/dist/lib/performance/path-index.js +139 -137
  24. package/dist/lib/performance/update-engine.js +171 -176
  25. package/dist/lib/security/security-validator.js +110 -128
  26. package/dist/lib/signal-tree.js +577 -611
  27. package/dist/lib/types.js +3 -9
  28. package/dist/lib/utils.js +236 -268
  29. package/dist/lru-cache.js +64 -0
  30. package/dist/parse-path.js +13 -0
  31. package/package.json +30 -16
  32. package/src/index.d.ts +17 -0
  33. package/{dist → src}/lib/utils.d.ts +1 -0
  34. package/dist/enhancers/batching/index.js +0 -1
  35. package/dist/enhancers/batching/jest.config.js +0 -21
  36. package/dist/enhancers/batching/test-setup.js +0 -5
  37. package/dist/enhancers/computed/index.js +0 -1
  38. package/dist/enhancers/computed/jest.config.js +0 -21
  39. package/dist/enhancers/devtools/index.js +0 -1
  40. package/dist/enhancers/devtools/jest.config.js +0 -21
  41. package/dist/enhancers/devtools/test-setup.js +0 -5
  42. package/dist/enhancers/entities/index.js +0 -1
  43. package/dist/enhancers/entities/jest.config.js +0 -21
  44. package/dist/enhancers/entities/test-setup.js +0 -5
  45. package/dist/enhancers/memoization/index.js +0 -1
  46. package/dist/enhancers/memoization/jest.config.js +0 -21
  47. package/dist/enhancers/memoization/test-setup.js +0 -5
  48. package/dist/enhancers/middleware/index.js +0 -2
  49. package/dist/enhancers/middleware/jest.config.js +0 -21
  50. package/dist/enhancers/middleware/test-setup.js +0 -5
  51. package/dist/enhancers/presets/index.js +0 -1
  52. package/dist/enhancers/presets/jest.config.js +0 -21
  53. package/dist/enhancers/presets/test-setup.js +0 -5
  54. package/dist/enhancers/serialization/index.js +0 -2
  55. package/dist/enhancers/serialization/jest.config.js +0 -21
  56. package/dist/enhancers/serialization/test-setup.js +0 -5
  57. package/dist/enhancers/time-travel/index.js +0 -1
  58. package/dist/enhancers/time-travel/jest.config.js +0 -21
  59. package/dist/enhancers/time-travel/lib/utils.js +0 -1
  60. package/dist/enhancers/time-travel/test-setup.js +0 -5
  61. package/dist/enhancers/types.js +0 -0
  62. /package/{dist → src}/enhancers/batching/index.d.ts +0 -0
  63. /package/{dist → src}/enhancers/batching/jest.config.d.ts +0 -0
  64. /package/{dist → src}/enhancers/batching/lib/batching.d.ts +0 -0
  65. /package/{dist → src}/enhancers/batching/test-setup.d.ts +0 -0
  66. /package/{dist → src}/enhancers/computed/index.d.ts +0 -0
  67. /package/{dist → src}/enhancers/computed/jest.config.d.ts +0 -0
  68. /package/{dist → src}/enhancers/computed/lib/computed.d.ts +0 -0
  69. /package/{dist → src}/enhancers/devtools/index.d.ts +0 -0
  70. /package/{dist → src}/enhancers/devtools/jest.config.d.ts +0 -0
  71. /package/{dist → src}/enhancers/devtools/lib/devtools.d.ts +0 -0
  72. /package/{dist → src}/enhancers/devtools/test-setup.d.ts +0 -0
  73. /package/{dist → src}/enhancers/entities/index.d.ts +0 -0
  74. /package/{dist → src}/enhancers/entities/jest.config.d.ts +0 -0
  75. /package/{dist → src}/enhancers/entities/lib/entities.d.ts +0 -0
  76. /package/{dist → src}/enhancers/entities/test-setup.d.ts +0 -0
  77. /package/{dist → src}/enhancers/index.d.ts +0 -0
  78. /package/{dist → src}/enhancers/memoization/index.d.ts +0 -0
  79. /package/{dist → src}/enhancers/memoization/jest.config.d.ts +0 -0
  80. /package/{dist → src}/enhancers/memoization/lib/memoization.d.ts +0 -0
  81. /package/{dist → src}/enhancers/memoization/test-setup.d.ts +0 -0
  82. /package/{dist → src}/enhancers/middleware/index.d.ts +0 -0
  83. /package/{dist → src}/enhancers/middleware/jest.config.d.ts +0 -0
  84. /package/{dist → src}/enhancers/middleware/lib/async-helpers.d.ts +0 -0
  85. /package/{dist → src}/enhancers/middleware/lib/middleware.d.ts +0 -0
  86. /package/{dist → src}/enhancers/middleware/test-setup.d.ts +0 -0
  87. /package/{dist → src}/enhancers/presets/index.d.ts +0 -0
  88. /package/{dist → src}/enhancers/presets/jest.config.d.ts +0 -0
  89. /package/{dist → src}/enhancers/presets/lib/presets.d.ts +0 -0
  90. /package/{dist → src}/enhancers/presets/test-setup.d.ts +0 -0
  91. /package/{dist → src}/enhancers/serialization/constants.d.ts +0 -0
  92. /package/{dist → src}/enhancers/serialization/index.d.ts +0 -0
  93. /package/{dist → src}/enhancers/serialization/jest.config.d.ts +0 -0
  94. /package/{dist → src}/enhancers/serialization/lib/serialization.d.ts +0 -0
  95. /package/{dist → src}/enhancers/serialization/test-setup.d.ts +0 -0
  96. /package/{dist → src}/enhancers/time-travel/index.d.ts +0 -0
  97. /package/{dist → src}/enhancers/time-travel/jest.config.d.ts +0 -0
  98. /package/{dist → src}/enhancers/time-travel/lib/time-travel.d.ts +0 -0
  99. /package/{dist → src}/enhancers/time-travel/lib/utils.d.ts +0 -0
  100. /package/{dist → src}/enhancers/time-travel/test-setup.d.ts +0 -0
  101. /package/{dist → src}/enhancers/types.d.ts +0 -0
  102. /package/{dist → src}/lib/constants.d.ts +0 -0
  103. /package/{dist → src}/lib/memory/memory-manager.d.ts +0 -0
  104. /package/{dist → src}/lib/performance/diff-engine.d.ts +0 -0
  105. /package/{dist → src}/lib/performance/path-index.d.ts +0 -0
  106. /package/{dist → src}/lib/performance/update-engine.d.ts +0 -0
  107. /package/{dist → src}/lib/security/security-validator.d.ts +0 -0
  108. /package/{dist → src}/lib/signal-tree.d.ts +0 -0
  109. /package/{dist → src}/lib/types.d.ts +0 -0
@@ -1,192 +1,193 @@
1
- import { deepClone, deepEqual } from './utils';
1
+ import { deepClone } from '../../../deep-clone.js';
2
+ import { deepEqual } from '../../../deep-equal.js';
3
+
2
4
  class TimeTravelManager {
3
- tree;
4
- config;
5
- restoreStateFn;
6
- history = [];
7
- currentIndex = -1;
8
- maxHistorySize;
9
- includePayload;
10
- actionNames;
11
- constructor(tree, config = {}, restoreStateFn) {
12
- this.tree = tree;
13
- this.config = config;
14
- this.restoreStateFn = restoreStateFn;
15
- this.maxHistorySize = config.maxHistorySize ?? 50;
16
- this.includePayload = config.includePayload ?? true;
17
- this.actionNames = {
18
- update: 'UPDATE',
19
- set: 'SET',
20
- batch: 'BATCH',
21
- ...config.actionNames,
22
- };
23
- this.addEntry('INIT', this.tree());
24
- }
25
- addEntry(action, state, payload) {
26
- if (this.currentIndex < this.history.length - 1) {
27
- this.history = this.history.slice(0, this.currentIndex + 1);
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
- jumpTo(index) {
73
- if (index < 0 || index >= this.history.length) {
74
- return false;
75
- }
76
- this.currentIndex = index;
77
- const entry = this.history[index];
78
- this.restoreState(entry.state);
79
- return true;
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
- getCurrentIndex() {
82
- return this.currentIndex;
45
+ }
46
+ undo() {
47
+ if (!this.canUndo()) {
48
+ return false;
83
49
  }
84
- canUndo() {
85
- return this.currentIndex > 0;
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
- canRedo() {
88
- return this.currentIndex < this.history.length - 1;
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
- restoreState(state) {
91
- if (this.restoreStateFn) {
92
- this.restoreStateFn(state);
93
- }
94
- else {
95
- this.tree(state);
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
- export function withTimeTravel(config = {}) {
100
- return (tree) => {
101
- const originalTreeCall = tree.bind(tree);
102
- let isRestoring = false;
103
- const timeTravelManager = new TimeTravelManager(tree, config, (state) => {
104
- isRestoring = true;
105
- try {
106
- originalTreeCall(state);
107
- }
108
- finally {
109
- isRestoring = false;
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
- const enhancedTree = function (...args) {
113
- if (args.length === 0) {
114
- return originalTreeCall();
115
- }
116
- else {
117
- if (isRestoring) {
118
- if (args.length === 1) {
119
- const arg = args[0];
120
- if (typeof arg === 'function') {
121
- return originalTreeCall(arg);
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
- if ('$' in tree) {
158
- Object.defineProperty(enhancedTree, '$', {
159
- value: tree['$'],
160
- enumerable: false,
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
- enhancedTree.undo = () => {
165
- timeTravelManager.undo();
166
- };
167
- enhancedTree.redo = () => {
168
- timeTravelManager.redo();
169
- };
170
- enhancedTree.getHistory = () => timeTravelManager.getHistory();
171
- enhancedTree.resetHistory =
172
- () => {
173
- timeTravelManager.resetHistory();
174
- };
175
- enhancedTree.jumpTo = (index) => {
176
- timeTravelManager.jumpTo(index);
177
- };
178
- enhancedTree.canUndo = () => timeTravelManager.canUndo();
179
- enhancedTree.canRedo = () => timeTravelManager.canRedo();
180
- enhancedTree.getCurrentIndex =
181
- () => timeTravelManager.getCurrentIndex();
182
- return Object.assign(enhancedTree, {
183
- __timeTravel: timeTravelManager,
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
- export function enableTimeTravel(maxHistorySize) {
188
- return withTimeTravel({ maxHistorySize });
184
+ function enableTimeTravel(maxHistorySize) {
185
+ return withTimeTravel({
186
+ maxHistorySize
187
+ });
189
188
  }
190
- export function getTimeTravel(tree) {
191
- return tree.__timeTravel;
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 { signalTree } from './lib/signal-tree';
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 { equal, deepEqual, isNodeAccessor, isAnySignal, parsePath, composeEnhancers, isBuiltInObject, createLazySignalTree, } from './lib/utils';
3
- export { SecurityValidator, SecurityPresets, } from './lib/security/security-validator';
4
- export { createEnhancer, resolveEnhancerOrder } from './enhancers/index';
5
- export { ENHANCER_META } from './lib/types';
6
- export { withBatching, withHighPerformanceBatching, flushBatchedUpdates, hasPendingUpdates, getBatchQueueSize, } from './enhancers/batching/lib/batching';
7
- export { withMemoization, withSelectorMemoization, withComputedMemoization, withDeepStateMemoization, withHighFrequencyMemoization, withHighPerformanceMemoization, withLightweightMemoization, withShallowMemoization, memoize, memoizeShallow, memoizeReference, cleanupMemoizationCache, clearAllCaches, getGlobalCacheStats, } from './enhancers/memoization/lib/memoization';
8
- export { withTimeTravel, enableTimeTravel, getTimeTravel, } from './enhancers/time-travel/lib/time-travel';
9
- export { withEntities, enableEntities, withHighPerformanceEntities, } from './enhancers/entities/lib/entities';
10
- export { withSerialization, enableSerialization, withPersistence, createStorageAdapter, createIndexedDBAdapter, applySerialization, applyPersistence, } from './enhancers/serialization/lib/serialization';
11
- export { withDevTools, enableDevTools, withFullDevTools, withProductionDevTools, } from './enhancers/devtools/lib/devtools';
12
- export { withMiddleware, createLoggingMiddleware, createValidationMiddleware, } from './enhancers/middleware/lib/middleware';
13
- export { createAsyncOperation, trackAsync, } from './enhancers/middleware/lib/async-helpers';
14
- export { TREE_PRESETS, createPresetConfig, validatePreset, getAvailablePresets, combinePresets, createDevTree, } from './enhancers/presets/lib/presets';
15
- export { computedEnhancer, createComputed, } from './enhancers/computed/lib/computed';
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 };
@@ -1,61 +1,57 @@
1
- import { DEFAULT_PATH_CACHE_SIZE } from '@signaltree/shared';
2
- export const SIGNAL_TREE_CONSTANTS = {
3
- MAX_PATH_CACHE_SIZE: DEFAULT_PATH_CACHE_SIZE,
4
- LAZY_THRESHOLD: 50,
5
- ESTIMATE_MAX_DEPTH: 3,
6
- ESTIMATE_SAMPLE_SIZE_ARRAY: 3,
7
- ESTIMATE_SAMPLE_SIZE_OBJECT: 5,
8
- DEFAULT_CACHE_SIZE: 100,
9
- DEFAULT_BATCH_SIZE: 10,
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
- NULL_OR_UNDEFINED: 'null/undefined',
13
- CIRCULAR_REF: 'circular ref',
14
- UPDATER_INVALID: 'updater invalid',
15
- LAZY_FALLBACK: 'lazy fallback',
16
- SIGNAL_CREATION_FAILED: 'signal creation failed',
17
- UPDATE_PATH_NOT_FOUND: 'update path not found',
18
- UPDATE_FAILED: 'update failed',
19
- ROLLBACK_FAILED: 'rollback failed',
20
- CLEANUP_ERROR: 'cleanup error',
21
- PRESET_UNKNOWN: 'unknown preset',
22
- STRATEGY_SELECTION: 'strategy select',
23
- TREE_DESTROYED: 'destroyed',
24
- UPDATE_TRANSACTION: 'update tx',
25
- BATCH_NOT_ENABLED: 'batching disabled',
26
- MEMOIZE_NOT_ENABLED: 'memoize disabled',
27
- MIDDLEWARE_NOT_AVAILABLE: 'middleware missing',
28
- ENTITY_HELPERS_NOT_AVAILABLE: 'entity helpers missing',
29
- ASYNC_ACTIONS_NOT_AVAILABLE: 'async actions missing',
30
- TIME_TRAVEL_NOT_AVAILABLE: 'time travel missing',
31
- OPTIMIZE_NOT_AVAILABLE: 'optimize missing',
32
- UPDATE_OPTIMIZED_NOT_AVAILABLE: 'update optimized missing',
33
- CACHE_NOT_AVAILABLE: 'cache missing',
34
- PERFORMANCE_NOT_ENABLED: 'performance disabled',
35
- ENHANCER_ORDER_FAILED: 'enhancer order failed',
36
- ENHANCER_CYCLE_DETECTED: 'enhancer cycle',
37
- ENHANCER_REQUIREMENT_MISSING: 'enhancer req missing',
38
- ENHANCER_PROVIDES_MISSING: 'enhancer provides missing',
39
- ENHANCER_FAILED: 'enhancer failed',
40
- ENHANCER_NOT_FUNCTION: 'enhancer not function',
41
- EFFECT_NO_CONTEXT: 'no angular context',
42
- SUBSCRIBE_NO_CONTEXT: 'no angular context',
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
- const out = {};
46
- let i = 0;
47
- for (const k of Object.keys(DEV_MESSAGES)) {
48
- out[k] = String(i++);
49
- }
50
- return out;
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
- export const SIGNAL_TREE_MESSAGES = Object.freeze(_isDev
60
- ? DEV_MESSAGES
61
- : PROD_MESSAGES);
55
+ const SIGNAL_TREE_MESSAGES = Object.freeze(_isDev ? DEV_MESSAGES : PROD_MESSAGES);
56
+
57
+ export { SIGNAL_TREE_CONSTANTS, SIGNAL_TREE_MESSAGES };