summaryrefslogtreecommitdiffhomepage
path: root/desktop/packages
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/packages')
-rw-r--r--desktop/packages/mullvad-vpn/gulpfile.js5
-rw-r--r--desktop/packages/mullvad-vpn/package.json7
-rw-r--r--desktop/packages/mullvad-vpn/src/main/user-interface.ts14
-rw-r--r--desktop/packages/mullvad-vpn/tasks/distribution.js35
-rw-r--r--desktop/packages/mullvad-vpn/tasks/scripts.js10
-rw-r--r--desktop/packages/nseventforwarder/build.sh2
6 files changed, 47 insertions, 26 deletions
diff --git a/desktop/packages/mullvad-vpn/gulpfile.js b/desktop/packages/mullvad-vpn/gulpfile.js
index 072e3652e0..ff5a82df17 100644
--- a/desktop/packages/mullvad-vpn/gulpfile.js
+++ b/desktop/packages/mullvad-vpn/gulpfile.js
@@ -23,7 +23,10 @@ task(
'build',
series('clean', 'set-prod-env', parallel(assets.copyAll, scripts.buildProto), scripts.build),
);
-task('develop', series('clean', 'set-dev-env', scripts.buildProto, watch.start));
+task(
+ 'develop',
+ series('clean', 'set-dev-env', scripts.buildProto, scripts.buildNseventforwarder, watch.start),
+);
task('pack-win', series('build', dist.packWin));
task('pack-linux', series('build', dist.packLinux));
task('pack-mac', series('build', dist.packMac));
diff --git a/desktop/packages/mullvad-vpn/package.json b/desktop/packages/mullvad-vpn/package.json
index 104291e824..b67b7e7421 100644
--- a/desktop/packages/mullvad-vpn/package.json
+++ b/desktop/packages/mullvad-vpn/package.json
@@ -25,11 +25,11 @@
"redux": "^4.2.0",
"simple-plist": "^1.3.1",
"sprintf-js": "^1.1.2",
- "styled-components": "^6.1.0"
+ "styled-components": "^6.1.0",
+ "nseventforwarder": "0.0.0"
},
"optionalDependencies": {
- "grpc-tools": "^1.12.4",
- "nseventmonitor": "^1.0.5"
+ "grpc-tools": "^1.12.4"
},
"devDependencies": {
"@playwright/test": "^1.41.1",
@@ -76,7 +76,6 @@
},
"scripts": {
"preinstall": "test -d node_modules || mkdir node_modules",
- "postinstall": "cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder install-app-deps",
"build": "gulp build",
"build-proto": "gulp build-proto",
"pack-test-executable": "./scripts/build-test-executable.sh",
diff --git a/desktop/packages/mullvad-vpn/src/main/user-interface.ts b/desktop/packages/mullvad-vpn/src/main/user-interface.ts
index f7b81247ff..a079246373 100644
--- a/desktop/packages/mullvad-vpn/src/main/user-interface.ts
+++ b/desktop/packages/mullvad-vpn/src/main/user-interface.ts
@@ -487,7 +487,7 @@ export default class UserInterface implements WindowControllerDelegate {
});
}
- // setup NSEvent monitor to fix inconsistent window.blur on macOS
+ // setup NSEvent forwarder to fix inconsistent window.blur on macOS
// see https://github.com/electron/electron/issues/8689
private installMacOsMenubarAppWindowHandlers() {
if (this.delegate.isUnpinnedWindow()) {
@@ -495,14 +495,14 @@ export default class UserInterface implements WindowControllerDelegate {
}
// eslint-disable-next-line @typescript-eslint/no-require-imports
- const { NSEventMonitor, NSEventMask } = require('nseventmonitor');
- const macEventMonitor = new NSEventMonitor();
- const eventMask = NSEventMask.leftMouseDown | NSEventMask.rightMouseDown;
+ const nseventforwarder = require('nseventforwarder');
+ let nseventforwarderStop: ReturnType<typeof nseventforwarder.start>;
- this.windowController.window?.on('show', () =>
- macEventMonitor.start(eventMask, () => this.windowController.hide()),
+ this.windowController.window?.on(
+ 'show',
+ () => (nseventforwarderStop = nseventforwarder.start(() => this.windowController.hide())),
);
- this.windowController.window?.on('hide', () => macEventMonitor.stop());
+ this.windowController.window?.on('hide', () => nseventforwarderStop?.());
this.windowController.window?.on('blur', () => {
// Make sure to hide the menubar window when other program captures the focus.
// But avoid doing that when dev tools capture the focus to make it possible to inspect the UI
diff --git a/desktop/packages/mullvad-vpn/tasks/distribution.js b/desktop/packages/mullvad-vpn/tasks/distribution.js
index c99be22fda..b3a4260434 100644
--- a/desktop/packages/mullvad-vpn/tasks/distribution.js
+++ b/desktop/packages/mullvad-vpn/tasks/distribution.js
@@ -60,7 +60,7 @@ const config = {
'node_modules/',
'!node_modules/grpc-tools',
'!node_modules/@types',
- '!node_modules/nseventmonitor/build/Release',
+ '!node_modules/nseventforwarder/target',
],
// Make sure that all files declared in "extraResources" exists and abort if they don't.
@@ -84,7 +84,7 @@ const config = {
target: 'pkg',
arch: getMacArch(),
},
- singleArchFiles: 'node_modules/nseventmonitor/lib/binding/Release/**',
+ singleArchFiles: 'node_modules/nseventforwarder/dist/**',
artifactName: 'MullvadVPN-${version}.${ext}',
category: 'public.app-category.tools',
icon: distAssets('icon-macos.icns'),
@@ -329,13 +329,15 @@ function packMac() {
config: {
...config,
asarUnpack: ['**/*.node'],
- beforeBuild: (options) => {
+ beforeBuild: async (options) => {
switch (options.arch) {
case 'x64':
process.env.TARGET_TRIPLE = 'x86_64-apple-darwin';
+ execFileSync('npm', ['-w', 'nseventforwarder', 'run', 'build-x86']);
break;
case 'arm64':
process.env.TARGET_TRIPLE = 'aarch64-apple-darwin';
+ execFileSync('npm', ['-w', 'nseventforwarder', 'run', 'build-arm']);
break;
default:
delete process.env.TARGET_TRIPLE;
@@ -348,17 +350,7 @@ function packMac() {
return true;
},
beforePack: async (context) => {
- try {
- // `@electron/universal` tries to lipo together libraries built for the same architecture
- // if they're present for both targets. So make sure we remove libraries for other archs.
- // Remove the workaround once the issue has been fixed:
- // https://github.com/electron/universal/issues/41#issuecomment-1496288834
- await fs.promises.rm('node_modules/nseventmonitor/lib/binding/Release', {
- recursive: true,
- });
- } catch {
- // noop
- }
+ await removeNseventforwarderNativeModules();
config.beforePack?.(context);
},
afterPack: (context) => {
@@ -538,6 +530,21 @@ function productVersion(extraArgs) {
return execFileSync('cargo', args, { encoding: 'utf-8' }).trim();
}
+// `@electron/universal` tries to lipo together libraries built for the same architecture
+// if they're present for both targets. So make sure we remove libraries for other archs.
+// Remove the workaround once the issue has been fixed:
+// https://github.com/electron/universal/issues/41#issuecomment-1496288834
+//
+// dist/darwin-x64/index.node
+// dist/darwin-arm64/index.node
+async function removeNseventforwarderNativeModules() {
+ try {
+ await fs.promises.rm('../../node_modules/nseventforwarder/dist/', { recursive: true });
+ } catch {
+ // noop
+ }
+}
+
packWin.displayName = 'builder-win';
packMac.displayName = 'builder-mac';
packLinux.displayName = 'builder-linux';
diff --git a/desktop/packages/mullvad-vpn/tasks/scripts.js b/desktop/packages/mullvad-vpn/tasks/scripts.js
index 20acc69c35..9074cd1f1d 100644
--- a/desktop/packages/mullvad-vpn/tasks/scripts.js
+++ b/desktop/packages/mullvad-vpn/tasks/scripts.js
@@ -113,12 +113,22 @@ function buildProto(callback) {
exec('bash ./scripts/build-proto.sh', (err) => callback(err));
}
+function buildNseventforwarder(callback) {
+ if (process.platform === 'darwin') {
+ exec('npm -w nseventforwarder run build-debug', (err) => callback(err));
+ } else {
+ callback();
+ }
+}
+
compileScripts.displayName = 'compile-scripts';
buildProto.displayName = 'build-proto';
+buildNseventforwarder.displayName = 'build-nseventforwarder';
exports.build = series(
compileScripts,
parallel(makeBrowserifyPreload(false), makeBrowserifyRenderer(false)),
);
exports.buildProto = buildProto;
+exports.buildNseventforwarder = buildNseventforwarder;
exports.makeWatchCompiler = makeWatchCompiler;
diff --git a/desktop/packages/nseventforwarder/build.sh b/desktop/packages/nseventforwarder/build.sh
index 53d39c762f..0b72762132 100644
--- a/desktop/packages/nseventforwarder/build.sh
+++ b/desktop/packages/nseventforwarder/build.sh
@@ -38,6 +38,8 @@ case "$TARGET_TRIPLE" in
esac
if [[ "$(uname -s)" == "Darwin" ]]; then
+ # We rely (heavily) on a pre-defined CARGO_TARGET_DIR, so don't let any user override it
+ unset CARGO_TARGET_DIR
npm run cargo-build -- --release --target "$TARGET_TRIPLE"
# Copy the neon library to the correct dists folder, which is what node will
# pick up when loading the library at runtime.