@signaltree/core 5.0.0 → 5.0.4

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.
@@ -3,6 +3,12 @@ import { isNodeAccessor } from '../../../lib/utils.js';
3
3
  import { LRUCache } from '../../../lru-cache.js';
4
4
  import { deepEqual } from '../../../deep-equal.js';
5
5
 
6
+ function isDevMode() {
7
+ if (typeof __DEV__ !== 'undefined') {
8
+ return __DEV__;
9
+ }
10
+ return false;
11
+ }
6
12
  const MAX_CACHE_SIZE = 1000;
7
13
  const DEFAULT_TTL = 5 * 60 * 1000;
8
14
  const memoizationCache = new Map();
@@ -291,6 +297,11 @@ function withMemoization(config = {}) {
291
297
  if (cached && equalityFn(cached.deps, [currentState])) {
292
298
  return cached.value;
293
299
  }
300
+ if (isDevMode() && tree.__devHooks?.onRecompute) {
301
+ try {
302
+ tree.__devHooks.onRecompute(key, 1);
303
+ } catch {}
304
+ }
294
305
  const result = fn(currentState);
295
306
  memoizeResultCache.set(key, {
296
307
  value: result,
@@ -556,7 +556,6 @@ function withPersistence(config) {
556
556
  });
557
557
  }, debounceMs);
558
558
  };
559
- let usingReactiveSubscription = false;
560
559
  try {
561
560
  tree.subscribe(() => {
562
561
  const currentState = JSON.stringify(tree());
@@ -565,7 +564,6 @@ function withPersistence(config) {
565
564
  triggerAutoSave();
566
565
  }
567
566
  });
568
- usingReactiveSubscription = true;
569
567
  } catch {
570
568
  const checkForChanges = () => {
571
569
  if (!pollingActive) return;
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { signalTree } from './lib/signal-tree.js';
2
2
  export { ENHANCER_META, entityMap } from './lib/types.js';
3
3
  export { composeEnhancers, createLazySignalTree, isAnySignal, isNodeAccessor, toWritableSignal } from './lib/utils.js';
4
+ export { getPathNotifier } from './lib/path-notifier.js';
4
5
  export { SecurityPresets, SecurityValidator } from './lib/security/security-validator.js';
5
6
  export { createEnhancer, resolveEnhancerOrder } from './enhancers/index.js';
6
7
  export { flushBatchedUpdates, getBatchQueueSize, hasPendingUpdates, withBatching, withHighPerformanceBatching } from './enhancers/batching/lib/batching.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaltree/core",
3
- "version": "5.0.0",
3
+ "version": "5.0.4",
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,
@@ -65,8 +65,26 @@
65
65
  }
66
66
  },
67
67
  "peerDependencies": {
68
- "@angular/core": "^20.3.0",
69
- "tslib": "^2.0.0"
68
+ "@angular/core": "^20.0.0",
69
+ "@angular/compiler": "^20.0.0",
70
+ "@angular/platform-browser-dynamic": "^20.0.0",
71
+ "zone.js": "^0.15.0",
72
+ "tslib": "^2.0.0",
73
+ "vitest": "^2.0.0"
74
+ },
75
+ "peerDependenciesMeta": {
76
+ "@angular/compiler": {
77
+ "optional": true
78
+ },
79
+ "@angular/platform-browser-dynamic": {
80
+ "optional": true
81
+ },
82
+ "zone.js": {
83
+ "optional": true
84
+ },
85
+ "vitest": {
86
+ "optional": true
87
+ }
70
88
  },
71
89
  "publishConfig": {
72
90
  "access": "public"
@@ -1 +1,3 @@
1
- export {};
1
+ import '@angular/compiler';
2
+ import 'zone.js';
3
+ import 'zone.js/testing';
@@ -39,7 +39,7 @@ export interface CompositionLogger {
39
39
  data: unknown;
40
40
  }>;
41
41
  }
