@signaltree/core 6.2.0 → 6.2.2

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.
@@ -160,6 +160,17 @@ function batching(config = {}) {
160
160
  try {
161
161
  copyTreeProperties(tree, enhancedTree);
162
162
  } catch {}
163
+ Object.defineProperty(enhancedTree, 'with', {
164
+ value: function (enhancer) {
165
+ if (typeof enhancer !== 'function') {
166
+ throw new Error('Enhancer must be a function');
167
+ }
168
+ return enhancer(enhancedTree);
169
+ },
170
+ writable: false,
171
+ enumerable: false,
172
+ configurable: true
173
+ });
163
174
  if ('state' in tree) {
164
175
  Object.defineProperty(enhancedTree, 'state', {
165
176
  value: tree.state,
@@ -1,4 +1,5 @@
1
1
  import { signal } from '@angular/core';
2
+ import { copyTreeProperties } from '../utils/copy-tree-properties.js';
2
3
 
3
4
  function createActivityTracker() {
4
5
  const modules = new Map();
@@ -203,7 +204,18 @@ function devTools(config = {}) {
203
204
  return result;
204
205
  };
205
206
  Object.setPrototypeOf(enhancedTree, Object.getPrototypeOf(tree));
206
- Object.assign(enhancedTree, tree);
207
+ copyTreeProperties(tree, enhancedTree);
208
+ Object.defineProperty(enhancedTree, 'with', {
209
+ value: function (enhancer) {
210
+ if (typeof enhancer !== 'function') {
211
+ throw new Error('Enhancer must be a function');
212
+ }
213
+ return enhancer(enhancedTree);
214
+ },
215
+ writable: false,
216
+ enumerable: false,
217
+ configurable: true
218
+ });
207
219
  if ('state' in tree) {
208
220
  Object.defineProperty(enhancedTree, 'state', {
209
221
  value: tree.state,
@@ -29,7 +29,12 @@ class TimeTravelManager {
29
29
  this.history = this.history.slice(0, this.currentIndex + 1);
30
30
  }
31
31
  const plain = snapshotState(this.tree.state);
32
- const cloned = typeof structuredClone !== 'undefined' ? structuredClone(plain) : JSON.parse(JSON.stringify(plain));
32
+ let cloned;
33
+ try {
34
+ cloned = typeof structuredClone !== 'undefined' ? structuredClone(plain) : JSON.parse(JSON.stringify(plain));
35
+ } catch {
36
+ cloned = JSON.parse(JSON.stringify(plain));
37
+ }
33
38
  const entry = {
34
39
  state: cloned,
35
40
  timestamp: Date.now(),
@@ -172,6 +177,17 @@ function timeTravel(config = {}) {
172
177
  };
173
178
  Object.setPrototypeOf(enhancedTree, Object.getPrototypeOf(tree));
174
179
  Object.assign(enhancedTree, tree);
180
+ Object.defineProperty(enhancedTree, 'with', {
181
+ value: function (enhancer) {
182
+ if (typeof enhancer !== 'function') {
183
+ throw new Error('Enhancer must be a function');
184
+ }
185
+ return enhancer(enhancedTree);
186
+ },
187
+ writable: false,
188
+ enumerable: false,
189
+ configurable: true
190
+ });
175
191
  if ('state' in tree) {
176
192
  Object.defineProperty(enhancedTree, 'state', {
177
193
  value: tree.state,
@@ -215,7 +215,8 @@ function create(initialState, config) {
215
215
  return enhancer(tree);
216
216
  },
217
217
  enumerable: false,
218
- writable: false
218
+ writable: false,
219
+ configurable: true
219
220
  });
220
221
  Object.defineProperty(tree, 'bind', {
221
222
  value: function (thisArg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaltree/core",
3
- "version": "6.2.0",
3
+ "version": "6.2.2",
4
4
  "description": "Lightweight, type-safe signal-based state management for Angular. Core package providing hierarchical signal trees, basic entity management, and async actions.",
5
5
  "type": "module",
6
6
  "sideEffects": false,