AbdulElahGwaith commited on
Commit
6202252
·
verified ·
1 Parent(s): 3b05920

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .base-sample/.gitignore +4 -0
  2. .base-sample/.vscode/extensions.json +9 -0
  3. .base-sample/.vscode/launch.json +35 -0
  4. .base-sample/.vscode/settings.json +3 -0
  5. .base-sample/.vscode/tasks.json +20 -0
  6. .base-sample/.vscodeignore +8 -0
  7. .base-sample/README.md +5 -0
  8. .base-sample/demo.gif +3 -0
  9. .base-sample/eslint.config.mjs +44 -0
  10. .base-sample/package.json +44 -0
  11. .base-sample/src/extension.ts +23 -0
  12. .base-sample/tsconfig.json +17 -0
  13. .editorconfig +3 -0
  14. .gitattributes +37 -0
  15. .github/CONTRIBUTING.md +3 -0
  16. .github/ISSUE_TEMPLATE/config.yml +8 -0
  17. .github/ISSUE_TEMPLATE/report-issue.yml +35 -0
  18. .github/SAMPLE_GUIDELINE.md +40 -0
  19. .github/commands.json +400 -0
  20. .github/workflows/ci.yml +16 -0
  21. .github/workflows/npm-publish.yml +33 -0
  22. .github/workflows/triage.yml +50 -0
  23. .gitignore +13 -0
  24. .lsifrc.json +4 -0
  25. .prettierrc.json +5 -0
  26. .scripts/copy-into.ts +23 -0
  27. .scripts/format.ts +82 -0
  28. .scripts/run-command.ts +33 -0
  29. .scripts/run-script.ts +26 -0
  30. .scripts/samples.ts +407 -0
  31. .scripts/tsconfig.json +15 -0
  32. .scripts/update-dependency.ts +51 -0
  33. .scripts/update-lsif.ts +31 -0
  34. .scripts/update-readme.ts +74 -0
  35. .scripts/validate.ts +56 -0
  36. .vscode/settings.json +14 -0
  37. LICENSE +21 -0
  38. README.md +95 -0
  39. SECURITY.md +41 -0
  40. authenticationprovider-sample/.vscode/extensions.json +7 -0
  41. authenticationprovider-sample/.vscode/launch.json +34 -0
  42. authenticationprovider-sample/.vscode/settings.json +11 -0
  43. authenticationprovider-sample/.vscode/tasks.json +20 -0
  44. authenticationprovider-sample/.vscodeignore +12 -0
  45. authenticationprovider-sample/CHANGELOG.md +9 -0
  46. authenticationprovider-sample/README.md +20 -0
  47. authenticationprovider-sample/eslint.config.mjs +44 -0
  48. authenticationprovider-sample/package-lock.json +0 -0
  49. authenticationprovider-sample/package.json +49 -0
  50. authenticationprovider-sample/src/authProvider.ts +147 -0
