@theia/plugin-ext 1.46.0-next.181 → 1.46.0-next.200

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.
Files changed (60) hide show
  1. package/lib/common/plugin-protocol.d.ts +1 -0
  2. package/lib/common/plugin-protocol.d.ts.map +1 -1
  3. package/lib/common/plugin-protocol.js.map +1 -1
  4. package/lib/hosted/node/hosted-plugin-deployer-handler.d.ts +1 -0
  5. package/lib/hosted/node/hosted-plugin-deployer-handler.d.ts.map +1 -1
  6. package/lib/hosted/node/hosted-plugin-deployer-handler.js +5 -0
  7. package/lib/hosted/node/hosted-plugin-deployer-handler.js.map +1 -1
  8. package/lib/main/browser/notebooks/notebook-documents-main.d.ts +3 -1
  9. package/lib/main/browser/notebooks/notebook-documents-main.d.ts.map +1 -1
  10. package/lib/main/browser/notebooks/notebook-documents-main.js +7 -5
  11. package/lib/main/browser/notebooks/notebook-documents-main.js.map +1 -1
  12. package/lib/main/browser/notebooks/notebook-editors-main.d.ts +4 -3
  13. package/lib/main/browser/notebooks/notebook-editors-main.d.ts.map +1 -1
  14. package/lib/main/browser/notebooks/notebook-editors-main.js +8 -3
  15. package/lib/main/browser/notebooks/notebook-editors-main.js.map +1 -1
  16. package/lib/main/browser/notebooks/notebooks-main.js +1 -1
  17. package/lib/main/browser/notebooks/notebooks-main.js.map +1 -1
  18. package/lib/main/node/plugin-ext-backend-module.d.ts.map +1 -1
  19. package/lib/main/node/plugin-ext-backend-module.js +8 -0
  20. package/lib/main/node/plugin-ext-backend-module.js.map +1 -1
  21. package/lib/main/node/plugin-remote-cli-contribution.d.ts +8 -0
  22. package/lib/main/node/plugin-remote-cli-contribution.d.ts.map +1 -0
  23. package/lib/main/node/plugin-remote-cli-contribution.js +41 -0
  24. package/lib/main/node/plugin-remote-cli-contribution.js.map +1 -0
  25. package/lib/main/node/plugin-remote-copy-contribution.d.ts +7 -0
  26. package/lib/main/node/plugin-remote-copy-contribution.d.ts.map +1 -0
  27. package/lib/main/node/plugin-remote-copy-contribution.js +40 -0
  28. package/lib/main/node/plugin-remote-copy-contribution.js.map +1 -0
  29. package/lib/main/node/plugin-service.d.ts +1 -1
  30. package/lib/main/node/plugin-service.d.ts.map +1 -1
  31. package/lib/main/node/plugin-service.js +1 -1
  32. package/lib/main/node/plugin-service.js.map +1 -1
  33. package/lib/plugin/editors-and-documents.d.ts +1 -0
  34. package/lib/plugin/editors-and-documents.d.ts.map +1 -1
  35. package/lib/plugin/editors-and-documents.js +3 -0
  36. package/lib/plugin/editors-and-documents.js.map +1 -1
  37. package/lib/plugin/notebook/notebook-document.d.ts.map +1 -1
  38. package/lib/plugin/notebook/notebook-document.js +10 -3
  39. package/lib/plugin/notebook/notebook-document.js.map +1 -1
  40. package/lib/plugin/notebook/notebooks.d.ts +1 -0
  41. package/lib/plugin/notebook/notebooks.d.ts.map +1 -1
  42. package/lib/plugin/notebook/notebooks.js +34 -12
  43. package/lib/plugin/notebook/notebooks.js.map +1 -1
  44. package/lib/plugin/plugin-context.d.ts.map +1 -1
  45. package/lib/plugin/plugin-context.js +7 -0
  46. package/lib/plugin/plugin-context.js.map +1 -1
  47. package/package.json +28 -28
  48. package/src/common/plugin-protocol.ts +1 -0
  49. package/src/hosted/node/hosted-plugin-deployer-handler.ts +6 -0
  50. package/src/main/browser/notebooks/notebook-documents-main.ts +9 -7
  51. package/src/main/browser/notebooks/notebook-editors-main.ts +11 -6
  52. package/src/main/browser/notebooks/notebooks-main.ts +1 -1
  53. package/src/main/node/plugin-ext-backend-module.ts +9 -0
  54. package/src/main/node/plugin-remote-cli-contribution.ts +36 -0
  55. package/src/main/node/plugin-remote-copy-contribution.ts +36 -0
  56. package/src/main/node/plugin-service.ts +1 -1
  57. package/src/plugin/editors-and-documents.ts +4 -0
  58. package/src/plugin/notebook/notebook-document.ts +13 -3
  59. package/src/plugin/notebook/notebooks.ts +37 -14
  60. package/src/plugin/plugin-context.ts +8 -0
