@codingame/monaco-vscode-api 7.0.0 → 7.0.2

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 CHANGED
@@ -18,7 +18,7 @@ npm install -D @types/vscode
18
18
 
19
19
  ## Monaco standalone services
20
20
 
21
- `monaco-editor`, as well as this library by default, uses `standalone` version or the vscode services, which are much simpler than the one used in VSCode.
21
+ `monaco-editor`, as well as this library by default, uses `standalone` version or the VSCode services, which are much simpler than the one used in VSCode.
22
22
 
23
23
  You may want to provide your custom implementations of them. To do so, you can use the `initialize` method from `vscode/services`.
24
24
  Also, monaco-editor doesn't provide types for them, so this library exports them.
@@ -47,86 +47,88 @@ Additionally, several packages that include the VSCode version of some services
47
47
  - **Extensions** (included by default): `@codingame/monaco-vscode-extensions-service-override`
48
48
  - Support for VSCode extensions.
49
49
  - A worker configuration can be provided to it:
50
- - Then, extensions run in a worker which runs 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.
50
+ - Then, the webworker extension host will be available, allowing to run extensions in a worker which runs in an iframe
51
51
  - **Files** (included by default): `@codingame/monaco-vscode-files-service-override`
52
- - It adds the overlay 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.
52
+ - It adds the overlay 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
53
53
  - It supports adding overlay filesystems for `file://` files
54
54
  - **QuickAccess** (included by default): `@codingame/monaco-vscode-quickaccess-service-override`
55
55
  - Enables the quickaccess menu in the editor (press F1 or ctrl+shift+p)
56
56
  - **Notifications**: `@codingame/monaco-vscode-notifications-service-override`
57
- - This services enables vscode notifications you usually find in the bottom right corner.
57
+ - This services enables vscode notifications you usually find in the bottom right corner
58
58
  - **Dialogs**: `@codingame/monaco-vscode-dialogs-service-override`
59
- - 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.
59
+ - 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
60
60
  - **Model**: `@codingame/monaco-vscode-model-service-override`
61
61
  - This service creates and takes care of model references. For example:
62
62
  - Create model from filesystem if content is unknown
63
63
  - Count references
64
64
  - Destroy models when they are no longer used
65
65
  - **Editor**: `@codingame/monaco-vscode-editor-service-override`
66
- - 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).
66
+ - 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 references will work)
67
+ - Is exclusive with the `views` and `workbench` services. Do not use more than 1 services at the same time
67
68
  - **Views**: `@codingame/monaco-vscode-views-service-override`
68
- - Enable full views support. Is exclusive with the `editor` service. Do not use both services at the same time.
69
+ - Enable full views support
70
+ - Is exclusive with the `editor` and `workbench` services. Do not use more than 1 service at the same time
69
71
  - **Configuration**: `@codingame/monaco-vscode-configuration-service-override`
70
- - 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).
72
+ - 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)
71
73
  - **Keybindings**: `@codingame/monaco-vscode-keybindings-service-override`
72
- - Enables platform specific keybindings and make it rely on a user definded keybindings configuration (if available).
74
+ - Enables platform specific keybindings and make it rely on a user definded keybindings configuration (if available)
73
75
  - **Languages**: `@codingame/monaco-vscode-languages-service-override`
74
76
  - Enable language support. It's like the standalone service with 2 differences:
75
- - It handle the language extension point (getting languages from vscode extensions)
76
- - It triggers the `onLanguage:${language}` event (to load vscode extension listening to those events)
77
+ - It handle the language extension point (getting languages from VSCode extensions)
78
+ - It triggers the `onLanguage:${language}` event (to load VSCode extension listening to those events)
77
79
  - **Textmate**: `@codingame/monaco-vscode-textmate-service-override`
78
- - 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.
80
+ - 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
79
81
  - **Themes**: `@codingame/monaco-vscode-theme-service-override`
80
- - Allows to use VSCode themes.
82
+ - Allows to use VSCode themes
81
83
  - **Snippets**: `@codingame/monaco-vscode-snippets-service-override`
