@difizen/libro-jupyter 0.2.0 → 0.2.2

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 (146) hide show
  1. package/es/add-between-cell/add-between-cell.js +1 -1
  2. package/es/cell/jupyter-code-cell-view.d.ts +3 -1
  3. package/es/cell/jupyter-code-cell-view.d.ts.map +1 -1
  4. package/es/cell/jupyter-code-cell-view.js +12 -5
  5. package/es/command/command-contribution.d.ts.map +1 -1
  6. package/es/command/command-contribution.js +5 -5
  7. package/es/components/icons.js +1 -1
  8. package/es/contents/content-contribution.js +1 -1
  9. package/es/contents/save-content-contribution.d.ts +10 -0
  10. package/es/contents/save-content-contribution.d.ts.map +1 -0
  11. package/es/contents/save-content-contribution.js +110 -0
  12. package/es/file/file-create-modal.d.ts.map +1 -1
  13. package/es/file/file-create-modal.js +16 -5
  14. package/es/file/file-service.js +1 -1
  15. package/es/file/index.d.ts +1 -0
  16. package/es/file/index.d.ts.map +1 -1
  17. package/es/file/index.js +2 -1
  18. package/es/index.d.ts +1 -0
  19. package/es/index.d.ts.map +1 -1
  20. package/es/index.js +2 -1
  21. package/es/keybind-instructions/index.less +9 -9
  22. package/es/keybind-instructions/keybind-instructions-view.d.ts +2 -2
  23. package/es/keybind-instructions/keybind-instructions-view.d.ts.map +1 -1
  24. package/es/keybind-instructions/keybind-instructions-view.js +69 -63
  25. package/es/libro-jupyter-model.d.ts +2 -4
  26. package/es/libro-jupyter-model.d.ts.map +1 -1
  27. package/es/libro-jupyter-model.js +35 -120
  28. package/es/libro-jupyter-workspace.d.ts +18 -0
  29. package/es/libro-jupyter-workspace.d.ts.map +1 -0
  30. package/es/libro-jupyter-workspace.js +108 -0
  31. package/es/module.d.ts.map +1 -1
  32. package/es/module.js +5 -2
  33. package/es/output/libro-jupyter-outputarea.d.ts.map +1 -1
  34. package/es/output/libro-jupyter-outputarea.js +60 -56
  35. package/es/toolbar/save-file-error.d.ts.map +1 -1
  36. package/es/toolbar/save-file-error.js +20 -13
  37. package/es/widget/box/contribution.d.ts +10 -0
  38. package/es/widget/box/contribution.d.ts.map +1 -0
  39. package/es/widget/box/contribution.js +48 -0
  40. package/es/widget/box/index.d.ts +3 -0
  41. package/es/widget/box/index.d.ts.map +1 -0
  42. package/es/widget/box/index.js +2 -0
  43. package/es/widget/box/index.less +3 -0
  44. package/es/widget/box/view.d.ts +19 -0
  45. package/es/widget/box/view.d.ts.map +1 -0
  46. package/es/widget/box/view.js +114 -0
  47. package/es/widget/comm.d.ts +65 -0
  48. package/es/widget/comm.d.ts.map +1 -0
  49. package/es/widget/comm.js +153 -0
  50. package/es/widget/index.d.ts +10 -0
  51. package/es/widget/index.d.ts.map +1 -0
  52. package/es/widget/index.js +9 -0
  53. package/es/widget/index.less +7 -0
  54. package/es/widget/instance-progress/contribution.d.ts +10 -0
  55. package/es/widget/instance-progress/contribution.d.ts.map +1 -0
  56. package/es/widget/instance-progress/contribution.js +39 -0
  57. package/es/widget/instance-progress/index.d.ts +3 -0
  58. package/es/widget/instance-progress/index.d.ts.map +1 -0
  59. package/es/widget/instance-progress/index.js +2 -0
  60. package/es/widget/instance-progress/view.d.ts +30 -0
  61. package/es/widget/instance-progress/view.d.ts.map +1 -0
  62. package/es/widget/instance-progress/view.js +180 -0
  63. package/es/widget/libro-widgets.d.ts +84 -0
  64. package/es/widget/libro-widgets.d.ts.map +1 -0
  65. package/es/widget/libro-widgets.js +307 -0
  66. package/es/widget/module.d.ts +4 -0
  67. package/es/widget/module.d.ts.map +1 -0
  68. package/es/widget/module.js +38 -0
  69. package/es/widget/progress/contribution.d.ts +10 -0
  70. package/es/widget/progress/contribution.d.ts.map +1 -0
  71. package/es/widget/progress/contribution.js +39 -0
  72. package/es/widget/progress/index.d.ts +3 -0
  73. package/es/widget/progress/index.d.ts.map +1 -0
  74. package/es/widget/progress/index.js +2 -0
  75. package/es/widget/progress/progressBar.d.ts +15 -0
  76. package/es/widget/progress/progressBar.d.ts.map +1 -0
  77. package/es/widget/progress/progressBar.js +20 -0
  78. package/es/widget/progress/view.d.ts +19 -0
  79. package/es/widget/progress/view.d.ts.map +1 -0
  80. package/es/widget/progress/view.js +74 -0
  81. package/es/widget/protocol.d.ts +193 -0
  82. package/es/widget/protocol.d.ts.map +1 -0
  83. package/es/widget/protocol.js +33 -0
  84. package/es/widget/utils.d.ts +27 -0
  85. package/es/widget/utils.d.ts.map +1 -0
  86. package/es/widget/utils.js +59 -0
  87. package/es/widget/version.d.ts +3 -0
  88. package/es/widget/version.d.ts.map +1 -0
  89. package/es/widget/version.js +2 -0
  90. package/es/widget/widget-manager.d.ts +19 -0
  91. package/es/widget/widget-manager.d.ts.map +1 -0
  92. package/es/widget/widget-manager.js +77 -0
  93. package/es/widget/widget-render.d.ts +7 -0
  94. package/es/widget/widget-render.d.ts.map +1 -0
  95. package/es/widget/widget-render.js +46 -0
  96. package/es/widget/widget-rendermime-contribution.d.ts +16 -0
  97. package/es/widget/widget-rendermime-contribution.d.ts.map +1 -0
  98. package/es/widget/widget-rendermime-contribution.js +50 -0
  99. package/es/widget/widget-view-contribution.d.ts +10 -0
  100. package/es/widget/widget-view-contribution.d.ts.map +1 -0
  101. package/es/widget/widget-view-contribution.js +36 -0
  102. package/es/widget/widget-view.d.ts +71 -0
  103. package/es/widget/widget-view.d.ts.map +1 -0
  104. package/es/widget/widget-view.js +273 -0
  105. package/package.json +18 -18
  106. package/src/add-between-cell/add-between-cell.tsx +1 -1
  107. package/src/cell/jupyter-code-cell-view.tsx +14 -6
  108. package/src/command/command-contribution.ts +11 -10
  109. package/src/components/icons.tsx +1 -1
  110. package/src/contents/content-contribution.ts +1 -1
  111. package/src/contents/save-content-contribution.ts +67 -0
  112. package/src/file/file-create-modal.tsx +10 -1
  113. package/src/file/file-service.ts +1 -1
  114. package/src/file/index.ts +1 -0
  115. package/src/index.ts +1 -0
  116. package/src/keybind-instructions/index.less +9 -9
  117. package/src/keybind-instructions/keybind-instructions-view.tsx +72 -62
  118. package/src/libro-jupyter-model.ts +1 -69
  119. package/src/libro-jupyter-workspace.ts +49 -0
  120. package/src/module.ts +6 -0
  121. package/src/output/libro-jupyter-outputarea.tsx +56 -49
  122. package/src/toolbar/save-file-error.tsx +25 -15
  123. package/src/widget/box/contribution.ts +29 -0
  124. package/src/widget/box/index.less +3 -0
  125. package/src/widget/box/index.ts +2 -0
  126. package/src/widget/box/view.tsx +112 -0
  127. package/src/widget/comm.ts +152 -0
  128. package/src/widget/index.less +7 -0
  129. package/src/widget/index.ts +9 -0
  130. package/src/widget/instance-progress/contribution.ts +20 -0
  131. package/src/widget/instance-progress/index.ts +2 -0
  132. package/src/widget/instance-progress/view.tsx +155 -0
  133. package/src/widget/libro-widgets.ts +223 -0
  134. package/src/widget/module.ts +73 -0
  135. package/src/widget/progress/contribution.ts +24 -0
  136. package/src/widget/progress/index.ts +2 -0
  137. package/src/widget/progress/progressBar.tsx +29 -0
  138. package/src/widget/progress/view.tsx +70 -0
  139. package/src/widget/protocol.ts +255 -0
  140. package/src/widget/utils.ts +67 -0
  141. package/src/widget/version.ts +2 -0
  142. package/src/widget/widget-manager.ts +45 -0
  143. package/src/widget/widget-render.tsx +52 -0
  144. package/src/widget/widget-rendermime-contribution.ts +36 -0
  145. package/src/widget/widget-view-contribution.ts +14 -0
  146. package/src/widget/widget-view.tsx +259 -0
