Releases: persevie/statemanjs
Releases · persevie/statemanjs
@persevie/[email protected]
[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
UpdateGenerationclass to prevent duplicate recomputations in complex dependency graphs - Batching Support: New
batchoption inStatemanjsOptionsenables 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:
createComputedStatenow accepts bothStatemanjsAPIandStatemanjsComputedAPIas dependencies, enabling computed chains - Deep Clone in Unwrap:
unwrap()method now returns a deep clone usingstructuredClone(with JSON fallback) to prevent accidental mutations - Skip Generation Increment: Internal
skipGenerationIncrementoption 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.ts→shared/entities.tsutility.ts→shared/utility.ts
- Jest Config: Converted TypeScript Jest configs to JavaScript (
jest.config.ts→jest.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
.jsextensions for CommonJS compatibility) - Updated test runner to use
.jsconfig files - Improved publish script with proper file extension handling
@persevie/[email protected]
Added
- Custom Comparators: Introduced support for custom comparator functions in the
setandupdatemethods. 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
notifyConditioncallbacks. This enables more efficient state updates and reduces unnecessary recalculations or re-renders. - Enhanced Computed State API: Improved the
createSelectorfunction 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]
feat: add debug service (transactions)
@persevie/[email protected]
chore(statemanjs-react): update repository url
@persevie/[email protected]
chore(statemanjs-react): update repository url
@persevie/[email protected]
chore(statemanjs-react): update repository url
@persevie/[email protected]
chore(statemanjs-react): update repository url
v1.5.3
@persevie/[email protected]
Note: Version bump only for package @persevie/statemanjs
@persevie/[email protected]
1.5.5 (2023-07-22)
1.5.3 (2023-07-22)
Note: Version bump only for package @persevie/statemanjs