diff --git a/.vscode/launch.json b/.vscode/launch.json index a2ca23c..9d50011 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -41,7 +41,7 @@ "skipFiles": [ "/**" ], - "program": "${workspaceFolder}/out/index.js", + "program": "${workspaceFolder}/out/server/index.js", "args": [ "--browserType=chromium", "--extensionDevelopmentPath=${workspaceFolder}/sample", @@ -58,7 +58,7 @@ "skipFiles": [ "/**" ], - "program": "${workspaceFolder}/out/index.js", + "program": "${workspaceFolder}/out/server/index.js", "args": [ "--browserType=chromium", "--extensionDevelopmentPath=${workspaceFolder}/sample", diff --git a/package.json b/package.json index f5b4635..80f4e91 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "0.0.57", "scripts": { "install-extensions": "npm i --prefix=fs-provider && npm i --prefix=sample", - "compile": "tsc -p ./ && npm run compile-fs-provider", - "watch": "tsc -w -p ./", + "compile": "tsc -b ./ && npm run compile-fs-provider", + "watch": "tsc -b -w ./", "prepack": "npm run compile", "test": "eslint src && tsc --noEmit", "preversion": "npm test", @@ -15,9 +15,9 @@ "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", "empty": "npm run compile && node ." }, - "main": "./out/index.js", + "main": "./out/server/index.js", "bin": { - "vscode-test-web": "./out/index.js" + "vscode-test-web": "./out/server/index.js" }, "engines": { "node": ">=16" diff --git a/src/browser/main.ts b/src/browser/main.ts index 1a208e3..b22ac6b 100644 --- a/src/browser/main.ts +++ b/src/browser/main.ts @@ -2,8 +2,9 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +/// -import { create, IWorkspaceProvider, IWorkbenchConstructionOptions, UriComponents, IWorkspace, URI, IURLCallbackProvider, Emitter, IDisposable} from "./workbench.api"; +import { create, IWorkspaceProvider, IWorkbenchConstructionOptions, UriComponents, IWorkspace, URI, IURLCallbackProvider, Emitter, IDisposable} from './workbench.api'; class WorkspaceProvider implements IWorkspaceProvider { diff --git a/src/browser/tsconfig-amd.json b/src/browser/tsconfig-amd.json new file mode 100644 index 0000000..888a9c7 --- /dev/null +++ b/src/browser/tsconfig-amd.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "AMD", + "lib": [ + "ES2022", + "DOM", + ], + "outDir": "../../out/browser/amd", + "declaration": true, + "strict": true, + "noImplicitAny": false, + "noImplicitThis": true, + "noUnusedLocals": true, + "alwaysStrict": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "sourceMap": false, + "newLine": "lf", + "removeComments": true + } +} \ No newline at end of file diff --git a/src/browser/tsconfig-esm.json b/src/browser/tsconfig-esm.json new file mode 100644 index 0000000..9a43186 --- /dev/null +++ b/src/browser/tsconfig-esm.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ES2022", + "lib": [ + "ES2022", + "DOM", + ], + "outDir": "../../out/browser/esm", + "declaration": true, + "strict": true, + "noImplicitAny": false, + "noImplicitThis": true, + "noUnusedLocals": true, + "alwaysStrict": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "sourceMap": false, + "newLine": "lf", + "removeComments": true + } +} \ No newline at end of file diff --git a/src/server/download.ts b/src/server/download.ts index ba927ad..14923fa 100644 --- a/src/server/download.ts +++ b/src/server/download.ts @@ -90,7 +90,7 @@ export async function downloadAndUnzipVSCode(vscodeTestDir: string, quality: 'st } if (existsSync(vscodeTestDir)) { - await fs.rmdir(vscodeTestDir, { recursive: true, maxRetries: 5 }); + await fs.rm(vscodeTestDir, { recursive: true, maxRetries: 5 }); } await fs.mkdir(vscodeTestDir, { recursive: true }); @@ -196,3 +196,8 @@ export async function fileExists(path: string): Promise { return false; } } + +export async function readFileInRepo(pathInRepo: string): Promise { + return (await fs.readFile(path.resolve(__dirname, '../..', pathInRepo))).toString() +} + diff --git a/src/index.ts b/src/server/index.ts similarity index 99% rename from src/index.ts rename to src/server/index.ts index ea5cd86..1ac1104 100644 --- a/src/index.ts +++ b/src/server/index.ts @@ -6,8 +6,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IConfig, runServer, Static, Sources } from './server/main'; -import { downloadAndUnzipVSCode, directoryExists, fileExists } from './server/download'; +import { IConfig, runServer, Static, Sources } from './main'; +import { downloadAndUnzipVSCode, directoryExists, fileExists, readFileInRepo } from './download'; import * as playwright from 'playwright'; import * as minimist from 'minimist'; @@ -609,7 +609,7 @@ async function cliMain(): Promise { /* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-require-imports */ - const manifest = require('../package.json'); + const manifest = JSON.parse(await readFileInRepo('package.json')); console.log(`${manifest.name}: ${manifest.version}`); const options: minimist.Opts = { diff --git a/src/browser/tsconfig.json b/src/server/tsconfig.json similarity index 80% rename from src/browser/tsconfig.json rename to src/server/tsconfig.json index d990f12..a827d85 100644 --- a/src/browser/tsconfig.json +++ b/src/server/tsconfig.json @@ -1,12 +1,11 @@ { "compilerOptions": { "target": "ES2022", - "module": "ES2022", + "module": "commonjs", "lib": [ - "ES2022", - "DOM", + "ES2022" ], - "outDir": "../../out/browser", + "outDir": "../../out/server", "declaration": true, "strict": true, "noImplicitAny": false, diff --git a/src/server/workbench.ts b/src/server/workbench.ts index 0dde0a3..2b65630 100644 --- a/src/server/workbench.ts +++ b/src/server/workbench.ts @@ -11,6 +11,7 @@ import * as Router from '@koa/router'; import { GalleryExtensionInfo, IConfig } from './main'; import { getScannedBuiltinExtensions, IScannedBuiltinExtension, scanForExtensions, URIComponents } from './extensions'; import { fsProviderExtensionPrefix, fsProviderFolderUri } from './mounts'; +import { readFileInRepo } from './download'; interface IDevelopmentOptions { extensionTestsPath?: URIComponents; @@ -43,55 +44,69 @@ class Workbench { WORKBENCH_AUTH_SESSION: '', WORKBENCH_WEB_BASE_URL: this.baseUrl, WORKBENCH_BUILTIN_EXTENSIONS: asJSON(this.builtInExtensions), - WORKBENCH_MAIN: this.getMain() + WORKBENCH_MAIN: await this.getMain() }; try { - const workbenchTemplate = (await fs.readFile(path.resolve(__dirname, `../../views/workbench${this.esm ? '-esm' : ''}.html`))).toString(); + const workbenchTemplate = await readFileInRepo(`views/workbench${this.esm ? '-esm' : ''}.html`); return workbenchTemplate.replace(/\{\{([^}]+)\}\}/g, (_, key) => values[key] ?? 'undefined'); } catch (e) { return String(e); } } - getMain() { + async getMain() { + const lines: string[] = []; if (this.esm) { - const lines = this.devCSSModules.length > 0 ? [ - "", - "" - ] : []; - lines.push(``); + let workbenchMain = await readFileInRepo(`out/browser/esm/main.js`); + if (this.dev) { + lines.push( + "", + ""); + workbenchMain = workbenchMain.replace('./workbench.api', `${this.baseUrl}/out/vs/workbench/workbench.web.main.js`); + lines.push(``); + } else { + workbenchMain = workbenchMain.replace('./workbench.api', `${this.baseUrl}/out/vs/workbench/workbench.web.main.internal.js`); + lines.push(``); + lines.push(``); + } return lines.join('\n'); + } else { + let workbenchMain = await readFileInRepo(`out/browser/amd/main.js`); // defines a AMD module `vscode-browser-main` + workbenchMain = workbenchMain.replace('./workbench.api', `vs/workbench/workbench.web.main`); + workbenchMain = workbenchMain + '\nrequire(["vscode-browser-main"], function() { });'; + if (this.dev) { + + } else { + lines.push(``); + lines.push(``); + lines.push(``); + } + lines.push(``); } - if (this.dev) { - return ``; - } - return `` - + `` - + `` - + ``; + return lines.join('\n'); } async renderCallback(): Promise { - return (await fs.readFile(path.resolve(__dirname, `../../views/callback.html`))).toString(); + return await readFileInRepo(`views/callback.html`); } } diff --git a/tsconfig.json b/tsconfig.json index 506d8e6..ceaadd5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,26 +1,18 @@ { - "compilerOptions": { - "target": "ES2020", - "module": "commonjs", - "lib": [ - "ES2020" - ], - "outDir": "out", - "declaration": true, - "strict": true, - "noImplicitAny": false, - "noImplicitThis": true, - "noUnusedLocals": true, - "alwaysStrict": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "sourceMap": false, - "newLine": "lf" - }, - "include": [ - "src" - ], - "exclude": [ - "node_modules" - ] + "compilerOptions": { + "incremental": true, + "composite": true + }, + "files": [], + "references": [ + { + "path": "./src/server/tsconfig.json" + }, + { + "path": "./src/browser/tsconfig-esm.json" + }, + { + "path": "./src/browser/tsconfig-amd.json" + } + ] } \ No newline at end of file diff --git a/views/workbench-esm.html b/views/workbench-esm.html index 83040e6..cca0a85 100644 --- a/views/workbench-esm.html +++ b/views/workbench-esm.html @@ -29,6 +29,7 @@ + diff --git a/views/workbench.html b/views/workbench.html index fb184b9..119fda6 100644 --- a/views/workbench.html +++ b/views/workbench.html @@ -39,9 +39,13 @@