Skip to content

Commit

Permalink
Merge pull request #34 from dala-ai/master
Browse files Browse the repository at this point in the history
fix: Fire the received event on linux
  • Loading branch information
glawson authored Nov 11, 2021
2 parents de4690f + 73d58ed commit 0a30f84
Show file tree
Hide file tree
Showing 6 changed files with 20,755 additions and 8,874 deletions.
3 changes: 1 addition & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ interface DeeplinkConfig {
app: App;
mainWindow: BrowserWindow;
isDev?: boolean;
isYarn?: boolean;
debugLogging?: boolean;
electronPath?: string;
}
Expand All @@ -23,7 +22,7 @@ declare class Deeplink extends EventEmitter {
private checkConfig;
private setAppProtocol;
private secondInstanceEvent;
private openEvent;
private darwinOpenEvent;
restoreInfoPlist: () => void;
getProtocol: () => string;
getLogfile: () => any;
Expand Down
25 changes: 18 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ var __extends = (this && this.__extends) || (function () {
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Expand Down Expand Up @@ -59,21 +66,25 @@ var Deeplink = /** @class */ (function (_super) {
return electronDeeplink.SetRuntimeAppProtocol(_this.electronPath, protocol, debugLogging);
};
_this.secondInstanceEvent = function (event, argv) {
if (os_1.default.platform() === 'darwin') {
var debugLogging = _this.config.debugLogging;
if (os_1.default.platform() === 'darwin' && debugLogging) {
_this.logger.error("electron-deeplink: the app event 'second-instance' fired, this should not of happened, please check your packager bundleId config");
return;
}
if (os_1.default.platform() === 'win32') {
_this.emit('received', argv.slice(-1).join(''));
}
else {
_this.emit.apply(_this, __spreadArrays(['received'], argv));
}
if (_this.mainWindow) {
if (_this.mainWindow.isMinimized()) {
_this.mainWindow.restore();
}
_this.mainWindow.focus();
}
};
_this.openEvent = function (event, url, eventName) {
_this.darwinOpenEvent = function (event, url, eventName) {
event.preventDefault();
var debugLogging = _this.config.debugLogging;
if (debugLogging) {
Expand Down Expand Up @@ -108,7 +119,7 @@ var Deeplink = /** @class */ (function (_super) {
_this.logger.transports.file.level = 'debug';
_this.logger.debug("electron-deeplink: debugLogging is enabled");
}
var instanceLock = process.mas === true ? true : app.requestSingleInstanceLock();
var instanceLock = process.mas === true || app.requestSingleInstanceLock();
if (!instanceLock) {
if (debugLogging) {
_this.logger.debug("electron-deeplink: unable to lock instance");
Expand All @@ -126,16 +137,16 @@ var Deeplink = /** @class */ (function (_super) {
}
if (os_1.default.platform() === 'darwin') {
app.setAsDefaultProtocolClient(protocol);
app.on('will-finish-launching', function () {
app.on('open-url', function (event, url) { return _this.darwinOpenEvent(event, url, 'open-url'); });
app.on('open-file', function (event, url) { return _this.darwinOpenEvent(event, url, 'open-file'); });
});
}
else {
var args = process.argv[1] ? [path_1.default.resolve(process.argv[1])] : [];
app.setAsDefaultProtocolClient(protocol, process.execPath, args);
}
app.on('second-instance', _this.secondInstanceEvent);
app.on('will-finish-launching', function () {
app.on('open-url', function (event, url) { return _this.openEvent(event, url, 'open-url'); });
app.on('open-file', function (event, url) { return _this.openEvent(event, url, 'open-file'); });
});
return _this;
}
return Deeplink;
Expand Down
Loading

0 comments on commit 0a30f84

Please sign in to comment.