@opensumi/ide-notebook 3.5.1-next-1732847732.0 → 3.5.1-next-1733450080.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,349 +0,0 @@
1
- export interface LanguageModel {
2
- initScript: string;
3
- queryCommand: string;
4
- matrixQueryCommand: string;
5
- widgetQueryCommand: string;
6
- deleteCommand: string;
7
- }
8
-
9
- export abstract class Languages {
10
- /**
11
- * Init and query script for supported languages.
12
- */
13
-
14
- static py_script = `import json
15
- import sys
16
- from importlib import __import__
17
- from IPython import get_ipython
18
- from IPython.core.magics.namespace import NamespaceMagics
19
-
20
-
21
- _jupyterlab_variableinspector_nms = NamespaceMagics()
22
- _jupyterlab_variableinspector_Jupyter = get_ipython()
23
- _jupyterlab_variableinspector_nms.shell = _jupyterlab_variableinspector_Jupyter.kernel.shell
24
-
25
- __np = None
26
- __pd = None
27
- __pyspark = None
28
- __tf = None
29
- __K = None
30
- __torch = None
31
- __ipywidgets = None
32
- __xr = None
33
-
34
-
35
- def _attempt_import(module):
36
- try:
37
- return __import__(module)
38
- except ImportError:
39
- return None
40
-
41
-
42
- def _check_imported():
43
- global __np, __pd, __pyspark, __tf, __K, __torch, __ipywidgets, __xr
44
-
45
- __np = _attempt_import('numpy')
46
- __pd = _attempt_import('pandas')
47
- __pyspark = _attempt_import('pyspark')
48
- __tf = _attempt_import('tensorflow')
49
- __K = _attempt_import('keras.backend') or _attempt_import('tensorflow.keras.backend')
50
- __torch = _attempt_import('torch')
51
- __ipywidgets = _attempt_import('ipywidgets')
52
- __xr = _attempt_import('xarray')
53
-
54
-
55
- def _jupyterlab_variableinspector_getsizeof(x):
56
- if type(x).__name__ in ['ndarray', 'Series']:
57
- return x.nbytes
58
- elif __pyspark and isinstance(x, __pyspark.sql.DataFrame):
59
- return "?"
60
- elif __tf and isinstance(x, __tf.Variable):
61
- return "?"
62
- elif __torch and isinstance(x, __torch.Tensor):
63
- return x.element_size() * x.nelement()
64
- elif __pd and type(x).__name__ == 'DataFrame':
65
- return x.memory_usage().sum()
66
- else:
67
- return sys.getsizeof(x)
68
-
69
-
70
- def _jupyterlab_variableinspector_getshapeof(x):
71
- if __pd and isinstance(x, __pd.DataFrame):
72
- return "%d rows x %d cols" % x.shape
73
- if __pd and isinstance(x, __pd.Series):
74
- return "%d rows" % x.shape
75
- if __np and isinstance(x, __np.ndarray):
76
- shape = " x ".join([str(i) for i in x.shape])
77
- return "%s" % shape
78
- if __pyspark and isinstance(x, __pyspark.sql.DataFrame):
79
- return "? rows x %d cols" % len(x.columns)
80
- if __tf and isinstance(x, __tf.Variable):
81
- shape = " x ".join([str(int(i)) for i in x.shape])
82
- return "%s" % shape
83
- if __tf and isinstance(x, __tf.Tensor):
84
- shape = " x ".join([str(int(i)) for i in x.shape])
85
- return "%s" % shape
86
- if __torch and isinstance(x, __torch.Tensor):
87
- shape = " x ".join([str(int(i)) for i in x.shape])
88
- return "%s" % shape
89
- if __xr and isinstance(x, __xr.DataArray):
90
- shape = " x ".join([str(int(i)) for i in x.shape])
91
- return "%s" % shape
92
- if isinstance(x, list):
93
- return "%s" % len(x)
94
- if isinstance(x, dict):
95
- return "%s keys" % len(x)
96
- return None
97
-
98
-
99
- def _jupyterlab_variableinspector_getcontentof(x):
100
- # returns content in a friendly way for python variables
101
- # pandas and numpy
102
- if __pd and isinstance(x, __pd.DataFrame):
103
- colnames = ', '.join(x.columns.map(str))
104
- content = "Columns: %s" % colnames
105
- elif __pd and isinstance(x, __pd.Series):
106
- content = str(x.values).replace(" ", ", ")[1:-1]
107
- content = content.replace("\\n", "")
108
- elif __np and isinstance(x, __np.ndarray):
109
- content = x.__repr__()
110
- elif __xr and isinstance(x, __xr.DataArray):
111
- content = x.values.__repr__()
112
- else:
113
- content = str(x)
114
-
115
- if len(content) > 150:
116
- return content[:150] + " ..."
117
- else:
118
- return content
119
-
120
-
121
- def _jupyterlab_variableinspector_is_matrix(x):
122
- # True if type(x).__name__ in ["DataFrame", "ndarray", "Series"] else False
123
- if __pd and isinstance(x, __pd.DataFrame):
124
- return True
125
- if __pd and isinstance(x, __pd.Series):
126
- return True
127
- if __np and isinstance(x, __np.ndarray) and len(x.shape) <= 2:
128
- return True
129
- if __pyspark and isinstance(x, __pyspark.sql.DataFrame):
130
- return True
131
- if __tf and isinstance(x, __tf.Variable) and len(x.shape) <= 2:
132
- return True
133
- if __tf and isinstance(x, __tf.Tensor) and len(x.shape) <= 2:
134
- return True
135
- if __torch and isinstance(x, __torch.Tensor) and len(x.shape) <= 2:
136
- return True
137
- if __xr and isinstance(x, __xr.DataArray) and len(x.shape) <= 2:
138
- return True
139
- if isinstance(x, list):
140
- return True
141
- return False
142
-
143
-
144
- def _jupyterlab_variableinspector_is_widget(x):
145
- return __ipywidgets and issubclass(x, __ipywidgets.DOMWidget)
146
-
147
-
148
- def _jupyterlab_variableinspector_dict_list():
149
- _check_imported()
150
- def keep_cond(v):
151
- try:
152
- obj = eval(v)
153
- if isinstance(obj, str):
154
- return True
155
- if __tf and isinstance(obj, __tf.Variable):
156
- return True
157
- if __pd and __pd is not None and (
158
- isinstance(obj, __pd.core.frame.DataFrame)
159
- or isinstance(obj, __pd.core.series.Series)):
160
- return True
161
- if __xr and __xr is not None and isinstance(obj, __xr.DataArray):
162
- return True
163
-
164
- if v in ['__np', '__pd', '__pyspark', '__tf', '__K', '__torch', '__ipywidgets', '__xr']:
165
- return obj is not None
166
- return True
167
- except:
168
- return False
169
- values = _jupyterlab_variableinspector_nms.who_ls()
170
- vardic = [
171
- {
172
- 'varName': _v,
173
- 'varType': type(eval(_v)).__name__,
174
- 'varSize': str(_jupyterlab_variableinspector_getsizeof(eval(_v))),
175
- 'varShape': str(_jupyterlab_variableinspector_getshapeof(eval(_v))) if _jupyterlab_variableinspector_getshapeof(eval(_v)) else '',
176
- 'varContent': str(_jupyterlab_variableinspector_getcontentof(eval(_v))),
177
- 'isMatrix': _jupyterlab_variableinspector_is_matrix(eval(_v)),
178
- 'isWidget': _jupyterlab_variableinspector_is_widget(type(eval(_v)))
179
- }
180
- for _v in values if keep_cond(_v)
181
- ]
182
- return json.dumps(vardic, ensure_ascii=False)
183
-
184
-
185
- def _jupyterlab_variableinspector_getmatrixcontent(x, max_rows=10000):
186
- # to do: add something to handle this in the future
187
- threshold = max_rows
188
-
189
- if __pd and __pyspark and isinstance(x, __pyspark.sql.DataFrame):
190
- df = x.limit(threshold).toPandas()
191
- return _jupyterlab_variableinspector_getmatrixcontent(df.copy())
192
- elif __np and __pd and type(x).__name__ == "DataFrame":
193
- if threshold is not None:
194
- x = x.head(threshold)
195
- x.columns = x.columns.map(str)
196
- return x.to_json(orient="table", default_handler=_jupyterlab_variableinspector_default, force_ascii=False)
197
- elif __np and __pd and type(x).__name__ == "Series":
198
- if threshold is not None:
199
- x = x.head(threshold)
200
- return x.to_json(orient="table", default_handler=_jupyterlab_variableinspector_default, force_ascii=False)
201
- elif __np and __pd and type(x).__name__ == "ndarray":
202
- df = __pd.DataFrame(x)
203
- return _jupyterlab_variableinspector_getmatrixcontent(df)
204
- elif __tf and (isinstance(x, __tf.Variable) or isinstance(x, __tf.Tensor)):
205
- df = __K.get_value(x)
206
- return _jupyterlab_variableinspector_getmatrixcontent(df)
207
- elif __torch and isinstance(x, __torch.Tensor):
208
- df = x.cpu().numpy()
209
- return _jupyterlab_variableinspector_getmatrixcontent(df)
210
- elif __xr and isinstance(x, __xr.DataArray):
211
- df = x.to_numpy()
212
- return _jupyterlab_variableinspector_getmatrixcontent(df)
213
- elif isinstance(x, list):
214
- s = __pd.Series(x)
215
- return _jupyterlab_variableinspector_getmatrixcontent(s)
216
-
217
-
218
- def _jupyterlab_variableinspector_displaywidget(widget):
219
- display(widget)
220
-
221
-
222
- def _jupyterlab_variableinspector_default(o):
223
- if isinstance(o, __np.number): return int(o)
224
- raise TypeError
225
-
226
-
227
- def _jupyterlab_variableinspector_deletevariable(x):
228
- exec("del %s" % x, globals())
229
- `;
230
-
231
- static r_script = `library(repr)
232
-
233
- .ls.objects = function (pos = 1, pattern, order.by, decreasing = FALSE, head = FALSE,
234
- n = 5)
235
- {
236
- napply <- function(names, fn) sapply(names, function(x) fn(get(x,
237
- pos = pos)))
238
- names <- ls(pos = pos, pattern = pattern)
239
- if (length(names) == 0) {
240
- return(jsonlite::toJSON(data.frame()))
241
- }
242
- obj.class <- napply(names, function(x) as.character(class(x))[1])
243
- obj.mode <- napply(names, mode)
244
- obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class)
245
- obj.size <- napply(names, object.size)
246
- obj.dim <- t(napply(names, function(x) as.numeric(dim(x))[1:2]))
247
- obj.content <- rep("NA", length(names))
248
- has_no_dim <- is.na(obj.dim)[1:length(names)]
249
- obj.dim[has_no_dim, 1] <- napply(names, length)[has_no_dim]
250
- vec <- (obj.type != "function")
251
- obj.content[vec] <- napply(names[vec], function(x) toString(x, width = 154)[1])
252
-
253
- obj.rownames <- napply(names, rownames)
254
- has_rownames <- obj.rownames != "NULL"
255
- obj.rownames <- sapply(obj.rownames[has_rownames], function(x) paste(x,
256
- collapse=", "))
257
- obj.rownames.short <- sapply(obj.rownames, function(x) paste(substr(x, 1, 150), "...."))
258
- obj.rownames <- ifelse(nchar(obj.rownames) > 154, obj.rownames.short, obj.rownames)
259
- obj.rownames <- sapply(obj.rownames, function(x) paste("Row names: ",x))
260
- obj.content[has_rownames] <- obj.rownames
261
-
262
-
263
- obj.colnames <- napply(names, colnames)
264
- has_colnames <- obj.colnames != "NULL"
265
- obj.colnames <- sapply(obj.colnames[has_colnames], function(x) paste(x,
266
- collapse = ", "))
267
- obj.colnames.short <- sapply(obj.colnames, function(x) paste(substr(x,
268
- 1, 150), "...."))
269
- obj.colnames <- ifelse(nchar(obj.colnames) > 154, obj.colnames.short,
270
- obj.colnames)
271
- obj.colnames <- sapply(obj.colnames, function(x) paste("Column names: ",x))
272
-
273
- obj.content[has_colnames] <- obj.colnames
274
-
275
- is_function <- (obj.type == "function")
276
- obj.content[is_function] <- napply(names[is_function], function(x) paste(strsplit(repr_text(x),")")[[1]][1],")",sep=""))
277
- obj.content <- unlist(obj.content, use.names = FALSE)
278
-
279
-
280
- out <- data.frame(obj.type, obj.size, obj.dim)
281
- names(out) <- c("varType", "varSize", "Rows", "Columns")
282
- out$varShape <- paste(out$Rows, " x ", out$Columns)
283
- out$varContent <- obj.content
284
- out$isMatrix <- FALSE
285
- out$varName <- row.names(out)
286
- out <- out[, !(names(out) %in% c("Rows", "Columns"))]
287
- rownames(out) <- NULL
288
- print(out)
289
- if (!missing(order.by))
290
- out <- out[order(out[[order.by]], decreasing = decreasing),
291
- ]
292
- if (head)
293
- out <- head(out, n)
294
- jsonlite::toJSON(out)
295
- }
296
-
297
- .deleteVariable <- function(x) {
298
- remove(list=c(x), envir=.GlobalEnv)
299
- }
300
- `;
301
-
302
- static scripts: Record<string, LanguageModel> = {
303
- python3: {
304
- initScript: Languages.py_script,
305
- queryCommand: '_jupyterlab_variableinspector_dict_list()',
306
- matrixQueryCommand: '_jupyterlab_variableinspector_getmatrixcontent',
307
- widgetQueryCommand: '_jupyterlab_variableinspector_displaywidget',
308
- deleteCommand: '_jupyterlab_variableinspector_deletevariable',
309
- },
310
- python2: {
311
- initScript: Languages.py_script,
312
- queryCommand: '_jupyterlab_variableinspector_dict_list()',
313
- matrixQueryCommand: '_jupyterlab_variableinspector_getmatrixcontent',
314
- widgetQueryCommand: '_jupyterlab_variableinspector_displaywidget',
315
- deleteCommand: '_jupyterlab_variableinspector_deletevariable',
316
- },
317
- python: {
318
- initScript: Languages.py_script,
319
- queryCommand: '_jupyterlab_variableinspector_dict_list()',
320
- matrixQueryCommand: '_jupyterlab_variableinspector_getmatrixcontent',
321
- widgetQueryCommand: '_jupyterlab_variableinspector_displaywidget',
322
- deleteCommand: '_jupyterlab_variableinspector_deletevariable',
323
- },
324
- R: {
325
- initScript: Languages.r_script,
326
- queryCommand: '.ls.objects()',
327
- matrixQueryCommand: '.ls.objects',
328
- widgetQueryCommand: 'TODO',
329
- deleteCommand: '.deleteVariable',
330
- },
331
- scala: {
332
- initScript: '_root_.almond.api.JupyterAPIHolder.value.VariableInspector.init()',
333
- queryCommand: '_root_.almond.api.JupyterAPIHolder.value.VariableInspector.dictList()',
334
- matrixQueryCommand: '', // TODO
335
- widgetQueryCommand: '', // TODO
336
- deleteCommand: '', // TODO
337
- },
338
- };
339
-
340
- public static getScript(lang: string): Promise<LanguageModel> {
341
- return new Promise((resolve, reject) => {
342
- if (lang in Languages.scripts) {
343
- resolve(Languages.scripts[lang]);
344
- } else {
345
- reject('Language ' + lang + ' not supported yet!');
346
- }
347
- });
348
- }
349
- }
@@ -1,131 +0,0 @@
1
- import { Color, ColorContribution, singleton } from '@difizen/mana-app';
2
-
3
- import type { ColorRegistry } from '@difizen/mana-app';
4
-
5
- @singleton({ contrib: ColorContribution })
6
- export class LibroVariableColorRegistry implements ColorContribution {
7
- // @inject(OpensumiInjector) injector: Injector;
8
-
9
- registerColors(colors: ColorRegistry): void {
10
- colors.register(
11
- // #region antd variable
12
- {
13
- id: 'libro.variable.search.background.color',
14
- defaults: {
15
- dark: '#ffffff0a',
16
- light: Color.rgba(0, 10, 26, 0.04),
17
- },
18
- description: '',
19
- },
20
- {
21
- id: 'libro.variable.search.text.color',
22
- defaults: { dark: '#878C93', light: Color.rgba(0, 10, 26, 0.26) },
23
- description: '',
24
- },
25
- {
26
- id: 'libro.variable.icon.color',
27
- defaults: {
28
- dark: Color.rgba(255, 255, 255, 0.45),
29
- light: Color.rgba(0, 10, 26, 0.47),
30
- },
31
- description: '',
32
- },
33
- {
34
- id: 'libro.variable.name.color',
35
- defaults: { dark: '#e3e4e6', light: '#000a1ac7' },
36
- description: '',
37
- },
38
- {
39
- id: 'libro.variable.title.color',
40
- defaults: { dark: '#ffffff59', light: '#000a1a78' },
41
- description: '',
42
- },
43
- {
44
- id: 'libro.variable.background.hover.color',
45
- defaults: { dark: '#ffffff14', light: '#151b2114' },
46
- description: '',
47
- },
48
- {
49
- id: 'libro.variable.description.color',
50
- defaults: { dark: '#bdc0c4', light: '#000a1aad' },
51
- description: '',
52
- },
53
- {
54
- id: 'libro.variable.tag.text.color',
55
- defaults: { dark: '#878c93', light: '#000a1aad' },
56
- description: '',
57
- },
58
- {
59
- id: 'libro.variable.tag.background.color',
60
- defaults: { dark: '#ffffff1f', light: '#0000001f' },
61
- description: '',
62
- },
63
- {
64
- id: 'libro.variable.border.color',
65
- defaults: {
66
- dark: '#ffffff14',
67
- light: '#151b2114',
68
- },
69
- description: '',
70
- },
71
- {
72
- id: 'libro.workbench.resource.spec.background',
73
- defaults: { dark: Color.rgba(255, 255, 255, 0.15), light: '#f9f9fb' },
74
- description: '',
75
- },
76
- {
77
- id: 'libro.workbench.panel.background.color',
78
- defaults: { dark: '#2B2C2E', light: '#f3f3f3' },
79
- description: '',
80
- },
81
- {
82
- id: 'libro.workbench.modal.title.color',
83
- defaults: { dark: '#EDEEEF', light: Color.rgba(0, 0, 0, 0.85) },
84
- description: '',
85
- },
86
- {
87
- id: 'libro.workbench.rating.input.background',
88
- defaults: { dark: Color.rgba(30, 30, 30, 0.48), light: '#fff' },
89
- description: '',
90
- },
91
- {
92
- id: 'libro.workbench.rating.input.border',
93
- defaults: {
94
- dark: Color.rgba(255, 255, 255, 0.07),
95
- light: Color.rgba(0, 10, 26, 0.07),
96
- },
97
- description: '',
98
- },
99
- {
100
- id: 'libro.workbench.popover.color',
101
- defaults: { dark: '#2F3032', light: '#ffffff' },
102
- description: '',
103
- },
104
- {
105
- id: 'libro.workbench.tour.description.color',
106
- defaults: { dark: '#BDC0C4', light: Color.rgba(0, 0, 0, 0.45) },
107
- description: '',
108
- },
109
- {
110
- id: 'libro.workbench.image.filter.container.background',
111
- defaults: { dark: '#2b2b2b', light: '#fafafa' },
112
- description: '',
113
- },
114
- {
115
- id: 'libro.workbench.image.filter.container.color',
116
- defaults: { dark: '#BDC0C4', light: '#000' },
117
- description: '',
118
- },
119
- {
120
- id: 'libro.workbench.image.filter.container.label.color',
121
- defaults: { dark: '#BDC0C4', light: '#000a1aad' },
122
- description: '',
123
- },
124
- {
125
- id: 'libro.workbench.image.filter.container.footer.background',
126
- defaults: { dark: '#2b2b2b', light: '#fff' },
127
- description: '',
128
- },
129
- );
130
- }
131
- }
@@ -1,6 +0,0 @@
1
- import { ManaModule } from '@difizen/mana-app';
2
-
3
- import { LibroVariableColorRegistry } from './libro-variable-color-registry';
4
- import { LibroVariablePanelView } from './variable-view';
5
-
6
- export const LibroVariableModule = ManaModule.create().register(LibroVariablePanelView, LibroVariableColorRegistry);
@@ -1,73 +0,0 @@
1
- import { Container, ViewManager, ViewRender } from '@difizen/mana-app';
2
- import { Empty } from 'antd';
3
- import React, { PropsWithChildren, memo, useEffect, useState } from 'react';
4
-
5
- import { URI, ViewState, localize, useInjectable } from '@opensumi/ide-core-browser';
6
- import { WorkbenchEditorService } from '@opensumi/ide-editor';
7
- import { WorkbenchEditorServiceImpl } from '@opensumi/ide-editor/lib/browser/workbench-editor.service';
8
-
9
- import { LIBRO_COMPONENTS_SCHEME_ID } from '../libro.protocol';
10
- import { ILibroOpensumiService } from '../libro.service';
11
- import { ManaContainer } from '../mana';
12
-
13
- import { LibroVariablePanelView } from './variable-view';
14
-
15
- export const VariablePanel = memo(({ viewState }: PropsWithChildren<{ viewState: ViewState }>) => {
16
- const collapsePanelContainerStyle = {
17
- width: viewState.width || '100%',
18
- height: viewState.height,
19
- };
20
- const editorService = useInjectable<WorkbenchEditorServiceImpl>(WorkbenchEditorService);
21
- const libroOpensumiService = useInjectable<ILibroOpensumiService>(ILibroOpensumiService);
22
- const manaContainer = useInjectable<Container>(ManaContainer);
23
-
24
- const [libroVariablePanelView, setLibroVariablePanelView] = useState<LibroVariablePanelView | undefined>(undefined);
25
-
26
- const createVariablePanelView = async (uri: URI, libro: any) => {
27
- const viewManager = manaContainer.get(ViewManager);
28
- const view = await viewManager.getOrCreateView<LibroVariablePanelView>(LibroVariablePanelView, {
29
- id: uri.toString(),
30
- });
31
- view?.pause();
32
- view.parent = libro;
33
- view.update();
34
- setLibroVariablePanelView(view);
35
- };
36
-
37
- useEffect(() => {
38
- if (editorService.currentResource?.uri.path.ext === `.${LIBRO_COMPONENTS_SCHEME_ID}`) {
39
- libroOpensumiService
40
- .getOrCreateLibroView(editorService.currentResource.uri)
41
- .then((libro) => createVariablePanelView(editorService.currentResource!.uri, libro));
42
- }
43
-
44
- const toDispose = editorService.onActiveResourceChange((e) => {
45
- if (e?.uri.path.ext === `.${LIBRO_COMPONENTS_SCHEME_ID}`) {
46
- libroOpensumiService.getOrCreateLibroView(e.uri).then((libro) => createVariablePanelView(e.uri, libro));
47
- } else {
48
- setLibroVariablePanelView(undefined);
49
- }
50
- });
51
-
52
- return () => {
53
- toDispose.dispose();
54
- };
55
- }, []);
56
- if (libroVariablePanelView) {
57
- return (
58
- <>
59
- <div style={collapsePanelContainerStyle}>{<ViewRender view={libroVariablePanelView}></ViewRender>}</div>
60
- </>
61
- );
62
- } else {
63
- return (
64
- <>
65
- <Empty
66
- image={Empty.PRESENTED_IMAGE_SIMPLE}
67
- description={localize('notebook.variable.panel.unsupported')}
68
- className='libro-variable-empty'
69
- />
70
- </>
71
- );
72
- }
73
- });
@@ -1 +0,0 @@
1
- export const VARIABLE_ID = 'variable';