@difizen/libro-jupyter 0.0.2-alpha.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 (267) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/es/add-between-cell/add-between-cell-command-contribution.d.ts +14 -0
  4. package/es/add-between-cell/add-between-cell-command-contribution.d.ts.map +1 -0
  5. package/es/add-between-cell/add-between-cell-command-contribution.js +97 -0
  6. package/es/add-between-cell/add-between-cell.d.ts +5 -0
  7. package/es/add-between-cell/add-between-cell.d.ts.map +1 -0
  8. package/es/add-between-cell/add-between-cell.js +243 -0
  9. package/es/add-between-cell/index.d.ts +3 -0
  10. package/es/add-between-cell/index.d.ts.map +1 -0
  11. package/es/add-between-cell/index.js +2 -0
  12. package/es/add-between-cell/index.less +103 -0
  13. package/es/add-between-cell/module.d.ts +3 -0
  14. package/es/add-between-cell/module.d.ts.map +1 -0
  15. package/es/add-between-cell/module.js +8 -0
  16. package/es/cell/index.d.ts +3 -0
  17. package/es/cell/index.d.ts.map +1 -0
  18. package/es/cell/index.js +2 -0
  19. package/es/cell/jupyter-code-cell-model.d.ts +12 -0
  20. package/es/cell/jupyter-code-cell-model.d.ts.map +1 -0
  21. package/es/cell/jupyter-code-cell-model.js +56 -0
  22. package/es/cell/jupyter-code-cell-view.d.ts +18 -0
  23. package/es/cell/jupyter-code-cell-view.d.ts.map +1 -0
  24. package/es/cell/jupyter-code-cell-view.js +280 -0
  25. package/es/command/command-contribution.d.ts +10 -0
  26. package/es/command/command-contribution.d.ts.map +1 -0
  27. package/es/command/command-contribution.js +161 -0
  28. package/es/command/index.d.ts +3 -0
  29. package/es/command/index.d.ts.map +1 -0
  30. package/es/command/index.js +2 -0
  31. package/es/command/keybinding-contribution.d.ts +8 -0
  32. package/es/command/keybinding-contribution.d.ts.map +1 -0
  33. package/es/command/keybinding-contribution.js +37 -0
  34. package/es/components/cell-execution-tip.d.ts +6 -0
  35. package/es/components/cell-execution-tip.d.ts.map +1 -0
  36. package/es/components/cell-execution-tip.js +69 -0
  37. package/es/components/cell-input-bottom-blank.d.ts +5 -0
  38. package/es/components/cell-input-bottom-blank.d.ts.map +1 -0
  39. package/es/components/cell-input-bottom-blank.js +21 -0
  40. package/es/components/icons.d.ts +5 -0
  41. package/es/components/icons.d.ts.map +1 -0
  42. package/es/components/icons.js +154 -0
  43. package/es/components/index.d.ts +4 -0
  44. package/es/components/index.d.ts.map +1 -0
  45. package/es/components/index.js +3 -0
  46. package/es/components/index.less +82 -0
  47. package/es/config/config-contribution.d.ts +10 -0
  48. package/es/config/config-contribution.d.ts.map +1 -0
  49. package/es/config/config-contribution.js +50 -0
  50. package/es/config/config.d.ts +3 -0
  51. package/es/config/config.d.ts.map +1 -0
  52. package/es/config/config.js +11 -0
  53. package/es/config/index.d.ts +2 -0
  54. package/es/config/index.d.ts.map +1 -0
  55. package/es/config/index.js +1 -0
  56. package/es/configuration/index.d.ts +3 -0
  57. package/es/configuration/index.d.ts.map +1 -0
  58. package/es/configuration/index.js +2 -0
  59. package/es/configuration/libro-configuration-contribution.d.ts +5 -0
  60. package/es/configuration/libro-configuration-contribution.d.ts.map +1 -0
  61. package/es/configuration/libro-configuration-contribution.js +24 -0
  62. package/es/configuration/libro-configuration.d.ts +3 -0
  63. package/es/configuration/libro-configuration.d.ts.map +1 -0
  64. package/es/configuration/libro-configuration.js +12 -0
  65. package/es/contents/content-contribution.d.ts +7 -0
  66. package/es/contents/content-contribution.d.ts.map +1 -0
  67. package/es/contents/content-contribution.js +63 -0
  68. package/es/contents/index.d.ts +2 -0
  69. package/es/contents/index.d.ts.map +1 -0
  70. package/es/contents/index.js +1 -0
  71. package/es/file/file-name-alias.d.ts +7 -0
  72. package/es/file/file-name-alias.d.ts.map +1 -0
  73. package/es/file/file-name-alias.js +26 -0
  74. package/es/file/file-protocol.d.ts +8 -0
  75. package/es/file/file-protocol.d.ts.map +1 -0
  76. package/es/file/file-protocol.js +7 -0
  77. package/es/file/file-service.d.ts +31 -0
  78. package/es/file/file-service.d.ts.map +1 -0
  79. package/es/file/file-service.js +329 -0
  80. package/es/file/file-tree-label-provider.d.ts +13 -0
  81. package/es/file/file-tree-label-provider.d.ts.map +1 -0
  82. package/es/file/file-tree-label-provider.js +62 -0
  83. package/es/file/file-view/index.d.ts +14 -0
  84. package/es/file/file-view/index.d.ts.map +1 -0
  85. package/es/file/file-view/index.js +101 -0
  86. package/es/file/file-view/index.less +5 -0
  87. package/es/file/index.d.ts +7 -0
  88. package/es/file/index.d.ts.map +1 -0
  89. package/es/file/index.js +6 -0
  90. package/es/file/module.d.ts +3 -0
  91. package/es/file/module.d.ts.map +1 -0
  92. package/es/file/module.js +8 -0
  93. package/es/file/navigatable-view.d.ts +24 -0
  94. package/es/file/navigatable-view.d.ts.map +1 -0
  95. package/es/file/navigatable-view.js +151 -0
  96. package/es/file/open-handler-contribution.d.ts +11 -0
  97. package/es/file/open-handler-contribution.d.ts.map +1 -0
  98. package/es/file/open-handler-contribution.js +102 -0
  99. package/es/index.d.ts +32 -0
  100. package/es/index.d.ts.map +1 -0
  101. package/es/index.js +31 -0
  102. package/es/keybind-instructions/index.d.ts +6 -0
  103. package/es/keybind-instructions/index.d.ts.map +1 -0
  104. package/es/keybind-instructions/index.js +5 -0
  105. package/es/keybind-instructions/index.less +177 -0
  106. package/es/keybind-instructions/keybind-instructions-contribution.d.ts +11 -0
  107. package/es/keybind-instructions/keybind-instructions-contribution.d.ts.map +1 -0
  108. package/es/keybind-instructions/keybind-instructions-contribution.js +84 -0
  109. package/es/keybind-instructions/keybind-instructions-icon.d.ts +3 -0
  110. package/es/keybind-instructions/keybind-instructions-icon.d.ts.map +1 -0
  111. package/es/keybind-instructions/keybind-instructions-icon.js +23 -0
  112. package/es/keybind-instructions/keybind-instructions-items.d.ts +14 -0
  113. package/es/keybind-instructions/keybind-instructions-items.d.ts.map +1 -0
  114. package/es/keybind-instructions/keybind-instructions-items.js +589 -0
  115. package/es/keybind-instructions/keybind-instructions-view.d.ts +16 -0
  116. package/es/keybind-instructions/keybind-instructions-view.d.ts.map +1 -0
  117. package/es/keybind-instructions/keybind-instructions-view.js +224 -0
  118. package/es/keybind-instructions/module.d.ts +3 -0
  119. package/es/keybind-instructions/module.d.ts.map +1 -0
  120. package/es/keybind-instructions/module.js +5 -0
  121. package/es/libro-jupyter-file-service.d.ts +106 -0
  122. package/es/libro-jupyter-file-service.d.ts.map +1 -0
  123. package/es/libro-jupyter-file-service.js +127 -0
  124. package/es/libro-jupyter-model.d.ts +49 -0
  125. package/es/libro-jupyter-model.d.ts.map +1 -0
  126. package/es/libro-jupyter-model.js +505 -0
  127. package/es/libro-jupyter-protocol.d.ts +38 -0
  128. package/es/libro-jupyter-protocol.d.ts.map +1 -0
  129. package/es/libro-jupyter-protocol.js +9 -0
  130. package/es/libro-jupyter-server-launch-manager.d.ts +11 -0
  131. package/es/libro-jupyter-server-launch-manager.d.ts.map +1 -0
  132. package/es/libro-jupyter-server-launch-manager.js +59 -0
  133. package/es/libro-jupyter-view.d.ts +10 -0
  134. package/es/libro-jupyter-view.d.ts.map +1 -0
  135. package/es/libro-jupyter-view.js +42 -0
  136. package/es/module.d.ts +3 -0
  137. package/es/module.d.ts.map +1 -0
  138. package/es/module.js +48 -0
  139. package/es/output/index.d.ts +2 -0
  140. package/es/output/index.d.ts.map +1 -0
  141. package/es/output/index.js +1 -0
  142. package/es/output/libro-jupyter-outputarea.d.ts +8 -0
  143. package/es/output/libro-jupyter-outputarea.d.ts.map +1 -0
  144. package/es/output/libro-jupyter-outputarea.js +77 -0
  145. package/es/rendermime/assets/plotly.svg +31 -0
  146. package/es/rendermime/index.d.ts +5 -0
  147. package/es/rendermime/index.d.ts.map +1 -0
  148. package/es/rendermime/index.js +4 -0
  149. package/es/rendermime/index.less +22 -0
  150. package/es/rendermime/module.d.ts +3 -0
  151. package/es/rendermime/module.d.ts.map +1 -0
  152. package/es/rendermime/module.js +3 -0
  153. package/es/rendermime/plotly-render.d.ts +7 -0
  154. package/es/rendermime/plotly-render.d.ts.map +1 -0
  155. package/es/rendermime/plotly-render.js +30 -0
  156. package/es/rendermime/plotly-renderers.d.ts +58 -0
  157. package/es/rendermime/plotly-renderers.d.ts.map +1 -0
  158. package/es/rendermime/plotly-renderers.js +211 -0
  159. package/es/rendermime/plotly-rendermime-contribution.d.ts +12 -0
  160. package/es/rendermime/plotly-rendermime-contribution.d.ts.map +1 -0
  161. package/es/rendermime/plotly-rendermime-contribution.js +22 -0
  162. package/es/theme/color-registry.d.ts +6 -0
  163. package/es/theme/color-registry.d.ts.map +1 -0
  164. package/es/theme/color-registry.js +393 -0
  165. package/es/theme/index.d.ts +2 -0
  166. package/es/theme/index.d.ts.map +1 -0
  167. package/es/theme/index.js +1 -0
  168. package/es/toolbar/index.d.ts +6 -0
  169. package/es/toolbar/index.d.ts.map +1 -0
  170. package/es/toolbar/index.js +5 -0
  171. package/es/toolbar/index.less +194 -0
  172. package/es/toolbar/kernel-selector-dropdown.d.ts +13 -0
  173. package/es/toolbar/kernel-selector-dropdown.d.ts.map +1 -0
  174. package/es/toolbar/kernel-selector-dropdown.js +165 -0
  175. package/es/toolbar/kernel-status-and-selector.d.ts +18 -0
  176. package/es/toolbar/kernel-status-and-selector.d.ts.map +1 -0
  177. package/es/toolbar/kernel-status-and-selector.js +164 -0
  178. package/es/toolbar/run-selector.d.ts +3 -0
  179. package/es/toolbar/run-selector.d.ts.map +1 -0
  180. package/es/toolbar/run-selector.js +98 -0
  181. package/es/toolbar/save-file-error-contribution.d.ts +5 -0
  182. package/es/toolbar/save-file-error-contribution.d.ts.map +1 -0
  183. package/es/toolbar/save-file-error-contribution.js +23 -0
  184. package/es/toolbar/save-file-error.d.ts +5 -0
  185. package/es/toolbar/save-file-error.d.ts.map +1 -0
  186. package/es/toolbar/save-file-error.js +27 -0
  187. package/es/toolbar/side-toolbar-run-selector.d.ts +3 -0
  188. package/es/toolbar/side-toolbar-run-selector.d.ts.map +1 -0
  189. package/es/toolbar/side-toolbar-run-selector.js +67 -0
  190. package/es/toolbar/toolbar-contribution.d.ts +9 -0
  191. package/es/toolbar/toolbar-contribution.d.ts.map +1 -0
  192. package/es/toolbar/toolbar-contribution.js +67 -0
  193. package/es/typings/index.d.ts +31 -0
  194. package/es/utils/index.d.ts +11 -0
  195. package/es/utils/index.d.ts.map +1 -0
  196. package/es/utils/index.js +47 -0
  197. package/package.json +75 -0
  198. package/src/add-between-cell/add-between-cell-command-contribution.ts +63 -0
  199. package/src/add-between-cell/add-between-cell.tsx +201 -0
  200. package/src/add-between-cell/index.less +103 -0
  201. package/src/add-between-cell/index.ts +2 -0
  202. package/src/add-between-cell/module.ts +13 -0
  203. package/src/cell/index.ts +2 -0
  204. package/src/cell/jupyter-code-cell-model.ts +36 -0
  205. package/src/cell/jupyter-code-cell-view.tsx +221 -0
  206. package/src/command/command-contribution.ts +163 -0
  207. package/src/command/index.ts +2 -0
  208. package/src/command/keybinding-contribution.ts +25 -0
  209. package/src/components/cell-execution-tip.tsx +107 -0
  210. package/src/components/cell-input-bottom-blank.tsx +24 -0
  211. package/src/components/icons.tsx +117 -0
  212. package/src/components/index.less +82 -0
  213. package/src/components/index.ts +3 -0
  214. package/src/config/config-contribution.ts +21 -0
  215. package/src/config/config.ts +14 -0
  216. package/src/config/index.ts +1 -0
  217. package/src/configuration/index.ts +2 -0
  218. package/src/configuration/libro-configuration-contribution.ts +11 -0
  219. package/src/configuration/libro-configuration.ts +14 -0
  220. package/src/contents/content-contribution.ts +32 -0
  221. package/src/contents/index.ts +1 -0
  222. package/src/file/file-name-alias.ts +15 -0
  223. package/src/file/file-protocol.ts +7 -0
  224. package/src/file/file-service.ts +179 -0
  225. package/src/file/file-tree-label-provider.ts +42 -0
  226. package/src/file/file-view/index.less +5 -0
  227. package/src/file/file-view/index.tsx +90 -0
  228. package/src/file/index.ts +6 -0
  229. package/src/file/module.ts +19 -0
  230. package/src/file/navigatable-view.tsx +93 -0
  231. package/src/file/open-handler-contribution.ts +44 -0
  232. package/src/index.ts +32 -0
  233. package/src/keybind-instructions/index.less +177 -0
  234. package/src/keybind-instructions/index.ts +5 -0
  235. package/src/keybind-instructions/keybind-instructions-contribution.ts +47 -0
  236. package/src/keybind-instructions/keybind-instructions-icon.tsx +28 -0
  237. package/src/keybind-instructions/keybind-instructions-items.tsx +597 -0
  238. package/src/keybind-instructions/keybind-instructions-view.tsx +239 -0
  239. package/src/keybind-instructions/module.ts +11 -0
  240. package/src/libro-jupyter-file-service.ts +158 -0
  241. package/src/libro-jupyter-model.ts +289 -0
  242. package/src/libro-jupyter-protocol.ts +59 -0
  243. package/src/libro-jupyter-server-launch-manager.ts +36 -0
  244. package/src/libro-jupyter-view.tsx +24 -0
  245. package/src/module.ts +105 -0
  246. package/src/output/index.ts +1 -0
  247. package/src/output/libro-jupyter-outputarea.tsx +71 -0
  248. package/src/rendermime/assets/plotly.svg +31 -0
  249. package/src/rendermime/index.less +13 -0
  250. package/src/rendermime/index.ts +4 -0
  251. package/src/rendermime/module.ts +7 -0
  252. package/src/rendermime/plotly-render.tsx +35 -0
  253. package/src/rendermime/plotly-renderers.ts +191 -0
  254. package/src/rendermime/plotly-rendermime-contribution.ts +15 -0
  255. package/src/theme/color-registry.ts +301 -0
  256. package/src/theme/index.ts +1 -0
  257. package/src/toolbar/index.less +194 -0
  258. package/src/toolbar/index.ts +5 -0
  259. package/src/toolbar/kernel-selector-dropdown.tsx +204 -0
  260. package/src/toolbar/kernel-status-and-selector.tsx +195 -0
  261. package/src/toolbar/run-selector.tsx +110 -0
  262. package/src/toolbar/save-file-error-contribution.ts +10 -0
  263. package/src/toolbar/save-file-error.tsx +35 -0
  264. package/src/toolbar/side-toolbar-run-selector.tsx +77 -0
  265. package/src/toolbar/toolbar-contribution.tsx +62 -0
  266. package/src/typings/index.d.ts +31 -0
  267. package/src/utils/index.ts +65 -0
