33 * Copyright (c) Microsoft Corporation. All rights reserved.
44 * Licensed under the MIT License. See License.txt in the project root for license information.
55 *--------------------------------------------------------------------------------------------*/
6+ import * as l10n from '@vscode/l10n' ;
67import { Connection , RequestType } from 'vscode-languageserver' ;
7- import { createConnection , BrowserMessageReader , BrowserMessageWriter } from 'vscode-languageserver/browser' ;
8+ import { BrowserMessageReader , BrowserMessageWriter , createConnection } from 'vscode-languageserver/browser' ;
89import { TelemetryImpl } from '../languageserver/telemetry' ;
910import { schemaRequestHandler , workspaceContext } from '../languageservice/services/schemaRequestHandler' ;
1011import { YAMLServerInit } from '../yamlServerInit' ;
@@ -15,35 +16,38 @@ namespace FSReadFile {
1516 export const type : RequestType < string , string , unknown > = new RequestType ( 'fs/readFile' ) ;
1617}
1718
18- const messageReader = new BrowserMessageReader ( globalThis ) ;
19- const messageWriter = new BrowserMessageWriter ( globalThis ) ;
20-
21- const connection = createConnection ( messageReader , messageWriter ) ;
22-
23- const yamlSettings = new SettingsState ( ) ;
24-
25- const fileSystem = {
26- readFile : ( fsPath : string ) => {
27- return connection . sendRequest ( FSReadFile . type , fsPath ) ;
28- } ,
19+ self . onmessage = ( e ) => {
20+ const messageReader = new BrowserMessageReader ( globalThis ) ;
21+ const messageWriter = new BrowserMessageWriter ( globalThis ) ;
22+
23+ const connection = createConnection ( messageReader , messageWriter ) ;
24+
25+ const yamlSettings = new SettingsState ( ) ;
26+
27+ const fileSystem = {
28+ readFile : ( fsPath : string ) => {
29+ return connection . sendRequest ( FSReadFile . type , fsPath ) ;
30+ } ,
31+ } ;
32+
33+ /**
34+ * Handles schema content requests given the schema URI
35+ * @param uri can be a local file, vscode request, http(s) request or a custom request
36+ */
37+ const schemaRequestHandlerWrapper = ( connection : Connection , uri : string ) : Promise < string > => {
38+ return schemaRequestHandler (
39+ connection ,
40+ uri ,
41+ yamlSettings . workspaceFolders ,
42+ yamlSettings . workspaceRoot ,
43+ yamlSettings . useVSCodeContentRequest ,
44+ fileSystem
45+ ) ;
46+ } ;
47+
48+ const schemaRequestService = schemaRequestHandlerWrapper . bind ( this , connection ) ;
49+ const telemetry = new TelemetryImpl ( connection ) ;
50+
51+ l10n . config ( { contents : e . data . l10nBundle } ) ;
52+ new YAMLServerInit ( connection , yamlSettings , workspaceContext , schemaRequestService , telemetry ) . start ( ) ;
2953} ;
30-
31- /**
32- * Handles schema content requests given the schema URI
33- * @param uri can be a local file, vscode request, http(s) request or a custom request
34- */
35- const schemaRequestHandlerWrapper = ( connection : Connection , uri : string ) : Promise < string > => {
36- return schemaRequestHandler (
37- connection ,
38- uri ,
39- yamlSettings . workspaceFolders ,
40- yamlSettings . workspaceRoot ,
41- yamlSettings . useVSCodeContentRequest ,
42- fileSystem
43- ) ;
44- } ;
45-
46- const schemaRequestService = schemaRequestHandlerWrapper . bind ( this , connection ) ;
47- const telemetry = new TelemetryImpl ( connection ) ;
48-
49- new YAMLServerInit ( connection , yamlSettings , workspaceContext , schemaRequestService , telemetry ) . start ( ) ;
0 commit comments