示例工程 45-sandbox-and-permissions
45-sandbox-and-permissions/app/.tsc/shared/ipc.js
export const CH = {
snapshot: "sandbox:snapshot",
setNotifications: "sandbox:set-notifications",
simulate: "sandbox:simulate-permission",
download: "sandbox:download",
probe: "sandbox:probe",
refresh: "sandbox:refresh",
};
export function assertNotificationReq(value) {
if (typeof value !== "object" || value === null) {
throw new Error("BAD_NOTIFICATION_REQ");
}
if (typeof value.enabled !== "boolean") {
throw new Error("BAD_NOTIFICATION_REQ");
}
}
const PERMISSIONS = new Set([
"notifications",
"media",
"geolocation",
"clipboard-read",
"openExternal",
]);
export function assertPermissionReq(value) {
if (typeof value !== "object" || value === null) {
throw new Error("BAD_PERMISSION_REQ");
}
const permission = value.permission;
if (typeof permission !== "string" || !PERMISSIONS.has(permission)) {
throw new Error("BAD_PERMISSION");
}
}
//# sourceMappingURL=ipc.js.map