@todesktop/runtime
Advanced tools
Comparing version 1.5.7-beta.0 to 1.5.7-beta.1
import AutoUpdater from "./AutoUpdater"; | ||
import { LoggerInterface } from "./Logger"; | ||
import { UpdateReadyAction } from "./types"; | ||
declare type ToDesktopRuntimeParams = { | ||
autoUpdater?: boolean; | ||
autoCheckInterval?: number; | ||
shouldAutoCheckOnLaunch?: boolean; | ||
customLogger?: LoggerInterface; | ||
updateReadyAction?: UpdateReadyAction; | ||
}; | ||
import { ToDesktopRuntimeParams } from "./types"; | ||
declare class ToDesktop { | ||
@@ -12,0 +4,0 @@ autoUpdater: AutoUpdater; |
@@ -9,61 +9,53 @@ "use strict"; | ||
class ToDesktop { | ||
constructor() { | ||
this.isSmokeTestMode = Boolean(process.env.TODESKTOP_SMOKE_TEST); | ||
} | ||
// This initializes everything. It must be called (at the top of their main script) | ||
init(params = {}) { | ||
if (this.isSmokeTestMode) { | ||
this.autoUpdater = (0, MockedAutoUpdater_1.createMockedAutoUpdater)(); | ||
} else { | ||
this.autoUpdater = this._init(params); | ||
constructor() { | ||
this.isSmokeTestMode = Boolean(process.env.TODESKTOP_SMOKE_TEST); | ||
} | ||
} | ||
_init({ | ||
autoUpdater = true, | ||
autoCheckInterval, | ||
shouldAutoCheckOnLaunch, | ||
customLogger, | ||
updateReadyAction, | ||
} = {}) { | ||
const logger = new Logger_1.default(customLogger); | ||
const Updater = (0, SimulatedAutoUpdater_1.parseSimulateUpdatesFlag)() | ||
? SimulatedAutoUpdater_1.SimulatedAutoUpdater | ||
: AutoUpdater_1.default; | ||
let autoUpdaterInstance; | ||
if (autoUpdater) { | ||
autoUpdaterInstance = new Updater({ | ||
logger, | ||
autoCheckInterval, | ||
shouldAutoCheckOnLaunch, | ||
}); | ||
new Notifier_1.default({ | ||
autoUpdater: autoUpdaterInstance, | ||
updateReadyAction, | ||
}); | ||
} else { | ||
// Disables the default behaviour | ||
autoUpdaterInstance = new Updater({ | ||
autoCheckInterval: 0, | ||
logger, | ||
shouldAutoCheckOnLaunch: false, | ||
}); | ||
// This initializes everything. It must be called (at the top of their main script) | ||
init(params = {}) { | ||
if (this.isSmokeTestMode) { | ||
this.autoUpdater = (0, MockedAutoUpdater_1.createMockedAutoUpdater)(); | ||
} | ||
else { | ||
this.autoUpdater = this._init(params); | ||
} | ||
} | ||
return autoUpdaterInstance; | ||
} | ||
_init({ autoUpdater = true, autoCheckInterval, shouldAutoCheckOnLaunch, customLogger, updateReadyAction, } = {}) { | ||
const logger = new Logger_1.default(customLogger); | ||
const Updater = (0, SimulatedAutoUpdater_1.parseSimulateUpdatesFlag)() | ||
? SimulatedAutoUpdater_1.SimulatedAutoUpdater | ||
: AutoUpdater_1.default; | ||
let autoUpdaterInstance; | ||
if (autoUpdater) { | ||
autoUpdaterInstance = new Updater({ | ||
logger, | ||
autoCheckInterval, | ||
shouldAutoCheckOnLaunch, | ||
}); | ||
new Notifier_1.default({ autoUpdater: autoUpdaterInstance, updateReadyAction }); | ||
} | ||
else { | ||
// Disables the default behaviour | ||
autoUpdaterInstance = new Updater({ | ||
autoCheckInterval: 0, | ||
logger, | ||
shouldAutoCheckOnLaunch: false, | ||
}); | ||
} | ||
return autoUpdaterInstance; | ||
} | ||
} | ||
let todesktop; | ||
if (cache_1.default.get()) { | ||
todesktop = cache_1.default.get(); | ||
} else { | ||
todesktop = new ToDesktop(); | ||
cache_1.default.set(todesktop); | ||
todesktop = cache_1.default.get(); | ||
} | ||
else { | ||
todesktop = new ToDesktop(); | ||
cache_1.default.set(todesktop); | ||
} | ||
if (todesktop.isSmokeTestMode) { | ||
Promise.resolve() | ||
.then(() => require("./initSmokeTest")) | ||
.then(({ default: initSmokeTest }) => initSmokeTest(todesktop)) | ||
.catch(() => { | ||
// Ignore | ||
Promise.resolve().then(() => require("./initSmokeTest")).then(({ default: initSmokeTest }) => initSmokeTest(todesktop)) | ||
.catch(() => { | ||
// Ignore | ||
}); | ||
} | ||
module.exports = todesktop; |
import { Notification, NotificationConstructorOptions } from "electron"; | ||
import { MessageBoxOptions } from "electron/main"; | ||
import { UpdateAvailableEventPayload } from "./AutoUpdater"; | ||
import { LoggerInterface } from "./Logger"; | ||
export declare type CheckForUpdatesInput = { | ||
@@ -39,2 +40,9 @@ source?: Source; | ||
declare type Awaitable<T> = T | Promise<T>; | ||
export declare type ToDesktopRuntimeParams = { | ||
autoUpdater?: boolean; | ||
autoCheckInterval?: number; | ||
shouldAutoCheckOnLaunch?: boolean; | ||
customLogger?: LoggerInterface; | ||
updateReadyAction?: UpdateReadyAction; | ||
}; | ||
export {}; |
@@ -7,3 +7,3 @@ { | ||
"name": "@todesktop/runtime", | ||
"version": "1.5.7-beta.0", | ||
"version": "1.5.7-beta.1", | ||
"license": "MIT", | ||
@@ -10,0 +10,0 @@ "author": "ToDesktop <hi@todesktop.com> (https://www.todesktop.com/)", |
89849
1452