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    
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const electron = require("electron");
function sendMainToNotion(eventName, ...args) {
    electron.BrowserWindow.getAllWindows().forEach(window => {
        sendMainToNotionWindow(window, eventName, ...args);
    });
}
exports.sendMainToNotion = sendMainToNotion;
function sendMainToNotionWindow(window, eventName, ...args) {
    window.webContents.send(eventName, ...args);
}
exports.sendMainToNotionWindow = sendMainToNotionWindow;
exports.receiveNotionFromMain = {
    addListener(eventName, fn) {
        electron.ipcRenderer.addListener(eventName, fn);
    },
    removeListener(eventName, fn) {
        electron.ipcRenderer.removeListener(eventName, fn);
    },
};
function proxyMainToNotion(notionWebView, eventName) {
    electron.ipcRenderer.addListener(eventName, (event, arg) => {
        electron.remote.webContents
            .fromId(notionWebView.getWebContentsId())
            .send(eventName, arg);
    });
}
const mainToNotionIpcMap = {
    "notion:update-error": true,
    "notion:checking-for-update": true,
    "notion:update-available": true,
    "notion:update-not-available": true,
    "notion:update-progress": true,
    "notion:update-ready": true,
    "notion:app-update-finished": true,
    "notion:app-update-error": true,
    "notion:checking-for-app-update": true,
    "notion:app-update-available": true,
    "notion:app-update-not-available": true,
    "notion:app-update-progress": true,
    "notion:app-update-ready": true,
    "notion:popup-callback": true,
    "notion:broadcast": true,
    "notion:google-drive-picker-callback": true,
    "notion:get-cookie-response": true,
    "notion:navigate-to-url": true,
};
const mainToNotionIpcEvents = Object.keys(mainToNotionIpcMap);
function proxyAllMainToNotion(notionWebView) {
    for (const eventName of mainToNotionIpcEvents) {
        proxyMainToNotion(notionWebView, eventName);
    }
}
exports.proxyAllMainToNotion = proxyAllMainToNotion;
function sendToMain(eventName, ...args) {
    electron.ipcRenderer.send(eventName, ...args);
}
exports.sendToMain = sendToMain;
exports.receiveMainFromRenderer = {
    addListener(eventName, fn) {
        electron.ipcMain.addListener(eventName, fn);
    },
    removeListener(eventName, fn) {
        electron.ipcMain.removeListener(eventName, fn);
    },
};
function sendIndexToNotion(notionWebView, eventName, ...args) {
    electron.remote.webContents
        .fromId(notionWebView.getWebContentsId())
        .send(eventName, ...args);
}
exports.sendIndexToNotion = sendIndexToNotion;
exports.receiveNotionFromIndex = {
    addListener(eventName, fn) {
        electron.ipcRenderer.addListener(eventName, fn);
    },
    removeListener(eventName, fn) {
        electron.ipcRenderer.removeListener(eventName, fn);
    },
};
function sendIndexToSearch(searchWebView, eventName, ...args) {
    electron.remote.webContents
        .fromId(searchWebView.getWebContentsId())
        .send(eventName, ...args);
}
exports.sendIndexToSearch = sendIndexToSearch;
exports.receiveSearchFromIndex = {
    addListener(eventName, fn) {
        electron.ipcRenderer.addListener(eventName, fn);
    },
    removeListener(eventName, fn) {
        electron.ipcRenderer.removeListener(eventName, fn);
    },
};
function sendSearchToIndex(eventName, ...args) {
    electron.ipcRenderer.sendToHost(eventName, ...args);
}
exports.sendSearchToIndex = sendSearchToIndex;
function sendNotionToIndex(eventName, ...args) {
    electron.ipcRenderer.sendToHost(eventName, ...args);
}
exports.sendNotionToIndex = sendNotionToIndex;
const receiveIndexFromNotionFnMap = new Map();
exports.receiveIndexFromNotion = {
    addListener(notionWebView, eventName, fn) {
        const listener = (event) => {
            if (event && event.channel === eventName) {
                const arg = event.args && event.args[0];
                fn(arg);
            }
        };
        receiveIndexFromNotionFnMap.set(fn, listener);
        notionWebView.addEventListener("ipc-message", listener);
    },
    removeListener(notionWebView, eventName, fn) {
        const listener = receiveIndexFromNotionFnMap.get(fn);
        if (listener) {
            notionWebView.removeEventListener("ipc-message", listener);
            receiveIndexFromNotionFnMap.delete(fn);
        }
    },
};
const receiveIndexFromSearchFnMap = new Map();
exports.receiveIndexFromSearch = {
    addListener(searchWebView, eventName, fn) {
        const listener = (event) => {
            if (event && event.channel === eventName) {
                const arg = event.args && event.args[0];
                fn(arg);
            }
        };
        receiveIndexFromSearchFnMap.set(fn, listener);
        searchWebView.addEventListener("ipc-message", listener);
    },
    removeListener(searchWebView, eventName, fn) {
        const listener = receiveIndexFromSearchFnMap.get(fn);
        if (listener) {
            searchWebView.removeEventListener("ipc-message", listener);
            receiveIndexFromSearchFnMap.delete(fn);
        }
    },
};
const broacastListenerMap = new Map();
exports.broadcast = {
    emit(channel, ...args) {
        sendToMain("notion:broadcast", {
            windowId: electron.remote.getCurrentWindow().id,
            channel: channel,
            args: args,
        });
    },
    addListener(channel, fn) {
        const callback = (sender, payload) => {
            if (payload.windowId !== electron.remote.getCurrentWindow().id &&
                payload.channel === channel) {
                fn(...payload.args);
            }
        };
        broacastListenerMap.set(fn, callback);
        exports.receiveNotionFromMain.addListener("notion:broadcast", callback);
    },
    removeListener(eventName, fn) {
        const callback = broacastListenerMap.get(fn);
        if (callback) {
            exports.receiveNotionFromMain.removeListener("notion:broadcast", callback);
            broacastListenerMap.delete(fn);
        }
    },
};
//# sourceMappingURL=notionIpc.js.map