@codingame/monaco-vscode-api 1.83.15 → 1.83.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +430 -0
- package/contributions.js +3 -0
- package/localExtensionHost.js +3 -2
- package/missing-services.js +57 -1
- package/monaco-editor-treemending.patch +957 -957
- package/package.json +6 -6
- package/vscode/src/vs/base/common/prefixTree.js +130 -0
- package/vscode/src/vs/platform/actions/browser/floatingMenu.js +26 -2
- package/vscode/src/vs/platform/terminal/common/capabilities/bufferMarkCapability.js +41 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +566 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/cwdDetectionCapability.js +29 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/partialCommandDetectionCapability.js +48 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/terminalCapabilityStore.js +94 -0
- package/vscode/src/vs/platform/terminal/common/terminalEnvironment.js +37 -0
- package/vscode/src/vs/platform/terminal/common/terminalStrings.js +16 -0
- package/vscode/src/vs/platform/terminal/common/xterm/shellIntegrationAddon.js +319 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput.js +91 -1
- package/vscode/src/vs/workbench/contrib/format/browser/formatActionsMultiple.js +423 -0
- package/vscode/src/vs/workbench/contrib/format/browser/formatActionsNone.js +82 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/detachedTerminal.js +67 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalExtensions.js +25 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIcons.js +64 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/widgets/widgetManager.js +36 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +538 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationStyles.js +104 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +416 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/suggestAddon.js +390 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +799 -0
- package/vscode/src/vs/workbench/contrib/testing/common/getComputedState.js +101 -0
- package/vscode/src/vs/workbench/contrib/testing/common/observableValue.js +30 -0
- package/vscode/src/vs/workbench/contrib/testing/common/storedValue.js +36 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testExplorerFilterState.js +116 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testProfileService.js +172 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testResult.js +384 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testResultService.js +156 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testResultStorage.js +156 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testService.js +75 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testTypes.js +9 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testingContextKeys.js +179 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testingContinuousRunService.js +102 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testingDecorations.js +29 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testingPeekOpener.js +3 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testingStates.js +47 -0
- package/vscode/src/vs/workbench/services/suggest/browser/media/suggest.css.js +4 -0
- package/vscode/src/vs/workbench/services/suggest/browser/simpleCompletionItem.js +10 -0
- package/vscode/src/vs/workbench/services/suggest/browser/simpleCompletionModel.js +98 -0
- package/vscode/src/vs/workbench/services/suggest/browser/simpleSuggestWidget.js +428 -0
- package/vscode/src/vs/workbench/services/suggest/browser/simpleSuggestWidgetRenderer.js +83 -0
package/README.md
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
# @codingame/monaco-vscode-api · [](https://www.npmjs.com/package/@codingame/monaco-vscode-api) [](https://www.npmjs.com/package/@codingame/monaco-vscode-api) [](https://github.com/codingame/monaco-vscode-api/pulls)
|
|
2
|
+
|
|
3
|
+
[NPM module](https://www.npmjs.com/) that implements the VSCode api and redirects calls to Monaco editor.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install vscode@npm:@codingame/monaco-vscode-api
|
|
9
|
+
npm install -D @types/vscode
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
⚠️ And add in your package.json ⚠️:
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"scripts": {
|
|
16
|
+
"postinstall": "monaco-treemending",
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Why?
|
|
22
|
+
|
|
23
|
+
Monaco-editor is a library that is constructed using code from vscode and goes through an intense treeshaking process.
|
|
24
|
+
|
|
25
|
+
However, due to the inclusion of additional code from VSCode in this library that utilizes internal modules bundled in monaco, this treeshaking is a problem here.
|
|
26
|
+
|
|
27
|
+
To **tree-mend** (to **un**treeshake it) monaco-editor, this library provides a script that will apply a patch on the local installation of monaco-editor, restoring all the code that was treeshaken during the monaco-editor build process
|
|
28
|
+
|
|
29
|
+
## Troubleshooting
|
|
30
|
+
|
|
31
|
+
### If you use Vite
|
|
32
|
+
|
|
33
|
+
This library uses a lot the `new URL('asset.extension', import.meta.url)` syntax which [is supported by vite](https://vitejs.dev/guide/assets.html#new-url-url-import-meta-url)
|
|
34
|
+
|
|
35
|
+
While it works great in `build` mode (because rollup is used), there is some issues in `watch`` mode:
|
|
36
|
+
- import.meta.url is not replaced while creating bundles, it is an issue when the syntax is used inside a dependency
|
|
37
|
+
- vite is still trying to inject/transform javascript assets files, breaking the code by injecting ESM imports in commonjs files
|
|
38
|
+
|
|
39
|
+
There are workarounds for both:
|
|
40
|
+
|
|
41
|
+
- We can help vite by replacing `import.meta.url` by the original module path (you need the --experimental-import-meta-resolve note option):
|
|
42
|
+
```typescript
|
|
43
|
+
{
|
|
44
|
+
...
|
|
45
|
+
optimizeDeps: {
|
|
46
|
+
esbuildOptions: {
|
|
47
|
+
plugins: [{
|
|
48
|
+
name: 'import.meta.url',
|
|
49
|
+
setup ({ onLoad }) {
|
|
50
|
+
// Help vite that bundles/move files in dev mode without touching `import.meta.url` which breaks asset urls
|
|
51
|
+
onLoad({ filter: /.*\.js/, namespace: 'file' }, async args => {
|
|
52
|
+
const code = fs.readFileSync(args.path, 'utf8')
|
|
53
|
+
|
|
54
|
+
const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g
|
|
55
|
+
let i = 0
|
|
56
|
+
let newCode = ''
|
|
57
|
+
for (let match = assetImportMetaUrlRE.exec(code); match != null; match = assetImportMetaUrlRE.exec(code)) {
|
|
58
|
+
newCode += code.slice(i, match.index)
|
|
59
|
+
|
|
60
|
+
const path = match[1].slice(1, -1)
|
|
61
|
+
const resolved = await import.meta.resolve!(path, url.pathToFileURL(args.path))
|
|
62
|
+
|
|
63
|
+
newCode += `new URL(${JSON.stringify(url.fileURLToPath(resolved))}, import.meta.url)`
|
|
64
|
+
|
|
65
|
+
i = assetImportMetaUrlRE.lastIndex
|
|
66
|
+
}
|
|
67
|
+
newCode += code.slice(i)
|
|
68
|
+
|
|
69
|
+
return { contents: newCode }
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
}]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### If using Angular and getting `Not allowed to load local resource:` errors
|
|
79
|
+
|
|
80
|
+
*The short version*: set up and use a custom webpack config file and add this under `module`:
|
|
81
|
+
```typescript
|
|
82
|
+
parser: {
|
|
83
|
+
javascript: {
|
|
84
|
+
url: true,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
See [this issue](https://github.com/CodinGame/monaco-vscode-api/issues/186) or this [StackOverflow answer](https://stackoverflow.com/a/75252098) for more details, and [this discussion](https://github.com/angular/angular-cli/issues/24617) for more context.
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# Usage
|
|
93
|
+
|
|
94
|
+
## Monaco standalone services
|
|
95
|
+
|
|
96
|
+
Also, monaco-editor use `standalone` versions or the vscode services, which are much simpler.
|
|
97
|
+
|
|
98
|
+
You may want to provide your custom implementations of them. To do so, you can use the `initialize` method from `vscode/services`.
|
|
99
|
+
Also, monaco-editor doesn't provide good type for them, so this library does it.
|
|
100
|
+
|
|
101
|
+
Example:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { INotificationService, initialize } from 'vscode/services'
|
|
105
|
+
|
|
106
|
+
class MyCustomNotificationService implements INotificationService { ... }
|
|
107
|
+
await initialize({
|
|
108
|
+
get [INotificationService.toString()] () {
|
|
109
|
+
return new MyCustomNotificationService(...)
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Additionally, 25 packages that include the vscode version of some services (with some glue to make it work with monaco) are published:
|
|
115
|
+
|
|
116
|
+
- **Extensions** (included by default): `@codingame/monaco-vscode-extensions-service-override`
|
|
117
|
+
- Support for VSCode extensions. A worker configuration can be past to it:
|
|
118
|
+
- Then, everything runs in one worker, where extensions run in an iframe, with all the implications (can be created by the bundler directly). The worker script is expected to be hosted on a separate domain.
|
|
119
|
+
- **Files** (included by default): `@codingame/monaco-vscode-files-service-override`
|
|
120
|
+
- It adds the memory filesystem for `file://` files, but also adds the support for lazy loaded extension files. It adds separate memory user files (e.g. config, keybindings), cache files and log files.
|
|
121
|
+
- **QuickAccess** (included by default): `@codingame/monaco-vscode-quickaccess-service-override`
|
|
122
|
+
- Enables the quickaccess menu in the editor (press F1 or ctrl+shift+p)
|
|
123
|
+
- **Notifications**: `@codingame/monaco-vscode-notifications-service-override`
|
|
124
|
+
- This services enables vscode notifications you usually find in the bottom right corner.
|
|
125
|
+
- **Dialogs**: `@codingame/monaco-vscode-dialogs-service-override`
|
|
126
|
+
- Enable vscode modal dialogs. It allows users to select an action to do. Those actions are exposed to the vscode API. Additionally, this service can be used by the language client to delegate questions to the user.
|
|
127
|
+
- **Model**: `@codingame/monaco-vscode-model-service-override`
|
|
128
|
+
- This service creates and takes care of model references. For example:
|
|
129
|
+
- Create model if content is unknown
|
|
130
|
+
- Count references
|
|
131
|
+
- Destroy models when they are no longer used
|
|
132
|
+
- **Editor**: `@codingame/monaco-vscode-editor-service-override`
|
|
133
|
+
- Enable editor support. This is usually needed when working with the language server protocol. Without enabling the editor service, it will only be able to resolve the currently open model (only internal file links will work).
|
|
134
|
+
- **Views**: `@codingame/monaco-vscode-views-service-override`
|
|
135
|
+
- Enable full views support. Is exclusive with the `editor` service. Do not use both services at the same time.
|
|
136
|
+
- **Configuration**: `@codingame/monaco-vscode-configuration-service-override`
|
|
137
|
+
- Allows to change the configuration of not only the editors, but every part of vscode. The language client for instance uses it to send the requested configuration to the server. The default configuration service already allows to change the configuration. This service overrides makes it rely on a user configuration file (with json schema, overridable by language including all vscode features).
|
|
138
|
+
- **Keybindings**: `@codingame/monaco-vscode-keybindings-service-override`
|
|
139
|
+
- Enables platform specific keybindings and make it rely on a user definded keybindings configuration (if available).
|
|
140
|
+
- **Languages**: `@codingame/monaco-vscode-languages-service-override`
|
|
141
|
+
- Enable language support. It's like the standalone service with 2 differences:
|
|
142
|
+
- It handle the language extension point (getting languages from vscode extensions)
|
|
143
|
+
- It triggers the `onLanguage:${language}` event (to load vscode extension listening to those events)
|
|
144
|
+
- **Textmate**: `@codingame/monaco-vscode-textmate-service-override`
|
|
145
|
+
- Allows to use textmate grammars. Depends on *themes* service. vscode extensions use textmate grammars exclusively for highlighting. Once this is enabled monarch grammars can no longer be loaded by monaco-editor.
|
|
146
|
+
- **Themes**: `@codingame/monaco-vscode-theme-service-override`
|
|
147
|
+
- Allows to use VSCode themes.
|
|
148
|
+
- **Snippets**: `@codingame/monaco-vscode-snippets-service-override`
|
|
149
|
+
- Add snippet extension point (register vscode extension snippets)
|
|
150
|
+
- **Audio cue**: `@codingame/monaco-vscode-audio-cue-service-override`
|
|
151
|
+
- If enabled the editor may provides audible hints
|
|
152
|
+
- **Debug**: `@codingame/monaco-vscode-debug-service-override`
|
|
153
|
+
- Activate debugging support
|
|
154
|
+
- **Preferences**: `@codingame/monaco-vscode-preferences-service-override`
|
|
155
|
+
- Allow to read and write preferences
|
|
156
|
+
- **Output**: `@codingame/monaco-vscode-output-service-override`
|
|
157
|
+
- Output panel support. *Hint*: It only makes sense to enable it when *Views* service is used.
|
|
158
|
+
- **Terminal**: `@codingame/monaco-vscode-terminal-service-override`
|
|
159
|
+
- Terminal panel support. *Hint*: It only makes sense to enable it when *Views* service is used.
|
|
160
|
+
- **Search**: `@codingame/monaco-vscode-search-service-override`
|
|
161
|
+
- search panel support. *Hint*: It only makes sense to enable it when *Views* service is used.
|
|
162
|
+
- **Markers**: `@codingame/monaco-vscode-markers-service-override`
|
|
163
|
+
- It adds the problems panel tab. *Hint*: It only makes sense to enable it when *Views* service is used.
|
|
164
|
+
- **SCM**: `@codingame/monaco-vscode-scm-service-override`
|
|
165
|
+
- It adds the SCM API that can be used to implement source control. *Hint*: It only makes sense to enable it when *Views* service is used.
|
|
166
|
+
- **Testing**: `@codingame/monaco-vscode-testing-service-override`
|
|
167
|
+
- It adds the Tests API. *Hint*: It makes more sense to enable it when *Views* service is used.
|
|
168
|
+
- **Language detection worker**: `@codingame/monaco-vscode-language-detection-worker-service-override`
|
|
169
|
+
- When opening an untitled model or a file without extension or if vscode is unable to guess the language simply by the file extension or by reading the first line. Then it will use tensorflow in a worker to try to guess the most probable language (here we are only able to rely on the open source model).
|
|
170
|
+
- **Storage**: `@codingame/monaco-vscode-storage-service-override`
|
|
171
|
+
- Define your own storage or use the default BrowserStorageService. The storage service is used in many places either as a cache or as a user preference store. For instance:
|
|
172
|
+
- Current loaded theme is stored in there to be loaded faster on start.
|
|
173
|
+
- Every panel/view positions are stored in there.
|
|
174
|
+
- **LifeCycle**: `@codingame/monaco-vscode-lifecycle-service-override`
|
|
175
|
+
- Allow other services to veto a page reload (for instance when not all open files are saved)
|
|
176
|
+
- **Remote agent**: `@codingame/monaco-vscode-remote-agent-service-override`
|
|
177
|
+
- Connect to a remote vscode agent and have access to:
|
|
178
|
+
- The remote filesystem
|
|
179
|
+
- The remote file search
|
|
180
|
+
- Running terminals
|
|
181
|
+
- Running vscode extensions (not web-compatible)
|
|
182
|
+
- and probably more?
|
|
183
|
+
|
|
184
|
+
Another package `@codingame/monaco-vscode-server` is published, which expose a `vscode-ext-host-server` bin to start the remote agent
|
|
185
|
+
- **Accessibility**: `@codingame/monaco-vscode-accessibility-service-override`
|
|
186
|
+
- Register accessibility helpers
|
|
187
|
+
- **Workspace trust**: `@codingame/monaco-vscode-workspace-trust-service-override`
|
|
188
|
+
- Ask user it they trust the current workspace, disable some features if not
|
|
189
|
+
- **Extension Gallery**: `@codingame/monaco-vscode-extension-gallery-service-override`
|
|
190
|
+
- Support for the VSCode marketplace, it allows to install extensions from the marketplace.
|
|
191
|
+
Usage:
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
import * as vscode from 'vscode'
|
|
195
|
+
import { initialize } from 'vscode/services'
|
|
196
|
+
import getEditorServiceOverride from '@codingame/monaco-vscode-editor-service-override'
|
|
197
|
+
import getConfigurationServiceOverride, { updateUserConfiguration, configurationRegistry } from '@codingame/monaco-vscode-configuration-service-override'
|
|
198
|
+
|
|
199
|
+
await initialize({
|
|
200
|
+
...getModelEditorServiceOverride((model, input, sideBySide) => {
|
|
201
|
+
// Open a new editor here and return it
|
|
202
|
+
// It will be called when for instance the user ctrl+click on an import
|
|
203
|
+
}),
|
|
204
|
+
...getConfigurationServiceOverride(vscode.Uri.file('/tmp/'))
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
updateUserConfiguration(`{
|
|
208
|
+
"editor.fontSize": 12,
|
|
209
|
+
"[java]": {
|
|
210
|
+
"editor.fontSize": 15,
|
|
211
|
+
}
|
|
212
|
+
}`)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Troubleshoot
|
|
216
|
+
|
|
217
|
+
`initialize` can only be called once ( and it should be called BEFORE creating your first editor).
|
|
218
|
+
|
|
219
|
+
## Editor configuration
|
|
220
|
+
|
|
221
|
+
The editors created using `monaco.editor.create` don't use the configuration from the configurationService.
|
|
222
|
+
|
|
223
|
+
This library exposes functions to create editors binded on the configuration service:
|
|
224
|
+
|
|
225
|
+
before:
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import * as monaco from 'monaco-editor'
|
|
229
|
+
const model = monaco.editor.createModel(...)
|
|
230
|
+
const editor = monaco.editor.create({ model, ... })
|
|
231
|
+
|
|
232
|
+
...
|
|
233
|
+
|
|
234
|
+
model.dispose()
|
|
235
|
+
editor.dispose()
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
after:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { createConfiguredEditor, createModelReference } from 'vscode/monaco'
|
|
243
|
+
|
|
244
|
+
const modelRef = await createModelReference(...)
|
|
245
|
+
|
|
246
|
+
const editor = createConfiguredEditor({ model: modelRef.object.textEditorModel })
|
|
247
|
+
|
|
248
|
+
...
|
|
249
|
+
|
|
250
|
+
await modelRef.object.save()
|
|
251
|
+
|
|
252
|
+
...
|
|
253
|
+
|
|
254
|
+
modelRef.dispose()
|
|
255
|
+
editor.dispose()
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
`createConfiguredEditor` returns a subclass of what is returned by `monaco.editor.create`, the `updateOptions` method can still be used.
|
|
261
|
+
The only difference is that is will use the `configurationService` as a default configuration
|
|
262
|
+
|
|
263
|
+
`createModelReference` return a reference to a model. The value is fetched from the memory filesystem (which is written if you provide the second argument).
|
|
264
|
+
The reference can then be disposed, the model will only be disposed if there is no remaining references.
|
|
265
|
+
|
|
266
|
+
## VSCode api usage
|
|
267
|
+
|
|
268
|
+
To be able to use the VSCode api directly from your code, you need to import `vscode/localExtensionHost` and the services to be initialized.
|
|
269
|
+
|
|
270
|
+
You will then be able to import it as if you were in a VSCode extension:
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
import * as vscode from 'vscode'
|
|
274
|
+
import 'vscode/localExtensionHost'
|
|
275
|
+
|
|
276
|
+
const range = new vscode.Range(...)
|
|
277
|
+
vscode.languages.registerCompletionItemProvider(...)
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The api will use the manifest of a default vscode extension, which can be overriden by providing it to the `initialize` function.
|
|
281
|
+
|
|
282
|
+
You can also register a new extension from its manifest:
|
|
283
|
+
```typescript
|
|
284
|
+
import { registerExtension, initialize, ExtensionHostKind } from 'vscode/extensions'
|
|
285
|
+
|
|
286
|
+
await initialize()
|
|
287
|
+
|
|
288
|
+
const extension = {
|
|
289
|
+
name: 'my-extension',
|
|
290
|
+
publisher: 'someone',
|
|
291
|
+
version: '1.0.0',
|
|
292
|
+
engines: {
|
|
293
|
+
vscode: '*'
|
|
294
|
+
},
|
|
295
|
+
contributes: {
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const { registerFileUrl, getApi } = registerExtension(extension, ExtensionHostKind.LocalProcess)
|
|
299
|
+
|
|
300
|
+
registerFileUrl('/file-extension-path.json', new URL('./file-real-path.json', import.meta.url).toString())
|
|
301
|
+
|
|
302
|
+
const vscode = await getApi()
|
|
303
|
+
|
|
304
|
+
vscode.languages.registerCompletionItemProvider(...)
|
|
305
|
+
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Default vscode extensions
|
|
309
|
+
|
|
310
|
+
VSCode uses a bunch of default extensions. Most of them are used to load the default languages and grammars (see https://github.com/microsoft/vscode/tree/main/extensions).
|
|
311
|
+
|
|
312
|
+
This library bundles and publishes them and allows to import the ones you want:
|
|
313
|
+
```typescript
|
|
314
|
+
import '@codingame/monaco-vscode-javascript-default-extension'
|
|
315
|
+
import '@codingame/monaco-vscode-json-default-extension'
|
|
316
|
+
...
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Loading vsix file
|
|
320
|
+
|
|
321
|
+
VSCode extension are bundled as vsix files.
|
|
322
|
+
This library publishes a rollup plugin (vite-compatible) that allows to load a vsix file.
|
|
323
|
+
|
|
324
|
+
- rollup/vite config:
|
|
325
|
+
```typescript
|
|
326
|
+
import vsixPlugin from '@codingame/monaco-vscode-rollup-vsix-plugin'
|
|
327
|
+
...
|
|
328
|
+
plugins: [
|
|
329
|
+
...,
|
|
330
|
+
vsixPlugin()
|
|
331
|
+
]
|
|
332
|
+
```
|
|
333
|
+
- code:
|
|
334
|
+
```typescript
|
|
335
|
+
import './extension.vsix'
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Localization
|
|
339
|
+
|
|
340
|
+
This library also offers the possibility to localize vscode and the extensions in the supported languages. To do so, import one of the following packages before anything else:
|
|
341
|
+
- `@codingame/monaco-vscode-language-pack-cs`
|
|
342
|
+
- `@codingame/monaco-vscode-language-pack-de`
|
|
343
|
+
- `@codingame/monaco-vscode-language-pack-es`
|
|
344
|
+
- `@codingame/monaco-vscode-language-pack-fr`
|
|
345
|
+
- `@codingame/monaco-vscode-language-pack-it`
|
|
346
|
+
- `@codingame/monaco-vscode-language-pack-ja`
|
|
347
|
+
- `@codingame/monaco-vscode-language-pack-ko`
|
|
348
|
+
- `@codingame/monaco-vscode-language-pack-pl`
|
|
349
|
+
- `@codingame/monaco-vscode-language-pack-pt-br`
|
|
350
|
+
- `@codingame/monaco-vscode-language-pack-qps-ploc`
|
|
351
|
+
- `@codingame/monaco-vscode-language-pack-ru`
|
|
352
|
+
- `@codingame/monaco-vscode-language-pack-tr`
|
|
353
|
+
- `@codingame/monaco-vscode-language-pack-zh-hans`
|
|
354
|
+
- `@codingame/monaco-vscode-language-pack-zh-hant`
|
|
355
|
+
|
|
356
|
+
⚠️ The language pack should be imported and loaded BEFORE anything else from monaco-editor or this library is loaded. Otherwise, some translations would be missing. ⚠️
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
### Demo
|
|
360
|
+
|
|
361
|
+
Try it out on https://codingame.github.io/monaco-vscode-api/
|
|
362
|
+
|
|
363
|
+
There is a demo that showcases the service-override features. It allows to register contributions with the same syntaxes as in VSCode.
|
|
364
|
+
It includes:
|
|
365
|
+
|
|
366
|
+
- Languages
|
|
367
|
+
- VSCode themes
|
|
368
|
+
- Textmate grammars (requires vscode themes)
|
|
369
|
+
- Notifications/Dialogs
|
|
370
|
+
- Model/Editor services
|
|
371
|
+
- Configuration service, with user configuration editor
|
|
372
|
+
- Keybinding service, with user keybindings editor
|
|
373
|
+
- Debuggers
|
|
374
|
+
|
|
375
|
+
From CLI run:
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
# build monaco-vscode-api (the demo use it as a local dependency)
|
|
379
|
+
npm ci
|
|
380
|
+
npm run build
|
|
381
|
+
# start demo
|
|
382
|
+
cd demo
|
|
383
|
+
npm ci
|
|
384
|
+
npm start
|
|
385
|
+
# OR: for vite debug output
|
|
386
|
+
npm run start:debug
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
For the debug feature, also run:
|
|
390
|
+
```bash
|
|
391
|
+
npm run start:debugServer
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
⚠️ Building monaco-vscode-api is only supported on Linux or Mac. It you use Windows, have a look at [WSL](https://learn.microsoft.com/windows/wsl/install) ⚠️
|
|
395
|
+
|
|
396
|
+
#### Remote agent
|
|
397
|
+
|
|
398
|
+
To connect to a remote agent, run:
|
|
399
|
+
```bash
|
|
400
|
+
npm run start:extHostServer
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
Then go to http://localhost:5173/?remoteAuthority=localhost:8000
|
|
404
|
+
|
|
405
|
+
You can also go to http://localhost:5173/?remoteAuthority=localhost:8000&remotePath=/any/path/on/your/machine to open a directory on your machine as the current workspace
|
|
406
|
+
|
|
407
|
+
### History
|
|
408
|
+
|
|
409
|
+
This project was mainly created to make the implementation of [monaco-languageclient](https://github.com/TypeFox/monaco-languageclient) more robust and maintainable.
|
|
410
|
+
|
|
411
|
+
monaco-languageclient uses [vscode-languageclient](https://www.npmjs.com/package/vscode-languageclient) which was built to run inside a VSCode extension. VSCode extensions communicate with the editor via an [API](https://www.npmjs.com/package/@types/vscode) they can import into their code.
|
|
412
|
+
|
|
413
|
+
[The VSCode api](https://code.visualstudio.com/api/references/vscode-api) exports:
|
|
414
|
+
|
|
415
|
+
- Some functions to interact with the IDE ([language feature registrations](https://code.visualstudio.com/api/references/vscode-api#languages), [command execution](https://code.visualstudio.com/api/references/vscode-api#commands)...)
|
|
416
|
+
- A lot of utility classes (Range, Position...)
|
|
417
|
+
|
|
418
|
+
The first implementations of [monaco-languageclient](https://github.com/TypeFox/monaco-languageclient) were using a fake VSCode api implementation. The vscode-languageclient was hacked so the VSCode<->protocol object converters were mainly bypassed, so the fake VSCode api was receiving [Language Server Protocol](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/) objects. Then the objects were transformed using custom transformers into [Monaco](https://www.npmjs.com/package/monaco-editor) objects to communicate with the monaco api.
|
|
419
|
+
|
|
420
|
+
This approach has some disadvantages:
|
|
421
|
+
|
|
422
|
+
- There is a lot of code to transform LSP objects into Monaco objects
|
|
423
|
+
- It's hard to follow the updates of VSCode and the language server protocol
|
|
424
|
+
- It doesn't behave exactly the same as in VSCode
|
|
425
|
+
|
|
426
|
+
With this library, it would be possible to plug vscode-languageclient directly on top of monaco, monaco-languageclient still helps to do so by:
|
|
427
|
+
|
|
428
|
+
- Adding some tweaks to the VSCode LanguageClient (Removing unsupported features...)
|
|
429
|
+
- Providing some examples on how to build an app using it
|
|
430
|
+
- Adding some tools (DisposableCollection)
|
package/contributions.js
CHANGED
|
@@ -17,6 +17,9 @@ import './vscode/src/vs/workbench/contrib/codeEditor/browser/toggleRenderControl
|
|
|
17
17
|
import './vscode/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.js';
|
|
18
18
|
import './vscode/src/vs/workbench/contrib/codeEditor/browser/toggleRenderWhitespace.js';
|
|
19
19
|
import './vscode/src/vs/workbench/contrib/codeEditor/browser/editorLineNumberMenu.js';
|
|
20
|
+
import './vscode/src/vs/workbench/contrib/format/browser/formatActionsMultiple.js';
|
|
21
|
+
import './vscode/src/vs/workbench/contrib/format/browser/formatActionsNone.js';
|
|
22
|
+
import './vscode/src/vs/workbench/contrib/format/browser/formatModified.js';
|
|
20
23
|
import './vscode/src/vs/workbench/contrib/folding/browser/folding.contribution.js';
|
|
21
24
|
import './vscode/src/vs/workbench/contrib/inlayHints/browser/inlayHintsAccessibilty.js';
|
|
22
25
|
import './vscode/src/vs/workbench/contrib/codeActions/browser/codeActions.contribution.js';
|
package/localExtensionHost.js
CHANGED
|
@@ -8,7 +8,7 @@ import { joinPath } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
|
8
8
|
import { UIKind } from './vscode/src/vs/workbench/services/extensions/common/extensionHostProtocol.js';
|
|
9
9
|
import * as platform from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
10
10
|
import { IExtHostExtensionService } from './vscode/src/vs/workbench/api/common/extHostExtensionService.js';
|
|
11
|
-
import { nullExtensionDescription } from './vscode/src/vs/workbench/services/extensions/common/extensions.js';
|
|
11
|
+
import { nullExtensionDescription, IExtensionService } from './vscode/src/vs/workbench/services/extensions/common/extensions.js';
|
|
12
12
|
import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
|
|
13
13
|
import { IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
14
14
|
import { ILabelService } from 'monaco-editor/esm/vs/platform/label/common/label.js';
|
|
@@ -202,6 +202,7 @@ async function createLocalApi(extensionId) {
|
|
|
202
202
|
}
|
|
203
203
|
setLocalExtensionHost(LocalExtensionHost);
|
|
204
204
|
registerLocalApiFactory(createLocalApi);
|
|
205
|
-
registerServiceInitializePostParticipant(async () => {
|
|
205
|
+
registerServiceInitializePostParticipant(async (accessor) => {
|
|
206
|
+
accessor.get(IExtensionService);
|
|
206
207
|
setDefaultApi(await createLocalApi());
|
|
207
208
|
});
|
package/missing-services.js
CHANGED
|
@@ -176,8 +176,13 @@ import { IWorkspaceExtensionsConfigService } from './vscode/src/vs/workbench/ser
|
|
|
176
176
|
import { IRemoteUserDataProfilesService } from './vscode/src/vs/workbench/services/userDataProfile/common/remoteUserDataProfiles.js';
|
|
177
177
|
import { IExtensionBisectService } from './vscode/src/vs/workbench/services/extensionManagement/browser/extensionBisect.js';
|
|
178
178
|
import { IUserDataSyncAccountService } from './vscode/src/vs/platform/userDataSync/common/userDataSyncAccount.js';
|
|
179
|
-
import {
|
|
179
|
+
import { ITestResultStorage } from './vscode/src/vs/workbench/contrib/testing/common/testResultStorage.js';
|
|
180
|
+
import { ITestingDecorationsService } from './vscode/src/vs/workbench/contrib/testing/common/testingDecorations.js';
|
|
181
|
+
import { ITestingContinuousRunService } from './vscode/src/vs/workbench/contrib/testing/common/testingContinuousRunService.js';
|
|
182
|
+
import { ITestExplorerFilterState } from './vscode/src/vs/workbench/contrib/testing/common/testExplorerFilterState.js';
|
|
183
|
+
import { ITestingPeekOpener } from './vscode/src/vs/workbench/contrib/testing/common/testingPeekOpener.js';
|
|
180
184
|
import { getBuiltInExtensionTranslationsUris } from './l10n.js';
|
|
185
|
+
import { unsupported } from './tools.js';
|
|
181
186
|
import { IFileDialogService } from './vscode/src/vs/platform/dialogs/common/dialogs.js';
|
|
182
187
|
var _a;
|
|
183
188
|
class NullLoggerService extends AbstractLoggerService {
|
|
@@ -2259,6 +2264,20 @@ registerSingleton(ITestResultService, class TestResultService {
|
|
|
2259
2264
|
this.getStateById = () => undefined;
|
|
2260
2265
|
}
|
|
2261
2266
|
}, 1 );
|
|
2267
|
+
registerSingleton(ITestResultStorage, class TestResultStorage {
|
|
2268
|
+
constructor() {
|
|
2269
|
+
this.read = unsupported;
|
|
2270
|
+
this.persist = unsupported;
|
|
2271
|
+
}
|
|
2272
|
+
}, 1 );
|
|
2273
|
+
registerSingleton(ITestingDecorationsService, class TestingDecorationsService {
|
|
2274
|
+
constructor() {
|
|
2275
|
+
this.onDidChange = Event.None;
|
|
2276
|
+
this.invalidateResultMessage = unsupported;
|
|
2277
|
+
this.syncDecorations = unsupported;
|
|
2278
|
+
this.getDecoratedTestPosition = unsupported;
|
|
2279
|
+
}
|
|
2280
|
+
}, 1 );
|
|
2262
2281
|
registerSingleton(IUserDataInitializationService, class UserDataInitializationService {
|
|
2263
2282
|
constructor() {
|
|
2264
2283
|
this.requiresInitialization = async () => false;
|
|
@@ -2337,3 +2356,40 @@ registerSingleton(ISignService, (_a = class SignService {
|
|
|
2337
2356
|
},
|
|
2338
2357
|
_a._nextId = 1,
|
|
2339
2358
|
_a), 1 );
|
|
2359
|
+
registerSingleton(ITestingContinuousRunService, class TestingContinuousRunService {
|
|
2360
|
+
constructor() {
|
|
2361
|
+
this.lastRunProfileIds = new Set();
|
|
2362
|
+
this.onDidChange = Event.None;
|
|
2363
|
+
this.isSpecificallyEnabledFor = () => false;
|
|
2364
|
+
this.isEnabledForAParentOf = () => false;
|
|
2365
|
+
this.isEnabledForAChildOf = () => false;
|
|
2366
|
+
this.isEnabled = () => false;
|
|
2367
|
+
this.start = unsupported;
|
|
2368
|
+
this.stop = unsupported;
|
|
2369
|
+
}
|
|
2370
|
+
}, 1 );
|
|
2371
|
+
registerSingleton(ITestExplorerFilterState, class TestExplorerFilterState {
|
|
2372
|
+
constructor() {
|
|
2373
|
+
this.onDidRequestInputFocus = Event.None;
|
|
2374
|
+
this.focusInput = unsupported;
|
|
2375
|
+
this.setText = unsupported;
|
|
2376
|
+
this.isFilteringFor = () => false;
|
|
2377
|
+
this.toggleFilteringFor = unsupported;
|
|
2378
|
+
}
|
|
2379
|
+
get text() { return unsupported(); }
|
|
2380
|
+
get reveal() { return unsupported(); }
|
|
2381
|
+
get globList() { return unsupported(); }
|
|
2382
|
+
get includeTags() { return unsupported(); }
|
|
2383
|
+
get excludeTags() { return unsupported(); }
|
|
2384
|
+
get fuzzy() { return unsupported(); }
|
|
2385
|
+
}, 1 );
|
|
2386
|
+
registerSingleton(ITestingPeekOpener, class TestingPeekOpener {
|
|
2387
|
+
constructor() {
|
|
2388
|
+
this.tryPeekFirstError = unsupported;
|
|
2389
|
+
this.peekUri = unsupported;
|
|
2390
|
+
this.openCurrentInEditor = unsupported;
|
|
2391
|
+
this.open = unsupported;
|
|
2392
|
+
this.closeAllPeeks = unsupported;
|
|
2393
|
+
}
|
|
2394
|
+
get historyVisible() { return unsupported(); }
|
|
2395
|
+
}, 1 );
|