@codingame/monaco-vscode-notebook-service-override 1.85.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 (84) hide show
  1. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  2. package/external/tslib/tslib.es6.js +11 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +1 -0
  5. package/notebook.d.ts +5 -0
  6. package/notebook.js +44 -0
  7. package/override/vs/platform/dialogs/common/dialogs.js +8 -0
  8. package/package.json +32 -0
  9. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +6 -0
  10. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +387 -0
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +668 -0
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +109 -0
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +319 -0
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +58 -0
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +173 -0
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +485 -0
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +106 -0
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +67 -0
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +165 -0
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +67 -0
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +238 -0
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +72 -0
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +6 -0
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +168 -0
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +317 -0
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +209 -0
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +87 -0
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +82 -0
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +67 -0
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +93 -0
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +383 -0
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +51 -0
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +46 -0
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +135 -0
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +383 -0
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +117 -0
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +511 -0
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +168 -0
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +57 -0
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +94 -0
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +51 -0
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +702 -0
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +268 -0
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +45 -0
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +1297 -0
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +284 -0
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +563 -0
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +108 -0
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +39 -0
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +6 -0
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +313 -0
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +872 -0
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +13 -0
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +393 -0
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +175 -0
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +1121 -0
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +159 -0
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +339 -0
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookCellStatusBarServiceImpl.js +41 -0
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +182 -0
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +106 -0
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +509 -0
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +133 -0
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +342 -0
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +111 -0
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +28 -0
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +65 -0
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +666 -0
  69. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +200 -0
  70. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +80 -0
  71. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +1001 -0
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +103 -0
  73. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +202 -0
  74. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +80 -0
  75. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +98 -0
  76. package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +217 -0
  77. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +89 -0
  78. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +372 -0
  79. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopy.js +706 -0
  80. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +407 -0
  81. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +144 -0
  82. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +129 -0
  83. package/worker.js +1 -0
  84. package/workers/notebook.worker.js +9 -0
