@vscode/test-web 0.0.57 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/README.md +1 -0
- package/fs-provider/dist/fsExtensionMain.js +27 -11
- package/fs-provider/package-lock.json +8 -10
- package/fs-provider/package.json +2 -1
- package/fs-provider/package.nls.json +2 -0
- package/out/browser/amd/main.js +207 -0
- package/out/browser/esm/main.js +204 -0
- package/out/server/download.js +41 -11
- package/out/{index.js → server/index.js} +24 -5
- package/out/server/workbench.js +50 -16
- package/package.json +7 -7
- package/views/callback.html +123 -0
- package/views/workbench-esm.html +1 -23
- package/views/workbench.html +7 -6
- package/out/index.d.ts +0 -134
|
@@ -8,8 +8,8 @@ exports.open = open;
|
|
|
8
8
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9
9
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
10
10
|
*--------------------------------------------------------------------------------------------*/
|
|
11
|
-
const main_1 = require("./
|
|
12
|
-
const download_1 = require("./
|
|
11
|
+
const main_1 = require("./main");
|
|
12
|
+
const download_1 = require("./download");
|
|
13
13
|
const playwright = require("playwright");
|
|
14
14
|
const minimist = require("minimist");
|
|
15
15
|
const path = require("path");
|
|
@@ -80,8 +80,9 @@ async function getBuild(options) {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
const quality = options.quality || options.version;
|
|
83
|
+
const commit = options.commit;
|
|
83
84
|
const testRunnerDataDir = options.testRunnerDataDir ?? path.resolve(process.cwd(), '.vscode-test-web');
|
|
84
|
-
return await (0, download_1.downloadAndUnzipVSCode)(quality === 'stable' ? 'stable' : 'insider',
|
|
85
|
+
return await (0, download_1.downloadAndUnzipVSCode)(testRunnerDataDir, quality === 'stable' ? 'stable' : 'insider', commit);
|
|
85
86
|
}
|
|
86
87
|
async function open(options) {
|
|
87
88
|
const config = {
|
|
@@ -335,6 +336,20 @@ function validateQuality(quality, version, vsCodeDevPath) {
|
|
|
335
336
|
showHelp();
|
|
336
337
|
process.exit(-1);
|
|
337
338
|
}
|
|
339
|
+
function validateCommit(commit, vsCodeDevPath) {
|
|
340
|
+
if (vsCodeDevPath && commit) {
|
|
341
|
+
console.log(`Sources folder is provided as input, commit is ignored.`);
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
344
|
+
if (commit === undefined || (typeof commit === 'string' && commit.match(/^[0-9a-f]{40}$/))) {
|
|
345
|
+
return commit;
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
console.log(`Invalid format for commit. Expected a 40 character long SHA1 hash.`);
|
|
349
|
+
}
|
|
350
|
+
showHelp();
|
|
351
|
+
process.exit(-1);
|
|
352
|
+
}
|
|
338
353
|
function validatePortNumber(port) {
|
|
339
354
|
if (typeof port === 'string') {
|
|
340
355
|
const number = Number.parseInt(port);
|
|
@@ -351,6 +366,7 @@ function showHelp() {
|
|
|
351
366
|
console.log(` --extensionDevelopmentPath path: A path pointing to an extension under development to include. [Optional]`);
|
|
352
367
|
console.log(` --extensionTestsPath path: A path to a test module to run. [Optional]`);
|
|
353
368
|
console.log(` --quality 'insiders' | 'stable' [Optional, default 'insiders', ignored when running from sources]`);
|
|
369
|
+
console.log(` --commit commitHash [Optional, defaults to latest build version of the given quality, ignored when running from sources]`);
|
|
354
370
|
console.log(` --sourcesPath path: If provided, running from VS Code sources at the given location. [Optional]`);
|
|
355
371
|
console.log(` --open-devtools: If set, opens the dev tools. [Optional]`);
|
|
356
372
|
console.log(` --headless: Whether to hide the browser. Defaults to true when an extensionTestsPath is provided, otherwise false. [Optional]`);
|
|
@@ -377,10 +393,10 @@ async function cliMain() {
|
|
|
377
393
|
});
|
|
378
394
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
379
395
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
380
|
-
const manifest =
|
|
396
|
+
const manifest = JSON.parse(await (0, download_1.readFileInRepo)('package.json'));
|
|
381
397
|
console.log(`${manifest.name}: ${manifest.version}`);
|
|
382
398
|
const options = {
|
|
383
|
-
string: ['extensionDevelopmentPath', 'extensionTestsPath', 'browser', 'browserOption', 'browserType', 'quality', 'version', 'waitForDebugger', 'folder-uri', 'permission', 'extensionPath', 'extensionId', 'sourcesPath', 'host', 'port', 'testRunnerDataDir'],
|
|
399
|
+
string: ['extensionDevelopmentPath', 'extensionTestsPath', 'browser', 'browserOption', 'browserType', 'quality', 'version', 'commit', 'waitForDebugger', 'folder-uri', 'permission', 'extensionPath', 'extensionId', 'sourcesPath', 'host', 'port', 'testRunnerDataDir'],
|
|
384
400
|
boolean: ['open-devtools', 'headless', 'hideServerLog', 'printServerLog', 'help', 'verbose', 'coi', 'esm'],
|
|
385
401
|
unknown: arg => {
|
|
386
402
|
if (arg.startsWith('-')) {
|
|
@@ -404,6 +420,7 @@ async function cliMain() {
|
|
|
404
420
|
const extensionIds = await validateExtensionIds(args.extensionId);
|
|
405
421
|
const vsCodeDevPath = await validatePathOrUndefined(args, 'sourcesPath');
|
|
406
422
|
const quality = validateQuality(args.quality, args.version, vsCodeDevPath);
|
|
423
|
+
const commit = validateCommit(args.commit, vsCodeDevPath);
|
|
407
424
|
const devTools = validateBooleanOrUndefined(args, 'open-devtools');
|
|
408
425
|
const headless = validateBooleanOrUndefined(args, 'headless');
|
|
409
426
|
const permissions = validatePermissions(args.permission);
|
|
@@ -435,6 +452,7 @@ async function cliMain() {
|
|
|
435
452
|
browserOptions,
|
|
436
453
|
browserType,
|
|
437
454
|
quality,
|
|
455
|
+
commit,
|
|
438
456
|
devTools,
|
|
439
457
|
waitForDebugger,
|
|
440
458
|
folderUri,
|
|
@@ -462,6 +480,7 @@ async function cliMain() {
|
|
|
462
480
|
browserOptions,
|
|
463
481
|
browserType,
|
|
464
482
|
quality,
|
|
483
|
+
commit,
|
|
465
484
|
devTools,
|
|
466
485
|
waitForDebugger,
|
|
467
486
|
folderUri,
|
package/out/server/workbench.js
CHANGED
|
@@ -10,12 +10,18 @@ const fs_1 = require("fs");
|
|
|
10
10
|
const vscode_uri_1 = require("vscode-uri");
|
|
11
11
|
const Router = require("@koa/router");
|
|
12
12
|
const extensions_1 = require("./extensions");
|
|
13
|
-
const download_1 = require("./download");
|
|
14
13
|
const mounts_1 = require("./mounts");
|
|
14
|
+
const download_1 = require("./download");
|
|
15
15
|
function asJSON(value) {
|
|
16
16
|
return JSON.stringify(value).replace(/"/g, '"');
|
|
17
17
|
}
|
|
18
18
|
class Workbench {
|
|
19
|
+
baseUrl;
|
|
20
|
+
dev;
|
|
21
|
+
esm;
|
|
22
|
+
devCSSModules;
|
|
23
|
+
builtInExtensions;
|
|
24
|
+
productOverrides;
|
|
19
25
|
constructor(baseUrl, dev, esm, devCSSModules, builtInExtensions = [], productOverrides) {
|
|
20
26
|
this.baseUrl = baseUrl;
|
|
21
27
|
this.dev = dev;
|
|
@@ -30,34 +36,51 @@ class Workbench {
|
|
|
30
36
|
}
|
|
31
37
|
const values = {
|
|
32
38
|
WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
|
|
33
|
-
WORKBENCH_AUTH_SESSION: '',
|
|
34
39
|
WORKBENCH_WEB_BASE_URL: this.baseUrl,
|
|
35
40
|
WORKBENCH_BUILTIN_EXTENSIONS: asJSON(this.builtInExtensions),
|
|
36
|
-
WORKBENCH_MAIN: this.getMain()
|
|
37
|
-
WORKBENCH_DEV_CSS_MODULES: JSON.stringify(this.devCSSModules)
|
|
41
|
+
WORKBENCH_MAIN: await this.getMain()
|
|
38
42
|
};
|
|
39
43
|
try {
|
|
40
|
-
const workbenchTemplate =
|
|
44
|
+
const workbenchTemplate = await (0, download_1.readFileInRepo)(`views/workbench${this.esm ? '-esm' : ''}.html`);
|
|
41
45
|
return workbenchTemplate.replace(/\{\{([^}]+)\}\}/g, (_, key) => values[key] ?? 'undefined');
|
|
42
46
|
}
|
|
43
47
|
catch (e) {
|
|
44
48
|
return String(e);
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
|
-
getMain() {
|
|
51
|
+
async getMain() {
|
|
52
|
+
const lines = [];
|
|
48
53
|
if (this.esm) {
|
|
49
|
-
|
|
54
|
+
let workbenchMain = await (0, download_1.readFileInRepo)(`out/browser/esm/main.js`);
|
|
55
|
+
if (this.dev) {
|
|
56
|
+
lines.push("<script>", `globalThis._VSCODE_CSS_MODULES = ${JSON.stringify(this.devCSSModules)};`, "</script>", "<script>", "const sheet = document.getElementById('vscode-css-modules').sheet;", "globalThis._VSCODE_CSS_LOAD = function (url) { sheet.insertRule(`@import url(${url});`); };", "", "const importMap = { imports: {} };", "for (const cssModule of globalThis._VSCODE_CSS_MODULES) {", " const cssUrl = new URL(cssModule, globalThis._VSCODE_FILE_ROOT).href;", " const jsSrc = `globalThis._VSCODE_CSS_LOAD('${cssUrl}');\\n`;", " const blob = new Blob([jsSrc], { type: 'application/javascript' });", " importMap.imports[cssUrl] = URL.createObjectURL(blob);", "}", "const importMapElement = document.createElement('script');", "importMapElement.type = 'importmap';", "importMapElement.setAttribute('nonce', '1nline-m4p');", "importMapElement.textContent = JSON.stringify(importMap, undefined, 2);", "document.head.appendChild(importMapElement);", "</script>");
|
|
57
|
+
workbenchMain = workbenchMain.replace('./workbench.api', `${this.baseUrl}/out/vs/workbench/workbench.web.main.internal.js`);
|
|
58
|
+
lines.push(`<script type="module">${workbenchMain}</script>`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
workbenchMain = workbenchMain.replace('./workbench.api', `${this.baseUrl}/out/vs/workbench/workbench.web.main.internal.js`);
|
|
62
|
+
lines.push(`<script src="${this.baseUrl}/out/nls.messages.js"></script>`);
|
|
63
|
+
lines.push(`<script type="module">${workbenchMain}</script>`);
|
|
64
|
+
}
|
|
65
|
+
return lines.join('\n');
|
|
50
66
|
}
|
|
51
|
-
|
|
52
|
-
|
|
67
|
+
else {
|
|
68
|
+
let workbenchMain = await (0, download_1.readFileInRepo)(`out/browser/amd/main.js`); // defines a AMD module `vscode-web-browser-main`
|
|
69
|
+
workbenchMain = workbenchMain.replace('./workbench.api', `vs/workbench/workbench.web.main`);
|
|
70
|
+
workbenchMain = workbenchMain + '\nrequire(["vscode-web-browser-main"], function() { });';
|
|
71
|
+
if (this.dev) {
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
lines.push(`<script src="${this.baseUrl}/out/nls.messages.js"></script>`);
|
|
75
|
+
lines.push(`<script src="${this.baseUrl}/out/vs/workbench/workbench.web.main.nls.js"></script>`);
|
|
76
|
+
lines.push(`<script src="${this.baseUrl}/out/vs/workbench/workbench.web.main.js"></script>`);
|
|
77
|
+
}
|
|
78
|
+
lines.push(`<script>${workbenchMain}</script>`);
|
|
53
79
|
}
|
|
54
|
-
return
|
|
55
|
-
+ `<script src="${this.baseUrl}/out/vs/workbench/workbench.web.main.nls.js"></script>`
|
|
56
|
-
+ `<script src="${this.baseUrl}/out/vs/workbench/workbench.web.main.js"></script>`
|
|
57
|
-
+ `<script src="${this.baseUrl}/out/vs/code/browser/workbench/workbench.js"></script>`;
|
|
80
|
+
return lines.join('\n');
|
|
58
81
|
}
|
|
59
82
|
async renderCallback() {
|
|
60
|
-
return await (0, download_1.
|
|
83
|
+
return await (0, download_1.readFileInRepo)(`views/callback.html`);
|
|
61
84
|
}
|
|
62
85
|
}
|
|
63
86
|
async function getWorkbenchOptions(ctx, config) {
|
|
@@ -115,8 +138,10 @@ function default_1(config) {
|
|
|
115
138
|
if (config.build.type === 'sources') {
|
|
116
139
|
const builtInExtensions = await (0, extensions_1.getScannedBuiltinExtensions)(config.build.location);
|
|
117
140
|
const productOverrides = await getProductOverrides(config.build.location);
|
|
118
|
-
const
|
|
119
|
-
|
|
141
|
+
const esm = config.esm || await isESM(config.build.location);
|
|
142
|
+
console.log('Using ESM loader:', esm);
|
|
143
|
+
const devCSSModules = esm ? await getDevCssModules(config.build.location) : [];
|
|
144
|
+
ctx.state.workbench = new Workbench(`${ctx.protocol}://${ctx.host}/static/sources`, true, esm, devCSSModules, builtInExtensions, {
|
|
120
145
|
...productOverrides,
|
|
121
146
|
webEndpointUrlTemplate: `${ctx.protocol}://{{uuid}}.${ctx.host}/static/sources`,
|
|
122
147
|
webviewContentExternalBaseUrlTemplate: `${ctx.protocol}://{{uuid}}.${ctx.host}/static/sources/out/vs/workbench/contrib/webview/browser/pre/`
|
|
@@ -159,3 +184,12 @@ async function getDevCssModules(vsCodeDevLocation) {
|
|
|
159
184
|
const glob = await Promise.resolve().then(() => require('glob'));
|
|
160
185
|
return glob.glob('**/*.css', { cwd: path.join(vsCodeDevLocation, 'out') });
|
|
161
186
|
}
|
|
187
|
+
async function isESM(vsCodeDevLocation) {
|
|
188
|
+
try {
|
|
189
|
+
const packageJSON = await fs_1.promises.readFile(path.join(vsCodeDevLocation, 'out', 'package.json'));
|
|
190
|
+
return JSON.parse(packageJSON.toString()).type === 'module';
|
|
191
|
+
}
|
|
192
|
+
catch (e) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vscode/test-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.59",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"install-extensions": "npm i --prefix=fs-provider && npm i --prefix=sample",
|
|
6
|
-
"compile": "tsc -
|
|
7
|
-
"watch": "tsc -
|
|
6
|
+
"compile": "tsc -b ./ && npm run compile-fs-provider",
|
|
7
|
+
"watch": "tsc -b -w ./",
|
|
8
8
|
"prepack": "npm run compile",
|
|
9
9
|
"test": "eslint src && tsc --noEmit",
|
|
10
10
|
"preversion": "npm test",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"sample-tests": "npm run compile && npm run compile-sample && node . --extensionDevelopmentPath=sample --extensionTestsPath=sample/dist/web/test/suite/index.js --headless=true sample/test-workspace",
|
|
16
16
|
"empty": "npm run compile && node ."
|
|
17
17
|
},
|
|
18
|
-
"main": "./out/index.js",
|
|
18
|
+
"main": "./out/server/index.js",
|
|
19
19
|
"bin": {
|
|
20
|
-
"vscode-test-web": "./out/index.js"
|
|
20
|
+
"vscode-test-web": "./out/server/index.js"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=16"
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"@types/minimist": "^1.2.5",
|
|
52
52
|
"@types/node": "^20.14.9",
|
|
53
53
|
"@types/tar-fs": "^2.0.4",
|
|
54
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
55
|
-
"@typescript-eslint/parser": "^8.
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^8.4.0",
|
|
55
|
+
"@typescript-eslint/parser": "^8.4.0",
|
|
56
56
|
"eslint": "^9.9.1",
|
|
57
57
|
"@tony.ganchev/eslint-plugin-header": "^3.1.2",
|
|
58
58
|
"typescript": "^5.5.4"
|