@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
@@ -32,6 +32,7 @@ import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from '@the
32
32
  import * as paths from 'path';
33
33
  import { es5ClassCompat } from '../common/types';
34
34
  import { isObject, isStringArray } from '@theia/core/lib/common';
35
+ import { CellEditType, CellMetadataEdit, NotebookDocumentMetadataEdit } from '@theia/notebook/lib/common';
35
36
 
36
37
  /**
37
38
  * This is an implementation of #theia.Uri based on vscode-uri.
@@ -1130,6 +1131,31 @@ export enum NotebookEditorRevealType {
1130
1131
  InCenterIfOutsideViewport = 2,
1131
1132
  AtTop = 3
1132
1133
  }
1134
+
1135
+ export enum NotebookCellExecutionState {
1136
+ /**
1137
+ * The cell is idle.
1138
+ */
1139
+ Idle = 1,
1140
+ /**
1141
+ * Execution for the cell is pending.
1142
+ */
1143
+ Pending = 2,
1144
+ /**
1145
+ * The cell is currently executing.
1146
+ */
1147
+ Executing = 3,
1148
+ }
1149
+
1150
+ export class NotebookKernelSourceAction {
1151
+ description?: string;
1152
+ detail?: string;
1153
+ command?: theia.Command;
1154
+ constructor(
1155
+ public label: string
1156
+ ) { }
1157
+ }
1158
+
1133
1159
  @es5ClassCompat
