@jupyterlab/debugger 4.0.0-alpha.9 → 4.0.0-beta.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 (119) hide show
  1. package/lib/debugger.d.ts +3 -1
  2. package/lib/debugger.js +5 -3
  3. package/lib/debugger.js.map +1 -1
  4. package/lib/dialogs/evaluate.d.ts +5 -0
  5. package/lib/dialogs/evaluate.js +16 -6
  6. package/lib/dialogs/evaluate.js.map +1 -1
  7. package/lib/factory.d.ts +1 -1
  8. package/lib/factory.js +15 -9
  9. package/lib/factory.js.map +1 -1
  10. package/lib/handler.js +15 -7
  11. package/lib/handler.js.map +1 -1
  12. package/lib/handlers/console.js +9 -3
  13. package/lib/handlers/console.js.map +1 -1
  14. package/lib/handlers/editor.d.ts +26 -12
  15. package/lib/handlers/editor.js +166 -89
  16. package/lib/handlers/editor.js.map +1 -1
  17. package/lib/handlers/file.js +6 -2
  18. package/lib/handlers/file.js.map +1 -1
  19. package/lib/handlers/notebook.d.ts +0 -7
  20. package/lib/handlers/notebook.js +11 -17
  21. package/lib/handlers/notebook.js.map +1 -1
  22. package/lib/icons.d.ts +2 -1
  23. package/lib/icons.js +6 -1
  24. package/lib/icons.js.map +1 -1
  25. package/lib/model.js +1 -0
  26. package/lib/model.js.map +1 -1
  27. package/lib/panels/breakpoints/index.d.ts +2 -2
  28. package/lib/panels/breakpoints/index.js +9 -7
  29. package/lib/panels/breakpoints/index.js.map +1 -1
  30. package/lib/panels/breakpoints/pauseonexceptions.d.ts +53 -0
  31. package/lib/panels/breakpoints/pauseonexceptions.js +98 -0
  32. package/lib/panels/breakpoints/pauseonexceptions.js.map +1 -0
  33. package/lib/panels/callstack/index.d.ts +1 -1
  34. package/lib/panels/kernelSources/body.d.ts +5 -7
  35. package/lib/panels/kernelSources/body.js +37 -47
  36. package/lib/panels/kernelSources/body.js.map +1 -1
  37. package/lib/panels/kernelSources/filter.d.ts +1 -2
  38. package/lib/panels/kernelSources/filter.js +2 -2
  39. package/lib/panels/kernelSources/filter.js.map +1 -1
  40. package/lib/panels/kernelSources/index.js +1 -1
  41. package/lib/panels/kernelSources/index.js.map +1 -1
  42. package/lib/panels/kernelSources/model.d.ts +10 -1
  43. package/lib/panels/kernelSources/model.js +19 -1
  44. package/lib/panels/kernelSources/model.js.map +1 -1
  45. package/lib/panels/sources/body.js +5 -3
  46. package/lib/panels/sources/body.js.map +1 -1
  47. package/lib/panels/variables/grid.d.ts +10 -0
  48. package/lib/panels/variables/grid.js +28 -351
  49. package/lib/panels/variables/grid.js.map +1 -1
  50. package/lib/panels/variables/gridpanel.d.ts +140 -0
  51. package/lib/panels/variables/gridpanel.js +363 -0
  52. package/lib/panels/variables/gridpanel.js.map +1 -0
  53. package/lib/panels/variables/mimerenderer.js +9 -1
  54. package/lib/panels/variables/mimerenderer.js.map +1 -1
  55. package/lib/panels/variables/scope.js +4 -0
  56. package/lib/panels/variables/scope.js.map +1 -1
  57. package/lib/panels/variables/tree.d.ts +1 -0
  58. package/lib/panels/variables/tree.js +136 -47
  59. package/lib/panels/variables/tree.js.map +1 -1
  60. package/lib/service.d.ts +20 -6
  61. package/lib/service.js +84 -59
  62. package/lib/service.js.map +1 -1
  63. package/lib/session.d.ts +20 -6
  64. package/lib/session.js +59 -11
  65. package/lib/session.js.map +1 -1
  66. package/lib/sidebar.js +1 -1
  67. package/lib/sources.d.ts +2 -2
  68. package/lib/sources.js +32 -17
  69. package/lib/sources.js.map +1 -1
  70. package/lib/tokens.d.ts +57 -13
  71. package/lib/tokens.js.map +1 -1
  72. package/package.json +38 -46
  73. package/src/config.ts +78 -0
  74. package/src/debugger.ts +154 -0
  75. package/src/dialogs/evaluate.ts +144 -0
  76. package/src/factory.ts +72 -0
  77. package/src/handler.ts +528 -0
  78. package/src/handlers/console.ts +118 -0
  79. package/src/handlers/editor.ts +469 -0
  80. package/src/handlers/file.ts +86 -0
  81. package/src/handlers/notebook.ts +128 -0
  82. package/src/hash.ts +69 -0
  83. package/src/icons.ts +64 -0
  84. package/src/index.ts +16 -0
  85. package/src/model.ts +155 -0
  86. package/src/panels/breakpoints/body.tsx +145 -0
  87. package/src/panels/breakpoints/index.ts +116 -0
  88. package/src/panels/breakpoints/model.ts +74 -0
  89. package/src/panels/breakpoints/pauseonexceptions.tsx +141 -0
  90. package/src/panels/callstack/body.tsx +96 -0
  91. package/src/panels/callstack/index.ts +152 -0
  92. package/src/panels/callstack/model.ts +86 -0
  93. package/src/panels/kernelSources/body.tsx +139 -0
  94. package/src/panels/kernelSources/filter.tsx +44 -0
  95. package/src/panels/kernelSources/index.tsx +106 -0
  96. package/src/panels/kernelSources/model.ts +160 -0
  97. package/src/panels/sources/body.ts +161 -0
  98. package/src/panels/sources/index.tsx +85 -0
  99. package/src/panels/sources/model.ts +94 -0
  100. package/src/panels/sources/sourcepath.tsx +28 -0
  101. package/src/panels/variables/grid.ts +144 -0
  102. package/src/panels/variables/gridpanel.ts +455 -0
  103. package/src/panels/variables/index.ts +199 -0
  104. package/src/panels/variables/mimerenderer.ts +125 -0
  105. package/src/panels/variables/model.ts +61 -0
  106. package/src/panels/variables/scope.tsx +132 -0
  107. package/src/panels/variables/tree.tsx +521 -0
  108. package/src/service.ts +1009 -0
  109. package/src/session.ts +342 -0
  110. package/src/sidebar.ts +194 -0
  111. package/src/sources.ts +327 -0
  112. package/src/svg.d.ts +9 -0
  113. package/src/tokens.ts +1071 -0
  114. package/style/breakpoints.css +21 -12
  115. package/style/icons/exceptions.svg +10 -0
  116. package/style/index.css +1 -1
  117. package/style/index.js +1 -1
  118. package/style/kernelSources.css +3 -0
  119. package/style/variables.css +68 -21
