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 / createGoogleDrivePicker.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 createGoogleDrivePicker(args) {
    const { url } = args;
    const rect = {
        x: undefined,
        y: undefined,
        width: 566,
        height: 350,
    };
    const PICKER_MAX_WIDTH = 1051;
    const PICKER_MAX_HEIGHT = 650;
    const focusedWindow = electron_1.BrowserWindow.getFocusedWindow();
    if (focusedWindow) {
        const [winX, winY] = focusedWindow.getPosition();
        const [winWidth, winHeight] = focusedWindow.getSize();
        rect.width = Math.min(Math.max(rect.width, winWidth * 0.8), PICKER_MAX_WIDTH);
        rect.height = Math.min(Math.max(rect.height, winHeight * 0.8), PICKER_MAX_HEIGHT);
        rect.x = Math.round(winX + winWidth / 2 - rect.width / 2);
        rect.y = Math.round(winY + winHeight / 2 - rect.height / 2);
    }
    const baseURLDomain = urlHelpers.parse(config_1.default.baseURL).hostname;
    if (!baseURLDomain) {
        throw new Error("No base URL dmain.");
    }
    const window = new electron_1.BrowserWindow({
        ...rect,
        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 === "google-drive-picker-callback") {
            notionIpc.receiveMainFromRenderer.removeListener("notion:post-message", handlePostMessage);
            window.removeListener("close", handleClose);
            window.close();
            notionIpc.sendMainToNotion("notion:google-drive-picker-callback", data.file);
        }
    };
    const handleClose = () => {
        notionIpc.receiveMainFromRenderer.removeListener("notion:post-message", handlePostMessage);
        window.removeListener("close", handleClose);
        notionIpc.sendMainToNotion("notion:google-drive-picker-callback", undefined);
    };
    notionIpc.receiveMainFromRenderer.addListener("notion:post-message", handlePostMessage);
    window.addListener("close", handleClose);
    window.loadURL(url);
}
exports.createGoogleDrivePicker = createGoogleDrivePicker;
//# sourceMappingURL=createGoogleDrivePicker.js.map

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