Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit 48f007e

Browse files
Snap launch (#58)
* Added debugging configuration * WIP * Auto open bim when passed as arg
1 parent 3b2fd8c commit 48f007e

File tree

6 files changed

+67
-32
lines changed

6 files changed

+67
-32
lines changed

.vscode/launch.json

+21-27
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,43 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
6-
"compounds": [
7-
{
8-
"name": "Electron",
9-
"configurations": [
10-
"Main",
11-
"Renderer"
12-
]
13-
}
14-
],
156
"configurations": [
167
{
17-
"name": "Main",
18-
"presentation": {
19-
"hidden": true
20-
},
8+
"name": "Electron: Main",
219
"type": "pwa-node",
2210
"request": "launch",
11+
"cwd": "${workspaceFolder}",
12+
"console": "internalConsole",
13+
"outputCapture": "std",
2314
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
2415
"runtimeArgs": [
25-
"${workspaceFolder}/lib/backend/main.js",
16+
"lib/backend/main.js",
2617
"--remote-debugging-port=9223"
2718
],
2819
"env": {
2920
"NODE_ENV": "development"
3021
},
31-
"autoAttachChildProcesses": false,
32-
"attachSimplePort": 0,
33-
"outputCapture": "std",
34-
"cascadeTerminateToConfigurations": [
35-
"Renderer"
36-
]
37-
},
38-
{
39-
"name": "Renderer",
4022
"presentation": {
41-
"hidden": true
23+
"group": "desktop-starter"
4224
},
25+
},
26+
{
27+
"name": "Electron: Renderer",
4328
"type": "pwa-chrome",
4429
"request": "attach",
4530
"port": 9223,
46-
"webRoot": "${workspaceFolder}/build/",
47-
"cascadeTerminateToConfigurations": [
48-
"Main"
31+
"timeout": 30000,
32+
"presentation": {
33+
"group": "desktop-starter"
34+
},
35+
},
36+
],
37+
"compounds": [
38+
{
39+
"name": "Electron: All",
40+
"configurations": [
41+
"Electron: Main",
42+
"Electron: Renderer"
4943
]
5044
}
5145
]

.vscode/tasks.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "npm",
6+
"script": "watch:backend",
7+
"problemMatcher": [
8+
"$tsc-watch"
9+
],
10+
"presentation": {
11+
"group": "desktop-starter"
12+
},
13+
"label": "watch:backend",
14+
},
15+
{
16+
"type": "npm",
17+
"script": "start:frontend",
18+
"problemMatcher": [
19+
"$tsc"
20+
],
21+
"presentation": {
22+
"group": "desktop-starter"
23+
},
24+
"label": "start:frontend",
25+
},
26+
{
27+
"label": "Watch All",
28+
"dependsOn": [
29+
"watch:backend",
30+
"start:frontend"
31+
],
32+
"problemMatcher": []
33+
},
34+
]
35+
}

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ See <https://itwinjs.org> for comprehensive documentation on the iTwin.js API an
1212

1313
To build and run this application, just follow our [step-by-step tutorial.](https://www.itwinjs.org/learning/tutorials/develop-desktop-viewer/)
1414

15+
## Debugging
16+
17+
1. In VS Code, select Terminal -> Run Task..., and pick "Watch All"
18+
1. Launch the VS Code debugger with configuration "Electron: All"
19+
1520
## Contributing
1621

1722
[Contributing to iTwin.js](https://github.com/imodeljs/imodeljs/blob/master/CONTRIBUTING.md)

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"scripts": {
2020
"build": "run-p build:backend build:frontend copy",
2121
"build:backend": "tsc -p tsconfig.backend.json",
22+
"watch:backend": "tsc -p tsconfig.backend.json --watch",
2223
"build:frontend": "cross-env DISABLE_ESLINT=true GENERATE_SOURCEMAP=false USE_FAST_SASS=true TRANSPILE_DEPS=false DISABLE_TERSER=true react-scripts build",
2324
"clean": "rimraf lib build dist",
2425
"copy": "npm run copy:assets && npm run copy:enUS",
@@ -27,8 +28,8 @@
2728
"electron": "electron lib/backend/main.js",
2829
"electron:debug": "cross-env NODE_ENV=development electron lib/backend/main.js",
2930
"lint": "eslint --config package.json --no-eslintrc \"./src/**/*.{ts,tsx}\" 1>&2",
30-
"start": "npm run build:backend && run-p \"start:frontend\" \"electron\"",
31-
"start:frontend": "cross-env BROWSER=none DISABLE_ESLINT=true USE_FAST_SASS=true TRANSPILE_DEPS=false react-scripts start",
31+
"start": "npm run build:backend && run-p \"start:frontend\" \"electron:debug\"",
32+
"start:frontend": "cross-env USE_FULL_SOURCEMAPS=true USE_FAST_SASS=true BROWSER=none react-scripts start",
3233
"build:pack": "electron-builder --dir",
3334
"build:dist": "electron-builder"
3435
},

src/backend/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const getAppEnvVar = (varName: string): string | undefined => process.env[`${app
2222
class DesktopStarterHandler extends IpcHandler implements DesktopStarterInterface {
2323
public get channelName() { return desktopStarterChannel; }
2424
public async getConfig(): Promise<ViewerConfig> {
25-
// first two arguments are .exe name and the path to ViewerMain.js. Skip them.
25+
// first two arguments are .exe name and the path to main.js. Skip them.
2626
const parsedArgs = process.env.NODE_ENV === "development"
27-
? minimist(process.argv.slice(2 + process.argv.findIndex((a: string) => a.includes("main.js"))))
27+
? minimist(process.argv.slice(1 + process.argv.findIndex((a: string) => a.includes("main.js"))))
2828
: minimist(process.argv.slice(1));
2929

3030
const samplePath = ElectronHost.app.isPackaged

src/frontend/components/AppComponent.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default class AppComponent extends React.Component<{}, AppState> {
6868
isOpening: false,
6969
};
7070

71-
this._autoOpenConfig = { snapshotName: null, contextId: null, imodelId: null };
71+
this._autoOpenConfig = { snapshotName: App.config.snapshotName ?? null, contextId: null, imodelId: null };
7272
this._isAutoOpen = true;
7373
this._wantSnapshot = true;
7474

0 commit comments

Comments
 (0)