42
- export interface ModularDevToolsInterface<T = unknown> {
42
+ export interface ModularDevToolsInterface<_T = unknown> {
43
43
  activityTracker: ModuleActivityTracker;
44
44
  logger: CompositionLogger;
45
45
  metrics: Signal<ModularPerformanceMetrics>;
@@ -1 +1,3 @@
1
- export {};
1
+ import '@angular/compiler';
2
+ import 'zone.js';
3
+ import 'zone.js/testing';
@@ -1 +1,3 @@
1
- export {};
1
+ import '@angular/compiler';
2
+ import 'zone.js';
3
+ import 'zone.js/testing';
@@ -1 +1,3 @@
1
- export {};
1
+ import '@angular/compiler';
2
+ import 'zone.js';
3
+ import 'zone.js/testing';
@@ -1 +1,3 @@
1
- export {};
1
+ import '@angular/compiler';
2
+ import 'zone.js';
3
+ import 'zone.js/testing';
@@ -1 +1,3 @@
1
- export {};
1
+ import '@angular/compiler';
2
+ import 'zone.js';
3
+ import 'zone.js/testing';
@@ -1 +1,3 @@
1
- export {};
1
+ import '@angular/compiler';
2
+ import 'zone.js';
3
+ import 'zone.js/testing';
package/src/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { signalTree } from './lib/signal-tree';
2
2
  export type { SignalTree, TreeNode, 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';
3
3
  export { entityMap } from './lib/types';
4
4
  export { equal, deepEqual, isNodeAccessor, isAnySignal, toWritableSignal, parsePath, composeEnhancers, isBuiltInObject, createLazySignalTree, } from './lib/utils';
5
+ export { getPathNotifier } from './lib/path-notifier';
5
6
  export { SecurityValidator, SecurityPresets, type SecurityEvent, type SecurityEventType, type SecurityValidatorConfig, } from './lib/security/security-validator';
6
7
  export { createEnhancer, resolveEnhancerOrder } from './enhancers/index';
7
8
  export { ENHANCER_META } from './lib/types';
@@ -231,7 +231,7 @@ export interface LogEntry {
231
231
  export interface ValidationConfig<T> {
232
232
  validators: Array<{
233
233
  match: (path: string) => boolean;
234
- validate: (value: unknown, path: string) => void | never;
234
+ validate: (value: T, path: string) => void | never;
235
235
  }>;
236
236
  onError?: (error: Error, path: string) => void;
237
237
  }
@@ -252,9 +252,9 @@ export interface DevToolsConfig {
252
252
  reorder?: boolean;
253
253
  };
254
254
  }
255
- export type EntityType<T> = T extends EntitySignal<infer E, any> ? E : never;
256
- export type EntityKeyType<T> = T extends EntitySignal<unknown, infer K> ? K : never;
257
- export type IsEntityMap<T> = T extends EntityMapMarker<unknown, any> ? true : false;
255
+ export type EntityType<T> = T extends EntitySignal<infer E, infer K extends string | number> ? E : never;
256
+ export type EntityKeyType<T> = T extends EntitySignal<unknown, infer K extends string | number> ? K : never;
257
+ export type IsEntityMap<T> = T extends EntityMapMarker<unknown, infer K extends string | number> ? true : false;
258
258
  export type EntityAwareTreeNode<T> = {
259
259
  [K in keyof T]: T[K] extends EntityMapMarker<infer E, infer Key> ? EntitySignal<E, Key> : T[K] extends object ? EntityAwareTreeNode<T[K]> : CallableWritableSignal<T[K]>;
260
260
  };
@@ -1,15 +0,0 @@
1
- declare const _default: {
2
- displayName: string;
3
- preset: string;
4
- setupFilesAfterEnv: string[];
5
- coverageDirectory: string;
6
- transform: {
7
- '^.+\\.(ts|mjs|js|html)$': (string | {
8
- tsconfig: string;
9
- stringifyContentPathRegex: string;
10
- })[];
11
- };
12
- transformIgnorePatterns: string[];
13
- snapshotSerializers: string[];
14
- };
15
- export default _default;
@@ -1,15 +0,0 @@
1
- declare const _default: {
2
- displayName: string;
3
- preset: string;
4
- setupFilesAfterEnv: string[];
5
- coverageDirectory: string;
6
- transform: {
7
- '^.+\\.(ts|mjs|js|html)$': (string | {
8
- tsconfig: string;
9
- stringifyContentPathRegex: string;
10
- })[];
11
- };
12
- transformIgnorePatterns: string[];
13
- snapshotSerializers: string[];
14
- };
15
- export default _default;
@@ -1,15 +0,0 @@
1
- declare const _default: {
2
- displayName: string;
3
- preset: string;
4
- setupFilesAfterEnv: string[];
5
- coverageDirectory: string;
6
- transform: {
7
- '^.+\\.(ts|mjs|js|html)$': (string | {
8
- tsconfig: string;
9
- stringifyContentPathRegex: string;
10
- })[];
11
- };
12
- transformIgnorePatterns: string[];
13
- snapshotSerializers: string[];
14
- };
15
- export default _default;
@@ -1,15 +0,0 @@
1
- declare const _default: {
2
- displayName: string;
3
- preset: string;
4
- setupFilesAfterEnv: string[];
5
- coverageDirectory: string;
6
- transform: {
7
- '^.+\\.(ts|mjs|js|html)$': (string | {
8
- tsconfig: string;
9
- stringifyContentPathRegex: string;
10
- })[];
11
- };
12
- transformIgnorePatterns: string[];
13
- snapshotSerializers: string[];
14
- };
15
- export default _default;
@@ -1,15 +0,0 @@
1
- declare const _default: {
2
- displayName: string;
3
- preset: string;
4
- setupFilesAfterEnv: string[];
5
- coverageDirectory: string;
6
- transform: {
7
- '^.+\\.(ts|mjs|js|html)$': (string | {
8
- tsconfig: string;
9
- stringifyContentPathRegex: string;
10
- })[];
11
- };
12
- transformIgnorePatterns: string[];
13
- snapshotSerializers: string[];
14
- };
15
- export default _default;
@@ -1,15 +0,0 @@
1
- declare const _default: {
2
- displayName: string;
3
- preset: string;
4
- setupFilesAfterEnv: string[];
5
- coverageDirectory: string;
6
- transform: {
7
- '^.+\\.(ts|mjs|js|html)$': (string | {
8
- tsconfig: string;
9
- stringifyContentPathRegex: string;
10
- })[];
11
- };
12
- transformIgnorePatterns: string[];
13
- snapshotSerializers: string[];
14
- };
15
- export default _default;
@@ -1,15 +0,0 @@
1
- declare const _default: {
2
- displayName: string;
3
- preset: string;
4
- setupFilesAfterEnv: string[];
5
- coverageDirectory: string;
6
- transform: {
7
- '^.+\\.(ts|mjs|js|html)$': (string | {
8
- tsconfig: string;
9
- stringifyContentPathRegex: string;
10
- })[];
11
- };
12
- transformIgnorePatterns: string[];
13
- snapshotSerializers: string[];
14
- };
15
- export default _default;
@@ -1,15 +0,0 @@
1
- declare const _default: {
2
- displayName: string;
3
- preset: string;
4
- setupFilesAfterEnv: string[];
5
- coverageDirectory: string;
6
- transform: {
7
- '^.+\\.(ts|mjs|js|html)$': (string | {
8
- tsconfig: string;
9
- stringifyContentPathRegex: string;
10
- })[];
11
- };
12
- transformIgnorePatterns: string[];
13
- snapshotSerializers: string[];
14
- };
15
- export default _default;