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

Commit

Permalink
Snap launch (#58)
Browse files Browse the repository at this point in the history
* Added debugging configuration

* WIP

* Auto open bim when passed as arg
  • Loading branch information
williamkbentley authored May 14, 2021
1 parent 3b2fd8c commit 48f007e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 32 deletions.
48 changes: 21 additions & 27 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,43 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"compounds": [
{
"name": "Electron",
"configurations": [
"Main",
"Renderer"
]
}
],
"configurations": [
{
"name": "Main",
"presentation": {
"hidden": true
},
"name": "Electron: Main",
"type": "pwa-node",
"request": "launch",
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"outputCapture": "std",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"runtimeArgs": [
"${workspaceFolder}/lib/backend/main.js",
"lib/backend/main.js",
"--remote-debugging-port=9223"
],
"env": {
"NODE_ENV": "development"
},
"autoAttachChildProcesses": false,
"attachSimplePort": 0,
"outputCapture": "std",
"cascadeTerminateToConfigurations": [
"Renderer"
]
},
{
"name": "Renderer",
"presentation": {
"hidden": true
"group": "desktop-starter"
},
},
{
"name": "Electron: Renderer",
"type": "pwa-chrome",
"request": "attach",
"port": 9223,
"webRoot": "${workspaceFolder}/build/",
"cascadeTerminateToConfigurations": [
"Main"
"timeout": 30000,
"presentation": {
"group": "desktop-starter"
},
},
],
"compounds": [
{
"name": "Electron: All",
"configurations": [
"Electron: Main",
"Electron: Renderer"
]
}
]
Expand Down
35 changes: 35 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch:backend",
"problemMatcher": [
"$tsc-watch"
],
"presentation": {
"group": "desktop-starter"
},
"label": "watch:backend",
},
{
"type": "npm",
"script": "start:frontend",
"problemMatcher": [
"$tsc"
],
"presentation": {
"group": "desktop-starter"
},
"label": "start:frontend",
},
{
"label": "Watch All",
"dependsOn": [
"watch:backend",
"start:frontend"
],
"problemMatcher": []
},
]
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ See <https://itwinjs.org> for comprehensive documentation on the iTwin.js API an

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

## Debugging

1. In VS Code, select Terminal -> Run Task..., and pick "Watch All"
1. Launch the VS Code debugger with configuration "Electron: All"

## Contributing

[Contributing to iTwin.js](https://github.com/imodeljs/imodeljs/blob/master/CONTRIBUTING.md)
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"scripts": {
"build": "run-p build:backend build:frontend copy",
"build:backend": "tsc -p tsconfig.backend.json",
"watch:backend": "tsc -p tsconfig.backend.json --watch",
"build:frontend": "cross-env DISABLE_ESLINT=true GENERATE_SOURCEMAP=false USE_FAST_SASS=true TRANSPILE_DEPS=false DISABLE_TERSER=true react-scripts build",
"clean": "rimraf lib build dist",
"copy": "npm run copy:assets && npm run copy:enUS",
Expand All @@ -27,8 +28,8 @@
"electron": "electron lib/backend/main.js",
"electron:debug": "cross-env NODE_ENV=development electron lib/backend/main.js",
"lint": "eslint --config package.json --no-eslintrc \"./src/**/*.{ts,tsx}\" 1>&2",
"start": "npm run build:backend && run-p \"start:frontend\" \"electron\"",
"start:frontend": "cross-env BROWSER=none DISABLE_ESLINT=true USE_FAST_SASS=true TRANSPILE_DEPS=false react-scripts start",
"start": "npm run build:backend && run-p \"start:frontend\" \"electron:debug\"",
"start:frontend": "cross-env USE_FULL_SOURCEMAPS=true USE_FAST_SASS=true BROWSER=none react-scripts start",
"build:pack": "electron-builder --dir",
"build:dist": "electron-builder"
},
Expand Down
4 changes: 2 additions & 2 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const getAppEnvVar = (varName: string): string | undefined => process.env[`${app
class DesktopStarterHandler extends IpcHandler implements DesktopStarterInterface {
public get channelName() { return desktopStarterChannel; }
public async getConfig(): Promise<ViewerConfig> {
// first two arguments are .exe name and the path to ViewerMain.js. Skip them.
// first two arguments are .exe name and the path to main.js. Skip them.
const parsedArgs = process.env.NODE_ENV === "development"
? minimist(process.argv.slice(2 + process.argv.findIndex((a: string) => a.includes("main.js"))))
? minimist(process.argv.slice(1 + process.argv.findIndex((a: string) => a.includes("main.js"))))
: minimist(process.argv.slice(1));

const samplePath = ElectronHost.app.isPackaged
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/components/AppComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class AppComponent extends React.Component<{}, AppState> {
isOpening: false,
};

this._autoOpenConfig = { snapshotName: null, contextId: null, imodelId: null };
this._autoOpenConfig = { snapshotName: App.config.snapshotName ?? null, contextId: null, imodelId: null };
this._isAutoOpen = true;
this._wantSnapshot = true;

Expand Down

0 comments on commit 48f007e

Please sign in to comment.