Skip to content

Commit

Permalink
Merge branch 'main' into limit-exchanges
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
Apollon77 committed Sep 19, 2024
2 parents 38b12f2 + ef3610f commit da1dcc6
Show file tree
Hide file tree
Showing 1,834 changed files with 74,172 additions and 73,603 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@

// Always of dubious value, this rule is buggy as of typescript-eslint 7.2.0 and TS 5.4.2 (works w/ TS 5.3.3
// though)
"@typescript-eslint/no-redundant-type-constituents": "off"
"@typescript-eslint/no-redundant-type-constituents": "off",

// This rule is fine... Except it's redundant with tsc and seems to be buggy with wildcard package.json
// import aliases
"import/no-unresolved": "off"
},
"settings": {
"import/extensions": [".ts"],
Expand Down
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
packages/model/src/standard/elements/*.ts linguist-generated=true
packages/types/src/clusters/* linguist-generated=true
packages/types/src/globals/* linguist-generated=true
packages/node/src/tags/* linguist-generated=true
packages/node/src/endpoints/* linguist-generated=true
packages/node/src/devices/* linguist-generated=true
packages/node/src/behaviors/*/index.ts linguist-generated=true
packages/node/src/behaviors/*/*Behavior.ts linguist-generated=true
packages/node/src/behaviors/*/*Interface.ts linguist-generated=true
4 changes: 3 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
queries: +security-and-quality
config: |
paths-ignore:
- packages/matter.js/src/node/ServerNode.ts
- packages/node/src/node/ServerNode.ts
- packages/examples/**
- chip-testing/**
- '**/test/**/*Test.ts'
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
Expand Down
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pull_request_rules:
- "check-success=pullapprove"
- "check-skipped=pullapprove"
- "check-neutral=pullapprove"
- label!="autmated pr" # Don't auto merge automated PRs, other processes do this
- label!="automated pr" # Don't auto merge automated PRs, other processes do this
actions:
merge:
method: squash
14 changes: 8 additions & 6 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
models/src/chip.ts
models/src/spec.ts
packages/model/src/standard/elements/*
packages/matter.js/src/cluster/definitions/*
packages/matter.js/src/cluster/globals/*
packages/matter.js/src/endpoint/definitions/*
packages/matter.js/src/behavior/definitions/*/export.ts
packages/matter.js/src/behavior/definitions/*/*Behavior.ts
packages/matter.js/src/behavior/definitions/*/*Interface.ts
packages/types/src/clusters/*
packages/types/src/globals/*
packages/node/src/tags/*
packages/node/src/endpoints/*
packages/node/src/devices/*
packages/node/src/behaviors/*/index.ts
packages/node/src/behaviors/*/*Behavior.ts
packages/node/src/behaviors/*/*Interface.ts
43 changes: 35 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,47 @@ The main work (all changes without a GitHub username in brackets in the below li

## __WORK IN PROGRESS__

- IMPORTANT: As of 0.10.0 the @project-chip/matter.js module has grown quite large. This release includes major refactoring that moves functional areas into independent NPM packages. We have added exports to maintain backwards compatibility but these are not exhaustive. In some cases you may need to update imports to reference new code locations.
- IMPORTANT: As of 0.10.0 the @project-chip/matter.js module has grown quite large. This release includes major refactoring that moves functional areas into independent NPM packages under the "@matter.js" org. We have added exports to maintain backwards compatibility but these are not exhaustive. In some cases you may need to update imports to reference new code locations.

- matter.js-general:
- General functionality that is not Matter specific previously resided in @project-chip/matter.js. It now lives in @project-chip/matter.js-general
- Cross-module changes
- Matter.js now uses aliases via `package.json` "imports" field. This is an internal change that simplifies imports but should not affect consumers
- Previously we used a mix of snake-case and CamelCase for sub-package exports. We have now standardized on snake case. Compatibility packages (see below) continue to support the original module names

- @matter.js/general:
- General functionality that is not Matter specific previously resided in `@project-chip/matter.js`. It now lives in `@matter.js/general`
- BREAKING: The "ByteArray" type is removed, replaced with native-JS Uint8Array and a small collection of utility functions in the "Bytes" namespace
- The Matter object model previously exported as @project-chip/matter.js/model now resides in @project-chip/matter.js-model
- Feature: The default "Time" implementation is now fully functional across all standard JS runtimes

- matter.js-protocol:
- Limits the number of parallel exchanges to 5
- @matter.js/model:
- The Matter object model previously exported as `@project-chip/matter.js/model` now resides in `@matter.js/model`
- Individual elements exported by name are now models (fully funcitonal classes) rather than elements (raw JSON data). This should be backwards compatible but makes them more useful operationally

- @matter.js/types:
- Various definitions previously defined in `@project-chip/matter.js` now reside in `@matter.js/types`. This includes most TLV structures, cluster definitions, and various support types
- Clusters are not exported in `@project-chip/matter.js`. You can import via `@project-chip/types/clusters` or individually (e.g. `@project-chip/types/clusters/window-covering`)

- @matter.js/protocol:
- Low-level Matter logic previously defined in `@project-chip/matter.js` now resides in `@matter.js/protocol`. This includes network communication, fabric management and cluster invocation, read/write, events, etc.
- BREAKING: Various types that were previously specialized with template parameters are no longer generic. This should be largely transparent to API consumers. Compatibility exports still support the generic parameters in some, but not all, cases.

- @matter.js/node:
- The high-level APIs previously defined in `@project-chip/matter.js` now reside in `@matter.js/node`. The Node API includes node management, behavior definitions and endpoint definitions
- We export behaviors under `@matter.js/node/behaviors` or individually (e.g. `@matter.js/node/behaviors/on-off`)
- We export device type definitions for system endpoints and devices under `@matter.js/node/endpoints` and `@matter.js/node/devices` respectively. You may also import these via inddex or individually

- matter.js-nodejs:
- Node specialization is moved to matter.js-nodejs. matter-node.js remains as a compatibility import.
- @matter.js/nodejs:
- Node.js specialization is moved here. `@project-chip/matter-node.js` remains as a compatibility import.
- BREAKING: The previously deprecated re-exports in matter-node.js from matter.js are removed.

- @matter.js/nodejs-ble
- The BLE specialization for Node.js is moved here. `@project-chip/matter-node-ble.js` remains as a compatibility import.

- matter.js-protocol:
- Limits the number of parallel exchanges to 5

- @matter.js/main:
- This package is a new "one-and-done" dependency for applications. It automatically loads platform specialization and reexports pacakages above as appropriate

## 0.10.1 (2024-09-08)

- Matter-Core functionality:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,25 @@ This will install all dependencies and create symlinks between the packages, so
On Windows in order to successfully build all the packages (tested on Windows 11 Pro) make sure that to have installed Node.js 18+, the windows-build-tools and node-gyp version 10.
On Non-Windows platforms and having Python 3.12+ installed please also make sure to use npm 10.2.3+.

### To use matter(-node).js in own projects
### To use matter.js in your own project

To use matter.js in own projects you simply use matter-node.js as dependency in your project. This package also re-exports all interfaces from matter.js, so it is not needed to use matter.js directly. If you need BLE support you can use matter-node-ble.js as additional dependency.
To use matter.js you import `@matter.js/main` as dependency in your project. This package re-exports functionality from other packages, so it is not necessary to have multiple dependencies. If you need BLE support you can use `@matter.js/nodejs-ble` as additional dependency.

```bash
npm install @project-chip/matter-node.js --save
npm install @matter.js/main --save
```

If your project is not based on Node.js you need to implement the platform specific parts. See [How to use matter.js in own projects](#how-to-use-matterjs-in-own-projects) for more details.

### To try out the Node.js based Examples

if you just want to try out the Node.js based examples you can use the following commands:
if you just want to try out the examples on Node.js you can use the following commands:

```bash
npm install @project-chip/matter-node.js-examples
npm install @matter.js/examples
```

Please refer to the Examples Readme on how to use the examples: [matter-node.js-examples](packages/matter-node.js-examples/README.md)
Please refer to the Examples readme on how to use the examples: [@matter.js/examples](packages/examples/README.md)

## Code style

Expand Down
19 changes: 12 additions & 7 deletions chip-testing/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"name": "@project-chip/matter.js-chip-testing",
"name": "@matter.js/chip-testing",
"version": "0.0.0-git",
"description": "Testing of matter.js with CHIP tool",
"private": true,
"license": "Apache-2.0",
"author": "Project CHIP Authors",
"author": "matter.js authors",
"contributors": [
"Ingo Fischer <github@fischer-ka.de>"
],
"type": "module",
"bugs": {
"url": "https://github.com/project-chip/matter.js/issues"
Expand All @@ -17,12 +20,14 @@
"scripts": {
"clean": "matter-build clean",
"build": "matter-build",
"build-clean": "matter-build --clean"
"build-clean": "matter-build --clean",
"wip-test": "matter-test esm"
},
"dependencies": {
"@project-chip/matter.js-general": "*",
"@project-chip/matter.js-nodejs": "*",
"@project-chip/matter.js": "*",
"@project-chip/matter.js-tools": "*"
"@matter.js/main": "*",
"@project-chip/matter.js": "*"
},
"devDependencies": {
"@matter.js/tools": "*"
}
}
2 changes: 1 addition & 1 deletion chip-testing/src/AllClustersTestApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright 2022-2024 Matter.js Authors
* SPDX-License-Identifier: Apache-2.0
*/
import "@project-chip/matter.js-nodejs";
import "@matter.js/nodejs";

import { AllClustersTestInstance } from "./AllClustersTestInstance.js";
import { startTestApp } from "./GenericTestApp.js";
Expand Down
109 changes: 54 additions & 55 deletions chip-testing/src/AllClustersTestInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,43 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Bytes, Storage } from "@project-chip/matter.js-general";
import { AdministratorCommissioningServer } from "@project-chip/matter.js/behavior/definitions/administrator-commissioning";
import { BooleanStateServer } from "@project-chip/matter.js/behavior/definitions/boolean-state";
import { CarbonDioxideConcentrationMeasurementServer } from "@project-chip/matter.js/behavior/definitions/carbon-dioxide-concentration-measurement";
import { CarbonMonoxideConcentrationMeasurementServer } from "@project-chip/matter.js/behavior/definitions/carbon-monoxide-concentration-measurement";
import { ColorControlServer } from "@project-chip/matter.js/behavior/definitions/color-control";
import { FixedLabelServer } from "@project-chip/matter.js/behavior/definitions/fixed-label";
import { FlowMeasurementServer } from "@project-chip/matter.js/behavior/definitions/flow-measurement";
import { FormaldehydeConcentrationMeasurementServer } from "@project-chip/matter.js/behavior/definitions/formaldehyde-concentration-measurement";
import { IlluminanceMeasurementServer } from "@project-chip/matter.js/behavior/definitions/illuminance-measurement";
import { LocalizationConfigurationServer } from "@project-chip/matter.js/behavior/definitions/localization-configuration";
import { ModeSelectServer } from "@project-chip/matter.js/behavior/definitions/mode-select";
import { NetworkCommissioningServer } from "@project-chip/matter.js/behavior/definitions/network-commissioning";
import { NitrogenDioxideConcentrationMeasurementServer } from "@project-chip/matter.js/behavior/definitions/nitrogen-dioxide-concentration-measurement";
import { OccupancySensingServer } from "@project-chip/matter.js/behavior/definitions/occupancy-sensing";
import { OzoneConcentrationMeasurementServer } from "@project-chip/matter.js/behavior/definitions/ozone-concentration-measurement";
import { Pm1ConcentrationMeasurementServer } from "@project-chip/matter.js/behavior/definitions/pm1-concentration-measurement";
import { Pm10ConcentrationMeasurementServer } from "@project-chip/matter.js/behavior/definitions/pm10-concentration-measurement";
import { Pm25ConcentrationMeasurementServer } from "@project-chip/matter.js/behavior/definitions/pm25-concentration-measurement";
import { PowerSourceServer } from "@project-chip/matter.js/behavior/definitions/power-source";
import { PowerTopologyServer } from "@project-chip/matter.js/behavior/definitions/power-topology";
import { PressureMeasurementServer } from "@project-chip/matter.js/behavior/definitions/pressure-measurement";
import { PumpConfigurationAndControlServer } from "@project-chip/matter.js/behavior/definitions/pump-configuration-and-control";
import { RadonConcentrationMeasurementServer } from "@project-chip/matter.js/behavior/definitions/radon-concentration-measurement";
import { RelativeHumidityMeasurementServer } from "@project-chip/matter.js/behavior/definitions/relative-humidity-measurement";
import { SwitchServer } from "@project-chip/matter.js/behavior/definitions/switch";
import { TemperatureMeasurementServer } from "@project-chip/matter.js/behavior/definitions/temperature-measurement";
import { ThermostatUserInterfaceConfigurationServer } from "@project-chip/matter.js/behavior/definitions/thermostat-user-interface-configuration";
import { TimeFormatLocalizationServer } from "@project-chip/matter.js/behavior/definitions/time-format-localization";
import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from "@project-chip/matter.js/behavior/definitions/total-volatile-organic-compounds-concentration-measurement";
import { UnitLocalizationServer } from "@project-chip/matter.js/behavior/definitions/unit-localization";
import { UserLabelServer } from "@project-chip/matter.js/behavior/definitions/user-label";
import { AirQualityServer } from "@project-chip/matter.js/behaviors/air-quality";
import { DescriptorServer } from "@project-chip/matter.js/behaviors/descriptor";
import { Bytes, Storage } from "@matter.js/general";
import { Endpoint, Environment, NumberTag, ServerNode, StorageService } from "@matter.js/main";
import {
AdministratorCommissioningServer,
AirQualityServer,
BooleanStateServer,
CarbonDioxideConcentrationMeasurementServer,
CarbonMonoxideConcentrationMeasurementServer,
ColorControlServer,
DescriptorServer,
FixedLabelServer,
FlowMeasurementServer,
FormaldehydeConcentrationMeasurementServer,
IlluminanceMeasurementServer,
LocalizationConfigurationServer,
ModeSelectServer,
NetworkCommissioningServer,
NitrogenDioxideConcentrationMeasurementServer,
OccupancySensingServer,
OzoneConcentrationMeasurementServer,
Pm10ConcentrationMeasurementServer,
Pm1ConcentrationMeasurementServer,
Pm25ConcentrationMeasurementServer,
PowerSourceServer,
PowerTopologyServer,
PressureMeasurementServer,
PumpConfigurationAndControlServer,
RadonConcentrationMeasurementServer,
RelativeHumidityMeasurementServer,
SwitchServer,
TemperatureMeasurementServer,
ThermostatUserInterfaceConfigurationServer,
TimeFormatLocalizationServer,
TotalVolatileOrganicCompoundsConcentrationMeasurementServer,
UnitLocalizationServer,
UserLabelServer,
} from "@matter.js/main/behaviors";
import {
AdministratorCommissioning,
AirQuality,
Expand All @@ -57,20 +60,16 @@ import {
ThermostatUserInterfaceConfiguration,
TimeFormatLocalization,
WindowCovering,
} from "@project-chip/matter.js/cluster";
import { DeviceTypeId, EndpointNumber, VendorId } from "@project-chip/matter.js/datatype";
import { OnOffLightDevice } from "@project-chip/matter.js/devices/OnOffLightDevice";
import { Endpoint } from "@project-chip/matter.js/endpoint";
import { Environment, StorageService } from "@project-chip/matter.js/environment";
import { ServerNode } from "@project-chip/matter.js/node";
import { NumberTag } from "@project-chip/matter.js/tags/NumberTag";
} from "@matter.js/main/clusters";
import { OnOffLightDevice } from "@matter.js/main/devices";
import { DeviceTypeId, EndpointNumber, VendorId } from "@matter.js/main/types";
import { TestActivatedCarbonFilterMonitoringServer } from "./cluster/TestActivatedCarbonFilterMonitoringServer.js";
import { TestGeneralDiagnosticsServer } from "./cluster/TestGeneralDiagnosticsServer.js";
import { TestHepaFilterMonitoringServer } from "./cluster/TestHEPAFilterMonitoringServer.js";
import { TestIdentifyServer } from "./cluster/TestIdentifyServer.js";
import { TestLevelControlServer } from "./cluster/TestLevelControlServer.js";
import { TestWindowCoveringServer } from "./cluster/TestWindowCoveringServer.js";
import { TestInstance } from "./GenericTestApp.js";
import { log, TestInstance } from "./GenericTestApp.js";
import { NamedPipeCommandHandler } from "./NamedPipeCommandHandler.js";

export class AllClustersTestInstance implements TestInstance {
Expand Down Expand Up @@ -100,7 +99,7 @@ export class AllClustersTestInstance implements TestInstance {
);
await this.#namedPipeHandler.listen();
} catch (error) {
console.log("Error creating named pipe:", error);
log.error("Error creating named pipe:", error);
}
}

Expand All @@ -111,11 +110,11 @@ export class AllClustersTestInstance implements TestInstance {
await this.#setupNamedPipe();
} catch (error) {
// Catch and log error, else the test framework hides issues here
console.log(error);
console.log((error as Error).stack);
log.error(error);
log.error((error as Error).stack);
throw error;
}
console.log(`======> ${this.appName}: Setup done`);
log.directive(`======> ${this.appName}: Setup done`);
}

