@springfield/ham-radio-utils 4.10.1 → 4.11.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 +7 -88
- package/dist/db/bands.json +48 -0
- package/dist/memory/memory-map-ui.d.ts +32 -1
- package/dist/memory/memory-map-ui.d.ts.map +1 -1
- package/dist/memory/memory-map-ui.js +108 -0
- package/dist/memory/memory-map-ui.js.map +1 -1
- package/dist/schemas/radio-memory-map-schema.json +43 -1
- package/package.json +2 -2
- package/src/db/bands.json +48 -0
- package/src/memory/memory-map-ui.ts +167 -0
- package/src/schemas/radio-memory-map-schema.json +43 -1
package/README.md
CHANGED
|
@@ -1,92 +1,11 @@
|
|
|
1
|
-
# ham-radio-
|
|
1
|
+
# ham-radio-utils
|
|
2
2
|
|
|
3
|
+
Shared utilities for HamBench: memory-map codec, band plan, Callook license-class mapping, schema validation, and test helpers.
|
|
3
4
|
|
|
5
|
+
Docs: [HamBench developer docs](https://springfield-ham-radio.github.io/ham-radio-docs/developer/) · [License lookup](https://springfield-ham-radio.github.io/ham-radio-docs/developer/license-lookup.html)
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
-
|
|
11
|
-
## Add your files
|
|
12
|
-
|
|
13
|
-
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
-
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
cd existing_repo
|
|
18
|
-
git remote add origin https://gitlab.com/springfield-ham-radio/app/ham-radio-driver-utils.git
|
|
19
|
-
git branch -M main
|
|
20
|
-
git push -uf origin main
|
|
7
|
+
```bash
|
|
8
|
+
corepack enable
|
|
9
|
+
yarn install
|
|
10
|
+
yarn build
|
|
21
11
|
```
|
|
22
|
-
|
|
23
|
-
## Integrate with your tools
|
|
24
|
-
|
|
25
|
-
- [ ] [Set up project integrations](https://gitlab.com/springfield-ham-radio/app/ham-radio-driver-utils/-/settings/integrations)
|
|
26
|
-
|
|
27
|
-
## Collaborate with your team
|
|
28
|
-
|
|
29
|
-
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
-
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
-
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
34
|
-
|
|
35
|
-
## Test and Deploy
|
|
36
|
-
|
|
37
|
-
Use the built-in continuous integration in GitLab.
|
|
38
|
-
|
|
39
|
-
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
40
|
-
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
-
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
-
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
-
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
-
|
|
45
|
-
***
|
|
46
|
-
|
|
47
|
-
# Editing this README
|
|
48
|
-
|
|
49
|
-
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
-
|
|
51
|
-
## Suggestions for a good README
|
|
52
|
-
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
53
|
-
|
|
54
|
-
## Name
|
|
55
|
-
Choose a self-explaining name for your project.
|
|
56
|
-
|
|
57
|
-
## Description
|
|
58
|
-
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
59
|
-
|
|
60
|
-
## Badges
|
|
61
|
-
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
62
|
-
|
|
63
|
-
## Visuals
|
|
64
|
-
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
65
|
-
|
|
66
|
-
## Installation
|
|
67
|
-
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
68
|
-
|
|
69
|
-
## Usage
|
|
70
|
-
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
71
|
-
|
|
72
|
-
## Support
|
|
73
|
-
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
74
|
-
|
|
75
|
-
## Roadmap
|
|
76
|
-
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
77
|
-
|
|
78
|
-
## Contributing
|
|
79
|
-
State if you are open to contributions and what your requirements are for accepting them.
|
|
80
|
-
|
|
81
|
-
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
82
|
-
|
|
83
|
-
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
84
|
-
|
|
85
|
-
## Authors and acknowledgment
|
|
86
|
-
Show your appreciation to those who have contributed to the project.
|
|
87
|
-
|
|
88
|
-
## License
|
|
89
|
-
For open source projects, say how it is licensed.
|
|
90
|
-
|
|
91
|
-
## Project status
|
|
92
|
-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
package/dist/db/bands.json
CHANGED
|
@@ -306,5 +306,53 @@
|
|
|
306
306
|
"frequency": 162525000
|
|
307
307
|
}
|
|
308
308
|
]
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"id": "8edabffb-dbaf-4302-b7eb-c6d467bc67d8",
|
|
312
|
+
"name": "Weather Radio-8",
|
|
313
|
+
"wavelength": 1.85,
|
|
314
|
+
"lowerFrequency": 161650000,
|
|
315
|
+
"upperFrequency": 161650000,
|
|
316
|
+
"frequencyDisplayBaseMultiplier": 1000000,
|
|
317
|
+
"frequencyDisplayNumberDecimals": 3,
|
|
318
|
+
"privileges": ["9689b06f-dfb0-4ae6-8fdc-f9a4e6e1b88e"],
|
|
319
|
+
"channels": [
|
|
320
|
+
{
|
|
321
|
+
"name": "WX8",
|
|
322
|
+
"frequency": 161650000
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"id": "c0217f5d-54b8-42c3-b6ad-63d63972b19f",
|
|
328
|
+
"name": "Weather Radio-9",
|
|
329
|
+
"wavelength": 1.85,
|
|
330
|
+
"lowerFrequency": 161775000,
|
|
331
|
+
"upperFrequency": 161775000,
|
|
332
|
+
"frequencyDisplayBaseMultiplier": 1000000,
|
|
333
|
+
"frequencyDisplayNumberDecimals": 3,
|
|
334
|
+
"privileges": ["9689b06f-dfb0-4ae6-8fdc-f9a4e6e1b88e"],
|
|
335
|
+
"channels": [
|
|
336
|
+
{
|
|
337
|
+
"name": "WX9",
|
|
338
|
+
"frequency": 161775000
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
"id": "8e2ccfe6-5be5-43c2-bbec-f80be8939464",
|
|
344
|
+
"name": "Weather Radio-10",
|
|
345
|
+
"wavelength": 1.85,
|
|
346
|
+
"lowerFrequency": 163275000,
|
|
347
|
+
"upperFrequency": 163275000,
|
|
348
|
+
"frequencyDisplayBaseMultiplier": 1000000,
|
|
349
|
+
"frequencyDisplayNumberDecimals": 3,
|
|
350
|
+
"privileges": ["9689b06f-dfb0-4ae6-8fdc-f9a4e6e1b88e"],
|
|
351
|
+
"channels": [
|
|
352
|
+
{
|
|
353
|
+
"name": "WX10",
|
|
354
|
+
"frequency": 163275000
|
|
355
|
+
}
|
|
356
|
+
]
|
|
309
357
|
}
|
|
310
358
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RadioMemoryMap, RadioMemoryMapFieldUi, RadioMemoryMapValueKind, RadioSettingValue } from '@springfield/ham-radio-api';
|
|
1
|
+
import type { RadioMemoryMap, RadioMemoryMapFieldUi, RadioMemoryMapGroupWarning, RadioMemoryMapValueKind, RadioSettingValue } from '@springfield/ham-radio-api';
|
|
2
2
|
/**
|
|
3
3
|
* Flattened field descriptor for schema-driven settings UI.
|
|
4
4
|
*/
|
|
@@ -29,4 +29,35 @@ export declare function formatMemoryMapFieldValue(value: RadioSettingValue | und
|
|
|
29
29
|
* Group UI fields by their ui.group key, preserving first-seen group order.
|
|
30
30
|
*/
|
|
31
31
|
export declare function groupMemoryMapUiFields(fields: RadioMemoryMapUiField[]): Map<string, RadioMemoryMapUiField[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Flattened settings group for schema-driven forms (left navigation).
|
|
34
|
+
*/
|
|
35
|
+
export interface RadioMemoryMapUiGroup {
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
icon?: string;
|
|
40
|
+
warning?: RadioMemoryMapGroupWarning;
|
|
41
|
+
fields: RadioMemoryMapUiField[];
|
|
42
|
+
/** Panel sections. Empty when the group has no sub-groups in use. */
|
|
43
|
+
groups: RadioMemoryMapUiSubgroup[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Flattened panel section inside a settings group.
|
|
47
|
+
*/
|
|
48
|
+
export interface RadioMemoryMapUiSubgroup {
|
|
49
|
+
id: string;
|
|
50
|
+
label: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
fields: RadioMemoryMapUiField[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Collect radio-wide UI fields grouped for display.
|
|
56
|
+
* Declared `memoryMap.groups` set label, icon, warning, and order for the left nav.
|
|
57
|
+
* Nested `groups` plus field `ui.subgroup` become panel sections.
|
|
58
|
+
* `ui.order` sorts fields within a group or section; EEPROM layout stays declaration order.
|
|
59
|
+
* Groups with no fields are omitted. Fields whose `ui.group` is not declared
|
|
60
|
+
* still appear, in first-seen order, after declared groups.
|
|
61
|
+
*/
|
|
62
|
+
export declare function collectMemoryMapUiGroups(memoryMap: RadioMemoryMap): RadioMemoryMapUiGroup[];
|
|
32
63
|
//# sourceMappingURL=memory-map-ui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-map-ui.d.ts","sourceRoot":"","sources":["../../src/memory/memory-map-ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,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;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,qBAAqB,EAAE,CAAC;CACjC;AA4GD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,cAAc,GAAG,qBAAqB,EAAE,CAyB3F"}
|
|
@@ -141,4 +141,112 @@ export function groupMemoryMapUiFields(fields) {
|
|
|
141
141
|
}
|
|
142
142
|
return groups;
|
|
143
143
|
}
|
|
144
|
+
function fallbackGroupLabel(id) {
|
|
145
|
+
return id
|
|
146
|
+
.split(/[-_\s]+/)
|
|
147
|
+
.filter((part) => part.length > 0)
|
|
148
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
149
|
+
.join(' ');
|
|
150
|
+
}
|
|
151
|
+
function fieldUiOrder(field) {
|
|
152
|
+
const extra = field.ui;
|
|
153
|
+
return typeof extra.order === 'number' && Number.isFinite(extra.order) ? extra.order : undefined;
|
|
154
|
+
}
|
|
155
|
+
function sortUiFields(fields) {
|
|
156
|
+
return fields
|
|
157
|
+
.map((field, index) => ({ field, index }))
|
|
158
|
+
.sort((left, right) => {
|
|
159
|
+
const leftOrder = fieldUiOrder(left.field) ?? Number.POSITIVE_INFINITY;
|
|
160
|
+
const rightOrder = fieldUiOrder(right.field) ?? Number.POSITIVE_INFINITY;
|
|
161
|
+
if (leftOrder !== rightOrder) {
|
|
162
|
+
return leftOrder - rightOrder;
|
|
163
|
+
}
|
|
164
|
+
return left.index - right.index;
|
|
165
|
+
})
|
|
166
|
+
.map((entry) => entry.field);
|
|
167
|
+
}
|
|
168
|
+
function collectUiSubgroups(declared, fields) {
|
|
169
|
+
const grouped = new Map();
|
|
170
|
+
for (const field of fields) {
|
|
171
|
+
const subgroupId = field.ui.subgroup;
|
|
172
|
+
if (!subgroupId) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
const existing = grouped.get(subgroupId);
|
|
176
|
+
if (existing) {
|
|
177
|
+
existing.push(field);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
grouped.set(subgroupId, [field]);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (grouped.size === 0) {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
const result = [];
|
|
187
|
+
const seen = new Set();
|
|
188
|
+
for (const subgroup of declared?.groups ?? []) {
|
|
189
|
+
const subgroupFields = grouped.get(subgroup.id);
|
|
190
|
+
if (!subgroupFields || subgroupFields.length === 0) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
seen.add(subgroup.id);
|
|
194
|
+
result.push({
|
|
195
|
+
id: subgroup.id,
|
|
196
|
+
label: subgroup.label,
|
|
197
|
+
description: subgroup.description,
|
|
198
|
+
fields: sortUiFields(subgroupFields),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
for (const [id, subgroupFields] of grouped) {
|
|
202
|
+
if (seen.has(id)) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
result.push({
|
|
206
|
+
id,
|
|
207
|
+
label: fallbackGroupLabel(id),
|
|
208
|
+
fields: sortUiFields(subgroupFields),
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
function toUiGroup(id, label, fields, declared) {
|
|
214
|
+
return {
|
|
215
|
+
id,
|
|
216
|
+
label,
|
|
217
|
+
description: declared?.description,
|
|
218
|
+
icon: declared?.icon,
|
|
219
|
+
warning: declared?.warning,
|
|
220
|
+
fields: sortUiFields(fields),
|
|
221
|
+
groups: collectUiSubgroups(declared, fields),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Collect radio-wide UI fields grouped for display.
|
|
226
|
+
* Declared `memoryMap.groups` set label, icon, warning, and order for the left nav.
|
|
227
|
+
* Nested `groups` plus field `ui.subgroup` become panel sections.
|
|
228
|
+
* `ui.order` sorts fields within a group or section; EEPROM layout stays declaration order.
|
|
229
|
+
* Groups with no fields are omitted. Fields whose `ui.group` is not declared
|
|
230
|
+
* still appear, in first-seen order, after declared groups.
|
|
231
|
+
*/
|
|
232
|
+
export function collectMemoryMapUiGroups(memoryMap) {
|
|
233
|
+
const grouped = groupMemoryMapUiFields(collectMemoryMapUiFields(memoryMap));
|
|
234
|
+
const result = [];
|
|
235
|
+
const seen = new Set();
|
|
236
|
+
for (const group of memoryMap.groups ?? []) {
|
|
237
|
+
const fields = grouped.get(group.id);
|
|
238
|
+
if (!fields || fields.length === 0) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
seen.add(group.id);
|
|
242
|
+
result.push(toUiGroup(group.id, group.label, fields, group));
|
|
243
|
+
}
|
|
244
|
+
for (const [id, fields] of grouped) {
|
|
245
|
+
if (seen.has(id)) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
result.push(toUiGroup(id, fallbackGroupLabel(id), fields));
|
|
249
|
+
}
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
144
252
|
//# sourceMappingURL=memory-map-ui.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-map-ui.js","sourceRoot":"","sources":["../../src/memory/memory-map-ui.ts"],"names":[],"mappings":"AAoBA,SAAS,oBAAoB,CAAC,SAAyB;IACrD,MAAM,QAAQ,GAAG,SAAS,CAAC,eAAe,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,MAAM,GAAG,IAAI;QAChB,QAAQ,CAAC,gBAAgB;QACzB,QAAQ,CAAC,iBAAiB;QAC1B,QAAQ,CAAC,WAAW;QACpB,QAAQ,CAAC,YAAY;QACrB,QAAQ,CAAC,SAAS;KACnB,EAAE,CAAC;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AAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n RadioMemoryMap,\n RadioMemoryMapFieldUi,\n RadioMemoryMapValueKind,\n RadioSettingValue,\n} from '@springfield/ham-radio-api';\n\n/**\n * Flattened field descriptor for schema-driven settings UI.\n */\nexport interface RadioMemoryMapUiField {\n /** Dot path into decoded settings, e.g. settings.squelch or pttid.0.code */\n path: string;\n structId: string;\n fieldId: string;\n arrayIndex?: number;\n ui: RadioMemoryMapFieldUi;\n value?: RadioMemoryMapValueKind;\n}\n\nfunction channelBoundFieldIds(memoryMap: RadioMemoryMap): Set<string> {\n const bindings = memoryMap.channelBindings;\n const ids = new Set<string>();\n\n if (!bindings) {\n return ids;\n }\n\n for (const key of [\n bindings.receiveFrequency,\n bindings.transmitFrequency,\n bindings.receiveTone,\n bindings.transmitTone,\n bindings.nameField,\n ]) {\n if (key) {\n ids.add(key);\n }\n }\n\n return ids;\n}\n\n/**\n * Collect writable UI fields from a memory map, in declaration order.\n * Channel-bound structs are skipped (use {@link collectChannelMemoryMapUiFields}).\n */\nexport function collectMemoryMapUiFields(memoryMap: RadioMemoryMap): RadioMemoryMapUiField[] {\n const fields: RadioMemoryMapUiField[] = [];\n const channelStructIds = new Set<string>();\n\n if (memoryMap.channelBindings) {\n channelStructIds.add(memoryMap.channelBindings.records);\n\n if (memoryMap.channelBindings.names) {\n channelStructIds.add(memoryMap.channelBindings.names);\n }\n\n if (memoryMap.channelBindings.extras) {\n channelStructIds.add(memoryMap.channelBindings.extras);\n }\n }\n\n for (const struct of memoryMap.structs) {\n if (channelStructIds.has(struct.id)) {\n continue;\n }\n\n const count = struct.count ?? 1;\n\n for (let index = 0; index < count; index += 1) {\n for (const field of struct.fields) {\n if (field.reserved || !field.ui) {\n continue;\n }\n\n const path =\n count > 1 ? `${struct.id}.${index}.${field.id}` : `${struct.id}.${field.id}`;\n\n const label =\n count > 1 && field.ui.label.indexOf('%') === -1\n ? `${field.ui.label} ${index + 1}`\n : field.ui.label;\n\n fields.push({\n path,\n structId: struct.id,\n fieldId: field.id,\n arrayIndex: count > 1 ? index : undefined,\n ui: { ...field.ui, label },\n value: field.value,\n });\n }\n }\n }\n\n return fields;\n}\n\n/**\n * Collect per-channel UI fields from the `channelBindings.records` struct.\n * Skips reserved fields, fields without `ui`, and fields bound onto RadioChannel.\n */\nexport function collectChannelMemoryMapUiFields(memoryMap: RadioMemoryMap): RadioMemoryMapUiField[] {\n const bindings = memoryMap.channelBindings;\n\n if (!bindings) {\n return [];\n }\n\n const struct = memoryMap.structs.find((entry) => entry.id === bindings.records);\n const extrasStruct = bindings.extras ? memoryMap.structs.find((entry) => entry.id === bindings.extras) : undefined;\n\n if (!struct) {\n return [];\n }\n\n const boundIds = channelBoundFieldIds(memoryMap);\n const fields: RadioMemoryMapUiField[] = [];\n\n for (const source of [struct, extrasStruct]) {\n if (!source) {\n continue;\n }\n\n for (const field of source.fields) {\n if (field.reserved || !field.ui || boundIds.has(field.id)) {\n continue;\n }\n\n fields.push({\n path: field.id,\n structId: source.id,\n fieldId: field.id,\n ui: field.ui,\n value: field.value,\n });\n }\n }\n\n return fields;\n}\n\n/**\n * Format a decoded memory-map field value for read-only display (e.g. channel table).\n */\nexport function formatMemoryMapFieldValue(\n value: RadioSettingValue | undefined,\n field: Pick<RadioMemoryMapUiField, 'value' | 'fieldId'>,\n): string {\n if (value === undefined || value === null) {\n return '';\n }\n\n if (field.value?.kind === 'enum' && typeof value === 'string') {\n return value;\n }\n\n if (field.value?.kind === 'boolean' || typeof value === 'boolean') {\n if (field.fieldId === 'wide') {\n return value ? 'Wide' : 'Narrow';\n }\n\n if (field.fieldId === 'scan') {\n return value ? 'On' : 'Off';\n }\n\n return value ? 'On' : 'Off';\n }\n\n if (field.fieldId === 'lowpower' && typeof value === 'number') {\n return value === 0 ? 'High' : 'Low';\n }\n\n if (field.fieldId === 'scode' && typeof value === 'number') {\n return String(value + 1);\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n\n return '';\n}\n\n/**\n * Group UI fields by their ui.group key, preserving first-seen group order.\n */\nexport function groupMemoryMapUiFields(fields: RadioMemoryMapUiField[]): Map<string, RadioMemoryMapUiField[]> {\n const groups = new Map<string, RadioMemoryMapUiField[]>();\n\n for (const field of fields) {\n const existing = groups.get(field.ui.group);\n\n if (existing) {\n existing.push(field);\n } else {\n groups.set(field.ui.group, [field]);\n }\n }\n\n return groups;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"memory-map-ui.js","sourceRoot":"","sources":["../../src/memory/memory-map-ui.ts"],"names":[],"mappings":"AAsBA,SAAS,oBAAoB,CAAC,SAAyB;IACrD,MAAM,QAAQ,GAAG,SAAS,CAAC,eAAe,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,MAAM,GAAG,IAAI;QAChB,QAAQ,CAAC,gBAAgB;QACzB,QAAQ,CAAC,iBAAiB;QAC1B,QAAQ,CAAC,WAAW;QACpB,QAAQ,CAAC,YAAY;QACrB,QAAQ,CAAC,SAAS;KACnB,EAAE,CAAC;QACF,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,SAAyB;IAChE,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE3C,IAAI,SAAS,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K,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACjB,SAAS;QACX,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n RadioMemoryMap,\n RadioMemoryMapFieldUi,\n RadioMemoryMapGroup,\n RadioMemoryMapGroupWarning,\n RadioMemoryMapValueKind,\n RadioSettingValue,\n} from '@springfield/ham-radio-api';\n\n/**\n * Flattened field descriptor for schema-driven settings UI.\n */\nexport interface RadioMemoryMapUiField {\n /** Dot path into decoded settings, e.g. settings.squelch or pttid.0.code */\n path: string;\n structId: string;\n fieldId: string;\n arrayIndex?: number;\n ui: RadioMemoryMapFieldUi;\n value?: RadioMemoryMapValueKind;\n}\n\nfunction channelBoundFieldIds(memoryMap: RadioMemoryMap): Set<string> {\n const bindings = memoryMap.channelBindings;\n const ids = new Set<string>();\n\n if (!bindings) {\n return ids;\n }\n\n for (const key of [\n bindings.receiveFrequency,\n bindings.transmitFrequency,\n bindings.receiveTone,\n bindings.transmitTone,\n bindings.nameField,\n ]) {\n if (key) {\n ids.add(key);\n }\n }\n\n return ids;\n}\n\n/**\n * Collect writable UI fields from a memory map, in declaration order.\n * Channel-bound structs are skipped (use {@link collectChannelMemoryMapUiFields}).\n */\nexport function collectMemoryMapUiFields(memoryMap: RadioMemoryMap): RadioMemoryMapUiField[] {\n const fields: RadioMemoryMapUiField[] = [];\n const channelStructIds = new Set<string>();\n\n if (memoryMap.channelBindings) {\n channelStructIds.add(memoryMap.channelBindings.records);\n\n if (memoryMap.channelBindings.names) {\n channelStructIds.add(memoryMap.channelBindings.names);\n }\n\n if (memoryMap.channelBindings.extras) {\n channelStructIds.add(memoryMap.channelBindings.extras);\n }\n }\n\n for (const struct of memoryMap.structs) {\n if (channelStructIds.has(struct.id)) {\n continue;\n }\n\n const count = struct.count ?? 1;\n\n for (let index = 0; index < count; index += 1) {\n for (const field of struct.fields) {\n if (field.reserved || !field.ui) {\n continue;\n }\n\n const path =\n count > 1 ? `${struct.id}.${index}.${field.id}` : `${struct.id}.${field.id}`;\n\n const label =\n count > 1 && field.ui.label.indexOf('%') === -1\n ? `${field.ui.label} ${index + 1}`\n : field.ui.label;\n\n fields.push({\n path,\n structId: struct.id,\n fieldId: field.id,\n arrayIndex: count > 1 ? index : undefined,\n ui: { ...field.ui, label },\n value: field.value,\n });\n }\n }\n }\n\n return fields;\n}\n\n/**\n * Collect per-channel UI fields from the `channelBindings.records` struct.\n * Skips reserved fields, fields without `ui`, and fields bound onto RadioChannel.\n */\nexport function collectChannelMemoryMapUiFields(memoryMap: RadioMemoryMap): RadioMemoryMapUiField[] {\n const bindings = memoryMap.channelBindings;\n\n if (!bindings) {\n return [];\n }\n\n const struct = memoryMap.structs.find((entry) => entry.id === bindings.records);\n const extrasStruct = bindings.extras ? memoryMap.structs.find((entry) => entry.id === bindings.extras) : undefined;\n\n if (!struct) {\n return [];\n }\n\n const boundIds = channelBoundFieldIds(memoryMap);\n const fields: RadioMemoryMapUiField[] = [];\n\n for (const source of [struct, extrasStruct]) {\n if (!source) {\n continue;\n }\n\n for (const field of source.fields) {\n if (field.reserved || !field.ui || boundIds.has(field.id)) {\n continue;\n }\n\n fields.push({\n path: field.id,\n structId: source.id,\n fieldId: field.id,\n ui: field.ui,\n value: field.value,\n });\n }\n }\n\n return fields;\n}\n\n/**\n * Format a decoded memory-map field value for read-only display (e.g. channel table).\n */\nexport function formatMemoryMapFieldValue(\n value: RadioSettingValue | undefined,\n field: Pick<RadioMemoryMapUiField, 'value' | 'fieldId'>,\n): string {\n if (value === undefined || value === null) {\n return '';\n }\n\n if (field.value?.kind === 'enum' && typeof value === 'string') {\n return value;\n }\n\n if (field.value?.kind === 'boolean' || typeof value === 'boolean') {\n if (field.fieldId === 'wide') {\n return value ? 'Wide' : 'Narrow';\n }\n\n if (field.fieldId === 'scan') {\n return value ? 'On' : 'Off';\n }\n\n return value ? 'On' : 'Off';\n }\n\n if (field.fieldId === 'lowpower' && typeof value === 'number') {\n return value === 0 ? 'High' : 'Low';\n }\n\n if (field.fieldId === 'scode' && typeof value === 'number') {\n return String(value + 1);\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n\n return '';\n}\n\n/**\n * Group UI fields by their ui.group key, preserving first-seen group order.\n */\nexport function groupMemoryMapUiFields(fields: RadioMemoryMapUiField[]): Map<string, RadioMemoryMapUiField[]> {\n const groups = new Map<string, RadioMemoryMapUiField[]>();\n\n for (const field of fields) {\n const existing = groups.get(field.ui.group);\n\n if (existing) {\n existing.push(field);\n } else {\n groups.set(field.ui.group, [field]);\n }\n }\n\n return groups;\n}\n\n/**\n * Flattened settings group for schema-driven forms (left navigation).\n */\nexport interface RadioMemoryMapUiGroup {\n id: string;\n label: string;\n description?: string;\n icon?: string;\n warning?: RadioMemoryMapGroupWarning;\n fields: RadioMemoryMapUiField[];\n /** Panel sections. Empty when the group has no sub-groups in use. */\n groups: RadioMemoryMapUiSubgroup[];\n}\n\n/**\n * Flattened panel section inside a settings group.\n */\nexport interface RadioMemoryMapUiSubgroup {\n id: string;\n label: string;\n description?: string;\n fields: RadioMemoryMapUiField[];\n}\n\nfunction fallbackGroupLabel(id: string): string {\n return id\n .split(/[-_\\s]+/)\n .filter((part) => part.length > 0)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(' ');\n}\n\nfunction fieldUiOrder(field: RadioMemoryMapUiField): number | undefined {\n const extra = field.ui as RadioMemoryMapUiField['ui'] & { order?: number };\n return typeof extra.order === 'number' && Number.isFinite(extra.order) ? extra.order : undefined;\n}\n\nfunction sortUiFields(fields: RadioMemoryMapUiField[]): RadioMemoryMapUiField[] {\n return fields\n .map((field, index) => ({ field, index }))\n .sort((left, right) => {\n const leftOrder = fieldUiOrder(left.field) ?? Number.POSITIVE_INFINITY;\n const rightOrder = fieldUiOrder(right.field) ?? Number.POSITIVE_INFINITY;\n\n if (leftOrder !== rightOrder) {\n return leftOrder - rightOrder;\n }\n\n return left.index - right.index;\n })\n .map((entry) => entry.field);\n}\n\nfunction collectUiSubgroups(\n declared: RadioMemoryMapGroup | undefined,\n fields: RadioMemoryMapUiField[],\n): RadioMemoryMapUiSubgroup[] {\n const grouped = new Map<string, RadioMemoryMapUiField[]>();\n\n for (const field of fields) {\n const subgroupId = field.ui.subgroup;\n\n if (!subgroupId) {\n continue;\n }\n\n const existing = grouped.get(subgroupId);\n\n if (existing) {\n existing.push(field);\n } else {\n grouped.set(subgroupId, [field]);\n }\n }\n\n if (grouped.size === 0) {\n return [];\n }\n\n const result: RadioMemoryMapUiSubgroup[] = [];\n const seen = new Set<string>();\n\n for (const subgroup of declared?.groups ?? []) {\n const subgroupFields = grouped.get(subgroup.id);\n\n if (!subgroupFields || subgroupFields.length === 0) {\n continue;\n }\n\n seen.add(subgroup.id);\n result.push({\n id: subgroup.id,\n label: subgroup.label,\n description: subgroup.description,\n fields: sortUiFields(subgroupFields),\n });\n }\n\n for (const [id, subgroupFields] of grouped) {\n if (seen.has(id)) {\n continue;\n }\n\n result.push({\n id,\n label: fallbackGroupLabel(id),\n fields: sortUiFields(subgroupFields),\n });\n }\n\n return result;\n}\n\nfunction toUiGroup(\n id: string,\n label: string,\n fields: RadioMemoryMapUiField[],\n declared?: RadioMemoryMapGroup,\n): RadioMemoryMapUiGroup {\n return {\n id,\n label,\n description: declared?.description,\n icon: declared?.icon,\n warning: declared?.warning,\n fields: sortUiFields(fields),\n groups: collectUiSubgroups(declared, fields),\n };\n}\n\n/**\n * Collect radio-wide UI fields grouped for display.\n * Declared `memoryMap.groups` set label, icon, warning, and order for the left nav.\n * Nested `groups` plus field `ui.subgroup` become panel sections.\n * `ui.order` sorts fields within a group or section; EEPROM layout stays declaration order.\n * Groups with no fields are omitted. Fields whose `ui.group` is not declared\n * still appear, in first-seen order, after declared groups.\n */\nexport function collectMemoryMapUiGroups(memoryMap: RadioMemoryMap): RadioMemoryMapUiGroup[] {\n const grouped = groupMemoryMapUiFields(collectMemoryMapUiFields(memoryMap));\n const result: RadioMemoryMapUiGroup[] = [];\n const seen = new Set<string>();\n\n for (const group of memoryMap.groups ?? []) {\n const fields = grouped.get(group.id);\n\n if (!fields || fields.length === 0) {\n continue;\n }\n\n seen.add(group.id);\n result.push(toUiGroup(group.id, group.label, fields, group));\n }\n\n for (const [id, fields] of grouped) {\n if (seen.has(id)) {\n continue;\n }\n\n result.push(toUiGroup(id, fallbackGroupLabel(id), fields));\n }\n\n return result;\n}\n"]}
|
|
@@ -21,6 +21,12 @@
|
|
|
21
21
|
},
|
|
22
22
|
"channelBindings": {
|
|
23
23
|
"$ref": "#/definitions/channelBindings"
|
|
24
|
+
},
|
|
25
|
+
"groups": {
|
|
26
|
+
"type": "array",
|
|
27
|
+
"items": {
|
|
28
|
+
"$ref": "#/definitions/group"
|
|
29
|
+
}
|
|
24
30
|
}
|
|
25
31
|
},
|
|
26
32
|
"definitions": {
|
|
@@ -53,18 +59,54 @@
|
|
|
53
59
|
},
|
|
54
60
|
"additionalProperties": false
|
|
55
61
|
},
|
|
62
|
+
"group": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"required": ["id", "label"],
|
|
65
|
+
"properties": {
|
|
66
|
+
"id": { "type": "string", "minLength": 1 },
|
|
67
|
+
"label": { "type": "string", "minLength": 1 },
|
|
68
|
+
"description": { "type": "string" },
|
|
69
|
+
"icon": { "type": "string", "minLength": 1 },
|
|
70
|
+
"warning": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"required": ["title", "description"],
|
|
73
|
+
"properties": {
|
|
74
|
+
"title": { "type": "string", "minLength": 1 },
|
|
75
|
+
"description": { "type": "string", "minLength": 1 }
|
|
76
|
+
},
|
|
77
|
+
"additionalProperties": false
|
|
78
|
+
},
|
|
79
|
+
"groups": {
|
|
80
|
+
"type": "array",
|
|
81
|
+
"items": { "$ref": "#/definitions/subgroup" }
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"additionalProperties": false
|
|
85
|
+
},
|
|
86
|
+
"subgroup": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"required": ["id", "label"],
|
|
89
|
+
"properties": {
|
|
90
|
+
"id": { "type": "string", "minLength": 1 },
|
|
91
|
+
"label": { "type": "string", "minLength": 1 },
|
|
92
|
+
"description": { "type": "string" }
|
|
93
|
+
},
|
|
94
|
+
"additionalProperties": false
|
|
95
|
+
},
|
|
56
96
|
"ui": {
|
|
57
97
|
"type": "object",
|
|
58
98
|
"required": ["group", "label", "widget"],
|
|
59
99
|
"properties": {
|
|
60
100
|
"group": { "type": "string" },
|
|
101
|
+
"subgroup": { "type": "string", "minLength": 1 },
|
|
61
102
|
"label": { "type": "string" },
|
|
62
103
|
"widget": {
|
|
63
104
|
"type": "string",
|
|
64
105
|
"enum": ["integer", "select", "switch", "text", "number"]
|
|
65
106
|
},
|
|
66
107
|
"description": { "type": "string" },
|
|
67
|
-
"writable": { "type": "boolean" }
|
|
108
|
+
"writable": { "type": "boolean" },
|
|
109
|
+
"order": { "type": "integer" }
|
|
68
110
|
},
|
|
69
111
|
"additionalProperties": false
|
|
70
112
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@springfield/ham-radio-utils",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
4
4
|
"author": "Bryan Hunt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"readme": "README.md",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test:unit": "tsx --test test/unit/**/*.test.ts"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@springfield/ham-radio-api": "^17.
|
|
33
|
+
"@springfield/ham-radio-api": "^17.8.0",
|
|
34
34
|
"ajv": "^8.20.0",
|
|
35
35
|
"ajv-formats": "^3.0.1",
|
|
36
36
|
"fishery": "^2.4.0",
|
package/src/db/bands.json
CHANGED
|
@@ -306,5 +306,53 @@
|
|
|
306
306
|
"frequency": 162525000
|
|
307
307
|
}
|
|
308
308
|
]
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"id": "8edabffb-dbaf-4302-b7eb-c6d467bc67d8",
|
|
312
|
+
"name": "Weather Radio-8",
|
|
313
|
+
"wavelength": 1.85,
|
|
314
|
+
"lowerFrequency": 161650000,
|
|
315
|
+
"upperFrequency": 161650000,
|
|
316
|
+
"frequencyDisplayBaseMultiplier": 1000000,
|
|
317
|
+
"frequencyDisplayNumberDecimals": 3,
|
|
318
|
+
"privileges": ["9689b06f-dfb0-4ae6-8fdc-f9a4e6e1b88e"],
|
|
319
|
+
"channels": [
|
|
320
|
+
{
|
|
321
|
+
"name": "WX8",
|
|
322
|
+
"frequency": 161650000
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"id": "c0217f5d-54b8-42c3-b6ad-63d63972b19f",
|
|
328
|
+
"name": "Weather Radio-9",
|
|
329
|
+
"wavelength": 1.85,
|
|
330
|
+
"lowerFrequency": 161775000,
|
|
331
|
+
"upperFrequency": 161775000,
|
|
332
|
+
"frequencyDisplayBaseMultiplier": 1000000,
|
|
333
|
+
"frequencyDisplayNumberDecimals": 3,
|
|
334
|
+
"privileges": ["9689b06f-dfb0-4ae6-8fdc-f9a4e6e1b88e"],
|
|
335
|
+
"channels": [
|
|
336
|
+
{
|
|
337
|
+
"name": "WX9",
|
|
338
|
+
"frequency": 161775000
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
"id": "8e2ccfe6-5be5-43c2-bbec-f80be8939464",
|
|
344
|
+
"name": "Weather Radio-10",
|
|
345
|
+
"wavelength": 1.85,
|
|
346
|
+
"lowerFrequency": 163275000,
|
|
347
|
+
"upperFrequency": 163275000,
|
|
348
|
+
"frequencyDisplayBaseMultiplier": 1000000,
|
|
349
|
+
"frequencyDisplayNumberDecimals": 3,
|
|
350
|
+
"privileges": ["9689b06f-dfb0-4ae6-8fdc-f9a4e6e1b88e"],
|
|
351
|
+
"channels": [
|
|
352
|
+
{
|
|
353
|
+
"name": "WX10",
|
|
354
|
+
"frequency": 163275000
|
|
355
|
+
}
|
|
356
|
+
]
|
|
309
357
|
}
|
|
310
358
|
]
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
RadioMemoryMap,
|
|
3
3
|
RadioMemoryMapFieldUi,
|
|
4
|
+
RadioMemoryMapGroup,
|
|
5
|
+
RadioMemoryMapGroupWarning,
|
|
4
6
|
RadioMemoryMapValueKind,
|
|
5
7
|
RadioSettingValue,
|
|
6
8
|
} from '@springfield/ham-radio-api';
|
|
@@ -201,3 +203,168 @@ export function groupMemoryMapUiFields(fields: RadioMemoryMapUiField[]): Map<str
|
|
|
201
203
|
|
|
202
204
|
return groups;
|
|
203
205
|
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Flattened settings group for schema-driven forms (left navigation).
|
|
209
|
+
*/
|
|
210
|
+
export interface RadioMemoryMapUiGroup {
|
|
211
|
+
id: string;
|
|
212
|
+
label: string;
|
|
213
|
+
description?: string;
|
|
214
|
+
icon?: string;
|
|
215
|
+
warning?: RadioMemoryMapGroupWarning;
|
|
216
|
+
fields: RadioMemoryMapUiField[];
|
|
217
|
+
/** Panel sections. Empty when the group has no sub-groups in use. */
|
|
218
|
+
groups: RadioMemoryMapUiSubgroup[];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Flattened panel section inside a settings group.
|
|
223
|
+
*/
|
|
224
|
+
export interface RadioMemoryMapUiSubgroup {
|
|
225
|
+
id: string;
|
|
226
|
+
label: string;
|
|
227
|
+
description?: string;
|
|
228
|
+
fields: RadioMemoryMapUiField[];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function fallbackGroupLabel(id: string): string {
|
|
232
|
+
return id
|
|
233
|
+
.split(/[-_\s]+/)
|
|
234
|
+
.filter((part) => part.length > 0)
|
|
235
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
236
|
+
.join(' ');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function fieldUiOrder(field: RadioMemoryMapUiField): number | undefined {
|
|
240
|
+
const extra = field.ui as RadioMemoryMapUiField['ui'] & { order?: number };
|
|
241
|
+
return typeof extra.order === 'number' && Number.isFinite(extra.order) ? extra.order : undefined;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function sortUiFields(fields: RadioMemoryMapUiField[]): RadioMemoryMapUiField[] {
|
|
245
|
+
return fields
|
|
246
|
+
.map((field, index) => ({ field, index }))
|
|
247
|
+
.sort((left, right) => {
|
|
248
|
+
const leftOrder = fieldUiOrder(left.field) ?? Number.POSITIVE_INFINITY;
|
|
249
|
+
const rightOrder = fieldUiOrder(right.field) ?? Number.POSITIVE_INFINITY;
|
|
250
|
+
|
|
251
|
+
if (leftOrder !== rightOrder) {
|
|
252
|
+
return leftOrder - rightOrder;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return left.index - right.index;
|
|
256
|
+
})
|
|
257
|
+
.map((entry) => entry.field);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function collectUiSubgroups(
|
|
261
|
+
declared: RadioMemoryMapGroup | undefined,
|
|
262
|
+
fields: RadioMemoryMapUiField[],
|
|
263
|
+
): RadioMemoryMapUiSubgroup[] {
|
|
264
|
+
const grouped = new Map<string, RadioMemoryMapUiField[]>();
|
|
265
|
+
|
|
266
|
+
for (const field of fields) {
|
|
267
|
+
const subgroupId = field.ui.subgroup;
|
|
268
|
+
|
|
269
|
+
if (!subgroupId) {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const existing = grouped.get(subgroupId);
|
|
274
|
+
|
|
275
|
+
if (existing) {
|
|
276
|
+
existing.push(field);
|
|
277
|
+
} else {
|
|
278
|
+
grouped.set(subgroupId, [field]);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (grouped.size === 0) {
|
|
283
|
+
return [];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const result: RadioMemoryMapUiSubgroup[] = [];
|
|
287
|
+
const seen = new Set<string>();
|
|
288
|
+
|
|
289
|
+
for (const subgroup of declared?.groups ?? []) {
|
|
290
|
+
const subgroupFields = grouped.get(subgroup.id);
|
|
291
|
+
|
|
292
|
+
if (!subgroupFields || subgroupFields.length === 0) {
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
seen.add(subgroup.id);
|
|
297
|
+
result.push({
|
|
298
|
+
id: subgroup.id,
|
|
299
|
+
label: subgroup.label,
|
|
300
|
+
description: subgroup.description,
|
|
301
|
+
fields: sortUiFields(subgroupFields),
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
for (const [id, subgroupFields] of grouped) {
|
|
306
|
+
if (seen.has(id)) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
result.push({
|
|
311
|
+
id,
|
|
312
|
+
label: fallbackGroupLabel(id),
|
|
313
|
+
fields: sortUiFields(subgroupFields),
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return result;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function toUiGroup(
|
|
321
|
+
id: string,
|
|
322
|
+
label: string,
|
|
323
|
+
fields: RadioMemoryMapUiField[],
|
|
324
|
+
declared?: RadioMemoryMapGroup,
|
|
325
|
+
): RadioMemoryMapUiGroup {
|
|
326
|
+
return {
|
|
327
|
+
id,
|
|
328
|
+
label,
|
|
329
|
+
description: declared?.description,
|
|
330
|
+
icon: declared?.icon,
|
|
331
|
+
warning: declared?.warning,
|
|
332
|
+
fields: sortUiFields(fields),
|
|
333
|
+
groups: collectUiSubgroups(declared, fields),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Collect radio-wide UI fields grouped for display.
|
|
339
|
+
* Declared `memoryMap.groups` set label, icon, warning, and order for the left nav.
|
|
340
|
+
* Nested `groups` plus field `ui.subgroup` become panel sections.
|
|
341
|
+
* `ui.order` sorts fields within a group or section; EEPROM layout stays declaration order.
|
|
342
|
+
* Groups with no fields are omitted. Fields whose `ui.group` is not declared
|
|
343
|
+
* still appear, in first-seen order, after declared groups.
|
|
344
|
+
*/
|
|
345
|
+
export function collectMemoryMapUiGroups(memoryMap: RadioMemoryMap): RadioMemoryMapUiGroup[] {
|
|
346
|
+
const grouped = groupMemoryMapUiFields(collectMemoryMapUiFields(memoryMap));
|
|
347
|
+
const result: RadioMemoryMapUiGroup[] = [];
|
|
348
|
+
const seen = new Set<string>();
|
|
349
|
+
|
|
350
|
+
for (const group of memoryMap.groups ?? []) {
|
|
351
|
+
const fields = grouped.get(group.id);
|
|
352
|
+
|
|
353
|
+
if (!fields || fields.length === 0) {
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
seen.add(group.id);
|
|
358
|
+
result.push(toUiGroup(group.id, group.label, fields, group));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
for (const [id, fields] of grouped) {
|
|
362
|
+
if (seen.has(id)) {
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
result.push(toUiGroup(id, fallbackGroupLabel(id), fields));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return result;
|
|
370
|
+
}
|
|
@@ -21,6 +21,12 @@
|
|
|
21
21
|
},
|
|
22
22
|
"channelBindings": {
|
|
23
23
|
"$ref": "#/definitions/channelBindings"
|
|
24
|
+
},
|
|
25
|
+
"groups": {
|
|
26
|
+
"type": "array",
|
|
27
|
+
"items": {
|
|
28
|
+
"$ref": "#/definitions/group"
|
|
29
|
+
}
|
|
24
30
|
}
|
|
25
31
|
},
|
|
26
32
|
"definitions": {
|
|
@@ -53,18 +59,54 @@
|
|
|
53
59
|
},
|
|
54
60
|
"additionalProperties": false
|
|
55
61
|
},
|
|
62
|
+
"group": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"required": ["id", "label"],
|
|
65
|
+
"properties": {
|
|
66
|
+
"id": { "type": "string", "minLength": 1 },
|
|
67
|
+
"label": { "type": "string", "minLength": 1 },
|
|
68
|
+
"description": { "type": "string" },
|
|
69
|
+
"icon": { "type": "string", "minLength": 1 },
|
|
70
|
+
"warning": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"required": ["title", "description"],
|
|
73
|
+
"properties": {
|
|
74
|
+
"title": { "type": "string", "minLength": 1 },
|
|
75
|
+
"description": { "type": "string", "minLength": 1 }
|
|
76
|
+
},
|
|
77
|
+
"additionalProperties": false
|
|
78
|
+
},
|
|
79
|
+
"groups": {
|
|
80
|
+
"type": "array",
|
|
81
|
+
"items": { "$ref": "#/definitions/subgroup" }
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"additionalProperties": false
|
|
85
|
+
},
|
|
86
|
+
"subgroup": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"required": ["id", "label"],
|
|
89
|
+
"properties": {
|
|
90
|
+
"id": { "type": "string", "minLength": 1 },
|
|
91
|
+
"label": { "type": "string", "minLength": 1 },
|
|
92
|
+
"description": { "type": "string" }
|
|
93
|
+
},
|
|
94
|
+
"additionalProperties": false
|
|
95
|
+
},
|
|
56
96
|
"ui": {
|
|
57
97
|
"type": "object",
|
|
58
98
|
"required": ["group", "label", "widget"],
|
|
59
99
|
"properties": {
|
|
60
100
|
"group": { "type": "string" },
|
|
101
|
+
"subgroup": { "type": "string", "minLength": 1 },
|
|
61
102
|
"label": { "type": "string" },
|
|
62
103
|
"widget": {
|
|
63
104
|
"type": "string",
|
|
64
105
|
"enum": ["integer", "select", "switch", "text", "number"]
|
|
65
106
|
},
|
|
66
107
|
"description": { "type": "string" },
|
|
67
|
-
"writable": { "type": "boolean" }
|
|
108
|
+
"writable": { "type": "boolean" },
|
|
109
|
+
"order": { "type": "integer" }
|
|
68
110
|
},
|
|
69
111
|
"additionalProperties": false
|
|
70
112
|
},
|