@theia/plugin-ext 1.40.1 → 1.41.0

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 (292) hide show
  1. package/lib/common/collections.d.ts +4 -0
  2. package/lib/common/collections.d.ts.map +1 -1
  3. package/lib/common/collections.js +17 -1
  4. package/lib/common/collections.js.map +1 -1
  5. package/lib/common/errors.d.ts +14 -0
  6. package/lib/common/errors.d.ts.map +1 -1
  7. package/lib/common/errors.js +17 -1
  8. package/lib/common/errors.js.map +1 -1
  9. package/lib/common/plugin-api-rpc.d.ts +286 -6
  10. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  11. package/lib/common/plugin-api-rpc.js +20 -1
  12. package/lib/common/plugin-api-rpc.js.map +1 -1
  13. package/lib/common/plugin-protocol.d.ts +27 -5
  14. package/lib/common/plugin-protocol.d.ts.map +1 -1
  15. package/lib/common/plugin-protocol.js.map +1 -1
  16. package/lib/hosted/browser/hosted-plugin.d.ts +5 -2
  17. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  18. package/lib/hosted/browser/hosted-plugin.js +21 -12
  19. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  20. package/lib/hosted/node/hosted-plugin-deployer-handler.js +1 -1
  21. package/lib/hosted/node/hosted-plugin-deployer-handler.js.map +1 -1
  22. package/lib/hosted/node/plugin-reader.d.ts +1 -1
  23. package/lib/hosted/node/plugin-reader.d.ts.map +1 -1
  24. package/lib/hosted/node/plugin-reader.js +1 -1
  25. package/lib/hosted/node/plugin-reader.js.map +1 -1
  26. package/lib/hosted/node/scanners/grammars-reader.d.ts +1 -1
  27. package/lib/hosted/node/scanners/grammars-reader.d.ts.map +1 -1
  28. package/lib/hosted/node/scanners/grammars-reader.js +5 -5
  29. package/lib/hosted/node/scanners/grammars-reader.js.map +1 -1
  30. package/lib/hosted/node/scanners/scanner-theia.d.ts +6 -6
  31. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  32. package/lib/hosted/node/scanners/scanner-theia.js +54 -41
  33. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  34. package/lib/main/browser/custom-editors/custom-editor-widget.d.ts +1 -1
  35. package/lib/main/browser/custom-editors/custom-editor-widget.d.ts.map +1 -1
  36. package/lib/main/browser/custom-editors/custom-editor-widget.js +1 -1
  37. package/lib/main/browser/custom-editors/custom-editor-widget.js.map +1 -1
  38. package/lib/main/browser/custom-editors/custom-editors-main.d.ts +1 -1
  39. package/lib/main/browser/custom-editors/custom-editors-main.d.ts.map +1 -1
  40. package/lib/main/browser/custom-editors/custom-editors-main.js +1 -1
  41. package/lib/main/browser/custom-editors/custom-editors-main.js.map +1 -1
  42. package/lib/main/browser/editors-and-documents-main.d.ts.map +1 -1
  43. package/lib/main/browser/editors-and-documents-main.js +1 -0
  44. package/lib/main/browser/editors-and-documents-main.js.map +1 -1
  45. package/lib/main/browser/languages-main.d.ts.map +1 -1
  46. package/lib/main/browser/languages-main.js +6 -4
  47. package/lib/main/browser/languages-main.js.map +1 -1
  48. package/lib/main/browser/main-context.d.ts.map +1 -1
  49. package/lib/main/browser/main-context.js +18 -0
  50. package/lib/main/browser/main-context.js.map +1 -1
  51. package/lib/main/browser/menus/menus-contribution-handler.d.ts.map +1 -1
  52. package/lib/main/browser/menus/menus-contribution-handler.js +6 -3
  53. package/lib/main/browser/menus/menus-contribution-handler.js.map +1 -1
  54. package/lib/main/browser/notebooks/notebook-documents-and-editors-main.d.ts +50 -0
  55. package/lib/main/browser/notebooks/notebook-documents-and-editors-main.d.ts.map +1 -0
  56. package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js +189 -0
  57. package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js.map +1 -0
  58. package/lib/main/browser/notebooks/notebook-documents-main.d.ts +22 -0
  59. package/lib/main/browser/notebooks/notebook-documents-main.d.ts.map +1 -0
  60. package/lib/main/browser/notebooks/notebook-documents-main.js +133 -0
  61. package/lib/main/browser/notebooks/notebook-documents-main.js.map +1 -0
  62. package/lib/main/browser/notebooks/notebook-dto.d.ts +15 -0
  63. package/lib/main/browser/notebooks/notebook-dto.d.ts.map +1 -0
  64. package/lib/main/browser/notebooks/notebook-dto.js +138 -0
  65. package/lib/main/browser/notebooks/notebook-dto.js.map +1 -0
  66. package/lib/main/browser/notebooks/notebook-editors-main.d.ts +20 -0
  67. package/lib/main/browser/notebooks/notebook-editors-main.d.ts.map +1 -0
  68. package/lib/main/browser/notebooks/notebook-editors-main.js +58 -0
  69. package/lib/main/browser/notebooks/notebook-editors-main.js.map +1 -0
  70. package/lib/main/browser/notebooks/notebook-kernels-main.d.ts +42 -0
  71. package/lib/main/browser/notebooks/notebook-kernels-main.d.ts.map +1 -0
  72. package/lib/main/browser/notebooks/notebook-kernels-main.js +230 -0
  73. package/lib/main/browser/notebooks/notebook-kernels-main.js.map +1 -0
  74. package/lib/main/browser/notebooks/notebook-renderers-main.d.ts +12 -0
  75. package/lib/main/browser/notebooks/notebook-renderers-main.d.ts.map +1 -0
  76. package/lib/main/browser/notebooks/notebook-renderers-main.js +39 -0
  77. package/lib/main/browser/notebooks/notebook-renderers-main.js.map +1 -0
  78. package/lib/main/browser/notebooks/notebooks-main.d.ts +20 -0
  79. package/lib/main/browser/notebooks/notebooks-main.d.ts.map +1 -0
  80. package/lib/main/browser/notebooks/notebooks-main.js +103 -0
  81. package/lib/main/browser/notebooks/notebooks-main.js.map +1 -0
  82. package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts +35 -0
  83. package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts.map +1 -0
  84. package/lib/main/browser/notebooks/renderers/cell-output-webview.js +204 -0
  85. package/lib/main/browser/notebooks/renderers/cell-output-webview.js.map +1 -0
  86. package/lib/main/browser/notebooks/renderers/output-webview-internal.d.ts +13 -0
  87. package/lib/main/browser/notebooks/renderers/output-webview-internal.d.ts.map +1 -0
  88. package/lib/main/browser/notebooks/renderers/output-webview-internal.js +375 -0
  89. package/lib/main/browser/notebooks/renderers/output-webview-internal.js.map +1 -0
  90. package/lib/main/browser/notebooks/renderers/webview-communication.d.ts +52 -0
  91. package/lib/main/browser/notebooks/renderers/webview-communication.d.ts.map +1 -0
  92. package/{src/typings/index.d.ts → lib/main/browser/notebooks/renderers/webview-communication.js} +8 -11
  93. package/lib/main/browser/notebooks/renderers/webview-communication.js.map +1 -0
  94. package/lib/main/browser/plugin-contribution-handler.d.ts +3 -0
  95. package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
  96. package/lib/main/browser/plugin-contribution-handler.js +31 -3
  97. package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
  98. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  99. package/lib/main/browser/plugin-ext-frontend-module.js +3 -2
  100. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  101. package/lib/main/browser/plugin-icon-theme-service.d.ts.map +1 -1
  102. package/lib/main/browser/plugin-icon-theme-service.js +6 -0
  103. package/lib/main/browser/plugin-icon-theme-service.js.map +1 -1
  104. package/lib/main/browser/plugin-shared-style.d.ts.map +1 -1
  105. package/lib/main/browser/plugin-shared-style.js +2 -1
  106. package/lib/main/browser/plugin-shared-style.js.map +1 -1
  107. package/lib/main/browser/tasks-main.js +2 -2
  108. package/lib/main/browser/tasks-main.js.map +1 -1
  109. package/lib/main/browser/terminal-main.d.ts +2 -2
  110. package/lib/main/browser/terminal-main.d.ts.map +1 -1
  111. package/lib/main/browser/terminal-main.js +4 -4
  112. package/lib/main/browser/terminal-main.js.map +1 -1
  113. package/lib/main/browser/view/tree-view-widget.d.ts +3 -1
  114. package/lib/main/browser/view/tree-view-widget.d.ts.map +1 -1
  115. package/lib/main/browser/view/tree-view-widget.js +32 -1
  116. package/lib/main/browser/view/tree-view-widget.js.map +1 -1
  117. package/lib/main/browser/view/tree-views-main.d.ts +2 -1
  118. package/lib/main/browser/view/tree-views-main.d.ts.map +1 -1
  119. package/lib/main/browser/view/tree-views-main.js +10 -0
  120. package/lib/main/browser/view/tree-views-main.js.map +1 -1
  121. package/lib/main/browser/webview/webview.d.ts +1 -0
  122. package/lib/main/browser/webview/webview.d.ts.map +1 -1
  123. package/lib/main/browser/webview/webview.js +5 -0
  124. package/lib/main/browser/webview/webview.js.map +1 -1
  125. package/lib/main/node/errors.spec.d.ts +2 -0
  126. package/lib/main/node/errors.spec.d.ts.map +1 -0
  127. package/lib/main/node/errors.spec.js +36 -0
  128. package/lib/main/node/errors.spec.js.map +1 -0
  129. package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts +5 -2
  130. package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts.map +1 -1
  131. package/lib/main/node/handlers/plugin-theia-directory-handler.js +14 -8
  132. package/lib/main/node/handlers/plugin-theia-directory-handler.js.map +1 -1
  133. package/lib/main/node/handlers/plugin-theia-file-handler.d.ts +2 -1
  134. package/lib/main/node/handlers/plugin-theia-file-handler.d.ts.map +1 -1
  135. package/lib/main/node/handlers/plugin-theia-file-handler.js +13 -5
  136. package/lib/main/node/handlers/plugin-theia-file-handler.js.map +1 -1
  137. package/lib/main/node/paths/plugin-paths-service.d.ts.map +1 -1
  138. package/lib/main/node/paths/plugin-paths-service.js +4 -9
  139. package/lib/main/node/paths/plugin-paths-service.js.map +1 -1
  140. package/lib/main/node/plugin-deployer-directory-handler-context-impl.js +8 -8
  141. package/lib/main/node/plugin-deployer-directory-handler-context-impl.js.map +1 -1
  142. package/lib/main/node/plugin-deployer-entry-impl.d.ts +2 -2
  143. package/lib/main/node/plugin-deployer-entry-impl.d.ts.map +1 -1
  144. package/lib/main/node/plugin-deployer-entry-impl.js +9 -7
  145. package/lib/main/node/plugin-deployer-entry-impl.js.map +1 -1
  146. package/lib/main/node/plugin-deployer-impl.d.ts +2 -2
  147. package/lib/main/node/plugin-deployer-impl.d.ts.map +1 -1
  148. package/lib/main/node/plugin-deployer-impl.js +16 -24
  149. package/lib/main/node/plugin-deployer-impl.js.map +1 -1
  150. package/lib/main/node/plugin-deployer-proxy-entry-impl.d.ts +2 -2
  151. package/lib/main/node/plugin-deployer-proxy-entry-impl.d.ts.map +1 -1
  152. package/lib/main/node/plugin-github-resolver.d.ts.map +1 -1
  153. package/lib/main/node/plugin-github-resolver.js +14 -6
  154. package/lib/main/node/plugin-github-resolver.js.map +1 -1
  155. package/lib/main/node/plugin-http-resolver.d.ts.map +1 -1
  156. package/lib/main/node/plugin-http-resolver.js +14 -6
  157. package/lib/main/node/plugin-http-resolver.js.map +1 -1
  158. package/lib/main/node/temp-dir-util.d.ts +1 -0
  159. package/lib/main/node/temp-dir-util.d.ts.map +1 -1
  160. package/lib/main/node/temp-dir-util.js +12 -3
  161. package/lib/main/node/temp-dir-util.js.map +1 -1
  162. package/lib/plugin/editors-and-documents.d.ts +1 -1
  163. package/lib/plugin/editors-and-documents.d.ts.map +1 -1
  164. package/lib/plugin/editors-and-documents.js +1 -1
  165. package/lib/plugin/editors-and-documents.js.map +1 -1
  166. package/lib/plugin/notebook/notebook-document.d.ts +62 -0
  167. package/lib/plugin/notebook/notebook-document.d.ts.map +1 -0
  168. package/lib/plugin/notebook/notebook-document.js +373 -0
  169. package/lib/plugin/notebook/notebook-document.js.map +1 -0
  170. package/lib/plugin/notebook/notebook-documents.d.ts +17 -0
  171. package/lib/plugin/notebook/notebook-documents.d.ts.map +1 -0
  172. package/lib/plugin/notebook/notebook-documents.js +48 -0
  173. package/lib/plugin/notebook/notebook-documents.js.map +1 -0
  174. package/lib/plugin/notebook/notebook-editor.d.ts +21 -0
  175. package/lib/plugin/notebook/notebook-editor.d.ts.map +1 -0
  176. package/lib/plugin/notebook/notebook-editor.js +99 -0
  177. package/lib/plugin/notebook/notebook-editor.js.map +1 -0
  178. package/lib/plugin/notebook/notebook-editors.d.ts +14 -0
  179. package/lib/plugin/notebook/notebook-editors.d.ts.map +1 -0
  180. package/lib/plugin/notebook/notebook-editors.js +65 -0
  181. package/lib/plugin/notebook/notebook-editors.js.map +1 -0
  182. package/lib/plugin/notebook/notebook-kernels.d.ts +37 -0
  183. package/lib/plugin/notebook/notebook-kernels.d.ts.map +1 -0
  184. package/lib/plugin/notebook/notebook-kernels.js +516 -0
  185. package/lib/plugin/notebook/notebook-kernels.js.map +1 -0
  186. package/lib/plugin/notebook/notebook-renderers.d.ts +14 -0
  187. package/lib/plugin/notebook/notebook-renderers.d.ts.map +1 -0
  188. package/lib/plugin/notebook/notebook-renderers.js +63 -0
  189. package/lib/plugin/notebook/notebook-renderers.js.map +1 -0
  190. package/lib/plugin/notebook/notebooks.d.ts +57 -0
  191. package/lib/plugin/notebook/notebooks.d.ts.map +1 -0
  192. package/lib/plugin/notebook/notebooks.js +295 -0
  193. package/lib/plugin/notebook/notebooks.js.map +1 -0
  194. package/lib/plugin/plugin-context.d.ts +2 -2
  195. package/lib/plugin/plugin-context.d.ts.map +1 -1
  196. package/lib/plugin/plugin-context.js +79 -59
  197. package/lib/plugin/plugin-context.js.map +1 -1
  198. package/lib/plugin/plugin-manager.d.ts +2 -0
  199. package/lib/plugin/plugin-manager.d.ts.map +1 -1
  200. package/lib/plugin/plugin-manager.js +9 -1
  201. package/lib/plugin/plugin-manager.js.map +1 -1
  202. package/lib/plugin/tasks/task-provider.d.ts +2 -2
  203. package/lib/plugin/tasks/task-provider.d.ts.map +1 -1
  204. package/lib/plugin/tasks/task-provider.js +7 -10
  205. package/lib/plugin/tasks/task-provider.js.map +1 -1
  206. package/lib/plugin/tasks/tasks.d.ts +3 -2
  207. package/lib/plugin/tasks/tasks.d.ts.map +1 -1
  208. package/lib/plugin/tasks/tasks.js +18 -13
  209. package/lib/plugin/tasks/tasks.js.map +1 -1
  210. package/lib/plugin/terminal-ext.d.ts +3 -0
  211. package/lib/plugin/terminal-ext.d.ts.map +1 -1
  212. package/lib/plugin/terminal-ext.js +11 -1
  213. package/lib/plugin/terminal-ext.js.map +1 -1
  214. package/lib/plugin/tree/tree-views.d.ts +15 -5
  215. package/lib/plugin/tree/tree-views.d.ts.map +1 -1
  216. package/lib/plugin/tree/tree-views.js +52 -3
  217. package/lib/plugin/tree/tree-views.js.map +1 -1
  218. package/lib/plugin/type-converters.d.ts +60 -0
  219. package/lib/plugin/type-converters.d.ts.map +1 -1
  220. package/lib/plugin/type-converters.js +372 -13
  221. package/lib/plugin/type-converters.js.map +1 -1
  222. package/lib/plugin/types-impl.d.ts +68 -29
  223. package/lib/plugin/types-impl.d.ts.map +1 -1
  224. package/lib/plugin/types-impl.js +123 -44
  225. package/lib/plugin/types-impl.js.map +1 -1
  226. package/package.json +31 -29
  227. package/src/common/collections.ts +17 -0
  228. package/src/common/errors.ts +26 -0
  229. package/src/common/plugin-api-rpc.ts +340 -5
  230. package/src/common/plugin-protocol.ts +23 -5
  231. package/src/hosted/browser/hosted-plugin.ts +21 -14
  232. package/src/hosted/node/hosted-plugin-deployer-handler.ts +1 -1
  233. package/src/hosted/node/plugin-reader.ts +1 -1
  234. package/src/hosted/node/scanners/grammars-reader.ts +6 -5
  235. package/src/hosted/node/scanners/scanner-theia.ts +55 -41
  236. package/src/main/browser/custom-editors/custom-editor-widget.ts +1 -1
  237. package/src/main/browser/custom-editors/custom-editors-main.ts +1 -1
  238. package/src/main/browser/editors-and-documents-main.ts +1 -0
  239. package/src/main/browser/languages-main.ts +7 -4
  240. package/src/main/browser/main-context.ts +19 -0
  241. package/src/main/browser/menus/menus-contribution-handler.ts +7 -4
  242. package/src/main/browser/notebooks/notebook-documents-and-editors-main.ts +238 -0
  243. package/src/main/browser/notebooks/notebook-documents-main.ts +166 -0
  244. package/src/main/browser/notebooks/notebook-dto.ts +141 -0
  245. package/src/main/browser/notebooks/notebook-editors-main.ts +70 -0
  246. package/src/main/browser/notebooks/notebook-kernels-main.ts +291 -0
  247. package/src/main/browser/notebooks/notebook-renderers-main.ts +47 -0
  248. package/src/main/browser/notebooks/notebooks-main.ts +124 -0
  249. package/src/main/browser/notebooks/renderers/cell-output-webview.tsx +198 -0
  250. package/src/main/browser/notebooks/renderers/output-webview-internal.ts +476 -0
  251. package/src/main/browser/notebooks/renderers/webview-communication.ts +79 -0
  252. package/src/main/browser/plugin-contribution-handler.ts +36 -3
  253. package/src/main/browser/plugin-ext-frontend-module.ts +7 -3
  254. package/src/main/browser/plugin-icon-theme-service.ts +6 -0
  255. package/src/main/browser/plugin-shared-style.ts +2 -1
  256. package/src/main/browser/tasks-main.ts +4 -4
  257. package/src/main/browser/terminal-main.ts +5 -5
  258. package/src/main/browser/view/tree-view-widget.tsx +36 -2
  259. package/src/main/browser/view/tree-views-main.ts +8 -0
  260. package/src/main/browser/webview/webview.ts +6 -0
  261. package/src/main/node/errors.spec.ts +37 -0
  262. package/src/main/node/handlers/plugin-theia-directory-handler.ts +18 -8
  263. package/src/main/node/handlers/plugin-theia-file-handler.ts +18 -6
  264. package/src/main/node/paths/plugin-paths-service.ts +5 -10
  265. package/src/main/node/plugin-deployer-directory-handler-context-impl.ts +8 -8
  266. package/src/main/node/plugin-deployer-entry-impl.ts +9 -7
  267. package/src/main/node/plugin-deployer-impl.ts +20 -28
  268. package/src/main/node/plugin-deployer-proxy-entry-impl.ts +2 -2
  269. package/src/main/node/plugin-github-resolver.ts +15 -8
  270. package/src/main/node/plugin-http-resolver.ts +15 -8
  271. package/src/main/node/temp-dir-util.ts +11 -2
  272. package/src/plugin/editors-and-documents.ts +1 -1
  273. package/src/plugin/notebook/notebook-document.ts +438 -0
  274. package/src/plugin/notebook/notebook-documents.ts +58 -0
  275. package/src/plugin/notebook/notebook-editor.ts +116 -0
  276. package/src/plugin/notebook/notebook-editors.ts +71 -0
  277. package/src/plugin/notebook/notebook-kernels.ts +616 -0
  278. package/src/plugin/notebook/notebook-renderers.ts +72 -0
  279. package/src/plugin/notebook/notebooks.ts +385 -0
  280. package/src/plugin/plugin-context.ts +77 -70
  281. package/src/plugin/plugin-manager.ts +9 -1
  282. package/src/plugin/tasks/task-provider.ts +9 -12
  283. package/src/plugin/tasks/tasks.ts +18 -13
  284. package/src/plugin/terminal-ext.ts +13 -1
  285. package/src/plugin/tree/tree-views.ts +57 -7
  286. package/src/plugin/type-converters.ts +370 -12
  287. package/src/plugin/types-impl.ts +162 -58
  288. package/lib/main/browser/custom-editors/undo-redo-service.d.ts +0 -24
  289. package/lib/main/browser/custom-editors/undo-redo-service.d.ts.map +0 -1
  290. package/lib/main/browser/custom-editors/undo-redo-service.js +0 -111
  291. package/lib/main/browser/custom-editors/undo-redo-service.js.map +0 -1
  292. package/src/main/browser/custom-editors/undo-redo-service.ts +0 -120
