vscode 编译过程探索
npm install steps
node build/npm/preinstall.js
- 检查
Node.js
版本是否满足最低要求 - 检查是否使用
npm install
instead ofyarn install
- 检查 C/C++ Compiler Toolchain 是否已安装(仅在 win32 下)
- 安装
node-gyp
in./build/npm/gyp
- 使用
node_gyp
获取已安装的Node.js
和electron
版本列表 - 使用
node_gyp
安装./.npmrc
中指定版本的electron
- 使用
node_gyp
安装./remote/.npmrc
中指定版本的Node.js
node build/npm/postinstall.js
- 从
./build/npm/dirs.js
获取需要install node modules
的目录列表 - 依次
install node modules
./build
./.build
目录会特殊处理
- 设置
git config
git config pull.rebase merges
git config blame.ignoreRevsFile .git-blame-ignore-revs
.\scripts\code.bat
steps
log
PS D:\repos\vscode> .\scripts\code.bat
> code-oss-dev@1.94.2 electron
> node build/lib/electron
> code-oss-dev@1.94.2 compile
> node ./node_modules/gulp/bin/gulp.js compile
[19:46:06] Using gulpfile D:\repos\vscode\gulpfile.js
[19:46:06] Starting 'compile'...
[19:46:06] Starting monaco-typecheck ...
[19:46:06] Starting clean-out ...
[19:46:06] Starting clean-extension-configuration-editing ...
[19:46:06] Starting clean-extension-css-language-features-client ...
[19:46:06] Starting clean-extension-css-language-features-server ...
[19:46:06] Starting clean-extension-debug-auto-launch ...
[19:46:06] Starting clean-extension-debug-server-ready ...
[19:46:06] Starting clean-extension-emmet ...
[19:46:06] Starting clean-extension-extension-editing ...
[19:46:06] Starting clean-extension-git ...
[19:46:06] Starting clean-extension-git-base ...
[19:46:06] Starting clean-extension-github ...
[19:46:06] Starting clean-extension-github-authentication ...
[19:46:06] Starting clean-extension-grunt ...
[19:46:06] Starting clean-extension-gulp ...
[19:46:06] Starting clean-extension-html-language-features-client ...
[19:46:06] Starting clean-extension-html-language-features-server ...
[19:46:06] Starting clean-extension-ipynb ...
[19:46:06] Starting clean-extension-jake ...
[19:46:06] Starting clean-extension-json-language-features-client ...
[19:46:06] Starting clean-extension-json-language-features-server ...
[19:46:06] Starting clean-extension-markdown-language-features-preview-src ...
[19:46:06] Starting clean-extension-markdown-language-features ...
[19:46:06] Starting clean-extension-markdown-math ...
[19:46:06] Starting clean-extension-media-preview ...
[19:46:06] Starting clean-extension-merge-conflict ...
[19:46:06] Starting clean-extension-microsoft-authentication ...
[19:46:06] Starting clean-extension-notebook-renderers ...
[19:46:06] Starting clean-extension-npm ...
[19:46:06] Starting clean-extension-php-language-features ...
[19:46:06] Starting clean-extension-references-view ...
[19:46:06] Starting clean-extension-search-result ...
[19:46:06] Starting clean-extension-simple-browser ...
[19:46:06] Starting clean-extension-tunnel-forwarding ...
[19:46:06] Starting clean-extension-typescript-language-features-test-workspace ...
[19:46:06] Starting clean-extension-typescript-language-features-web ...
[19:46:06] Starting clean-extension-typescript-language-features ...
[19:46:06] Starting clean-extension-vscode-api-tests ...
[19:46:06] Starting clean-extension-vscode-colorize-tests ...
[19:46:06] Starting clean-extension-vscode-test-resolver ...
[19:46:06] Starting clean-extension-vscode-selfhost-test-provider ...
[19:46:06] Starting clean-extension-vscode-selfhost-import-aid ...
[19:46:06] Starting compile-extension-media ...
[19:46:06] Finished clean-out after 316 ms
[19:46:06] Starting build-web-node-paths ...
[19:46:06] Finished build-web-node-paths after 8 ms
[19:46:06] Starting compile-api-proposal-names ...
[19:46:06] Starting compilation api-proposal-names...
[19:46:06] Finished clean-extension-configuration-editing after 331 ms
[19:46:06] Starting compile-extension:configuration-editing ...
[19:46:06] Starting compilation extensions...
[19:46:06] Finished clean-extension-css-language-features-client after 398 ms
[19:46:06] Starting compile-extension:css-language-features-client ...
[19:46:06] Finished clean-extension-css-language-features-server after 415 ms
[19:46:06] Starting compile-extension:css-language-features-server ...
[19:46:06] Finished clean-extension-debug-auto-launch after 430 ms
[19:46:06] Starting compile-extension:debug-auto-launch ...
[19:46:06] Finished clean-extension-debug-server-ready after 438 ms
[19:46:06] Starting compile-extension:debug-server-ready ...
[19:46:06] Finished clean-extension-emmet after 447 ms
[19:46:06] Starting compile-extension:emmet ...
[19:46:06] Finished clean-extension-extension-editing after 473 ms
[19:46:06] Starting compile-extension:extension-editing ...
[19:46:06] Finished clean-extension-git after 483 ms
[19:46:06] Starting compile-extension:git ...
[19:46:06] Finished clean-extension-git-base after 521 ms
[19:46:06] Starting compile-extension:git-base ...
[19:46:06] Finished clean-extension-github after 533 ms
[19:46:06] Starting compile-extension:github ...
[19:46:06] Finished clean-extension-github-authentication after 550 ms
[19:46:06] Starting compile-extension:github-authentication ...
[19:46:06] Finished clean-extension-grunt after 565 ms
[19:46:06] Starting compile-extension:grunt ...
[19:46:06] Finished clean-extension-gulp after 573 ms
[19:46:06] Starting compile-extension:gulp ...
[19:46:06] Finished clean-extension-html-language-features-client after 580 ms
[19:46:06] Starting compile-extension:html-language-features-client ...
[19:46:06] Finished clean-extension-html-language-features-server after 592 ms
[19:46:06] Starting compile-extension:html-language-features-server ...
[19:46:06] Finished clean-extension-ipynb after 612 ms
[19:46:06] Starting compile-extension:ipynb ...
[19:46:06] Finished clean-extension-jake after 626 ms
[19:46:06] Starting compile-extension:jake ...
[19:46:06] Finished clean-extension-json-language-features-client after 634 ms
[19:46:06] Starting compile-extension:json-language-features-client ...
[19:46:06] Finished clean-extension-json-language-features-server after 645 ms
[19:46:06] Starting compile-extension:json-language-features-server ...
[19:46:06] Finished clean-extension-markdown-language-features-preview-src after 653 ms
[19:46:06] Starting compile-extension:markdown-language-features-preview-src ...
[19:46:06] Finished clean-extension-markdown-language-features after 658 ms
[19:46:06] Starting compile-extension:markdown-language-features ...
[19:46:06] Finished clean-extension-markdown-math after 689 ms
[19:46:06] Starting compile-extension:markdown-math ...
[19:46:06] Finished clean-extension-media-preview after 696 ms
[19:46:06] Starting compile-extension:media-preview ...
[19:46:07] Finished clean-extension-merge-conflict after 707 ms
[19:46:07] Starting compile-extension:merge-conflict ...
[19:46:07] Finished clean-extension-microsoft-authentication after 717 ms
[19:46:07] Starting compile-extension:microsoft-authentication ...
[19:46:07] Finished clean-extension-notebook-renderers after 737 ms
[19:46:07] Starting compile-extension:notebook-renderers ...
[19:46:07] Finished clean-extension-npm after 749 ms
[19:46:07] Starting compile-extension:npm ...
[19:46:07] Finished clean-extension-php-language-features after 761 ms
[19:46:07] Starting compile-extension:php-language-features ...
[19:46:07] Finished clean-extension-references-view after 771 ms
[19:46:07] Starting compile-extension:references-view ...
[19:46:07] Finished clean-extension-search-result after 783 ms
[19:46:07] Starting compile-extension:search-result ...
[19:46:07] Finished clean-extension-simple-browser after 790 ms
[19:46:07] Starting compile-extension:simple-browser ...
[19:46:07] Finished clean-extension-tunnel-forwarding after 799 ms
[19:46:07] Starting compile-extension:tunnel-forwarding ...
[19:46:07] Finished clean-extension-typescript-language-features-test-workspace after 808 ms
[19:46:07] Starting compile-extension:typescript-language-features-test-workspace ...
[19:46:07] Finished clean-extension-typescript-language-features-web after 811 ms
[19:46:07] Starting compile-extension:typescript-language-features-web ...
[19:46:07] Finished clean-extension-typescript-language-features after 818 ms
[19:46:07] Starting compile-extension:typescript-language-features ...
[19:46:07] Finished clean-extension-vscode-api-tests after 891 ms
[19:46:07] Starting compile-extension:vscode-api-tests ...
[19:46:07] Finished clean-extension-vscode-colorize-tests after 955 ms
[19:46:07] Starting compile-extension:vscode-colorize-tests ...
[19:46:07] Finished clean-extension-vscode-test-resolver after 961 ms
[19:46:07] Starting compile-extension:vscode-test-resolver ...
[19:46:07] Finished clean-extension-vscode-selfhost-test-provider after 971 ms
[19:46:07] Starting compile-extension:vscode-selfhost-test-provider ...
[19:46:07] Finished clean-extension-vscode-selfhost-import-aid after 987 ms
[19:46:07] Starting compile-extension:vscode-selfhost-import-aid ...
[19:46:07] Finished monaco-typecheck after 1022 ms
[19:46:08] Finished compile-extension:typescript-language-features-test-workspace after 1634 ms
[19:46:08] Finished esbuilding extension media D:\repos\vscode\extensions\markdown-math\esbuild.js with 0 errors.
[19:46:08] Finished esbuilding extension media D:\repos\vscode\extensions\markdown-language-features\esbuild-notebook.js with 0 errors.
[19:46:08] Finished esbuilding extension media D:\repos\vscode\extensions\simple-browser\esbuild-preview.js with 0 errors.
[19:46:08] Finished esbuilding extension media D:\repos\vscode\extensions\markdown-language-features\esbuild-preview.js with 0 errors.
[19:46:08] Finished esbuilding extension media D:\repos\vscode\extensions\notebook-renderers\esbuild.js with 0 errors.
[19:46:08] Finished esbuilding extension media D:\repos\vscode\extensions\ipynb\esbuild.js with 0 errors.
[19:46:08] Finished compile-extension-media after 2442 ms
[19:46:12] Finished compile-extension:debug-server-ready after 5413 ms
[19:46:12] Finished compile-extension:debug-auto-launch after 5422 ms
[19:46:12] Finished compile-extension:gulp after 5277 ms
[19:46:12] Finished compile-extension:grunt after 5285 ms
[19:46:12] Finished compile-extension:markdown-math after 5160 ms
[19:46:12] Finished compile-extension:jake after 5224 ms
[19:46:12] Finished compile-extension:vscode-selfhost-import-aid after 4859 ms
[19:46:13] Finished compile-extension:search-result after 6752 ms
[19:46:16] Finished compile-extension:vscode-colorize-tests after 9476 ms
[19:46:16] Finished compile-extension:tunnel-forwarding after 9634 ms
[19:46:19] Finished compile-extension:simple-browser after 12407 ms
[19:46:19] Finished compile-extension:vscode-test-resolver after 12677 ms
[19:46:22] Finished compile-extension:markdown-language-features-preview-src after 15905 ms
[19:46:23] Finished compile-extension:extension-editing after 16601 ms
[19:46:23] Finished compile-extension:json-language-features-client after 16438 ms
[19:46:23] Finished compile-extension:html-language-features-client after 16501 ms
[19:46:23] Finished compile-extension:git-base after 16565 ms
[19:46:23] Finished compile-extension:configuration-editing after 16757 ms
[19:46:23] Finished compile-extension:css-language-features-client after 16695 ms
[19:46:23] Finished compile-extension:json-language-features-server after 16445 ms
[19:46:23] Finished compile-extension:php-language-features after 16329 ms
[19:46:24] Finished compile-extension:media-preview after 17241 ms
[19:46:24] Finished compile-extension:merge-conflict after 17230 ms
[19:46:24] Finished compile-extension:typescript-language-features-web after 17125 ms
[19:46:24] Finished compile-extension:references-view after 17167 ms
[19:46:25] Finished compile-extension:notebook-renderers after 18167 ms
[19:46:25] Finished compile-extension:npm after 18156 ms
[19:46:27] Finished compile-extension:css-language-features-server after 20525 ms
[19:46:27] Finished compile-extension:css-language-features-server after 20525 ms
[19:46:28] Finished compile-extension:github after 21789 ms
[19:46:28] Finished compile-extension:vscode-selfhost-test-provider after 21348 ms
[19:46:28] Finished compile-extension:ipynb after 21717 ms
[19:46:30] Finished compile-extension:github-authentication after 23165 ms
[19:46:30] Finished compile-extension:microsoft-authentication after 23029 ms
[19:46:30] Finished compilation api-proposal-names with 0 errors after 23440 ms
[19:46:30] Finished compile-api-proposal-names after 23447 ms
[19:46:30] Starting compile-src ...
[19:46:30] Starting compilation...
[19:46:30] Finished compile-extension:vscode-api-tests after 23653 ms
[19:46:31] Finished compile-extension:emmet after 24514 ms
[19:46:33] Finished compile-extension:html-language-features-server after 26293 ms
[19:46:33] Finished compile-extension:git after 26411 ms
[19:46:33] Finished compile-extension:markdown-language-features after 26298 ms
[19:46:33] Finished compilation extensions with 0 errors after 26712 ms
[19:46:33] Finished compile-extension:typescript-language-features after 26375 ms
[19:46:33] Starting compile-extensions ...
[19:46:33] Finished compile-extensions after 0 ms
[19:47:43] Finished compilation with 0 errors after 72884 ms
[19:47:43] Finished compile-src after 73712 ms
[19:47:43] Starting compile-client ...
[19:47:43] Finished compile-client after 0 ms
[19:47:43] Starting compile ...
[19:47:43] Finished compile after 0 ms
[19:47:43] Finished 'compile' after 1.62 min
[19:47:44] Synchronizing built-in extensions...
[19:47:44] You can manage built-in extensions with the --builtin flag
[19:47:44] [local] ms-vscode.js-debug-companion: D:\repos\vscode-js-debug-companion ✔︎
[19:47:44] [local] ms-vscode.js-debug: D:\repos\vscode-js-debug ✔︎
[19:47:44] [local] ms-vscode.vscode-js-profile-table: D:\repos\vscode-js-profile-visualizer ✔︎
[main 2024-10-21T11:47:48.697Z] [CSS_DEV] FAILED to compute CSS data Error: spawn D:\repos\vscode\node_modules\@vscode\ripgrep\bin\rg.exe ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn D:\\repos\\vscode\\node_modules\\@vscode\\ripgrep\\bin\\rg.exe',
path: 'D:\\repos\\vscode\\node_modules\\@vscode\\ripgrep\\bin\\rg.exe',
spawnargs: [
'-g',
'**/*.css',
'--files',
'--no-ignore',
'd:\\repos\\vscode\\out'
]
}
[main 2024-10-21T11:47:48.777Z] update#setState disabled
[main 2024-10-21T11:47:48.779Z] [CSS_DEV] DONE, 0 css modules (84ms)
[3356:1021/194749.295:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/browser/parts/statusbar/media/statusbarpart.css (0)
[3356:1021/194749.295:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/browser/parts/banner/media/bannerpart.css (0)
[3356:1021/194749.295:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/services/progress/browser/media/progressService.css (0)
[3356:1021/194749.318:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/services/userDataProfile/browser/media/userDataProfileView.css (0)
[3356:1021/194749.419:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/preferences/browser/media/preferences.css (0)
[3356:1021/194749.444:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/files/browser/media/explorerviewlet.css (0)
[3356:1021/194749.461:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/search/browser/media/searchview.css (0)
[3356:1021/194749.478:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/debug/browser/media/debug.contribution.css (0)
[3356:1021/194749.478:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/debug/browser/media/debugHover.css (0)
[3356:1021/194749.490:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/browser/actions/media/actions.css (0)
[3356:1021/194749.492:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/debug/browser/media/callStackEditorContribution.css (0)
[3356:1021/194749.499:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/debug/browser/media/repl.css (0)
[3356:1021/194749.501:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/debug/browser/media/debugViewlet.css (0)
[3356:1021/194749.524:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/output/browser/output.css (0)
[3356:1021/194749.525:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/extensions/browser/media/extensionsViewlet.css (0)
[3356:1021/194749.551:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css (0)
[3356:1021/194749.561:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/workspace/browser/media/workspaceTrustEditor.css (0)
[3356:1021/194749.570:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/share/browser/share.css (0)
[3356:1021/194749.570:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/electron-sandbox/media/window.css (0)
[3356:1021/194749.575:INFO:CONSOLE(295)] "[uncaught exception]: TypeError: Failed to fetch dynamically imported module: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/workbench.desktop.main.js", source: file:///D:/repos/vscode/src/bootstrap-window.js (295)
[3356:1021/194749.575:INFO:CONSOLE(298)] "TypeError: Failed to fetch dynamically imported module: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/workbench.desktop.main.js", source: file:///D:/repos/vscode/src/bootstrap-window.js (298)
[3356:1021/194749.581:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/electron-sandbox/actions/media/actions.css (0)
[3356:1021/194749.586:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/base/browser/ui/contextview/contextview.css (0)
[3356:1021/194749.595:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/issue/electron-sandbox/media/newIssueReporter.css (0)
[3356:1021/194749.607:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/contrib/chat/electron-sandbox/actions/media/voiceChatActions.css (0)
[3356:1021/194749.609:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/browser/widget/codeEditor/editor.css (0)
[3356:1021/194749.613:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/bracketMatching/browser/bracketMatching.css (0)
[3356:1021/194749.615:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/anchorSelect/browser/anchorSelect.css (0)
[3356:1021/194749.621:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/dnd/browser/dnd.css (0)
[3356:1021/194749.622:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/inlineProgress/browser/inlineProgressWidget.css (0)
[3356:1021/194749.629:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/folding/browser/folding.css (0)
[3356:1021/194749.630:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/hover/browser/hover.css (0)
[3356:1021/194749.630:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.css (0)
[3356:1021/194749.633:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/links/browser/links.css (0)
[3356:1021/194749.634:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/inPlaceReplace/browser/inPlaceReplace.css (0)
[3356:1021/194749.634:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/linkedEditing/browser/linkedEditing.css (0)
[3356:1021/194749.635:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/placeholderText/browser/placeholderText.css (0)
[3356:1021/194749.641:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.css (0)
[3356:1021/194749.644:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/base/browser/ui/codicons/codicon/codicon.css (0)
[3356:1021/194749.644:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/base/browser/ui/codicons/codicon/codicon-modifiers.css (0)
[3356:1021/194749.664:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/browser/parts/editor/media/sidebysideeditor.css (0)
[3356:1021/194749.666:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/browser/parts/editor/media/editorstatus.css (0)
[3356:1021/194749.666:INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.", source: vscode-file://vscode-app/d:/repos/vscode/out/vs/workbench/browser/parts/editor/media/editorquickaccess.css (0)
^CTerminate batch job (Y/N)?
^CThe system cannot open the device or file specified.
vscode startup steps
startup 源码组织
main.ts
src/main.ts
- import { app } from 'electron';
- app.once() -> onReady() -> startup() -> CodeMain
main.ts(vs/code/electron-main)
src/vs/code/electron-main/main.ts
- CodeMain -> startup() -> CodeApplication
app.ts
src/vs/code/electron-main/app.ts
- CodeApplication -> startup() -> openFirstWindow() -> WindowsMainService
windowsMainService.ts
src/vs/platform/windows/electron-main/windowsMainService.ts
- WindowsMainService -> open() -> doOpen() -> openInBrowserWindow() -> doOpenInBrowserWindow -> CodeWindow -> load()
windowImpl.ts
src/vs/platform/windows/electron-main/windowImpl.ts
- CodeWindow -> load() -> loadURL() -> workbench{?.-dev?.esm}.html
workbench.html
src/vs/code/electron-sandbox/workbench/workbench{?.-dev?.esm}.html
- workbench{?.-dev?.esm}.html
<script src="./workbench.js" type="module"></script>
-> workbench.ts
workbench.ts(vs/code/electron-sandbox/workbench)
src/vs/code/electron-sandbox/workbench/workbench.ts
bootstrapWindow.load('vs/workbench/workbench.desktop.main', {...})
- main()
workbench.desktop.main.ts
src/vs/workbench/workbench.desktop.main.ts
- import workbench common
src/vs/workbench/workbench.common.main.ts
- import workbench (desktop main)
src/vs/workbench/electron-sandbox/desktop.main.ts
src/vs/workbench/electron-sandbox/desktop.contribution.ts
- import workbench parts
src/vs/workbench/electron-sandbox/parts/dialog.contribution.ts
- import workbench services
src/vs/workbench/services/*/electron-sandbox/*Service.ts
src/vs/platform/extensionResourceLoader/common/extensionResourceLoaderService.ts
src/vs/platform/*/electron-sandbox/*Service.ts
registerSingleton(IUserDataInitializationService, new SyncDescriptor(UserDataInitializationService, [[]], true))
- workbench contributions
src/vs/workbench/contrib/*/electron-sandbox/*.contribution.ts
- import workbench common
- export main from workbench (desktop main)
export { main } from 'src/vs/workbench/electron-sandbox/desktop.main.ts'
desktop.main.ts
src/vs/workbench/electron-sandbox/desktop.main.ts
- main() -> DesktopMain -> WindowsMainService -> open() -> Workbench -> startup()
workbench.ts(vs/workbench/browser)
src/vs/workbench/browser/workbench.ts
- Workbench -> startup() -> renderWorkbench() -> createWorkbenchLayout() -> layout()
startup 源码链路
main.ts
ts
// src/main.ts
import { app, protocol, crashReporter, Menu, contentTracing } from 'electron';
app.once('ready', function () {
onReady();
});
async function onReady() {
await startup(codeCachePath, nlsConfig);
}
async function startup(codeCachePath: string | undefined, nlsConfig: INLSConfiguration): Promise<void> {
// Load Main
await import('./vs/code/electron-main/main.js');
}
main.ts(vs/code/electron-main)
ts
// src/vs/code/electron-main/main.ts
// Main Startup
const code = new CodeMain();
code.main();
class CodeMain {
main(): void {
this.startup();
}
private async startup(): Promise<void> {
// 省略大量内容...
// Create services
const [instantiationService, instanceEnvironment, environmentMainService, configurationService, stateMainService, bufferLogger, productService, userDataProfilesMainService] = this.createServices();
// Init services
await this.initServices(environmentMainService, userDataProfilesMainService, configurationService, stateMainService, productService);
// Startup
await instantiationService.invokeFunction(async accessor => {
// Create the main IPC server by trying to be the server
// If this throws an error it means we are not the first
// instance of VS Code running and so we would quit.
const mainProcessNodeIpcServer = await this.claimInstance(logService, environmentMainService, lifecycleMainService, instantiationService, productService, true);
return instantiationService.createInstance(CodeApplication, mainProcessNodeIpcServer, instanceEnvironment).startup();
});
// 省略大量内容...
}
}
app.ts
ts
// src/vs/code/electron-main/app.ts
class CodeApplication {
private windowsMainService: IWindowsMainService | undefined;
async startup(): Promise<void> {
// 省略大量内容...
// Services
const appInstantiationService = await this.initServices(machineId, sqmId, devDeviceId, sharedProcessReady);
// Open Windows
await appInstantiationService.invokeFunction(accessor => this.openFirstWindow(accessor, initialProtocolUrls));
// 省略大量内容...
}
private async openFirstWindow(accessor: ServicesAccessor, initialProtocolUrls: IInitialProtocolUrls | undefined): Promise<ICodeWindow[]> {
const windowsMainService = this.windowsMainService = accessor.get(IWindowsMainService);
this.auxiliaryWindowsMainService = accessor.get(IAuxiliaryWindowsMainService);
const context = isLaunchedFromCli(process.env) ? OpenContext.CLI : OpenContext.DESKTOP;
const args = this.environmentMainService.args;
// open1: Openables can open as windows directly 省略...
// open2: Open URIs
// open3: Started without file/folder arguments -> Force new window
// open4: Started without file/folder arguments -> mac: open-file event received on startup
// open5: default: read paths from cli
return windowsMainService.open({
context,
cli: args,
forceNewWindow: args['new-window'],
diffMode: args.diff,
mergeMode: args.merge,
noRecentEntry,
waitMarkerFileURI,
gotoLineMode: args.goto,
initialStartup: true,
remoteAuthority,
forceProfile,
forceTempProfile
});
}
}
windowsMainService.ts
ts
// src/vs/platform/windows/electron-main/windowsMainService.ts
export class WindowsMainService {
async open(openConfig: IOpenConfiguration): Promise<ICodeWindow[]> {
// 省略大量代码...
// Open based on config
const { windows: usedWindows, filesOpenedInWindow } = await this.doOpen(openConfig, workspacesToOpen, foldersToOpen, emptyWindowsWithBackupsToRestore, openOneEmptyWindow, filesToOpen, foldersToAdd);
// 省略大量代码...
return usedWindows;
}
private async doOpen(
openConfig: IOpenConfiguration,
workspacesToOpen: IWorkspacePathToOpen[],
foldersToOpen: ISingleFolderWorkspacePathToOpen[],
emptyToRestore: IEmptyWindowBackupInfo[],
openOneEmptyWindow: boolean,
filesToOpen: IFilesToOpen | undefined,
foldersToAdd: ISingleFolderWorkspacePathToOpen[]
): Promise<{ windows: ICodeWindow[]; filesOpenedInWindow: ICodeWindow | undefined }> {
// Keep track of used windows and remember
// if files have been opened in one of them
const usedWindows: ICodeWindow[] = [];
let filesOpenedInWindow: ICodeWindow | undefined = undefined;
function addUsedWindow(window: ICodeWindow, openedFiles?: boolean): void {
usedWindows.push(window);
if (openedFiles) {
filesOpenedInWindow = window;
filesToOpen = undefined; // reset `filesToOpen` since files have been opened
}
}
addUsedWindow(await this.openInBrowserWindow({
userEnv: openConfig.userEnv,
cli: openConfig.cli,
initialStartup: openConfig.initialStartup,
filesToOpen,
forceNewWindow: true,
remoteAuthority: filesToOpen.remoteAuthority,
forceNewTabbedWindow: openConfig.forceNewTabbedWindow,
forceProfile: openConfig.forceProfile,
forceTempProfile: openConfig.forceTempProfile
}), true);
// Handle workspaces to open (instructed and to restore)
// 省略大量代码...
// Handle folders to open (instructed and to restore)
// 省略大量代码...
// Handle empty to restore
// 省略大量代码...
// Open empty window either if enforced or when files still have to open
// 省略大量代码...
return { windows: distinct(usedWindows), filesOpenedInWindow };
}
private async openInBrowserWindow(options: IOpenBrowserWindowOptions): Promise<ICodeWindow> {
await this.doOpenInBrowserWindow(window, configuration, options, defaultProfile);
return window;
}
private async doOpenInBrowserWindow(window: ICodeWindow, configuration: INativeWindowConfiguration, options: IOpenBrowserWindowOptions, defaultProfile: IUserDataProfile): Promise<void> {
// 省略大量代码...
// Load it
window.load(configuration);
}
windowImpl.ts
ts
// src/vs/platform/windows/electron-main/windowImpl.ts
class CodeWindow {
protected override _win: electron.BrowserWindow;
load(configuration: INativeWindowConfiguration, options: ILoadOptions = Object.create(null)): void {
// 省略大量代码...
// Load URL
this._win.loadURL(FileAccess.asBrowserUri(`vs/code/electron-sandbox/workbench/workbench${this.environmentMainService.isBuilt ? '' : '-dev'}.html`).toString(true));
// 省略大量代码...
}
}
workbench.html
html
<!-- src/vs/code/electron-sandbox/workbench/workbench.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
http-equiv="Content-Security-Policy"
content="省略..."/>
<!-- Workbench CSS -->
<link rel="stylesheet" href="../../../workbench/workbench.desktop.main.css">
</head>
<body aria-label="">
</body>
<!-- Startup (do not modify order of script tags!) -->
<script src="./workbench.js" type="module"></script>
</html>
workbench.ts(vs/code/electron-sandbox/workbench)
ts
// src/vs/code/electron-sandbox/workbench/workbench.ts
(async function () {
const { result, configuration } = await bootstrapWindow.load<IDesktopMain, INativeWindowConfiguration>('vs/workbench/workbench.desktop.main',
{
// 省略...
}
);
// Load workbench
result.main(configuration);
}());
workbench.desktop.main.ts
ts
// src/vs/workbench/workbench.desktop.main.ts
export { main } from './electron-sandbox/desktop.main.js';
desktop.main.ts
ts
// src\vs\workbench\electron-sandbox\desktop.main.ts
function main(configuration: INativeWindowConfiguration): Promise<void> {
const workbench = new DesktopMain(configuration);
return workbench.open();
}
class DesktopMain {
constructor(
private readonly configuration: INativeWindowConfiguration
) {
super();
this.init();
}
async open(): Promise<void> {
// Create Workbench
const workbench = new Workbench(mainWindow.document.body, { extraClasses: this.getExtraClasses() }, services.serviceCollection, services.logService);
// Startup
const instantiationService = workbench.startup();
}
}
workbench.ts(vs/workbench/browser)
ts
// src\vs\workbench\browser\workbench.ts
class Workbench extends Layout {
startup(): IInstantiationService {
// Services
const instantiationService = this.initServices(this.serviceCollection);
instantiationService.invokeFunction(accessor => {
const lifecycleService = accessor.get(ILifecycleService);
const storageService = accessor.get(IStorageService);
const configurationService = accessor.get(IConfigurationService);
const hostService = accessor.get(IHostService);
const hoverService = accessor.get(IHoverService);
const dialogService = accessor.get(IDialogService);
const notificationService = accessor.get(INotificationService) as NotificationService;
// Layout
this.initLayout(accessor);
// Render Workbench
this.renderWorkbench(instantiationService, notificationService, storageService, configurationService);
// Workbench Layout
this.createWorkbenchLayout();
// Layout
this.layout();
// Restore
this.restore(lifecycleService);
});
return instantiationService;
}
}
startup 源码链路(services)
main.ts
ts
// src/main.ts
import { app, protocol, crashReporter, Menu, contentTracing } from 'electron';
app.once('ready', function () {
onReady();
});
async function onReady() {
await startup(codeCachePath, nlsConfig);
}
async function startup(codeCachePath: string | undefined, nlsConfig: INLSConfiguration): Promise<void> {
// Load Main
await import('./vs/code/electron-main/main.js');
}
main.ts(vs/code/electron-main)
ts
// src/vs/code/electron-main/main.ts
// Main Startup
const code = new CodeMain();
code.main();
class CodeMain {
main(): void {
this.startup();
}
private async startup(): Promise<void> {
try {
// Create services
const [instantiationService, instanceEnvironment, environmentMainService, configurationService, stateMainService, bufferLogger, productService, userDataProfilesMainService] = this.createServices();
// Init services
await this.initServices(environmentMainService, userDataProfilesMainService, configurationService, stateMainService, productService);
// Startup
await instantiationService.invokeFunction(async accessor => {
const logService = accessor.get(ILogService);
const lifecycleMainService = accessor.get(ILifecycleMainService);
const fileService = accessor.get(IFileService);
const loggerService = accessor.get(ILoggerService);
// Create the main IPC server by trying to be the server
// If this throws an error it means we are not the first
// instance of VS Code running and so we would quit.
const mainProcessNodeIpcServer = await this.claimInstance(logService, environmentMainService, lifecycleMainService, instantiationService, productService, true);
// Delay creation of spdlog for perf reasons (https://github.com/microsoft/vscode/issues/72906)
bufferLogger.logger = loggerService.createLogger('main', { name: localize('mainLog', "Main") });
return instantiationService.createInstance(CodeApplication, mainProcessNodeIpcServer, instanceEnvironment).startup();
});
} catch (error) {
instantiationService.invokeFunction(this.quit, error);
}
}
private createServices(): [IInstantiationService, IProcessEnvironment, IEnvironmentMainService, ConfigurationService, StateService, BufferLogger, IProductService, UserDataProfilesMainService] {
const services = new ServiceCollection();
const disposables = new DisposableStore();
process.once('exit', () => disposables.dispose());
// Product
const productService = { _serviceBrand: undefined, ...product };
services.set(IProductService, productService);
// Environment 环境变量服务,保存了诸如根目录、用户目录、插件目录等信息
const environmentMainService = new EnvironmentMainService(this.resolveArgs(), productService);
const instanceEnvironment = this.patchEnvironment(environmentMainService); // Patch `process.env` with the instance's environment
services.set(IEnvironmentMainService, environmentMainService);
// Logger
const loggerService = new LoggerMainService(getLogLevel(environmentMainService), environmentMainService.logsHome);
services.set(ILoggerMainService, loggerService);
// Log: We need to buffer the spdlog logs until we are sure
// we are the only instance running, otherwise we'll have concurrent
// log file access on Windows (https://github.com/microsoft/vscode/issues/41218)
const bufferLogger = new BufferLogger(loggerService.getLogLevel());
const logService = disposables.add(new LogService(bufferLogger, [new ConsoleMainLogger(loggerService.getLogLevel())]));
services.set(ILogService, logService);
// Files 文件存取服务
const fileService = new FileService(logService);
services.set(IFileService, fileService);
const diskFileSystemProvider = new DiskFileSystemProvider(logService);
fileService.registerProvider(Schemas.file, diskFileSystemProvider);
// URI Identity URL 解析
const uriIdentityService = new UriIdentityService(fileService);
services.set(IUriIdentityService, uriIdentityService);
// State 状态服务,它负责对 vscode 的 db 的读写
const stateService = new StateService(SaveStrategy.DELAYED, environmentMainService, logService, fileService);
services.set(IStateReadService, stateService);
services.set(IStateService, stateService);
// User Data Profiles
const userDataProfilesMainService = new UserDataProfilesMainService(stateService, uriIdentityService, environmentMainService, fileService, logService);
services.set(IUserDataProfilesMainService, userDataProfilesMainService);
// Use FileUserDataProvider for user data to
// enable atomic read / write operations.
fileService.registerProvider(Schemas.vscodeUserData, new FileUserDataProvider(Schemas.file, diskFileSystemProvider, Schemas.vscodeUserData, userDataProfilesMainService, uriIdentityService, logService));
// Policy
const policyService = isWindows && productService.win32RegValueName ? disposables.add(new NativePolicyService(logService, productService.win32RegValueName))
: environmentMainService.policyFile ? disposables.add(new FilePolicyService(environmentMainService.policyFile, fileService, logService))
: new NullPolicyService();
services.set(IPolicyService, policyService);
// Configuration
const configurationService = new ConfigurationService(userDataProfilesMainService.defaultProfile.settingsResource, fileService, policyService, logService);
services.set(IConfigurationService, configurationService);
// Lifecycle 生命周期服务,封装了 Electron 的一写生命周期事件,使得消费者能够在这些生命周期钩子里做一些事情
services.set(ILifecycleMainService, new SyncDescriptor(LifecycleMainService, undefined, false));
// Request 请求服务,负责发起 http 请求,背后调用的是 node 的 https 和 http 等模块
services.set(IRequestService, new SyncDescriptor(RequestService, undefined, true));
// Themes 负责编辑器主题相关
services.set(IThemeMainService, new SyncDescriptor(ThemeMainService));
// Signing 应用签名服务
services.set(ISignService, new SyncDescriptor(SignService, undefined, false /* proxied to other processes */));
// Tunnel
services.set(ITunnelService, new SyncDescriptor(TunnelService));
// Protocol (instantiated early and not using sync descriptor for security reasons)
services.set(IProtocolMainService, new ProtocolMainService(environmentMainService, userDataProfilesMainService, logService));
return [new InstantiationService(services, true), instanceEnvironment, environmentMainService, configurationService, stateService, bufferLogger, productService, userDataProfilesMainService];
}
}
app.ts
ts
// src/vs/code/electron-main/app.ts
class CodeApplication {
private windowsMainService: IWindowsMainService | undefined;
private auxiliaryWindowsMainService: IAuxiliaryWindowsMainService | undefined;
private nativeHostMainService: INativeHostMainService | undefined;
constructor(
private readonly mainProcessNodeIpcServer: NodeIPCServer,
private readonly userEnv: IProcessEnvironment,
@IInstantiationService private readonly mainInstantiationService: IInstantiationService,
@ILogService private readonly logService: ILogService,
@ILoggerService private readonly loggerService: ILoggerService,
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IStateService private readonly stateService: IStateService,
@IFileService private readonly fileService: IFileService,
@IProductService private readonly productService: IProductService,
@IUserDataProfilesMainService private readonly userDataProfilesMainService: IUserDataProfilesMainService
) {
super();
this.configureSession();
this.registerListeners();
}
async startup(): Promise<void> {
// 省略大量内容...
// Main process server (electron IPC based)
const mainProcessElectronServer = new ElectronIPCServer();
// Services
const appInstantiationService = await this.initServices(machineId, sqmId, devDeviceId, sharedProcessReady);
// Auth Handler
appInstantiationService.invokeFunction(accessor => accessor.get(IProxyAuthService));
// Transient profiles handler
this._register(appInstantiationService.createInstance(UserDataProfilesHandler));
// Init Channels
appInstantiationService.invokeFunction(accessor => this.initChannels(accessor, mainProcessElectronServer, sharedProcessClient));
// Setup Protocol URL Handlers
const initialProtocolUrls = await appInstantiationService.invokeFunction(accessor => this.setupProtocolUrlHandlers(accessor, mainProcessElectronServer));
// Open Windows
await appInstantiationService.invokeFunction(accessor => this.openFirstWindow(accessor, initialProtocolUrls));
// 省略大量内容...
}
private async openFirstWindow(accessor: ServicesAccessor, initialProtocolUrls: IInitialProtocolUrls | undefined): Promise<ICodeWindow[]> {
const windowsMainService = this.windowsMainService = accessor.get(IWindowsMainService);
this.auxiliaryWindowsMainService = accessor.get(IAuxiliaryWindowsMainService);
const context = isLaunchedFromCli(process.env) ? OpenContext.CLI : OpenContext.DESKTOP;
const args = this.environmentMainService.args;
// open1: Openables can open as windows directly 省略...
// open2: Open URIs
// open3: Started without file/folder arguments -> Force new window
// open4: Started without file/folder arguments -> mac: open-file event received on startup
// open5: default: read paths from cli
return windowsMainService.open({
context,
cli: args,
forceNewWindow: args['new-window'],
diffMode: args.diff,
mergeMode: args.merge,
noRecentEntry,
waitMarkerFileURI,
gotoLineMode: args.goto,
initialStartup: true,
remoteAuthority,
forceProfile,
forceTempProfile
});
}
private async initServices(machineId: string, sqmId: string, devDeviceId: string, sharedProcessReady: Promise<MessagePortClient>): Promise<IInstantiationService> {
const services = new ServiceCollection();
// Update
switch (process.platform) {
case 'win32':
services.set(IUpdateService, new SyncDescriptor(Win32UpdateService));
break;
case 'linux':
if (isLinuxSnap) {
services.set(IUpdateService, new SyncDescriptor(SnapUpdateService, [process.env['SNAP'], process.env['SNAP_REVISION']]));
} else {
services.set(IUpdateService, new SyncDescriptor(LinuxUpdateService));
}
break;
case 'darwin':
services.set(IUpdateService, new SyncDescriptor(DarwinUpdateService));
break;
}
// Windows 用于管理 vscode 的所有的窗口(打开、关闭、激活等等)
services.set(IWindowsMainService, new SyncDescriptor(WindowsMainService, [machineId, sqmId, devDeviceId, this.userEnv], false));
services.set(IAuxiliaryWindowsMainService, new SyncDescriptor(AuxiliaryWindowsMainService, undefined, false));
// Dialogs 对话框管理
const dialogMainService = new DialogMainService(this.logService, this.productService);
services.set(IDialogMainService, dialogMainService);
// Launch
services.set(ILaunchMainService, new SyncDescriptor(LaunchMainService, undefined, false /* proxied to other processes */));
// Diagnostics 应用运行性能诊断
services.set(IDiagnosticsMainService, new SyncDescriptor(DiagnosticsMainService, undefined, false /* proxied to other processes */));
services.set(IDiagnosticsService, ProxyChannel.toService(getDelayedChannel(sharedProcessReady.then(client => client.getChannel('diagnostics')))));
// Issues
services.set(IIssueMainService, new SyncDescriptor(IssueMainService, [this.userEnv]));
// Process
services.set(IProcessMainService, new SyncDescriptor(ProcessMainService, [this.userEnv]));
// Encryption
services.set(IEncryptionMainService, new SyncDescriptor(EncryptionMainService));
// Keyboard Layout
services.set(IKeyboardLayoutMainService, new SyncDescriptor(KeyboardLayoutMainService));
// Native Host
services.set(INativeHostMainService, new SyncDescriptor(NativeHostMainService, undefined, false /* proxied to other processes */));
// Webview Manager
services.set(IWebviewManagerService, new SyncDescriptor(WebviewMainService));
// Menubar 菜单栏管理服务
services.set(IMenubarMainService, new SyncDescriptor(MenubarMainService));
// Extension Host Starter
services.set(IExtensionHostStarter, new SyncDescriptor(ExtensionHostStarter));
// Storage
services.set(IStorageMainService, new SyncDescriptor(StorageMainService));
services.set(IApplicationStorageMainService, new SyncDescriptor(ApplicationStorageMainService));
// Terminal
const ptyHostStarter = new ElectronPtyHostStarter({
graceTime: LocalReconnectConstants.GraceTime,
shortGraceTime: LocalReconnectConstants.ShortGraceTime,
scrollback: this.configurationService.getValue<number>(TerminalSettingId.PersistentSessionScrollback) ?? 100
}, this.configurationService, this.environmentMainService, this.lifecycleMainService, this.logService);
const ptyHostService = new PtyHostService(
ptyHostStarter,
this.configurationService,
this.logService,
this.loggerService
);
services.set(ILocalPtyService, ptyHostService);
// External terminal
if (isWindows) {
services.set(IExternalTerminalMainService, new SyncDescriptor(WindowsExternalTerminalService));
} else if (isMacintosh) {
services.set(IExternalTerminalMainService, new SyncDescriptor(MacExternalTerminalService));
} else if (isLinux) {
services.set(IExternalTerminalMainService, new SyncDescriptor(LinuxExternalTerminalService));
}
// Backups
const backupMainService = new BackupMainService(this.environmentMainService, this.configurationService, this.logService, this.stateService);
services.set(IBackupMainService, backupMainService);
// Workspaces 工作区管理服务
const workspacesManagementMainService = new WorkspacesManagementMainService(this.environmentMainService, this.logService, this.userDataProfilesMainService, backupMainService, dialogMainService);
services.set(IWorkspacesManagementMainService, workspacesManagementMainService);
services.set(IWorkspacesService, new SyncDescriptor(WorkspacesMainService, undefined, false /* proxied to other processes */));
services.set(IWorkspacesHistoryMainService, new SyncDescriptor(WorkspacesHistoryMainService, undefined, false));
// URL handling URL 解析
services.set(IURLService, new SyncDescriptor(NativeURLService, undefined, false /* proxied to other processes */));
// Telemetry
if (supportsTelemetry(this.productService, this.environmentMainService)) {
const isInternal = isInternalTelemetry(this.productService, this.configurationService);
const channel = getDelayedChannel(sharedProcessReady.then(client => client.getChannel('telemetryAppender')));
const appender = new TelemetryAppenderClient(channel);
const commonProperties = resolveCommonProperties(release(), hostname(), process.arch, this.productService.commit, this.productService.version, machineId, sqmId, devDeviceId, isInternal);
const piiPaths = getPiiPathsFromEnvironment(this.environmentMainService);
const config: ITelemetryServiceConfig = { appenders: [appender], commonProperties, piiPaths, sendErrorTelemetry: true };
services.set(ITelemetryService, new SyncDescriptor(TelemetryService, [config], false));
} else {
services.set(ITelemetryService, NullTelemetryService);
}
// Default Extensions Profile Init
services.set(IExtensionsProfileScannerService, new SyncDescriptor(ExtensionsProfileScannerService, undefined, true));
services.set(IExtensionsScannerService, new SyncDescriptor(ExtensionsScannerService, undefined, true));
// Utility Process Worker
services.set(IUtilityProcessWorkerMainService, new SyncDescriptor(UtilityProcessWorkerMainService, undefined, true));
// Proxy Auth
services.set(IProxyAuthService, new SyncDescriptor(ProxyAuthService));
// Dev Only: CSS service (for ESM)
services.set(ICSSDevelopmentService, new SyncDescriptor(CSSDevelopmentService, undefined, true));
if (this.productService.quality !== 'stable') {
// extensions signature verification service
services.set(IExtensionSignatureVerificationService, new SyncDescriptor(ExtensionSignatureVerificationService, undefined, true));
}
// Init services that require it
await Promises.settled([
backupMainService.initialize(),
workspacesManagementMainService.initialize()
]);
return this.mainInstantiationService.createChild(services);
}
}
windowsMainService.ts
ts
// src/vs/platform/windows/electron-main/windowsMainService.ts
export class WindowsMainService {
constructor(
private readonly machineId: string,
private readonly sqmId: string,
private readonly devDeviceId: string,
private readonly initialUserEnv: IProcessEnvironment,
@ILogService private readonly logService: ILogService,
@ILoggerMainService private readonly loggerService: ILoggerMainService,
@IStateService private readonly stateService: IStateService,
@IPolicyService private readonly policyService: IPolicyService,
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
@IUserDataProfilesMainService private readonly userDataProfilesMainService: IUserDataProfilesMainService,
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
@IBackupMainService private readonly backupMainService: IBackupMainService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IWorkspacesHistoryMainService private readonly workspacesHistoryMainService: IWorkspacesHistoryMainService, // 工作区历史
@IWorkspacesManagementMainService private readonly workspacesManagementMainService: IWorkspacesManagementMainService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IDialogMainService private readonly dialogMainService: IDialogMainService,
@IFileService private readonly fileService: IFileService,
@IProtocolMainService private readonly protocolMainService: IProtocolMainService,
@IThemeMainService private readonly themeMainService: IThemeMainService,
@IAuxiliaryWindowsMainService private readonly auxiliaryWindowsMainService: IAuxiliaryWindowsMainService,
@ICSSDevelopmentService private readonly cssDevelopmentService: ICSSDevelopmentService
) {
super();
this.registerListeners();
}
async open(openConfig: IOpenConfiguration): Promise<ICodeWindow[]> {
// 省略大量代码...
// Open based on config
const { windows: usedWindows, filesOpenedInWindow } = await this.doOpen(openConfig, workspacesToOpen, foldersToOpen, emptyWindowsWithBackupsToRestore, openOneEmptyWindow, filesToOpen, foldersToAdd);
// 省略大量代码...
return usedWindows;
}
private async doOpen(
openConfig: IOpenConfiguration,
workspacesToOpen: IWorkspacePathToOpen[],
foldersToOpen: ISingleFolderWorkspacePathToOpen[],
emptyToRestore: IEmptyWindowBackupInfo[],
openOneEmptyWindow: boolean,
filesToOpen: IFilesToOpen | undefined,
foldersToAdd: ISingleFolderWorkspacePathToOpen[]
): Promise<{ windows: ICodeWindow[]; filesOpenedInWindow: ICodeWindow | undefined }> {
// Keep track of used windows and remember
// if files have been opened in one of them
const usedWindows: ICodeWindow[] = [];
let filesOpenedInWindow: ICodeWindow | undefined = undefined;
function addUsedWindow(window: ICodeWindow, openedFiles?: boolean): void {
usedWindows.push(window);
if (openedFiles) {
filesOpenedInWindow = window;
filesToOpen = undefined; // reset `filesToOpen` since files have been opened
}
}
addUsedWindow(await this.openInBrowserWindow({
userEnv: openConfig.userEnv,
cli: openConfig.cli,
initialStartup: openConfig.initialStartup,
filesToOpen,
forceNewWindow: true,
remoteAuthority: filesToOpen.remoteAuthority,
forceNewTabbedWindow: openConfig.forceNewTabbedWindow,
forceProfile: openConfig.forceProfile,
forceTempProfile: openConfig.forceTempProfile
}), true);
// Handle workspaces to open (instructed and to restore)
// 省略大量代码...
// Handle folders to open (instructed and to restore)
// 省略大量代码...
// Handle empty to restore
// 省略大量代码...
// Open empty window either if enforced or when files still have to open
// 省略大量代码...
return { windows: distinct(usedWindows), filesOpenedInWindow };
}
private async openInBrowserWindow(options: IOpenBrowserWindowOptions): Promise<ICodeWindow> {
await this.doOpenInBrowserWindow(window, configuration, options, defaultProfile);
return window;
}
private async doOpenInBrowserWindow(window: ICodeWindow, configuration: INativeWindowConfiguration, options: IOpenBrowserWindowOptions, defaultProfile: IUserDataProfile): Promise<void> {
// 省略大量代码...
// Load it
window.load(configuration);
}
windowImpl.ts
ts
// src/vs/platform/windows/electron-main/windowImpl.ts
class CodeWindow {
protected override _win: electron.BrowserWindow;
constructor(
config: IWindowCreationOptions,
@ILogService logService: ILogService,
@ILoggerMainService private readonly loggerMainService: ILoggerMainService,
@IEnvironmentMainService environmentMainService: IEnvironmentMainService,
@IPolicyService private readonly policyService: IPolicyService,
@IUserDataProfilesMainService private readonly userDataProfilesService: IUserDataProfilesMainService,
@IFileService private readonly fileService: IFileService,
@IApplicationStorageMainService private readonly applicationStorageMainService: IApplicationStorageMainService,
@IStorageMainService private readonly storageMainService: IStorageMainService,
@IConfigurationService configurationService: IConfigurationService,
@IThemeMainService private readonly themeMainService: IThemeMainService,
@IWorkspacesManagementMainService private readonly workspacesManagementMainService: IWorkspacesManagementMainService,
@IBackupMainService private readonly backupMainService: IBackupMainService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IDialogMainService private readonly dialogMainService: IDialogMainService,
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
@IProductService private readonly productService: IProductService,
@IProtocolMainService private readonly protocolMainService: IProtocolMainService,
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
@IStateService stateService: IStateService,
@IInstantiationService instantiationService: IInstantiationService
) {
super(configurationService, stateService, environmentMainService, logService);
const options = instantiationService.invokeFunction(defaultBrowserWindowOptions, this.windowState, undefined, {
preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-sandbox/preload.js').fsPath,
additionalArguments: [`--vscode-window-config=${this.configObjectUrl.resource.toString()}`],
v8CacheOptions: this.environmentMainService.useCodeCache ? 'bypassHeatCheck' : 'none',
});
}
load(configuration: INativeWindowConfiguration, options: ILoadOptions = Object.create(null)): void {
// 省略大量代码...
// Load URL
this._win.loadURL(FileAccess.asBrowserUri(`vs/code/electron-sandbox/workbench/workbench${this.environmentMainService.isBuilt ? '' : '-dev'}.html`).toString(true));
// 省略大量代码...
}
}
workbench.html
html
<!-- src/vs/code/electron-sandbox/workbench/workbench.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
http-equiv="Content-Security-Policy"
content="省略..."/>
<!-- Workbench CSS -->
<link rel="stylesheet" href="../../../workbench/workbench.desktop.main.css">
</head>
<body aria-label="">
</body>
<!-- Startup (do not modify order of script tags!) -->
<script src="./workbench.js" type="module"></script>
</html>
workbench.ts(vs/code/electron-sandbox/workbench)
ts
// src/vs/code/electron-sandbox/workbench/workbench.ts
(async function () {
const { result, configuration } = await bootstrapWindow.load<IDesktopMain, INativeWindowConfiguration>('vs/workbench/workbench.desktop.main',
{
// 省略...
}
);
// Load workbench
result.main(configuration);
}());
workbench.desktop.main.ts
ts
// src/vs/workbench/workbench.desktop.main.ts
// workbench services
import './services/textfile/electron-sandbox/nativeTextFileService.js';
import './services/dialogs/electron-sandbox/fileDialogService.js';
import './services/workspaces/electron-sandbox/workspacesService.js';
import './services/menubar/electron-sandbox/menubarService.js';
import './services/update/electron-sandbox/updateService.js';
import './services/url/electron-sandbox/urlService.js';
import './services/lifecycle/electron-sandbox/lifecycleService.js';
import './services/title/electron-sandbox/titleService.js';
import './services/host/electron-sandbox/nativeHostService.js';
import './services/request/electron-sandbox/requestService.js';
import './services/clipboard/electron-sandbox/clipboardService.js';
import './services/contextmenu/electron-sandbox/contextmenuService.js';
import './services/workspaces/electron-sandbox/workspaceEditingService.js';
import './services/configurationResolver/electron-sandbox/configurationResolverService.js';
import './services/accessibility/electron-sandbox/accessibilityService.js';
import './services/keybinding/electron-sandbox/nativeKeyboardLayout.js';
import './services/path/electron-sandbox/pathService.js';
import './services/themes/electron-sandbox/nativeHostColorSchemeService.js';
import './services/extensionManagement/electron-sandbox/extensionManagementService.js';
import './services/encryption/electron-sandbox/encryptionService.js';
import './services/secrets/electron-sandbox/secretStorageService.js';
import './services/localization/electron-sandbox/languagePackService.js';
import './services/telemetry/electron-sandbox/telemetryService.js';
import './services/extensions/electron-sandbox/extensionHostStarter.js';
import '../platform/extensionResourceLoader/common/extensionResourceLoaderService.js';
import './services/localization/electron-sandbox/localeService.js';
import './services/extensions/electron-sandbox/extensionsScannerService.js';
import './services/extensionManagement/electron-sandbox/extensionManagementServerService.js';
import './services/extensionManagement/electron-sandbox/extensionTipsService.js';
import './services/userDataSync/electron-sandbox/userDataSyncService.js';
import './services/userDataSync/electron-sandbox/userDataAutoSyncService.js';
import './services/timer/electron-sandbox/timerService.js';
import './services/environment/electron-sandbox/shellEnvironmentService.js';
import './services/integrity/electron-sandbox/integrityService.js';
import './services/workingCopy/electron-sandbox/workingCopyBackupService.js';
import './services/checksum/electron-sandbox/checksumService.js';
import '../platform/remote/electron-sandbox/sharedProcessTunnelService.js';
import './services/tunnel/electron-sandbox/tunnelService.js';
import '../platform/diagnostics/electron-sandbox/diagnosticsService.js';
import '../platform/profiling/electron-sandbox/profilingService.js';
import '../platform/telemetry/electron-sandbox/customEndpointTelemetryService.js';
import '../platform/remoteTunnel/electron-sandbox/remoteTunnelService.js';
import './services/files/electron-sandbox/elevatedFileService.js';
import './services/search/electron-sandbox/searchService.js';
import './services/workingCopy/electron-sandbox/workingCopyHistoryService.js';
import './services/userDataSync/browser/userDataSyncEnablementService.js';
import './services/extensions/electron-sandbox/nativeExtensionService.js';
import '../platform/userDataProfile/electron-sandbox/userDataProfileStorageService.js';
import './services/auxiliaryWindow/electron-sandbox/auxiliaryWindowService.js';
import '../platform/extensionManagement/electron-sandbox/extensionsProfileScannerService.js';
import { registerSingleton } from '../platform/instantiation/common/extensions.js';
import { IUserDataInitializationService, UserDataInitializationService } from './services/userData/browser/userDataInit.js';
import { SyncDescriptor } from '../platform/instantiation/common/descriptors.js';
registerSingleton(IUserDataInitializationService, new SyncDescriptor(UserDataInitializationService, [[]], true));
// workbench contributions
// Logs
import './contrib/logs/electron-sandbox/logs.contribution.js';
// Localizations
import './contrib/localization/electron-sandbox/localization.contribution.js';
// Explorer
import './contrib/files/electron-sandbox/fileActions.contribution.js';
// CodeEditor Contributions
import './contrib/codeEditor/electron-sandbox/codeEditor.contribution.js';
// Debug
import './contrib/debug/electron-sandbox/extensionHostDebugService.js';
// Extensions Management
import './contrib/extensions/electron-sandbox/extensions.contribution.js';
// Issues
import './contrib/issue/electron-sandbox/issue.contribution.js';
// Process
import './contrib/issue/electron-sandbox/process.contribution.js';
// Remote
import './contrib/remote/electron-sandbox/remote.contribution.js';
// Configuration Exporter
import './contrib/configExporter/electron-sandbox/configurationExportHelper.contribution.js';
// Terminal
import './contrib/terminal/electron-sandbox/terminal.contribution.js';
// Themes
import './contrib/themes/browser/themes.test.contribution.js';
import './services/themes/electron-sandbox/themes.contribution.js';
// User Data Sync
import './contrib/userDataSync/electron-sandbox/userDataSync.contribution.js';
// Tags
import './contrib/tags/electron-sandbox/workspaceTagsService.js';
import './contrib/tags/electron-sandbox/tags.contribution.js';
// Performance
import './contrib/performance/electron-sandbox/performance.contribution.js';
// Tasks
import './contrib/tasks/electron-sandbox/taskService.js';
// External terminal
import './contrib/externalTerminal/electron-sandbox/externalTerminal.contribution.js';
// Webview
import './contrib/webview/electron-sandbox/webview.contribution.js';
// Splash
import './contrib/splash/electron-sandbox/splash.contribution.js';
// Local History
import './contrib/localHistory/electron-sandbox/localHistory.contribution.js';
// Merge Editor
import './contrib/mergeEditor/electron-sandbox/mergeEditor.contribution.js';
// Multi Diff Editor
import './contrib/multiDiffEditor/browser/multiDiffEditor.contribution.js';
// Remote Tunnel
import './contrib/remoteTunnel/electron-sandbox/remoteTunnel.contribution.js';
// Chat
import './contrib/chat/electron-sandbox/chat.contribution.js';
import './contrib/inlineChat/electron-sandbox/inlineChat.contribution.js';
import './contrib/chat/common/chatInstallEntitlement.contribution.js';
import './contrib/chat/browser/chatMovedView.contribution.js';
// Encryption
import './contrib/encryption/electron-sandbox/encryption.contribution.js';
// Emergency Alert
import './contrib/emergencyAlert/electron-sandbox/emergencyAlert.contribution.js';
export { main } from './electron-sandbox/desktop.main.js';
desktop.main.ts
ts
// src\vs\workbench\electron-sandbox\desktop.main.ts
function main(configuration: INativeWindowConfiguration): Promise<void> {
const workbench = new DesktopMain(configuration);
return workbench.open();
}
class DesktopMain {
constructor(
private readonly configuration: INativeWindowConfiguration
) {
super();
this.init();
}
async open(): Promise<void> {
// Init services and wait for DOM to be ready in parallel
const [services] = await Promise.all([this.initServices(), domContentLoaded(mainWindow)]);
// Create Workbench
const workbench = new Workbench(mainWindow.document.body, { extraClasses: this.getExtraClasses() }, services.serviceCollection, services.logService);
// Startup
const instantiationService = workbench.startup();
}
private async initServices(): Promise<{ serviceCollection: ServiceCollection; logService: ILogService; storageService: NativeWorkbenchStorageService; configurationService: IConfigurationService }> {
const serviceCollection = new ServiceCollection();
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// NOTE: Please do NOT register services here. Use `registerSingleton()`
// from `workbench.common.main.ts` if the service is shared between
// desktop and web or `workbench.desktop.main.ts` if the service
// is desktop only.
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Main Process
const mainProcessService = this._register(new ElectronIPCMainProcessService(this.configuration.windowId));
serviceCollection.set(IMainProcessService, mainProcessService);
// Policies
const policyService = this.configuration.policiesData ? new PolicyChannelClient(this.configuration.policiesData, mainProcessService.getChannel('policy')) : new NullPolicyService();
serviceCollection.set(IPolicyService, policyService);
// Product
const productService: IProductService = { _serviceBrand: undefined, ...product };
serviceCollection.set(IProductService, productService);
// Environment
const environmentService = new NativeWorkbenchEnvironmentService(this.configuration, productService);
serviceCollection.set(INativeWorkbenchEnvironmentService, environmentService);
// Logger
const loggers = [
...this.configuration.loggers.global.map(loggerResource => ({ ...loggerResource, resource: URI.revive(loggerResource.resource) })),
...this.configuration.loggers.window.map(loggerResource => ({ ...loggerResource, resource: URI.revive(loggerResource.resource), hidden: true })),
];
const loggerService = new LoggerChannelClient(this.configuration.windowId, this.configuration.logLevel, environmentService.windowLogsPath, loggers, mainProcessService.getChannel('logger'));
serviceCollection.set(ILoggerService, loggerService);
// Log
const logService = this._register(new NativeLogService(loggerService, environmentService));
serviceCollection.set(ILogService, logService);
if (isCI) {
logService.info('workbench#open()'); // marking workbench open helps to diagnose flaky integration/smoke tests
}
if (logService.getLevel() === LogLevel.Trace) {
logService.trace('workbench#open(): with configuration', safeStringify({ ...this.configuration, nls: undefined /* exclude large property */ }));
}
// Shared Process
const sharedProcessService = new SharedProcessService(this.configuration.windowId, logService);
serviceCollection.set(ISharedProcessService, sharedProcessService);
// Utility Process Worker
const utilityProcessWorkerWorkbenchService = new UtilityProcessWorkerWorkbenchService(this.configuration.windowId, logService, mainProcessService);
serviceCollection.set(IUtilityProcessWorkerWorkbenchService, utilityProcessWorkerWorkbenchService);
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// NOTE: Please do NOT register services here. Use `registerSingleton()`
// from `workbench.common.main.ts` if the service is shared between
// desktop and web or `workbench.desktop.main.ts` if the service
// is desktop only.
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Sign
const signService = ProxyChannel.toService<ISignService>(mainProcessService.getChannel('sign'));
serviceCollection.set(ISignService, signService);
// Files
const fileService = this._register(new FileService(logService));
serviceCollection.set(IFileService, fileService);
// Remote
const remoteAuthorityResolverService = new RemoteAuthorityResolverService(productService, new ElectronRemoteResourceLoader(environmentService.window.id, mainProcessService, fileService));
serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService);
// Local Files
const diskFileSystemProvider = this._register(new DiskFileSystemProvider(mainProcessService, utilityProcessWorkerWorkbenchService, logService, loggerService));
fileService.registerProvider(Schemas.file, diskFileSystemProvider);
// URI Identity
const uriIdentityService = new UriIdentityService(fileService);
serviceCollection.set(IUriIdentityService, uriIdentityService);
// User Data Profiles
const userDataProfilesService = new UserDataProfilesService(this.configuration.profiles.all, URI.revive(this.configuration.profiles.home).with({ scheme: environmentService.userRoamingDataHome.scheme }), mainProcessService.getChannel('userDataProfiles'));
serviceCollection.set(IUserDataProfilesService, userDataProfilesService);
const userDataProfileService = new UserDataProfileService(reviveProfile(this.configuration.profiles.profile, userDataProfilesService.profilesHome.scheme));
serviceCollection.set(IUserDataProfileService, userDataProfileService);
// Use FileUserDataProvider for user data to
// enable atomic read / write operations.
fileService.registerProvider(Schemas.vscodeUserData, this._register(new FileUserDataProvider(Schemas.file, diskFileSystemProvider, Schemas.vscodeUserData, userDataProfilesService, uriIdentityService, logService)));
// Remote Agent
const remoteSocketFactoryService = new RemoteSocketFactoryService();
remoteSocketFactoryService.register(RemoteConnectionType.WebSocket, new BrowserSocketFactory(null));
serviceCollection.set(IRemoteSocketFactoryService, remoteSocketFactoryService);
const remoteAgentService = this._register(new RemoteAgentService(remoteSocketFactoryService, userDataProfileService, environmentService, productService, remoteAuthorityResolverService, signService, logService));
serviceCollection.set(IRemoteAgentService, remoteAgentService);
// Remote Files
this._register(RemoteFileSystemProviderClient.register(remoteAgentService, fileService, logService));
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// NOTE: Please do NOT register services here. Use `registerSingleton()`
// from `workbench.common.main.ts` if the service is shared between
// desktop and web or `workbench.desktop.main.ts` if the service
// is desktop only.
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Create services that require resolving in parallel
const workspace = this.resolveWorkspaceIdentifier(environmentService);
const [configurationService, storageService] = await Promise.all([
this.createWorkspaceService(workspace, environmentService, userDataProfileService, userDataProfilesService, fileService, remoteAgentService, uriIdentityService, logService, policyService).then(service => {
// Workspace
serviceCollection.set(IWorkspaceContextService, service);
// Configuration
serviceCollection.set(IWorkbenchConfigurationService, service);
return service;
}),
this.createStorageService(workspace, environmentService, userDataProfileService, userDataProfilesService, mainProcessService).then(service => {
// Storage
serviceCollection.set(IStorageService, service);
return service;
}),
this.createKeyboardLayoutService(mainProcessService).then(service => {
// KeyboardLayout
serviceCollection.set(INativeKeyboardLayoutService, service);
return service;
})
]);
// Workspace Trust Service
const workspaceTrustEnablementService = new WorkspaceTrustEnablementService(configurationService, environmentService);
serviceCollection.set(IWorkspaceTrustEnablementService, workspaceTrustEnablementService);
const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService, fileService);
serviceCollection.set(IWorkspaceTrustManagementService, workspaceTrustManagementService);
// Update workspace trust so that configuration is updated accordingly
configurationService.updateWorkspaceTrust(workspaceTrustManagementService.isWorkspaceTrusted());
this._register(workspaceTrustManagementService.onDidChangeTrust(() => configurationService.updateWorkspaceTrust(workspaceTrustManagementService.isWorkspaceTrusted())));
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// NOTE: Please do NOT register services here. Use `registerSingleton()`
// from `workbench.common.main.ts` if the service is shared between
// desktop and web or `workbench.desktop.main.ts` if the service
// is desktop only.
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
return { serviceCollection, logService, storageService, configurationService };
}
}
workbench.ts(vs/workbench/browser)
ts
// src\vs\workbench\browser\workbench.ts
class Workbench extends Layout {
startup(): IInstantiationService {
// Services
const instantiationService = this.initServices(this.serviceCollection);
instantiationService.invokeFunction(accessor => {
const lifecycleService = accessor.get(ILifecycleService);
const storageService = accessor.get(IStorageService);
const configurationService = accessor.get(IConfigurationService);
const hostService = accessor.get(IHostService);
const hoverService = accessor.get(IHoverService);
const dialogService = accessor.get(IDialogService);
const notificationService = accessor.get(INotificationService) as NotificationService;
// Layout
this.initLayout(accessor);
// Render Workbench
this.renderWorkbench(instantiationService, notificationService, storageService, configurationService);
// Workbench Layout
this.createWorkbenchLayout();
// Layout
this.layout();
// Restore
this.restore(lifecycleService);
});
return instantiationService;
}
}
registerSingleton
ts
// src/vs/editor/browser/services/hoverService/hoverService.ts
registerSingleton(IHoverService, HoverService, InstantiationType.Delayed);
// src/vs/editor/browser/widget/diffEditor/diffProviderFactoryService.ts
registerSingleton(IDiffProviderFactoryService, WorkerBasedDiffProviderFactoryService, InstantiationType.Delayed);
// src/vs/editor/common/languages/languageConfigurationRegistry.ts
registerSingleton(ILanguageConfigurationService, LanguageConfigurationService, InstantiationType.Delayed);
// src/vs/editor/common/services/languageFeatureDebounce.ts
registerSingleton(ILanguageFeatureDebounceService, LanguageFeatureDebounceService, InstantiationType.Delayed);
// src/vs/editor/common/services/languageFeaturesService.ts
registerSingleton(ILanguageFeaturesService, LanguageFeaturesService, InstantiationType.Delayed);
// src/vs/editor/common/services/semanticTokensStylingService.ts
registerSingleton(ISemanticTokensStylingService, SemanticTokensStylingService, InstantiationType.Delayed);
// src/vs/editor/common/services/treeViewsDndService.ts
registerSingleton(ITreeViewsDnDService, TreeViewsDnDService, InstantiationType.Delayed);
// src/vs/editor/contrib/codelens/browser/codeLensCache.ts
registerSingleton(ICodeLensCache, CodeLensCache, InstantiationType.Delayed);
// src/vs/editor/contrib/documentSymbols/browser/outlineModel.ts
registerSingleton(IOutlineModelService, OutlineModelService, InstantiationType.Delayed);
// src/vs/editor/contrib/editorState/browser/keybindingCancellation.ts
registerSingleton(IEditorCancellationTokens, class implements IEditorCancellationTokens {
// src/vs/editor/contrib/gotoError/browser/markerNavigationService.ts
registerSingleton(IMarkerNavigationService, MarkerNavigationService, InstantiationType.Delayed);
// src/vs/editor/contrib/gotoSymbol/browser/symbolNavigation.ts
registerSingleton(ISymbolNavigationService, SymbolNavigationService, InstantiationType.Delayed);
// src/vs/editor/contrib/inlayHints/browser/inlayHintsController.ts
registerSingleton(IInlayHintsCache, InlayHintsCache, InstantiationType.Delayed);
// src/vs/editor/contrib/peekView/browser/peekView.ts
registerSingleton(IPeekViewService, class implements IPeekViewService {
// src/vs/editor/contrib/suggest/browser/suggestMemory.ts
registerSingleton(ISuggestMemoryService, SuggestMemoryService, InstantiationType.Delayed);
// src/vs/editor/standalone/browser/standaloneCodeEditorService.ts
registerSingleton(ICodeEditorService, StandaloneCodeEditorService, InstantiationType.Eager);
// src/vs/editor/standalone/browser/standaloneLayoutService.ts
registerSingleton(ILayoutService, StandaloneLayoutService, InstantiationType.Delayed);
// src/vs/editor/standalone/browser/standaloneServices.ts
registerSingleton(ILogService, StandaloneLogService, InstantiationType.Eager);
registerSingleton(IConfigurationService, StandaloneConfigurationService, InstantiationType.Eager);
registerSingleton(ITextResourceConfigurationService, StandaloneResourceConfigurationService, InstantiationType.Eager);
registerSingleton(ITextResourcePropertiesService, StandaloneResourcePropertiesService, InstantiationType.Eager);
registerSingleton(IWorkspaceContextService, StandaloneWorkspaceContextService, InstantiationType.Eager);
registerSingleton(ILabelService, StandaloneUriLabelService, InstantiationType.Eager);
registerSingleton(ITelemetryService, StandaloneTelemetryService, InstantiationType.Eager);
registerSingleton(IDialogService, StandaloneDialogService, InstantiationType.Eager);
registerSingleton(IEnvironmentService, StandaloneEnvironmentService, InstantiationType.Eager);
registerSingleton(INotificationService, StandaloneNotificationService, InstantiationType.Eager);
registerSingleton(IMarkerService, MarkerService, InstantiationType.Eager);
registerSingleton(ILanguageService, StandaloneLanguageService, InstantiationType.Eager);
registerSingleton(IStandaloneThemeService, StandaloneThemeService, InstantiationType.Eager);
registerSingleton(IModelService, ModelService, InstantiationType.Eager);
registerSingleton(IMarkerDecorationsService, MarkerDecorationsService, InstantiationType.Eager);
registerSingleton(IContextKeyService, ContextKeyService, InstantiationType.Eager);
registerSingleton(IProgressService, StandaloneProgressService, InstantiationType.Eager);
registerSingleton(IEditorProgressService, StandaloneEditorProgressService, InstantiationType.Eager);
registerSingleton(IStorageService, InMemoryStorageService, InstantiationType.Eager);
registerSingleton(IEditorWorkerService, StandaloneEditorWorkerService, InstantiationType.Eager);
registerSingleton(IBulkEditService, StandaloneBulkEditService, InstantiationType.Eager);
registerSingleton(IWorkspaceTrustManagementService, StandaloneWorkspaceTrustManagementService, InstantiationType.Eager);
registerSingleton(ITextModelService, StandaloneTextModelService, InstantiationType.Eager);
registerSingleton(IAccessibilityService, AccessibilityService, InstantiationType.Eager);
registerSingleton(IListService, ListService, InstantiationType.Eager);
registerSingleton(ICommandService, StandaloneCommandService, InstantiationType.Eager);
registerSingleton(IKeybindingService, StandaloneKeybindingService, InstantiationType.Eager);
registerSingleton(IQuickInputService, StandaloneQuickInputService, InstantiationType.Eager);
registerSingleton(IContextViewService, StandaloneContextViewService, InstantiationType.Eager);
registerSingleton(IOpenerService, OpenerService, InstantiationType.Eager);
registerSingleton(IClipboardService, BrowserClipboardService, InstantiationType.Eager);
registerSingleton(IContextMenuService, StandaloneContextMenuService, InstantiationType.Eager);
registerSingleton(IMenuService, MenuService, InstantiationType.Eager);
registerSingleton(IAccessibilitySignalService, StandaloneAccessbilitySignalService, InstantiationType.Eager);
registerSingleton(ITreeSitterParserService, StandaloneTreeSitterParserService, InstantiationType.Eager);
// src/vs/platform/actions/browser/actionViewItemService.ts
registerSingleton(IActionViewItemService, ActionViewItemService, InstantiationType.Delayed);
// src/vs/platform/actions/common/actions.contribution.ts
registerSingleton(IMenuService, MenuService, InstantiationType.Delayed);
// src/vs/platform/actionWidget/browser/actionWidget.ts
registerSingleton(IActionWidgetService, ActionWidgetService, InstantiationType.Delayed);
// src/vs/platform/extensionManagement/electron-sandbox/extensionsProfileScannerService.ts
registerSingleton(IExtensionsProfileScannerService, ExtensionsProfileScannerService, InstantiationType.Delayed);
// src/vs/platform/extensionResourceLoader/browser/extensionResourceLoaderService.ts
registerSingleton(IExtensionResourceLoaderService, ExtensionResourceLoaderService, InstantiationType.Delayed);
// src/vs/platform/extensionResourceLoader/common/extensionResourceLoaderService.ts
registerSingleton(IExtensionResourceLoaderService, ExtensionResourceLoaderService, InstantiationType.Delayed);
// src/vs/platform/ipc/electron-sandbox/services.ts
registerSingleton(id, new SyncDescriptor(MainProcessRemoteServiceStub, [channelName, options], true));
registerSingleton(id, new SyncDescriptor(SharedProcessRemoteServiceStub, [channelName, options], true));
// src/vs/platform/profiling/electron-sandbox/profileAnalysisWorkerService.ts
registerSingleton(IProfileAnalysisWorkerService, ProfileAnalysisWorkerService, InstantiationType.Delayed);
// src/vs/platform/undoRedo/common/undoRedoService.ts
registerSingleton(IUndoRedoService, UndoRedoService, InstantiationType.Delayed);
// src/vs/platform/uriIdentity/common/uriIdentityService.ts
registerSingleton(IUriIdentityService, UriIdentityService, InstantiationType.Delayed);
// src/vs/platform/userDataProfile/electron-sandbox/userDataProfileStorageService.ts
registerSingleton(IUserDataProfileStorageService, NativeUserDataProfileStorageService, InstantiationType.Delayed);
// src/vs/workbench/api/browser/mainThreadEmbeddings.ts
registerSingleton(IEmbeddingsService, EmbeddingsService, InstantiationType.Delayed);
// src/vs/workbench/api/browser/statusBarExtensionPoint.ts
registerSingleton(IExtensionStatusBarItemService, ExtensionStatusBarItemService, InstantiationType.Delayed);
// src/vs/workbench/api/common/extHost.common.services.ts
registerSingleton(IExtHostLocalizationService, ExtHostLocalizationService, InstantiationType.Delayed);
registerSingleton(ILoggerService, ExtHostLoggerService, InstantiationType.Delayed);
registerSingleton(IExtHostApiDeprecationService, ExtHostApiDeprecationService, InstantiationType.Delayed);
registerSingleton(IExtHostCommands, ExtHostCommands, InstantiationType.Eager);
registerSingleton(IExtHostAuthentication, ExtHostAuthentication, InstantiationType.Eager);
registerSingleton(IExtHostLanguageModels, ExtHostLanguageModels, InstantiationType.Eager);
registerSingleton(IExtHostConfiguration, ExtHostConfiguration, InstantiationType.Eager);
registerSingleton(IExtHostConsumerFileSystem, ExtHostConsumerFileSystem, InstantiationType.Eager);
registerSingleton(IExtHostTesting, ExtHostTesting, InstantiationType.Eager);
registerSingleton(IExtHostDebugService, WorkerExtHostDebugService, InstantiationType.Eager);
registerSingleton(IExtHostDecorations, ExtHostDecorations, InstantiationType.Eager);
registerSingleton(IExtHostDocumentsAndEditors, ExtHostDocumentsAndEditors, InstantiationType.Eager);
registerSingleton(IExtHostManagedSockets, ExtHostManagedSockets, InstantiationType.Eager);
registerSingleton(IExtHostFileSystemInfo, ExtHostFileSystemInfo, InstantiationType.Eager);
registerSingleton(IExtHostOutputService, ExtHostOutputService, InstantiationType.Delayed);
registerSingleton(IExtHostSearch, ExtHostSearch, InstantiationType.Eager);
registerSingleton(IExtHostStorage, ExtHostStorage, InstantiationType.Eager);
registerSingleton(IExtHostTask, WorkerExtHostTask, InstantiationType.Eager);
registerSingleton(IExtHostTerminalService, WorkerExtHostTerminalService, InstantiationType.Eager);
registerSingleton(IExtHostTerminalShellIntegration, ExtHostTerminalShellIntegration, InstantiationType.Eager);
registerSingleton(IExtHostTunnelService, ExtHostTunnelService, InstantiationType.Eager);
registerSingleton(IExtHostWindow, ExtHostWindow, InstantiationType.Eager);
registerSingleton(IExtHostWorkspace, ExtHostWorkspace, InstantiationType.Eager);
registerSingleton(IExtHostSecretState, ExtHostSecretState, InstantiationType.Eager);
registerSingleton(IExtHostTelemetry, ExtHostTelemetry, InstantiationType.Eager);
registerSingleton(IExtHostEditorTabs, ExtHostEditorTabs, InstantiationType.Eager);
registerSingleton(IExtHostVariableResolverProvider, ExtHostVariableResolverProviderService, InstantiationType.Eager);
// src/vs/workbench/api/node/extHost.node.services.ts
registerSingleton(IExtHostExtensionService, ExtHostExtensionService, InstantiationType.Eager);
registerSingleton(ILoggerService, ExtHostLoggerService, InstantiationType.Delayed);
registerSingleton(ILogService, new SyncDescriptor(ExtHostLogService, [false], true));
registerSingleton(ISignService, SignService, InstantiationType.Delayed);
registerSingleton(IExtensionStoragePaths, ExtensionStoragePaths, InstantiationType.Eager);
registerSingleton(IExtHostDebugService, ExtHostDebugService, InstantiationType.Eager);
registerSingleton(IExtHostSearch, NativeExtHostSearch, InstantiationType.Eager);
registerSingleton(IExtHostTask, ExtHostTask, InstantiationType.Eager);
registerSingleton(IExtHostTerminalService, ExtHostTerminalService, InstantiationType.Eager);
registerSingleton(IExtHostTunnelService, NodeExtHostTunnelService, InstantiationType.Eager);
registerSingleton(IExtHostVariableResolverProvider, NodeExtHostVariableResolverProviderService, InstantiationType.Eager);
// src/vs/workbench/api/worker/extHost.worker.services.ts
registerSingleton(ILogService, new SyncDescriptor(ExtHostLogService, [true], true));
registerSingleton(IExtHostExtensionService, ExtHostExtensionService, InstantiationType.Eager);
registerSingleton(IExtensionStoragePaths, ExtensionStoragePaths, InstantiationType.Eager);
// src/vs/workbench/browser/parts/banner/bannerPart.ts
registerSingleton(IBannerService, BannerPart, InstantiationType.Eager);
// src/vs/workbench/browser/parts/editor/breadcrumbs.ts
registerSingleton(IBreadcrumbsService, BreadcrumbsService, InstantiationType.Delayed);
// src/vs/workbench/browser/parts/editor/editorParts.ts
registerSingleton(IEditorGroupsService, EditorParts, InstantiationType.Eager);
// src/vs/workbench/browser/parts/statusbar/statusbarPart.ts
registerSingleton(IStatusbarService, StatusbarService, InstantiationType.Eager);
// src/vs/workbench/browser/parts/paneCompositePartService.ts
registerSingleton(IPaneCompositePartService, PaneCompositePartService, InstantiationType.Delayed);
// src/vs/workbench/contrib/accessibility/browser/accessibility.contribution.ts
registerSingleton(IAccessibleViewService, AccessibleViewService, InstantiationType.Delayed);
registerSingleton(IAccessibleViewInformationService, AccessibleViewInformationService, InstantiationType.Delayed);
// src/vs/workbench/contrib/accessibilitySignals/browser/accessibilitySignal.contribution.ts
registerSingleton(IAccessibilitySignalService, AccessibilitySignalService, InstantiationType.Delayed);
// src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.ts
registerSingleton(IBulkEditService, BulkEditService, InstantiationType.Delayed);
// src/vs/workbench/contrib/chat/browser/chatContentParts/chatTextEditContentPart.ts
registerSingleton(ICodeCompareModelService, CodeCompareModelService, InstantiationType.Delayed);
// src/vs/workbench/contrib/chat/browser/chat.contribution.ts
registerSingleton(IChatService, ChatService, InstantiationType.Delayed);
registerSingleton(IChatWidgetService, ChatWidgetService, InstantiationType.Delayed);
registerSingleton(IQuickChatService, QuickChatService, InstantiationType.Delayed);
registerSingleton(IChatAccessibilityService, ChatAccessibilityService, InstantiationType.Delayed);
registerSingleton(IChatWidgetHistoryService, ChatWidgetHistoryService, InstantiationType.Delayed);
registerSingleton(ILanguageModelsService, LanguageModelsService, InstantiationType.Delayed);
registerSingleton(ILanguageModelStatsService, LanguageModelStatsService, InstantiationType.Delayed);
registerSingleton(IChatSlashCommandService, ChatSlashCommandService, InstantiationType.Delayed);
registerSingleton(IChatAgentService, ChatAgentService, InstantiationType.Delayed);
registerSingleton(IChatAgentNameService, ChatAgentNameService, InstantiationType.Delayed);
registerSingleton(IChatVariablesService, ChatVariablesService, InstantiationType.Delayed);
registerSingleton(ILanguageModelToolsService, LanguageModelToolsService, InstantiationType.Delayed);
registerSingleton(IVoiceChatService, VoiceChatService, InstantiationType.Delayed);
registerSingleton(IChatCodeBlockContextProviderService, ChatCodeBlockContextProviderService, InstantiationType.Delayed);
registerSingleton(ICodeMapperService, CodeMapperService, InstantiationType.Delayed);
registerSingleton(IChatEditingService, ChatEditingService, InstantiationType.Delayed);
registerSingleton(IChatMarkdownAnchorService, ChatMarkdownAnchorService, InstantiationType.Delayed);
registerSingleton(ILanguageModelIgnoredFilesService, LanguageModelIgnoredFilesService, InstantiationType.Delayed);
// src/vs/workbench/contrib/comments/browser/comments.contribution.ts
registerSingleton(ICommentService, CommentService, InstantiationType.Delayed);
// src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.ts
registerSingleton(ICustomEditorService, CustomEditorService, InstantiationType.Delayed);
// src/vs/workbench/contrib/debug/browser/debug.contribution.ts
registerSingleton(IDebugService, DebugService, InstantiationType.Delayed);
registerSingleton(IDebugVisualizerService, DebugVisualizerService, InstantiationType.Delayed);
// src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts
registerSingleton(IExtensionHostDebugService, BrowserExtensionHostDebugService, InstantiationType.Delayed);
// src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.ts
registerSingleton(IEditSessionsLogService, EditSessionsLogService, InstantiationType.Delayed);
registerSingleton(IEditSessionsStorageService, EditSessionsWorkbenchService, InstantiationType.Delayed);
// src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService, InstantiationType.Eager /* Auto updates extensions */);
registerSingleton(IExtensionRecommendationNotificationService, ExtensionRecommendationNotificationService, InstantiationType.Delayed);
registerSingleton(IExtensionRecommendationsService, ExtensionRecommendationsService, InstantiationType.Eager /* Prompts recommendations in the background */);
// src/vs/workbench/contrib/extensions/electron-sandbox/extensions.contribution.ts
registerSingleton(IExtensionHostProfileService, ExtensionHostProfileService, InstantiationType.Delayed);
// src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.ts
registerSingleton(IExternalUriOpenerService, ExternalUriOpenerService, InstantiationType.Delayed);
// src/vs/workbench/contrib/files/browser/files.contribution.ts
registerSingleton(IExplorerService, ExplorerService, InstantiationType.Delayed);
// src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.ts
registerSingleton(IInlineChatSessionService, InlineChatSessionServiceImpl, InstantiationType.Delayed);
registerSingleton(IInlineChatSavingService, InlineChatSavingServiceImpl, InstantiationType.Delayed);
// src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts
registerSingleton(IInteractiveHistoryService, InteractiveHistoryService, InstantiationType.Delayed);
registerSingleton(IInteractiveDocumentService, InteractiveDocumentService, InstantiationType.Delayed);
// src/vs/workbench/contrib/issue/browser/issue.contribution.ts
registerSingleton(IWorkbenchIssueService, BrowserIssueService, InstantiationType.Delayed);
registerSingleton(IIssueFormService, IssueFormService, InstantiationType.Delayed);
// src/vs/workbench/contrib/issue/browser/issueService.ts
registerSingleton(IWorkbenchIssueService, BrowserIssueService, InstantiationType.Delayed);
// src/vs/workbench/contrib/issue/browser/issueTroubleshoot.ts
registerSingleton(ITroubleshootIssueService, TroubleshootIssueService, InstantiationType.Delayed);
// src/vs/workbench/contrib/issue/electron-sandbox/issue.contribution.ts
registerSingleton(IWorkbenchIssueService, NativeIssueService, InstantiationType.Delayed);
registerSingleton(IIssueFormService, NativeIssueFormService, InstantiationType.Delayed);
// src/vs/workbench/contrib/issue/electron-sandbox/issueService.ts
registerSingleton(IWorkbenchIssueService, NativeIssueService, InstantiationType.Delayed);
// src/vs/workbench/contrib/issue/electron-sandbox/processService.ts
registerSingleton(IWorkbenchProcessService, ProcessService, InstantiationType.Delayed);
// src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor.contribution.ts
registerSingleton(IMultiDiffSourceResolverService, MultiDiffSourceResolverService, InstantiationType.Delayed);
// src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
registerSingleton(INotebookService, NotebookService, InstantiationType.Delayed);
registerSingleton(INotebookEditorWorkerService, NotebookEditorWorkerServiceImpl, InstantiationType.Delayed);
registerSingleton(INotebookEditorModelResolverService, NotebookModelResolverServiceImpl, InstantiationType.Delayed);
registerSingleton(INotebookCellStatusBarService, NotebookCellStatusBarService, InstantiationType.Delayed);
registerSingleton(INotebookEditorService, NotebookEditorWidgetService, InstantiationType.Delayed);
registerSingleton(INotebookKernelService, NotebookKernelService, InstantiationType.Delayed);
registerSingleton(INotebookKernelHistoryService, NotebookKernelHistoryService, InstantiationType.Delayed);
registerSingleton(INotebookExecutionService, NotebookExecutionService, InstantiationType.Delayed);
registerSingleton(INotebookExecutionStateService, NotebookExecutionStateService, InstantiationType.Delayed);
registerSingleton(INotebookRendererMessagingService, NotebookRendererMessagingService, InstantiationType.Delayed);
registerSingleton(INotebookKeymapService, NotebookKeymapService, InstantiationType.Delayed);
registerSingleton(INotebookLoggingService, NotebookLoggingService, InstantiationType.Delayed);
registerSingleton(INotebookCellOutlineDataSourceFactory, NotebookCellOutlineDataSourceFactory, InstantiationType.Delayed);
registerSingleton(INotebookOutlineEntryFactory, NotebookOutlineEntryFactory, InstantiationType.Delayed);
// src/vs/workbench/contrib/output/browser/output.contribution.ts
registerSingleton(IOutputService, OutputService, InstantiationType.Delayed);
// src/vs/workbench/contrib/output/common/outputChannelModelService.ts
registerSingleton(IOutputChannelModelService, OutputChannelModelService, InstantiationType.Delayed);
// src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts
registerSingleton(IPreferencesSearchService, PreferencesSearchService, InstantiationType.Delayed);
// src/vs/workbench/contrib/scm/browser/scm.contribution.ts
registerSingleton(ISCMService, SCMService, InstantiationType.Delayed);
registerSingleton(ISCMViewService, SCMViewService, InstantiationType.Delayed);
registerSingleton(IQuickDiffService, QuickDiffService, InstantiationType.Delayed);
// src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchContributions.ts
registerSingleton(INotebookSearchService, NotebookSearchService, InstantiationType.Delayed);
// src/vs/workbench/contrib/search/browser/replaceContributions.ts
registerSingleton(IReplaceService, ReplaceService, InstantiationType.Delayed);
// src/vs/workbench/contrib/search/browser/search.contribution.ts
registerSingleton(ISearchViewModelWorkbenchService, SearchViewModelWorkbenchService, InstantiationType.Delayed);
registerSingleton(ISearchHistoryService, SearchHistoryService, InstantiationType.Delayed);
// src/vs/workbench/contrib/share/browser/share.contribution.ts
registerSingleton(IShareService, ShareService, InstantiationType.Delayed);
// src/vs/workbench/contrib/snippets/browser/snippets.contribution.ts
registerSingleton(ISnippetsService, SnippetsService, InstantiationType.Delayed);
// src/vs/workbench/contrib/speech/browser/speech.contribution.ts
registerSingleton(ISpeechService, SpeechService, InstantiationType.Eager /* Reads Extension Points */);
// src/vs/workbench/contrib/splash/browser/splash.contribution.ts
registerSingleton(ISplashStorageService, class SplashStorageService implements ISplashStorageService {
// src/vs/workbench/contrib/splash/electron-sandbox/splash.contribution.ts
registerSingleton(ISplashStorageService, SplashStorageService, InstantiationType.Delayed);
// src/vs/workbench/contrib/tags/browser/workspaceTagsService.ts
registerSingleton(IWorkspaceTagsService, NoOpWorkspaceTagsService, InstantiationType.Delayed);
// src/vs/workbench/contrib/tags/electron-sandbox/workspaceTagsService.ts
registerSingleton(IWorkspaceTagsService, WorkspaceTagsService, InstantiationType.Delayed);
// src/vs/workbench/contrib/tasks/browser/taskService.ts
registerSingleton(ITaskService, TaskService, InstantiationType.Delayed);
// src/vs/workbench/contrib/tasks/electron-sandbox/taskService.ts
registerSingleton(ITaskService, TaskService, InstantiationType.Delayed);
// src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts
registerSingleton(ITerminalLogService, TerminalLogService, InstantiationType.Delayed);
registerSingleton(ITerminalConfigurationService, TerminalConfigurationService, InstantiationType.Delayed);
registerSingleton(ITerminalService, TerminalService, InstantiationType.Delayed);
registerSingleton(ITerminalEditorService, TerminalEditorService, InstantiationType.Delayed);
registerSingleton(ITerminalGroupService, TerminalGroupService, InstantiationType.Delayed);
registerSingleton(ITerminalInstanceService, TerminalInstanceService, InstantiationType.Delayed);
registerSingleton(ITerminalProfileService, TerminalProfileService, InstantiationType.Delayed);
// src/vs/workbench/contrib/terminal/browser/terminal.web.contribution.ts
registerSingleton(ITerminalProfileResolverService, BrowserTerminalProfileResolverService, InstantiationType.Delayed);
// src/vs/workbench/contrib/terminal/browser/terminalInstanceService.ts
registerSingleton(ITerminalInstanceService, TerminalInstanceService, InstantiationType.Delayed);
// src/vs/workbench/contrib/terminal/common/environmentVariable.contribution.ts
registerSingleton(IEnvironmentVariableService, EnvironmentVariableService, InstantiationType.Delayed);
// src/vs/workbench/contrib/terminal/common/terminalExtensionPoints.contribution.ts
registerSingleton(ITerminalContributionService, TerminalContributionService, InstantiationType.Delayed);
// src/vs/workbench/contrib/terminal/electron-sandbox/terminal.contribution.ts
registerSingleton(ITerminalProfileResolverService, ElectronTerminalProfileResolverService, InstantiationType.Delayed);
// src/vs/workbench/contrib/terminalContrib/links/browser/terminal.links.contribution.ts
registerSingleton(ITerminalLinkProviderService, TerminalLinkProviderService, InstantiationType.Delayed);
// src/vs/workbench/contrib/terminalContrib/quickFix/browser/terminal.quickFix.contribution.ts
registerSingleton(ITerminalQuickFixService, TerminalQuickFixService, InstantiationType.Delayed);
// src/vs/workbench/contrib/testing/browser/testing.contribution.ts
registerSingleton(ITestService, TestService, InstantiationType.Delayed);
registerSingleton(ITestResultStorage, TestResultStorage, InstantiationType.Delayed);
registerSingleton(ITestProfileService, TestProfileService, InstantiationType.Delayed);
registerSingleton(ITestCoverageService, TestCoverageService, InstantiationType.Delayed);
registerSingleton(ITestingContinuousRunService, TestingContinuousRunService, InstantiationType.Delayed);
registerSingleton(ITestResultService, TestResultService, InstantiationType.Delayed);
registerSingleton(ITestExplorerFilterState, TestExplorerFilterState, InstantiationType.Delayed);
registerSingleton(ITestingPeekOpener, TestingPeekOpener, InstantiationType.Delayed);
registerSingleton(ITestingDecorationsService, TestingDecorationService, InstantiationType.Delayed);
// src/vs/workbench/contrib/timeline/browser/timeline.contribution.ts
registerSingleton(ITimelineService, TimelineService, InstantiationType.Delayed);
// src/vs/workbench/contrib/url/browser/url.contribution.ts
registerSingleton(ITrustedDomainService, TrustedDomainService, InstantiationType.Delayed);
// src/vs/workbench/contrib/webview/browser/webview.web.contribution.ts
registerSingleton(IWebviewService, WebviewService, InstantiationType.Delayed);
// src/vs/workbench/contrib/webview/electron-sandbox/webview.contribution.ts
registerSingleton(IWebviewService, ElectronWebviewService, InstantiationType.Delayed);
// src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.ts
registerSingleton(IWebviewWorkbenchService, WebviewEditorService, InstantiationType.Delayed);
// src/vs/workbench/contrib/webviewView/browser/webviewView.contribution.ts
registerSingleton(IWebviewViewService, WebviewViewService, InstantiationType.Delayed);
// src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
registerSingleton(IWalkthroughsService, WalkthroughsService, InstantiationType.Delayed);
// src/vs/workbench/electron-sandbox/desktop.main.ts
Please do NOT register services here. Use `registerSingleton()`
Please do NOT register services here. Use `registerSingleton()`
Please do NOT register services here. Use `registerSingleton()`
Please do NOT register services here. Use `registerSingleton()`
// src/vs/workbench/services/accessibility/electron-sandbox/accessibilityService.ts
registerSingleton(IAccessibilityService, NativeAccessibilityService, InstantiationType.Delayed);
// src/vs/workbench/services/activity/browser/activityService.ts
registerSingleton(IActivityService, ActivityService, InstantiationType.Delayed);
// src/vs/workbench/services/aiEmbeddingVector/common/aiEmbeddingVectorService.ts
registerSingleton(IAiEmbeddingVectorService, AiEmbeddingVectorService, InstantiationType.Delayed);
// src/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformationService.ts
registerSingleton(IAiRelatedInformationService, AiRelatedInformationService, InstantiationType.Delayed);
// src/vs/workbench/services/assignment/common/assignmentService.ts
registerSingleton(IWorkbenchAssignmentService, WorkbenchAssignmentService, InstantiationType.Delayed);
// src/vs/workbench/services/authentication/browser/authenticationAccessService.ts
registerSingleton(IAuthenticationAccessService, AuthenticationAccessService, InstantiationType.Delayed);
// src/vs/workbench/services/authentication/browser/authenticationExtensionsService.ts
registerSingleton(IAuthenticationExtensionsService, AuthenticationExtensionsService, InstantiationType.Delayed);
// src/vs/workbench/services/authentication/browser/authenticationService.ts
registerSingleton(IAuthenticationService, AuthenticationService, InstantiationType.Delayed);
// src/vs/workbench/services/authentication/browser/authenticationUsageService.ts
registerSingleton(IAuthenticationUsageService, AuthenticationUsageService, InstantiationType.Delayed);
// src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
registerSingleton(IAuxiliaryWindowService, BrowserAuxiliaryWindowService, InstantiationType.Delayed);
// src/vs/workbench/services/auxiliaryWindow/electron-sandbox/auxiliaryWindowService.ts
registerSingleton(IAuxiliaryWindowService, NativeAuxiliaryWindowService, InstantiationType.Delayed);
// src/vs/workbench/services/clipboard/browser/clipboardService.ts
registerSingleton(IClipboardService, BrowserClipboardService, InstantiationType.Delayed);
// src/vs/workbench/services/clipboard/electron-sandbox/clipboardService.ts
registerSingleton(IClipboardService, NativeClipboardService, InstantiationType.Delayed);
// src/vs/workbench/services/commands/common/commandService.ts
registerSingleton(ICommandService, CommandService, InstantiationType.Delayed);
// src/vs/workbench/services/configuration/common/jsonEditingService.ts
registerSingleton(IJSONEditingService, JSONEditingService, InstantiationType.Delayed);
// src/vs/workbench/services/configurationResolver/browser/configurationResolverService.ts
registerSingleton(IConfigurationResolverService, ConfigurationResolverService, InstantiationType.Delayed);
// src/vs/workbench/services/configurationResolver/electron-sandbox/configurationResolverService.ts
registerSingleton(IConfigurationResolverService, ConfigurationResolverService, InstantiationType.Delayed);
// src/vs/workbench/services/contextmenu/electron-sandbox/contextmenuService.ts
registerSingleton(IContextMenuService, ContextMenuService, InstantiationType.Delayed);
// src/vs/workbench/services/decorations/browser/decorationsService.ts
registerSingleton(IDecorationsService, DecorationsService, InstantiationType.Delayed);
// src/vs/workbench/services/dialogs/browser/fileDialogService.ts
registerSingleton(IFileDialogService, FileDialogService, InstantiationType.Delayed);
// src/vs/workbench/services/dialogs/common/dialogService.ts
registerSingleton(IDialogService, DialogService, InstantiationType.Delayed);
// src/vs/workbench/services/dialogs/electron-sandbox/fileDialogService.ts
registerSingleton(IFileDialogService, FileDialogService, InstantiationType.Delayed);
// src/vs/workbench/services/editor/browser/codeEditorService.ts
registerSingleton(ICodeEditorService, CodeEditorService, InstantiationType.Delayed);
// src/vs/workbench/services/editor/browser/editorPaneService.ts
registerSingleton(IEditorPaneService, EditorPaneService, InstantiationType.Delayed);
// src/vs/workbench/services/editor/browser/editorResolverService.ts
registerSingleton(IEditorResolverService, EditorResolverService, InstantiationType.Eager);
// src/vs/workbench/services/editor/browser/editorService.ts
registerSingleton(IEditorService, new SyncDescriptor(EditorService, [undefined], false));
// src/vs/workbench/services/editor/common/customEditorLabelService.ts
registerSingleton(ICustomEditorLabelService, CustomEditorLabelService, InstantiationType.Delayed);
// src/vs/workbench/services/encryption/browser/encryptionService.ts
registerSingleton(IEncryptionService, EncryptionService, InstantiationType.Delayed);
// src/vs/workbench/services/environment/electron-sandbox/shellEnvironmentService.ts
registerSingleton(IShellEnvironmentService, ShellEnvironmentService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionManagement/browser/builtinExtensionsScannerService.ts
registerSingleton(IBuiltinExtensionsScannerService, BuiltinExtensionsScannerService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionManagement/browser/extensionBisect.ts
registerSingleton(IExtensionBisectService, ExtensionBisectService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts
registerSingleton(IWorkbenchExtensionEnablementService, ExtensionEnablementService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionManagement/browser/extensionsProfileScannerService.ts
registerSingleton(IExtensionsProfileScannerService, ExtensionsProfileScannerService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts
registerSingleton(IWebExtensionsScannerService, WebExtensionsScannerService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionManagement/common/extensionFeaturesManagemetService.ts
registerSingleton(IExtensionFeaturesManagementService, ExtensionFeaturesManagementService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionManagement/common/extensionManagementServerService.ts
registerSingleton(IExtensionManagementServerService, ExtensionManagementServerService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionManagement/electron-sandbox/extensionManagementServerService.ts
registerSingleton(IExtensionManagementServerService, ExtensionManagementServerService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionManagement/electron-sandbox/extensionManagementService.ts
registerSingleton(IWorkbenchExtensionManagementService, ExtensionManagementService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionManagement/electron-sandbox/extensionTipsService.ts
registerSingleton(IExtensionTipsService, NativeExtensionTipsService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionRecommendations/common/extensionIgnoredRecommendationsService.ts
registerSingleton(IExtensionIgnoredRecommendationsService, ExtensionIgnoredRecommendationsService, InstantiationType.Delayed);
// src/vs/workbench/services/extensionRecommendations/common/workspaceExtensionsConfig.ts
registerSingleton(IWorkspaceExtensionsConfigService, WorkspaceExtensionsConfigService, InstantiationType.Delayed);
// src/vs/workbench/services/extensions/browser/extensionService.ts
registerSingleton(IExtensionService, ExtensionService, InstantiationType.Eager);
// src/vs/workbench/services/extensions/browser/extensionsScannerService.ts
registerSingleton(IExtensionsScannerService, ExtensionsScannerService, InstantiationType.Delayed);
// src/vs/workbench/services/extensions/browser/extensionUrlHandler.ts
registerSingleton(IExtensionUrlHandler, ExtensionUrlHandler, InstantiationType.Eager);
// src/vs/workbench/services/extensions/common/extensionManifestPropertiesService.ts
registerSingleton(IExtensionManifestPropertiesService, ExtensionManifestPropertiesService, InstantiationType.Delayed);
// src/vs/workbench/services/extensions/electron-sandbox/extensionsScannerService.ts
registerSingleton(IExtensionsScannerService, ExtensionsScannerService, InstantiationType.Delayed);
// src/vs/workbench/services/extensions/electron-sandbox/nativeExtensionService.ts
registerSingleton(IExtensionService, NativeExtensionService, InstantiationType.Eager);
// src/vs/workbench/services/files/browser/elevatedFileService.ts
registerSingleton(IElevatedFileService, BrowserElevatedFileService, InstantiationType.Delayed);
// src/vs/workbench/services/files/electron-sandbox/elevatedFileService.ts
registerSingleton(IElevatedFileService, NativeElevatedFileService, InstantiationType.Delayed);
// src/vs/workbench/services/filesConfiguration/common/filesConfigurationService.ts
registerSingleton(IFilesConfigurationService, FilesConfigurationService, InstantiationType.Eager);
// src/vs/workbench/services/history/browser/historyService.ts
registerSingleton(IHistoryService, HistoryService, InstantiationType.Eager);
// src/vs/workbench/services/host/browser/browserHostService.ts
registerSingleton(IHostService, BrowserHostService, InstantiationType.Delayed);
// src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts
registerSingleton(IHostService, WorkbenchHostService, InstantiationType.Delayed);
registerSingleton(INativeHostService, WorkbenchNativeHostService, InstantiationType.Delayed);
// src/vs/workbench/services/integrity/browser/integrityService.ts
registerSingleton(IIntegrityService, IntegrityService, InstantiationType.Delayed);
// src/vs/workbench/services/integrity/electron-sandbox/integrityService.ts
registerSingleton(IIntegrityService, IntegrityService, InstantiationType.Delayed);
// src/vs/workbench/services/keybinding/browser/keybindingService.ts
registerSingleton(IKeybindingService, WorkbenchKeybindingService, InstantiationType.Eager);
// src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts
registerSingleton(IKeyboardLayoutService, BrowserKeyboardLayoutService, InstantiationType.Delayed);
// src/vs/workbench/services/keybinding/common/keybindingEditing.ts
registerSingleton(IKeybindingEditingService, KeybindingsEditingService, InstantiationType.Delayed);
// src/vs/workbench/services/keybinding/electron-sandbox/nativeKeyboardLayout.ts
registerSingleton(IKeyboardLayoutService, KeyboardLayoutService, InstantiationType.Delayed);
// src/vs/workbench/services/label/common/labelService.ts
registerSingleton(ILabelService, LabelService, InstantiationType.Delayed);
// src/vs/workbench/services/language/common/languageService.ts
registerSingleton(ILanguageService, WorkbenchLanguageService, InstantiationType.Eager);
// src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts
registerSingleton(ILanguageDetectionService, LanguageDetectionService, InstantiationType.Eager);
// src/vs/workbench/services/languageStatus/common/languageStatusService.ts
registerSingleton(ILanguageStatusService, LanguageStatusServiceImpl, InstantiationType.Delayed);
// src/vs/workbench/services/lifecycle/browser/lifecycleService.ts
registerSingleton(ILifecycleService, BrowserLifecycleService, InstantiationType.Eager);
// src/vs/workbench/services/lifecycle/electron-sandbox/lifecycleService.ts
registerSingleton(ILifecycleService, NativeLifecycleService, InstantiationType.Eager);
// src/vs/workbench/services/localization/browser/localeService.ts
registerSingleton(ILocaleService, WebLocaleService, InstantiationType.Delayed);
registerSingleton(IActiveLanguagePackService, WebActiveLanguagePackService, InstantiationType.Delayed);
// src/vs/workbench/services/localization/electron-sandbox/localeService.ts
registerSingleton(ILocaleService, NativeLocaleService, InstantiationType.Delayed);
registerSingleton(IActiveLanguagePackService, NativeActiveLanguagePackService, InstantiationType.Delayed);
// src/vs/workbench/services/model/common/modelService.ts
registerSingleton(IModelService, WorkbenchModelService, InstantiationType.Delayed);
// src/vs/workbench/services/notebook/common/notebookDocumentService.ts
registerSingleton(INotebookDocumentService, NotebookDocumentWorkbenchService, InstantiationType.Delayed);
// src/vs/workbench/services/notification/common/notificationService.ts
registerSingleton(INotificationService, NotificationService, InstantiationType.Delayed);
// src/vs/workbench/services/outline/browser/outlineService.ts
registerSingleton(IOutlineService, OutlineService, InstantiationType.Delayed);
// src/vs/workbench/services/path/browser/pathService.ts
registerSingleton(IPathService, BrowserPathService, InstantiationType.Delayed);
// src/vs/workbench/services/path/electron-sandbox/pathService.ts
registerSingleton(IPathService, NativePathService, InstantiationType.Delayed);
// src/vs/workbench/services/preferences/browser/preferencesService.ts
registerSingleton(IPreferencesService, PreferencesService, InstantiationType.Delayed);
// src/vs/workbench/services/progress/browser/progressService.ts
registerSingleton(IProgressService, ProgressService, InstantiationType.Delayed);
// src/vs/workbench/services/quickinput/browser/quickInputService.ts
registerSingleton(IQuickInputService, QuickInputService, InstantiationType.Delayed);
// src/vs/workbench/services/remote/common/remoteExplorerService.ts
registerSingleton(IRemoteExplorerService, RemoteExplorerService, InstantiationType.Delayed);
// src/vs/workbench/services/remote/common/remoteExtensionsScanner.ts
registerSingleton(IRemoteExtensionsScannerService, RemoteExtensionsScannerService, InstantiationType.Delayed);
// src/vs/workbench/services/request/electron-sandbox/requestService.ts
registerSingleton(IRequestService, NativeRequestService, InstantiationType.Delayed);
// src/vs/workbench/services/search/browser/searchService.ts
registerSingleton(ISearchService, RemoteSearchService, InstantiationType.Delayed);
// src/vs/workbench/services/search/electron-sandbox/searchService.ts
registerSingleton(ISearchService, SearchService, InstantiationType.Delayed);
// src/vs/workbench/services/secrets/browser/secretStorageService.ts
registerSingleton(ISecretStorageService, BrowserSecretStorageService, InstantiationType.Delayed);
// src/vs/workbench/services/secrets/electron-sandbox/secretStorageService.ts
registerSingleton(ISecretStorageService, NativeSecretStorageService, InstantiationType.Delayed);
// src/vs/workbench/services/telemetry/browser/telemetryService.ts
registerSingleton(ITelemetryService, TelemetryService, InstantiationType.Delayed);
// src/vs/workbench/services/telemetry/electron-sandbox/telemetryService.ts
registerSingleton(ITelemetryService, TelemetryService, InstantiationType.Delayed);
// src/vs/workbench/services/terminal/common/embedderTerminalService.ts
registerSingleton(IEmbedderTerminalService, EmbedderTerminalService, InstantiationType.Delayed);
// src/vs/workbench/services/textfile/browser/browserTextFileService.ts
registerSingleton(ITextFileService, BrowserTextFileService, InstantiationType.Eager);
// src/vs/workbench/services/textfile/common/textEditorService.ts
https://github.com/microsoft/vscode/issues/137675 */);
// src/vs/workbench/services/textfile/electron-sandbox/nativeTextFileService.ts
registerSingleton(ITextFileService, NativeTextFileService, InstantiationType.Eager);
// src/vs/workbench/services/textMate/browser/textMateTokenizationFeature.contribution.ts
registerSingleton(ITextMateTokenizationService, TextMateTokenizationFeature, InstantiationType.Eager);
// src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts
registerSingleton(ITextModelService, TextModelResolverService, InstantiationType.Delayed);
// src/vs/workbench/services/textresourceProperties/common/textResourcePropertiesService.ts
registerSingleton(ITextResourcePropertiesService, TextResourcePropertiesService, InstantiationType.Delayed);
// src/vs/workbench/services/themes/browser/browserHostColorSchemeService.ts
registerSingleton(IHostColorSchemeService, BrowserHostColorSchemeService, InstantiationType.Delayed);
// src/vs/workbench/services/themes/browser/workbenchThemeService.ts
registerSingleton(IWorkbenchThemeService, WorkbenchThemeService, InstantiationType.Eager);
// src/vs/workbench/services/themes/electron-sandbox/nativeHostColorSchemeService.ts
registerSingleton(IHostColorSchemeService, NativeHostColorSchemeService, InstantiationType.Delayed);
// src/vs/workbench/services/timer/electron-sandbox/timerService.ts
registerSingleton(ITimerService, TimerService, InstantiationType.Delayed);
// src/vs/workbench/services/title/electron-sandbox/titleService.ts
registerSingleton(ITitleService, NativeTitleService, InstantiationType.Eager);
// src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.contribution.ts
registerSingleton(ITreeSitterParserService, TreeSitterTextModelService, InstantiationType.Eager);
// src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts
registerSingleton(ITreeSitterTokenizationFeature, TreeSitterTokenizationFeature, InstantiationType.Eager);
// src/vs/workbench/services/tunnel/browser/tunnelService.ts
registerSingleton(ITunnelService, TunnelService, InstantiationType.Delayed);
// src/vs/workbench/services/tunnel/electron-sandbox/tunnelService.ts
registerSingleton(ITunnelService, TunnelService, InstantiationType.Delayed);
// src/vs/workbench/services/untitled/common/untitledTextEditorService.ts
registerSingleton(IUntitledTextEditorService, UntitledTextEditorService, InstantiationType.Delayed);
// src/vs/workbench/services/update/browser/updateService.ts
registerSingleton(IUpdateService, BrowserUpdateService, InstantiationType.Eager);
// src/vs/workbench/services/url/browser/urlService.ts
registerSingleton(IURLService, BrowserURLService, InstantiationType.Delayed);
// src/vs/workbench/services/url/electron-sandbox/urlService.ts
registerSingleton(IURLService, RelayURLService, InstantiationType.Eager);
// src/vs/workbench/services/userActivity/common/userActivityService.ts
registerSingleton(IUserActivityService, UserActivityService, InstantiationType.Delayed);
// src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.ts
registerSingleton(IUserDataProfileImportExportService, UserDataProfileImportExportService, InstantiationType.Delayed);
// src/vs/workbench/services/userDataProfile/browser/userDataProfileManagement.ts
registerSingleton(IUserDataProfileManagementService, UserDataProfileManagementService, InstantiationType.Eager /* Eager because it updates the current window profile by listening to profiles changes */);
// src/vs/workbench/services/userDataProfile/browser/userDataProfileStorageService.ts
registerSingleton(IUserDataProfileStorageService, UserDataProfileStorageService, InstantiationType.Delayed);
// src/vs/workbench/services/userDataProfile/common/remoteUserDataProfiles.ts
registerSingleton(IRemoteUserDataProfilesService, RemoteUserDataProfilesService, InstantiationType.Delayed);
// src/vs/workbench/services/userDataSync/browser/userDataSyncEnablementService.ts
registerSingleton(IUserDataSyncEnablementService, UserDataSyncEnablementService, InstantiationType.Delayed);
// src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts
registerSingleton(IUserDataSyncWorkbenchService, UserDataSyncWorkbenchService, InstantiationType.Eager /* Eager because it initializes settings sync accounts */);
// src/vs/workbench/services/userDataSync/browser/webUserDataSyncEnablementService.ts
registerSingleton(IUserDataSyncEnablementService, WebUserDataSyncEnablementService, InstantiationType.Delayed);
// src/vs/workbench/services/userDataSync/common/userDataSyncUtil.ts
registerSingleton(IUserDataSyncUtilService, UserDataSyncUtilService, InstantiationType.Delayed);
// src/vs/workbench/services/userDataSync/electron-sandbox/userDataAutoSyncService.ts
registerSingleton(IUserDataAutoSyncService, UserDataAutoSyncService, InstantiationType.Delayed);
// src/vs/workbench/services/views/browser/viewDescriptorService.ts
registerSingleton(IViewDescriptorService, ViewDescriptorService, InstantiationType.Delayed);
// src/vs/workbench/services/views/browser/viewsService.ts
registerSingleton(IViewsService, ViewsService, InstantiationType.Eager /* Eager because it registers viewlets and panels in the constructor which are required during workbench layout */);
// src/vs/workbench/services/workingCopy/browser/workingCopyBackupService.ts
registerSingleton(IWorkingCopyBackupService, BrowserWorkingCopyBackupService, InstantiationType.Eager);
// src/vs/workbench/services/workingCopy/browser/workingCopyHistoryService.ts
registerSingleton(IWorkingCopyHistoryService, BrowserWorkingCopyHistoryService, InstantiationType.Delayed);
// src/vs/workbench/services/workingCopy/common/workingCopyEditorService.ts
registerSingleton(IWorkingCopyEditorService, WorkingCopyEditorService, InstantiationType.Delayed);
// src/vs/workbench/services/workingCopy/common/workingCopyFileService.ts
registerSingleton(IWorkingCopyFileService, WorkingCopyFileService, InstantiationType.Delayed);
// src/vs/workbench/services/workingCopy/common/workingCopyService.ts
registerSingleton(IWorkingCopyService, WorkingCopyService, InstantiationType.Delayed);
// src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupService.ts
registerSingleton(IWorkingCopyBackupService, NativeWorkingCopyBackupService, InstantiationType.Eager);
// src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyHistoryService.ts
registerSingleton(IWorkingCopyHistoryService, NativeWorkingCopyHistoryService, InstantiationType.Delayed);
// src/vs/workbench/services/workspaces/browser/workspaceEditingService.ts
registerSingleton(IWorkspaceEditingService, BrowserWorkspaceEditingService, InstantiationType.Delayed);
// src/vs/workbench/services/workspaces/browser/workspacesService.ts
registerSingleton(IWorkspacesService, BrowserWorkspacesService, InstantiationType.Delayed);
// src/vs/workbench/services/workspaces/common/canonicalUriService.ts
registerSingleton(ICanonicalUriService, CanonicalUriService, InstantiationType.Delayed);
// src/vs/workbench/services/workspaces/common/editSessionIdentityService.ts
registerSingleton(IEditSessionIdentityService, EditSessionIdentityService, InstantiationType.Delayed);
// src/vs/workbench/services/workspaces/common/workspaceIdentityService.ts
registerSingleton(IWorkspaceIdentityService, WorkspaceIdentityService, InstantiationType.Delayed);
// src/vs/workbench/services/workspaces/common/workspaceTrust.ts
registerSingleton(IWorkspaceTrustRequestService, WorkspaceTrustRequestService, InstantiationType.Delayed);
// src/vs/workbench/services/workspaces/electron-sandbox/workspaceEditingService.ts
registerSingleton(IWorkspaceEditingService, NativeWorkspaceEditingService, InstantiationType.Delayed);
// src/vs/workbench/services/workspaces/electron-sandbox/workspacesService.ts
registerSingleton(IWorkspacesService, NativeWorkspacesService, InstantiationType.Delayed);
// src/vs/workbench/workbench.common.main.ts
registerSingleton(IUserDataSyncLogService, UserDataSyncLogService, InstantiationType.Delayed);
registerSingleton(IIgnoredExtensionsManagementService, IgnoredExtensionsManagementService, InstantiationType.Delayed);
registerSingleton(IGlobalExtensionEnablementService, GlobalExtensionEnablementService, InstantiationType.Delayed);
registerSingleton(IExtensionStorageService, ExtensionStorageService, InstantiationType.Delayed);
registerSingleton(IExtensionGalleryService, ExtensionGalleryService, InstantiationType.Delayed);
registerSingleton(IContextViewService, ContextViewService, InstantiationType.Delayed);
registerSingleton(IListService, ListService, InstantiationType.Delayed);
registerSingleton(IEditorWorkerService, WorkbenchEditorWorkerService, InstantiationType.Eager /* registers link detection and word based suggestions for any document */);
registerSingleton(IMarkerDecorationsService, MarkerDecorationsService, InstantiationType.Delayed);
registerSingleton(IMarkerService, MarkerService, InstantiationType.Delayed);
registerSingleton(IContextKeyService, ContextKeyService, InstantiationType.Delayed);
registerSingleton(ITextResourceConfigurationService, TextResourceConfigurationService, InstantiationType.Delayed);
registerSingleton(IDownloadService, DownloadService, InstantiationType.Delayed);
registerSingleton(IOpenerService, OpenerService, InstantiationType.Delayed);
// src/vs/workbench/workbench.desktop.main.ts
registerSingleton(IUserDataInitializationService, new SyncDescriptor(UserDataInitializationService, [[]], true));
// src/vs/workbench/workbench.web.main.internal.ts
registerSingleton(IWorkbenchExtensionManagementService, ExtensionManagementService, InstantiationType.Delayed);
registerSingleton(IAccessibilityService, AccessibilityService, InstantiationType.Delayed);
registerSingleton(IContextMenuService, ContextMenuService, InstantiationType.Delayed);
registerSingleton(IUserDataSyncStoreService, UserDataSyncStoreService, InstantiationType.Delayed);
registerSingleton(IUserDataSyncMachinesService, UserDataSyncMachinesService, InstantiationType.Delayed);
registerSingleton(IUserDataSyncLocalStoreService, UserDataSyncLocalStoreService, InstantiationType.Delayed);
registerSingleton(IUserDataSyncAccountService, UserDataSyncAccountService, InstantiationType.Delayed);
registerSingleton(IUserDataSyncService, UserDataSyncService, InstantiationType.Delayed);
registerSingleton(IUserDataSyncResourceProviderService, UserDataSyncResourceProviderService, InstantiationType.Delayed);
registerSingleton(IUserDataAutoSyncService, UserDataAutoSyncService, InstantiationType.Eager /* Eager to start auto sync */);
registerSingleton(ITitleService, BrowserTitleService, InstantiationType.Eager);
registerSingleton(IExtensionTipsService, ExtensionTipsService, InstantiationType.Delayed);
registerSingleton(ITimerService, TimerService, InstantiationType.Delayed);
registerSingleton(ICustomEndpointTelemetryService, NullEndpointTelemetryService, InstantiationType.Delayed);
registerSingleton(IDiagnosticsService, NullDiagnosticsService, InstantiationType.Delayed);
registerSingleton(ILanguagePackService, WebLanguagePacksService, InstantiationType.Delayed);
workbench render steps
render 源码组织
workbench.ts
src/vs/workbench/browser/workbench.ts
- Workbench -> startup() -> createWorkbenchLayout() -> Layout
layout.ts
src/vs/workbench/browser/layout.ts
- Layout -> createWorkbenchLayout() -> SerializableGrid -> grid.ts
grid.ts
src/vs/base/browser/ui/grid/grid.ts
- SerializableGrid -> deserialize() -> GridView
gridview.ts
src/vs/base/browser/ui/grid/gridview.ts
- GridView -> deserialize() -> _deserialize() -> _deserializeNode() -> BranchNode/LeafNode -> SplitView
render 源码链路(精简)
workbench.ts
ts
// src/vs/workbench/browser/workbench.ts
class Workbench extends Layout {
startup(): IInstantiationService {
// Services
const instantiationService = this.initServices(this.serviceCollection);
instantiationService.invokeFunction(accessor => {
// Layout
this.initLayout(accessor);
// Render Workbench
this.renderWorkbench(instantiationService, notificationService, storageService, configurationService);
// Workbench Layout
this.createWorkbenchLayout();
});
}
}
layout.ts
ts
// src/vs/workbench/browser/layout.ts
abstract class Layout extends Disposable implements IWorkbenchLayoutService {
protected createWorkbenchLayout(): void {
const workbenchGrid = SerializableGrid.deserialize(
this.createGridDescriptor(),
{ fromJSON },
{ proportionalLayout: false }
);
this.mainContainer.prepend(workbenchGrid.element);
this.mainContainer.setAttribute('role', 'application');
}
}
grid.ts
ts
// src/vs/base/browser/ui/grid/grid.ts
class SerializableGrid {
static deserialize<T extends ISerializableView>(json: ISerializedGrid, deserializer: IViewDeserializer<T>, options: IGridOptions = {}): SerializableGrid<T> {
const gridview = GridView.deserialize(json, deserializer, options);
const result = new SerializableGrid<T>(gridview, options);
return result;
}
}
gridview.ts
ts
// src/vs/base/browser/ui/grid/gridview.ts
class GridView {
static deserialize<T extends ISerializableView>(json: ISerializedGridView, deserializer: IViewDeserializer<T>, options: IGridViewOptions = {}): GridView {
const orientation = json.orientation;
const height = json.height;
const result = new GridView(options);
result._deserialize(json.root as ISerializedBranchNode, orientation, deserializer, height);
return result;
}
private _deserialize(root: ISerializedBranchNode, orientation: Orientation, deserializer: IViewDeserializer<ISerializableView>, orthogonalSize: number): void {
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize) as BranchNode;
}
/**
* 最终返回值的 `result.element` {@link workbench html elements} 元素
*/
private _deserializeNode(node: ISerializedNode, orientation: Orientation, deserializer: IViewDeserializer<ISerializableView>, orthogonalSize: number): Node {
let result: Node;
if (node.type === 'branch') {
const serializedChildren = node.data as ISerializedNode[];
const children = serializedChildren.map(serializedChild => {
return {
node: this._deserializeNode(serializedChild, orthogonal(orientation), deserializer, node.size),
visible: (serializedChild as { visible?: boolean }).visible
} satisfies INodeDescriptor;
});
result = new BranchNode(orientation, this.layoutController, this.styles, this.proportionalLayout, node.size, orthogonalSize, undefined, children);
} else {
result = new LeafNode(deserializer.fromJSON(node.data), orientation, this.layoutController, orthogonalSize, node.size);
if (node.maximized && !this.maximizedNode) {
this.maximizedNode = result;
this._onDidChangeViewMaximized.fire(true);
}
}
return result;
}
}
render 源码链路
workbench.desktop.main.ts
ts
// src/vs/workbench/workbench.desktop.main.ts
import './workbench.common.main.js';
import './services/title/electron-sandbox/titleService.js';
workbench.common.main.ts
ts
import './browser/parts/editor/editor.contribution.js';
import './browser/parts/editor/editorParts.js';
import './browser/parts/paneCompositePartService.js';
import './browser/parts/banner/bannerPart.js';
import './browser/parts/statusbar/statusbarPart.js';
editorParts.ts
ts
// src/vs/workbench/browser/parts/editor/editorParts.ts
class EditorParts { }
registerSingleton(IEditorGroupsService, EditorParts, InstantiationType.Eager);
paneCompositePartService.ts
ts
// src/vs/workbench/browser/parts/paneCompositePartService.ts
class PaneCompositePartService {
private readonly paneCompositeParts = new Map<ViewContainerLocation, IPaneCompositePart>();
constructor(
@IInstantiationService instantiationService: IInstantiationService,
) {
super();
const panelPart = instantiationService.createInstance(PanelPart);
const sideBarPart = instantiationService.createInstance(SidebarPart);
const auxiliaryBarPart = instantiationService.createInstance(AuxiliaryBarPart);
this.paneCompositeParts.set(ViewContainerLocation.Panel, panelPart);
this.paneCompositeParts.set(ViewContainerLocation.Sidebar, sideBarPart);
this.paneCompositeParts.set(ViewContainerLocation.AuxiliaryBar, auxiliaryBarPart);
const eventDisposables = this._register(new DisposableStore());
this.onDidPaneCompositeOpen = Event.any(...ViewContainerLocations.map(loc => Event.map(this.paneCompositeParts.get(loc)!.onDidPaneCompositeOpen, composite => { return { composite, viewContainerLocation: loc }; }, eventDisposables)));
this.onDidPaneCompositeClose = Event.any(...ViewContainerLocations.map(loc => Event.map(this.paneCompositeParts.get(loc)!.onDidPaneCompositeClose, composite => { return { composite, viewContainerLocation: loc }; }, eventDisposables)));
}
}
// src/vs/workbench/browser/parts/sidebar/sidebarPart.ts
class SidebarPart {
private readonly activityBarPart = this._register(
this.instantiationService.createInstance(ActivitybarPart, this)
);
constructor(
// ...
@IInstantiationService instantiationService: IInstantiationService,
// ...
) { }
}
// 全局单例依赖注入 PanelPart、SidebarPart(含ActivitybarPart)、AuxiliaryBarPart 服务:
registerSingleton(IPaneCompositePartService, PaneCompositePartService, InstantiationType.Delayed);
bannerPart.ts
ts
// src/vs/workbench/browser/parts/banner/bannerPart.ts
class BannerPart {}
// 全局单例依赖注入 BannerPart 服务:BannerPart
registerSingleton(IBannerService, BannerPart, InstantiationType.Eager);
registerAction2(FocusBannerAction);
statusbarPart.ts
ts
// src/vs/workbench/browser/parts/statusbar/statusbarPart.ts
class StatusbarPart {}
class MainStatusbarPart extends StatusbarPart {}
// 全局单例依赖注入 StatusbarPart 服务:BannerPart
registerSingleton(IStatusbarService, StatusbarService, InstantiationType.Eager);
titleService.ts
ts
// src/vs/workbench/services/title/electron-sandbox/titleService.ts
// 全局单例依赖注入 titlebarPart 服务(NativeTitleService)
registerSingleton(ITitleService, NativeTitleService, InstantiationType.Eager);
workbench.ts
ts
// src/vs/workbench/browser/workbench.ts
class Workbench extends Layout {
startup(): IInstantiationService {
try {
// Configure emitter leak warning threshold
this._register(setGlobalLeakWarningThreshold(175));
// Services
const instantiationService = this.initServices(this.serviceCollection);
instantiationService.invokeFunction(accessor => {
const lifecycleService = accessor.get(ILifecycleService);
const storageService = accessor.get(IStorageService);
const configurationService = accessor.get(IConfigurationService);
const hostService = accessor.get(IHostService);
const hoverService = accessor.get(IHoverService);
const dialogService = accessor.get(IDialogService);
const notificationService = accessor.get(INotificationService) as NotificationService;
// Default Hover Delegate must be registered before creating any workbench/layout components
// as these possibly will use the default hover delegate
setHoverDelegateFactory((placement, enableInstantHover) => instantiationService.createInstance(WorkbenchHoverDelegate, placement, enableInstantHover, {}));
setBaseLayerHoverDelegate(hoverService);
// Layout
this.initLayout(accessor);
// Registries
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).start(accessor);
Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).start(accessor);
// Context Keys
this._register(instantiationService.createInstance(WorkbenchContextKeysHandler));
// Register Listeners
this.registerListeners(lifecycleService, storageService, configurationService, hostService, dialogService);
// Render Workbench
this.renderWorkbench(instantiationService, notificationService, storageService, configurationService);
// Workbench Layout
this.createWorkbenchLayout();
// Layout
this.layout();
// Restore
this.restore(lifecycleService);
});
return instantiationService;
} catch (error) {
onUnexpectedError(error);
throw error; // rethrow because this is a critical issue we cannot handle properly here
}
}
private initServices(serviceCollection: ServiceCollection): IInstantiationService {
// Layout Service
serviceCollection.set(IWorkbenchLayoutService, this);
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// NOTE: Please do NOT register services here. Use `registerSingleton()`
// from `workbench.common.main.ts` if the service is shared between
// desktop and web or `workbench.desktop.main.ts` if the service
// is desktop only.
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// All Contributed Services
const contributedServices = getSingletonServiceDescriptors();
for (const [id, descriptor] of contributedServices) {
serviceCollection.set(id, descriptor);
}
const instantiationService = new InstantiationService(serviceCollection, true);
// Wrap up
instantiationService.invokeFunction(accessor => {
const lifecycleService = accessor.get(ILifecycleService);
// TODO@Sandeep debt around cyclic dependencies
const configurationService = accessor.get(IConfigurationService) as any;
if (typeof configurationService.acquireInstantiationService === 'function') {
configurationService.acquireInstantiationService(instantiationService);
}
// Signal to lifecycle that services are set
lifecycleService.phase = LifecyclePhase.Ready;
});
return instantiationService;
}
}
layout.ts
ts
// src/vs/workbench/browser/layout.ts
abstract class Layout extends Disposable implements IWorkbenchLayoutService {
protected createWorkbenchLayout(): void {
const titleBar = this.getPart(Parts.TITLEBAR_PART);
const bannerPart = this.getPart(Parts.BANNER_PART);
const editorPart = this.getPart(Parts.EDITOR_PART);
const activityBar = this.getPart(Parts.ACTIVITYBAR_PART);
const panelPart = this.getPart(Parts.PANEL_PART);
const auxiliaryBarPart = this.getPart(Parts.AUXILIARYBAR_PART);
const sideBar = this.getPart(Parts.SIDEBAR_PART);
const statusBar = this.getPart(Parts.STATUSBAR_PART);
// View references for all parts
this.titleBarPartView = titleBar;
this.bannerPartView = bannerPart;
this.sideBarPartView = sideBar;
this.activityBarPartView = activityBar;
this.editorPartView = editorPart;
this.panelPartView = panelPart;
this.auxiliaryBarPartView = auxiliaryBarPart;
this.statusBarPartView = statusBar;
const viewMap = {
[Parts.ACTIVITYBAR_PART]: this.activityBarPartView,
[Parts.BANNER_PART]: this.bannerPartView,
[Parts.TITLEBAR_PART]: this.titleBarPartView,
[Parts.EDITOR_PART]: this.editorPartView,
[Parts.PANEL_PART]: this.panelPartView,
[Parts.SIDEBAR_PART]: this.sideBarPartView,
[Parts.STATUSBAR_PART]: this.statusBarPartView,
[Parts.AUXILIARYBAR_PART]: this.auxiliaryBarPartView
};
const fromJSON = ({ type }: { type: Parts }) => viewMap[type];
const workbenchGrid = SerializableGrid.deserialize(
this.createGridDescriptor(),
{ fromJSON },
{ proportionalLayout: false }
);
this.mainContainer.prepend(workbenchGrid.element);
this.mainContainer.setAttribute('role', 'application');
this.workbenchGrid = workbenchGrid;
this.workbenchGrid.edgeSnapping = this.state.runtime.mainWindowFullscreen;
for (const part of [titleBar, editorPart, activityBar, panelPart, sideBar, statusBar, auxiliaryBarPart, bannerPart]) {
this._register(part.onDidVisibilityChange((visible) => {
if (part === sideBar) {
this.setSideBarHidden(!visible, true);
} else if (part === panelPart) {
this.setPanelHidden(!visible, true);
} else if (part === auxiliaryBarPart) {
this.setAuxiliaryBarHidden(!visible, true);
} else if (part === editorPart) {
this.setEditorHidden(!visible, true);
}
this._onDidChangePartVisibility.fire();
this.handleContainerDidLayout(this.mainContainer, this._mainContainerDimension);
}));
}
this._register(this.storageService.onWillSaveState(e => {
// Side Bar Size
const sideBarSize = this.stateModel.getRuntimeValue(LayoutStateKeys.SIDEBAR_HIDDEN)
? this.workbenchGrid.getViewCachedVisibleSize(this.sideBarPartView)
: this.workbenchGrid.getViewSize(this.sideBarPartView).width;
this.stateModel.setInitializationValue(LayoutStateKeys.SIDEBAR_SIZE, sideBarSize as number);
// Panel Size
const panelSize = this.stateModel.getRuntimeValue(LayoutStateKeys.PANEL_HIDDEN)
? this.workbenchGrid.getViewCachedVisibleSize(this.panelPartView)
: isHorizontal(this.stateModel.getRuntimeValue(LayoutStateKeys.PANEL_POSITION))
? this.workbenchGrid.getViewSize(this.panelPartView).height
: this.workbenchGrid.getViewSize(this.panelPartView).width;
this.stateModel.setInitializationValue(LayoutStateKeys.PANEL_SIZE, panelSize as number);
// Auxiliary Bar Size
const auxiliaryBarSize = this.stateModel.getRuntimeValue(LayoutStateKeys.AUXILIARYBAR_HIDDEN)
? this.workbenchGrid.getViewCachedVisibleSize(this.auxiliaryBarPartView)
: this.workbenchGrid.getViewSize(this.auxiliaryBarPartView).width;
this.stateModel.setInitializationValue(LayoutStateKeys.AUXILIARYBAR_SIZE, auxiliaryBarSize as number);
this.stateModel.save(true, true);
}));
}
private createGridDescriptor(): ISerializedGrid {
const { width, height } = this.stateModel.getInitializationValue(LayoutStateKeys.GRID_SIZE);
const sideBarSize = this.stateModel.getInitializationValue(LayoutStateKeys.SIDEBAR_SIZE);
const auxiliaryBarPartSize = this.stateModel.getInitializationValue(LayoutStateKeys.AUXILIARYBAR_SIZE);
const panelSize = this.stateModel.getInitializationValue(LayoutStateKeys.PANEL_SIZE);
const titleBarHeight = this.titleBarPartView.minimumHeight;
const bannerHeight = this.bannerPartView.minimumHeight;
const statusBarHeight = this.statusBarPartView.minimumHeight;
const activityBarWidth = this.activityBarPartView.minimumWidth;
const middleSectionHeight = height - titleBarHeight - statusBarHeight;
const titleAndBanner: ISerializedNode[] = [
{
type: 'leaf',
data: { type: Parts.TITLEBAR_PART },
size: titleBarHeight,
visible: this.isVisible(Parts.TITLEBAR_PART, mainWindow)
},
{
type: 'leaf',
data: { type: Parts.BANNER_PART },
size: bannerHeight,
visible: false
}
];
const activityBarNode: ISerializedLeafNode = {
type: 'leaf',
data: { type: Parts.ACTIVITYBAR_PART },
size: activityBarWidth,
visible: !this.stateModel.getRuntimeValue(LayoutStateKeys.ACTIVITYBAR_HIDDEN)
};
const sideBarNode: ISerializedLeafNode = {
type: 'leaf',
data: { type: Parts.SIDEBAR_PART },
size: sideBarSize,
visible: !this.stateModel.getRuntimeValue(LayoutStateKeys.SIDEBAR_HIDDEN)
};
const auxiliaryBarNode: ISerializedLeafNode = {
type: 'leaf',
data: { type: Parts.AUXILIARYBAR_PART },
size: auxiliaryBarPartSize,
visible: this.isVisible(Parts.AUXILIARYBAR_PART)
};
const editorNode: ISerializedLeafNode = {
type: 'leaf',
data: { type: Parts.EDITOR_PART },
size: 0, // Update based on sibling sizes
visible: !this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_HIDDEN)
};
const panelNode: ISerializedLeafNode = {
type: 'leaf',
data: { type: Parts.PANEL_PART },
size: panelSize,
visible: !this.stateModel.getRuntimeValue(LayoutStateKeys.PANEL_HIDDEN)
};
const middleSection: ISerializedNode[] = this.arrangeMiddleSectionNodes({
activityBar: activityBarNode,
auxiliaryBar: auxiliaryBarNode,
editor: editorNode,
panel: panelNode,
sideBar: sideBarNode
}, width, middleSectionHeight);
const result: ISerializedGrid = {
root: {
type: 'branch',
size: width,
data: [
...(this.shouldShowBannerFirst() ? titleAndBanner.reverse() : titleAndBanner),
{
type: 'branch',
data: middleSection,
size: middleSectionHeight
},
{
type: 'leaf',
data: { type: Parts.STATUSBAR_PART },
size: statusBarHeight,
visible: !this.stateModel.getRuntimeValue(LayoutStateKeys.STATUSBAR_HIDDEN)
}
]
},
orientation: Orientation.VERTICAL,
width,
height
};
type StartupLayoutEvent = {
activityBarVisible: boolean;
sideBarVisible: boolean;
auxiliaryBarVisible: boolean;
panelVisible: boolean;
statusbarVisible: boolean;
sideBarPosition: string;
panelPosition: string;
};
type StartupLayoutEventClassification = {
owner: 'sbatten';
comment: 'Information about the layout of the workbench during statup';
activityBarVisible: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether or the not the activity bar is visible' };
sideBarVisible: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether or the not the primary side bar is visible' };
auxiliaryBarVisible: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether or the not the secondary side bar is visible' };
panelVisible: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether or the not the panel is visible' };
statusbarVisible: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether or the not the status bar is visible' };
sideBarPosition: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the primary side bar is on the left or right' };
panelPosition: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the panel is on the top, bottom, left, or right' };
};
const layoutDescriptor: StartupLayoutEvent = {
activityBarVisible: !this.stateModel.getRuntimeValue(LayoutStateKeys.ACTIVITYBAR_HIDDEN),
sideBarVisible: !this.stateModel.getRuntimeValue(LayoutStateKeys.SIDEBAR_HIDDEN),
auxiliaryBarVisible: !this.stateModel.getRuntimeValue(LayoutStateKeys.AUXILIARYBAR_HIDDEN),
panelVisible: !this.stateModel.getRuntimeValue(LayoutStateKeys.PANEL_HIDDEN),
statusbarVisible: !this.stateModel.getRuntimeValue(LayoutStateKeys.STATUSBAR_HIDDEN),
sideBarPosition: positionToString(this.stateModel.getRuntimeValue(LayoutStateKeys.SIDEBAR_POSITON)),
panelPosition: positionToString(this.stateModel.getRuntimeValue(LayoutStateKeys.PANEL_POSITION)),
};
this.telemetryService.publicLog2<StartupLayoutEvent, StartupLayoutEventClassification>('startupLayout', layoutDescriptor);
return result;
}
}
grid.ts
ts
// src/vs/base/browser/ui/grid/grid.ts
class SerializableGrid {
/**
* Construct a new {@link SerializableGrid} from a JSON object.
*
* @param json The JSON object.
* @param deserializer A deserializer which can revive each view.
* @returns A new {@link SerializableGrid} instance.
*/
static deserialize<T extends ISerializableView>(json: ISerializedGrid, deserializer: IViewDeserializer<T>, options: IGridOptions = {}): SerializableGrid<T> {
if (typeof json.orientation !== 'number') {
throw new Error('Invalid JSON: \'orientation\' property must be a number.');
} else if (typeof json.width !== 'number') {
throw new Error('Invalid JSON: \'width\' property must be a number.');
} else if (typeof json.height !== 'number') {
throw new Error('Invalid JSON: \'height\' property must be a number.');
}
const gridview = GridView.deserialize(json, deserializer, options);
const result = new SerializableGrid<T>(gridview, options);
return result;
}
}
gridview.ts
ts
// src/vs/base/browser/ui/grid/gridview.ts
class GridView {
/**
* Construct a new {@link GridView} from a JSON object.
*
* @param json The JSON object.
* @param deserializer A deserializer which can revive each view.
* @returns A new {@link GridView} instance.
*/
static deserialize<T extends ISerializableView>(json: ISerializedGridView, deserializer: IViewDeserializer<T>, options: IGridViewOptions = {}): GridView {
if (typeof json.orientation !== 'number') {
throw new Error('Invalid JSON: \'orientation\' property must be a number.');
} else if (typeof json.width !== 'number') {
throw new Error('Invalid JSON: \'width\' property must be a number.');
} else if (typeof json.height !== 'number') {
throw new Error('Invalid JSON: \'height\' property must be a number.');
} else if (json.root?.type !== 'branch') {
throw new Error('Invalid JSON: \'root\' property must have \'type\' value of branch.');
}
const orientation = json.orientation;
const height = json.height;
const result = new GridView(options);
result._deserialize(json.root as ISerializedBranchNode, orientation, deserializer, height);
return result;
}
private _deserialize(root: ISerializedBranchNode, orientation: Orientation, deserializer: IViewDeserializer<ISerializableView>, orthogonalSize: number): void {
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize) as BranchNode;
}
private _deserializeNode(node: ISerializedNode, orientation: Orientation, deserializer: IViewDeserializer<ISerializableView>, orthogonalSize: number): Node {
let result: Node;
if (node.type === 'branch') {
const serializedChildren = node.data as ISerializedNode[];
const children = serializedChildren.map(serializedChild => {
return {
node: this._deserializeNode(serializedChild, orthogonal(orientation), deserializer, node.size),
visible: (serializedChild as { visible?: boolean }).visible
} satisfies INodeDescriptor;
});
result = new BranchNode(orientation, this.layoutController, this.styles, this.proportionalLayout, node.size, orthogonalSize, undefined, children);
} else {
result = new LeafNode(deserializer.fromJSON(node.data), orientation, this.layoutController, orthogonalSize, node.size);
if (node.maximized && !this.maximizedNode) {
this.maximizedNode = result;
this._onDidChangeViewMaximized.fire(true);
}
}
return result;
}
}
workbench tree(json and elements)
json data
json
{
root: {
type: "branch",
size: 881,
data: [
{
type: "leaf",
data: {
type: "workbench.parts.banner",
},
size: 0,
visible: false,
},
{
type: "leaf",
data: {
type: "workbench.parts.titlebar",
},
size: 35,
visible: true,
},
{
type: "branch",
data: [
{
type: "leaf",
data: {
type: "workbench.parts.activitybar",
},
size: 48,
visible: true,
},
{
type: "leaf",
data: {
type: "workbench.parts.sidebar",
},
size: 220,
visible: true,
},
{
type: "branch",
data: [
{
type: "leaf",
data: {
type: "workbench.parts.editor",
},
size: 744,
visible: true,
},
{
type: "leaf",
data: {
type: "workbench.parts.panel",
},
size: 267,
visible: false,
},
],
size: 613,
},
{
type: "leaf",
data: {
type: "workbench.parts.auxiliarybar",
},
size: 220,
visible: false,
},
],
size: 744,
},
{
type: "leaf",
data: {
type: "workbench.parts.statusbar",
},
size: 22,
visible: true,
},
],
},
orientation: 0,
width: 881,
height: 801,
}
elements nodes
html
<div class="file-icons-enabled enable-motion monaco-workbench windows chromium noauxiliarybar vs-dark vscode-theme-defaults-themes-dark_modern-json" role="application">
<!-- branch node -->
<div class="monaco-grid-view">
<div class="monaco-grid-branch-node">
<div class="monaco-split-view2 vertical">
<div class="sash-container"></div>
<div class="monaco-scrollable-element" role="presentation">
<div class="split-view-container">
<!-- leaf node: titlebar -->
<div class="split-view-view visible">
<div class="part titlebar inactive" id="workbench.parts.titlebar" role="none"> </div>
</div>
<!-- leaf node: banner -->
<div class="split-view-view">
<div class="part banner" id="workbench.parts.banner" role="banner"></div>
</div>
<!-- branch node: activetybar sidebar auxiliarybar editor and panel -->
<div class="split-view-view visible">
<div class="monaco-grid-branch-node">
<div class="monaco-split-view2 horizontal">
<div class="sash-container"> </div>
<div class="monaco-scrollable-element " role="presentation">
<div class="split-view-container">
<!-- leaf node: activetybar -->
<div class="split-view-view visible">
<div class="part activitybar left bordered" id="workbench.parts.activitybar" role="none"> </div>
</div>
<!-- leaf node: sidebar -->
<div class="split-view-view visible">
<div class="part sidebar left pane-composite-part" id="workbench.parts.sidebar" role="none">
</div>
</div>
<!-- branch node: editor and panel -->
<div class="split-view-view visible">
<div class="monaco-grid-branch-node">
<div class="monaco-split-view2 vertical">
<div class="sash-container"></div>
<div class="monaco-scrollable-element " role="presentation">
<div class="split-view-container">
<!-- leaf node: editor -->
<div class="split-view-view visible">
<div class="part editor" id="workbench.parts.editor" role="main"> </div>
</div>
<!-- leaf node: panel -->
<div class="split-view-view visible">
<div class="part panel basepanel bottom pane-composite-part" id="workbench.parts.panel" role="none"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- leaf node: auxiliarybar -->
<div class="split-view-view">
<div class="part auxiliarybar basepanel right pane-composite-part" id="workbench.parts.auxiliarybar" role="none"> </div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- leaf node: statusbar -->
<div class="split-view-view visible">
<footer class="part statusbar status-border-top" id="workbench.parts.statusbar" role="status"> </footer>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
part render steps
html elements
statusbar
html
<footer class="part statusbar" id="workbench.parts.statusbar" role="status">
<div class="left-items items-container">
<div id="status.host" class="statusbar-item left remote-kind has-background-color first-visible-item"
aria-label="remote" custom-hover="true">
<a tabindex="-1" role="button" class="statusbar-item-label" aria-label="remote">
<span class="codicon codicon-remote"></span>
</a>
<div class="status-bar-item-beak-container"></div>
</div>
<div id="antfu.where-am-i" class="statusbar-item left" aria-label="folder-opened Notes" custom-hover="true"><a
tabindex="-1" role="button" class="statusbar-item-label" aria-label="folder-opened Notes"
style="color: rgb(199, 160, 131);"><span class="codicon codicon-folder-opened"></span> Notes</a>
<div class="status-bar-item-beak-container"></div>
</div>
</div>
<div class="right-items items-container">
<div id="status.notifications" class="statusbar-item right last-visible-item" aria-label="Notifications"
custom-hover="true">
<a tabindex="-1" role="button" class="statusbar-item-label" aria-label="Notifications">
<span class="codicon codicon-bell"></span>
</a>
<div class="status-bar-item-beak-container"></div>
</div>
<div id="ritwickdey.LiveServer" class="statusbar-item right"
aria-label="broadcast Go Live, Click to run live server" custom-hover="true" aria-hidden="true"
style="display: none;">
<a tabindex="-1" role="button" class="statusbar-item-label"
aria-label="broadcast Go Live, Click to run live server">
<span class="codicon codicon-broadcast"></span>
Go Live
</a>
<div class="status-bar-item-beak-container"></div>
</div>
</div>
</footer>
panelbar
html