@opensumi/ide-debug 3.5.1-next-1730948411.0 → 3.5.1-next-1730963433.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 (80) hide show
  1. package/lib/browser/components/floating-click-widget/index.d.ts +1 -3
  2. package/lib/browser/components/floating-click-widget/index.d.ts.map +1 -1
  3. package/lib/browser/components/floating-click-widget/index.js +6 -5
  4. package/lib/browser/components/floating-click-widget/index.js.map +1 -1
  5. package/lib/browser/debug-contribution.js +2 -2
  6. package/lib/browser/debug-contribution.js.map +1 -1
  7. package/lib/browser/editor/debug-hover.view.d.ts +1 -3
  8. package/lib/browser/editor/debug-hover.view.d.ts.map +1 -1
  9. package/lib/browser/editor/debug-hover.view.js +3 -3
  10. package/lib/browser/editor/debug-hover.view.js.map +1 -1
  11. package/lib/browser/index.d.ts +1 -3
  12. package/lib/browser/index.d.ts.map +1 -1
  13. package/lib/browser/view/breakpoints/debug-breakpoints.service.d.ts +2 -2
  14. package/lib/browser/view/breakpoints/debug-breakpoints.service.d.ts.map +1 -1
  15. package/lib/browser/view/breakpoints/debug-breakpoints.service.js +13 -40
  16. package/lib/browser/view/breakpoints/debug-breakpoints.service.js.map +1 -1
  17. package/lib/browser/view/breakpoints/debug-breakpoints.view.d.ts +2 -4
  18. package/lib/browser/view/breakpoints/debug-breakpoints.view.d.ts.map +1 -1
  19. package/lib/browser/view/breakpoints/debug-breakpoints.view.js +9 -7
  20. package/lib/browser/view/breakpoints/debug-breakpoints.view.js.map +1 -1
  21. package/lib/browser/view/configuration/debug-configuration.service.d.ts +6 -6
  22. package/lib/browser/view/configuration/debug-configuration.service.d.ts.map +1 -1
  23. package/lib/browser/view/configuration/debug-configuration.service.js +24 -71
  24. package/lib/browser/view/configuration/debug-configuration.service.js.map +1 -1
  25. package/lib/browser/view/configuration/debug-configuration.view.d.ts +2 -6
  26. package/lib/browser/view/configuration/debug-configuration.view.d.ts.map +1 -1
  27. package/lib/browser/view/configuration/debug-configuration.view.js +15 -8
  28. package/lib/browser/view/configuration/debug-configuration.view.js.map +1 -1
  29. package/lib/browser/view/configuration/debug-toolbar.service.d.ts +3 -4
  30. package/lib/browser/view/configuration/debug-toolbar.service.d.ts.map +1 -1
  31. package/lib/browser/view/configuration/debug-toolbar.service.js +17 -44
  32. package/lib/browser/view/configuration/debug-toolbar.service.js.map +1 -1
  33. package/lib/browser/view/configuration/debug-toolbar.view.d.ts +2 -6
  34. package/lib/browser/view/configuration/debug-toolbar.view.d.ts.map +1 -1
  35. package/lib/browser/view/configuration/debug-toolbar.view.js +69 -82
  36. package/lib/browser/view/configuration/debug-toolbar.view.js.map +1 -1
  37. package/lib/browser/view/console/debug-console-filter.view.d.ts +1 -3
  38. package/lib/browser/view/console/debug-console-filter.view.d.ts.map +1 -1
  39. package/lib/browser/view/console/debug-console-filter.view.js +3 -3
  40. package/lib/browser/view/console/debug-console-filter.view.js.map +1 -1
  41. package/lib/browser/view/console/debug-console.contribution.d.ts.map +1 -1
  42. package/lib/browser/view/console/debug-console.contribution.js +1 -0
  43. package/lib/browser/view/console/debug-console.contribution.js.map +1 -1
  44. package/lib/browser/view/console/debug-console.view.d.ts +2 -4
  45. package/lib/browser/view/console/debug-console.view.d.ts.map +1 -1
  46. package/lib/browser/view/console/debug-console.view.js +3 -3
  47. package/lib/browser/view/console/debug-console.view.js.map +1 -1
  48. package/lib/browser/view/frames/debug-call-stack-frame.view.d.ts +1 -3
  49. package/lib/browser/view/frames/debug-call-stack-frame.view.d.ts.map +1 -1
  50. package/lib/browser/view/frames/debug-call-stack-frame.view.js +3 -3
  51. package/lib/browser/view/frames/debug-call-stack-frame.view.js.map +1 -1
  52. package/lib/browser/view/frames/debug-call-stack.view.d.ts +2 -4
  53. package/lib/browser/view/frames/debug-call-stack.view.d.ts.map +1 -1
  54. package/lib/browser/view/frames/debug-call-stack.view.js +3 -3
  55. package/lib/browser/view/frames/debug-call-stack.view.js.map +1 -1
  56. package/lib/browser/view/variables/debug-variables.view.d.ts +2 -4
  57. package/lib/browser/view/variables/debug-variables.view.d.ts.map +1 -1
  58. package/lib/browser/view/variables/debug-variables.view.js +6 -6
  59. package/lib/browser/view/variables/debug-variables.view.js.map +1 -1
  60. package/lib/browser/view/watch/debug-watch.view.d.ts +2 -4
  61. package/lib/browser/view/watch/debug-watch.view.d.ts.map +1 -1
  62. package/lib/browser/view/watch/debug-watch.view.js +5 -5
  63. package/lib/browser/view/watch/debug-watch.view.js.map +1 -1
  64. package/package.json +25 -25
  65. package/src/browser/components/floating-click-widget/index.tsx +7 -6
  66. package/src/browser/debug-contribution.ts +2 -2
  67. package/src/browser/editor/debug-hover.view.tsx +3 -4
  68. package/src/browser/view/breakpoints/debug-breakpoints.service.ts +13 -18
  69. package/src/browser/view/breakpoints/debug-breakpoints.view.tsx +9 -7
  70. package/src/browser/view/configuration/debug-configuration.service.ts +24 -35
  71. package/src/browser/view/configuration/debug-configuration.view.tsx +21 -15
  72. package/src/browser/view/configuration/debug-toolbar.service.ts +21 -28
  73. package/src/browser/view/configuration/debug-toolbar.view.tsx +98 -91
  74. package/src/browser/view/console/debug-console-filter.view.tsx +2 -3
  75. package/src/browser/view/console/debug-console.contribution.ts +1 -0
  76. package/src/browser/view/console/debug-console.view.tsx +2 -3
  77. package/src/browser/view/frames/debug-call-stack-frame.view.tsx +2 -3
  78. package/src/browser/view/frames/debug-call-stack.view.tsx +2 -3
  79. package/src/browser/view/variables/debug-variables.view.tsx +5 -8
  80. package/src/browser/view/watch/debug-watch.view.tsx +5 -8