@@ -0,0 +1,189 @@
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.NotebooksAndEditorsMain = void 0;
23
+ const core_1 = require("@theia/core");
24
+ const browser_1 = require("@theia/notebook/lib/browser");
25
+ const common_1 = require("../../../common");
26
+ const notebook_dto_1 = require("./notebook-dto");
27
+ const browser_2 = require("@theia/core/lib/browser");
28
+ const collections_1 = require("../../../common/collections");
29
+ const async_mutex_1 = require("async-mutex");
30
+ class NotebookAndEditorState {
31
+ constructor(documents, textEditors, activeEditor, visibleEditors) {
32
+ this.documents = documents;
33
+ this.textEditors = textEditors;
34
+ this.activeEditor = activeEditor;
35
+ this.visibleEditors = visibleEditors;
36
+ //
37
+ }
38
+ static delta(before, after) {
39
+ if (!before) {
40
+ return {
41
+ addedDocuments: [...after.documents],
42
+ removedDocuments: [],
43
+ addedEditors: [...after.textEditors.values()],
44
+ removedEditors: [],
45
+ visibleEditors: [...after.visibleEditors].map(editor => editor[0])
46
+ };
47
+ }
48
+ const documentDelta = (0, collections_1.diffSets)(before.documents, after.documents);
49
+ const editorDelta = (0, collections_1.diffMaps)(before.textEditors, after.textEditors);
50
+ const newActiveEditor = before.activeEditor !== after.activeEditor ? after.activeEditor : undefined;
51
+ const visibleEditorDelta = (0, collections_1.diffMaps)(before.visibleEditors, after.visibleEditors);
52
+ return {
53
+ addedDocuments: documentDelta.added,
54
+ removedDocuments: documentDelta.removed.map(e => e.uri.toComponents()),
55
+ addedEditors: editorDelta.added,
56
+ removedEditors: editorDelta.removed.map(removed => removed.id),
57
+ newActiveEditor: newActiveEditor,
58
+ visibleEditors: visibleEditorDelta.added.length === 0 && visibleEditorDelta.removed.length === 0
59
+ ? undefined
60
+ : [...after.visibleEditors].map(editor => editor[0])
61
+ };
62
+ }
63
+ }
64
+ class NotebooksAndEditorsMain {
65
+ constructor(rpc, container, notebookDocumentsMain, notebookEditorsMain) {
66
+ this.notebookDocumentsMain = notebookDocumentsMain;
67
+ this.notebookEditorsMain = notebookEditorsMain;
68
+ this.disposables = new core_1.DisposableCollection();
69
+ this.editorListeners = new Map();
70
+ this.updateMutex = new async_mutex_1.Mutex();
71
+ this.proxy = rpc.getProxy(common_1.MAIN_RPC_CONTEXT.NOTEBOOKS_EXT);
72
+ this.notebookService = container.get(browser_1.NotebookService);
73
+ this.notebookEditorService = container.get(browser_1.NotebookEditorWidgetService);
74
+ this.WidgetManager = container.get(browser_2.WidgetManager);
75
+ this.notebookService.onDidAddNotebookDocument(async () => this.updateState(), this, this.disposables);
76
+ this.notebookService.onDidRemoveNotebookDocument(async () => this.updateState(), this, this.disposables);
77
+ // this.WidgetManager.onActiveEditorChanged(() => this.updateState(), this, this.disposables);
78
+ this.notebookEditorService.onDidAddNotebookEditor(async (editor) => this.handleEditorAdd(editor), this, this.disposables);
79
+ this.notebookEditorService.onDidRemoveNotebookEditor(async (editor) => this.handleEditorRemove(editor), this, this.disposables);
80
+ this.notebookEditorService.onFocusedEditorChanged(async (editor) => this.updateState(editor), this, this.disposables);
81
+ }
82
+ dispose() {
83
+ this.notebookDocumentsMain.dispose();
84
+ this.notebookEditorsMain.dispose();
85
+ this.disposables.dispose();
86
+ this.editorListeners.forEach(listeners => listeners.forEach(listener => listener.dispose()));
87
+ }
88
+ async handleEditorAdd(editor) {
89
+ const listeners = this.editorListeners.get(editor.id);
90
+ const disposable = editor.onDidChangeModel(() => this.updateState());
91
+ if (listeners) {
92
+ listeners.push(disposable);
93
+ }
94
+ else {
95
+ this.editorListeners.set(editor.id, [disposable]);
96
+ }
97
+ await this.updateState();
98
+ }
99
+ handleEditorRemove(editor) {
100
+ const listeners = this.editorListeners.get(editor.id);
101
+ listeners === null || listeners === void 0 ? void 0 : listeners.forEach(listener => listener.dispose());
102
+ this.editorListeners.delete(editor.id);
103
+ this.updateState();
104
+ }
105
+ async updateState(focusedEditor) {
106
+ await this.updateMutex.runExclusive(async () => this.doUpdateState(focusedEditor));
107
+ }
108
+ async doUpdateState(focusedEditor) {
109
+ const editors = new Map();
110
+ const visibleEditorsMap = new Map();
111
+ for (const editor of this.notebookEditorService.listNotebookEditors()) {
112
+ if (editor.model) {
113
+ editors.set(editor.id, editor);
114
+ }
115
+ }
116
+ const activeNotebookEditor = this.notebookEditorService.currentFocusedEditor;
117
+ let activeEditor = null;
118
+ if (activeNotebookEditor) {
119
+ activeEditor = activeNotebookEditor.id;
120
+ }
121
+ else if (focusedEditor === null || focusedEditor === void 0 ? void 0 : focusedEditor.model) {
122
+ activeEditor = focusedEditor.id;
123
+ }
124
+ if (activeEditor && !editors.has(activeEditor)) {
125
+ activeEditor = null;
126
+ }
127
+ const notebookEditors = this.WidgetManager.getWidgets(browser_1.NotebookEditorWidget.ID);
128
+ for (const notebookEditor of notebookEditors) {
129
+ if ((notebookEditor === null || notebookEditor === void 0 ? void 0 : notebookEditor.model) && editors.has(notebookEditor.id) && notebookEditor.isVisible) {
130
+ visibleEditorsMap.set(notebookEditor.id, notebookEditor);
131
+ }
132
+ }
133
+ const newState = new NotebookAndEditorState(new Set(this.notebookService.listNotebookDocuments()), editors, activeEditor, visibleEditorsMap);
134
+ await this.onDelta(NotebookAndEditorState.delta(this.currentState, newState));
135
+ this.currentState = newState;
136
+ }
137
+ async onDelta(delta) {
138
+ if (NotebooksAndEditorsMain._isDeltaEmpty(delta)) {
139
+ return;
140
+ }
141
+ const dto = {
142
+ removedDocuments: delta.removedDocuments,
143
+ removedEditors: delta.removedEditors,
144
+ newActiveEditor: delta.newActiveEditor,
145
+ visibleEditors: delta.visibleEditors,
146
+ addedDocuments: delta.addedDocuments.map(NotebooksAndEditorsMain.asModelAddData),
147
+ // addedEditors: delta.addedEditors.map(this.asEditorAddData, this),
148
+ };
149
+ // send to extension FIRST
150
+ await this.proxy.$acceptDocumentsAndEditorsDelta(dto);
151
+ // handle internally
152
+ this.notebookEditorsMain.handleEditorsRemoved(delta.removedEditors);
153
+ this.notebookDocumentsMain.handleNotebooksRemoved(delta.removedDocuments);
154
+ this.notebookDocumentsMain.handleNotebooksAdded(delta.addedDocuments);
155
+ this.notebookEditorsMain.handleEditorsAdded(delta.addedEditors);
156
+ }
157
+ static _isDeltaEmpty(delta) {
158
+ if (delta.addedDocuments !== undefined && delta.addedDocuments.length > 0) {
159
+ return false;
160
+ }
161
+ if (delta.removedDocuments !== undefined && delta.removedDocuments.length > 0) {
162
+ return false;
163
+ }
164
+ if (delta.addedEditors !== undefined && delta.addedEditors.length > 0) {
165
+ return false;
166
+ }
167
+ if (delta.removedEditors !== undefined && delta.removedEditors.length > 0) {
168
+ return false;
169
+ }
170
+ if (delta.visibleEditors !== undefined && delta.visibleEditors.length > 0) {
171
+ return false;
172
+ }
173
+ if (delta.newActiveEditor !== undefined) {
174
+ return false;
175
+ }
176
+ return true;
177
+ }
178
+ static asModelAddData(e) {
179
+ return {
180
+ viewType: e.viewType,
181
+ uri: e.uri.toComponents(),
182
+ metadata: e.metadata,
183
+ versionId: 1,
184
+ cells: e.cells.map(notebook_dto_1.NotebookDto.toNotebookCellDto)
185
+ };
186
+ }
187
+ }
188
+ exports.NotebooksAndEditorsMain = NotebooksAndEditorsMain;
189
+ //# sourceMappingURL=notebook-documents-and-editors-main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-documents-and-editors-main.js","sourceRoot":"","sources":["../../../../src/main/browser/notebooks/notebook-documents-and-editors-main.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,sCAA+D;AAG/D,yDAAiH;AAEjH,4CAA4J;AAE5J,iDAA6C;AAC7C,qDAAwD;AAGxD,6DAAiE;AACjE,6CAAoC;AAWpC,MAAM,sBAAsB;IA6BxB,YACa,SAA6B,EAC7B,WAA8C,EAC9C,YAAuC,EACvC,cAAiD;QAHjD,cAAS,GAAT,SAAS,CAAoB;QAC7B,gBAAW,GAAX,WAAW,CAAmC;QAC9C,iBAAY,GAAZ,YAAY,CAA2B;QACvC,mBAAc,GAAd,cAAc,CAAmC;QAE1D,EAAE;IACN,CAAC;IAnCD,MAAM,CAAC,KAAK,CAAC,MAA0C,EAAE,KAA6B;QAClF,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;gBACH,cAAc,EAAE,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;gBACpC,gBAAgB,EAAE,EAAE;gBACpB,YAAY,EAAE,CAAC,GAAG,KAAK,CAAC,WAAW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 @@
1
+ import { UriComponents } from '@theia/core/lib/common/uri';
2
+ import { interfaces } from '@theia/core/shared/inversify';
3
+ import { NotebookModel } from '@theia/notebook/lib/browser/view-model/notebook-model';
4
+ import { NotebookDataDto, NotebookDocumentsMain } from '../../../common';
5
+ import { RPCProtocol } from '../../../common/rpc-protocol';
6
+ export declare class NotebookDocumentsMainImpl implements NotebookDocumentsMain {
7
+ private readonly disposables;
8
+ private readonly proxy;
9
+ private readonly documentEventListenersMapping;
10
+ private readonly notebookModelResolverService;
11
+ constructor(rpc: RPCProtocol, container: interfaces.Container);
12
+ dispose(): void;
13
+ handleNotebooksAdded(notebooks: readonly NotebookModel[]): void;
14
+ handleNotebooksRemoved(uris: UriComponents[]): void;
15
+ $tryCreateNotebook(options: {
16
+ viewType: string;
17
+ content?: NotebookDataDto;
18
+ }): Promise<UriComponents>;
19
+ $tryOpenNotebook(uriComponents: UriComponents): Promise<UriComponents>;
20
+ $trySaveNotebook(uriComponents: UriComponents): Promise<boolean>;
21
+ }
22
+ //# sourceMappingURL=notebook-documents-main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-documents-main.d.ts","sourceRoot":"","sources":["../../../../src/main/browser/notebooks/notebook-documents-main.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAO,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,uDAAuD,CAAC;AAEtF,OAAO,EAAmE,eAAe,EAAwB,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAChK,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,qBAAa,yBAA0B,YAAW,qBAAqB;IAEnE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;IAE1D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAA2C;IAEzF,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAA+B;gBAGxE,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,UAAU,CAAC,SAAS;IAWnC,OAAO,IAAI,IAAI;IAMf,oBAAoB,CAAC,SAAS,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI;IAuE/D,sBAAsB,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI;IAO7C,kBAAkB,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,eAAe,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAoBpG,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAKtE,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;CAQzE"}
@@ -0,0 +1,133 @@
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.NotebookDocumentsMainImpl = void 0;
19
+ const core_1 = require("@theia/core");
20
+ const uri_1 = require("@theia/core/lib/common/uri");
21
+ const browser_1 = require("@theia/notebook/lib/browser");
22
+ const common_1 = require("@theia/notebook/lib/common");
23
+ const common_2 = require("../../../common");
24
+ const notebook_dto_1 = require("./notebook-dto");
25
+ class NotebookDocumentsMainImpl {
26
+ constructor(rpc, container) {
27
+ this.disposables = new core_1.DisposableCollection();
28
+ this.documentEventListenersMapping = new Map();
29
+ this.proxy = rpc.getProxy(common_2.MAIN_RPC_CONTEXT.NOTEBOOK_DOCUMENTS_EXT);
30
+ this.notebookModelResolverService = container.get(browser_1.NotebookModelResolverService);
31
+ // forward dirty and save events
32
+ this.disposables.push(this.notebookModelResolverService.onDidChangeDirty(model => this.proxy.$acceptDirtyStateChanged(model.uri.toComponents(), model.isDirty())));
33
+ this.disposables.push(this.notebookModelResolverService.onDidSaveNotebook(e => this.proxy.$acceptModelSaved(e)));
34
+ }
35
+ dispose() {
36
+ this.disposables.dispose();
37
+ // this.modelReferenceCollection.dispose();
38
+ this.documentEventListenersMapping.forEach(value => value.dispose());
39
+ }
40
+ handleNotebooksAdded(notebooks) {
41
+ for (const textModel of notebooks) {
42
+ const disposableStore = new core_1.DisposableCollection();
43
+ disposableStore.push(textModel.onDidChangeContent(event => {
44
+ const eventDto = {
45
+ versionId: 1,
46
+ rawEvents: []
47
+ };
48
+ for (const e of event.rawEvents) {
49
+ switch (e.kind) {
50
+ case common_1.NotebookCellsChangeType.ModelChange:
51
+ eventDto.rawEvents.push({
52
+ kind: e.kind,
53
+ changes: e.changes.map(diff => [diff[0], diff[1], diff[2].map(notebook_dto_1.NotebookDto.toNotebookCellDto)])
54
+ });
55
+ break;
56
+ case common_1.NotebookCellsChangeType.Move:
57
+ eventDto.rawEvents.push({
58
+ kind: e.kind,
59
+ index: e.index,
60
+ length: e.length,
61
+ newIdx: e.newIdx,
62
+ });
63
+ break;
64
+ case common_1.NotebookCellsChangeType.Output:
65
+ eventDto.rawEvents.push({
66
+ kind: e.kind,
67
+ index: e.index,
68
+ outputs: e.outputs.map(notebook_dto_1.NotebookDto.toNotebookOutputDto)
69
+ });
70
+ break;
71
+ case common_1.NotebookCellsChangeType.OutputItem:
72
+ eventDto.rawEvents.push({
73
+ kind: e.kind,
74
+ index: e.index,
75
+ outputId: e.outputId,
76
+ outputItems: e.outputItems.map(notebook_dto_1.NotebookDto.toNotebookOutputItemDto),
77
+ append: e.append
78
+ });
79
+ break;
80
+ case common_1.NotebookCellsChangeType.ChangeCellLanguage:
81
+ case common_1.NotebookCellsChangeType.ChangeCellContent:
82
+ case common_1.NotebookCellsChangeType.ChangeCellMetadata:
83
+ case common_1.NotebookCellsChangeType.ChangeCellInternalMetadata:
84
+ eventDto.rawEvents.push(e);
85
+ break;
86
+ }
87
+ }
88
+ const hasDocumentMetadataChangeEvent = event.rawEvents.find(e => e.kind === common_1.NotebookCellsChangeType.ChangeDocumentMetadata);
89
+ // using the model resolver service to know if the model is dirty or not.
90
+ // assuming this is the first listener it can mean that at first the model
91
+ // is marked as dirty and that another event is fired
92
+ this.proxy.$acceptModelChanged(textModel.uri.toComponents(), eventDto, textModel.isDirty(), hasDocumentMetadataChangeEvent ? textModel.metadata : undefined);
93
+ }));
94
+ this.documentEventListenersMapping.set(textModel.uri.toString(), disposableStore);
95
+ }
96
+ }
97
+ handleNotebooksRemoved(uris) {
98
+ var _a;
99
+ for (const uri of uris) {
100
+ (_a = this.documentEventListenersMapping.get(uri.toString())) === null || _a === void 0 ? void 0 : _a.dispose();
101
+ this.documentEventListenersMapping.delete(uri.toString());
102
+ }
103
+ }
104
+ async $tryCreateNotebook(options) {
105
+ const ref = await this.notebookModelResolverService.resolve({ untitledResource: undefined }, options.viewType);
106
+ // untitled notebooks are disposed when they get saved. we should not hold a reference
107
+ // to such a disposed notebook and therefore dispose the reference as well
108
+ // ref.onWillDispose(() => {
109
+ // ref.dispose();
110
+ // });
111
+ // untitled notebooks are dirty by default
112
+ this.proxy.$acceptDirtyStateChanged(ref.uri.toComponents(), true);
113
+ // apply content changes... slightly HACKY -> this triggers a change event
114
+ // if (options.content) {
115
+ // const data = NotebookDto.fromNotebookDataDto(options.content);
116
+ // ref.notebook.reset(data.cells, data.metadata, ref.object.notebook.transientOptions);
117
+ // }
118
+ return ref.uri.toComponents();
119
+ }
120
+ async $tryOpenNotebook(uriComponents) {
121
+ const uri = uri_1.URI.fromComponents(uriComponents);
122
+ return uri.toComponents();
123
+ }
124
+ async $trySaveNotebook(uriComponents) {
125
+ const uri = uri_1.URI.fromComponents(uriComponents);
126
+ const ref = await this.notebookModelResolverService.resolve(uri);
127
+ await ref.save({});
128
+ ref.dispose();
129
+ return true;
130
+ }
131
+ }
132
+ exports.NotebookDocumentsMainImpl = NotebookDocumentsMainImpl;
133
+ //# sourceMappingURL=notebook-documents-main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-documents-main.js","sourceRoot":"","sources":["../../../../src/main/browser/notebooks/notebook-documents-main.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,sCAAmD;AACnD,oDAAgE;AAEhE,yDAA2E;AAE3E,uDAAqE;AACrE,4CAAgK;AAEhK,iDAA6C;AAE7C,MAAa,yBAAyB;IASlC,YACI,GAAgB,EAChB,SAA+B;QATlB,gBAAW,GAAG,IAAI,2BAAoB,EAAE,CAAC;QAGzC,kCAA6B,GAAG,IAAI,GAAG,EAAgC,CAAC;QAQrF,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,yBAAgB,CAAC,sBAAsB,CAAC,CAAC;QACnE,IAAI,CAAC,4BAA4B,GAAG,SAAS,CAAC,GAAG,CAAC,sCAA4B,CAAC,CAAC;QAEhF,gCAAgC;QAChC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,EA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C,aAA4B;QAC/C,MAAM,GAAG,GAAG,SAAG,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC9C,OAAO,GAAG,CAAC,YAAY,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,aAA4B;QAC/C,MAAM,GAAG,GAAG,SAAG,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAE9C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjE,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnB,GAAG,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA3ID,8DA2IC"}
@@ -0,0 +1,15 @@
1
+ import * as notebookCommon from '@theia/notebook/lib/common';
2
+ import { NotebookCellModel } from '@theia/notebook/lib/browser/view-model/notebook-cell-model';
3
+ import * as rpc from '../../../common';
4
+ export declare namespace NotebookDto {
5
+ function toNotebookOutputItemDto(item: notebookCommon.CellOutputItem): rpc.NotebookOutputItemDto;
6
+ function toNotebookOutputDto(output: notebookCommon.CellOutput): rpc.NotebookOutputDto;
7
+ function toNotebookCellDataDto(cell: notebookCommon.CellData): rpc.NotebookCellDataDto;
8
+ function toNotebookDataDto(data: notebookCommon.NotebookData): rpc.NotebookDataDto;
9
+ function fromNotebookOutputItemDto(item: rpc.NotebookOutputItemDto): notebookCommon.CellOutputItem;
10
+ function fromNotebookOutputDto(output: rpc.NotebookOutputDto): notebookCommon.CellOutput;
11
+ function fromNotebookCellDataDto(cell: rpc.NotebookCellDataDto): notebookCommon.CellData;
12
+ function fromNotebookDataDto(data: rpc.NotebookDataDto): notebookCommon.NotebookData;
13
+ function toNotebookCellDto(cell: NotebookCellModel): rpc.NotebookCellDto;
14
+ }
15
+ //# sourceMappingURL=notebook-dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-dto.d.ts","sourceRoot":"","sources":["../../../../src/main/browser/notebooks/notebook-dto.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4DAA4D,CAAC;AAC/F,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAEvC,yBAAiB,WAAW,CAAC;IAEzB,SAAgB,uBAAuB,CAAC,IAAI,EAAE,cAAc,CAAC,cAAc,GAAG,GAAG,CAAC,qBAAqB,CAKtG;IAED,SAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,GAAG,GAAG,CAAC,iBAAiB,CAM5F;IAED,SAAgB,qBAAqB,CAAC,IAAI,EAAE,cAAc,CAAC,QAAQ,GAAG,GAAG,CAAC,mBAAmB,CAS5F;IAED,SAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,YAAY,GAAG,GAAG,CAAC,eAAe,CAKxF;IAED,SAAgB,yBAAyB,CAAC,IAAI,EAAE,GAAG,CAAC,qBAAqB,GAAG,cAAc,CAAC,cAAc,CAKxG;IAED,SAAgB,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,iBAAiB,GAAG,cAAc,CAAC,UAAU,CAM9F;IAED,SAAgB,uBAAuB,CAAC,IAAI,EAAE,GAAG,CAAC,mBAAmB,GAAG,cAAc,CAAC,QAAQ,CAS9F;IAED,SAAgB,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,eAAe,GAAG,cAAc,CAAC,YAAY,CAK1F;IAED,SAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,GAAG,CAAC,eAAe,CAa9E;CAsCJ"}
@@ -0,0 +1,138 @@
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.NotebookDto = void 0;
19
+ const core_1 = require("@theia/core");
20
+ var NotebookDto;
21
+ (function (NotebookDto) {
22
+ function toNotebookOutputItemDto(item) {
23
+ return {
24
+ mime: item.mime,
25
+ valueBytes: item.data
26
+ };
27
+ }
28
+ NotebookDto.toNotebookOutputItemDto = toNotebookOutputItemDto;
29
+ function toNotebookOutputDto(output) {
30
+ return {
31
+ outputId: output.outputId,
32
+ metadata: output.metadata,
33
+ items: output.outputs.map(toNotebookOutputItemDto)
34
+ };
35
+ }
36
+ NotebookDto.toNotebookOutputDto = toNotebookOutputDto;
37
+ function toNotebookCellDataDto(cell) {
38
+ return {
39
+ cellKind: cell.cellKind,
40
+ language: cell.language,
41
+ source: cell.source,
42
+ internalMetadata: cell.internalMetadata,
43
+ metadata: cell.metadata,
44
+ outputs: cell.outputs.map(toNotebookOutputDto)
45
+ };
46
+ }
47
+ NotebookDto.toNotebookCellDataDto = toNotebookCellDataDto;
48
+ function toNotebookDataDto(data) {
49
+ return {
50
+ metadata: data.metadata,
51
+ cells: data.cells.map(toNotebookCellDataDto)
52
+ };
53
+ }
54
+ NotebookDto.toNotebookDataDto = toNotebookDataDto;
55
+ function fromNotebookOutputItemDto(item) {
56
+ return {
57
+ mime: item.mime,
58
+ data: item.valueBytes
59
+ };
60
+ }
61
+ NotebookDto.fromNotebookOutputItemDto = fromNotebookOutputItemDto;
62
+ function fromNotebookOutputDto(output) {
63
+ return {
64
+ outputId: output.outputId,
65
+ metadata: output.metadata,
66
+ outputs: output.items.map(fromNotebookOutputItemDto)
67
+ };
68
+ }
69
+ NotebookDto.fromNotebookOutputDto = fromNotebookOutputDto;
70
+ function fromNotebookCellDataDto(cell) {
71
+ return {
72
+ cellKind: cell.cellKind,
73
+ language: cell.language,
74
+ source: cell.source,
75
+ outputs: cell.outputs.map(fromNotebookOutputDto),
76
+ metadata: cell.metadata,
77
+ internalMetadata: cell.internalMetadata
78
+ };
79
+ }
80
+ NotebookDto.fromNotebookCellDataDto = fromNotebookCellDataDto;
81
+ function fromNotebookDataDto(data) {
82
+ return {
83
+ metadata: data.metadata,
84
+ cells: data.cells.map(fromNotebookCellDataDto)
85
+ };
86
+ }
87
+ NotebookDto.fromNotebookDataDto = fromNotebookDataDto;
88
+ function toNotebookCellDto(cell) {
89
+ const eol = core_1.OS.backend.isWindows ? '\r\n' : '\n';
90
+ return {
91
+ handle: cell.handle,
92
+ uri: cell.uri.toComponents(),
93
+ source: cell.textBuffer.split(eol),
94
+ eol,
95
+ language: cell.language,
96
+ cellKind: cell.cellKind,
97
+ outputs: cell.outputs.map(toNotebookOutputDto),
98
+ metadata: cell.metadata,
99
+ internalMetadata: cell.internalMetadata,
100
+ };
101
+ }
102
+ NotebookDto.toNotebookCellDto = toNotebookCellDto;
103
+ // export function fromCellExecuteUpdateDto(data: extHostProtocol.ICellExecuteUpdateDto): ICellExecuteUpdate {
104
+ // if (data.editType === CellExecutionUpdateType.Output) {
105
+ // return {
106
+ // editType: data.editType,
107
+ // cellHandle: data.cellHandle,
108
+ // append: data.append,
109
+ // outputs: data.outputs.map(fromNotebookOutputDto)
110
+ // };
111
+ // } else if (data.editType === CellExecutionUpdateType.OutputItems) {
112
+ // return {
113
+ // editType: data.editType,
114
+ // append: data.append,
115
+ // outputId: data.outputId,
116
+ // items: data.items.map(fromNotebookOutputItemDto)
117
+ // };
118
+ // } else {
119
+ // return data;
120
+ // }
121
+ // }
122
+ // export function fromCellExecuteCompleteDto(data: extHostProtocol.ICellExecutionCompleteDto): ICellExecutionComplete {
123
+ // return data;
124
+ // }
125
+ // export function fromCellEditOperationDto(edit: extHostProtocol.ICellEditOperationDto): notebookCommon.ICellEditOperation {
126
+ // if (edit.editType === notebookCommon.CellEditType.Replace) {
127
+ // return {
128
+ // editType: edit.editType,
129
+ // index: edit.index,
130
+ // count: edit.count,
131
+ // cells: edit.cells.map(fromNotebookCellDataDto)
132
+ // };
133
+ // } else {
134
+ // return edit;
135
+ // }
136
+ // }
137
+ })(NotebookDto = exports.NotebookDto || (exports.NotebookDto = {}));
138
+ //# sourceMappingURL=notebook-dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-dto.js","sourceRoot":"","sources":["../../../../src/main/browser/notebooks/notebook-dto.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,sCAAiC;AAKjC,IAAiB,WAAW,CAuH3B;AAvHD,WAAiB,WAAW;IAExB,SAAgB,uBAAuB,CAAC,IAAmC;QACvE,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,IAAI;SACxB,CAAC;IACN,CAAC;IALe,mCAAuB,0BAKtC,CAAA;IAED,SAAgB,mBAAmB,CAAC,MAAiC;QACjE,OAAO;YACH,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;SACrD,CAAC;IACN,CAAC;IANe,+BAAmB,sBAMlC,CAAA;IAED,SAAgB,qBAAqB,CAAC,IAA6B;QAC/D,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,C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ACvB,QAAQ;IACR,IAAI;AACR,CAAC,EAvHgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAuH3B"}
@@ -0,0 +1,20 @@
1
+ import { UriComponents } from '@theia/core/lib/common/uri';
2
+ import { CellRange } from '@theia/notebook/lib/common';
3
+ import { NotebookEditorWidget } from '@theia/notebook/lib/browser';
4
+ import { NotebookDocumentShowOptions, NotebookEditorRevealType, NotebookEditorsExt, NotebookEditorsMain } from '../../../common';
5
+ import { RPCProtocol } from '../../../common/rpc-protocol';
6
+ import { interfaces } from '@theia/core/shared/inversify';
7
+ import { OpenerService } from '@theia/core/lib/browser';
8
+ export declare class NotebookEditorsMainImpl implements NotebookEditorsMain {
9
+ protected readonly proxy: NotebookEditorsExt;
10
+ protected readonly openerService: OpenerService;
11
+ protected readonly mainThreadEditors: Map<string, NotebookEditorWidget>;
12
+ constructor(rpc: RPCProtocol, container: interfaces.Container);
13
+ $tryShowNotebookDocument(uriComponents: UriComponents, viewType: string, options: NotebookDocumentShowOptions): Promise<string>;
14
+ $tryRevealRange(id: string, range: CellRange, revealType: NotebookEditorRevealType): Promise<void>;
15
+ $trySetSelections(id: string, range: CellRange[]): void;
16
+ handleEditorsAdded(editors: readonly NotebookEditorWidget[]): void;
17
+ handleEditorsRemoved(editorIds: readonly string[]): void;
18
+ dispose(): void;
19
+ }
20
+ //# sourceMappingURL=notebook-editors-main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-editors-main.d.ts","sourceRoot":"","sources":["../../../../src/main/browser/notebooks/notebook-editors-main.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,aAAa,EAAO,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAoB,2BAA2B,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnJ,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAQ,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE9D,qBAAa,uBAAwB,YAAW,mBAAmB;IAE/D,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IAC7C,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAEhD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,oCAA2C;gBAG3E,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,UAAU,CAAC,SAAS;IAM7B,wBAAwB,CAAC,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrI,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAGlG,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI;IAIvD,kBAAkB,CAAC,OAAO,EAAE,SAAS,oBAAoB,EAAE,GAAG,IAAI;IAMlE,oBAAoB,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAOxD,OAAO,IAAI,IAAI;CAElB"}
@@ -0,0 +1,58 @@
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.NotebookEditorsMainImpl = void 0;
23
+ const uri_1 = require("@theia/core/lib/common/uri");
24
+ const common_1 = require("../../../common");
25
+ const browser_1 = require("@theia/core/lib/browser");
26
+ class NotebookEditorsMainImpl {
27
+ constructor(rpc, container) {
28
+ this.mainThreadEditors = new Map();
29
+ this.proxy = rpc.getProxy(common_1.MAIN_RPC_CONTEXT.NOTEBOOK_EDITORS_EXT);
30
+ this.openerService = container.get(browser_1.OpenerService);
31
+ }
32
+ async $tryShowNotebookDocument(uriComponents, viewType, options) {
33
+ const editor = await (0, browser_1.open)(this.openerService, uri_1.URI.fromComponents(uriComponents), {});
34
+ return editor.id;
35
+ }
36
+ $tryRevealRange(id, range, revealType) {
37
+ throw new Error('Method not implemented.');
38
+ }
39
+ $trySetSelections(id, range) {
40
+ throw new Error('Method not implemented.');
41
+ }
42
+ handleEditorsAdded(editors) {
43
+ for (const editor of editors) {
44
+ this.mainThreadEditors.set(editor.id, editor);
45
+ }
46
+ }
47
+ handleEditorsRemoved(editorIds) {
48
+ var _a;
49
+ for (const id of editorIds) {
50
+ (_a = this.mainThreadEditors.get(id)) === null || _a === void 0 ? void 0 : _a.dispose();
51
+ this.mainThreadEditors.delete(id);
52
+ }
53
+ }
54
+ dispose() {
55
+ }
56
+ }
57
+ exports.NotebookEditorsMainImpl = NotebookEditorsMainImpl;
58
+ //# sourceMappingURL=notebook-editors-main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-editors-main.js","sourceRoot":"","sources":["../../../../src/main/browser/notebooks/notebook-editors-main.ts"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