diff --git a/package.json b/package.json index 0a3931e866ba..d12fa6b58ce5 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@actions/core": "^1.11.1", "@actions/exec": "^1.1.1", "@actions/github": "^6.0.0", - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@alcalzone/jsonl-db": "^3.1.1", "@alcalzone/monopack": "^1.3.0", "@alcalzone/release-script": "~3.8.0", @@ -81,6 +81,7 @@ "reflect-metadata": "^0.2.2", "semver": "^7.6.3", "source-map-support": "^0.5.21", + "ts-morph": "^24.0.0", "ts-patch": "3.2.1", "tsx": "^4.19.2", "turbo": "2.2.3", diff --git a/packages/cc/package.json b/packages/cc/package.json index 15bdd33c051c..497fb02f9ba7 100644 --- a/packages/cc/package.json +++ b/packages/cc/package.json @@ -76,7 +76,7 @@ "reflect-metadata": "^0.2.2" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@microsoft/api-extractor": "^7.47.9", "@types/node": "^18.19.63", "@zwave-js/maintenance": "workspace:*", diff --git a/packages/config/package.json b/packages/config/package.json index 3489e3bbaff7..fca74583072f 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -68,7 +68,7 @@ "winston": "^3.15.0" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@microsoft/api-extractor": "^7.47.9", "@types/js-levenshtein": "^1.1.3", "@types/json-logic-js": "^2.0.7", diff --git a/packages/core/package.json b/packages/core/package.json index 0b347ecb7272..c91c6eaf72d6 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -128,7 +128,7 @@ "winston-transport": "^4.8.0" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@microsoft/api-extractor": "^7.47.9", "@types/node": "^18.19.63", "@types/semver": "^7.5.8", diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 1a70995cad81..07c0a5221978 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -38,7 +38,7 @@ "lint:ts:fix": "yarn run lint:ts --fix" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@types/eslint": "^9.6.1", "@typescript-eslint/utils": "^8.8.1", "@zwave-js/core": "workspace:*", diff --git a/packages/host/package.json b/packages/host/package.json index ebe6f91d9bc7..cbad15ee539a 100644 --- a/packages/host/package.json +++ b/packages/host/package.json @@ -58,7 +58,7 @@ "alcalzone-shared": "^5.0.0" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@microsoft/api-extractor": "^7.47.9", "@types/node": "^18.19.63", "del-cli": "^6.0.0", diff --git a/packages/maintenance/package.json b/packages/maintenance/package.json index b26a8cd55568..36b14d5e24eb 100644 --- a/packages/maintenance/package.json +++ b/packages/maintenance/package.json @@ -38,7 +38,7 @@ "lint:ts:fix": "yarn run lint:ts --fix" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@dprint/formatter": "^0.4.1", "@dprint/json": "^0.19.4", "@dprint/markdown": "^0.17.8", diff --git a/packages/nvmedit/package.json b/packages/nvmedit/package.json index acab66ddf6c9..017d8b4889bc 100644 --- a/packages/nvmedit/package.json +++ b/packages/nvmedit/package.json @@ -65,7 +65,7 @@ "test:dirty": "tsx ../maintenance/src/resolveDirtyTests.ts --run" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@microsoft/api-extractor": "^7.47.9", "@types/node": "^18.19.63", "@types/semver": "^7.5.8", diff --git a/packages/serial/package.json b/packages/serial/package.json index 9c77c8b02746..b000cdcbeb16 100644 --- a/packages/serial/package.json +++ b/packages/serial/package.json @@ -74,7 +74,7 @@ "winston": "^3.15.0" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@microsoft/api-extractor": "^7.47.9", "@serialport/binding-mock": "^10.2.2", "@serialport/bindings-interface": "patch:@serialport/bindings-interface@npm%3A1.2.2#~/.yarn/patches/@serialport-bindings-interface-npm-1.2.2-e597dbc676.patch", diff --git a/packages/shared/package.json b/packages/shared/package.json index c2e489351f2a..9aa77383e887 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -59,7 +59,7 @@ "test:dirty": "tsx ../maintenance/src/resolveDirtyTests.ts --run" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@microsoft/api-extractor": "^7.47.9", "@types/node": "^18.19.63", "@types/sinon": "^17.0.3", diff --git a/packages/testing/package.json b/packages/testing/package.json index 2faa2d551d25..5a0f3056af72 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -55,7 +55,7 @@ "ansi-colors": "^4.1.3" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@microsoft/api-extractor": "^7.47.9", "@types/node": "^18.19.63", "@types/triple-beam": "^1.3.5", diff --git a/packages/zwave-js/package.json b/packages/zwave-js/package.json index 813753719574..d92c6089cb02 100644 --- a/packages/zwave-js/package.json +++ b/packages/zwave-js/package.json @@ -122,7 +122,7 @@ "xstate": "4.38.3" }, "devDependencies": { - "@alcalzone/esm2cjs": "^1.4.0", + "@alcalzone/esm2cjs": "^1.4.1", "@microsoft/api-extractor": "^7.47.9", "@types/node": "^18.19.63", "@types/proper-lockfile": "^4.1.4", diff --git a/packages/zwave-js/src/lib/test/compat/mapRootReportsToEndpoint.test.ts b/packages/zwave-js/src/lib/test/compat/mapRootReportsToEndpoint.test.ts new file mode 100644 index 000000000000..89a8b6a5f902 --- /dev/null +++ b/packages/zwave-js/src/lib/test/compat/mapRootReportsToEndpoint.test.ts @@ -0,0 +1,91 @@ +import { + BinarySwitchCCReport, + BinarySwitchCCValues, + type CommandClass, + MultiChannelCC, +} from "@zwave-js/cc"; +import { CommandClasses } from "@zwave-js/core"; +import { ccCaps, createMockZWaveRequestFrame } from "@zwave-js/testing"; +import { wait } from "alcalzone-shared/async"; +import { integrationTest } from "../integrationTestSuite.js"; + +integrationTest( + "The compat flag mapRootReportsToEndpoint works correctly", + { + // debug: true, + + nodeCapabilities: { + // Fibaro FGS221 uses the flag + manufacturerId: 0x010f, + productType: 0x0200, + productId: 0x0102, + + commandClasses: [ + CommandClasses.Version, + { + ccId: CommandClasses["Multi Channel"], + version: 2, + }, + CommandClasses["Manufacturer Specific"], + CommandClasses["Binary Switch"], + ], + + endpoints: [ + { + commandClasses: [ + ccCaps({ + ccId: CommandClasses["Binary Switch"], + isSupported: true, + defaultValue: false, + }), + ], + }, + { + commandClasses: [ + ccCaps({ + ccId: CommandClasses["Binary Switch"], + isSupported: true, + defaultValue: false, + }), + ], + }, + ], + }, + + async testBody(t, driver, node, mockController, mockNode) { + // Send a report from endpoint 2. It should end up on endpoint 2. + let cc: CommandClass = new BinarySwitchCCReport({ + nodeId: 2, + currentValue: true, + }); + cc = MultiChannelCC.encapsulate(cc); + cc.endpointIndex = 2; + + await mockNode.sendToController( + createMockZWaveRequestFrame(cc, { ackRequested: false }), + ); + + await wait(100); + + t.expect( + node.getValue(BinarySwitchCCValues.currentValue.endpoint(2)), + ).toBe(true); + + // Send another one from the root. It should end up on endpoint 1. + cc = new BinarySwitchCCReport({ + nodeId: 2, + currentValue: true, + }); + + await mockNode.sendToController( + createMockZWaveRequestFrame(cc, { ackRequested: false }), + ); + + await wait(100); + + t.expect( + node.getValue(BinarySwitchCCValues.currentValue.endpoint(1)), + ).toBe(true); + }, + }, +); diff --git a/yarn.lock b/yarn.lock index db7e604864c0..9ee03cc11940 100644 --- a/yarn.lock +++ b/yarn.lock @@ -69,9 +69,9 @@ __metadata: languageName: node linkType: hard -"@alcalzone/esm2cjs@npm:^1.4.0": - version: 1.4.0 - resolution: "@alcalzone/esm2cjs@npm:1.4.0" +"@alcalzone/esm2cjs@npm:^1.4.1": + version: 1.4.1 + resolution: "@alcalzone/esm2cjs@npm:1.4.1" dependencies: esbuild: "npm:^0.24.0" fs-extra: "npm:^10.1.0" @@ -79,7 +79,7 @@ __metadata: yargs: "npm:^17.5.1" bin: esm2cjs: bin/esm2cjs.cjs - checksum: 10/9ab7c4e383e8762319de1f79bd2dd8134f47b5227a935387764a7b7a159de8bab36806274ca875368e821f95285fb61fa4bc2b09df6af3302e5ec524f7e06463 + checksum: 10/9133100b28480d03e03b3aca5777cd48308c01a8ff2cec1fa68e86fdde29b0c28a4559cd658676bc215bdb09b2cb5ba267744cfcb320283ef500c95985ea8c56 languageName: node linkType: hard @@ -2558,7 +2558,7 @@ __metadata: version: 0.0.0-use.local resolution: "@zwave-js/cc@workspace:packages/cc" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@microsoft/api-extractor": "npm:^7.47.9" "@types/node": "npm:^18.19.63" "@zwave-js/core": "workspace:*" @@ -2581,7 +2581,7 @@ __metadata: version: 0.0.0-use.local resolution: "@zwave-js/config@workspace:packages/config" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@microsoft/api-extractor": "npm:^7.47.9" "@types/js-levenshtein": "npm:^1.1.3" "@types/json-logic-js": "npm:^2.0.7" @@ -2621,7 +2621,7 @@ __metadata: version: 0.0.0-use.local resolution: "@zwave-js/core@workspace:packages/core" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@alcalzone/jsonl-db": "npm:^3.1.1" "@microsoft/api-extractor": "npm:^7.47.9" "@types/node": "npm:^18.19.63" @@ -2653,7 +2653,7 @@ __metadata: version: 0.0.0-use.local resolution: "@zwave-js/eslint-plugin@workspace:packages/eslint-plugin" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@types/eslint": "npm:^9.6.1" "@typescript-eslint/utils": "npm:^8.8.1" "@zwave-js/core": "workspace:*" @@ -2698,7 +2698,7 @@ __metadata: version: 0.0.0-use.local resolution: "@zwave-js/host@workspace:packages/host" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@microsoft/api-extractor": "npm:^7.47.9" "@types/node": "npm:^18.19.63" "@zwave-js/config": "workspace:*" @@ -2714,7 +2714,7 @@ __metadata: version: 0.0.0-use.local resolution: "@zwave-js/maintenance@workspace:packages/maintenance" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@dprint/formatter": "npm:^0.4.1" "@dprint/json": "npm:^0.19.4" "@dprint/markdown": "npm:^0.17.8" @@ -2746,7 +2746,7 @@ __metadata: version: 0.0.0-use.local resolution: "@zwave-js/nvmedit@workspace:packages/nvmedit" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@microsoft/api-extractor": "npm:^7.47.9" "@types/node": "npm:^18.19.63" "@types/semver": "npm:^7.5.8" @@ -2773,7 +2773,7 @@ __metadata: "@actions/core": "npm:^1.11.1" "@actions/exec": "npm:^1.1.1" "@actions/github": "npm:^6.0.0" - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@alcalzone/jsonl-db": "npm:^3.1.1" "@alcalzone/monopack": "npm:^1.3.0" "@alcalzone/release-script": "npm:~3.8.0" @@ -2822,6 +2822,7 @@ __metadata: reflect-metadata: "npm:^0.2.2" semver: "npm:^7.6.3" source-map-support: "npm:^0.5.21" + ts-morph: "npm:^24.0.0" ts-patch: "npm:3.2.1" tsx: "npm:^4.19.2" turbo: "npm:2.2.3" @@ -2837,7 +2838,7 @@ __metadata: version: 0.0.0-use.local resolution: "@zwave-js/serial@workspace:packages/serial" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@microsoft/api-extractor": "npm:^7.47.9" "@serialport/binding-mock": "npm:^10.2.2" "@serialport/bindings-interface": "patch:@serialport/bindings-interface@npm%3A1.2.2#~/.yarn/patches/@serialport-bindings-interface-npm-1.2.2-e597dbc676.patch" @@ -2864,7 +2865,7 @@ __metadata: version: 0.0.0-use.local resolution: "@zwave-js/shared@workspace:packages/shared" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@microsoft/api-extractor": "npm:^7.47.9" "@types/node": "npm:^18.19.63" "@types/sinon": "npm:^17.0.3" @@ -2881,7 +2882,7 @@ __metadata: version: 0.0.0-use.local resolution: "@zwave-js/testing@workspace:packages/testing" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@microsoft/api-extractor": "npm:^7.47.9" "@types/node": "npm:^18.19.63" "@types/triple-beam": "npm:^1.3.5" @@ -10068,7 +10069,7 @@ __metadata: version: 0.0.0-use.local resolution: "zwave-js@workspace:packages/zwave-js" dependencies: - "@alcalzone/esm2cjs": "npm:^1.4.0" + "@alcalzone/esm2cjs": "npm:^1.4.1" "@alcalzone/jsonl-db": "npm:^3.1.1" "@homebridge/ciao": "npm:^1.3.1" "@microsoft/api-extractor": "npm:^7.47.9"