@@ -1,7 +1,6 @@
1
- import { action, makeObservable, observable, runInAction } from 'mobx';
2
-
3
1
  import { Autowired, Injectable } from '@opensumi/di';
4
2
  import { IEventBus, PreferenceConfigurations, PreferenceService, URI, isUndefined } from '@opensumi/ide-core-browser';
3
+ import { observableValue, transaction } from '@opensumi/ide-monaco/lib/common/observable';
5
4
  import { IWorkspaceService } from '@opensumi/ide-workspace';
6
5
  import { WorkspaceVariableContribution } from '@opensumi/ide-workspace/lib/browser/workspace-variable-contribution';
7
6
 
@@ -51,27 +50,15 @@ export class DebugConfigurationService {
51
50
  private _whenReady: Promise<void>;
52
51
 
53
52
  constructor() {
54
- makeObservable(this);
55
53
  this._whenReady = this.init();
56
54
  }
57
55
 
58
- @observable
59
- currentValue: string = DEFAULT_ADD_CONFIGURATION_KEY;
60
-
61
- @observable
62
- float = true;
63
-
64
- @observable
65
- isMultiRootWorkspace: boolean;
66
-
67
- @observable.shallow
68
- workspaceRoots: string[] = observable.array([]);
69
-
70
- @observable.shallow
71
- configurationOptions: DebugSessionOptions[] = observable.array([]);
72
-
73
- @observable.shallow
74
- dynamicConfigurations: DebugConfigurationType[] = [];
56
+ currentValue = observableValue(this, DEFAULT_ADD_CONFIGURATION_KEY);
57
+ float = observableValue(this, false);
58
+ configurationOptions = observableValue<DebugSessionOptions[]>(this, []);
59
+ dynamicConfigurations = observableValue<DebugConfigurationType[]>(this, []);
60
+ isMultiRootWorkspace = observableValue(this, false);
61
+ workspaceRoots = observableValue<string[]>(this, []);
75
62
 
76
63
  get whenReady() {
77
64
  return this._whenReady;
@@ -88,7 +75,7 @@ export class DebugConfigurationService {
88
75
  this.preferenceService.onPreferenceChanged((event) => {
89
76
  const { preferenceName, newValue } = event;
90
77
  if (preferenceName === 'debug.toolbar.float') {
91
- if (this.float !== newValue) {
78
+ if (this.float.get() !== newValue) {
92
79
  this.updateFloat(newValue);
93
80
  }
94
81
  }
@@ -107,30 +94,33 @@ export class DebugConfigurationService {
107
94
 
108
95
  async updateWorkspaceState() {
109
96
  const roots = (await this.workspaceService.tryGetRoots()).map((root) => root.uri);
110
- runInAction(() => {
111
- this.isMultiRootWorkspace = this.workspaceService.isMultiRootWorkspaceOpened;
112
- this.workspaceRoots = roots;
97
+ transaction((tx) => {
98
+ this.isMultiRootWorkspace.set(this.workspaceService.isMultiRootWorkspaceOpened, tx);
99
+ this.workspaceRoots.set(roots, tx);
113
100
  });
114
101
  }
115
102
 
116
- @action
117
103
  async updateDynamicConfigurations() {
118
- this.dynamicConfigurations = await this.debugConfigurationManager.getDynamicConfigurationsSupportTypes();
104
+ const types = await this.debugConfigurationManager.getDynamicConfigurationsSupportTypes();
105
+ transaction((tx) => {
106
+ this.dynamicConfigurations.set(types, tx);
107
+ });
119
108
  }
120
109
 
121
- @action
122
110
  updateFloat(value: boolean) {
123
- this.float = value;
111
+ this.float.set(value, undefined);
124
112
  }
125
113
 
126
- @action
127
114
  updateCurrentValue(value: string) {
128
- this.currentValue = value;
115
+ transaction((tx) => {
116
+ this.currentValue.set(value, tx);
117
+ });
129
118
  }
130
119
 
131
- @action
132
120
  async updateConfigurationOptions() {
133
- this.configurationOptions = this.debugConfigurationManager.all;
121
+ transaction((tx) => {
122
+ this.configurationOptions.set(this.debugConfigurationManager.all, tx);
123
+ });
134
124
  const { current } = this.debugConfigurationManager;
135
125
  if (current) {
136
126
  const currentValue = this.toValue(current);
@@ -203,13 +193,12 @@ export class DebugConfigurationService {
203
193
  if (config) {
204
194
  this.debugSessionManager.start({
205
195
  configuration: config,
206
- workspaceFolderUri: this.workspaceRoots[0],
196
+ workspaceFolderUri: this.workspaceRoots.get()[0],
207
197
  index: -1,
208
198
  });
209
199
  }
210
200
  };
211
201
 
212
- @action.bound
213
202
  toValue({ configuration, workspaceFolderUri, index }: DebugSessionOptions) {
214
203
  if (!workspaceFolderUri) {
215
204
  return configuration.name;
@@ -219,7 +208,7 @@ export class DebugConfigurationService {
219
208
  if (options && options.index) {
220
209
  return this.toValue(options);
221
210
  }
222
- return this.currentValue;
211
+ return this.currentValue.get();
223
212
  }
224
213
  return (
225
214
  configuration.name +
@@ -1,9 +1,8 @@
1
1
  import cls from 'classnames';
2
- import { observer } from 'mobx-react-lite';
3
2
  import React from 'react';
4
3
 
5
4
  import { Option, Popover, Select } from '@opensumi/ide-components';
6
- import { AppConfig, URI, localize, useInjectable } from '@opensumi/ide-core-browser';
5
+ import { AppConfig, URI, localize, useAutorun, useInjectable } from '@opensumi/ide-core-browser';
7
6
  import { Select as NativeSelect } from '@opensumi/ide-core-browser/lib/components/select';
8
7
 
9
8
  import {
@@ -260,8 +259,9 @@ export const DebugActionBar = React.memo(({ runDebug, openConfiguration, openDeb
260
259
  </div>
261
260
  ));
262
261
 
263
- export const DebugConfigurationContainerView = observer(() => {
264
- const { float } = useInjectable<DebugConfigurationService>(DebugConfigurationService);
262
+ export const DebugConfigurationContainerView = () => {
263
+ const debugConfigurationService = useInjectable<DebugConfigurationService>(DebugConfigurationService);
264
+ const float = useAutorun(debugConfigurationService.float);
265
265
 
266
266
  return (
267
267
  <>
@@ -269,7 +269,7 @@ export const DebugConfigurationContainerView = observer(() => {
269
269
  {!float && <DebugToolbarView float={false} className={styles.debug_action_bar_internal} />}
270
270
  </>
271
271
  );
272
- });
272
+ };
273
273
 
274
274
  export interface DebugControllerViewProps {
275
275
  className?: string;
@@ -280,21 +280,27 @@ export interface DebugControllerViewProps {
280
280
  * 该组件支持用户导入
281
281
  * 后续如果有一些改动需要考虑是否有 breakchange
282
282
  */
283
- export const DebugControllerView = observer((props: DebugControllerViewProps) => {
283
+ export const DebugControllerView = (props: DebugControllerViewProps) => {
284
284
  const {
285
- configurationOptions,
286
- dynamicConfigurations,
287
285
  toValue,
288
- currentValue,
289
286
  openConfiguration,
290
287
  addConfiguration,
291
288
  openDebugConsole,
292
289
  updateConfiguration,
293
290
  start,
294
291
  showDynamicQuickPick,
292
+ currentValue,
293
+ configurationOptions,
294
+ dynamicConfigurations,
295
295
  isMultiRootWorkspace,
296
296
  workspaceRoots,
297
297
  } = useInjectable<DebugConfigurationService>(DebugConfigurationService);
298
+ const autorunDynamicConfigurations = useAutorun(dynamicConfigurations);
299
+ const autorunCurrentValue = useAutorun(currentValue);
300
+ const autorunConfigurationOptions = useAutorun(configurationOptions);
301
+ const autorunIsMultiRootWorkspace = useAutorun(isMultiRootWorkspace);
302
+ const autorunWorkspaceRoots = useAutorun(workspaceRoots);
303
+
298
304
  const appConfig = useInjectable<AppConfig>(AppConfig);
299
305
  const addConfigurationLabel = localize('debug.action.add.configuration');
300
306
  const editConfigurationLabel = localize('debug.action.edit.configuration');
@@ -329,16 +335,16 @@ export const DebugControllerView = observer((props: DebugControllerViewProps) =>
329
335
  return (
330
336
  <div className={cls(styles.debug_configuration_toolbar, props.className || '')}>
331
337
  <ConfigurationSelector
332
- currentValue={currentValue}
333
- options={configurationOptions}
334
- dynamicOptions={dynamicConfigurations}
338
+ currentValue={autorunCurrentValue}
339
+ options={autorunConfigurationOptions}
340
+ dynamicOptions={autorunDynamicConfigurations}
341
+ workspaceRoots={autorunWorkspaceRoots}
342
+ isMultiRootWorkspace={autorunIsMultiRootWorkspace}
335
343
  onChangeConfiguration={setCurrentConfiguration}
336
- isMultiRootWorkspace={isMultiRootWorkspace}
337
344
  addConfigurationLabel={addConfigurationLabel}
338
345
  editConfigurationLabel={editConfigurationLabel}
339
346
  toValue={toValue}
340
347
  isElectronRenderer={appConfig.isElectronRenderer}
341
- workspaceRoots={workspaceRoots}
342
348
  />
343
349
  {CustomActionBar ? (
344
350
  <CustomActionBar />
@@ -347,4 +353,4 @@ export const DebugControllerView = observer((props: DebugControllerViewProps) =>
347
353
  )}
348
354
  </div>
349
355
  );
350
- });
356
+ };
@@ -1,9 +1,8 @@
1
- import { action, makeObservable, observable } from 'mobx';
2
-
3
1
  import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di';
4
2
  import { IContextKeyService, IReporterService, memoize } from '@opensumi/ide-core-browser';
5
3
  import { AbstractContextMenuService, IContextMenu, MenuId } from '@opensumi/ide-core-browser/lib/menu/next';
6
4
  import { IElectronMainUIService } from '@opensumi/ide-core-common/lib/electron';
5
+ import { observableValue, transaction } from '@opensumi/ide-monaco/lib/common/observable';
7
6
 
8
7
  import { DEBUG_REPORT_NAME, DebugState } from '../../../common';
9
8
  import { DebugSession } from '../../debug-session';
@@ -26,22 +25,13 @@ export class DebugToolbarService {
26
25
  @Autowired(INJECTOR_TOKEN)
27
26
  private readonly injector: Injector;
28
27
 
29
- @observable
30
- state: DebugState = DebugState.Inactive;
31
-
32
- @observable
33
- sessionCount: number;
34
-
35
- @observable.shallow
36
- currentSession: DebugSession | undefined;
37
-
38
- @observable.shallow
39
- sessions: DebugSession[] = [];
28
+ state = observableValue(this, DebugState.Inactive);
29
+ currentSession = observableValue<DebugSession | undefined>(this, undefined);
30
+ sessions = observableValue<DebugSession[]>(this, []);
40
31
 
41
32
  public readonly toolBarMenuMap: Map<string, IContextMenu> = new Map();
42
33
 
43
34
  constructor() {
44
- makeObservable(this);
45
35
  this.model.onDidChange(() => {
46
36
  this.updateToolBarMenu();
47
37
  this.updateModel();
@@ -53,28 +43,31 @@ export class DebugToolbarService {
53
43
  return this.injector.get(IElectronMainUIService);
54
44
  }
55
45
 
56
- @action
57
46
  updateModel() {
58
- this.state = this.model.state;
59
- this.currentSession = this.model.currentSession;
60
- this.sessions = Array.from(this.model.sessions).filter(
61
- (session: DebugSession) => session && session.state > DebugState.Inactive,
62
- );
63
- this.sessionCount = this.sessions.length;
47
+ transaction((tx) => {
48
+ this.state.set(this.model.state, tx);
49
+ this.currentSession.set(this.model.currentSession, tx);
50
+ this.sessions.set(
51
+ Array.from(this.model.sessions).filter(
52
+ (session: DebugSession) => session && session.state > DebugState.Inactive,
53
+ ),
54
+ tx,
55
+ );
56
+ });
64
57
  }
65
58
 
66
- @action
67
59
  updateToolBarMenu() {
68
- if (this.currentSession && this.currentSession.id && !this.toolBarMenuMap.has(this.currentSession.id)) {
60
+ const currentSession = this.currentSession.get();
61
+ if (currentSession && currentSession.id && !this.toolBarMenuMap.has(currentSession.id)) {
69
62
  const contextMenu = this.contextMenuService.createMenu({
70
63
  id: MenuId.DebugToolBar,
71
64
  contextKeyService: this.contextKeyService.createScoped(),
72
65
  });
73
- this.currentSession.on('terminated', () => {
74
- this.toolBarMenuMap.delete(this.currentSession?.id!);
66
+ currentSession.on('terminated', () => {
67
+ this.toolBarMenuMap.delete(currentSession.id);
75
68
  });
76
69
 
77
- this.toolBarMenuMap.set(this.currentSession.id, contextMenu);
70
+ this.toolBarMenuMap.set(currentSession.id, contextMenu);
78
71
  }
79
72
  }
80
73
 
@@ -86,7 +79,7 @@ export class DebugToolbarService {
86
79
  this.model.reportAction(session.id, threadId, name);
87
80
  const extra = {
88
81
  type: languageType,
89
- request: this.currentSession?.configuration.request,
82
+ request: this.currentSession.get()?.configuration?.request,
90
83
  sessionId: session.id,
91
84
  threadId,
92
85
  };
@@ -97,7 +90,7 @@ export class DebugToolbarService {
97
90
  };
98
91
  }
99
92
 
100
- doStart = () => this.model.start();
93
+ doStart = async () => await this.model.start();
101
94
 
102
95
  doRestart = async () => {
103
96
  const reportTimeEnd = this.instrumentReporter('restart');
@@ -1,6 +1,4 @@
1
1
  import cls from 'classnames';
2
- import { action, makeObservable, observable } from 'mobx';
3
- import { observer } from 'mobx-react-lite';
4
2
  import React, { useCallback, useEffect, useState } from 'react';
5
3
 
6
4
  import { Injectable } from '@opensumi/di';
@@ -12,6 +10,7 @@ import {
12
10
  electronEnv,
13
11
  getIcon,
14
12
  localize,
13
+ useAutorun,
15
14
  useDesignStyles,
16
15
  useInjectable,
17
16
  } from '@opensumi/ide-core-browser';
@@ -19,6 +18,7 @@ import { InlineMenuBar } from '@opensumi/ide-core-browser/lib/components/actions
19
18
  import { Select as NativeSelect } from '@opensumi/ide-core-browser/lib/components/select';
20
19
  import { LayoutViewSizeConfig } from '@opensumi/ide-core-browser/lib/layout/constants';
21
20
  import { IElectronMainUIService } from '@opensumi/ide-core-common/lib/electron';
21
+ import { derived, observableValue, transaction } from '@opensumi/ide-monaco/lib/common/observable';
22
22
 
23
23
  import { DebugState } from '../../../common';
24
24
  import { DebugAction } from '../../components';
@@ -31,50 +31,45 @@ import { DebugToolbarService } from './debug-toolbar.service';
31
31
 
32
32
  @Injectable()
33
33
  class FloatController {
34
- @observable
35
- x: number;
36
-
37
- @observable
38
- line: number;
39
-
40
- @observable
41
- enable: boolean;
42
-
43
- private _origin: number;
44
- private _last: number;
45
-
46
- private _y: number;
47
-
48
- constructor() {
49
- makeObservable(this);
50
- this.x = 0;
51
- this.line = 0;
52
- this.enable = false;
53
- this._origin = 0;
54
- this._last = 0;
55
- this._y = 0;
34
+ private _x = observableValue(this, 0);
35
+ private _line = observableValue(this, 0);
36
+ private _enable = observableValue(this, false);
37
+
38
+ private y: number = 0;
39
+ private last: number = 0;
40
+ private origin: number = 0;
41
+
42
+ state = derived(this, (reader) => ({
43
+ enable: this._enable.read(reader),
44
+ x: this._x.read(reader),
45
+ line: this._line.read(reader),
46
+ }));
47
+
48
+ setEnable(value: boolean) {
49
+ transaction((tx) => {
50
+ this._enable.set(value, tx);
51
+ });
56
52
  }
57
53
 
58
- @action.bound
59
54
  onMouseDown(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
60
- this.enable = true;
61
- this._origin = e.clientX;
62
- this._y = e.clientY;
55
+ this.setEnable(true);
56
+ this.y = e.clientY;
57
+ this.origin = e.clientX;
63
58
  }
64
59
 
65
- @action.bound
66
60
  onMouseMove(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
67
61
  e.stopPropagation();
68
- if (this.enable) {
69
- this.x = e.clientX - this._origin + this._last;
70
- this.line = e.clientY - this._y > 10 ? 1 : 0;
71
- }
62
+ transaction((tx) => {
63
+ if (this._enable.get()) {
64
+ this._x.set(e.clientX - this.origin + this.last, tx);
65
+ this._line.set(e.clientY - this.y > 10 ? 1 : 0, tx);
66
+ }
67
+ });
72
68
  }
73
69
 
74
- @action.bound
75
70
  onMouseUp() {
76
- this.enable = false;
77
- this._last = this.x;
71
+ this.setEnable(false);
72
+ this.last = this._x.get();
78
73
  }
79
74
  }
80
75
 
@@ -87,7 +82,7 @@ export interface DebugToolbarViewProps {
87
82
  * 该组件支持用户导入
88
83
  * 后续如果有一些改动需要考虑是否有 breakchange
89
84
  */
90
- export const DebugToolbarView = observer((props: DebugToolbarViewProps) => {
85
+ export const DebugToolbarView = (props: DebugToolbarViewProps) => {
91
86
  const {
92
87
  state,
93
88
  toolBarMenuMap,
@@ -102,13 +97,17 @@ export const DebugToolbarView = observer((props: DebugToolbarViewProps) => {
102
97
  sessions,
103
98
  updateCurrentSession,
104
99
  } = useInjectable<DebugToolbarService>(DebugToolbarService);
100
+ const autorunState = useAutorun(state);
101
+ const autorunCurrentSession = useAutorun(currentSession);
102
+ const autorunSessions = useAutorun(sessions);
103
+
105
104
  const { isElectronRenderer } = useInjectable<AppConfig>(AppConfig);
106
105
  const isAttach =
107
- !!currentSession &&
108
- currentSession.configuration.request === 'attach' &&
109
- !isExtensionHostDebugging(currentSession.configuration);
106
+ !!autorunCurrentSession &&
107
+ autorunCurrentSession.configuration?.request === 'attach' &&
108
+ !isExtensionHostDebugging(autorunCurrentSession.configuration);
110
109
 
111
- const currentSessionId = currentSession && currentSession.id;
110
+ const currentSessionId = autorunCurrentSession && autorunCurrentSession.id;
112
111
 
113
112
  const renderToolBar = useCallback(
114
113
  (session: DebugSession | undefined): React.ReactNode => {
@@ -129,7 +128,7 @@ export const DebugToolbarView = observer((props: DebugToolbarViewProps) => {
129
128
  return (
130
129
  <DebugAction
131
130
  run={doStop}
132
- enabled={typeof state === 'number' && state !== DebugState.Inactive}
131
+ enabled={autorunState !== DebugState.Inactive}
133
132
  icon={'disconnect'}
134
133
  label={localize('debug.action.disattach')}
135
134
  />
@@ -138,7 +137,7 @@ export const DebugToolbarView = observer((props: DebugToolbarViewProps) => {
138
137
  return (
139
138
  <DebugAction
140
139
  run={doStop}
141
- enabled={typeof state === 'number' && state !== DebugState.Inactive}
140
+ enabled={autorunState !== DebugState.Inactive}
142
141
  icon={'stop'}
143
142
  label={localize('debug.action.stop')}
144
143
  />
@@ -155,7 +154,7 @@ export const DebugToolbarView = observer((props: DebugToolbarViewProps) => {
155
154
  return (
156
155
  <DebugAction
157
156
  run={doPause}
158
- enabled={typeof state === 'number' && state === DebugState.Running}
157
+ enabled={autorunState === DebugState.Running}
159
158
  icon={'pause'}
160
159
  label={localize('debug.action.pause')}
161
160
  />
@@ -183,29 +182,32 @@ export const DebugToolbarView = observer((props: DebugToolbarViewProps) => {
183
182
  [],
184
183
  );
185
184
 
186
- const renderSelections = useCallback((sessions: DebugSession[]) => {
187
- if (sessions.length > 1) {
188
- return (
189
- <div className={cls(styles.debug_selection)}>
190
- {isElectronRenderer ? (
191
- <NativeSelect value={currentSessionId} onChange={setCurrentSession}>
192
- {renderSessionOptions(sessions)}
193
- </NativeSelect>
194
- ) : (
195
- <Select
196
- className={cls(styles.debug_selection, styles.special_radius)}
197
- size={props.float ? 'small' : 'default'}
198
- value={currentSessionId}
199
- options={sessions.map((s) => ({ label: s.label, value: s.id }))}
200
- onChange={setCurrentSession}
201
- >
202
- {renderSessionOptions(sessions)}
203
- </Select>
204
- )}
205
- </div>
206
- );
207
- }
208
- }, []);
185
+ const renderSelections = useCallback(
186
+ (sessions: DebugSession[]) => {
187
+ if (sessions.length > 1) {
188
+ return (
189
+ <div className={cls(styles.debug_selection)}>
190
+ {isElectronRenderer ? (
191
+ <NativeSelect value={currentSessionId} onChange={setCurrentSession}>
192
+ {renderSessionOptions(sessions)}
193
+ </NativeSelect>
194
+ ) : (
195
+ <Select
196
+ className={cls(styles.debug_selection, styles.special_radius)}
197
+ size={props.float ? 'small' : 'default'}
198
+ value={currentSessionId}
199
+ options={sessions.map((s) => ({ label: s.label, value: s.id }))}
200
+ onChange={setCurrentSession}
201
+ >
202
+ {renderSessionOptions(sessions)}
203
+ </Select>
204
+ )}
205
+ </div>
206
+ );
207
+ }
208
+ },
209
+ [currentSessionId],
210
+ );
209
211
 
210
212
  const setCurrentSession = useCallback(
211
213
  (event: React.ChangeEvent<HTMLSelectElement> | string | number) => {
@@ -214,66 +216,69 @@ export const DebugToolbarView = observer((props: DebugToolbarViewProps) => {
214
216
  value = (event as React.ChangeEvent<HTMLSelectElement>).target.value;
215
217
  }
216
218
 
217
- if (!sessions) {
219
+ if (!autorunSessions) {
218
220
  return;
219
221
  }
220
- for (const session of sessions) {
222
+ for (const session of autorunSessions) {
221
223
  if (session.id === value) {
222
224
  updateCurrentSession(session);
223
225
  }
224
226
  }
225
227
  },
226
- [updateCurrentSession],
228
+ [autorunSessions, updateCurrentSession],
227
229
  );
228
230
 
229
231
  return (
230
232
  <div className={cls(styles.debug_action_bar, props.className || '')}>
231
- {renderSelections(sessions.filter((s: DebugSession) => !s.parentSession))}
233
+ {renderSelections(autorunSessions.filter((s: DebugSession) => !s.parentSession))}
232
234
  <div className={styles.debug_actions}>
233
- {renderContinue(state)}
235
+ {renderContinue(autorunState)}
234
236
  <DebugAction
235
237
  run={doStepOver}
236
- enabled={typeof state === 'number' && state === DebugState.Stopped}
238
+ enabled={autorunState === DebugState.Stopped}
237
239
  icon={'step'}
238
240
  label={localize('debug.action.step-over')}
239
241
  />
240
242
  <DebugAction
241
243
  run={doStepIn}
242
- enabled={typeof state === 'number' && state === DebugState.Stopped}
244
+ enabled={autorunState === DebugState.Stopped}
243
245
  icon={'step-in'}
244
246
  label={localize('debug.action.step-into')}
245
247
  />
246
248
  <DebugAction
247
249
  run={doStepOut}
248
- enabled={typeof state === 'number' && state === DebugState.Stopped}
250
+ enabled={autorunState === DebugState.Stopped}
249
251
  icon={'step-out'}
250
252
  label={localize('debug.action.step-out')}
251
253
  />
252
254
  <DebugAction
253
255
  run={doRestart}
254
- enabled={typeof state === 'number' && state !== DebugState.Inactive}
256
+ enabled={autorunState !== DebugState.Inactive}
255
257
  icon={'reload'}
256
258
  label={localize('debug.action.restart')}
257
259
  />
258
- {renderStop(state)}
259
- {renderToolBar(currentSession)}
260
+ {renderStop(autorunState)}
261
+ {renderToolBar(autorunCurrentSession)}
260
262
  </div>
261
263
  </div>
262
264
  );
263
- });
265
+ };
264
266
 
265
267
  const DebugPreferenceTopKey = 'debug.toolbar.top';
266
268
  const DebugPreferenceHeightKey = 'debug.toolbar.height';
267
269
 
268
- const FloatDebugToolbarView = observer(() => {
269
- const controller = useInjectable<FloatController>(FloatController);
270
+ const FloatDebugToolbarView = () => {
270
271
  const preference = useInjectable<PreferenceService>(PreferenceService);
271
272
  const { isElectronRenderer } = useInjectable<AppConfig>(AppConfig);
272
273
  const layoutViewSize = useInjectable<LayoutViewSizeConfig>(LayoutViewSizeConfig);
273
- const debugToolbarService = useInjectable<DebugToolbarService>(DebugToolbarService);
274
274
  const styles_debug_toolbar_wrapper = useDesignStyles(styles.debug_toolbar_wrapper, 'debug_toolbar_wrapper');
275
275
  const [toolbarOffsetTop, setToolbarOffsetTop] = useState<number>(0);
276
- const { state } = debugToolbarService;
276
+
277
+ const controller = useInjectable<FloatController>(FloatController);
278
+ const derivedController = useAutorun(controller.state);
279
+
280
+ const debugToolbarService = useInjectable<DebugToolbarService>(DebugToolbarService);
281
+ const state = useAutorun(debugToolbarService.state);
277
282
 
278
283
  useEffect(() => {
279
284
  const disposableCollection = new DisposableCollection();
@@ -311,15 +316,15 @@ const FloatDebugToolbarView = observer(() => {
311
316
  if (state) {
312
317
  return (
313
318
  <div
314
- style={{ pointerEvents: controller.enable ? 'all' : 'none' }}
319
+ style={{ pointerEvents: derivedController.enable ? 'all' : 'none' }}
315
320
  className={styles.debug_toolbar_container}
316
321
  onMouseMove={(e) => controller.onMouseMove(e)}
317
322
  onMouseUp={(e) => controller.onMouseUp()}
318
323
  >
319
324
  <div
320
325
  style={{
321
- transform: `translateX(${controller.x}px) translateY(${
322
- toolbarOffsetTop + controller.line * customHeight
326
+ transform: `translateX(${derivedController.x}px) translateY(${
327
+ toolbarOffsetTop + derivedController.line * customHeight
323
328
  }px)`,
324
329
  height: `${customHeight}px`,
325
330
  }}
@@ -338,15 +343,17 @@ const FloatDebugToolbarView = observer(() => {
338
343
  );
339
344
  }
340
345
 
341
- controller.enable = false;
346
+ controller.setEnable(false);
342
347
  return null;
343
- });
348
+ };
349
+
350
+ export const DebugToolbarOverlayWidget = () => {
351
+ const debugConfigurationService = useInjectable<DebugConfigurationService>(DebugConfigurationService);
352
+ const float = useAutorun(debugConfigurationService.float);
344
353
 
345
- export const DebugToolbarOverlayWidget = observer(() => {
346
- const { float } = useInjectable<DebugConfigurationService>(DebugConfigurationService);
347
354
  if (!float) {
348
355
  return null;
349
356
  }
350
357
 
351
358
  return <FloatDebugToolbarView />;
352
- });
359
+ };
@@ -1,5 +1,4 @@
1
1
  import debounce from 'lodash/debounce';
2
- import { observer } from 'mobx-react-lite';
3
2
  import React from 'react';
4
3
 
5
4
  import { HistoryInputBox, IHistoryInputBoxHandler } from '@opensumi/ide-components/lib/input/HistoryInputBox';
@@ -11,7 +10,7 @@ import styles from './debug-console.module.less';
11
10
  /**
12
11
  * 调试控制台筛选器
13
12
  */
14
- export const DebugConsoleFilterView = observer(() => {
13
+ export const DebugConsoleFilterView = () => {
15
14
  const debugConsoleFilterService = useInjectable<DebugConsoleFilterService>(DebugConsoleFilterService);
16
15
  const [filterValue, setFilterValue] = React.useState<string>('');
17
16
  const [historyApi, setHistoryApi] = React.useState<IHistoryInputBoxHandler>();
@@ -75,4 +74,4 @@ export const DebugConsoleFilterView = observer(() => {
75
74
  ></HistoryInputBox>
76
75
  </div>
77
76
  );
78
- });
77
+ };