@@ -0,0 +1,141 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import * as React from 'react';
5
+ import {
6
+ MenuSvg,
7
+ ToolbarButton,
8
+ ToolbarButtonComponent
9
+ } from '@jupyterlab/ui-components';
10
+ import { IDebugger } from '../../tokens';
11
+ import { Breakpoints } from './index';
12
+
13
+ const PAUSE_ON_EXCEPTION_CLASS = 'jp-debugger-pauseOnExceptions';
14
+ const PAUSE_ON_EXCEPTION_BUTTON_CLASS = 'jp-PauseOnExceptions';
15
+ const PAUSE_ON_EXCEPTION_MENU_CLASS = 'jp-PauseOnExceptions-menu';
16
+
17
+ /**
18
+ * A button which display a menu on click, to select the filter.
19
+ */
20
+ export class PauseOnExceptionsWidget extends ToolbarButton {
21
+ /**
22
+ * Constructor of the button.
23
+ */
24
+ constructor(props: PauseOnExceptions.IProps) {
25
+ super();
26
+ this._menu = new PauseOnExceptionsMenu({
27
+ service: props.service,
28
+ commands: {
29
+ registry: props.commands.registry,
30
+ pauseOnExceptions: props.commands.pauseOnExceptions
31
+ }
32
+ });
33
+
34
+ this.node.className = PAUSE_ON_EXCEPTION_CLASS;
35
+
36
+ this._props = props;
37
+ this._props.className = PAUSE_ON_EXCEPTION_BUTTON_CLASS;
38
+ this._props.service.eventMessage.connect((_, event): void => {
39
+ if (event.event === 'initialized' || event.event === 'terminated') {
40
+ this.onChange();
41
+ }
42
+ }, this);
43
+ this._props.enabled = this._props.service.pauseOnExceptionsIsValid();
44
+ this._props.service.pauseOnExceptionChanged.connect(this.onChange, this);
45
+ }
46
+
47
+ /**
48
+ * Called when the debugger is initialized or the filter changed.
49
+ */
50
+ onChange() {
51
+ const session = this._props.service.session;
52
+ const exceptionBreakpointFilters = session?.exceptionBreakpointFilters;
53
+ this._props.className = PAUSE_ON_EXCEPTION_BUTTON_CLASS;
54
+ if (this._props.service.session?.isStarted && exceptionBreakpointFilters) {
55
+ if (session.isPausingOnException()) {
56
+ this._props.className += ' lm-mod-toggled';
57
+ }
58
+ this._props.enabled = true;
59
+ } else {
60
+ this._props.enabled = false;
61
+ }
62
+ this.update();
63
+ }
64
+
65
+ /**
66
+ * open menu on click.
67
+ */
68
+ onclick = () => {
69
+ this._menu.open(
70
+ this.node.getBoundingClientRect().left,
71
+ this.node.getBoundingClientRect().bottom
72
+ );
73
+ };
74
+
75
+ render(): JSX.Element {
76
+ return <ToolbarButtonComponent {...this._props} onClick={this.onclick} />;
77
+ }
78
+
79
+ private _menu: PauseOnExceptionsMenu;
80
+ private _props: PauseOnExceptions.IProps;
81
+ }
82
+
83
+ /**
84
+ * A menu with all the available filter from the debugger as entries.
85
+ */
86
+ export class PauseOnExceptionsMenu extends MenuSvg {
87
+ /**
88
+ * The constructor of the menu.
89
+ */
90
+ constructor(props: PauseOnExceptions.IProps) {
91
+ super({ commands: props.commands.registry });
92
+ this._service = props.service;
93
+ this._command = props.commands.pauseOnExceptions;
94
+
95
+ props.service.eventMessage.connect((_, event): void => {
96
+ if (event.event === 'initialized') {
97
+ this._build();
98
+ }
99
+ }, this);
100
+
101
+ this._build();
102
+ this.addClass(PAUSE_ON_EXCEPTION_MENU_CLASS);
103
+ }
104
+
105
+ private _build(): void {
106
+ this.clearItems();
107
+ const exceptionsBreakpointFilters =
108
+ this._service.session?.exceptionBreakpointFilters ?? [];
109
+ exceptionsBreakpointFilters.map((filter, _) => {
110
+ this.addItem({
111
+ command: this._command,
112
+ args: {
113
+ filter: filter.filter,
114
+ description: filter.description as string
115
+ }
116
+ });
117
+ });
118
+ }
119
+
120
+ private _service: IDebugger;
121
+ private _command: string;
122
+ }
123
+
124
+ /**
125
+ * A namespace for the widget.
126
+ */
127
+ export namespace PauseOnExceptions {
128
+ /**
129
+ * The properties of the widget and menu.
130
+ */
131
+ export interface IProps extends ToolbarButtonComponent.IProps {
132
+ /**
133
+ * The debugger service linked to the widget.
134
+ */
135
+ service: IDebugger;
136
+ /**
137
+ * The commands registry and the command ID associated to the menu.
138
+ */
139
+ commands: Breakpoints.ICommands;
140
+ }
141
+ }
@@ -0,0 +1,96 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { PathExt } from '@jupyterlab/coreutils';
5
+ import { ReactWidget } from '@jupyterlab/ui-components';
6
+ import React, { useEffect, useState } from 'react';
7
+ import { IDebugger } from '../../tokens';
8
+
9
+ /**
10
+ * The body for a Callstack Panel.
11
+ */
12
+ export class CallstackBody extends ReactWidget {
13
+ /**
14
+ * Instantiate a new Body for the Callstack Panel.
15
+ *
16
+ * @param model The model for the callstack.
17
+ */
18
+ constructor(model: IDebugger.Model.ICallstack) {
19
+ super();
20
+ this._model = model;
21
+ this.addClass('jp-DebuggerCallstack-body');
22
+ }
23
+
24
+ /**
25
+ * Render the FramesComponent.
26
+ */
27
+ render(): JSX.Element {
28
+ return <FramesComponent model={this._model} />;
29
+ }
30
+
31
+ private _model: IDebugger.Model.ICallstack;
32
+ }
33
+
34
+ /**
35
+ * A React component to display a list of frames in a callstack.
36
+ *
37
+ * @param {object} props The component props.
38
+ * @param props.model The model for the callstack.
39
+ */
40
+ const FramesComponent = ({
41
+ model
42
+ }: {
43
+ model: IDebugger.Model.ICallstack;
44
+ }): JSX.Element => {
45
+ const [frames, setFrames] = useState(model.frames);
46
+ const [selected, setSelected] = useState(model.frame);
47
+
48
+ const onSelected = (frame: any): void => {
49
+ setSelected(frame);
50
+ model.frame = frame;
51
+ };
52
+
53
+ useEffect(() => {
54
+ const updateFrames = (): void => {
55
+ setSelected(model.frame);
56
+ setFrames(model.frames);
57
+ };
58
+ model.framesChanged.connect(updateFrames);
59
+
60
+ return (): void => {
61
+ model.framesChanged.disconnect(updateFrames);
62
+ };
63
+ }, [model]);
64
+
65
+ const toShortLocation = (el: IDebugger.IStackFrame) => {
66
+ const path = el.source?.path || '';
67
+ const base = PathExt.basename(PathExt.dirname(path));
68
+ const filename = PathExt.basename(path);
69
+ const shortname = PathExt.join(base, filename);
70
+ return `${shortname}:${el.line}`;
71
+ };
72
+
73
+ return (
74
+ <ul>
75
+ {frames.map(ele => (
76
+ <li
77
+ key={ele.id}
78
+ onClick={(): void => onSelected(ele)}
79
+ className={
80
+ selected?.id === ele.id
81
+ ? 'selected jp-DebuggerCallstackFrame'
82
+ : 'jp-DebuggerCallstackFrame'
83
+ }
84
+ >
85
+ <span className={'jp-DebuggerCallstackFrame-name'}>{ele.name}</span>
86
+ <span
87
+ className={'jp-DebuggerCallstackFrame-location'}
88
+ title={ele.source?.path}
89
+ >
90
+ {toShortLocation(ele)}
91
+ </span>
92
+ </li>
93
+ ))}
94
+ </ul>
95
+ );
96
+ };
@@ -0,0 +1,152 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { ITranslator, nullTranslator } from '@jupyterlab/translation';
5
+ import {
6
+ CommandToolbarButton,
7
+ PanelWithToolbar
8
+ } from '@jupyterlab/ui-components';
9
+ import { CommandRegistry } from '@lumino/commands';
10
+ import { Panel } from '@lumino/widgets';
11
+ import { IDebugger } from '../../tokens';
12
+ import { CallstackBody } from './body';
13
+
14
+ /**
15
+ * A Panel to show a callstack.
16
+ */
17
+ export class Callstack extends PanelWithToolbar {
18
+ /**
19
+ * Instantiate a new Callstack Panel.
20
+ *
21
+ * @param options The instantiation options for a Callstack Panel.
22
+ */
23
+ constructor(options: Callstack.IOptions) {
24
+ super(options);
25
+ const { commands, model } = options;
26
+ const trans = (options.translator ?? nullTranslator).load('jupyterlab');
27
+ this.title.label = trans.__('Callstack');
28
+ const body = new CallstackBody(model);
29
+
30
+ this.toolbar.addItem(
31
+ 'continue',
32
+ new CommandToolbarButton({
33
+ commands: commands.registry,
34
+ id: commands.continue,
35
+ label: ''
36
+ })
37
+ );
38
+
39
+ this.toolbar.addItem(
40
+ 'terminate',
41
+ new CommandToolbarButton({
42
+ commands: commands.registry,
43
+ id: commands.terminate,
44
+ label: ''
45
+ })
46
+ );
47
+
48
+ this.toolbar.addItem(
49
+ 'step-over',
50
+ new CommandToolbarButton({
51
+ commands: commands.registry,
52
+ id: commands.next,
53
+ label: ''
54
+ })
55
+ );
56
+
57
+ this.toolbar.addItem(
58
+ 'step-in',
59
+ new CommandToolbarButton({
60
+ commands: commands.registry,
61
+ id: commands.stepIn,
62
+ label: ''
63
+ })
64
+ );
65
+
66
+ this.toolbar.addItem(
67
+ 'step-out',
68
+ new CommandToolbarButton({
69
+ commands: commands.registry,
70
+ id: commands.stepOut,
71
+ label: ''
72
+ })
73
+ );
74
+
75
+ this.toolbar.addItem(
76
+ 'evaluate',
77
+ new CommandToolbarButton({
78
+ commands: commands.registry,
79
+ id: commands.evaluate,
80
+ label: ''
81
+ })
82
+ );
83
+
84
+ this.addWidget(body);
85
+ this.addClass('jp-DebuggerCallstack');
86
+ }
87
+ }
88
+
89
+ /**
90
+ * A namespace for Callstack `statics`.
91
+ */
92
+ export namespace Callstack {
93
+ /**
94
+ * The toolbar commands and registry for the callstack.
95
+ */
96
+ export interface ICommands {
97
+ /**
98
+ * The command registry.
99
+ */
100
+ registry: CommandRegistry;
101
+
102
+ /**
103
+ * The pause/continue command ID.
104
+ */
105
+ continue: string;
106
+
107
+ /**
108
+ * The terminate command ID.
109
+ */
110
+ terminate: string;
111
+
112
+ /**
113
+ * The next / stepOver command ID.
114
+ */
115
+ next: string;
116
+
117
+ /**
118
+ * The stepIn command ID.
119
+ */
120
+ stepIn: string;
121
+
122
+ /**
123
+ * The stepOut command ID.
124
+ */
125
+ stepOut: string;
126
+
127
+ /**
128
+ * The evaluate command ID.
129
+ */
130
+ evaluate: string;
131
+ }
132
+
133
+ /**
134
+ * Instantiation options for `Callstack`.
135
+ */
136
+ export interface IOptions extends Panel.IOptions {
137
+ /**
138
+ * The toolbar commands interface for the callstack.
139
+ */
140
+ commands: ICommands;
141
+
142
+ /**
143
+ * The model for the callstack.
144
+ */
145
+ model: IDebugger.Model.ICallstack;
146
+
147
+ /**
148
+ * The application language translator
149
+ */
150
+ translator?: ITranslator;
151
+ }
152
+ }
@@ -0,0 +1,86 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { ISignal, Signal } from '@lumino/signaling';
5
+
6
+ import { IDebugger } from '../../tokens';
7
+
8
+ /**
9
+ * A model for a callstack.
10
+ */
11
+ export class CallstackModel implements IDebugger.Model.ICallstack {
12
+ /**
13
+ * Get all the frames.
14
+ */
15
+ get frames(): IDebugger.IStackFrame[] {
16
+ return this._state;
17
+ }
18
+
19
+ /**
20
+ * Set the frames.
21
+ */
22
+ set frames(newFrames: IDebugger.IStackFrame[]) {
23
+ this._state = newFrames;
24
+ const currentFrameId =
25
+ this.frame !== null ? Private.getFrameId(this.frame) : '';
26
+ const frame = newFrames.find(
27
+ frame => Private.getFrameId(frame) === currentFrameId
28
+ );
29
+ // Default to the first frame if the previous one can't be found.
30
+ // Otherwise keep the current frame selected.
31
+ if (!frame) {
32
+ this.frame = newFrames[0];
33
+ }
34
+ this._framesChanged.emit(newFrames);
35
+ }
36
+
37
+ /**
38
+ * Get the current frame.
39
+ */
40
+ get frame(): IDebugger.IStackFrame | null {
41
+ return this._currentFrame;
42
+ }
43
+
44
+ /**
45
+ * Set the current frame.
46
+ */
47
+ set frame(frame: IDebugger.IStackFrame | null) {
48
+ this._currentFrame = frame;
49
+ this._currentFrameChanged.emit(frame);
50
+ }
51
+
52
+ /**
53
+ * Signal emitted when the frames have changed.
54
+ */
55
+ get framesChanged(): ISignal<this, IDebugger.IStackFrame[]> {
56
+ return this._framesChanged;
57
+ }
58
+
59
+ /**
60
+ * Signal emitted when the current frame has changed.
61
+ */
62
+ get currentFrameChanged(): ISignal<this, IDebugger.IStackFrame | null> {
63
+ return this._currentFrameChanged;
64
+ }
65
+
66
+ private _state: IDebugger.IStackFrame[] = [];
67
+ private _currentFrame: IDebugger.IStackFrame | null = null;
68
+ private _framesChanged = new Signal<this, IDebugger.IStackFrame[]>(this);
69
+ private _currentFrameChanged = new Signal<this, IDebugger.IStackFrame | null>(
70
+ this
71
+ );
72
+ }
73
+
74
+ /**
75
+ * A namespace for private data.
76
+ */
77
+ namespace Private {
78
+ /**
79
+ * Construct an id for the given frame.
80
+ *
81
+ * @param frame The frame.
82
+ */
83
+ export function getFrameId(frame: IDebugger.IStackFrame): string {
84
+ return `${frame?.source?.path}-${frame?.id}`;
85
+ }
86
+ }
@@ -0,0 +1,139 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import React from 'react';
5
+
6
+ import { openKernelSourceIcon } from '../../icons';
7
+
8
+ import { ReactWidget, ToolbarButtonComponent } from '@jupyterlab/ui-components';
9
+
10
+ import { showErrorMessage } from '@jupyterlab/apputils';
11
+
12
+ import { ITranslator, nullTranslator } from '@jupyterlab/translation';
13
+
14
+ import { KernelSourcesFilter } from './filter';
15
+
16
+ import { IDebugger } from '../../tokens';
17
+ import { UseSignal } from '@jupyterlab/ui-components';
18
+ import { IRenderMime } from '@jupyterlab/rendermime';
19
+
20
+ /**
21
+ * The class name added to the filterbox node.
22
+ */
23
+ const FILTERBOX_CLASS = 'jp-DebuggerKernelSource-filterBox';
24
+
25
+ /**
26
+ * The class name added to hide the filterbox node.
27
+ */
28
+ const FILTERBOX_HIDDEN_CLASS = 'jp-DebuggerKernelSource-filterBox-hidden';
29
+
30
+ /**
31
+ * The body for a Sources Panel.
32
+ */
33
+ export class KernelSourcesBody extends ReactWidget {
34
+ /**
35
+ * Instantiate a new Body for the KernelSourcesBody widget.
36
+ *
37
+ * @param options The instantiation options for a KernelSourcesBody.
38
+ */
39
+ constructor(options: KernelSourcesBody.IOptions) {
40
+ super();
41
+ this._model = options.model;
42
+ this._debuggerService = options.service;
43
+ this._trans = (options.translator ?? nullTranslator).load('jupyterlab');
44
+
45
+ this.addClass('jp-DebuggerKernelSources-body');
46
+ }
47
+
48
+ render() {
49
+ let filterClass = FILTERBOX_CLASS;
50
+ if (!this._showFilter) {
51
+ filterClass += ' ' + FILTERBOX_HIDDEN_CLASS;
52
+ }
53
+ return (
54
+ <React.Fragment>
55
+ <div className={filterClass} key={'filter'}>
56
+ <KernelSourcesFilter model={this._model} />
57
+ </div>
58
+ <UseSignal signal={this._model.changed}>
59
+ {(_, kernelSources) => {
60
+ const keymap: { [key: string]: number } = {};
61
+ return (kernelSources ?? []).map(module => {
62
+ const name = module.name;
63
+ const path = module.path;
64
+ const key =
65
+ name + (keymap[name] = (keymap[name] ?? 0) + 1).toString();
66
+ const button = (
67
+ <ToolbarButtonComponent
68
+ key={key}
69
+ icon={openKernelSourceIcon}
70
+ label={name}
71
+ tooltip={path}
72
+ onClick={() => {
73
+ this._debuggerService
74
+ .getSource({
75
+ sourceReference: 0,
76
+ path: path
77
+ })
78
+ .then(source => {
79
+ this._model.open(source);
80
+ })
81
+ .catch(reason => {
82
+ void showErrorMessage(
83
+ this._trans.__('Fail to get source'),
84
+ this._trans.__(
85
+ "Fail to get '%1' source:\n%2",
86
+ path,
87
+ reason
88
+ )
89
+ );
90
+ });
91
+ }}
92
+ />
93
+ );
94
+ return button;
95
+ });
96
+ }}
97
+ </UseSignal>
98
+ </React.Fragment>
99
+ );
100
+ }
101
+
102
+ /**
103
+ * Show or hide the filter box.
104
+ */
105
+ public toggleFilterbox(): void {
106
+ this._showFilter = !this._showFilter;
107
+ this.update();
108
+ }
109
+
110
+ private _model: IDebugger.Model.IKernelSources;
111
+ private _debuggerService: IDebugger;
112
+ private _trans: IRenderMime.TranslationBundle;
113
+ private _showFilter = false;
114
+ }
115
+
116
+ /**
117
+ * A namespace for SourcesBody `statics`.
118
+ */
119
+ export namespace KernelSourcesBody {
120
+ /**
121
+ * Instantiation options for `Breakpoints`.
122
+ */
123
+ export interface IOptions {
124
+ /**
125
+ * The debug service.
126
+ */
127
+ service: IDebugger;
128
+
129
+ /**
130
+ * The sources model.
131
+ */
132
+ model: IDebugger.Model.IKernelSources;
133
+
134
+ /**
135
+ * The application language translator
136
+ */
137
+ translator?: ITranslator;
138
+ }
139
+ }
@@ -0,0 +1,44 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { InputGroup, UseSignal } from '@jupyterlab/ui-components';
5
+
6
+ import React from 'react';
7
+
8
+ import { IDebugger } from '../../tokens';
9
+
10
+ /**
11
+ * The class name added to the filebrowser crumbs node.
12
+ */
13
+ export interface IFilterBoxProps {
14
+ model: IDebugger.Model.IKernelSources;
15
+ }
16
+
17
+ const FilterBox = (props: IFilterBoxProps) => {
18
+ const onFilterChange = (e: any) => {
19
+ const filter = (e.target as HTMLInputElement).value;
20
+ props.model.filter = filter;
21
+ };
22
+ return (
23
+ <InputGroup
24
+ type="text"
25
+ onChange={onFilterChange}
26
+ placeholder="Filter the kernel sources"
27
+ value={props.model.filter}
28
+ />
29
+ );
30
+ };
31
+
32
+ /**
33
+ * A widget which hosts a input textbox to filter on file names.
34
+ */
35
+ export const KernelSourcesFilter = (props: IFilterBoxProps) => {
36
+ return (
37
+ <UseSignal
38
+ signal={props.model.filterChanged}
39
+ initialArgs={props.model.filter}
40
+ >
41
+ {model => <FilterBox model={props.model} />}
42
+ </UseSignal>
43
+ );
44
+ };