ngx-electron-fresher
Version:
A wrapper for Electron Renderer APIs. Finally easy to use in Angular forked from ThorstenHans/ngx-electron
104 lines (98 loc) • 3.52 kB
JavaScript
import * as i0 from '@angular/core';
import { Injectable, NgModule } from '@angular/core';
import * as Electron from 'electron';
class ElectronService {
_electron;
get electron() {
if (!this._electron) {
if (window && window.require) {
this._electron = window.require('electron');
return this._electron;
}
return null;
}
return this._electron;
}
/**
* determines if SPA is running in Electron
*/
get isElectronApp() {
return !!window.navigator.userAgent.match(/Electron/);
}
get isMacOS() {
return this.isElectronApp && process.platform === 'darwin';
}
get isWindows() {
return this.isElectronApp && process.platform === 'win32';
}
get isLinux() {
return this.isElectronApp && process.platform === 'linux';
}
get isX86() {
return this.isElectronApp && process.arch === 'ia32';
}
get isX64() {
return this.isElectronApp && process.arch === 'x64';
}
get isArm() {
return this.isElectronApp && process.arch === 'arm';
}
get desktopCapturer() {
return this.electron ? Electron.desktopCapturer : null;
}
get ipcRenderer() {
return this.electron ? Electron.ipcRenderer : null;
}
get remote() {
return this.electron ? Electron.webContents : null;
}
get webFrame() {
return this.electron ? Electron.webFrame : null;
}
get clipboard() {
return this.electron ? Electron.clipboard : null;
}
get crashReporter() {
return this.electron ? Electron.crashReporter : null;
}
get process() {
return this.remote ? this.remote.process : null;
}
get nativeImage() {
return this.electron ? Electron.nativeImage : null;
}
get screen() {
return this.electron ? Electron.screen : null;
}
get shell() {
return this.electron ? Electron.shell : null;
}
}
class ElectronServiceRef extends ElectronService {
constructor() {
super();
}
/** @nocollapse */ static ɵfac = function ElectronServiceRef_Factory(t) { return new (t || ElectronServiceRef)(); };
/** @nocollapse */ static ɵprov = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjectable({ token: ElectronServiceRef, factory: ElectronServiceRef.ɵfac });
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ElectronServiceRef, [{
type: Injectable
}], function () { return []; }, null); })();
class NgxElectronModule {
/** @nocollapse */ static ɵfac = function NgxElectronModule_Factory(t) { return new (t || NgxElectronModule)(); };
/** @nocollapse */ static ɵmod = /** @pureOrBreakMyCode */ i0.ɵɵdefineNgModule({ type: NgxElectronModule });
/** @nocollapse */ static ɵinj = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjector({ providers: [{ provide: ElectronService, useClass: ElectronServiceRef }] });
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NgxElectronModule, [{
type: NgModule,
args: [{
declarations: [],
exports: [],
providers: [{ provide: ElectronService, useClass: ElectronServiceRef }]
}]
}], null, null); })();
/**
* Generated bundle index. Do not edit.
*/
export { ElectronService, ElectronServiceRef, NgxElectronModule };
//# sourceMappingURL=ngx-electron-fresh.mjs.map