@ya-modbus/transport 0.8.1 → 0.9.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.9.1](https://github.com/groupsky/ya-modbus/compare/@ya-modbus/transport@0.9.0...@ya-modbus/transport@0.9.1) (2026-10-12)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **transport:** make Modbus TCP work from the CLI and profiler ([#542](https://github.com/groupsky/ya-modbus/issues/542)) ([2aa24ac](https://github.com/groupsky/ya-modbus/commit/2aa24ac1753416c261d05bb8b8b12fccbc10e3e4))
11
+
12
+ # [0.9.0](https://github.com/groupsky/ya-modbus/compare/@ya-modbus/transport@0.8.1...@ya-modbus/transport@0.9.0) (2026-10-12)
13
+
14
+ - feat!: drop Node.js 20 support (#516) ([70002ab](https://github.com/groupsky/ya-modbus/commit/70002ab28155432e0984c67a70d1469fc5be7cb3)), closes [#516](https://github.com/groupsky/ya-modbus/issues/516)
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ - Node.js 20 is no longer supported. Use Node.js 22 or 24.
19
+
6
20
  ## [0.8.1](https://github.com/groupsky/ya-modbus/compare/@ya-modbus/transport@0.8.0...@ya-modbus/transport@0.8.1) (2026-10-12)
7
21
 
8
22
  **Note:** Version bump only for package @ya-modbus/transport
@@ -11,8 +11,8 @@ export type TransportConfig = RTUConfig | TCPConfig;
11
11
  * Create a transport instance based on configuration
12
12
  *
13
13
  * Detects whether to create RTU or TCP transport based on the config:
14
- * - If `port` is provided → RTU transport
15
- * - If `host` is provided → TCP transport
14
+ * - If `host` is provided → TCP transport (`port` is the optional TCP port number)
15
+ * - Otherwise, if `port` is provided → RTU transport (`port` is the serial path)
16
16
  *
17
17
  * @param config - Transport configuration (RTU or TCP)
18
18
  * @returns Transport implementation
@@ -4,33 +4,33 @@ exports.createTransport = createTransport;
4
4
  const rtu_transport_js_1 = require("./rtu-transport.js");
5
5
  const tcp_transport_js_1 = require("./tcp-transport.js");
6
6
  /**
7
- * Type guard to check if config is RTU
7
+ * Type guard to check if config is TCP
8
8
  */
9
- function isRTUConfig(config) {
10
- return 'port' in config && !('host' in config);
9
+ function isTCPConfig(config) {
10
+ return 'host' in config;
11
11
  }
12
12
  /**
13
13
  * Create a transport instance based on configuration
14
14
  *
15
15
  * Detects whether to create RTU or TCP transport based on the config:
16
- * - If `port` is provided → RTU transport
17
- * - If `host` is provided → TCP transport
16
+ * - If `host` is provided → TCP transport (`port` is the optional TCP port number)
17
+ * - Otherwise, if `port` is provided → RTU transport (`port` is the serial path)
18
18
  *
19
19
  * @param config - Transport configuration (RTU or TCP)
20
20
  * @returns Transport implementation
21
21
  * @throws Error if config is invalid
22
22
  */
23
23
  async function createTransport(config) {
24
- // Validate that exactly one of port/host is provided
25
- if ('port' in config && 'host' in config) {
26
- throw new Error('Cannot specify both port (RTU) and host (TCP)');
24
+ if (isTCPConfig(config)) {
25
+ // A string `port` is a serial path, which cannot be combined with a TCP host
26
+ if (typeof config.port === 'string') {
27
+ throw new Error('Cannot specify both port (RTU) and host (TCP)');
28
+ }
29
+ return (0, tcp_transport_js_1.createTCPTransport)(config);
27
30
  }
28
- if (isRTUConfig(config)) {
31
+ if ('port' in config) {
29
32
  return (0, rtu_transport_js_1.createRTUTransport)(config);
30
33
  }
31
- if ('host' in config) {
32
- return (0, tcp_transport_js_1.createTCPTransport)(config);
33
- }
34
34
  throw new Error('Either port (for RTU) or host (for TCP) must be specified');
35
35
  }
36
36
  //# sourceMappingURL=factory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/factory.ts"],"names":[],"mappings":";;AAgCA,0CAeC;AA7CD,yDAAuE;AACvE,yDAAuE;AAWvE;;GAEG;AACH,SAAS,WAAW,CAAC,MAAuB;IAC1C,OAAO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