@jupyterlab/debugger 4.0.0-alpha.9 → 4.0.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.
Files changed (123) 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/sources/sourcepath.js +1 -1
  48. package/lib/panels/sources/sourcepath.js.map +1 -1
  49. package/lib/panels/variables/grid.d.ts +23 -10
  50. package/lib/panels/variables/grid.js +42 -367
  51. package/lib/panels/variables/grid.js.map +1 -1
  52. package/lib/panels/variables/gridpanel.d.ts +138 -0
  53. package/lib/panels/variables/gridpanel.js +362 -0
  54. package/lib/panels/variables/gridpanel.js.map +1 -0
  55. package/lib/panels/variables/mimerenderer.js +9 -1
  56. package/lib/panels/variables/mimerenderer.js.map +1 -1
  57. package/lib/panels/variables/scope.js +4 -0
  58. package/lib/panels/variables/scope.js.map +1 -1
  59. package/lib/panels/variables/tree.d.ts +1 -0
  60. package/lib/panels/variables/tree.js +136 -47
  61. package/lib/panels/variables/tree.js.map +1 -1
  62. package/lib/service.d.ts +20 -6
  63. package/lib/service.js +84 -59
  64. package/lib/service.js.map +1 -1
  65. package/lib/session.d.ts +20 -6
  66. package/lib/session.js +59 -11
  67. package/lib/session.js.map +1 -1
  68. package/lib/sidebar.js +1 -1
  69. package/lib/sources.d.ts +2 -2
  70. package/lib/sources.js +32 -17
  71. package/lib/sources.js.map +1 -1
  72. package/lib/tokens.d.ts +57 -13
  73. package/lib/tokens.js.map +1 -1
  74. package/package.json +38 -46
  75. package/src/config.ts +78 -0
  76. package/src/debugger.ts +154 -0
  77. package/src/dialogs/evaluate.ts +144 -0
  78. package/src/factory.ts +72 -0
  79. package/src/handler.ts +528 -0
  80. package/src/handlers/console.ts +118 -0
  81. package/src/handlers/editor.ts +469 -0
  82. package/src/handlers/file.ts +86 -0
  83. package/src/handlers/notebook.ts +128 -0
  84. package/src/hash.ts +69 -0
  85. package/src/icons.ts +64 -0
  86. package/src/index.ts +16 -0
  87. package/src/model.ts +155 -0
  88. package/src/panels/breakpoints/body.tsx +145 -0
  89. package/src/panels/breakpoints/index.ts +116 -0
  90. package/src/panels/breakpoints/model.ts +74 -0
  91. package/src/panels/breakpoints/pauseonexceptions.tsx +141 -0
  92. package/src/panels/callstack/body.tsx +96 -0
  93. package/src/panels/callstack/index.ts +152 -0
  94. package/src/panels/callstack/model.ts +86 -0
  95. package/src/panels/kernelSources/body.tsx +139 -0
  96. package/src/panels/kernelSources/filter.tsx +44 -0
  97. package/src/panels/kernelSources/index.tsx +106 -0
  98. package/src/panels/kernelSources/model.ts +160 -0
  99. package/src/panels/sources/body.ts +161 -0
  100. package/src/panels/sources/index.tsx +85 -0
  101. package/src/panels/sources/model.ts +94 -0
  102. package/src/panels/sources/sourcepath.tsx +31 -0
  103. package/src/panels/variables/grid.ts +145 -0
  104. package/src/panels/variables/gridpanel.ts +453 -0
  105. package/src/panels/variables/index.ts +199 -0
  106. package/src/panels/variables/mimerenderer.ts +125 -0
  107. package/src/panels/variables/model.ts +61 -0
  108. package/src/panels/variables/scope.tsx +132 -0
  109. package/src/panels/variables/tree.tsx +521 -0
  110. package/src/service.ts +1009 -0
  111. package/src/session.ts +342 -0
  112. package/src/sidebar.ts +194 -0
  113. package/src/sources.ts +327 -0
  114. package/src/svg.d.ts +9 -0
  115. package/src/tokens.ts +1071 -0
  116. package/style/breakpoints.css +21 -12
  117. package/style/callstack.css +2 -2
  118. package/style/icons/exceptions.svg +10 -0
  119. package/style/index.css +1 -1
  120. package/style/index.js +1 -1
  121. package/style/kernelSources.css +3 -9
  122. package/style/sources.css +1 -1
  123. package/style/variables.css +68 -21