.base-sample/.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ out
2
+ node_modules
3
+ .vscode-test/
4
+ *.vsix
.base-sample/.vscode/extensions.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3
+ // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4
+
5
+ // List of extensions which should be recommended for users of this workspace.
6
+ "recommendations": [
7
+ "dbaeumer.vscode-eslint"
8
+ ]
9
+ }
.base-sample/.vscode/launch.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // A launch configuration that compiles the extension and then opens it inside a new window
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ {
6
+ "version": "0.2.0",
7
+ "configurations": [{
8
+ "name": "Run Extension",
9
+ "type": "extensionHost",
10
+ "request": "launch",
11
+ "runtimeExecutable": "${execPath}",
12
+ "args": [
13
+ "--extensionDevelopmentPath=${workspaceFolder}"
14
+ ],
15
+ "outFiles": [
16
+ "${workspaceFolder}/out/**/*.js"
17
+ ],
18
+ "preLaunchTask": "npm: watch"
19
+ },
20
+ {
21
+ "name": "Run Extension Tests",
22
+ "type": "extensionHost",
23
+ "request": "launch",
24
+ "runtimeExecutable": "${execPath}",
25
+ "args": [
26
+ "--extensionDevelopmentPath=${workspaceFolder}",
27
+ "--extensionTestsPath=${workspaceFolder}/out/test"
28
+ ],
29
+ "outFiles": [
30
+ "${workspaceFolder}/out/test/**/*.js"
31
+ ],
32
+ "preLaunchTask": "npm: watch"
33
+ }
34
+ ]
35
+ }
.base-sample/.vscode/settings.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "editor.insertSpaces": false
3
+ }
.base-sample/.vscode/tasks.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
2
+ // for the documentation about the tasks.json format
3
+ {
4
+ "version": "2.0.0",
5
+ "tasks": [
6
+ {
7
+ "type": "npm",
8
+ "script": "watch",
9
+ "problemMatcher": "$tsc-watch",
10
+ "isBackground": true,
11
+ "presentation": {
12
+ "reveal": "never"
13
+ },
14
+ "group": {
15
+ "kind": "build",
16
+ "isDefault": true
17
+ }
18
+ }
19
+ ]
20
+ }
.base-sample/.vscodeignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ .vscode/**
2
+ .vscode-test/**
3
+ out/test/**
4
+ out/**/*.map
5
+ src/**
6
+ .gitignore
7
+ tsconfig.json
8
+ vsc-extension-quickstart.md
.base-sample/README.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Base Sample
2
+
3
+ This sample is similar to the [helloworld-sample](../helloworld-sample), but it follows the [Sample Guideline](https://github.com/Microsoft/vscode-extension-samples/blob/main/.github/SAMPLE_GUIDELINE.md).
4
+
5
+ You can easily write a new sample following the guideline by `cp -r .base-sample my-sample`.
.base-sample/demo.gif ADDED

Git LFS Details

  • SHA256: eb75c985e695b9be20277ae6f12bf58955baad22d6e8680df9d3be4410f8930c
  • Pointer size: 131 Bytes
  • Size of remote file: 867 kB
.base-sample/eslint.config.mjs ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * ESLint configuration for the project.
3
+ *
4
+ * See https://eslint.style and https://typescript-eslint.io for additional linting options.
5
+ */
6
+ // @ts-check
7
+ import js from '@eslint/js';
8
+ import tseslint from 'typescript-eslint';
9
+ import stylistic from '@stylistic/eslint-plugin';
10
+
11
+ export default tseslint.config(
12
+ {
13
+ ignores: [
14
+ '.vscode-test',
15
+ 'out',
16
+ ]
17
+ },
18
+ js.configs.recommended,
19
+ ...tseslint.configs.recommended,
20
+ ...tseslint.configs.stylistic,
21
+ {
22
+ plugins: {
23
+ '@stylistic': stylistic
24
+ },
25
+ rules: {
26
+ 'curly': 'warn',
27
+ '@stylistic/semi': ['warn', 'always'],
28
+ '@typescript-eslint/no-empty-function': 'off',
29
+ '@typescript-eslint/naming-convention': [
30
+ 'warn',
31
+ {
32
+ 'selector': 'import',
33
+ 'format': ['camelCase', 'PascalCase']
34
+ }
35
+ ],
36
+ '@typescript-eslint/no-unused-vars': [
37
+ 'error',
38
+ {
39
+ 'argsIgnorePattern': '^_'
40
+ }
41
+ ]
42
+ }
43
+ }
44
+ );
.base-sample/package.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "base-sample",
3
+ "displayName": "base-sample",
4
+ "description": "Base sample for other samples at Microsoft/vscode-extension-samples",
5
+ "version": "0.0.1",
6
+ "publisher": "vscode-samples",
7
+ "private": true,
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/Microsoft/vscode-extension-samples"
12
+ },
13
+ "engines": {
14
+ "vscode": "^1.100.0"
15
+ },
16
+ "categories": [
17
+ "Other"
18
+ ],
19
+ "activationEvents": [],
20
+ "main": "./out/extension.js",
21
+ "contributes": {
22
+ "commands": [
23
+ {
24
+ "command": "extension.helloWorld",
25
+ "title": "Hello World"
26
+ }
27
+ ]
28
+ },
29
+ "scripts": {
30
+ "vscode:prepublish": "npm run compile",
31
+ "compile": "tsc -p ./",
32
+ "lint": "eslint",
33
+ "watch": "tsc -watch -p ./"
34
+ },
35
+ "devDependencies": {
36
+ "@eslint/js": "^9.13.0",
37
+ "@stylistic/eslint-plugin": "^2.9.0",
38
+ "@types/node": "^22",
39
+ "@types/vscode": "^1.100.0",
40
+ "eslint": "^9.13.0",
41
+ "typescript": "^5.8.2",
42
+ "typescript-eslint": "^8.26.0"
43
+ }
44
+ }
.base-sample/src/extension.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // The module 'vscode' contains the VS Code extensibility API
2
+ // Import the module and reference it with the alias vscode in your code below
3
+ import * as vscode from 'vscode';
4
+
5
+ // this method is called when your extension is activated
6
+ // your extension is activated the very first time the command is executed
7
+ export function activate(context: vscode.ExtensionContext) {
8
+ // Use the console to output diagnostic information (console.log) and errors (console.error)
9
+ // This line of code will only be executed once when your extension is activated
10
+ console.log('Congratulations, your extension "helloworld-sample" is now active!');
11
+
12
+ // The command has been defined in the package.json file
13
+ // Now provide the implementation of the command with registerCommand
14
+ // The commandId parameter must match the command field in package.json
15
+ const disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
16
+ // The code you place here will be executed every time your command is executed
17
+
18
+ // Display a message box to the user
19
+ vscode.window.showInformationMessage('Hello World!');
20
+ });
21
+
22
+ context.subscriptions.push(disposable);
23
+ }
.base-sample/tsconfig.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "target": "ES2024",
5
+ "lib": [
6
+ "ES2024"
7
+ ],
8
+ "outDir": "out",
9
+ "sourceMap": true,
10
+ "rootDir": "src",
11
+ "strict": true
12
+ },
13
+ "exclude": [
14
+ "node_modules",
15
+ ".vscode-test"
16
+ ]
17
+ }
.editorconfig ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [*.{ts,tsx,js,jsx,json}]
2
+ indent_style = tab
3
+ tab_width = 4
.gitattributes CHANGED
@@ -33,3 +33,40 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ .base-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
37
+ basic-multi-root-sample/preview.gif filter=lfs diff=lfs merge=lfs -text
38
+ call-hierarchy-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
39
+ chat-sample/demo.png filter=lfs diff=lfs merge=lfs -text
40
+ code-actions-sample/example.gif filter=lfs diff=lfs merge=lfs -text
41
+ code-actions-sample/example_diagnostic.gif filter=lfs diff=lfs merge=lfs -text
42
+ codelens-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
43
+ comment-sample/wiki-demo.gif filter=lfs diff=lfs merge=lfs -text
44
+ completions-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
45
+ contentprovider-sample/preview.gif filter=lfs diff=lfs merge=lfs -text
46
+ custom-data-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
47
+ custom-editor-sample/documentation/example.png filter=lfs diff=lfs merge=lfs -text
48
+ diagnostic-related-information-sample/resources/diagnostic-related-info.png filter=lfs diff=lfs merge=lfs -text
49
+ document-editing-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
50
+ fsprovider-sample/sample.png filter=lfs diff=lfs merge=lfs -text
51
+ getting-started-sample/media/preview.png filter=lfs diff=lfs merge=lfs -text
52
+ getting-started-sample/media/sample.png filter=lfs diff=lfs merge=lfs -text
53
+ github-authentication-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
54
+ helloworld-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
55
+ helloworld-test-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
56
+ inline-completions/demo.gif filter=lfs diff=lfs merge=lfs -text
57
+ jupyter-server-provider-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
58
+ lsp-log-streaming-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
59
+ notebook-renderer-sample/notebook-renderer-sample.gif filter=lfs diff=lfs merge=lfs -text
60
+ notifications-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
61
+ quickinput-sample/preview.gif filter=lfs diff=lfs merge=lfs -text
62
+ source-control-sample/resources/images/demo.gif filter=lfs diff=lfs merge=lfs -text
63
+ source-control-sample/resources/images/multi-workspace-folder.gif filter=lfs diff=lfs merge=lfs -text
64
+ statusbar-sample/preview.gif filter=lfs diff=lfs merge=lfs -text
65
+ theme-sample/demo-dark.png filter=lfs diff=lfs merge=lfs -text
66
+ theme-sample/demo-light.png filter=lfs diff=lfs merge=lfs -text
67
+ tree-view-sample/resources/package-explorer.png filter=lfs diff=lfs merge=lfs -text
68
+ vim-sample/example.gif filter=lfs diff=lfs merge=lfs -text
69
+ virtual-document-sample/cowsay.gif filter=lfs diff=lfs merge=lfs -text
70
+ webview-codicons-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
71
+ webview-sample/demo.gif filter=lfs diff=lfs merge=lfs -text
72
+ webview-sample/media/cat.gif filter=lfs diff=lfs merge=lfs -text
.github/CONTRIBUTING.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Contributing to vscode-extension-samples
2
+
3
+ If you want to contribute a new sample, see [Sample Guideline](./SAMPLE_GUIDELINE.md)
.github/ISSUE_TEMPLATE/config.yml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: 🙋 Ask Question
4
+ about: Ask questions about developing VS Code extensions on Stack Overflow.
5
+ url: 'https://stackoverflow.com/questions/tagged/vscode-extensions'
6
+ - name: 💬 Discuss
7
+ url: https://github.com/microsoft/vscode-discussions/discussions
8
+ about: Discuss extension development questions and ideas with the VS Code developer community.
.github/ISSUE_TEMPLATE/report-issue.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 🐛 Report Extension Sample Issue
2
+ description: Report an issue with one of the extension samples.
3
+ body:
4
+ - type: markdown
5
+ attributes:
6
+ value: |
7
+ Thank you for taking the time to fill out this bug report! Please make sure to fill in the following sections:
8
+ - type: input
9
+ id: sample-name
10
+ attributes:
11
+ label: Extension sample
12
+ description: Name of the extension sample that you are reporting with issue in
13
+ placeholder: extension-sample-name
14
+ validations:
15
+ required: true
16
+ - type: input
17
+ id: vscode-version
18
+ attributes:
19
+ label: VS Code version
20
+ description: The version of VS Code that the issue reproduces in
21
+ placeholder: 1.xx.x
22
+ validations:
23
+ required: true
24
+ - type: textarea
25
+ id: what-happened
26
+ attributes:
27
+ label: What went wrong?
28
+ description: |
29
+ Tell us what what went wrong. Be sure to include:
30
+
31
+ - What were you trying to do?
32
+ - What went wrong?
33
+ - What was the expected behavior?
34
+ validations:
35
+ required: true
.github/SAMPLE_GUIDELINE.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Sample Guideline
2
+
3
+ Each sample should have the following components and structure, so that users could have a smooth experience when playing with different samples.
4
+ The quickest way is to start your project by copying [.base-sample](https://github.com/microsoft/vscode-extension-samples/tree/main/.base-sample).
5
+
6
+ ## 1: Sample Listing
7
+
8
+ - 1.1: Each sample should add itself to the sample listing at `.scripts/samples.js`. This file will be used for generating tables in the README and on the [Extension Guides / Overview](https://code.visualstudio.com/api/extension-guides/overview) topic of the website.
9
+ - 1.2: Each sample should list the API / Contribution that it means to illustrate.
10
+
11
+ ## 2: README
12
+
13
+ - 2.1: Each README should start with a short sentence / paragraph that describes what the extensions is and what it is meant to illustrate.
14
+ - 2.2: If the sample has a corresponding guide, it should link to the guide.
15
+ - 2.3: If the illustrated functionality is visual, a gif/image should follow the explanation. (File should be demo.png/gif/jpg. Use default Dark+/Light+ theme)
16
+ - 2.4: A `VS Code API` section listing the illustrated API, Contribution Points and Activation Events.
17
+ - 2.5: A `Running the Sample` section should describe the actions to run the sample.
18
+
19
+ ## 3: .vscode
20
+
21
+ - 3.1: `launch.json`: use 0.2.0 version.
22
+ - 3.2: `settings.json`: use `"editor.insertSpaces": false`. This ensures when user opens the subfolder, tab indentation is enforced.
23
+
24
+ ## 4: Dependencies
25
+
26
+ - 4.1: Use `npm`'s `package-lock.json` instead of `yarn.lock`.
27
+ - 4.2: `devDependencies` should include `@types/node`, `@types/vscode`, `@typescript-eslint/eslint-plugin`, `@typescript-eslint/parser`, `eslint`, and `typescript`.
28
+
29
+ ## 5: Formatter and Linter
30
+
31
+ Only deviate from the standard setting if your sample needs to.
32
+
33
+ - 5.1: Include a `.eslintrc.js` following <https://github.com/microsoft/vscode-extension-samples/blob/main/helloworld-sample/.eslintrc.js>.
34
+ - 5.2: Include a `tsconfig.json` following <https://github.com/microsoft/vscode-extension-samples/blob/main/helloworld-sample/tsconfig.json>.
35
+ - 5.3: Your source code should be formatted either using [tsfmt](https://github.com/vvakame/typescript-formatter) or the editor's TS formatter and contain no ESLint/TS errors.
36
+
37
+ ## 6: Tests
38
+
39
+ - 6.1: If your extension does not have meaningful tests, remove the `src/test` folder.
40
+ - 6.2: If your extension can be meaningfully tested, include a sample test. If you have an associated guide, explain the test in the guide.
.github/commands.json ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "comment",
4
+ "name": "question",
5
+ "allowUsers": [
6
+ "cleidigh",
7
+ "usernamehw",
8
+ "gjsjohnmurray",
9
+ "IllusionMH"
10
+ ],
11
+ "action": "updateLabels",
12
+ "addLabel": "*question"
13
+ },
14
+ {
15
+ "type": "comment",
16
+ "name": "needsPerfInfo",
17
+ "allowUsers": [
18
+ "cleidigh",
19
+ "usernamehw",
20
+ "gjsjohnmurray",
21
+ "IllusionMH"
22
+ ],
23
+ "addLabel": "info-needed",
24
+ "comment": "Thanks for creating this issue regarding performance! Please follow this guide to help us diagnose performance issues: https://github.com/microsoft/vscode/wiki/Performance-Issues \n\nHappy Coding!"
25
+ },
26
+ {
27
+ "type": "label",
28
+ "name": "*question",
29
+ "action": "close",
30
+ "comment": "Please ask your question on [StackOverflow](https://aka.ms/vscodestackoverflow). We have a great community over [there](https://aka.ms/vscodestackoverflow). They have already answered thousands of questions and are happy to answer yours as well. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines.\n\nHappy Coding!"
31
+ },
32
+ {
33
+ "type": "label",
34
+ "name": "*dev-question",
35
+ "action": "close",
36
+ "comment": "We have a great developer community [over on slack](https://aka.ms/vscode-dev-community) where extension authors help each other. This is a great place for you to ask questions and find support.\n\nHappy Coding!"
37
+ },
38
+ {
39
+ "type": "label",
40
+ "name": "*extension-candidate",
41
+ "action": "close",
42
+ "comment": "We try to keep VS Code lean and we think the functionality you're asking for is great for a VS Code extension. Maybe you can already find one that suits you in the [VS Code Marketplace](https://aka.ms/vscodemarketplace). Just in case, in a few simple steps you can get started [writing your own extension](https://aka.ms/vscodewritingextensions). See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines.\n\nHappy Coding!"
43
+ },
44
+ {
45
+ "type": "label",
46
+ "name": "*not-reproducible",
47
+ "action": "close",
48
+ "comment": "We closed this issue because we are unable to reproduce the problem with the steps you describe. Chances are we've already fixed your problem in a recent version of VS Code. If not, please ask us to reopen the issue and provide us with more detail. Our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines might help you with that.\n\nHappy Coding!"
49
+ },
50
+ {
51
+ "type": "label",
52
+ "name": "*out-of-scope",
53
+ "action": "close",
54
+ "comment": "We closed this issue because we don't plan to address it in the foreseeable future. You can find more detailed information about our decision-making process [here](https://aka.ms/vscode-out-of-scope). If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.\n\nIf you wonder what we are up to, please see our [roadmap](https://aka.ms/vscoderoadmap) and [issue reporting](https://aka.ms/vscodeissuereporting) guidelines.\n\nThanks for your understanding and happy coding!"
55
+ },
56
+ {
57
+ "type": "comment",
58
+ "name": "causedByExtension",
59
+ "allowUsers": [
60
+ "cleidigh",
61
+ "usernamehw",
62
+ "gjsjohnmurray",
63
+ "IllusionMH"
64
+ ],
65
+ "action": "updateLabels",
66
+ "addLabel": "*caused-by-extension"
67
+ },
68
+ {
69
+ "type": "label",
70
+ "name": "*caused-by-extension",
71
+ "action": "close",
72
+ "comment": "This issue is caused by an extension, please file it with the repository (or contact) the extension has linked in its overview in VS Code or the [marketplace](https://aka.ms/vscodemarketplace) for VS Code. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines.\n\nHappy Coding!"
73
+ },
74
+ {
75
+ "type": "label",
76
+ "name": "*as-designed",
77
+ "action": "close",
78
+ "comment": "The described behavior is how it is expected to work. If you disagree, please explain what is expected and what is not in more detail. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines.\n\nHappy Coding!"
79
+ },
80
+ {
81
+ "type": "comment",
82
+ "name": "duplicate",
83
+ "allowUsers": [
84
+ "cleidigh",
85
+ "usernamehw",
86
+ "gjsjohnmurray",
87
+ "IllusionMH"
88
+ ],
89
+ "action": "updateLabels",
90
+ "addLabel": "*duplicate"
91
+ },
92
+ {
93
+ "type": "label",
94
+ "name": "*duplicate",
95
+ "action": "close",
96
+ "comment": "Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues [here](https://aka.ms/vscodeissuesearch). See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines.\n\nHappy Coding!"
97
+ },
98
+ {
99
+ "type": "comment",
100
+ "name": "verified",
101
+ "allowUsers": [
102
+ "@author"
103
+ ],
104
+ "action": "updateLabels",
105
+ "addLabel": "z-author-verified",
106
+ "removeLabel": "author-verification-requested",
107
+ "requireLabel": "author-verification-requested",
108
+ "disallowLabel": "awaiting-insiders-release"
109
+ },
110
+ {
111
+ "type": "comment",
112
+ "name": "confirm",
113
+ "allowUsers": [
114
+ "cleidigh",
115
+ "usernamehw",
116
+ "gjsjohnmurray",
117
+ "IllusionMH"
118
+ ],
119
+ "action": "updateLabels",
120
+ "addLabel": "confirmed",
121
+ "removeLabel": "confirmation-pending"
122
+ },
123
+ {
124
+ "type": "comment",
125
+ "name": "confirmationPending",
126
+ "allowUsers": [
127
+ "cleidigh",
128
+ "usernamehw",
129
+ "gjsjohnmurray",
130
+ "IllusionMH"
131
+ ],
132
+ "action": "updateLabels",
133
+ "addLabel": "confirmation-pending",
134
+ "removeLabel": "confirmed"
135
+ },
136
+ {
137
+ "type": "comment",
138
+ "name": "needsMoreInfo",
139
+ "allowUsers": [
140
+ "cleidigh",
141
+ "usernamehw",
142
+ "gjsjohnmurray",
143
+ "IllusionMH"
144
+ ],
145
+ "action": "updateLabels",
146
+ "addLabel": "~info-needed"
147
+ },
148
+ {
149
+ "type": "comment",
150
+ "name": "jsDebugLogs",
151
+ "action": "updateLabels",
152
+ "addLabel": "info-needed",
153
+ "comment": "Please collect trace logs using the following instructions:\n\n> If you're able to, add `\"trace\": true` to your `launch.json` and reproduce the issue. The location of the log file on your disk will be written to the Debug Console. Share that with us.\n>\n> ⚠️ This log file will not contain source code, but will contain file paths. You can drop it into https://microsoft.github.io/vscode-pwa-analyzer/index.html to see what it contains. If you'd rather not share the log publicly, you can email it to connor@xbox.com"
154
+ },
155
+ {
156
+ "type": "comment",
157
+ "name": "closedWith",
158
+ "allowUsers": [
159
+ "cleidigh",
160
+ "usernamehw",
161
+ "gjsjohnmurray",
162
+ "IllusionMH"
163
+ ],
164
+ "action": "close",
165
+ "addLabel": "unreleased"
166
+ },
167
+ {
168
+ "type": "label",
169
+ "name": "~info-needed",
170
+ "action": "updateLabels",
171
+ "addLabel": "info-needed",
172
+ "removeLabel": "~info-needed",
173
+ "comment": "Thanks for creating this issue! We figured it's missing some basic information or in some other way doesn't follow our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines. Please take the time to review these and update the issue.\n\nHappy Coding!"
174
+ },
175
+ {
176
+ "type": "label",
177
+ "name": "~version-info-needed",
178
+ "action": "updateLabels",
179
+ "addLabel": "info-needed",
180
+ "removeLabel": "~version-info-needed",
181
+ "comment": "Thanks for creating this issue! We figured it's missing some basic information, such as a version number, or in some other way doesn't follow our [issue reporting guidelines](https://aka.ms/vscodeissuereporting). Please take the time to review these and update the issue.\n\nHappy Coding!"
182
+ },
183
+ {
184
+ "type": "comment",
185
+ "name": "a11ymas",
186
+ "allowUsers": [
187
+ "AccessibilityTestingTeam-TCS",
188
+ "dixitsonali95",
189
+ "Mohini78",
190
+ "ChitrarupaSharma",
191
+ "mspatil110",
192
+ "umasarath52",
193
+ "v-umnaik"
194
+ ],
195
+ "action": "updateLabels",
196
+ "addLabel": "a11ymas"
197
+ },
198
+ {
199
+ "type": "label",
200
+ "name": "*off-topic",
201
+ "action": "close",
202
+ "comment": "Thanks for creating this issue. We think this issue is unactionable or unrelated to the goals of this project. Please follow our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines.\n\nHappy Coding!"
203
+ },
204
+ {
205
+ "type": "comment",
206
+ "name": "extPython",
207
+ "allowUsers": [
208
+ "cleidigh",
209
+ "usernamehw",
210
+ "gjsjohnmurray",
211
+ "IllusionMH"
212
+ ],
213
+ "action": "close",
214
+ "addLabel": "*caused-by-extension",
215
+ "comment": "It looks like this is caused by the Python extension. Please file it with the repository [here](https://github.com/microsoft/vscode-python). Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
216
+ },
217
+ {
218
+ "type": "comment",
219
+ "name": "extC",
220
+ "allowUsers": [
221
+ "cleidigh",
222
+ "usernamehw",
223
+ "gjsjohnmurray",
224
+ "IllusionMH"
225
+ ],
226
+ "action": "close",
227
+ "addLabel": "*caused-by-extension",
228
+ "comment": "It looks like this is caused by the C extension. Please file it with the repository [here](https://github.com/microsoft/vscode-cpptools). Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
229
+ },
230
+ {
231
+ "type": "comment",
232
+ "name": "extC++",
233
+ "allowUsers": [
234
+ "cleidigh",
235
+ "usernamehw",
236
+ "gjsjohnmurray",
237
+ "IllusionMH"
238
+ ],
239
+ "action": "close",
240
+ "addLabel": "*caused-by-extension",
241
+ "comment": "It looks like this is caused by the C++ extension. Please file it with the repository [here](https://github.com/microsoft/vscode-cpptools). Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
242
+ },
243
+ {
244
+ "type": "comment",
245
+ "name": "extCpp",
246
+ "allowUsers": [
247
+ "cleidigh",
248
+ "usernamehw",
249
+ "gjsjohnmurray",
250
+ "IllusionMH"
251
+ ],
252
+ "action": "close",
253
+ "addLabel": "*caused-by-extension",
254
+ "comment": "It looks like this is caused by the C++ extension. Please file it with the repository [here](https://github.com/microsoft/vscode-cpptools). Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
255
+ },
256
+ {
257
+ "type": "comment",
258
+ "name": "extTS",
259
+ "allowUsers": [
260
+ "cleidigh",
261
+ "usernamehw",
262
+ "gjsjohnmurray",
263
+ "IllusionMH"
264
+ ],
265
+ "action": "close",
266
+ "addLabel": "*caused-by-extension",
267
+ "comment": "It looks like this is caused by the TypeScript language service. Please file it with the repository [here](https://github.com/microsoft/TypeScript/). Make sure to check their [contributing guidelines](https://github.com/microsoft/TypeScript/blob/master/CONTRIBUTING.md) and provide relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
268
+ },
269
+ {
270
+ "type": "comment",
271
+ "name": "extJS",
272
+ "allowUsers": [
273
+ "cleidigh",
274
+ "usernamehw",
275
+ "gjsjohnmurray",
276
+ "IllusionMH"
277
+ ],
278
+ "action": "close",
279
+ "addLabel": "*caused-by-extension",
280
+ "comment": "It looks like this is caused by the TypeScript/JavaScript language service. Please file it with the repository [here](https://github.com/microsoft/TypeScript/). Make sure to check their [contributing guidelines](https://github.com/microsoft/TypeScript/blob/master/CONTRIBUTING.md) and provide relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
281
+ },
282
+ {
283
+ "type": "comment",
284
+ "name": "extC#",
285
+ "allowUsers": [
286
+ "cleidigh",
287
+ "usernamehw",
288
+ "gjsjohnmurray",
289
+ "IllusionMH"
290
+ ],
291
+ "action": "close",
292
+ "addLabel": "*caused-by-extension",
293
+ "comment": "It looks like this is caused by the C# extension. Please file it with the repository [here](https://github.com/OmniSharp/omnisharp-vscode.git). Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
294
+ },
295
+ {
296
+ "type": "comment",
297
+ "name": "extGo",
298
+ "allowUsers": [
299
+ "cleidigh",
300
+ "usernamehw",
301
+ "gjsjohnmurray",
302
+ "IllusionMH"
303
+ ],
304
+ "action": "close",
305
+ "addLabel": "*caused-by-extension",
306
+ "comment": "It looks like this is caused by the Go extension. Please file it with the repository [here](https://github.com/golang/vscode-go). Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
307
+ },
308
+ {
309
+ "type": "comment",
310
+ "name": "extPowershell",
311
+ "allowUsers": [
312
+ "cleidigh",
313
+ "usernamehw",
314
+ "gjsjohnmurray",
315
+ "IllusionMH"
316
+ ],
317
+ "action": "close",
318
+ "addLabel": "*caused-by-extension",
319
+ "comment": "It looks like this is caused by the PowerShell extension. Please file it with the repository [here](https://github.com/PowerShell/vscode-powershell). Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
320
+ },
321
+ {
322
+ "type": "comment",
323
+ "name": "extLiveShare",
324
+ "allowUsers": [
325
+ "cleidigh",
326
+ "usernamehw",
327
+ "gjsjohnmurray",
328
+ "IllusionMH"
329
+ ],
330
+ "action": "close",
331
+ "addLabel": "*caused-by-extension",
332
+ "comment": "It looks like this is caused by the LiveShare extension. Please file it with the repository [here](https://github.com/MicrosoftDocs/live-share). Make sure to check their [contributing guidelines](https://github.com/MicrosoftDocs/live-share/blob/master/CONTRIBUTING.md) and provide relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
333
+ },
334
+ {
335
+ "type": "comment",
336
+ "name": "extDocker",
337
+ "allowUsers": [
338
+ "cleidigh",
339
+ "usernamehw",
340
+ "gjsjohnmurray",
341
+ "IllusionMH"
342
+ ],
343
+ "action": "close",
344
+ "addLabel": "*caused-by-extension",
345
+ "comment": "It looks like this is caused by the Docker extension. Please file it with the repository [here](https://github.com/microsoft/vscode-docker). Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
346
+ },
347
+ {
348
+ "type": "comment",
349
+ "name": "extJava",
350
+ "allowUsers": [
351
+ "cleidigh",
352
+ "usernamehw",
353
+ "gjsjohnmurray",
354
+ "IllusionMH"
355
+ ],
356
+ "action": "close",
357
+ "addLabel": "*caused-by-extension",
358
+ "comment": "It looks like this is caused by the Java extension. Please file it with the repository [here](https://github.com/redhat-developer/vscode-java). Make sure to check their [troubleshooting instructions](https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting) and provide relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
359
+ },
360
+ {
361
+ "type": "comment",
362
+ "name": "extJavaDebug",
363
+ "allowUsers": [
364
+ "cleidigh",
365
+ "usernamehw",
366
+ "gjsjohnmurray",
367
+ "IllusionMH"
368
+ ],
369
+ "action": "close",
370
+ "addLabel": "*caused-by-extension",
371
+ "comment": "It looks like this is caused by the Java Debugger extension. Please file it with the repository [here](https://github.com/microsoft/vscode-java-debug). Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines for more information.\n\nHappy Coding!"
372
+ },
373
+ {
374
+ "type": "comment",
375
+ "name": "gifPlease",
376
+ "allowUsers": [
377
+ "cleidigh",
378
+ "usernamehw",
379
+ "gjsjohnmurray",
380
+ "IllusionMH"
381
+ ],
382
+ "action": "comment",
383
+ "comment": "Thanks for reporting this issue! Unfortunately, it's hard for us to understand what issue you're seeing. Please help us out by providing a screen recording showing exactly what isn't working as expected. While we can work with most standard formats, `.gif` files are preferred as they are displayed inline on GitHub. You may find https://gifcap.dev helpful as a browser-based gif recording tool.\n\nIf the issue depends on keyboard input, you can help us by enabling screencast mode for the recording (`Developer: Toggle Screencast Mode` in the command palette).\n\nHappy coding!"
384
+ },
385
+ {
386
+ "type": "comment",
387
+ "name": "label",
388
+ "allowUsers": []
389
+ },
390
+ {
391
+ "type": "comment",
392
+ "name": "assign",
393
+ "allowUsers": [
394
+ "cleidigh",
395
+ "usernamehw",
396
+ "gjsjohnmurray",
397
+ "IllusionMH"
398
+ ]
399
+ }
400
+ ]
.github/workflows/ci.yml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: actions/setup-node@v4
15
+ - run: npm ci --workspaces=false
16
+ - run: npm run validate
.github/workflows/npm-publish.yml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: 20
18
+ - run: npm ci
19
+ - run: npm test
20
+
21
+ publish-npm:
22
+ needs: build
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: actions/setup-node@v4
27
+ with:
28
+ node-version: 20
29
+ registry-url: https://registry.npmjs.org/
30
+ - run: npm ci
31
+ - run: npm publish
32
+ env:
33
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
.github/workflows/triage.yml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Triage Opened Issues
2
+ on:
3
+ issues:
4
+ types: [opened]
5
+
6
+ permissions:
7
+ issues: write
8
+
9
+ jobs:
10
+ assign_triage_label:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Assign Triage Label
14
+ if: ${{ join(github.event.issue.labels) == '' && join(github.event.issue.assignees) == '' }}
15
+ uses: actions-ecosystem/action-add-labels@v1
16
+ with:
17
+ labels: triage-needed
18
+ number: ${{ github.event.issue.number }}
19
+ github_token: ${{ secrets.GITHUB_TOKEN }}
20
+
21
+ assign_random_user:
22
+ needs: assign_triage_label
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - name: Assign Random User
26
+ run: |
27
+ echo "Waiting a few seconds before assigning..."
28
+ sleep 30
29
+ assignees=$(gh issue view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json assignees)
30
+ if echo "$assignees" | grep -q '"login"'; then
31
+ echo "The issue has assignees. "
32
+ exit 0
33
+ else
34
+ echo "The issue has no assignee(s)."
35
+ if ! gh issue view ${{ github.event.issue.number }} --repo ${{ github.event.repository.full_name }} --json labels | grep "triage-needed"; then
36
+ echo "Skipping triage assignment since triage-needed label is not present"
37
+ exit 0
38
+ fi
39
+ users=("isidorn" "jrieken" "roblourens" "aeschli" "mjbvz" "connor4312" "Tyriar" "Yoyokrazy" "andreamah" "joyceerhl" "alexr00" "bpasero" "rebornix" "chrmarti" "lramos15" "hediet" "alexdima" "rzhao271" "bhavyaus")
40
+ if [[ " ${users[@]} " =~ " ${{ github.event.issue.user.login }} " ]]; then
41
+ echo "Issue author is in the users list, skipping random assignment."
42
+ exit 0
43
+ else
44
+ random_user=${users[$RANDOM % ${#users[@]}]}
45
+ echo "Assigning issue to $random_user"
46
+ gh issue edit ${{ github.event.issue.number }} --add-assignee $random_user --repo ${{ github.repository }}
47
+ fi
48
+ fi
49
+ env:
50
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
.gitignore ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .DS_Store
2
+ npm-debug.log
3
+ Thumbs.db
4
+ **/node_modules/
5
+ */out/
6
+ */.vs/
7
+ tsconfig.lsif.json
8
+ *.lsif
9
+ *.db
10
+ *.tsbuildinfo
11
+
12
+ # Don't check in API files. These should be pulled in during install
13
+ vscode*.d.ts
.lsifrc.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "project": "tsconfig.lsif.json",
3
+ "out": "vscode-extension-samples.lsif"
4
+ }
.prettierrc.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "useTabs": true,
3
+ "singleQuote": true,
4
+ "printWidth": 92
5
+ }
.scripts/copy-into.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copies a file into every sample, overwriting the existing file if it exists.
3
+ */
4
+ import * as fs from 'fs';
5
+ import * as path from 'path';
6
+ import { lspSamples, samples } from './samples';
7
+
8
+ if (require.main === module) {
9
+ const filePath = process.argv[2];
10
+ if (!filePath) {
11
+ console.error('Please provide a file path as the argument.');
12
+ process.exit(1);
13
+ }
14
+
15
+ const fileName = path.basename(filePath);
16
+ const fileContent = fs.readFileSync(filePath);
17
+
18
+ for (const sample of [...samples, ...lspSamples]) {
19
+ const destinationPath = path.join(sample.path, fileName);
20
+ fs.writeFileSync(destinationPath, fileContent);
21
+ console.log(`Copied ${fileName} to ${sample.path}`);
22
+ }
23
+ }
.scripts/format.ts ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as fs from 'fs';
2
+ import * as glob from 'glob';
3
+ import * as ts from 'typescript';
4
+
5
+ class LanguageServiceHost implements ts.LanguageServiceHost {
6
+ files: ts.MapLike<ts.IScriptSnapshot> = {};
7
+ addFile(fileName: string, text: string) {
8
+ this.files[fileName] = ts.ScriptSnapshot.fromString(text);
9
+ }
10
+
11
+ fileExists(path: string): boolean {
12
+ return !!this.files[path];
13
+ }
14
+
15
+ readFile(path: string): string | undefined {
16
+ return this.files[path]?.getText(0, this.files[path]!.getLength());
17
+ }
18
+
19
+ // for ts.LanguageServiceHost
20
+
21
+ getCompilationSettings = () => ts.getDefaultCompilerOptions();
22
+ getScriptFileNames = () => Object.keys(this.files);
23
+ getScriptVersion = (_fileName: string) => '0';
24
+ getScriptSnapshot = (fileName: string) => this.files[fileName];
25
+ getCurrentDirectory = () => process.cwd();
26
+ getDefaultLibFileName = (options: ts.CompilerOptions) => ts.getDefaultLibFilePath(options);
27
+ }
28
+
29
+ const defaults: ts.FormatCodeSettings = {
30
+ baseIndentSize: 0,
31
+ indentSize: 4,
32
+ tabSize: 4,
33
+ indentStyle: ts.IndentStyle.Smart,
34
+ newLineCharacter: '\r\n',
35
+ convertTabsToSpaces: false,
36
+ insertSpaceAfterCommaDelimiter: true,
37
+ insertSpaceAfterSemicolonInForStatements: true,
38
+ insertSpaceBeforeAndAfterBinaryOperators: true,
39
+ insertSpaceAfterConstructor: false,
40
+ insertSpaceAfterKeywordsInControlFlowStatements: true,
41
+ insertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
42
+ insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
43
+ insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
44
+ insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,
45
+ insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
46
+ insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false,
47
+ insertSpaceAfterTypeAssertion: false,
48
+ insertSpaceBeforeFunctionParenthesis: false,
49
+ placeOpenBraceOnNewLineForFunctions: false,
50
+ placeOpenBraceOnNewLineForControlBlocks: false,
51
+ insertSpaceBeforeTypeAnnotation: false,
52
+ };
53
+
54
+ function format(fileName: string, text: string) {
55
+
56
+ const host = new LanguageServiceHost();
57
+ host.addFile(fileName, text);
58
+
59
+ const languageService = ts.createLanguageService(host);
60
+ const edits = languageService.getFormattingEditsForDocument(fileName, { ...defaults });
61
+ edits
62
+ .sort((a, b) => a.span.start - b.span.start)
63
+ .reverse()
64
+ .forEach(edit => {
65
+ const head = text.slice(0, edit.span.start);
66
+ const tail = text.slice(edit.span.start + edit.span.length);
67
+ text = `${head}${edit.newText}${tail}`;
68
+ });
69
+
70
+ return text;
71
+ }
72
+
73
+ if (require.main === module) {
74
+ glob.sync(`${__dirname}/../**/*.ts`).forEach((file) => {
75
+ if (file.endsWith('.d.ts') || file.includes('node_modules')) {
76
+ return;
77
+ }
78
+
79
+ const out = format(file, fs.readFileSync(file, 'utf8'));
80
+ fs.writeFileSync(file, out);
81
+ });
82
+ }
.scripts/run-command.ts ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-check
2
+ /**
3
+ * Try running install for all the samples
4
+ */
5
+ import * as child_process from 'child_process';
6
+ import * as fs from 'fs';
7
+ import * as path from 'path';
8
+ import { lspSamples, Sample, samples } from './samples';
9
+
10
+ async function tryRunCommand(command: string, sample: Sample) {
11
+ const packageJsonPath = path.join(sample.path, 'package.json');
12
+ if (fs.existsSync(packageJsonPath)) {
13
+ try {
14
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
15
+ if (packageJson['devDependencies'] || packageJson['dependencies']) {
16
+ console.log(`=== Running ${command} on ${path.basename(sample.path)} ===`);
17
+ child_process.execSync(command, {
18
+ cwd: sample.path,
19
+ stdio: 'inherit'
20
+ });
21
+ }
22
+ } catch (e) {
23
+ console.error(e);
24
+ }
25
+ }
26
+ }
27
+
28
+ if (require.main === module) {
29
+ const command = process.argv.slice(2).join(' ');
30
+ for (const sample of [...samples, ...lspSamples]) {
31
+ tryRunCommand(command, sample);
32
+ }
33
+ }
.scripts/run-script.ts ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Try running an npm script for each of the samples.
3
+ */
4
+ import * as child_process from 'child_process';
5
+ import * as fs from 'fs';
6
+ import * as path from 'path';
7
+ import { lspSamples, Sample, samples } from './samples';
8
+
9
+ function tryRun(scriptName: string, sample: Sample) {
10
+ const packageJsonPath = path.join(sample.path, 'package.json');
11
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
12
+ if (Object.keys(packageJson['scripts'] || {}).includes(scriptName)) {
13
+ console.log(`=== Running ${scriptName} on ${path.basename(sample.path)} ===`)
14
+ child_process.execSync(`npm run ${scriptName}`, {
15
+ cwd: sample.path,
16
+ stdio: 'inherit'
17
+ });
18
+ }
19
+ }
20
+
21
+ if (require.main === module) {
22
+ const scriptName = process.argv[2];
23
+ for (const sample of [...samples, ...lspSamples]) {
24
+ tryRun(scriptName, sample);
25
+ }
26
+ }
.scripts/samples.ts ADDED
@@ -0,0 +1,407 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export interface Sample {
2
+ readonly description: string;
3
+ readonly path: string;
4
+ readonly guide: string | null;
5
+ readonly apis: readonly string[];
6
+ readonly contributions: readonly string[];
7
+ readonly excludeFromReadme?: boolean;
8
+ }
9
+
10
+ export const samples: Sample[] = [
11
+ {
12
+ description: 'Webview Sample',
13
+ path: 'webview-sample',
14
+ guide: '/api/extension-guides/webview',
15
+ apis: ['window.createWebviewPanel', 'window.registerWebviewPanelSerializer'],
16
+ contributions: []
17
+ },
18
+ {
19
+ description: 'Webview View Sample',
20
+ path: 'webview-view-sample',
21
+ guide: null,
22
+ apis: ['window.registerWebviewViewProvider'],
23
+ contributions: []
24
+ },
25
+ {
26
+ description: 'Webview Codicons Sample',
27
+ path: 'webview-codicons-sample',
28
+ guide: null,
29
+ apis: [],
30
+ contributions: []
31
+ },
32
+ {
33
+ description: 'Status Bar Sample',
34
+ path: 'statusbar-sample',
35
+ guide: null,
36
+ apis: ['window.createStatusBarItem', 'StatusBarItem'],
37
+ contributions: []
38
+ },
39
+ {
40
+ description: 'Tree View Sample',
41
+ path: 'tree-view-sample',
42
+ guide: '/api/extension-guides/tree-view',
43
+ apis: ['window.createTreeView', 'window.registerTreeDataProvider', 'TreeView', 'TreeDataProvider'],
44
+ contributions: ['views', 'viewsContainers']
45
+ },
46
+ {
47
+ description: 'Task Provider Sample',
48
+ path: 'task-provider-sample',
49
+ guide: '/api/extension-guides/task-provider',
50
+ apis: ['tasks.registerTaskProvider', 'Task', 'ShellExecution'],
51
+ contributions: ['taskDefinitions']
52
+ },
53
+ {
54
+ description: 'Multi Root Sample',
55
+ path: 'basic-multi-root-sample',
56
+ guide: null,
57
+ apis: ['workspace.getWorkspaceFolder', 'workspace.onDidChangeWorkspaceFolders'],
58
+ contributions: []
59
+ },
60
+ {
61
+ description: 'Completion Provider Sample',
62
+ path: 'completions-sample',
63
+ guide: null,
64
+ apis: ['languages.registerCompletionItemProvider', 'CompletionItem', 'SnippetString'],
65
+ contributions: []
66
+ },
67
+ {
68
+ description: 'Code Actions Sample',
69
+ path: 'code-actions-sample',
70
+ guide: null,
71
+ apis: ['languages.registerCodeActionsProvider', 'CodeActionProvider'],
72
+ contributions: []
73
+ },
74
+ {
75
+ description: 'File System Provider Sample',
76
+ path: 'fsprovider-sample',
77
+ guide: null,
78
+ apis: ['workspace.registerFileSystemProvider'],
79
+ contributions: []
80
+ },
81
+ {
82
+ description: 'Editor Decorator Sample',
83
+ path: 'decorator-sample',
84
+ guide: null,
85
+ apis: [
86
+ 'TextEditor.setDecorations',
87
+ 'DecorationOptions',
88
+ 'DecorationInstanceRenderOptions',
89
+ 'ThemableDecorationInstanceRenderOptions',
90
+ 'window.createTextEditorDecorationType',
91
+ 'TextEditorDecorationType'
92
+ ],
93
+ contributions: ['colors']
94
+ },
95
+ {
96
+ description: 'L10n Sample',
97
+ path: 'l10n-sample',
98
+ guide: null,
99
+ apis: [],
100
+ contributions: []
101
+ },
102
+ {
103
+ description: 'Terminal Sample',
104
+ path: 'terminal-sample',
105
+ guide: null,
106
+ apis: [
107
+ 'window.createTerminal',
108
+ 'window.onDidChangeActiveTerminal',
109
+ 'window.onDidCloseTerminal',
110
+ 'window.onDidOpenTerminal',
111
+ 'window.Terminal',
112
+ 'window.terminals'
113
+ ],
114
+ contributions: []
115
+ },
116
+ {
117
+ description: 'Extension Terminal Sample',
118
+ path: 'extension-terminal-sample',
119
+ guide: null,
120
+ apis: [
121
+ 'window.createTerminal',
122
+ 'window.Pseudoterminal',
123
+ 'window.ExtensionTerminalOptions'
124
+ ],
125
+ contributions: []
126
+ },
127
+ {
128
+ description: 'Color Theme Sample',
129
+ path: 'theme-sample',
130
+ guide: '/api/extension-guides/color-theme',
131
+ apis: [],
132
+ contributions: ['themes']
133
+ },
134
+ {
135
+ description: 'Product Icon Theme Sample',
136
+ path: 'product-icon-theme-sample',
137
+ guide: '/api/extension-guides/product-icon-theme',
138
+ apis: [],
139
+ contributions: ['productIconThemes']
140
+ },
141
+ {
142
+ description: 'Vim Sample',
143
+ path: 'vim-sample',
144
+ guide: null,
145
+ apis: [
146
+ `commands`,
147
+ `StatusBarItem`,
148
+ `window.createStatusBarItem`,
149
+ `TextEditorCursorStyle`,
150
+ `window.activeTextEditor`,
151
+ `Position`,
152
+ `Range`,
153
+ `Selection`,
154
+ `TextEditor`,
155
+ `TextEditorRevealType`,
156
+ `TextDocument`
157
+ ],
158
+ contributions: []
159
+ },
160
+ {
161
+ description: 'webpack-sample',
162
+ path: 'webpack-sample',
163
+ guide: '/api/working-with-extensions/bundling-extension',
164
+ apis: [],
165
+ contributions: []
166
+ },
167
+ {
168
+ description: 'esbuild-sample',
169
+ path: 'esbuild-sample',
170
+ guide: '/api/working-with-extensions/bundling-extension',
171
+ apis: [],
172
+ contributions: []
173
+ },
174
+ {
175
+ description: 'Source Control Sample',
176
+ path: 'source-control-sample',
177
+ guide: '/api/extension-guides/scm-provider',
178
+ apis: [
179
+ 'workspace.workspaceFolders',
180
+ 'SourceControl',
181
+ 'SourceControlResourceGroup',
182
+ 'scm.createSourceControl',
183
+ 'TextDocumentContentProvider'
184
+ ],
185
+ contributions: ["menus"]
186
+ },
187
+ {
188
+ description: 'Commenting API Sample',
189
+ path: 'comment-sample',
190
+ guide: null,
191
+ apis: [],
192
+ contributions: []
193
+ },
194
+ {
195
+ description: 'Document Editing Sample',
196
+ path: 'document-editing-sample',
197
+ guide: null,
198
+ apis: [
199
+ `commands`
200
+ ],
201
+ contributions: []
202
+ },
203
+ {
204
+ description: 'Custom Data Sample',
205
+ path: 'custom-data-sample',
206
+ guide: '/api/extension-guides/custom-data-extension',
207
+ apis: [],
208
+ contributions: []
209
+ },
210
+ {
211
+ description: 'CodeLens Provider Sample',
212
+ path: 'codelens-sample',
213
+ guide: null,
214
+ apis: [`languages.registerCodeLensProvider`, `CodeLensProvider`, `CodeLens`],
215
+ contributions: []
216
+ },
217
+ {
218
+ description: 'Call Hierarchy Sample',
219
+ path: 'call-hierarchy-sample',
220
+ guide: null,
221
+ apis: [`languages.registerCallHierarchyProvider`, `CallHierarchyProvider`, `CallHierarchyItem`, `CallHierarchyOutgoingCall`, `CallHierarchyIncomingCall`],
222
+ contributions: []
223
+ },
224
+ {
225
+ description: 'Custom Editors Sample',
226
+ path: 'custom-editor-sample',
227
+ guide: '/api/extension-guides/custom-editors',
228
+ apis: ['window.registerCustomEditorProvider', 'CustomTextEditorProvider'],
229
+ contributions: ["customEditors"]
230
+ },
231
+ {
232
+ description: 'Semantic tokens',
233
+ path: 'semantic-tokens-sample',
234
+ guide: '/api/language-extensions/semantic-highlight-guide',
235
+ apis: ['languages.registerDocumentSemanticTokensProvider', 'vscode.DocumentSemanticTokensProvider'],
236
+ contributions: []
237
+ },
238
+ {
239
+ description: 'Test Provider Sample',
240
+ path: 'test-provider-sample',
241
+ guide: null,
242
+ apis: [],
243
+ contributions: []
244
+ },
245
+ {
246
+ description: 'Getting Started Sample',
247
+ path: 'getting-started-sample',
248
+ guide: null,
249
+ apis: [],
250
+ contributions: []
251
+ },
252
+ {
253
+ description: 'notebook-renderer-sample',
254
+ path: 'notebook-renderer-sample',
255
+ guide: "/api/extension-guides/notebook#notebook-renderer",
256
+ apis: [],
257
+ contributions: ["notebookRenderer"]
258
+ },
259
+ {
260
+ description: 'notebook-extend-markdown-renderer-sample',
261
+ path: 'notebook-extend-markdown-renderer-sample',
262
+ guide: "/api/extension-guides/notebook#notebook-renderer",
263
+ apis: [],
264
+ contributions: ["notebookRenderer"]
265
+ },
266
+ {
267
+ description: 'jupyter-server-provider-sample',
268
+ path: 'jupyter-server-provider-sample',
269
+ guide: null,
270
+ apis: [],
271
+ contributions: []
272
+ },
273
+ {
274
+ description: 'Chat Sample',
275
+ path: 'chat-sample',
276
+ guide: null,
277
+ apis: [],
278
+ contributions: []
279
+ },
280
+ {
281
+ description: 'Chat Tutorial',
282
+ path: 'chat-tutorial',
283
+ guide: null,
284
+ apis: [],
285
+ contributions: []
286
+ },
287
+ {
288
+ description: 'Notifications Sample',
289
+ path: 'notifications-sample',
290
+ guide: null,
291
+ apis: [],
292
+ contributions: []
293
+ },
294
+ { description: 'authenticationprovider-sample', excludeFromReadme: true, path: 'authenticationprovider-sample', guide: null, apis: [], contributions: [] },
295
+ { description: 'configuration-sample', excludeFromReadme: true, path: 'configuration-sample', guide: null, apis: [], contributions: [] },
296
+ { description: 'chat-model-provider-sample', excludeFromReadme: true, path: 'chat-model-provider-sample', guide: null, apis: [], contributions: [] },
297
+ { description: 'chat-output-renderer-sample', excludeFromReadme: true, path: 'chat-output-renderer-sample', guide: null, apis: [], contributions: [] },
298
+ { description: 'contentprovider-sample', excludeFromReadme: true, path: 'contentprovider-sample', guide: null, apis: [], contributions: [] },
299
+ { description: 'diagnostic-related-information-sample', excludeFromReadme: true, path: 'diagnostic-related-information-sample', guide: null, apis: [], contributions: [] },
300
+ { description: 'document-paste', excludeFromReadme: true, path: 'document-paste', guide: null, apis: [], contributions: [] },
301
+ { description: 'drop-on-document', excludeFromReadme: true, path: 'drop-on-document', guide: null, apis: [], contributions: [] },
302
+ { description: 'fsconsumer-sample', excludeFromReadme: true, path: 'fsconsumer-sample', guide: null, apis: [], contributions: [] },
303
+ { description: 'github-authentication-sample', excludeFromReadme: true, path: 'github-authentication-sample', guide: null, apis: [], contributions: [] },
304
+ { description: 'helloworld-minimal-sample', excludeFromReadme: true, path: 'helloworld-minimal-sample', guide: null, apis: [], contributions: [] },
305
+ { description: 'helloworld-sample', excludeFromReadme: true, path: 'helloworld-sample', guide: null, apis: [], contributions: [] },
306
+ { description: 'helloworld-test-cli-sample', excludeFromReadme: true, path: 'helloworld-test-cli-sample', guide: null, apis: [], contributions: [] },
307
+ { description: 'helloworld-test-sample', excludeFromReadme: true, path: 'helloworld-test-sample', guide: null, apis: [], contributions: [] },
308
+ { description: 'helloworld-web-sample', excludeFromReadme: true, path: 'helloworld-web-sample', guide: null, apis: [], contributions: [] },
309
+ { description: 'inline-completions', excludeFromReadme: true, path: 'inline-completions', guide: null, apis: [], contributions: [] },
310
+ { description: 'jupyter-kernel-execution-sample', excludeFromReadme: true, path: 'jupyter-kernel-execution-sample', guide: null, apis: [], contributions: [] },
311
+ { description: 'lm-api-tutorial', excludeFromReadme: true, path: 'lm-api-tutorial', guide: null, apis: [], contributions: [] },
312
+ { description: 'mcp-extension-sample', excludeFromReadme: true, path: 'mcp-extension-sample', guide: null, apis: [], contributions: [] },
313
+ { description: 'nodefs-provider-sample', excludeFromReadme: true, path: 'nodefs-provider-sample', guide: null, apis: [], contributions: [] },
314
+ { description: 'notebook-format-code-action-sample', excludeFromReadme: true, path: 'notebook-format-code-action-sample', guide: null, apis: [], contributions: [] },
315
+ { description: 'notebook-renderer-react-sample', excludeFromReadme: true, path: 'notebook-renderer-react-sample', guide: null, apis: [], contributions: [] },
316
+ { description: 'notebook-serializer-sample', excludeFromReadme: true, path: 'notebook-serializer-sample', guide: null, apis: [], contributions: [] },
317
+ { description: 'progress-sample', excludeFromReadme: true, path: 'progress-sample', guide: null, apis: [], contributions: [] },
318
+ { description: 'proposed-api-sample', excludeFromReadme: true, path: 'proposed-api-sample', guide: null, apis: [], contributions: [] },
319
+ { description: 'quickinput-sample', excludeFromReadme: true, path: 'quickinput-sample', guide: null, apis: [], contributions: [] },
320
+ { description: 'shell-integration-sample', excludeFromReadme: true, path: 'shell-integration-sample', guide: null, apis: [], contributions: [] },
321
+ { description: 'tabs-api-sample', excludeFromReadme: true, path: 'tabs-api-sample', guide: null, apis: [], contributions: [] },
322
+ { description: 'telemetry-sample', excludeFromReadme: true, path: 'telemetry-sample', guide: null, apis: [], contributions: [] },
323
+ { description: 'uri-handler-sample', excludeFromReadme: true, path: 'uri-handler-sample', guide: null, apis: [], contributions: [] },
324
+ { description: 'virtual-document-sample', excludeFromReadme: true, path: 'virtual-document-sample', guide: null, apis: [], contributions: [] },
325
+ { description: 'wasm-component-model-async', excludeFromReadme: true, path: 'wasm-component-model-async', guide: null, apis: [], contributions: [] },
326
+ { description: 'wasm-component-model-resource', excludeFromReadme: true, path: 'wasm-component-model-resource', guide: null, apis: [], contributions: [] },
327
+ { description: 'wasm-component-model', excludeFromReadme: true, path: 'wasm-component-model', guide: null, apis: [], contributions: [] },
328
+ { description: 'welcome-view-content-sample', excludeFromReadme: true, path: 'welcome-view-content-sample', guide: null, apis: [], contributions: [] },
329
+ ]
330
+
331
+ /**
332
+ * LSP specific samples
333
+ * DO NOT add non-LSP items here. Add it to {@link samples} list.
334
+ */
335
+ export const lspSamples: Sample[] = [
336
+ {
337
+ description: 'Snippet Sample',
338
+ path: 'snippet-sample',
339
+ guide: '/api/language-extensions/snippet-guide',
340
+ apis: [],
341
+ contributions: ['snippets']
342
+ },
343
+ {
344
+ description: 'Language Configuration Sample',
345
+ path: 'language-configuration-sample',
346
+ guide: '/api/language-extensions/language-configuration-guide',
347
+ apis: [],
348
+ contributions: ['languages']
349
+ },
350
+ {
351
+ description: 'LSP Sample',
352
+ path: 'lsp-sample',
353
+ guide: '/api/language-extensions/language-server-extension-guide',
354
+ apis: [],
355
+ contributions: []
356
+ },
357
+ {
358
+ description: 'LSP Log Streaming Sample',
359
+ path: 'lsp-log-streaming-sample',
360
+ guide: null,
361
+ apis: [],
362
+ contributions: []
363
+ },
364
+ {
365
+ description: 'LSP Multi Root Server Sample',
366
+ path: 'lsp-multi-server-sample',
367
+ guide:
368
+ 'https://github.com/Microsoft/vscode/wiki/Extension-Authoring:-Adopting-Multi-Root-Workspace-APIs#language-client--language-server',
369
+ apis: [],
370
+ contributions: []
371
+ },
372
+ {
373
+ description: 'LSP Web Extension Sample',
374
+ path: 'lsp-web-extension-sample',
375
+ guide: '/api/language-extensions/language-server-extension-guide',
376
+ apis: [],
377
+ contributions: []
378
+ },
379
+ {
380
+ description: 'LSP User Input Sample',
381
+ path: 'lsp-user-input-sample',
382
+ guide: null,
383
+ apis: [],
384
+ contributions: []
385
+ },
386
+ {
387
+ description: 'LSP Embedded Language Service',
388
+ path: 'lsp-embedded-language-service',
389
+ guide: null,
390
+ apis: [],
391
+ contributions: []
392
+ },
393
+ {
394
+ description: 'LSP Embedded Request Forwarding',
395
+ path: 'lsp-embedded-request-forwarding',
396
+ guide: null,
397
+ apis: [],
398
+ contributions: []
399
+ },
400
+ {
401
+ description: 'Wasm language server',
402
+ path: 'wasm-language-server',
403
+ guide: null,
404
+ apis: [],
405
+ contributions: []
406
+ },
407
+ ];
.scripts/tsconfig.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ESNext",
4
+ "moduleResolution": "Node",
5
+ "target": "ES2024",
6
+ "lib": [
7
+ "ES2024"
8
+ ],
9
+ "noEmit": true,
10
+ "strict": true
11
+ },
12
+ "ts-node": {
13
+ "esm": true
14
+ }
15
+ }
.scripts/update-dependency.ts ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Update a dependency to a version in all relevant samples
3
+ */
4
+ import * as child_process from 'child_process';
5
+ import * as fs from 'fs';
6
+ import * as path from 'path';
7
+ import { Sample, samples } from './samples';
8
+
9
+ function setVersion(
10
+ dependencyName: string,
11
+ version: string,
12
+ sample: Sample
13
+ ) {
14
+ const packageJsonPath = path.join(sample.path, 'package.json');
15
+ const packageJsonContents = fs.readFileSync(packageJsonPath).toString();
16
+ const packageJson = JSON.parse(packageJsonContents);
17
+
18
+ let changed = false;
19
+ if (packageJson.dependencies?.[dependencyName]) {
20
+ packageJson.dependencies[dependencyName] = version;
21
+ changed = true;
22
+ }
23
+ if (packageJson.devDependencies?.[dependencyName]) {
24
+ packageJson.devDependencies[dependencyName] = version;
25
+ changed = true;
26
+ }
27
+
28
+ if (!changed) {
29
+ return;
30
+ }
31
+
32
+ console.log(`Updated ${dependencyName} in ${packageJson.name}`);
33
+ const space = packageJsonContents.includes('\t') ? '\t' : ' ';
34
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, undefined, space) + '\n');
35
+
36
+ if (fs.existsSync(path.join(sample.path, 'package-lock.json'))) {
37
+ console.log(` npm install in ${packageJson.name}`);
38
+ child_process.execSync(`npm install`, {
39
+ cwd: sample.path,
40
+ stdio: 'inherit'
41
+ });
42
+ }
43
+ }
44
+
45
+ const [, , dependency, version] = process.argv;
46
+ if (!dependency || !version) {
47
+ console.log(`Usage: ${process.argv[0]} ${process.argv[1]} <depndency> <version>`);
48
+ }
49
+ for (const sample of samples) {
50
+ setVersion(dependency, version, sample);
51
+ }
.scripts/update-lsif.ts ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as fs from 'fs/promises';
2
+ import * as path from 'path';
3
+ import { samples } from './samples';
4
+
5
+ const root = path.join(__dirname, '..');
6
+
7
+ async function main() {
8
+ const references = [];
9
+ for (const sample of samples) {
10
+ try {
11
+ const stat = await fs.stat(path.join(root, sample.path, 'tsconfig.json'));
12
+ if (stat.isFile()) {
13
+ references.push(`./${sample.path}/tsconfig.json`);
14
+ }
15
+ } catch (error) {
16
+ // Ignore error of stat call.
17
+ }
18
+ }
19
+ const tsconfig = {
20
+ compilerOptions: {
21
+ },
22
+ files: [
23
+ ],
24
+ references: references.map(reference => { return { path: reference } })
25
+ }
26
+ await fs.writeFile(path.join(root, 'tsconfig.lsif.json'), JSON.stringify(tsconfig, undefined, '\t'), { encoding: 'utf8' });
27
+ }
28
+
29
+ if (require.main === module) {
30
+ main().catch(console.error);
31
+ }
.scripts/update-readme.ts ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as fs from 'fs';
2
+ import { lspSamples, Sample, samples } from './samples';
3
+
4
+ const TABLE_HEAD = `<!-- SAMPLES_BEGIN -->
5
+ | Sample | Guide on VS Code Website | API & Contribution |
6
+ | ------ | ----- | --- |`
7
+ const TABLE_END = `<!-- SAMPLES_END -->`
8
+ const LSP_TABLE_HEAD = `<!-- LSP_SAMPLES_BEGIN -->
9
+ | Sample | Guide on VS Code Website | API & Contribution |
10
+ | ------ | ----- | --- |`
11
+ const LSP_TABLE_END = `<!-- LSP_SAMPLES_END -->`
12
+
13
+ const getTableRow = (sample: Sample) => {
14
+ const descriptionCell = `[${sample.description}](https://github.com/Microsoft/vscode-extension-samples/tree/main/${sample.path})`
15
+ let guideCell
16
+ if (!sample.guide) {
17
+ guideCell = 'N/A'
18
+ } else if (sample.guide && sample.guide.startsWith('http')) {
19
+ guideCell = sample.guide
20
+ } else {
21
+ guideCell = `[${sample.guide}](https://code.visualstudio.com${sample.guide})`
22
+ }
23
+
24
+ const apis = sample.apis.map(api => {
25
+ return `[${api}](https://code.visualstudio.com/api/references/vscode-api#${api})`
26
+ })
27
+ const contributions = sample.contributions.map(c => {
28
+ return `[contributes.${c}](https://code.visualstudio.com/api/references/contribution-points#contributes.${c})`
29
+ })
30
+ const apiAndContributionCell = apis.concat(contributions).join('<br>')
31
+
32
+ return `| ${descriptionCell} | ${guideCell} | ${apiAndContributionCell} |`
33
+ }
34
+
35
+ const getSamplesTable = (samples: readonly Sample[]) => {
36
+ const samplesMd = samples.map(s => getTableRow(s)).join('\n')
37
+
38
+ return `${TABLE_HEAD.trim()}
39
+ ${samplesMd}
40
+ ${TABLE_END.trim()}`
41
+ }
42
+
43
+ const getLSPSamplesTable = (samples: readonly Sample[]) => {
44
+ const samplesMd = samples.map(s => getTableRow(s)).join('\n')
45
+
46
+ return `${LSP_TABLE_HEAD.trim()}
47
+ ${samplesMd}
48
+ ${LSP_TABLE_END.trim()}`
49
+ }
50
+
51
+ /**
52
+ * Update the README with the latest samples.
53
+ *
54
+ * @returns true if the README was updated, false otherwise.
55
+ */
56
+ export function updateReadme(dryRun = false): boolean {
57
+ const readme = fs.readFileSync('README.md', 'utf-8')
58
+ const newReadme = readme
59
+ .replace(/<!-- SAMPLES_BEGIN -->(.|\n)*<!-- SAMPLES_END -->/gm, getSamplesTable(samples.filter(x => !x.excludeFromReadme)))
60
+ .replace(/<!-- LSP_SAMPLES_BEGIN -->(.|\n)*<!-- LSP_SAMPLES_END -->/gm, getLSPSamplesTable(lspSamples))
61
+
62
+ if (readme !== newReadme) {
63
+ if (!dryRun) {
64
+ fs.writeFileSync('README.md', newReadme)
65
+ }
66
+ return true;
67
+ } else {
68
+ return false;
69
+ }
70
+ }
71
+
72
+ if (require.main === module) {
73
+ updateReadme();
74
+ }
.scripts/validate.ts ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { lspSamples, samples } from './samples';
4
+
5
+ const root = path.join(__dirname, '..');
6
+ console.log(root);
7
+
8
+ /**
9
+ * Validates that all samples are correctly listed in `.scripts/samples.js`.
10
+ */
11
+ function validateSamplesAreListed() {
12
+ const allSamples = samples.concat(lspSamples);
13
+
14
+ const samplesByPath = new Map();
15
+ for (const sample of allSamples) {
16
+ samplesByPath.set(sample.path, sample);
17
+ }
18
+
19
+
20
+ const errors: Error[] = [];
21
+
22
+ for (const fileName of fs.readdirSync(root)) {
23
+ if (fileName === 'node_modules'
24
+ || fileName.startsWith('.')
25
+ || !fs.lstatSync(path.join(root, fileName)).isDirectory()
26
+ ) {
27
+ continue;
28
+ }
29
+
30
+ const sampleEntry = samplesByPath.get(fileName);
31
+ if (!sampleEntry) {
32
+ errors.push(new Error(`Sample '${fileName}' is not listed in samples.js`));
33
+ }
34
+ }
35
+
36
+ if (errors.length > 0) {
37
+ if (errors.length === 1) {
38
+ throw errors[0];
39
+ } else {
40
+ throw new AggregateError(errors, 'Multiple samples are not listed in samples.js');
41
+ }
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Validates that all samples are correctly listed in `.scripts/samples.js`.
47
+ */
48
+ function validateReadmeUpdated() {
49
+ const { updateReadme } = require('./update-readme');
50
+ if (updateReadme(true)) {
51
+ throw new Error(`Readme not updated. Run 'node .scripts/update-readme.js' to update the readme.`);
52
+ }
53
+ }
54
+
55
+ validateSamplesAreListed();
56
+ validateReadmeUpdated();
.vscode/settings.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "editor.insertSpaces": false,
3
+ "prettier.semi": true,
4
+ "prettier.printWidth": 92,
5
+ "prettier.singleQuote": true,
6
+ "prettier.useTabs": true,
7
+ "git.branchProtection": [
8
+ "main"
9
+ ],
10
+ "git.branchProtectionPrompt": "alwaysCommitToNewBranch",
11
+ "git.branchRandomName.enable": true,
12
+ "githubPullRequests.assignCreated": "${user}",
13
+ "githubPullRequests.defaultMergeMethod": "squash"
14
+ }
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2015 - present Microsoft Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h1 align="center">
2
+ VS Code Extension Samples
3
+ </h1>
4
+
5
+ This repository contains sample code illustrating the VS Code extension API. Each sample is a self-contained extension that explains one topic in [VS Code API](https://code.visualstudio.com/api/references/vscode-api) or VS Code's [Contribution Points](https://code.visualstudio.com/api/references/contribution-points). You can read, play with or adapt from these samples to create your own extensions.
6
+
7
+ You can expect from each sample:
8
+ - An explanation of its functionality
9
+ - A gif or screenshot demonstrating its usage
10
+ - Link to a guide on VS Code website, if it has one
11
+ - Listing of used VS Code API and Contribution Points
12
+ - Code of the same style, enforced using ESLint
13
+
14
+ ## Prerequisites
15
+
16
+ You need to have [node](https://nodejs.org/en/) and [npm](https://nodejs.org/en/) installed on your system to run the examples. It is recommended to use the node version used for VS Code development itself which is documented [here](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#prerequisites)
17
+
18
+ ## Usage
19
+
20
+ - `git clone https://github.com/Microsoft/vscode-extension-samples`
21
+ - `code <any-sample-folder>`
22
+ - `npm install` in the terminal, then `F5` to run the sample
23
+ - Alternatively, follow the instructions in each sample's README for setting up and running the sample
24
+
25
+ ## Getting Started
26
+
27
+ - [Hello World Sample](helloworld-sample): The Hello World sample for VS Code. See [Extension Anatomy](https://code.visualstudio.com/api/get-started/extension-anatomy) documentation.
28
+ - [Hello World Minimal Sample](helloworld-minimal-sample): A minimal version of Hello World Sample written in JavaScript.
29
+ - [Hello World Test Sample](helloworld-test-sample): Hello World sample with extension integration test. See [Testing Extensions](https://code.visualstudio.com/api/working-with-extensions/testing-extension) documentation.
30
+ - [Hello World Web Sample](helloworld-web-sample): The Hello World sample for VS Code Web. See the [Web Extensions](https://code.visualstudio.com/api/extension-guides/web-extensions) guide.
31
+
32
+ ## Samples
33
+
34
+ <!-- SAMPLES_BEGIN -->
35
+ | Sample | Guide on VS Code Website | API & Contribution |
36
+ | ------ | ----- | --- |
37
+ | [Webview Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/webview-sample) | [/api/extension-guides/webview](https://code.visualstudio.com/api/extension-guides/webview) | [window.createWebviewPanel](https://code.visualstudio.com/api/references/vscode-api#window.createWebviewPanel)<br>[window.registerWebviewPanelSerializer](https://code.visualstudio.com/api/references/vscode-api#window.registerWebviewPanelSerializer) |
38
+ | [Webview View Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/webview-view-sample) | N/A | [window.registerWebviewViewProvider](https://code.visualstudio.com/api/references/vscode-api#window.registerWebviewViewProvider) |
39
+ | [Webview Codicons Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/webview-codicons-sample) | N/A | |
40
+ | [Status Bar Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/statusbar-sample) | N/A | [window.createStatusBarItem](https://code.visualstudio.com/api/references/vscode-api#window.createStatusBarItem)<br>[StatusBarItem](https://code.visualstudio.com/api/references/vscode-api#StatusBarItem) |
41
+ | [Tree View Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/tree-view-sample) | [/api/extension-guides/tree-view](https://code.visualstudio.com/api/extension-guides/tree-view) | [window.createTreeView](https://code.visualstudio.com/api/references/vscode-api#window.createTreeView)<br>[window.registerTreeDataProvider](https://code.visualstudio.com/api/references/vscode-api#window.registerTreeDataProvider)<br>[TreeView](https://code.visualstudio.com/api/references/vscode-api#TreeView)<br>[TreeDataProvider](https://code.visualstudio.com/api/references/vscode-api#TreeDataProvider)<br>[contributes.views](https://code.visualstudio.com/api/references/contribution-points#contributes.views)<br>[contributes.viewsContainers](https://code.visualstudio.com/api/references/contribution-points#contributes.viewsContainers) |
42
+ | [Task Provider Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/task-provider-sample) | [/api/extension-guides/task-provider](https://code.visualstudio.com/api/extension-guides/task-provider) | [tasks.registerTaskProvider](https://code.visualstudio.com/api/references/vscode-api#tasks.registerTaskProvider)<br>[Task](https://code.visualstudio.com/api/references/vscode-api#Task)<br>[ShellExecution](https://code.visualstudio.com/api/references/vscode-api#ShellExecution)<br>[contributes.taskDefinitions](https://code.visualstudio.com/api/references/contribution-points#contributes.taskDefinitions) |
43
+ | [Multi Root Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/basic-multi-root-sample) | N/A | [workspace.getWorkspaceFolder](https://code.visualstudio.com/api/references/vscode-api#workspace.getWorkspaceFolder)<br>[workspace.onDidChangeWorkspaceFolders](https://code.visualstudio.com/api/references/vscode-api#workspace.onDidChangeWorkspaceFolders) |
44
+ | [Completion Provider Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/completions-sample) | N/A | [languages.registerCompletionItemProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerCompletionItemProvider)<br>[CompletionItem](https://code.visualstudio.com/api/references/vscode-api#CompletionItem)<br>[SnippetString](https://code.visualstudio.com/api/references/vscode-api#SnippetString) |
45
+ | [Code Actions Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/code-actions-sample) | N/A | [languages.registerCodeActionsProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerCodeActionsProvider)<br>[CodeActionProvider](https://code.visualstudio.com/api/references/vscode-api#CodeActionProvider) |
46
+ | [File System Provider Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/fsprovider-sample) | N/A | [workspace.registerFileSystemProvider](https://code.visualstudio.com/api/references/vscode-api#workspace.registerFileSystemProvider) |
47
+ | [Editor Decorator Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/decorator-sample) | N/A | [TextEditor.setDecorations](https://code.visualstudio.com/api/references/vscode-api#TextEditor.setDecorations)<br>[DecorationOptions](https://code.visualstudio.com/api/references/vscode-api#DecorationOptions)<br>[DecorationInstanceRenderOptions](https://code.visualstudio.com/api/references/vscode-api#DecorationInstanceRenderOptions)<br>[ThemableDecorationInstanceRenderOptions](https://code.visualstudio.com/api/references/vscode-api#ThemableDecorationInstanceRenderOptions)<br>[window.createTextEditorDecorationType](https://code.visualstudio.com/api/references/vscode-api#window.createTextEditorDecorationType)<br>[TextEditorDecorationType](https://code.visualstudio.com/api/references/vscode-api#TextEditorDecorationType)<br>[contributes.colors](https://code.visualstudio.com/api/references/contribution-points#contributes.colors) |
48
+ | [L10n Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/l10n-sample) | N/A | |
49
+ | [Terminal Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/terminal-sample) | N/A | [window.createTerminal](https://code.visualstudio.com/api/references/vscode-api#window.createTerminal)<br>[window.onDidChangeActiveTerminal](https://code.visualstudio.com/api/references/vscode-api#window.onDidChangeActiveTerminal)<br>[window.onDidCloseTerminal](https://code.visualstudio.com/api/references/vscode-api#window.onDidCloseTerminal)<br>[window.onDidOpenTerminal](https://code.visualstudio.com/api/references/vscode-api#window.onDidOpenTerminal)<br>[window.Terminal](https://code.visualstudio.com/api/references/vscode-api#window.Terminal)<br>[window.terminals](https://code.visualstudio.com/api/references/vscode-api#window.terminals) |
50
+ | [Extension Terminal Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/extension-terminal-sample) | N/A | [window.createTerminal](https://code.visualstudio.com/api/references/vscode-api#window.createTerminal)<br>[window.Pseudoterminal](https://code.visualstudio.com/api/references/vscode-api#window.Pseudoterminal)<br>[window.ExtensionTerminalOptions](https://code.visualstudio.com/api/references/vscode-api#window.ExtensionTerminalOptions) |
51
+ | [Color Theme Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/theme-sample) | [/api/extension-guides/color-theme](https://code.visualstudio.com/api/extension-guides/color-theme) | [contributes.themes](https://code.visualstudio.com/api/references/contribution-points#contributes.themes) |
52
+ | [Product Icon Theme Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/product-icon-theme-sample) | [/api/extension-guides/product-icon-theme](https://code.visualstudio.com/api/extension-guides/product-icon-theme) | [contributes.productIconThemes](https://code.visualstudio.com/api/references/contribution-points#contributes.productIconThemes) |
53
+ | [Vim Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/vim-sample) | N/A | [commands](https://code.visualstudio.com/api/references/vscode-api#commands)<br>[StatusBarItem](https://code.visualstudio.com/api/references/vscode-api#StatusBarItem)<br>[window.createStatusBarItem](https://code.visualstudio.com/api/references/vscode-api#window.createStatusBarItem)<br>[TextEditorCursorStyle](https://code.visualstudio.com/api/references/vscode-api#TextEditorCursorStyle)<br>[window.activeTextEditor](https://code.visualstudio.com/api/references/vscode-api#window.activeTextEditor)<br>[Position](https://code.visualstudio.com/api/references/vscode-api#Position)<br>[Range](https://code.visualstudio.com/api/references/vscode-api#Range)<br>[Selection](https://code.visualstudio.com/api/references/vscode-api#Selection)<br>[TextEditor](https://code.visualstudio.com/api/references/vscode-api#TextEditor)<br>[TextEditorRevealType](https://code.visualstudio.com/api/references/vscode-api#TextEditorRevealType)<br>[TextDocument](https://code.visualstudio.com/api/references/vscode-api#TextDocument) |
54
+ | [webpack-sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/webpack-sample) | [/api/working-with-extensions/bundling-extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension) | |
55
+ | [esbuild-sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/esbuild-sample) | [/api/working-with-extensions/bundling-extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension) | |
56
+ | [Source Control Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/source-control-sample) | [/api/extension-guides/scm-provider](https://code.visualstudio.com/api/extension-guides/scm-provider) | [workspace.workspaceFolders](https://code.visualstudio.com/api/references/vscode-api#workspace.workspaceFolders)<br>[SourceControl](https://code.visualstudio.com/api/references/vscode-api#SourceControl)<br>[SourceControlResourceGroup](https://code.visualstudio.com/api/references/vscode-api#SourceControlResourceGroup)<br>[scm.createSourceControl](https://code.visualstudio.com/api/references/vscode-api#scm.createSourceControl)<br>[TextDocumentContentProvider](https://code.visualstudio.com/api/references/vscode-api#TextDocumentContentProvider)<br>[contributes.menus](https://code.visualstudio.com/api/references/contribution-points#contributes.menus) |
57
+ | [Commenting API Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/comment-sample) | N/A | |
58
+ | [Document Editing Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/document-editing-sample) | N/A | [commands](https://code.visualstudio.com/api/references/vscode-api#commands) |
59
+ | [Custom Data Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/custom-data-sample) | [/api/extension-guides/custom-data-extension](https://code.visualstudio.com/api/extension-guides/custom-data-extension) | |
60
+ | [CodeLens Provider Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/codelens-sample) | N/A | [languages.registerCodeLensProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerCodeLensProvider)<br>[CodeLensProvider](https://code.visualstudio.com/api/references/vscode-api#CodeLensProvider)<br>[CodeLens](https://code.visualstudio.com/api/references/vscode-api#CodeLens) |
61
+ | [Call Hierarchy Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/call-hierarchy-sample) | N/A | [languages.registerCallHierarchyProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerCallHierarchyProvider)<br>[CallHierarchyProvider](https://code.visualstudio.com/api/references/vscode-api#CallHierarchyProvider)<br>[CallHierarchyItem](https://code.visualstudio.com/api/references/vscode-api#CallHierarchyItem)<br>[CallHierarchyOutgoingCall](https://code.visualstudio.com/api/references/vscode-api#CallHierarchyOutgoingCall)<br>[CallHierarchyIncomingCall](https://code.visualstudio.com/api/references/vscode-api#CallHierarchyIncomingCall) |
62
+ | [Custom Editors Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/custom-editor-sample) | [/api/extension-guides/custom-editors](https://code.visualstudio.com/api/extension-guides/custom-editors) | [window.registerCustomEditorProvider](https://code.visualstudio.com/api/references/vscode-api#window.registerCustomEditorProvider)<br>[CustomTextEditorProvider](https://code.visualstudio.com/api/references/vscode-api#CustomTextEditorProvider)<br>[contributes.customEditors](https://code.visualstudio.com/api/references/contribution-points#contributes.customEditors) |
63
+ | [Semantic tokens](https://github.com/Microsoft/vscode-extension-samples/tree/main/semantic-tokens-sample) | [/api/language-extensions/semantic-highlight-guide](https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide) | [languages.registerDocumentSemanticTokensProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerDocumentSemanticTokensProvider)<br>[vscode.DocumentSemanticTokensProvider](https://code.visualstudio.com/api/references/vscode-api#vscode.DocumentSemanticTokensProvider) |
64
+ | [Test Provider Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/test-provider-sample) | N/A | |
65
+ | [Getting Started Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/getting-started-sample) | N/A | |
66
+ | [notebook-renderer-sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/notebook-renderer-sample) | [/api/extension-guides/notebook#notebook-renderer](https://code.visualstudio.com/api/extension-guides/notebook#notebook-renderer) | [contributes.notebookRenderer](https://code.visualstudio.com/api/references/contribution-points#contributes.notebookRenderer) |
67
+ | [notebook-extend-markdown-renderer-sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/notebook-extend-markdown-renderer-sample) | [/api/extension-guides/notebook#notebook-renderer](https://code.visualstudio.com/api/extension-guides/notebook#notebook-renderer) | [contributes.notebookRenderer](https://code.visualstudio.com/api/references/contribution-points#contributes.notebookRenderer) |
68
+ | [jupyter-server-provider-sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/jupyter-server-provider-sample) | N/A | |
69
+ | [Chat Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/chat-sample) | N/A | |
70
+ | [Chat Tutorial](https://github.com/Microsoft/vscode-extension-samples/tree/main/chat-tutorial) | N/A | |
71
+ | [Notifications Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/notifications-sample) | N/A | |
72
+ <!-- SAMPLES_END -->
73
+
74
+ ### Language Server Protocol Samples
75
+
76
+ <!-- LSP_SAMPLES_BEGIN -->
77
+ | Sample | Guide on VS Code Website | API & Contribution |
78
+ | ------ | ----- | --- |
79
+ | [Snippet Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/snippet-sample) | [/api/language-extensions/snippet-guide](https://code.visualstudio.com/api/language-extensions/snippet-guide) | [contributes.snippets](https://code.visualstudio.com/api/references/contribution-points#contributes.snippets) |
80
+ | [Language Configuration Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/language-configuration-sample) | [/api/language-extensions/language-configuration-guide](https://code.visualstudio.com/api/language-extensions/language-configuration-guide) | [contributes.languages](https://code.visualstudio.com/api/references/contribution-points#contributes.languages) |
81
+ | [LSP Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-sample) | [/api/language-extensions/language-server-extension-guide](https://code.visualstudio.com/api/language-extensions/language-server-extension-guide) | |
82
+ | [LSP Log Streaming Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-log-streaming-sample) | N/A | |
83
+ | [LSP Multi Root Server Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-multi-server-sample) | https://github.com/Microsoft/vscode/wiki/Extension-Authoring:-Adopting-Multi-Root-Workspace-APIs#language-client--language-server | |
84
+ | [LSP Web Extension Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-web-extension-sample) | [/api/language-extensions/language-server-extension-guide](https://code.visualstudio.com/api/language-extensions/language-server-extension-guide) | |
85
+ | [LSP User Input Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-user-input-sample) | N/A | |
86
+ | [LSP Embedded Language Service](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-embedded-language-service) | N/A | |
87
+ | [LSP Embedded Request Forwarding](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-embedded-request-forwarding) | N/A | |
88
+ | [Wasm language server](https://github.com/Microsoft/vscode-extension-samples/tree/main/wasm-language-server) | N/A | |
89
+ <!-- LSP_SAMPLES_END -->
90
+
91
+ ## License
92
+
93
+ Copyright (c) Microsoft Corporation. All rights reserved.
94
+
95
+ Licensed under the [MIT](https://github.com/microsoft/vscode-extension-samples/blob/main/LICENSE) License.
SECURITY.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
2
+
3
+ ## Security
4
+
5
+ Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6
+
7
+ If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
8
+
9
+ ## Reporting Security Issues
10
+
11
+ **Please do not report security vulnerabilities through public GitHub issues.**
12
+
13
+ Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
14
+
15
+ If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
16
+
17
+ You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
18
+
19
+ Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20
+
21
+ * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22
+ * Full paths of source file(s) related to the manifestation of the issue
23
+ * The location of the affected source code (tag/branch/commit or direct URL)
24
+ * Any special configuration required to reproduce the issue
25
+ * Step-by-step instructions to reproduce the issue
26
+ * Proof-of-concept or exploit code (if possible)
27
+ * Impact of the issue, including how an attacker might exploit the issue
28
+
29
+ This information will help us triage your report more quickly.
30
+
31
+ If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
32
+
33
+ ## Preferred Languages
34
+
35
+ We prefer all communications to be in English.
36
+
37
+ ## Policy
38
+
39
+ Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
40
+
41
+ <!-- END MICROSOFT SECURITY.MD BLOCK -->
authenticationprovider-sample/.vscode/extensions.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ // See http://go.microsoft.com/fwlink/?LinkId=827846
3
+ // for the documentation about the extensions.json format
4
+ "recommendations": [
5
+ "dbaeumer.vscode-eslint"
6
+ ]
7
+ }
authenticationprovider-sample/.vscode/launch.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // A launch configuration that compiles the extension and then opens it inside a new window
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ {
6
+ "version": "0.2.0",
7
+ "configurations": [
8
+ {
9
+ "name": "Run Extension",
10
+ "type": "extensionHost",
11
+ "request": "launch",
12
+ "args": [
13
+ "--extensionDevelopmentPath=${workspaceFolder}"
14
+ ],
15
+ "outFiles": [
16
+ "${workspaceFolder}/out/**/*.js"
17
+ ],
18
+ "preLaunchTask": "${defaultBuildTask}"
19
+ },
20
+ {
21
+ "name": "Extension Tests",
22
+ "type": "extensionHost",
23
+ "request": "launch",
24
+ "args": [
25
+ "--extensionDevelopmentPath=${workspaceFolder}",
26
+ "--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
27
+ ],
28
+ "outFiles": [
29
+ "${workspaceFolder}/out/test/**/*.js"
30
+ ],
31
+ "preLaunchTask": "${defaultBuildTask}"
32
+ }
33
+ ]
34
+ }
authenticationprovider-sample/.vscode/settings.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Place your settings in this file to overwrite default and user settings.
2
+ {
3
+ "files.exclude": {
4
+ "out": false // set this to true to hide the "out" folder with the compiled JS files
5
+ },
6
+ "search.exclude": {
7
+ "out": true // set this to false to include "out" folder in search results
8
+ },
9
+ // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10
+ "typescript.tsc.autoDetect": "off"
11
+ }
authenticationprovider-sample/.vscode/tasks.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
2
+ // for the documentation about the tasks.json format
3
+ {
4
+ "version": "2.0.0",
5
+ "tasks": [
6
+ {
7
+ "type": "npm",
8
+ "script": "watch",
9
+ "problemMatcher": "$tsc-watch",
10
+ "isBackground": true,
11
+ "presentation": {
12
+ "reveal": "never"
13
+ },
14
+ "group": {
15
+ "kind": "build",
16
+ "isDefault": true
17
+ }
18
+ }
19
+ ]
20
+ }
authenticationprovider-sample/.vscodeignore ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .vscode/**
2
+ .vscode-test/**
3
+ out/test/**
4
+
5
+ src/**
6
+ .gitignore
7
+ .yarnrc
8
+ vsc-extension-quickstart.md
9
+ **/tsconfig.json
10
+ **/.eslintrc.json
11
+ **/*.map
12
+ **/*.ts
authenticationprovider-sample/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Change Log
2
+
3
+ All notable changes to the "vscode-authenticationprovider-sample" extension will be documented in this file.
4
+
5
+ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6
+
7
+ ## [Unreleased]
8
+
9
+ - Initial release
authenticationprovider-sample/README.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Azure DevOps Auth Provider - Authentication Provider API Sample
2
+
3
+ Demonstrates VS Code's authentication provider API by registering and using an Azure DevOps Personal Access Token authentication provider.
4
+
5
+ ## VS Code API
6
+
7
+ ### `vscode` module
8
+
9
+ - [`authentication.registerAuthenticationProvider`](https://code.visualstudio.com/api/references/vscode-api#authentication.registerAuthenticationProvider)
10
+ - [`authentication.getSession`](https://code.visualstudio.com/api/references/vscode-api#authentication.getSession)
11
+
12
+ ## Running the example
13
+
14
+ - Open this example in VS Code 1.60+
15
+ - `npm install`
16
+ - `cmd/ctrl+shift+b` or `npm run watch` or `npm run compile`
17
+ - `F5` to start debugging
18
+
19
+ Run the `Login with Azure DevOps` command to log in.
20
+
authenticationprovider-sample/eslint.config.mjs ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * ESLint configuration for the project.
3
+ *
4
+ * See https://eslint.style and https://typescript-eslint.io for additional linting options.
5
+ */
6
+ // @ts-check
7
+ import js from '@eslint/js';
8
+ import tseslint from 'typescript-eslint';
9
+ import stylistic from '@stylistic/eslint-plugin';
10
+
11
+ export default tseslint.config(
12
+ {
13
+ ignores: [
14
+ '.vscode-test',
15
+ 'out',
16
+ ]
17
+ },
18
+ js.configs.recommended,
19
+ ...tseslint.configs.recommended,
20
+ ...tseslint.configs.stylistic,
21
+ {
22
+ plugins: {
23
+ '@stylistic': stylistic
24
+ },
25
+ rules: {
26
+ 'curly': 'warn',
27
+ '@stylistic/semi': ['warn', 'always'],
28
+ '@typescript-eslint/no-empty-function': 'off',
29
+ '@typescript-eslint/naming-convention': [
30
+ 'warn',
31
+ {
32
+ 'selector': 'import',
33
+ 'format': ['camelCase', 'PascalCase']
34
+ }
35
+ ],
36
+ '@typescript-eslint/no-unused-vars': [
37
+ 'error',
38
+ {
39
+ 'argsIgnorePattern': '^_'
40
+ }
41
+ ]
42
+ }
43
+ }
44
+ );
authenticationprovider-sample/package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
authenticationprovider-sample/package.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "vscode-authenticationprovider-sample",
3
+ "displayName": "AuthenticationProvider API Sample",
4
+ "description": "AuthenticationProvider API Sample",
5
+ "version": "0.0.1",
6
+ "engines": {
7
+ "vscode": "^1.100.0"
8
+ },
9
+ "categories": [
10
+ "Other"
11
+ ],
12
+ "activationEvents": [],
13
+ "main": "./out/extension.js",
14
+ "contributes": {
15
+ "commands": [
16
+ {
17
+ "command": "vscode-authenticationprovider-sample.login",
18
+ "title": "Login with Azure DevOps"
19
+ }
20
+ ],
21
+ "authentication": [
22
+ {
23
+ "id": "azuredevopspat",
24
+ "label": "Azure DevOps PAT"
25
+ }
26
+ ]
27
+ },
28
+ "scripts": {
29
+ "vscode:prepublish": "npm run compile",
30
+ "compile": "tsc -p ./",
31
+ "watch": "tsc -watch -p ./",
32
+ "pretest": "npm run compile && npm run lint",
33
+ "lint": "eslint",
34
+ "test": "node ./out/test/runTest.js"
35
+ },
36
+ "devDependencies": {
37
+ "@eslint/js": "^9.13.0",
38
+ "@stylistic/eslint-plugin": "^2.9.0",
39
+ "@types/isomorphic-fetch": "^0.0.35",
40
+ "@types/node": "^22",
41
+ "@types/vscode": "^1.100.0",
42
+ "eslint": "^9.13.0",
43
+ "typescript": "^5.9.2",
44
+ "typescript-eslint": "^8.39.0"
45
+ },
46
+ "dependencies": {
47
+ "isomorphic-fetch": "^3.0.0"
48
+ }
49
+ }
authenticationprovider-sample/src/authProvider.ts ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ authentication,
3
+ AuthenticationGetSessionOptions,
4
+ AuthenticationProvider,
5
+ AuthenticationProviderAuthenticationSessionsChangeEvent,
6
+ AuthenticationSession,
7
+ Disposable,
8
+ Event,
9
+ EventEmitter,
10
+ SecretStorage,
11
+ window,
12
+ } from 'vscode';
13
+
14
+ class AzureDevOpsPatSession implements AuthenticationSession {
15
+ // We don't know the user's account name, so we'll just use a constant
16
+ readonly account = { id: AzureDevOpsAuthenticationProvider.id, label: 'Personal Access Token' };
17
+ // This id isn't used for anything in this example, so we set it to a constant
18
+ readonly id = AzureDevOpsAuthenticationProvider.id;
19
+ // We don't know what scopes the PAT has, so we have an empty array here.
20
+ readonly scopes = [];
21
+
22
+ /**
23
+ *
24
+ * @param accessToken The personal access token to use for authentication
25
+ */
26
+ constructor(public readonly accessToken: string) { }
27
+ }
28
+
29
+ export class AzureDevOpsAuthenticationProvider implements AuthenticationProvider, Disposable {
30
+ static id = 'azuredevopspat';
31
+ private static secretKey = 'AzureDevOpsPAT';
32
+
33
+ // this property is used to determine if the token has been changed in another window of VS Code.
34
+ // It is used in the checkForUpdates function.
35
+ private currentToken: Promise<string | undefined> | undefined;
36
+ private initializedDisposable: Disposable | undefined;
37
+
38
+ private _onDidChangeSessions = new EventEmitter<AuthenticationProviderAuthenticationSessionsChangeEvent>();
39
+ get onDidChangeSessions(): Event<AuthenticationProviderAuthenticationSessionsChangeEvent> {
40
+ return this._onDidChangeSessions.event;
41
+ }
42
+
43
+ constructor(private readonly secretStorage: SecretStorage) { }
44
+
45
+ dispose(): void {
46
+ this.initializedDisposable?.dispose();
47
+ }
48
+
49
+ private ensureInitialized(): void {
50
+ if (this.initializedDisposable === undefined) {
51
+ void this.cacheTokenFromStorage();
52
+
53
+ this.initializedDisposable = Disposable.from(
54
+ // This onDidChange event happens when the secret storage changes in _any window_ since
55
+ // secrets are shared across all open windows.
56
+ this.secretStorage.onDidChange(e => {
57
+ if (e.key === AzureDevOpsAuthenticationProvider.secretKey) {
58
+ void this.checkForUpdates();
59
+ }
60
+ }),
61
+ // This fires when the user initiates a "silent" auth flow via the Accounts menu.
62
+ authentication.onDidChangeSessions(e => {
63
+ if (e.provider.id === AzureDevOpsAuthenticationProvider.id) {
64
+ void this.checkForUpdates();
65
+ }
66
+ }),
67
+ );
68
+ }
69
+ }
70
+
71
+ // This is a crucial function that handles whether or not the token has changed in
72
+ // a different window of VS Code and sends the necessary event if it has.
73
+ private async checkForUpdates(): Promise<void> {
74
+ const added: AuthenticationSession[] = [];
75
+ const removed: AuthenticationSession[] = [];
76
+ const changed: AuthenticationSession[] = [];
77
+
78
+ const previousToken = await this.currentToken;
79
+ const session = (await this.getSessions(undefined))[0];
80
+
81
+ if (session?.accessToken && !previousToken) {
82
+ added.push(session);
83
+ } else if (!session?.accessToken && previousToken) {
84
+ removed.push(session);
85
+ } else if (session?.accessToken !== previousToken) {
86
+ changed.push(session);
87
+ } else {
88
+ return;
89
+ }
90
+
91
+ void this.cacheTokenFromStorage();
92
+ this._onDidChangeSessions.fire({ added: added, removed: removed, changed: changed });
93
+ }
94
+
95
+ private cacheTokenFromStorage() {
96
+ this.currentToken = this.secretStorage.get(AzureDevOpsAuthenticationProvider.secretKey) as Promise<string | undefined>;
97
+ return this.currentToken;
98
+ }
99
+
100
+ // This function is called first when `vscode.authentication.getSessions` is called.
101
+ async getSessions(_scopes: string[] | undefined, _options?: AuthenticationGetSessionOptions): Promise<AuthenticationSession[]> {
102
+ this.ensureInitialized();
103
+ const token = await this.cacheTokenFromStorage();
104
+ return token ? [new AzureDevOpsPatSession(token)] : [];
105
+ }
106
+
107
+ // This function is called after `this.getSessions` is called and only when:
108
+ // - `this.getSessions` returns nothing but `createIfNone` was set to `true` in `vscode.authentication.getSessions`
109
+ // - `vscode.authentication.getSessions` was called with `forceNewSession: true`
110
+ // - The end user initiates the "silent" auth flow via the Accounts menu
111
+ async createSession(_scopes: string[]): Promise<AuthenticationSession> {
112
+ this.ensureInitialized();
113
+
114
+ // Prompt for the PAT.
115
+ const token = await window.showInputBox({
116
+ ignoreFocusOut: true,
117
+ placeHolder: 'Personal access token',
118
+ prompt: 'Enter an Azure DevOps Personal Access Token (PAT).',
119
+ password: true,
120
+ });
121
+
122
+ // Note: this example doesn't do any validation of the token beyond making sure it's not empty.
123
+ if (!token) {
124
+ throw new Error('PAT is required');
125
+ }
126
+
127
+ // Don't set `currentToken` here, since we want to fire the proper events in the `checkForUpdates` call
128
+ await this.secretStorage.store(AzureDevOpsAuthenticationProvider.secretKey, token);
129
+ console.log('Successfully logged in to Azure DevOps');
130
+
131
+ return new AzureDevOpsPatSession(token);
132
+ }
133
+
134
+ // This function is called when the end user signs out of the account.
135
+ async removeSession(_sessionId: string): Promise<void> {
136
+ const token = await this.currentToken;
137
+ if (!token) {
138
+ return;
139
+ }
140
+ await this.secretStorage.delete(AzureDevOpsAuthenticationProvider.secretKey);
141
+ this._onDidChangeSessions.fire({
142
+ removed: [new AzureDevOpsPatSession(token)],
143
+ added: [],
144
+ changed: [],
145
+ });
146
+ }
147
+ }