import { ParseResult } from './grammar' ; import { monaco } from '../monaco' ; import { XJsonWorker } from './worker' ; import { ID } from './constants' ; export class WorkerProxyService { private worker : monaco . editor . MonacoWebWorker < XJsonWorker > | undefined ; public async getAnnos ( modelUri ) { if ( ! this . worker ) { throw new Error ( 'Worker Proxy Service has not been setup!' ) ; } await this . worker . withSyncedResources ( [ modelUri ] ) ; const proxy = await this . worker . getProxy ( ) ; return proxy . parse ( modelUri . toString ( ) ) ; } public setup ( ) { this . worker = monaco . editor . createWebWorker ( { label : ID , moduleId : '' } ) ; } public stop ( ) { if ( this . worker ) this . worker . dispose ( ) ; } }