示例工程 29-menu-tray
29-menu-tray/app/.tsc/shared/ipc.js
export const CH = {
get: "menu:get",
invoke: "menu:invoke",
setFlag: "menu:set-flag",
popup: "menu:popup",
reset: "menu:reset",
changed: "menu:changed",
};
export function assertInvokeReq(value) {
if (typeof value !== "object" || value === null) {
throw new Error("BAD_INVOKE_REQ");
}
const id = value.id;
if (typeof id !== "string" || id.length === 0 || id.length > 64) {
throw new Error("BAD_INVOKE_REQ");
}
}
export function assertFlagReq(value) {
if (typeof value !== "object" || value === null) {
throw new Error("BAD_FLAG_REQ");
}
const { key, value: flag } = value;
if ((key !== "compact" && key !== "statusbar") || typeof flag !== "boolean") {
throw new Error("BAD_FLAG_REQ");
}
}
export function assertPopupReq(value) {
if (typeof value !== "object" || value === null) {
throw new Error("BAD_POPUP_REQ");
}
const { x, y } = value;
if (typeof x !== "number" ||
typeof y !== "number" ||
!Number.isFinite(x) ||
!Number.isFinite(y) ||
x < 0 ||
y < 0 ||
x > 10000 ||
y > 10000) {
throw new Error("BAD_POPUP_REQ");
}
}
//# sourceMappingURL=ipc.js.map