Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ed97fc8

Browse files
author
Akos Kitta
committedAug 4, 2022
Replaced the splash screen with a preload.
Added a bare minimum example. Closes #324 Closes #327 Closes #717 Closes #851 Signed-off-by: Akos Kitta <[email protected]>
1 parent 36ac47b commit ed97fc8

File tree

13 files changed

+134
-329
lines changed

13 files changed

+134
-329
lines changed
 

‎.vscode/launch.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"--no-app-auto-install",
2121
"--plugins=local-dir:../plugins",
2222
"--hosted-plugin-inspect=9339",
23-
"--nosplash",
2423
"--content-trace",
2524
"--open-devtools"
2625
],

‎arduino-ide-extension/src/electron-browser/theia/core/electron-window-module.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import {
66
ElectronMainWindowServiceExt,
77
electronMainWindowServiceExtPath,
88
} from '../../../electron-common/electron-main-window-service-ext';
9-
import {
10-
SplashService,
11-
splashServicePath,
12-
} from '../../../electron-common/splash-service';
139
import { ElectronWindowService } from './electron-window-service';
1410

1511
export default new ContainerModule((bind, unbind, isBound, rebind) => {
@@ -24,9 +20,4 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
2420
)
2521
)
2622
.inSingletonScope();
27-
bind(SplashService)
28-
.toDynamicValue(({ container }) =>
29-
ElectronIpcConnectionProvider.createProxy(container, splashServicePath)
30-
)
31-
.inSingletonScope();
3223
});

‎arduino-ide-extension/src/electron-browser/theia/core/electron-window-service.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import {
2-
inject,
3-
injectable,
4-
postConstruct,
5-
} from '@theia/core/shared/inversify';
61
import * as remote from '@theia/core/electron-shared/@electron/remote';
7-
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
82
import {
93
ConnectionStatus,
104
ConnectionStatusService,
115
} from '@theia/core/lib/browser/connection-status-service';
12-
import { ElectronWindowService as TheiaElectronWindowService } from '@theia/core/lib/electron-browser/window/electron-window-service';
13-
import { SplashService } from '../../../electron-common/splash-service';
146
import { nls } from '@theia/core/lib/common';
7+
import { ElectronWindowService as TheiaElectronWindowService } from '@theia/core/lib/electron-browser/window/electron-window-service';
8+
import {
9+
inject,
10+
injectable,
11+
postConstruct,
12+
} from '@theia/core/shared/inversify';
1513
import { WindowServiceExt } from '../../../browser/theia/core/window-service-ext';
1614
import { ElectronMainWindowServiceExt } from '../../../electron-common/electron-main-window-service-ext';
1715

@@ -23,20 +21,14 @@ export class ElectronWindowService
2321
@inject(ConnectionStatusService)
2422
private readonly connectionStatusService: ConnectionStatusService;
2523

26-
@inject(SplashService)
27-
private readonly splashService: SplashService;
28-
29-
@inject(FrontendApplicationStateService)
30-
private readonly appStateService: FrontendApplicationStateService;
31-
3224
@inject(ElectronMainWindowServiceExt)
3325
private readonly mainWindowServiceExt: ElectronMainWindowServiceExt;
3426

3527
@postConstruct()
3628
protected override init(): void {
37-
this.appStateService
38-
.reachedAnyState('initialized_layout')
39-
.then(() => this.splashService.requestClose());
29+
// NOOP
30+
// Does not listen on Theia's `window.zoomLevel` changes.
31+
// TODO: IDE2 must switch to the Theia preferences and drop the custom one.
4032
}
4133

