Stefan Huber

dist

This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
import { ServiceLocator } from './service-locator';
import { NodeFileHandler } from './file-handler/node-file-handler';
export default class Bsync {
static NodeFileHandler = NodeFileHandler;
static ServiceLocator = ServiceLocator;
static configIpcMain(ipcMain: any, basePath: string) {
ipcMain.on('bsync-download', (event, args) => {
......
import {NodeFileHandler} from './file-handler/node-file-handler';
import {FileHandler} from './api/file-handler';
import {ElectronFileHandler} from './file-handler/electron-file-handler';
import {CordovaFileHandler} from './file-handler/cordova-file-handler';
......@@ -12,6 +13,7 @@ import {
CONFIG_TARGET_DIRECTORY
} from './config';
export const ENV_NODE = "node";
export const ENV_ELECTRON = "electron";
export const ENV_CORDOVA = "cordova";
export const ENV_UNKNOWN = "unknown";
......@@ -35,12 +37,15 @@ export class ServiceLocator {
}
static getEnvironment() {
if (typeof window['require'] === 'function' && window['require']('electron')) {
if (typeof window != 'undefined' && typeof window['require'] === 'function' && window['require']('electron')) {
return ENV_ELECTRON;
}
if (typeof window['FileTransfer'] === 'function') {
if (typeof window != 'undefined' && typeof window['FileTransfer'] === 'function') {
return ENV_CORDOVA;
}
if (typeof process != 'undefined' && typeof process === 'object') {
return ENV_NODE;
}
return ENV_UNKNOWN;
}
......@@ -55,10 +60,12 @@ export class ServiceLocator {
if (environment === ENV_ELECTRON) {
return new ElectronFileHandler(window['require']('electron').ipcRenderer);
}
if (environment === ENV_CORDOVA) {
return new CordovaFileHandler();
}
if (environment === ENV_NODE) {
return new NodeFileHandler();
}
return null;
}
......