/** Start the test instance MatterServer with the included device. */
Expand All @@ -131,18 +130,18 @@ export class AllClustersTestInstance implements TestInstance {
await this.serverNode.start();
const { qrPairingCode } = this.serverNode.state.commissioning.pairingCodes;
// Magic logging chip testing waits for
console.log(`SetupQRCode: [${qrPairingCode}]`);
console.log();
log.directive(`SetupQRCode: [${qrPairingCode}]`);
log.directive();
// Magic logging chip testing waits for
console.log("mDNS service published:");
console.log();
log.directive("mDNS service published:");
log.directive();

console.log(`======> ${this.appName}: Instance started`);
log.directive(`======> ${this.appName}: Instance started`);
} catch (error) {
// Catch and log error, else the test framework hides issues here
console.log(error);
log.error(error);
}
console.log("=====>>> STARTED");
log.directive("=====>>> STARTED");
}

/** Stop the test instance MatterServer and the device. */
Expand All @@ -155,9 +154,9 @@ export class AllClustersTestInstance implements TestInstance {
try {
await this.#namedPipeHandler?.close();
} catch (error) {
console.log("Error closing named pipe:", error);
log.error("Error closing named pipe:", error);
}
console.log(`======> ${this.appName}: Instance stopped`);
log.directive(`======> ${this.appName}: Instance stopped`);
}

async setupServer(): Promise<ServerNode> {
Expand Down
Loading

0 comments on commit da1dcc6

Please sign in to comment.