Skip to content

Commit 493ddc2

Browse files
committed
Initial draft for restoring browser app
1 parent 9ab87bf commit 493ddc2

13 files changed

+214
-3
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
'.browser_modules/*',
1515
'docs/*',
1616
'scripts/*',
17+
'browser-app/*',
1718
'electron-app/lib/*',
1819
'electron-app/src-gen/*',
1920
'electron-app/gen-webpack*.js',

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

.vscode/launch.json

+31
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,37 @@
8080
"port": 9222,
8181
"webRoot": "${workspaceFolder}/electron-app"
8282
},
83+
{
84+
"type": "node",
85+
"request": "launch",
86+
"name": "App (Browser)",
87+
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
88+
"args": [
89+
"--hostname=0.0.0.0",
90+
"--port=3000",
91+
"--no-cluster",
92+
"--no-app-auto-install",
93+
"--plugins=local-dir:plugins"
94+
],
95+
"windows": {
96+
"env": {
97+
"NODE_ENV": "development",
98+
"NODE_PRESERVE_SYMLINKS": "1"
99+
}
100+
},
101+
"env": {
102+
"NODE_ENV": "development"
103+
},
104+
"sourceMaps": true,
105+
"outFiles": [
106+
"${workspaceRoot}/browser-app/src-gen/backend/*.js",
107+
"${workspaceRoot}/browser-app/lib/**/*.js",
108+
"${workspaceRoot}/arduino-ide-extension/lib/**/*.js"
109+
],
110+
"smartStep": true,
111+
"internalConsoleOptions": "openOnSessionStart",
112+
"outputCapture": "std"
113+
},
83114
{
84115
"type": "node",
85116
"request": "launch",

.vscode/tasks.json

+30
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
"clear": false
1616
}
1717
},
18+
{
19+
"label": "Arduino IDE - Start Browser App",
20+
"type": "shell",
21+
"command": "yarn --cwd ./browser-app start",
22+
"group": "build",
23+
"presentation": {
24+
"reveal": "always",
25+
"panel": "new",
26+
"clear": true
27+
}
28+
},
1829
{
1930
"label": "Watch Extension",
2031
"type": "shell",
@@ -26,6 +37,17 @@
2637
"clear": false
2738
}
2839
},
40+
{
41+
"label": "Arduino IDE - Watch Browser App",
42+
"type": "shell",
43+
"command": "yarn --cwd ./browser-app watch",
44+
"group": "build",
45+
"presentation": {
46+
"reveal": "always",
47+
"panel": "new",
48+
"clear": false
49+
}
50+
},
2951
{
3052
"label": "Watch App",
3153
"type": "shell",
@@ -37,6 +59,14 @@
3759
"clear": false
3860
}
3961
},
62+
{
63+
"label": "Arduino IDE - Watch All [Browser]",
64+
"type": "shell",
65+
"dependsOn": [
66+
"Arduino IDE - Watch IDE Extension",
67+
"Arduino IDE - Watch Browser App"
68+
]
69+
},
4070
{
4171
"label": "Watch All",
4272
"type": "shell",

arduino-ide-extension/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@
158158
"frontend": "lib/browser/arduino-ide-frontend-module"
159159
},
160160
{
161+
"frontend": "lib/browser/theia/core/browser-menu-module",
161162
"frontendElectron": "lib/electron-browser/theia/core/electron-menu-module"
162163
},
163164
{
165+
"frontend": "lib/browser/theia/core/browser-window-module",
164166
"frontendElectron": "lib/electron-browser/theia/core/electron-window-module"
165167
},
166168
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { injectable } from '@theia/core/shared/inversify';
2+
import {
3+
BrowserMainMenuFactory as TheiaBrowserMainMenuFactory,
4+
MenuBarWidget,
5+
} from '@theia/core/lib/browser/menu/browser-menu-plugin';
6+
import { MainMenuManager } from '../../../common/main-menu-manager';
7+
8+
@injectable()
9+
export class BrowserMainMenuFactory
10+
extends TheiaBrowserMainMenuFactory
11+
implements MainMenuManager
12+
{
13+
protected menuBar: MenuBarWidget | undefined;
14+
15+
override createMenuBar(): MenuBarWidget {
16+
this.menuBar = super.createMenuBar();
17+
return this.menuBar;
18+
}
19+
20+
update(): void {
21+
if (this.menuBar) {
22+
this.menuBar.clearMenus();
23+
this.fillMenuBar(this.menuBar);
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import '../../../../src/browser/style/browser-menu.css';
2+
import { ContainerModule } from '@theia/core/shared/inversify';
3+
import {
4+
BrowserMenuBarContribution,
5+
BrowserMainMenuFactory as TheiaBrowserMainMenuFactory,
6+
} from '@theia/core/lib/browser/menu/browser-menu-plugin';
7+
import { MainMenuManager } from '../../../common/main-menu-manager';
8+
import { ArduinoMenuContribution } from './browser-menu-plugin';
9+
import { BrowserMainMenuFactory } from './browser-main-menu-factory';
10+
11+
export default new ContainerModule((bind, unbind, isBound, rebind) => {
12+
bind(BrowserMainMenuFactory).toSelf().inSingletonScope();
13+
bind(MainMenuManager).toService(BrowserMainMenuFactory);
14+
rebind(TheiaBrowserMainMenuFactory).toService(BrowserMainMenuFactory);
15+
rebind(BrowserMenuBarContribution)
16+
.to(ArduinoMenuContribution)
17+
.inSingletonScope();
18+
});

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

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { DefaultWindowService as TheiaDefaultWindowService } from '@theia/core/lib/browser/window/default-window-service';
2+
import { injectable } from '@theia/core/shared/inversify';
3+
import { WindowServiceExt } from './window-service-ext';
4+
5+
@injectable()
6+
export class DefaultWindowService
7+
extends TheiaDefaultWindowService
8+
implements WindowServiceExt
9+
{
10+
/**
11+
* The default implementation always resolves to `true`.
12+
* IDE2 does not use it. It's currently an electron-only app.
13+
*/
14+
async isFirstWindow(): Promise<boolean> {
15+
return true;
16+
}
17+
}

browser-app/package.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"private": true,
3+
"name": "browser-app",
4+
"version": "2.0.0",
5+
"license": "AGPL-3.0-or-later",
6+
"dependencies": {
7+
"@theia/core": "1.41.0",
8+
"@theia/debug": "1.41.0",
9+
"@theia/editor": "1.41.0",
10+
"@theia/file-search": "1.41.0",
11+
"@theia/filesystem": "1.41.0",
12+
"@theia/keymaps": "1.41.0",
13+
"@theia/messages": "1.41.0",
14+
"@theia/monaco": "1.41.0",
15+
"@theia/navigator": "1.41.0",
16+
"@theia/plugin-ext": "1.41.0",
17+
"@theia/plugin-ext-vscode": "1.41.0",
18+
"@theia/preferences": "1.41.0",
19+
"@theia/process": "1.41.0",
20+
"@theia/terminal": "1.41.0",
21+
"@theia/workspace": "1.41.0",
22+
"arduino-ide-extension": "2.3.5"
23+
},
24+
"devDependencies": {
25+
"@theia/cli": "1.41.0"
26+
},
27+
"scripts": {
28+
"prepare": "theia build --mode development",
29+
"start": "theia start --plugins=local-dir:../plugins",
30+
"watch": "theia build --watch --mode development"
31+
},
32+
"theia": {
33+
"frontend": {
34+
"config": {
35+
"applicationName": "Arduino IDE",
36+
"defaultTheme": "arduino-theme",
37+
"preferences": {
38+
"files.autoSave": "afterDelay",
39+
"editor.minimap.enabled": false,
40+
"editor.tabSize": 2,
41+
"editor.scrollBeyondLastLine": false,
42+
"editor.quickSuggestions": {
43+
"other": false,
44+
"comments": false,
45+
"strings": false
46+
},
47+
"breadcrumbs.enabled": false
48+
}
49+
}
50+
},
51+
"backend": {
52+
"config": {
53+
"configDirName": ".arduinoIDE"
54+
}
55+
},
56+
"generator": {
57+
"config": {
58+
"preloadTemplate": "<div class='theia-preload' style='background-color: rgb(237, 241, 242);'></div>"
59+
}
60+
}
61+
}
62+
}
63+

browser-app/webpack.config.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* This file can be edited to customize webpack configuration.
3+
* To reset delete this file and rerun theia build again.
4+
*/
5+
// @ts-check
6+
const config = require('./gen-webpack.config.js');
7+
8+
config.resolve.fallback['http'] = false;
9+
config.resolve.fallback['fs'] = false;
10+
11+
/**
12+
* Expose bundled modules on window.theia.moduleName namespace, e.g.
13+
* window['theia']['@theia/core/lib/common/uri'].
14+
* Such syntax can be used by external code, for instance, for testing.
15+
config.module.rules.push({
16+
test: /\.js$/,
17+
loader: require.resolve('@theia/application-manager/lib/expose-loader')
18+
}); */
19+
20+
module.exports = config;

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"scripts": {
4646
"prepare": "lerna run prepare",
47-
"cleanup": "rimraf ./**/node_modules && rm -rf ./node_modules ./.browser_modules ./arduino-ide-extension/build ./arduino-ide-extension/downloads ./arduino-ide-extension/Examples ./arduino-ide-extension/lib ./electron-app/lib ./electron-app/src-gen ./electron-app/gen-webpack.config.js",
47+
"cleanup": "rimraf ./**/node_modules && rm -rf ./node_modules ./.browser_modules ./arduino-ide-extension/build ./arduino-ide-extension/downloads ./arduino-ide-extension/Examples ./arduino-ide-extension/lib ./electron-app/lib ./electron-app/src-gen ./electron-app/gen-webpack.config.js ./browser-app/lib ./browser-app/src-gen ./browser-app/gen-webpack.config.js",
4848
"rebuild:browser": "theia rebuild:browser",
4949
"rebuild:electron": "theia rebuild:electron",
5050
"start": "yarn --cwd ./electron-app start",
@@ -54,7 +54,7 @@
5454
"test": "lerna run test",
5555
"test:slow": "lerna run test:slow",
5656
"update:version": "node ./scripts/update-version.js",
57-
"i18n:generate": "theia nls-extract -e vscode -f \"+(arduino-ide-extension|electron-app|plugins)/**/*.ts?(x)\" -o ./i18n/en.json",
57+
"i18n:generate": "theia nls-extract -e vscode -f \"+(arduino-ide-extension|browser-app|electron-app|plugins)/**/*.ts?(x)\" -o ./i18n/en.json",
5858
"i18n:check": "yarn i18n:generate && git add -N ./i18n && git diff --exit-code ./i18n",
5959
"i18n:push": "node ./scripts/i18n/transifex-push.js ./i18n/en.json",
6060
"i18n:pull": "node ./scripts/i18n/transifex-pull.js ./i18n/",
@@ -74,6 +74,7 @@
7474
},
7575
"workspaces": [
7676
"arduino-ide-extension",
77-
"electron-app"
77+
"electron-app",
78+
"browser-app"
7879
]
7980
}

scripts/update-version.js

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ console.log(
3838
for (const toUpdate of [
3939
path.join(repoRootPath, 'package.json'),
4040
path.join(repoRootPath, 'electron-app', 'package.json'),
41+
path.join(repoRootPath, 'browser-app', 'package.json'),
4142
path.join(repoRootPath, 'arduino-ide-extension', 'package.json'),
4243
]) {
4344
process.stdout.write(` Updating ${toUpdate}'...`);

0 commit comments

Comments
 (0)