Pass translations down to Markdown Language Server (#172884)

Fixes #172060
This commit is contained in:
Matt Bierner
2023-01-30 21:29:41 -08:00
committed by GitHub
parent 62dd7cd76d
commit c18f80a2d4
9 changed files with 83 additions and 8 deletions

View File

@@ -13,10 +13,10 @@ const path = require('path');
module.exports = withBrowserDefaults({
context: __dirname,
entry: {
extension: './src/browser/main.ts',
extension: './src/browser/workerMain.ts',
},
output: {
filename: 'main.js',
filename: 'workerMain.js',
path: path.join(__dirname, 'dist', 'browser'),
libraryTarget: 'var',
library: 'serverExportVar'

View File

@@ -13,10 +13,10 @@ const path = require('path');
module.exports = withDefaults({
context: path.join(__dirname),
entry: {
extension: './src/node/main.ts',
extension: './src/node/workerMain.ts',
},
output: {
filename: 'main.js',
filename: 'workerMain.js',
path: path.join(__dirname, 'dist', 'node'),
}
});

View File

@@ -14,7 +14,7 @@
"out/**/*.js"
],
"dependencies": {
"@vscode/l10n": "^0.0.10",
"@vscode/l10n": "^0.0.11",
"vscode-languageserver": "^8.0.2",
"vscode-languageserver-textdocument": "^1.0.5",
"vscode-languageserver-types": "^3.17.1",
@@ -27,6 +27,8 @@
"scripts": {
"compile": "gulp compile-extension:markdown-language-features-server",
"prepublishOnly": "npm run compile",
"watch": "gulp watch-extension:markdown-language-features-server"
"watch": "gulp watch-extension:markdown-language-features-server",
"compile-web": "npx webpack-cli --config extension-browser.webpack.config --mode none",
"watch-web": "npx webpack-cli --config extension-browser.webpack.config --mode none --watch --info-verbosity verbose"
}
}

View File

@@ -0,0 +1,38 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as l10n from '@vscode/l10n';
let initialized = false;
const pendingMessages: any[] = [];
const messageHandler = async (e: any) => {
if (!initialized) {
const l10nLog: string[] = [];
initialized = true;
const i10lLocation = e.data.i10lLocation;
if (i10lLocation) {
try {
await l10n.config({ uri: i10lLocation });
l10nLog.push(`l10n: Configured to ${i10lLocation.toString()}.`);
} catch (e) {
l10nLog.push(`l10n: Problems loading ${i10lLocation.toString()} : ${e}.`);
}
} else {
l10nLog.push(`l10n: No bundle configured.`);
}
await import('./main');
if (self.onmessage !== messageHandler) {
pendingMessages.forEach(msg => self.onmessage?.(msg));
pendingMessages.length = 0;
}
l10nLog.forEach(console.log);
} else {
pendingMessages.push(e);
}
};
self.onmessage = messageHandler;

View File

@@ -0,0 +1,23 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as l10n from '@vscode/l10n';
async function setupMain() {
const l10nLog: string[] = [];
const i10lLocation = process.env['VSCODE_L10N_BUNDLE_LOCATION'];
if (i10lLocation) {
try {
await l10n.config({ uri: i10lLocation });
l10nLog.push(`l10n: Configured to ${i10lLocation.toString()}`);
} catch (e) {
l10nLog.push(`l10n: Problems loading ${i10lLocation.toString()} : ${e}`);
}
}
await import('./main');
l10nLog.forEach(console.log);
}
setupMain();

View File

@@ -12,6 +12,11 @@
resolved "https://registry.yarnpkg.com/@vscode/l10n/-/l10n-0.0.10.tgz#9c513107c690c0dd16e3ec61e453743de15ebdb0"
integrity sha512-E1OCmDcDWa0Ya7vtSjp/XfHFGqYJfh+YPC1RkATU71fTac+j1JjCcB3qwSzmlKAighx2WxhLlfhS0RwAN++PFQ==
"@vscode/l10n@^0.0.11":
version "0.0.11"
resolved "https://registry.yarnpkg.com/@vscode/l10n/-/l10n-0.0.11.tgz#325d7beb2cfb87162bc624d16c4d546de6a73b72"
integrity sha512-ukOMWnCg1tCvT7WnDfsUKQOFDQGsyR5tNgRpwmqi+5/vzU3ghdDXzvIM4IOPdSb3OeSsBNvmSL8nxIVOqi2WXA==
picomatch@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"