Support custom external browser on remote cases (SSH, Dev Container) (#520)

* Support custom external browser on remote cases (SSH, Dev Container)
Fixes #517
This commit is contained in:
Andrea Mah 2023-06-19 11:39:28 -07:00 коммит произвёл GitHub
Родитель af2cf4b52b
Коммит a1b96b821f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 36 добавлений и 149 удалений

26
.vscode/launch.json поставляемый
Просмотреть файл

@ -33,5 +33,31 @@
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
},
{
"name": "Extension and JS Debug Companion",
"type": "extensionHost",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/../vscode-js-debug-companion",
"--extensionDevelopmentPath=${workspaceFolder}/"
],
"env": {
"JS_DEBUG_USE_COMPANION": "1"
},
"trace": true,
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"${workspaceFolder}/../vscode-js-debug-companion/**",
"!**/node_modules/**"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js",
"${workspaceFolder}/../vscode-js-debug-companion/out/**/*.js"
]
},
]
}

Просмотреть файл

@ -19,7 +19,7 @@
}
},
"engines": {
"vscode": "^1.74.0"
"vscode": "^1.80.0"
},
"bugs": {
"url": "https://github.com/microsoft/vscode-livepreview/issues"
@ -331,8 +331,6 @@
"@types/express": "^4.17.17",
"@vscode/codicons": "^0.0.32",
"mime": "^3.0.0",
"open": "^8.4.0",
"@vscode/js-debug-browsers": "^1.1.0",
"url": "^0.11.0",
"vscode-extension-telemetry": "^0.4.5",
"ws": "^8.8.1"

Просмотреть файл

@ -4,48 +4,20 @@
*--------------------------------------------------------------------------------------------*/
import { CustomExternalBrowser } from "./settingsUtil";
import * as vscode from 'vscode';
import * as JSDebugBrowsers from '@vscode/js-debug-browsers';
import open from "open";
export class ExternalBrowserUtils {
static async openInBrowser(target: string, browser: CustomExternalBrowser): Promise<void> {
if (vscode.env.appHost !== 'desktop') {
if (vscode.env.appHost !== 'desktop' || browser === CustomExternalBrowser.default) {
vscode.env.openExternal(vscode.Uri.parse(target));
return;
}
if (browser === CustomExternalBrowser.default) {
vscode.env.openExternal(vscode.Uri.parse(target));
return;
}
try {
let browserFinder: JSDebugBrowsers.IBrowserFinder | undefined;
switch (browser) {
case CustomExternalBrowser.chrome:
browserFinder = new JSDebugBrowsers.ChromeBrowserFinder();
break;
case CustomExternalBrowser.edge:
browserFinder = new JSDebugBrowsers.EdgeBrowserFinder();
break;
case CustomExternalBrowser.firefox:
browserFinder = new JSDebugBrowsers.FirefoxBrowserFinder();
break;
}
const exe = await browserFinder?.findWhere(() => true);
if (exe) {
await open(target, { app: { name: exe.path } });
} else {
vscode.window.showErrorMessage(`Could not find ${browser} installation. Please make sure it is installed or change the external preview browser in your settings.`,
'Open Settings').then((value) => {
if (value) {
vscode.commands.executeCommand('workbench.action.openSettings', 'livePreview.customExternalBrowser');
}
});
}
const browserStr = browser.toLowerCase(); // the debug companion expects lowercase browser names
vscode.commands.executeCommand('js-debug-companion.launch', {browserType: browserStr, URL: target});
} catch (e) {
vscode.env.openExternal(vscode.Uri.parse(target));
}
}

119
yarn.lock
Просмотреть файл

@ -300,7 +300,7 @@
"@types/estree@*":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.1.tgz#aa22750962f3bf0e79d753d3cc067f010c95f194"
resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz"
integrity sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==
"@types/estree@^0.0.51":
@ -544,13 +544,6 @@
resolved "https://registry.npmjs.org/@vscode/codicons/-/codicons-0.0.32.tgz"
integrity sha512-3lgSTWhAzzWN/EPURoY4ZDBEA80OPmnaknNujA3qnI4Iu7AONWd9xF3iE4L+4prIe8E3TUnLQ4pxoaFTEEZNwg==
"@vscode/js-debug-browsers@^1.1.0":
version "1.1.0"
resolved "https://registry.npmjs.org/@vscode/js-debug-browsers/-/js-debug-browsers-1.1.0.tgz"
integrity sha512-v2hkBzA3DlUYxq3fMpCR8xuzmYjkoYjy276XA7mzZVstsFYkfbsOkluRwulrbqEEsjy3XObPNZq+A3ZZkpC+Gw==
dependencies:
execa "^4.0.0"
"@vscode/test-electron@^1.6.1":
version "1.6.2"
resolved "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-1.6.2.tgz"
@ -1155,7 +1148,7 @@ core-util-is@~1.0.0:
resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz"
integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==
cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
@ -1193,11 +1186,6 @@ deep-is@^0.1.3:
resolved "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz"
integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=
define-lazy-prop@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz"
integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==
del@^4.1.1:
version "4.1.1"
resolved "https://registry.npmjs.org/del/-/del-4.1.1.tgz"
@ -1262,16 +1250,9 @@ emoji-regex@^8.0.0:
resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz"
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
end-of-stream@^1.1.0:
version "1.4.4"
resolved "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz"
integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==
dependencies:
once "^1.4.0"
enhanced-resolve@^5.0.0:
version "5.14.1"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.14.1.tgz#de684b6803724477a4af5d74ccae5de52c25f6b3"
resolved "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.14.1.tgz"
integrity sha512-Vklwq2vDKtl0y/vtwjSesgJ5MYS7Etuk5txS8VdKL4AOS1aUlD96zqIfsOSLQsdv3xgMRbtkWM8eG9XDfKUPow==
dependencies:
graceful-fs "^4.2.4"
@ -1651,21 +1632,6 @@ events@^3.2.0:
resolved "https://registry.npmjs.org/events/-/events-3.3.0.tgz"
integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==
execa@^4.0.0:
version "4.1.0"
resolved "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz"
integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==
dependencies:
cross-spawn "^7.0.0"
get-stream "^5.0.0"
human-signals "^1.1.1"
is-stream "^2.0.0"
merge-stream "^2.0.0"
npm-run-path "^4.0.0"
onetime "^5.1.0"
signal-exit "^3.0.2"
strip-final-newline "^2.0.0"
fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
version "3.1.3"
resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz"
@ -1799,13 +1765,6 @@ get-stdin@^8.0.0:
resolved "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz"
integrity sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==
get-stream@^5.0.0:
version "5.2.0"
resolved "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz"
integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==
dependencies:
pump "^3.0.0"
glob-parent@^5.1.2, glob-parent@~5.1.2:
version "5.1.2"
resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz"
@ -1956,11 +1915,6 @@ https-proxy-agent@^5.0.0:
agent-base "6"
debug "4"
human-signals@^1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz"
integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==
ignore@^4.0.6:
version "4.0.6"
resolved "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz"
@ -2029,11 +1983,6 @@ is-core-module@^2.2.0:
dependencies:
has "^1.0.3"
is-docker@^2.0.0, is-docker@^2.1.1:
version "2.2.1"
resolved "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz"
integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==
is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz"
@ -2099,23 +2048,11 @@ is-plain-object@^2.0.4:
dependencies:
isobject "^3.0.1"
is-stream@^2.0.0:
version "2.0.1"
resolved "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz"
integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==
is-unicode-supported@^0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz"
integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==
is-wsl@^2.2.0:
version "2.2.0"
resolved "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz"
integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
dependencies:
is-docker "^2.0.0"
isarray@0.0.1:
version "0.0.1"
resolved "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz"
@ -2338,11 +2275,6 @@ mime@^3.0.0:
resolved "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz"
integrity sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==
mimic-fn@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz"
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
minimatch@4.2.1:
version "4.2.1"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz"
@ -2450,41 +2382,18 @@ normalize-path@^3.0.0, normalize-path@~3.0.0:
resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
npm-run-path@^4.0.0:
version "4.0.1"
resolved "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz"
integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==
dependencies:
path-key "^3.0.0"
object-assign@^4.0.1:
version "4.1.1"
resolved "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
once@^1.3.0, once@^1.3.1, once@^1.4.0:
once@^1.3.0:
version "1.4.0"
resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz"
integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==
dependencies:
wrappy "1"
onetime@^5.1.0:
version "5.1.2"
resolved "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz"
integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==
dependencies:
mimic-fn "^2.1.0"
open@^8.4.0:
version "8.4.0"
resolved "https://registry.npmjs.org/open/-/open-8.4.0.tgz"
integrity sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==
dependencies:
define-lazy-prop "^2.0.0"
is-docker "^2.1.1"
is-wsl "^2.2.0"
optionator@^0.9.1:
version "0.9.1"
resolved "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz"
@ -2569,7 +2478,7 @@ path-is-inside@^1.0.2:
resolved "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz"
integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=
path-key@^3.0.0, path-key@^3.1.0:
path-key@^3.1.0:
version "3.1.1"
resolved "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz"
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
@ -2695,14 +2604,6 @@ progress@^2.0.0:
resolved "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz"
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
pump@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz"
integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==
dependencies:
end-of-stream "^1.1.0"
once "^1.3.1"
punycode@1.3.2:
version "1.3.2"
resolved "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz"
@ -2929,11 +2830,6 @@ shebang-regex@^3.0.0:
resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz"
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
signal-exit@^3.0.2:
version "3.0.7"
resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz"
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
sinon@9.0.0:
version "9.0.0"
resolved "https://registry.npmjs.org/sinon/-/sinon-9.0.0.tgz"
@ -3030,11 +2926,6 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1:
dependencies:
ansi-regex "^5.0.1"
strip-final-newline@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz"
integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==
strip-json-comments@3.1.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
version "3.1.1"
resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz"