Skip to content

Commit 2e4719a

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 9538598 commit 2e4719a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+911
-572
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ import { MonacoTextModelService } from './theia/monaco/monaco-text-model-service
164164
import { ResponseServiceImpl } from './response-service-impl';
165165
import {
166166
ResponseService,
167-
ResponseServiceArduino,
167+
ResponseServiceClient,
168168
ResponseServicePath,
169169
} from '../common/protocol/response-service';
170170
import { NotificationCenter } from './notification-center';
@@ -302,6 +302,8 @@ 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';
306+
import { Daemon } from './contributions/daemon';
305307

306308
MonacoThemingService.register({
307309
id: 'arduino-theme',
@@ -698,6 +700,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
698700
Contribution.configure(bind, PlotterFrontendContribution);
699701
Contribution.configure(bind, Format);
700702
Contribution.configure(bind, CompilerErrors);
703+
Contribution.configure(bind, IndexesUpdateProgress);
704+
Contribution.configure(bind, Daemon);
701705

702706
// Disabled the quick-pick customization from Theia when multiple formatters are available.
703707
// Use the default VS Code behavior, and pick the first one. In the IDE2, clang-format has `exclusive` selectors.
@@ -719,7 +723,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
719723
});
720724

721725
bind(ResponseService).toService(ResponseServiceImpl);
722-
bind(ResponseServiceArduino).toService(ResponseServiceImpl);
726+
bind(ResponseServiceClient).toService(ResponseServiceImpl);
723727

724728
bind(NotificationCenter).toSelf().inSingletonScope();
725729
bind(FrontendApplicationContribution).toService(NotificationCenter);

arduino-ide-extension/src/browser/boards/boards-auto-installer.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '../../common/protocol/boards-service';
99
import { BoardsServiceProvider } from './boards-service-provider';
1010
import { BoardsConfig } from './boards-config';
11-
import { Installable, ResponseServiceArduino } from '../../common/protocol';
11+
import { Installable, ResponseServiceClient } from '../../common/protocol';
1212
import { BoardsListWidgetFrontendContribution } from './boards-widget-frontend-contribution';
1313
import { nls } from '@theia/core/lib/common';
1414

