All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- BREAKING: Re-define
ComposableControllerStateConstrainttype usingStateConstraintinstead ofLegacyControllerStateConstraint(#5018) - BREAKING: Constrain the
ComposableControllerStategeneric argument for theComposableControllerclass usingComposableControllerStateConstraintinstead ofLegacyComposableControllerStateConstraint(#5018) - Bump
@metamask/base-controllerfrom^7.0.2to^8.0.0(#5079), (#5135), (#5305) - Bump
@metamask/json-rpc-enginefrom^10.0.1to^10.0.3(#5082), (#5272)
- BREAKING:
ComposableControllerconstructor optioncontrollersand generic type argumentChildControllersare re-defined from an array of controller instances to an object that maps controller names to controller instances (#4968) - BREAKING:
ComposableControllerclass field objectsstateandmetadataexclude child controllers that do not extend fromBaseControllerorBaseControllerV1. Any non-controller entries that are passed into the constructor will be removed automatically (#4968) - Bump devDependency
@metamask/json-rpc-enginefrom^9.0.3to^10.0.1(#4798, #4862)
- BREAKING:
ComposableControllerclass field objectmetadatanow assigns theStateMetadataProperty-type object{ persist: true, anonymous: true }to each child controller name (#4968)- Previously, V2 child controllers were erroneously assigned their own metadata object. This issue was introduced in
@metamask/base-controller@6.0.0.
- Previously, V2 child controllers were erroneously assigned their own metadata object. This issue was introduced in
- Produce and export ESM-compatible TypeScript type declaration files in addition to CommonJS-compatible declaration files (#4648)
- Previously, this package shipped with only one variant of type declaration
files, and these files were only CommonJS-compatible, and the
exportsfield inpackage.jsonlinked to these files. This is an anti-pattern and was rightfully flagged by the "Are the Types Wrong?" tool as "masquerading as CJS". All of the ATTW checks now pass.
- Previously, this package shipped with only one variant of type declaration
files, and these files were only CommonJS-compatible, and the
- Remove chunk files (#4648).
- Previously, the build tool we used to generate JavaScript files extracted common code to "chunk" files. While this was intended to make this package more tree-shakeable, it also made debugging more difficult for our development teams. These chunk files are no longer present.
- Bump
@metamask/base-controllerfrom^6.0.3to^7.0.0(#4643)
- BREAKING: Remove exports for types
LegacyControllerStateConstraint,RestrictedControllerMessengerConstraint, and type guard functionsisBaseController,isBaseControllerV1(#4467)- These have been migrated to
@metamask/base-controller@7.0.0.
- These have been migrated to
- BREAKING: Add two required generic parameters to the
ComposableControllerclass:ComposedControllerState(constrained byLegacyComposableControllerStateConstraint) andChildControllers(constrained byControllerInstance) (#4467) - BREAKING: The type guard
isBaseControllernow validates that the input has an object-type property namedmetadatain addition to its existing checks (#4467) - BREAKING: The type guard
isBaseControllerV1now validates that the input has object-type propertiesconfig,state, and function-type propertysubscribe, in addition to its existing checks (#4467) - BREAKING: Narrow
LegacyControllerStateConstrainttype fromBaseState | StateConstrainttoBaseState & object | StateConstraint(#4467) - Add an optional generic parameter
ControllerNameto theRestrictedControllerMessengerConstrainttype, which extendsstringand defaults tostring(#4467) - Bump
@metamask/base-controllerfrom~6.0.0to~6.0.3(#4517, #4544, #4625) - Bump
typescriptfrom~4.9.5to~5.2.2and setmodule{,Resolution}options toNode16(#3645, #4576, #4584)
- BREAKING: The
ComposableControllerclass raises a type error if a non-controller with nostateproperty is passed into theChildControllersgeneric parameter or thecontrollersconstructor option (#4467)- Previously, a runtime error was thrown at class instantiation with no type-level enforcement.
- When the
ComposableControllerclass is instantiated, its messenger now attempts to subscribe to all child controllerstateChangeevents that are included in the messenger's events allowlist (#4467)- This was always the expected behavior, but a bug introduced in
@metamask/composable-controller@6.0.0causedstateChangeevent subscriptions to fail.
- This was always the expected behavior, but a bug introduced in
isBaseControllerandisBaseControllerV1no longer return false negatives (#4467)- The
instanceofoperator is no longer used to validate that the input is a subclass ofBaseControllerorBaseControllerV1.
- The
- The
ChildControllerStateChangeEventstype checks that the child controller's state extends from theStateConstraintV1type instead of fromRecord<string, unknown>(#4467)- V1 controllers define their state types using the
interfacekeyword, which are incompatible withRecord<string, unknown>by default. This resulted inChildControllerStateChangeEventsfailing to generatestateChangeevents for V1 controllers and returningnever.
- V1 controllers define their state types using the
- BREAKING: Bump minimum Node version to 18.18 (#3611)
- Bump
@metamask/base-controllerto^6.0.0(#4352) - Bump
@metamask/json-rpc-engineto^9.0.0(#4352)
- Adds and exports new types: (#3952)
RestrictedControllerMessengerConstraint, which is the narrowest supertype of all controller-messenger instances.LegacyControllerStateConstraint, a universal supertype for the controller state object, encompassing both BaseControllerV1 and BaseControllerV2 state.ComposableControllerStateConstraint, the narrowest supertype for the composable controller state object.
- BREAKING: The
ComposableControllerclass is now a generic class that expects one generic argumentComposableControllerState(#3952).- BREAKING: For the
ComposableControllerclass to be typed correctly, any of its child controllers that extendBaseControllerV1must have an overriddennameproperty that is defined using theas constassertion.
- BREAKING: For the
- BREAKING: The types
ComposableControllerStateChangeEvent,ComposableControllerEvents,ComposableControllerMessengerare now generic types that expect one generic argumentComposableControllerState(#3952). - Bump
@metamask/json-rpc-engineto^8.0.2(#4234) - Bump
@metamask/base-controllerto^5.0.2(#4232)
- Fix
typesfield inpackage.json(#4047)
- BREAKING: Add ESM build (#3998)
- It's no longer possible to import files from
./distdirectly.
- It's no longer possible to import files from
- Add and export functions
isBaseControllerV1andisBaseController, which are type guards for validating controller instances (#3904) ComposableControllernow accommodatesBaseControllerV1controllers that use a messenger (specifically, which have amessagingSystemproperty which is an instance ofRestrictedControllerMessenger), by subscribing to thestateChangeevent of the messenger instead of using thesubscribemethod on the controller (#3964)
- BREAKING: Passing a non-controller into
controllersconstructor option now throws an error (#3904) - BREAKING: The
AllowedActionparameter of theComposableControllerMessengertype is narrowed fromstringtonever, asComposableControllerdoes not use any external controller actions (#3904) - BREAKING: Bump
@metamask/base-controllerto^5.0.0(#4039)- This version has a number of breaking changes. See the changelog for more.
- Relax
payloadinComposableControllerStateChangeEventto useRecord<string, any>rather thanRecord<string, unknown>(#3949) - Bump
@metamask/json-rpc-engineto^8.0.0(#4039)
- BREAKING: Remove
flatStategetter fromComposableController(#3877)- This method was confusing to use in practice. Consumers should use the
ComposableControllerstate directly.
- This method was confusing to use in practice. Consumers should use the
- BREAKING: Remove
ControllerListas an exported type (#3904)- There is no replacement.
- Add types
ComposableControllerState,ComposableControllerStateChangeEvent,ComposableControllerEvents,ComposableControllerMessenger(#3590)
- BREAKING:
ComposableControlleris upgraded to extendBaseControllerV2(#3590)- The constructor now expects an options object with required properties
controllersandmessengeras its only argument. ComposableControllerno longer has asubscribemethod. Instead, listeners forComposableControllerevents must be registered to the controller messenger that generated the restricted messenger assigned to the instance'smessagingSystemclass field.- Any getters for
ComposableControllerstate that access the internal class field directly should be refactored to instead use listeners that are subscribed toComposableControllerStateChangeEvent.
- The constructor now expects an options object with required properties
- Bump
@metamask/base-controllerto^4.0.1(#3695)
- BREAKING: Bump
@metamask/base-controllerto ^4.0.0 (#2063)- This is breaking because the type of the
messengerhas backward-incompatible changes. See the changelog for this package for more.
- This is breaking because the type of the
- Bump dependency on
@metamask/base-controllerto ^3.2.3 (#1747)
- Update TypeScript to v4.8.x (#1718)
- Bump dependency on
@metamask/base-controllerto ^3.2.1
- BREAKING: Bump to Node 16 (#1262)
- BREAKING: Remove
isomorphic-fetch(#1106)- Consumers must now import
isomorphic-fetchor another polyfill themselves if they are running in an environment withoutfetch
- Consumers must now import
- Relax dependency on
@metamask/controller-utils(use^instead of~) (#998)
-
Initial release
-
As a result of converting our shared controllers repo into a monorepo (#831), we've created this package from select parts of
@metamask/controllersv33.0.0, namely:src/ComposableController.tssrc/ComposableController.test.ts
All changes listed after this point were applied to this package following the monorepo conversion.
-