Skip to content

Releases: persevie/statemanjs

@persevie/[email protected]

28 Oct 19:09

Choose a tag to compare

[1.8.0] - 2025-10-28

Added

Core Features

  • Computed Scheduler: Implemented global deferred computed scheduler (computedScheduler.ts) that resolves diamond dependency problems by ensuring computed values are recomputed only once per update wave
  • Update Generation Tracking: Added UpdateGeneration class to prevent duplicate recomputations in complex dependency graphs
  • Batching Support: New batch option in StatemanjsOptions enables microtask-based batching of subscriber notifications for better performance
  • FinalizationRegistry Integration: Automatic cleanup of garbage-collected subscribers prevents memory leaks without manual unsubscribe calls
  • Lazy Computed Evaluation: Computed states now calculate values only when accessed or when they have active subscribers

Performance Optimizations

  • Primitive Fast-Path: Ultra-fast code path for primitive state values (numbers, strings, booleans) bypassing Proxy overhead
  • WeakMap-Based Proxy Cache: Replaced string-based Map cache with WeakMap for automatic garbage collection and better memory management
  • String-Based Path Tracking: Optimized property path tracking using string concatenation instead of arrays (faster and less memory)
  • Precompiled Comparators: Comparator functions are now precompiled at initialization to avoid switch statements in hot paths
  • Array Accessor Method Proxying: Added support for tracking changes through array methods: find(), filter(), map(), at(), slice(), concat(), reduce(), reduceRight(), flatMap()
  • Lazy Computed Recomputation: Computed states now skip recomputation when no subscribers are active, saving CPU cycles
  • Diamond Dependency Resolution: Deferred scheduler ensures computed states in diamond-shaped dependency graphs receive correct values without glitches or duplicate recomputations

API Enhancements

  • Computed Dependencies: createComputedState now accepts both StatemanjsAPI and StatemanjsComputedAPI as dependencies, enabling computed chains
  • Deep Clone in Unwrap: unwrap() method now returns a deep clone using structuredClone (with JSON fallback) to prevent accidental mutations
  • Skip Generation Increment: Internal skipGenerationIncrement option for computed states to avoid generation counter interference
  • Cyclic Dependency Detection: Added cycle detection in computed states with clear error messages preventing infinite loops

Changed

Breaking Changes

  • File Structure: Moved shared entities and utilities to shared/ directory:
    • entities.tsshared/entities.ts
    • utility.tsshared/utility.ts
  • Jest Config: Converted TypeScript Jest configs to JavaScript (jest.config.tsjest.config.js) for better compatibility

Internal Improvements

  • Path Representation: Internal property paths now use dot-separated strings instead of arrays for better performance
  • Subscriber Notification: Refactored subscriber notification logic to support both synchronous and batched modes
  • Proxy Handler: Simplified proxy handler logic by removing unnecessary path manipulations
  • Error Handling: Improved error messages for cyclic dependencies and primitive state updates

Tests

  • Added test for unwrap() method behavior
  • Added tests for array accessor methods (find(), filter(), map(), at(), slice())
  • Added Vue integration test for hook usage outside component scope
  • All existing tests pass with new optimizations

Documentation

  • Updated README with architectural requirements section ("Why Statemanjs")
  • Added detailed performance benchmarks
  • Documented diamond dependency resolution and scheduler implementation

Build & Tooling

  • Fixed module imports in build scripts (added .js extensions for CommonJS compatibility)
  • Updated test runner to use .js config files
  • Improved publish script with proper file extension handling

@persevie/[email protected]

15 Aug 20:32

Choose a tag to compare

Added

  • Custom Comparators: Introduced support for custom comparator functions in the set and update methods. This allows developers to define how states should be compared, providing greater flexibility in state management.
  • Extended Subscription Options: Added new subscription options, including property-based notifications and notifyCondition callbacks. This enables more efficient state updates and reduces unnecessary recalculations or re-renders.
  • Enhanced Computed State API: Improved the createSelector function to accept additional configuration options, such as custom and default comparators. This ensures computed states are more efficiently managed.

Changed

  • Optimized Core Logic: Refactored the internal state management logic to improve performance, particularly in how state changes are tracked and handled. This includes the introduction of a proxy cache to reduce the overhead of accessing nested properties.
  • Improved Error Handling: Enhanced error handling mechanisms across the state management system, providing clearer feedback when issues occur during state updates or subscriptions.
  • Refined Update Process: The update process now better handles property changes, ensuring that only necessary updates trigger notifications to subscribers.

Fixed

  • Vulnerability Fixes: Addressed potential vulnerabilities in state management by tightening control over how state modifications are performed and by improving access controls.

This release focuses on improving the performance, flexibility, and security of the statemanjs library, offering developers greater control and efficiency in managing application state.

@persevie/[email protected]

14 Dec 21:23

Choose a tag to compare

feat: add debug service (transactions)

@persevie/[email protected]

23 Jul 14:57

Choose a tag to compare

chore(statemanjs-react): update repository url

@persevie/[email protected]

23 Jul 14:58

Choose a tag to compare

chore(statemanjs-react): update repository url

@persevie/[email protected]

23 Jul 14:59

Choose a tag to compare

chore(statemanjs-react): update repository url

@persevie/[email protected]

23 Jul 14:58

Choose a tag to compare

chore(statemanjs-react): update repository url

v1.5.3

22 Jul 00:28

Choose a tag to compare

chore(release): get ready for new version

@persevie/[email protected]

22 Jul 01:08

Choose a tag to compare

Note: Version bump only for package @persevie/statemanjs

@persevie/[email protected]

22 Jul 01:01

Choose a tag to compare

1.5.5 (2023-07-22)

1.5.3 (2023-07-22)

Note: Version bump only for package @persevie/statemanjs