Merge pull request #114 from manojVivek/browser-extension

Browser extension, app support #78
This commit is contained in:
Manoj Vivek 2020-05-25 19:40:38 +05:30 committed by GitHub
commit d464c1780d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1 @@
build/entitlements.mac.plist

View file

@ -23,6 +23,7 @@ import installExtension, {
REDUX_DEVTOOLS,
} from 'electron-devtools-installer';
import devtron from 'devtron';
import fs from 'fs';
const path = require('path');
@ -41,6 +42,7 @@ export default class AppUpdater {
}
let mainWindow = null;
let urlToOpen = null;
let httpAuthCallbacks = {};
@ -67,11 +69,44 @@ const installExtensions = async () => {
}
};
const openUrl = url => {
mainWindow.webContents.send(
'address-change',
url.replace('responsively://', '')
);
mainWindow.show();
};
/**
* Add event listeners...
*/
app.on('will-finish-launching', () => {
if (['win32', 'darwin'].includes(process.platform)) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('responsively', process.execPath, [
path.resolve(process.argv[1]),
]);
} else {
app.setAsDefaultProtocolClient('responsively');
}
}
});
app.on('open-url', async (event, url) => {
log.info('Open-url', url);
if (mainWindow) {
openUrl(url);
} else {
urlToOpen = url;
}
});
app.on('window-all-closed', () => {
if (process.env.NODE_ENV === 'development') {
['win32', 'darwin'].includes(process.platform) &&
app.removeAsDefaultProtocolClient('responsively');
}
// Respect the OSX convention of having the application in memory even
// after all windows have been closed
if (process.platform !== 'darwin') {
@ -144,6 +179,10 @@ const createWindow = async () => {
});
mainWindow.once('ready-to-show', () => {
if (urlToOpen) {
openUrl(urlToOpen);
urlToOpen = null;
}
mainWindow.show();
});

View file

@ -97,6 +97,16 @@
"category": "public.app-category.developer-tools",
"entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.plist",
"extendInfo": {
"CFBundleURLTypes": [
{
"CFBundleURLSchemes": [
"responsively"
],
"CFBundleURLName": "app.responsively"
}
]
},
"icon": "resources/icon.icns",
"target": [
"dmg"