@theia/notebook 1.56.0 → 1.57.0-next.136

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 (52) hide show
  1. package/README.md +2 -1
  2. package/lib/browser/contributions/notebook-cell-actions-contribution.js +1 -1
  3. package/lib/browser/contributions/notebook-cell-actions-contribution.js.map +1 -1
  4. package/lib/browser/notebook-editor-widget-factory.d.ts.map +1 -1
  5. package/lib/browser/notebook-editor-widget-factory.js +10 -1
  6. package/lib/browser/notebook-editor-widget-factory.js.map +1 -1
  7. package/lib/browser/notebook-editor-widget.d.ts +2 -0
  8. package/lib/browser/notebook-editor-widget.d.ts.map +1 -1
  9. package/lib/browser/notebook-editor-widget.js +10 -0
  10. package/lib/browser/notebook-editor-widget.js.map +1 -1
  11. package/lib/browser/renderers/cell-output-webview.d.ts +0 -1
  12. package/lib/browser/renderers/cell-output-webview.d.ts.map +1 -1
  13. package/lib/browser/service/notebook-execution-service.d.ts +2 -1
  14. package/lib/browser/service/notebook-execution-service.d.ts.map +1 -1
  15. package/lib/browser/service/notebook-execution-service.js +18 -0
  16. package/lib/browser/service/notebook-execution-service.js.map +1 -1
  17. package/lib/browser/service/notebook-execution-state-service.d.ts +0 -1
  18. package/lib/browser/service/notebook-execution-state-service.d.ts.map +1 -1
  19. package/lib/browser/service/notebook-execution-state-service.js +0 -4
  20. package/lib/browser/service/notebook-execution-state-service.js.map +1 -1
  21. package/lib/browser/service/notebook-kernel-quick-pick-service.d.ts +4 -3
  22. package/lib/browser/service/notebook-kernel-quick-pick-service.d.ts.map +1 -1
  23. package/lib/browser/service/notebook-kernel-quick-pick-service.js +13 -0
  24. package/lib/browser/service/notebook-kernel-quick-pick-service.js.map +1 -1
  25. package/lib/browser/service/notebook-model-resolver-service.d.ts.map +1 -1
  26. package/lib/browser/service/notebook-model-resolver-service.js +13 -6
  27. package/lib/browser/service/notebook-model-resolver-service.js.map +1 -1
  28. package/lib/browser/service/notebook-options.js +2 -2
  29. package/lib/browser/service/notebook-options.js.map +1 -1
  30. package/lib/browser/view/notebook-cell-list-view.js +1 -1
  31. package/lib/browser/view/notebook-cell-list-view.js.map +1 -1
  32. package/lib/browser/view-model/notebook-model.d.ts +1 -0
  33. package/lib/browser/view-model/notebook-model.d.ts.map +1 -1
  34. package/lib/browser/view-model/notebook-model.js +10 -1
  35. package/lib/browser/view-model/notebook-model.js.map +1 -1
  36. package/lib/common/notebook-common.d.ts +5 -0
  37. package/lib/common/notebook-common.d.ts.map +1 -1
  38. package/lib/common/notebook-common.js.map +1 -1
  39. package/package.json +9 -9
  40. package/src/browser/contributions/notebook-cell-actions-contribution.ts +1 -1
  41. package/src/browser/notebook-editor-widget-factory.ts +12 -1
  42. package/src/browser/notebook-editor-widget.tsx +13 -2
  43. package/src/browser/renderers/cell-output-webview.ts +0 -2
  44. package/src/browser/service/notebook-execution-service.ts +20 -2
  45. package/src/browser/service/notebook-execution-state-service.ts +0 -5
  46. package/src/browser/service/notebook-kernel-quick-pick-service.ts +14 -6
  47. package/src/browser/service/notebook-model-resolver-service.ts +13 -6
  48. package/src/browser/service/notebook-options.ts +2 -2
  49. package/src/browser/style/index.css +35 -13
  50. package/src/browser/view/notebook-cell-list-view.tsx +1 -1
  51. package/src/browser/view-model/notebook-model.ts +10 -1
  52. package/src/common/notebook-common.ts +5 -0
@@ -18,13 +18,13 @@
18
18
  * Licensed under the MIT License. See License.txt in the project root for license information.
19
19
  *--------------------------------------------------------------------------------------------*/
20
20
 
