jmri-client 3.2.1 → 3.3.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/README.md +3 -1
- package/dist/browser/jmri-client.js +38 -23
- package/dist/browser/jmri-client.js.map +2 -2
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mocks/mock-data.js +23 -21
- package/dist/cjs/mocks/mock-data.js.map +1 -1
- package/dist/cjs/types/jmri-messages.js +23 -3
- package/dist/cjs/types/jmri-messages.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mocks/mock-data.js +23 -21
- package/dist/esm/mocks/mock-data.js.map +1 -1
- package/dist/esm/types/jmri-messages.js +22 -3
- package/dist/esm/types/jmri-messages.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/mocks/mock-data.d.ts +105 -21
- package/dist/types/types/jmri-messages.d.ts +23 -7
- package/docs/API.md +43 -1
- package/docs/BROWSER.md +3 -3
- package/docs/EXAMPLES.md +12 -4
- package/docs/MIGRATION.md +4 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* WebSocket client for JMRI with real-time updates and throttle control
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.mockData = exports.mockResponseManager = exports.MockResponseManager = exports.isValidSpeed = exports.isThrottleFunctionKey = exports.ConnectionState = exports.PowerState = exports.JmriClient = void 0;
|
|
7
|
+
exports.mockData = exports.mockResponseManager = exports.MockResponseManager = exports.powerStateToString = exports.isValidSpeed = exports.isThrottleFunctionKey = exports.ConnectionState = exports.PowerState = exports.JmriClient = void 0;
|
|
8
8
|
var client_js_1 = require("./client.js");
|
|
9
9
|
Object.defineProperty(exports, "JmriClient", { enumerable: true, get: function () { return client_js_1.JmriClient; } });
|
|
10
10
|
// Export types
|
|
@@ -13,10 +13,12 @@ var index_js_1 = require("./types/index.js");
|
|
|
13
13
|
Object.defineProperty(exports, "PowerState", { enumerable: true, get: function () { return index_js_1.PowerState; } });
|
|
14
14
|
// Event types
|
|
15
15
|
Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: function () { return index_js_1.ConnectionState; } });
|
|
16
|
-
// Export utility functions
|
|
16
|
+
// Export utility functions
|
|
17
17
|
var throttle_js_1 = require("./types/throttle.js");
|
|
18
18
|
Object.defineProperty(exports, "isThrottleFunctionKey", { enumerable: true, get: function () { return throttle_js_1.isThrottleFunctionKey; } });
|
|
19
19
|
Object.defineProperty(exports, "isValidSpeed", { enumerable: true, get: function () { return throttle_js_1.isValidSpeed; } });
|
|
20
|
+
var jmri_messages_js_1 = require("./types/jmri-messages.js");
|
|
21
|
+
Object.defineProperty(exports, "powerStateToString", { enumerable: true, get: function () { return jmri_messages_js_1.powerStateToString; } });
|
|
20
22
|
// Export mock system for testing and demo purposes
|
|
21
23
|
var index_js_2 = require("./mocks/index.js");
|
|
22
24
|
Object.defineProperty(exports, "MockResponseManager", { enumerable: true, get: function () { return index_js_2.MockResponseManager; } });
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AAAhC,uGAAA,UAAU,OAAA;AAEnB,eAAe;AACf,6CAwB0B;AAhBxB,qBAAqB;AACrB,sGAAA,UAAU,OAAA;AAOV,cAAc;AACd,2GAAA,eAAe,OAAA;AASjB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AAAhC,uGAAA,UAAU,OAAA;AAEnB,eAAe;AACf,6CAwB0B;AAhBxB,qBAAqB;AACrB,sGAAA,UAAU,OAAA;AAOV,cAAc;AACd,2GAAA,eAAe,OAAA;AASjB,2BAA2B;AAC3B,mDAA0E;AAAjE,oHAAA,qBAAqB,OAAA;AAAE,2GAAA,YAAY,OAAA;AAC5C,6DAA8D;AAArD,sHAAA,kBAAkB,OAAA;AAE3B,mDAAmD;AACnD,6CAAsF;AAA7E,+GAAA,mBAAmB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAAE,oGAAA,QAAQ,OAAA"}
|
|
@@ -54,13 +54,14 @@ exports.mockData = {
|
|
|
54
54
|
"model": "GP38-2",
|
|
55
55
|
"comment": "Blue and yellow scheme",
|
|
56
56
|
"maxSpeed": 126,
|
|
57
|
-
"functionKeys":
|
|
58
|
-
"F0": "Headlight",
|
|
59
|
-
"F1": "Bell",
|
|
60
|
-
"F2": "Horn",
|
|
61
|
-
"F3": "
|
|
62
|
-
"F4": "Dynamic Brake"
|
|
63
|
-
|
|
57
|
+
"functionKeys": [
|
|
58
|
+
{ "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
|
|
59
|
+
{ "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
|
|
60
|
+
{ "name": "F2", "label": "Horn", "lockable": false, "icon": null, "selectedIcon": null },
|
|
61
|
+
{ "name": "F3", "label": null, "lockable": false, "icon": null, "selectedIcon": null },
|
|
62
|
+
{ "name": "F4", "label": "Dynamic Brake", "lockable": true, "icon": null, "selectedIcon": null },
|
|
63
|
+
{ "name": "F5", "label": null, "lockable": false, "icon": null, "selectedIcon": null }
|
|
64
|
+
]
|
|
64
65
|
},
|
|
65
66
|
"UP3985": {
|
|
66
67
|
"name": "UP3985",
|
|
@@ -72,13 +73,13 @@ exports.mockData = {
|
|
|
72
73
|
"model": "Challenger 4-6-6-4",
|
|
73
74
|
"comment": "Steam locomotive",
|
|
74
75
|
"maxSpeed": 126,
|
|
75
|
-
"functionKeys":
|
|
76
|
-
"F0": "Headlight",
|
|
77
|
-
"F1": "Bell",
|
|
78
|
-
"F2": "Whistle",
|
|
79
|
-
"F3": "Steam",
|
|
80
|
-
"F4": "
|
|
81
|
-
|
|
76
|
+
"functionKeys": [
|
|
77
|
+
{ "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
|
|
78
|
+
{ "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
|
|
79
|
+
{ "name": "F2", "label": "Whistle", "lockable": false, "icon": null, "selectedIcon": null },
|
|
80
|
+
{ "name": "F3", "label": "Steam", "lockable": true, "icon": null, "selectedIcon": null },
|
|
81
|
+
{ "name": "F4", "label": null, "lockable": false, "icon": null, "selectedIcon": null }
|
|
82
|
+
]
|
|
82
83
|
},
|
|
83
84
|
"BNSF5240": {
|
|
84
85
|
"name": "BNSF5240",
|
|
@@ -90,13 +91,14 @@ exports.mockData = {
|
|
|
90
91
|
"model": "SD40-2",
|
|
91
92
|
"comment": "Heritage II paint",
|
|
92
93
|
"maxSpeed": 126,
|
|
93
|
-
"functionKeys":
|
|
94
|
-
"F0": "Headlight",
|
|
95
|
-
"F1": "Bell",
|
|
96
|
-
"F2": "Horn",
|
|
97
|
-
"F3": "Dynamic Brake",
|
|
98
|
-
"F4": "
|
|
99
|
-
|
|
94
|
+
"functionKeys": [
|
|
95
|
+
{ "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
|
|
96
|
+
{ "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
|
|
97
|
+
{ "name": "F2", "label": "Horn", "lockable": false, "icon": null, "selectedIcon": null },
|
|
98
|
+
{ "name": "F3", "label": "Dynamic Brake", "lockable": true, "icon": null, "selectedIcon": null },
|
|
99
|
+
{ "name": "F4", "label": null, "lockable": false, "icon": null, "selectedIcon": null },
|
|
100
|
+
{ "name": "F5", "label": "Mars Light", "lockable": true, "icon": null, "selectedIcon": null }
|
|
101
|
+
]
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-data.js","sourceRoot":"","sources":["../../../src/mocks/mock-data.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEU,QAAA,QAAQ,GAAG;IACtB,OAAO,EAAE;QACP,MAAM,EAAE,OAAO;QACf,MAAM,EAAE;YACN,MAAM,EAAE,OAAO;YACf,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,eAAe;YAC3B,MAAM,EAAE,aAAa;YACrB,eAAe,EAAE,cAAc;SAChC;KACF;IACD,OAAO,EAAE;QACP,KAAK,EAAE;YACL,IAAI,EAAE;gBACJ,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE;oBACN,OAAO,EAAE,CAAC;iBACX;aACF;YACD,KAAK,EAAE;gBACL,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE;oBACN,OAAO,EAAE,CAAC;iBACX;aACF;SACF;QACD,MAAM,EAAE;YACN,SAAS,EAAE;gBACT,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE;oBACN,OAAO,EAAE,CAAC;iBACX;aACF;SACF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE;gBACN,QAAQ,EAAE;oBACR,MAAM,EAAE,QAAQ;oBAChB,SAAS,EAAE,KAAK;oBAChB,eAAe,EAAE,IAAI;oBACrB,MAAM,EAAE,KAAK;oBACb,QAAQ,EAAE,KAAK;oBACf,KAAK,EAAE,SAAS;oBAChB,OAAO,EAAE,QAAQ;oBACjB,SAAS,EAAE,wBAAwB;oBACnC,UAAU,EAAE,GAAG;oBACf,cAAc,EAAE;wBACd,IAAI,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"mock-data.js","sourceRoot":"","sources":["../../../src/mocks/mock-data.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEU,QAAA,QAAQ,GAAG;IACtB,OAAO,EAAE;QACP,MAAM,EAAE,OAAO;QACf,MAAM,EAAE;YACN,MAAM,EAAE,OAAO;YACf,MAAM,EAAE,KAAK;YACb,UAAU,EA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AAS,EAAE,kBAAkB;aAC9B;SACF;KACF;CACO,CAAC"}
|
|
@@ -5,14 +5,34 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.PowerState = void 0;
|
|
8
|
+
exports.powerStateToString = powerStateToString;
|
|
8
9
|
/**
|
|
9
|
-
* Power state values
|
|
10
|
-
*
|
|
10
|
+
* Power state values (from JMRI JSON protocol constants)
|
|
11
|
+
* UNKNOWN = 0 (state cannot be determined)
|
|
12
|
+
* ON = 2 (power is on)
|
|
13
|
+
* OFF = 4 (power is off)
|
|
11
14
|
*/
|
|
12
15
|
var PowerState;
|
|
13
16
|
(function (PowerState) {
|
|
17
|
+
PowerState[PowerState["UNKNOWN"] = 0] = "UNKNOWN";
|
|
14
18
|
PowerState[PowerState["ON"] = 2] = "ON";
|
|
15
19
|
PowerState[PowerState["OFF"] = 4] = "OFF";
|
|
16
|
-
PowerState[PowerState["UNKNOWN"] = 0] = "UNKNOWN";
|
|
17
20
|
})(PowerState || (exports.PowerState = PowerState = {}));
|
|
21
|
+
/**
|
|
22
|
+
* Convert PowerState enum to human-readable string
|
|
23
|
+
* @param state - The power state
|
|
24
|
+
* @returns 'ON', 'OFF', or 'UNKNOWN'
|
|
25
|
+
*/
|
|
26
|
+
function powerStateToString(state) {
|
|
27
|
+
switch (state) {
|
|
28
|
+
case PowerState.ON:
|
|
29
|
+
return 'ON';
|
|
30
|
+
case PowerState.OFF:
|
|
31
|
+
return 'OFF';
|
|
32
|
+
case PowerState.UNKNOWN:
|
|
33
|
+
return 'UNKNOWN';
|
|
34
|
+
default:
|
|
35
|
+
return 'UNKNOWN';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
18
38
|
//# sourceMappingURL=jmri-messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jmri-messages.js","sourceRoot":"","sources":["../../../src/types/jmri-messages.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"jmri-messages.js","sourceRoot":"","sources":["../../../src/types/jmri-messages.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6BH,gDAWC;AA5BD;;;;;GAKG;AACH,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,iDAAW,CAAA;IACX,uCAAM,CAAA;IACN,yCAAO,CAAA;AACT,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,KAAiB;IAClD,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,UAAU,CAAC,EAAE;YAChB,OAAO,IAAI,CAAC;QACd,KAAK,UAAU,CAAC,GAAG;YACjB,OAAO,KAAK,CAAC;QACf,KAAK,UAAU,CAAC,OAAO;YACrB,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -9,8 +9,9 @@ export {
|
|
|
9
9
|
PowerState,
|
|
10
10
|
// Event types
|
|
11
11
|
ConnectionState } from './types/index.js';
|
|
12
|
-
// Export utility functions
|
|
12
|
+
// Export utility functions
|
|
13
13
|
export { isThrottleFunctionKey, isValidSpeed } from './types/throttle.js';
|
|
14
|
+
export { powerStateToString } from './types/jmri-messages.js';
|
|
14
15
|
// Export mock system for testing and demo purposes
|
|
15
16
|
export { MockResponseManager, mockResponseManager, mockData } from './mocks/index.js';
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,eAAe;AACf,OAAO;AAQL,qBAAqB;AACrB,UAAU;AAOV,cAAc;AACd,eAAe,EAOhB,MAAM,kBAAkB,CAAC;AAE1B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,eAAe;AACf,OAAO;AAQL,qBAAqB;AACrB,UAAU;AAOV,cAAc;AACd,eAAe,EAOhB,MAAM,kBAAkB,CAAC;AAE1B,2BAA2B;AAC3B,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,mDAAmD;AACnD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -51,13 +51,14 @@ export const mockData = {
|
|
|
51
51
|
"model": "GP38-2",
|
|
52
52
|
"comment": "Blue and yellow scheme",
|
|
53
53
|
"maxSpeed": 126,
|
|
54
|
-
"functionKeys":
|
|
55
|
-
"F0": "Headlight",
|
|
56
|
-
"F1": "Bell",
|
|
57
|
-
"F2": "Horn",
|
|
58
|
-
"F3": "
|
|
59
|
-
"F4": "Dynamic Brake"
|
|
60
|
-
|
|
54
|
+
"functionKeys": [
|
|
55
|
+
{ "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
|
|
56
|
+
{ "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
|
|
57
|
+
{ "name": "F2", "label": "Horn", "lockable": false, "icon": null, "selectedIcon": null },
|
|
58
|
+
{ "name": "F3", "label": null, "lockable": false, "icon": null, "selectedIcon": null },
|
|
59
|
+
{ "name": "F4", "label": "Dynamic Brake", "lockable": true, "icon": null, "selectedIcon": null },
|
|
60
|
+
{ "name": "F5", "label": null, "lockable": false, "icon": null, "selectedIcon": null }
|
|
61
|
+
]
|
|
61
62
|
},
|
|
62
63
|
"UP3985": {
|
|
63
64
|
"name": "UP3985",
|
|
@@ -69,13 +70,13 @@ export const mockData = {
|
|
|
69
70
|
"model": "Challenger 4-6-6-4",
|
|
70
71
|
"comment": "Steam locomotive",
|
|
71
72
|
"maxSpeed": 126,
|
|
72
|
-
"functionKeys":
|
|
73
|
-
"F0": "Headlight",
|
|
74
|
-
"F1": "Bell",
|
|
75
|
-
"F2": "Whistle",
|
|
76
|
-
"F3": "Steam",
|
|
77
|
-
"F4": "
|
|
78
|
-
|
|
73
|
+
"functionKeys": [
|
|
74
|
+
{ "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
|
|
75
|
+
{ "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
|
|
76
|
+
{ "name": "F2", "label": "Whistle", "lockable": false, "icon": null, "selectedIcon": null },
|
|
77
|
+
{ "name": "F3", "label": "Steam", "lockable": true, "icon": null, "selectedIcon": null },
|
|
78
|
+
{ "name": "F4", "label": null, "lockable": false, "icon": null, "selectedIcon": null }
|
|
79
|
+
]
|
|
79
80
|
},
|
|
80
81
|
"BNSF5240": {
|
|
81
82
|
"name": "BNSF5240",
|
|
@@ -87,13 +88,14 @@ export const mockData = {
|
|
|
87
88
|
"model": "SD40-2",
|
|
88
89
|
"comment": "Heritage II paint",
|
|
89
90
|
"maxSpeed": 126,
|
|
90
|
-
"functionKeys":
|
|
91
|
-
"F0": "Headlight",
|
|
92
|
-
"F1": "Bell",
|
|
93
|
-
"F2": "Horn",
|
|
94
|
-
"F3": "Dynamic Brake",
|
|
95
|
-
"F4": "
|
|
96
|
-
|
|
91
|
+
"functionKeys": [
|
|
92
|
+
{ "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
|
|
93
|
+
{ "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
|
|
94
|
+
{ "name": "F2", "label": "Horn", "lockable": false, "icon": null, "selectedIcon": null },
|
|
95
|
+
{ "name": "F3", "label": "Dynamic Brake", "lockable": true, "icon": null, "selectedIcon": null },
|
|
96
|
+
{ "name": "F4", "label": null, "lockable": false, "icon": null, "selectedIcon": null },
|
|
97
|
+
{ "name": "F5", "label": "Mars Light", "lockable": true, "icon": null, "selectedIcon": null }
|
|
98
|
+
]
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-data.js","sourceRoot":"","sources":["../../../src/mocks/mock-data.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE;QACP,MAAM,EAAE,OAAO;QACf,MAAM,EAAE;YACN,MAAM,EAAE,OAAO;YACf,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,eAAe;YAC3B,MAAM,EAAE,aAAa;YACrB,eAAe,EAAE,cAAc;SAChC;KACF;IACD,OAAO,EAAE;QACP,KAAK,EAAE;YACL,IAAI,EAAE;gBACJ,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE;oBACN,OAAO,EAAE,CAAC;iBACX;aACF;YACD,KAAK,EAAE;gBACL,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE;oBACN,OAAO,EAAE,CAAC;iBACX;aACF;SACF;QACD,MAAM,EAAE;YACN,SAAS,EAAE;gBACT,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE;oBACN,OAAO,EAAE,CAAC;iBACX;aACF;SACF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE;gBACN,QAAQ,EAAE;oBACR,MAAM,EAAE,QAAQ;oBAChB,SAAS,EAAE,KAAK;oBAChB,eAAe,EAAE,IAAI;oBACrB,MAAM,EAAE,KAAK;oBACb,QAAQ,EAAE,KAAK;oBACf,KAAK,EAAE,SAAS;oBAChB,OAAO,EAAE,QAAQ;oBACjB,SAAS,EAAE,wBAAwB;oBACnC,UAAU,EAAE,GAAG;oBACf,cAAc,EAAE;wBACd,IAAI,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"mock-data.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;aAChC;SACF;QACD,cAAc,EAAE;YACd,MAAM,EAAE,OAAO;YACf,MAAM,EAAE;gBACN,MAAM,EAAE,GAAG;gBACX,SAAS,EAAE,qBAAqB;aACjC;SACF;QACD,iBAAiB,EAAE;YACjB,MAAM,EAAE,OAAO;YACf,MAAM,EAAE;gBACN,MAAM,EAAE,GAAG;gBACX,SAAS,EAAE,kBAAkB;aAC9B;SACF;KACF;CACO,CAAC"}
|
|
@@ -3,13 +3,32 @@
|
|
|
3
3
|
* Based on JMRI JSON protocol specification
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Power state values
|
|
7
|
-
*
|
|
6
|
+
* Power state values (from JMRI JSON protocol constants)
|
|
7
|
+
* UNKNOWN = 0 (state cannot be determined)
|
|
8
|
+
* ON = 2 (power is on)
|
|
9
|
+
* OFF = 4 (power is off)
|
|
8
10
|
*/
|
|
9
11
|
export var PowerState;
|
|
10
12
|
(function (PowerState) {
|
|
13
|
+
PowerState[PowerState["UNKNOWN"] = 0] = "UNKNOWN";
|
|
11
14
|
PowerState[PowerState["ON"] = 2] = "ON";
|
|
12
15
|
PowerState[PowerState["OFF"] = 4] = "OFF";
|
|
13
|
-
PowerState[PowerState["UNKNOWN"] = 0] = "UNKNOWN";
|
|
14
16
|
})(PowerState || (PowerState = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Convert PowerState enum to human-readable string
|
|
19
|
+
* @param state - The power state
|
|
20
|
+
* @returns 'ON', 'OFF', or 'UNKNOWN'
|
|
21
|
+
*/
|
|
22
|
+
export function powerStateToString(state) {
|
|
23
|
+
switch (state) {
|
|
24
|
+
case PowerState.ON:
|
|
25
|
+
return 'ON';
|
|
26
|
+
case PowerState.OFF:
|
|
27
|
+
return 'OFF';
|
|
28
|
+
case PowerState.UNKNOWN:
|
|
29
|
+
return 'UNKNOWN';
|
|
30
|
+
default:
|
|
31
|
+
return 'UNKNOWN';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
15
34
|
//# sourceMappingURL=jmri-messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jmri-messages.js","sourceRoot":"","sources":["../../../src/types/jmri-messages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH
|
|
1
|
+
{"version":3,"file":"jmri-messages.js","sourceRoot":"","sources":["../../../src/types/jmri-messages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;;;;GAKG;AACH,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,iDAAW,CAAA;IACX,uCAAM,CAAA;IACN,yCAAO,CAAA;AACT,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAiB;IAClD,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,UAAU,CAAC,EAAE;YAChB,OAAO,IAAI,CAAC;QACd,KAAK,UAAU,CAAC,GAAG;YACjB,OAAO,KAAK,CAAC;QACf,KAAK,UAAU,CAAC,OAAO;YACrB,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
export { JmriClient } from './client.js';
|
|
6
6
|
export { JmriClientOptions, PartialClientOptions, ReconnectionOptions, HeartbeatOptions, MockOptions, PowerState, RosterEntry, JmriMessage, PowerMessage, ThrottleMessage, RosterMessage, ConnectionState, EventPayloads, ThrottleAcquireOptions, ThrottleFunctionKey, ThrottleState } from './types/index.js';
|
|
7
7
|
export { isThrottleFunctionKey, isValidSpeed } from './types/throttle.js';
|
|
8
|
+
export { powerStateToString } from './types/jmri-messages.js';
|
|
8
9
|
export { MockResponseManager, mockResponseManager, mockData } from './mocks/index.js';
|
|
9
10
|
export type { MockResponseManagerOptions } from './mocks/index.js';
|
|
@@ -51,13 +51,43 @@ export declare const mockData: {
|
|
|
51
51
|
readonly model: "GP38-2";
|
|
52
52
|
readonly comment: "Blue and yellow scheme";
|
|
53
53
|
readonly maxSpeed: 126;
|
|
54
|
-
readonly functionKeys: {
|
|
55
|
-
readonly
|
|
56
|
-
readonly
|
|
57
|
-
readonly
|
|
58
|
-
readonly
|
|
59
|
-
readonly
|
|
60
|
-
}
|
|
54
|
+
readonly functionKeys: readonly [{
|
|
55
|
+
readonly name: "F0";
|
|
56
|
+
readonly label: "Headlight";
|
|
57
|
+
readonly lockable: true;
|
|
58
|
+
readonly icon: null;
|
|
59
|
+
readonly selectedIcon: null;
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "F1";
|
|
62
|
+
readonly label: "Bell";
|
|
63
|
+
readonly lockable: true;
|
|
64
|
+
readonly icon: null;
|
|
65
|
+
readonly selectedIcon: null;
|
|
66
|
+
}, {
|
|
67
|
+
readonly name: "F2";
|
|
68
|
+
readonly label: "Horn";
|
|
69
|
+
readonly lockable: false;
|
|
70
|
+
readonly icon: null;
|
|
71
|
+
readonly selectedIcon: null;
|
|
72
|
+
}, {
|
|
73
|
+
readonly name: "F3";
|
|
74
|
+
readonly label: null;
|
|
75
|
+
readonly lockable: false;
|
|
76
|
+
readonly icon: null;
|
|
77
|
+
readonly selectedIcon: null;
|
|
78
|
+
}, {
|
|
79
|
+
readonly name: "F4";
|
|
80
|
+
readonly label: "Dynamic Brake";
|
|
81
|
+
readonly lockable: true;
|
|
82
|
+
readonly icon: null;
|
|
83
|
+
readonly selectedIcon: null;
|
|
84
|
+
}, {
|
|
85
|
+
readonly name: "F5";
|
|
86
|
+
readonly label: null;
|
|
87
|
+
readonly lockable: false;
|
|
88
|
+
readonly icon: null;
|
|
89
|
+
readonly selectedIcon: null;
|
|
90
|
+
}];
|
|
61
91
|
};
|
|
62
92
|
readonly UP3985: {
|
|
63
93
|
readonly name: "UP3985";
|
|
@@ -69,13 +99,37 @@ export declare const mockData: {
|
|
|
69
99
|
readonly model: "Challenger 4-6-6-4";
|
|
70
100
|
readonly comment: "Steam locomotive";
|
|
71
101
|
readonly maxSpeed: 126;
|
|
72
|
-
readonly functionKeys: {
|
|
73
|
-
readonly
|
|
74
|
-
readonly
|
|
75
|
-
readonly
|
|
76
|
-
readonly
|
|
77
|
-
readonly
|
|
78
|
-
}
|
|
102
|
+
readonly functionKeys: readonly [{
|
|
103
|
+
readonly name: "F0";
|
|
104
|
+
readonly label: "Headlight";
|
|
105
|
+
readonly lockable: true;
|
|
106
|
+
readonly icon: null;
|
|
107
|
+
readonly selectedIcon: null;
|
|
108
|
+
}, {
|
|
109
|
+
readonly name: "F1";
|
|
110
|
+
readonly label: "Bell";
|
|
111
|
+
readonly lockable: true;
|
|
112
|
+
readonly icon: null;
|
|
113
|
+
readonly selectedIcon: null;
|
|
114
|
+
}, {
|
|
115
|
+
readonly name: "F2";
|
|
116
|
+
readonly label: "Whistle";
|
|
117
|
+
readonly lockable: false;
|
|
118
|
+
readonly icon: null;
|
|
119
|
+
readonly selectedIcon: null;
|
|
120
|
+
}, {
|
|
121
|
+
readonly name: "F3";
|
|
122
|
+
readonly label: "Steam";
|
|
123
|
+
readonly lockable: true;
|
|
124
|
+
readonly icon: null;
|
|
125
|
+
readonly selectedIcon: null;
|
|
126
|
+
}, {
|
|
127
|
+
readonly name: "F4";
|
|
128
|
+
readonly label: null;
|
|
129
|
+
readonly lockable: false;
|
|
130
|
+
readonly icon: null;
|
|
131
|
+
readonly selectedIcon: null;
|
|
132
|
+
}];
|
|
79
133
|
};
|
|
80
134
|
readonly BNSF5240: {
|
|
81
135
|
readonly name: "BNSF5240";
|
|
@@ -87,13 +141,43 @@ export declare const mockData: {
|
|
|
87
141
|
readonly model: "SD40-2";
|
|
88
142
|
readonly comment: "Heritage II paint";
|
|
89
143
|
readonly maxSpeed: 126;
|
|
90
|
-
readonly functionKeys: {
|
|
91
|
-
readonly
|
|
92
|
-
readonly
|
|
93
|
-
readonly
|
|
94
|
-
readonly
|
|
95
|
-
readonly
|
|
96
|
-
}
|
|
144
|
+
readonly functionKeys: readonly [{
|
|
145
|
+
readonly name: "F0";
|
|
146
|
+
readonly label: "Headlight";
|
|
147
|
+
readonly lockable: true;
|
|
148
|
+
readonly icon: null;
|
|
149
|
+
readonly selectedIcon: null;
|
|
150
|
+
}, {
|
|
151
|
+
readonly name: "F1";
|
|
152
|
+
readonly label: "Bell";
|
|
153
|
+
readonly lockable: true;
|
|
154
|
+
readonly icon: null;
|
|
155
|
+
readonly selectedIcon: null;
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "F2";
|
|
158
|
+
readonly label: "Horn";
|
|
159
|
+
readonly lockable: false;
|
|
160
|
+
readonly icon: null;
|
|
161
|
+
readonly selectedIcon: null;
|
|
162
|
+
}, {
|
|
163
|
+
readonly name: "F3";
|
|
164
|
+
readonly label: "Dynamic Brake";
|
|
165
|
+
readonly lockable: true;
|
|
166
|
+
readonly icon: null;
|
|
167
|
+
readonly selectedIcon: null;
|
|
168
|
+
}, {
|
|
169
|
+
readonly name: "F4";
|
|
170
|
+
readonly label: null;
|
|
171
|
+
readonly lockable: false;
|
|
172
|
+
readonly icon: null;
|
|
173
|
+
readonly selectedIcon: null;
|
|
174
|
+
}, {
|
|
175
|
+
readonly name: "F5";
|
|
176
|
+
readonly label: "Mars Light";
|
|
177
|
+
readonly lockable: true;
|
|
178
|
+
readonly icon: null;
|
|
179
|
+
readonly selectedIcon: null;
|
|
180
|
+
}];
|
|
97
181
|
};
|
|
98
182
|
};
|
|
99
183
|
};
|
|
@@ -12,14 +12,22 @@ export interface JmriMessage {
|
|
|
12
12
|
id?: number;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Power state values
|
|
16
|
-
*
|
|
15
|
+
* Power state values (from JMRI JSON protocol constants)
|
|
16
|
+
* UNKNOWN = 0 (state cannot be determined)
|
|
17
|
+
* ON = 2 (power is on)
|
|
18
|
+
* OFF = 4 (power is off)
|
|
17
19
|
*/
|
|
18
20
|
export declare enum PowerState {
|
|
21
|
+
UNKNOWN = 0,
|
|
19
22
|
ON = 2,
|
|
20
|
-
OFF = 4
|
|
21
|
-
UNKNOWN = 0
|
|
23
|
+
OFF = 4
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert PowerState enum to human-readable string
|
|
27
|
+
* @param state - The power state
|
|
28
|
+
* @returns 'ON', 'OFF', or 'UNKNOWN'
|
|
29
|
+
*/
|
|
30
|
+
export declare function powerStateToString(state: PowerState): string;
|
|
23
31
|
/**
|
|
24
32
|
* Power message data
|
|
25
33
|
*/
|
|
@@ -80,6 +88,16 @@ export interface ThrottleMessage extends JmriMessage {
|
|
|
80
88
|
type: 'throttle';
|
|
81
89
|
data: ThrottleData;
|
|
82
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Function key definition
|
|
93
|
+
*/
|
|
94
|
+
export interface FunctionKey {
|
|
95
|
+
name: string;
|
|
96
|
+
label: string | null;
|
|
97
|
+
lockable: boolean;
|
|
98
|
+
icon: string | null;
|
|
99
|
+
selectedIcon: string | null;
|
|
100
|
+
}
|
|
83
101
|
/**
|
|
84
102
|
* Roster entry
|
|
85
103
|
*/
|
|
@@ -95,9 +113,7 @@ export interface RosterEntry {
|
|
|
95
113
|
maxSpeed?: number;
|
|
96
114
|
imageFilePath?: string;
|
|
97
115
|
iconFilePath?: string;
|
|
98
|
-
functionKeys?:
|
|
99
|
-
[key: string]: string;
|
|
100
|
-
};
|
|
116
|
+
functionKeys?: FunctionKey[];
|
|
101
117
|
}
|
|
102
118
|
/**
|
|
103
119
|
* Roster data structure
|
package/docs/API.md
CHANGED
|
@@ -58,12 +58,36 @@ client.on('heartbeat:timeout', () => { });
|
|
|
58
58
|
```typescript
|
|
59
59
|
// Get current power state
|
|
60
60
|
const state: PowerState = await client.getPower();
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
// PowerState enum values (from JMRI JSON protocol):
|
|
63
|
+
// PowerState.UNKNOWN = 0 (state cannot be determined)
|
|
64
|
+
// PowerState.ON = 2 (power is on)
|
|
65
|
+
// PowerState.OFF = 4 (power is off)
|
|
66
|
+
|
|
67
|
+
// Handle power state
|
|
68
|
+
switch (state) {
|
|
69
|
+
case PowerState.ON:
|
|
70
|
+
console.log('Power is ON');
|
|
71
|
+
break;
|
|
72
|
+
case PowerState.OFF:
|
|
73
|
+
console.log('Power is OFF');
|
|
74
|
+
break;
|
|
75
|
+
case PowerState.UNKNOWN:
|
|
76
|
+
console.log('Power state is UNKNOWN');
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
62
79
|
|
|
63
80
|
// Set power
|
|
64
81
|
await client.setPower(PowerState.ON);
|
|
65
82
|
await client.powerOn(); // Convenience method
|
|
66
83
|
await client.powerOff(); // Convenience method
|
|
84
|
+
|
|
85
|
+
// Listen for power changes (including UNKNOWN states)
|
|
86
|
+
client.on('power:changed', (state: PowerState) => {
|
|
87
|
+
if (state === PowerState.UNKNOWN) {
|
|
88
|
+
console.log('Power state became unknown (connection issue?)');
|
|
89
|
+
}
|
|
90
|
+
});
|
|
67
91
|
```
|
|
68
92
|
|
|
69
93
|
## Roster Management
|
|
@@ -138,6 +162,24 @@ const state = client.getConnectionState();
|
|
|
138
162
|
// ConnectionState.CONNECTED, DISCONNECTED, CONNECTING, or RECONNECTING
|
|
139
163
|
```
|
|
140
164
|
|
|
165
|
+
## Utility Functions
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
import { powerStateToString, isThrottleFunctionKey, isValidSpeed } from 'jmri-client';
|
|
169
|
+
|
|
170
|
+
// Convert PowerState enum to readable string
|
|
171
|
+
const stateStr = powerStateToString(PowerState.ON); // 'ON'
|
|
172
|
+
const stateStr2 = powerStateToString(PowerState.UNKNOWN); // 'UNKNOWN'
|
|
173
|
+
|
|
174
|
+
// Validate throttle function key
|
|
175
|
+
isThrottleFunctionKey('F0'); // true
|
|
176
|
+
isThrottleFunctionKey('F99'); // false
|
|
177
|
+
|
|
178
|
+
// Validate speed value (0.0 to 1.0)
|
|
179
|
+
isValidSpeed(0.5); // true
|
|
180
|
+
isValidSpeed(1.5); // false
|
|
181
|
+
```
|
|
182
|
+
|
|
141
183
|
## TypeScript Types
|
|
142
184
|
|
|
143
185
|
All types are exported from the main package:
|
package/docs/BROWSER.md
CHANGED
|
@@ -112,7 +112,7 @@ For quick prototypes without a build step, use the browser bundle:
|
|
|
112
112
|
|
|
113
113
|
<script type="module">
|
|
114
114
|
// Use the browser bundle from CDN
|
|
115
|
-
import { JmriClient } from 'https://unpkg.com/jmri-client@3.
|
|
115
|
+
import { JmriClient } from 'https://unpkg.com/jmri-client@3.3.0/dist/browser/jmri-client.js';
|
|
116
116
|
|
|
117
117
|
const client = new JmriClient({
|
|
118
118
|
host: 'localhost',
|
|
@@ -144,8 +144,8 @@ For quick prototypes without a build step, use the browser bundle:
|
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
Alternative CDNs:
|
|
147
|
-
- **unpkg**: `https://unpkg.com/jmri-client@3.
|
|
148
|
-
- **jsDelivr**: `https://cdn.jsdelivr.net/npm/jmri-client@3.
|
|
147
|
+
- **unpkg**: `https://unpkg.com/jmri-client@3.3.0/dist/browser/jmri-client.js`
|
|
148
|
+
- **jsDelivr**: `https://cdn.jsdelivr.net/npm/jmri-client@3.3.0/dist/browser/jmri-client.js`
|
|
149
149
|
|
|
150
150
|
## React Example
|
|
151
151
|
|