jmri-client 3.4.1 → 3.5.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/dist/browser/jmri-client.js +82 -25
- package/dist/browser/jmri-client.js.map +2 -2
- package/dist/cjs/managers/roster-manager.js +25 -7
- package/dist/cjs/managers/roster-manager.js.map +1 -1
- package/dist/cjs/mocks/mock-data.js +54 -16
- package/dist/cjs/mocks/mock-data.js.map +1 -1
- package/dist/cjs/mocks/mock-response-manager.js +7 -2
- package/dist/cjs/mocks/mock-response-manager.js.map +1 -1
- package/dist/esm/managers/roster-manager.js +25 -7
- package/dist/esm/managers/roster-manager.js.map +1 -1
- package/dist/esm/mocks/mock-data.js +54 -16
- package/dist/esm/mocks/mock-data.js.map +1 -1
- package/dist/esm/mocks/mock-response-manager.js +7 -2
- package/dist/esm/mocks/mock-response-manager.js.map +1 -1
- package/dist/types/client.d.ts +5 -5
- package/dist/types/managers/roster-manager.d.ts +6 -6
- package/dist/types/mocks/mock-data.d.ts +177 -143
- package/dist/types/types/jmri-messages.d.ts +35 -11
- package/docs/MOCK_MODE.md +9 -5
- package/package.json +1 -1
- package/dist/cjs/mocks/mock-data.json +0 -176
- package/dist/esm/mocks/mock-data.json +0 -176
|
@@ -625,8 +625,10 @@ var mockData = {
|
|
|
625
625
|
"type": "hello",
|
|
626
626
|
"data": {
|
|
627
627
|
"JMRI": "5.9.2",
|
|
628
|
-
"
|
|
629
|
-
"
|
|
628
|
+
"json": "5.0",
|
|
629
|
+
"version": "v5",
|
|
630
|
+
"heartbeat": 13500,
|
|
631
|
+
"railroad": "Demo Railroad",
|
|
630
632
|
"node": "jmri-server",
|
|
631
633
|
"activeProfile": "Demo Profile"
|
|
632
634
|
}
|
|
@@ -656,19 +658,26 @@ var mockData = {
|
|
|
656
658
|
}
|
|
657
659
|
},
|
|
658
660
|
"roster": {
|
|
659
|
-
"list":
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
"
|
|
661
|
+
"list": [
|
|
662
|
+
{
|
|
663
|
+
"type": "rosterEntry",
|
|
664
|
+
"data": {
|
|
663
665
|
"name": "CSX754",
|
|
664
666
|
"address": "754",
|
|
665
667
|
"isLongAddress": true,
|
|
666
668
|
"road": "CSX",
|
|
667
669
|
"number": "754",
|
|
668
670
|
"mfg": "Athearn",
|
|
671
|
+
"decoderModel": "DH163D",
|
|
672
|
+
"decoderFamily": "Digitrax DH163",
|
|
669
673
|
"model": "GP38-2",
|
|
670
674
|
"comment": "Blue and yellow scheme",
|
|
671
|
-
"
|
|
675
|
+
"maxSpeedPct": 100,
|
|
676
|
+
"image": null,
|
|
677
|
+
"icon": "/roster/CSX754/icon",
|
|
678
|
+
"shuntingFunction": "",
|
|
679
|
+
"owner": "",
|
|
680
|
+
"dateModified": "2026-02-10T00:00:00.000+00:00",
|
|
672
681
|
"functionKeys": [
|
|
673
682
|
{ "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
|
|
674
683
|
{ "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
|
|
@@ -676,36 +685,62 @@ var mockData = {
|
|
|
676
685
|
{ "name": "F3", "label": null, "lockable": false, "icon": null, "selectedIcon": null },
|
|
677
686
|
{ "name": "F4", "label": "Dynamic Brake", "lockable": true, "icon": null, "selectedIcon": null },
|
|
678
687
|
{ "name": "F5", "label": null, "lockable": false, "icon": null, "selectedIcon": null }
|
|
679
|
-
]
|
|
688
|
+
],
|
|
689
|
+
"attributes": [],
|
|
690
|
+
"rosterGroups": []
|
|
680
691
|
},
|
|
681
|
-
"
|
|
692
|
+
"id": 1
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
"type": "rosterEntry",
|
|
696
|
+
"data": {
|
|
682
697
|
"name": "UP3985",
|
|
683
698
|
"address": "3985",
|
|
684
699
|
"isLongAddress": true,
|
|
685
700
|
"road": "Union Pacific",
|
|
686
701
|
"number": "3985",
|
|
687
702
|
"mfg": "Rivarossi",
|
|
703
|
+
"decoderModel": "Sound decoder",
|
|
704
|
+
"decoderFamily": "ESU LokSound",
|
|
688
705
|
"model": "Challenger 4-6-6-4",
|
|
689
706
|
"comment": "Steam locomotive",
|
|
690
|
-
"
|
|
707
|
+
"maxSpeedPct": 100,
|
|
708
|
+
"image": null,
|
|
709
|
+
"icon": "/roster/UP3985/icon",
|
|
710
|
+
"shuntingFunction": "",
|
|
711
|
+
"owner": "",
|
|
712
|
+
"dateModified": "2026-02-10T00:00:00.000+00:00",
|
|
691
713
|
"functionKeys": [
|
|
692
714
|
{ "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
|
|
693
715
|
{ "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
|
|
694
716
|
{ "name": "F2", "label": "Whistle", "lockable": false, "icon": null, "selectedIcon": null },
|
|
695
717
|
{ "name": "F3", "label": "Steam", "lockable": true, "icon": null, "selectedIcon": null },
|
|
696
718
|
{ "name": "F4", "label": null, "lockable": false, "icon": null, "selectedIcon": null }
|
|
697
|
-
]
|
|
719
|
+
],
|
|
720
|
+
"attributes": [],
|
|
721
|
+
"rosterGroups": []
|
|
698
722
|
},
|
|
699
|
-
"
|
|
723
|
+
"id": 2
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
"type": "rosterEntry",
|
|
727
|
+
"data": {
|
|
700
728
|
"name": "BNSF5240",
|
|
701
729
|
"address": "5240",
|
|
702
730
|
"isLongAddress": true,
|
|
703
731
|
"road": "BNSF",
|
|
704
732
|
"number": "5240",
|
|
705
733
|
"mfg": "Kato",
|
|
734
|
+
"decoderModel": "DCC Sound",
|
|
735
|
+
"decoderFamily": "Kato",
|
|
706
736
|
"model": "SD40-2",
|
|
707
737
|
"comment": "Heritage II paint",
|
|
708
|
-
"
|
|
738
|
+
"maxSpeedPct": 100,
|
|
739
|
+
"image": null,
|
|
740
|
+
"icon": "/roster/BNSF5240/icon",
|
|
741
|
+
"shuntingFunction": "",
|
|
742
|
+
"owner": "",
|
|
743
|
+
"dateModified": "2026-02-10T00:00:00.000+00:00",
|
|
709
744
|
"functionKeys": [
|
|
710
745
|
{ "name": "F0", "label": "Headlight", "lockable": true, "icon": null, "selectedIcon": null },
|
|
711
746
|
{ "name": "F1", "label": "Bell", "lockable": true, "icon": null, "selectedIcon": null },
|
|
@@ -713,10 +748,13 @@ var mockData = {
|
|
|
713
748
|
{ "name": "F3", "label": "Dynamic Brake", "lockable": true, "icon": null, "selectedIcon": null },
|
|
714
749
|
{ "name": "F4", "label": null, "lockable": false, "icon": null, "selectedIcon": null },
|
|
715
750
|
{ "name": "F5", "label": "Mars Light", "lockable": true, "icon": null, "selectedIcon": null }
|
|
716
|
-
]
|
|
717
|
-
|
|
751
|
+
],
|
|
752
|
+
"attributes": [],
|
|
753
|
+
"rosterGroups": []
|
|
754
|
+
},
|
|
755
|
+
"id": 3
|
|
718
756
|
}
|
|
719
|
-
|
|
757
|
+
]
|
|
720
758
|
},
|
|
721
759
|
"throttle": {
|
|
722
760
|
"acquire": {
|
|
@@ -857,12 +895,16 @@ var MockResponseManager = class {
|
|
|
857
895
|
*/
|
|
858
896
|
getRosterResponse(message) {
|
|
859
897
|
if (message.type === "roster" && message.method === "list") {
|
|
860
|
-
return
|
|
898
|
+
return {
|
|
899
|
+
type: "roster",
|
|
900
|
+
method: "list",
|
|
901
|
+
data: JSON.parse(JSON.stringify(mockData.roster.list))
|
|
902
|
+
};
|
|
861
903
|
}
|
|
862
904
|
return {
|
|
863
905
|
type: "roster",
|
|
864
906
|
method: "list",
|
|
865
|
-
data:
|
|
907
|
+
data: []
|
|
866
908
|
};
|
|
867
909
|
}
|
|
868
910
|
/**
|
|
@@ -1411,9 +1453,9 @@ var RosterManager = class {
|
|
|
1411
1453
|
await this.getRoster();
|
|
1412
1454
|
}
|
|
1413
1455
|
const addressStr = address.toString();
|
|
1414
|
-
for (const
|
|
1415
|
-
if (
|
|
1416
|
-
return
|
|
1456
|
+
for (const wrapper of this.rosterCache.values()) {
|
|
1457
|
+
if (wrapper.data.address === addressStr) {
|
|
1458
|
+
return wrapper;
|
|
1417
1459
|
}
|
|
1418
1460
|
}
|
|
1419
1461
|
return void 0;
|
|
@@ -1427,9 +1469,10 @@ var RosterManager = class {
|
|
|
1427
1469
|
}
|
|
1428
1470
|
const lowerQuery = query.toLowerCase();
|
|
1429
1471
|
const results = [];
|
|
1430
|
-
for (const
|
|
1472
|
+
for (const wrapper of this.rosterCache.values()) {
|
|
1473
|
+
const entry = wrapper.data;
|
|
1431
1474
|
if (entry.name.toLowerCase().includes(lowerQuery) || entry.address.includes(query) || entry.road?.toLowerCase().includes(lowerQuery) || entry.number?.includes(query)) {
|
|
1432
|
-
results.push(
|
|
1475
|
+
results.push(wrapper);
|
|
1433
1476
|
}
|
|
1434
1477
|
}
|
|
1435
1478
|
return results;
|
|
@@ -1451,8 +1494,22 @@ var RosterManager = class {
|
|
|
1451
1494
|
*/
|
|
1452
1495
|
updateCache(rosterData) {
|
|
1453
1496
|
this.rosterCache.clear();
|
|
1454
|
-
|
|
1455
|
-
|
|
1497
|
+
if (Array.isArray(rosterData)) {
|
|
1498
|
+
for (const wrapper of rosterData) {
|
|
1499
|
+
if (wrapper.type === "rosterEntry" && wrapper.data) {
|
|
1500
|
+
this.rosterCache.set(wrapper.data.name, wrapper);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
} else {
|
|
1504
|
+
let id = 1;
|
|
1505
|
+
for (const [name, entry] of Object.entries(rosterData)) {
|
|
1506
|
+
const wrapper = {
|
|
1507
|
+
type: "rosterEntry",
|
|
1508
|
+
data: entry,
|
|
1509
|
+
id: id++
|
|
1510
|
+
};
|
|
1511
|
+
this.rosterCache.set(name, wrapper);
|
|
1512
|
+
}
|
|
1456
1513
|
}
|
|
1457
1514
|
}
|
|
1458
1515
|
};
|