mirror of
https://github.com/denoland/deno.git
synced 2025-09-30 06:04:48 +00:00
feat: move unstable Deno.permissions to navigator.permissions (#6244)
This commit is contained in:
parent
e92cf5b9e8
commit
202e7fa6ad
15 changed files with 403 additions and 243 deletions
54
cli/js/lib.deno.shared_globals.d.ts
vendored
54
cli/js/lib.deno.shared_globals.d.ts
vendored
|
@ -1556,6 +1556,60 @@ declare const AbortSignal: {
|
|||
new (): AbortSignal;
|
||||
};
|
||||
|
||||
type PermissionState = "denied" | "granted" | "prompt";
|
||||
|
||||
interface PermissionStatusEventMap {
|
||||
change: Event;
|
||||
}
|
||||
|
||||
interface PermissionStatus extends EventTarget {
|
||||
onchange: ((this: PermissionStatus, ev: Event) => any) | null;
|
||||
readonly state: PermissionState;
|
||||
addEventListener<K extends keyof PermissionStatusEventMap>(
|
||||
type: K,
|
||||
listener: (this: PermissionStatus, ev: PermissionStatusEventMap[K]) => any,
|
||||
options?: boolean | AddEventListenerOptions
|
||||
): void;
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | AddEventListenerOptions
|
||||
): void;
|
||||
removeEventListener<K extends keyof PermissionStatusEventMap>(
|
||||
type: K,
|
||||
listener: (this: PermissionStatus, ev: PermissionStatusEventMap[K]) => any,
|
||||
options?: boolean | EventListenerOptions
|
||||
): void;
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | EventListenerOptions
|
||||
): void;
|
||||
}
|
||||
|
||||
/** Deno does not currently support any of the browser permissions, and so the
|
||||
* `name` property of the global types is `undefined`. The Deno permissions
|
||||
* that are supported are defined in the `lib.deno.ns.d.ts` and pull from the
|
||||
* `Deno` namespace. */
|
||||
declare interface PermissionDescriptor {
|
||||
name: undefined;
|
||||
}
|
||||
|
||||
declare interface Permissions {
|
||||
query(permissionDesc: PermissionDescriptor): Promise<PermissionStatus>;
|
||||
}
|
||||
|
||||
declare const Permissions: {
|
||||
prototype: Permissions;
|
||||
new (): Permissions;
|
||||
};
|
||||
|
||||
declare class Navigator {
|
||||
readonly permissions: Permissions;
|
||||
}
|
||||
|
||||
declare const navigator: Navigator;
|
||||
|
||||
interface ErrorConstructor {
|
||||
/** See https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions. */
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue