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 CHANGED
@@ -42,7 +42,9 @@ const client = new JmriClient({
42
42
  // Listen for events
43
43
  client.on('connected', () => console.log('Connected!'));
44
44
  client.on('power:changed', (state) => {
45
- console.log('Power:', state === PowerState.ON ? 'ON' : 'OFF');
45
+ const stateStr = state === PowerState.ON ? 'ON' :
46
+ state === PowerState.OFF ? 'OFF' : 'UNKNOWN';
47
+ console.log('Power:', stateStr);
46
48
  });
47
49
 
48
50
  // Control power
@@ -601,11 +601,23 @@ var ReconnectionManager = class extends import_index.default {
601
601
 
602
602
  // src/types/jmri-messages.ts
603
603
  var PowerState = /* @__PURE__ */ ((PowerState2) => {
604
+ PowerState2[PowerState2["UNKNOWN"] = 0] = "UNKNOWN";
604
605
  PowerState2[PowerState2["ON"] = 2] = "ON";
605
606
  PowerState2[PowerState2["OFF"] = 4] = "OFF";
606
- PowerState2[PowerState2["UNKNOWN"] = 0] = "UNKNOWN";
607
607
  return PowerState2;
608
608
  })(PowerState || {});
609
+ function powerStateToString(state) {
610
+ switch (state) {
611
+ case 2 /* ON */:
612
+ return "ON";
613
+ case 4 /* OFF */:
614
+ return "OFF";
615
+ case 0 /* UNKNOWN */:
616
+ return "UNKNOWN";
617
+ default:
618
+ return "UNKNOWN";
619
+ }
620
+ }
609
621
 
610
622
  // src/mocks/mock-data.ts
611
623
  var mockData = {
@@ -657,13 +669,14 @@ var mockData = {
657
669
  "model": "GP38-2",
658
670
  "comment": "Blue and yellow scheme",
659
671
  "maxSpeed": 126,
660
- "functionKeys": {
661
- "F0": "Headlight",
662
- "F1": "Bell",
663
- "F2": "Horn",
664
- "F3": "Air Release",
665
- "F4": "Dynamic Brake"
666
- }
672
+ "functionKeys": [
673
+ { "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
674
+ { "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
675
+ { "name": "F2", "label": "Horn", "lockable": false, "icon": null, "selectedIcon": null },
676
+ { "name": "F3", "label": null, "lockable": false, "icon": null, "selectedIcon": null },
677
+ { "name": "F4", "label": "Dynamic Brake", "lockable": true, "icon": null, "selectedIcon": null },
678
+ { "name": "F5", "label": null, "lockable": false, "icon": null, "selectedIcon": null }
679
+ ]
667
680
  },
668
681
  "UP3985": {
669
682
  "name": "UP3985",
@@ -675,13 +688,13 @@ var mockData = {
675
688
  "model": "Challenger 4-6-6-4",
676
689
  "comment": "Steam locomotive",
677
690
  "maxSpeed": 126,
678
- "functionKeys": {
679
- "F0": "Headlight",
680
- "F1": "Bell",
681
- "F2": "Whistle",
682
- "F3": "Steam",
683
- "F4": "Coupler"
684
- }
691
+ "functionKeys": [
692
+ { "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
693
+ { "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
694
+ { "name": "F2", "label": "Whistle", "lockable": false, "icon": null, "selectedIcon": null },
695
+ { "name": "F3", "label": "Steam", "lockable": true, "icon": null, "selectedIcon": null },
696
+ { "name": "F4", "label": null, "lockable": false, "icon": null, "selectedIcon": null }
697
+ ]
685
698
  },
686
699
  "BNSF5240": {
687
700
  "name": "BNSF5240",
@@ -693,13 +706,14 @@ var mockData = {
693
706
  "model": "SD40-2",
694
707
  "comment": "Heritage II paint",
695
708
  "maxSpeed": 126,
696
- "functionKeys": {
697
- "F0": "Headlight",
698
- "F1": "Bell",
699
- "F2": "Horn",
700
- "F3": "Dynamic Brake",
701
- "F4": "Mars Light"
702
- }
709
+ "functionKeys": [
710
+ { "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
711
+ { "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
712
+ { "name": "F2", "label": "Horn", "lockable": false, "icon": null, "selectedIcon": null },
713
+ { "name": "F3", "label": "Dynamic Brake", "lockable": true, "icon": null, "selectedIcon": null },
714
+ { "name": "F4", "label": null, "lockable": false, "icon": null, "selectedIcon": null },
715
+ { "name": "F5", "label": "Mars Light", "lockable": true, "icon": null, "selectedIcon": null }
716
+ ]
703
717
  }
704
718
  }
705
719
  }
@@ -1955,6 +1969,7 @@ export {
1955
1969
  isThrottleFunctionKey,
1956
1970
  isValidSpeed,
1957
1971
  mockData,
1958
- mockResponseManager
1972
+ mockResponseManager,
1973
+ powerStateToString
1959
1974
  };
1960
1975
  //# sourceMappingURL=jmri-client.js.map