Adopt vscode-oniguruma-wasm

This commit is contained in:
Alex Dima
2020-04-23 11:16:21 +02:00
parent 2f9d3f166e
commit a6e59815c8
23 changed files with 137 additions and 170 deletions

View File

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

View File

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

View File

@@ -19,13 +19,6 @@ vscode-sqlite3/build/**
vscode-sqlite3/src/** vscode-sqlite3/src/**
!vscode-sqlite3/build/Release/*.node !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/binding.gyp
windows-mutex/build/** windows-mutex/build/**
windows-mutex/src/** windows-mutex/src/**

View File

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

View File

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

View File

@@ -2,9 +2,9 @@
"name": "vscode-web", "name": "vscode-web",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"onigasm-umd": "2.2.5",
"semver-umd": "^5.5.6", "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": "4.6.0-beta.15",
"xterm-addon-search": "0.6.0", "xterm-addon-search": "0.6.0",
"xterm-addon-unicode11": "0.2.0-beta.2", "xterm-addon-unicode11": "0.2.0-beta.2",

View File

@@ -2,34 +2,20 @@
# yarn lockfile v1 # 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: semver-umd@^5.5.6:
version "5.5.6" version "5.5.6"
resolved "https://registry.yarnpkg.com/semver-umd/-/semver-umd-5.5.6.tgz#1d185bbd2caec825c564b54907cd09e14083f228" resolved "https://registry.yarnpkg.com/semver-umd/-/semver-umd-5.5.6.tgz#1d185bbd2caec825c564b54907cd09e14083f228"
integrity sha512-6ARYXVi4Y4VO5HfyCjT/6xyykBtJwEXSGQ8ON4UPQSFOjZUDsbAE0J614QcBBsLTTyQMEqvsXN804vAqpydjzw== integrity sha512-6ARYXVi4Y4VO5HfyCjT/6xyykBtJwEXSGQ8ON4UPQSFOjZUDsbAE0J614QcBBsLTTyQMEqvsXN804vAqpydjzw==
vscode-textmate@4.4.0: vscode-oniguruma-wasm@1.1.0:
version "4.4.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.4.0.tgz#14032afeb50152e8f53258c95643e555f2948305" resolved "https://registry.yarnpkg.com/vscode-oniguruma-wasm/-/vscode-oniguruma-wasm-1.1.0.tgz#9959396aa20ffe570f1b3a4d51d37ce94b73943d"
integrity sha512-dFpm2eK0HwEjeFSD1DDh3j0q47bDSVuZt20RiJWxGqjtm73Wu2jip3C2KaZI3dQx/fSeeXCr/uEN4LNaNj7Ytw== integrity sha512-VbJJ8lx0YFnPI7Zu+EKNYuw02NFTobKKqxZjfxnQz9AGKN3wl8D+bB748zC9DRoEX4vgWd5NYdMvdfA9zT2tCw==
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==
xterm-addon-search@0.6.0: xterm-addon-search@0.6.0:
version "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" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== 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: pend@~1.2.0:
version "1.2.0" version "1.2.0"
resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" 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" lodash.isundefined "^3.0.1"
nan "^2.10.0" 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: vscode-proxy-agent@^0.5.2:
version "0.5.2" version "0.5.2"
resolved "https://registry.yarnpkg.com/vscode-proxy-agent/-/vscode-proxy-agent-0.5.2.tgz#0c90d24d353957b841d741da7b2701e3f0a044c4" 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" resolved "https://registry.yarnpkg.com/vscode-ripgrep/-/vscode-ripgrep-1.5.8.tgz#32cb33da6d1a9ca8f5de8c2813ed5114fd55fc11"
integrity sha512-l6Pv/t1Jk63RU+kEkMO04XxnNRYdyzuesizj9AzFpcfrUxxpAjEJBK1qO9Mov30UUGZl7uDUBn+uCv9koaHPPA== integrity sha512-l6Pv/t1Jk63RU+kEkMO04XxnNRYdyzuesizj9AzFpcfrUxxpAjEJBK1qO9Mov30UUGZl7uDUBn+uCv9koaHPPA==
vscode-textmate@4.4.0: vscode-textmate@5.0.2:
version "4.4.0" version "5.0.2"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.4.0.tgz#14032afeb50152e8f53258c95643e555f2948305" resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-5.0.2.tgz#db661c4a9d7aae5923030b4e3d55cf88b7ece0dd"
integrity sha512-dFpm2eK0HwEjeFSD1DDh3j0q47bDSVuZt20RiJWxGqjtm73Wu2jip3C2KaZI3dQx/fSeeXCr/uEN4LNaNj7Ytw== integrity sha512-ZkaXGGXvxinC7bVJT67MOQLdmXE3p3xqUbkhy7tmBRlsHWPKh3MP1zA/+NeFlu4JAGzyuT1Y5MPn7s64szvMpQ==
dependencies:
oniguruma "^7.2.0"
vscode-windows-ca-certs@0.2.0: vscode-windows-ca-certs@0.2.0:
version "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 ELECTRON_RUN_AS_NODE=1
set NODE_ENV=development set NODE_ENV=development
set VSCODE_DEV=1 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 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_LOGGING=1
set ELECTRON_ENABLE_STACK_DUMPING=1 set ELECTRON_ENABLE_STACK_DUMPING=1

View File

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

View File

@@ -28,7 +28,6 @@ if not exist out yarn compile
:: Configuration :: Configuration
set NODE_ENV=development set NODE_ENV=development
set VSCODE_DEV=1 set VSCODE_DEV=1
set ELECTRON_ENABLE_SECURITY_WARNINGS=1
set VSCODE_CLI=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 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_LOGGING=1

View File

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

View File

@@ -28,7 +28,7 @@
baseUrl: `${window.location.origin}/static/out`, baseUrl: `${window.location.origin}/static/out`,
paths: { paths: {
'vscode-textmate': `${window.location.origin}/static/remote/web/node_modules/vscode-textmate/release/main`, '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': `${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-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`, '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`, baseUrl: `${window.location.origin}/static/out`,
paths: { paths: {
'vscode-textmate': `${window.location.origin}/static/node_modules/vscode-textmate/release/main`, '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': `${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-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`, 'xterm-addon-unicode11': `${window.location.origin}/static/node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`,

View File

@@ -3,7 +3,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8" /> <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> </head>
<body class="vs-dark" aria-label=""> <body class="vs-dark" aria-label="">
</body> </body>

View File

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

View File

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

View File

@@ -6,7 +6,6 @@
import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService'; import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { AbstractTextMateService } from 'vs/workbench/services/textMate/browser/abstractTextMateService'; import { AbstractTextMateService } from 'vs/workbench/services/textMate/browser/abstractTextMateService';
import { IOnigLib } from 'vscode-textmate';
import { IModeService } from 'vs/editor/common/services/modeService'; import { IModeService } from 'vs/editor/common/services/modeService';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { INotificationService } from 'vs/platform/notification/common/notification'; 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); super(modeService, themeService, extensionResourceLoaderService, notificationService, logService, configurationService, storageService);
} }
protected _loadVSCodeTextmate(): Promise<typeof import('vscode-textmate')> { protected async _loadVSCodeOnigurumWASM(): Promise<Response | ArrayBuffer> {
return import('vscode-textmate'); const wasmPath = require.toUrl('vscode-oniguruma-wasm/../onig.wasm');
}
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 response = await fetch(wasmPath);
const bytes = await response.arrayBuffer(); // Using the response directly only works if the server sets the MIME type 'application/wasm'.
return bytes; // Otherwise, a TypeError is thrown when using the streaming compiler.
// We therefore use the non-streaming compiler :(.
return await response.arrayBuffer();
}
} }
registerSingleton(ITextMateService, TextMateService); registerSingleton(ITextMateService, TextMateService);

View File

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

View File

@@ -5,41 +5,43 @@
"type": "other", "type": "other",
"other": { "other": {
"name": "lib-oniguruma", "name": "lib-oniguruma",
"downloadUrl": "http://dl.fedoraproject.org/pub/epel/7/SRPMS/Packages/o/oniguruma-5.9.5-3.el7.src.rpm", "downloadUrl": "https://github.com/kkos/oniguruma",
"version": "5.9.3" "version": "6.9.5"
} }
}, },
"licenseDetail": [ "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", "The BSD License",
"", "",
"Redistribution and use in source and binary forms, with or without", "Redistribution and use in source and binary forms, with or without",
"modification, are permitted provided that the following conditions", "modification, are permitted provided that the following conditions",
"are met:", "are met:",
"",
"1. Redistributions of source code must retain the above copyright", "1. Redistributions of source code must retain the above copyright",
" notice, this list of conditions and the following disclaimer.", " notice, this list of conditions and the following disclaimer.",
"",
"2. Redistributions in binary form must reproduce the above copyright", "2. Redistributions in binary form must reproduce the above copyright",
" notice, this list of conditions and the following disclaimer in the", " notice, this list of conditions and the following disclaimer in the",
" documentation and/or other materials provided with the distribution.", " documentation and/or other materials provided with the distribution.",
"", "",
"THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND", "THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND",
"ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE", "ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE",
"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR", "IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE",
"PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS", "ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE",
"BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR", "FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL",
"CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF", "DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS",
"SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR", "OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)",
"BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,", "HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT",
"WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE", "LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY",
"OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN", "OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF",
"IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." "SUCH DAMAGE."
], ],
"isOnlyProductionDependency": true, "isOnlyProductionDependency": true,
"license": "BSD", "license": "BSD",
"version": "5.9.3" "version": "6.9.5"
} }
], ],
"version": 1 "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 { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { createWebWorker, MonacoWebWorker } from 'vs/editor/common/services/webWorker'; import { createWebWorker, MonacoWebWorker } from 'vs/editor/common/services/webWorker';
import { IModelService } from 'vs/editor/common/services/modelService'; 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 { IValidGrammarDefinition } from 'vs/workbench/services/textMate/common/TMScopeRegistry';
import { TextMateWorker } from 'vs/workbench/services/textMate/electron-browser/textMateWorker'; import { TextMateWorker } from 'vs/workbench/services/textMate/electron-browser/textMateWorker';
import { ITextModel } from 'vs/editor/common/model'; import { ITextModel } from 'vs/editor/common/model';
@@ -177,12 +177,10 @@ export class TextMateService extends AbstractTextMateService {
} }
} }
protected _loadVSCodeTextmate(): Promise<typeof import('vscode-textmate')> { protected async _loadVSCodeOnigurumWASM(): Promise<Response | ArrayBuffer> {
return import('vscode-textmate'); const wasmPath = require.toUrl('../../../../../../node_modules/vscode-oniguruma-wasm/release/onig.wasm');
} const response = await fetch(wasmPath);
return response;
protected _loadOnigLib(): Promise<IOnigLib> | undefined {
return undefined;
} }
protected _onDidCreateGrammarFactory(grammarDefinitions: IValidGrammarDefinition[]): void { 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 { IModelChangedEvent, MirrorTextModel } from 'vs/editor/common/model/mirrorTextModel';
import { TextMateWorkerHost } from 'vs/workbench/services/textMate/electron-browser/textMateService'; import { TextMateWorkerHost } from 'vs/workbench/services/textMate/electron-browser/textMateService';
import { TokenizationStateStore } from 'vs/editor/common/model/textModelTokens'; 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 { MultilineTokensBuilder, countEOL } from 'vs/editor/common/model/tokensStore';
import { LineTokens } from 'vs/editor/common/core/lineTokens'; import { LineTokens } from 'vs/editor/common/core/lineTokens';
@@ -118,7 +118,7 @@ export class TextMateWorker {
private readonly _host: TextMateWorkerHost; private readonly _host: TextMateWorkerHost;
private readonly _models: { [uri: string]: TextMateWorkerModel; }; private readonly _models: { [uri: string]: TextMateWorkerModel; };
private readonly _grammarCache: Promise<ICreateGrammarResult>[]; private readonly _grammarCache: Promise<ICreateGrammarResult>[];
private readonly _grammarFactory: TMGrammarFactory | null; private readonly _grammarFactory: Promise<TMGrammarFactory | null>;
constructor(ctx: IWorkerContext<TextMateWorkerHost>, createData: ICreateData) { constructor(ctx: IWorkerContext<TextMateWorkerHost>, createData: ICreateData) {
this._host = ctx.host; this._host = ctx.host;
@@ -134,24 +134,36 @@ export class TextMateWorker {
injectTo: def.injectTo, injectTo: def.injectTo,
}; };
}); });
this._grammarFactory = this._loadTMGrammarFactory(grammarDefinitions);
}
const globalDefine = (<any>self).define; private async _loadTMGrammarFactory(grammarDefinitions: IValidGrammarDefinition[]): Promise<TMGrammarFactory> {
try { require.config({
(<any>self).define.amd = undefined; paths: {
const vscodeTextmate = <typeof import('vscode-textmate')>require.__$__nodeRequire('vscode-textmate'); '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({ 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) */ }, logTrace: (msg: string) => {/* console.log(msg) */ },
logError: (msg: string, err: any) => console.error(msg, err), logError: (msg: string, err: any) => console.error(msg, err),
readFile: (resource: URI) => this._host.readFile(resource) readFile: (resource: URI) => this._host.readFile(resource)
}, grammarDefinitions, vscodeTextmate, undefined); }, grammarDefinitions, vscodeTextmate, onigLib);
} catch (err) {
console.error(err);
this._grammarFactory = null;
return;
} finally {
(<any>self).define = globalDefine;
}
} }
public acceptNewModel(data: IRawModelData): void { public acceptNewModel(data: IRawModelData): void {
@@ -175,19 +187,21 @@ export class TextMateWorker {
} }
} }
public getOrCreateGrammar(languageId: LanguageId): Promise<ICreateGrammarResult | null> { public async getOrCreateGrammar(languageId: LanguageId): Promise<ICreateGrammarResult | null> {
if (!this._grammarFactory) { const grammarFactory = await this._grammarFactory;
if (!grammarFactory) {
return Promise.resolve(null); return Promise.resolve(null);
} }
if (!this._grammarCache[languageId]) { if (!this._grammarCache[languageId]) {
this._grammarCache[languageId] = this._grammarFactory.createGrammar(languageId); this._grammarCache[languageId] = grammarFactory.createGrammar(languageId);
} }
return this._grammarCache[languageId]; return this._grammarCache[languageId];
} }
public acceptTheme(theme: IRawTheme, colorMap: string[]): void { public async acceptTheme(theme: IRawTheme, colorMap: string[]): Promise<void> {
if (this._grammarFactory) { const grammarFactory = await this._grammarFactory;
this._grammarFactory.setTheme(theme, colorMap); if (grammarFactory) {
grammarFactory.setTheme(theme, colorMap);
} }
} }