1134
1160
  export class NotebookCellData implements theia.NotebookCellData {
1135
1161
  languageId: string;
@@ -1140,23 +1166,34 @@ export class NotebookCellData implements theia.NotebookCellData {
1140
1166
  metadata?: { [key: string]: any };
1141
1167
  executionSummary?: theia.NotebookCellExecutionSummary;
1142
1168
 
1143
- constructor(kind: NotebookCellKind, value: string, languageId: string) {
1169
+ constructor(kind: NotebookCellKind, value: string, languageId: string,
1170
+ outputs?: theia.NotebookCellOutput[], metadata?: Record<string, unknown>, executionSummary?: theia.NotebookCellExecutionSummary) {
1144
1171
  this.kind = kind;
1145
1172
  this.value = value;
1146
1173
  this.languageId = languageId;
1174
+ this.outputs = outputs ?? [];
1175
+ this.metadata = metadata;
1176
+ this.executionSummary = executionSummary;
1147
1177
  }
1148
1178
  }
1149
1179
 
1150
1180
  @es5ClassCompat
1151
1181
  export class NotebookCellOutput implements theia.NotebookCellOutput {
1182
+ outputId: string;
1152
1183
  items: theia.NotebookCellOutputItem[];
1153
1184
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1154
1185
  metadata?: { [key: string]: any };
1155
1186
 
1156
1187
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1157
- constructor(items: theia.NotebookCellOutputItem[], metadata?: { [key: string]: any }) {
1188
+ constructor(items: theia.NotebookCellOutputItem[], idOrMetadata?: string | Record<string, any>, metadata?: { [key: string]: any }) {
1158
1189
  this.items = items;
1159
- this.metadata = metadata;
1190
+ if (typeof idOrMetadata === 'string') {
1191
+ this.outputId = idOrMetadata;
1192
+ this.metadata = metadata;
1193
+ } else {
1194
+ this.outputId = UUID.uuid4();
1195
+ this.metadata = idOrMetadata ?? metadata;
1196
+ }
1160
1197
  }
1161
1198
  }
1162
1199
 
@@ -1227,41 +1264,18 @@ export class NotebookData implements theia.NotebookData {
1227
1264
  }
1228
1265
  }
1229
1266
 
1230
- export class NotebookDocument implements theia.NotebookDocument {
1231
- readonly uri: theia.Uri;
1232
- readonly notebookType: string;
1233
- readonly version: number;
1234
- readonly isDirty: boolean;
1235
- readonly isUntitled: boolean;
1236
- readonly isClosed: boolean;
1237
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1238
- readonly metadata: { [key: string]: any };
1239
- readonly cellCount: number;
1240
-
1241
- cellAt(index: number): theia.NotebookCell {
1242
- return {} as theia.NotebookCell;
1243
- }
1244
- save(): theia.Thenable<boolean> {
1245
- return Promise.resolve(false);
1246
- }
1247
-
1248
- getCells(range?: theia.NotebookRange | undefined): theia.NotebookCell[] {
1249
- return [] as NotebookCell[];
1267
+ export class NotebookRange implements theia.NotebookRange {
1268
+ static isNotebookRange(thing: unknown): thing is theia.NotebookRange {
1269
+ if (thing instanceof NotebookRange) {
1270
+ return true;
1271
+ }
1272
+ if (!thing) {
1273
+ return false;
1274
+ }
1275
+ return typeof (<NotebookRange>thing).start === 'number'
1276
+ && typeof (<NotebookRange>thing).end === 'number';
1250
1277
  }
1251
- }
1252
- export class NotebookCell implements theia.NotebookCell {
1253
- readonly index: number;
1254
- readonly notebook: theia.NotebookDocument;
1255
- readonly kind: theia.NotebookCellKind;
1256
- readonly document: theia.TextDocument;
1257
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1258
- readonly metadata: { readonly [key: string]: any; };
1259
- readonly outputs: readonly theia.NotebookCellOutput[];
1260
- readonly executionSummary: theia.NotebookCellExecutionSummary | undefined;
1261
1278
 
1262
- }
1263
-
1264
- export class NotebookRange implements theia.NotebookRange {
1265
1279
  readonly start: number;
1266
1280
  readonly end: number;
1267
1281
  readonly isEmpty: boolean;
@@ -1322,27 +1336,58 @@ export class NotebookEdit implements theia.NotebookEdit {
1322
1336
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1323
1337
  newNotebookMetadata?: { [key: string]: any; } | undefined;
1324
1338
 
1339
+ static isNotebookCellEdit(thing: unknown): thing is NotebookEdit {
1340
+ if (thing instanceof NotebookEdit) {
1341
+ return true;
1342
+ }
1343
+ if (!thing) {
1344
+ return false;
1345
+ }
1346
+ return NotebookRange.isNotebookRange((<NotebookEdit>thing))
1347
+ && Array.isArray((<NotebookEdit>thing).newCells);
1348
+ }
1349
+
1325
1350
  static replaceCells(range: NotebookRange, newCells: NotebookCellData[]): NotebookEdit {
1326
- return new NotebookEdit();
1351
+ return new NotebookEdit(range, newCells);
1327
1352
  }
1328
1353
 
1329
1354
  static insertCells(index: number, newCells: NotebookCellData[]): NotebookEdit {
1330
- return new NotebookEdit();
1355
+ return new NotebookEdit(new NotebookRange(index, index), newCells);
1331
1356
  }
1332
1357
 
1333
1358
  static deleteCells(range: NotebookRange): NotebookEdit {
1334
- return new NotebookEdit();
1359
+ return new NotebookEdit(range, []);
1335
1360
  }
1336
1361
 
1337
1362
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1338
1363
  static updateCellMetadata(index: number, newCellMetadata: { [key: string]: any }): NotebookEdit {
1339
- return new NotebookEdit();
1364
+ return new NotebookEdit(new NotebookRange(index, index), [], newCellMetadata);
1340
1365
  }
1341
1366
 
1342
1367
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1343
1368
  static updateNotebookMetadata(newNotebookMetadata: { [key: string]: any }): NotebookEdit {
1344
- return new NotebookEdit();
1369
+ return new NotebookEdit(new NotebookRange(0, 0), [], undefined, newNotebookMetadata);
1345
1370
  }
1371
+
1372
+ constructor(range: NotebookRange, newCells: NotebookCellData[], newCellMetadata?: { [key: string]: unknown }, newNotebookMetadata?: { [key: string]: unknown }) {
1373
+ this.range = range;
1374
+ this.newCells = newCells;
1375
+ this.newCellMetadata = newCellMetadata;
1376
+ this.newNotebookMetadata = newNotebookMetadata;
1377
+ }
1378
+
1379
+ }
1380
+
1381
+ export class NotebookRendererScript implements theia.NotebookRendererScript {
1382
+ provides: readonly string[];
1383
+
1384
+ constructor(
1385
+ public uri: theia.Uri,
1386
+ provides?: string | readonly string[]
1387
+ ) {
1388
+ this.provides = Array.isArray(provides) ? provides : [provides];
1389
+ };
1390
+
1346
1391
  }
1347
1392
 
1348
1393
  @es5ClassCompat
@@ -1681,6 +1726,9 @@ export interface WorkspaceEditMetadata {
1681
1726
  export const enum FileEditType {
1682
1727
  File = 1,
1683
1728
  Text = 2,
1729
+ // eslint-disable-next-line @typescript-eslint/no-shadow
1730
+ Cell = 3,
1731
+ CellReplace = 5,
1684
1732
  Snippet = 6,
1685
1733
  }
1686
1734
 
@@ -1707,7 +1755,24 @@ export interface FileSnippetTextEdit {
1707
1755
  readonly metadata?: theia.WorkspaceEditEntryMetadata;
1708
1756
  }
1709
1757
 
1710
- type WorkspaceEditEntry = FileOperation | FileTextEdit | FileSnippetTextEdit | undefined;
1758
+ export interface FileCellEdit {
1759
+ readonly _type: FileEditType.Cell;
1760
+ readonly uri: URI;
1761
+ readonly edit?: CellMetadataEdit | NotebookDocumentMetadataEdit;
1762
+ readonly notebookMetadata?: Record<string, unknown>;
1763
+ readonly metadata?: theia.WorkspaceEditEntryMetadata;
1764
+ }
1765
+
1766
+ export interface CellEdit {
1767
+ readonly _type: FileEditType.CellReplace;
1768
+ readonly metadata?: theia.WorkspaceEditEntryMetadata;
1769
+ readonly uri: URI;
1770
+ readonly index: number;
1771
+ readonly count: number;
1772
+ readonly cells: theia.NotebookCellData[];
1773
+ }
1774
+
1775
+ type WorkspaceEditEntry = FileOperation | FileTextEdit | FileSnippetTextEdit | FileCellEdit | CellEdit | undefined;
1711
1776
 
1712
1777
  @es5ClassCompat
1713
1778
  export class WorkspaceEdit implements theia.WorkspaceEdit {
@@ -1749,8 +1814,12 @@ export class WorkspaceEdit implements theia.WorkspaceEdit {
1749
1814
 
1750
1815
  set(uri: URI, edits: ReadonlyArray<TextEdit | SnippetTextEdit>): void;
1751
1816
  set(uri: URI, edits: ReadonlyArray<[TextEdit | SnippetTextEdit, theia.WorkspaceEditEntryMetadata]>): void;
1817
+ set(uri: URI, edits: ReadonlyArray<NotebookEdit>): void;
1818
+ set(uri: URI, edits: ReadonlyArray<[NotebookEdit, theia.WorkspaceEditEntryMetadata]>): void;
1752
1819
 
1753
- set(uri: URI, edits: ReadonlyArray<TextEdit | SnippetTextEdit | [TextEdit | SnippetTextEdit, theia.WorkspaceEditEntryMetadata]>): void {
1820
+ set(uri: URI, edits: ReadonlyArray<TextEdit | SnippetTextEdit
1821
+ | NotebookEdit | [NotebookEdit, theia.WorkspaceEditEntryMetadata]
1822
+ | [TextEdit | SnippetTextEdit, theia.WorkspaceEditEntryMetadata]>): void {
1754
1823
  if (!edits) {
1755
1824
  // remove all text edits for `uri`
1756
1825
  for (let i = 0; i < this._edits.length; i++) {
@@ -1769,7 +1838,7 @@ export class WorkspaceEdit implements theia.WorkspaceEdit {
1769
1838
  continue;
1770
1839
  }
1771
1840
 
1772
- let edit: TextEdit | SnippetTextEdit;
1841
+ let edit: TextEdit | SnippetTextEdit | NotebookEdit;
1773
1842
  let metadata: theia.WorkspaceEditEntryMetadata | undefined;
1774
1843
  if (Array.isArray(editOrTuple)) {
1775
1844
  edit = editOrTuple[0];
@@ -1778,7 +1847,27 @@ export class WorkspaceEdit implements theia.WorkspaceEdit {
1778
1847
  edit = editOrTuple;
1779
1848
  }
1780
1849
 
1781
- if (SnippetTextEdit.isSnippetTextEdit(edit)) {
1850
+ if (NotebookEdit.isNotebookCellEdit(edit)) {
1851
+ if (edit.newCellMetadata) {
1852
+ this._edits.push({
1853
+ _type: FileEditType.Cell, metadata, uri,
1854
+ edit: { editType: CellEditType.Metadata, index: edit.range.start, metadata: edit.newCellMetadata }
1855
+ });
1856
+ } else if (edit.newNotebookMetadata) {
1857
+ this._edits.push({
1858
+ _type: FileEditType.Cell, metadata, uri,
1859
+ edit: { editType: CellEditType.DocumentMetadata, metadata: edit.newNotebookMetadata }, notebookMetadata: edit.newNotebookMetadata
1860
+ });
1861
+ } else {
1862
+ const start = edit.range.start;
1863
+ const end = edit.range.end;
1864
+
1865
+ if (start !== end || edit.newCells.length > 0) {
1866
+ this._edits.push({ _type: FileEditType.CellReplace, uri, index: start, count: end - start, cells: edit.newCells, metadata });
1867
+ }
1868
+ }
1869
+
1870
+ } else if (SnippetTextEdit.isSnippetTextEdit(edit)) {
1782
1871
  this._edits.push({ _type: FileEditType.Snippet, uri, range: edit.range, edit, metadata });
1783
1872
  } else {
1784
1873
  this._edits.push({ _type: FileEditType.Text, uri, edit });
@@ -1817,19 +1906,23 @@ export class WorkspaceEdit implements theia.WorkspaceEdit {
1817
1906
  return result;
1818
1907
  }
1819
1908
 
1820
- _allEntries(): ([URI, Array<TextEdit | SnippetTextEdit>, theia.WorkspaceEditEntryMetadata] | [URI, URI, FileOperationOptions, WorkspaceEditMetadata])[] {
1821
- const res: ([URI, Array<TextEdit | SnippetTextEdit>, theia.WorkspaceEditEntryMetadata] | [URI, URI, FileOperationOptions, WorkspaceEditMetadata])[] = [];
1822
- for (const edit of this._edits) {
1823
- if (!edit) {
1824
- continue;
1825
- }
1826
- if (edit._type === FileEditType.File) {
1827
- res.push([edit.from!, edit.to!, edit.options!, edit.metadata!]);
1828
- } else {
1829
- res.push([edit.uri, [edit.edit], edit.metadata!]);
1830
- }
1831
- }
1832
- return res;
1909
+ // _allEntries(): ([URI, Array<TextEdit | SnippetTextEdit>, theia.WorkspaceEditEntryMetadata] | [URI, URI, FileOperationOptions, WorkspaceEditMetadata])[] {
1910
+ // const res: ([URI, Array<TextEdit | SnippetTextEdit>, theia.WorkspaceEditEntryMetadata] | [URI, URI, FileOperationOptions, WorkspaceEditMetadata])[] = [];
1911
+ // for (const edit of this._edits) {
1912
+ // if (!edit) {
1913
+ // continue;
1914
+ // }
1915
+ // if (edit._type === FileEditType.File) {
1916
+ // res.push([edit.from!, edit.to!, edit.options!, edit.metadata!]);
1917
+ // } else {
1918
+ // res.push([edit.uri, [edit.edit], edit.metadata!]);
1919
+ // }
1920
+ // }
1921
+ // return res;
1922
+ // }
1923
+
1924
+ _allEntries(): ReadonlyArray<WorkspaceEditEntry> {
1925
+ return this._edits;
1833
1926
  }
1834
1927
 
1835
1928
  get size(): number {
@@ -1908,6 +2001,12 @@ export class TreeItem {
1908
2001
 
1909
2002
  contextValue?: string;
1910
2003
 
2004
+ checkboxState?: theia.TreeItemCheckboxState | {
2005
+ readonly state: theia.TreeItemCheckboxState;
2006
+ readonly tooltip?: string;
2007
+ readonly accessibilityInformation?: AccessibilityInformation
2008
+ };
2009
+
1911
2010
  constructor(label: string | theia.TreeItemLabel, collapsibleState?: theia.TreeItemCollapsibleState)
1912
2011
  constructor(resourceUri: URI, collapsibleState?: theia.TreeItemCollapsibleState)
1913
2012
  constructor(arg1: string | theia.TreeItemLabel | URI, public collapsibleState: theia.TreeItemCollapsibleState = TreeItemCollapsibleState.None) {
@@ -1925,6 +2024,11 @@ export enum TreeItemCollapsibleState {
1925
2024
  Expanded = 2
1926
2025
  }
1927
2026
 
2027
+ export enum TreeItemCheckboxState {
2028
+ Unchecked = 0,
2029
+ Checked = 1
2030
+ }
2031
+
1928
2032
  export enum SymbolTag {
1929
2033
  Deprecated = 1
1930
2034
  }
@@ -1,24 +0,0 @@
1
- import URI from '@theia/core/lib/common/uri';
2
- export declare class UndoRedoService {
3
- private readonly editStacks;
4
- pushElement(resource: URI, undo: () => Promise<void>, redo: () => Promise<void>): void;
5
- removeElements(resource: URI): void;
6
- undo(resource: URI): void;
7
- redo(resource: URI): void;
8
- }
9
- interface StackElement {
10
- undo(): Promise<void> | void;
11
- redo(): Promise<void> | void;
12
- }
13
- export declare class ResourceEditStack {
14
- private past;
15
- private future;
16
- constructor();
17
- pushElement(element: StackElement): void;
18
- getClosestPastElement(): StackElement | null;
19
- getClosestFutureElement(): StackElement | null;
20
- moveBackward(element: StackElement): void;
21
- moveForward(element: StackElement): void;
22
- }
23
- export {};
24
- //# sourceMappingURL=undo-redo-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"undo-redo-service.d.ts","sourceRoot":"","sources":["../../../../src/main/browser/custom-editors/undo-redo-service.ts"],"names":[],"mappings":"AAsBA,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAE7C,qBACa,eAAe;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwC;IAEnE,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAYtF,cAAc,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAMnC,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAezB,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;CAc5B;AAED,UAAU,YAAY;IAClB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAChC;AAED,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,MAAM,CAAiB;;IAO/B,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAKxC,qBAAqB,IAAI,YAAY,GAAG,IAAI;IAO5C,uBAAuB,IAAI,YAAY,GAAG,IAAI;IAO9C,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAKzC,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;CAI3C"}
@@ -1,111 +0,0 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2021 SAP SE or an SAP affiliate company 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
- // copied and modified from https://github.com/microsoft/vscode/blob/53eac52308c4611000a171cc7bf1214293473c78/src/vs/platform/undoRedo/common/undoRedoService.ts#
22
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
23
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
25
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
26
- return c > 3 && r && Object.defineProperty(target, key, r), r;
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ResourceEditStack = exports.UndoRedoService = void 0;
30
- const inversify_1 = require("@theia/core/shared/inversify");
31
- let UndoRedoService = class UndoRedoService {
32
- constructor() {
33
- this.editStacks = new Map();
34
- }
35
- pushElement(resource, undo, redo) {
36
- let editStack;
37
- if (this.editStacks.has(resource.toString())) {
38
- editStack = this.editStacks.get(resource.toString());
39
- }
40
- else {
41
- editStack = new ResourceEditStack();
42
- this.editStacks.set(resource.toString(), editStack);
43
- }
44
- editStack.pushElement({ undo, redo });
45
- }
46
- removeElements(resource) {
47
- if (this.editStacks.has(resource.toString())) {
48
- this.editStacks.delete(resource.toString());
49
- }
50
- }
51
- undo(resource) {
52
- if (!this.editStacks.has(resource.toString())) {
53
- return;
54
- }
55
- const editStack = this.editStacks.get(resource.toString());
56
- const element = editStack.getClosestPastElement();
57
- if (!element) {
58
- return;
59
- }
60
- editStack.moveBackward(element);
61
- element.undo();
62
- }
63
- redo(resource) {
64
- if (!this.editStacks.has(resource.toString())) {
65
- return;
66
- }
67
- const editStack = this.editStacks.get(resource.toString());
68
- const element = editStack.getClosestFutureElement();
69
- if (!element) {
70
- return;
71
- }
72
- editStack.moveForward(element);
73
- element.redo();
74
- }
75
- };
76
- UndoRedoService = __decorate([
77
- (0, inversify_1.injectable)()
78
- ], UndoRedoService);
79
- exports.UndoRedoService = UndoRedoService;
80
- class ResourceEditStack {
81
- constructor() {
82
- this.past = [];
83
- this.future = [];
84
- }
85
- pushElement(element) {
86
- this.future = [];
87
- this.past.push(element);
88
- }
89
- getClosestPastElement() {
90
- if (this.past.length === 0) {
91
- return null;
92
- }
93
- return this.past[this.past.length - 1];
94
- }
95
- getClosestFutureElement() {
96
- if (this.future.length === 0) {
97
- return null;
98
- }
99
- return this.future[this.future.length - 1];
100
- }
101
- moveBackward(element) {
102
- this.past.pop();
103
- this.future.push(element);
104
- }
105
- moveForward(element) {
106
- this.future.pop();
107
- this.past.push(element);
108
- }
109
- }
110
- exports.ResourceEditStack = ResourceEditStack;
111
- //# sourceMappingURL=undo-redo-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"undo-redo-service.js","sourceRoot":"","sources":["../../../../src/main/browser/custom-editors/undo-redo-service.ts"],"names":[],"mappings":"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"}
@@ -1,120 +0,0 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
- /*---------------------------------------------------------------------------------------------
17
- * Copyright (c) Microsoft Corporation. All rights reserved.
18
- * Licensed under the MIT License. See License.txt in the project root for license information.
19
- *--------------------------------------------------------------------------------------------*/
20
- // copied and modified from https://github.com/microsoft/vscode/blob/53eac52308c4611000a171cc7bf1214293473c78/src/vs/platform/undoRedo/common/undoRedoService.ts#
21
-
22
- import { injectable } from '@theia/core/shared/inversify';
23
- import URI from '@theia/core/lib/common/uri';
24
-
25
- @injectable()
26
- export class UndoRedoService {
27
- private readonly editStacks = new Map<string, ResourceEditStack>();
28
-
29
- pushElement(resource: URI, undo: () => Promise<void>, redo: () => Promise<void>): void {
30
- let editStack: ResourceEditStack;
31
- if (this.editStacks.has(resource.toString())) {
32
- editStack = this.editStacks.get(resource.toString())!;
33
- } else {
34
- editStack = new ResourceEditStack();
35
- this.editStacks.set(resource.toString(), editStack);
36
- }
37
-
38
- editStack.pushElement({ undo, redo });
39
- }
40
-
41
- removeElements(resource: URI): void {
42
- if (this.editStacks.has(resource.toString())) {
43
- this.editStacks.delete(resource.toString());
44
- }
45
- }
46
-
47
- undo(resource: URI): void {
48
- if (!this.editStacks.has(resource.toString())) {
49
- return;
50
- }
51
-
52
- const editStack = this.editStacks.get(resource.toString())!;
53
- const element = editStack.getClosestPastElement();
54
- if (!element) {
55
- return;
56
- }
57
-
58
- editStack.moveBackward(element);
59
- element.undo();
60
- }
61
-
62
- redo(resource: URI): void {
63
- if (!this.editStacks.has(resource.toString())) {
64
- return;
65
- }
66
-
67
- const editStack = this.editStacks.get(resource.toString())!;
68
- const element = editStack.getClosestFutureElement();
69
- if (!element) {
70
- return;
71
- }
72
-
73
- editStack.moveForward(element);
74
- element.redo();
75
- }
76
- }
77
-
78
- interface StackElement {
79
- undo(): Promise<void> | void;
80
- redo(): Promise<void> | void;
81
- }
82
-
83
- export class ResourceEditStack {
84
- private past: StackElement[];
85
- private future: StackElement[];
86
-
87
- constructor() {
88
- this.past = [];
89
- this.future = [];
90
- }
91
-
92
- pushElement(element: StackElement): void {
93
- this.future = [];
94
- this.past.push(element);
95
- }
96
-
97
- getClosestPastElement(): StackElement | null {
98
- if (this.past.length === 0) {
99
- return null;
100
- }
101
- return this.past[this.past.length - 1];
102
- }
103
-
104
- getClosestFutureElement(): StackElement | null {
105
- if (this.future.length === 0) {
106
- return null;
107
- }
108
- return this.future[this.future.length - 1];
109
- }
110
-
111
- moveBackward(element: StackElement): void {
112
- this.past.pop();
113
- this.future.push(element);
114
- }
115
-
116
- moveForward(element: StackElement): void {
117
- this.future.pop();
118
- this.past.push(element);
119
- }
120
- }