82
- - Add snippet extension point (register vscode extension snippets)
84
+ - Add snippet extension point (register VSCode extension snippets)
83
85
  - **Debug**: `@codingame/monaco-vscode-debug-service-override`
84
86
  - Activate debugging support
85
87
  - **Preferences**: `@codingame/monaco-vscode-preferences-service-override`
86
88
  - Allow to read and write preferences
87
89
  - **Output**: `@codingame/monaco-vscode-output-service-override`
88
- - Output panel support. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used.
90
+ - Output panel support. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used
89
91
  - **Terminal**: `@codingame/monaco-vscode-terminal-service-override`
90
- - Terminal panel support. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used.
92
+ - Terminal panel support. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used
91
93
  - **Search**: `@codingame/monaco-vscode-search-service-override`
92
- - search panel support. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used.
94
+ - search panel support. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used
93
95
  - **Markers**: `@codingame/monaco-vscode-markers-service-override`
94
- - It adds the problems panel tab. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used.
96
+ - It adds the problems panel tab. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used
95
97
  - **SCM**: `@codingame/monaco-vscode-scm-service-override`
96
- - It adds the SCM API that can be used to implement source control. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used.
98
+ - It adds the SCM API that can be used to implement source control. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used
97
99
  - **Testing**: `@codingame/monaco-vscode-testing-service-override`
98
- - It adds the Tests API. *Hint*: It makes more sense to enable it when *Views* service is used.
100
+ - It adds the Tests API. *Hint*: It makes more sense to enable it when *Views* or *Workbench* service are used
99
101
  - **Language detection worker**: `@codingame/monaco-vscode-language-detection-worker-service-override`
100
- - 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).
102
+ - 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 (only the open source model can be used)
101
103
  - **Storage**: `@codingame/monaco-vscode-storage-service-override`
102
104
  - 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:
103
- - Current loaded theme is stored in there to be loaded faster on start.
104
- - Every panel/view positions are stored in there.
105
+ - Current loaded theme is stored in there to be loaded faster on start
106
+ - Every panel/view positions are stored in there
105
107
  - **LifeCycle**: `@codingame/monaco-vscode-lifecycle-service-override`
106
108
  - Allow other services to veto a page reload (for instance when not all open files are saved)
107
109
  - **Remote agent**: `@codingame/monaco-vscode-remote-agent-service-override`
108
- - Connect to a remote vscode agent and have access to:
110
+ - Connect to a remote VSCode agent and have access to:
109
111
  - The remote filesystem
110
112
  - The remote file search
111
113
  - Running terminals
112
- - Running vscode extensions (not web-compatible)
114
+ - Running VSCode extensions (not web-compatible)
113
115
  - and probably more?
114
116
 
115
- Another package `@codingame/monaco-vscode-server` is published, which expose a `vscode-ext-host-server` bin to start the remote agent
117
+ Refer to [vscode_server.md](./docs/vscode_server.md) for the server part
116
118
  - **Accessibility**: `@codingame/monaco-vscode-accessibility-service-override`
117
119
  - Register accessibility helpers and signals
118
120
  - **Workspace trust**: `@codingame/monaco-vscode-workspace-trust-service-override`
119
121
  - Ask user it they trust the current workspace, disable some features if not
120
122
  - **Extension Gallery**: `@codingame/monaco-vscode-extension-gallery-service-override`
121
- - Support for the VSCode marketplace, it allows to install extensions from the marketplace.
123
+ - Support for the VSCode marketplace, it allows to install extensions from the marketplace
122
124
  - **Chat**: `@codingame/monaco-vscode-chat-service-override`
123
125
  - Support for chat and inline chat features
124
126
  - **Notebook**: `@codingame/monaco-vscode-notebook-service-override`
125
127
  - Support for Jupyter notebooks
126
128
  - **Welcome**: `@codingame/monaco-vscode-welcome-service-override`
