Skip to content

Commit 1d87317

Browse files
authored
chore: update app container tokens to 0.2.0 (#2194)
* chore: experimental networking by default on recent Node versions It's now good enough to be reasonably useful in Node.js, so turn it on by default. Still have a setting to turn it off. * chore: update app container tokens to 0.2.0 Closes microsoft/vscode#244139 * rm outdated test
1 parent 1cce1d0 commit 1d87317

File tree

8 files changed

+69
-171
lines changed

8 files changed

+69
-171
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
77
- fix: explicitly specify completion ranges ([[vscode#243409](https://github.com/microsoft/vscode/issues/243409)])
88
- fix: memory leak between debug sessions ([#2173](https://github.com/microsoft/vscode-js-debug/issues/2173))
99
- fix: support `npm.scriptRunner: node`
10+
- fix: support "attach to node process" without wmic.exe and on arm64 ([vscode#244139](https://github.com/microsoft/vscode/issues/244139))
11+
- fix: support webview2 debugging on arm64
1012
- chore: enable experimental networking by default on recent Node versions
1113

1214
## 1.97 (January 2025)

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@jridgewell/trace-mapping": "^0.3.22",
5656
"@vscode/js-debug-browsers": "^1.1.2",
5757
"@vscode/l10n": "^0.0.18",
58-
"@vscode/win32-app-container-tokens": "^0.1.0",
58+
"@vscode/win32-app-container-tokens": "^0.2.0",
5959
"acorn": "^8.11.3",
6060
"acorn-loose": "^8.4.0",
6161
"astring": "^1.8.6",

src/build/esbuildPlugins.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@ exports.nativeNodeModulesPlugin = () => ({
3939
setup(build) {
4040
// If a ".node" file is imported within a module in the "file" namespace, resolve
4141
// it to an absolute path and put it into the "node-file" virtual namespace.
42-
build.onResolve({ filter: /\.node$/, namespace: 'file' }, args => ({
43-
path: require.resolve(args.path, { paths: [args.resolveDir] }),
44-
namespace: 'node-file',
45-
}));
42+
build.onResolve({ filter: /\.node$/, namespace: 'file' }, args => {
43+
return ({
44+
path: require.resolve(args.path, { paths: [args.resolveDir] }),
45+
namespace: 'node-file',
46+
});
47+
});
4648

4749
// Files in the "node-file" virtual namespace call "require()" on the
4850
// path from esbuild of the ".node" file in the output directory.
4951
build.onLoad({ filter: /.*/, namespace: 'node-file' }, args => ({
5052
contents: `
51-
import path from ${JSON.stringify(args.path)}
52-
try { module.exports = require(path) }
53+
try { module.exports = require(${JSON.stringify(args.path)}) }
5354
catch {}
5455
`,
5556
}));
@@ -66,7 +67,7 @@ exports.nativeNodeModulesPlugin = () => ({
6667
// these ".node" files.
6768
let opts = build.initialOptions;
6869
opts.loader = opts.loader || {};
69-
opts.loader['.node'] = 'file';
70+
opts.loader['.node'] = 'copy';
7071
},
7172
});
7273

src/common/win32Utils.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*---------------------------------------------------------
2+
* Copyright (C) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------*/
4+
5+
import type * as Win32AppContainerTokens from '@vscode/win32-app-container-tokens';
6+
import { once } from './objUtils';
7+
8+
const load = once((): Promise<typeof Win32AppContainerTokens> => {
9+
if (process.arch === 'arm64') {
10+
return import(
11+
// @ts-expect-error no types here
12+
'@vscode/win32-app-container-tokens/win32-app-container-tokens.win32-arm64-msvc.node'
13+
);
14+
} else if (process.arch === 'x64') {
15+
return import(
16+
// @ts-expect-error no types here
17+
'@vscode/win32-app-container-tokens/win32-app-container-tokens.win32-x64-msvc.node'
18+
);
19+
} else {
20+
throw new Error(`Unsupported architecture ${process.arch}`);
21+
}
22+
});
23+
24+
export function getWinUtils() {
25+
if (process.platform !== 'win32') {
26+
throw new Error('Not running on Windows');
27+
}
28+
29+
return load();
30+
}

src/targets/browser/uwpWebviewBrowserAttacher.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import { inject, injectable, optional } from 'inversify';
66
import { connect, Socket } from 'net';
7+
import { join } from 'path';
78
import type * as vscodeType from 'vscode';
89
import Connection from '../../cdp/connection';
910
import { RawPipeTransport } from '../../cdp/rawPipeTransport';
@@ -12,6 +13,7 @@ import { DebugType } from '../../common/contributionUtils';
1213
import { ILogger } from '../../common/logging';
1314
import { some } from '../../common/promiseUtil';
1415
import { ISourcePathResolver } from '../../common/sourcePathResolver';
16+
import { getWinUtils } from '../../common/win32Utils';
1517
import { AnyLaunchConfiguration, IEdgeAttachConfiguration } from '../../configuration';
1618
import { noUwpPipeFound, uwpPipeNotAvailable } from '../../dap/errors';
1719
import { ProtocolError } from '../../dap/protocolError';
@@ -51,8 +53,8 @@ export class UWPWebviewBrowserAttacher extends BrowserAttacher<IEdgeParamsWithWe
5153
context: ILaunchContext,
5254
params: IEdgeParamsWithWebviewPipe,
5355
): Promise<Connection> {
54-
const { getAppContainerProcessTokens } = await import('@vscode/win32-app-container-tokens');
55-
const pipeNames = getAppContainerProcessTokens(params.useWebView.pipeName);
56+
const { getAppContainerProcessTokens } = await getWinUtils();
57+
const pipeNames = getAppContainerProcessTokens().map(n => join(n, params.useWebView.pipeName));
5658
if (!pipeNames) {
5759
throw new ProtocolError(uwpPipeNotAvailable());
5860
}

0 commit comments

Comments
 (0)