Skip to content

Commit bd399eb

Browse files
author
Akos Kitta
committed
Update package index on 3rd party URLs change.
Closes #637 Closes #906 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 5499c25 commit bd399eb

32 files changed

+639
-453
lines changed

arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ import { CoreErrorHandler } from './contributions/core-error-handler';
302302
import { CompilerErrors } from './contributions/compiler-errors';
303303
import { WidgetManager } from './theia/core/widget-manager';
304304
import { WidgetManager as TheiaWidgetManager } from '@theia/core/lib/browser/widget-manager';
305+
import { IndexesUpdateProgress } from './contributions/indexes-update-progress';
305306

306307
MonacoThemingService.register({
307308
id: 'arduino-theme',
@@ -698,6 +699,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
698699
Contribution.configure(bind, PlotterFrontendContribution);
699700
Contribution.configure(bind, Format);
700701
Contribution.configure(bind, CompilerErrors);
702+
Contribution.configure(bind, IndexesUpdateProgress);
701703

702704
// Disabled the quick-pick customization from Theia when multiple formatters are available.
703705
// Use the default VS Code behavior, and pick the first one. In the IDE2, clang-format has `exclusive` selectors.

arduino-ide-extension/src/browser/boards/boards-config.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class BoardsConfig extends React.Component<
113113
);
114114
}
115115
}),
116-
this.props.notificationCenter.onAttachedBoardsChanged((event) =>
116+
this.props.notificationCenter.onAttachedBoardsDidChange((event) =>
117117
this.updatePorts(
118118
event.newState.ports,
119119
AttachedBoardsChangeEvent.diff(event).detached.ports
@@ -126,19 +126,19 @@ export class BoardsConfig extends React.Component<
126126
);
127127
}
128128
),
129-
this.props.notificationCenter.onPlatformInstalled(() =>
129+
this.props.notificationCenter.onPlatformDidInstall(() =>
130130
this.updateBoards(this.state.query)
131131
),
132-
this.props.notificationCenter.onPlatformUninstalled(() =>
132+
this.props.notificationCenter.onPlatformDidUninstall(() =>
133133
this.updateBoards(this.state.query)
134134
),
135-
this.props.notificationCenter.onIndexUpdated(() =>
135+
this.props.notificationCenter.onIndexDidUpdate(() =>
136136
this.updateBoards(this.state.query)
137137
),
138-
this.props.notificationCenter.onDaemonStarted(() =>
138+
this.props.notificationCenter.onDaemonDidStart(() =>
139139
this.updateBoards(this.state.query)
140140
),
141-
this.props.notificationCenter.onDaemonStopped(() =>
141+
this.props.notificationCenter.onDaemonDidStop(() =>
142142
this.setState({ searchResults: [] })
143143
),
144144
this.props.onFilteredTextDidChangeEvent((query) =>

arduino-ide-extension/src/browser/boards/boards-data-store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class BoardsDataStore implements FrontendApplicationContribution {
3333
protected readonly onChangedEmitter = new Emitter<void>();
3434

3535
onStart(): void {
36-
this.notificationCenter.onPlatformInstalled(async ({ item }) => {
36+
this.notificationCenter.onPlatformDidInstall(async ({ item }) => {
3737
let shouldFireChanged = false;
3838
for (const fqbn of item.boards
3939
.map(({ fqbn }) => fqbn)

arduino-ide-extension/src/browser/boards/boards-list-widget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export class BoardsListWidget extends ListWidget<BoardsPackage> {
3333
protected override init(): void {
3434
super.init();
3535
this.toDispose.pushAll([
36-
this.notificationCenter.onPlatformInstalled(() =>
36+
this.notificationCenter.onPlatformDidInstall(() =>
3737
this.refresh(undefined)
3838
),
39-
this.notificationCenter.onPlatformUninstalled(() =>
39+
this.notificationCenter.onPlatformDidUninstall(() =>
4040
this.refresh(undefined)
4141
),
4242
]);

arduino-ide-extension/src/browser/boards/boards-service-provider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
7474
readonly onAvailablePortsChanged = this.onAvailablePortsChangedEmitter.event;
7575

7676
onStart(): void {
77-
this.notificationCenter.onAttachedBoardsChanged(
77+
this.notificationCenter.onAttachedBoardsDidChange(
7878
this.notifyAttachedBoardsChanged.bind(this)
7979
);
80-
this.notificationCenter.onPlatformInstalled(
80+
this.notificationCenter.onPlatformDidInstall(
8181
this.notifyPlatformInstalled.bind(this)
8282
);
83-
this.notificationCenter.onPlatformUninstalled(
83+
this.notificationCenter.onPlatformDidUninstall(
8484
this.notifyPlatformUninstalled.bind(this)
8585
);
8686

arduino-ide-extension/src/browser/contributions/board-selection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ PID: ${PID}`;
101101
}
102102

103103
override onStart(): void {
104-
this.notificationCenter.onPlatformInstalled(() => this.updateMenus());
105-
this.notificationCenter.onPlatformUninstalled(() => this.updateMenus());
104+
this.notificationCenter.onPlatformDidInstall(() => this.updateMenus());
105+
this.notificationCenter.onPlatformDidUninstall(() => this.updateMenus());
106106
this.boardsServiceProvider.onBoardsConfigChanged(() => this.updateMenus());
107107
this.boardsServiceProvider.onAvailableBoardsChanged(() =>
108108
this.updateMenus()

arduino-ide-extension/src/browser/contributions/debug.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ export class Debug extends SketchContribution {
8383
this.boardsServiceProvider.onBoardsConfigChanged(({ selectedBoard }) =>
8484
this.refreshState(selectedBoard)
8585
);
86-
this.notificationCenter.onPlatformInstalled(() => this.refreshState());
87-
this.notificationCenter.onPlatformUninstalled(() => this.refreshState());
86+
this.notificationCenter.onPlatformDidInstall(() => this.refreshState());
87+
this.notificationCenter.onPlatformDidUninstall(() => this.refreshState());
8888
}
8989

9090
override onReady(): MaybePromise<void> {

arduino-ide-extension/src/browser/contributions/examples.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ export class LibraryExamples extends Examples {
202202
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
203203

204204
override onStart(): void {
205-
this.notificationCenter.onLibraryInstalled(() => this.register());
206-
this.notificationCenter.onLibraryUninstalled(() => this.register());
205+
this.notificationCenter.onLibraryDidInstall(() => this.register());
206+
this.notificationCenter.onLibraryDidUninstall(() => this.register());
207207
}
208208

209209
override async onReady(): Promise<void> {

arduino-ide-extension/src/browser/contributions/include-library.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export class IncludeLibrary extends SketchContribution {
4949
this.boardsServiceClient.onBoardsConfigChanged(() =>
5050
this.updateMenuActions()
5151
);
52-
this.notificationCenter.onLibraryInstalled(() => this.updateMenuActions());
53-
this.notificationCenter.onLibraryUninstalled(() =>
52+
this.notificationCenter.onLibraryDidInstall(() => this.updateMenuActions());
53+
this.notificationCenter.onLibraryDidUninstall(() =>
5454
this.updateMenuActions()
5555
);
5656
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { Progress } from '@theia/core/lib/common/message-service-protocol';
2+
import { ProgressService } from '@theia/core/lib/common/progress-service';
3+
import { inject, injectable } from '@theia/core/shared/inversify';
4+
import { ProgressMessage } from '../../common/protocol';
5+
import { NotificationCenter } from '../notification-center';
6+
import { Contribution } from './contribution';
7+
8+
@injectable()
9+
export class IndexesUpdateProgress extends Contribution {
10+
@inject(NotificationCenter)
11+
private readonly notificationCenter: NotificationCenter;
12+
@inject(ProgressService)
13+
private readonly progressService: ProgressService;
14+
private currentProgress:
15+
| (Progress & Readonly<{ progressId: string }>)
16+
| undefined;
17+
18+
override onStart(): void {
19+
this.notificationCenter.onIndexWillUpdate((progressId) =>
20+
this.getOrCreateProgress(progressId)
21+
);
22+
this.notificationCenter.onIndexUpdateDidProgress((progress) => {
23+
this.getOrCreateProgress(progress).then((delegate) =>
24+
delegate.report(progress)
25+
);
26+
});
27+
this.notificationCenter.onIndexDidUpdate((progressId) => {
28+
if (this.currentProgress) {
29+
if (this.currentProgress.progressId !== progressId) {
30+
console.warn(
31+
`Mismatching progress IDs. Expected ${progressId}, got ${this.currentProgress.progressId}. Canceling anyway.`
32+
);
33+
}
34+
this.currentProgress.cancel();
35+
this.currentProgress = undefined;
36+
}
37+
});
38+
}
39+
40+
private async getOrCreateProgress(
41+
progressOrId: ProgressMessage | string
42+
): Promise<Progress & { progressId: string }> {
43+
const progressId = ProgressMessage.is(progressOrId)
44+
? progressOrId.progressId
45+
: progressOrId;
46+
if (
47+
this.currentProgress &&
48+
this.currentProgress.progressId === progressId
49+
) {
50+
return this.currentProgress;
51+
}
52+
if (this.currentProgress) {
53+
this.currentProgress.cancel();
54+
}
55+
this.currentProgress = undefined;
56+
const progress = await this.progressService.showProgress({
57+
text: 'Arduino',
58+
// TODO: IDE2 could show the progress in `notification`, like the platform/library install and uninstall.
59+
// However, the index update progress responses are not much helpful. They cannot provide a fine-grain progress.
60+
// So IDE2 could report two total works only: index update and library index update.
61+
// See here an example: https://github.com/arduino/arduino-ide/issues/906#issuecomment-1171145630
62+
// Due to this, IDE2 shows a spinner on the status bar.
63+
options: { location: 'window' },
64+
});
65+
if (ProgressMessage.is(progressOrId)) {
66+
progress.report(progressOrId); // if the client has missed the `willStart` event, report the progress immediately.
67+
}
68+
this.currentProgress = { ...progress, progressId };
69+
return this.currentProgress;
70+
}
71+
}

0 commit comments

Comments
 (0)