@opensumi/ide-notebook 3.5.1-next-1732847732.0 → 3.5.1-next-1733392574.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 (61) hide show
  1. package/lib/browser/index.d.ts.map +1 -1
  2. package/lib/browser/index.js +2 -0
  3. package/lib/browser/index.js.map +1 -1
  4. package/lib/browser/kernel-panel/index.d.ts +1 -0
  5. package/lib/browser/kernel-panel/index.d.ts.map +1 -1
  6. package/lib/browser/kernel-panel/index.js +1 -0
  7. package/lib/browser/kernel-panel/index.js.map +1 -1
  8. package/lib/browser/kernel-panel/kernel.panel.contribution.d.ts +7 -0
  9. package/lib/browser/kernel-panel/kernel.panel.contribution.d.ts.map +1 -0
  10. package/lib/browser/kernel-panel/kernel.panel.contribution.js +32 -0
  11. package/lib/browser/kernel-panel/kernel.panel.contribution.js.map +1 -0
  12. package/lib/browser/libro/libro-opensumi-content-contribution.d.ts.map +1 -1
  13. package/lib/browser/libro/libro-opensumi-content-contribution.js +2 -3
  14. package/lib/browser/libro/libro-opensumi-content-contribution.js.map +1 -1
  15. package/lib/browser/libro-keybind-contribution.d.ts +7 -5
  16. package/lib/browser/libro-keybind-contribution.d.ts.map +1 -1
  17. package/lib/browser/libro-keybind-contribution.js +23 -14
  18. package/lib/browser/libro-keybind-contribution.js.map +1 -1
  19. package/lib/browser/libro.contribution.d.ts +2 -4
  20. package/lib/browser/libro.contribution.d.ts.map +1 -1
  21. package/lib/browser/libro.contribution.js +4 -33
  22. package/lib/browser/libro.contribution.js.map +1 -1
  23. package/package.json +13 -13
  24. package/src/browser/index.ts +2 -0
  25. package/src/browser/kernel-panel/index.ts +1 -0
  26. package/src/browser/kernel-panel/kernel.panel.contribution.ts +32 -0
  27. package/src/browser/libro/libro-opensumi-content-contribution.ts +2 -3
  28. package/src/browser/libro-keybind-contribution.ts +24 -17
  29. package/src/browser/libro.contribution.tsx +3 -47
  30. package/lib/browser/variables/index.less +0 -102
  31. package/lib/browser/variables/inspector-script.d.ts +0 -17
  32. package/lib/browser/variables/inspector-script.d.ts.map +0 -1
  33. package/lib/browser/variables/inspector-script.js +0 -339
  34. package/lib/browser/variables/inspector-script.js.map +0 -1
  35. package/lib/browser/variables/libro-variable-color-registry.d.ts +0 -6
  36. package/lib/browser/variables/libro-variable-color-registry.d.ts.map +0 -1
  37. package/lib/browser/variables/libro-variable-color-registry.js +0 -111
  38. package/lib/browser/variables/libro-variable-color-registry.js.map +0 -1
  39. package/lib/browser/variables/libro-variable-module.d.ts +0 -3
  40. package/lib/browser/variables/libro-variable-module.d.ts.map +0 -1
  41. package/lib/browser/variables/libro-variable-module.js +0 -5
  42. package/lib/browser/variables/libro-variable-module.js.map +0 -1
  43. package/lib/browser/variables/variable-panel.d.ts +0 -6
  44. package/lib/browser/variables/variable-panel.d.ts.map +0 -1
  45. package/lib/browser/variables/variable-panel.js +0 -57
  46. package/lib/browser/variables/variable-panel.js.map +0 -1
  47. package/lib/browser/variables/variable-protocol.d.ts +0 -2
  48. package/lib/browser/variables/variable-protocol.d.ts.map +0 -1
  49. package/lib/browser/variables/variable-protocol.js +0 -2
  50. package/lib/browser/variables/variable-protocol.js.map +0 -1
  51. package/lib/browser/variables/variable-view.d.ts +0 -45
  52. package/lib/browser/variables/variable-view.d.ts.map +0 -1
  53. package/lib/browser/variables/variable-view.js +0 -242
  54. package/lib/browser/variables/variable-view.js.map +0 -1
  55. package/src/browser/variables/index.less +0 -102
  56. package/src/browser/variables/inspector-script.ts +0 -349
  57. package/src/browser/variables/libro-variable-color-registry.ts +0 -131
  58. package/src/browser/variables/libro-variable-module.ts +0 -6
  59. package/src/browser/variables/variable-panel.tsx +0 -73
  60. package/src/browser/variables/variable-protocol.ts +0 -1
  61. package/src/browser/variables/variable-view.tsx +0 -311
