Adopt vscode-oniguruma-wasm

This commit is contained in:
Alex Dima 2020-04-23 11:16:21 +02:00
parent 2f9d3f166e
commit a6e59815c8
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
23 changed files with 137 additions and 170 deletions

View file

@ -461,7 +461,8 @@
"**/vs/workbench/common/**",
"**/vs/workbench/services/**/common/**",
"**/vs/workbench/api/**/common/**",
"vscode-textmate"
"vscode-textmate",
"vscode-oniguruma-wasm"
]
},
{
@ -490,7 +491,7 @@
"**/vs/workbench/api/{common,browser}/**",
"**/vs/workbench/services/**/{common,browser}/**",
"vscode-textmate",
"onigasm-umd"
"vscode-oniguruma-wasm"
]
},
{

View file

@ -7,7 +7,8 @@
"**/.DS_Store": true,
"build/**/*.js": {
"when": "$(basename).ts"
}
},
"src/vs/server": false
},
"files.associations": {
"cglicenses.json": "jsonc"
@ -24,7 +25,8 @@
"test/smoke/out/**": true,
"test/automation/out/**": true,
"test/integration/browser/out/**": true,
"src/vs/base/test/node/uri.test.data.txt": true
"src/vs/base/test/node/uri.test.data.txt": true,
"src/vs/server": false
},
"lcov.path": [
"./.build/coverage/lcov.info",

View file

@ -19,13 +19,6 @@ vscode-sqlite3/build/**
vscode-sqlite3/src/**
!vscode-sqlite3/build/Release/*.node
oniguruma/binding.gyp
oniguruma/build/**
oniguruma/src/**
oniguruma/deps/**
!oniguruma/build/Release/*.node
!oniguruma/src/*.js
windows-mutex/binding.gyp
windows-mutex/build/**
windows-mutex/src/**

View file

@ -50,16 +50,16 @@
"native-keymap": "2.1.1",
"native-watchdog": "1.3.0",
"node-pty": "0.10.0-beta8",
"onigasm-umd": "2.2.5",
"semver-umd": "^5.5.6",
"spdlog": "^0.11.1",
"sudo-prompt": "9.1.1",
"v8-inspect-profiler": "^0.0.20",
"vscode-nsfw": "1.2.8",
"vscode-oniguruma-wasm": "1.1.0",
"vscode-proxy-agent": "^0.5.2",
"vscode-ripgrep": "^1.5.8",
"vscode-sqlite3": "4.0.10",
"vscode-textmate": "4.4.0",
"vscode-textmate": "5.0.2",
"xterm": "4.6.0-beta.15",
"xterm-addon-search": "0.6.0",
"xterm-addon-unicode11": "0.2.0-beta.2",

View file

@ -13,13 +13,13 @@
"minimist": "^1.2.5",
"native-watchdog": "1.3.0",
"node-pty": "0.10.0-beta8",
"onigasm-umd": "2.2.5",
"semver-umd": "^5.5.6",
"spdlog": "^0.11.1",
"vscode-nsfw": "1.2.8",
"vscode-oniguruma-wasm": "1.1.0",
"vscode-proxy-agent": "^0.5.2",
"vscode-ripgrep": "^1.5.8",
"vscode-textmate": "4.4.0",
"vscode-textmate": "5.0.2",
"xterm": "4.6.0-beta.15",
"xterm-addon-search": "0.6.0",
"xterm-addon-unicode11": "0.2.0-beta.2",

View file

@ -2,9 +2,9 @@
"name": "vscode-web",
"version": "0.0.0",
"dependencies": {
"onigasm-umd": "2.2.5",
"semver-umd": "^5.5.6",
"vscode-textmate": "4.4.0",
"vscode-oniguruma-wasm": "1.1.0",
"vscode-textmate": "5.0.2",
"xterm": "4.6.0-beta.15",
"xterm-addon-search": "0.6.0",
"xterm-addon-unicode11": "0.2.0-beta.2",

View file

@ -2,34 +2,20 @@
# yarn lockfile v1
nan@^2.14.0:
version "2.14.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
onigasm-umd@2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/onigasm-umd/-/onigasm-umd-2.2.5.tgz#f104247334a543accd3f8d641a4d99b3d908d6a1"
integrity sha512-R3qD7hq6i2bBklF+QyjqZl/G4fe7GwtukI28YLH2vuiatqx52tb9vpg2sxwemKc3nF76SgkeyOKJLchBmTm0Aw==
oniguruma@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/oniguruma/-/oniguruma-7.2.0.tgz#c9a59c1ea7b9fe67e237a02e02139b638856f3af"
integrity sha512-bh+ZLdykY1sdIx8jBp2zpLbVFDBc3XmKH4Ceo2lijNaN1WhEqtnpqFlmtCbRuDB17nJ58RAUStVwfW8e8uEbnA==
dependencies:
nan "^2.14.0"
semver-umd@^5.5.6:
version "5.5.6"
resolved "https://registry.yarnpkg.com/semver-umd/-/semver-umd-5.5.6.tgz#1d185bbd2caec825c564b54907cd09e14083f228"
integrity sha512-6ARYXVi4Y4VO5HfyCjT/6xyykBtJwEXSGQ8ON4UPQSFOjZUDsbAE0J614QcBBsLTTyQMEqvsXN804vAqpydjzw==
vscode-textmate@4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.4.0.tgz#14032afeb50152e8f53258c95643e555f2948305"
integrity sha512-dFpm2eK0HwEjeFSD1DDh3j0q47bDSVuZt20RiJWxGqjtm73Wu2jip3C2KaZI3dQx/fSeeXCr/uEN4LNaNj7Ytw==
dependencies:
oniguruma "^7.2.0"
vscode-oniguruma-wasm@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/vscode-oniguruma-wasm/-/vscode-oniguruma-wasm-1.1.0.tgz#9959396aa20ffe570f1b3a4d51d37ce94b73943d"
integrity sha512-VbJJ8lx0YFnPI7Zu+EKNYuw02NFTobKKqxZjfxnQz9AGKN3wl8D+bB748zC9DRoEX4vgWd5NYdMvdfA9zT2tCw==
vscode-textmate@5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-5.0.2.tgz#db661c4a9d7aae5923030b4e3d55cf88b7ece0dd"
integrity sha512-ZkaXGGXvxinC7bVJT67MOQLdmXE3p3xqUbkhy7tmBRlsHWPKh3MP1zA/+NeFlu4JAGzyuT1Y5MPn7s64szvMpQ==
xterm-addon-search@0.6.0:
version "0.6.0"

View file

@ -283,18 +283,6 @@ normalize-path@^3.0.0, normalize-path@~3.0.0:
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
onigasm-umd@2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/onigasm-umd/-/onigasm-umd-2.2.5.tgz#f104247334a543accd3f8d641a4d99b3d908d6a1"
integrity sha512-R3qD7hq6i2bBklF+QyjqZl/G4fe7GwtukI28YLH2vuiatqx52tb9vpg2sxwemKc3nF76SgkeyOKJLchBmTm0Aw==
oniguruma@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/oniguruma/-/oniguruma-7.2.0.tgz#c9a59c1ea7b9fe67e237a02e02139b638856f3af"
integrity sha512-bh+ZLdykY1sdIx8jBp2zpLbVFDBc3XmKH4Ceo2lijNaN1WhEqtnpqFlmtCbRuDB17nJ58RAUStVwfW8e8uEbnA==
dependencies:
nan "^2.14.0"
pend@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50"
@ -379,6 +367,11 @@ vscode-nsfw@1.2.8:
lodash.isundefined "^3.0.1"
nan "^2.10.0"
vscode-oniguruma-wasm@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/vscode-oniguruma-wasm/-/vscode-oniguruma-wasm-1.1.0.tgz#9959396aa20ffe570f1b3a4d51d37ce94b73943d"
integrity sha512-VbJJ8lx0YFnPI7Zu+EKNYuw02NFTobKKqxZjfxnQz9AGKN3wl8D+bB748zC9DRoEX4vgWd5NYdMvdfA9zT2tCw==
vscode-proxy-agent@^0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/vscode-proxy-agent/-/vscode-proxy-agent-0.5.2.tgz#0c90d24d353957b841d741da7b2701e3f0a044c4"
@ -394,12 +387,10 @@ vscode-ripgrep@^1.5.8:
resolved "https://registry.yarnpkg.com/vscode-ripgrep/-/vscode-ripgrep-1.5.8.tgz#32cb33da6d1a9ca8f5de8c2813ed5114fd55fc11"
integrity sha512-l6Pv/t1Jk63RU+kEkMO04XxnNRYdyzuesizj9AzFpcfrUxxpAjEJBK1qO9Mov30UUGZl7uDUBn+uCv9koaHPPA==
vscode-textmate@4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.4.0.tgz#14032afeb50152e8f53258c95643e555f2948305"
integrity sha512-dFpm2eK0HwEjeFSD1DDh3j0q47bDSVuZt20RiJWxGqjtm73Wu2jip3C2KaZI3dQx/fSeeXCr/uEN4LNaNj7Ytw==
dependencies:
oniguruma "^7.2.0"
vscode-textmate@5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-5.0.2.tgz#db661c4a9d7aae5923030b4e3d55cf88b7ece0dd"
integrity sha512-ZkaXGGXvxinC7bVJT67MOQLdmXE3p3xqUbkhy7tmBRlsHWPKh3MP1zA/+NeFlu4JAGzyuT1Y5MPn7s64szvMpQ==
vscode-windows-ca-certs@0.2.0:
version "0.2.0"

View file

@ -30,7 +30,6 @@ if not exist out yarn compile
set ELECTRON_RUN_AS_NODE=1
set NODE_ENV=development
set VSCODE_DEV=1
set ELECTRON_ENABLE_SECURITY_WARNINGS=1
REM set ELECTRON_DEFAULT_ERROR_MODE=1 TODO@ben to investigate if this helps with builds reporting stacks if renderer crashes
set ELECTRON_ENABLE_LOGGING=1
set ELECTRON_ENABLE_STACK_DUMPING=1

View file

@ -39,7 +39,6 @@ function code() {
ELECTRON_RUN_AS_NODE=1 \
NODE_ENV=development \
VSCODE_DEV=1 \
ELECTRON_ENABLE_SECURITY_WARNINGS=1 \
ELECTRON_ENABLE_LOGGING=1 \
ELECTRON_ENABLE_STACK_DUMPING=1 \
"$CODE" --inspect=5874 "$ROOT/out/cli.js" . "$@"

View file

@ -28,7 +28,6 @@ if not exist out yarn compile
:: Configuration
set NODE_ENV=development
set VSCODE_DEV=1
set ELECTRON_ENABLE_SECURITY_WARNINGS=1
set VSCODE_CLI=1
REM set ELECTRON_DEFAULT_ERROR_MODE=1 TODO@ben to investigate if this helps with builds reporting stacks if renderer crashes
set ELECTRON_ENABLE_LOGGING=1

View file

@ -44,7 +44,6 @@ function code() {
# Configuration
export NODE_ENV=development
export VSCODE_DEV=1
export ELECTRON_ENABLE_SECURITY_WARNINGS=1
export VSCODE_CLI=1
export ELECTRON_ENABLE_STACK_DUMPING=1
export ELECTRON_ENABLE_LOGGING=1

View file

@ -28,7 +28,7 @@
baseUrl: `${window.location.origin}/static/out`,
paths: {
'vscode-textmate': `${window.location.origin}/static/remote/web/node_modules/vscode-textmate/release/main`,
'onigasm-umd': `${window.location.origin}/static/remote/web/node_modules/onigasm-umd/release/main`,
'vscode-oniguruma-wasm': `${window.location.origin}/static/remote/web/node_modules/vscode-oniguruma-wasm/release/main`,
'xterm': `${window.location.origin}/static/remote/web/node_modules/xterm/lib/xterm.js`,
'xterm-addon-search': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
'xterm-addon-unicode11': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`,

View file

@ -32,7 +32,7 @@
baseUrl: `${window.location.origin}/static/out`,
paths: {
'vscode-textmate': `${window.location.origin}/static/node_modules/vscode-textmate/release/main`,
'onigasm-umd': `${window.location.origin}/static/node_modules/onigasm-umd/release/main`,
'vscode-oniguruma-wasm': `${window.location.origin}/static/node_modules/vscode-oniguruma-wasm/release/main`,
'xterm': `${window.location.origin}/static/node_modules/xterm/lib/xterm.js`,
'xterm-addon-search': `${window.location.origin}/static/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
'xterm-addon-unicode11': `${window.location.origin}/static/node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`,

View file

@ -3,7 +3,7 @@
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self' https: data: blob: vscode-remote-resource:; media-src 'none'; frame-src 'self' https://*.vscode-webview-test.com; object-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' https:; font-src 'self' https: vscode-remote-resource:;">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self' https: data: blob: vscode-remote-resource:; media-src 'none'; frame-src 'self' https://*.vscode-webview-test.com; object-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; connect-src 'self' https:; font-src 'self' https: vscode-remote-resource:;">
</head>
<body class="vs-dark" aria-label="">
</body>

View file

@ -1491,6 +1491,10 @@ var AMDLoader;
result.getStats = function () {
return _this.getLoaderEvents();
};
result.config = function (params, shouldOverwrite) {
if (shouldOverwrite === void 0) { shouldOverwrite = false; }
_this.configure(params, shouldOverwrite);
};
result.__$__nodeRequire = AMDLoader.global.nodeRequire;
return result;
};

View file

@ -184,7 +184,11 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
return this._grammarFactory;
}
const vscodeTextmate = await this._loadVSCodeTextmate();
const [vscodeTextmate, vscodeOniguruma] = await Promise.all([import('vscode-textmate'), this._getVSCodeOniguruma()]);
const onigLib: Promise<IOnigLib> = Promise.resolve({
createOnigScanner: (sources: string[]) => vscodeOniguruma.createOnigScanner(sources),
createOnigString: (str: string) => vscodeOniguruma.createOnigString(str)
});
// Avoid duplicate instantiations
if (this._grammarFactory) {
@ -195,7 +199,7 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
logTrace: (msg: string) => this._logService.trace(msg),
logError: (msg: string, err: any) => this._logService.error(msg, err),
readFile: (resource: URI) => this._extensionResourceLoaderService.readExtensionResource(resource)
}, this._grammarDefinitions || [], vscodeTextmate, this._loadOnigLib());
}, this._grammarDefinitions || [], vscodeTextmate, onigLib);
this._onDidCreateGrammarFactory(this._grammarDefinitions || []);
this._updateTheme(this._grammarFactory, this._themeService.getColorTheme(), true);
@ -340,8 +344,21 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
protected _onDidDisposeGrammarFactory(): void {
}
protected abstract _loadVSCodeTextmate(): Promise<typeof import('vscode-textmate')>;
protected abstract _loadOnigLib(): Promise<IOnigLib> | undefined;
private _vscodeOniguruma: Promise<typeof import('vscode-oniguruma-wasm')> | null = null;
private _getVSCodeOniguruma(): Promise<typeof import('vscode-oniguruma-wasm')> {
if (!this._vscodeOniguruma) {
this._vscodeOniguruma = this._doGetVSCodeOniguruma();
}
return this._vscodeOniguruma;
}
private async _doGetVSCodeOniguruma(): Promise<typeof import('vscode-oniguruma-wasm')> {
const [vscodeOniguruma, wasm] = await Promise.all([import('vscode-oniguruma-wasm'), this._loadVSCodeOnigurumWASM()]);
await vscodeOniguruma.loadWASM(wasm);
return vscodeOniguruma;
}
protected abstract _loadVSCodeOnigurumWASM(): Promise<Response | ArrayBuffer>;
}
const donotAskUpdateKey = 'editor.maxTokenizationLineLength.donotask';

View file

@ -6,7 +6,6 @@
import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { AbstractTextMateService } from 'vs/workbench/services/textMate/browser/abstractTextMateService';
import { IOnigLib } from 'vscode-textmate';
import { IModeService } from 'vs/editor/common/services/modeService';
import { ILogService } from 'vs/platform/log/common/log';
import { INotificationService } from 'vs/platform/notification/common/notification';
@ -29,41 +28,14 @@ export class TextMateService extends AbstractTextMateService {
super(modeService, themeService, extensionResourceLoaderService, notificationService, logService, configurationService, storageService);
}
protected _loadVSCodeTextmate(): Promise<typeof import('vscode-textmate')> {
return import('vscode-textmate');
protected async _loadVSCodeOnigurumWASM(): Promise<Response | ArrayBuffer> {
const wasmPath = require.toUrl('vscode-oniguruma-wasm/../onig.wasm');
const response = await fetch(wasmPath);
// Using the response directly only works if the server sets the MIME type 'application/wasm'.
// Otherwise, a TypeError is thrown when using the streaming compiler.
// We therefore use the non-streaming compiler :(.
return await response.arrayBuffer();
}
protected _loadOnigLib(): Promise<IOnigLib> | undefined {
return loadOnigasm();
}
}
let onigasmPromise: Promise<IOnigLib> | null = null;
async function loadOnigasm(): Promise<IOnigLib> {
if (!onigasmPromise) {
onigasmPromise = doLoadOnigasm();
}
return onigasmPromise;
}
async function doLoadOnigasm(): Promise<IOnigLib> {
const [wasmBytes, onigasm] = await Promise.all([
loadOnigasmWASM(),
import('onigasm-umd')
]);
await onigasm.loadWASM(wasmBytes);
return {
createOnigScanner(patterns: string[]) { return new onigasm.OnigScanner(patterns); },
createOnigString(s: string) { return new onigasm.OnigString(s); }
};
}
async function loadOnigasmWASM(): Promise<ArrayBuffer> {
const wasmPath = require.toUrl('onigasm-umd/../onigasm.wasm');
const response = await fetch(wasmPath);
const bytes = await response.arrayBuffer();
return bytes;
}
registerSingleton(ITextMateService, TextMateService);

View file

@ -33,7 +33,7 @@ export class TMGrammarFactory extends Disposable {
private readonly _languageToScope2: string[];
private readonly _grammarRegistry: Registry;
constructor(host: ITMGrammarFactoryHost, grammarDefinitions: IValidGrammarDefinition[], vscodeTextmate: typeof import('vscode-textmate'), onigLib: Promise<IOnigLib> | undefined) {
constructor(host: ITMGrammarFactoryHost, grammarDefinitions: IValidGrammarDefinition[], vscodeTextmate: typeof import('vscode-textmate'), onigLib: Promise<IOnigLib>) {
super();
this._host = host;
this._initialState = vscodeTextmate.INITIAL;
@ -42,7 +42,7 @@ export class TMGrammarFactory extends Disposable {
this._injectedEmbeddedLanguages = {};
this._languageToScope2 = [];
this._grammarRegistry = new vscodeTextmate.Registry({
getOnigLib: (typeof onigLib === 'undefined' ? undefined : () => onigLib),
onigLib: onigLib,
loadGrammar: async (scopeName: string) => {
const grammarDefinition = this._scopeRegistry.getGrammarDefinition(scopeName);
if (!grammarDefinition) {

View file

@ -5,41 +5,43 @@
"type": "other",
"other": {
"name": "lib-oniguruma",
"downloadUrl": "http://dl.fedoraproject.org/pub/epel/7/SRPMS/Packages/o/oniguruma-5.9.5-3.el7.src.rpm",
"version": "5.9.3"
"downloadUrl": "https://github.com/kkos/oniguruma",
"version": "6.9.5"
}
},
"licenseDetail": [
"Copyright (c) 2002-2007 K.Kosako. All rights reserved.",
"Oniguruma LICENSE",
"-----------------",
"",
"Copyright (c) 2002-2020 K.Kosako <kkosako0@gmail.com>",
"All rights reserved.",
"",
"The BSD License",
"",
"Redistribution and use in source and binary forms, with or without",
"modification, are permitted provided that the following conditions",
"are met:",
"",
"1. Redistributions of source code must retain the above copyright",
" notice, this list of conditions and the following disclaimer.",
"",
"2. Redistributions in binary form must reproduce the above copyright",
" notice, this list of conditions and the following disclaimer in the",
" documentation and/or other materials provided with the distribution.",
"",
"THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND",
"ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE",
"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR",
"PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS",
"BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR",
"CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF",
"SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR",
"BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,",
"WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE",
"OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN",
"IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE",
"ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE",
"FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL",
"DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS",
"OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)",
"HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT",
"LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY",
"OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF",
"SUCH DAMAGE."
],
"isOnlyProductionDependency": true,
"license": "BSD",
"version": "5.9.3"
"version": "6.9.5"
}
],
"version": 1

View file

@ -13,7 +13,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { createWebWorker, MonacoWebWorker } from 'vs/editor/common/services/webWorker';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IOnigLib, IRawTheme } from 'vscode-textmate';
import { IRawTheme } from 'vscode-textmate';
import { IValidGrammarDefinition } from 'vs/workbench/services/textMate/common/TMScopeRegistry';
import { TextMateWorker } from 'vs/workbench/services/textMate/electron-browser/textMateWorker';
import { ITextModel } from 'vs/editor/common/model';
@ -177,12 +177,10 @@ export class TextMateService extends AbstractTextMateService {
}
}
protected _loadVSCodeTextmate(): Promise<typeof import('vscode-textmate')> {
return import('vscode-textmate');
}
protected _loadOnigLib(): Promise<IOnigLib> | undefined {
return undefined;
protected async _loadVSCodeOnigurumWASM(): Promise<Response | ArrayBuffer> {
const wasmPath = require.toUrl('../../../../../../node_modules/vscode-oniguruma-wasm/release/onig.wasm');
const response = await fetch(wasmPath);
return response;
}
protected _onDidCreateGrammarFactory(grammarDefinitions: IValidGrammarDefinition[]): void {

View file

@ -11,7 +11,7 @@ import { TMGrammarFactory, ICreateGrammarResult } from 'vs/workbench/services/te
import { IModelChangedEvent, MirrorTextModel } from 'vs/editor/common/model/mirrorTextModel';
import { TextMateWorkerHost } from 'vs/workbench/services/textMate/electron-browser/textMateService';
import { TokenizationStateStore } from 'vs/editor/common/model/textModelTokens';
import { IGrammar, StackElement, IRawTheme } from 'vscode-textmate';
import { IGrammar, StackElement, IRawTheme, IOnigLib } from 'vscode-textmate';
import { MultilineTokensBuilder, countEOL } from 'vs/editor/common/model/tokensStore';
import { LineTokens } from 'vs/editor/common/core/lineTokens';
@ -118,7 +118,7 @@ export class TextMateWorker {
private readonly _host: TextMateWorkerHost;
private readonly _models: { [uri: string]: TextMateWorkerModel; };
private readonly _grammarCache: Promise<ICreateGrammarResult>[];
private readonly _grammarFactory: TMGrammarFactory | null;
private readonly _grammarFactory: Promise<TMGrammarFactory | null>;
constructor(ctx: IWorkerContext<TextMateWorkerHost>, createData: ICreateData) {
this._host = ctx.host;
@ -134,24 +134,36 @@ export class TextMateWorker {
injectTo: def.injectTo,
};
});
this._grammarFactory = this._loadTMGrammarFactory(grammarDefinitions);
}
const globalDefine = (<any>self).define;
try {
(<any>self).define.amd = undefined;
const vscodeTextmate = <typeof import('vscode-textmate')>require.__$__nodeRequire('vscode-textmate');
private async _loadTMGrammarFactory(grammarDefinitions: IValidGrammarDefinition[]): Promise<TMGrammarFactory> {
require.config({
paths: {
'vscode-textmate': '../node_modules/vscode-textmate/release/main',
'vscode-oniguruma-wasm': '../node_modules/vscode-oniguruma-wasm/release/main',
}
});
const vscodeTextmate = await import('vscode-textmate');
const vscodeOniguruma = await import('vscode-oniguruma-wasm');
const wasmPath = require.toUrl('vscode-oniguruma-wasm/../onig.wasm');
const response = await fetch(wasmPath);
// Using the response directly only works if the server sets the MIME type 'application/wasm'.
// Otherwise, a TypeError is thrown when using the streaming compiler.
// We therefore use the non-streaming compiler :(.
const bytes = await response.arrayBuffer();
await vscodeOniguruma.loadWASM(bytes);
this._grammarFactory = new TMGrammarFactory({
logTrace: (msg: string) => {/* console.log(msg) */ },
logError: (msg: string, err: any) => console.error(msg, err),
readFile: (resource: URI) => this._host.readFile(resource)
}, grammarDefinitions, vscodeTextmate, undefined);
} catch (err) {
console.error(err);
this._grammarFactory = null;
return;
} finally {
(<any>self).define = globalDefine;
}
const onigLib: Promise<IOnigLib> = Promise.resolve({
createOnigScanner: (sources) => vscodeOniguruma.createOnigScanner(sources),
createOnigString: (str) => vscodeOniguruma.createOnigString(str)
});
return new TMGrammarFactory({
logTrace: (msg: string) => {/* console.log(msg) */ },
logError: (msg: string, err: any) => console.error(msg, err),
readFile: (resource: URI) => this._host.readFile(resource)
}, grammarDefinitions, vscodeTextmate, onigLib);
}
public acceptNewModel(data: IRawModelData): void {
@ -175,19 +187,21 @@ export class TextMateWorker {
}
}
public getOrCreateGrammar(languageId: LanguageId): Promise<ICreateGrammarResult | null> {
if (!this._grammarFactory) {
public async getOrCreateGrammar(languageId: LanguageId): Promise<ICreateGrammarResult | null> {
const grammarFactory = await this._grammarFactory;
if (!grammarFactory) {
return Promise.resolve(null);
}
if (!this._grammarCache[languageId]) {
this._grammarCache[languageId] = this._grammarFactory.createGrammar(languageId);
this._grammarCache[languageId] = grammarFactory.createGrammar(languageId);
}
return this._grammarCache[languageId];
}
public acceptTheme(theme: IRawTheme, colorMap: string[]): void {
if (this._grammarFactory) {
this._grammarFactory.setTheme(theme, colorMap);
public async acceptTheme(theme: IRawTheme, colorMap: string[]): Promise<void> {
const grammarFactory = await this._grammarFactory;
if (grammarFactory) {
grammarFactory.setTheme(theme, colorMap);
}
}

View file

@ -6575,18 +6575,6 @@ onetime@^5.1.0:
dependencies:
mimic-fn "^2.1.0"
onigasm-umd@2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/onigasm-umd/-/onigasm-umd-2.2.5.tgz#f104247334a543accd3f8d641a4d99b3d908d6a1"
integrity sha512-R3qD7hq6i2bBklF+QyjqZl/G4fe7GwtukI28YLH2vuiatqx52tb9vpg2sxwemKc3nF76SgkeyOKJLchBmTm0Aw==
oniguruma@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/oniguruma/-/oniguruma-7.2.0.tgz#c9a59c1ea7b9fe67e237a02e02139b638856f3af"
integrity sha512-bh+ZLdykY1sdIx8jBp2zpLbVFDBc3XmKH4Ceo2lijNaN1WhEqtnpqFlmtCbRuDB17nJ58RAUStVwfW8e8uEbnA==
dependencies:
nan "^2.14.0"
opn@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/opn/-/opn-6.0.0.tgz#3c5b0db676d5f97da1233d1ed42d182bc5a27d2d"
@ -9706,6 +9694,11 @@ vscode-nsfw@1.2.8:
lodash.isundefined "^3.0.1"
nan "^2.10.0"
vscode-oniguruma-wasm@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/vscode-oniguruma-wasm/-/vscode-oniguruma-wasm-1.1.0.tgz#9959396aa20ffe570f1b3a4d51d37ce94b73943d"
integrity sha512-VbJJ8lx0YFnPI7Zu+EKNYuw02NFTobKKqxZjfxnQz9AGKN3wl8D+bB748zC9DRoEX4vgWd5NYdMvdfA9zT2tCw==
vscode-proxy-agent@^0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/vscode-proxy-agent/-/vscode-proxy-agent-0.5.2.tgz#0c90d24d353957b841d741da7b2701e3f0a044c4"
@ -9728,12 +9721,10 @@ vscode-sqlite3@4.0.10:
dependencies:
nan "^2.14.0"
vscode-textmate@4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.4.0.tgz#14032afeb50152e8f53258c95643e555f2948305"
integrity sha512-dFpm2eK0HwEjeFSD1DDh3j0q47bDSVuZt20RiJWxGqjtm73Wu2jip3C2KaZI3dQx/fSeeXCr/uEN4LNaNj7Ytw==
dependencies:
oniguruma "^7.2.0"
vscode-textmate@5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-5.0.2.tgz#db661c4a9d7aae5923030b4e3d55cf88b7ece0dd"
integrity sha512-ZkaXGGXvxinC7bVJT67MOQLdmXE3p3xqUbkhy7tmBRlsHWPKh3MP1zA/+NeFlu4JAGzyuT1Y5MPn7s64szvMpQ==
vscode-windows-ca-certs@0.2.0:
version "0.2.0"