Feature/#48 migrate to typescript #151

Merged
Serraniel merged 30 commits from feature/#48-migrate-to-typescript into develop 2020-12-30 17:24:49 +01:00
Showing only changes of commit 421c191e1d - Show all commits

View file

@ -1,5 +1,11 @@
const { assigned } = require("../utils/helpers") const { assigned } = require("../utils/helpers")
enum BrowserApi {
Unknown,
Chromium,
Firefox,
}
export type ConfigurationStorageBooleanCallback = (value: boolean) => void; export type ConfigurationStorageBooleanCallback = (value: boolean) => void;
export interface ICustomBrowserStorageProvider { export interface ICustomBrowserStorageProvider {
@ -70,18 +76,36 @@ class StorageProviderFirefox implements ICustomBrowserStorageProvider {
let __storageProvieder: ICustomBrowserStorageProvider; let __storageProvieder: ICustomBrowserStorageProvider;
function getBrowserApi(): BrowserApi {
if (assigned(chrome)) {
if (assigned(browser)) {
return BrowserApi.Firefox;
}
return BrowserApi.Chromium;
}
else if (assigned(browser)) {
return BrowserApi.Firefox;
}
return BrowserApi.Unknown;
}
function createStorageProvider() { function createStorageProvider() {
// chrome based browser
// TODO: chrome.app? let api = getBrowserApi();
// if (assigned(chrome?.app)) {
if (true) { // chromium
if (api === BrowserApi.Chromium) {
__storageProvieder = new StorageProviderChromium(); __storageProvieder = new StorageProviderChromium();
} }
// firefox // firefox
else { else if (api === BrowserApi.Firefox) {
__storageProvieder = new StorageProviderFirefox(); __storageProvieder = new StorageProviderFirefox();
} }
else {
throw "Unknown browser API. Cannot create storage provider.";
}
} }
export function getGlobalStorageProvider(): ICustomBrowserStorageProvider { export function getGlobalStorageProvider(): ICustomBrowserStorageProvider {