@signaltree/core 5.1.4 → 5.1.6

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.
@@ -5,11 +5,7 @@ import { isNodeAccessor } from '../../../lib/utils.js';
5
5
  function isEntityMapMarker(value) {
6
6
  return Boolean(value && typeof value === 'object' && value['__isEntityMap'] === true);
7
7
  }
8
- function isEntitySignal(value) {
9
- return !!value && typeof value === 'object' && typeof value['addOne'] === 'function' && typeof value['all'] !== 'undefined';
10
- }
11
8
  function materializeEntities(tree, notifier = getPathNotifier()) {
12
- const registry = new Map();
13
9
  const state = tree.state;
14
10
  const visit = (parent, key, value, path) => {
15
11
  const nextPath = [...path, key];
@@ -25,7 +21,6 @@ function materializeEntities(tree, notifier = getPathNotifier()) {
25
21
  try {
26
22
  tree[key] = entitySignal;
27
23
  } catch {}
28
- registry.set(basePath, entitySignal);
29
24
  return;
30
25
  }
31
26
  if (isNodeAccessor(value)) {
@@ -44,23 +39,6 @@ function materializeEntities(tree, notifier = getPathNotifier()) {
44
39
  for (const key of Object.keys(state)) {
45
40
  visit(state, key, state[key], []);
46
41
  }
47
- return registry;
48
- }
49
- function resolveEntitySignal(tree, registry, path) {
50
- const pathStr = String(path);
51
- const existing = registry.get(pathStr);
52
- if (existing) return existing;
53
- const segments = pathStr.split('.');
54
- let current = tree.state;
55
- for (const segment of segments) {
56
- if (!current) break;
57
- current = current[segment];
58
- }
59
- if (isEntitySignal(current)) {
60
- registry.set(pathStr, current);
61
- return current;
62
- }
63
- throw new Error(`Entity path '${pathStr}' is not configured. Define it with entityMap() in your initial state.`);
64
42
  }
65
43
  function withEntities(config = {}) {
66
44
  const {
@@ -70,13 +48,8 @@ function withEntities(config = {}) {
70
48
  if (!enabled) {
71
49
  return tree;
72
50
  }
73
- const registry = materializeEntities(tree);
74
- const enhancedTree = Object.assign(tree, {
75
- entities(path) {
76
- return resolveEntitySignal(tree, registry, path);
77
- }
78
- });
79
- return enhancedTree;
51
+ materializeEntities(tree);
52
+ return tree;
80
53
  };
81
54
  }
82
55
  function enableEntities() {
@@ -449,15 +449,6 @@ function addStubMethods(tree, config) {
449
449
  }
450
450
  return engine.update(tree(), updates, options);
451
451
  };
452
- tree.getMetrics = () => {
453
- return {
454
- updates: 0,
455
- computations: 0,
456
- cacheHits: 0,
457
- cacheMisses: 0,
458
- averageUpdateTime: 0
459
- };
460
- };
461
452
  tree.entities = () => {
462
453
  console.warn('[@signaltree/core] tree.entities() is deprecated and will be removed in v6.0. ' + 'Use entityMap<E>() + withEntities() + tree.$.collectionName instead. ' + 'See https://signaltree.dev/docs/migration for migration guide.');
463
454
  if (config.debugMode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaltree/core",
3
- "version": "5.1.4",
3
+ "version": "5.1.6",
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,
@@ -1,20 +1,17 @@
1
- import type { EntitySignal, SignalTree, EntityAwareTreeNode } from '../../../lib/types';
1
+ import type { SignalTree, EntityAwareTreeNode } from '../../../lib/types';
2
2
  interface EntitiesEnhancerConfig {
3
3
  enabled?: boolean;
4
4
  }
5
5
  export declare function withEntities(config?: EntitiesEnhancerConfig): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
6
6
  state: EntityAwareTreeNode<T>;
7
7
  $: EntityAwareTreeNode<T>;
8
- entities<E, K extends string | number>(path: keyof T | string): EntitySignal<E, K>;
9
8
  };
10
9
  export declare function enableEntities(): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
11
10
  state: EntityAwareTreeNode<T>;
12
11
  $: EntityAwareTreeNode<T>;
13
- entities<E, K extends string | number>(path: keyof T | string): EntitySignal<E, K>;
14
12
  };
15
13
  export declare function withHighPerformanceEntities(): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
16
14
  state: EntityAwareTreeNode<T>;
17
15
  $: EntityAwareTreeNode<T>;
18
- entities<E, K extends string | number>(path: keyof T | string): EntitySignal<E, K>;
19
16
  };
20
17
  export {};
package/src/entities.d.ts CHANGED
@@ -1,20 +1,28 @@
1
- import type { EntitySignal, SignalTree, EntityAwareTreeNode } from '../../../lib/types';
1
+ import type {
2
+ EntitySignal,
3
+ SignalTree,
4
+ EntityAwareTreeNode,
5
+ } from '../../../lib/types';
2
6
  interface EntitiesEnhancerConfig {
3
- enabled?: boolean;
7
+ enabled?: boolean;
4
8
  }
5
- export declare function withEntities(config?: EntitiesEnhancerConfig): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
6
- state: EntityAwareTreeNode<T>;
7
- $: EntityAwareTreeNode<T>;
8
- entities<E, K extends string | number>(path: keyof T | string): EntitySignal<E, K>;
9
+ export declare function withEntities(config?: EntitiesEnhancerConfig): <T>(
10
+ tree: SignalTree<T>
11
+ ) => Omit<SignalTree<T>, 'state' | '$'> & {
12
+ state: EntityAwareTreeNode<T>;
13
+ $: EntityAwareTreeNode<T>;
9
14
  };
10
- export declare function enableEntities(): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
11
- state: EntityAwareTreeNode<T>;
12
- $: EntityAwareTreeNode<T>;
13
- entities<E, K extends string | number>(path: keyof T | string): EntitySignal<E, K>;
15
+ export declare function enableEntities(): <T>(tree: SignalTree<T>) => Omit<
16
+ SignalTree<T>,
17
+ 'state' | '$'
18
+ > & {
19
+ state: EntityAwareTreeNode<T>;
20
+ $: EntityAwareTreeNode<T>;
14
21
  };
15
- export declare function withHighPerformanceEntities(): <T>(tree: SignalTree<T>) => Omit<SignalTree<T>, "state" | "$"> & {
16
- state: EntityAwareTreeNode<T>;
17
- $: EntityAwareTreeNode<T>;
18
- entities<E, K extends string | number>(path: keyof T | string): EntitySignal<E, K>;
22
+ export declare function withHighPerformanceEntities(): <T>(
23
+ tree: SignalTree<T>
24
+ ) => Omit<SignalTree<T>, 'state' | '$'> & {
25
+ state: EntityAwareTreeNode<T>;
26
+ $: EntityAwareTreeNode<T>;
19
27
  };
20
28
  export {};
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { signalTree } from './lib/signal-tree';
2
- export type { SignalTree, TreeNode, CallableWritableSignal, AccessibleNode, NodeAccessor, RemoveSignalMethods, Primitive, BuiltInObject, NotFn, DeepPath, DeepAccess, TreeConfig, TreePreset, Enhancer, EnhancerMeta, EnhancerWithMeta, ChainResult, WithMethod, EntitySignal, EntityMapMarker, EntityConfig, MutationOptions, AddOptions, AddManyOptions, PerformanceMetrics, EntityHelpers, TimeTravelEntry, } from './lib/types';
2
+ export type { SignalTree, TreeNode, CallableWritableSignal, AccessibleNode, NodeAccessor, RemoveSignalMethods, Primitive, BuiltInObject, NotFn, DeepPath, DeepAccess, TreeConfig, TreePreset, Enhancer, EnhancerMeta, EnhancerWithMeta, ChainResult, WithMethod, EntitySignal, EntityMapMarker, EntityConfig, MutationOptions, AddOptions, AddManyOptions, EntityHelpers, TimeTravelEntry, } from './lib/types';
3
3
  export { entityMap } from './lib/types';
4
4
  export { equal, deepEqual, isNodeAccessor, isAnySignal, toWritableSignal, parsePath, composeEnhancers, isBuiltInObject, createLazySignalTree, } from './lib/utils';
5
5
  export { getPathNotifier } from './lib/path-notifier';
@@ -89,7 +89,6 @@ export type SignalTree<T> = NodeAccessor<T> & {
89
89
  batchedUpdates: number;
90
90
  };
91
91
  };
92
- getMetrics(): PerformanceMetrics;
93
92
  entities<E extends {
94
93
  id: string | number;
95
94
  }>(entityKey?: keyof T): EntityHelpers<E>;
@@ -117,13 +116,6 @@ export interface TreeConfig {
117
116
  useStructuralSharing?: boolean;
118
117
  security?: SecurityValidatorConfig;
119
118
  }
120
- export interface PerformanceMetrics {
121
- updates: number;
122
- computations: number;
123
- cacheHits: number;
124
- cacheMisses: number;
125
- averageUpdateTime: number;
126
- }
127
119
  export interface EntityConfig<E, K extends string | number = string> {
128
120
  selectId?: (entity: E) => K;
129
121
  hooks?: {
package/src/types.d.ts CHANGED
@@ -210,7 +210,6 @@ export type SignalTree<T> = NodeAccessor<T> & {
210
210
  batchedUpdates: number;
211
211
  };
212
212
  };
213
- getMetrics(): PerformanceMetrics;
214
213
  entities<
215
214
  E extends {
216
215
  id: string | number;
@@ -242,13 +241,6 @@ export interface TreeConfig {
242
241
  useStructuralSharing?: boolean;
243
242
  security?: SecurityValidatorConfig;
244
243
  }
245
- export interface PerformanceMetrics {
246
- updates: number;
247
- computations: number;
248
- cacheHits: number;
249
- cacheMisses: number;
250
- averageUpdateTime: number;
251
- }
252
244
  export interface EntityConfig<E, K extends string | number = string> {
253
245
  selectId?: (entity: E) => K;
254
246
  hooks?: {