* Convert a dotted CDDL name to PascalCase TypeScript name. * "browsingContext.Info" → "BrowsingContextInfo"
(name)
| 360 | * "browsingContext.Info" → "BrowsingContextInfo" |
| 361 | */ |
| 362 | function normalizeDottedName(name) { |
| 363 | return name |
| 364 | .split('.') |
| 365 | .map((part) => |
| 366 | // A schema name segment may itself be hyphenated (e.g. the CDDL prelude |
| 367 | // range aliases 'js-uint'/'js-int'), which isn't a valid TS identifier |
| 368 | // character — split on '-' too so each word gets its own PascalCase turn. |
| 369 | part |
| 370 | .split('-') |
| 371 | .map((word) => { |
| 372 | const titled = word.charAt(0).toUpperCase() + word.slice(1) |
| 373 | // Normalize acronym runs to match cddl2ts output: |
| 374 | // CSPParameters → CspParameters HTMLCollection → HtmlCollection |
| 375 | // Rule: 2+ uppercase letters followed by an uppercase+lowercase pair (or end |
| 376 | // of string) → keep only the first uppercase and lowercase the rest. |
| 377 | return titled.replace(/([A-Z]{2,})(?=[A-Z][a-z]|$)/g, (m) => m[0] + m.slice(1).toLowerCase()) |
| 378 | }) |
| 379 | .join(''), |
| 380 | ) |
| 381 | .join('') |
| 382 | } |
| 383 | |
| 384 | /** |
| 385 | * Walk the `CommandData` or `EventData` union type hierarchy and collect all |
no test coverage detected