/** * Parameters for creating a delegated Permissions API. * * @see {@link createDelegatedPermissions} to create a delegated Permissions * API. */ export interface DelegatedPermissionsParameters { /** * The Permissions APIs to delegate to. * * The list must have at least one delegate, which will be selected initially. * The list is static, and cannot be changed after the delegated API is * created. */ delegates: globalThis.Permissions[]; } /** * The result of calling {@link createDelegatedPermissions}. */ export interface DelegatedPermissionsResult { /** * The delegated Permissions API. */ readonly permissions: globalThis.Permissions; /** * A handle for controlling the delegated Permissions API. */ readonly handle: DelegatedPermissionsHandle; } /** * A handle for controlling a delegated Permissions API. */ export interface DelegatedPermissionsHandle { /** * Select a Permissions API delegate. * * @param delegate - The delegate to select. */ selectDelegate: (delegate: globalThis.Permissions) => void; /** * Get the selected Permissions API delegate. * * @returns The selected delegate. */ selectedDelegate: () => globalThis.Permissions; /** * Check if a Permissions API delegate is selected. * * @param delegate - The delegate to check. * * @returns `true` if the delegate is selected, `false` otherwise. */ isSelectedDelegate: (delegate: globalThis.Permissions) => boolean; } /** * Create a Permissions API that delegates to other Permissions APIs. * * Delegated Permissions APIs can be used, for example, to dynamically "switch" * between a fake Permissions API and a real Permissions API. * * When {@link globalThis.Permissions.query | Permissions.query} is called on * the delegated Permissions API, the resulting {@link PermissionStatus} will * reflect the {@link PermissionState} of the permission in the selected * delegate. * * Permissions API delegates can be selected dynamically at any time, and any * {@link PermissionStatus} queries will immediately update to reflect the new * delegate's {@link PermissionState} for the relevant permission, dispatching * events as appropriate to any registered `change` listeners. * * @param params - The parameters for creating the delegated Permissions API. * * @returns The delegated Permissions API, and functions for managing the * selected delegate. * @throws A {@link TypeError} if no delegates are provided. * * @inlineType DelegatedPermissionsParameters * @inlineType DelegatedPermissionsResult */ export declare function createDelegatedPermissions(params: DelegatedPermissionsParameters): DelegatedPermissionsResult;