@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,179 @@
1
+ import type { IContentsModel } from '@difizen/libro-kernel';
2
+ import { ContentsManager } from '@difizen/libro-kernel';
3
+ import type {
4
+ CopyFileOptions,
5
+ FileStatWithMetadata,
6
+ MoveFileOptions,
7
+ ResolveFileOptions,
8
+ } from '@difizen/mana-app';
9
+ import { FileService, URI, inject, singleton } from '@difizen/mana-app';
10
+
11
+ import { FileNameAlias } from './file-name-alias.js';
12
+ import type { DirItem } from './file-protocol.js';
13
+
14
+ interface FileMeta extends Omit<FileStatWithMetadata, 'children' | 'resource'> {
15
+ resource: string;
16
+ children?: FileMeta[];
17
+ }
18
+
19
+ interface DirectoryModel extends IContentsModel {
20
+ type: 'directory';
21
+ content: IContentsModel[];
22
+ }
23
+
24
+ @singleton({ token: FileService })
25
+ export class JupyterFileService extends FileService {
26
+ @inject(ContentsManager) protected readonly contentsManager: ContentsManager;
27
+ // '/read'
28
+ // '/read-dir'
29
+ // '/mkdirp'
30
+ // '/write'
31
+ // '/rename'
32
+ // '/copy'
33
+ // '/delete'
34
+ // '/stat'
35
+ // '/access'
36
+ // '/emptd-dir'
37
+ // '/ensure-file'
38
+ // '/ensure-link'
39
+ // '/ensure-symlink'
40
+
41
+ protected fileNameAlias: FileNameAlias;
42
+
43
+ constructor(
44
+ @inject(FileNameAlias)
45
+ fileNameAlias: FileNameAlias,
46
+ ) {
47
+ super();
48
+
49
+ this.fileNameAlias = fileNameAlias;
50
+ }
51
+
52
+ async write(filePath: string, content: string): Promise<string | undefined> {
53
+ try {
54
+ await this.contentsManager.save(filePath, {
55
+ content,
56
+ });
57
+ return filePath;
58
+ } catch (_e) {
59
+ //
60
+ }
61
+ return undefined;
62
+ }
63
+
64
+ async readDir(dirPath: string): Promise<DirItem[]> {
65
+ let children: DirItem[] = [];
66
+ try {
67
+ const res = await this.contentsManager.get(dirPath, { type: 'directory' });
68
+ if (res && this.isDirectory(res)) {
69
+ const content = res.content;
70
+ children = content.map((item) => {
71
+ return [item.path, this.isDirectory(item) ? 2 : 1];
72
+ });
73
+ }
74
+ } catch (_e) {
75
+ //
76
+ }
77
+ return children;
78
+ }
79
+ async read(filePath: string): Promise<string | undefined> {
80
+ let content: string | undefined = undefined;
81
+ try {
82
+ const res = await this.contentsManager.get(filePath);
83
+ if (res && !this.isDirectory(res)) {
84
+ content = res.content as string;
85
+ }
86
+ } catch (_e) {
87
+ //
88
+ }
89
+ return content;
90
+ }
91
+
92
+ protected async doResolve(filePath: string): Promise<FileMeta | undefined> {
93
+ let stat: FileMeta | undefined = undefined;
94
+ try {
95
+ const res = await this.contentsManager.get(filePath);
96
+ stat = this.toFileMeta(res);
97
+ } catch (_e) {
98
+ //
99
+ }
100
+ return stat;
101
+ }
102
+
103
+ protected isDirectory(model: IContentsModel): model is DirectoryModel {
104
+ if (model.type === 'directory') {
105
+ return true;
106
+ }
107
+ return false;
108
+ }
109
+
110
+ protected toFileMeta(model: IContentsModel): FileMeta {
111
+ const isDirectory = model.type === 'directory';
112
+ const isSymbolicLink = model.type === 'symlink';
113
+ let children = undefined;
114
+ if (isDirectory) {
115
+ const content = model.content as IContentsModel[];
116
+ children = content?.map((item) => this.toFileMeta(item));
117
+ }
118
+ const uri = URI.withScheme(new URI(model.path), 'file');
119
+ return {
120
+ resource: uri.path.toString(),
121
+ etag: uri.path.toString(),
122
+ name: uri.displayName,
123
+ mtime: new Date(model.last_modified).getTime(),
124
+ ctime: new Date(model.created).getTime(),
125
+ size: model.size!,
126
+ isDirectory,
127
+ isSymbolicLink,
128
+ isFile: !isSymbolicLink && !isDirectory,
129
+ children,
130
+ };
131
+ }
132
+
133
+ override async copy(
134
+ source: URI,
135
+ target: URI,
136
+ options?: CopyFileOptions,
137
+ ): Promise<FileStatWithMetadata> {
138
+ return this.resolve(source);
139
+ }
140
+ override async move(
141
+ source: URI,
142
+ target: URI,
143
+ options?: MoveFileOptions,
144
+ ): Promise<FileStatWithMetadata> {
145
+ return this.resolve(source);
146
+ }
147
+
148
+ toFileStatMeta(meta: FileMeta): FileStatWithMetadata {
149
+ const uri = URI.withScheme(new URI(meta.resource), 'file');
150
+
151
+ return {
152
+ ...meta,
153
+ resource: uri,
154
+ name: this.fileNameAlias.get(uri) ?? meta.name,
155
+ children: meta.children?.map((child) => this.toFileStatMeta(child)),
156
+ };
157
+ }
158
+
159
+ override async resolve(
160
+ resource: URI,
161
+ options?: ResolveFileOptions | undefined,
162
+ ): Promise<FileStatWithMetadata> {
163
+ const resolved = await this.doResolve(resource.path.toString());
164
+ if (resolved) {
165
+ return this.toFileStatMeta(resolved);
166
+ }
167
+ return {
168
+ resource,
169
+ name: resource.path.base,
170
+ mtime: 0,
171
+ ctime: 0,
172
+ etag: '',
173
+ size: 0,
174
+ isFile: false,
175
+ isDirectory: false,
176
+ isSymbolicLink: false,
177
+ };
178
+ }
179
+ }
@@ -0,0 +1,42 @@
1
+ import type { DidChangeLabelEvent, FileStat, URI } from '@difizen/mana-app';
2
+ import {
3
+ FileStatNode,
4
+ LabelProvider,
5
+ LabelProviderContribution,
6
+ TreeLabelProvider,
7
+ URIIconReference,
8
+ inject,
9
+ singleton,
10
+ } from '@difizen/mana-app';
11
+
12
+ @singleton({ contrib: LabelProviderContribution })
13
+ export class FileTreeLabelProvider implements LabelProviderContribution {
14
+ @inject(LabelProvider) protected readonly labelProvider: LabelProvider;
15
+ @inject(TreeLabelProvider) protected readonly treeLabelProvider: TreeLabelProvider;
16
+
17
+ protected asURIIconReference(element: FileStat): URI | URIIconReference {
18
+ return URIIconReference.create(
19
+ element.isDirectory ? 'folder' : 'file',
20
+ element.resource,
21
+ );
22
+ }
23
+ canHandle(element: object): number {
24
+ return FileStatNode.is(element) ? this.treeLabelProvider.canHandle(element) + 2 : 0;
25
+ }
26
+
27
+ getIcon(node: FileStatNode): string {
28
+ return this.labelProvider.getIcon(this.asURIIconReference(node.fileStat));
29
+ }
30
+
31
+ getName(node: FileStatNode): string {
32
+ return node.fileStat.name;
33
+ }
34
+
35
+ getDescription(node: FileStatNode): string {
36
+ return this.labelProvider.getLongName(this.asURIIconReference(node.fileStat));
37
+ }
38
+
39
+ affects(node: FileStatNode, event: DidChangeLabelEvent): boolean {
40
+ return event.affects(node.fileStat);
41
+ }
42
+ }
@@ -0,0 +1,5 @@
1
+ .libro-jupyter-file-tree {
2
+ &-content {
3
+ height: calc(100% - 48px);
4
+ }
5
+ }
@@ -0,0 +1,90 @@
1
+ import type { TreeNode, ViewOpenHandler } from '@difizen/mana-app';
2
+ import { FileTreeViewFactory } from '@difizen/mana-app';
3
+ import {
4
+ FileStatNode,
5
+ FileTree,
6
+ FileTreeModel,
7
+ FileTreeView,
8
+ isOSX,
9
+ LabelProvider,
10
+ TreeDecoratorService,
11
+ TreeProps,
12
+ TreeViewDecorator,
13
+ TreeViewModule,
14
+ CommandRegistry,
15
+ ManaModule,
16
+ OpenerService,
17
+ SelectionService,
18
+ view,
19
+ inject,
20
+ singleton,
21
+ } from '@difizen/mana-app';
22
+ import type React from 'react';
23
+
24
+ import type { LibroNavigatableView } from '../navigatable-view.js';
25
+
26
+ import './index.less';
27
+
28
+ const FileTreeModule = ManaModule.create()
29
+ .register(FileTree, FileTreeModel)
30
+ .dependOn(TreeViewModule);
31
+
32
+ @singleton()
33
+ @view(FileTreeViewFactory, FileTreeModule)
34
+ export class FileView extends FileTreeView {
35
+ @inject(OpenerService) protected openService: OpenerService;
36
+ @inject(CommandRegistry) protected command: CommandRegistry;
37
+ override id = FileTreeViewFactory;
38
+ override className = 'libro-jupyter-file-tree';
39
+
40
+ constructor(
41
+ @inject(TreeProps) props: TreeProps,
42
+ @inject(FileTreeModel) model: FileTreeModel,
43
+ @inject(TreeViewDecorator) treeViewDecorator: TreeViewDecorator,
44
+ @inject(SelectionService) selectionService: SelectionService,
45
+ @inject(LabelProvider) labelProvider: LabelProvider,
46
+ @inject(TreeDecoratorService) decoratorService: TreeDecoratorService,
47
+ ) {
48
+ super(
49
+ props,
50
+ model,
51
+ treeViewDecorator,
52
+ selectionService,
53
+ labelProvider,
54
+ decoratorService,
55
+ );
56
+ this.toDispose.push(this.model.onOpenNode(this.openNode));
57
+ }
58
+
59
+ openNode = async (treeNode: TreeNode) => {
60
+ if (FileStatNode.is(treeNode) && !treeNode.fileStat.isDirectory) {
61
+ const opener = (await this.openService.getOpener(
62
+ treeNode.uri,
63
+ )) as ViewOpenHandler<LibroNavigatableView>;
64
+ if (opener) {
65
+ opener.open(treeNode.uri, {
66
+ viewOptions: { name: treeNode.fileStat.name },
67
+ });
68
+ }
69
+ }
70
+ };
71
+
72
+ override handleClickEvent(
73
+ node: TreeNode | undefined,
74
+ event: React.MouseEvent<HTMLElement>,
75
+ ): void {
76
+ const modifierKeyCombined: boolean = isOSX
77
+ ? event.shiftKey || event.metaKey
78
+ : event.shiftKey || event.ctrlKey;
79
+ if (!modifierKeyCombined && node) {
80
+ if (
81
+ FileStatNode.is(node) &&
82
+ !node.fileStat.isDirectory &&
83
+ !node.fileStat.isSymbolicLink
84
+ ) {
85
+ this.model.openNode(node);
86
+ }
87
+ }
88
+ super.handleClickEvent(node, event);
89
+ }
90
+ }
@@ -0,0 +1,6 @@
1
+ export * from './module.js';
2
+ export * from './file-view/index.js';
3
+ export * from './navigatable-view.js';
4
+ export * from './open-handler-contribution.js';
5
+ export * from './file-service.js';
6
+ export * from './file-protocol.js';
@@ -0,0 +1,19 @@
1
+ import { FileTreeModule, ManaModule } from '@difizen/mana-app';
2
+
3
+ import { FileNameAlias } from './file-name-alias.js';
4
+ import { JupyterFileService } from './file-service.js';
5
+ import { FileTreeLabelProvider } from './file-tree-label-provider.js';
6
+ import { FileView } from './file-view/index.js';
7
+ import { LibroNavigatableView } from './navigatable-view.js';
8
+ import { LibroJupyterOpenHandler } from './open-handler-contribution.js';
9
+
10
+ export const LibroJupyterFileModule = ManaModule.create()
11
+ .register(
12
+ JupyterFileService,
13
+ FileView,
14
+ FileNameAlias,
15
+ FileTreeLabelProvider,
16
+ LibroNavigatableView,
17
+ LibroJupyterOpenHandler,
18
+ )
19
+ .dependOn(FileTreeModule);
@@ -0,0 +1,93 @@
1
+ import type { LibroView } from '@difizen/libro-core';
2
+ import { LibroService } from '@difizen/libro-core';
3
+ import type { NavigatableView } from '@difizen/mana-app';
4
+ import {
5
+ BaseView,
6
+ inject,
7
+ LabelProvider,
8
+ prop,
9
+ transient,
10
+ URI as VScodeURI,
11
+ URIIconReference,
12
+ useInject,
13
+ view,
14
+ ViewInstance,
15
+ ViewOption,
16
+ ViewRender,
17
+ Deferred,
18
+ URI,
19
+ } from '@difizen/mana-app';
20
+ import { createRef, forwardRef } from 'react';
21
+
22
+ export const LibroEditorComponent = forwardRef(function LibroEditorComponent() {
23
+ const instance = useInject<LibroNavigatableView>(ViewInstance);
24
+
25
+ if (!instance.libroView || !instance.libroView.view) {
26
+ return null;
27
+ }
28
+
29
+ return <ViewRender view={instance.libroView} key={instance.filePath} />;
30
+ });
31
+
32
+ export const LibroNavigatableViewFactoryId = 'libro-navigatable-view-factory';
33
+ @transient()
34
+ @view(LibroNavigatableViewFactoryId)
35
+ export class LibroNavigatableView extends BaseView implements NavigatableView {
36
+ @inject(LibroService) protected libroService: LibroService;
37
+
38
+ override view = LibroEditorComponent;
39
+
40
+ codeRef = createRef<HTMLDivElement>();
41
+
42
+ @prop() filePath?: string;
43
+
44
+ @prop()
45
+ libroView?: LibroView;
46
+
47
+ protected defer = new Deferred<void>();
48
+
49
+ get ready() {
50
+ return this.defer.promise;
51
+ }
52
+
53
+ constructor(
54
+ @inject(ViewOption) options: { path: string },
55
+ @inject(LabelProvider) labelProvider: LabelProvider,
56
+ ) {
57
+ super();
58
+ this.filePath = options.path;
59
+ this.title.caption = options.path;
60
+ const uri = new URI(options.path);
61
+ const uriRef = URIIconReference.create('file', new VScodeURI(options.path));
62
+ const iconClass = labelProvider.getIcon(uriRef);
63
+ this.title.icon = <div className={iconClass} />;
64
+ this.title.label = uri.displayName;
65
+ }
66
+
67
+ override async onViewMount(): Promise<void> {
68
+ this.getOrCreateLibroView();
69
+ }
70
+
71
+ protected async getOrCreateLibroView() {
72
+ const libroView = await this.libroService.getOrCreateView({
73
+ id: this.filePath,
74
+ resource: this.filePath,
75
+ });
76
+ if (!libroView) {
77
+ return;
78
+ }
79
+ this.libroView = libroView;
80
+ await this.libroView.initialized;
81
+ this.defer.resolve();
82
+ }
83
+
84
+ getResourceUri(): URI | undefined {
85
+ return new URI(this.filePath);
86
+ }
87
+
88
+ createMoveToUri(resourceUri: URI): URI | undefined {
89
+ this.filePath = resourceUri.path.toString();
90
+ this.getOrCreateLibroView();
91
+ return resourceUri;
92
+ }
93
+ }
@@ -0,0 +1,44 @@
1
+ import type { URI, ViewOpenHandlerOptions } from '@difizen/mana-app';
2
+ import { ConfigurationService, inject } from '@difizen/mana-app';
3
+ import {
4
+ NavigatableViewOpenHandler,
5
+ OpenHandler,
6
+ singleton,
7
+ Priority,
8
+ } from '@difizen/mana-app';
9
+
10
+ import { LibroJupyterConfiguration } from '../configuration/index.js';
11
+
12
+ import type { LibroNavigatableView } from './navigatable-view.js';
13
+ import { LibroNavigatableViewFactoryId } from './navigatable-view.js';
14
+
15
+ @singleton({ contrib: OpenHandler })
16
+ export class LibroJupyterOpenHandler extends NavigatableViewOpenHandler<LibroNavigatableView> {
17
+ @inject(ConfigurationService) protected configurationService: ConfigurationService;
18
+
19
+ id = LibroNavigatableViewFactoryId;
20
+
21
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
+ canHandle(uri: URI, _options?: ViewOpenHandlerOptions) {
23
+ if (uri.scheme === 'file' && uri.path.ext === '.ipynb') {
24
+ return Priority.PRIOR + 1;
25
+ }
26
+ return Priority.IDLE;
27
+ }
28
+
29
+ override async open(uri: URI, options: ViewOpenHandlerOptions = {}) {
30
+ const { viewOptions, ...extra } = options;
31
+ const slot = await this.configurationService.get(
32
+ LibroJupyterConfiguration['OpenSlot'],
33
+ );
34
+ return super.open(uri, {
35
+ slot,
36
+ viewOptions: {
37
+ path: uri.path.toString(),
38
+ ...viewOptions,
39
+ },
40
+ reveal: true,
41
+ ...extra,
42
+ });
43
+ }
44
+ }
package/src/index.ts ADDED
@@ -0,0 +1,32 @@
1
+ export * from '@difizen/libro-core';
2
+ export * from '@difizen/libro-kernel';
3
+ export * from '@difizen/libro-common';
4
+ export * from '@difizen/libro-output';
5
+ export * from '@difizen/libro-codemirror-markdown-cell';
6
+ export * from '@difizen/libro-codemirror-code-cell';
7
+ export * from '@difizen/libro-rendermime';
8
+ export * from '@difizen/libro-l10n';
9
+ export * from '@difizen/libro-search';
10
+ export * from '@difizen/libro-search-codemirror-cell';
11
+ export * from '@difizen/libro-code-editor';
12
+ export * from '@difizen/libro-codemirror';
13
+ export * from '@difizen/libro-codemirror-raw-cell';
14
+
15
+ export * from './module.js';
16
+ export * from './add-between-cell/index.js';
17
+ export * from './cell/index.js';
18
+ export * from './command/index.js';
19
+ export * from './components/index.js';
20
+ export * from './config/index.js';
21
+ export * from './contents/index.js';
22
+ export * from './keybind-instructions/index.js';
23
+ export * from './output/index.js';
24
+ export * from './rendermime/index.js';
25
+ export * from './theme/index.js';
26
+ export * from './toolbar/index.js';
27
+ export * from './libro-jupyter-protocol.js';
28
+ export * from './libro-jupyter-model.js';
29
+ export * from './libro-jupyter-file-service.js';
30
+ export * from './libro-jupyter-server-launch-manager.js';
31
+ export * from './file/index.js';
32
+ export * from './configuration/index.js';
@@ -0,0 +1,177 @@
1
+ /* stylelint-disable declaration-property-value-disallowed-list */
2
+ // The prefix to use on all css classes from ant.
3
+ @ant-prefix: ant;
4
+
5
+ .libro-keybind-instructions-command-search {
6
+ // padding: 16px 16px 0px 24px;
7
+ .@{ant-prefix}-input-group-wrapper {
8
+ background-color: var(--mana-libro-filtered-background-color) !important;
9
+ border-radius: 6px;
10
+ }
11
+
12
+ .@{ant-prefix}-input-group-addon {
13
+ background: transparent;
14
+ }
15
+ .@{ant-prefix}-input-search-button {
16
+ background: transparent;
17
+ border: none;
18
+ }
19
+ }
20
+
21
+ .libro-keybind-instructions-drawer {
22
+ .@{ant-prefix}-drawer-content-wrapper {
23
+ box-shadow:
24
+ 0 0 16px -8px rgba(0, 0, 0, 8%),
25
+ 0 0 28px 0 rgba(0, 0, 0, 5%),
26
+ 0 0 48px 16px rgba(0, 0, 0, 3%) !important;
27
+ }
28
+ .@{ant-prefix}-segmented {
29
+ background-color: var(--mana-libro-filtered-background-color);
30
+ }
31
+ .@{ant-prefix}-segmented:hover {
32
+ background: var(--mana-libro-filtered-background-color) !important;
33
+ }
34
+ .@{ant-prefix}-segmented-item-label {
35
+ color: var(--mana-libro-drawer-title-color);
36
+ }
37
+ .@{ant-prefix}-segmented-item-selected {
38
+ .@{ant-prefix}-segmented-item-label {
39
+ color: rgba(0, 10, 26, 89%);
40
+ }
41
+ }
42
+ .@{ant-prefix}-drawer-mask {
43
+ opacity: 0;
44
+ }
45
+ .@{ant-prefix}-drawer-content {
46
+ background: var(--mana-libro-popover-background-color);
47
+ }
48
+ .@{ant-prefix}-drawer-close {
49
+ color: var(--mana-libro-drawer-close-color);
50
+ }
51
+ .@{ant-prefix}-drawer-close:hover {
52
+ color: var(--mana-libro-drawer-close-color);
53
+ }
54
+ .@{ant-prefix}-drawer-title {
55
+ color: var(--mana-libro-drawer-title-color);
56
+ }
57
+ .@{ant-prefix}-input-search-button {
58
+ color: var(--mana-libro-filtered-text-color) !important;
59
+ }
60
+ .@{ant-prefix}-drawer-header {
61
+ border-bottom: 1px solid var(--mana-libro-filtered-border-color);
62
+ }
63
+
64
+ .@{ant-prefix}-btn:hover,
65
+ .@{ant-prefix}-btn:focus,
66
+ .@{ant-prefix}-btn:active {
67
+ background: var(--mana-libro-btn-hover-color) !important;
68
+ }
69
+
70
+ .@{ant-prefix}-input {
71
+ color: var(--mana-libro-drawer-title-color);
72
+ }
73
+ }
74
+
75
+ .libro-keybind-instructions-table {
76
+ height: calc(100% - 48px) !important;
77
+ margin-top: 16px;
78
+ overflow-y: auto !important;
79
+ }
80
+
81
+ .libro-keybind-instructions-table,
82
+ .libro-magic-table {
83
+ .@{ant-prefix}-table {
84
+ background: var(--mana-libro-popover-background-color);
85
+ }
86
+ }
87
+
88
+ .libro-keybind-instructions-icon {
89
+ display: flex;
90
+ width: 18px;
91
+ height: 18px;
92
+ }
93
+
94
+ .libro-edit-mode-keybind-instructions-table {
95
+ margin-top: 24px;
96
+ }
97
+
98
+ .libro-command-mode-keybind-instructions-table,
99
+ .libro-edit-mode-keybind-instructions-table {
100
+ tbody {
101
+ .anticon svg {
102
+ font-size: 12px;
103
+ }
104
+ }
105
+
106
+ thead > tr > th:nth-child(2) {
107
+ padding-right: 8px;
108
+ }
109
+
110
+ thead > tr > th:nth-child(2),
111
+ tbody > tr > td:nth-child(2) {
112
+ text-align: end;
113
+ }
114
+ .@{ant-prefix}-tag {
115
+ display: inline;
116
+ color: var(--mana-libro-keybind-tag-text-color);
117
+ font-weight: 400;
118
+ font-size: 10px;
119
+ font-family: SFProText;
120
+ line-height: 12px;
121
+ letter-spacing: 0;
122
+ background-color: var(--mana-libro-keybind-tag-background-color);
123
+ border: none;
124
+ border-radius: 2px;
125
+ }
126
+ }
127
+
128
+ .libro-keybind-search-match {
129
+ background-color: var(--mana-libro-search-match-background-color);
130
+ color: rgba(0, 10, 26, 89%);
131
+ }
132
+
133
+ .libro-command-mode-keybind-instructions-table,
134
+ .libro-edit-mode-keybind-instructions-table,
135
+ .libro-magic-table {
136
+ .@{ant-prefix}-table-thead > tr > th {
137
+ background: var(--mana-libro-popover-background-color);
138
+ }
139
+
140
+ .@{ant-prefix}-table-tbody > tr.@{ant-prefix}-table-row:hover > td {
141
+ background: var(--mana-libro-btn-hover-color) !important;
142
+ }
143
+
144
+ .@{ant-prefix}-table-tbody > tr > td,
145
+ .@{ant-prefix}-table-thead > tr > th {
146
+ border-bottom: 1px solid var(--mana-libro-table-border-color) !important;
147
+ }
148
+
149
+ thead tr th {
150
+ height: 30px;
151
+ color: var(--mana-libro-table-title-color);
152
+ font-weight: 600;
153
+ font-size: 14px;
154
+ font-family: PingFangSC;
155
+ font-style: semibold;
156
+ }
157
+
158
+ tbody > tr > td {
159
+ height: 33px;
160
+ color: var(--mana-libro-table-title-color);
161
+ font-weight: 400;
162
+ font-size: 10px;
163
+ font-family: PingFangSC;
164
+ font-style: regular;
165
+ line-height: 14px;
166
+ }
167
+
168
+ .@{ant-prefix}-table-thead > tr > th,
169
+ .@{ant-prefix}-table-tbody > tr > td,
170
+ .@{ant-prefix}-table tfoot > tr > th,
171
+ .@{ant-prefix}-table tfoot > tr > td {
172
+ padding: 0;
173
+ }
174
+ .@{ant-prefix}-table-cell .@{ant-prefix}-table-cell-scrollbar {
175
+ border-bottom: unset !important;
176
+ }
177
+ }
@@ -0,0 +1,5 @@
1
+ export * from './module.js';
2
+ export * from './keybind-instructions-icon.js';
3
+ export * from './keybind-instructions-items.js';
4
+ export * from './keybind-instructions-view.js';
5
+ export * from './keybind-instructions-contribution.js';