@@ -0,0 +1,109 @@
1
+ import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Throttler } from 'monaco-editor/esm/vs/base/common/async.js';
3
+ import { CancellationTokenSource } from 'monaco-editor/esm/vs/base/common/cancellation.js';
4
+ import { Disposable, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
5
+ import { NotebookVisibleCellObserver } from './notebookVisibleCellObserver.js';
6
+ import { registerNotebookContribution } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
7
+ import { INotebookCellStatusBarService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCellStatusBarService';
8
+
9
+ let ContributedStatusBarItemController = class ContributedStatusBarItemController extends Disposable {
10
+ static { this.id = 'workbench.notebook.statusBar.contributed'; }
11
+ constructor(_notebookEditor, _notebookCellStatusBarService) {
12
+ super();
13
+ this._notebookEditor = _notebookEditor;
14
+ this._notebookCellStatusBarService = _notebookCellStatusBarService;
15
+ this._visibleCells = ( new Map());
16
+ this._observer = this._register(( new NotebookVisibleCellObserver(this._notebookEditor)));
17
+ this._register(this._observer.onDidChangeVisibleCells(this._updateVisibleCells, this));
18
+ this._updateEverything();
19
+ this._register(this._notebookCellStatusBarService.onDidChangeProviders(this._updateEverything, this));
20
+ this._register(this._notebookCellStatusBarService.onDidChangeItems(this._updateEverything, this));
21
+ }
22
+ _updateEverything() {
23
+ const newCells = this._observer.visibleCells.filter(cell => !( this._visibleCells.has(cell.handle)));
24
+ const visibleCellHandles = ( new Set(( this._observer.visibleCells.map(item => item.handle))));
25
+ const currentCellHandles = Array.from(( this._visibleCells.keys()));
26
+ const removedCells = currentCellHandles.filter(handle => !( visibleCellHandles.has(handle)));
27
+ const itemsToUpdate = currentCellHandles.filter(handle => ( visibleCellHandles.has(handle)));
28
+ this._updateVisibleCells({ added: newCells, removed: ( removedCells.map(handle => ({ handle }))) });
29
+ itemsToUpdate.forEach(handle => this._visibleCells.get(handle)?.update());
30
+ }
31
+ _updateVisibleCells(e) {
32
+ const vm = this._notebookEditor.getViewModel();
33
+ if (!vm) {
34
+ return;
35
+ }
36
+ for (const newCell of e.added) {
37
+ const helper = ( new CellStatusBarHelper(vm, newCell, this._notebookCellStatusBarService));
38
+ this._visibleCells.set(newCell.handle, helper);
39
+ }
40
+ for (const oldCell of e.removed) {
41
+ this._visibleCells.get(oldCell.handle)?.dispose();
42
+ this._visibleCells.delete(oldCell.handle);
43
+ }
44
+ }
45
+ dispose() {
46
+ super.dispose();
47
+ this._visibleCells.forEach(cell => cell.dispose());
48
+ this._visibleCells.clear();
49
+ }
50
+ };
51
+ ContributedStatusBarItemController = ( __decorate([
52
+ ( __param(1, INotebookCellStatusBarService))
53
+ ], ContributedStatusBarItemController));
54
+ class CellStatusBarHelper extends Disposable {
55
+ constructor(_notebookViewModel, _cell, _notebookCellStatusBarService) {
56
+ super();
57
+ this._notebookViewModel = _notebookViewModel;
58
+ this._cell = _cell;
59
+ this._notebookCellStatusBarService = _notebookCellStatusBarService;
60
+ this._currentItemIds = [];
61
+ this._currentItemLists = [];
62
+ this._isDisposed = false;
63
+ this._updateThrottler = this._register(( new Throttler()));
64
+ this._register(toDisposable(() => this._activeToken?.dispose(true)));
65
+ this._updateSoon();
66
+ this._register(this._cell.model.onDidChangeContent(() => this._updateSoon()));
67
+ this._register(this._cell.model.onDidChangeLanguage(() => this._updateSoon()));
68
+ this._register(this._cell.model.onDidChangeMetadata(() => this._updateSoon()));
69
+ this._register(this._cell.model.onDidChangeInternalMetadata(() => this._updateSoon()));
70
+ this._register(this._cell.model.onDidChangeOutputs(() => this._updateSoon()));
71
+ }
72
+ update() {
73
+ this._updateSoon();
74
+ }
75
+ _updateSoon() {
76
+ setTimeout(() => {
77
+ if (!this._isDisposed) {
78
+ this._updateThrottler.queue(() => this._update());
79
+ }
80
+ }, 0);
81
+ }
82
+ async _update() {
83
+ const cellIndex = this._notebookViewModel.getCellIndex(this._cell);
84
+ const docUri = this._notebookViewModel.notebookDocument.uri;
85
+ const viewType = this._notebookViewModel.notebookDocument.viewType;
86
+ this._activeToken?.dispose(true);
87
+ const tokenSource = this._activeToken = ( new CancellationTokenSource());
88
+ const itemLists = await this._notebookCellStatusBarService.getStatusBarItemsForCell(docUri, cellIndex, viewType, tokenSource.token);
89
+ if (tokenSource.token.isCancellationRequested) {
90
+ itemLists.forEach(itemList => itemList.dispose && itemList.dispose());
91
+ return;
92
+ }
93
+ const items = ( itemLists.map(itemList => itemList.items)).flat();
94
+ const newIds = this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items }]);
95
+ this._currentItemLists.forEach(itemList => itemList.dispose && itemList.dispose());
96
+ this._currentItemLists = itemLists;
97
+ this._currentItemIds = newIds;
98
+ }
99
+ dispose() {
100
+ super.dispose();
101
+ this._isDisposed = true;
102
+ this._activeToken?.dispose(true);
103
+ this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items: [] }]);
104
+ this._currentItemLists.forEach(itemList => itemList.dispose && itemList.dispose());
105
+ }
106
+ }
107
+ registerNotebookContribution(ContributedStatusBarItemController.id, ContributedStatusBarItemController);
108
+
109
+ export { ContributedStatusBarItemController };
@@ -0,0 +1,319 @@
1
+ import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { disposableTimeout, RunOnceScheduler } from 'monaco-editor/esm/vs/base/common/async.js';
3
+ import { Disposable, MutableDisposable, dispose } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { language } from 'monaco-editor/esm/vs/base/common/platform.js';
5
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
6
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
7
+ import { themeColorFromId } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
8
+ import { ThemeIcon } from 'monaco-editor/esm/vs/base/common/themables.js';
9
+ import { NotebookVisibleCellObserver } from './notebookVisibleCellObserver.js';
10
+ import { registerNotebookContribution } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
11
+ import { cellStatusIconSuccess, cellStatusIconError } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorWidget';
12
+ import { successStateIcon, errorStateIcon, pendingStateIcon, executingStateIcon } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
13
+ import { NotebookCellExecutionState } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
14
+ import { NotebookExecutionType, INotebookExecutionStateService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
15
+ import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
16
+
17
+ var ExecutionStateCellStatusBarItem_1, TimerCellStatusBarItem_1;
18
+ function formatCellDuration(duration, showMilliseconds = true) {
19
+ if (showMilliseconds && duration < 1000) {
20
+ return `${duration}ms`;
21
+ }
22
+ const minutes = Math.floor(duration / 1000 / 60);
23
+ const seconds = Math.floor(duration / 1000) % 60;
24
+ const tenths = Math.floor((duration % 1000) / 100);
25
+ if (minutes > 0) {
26
+ return `${minutes}m ${seconds}.${tenths}s`;
27
+ }
28
+ else {
29
+ return `${seconds}.${tenths}s`;
30
+ }
31
+ }
32
+ class NotebookStatusBarController extends Disposable {
33
+ constructor(_notebookEditor, _itemFactory) {
34
+ super();
35
+ this._notebookEditor = _notebookEditor;
36
+ this._itemFactory = _itemFactory;
37
+ this._visibleCells = ( new Map());
38
+ this._observer = this._register(( new NotebookVisibleCellObserver(this._notebookEditor)));
39
+ this._register(this._observer.onDidChangeVisibleCells(this._updateVisibleCells, this));
40
+ this._updateEverything();
41
+ }
42
+ _updateEverything() {
43
+ this._visibleCells.forEach(dispose);
44
+ this._visibleCells.clear();
45
+ this._updateVisibleCells({ added: this._observer.visibleCells, removed: [] });
46
+ }
47
+ _updateVisibleCells(e) {
48
+ const vm = this._notebookEditor.getViewModel();
49
+ if (!vm) {
50
+ return;
51
+ }
52
+ for (const oldCell of e.removed) {
53
+ this._visibleCells.get(oldCell.handle)?.dispose();
54
+ this._visibleCells.delete(oldCell.handle);
55
+ }
56
+ for (const newCell of e.added) {
57
+ this._visibleCells.set(newCell.handle, this._itemFactory(vm, newCell));
58
+ }
59
+ }
60
+ dispose() {
61
+ super.dispose();
62
+ this._visibleCells.forEach(dispose);
63
+ this._visibleCells.clear();
64
+ }
65
+ }
66
+ let ExecutionStateCellStatusBarContrib = class ExecutionStateCellStatusBarContrib extends Disposable {
67
+ static { this.id = 'workbench.notebook.statusBar.execState'; }
68
+ constructor(notebookEditor, instantiationService) {
69
+ super();
70
+ this._register(( new NotebookStatusBarController(
71
+ notebookEditor,
72
+ (vm, cell) => instantiationService.createInstance(ExecutionStateCellStatusBarItem, vm, cell)
73
+ )));
74
+ }
75
+ };
76
+ ExecutionStateCellStatusBarContrib = ( __decorate([
77
+ ( __param(1, IInstantiationService))
78
+ ], ExecutionStateCellStatusBarContrib));
79
+ registerNotebookContribution(ExecutionStateCellStatusBarContrib.id, ExecutionStateCellStatusBarContrib);
80
+ let ExecutionStateCellStatusBarItem = class ExecutionStateCellStatusBarItem extends Disposable {
81
+ static { ExecutionStateCellStatusBarItem_1 = this; }
82
+ static { this.MIN_SPINNER_TIME = 500; }
83
+ constructor(_notebookViewModel, _cell, _executionStateService) {
84
+ super();
85
+ this._notebookViewModel = _notebookViewModel;
86
+ this._cell = _cell;
87
+ this._executionStateService = _executionStateService;
88
+ this._currentItemIds = [];
89
+ this._clearExecutingStateTimer = this._register(( new MutableDisposable()));
90
+ this._update();
91
+ this._register(this._executionStateService.onDidChangeExecution(e => {
92
+ if (e.type === NotebookExecutionType.cell && e.affectsCell(this._cell.uri)) {
93
+ this._update();
94
+ }
95
+ }));
96
+ this._register(this._cell.model.onDidChangeInternalMetadata(() => this._update()));
97
+ }
98
+ async _update() {
99
+ const items = this._getItemsForCell();
100
+ if (Array.isArray(items)) {
101
+ this._currentItemIds = this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items }]);
102
+ }
103
+ }
104
+ _getItemsForCell() {
105
+ const runState = this._executionStateService.getCellExecution(this._cell.uri);
106
+ if (runState?.state === NotebookCellExecutionState.Executing && typeof this._showedExecutingStateTime !== 'number') {
107
+ this._showedExecutingStateTime = Date.now();
108
+ }
109
+ else if (runState?.state !== NotebookCellExecutionState.Executing && typeof this._showedExecutingStateTime === 'number') {
110
+ const timeUntilMin = ExecutionStateCellStatusBarItem_1.MIN_SPINNER_TIME - (Date.now() - this._showedExecutingStateTime);
111
+ if (timeUntilMin > 0) {
112
+ if (!this._clearExecutingStateTimer.value) {
113
+ this._clearExecutingStateTimer.value = disposableTimeout(() => {
114
+ this._showedExecutingStateTime = undefined;
115
+ this._clearExecutingStateTimer.clear();
116
+ this._update();
117
+ }, timeUntilMin);
118
+ }
119
+ return undefined;
120
+ }
121
+ else {
122
+ this._showedExecutingStateTime = undefined;
123
+ }
124
+ }
125
+ const items = this._getItemForState(runState, this._cell.internalMetadata);
126
+ return items;
127
+ }
128
+ _getItemForState(runState, internalMetadata) {
129
+ const state = runState?.state;
130
+ const { lastRunSuccess } = internalMetadata;
131
+ if (!state && lastRunSuccess) {
132
+ return [{
133
+ text: `$(${successStateIcon.id})`,
134
+ color: themeColorFromId(cellStatusIconSuccess),
135
+ tooltip: ( localizeWithPath(
136
+ 'vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController',
137
+ 'notebook.cell.status.success',
138
+ "Success"
139
+ )),
140
+ alignment: 1 ,
141
+ priority: Number.MAX_SAFE_INTEGER
142
+ }];
143
+ }
144
+ else if (!state && lastRunSuccess === false) {
145
+ return [{
146
+ text: `$(${errorStateIcon.id})`,
147
+ color: themeColorFromId(cellStatusIconError),
148
+ tooltip: ( localizeWithPath(
149
+ 'vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController',
150
+ 'notebook.cell.status.failed',
151
+ "Failed"
152
+ )),
153
+ alignment: 1 ,
154
+ priority: Number.MAX_SAFE_INTEGER
155
+ }];
156
+ }
157
+ else if (state === NotebookCellExecutionState.Pending || state === NotebookCellExecutionState.Unconfirmed) {
158
+ return [{
159
+ text: `$(${pendingStateIcon.id})`,
160
+ tooltip: ( localizeWithPath(
161
+ 'vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController',
162
+ 'notebook.cell.status.pending',
163
+ "Pending"
164
+ )),
165
+ alignment: 1 ,
166
+ priority: Number.MAX_SAFE_INTEGER
167
+ }];
168
+ }
169
+ else if (state === NotebookCellExecutionState.Executing) {
170
+ const icon = runState?.didPause ?
171
+ executingStateIcon :
172
+ ThemeIcon.modify(executingStateIcon, 'spin');
173
+ return [{
174
+ text: `$(${icon.id})`,
175
+ tooltip: ( localizeWithPath(
176
+ 'vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController',
177
+ 'notebook.cell.status.executing',
178
+ "Executing"
179
+ )),
180
+ alignment: 1 ,
181
+ priority: Number.MAX_SAFE_INTEGER
182
+ }];
183
+ }
184
+ return [];
185
+ }
186
+ dispose() {
187
+ super.dispose();
188
+ this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items: [] }]);
189
+ }
190
+ };
191
+ ExecutionStateCellStatusBarItem = ExecutionStateCellStatusBarItem_1 = ( __decorate([
192
+ ( __param(2, INotebookExecutionStateService))
193
+ ], ExecutionStateCellStatusBarItem));
194
+ let TimerCellStatusBarContrib = class TimerCellStatusBarContrib extends Disposable {
195
+ static { this.id = 'workbench.notebook.statusBar.execTimer'; }
196
+ constructor(notebookEditor, instantiationService) {
197
+ super();
198
+ this._register(( new NotebookStatusBarController(
199
+ notebookEditor,
200
+ (vm, cell) => instantiationService.createInstance(TimerCellStatusBarItem, vm, cell)
201
+ )));
202
+ }
203
+ };
204
+ TimerCellStatusBarContrib = ( __decorate([
205
+ ( __param(1, IInstantiationService))
206
+ ], TimerCellStatusBarContrib));
207
+ registerNotebookContribution(TimerCellStatusBarContrib.id, TimerCellStatusBarContrib);
208
+ const UPDATE_TIMER_GRACE_PERIOD = 200;
209
+ let TimerCellStatusBarItem = class TimerCellStatusBarItem extends Disposable {
210
+ static { TimerCellStatusBarItem_1 = this; }
211
+ static { this.UPDATE_INTERVAL = 100; }
212
+ constructor(_notebookViewModel, _cell, _executionStateService, _notebookService) {
213
+ super();
214
+ this._notebookViewModel = _notebookViewModel;
215
+ this._cell = _cell;
216
+ this._executionStateService = _executionStateService;
217
+ this._notebookService = _notebookService;
218
+ this._currentItemIds = [];
219
+ this._scheduler = this._register(( new RunOnceScheduler(() => this._update(), TimerCellStatusBarItem_1.UPDATE_INTERVAL)));
220
+ this._update();
221
+ this._register(this._cell.model.onDidChangeInternalMetadata(() => this._update()));
222
+ }
223
+ async _update() {
224
+ let timerItem;
225
+ const runState = this._executionStateService.getCellExecution(this._cell.uri);
226
+ const state = runState?.state;
227
+ const startTime = this._cell.internalMetadata.runStartTime;
228
+ const adjustment = this._cell.internalMetadata.runStartTimeAdjustment ?? 0;
229
+ const endTime = this._cell.internalMetadata.runEndTime;
230
+ if (runState?.didPause) {
231
+ timerItem = undefined;
232
+ }
233
+ else if (state === NotebookCellExecutionState.Executing) {
234
+ if (typeof startTime === 'number') {
235
+ timerItem = this._getTimeItem(startTime, Date.now(), adjustment);
236
+ this._scheduler.schedule();
237
+ }
238
+ }
239
+ else if (!state) {
240
+ if (typeof startTime === 'number' && typeof endTime === 'number') {
241
+ const timerDuration = Date.now() - startTime + adjustment;
242
+ const executionDuration = endTime - startTime;
243
+ const renderDuration = this._cell.internalMetadata.renderDuration ?? {};
244
+ timerItem = this._getTimeItem(startTime, endTime, undefined, {
245
+ timerDuration,
246
+ executionDuration,
247
+ renderDuration
248
+ });
249
+ }
250
+ }
251
+ const items = timerItem ? [timerItem] : [];
252
+ if (!items.length && !!runState) {
253
+ if (!this._deferredUpdate) {
254
+ this._deferredUpdate = disposableTimeout(() => {
255
+ this._deferredUpdate = undefined;
256
+ this._currentItemIds = this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items }]);
257
+ }, UPDATE_TIMER_GRACE_PERIOD);
258
+ }
259
+ }
260
+ else {
261
+ this._deferredUpdate?.dispose();
262
+ this._deferredUpdate = undefined;
263
+ this._currentItemIds = this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items }]);
264
+ }
265
+ }
266
+ _getTimeItem(startTime, endTime, adjustment = 0, runtimeInformation) {
267
+ const duration = endTime - startTime + adjustment;
268
+ let tooltip;
269
+ if (runtimeInformation) {
270
+ const lastExecution = ( new Date(endTime)).toLocaleTimeString(language);
271
+ const { renderDuration, executionDuration, timerDuration } = runtimeInformation;
272
+ let renderTimes = '';
273
+ for (const key in renderDuration) {
274
+ const rendererInfo = this._notebookService.getRendererInfo(key);
275
+ const args = encodeURIComponent(JSON.stringify({
276
+ extensionId: rendererInfo?.extensionId.value ?? '',
277
+ issueBody: `Auto-generated text from notebook cell performance. The duration for the renderer, ${rendererInfo?.displayName ?? key}, is slower than expected.\n` +
278
+ `Execution Time: ${formatCellDuration(executionDuration)}\n` +
279
+ `Renderer Duration: ${formatCellDuration(renderDuration[key])}\n`
280
+ }));
281
+ renderTimes += `- [${rendererInfo?.displayName ?? key}](command:workbench.action.openIssueReporter?${args}) ${formatCellDuration(renderDuration[key])}\n`;
282
+ }
283
+ renderTimes += `\n*${( localizeWithPath(
284
+ 'vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController',
285
+ 'notebook.cell.statusBar.timerTooltip.reportIssueFootnote',
286
+ "Use the links above to file an issue using the issue reporter."
287
+ ))}*\n`;
288
+ tooltip = {
289
+ value: ( localizeWithPath(
290
+ 'vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController',
291
+ 'notebook.cell.statusBar.timerTooltip',
292
+ "**Last Execution** {0}\n\n**Execution Time** {1}\n\n**Overhead Time** {2}\n\n**Render Times**\n\n{3}",
293
+ lastExecution,
294
+ formatCellDuration(executionDuration),
295
+ formatCellDuration(timerDuration - executionDuration),
296
+ renderTimes
297
+ )),
298
+ isTrusted: true
299
+ };
300
+ }
301
+ return {
302
+ text: formatCellDuration(duration, false),
303
+ alignment: 1 ,
304
+ priority: Number.MAX_SAFE_INTEGER - 5,
305
+ tooltip
306
+ };
307
+ }
308
+ dispose() {
309
+ super.dispose();
310
+ this._deferredUpdate?.dispose();
311
+ this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items: [] }]);
312
+ }
313
+ };
314
+ TimerCellStatusBarItem = TimerCellStatusBarItem_1 = ( __decorate([
315
+ ( __param(2, INotebookExecutionStateService)),
316
+ ( __param(3, INotebookService))
317
+ ], TimerCellStatusBarItem));
318
+
319
+ export { ExecutionStateCellStatusBarContrib, NotebookStatusBarController, TimerCellStatusBarContrib, formatCellDuration };
@@ -0,0 +1,58 @@
1
+ import { diffSets } from 'monaco-editor/esm/vs/base/common/collections.js';
2
+ import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
3
+ import { Disposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { isDefined } from 'monaco-editor/esm/vs/base/common/types.js';
5
+ import { cellRangesToIndexes } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookRange';
6
+
7
+ class NotebookVisibleCellObserver extends Disposable {
8
+ get visibleCells() {
9
+ return this._visibleCells;
10
+ }
11
+ constructor(_notebookEditor) {
12
+ super();
13
+ this._notebookEditor = _notebookEditor;
14
+ this._onDidChangeVisibleCells = this._register(( new Emitter()));
15
+ this.onDidChangeVisibleCells = this._onDidChangeVisibleCells.event;
16
+ this._viewModelDisposables = this._register(( new DisposableStore()));
17
+ this._visibleCells = [];
18
+ this._register(this._notebookEditor.onDidChangeVisibleRanges(this._updateVisibleCells, this));
19
+ this._register(this._notebookEditor.onDidChangeModel(this._onModelChange, this));
20
+ this._updateVisibleCells();
21
+ }
22
+ _onModelChange() {
23
+ this._viewModelDisposables.clear();
24
+ if (this._notebookEditor.hasModel()) {
25
+ this._viewModelDisposables.add(this._notebookEditor.onDidChangeViewCells(() => this.updateEverything()));
26
+ }
27
+ this.updateEverything();
28
+ }
29
+ updateEverything() {
30
+ this._onDidChangeVisibleCells.fire({ added: [], removed: Array.from(this._visibleCells) });
31
+ this._visibleCells = [];
32
+ this._updateVisibleCells();
33
+ }
34
+ _updateVisibleCells() {
35
+ if (!this._notebookEditor.hasModel()) {
36
+ return;
37
+ }
38
+ const newVisibleCells = ( cellRangesToIndexes(this._notebookEditor.visibleRanges)
39
+ .map(index => this._notebookEditor.cellAt(index)))
40
+ .filter(isDefined);
41
+ const newVisibleHandles = ( new Set(( newVisibleCells.map(cell => cell.handle))));
42
+ const oldVisibleHandles = ( new Set(( this._visibleCells.map(cell => cell.handle))));
43
+ const diff = diffSets(oldVisibleHandles, newVisibleHandles);
44
+ const added = ( diff.added
45
+ .map(handle => this._notebookEditor.getCellByHandle(handle)))
46
+ .filter(isDefined);
47
+ const removed = ( diff.removed
48
+ .map(handle => this._notebookEditor.getCellByHandle(handle)))
49
+ .filter(isDefined);
50
+ this._visibleCells = newVisibleCells;
51
+ this._onDidChangeVisibleCells.fire({
52
+ added,
53
+ removed
54
+ });
55
+ }
56
+ }
57
+
58
+ export { NotebookVisibleCellObserver };
@@ -0,0 +1,173 @@
1
+ import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
3
+ import { ResourceMap } from 'monaco-editor/esm/vs/base/common/map.js';
4
+ import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
5
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
6
+ import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
7
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
8
+ import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
9
+ import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
10
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
11
+ import { CHANGE_CELL_LANGUAGE, DETECT_CELL_LANGUAGE } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
12
+ import { INotebookCellStatusBarService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCellStatusBarService';
13
+ import { CellKind } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
14
+ import { INotebookKernelService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookKernelService';
15
+ import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
16
+ import { ILanguageDetectionService } from 'vscode/vscode/vs/workbench/services/languageDetection/common/languageDetectionWorkerService';
17
+
18
+ let CellStatusBarLanguagePickerProvider = class CellStatusBarLanguagePickerProvider {
19
+ constructor(_notebookService, _languageService) {
20
+ this._notebookService = _notebookService;
21
+ this._languageService = _languageService;
22
+ this.viewType = '*';
23
+ }
24
+ async provideCellStatusBarItems(uri, index, _token) {
25
+ const doc = this._notebookService.getNotebookTextModel(uri);
26
+ const cell = doc?.cells[index];
27
+ if (!cell) {
28
+ return;
29
+ }
30
+ const statusBarItems = [];
31
+ let displayLanguage = cell.language;
32
+ if (cell.cellKind === CellKind.Markup) {
33
+ displayLanguage = 'markdown';
34
+ }
35
+ else {
36
+ const registeredId = this._languageService.getLanguageIdByLanguageName(cell.language);
37
+ if (registeredId) {
38
+ displayLanguage = this._languageService.getLanguageName(displayLanguage) ?? displayLanguage;
39
+ }
40
+ else {
41
+ const searchTooltip = ( localizeWithPath(
42
+ 'vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders',
43
+ 'notebook.cell.status.searchLanguageExtensions',
44
+ "Unknown cell language. Click to search for '{0}' extensions",
45
+ cell.language
46
+ ));
47
+ statusBarItems.push({
48
+ text: `$(dialog-warning)`,
49
+ command: { id: 'workbench.extensions.search', arguments: [`@tag:${cell.language}`], title: 'Search Extensions' },
50
+ tooltip: searchTooltip,
51
+ alignment: 2 ,
52
+ priority: -Number.MAX_SAFE_INTEGER + 1
53
+ });
54
+ }
55
+ }
56
+ statusBarItems.push({
57
+ text: displayLanguage,
58
+ command: CHANGE_CELL_LANGUAGE,
59
+ tooltip: ( localizeWithPath(
60
+ 'vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders',
61
+ 'notebook.cell.status.language',
62
+ "Select Cell Language Mode"
63
+ )),
64
+ alignment: 2 ,
65
+ priority: -Number.MAX_SAFE_INTEGER
66
+ });
67
+ return {
68
+ items: statusBarItems
69
+ };
70
+ }
71
+ };
72
+ CellStatusBarLanguagePickerProvider = ( __decorate([
73
+ ( __param(0, INotebookService)),
74
+ ( __param(1, ILanguageService))
75
+ ], CellStatusBarLanguagePickerProvider));
76
+ let CellStatusBarLanguageDetectionProvider = class CellStatusBarLanguageDetectionProvider {
77
+ constructor(_notebookService, _notebookKernelService, _languageService, _configurationService, _languageDetectionService, _keybindingService) {
78
+ this._notebookService = _notebookService;
79
+ this._notebookKernelService = _notebookKernelService;
80
+ this._languageService = _languageService;
81
+ this._configurationService = _configurationService;
82
+ this._languageDetectionService = _languageDetectionService;
83
+ this._keybindingService = _keybindingService;
84
+ this.viewType = '*';
85
+ this.cache = ( new ResourceMap());
86
+ }
87
+ async provideCellStatusBarItems(uri, index, token) {
88
+ const doc = this._notebookService.getNotebookTextModel(uri);
89
+ const cell = doc?.cells[index];
90
+ if (!cell) {
91
+ return;
92
+ }
93
+ const enablementConfig = this._configurationService.getValue('workbench.editor.languageDetectionHints');
94
+ const enabled = typeof enablementConfig === 'object' && enablementConfig?.notebookEditors;
95
+ if (!enabled) {
96
+ return;
97
+ }
98
+ const cellUri = cell.uri;
99
+ const contentVersion = cell.textModel?.getVersionId();
100
+ if (!contentVersion) {
101
+ return;
102
+ }
103
+ const currentLanguageId = cell.cellKind === CellKind.Markup ?
104
+ 'markdown' :
105
+ (this._languageService.getLanguageIdByLanguageName(cell.language) || cell.language);
106
+ if (!( this.cache.has(cellUri))) {
107
+ this.cache.set(cellUri, {
108
+ cellLanguage: currentLanguageId,
109
+ updateTimestamp: 0,
110
+ contentVersion: 1,
111
+ });
112
+ }
113
+ const cached = this.cache.get(cellUri);
114
+ if (cached.cellLanguage !== currentLanguageId || (cached.updateTimestamp < Date.now() - 1000 && cached.contentVersion !== contentVersion)) {
115
+ cached.updateTimestamp = Date.now();
116
+ cached.cellLanguage = currentLanguageId;
117
+ cached.contentVersion = contentVersion;
118
+ const kernel = this._notebookKernelService.getSelectedOrSuggestedKernel(doc);
119
+ if (kernel) {
120
+ const supportedLangs = [...kernel.supportedLanguages, 'markdown'];
121
+ cached.guess = await this._languageDetectionService.detectLanguage(cell.uri, supportedLangs);
122
+ }
123
+ }
124
+ const items = [];
125
+ if (cached.guess && currentLanguageId !== cached.guess) {
126
+ const detectedName = this._languageService.getLanguageName(cached.guess) || cached.guess;
127
+ let tooltip = ( localizeWithPath(
128
+ 'vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders',
129
+ 'notebook.cell.status.autoDetectLanguage',
130
+ "Accept Detected Language: {0}",
131
+ detectedName
132
+ ));
133
+ const keybinding = this._keybindingService.lookupKeybinding(DETECT_CELL_LANGUAGE);
134
+ const label = keybinding?.getLabel();
135
+ if (label) {
136
+ tooltip += ` (${label})`;
137
+ }
138
+ items.push({
139
+ text: '$(lightbulb-autofix)',
140
+ command: DETECT_CELL_LANGUAGE,
141
+ tooltip,
142
+ alignment: 2 ,
143
+ priority: -Number.MAX_SAFE_INTEGER + 1
144
+ });
145
+ }
146
+ return { items };
147
+ }
148
+ };
149
+ CellStatusBarLanguageDetectionProvider = ( __decorate([
150
+ ( __param(0, INotebookService)),
151
+ ( __param(1, INotebookKernelService)),
152
+ ( __param(2, ILanguageService)),
153
+ ( __param(3, IConfigurationService)),
154
+ ( __param(4, ILanguageDetectionService)),
155
+ ( __param(5, IKeybindingService))
156
+ ], CellStatusBarLanguageDetectionProvider));
157
+ let BuiltinCellStatusBarProviders = class BuiltinCellStatusBarProviders extends Disposable {
158
+ constructor(instantiationService, notebookCellStatusBarService) {
159
+ super();
160
+ const builtinProviders = [
161
+ CellStatusBarLanguagePickerProvider,
162
+ CellStatusBarLanguageDetectionProvider,
163
+ ];
164
+ builtinProviders.forEach(p => {
165
+ this._register(notebookCellStatusBarService.registerCellStatusBarItemProvider(instantiationService.createInstance(p)));
166
+ });
167
+ }
168
+ };
169
+ BuiltinCellStatusBarProviders = ( __decorate([
170
+ ( __param(0, IInstantiationService)),
171
+ ( __param(1, INotebookCellStatusBarService))
172
+ ], BuiltinCellStatusBarProviders));
173
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(BuiltinCellStatusBarProviders, 3 );