@@ -1,311 +0,0 @@
1
- import { SearchOutlined, SelectOutlined } from '@ant-design/icons';
2
- import { LibroContextKey, LibroJupyterModel, LibroView, NotebookCommands } from '@difizen/libro-jupyter/noeditor';
3
- import {
4
- BaseView,
5
- CommandRegistry,
6
- ThemeService,
7
- ViewInstance,
8
- inject,
9
- prop,
10
- transient,
11
- useInject,
12
- view,
13
- } from '@difizen/mana-app';
14
- import { Input, List, Tag, Tooltip, message } from 'antd';
15
- import React, { forwardRef } from 'react';
16
- import './index.less';
17
-
18
- import { DisposableCollection, localize } from '@opensumi/ide-core-common';
19
-
20
- import { Languages } from './inspector-script';
21
-
22
- import type { LanguageModel } from './inspector-script';
23
- import type { KernelMessage } from '@difizen/libro-kernel';
24
-
25
- const LibroVariableComponent = forwardRef<HTMLDivElement>((props, ref) => {
26
- const instance = useInject<LibroVariablePanelView>(ViewInstance);
27
- const themeService = useInject(ThemeService);
28
- const libroContextKey = useInject(LibroContextKey);
29
- return (
30
- <div ref={ref} className='libro-variable-content'>
31
- <div className='libro-variable-search'>
32
- <Input
33
- className='libro-variable-search-input'
34
- placeholder={localize('notebook.variable.panel.search.placeholder')}
35
- prefix={<SearchOutlined />}
36
- onChange={(e) => instance.search(e.target.value)}
37
- onFocus={() => {
38
- libroContextKey.disableCommandMode();
39
- }}
40
- onBlur={() => {
41
- libroContextKey.enableCommandMode();
42
- }}
43
- />
44
- <img
45
- src={`${
46
- themeService.getCurrentTheme().type === 'dark'
47
- ? 'https://mdn.alipayobjects.com/huamei_xt20ge/afts/img/A*rY0oTpYcmZsAAAAAAAAAAAAADiuUAQ/original'
48
- : 'https://mdn.alipayobjects.com/huamei_xt20ge/afts/img/A*VApRSqHz8wQAAAAAAAAAAAAADiuUAQ/original'
49
- }`}
50
- onClick={instance.refresh}
51
- className='libro-variable-search-extra'
52
- ></img>
53
- </div>
54
- <List
55
- className='libro-variable-list'
56
- itemLayout='horizontal'
57
- dataSource={instance.filteredList}
58
- renderItem={(item) => {
59
- const DesrendeItem = () => <Tooltip title={item.varContent}>{item.varContent}</Tooltip>;
60
- return (
61
- <List.Item>
62
- <List.Item.Meta
63
- title={
64
- <div className='libro-variable-title'>
65
- <span className='libro-variable-name'>
66
- {item.varName}
67
- <Tag className='libro-variable-type-tag' bordered={false}>
68
- {item.varType}
69
- </Tag>
70
- </span>
71
- <Tooltip placement='top' title={localize('notebook.variable.panel.show.detail')}>
72
- <SelectOutlined onClick={() => instance.showVariable(item)} className='libro-variable-extra' />
73
- </Tooltip>
74
- </div>
75
- }
76
- description={<DesrendeItem />}
77
- />
78
- </List.Item>
79
- );
80
- }}
81
- />
82
- </div>
83
- );
84
- });
85
-
86
- export interface IVariable {
87
- varName: string;
88
- varSize: string;
89
- varShape: string;
90
- varContent: string;
91
- varType: string;
92
- isMatrix: boolean;
93
- isWidget: boolean;
94
- }
95
-
96
- @transient()
97
- @view('libro-variable-panel-view')
98
- export class LibroVariablePanelView extends BaseView {
99
- @inject(CommandRegistry) commands: CommandRegistry | undefined;
100
- protected connectorToDispose = new DisposableCollection();
101
- @prop()
102
- list?: IVariable[];
103
- @prop()
104
- searchValue?: string;
105
- protected languageModel?: LanguageModel;
106
- protected kernelInited = false;
107
- view = LibroVariableComponent;
108
- parent?: LibroView;
109
-
110
- get filteredList() {
111
- if (!this.searchValue) {
112
- return this.list;
113
- }
114
- if (!this.list) {
115
- return undefined;
116
- }
117
- return this.list.filter((item) => {
118
- if (!this.searchValue) {
119
- return true;
120
- }
121
- return item.varName.includes(this.searchValue);
122
- });
123
- }
124
- showVariable = async (variable: IVariable) => {
125
- if (!this.parent) {
126
- return;
127
- }
128
- let activeIndex = this.parent.model.cells.length;
129
- if (this.parent.activeCell) {
130
- activeIndex = this.parent.findCellIndex(this.parent.activeCell) + 1;
131
- }
132
- await this.parent.addCell(
133
- {
134
- cell: {
135
- cell_type: 'code',
136
- source: variable.varName,
137
- metadata: {},
138
- outputs: [],
139
- },
140
- },
141
- activeIndex,
142
- );
143
- const cell = this.parent.model.cells[activeIndex];
144
- window.requestAnimationFrame(() => {
145
- this.commands?.executeCommand(NotebookCommands.RunCell.id, cell, this.parent);
146
- });
147
- };
148
- async update() {
149
- if (!this.parent) {
150
- return;
151
- }
152
- if (!(this.parent.model instanceof LibroJupyterModel)) {
153
- return;
154
- }
155
- const model = this.parent.model;
156
- const connection = model.kernelConnection;
157
- if (connection) {
158
- this.connectorToDispose.push(
159
- connection.statusChanged((status) => {
160
- if (status === 'dead') {
161
- this.kernelInited = false;
162
- this.list = undefined;
163
- this.connectorToDispose.dispose();
164
- }
165
- }),
166
- );
167
- this.connectorToDispose.push(
168
- connection.statusChanged((status) => {
169
- if (status === 'restarting') {
170
- this.kernelInited = false;
171
- this.list = undefined;
172
- this.setupConnector(model);
173
- }
174
- }),
175
- );
176
- }
177
- this.setupConnector(model);
178
- }
179
-
180
- protected async setupConnector(model: LibroJupyterModel) {
181
- if (!this.kernelInited) {
182
- model.kcReady.then(async (connection) => {
183
- const lang = (await connection.info).language_info.name;
184
- const languageModel = await Languages.getScript(lang);
185
- this.languageModel = languageModel;
186
- this.initOnKernel().then(() => {
187
- this.kernelInited = true;
188
- this.connectorToDispose.push(connection.iopubMessage(this.queryCall));
189
- this.performInspection();
190
- });
191
- });
192
- } else {
193
- if (model.kernelConnection) {
194
- this.connectorToDispose.push(model.kernelConnection.iopubMessage(this.queryCall));
195
- this.performInspection();
196
- }
197
- }
198
- }
199
-
200
- pause = () => {
201
- this.connectorToDispose.dispose();
202
- this.connectorToDispose = new DisposableCollection();
203
- };
204
-
205
- search = (v: string) => {
206
- this.searchValue = v;
207
- };
208
-
209
- /*
210
- * Invokes a inspection if the signal emitted from specified session is an 'execute_input' msg.
211
- */
212
- protected queryCall = (msg: KernelMessage.IMessage): void => {
213
- const msgType = msg.header.msg_type;
214
- switch (msgType) {
215
- case 'execute_input': {
216
- const code = (msg as KernelMessage.IExecuteInputMsg).content.code;
217
- if (
218
- !(code === this.languageModel?.queryCommand) &&
219
- !(code === this.languageModel?.matrixQueryCommand) &&
220
- !code.startsWith(this.languageModel?.widgetQueryCommand || '')
221
- ) {
222
- this.performInspection();
223
- }
224
- break;
225
- }
226
- default:
227
- break;
228
- }
229
- };
230
-
231
- public refresh = async () => {
232
- try {
233
- await this.performInspection();
234
- message.success(localize('notebook.variable.panel.refresh.success', 'Variable refresh successful'));
235
- } catch (ex) {
236
- message.error(localize('notebook.variable.panel.refresh.error', 'Variable refresh failed'));
237
- }
238
- };
239
- /**
240
- * Performs an inspection by sending an execute request with the query command to the kernel.
241
- */
242
- public performInspection = (): Promise<KernelMessage.IExecuteReplyMsg> => {
243
- const content: KernelMessage.IExecuteRequestMsg['content'] = {
244
- code: this.languageModel!.queryCommand,
245
- stop_on_error: false,
246
- store_history: false,
247
- };
248
- return this.fetch(content, this.handleQueryResponse);
249
- };
250
-
251
- protected handleQueryResponse = (response: KernelMessage.IIOPubMessage) => {
252
- const msgType = response.header.msg_type;
253
- switch (msgType) {
254
- case 'execute_result': {
255
- const payload = response as KernelMessage.IExecuteResultMsg;
256
- let content: string = payload.content.data['text/plain'] as string;
257
- if (content.slice(0, 1) === "'" || content.slice(0, 1) === '"') {
258
- content = content.slice(1, -1);
259
- content = content.replace(/\\"/g, '"').replace(/\\'/g, "'");
260
- }
261
-
262
- const update = JSON.parse(content) as IVariable[];
263
- this.list = update;
264
- break;
265
- }
266
- case 'display_data': {
267
- const payloadDisplay = response as KernelMessage.IExecuteResultMsg;
268
- let contentDisplay: string = payloadDisplay.content.data['text/plain'] as string;
269
- if (contentDisplay.slice(0, 1) === "'" || contentDisplay.slice(0, 1) === '"') {
270
- contentDisplay = contentDisplay.slice(1, -1);
271
- contentDisplay = contentDisplay.replace(/\\"/g, '"').replace(/\\'/g, "'");
272
- }
273
-
274
- const updateDisplay = JSON.parse(contentDisplay) as IVariable[];
275
- this.list = updateDisplay;
276
- break;
277
- }
278
- default:
279
- break;
280
- }
281
- };
282
-
283
- /**
284
- * Initializes the kernel by running the set up script located at _initScriptPath.
285
- */
286
- protected initOnKernel(): Promise<KernelMessage.IExecuteReplyMsg> {
287
- const content: KernelMessage.IExecuteRequestMsg['content'] = {
288
- code: this.languageModel!.initScript,
289
- stop_on_error: false,
290
- silent: true,
291
- };
292
-
293
- return this.fetch(content, () => {
294
- // no op
295
- });
296
- }
297
-
298
- protected fetch = async (
299
- content: KernelMessage.IExecuteRequestMsg['content'],
300
- ioCallback: (msg: KernelMessage.IIOPubMessage) => any,
301
- ) => {
302
- const model = this.parent!.model! as LibroJupyterModel;
303
- await model.kcReady;
304
- const connection = model.kernelConnection!;
305
- const future = connection.requestExecute(content);
306
- future.onIOPub = (msg) => {
307
- ioCallback(msg);
308
- };
309
- return future.done as Promise<KernelMessage.IExecuteReplyMsg>;
310
- };
311
- }