cloner 1.1.0
cloner: ^1.1.0 copied to clipboard
Utilities for deep cloning collections and custom types with flexible extension points and optional circular reference detection.
1.1.0 #
Breaking Changes #
- Extracted cloneMapTyped from
ICloninginto separateIMapTypedCloning - Re-structurization of logging framework in
cloner:base.dart - Updated
AdaptiveClonerconstruction/builder behavior
Added #
PureCloner: Added a new cloner implementation that performs deep cloning for common Dart collections and objects, without preserving type arguments or underlying collection implementations- Builder extraction API for cloners: All core cloner implementations (
BaseCloner,CountedCloner,HashedCloner,AdaptiveCloner,PureCloner) now expose a.builder()method, allowing constructorless builder access for configuration and instantiation (enables more flexible and idiomatic cloner construction and runtime configuration) - Interfaces for logging and builder extraction: Added
ILogging,IShowLogging,IPrintLogging, andIBuildableinterfaces to support logging and builder extraction for cloners
Changed #
- Cloner architecture: Refactored cloner interfaces in
cloner:base.dart:- Base interface update:
ICloningis now an agent interface focused on value cloning, and is split into smaller sub-interfaces for lists, sets, and maps (enables more modular cloner implementations and easier extension) ICloningnow only enforces dynamic map cloning (cloneMap<K, V>), with strict typed map cloning (cloneMapTyped<K, V>) moved to a separateIMapTypedCloninginterface. This enables more flexible cloner implementations and extension support- All cloner base implementations now implement
IBuildable, exposing a.builder()method for runtime builder extraction
- Base interface update:
- Revamp
AdaptiveCloner - Refresh benchmarks
Fixed #
- Logging architecture: Logging for clone operations is now consistent and accessible via log history and mixins. Log history can be accessed and reset, and printing can be enabled or disabled
- Extension error handling: Collection extension methods now reliably throw
UnsupportedTypedCloneExceptionwhen a cloner does not support strict typed cloning, improving error reporting for unsupported scenarios - Builder API consistency: All cloner builders now implement a consistent
instance()method returning a fresh builder, improving builder usage patterns
1.0.4 #
Added #
SetClonewrapper for typed nested set cloning that enables safe deep cloning of nested sets while preserving both the element type and the runtime set implementation. UseSetClonefor cases where you need to clone nested typed sets and retain their concrete collection type- IRestorable interface: Added
IRestorable, which provides areset()method for cloners that maintain internal state. BothCountedClonerandHashedClonernow implementIRestorable, allowing their internal counters or hash tracking to be reset between clone operations
Fixed #
cloneValueforICloneablenow correctly passes the cloner instance- Preservation of set and map concrete types:
SetCloneandMapClonenow more reliably preserve the underlying collection implementation (e.g.,LinkedHashSet,HashSet) during cloning and copying
1.0.3 #
Added #
- Serialization support for cloner builders: Major cloner builders (
BaseClonerBuilder,CountedClonerBuilder,HashedClonerBuilder) now implementISerializable, allowing serialization and deserialization of builder configuration to/from strings. This enables saving and restoring cloner settings (can be handy for isolates) - Builder serialization helpers
serializeBaseFlaganddeserializeBaseFlagfor encoding/decoding cloner configuration flags - Exception hierarchy: Introduced
ACloneExceptionandASerializationExceptionas base classes for cloning and serialization errors, respectively. Specific exceptions (e.g.,UnsupportedTypedCloneException,LimitExceededException,CircularReferenceCloneException,DeserializationFormatException) now extend these bases
Changed #
ICloneable<T>.clone()method now accepts an optionalICloningparameter, allowing custom clone logic to receive the current cloner instance
Deprecations
replicate()method has been removed. Use the builder pattern (*Builder().build()) for cloner instantiation and configurationCloner.referenceproperty is removed. UseCloner.builderandCloner.instance()for global cloner configuration and access.
1.0.2 #
Added #
- Builder pattern for cloners: All cloner implementations (
BaseCloner,CountedCloner,HashedCloner) now have corresponding*Builderclasses (e.g.,BaseClonerBuilder) for configuration and instantiation. This enables more flexible and idiomatic cloner construction - AdaptiveCloner: New
AdaptiveClonerandAdaptiveClonerBuilderfor dispatching cloning operations to different delegate cloners based on configuration (e.g., AOT/JIT, collection type) MClonerLoggingmixin: AddMClonerLoggingfor logging clone operations, with log history and optional printing.- Extensions accept custom cloner: Collection extension methods (
clone,cloneDynamic) now accept an optionalclonerparameter for explicit cloner usage
Changed #
- Global cloner API:
Cloner.referenceis deprecated in favor ofCloner.builder(to leverage aforementioned builder pattern for global cloner configuration) Cloner.instancenow uses the builder- DEPRECATED
replicate(): Thereplicate()method on cloners is deprecated and will be removed in a future release - Extensions: Collection extensions now use the builder-based cloner and allow passing a custom cloner
Fixed #
CountedClonernesting depth limit now takes in account only collections (cloneValue()is excluded)
1.0.1 #
Added #
- New
CountedClonerandHashedClonerimplementations:CountedClonerenforces recursion depth and total clone count limits to prevent stack overflows and runaway cloning.HashedClonerprovides circular reference detection for collections, throwingCircularReferenceCloneExceptionon cycles.
LimitExceededExceptionfor reporting exceeded size/nesting limits during cloning.- Benchmarks and performance recommendations for different cloner implementations (see doc/benchmarks)
Changed #
Clonernow usesCountedCloneras the default global cloner instead ofBaseClonerICloning.replicatesignature simplified: removeddoCircRefCheckparameter (circular reference detection is now handled byHashedCloner)- Collection extension methods (
clone,cloneDynamic) no longer acceptdoCircRefCheckparameter - Improved documentation and README with new "Benchmarks" and "Worth Noting" sections
Fixed #
- Improved test coverage for circular reference and limit enforcement scenarios
1.0.0 #
Initial version #
ICloneableandICopyablecontracts for custom deep/shallow copy supportClonerfacade with pluggable backendBaseClonerdefault implementation andICloninginterface for custom cloners- Element/value-wise deep cloning for
List,Set, andMap - Optional circular-reference detection
- Element/value-wise deep cloning for
- Collection extensions:
List.clone()/Set.clone()/Map.clone() MapClonetyped map wrapper for safe nested typed map cloning andcopy()/clone()helpers- Typed-clone safety checks and
UnsupportedTypedCloneExceptionfor unsupported typed scenarios - Preserves common concrete collection implementations (
LinkedHashMap,HashMap) where possible