@@ -26,6 +26,7 @@ import * as EngineConst from './engine_const.js';
2626import { KeyCode } from './event_util.js' ;
2727import * as FileUtil from './file_util.js' ;
2828import * as ProcessorFactory from './processor_factory.js' ;
29+ import { OptionsList , WorkerStructure } from './processor_factory.js' ;
2930import { SystemExternal } from './system_external.js' ;
3031import { Variables } from './variables.js' ;
3132import { standardLoader } from '../speech_rules/math_map.js' ;
@@ -412,21 +413,6 @@ export function toSpeechStructure(expr: string): string {
412413/**
413414 * Web worker related API methods.
414415 */
415- import { LOCALE } from '../l10n/locale.js' ;
416-
417- type OptionsList = { [ key : string ] : string } ;
418- type SpeechList = { [ id : string ] : { [ mod : string ] : string } } ;
419-
420- type WorkerStructure = {
421- speech ?: SpeechList ;
422- braille ?: SpeechList ;
423- mactions ?: SpeechList ;
424- options ?: OptionsList ;
425- translations ?: OptionsList ;
426- label ?: string ;
427- braillelabel ?: string ;
428- ssml ?: string ;
429- } ;
430416
431417/**
432418 * Compute speech structure for the expression.
@@ -537,13 +523,7 @@ async function assembleWorkerStructure(
537523 await setupEngine ( options ) ;
538524 Engine . getInstance ( ) . options . automark = true ;
539525 const json : WorkerStructure = { } ;
540- json . options = options ;
541- json . mactions = SpeechGeneratorUtil . connectMactionSelections ( mml , sxml ) ;
542- json . speech = SpeechGeneratorUtil . computeSpeechStructure ( sxml ) ;
543- const root = ( sxml . childNodes [ 0 ] as Element ) ?. getAttribute ( 'id' ) ;
544- json . label = json . speech [ root ] [ 'speech-none' ] ;
545- json . ssml = json . speech [ root ] [ 'speech-ssml' ] ;
546- json . translations = Object . assign ( { } , LOCALE . MESSAGES . navigate ) ;
526+ ProcessorFactory . assembleSpeechStructure ( json , mml , sxml , options ) ;
547527 if ( options . braille === 'none' ) {
548528 return json ;
549529 }
@@ -553,6 +533,7 @@ async function assembleWorkerStructure(
553533 domain : 'default' ,
554534 style : 'default'
555535 } ) ;
536+ const root = ( sxml . childNodes [ 0 ] as Element ) ?. getAttribute ( 'id' ) ;
556537 json . braille = SpeechGeneratorUtil . computeBrailleStructure ( sxml ) ;
557538 json . braillelabel = json . braille [ root ] [ 'braille-none' ] ;
558539 return json ;
0 commit comments