11export type NuVoiceRecordType = 'v' | 'd' | 'm' | 'x' | 'X' | 'P' | 'H' | 'A' | 'n' | 'N' | 'S' | 'E' | 'G' | 'a' | 'C' | 'D' | 'U' | 'V' | 'p' | 'k' | 'q' ;
22
3+ export interface NuVoiceBinaryRecordBase {
4+ type : NuVoiceRecordType ;
5+ rawLine : string ;
6+ bodyBytes : Uint8Array ;
7+ checksum : number ;
8+ checksumValid : boolean ;
9+ }
10+
11+ export interface NuVoiceTextSegment {
12+ text : string ;
13+ hasNullTerminator : boolean ;
14+ suffixBytes : Uint8Array ;
15+ }
16+
317export interface NuVoiceHeaderRecord {
418 type : 'v' ;
519 rawLine : string ;
@@ -8,27 +22,13 @@ export interface NuVoiceHeaderRecord {
822 product ?: string ;
923}
1024
11- interface NuVoiceBinaryRecordBase {
12- type : 'd' | 'm' | 'x' | 'X' ;
13- rawLine : string ;
14- bodyBytes : Uint8Array ;
15- checksum : number ;
16- checksumValid : boolean ;
17- }
18-
1925export interface NuVoiceDictionaryRecord extends NuVoiceBinaryRecordBase {
2026 type : 'd' ;
2127 word : string ;
2228 pronunciation : string ;
2329 trailingBytes : Uint8Array ;
2430}
2531
26- export interface NuVoiceTextSegment {
27- text : string ;
28- hasNullTerminator : boolean ;
29- suffixBytes : Uint8Array ;
30- }
31-
3232export interface NuVoiceMemoryRecord extends NuVoiceBinaryRecordBase {
3333 type : 'm' ;
3434 addressHex : string ;
@@ -48,25 +48,76 @@ export interface NuVoicePointerRecord extends NuVoiceBinaryRecordBase {
4848 type : 'X' ;
4949}
5050
51+ // Additional record types found in fuller MTI files (based on NuVoice Maps analysis)
5152export interface NuVoicePageRecord extends NuVoiceBinaryRecordBase {
52- type : 'P' ;
53- pageId : string ;
53+ type : 'P' ; // Page definition
54+ pageId ? : string ;
5455 pageName ?: string ;
5556}
5657
57- export interface NuVoiceButtonRecord extends NuVoiceBinaryRecordBase {
58- type : 'C' ;
59- pageId : string ;
60- buttonId : string ;
61- label ?: string ;
62- action ?: string ;
58+ export interface NuVoiceHeaderRecord2 extends NuVoiceBinaryRecordBase {
59+ type : 'H' ; // Additional header information
60+ }
61+
62+ export interface NuVoiceActionRecord extends NuVoiceBinaryRecordBase {
63+ type : 'A' ; // Action/button definitions
64+ }
65+
66+ export interface NuVoiceNavigationRecord extends NuVoiceBinaryRecordBase {
67+ type : 'n' ; // Navigation elements
68+ }
69+
70+ export interface NuVoiceNodeRecord extends NuVoiceBinaryRecordBase {
71+ type : 'N' ; // Structural nodes
72+ }
73+
74+ export interface NuVoiceSymbolRecord extends NuVoiceBinaryRecordBase {
75+ type : 'S' ; // Symbol/string data
76+ }
77+
78+ export interface NuVoiceElementRecord extends NuVoiceBinaryRecordBase {
79+ type : 'E' ; // UI elements
6380}
6481
6582export interface NuVoiceGridRecord extends NuVoiceBinaryRecordBase {
66- type : 'G' ;
67- pageId : string ;
68- rows : number ;
69- columns : number ;
83+ type : 'G' ; // Grid layouts
84+ gridId ?: string ;
85+ rows ?: number ;
86+ columns ?: number ;
87+ }
88+
89+ export interface NuVoiceAudioRecord extends NuVoiceBinaryRecordBase {
90+ type : 'a' ; // Audio data
91+ }
92+
93+ export interface NuVoiceCellRecord extends NuVoiceBinaryRecordBase {
94+ type : 'C' ; // Cell definitions
95+ cellId ?: string ;
96+ content ?: string ;
97+ }
98+
99+ export interface NuVoiceDataRecord extends NuVoiceBinaryRecordBase {
100+ type : 'D' ; // Data records
101+ }
102+
103+ export interface NuVoiceUIRecord extends NuVoiceBinaryRecordBase {
104+ type : 'U' ; // User interface elements
105+ }
106+
107+ export interface NuVoiceVoiceRecord extends NuVoiceBinaryRecordBase {
108+ type : 'V' ; // Voice data
109+ }
110+
111+ export interface NuVoicePositionRecord extends NuVoiceBinaryRecordBase {
112+ type : 'p' ; // Position data
113+ }
114+
115+ export interface NuVoiceKeyRecord extends NuVoiceBinaryRecordBase {
116+ type : 'k' ; // Key definitions
117+ }
118+
119+ export interface NuVoiceQueryRecord extends NuVoiceBinaryRecordBase {
120+ type : 'q' ; // Query data
70121}
71122
72123export type NuVoiceRecord =
@@ -76,7 +127,7 @@ export type NuVoiceRecord =
76127 | NuVoiceLayoutRecord
77128 | NuVoicePointerRecord
78129 | NuVoicePageRecord
79- | NuVoiceButtonRecord
130+ | NuVoiceActionRecord
80131 | NuVoiceGridRecord
81132 | NuVoiceBinaryRecordBase ; // For unknown types
82133
@@ -88,7 +139,7 @@ export interface NuVoiceDocument {
88139
89140export interface NuVoiceTextEntry {
90141 source : string ;
91- table : 'dictionary' | 'memory' | 'layout' ;
142+ table : 'dictionary' | 'memory' | 'layout' | 'other' ;
92143 column : 'WORD' | 'PRONUNCIATION' | 'TEXT' ;
93144 id : string ;
94145}
@@ -141,7 +192,7 @@ function isPrintableAscii(bytes: Uint8Array): boolean {
141192 return bytes . every ( ( value ) => value >= 0x20 && value <= 0x7e ) ;
142193}
143194
144- function parseTextSegment ( payloadBytes : Uint8Array ) : NuVoiceTextSegment | null {
195+ export function parseTextSegment ( payloadBytes : Uint8Array ) : NuVoiceTextSegment | null {
145196 if ( payloadBytes . length === 0 ) {
146197 return null ;
147198 }
@@ -406,15 +457,16 @@ export function serializeNuVoiceDocument(document: NuVoiceDocument): string {
406457 case 'v' :
407458 return record . rawLine ;
408459 case 'd' :
409- return serializeDictionaryRecord ( record ) ;
460+ return serializeDictionaryRecord ( record as NuVoiceDictionaryRecord ) ;
410461 case 'm' :
411- return serializeMemoryRecord ( record ) ;
462+ return serializeMemoryRecord ( record as NuVoiceMemoryRecord ) ;
412463 case 'x' :
413- return serializeLayoutRecord ( record ) ;
464+ return serializeLayoutRecord ( record as NuVoiceLayoutRecord ) ;
414465 case 'X' :
415- return serializePointerRecord ( record ) ;
466+ return serializePointerRecord ( record as NuVoicePointerRecord ) ;
416467 default :
417- throw new Error ( 'Unsupported NuVoice record during serialization' ) ;
468+ // For unknown record types, return the raw line as-is
469+ return record . rawLine ;
418470 }
419471 } ) ;
420472
0 commit comments