示例工程 33-clipboard-dnd-fs

33-clipboard-dnd-fs/app/.tsc/shared/ipc.js

javascript · 1.2 KB

export const CH = {
    get: "clipboard:get",
    readClipboard: "clipboard:read",
    writeText: "clipboard:write-text",
    writeHtml: "clipboard:write-html",
    readPath: "fs:read-path",
    pickFile: "fs:pick",
    refreshRecent: "fs:refresh-recent",
    clearRecent: "fs:clear-recent",
};
export function assertTextReq(value) {
    if (typeof value !== "object" || value === null) {
        throw new Error("BAD_TEXT_REQ");
    }
    const text = value.text;
    if (typeof text !== "string" || text.length > 100_000) {
        throw new Error("BAD_TEXT_REQ");
    }
}
export function assertHtmlReq(value) {
    if (typeof value !== "object" || value === null) {
        throw new Error("BAD_HTML_REQ");
    }
    const html = value.html;
    if (typeof html !== "string" || html.length > 100_000) {
        throw new Error("BAD_HTML_REQ");
    }
}
export function assertPathReq(value) {
    if (typeof value !== "object" || value === null) {
        throw new Error("BAD_PATH_REQ");
    }
    const path = value.path;
    if (typeof path !== "string" ||
        path.length === 0 ||
        path.length > 4096 ||
        path.includes("\0")) {
        throw new Error("BAD_PATH_REQ");
    }
}
//# sourceMappingURL=ipc.js.map