View File

@@ -6575,18 +6575,6 @@ onetime@^5.1.0:
dependencies: dependencies:
mimic-fn "^2.1.0" 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: opn@^6.0.0:
version "6.0.0" version "6.0.0"
resolved "https://registry.yarnpkg.com/opn/-/opn-6.0.0.tgz#3c5b0db676d5f97da1233d1ed42d182bc5a27d2d" 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" lodash.isundefined "^3.0.1"
nan "^2.10.0" 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: vscode-proxy-agent@^0.5.2:
version "0.5.2" version "0.5.2"
resolved "https://registry.yarnpkg.com/vscode-proxy-agent/-/vscode-proxy-agent-0.5.2.tgz#0c90d24d353957b841d741da7b2701e3f0a044c4" 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: dependencies:
nan "^2.14.0" nan "^2.14.0"
vscode-textmate@4.4.0: vscode-textmate@5.0.2:
version "4.4.0" version "5.0.2"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.4.0.tgz#14032afeb50152e8f53258c95643e555f2948305" resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-5.0.2.tgz#db661c4a9d7aae5923030b4e3d55cf88b7ece0dd"
integrity sha512-dFpm2eK0HwEjeFSD1DDh3j0q47bDSVuZt20RiJWxGqjtm73Wu2jip3C2KaZI3dQx/fSeeXCr/uEN4LNaNj7Ytw== integrity sha512-ZkaXGGXvxinC7bVJT67MOQLdmXE3p3xqUbkhy7tmBRlsHWPKh3MP1zA/+NeFlu4JAGzyuT1Y5MPn7s64szvMpQ==
dependencies:
oniguruma "^7.2.0"
vscode-windows-ca-certs@0.2.0: vscode-windows-ca-certs@0.2.0:
version "0.2.0" version "0.2.0"