@theia/notebook 1.67.0-next.56 → 1.67.0-next.59

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 (229) hide show
  1. package/lib/browser/contributions/cell-operations.d.ts +8 -0
  2. package/lib/browser/contributions/cell-operations.d.ts.map +1 -0
  3. package/lib/browser/contributions/cell-operations.js +45 -0
  4. package/lib/browser/contributions/cell-operations.js.map +1 -0
  5. package/lib/browser/contributions/notebook-actions-contribution.d.ts +48 -0
  6. package/lib/browser/contributions/notebook-actions-contribution.d.ts.map +1 -0
  7. package/lib/browser/contributions/notebook-actions-contribution.js +344 -0
  8. package/lib/browser/contributions/notebook-actions-contribution.js.map +1 -0
  9. package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts +66 -0
  10. package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts.map +1 -0
  11. package/lib/browser/contributions/notebook-cell-actions-contribution.js +526 -0
  12. package/lib/browser/contributions/notebook-cell-actions-contribution.js.map +1 -0
  13. package/lib/browser/contributions/notebook-color-contribution.d.ts +6 -0
  14. package/lib/browser/contributions/notebook-color-contribution.d.ts.map +1 -0
  15. package/lib/browser/contributions/notebook-color-contribution.js +247 -0
  16. package/lib/browser/contributions/notebook-color-contribution.js.map +1 -0
  17. package/lib/browser/contributions/notebook-context-keys.d.ts +44 -0
  18. package/lib/browser/contributions/notebook-context-keys.d.ts.map +1 -0
  19. package/lib/browser/contributions/notebook-context-keys.js +108 -0
  20. package/lib/browser/contributions/notebook-context-keys.js.map +1 -0
  21. package/lib/browser/contributions/notebook-label-provider-contribution.d.ts +19 -0
  22. package/lib/browser/contributions/notebook-label-provider-contribution.d.ts.map +1 -0
  23. package/lib/browser/contributions/notebook-label-provider-contribution.js +86 -0
  24. package/lib/browser/contributions/notebook-label-provider-contribution.js.map +1 -0
  25. package/lib/browser/contributions/notebook-outline-contribution.d.ts +29 -0
  26. package/lib/browser/contributions/notebook-outline-contribution.d.ts.map +1 -0
  27. package/lib/browser/contributions/notebook-outline-contribution.js +115 -0
  28. package/lib/browser/contributions/notebook-outline-contribution.js.map +1 -0
  29. package/lib/browser/contributions/notebook-output-action-contribution.d.ts +16 -0
  30. package/lib/browser/contributions/notebook-output-action-contribution.d.ts.map +1 -0
  31. package/lib/browser/contributions/notebook-output-action-contribution.js +83 -0
  32. package/lib/browser/contributions/notebook-output-action-contribution.js.map +1 -0
  33. package/lib/browser/contributions/notebook-status-bar-contribution.d.ts +12 -0
  34. package/lib/browser/contributions/notebook-status-bar-contribution.d.ts.map +1 -0
  35. package/lib/browser/contributions/notebook-status-bar-contribution.js +61 -0
  36. package/lib/browser/contributions/notebook-status-bar-contribution.js.map +1 -0
  37. package/lib/browser/contributions/notebook-undo-redo-handler.d.ts +10 -0
  38. package/lib/browser/contributions/notebook-undo-redo-handler.d.ts.map +1 -0
  39. package/lib/browser/contributions/notebook-undo-redo-handler.js +49 -0
  40. package/lib/browser/contributions/notebook-undo-redo-handler.js.map +1 -0
  41. package/lib/browser/index.d.ts +14 -0
  42. package/lib/browser/index.d.ts.map +1 -0
  43. package/lib/browser/index.js +32 -0
  44. package/lib/browser/index.js.map +1 -0
  45. package/lib/browser/notebook-cell-open-handler.d.ts +10 -0
  46. package/lib/browser/notebook-cell-open-handler.d.ts.map +1 -0
  47. package/lib/browser/notebook-cell-open-handler.js +52 -0
  48. package/lib/browser/notebook-cell-open-handler.js.map +1 -0
  49. package/lib/browser/notebook-cell-resource-resolver.d.ts +26 -0
  50. package/lib/browser/notebook-cell-resource-resolver.d.ts.map +1 -0
  51. package/lib/browser/notebook-cell-resource-resolver.js +109 -0
  52. package/lib/browser/notebook-cell-resource-resolver.js.map +1 -0
  53. package/lib/browser/notebook-editor-split-contribution.d.ts +14 -0
  54. package/lib/browser/notebook-editor-split-contribution.d.ts.map +1 -0
  55. package/lib/browser/notebook-editor-split-contribution.js +51 -0
  56. package/lib/browser/notebook-editor-split-contribution.js.map +1 -0
  57. package/lib/browser/notebook-editor-widget-factory.d.ts +20 -0
  58. package/lib/browser/notebook-editor-widget-factory.d.ts.map +1 -0
  59. package/lib/browser/notebook-editor-widget-factory.js +101 -0
  60. package/lib/browser/notebook-editor-widget-factory.js.map +1 -0
  61. package/lib/browser/notebook-editor-widget.d.ts +102 -0
  62. package/lib/browser/notebook-editor-widget.d.ts.map +1 -0
  63. package/lib/browser/notebook-editor-widget.js +336 -0
  64. package/lib/browser/notebook-editor-widget.js.map +1 -0
  65. package/lib/browser/notebook-frontend-module.d.ts +5 -0
  66. package/lib/browser/notebook-frontend-module.d.ts.map +1 -0
  67. package/lib/browser/notebook-frontend-module.js +116 -0
  68. package/lib/browser/notebook-frontend-module.js.map +1 -0
  69. package/lib/browser/notebook-open-handler.d.ts +29 -0
  70. package/lib/browser/notebook-open-handler.d.ts.map +1 -0
  71. package/lib/browser/notebook-open-handler.js +119 -0
  72. package/lib/browser/notebook-open-handler.js.map +1 -0
  73. package/lib/browser/notebook-output-utils.d.ts +13 -0
  74. package/lib/browser/notebook-output-utils.d.ts.map +1 -0
  75. package/lib/browser/notebook-output-utils.js +112 -0
  76. package/lib/browser/notebook-output-utils.js.map +1 -0
  77. package/lib/browser/notebook-renderer-registry.d.ts +25 -0
  78. package/lib/browser/notebook-renderer-registry.d.ts.map +1 -0
  79. package/lib/browser/notebook-renderer-registry.js +72 -0
  80. package/lib/browser/notebook-renderer-registry.js.map +1 -0
  81. package/lib/browser/notebook-type-registry.d.ts +12 -0
  82. package/lib/browser/notebook-type-registry.d.ts.map +1 -0
  83. package/lib/browser/notebook-type-registry.js +60 -0
  84. package/lib/browser/notebook-type-registry.js.map +1 -0
  85. package/lib/browser/notebook-types.d.ts +131 -0
  86. package/lib/browser/notebook-types.d.ts.map +1 -0
  87. package/lib/browser/notebook-types.js +28 -0
  88. package/lib/browser/notebook-types.js.map +1 -0
  89. package/lib/browser/renderers/cell-output-webview.d.ts +26 -0
  90. package/lib/browser/renderers/cell-output-webview.d.ts.map +1 -0
  91. package/lib/browser/renderers/cell-output-webview.js +21 -0
  92. package/lib/browser/renderers/cell-output-webview.js.map +1 -0
  93. package/lib/browser/service/notebook-cell-editor-service.d.ts +23 -0
  94. package/lib/browser/service/notebook-cell-editor-service.d.ts.map +1 -0
  95. package/lib/browser/service/notebook-cell-editor-service.js +89 -0
  96. package/lib/browser/service/notebook-cell-editor-service.js.map +1 -0
  97. package/lib/browser/service/notebook-cell-status-bar-service.d.ts +39 -0
  98. package/lib/browser/service/notebook-cell-status-bar-service.d.ts.map +1 -0
  99. package/lib/browser/service/notebook-cell-status-bar-service.js +69 -0
  100. package/lib/browser/service/notebook-cell-status-bar-service.js.map +1 -0
  101. package/lib/browser/service/notebook-clipboard-service.d.ts +10 -0
  102. package/lib/browser/service/notebook-clipboard-service.d.ts.map +1 -0
  103. package/lib/browser/service/notebook-clipboard-service.js +42 -0
  104. package/lib/browser/service/notebook-clipboard-service.js.map +1 -0
  105. package/lib/browser/service/notebook-context-manager.d.ts +28 -0
  106. package/lib/browser/service/notebook-context-manager.d.ts.map +1 -0
  107. package/lib/browser/service/notebook-context-manager.js +135 -0
  108. package/lib/browser/service/notebook-context-manager.js.map +1 -0
  109. package/lib/browser/service/notebook-editor-widget-service.d.ts +27 -0
  110. package/lib/browser/service/notebook-editor-widget-service.d.ts.map +1 -0
  111. package/lib/browser/service/notebook-editor-widget-service.js +124 -0
  112. package/lib/browser/service/notebook-editor-widget-service.js.map +1 -0
  113. package/lib/browser/service/notebook-execution-service.d.ts +25 -0
  114. package/lib/browser/service/notebook-execution-service.d.ts.map +1 -0
  115. package/lib/browser/service/notebook-execution-service.js +150 -0
  116. package/lib/browser/service/notebook-execution-service.js.map +1 -0
  117. package/lib/browser/service/notebook-execution-state-service.d.ts +78 -0
  118. package/lib/browser/service/notebook-execution-state-service.d.ts.map +1 -0
  119. package/lib/browser/service/notebook-execution-state-service.js +247 -0
  120. package/lib/browser/service/notebook-execution-state-service.js.map +1 -0
  121. package/lib/browser/service/notebook-kernel-history-service.d.ts +28 -0
  122. package/lib/browser/service/notebook-kernel-history-service.d.ts.map +1 -0
  123. package/lib/browser/service/notebook-kernel-history-service.js +116 -0
  124. package/lib/browser/service/notebook-kernel-history-service.js.map +1 -0
  125. package/lib/browser/service/notebook-kernel-quick-pick-service.d.ts +61 -0
  126. package/lib/browser/service/notebook-kernel-quick-pick-service.d.ts.map +1 -0
  127. package/lib/browser/service/notebook-kernel-quick-pick-service.js +425 -0
  128. package/lib/browser/service/notebook-kernel-quick-pick-service.js.map +1 -0
  129. package/lib/browser/service/notebook-kernel-service.d.ts +125 -0
  130. package/lib/browser/service/notebook-kernel-service.d.ts.map +1 -0
  131. package/lib/browser/service/notebook-kernel-service.js +268 -0
  132. package/lib/browser/service/notebook-kernel-service.js.map +1 -0
  133. package/lib/browser/service/notebook-model-resolver-service.d.ts +28 -0
  134. package/lib/browser/service/notebook-model-resolver-service.d.ts.map +1 -0
  135. package/lib/browser/service/notebook-model-resolver-service.js +157 -0
  136. package/lib/browser/service/notebook-model-resolver-service.js.map +1 -0
  137. package/lib/browser/service/notebook-monaco-text-model-service.d.ts +21 -0
  138. package/lib/browser/service/notebook-monaco-text-model-service.d.ts.map +1 -0
  139. package/lib/browser/service/notebook-monaco-text-model-service.js +73 -0
  140. package/lib/browser/service/notebook-monaco-text-model-service.js.map +1 -0
  141. package/lib/browser/service/notebook-options.d.ts +30 -0
  142. package/lib/browser/service/notebook-options.d.ts.map +1 -0
  143. package/lib/browser/service/notebook-options.js +130 -0
  144. package/lib/browser/service/notebook-options.js.map +1 -0
  145. package/lib/browser/service/notebook-renderer-messaging-service.d.ts +35 -0
  146. package/lib/browser/service/notebook-renderer-messaging-service.d.ts.map +1 -0
  147. package/lib/browser/service/notebook-renderer-messaging-service.js +100 -0
  148. package/lib/browser/service/notebook-renderer-messaging-service.js.map +1 -0
  149. package/lib/browser/service/notebook-service.d.ts +68 -0
  150. package/lib/browser/service/notebook-service.d.ts.map +1 -0
  151. package/lib/browser/service/notebook-service.js +184 -0
  152. package/lib/browser/service/notebook-service.js.map +1 -0
  153. package/lib/browser/view/notebook-cell-editor.d.ts +46 -0
  154. package/lib/browser/view/notebook-cell-editor.d.ts.map +1 -0
  155. package/lib/browser/view/notebook-cell-editor.js +271 -0
  156. package/lib/browser/view/notebook-cell-editor.js.map +1 -0
  157. package/lib/browser/view/notebook-cell-list-view.d.ts +58 -0
  158. package/lib/browser/view/notebook-cell-list-view.d.ts.map +1 -0
  159. package/lib/browser/view/notebook-cell-list-view.js +225 -0
  160. package/lib/browser/view/notebook-cell-list-view.js.map +1 -0
  161. package/lib/browser/view/notebook-cell-toolbar-factory.d.ts +33 -0
  162. package/lib/browser/view/notebook-cell-toolbar-factory.d.ts.map +1 -0
  163. package/lib/browser/view/notebook-cell-toolbar-factory.js +110 -0
  164. package/lib/browser/view/notebook-cell-toolbar-factory.js.map +1 -0
  165. package/lib/browser/view/notebook-cell-toolbar.d.ts +25 -0
  166. package/lib/browser/view/notebook-cell-toolbar.d.ts.map +1 -0
  167. package/lib/browser/view/notebook-cell-toolbar.js +51 -0
  168. package/lib/browser/view/notebook-cell-toolbar.js.map +1 -0
  169. package/lib/browser/view/notebook-code-cell-view.d.ts +93 -0
  170. package/lib/browser/view/notebook-code-cell-view.d.ts.map +1 -0
  171. package/lib/browser/view/notebook-code-cell-view.js +338 -0
  172. package/lib/browser/view/notebook-code-cell-view.js.map +1 -0
  173. package/lib/browser/view/notebook-find-widget.d.ts +63 -0
  174. package/lib/browser/view/notebook-find-widget.d.ts.map +1 -0
  175. package/lib/browser/view/notebook-find-widget.js +225 -0
  176. package/lib/browser/view/notebook-find-widget.js.map +1 -0
  177. package/lib/browser/view/notebook-main-toolbar.d.ts +53 -0
  178. package/lib/browser/view/notebook-main-toolbar.d.ts.map +1 -0
  179. package/lib/browser/view/notebook-main-toolbar.js +184 -0
  180. package/lib/browser/view/notebook-main-toolbar.js.map +1 -0
  181. package/lib/browser/view/notebook-markdown-cell-view.d.ts +28 -0
  182. package/lib/browser/view/notebook-markdown-cell-view.d.ts.map +1 -0
  183. package/lib/browser/view/notebook-markdown-cell-view.js +216 -0
  184. package/lib/browser/view/notebook-markdown-cell-view.js.map +1 -0
  185. package/lib/browser/view/notebook-viewport-service.d.ts +17 -0
  186. package/lib/browser/view/notebook-viewport-service.d.ts.map +1 -0
  187. package/lib/browser/view/notebook-viewport-service.js +61 -0
  188. package/lib/browser/view/notebook-viewport-service.js.map +1 -0
  189. package/lib/browser/view-model/notebook-cell-model.d.ts +137 -0
  190. package/lib/browser/view-model/notebook-cell-model.d.ts.map +1 -0
  191. package/lib/browser/view-model/notebook-cell-model.js +367 -0
  192. package/lib/browser/view-model/notebook-cell-model.js.map +1 -0
  193. package/lib/browser/view-model/notebook-cell-output-model.d.ts +17 -0
  194. package/lib/browser/view-model/notebook-cell-output-model.d.ts.map +1 -0
  195. package/lib/browser/view-model/notebook-cell-output-model.js +87 -0
  196. package/lib/browser/view-model/notebook-cell-output-model.js.map +1 -0
  197. package/lib/browser/view-model/notebook-model.d.ts +85 -0
  198. package/lib/browser/view-model/notebook-model.d.ts.map +1 -0
  199. package/lib/browser/view-model/notebook-model.js +446 -0
  200. package/lib/browser/view-model/notebook-model.js.map +1 -0
  201. package/lib/browser/view-model/notebook-view-model.d.ts +40 -0
  202. package/lib/browser/view-model/notebook-view-model.d.ts.map +1 -0
  203. package/lib/browser/view-model/notebook-view-model.js +120 -0
  204. package/lib/browser/view-model/notebook-view-model.js.map +1 -0
  205. package/lib/common/index.d.ts +3 -0
  206. package/lib/common/index.d.ts.map +1 -0
  207. package/lib/common/index.js +21 -0
  208. package/lib/common/index.js.map +1 -0
  209. package/lib/common/notebook-common.d.ts +227 -0
  210. package/lib/common/notebook-common.d.ts.map +1 -0
  211. package/lib/common/notebook-common.js +151 -0
  212. package/lib/common/notebook-common.js.map +1 -0
  213. package/lib/common/notebook-preferences.d.ts +15 -0
  214. package/lib/common/notebook-preferences.d.ts.map +1 -0
  215. package/lib/common/notebook-preferences.js +89 -0
  216. package/lib/common/notebook-preferences.js.map +1 -0
  217. package/lib/common/notebook-protocol.d.ts +21 -0
  218. package/lib/common/notebook-protocol.d.ts.map +1 -0
  219. package/lib/common/notebook-protocol.js +18 -0
  220. package/lib/common/notebook-protocol.js.map +1 -0
  221. package/lib/common/notebook-range.d.ts +14 -0
  222. package/lib/common/notebook-range.d.ts.map +1 -0
  223. package/lib/common/notebook-range.js +18 -0
  224. package/lib/common/notebook-range.js.map +1 -0
  225. package/lib/node/notebook-backend-module.d.ts +4 -0
  226. package/lib/node/notebook-backend-module.d.ts.map +1 -0
  227. package/lib/node/notebook-backend-module.js +23 -0
  228. package/lib/node/notebook-backend-module.js.map +1 -0
  229. package/package.json +7 -7
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.NotebookEditorWidgetService = void 0;
19
+ const tslib_1 = require("tslib");
20
+ /*---------------------------------------------------------------------------------------------
21
+ * Copyright (c) Microsoft Corporation. All rights reserved.
22
+ * Licensed under the MIT License. See License.txt in the project root for license information.
23
+ *--------------------------------------------------------------------------------------------*/
24
+ const core_1 = require("@theia/core");
25
+ const inversify_1 = require("@theia/core/shared/inversify");
26
+ const browser_1 = require("@theia/core/lib/browser");
27
+ const notebook_editor_widget_1 = require("../notebook-editor-widget");
28
+ const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
29
+ const notebook_context_keys_1 = require("../contributions/notebook-context-keys");
30
+ let NotebookEditorWidgetService = class NotebookEditorWidgetService {
31
+ constructor() {
32
+ this.notebookEditors = new Map();
33
+ this.onNotebookEditorAddEmitter = new core_1.Emitter();
34
+ this.onNotebookEditorRemoveEmitter = new core_1.Emitter();
35
+ this.onDidAddNotebookEditor = this.onNotebookEditorAddEmitter.event;
36
+ this.onDidRemoveNotebookEditor = this.onNotebookEditorRemoveEmitter.event;
37
+ this.onDidChangeFocusedEditorEmitter = new core_1.Emitter();
38
+ this.onDidChangeFocusedEditor = this.onDidChangeFocusedEditorEmitter.event;
39
+ this.onDidChangeCurrentEditorEmitter = new core_1.Emitter();
40
+ this.onDidChangeCurrentEditor = this.onDidChangeCurrentEditorEmitter.event;
41
+ this.focusedEditor = undefined;
42
+ this.currentEditor = undefined;
43
+ }
44
+ init() {
45
+ this.applicationShell.onDidChangeActiveWidget(event => {
46
+ this.notebookEditorFocusChanged(event.newValue, event.newValue instanceof notebook_editor_widget_1.NotebookEditorWidget);
47
+ });
48
+ this.applicationShell.onDidChangeCurrentWidget(event => {
49
+ if (event.newValue instanceof notebook_editor_widget_1.NotebookEditorWidget || event.oldValue instanceof notebook_editor_widget_1.NotebookEditorWidget) {
50
+ this.currentNotebookEditorChanged(event.newValue);
51
+ }
52
+ });
53
+ }
54
+ // --- editor management
55
+ addNotebookEditor(editor) {
56
+ if (this.notebookEditors.has(editor.id)) {
57
+ console.warn('Attempting to add duplicated notebook editor: ' + editor.id);
58
+ }
59
+ this.notebookEditors.set(editor.id, editor);
60
+ this.onNotebookEditorAddEmitter.fire(editor);
61
+ if (editor.isVisible) {
62
+ this.notebookEditorFocusChanged(editor, true);
63
+ }
64
+ }
65
+ removeNotebookEditor(editor) {
66
+ if (this.notebookEditors.has(editor.id)) {
67
+ this.notebookEditors.delete(editor.id);
68
+ this.onNotebookEditorRemoveEmitter.fire(editor);
69
+ }
70
+ else {
71
+ console.warn('Attempting to remove not registered editor: ' + editor.id);
72
+ }
73
+ }
74
+ getNotebookEditor(editorId) {
75
+ return this.notebookEditors.get(editorId);
76
+ }
77
+ getNotebookEditors() {
78
+ return Array.from(this.notebookEditors.values());
79
+ }
80
+ notebookEditorFocusChanged(editor, focus) {
81
+ if (focus) {
82
+ if (editor !== this.focusedEditor) {
83
+ this.focusedEditor = editor;
84
+ this.contextKeyService.setContext(notebook_context_keys_1.NOTEBOOK_EDITOR_FOCUSED, true);
85
+ this.onDidChangeFocusedEditorEmitter.fire(this.focusedEditor);
86
+ }
87
+ }
88
+ else if (this.focusedEditor) {
89
+ this.focusedEditor = undefined;
90
+ this.contextKeyService.setContext(notebook_context_keys_1.NOTEBOOK_EDITOR_FOCUSED, false);
91
+ this.onDidChangeFocusedEditorEmitter.fire(undefined);
92
+ }
93
+ }
94
+ currentNotebookEditorChanged(newEditor) {
95
+ var _a, _b;
96
+ if (newEditor instanceof notebook_editor_widget_1.NotebookEditorWidget) {
97
+ this.currentEditor = newEditor;
98
+ this.onDidChangeCurrentEditorEmitter.fire(newEditor);
99
+ }
100
+ else if (((_a = this.currentEditor) === null || _a === void 0 ? void 0 : _a.isDisposed) || !((_b = this.currentEditor) === null || _b === void 0 ? void 0 : _b.isVisible)) {
101
+ this.currentEditor = undefined;
102
+ this.onDidChangeCurrentEditorEmitter.fire(undefined);
103
+ }
104
+ }
105
+ };
106
+ exports.NotebookEditorWidgetService = NotebookEditorWidgetService;
107
+ tslib_1.__decorate([
108
+ (0, inversify_1.inject)(browser_1.ApplicationShell),
109
+ tslib_1.__metadata("design:type", browser_1.ApplicationShell)
110
+ ], NotebookEditorWidgetService.prototype, "applicationShell", void 0);
111
+ tslib_1.__decorate([
112
+ (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
113
+ tslib_1.__metadata("design:type", Object)
114
+ ], NotebookEditorWidgetService.prototype, "contextKeyService", void 0);
115
+ tslib_1.__decorate([
116
+ (0, inversify_1.postConstruct)(),
117
+ tslib_1.__metadata("design:type", Function),
118
+ tslib_1.__metadata("design:paramtypes", []),
119
+ tslib_1.__metadata("design:returntype", void 0)
120
+ ], NotebookEditorWidgetService.prototype, "init", null);
121
+ exports.NotebookEditorWidgetService = NotebookEditorWidgetService = tslib_1.__decorate([
122
+ (0, inversify_1.injectable)()
123
+ ], NotebookEditorWidgetService);
124
+ //# sourceMappingURL=notebook-editor-widget-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-editor-widget-service.js","sourceRoot":"","sources":["../../../src/browser/service/notebook-editor-widget-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF;;;gGAGgG;AAEhG,sCAAsC;AACtC,4DAAiF;AACjF,qDAA2D;AAC3D,sEAAiE;AACjE,qFAAgF;AAChF,kFAAiF;AAG1E,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAAjC;QAQgB,oBAAe,GAAG,IAAI,GAAG,EAAgC,CAAC;QAE1D,+BAA0B,GAAG,IAAI,cAAO,EAAwB,CAAC;QACjE,kCAA6B,GAAG,IAAI,cAAO,EAAwB,CAAC;QAC9E,2BAAsB,GAAG,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC;QAC/D,8BAAyB,GAAG,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC;QAE3D,oCAA+B,GAAG,IAAI,cAAO,EAAoC,CAAC;QAC5F,6BAAwB,GAAG,IAAI,CAAC,+BAA+B,CAAC,KAAK,CAAC;QAE5D,oCAA+B,GAAG,IAAI,cAAO,EAAoC,CAAC;QAC5F,6BAAwB,GAAG,IAAI,CAAC,+BAA+B,CAAC,KAAK,CAAC;QAE/E,kBAAa,GAA0B,SAAS,CA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AA,IAAI,CAAC,aAAa,0CAAE,SAAS,CAAA,EAAE,CAAC;YAC1E,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;YAC/B,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;CAEJ,CAAA;AA3FY,kEAA2B;AAG1B;IADT,IAAA,kBAAM,EAAC,0BAAgB,CAAC;sCACG,0BAAgB;qEAAC;AAGnC;IADT,IAAA,kBAAM,EAAC,uCAAiB,CAAC;;sEACqB;AAoBrC;IADT,IAAA,yBAAa,GAAE;;;;uDAUf;sCAnCQ,2BAA2B;IADvC,IAAA,sBAAU,GAAE;GACA,2BAA2B,CA2FvC"}
@@ -0,0 +1,25 @@
1
+ import { CellExecution, NotebookExecutionStateService } from '../service/notebook-execution-state-service';
2
+ import { NotebookCellModel } from '../view-model/notebook-cell-model';
3
+ import { NotebookModel } from '../view-model/notebook-model';
4
+ import { NotebookKernelService } from './notebook-kernel-service';
5
+ import { CommandService, Disposable, ILogger } from '@theia/core';
6
+ import { NotebookKernelQuickPickService } from './notebook-kernel-quick-pick-service';
7
+ import { NotebookKernelHistoryService } from './notebook-kernel-history-service';
8
+ export interface CellExecutionParticipant {
9
+ onWillExecuteCell(executions: CellExecution[]): Promise<void>;
10
+ }
11
+ export declare class NotebookExecutionService {
12
+ protected notebookExecutionStateService: NotebookExecutionStateService;
13
+ protected notebookKernelService: NotebookKernelService;
14
+ protected notebookKernelHistoryService: NotebookKernelHistoryService;
15
+ protected commandService: CommandService;
16
+ protected notebookKernelQuickPickService: NotebookKernelQuickPickService;
17
+ protected readonly logger: ILogger;
18
+ protected readonly cellExecutionParticipants: Set<CellExecutionParticipant>;
19
+ executeNotebookCells(notebook: NotebookModel, cells: Iterable<NotebookCellModel>): Promise<void>;
20
+ registerExecutionParticipant(participant: CellExecutionParticipant): Disposable;
21
+ protected runExecutionParticipants(executions: CellExecution[]): Promise<void>;
22
+ cancelNotebookCellHandles(notebook: NotebookModel, cells: Iterable<number>): Promise<void>;
23
+ cancelNotebookCells(notebook: NotebookModel, cells: Iterable<NotebookCellModel>): Promise<void>;
24
+ }
25
+ //# sourceMappingURL=notebook-execution-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-execution-service.d.ts","sourceRoot":"","sources":["../../../src/browser/service/notebook-execution-service.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAE3G,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,MAAM,WAAW,wBAAwB;IACrC,iBAAiB,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE;AAED,qBACa,wBAAwB;IAGjC,SAAS,CAAC,6BAA6B,EAAE,6BAA6B,CAAC;IAGvE,SAAS,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAGvD,SAAS,CAAC,4BAA4B,EAAE,4BAA4B,CAAC;IAGrE,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IAGzC,SAAS,CAAC,8BAA8B,EAAE,8BAA8B,CAAC;IAGzE,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC,SAAS,CAAC,QAAQ,CAAC,yBAAyB,gCAAuC;IAE7E,oBAAoB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IA2EtG,4BAA4B,CAAC,WAAW,EAAE,wBAAwB,GAAG,UAAU;cAK/D,wBAAwB,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9E,yBAAyB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1F,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAIxG"}
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ /*---------------------------------------------------------------------------------------------
18
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19
+ * Licensed under the MIT License. See License.txt in the project root for license information.
20
+ *--------------------------------------------------------------------------------------------*/
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.NotebookExecutionService = void 0;
23
+ const tslib_1 = require("tslib");
24
+ const inversify_1 = require("@theia/core/shared/inversify");
25
+ const notebook_execution_state_service_1 = require("../service/notebook-execution-state-service");
26
+ const common_1 = require("../../common");
27
+ const notebook_kernel_service_1 = require("./notebook-kernel-service");
28
+ const core_1 = require("@theia/core");
29
+ const notebook_kernel_quick_pick_service_1 = require("./notebook-kernel-quick-pick-service");
30
+ const notebook_kernel_history_service_1 = require("./notebook-kernel-history-service");
31
+ let NotebookExecutionService = class NotebookExecutionService {
32
+ constructor() {
33
+ this.cellExecutionParticipants = new Set();
34
+ }
35
+ async executeNotebookCells(notebook, cells) {
36
+ const cellsArr = Array.from(cells)
37
+ .filter(c => c.cellKind === common_1.CellKind.Code);
38
+ if (!cellsArr.length) {
39
+ return;
40
+ }
41
+ this.logger.debug('Executing notebook cells', {
42
+ notebook: notebook.uri.toString(),
43
+ cells: cellsArr.map(c => c.handle)
44
+ });
45
+ // create cell executions
46
+ const cellExecutions = [];
47
+ for (const cell of cellsArr) {
48
+ const cellExe = this.notebookExecutionStateService.getCellExecution(cell.uri);
49
+ if (!cellExe) {
50
+ cellExecutions.push([cell, this.notebookExecutionStateService.getOrCreateCellExecution(notebook.uri, cell.handle)]);
51
+ }
52
+ }
53
+ const kernel = await this.notebookKernelHistoryService.resolveSelectedKernel(notebook);
54
+ if (!kernel) {
55
+ this.logger.debug('Failed to resolve kernel for execution', notebook.uri.toString());
56
+ // clear all pending cell executions
57
+ cellExecutions.forEach(cellExe => cellExe[1].complete({}));
58
+ return;
59
+ }
60
+ // filter cell executions based on selected kernel
61
+ const validCellExecutions = [];
62
+ for (const [cell, cellExecution] of cellExecutions) {
63
+ if (!kernel.supportedLanguages.includes(cell.language)) {
64
+ cellExecution.complete({});
65
+ }
66
+ else {
67
+ validCellExecutions.push(cellExecution);
68
+ }
69
+ }
70
+ // request execution
71
+ if (validCellExecutions.length > 0) {
72
+ const cellRemoveListener = notebook.onDidAddOrRemoveCell(e => {
73
+ if (e.rawEvent.changes.some(c => c.deleteCount > 0)) {
74
+ const executionsToCancel = validCellExecutions.filter(exec => !notebook.cells.find(cell => cell.handle === exec.cellHandle));
75
+ if (executionsToCancel.length > 0) {
76
+ kernel.cancelNotebookCellExecution(notebook.uri, executionsToCancel.map(c => c.cellHandle));
77
+ executionsToCancel.forEach(exec => exec.complete({}));
78
+ }
79
+ }
80
+ });
81
+ await this.runExecutionParticipants(validCellExecutions);
82
+ this.logger.debug('Selecting kernel for cell execution', {
83
+ notebook: notebook.uri.toString(),
84
+ kernel: kernel.id
85
+ });
86
+ this.notebookKernelService.selectKernelForNotebook(kernel, notebook);
87
+ this.logger.debug('Running cell execution request', {
88
+ notebook: notebook.uri.toString(),
89
+ cells: validCellExecutions.map(c => c.cellHandle)
90
+ });
91
+ await kernel.executeNotebookCellsRequest(notebook.uri, validCellExecutions.map(c => c.cellHandle));
92
+ // the connecting state can change before the kernel resolves executeNotebookCellsRequest
93
+ const unconfirmed = validCellExecutions.filter(exe => exe.state === common_1.NotebookCellExecutionState.Unconfirmed);
94
+ if (unconfirmed.length) {
95
+ unconfirmed.forEach(exe => exe.complete({}));
96
+ }
97
+ cellRemoveListener.dispose();
98
+ }
99
+ }
100
+ registerExecutionParticipant(participant) {
101
+ this.cellExecutionParticipants.add(participant);
102
+ return core_1.Disposable.create(() => this.cellExecutionParticipants.delete(participant));
103
+ }
104
+ async runExecutionParticipants(executions) {
105
+ for (const participant of this.cellExecutionParticipants) {
106
+ await participant.onWillExecuteCell(executions);
107
+ }
108
+ return;
109
+ }
110
+ async cancelNotebookCellHandles(notebook, cells) {
111
+ const cellsArr = Array.from(cells);
112
+ const kernel = this.notebookKernelService.getSelectedOrSuggestedKernel(notebook);
113
+ if (kernel) {
114
+ await kernel.cancelNotebookCellExecution(notebook.uri, cellsArr);
115
+ }
116
+ }
117
+ async cancelNotebookCells(notebook, cells) {
118
+ this.cancelNotebookCellHandles(notebook, Array.from(cells, cell => cell.handle));
119
+ }
120
+ };
121
+ exports.NotebookExecutionService = NotebookExecutionService;
122
+ tslib_1.__decorate([
123
+ (0, inversify_1.inject)(notebook_execution_state_service_1.NotebookExecutionStateService),
124
+ tslib_1.__metadata("design:type", notebook_execution_state_service_1.NotebookExecutionStateService)
125
+ ], NotebookExecutionService.prototype, "notebookExecutionStateService", void 0);
126
+ tslib_1.__decorate([
127
+ (0, inversify_1.inject)(notebook_kernel_service_1.NotebookKernelService),
128
+ tslib_1.__metadata("design:type", notebook_kernel_service_1.NotebookKernelService)
129
+ ], NotebookExecutionService.prototype, "notebookKernelService", void 0);
130
+ tslib_1.__decorate([
131
+ (0, inversify_1.inject)(notebook_kernel_history_service_1.NotebookKernelHistoryService),
132
+ tslib_1.__metadata("design:type", notebook_kernel_history_service_1.NotebookKernelHistoryService)
133
+ ], NotebookExecutionService.prototype, "notebookKernelHistoryService", void 0);
134
+ tslib_1.__decorate([
135
+ (0, inversify_1.inject)(core_1.CommandService),
136
+ tslib_1.__metadata("design:type", Object)
137
+ ], NotebookExecutionService.prototype, "commandService", void 0);
138
+ tslib_1.__decorate([
139
+ (0, inversify_1.inject)(notebook_kernel_quick_pick_service_1.NotebookKernelQuickPickService),
140
+ tslib_1.__metadata("design:type", notebook_kernel_quick_pick_service_1.NotebookKernelQuickPickService)
141
+ ], NotebookExecutionService.prototype, "notebookKernelQuickPickService", void 0);
142
+ tslib_1.__decorate([
143
+ (0, inversify_1.inject)(core_1.ILogger),
144
+ (0, inversify_1.named)('notebook'),
145
+ tslib_1.__metadata("design:type", Object)
146
+ ], NotebookExecutionService.prototype, "logger", void 0);
147
+ exports.NotebookExecutionService = NotebookExecutionService = tslib_1.__decorate([
148
+ (0, inversify_1.injectable)()
149
+ ], NotebookExecutionService);
150
+ //# sourceMappingURL=notebook-execution-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-execution-service.js","sourceRoot":"","sources":["../../../src/browser/service/notebook-execution-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF;;;gGAGgG;;;;AAEhG,4DAAyE;AACzE,kGAA2G;AAC3G,yCAAoE;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ACG,8DAA4B;8EAAC;AAG3D;IADT,IAAA,kBAAM,EAAC,qBAAc,CAAC;;gEACkB;AAG/B;IADT,IAAA,kBAAM,EAAC,mEAA8B,CAAC;sCACG,mEAA8B;gFAAC;AAGtD;IADlB,IAAA,kBAAM,EAAC,cAAO,CAAC;IAAE,IAAA,iBAAK,EAAC,UAAU,CAAC;;wDACA;mCAlB1B,wBAAwB;IADpC,IAAA,sBAAU,GAAE;GACA,wBAAwB,CAyHpC"}
@@ -0,0 +1,78 @@
1
+ import { Disposable, DisposableCollection, Emitter, URI } from '@theia/core';
2
+ import { NotebookService } from './notebook-service';
3
+ import { CellExecuteOutputEdit, CellExecuteOutputItemEdit, CellExecutionUpdateType, NotebookCellExecutionState } from '../../common';
4
+ import { CellEditOperation } from '../notebook-types';
5
+ import { NotebookModel } from '../view-model/notebook-model';
6
+ export type CellExecuteUpdate = CellExecuteOutputEdit | CellExecuteOutputItemEdit | CellExecutionStateUpdate;
7
+ export interface CellExecutionComplete {
8
+ runEndTime?: number;
9
+ lastRunSuccess?: boolean;
10
+ }
11
+ export interface CellExecutionStateUpdate {
12
+ editType: CellExecutionUpdateType.ExecutionState;
13
+ executionOrder?: number;
14
+ runStartTime?: number;
15
+ didPause?: boolean;
16
+ isPaused?: boolean;
17
+ }
18
+ export declare enum NotebookExecutionType {
19
+ cell = 0,
20
+ notebook = 1
21
+ }
22
+ export interface NotebookFailStateChangedEvent {
23
+ visible: boolean;
24
+ notebook: URI;
25
+ }
26
+ export interface FailedCellInfo {
27
+ cellHandle: number;
28
+ disposable: Disposable;
29
+ visible: boolean;
30
+ }
31
+ export declare class NotebookExecutionStateService implements Disposable {
32
+ protected notebookService: NotebookService;
33
+ protected toDispose: DisposableCollection;
34
+ protected readonly executions: Map<string, Map<number, CellExecution>>;
35
+ protected readonly onDidChangeExecutionEmitter: Emitter<CellExecutionStateChangedEvent>;
36
+ onDidChangeExecution: import("@theia/core").Event<CellExecutionStateChangedEvent>;
37
+ protected readonly onDidChangeLastRunFailStateEmitter: Emitter<NotebookFailStateChangedEvent>;
38
+ onDidChangeLastRunFailState: import("@theia/core").Event<NotebookFailStateChangedEvent>;
39
+ getOrCreateCellExecution(notebookUri: URI, cellHandle: number): CellExecution;
40
+ protected createNotebookCellExecution(notebook: NotebookModel, cellHandle: number): CellExecution;
41
+ protected onCellExecutionDidComplete(notebookUri: URI, cellHandle: number, exe: CellExecution, lastRunSuccess?: boolean): void;
42
+ getCellExecution(cellUri: URI): CellExecution | undefined;
43
+ dispose(): void;
44
+ }
45
+ export declare class CellExecution implements Disposable {
46
+ readonly cellHandle: number;
47
+ protected readonly notebook: NotebookModel;
48
+ protected readonly onDidUpdateEmitter: Emitter<void>;
49
+ readonly onDidUpdate: import("@theia/core").Event<void>;
50
+ protected readonly onDidCompleteEmitter: Emitter<boolean | undefined>;
51
+ readonly onDidComplete: import("@theia/core").Event<boolean | undefined>;
52
+ toDispose: DisposableCollection;
53
+ protected _state: NotebookCellExecutionState;
54
+ get state(): NotebookCellExecutionState;
55
+ get notebookURI(): URI;
56
+ protected _didPause: boolean;
57
+ get didPause(): boolean;
58
+ protected _isPaused: boolean;
59
+ get isPaused(): boolean;
60
+ constructor(cellHandle: number, notebook: NotebookModel);
61
+ initialize(): void;
62
+ confirm(): void;
63
+ update(updates: CellExecuteUpdate[]): void;
64
+ complete(completionData: CellExecutionComplete): void;
65
+ dispose(): void;
66
+ protected applyCellExecutionEditsToNotebook(edits: CellEditOperation[]): void;
67
+ }
68
+ export declare class CellExecutionStateChangedEvent {
69
+ readonly notebook: URI;
70
+ readonly cellHandle: number;
71
+ readonly changed?: CellExecution | undefined;
72
+ readonly type = NotebookExecutionType.cell;
73
+ constructor(notebook: URI, cellHandle: number, changed?: CellExecution | undefined);
74
+ affectsCell(cell: URI): boolean;
75
+ affectsNotebook(notebook: URI): boolean;
76
+ }
77
+ export declare function updateToEdit(update: CellExecuteUpdate, cellHandle: number): CellEditOperation;
78
+ //# sourceMappingURL=notebook-execution-state-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-execution-state-service.d.ts","sourceRoot":"","sources":["../../../src/browser/service/notebook-execution-state-service.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAAG,EAAgB,MAAM,aAAa,CAAC;AAE3F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACW,qBAAqB,EAAE,yBAAyB,EAAE,uBAAuB,EAC9E,0BAA0B,EACtC,MAAM,cAAc,CAAC;AACtB,OAAO,EAA2C,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GAAG,yBAAyB,GAAG,wBAAwB,CAAC;AAE7G,MAAM,WAAW,qBAAqB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACrC,QAAQ,EAAE,uBAAuB,CAAC,cAAc,CAAC;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,oBAAY,qBAAqB;IAC7B,IAAI,IAAA;IACJ,QAAQ,IAAA;CACX;AAED,MAAM,WAAW,6BAA6B;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,GAAG,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,qBACa,6BAA8B,YAAW,UAAU;IAG5D,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAE3C,SAAS,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Q,EAAE,aAAa;IAI9C,UAAU,IAAI,IAAI;IAgBlB,OAAO,IAAI,IAAI;IAKf,MAAM,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,IAAI;IA4B1C,QAAQ,CAAC,cAAc,EAAE,qBAAqB,GAAG,IAAI;IAuBrD,OAAO,IAAI,IAAI;IAMf,SAAS,CAAC,iCAAiC,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,IAAI;CAGhF;AAED,qBAAa,8BAA8B;IAGnC,QAAQ,CAAC,QAAQ,EAAE,GAAG;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM;IAC3B,QAAQ,CAAC,OAAO,CAAC;IAJrB,QAAQ,CAAC,IAAI,8BAA8B;gBAE9B,QAAQ,EAAE,GAAG,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,2BAAe;IAGpC,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO;IAK/B,eAAe,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO;CAG1C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB,CA+B7F"}
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ /*---------------------------------------------------------------------------------------------
18
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19
+ * Licensed under the MIT License. See License.txt in the project root for license information.
20
+ *--------------------------------------------------------------------------------------------*/
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.updateToEdit = exports.CellExecutionStateChangedEvent = exports.CellExecution = exports.NotebookExecutionStateService = exports.NotebookExecutionType = void 0;
23
+ const tslib_1 = require("tslib");
24
+ const core_1 = require("@theia/core");
25
+ const inversify_1 = require("@theia/core/shared/inversify");
26
+ const notebook_service_1 = require("./notebook-service");
27
+ const common_1 = require("../../common");
28
+ var NotebookExecutionType;
29
+ (function (NotebookExecutionType) {
30
+ NotebookExecutionType[NotebookExecutionType["cell"] = 0] = "cell";
31
+ NotebookExecutionType[NotebookExecutionType["notebook"] = 1] = "notebook";
32
+ })(NotebookExecutionType || (exports.NotebookExecutionType = NotebookExecutionType = {}));
33
+ let NotebookExecutionStateService = class NotebookExecutionStateService {
34
+ constructor() {
35
+ this.toDispose = new core_1.DisposableCollection();
36
+ this.executions = new Map();
37
+ this.onDidChangeExecutionEmitter = new core_1.Emitter();
38
+ this.onDidChangeExecution = this.onDidChangeExecutionEmitter.event;
39
+ this.onDidChangeLastRunFailStateEmitter = new core_1.Emitter();
40
+ this.onDidChangeLastRunFailState = this.onDidChangeLastRunFailStateEmitter.event;
41
+ }
42
+ getOrCreateCellExecution(notebookUri, cellHandle) {
43
+ var _a, _b;
44
+ const notebook = this.notebookService.getNotebookEditorModel(notebookUri);
45
+ if (!notebook) {
46
+ throw new Error(`Notebook not found: ${notebookUri.toString()}`);
47
+ }
48
+ let execution = (_a = this.executions.get(notebookUri.toString())) === null || _a === void 0 ? void 0 : _a.get(cellHandle);
49
+ if (!execution) {
50
+ execution = this.createNotebookCellExecution(notebook, cellHandle);
51
+ if (!this.executions.has(notebookUri.toString())) {
52
+ this.executions.set(notebookUri.toString(), new Map());
53
+ }
54
+ (_b = this.executions.get(notebookUri.toString())) === null || _b === void 0 ? void 0 : _b.set(cellHandle, execution);
55
+ execution.initialize();
56
+ this.onDidChangeExecutionEmitter.fire(new CellExecutionStateChangedEvent(notebookUri, cellHandle, execution));
57
+ }
58
+ return execution;
59
+ }
60
+ createNotebookCellExecution(notebook, cellHandle) {
61
+ const notebookUri = notebook.uri;
62
+ const execution = new CellExecution(cellHandle, notebook);
63
+ execution.toDispose.push(execution.onDidUpdate(() => this.onDidChangeExecutionEmitter.fire(new CellExecutionStateChangedEvent(notebookUri, cellHandle, execution))));
64
+ execution.toDispose.push(execution.onDidComplete(lastRunSuccess => this.onCellExecutionDidComplete(notebookUri, cellHandle, execution, lastRunSuccess)));
65
+ return execution;
66
+ }
67
+ onCellExecutionDidComplete(notebookUri, cellHandle, exe, lastRunSuccess) {
68
+ var _a, _b;
69
+ const notebookExecutions = (_a = this.executions.get(notebookUri.toString())) === null || _a === void 0 ? void 0 : _a.get(cellHandle);
70
+ if (!notebookExecutions) {
71
+ throw new Error('Notebook Cell Execution not found while trying to complete it');
72
+ }
73
+ exe.dispose();
74
+ (_b = this.executions.get(notebookUri.toString())) === null || _b === void 0 ? void 0 : _b.delete(cellHandle);
75
+ this.onDidChangeExecutionEmitter.fire(new CellExecutionStateChangedEvent(notebookUri, cellHandle));
76
+ }
77
+ getCellExecution(cellUri) {
78
+ var _a;
79
+ const parsed = common_1.CellUri.parse(cellUri);
80
+ if (!parsed) {
81
+ throw new Error(`Not a cell URI: ${cellUri}`);
82
+ }
83
+ return (_a = this.executions.get(parsed.notebook.toString())) === null || _a === void 0 ? void 0 : _a.get(parsed.handle);
84
+ }
85
+ dispose() {
86
+ this.onDidChangeExecutionEmitter.dispose();
87
+ this.onDidChangeLastRunFailStateEmitter.dispose();
88
+ this.executions.forEach(notebookExecutions => notebookExecutions.forEach(execution => execution.dispose()));
89
+ }
90
+ };
91
+ exports.NotebookExecutionStateService = NotebookExecutionStateService;
92
+ tslib_1.__decorate([
93
+ (0, inversify_1.inject)(notebook_service_1.NotebookService),
94
+ tslib_1.__metadata("design:type", notebook_service_1.NotebookService)
95
+ ], NotebookExecutionStateService.prototype, "notebookService", void 0);
96
+ exports.NotebookExecutionStateService = NotebookExecutionStateService = tslib_1.__decorate([
97
+ (0, inversify_1.injectable)()
98
+ ], NotebookExecutionStateService);
99
+ class CellExecution {
100
+ get state() {
101
+ return this._state;
102
+ }
103
+ get notebookURI() {
104
+ return this.notebook.uri;
105
+ }
106
+ get didPause() {
107
+ return this._didPause;
108
+ }
109
+ get isPaused() {
110
+ return this._isPaused;
111
+ }
112
+ constructor(cellHandle, notebook) {
113
+ this.cellHandle = cellHandle;
114
+ this.notebook = notebook;
115
+ this.onDidUpdateEmitter = new core_1.Emitter();
116
+ this.onDidUpdate = this.onDidUpdateEmitter.event;
117
+ this.onDidCompleteEmitter = new core_1.Emitter();
118
+ this.onDidComplete = this.onDidCompleteEmitter.event;
119
+ this.toDispose = new core_1.DisposableCollection();
120
+ this._state = common_1.NotebookCellExecutionState.Unconfirmed;
121
+ this._didPause = false;
122
+ this._isPaused = false;
123
+ }
124
+ initialize() {
125
+ const startExecuteEdit = {
126
+ editType: 9 /* CellEditType.PartialInternalMetadata */,
127
+ handle: this.cellHandle,
128
+ internalMetadata: {
129
+ executionId: (0, core_1.generateUuid)(),
130
+ runStartTime: undefined,
131
+ runEndTime: undefined,
132
+ lastRunSuccess: undefined,
133
+ executionOrder: undefined,
134
+ renderDuration: undefined,
135
+ }
136
+ };
137
+ this.applyCellExecutionEditsToNotebook([startExecuteEdit]);
138
+ }
139
+ confirm() {
140
+ this._state = common_1.NotebookCellExecutionState.Pending;
141
+ this.onDidUpdateEmitter.fire();
142
+ }
143
+ update(updates) {
144
+ if (updates.some(u => u.editType === common_1.CellExecutionUpdateType.ExecutionState)) {
145
+ this._state = common_1.NotebookCellExecutionState.Executing;
146
+ }
147
+ if (!this._didPause && updates.some(u => u.editType === common_1.CellExecutionUpdateType.ExecutionState && u.didPause)) {
148
+ this._didPause = true;
149
+ }
150
+ const lastIsPausedUpdate = [...updates].reverse().find(u => u.editType === common_1.CellExecutionUpdateType.ExecutionState && typeof u.isPaused === 'boolean');
151
+ if (lastIsPausedUpdate) {
152
+ this._isPaused = lastIsPausedUpdate.isPaused;
153
+ }
154
+ const cellModel = this.notebook.cells.find(c => c.handle === this.cellHandle);
155
+ if (!cellModel) {
156
+ console.debug(`CellExecution#update, updating cell not in notebook: ${this.notebook.uri.toString()}, ${this.cellHandle}`);
157
+ }
158
+ else {
159
+ const edits = updates.map(update => updateToEdit(update, this.cellHandle));
160
+ this.applyCellExecutionEditsToNotebook(edits);
161
+ }
162
+ if (updates.some(u => u.editType === common_1.CellExecutionUpdateType.ExecutionState)) {
163
+ this.onDidUpdateEmitter.fire();
164
+ }
165
+ }
166
+ complete(completionData) {
167
+ const cellModel = this.notebook.cells.find(c => c.handle === this.cellHandle);
168
+ if (!cellModel) {
169
+ console.debug(`CellExecution#complete, completing cell not in notebook: ${this.notebook.uri.toString()}, ${this.cellHandle}`);
170
+ }
171
+ else {
172
+ const edit = {
173
+ editType: 9 /* CellEditType.PartialInternalMetadata */,
174
+ handle: this.cellHandle,
175
+ internalMetadata: {
176
+ lastRunSuccess: completionData.lastRunSuccess,
177
+ // eslint-disable-next-line no-null/no-null
178
+ runStartTime: this._didPause ? null : cellModel.internalMetadata.runStartTime,
179
+ // eslint-disable-next-line no-null/no-null
180
+ runEndTime: this._didPause ? null : completionData.runEndTime,
181
+ }
182
+ };
183
+ this.applyCellExecutionEditsToNotebook([edit]);
184
+ }
185
+ this.onDidCompleteEmitter.fire(completionData.lastRunSuccess);
186
+ }
187
+ dispose() {
188
+ this.onDidUpdateEmitter.dispose();
189
+ this.onDidCompleteEmitter.dispose();
190
+ this.toDispose.dispose();
191
+ }
192
+ applyCellExecutionEditsToNotebook(edits) {
193
+ this.notebook.applyEdits(edits, false);
194
+ }
195
+ }
196
+ exports.CellExecution = CellExecution;
197
+ class CellExecutionStateChangedEvent {
198
+ constructor(notebook, cellHandle, changed) {
199
+ this.notebook = notebook;
200
+ this.cellHandle = cellHandle;
201
+ this.changed = changed;
202
+ this.type = NotebookExecutionType.cell;
203
+ }
204
+ affectsCell(cell) {
205
+ const parsedUri = common_1.CellUri.parse(cell);
206
+ return !!parsedUri && this.notebook.isEqual(parsedUri.notebook) && this.cellHandle === parsedUri.handle;
207
+ }
208
+ affectsNotebook(notebook) {
209
+ return this.notebook.toString() === notebook.toString();
210
+ }
211
+ }
212
+ exports.CellExecutionStateChangedEvent = CellExecutionStateChangedEvent;
213
+ function updateToEdit(update, cellHandle) {
214
+ if (update.editType === common_1.CellExecutionUpdateType.Output) {
215
+ return {
216
+ editType: 2 /* CellEditType.Output */,
217
+ handle: update.cellHandle,
218
+ append: update.append,
219
+ outputs: update.outputs,
220
+ };
221
+ }
222
+ else if (update.editType === common_1.CellExecutionUpdateType.OutputItems) {
223
+ return {
224
+ editType: 7 /* CellEditType.OutputItems */,
225
+ items: update.items,
226
+ outputId: update.outputId,
227
+ append: update.append,
228
+ };
229
+ }
230
+ else if (update.editType === common_1.CellExecutionUpdateType.ExecutionState) {
231
+ const newInternalMetadata = {};
232
+ if (typeof update.executionOrder !== 'undefined') {
233
+ newInternalMetadata.executionOrder = update.executionOrder;
234
+ }
235
+ if (typeof update.runStartTime !== 'undefined') {
236
+ newInternalMetadata.runStartTime = update.runStartTime;
237
+ }
238
+ return {
239
+ editType: 9 /* CellEditType.PartialInternalMetadata */,
240
+ handle: cellHandle,
241
+ internalMetadata: newInternalMetadata
242
+ };
243
+ }
244
+ throw new Error('Unknown cell update type');
245
+ }
246
+ exports.updateToEdit = updateToEdit;
247
+ //# sourceMappingURL=notebook-execution-state-service.js.map