ngx-electron-croft
Version:
access Electron Renderer APIs easily using an Angular Service
102 lines (101 loc) • 3.37 kB
JavaScript
var ElectronService = (function () {
function ElectronService() {
}
Object.defineProperty(ElectronService.prototype, "electron", {
get: function () {
if (!this._electron) {
if (window && window.require) {
this._electron = window.require('electron');
return this._electron;
}
return null;
}
return this._electron;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "isElectronApp", {
/**
* determines if SPA is running in Electron
* @returns {boolean}
*/
get: function () {
return !!window.navigator.userAgent.match(/Electron/);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "desktopCapturer", {
get: function () {
return this.electron ? this.electron.desktopCapturer : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "ipcRenderer", {
get: function () {
return this.electron ? this.electron.ipcRenderer : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "remote", {
get: function () {
return this.electron ? this.electron.remote : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "webFrame", {
get: function () {
return this.electron ? this.electron.webFrame : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "clipboard", {
get: function () {
return this.electron ? this.electron.clipboard : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "crashReporter", {
get: function () {
return this.electron ? this.electron.crashReporter : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "process", {
get: function () {
return this.remote ? this.remote.process : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "nativeImage", {
get: function () {
return this.electron ? this.electron.nativeImage : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "screen", {
get: function () {
return this.electron ? this.electron.screen : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ElectronService.prototype, "shell", {
get: function () {
return this.electron ? this.electron.shell : null;
},
enumerable: true,
configurable: true
});
return ElectronService;
}());
export { ElectronService };