@@ -0,0 +1,163 @@
1
+ import {
2
+ KernelCommands,
3
+ LibroCommandRegister,
4
+ LibroService,
5
+ LibroToolbarArea,
6
+ LibroView,
7
+ NotebookCommands,
8
+ LibroCellView,
9
+ ExecutableCellView,
10
+ } from '@difizen/libro-core';
11
+ import type { CommandRegistry } from '@difizen/mana-app';
12
+ import {
13
+ CommandContribution,
14
+ inject,
15
+ ModalService,
16
+ singleton,
17
+ } from '@difizen/mana-app';
18
+
19
+ import { LibroJupyterModel } from '../libro-jupyter-model.js';
20
+ import { ExecutedWithKernelCellModel } from '../libro-jupyter-protocol.js';
21
+
22
+ @singleton({ contrib: CommandContribution })
23
+ export class LibroJupyterCommandContribution implements CommandContribution {
24
+ @inject(ModalService) protected readonly modalService: ModalService;
25
+ @inject(LibroCommandRegister) protected readonly libroCommand: LibroCommandRegister;
26
+ @inject(LibroService) protected readonly libroService: LibroService;
27
+
28
+ registerCommands(command: CommandRegistry): void {
29
+ this.libroCommand.registerLibroCommand(
30
+ command,
31
+ KernelCommands['ShowKernelStatusAndSelector'],
32
+ {
33
+ execute: async (_cell, libro) => {
34
+ if (!libro || !(libro instanceof LibroView)) {
35
+ return;
36
+ }
37
+ },
38
+ isVisible: (_cell, libro, path) => {
39
+ if (!libro || !(libro instanceof LibroView)) {
40
+ return false;
41
+ }
42
+ return (
43
+ !libro?.model.quickEditMode &&
44
+ !libro?.model.readOnly &&
45
+ path === LibroToolbarArea.HeaderLeft
46
+ );
47
+ },
48
+ isEnabled: (_cell, libro) => {
49
+ if (!libro || !(libro instanceof LibroView)) {
50
+ return false;
51
+ }
52
+ return true;
53
+ },
54
+ },
55
+ );
56
+
57
+ this.libroCommand.registerLibroCommand(
58
+ command,
59
+ NotebookCommands['TopToolbarRunSelect'],
60
+ {
61
+ execute: () => {
62
+ //
63
+ },
64
+ isVisible: (cell, libro, path) => {
65
+ if (
66
+ !cell ||
67
+ !libro ||
68
+ !(cell instanceof LibroCellView) ||
69
+ !(libro instanceof LibroView)
70
+ ) {
71
+ return false;
72
+ }
73
+ if (
74
+ path !== LibroToolbarArea.HeaderCenter ||
75
+ libro.model.quickEditMode ||
76
+ libro.model.readOnly
77
+ ) {
78
+ return false;
79
+ }
80
+ return !!cell;
81
+ },
82
+ isEnabled: (_cell, libro) => {
83
+ if (!libro || !(libro instanceof LibroView)) {
84
+ return false;
85
+ }
86
+ return (
87
+ (libro.model as LibroJupyterModel).kernelConnection !== undefined &&
88
+ (libro.model as LibroJupyterModel).kernelConnecting === false
89
+ );
90
+ },
91
+ },
92
+ );
93
+
94
+ this.libroCommand.registerLibroCommand(
95
+ command,
96
+ NotebookCommands['SideToolbarRunSelect'],
97
+ {
98
+ execute: () => {
99
+ //
100
+ },
101
+ isVisible: (cell, libro, path) => {
102
+ if (
103
+ !cell ||
104
+ !libro ||
105
+ !ExecutableCellView.is(cell) ||
106
+ !(libro instanceof LibroView)
107
+ ) {
108
+ return false;
109
+ }
110
+ return (
111
+ !libro?.model.quickEditMode &&
112
+ !libro?.model.readOnly &&
113
+ path === LibroToolbarArea.CellRight
114
+ );
115
+ },
116
+ isEnabled: (_cell, libro) => {
117
+ if (!libro || !(libro instanceof LibroView)) {
118
+ return false;
119
+ }
120
+ return (
121
+ (libro.model as LibroJupyterModel).kernelConnection !== undefined &&
122
+ (libro.model as LibroJupyterModel).kernelConnecting === false
123
+ );
124
+ },
125
+ },
126
+ );
127
+
128
+ this.libroCommand.registerLibroCommand(
129
+ command,
130
+ NotebookCommands['SelectLastRunCell'],
131
+ {
132
+ execute: async (_cell, libro) => {
133
+ if (!libro || !(libro instanceof LibroView)) {
134
+ return;
135
+ }
136
+ if (libro.model instanceof LibroJupyterModel) {
137
+ libro.model.findRunningCell();
138
+ }
139
+ },
140
+ isVisible: (_cell, libro, path) => {
141
+ if (!libro || !(libro instanceof LibroView)) {
142
+ return false;
143
+ }
144
+ return path === LibroToolbarArea.HeaderCenter && !libro.model.readOnly;
145
+ },
146
+ isEnabled: (_cell, libro) => {
147
+ if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
148
+ return false;
149
+ }
150
+ return (
151
+ libro.model
152
+ .getCells()
153
+ .findIndex(
154
+ (item) =>
155
+ ExecutedWithKernelCellModel.is(item.model) &&
156
+ item.model.kernelExecuting,
157
+ ) >= 0
158
+ );
159
+ },
160
+ },
161
+ );
162
+ }
163
+ }
@@ -0,0 +1,2 @@
1
+ export * from './command-contribution.js';
2
+ export * from './keybinding-contribution.js';
@@ -0,0 +1,25 @@
1
+ import {
2
+ NotebookCommands,
3
+ DocumentCommands,
4
+ LibroCommandRegister,
5
+ } from '@difizen/libro-core';
6
+ import {
7
+ inject,
8
+ KeybindingRegistry,
9
+ singleton,
10
+ KeybindingContribution,
11
+ } from '@difizen/mana-app';
12
+
13
+ @singleton({ contrib: KeybindingContribution })
14
+ export class LibroJupyterKeybindingContribution implements KeybindingContribution {
15
+ @inject(LibroCommandRegister) protected readonly libroCommand: LibroCommandRegister;
16
+ constructor(@inject(KeybindingRegistry) keybindRegistry: KeybindingRegistry) {
17
+ // 快捷键命中时默认阻止事件冒泡
18
+ keybindRegistry.preventDefault = true;
19
+ keybindRegistry.stopPropagation = true;
20
+ }
21
+ registerKeybindings(keybindings: KeybindingRegistry) {
22
+ this.libroCommand.registerKeybinds(keybindings, NotebookCommands);
23
+ this.libroCommand.registerKeybinds(keybindings, DocumentCommands);
24
+ }
25
+ }
@@ -0,0 +1,107 @@
1
+ import { LoadingOutlined } from '@ant-design/icons';
2
+ import type { CellView } from '@difizen/libro-core';
3
+ import {
4
+ ExecutableCellView,
5
+ CheckCircleOutlined,
6
+ ExecutableCellModel,
7
+ } from '@difizen/libro-core';
8
+ import { useObserve } from '@difizen/mana-app';
9
+ import classnames from 'classnames';
10
+ import moment from 'moment';
11
+
12
+ import type { JupyterCodeCellModel } from '../cell/jupyter-code-cell-model.js';
13
+ import {
14
+ formatTime,
15
+ parseExecutionInfoFromModel,
16
+ isWaitingExecute,
17
+ } from '../utils/index.js';
18
+
19
+ import { InfoCircle } from './icons.js';
20
+
21
+ import './index.less';
22
+
23
+ export function CellExecutionTip({ cell }: { cell: CellView }) {
24
+ const observableCell = useObserve(cell);
25
+
26
+ if (!ExecutableCellView.is(cell)) {
27
+ return null;
28
+ }
29
+
30
+ if (!ExecutableCellModel.is(observableCell.model)) {
31
+ return null;
32
+ }
33
+
34
+ const isHidden = observableCell.model.hasOutputHidden;
35
+ const kernelExecuting = (cell.model as JupyterCodeCellModel).kernelExecuting;
36
+ const executionInfo = parseExecutionInfoFromModel(cell.model);
37
+
38
+ const output = cell.outputArea.outputs;
39
+ const existOutput = output && output.length !== 0;
40
+
41
+ const waitingExecute = isWaitingExecute(observableCell.model);
42
+
43
+ if (!executionInfo) {
44
+ return null;
45
+ }
46
+
47
+ const { executeStartTime, executeFinishTime } = executionInfo;
48
+ if (executeStartTime && executeFinishTime && observableCell.model.executeCount) {
49
+ return isHidden ? (
50
+ <div className="libro-cell-execution-tip-hide-output">
51
+ <div className="libro-cell-execution-tip-border" />
52
+ <CheckCircleOutlined />
53
+ </div>
54
+ ) : (
55
+ <div
56
+ className={classnames(
57
+ `libro-cell-execution-tip`,
58
+ !existOutput && 'libro-cell-execution-tip-without-output',
59
+ )}
60
+ >
61
+ <div className="libro-cell-execution-tip-border" />
62
+ <CheckCircleOutlined />
63
+ <p>
64
+ {'The execution took in ' +
65
+ formatTime(
66
+ Number(new Date(executeFinishTime).getTime()) -
67
+ Number(new Date(executeStartTime).getTime()),
68
+ ) +
69
+ ', finished at ' +
70
+ moment(new Date(executeFinishTime).getTime()).format('hh:mm a') +
71
+ '.'}
72
+ </p>
73
+ </div>
74
+ );
75
+ } else if (kernelExecuting) {
76
+ return (
77
+ <div
78
+ className={classnames(
79
+ `libro-cell-execution-tip`,
80
+ !existOutput && 'libro-cell-execution-tip-without-output',
81
+ )}
82
+ >
83
+ <div className="libro-cell-execution-tip-border" />
84
+ <LoadingOutlined style={{ color: 'rgba(24,144,255,1)' }} />
85
+ <p>
86
+ {'It takes ' +
87
+ formatTime(Date.now() - Number(new Date(executeStartTime).getTime())) +
88
+ '.'}
89
+ </p>
90
+ </div>
91
+ );
92
+ } else if (waitingExecute) {
93
+ return (
94
+ <div
95
+ className={classnames(
96
+ `libro-cell-execution-tip`,
97
+ waitingExecute && 'libro-cell-execution-tip-without-output',
98
+ )}
99
+ >
100
+ <div className="libro-cell-execution-tip-border" />
101
+ <InfoCircle />
102
+ <p>{'execution queued.'}</p>
103
+ </div>
104
+ );
105
+ }
106
+ return null;
107
+ }
@@ -0,0 +1,24 @@
1
+ import { LibroExecutableCellView } from '@difizen/libro-core';
2
+ import type { CellView } from '@difizen/libro-core';
3
+ import { useObserve } from '@difizen/mana-app';
4
+
5
+ import { isWaitingExecute } from '../utils/index.js';
6
+
7
+ export function CellInputBottomBlank({ cell }: { cell: CellView }) {
8
+ const observableCell = useObserve(cell) as LibroExecutableCellView;
9
+
10
+ if (!(cell instanceof LibroExecutableCellView)) {
11
+ return null;
12
+ }
13
+
14
+ const outputs = observableCell.outputArea.outputs;
15
+ const hasNoneOutput =
16
+ (!outputs || outputs.length === 0) && observableCell.model.executeCount;
17
+
18
+ // 有output时 或者 没有被执行过,不显示input底部的空白
19
+ if (hasNoneOutput || isWaitingExecute(observableCell.model)) {
20
+ return <div className="libro-cell-bottom-blank" />;
21
+ }
22
+
23
+ return null;
24
+ }
@@ -0,0 +1,117 @@
1
+ import React from 'react';
2
+
3
+ export const InfoCircle: React.FC = () => (
4
+ <svg
5
+ version="1.1"
6
+ width="15px"
7
+ height="15px"
8
+ viewBox="0 0 14.0 14.0"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ xmlnsXlink="http://www.w3.org/1999/xlink"
11
+ >
12
+ <defs>
13
+ <clipPath id="i0">
14
+ <path d="M1840,0 L1840,900 L0,900 L0,0 L1840,0 Z" />
15
+ </clipPath>
16
+ <clipPath id="i1">
17
+ <path d="M980,0 C982.209139,-4.05812251e-16 984,1.790861 984,4 L984,126 C984,128.209139 982.209139,130 980,130 L4,130 C1.790861,130 2.705415e-16,128.209139 0,126 L0,4 C-2.705415e-16,1.790861 1.790861,4.05812251e-16 4,0 L980,0 Z" />
18
+ </clipPath>
19
+ <clipPath id="i2">
20
+ <path d="M6.125,0 C9.50742188,0 12.25,2.74257813 12.25,6.125 C12.25,9.50742188 9.50742188,12.25 6.125,12.25 C2.74257813,12.25 0,9.50742188 0,6.125 C0,2.74257813 2.74257813,0 6.125,0 Z M6.49414062,5.11328125 L5.75585938,5.11328125 C5.68818359,5.11328125 5.6328125,5.16796875 5.6328125,5.23632812 L5.6328125,9.36523438 C5.6328125,9.43359375 5.68818359,9.48828125 5.75585938,9.48828125 L6.49414062,9.48828125 C6.56181641,9.48828125 6.6171875,9.43359375 6.6171875,9.36523438 L6.6171875,5.23632812 C6.6171875,5.16796875 6.56181641,5.11328125 6.49414062,5.11328125 Z M6.125,2.76171875 C5.71740723,2.76171875 5.38671875,3.09240723 5.38671875,3.5 C5.38671875,3.90759277 5.71740723,4.23828125 6.125,4.23828125 C6.53259277,4.23828125 6.86328125,3.90759277 6.86328125,3.5 C6.86328125,3.09240723 6.53259277,2.76171875 6.125,2.76171875 Z" />
21
+ </clipPath>
22
+ </defs>
23
+ <g transform="translate(-366.0 -681.0)">
24
+ <g clipPath="url(#i0)">
25
+ <g transform="translate(334.0 579.0)">
26
+ <g clipPath="url(#i1)">
27
+ <g transform="translate(0.0 94.0)">
28
+ <g transform="translate(32.0 8.0)">
29
+ <g transform="translate(0.5185185185185182 0.5185185185185182)">
30
+ <g transform="translate(0.35648148148148184 0.35648148148148184)">
31
+ <g clipPath="url(#i2)">
32
+ <polygon
33
+ points="0,0 12.25,0 12.25,12.25 0,12.25 0,0"
34
+ stroke="none"
35
+ fill="#1890FF"
36
+ />
37
+ </g>
38
+ </g>
39
+ </g>
40
+ </g>
41
+ </g>
42
+ </g>
43
+ </g>
44
+ </g>
45
+ </g>
46
+ </svg>
47
+ );
48
+
49
+ export const WarningIcon: React.FC = () => (
50
+ <svg
51
+ width="14px"
52
+ height="14px"
53
+ viewBox="0 0 12 12"
54
+ version="1.1"
55
+ xmlns="http://www.w3.org/2000/svg"
56
+ xmlnsXlink="http://www.w3.org/1999/xlink"
57
+ >
58
+ <g id="0417" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
59
+ <g id="2.0-chart-cell初始化" transform="translate(-521.000000, -233.000000)">
60
+ <rect fill="#FFFFFF" x="0" y="0" width="1840" height="900" />
61
+ <g
62
+ id="编组-31"
63
+ transform="translate(286.000000, -434.000000)"
64
+ fill="#000A1A"
65
+ fillOpacity="0.26"
66
+ >
67
+ <g id="编组-7" transform="translate(0.000000, 655.000000)">
68
+ <g id="矩形备份-2" transform="translate(45.000000, 0.000000)">
69
+ <g id="General/Details备份" transform="translate(16.000000, 7.000000)">
70
+ <g id="编组-8" transform="translate(135.000000, 0.000000)">
71
+ <g
72
+ id="1.通用/2.Icon图标/Fill/Warning-Circle-Fill"
73
+ transform="translate(39.750000, 5.750000)"
74
+ >
75
+ <path
76
+ d="M5.25,0 C2.35078125,0 0,2.35078125 0,5.25 C0,8.14921875 2.35078125,10.5 5.25,10.5 C8.14921875,10.5 10.5,8.14921875 10.5,5.25 C10.5,2.35078125 8.14921875,0 5.25,0 Z M4.875,2.71875 C4.875,2.6671875 4.9171875,2.625 4.96875,2.625 L5.53125,2.625 C5.5828125,2.625 5.625,2.6671875 5.625,2.71875 L5.625,5.90625 C5.625,5.9578125 5.5828125,6 5.53125,6 L4.96875,6 C4.9171875,6 4.875,5.9578125 4.875,5.90625 L4.875,2.71875 Z M5.25,7.875 C4.93945312,7.875 4.6875,7.62304688 4.6875,7.3125 C4.6875,7.00195312 4.93945312,6.75 5.25,6.75 C5.56054688,6.75 5.8125,7.00195312 5.8125,7.3125 C5.8125,7.62304688 5.56054688,7.875 5.25,7.875 Z"
77
+ id="warning-circle-filled"
78
+ />
79
+ </g>
80
+ </g>
81
+ </g>
82
+ </g>
83
+ </g>
84
+ </g>
85
+ </g>
86
+ </g>
87
+ </svg>
88
+ );
89
+
90
+ export const Location: React.FC = () => (
91
+ <svg
92
+ width="17px"
93
+ height="20px"
94
+ viewBox="0 0 17 20"
95
+ version="1.1"
96
+ xmlns="http://www.w3.org/2000/svg"
97
+ xmlnsXlink="http://www.w3.org/1999/xlink"
98
+ >
99
+ <g id="页面-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
100
+ <g
101
+ id="2.0-kernel-启动前"
102
+ transform="translate(-738.000000, -80.000000)"
103
+ fill="#7B7B7B"
104
+ fillRule="nonzero"
105
+ >
106
+ <g id="编组-24" transform="translate(637.000000, 80.000000)">
107
+ <g id="location" transform="translate(99.000000, 0.000000)">
108
+ <path
109
+ d="M18.0602315,4.99157209 C17.6377121,4.01618159 17.0331498,3.14192606 16.2645241,2.39127992 C15.4958984,1.64063378 14.6036633,1.05405102 13.6080458,0.64276885 C12.5787167,0.215754579 11.4864592,0 10.3604899,0 C9.23452073,0 8.14226318,0.215754579 7.11293404,0.640521407 C6.11731655,1.05180357 5.22508147,1.64063378 4.45645578,2.38903248 C3.68783009,3.13967862 3.08326778,4.01618159 2.6607484,4.98932464 C2.22249691,6.00067423 2,7.07495224 2,8.18069446 C2,9.76738959 2.37981796,11.3473424 3.12596921,12.8711091 C3.72603663,14.0959658 4.56433307,15.2893584 5.62063153,16.4243173 C7.42532869,18.3616137 9.31767614,19.5460164 9.85481515,19.8629059 C10.0098888,19.9550511 10.1851893,20 10.3582425,20 C10.5335431,20 10.7065962,19.9550511 10.8616699,19.8629059 C11.3988089,19.5460164 13.2911563,18.3616137 15.0958535,16.4243173 C16.1521519,15.2916058 16.9904484,14.0959658 17.5905158,12.8711091 C18.3411619,11.3495898 18.7209799,9.77188448 18.7209799,8.1829419 C18.7209799,7.07719969 18.498483,6.00292168 18.0602315,4.99157209 Z M10.3604899,18.2762108 C8.87942465,17.334532 3.61815934,13.6060231 3.61815934,8.1829419 C3.61815934,6.43218339 4.31711428,4.78705473 5.58691988,3.5464659 C6.86122036,2.30362962 8.55579279,1.61815934 10.3604899,1.61815934 C12.1651871,1.61815934 13.8597595,2.30362962 15.13406,3.54871334 C16.4038656,4.78705473 17.1028205,6.43218339 17.1028205,8.1829419 C17.1028205,13.6060231 11.8415552,17.334532 10.3604899,18.2762108 Z M10.3604899,4.40498932 C8.17597483,4.40498932 6.40498932,6.17597483 6.40498932,8.36048994 C6.40498932,10.5450051 8.17597483,12.3159906 10.3604899,12.3159906 C12.5450051,12.3159906 14.3159906,10.5450051 14.3159906,8.36048994 C14.3159906,6.17597483 12.5450051,4.40498932 10.3604899,4.40498932 Z M12.1404652,10.1404652 C11.6640072,10.6146758 11.0324756,10.8776267 10.3604899,10.8776267 C9.68850433,10.8776267 9.05697269,10.6146758 8.58051466,10.1404652 C8.10630408,9.66400719 7.84335319,9.03247556 7.84335319,8.36048994 C7.84335319,7.68850433 8.10630408,7.05697269 8.58051466,6.58051466 C9.05697269,6.10405664 9.68850433,5.84335319 10.3604899,5.84335319 C11.0324756,5.84335319 11.6640072,6.10405664 12.1404652,6.58051466 C12.6169232,7.05697269 12.8776267,7.68850433 12.8776267,8.36048994 C12.8776267,9.03247556 12.6169232,9.66400719 12.1404652,10.1404652 Z"
110
+ id="locate"
111
+ />
112
+ </g>
113
+ </g>
114
+ </g>
115
+ </g>
116
+ </svg>
117
+ );
@@ -0,0 +1,82 @@
1
+ .libro-cell-execution-tip {
2
+ position: absolute;
3
+ bottom: -15px;
4
+ left: 40px;
5
+ z-index: 10;
6
+ width: calc(100% - 50px);
7
+ max-width: 400px;
8
+ height: 30px;
9
+ background-color: transparent;
10
+
11
+ > svg,
12
+ > span {
13
+ margin-top: 7px;
14
+ margin-left: 8px;
15
+ }
16
+
17
+ > svg {
18
+ position: absolute;
19
+ color: var(--mana-libro-execution-tip-success-color);
20
+ }
21
+
22
+ p {
23
+ width: calc(100% - 56px);
24
+ white-space: nowrap;
25
+ overflow: hidden;
26
+ text-overflow: ellipsis;
27
+ position: absolute;
28
+ top: 4px;
29
+ left: 26px;
30
+ color: var(--mana-libro-tip-font-color) !important;
31
+ font-weight: 400;
32
+ font-size: 12px;
33
+ font-family: 'AlibabaPuHuiTi_2_55_Regular';
34
+ line-height: 20px;
35
+ }
36
+ }
37
+
38
+ .libro-cell-execution-tip-without-output {
39
+ bottom: 5px;
40
+ }
41
+
42
+ .libro-cell-bottom-blank {
43
+ height: 20px;
44
+ border-top: 1px solid var(--mana-color-border);
45
+
46
+ > div {
47
+ margin: 0;
48
+ }
49
+
50
+ background: var(--mana-libro-output-background);
51
+ }
52
+
53
+ .libro-cell-execution-tip-hide-output {
54
+ position: absolute;
55
+ bottom: -15px;
56
+ left: 40px;
57
+ z-index: 1000;
58
+ width: 30px;
59
+ height: 30px;
60
+ // background-color: var(--mana-color-bg-container);
61
+ > svg,
62
+ > span {
63
+ margin-top: 7px;
64
+ margin-left: 8px;
65
+ }
66
+
67
+ > svg {
68
+ position: absolute;
69
+ color: var(--mana-libro-execution-tip-success-color);
70
+ }
71
+ }
72
+
73
+ .libro-cell-execution-tip-border {
74
+ position: absolute;
75
+ background: var(--mana-libro-output-background);
76
+ width: 100%;
77
+ height: 16px;
78
+ border: 1px solid var(--mana-libro-code-border-color);
79
+ border-bottom: unset;
80
+ border-top-left-radius: 25px;
81
+ border-top-right-radius: 25px;
82
+ }
@@ -0,0 +1,3 @@
1
+ export * from './cell-execution-tip.js';
2
+ export * from './cell-input-bottom-blank.js';
3
+ export * from './icons.js';
@@ -0,0 +1,21 @@
1
+ import { AutoInsertWhenNoCell, EnterEditModeWhenAddCell } from '@difizen/libro-core';
2
+ import { ConfigurationContribution, ConfigurationService } from '@difizen/mana-app';
3
+ import { ApplicationContribution } from '@difizen/mana-app';
4
+ import { inject, singleton } from '@difizen/mana-app';
5
+
6
+ import { LibroAutosaveSetting } from './config.js';
7
+
8
+ @singleton({ contrib: ConfigurationContribution })
9
+ export class LibroSettingContribution implements ConfigurationContribution {
10
+ registerConfigurations() {
11
+ return [LibroAutosaveSetting];
12
+ }
13
+ }
14
+ @singleton({ contrib: ApplicationContribution })
15
+ export class ConfigAppContribution implements ApplicationContribution {
16
+ @inject(ConfigurationService) configurationService: ConfigurationService;
17
+ onViewStart() {
18
+ this.configurationService.set(AutoInsertWhenNoCell, true);
19
+ this.configurationService.set(EnterEditModeWhenAddCell, false);
20
+ }
21
+ }
@@ -0,0 +1,14 @@
1
+ import type { ConfigurationNode } from '@difizen/mana-app';
2
+ import { l10n } from '@difizen/mana-l10n';
3
+
4
+ export const LibroAutosaveSetting: ConfigurationNode<boolean> = {
5
+ id: 'libro.autosave',
6
+
7
+ description: l10n.t('是否自动保存修改'),
8
+ title: 'checkbox',
9
+ type: 'checkbox',
10
+ defaultValue: false,
11
+ schema: {
12
+ type: 'boolean',
13
+ },
14
+ };
@@ -0,0 +1 @@
1
+ export * from './config-contribution.js';
@@ -0,0 +1,2 @@
1
+ export * from './libro-configuration.js';
2
+ export * from './libro-configuration-contribution.js';
@@ -0,0 +1,11 @@
1
+ import { ConfigurationContribution } from '@difizen/mana-app';
2
+ import { singleton } from '@difizen/mana-app';
3
+
4
+ import { LibroJupyterConfiguration } from './libro-configuration.js';
5
+
6
+ @singleton({ contrib: ConfigurationContribution })
7
+ export class LibroConfigurationContribution implements ConfigurationContribution {
8
+ registerConfigurations() {
9
+ return [LibroJupyterConfiguration['OpenSlot']];
10
+ }
11
+ }
@@ -0,0 +1,14 @@
1
+ import type { ConfigurationNode } from '@difizen/mana-app';
2
+
3
+ export const LibroJupyterConfiguration: Record<string, ConfigurationNode<string>> = {
4
+ OpenSlot: {
5
+ id: 'libro.jupyter.open.slot',
6
+ description: '文件默认打开位置',
7
+ title: '文件默认打开位置',
8
+ type: 'checkbox',
9
+ defaultValue: 'main',
10
+ schema: {
11
+ type: 'string',
12
+ },
13
+ },
14
+ };
@@ -0,0 +1,32 @@
1
+ import type { NotebookModel, NotebookOption } from '@difizen/libro-core';
2
+ import { ContentContribution } from '@difizen/libro-core';
3
+ import { URI } from '@difizen/mana-app';
4
+ import { singleton } from '@difizen/mana-app';
5
+
6
+ import type { LibroJupyterModel } from '../libro-jupyter-model.js';
7
+
8
+ @singleton({ contrib: ContentContribution })
9
+ export class LibroJupyterContentContribution implements ContentContribution {
10
+ canHandle = () => {
11
+ return 2;
12
+ };
13
+ async loadContent(options: NotebookOption, model: NotebookModel) {
14
+ const jupyterModel = model as LibroJupyterModel;
15
+ const fireUri = new URI(options['resource']);
16
+ const filePath = fireUri.path.toString();
17
+
18
+ const currentFileContents = await jupyterModel.fileService.read(filePath);
19
+ if (currentFileContents) {
20
+ currentFileContents.content.nbformat_minor = 5;
21
+ jupyterModel.currentFileContents = currentFileContents;
22
+ jupyterModel.filePath = currentFileContents.path;
23
+ jupyterModel.lastModified = jupyterModel.currentFileContents.last_modified;
24
+
25
+ if (!jupyterModel.quickEditMode && !jupyterModel.readOnly) {
26
+ jupyterModel.startKernelConnection();
27
+ }
28
+
29
+ return jupyterModel.currentFileContents.content;
30
+ }
31
+ }
32
+ }
@@ -0,0 +1 @@
1
+ export * from './content-contribution.js';
@@ -0,0 +1,15 @@
1
+ import type { URI } from '@difizen/mana-app';
2
+ import { singleton } from '@difizen/mana-app';
3
+
4
+ @singleton()
5
+ export class FileNameAlias {
6
+ protected aliases = new Map<string, string>();
7
+
8
+ set(uri: URI, name: string) {
9
+ this.aliases.set(uri.path.toString(), name);
10
+ }
11
+
12
+ get(uri: URI) {
13
+ return this.aliases.get(uri.path.toString());
14
+ }
15
+ }
@@ -0,0 +1,7 @@
1
+ export enum FileType {
2
+ Unknown = 0,
3
+ File = 1,
4
+ Directory = 2,
5
+ SymbolicLink = 64,
6
+ }
7
+ export type DirItem = [string, FileType];