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 / createPopup.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
const path = require("path");
const config_1 = require("../config");
const notionIpc = require("../helpers/notionIpc");
const urlHelpers = require("../shared/urlHelpers");
const constants_1 = require("../shared/constants");
async function createPopup(args) {
    const { url, title, width, height } = args;
    const rect = {
        x: undefined,
        y: undefined,
        width: width,
        height: height,
    };
    const focusedWindow = electron_1.BrowserWindow.getFocusedWindow();
    if (focusedWindow) {
        const [winX, winY] = focusedWindow.getPosition();
        const [winWidth, winHeight] = focusedWindow.getSize();
        rect.x = Math.round(winX + winWidth / 2 - width / 2);
        rect.y = Math.round(winY + winHeight / 2 - height / 2);
        rect.width = width;
        rect.height = height;
    }
    const baseURLDomain = urlHelpers.parse(config_1.default.baseURL).hostname;
    if (!baseURLDomain) {
        throw new Error("No base URL domain.");
    }
    const window = new electron_1.BrowserWindow({
        ...rect,
        title: title,
        webPreferences: {
            preload: path.join(__dirname, "../renderer/popupPreload.js"),
            nodeIntegration: false,
            session: electron_1.session.fromPartition(constants_1.electronSessionPartition),
        },
    });
    const handlePostMessage = (event, data) => {
        if (data && data.type === "popup-callback") {
            notionIpc.receiveMainFromRenderer.removeListener("notion:post-message", handlePostMessage);
            window.removeListener("close", handleClose);
            window.close();
            notionIpc.sendMainToNotion("notion:popup-callback", data.url);
        }
    };
    const handleClose = () => {
        notionIpc.receiveMainFromRenderer.removeListener("notion:post-message", handlePostMessage);
        window.removeListener("close", handleClose);
        notionIpc.sendMainToNotion("notion:popup-callback", undefined);
    };
    notionIpc.receiveMainFromRenderer.addListener("notion:post-message", handlePostMessage);
    window.addListener("close", handleClose);
    window.loadURL(url);
}
exports.createPopup = createPopup;
//# sourceMappingURL=createPopup.js.map

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