@jupyterlab/debugger 4.3.0-alpha.2 → 4.3.0-beta.1
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/panels/variables/index.js +2 -2
- package/lib/panels/variables/index.js.map +1 -1
- package/lib/panels/variables/tree.d.ts +0 -1
- package/lib/panels/variables/tree.js +92 -126
- package/lib/panels/variables/tree.js.map +1 -1
- package/package.json +19 -19
- package/src/panels/variables/index.ts +2 -2
- package/src/panels/variables/tree.tsx +160 -262
- package/style/variables.css +8 -73
|
@@ -57,13 +57,13 @@ export class Variables extends PanelWithToolbar {
|
|
|
57
57
|
};
|
|
58
58
|
const treeViewButton = new ToolbarButton({
|
|
59
59
|
icon: treeViewIcon,
|
|
60
|
-
className: 'jp-TreeView',
|
|
60
|
+
className: 'jp-TreeView-Button',
|
|
61
61
|
onClick: onViewChange,
|
|
62
62
|
tooltip: trans.__('Tree View')
|
|
63
63
|
});
|
|
64
64
|
const tableViewButton = new ToolbarButton({
|
|
65
65
|
icon: tableRowsIcon,
|
|
66
|
-
className: 'jp-TableView',
|
|
66
|
+
className: 'jp-TableView-Button',
|
|
67
67
|
onClick: onViewChange,
|
|
68
68
|
tooltip: trans.__('Table View')
|
|
69
69
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/panels/variables/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAAe,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,YAAY,EACb,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C;;GAEG;AACH,MAAM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CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;QAC3D,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC;IAC/C,CAAC;CAIF;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAA6B,EAAmB,EAAE;;IAC5E,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC;IACjC,QAAQ,IAAI,EAAE;QACZ,KAAK,KAAK;YACR,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7B,KAAK,OAAO;YACV,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;QAC3B,KAAK,MAAM;YACT,OAAO,KAAK,CAAC;QACf,KAAK,KAAK;YACR,IAAI,MAAA,MAAA,QAAQ,CAAC,gBAAgB,0CAAE,UAAU,0CAAE,QAAQ,CAAC,WAAW,CAAC,EAAE;gBAChE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;aACzC;iBAAM;gBACL,OAAO,KAAK,CAAC;aACd;QACH;YACE,OAAO,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,KAAK,CAAC;KACxB;AACH,CAAC,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
import { nullTranslator } from '@jupyterlab/translation';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { getTreeItemElement, ReactWidget, searchIcon } from '@jupyterlab/ui-components';
|
|
5
|
+
import { Button, TreeItem, TreeView } from '@jupyter/react-components';
|
|
6
6
|
import { ArrayExt } from '@lumino/algorithm';
|
|
7
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
7
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
8
|
import { convertType } from '.';
|
|
9
9
|
import { Debugger } from '../../debugger';
|
|
10
|
-
const BUTTONS_CLASS = 'jp-DebuggerVariables-buttons';
|
|
11
10
|
/**
|
|
12
11
|
* The body for tree of variables.
|
|
13
12
|
*/
|
|
@@ -25,7 +24,6 @@ export class VariablesBodyTree extends ReactWidget {
|
|
|
25
24
|
this._commands = options.commands;
|
|
26
25
|
this._service = options.service;
|
|
27
26
|
this._translator = options.translator;
|
|
28
|
-
this._hoverChanged = new Signal(this);
|
|
29
27
|
const model = (this.model = options.model);
|
|
30
28
|
model.changed.connect(this._updateScopes, this);
|
|
31
29
|
this.addClass('jp-DebuggerVariables-body');
|
|
@@ -39,7 +37,6 @@ export class VariablesBodyTree extends ReactWidget {
|
|
|
39
37
|
const handleSelectVariable = (variable) => {
|
|
40
38
|
this.model.selectedVariable = variable;
|
|
41
39
|
};
|
|
42
|
-
const collapserIcon = (React.createElement(caretDownEmptyIcon.react, { stylesheet: "menuItem", tag: "span" }));
|
|
43
40
|
if ((scope === null || scope === void 0 ? void 0 : scope.name) !== 'Globals') {
|
|
44
41
|
this.addClass('jp-debuggerVariables-local');
|
|
45
42
|
}
|
|
@@ -47,10 +44,8 @@ export class VariablesBodyTree extends ReactWidget {
|
|
|
47
44
|
this.removeClass('jp-debuggerVariables-local');
|
|
48
45
|
}
|
|
49
46
|
return scope ? (React.createElement(React.Fragment, null,
|
|
50
|
-
React.createElement(
|
|
51
|
-
|
|
52
|
-
}, collapserIcon: collapserIcon }),
|
|
53
|
-
React.createElement(TreeButtons, { commands: this._commands, service: this._service, hoverChanged: this._hoverChanged, handleSelectVariable: handleSelectVariable }))) : (React.createElement("div", null));
|
|
47
|
+
React.createElement(TreeView, { className: "jp-TreeView" },
|
|
48
|
+
React.createElement(VariablesBranch, { key: scope.name, commands: this._commands, service: this._service, data: scope.variables, filter: this._filter, translator: this._translator, handleSelectVariable: handleSelectVariable })))) : (React.createElement("div", null));
|
|
54
49
|
}
|
|
55
50
|
/**
|
|
56
51
|
* Set the variable filter list.
|
|
@@ -79,91 +74,6 @@ export class VariablesBodyTree extends ReactWidget {
|
|
|
79
74
|
this.update();
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
|
-
/**
|
|
83
|
-
* The singleton buttons bar shown by the variables.
|
|
84
|
-
*/
|
|
85
|
-
const TreeButtons = (props) => {
|
|
86
|
-
var _a;
|
|
87
|
-
const { commands, service, translator, handleSelectVariable } = props;
|
|
88
|
-
const trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyterlab');
|
|
89
|
-
const [buttonsTop, setButtonsTop] = useState(0);
|
|
90
|
-
const [variable, setVariable] = useState(null);
|
|
91
|
-
let stateRefreshLock = 0;
|
|
92
|
-
// Empty dependency array is to only register once per lifetime.
|
|
93
|
-
const handleHover = useCallback((_, data) => {
|
|
94
|
-
const current = ++stateRefreshLock;
|
|
95
|
-
if (!data.variable) {
|
|
96
|
-
// Handle mouse leave.
|
|
97
|
-
if (current !== stateRefreshLock) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const target = data.target;
|
|
101
|
-
if (target &&
|
|
102
|
-
// Note: Element, not HTMLElement to permit entering <svg> icon.
|
|
103
|
-
target instanceof Element &&
|
|
104
|
-
target.closest(`.${BUTTONS_CLASS}`)) {
|
|
105
|
-
// Allow to enter the buttons.
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
setVariable(null);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
// Handle mouse over.
|
|
112
|
-
setVariable(data.variable);
|
|
113
|
-
requestAnimationFrame(() => {
|
|
114
|
-
if (current !== stateRefreshLock || !data.target) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
setButtonsTop(data.target.offsetTop);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}, []);
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
props.hoverChanged.connect(handleHover);
|
|
123
|
-
return () => {
|
|
124
|
-
props.hoverChanged.disconnect(handleHover);
|
|
125
|
-
};
|
|
126
|
-
}, [handleHover]);
|
|
127
|
-
return (React.createElement("div", { className: BUTTONS_CLASS, style:
|
|
128
|
-
// Positioning and hiding is implemented using compositor-only
|
|
129
|
-
// properties (transform and opacity) for performance.
|
|
130
|
-
{
|
|
131
|
-
transform: `translateY(${buttonsTop}px)`,
|
|
132
|
-
opacity: !variable ||
|
|
133
|
-
// Do not show buttons display for special entries, defined in debugpy:
|
|
134
|
-
// https://github.com/microsoft/debugpy/blob/cf0d684566edc339545b161da7c3dfc48af7c7d5/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_utils.py#L359
|
|
135
|
-
[
|
|
136
|
-
'special variables',
|
|
137
|
-
'protected variables',
|
|
138
|
-
'function variables',
|
|
139
|
-
'class variables'
|
|
140
|
-
].includes(variable.name)
|
|
141
|
-
? 0
|
|
142
|
-
: 1
|
|
143
|
-
} },
|
|
144
|
-
React.createElement("button", { className: "jp-DebuggerVariables-renderVariable", disabled: !variable ||
|
|
145
|
-
!service.model.hasRichVariableRendering ||
|
|
146
|
-
!commands.isEnabled(Debugger.CommandIDs.renderMimeVariable, {
|
|
147
|
-
name: variable.name,
|
|
148
|
-
frameID: (_a = service.model.callstack.frame) === null || _a === void 0 ? void 0 : _a.id
|
|
149
|
-
}), onClick: e => {
|
|
150
|
-
var _a;
|
|
151
|
-
if (!variable || !handleSelectVariable) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
e.stopPropagation();
|
|
155
|
-
handleSelectVariable(variable);
|
|
156
|
-
commands
|
|
157
|
-
.execute(Debugger.CommandIDs.renderMimeVariable, {
|
|
158
|
-
name: variable.name,
|
|
159
|
-
frameID: (_a = service.model.callstack.frame) === null || _a === void 0 ? void 0 : _a.id
|
|
160
|
-
})
|
|
161
|
-
.catch(reason => {
|
|
162
|
-
console.error(`Failed to render variable ${variable === null || variable === void 0 ? void 0 : variable.name}`, reason);
|
|
163
|
-
});
|
|
164
|
-
}, title: trans.__('Render variable: %1', variable === null || variable === void 0 ? void 0 : variable.name) },
|
|
165
|
-
React.createElement(searchIcon.react, { stylesheet: "menuItem", tag: "span" }))));
|
|
166
|
-
};
|
|
167
77
|
/**
|
|
168
78
|
* A React component to display a list of variables.
|
|
169
79
|
*
|
|
@@ -173,16 +83,16 @@ const TreeButtons = (props) => {
|
|
|
173
83
|
* @param props.filter Optional variable filter list.
|
|
174
84
|
*/
|
|
175
85
|
const VariablesBranch = (props) => {
|
|
176
|
-
const { commands, data, service, filter, translator, handleSelectVariable
|
|
86
|
+
const { commands, data, service, filter, translator, handleSelectVariable } = props;
|
|
177
87
|
const [variables, setVariables] = useState(data);
|
|
178
88
|
useEffect(() => {
|
|
179
89
|
setVariables(data);
|
|
180
90
|
}, [data]);
|
|
181
|
-
return (React.createElement(
|
|
91
|
+
return (React.createElement(React.Fragment, null, variables
|
|
182
92
|
.filter(variable => !(filter || new Set()).has(variable.evaluateName || ''))
|
|
183
93
|
.map(variable => {
|
|
184
94
|
const key = `${variable.name}-${variable.evaluateName}-${variable.type}-${variable.value}-${variable.variablesReference}`;
|
|
185
|
-
return (React.createElement(VariableComponent, { key: key, commands: commands, data: variable, service: service, filter: filter, translator: translator, onSelect: handleSelectVariable
|
|
95
|
+
return (React.createElement(VariableComponent, { key: key, commands: commands, data: variable, service: service, filter: filter, translator: translator, onSelect: handleSelectVariable }));
|
|
186
96
|
})));
|
|
187
97
|
};
|
|
188
98
|
function _prepareDetail(variable) {
|
|
@@ -207,44 +117,100 @@ function _prepareDetail(variable) {
|
|
|
207
117
|
* @param props.filter Optional variable filter list.
|
|
208
118
|
*/
|
|
209
119
|
const VariableComponent = (props) => {
|
|
210
|
-
|
|
120
|
+
var _a, _b;
|
|
121
|
+
const { commands, data, service, filter, translator, onSelect } = props;
|
|
211
122
|
const [variable] = useState(data);
|
|
212
|
-
const [
|
|
213
|
-
const [
|
|
123
|
+
const [showDetailsButton, setShowDetailsButton] = useState(false);
|
|
124
|
+
const [expanded, setExpanded] = useState(false);
|
|
125
|
+
const [variables, setVariables] = useState(null);
|
|
126
|
+
const trans = useMemo(() => (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyterlab'), [translator]);
|
|
214
127
|
const onSelection = onSelect !== null && onSelect !== void 0 ? onSelect : (() => void 0);
|
|
215
|
-
const expandable = variable.variablesReference !== 0 || variable.type === 'function';
|
|
216
|
-
const
|
|
128
|
+
const expandable = useMemo(() => variable.variablesReference !== 0 || variable.type === 'function', [variable.variablesReference, variable.type]);
|
|
129
|
+
const details = useMemo(() => _prepareDetail(variable), [variable]);
|
|
130
|
+
const hasMimeRenderer = useMemo(() => ![
|
|
131
|
+
'special variables',
|
|
132
|
+
'protected variables',
|
|
133
|
+
'function variables',
|
|
134
|
+
'class variables'
|
|
135
|
+
].includes(variable.name), [variable.name]);
|
|
136
|
+
const disableMimeRenderer = useMemo(() => {
|
|
137
|
+
var _a;
|
|
138
|
+
return !service.model.hasRichVariableRendering ||
|
|
139
|
+
!commands.isEnabled(Debugger.CommandIDs.renderMimeVariable, {
|
|
140
|
+
name: variable.name,
|
|
141
|
+
frameID: (_a = service.model.callstack.frame) === null || _a === void 0 ? void 0 : _a.id
|
|
142
|
+
});
|
|
143
|
+
}, [
|
|
144
|
+
service.model.hasRichVariableRendering,
|
|
145
|
+
variable.name,
|
|
146
|
+
(_a = service.model.callstack.frame) === null || _a === void 0 ? void 0 : _a.id
|
|
147
|
+
]);
|
|
148
|
+
const fetchChildren = useCallback(async () => {
|
|
149
|
+
if (expandable && !variables) {
|
|
150
|
+
setVariables(await service.inspectVariable(variable.variablesReference));
|
|
151
|
+
}
|
|
152
|
+
}, [expandable, service, variable.variablesReference, variables]);
|
|
153
|
+
const onVariableClicked = useCallback(async (event) => {
|
|
154
|
+
const item = getTreeItemElement(event.target);
|
|
155
|
+
if (event.currentTarget !== item) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
217
158
|
if (!expandable) {
|
|
218
159
|
return;
|
|
219
160
|
}
|
|
220
|
-
e.stopPropagation();
|
|
221
|
-
const variables = await service.inspectVariable(variable.variablesReference);
|
|
222
161
|
setExpanded(!expanded);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
e.stopPropagation();
|
|
162
|
+
}, [expandable, expanded]);
|
|
163
|
+
const onSelectChange = useCallback((event) => {
|
|
164
|
+
if (event.currentTarget === event.detail && event.detail.selected) {
|
|
227
165
|
onSelection(variable);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
166
|
+
}
|
|
167
|
+
}, [variable]);
|
|
168
|
+
const renderVariable = useCallback(() => {
|
|
169
|
+
var _a;
|
|
170
|
+
commands
|
|
171
|
+
.execute(Debugger.CommandIDs.renderMimeVariable, {
|
|
172
|
+
name: variable.name,
|
|
173
|
+
frameID: (_a = service.model.callstack.frame) === null || _a === void 0 ? void 0 : _a.id
|
|
174
|
+
})
|
|
175
|
+
.catch(reason => {
|
|
176
|
+
console.error(`Failed to render variable ${variable === null || variable === void 0 ? void 0 : variable.name}`, reason);
|
|
177
|
+
});
|
|
178
|
+
}, [commands, variable.name, (_b = service.model.callstack.frame) === null || _b === void 0 ? void 0 : _b.id]);
|
|
179
|
+
const onContextMenu = useCallback((event) => {
|
|
180
|
+
const item = getTreeItemElement(event.target);
|
|
181
|
+
if (event.currentTarget !== item) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
onSelection(variable);
|
|
185
|
+
}, [variable]);
|
|
186
|
+
return (React.createElement(TreeItem, { className: "jp-TreeItem nested", expanded: expanded, onSelect: onSelectChange, onExpand: fetchChildren, onClick: (e) => onVariableClicked(e), onContextMenu: onContextMenu, onKeyDown: event => {
|
|
187
|
+
if (event.key == 'Enter') {
|
|
188
|
+
if (hasMimeRenderer && showDetailsButton) {
|
|
189
|
+
onSelection(variable);
|
|
190
|
+
renderVariable();
|
|
191
|
+
}
|
|
232
192
|
}
|
|
193
|
+
}, onFocus: event => {
|
|
194
|
+
setShowDetailsButton(!event.defaultPrevented);
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
}, onBlur: event => {
|
|
197
|
+
setShowDetailsButton(false);
|
|
198
|
+
}, onMouseOver: (event) => {
|
|
199
|
+
setShowDetailsButton(!event.defaultPrevented);
|
|
200
|
+
event.preventDefault();
|
|
233
201
|
}, onMouseLeave: (event) => {
|
|
234
|
-
|
|
235
|
-
onHoverChanged({
|
|
236
|
-
target: event.relatedTarget,
|
|
237
|
-
variable: null
|
|
238
|
-
});
|
|
239
|
-
event.stopPropagation();
|
|
240
|
-
}
|
|
202
|
+
setShowDetailsButton(false);
|
|
241
203
|
} },
|
|
242
|
-
React.createElement("span", { className: 'jp-DebuggerVariables-collapser' +
|
|
243
|
-
(expanded ? ' jp-mod-expanded' : '') },
|
|
244
|
-
// note: using React.cloneElement due to high typestyle cost
|
|
245
|
-
expandable ? React.cloneElement(collapserIcon) : null),
|
|
246
204
|
React.createElement("span", { className: "jp-DebuggerVariables-name" }, variable.name),
|
|
247
|
-
React.createElement("span", { className: "jp-DebuggerVariables-detail" },
|
|
248
|
-
|
|
205
|
+
details && (React.createElement("span", { className: "jp-DebuggerVariables-detail" }, details)),
|
|
206
|
+
hasMimeRenderer && showDetailsButton && (React.createElement(Button, { className: "jp-DebuggerVariables-renderVariable", appearance: "stealth", slot: "end", disabled: disableMimeRenderer, onClick: e => {
|
|
207
|
+
e.stopPropagation();
|
|
208
|
+
renderVariable();
|
|
209
|
+
}, title: trans.__('Render variable: %1', variable === null || variable === void 0 ? void 0 : variable.name) },
|
|
210
|
+
React.createElement(searchIcon.react, { tag: null }))),
|
|
211
|
+
variables ? (React.createElement(VariablesBranch, { key: variable.name, commands: commands, data: variables, service: service, filter: filter, translator: translator, handleSelectVariable: onSelect })) : (
|
|
212
|
+
/* Trick to ensure collapse button is displayed
|
|
213
|
+
when variables are not loaded yet */
|
|
214
|
+
expandable && React.createElement(TreeItem, null))));
|
|
249
215
|
};
|
|
250
216
|
//# sourceMappingURL=tree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/panels/variables/tree.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAe,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/panels/variables/tree.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAe,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,UAAU,EACX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAM7C,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAM1C;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD;;;;OAIG;IACH,YAAY,OAAmC;QAC7C,KAAK,EAAE,CAAC;QA8EF,WAAM,GAAG,EAAE,CAAC;QACZ,YAAO,GAAuB,EAAE,CAAC;QACjC,YAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QA/ElC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;QAEtC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,K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3.0-
|
|
3
|
+
"version": "4.3.0-beta.1",
|
|
4
4
|
"description": "JupyterLab - Debugger Extension",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -50,23 +50,23 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@codemirror/state": "^6.4.1",
|
|
52
52
|
"@codemirror/view": "^6.26.3",
|
|
53
|
-
"@jupyter/react-components": "^0.16.
|
|
54
|
-
"@jupyter/ydoc": "^
|
|
55
|
-
"@jupyterlab/application": "^4.3.0-
|
|
56
|
-
"@jupyterlab/apputils": "^4.4.0-
|
|
57
|
-
"@jupyterlab/cells": "^4.3.0-
|
|
58
|
-
"@jupyterlab/codeeditor": "^4.3.0-
|
|
59
|
-
"@jupyterlab/codemirror": "^4.3.0-
|
|
60
|
-
"@jupyterlab/console": "^4.3.0-
|
|
61
|
-
"@jupyterlab/coreutils": "^6.3.0-
|
|
62
|
-
"@jupyterlab/docregistry": "^4.3.0-
|
|
63
|
-
"@jupyterlab/fileeditor": "^4.3.0-
|
|
64
|
-
"@jupyterlab/notebook": "^4.3.0-
|
|
65
|
-
"@jupyterlab/observables": "^5.3.0-
|
|
66
|
-
"@jupyterlab/rendermime": "^4.3.0-
|
|
67
|
-
"@jupyterlab/services": "^7.3.0-
|
|
68
|
-
"@jupyterlab/translation": "^4.3.0-
|
|
69
|
-
"@jupyterlab/ui-components": "^4.3.0-
|
|
53
|
+
"@jupyter/react-components": "^0.16.6",
|
|
54
|
+
"@jupyter/ydoc": "^3.0.0-a5",
|
|
55
|
+
"@jupyterlab/application": "^4.3.0-beta.1",
|
|
56
|
+
"@jupyterlab/apputils": "^4.4.0-beta.1",
|
|
57
|
+
"@jupyterlab/cells": "^4.3.0-beta.1",
|
|
58
|
+
"@jupyterlab/codeeditor": "^4.3.0-beta.1",
|
|
59
|
+
"@jupyterlab/codemirror": "^4.3.0-beta.1",
|
|
60
|
+
"@jupyterlab/console": "^4.3.0-beta.1",
|
|
61
|
+
"@jupyterlab/coreutils": "^6.3.0-beta.1",
|
|
62
|
+
"@jupyterlab/docregistry": "^4.3.0-beta.1",
|
|
63
|
+
"@jupyterlab/fileeditor": "^4.3.0-beta.1",
|
|
64
|
+
"@jupyterlab/notebook": "^4.3.0-beta.1",
|
|
65
|
+
"@jupyterlab/observables": "^5.3.0-beta.1",
|
|
66
|
+
"@jupyterlab/rendermime": "^4.3.0-beta.1",
|
|
67
|
+
"@jupyterlab/services": "^7.3.0-beta.1",
|
|
68
|
+
"@jupyterlab/translation": "^4.3.0-beta.1",
|
|
69
|
+
"@jupyterlab/ui-components": "^4.3.0-beta.1",
|
|
70
70
|
"@lumino/algorithm": "^2.0.1",
|
|
71
71
|
"@lumino/commands": "^2.3.0",
|
|
72
72
|
"@lumino/coreutils": "^2.1.2",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"react": "^18.2.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@jupyterlab/testing": "^4.3.0-
|
|
83
|
+
"@jupyterlab/testing": "^4.3.0-beta.1",
|
|
84
84
|
"@types/jest": "^29.2.0",
|
|
85
85
|
"jest": "^29.2.0",
|
|
86
86
|
"jest-canvas-mock": "^2.5.2",
|
|
@@ -73,14 +73,14 @@ export class Variables extends PanelWithToolbar {
|
|
|
73
73
|
|
|
74
74
|
const treeViewButton = new ToolbarButton({
|
|
75
75
|
icon: treeViewIcon,
|
|
76
|
-
className: 'jp-TreeView',
|
|
76
|
+
className: 'jp-TreeView-Button',
|
|
77
77
|
onClick: onViewChange,
|
|
78
78
|
tooltip: trans.__('Tree View')
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
const tableViewButton = new ToolbarButton({
|
|
82
82
|
icon: tableRowsIcon,
|
|
83
|
-
className: 'jp-TableView',
|
|
83
|
+
className: 'jp-TableView-Button',
|
|
84
84
|
onClick: onViewChange,
|
|
85
85
|
tooltip: trans.__('Table View')
|
|
86
86
|
});
|
|
@@ -3,21 +3,21 @@
|
|
|
3
3
|
|
|
4
4
|
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
5
5
|
|
|
6
|
-
import { ISignal, Signal } from '@lumino/signaling';
|
|
7
|
-
|
|
8
6
|
import {
|
|
9
|
-
|
|
7
|
+
getTreeItemElement,
|
|
10
8
|
ReactWidget,
|
|
11
9
|
searchIcon
|
|
12
10
|
} from '@jupyterlab/ui-components';
|
|
13
11
|
|
|
12
|
+
import { Button, TreeItem, TreeView } from '@jupyter/react-components';
|
|
13
|
+
|
|
14
14
|
import { ArrayExt } from '@lumino/algorithm';
|
|
15
15
|
|
|
16
16
|
import { CommandRegistry } from '@lumino/commands';
|
|
17
17
|
|
|
18
18
|
import { DebugProtocol } from '@vscode/debugprotocol';
|
|
19
19
|
|
|
20
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
20
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
21
21
|
|
|
22
22
|
import { convertType } from '.';
|
|
23
23
|
|
|
@@ -27,8 +27,6 @@ import { IDebugger } from '../../tokens';
|
|
|
27
27
|
|
|
28
28
|
import { VariablesModel } from './model';
|
|
29
29
|
|
|
30
|
-
const BUTTONS_CLASS = 'jp-DebuggerVariables-buttons';
|
|
31
|
-
|
|
32
30
|
/**
|
|
33
31
|
* The body for tree of variables.
|
|
34
32
|
*/
|
|
@@ -43,7 +41,6 @@ export class VariablesBodyTree extends ReactWidget {
|
|
|
43
41
|
this._commands = options.commands;
|
|
44
42
|
this._service = options.service;
|
|
45
43
|
this._translator = options.translator;
|
|
46
|
-
this._hoverChanged = new Signal(this);
|
|
47
44
|
|
|
48
45
|
const model = (this.model = options.model);
|
|
49
46
|
model.changed.connect(this._updateScopes, this);
|
|
@@ -61,9 +58,6 @@ export class VariablesBodyTree extends ReactWidget {
|
|
|
61
58
|
const handleSelectVariable = (variable: IDebugger.IVariable) => {
|
|
62
59
|
this.model.selectedVariable = variable;
|
|
63
60
|
};
|
|
64
|
-
const collapserIcon = (
|
|
65
|
-
<caretDownEmptyIcon.react stylesheet="menuItem" tag="span" />
|
|
66
|
-
);
|
|
67
61
|
|
|
68
62
|
if (scope?.name !== 'Globals') {
|
|
69
63
|
this.addClass('jp-debuggerVariables-local');
|
|
@@ -73,25 +67,17 @@ export class VariablesBodyTree extends ReactWidget {
|
|
|
73
67
|
|
|
74
68
|
return scope ? (
|
|
75
69
|
<>
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
collapserIcon={collapserIcon}
|
|
88
|
-
/>
|
|
89
|
-
<TreeButtons
|
|
90
|
-
commands={this._commands}
|
|
91
|
-
service={this._service}
|
|
92
|
-
hoverChanged={this._hoverChanged}
|
|
93
|
-
handleSelectVariable={handleSelectVariable}
|
|
94
|
-
/>
|
|
70
|
+
<TreeView className="jp-TreeView">
|
|
71
|
+
<VariablesBranch
|
|
72
|
+
key={scope.name}
|
|
73
|
+
commands={this._commands}
|
|
74
|
+
service={this._service}
|
|
75
|
+
data={scope.variables}
|
|
76
|
+
filter={this._filter}
|
|
77
|
+
translator={this._translator}
|
|
78
|
+
handleSelectVariable={handleSelectVariable}
|
|
79
|
+
/>
|
|
80
|
+
</TreeView>
|
|
95
81
|
</>
|
|
96
82
|
) : (
|
|
97
83
|
<div></div>
|
|
@@ -134,152 +120,8 @@ export class VariablesBodyTree extends ReactWidget {
|
|
|
134
120
|
private _filter = new Set<string>();
|
|
135
121
|
private _service: IDebugger;
|
|
136
122
|
private _translator: ITranslator | undefined;
|
|
137
|
-
private _hoverChanged: Signal<VariablesBodyTree, IHoverData>;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
interface IHoverData {
|
|
141
|
-
/**
|
|
142
|
-
* The mouse target.
|
|
143
|
-
*/
|
|
144
|
-
target: (EventTarget & HTMLElement) | null;
|
|
145
|
-
/**
|
|
146
|
-
* The variable corresponding to node under cursor.
|
|
147
|
-
*/
|
|
148
|
-
variable: IDebugger.IVariable | null;
|
|
149
123
|
}
|
|
150
124
|
|
|
151
|
-
interface ITreeButtonsProps {
|
|
152
|
-
/**
|
|
153
|
-
* The commands registry.
|
|
154
|
-
*/
|
|
155
|
-
commands: CommandRegistry;
|
|
156
|
-
/**
|
|
157
|
-
* The debugger service.
|
|
158
|
-
*/
|
|
159
|
-
service: IDebugger;
|
|
160
|
-
/**
|
|
161
|
-
* The application language translator
|
|
162
|
-
*/
|
|
163
|
-
translator?: ITranslator;
|
|
164
|
-
/**
|
|
165
|
-
* Callback on variable selection
|
|
166
|
-
*/
|
|
167
|
-
handleSelectVariable: (variable: IDebugger.IVariable) => void;
|
|
168
|
-
/**
|
|
169
|
-
* Signal to be emitted on mouse over event.
|
|
170
|
-
*/
|
|
171
|
-
hoverChanged: ISignal<VariablesBodyTree, IHoverData>;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* The singleton buttons bar shown by the variables.
|
|
176
|
-
*/
|
|
177
|
-
const TreeButtons = (props: ITreeButtonsProps): JSX.Element => {
|
|
178
|
-
const { commands, service, translator, handleSelectVariable } = props;
|
|
179
|
-
const trans = (translator ?? nullTranslator).load('jupyterlab');
|
|
180
|
-
|
|
181
|
-
const [buttonsTop, setButtonsTop] = useState<number>(0);
|
|
182
|
-
const [variable, setVariable] = useState<IDebugger.IVariable | null>(null);
|
|
183
|
-
|
|
184
|
-
let stateRefreshLock = 0;
|
|
185
|
-
|
|
186
|
-
// Empty dependency array is to only register once per lifetime.
|
|
187
|
-
const handleHover = useCallback((_: VariablesBodyTree, data: IHoverData) => {
|
|
188
|
-
const current = ++stateRefreshLock;
|
|
189
|
-
if (!data.variable) {
|
|
190
|
-
// Handle mouse leave.
|
|
191
|
-
if (current !== stateRefreshLock) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const target = data.target;
|
|
195
|
-
if (
|
|
196
|
-
target &&
|
|
197
|
-
// Note: Element, not HTMLElement to permit entering <svg> icon.
|
|
198
|
-
target instanceof Element &&
|
|
199
|
-
target.closest(`.${BUTTONS_CLASS}`)
|
|
200
|
-
) {
|
|
201
|
-
// Allow to enter the buttons.
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
setVariable(null);
|
|
205
|
-
} else {
|
|
206
|
-
// Handle mouse over.
|
|
207
|
-
setVariable(data.variable);
|
|
208
|
-
requestAnimationFrame(() => {
|
|
209
|
-
if (current !== stateRefreshLock || !data.target) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
setButtonsTop(data.target.offsetTop);
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}, []);
|
|
216
|
-
|
|
217
|
-
useEffect(() => {
|
|
218
|
-
props.hoverChanged.connect(handleHover);
|
|
219
|
-
return () => {
|
|
220
|
-
props.hoverChanged.disconnect(handleHover);
|
|
221
|
-
};
|
|
222
|
-
}, [handleHover]);
|
|
223
|
-
|
|
224
|
-
return (
|
|
225
|
-
<div
|
|
226
|
-
className={BUTTONS_CLASS}
|
|
227
|
-
style={
|
|
228
|
-
// Positioning and hiding is implemented using compositor-only
|
|
229
|
-
// properties (transform and opacity) for performance.
|
|
230
|
-
{
|
|
231
|
-
transform: `translateY(${buttonsTop}px)`,
|
|
232
|
-
opacity:
|
|
233
|
-
!variable ||
|
|
234
|
-
// Do not show buttons display for special entries, defined in debugpy:
|
|
235
|
-
// https://github.com/microsoft/debugpy/blob/cf0d684566edc339545b161da7c3dfc48af7c7d5/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_utils.py#L359
|
|
236
|
-
[
|
|
237
|
-
'special variables',
|
|
238
|
-
'protected variables',
|
|
239
|
-
'function variables',
|
|
240
|
-
'class variables'
|
|
241
|
-
].includes(variable.name)
|
|
242
|
-
? 0
|
|
243
|
-
: 1
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
>
|
|
247
|
-
<button
|
|
248
|
-
className="jp-DebuggerVariables-renderVariable"
|
|
249
|
-
disabled={
|
|
250
|
-
!variable ||
|
|
251
|
-
!service.model.hasRichVariableRendering ||
|
|
252
|
-
!commands.isEnabled(Debugger.CommandIDs.renderMimeVariable, {
|
|
253
|
-
name: variable.name,
|
|
254
|
-
frameID: service.model.callstack.frame?.id
|
|
255
|
-
} as any)
|
|
256
|
-
}
|
|
257
|
-
onClick={e => {
|
|
258
|
-
if (!variable || !handleSelectVariable) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
e.stopPropagation();
|
|
262
|
-
handleSelectVariable(variable);
|
|
263
|
-
commands
|
|
264
|
-
.execute(Debugger.CommandIDs.renderMimeVariable, {
|
|
265
|
-
name: variable.name,
|
|
266
|
-
frameID: service.model.callstack.frame?.id
|
|
267
|
-
} as any)
|
|
268
|
-
.catch(reason => {
|
|
269
|
-
console.error(
|
|
270
|
-
`Failed to render variable ${variable?.name}`,
|
|
271
|
-
reason
|
|
272
|
-
);
|
|
273
|
-
});
|
|
274
|
-
}}
|
|
275
|
-
title={trans.__('Render variable: %1', variable?.name)}
|
|
276
|
-
>
|
|
277
|
-
<searchIcon.react stylesheet="menuItem" tag="span" />
|
|
278
|
-
</button>
|
|
279
|
-
</div>
|
|
280
|
-
);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
125
|
interface IVariablesBranchProps {
|
|
284
126
|
/**
|
|
285
127
|
* The commands registry.
|
|
@@ -296,14 +138,6 @@ interface IVariablesBranchProps {
|
|
|
296
138
|
* Callback on variable selection
|
|
297
139
|
*/
|
|
298
140
|
handleSelectVariable?: (variable: IDebugger.IVariable) => void;
|
|
299
|
-
/**
|
|
300
|
-
* Callback on mouseOver/mouseLeave event.
|
|
301
|
-
*/
|
|
302
|
-
onHoverChanged?: (data: IHoverData) => void;
|
|
303
|
-
/**
|
|
304
|
-
* Collapser icon component
|
|
305
|
-
*/
|
|
306
|
-
collapserIcon: JSX.Element;
|
|
307
141
|
}
|
|
308
142
|
|
|
309
143
|
/**
|
|
@@ -315,16 +149,8 @@ interface IVariablesBranchProps {
|
|
|
315
149
|
* @param props.filter Optional variable filter list.
|
|
316
150
|
*/
|
|
317
151
|
const VariablesBranch = (props: IVariablesBranchProps): JSX.Element => {
|
|
318
|
-
const {
|
|
319
|
-
|
|
320
|
-
data,
|
|
321
|
-
service,
|
|
322
|
-
filter,
|
|
323
|
-
translator,
|
|
324
|
-
handleSelectVariable,
|
|
325
|
-
onHoverChanged,
|
|
326
|
-
collapserIcon
|
|
327
|
-
} = props;
|
|
152
|
+
const { commands, data, service, filter, translator, handleSelectVariable } =
|
|
153
|
+
props;
|
|
328
154
|
const [variables, setVariables] = useState(data);
|
|
329
155
|
|
|
330
156
|
useEffect(() => {
|
|
@@ -332,7 +158,7 @@ const VariablesBranch = (props: IVariablesBranchProps): JSX.Element => {
|
|
|
332
158
|
}, [data]);
|
|
333
159
|
|
|
334
160
|
return (
|
|
335
|
-
|
|
161
|
+
<>
|
|
336
162
|
{variables
|
|
337
163
|
.filter(
|
|
338
164
|
variable => !(filter || new Set()).has(variable.evaluateName || '')
|
|
@@ -348,12 +174,10 @@ const VariablesBranch = (props: IVariablesBranchProps): JSX.Element => {
|
|
|
348
174
|
filter={filter}
|
|
349
175
|
translator={translator}
|
|
350
176
|
onSelect={handleSelectVariable}
|
|
351
|
-
onHoverChanged={onHoverChanged}
|
|
352
|
-
collapserIcon={collapserIcon}
|
|
353
177
|
/>
|
|
354
178
|
);
|
|
355
179
|
})}
|
|
356
|
-
|
|
180
|
+
</>
|
|
357
181
|
);
|
|
358
182
|
};
|
|
359
183
|
|
|
@@ -385,14 +209,6 @@ interface IVariableComponentProps {
|
|
|
385
209
|
* Callback on selection
|
|
386
210
|
*/
|
|
387
211
|
onSelect?: (variable: IDebugger.IVariable) => void;
|
|
388
|
-
/**
|
|
389
|
-
* Callback on mouseOver/mouseLeave event.
|
|
390
|
-
*/
|
|
391
|
-
onHoverChanged?: (data: IHoverData) => void;
|
|
392
|
-
/**
|
|
393
|
-
* Collapser icon component
|
|
394
|
-
*/
|
|
395
|
-
collapserIcon: JSX.Element;
|
|
396
212
|
}
|
|
397
213
|
|
|
398
214
|
function _prepareDetail(variable: IDebugger.IVariable) {
|
|
@@ -420,76 +236,156 @@ function _prepareDetail(variable: IDebugger.IVariable) {
|
|
|
420
236
|
* @param props.filter Optional variable filter list.
|
|
421
237
|
*/
|
|
422
238
|
const VariableComponent = (props: IVariableComponentProps): JSX.Element => {
|
|
423
|
-
const {
|
|
424
|
-
commands,
|
|
425
|
-
data,
|
|
426
|
-
service,
|
|
427
|
-
filter,
|
|
428
|
-
translator,
|
|
429
|
-
onSelect,
|
|
430
|
-
onHoverChanged,
|
|
431
|
-
collapserIcon
|
|
432
|
-
} = props;
|
|
239
|
+
const { commands, data, service, filter, translator, onSelect } = props;
|
|
433
240
|
const [variable] = useState(data);
|
|
434
|
-
const [
|
|
435
|
-
const [
|
|
241
|
+
const [showDetailsButton, setShowDetailsButton] = useState<boolean>(false);
|
|
242
|
+
const [expanded, setExpanded] = useState<boolean>(false);
|
|
243
|
+
const [variables, setVariables] = useState<DebugProtocol.Variable[] | null>(
|
|
244
|
+
null
|
|
245
|
+
);
|
|
436
246
|
|
|
247
|
+
const trans = useMemo(
|
|
248
|
+
() => (translator ?? nullTranslator).load('jupyterlab'),
|
|
249
|
+
[translator]
|
|
250
|
+
);
|
|
437
251
|
const onSelection = onSelect ?? (() => void 0);
|
|
438
252
|
|
|
439
|
-
const expandable =
|
|
440
|
-
variable.variablesReference !== 0 || variable.type === 'function'
|
|
253
|
+
const expandable = useMemo(
|
|
254
|
+
() => variable.variablesReference !== 0 || variable.type === 'function',
|
|
255
|
+
[variable.variablesReference, variable.type]
|
|
256
|
+
);
|
|
441
257
|
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
258
|
+
const details = useMemo(() => _prepareDetail(variable), [variable]);
|
|
259
|
+
|
|
260
|
+
const hasMimeRenderer = useMemo(
|
|
261
|
+
() =>
|
|
262
|
+
![
|
|
263
|
+
'special variables',
|
|
264
|
+
'protected variables',
|
|
265
|
+
'function variables',
|
|
266
|
+
'class variables'
|
|
267
|
+
].includes(variable.name),
|
|
268
|
+
[variable.name]
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const disableMimeRenderer = useMemo(
|
|
272
|
+
() =>
|
|
273
|
+
!service.model.hasRichVariableRendering ||
|
|
274
|
+
!commands.isEnabled(Debugger.CommandIDs.renderMimeVariable, {
|
|
275
|
+
name: variable.name,
|
|
276
|
+
frameID: service.model.callstack.frame?.id
|
|
277
|
+
} as any),
|
|
278
|
+
[
|
|
279
|
+
service.model.hasRichVariableRendering,
|
|
280
|
+
variable.name,
|
|
281
|
+
service.model.callstack.frame?.id
|
|
282
|
+
]
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
const fetchChildren = useCallback(async () => {
|
|
286
|
+
if (expandable && !variables) {
|
|
287
|
+
setVariables(await service.inspectVariable(variable.variablesReference));
|
|
445
288
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
)
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
289
|
+
}, [expandable, service, variable.variablesReference, variables]);
|
|
290
|
+
|
|
291
|
+
const onVariableClicked = useCallback(
|
|
292
|
+
async (event: React.MouseEvent): Promise<void> => {
|
|
293
|
+
const item = getTreeItemElement(event.target as HTMLElement);
|
|
294
|
+
if (event.currentTarget !== item) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (!expandable) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
setExpanded(!expanded);
|
|
302
|
+
},
|
|
303
|
+
[expandable, expanded]
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
const onSelectChange = useCallback(
|
|
307
|
+
(event: CustomEvent) => {
|
|
308
|
+
if (event.currentTarget === event.detail && event.detail.selected) {
|
|
309
|
+
onSelection(variable);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
[variable]
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
const renderVariable = useCallback(() => {
|
|
316
|
+
commands
|
|
317
|
+
.execute(Debugger.CommandIDs.renderMimeVariable, {
|
|
318
|
+
name: variable.name,
|
|
319
|
+
frameID: service.model.callstack.frame?.id
|
|
320
|
+
} as any)
|
|
321
|
+
.catch(reason => {
|
|
322
|
+
console.error(`Failed to render variable ${variable?.name}`, reason);
|
|
323
|
+
});
|
|
324
|
+
}, [commands, variable.name, service.model.callstack.frame?.id]);
|
|
325
|
+
|
|
326
|
+
const onContextMenu = useCallback(
|
|
327
|
+
(event: React.MouseEvent<HTMLElement, MouseEvent>): void => {
|
|
328
|
+
const item = getTreeItemElement(event.target as HTMLElement);
|
|
329
|
+
if (event.currentTarget !== item) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
onSelection(variable);
|
|
334
|
+
},
|
|
335
|
+
[variable]
|
|
336
|
+
);
|
|
453
337
|
|
|
454
338
|
return (
|
|
455
|
-
<
|
|
339
|
+
<TreeItem
|
|
340
|
+
className="jp-TreeItem nested"
|
|
341
|
+
expanded={expanded}
|
|
342
|
+
onSelect={onSelectChange}
|
|
343
|
+
onExpand={fetchChildren}
|
|
456
344
|
onClick={(e): Promise<void> => onVariableClicked(e)}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
event.stopPropagation();
|
|
345
|
+
onContextMenu={onContextMenu}
|
|
346
|
+
onKeyDown={event => {
|
|
347
|
+
if (event.key == 'Enter') {
|
|
348
|
+
if (hasMimeRenderer && showDetailsButton) {
|
|
349
|
+
onSelection(variable);
|
|
350
|
+
renderVariable();
|
|
351
|
+
}
|
|
465
352
|
}
|
|
466
353
|
}}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
354
|
+
onFocus={event => {
|
|
355
|
+
setShowDetailsButton(!event.defaultPrevented);
|
|
356
|
+
event.preventDefault();
|
|
357
|
+
}}
|
|
358
|
+
onBlur={event => {
|
|
359
|
+
setShowDetailsButton(false);
|
|
360
|
+
}}
|
|
361
|
+
onMouseOver={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
362
|
+
setShowDetailsButton(!event.defaultPrevented);
|
|
363
|
+
event.preventDefault();
|
|
364
|
+
}}
|
|
365
|
+
onMouseLeave={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
366
|
+
setShowDetailsButton(false);
|
|
475
367
|
}}
|
|
476
368
|
>
|
|
477
|
-
<span
|
|
478
|
-
className={
|
|
479
|
-
'jp-DebuggerVariables-collapser' +
|
|
480
|
-
(expanded ? ' jp-mod-expanded' : '')
|
|
481
|
-
}
|
|
482
|
-
>
|
|
483
|
-
{
|
|
484
|
-
// note: using React.cloneElement due to high typestyle cost
|
|
485
|
-
expandable ? React.cloneElement(collapserIcon) : null
|
|
486
|
-
}
|
|
487
|
-
</span>
|
|
488
369
|
<span className="jp-DebuggerVariables-name">{variable.name}</span>
|
|
489
|
-
|
|
490
|
-
{
|
|
491
|
-
|
|
492
|
-
{
|
|
370
|
+
{details && (
|
|
371
|
+
<span className="jp-DebuggerVariables-detail">{details}</span>
|
|
372
|
+
)}
|
|
373
|
+
{hasMimeRenderer && showDetailsButton && (
|
|
374
|
+
<Button
|
|
375
|
+
className="jp-DebuggerVariables-renderVariable"
|
|
376
|
+
appearance="stealth"
|
|
377
|
+
slot="end"
|
|
378
|
+
disabled={disableMimeRenderer}
|
|
379
|
+
onClick={e => {
|
|
380
|
+
e.stopPropagation();
|
|
381
|
+
renderVariable();
|
|
382
|
+
}}
|
|
383
|
+
title={trans.__('Render variable: %1', variable?.name)}
|
|
384
|
+
>
|
|
385
|
+
<searchIcon.react tag={null} />
|
|
386
|
+
</Button>
|
|
387
|
+
)}
|
|
388
|
+
{variables ? (
|
|
493
389
|
<VariablesBranch
|
|
494
390
|
key={variable.name}
|
|
495
391
|
commands={commands}
|
|
@@ -498,11 +394,13 @@ const VariableComponent = (props: IVariableComponentProps): JSX.Element => {
|
|
|
498
394
|
filter={filter}
|
|
499
395
|
translator={translator}
|
|
500
396
|
handleSelectVariable={onSelect}
|
|
501
|
-
onHoverChanged={onHoverChanged}
|
|
502
|
-
collapserIcon={collapserIcon}
|
|
503
397
|
/>
|
|
398
|
+
) : (
|
|
399
|
+
/* Trick to ensure collapse button is displayed
|
|
400
|
+
when variables are not loaded yet */
|
|
401
|
+
expandable && <TreeItem />
|
|
504
402
|
)}
|
|
505
|
-
</
|
|
403
|
+
</TreeItem>
|
|
506
404
|
);
|
|
507
405
|
};
|
|
508
406
|
|
package/style/variables.css
CHANGED
|
@@ -20,60 +20,15 @@
|
|
|
20
20
|
position: relative;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
.jp-DebuggerVariables-branch {
|
|
24
|
-
list-style: none;
|
|
25
|
-
margin: 0;
|
|
26
|
-
padding: 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.jp-DebuggerVariables-body
|
|
30
|
-
.jp-DebuggerVariables-branch
|
|
31
|
-
.jp-DebuggerVariables-branch {
|
|
32
|
-
grid-area: nested;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.jp-DebuggerVariables-body > .jp-DebuggerVariables-branch {
|
|
36
|
-
padding-top: 0.1em;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.jp-DebuggerVariables-branch li {
|
|
40
|
-
padding: 3px 0;
|
|
41
|
-
cursor: pointer;
|
|
42
|
-
color: var(--jp-content-font-color1);
|
|
43
|
-
display: grid;
|
|
44
|
-
grid-template:
|
|
45
|
-
'collapser name detail'
|
|
46
|
-
'nested nested nested';
|
|
47
|
-
grid-template-columns: max-content max-content 1fr;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.jp-DebuggerVariables-branch li:not(:has(li:hover)):hover {
|
|
51
|
-
background: var(--jp-layout-color2);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.jp-DebuggerVariables-collapser {
|
|
55
|
-
width: 16px;
|
|
56
|
-
grid-area: collapser;
|
|
57
|
-
transform: rotate(-90deg);
|
|
58
|
-
transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.jp-DebuggerVariables-collapser.jp-mod-expanded {
|
|
62
|
-
transform: rotate(0);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.jp-DebuggerVariables-buttons {
|
|
66
|
-
position: absolute;
|
|
67
|
-
top: 0;
|
|
68
|
-
right: 8px;
|
|
69
|
-
margin-top: 1px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
23
|
.jp-DebuggerVariables-name {
|
|
73
24
|
color: var(--jp-mirror-editor-attribute-color);
|
|
74
25
|
grid-area: name;
|
|
75
26
|
}
|
|
76
27
|
|
|
28
|
+
.jp-DebuggerVariables-name:last-of-type {
|
|
29
|
+
flex: 1 1 auto;
|
|
30
|
+
}
|
|
31
|
+
|
|
77
32
|
.jp-DebuggerVariables-name::after {
|
|
78
33
|
content: ':';
|
|
79
34
|
margin-right: 5px;
|
|
@@ -82,30 +37,10 @@
|
|
|
82
37
|
.jp-DebuggerVariables-detail {
|
|
83
38
|
/* detail contains value for primitive types or name of the type otherwise */
|
|
84
39
|
color: var(--jp-mirror-editor-string-color);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
background: none;
|
|
90
|
-
cursor: pointer;
|
|
91
|
-
transform-origin: center center;
|
|
92
|
-
transition: transform 0.2s cubic-bezier(0.4, 0, 1, 1);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.jp-DebuggerVariables-renderVariable:active {
|
|
96
|
-
transform: scale(1.35);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.jp-DebuggerVariables-renderVariable:hover {
|
|
100
|
-
background-color: var(--jp-layout-color2);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.jp-DebuggerVariables-renderVariable:disabled {
|
|
104
|
-
cursor: default;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.jp-DebuggerVariables-branch li > .jp-DebuggerVariables-branch {
|
|
108
|
-
margin-left: 12px;
|
|
40
|
+
flex: 1 1 auto;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
text-overflow: ellipsis;
|
|
109
44
|
}
|
|
110
45
|
|
|
111
46
|
.jp-DebuggerVariables-grid {
|