@@ -27,8 +27,8 @@ export class BoardsAutoInstaller implements FrontendApplicationContribution {
2727
@inject(BoardsServiceProvider)
2828
protected readonly boardsServiceClient: BoardsServiceProvider;
2929

30-
@inject(ResponseServiceArduino)
31-
protected readonly responseService: ResponseServiceArduino;
30+
@inject(ResponseServiceClient)
31+
protected readonly responseService: ResponseServiceClient;
3232

3333
@inject(BoardsListWidgetFrontendContribution)
3434
protected readonly boardsManagerFrontendContribution: BoardsListWidgetFrontendContribution;

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

+6-6
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

+1-1
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

+2-2
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

+3-3
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/add-zip-library.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ArduinoMenus } from '../menu/arduino-menus';
77
import {
88
Installable,
99
LibraryService,
10-
ResponseServiceArduino,
10+
ResponseServiceClient,
1111
} from '../../common/protocol';
1212
import {
1313
SketchContribution,
@@ -22,8 +22,8 @@ export class AddZipLibrary extends SketchContribution {
2222
@inject(EnvVariablesServer)
2323
protected readonly envVariableServer: EnvVariablesServer;
2424

25-
@inject(ResponseServiceArduino)
26-
protected readonly responseService: ResponseServiceArduino;
25+
@inject(ResponseServiceClient)
26+
protected readonly responseService: ResponseServiceClient;
2727

2828
@inject(LibraryService)
2929
protected readonly libraryService: LibraryService;

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

+2-2
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()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { nls } from '@theia/core';
2+
import { inject, injectable } from '@theia/core/shared/inversify';
3+
import { ArduinoDaemon } from '../../common/protocol';
4+
import { Contribution, Command, CommandRegistry } from './contribution';
5+
6+
@injectable()
7+
export class Daemon extends Contribution {
8+
@inject(ArduinoDaemon)
9+
private readonly daemon: ArduinoDaemon;
10+
11+
override registerCommands(registry: CommandRegistry): void {
12+
registry.registerCommand(Daemon.Commands.START_DAEMON, {
13+
execute: () => this.daemon.start(),
14+
});
15+
registry.registerCommand(Daemon.Commands.STOP_DAEMON, {
16+
execute: () => this.daemon.stop(),
17+
});
18+
registry.registerCommand(Daemon.Commands.RESTART_DAEMON, {
19+
execute: () => this.daemon.restart(),
20+
});
21+
}
22+
}
23+
export namespace Daemon {
24+
export namespace Commands {
25+
export const START_DAEMON: Command = {
26+
id: 'arduino-start-daemon',
27+
label: nls.localize('arduino/daemon/start', 'Start Daemon'),
28+
category: 'Arduino',
29+
};
30+
export const STOP_DAEMON: Command = {
31+
id: 'arduino-stop-daemon',
32+
label: nls.localize('arduino/daemon/stop', 'Stop Daemon'),
33+
category: 'Arduino',
34+
};
35+
export const RESTART_DAEMON: Command = {
36+
id: 'arduino-restart-daemon',
37+
label: nls.localize('arduino/daemon/restart', 'Restart Daemon'),
38+
category: 'Arduino',
39+
};
40+
}
41+
}

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

+2-2
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

+2-2
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

+2-2
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
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
this.cancelProgress(progressId);
29+
});
30+
this.notificationCenter.onIndexUpdateDidFail(({ progressId, message }) => {
31+
this.cancelProgress(progressId);
32+
this.messageService.error(message);
33+
});
34+
}
35+
36+
private async getOrCreateProgress(
37+
progressOrId: ProgressMessage | string
38+
): Promise<Progress & { progressId: string }> {
39+
const progressId = ProgressMessage.is(progressOrId)
40+
? progressOrId.progressId
41+
: progressOrId;
42+
if (
43+
this.currentProgress &&
44+
this.currentProgress.progressId === progressId
45+
) {
46+
return this.currentProgress;
47+
}
48+
if (this.currentProgress) {
49+
this.currentProgress.cancel();
50+
}
51+
this.currentProgress = undefined;
52+
const progress = await this.progressService.showProgress({
53+
text: '',
54+
options: { location: 'notification' },
55+
});
56+
if (ProgressMessage.is(progressOrId)) {
57+
progress.report(progressOrId);
58+
}
59+
this.currentProgress = { ...progress, progressId };
60+
return this.currentProgress;
61+
}
62+
63+
private cancelProgress(progressId: string) {
64+
if (this.currentProgress) {
65+
if (this.currentProgress.progressId !== progressId) {
66+
console.warn(
67+
`Mismatching progress IDs. Expected ${progressId}, got ${this.currentProgress.progressId}. Canceling anyway.`
68+
);
69+
}
70+
this.currentProgress.cancel();
71+
this.currentProgress = undefined;
72+
}
73+
}
74+
}

arduino-ide-extension/src/browser/contributions/open-recent-sketch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class OpenRecentSketch extends SketchContribution {
3636
protected toDisposeBeforeRegister = new Map<string, DisposableCollection>();
3737

3838
override onStart(): void {
39-
this.notificationCenter.onRecentSketchesChanged(({ sketches }) =>
39+
this.notificationCenter.onRecentSketchesDidChange(({ sketches }) =>
4040
this.refreshMenu(sketches)
4141
);
4242
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export class LibraryListWidget extends ListWidget<LibraryPackage> {
4141
protected override init(): void {
4242
super.init();
4343
this.toDispose.pushAll([
44-
this.notificationCenter.onLibraryInstalled(() => this.refresh(undefined)),
45-
this.notificationCenter.onLibraryUninstalled(() =>
44+
this.notificationCenter.onLibraryDidInstall(() => this.refresh(undefined)),
45+
this.notificationCenter.onLibraryDidUninstall(() =>
4646
this.refresh(undefined)
4747
),
4848
]);

0 commit comments

Comments
 (0)