@flux-control/effect-modbus-rs 0.1.1 → 0.3.0
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/README.md +344 -87
- package/dist/index.d.ts +85 -11
- package/dist/index.js +576 -280
- package/dist/src/AsciiTransportService.d.ts +29 -8
- package/dist/src/RtuTransportService.d.ts +29 -8
- package/dist/src/SerialModbusServerService.d.ts +5 -5
- package/dist/src/SerialTransportService.d.ts +8 -7
- package/dist/src/TcpGatewayService.d.ts +4 -4
- package/dist/src/TcpModbusServerService.d.ts +4 -4
- package/dist/src/TcpTransportService.d.ts +29 -8
- package/dist/src/WasmAsciiTransportService.d.ts +73 -0
- package/dist/src/WasmRtuTransportService.d.ts +73 -0
- package/dist/src/WasmSerialModbusServerService.d.ts +54 -0
- package/dist/src/WasmSerialPort.d.ts +27 -0
- package/dist/src/WasmSerialTransportService.d.ts +48 -0
- package/dist/src/WasmTcpServerService.d.ts +38 -0
- package/dist/src/WasmWsTransportService.d.ts +60 -0
- package/dist/src/connection.d.ts +170 -0
- package/dist/src/errors.d.ts +25 -1
- package/dist/src/mocks.d.ts +49 -9
- package/dist/src/modbus-client.d.ts +82 -23
- package/dist/src/modbus-client.wasm.test.d.ts +1 -0
- package/dist/src/resilience.test.d.ts +1 -0
- package/dist/src/retry.d.ts +227 -0
- package/dist/src/retry.test.d.ts +1 -0
- package/dist/src/shared-transport.d.ts +113 -8
- package/dist/src/shared-transport.test.d.ts +1 -0
- package/dist/src/upstream-options.test.d.ts +1 -0
- package/dist/src/wasm-mocks.test.d.ts +1 -0
- package/package.json +24 -17
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* # effect-modbus-rs
|
|
2
|
+
* # @flux-control/effect-modbus-rs
|
|
3
3
|
*
|
|
4
4
|
* Type-safe Modbus communication via Effect-TS, wrapping the `modbus-rs`
|
|
5
5
|
* npm bindings (Rust `napi-rs` under the hood).
|
|
@@ -11,6 +11,14 @@
|
|
|
11
11
|
* - {@link AsciiTransportService} — Serial ASCII transport.
|
|
12
12
|
* - {@link TcpTransportService} — TCP/IP transport (Modbus/TCP).
|
|
13
13
|
*
|
|
14
|
+
* ## Browser (WASM) transport services
|
|
15
|
+
*
|
|
16
|
+
* - {@link WasmSerialTransportService} — Abstract Web Serial transport (ASCII or RTU).
|
|
17
|
+
* - {@link WasmRtuTransportService} — Web Serial RTU transport.
|
|
18
|
+
* - {@link WasmAsciiTransportService} — Web Serial ASCII transport.
|
|
19
|
+
* - {@link WasmWsTransportService} — TCP-over-WebSocket transport (Modbus/TCP via a WS gateway).
|
|
20
|
+
* - {@link requestSerialPort} — Requests a Web Serial port handle (user-gesture gated).
|
|
21
|
+
*
|
|
14
22
|
* ## Server layers
|
|
15
23
|
*
|
|
16
24
|
* Run a server layer with {@link Layer.launch} and execute with a runtime:
|
|
@@ -23,6 +31,8 @@
|
|
|
23
31
|
* - {@link serialAsciiServerLayer} — Serial ASCII server.
|
|
24
32
|
* - {@link tcpServerLayer} — TCP server.
|
|
25
33
|
* - {@link tcpGatewayLayer} — TCP gateway.
|
|
34
|
+
* - {@link wasmWsServerLayer} — Browser WS-gateway server (experimental upstream surface).
|
|
35
|
+
* - {@link wasmSerialRtuServerLayer} / {@link wasmSerialAsciiServerLayer} — Browser Web Serial servers (experimental).
|
|
26
36
|
*
|
|
27
37
|
* ## Errors
|
|
28
38
|
*
|
|
@@ -36,14 +46,78 @@
|
|
|
36
46
|
* })
|
|
37
47
|
* ```
|
|
38
48
|
*
|
|
39
|
-
*
|
|
49
|
+
* ## Resilience
|
|
50
|
+
*
|
|
51
|
+
* Nothing retries or reconnects implicitly — a transport behaves exactly as it
|
|
52
|
+
* always has until a policy is attached, so timing stays predictable by
|
|
53
|
+
* default. Resilience is configured on the **transport**, which owns it for
|
|
54
|
+
* every client derived from it:
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* TcpTransportService.Default({
|
|
58
|
+
* host, port,
|
|
59
|
+
* retry: RetryPolicies.tcp(), // applied to every operation
|
|
60
|
+
* reconnect: {}, // supervised reconnect + circuit breaker
|
|
61
|
+
* })
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* Policies are error-aware: transient failures (timeouts, framing errors, a
|
|
65
|
+
* busy device) back off exponentially with jitter (on by default), while
|
|
66
|
+
* deterministic ones (illegal address, invalid argument) fail immediately.
|
|
67
|
+
*
|
|
68
|
+
* Override per client — one bus, several device types — or per operation.
|
|
69
|
+
* Both replace the policy rather than composing with it:
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* const meter = yield* transport.withClient(1, { retry: RetryPolicies.serial() });
|
|
73
|
+
* yield* meter.withRetry(RetryPolicies.none()).writeSingleCoil({ address: 0, value });
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* With `reconnect` enabled, the transport runs one supervised reconnect for the
|
|
77
|
+
* whole application and refuses operations with {@link ModbusCircuitOpenError}
|
|
78
|
+
* while the link is down, instead of letting every caller queue requests onto a
|
|
79
|
+
* dead bus. Watch {@link ConnectionState} via `transport.connectionState`.
|
|
80
|
+
*
|
|
81
|
+
* {@link retryModbus} remains for retrying a compound operation — a
|
|
82
|
+
* read-modify-write driven as a unit — over a `RetryPolicies.none()` client.
|
|
83
|
+
* Note that it **wraps** rather than replaces: unlike the two overrides above,
|
|
84
|
+
* it is piped around an effect the client has already wrapped in its own retry,
|
|
85
|
+
* so over a policied client the two nest and attempt counts multiply.
|
|
86
|
+
*
|
|
87
|
+
* Resilience lives at this layer and only at this layer. `modbus-rs`'s own
|
|
88
|
+
* transport-level `retryAttempts` / `retryDelayMs` / `retryBackoffStrategy` are
|
|
89
|
+
* **not accepted** by any transport constructor here: they retry beneath the
|
|
90
|
+
* Effect boundary where neither the policy, the circuit breaker, nor the logs
|
|
91
|
+
* can see them, and they reconnect inline, racing the supervisor fiber that
|
|
92
|
+
* owns reconnection. See {@link UpstreamRetryOptionKey}.
|
|
93
|
+
*
|
|
94
|
+
* @module @flux-control/effect-modbus-rs
|
|
40
95
|
*/
|
|
41
|
-
export * from
|
|
42
|
-
export {
|
|
43
|
-
export {
|
|
44
|
-
export {
|
|
45
|
-
export {
|
|
46
|
-
export {
|
|
47
|
-
export {
|
|
48
|
-
export {
|
|
49
|
-
export
|
|
96
|
+
export * from './src/errors';
|
|
97
|
+
export type { EffectModbusClient } from './src/modbus-client';
|
|
98
|
+
export { makeRetryPolicy, retryableExceptionCodes, RetryPolicies, retryModbus } from './src/retry';
|
|
99
|
+
export type { ModbusErrorTag, ModbusRetryPolicy, ModbusRetryPolicyOptions, RetryDelayOptions, RetryErrorOptions, } from './src/retry';
|
|
100
|
+
export { ConnectionState } from './src/connection';
|
|
101
|
+
export type { ReconnectOptions } from './src/connection';
|
|
102
|
+
export type { TransportResilienceOptions, UpstreamRetryOptionKey, WithoutUpstreamRetry, } from './src/shared-transport';
|
|
103
|
+
export type { ModbusOperations } from './src/modbus-client';
|
|
104
|
+
export { AsciiTransportService } from './src/AsciiTransportService';
|
|
105
|
+
export type { AsciiTransportOpenOptions } from './src/AsciiTransportService';
|
|
106
|
+
export { SerialTransportService } from './src/SerialTransportService';
|
|
107
|
+
export { TcpTransportService } from './src/TcpTransportService';
|
|
108
|
+
export type { TcpTransportOpenOptions } from './src/TcpTransportService';
|
|
109
|
+
export { RtuTransportService } from './src/RtuTransportService';
|
|
110
|
+
export type { RtuTransportOpenOptions } from './src/RtuTransportService';
|
|
111
|
+
export { serialRtuServerLayer, serialAsciiServerLayer } from './src/SerialModbusServerService';
|
|
112
|
+
export { tcpServerLayer } from './src/TcpModbusServerService';
|
|
113
|
+
export { tcpGatewayLayer } from './src/TcpGatewayService';
|
|
114
|
+
export { WasmWsTransportService } from './src/WasmWsTransportService';
|
|
115
|
+
export { WasmRtuTransportService } from './src/WasmRtuTransportService';
|
|
116
|
+
export type { WasmRtuTransportOpenOptions } from './src/WasmRtuTransportService';
|
|
117
|
+
export { WasmAsciiTransportService } from './src/WasmAsciiTransportService';
|
|
118
|
+
export type { WasmAsciiTransportOpenOptions } from './src/WasmAsciiTransportService';
|
|
119
|
+
export { WasmSerialTransportService } from './src/WasmSerialTransportService';
|
|
120
|
+
export { requestSerialPort } from './src/WasmSerialPort';
|
|
121
|
+
export { wasmWsServerLayer } from './src/WasmTcpServerService';
|
|
122
|
+
export { wasmSerialRtuServerLayer, wasmSerialAsciiServerLayer, } from './src/WasmSerialModbusServerService';
|
|
123
|
+
export type { CoilDefinition, DiscreteInputDefinition, RegisterDefinition, SlaveDeviceDefinition, SlaveDeviceDefinitions, } from './src/mocks';
|