@matter/node 0.18.0 → 0.18.1-alpha.0-20261111-b89790712
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/behavior/Behavior.d.ts.map +1 -1
- package/dist/cjs/behavior/Behavior.js +2 -0
- package/dist/cjs/behavior/Behavior.js.map +1 -1
- package/dist/cjs/behavior/Events.d.ts.map +1 -1
- package/dist/cjs/behavior/Events.js +4 -2
- package/dist/cjs/behavior/Events.js.map +1 -1
- package/dist/cjs/behavior/cluster/ClusterBehavior.d.ts +17 -3
- package/dist/cjs/behavior/cluster/ClusterBehavior.d.ts.map +1 -1
- package/dist/cjs/behavior/cluster/ClusterBehavior.js +2 -20
- package/dist/cjs/behavior/cluster/ClusterBehavior.js.map +1 -1
- package/dist/cjs/behavior/cluster/ClusterBehaviorType.d.ts.map +1 -1
- package/dist/cjs/behavior/cluster/ClusterBehaviorType.js +8 -150
- package/dist/cjs/behavior/cluster/ClusterBehaviorType.js.map +1 -1
- package/dist/cjs/behavior/internal/BehaviorBacking.d.ts.map +1 -1
- package/dist/cjs/behavior/internal/BehaviorBacking.js +2 -0
- package/dist/cjs/behavior/internal/BehaviorBacking.js.map +1 -1
- package/dist/cjs/behavior/internal/ClusterDerivation.d.ts +45 -0
- package/dist/cjs/behavior/internal/ClusterDerivation.d.ts.map +1 -0
- package/dist/cjs/behavior/internal/ClusterDerivation.js +192 -0
- package/dist/cjs/behavior/internal/ClusterDerivation.js.map +6 -0
- package/dist/cjs/behavior/internal/ClusterStatics.d.ts +16 -0
- package/dist/cjs/behavior/internal/ClusterStatics.d.ts.map +1 -0
- package/dist/cjs/behavior/internal/ClusterStatics.js +138 -0
- package/dist/cjs/behavior/internal/ClusterStatics.js.map +6 -0
- package/dist/cjs/behavior/internal/ModeledState.d.ts +18 -0
- package/dist/cjs/behavior/internal/ModeledState.d.ts.map +1 -0
- package/dist/cjs/behavior/internal/ModeledState.js +54 -0
- package/dist/cjs/behavior/internal/ModeledState.js.map +6 -0
- package/dist/cjs/behavior/internal/ServerBehaviorBacking.d.ts.map +1 -1
- package/dist/cjs/behavior/internal/ServerBehaviorBacking.js +3 -12
- package/dist/cjs/behavior/internal/ServerBehaviorBacking.js.map +1 -1
- package/dist/cjs/behavior/state/managed/Datasource.js +28 -17
- package/dist/cjs/behavior/state/managed/Datasource.js.map +1 -1
- package/dist/cjs/behavior/state/managed/Internal.d.ts +16 -5
- package/dist/cjs/behavior/state/managed/Internal.d.ts.map +1 -1
- package/dist/cjs/behavior/state/managed/Internal.js +23 -25
- package/dist/cjs/behavior/state/managed/Internal.js.map +1 -1
- package/dist/cjs/behavior/state/managed/ManagedReference.d.ts +45 -12
- package/dist/cjs/behavior/state/managed/ManagedReference.d.ts.map +1 -1
- package/dist/cjs/behavior/state/managed/ManagedReference.js +74 -44
- package/dist/cjs/behavior/state/managed/ManagedReference.js.map +1 -1
- package/dist/cjs/behavior/state/managed/ReadOnlyReference.d.ts +31 -0
- package/dist/cjs/behavior/state/managed/ReadOnlyReference.d.ts.map +1 -0
- package/dist/cjs/behavior/state/managed/ReadOnlyReference.js +60 -0
- package/dist/cjs/behavior/state/managed/ReadOnlyReference.js.map +6 -0
- package/dist/cjs/behavior/state/managed/ValReference.d.ts +47 -10
- package/dist/cjs/behavior/state/managed/ValReference.d.ts.map +1 -1
- package/dist/cjs/behavior/state/managed/ValReference.js +29 -0
- package/dist/cjs/behavior/state/managed/ValReference.js.map +2 -2
- package/dist/cjs/behavior/state/managed/values/BitmapManager.js +5 -20
- package/dist/cjs/behavior/state/managed/values/BitmapManager.js.map +1 -1
- package/dist/cjs/behavior/state/managed/values/ListManager.d.ts.map +1 -1
- package/dist/cjs/behavior/state/managed/values/ListManager.js +262 -119
- package/dist/cjs/behavior/state/managed/values/ListManager.js.map +2 -2
- package/dist/cjs/behavior/state/managed/values/StructManager.js +14 -23
- package/dist/cjs/behavior/state/managed/values/StructManager.js.map +2 -2
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts +13 -3
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.js +12 -0
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.js.map +1 -1
- package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.d.ts +9 -1
- package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.d.ts.map +1 -1
- package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.js +9 -0
- package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.js.map +1 -1
- package/dist/cjs/behavior/system/controller/ControllerBehavior.d.ts +2 -1
- package/dist/cjs/behavior/system/controller/ControllerBehavior.d.ts.map +1 -1
- package/dist/cjs/behavior/system/controller/ControllerBehavior.js +2 -1
- package/dist/cjs/behavior/system/controller/ControllerBehavior.js.map +1 -1
- package/dist/cjs/behavior/system/dcl/DclBehavior.d.ts +3 -3
- package/dist/cjs/behavior/system/network/ServerGroupNetworking.d.ts +2 -1
- package/dist/cjs/behavior/system/network/ServerGroupNetworking.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/ServerGroupNetworking.js.map +1 -1
- package/dist/cjs/behavior/system/sessions/SessionsBehavior.d.ts +4 -0
- package/dist/cjs/behavior/system/sessions/SessionsBehavior.d.ts.map +1 -1
- package/dist/cjs/behavior/system/sessions/SessionsBehavior.js +6 -1
- package/dist/cjs/behavior/system/sessions/SessionsBehavior.js.map +1 -1
- package/dist/cjs/behavior/system/subscriptions/SubscriptionStore.d.ts +28 -0
- package/dist/cjs/behavior/system/subscriptions/SubscriptionStore.d.ts.map +1 -0
- package/dist/cjs/behavior/system/subscriptions/SubscriptionStore.js +74 -0
- package/dist/cjs/behavior/system/subscriptions/SubscriptionStore.js.map +6 -0
- package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.d.ts +8 -3
- package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.d.ts.map +1 -1
- package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js +61 -30
- package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
- package/dist/cjs/behaviors/access-control/AccessControlServer.d.ts +2 -2
- package/dist/cjs/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +43 -21
- package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts +29 -23
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +104 -60
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
- package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.d.ts +9 -1
- package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.js +11 -7
- package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.js.map +1 -1
- package/dist/cjs/behaviors/groupcast/GroupcastServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/groupcast/GroupcastServer.js +41 -25
- package/dist/cjs/behaviors/groupcast/GroupcastServer.js.map +2 -2
- package/dist/cjs/behaviors/localization-configuration/LocalizationConfigurationServer.d.ts +1 -1
- package/dist/cjs/behaviors/localization-configuration/LocalizationConfigurationServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/operational-credentials/VendorIdVerification.d.ts +2 -0
- package/dist/cjs/behaviors/operational-credentials/VendorIdVerification.d.ts.map +1 -1
- package/dist/cjs/behaviors/operational-credentials/VendorIdVerification.js +27 -23
- package/dist/cjs/behaviors/operational-credentials/VendorIdVerification.js.map +1 -1
- package/dist/cjs/behaviors/thermostat/ThermostatServer.d.ts +15 -4
- package/dist/cjs/behaviors/thermostat/ThermostatServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/thermostat/ThermostatServer.js +66 -49
- package/dist/cjs/behaviors/thermostat/ThermostatServer.js.map +1 -1
- package/dist/cjs/behaviors/time-format-localization/TimeFormatLocalizationServer.d.ts +4 -4
- package/dist/cjs/behaviors/time-format-localization/TimeFormatLocalizationServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/time-format-localization/TimeFormatLocalizationServer.js.map +1 -1
- package/dist/cjs/endpoint/properties/Behaviors.d.ts.map +1 -1
- package/dist/cjs/endpoint/properties/Behaviors.js +5 -1
- package/dist/cjs/endpoint/properties/Behaviors.js.map +1 -1
- package/dist/cjs/node/ClientNode.d.ts +6 -0
- package/dist/cjs/node/ClientNode.d.ts.map +1 -1
- package/dist/cjs/node/ClientNode.js +6 -0
- package/dist/cjs/node/ClientNode.js.map +1 -1
- package/dist/cjs/node/ServerNode.d.ts.map +1 -1
- package/dist/cjs/node/ServerNode.js +2 -0
- package/dist/cjs/node/ServerNode.js.map +1 -1
- package/dist/cjs/node/client/ClientEventEmitter.d.ts.map +1 -1
- package/dist/cjs/node/client/ClientEventEmitter.js +6 -2
- package/dist/cjs/node/client/ClientEventEmitter.js.map +1 -1
- package/dist/cjs/node/client/ClientStructure.d.ts.map +1 -1
- package/dist/cjs/node/client/ClientStructure.js +181 -108
- package/dist/cjs/node/client/ClientStructure.js.map +2 -2
- package/dist/cjs/node/client/Peers.d.ts +3 -2
- package/dist/cjs/node/client/Peers.d.ts.map +1 -1
- package/dist/cjs/node/client/Peers.js +8 -9
- package/dist/cjs/node/client/Peers.js.map +1 -1
- package/dist/cjs/node/integration/ChangeNotificationService.d.ts +14 -3
- package/dist/cjs/node/integration/ChangeNotificationService.d.ts.map +1 -1
- package/dist/cjs/node/integration/ProtocolService.d.ts.map +1 -1
- package/dist/cjs/node/integration/ProtocolService.js +38 -56
- package/dist/cjs/node/integration/ProtocolService.js.map +1 -1
- package/dist/cjs/node/server/InteractionServer.d.ts.map +1 -1
- package/dist/cjs/node/server/InteractionServer.js +28 -24
- package/dist/cjs/node/server/InteractionServer.js.map +2 -2
- package/dist/cjs/node/server/ServerSubscription.d.ts +7 -2
- package/dist/cjs/node/server/ServerSubscription.d.ts.map +1 -1
- package/dist/cjs/node/server/ServerSubscription.js +83 -47
- package/dist/cjs/node/server/ServerSubscription.js.map +1 -1
- package/dist/cjs/testing/mock-server-node.d.ts +2 -1
- package/dist/cjs/testing/mock-server-node.d.ts.map +1 -1
- package/dist/cjs/testing/mock-server-node.js +8 -5
- package/dist/cjs/testing/mock-server-node.js.map +2 -2
- package/dist/cjs/testing/node-helpers.d.ts +5 -0
- package/dist/cjs/testing/node-helpers.d.ts.map +1 -1
- package/dist/cjs/testing/node-helpers.js +4 -4
- package/dist/cjs/testing/node-helpers.js.map +1 -1
- package/dist/esm/behavior/Behavior.d.ts.map +1 -1
- package/dist/esm/behavior/Behavior.js +2 -0
- package/dist/esm/behavior/Behavior.js.map +1 -1
- package/dist/esm/behavior/Events.d.ts.map +1 -1
- package/dist/esm/behavior/Events.js +4 -2
- package/dist/esm/behavior/Events.js.map +1 -1
- package/dist/esm/behavior/cluster/ClusterBehavior.d.ts +17 -3
- package/dist/esm/behavior/cluster/ClusterBehavior.d.ts.map +1 -1
- package/dist/esm/behavior/cluster/ClusterBehavior.js +2 -20
- package/dist/esm/behavior/cluster/ClusterBehavior.js.map +1 -1
- package/dist/esm/behavior/cluster/ClusterBehaviorType.d.ts.map +1 -1
- package/dist/esm/behavior/cluster/ClusterBehaviorType.js +10 -159
- package/dist/esm/behavior/cluster/ClusterBehaviorType.js.map +1 -1
- package/dist/esm/behavior/internal/BehaviorBacking.d.ts.map +1 -1
- package/dist/esm/behavior/internal/BehaviorBacking.js +2 -0
- package/dist/esm/behavior/internal/BehaviorBacking.js.map +1 -1
- package/dist/esm/behavior/internal/ClusterDerivation.d.ts +45 -0
- package/dist/esm/behavior/internal/ClusterDerivation.d.ts.map +1 -0
- package/dist/esm/behavior/internal/ClusterDerivation.js +172 -0
- package/dist/esm/behavior/internal/ClusterDerivation.js.map +6 -0
- package/dist/esm/behavior/internal/ClusterStatics.d.ts +16 -0
- package/dist/esm/behavior/internal/ClusterStatics.d.ts.map +1 -0
- package/dist/esm/behavior/internal/ClusterStatics.js +118 -0
- package/dist/esm/behavior/internal/ClusterStatics.js.map +6 -0
- package/dist/esm/behavior/internal/ModeledState.d.ts +18 -0
- package/dist/esm/behavior/internal/ModeledState.d.ts.map +1 -0
- package/dist/esm/behavior/internal/ModeledState.js +34 -0
- package/dist/esm/behavior/internal/ModeledState.js.map +6 -0
- package/dist/esm/behavior/internal/ServerBehaviorBacking.d.ts.map +1 -1
- package/dist/esm/behavior/internal/ServerBehaviorBacking.js +3 -12
- package/dist/esm/behavior/internal/ServerBehaviorBacking.js.map +1 -1
- package/dist/esm/behavior/state/managed/Datasource.js +28 -17
- package/dist/esm/behavior/state/managed/Datasource.js.map +1 -1
- package/dist/esm/behavior/state/managed/Internal.d.ts +16 -5
- package/dist/esm/behavior/state/managed/Internal.d.ts.map +1 -1
- package/dist/esm/behavior/state/managed/Internal.js +23 -25
- package/dist/esm/behavior/state/managed/Internal.js.map +1 -1
- package/dist/esm/behavior/state/managed/ManagedReference.d.ts +45 -12
- package/dist/esm/behavior/state/managed/ManagedReference.d.ts.map +1 -1
- package/dist/esm/behavior/state/managed/ManagedReference.js +75 -45
- package/dist/esm/behavior/state/managed/ManagedReference.js.map +1 -1
- package/dist/esm/behavior/state/managed/ReadOnlyReference.d.ts +31 -0
- package/dist/esm/behavior/state/managed/ReadOnlyReference.d.ts.map +1 -0
- package/dist/esm/behavior/state/managed/ReadOnlyReference.js +40 -0
- package/dist/esm/behavior/state/managed/ReadOnlyReference.js.map +6 -0
- package/dist/esm/behavior/state/managed/ValReference.d.ts +47 -10
- package/dist/esm/behavior/state/managed/ValReference.d.ts.map +1 -1
- package/dist/esm/behavior/state/managed/ValReference.js +25 -0
- package/dist/esm/behavior/state/managed/ValReference.js.map +2 -2
- package/dist/esm/behavior/state/managed/values/BitmapManager.js +6 -21
- package/dist/esm/behavior/state/managed/values/BitmapManager.js.map +1 -1
- package/dist/esm/behavior/state/managed/values/ListManager.d.ts.map +1 -1
- package/dist/esm/behavior/state/managed/values/ListManager.js +264 -129
- package/dist/esm/behavior/state/managed/values/ListManager.js.map +2 -2
- package/dist/esm/behavior/state/managed/values/StructManager.js +15 -24
- package/dist/esm/behavior/state/managed/values/StructManager.js.map +2 -2
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts +13 -3
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.js +12 -0
- package/dist/esm/behavior/system/commissioning/CommissioningClient.js.map +1 -1
- package/dist/esm/behavior/system/commissioning/RemoteDescriptor.d.ts +9 -1
- package/dist/esm/behavior/system/commissioning/RemoteDescriptor.d.ts.map +1 -1
- package/dist/esm/behavior/system/commissioning/RemoteDescriptor.js +10 -1
- package/dist/esm/behavior/system/commissioning/RemoteDescriptor.js.map +1 -1
- package/dist/esm/behavior/system/controller/ControllerBehavior.d.ts +2 -1
- package/dist/esm/behavior/system/controller/ControllerBehavior.d.ts.map +1 -1
- package/dist/esm/behavior/system/controller/ControllerBehavior.js +2 -1
- package/dist/esm/behavior/system/controller/ControllerBehavior.js.map +1 -1
- package/dist/esm/behavior/system/dcl/DclBehavior.d.ts +3 -3
- package/dist/esm/behavior/system/network/ServerGroupNetworking.d.ts +2 -1
- package/dist/esm/behavior/system/network/ServerGroupNetworking.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/ServerGroupNetworking.js.map +1 -1
- package/dist/esm/behavior/system/sessions/SessionsBehavior.d.ts +4 -0
- package/dist/esm/behavior/system/sessions/SessionsBehavior.d.ts.map +1 -1
- package/dist/esm/behavior/system/sessions/SessionsBehavior.js +6 -1
- package/dist/esm/behavior/system/sessions/SessionsBehavior.js.map +1 -1
- package/dist/esm/behavior/system/subscriptions/SubscriptionStore.d.ts +28 -0
- package/dist/esm/behavior/system/subscriptions/SubscriptionStore.d.ts.map +1 -0
- package/dist/esm/behavior/system/subscriptions/SubscriptionStore.js +54 -0
- package/dist/esm/behavior/system/subscriptions/SubscriptionStore.js.map +6 -0
- package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.d.ts +8 -3
- package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.d.ts.map +1 -1
- package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js +61 -30
- package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
- package/dist/esm/behaviors/access-control/AccessControlServer.d.ts +2 -2
- package/dist/esm/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
- package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
- package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +43 -21
- package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts +29 -23
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +105 -60
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
- package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.d.ts +9 -1
- package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.d.ts.map +1 -1
- package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.js +11 -7
- package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.js.map +1 -1
- package/dist/esm/behaviors/groupcast/GroupcastServer.d.ts.map +1 -1
- package/dist/esm/behaviors/groupcast/GroupcastServer.js +42 -25
- package/dist/esm/behaviors/groupcast/GroupcastServer.js.map +2 -2
- package/dist/esm/behaviors/localization-configuration/LocalizationConfigurationServer.d.ts +1 -1
- package/dist/esm/behaviors/localization-configuration/LocalizationConfigurationServer.d.ts.map +1 -1
- package/dist/esm/behaviors/operational-credentials/VendorIdVerification.d.ts +2 -0
- package/dist/esm/behaviors/operational-credentials/VendorIdVerification.d.ts.map +1 -1
- package/dist/esm/behaviors/operational-credentials/VendorIdVerification.js +32 -24
- package/dist/esm/behaviors/operational-credentials/VendorIdVerification.js.map +1 -1
- package/dist/esm/behaviors/thermostat/ThermostatServer.d.ts +15 -4
- package/dist/esm/behaviors/thermostat/ThermostatServer.d.ts.map +1 -1
- package/dist/esm/behaviors/thermostat/ThermostatServer.js +66 -49
- package/dist/esm/behaviors/thermostat/ThermostatServer.js.map +1 -1
- package/dist/esm/behaviors/time-format-localization/TimeFormatLocalizationServer.d.ts +4 -4
- package/dist/esm/behaviors/time-format-localization/TimeFormatLocalizationServer.d.ts.map +1 -1
- package/dist/esm/behaviors/time-format-localization/TimeFormatLocalizationServer.js.map +1 -1
- package/dist/esm/endpoint/properties/Behaviors.d.ts.map +1 -1
- package/dist/esm/endpoint/properties/Behaviors.js +6 -2
- package/dist/esm/endpoint/properties/Behaviors.js.map +1 -1
- package/dist/esm/node/ClientNode.d.ts +6 -0
- package/dist/esm/node/ClientNode.d.ts.map +1 -1
- package/dist/esm/node/ClientNode.js +6 -0
- package/dist/esm/node/ClientNode.js.map +1 -1
- package/dist/esm/node/ServerNode.d.ts.map +1 -1
- package/dist/esm/node/ServerNode.js +2 -0
- package/dist/esm/node/ServerNode.js.map +1 -1
- package/dist/esm/node/client/ClientEventEmitter.d.ts.map +1 -1
- package/dist/esm/node/client/ClientEventEmitter.js +6 -2
- package/dist/esm/node/client/ClientEventEmitter.js.map +1 -1
- package/dist/esm/node/client/ClientStructure.d.ts.map +1 -1
- package/dist/esm/node/client/ClientStructure.js +181 -108
- package/dist/esm/node/client/ClientStructure.js.map +2 -2
- package/dist/esm/node/client/Peers.d.ts +3 -2
- package/dist/esm/node/client/Peers.d.ts.map +1 -1
- package/dist/esm/node/client/Peers.js +8 -10
- package/dist/esm/node/client/Peers.js.map +1 -1
- package/dist/esm/node/integration/ChangeNotificationService.d.ts +14 -3
- package/dist/esm/node/integration/ChangeNotificationService.d.ts.map +1 -1
- package/dist/esm/node/integration/ProtocolService.d.ts.map +1 -1
- package/dist/esm/node/integration/ProtocolService.js +40 -57
- package/dist/esm/node/integration/ProtocolService.js.map +1 -1
- package/dist/esm/node/server/InteractionServer.d.ts.map +1 -1
- package/dist/esm/node/server/InteractionServer.js +28 -25
- package/dist/esm/node/server/InteractionServer.js.map +2 -2
- package/dist/esm/node/server/ServerSubscription.d.ts +7 -2
- package/dist/esm/node/server/ServerSubscription.d.ts.map +1 -1
- package/dist/esm/node/server/ServerSubscription.js +83 -47
- package/dist/esm/node/server/ServerSubscription.js.map +1 -1
- package/dist/esm/testing/mock-server-node.d.ts +2 -1
- package/dist/esm/testing/mock-server-node.d.ts.map +1 -1
- package/dist/esm/testing/mock-server-node.js +16 -7
- package/dist/esm/testing/mock-server-node.js.map +2 -2
- package/dist/esm/testing/node-helpers.d.ts +5 -0
- package/dist/esm/testing/node-helpers.d.ts.map +1 -1
- package/dist/esm/testing/node-helpers.js +4 -4
- package/dist/esm/testing/node-helpers.js.map +1 -1
- package/package.json +6 -6
- package/src/behavior/Behavior.ts +2 -0
- package/src/behavior/Events.ts +6 -3
- package/src/behavior/cluster/ClusterBehavior.ts +22 -13
- package/src/behavior/cluster/ClusterBehaviorType.ts +9 -270
- package/src/behavior/internal/BehaviorBacking.ts +3 -0
- package/src/behavior/internal/ClusterDerivation.ts +295 -0
- package/src/behavior/internal/ClusterStatics.ts +180 -0
- package/src/behavior/internal/ModeledState.ts +58 -0
- package/src/behavior/internal/ServerBehaviorBacking.ts +3 -15
- package/src/behavior/state/managed/Datasource.ts +36 -21
- package/src/behavior/state/managed/Internal.ts +36 -33
- package/src/behavior/state/managed/ManagedReference.ts +120 -68
- package/src/behavior/state/managed/ReadOnlyReference.ts +54 -0
- package/src/behavior/state/managed/ValReference.ts +67 -11
- package/src/behavior/state/managed/values/BitmapManager.ts +6 -22
- package/src/behavior/state/managed/values/ListManager.ts +301 -146
- package/src/behavior/state/managed/values/StructManager.ts +20 -29
- package/src/behavior/system/commissioning/CommissioningClient.ts +22 -3
- package/src/behavior/system/commissioning/RemoteDescriptor.ts +17 -1
- package/src/behavior/system/controller/ControllerBehavior.ts +2 -1
- package/src/behavior/system/dcl/DclBehavior.ts +3 -3
- package/src/behavior/system/network/ServerGroupNetworking.ts +3 -2
- package/src/behavior/system/sessions/SessionsBehavior.ts +8 -2
- package/src/behavior/system/subscriptions/SubscriptionStore.ts +66 -0
- package/src/behavior/system/subscriptions/SubscriptionsServer.ts +73 -33
- package/src/behaviors/access-control/AccessControlServer.ts +3 -3
- package/src/behaviors/administrator-commissioning/AdministratorCommissioningServer.ts +47 -24
- package/src/behaviors/general-diagnostics/GeneralDiagnosticsServer.ts +138 -84
- package/src/behaviors/group-key-management/GroupKeyManagementServer.ts +12 -8
- package/src/behaviors/groupcast/GroupcastServer.ts +50 -34
- package/src/behaviors/localization-configuration/LocalizationConfigurationServer.ts +1 -1
- package/src/behaviors/operational-credentials/VendorIdVerification.ts +50 -35
- package/src/behaviors/thermostat/ThermostatServer.ts +93 -70
- package/src/behaviors/time-format-localization/TimeFormatLocalizationServer.ts +4 -4
- package/src/endpoint/properties/Behaviors.ts +6 -2
- package/src/node/ClientNode.ts +6 -0
- package/src/node/ServerNode.ts +2 -0
- package/src/node/client/ClientEventEmitter.ts +7 -3
- package/src/node/client/ClientStructure.ts +208 -135
- package/src/node/client/Peers.ts +10 -14
- package/src/node/integration/ChangeNotificationService.ts +18 -3
- package/src/node/integration/ProtocolService.ts +45 -57
- package/src/node/server/InteractionServer.ts +33 -35
- package/src/node/server/ServerSubscription.ts +88 -50
- package/src/testing/mock-server-node.ts +22 -9
- package/src/testing/node-helpers.ts +5 -1
|
@@ -4,26 +4,18 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { isObject, serialize } from "@matter/general";
|
|
7
|
+
import { InternalError, isObject, serialize } from "@matter/general";
|
|
8
8
|
import type { Schema } from "@matter/model";
|
|
9
9
|
import { Access, AttributeModel, DataModelPath, ValueModel } from "@matter/model";
|
|
10
|
-
import {
|
|
11
|
-
AccessControl,
|
|
12
|
-
ExpiredReferenceError,
|
|
13
|
-
hasLocalActor,
|
|
14
|
-
hasRemoteActor,
|
|
15
|
-
ReadError,
|
|
16
|
-
SchemaImplementationError,
|
|
17
|
-
Val,
|
|
18
|
-
WriteError,
|
|
19
|
-
} from "@matter/protocol";
|
|
10
|
+
import { AccessControl, hasRemoteActor, ReadError, SchemaImplementationError, Val, WriteError } from "@matter/protocol";
|
|
20
11
|
import { Status } from "@matter/types";
|
|
21
12
|
import type { RootSupervisor } from "../../../supervision/RootSupervisor.js";
|
|
22
13
|
import type { ValueSupervisor } from "../../../supervision/ValueSupervisor.js";
|
|
23
14
|
import type { ValidationLocation } from "../../validation/location.js";
|
|
24
15
|
import { Internal } from "../Internal.js";
|
|
25
16
|
import { ManagedReference } from "../ManagedReference.js";
|
|
26
|
-
import
|
|
17
|
+
import { ReadOnlyReference } from "../ReadOnlyReference.js";
|
|
18
|
+
import { ValReference } from "../ValReference.js";
|
|
27
19
|
import { PrimitiveManager } from "./PrimitiveManager.js";
|
|
28
20
|
|
|
29
21
|
/**
|
|
@@ -100,7 +92,6 @@ interface ListConfig {
|
|
|
100
92
|
authorizeWrite: AccessControl["authorizeWrite"];
|
|
101
93
|
}
|
|
102
94
|
|
|
103
|
-
const assertWriteOkAlways = () => true;
|
|
104
95
|
const cloneEntry = (val: Val) => (Array.isArray(val) ? [...(val as Val.List)] : isObject(val) ? { ...val } : val);
|
|
105
96
|
const inspectCustom = Symbol.for("nodejs.util.inspect.custom");
|
|
106
97
|
|
|
@@ -112,6 +103,35 @@ function inspectList(this: Val.List) {
|
|
|
112
103
|
return [...this];
|
|
113
104
|
}
|
|
114
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Maximum number of entries in a list: list indices are 16 bits wide.
|
|
108
|
+
*/
|
|
109
|
+
const MAX_LIST_LENGTH = 65536;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Array methods that add, remove, overwrite, move or insert entries. The proxy runs them on a plain array of the
|
|
113
|
+
* visible entries; see {@link ListProxyHandler.editEntries}.
|
|
114
|
+
*/
|
|
115
|
+
const entryEdits = new Map<PropertyKey, (...args: never[]) => unknown>([
|
|
116
|
+
["copyWithin", Array.prototype.copyWithin],
|
|
117
|
+
["fill", Array.prototype.fill],
|
|
118
|
+
["pop", Array.prototype.pop],
|
|
119
|
+
["push", Array.prototype.push],
|
|
120
|
+
["reverse", Array.prototype.reverse],
|
|
121
|
+
["shift", Array.prototype.shift],
|
|
122
|
+
["sort", Array.prototype.sort],
|
|
123
|
+
["splice", Array.prototype.splice],
|
|
124
|
+
["unshift", Array.prototype.unshift],
|
|
125
|
+
]);
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The list index a property key names, or `undefined` for any other key. Like an array, the list treats only the
|
|
129
|
+
* canonical decimal form as an index, so `"1.5"` and `"01"` are not indices.
|
|
130
|
+
*/
|
|
131
|
+
function entryIndexFor(property: PropertyKey) {
|
|
132
|
+
return typeof property === "string" && /^(0|[1-9]\d*)$/.test(property) ? Number.parseInt(property) : undefined;
|
|
133
|
+
}
|
|
134
|
+
|
|
115
135
|
class ListProxyHandler implements ProxyHandler<Val.List> {
|
|
116
136
|
protected reference: ValReference<Val.List>;
|
|
117
137
|
protected session: ValueSupervisor.Session;
|
|
@@ -130,14 +150,11 @@ class ListProxyHandler implements ProxyHandler<Val.List> {
|
|
|
130
150
|
}
|
|
131
151
|
|
|
132
152
|
protected readVal() {
|
|
133
|
-
return this.reference
|
|
153
|
+
return ValReference.containerOf(this.reference);
|
|
134
154
|
}
|
|
135
155
|
|
|
136
156
|
protected writeVal() {
|
|
137
|
-
|
|
138
|
-
throw new ExpiredReferenceError(this.reference.location);
|
|
139
|
-
}
|
|
140
|
-
return this.reference.value;
|
|
157
|
+
return ValReference.writableContainerOf(this.reference);
|
|
141
158
|
}
|
|
142
159
|
|
|
143
160
|
protected getListLength() {
|
|
@@ -145,10 +162,14 @@ class ListProxyHandler implements ProxyHandler<Val.List> {
|
|
|
145
162
|
}
|
|
146
163
|
|
|
147
164
|
protected setListLength(length: number) {
|
|
148
|
-
|
|
149
|
-
|
|
165
|
+
this.config.authorizeWrite(this.session, this.reference.location);
|
|
166
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
167
|
+
throw new WriteError(this.reference.location, `Length ${length} is not a valid list length`);
|
|
168
|
+
}
|
|
169
|
+
if (length > this.getListLength()) {
|
|
170
|
+
throw new WriteError(this.reference.location, `Length ${length} would leave a gap after the last entry`);
|
|
150
171
|
}
|
|
151
|
-
this.
|
|
172
|
+
this.storeEntries(this.visibleEntries().slice(0, length));
|
|
152
173
|
}
|
|
153
174
|
|
|
154
175
|
protected hasEntry(index: number) {
|
|
@@ -163,8 +184,11 @@ class ListProxyHandler implements ProxyHandler<Val.List> {
|
|
|
163
184
|
throw new ReadError(this.reference.location, `Index ${index} is out of bounds`);
|
|
164
185
|
}
|
|
165
186
|
|
|
166
|
-
if (index
|
|
167
|
-
throw new ReadError(
|
|
187
|
+
if (index >= MAX_LIST_LENGTH) {
|
|
188
|
+
throw new ReadError(
|
|
189
|
+
this.reference.location,
|
|
190
|
+
`Index ${index} is greater than allowed maximum of ${MAX_LIST_LENGTH - 1}`,
|
|
191
|
+
);
|
|
168
192
|
}
|
|
169
193
|
|
|
170
194
|
const value = this.readVal()[index];
|
|
@@ -175,14 +199,7 @@ class ListProxyHandler implements ProxyHandler<Val.List> {
|
|
|
175
199
|
let subref = this.reference.subrefs?.[index];
|
|
176
200
|
|
|
177
201
|
if (subref === undefined) {
|
|
178
|
-
subref = new ManagedReference(
|
|
179
|
-
this.reference,
|
|
180
|
-
index,
|
|
181
|
-
undefined,
|
|
182
|
-
assertWriteOkAlways,
|
|
183
|
-
cloneEntry,
|
|
184
|
-
this.session,
|
|
185
|
-
);
|
|
202
|
+
subref = new ManagedReference(this.reference, index, undefined, cloneEntry, this.session, "entry");
|
|
186
203
|
|
|
187
204
|
this.config.manageEntry(subref, this.session);
|
|
188
205
|
}
|
|
@@ -202,35 +219,181 @@ class ListProxyHandler implements ProxyHandler<Val.List> {
|
|
|
202
219
|
*
|
|
203
220
|
* Invoked before the entry is validated, because validation judges the entry as a whole.
|
|
204
221
|
*/
|
|
205
|
-
protected prepareEntry(value: Val): Val {
|
|
222
|
+
protected prepareEntry(value: Val, _location: AccessControl.Location): Val {
|
|
206
223
|
return value;
|
|
207
224
|
}
|
|
208
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Store a prepared, validated entry after the caller authorized the write. The caller passes a value the list may
|
|
228
|
+
* own; see {@link Internal.copy}.
|
|
229
|
+
*/
|
|
209
230
|
protected writeEntry(index: number, value: Val, location: AccessControl.Location) {
|
|
210
|
-
this.
|
|
211
|
-
|
|
212
|
-
if (index < 0 || index > this.readVal().length + 1) {
|
|
231
|
+
if (index < 0 || index > this.readVal().length) {
|
|
213
232
|
throw new WriteError(location, `Index ${index} is out of bounds`);
|
|
214
233
|
}
|
|
215
234
|
|
|
216
|
-
if (index
|
|
217
|
-
throw new
|
|
235
|
+
if (index >= MAX_LIST_LENGTH) {
|
|
236
|
+
throw new WriteError(location, `Index ${index} is greater than allowed maximum of ${MAX_LIST_LENGTH - 1}`);
|
|
218
237
|
}
|
|
219
238
|
|
|
220
|
-
// Unwrap incoming managed values (including nested)
|
|
221
|
-
value = Internal.unmanage(value);
|
|
222
|
-
|
|
223
239
|
this.reference.change(() => (this.writeVal()[index] = value), index);
|
|
224
240
|
}
|
|
225
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Remove an entry. Only the last entry may go, so the list never has a gap. An index beyond the end is ignored.
|
|
244
|
+
*/
|
|
245
|
+
protected deleteEntry(index: number, location: AccessControl.Location) {
|
|
246
|
+
const length = this.getListLength();
|
|
247
|
+
if (index >= length) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (index !== length - 1) {
|
|
251
|
+
throw new WriteError(location, `Deleting entry ${index} would leave a gap; use splice to remove it`);
|
|
252
|
+
}
|
|
253
|
+
this.setListLength(index);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The stored entries this session sees, in the order of the indices {@link readEntry} and {@link writeEntry} use.
|
|
258
|
+
*/
|
|
259
|
+
protected visibleEntries(): Val[] {
|
|
260
|
+
return [...this.readVal()];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Replace the entries {@link visibleEntries} returns with `entries` in a single change. Throws {@link WriteError}
|
|
265
|
+
* when the list would exceed {@link MAX_LIST_LENGTH}.
|
|
266
|
+
*
|
|
267
|
+
* An entry that `entries` holds more than once is stored once and copied into its other slots, because the
|
|
268
|
+
* transaction may own the entry and a nested write changes an owned entry in place (see {@link ValReference.owns}).
|
|
269
|
+
* The original stays at the slot that already holds it, so the reference held for that slot stays live.
|
|
270
|
+
*/
|
|
271
|
+
protected storeEntries(entries: Val[]) {
|
|
272
|
+
if (entries.length > MAX_LIST_LENGTH) {
|
|
273
|
+
throw new WriteError(
|
|
274
|
+
this.reference.location,
|
|
275
|
+
`Length ${entries.length} exceeds the maximum of ${MAX_LIST_LENGTH}`,
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const current = this.readVal();
|
|
280
|
+
const originalSlot = new Map<Val, number>();
|
|
281
|
+
entries.forEach((entry, index) => {
|
|
282
|
+
if (typeof entry !== "object" || entry === null) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const slot = originalSlot.get(entry);
|
|
286
|
+
if (slot === undefined || current[index] === entry) {
|
|
287
|
+
originalSlot.set(entry, index);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
const placed = entries.map((entry, index) =>
|
|
291
|
+
typeof entry === "object" && entry !== null && originalSlot.get(entry) !== index
|
|
292
|
+
? Internal.copy(entry)
|
|
293
|
+
: entry,
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
this.reference.change(() => {
|
|
297
|
+
const list = this.writeVal();
|
|
298
|
+
placed.forEach((entry, index) => (list[index] = entry));
|
|
299
|
+
list.length = placed.length;
|
|
300
|
+
}, "length");
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Apply an array method that changes entries, and return its result.
|
|
305
|
+
*
|
|
306
|
+
* The method runs on a plain array of the visible entries, so it moves entry objects rather than entry proxies. A
|
|
307
|
+
* stored entry keeps its value. Every other value is new: it is copied, prepared and validated before anything is
|
|
308
|
+
* stored. The result is stored in a single change, so a rejected entry leaves the list unchanged.
|
|
309
|
+
*
|
|
310
|
+
* A stored entry leaves this method only as a read-only view (see {@link ReadOnlyReference}): the entries `pop`,
|
|
311
|
+
* `shift` and `splice` remove, and the entries a `sort` comparator receives. A method that returns its array
|
|
312
|
+
* returns the list itself.
|
|
313
|
+
*/
|
|
314
|
+
protected editEntries(method: (...args: never[]) => unknown, args: unknown[], receiver: Val.List): unknown {
|
|
315
|
+
this.config.authorizeWrite(this.session, this.reference.location);
|
|
316
|
+
|
|
317
|
+
const stored = this.visibleEntries();
|
|
318
|
+
const viewOf = this.#viewsOf(stored);
|
|
319
|
+
const [compare] = args;
|
|
320
|
+
const edited = [...stored];
|
|
321
|
+
const result = Reflect.apply(
|
|
322
|
+
method,
|
|
323
|
+
edited,
|
|
324
|
+
method === Array.prototype.sort && typeof compare === "function"
|
|
325
|
+
? [(a: Val, b: Val): unknown => Reflect.apply(compare, undefined, [viewOf(a), viewOf(b)])]
|
|
326
|
+
: args,
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
const isStored = new Set(stored);
|
|
330
|
+
const entries = edited.map((entry, index) => (isStored.has(entry) ? entry : this.#acceptEntry(entry, index)));
|
|
331
|
+
|
|
332
|
+
this.storeEntries(entries);
|
|
333
|
+
|
|
334
|
+
if (result === edited) {
|
|
335
|
+
return receiver;
|
|
336
|
+
}
|
|
337
|
+
if (method === Array.prototype.splice && Array.isArray(result)) {
|
|
338
|
+
return result.map(viewOf);
|
|
339
|
+
}
|
|
340
|
+
return viewOf(result);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Create a function that returns a read-only managed view of an entry of `stored`, one view per entry. Any other
|
|
345
|
+
* value, and every entry of a list of primitives, is returned unchanged.
|
|
346
|
+
*/
|
|
347
|
+
#viewsOf(stored: Val[]) {
|
|
348
|
+
const views = new Map<Val, Val>();
|
|
349
|
+
let indices: Map<Val, number> | undefined;
|
|
350
|
+
|
|
351
|
+
return (entry: Val) => {
|
|
352
|
+
if (!this.config.manageEntries || typeof entry !== "object" || entry === null) {
|
|
353
|
+
return entry;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
let view = views.get(entry);
|
|
357
|
+
if (view === undefined) {
|
|
358
|
+
indices ??= new Map(stored.map((entry, index) => [entry, index]));
|
|
359
|
+
const index = indices.get(entry);
|
|
360
|
+
if (index === undefined) {
|
|
361
|
+
throw new InternalError(`Entry to view at ${this.reference.location.path} is not a stored entry`);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const location = { ...this.reference.location, path: this.reference.location.path.at(index) };
|
|
365
|
+
const reference = new ReadOnlyReference(entry, location, this.reference.rootOwner);
|
|
366
|
+
this.config.manageEntry(reference, this.session);
|
|
367
|
+
view = reference.owner;
|
|
368
|
+
views.set(entry, view);
|
|
369
|
+
}
|
|
370
|
+
return view;
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Turn a caller's value into an entry the list may store: a copy of the value, prepared and validated. The
|
|
376
|
+
* caller's value stays unchanged.
|
|
377
|
+
*/
|
|
378
|
+
#acceptEntry(value: Val, index: number) {
|
|
379
|
+
this.#sublocation.path.id = index;
|
|
380
|
+
if (value === undefined) {
|
|
381
|
+
throw new WriteError(this.#sublocation, `Entry ${index} has no value`);
|
|
382
|
+
}
|
|
383
|
+
const entry = this.prepareEntry(Internal.copy(value), this.#sublocation);
|
|
384
|
+
this.config.validateEntry?.(entry, this.session, this.#sublocation);
|
|
385
|
+
return entry;
|
|
386
|
+
}
|
|
387
|
+
|
|
226
388
|
protected getIteratorFn(): Val.List[typeof Symbol.iterator] {
|
|
227
389
|
return this.readVal()[Symbol.iterator];
|
|
228
390
|
}
|
|
229
391
|
|
|
230
392
|
get(_target: Val.List, property: PropertyKey, receiver: Val.List) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
393
|
+
const index = entryIndexFor(property);
|
|
394
|
+
if (index !== undefined) {
|
|
395
|
+
this.#sublocation.path.id = index;
|
|
396
|
+
return this.readEntry(index, this.#sublocation);
|
|
234
397
|
}
|
|
235
398
|
|
|
236
399
|
switch (property) {
|
|
@@ -253,15 +416,19 @@ class ListProxyHandler implements ProxyHandler<Val.List> {
|
|
|
253
416
|
return undefined;
|
|
254
417
|
}
|
|
255
418
|
|
|
419
|
+
const method = entryEdits.get(property);
|
|
420
|
+
if (method) {
|
|
421
|
+
return (...args: unknown[]) => this.editEntries(method, args, receiver);
|
|
422
|
+
}
|
|
423
|
+
|
|
256
424
|
return Reflect.get(this.readVal(), property, receiver);
|
|
257
425
|
}
|
|
258
426
|
|
|
259
427
|
set(_target: Val.List, property: PropertyKey, newValue: Val, receiver: Val.List) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.
|
|
264
|
-
this.writeEntry(Number.parseInt(property), newValue, this.#sublocation);
|
|
428
|
+
const index = entryIndexFor(property);
|
|
429
|
+
if (index !== undefined) {
|
|
430
|
+
this.config.authorizeWrite(this.session, this.reference.location);
|
|
431
|
+
this.writeEntry(index, this.#acceptEntry(newValue, index), this.#sublocation);
|
|
265
432
|
return true;
|
|
266
433
|
} else if (property === "length") {
|
|
267
434
|
this.setListLength(newValue as number);
|
|
@@ -272,17 +439,19 @@ class ListProxyHandler implements ProxyHandler<Val.List> {
|
|
|
272
439
|
}
|
|
273
440
|
|
|
274
441
|
has(_target: Val.List, property: PropertyKey) {
|
|
275
|
-
|
|
276
|
-
|
|
442
|
+
const index = entryIndexFor(property);
|
|
443
|
+
if (index !== undefined) {
|
|
444
|
+
return this.hasEntry(index);
|
|
277
445
|
}
|
|
278
446
|
|
|
279
447
|
return Reflect.has(this.readVal(), property);
|
|
280
448
|
}
|
|
281
449
|
|
|
282
450
|
deleteProperty(_target: Val.List, property: PropertyKey) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
this.
|
|
451
|
+
const index = entryIndexFor(property);
|
|
452
|
+
if (index !== undefined) {
|
|
453
|
+
this.#sublocation.path.id = index;
|
|
454
|
+
this.deleteEntry(index, this.#sublocation);
|
|
286
455
|
return true;
|
|
287
456
|
}
|
|
288
457
|
|
|
@@ -293,8 +462,30 @@ class ListProxyHandler implements ProxyHandler<Val.List> {
|
|
|
293
462
|
return Reflect.ownKeys(this.readVal());
|
|
294
463
|
}
|
|
295
464
|
|
|
465
|
+
/**
|
|
466
|
+
* The descriptors of the entries and of `length` carry what {@link get} returns: the managed entry and the length
|
|
467
|
+
* this session sees.
|
|
468
|
+
*/
|
|
296
469
|
getOwnPropertyDescriptor(_target: Val.List, key: PropertyKey) {
|
|
297
|
-
|
|
470
|
+
const index = entryIndexFor(key);
|
|
471
|
+
if (index === undefined) {
|
|
472
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(this.readVal(), key);
|
|
473
|
+
if (key === "length" && descriptor !== undefined) {
|
|
474
|
+
descriptor.value = this.getListLength();
|
|
475
|
+
}
|
|
476
|
+
return descriptor;
|
|
477
|
+
}
|
|
478
|
+
if (index >= this.getListLength()) {
|
|
479
|
+
return undefined;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
this.#sublocation.path.id = index;
|
|
483
|
+
return {
|
|
484
|
+
value: this.readEntry(index, this.#sublocation),
|
|
485
|
+
writable: true,
|
|
486
|
+
enumerable: true,
|
|
487
|
+
configurable: true,
|
|
488
|
+
};
|
|
298
489
|
}
|
|
299
490
|
}
|
|
300
491
|
|
|
@@ -303,6 +494,14 @@ class ListProxyHandler implements ProxyHandler<Val.List> {
|
|
|
303
494
|
* list with fabric filtering enabled, logical indices are mapped to physical indices that match the actor's fabric.
|
|
304
495
|
*/
|
|
305
496
|
class FabricFilteredListProxyHandler extends ListProxyHandler {
|
|
497
|
+
#isVisible(entry: Val) {
|
|
498
|
+
if (!isObject(entry)) {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
const { fabricIndex } = entry as { fabricIndex?: number };
|
|
502
|
+
return !fabricIndex || fabricIndex === this.session.fabric;
|
|
503
|
+
}
|
|
504
|
+
|
|
306
505
|
#mapScopedToActual(index: number, reading: boolean) {
|
|
307
506
|
if (index < 0) {
|
|
308
507
|
throw new (reading ? ReadError : WriteError)(
|
|
@@ -311,14 +510,10 @@ class FabricFilteredListProxyHandler extends ListProxyHandler {
|
|
|
311
510
|
);
|
|
312
511
|
}
|
|
313
512
|
|
|
513
|
+
const list = reading ? this.readVal() : this.writeVal();
|
|
314
514
|
let nextPos = 0;
|
|
315
|
-
for (let i = 0; i <
|
|
316
|
-
|
|
317
|
-
if (!isObject(entry)) {
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
if (hasLocalActor(this.session) || !entry.fabricIndex || entry.fabricIndex === this.session.fabric) {
|
|
515
|
+
for (let i = 0; i < list.length; i++) {
|
|
516
|
+
if (this.#isVisible(list[i])) {
|
|
322
517
|
if (nextPos === index) {
|
|
323
518
|
return i;
|
|
324
519
|
}
|
|
@@ -331,7 +526,7 @@ class FabricFilteredListProxyHandler extends ListProxyHandler {
|
|
|
331
526
|
}
|
|
332
527
|
|
|
333
528
|
if (nextPos === index) {
|
|
334
|
-
return
|
|
529
|
+
return list.length;
|
|
335
530
|
}
|
|
336
531
|
|
|
337
532
|
throw new WriteError(this.reference.location, `Index ${index} would leave gaps in fabric-filtered list`);
|
|
@@ -341,7 +536,10 @@ class FabricFilteredListProxyHandler extends ListProxyHandler {
|
|
|
341
536
|
try {
|
|
342
537
|
return super.readEntry(this.#mapScopedToActual(index, true), this.reference.location) !== undefined;
|
|
343
538
|
} catch (e) {
|
|
344
|
-
|
|
539
|
+
if (e instanceof ReadError) {
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
throw e;
|
|
345
543
|
}
|
|
346
544
|
}
|
|
347
545
|
|
|
@@ -349,85 +547,58 @@ class FabricFilteredListProxyHandler extends ListProxyHandler {
|
|
|
349
547
|
return super.readEntry(this.#mapScopedToActual(index, true), location);
|
|
350
548
|
}
|
|
351
549
|
|
|
352
|
-
protected override prepareEntry(value: Val) {
|
|
353
|
-
if (isObject(value)) {
|
|
354
|
-
(
|
|
550
|
+
protected override prepareEntry(value: Val, location: AccessControl.Location) {
|
|
551
|
+
if (!isObject(value)) {
|
|
552
|
+
throw new WriteError(location, `Fabric scoped list value is not an object`, Status.Failure);
|
|
355
553
|
}
|
|
554
|
+
(value as { fabricIndex?: number }).fabricIndex ??= this.session.fabric;
|
|
356
555
|
return value;
|
|
357
556
|
}
|
|
358
557
|
|
|
359
558
|
protected override writeEntry(index: number, value: Val, location: AccessControl.Location) {
|
|
360
|
-
|
|
361
|
-
const valueIndex = this.#mapScopedToActual(index, false);
|
|
362
|
-
this.writeVal().splice(valueIndex, 1);
|
|
363
|
-
} else {
|
|
364
|
-
if (!isObject(value)) {
|
|
365
|
-
throw new WriteError(location, `Fabric scoped list value is not an object`, Status.Failure);
|
|
366
|
-
}
|
|
367
|
-
super.writeEntry(this.#mapScopedToActual(index, false), value, location);
|
|
368
|
-
}
|
|
559
|
+
super.writeEntry(this.#mapScopedToActual(index, false), value, location);
|
|
369
560
|
}
|
|
370
561
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
562
|
+
/**
|
|
563
|
+
* Remove an entry. Any entry may go, because the later entries of this fabric move up to fill the gap. An index
|
|
564
|
+
* beyond the end is ignored.
|
|
565
|
+
*/
|
|
566
|
+
protected override deleteEntry(index: number, location: AccessControl.Location) {
|
|
567
|
+
if (index >= this.getListLength()) {
|
|
568
|
+
return;
|
|
378
569
|
}
|
|
379
|
-
|
|
570
|
+
this.config.authorizeWrite(this.session, location);
|
|
571
|
+
const entries = this.visibleEntries();
|
|
572
|
+
entries.splice(index, 1);
|
|
573
|
+
this.storeEntries(entries);
|
|
380
574
|
}
|
|
381
575
|
|
|
382
|
-
protected override
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
this.reference.change(() => {
|
|
386
|
-
for (let i = formerLength - 1; i >= length; i--) {
|
|
387
|
-
const entry = this.writeVal()[this.#mapScopedToActual(i, true)] as undefined | { fabricIndex?: number };
|
|
388
|
-
if (isObject(entry) && (!entry.fabricIndex || entry.fabricIndex === this.session.fabric)) {
|
|
389
|
-
this.writeVal().splice(this.#mapScopedToActual(i, false), 1);
|
|
390
|
-
} else if (entry !== undefined) {
|
|
391
|
-
throw new WriteError(
|
|
392
|
-
this.reference.location,
|
|
393
|
-
`Fabric scoped list value is not an object`,
|
|
394
|
-
Status.Failure,
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}, "length");
|
|
576
|
+
protected override visibleEntries() {
|
|
577
|
+
return this.readVal().filter(entry => this.#isVisible(entry));
|
|
399
578
|
}
|
|
400
579
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
(next.value as { fabricIndex?: number }).fabricIndex !== fabric
|
|
418
|
-
) {
|
|
419
|
-
continue;
|
|
420
|
-
}
|
|
580
|
+
/**
|
|
581
|
+
* Put `entries` into the positions of this fabric's entries, in order, and keep other fabrics' entries in their
|
|
582
|
+
* order. Entries beyond those positions go to the end; positions beyond the entries are removed.
|
|
583
|
+
*/
|
|
584
|
+
protected override storeEntries(entries: Val[]) {
|
|
585
|
+
const stored = this.readVal();
|
|
586
|
+
const result = new Array<Val>();
|
|
587
|
+
let next = 0;
|
|
588
|
+
for (const entry of stored) {
|
|
589
|
+
if (!this.#isVisible(entry)) {
|
|
590
|
+
result.push(entry);
|
|
591
|
+
} else if (next < entries.length) {
|
|
592
|
+
result.push(entries[next++]);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
result.push(...entries.slice(next));
|
|
421
596
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
},
|
|
597
|
+
super.storeEntries(result);
|
|
598
|
+
}
|
|
425
599
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
},
|
|
429
|
-
};
|
|
430
|
-
}) as Val.List[typeof Symbol.iterator];
|
|
600
|
+
protected override getListLength() {
|
|
601
|
+
return this.visibleEntries().length;
|
|
431
602
|
}
|
|
432
603
|
|
|
433
604
|
override ownKeys() {
|
|
@@ -437,26 +608,10 @@ class FabricFilteredListProxyHandler extends ListProxyHandler {
|
|
|
437
608
|
if (typeof k !== "string") {
|
|
438
609
|
return true;
|
|
439
610
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
if (Number.parseInt(k) < length) {
|
|
444
|
-
return true;
|
|
445
|
-
}
|
|
446
|
-
return false;
|
|
611
|
+
const index = entryIndexFor(k);
|
|
612
|
+
return index === undefined || index < length;
|
|
447
613
|
});
|
|
448
614
|
}
|
|
449
|
-
|
|
450
|
-
override getOwnPropertyDescriptor(_target: Val.List, key: PropertyKey) {
|
|
451
|
-
if (typeof key === "string" && key.match(/^\d+$/)) {
|
|
452
|
-
key = Number.parseInt(key);
|
|
453
|
-
}
|
|
454
|
-
if (typeof key !== "number") {
|
|
455
|
-
return Reflect.getOwnPropertyDescriptor(this.readVal(), key);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
return Reflect.getOwnPropertyDescriptor(this.readVal(), this.#mapScopedToActual(key, true));
|
|
459
|
-
}
|
|
460
615
|
}
|
|
461
616
|
|
|
462
617
|
function createProxy(config: ListConfig, reference: ValReference<Val.List>, session: ValueSupervisor.Session) {
|