@jupyterlab/debugger 4.0.0-alpha.8 → 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 +39 -47
  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,106 @@
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
+
6
+ import { showErrorMessage } from '@jupyterlab/apputils';
7
+
8
+ import {
9
+ PanelWithToolbar,
10
+ refreshIcon,
11
+ searchIcon,
12
+ ToolbarButton
13
+ } from '@jupyterlab/ui-components';
14
+
15
+ import { IDebugger } from '../../tokens';
16
+
17
+ import { KernelSourcesBody } from './body';
18
+
19
+ /**
20
+ * A Panel that shows a preview of the source code while debugging.
21
+ */
22
+ export class KernelSources extends PanelWithToolbar {
23
+ /**
24
+ * Instantiate a new Sources preview Panel.
25
+ *
26
+ * @param options The Sources instantiation options.
27
+ */
28
+ constructor(options: KernelSources.IOptions) {
29
+ super();
30
+ const { model, service } = options;
31
+ this._model = model;
32
+ const trans = (options.translator ?? nullTranslator).load('jupyterlab');
33
+ this.title.label = trans.__('Kernel Sources');
34
+ this.toolbar.addClass('jp-DebuggerKernelSources-header');
35
+
36
+ this._body = new KernelSourcesBody({
37
+ service,
38
+ model,
39
+ translator: options.translator
40
+ });
41
+
42
+ this.toolbar.addItem(
43
+ 'open-filter',
44
+ new ToolbarButton({
45
+ icon: searchIcon,
46
+ onClick: async (): Promise<void> => {
47
+ this._body.toggleFilterbox();
48
+ },
49
+ tooltip: trans.__('Toggle search filter')
50
+ })
51
+ );
52
+
53
+ this.toolbar.addItem(
54
+ 'refresh',
55
+ new ToolbarButton({
56
+ icon: refreshIcon,
57
+ onClick: () => {
58
+ this._model.kernelSources = [];
59
+ void service.displayModules().catch(reason => {
60
+ void showErrorMessage(
61
+ trans.__('Fail to get kernel sources'),
62
+ trans.__('Fail to get kernel sources:\n%2', reason)
63
+ );
64
+ });
65
+ },
66
+ tooltip: trans.__('Refresh kernel sources')
67
+ })
68
+ );
69
+
70
+ this.addClass('jp-DebuggerKernelSources-header');
71
+ this.addWidget(this._body);
72
+ this.addClass('jp-DebuggerKenelSources');
73
+ }
74
+
75
+ public set filter(filter: string) {
76
+ this._model.filter = filter;
77
+ }
78
+
79
+ private _model: IDebugger.Model.IKernelSources;
80
+ private _body: KernelSourcesBody;
81
+ }
82
+
83
+ /**
84
+ * A namespace for `Sources` statics.
85
+ */
86
+ export namespace KernelSources {
87
+ /**
88
+ * The options used to create a Sources.
89
+ */
90
+ export interface IOptions {
91
+ /**
92
+ * The debugger service.
93
+ */
94
+ service: IDebugger;
95
+
96
+ /**
97
+ * The model for the sources.
98
+ */
99
+ model: IDebugger.Model.IKernelSources;
100
+
101
+ /**
102
+ * The application language translator
103
+ */
104
+ translator?: ITranslator;
105
+ }
106
+ }
@@ -0,0 +1,160 @@
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 { Debouncer } from '@lumino/polling';
7
+
8
+ import { IDebugger } from '../../tokens';
9
+
10
+ /**
11
+ * The rate limit for the filter debouncer
12
+ */
13
+ const DEBOUNCER_RATE_LIMIT_MS = 500;
14
+
15
+ const compare = (a: IDebugger.KernelSource, b: IDebugger.KernelSource) => {
16
+ if (a.name < b.name) {
17
+ return -1;
18
+ }
19
+ if (a.name > b.name) {
20
+ return 1;
21
+ }
22
+ return 0;
23
+ };
24
+
25
+ /**
26
+ * The model to keep track of the current source being displayed.
27
+ */
28
+ export class KernelSourcesModel implements IDebugger.Model.IKernelSources {
29
+ constructor() {
30
+ this.refresh = this.refresh.bind(this);
31
+ this._refreshDebouncer = new Debouncer(
32
+ this.refresh,
33
+ DEBOUNCER_RATE_LIMIT_MS
34
+ );
35
+ }
36
+
37
+ /**
38
+ * Get the filter.
39
+ */
40
+ get filter(): string {
41
+ return this._filter;
42
+ }
43
+
44
+ /**
45
+ * Set the filter.
46
+ * The update
47
+ */
48
+ set filter(filter: string) {
49
+ this._filter = filter;
50
+ this._filterChanged.emit(filter);
51
+ void this._refreshDebouncer.invoke();
52
+ }
53
+
54
+ /**
55
+ * Whether the kernel sources model is disposed or not.
56
+ */
57
+ get isDisposed(): boolean {
58
+ return this._isDisposed;
59
+ }
60
+
61
+ /**
62
+ * Get the kernel sources.
63
+ */
64
+ get kernelSources(): IDebugger.KernelSource[] | null {
65
+ return this._kernelSources;
66
+ }
67
+
68
+ /**
69
+ * Set the kernel sources and emit a changed signal.
70
+ */
71
+ set kernelSources(kernelSources: IDebugger.KernelSource[] | null) {
72
+ this._kernelSources = kernelSources;
73
+ this.refresh();
74
+ }
75
+
76
+ /**
77
+ * Signal emitted when the current source changes.
78
+ */
79
+ get changed(): ISignal<this, IDebugger.KernelSource[] | null> {
80
+ return this._changed;
81
+ }
82
+
83
+ /**
84
+ * Signal emitted when the current source changes.
85
+ */
86
+ get filterChanged(): ISignal<this, string> {
87
+ return this._filterChanged;
88
+ }
89
+
90
+ /**
91
+ * Signal emitted when a kernel source should be open in the main area.
92
+ */
93
+ get kernelSourceOpened(): ISignal<this, IDebugger.Source | null> {
94
+ return this._kernelSourceOpened;
95
+ }
96
+
97
+ /**
98
+ * Dispose the kernel sources model
99
+ */
100
+ dispose(): void {
101
+ if (this._isDisposed) {
102
+ return;
103
+ }
104
+ this._isDisposed = true;
105
+ this._refreshDebouncer.dispose();
106
+ Signal.clearData(this);
107
+ }
108
+
109
+ /**
110
+ * Open a source in the main area.
111
+ */
112
+ open(kernelSource: IDebugger.Source): void {
113
+ this._kernelSourceOpened.emit(kernelSource);
114
+ }
115
+
116
+ private getFilteredKernelSources() {
117
+ const regexp = new RegExp(this._filter);
118
+ return this._kernelSources!.filter(module => regexp.test(module.name));
119
+ }
120
+
121
+ private refresh() {
122
+ if (this._kernelSources) {
123
+ this._filteredKernelSources = this._filter
124
+ ? this.getFilteredKernelSources()
125
+ : this._kernelSources;
126
+ this._filteredKernelSources.sort(compare);
127
+ } else {
128
+ this._kernelSources = new Array<IDebugger.KernelSource>();
129
+ this._filteredKernelSources = new Array<IDebugger.KernelSource>();
130
+ }
131
+ this._changed.emit(this._filteredKernelSources);
132
+ }
133
+
134
+ private _filteredKernelSources: IDebugger.KernelSource[] | null = null;
135
+ private _filter = '';
136
+ private _isDisposed = false;
137
+ private _kernelSources: IDebugger.KernelSource[] | null = null;
138
+ private _refreshDebouncer: Debouncer;
139
+ private _changed = new Signal<this, IDebugger.KernelSource[] | null>(this);
140
+ private _filterChanged = new Signal<this, string>(this);
141
+ private _kernelSourceOpened = new Signal<this, IDebugger.Source | null>(this);
142
+ }
143
+
144
+ /**
145
+ * A namespace for SourcesModel `statics`.
146
+ */
147
+ export namespace KernelSourcesModel {
148
+ /**
149
+ * The options used to initialize a SourcesModel object.
150
+ */
151
+ export interface IOptions {
152
+ /**
153
+ * Signal emitted when the current frame changes.
154
+ */
155
+ currentFrameChanged: ISignal<
156
+ IDebugger.Model.ICallstack,
157
+ IDebugger.IStackFrame | null
158
+ >;
159
+ }
160
+ }
@@ -0,0 +1,161 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import {
5
+ CodeEditorWrapper,
6
+ IEditorMimeTypeService,
7
+ IEditorServices
8
+ } from '@jupyterlab/codeeditor';
9
+
10
+ import { Signal } from '@lumino/signaling';
11
+
12
+ import { PanelLayout, Widget } from '@lumino/widgets';
13
+
14
+ import { Debugger } from '../..';
15
+
16
+ import { EditorHandler } from '../../handlers/editor';
17
+
18
+ import { IDebugger } from '../../tokens';
19
+
20
+ /**
21
+ * The body for a Sources Panel.
22
+ */
23
+ export class SourcesBody extends Widget {
24
+ /**
25
+ * Instantiate a new Body for the SourcesBody widget.
26
+ *
27
+ * @param options The instantiation options for a SourcesBody.
28
+ */
29
+ constructor(options: SourcesBody.IOptions) {
30
+ super();
31
+ this._model = options.model;
32
+ this._debuggerService = options.service;
33
+ this._mimeTypeService = options.editorServices.mimeTypeService;
34
+
35
+ const factory = new Debugger.ReadOnlyEditorFactory({
36
+ editorServices: options.editorServices
37
+ });
38
+
39
+ this._editor = factory.createNewEditor({
40
+ content: '',
41
+ mimeType: '',
42
+ path: ''
43
+ });
44
+ this._editor.hide();
45
+
46
+ this._model.currentFrameChanged.connect(async (_, frame) => {
47
+ if (!frame) {
48
+ this._clearEditor();
49
+ return;
50
+ }
51
+
52
+ void this._showSource(frame);
53
+ });
54
+
55
+ const layout = new PanelLayout();
56
+ layout.addWidget(this._editor);
57
+ this.layout = layout;
58
+
59
+ this.addClass('jp-DebuggerSources-body');
60
+ }
61
+
62
+ /**
63
+ * Dispose the sources body widget.
64
+ */
65
+ dispose(): void {
66
+ if (this.isDisposed) {
67
+ return;
68
+ }
69
+ this._editorHandler?.dispose();
70
+ Signal.clearData(this);
71
+ super.dispose();
72
+ }
73
+
74
+ /**
75
+ * Clear the content of the source read-only editor.
76
+ */
77
+ private _clearEditor(): void {
78
+ this._model.currentSource = null;
79
+ this._editor.hide();
80
+ }
81
+
82
+ /**
83
+ * Show the content of the source for the given frame.
84
+ *
85
+ * @param frame The current frame.
86
+ */
87
+ private async _showSource(frame: IDebugger.IStackFrame): Promise<void> {
88
+ const path = frame.source?.path;
89
+ const source = await this._debuggerService.getSource({
90
+ sourceReference: 0,
91
+ path
92
+ });
93
+
94
+ if (!source?.content) {
95
+ this._clearEditor();
96
+ return;
97
+ }
98
+
99
+ if (this._editorHandler) {
100
+ this._editorHandler.dispose();
101
+ }
102
+
103
+ const { content, mimeType } = source;
104
+ const editorMimeType =
105
+ mimeType || this._mimeTypeService.getMimeTypeByFilePath(path ?? '');
106
+
107
+ this._editor.model.sharedModel.setSource(content);
108
+ this._editor.model.mimeType = editorMimeType;
109
+
110
+ this._editorHandler = new EditorHandler({
111
+ debuggerService: this._debuggerService,
112
+ editorReady: () => Promise.resolve(this._editor.editor),
113
+ getEditor: () => this._editor.editor,
114
+ path,
115
+ src: this._editor.model.sharedModel
116
+ });
117
+
118
+ this._model.currentSource = {
119
+ content,
120
+ mimeType: editorMimeType,
121
+ path: path ?? ''
122
+ };
123
+
124
+ requestAnimationFrame(() => {
125
+ EditorHandler.showCurrentLine(this._editor.editor, frame.line);
126
+ });
127
+
128
+ this._editor.show();
129
+ }
130
+
131
+ private _model: IDebugger.Model.ISources;
132
+ private _editor: CodeEditorWrapper;
133
+ private _editorHandler: EditorHandler;
134
+ private _debuggerService: IDebugger;
135
+ private _mimeTypeService: IEditorMimeTypeService;
136
+ }
137
+
138
+ /**
139
+ * A namespace for SourcesBody `statics`.
140
+ */
141
+ export namespace SourcesBody {
142
+ /**
143
+ * Instantiation options for `Breakpoints`.
144
+ */
145
+ export interface IOptions {
146
+ /**
147
+ * The debug service.
148
+ */
149
+ service: IDebugger;
150
+
151
+ /**
152
+ * The sources model.
153
+ */
154
+ model: IDebugger.Model.ISources;
155
+
156
+ /**
157
+ * The editor services used to create new read-only editors.
158
+ */
159
+ editorServices: IEditorServices;
160
+ }
161
+ }
@@ -0,0 +1,85 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+
6
+ import { IEditorServices } from '@jupyterlab/codeeditor';
7
+ import { ITranslator, nullTranslator } from '@jupyterlab/translation';
8
+ import { PanelWithToolbar, ToolbarButton } from '@jupyterlab/ui-components';
9
+ import { viewBreakpointIcon } from '../../icons';
10
+ import { IDebugger } from '../../tokens';
11
+ import { SourcePathComponent } from './sourcepath';
12
+ import { SourcesBody } from './body';
13
+ import { ReactWidget } from '@jupyterlab/ui-components';
14
+ import React from 'react';
15
+
16
+ /**
17
+ * A Panel that shows a preview of the source code while debugging.
18
+ */
19
+ export class Sources extends PanelWithToolbar {
20
+ /**
21
+ * Instantiate a new Sources preview Panel.
22
+ *
23
+ * @param options The Sources instantiation options.
24
+ */
25
+ constructor(options: Sources.IOptions) {
26
+ super();
27
+ const { model, service, editorServices } = options;
28
+ const trans = (options.translator ?? nullTranslator).load('jupyterlab');
29
+ this.title.label = trans.__('Source');
30
+
31
+ this.toolbar.addClass('jp-DebuggerSources-header');
32
+ const body = new SourcesBody({
33
+ service,
34
+ model,
35
+ editorServices
36
+ });
37
+ this.toolbar.addItem(
38
+ 'open',
39
+ new ToolbarButton({
40
+ icon: viewBreakpointIcon,
41
+ onClick: (): void => model.open(),
42
+ tooltip: trans.__('Open in the Main Area')
43
+ })
44
+ );
45
+ const sourcePath = ReactWidget.create(
46
+ <SourcePathComponent model={model} />
47
+ );
48
+
49
+ this.toolbar.addItem('sourcePath', sourcePath);
50
+ this.addClass('jp-DebuggerSources-header');
51
+
52
+ this.addWidget(body);
53
+ this.addClass('jp-DebuggerSources');
54
+ }
55
+ }
56
+
57
+ /**
58
+ * A namespace for `Sources` statics.
59
+ */
60
+ export namespace Sources {
61
+ /**
62
+ * The options used to create a Sources.
63
+ */
64
+ export interface IOptions {
65
+ /**
66
+ * The debugger service.
67
+ */
68
+ service: IDebugger;
69
+
70
+ /**
71
+ * The model for the sources.
72
+ */
73
+ model: IDebugger.Model.ISources;
74
+
75
+ /**
76
+ * The editor services used to create new read-only editors.
77
+ */
78
+ editorServices: IEditorServices;
79
+
80
+ /**
81
+ * The application language translator
82
+ */
83
+ translator?: ITranslator;
84
+ }
85
+ }
@@ -0,0 +1,94 @@
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
+ * The model to keep track of the current source being displayed.
10
+ */
11
+ export class SourcesModel implements IDebugger.Model.ISources {
12
+ /**
13
+ * Instantiate a new Sources.Model
14
+ *
15
+ * @param options The Sources.Model instantiation options.
16
+ */
17
+ constructor(options: SourcesModel.IOptions) {
18
+ this.currentFrameChanged = options.currentFrameChanged;
19
+ }
20
+
21
+ /**
22
+ * Signal emitted when the current frame changes.
23
+ */
24
+ readonly currentFrameChanged: ISignal<
25
+ IDebugger.Model.ICallstack,
26
+ IDebugger.IStackFrame | null
27
+ >;
28
+
29
+ /**
30
+ * Signal emitted when a source should be open in the main area.
31
+ */
32
+ get currentSourceOpened(): ISignal<SourcesModel, IDebugger.Source | null> {
33
+ return this._currentSourceOpened;
34
+ }
35
+
36
+ /**
37
+ * Signal emitted when the current source changes.
38
+ */
39
+ get currentSourceChanged(): ISignal<SourcesModel, IDebugger.Source | null> {
40
+ return this._currentSourceChanged;
41
+ }
42
+
43
+ /**
44
+ * Return the current source.
45
+ */
46
+ get currentSource(): IDebugger.Source | null {
47
+ return this._currentSource;
48
+ }
49
+
50
+ /**
51
+ * Set the current source.
52
+ *
53
+ * @param source The source to set as the current source.
54
+ */
55
+ set currentSource(source: IDebugger.Source | null) {
56
+ this._currentSource = source;
57
+ this._currentSourceChanged.emit(source);
58
+ }
59
+
60
+ /**
61
+ * Open a source in the main area.
62
+ */
63
+ open(): void {
64
+ this._currentSourceOpened.emit(this._currentSource);
65
+ }
66
+
67
+ private _currentSource: IDebugger.Source | null;
68
+ private _currentSourceOpened = new Signal<
69
+ SourcesModel,
70
+ IDebugger.Source | null
71
+ >(this);
72
+ private _currentSourceChanged = new Signal<
73
+ SourcesModel,
74
+ IDebugger.Source | null
75
+ >(this);
76
+ }
77
+
78
+ /**
79
+ * A namespace for SourcesModel `statics`.
80
+ */
81
+ export namespace SourcesModel {
82
+ /**
83
+ * The options used to initialize a SourcesModel object.
84
+ */
85
+ export interface IOptions {
86
+ /**
87
+ * Signal emitted when the current frame changes.
88
+ */
89
+ currentFrameChanged: ISignal<
90
+ IDebugger.Model.ICallstack,
91
+ IDebugger.IStackFrame | null
92
+ >;
93
+ }
94
+ }
@@ -0,0 +1,28 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { UseSignal } from '@jupyterlab/ui-components';
5
+ import React from 'react';
6
+ import { IDebugger } from '../../tokens';
7
+
8
+ /**
9
+ * A React component to display the path to a source.
10
+ *
11
+ * @param {object} props The component props.
12
+ * @param props.model The model for the sources.
13
+ */
14
+ export const SourcePathComponent = ({
15
+ model
16
+ }: {
17
+ model: IDebugger.Model.ISources;
18
+ }): JSX.Element => {
19
+ return (
20
+ <UseSignal signal={model.currentSourceChanged} initialSender={model}>
21
+ {(model): JSX.Element => (
22
+ <span onClick={(): void => model?.open()}>
23
+ {model?.currentSource?.path ?? ''}
24
+ </span>
25
+ )}
26
+ </UseSignal>
27
+ );
28
+ };