-
-
Notifications
You must be signed in to change notification settings - Fork 630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: decouple CCs and messages from host instance, split ZWaveNode class into "mixins" #7260
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AlCalzone
changed the title
refactor: split ZWaveNode class into "mixins"
refactor: decouple CCs and messages from host instance, split ZWaveNode class into "mixins"
Oct 16, 2024
AlCalzone
force-pushed
the
mixin-refactor
branch
from
October 17, 2024 07:01
2df4e79
to
a02315e
Compare
AlCalzone
force-pushed
the
mixin-refactor
branch
from
October 17, 2024 07:21
5b6de82
to
c4daea5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CC and Serial API message instances were decoupled from the host instance they previously required. Instead, contexts with the relevant functionality are now passed where they are necessary (parsing, serializing, interview, ...).
A lot of the code has been reworked to define which functionality is expected from those contexts. To do so, the previous
ZWaveHost
andZWaveApplicationHost
interfaces have been split into multiple smaller "traits".Edit: While working on this PR, the focus has drastically changed. The original change is still in there, but it's merely a side effect now:
Although TS 5.6 made working with large files more bearable, it's time to start breaking the biggest offenders into smaller chunks, starting with the
ZWaveNode
class.With this PR, related functionality is now grouped into individual "mixin" classes. They are not really mixins in the traditional sense, but rather a long chain of partial classes that are inherited to compose the building blocks of the
ZWaveNode
class.List of breaking API changes:
ZWaveHost
andZWaveApplicationHost
interfaces have been split into multiple smaller "traits"Driver
class still implements all those traits, but receiving functions now just require the necessary subset.CommandClassDeserializationOptions
type now contains all additional info it needs in the new propertycontext: CCParsingContext
.frameType
was moved there.ZWaveHost
as the first parameter. All needed information has been merged into theCCParsingContext
type.CommandClass.from
method no longer takes an instance ofZWaveHost
as the first parameter for the same reason.CommandClass
instances no longer store a reference to their host. They are now "just data".serialize()
implementations of CCs now take an argument of typeCCEncodingContext
toLogEntry()
implementations of CCs now take an argument of typeGetValueDB
instead ofZWaveHost
interview()
implementations of CCs now take an argument of typeInterviewContext
instead ofZWaveApplicationHost
refreshValues()
implementations of CCs now take an argument of typeRefreshValuesContext
instead ofZWaveApplicationHost
persistValues()
implementations of CCs now take an argument of typePersistValuesContext
instead ofZWaveApplicationHost
translateProperty()
andtranslatePropertyKey()
implementations of CCs now take an argument of typeGetValueDB
instead ofZWaveApplicationHost
mergePartialCCs
signature has changed:ICommandClass
interface has been eliminated. Where applicable, it has been replaced with theCCId
interface whose sole purpose is to identify the command and destination of a CC.IZWaveNode
,IZWaveEndpoint
,IVirtualNode
andIVirtualEndpoint
interfaces have been eliminated and replaced with more specific "trait" interfaces where they were previously used.TestingHost
,TestNode
andTestEndpoint
interfaces and implementations have been reworked to be more declarative and require less input in tests.MessageDeserializationOptions
type now contains all additional info it needs in the new propertyctx: MessageParsingContext
.Message
constructors no longer take an instance ofZWaveHost
as the first parameter. All needed information has been merged into theMessageParsingContext
type.Message.from
method no longer takes an instance ofZWaveHost
as the first parameter for the same reason.callbackId
of aMessage
instance is no longer automatically generated when reading it for the first time. Instead, thecallbackId
can be undefined and has to be explicitly set before serializing if necessary.serialize()
implementations ofMessage
s now take an argument of typeMessageEncodingContext
Message.getNodeUnsafe()
method has been renamed toMessage.tryGetNode
Driver.getNodeUnsafe(message)
method has been renamed toDriver.tryGetNode(message)
Driver.controllerLog
is no longer public.Driver.getSafeCCVersion
can now returnundefined
if the requested CC is not implemented inzwave-js
Driver.isControllerNode(nodeId)
has been removed. Compare withownNodeId
instead.Endpoint.getNodeUnsafe()
method has been renamed totryGetNode