@codingame/monaco-vscode-extensions-service-override 4.1.0 → 4.1.1

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 (109) hide show
  1. package/_virtual/semver.js +3 -0
  2. package/extensions.js +6 -6
  3. package/external/vscode-semver/semver.js +985 -0
  4. package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +8 -0
  5. package/package.json +9 -9
  6. package/vscode/src/vs/base/common/console.js +62 -0
  7. package/vscode/src/vs/platform/extensionManagement/common/extensionManagementCLI.js +497 -0
  8. package/vscode/src/vs/platform/extensionResourceLoader/browser/extensionResourceLoaderService.js +44 -0
  9. package/vscode/src/vs/platform/lifecycle/common/lifecycle.js +27 -0
  10. package/vscode/src/vs/platform/remote/common/managedSocket.js +98 -0
  11. package/vscode/src/vs/workbench/api/browser/extensionHost.contribution.js +104 -0
  12. package/vscode/src/vs/workbench/api/browser/mainThreadAiEmbeddingVector.js +31 -0
  13. package/vscode/src/vs/workbench/api/browser/mainThreadAiRelatedInformation.js +35 -0
  14. package/vscode/src/vs/workbench/api/browser/mainThreadAuthentication.js +254 -0
  15. package/vscode/src/vs/workbench/api/browser/mainThreadBulkEdits.js +68 -0
  16. package/vscode/src/vs/workbench/api/browser/mainThreadCLICommands.js +103 -0
  17. package/vscode/src/vs/workbench/api/browser/mainThreadChat.js +70 -0
  18. package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents2.js +207 -0
  19. package/vscode/src/vs/workbench/api/browser/mainThreadChatVariables.js +41 -0
  20. package/vscode/src/vs/workbench/api/browser/mainThreadClipboard.js +24 -0
  21. package/vscode/src/vs/workbench/api/browser/mainThreadCodeInsets.js +108 -0
  22. package/vscode/src/vs/workbench/api/browser/mainThreadCommands.js +98 -0
  23. package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +560 -0
  24. package/vscode/src/vs/workbench/api/browser/mainThreadConfiguration.js +80 -0
  25. package/vscode/src/vs/workbench/api/browser/mainThreadConsole.js +35 -0
  26. package/vscode/src/vs/workbench/api/browser/mainThreadCustomEditors.js +579 -0
  27. package/vscode/src/vs/workbench/api/browser/mainThreadDebugService.js +435 -0
  28. package/vscode/src/vs/workbench/api/browser/mainThreadDecorations.js +102 -0
  29. package/vscode/src/vs/workbench/api/browser/mainThreadDiagnostics.js +69 -0
  30. package/vscode/src/vs/workbench/api/browser/mainThreadDialogs.js +68 -0
  31. package/vscode/src/vs/workbench/api/browser/mainThreadDocumentContentProviders.js +79 -0
  32. package/vscode/src/vs/workbench/api/browser/mainThreadDocuments.js +253 -0
  33. package/vscode/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.js +370 -0
  34. package/vscode/src/vs/workbench/api/browser/mainThreadDownloadService.js +22 -0
  35. package/vscode/src/vs/workbench/api/browser/mainThreadEditSessionIdentityParticipant.js +41 -0
  36. package/vscode/src/vs/workbench/api/browser/mainThreadEditor.js +414 -0
  37. package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +501 -0
  38. package/vscode/src/vs/workbench/api/browser/mainThreadEditors.js +227 -0
  39. package/vscode/src/vs/workbench/api/browser/mainThreadErrors.js +24 -0
  40. package/vscode/src/vs/workbench/api/browser/mainThreadExtensionService.js +317 -0
  41. package/vscode/src/vs/workbench/api/browser/mainThreadFileSystem.js +208 -0
  42. package/vscode/src/vs/workbench/api/browser/mainThreadFileSystemEventService.js +369 -0
  43. package/vscode/src/vs/workbench/api/browser/mainThreadInlineChat.js +72 -0
  44. package/vscode/src/vs/workbench/api/browser/mainThreadInteractive.js +28 -0
  45. package/vscode/src/vs/workbench/api/browser/mainThreadIssueReporter.js +50 -0
  46. package/vscode/src/vs/workbench/api/browser/mainThreadLabelService.js +27 -0
  47. package/vscode/src/vs/workbench/api/browser/mainThreadLanguageFeatures.js +1016 -0
  48. package/vscode/src/vs/workbench/api/browser/mainThreadLanguageModels.js +185 -0
  49. package/vscode/src/vs/workbench/api/browser/mainThreadLanguages.js +78 -0
  50. package/vscode/src/vs/workbench/api/browser/mainThreadLocalization.js +35 -0
  51. package/vscode/src/vs/workbench/api/browser/mainThreadLogService.js +78 -0
  52. package/vscode/src/vs/workbench/api/browser/mainThreadManagedSockets.js +93 -0
  53. package/vscode/src/vs/workbench/api/browser/mainThreadMessageService.js +137 -0
  54. package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +194 -0
  55. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.js +123 -0
  56. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.js +188 -0
  57. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDto.js +129 -0
  58. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.js +131 -0
  59. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +374 -0
  60. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.js +25 -0
  61. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +48 -0
  62. package/vscode/src/vs/workbench/api/browser/mainThreadOutputService.js +76 -0
  63. package/vscode/src/vs/workbench/api/browser/mainThreadProfileContentHandlers.js +38 -0
  64. package/vscode/src/vs/workbench/api/browser/mainThreadProgress.js +68 -0
  65. package/vscode/src/vs/workbench/api/browser/mainThreadQuickDiff.js +42 -0
  66. package/vscode/src/vs/workbench/api/browser/mainThreadQuickOpen.js +185 -0
  67. package/vscode/src/vs/workbench/api/browser/mainThreadRemoteConnectionData.js +30 -0
  68. package/vscode/src/vs/workbench/api/browser/mainThreadSCM.js +493 -0
  69. package/vscode/src/vs/workbench/api/browser/mainThreadSaveParticipant.js +49 -0
  70. package/vscode/src/vs/workbench/api/browser/mainThreadSearch.js +168 -0
  71. package/vscode/src/vs/workbench/api/browser/mainThreadSecretState.js +70 -0
  72. package/vscode/src/vs/workbench/api/browser/mainThreadShare.js +50 -0
  73. package/vscode/src/vs/workbench/api/browser/mainThreadSpeech.js +99 -0
  74. package/vscode/src/vs/workbench/api/browser/mainThreadStatusBar.js +53 -0
  75. package/vscode/src/vs/workbench/api/browser/mainThreadStorage.js +72 -0
  76. package/vscode/src/vs/workbench/api/browser/mainThreadTask.js +731 -0
  77. package/vscode/src/vs/workbench/api/browser/mainThreadTelemetry.js +53 -0
  78. package/vscode/src/vs/workbench/api/browser/mainThreadTerminalService.js +409 -0
  79. package/vscode/src/vs/workbench/api/browser/mainThreadTerminalShellIntegration.js +51 -0
  80. package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +219 -0
  81. package/vscode/src/vs/workbench/api/browser/mainThreadTheming.js +24 -0
  82. package/vscode/src/vs/workbench/api/browser/mainThreadTimeline.js +55 -0
  83. package/vscode/src/vs/workbench/api/browser/mainThreadTreeViews.js +312 -0
  84. package/vscode/src/vs/workbench/api/browser/mainThreadTunnelService.js +223 -0
  85. package/vscode/src/vs/workbench/api/browser/mainThreadUriOpeners.js +110 -0
  86. package/vscode/src/vs/workbench/api/browser/mainThreadUrls.js +61 -0
  87. package/vscode/src/vs/workbench/api/browser/mainThreadWebviewManager.js +29 -0
  88. package/vscode/src/vs/workbench/api/browser/mainThreadWebviewPanels.js +283 -0
  89. package/vscode/src/vs/workbench/api/browser/mainThreadWebviewViews.js +100 -0
  90. package/vscode/src/vs/workbench/api/browser/mainThreadWebviews.js +135 -0
  91. package/vscode/src/vs/workbench/api/browser/mainThreadWindow.js +57 -0
  92. package/vscode/src/vs/workbench/api/browser/mainThreadWorkspace.js +268 -0
  93. package/vscode/src/vs/workbench/api/common/shared/dataTransferCache.js +35 -0
  94. package/vscode/src/vs/workbench/contrib/customEditor/common/customTextEditorModel.js +76 -0
  95. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/contributedOpeners.js +83 -0
  96. package/vscode/src/vs/workbench/services/extensions/browser/extensionService.js +285 -0
  97. package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.js +276 -0
  98. package/vscode/src/vs/workbench/services/extensions/browser/webWorkerFileSystemProvider.js +52 -0
  99. package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.js +1149 -0
  100. package/vscode/src/vs/workbench/services/extensions/common/extHostCustomers.js +41 -0
  101. package/vscode/src/vs/workbench/services/extensions/common/extensionDevOptions.js +25 -0
  102. package/vscode/src/vs/workbench/services/extensions/common/extensionHostManager.js +512 -0
  103. package/vscode/src/vs/workbench/services/extensions/common/extensionRunningLocationTracker.js +274 -0
  104. package/vscode/src/vs/workbench/services/extensions/common/extensionStorageMigration.js +58 -0
  105. package/vscode/src/vs/workbench/services/extensions/common/extensionsProposedApi.js +80 -0
  106. package/vscode/src/vs/workbench/services/extensions/common/extensionsUtil.js +64 -0
  107. package/vscode/src/vs/workbench/services/extensions/common/lazyCreateExtensionHostManager.js +161 -0
  108. package/vscode/src/vs/workbench/services/extensions/common/remoteConsoleUtil.js +49 -0
  109. package/vscode/src/vs/workbench/services/extensions/common/remoteExtensionHost.js +222 -0
