1
1
import * as path from 'path' ;
2
-
3
2
import { app , BrowserWindow , shell } from 'electron' ;
4
3
4
+ // tslint:disable-next-line:no-var-requires
5
+ const packageJson = require ( '../package.json' ) ;
6
+
5
7
const APP_URL = 'https://app.httptoolkit.tech' ;
6
8
7
9
// Keep a global reference of the window object, if you don't, the window will
@@ -51,6 +53,16 @@ app.on('activate', () => {
51
53
} ) ;
52
54
53
55
app . on ( 'web-contents-created' , ( _event , contents ) => {
56
+ contents . on ( 'dom-ready' , ( ) => {
57
+ // Define & announce the desktop shell version to the app
58
+ // Not used now, intended to allow us to detect and prompt for updates
59
+ // in future, if a certain desktop shell version is required.
60
+ contents . executeJavaScript ( `
61
+ window.httpToolkitDesktopVersion = '${ packageJson . version } ';
62
+ window.postMessage({ httpToolkitDesktopVersion: window.httpToolkitDesktopVersion }, '*');
63
+ ` ) ;
64
+ } ) ;
65
+
54
66
// Redirect all navigations & new windows to the system browser
55
67
contents . on ( 'will-navigate' , ( event , navigationUrl ) => {
56
68
const parsedUrl = new URL ( navigationUrl ) ;
@@ -69,4 +81,4 @@ app.on('web-contents-created', (_event, contents) => {
69
81
shell . openExternal ( navigationUrl ) ;
70
82
}
71
83
} ) ;
72
- } )
84
+ } ) ;
0 commit comments