Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
notion-enhanced / usr / lib / notion-enhanced / resources / app / main / autoUpdater.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
const logger = require("electron-log");
const electron_updater_1 = require("electron-updater");
const config_1 = require("../config");
const notionIpc = require("../helpers/notionIpc");
const loggly_1 = require("../helpers/loggly");
const isOfflineError_1 = require("../shared/isOfflineError");
const cleanObjectForSerialization_1 = require("../shared/cleanObjectForSerialization");
logger.transports.file.level = "info";
logger.transports.file.fileName = "log.log";
electron_updater_1.autoUpdater.logger = logger;
let electronUpdateIsAvailable = false;
electron_updater_1.autoUpdater.autoInstallOnAppQuit = true;
notionIpc.receiveMainFromRenderer.addListener("notion:install-update", () => {
    setTimeout(() => {
        if (electronUpdateIsAvailable) {
            electron_updater_1.autoUpdater.quitAndInstall();
        }
        else {
            electron_1.app.relaunch();
            electron_1.app.quit();
        }
    });
});
notionIpc.receiveMainFromRenderer.addListener("notion:check-for-updates", () => {
    electron_updater_1.autoUpdater.checkForUpdates();
});
electron_updater_1.autoUpdater.on("error", error => {
    electronUpdateIsAvailable = false;
    if (isOfflineError_1.default(error)) {
        logger.info("No electron update -- offline");
        notionIpc.sendMainToNotion("notion:update-not-available");
        return;
    }
    if (error.domain === "NSPOSIXErrorDomain") {
        loggly_1.loggly.log({
            level: "error",
            from: "autoUpdater",
            type: "NSPOSIXErrorDomainError",
            error: error,
        });
    }
    else if (error.domain === "SQRLUpdaterErrorDomain") {
        loggly_1.loggly.log({
            level: "error",
            from: "autoUpdater",
            type: "SQRLUpdaterErrorDomainError",
            error: error,
        });
    }
    else if (error.domain === "NSCocoaErrorDomain") {
        loggly_1.loggly.log({
            level: "error",
            from: "autoUpdater",
            type: "NSCocoaErrorDomainError",
            error: error,
        });
    }
    else if (error.message.startsWith("net::ERR")) {
        loggly_1.loggly.log({
            level: "info",
            from: "autoUpdater",
            type: "networkError",
            error: error,
        });
    }
    else if (error.statusCode === 403) {
        loggly_1.loggly.log({
            level: "warning",
            from: "autoUpdater",
            type: "cloudflareCaptcha",
            error: error,
        });
    }
    else if (error.statusCode === 503) {
        loggly_1.loggly.log({
            level: "warning",
            from: "autoUpdater",
            type: "serviceUnavailable",
            error: error,
        });
    }
    else if (error.message.indexOf("/opt/notion-app/app.asar") !== -1) {
        loggly_1.loggly.log({
            level: "info",
            from: "autoUpdater",
            type: "unsupportedLinuxApp",
            error: error,
        });
    }
    else if (error.message.indexOf("app-update.yml") !== -1) {
    }
    else {
        loggly_1.loggly.log({
            level: "error",
            from: "autoUpdater",
            type: "unknownAutoUpdaterError",
            error: error,
        });
    }
    notionIpc.sendMainToNotion("notion:update-error", cleanObjectForSerialization_1.cleanObjectForSerialization(error));
});
electron_updater_1.autoUpdater.on("checking-for-update", () => {
    notionIpc.sendMainToNotion("notion:checking-for-update");
});
electron_updater_1.autoUpdater.on("update-available", (info) => {
    electronUpdateIsAvailable = true;
    notionIpc.sendMainToNotion("notion:update-available", info);
});
electron_updater_1.autoUpdater.on("update-not-available", () => {
    notionIpc.sendMainToNotion("notion:update-not-available");
});
electron_updater_1.autoUpdater.on("download-progress", (progress) => {
    notionIpc.sendMainToNotion("notion:update-progress", progress);
});
electron_updater_1.autoUpdater.on("update-downloaded", (info) => {
    notionIpc.sendMainToNotion("notion:update-ready", info);
});
const pollInterval = config_1.default.isLocalhost ? 10 * 1000 : 24 * 60 * 60 * 1000;
async function pollForElectronUpdates() {
    while (true) {
        if (!electronUpdateIsAvailable) {
            try {
                await electron_updater_1.autoUpdater.checkForUpdates();
            }
            catch (error) { }
        }
        await new Promise(resolve => setTimeout(resolve, pollInterval));
    }
}
if (!config_1.default.isLocalhost) {
    pollForElectronUpdates();
}
//# sourceMappingURL=autoUpdater.js.map

//notion-enhancer
require('notion-enhancer/pkg/loader.js')(__filename, exports);