127
- - Support for [viewsWelcome contribution point](https://code.visualstudio.com/api/references/contribution-points#contributes.viewsWelcome). *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used.
129
+ - Support for [viewsWelcome contribution point](https://code.visualstudio.com/api/references/contribution-points#contributes.viewsWelcome). *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used
128
130
  - **Walkthrough**: `@codingame/monaco-vscode-walkthrough-service-override`
129
- - Getting Started page and support for [walkthrough contribution point](https://code.visualstudio.com/api/references/contribution-points#contributes.walkthroughs). *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used.
131
+ - Getting Started page and support for [walkthrough contribution point](https://code.visualstudio.com/api/references/contribution-points#contributes.walkthroughs). *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used
130
132
  - **User data profile**: `@codingame/monaco-vscode-user-data-profile-service-override`
131
133
  - User profiles support
132
134
  - **User data sync**: `@codingame/monaco-vscode-user-data-sync-service-override`
@@ -136,11 +138,11 @@ Additionally, several packages that include the VSCode version of some services
136
138
  - **Task**: `@codingame/monaco-vscode-task-service-override`
137
139
  - Task management
138
140
  - **Outline**: `@codingame/monaco-vscode-outline-service-override`
139
- - Support for the outline view. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used.
141
+ - Support for the outline view. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used
140
142
  - **Timeline**: `@codingame/monaco-vscode-timeline-service-override`
141
- - Support for the timeline view. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used.
143
+ - Support for the timeline view. *Hint*: It only makes sense to enable it when *Views* or *Workbench* service are used
142
144
  - **Workbench**: `@codingame/monaco-vscode-workbench-service-override`
143
- - Allows to render the full workbench layout. Is exclusive with the `views` service. Do not use both services at the same time.
145
+ - Allows to render the full workbench layout. Is exclusive with the `editor` and `views` service. Do not use more than 1 service at the same time
144
146
  - **Comments**
145
147
  - Enables comments extension api
146
148
  - **Edit-sessions**
@@ -148,7 +150,7 @@ Additionally, several packages that include the VSCode version of some services
148
150
  - **Emmet**
149
151
  - Enables the `triggerExpansionOnTab` command for the emmet default extension
150
152
  - **Interactive**
151
- - Interactive notbooks
153
+ - Interactive notebooks
152
154
  - **Issue**
153
155
  - Issue reporting
154
156
  - **Multi diff editor**
@@ -166,7 +168,7 @@ Additionally, several packages that include the VSCode version of some services
166
168
  - **Localization**
167
169
  - Register callbacks to update the display language from the VSCode UI (either from the `Set Display Language` command or from the extension gallery extension packs)
168
170
  - **Secret Storage**
169
- - Storage of secrets for extensions, will store by default in-memory. You can pass a custom implementation as part of the workbench construction options when initializing monaco services (under `secretStorageProvider`).
171
+ - Storage of secrets for extensions, will store by default in-memory. You can pass a custom implementation as part of the workbench construction options when initializing monaco services (under `secretStorageProvider`)
170
172
 
171
173
  Usage:
172
174
 
@@ -177,7 +179,7 @@ import getEditorServiceOverride from '@codingame/monaco-vscode-editor-service-ov
177
179
  import getConfigurationServiceOverride, { updateUserConfiguration, configurationRegistry } from '@codingame/monaco-vscode-configuration-service-override'
178
180
 
179
181
  await initialize({
180
- ...getModelEditorServiceOverride((model, input, sideBySide) => {
182
+ ...getEditorServiceOverride((model, input, sideBySide) => {
181
183
  // Open a new editor here and return it
182
184
  // It will be called when for instance the user ctrl+click on an import
183
185
  }),
@@ -209,7 +211,9 @@ It has some pros:
209
211
  - The returned model is bound to a filesystem file, and you have access to methods allowing to control the file lifecycle (saving the file, accessing the dirty state...)
210
212
  - It is possible to call the method multiple times on the same file to get multiple references. The model is disposed when there is no reference left
211
213
 
212
- The second argument of the method allows you to write the file content to the virtual filesystem in case the file wasn't registered in it beforehand.
214
+ To work, it needs the file to exist on the virtual filesystem. It can be achieved either by:
215
+ - using the `registerFileSystemOverlay` from the files service override, which can be cleaned when not needed anymore (recommended)
216
+ - by using the second argument of the `createModelReference` function, which writes the file content to the virtual filesystem before creating the model
213
217
 
214
218
  before:
215
219
 
@@ -229,8 +233,15 @@ after:
229
233
 
230
234
  ```typescript
231
235
  import * as monaco from 'monaco-editor'
236
+ import { RegisteredFileSystemProvider, RegisteredMemoryFile, registerFileSystemOverlay } from '@codingame/monaco-vscode-files-service-override'
232
237
 
233
- const modelRef = await monaco.editor.createModelReference(...)
238
+ const fileUri = monaco.Uri.file(<file uri>);
239
+
240
+ const fileSystemProvider = new RegisteredFileSystemProvider(false)
241
+ fileSystemProvider.registerFile(new RegisteredMemoryFile(fileUri, <file content>))
242
+ const overlayDisposable = registerFileSystemOverlay(1, fileSystemProvider)
243
+
244
+ const modelRef = await monaco.editor.createModelReference(fileUri)
234
245
 
235
246
  const editor = monaco.editor.create({ model: modelRef.object.textEditorModel })
236
247
 
@@ -242,16 +253,16 @@ await modelRef.object.save()
242
253
 
243
254
  modelRef.dispose()
244
255
  editor.dispose()
245
-
256
+ overlayDisposable.dispose()
246
257
 
247
258
  ```
248
259
 
249
- `createModelReference` return a reference to a model. The value is fetched from the memory filesystem (which is written if you provide the second argument).
260
+ `createModelReference` return a reference to a model. The value is fetched from the memory filesystem.
250
261
  The reference can then be disposed, the model will only be disposed if there is no remaining references.
251
262
 
252
263
  ## VSCode api usage
253
264
 
254
- To be able to use the VSCode api directly from your code, you need to import `vscode/localExtensionHost` and the services to be initialized.
265
+ To be able to use the VSCode api directly from your code, you need to import `vscode/localExtensionHost` and wait for the services to be initialized.
255
266
 
256
267
  You will then be able to import it as if you were in a VSCode extension:
257
268
 
@@ -291,7 +302,7 @@ vscode.languages.registerCompletionItemProvider(...)
291
302
 
292
303
  ### Default vscode extensions
293
304
 
294
- VSCode uses a bunch of default extensions. Most of them are used to load the default languages and grammars (see <ttps://github.com/microsoft/vscode/tree/main/extensions>).
305
+ 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>).
295
306
 
296
307
  This library bundles and publishes them and allows to import the ones you want:
297
308
 
@@ -301,6 +312,8 @@ import '@codingame/monaco-vscode-json-default-extension'
301
312
  ...
302
313
  ```
303
314
 
315
+ See [the full list](https://www.npmjs.com/search?q=%40codingame%2Fmonaco-vscode-*-default-extension)
316
+
304
317
  ### Loading vsix file
305
318
 
306
319
  VSCode extensions are bundled as vsix files.
@@ -342,18 +355,18 @@ This library also offers the possibility to localize vscode and the extensions i
342
355
  - `@codingame/monaco-vscode-language-pack-zh-hans`
343
356
  - `@codingame/monaco-vscode-language-pack-zh-hant`
344
357
 
345
- ⚠️ 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. ⚠️
358
+ ⚠️ The language pack should be imported and loaded BEFORE anything else from this library is loaded. Otherwise, some translations would be missing and an error would be displayed in the console. ⚠️
346
359
 
347
360
  ### Demo
348
361
 
349
362
  Try it out on <https://monaco-vscode-api.netlify.app/>
350
363
 
351
- There is a demo that showcases the service-override features. It allows to register contributions with the same syntaxes as in VSCode.
364
+ There is a demo that showcases the service-override features.
352
365
  It includes:
353
366
 
354
367
  - Languages
355
368
  - VSCode themes
356
- - Textmate grammars (requires vscode themes)
369
+ - Textmate grammars (requires VSCode themes)
357
370
  - Notifications/Dialogs
358
371
  - Model/Editor services
359
372
  - Configuration service, with user configuration editor
@@ -408,7 +421,7 @@ Here's the alternative for each options:
408
421
 
409
422
  - `filename`: it can be configured at the webpack level directly
410
423
  - `publicPath`: it can be configured at the webpack level or by hands when redistering the worker in `window.MonacoEnvironment`.
411
- - `languages`: Import vscode language extensions (`@codingame/monaco-vscode-xxx-default-extension`) or (`@codingame/@codingame/monaco-vscode-standalone-*`). Please obey: VSCode extensions can only be used if `themes` and `textmate` service overrides are configured and monaco languages can only be used if those two services are not configured (see [here](#monaco-standalone-services) for further details).
424
+ - `languages`: Import VSCode language extensions (`@codingame/monaco-vscode-xxx-default-extension`) or (`@codingame/@codingame/monaco-vscode-standalone-*`). Please obey: VSCode extensions can only be used if `themes` and `textmate` service overrides are configured and monaco languages can only be used if those two services are not configured (see [here](#monaco-standalone-services) for further details).
412
425
  - `features`: With this lib, you can't remove editor features.
413
426
  - `globalAPI`: you can set `window.MonacoEnvironment.globalAPI` to true
414
427
 
@@ -429,8 +442,8 @@ This library uses a lot the `new URL('asset.extension', import.meta.url)` syntax
429
442
 
430
443
  While it works great in `build` mode (because rollup is used), there is some issues in `watch` mode:
431
444
 
432
- - import.meta.url is not replaced while creating bundles, it is an issue when the syntax is used inside a dependency
433
- - vite is still trying to inject/transform javascript assets files, breaking the code by injecting ESM imports in commonjs files
445
+ - `import.meta.url` is not replaced while creating bundles, it is an issue when the syntax is used inside a dependency
446
+ - Vite is still trying to inject/transform javascript assets files, breaking the code by injecting ESM imports in commonjs files
434
447
 
435
448
  There are workarounds for both:
436
449
 
@@ -3238,7 +3238,7 @@ registerSingleton(ILanguageModelToolsService, class LanguageModelToolsService {
3238
3238
  this.onDidChangeTools = Event.None;
3239
3239
  this.registerToolData = unsupported;
3240
3240
  this.registerToolImplementation = unsupported;
3241
- this.getTools = unsupported;
3241
+ this.getTools = () => [];
3242
3242
  this.invokeTool = unsupported;
3243
3243
  }
3244
3244
  }, 1 );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-api",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "VSCode public API plugged on the monaco editor",
5
5
  "keywords": [],
6
6
  "author": {
@@ -99,12 +99,12 @@
99
99
  "dependencies": {
100
100
  "@vscode/iconv-lite-umd": "0.7.0",
101
101
  "jschardet": "3.1.2",
102
- "@codingame/monaco-vscode-extensions-service-override": "7.0.0",
103
- "@codingame/monaco-vscode-files-service-override": "7.0.0",
104
- "@codingame/monaco-vscode-quickaccess-service-override": "7.0.0",
105
- "@codingame/monaco-vscode-environment-service-override": "7.0.0",
106
- "@codingame/monaco-vscode-layout-service-override": "7.0.0",
107
- "@codingame/monaco-vscode-host-service-override": "7.0.0",
108
- "@codingame/monaco-vscode-base-service-override": "7.0.0"
102
+ "@codingame/monaco-vscode-extensions-service-override": "7.0.2",
103
+ "@codingame/monaco-vscode-files-service-override": "7.0.2",
104
+ "@codingame/monaco-vscode-quickaccess-service-override": "7.0.2",
105
+ "@codingame/monaco-vscode-environment-service-override": "7.0.2",
106
+ "@codingame/monaco-vscode-layout-service-override": "7.0.2",
107
+ "@codingame/monaco-vscode-host-service-override": "7.0.2",
108
+ "@codingame/monaco-vscode-base-service-override": "7.0.2"
109
109
  }
110
110
  }
@@ -10,7 +10,7 @@ if (typeof vscodeGlobal !== 'undefined' && typeof vscodeGlobal.process !== 'unde
10
10
  cwd() { return sandboxProcess.cwd(); }
11
11
  };
12
12
  }
13
- else if (typeof process !== 'undefined') {
13
+ else if (typeof process !== 'undefined' && typeof process?.versions?.node === 'string') {
14
14
  safeProcess = {
15
15
  get platform() { return process.platform; },
16
16
  get arch() { return process.arch; },