4234
protected shouldUnload(): boolean {

‎arduino-ide-extension/src/electron-common/splash-service.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎arduino-ide-extension/src/electron-main/arduino-electron-main-module.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@ import {
1616
ElectronMainWindowServiceExt,
1717
electronMainWindowServiceExtPath,
1818
} from '../electron-common/electron-main-window-service-ext';
19-
import {
20-
SplashService,
21-
splashServicePath,
22-
} from '../electron-common/splash-service';
2319
import { ElectronMainWindowServiceExtImpl } from './electron-main-window-service-ext-impl';
2420
import { IDEUpdaterImpl } from './ide-updater/ide-updater-impl';
25-
import { SplashServiceImpl } from './splash/splash-service-impl';
2621
import { ElectronMainApplication } from './theia/electron-main-application';
2722
import { ElectronMainWindowServiceImpl } from './theia/electron-main-window-service';
2823
import { TheiaElectronWindow } from './theia/theia-electron-window';
@@ -34,17 +29,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
3429
bind(ElectronMainWindowServiceImpl).toSelf().inSingletonScope();
3530
rebind(ElectronMainWindowService).toService(ElectronMainWindowServiceImpl);
3631

37-
bind(SplashServiceImpl).toSelf().inSingletonScope();
38-
bind(SplashService).toService(SplashServiceImpl);
39-
bind(ElectronConnectionHandler)
40-
.toDynamicValue(
41-
(context) =>
42-
new JsonRpcConnectionHandler(splashServicePath, () =>
43-
context.container.get(SplashService)
44-
)
45-
)
46-
.inSingletonScope();
47-
4832
// IDE updater bindings
4933
bind(IDEUpdaterImpl).toSelf().inSingletonScope();
5034
bind(IDEUpdater).toService(IDEUpdaterImpl);

‎arduino-ide-extension/src/electron-main/splash/splash-screen.ts

Lines changed: 0 additions & 158 deletions
This file was deleted.

‎arduino-ide-extension/src/electron-main/splash/splash-service-impl.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

‎arduino-ide-extension/src/electron-main/splash/static/splash.html

Lines changed: 0 additions & 25 deletions
This file was deleted.
Binary file not shown.

‎arduino-ide-extension/src/electron-main/theia/electron-main-application.ts

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
import { inject, injectable } from '@theia/core/shared/inversify';
1+
import { injectable } from '@theia/core/shared/inversify';
22
import {
33
app,
44
BrowserWindow,
5-
BrowserWindowConstructorOptions,
65
contentTracing,
76
ipcMain,
8-
screen,
97
Event as ElectronEvent,
108
} from '@theia/core/electron-shared/electron';
119
import { fork } from 'child_process';
1210
import { AddressInfo } from 'net';
1311
import { join, dirname } from 'path';
1412
import * as fs from 'fs-extra';
15-
import { initSplashScreen } from '../splash/splash-screen';
1613
import { MaybePromise } from '@theia/core/lib/common/types';
1714
import { ElectronSecurityToken } from '@theia/core/lib/electron-common/electron-token';
1815
import { FrontendApplicationConfig } from '@theia/application-package/lib/application-props';
1916
import {
2017
ElectronMainApplication as TheiaElectronMainApplication,
2118
ElectronMainExecutionParams,
2219
} from '@theia/core/lib/electron-main/electron-main-application';
23-
import { SplashServiceImpl } from '../splash/splash-service-impl';
2420
import { URI } from '@theia/core/shared/vscode-uri';
2521
import { Deferred } from '@theia/core/lib/common/promise-util';
2622
import * as os from '@theia/core/lib/common/os';
@@ -42,14 +38,6 @@ interface WorkspaceOptions {
4238

4339
const WORKSPACES = 'workspaces';
4440

45-
/**
46-
* Purely a dev thing. If you start the app with the `--nosplash` argument,
47-
* then you won't have the splash screen (which is always on top :confused:) and can debug the app at startup.
48-
* Note: if you start the app from VS Code with the `App (Electron)` config, the splash screen will be disabled.
49-
*/
50-
const APP_STARTED_WITH_NOSPLASH =
51-
typeof process !== 'undefined' && process.argv.indexOf('--nosplash') !== -1;
52-
5341
/**
5442
* If the app is started with `--open-devtools` argument, the `Dev Tools` will be opened.
5543
*/
@@ -70,9 +58,6 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
7058
private _firstWindowId: number | undefined;
7159
private openFilePromise = new Deferred();
7260

73-
@inject(SplashServiceImpl)
74-
private readonly splashService: SplashServiceImpl;
75-
7661
override async start(config: FrontendApplicationConfig): Promise<void> {
7762
// Explicitly set the app name to have better menu items on macOS. ("About", "Hide", and "Quit")
7863
// See: https://github.com/electron-userland/electron-builder/issues/2468
@@ -289,69 +274,10 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
289274
super.onSecondInstance(event, argv, cwd);
290275
}
291276

292-
/**
293-
* Use this rather than creating `BrowserWindow` instances from scratch, since some security parameters need to be set, this method will do it.
294-
*
295-
* @param options
296-
*/
297277
override async createWindow(
298278
asyncOptions: MaybePromise<TheiaBrowserWindowOptions> = this.getDefaultTheiaWindowOptions()
299279
): Promise<BrowserWindow> {
300-
let options = await asyncOptions;
301-
options = this.avoidOverlap(options);
302-
let electronWindow: BrowserWindow | undefined;
303-
if (this.windows.size || APP_STARTED_WITH_NOSPLASH) {
304-
electronWindow = await this.doCreateWindow(options);
305-
} else {
306-
const { bounds } = screen.getDisplayNearestPoint(
307-
screen.getCursorScreenPoint()
308-
);
309-
const splashHeight = 450;
310-
const splashWidth = 600;
311-
const splashY = Math.floor(bounds.y + (bounds.height - splashHeight) / 2);
312-
const splashX = Math.floor(bounds.x + (bounds.width - splashWidth) / 2);
313-
const splashScreenOpts: BrowserWindowConstructorOptions = {
314-
height: splashHeight,
315-
width: splashWidth,
316-
x: splashX,
317-
y: splashY,
318-
transparent: true,
319-
alwaysOnTop: true,
320-
focusable: false,
321-
minimizable: false,
322-
maximizable: false,
323-
hasShadow: false,
324-
resizable: false,
325-
};
326-
electronWindow = await initSplashScreen(
327-
{
328-
windowOpts: options,
329-
templateUrl: join(
330-
__dirname,
331-
'..',
332-
'..',
333-
'..',
334-
'src',
335-
'electron-main',
336-
'splash',
337-
'static',
338-
'splash.html'
339-
),
340-
delay: 0,
341-
minVisible: 2000,
342-
splashScreenOpts,
343-
},
344-
(windowOptions) => this.doCreateWindow(windowOptions),
345-
this.splashService.onCloseRequested
346-
);
347-
}
348-
return electronWindow;
349-
}
350-
351-
private async doCreateWindow(
352-
options: TheiaBrowserWindowOptions
353-
): Promise<BrowserWindow> {
354-
const electronWindow = await super.createWindow(options);
280+
const electronWindow = await super.createWindow(asyncOptions);
355281
if (APP_STARTED_WITH_DEV_TOOLS) {
356282
electronWindow.webContents.openDevTools();
357283
}

‎electron-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
},
6262
"generator": {
6363
"config": {
64-
"preloadTemplate": "<div class='theia-preload' style='background-color: rgb(237, 241, 242);'></div>"
64+
"preloadTemplate": "./resources/preload.html"
6565
}
6666
}
6767
}

‎electron-app/patch/frontend/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ if (!window[ThemeServiceSymbol]) {
9292
arduinoLightTheme
9393
);
9494
themeService.startupTheme();
95-
themeService.setCurrentTheme(defaultTheme);
95+
// themeService.setCurrentTheme(defaultTheme); // TODO: check if window.localStorage.getItem('theme') === undefined, then set
9696
window[ThemeServiceSymbol] = themeService;
9797
}
9898

