@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.
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +2 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/kernel-panel/index.d.ts +1 -0
- package/lib/browser/kernel-panel/index.d.ts.map +1 -1
- package/lib/browser/kernel-panel/index.js +1 -0
- package/lib/browser/kernel-panel/index.js.map +1 -1
- package/lib/browser/kernel-panel/kernel.panel.contribution.d.ts +7 -0
- package/lib/browser/kernel-panel/kernel.panel.contribution.d.ts.map +1 -0
- package/lib/browser/kernel-panel/kernel.panel.contribution.js +32 -0
- package/lib/browser/kernel-panel/kernel.panel.contribution.js.map +1 -0
- package/lib/browser/libro/libro-opensumi-content-contribution.d.ts.map +1 -1
- package/lib/browser/libro/libro-opensumi-content-contribution.js +2 -3
- package/lib/browser/libro/libro-opensumi-content-contribution.js.map +1 -1
- package/lib/browser/libro-keybind-contribution.d.ts +7 -5
- package/lib/browser/libro-keybind-contribution.d.ts.map +1 -1
- package/lib/browser/libro-keybind-contribution.js +23 -14
- package/lib/browser/libro-keybind-contribution.js.map +1 -1
- package/lib/browser/libro.contribution.d.ts +2 -4
- package/lib/browser/libro.contribution.d.ts.map +1 -1
- package/lib/browser/libro.contribution.js +4 -33
- package/lib/browser/libro.contribution.js.map +1 -1
- package/package.json +13 -13
- package/src/browser/index.ts +2 -0
- package/src/browser/kernel-panel/index.ts +1 -0
- package/src/browser/kernel-panel/kernel.panel.contribution.ts +32 -0
- package/src/browser/libro/libro-opensumi-content-contribution.ts +2 -3
- package/src/browser/libro-keybind-contribution.ts +24 -17
- package/src/browser/libro.contribution.tsx +3 -47
- package/lib/browser/variables/index.less +0 -102
- package/lib/browser/variables/inspector-script.d.ts +0 -17
- package/lib/browser/variables/inspector-script.d.ts.map +0 -1
- package/lib/browser/variables/inspector-script.js +0 -339
- package/lib/browser/variables/inspector-script.js.map +0 -1
- package/lib/browser/variables/libro-variable-color-registry.d.ts +0 -6
- package/lib/browser/variables/libro-variable-color-registry.d.ts.map +0 -1
- package/lib/browser/variables/libro-variable-color-registry.js +0 -111
- package/lib/browser/variables/libro-variable-color-registry.js.map +0 -1
- package/lib/browser/variables/libro-variable-module.d.ts +0 -3
- package/lib/browser/variables/libro-variable-module.d.ts.map +0 -1
- package/lib/browser/variables/libro-variable-module.js +0 -5
- package/lib/browser/variables/libro-variable-module.js.map +0 -1
- package/lib/browser/variables/variable-panel.d.ts +0 -6
- package/lib/browser/variables/variable-panel.d.ts.map +0 -1
- package/lib/browser/variables/variable-panel.js +0 -57
- package/lib/browser/variables/variable-panel.js.map +0 -1
- package/lib/browser/variables/variable-protocol.d.ts +0 -2
- package/lib/browser/variables/variable-protocol.d.ts.map +0 -1
- package/lib/browser/variables/variable-protocol.js +0 -2
- package/lib/browser/variables/variable-protocol.js.map +0 -1
- package/lib/browser/variables/variable-view.d.ts +0 -45
- package/lib/browser/variables/variable-view.d.ts.map +0 -1
- package/lib/browser/variables/variable-view.js +0 -242
- package/lib/browser/variables/variable-view.js.map +0 -1
- package/src/browser/variables/index.less +0 -102
- package/src/browser/variables/inspector-script.ts +0 -349
- package/src/browser/variables/libro-variable-color-registry.ts +0 -131
- package/src/browser/variables/libro-variable-module.ts +0 -6
- package/src/browser/variables/variable-panel.tsx +0 -73
- package/src/browser/variables/variable-protocol.ts +0 -1
- package/src/browser/variables/variable-view.tsx +0 -311
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import { LibroSearchToggleCommand, LibroService, NotebookCommands } from '@difizen/libro-jupyter/noeditor';
|
|
1
|
+
import { LibroSearchToggleCommand, LibroService, LibroView, NotebookCommands } from '@difizen/libro-jupyter/noeditor';
|
|
2
2
|
import { Container, CommandRegistry as LibroCommandRegistry } from '@difizen/mana-app';
|
|
3
3
|
|
|
4
4
|
import { Autowired } from '@opensumi/di';
|
|
5
5
|
import {
|
|
6
6
|
ClientAppContribution,
|
|
7
|
-
CommandContribution,
|
|
8
7
|
CommandRegistry,
|
|
9
8
|
Domain,
|
|
10
9
|
IContextKeyService,
|
|
11
|
-
KeybindingContribution,
|
|
12
10
|
KeybindingRegistry,
|
|
13
11
|
KeybindingScope,
|
|
14
|
-
MaybePromise,
|
|
15
12
|
} from '@opensumi/ide-core-browser';
|
|
16
13
|
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
17
14
|
|
|
18
15
|
import { LIBRO_COMPONENTS_SCHEME_ID } from './libro.protocol';
|
|
19
16
|
import { ManaContainer } from './mana';
|
|
20
17
|
|
|
21
|
-
@Domain(ClientAppContribution
|
|
22
|
-
export class LibroKeybindContribution implements ClientAppContribution
|
|
18
|
+
@Domain(ClientAppContribution)
|
|
19
|
+
export class LibroKeybindContribution implements ClientAppContribution {
|
|
23
20
|
@Autowired(IContextKeyService) contextKeyService: IContextKeyService;
|
|
21
|
+
@Autowired(KeybindingRegistry) keybindingRegistry: KeybindingRegistry;
|
|
24
22
|
@Autowired(WorkbenchEditorService)
|
|
25
23
|
workbenchEditorService: WorkbenchEditorService;
|
|
26
24
|
@Autowired(CommandRegistry)
|
|
@@ -28,12 +26,17 @@ export class LibroKeybindContribution implements ClientAppContribution, Keybindi
|
|
|
28
26
|
@Autowired(ManaContainer)
|
|
29
27
|
private readonly manaContainer: Container;
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
onStart() {
|
|
32
30
|
this.registerContextKey();
|
|
31
|
+
this.registerCommand();
|
|
32
|
+
this.registerKeybind();
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
registerContextKey() {
|
|
36
|
-
const notebookFocusContext = this.contextKeyService.createKey<boolean>(
|
|
36
|
+
const notebookFocusContext = this.contextKeyService.createKey<boolean>(
|
|
37
|
+
'libroNotebookFocused',
|
|
38
|
+
this.hasActiveNotebook(),
|
|
39
|
+
);
|
|
37
40
|
|
|
38
41
|
this.workbenchEditorService.onActiveResourceChange((e) => {
|
|
39
42
|
if (e?.uri?.path.ext === `.${LIBRO_COMPONENTS_SCHEME_ID}`) {
|
|
@@ -52,41 +55,45 @@ export class LibroKeybindContribution implements ClientAppContribution, Keybindi
|
|
|
52
55
|
return this.manaContainer.get(LibroCommandRegistry);
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
hasActiveNotebook() {
|
|
59
|
+
return this.libroService.active instanceof LibroView;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
registerCommand() {
|
|
63
|
+
this.commandRegistry.registerCommand(NotebookCommands['EnterCommandMode'], {
|
|
57
64
|
execute: () => {
|
|
58
65
|
this.libroCommandRegistry.executeCommand(NotebookCommands['EnterCommandMode'].id);
|
|
59
66
|
},
|
|
60
67
|
});
|
|
61
|
-
|
|
68
|
+
this.commandRegistry.registerCommand(NotebookCommands['RunCell'], {
|
|
62
69
|
execute: () => {
|
|
63
70
|
this.libroCommandRegistry.executeCommand(NotebookCommands['RunCell'].id);
|
|
64
71
|
},
|
|
65
72
|
});
|
|
66
|
-
|
|
73
|
+
this.commandRegistry.registerCommand(NotebookCommands['RunCellAndSelectNext'], {
|
|
67
74
|
execute: () => {
|
|
68
75
|
this.libroCommandRegistry.executeCommand(NotebookCommands['RunCellAndSelectNext'].id);
|
|
69
76
|
},
|
|
70
77
|
});
|
|
71
|
-
|
|
78
|
+
this.commandRegistry.registerCommand(NotebookCommands['RunCellAndInsertBelow'], {
|
|
72
79
|
execute: () => {
|
|
73
80
|
this.libroCommandRegistry.executeCommand(NotebookCommands['RunCellAndInsertBelow'].id);
|
|
74
81
|
},
|
|
75
82
|
});
|
|
76
|
-
|
|
83
|
+
this.commandRegistry.registerCommand(NotebookCommands['SplitCellAntCursor'], {
|
|
77
84
|
execute: () => {
|
|
78
85
|
this.libroCommandRegistry.executeCommand(NotebookCommands['SplitCellAntCursor'].id);
|
|
79
86
|
},
|
|
80
87
|
});
|
|
81
|
-
|
|
88
|
+
this.commandRegistry.registerCommand(LibroSearchToggleCommand.ShowLibroSearch, {
|
|
82
89
|
execute: () => {
|
|
83
90
|
this.libroCommandRegistry.executeCommand(LibroSearchToggleCommand.ShowLibroSearch.id);
|
|
84
91
|
},
|
|
85
92
|
});
|
|
86
93
|
}
|
|
87
94
|
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
registerKeybind() {
|
|
96
|
+
this.keybindingRegistry.registerKeybindings(
|
|
90
97
|
[
|
|
91
98
|
{
|
|
92
99
|
keybinding: 'f1',
|
|
@@ -15,8 +15,6 @@ import {
|
|
|
15
15
|
ClientAppContribution,
|
|
16
16
|
CommandContribution,
|
|
17
17
|
type CommandRegistry,
|
|
18
|
-
ComponentContribution,
|
|
19
|
-
ComponentRegistry,
|
|
20
18
|
Disposable,
|
|
21
19
|
Domain,
|
|
22
20
|
IClientApp,
|
|
@@ -24,7 +22,6 @@ import {
|
|
|
24
22
|
OpenerContribution,
|
|
25
23
|
Schemes,
|
|
26
24
|
URI,
|
|
27
|
-
localize,
|
|
28
25
|
} from '@opensumi/ide-core-browser';
|
|
29
26
|
import { message } from '@opensumi/ide-core-browser/lib/components';
|
|
30
27
|
import {
|
|
@@ -39,7 +36,7 @@ import { IEditorDocumentModelContentRegistry } from '@opensumi/ide-editor/lib/br
|
|
|
39
36
|
import { IconService } from '@opensumi/ide-theme/lib/browser';
|
|
40
37
|
import { IThemeService, IconType } from '@opensumi/ide-theme/lib/common';
|
|
41
38
|
|
|
42
|
-
import {
|
|
39
|
+
import { initKernelPanelColorToken } from './kernel-panel';
|
|
43
40
|
import { LibroOpensumiModule } from './libro';
|
|
44
41
|
import { LibroOpener } from './libro-opener';
|
|
45
42
|
import { initLibroColorToken } from './libro.color.tokens';
|
|
@@ -49,9 +46,6 @@ import { ManaContainer, initLibroOpensumi, manaContainer } from './mana/index';
|
|
|
49
46
|
import { NotebookDocumentContentProvider } from './notebook-document-content-provider';
|
|
50
47
|
import { NotebookServiceOverride } from './notebook.service';
|
|
51
48
|
import { initTocPanelColorToken } from './toc';
|
|
52
|
-
import { LibroVariableModule } from './variables/libro-variable-module';
|
|
53
|
-
import { VariablePanel } from './variables/variable-panel';
|
|
54
|
-
import { VARIABLE_ID } from './variables/variable-protocol';
|
|
55
49
|
|
|
56
50
|
const LIBRO_COMPONENTS_VIEW_COMMAND = {
|
|
57
51
|
id: 'opensumi-libro',
|
|
@@ -62,7 +56,7 @@ const LayoutWrapper: React.FC<React.PropsWithChildren> = ({ children }) => {
|
|
|
62
56
|
return (
|
|
63
57
|
<ManaComponents.Application
|
|
64
58
|
context={{ container: manaContainer }}
|
|
65
|
-
modules={[ManaAppPreset, LibroJupyterNoEditorModule, LibroTOCModule, LibroOpensumiModule
|
|
59
|
+
modules={[ManaAppPreset, LibroJupyterNoEditorModule, LibroTOCModule, LibroOpensumiModule]}
|
|
66
60
|
renderChildren
|
|
67
61
|
onReady={() => setIsReady(true)}
|
|
68
62
|
>
|
|
@@ -71,15 +65,12 @@ const LayoutWrapper: React.FC<React.PropsWithChildren> = ({ children }) => {
|
|
|
71
65
|
);
|
|
72
66
|
};
|
|
73
67
|
|
|
74
|
-
export const NOTE_BOOK_PANEL_ID = 'notebook-panel';
|
|
75
|
-
|
|
76
68
|
@Domain(
|
|
77
69
|
ClientAppContribution,
|
|
78
70
|
BrowserEditorContribution,
|
|
79
71
|
ClientAppContextContribution,
|
|
80
72
|
CommandContribution,
|
|
81
73
|
OpenerContribution,
|
|
82
|
-
ComponentContribution,
|
|
83
74
|
)
|
|
84
75
|
export class LibroContribution
|
|
85
76
|
extends Disposable
|
|
@@ -88,8 +79,7 @@ export class LibroContribution
|
|
|
88
79
|
BrowserEditorContribution,
|
|
89
80
|
ClientAppContextContribution,
|
|
90
81
|
CommandContribution,
|
|
91
|
-
OpenerContribution
|
|
92
|
-
ComponentContribution
|
|
82
|
+
OpenerContribution
|
|
93
83
|
{
|
|
94
84
|
@Autowired(ManaContainer)
|
|
95
85
|
private readonly manaContainer: Container;
|
|
@@ -125,40 +115,6 @@ export class LibroContribution
|
|
|
125
115
|
initLibroOpensumi(app.injector, manaContainer);
|
|
126
116
|
}
|
|
127
117
|
|
|
128
|
-
registerComponent(registry: ComponentRegistry) {
|
|
129
|
-
const iconClass = this.iconService.fromIcon(
|
|
130
|
-
'',
|
|
131
|
-
{
|
|
132
|
-
dark: 'https://mdn.alipayobjects.com/huamei_rm3rgy/afts/img/A*tFyaRbqux_4AAAAAAAAAAAAADr2GAQ/original',
|
|
133
|
-
light: 'https://mdn.alipayobjects.com/huamei_rm3rgy/afts/img/A*ebL7T4dWefUAAAAAAAAAAAAADr2GAQ/original',
|
|
134
|
-
},
|
|
135
|
-
IconType.Background,
|
|
136
|
-
);
|
|
137
|
-
registry.register(
|
|
138
|
-
'@opensumi/ide-notebook',
|
|
139
|
-
[
|
|
140
|
-
{
|
|
141
|
-
id: KERNEL_PANEL_ID,
|
|
142
|
-
name: localize('notebook.kernel.panel.title'),
|
|
143
|
-
component: KernelPanel,
|
|
144
|
-
priority: 0,
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
id: VARIABLE_ID,
|
|
148
|
-
name: localize('notebook.variable.panel.title'),
|
|
149
|
-
weight: 2,
|
|
150
|
-
priority: 1,
|
|
151
|
-
component: VariablePanel,
|
|
152
|
-
},
|
|
153
|
-
],
|
|
154
|
-
{
|
|
155
|
-
activateKeyBinding: 'ctrlcmd+shift+k',
|
|
156
|
-
containerId: NOTE_BOOK_PANEL_ID,
|
|
157
|
-
iconClass,
|
|
158
|
-
},
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
118
|
registerClientAppContext(Layout: React.FC, injector: Injector): React.FC {
|
|
163
119
|
initLibroColorToken();
|
|
164
120
|
initKernelPanelColorToken();
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
.libro-variable-content {
|
|
2
|
-
height: calc(100% - 40px);
|
|
3
|
-
|
|
4
|
-
.libro-variable-list {
|
|
5
|
-
height: 100%;
|
|
6
|
-
overflow-y: auto;
|
|
7
|
-
|
|
8
|
-
.ant-list-item {
|
|
9
|
-
padding: 4px 12px 0;
|
|
10
|
-
border-bottom: none;
|
|
11
|
-
|
|
12
|
-
&:hover {
|
|
13
|
-
border-radius: 6px;
|
|
14
|
-
background-color: var(--mana-libro-variable-background-hover-color);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.ant-list-item-meta {
|
|
18
|
-
border-bottom: 1px solid var(--mana-libro-variable-border-color);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.ant-list-item-meta-title {
|
|
22
|
-
color: var(--mana-libro-variable-title-color);
|
|
23
|
-
|
|
24
|
-
.libro-variable-title {
|
|
25
|
-
display: flex;
|
|
26
|
-
align-items: center;
|
|
27
|
-
justify-content: space-between;
|
|
28
|
-
|
|
29
|
-
.libro-variable-type-tag {
|
|
30
|
-
font-size: 10px;
|
|
31
|
-
margin-left: 8px;
|
|
32
|
-
color: var(--mana-libro-variable-tag-text-color);
|
|
33
|
-
background-color: var(--mana-libro-variable-tag-background-color);
|
|
34
|
-
border-radius: 4px;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.libro-variable-extra {
|
|
38
|
-
color: var(--mana-libro-variable-icon-color);
|
|
39
|
-
transform: rotate(90deg);
|
|
40
|
-
|
|
41
|
-
:hover {
|
|
42
|
-
color: #1890ff;
|
|
43
|
-
cursor: pointer;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.libro-variable-name {
|
|
49
|
-
color: var(--mana-libro-variable-name-color);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.ant-list-item-meta-description {
|
|
54
|
-
overflow: hidden;
|
|
55
|
-
color: var(--mana-libro-variable-description-color);
|
|
56
|
-
text-overflow: ellipsis;
|
|
57
|
-
white-space: nowrap;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.libro-variable-search {
|
|
63
|
-
display: flex;
|
|
64
|
-
align-items: center;
|
|
65
|
-
padding: 4px 12px 8px;
|
|
66
|
-
|
|
67
|
-
&-input {
|
|
68
|
-
background: var(--mana-libro-variable-search-background-color);
|
|
69
|
-
border: none;
|
|
70
|
-
border-radius: 6px;
|
|
71
|
-
height: 28px;
|
|
72
|
-
|
|
73
|
-
input {
|
|
74
|
-
color: var(--mana-libro-variable-title-color);
|
|
75
|
-
background: transparent;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.ant-input-prefix {
|
|
79
|
-
color: var(--mana-libro-variable-icon-color);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
&-extra {
|
|
84
|
-
margin-left: 8px;
|
|
85
|
-
color: var(--mana-libro-variable-icon-color);
|
|
86
|
-
|
|
87
|
-
:hover {
|
|
88
|
-
color: #1890ff;
|
|
89
|
-
cursor: pointer;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.libro-variable-empty {
|
|
96
|
-
display: flex;
|
|
97
|
-
flex-direction: column;
|
|
98
|
-
align-items: center;
|
|
99
|
-
justify-content: center;
|
|
100
|
-
height: 100%;
|
|
101
|
-
margin: unset !important;
|
|
102
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface LanguageModel {
|
|
2
|
-
initScript: string;
|
|
3
|
-
queryCommand: string;
|
|
4
|
-
matrixQueryCommand: string;
|
|
5
|
-
widgetQueryCommand: string;
|
|
6
|
-
deleteCommand: string;
|
|
7
|
-
}
|
|
8
|
-
export declare abstract class Languages {
|
|
9
|
-
/**
|
|
10
|
-
* Init and query script for supported languages.
|
|
11
|
-
*/
|
|
12
|
-
static py_script: string;
|
|
13
|
-
static r_script: string;
|
|
14
|
-
static scripts: Record<string, LanguageModel>;
|
|
15
|
-
static getScript(lang: string): Promise<LanguageModel>;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=inspector-script.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inspector-script.d.ts","sourceRoot":"","sources":["../../../src/browser/variables/inspector-script.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,8BAAsB,SAAS;IAC7B;;OAEG;IAEH,MAAM,CAAC,SAAS,SAuNhB;IAEA,MAAM,CAAC,QAAQ,SAqEX;IAEJ,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAoC3C;WAEY,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAS9D"}
|
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
export class Languages {
|
|
2
|
-
static getScript(lang) {
|
|
3
|
-
return new Promise((resolve, reject) => {
|
|
4
|
-
if (lang in Languages.scripts) {
|
|
5
|
-
resolve(Languages.scripts[lang]);
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
8
|
-
reject('Language ' + lang + ' not supported yet!');
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Init and query script for supported languages.
|
|
15
|
-
*/
|
|
16
|
-
Languages.py_script = `import json
|
|
17
|
-
import sys
|
|
18
|
-
from importlib import __import__
|
|
19
|
-
from IPython import get_ipython
|
|
20
|
-
from IPython.core.magics.namespace import NamespaceMagics
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
_jupyterlab_variableinspector_nms = NamespaceMagics()
|
|
24
|
-
_jupyterlab_variableinspector_Jupyter = get_ipython()
|
|
25
|
-
_jupyterlab_variableinspector_nms.shell = _jupyterlab_variableinspector_Jupyter.kernel.shell
|
|
26
|
-
|
|
27
|
-
__np = None
|
|
28
|
-
__pd = None
|
|
29
|
-
__pyspark = None
|
|
30
|
-
__tf = None
|
|
31
|
-
__K = None
|
|
32
|
-
__torch = None
|
|
33
|
-
__ipywidgets = None
|
|
34
|
-
__xr = None
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _attempt_import(module):
|
|
38
|
-
try:
|
|
39
|
-
return __import__(module)
|
|
40
|
-
except ImportError:
|
|
41
|
-
return None
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def _check_imported():
|
|
45
|
-
global __np, __pd, __pyspark, __tf, __K, __torch, __ipywidgets, __xr
|
|
46
|
-
|
|
47
|
-
__np = _attempt_import('numpy')
|
|
48
|
-
__pd = _attempt_import('pandas')
|
|
49
|
-
__pyspark = _attempt_import('pyspark')
|
|
50
|
-
__tf = _attempt_import('tensorflow')
|
|
51
|
-
__K = _attempt_import('keras.backend') or _attempt_import('tensorflow.keras.backend')
|
|
52
|
-
__torch = _attempt_import('torch')
|
|
53
|
-
__ipywidgets = _attempt_import('ipywidgets')
|
|
54
|
-
__xr = _attempt_import('xarray')
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def _jupyterlab_variableinspector_getsizeof(x):
|
|
58
|
-
if type(x).__name__ in ['ndarray', 'Series']:
|
|
59
|
-
return x.nbytes
|
|
60
|
-
elif __pyspark and isinstance(x, __pyspark.sql.DataFrame):
|
|
61
|
-
return "?"
|
|
62
|
-
elif __tf and isinstance(x, __tf.Variable):
|
|
63
|
-
return "?"
|
|
64
|
-
elif __torch and isinstance(x, __torch.Tensor):
|
|
65
|
-
return x.element_size() * x.nelement()
|
|
66
|
-
elif __pd and type(x).__name__ == 'DataFrame':
|
|
67
|
-
return x.memory_usage().sum()
|
|
68
|
-
else:
|
|
69
|
-
return sys.getsizeof(x)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def _jupyterlab_variableinspector_getshapeof(x):
|
|
73
|
-
if __pd and isinstance(x, __pd.DataFrame):
|
|
74
|
-
return "%d rows x %d cols" % x.shape
|
|
75
|
-
if __pd and isinstance(x, __pd.Series):
|
|
76
|
-
return "%d rows" % x.shape
|
|
77
|
-
if __np and isinstance(x, __np.ndarray):
|
|
78
|
-
shape = " x ".join([str(i) for i in x.shape])
|
|
79
|
-
return "%s" % shape
|
|
80
|
-
if __pyspark and isinstance(x, __pyspark.sql.DataFrame):
|
|
81
|
-
return "? rows x %d cols" % len(x.columns)
|
|
82
|
-
if __tf and isinstance(x, __tf.Variable):
|
|
83
|
-
shape = " x ".join([str(int(i)) for i in x.shape])
|
|
84
|
-
return "%s" % shape
|
|
85
|
-
if __tf and isinstance(x, __tf.Tensor):
|
|
86
|
-
shape = " x ".join([str(int(i)) for i in x.shape])
|
|
87
|
-
return "%s" % shape
|
|
88
|
-
if __torch and isinstance(x, __torch.Tensor):
|
|
89
|
-
shape = " x ".join([str(int(i)) for i in x.shape])
|
|
90
|
-
return "%s" % shape
|
|
91
|
-
if __xr and isinstance(x, __xr.DataArray):
|
|
92
|
-
shape = " x ".join([str(int(i)) for i in x.shape])
|
|
93
|
-
return "%s" % shape
|
|
94
|
-
if isinstance(x, list):
|
|
95
|
-
return "%s" % len(x)
|
|
96
|
-
if isinstance(x, dict):
|
|
97
|
-
return "%s keys" % len(x)
|
|
98
|
-
return None
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def _jupyterlab_variableinspector_getcontentof(x):
|
|
102
|
-
# returns content in a friendly way for python variables
|
|
103
|
-
# pandas and numpy
|
|
104
|
-
if __pd and isinstance(x, __pd.DataFrame):
|
|
105
|
-
colnames = ', '.join(x.columns.map(str))
|
|
106
|
-
content = "Columns: %s" % colnames
|
|
107
|
-
elif __pd and isinstance(x, __pd.Series):
|
|
108
|
-
content = str(x.values).replace(" ", ", ")[1:-1]
|
|
109
|
-
content = content.replace("\\n", "")
|
|
110
|
-
elif __np and isinstance(x, __np.ndarray):
|
|
111
|
-
content = x.__repr__()
|
|
112
|
-
elif __xr and isinstance(x, __xr.DataArray):
|
|
113
|
-
content = x.values.__repr__()
|
|
114
|
-
else:
|
|
115
|
-
content = str(x)
|
|
116
|
-
|
|
117
|
-
if len(content) > 150:
|
|
118
|
-
return content[:150] + " ..."
|
|
119
|
-
else:
|
|
120
|
-
return content
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def _jupyterlab_variableinspector_is_matrix(x):
|
|
124
|
-
# True if type(x).__name__ in ["DataFrame", "ndarray", "Series"] else False
|
|
125
|
-
if __pd and isinstance(x, __pd.DataFrame):
|
|
126
|
-
return True
|
|
127
|
-
if __pd and isinstance(x, __pd.Series):
|
|
128
|
-
return True
|
|
129
|
-
if __np and isinstance(x, __np.ndarray) and len(x.shape) <= 2:
|
|
130
|
-
return True
|
|
131
|
-
if __pyspark and isinstance(x, __pyspark.sql.DataFrame):
|
|
132
|
-
return True
|
|
133
|
-
if __tf and isinstance(x, __tf.Variable) and len(x.shape) <= 2:
|
|
134
|
-
return True
|
|
135
|
-
if __tf and isinstance(x, __tf.Tensor) and len(x.shape) <= 2:
|
|
136
|
-
return True
|
|
137
|
-
if __torch and isinstance(x, __torch.Tensor) and len(x.shape) <= 2:
|
|
138
|
-
return True
|
|
139
|
-
if __xr and isinstance(x, __xr.DataArray) and len(x.shape) <= 2:
|
|
140
|
-
return True
|
|
141
|
-
if isinstance(x, list):
|
|
142
|
-
return True
|
|
143
|
-
return False
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def _jupyterlab_variableinspector_is_widget(x):
|
|
147
|
-
return __ipywidgets and issubclass(x, __ipywidgets.DOMWidget)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def _jupyterlab_variableinspector_dict_list():
|
|
151
|
-
_check_imported()
|
|
152
|
-
def keep_cond(v):
|
|
153
|
-
try:
|
|
154
|
-
obj = eval(v)
|
|
155
|
-
if isinstance(obj, str):
|
|
156
|
-
return True
|
|
157
|
-
if __tf and isinstance(obj, __tf.Variable):
|
|
158
|
-
return True
|
|
159
|
-
if __pd and __pd is not None and (
|
|
160
|
-
isinstance(obj, __pd.core.frame.DataFrame)
|
|
161
|
-
or isinstance(obj, __pd.core.series.Series)):
|
|
162
|
-
return True
|
|
163
|
-
if __xr and __xr is not None and isinstance(obj, __xr.DataArray):
|
|
164
|
-
return True
|
|
165
|
-
|
|
166
|
-
if v in ['__np', '__pd', '__pyspark', '__tf', '__K', '__torch', '__ipywidgets', '__xr']:
|
|
167
|
-
return obj is not None
|
|
168
|
-
return True
|
|
169
|
-
except:
|
|
170
|
-
return False
|
|
171
|
-
values = _jupyterlab_variableinspector_nms.who_ls()
|
|
172
|
-
vardic = [
|
|
173
|
-
{
|
|
174
|
-
'varName': _v,
|
|
175
|
-
'varType': type(eval(_v)).__name__,
|
|
176
|
-
'varSize': str(_jupyterlab_variableinspector_getsizeof(eval(_v))),
|
|
177
|
-
'varShape': str(_jupyterlab_variableinspector_getshapeof(eval(_v))) if _jupyterlab_variableinspector_getshapeof(eval(_v)) else '',
|
|
178
|
-
'varContent': str(_jupyterlab_variableinspector_getcontentof(eval(_v))),
|
|
179
|
-
'isMatrix': _jupyterlab_variableinspector_is_matrix(eval(_v)),
|
|
180
|
-
'isWidget': _jupyterlab_variableinspector_is_widget(type(eval(_v)))
|
|
181
|
-
}
|
|
182
|
-
for _v in values if keep_cond(_v)
|
|
183
|
-
]
|
|
184
|
-
return json.dumps(vardic, ensure_ascii=False)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
def _jupyterlab_variableinspector_getmatrixcontent(x, max_rows=10000):
|
|
188
|
-
# to do: add something to handle this in the future
|
|
189
|
-
threshold = max_rows
|
|
190
|
-
|
|
191
|
-
if __pd and __pyspark and isinstance(x, __pyspark.sql.DataFrame):
|
|
192
|
-
df = x.limit(threshold).toPandas()
|
|
193
|
-
return _jupyterlab_variableinspector_getmatrixcontent(df.copy())
|
|
194
|
-
elif __np and __pd and type(x).__name__ == "DataFrame":
|
|
195
|
-
if threshold is not None:
|
|
196
|
-
x = x.head(threshold)
|
|
197
|
-
x.columns = x.columns.map(str)
|
|
198
|
-
return x.to_json(orient="table", default_handler=_jupyterlab_variableinspector_default, force_ascii=False)
|
|
199
|
-
elif __np and __pd and type(x).__name__ == "Series":
|
|
200
|
-
if threshold is not None:
|
|
201
|
-
x = x.head(threshold)
|
|
202
|
-
return x.to_json(orient="table", default_handler=_jupyterlab_variableinspector_default, force_ascii=False)
|
|
203
|
-
elif __np and __pd and type(x).__name__ == "ndarray":
|
|
204
|
-
df = __pd.DataFrame(x)
|
|
205
|
-
return _jupyterlab_variableinspector_getmatrixcontent(df)
|
|
206
|
-
elif __tf and (isinstance(x, __tf.Variable) or isinstance(x, __tf.Tensor)):
|
|
207
|
-
df = __K.get_value(x)
|
|
208
|
-
return _jupyterlab_variableinspector_getmatrixcontent(df)
|
|
209
|
-
elif __torch and isinstance(x, __torch.Tensor):
|
|
210
|
-
df = x.cpu().numpy()
|
|
211
|
-
return _jupyterlab_variableinspector_getmatrixcontent(df)
|
|
212
|
-
elif __xr and isinstance(x, __xr.DataArray):
|
|
213
|
-
df = x.to_numpy()
|
|
214
|
-
return _jupyterlab_variableinspector_getmatrixcontent(df)
|
|
215
|
-
elif isinstance(x, list):
|
|
216
|
-
s = __pd.Series(x)
|
|
217
|
-
return _jupyterlab_variableinspector_getmatrixcontent(s)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
def _jupyterlab_variableinspector_displaywidget(widget):
|
|
221
|
-
display(widget)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
def _jupyterlab_variableinspector_default(o):
|
|
225
|
-
if isinstance(o, __np.number): return int(o)
|
|
226
|
-
raise TypeError
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
def _jupyterlab_variableinspector_deletevariable(x):
|
|
230
|
-
exec("del %s" % x, globals())
|
|
231
|
-
`;
|
|
232
|
-
Languages.r_script = `library(repr)
|
|
233
|
-
|
|
234
|
-
.ls.objects = function (pos = 1, pattern, order.by, decreasing = FALSE, head = FALSE,
|
|
235
|
-
n = 5)
|
|
236
|
-
{
|
|
237
|
-
napply <- function(names, fn) sapply(names, function(x) fn(get(x,
|
|
238
|
-
pos = pos)))
|
|
239
|
-
names <- ls(pos = pos, pattern = pattern)
|
|
240
|
-
if (length(names) == 0) {
|
|
241
|
-
return(jsonlite::toJSON(data.frame()))
|
|
242
|
-
}
|
|
243
|
-
obj.class <- napply(names, function(x) as.character(class(x))[1])
|
|
244
|
-
obj.mode <- napply(names, mode)
|
|
245
|
-
obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class)
|
|
246
|
-
obj.size <- napply(names, object.size)
|
|
247
|
-
obj.dim <- t(napply(names, function(x) as.numeric(dim(x))[1:2]))
|
|
248
|
-
obj.content <- rep("NA", length(names))
|
|
249
|
-
has_no_dim <- is.na(obj.dim)[1:length(names)]
|
|
250
|
-
obj.dim[has_no_dim, 1] <- napply(names, length)[has_no_dim]
|
|
251
|
-
vec <- (obj.type != "function")
|
|
252
|
-
obj.content[vec] <- napply(names[vec], function(x) toString(x, width = 154)[1])
|
|
253
|
-
|
|
254
|
-
obj.rownames <- napply(names, rownames)
|
|
255
|
-
has_rownames <- obj.rownames != "NULL"
|
|
256
|
-
obj.rownames <- sapply(obj.rownames[has_rownames], function(x) paste(x,
|
|
257
|
-
collapse=", "))
|
|
258
|
-
obj.rownames.short <- sapply(obj.rownames, function(x) paste(substr(x, 1, 150), "...."))
|
|
259
|
-
obj.rownames <- ifelse(nchar(obj.rownames) > 154, obj.rownames.short, obj.rownames)
|
|
260
|
-
obj.rownames <- sapply(obj.rownames, function(x) paste("Row names: ",x))
|
|
261
|
-
obj.content[has_rownames] <- obj.rownames
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
obj.colnames <- napply(names, colnames)
|
|
265
|
-
has_colnames <- obj.colnames != "NULL"
|
|
266
|
-
obj.colnames <- sapply(obj.colnames[has_colnames], function(x) paste(x,
|
|
267
|
-
collapse = ", "))
|
|
268
|
-
obj.colnames.short <- sapply(obj.colnames, function(x) paste(substr(x,
|
|
269
|
-
1, 150), "...."))
|
|
270
|
-
obj.colnames <- ifelse(nchar(obj.colnames) > 154, obj.colnames.short,
|
|
271
|
-
obj.colnames)
|
|
272
|
-
obj.colnames <- sapply(obj.colnames, function(x) paste("Column names: ",x))
|
|
273
|
-
|
|
274
|
-
obj.content[has_colnames] <- obj.colnames
|
|
275
|
-
|
|
276
|
-
is_function <- (obj.type == "function")
|
|
277
|
-
obj.content[is_function] <- napply(names[is_function], function(x) paste(strsplit(repr_text(x),")")[[1]][1],")",sep=""))
|
|
278
|
-
obj.content <- unlist(obj.content, use.names = FALSE)
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
out <- data.frame(obj.type, obj.size, obj.dim)
|
|
282
|
-
names(out) <- c("varType", "varSize", "Rows", "Columns")
|
|
283
|
-
out$varShape <- paste(out$Rows, " x ", out$Columns)
|
|
284
|
-
out$varContent <- obj.content
|
|
285
|
-
out$isMatrix <- FALSE
|
|
286
|
-
out$varName <- row.names(out)
|
|
287
|
-
out <- out[, !(names(out) %in% c("Rows", "Columns"))]
|
|
288
|
-
rownames(out) <- NULL
|
|
289
|
-
print(out)
|
|
290
|
-
if (!missing(order.by))
|
|
291
|
-
out <- out[order(out[[order.by]], decreasing = decreasing),
|
|
292
|
-
]
|
|
293
|
-
if (head)
|
|
294
|
-
out <- head(out, n)
|
|
295
|
-
jsonlite::toJSON(out)
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
.deleteVariable <- function(x) {
|
|
299
|
-
remove(list=c(x), envir=.GlobalEnv)
|
|
300
|
-
}
|
|
301
|
-
`;
|
|
302
|
-
Languages.scripts = {
|
|
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
|
-
//# sourceMappingURL=inspector-script.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inspector-script.js","sourceRoot":"","sources":["../../../src/browser/variables/inspector-script.ts"],"names":[],"mappings":"AAQA,MAAM,OAAgB,SAAS;IA2UtB,MAAM,CAAC,SAAS,CAAC,IAAY;QAClC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,IAAI,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;gBAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YACnC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,WAAW,GAAG,IAAI,GAAG,qBAAqB,CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;;AAlVD;;GAEG;AAEI,mBAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuNpB,CAAC;AAEO,kBAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqEf,CAAC;AAEG,iBAAO,GAAkC;IAC9C,OAAO,EAAE;QACP,UAAU,EAAE,SAAS,CAAC,SAAS;QAC/B,YAAY,EAAE,2CAA2C;QACzD,kBAAkB,EAAE,gDAAgD;QACpE,kBAAkB,EAAE,6CAA6C;QACjE,aAAa,EAAE,8CAA8C;KAC9D;IACD,OAAO,EAAE;QACP,UAAU,EAAE,SAAS,CAAC,SAAS;QAC/B,YAAY,EAAE,2CAA2C;QACzD,kBAAkB,EAAE,gDAAgD;QACpE,kBAAkB,EAAE,6CAA6C;QACjE,aAAa,EAAE,8CAA8C;KAC9D;IACD,MAAM,EAAE;QACN,UAAU,EAAE,SAAS,CAAC,SAAS;QAC/B,YAAY,EAAE,2CAA2C;QACzD,kBAAkB,EAAE,gDAAgD;QACpE,kBAAkB,EAAE,6CAA6C;QACjE,aAAa,EAAE,8CAA8C;KAC9D;IACD,CAAC,EAAE;QACD,UAAU,EAAE,SAAS,CAAC,QAAQ;QAC9B,YAAY,EAAE,eAAe;QAC7B,kBAAkB,EAAE,aAAa;QACjC,kBAAkB,EAAE,MAAM;QAC1B,aAAa,EAAE,iBAAiB;KACjC;IACD,KAAK,EAAE;QACL,UAAU,EAAE,mEAAmE;QAC/E,YAAY,EAAE,uEAAuE;QACrF,kBAAkB,EAAE,EAAE,EAAE,OAAO;QAC/B,kBAAkB,EAAE,EAAE,EAAE,OAAO;QAC/B,aAAa,EAAE,EAAE,EAAE,OAAO;KAC3B;CACF,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ColorContribution } from '@difizen/mana-app';
|
|
2
|
-
import type { ColorRegistry } from '@difizen/mana-app';
|
|
3
|
-
export declare class LibroVariableColorRegistry implements ColorContribution {
|
|
4
|
-
registerColors(colors: ColorRegistry): void;
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=libro-variable-color-registry.d.ts.map
|