Skip to content

Commit 80a21b2

Browse files
authored
feat: support UWP webview debugging (#1282)
* feat: allow debugging hosted uwps * debug * fixup! final fixings
1 parent 259706c commit 80a21b2

14 files changed

+253
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
3333
### v1.66.1 - 2022-03-24
3434

3535
- feat: adopt `CompletionItem.detail` ([vscode#145645](https://github.com/microsoft/vscode/issues/145645))
36+
- feat: support for debugging webviews in UWPs ([#1209](https://github.com/microsoft/vscode-js-debug/issues/1209))
3637
- fix: accessor properties not being writable ([vscode#146001](https://github.com/microsoft/vscode/issues/146001))
3738
- fix: completions sometimes throwing issue on accessor ([#1218](https://github.com/microsoft/vscode-js-debug/issues/1218))
3839

OPTIONS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
<h5>Default value:</h4><pre><code>false</pre></code><h4>url</h4><p>Will search for a tab with this exact url and attach to it, if found</p>
344344
<h5>Default value:</h4><pre><code>null</pre></code><h4>urlFilter</h4><p>Will search for a page with this url and attach to it, if found. Can have * wildcards.</p>
345345
<h5>Default value:</h4><pre><code>"*"</pre></code><h4>userDataDir</h4><p>By default, the browser is launched with a separate user profile in a temp folder. Use this option to override it. Set to false to launch with your default user profile. A new browser can&#39;t be launched if an instance is already running from <code>userDataDir</code>.</p>
346-
<h5>Default value:</h4><pre><code>true</pre></code><h4>useWebView</h4><p>(Edge (Chromium) only) When &#39;true&#39;, the debugger will treat the runtime executable as a host application that contains a WebView allowing you to debug the WebView script content.</p>
346+
<h5>Default value:</h4><pre><code>true</pre></code><h4>useWebView</h4><p>When &#39;true&#39;, the debugger will treat the runtime executable as a host application that contains a WebView allowing you to debug the WebView script content.</p>
347347
<h5>Default value:</h4><pre><code>false</pre></code><h4>vueComponentPaths</h4><p>A list of file glob patterns to find <code>*.vue</code> components. By default, searches the entire workspace. This needs to be specified due to extra lookups that Vue&#39;s sourcemaps require in Vue CLI 4. You can disable this special handling by setting this to an empty array.</p>
348348
<h5>Default value:</h4><pre><code>[
349349
"${workspaceFolder}/**/*.vue",
@@ -390,7 +390,7 @@
390390
<h5>Default value:</h4><pre><code>{}</pre></code><h4>trace</h4><p>Configures what diagnostic output is produced.</p>
391391
<h5>Default value:</h4><pre><code>false</pre></code><h4>url</h4><p>Will search for a tab with this exact url and attach to it, if found</p>
392392
<h5>Default value:</h4><pre><code>null</pre></code><h4>urlFilter</h4><p>Will search for a page with this url and attach to it, if found. Can have * wildcards.</p>
393-
<h5>Default value:</h4><pre><code>""</pre></code><h4>useWebView</h4><p>(Edge (Chromium) only) When &#39;true&#39;, the debugger will treat the runtime executable as a host application that contains a WebView allowing you to debug the WebView script content.</p>
393+
<h5>Default value:</h4><pre><code>""</pre></code><h4>useWebView</h4><p>An object containing the <code>pipeName</code> of a debug pipe for a UWP hosted Webview2. This is the &quot;MyTestSharedMemory&quot; when creating the pipe &quot;\.\pipe\LOCAL\MyTestSharedMemory&quot;</p>
394394
<h5>Default value:</h4><pre><code>false</pre></code><h4>vueComponentPaths</h4><p>A list of file glob patterns to find <code>*.vue</code> components. By default, searches the entire workspace. This needs to be specified due to extra lookups that Vue&#39;s sourcemaps require in Vue CLI 4. You can disable this special handling by setting this to an empty array.</p>
395395
<h5>Default value:</h4><pre><code>[
396396
"${workspaceFolder}/**/*.vue",

gulpfile.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ async function runWebpack({
219219
base: path.join(__dirname, 'out/src'),
220220
},
221221
},
222+
{
223+
test: '\\.node$', // will be regex'd in the webpackBuild script
224+
loader: 'node-loader',
225+
},
222226
{
223227
test: '\\.css$', // will be regex'd in the webpackBuild script
224228
use: ['style-loader', 'css-loader'],

package-lock.json

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"dependencies": {
5151
"@c4312/chromehash": "^0.3.0",
5252
"@vscode/js-debug-browsers": "^1.0.6",
53+
"@vscode/win32-app-container-tokens": "^0.1.0",
5354
"acorn": "^8.7.0",
5455
"acorn-loose": "^8.3.0",
5556
"astring": "^1.8.1",
@@ -149,6 +150,7 @@
149150
"mocha": "^9.2.2",
150151
"mocha-junit-reporter": "^2.0.2",
151152
"mocha-multi-reporters": "^1.5.1",
153+
"node-loader": "^2.0.0",
152154
"npm-run-all": "^4.1.5",
153155
"nyc": "^15.1.0",
154156
"playwright": "^1.20.1",

src/build/generate-contributions.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ const edgeLaunchConfig: IDebugger<IEdgeLaunchConfiguration> = {
984984
},
985985
useWebView: {
986986
type: 'boolean',
987-
description: refString('edge.useWebView.description'),
987+
description: refString('edge.useWebView.launch.description'),
988988
default: false,
989989
},
990990
address: {
@@ -1022,9 +1022,10 @@ const edgeAttachConfig: IDebugger<IEdgeAttachConfiguration> = {
10221022
configurationAttributes: {
10231023
...chromiumAttachConfigurationAttributes,
10241024
useWebView: {
1025-
type: 'boolean',
1026-
description: refString('edge.useWebView.description'),
1027-
default: false,
1025+
type: 'object',
1026+
properties: { pipeName: { type: 'string' } },
1027+
description: refString('edge.useWebView.attach.description'),
1028+
default: { pipeName: 'MyPipeName' },
10281029
},
10291030
},
10301031
defaults: edgeAttachConfigDefaults,

src/build/strings.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ const strings = {
3838
'extensionHost.snippet.launch.description': 'Launch a VS Code extension in debug mode',
3939
'extensionHost.snippet.launch.label': 'VS Code Extension Development',
4040

41-
'edge.useWebView.description':
42-
"(Edge (Chromium) only) When 'true', the debugger will treat the runtime executable as a host application that contains a WebView allowing you to debug the WebView script content.",
41+
'edge.useWebView.launch.description':
42+
"When 'true', the debugger will treat the runtime executable as a host application that contains a WebView allowing you to debug the WebView script content.",
43+
'edge.useWebView.attach.description':
44+
'An object containing the `pipeName` of a debug pipe for a UWP hosted Webview2. This is the "MyTestSharedMemory" when creating the pipe "\\\\.\\pipe\\LOCAL\\MyTestSharedMemory"',
4345

4446
'chrome.label': 'Web App (Chrome)',
4547
'edge.label': 'Web App (Edge)',

src/cdp/rawPipeTransport.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import { ITransport } from './transport';
6-
import { ILogger, LogTag } from '../common/logging';
7-
import { Duplex, Readable, Writable } from 'stream';
85
import split from 'split2';
9-
import { once } from '../common/objUtils';
6+
import { Duplex, Readable, Writable } from 'stream';
107
import { EventEmitter } from '../common/events';
118
import { HrTime } from '../common/hrnow';
9+
import { ILogger, LogTag } from '../common/logging';
10+
import { once } from '../common/objUtils';
11+
import { ITransport } from './transport';
1212

1313
export class RawPipeTransport implements ITransport {
1414
private readonly messageEmitter = new EventEmitter<[string, HrTime]>();

src/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ export interface IEdgeLaunchConfiguration extends IChromiumLaunchConfiguration {
724724
export interface IEdgeAttachConfiguration extends IChromiumAttachConfiguration {
725725
type: DebugType.Edge;
726726
request: 'attach';
727-
useWebView: boolean;
727+
useWebView: boolean | { pipeName: string };
728728
}
729729

730730
/**

src/dap/errors.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,19 @@ export const sourceMapParseFailed = (compiledUrl: string, message: string) =>
238238
localize('sourcemapParseError', 'Could not read source map for {0}: {1}', compiledUrl, message),
239239
);
240240

241+
export const uwpPipeNotAvailable = () =>
242+
createUserError(
243+
localize('uwpPipeNotAvailable', 'UWP webview debugging is not available on your platform.'),
244+
);
245+
246+
export const noUwpPipeFound = () =>
247+
createUserError(
248+
localize(
249+
'noUwpPipeFound',
250+
'Could not connect to any UWP Webview pipe. Make sure your webview is hosted in debug mode, and that the `pipeName` in your `launch.json` is correct.',
251+
),
252+
);
253+
241254
/**
242255
* Returns if the value looks like a DAP error.
243256
*/

0 commit comments

Comments
 (0)