package/src/sources.ts ADDED
@@ -0,0 +1,327 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { JupyterFrontEnd } from '@jupyterlab/application';
5
+ import { DOMUtils, MainAreaWidget, WidgetTracker } from '@jupyterlab/apputils';
6
+ import { CodeEditorWrapper, IEditorServices } from '@jupyterlab/codeeditor';
7
+ import { IConsoleTracker } from '@jupyterlab/console';
8
+ import { IEditorTracker } from '@jupyterlab/fileeditor';
9
+ import { INotebookTracker } from '@jupyterlab/notebook';
10
+ import { textEditorIcon } from '@jupyterlab/ui-components';
11
+ import { IDebugger } from './tokens';
12
+
13
+ /**
14
+ * The source and editor manager for a debugger instance.
15
+ */
16
+ export class DebuggerSources implements IDebugger.ISources {
17
+ /**
18
+ * Create a new DebuggerSources instance.
19
+ *
20
+ * @param options The instantiation options for a DebuggerSources instance.
21
+ */
22
+ constructor(options: DebuggerSources.IOptions) {
23
+ this._config = options.config;
24
+ this._shell = options.shell;
25
+ this._notebookTracker = options.notebookTracker ?? null;
26
+ this._consoleTracker = options.consoleTracker ?? null;
27
+ this._editorTracker = options.editorTracker ?? null;
28
+ this._readOnlyEditorTracker = new WidgetTracker<
29
+ MainAreaWidget<CodeEditorWrapper>
30
+ >({ namespace: '@jupyterlab/debugger' });
31
+ }
32
+
33
+ /**
34
+ * Returns an array of editors for a source matching the current debug
35
+ * session by iterating through all the widgets in each of the supported
36
+ * debugger types (i.e., consoles, files, notebooks).
37
+ *
38
+ * @param params - The editor search parameters.
39
+ */
40
+ find(params: IDebugger.ISources.FindParams): IDebugger.ISources.IEditor[] {
41
+ return [
42
+ ...this._findInConsoles(params),
43
+ ...this._findInEditors(params),
44
+ ...this._findInNotebooks(params),
45
+ ...this._findInReadOnlyEditors(params)
46
+ ];
47
+ }
48
+
49
+ /**
50
+ * Open a read-only editor in the main area.
51
+ *
52
+ * @param params The editor open parameters.
53
+ */
54
+ open(params: IDebugger.ISources.OpenParams): void {
55
+ const { editorWrapper, label, caption } = params;
56
+ const widget = new MainAreaWidget<CodeEditorWrapper>({
57
+ content: editorWrapper
58
+ });
59
+ widget.id = DOMUtils.createDomID();
60
+ widget.title.label = label;
61
+ widget.title.closable = true;
62
+ widget.title.caption = caption;
63
+ widget.title.icon = textEditorIcon;
64
+ this._shell.add(widget, 'main', { type: 'Debugger Sources' });
65
+ void this._readOnlyEditorTracker.add(widget);
66
+ }
67
+
68
+ /**
69
+ * Find relevant editors matching the search params in the notebook tracker.
70
+ *
71
+ * @param params - The editor search parameters.
72
+ */
73
+ private _findInNotebooks(
74
+ params: IDebugger.ISources.FindParams
75
+ ): IDebugger.ISources.IEditor[] {
76
+ if (!this._notebookTracker) {
77
+ return [];
78
+ }
79
+ const { focus, kernel, path, source } = params;
80
+
81
+ const editors: IDebugger.ISources.IEditor[] = [];
82
+ this._notebookTracker.forEach(notebookPanel => {
83
+ const sessionContext = notebookPanel.sessionContext;
84
+
85
+ if (path !== sessionContext.path) {
86
+ return;
87
+ }
88
+
89
+ const notebook = notebookPanel.content;
90
+ if (focus) {
91
+ notebook.mode = 'command';
92
+ }
93
+
94
+ const cells = notebookPanel.content.widgets;
95
+ cells.forEach((cell, i) => {
96
+ // check the event is for the correct cell
97
+ const code = cell.model.sharedModel.getSource();
98
+ const codeId = this._getCodeId(code, kernel);
99
+ if (!codeId) {
100
+ return;
101
+ }
102
+ if (source !== codeId) {
103
+ return;
104
+ }
105
+ if (focus) {
106
+ notebook.activeCellIndex = i;
107
+ if (notebook.activeCell) {
108
+ notebook.scrollToItem(notebook.activeCellIndex).catch(reason => {
109
+ // no-op
110
+ });
111
+ }
112
+ this._shell.activateById(notebookPanel.id);
113
+ }
114
+
115
+ editors.push(
116
+ Object.freeze({
117
+ get: () => cell.editor,
118
+ reveal: () => notebook.scrollToItem(i),
119
+ src: cell.model.sharedModel
120
+ })
121
+ );
122
+ });
123
+ });
124
+ return editors;
125
+ }
126
+
127
+ /**
128
+ * Find relevant editors matching the search params in the console tracker.
129
+ *
130
+ * @param params - The editor search parameters.
131
+ */
132
+ private _findInConsoles(
133
+ params: IDebugger.ISources.FindParams
134
+ ): IDebugger.ISources.IEditor[] {
135
+ if (!this._consoleTracker) {
136
+ return [];
137
+ }
138
+ const { focus, kernel, path, source } = params;
139
+
140
+ const editors: IDebugger.ISources.IEditor[] = [];
141
+ this._consoleTracker.forEach(consoleWidget => {
142
+ const sessionContext = consoleWidget.sessionContext;
143
+
144
+ if (path !== sessionContext.path) {
145
+ return;
146
+ }
147
+
148
+ const cells = consoleWidget.console.cells;
149
+ for (const cell of cells) {
150
+ const code = cell.model.sharedModel.getSource();
151
+ const codeId = this._getCodeId(code, kernel);
152
+ if (!codeId) {
153
+ break;
154
+ }
155
+ if (source !== codeId) {
156
+ break;
157
+ }
158
+
159
+ editors.push(
160
+ Object.freeze({
161
+ get: () => cell.editor,
162
+ reveal: () =>
163
+ Promise.resolve(this._shell.activateById(consoleWidget.id)),
164
+ src: cell.model.sharedModel
165
+ })
166
+ );
167
+
168
+ if (focus) {
169
+ this._shell.activateById(consoleWidget.id);
170
+ }
171
+ }
172
+ });
173
+ return editors;
174
+ }
175
+
176
+ /**
177
+ * Find relevant editors matching the search params in the editor tracker.
178
+ *
179
+ * @param params - The editor search parameters.
180
+ */
181
+ private _findInEditors(
182
+ params: IDebugger.ISources.FindParams
183
+ ): IDebugger.ISources.IEditor[] {
184
+ if (!this._editorTracker) {
185
+ return [];
186
+ }
187
+ const { focus, kernel, path, source } = params;
188
+
189
+ const editors: IDebugger.ISources.IEditor[] = [];
190
+ this._editorTracker.forEach(doc => {
191
+ const fileEditor = doc.content;
192
+ if (path !== fileEditor.context.path) {
193
+ return;
194
+ }
195
+
196
+ const editor = fileEditor.editor;
197
+ if (!editor) {
198
+ return;
199
+ }
200
+
201
+ const code = editor.model.sharedModel.getSource();
202
+ const codeId = this._getCodeId(code, kernel);
203
+ if (!codeId) {
204
+ return;
205
+ }
206
+ if (source !== codeId) {
207
+ return;
208
+ }
209
+ editors.push(
210
+ Object.freeze({
211
+ get: () => editor,
212
+ reveal: () => Promise.resolve(this._shell.activateById(doc.id)),
213
+ src: fileEditor.model.sharedModel
214
+ })
215
+ );
216
+
217
+ if (focus) {
218
+ this._shell.activateById(doc.id);
219
+ }
220
+ });
221
+ return editors;
222
+ }
223
+
224
+ /**
225
+ * Find relevant editors matching the search params in the read-only tracker.
226
+ *
227
+ * @param params - The editor search parameters.
228
+ */
229
+ private _findInReadOnlyEditors(
230
+ params: IDebugger.ISources.FindParams
231
+ ): IDebugger.ISources.IEditor[] {
232
+ const { focus, kernel, source } = params;
233
+
234
+ const editors: IDebugger.ISources.IEditor[] = [];
235
+ this._readOnlyEditorTracker.forEach(widget => {
236
+ const editor = widget.content?.editor;
237
+ if (!editor) {
238
+ return;
239
+ }
240
+
241
+ const code = editor.model.sharedModel.getSource();
242
+ const codeId = this._getCodeId(code, kernel);
243
+ if (!codeId) {
244
+ return;
245
+ }
246
+
247
+ if (widget.title.caption !== source && source !== codeId) {
248
+ return;
249
+ }
250
+ editors.push(
251
+ Object.freeze({
252
+ get: () => editor,
253
+ reveal: () => Promise.resolve(this._shell.activateById(widget.id)),
254
+ src: editor.model.sharedModel
255
+ })
256
+ );
257
+ if (focus) {
258
+ this._shell.activateById(widget.id);
259
+ }
260
+ });
261
+ return editors;
262
+ }
263
+
264
+ /**
265
+ * Get the code id for a given source and kernel,
266
+ * and handle the case of a kernel without parameters.
267
+ *
268
+ * @param code The source code.
269
+ * @param kernel The name of the kernel.
270
+ */
271
+ private _getCodeId(code: string, kernel: string): string {
272
+ try {
273
+ return this._config.getCodeId(code, kernel);
274
+ } catch {
275
+ return '';
276
+ }
277
+ }
278
+
279
+ private _shell: JupyterFrontEnd.IShell;
280
+ private _readOnlyEditorTracker: WidgetTracker<
281
+ MainAreaWidget<CodeEditorWrapper>
282
+ >;
283
+
284
+ private _config: IDebugger.IConfig;
285
+ private _notebookTracker: INotebookTracker | null;
286
+ private _consoleTracker: IConsoleTracker | null;
287
+ private _editorTracker: IEditorTracker | null;
288
+ }
289
+ /**
290
+ * A namespace for `DebuggerSources` statics.
291
+ */
292
+ export namespace DebuggerSources {
293
+ /**
294
+ * The options used to initialize a DebuggerSources object.
295
+ */
296
+ export interface IOptions {
297
+ /**
298
+ * The instance of configuration with hash method.
299
+ */
300
+ config: IDebugger.IConfig;
301
+
302
+ /**
303
+ * The editor services.
304
+ */
305
+ editorServices: IEditorServices;
306
+
307
+ /**
308
+ * The application shell.
309
+ */
310
+ shell: JupyterFrontEnd.IShell;
311
+
312
+ /**
313
+ * An optional console tracker.
314
+ */
315
+ consoleTracker?: IConsoleTracker | null;
316
+
317
+ /**
318
+ * An optional file editor tracker.
319
+ */
320
+ editorTracker?: IEditorTracker | null;
321
+
322
+ /**
323
+ * An optional notebook tracker.
324
+ */
325
+ notebookTracker?: INotebookTracker | null;
326
+ }
327
+ }
package/src/svg.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Copyright (c) Jupyter Development Team.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+
6
+ declare module '*.svg' {
7
+ const value: string; // @ts-ignore
8
+ export default value;
9
+ }