@@ -0,0 +1,194 @@
1
+ import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
2
+ import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
3
+ import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
4
+ import { Emitter } from 'vscode/vscode/vs/base/common/event';
5
+ import { DisposableStore, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
6
+ import { StopWatch } from 'vscode/vscode/vs/base/common/stopwatch';
7
+ import { assertType } from 'vscode/vscode/vs/base/common/types';
8
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
9
+ import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
10
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
11
+ import { NotebookDto } from './mainThreadNotebookDto.js';
12
+ import { INotebookCellStatusBarService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCellStatusBarService';
13
+ import { INotebookService, SimpleNotebookProviderInfo } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
14
+ import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
15
+ import { SerializableObjectWithBuffers } from 'vscode/vscode/vs/workbench/services/extensions/common/proxyIdentifier';
16
+ import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
17
+ import { revive } from 'vscode/vscode/vs/base/common/marshalling';
18
+ import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
19
+
20
+ let MainThreadNotebooks = class MainThreadNotebooks {
21
+ constructor(extHostContext, _notebookService, _cellStatusBarService, _logService) {
22
+ this._notebookService = _notebookService;
23
+ this._cellStatusBarService = _cellStatusBarService;
24
+ this._logService = _logService;
25
+ this._disposables = ( new DisposableStore());
26
+ this._notebookSerializer = ( new Map());
27
+ this._notebookCellStatusBarRegistrations = ( new Map());
28
+ this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostNotebook));
29
+ }
30
+ dispose() {
31
+ this._disposables.dispose();
32
+ dispose(( this._notebookSerializer.values()));
33
+ }
34
+ $registerNotebookSerializer(handle, extension, viewType, options, data) {
35
+ const disposables = ( new DisposableStore());
36
+ disposables.add(this._notebookService.registerNotebookSerializer(viewType, extension, {
37
+ options,
38
+ dataToNotebook: async (data) => {
39
+ const sw = ( new StopWatch());
40
+ let result;
41
+ if (data.byteLength === 0 && viewType === 'interactive') {
42
+ result = NotebookDto.fromNotebookDataDto({ cells: [], metadata: {} });
43
+ }
44
+ else {
45
+ const dto = await this._proxy.$dataToNotebook(handle, data, CancellationToken.None);
46
+ result = NotebookDto.fromNotebookDataDto(dto.value);
47
+ }
48
+ this._logService.trace(`[NotebookSerializer] dataToNotebook DONE after ${sw.elapsed()}ms`, {
49
+ viewType,
50
+ extensionId: extension.id.value,
51
+ });
52
+ return result;
53
+ },
54
+ notebookToData: (data) => {
55
+ const sw = ( new StopWatch());
56
+ const result = this._proxy.$notebookToData(handle, ( new SerializableObjectWithBuffers(NotebookDto.toNotebookDataDto(data))), CancellationToken.None);
57
+ this._logService.trace(`[NotebookSerializer] notebookToData DONE after ${sw.elapsed()}`, {
58
+ viewType,
59
+ extensionId: extension.id.value,
60
+ });
61
+ return result;
62
+ },
63
+ save: async (uri, versionId, options, token) => {
64
+ const stat = await this._proxy.$saveNotebook(handle, uri, versionId, options, token);
65
+ return {
66
+ ...stat,
67
+ children: undefined,
68
+ resource: uri
69
+ };
70
+ },
71
+ searchInNotebooks: async (textQuery, token, allPriorityInfo) => {
72
+ const contributedType = this._notebookService.getContributedNotebookType(viewType);
73
+ if (!contributedType) {
74
+ return { results: [], limitHit: false };
75
+ }
76
+ const fileNames = contributedType.selectors;
77
+ const includes = ( fileNames.map((selector) => {
78
+ const globPattern = selector.include || selector;
79
+ return ( globPattern.toString());
80
+ }));
81
+ if (!includes.length) {
82
+ return {
83
+ results: [], limitHit: false
84
+ };
85
+ }
86
+ const thisPriorityInfo = coalesce([{ isFromSettings: false, filenamePatterns: includes }, ...(allPriorityInfo.get(viewType) ?? [])]);
87
+ const otherEditorsPriorityInfo = Array.from(( allPriorityInfo.keys()))
88
+ .flatMap(key => {
89
+ if (key !== viewType) {
90
+ return allPriorityInfo.get(key) ?? [];
91
+ }
92
+ return [];
93
+ });
94
+ const searchComplete = await this._proxy.$searchInNotebooks(handle, textQuery, thisPriorityInfo, otherEditorsPriorityInfo, token);
95
+ const revivedResults = ( searchComplete.results.map(result => {
96
+ const resource = URI.revive(result.resource);
97
+ return {
98
+ resource,
99
+ cellResults: ( result.cellResults.map(e => revive(e)))
100
+ };
101
+ }));
102
+ return { results: revivedResults, limitHit: searchComplete.limitHit };
103
+ }
104
+ }));
105
+ if (data) {
106
+ disposables.add(this._notebookService.registerContributedNotebookType(viewType, data));
107
+ }
108
+ this._notebookSerializer.set(handle, disposables);
109
+ this._logService.trace('[NotebookSerializer] registered notebook serializer', {
110
+ viewType,
111
+ extensionId: extension.id.value,
112
+ });
113
+ }
114
+ $unregisterNotebookSerializer(handle) {
115
+ this._notebookSerializer.get(handle)?.dispose();
116
+ this._notebookSerializer.delete(handle);
117
+ }
118
+ $emitCellStatusBarEvent(eventHandle) {
119
+ const emitter = this._notebookCellStatusBarRegistrations.get(eventHandle);
120
+ if (emitter instanceof Emitter) {
121
+ emitter.fire(undefined);
122
+ }
123
+ }
124
+ async $registerNotebookCellStatusBarItemProvider(handle, eventHandle, viewType) {
125
+ const that = this;
126
+ const provider = {
127
+ async provideCellStatusBarItems(uri, index, token) {
128
+ const result = await that._proxy.$provideNotebookCellStatusBarItems(handle, uri, index, token);
129
+ return {
130
+ items: result?.items ?? [],
131
+ dispose() {
132
+ if (result) {
133
+ that._proxy.$releaseNotebookCellStatusBarItems(result.cacheId);
134
+ }
135
+ }
136
+ };
137
+ },
138
+ viewType
139
+ };
140
+ if (typeof eventHandle === 'number') {
141
+ const emitter = ( new Emitter());
142
+ this._notebookCellStatusBarRegistrations.set(eventHandle, emitter);
143
+ provider.onDidChangeStatusBarItems = emitter.event;
144
+ }
145
+ const disposable = this._cellStatusBarService.registerCellStatusBarItemProvider(provider);
146
+ this._notebookCellStatusBarRegistrations.set(handle, disposable);
147
+ }
148
+ async $unregisterNotebookCellStatusBarItemProvider(handle, eventHandle) {
149
+ const unregisterThing = (handle) => {
150
+ const entry = this._notebookCellStatusBarRegistrations.get(handle);
151
+ if (entry) {
152
+ this._notebookCellStatusBarRegistrations.get(handle)?.dispose();
153
+ this._notebookCellStatusBarRegistrations.delete(handle);
154
+ }
155
+ };
156
+ unregisterThing(handle);
157
+ if (typeof eventHandle === 'number') {
158
+ unregisterThing(eventHandle);
159
+ }
160
+ }
161
+ };
162
+ MainThreadNotebooks = __decorate([
163
+ extHostNamedCustomer(MainContext.MainThreadNotebook),
164
+ ( __param(1, INotebookService)),
165
+ ( __param(2, INotebookCellStatusBarService)),
166
+ ( __param(3, ILogService))
167
+ ], MainThreadNotebooks);
168
+ CommandsRegistry.registerCommand('_executeDataToNotebook', async (accessor, ...args) => {
169
+ const [notebookType, bytes] = args;
170
+ assertType(typeof notebookType === 'string', 'string');
171
+ assertType(bytes instanceof VSBuffer, 'VSBuffer');
172
+ const notebookService = accessor.get(INotebookService);
173
+ const info = await notebookService.withNotebookDataProvider(notebookType);
174
+ if (!(info instanceof SimpleNotebookProviderInfo)) {
175
+ return;
176
+ }
177
+ const dto = await info.serializer.dataToNotebook(bytes);
178
+ return ( new SerializableObjectWithBuffers(NotebookDto.toNotebookDataDto(dto)));
179
+ });
180
+ CommandsRegistry.registerCommand('_executeNotebookToData', async (accessor, ...args) => {
181
+ const [notebookType, dto] = args;
182
+ assertType(typeof notebookType === 'string', 'string');
183
+ assertType(typeof dto === 'object');
184
+ const notebookService = accessor.get(INotebookService);
185
+ const info = await notebookService.withNotebookDataProvider(notebookType);
186
+ if (!(info instanceof SimpleNotebookProviderInfo)) {
187
+ return;
188
+ }
189
+ const data = NotebookDto.fromNotebookDataDto(dto.value);
190
+ const bytes = await info.serializer.notebookToData(data);
191
+ return bytes;
192
+ });
193
+
194
+ export { MainThreadNotebooks };
@@ -0,0 +1,123 @@
1
+ import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
2
+ import { DisposableStore, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
3
+ import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
4
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
5
+ import { BoundModelReferenceCollection } from './mainThreadDocuments.js';
6
+ import { NotebookCellsChangeType } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
7
+ import { INotebookEditorModelResolverService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService';
8
+ import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
9
+ import { ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
10
+ import { NotebookDto } from './mainThreadNotebookDto.js';
11
+ import { SerializableObjectWithBuffers } from 'vscode/vscode/vs/workbench/services/extensions/common/proxyIdentifier';
12
+
13
+ let MainThreadNotebookDocuments = class MainThreadNotebookDocuments {
14
+ constructor(extHostContext, _notebookEditorModelResolverService, _uriIdentityService) {
15
+ this._notebookEditorModelResolverService = _notebookEditorModelResolverService;
16
+ this._uriIdentityService = _uriIdentityService;
17
+ this._disposables = ( new DisposableStore());
18
+ this._documentEventListenersMapping = ( new ResourceMap());
19
+ this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostNotebookDocuments));
20
+ this._modelReferenceCollection = ( new BoundModelReferenceCollection(this._uriIdentityService.extUri));
21
+ this._disposables.add(this._notebookEditorModelResolverService.onDidChangeDirty(model => this._proxy.$acceptDirtyStateChanged(model.resource, model.isDirty())));
22
+ this._disposables.add(this._notebookEditorModelResolverService.onDidSaveNotebook(e => this._proxy.$acceptModelSaved(e)));
23
+ this._disposables.add(_notebookEditorModelResolverService.onWillFailWithConflict(e => {
24
+ this._modelReferenceCollection.remove(e.resource);
25
+ }));
26
+ }
27
+ dispose() {
28
+ this._disposables.dispose();
29
+ this._modelReferenceCollection.dispose();
30
+ dispose(( this._documentEventListenersMapping.values()));
31
+ }
32
+ handleNotebooksAdded(notebooks) {
33
+ for (const textModel of notebooks) {
34
+ const disposableStore = ( new DisposableStore());
35
+ disposableStore.add(textModel.onDidChangeContent(event => {
36
+ const eventDto = {
37
+ versionId: event.versionId,
38
+ rawEvents: []
39
+ };
40
+ for (const e of event.rawEvents) {
41
+ switch (e.kind) {
42
+ case NotebookCellsChangeType.ModelChange:
43
+ eventDto.rawEvents.push({
44
+ kind: e.kind,
45
+ changes: ( e.changes.map(diff => [diff[0], diff[1], ( diff[2].map(cell => NotebookDto.toNotebookCellDto(cell)))]))
46
+ });
47
+ break;
48
+ case NotebookCellsChangeType.Move:
49
+ eventDto.rawEvents.push({
50
+ kind: e.kind,
51
+ index: e.index,
52
+ length: e.length,
53
+ newIdx: e.newIdx,
54
+ });
55
+ break;
56
+ case NotebookCellsChangeType.Output:
57
+ eventDto.rawEvents.push({
58
+ kind: e.kind,
59
+ index: e.index,
60
+ outputs: ( e.outputs.map(NotebookDto.toNotebookOutputDto))
61
+ });
62
+ break;
63
+ case NotebookCellsChangeType.OutputItem:
64
+ eventDto.rawEvents.push({
65
+ kind: e.kind,
66
+ index: e.index,
67
+ outputId: e.outputId,
68
+ outputItems: ( e.outputItems.map(NotebookDto.toNotebookOutputItemDto)),
69
+ append: e.append
70
+ });
71
+ break;
72
+ case NotebookCellsChangeType.ChangeCellLanguage:
73
+ case NotebookCellsChangeType.ChangeCellContent:
74
+ case NotebookCellsChangeType.ChangeCellMetadata:
75
+ case NotebookCellsChangeType.ChangeCellInternalMetadata:
76
+ eventDto.rawEvents.push(e);
77
+ break;
78
+ }
79
+ }
80
+ const hasDocumentMetadataChangeEvent = event.rawEvents.find(e => e.kind === NotebookCellsChangeType.ChangeDocumentMetadata);
81
+ this._proxy.$acceptModelChanged(textModel.uri, ( new SerializableObjectWithBuffers(eventDto)), this._notebookEditorModelResolverService.isDirty(textModel.uri), hasDocumentMetadataChangeEvent ? textModel.metadata : undefined);
82
+ }));
83
+ this._documentEventListenersMapping.set(textModel.uri, disposableStore);
84
+ }
85
+ }
86
+ handleNotebooksRemoved(uris) {
87
+ for (const uri of uris) {
88
+ this._documentEventListenersMapping.get(uri)?.dispose();
89
+ this._documentEventListenersMapping.delete(uri);
90
+ }
91
+ }
92
+ async $tryCreateNotebook(options) {
93
+ const ref = await this._notebookEditorModelResolverService.resolve({ untitledResource: undefined }, options.viewType);
94
+ ref.object.notebook.onWillDispose(() => {
95
+ ref.dispose();
96
+ });
97
+ this._proxy.$acceptDirtyStateChanged(ref.object.resource, true);
98
+ if (options.content) {
99
+ const data = NotebookDto.fromNotebookDataDto(options.content);
100
+ ref.object.notebook.reset(data.cells, data.metadata, ref.object.notebook.transientOptions);
101
+ }
102
+ return ref.object.resource;
103
+ }
104
+ async $tryOpenNotebook(uriComponents) {
105
+ const uri = URI.revive(uriComponents);
106
+ const ref = await this._notebookEditorModelResolverService.resolve(uri, undefined);
107
+ this._modelReferenceCollection.add(uri, ref);
108
+ return uri;
109
+ }
110
+ async $trySaveNotebook(uriComponents) {
111
+ const uri = URI.revive(uriComponents);
112
+ const ref = await this._notebookEditorModelResolverService.resolve(uri);
113
+ const saveResult = await ref.object.save();
114
+ ref.dispose();
115
+ return saveResult;
116
+ }
117
+ };
118
+ MainThreadNotebookDocuments = ( __decorate([
119
+ ( __param(1, INotebookEditorModelResolverService)),
120
+ ( __param(2, IUriIdentityService))
121
+ ], MainThreadNotebookDocuments));
122
+
123
+ export { MainThreadNotebookDocuments };
@@ -0,0 +1,188 @@
1
+ import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
2
+ import { diffSets, diffMaps } from 'vscode/vscode/vs/base/common/collections';
3
+ import { DisposableStore, DisposableMap, combinedDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
5
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
6
+ import { MainThreadNotebookDocuments } from './mainThreadNotebookDocuments.js';
7
+ import { NotebookDto } from './mainThreadNotebookDto.js';
8
+ import { MainThreadNotebookEditors } from './mainThreadNotebookEditors.js';
9
+ import { extHostCustomer } from '../../services/extensions/common/extHostCustomers.js';
10
+ import { editorGroupToColumn } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupColumn';
11
+ import { getNotebookEditorFromEditorPane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
12
+ import { INotebookEditorService } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService';
13
+ import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
14
+ import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
15
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
16
+ import { ExtHostContext, MainContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
17
+ import { SerializableObjectWithBuffers } from 'vscode/vscode/vs/workbench/services/extensions/common/proxyIdentifier';
18
+
19
+ var MainThreadNotebooksAndEditors_1;
20
+ class NotebookAndEditorState {
21
+ static delta(before, after) {
22
+ if (!before) {
23
+ return {
24
+ addedDocuments: [...after.documents],
25
+ removedDocuments: [],
26
+ addedEditors: [...( after.textEditors.values())],
27
+ removedEditors: [],
28
+ visibleEditors: ( [...after.visibleEditors].map(editor => editor[0]))
29
+ };
30
+ }
31
+ const documentDelta = diffSets(before.documents, after.documents);
32
+ const editorDelta = diffMaps(before.textEditors, after.textEditors);
33
+ const newActiveEditor = before.activeEditor !== after.activeEditor ? after.activeEditor : undefined;
34
+ const visibleEditorDelta = diffMaps(before.visibleEditors, after.visibleEditors);
35
+ return {
36
+ addedDocuments: documentDelta.added,
37
+ removedDocuments: ( documentDelta.removed.map(e => e.uri)),
38
+ addedEditors: editorDelta.added,
39
+ removedEditors: ( editorDelta.removed.map(removed => removed.getId())),
40
+ newActiveEditor: newActiveEditor,
41
+ visibleEditors: visibleEditorDelta.added.length === 0 && visibleEditorDelta.removed.length === 0
42
+ ? undefined
43
+ : ( [...after.visibleEditors].map(editor => editor[0]))
44
+ };
45
+ }
46
+ constructor(documents, textEditors, activeEditor, visibleEditors) {
47
+ this.documents = documents;
48
+ this.textEditors = textEditors;
49
+ this.activeEditor = activeEditor;
50
+ this.visibleEditors = visibleEditors;
51
+ }
52
+ }
53
+ let MainThreadNotebooksAndEditors = MainThreadNotebooksAndEditors_1 = class MainThreadNotebooksAndEditors {
54
+ constructor(extHostContext, instantiationService, _notebookService, _notebookEditorService, _editorService, _editorGroupService, _logService) {
55
+ this._notebookService = _notebookService;
56
+ this._notebookEditorService = _notebookEditorService;
57
+ this._editorService = _editorService;
58
+ this._editorGroupService = _editorGroupService;
59
+ this._logService = _logService;
60
+ this._disposables = ( new DisposableStore());
61
+ this._editorListeners = ( new DisposableMap());
62
+ this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostNotebook));
63
+ this._mainThreadNotebooks = instantiationService.createInstance(MainThreadNotebookDocuments, extHostContext);
64
+ this._mainThreadEditors = instantiationService.createInstance(MainThreadNotebookEditors, extHostContext);
65
+ extHostContext.set(MainContext.MainThreadNotebookDocuments, this._mainThreadNotebooks);
66
+ extHostContext.set(MainContext.MainThreadNotebookEditors, this._mainThreadEditors);
67
+ this._notebookService.onWillAddNotebookDocument(() => this._updateState(), this, this._disposables);
68
+ this._notebookService.onDidRemoveNotebookDocument(() => this._updateState(), this, this._disposables);
69
+ this._editorService.onDidActiveEditorChange(() => this._updateState(), this, this._disposables);
70
+ this._editorService.onDidVisibleEditorsChange(() => this._updateState(), this, this._disposables);
71
+ this._notebookEditorService.onDidAddNotebookEditor(this._handleEditorAdd, this, this._disposables);
72
+ this._notebookEditorService.onDidRemoveNotebookEditor(this._handleEditorRemove, this, this._disposables);
73
+ this._updateState();
74
+ }
75
+ dispose() {
76
+ this._mainThreadNotebooks.dispose();
77
+ this._mainThreadEditors.dispose();
78
+ this._disposables.dispose();
79
+ this._editorListeners.dispose();
80
+ }
81
+ _handleEditorAdd(editor) {
82
+ this._editorListeners.set(editor.getId(), combinedDisposable(editor.onDidChangeModel(() => this._updateState()), editor.onDidFocusWidget(() => this._updateState(editor))));
83
+ this._updateState();
84
+ }
85
+ _handleEditorRemove(editor) {
86
+ this._editorListeners.deleteAndDispose(editor.getId());
87
+ this._updateState();
88
+ }
89
+ _updateState(focusedEditor) {
90
+ const editors = ( new Map());
91
+ const visibleEditorsMap = ( new Map());
92
+ for (const editor of this._notebookEditorService.listNotebookEditors()) {
93
+ if (editor.hasModel()) {
94
+ editors.set(editor.getId(), editor);
95
+ }
96
+ }
97
+ const activeNotebookEditor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
98
+ let activeEditor = null;
99
+ if (activeNotebookEditor) {
100
+ activeEditor = activeNotebookEditor.getId();
101
+ }
102
+ else if (focusedEditor?.textModel) {
103
+ activeEditor = focusedEditor.getId();
104
+ }
105
+ if (activeEditor && !( editors.has(activeEditor))) {
106
+ this._logService.trace('MainThreadNotebooksAndEditors#_updateState: active editor is not in editors list', activeEditor, ( editors.keys()));
107
+ activeEditor = null;
108
+ }
109
+ for (const editorPane of this._editorService.visibleEditorPanes) {
110
+ const notebookEditor = getNotebookEditorFromEditorPane(editorPane);
111
+ if (notebookEditor?.hasModel() && ( editors.has(notebookEditor.getId()))) {
112
+ visibleEditorsMap.set(notebookEditor.getId(), notebookEditor);
113
+ }
114
+ }
115
+ const newState = ( new NotebookAndEditorState(( new Set(this._notebookService.listNotebookDocuments())), editors, activeEditor, visibleEditorsMap));
116
+ this._onDelta(NotebookAndEditorState.delta(this._currentState, newState));
117
+ this._currentState = newState;
118
+ }
119
+ _onDelta(delta) {
120
+ if (MainThreadNotebooksAndEditors_1._isDeltaEmpty(delta)) {
121
+ return;
122
+ }
123
+ const dto = {
124
+ removedDocuments: delta.removedDocuments,
125
+ removedEditors: delta.removedEditors,
126
+ newActiveEditor: delta.newActiveEditor,
127
+ visibleEditors: delta.visibleEditors,
128
+ addedDocuments: ( delta.addedDocuments.map(MainThreadNotebooksAndEditors_1._asModelAddData)),
129
+ addedEditors: ( delta.addedEditors.map(this._asEditorAddData, this)),
130
+ };
131
+ this._proxy.$acceptDocumentAndEditorsDelta(( new SerializableObjectWithBuffers(dto)));
132
+ this._mainThreadEditors.handleEditorsRemoved(delta.removedEditors);
133
+ this._mainThreadNotebooks.handleNotebooksRemoved(delta.removedDocuments);
134
+ this._mainThreadNotebooks.handleNotebooksAdded(delta.addedDocuments);
135
+ this._mainThreadEditors.handleEditorsAdded(delta.addedEditors);
136
+ }
137
+ static _isDeltaEmpty(delta) {
138
+ if (delta.addedDocuments !== undefined && delta.addedDocuments.length > 0) {
139
+ return false;
140
+ }
141
+ if (delta.removedDocuments !== undefined && delta.removedDocuments.length > 0) {
142
+ return false;
143
+ }
144
+ if (delta.addedEditors !== undefined && delta.addedEditors.length > 0) {
145
+ return false;
146
+ }
147
+ if (delta.removedEditors !== undefined && delta.removedEditors.length > 0) {
148
+ return false;
149
+ }
150
+ if (delta.visibleEditors !== undefined && delta.visibleEditors.length > 0) {
151
+ return false;
152
+ }
153
+ if (delta.newActiveEditor !== undefined) {
154
+ return false;
155
+ }
156
+ return true;
157
+ }
158
+ static _asModelAddData(e) {
159
+ return {
160
+ viewType: e.viewType,
161
+ uri: e.uri,
162
+ metadata: e.metadata,
163
+ versionId: e.versionId,
164
+ cells: ( e.cells.map(NotebookDto.toNotebookCellDto))
165
+ };
166
+ }
167
+ _asEditorAddData(add) {
168
+ const pane = this._editorService.visibleEditorPanes.find(pane => getNotebookEditorFromEditorPane(pane) === add);
169
+ return {
170
+ id: add.getId(),
171
+ documentUri: add.textModel.uri,
172
+ selections: add.getSelections(),
173
+ visibleRanges: add.visibleRanges,
174
+ viewColumn: pane && editorGroupToColumn(this._editorGroupService, pane.group)
175
+ };
176
+ }
177
+ };
178
+ MainThreadNotebooksAndEditors = MainThreadNotebooksAndEditors_1 = __decorate([
179
+ extHostCustomer,
180
+ ( __param(1, IInstantiationService)),
181
+ ( __param(2, INotebookService)),
182
+ ( __param(3, INotebookEditorService)),
183
+ ( __param(4, IEditorService)),
184
+ ( __param(5, IEditorGroupsService)),
185
+ ( __param(6, ILogService))
186
+ ], MainThreadNotebooksAndEditors);
187
+
188
+ export { MainThreadNotebooksAndEditors };
@@ -0,0 +1,129 @@
1
+ import { CellExecutionUpdateType } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionService';
2
+
3
+ var NotebookDto;
4
+ ( (function(NotebookDto) {
5
+ function toNotebookOutputItemDto(item) {
6
+ return {
7
+ mime: item.mime,
8
+ valueBytes: item.data
9
+ };
10
+ }
11
+ NotebookDto.toNotebookOutputItemDto = toNotebookOutputItemDto;
12
+ function toNotebookOutputDto(output) {
13
+ return {
14
+ outputId: output.outputId,
15
+ metadata: output.metadata,
16
+ items: ( output.outputs.map(toNotebookOutputItemDto))
17
+ };
18
+ }
19
+ NotebookDto.toNotebookOutputDto = toNotebookOutputDto;
20
+ function toNotebookCellDataDto(cell) {
21
+ return {
22
+ cellKind: cell.cellKind,
23
+ language: cell.language,
24
+ mime: cell.mime,
25
+ source: cell.source,
26
+ internalMetadata: cell.internalMetadata,
27
+ metadata: cell.metadata,
28
+ outputs: ( cell.outputs.map(toNotebookOutputDto))
29
+ };
30
+ }
31
+ NotebookDto.toNotebookCellDataDto = toNotebookCellDataDto;
32
+ function toNotebookDataDto(data) {
33
+ return {
34
+ metadata: data.metadata,
35
+ cells: ( data.cells.map(toNotebookCellDataDto))
36
+ };
37
+ }
38
+ NotebookDto.toNotebookDataDto = toNotebookDataDto;
39
+ function fromNotebookOutputItemDto(item) {
40
+ return {
41
+ mime: item.mime,
42
+ data: item.valueBytes
43
+ };
44
+ }
45
+ NotebookDto.fromNotebookOutputItemDto = fromNotebookOutputItemDto;
46
+ function fromNotebookOutputDto(output) {
47
+ return {
48
+ outputId: output.outputId,
49
+ metadata: output.metadata,
50
+ outputs: ( output.items.map(fromNotebookOutputItemDto))
51
+ };
52
+ }
53
+ NotebookDto.fromNotebookOutputDto = fromNotebookOutputDto;
54
+ function fromNotebookCellDataDto(cell) {
55
+ return {
56
+ cellKind: cell.cellKind,
57
+ language: cell.language,
58
+ mime: cell.mime,
59
+ source: cell.source,
60
+ outputs: ( cell.outputs.map(fromNotebookOutputDto)),
61
+ metadata: cell.metadata,
62
+ internalMetadata: cell.internalMetadata
63
+ };
64
+ }
65
+ NotebookDto.fromNotebookCellDataDto = fromNotebookCellDataDto;
66
+ function fromNotebookDataDto(data) {
67
+ return {
68
+ metadata: data.metadata,
69
+ cells: ( data.cells.map(fromNotebookCellDataDto))
70
+ };
71
+ }
72
+ NotebookDto.fromNotebookDataDto = fromNotebookDataDto;
73
+ function toNotebookCellDto(cell) {
74
+ return {
75
+ handle: cell.handle,
76
+ uri: cell.uri,
77
+ source: cell.textBuffer.getLinesContent(),
78
+ eol: cell.textBuffer.getEOL(),
79
+ language: cell.language,
80
+ cellKind: cell.cellKind,
81
+ outputs: ( cell.outputs.map(toNotebookOutputDto)),
82
+ metadata: cell.metadata,
83
+ internalMetadata: cell.internalMetadata,
84
+ };
85
+ }
86
+ NotebookDto.toNotebookCellDto = toNotebookCellDto;
87
+ function fromCellExecuteUpdateDto(data) {
88
+ if (data.editType === CellExecutionUpdateType.Output) {
89
+ return {
90
+ editType: data.editType,
91
+ cellHandle: data.cellHandle,
92
+ append: data.append,
93
+ outputs: ( data.outputs.map(fromNotebookOutputDto))
94
+ };
95
+ }
96
+ else if (data.editType === CellExecutionUpdateType.OutputItems) {
97
+ return {
98
+ editType: data.editType,
99
+ append: data.append,
100
+ outputId: data.outputId,
101
+ items: ( data.items.map(fromNotebookOutputItemDto))
102
+ };
103
+ }
104
+ else {
105
+ return data;
106
+ }
107
+ }
108
+ NotebookDto.fromCellExecuteUpdateDto = fromCellExecuteUpdateDto;
109
+ function fromCellExecuteCompleteDto(data) {
110
+ return data;
111
+ }
112
+ NotebookDto.fromCellExecuteCompleteDto = fromCellExecuteCompleteDto;
113
+ function fromCellEditOperationDto(edit) {
114
+ if (edit.editType === 1 ) {
115
+ return {
116
+ editType: edit.editType,
117
+ index: edit.index,
118
+ count: edit.count,
119
+ cells: ( edit.cells.map(fromNotebookCellDataDto))
120
+ };
121
+ }
122
+ else {
123
+ return edit;
124
+ }
125
+ }
126
+ NotebookDto.fromCellEditOperationDto = fromCellEditOperationDto;
127
+ })(NotebookDto || (NotebookDto = {})));
128
+
129
+ export { NotebookDto };