package/package.json CHANGED
@@ -1,37 +1,37 @@
1
1
  {
2
2
  "name": "@theia/plugin-ext",
3
- "version": "1.46.0-next.181+b20a75135",
3
+ "version": "1.46.0-next.200+44b4f27c6",
4
4
  "description": "Theia - Plugin Extension",
5
5
  "main": "lib/common/index.js",
6
6
  "typings": "lib/common/index.d.ts",
7
7
  "dependencies": {
8
- "@theia/bulk-edit": "1.46.0-next.181+b20a75135",
9
- "@theia/callhierarchy": "1.46.0-next.181+b20a75135",
10
- "@theia/console": "1.46.0-next.181+b20a75135",
11
- "@theia/core": "1.46.0-next.181+b20a75135",
12
- "@theia/debug": "1.46.0-next.181+b20a75135",
13
- "@theia/editor": "1.46.0-next.181+b20a75135",
14
- "@theia/editor-preview": "1.46.0-next.181+b20a75135",
15
- "@theia/file-search": "1.46.0-next.181+b20a75135",
16
- "@theia/filesystem": "1.46.0-next.181+b20a75135",
17
- "@theia/markers": "1.46.0-next.181+b20a75135",
18
- "@theia/messages": "1.46.0-next.181+b20a75135",
19
- "@theia/monaco": "1.46.0-next.181+b20a75135",
8
+ "@theia/bulk-edit": "1.46.0-next.200+44b4f27c6",
9
+ "@theia/callhierarchy": "1.46.0-next.200+44b4f27c6",
10
+ "@theia/console": "1.46.0-next.200+44b4f27c6",
11
+ "@theia/core": "1.46.0-next.200+44b4f27c6",
12
+ "@theia/debug": "1.46.0-next.200+44b4f27c6",
13
+ "@theia/editor": "1.46.0-next.200+44b4f27c6",
14
+ "@theia/editor-preview": "1.46.0-next.200+44b4f27c6",
15
+ "@theia/file-search": "1.46.0-next.200+44b4f27c6",
16
+ "@theia/filesystem": "1.46.0-next.200+44b4f27c6",
17
+ "@theia/markers": "1.46.0-next.200+44b4f27c6",
18
+ "@theia/messages": "1.46.0-next.200+44b4f27c6",
19
+ "@theia/monaco": "1.46.0-next.200+44b4f27c6",
20
20
  "@theia/monaco-editor-core": "1.83.101",
21
- "@theia/navigator": "1.46.0-next.181+b20a75135",
22
- "@theia/notebook": "1.46.0-next.181+b20a75135",
23
- "@theia/output": "1.46.0-next.181+b20a75135",
24
- "@theia/plugin": "1.46.0-next.181+b20a75135",
25
- "@theia/preferences": "1.46.0-next.181+b20a75135",
26
- "@theia/scm": "1.46.0-next.181+b20a75135",
27
- "@theia/search-in-workspace": "1.46.0-next.181+b20a75135",
28
- "@theia/task": "1.46.0-next.181+b20a75135",
29
- "@theia/terminal": "1.46.0-next.181+b20a75135",
30
- "@theia/test": "1.46.0-next.181+b20a75135",
31
- "@theia/timeline": "1.46.0-next.181+b20a75135",
32
- "@theia/typehierarchy": "1.46.0-next.181+b20a75135",
33
- "@theia/variable-resolver": "1.46.0-next.181+b20a75135",
34
- "@theia/workspace": "1.46.0-next.181+b20a75135",
21
+ "@theia/navigator": "1.46.0-next.200+44b4f27c6",
22
+ "@theia/notebook": "1.46.0-next.200+44b4f27c6",
23
+ "@theia/output": "1.46.0-next.200+44b4f27c6",
24
+ "@theia/plugin": "1.46.0-next.200+44b4f27c6",
25
+ "@theia/preferences": "1.46.0-next.200+44b4f27c6",
26
+ "@theia/scm": "1.46.0-next.200+44b4f27c6",
27
+ "@theia/search-in-workspace": "1.46.0-next.200+44b4f27c6",
28
+ "@theia/task": "1.46.0-next.200+44b4f27c6",
29
+ "@theia/terminal": "1.46.0-next.200+44b4f27c6",
30
+ "@theia/test": "1.46.0-next.200+44b4f27c6",
31
+ "@theia/timeline": "1.46.0-next.200+44b4f27c6",
32
+ "@theia/typehierarchy": "1.46.0-next.200+44b4f27c6",
33
+ "@theia/variable-resolver": "1.46.0-next.200+44b4f27c6",
34
+ "@theia/workspace": "1.46.0-next.200+44b4f27c6",
35
35
  "@types/mime": "^2.0.1",
36
36
  "@vscode/debugprotocol": "^1.51.0",
37
37
  "@vscode/proxy-agent": "^0.13.2",
@@ -97,5 +97,5 @@
97
97
  "nyc": {
98
98
  "extends": "../../configs/nyc.json"
99
99
  },
100
- "gitHead": "b20a7513502fada4045b375f068152a7235e6c05"
100
+ "gitHead": "44b4f27c63028c1bdc7dcd9b565d666428af6f97"
101
101
  }
@@ -984,6 +984,7 @@ export interface PluginDeployerHandler {
984
984
  deployFrontendPlugins(frontendPlugins: PluginDeployerEntry[]): Promise<number | undefined>;
985
985
  deployBackendPlugins(backendPlugins: PluginDeployerEntry[]): Promise<number | undefined>;
986
986
 
987
+ getDeployedPlugins(): Promise<DeployedPlugin[]>;
987
988
  getDeployedPluginsById(pluginId: string): DeployedPlugin[];
988
989
 
989
990
  getDeployedPlugin(pluginId: PluginIdentifiers.VersionedId): DeployedPlugin | undefined;
@@ -83,6 +83,12 @@ export class HostedPluginDeployerHandler implements PluginDeployerHandler {
83
83
  return Array.from(this.deployedBackendPlugins.values());
84
84
  }
85
85
 
86
+ async getDeployedPlugins(): Promise<DeployedPlugin[]> {
87
+ await this.frontendPluginsMetadataDeferred.promise;
88
+ await this.backendPluginsMetadataDeferred.promise;
89
+ return [...this.deployedFrontendPlugins.values(), ...this.deployedBackendPlugins.values()];
90
+ }
91
+
86
92
  getDeployedPluginsById(pluginId: string): DeployedPlugin[] {
87
93
  const matches: DeployedPlugin[] = [];
88
94
  const handle = (plugins: Iterable<DeployedPlugin>): void => {
@@ -25,6 +25,7 @@ import { MAIN_RPC_CONTEXT, NotebookCellsChangedEventDto, NotebookDataDto, Notebo
25
25
  import { RPCProtocol } from '../../../common/rpc-protocol';
26
26
  import { NotebookDto } from './notebook-dto';
27
27
  import { MonacoEditorModel } from '@theia/monaco/lib/browser/monaco-editor-model';
28
+ import { NotebookOpenHandler } from '@theia/notebook/lib/browser/notebook-open-handler';
28
29
 
29
30
  export class NotebookDocumentsMainImpl implements NotebookDocumentsMain {
30
31
 
@@ -35,7 +36,8 @@ export class NotebookDocumentsMainImpl implements NotebookDocumentsMain {
35
36
 
36
37
  protected readonly notebookModelResolverService: NotebookModelResolverService;
37
38
 
38
- protected notebookMonacoTextModelService: NotebookMonacoTextModelService;
39
+ protected readonly notebookMonacoTextModelService: NotebookMonacoTextModelService;
40
+ protected readonly notebookOpenHandler: NotebookOpenHandler;
39
41
 
40
42
  constructor(
41
43
  rpc: RPCProtocol,
@@ -43,6 +45,7 @@ export class NotebookDocumentsMainImpl implements NotebookDocumentsMain {
43
45
  ) {
44
46
  this.proxy = rpc.getProxy(MAIN_RPC_CONTEXT.NOTEBOOK_DOCUMENTS_EXT);
45
47
  this.notebookModelResolverService = container.get(NotebookModelResolverService);
48
+ this.notebookOpenHandler = container.get(NotebookOpenHandler);
46
49
 
47
50
  // forward dirty and save events
48
51
  this.disposables.push(this.notebookModelResolverService.onDidChangeDirty(model => this.proxy.$acceptDirtyStateChanged(model.uri.toComponents(), model.isDirty())));
@@ -157,10 +160,10 @@ export class NotebookDocumentsMainImpl implements NotebookDocumentsMain {
157
160
  this.proxy.$acceptDirtyStateChanged(ref.uri.toComponents(), true);
158
161
 
159
162
  // apply content changes... slightly HACKY -> this triggers a change event
160
- // if (options.content) {
161
- // const data = NotebookDto.fromNotebookDataDto(options.content);
162
- // ref.notebook.reset(data.cells, data.metadata, ref.object.notebook.transientOptions);
163
- // }
163
+ if (options.content) {
164
+ const data = NotebookDto.fromNotebookDataDto(options.content);
165
+ ref.setData(data);
166
+ }
164
167
  return ref.uri.toComponents();
165
168
  }
166
169
 
@@ -171,9 +174,8 @@ export class NotebookDocumentsMainImpl implements NotebookDocumentsMain {
171
174
 
172
175
  async $trySaveNotebook(uriComponents: UriComponents): Promise<boolean> {
173
176
  const uri = URI.fromComponents(uriComponents);
174
-
175
177
  const ref = await this.notebookModelResolverService.resolve(uri);
176
- await ref.save({});
178
+ await ref.save();
177
179
  ref.dispose();
178
180
  return true;
179
181
  }
@@ -20,16 +20,17 @@
20
20
 
21
21
  import { UriComponents, URI } from '@theia/core/lib/common/uri';
22
22
  import { CellRange } from '@theia/notebook/lib/common';
23
- import { NotebookEditorWidget } from '@theia/notebook/lib/browser';
23
+ import { NotebookEditorWidget, NotebookService } from '@theia/notebook/lib/browser';
24
24
  import { MAIN_RPC_CONTEXT, NotebookDocumentShowOptions, NotebookEditorRevealType, NotebookEditorsExt, NotebookEditorsMain } from '../../../common';
25
25
  import { RPCProtocol } from '../../../common/rpc-protocol';
26
26
  import { interfaces } from '@theia/core/shared/inversify';
27
- import { open, OpenerService } from '@theia/core/lib/browser';
27
+ import { NotebookOpenHandler } from '@theia/notebook/lib/browser/notebook-open-handler';
28
28
 
29
29
  export class NotebookEditorsMainImpl implements NotebookEditorsMain {
30
30
 
31
31
  protected readonly proxy: NotebookEditorsExt;
32
- protected readonly openerService: OpenerService;
32
+ protected readonly notebookService: NotebookService;
33
+ protected readonly notebookOpenHandler: NotebookOpenHandler;
33
34
 
34
35
  protected readonly mainThreadEditors = new Map<string, NotebookEditorWidget>();
35
36
 
@@ -38,12 +39,16 @@ export class NotebookEditorsMainImpl implements NotebookEditorsMain {
38
39
  container: interfaces.Container
39
40
  ) {
40
41
  this.proxy = rpc.getProxy(MAIN_RPC_CONTEXT.NOTEBOOK_EDITORS_EXT);
41
- this.openerService = container.get(OpenerService);
42
+ this.notebookService = container.get(NotebookService);
43
+ this.notebookOpenHandler = container.get(NotebookOpenHandler);
42
44
  }
43
45
 
44
46
  async $tryShowNotebookDocument(uriComponents: UriComponents, viewType: string, options: NotebookDocumentShowOptions): Promise<string> {
45
- const editor = await open(this.openerService, URI.fromComponents(uriComponents), {});
46
- return (editor as NotebookEditorWidget).id;
47
+ const editor = await this.notebookOpenHandler.open(URI.fromComponents(uriComponents), {
48
+ notebookType: viewType
49
+ });
50
+ await editor.ready;
51
+ return editor.id;
47
52
  }
48
53
  $tryRevealRange(id: string, range: CellRange, revealType: NotebookEditorRevealType): Promise<void> {
49
54
  throw new Error('Method not implemented.');
@@ -58,7 +58,7 @@ export class NotebooksMainImpl implements NotebooksMain {
58
58
  const plugins = container.get(HostedPluginSupport);
59
59
 
60
60
  this.proxy = rpc.getProxy(MAIN_RPC_CONTEXT.NOTEBOOKS_EXT);
61
- this.notebookService.onWillUseNotebookSerializer(async event => plugins.activateByNotebookSerializer(event));
61
+ this.notebookService.onWillUseNotebookSerializer(event => plugins.activateByNotebookSerializer(event));
62
62
  this.notebookService.markReady();
63
63
  commands.registerArgumentProcessor({
64
64
  processArgument: arg => {
@@ -42,6 +42,10 @@ import { PluginUninstallationManager } from './plugin-uninstallation-manager';
42
42
  import { LocalizationServerImpl } from '@theia/core/lib/node/i18n/localization-server';
43
43
  import { PluginLocalizationServer } from './plugin-localization-server';
44
44
  import { PluginMgmtCliContribution } from './plugin-mgmt-cli-contribution';
45
+ import { PluginRemoteCliContribution } from './plugin-remote-cli-contribution';
46
+ import { RemoteCliContribution } from '@theia/core/lib/node/remote/remote-cli-contribution';
47
+ import { PluginRemoteCopyContribution } from './plugin-remote-copy-contribution';
48
+ import { RemoteCopyContribution } from '@theia/core/lib/node/remote/remote-copy-contribution';
45
49
 
46
50
  export function bindMainBackend(bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind): void {
47
51
  bind(PluginApiContribution).toSelf().inSingletonScope();
@@ -89,6 +93,11 @@ export function bindMainBackend(bind: interfaces.Bind, unbind: interfaces.Unbind
89
93
  bind(PluginMgmtCliContribution).toSelf().inSingletonScope();
90
94
  bind(CliContribution).toService(PluginMgmtCliContribution);
91
95
 
96
+ bind(PluginRemoteCliContribution).toSelf().inSingletonScope();
97
+ bind(RemoteCliContribution).toService(PluginRemoteCliContribution);
98
+ bind(PluginRemoteCopyContribution).toSelf().inSingletonScope();
99
+ bind(RemoteCopyContribution).toService(PluginRemoteCopyContribution);
100
+
92
101
  bind(WebviewBackendSecurityWarnings).toSelf().inSingletonScope();
93
102
  bind(BackendApplicationContribution).toService(WebviewBackendSecurityWarnings);
94
103
 
@@ -0,0 +1,36 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { MaybePromise } from '@theia/core';
18
+ import { RemoteCliContext, RemoteCliContribution } from '@theia/core/lib/node/remote/remote-cli-contribution';
19
+ import { inject, injectable } from '@theia/core/shared/inversify';
20
+ import { PluginCliContribution } from './plugin-cli-contribution';
21
+
22
+ @injectable()
23
+ export class PluginRemoteCliContribution implements RemoteCliContribution {
24
+
25
+ @inject(PluginCliContribution)
26
+ protected readonly pluginCliContribution: PluginCliContribution;
27
+
28
+ enhanceArgs(context: RemoteCliContext): MaybePromise<string[]> {
29
+ const pluginsFolder = this.pluginCliContribution.localDir();
30
+ if (!pluginsFolder) {
31
+ return [];
32
+ } else {
33
+ return ['--plugins=local-dir:./plugins'];
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,36 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { RemoteCopyContribution, RemoteCopyRegistry } from '@theia/core/lib/node/remote/remote-copy-contribution';
18
+ import { inject, injectable } from '@theia/core/shared/inversify';
19
+ import { PluginCliContribution } from './plugin-cli-contribution';
20
+ import { FileUri } from '@theia/core/lib/common/file-uri';
21
+
22
+ @injectable()
23
+ export class PluginRemoteCopyContribution implements RemoteCopyContribution {
24
+
25
+ @inject(PluginCliContribution)
26
+ protected readonly pluginCliContribution: PluginCliContribution;
27
+
28
+ async copy(registry: RemoteCopyRegistry): Promise<void> {
29
+ const localDir = this.pluginCliContribution.localDir();
30
+ if (localDir) {
31
+ const fsPath = FileUri.fsPath(localDir);
32
+ await registry.directory(fsPath, 'plugins');
33
+ }
34
+
35
+ }
36
+ }
@@ -26,7 +26,7 @@ import { environment } from '@theia/core/shared/@theia/application-package/lib/e
26
26
  import { WsRequestValidatorContribution } from '@theia/core/lib/node/ws-request-validators';
27
27
  import { MaybePromise } from '@theia/core/lib/common';
28
28
  import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
29
- import { BackendRemoteService } from '@theia/core/lib/node/backend-remote-service';
29
+ import { BackendRemoteService } from '@theia/core/lib/node/remote/backend-remote-service';
30
30
 
31
31
  @injectable()
32
32
  export class PluginApiContribution implements BackendApplicationContribution, WsRequestValidatorContribution {
@@ -46,6 +46,10 @@ export class EditorsAndDocumentsExtImpl implements EditorsAndDocumentsExt {
46
46
  private readonly editors = new Map<string, TextEditorExt>();
47
47
 
48
48
  async $acceptEditorsAndDocumentsDelta(delta: EditorsAndDocumentsDelta): Promise<void> {
49
+ this.acceptEditorsAndDocumentsDelta(delta);
50
+ }
51
+
52
+ acceptEditorsAndDocumentsDelta(delta: EditorsAndDocumentsDelta): void {
49
53
  const removedDocuments = new Array<DocumentDataExt>();
50
54
  const addedDocuments = new Array<DocumentDataExt>();
51
55
  const removedEditors = new Array<TextEditorExt>();
@@ -27,6 +27,7 @@ import * as typeConverters from '../type-converters';
27
27
  import { ModelAddedData, NotebookCellDto, NotebookCellsChangedEventDto, NotebookModelAddedData, NotebookOutputDto } from '../../common';
28
28
  import { NotebookRange } from '../types-impl';
29
29
  import { DocumentsExtImpl } from '../documents';
30
+ import { UriComponents } from '../../common/uri-components';
30
31
 
31
32
  class RawContentChangeEvent {
32
33
 
@@ -345,6 +346,9 @@ export class NotebookDocument implements Disposable {
345
346
  return;
346
347
  }
347
348
 
349
+ const addedDocuments: ModelAddedData[] = [];
350
+ const removedDocuments: UriComponents[] = [];
351
+
348
352
  const contentChangeEvents: RawContentChangeEvent[] = [];
349
353
 
350
354
  splices.reverse().forEach(splice => {
@@ -353,9 +357,7 @@ export class NotebookDocument implements Disposable {
353
357
 
354
358
  const extCell = new Cell(this, this.editorsAndDocuments, cell);
355
359
  if (!initialization) {
356
- this.editorsAndDocuments.$acceptEditorsAndDocumentsDelta({
357
- addedDocuments: [Cell.asModelAddData(cell)]
358
- });
360
+ addedDocuments.push(Cell.asModelAddData(cell));
359
361
  }
360
362
  return extCell;
361
363
  });
@@ -364,10 +366,18 @@ export class NotebookDocument implements Disposable {
364
366
  const deletedItems = this.cells.splice(splice.start, splice.deleteCount, ...newCells);
365
367
  for (const cell of deletedItems) {
366
368
  changeEvent.deletedItems.push(cell.apiCell);
369
+ removedDocuments.push(cell.uri.toComponents());
367
370
  }
368
371
  contentChangeEvents.push(changeEvent);
369
372
  });
370
373
 
374
+ if (addedDocuments.length > 0 || removedDocuments.length > 0) {
375
+ this.editorsAndDocuments.acceptEditorsAndDocumentsDelta({
376
+ addedDocuments,
377
+ removedDocuments
378
+ });
379
+ }
380
+
371
381
  if (bucket) {
372
382
  for (const changeEvent of contentChangeEvents) {
373
383
  bucket.push(changeEvent.asApiEvent());
@@ -22,7 +22,7 @@ import { CancellationToken, Disposable, DisposableCollection, Emitter, Event, UR
22
22
  import { URI as TheiaURI } from '../types-impl';
23
23
  import * as theia from '@theia/plugin';
24
24
  import {
25
- CommandRegistryExt, ModelAddedData, NotebookCellStatusBarListDto, NotebookDataDto,
25
+ CommandRegistryExt, NotebookCellStatusBarListDto, NotebookDataDto,
26
26
  NotebookDocumentsAndEditorsDelta, NotebookDocumentShowOptions, NotebookDocumentsMain, NotebookEditorAddData, NotebookEditorsMain, NotebooksExt, NotebooksMain, Plugin,
27
27
  PLUGIN_RPC_CONTEXT
28
28
  } from '../../common';
@@ -205,7 +205,6 @@ export class NotebooksExtImpl implements NotebooksExt {
205
205
 
206
206
  async $acceptDocumentsAndEditorsDelta(delta: NotebookDocumentsAndEditorsDelta): Promise<void> {
207
207
  const removedCellDocuments: UriComponents[] = [];
208
- const addedCellDocuments: ModelAddedData[] = [];
209
208
  if (delta.removedDocuments) {
210
209
  for (const uri of delta.removedDocuments) {
211
210
  const revivedUri = URI.fromComponents(uri);
@@ -226,10 +225,12 @@ export class NotebooksExtImpl implements NotebooksExt {
226
225
  }
227
226
  }
228
227
 
229
- // publish all removed cell documents first
230
- await this.textDocumentsAndEditors.$acceptEditorsAndDocumentsDelta({
231
- removedDocuments: removedCellDocuments
232
- });
228
+ if (removedCellDocuments.length > 0) {
229
+ // publish all removed cell documents first
230
+ this.textDocumentsAndEditors.acceptEditorsAndDocumentsDelta({
231
+ removedDocuments: removedCellDocuments
232
+ });
233
+ }
233
234
 
234
235
  if (delta.addedDocuments) {
235
236
  for (const modelData of delta.addedDocuments) {
@@ -250,17 +251,18 @@ export class NotebooksExtImpl implements NotebooksExt {
250
251
  this.documents.get(uri.toString())?.dispose();
251
252
  this.documents.set(uri.toString(), document);
252
253
 
253
- addedCellDocuments.push(...modelData.cells.map(cell => Cell.asModelAddData(cell)));
254
+ if (modelData.cells.length > 0) {
255
+ // Publish new cell documents before calling the notebook document open event
256
+ // During this event, extensions might request the cell document and we want to make sure it is available
257
+ this.textDocumentsAndEditors.acceptEditorsAndDocumentsDelta({
258
+ addedDocuments: modelData.cells.map(cell => Cell.asModelAddData(cell))
259
+ });
260
+ }
254
261
 
255
262
  this.onDidOpenNotebookDocumentEmitter.fire(document.apiNotebook);
256
263
  }
257
264
  }
258
265
 
259
- // publish all added cell documents in a separate call
260
- await this.textDocumentsAndEditors.$acceptEditorsAndDocumentsDelta({
261
- addedDocuments: addedCellDocuments
262
- });
263
-
264
266
  if (delta.addedEditors) {
265
267
  for (const editorModelData of delta.addedEditors) {
266
268
  if (this.editors.has(editorModelData.id)) {
@@ -370,6 +372,27 @@ export class NotebooksExtImpl implements NotebooksExt {
370
372
  this.editors.set(editorId, editor);
371
373
  }
372
374
 
375
+ private waitForNotebookEditor(editorId: string, duration = 2000): Promise<theia.NotebookEditor> {
376
+ const existing = this.editors.get(editorId);
377
+ if (existing) {
378
+ return Promise.resolve(existing.apiEditor);
379
+ }
380
+ return new Promise<theia.NotebookEditor>((resolve, reject) => {
381
+ const listener = this.onDidChangeVisibleNotebookEditors(() => {
382
+ const editor = this.editors.get(editorId);
383
+ if (editor) {
384
+ clearTimeout(timeout);
385
+ listener.dispose();
386
+ resolve(editor.apiEditor);
387
+ }
388
+ });
389
+ const timeout = setTimeout(() => {
390
+ listener.dispose();
391
+ reject(new Error(`Notebook editor did NOT open in ${duration}ms: ${editorId}`));
392
+ }, duration);
393
+ });
394
+ }
395
+
373
396
  async createNotebookDocument(options: { viewType: string; content?: theia.NotebookData }): Promise<TheiaURI> {
374
397
  const canonicalUri = await this.notebookDocumentsProxy.$tryCreateNotebook({
375
398
  viewType: options.viewType,
@@ -393,7 +416,7 @@ export class NotebooksExtImpl implements NotebooksExt {
393
416
  notebookOrUri = await this.openNotebookDocument(notebookOrUri as TheiaURI);
394
417
  }
395
418
 
396
- const notebook = notebookOrUri as theia.NotebookDocument;
419
+ const notebook = notebookOrUri;
397
420
 
398
421
  let resolvedOptions: NotebookDocumentShowOptions;
399
422
  if (typeof options === 'object') {
@@ -410,7 +433,7 @@ export class NotebooksExtImpl implements NotebooksExt {
410
433
  }
411
434
 
412
435
  const editorId = await this.notebookEditors.$tryShowNotebookDocument(notebook.uri, notebook.notebookType, resolvedOptions);
413
- const editor = editorId && this.editors.get(editorId)?.apiEditor;
436
+ const editor = editorId && await this.waitForNotebookEditor(editorId);
414
437
 
415
438
  if (editor) {
416
439
  return editor;
@@ -1218,9 +1218,17 @@ export function createAPIFactory(
1218
1218
  }
1219
1219
  };
1220
1220
 
1221
+ const chat: typeof theia.chat = {
1222
+ /** @stubbed MappedEditsProvider */
1223
+ registerMappedEditsProvider(documentSelector: theia.DocumentSelector, provider: theia.MappedEditsProvider): Disposable {
1224
+ return Disposable.NULL;
1225
+ }
1226
+ };
1227
+
1221
1228
  return <typeof theia>{
1222
1229
  version: require('../../package.json').version,
1223
1230
  authentication,
1231
+ chat,
1224
1232
  commands,
1225
1233
  comments,
1226
1234
  window,