示例工程 36-project-desktop-hub

36-project-desktop-hub/app/.tsc/shared/ipc.js

javascript · 1.8 KB

export const CH = {
    snapshot: "hub:snapshot",
    setView: "hub:set-view",
    openLink: "hub:open-link",
    notify: "hub:notify",
    setAutostart: "hub:set-autostart",
    hide: "hub:hide",
    show: "hub:show",
    closeToTray: "hub:close-to-tray",
    quit: "hub:quit",
    refresh: "hub:refresh",
};
export function assertViewReq(value) {
    if (typeof value !== "object" || value === null) {
        throw new Error("BAD_VIEW_REQ");
    }
    const view = value.view;
    if (view !== "inbox" && view !== "tasks" && view !== "settings") {
        throw new Error("BAD_VIEW");
    }
}
export function assertLinkReq(value) {
    if (typeof value !== "object" || value === null) {
        throw new Error("BAD_LINK_REQ");
    }
    const req = value;
    if (typeof req.url !== "string" ||
        req.url.length === 0 ||
        req.url.length > 2048) {
        throw new Error("BAD_URL");
    }
    if (req.source !== "manual" &&
        req.source !== "second-instance" &&
        req.source !== "open-url") {
        throw new Error("BAD_SOURCE");
    }
}
export function assertNotifyReq(value) {
    if (typeof value !== "object" || value === null) {
        throw new Error("BAD_NOTIFY_REQ");
    }
    const req = value;
    if (typeof req.title !== "string" ||
        req.title.length === 0 ||
        req.title.length > 120) {
        throw new Error("BAD_TITLE");
    }
    if (typeof req.body !== "string" || req.body.length > 500) {
        throw new Error("BAD_BODY");
    }
}
export function assertAutostartReq(value) {
    if (typeof value !== "object" || value === null) {
        throw new Error("BAD_AUTOSTART_REQ");
    }
    const req = value;
    if (typeof req.enabled !== "boolean" || typeof req.dryRun !== "boolean") {
        throw new Error("BAD_AUTOSTART_REQ");
    }
}
//# sourceMappingURL=ipc.js.map