* Convert a dotted CDDL name to PascalCase TypeScript name. * "browsingContext.Info" → "BrowsingContextInfo"
(name)
| 541 | * "browsingContext.Info" → "BrowsingContextInfo" |
| 542 | */ |
| 543 | function normalizeDottedName(name) { |
| 544 | return name |
| 545 | .split('.') |
| 546 | .map((part) => { |
| 547 | const titled = part.charAt(0).toUpperCase() + part.slice(1) |
| 548 | // Normalize acronym runs to match cddl2ts output: |
| 549 | // CSPParameters → CspParameters HTMLCollection → HtmlCollection |
| 550 | // Rule: 2+ uppercase letters followed by an uppercase+lowercase pair (or end |
| 551 | // of string) → keep only the first uppercase and lowercase the rest. |
| 552 | return titled.replace(/([A-Z]{2,})(?=[A-Z][a-z]|$)/g, (m) => m[0] + m.slice(1).toLowerCase()) |
| 553 | }) |
| 554 | .join('') |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Walk the `CommandData` or `EventData` union type hierarchy and collect all |
no test coverage detected