@@ -7,6 +7,13 @@
7
7
  .@{ant-prefix}-input-group-wrapper {
8
8
  background-color: var(--mana-libro-filtered-background-color) !important;
9
9
  border-radius: 6px;
10
+ .@{ant-prefix}-input {
11
+ color: var(--mana-libro-drawer-title-color);
12
+
13
+ &::placeholder {
14
+ color: var(--mana-libro-keybind-tag-text-color);
15
+ }
16
+ }
10
17
  }
11
18
 
12
19
  .@{ant-prefix}-input-group-addon {
@@ -19,6 +26,7 @@
19
26
  }
20
27
 
21
28
  .libro-keybind-instructions-drawer {
29
+ background: var(--mana-libro-popover-background-color) !important;
22
30
  .@{ant-prefix}-drawer-content-wrapper {
23
31
  box-shadow:
24
32
  0 0 16px -8px rgba(0, 0, 0, 8%),
@@ -34,17 +42,9 @@
34
42
  .@{ant-prefix}-segmented-item-label {
35
43
  color: var(--mana-libro-drawer-title-color);
36
44
  }
37
- .@{ant-prefix}-segmented-item-selected {
38
- .@{ant-prefix}-segmented-item-label {
39
- color: rgba(0, 10, 26, 89%);
40
- }
41
- }
42
45
  .@{ant-prefix}-drawer-mask {
43
46
  opacity: 0;
44
47
  }
45
- .@{ant-prefix}-drawer-content {
46
- background: var(--mana-libro-popover-background-color);
47
- }
48
48
  .@{ant-prefix}-drawer-close {
49
49
  color: var(--mana-libro-drawer-close-color);
50
50
  }
@@ -135,6 +135,7 @@
135
135
  .libro-magic-table {
136
136
  .@{ant-prefix}-table-thead > tr > th {
137
137
  background: var(--mana-libro-popover-background-color);
138
+ color: var(--mana-libro-table-title-color);
138
139
  }
139
140
 
140
141
  .@{ant-prefix}-table-tbody > tr.@{ant-prefix}-table-row:hover > td {
@@ -148,7 +149,6 @@
148
149
 
149
150
  thead tr th {
150
151
  height: 30px;
151
- color: var(--mana-libro-table-title-color);
152
152
  font-weight: 600;
153
153
  font-size: 14px;
154
154
  font-family: PingFangSC;
@@ -1,10 +1,10 @@
1
- import { LirboContextKey } from '@difizen/libro-core';
2
- import { inject, singleton } from '@difizen/mana-app';
1
+ import { LibroContextKey } from '@difizen/libro-core';
2
+ import { inject, singleton, ThemeService } from '@difizen/mana-app';
3
3
  import { getOrigin, prop, useInject } from '@difizen/mana-app';
4
4
  import type { ModalItem, ModalItemProps } from '@difizen/mana-app';
5
5
  import type { Disposable } from '@difizen/mana-app';
6
6
  import { l10n } from '@difizen/mana-l10n';
7
- import { Input, Drawer, Table, Segmented } from 'antd';
7
+ import { Input, Drawer, Table, Segmented, ConfigProvider, theme } from 'antd';
8
8
  import { forwardRef, useCallback, useState } from 'react';
9
9
 
10
10
  import type { DataType } from './keybind-instructions-items.js';
@@ -49,7 +49,7 @@ const getSearchResult = (
49
49
 
50
50
  @singleton()
51
51
  export class KeybindInstrutionsService implements Disposable {
52
- @inject(LirboContextKey) contextKey: LirboContextKey;
52
+ @inject(LibroContextKey) contextKey: LibroContextKey;
53
53
  isKeybindInstructionsMask = false;
54
54
  @prop() searchCommandModeData: DataType[] = [];
55
55
  @prop() searchEditModeData: DataType[] = [];
@@ -132,6 +132,7 @@ export const KeybindInstrutionsComponent = forwardRef<
132
132
  const keybindInstrutionsService = useInject<KeybindInstrutionsService>(
133
133
  KeybindInstrutionsService,
134
134
  );
135
+ const themeService = useInject(ThemeService);
135
136
  const libroKeybindItems = useInject(LibroKeybindItems);
136
137
  const handleClose = useCallback(() => {
137
138
  close();
@@ -166,70 +167,79 @@ export const KeybindInstrutionsComponent = forwardRef<
166
167
  );
167
168
 
168
169
  return (
169
- <div className="libro-keybind-instructions-command" ref={ref}>
170
- <Drawer
171
- title={
172
- <Segmented
173
- value={segment}
174
- onChange={(value) => setSegment(value as Segment)}
175
- options={[
176
- { label: l10n.t('快捷键'), value: 'keybind' },
177
- { label: 'Magic 命令', value: 'magic' },
178
- ]}
179
- />
180
- }
181
- placement="right"
182
- onClose={handleClose}
183
- width="360px"
184
- open={visible}
185
- mask={true}
186
- className="libro-keybind-instructions-drawer"
187
- maskClosable={true}
188
- >
189
- {segment === 'magic' && (
190
- <div className="libro-magic-table">
191
- <Table
192
- size="small"
193
- columns={magicColumns}
194
- dataSource={magics}
195
- pagination={false}
196
- rowKey="key"
170
+ <ConfigProvider
171
+ theme={{
172
+ algorithm:
173
+ themeService.getCurrentTheme().type === 'dark'
174
+ ? theme.darkAlgorithm
175
+ : theme.defaultAlgorithm,
176
+ }}
177
+ >
178
+ <div className="libro-keybind-instructions-command" ref={ref}>
179
+ <Drawer
180
+ title={
181
+ <Segmented
182
+ value={segment}
183
+ onChange={(value) => setSegment(value as Segment)}
184
+ options={[
185
+ { label: l10n.t('快捷键'), value: 'keybind' },
186
+ { label: 'Magic 命令', value: 'magic' },
187
+ ]}
197
188
  />
198
- </div>
199
- )}
200
- {segment === 'keybind' && (
201
- <>
202
- <div className="libro-keybind-instructions-command-search">
203
- <Search
204
- placeholder={l10n.t('搜索功能关键字')}
205
- allowClear
206
- bordered={false}
207
- size="middle"
208
- onSearch={handleSearch}
189
+ }
190
+ placement="right"
191
+ onClose={handleClose}
192
+ width="360px"
193
+ open={visible}
194
+ mask={true}
195
+ className="libro-keybind-instructions-drawer"
196
+ maskClosable={true}
197
+ >
198
+ {segment === 'magic' && (
199
+ <div className="libro-magic-table">
200
+ <Table
201
+ size="small"
202
+ columns={magicColumns}
203
+ dataSource={magics}
204
+ pagination={false}
205
+ rowKey="key"
209
206
  />
210
207
  </div>
211
- <div className="libro-keybind-instructions-table">
212
- <div className="libro-command-mode-keybind-instructions-table">
213
- <Table
214
- rowKey="key"
215
- columns={libroKeybindItems.commandModeActionColumns}
216
- dataSource={commandModeDataSource}
217
- pagination={false}
208
+ )}
209
+ {segment === 'keybind' && (
210
+ <>
211
+ <div className="libro-keybind-instructions-command-search">
212
+ <Search
213
+ placeholder={l10n.t('搜索功能关键字')}
214
+ allowClear
215
+ bordered={false}
216
+ size="middle"
217
+ onSearch={handleSearch}
218
218
  />
219
219
  </div>
220
- <div className="libro-edit-mode-keybind-instructions-table">
221
- <Table
222
- rowKey="key"
223
- columns={libroKeybindItems.editModeActionColumns}
224
- dataSource={editModeDataSource}
225
- pagination={false}
226
- />
220
+ <div className="libro-keybind-instructions-table">
221
+ <div className="libro-command-mode-keybind-instructions-table">
222
+ <Table
223
+ rowKey="key"
224
+ columns={libroKeybindItems.commandModeActionColumns}
225
+ dataSource={commandModeDataSource}
226
+ pagination={false}
227
+ />
228
+ </div>
229
+ <div className="libro-edit-mode-keybind-instructions-table">
230
+ <Table
231
+ rowKey="key"
232
+ columns={libroKeybindItems.editModeActionColumns}
233
+ dataSource={editModeDataSource}
234
+ pagination={false}
235
+ />
236
+ </div>
227
237
  </div>
228
- </div>
229
- </>
230
- )}
231
- </Drawer>
232
- </div>
238
+ </>
239
+ )}
240
+ </Drawer>
241
+ </div>
242
+ </ConfigProvider>
233
243
  );
234
244
  });
235
245
 
@@ -2,13 +2,12 @@ import type { VirtualizedManager } from '@difizen/libro-core';
2
2
  import { LibroModel, VirtualizedManagerHelper } from '@difizen/libro-core';
3
3
  import {
4
4
  ContentsManager,
5
- ExecutableNotebookModel,
6
5
  isDisplayDataMsg,
7
6
  LibroKernelConnectionManager,
8
7
  ServerConnection,
9
8
  ServerManager,
10
9
  } from '@difizen/libro-kernel';
11
- import type { IKernelConnection } from '@difizen/libro-kernel';
10
+ import type { IKernelConnection, ExecutableNotebookModel } from '@difizen/libro-kernel';
12
11
  import type { IContentsCheckpointModel, IContentsModel } from '@difizen/libro-kernel';
13
12
  import { getOrigin, ModalService, prop } from '@difizen/mana-app';
14
13
  import { Deferred } from '@difizen/mana-app';
@@ -20,23 +19,11 @@ import {
20
19
  libroArgsMimetype,
21
20
  LibroFileService,
22
21
  } from './libro-jupyter-protocol.js';
23
- import { SaveFileErrorModal } from './toolbar/save-file-error.js';
24
22
  import { getDefaultKernel } from './utils/index.js';
25
23
 
26
24
  type IModel = IContentsModel;
27
25
  @transient()
28
26
  export class LibroJupyterModel extends LibroModel implements ExecutableNotebookModel {
29
- static is = (arg: Record<any, any> | undefined): arg is LibroJupyterModel => {
30
- return (
31
- !!arg &&
32
- ExecutableNotebookModel.is(arg) &&
33
- 'kernelConnection' in arg &&
34
- typeof (arg as any).kernelConnection === 'object' &&
35
- 'lspEnabled' in arg &&
36
- typeof (arg as any).lspEnabled === 'boolean'
37
- );
38
- };
39
-
40
27
  protected libroFileService: LibroFileService;
41
28
  protected virtualizedManager: VirtualizedManager;
42
29
 
@@ -187,61 +174,6 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
187
174
  .catch(console.error);
188
175
  }
189
176
 
190
- override async saveNotebookContent(): Promise<void> {
191
- const notebookContent = this.toJSON();
192
- if (!this.currentFileContents) {
193
- throw new Error('currentFileContents is undefined');
194
- }
195
-
196
- let res = {} as IModel | undefined;
197
-
198
- try {
199
- res = await this.libroFileService.write(
200
- notebookContent,
201
- this.currentFileContents,
202
- );
203
- if (!res) {
204
- return;
205
- }
206
- // 文件保存失败
207
- if (res.last_modified === this.last_modified || res.size === 0) {
208
- const errorMsg = `File Save Error: ${res?.message} `;
209
- this.libroFileService.fileSaveErrorEmitter.fire({
210
- cause: res.message,
211
- msg: errorMsg,
212
- name: res.name,
213
- path: res.path,
214
- created: res.created,
215
- last_modified: res.last_modified,
216
- size: res.size,
217
- type: res.type,
218
- });
219
- this.modalService.openModal(SaveFileErrorModal);
220
-
221
- throw new Error(errorMsg);
222
- }
223
- } catch (e: any) {
224
- if (!res) {
225
- return;
226
- }
227
- this.libroFileService.fileSaveErrorEmitter.fire({
228
- cause: e.errorCause,
229
- msg: e.message,
230
- name: res.name || this.currentFileContents.name,
231
- path: res.path || this.currentFileContents.path,
232
- created: res.created || this.currentFileContents.created,
233
- last_modified: res.last_modified || this.currentFileContents.last_modified,
234
- size: res.size || this.currentFileContents.size,
235
- type: res.type || this.currentFileContents.type,
236
- });
237
- this.modalService.openModal(SaveFileErrorModal);
238
-
239
- throw new Error('File Save Error');
240
- }
241
-
242
- await this.createCheckpoint();
243
- }
244
-
245
177
  override canRun() {
246
178
  if (!this.kernelConnection) {
247
179
  alert(l10n.t('Kernel Connection 还没有建立'));
@@ -0,0 +1,49 @@
1
+ import { URL } from '@difizen/libro-common';
2
+ import { BaseWorkspaceService, ILibroWorkspaceService } from '@difizen/libro-core';
3
+ import { ServerConnection, ServerManager } from '@difizen/libro-kernel';
4
+ import { ApplicationContribution } from '@difizen/mana-app';
5
+ import { URI } from '@difizen/mana-app';
6
+ import { inject, singleton } from '@difizen/mana-app';
7
+
8
+ interface JupyterWorkspaceData {
9
+ rootUri: string;
10
+ }
11
+
12
+ @singleton({ contrib: [ILibroWorkspaceService, ApplicationContribution] })
13
+ export class JupyterWorkspaceService
14
+ extends BaseWorkspaceService
15
+ implements ILibroWorkspaceService, ApplicationContribution
16
+ {
17
+ @inject(ServerConnection) serverConnection: ServerConnection;
18
+ @inject(ServerManager) serverManager: ServerManager;
19
+
20
+ protected workspaceData: JupyterWorkspaceData;
21
+
22
+ onViewStart() {
23
+ this.serverManager.ready
24
+ .then(() => {
25
+ const settings = { ...this.serverConnection.settings };
26
+ const url = URL.join(settings.baseUrl, '/libro/api/workspace');
27
+ return this.serverConnection.makeRequest(url, {});
28
+ })
29
+ .then(async (res) => {
30
+ const data = await res.json();
31
+ this.workspaceData = data;
32
+ this.deferred.resolve();
33
+ return;
34
+ })
35
+ .catch(() => {
36
+ return;
37
+ });
38
+ }
39
+
40
+ override get workspaceRoot() {
41
+ return new URI(this.workspaceData.rootUri);
42
+ }
43
+ override get notebooks() {
44
+ return [];
45
+ }
46
+ override get files() {
47
+ return [];
48
+ }
49
+ }
package/src/module.ts CHANGED
@@ -39,6 +39,7 @@ import {
39
39
  LibroJupyterSettingContribution,
40
40
  } from './config/index.js';
41
41
  import { LibroJupyterContentContribution } from './contents/index.js';
42
+ import { LibroJupyterContentSaveContribution } from './contents/save-content-contribution.js';
42
43
  import { LibroJupyterFileModule } from './file/index.js';
43
44
  import { KeybindInstructionsModule } from './keybind-instructions/index.js';
44
45
  import { LibroJupyterFileService } from './libro-jupyter-file-service.js';
@@ -46,6 +47,7 @@ import { LibroJupyterModel } from './libro-jupyter-model.js';
46
47
  import { KernelStatusAndSelectorProvider } from './libro-jupyter-protocol.js';
47
48
  import { JupyterServerLaunchManager } from './libro-jupyter-server-launch-manager.js';
48
49
  import { LibroJupyterView } from './libro-jupyter-view.js';
50
+ import { JupyterWorkspaceService } from './libro-jupyter-workspace.js';
49
51
  import { LibroJupyterOutputArea } from './output/index.js';
50
52
  import { PlotlyModule } from './rendermime/index.js';
51
53
  import { LibroJupyterColorContribution } from './theme/index.js';
@@ -54,9 +56,11 @@ import {
54
56
  LibroJupyterToolbarContribution,
55
57
  SaveFileErrorContribution,
56
58
  } from './toolbar/index.js';
59
+ import { WidgetModule } from './widget/index.js';
57
60
 
58
61
  export const LibroJupyterModule = ManaModule.create()
59
62
  .register(
63
+ JupyterWorkspaceService,
60
64
  LibroJupyterFileService,
61
65
  LibroJupyterCommandContribution,
62
66
  LibroJupyterKeybindingContribution,
@@ -65,6 +69,7 @@ export const LibroJupyterModule = ManaModule.create()
65
69
  SaveFileErrorContribution,
66
70
  LibroKeybindRegistry,
67
71
  LibroJupyterContentContribution,
72
+ LibroJupyterContentSaveContribution,
68
73
  LibroJupyterOutputArea,
69
74
  LibroJupyterColorContribution,
70
75
  LibroJupyterSettingContribution,
@@ -110,4 +115,5 @@ export const LibroJupyterModule = ManaModule.create()
110
115
  PlotlyModule,
111
116
  LibroJupyterFileModule,
112
117
  LibroLanguageClientModule,
118
+ WidgetModule,
113
119
  );
@@ -6,8 +6,10 @@ import type {
6
6
  } from '@difizen/libro-core';
7
7
  import { LibroOutputArea } from '@difizen/libro-core';
8
8
  import {
9
+ isClearOutputMsg,
9
10
  isDisplayDataMsg,
10
11
  isErrorMsg,
12
+ isExecuteInputMsg,
11
13
  isExecuteReplyMsg,
12
14
  isExecuteResultMsg,
13
15
  isStreamMsg,
@@ -31,58 +33,61 @@ export class LibroJupyterOutputArea extends LibroOutputArea {
31
33
  cellModel.msgChangeEmitter.event((msg) => {
32
34
  const transientMsg = (msg.content.transient || {}) as nbformat.JSONObject;
33
35
  const displayId = transientMsg['display_id'] as string;
34
- if (msg.header.msg_type !== 'status') {
35
- if (msg.header.msg_type === 'execute_input') {
36
- cellModel.executeCount = msg.content.execution_count;
37
- }
38
- if (
39
- isDisplayDataMsg(msg) ||
40
- isStreamMsg(msg) ||
41
- isErrorMsg(msg) ||
42
- isExecuteResultMsg(msg)
43
- ) {
44
- const output: nbformat.IOutput = {
45
- ...msg.content,
46
- output_type: msg.header.msg_type,
47
- };
48
- this.add(output);
49
- }
50
- if (isUpdateDisplayDataMsg(msg)) {
51
- const output = { ...msg.content, output_type: 'display_data' };
52
- const targets = this.displayIdMap.get(displayId);
53
- if (targets) {
54
- for (const index of targets) {
55
- this.set(index, output);
56
- }
36
+ if (isExecuteInputMsg(msg)) {
37
+ cellModel.executeCount = msg.content.execution_count;
38
+ }
39
+ if (
40
+ isDisplayDataMsg(msg) ||
41
+ isStreamMsg(msg) ||
42
+ isErrorMsg(msg) ||
43
+ isExecuteResultMsg(msg)
44
+ ) {
45
+ const output: nbformat.IOutput = {
46
+ ...msg.content,
47
+ output_type: msg.header.msg_type,
48
+ };
49
+ this.add(output);
50
+ }
51
+ if (isUpdateDisplayDataMsg(msg)) {
52
+ const output = { ...msg.content, output_type: 'display_data' };
53
+ const targets = this.displayIdMap.get(displayId);
54
+ if (targets) {
55
+ for (const index of targets) {
56
+ this.set(index, output);
57
57
  }
58
58
  }
59
- if (displayId && isDisplayDataMsg(msg)) {
60
- const targets = this.displayIdMap.get(displayId) || [];
61
- targets.push(this.outputs.length);
62
- this.displayIdMap.set(displayId, targets);
59
+ }
60
+ if (displayId && isDisplayDataMsg(msg)) {
61
+ const targets = this.displayIdMap.get(displayId) || [];
62
+ targets.push(this.outputs.length);
63
+ this.displayIdMap.set(displayId, targets);
64
+ }
65
+ //Handle an execute reply message.
66
+ if (isExecuteReplyMsg(msg)) {
67
+ const content = msg.content;
68
+ if (content.status !== 'ok') {
69
+ return;
63
70
  }
64
- //Handle an execute reply message.
65
- if (isExecuteReplyMsg(msg)) {
66
- const content = msg.content;
67
- if (content.status !== 'ok') {
68
- return;
69
- }
70
- const payload = content && content.payload;
71
- if (!payload || !payload.length) {
72
- return;
73
- }
74
- const pages = payload.filter((i: any) => i.source === 'page');
75
- if (!pages.length) {
76
- return;
77
- }
78
- const page = JSON.parse(JSON.stringify(pages[0]));
79
- const output: nbformat.IOutput = {
80
- output_type: 'display_data',
81
- data: page.data as nbformat.IMimeBundle,
82
- metadata: {},
83
- };
84
- this.add(output);
71
+ const payload = content && content.payload;
72
+ if (!payload || !payload.length) {
73
+ return;
74
+ }
75
+ const pages = payload.filter((i: any) => i.source === 'page');
76
+ if (!pages.length) {
77
+ return;
85
78
  }
79
+ const page = JSON.parse(JSON.stringify(pages[0]));
80
+ const output: nbformat.IOutput = {
81
+ output_type: 'display_data',
82
+ data: page.data as nbformat.IMimeBundle,
83
+ metadata: {},
84
+ };
85
+ this.add(output);
86
+ }
87
+
88
+ if (isClearOutputMsg(msg)) {
89
+ const wait = msg.content.wait;
90
+ this.clear(wait);
86
91
  }
87
92
  });
88
93
  }
@@ -94,6 +99,8 @@ export class LibroJupyterOutputArea extends LibroOutputArea {
94
99
 
95
100
  override clear(wait?: boolean | undefined): void {
96
101
  super.clear(wait);
97
- this.displayIdMap.clear();
102
+ if (!wait) {
103
+ this.displayIdMap.clear();
104
+ }
98
105
  }
99
106
  }
@@ -1,7 +1,8 @@
1
1
  import type { LibroView } from '@difizen/libro-core';
2
2
  import type { ModalItemProps, ModalItem } from '@difizen/mana-app';
3
+ import { ThemeService } from '@difizen/mana-app';
3
4
  import { useInject, ViewInstance } from '@difizen/mana-app';
4
- import { Modal } from 'antd';
5
+ import { ConfigProvider, Modal, theme } from 'antd';
5
6
 
6
7
  import type { LibroJupyterModel } from '../libro-jupyter-model.js';
7
8
 
@@ -10,22 +11,31 @@ export const SaveFileModalComponent: React.FC<ModalItemProps<void>> = ({
10
11
  close,
11
12
  }: ModalItemProps<void>) => {
12
13
  const libroView = useInject<LibroView>(ViewInstance);
13
-
14
+ const themeService = useInject(ThemeService);
14
15
  return (
15
- <Modal
16
- title="File Save Error"
17
- open={visible}
18
- onOk={() => close()}
19
- onCancel={() => close()}
20
- width={'400px'}
21
- centered={true}
16
+ <ConfigProvider
17
+ theme={{
18
+ algorithm:
19
+ themeService.getCurrentTheme().type === 'dark'
20
+ ? theme.darkAlgorithm
21
+ : theme.defaultAlgorithm,
22
+ }}
22
23
  >
23
- <p>{`File Save Error for: "${
24
- libroView && libroView.model
25
- ? (libroView.model as LibroJupyterModel).currentFileContents.name
26
- : ''
27
- }"`}</p>
28
- </Modal>
24
+ <Modal
25
+ title="File Save Error"
26
+ open={visible}
27
+ onOk={() => close()}
28
+ onCancel={() => close()}
29
+ width={'400px'}
30
+ centered={true}
31
+ >
32
+ <p>{`File Save Error for: "${
33
+ libroView && libroView.model
34
+ ? (libroView.model as LibroJupyterModel).currentFileContents.name
35
+ : ''
36
+ }"`}</p>
37
+ </Modal>
38
+ </ConfigProvider>
29
39
  );
30
40
  };
31
41
 
@@ -0,0 +1,29 @@
1
+ import { ViewManager, inject, singleton } from '@difizen/mana-app';
2
+
3
+ import type { IWidgetViewProps } from '../protocol.js';
4
+ import { WidgetViewContribution } from '../protocol.js';
5
+
6
+ import { VBoxWidget } from './view.js';
7
+
8
+ @singleton({ contrib: WidgetViewContribution })
9
+ export class VBoxWidgetContribution implements WidgetViewContribution {
10
+ @inject(ViewManager) viewManager: ViewManager;
11
+ canHandle = (attributes: any) => {
12
+ if (attributes._model_name === 'VBoxModel') {
13
+ return 100;
14
+ }
15
+ if (attributes.__view_name === 'VBoxView') {
16
+ return 100;
17
+ }
18
+ if (attributes._model_name === 'HBoxModel') {
19
+ return 100;
20
+ }
21
+ if (attributes.__view_name === 'HBoxView') {
22
+ return 100;
23
+ }
24
+ return 1;
25
+ };
26
+ factory(props: IWidgetViewProps) {
27
+ return this.viewManager.getOrCreateView(VBoxWidget, props);
28
+ }
29
+ }
@@ -0,0 +1,3 @@
1
+ .libro-widget-hbox {
2
+ display: flex;
3
+ }
@@ -0,0 +1,2 @@
1
+ export * from './contribution.js';
2
+ export * from './view.js';