21
- import { inject, injectable } from '@theia/core/shared/inversify';
21
+ import { inject, injectable, named } from '@theia/core/shared/inversify';
22
22
  import { CellExecution, NotebookExecutionStateService } from '../service/notebook-execution-state-service';
23
23
  import { CellKind, NotebookCellExecutionState } from '../../common';
24
24
  import { NotebookCellModel } from '../view-model/notebook-cell-model';
25
25
  import { NotebookModel } from '../view-model/notebook-model';
26
26
  import { NotebookKernelService } from './notebook-kernel-service';
27
- import { CommandService, Disposable } from '@theia/core';
27
+ import { CommandService, Disposable, ILogger } from '@theia/core';
28
28
  import { NotebookKernelQuickPickService } from './notebook-kernel-quick-pick-service';
29
29
  import { NotebookKernelHistoryService } from './notebook-kernel-history-service';
30
30
 
@@ -50,6 +50,9 @@ export class NotebookExecutionService {
50
50
  @inject(NotebookKernelQuickPickService)
51
51
  protected notebookKernelQuickPickService: NotebookKernelQuickPickService;
52
52
 
53
+ @inject(ILogger) @named('notebook')
54
+ protected readonly logger: ILogger;
55
+
53
56
  protected readonly cellExecutionParticipants = new Set<CellExecutionParticipant>();
54
57
 
55
58
  async executeNotebookCells(notebook: NotebookModel, cells: Iterable<NotebookCellModel>): Promise<void> {
@@ -59,6 +62,11 @@ export class NotebookExecutionService {
59
62
  return;
60
63
  }
61
64
 
65
+ this.logger.debug('Executing notebook cells', {
66
+ notebook: notebook.uri.toString(),
67
+ cells: cellsArr.map(c => c.handle)
68
+ });
69
+
62
70
  // create cell executions
63
71
  const cellExecutions: [NotebookCellModel, CellExecution][] = [];
64
72
  for (const cell of cellsArr) {
@@ -71,6 +79,7 @@ export class NotebookExecutionService {
71
79
  const kernel = await this.notebookKernelHistoryService.resolveSelectedKernel(notebook);
72
80
 
73
81
  if (!kernel) {
82
+ this.logger.debug('Failed to resolve kernel for execution', notebook.uri.toString());
74
83
  // clear all pending cell executions
75
84
  cellExecutions.forEach(cellExe => cellExe[1].complete({}));
76
85
  return;
@@ -99,7 +108,16 @@ export class NotebookExecutionService {
99
108
  });
100
109
  await this.runExecutionParticipants(validCellExecutions);
101
110
 
111
+ this.logger.debug('Selecting kernel for cell execution', {
112
+ notebook: notebook.uri.toString(),
113
+ kernel: kernel.id
114
+ });
102
115
  this.notebookKernelService.selectKernelForNotebook(kernel, notebook);
116
+
117
+ this.logger.debug('Running cell execution request', {
118
+ notebook: notebook.uri.toString(),
119
+ cells: validCellExecutions.map(c => c.cellHandle)
120
+ });
103
121
  await kernel.executeNotebookCellsRequest(notebook.uri, validCellExecutions.map(c => c.cellHandle));
104
122
  // the connecting state can change before the kernel resolves executeNotebookCellsRequest
105
123
  const unconfirmed = validCellExecutions.filter(exe => exe.state === NotebookCellExecutionState.Unconfirmed);
@@ -169,7 +169,6 @@ export class CellExecution implements Disposable {
169
169
  readonly cellHandle: number,
170
170
  protected readonly notebook: NotebookModel,
171
171
  ) {
172
- console.debug(`CellExecution#ctor ${this.getCellLog()}`);
173
172
  }
174
173
 
175
174
  initialize(): void {
@@ -188,10 +187,6 @@ export class CellExecution implements Disposable {
188
187
  this.applyCellExecutionEditsToNotebook([startExecuteEdit]);
189
188
  }
190
189
 
191
- protected getCellLog(): string {
192
- return `${this.notebookURI.toString()}, ${this.cellHandle}`;
193
- }
194
-
195
190
  confirm(): void {
196
191
  this._state = NotebookCellExecutionState.Pending;
197
192
  this.onDidUpdateEmitter.fire();
@@ -18,8 +18,8 @@
18
18
  * Copyright (c) Microsoft Corporation. All rights reserved.
19
19
  * Licensed under the MIT License. See License.txt in the project root for license information.
20
20
  *--------------------------------------------------------------------------------------------*/
21
- import { ArrayUtils, CommandService, DisposableCollection, Event, nls, QuickInputButton, QuickInputService, QuickPickInput, QuickPickItem, URI, } from '@theia/core';
22
- import { inject, injectable } from '@theia/core/shared/inversify';
21
+ import { ArrayUtils, CommandService, DisposableCollection, Event, ILogger, nls, QuickInputButton, QuickInputService, QuickPickInput, QuickPickItem, URI, } from '@theia/core';
22
+ import { inject, injectable, named } from '@theia/core/shared/inversify';
23
23
  import { NotebookKernelService, NotebookKernel, NotebookKernelMatchResult, SourceCommand } from './notebook-kernel-service';
24
24
  import { NotebookModel } from '../view-model/notebook-model';
25
25
  import { NotebookEditorWidget } from '../notebook-editor-widget';
@@ -89,12 +89,12 @@ export class NotebookKernelQuickPickService {
89
89
  protected readonly quickInputService: QuickInputService;
90
90
  @inject(CommandService)
91
91
  protected readonly commandService: CommandService;
92
-
93
92
  @inject(OpenerService)
94
- protected openerService: OpenerService;
95
-
93
+ protected readonly openerService: OpenerService;
96
94
  @inject(NotebookKernelHistoryService)
97
- protected notebookKernelHistoryService: NotebookKernelHistoryService;
95
+ protected readonly notebookKernelHistoryService: NotebookKernelHistoryService;
96
+ @inject(ILogger) @named('notebook')
97
+ protected readonly logger: ILogger;
98
98
 
99
99
  async showQuickPick(editor: NotebookModel, wantedId?: string, skipAutoRun?: boolean): Promise<boolean> {
100
100
  const notebook = editor;
@@ -238,6 +238,10 @@ export class NotebookKernelQuickPickService {
238
238
  }
239
239
 
240
240
  protected selectKernel(notebook: NotebookModel, kernel: NotebookKernel): void {
241
+ this.logger.debug('Selected notebook kernel', {
242
+ notebook: notebook.uri.toString(),
243
+ kernel: kernel.id
244
+ });
241
245
  const currentInfo = this.notebookKernelService.getMatchingKernel(notebook);
242
246
  if (currentInfo.selected) {
243
247
  // there is already a selected kernel
@@ -270,6 +274,10 @@ export class NotebookKernelQuickPickService {
270
274
  }
271
275
 
272
276
  if (isSourcePick(pick)) {
277
+ this.logger.debug('Selected notebook kernel command', {
278
+ notebook: editor.uri.toString(),
279
+ command: pick.action.command.id
280
+ });
273
281
  // selected explicitly, it should trigger the execution?
274
282
  pick.action.run(this.commandService);
275
283
  }
@@ -65,14 +65,21 @@ export class NotebookModelResolverService {
65
65
  throw new Error(`Missing viewType for '${resource}'`);
66
66
  }
67
67
 
68
- const actualResource = await this.resourceProvider(resource);
69
- const notebookData = await this.resolveExistingNotebookData(actualResource, viewType!);
70
- const notebookModel = await this.notebookService.createNotebookModel(notebookData, viewType, actualResource);
68
+ try {
71
69
 
72
- notebookModel.onDirtyChanged(() => this.onDidChangeDirtyEmitter.fire(notebookModel));
73
- notebookModel.onDidSaveNotebook(() => this.onDidSaveNotebookEmitter.fire(notebookModel.uri.toComponents()));
70
+ const actualResource = await this.resourceProvider(resource);
71
+ const notebookData = await this.resolveExistingNotebookData(actualResource, viewType!);
72
+ const notebookModel = await this.notebookService.createNotebookModel(notebookData, viewType, actualResource);
74
73
 
75
- return notebookModel;
74
+ notebookModel.onDirtyChanged(() => this.onDidChangeDirtyEmitter.fire(notebookModel));
75
+ notebookModel.onDidSaveNotebook(() => this.onDidSaveNotebookEmitter.fire(notebookModel.uri.toComponents()));
76
+
77
+ return notebookModel;
78
+ } catch (e) {
79
+ const message = `Error resolving notebook model for: \n ${resource.path.fsPath()} \n with view type ${viewType}. \n ${e}`;
80
+ console.error(message);
81
+ throw new Error(message);
82
+ }
76
83
  }
77
84
 
78
85
  async resolveUntitledResource(arg: UntitledResource, viewType: string): Promise<NotebookModel> {
@@ -21,7 +21,7 @@ import { Emitter } from '@theia/core';
21
21
  import { NotebookPreferences, notebookPreferenceSchema } from '../contributions/notebook-preferences';
22
22
  import { EditorPreferences } from '@theia/editor/lib/browser';
23
23
  import { BareFontInfo } from '@theia/monaco-editor-core/esm/vs/editor/common/config/fontInfo';
24
- import { PixelRatio } from '@theia/monaco-editor-core/esm/vs/base/browser/browser';
24
+ import { PixelRatio } from '@theia/monaco-editor-core/esm/vs/base/browser/pixelRatio';
25
25
 
26
26
  const notebookOutputOptionsRelevantPreferences = [
27
27
  'editor.fontSize',
@@ -149,7 +149,7 @@ export class NotebookOptionsService {
149
149
  fontLigatures: this.editorPreferences['editor.fontLigatures'],
150
150
  lineHeight: this.editorPreferences['editor.lineHeight'],
151
151
  letterSpacing: this.editorPreferences['editor.letterSpacing'],
152
- }, PixelRatio.value);
152
+ }, PixelRatio.getInstance(window).value);
153
153
  }
154
154
 
155
155
  }
@@ -31,7 +31,6 @@
31
31
  pointer-events: none;
32
32
  }
33
33
 
34
-
35
34
  .theia-notebook-cell-output-webview {
36
35
  padding: 5px 0px;
37
36
  margin: 0px 15px 0px 50px;
@@ -77,7 +76,8 @@
77
76
 
78
77
  .theia-notebook-cell-content {
79
78
  flex: 1;
80
- width: calc(100% - 15px);
79
+ /* needs this set width because of monaco. 56px is sidebar + gap to sidebar */
80
+ width: calc(100% - 56px);
81
81
  }
82
82
 
83
83
  /* Rendered Markdown Content */
@@ -88,16 +88,16 @@
88
88
  font-size: var(--theia-notebook-markdown-size);
89
89
  }
90
90
 
91
- .theia-notebook-markdown-content>* {
91
+ .theia-notebook-markdown-content > * {
92
92
  font-weight: 400;
93
93
  }
94
94
 
95
- .theia-notebook-markdown-content>*:first-child {
95
+ .theia-notebook-markdown-content > *:first-child {
96
96
  margin-top: 0;
97
97
  padding-top: 0;
98
98
  }
99
99
 
100
- .theia-notebook-markdown-content>*:last-child {
100
+ .theia-notebook-markdown-content > *:last-child {
101
101
  margin-bottom: 0;
102
102
  padding-bottom: 0;
103
103
  }
@@ -107,14 +107,19 @@
107
107
  }
108
108
 
109
109
  /* Markdown cell edit mode */
110
- .theia-notebook-cell-content:has(.theia-notebook-markdown-editor-container>.theia-notebook-cell-editor) {
110
+ .theia-notebook-cell-content:has(
111
+ .theia-notebook-markdown-editor-container > .theia-notebook-cell-editor
112
+ ) {
111
113
  pointer-events: all;
112
114
  margin-right: var(--theia-notebook-cell-editor-margin-right);
113
115
  outline: 1px solid var(--theia-notebook-cellBorderColor);
114
116
  }
115
117
 
116
118
  /* Markdown cell edit mode focused */
117
- .theia-notebook-cell.focused .theia-notebook-cell-content:has(.theia-notebook-markdown-editor-container>.theia-notebook-cell-editor) {
119
+ .theia-notebook-cell.focused
120
+ .theia-notebook-cell-content:has(
121
+ .theia-notebook-markdown-editor-container > .theia-notebook-cell-editor
122
+ ) {
118
123
  outline-color: var(--theia-notebook-focusedEditorBorder);
119
124
  }
120
125
 
@@ -126,6 +131,10 @@
126
131
  padding: 10px 10px 0 10px;
127
132
  }
128
133
 
134
+ .theia-notebook-cell-editor .monaco-editor {
135
+ outline: none;
136
+ }
137
+
129
138
  .theia-notebook-cell-editor-container {
130
139
  pointer-events: all;
131
140
  width: calc(100% - 46px);
@@ -242,11 +251,23 @@
242
251
 
243
252
  .theia-notebook-main-container .theia-notebook-main-loading-indicator {
244
253
  /* `progress-animation` is defined in `packages/core/src/browser/style/progress-bar.css` */
245
- animation: progress-animation 1.8s 0s infinite cubic-bezier(0.645, 0.045, 0.355, 1);
254
+ animation: progress-animation 1.8s 0s infinite
255
+ cubic-bezier(0.645, 0.045, 0.355, 1);
246
256
  background-color: var(--theia-progressBar-background);
247
257
  height: 2px;
248
258
  }
249
259
 
260
+ .error-message {
261
+ justify-content: center;
262
+ margin: 0 50px;
263
+ text-align: center;
264
+ }
265
+
266
+ .error-message > span {
267
+ color: var(--theia-errorForeground);
268
+ font-size: 40px !important;
269
+ }
270
+
250
271
  .theia-notebook-viewport {
251
272
  display: flex;
252
273
  overflow: hidden;
@@ -317,7 +338,7 @@
317
338
  background-color: var(--theia-toolbar-active);
318
339
  }
319
340
 
320
- .theia-notebook-add-cell-button>* {
341
+ .theia-notebook-add-cell-button > * {
321
342
  vertical-align: middle;
322
343
  }
323
344
 
@@ -393,7 +414,7 @@
393
414
  transform: translateY(calc(-100% - 10px));
394
415
  }
395
416
 
396
- .theia-notebook-find-widget.search-mode>*>*:nth-child(2) {
417
+ .theia-notebook-find-widget.search-mode > * > *:nth-child(2) {
397
418
  display: none;
398
419
  }
399
420
 
@@ -422,8 +443,8 @@
422
443
  align-items: center;
423
444
  }
424
445
 
425
- .theia-notebook-find-widget-buttons-first>div,
426
- .theia-notebook-find-widget-buttons-second>div {
446
+ .theia-notebook-find-widget-buttons-first > div,
447
+ .theia-notebook-find-widget-buttons-second > div {
427
448
  margin-right: 4px;
428
449
  }
429
450
 
@@ -481,7 +502,8 @@
481
502
  margin: 2px;
482
503
  }
483
504
 
484
- .theia-notebook-find-widget-input-wrapper .theia-notebook-find-widget-input:focus {
505
+ .theia-notebook-find-widget-input-wrapper
506
+ .theia-notebook-find-widget-input:focus {
485
507
  border: none;
486
508
  outline: none;
487
509
  }
@@ -120,7 +120,7 @@ export class NotebookCellListView extends React.Component<CellListProps, Noteboo
120
120
 
121
121
  override render(): React.ReactNode {
122
122
  return <ul className='theia-notebook-cell-list' ref={this.cellListRef} onDragStart={e => this.onDragStart(e)}>
123
- {this.props.notebookModel.cells
123
+ {this.props.notebookModel.getVisibleCells()
124
124
  .map((cell, index) =>
125
125
  <React.Fragment key={'cell-' + cell.handle}>
126
126
  <NotebookCellDivider
@@ -289,6 +289,10 @@ export class NotebookModel implements Saveable, Disposable {
289
289
  }
290
290
  }
291
291
 
292
+ getVisibleCells(): NotebookCellModel[] {
293
+ return this.cells;
294
+ }
295
+
292
296
  applyEdits(rawEdits: CellEditOperation[], computeUndoRedo: boolean): void {
293
297
  const editsWithDetails = rawEdits.map((edit, index) => {
294
298
  let cellIndex: number = -1;
@@ -390,7 +394,12 @@ export class NotebookModel implements Saveable, Disposable {
390
394
  });
391
395
  this.addCellOutputListeners(cells);
392
396
 
393
- const changes: NotebookCellTextModelSplice<NotebookCellModel>[] = [{ start, deleteCount, newItems: cells }];
397
+ const changes: NotebookCellTextModelSplice<NotebookCellModel>[] = [{
398
+ start,
399
+ deleteCount,
400
+ newItems: cells,
401
+ startHandle: this.cells[start]?.handle ?? -1 // -1 in case of new Cells are added at the end.
402
+ }];
394
403
 
395
404
  const deletedCells = this.cells.splice(start, deleteCount, ...cells);
396
405
 
@@ -126,6 +126,11 @@ export interface NotebookCellTextModelSplice<T> {
126
126
  start: number,
127
127
  deleteCount: number,
128
128
  newItems: T[]
129
+ /**
130
+ * In case of e.g. deletion, the handle of the first cell that was deleted.
131
+ * -1 in case of new Cells are added at the end.
132
+ */
133
+ startHandle: number,
129
134
  };
130
135
 
131
136
  export enum NotebookCellsChangeType {