‎electron-app/resources/preload.html

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<style>
6+
/* The colors are hard-coded and based on the `editor.background` and `editor.foreground` values from `./arduino-ide-extension/src/browser/data/default.color-theme.json` */
7+
@media (prefers-color-scheme: light) {
8+
html {
9+
background: #ffffff;
10+
color: #4e5b61;
11+
}
12+
}
13+
14+
/* The colors are hard-coded and based on the `editor.background` and `editor.foreground` values from `./arduino-ide-extension/src/browser/data/dark.color-theme.json` */
15+
@media (prefers-color-scheme: dark) {
16+
html {
17+
background: #1f272a;
18+
color: #dae3e3;
19+
}
20+
}
21+
22+
.theia-preload {
23+
position: absolute;
24+
top: 0;
25+
left: 0;
26+
right: 0;
27+
bottom: 0;
28+
29+
/* Above styles copied from https://github.com/eclipse-theia/theia/blob/5aeef6c0c683b4e91713ab736957e6655b486adc/packages/core/src/browser/style/index.css#L147-L161 */
30+
/* Otherwise, there is a flickering when Theia's CSS loads. */
31+
32+
background-image: none;
33+
}
34+
35+
.theia-preload::after {
36+
/* remove default loading animation */
37+
content: none;
38+
}
39+
40+
.spinner-container {
41+
display: flex;
42+
flex-direction: center;
43+
align-self: center;
44+
justify-content: center;
45+
height: 100vh;
46+
width: 100vw;
47+
}
48+
49+
.custom-spinner {
50+
align-self: center;
51+
}
52+
53+
.custom-spinner svg {
54+
width: 16vw;
55+
height: 16vh;
56+
animation-delay: 0;
57+
animation-duration: 2s;
58+
animation-iteration-count: infinite;
59+
animation-name: preload-spinner;
60+
animation-timing-function: ease;
61+
}
62+
63+
@keyframes preload-spinner {
64+
0% {
65+
transform: scale(1.0);
66+
}
67+
68+
50% {
69+
transform: scale(0.8);
70+
}
71+
72+
100% {
73+
transform: scale(1.0);
74+
}
75+
}
76+
</style>
77+
</head>
78+
79+
<body>
80+
<div class='spinner-container'>
81+
<div class='custom-spinner'>
82+
<svg id="spinner" xmlns="http://www.w3.org/2000/svg" width="2499" height="2500"
83+
viewBox="0 0 1372.201 1372.684">
84+
<path fill="#00979D" stroke="#81C9CB" stroke-width=".932" stroke-miterlimit="10"
85+
d="M1371.701 686.024c0 378.658-306.972 685.605-685.549 685.605C307.451 1371.629.5 1064.682.5 686.024.5 307.455 307.451.483 686.152.483c378.594.001 685.549 306.972 685.549 685.541z" />
86+
<linearGradient id="a" gradientUnits="userSpaceOnUse" x1="-16.3" y1="16.071" x2="1354.901" y2="16.071"
87+
gradientTransform="matrix(1 0 0 -1 16.8 702.696)">
88+
<stop offset=".117" stop-color="#fff" stop-opacity="0" />
89+
<stop offset=".252" stop-color="#c0d1d3" stop-opacity=".153" />
90+
<stop offset=".387" stop-color="#91b3b7" stop-opacity=".306" />
91+
<stop offset=".52" stop-color="#6d9fa3" stop-opacity=".457" />
92+
<stop offset=".65" stop-color="#4d9195" stop-opacity=".604" />
93+
<stop offset=".776" stop-color="#30888b" stop-opacity=".746" />
94+
<stop offset=".895" stop-color="#148386" stop-opacity=".881" />
95+
<stop offset="1" stop-color="#008184" />
96+
</linearGradient>
97+
<linearGradient id="b" gradientUnits="userSpaceOnUse" x1="-16.8" y1="16.071" x2="1355.401" y2="16.071"
98+
gradientTransform="matrix(1 0 0 -1 16.8 702.696)">
99+
<stop offset="0" stop-color="#fff" stop-opacity="0" />
100+
<stop offset=".153" stop-color="#c0d1d3" stop-opacity=".153" />
101+
<stop offset=".306" stop-color="#91b3b7" stop-opacity=".306" />
102+
<stop offset=".457" stop-color="#6d9fa3" stop-opacity=".457" />
103+
<stop offset=".604" stop-color="#4d9195" stop-opacity=".604" />
104+
<stop offset=".746" stop-color="#30888b" stop-opacity=".746" />
105+
<stop offset=".881" stop-color="#148386" stop-opacity=".881" />
106+
<stop offset="1" stop-color="#008184" />
107+
</linearGradient>
108+
<path opacity=".5" fill="url(#a)" stroke="url(#b)" stroke-miterlimit="10"
109+
d="M1371.701 686.595c0 378.65-306.972 685.606-685.549 685.606C307.451 1372.201.5 1065.23.5 686.595.5 308.019 307.451 1.048 686.152 1.048c378.594.016 685.549 306.97 685.549 685.547z" />
110+
<g fill="#FFF">
111+
<path
112+
d="M947.959 931.196c-12.909 0-26.127-.929-39.127-2.864-108.978-15.554-181.848-93.822-222.665-153.989-40.946 60.166-113.811 138.512-222.74 154.045a275.864 275.864 0 0 1-39.133 2.785c-67.753 0-131.358-25.217-179.201-71.003-48.299-46.165-74.951-108.114-74.951-174.171 0-66.14 26.651-128.004 75.021-174.253 47.797-45.793 111.449-70.936 179.231-70.936 12.918 0 26.067.928 39.023 2.783 108.932 15.535 181.794 93.813 222.743 153.99 40.825-60.177 113.689-138.432 222.658-153.99 13-1.863 26.148-2.783 39.066-2.783 67.753 0 131.401 25.208 179.197 70.936 48.345 46.249 74.937 108.113 74.937 174.253 0 66.057-26.524 128.006-74.868 174.171-47.881 45.785-111.434 71.026-179.191 71.026M734.42 686.024c21.283 40.534 84.067 141.676 186.692 156.375 8.984 1.236 18.028 1.923 26.839 1.923 92.185 0 167.225-71.002 167.225-158.322s-75.023-158.321-167.291-158.321c-8.812 0-17.853.629-26.753 1.921-102.644 14.664-165.428 115.806-186.712 156.424M424.393 527.702c-92.308 0-167.36 70.998-167.36 158.321 0 87.305 75.021 158.322 167.245 158.322 8.852 0 17.897-.688 26.879-1.922 102.629-14.697 165.394-115.783 186.689-156.375-21.237-40.535-84.061-141.761-186.689-156.376-8.877-1.341-17.945-1.97-26.764-1.97" />
113+
<path
114+
d="M354.37 662.051h152.625v49.181H354.37zM1016.484 662.051h-51.671v-51.747h-49.348v51.747h-51.648v49.181h51.648v51.737h49.348v-51.737h51.671z" />
115+
</g>
116+
</svg>
117+
</div>
118+
</div>
119+
</body>
120+
121+
</html>

0 commit comments

Comments
 (0)
Please sign in to comment.