jmri-client 5.1.0 → 5.2.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 +1 -1
- package/dist/browser/jmri-client.js +4 -4
- package/dist/cjs/index.js +4 -4
- package/dist/esm/index.js +4 -4
- package/dist/types/managers/throttle-manager.d.ts +1 -1
- package/dist/types/types/jmri-messages.d.ts +40 -0
- package/dist/types/types/throttle.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ WebSocket client for [JMRI](http://jmri.sourceforge.net/) with real-time updates
|
|
|
12
12
|
|
|
13
13
|
- ✅ **WebSocket-based** - Real-time bidirectional communication
|
|
14
14
|
- ✅ **Event-driven** - Subscribe to power changes, throttle updates, and more
|
|
15
|
-
- ✅ **Full Throttle Control** - Speed (0.0-1.0), direction, and functions (F0-
|
|
15
|
+
- ✅ **Full Throttle Control** - Speed (0.0-1.0), direction, and functions (F0-F68)
|
|
16
16
|
- ✅ **Browser & Node.js** - Works in browsers and Node.js with auto-detection
|
|
17
17
|
- ✅ **Mock Mode** - Test and demo without JMRI hardware
|
|
18
18
|
- ✅ **Auto-reconnection** - Exponential backoff with jitter
|
|
@@ -1043,7 +1043,7 @@ var MockResponseManager = class {
|
|
|
1043
1043
|
if (data.forward !== void 0) {
|
|
1044
1044
|
throttleState.forward = data.forward;
|
|
1045
1045
|
}
|
|
1046
|
-
for (let i = 0; i <=
|
|
1046
|
+
for (let i = 0; i <= 68; i++) {
|
|
1047
1047
|
const key = `F${i}`;
|
|
1048
1048
|
if (data[key] !== void 0) {
|
|
1049
1049
|
throttleState[key] = data[key];
|
|
@@ -1695,7 +1695,7 @@ var RosterManager = class {
|
|
|
1695
1695
|
|
|
1696
1696
|
// src/types/throttle.ts
|
|
1697
1697
|
function isThrottleFunctionKey(key) {
|
|
1698
|
-
return /^F([0-9]|1[0-9]|
|
|
1698
|
+
return /^F([0-9]|[1-5][0-9]|6[0-8])$/.test(key);
|
|
1699
1699
|
}
|
|
1700
1700
|
function isValidSpeed(speed) {
|
|
1701
1701
|
return typeof speed === "number" && speed >= 0 && speed <= 1;
|
|
@@ -1808,7 +1808,7 @@ var ThrottleManager = class extends import_index.default {
|
|
|
1808
1808
|
this.emit("throttle:updated", throttleId, { forward });
|
|
1809
1809
|
}
|
|
1810
1810
|
/**
|
|
1811
|
-
* Set throttle function (F0-
|
|
1811
|
+
* Set throttle function (F0-F68)
|
|
1812
1812
|
*/
|
|
1813
1813
|
async setFunction(throttleId, functionKey, value) {
|
|
1814
1814
|
const state = this.throttles.get(throttleId);
|
|
@@ -1892,7 +1892,7 @@ var ThrottleManager = class extends import_index.default {
|
|
|
1892
1892
|
if (message.data.forward !== void 0) {
|
|
1893
1893
|
state.forward = message.data.forward;
|
|
1894
1894
|
}
|
|
1895
|
-
for (let i = 0; i <=
|
|
1895
|
+
for (let i = 0; i <= 68; i++) {
|
|
1896
1896
|
const key = `F${i}`;
|
|
1897
1897
|
if (message.data[key] !== void 0) {
|
|
1898
1898
|
state.functions.set(key, message.data[key]);
|
package/dist/cjs/index.js
CHANGED
|
@@ -901,7 +901,7 @@ var MockResponseManager = class {
|
|
|
901
901
|
if (data.forward !== void 0) {
|
|
902
902
|
throttleState.forward = data.forward;
|
|
903
903
|
}
|
|
904
|
-
for (let i = 0; i <=
|
|
904
|
+
for (let i = 0; i <= 68; i++) {
|
|
905
905
|
const key = `F${i}`;
|
|
906
906
|
if (data[key] !== void 0) {
|
|
907
907
|
throttleState[key] = data[key];
|
|
@@ -1557,7 +1557,7 @@ var import_eventemitter37 = require("eventemitter3");
|
|
|
1557
1557
|
|
|
1558
1558
|
// src/types/throttle.ts
|
|
1559
1559
|
function isThrottleFunctionKey(key) {
|
|
1560
|
-
return /^F([0-9]|1[0-9]|
|
|
1560
|
+
return /^F([0-9]|[1-5][0-9]|6[0-8])$/.test(key);
|
|
1561
1561
|
}
|
|
1562
1562
|
function isValidSpeed(speed) {
|
|
1563
1563
|
return typeof speed === "number" && speed >= 0 && speed <= 1;
|
|
@@ -1670,7 +1670,7 @@ var ThrottleManager = class extends import_eventemitter37.EventEmitter {
|
|
|
1670
1670
|
this.emit("throttle:updated", throttleId, { forward });
|
|
1671
1671
|
}
|
|
1672
1672
|
/**
|
|
1673
|
-
* Set throttle function (F0-
|
|
1673
|
+
* Set throttle function (F0-F68)
|
|
1674
1674
|
*/
|
|
1675
1675
|
async setFunction(throttleId, functionKey, value) {
|
|
1676
1676
|
const state = this.throttles.get(throttleId);
|
|
@@ -1754,7 +1754,7 @@ var ThrottleManager = class extends import_eventemitter37.EventEmitter {
|
|
|
1754
1754
|
if (message.data.forward !== void 0) {
|
|
1755
1755
|
state.forward = message.data.forward;
|
|
1756
1756
|
}
|
|
1757
|
-
for (let i = 0; i <=
|
|
1757
|
+
for (let i = 0; i <= 68; i++) {
|
|
1758
1758
|
const key = `F${i}`;
|
|
1759
1759
|
if (message.data[key] !== void 0) {
|
|
1760
1760
|
state.functions.set(key, message.data[key]);
|
package/dist/esm/index.js
CHANGED
|
@@ -852,7 +852,7 @@ var MockResponseManager = class {
|
|
|
852
852
|
if (data.forward !== void 0) {
|
|
853
853
|
throttleState.forward = data.forward;
|
|
854
854
|
}
|
|
855
|
-
for (let i = 0; i <=
|
|
855
|
+
for (let i = 0; i <= 68; i++) {
|
|
856
856
|
const key = `F${i}`;
|
|
857
857
|
if (data[key] !== void 0) {
|
|
858
858
|
throttleState[key] = data[key];
|
|
@@ -1508,7 +1508,7 @@ import { EventEmitter as EventEmitter7 } from "eventemitter3";
|
|
|
1508
1508
|
|
|
1509
1509
|
// src/types/throttle.ts
|
|
1510
1510
|
function isThrottleFunctionKey(key) {
|
|
1511
|
-
return /^F([0-9]|1[0-9]|
|
|
1511
|
+
return /^F([0-9]|[1-5][0-9]|6[0-8])$/.test(key);
|
|
1512
1512
|
}
|
|
1513
1513
|
function isValidSpeed(speed) {
|
|
1514
1514
|
return typeof speed === "number" && speed >= 0 && speed <= 1;
|
|
@@ -1621,7 +1621,7 @@ var ThrottleManager = class extends EventEmitter7 {
|
|
|
1621
1621
|
this.emit("throttle:updated", throttleId, { forward });
|
|
1622
1622
|
}
|
|
1623
1623
|
/**
|
|
1624
|
-
* Set throttle function (F0-
|
|
1624
|
+
* Set throttle function (F0-F68)
|
|
1625
1625
|
*/
|
|
1626
1626
|
async setFunction(throttleId, functionKey, value) {
|
|
1627
1627
|
const state = this.throttles.get(throttleId);
|
|
@@ -1705,7 +1705,7 @@ var ThrottleManager = class extends EventEmitter7 {
|
|
|
1705
1705
|
if (message.data.forward !== void 0) {
|
|
1706
1706
|
state.forward = message.data.forward;
|
|
1707
1707
|
}
|
|
1708
|
-
for (let i = 0; i <=
|
|
1708
|
+
for (let i = 0; i <= 68; i++) {
|
|
1709
1709
|
const key = `F${i}`;
|
|
1710
1710
|
if (message.data[key] !== void 0) {
|
|
1711
1711
|
state.functions.set(key, message.data[key]);
|
|
@@ -29,7 +29,7 @@ export declare class ThrottleManager extends EventEmitter {
|
|
|
29
29
|
*/
|
|
30
30
|
setDirection(throttleId: string, forward: boolean): Promise<void>;
|
|
31
31
|
/**
|
|
32
|
-
* Set throttle function (F0-
|
|
32
|
+
* Set throttle function (F0-F68)
|
|
33
33
|
*/
|
|
34
34
|
setFunction(throttleId: string, functionKey: ThrottleFunctionKey, value: boolean): Promise<void>;
|
|
35
35
|
/**
|
|
@@ -98,6 +98,46 @@ export interface ThrottleData {
|
|
|
98
98
|
F26?: boolean;
|
|
99
99
|
F27?: boolean;
|
|
100
100
|
F28?: boolean;
|
|
101
|
+
F29?: boolean;
|
|
102
|
+
F30?: boolean;
|
|
103
|
+
F31?: boolean;
|
|
104
|
+
F32?: boolean;
|
|
105
|
+
F33?: boolean;
|
|
106
|
+
F34?: boolean;
|
|
107
|
+
F35?: boolean;
|
|
108
|
+
F36?: boolean;
|
|
109
|
+
F37?: boolean;
|
|
110
|
+
F38?: boolean;
|
|
111
|
+
F39?: boolean;
|
|
112
|
+
F40?: boolean;
|
|
113
|
+
F41?: boolean;
|
|
114
|
+
F42?: boolean;
|
|
115
|
+
F43?: boolean;
|
|
116
|
+
F44?: boolean;
|
|
117
|
+
F45?: boolean;
|
|
118
|
+
F46?: boolean;
|
|
119
|
+
F47?: boolean;
|
|
120
|
+
F48?: boolean;
|
|
121
|
+
F49?: boolean;
|
|
122
|
+
F50?: boolean;
|
|
123
|
+
F51?: boolean;
|
|
124
|
+
F52?: boolean;
|
|
125
|
+
F53?: boolean;
|
|
126
|
+
F54?: boolean;
|
|
127
|
+
F55?: boolean;
|
|
128
|
+
F56?: boolean;
|
|
129
|
+
F57?: boolean;
|
|
130
|
+
F58?: boolean;
|
|
131
|
+
F59?: boolean;
|
|
132
|
+
F60?: boolean;
|
|
133
|
+
F61?: boolean;
|
|
134
|
+
F62?: boolean;
|
|
135
|
+
F63?: boolean;
|
|
136
|
+
F64?: boolean;
|
|
137
|
+
F65?: boolean;
|
|
138
|
+
F66?: boolean;
|
|
139
|
+
F67?: boolean;
|
|
140
|
+
F68?: boolean;
|
|
101
141
|
}
|
|
102
142
|
/**
|
|
103
143
|
* Throttle message
|
|
@@ -21,9 +21,9 @@ export interface ThrottleAcquireOptions {
|
|
|
21
21
|
prefix?: string;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Throttle function key (F0-
|
|
24
|
+
* Throttle function key (F0-F68)
|
|
25
25
|
*/
|
|
26
|
-
export type ThrottleFunctionKey = 'F0' | 'F1' | 'F2' | 'F3' | 'F4' | 'F5' | 'F6' | 'F7' | 'F8' | 'F9' | 'F10' | 'F11' | 'F12' | 'F13' | 'F14' | 'F15' | 'F16' | 'F17' | 'F18' | 'F19' | 'F20' | 'F21' | 'F22' | 'F23' | 'F24' | 'F25' | 'F26' | 'F27' | 'F28';
|
|
26
|
+
export type ThrottleFunctionKey = 'F0' | 'F1' | 'F2' | 'F3' | 'F4' | 'F5' | 'F6' | 'F7' | 'F8' | 'F9' | 'F10' | 'F11' | 'F12' | 'F13' | 'F14' | 'F15' | 'F16' | 'F17' | 'F18' | 'F19' | 'F20' | 'F21' | 'F22' | 'F23' | 'F24' | 'F25' | 'F26' | 'F27' | 'F28' | 'F29' | 'F30' | 'F31' | 'F32' | 'F33' | 'F34' | 'F35' | 'F36' | 'F37' | 'F38' | 'F39' | 'F40' | 'F41' | 'F42' | 'F43' | 'F44' | 'F45' | 'F46' | 'F47' | 'F48' | 'F49' | 'F50' | 'F51' | 'F52' | 'F53' | 'F54' | 'F55' | 'F56' | 'F57' | 'F58' | 'F59' | 'F60' | 'F61' | 'F62' | 'F63' | 'F64' | 'F65' | 'F66' | 'F67' | 'F68';
|
|
27
27
|
/**
|
|
28
28
|
* Throttle state tracking
|
|
29
29
|
*/
|
|
@@ -45,7 +45,7 @@ export interface ThrottleState {
|
|
|
45
45
|
*/
|
|
46
46
|
forward: boolean;
|
|
47
47
|
/**
|
|
48
|
-
* Function states (F0-
|
|
48
|
+
* Function states (F0-F68)
|
|
49
49
|
*/
|
|
50
50
|
functions: Map<ThrottleFunctionKey, boolean>;
|
|
51
51
|
/**
|
package/package.json
CHANGED