From dcb4ffb93a380710c32cc212b937ea38db5ceacc Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 25 Nov 2022 18:29:48 -0500 Subject: refactor: move dts files, diagnostics.rs, and tsc.rs to tsc folder (#16820) --- cli/dts/README.md | 29 - cli/dts/lib.d.ts | 24 - cli/dts/lib.deno.ns.d.ts | 5217 -------- cli/dts/lib.deno.shared_globals.d.ts | 684 -- cli/dts/lib.deno.unstable.d.ts | 1911 --- cli/dts/lib.deno.window.d.ts | 270 - cli/dts/lib.deno.worker.d.ts | 208 - cli/dts/lib.deno_webgpu.d.ts | 1322 --- cli/dts/lib.dom.asynciterable.d.ts | 9 - cli/dts/lib.dom.d.ts | 18269 ----------------------------- cli/dts/lib.dom.extras.d.ts | 149 - cli/dts/lib.dom.iterable.d.ts | 337 - cli/dts/lib.es2015.collection.d.ts | 150 - cli/dts/lib.es2015.core.d.ts | 559 - cli/dts/lib.es2015.d.ts | 30 - cli/dts/lib.es2015.generator.d.ts | 79 - cli/dts/lib.es2015.iterable.d.ts | 498 - cli/dts/lib.es2015.promise.d.ts | 78 - cli/dts/lib.es2015.proxy.d.ts | 130 - cli/dts/lib.es2015.reflect.d.ts | 123 - cli/dts/lib.es2015.symbol.d.ts | 48 - cli/dts/lib.es2015.symbol.wellknown.d.ts | 324 - cli/dts/lib.es2016.array.include.d.ts | 118 - cli/dts/lib.es2016.d.ts | 22 - cli/dts/lib.es2016.full.d.ts | 25 - cli/dts/lib.es2017.d.ts | 26 - cli/dts/lib.es2017.full.d.ts | 25 - cli/dts/lib.es2017.intl.d.ts | 47 - cli/dts/lib.es2017.object.d.ts | 51 - cli/dts/lib.es2017.sharedmemory.d.ts | 137 - cli/dts/lib.es2017.string.d.ts | 47 - cli/dts/lib.es2017.typedarrays.d.ts | 55 - cli/dts/lib.es2018.asyncgenerator.d.ts | 79 - cli/dts/lib.es2018.asynciterable.d.ts | 45 - cli/dts/lib.es2018.d.ts | 26 - cli/dts/lib.es2018.full.d.ts | 25 - cli/dts/lib.es2018.intl.d.ts | 73 - cli/dts/lib.es2018.promise.d.ts | 32 - cli/dts/lib.es2018.regexp.d.ts | 39 - cli/dts/lib.es2019.array.d.ts | 85 - cli/dts/lib.es2019.d.ts | 25 - cli/dts/lib.es2019.full.d.ts | 25 - cli/dts/lib.es2019.object.d.ts | 35 - cli/dts/lib.es2019.string.d.ts | 39 - cli/dts/lib.es2019.symbol.d.ts | 26 - cli/dts/lib.es2020.bigint.d.ts | 730 -- cli/dts/lib.es2020.d.ts | 29 - cli/dts/lib.es2020.date.d.ts | 44 - cli/dts/lib.es2020.full.d.ts | 25 - cli/dts/lib.es2020.intl.d.ts | 433 - cli/dts/lib.es2020.number.d.ts | 30 - cli/dts/lib.es2020.promise.d.ts | 49 - cli/dts/lib.es2020.sharedmemory.d.ts | 99 - cli/dts/lib.es2020.string.d.ts | 30 - cli/dts/lib.es2020.symbol.wellknown.d.ts | 39 - cli/dts/lib.es2021.d.ts | 25 - cli/dts/lib.es2021.full.d.ts | 25 - cli/dts/lib.es2021.intl.d.ts | 154 - cli/dts/lib.es2021.promise.d.ts | 50 - cli/dts/lib.es2021.string.d.ts | 35 - cli/dts/lib.es2021.weakref.d.ts | 75 - cli/dts/lib.es2022.array.d.ts | 123 - cli/dts/lib.es2022.d.ts | 27 - cli/dts/lib.es2022.error.d.ts | 75 - cli/dts/lib.es2022.full.d.ts | 25 - cli/dts/lib.es2022.intl.d.ts | 111 - cli/dts/lib.es2022.object.d.ts | 28 - cli/dts/lib.es2022.sharedmemory.d.ts | 27 - cli/dts/lib.es2022.string.d.ts | 27 - cli/dts/lib.es5.d.ts | 4513 ------- cli/dts/lib.es6.d.ts | 25 - cli/dts/lib.esnext.array.d.ts | 583 - cli/dts/lib.esnext.d.ts | 23 - cli/dts/lib.esnext.full.d.ts | 25 - cli/dts/lib.esnext.intl.d.ts | 30 - cli/dts/lib.scripthost.d.ts | 327 - cli/dts/lib.webworker.d.ts | 5956 ---------- cli/dts/lib.webworker.importscripts.d.ts | 26 - cli/dts/lib.webworker.iterable.d.ts | 167 - cli/dts/typescript.d.ts | 8118 ------------- 80 files changed, 53663 deletions(-) delete mode 100644 cli/dts/README.md delete mode 100644 cli/dts/lib.d.ts delete mode 100644 cli/dts/lib.deno.ns.d.ts delete mode 100644 cli/dts/lib.deno.shared_globals.d.ts delete mode 100644 cli/dts/lib.deno.unstable.d.ts delete mode 100644 cli/dts/lib.deno.window.d.ts delete mode 100644 cli/dts/lib.deno.worker.d.ts delete mode 100644 cli/dts/lib.deno_webgpu.d.ts delete mode 100644 cli/dts/lib.dom.asynciterable.d.ts delete mode 100644 cli/dts/lib.dom.d.ts delete mode 100644 cli/dts/lib.dom.extras.d.ts delete mode 100644 cli/dts/lib.dom.iterable.d.ts delete mode 100644 cli/dts/lib.es2015.collection.d.ts delete mode 100644 cli/dts/lib.es2015.core.d.ts delete mode 100644 cli/dts/lib.es2015.d.ts delete mode 100644 cli/dts/lib.es2015.generator.d.ts delete mode 100644 cli/dts/lib.es2015.iterable.d.ts delete mode 100644 cli/dts/lib.es2015.promise.d.ts delete mode 100644 cli/dts/lib.es2015.proxy.d.ts delete mode 100644 cli/dts/lib.es2015.reflect.d.ts delete mode 100644 cli/dts/lib.es2015.symbol.d.ts delete mode 100644 cli/dts/lib.es2015.symbol.wellknown.d.ts delete mode 100644 cli/dts/lib.es2016.array.include.d.ts delete mode 100644 cli/dts/lib.es2016.d.ts delete mode 100644 cli/dts/lib.es2016.full.d.ts delete mode 100644 cli/dts/lib.es2017.d.ts delete mode 100644 cli/dts/lib.es2017.full.d.ts delete mode 100644 cli/dts/lib.es2017.intl.d.ts delete mode 100644 cli/dts/lib.es2017.object.d.ts delete mode 100644 cli/dts/lib.es2017.sharedmemory.d.ts delete mode 100644 cli/dts/lib.es2017.string.d.ts delete mode 100644 cli/dts/lib.es2017.typedarrays.d.ts delete mode 100644 cli/dts/lib.es2018.asyncgenerator.d.ts delete mode 100644 cli/dts/lib.es2018.asynciterable.d.ts delete mode 100644 cli/dts/lib.es2018.d.ts delete mode 100644 cli/dts/lib.es2018.full.d.ts delete mode 100644 cli/dts/lib.es2018.intl.d.ts delete mode 100644 cli/dts/lib.es2018.promise.d.ts delete mode 100644 cli/dts/lib.es2018.regexp.d.ts delete mode 100644 cli/dts/lib.es2019.array.d.ts delete mode 100644 cli/dts/lib.es2019.d.ts delete mode 100644 cli/dts/lib.es2019.full.d.ts delete mode 100644 cli/dts/lib.es2019.object.d.ts delete mode 100644 cli/dts/lib.es2019.string.d.ts delete mode 100644 cli/dts/lib.es2019.symbol.d.ts delete mode 100644 cli/dts/lib.es2020.bigint.d.ts delete mode 100644 cli/dts/lib.es2020.d.ts delete mode 100644 cli/dts/lib.es2020.date.d.ts delete mode 100644 cli/dts/lib.es2020.full.d.ts delete mode 100644 cli/dts/lib.es2020.intl.d.ts delete mode 100644 cli/dts/lib.es2020.number.d.ts delete mode 100644 cli/dts/lib.es2020.promise.d.ts delete mode 100644 cli/dts/lib.es2020.sharedmemory.d.ts delete mode 100644 cli/dts/lib.es2020.string.d.ts delete mode 100644 cli/dts/lib.es2020.symbol.wellknown.d.ts delete mode 100644 cli/dts/lib.es2021.d.ts delete mode 100644 cli/dts/lib.es2021.full.d.ts delete mode 100644 cli/dts/lib.es2021.intl.d.ts delete mode 100644 cli/dts/lib.es2021.promise.d.ts delete mode 100644 cli/dts/lib.es2021.string.d.ts delete mode 100644 cli/dts/lib.es2021.weakref.d.ts delete mode 100644 cli/dts/lib.es2022.array.d.ts delete mode 100644 cli/dts/lib.es2022.d.ts delete mode 100644 cli/dts/lib.es2022.error.d.ts delete mode 100644 cli/dts/lib.es2022.full.d.ts delete mode 100644 cli/dts/lib.es2022.intl.d.ts delete mode 100644 cli/dts/lib.es2022.object.d.ts delete mode 100644 cli/dts/lib.es2022.sharedmemory.d.ts delete mode 100644 cli/dts/lib.es2022.string.d.ts delete mode 100644 cli/dts/lib.es5.d.ts delete mode 100644 cli/dts/lib.es6.d.ts delete mode 100644 cli/dts/lib.esnext.array.d.ts delete mode 100644 cli/dts/lib.esnext.d.ts delete mode 100644 cli/dts/lib.esnext.full.d.ts delete mode 100644 cli/dts/lib.esnext.intl.d.ts delete mode 100644 cli/dts/lib.scripthost.d.ts delete mode 100644 cli/dts/lib.webworker.d.ts delete mode 100644 cli/dts/lib.webworker.importscripts.d.ts delete mode 100644 cli/dts/lib.webworker.iterable.d.ts delete mode 100644 cli/dts/typescript.d.ts (limited to 'cli/dts') diff --git a/cli/dts/README.md b/cli/dts/README.md deleted file mode 100644 index 14d937c88..000000000 --- a/cli/dts/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# How to upgrade TypeScript. - -The files in this directory are mostly from the TypeScript repository. We -currently (unfortunately) have a rather manual process for upgrading TypeScript. -It works like this currently: - -1. Checkout denoland/TypeScript repo in a separate directory. -1. Add Microsoft/TypeScript as a remote and fetch its latest tags -1. Checkout a new branch based on this tag. -1. Cherry pick the custom commit we made in a previous release to the new one. -1. This commit has a "deno.ts" file in it. Read the instructions in it. -1. Copy typescript.js into Deno repo. -1. Copy d.ts files into dts directory. - -So that might look something like this: - -``` -git clone https://github.com/denoland/TypeScript.git -cd typescript -git remote add upstream https://github.com/Microsoft/TypeScript -git fetch upstream -git checkout v3.9.7 -git checkout -b branch_v3.9.7 -git cherry pick -npm install -gulp local -rsync lib/typescript.js ~/src/deno/cli/tsc/00_typescript.js -rsync --exclude=protocol.d.ts --exclude=tsserverlibrary.d.ts --exclude=typescriptServices.d.ts lib/*.d.ts ~/src/deno/cli/dts/ -``` diff --git a/cli/dts/lib.d.ts b/cli/dts/lib.d.ts deleted file mode 100644 index 9152c4dfc..000000000 --- a/cli/dts/lib.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - - - -/// - - -/// -/// -/// -/// diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts deleted file mode 100644 index 1049bf643..000000000 --- a/cli/dts/lib.deno.ns.d.ts +++ /dev/null @@ -1,5217 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. - -/// -/// -/// - -/** Deno provides extra properties on `import.meta`. These are included here - * to ensure that these are still available when using the Deno namespace in - * conjunction with other type libs, like `dom`. - * - * @category ES Modules - */ -declare interface ImportMeta { - /** A string representation of the fully qualified module URL. When the - * module is loaded locally, the value will be a file URL (e.g. - * `file:///path/module.ts`). - * - * You can also parse the string as a URL to determine more information about - * how the current module was loaded. For example to determine if a module was - * local or not: - * - * ```ts - * const url = new URL(import.meta.url); - * if (url.protocol === "file:") { - * console.log("this module was loaded locally"); - * } - * ``` - */ - url: string; - - /** A flag that indicates if the current module is the main module that was - * called when starting the program under Deno. - * - * ```ts - * if (import.meta.main) { - * // this was loaded as the main module, maybe do some bootstrapping - * } - * ``` - */ - main: boolean; - - /** A function that returns resolved specifier as if it would be imported - * using `import(specifier)`. - * - * ```ts - * console.log(import.meta.resolve("./foo.js")); - * // file:///dev/foo.js - * ``` - */ - resolve(specifier: string): string; -} - -/** Deno supports [User Timing Level 3](https://w3c.github.io/user-timing) - * which is not widely supported yet in other runtimes. - * - * Check out the - * [Performance API](https://developer.mozilla.org/en-US/docs/Web/API/Performance) - * documentation on MDN for further information about how to use the API. - * - * @category Performance - */ -declare interface Performance { - /** Stores a timestamp with the associated name (a "mark"). */ - mark(markName: string, options?: PerformanceMarkOptions): PerformanceMark; - - /** Stores the `DOMHighResTimeStamp` duration between two marks along with the - * associated name (a "measure"). */ - measure( - measureName: string, - options?: PerformanceMeasureOptions, - ): PerformanceMeasure; -} - -/** - * Options which are used in conjunction with `performance.mark`. Check out the - * MDN - * [`performance.mark()`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark#markoptions) - * documentation for more details. - * - * @category Performance - */ -declare interface PerformanceMarkOptions { - /** Metadata to be included in the mark. */ - // deno-lint-ignore no-explicit-any - detail?: any; - - /** Timestamp to be used as the mark time. */ - startTime?: number; -} - -/** - * Options which are used in conjunction with `performance.measure`. Check out the - * MDN - * [`performance.mark()`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure#measureoptions) - * documentation for more details. - * - * @category Performance - */ -declare interface PerformanceMeasureOptions { - /** Metadata to be included in the measure. */ - // deno-lint-ignore no-explicit-any - detail?: any; - - /** Timestamp to be used as the start time or string to be used as start - * mark. */ - start?: string | number; - - /** Duration between the start and end times. */ - duration?: number; - - /** Timestamp to be used as the end time or string to be used as end mark. */ - end?: string | number; -} - -/** The global namespace where Deno specific, non-standard APIs are located. */ -declare namespace Deno { - /** A set of error constructors that are raised by Deno APIs. - * - * Can be used to provide more specific handling of failures within code - * which is using Deno APIs. For example, handling attempting to open a file - * which does not exist: - * - * ```ts - * try { - * const file = await Deno.open("./some/file.txt"); - * } catch (error) { - * if (error instanceof Deno.errors.NotFound) { - * console.error("the file was not found"); - * } else { - * // otherwise re-throw - * throw error; - * } - * } - * ``` - * - * @category Errors - */ - export namespace errors { - /** - * Raised when the underlying operating system indicates that the file - * was not found. - * - * @category Errors */ - export class NotFound extends Error {} - /** - * Raised when the underlying operating system indicates the current user - * which the Deno process is running under does not have the appropriate - * permissions to a file or resource, or the user _did not_ provide required - * `--allow-*` flag. - * - * @category Errors */ - export class PermissionDenied extends Error {} - /** - * Raised when the underlying operating system reports that a connection to - * a resource is refused. - * - * @category Errors */ - export class ConnectionRefused extends Error {} - /** - * Raised when the underlying operating system reports that a connection has - * been reset. With network servers, it can be a _normal_ occurrence where a - * client will abort a connection instead of properly shutting it down. - * - * @category Errors */ - export class ConnectionReset extends Error {} - /** - * Raised when the underlying operating system reports an `ECONNABORTED` - * error. - * - * @category Errors */ - export class ConnectionAborted extends Error {} - /** - * Raised when the underlying operating system reports an `ENOTCONN` error. - * - * @category Errors */ - export class NotConnected extends Error {} - /** - * Raised when attempting to open a server listener on an address and port - * that already has a listener. - * - * @category Errors */ - export class AddrInUse extends Error {} - /** - * Raised when the underlying operating system reports an `EADDRNOTAVAIL` - * error. - * - * @category Errors */ - export class AddrNotAvailable extends Error {} - /** - * Raised when trying to write to a resource and a broken pipe error occurs. - * This can happen when trying to write directly to `stdout` or `stderr` - * and the operating system is unable to pipe the output for a reason - * external to the Deno runtime. - * - * @category Errors */ - export class BrokenPipe extends Error {} - /** - * Raised when trying to create a resource, like a file, that already - * exits. - * - * @category Errors */ - export class AlreadyExists extends Error {} - /** - * Raised when an operation to returns data that is invalid for the - * operation being performed. - * - * @category Errors */ - export class InvalidData extends Error {} - /** - * Raised when the underlying operating system reports that an I/O operation - * has timed out (`ETIMEDOUT`). - * - * @category Errors */ - export class TimedOut extends Error {} - /** - * Raised when the underlying operating system reports an `EINTR` error. In - * many cases, this underlying IO error will be handled internally within - * Deno, or result in an @{link BadResource} error instead. - * - * @category Errors */ - export class Interrupted extends Error {} - /** - * Raised when expecting to write to a IO buffer resulted in zero bytes - * being written. - * - * @category Errors */ - export class WriteZero extends Error {} - /** - * Raised when attempting to read bytes from a resource, but the EOF was - * unexpectedly encountered. - * - * @category Errors */ - export class UnexpectedEof extends Error {} - /** - * The underlying IO resource is invalid or closed, and so the operation - * could not be performed. - * - * @category Errors */ - export class BadResource extends Error {} - /** - * Raised in situations where when attempting to load a dynamic import, - * too many redirects were encountered. - * - * @category Errors */ - export class Http extends Error {} - /** - * Raised when the underlying IO resource is not available because it is - * being awaited on in another block of code. - * - * @category Errors */ - export class Busy extends Error {} - /** - * Raised when the underlying Deno API is asked to perform a function that - * is not currently supported. - * - * @category Errors */ - export class NotSupported extends Error {} - } - - /** The current process ID of this instance of the Deno CLI. - * - * ```ts - * console.log(Deno.pid); - * ``` - * - * @category Runtime Environment - */ - export const pid: number; - - /** - * The process ID of parent process of this instance of the Deno CLI. - * - * ```ts - * console.log(Deno.ppid); - * ``` - * - * @category Runtime Environment - */ - export const ppid: number; - - /** @category Runtime Environment */ - export interface MemoryUsage { - /** The number of bytes of the current Deno's process resident set size, - * which is the amount of memory occupied in main memory (RAM). */ - rss: number; - /** The total size of the heap for V8, in bytes. */ - heapTotal: number; - /** The amount of the heap used for V8, in bytes. */ - heapUsed: number; - /** Memory, in bytes, associated with JavaScript objects outside of the - * JavaScript isolate. */ - external: number; - } - - /** - * Returns an object describing the memory usage of the Deno process and the - * V8 subsystem measured in bytes. - * - * @category Runtime Environment - */ - export function memoryUsage(): MemoryUsage; - - /** - * Get the `hostname` of the machine the Deno process is running on. - * - * ```ts - * console.log(Deno.hostname()); - * ``` - * - * Requires `allow-sys` permission. - * - * @tags allow-sys - * @category Runtime Environment - */ - export function hostname(): string; - - /** - * Returns an array containing the 1, 5, and 15 minute load averages. The - * load average is a measure of CPU and IO utilization of the last one, five, - * and 15 minute periods expressed as a fractional number. Zero means there - * is no load. On Windows, the three values are always the same and represent - * the current load, not the 1, 5 and 15 minute load averages. - * - * ```ts - * console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ] - * ``` - * - * Requires `allow-sys` permission. - * - * @tags allow-sys - * @category Observability - */ - export function loadavg(): number[]; - - /** - * The information for a network interface returned from a call to - * {@linkcode Deno.networkInterfaces}. - * - * @category Network - */ - export interface NetworkInterfaceInfo { - /** The network interface name. */ - name: string; - /** The IP protocol version. */ - family: "IPv4" | "IPv6"; - /** The IP address bound to the interface. */ - address: string; - /** The netmask applied to the interface. */ - netmask: string; - /** The IPv6 scope id or `null`. */ - scopeid: number | null; - /** The CIDR range. */ - cidr: string; - /** The MAC address. */ - mac: string; - } - - /** - * Returns an array of the network interface information. - * - * ```ts - * console.log(Deno.networkInterfaces()); - * ``` - * - * Requires `allow-sys` permission. - * - * @tags allow-sys - * @category Network - */ - export function networkInterfaces(): NetworkInterfaceInfo[]; - - /** - * Displays the total amount of free and used physical and swap memory in the - * system, as well as the buffers and caches used by the kernel. - * - * This is similar to the `free` command in Linux - * - * ```ts - * console.log(Deno.systemMemoryInfo()); - * ``` - * - * Requires `allow-sys` permission. - * - * @tags allow-sys - * @category Runtime Environment - */ - export function systemMemoryInfo(): SystemMemoryInfo; - - /** - * Information returned from a call to {@linkcode Deno.systemMemoryInfo}. - * - * @category Runtime Environment - */ - export interface SystemMemoryInfo { - /** Total installed memory in bytes. */ - total: number; - /** Unused memory in bytes. */ - free: number; - /** Estimation of how much memory, in bytes, is available for starting new - * applications, without swapping. Unlike the data provided by the cache or - * free fields, this field takes into account page cache and also that not - * all reclaimable memory will be reclaimed due to items being in use. - */ - available: number; - /** Memory used by kernel buffers. */ - buffers: number; - /** Memory used by the page cache and slabs. */ - cached: number; - /** Total swap memory. */ - swapTotal: number; - /** Unused swap memory. */ - swapFree: number; - } - - /** Reflects the `NO_COLOR` environment variable at program start. - * - * When the value is `true`, the Deno CLI will attempt to not send color codes - * to `stderr` or `stdout` and other command line programs should also attempt - * to respect this value. - * - * See: https://no-color.org/ - * - * @category Runtime Environment - */ - export const noColor: boolean; - - /** - * Returns the release version of the Operating System. - * - * ```ts - * console.log(Deno.osRelease()); - * ``` - * - * Requires `allow-sys` permission. - * Under consideration to possibly move to Deno.build or Deno.versions and if - * it should depend sys-info, which may not be desirable. - * - * @tags allow-sys - * @category Runtime Environment - */ - export function osRelease(): string; - - /** - * Options which define the permissions within a test or worker context. - * - * `"inherit"` ensures that all permissions of the parent process will be - * applied to the test context. `"none"` ensures the test context has no - * permissions. A `PermissionOptionsObject` provides a more specific - * set of permissions to the test context. - * - * @category Permissions */ - export type PermissionOptions = - | "inherit" - | "none" - | PermissionOptionsObject; - - /** - * A set of options which can define the permissions within a test or worker - * context at a highly specific level. - * - * @category Permissions */ - export interface PermissionOptionsObject { - /** Specifies if the `env` permission should be requested or revoked. - * If set to `"inherit"`, the current `env` permission will be inherited. - * If set to `true`, the global `env` permission will be requested. - * If set to `false`, the global `env` permission will be revoked. - * - * Defaults to `false`. - */ - env?: "inherit" | boolean | string[]; - - /** Specifies if the `sys` permission should be requested or revoked. - * If set to `"inherit"`, the current `sys` permission will be inherited. - * If set to `true`, the global `sys` permission will be requested. - * If set to `false`, the global `sys` permission will be revoked. - * - * Defaults to `false`. - */ - sys?: "inherit" | boolean | string[]; - - /** Specifies if the `hrtime` permission should be requested or revoked. - * If set to `"inherit"`, the current `hrtime` permission will be inherited. - * If set to `true`, the global `hrtime` permission will be requested. - * If set to `false`, the global `hrtime` permission will be revoked. - * - * Defaults to `false`. - */ - hrtime?: "inherit" | boolean; - - /** Specifies if the `net` permission should be requested or revoked. - * if set to `"inherit"`, the current `net` permission will be inherited. - * if set to `true`, the global `net` permission will be requested. - * if set to `false`, the global `net` permission will be revoked. - * if set to `string[]`, the `net` permission will be requested with the - * specified host strings with the format `"[:]`. - * - * Defaults to `false`. - * - * Examples: - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.test({ - * name: "inherit", - * permissions: { - * net: "inherit", - * }, - * async fn() { - * const status = await Deno.permissions.query({ name: "net" }) - * assertEquals(status.state, "granted"); - * }, - * }); - * ``` - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.test({ - * name: "true", - * permissions: { - * net: true, - * }, - * async fn() { - * const status = await Deno.permissions.query({ name: "net" }); - * assertEquals(status.state, "granted"); - * }, - * }); - * ``` - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.test({ - * name: "false", - * permissions: { - * net: false, - * }, - * async fn() { - * const status = await Deno.permissions.query({ name: "net" }); - * assertEquals(status.state, "denied"); - * }, - * }); - * ``` - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.test({ - * name: "localhost:8080", - * permissions: { - * net: ["localhost:8080"], - * }, - * async fn() { - * const status = await Deno.permissions.query({ name: "net", host: "localhost:8080" }); - * assertEquals(status.state, "granted"); - * }, - * }); - * ``` - */ - net?: "inherit" | boolean | string[]; - - /** Specifies if the `ffi` permission should be requested or revoked. - * If set to `"inherit"`, the current `ffi` permission will be inherited. - * If set to `true`, the global `ffi` permission will be requested. - * If set to `false`, the global `ffi` permission will be revoked. - * - * Defaults to `false`. - */ - ffi?: "inherit" | boolean | Array; - - /** Specifies if the `read` permission should be requested or revoked. - * If set to `"inherit"`, the current `read` permission will be inherited. - * If set to `true`, the global `read` permission will be requested. - * If set to `false`, the global `read` permission will be revoked. - * If set to `Array`, the `read` permission will be requested with the - * specified file paths. - * - * Defaults to `false`. - */ - read?: "inherit" | boolean | Array; - - /** Specifies if the `run` permission should be requested or revoked. - * If set to `"inherit"`, the current `run` permission will be inherited. - * If set to `true`, the global `run` permission will be requested. - * If set to `false`, the global `run` permission will be revoked. - * - * Defaults to `false`. - */ - run?: "inherit" | boolean | Array; - - /** Specifies if the `write` permission should be requested or revoked. - * If set to `"inherit"`, the current `write` permission will be inherited. - * If set to `true`, the global `write` permission will be requested. - * If set to `false`, the global `write` permission will be revoked. - * If set to `Array`, the `write` permission will be requested with the - * specified file paths. - * - * Defaults to `false`. - */ - write?: "inherit" | boolean | Array; - } - - /** - * Context that is passed to a testing function, which can be used to either - * gain information about the current test, or register additional test - * steps within the current test. - * - * @category Testing */ - export interface TestContext { - /** The current test name. */ - name: string; - /** The string URL of the current test. */ - origin: string; - /** If the current test is a step of another test, the parent test context - * will be set here. */ - parent?: TestContext; - - /** Run a sub step of the parent test or step. Returns a promise - * that resolves to a boolean signifying if the step completed successfully. - * - * The returned promise never rejects unless the arguments are invalid. - * - * If the test was ignored the promise returns `false`. - * - * ```ts - * Deno.test({ - * name: "a parent test", - * async fn(t) { - * console.log("before the step"); - * await t.step({ - * name: "step 1", - * fn(t) { - * console.log("current step:", t.name); - * } - * }); - * console.log("after the step"); - * } - * }); - * ``` - */ - step(definition: TestStepDefinition): Promise; - - /** Run a sub step of the parent test or step. Returns a promise - * that resolves to a boolean signifying if the step completed successfully. - * - * The returned promise never rejects unless the arguments are invalid. - * - * If the test was ignored the promise returns `false`. - * - * ```ts - * Deno.test( - * "a parent test", - * async (t) => { - * console.log("before the step"); - * await t.step( - * "step 1", - * (t) => { - * console.log("current step:", t.name); - * } - * ); - * console.log("after the step"); - * } - * ); - * ``` - */ - step( - name: string, - fn: (t: TestContext) => void | Promise, - ): Promise; - } - - /** @category Testing */ - export interface TestStepDefinition { - /** The test function that will be tested when this step is executed. The - * function can take an argument which will provide information about the - * current step's context. */ - fn: (t: TestContext) => void | Promise; - /** The name of the step. */ - name: string; - /** If truthy the current test step will be ignored. - * - * This is a quick way to skip over a step, but also can be used for - * conditional logic, like determining if an environment feature is present. - */ - ignore?: boolean; - /** Check that the number of async completed operations after the test step - * is the same as number of dispatched operations. This ensures that the - * code tested does not start async operations which it then does - * not await. This helps in preventing logic errors and memory leaks - * in the application code. - * - * Defaults to the parent test or step's value. */ - sanitizeOps?: boolean; - /** Ensure the test step does not "leak" resources - like open files or - * network connections - by ensuring the open resources at the start of the - * step match the open resources at the end of the step. - * - * Defaults to the parent test or step's value. */ - sanitizeResources?: boolean; - /** Ensure the test step does not prematurely cause the process to exit, - * for example via a call to {@linkcode Deno.exit}. - * - * Defaults to the parent test or step's value. */ - sanitizeExit?: boolean; - } - - /** @category Testing */ - export interface TestDefinition { - fn: (t: TestContext) => void | Promise; - /** The name of the test. */ - name: string; - /** If truthy the current test step will be ignored. - * - * It is a quick way to skip over a step, but also can be used for - * conditional logic, like determining if an environment feature is present. - */ - ignore?: boolean; - /** If at least one test has `only` set to `true`, only run tests that have - * `only` set to `true` and fail the test suite. */ - only?: boolean; - /** Check that the number of async completed operations after the test step - * is the same as number of dispatched operations. This ensures that the - * code tested does not start async operations which it then does - * not await. This helps in preventing logic errors and memory leaks - * in the application code. - * - * Defaults to `true`. */ - sanitizeOps?: boolean; - /** Ensure the test step does not "leak" resources - like open files or - * network connections - by ensuring the open resources at the start of the - * test match the open resources at the end of the test. - * - * Defaults to `true`. */ - sanitizeResources?: boolean; - /** Ensure the test case does not prematurely cause the process to exit, - * for example via a call to {@linkcode Deno.exit}. - * - * Defaults to `true`. */ - sanitizeExit?: boolean; - /** Specifies the permissions that should be used to run the test. - * - * Set this to "inherit" to keep the calling runtime permissions, set this - * to "none" to revoke all permissions, or set a more specific set of - * permissions using a {@linkcode PermissionOptionsObject}. - * - * Defaults to `"inherit"`. */ - permissions?: PermissionOptions; - } - - /** Register a test which will be run when `deno test` is used on the command - * line and the containing module looks like a test module. - * - * `fn` can be async if required. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.test({ - * name: "example test", - * fn() { - * assertEquals("world", "world"); - * }, - * }); - * - * Deno.test({ - * name: "example ignored test", - * ignore: Deno.build.os === "windows", - * fn() { - * // This test is ignored only on Windows machines - * }, - * }); - * - * Deno.test({ - * name: "example async test", - * async fn() { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * } - * }); - * ``` - * - * @category Testing - */ - export function test(t: TestDefinition): void; - - /** Register a test which will be run when `deno test` is used on the command - * line and the containing module looks like a test module. - * - * `fn` can be async if required. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.test("My test description", () => { - * assertEquals("hello", "hello"); - * }); - * - * Deno.test("My async test description", async () => { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * }); - * ``` - * - * @category Testing - */ - export function test( - name: string, - fn: (t: TestContext) => void | Promise, - ): void; - - /** Register a test which will be run when `deno test` is used on the command - * line and the containing module looks like a test module. - * - * `fn` can be async if required. Declared function must have a name. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.test(function myTestName() { - * assertEquals("hello", "hello"); - * }); - * - * Deno.test(async function myOtherTestName() { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * }); - * ``` - * - * @category Testing - */ - export function test(fn: (t: TestContext) => void | Promise): void; - - /** Register a test which will be run when `deno test` is used on the command - * line and the containing module looks like a test module. - * - * `fn` can be async if required. - * - * ```ts - * import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.test("My test description", { permissions: { read: true } }, (): void => { - * assertEquals("hello", "hello"); - * }); - * - * Deno.test("My async test description", { permissions: { read: false } }, async (): Promise => { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * }); - * ``` - * - * @category Testing - */ - export function test( - name: string, - options: Omit, - fn: (t: TestContext) => void | Promise, - ): void; - - /** Register a test which will be run when `deno test` is used on the command - * line and the containing module looks like a test module. - * - * `fn` can be async if required. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.test( - * { - * name: "My test description", - * permissions: { read: true }, - * }, - * () => { - * assertEquals("hello", "hello"); - * }, - * ); - * - * Deno.test( - * { - * name: "My async test description", - * permissions: { read: false }, - * }, - * async () => { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * }, - * ); - * ``` - * - * @category Testing - */ - export function test( - options: Omit, - fn: (t: TestContext) => void | Promise, - ): void; - - /** Register a test which will be run when `deno test` is used on the command - * line and the containing module looks like a test module. - * - * `fn` can be async if required. Declared function must have a name. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.test( - * { permissions: { read: true } }, - * function myTestName() { - * assertEquals("hello", "hello"); - * }, - * ); - * - * Deno.test( - * { permissions: { read: false } }, - * async function myOtherTestName() { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * }, - * ); - * ``` - * - * @category Testing - */ - export function test( - options: Omit, - fn: (t: TestContext) => void | Promise, - ): void; - - /** - * The interface for defining a benchmark test using {@linkcode Deno.bench}. - * - * @category Testing - */ - export interface BenchDefinition { - /** The test function which will be benchmarked. */ - fn: () => void | Promise; - /** The name of the test, which will be used in displaying the results. */ - name: string; - /** If truthy, the benchmark test will be ignored/skipped. */ - ignore?: boolean; - /** Group name for the benchmark. - * - * Grouped benchmarks produce a group time summary, where the difference - * in performance between each test of the group is compared. */ - group?: string; - /** Benchmark should be used as the baseline for other benchmarks. - * - * If there are multiple baselines in a group, the first one is used as the - * baseline. */ - baseline?: boolean; - /** If at least one bench has `only` set to true, only run benches that have - * `only` set to `true` and fail the bench suite. */ - only?: boolean; - /** Ensure the bench case does not prematurely cause the process to exit, - * for example via a call to {@linkcode Deno.exit}. Defaults to `true`. */ - sanitizeExit?: boolean; - /** Specifies the permissions that should be used to run the bench. - * - * Set this to `"inherit"` to keep the calling thread's permissions. - * - * Set this to `"none"` to revoke all permissions. - * - * Defaults to "inherit". - */ - permissions?: PermissionOptions; - } - - /** - * Register a benchmark test which will be run when `deno bench` is used on - * the command line and the containing module looks like a bench module. - * - * If the test function (`fn`) returns a promise or is async, the test runner - * will await resolution to consider the test complete. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.bench({ - * name: "example test", - * fn() { - * assertEquals("world", "world"); - * }, - * }); - * - * Deno.bench({ - * name: "example ignored test", - * ignore: Deno.build.os === "windows", - * fn() { - * // This test is ignored only on Windows machines - * }, - * }); - * - * Deno.bench({ - * name: "example async test", - * async fn() { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * } - * }); - * ``` - * - * @category Testing - */ - export function bench(t: BenchDefinition): void; - - /** - * Register a benchmark test which will be run when `deno bench` is used on - * the command line and the containing module looks like a bench module. - * - * If the test function (`fn`) returns a promise or is async, the test runner - * will await resolution to consider the test complete. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.bench("My test description", () => { - * assertEquals("hello", "hello"); - * }); - * - * Deno.bench("My async test description", async () => { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * }); - * ``` - * - * @category Testing - */ - export function bench( - name: string, - fn: () => void | Promise, - ): void; - - /** - * Register a benchmark test which will be run when `deno bench` is used on - * the command line and the containing module looks like a bench module. - * - * If the test function (`fn`) returns a promise or is async, the test runner - * will await resolution to consider the test complete. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.bench(function myTestName() { - * assertEquals("hello", "hello"); - * }); - * - * Deno.bench(async function myOtherTestName() { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * }); - * ``` - * - * @category Testing - */ - export function bench(fn: () => void | Promise): void; - - /** - * Register a benchmark test which will be run when `deno bench` is used on - * the command line and the containing module looks like a bench module. - * - * If the test function (`fn`) returns a promise or is async, the test runner - * will await resolution to consider the test complete. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.bench( - * "My test description", - * { permissions: { read: true } }, - * () => { - * assertEquals("hello", "hello"); - * } - * ); - * - * Deno.bench( - * "My async test description", - * { permissions: { read: false } }, - * async () => { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * } - * ); - * ``` - * - * @category Testing - */ - export function bench( - name: string, - options: Omit, - fn: () => void | Promise, - ): void; - - /** - * Register a benchmark test which will be run when `deno bench` is used on - * the command line and the containing module looks like a bench module. - * - * If the test function (`fn`) returns a promise or is async, the test runner - * will await resolution to consider the test complete. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.bench( - * { name: "My test description", permissions: { read: true } }, - * () => { - * assertEquals("hello", "hello"); - * } - * ); - * - * Deno.bench( - * { name: "My async test description", permissions: { read: false } }, - * async () => { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * } - * ); - * ``` - * - * @category Testing - */ - export function bench( - options: Omit, - fn: () => void | Promise, - ): void; - - /** - * Register a benchmark test which will be run when `deno bench` is used on - * the command line and the containing module looks like a bench module. - * - * If the test function (`fn`) returns a promise or is async, the test runner - * will await resolution to consider the test complete. - * - * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; - * - * Deno.bench( - * { permissions: { read: true } }, - * function myTestName() { - * assertEquals("hello", "hello"); - * } - * ); - * - * Deno.bench( - * { permissions: { read: false } }, - * async function myOtherTestName() { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world"); - * } - * ); - * ``` - * - * @category Testing - */ - export function bench( - options: Omit, - fn: () => void | Promise, - ): void; - - /** Exit the Deno process with optional exit code. - * - * If no exit code is supplied then Deno will exit with return code of `0`. - * - * In worker contexts this is an alias to `self.close();`. - * - * ```ts - * Deno.exit(5); - * ``` - * - * @category Runtime Environment - */ - export function exit(code?: number): never; - - /** An interface containing methods to interact with the process environment - * variables. - * - * @tags allow-env - * @category Runtime Environment - */ - export interface Env { - /** Retrieve the value of an environment variable. - * - * Returns `undefined` if the supplied environment variable is not defined. - * - * ```ts - * console.log(Deno.env.get("HOME")); // e.g. outputs "/home/alice" - * console.log(Deno.env.get("MADE_UP_VAR")); // outputs "undefined" - * ``` - * - * Requires `allow-env` permission. - * - * @tags allow-env - */ - get(key: string): string | undefined; - - /** Set the value of an environment variable. - * - * ```ts - * Deno.env.set("SOME_VAR", "Value"); - * Deno.env.get("SOME_VAR"); // outputs "Value" - * ``` - * - * Requires `allow-env` permission. - * - * @tags allow-env - */ - set(key: string, value: string): void; - - /** Delete the value of an environment variable. - * - * ```ts - * Deno.env.set("SOME_VAR", "Value"); - * Deno.env.delete("SOME_VAR"); // outputs "undefined" - * ``` - * - * Requires `allow-env` permission. - * - * @tags allow-env - */ - delete(key: string): void; - - /** Returns a snapshot of the environment variables at invocation as a - * simple object of keys and values. - * - * ```ts - * Deno.env.set("TEST_VAR", "A"); - * const myEnv = Deno.env.toObject(); - * console.log(myEnv.SHELL); - * Deno.env.set("TEST_VAR", "B"); - * console.log(myEnv.TEST_VAR); // outputs "A" - * ``` - * - * Requires `allow-env` permission. - * - * @tags allow-env - */ - toObject(): { [index: string]: string }; - } - - /** An interface containing methods to interact with the process environment - * variables. - * - * @tags allow-env - * @category Runtime Environment - */ - export const env: Env; - - /** - * Returns the path to the current deno executable. - * - * ```ts - * console.log(Deno.execPath()); // e.g. "/home/alice/.local/bin/deno" - * ``` - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category Runtime Environment - */ - export function execPath(): string; - - /** - * Change the current working directory to the specified path. - * - * ```ts - * Deno.chdir("/home/userA"); - * Deno.chdir("../userB"); - * Deno.chdir("C:\\Program Files (x86)\\Java"); - * ``` - * - * Throws {@linkcode Deno.errors.NotFound} if directory not found. - * - * Throws {@linkcode Deno.errors.PermissionDenied} if the user does not have - * operating system file access rights. - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category Runtime Environment - */ - export function chdir(directory: string | URL): void; - - /** - * Return a string representing the current working directory. - * - * If the current directory can be reached via multiple paths (due to symbolic - * links), `cwd()` may return any one of them. - * - * ```ts - * const currentWorkingDirectory = Deno.cwd(); - * ``` - * - * Throws {@linkcode Deno.errors.NotFound} if directory not available. - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category Runtime Environment - */ - export function cwd(): string; - - /** - * Creates `newpath` as a hard link to `oldpath`. - * - * ```ts - * await Deno.link("old/name", "new/name"); - * ``` - * - * Requires `allow-read` and `allow-write` permissions. - * - * @tags allow-read, allow-write - * @category File System - */ - export function link(oldpath: string, newpath: string): Promise; - - /** - * Synchronously creates `newpath` as a hard link to `oldpath`. - * - * ```ts - * Deno.linkSync("old/name", "new/name"); - * ``` - * - * Requires `allow-read` and `allow-write` permissions. - * - * @tags allow-read, allow-write - * @category File System - */ - export function linkSync(oldpath: string, newpath: string): void; - - /** - * A enum which defines the seek mode for IO related APIs that support - * seeking. - * - * @category I/O */ - export enum SeekMode { - /* Seek from the start of the file/resource. */ - Start = 0, - /* Seek from the current position within the file/resource. */ - Current = 1, - /* Seek from the end of the current file/resource. */ - End = 2, - } - - /** - * An abstract interface which when implemented provides an interface to read - * bytes into an array buffer asynchronously. - * - * @category I/O */ - export interface Reader { - /** Reads up to `p.byteLength` bytes into `p`. It resolves to the number of - * bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error - * encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may - * use all of `p` as scratch space during the call. If some data is - * available but not `p.byteLength` bytes, `read()` conventionally resolves - * to what is available instead of waiting for more. - * - * When `read()` encounters end-of-file condition, it resolves to EOF - * (`null`). - * - * When `read()` encounters an error, it rejects with an error. - * - * Callers should always process the `n` > `0` bytes returned before - * considering the EOF (`null`). Doing so correctly handles I/O errors that - * happen after reading some bytes and also both of the allowed EOF - * behaviors. - * - * Implementations should not retain a reference to `p`. - * - * Use - * [`itereateReader`](https://deno.land/std/streams/conversion.ts?s=iterateReader) - * from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * to turn a `Reader` into an {@linkcode AsyncIterator}. - */ - read(p: Uint8Array): Promise; - } - - /** - * An abstract interface which when implemented provides an interface to read - * bytes into an array buffer synchronously. - * - * @category I/O */ - export interface ReaderSync { - /** Reads up to `p.byteLength` bytes into `p`. It resolves to the number - * of bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error - * encountered. Even if `readSync()` returns `n` < `p.byteLength`, it may use - * all of `p` as scratch space during the call. If some data is available - * but not `p.byteLength` bytes, `readSync()` conventionally returns what is - * available instead of waiting for more. - * - * When `readSync()` encounters end-of-file condition, it returns EOF - * (`null`). - * - * When `readSync()` encounters an error, it throws with an error. - * - * Callers should always process the `n` > `0` bytes returned before - * considering the EOF (`null`). Doing so correctly handles I/O errors that - * happen after reading some bytes and also both of the allowed EOF - * behaviors. - * - * Implementations should not retain a reference to `p`. - * - * Use - * [`itereateReaderSync`](https://deno.land/std/streams/conversion.ts?s=iterateReaderSync) - * from from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * to turn a `ReaderSync` into an {@linkcode Iterator}. - */ - readSync(p: Uint8Array): number | null; - } - - /** - * An abstract interface which when implemented provides an interface to write - * bytes from an array buffer to a file/resource asynchronously. - * - * @category I/O */ - export interface Writer { - /** Writes `p.byteLength` bytes from `p` to the underlying data stream. It - * resolves to the number of bytes written from `p` (`0` <= `n` <= - * `p.byteLength`) or reject with the error encountered that caused the - * write to stop early. `write()` must reject with a non-null error if - * would resolve to `n` < `p.byteLength`. `write()` must not modify the - * slice data, even temporarily. - * - * Implementations should not retain a reference to `p`. - */ - write(p: Uint8Array): Promise; - } - - /** - * An abstract interface which when implemented provides an interface to write - * bytes from an array buffer to a file/resource synchronously. - * - * @category I/O */ - export interface WriterSync { - /** Writes `p.byteLength` bytes from `p` to the underlying data - * stream. It returns the number of bytes written from `p` (`0` <= `n` - * <= `p.byteLength`) and any error encountered that caused the write to - * stop early. `writeSync()` must throw a non-null error if it returns `n` < - * `p.byteLength`. `writeSync()` must not modify the slice data, even - * temporarily. - * - * Implementations should not retain a reference to `p`. - */ - writeSync(p: Uint8Array): number; - } - - /** - * An abstract interface which when implemented provides an interface to close - * files/resources that were previously opened. - * - * @category I/O */ - export interface Closer { - /** Closes the resource, "freeing" the backing file/resource. */ - close(): void; - } - - /** - * An abstract interface which when implemented provides an interface to seek - * within an open file/resource asynchronously. - * - * @category I/O */ - export interface Seeker { - /** Seek sets the offset for the next `read()` or `write()` to offset, - * interpreted according to `whence`: `Start` means relative to the - * start of the file, `Current` means relative to the current offset, - * and `End` means relative to the end. Seek resolves to the new offset - * relative to the start of the file. - * - * Seeking to an offset before the start of the file is an error. Seeking to - * any positive offset is legal, but the behavior of subsequent I/O - * operations on the underlying object is implementation-dependent. - * - * It resolves with the updated offset. - */ - seek(offset: number, whence: SeekMode): Promise; - } - - /** - * An abstract interface which when implemented provides an interface to seek - * within an open file/resource synchronously. - * - * @category I/O */ - export interface SeekerSync { - /** Seek sets the offset for the next `readSync()` or `writeSync()` to - * offset, interpreted according to `whence`: `Start` means relative - * to the start of the file, `Current` means relative to the current - * offset, and `End` means relative to the end. - * - * Seeking to an offset before the start of the file is an error. Seeking to - * any positive offset is legal, but the behavior of subsequent I/O - * operations on the underlying object is implementation-dependent. - * - * It returns the updated offset. - */ - seekSync(offset: number, whence: SeekMode): number; - } - - /** - * Copies from `src` to `dst` until either EOF (`null`) is read from `src` or - * an error occurs. It resolves to the number of bytes copied or rejects with - * the first error encountered while copying. - * - * @deprecated Use - * [`copy`](https://deno.land/std/streams/conversion.ts?s=copy) from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. `Deno.copy` will be removed in the future. - * - * @category I/O - * - * @param src The source to copy from - * @param dst The destination to copy to - * @param options Can be used to tune size of the buffer. Default size is 32kB - */ - export function copy( - src: Reader, - dst: Writer, - options?: { bufSize?: number }, - ): Promise; - - /** - * Turns a Reader, `r`, into an async iterator. - * - * @deprecated Use - * [`iterateReader`](https://deno.land/std/streams/conversion.ts?s=iterateReader) - * from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. `Deno.iter` will be removed in the future. - * - * @category I/O - */ - export function iter( - r: Reader, - options?: { bufSize?: number }, - ): AsyncIterableIterator; - - /** - * Turns a ReaderSync, `r`, into an iterator. - * - * @deprecated Use - * [`iterateReaderSync`](https://deno.land/std/streams/conversion.ts?s=iterateReaderSync) - * from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. `Deno.iterSync` will be removed in the future. - * - * @category I/O - */ - export function iterSync( - r: ReaderSync, - options?: { - bufSize?: number; - }, - ): IterableIterator; - - /** Open a file and resolve to an instance of {@linkcode Deno.FsFile}. The - * file does not need to previously exist if using the `create` or `createNew` - * open options. It is the caller's responsibility to close the file when - * finished with it. - * - * ```ts - * const file = await Deno.open("/foo/bar.txt", { read: true, write: true }); - * // Do work with file - * Deno.close(file.rid); - * ``` - * - * Requires `allow-read` and/or `allow-write` permissions depending on - * options. - * - * @tags allow-read, allow-write - * @category File System - */ - export function open( - path: string | URL, - options?: OpenOptions, - ): Promise; - - /** Synchronously open a file and return an instance of - * {@linkcode Deno.FsFile}. The file does not need to previously exist if - * using the `create` or `createNew` open options. It is the caller's - * responsibility to close the file when finished with it. - * - * ```ts - * const file = Deno.openSync("/foo/bar.txt", { read: true, write: true }); - * // Do work with file - * Deno.close(file.rid); - * ``` - * - * Requires `allow-read` and/or `allow-write` permissions depending on - * options. - * - * @tags allow-read, allow-write - * @category File System - */ - export function openSync(path: string | URL, options?: OpenOptions): FsFile; - - /** Creates a file if none exists or truncates an existing file and resolves to - * an instance of {@linkcode Deno.FsFile}. - * - * ```ts - * const file = await Deno.create("/foo/bar.txt"); - * ``` - * - * Requires `allow-read` and `allow-write` permissions. - * - * @tags allow-read, allow-write - * @category File System - */ - export function create(path: string | URL): Promise; - - /** Creates a file if none exists or truncates an existing file and returns - * an instance of {@linkcode Deno.FsFile}. - * - * ```ts - * const file = Deno.createSync("/foo/bar.txt"); - * ``` - * - * Requires `allow-read` and `allow-write` permissions. - * - * @tags allow-read, allow-write - * @category File System - */ - export function createSync(path: string | URL): FsFile; - - /** Read from a resource ID (`rid`) into an array buffer (`buffer`). - * - * Resolves to either the number of bytes read during the operation or EOF - * (`null`) if there was nothing more to read. - * - * It is possible for a read to successfully return with `0` bytes. This does - * not indicate EOF. - * - * This function is one of the lowest level APIs and most users should not - * work with this directly, but rather use - * [`readAll()`](https://deno.land/std/streams/conversion.ts?s=readAll) from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. - * - * **It is not guaranteed that the full buffer will be read in a single call.** - * - * ```ts - * // if "/foo/bar.txt" contains the text "hello world": - * const file = await Deno.open("/foo/bar.txt"); - * const buf = new Uint8Array(100); - * const numberOfBytesRead = await Deno.read(file.rid, buf); // 11 bytes - * const text = new TextDecoder().decode(buf); // "hello world" - * Deno.close(file.rid); - * ``` - * - * @category I/O - */ - export function read(rid: number, buffer: Uint8Array): Promise; - - /** Synchronously read from a resource ID (`rid`) into an array buffer - * (`buffer`). - * - * Returns either the number of bytes read during the operation or EOF - * (`null`) if there was nothing more to read. - * - * It is possible for a read to successfully return with `0` bytes. This does - * not indicate EOF. - * - * This function is one of the lowest level APIs and most users should not - * work with this directly, but rather use - * [`readAllSync()`](https://deno.land/std/streams/conversion.ts?s=readAllSync) - * from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. - * - * **It is not guaranteed that the full buffer will be read in a single - * call.** - * - * ```ts - * // if "/foo/bar.txt" contains the text "hello world": - * const file = Deno.openSync("/foo/bar.txt"); - * const buf = new Uint8Array(100); - * const numberOfBytesRead = Deno.readSync(file.rid, buf); // 11 bytes - * const text = new TextDecoder().decode(buf); // "hello world" - * Deno.close(file.rid); - * ``` - * - * @category I/O - */ - export function readSync(rid: number, buffer: Uint8Array): number | null; - - /** Write to the resource ID (`rid`) the contents of the array buffer (`data`). - * - * Resolves to the number of bytes written. This function is one of the lowest - * level APIs and most users should not work with this directly, but rather use - * [`writeAll()`](https://deno.land/std/streams/conversion.ts?s=writeAll) from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. - * - * **It is not guaranteed that the full buffer will be written in a single - * call.** - * - * ```ts - * const encoder = new TextEncoder(); - * const data = encoder.encode("Hello world"); - * const file = await Deno.open("/foo/bar.txt", { write: true }); - * const bytesWritten = await Deno.write(file.rid, data); // 11 - * Deno.close(file.rid); - * ``` - * - * @category I/O - */ - export function write(rid: number, data: Uint8Array): Promise; - - /** Synchronously write to the resource ID (`rid`) the contents of the array - * buffer (`data`). - * - * Returns the number of bytes written. This function is one of the lowest - * level APIs and most users should not work with this directly, but rather - * use - * [`writeAllSync()`](https://deno.land/std/streams/conversion.ts?s=writeAllSync) - * from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. - * - * **It is not guaranteed that the full buffer will be written in a single - * call.** - * - * ```ts - * const encoder = new TextEncoder(); - * const data = encoder.encode("Hello world"); - * const file = Deno.openSync("/foo/bar.txt", { write: true }); - * const bytesWritten = Deno.writeSync(file.rid, data); // 11 - * Deno.close(file.rid); - * ``` - * - * @category I/O - */ - export function writeSync(rid: number, data: Uint8Array): number; - - /** Seek a resource ID (`rid`) to the given `offset` under mode given by `whence`. - * The call resolves to the new position within the resource (bytes from the start). - * - * ```ts - * // Given file.rid pointing to file with "Hello world", which is 11 bytes long: - * const file = await Deno.open( - * "hello.txt", - * { read: true, write: true, truncate: true, create: true }, - * ); - * await Deno.write(file.rid, new TextEncoder().encode("Hello world")); - * - * // advance cursor 6 bytes - * const cursorPosition = await Deno.seek(file.rid, 6, Deno.SeekMode.Start); - * console.log(cursorPosition); // 6 - * const buf = new Uint8Array(100); - * await file.read(buf); - * console.log(new TextDecoder().decode(buf)); // "world" - * file.close(); - * ``` - * - * The seek modes work as follows: - * - * ```ts - * // Given file.rid pointing to file with "Hello world", which is 11 bytes long: - * const file = await Deno.open( - * "hello.txt", - * { read: true, write: true, truncate: true, create: true }, - * ); - * await Deno.write(file.rid, new TextEncoder().encode("Hello world")); - * - * // Seek 6 bytes from the start of the file - * console.log(await Deno.seek(file.rid, 6, Deno.SeekMode.Start)); // "6" - * // Seek 2 more bytes from the current position - * console.log(await Deno.seek(file.rid, 2, Deno.SeekMode.Current)); // "8" - * // Seek backwards 2 bytes from the end of the file - * console.log(await Deno.seek(file.rid, -2, Deno.SeekMode.End)); // "9" (e.g. 11-2) - * file.close(); - * ``` - * - * @category I/O - */ - export function seek( - rid: number, - offset: number, - whence: SeekMode, - ): Promise; - - /** Synchronously seek a resource ID (`rid`) to the given `offset` under mode - * given by `whence`. The new position within the resource (bytes from the - * start) is returned. - * - * ```ts - * const file = Deno.openSync( - * "hello.txt", - * { read: true, write: true, truncate: true, create: true }, - * ); - * Deno.writeSync(file.rid, new TextEncoder().encode("Hello world")); - * - * // advance cursor 6 bytes - * const cursorPosition = Deno.seekSync(file.rid, 6, Deno.SeekMode.Start); - * console.log(cursorPosition); // 6 - * const buf = new Uint8Array(100); - * file.readSync(buf); - * console.log(new TextDecoder().decode(buf)); // "world" - * file.close(); - * ``` - * - * The seek modes work as follows: - * - * ```ts - * // Given file.rid pointing to file with "Hello world", which is 11 bytes long: - * const file = Deno.openSync( - * "hello.txt", - * { read: true, write: true, truncate: true, create: true }, - * ); - * Deno.writeSync(file.rid, new TextEncoder().encode("Hello world")); - * - * // Seek 6 bytes from the start of the file - * console.log(Deno.seekSync(file.rid, 6, Deno.SeekMode.Start)); // "6" - * // Seek 2 more bytes from the current position - * console.log(Deno.seekSync(file.rid, 2, Deno.SeekMode.Current)); // "8" - * // Seek backwards 2 bytes from the end of the file - * console.log(Deno.seekSync(file.rid, -2, Deno.SeekMode.End)); // "9" (e.g. 11-2) - * file.close(); - * ``` - * - * @category I/O - */ - export function seekSync( - rid: number, - offset: number, - whence: SeekMode, - ): number; - - /** - * Flushes any pending data and metadata operations of the given file stream - * to disk. - * - * ```ts - * const file = await Deno.open( - * "my_file.txt", - * { read: true, write: true, create: true }, - * ); - * await Deno.write(file.rid, new TextEncoder().encode("Hello World")); - * await Deno.ftruncate(file.rid, 1); - * await Deno.fsync(file.rid); - * console.log(new TextDecoder().decode(await Deno.readFile("my_file.txt"))); // H - * ``` - * - * @category I/O - */ - export function fsync(rid: number): Promise; - - /** - * Synchronously flushes any pending data and metadata operations of the given - * file stream to disk. - * - * ```ts - * const file = Deno.openSync( - * "my_file.txt", - * { read: true, write: true, create: true }, - * ); - * Deno.writeSync(file.rid, new TextEncoder().encode("Hello World")); - * Deno.ftruncateSync(file.rid, 1); - * Deno.fsyncSync(file.rid); - * console.log(new TextDecoder().decode(Deno.readFileSync("my_file.txt"))); // H - * ``` - * - * @category I/O - */ - export function fsyncSync(rid: number): void; - - /** - * Flushes any pending data operations of the given file stream to disk. - * ```ts - * const file = await Deno.open( - * "my_file.txt", - * { read: true, write: true, create: true }, - * ); - * await Deno.write(file.rid, new TextEncoder().encode("Hello World")); - * await Deno.fdatasync(file.rid); - * console.log(new TextDecoder().decode(await Deno.readFile("my_file.txt"))); // Hello World - * ``` - * - * @category I/O - */ - export function fdatasync(rid: number): Promise; - - /** - * Synchronously flushes any pending data operations of the given file stream - * to disk. - * - * ```ts - * const file = Deno.openSync( - * "my_file.txt", - * { read: true, write: true, create: true }, - * ); - * Deno.writeSync(file.rid, new TextEncoder().encode("Hello World")); - * Deno.fdatasyncSync(file.rid); - * console.log(new TextDecoder().decode(Deno.readFileSync("my_file.txt"))); // Hello World - * ``` - * - * @category I/O - */ - export function fdatasyncSync(rid: number): void; - - /** Close the given resource ID (`rid`) which has been previously opened, such - * as via opening or creating a file. Closing a file when you are finished - * with it is important to avoid leaking resources. - * - * ```ts - * const file = await Deno.open("my_file.txt"); - * // do work with "file" object - * Deno.close(file.rid); - * ``` - * - * @category I/O - */ - export function close(rid: number): void; - - /** The Deno abstraction for reading and writing files. - * - * This is the most straight forward way of handling files within Deno and is - * recommended over using the discreet functions within the `Deno` namespace. - * - * ```ts - * const file = await Deno.open("/foo/bar.txt", { read: true }); - * const fileInfo = await file.stat(); - * if (fileInfo.isFile) { - * const buf = new Uint8Array(100); - * const numberOfBytesRead = await file.read(buf); // 11 bytes - * const text = new TextDecoder().decode(buf); // "hello world" - * } - * file.close(); - * ``` - * - * @category File System - */ - export class FsFile - implements - Reader, - ReaderSync, - Writer, - WriterSync, - Seeker, - SeekerSync, - Closer { - /** The resource ID associated with the file instance. The resource ID - * should be considered an opaque reference to resource. */ - readonly rid: number; - /** A {@linkcode ReadableStream} instance representing to the byte contents - * of the file. This makes it easy to interoperate with other web streams - * based APIs. - * - * ```ts - * const file = await Deno.open("my_file.txt", { read: true }); - * const decoder = new TextDecoder(); - * for await (const chunk of file.readable) { - * console.log(decoder.decode(chunk)); - * } - * file.close(); - * ``` - */ - readonly readable: ReadableStream; - /** A {@linkcode WritableStream} instance to write the contents of the - * file. This makes it easy to interoperate with other web streams based - * APIs. - * - * ```ts - * const items = ["hello", "world"]; - * const file = await Deno.open("my_file.txt", { write: true }); - * const encoder = new TextEncoder(); - * const writer = file.writable.getWriter(); - * for (const item of items) { - * await writer.write(encoder.encode(item)); - * } - * file.close(); - * ``` - */ - readonly writable: WritableStream; - /** The constructor which takes a resource ID. Generally `FsFile` should - * not be constructed directly. Instead use {@linkcode Deno.open} or - * {@linkcode Deno.openSync} to create a new instance of `FsFile`. */ - constructor(rid: number); - /** Write the contents of the array buffer (`p`) to the file. - * - * Resolves to the number of bytes written. - * - * **It is not guaranteed that the full buffer will be written in a single - * call.** - * - * ```ts - * const encoder = new TextEncoder(); - * const data = encoder.encode("Hello world"); - * const file = await Deno.open("/foo/bar.txt", { write: true }); - * const bytesWritten = await file.write(data); // 11 - * file.close(); - * ``` - * - * @category I/O - */ - write(p: Uint8Array): Promise; - /** Synchronously write the contents of the array buffer (`p`) to the file. - * - * Returns the number of bytes written. - * - * **It is not guaranteed that the full buffer will be written in a single - * call.** - * - * ```ts - * const encoder = new TextEncoder(); - * const data = encoder.encode("Hello world"); - * const file = Deno.openSync("/foo/bar.txt", { write: true }); - * const bytesWritten = file.writeSync(data); // 11 - * file.close(); - * ``` - */ - writeSync(p: Uint8Array): number; - /** Truncates (or extends) the file to reach the specified `len`. If `len` - * is not specified, then the entire file contents are truncated. - * - * ### Truncate the entire file - * - * ```ts - * const file = await Deno.open("my_file.txt", { write: true }); - * await file.truncate(); - * file.close(); - * ``` - * - * ### Truncate part of the file - * - * ```ts - * // if "my_file.txt" contains the text "hello world": - * const file = await Deno.open("my_file.txt", { write: true }); - * await file.truncate(7); - * const buf = new Uint8Array(100); - * await file.read(buf); - * const text = new TextDecoder().decode(buf); // "hello w" - * file.close(); - * ``` - */ - truncate(len?: number): Promise; - /** Synchronously truncates (or extends) the file to reach the specified - * `len`. If `len` is not specified, then the entire file contents are - * truncated. - * - * ### Truncate the entire file - * - * ```ts - * const file = Deno.openSync("my_file.txt", { write: true }); - * file.truncateSync(); - * file.close(); - * ``` - * - * ### Truncate part of the file - * - * ```ts - * // if "my_file.txt" contains the text "hello world": - * const file = Deno.openSync("my_file.txt", { write: true }); - * file.truncateSync(7); - * const buf = new Uint8Array(100); - * file.readSync(buf); - * const text = new TextDecoder().decode(buf); // "hello w" - * file.close(); - * ``` - */ - truncateSync(len?: number): void; - /** Read the file into an array buffer (`p`). - * - * Resolves to either the number of bytes read during the operation or EOF - * (`null`) if there was nothing more to read. - * - * It is possible for a read to successfully return with `0` bytes. This - * does not indicate EOF. - * - * **It is not guaranteed that the full buffer will be read in a single - * call.** - * - * ```ts - * // if "/foo/bar.txt" contains the text "hello world": - * const file = await Deno.open("/foo/bar.txt"); - * const buf = new Uint8Array(100); - * const numberOfBytesRead = await file.read(buf); // 11 bytes - * const text = new TextDecoder().decode(buf); // "hello world" - * file.close(); - * ``` - */ - read(p: Uint8Array): Promise; - /** Synchronously read from the file into an array buffer (`p`). - * - * Returns either the number of bytes read during the operation or EOF - * (`null`) if there was nothing more to read. - * - * It is possible for a read to successfully return with `0` bytes. This - * does not indicate EOF. - * - * **It is not guaranteed that the full buffer will be read in a single - * call.** - * - * ```ts - * // if "/foo/bar.txt" contains the text "hello world": - * const file = Deno.openSync("/foo/bar.txt"); - * const buf = new Uint8Array(100); - * const numberOfBytesRead = file.readSync(buf); // 11 bytes - * const text = new TextDecoder().decode(buf); // "hello world" - * file.close(); - * ``` - */ - readSync(p: Uint8Array): number | null; - /** Seek to the given `offset` under mode given by `whence`. The call - * resolves to the new position within the resource (bytes from the start). - * - * ```ts - * // Given file pointing to file with "Hello world", which is 11 bytes long: - * const file = await Deno.open( - * "hello.txt", - * { read: true, write: true, truncate: true, create: true }, - * ); - * await file.write(new TextEncoder().encode("Hello world")); - * - * // advance cursor 6 bytes - * const cursorPosition = await file.seek(6, Deno.SeekMode.Start); - * console.log(cursorPosition); // 6 - * const buf = new Uint8Array(100); - * await file.read(buf); - * console.log(new TextDecoder().decode(buf)); // "world" - * file.close(); - * ``` - * - * The seek modes work as follows: - * - * ```ts - * // Given file.rid pointing to file with "Hello world", which is 11 bytes long: - * const file = await Deno.open( - * "hello.txt", - * { read: true, write: true, truncate: true, create: true }, - * ); - * await file.write(new TextEncoder().encode("Hello world")); - * - * // Seek 6 bytes from the start of the file - * console.log(await file.seek(6, Deno.SeekMode.Start)); // "6" - * // Seek 2 more bytes from the current position - * console.log(await file.seek(2, Deno.SeekMode.Current)); // "8" - * // Seek backwards 2 bytes from the end of the file - * console.log(await file.seek(-2, Deno.SeekMode.End)); // "9" (e.g. 11-2) - * ``` - */ - seek(offset: number, whence: SeekMode): Promise; - /** Synchronously seek to the given `offset` under mode given by `whence`. - * The new position within the resource (bytes from the start) is returned. - * - * ```ts - * const file = Deno.openSync( - * "hello.txt", - * { read: true, write: true, truncate: true, create: true }, - * ); - * file.writeSync(new TextEncoder().encode("Hello world")); - * - * // advance cursor 6 bytes - * const cursorPosition = file.seekSync(6, Deno.SeekMode.Start); - * console.log(cursorPosition); // 6 - * const buf = new Uint8Array(100); - * file.readSync(buf); - * console.log(new TextDecoder().decode(buf)); // "world" - * file.close(); - * ``` - * - * The seek modes work as follows: - * - * ```ts - * // Given file.rid pointing to file with "Hello world", which is 11 bytes long: - * const file = Deno.openSync( - * "hello.txt", - * { read: true, write: true, truncate: true, create: true }, - * ); - * file.writeSync(new TextEncoder().encode("Hello world")); - * - * // Seek 6 bytes from the start of the file - * console.log(file.seekSync(6, Deno.SeekMode.Start)); // "6" - * // Seek 2 more bytes from the current position - * console.log(file.seekSync(2, Deno.SeekMode.Current)); // "8" - * // Seek backwards 2 bytes from the end of the file - * console.log(file.seekSync(-2, Deno.SeekMode.End)); // "9" (e.g. 11-2) - * file.close(); - * ``` - */ - seekSync(offset: number, whence: SeekMode): number; - /** Resolves to a {@linkcode Deno.FileInfo} for the file. - * - * ```ts - * import { assert } from "https://deno.land/std/testing/asserts.ts"; - * - * const file = await Deno.open("hello.txt"); - * const fileInfo = await file.stat(); - * assert(fileInfo.isFile); - * file.close(); - * ``` - */ - stat(): Promise; - /** Synchronously returns a {@linkcode Deno.FileInfo} for the file. - * - * ```ts - * import { assert } from "https://deno.land/std/testing/asserts.ts"; - * - * const file = Deno.openSync("hello.txt") - * const fileInfo = file.statSync(); - * assert(fileInfo.isFile); - * file.close(); - * ``` - */ - statSync(): FileInfo; - /** Close the file. Closing a file when you are finished with it is - * important to avoid leaking resources. - * - * ```ts - * const file = await Deno.open("my_file.txt"); - * // do work with "file" object - * file.close(); - * ``` - */ - close(): void; - } - - /** - * The Deno abstraction for reading and writing files. - * - * @deprecated Use {@linkcode Deno.FsFile} instead. `Deno.File` will be - * removed in the future. - * @category File System - */ - export const File: typeof FsFile; - - /** Gets the size of the console as columns/rows. - * - * ```ts - * const { columns, rows } = Deno.consoleSize(); - * ``` - * - * @category I/O - */ - export function consoleSize(): { - columns: number; - rows: number; - }; - - /** @category I/O */ - export interface SetRawOptions { - /** - * The `cbreak` option can be used to indicate that characters that - * correspond to a signal should still be generated. When disabling raw - * mode, this option is ignored. This functionality currently only works on - * Linux and Mac OS. - */ - cbreak: boolean; - } - - /** A reference to `stdin` which can be used to read directly from `stdin`. - * It implements the Deno specific {@linkcode Reader}, {@linkcode ReaderSync}, - * and {@linkcode Closer} interfaces as well as provides a - * {@linkcode ReadableStream} interface. - * - * ### Reading chunks from the readable stream - * - * ```ts - * const decoder = new TextDecoder(); - * for await (const chunk of Deno.stdin.readable) { - * const text = decoder.decode(chunk); - * // do something with the text - * } - * ``` - * - * @category I/O - */ - export const stdin: Reader & ReaderSync & Closer & { - /** The resource ID assigned to `stdin`. This can be used with the discreet - * I/O functions in the `Deno` namespace. */ - readonly rid: number; - /** A readable stream interface to `stdin`. */ - readonly readable: ReadableStream; - /** - * Set TTY to be under raw mode or not. In raw mode, characters are read and - * returned as is, without being processed. All special processing of - * characters by the terminal is disabled, including echoing input - * characters. Reading from a TTY device in raw mode is faster than reading - * from a TTY device in canonical mode. - * - * ```ts - * Deno.stdin.setRaw(true, { cbreak: true }); - * ``` - * - * @category I/O - */ - setRaw(mode: boolean, options?: SetRawOptions): void; - }; - /** A reference to `stdout` which can be used to write directly to `stdout`. - * It implements the Deno specific {@linkcode Writer}, {@linkcode WriterSync}, - * and {@linkcode Closer} interfaces as well as provides a - * {@linkcode WritableStream} interface. - * - * These are low level constructs, and the {@linkcode console} interface is a - * more straight forward way to interact with `stdout` and `stderr`. - * - * @category I/O - */ - export const stdout: Writer & WriterSync & Closer & { - /** The resource ID assigned to `stdout`. This can be used with the discreet - * I/O functions in the `Deno` namespace. */ - readonly rid: number; - /** A writable stream interface to `stdout`. */ - readonly writable: WritableStream; - }; - /** A reference to `stderr` which can be used to write directly to `stderr`. - * It implements the Deno specific {@linkcode Writer}, {@linkcode WriterSync}, - * and {@linkcode Closer} interfaces as well as provides a - * {@linkcode WritableStream} interface. - * - * These are low level constructs, and the {@linkcode console} interface is a - * more straight forward way to interact with `stdout` and `stderr`. - * - * @category I/O - */ - export const stderr: Writer & WriterSync & Closer & { - /** The resource ID assigned to `stderr`. This can be used with the discreet - * I/O functions in the `Deno` namespace. */ - readonly rid: number; - /** A writable stream interface to `stderr`. */ - readonly writable: WritableStream; - }; - - /** - * Options which can be set when doing {@linkcode Deno.open} and - * {@linkcode Deno.openSync}. - * - * @category File System */ - export interface OpenOptions { - /** Defaults to `true`. Sets the option for read access. This option, when `true`, means that - * the file should be read-able if opened. */ - read?: boolean; - /** Defaults to `false`. Sets the option for write access. This option, when `true`, means that - * the file should be write-able if opened. If the file already exists, - * any write calls on it will overwrite its contents, by default without - * truncating it. */ - write?: boolean; - /** Defaults to `false`. Sets the option for the append mode. This option, when `true`, means - * that writes will append to a file instead of overwriting previous - * contents. - * - * Note that setting `{ write: true, append: true }` has the same effect as - * setting only `{ append: true }`. */ - append?: boolean; - /** Defaults to `false`. Sets the option for truncating a previous file. If a file is - * successfully opened with this option set it will truncate the file to `0` - * size if it already exists. The file must be opened with write access - * for truncate to work. */ - truncate?: boolean; - /** Defaults to `false`. Sets the option to allow creating a new file, if one doesn't already - * exist at the specified path. Requires write or append access to be - * used. */ - create?: boolean; - /** Defaults to `false`. If set to `true`, no file, directory, or symlink is - * allowed to exist at the target location. Requires write or append - * access to be used. When createNew is set to `true`, create and truncate - * are ignored. */ - createNew?: boolean; - /** Permissions to use if creating the file (defaults to `0o666`, before - * the process's umask). - * - * Ignored on Windows. */ - mode?: number; - } - - /** - * Options which can be set when using {@linkcode Deno.readFile} or - * {@linkcode Deno.readFileSync}. - * - * @category File System */ - export interface ReadFileOptions { - /** - * An abort signal to allow cancellation of the file read operation. - * If the signal becomes aborted the readFile operation will be stopped - * and the promise returned will be rejected with an AbortError. - */ - signal?: AbortSignal; - } - - /** - * Check if a given resource id (`rid`) is a TTY (a terminal). - * - * ```ts - * // This example is system and context specific - * const nonTTYRid = Deno.openSync("my_file.txt").rid; - * const ttyRid = Deno.openSync("/dev/tty6").rid; - * console.log(Deno.isatty(nonTTYRid)); // false - * console.log(Deno.isatty(ttyRid)); // true - * Deno.close(nonTTYRid); - * Deno.close(ttyRid); - * ``` - * - * @category I/O - */ - export function isatty(rid: number): boolean; - - /** - * A variable-sized buffer of bytes with `read()` and `write()` methods. - * - * @deprecated Use [`Buffer`](https://deno.land/std/io/buffer.ts?s=Buffer) - * from [`std/io/buffer.ts`](https://deno.land/std/io/buffer.ts) instead. - * `Deno.Buffer` will be removed in the future. - * - * @category I/O - */ - export class Buffer implements Reader, ReaderSync, Writer, WriterSync { - constructor(ab?: ArrayBuffer); - /** Returns a slice holding the unread portion of the buffer. - * - * The slice is valid for use only until the next buffer modification (that - * is, only until the next call to a method like `read()`, `write()`, - * `reset()`, or `truncate()`). If `options.copy` is false the slice aliases the buffer content at - * least until the next buffer modification, so immediate changes to the - * slice will affect the result of future reads. - * @param options Defaults to `{ copy: true }` - */ - bytes(options?: { copy?: boolean }): Uint8Array; - /** Returns whether the unread portion of the buffer is empty. */ - empty(): boolean; - /** A read only number of bytes of the unread portion of the buffer. */ - readonly length: number; - /** The read only capacity of the buffer's underlying byte slice, that is, - * the total space allocated for the buffer's data. */ - readonly capacity: number; - /** Discards all but the first `n` unread bytes from the buffer but - * continues to use the same allocated storage. It throws if `n` is - * negative or greater than the length of the buffer. */ - truncate(n: number): void; - /** Resets the buffer to be empty, but it retains the underlying storage for - * use by future writes. `.reset()` is the same as `.truncate(0)`. */ - reset(): void; - /** Reads the next `p.length` bytes from the buffer or until the buffer is - * drained. Returns the number of bytes read. If the buffer has no data to - * return, the return is EOF (`null`). */ - readSync(p: Uint8Array): number | null; - /** Reads the next `p.length` bytes from the buffer or until the buffer is - * drained. Resolves to the number of bytes read. If the buffer has no - * data to return, resolves to EOF (`null`). - * - * NOTE: This methods reads bytes synchronously; it's provided for - * compatibility with `Reader` interfaces. - */ - read(p: Uint8Array): Promise; - writeSync(p: Uint8Array): number; - /** NOTE: This methods writes bytes synchronously; it's provided for - * compatibility with `Writer` interface. */ - write(p: Uint8Array): Promise; - /** Grows the buffer's capacity, if necessary, to guarantee space for - * another `n` bytes. After `.grow(n)`, at least `n` bytes can be written to - * the buffer without another allocation. If `n` is negative, `.grow()` will - * throw. If the buffer can't grow it will throw an error. - * - * Based on Go Lang's - * [Buffer.Grow](https://golang.org/pkg/bytes/#Buffer.Grow). */ - grow(n: number): void; - /** Reads data from `r` until EOF (`null`) and appends it to the buffer, - * growing the buffer as needed. It resolves to the number of bytes read. - * If the buffer becomes too large, `.readFrom()` will reject with an error. - * - * Based on Go Lang's - * [Buffer.ReadFrom](https://golang.org/pkg/bytes/#Buffer.ReadFrom). */ - readFrom(r: Reader): Promise; - /** Reads data from `r` until EOF (`null`) and appends it to the buffer, - * growing the buffer as needed. It returns the number of bytes read. If the - * buffer becomes too large, `.readFromSync()` will throw an error. - * - * Based on Go Lang's - * [Buffer.ReadFrom](https://golang.org/pkg/bytes/#Buffer.ReadFrom). */ - readFromSync(r: ReaderSync): number; - } - - /** - * Read Reader `r` until EOF (`null`) and resolve to the content as - * Uint8Array`. - * - * @deprecated Use - * [`readAll`](https://deno.land/std/streams/conversion.ts?s=readAll) from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. `Deno.readAll` will be removed in the future. - * - * @category I/O - */ - export function readAll(r: Reader): Promise; - - /** - * Synchronously reads Reader `r` until EOF (`null`) and returns the content - * as `Uint8Array`. - * - * @deprecated Use - * [`readAllSync`](https://deno.land/std/streams/conversion.ts?s=readAllSync) - * from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. `Deno.readAllSync` will be removed in the future. - * - * @category I/O - */ - export function readAllSync(r: ReaderSync): Uint8Array; - - /** - * Write all the content of the array buffer (`arr`) to the writer (`w`). - * - * @deprecated Use - * [`writeAll`](https://deno.land/std/streams/conversion.ts?s=writeAll) from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. `Deno.writeAll` will be removed in the future. - * - * @category I/O - */ - export function writeAll(w: Writer, arr: Uint8Array): Promise; - - /** - * Synchronously write all the content of the array buffer (`arr`) to the - * writer (`w`). - * - * @deprecated Use - * [`writeAllSync`](https://deno.land/std/streams/conversion.ts?s=writeAllSync) - * from - * [`std/streams/conversion.ts`](https://deno.land/std/streams/conversion.ts) - * instead. `Deno.writeAllSync` will be removed in the future. - * - * @category I/O - */ - export function writeAllSync(w: WriterSync, arr: Uint8Array): void; - - /** - * Options which can be set when using {@linkcode Deno.mkdir} and - * {@linkcode Deno.mkdirSync}. - * - * @category File System */ - export interface MkdirOptions { - /** Defaults to `false`. If set to `true`, means that any intermediate - * directories will also be created (as with the shell command `mkdir -p`). - * - * Intermediate directories are created with the same permissions. - * - * When recursive is set to `true`, succeeds silently (without changing any - * permissions) if a directory already exists at the path, or if the path - * is a symlink to an existing directory. */ - recursive?: boolean; - /** Permissions to use when creating the directory (defaults to `0o777`, - * before the process's umask). - * - * Ignored on Windows. */ - mode?: number; - } - - /** Creates a new directory with the specified path. - * - * ```ts - * await Deno.mkdir("new_dir"); - * await Deno.mkdir("nested/directories", { recursive: true }); - * await Deno.mkdir("restricted_access_dir", { mode: 0o700 }); - * ``` - * - * Defaults to throwing error if the directory already exists. - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function mkdir( - path: string | URL, - options?: MkdirOptions, - ): Promise; - - /** Synchronously creates a new directory with the specified path. - * - * ```ts - * Deno.mkdirSync("new_dir"); - * Deno.mkdirSync("nested/directories", { recursive: true }); - * Deno.mkdirSync("restricted_access_dir", { mode: 0o700 }); - * ``` - * - * Defaults to throwing error if the directory already exists. - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function mkdirSync(path: string | URL, options?: MkdirOptions): void; - - /** - * Options which can be set when using {@linkcode Deno.makeTempDir}, - * {@linkcode Deno.makeTempDirSync}, {@linkcode Deno.makeTempFile}, and - * {@linkcode Deno.makeTempFileSync}. - * - * @category File System */ - export interface MakeTempOptions { - /** Directory where the temporary directory should be created (defaults to - * the env variable `TMPDIR`, or the system's default, usually `/tmp`). - * - * Note that if the passed `dir` is relative, the path returned by - * `makeTempFile()` and `makeTempDir()` will also be relative. Be mindful of - * this when changing working directory. */ - dir?: string; - /** String that should precede the random portion of the temporary - * directory's name. */ - prefix?: string; - /** String that should follow the random portion of the temporary - * directory's name. */ - suffix?: string; - } - - /** Creates a new temporary directory in the default directory for temporary - * files, unless `dir` is specified. Other optional options include - * prefixing and suffixing the directory name with `prefix` and `suffix` - * respectively. - * - * This call resolves to the full path to the newly created directory. - * - * Multiple programs calling this function simultaneously will create different - * directories. It is the caller's responsibility to remove the directory when - * no longer needed. - * - * ```ts - * const tempDirName0 = await Deno.makeTempDir(); // e.g. /tmp/2894ea76 - * const tempDirName1 = await Deno.makeTempDir({ prefix: 'my_temp' }); // e.g. /tmp/my_temp339c944d - * ``` - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - // TODO(ry) Doesn't check permissions. - export function makeTempDir(options?: MakeTempOptions): Promise; - - /** Synchronously creates a new temporary directory in the default directory - * for temporary files, unless `dir` is specified. Other optional options - * include prefixing and suffixing the directory name with `prefix` and - * `suffix` respectively. - * - * The full path to the newly created directory is returned. - * - * Multiple programs calling this function simultaneously will create different - * directories. It is the caller's responsibility to remove the directory when - * no longer needed. - * - * ```ts - * const tempDirName0 = Deno.makeTempDirSync(); // e.g. /tmp/2894ea76 - * const tempDirName1 = Deno.makeTempDirSync({ prefix: 'my_temp' }); // e.g. /tmp/my_temp339c944d - * ``` - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - // TODO(ry) Doesn't check permissions. - export function makeTempDirSync(options?: MakeTempOptions): string; - - /** Creates a new temporary file in the default directory for temporary - * files, unless `dir` is specified. - * - * Other options include prefixing and suffixing the directory name with - * `prefix` and `suffix` respectively. - * - * This call resolves to the full path to the newly created file. - * - * Multiple programs calling this function simultaneously will create - * different files. It is the caller's responsibility to remove the file when - * no longer needed. - * - * ```ts - * const tmpFileName0 = await Deno.makeTempFile(); // e.g. /tmp/419e0bf2 - * const tmpFileName1 = await Deno.makeTempFile({ prefix: 'my_temp' }); // e.g. /tmp/my_temp754d3098 - * ``` - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function makeTempFile(options?: MakeTempOptions): Promise; - - /** Synchronously creates a new temporary file in the default directory for - * temporary files, unless `dir` is specified. - * - * Other options include prefixing and suffixing the directory name with - * `prefix` and `suffix` respectively. - * - * The full path to the newly created file is returned. - * - * Multiple programs calling this function simultaneously will create - * different files. It is the caller's responsibility to remove the file when - * no longer needed. - * - * ```ts - * const tempFileName0 = Deno.makeTempFileSync(); // e.g. /tmp/419e0bf2 - * const tempFileName1 = Deno.makeTempFileSync({ prefix: 'my_temp' }); // e.g. /tmp/my_temp754d3098 - * ``` - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function makeTempFileSync(options?: MakeTempOptions): string; - - /** Changes the permission of a specific file/directory of specified path. - * Ignores the process's umask. - * - * ```ts - * await Deno.chmod("/path/to/file", 0o666); - * ``` - * - * The mode is a sequence of 3 octal numbers. The first/left-most number - * specifies the permissions for the owner. The second number specifies the - * permissions for the group. The last/right-most number specifies the - * permissions for others. For example, with a mode of 0o764, the owner (7) - * can read/write/execute, the group (6) can read/write and everyone else (4) - * can read only. - * - * | Number | Description | - * | ------ | ----------- | - * | 7 | read, write, and execute | - * | 6 | read and write | - * | 5 | read and execute | - * | 4 | read only | - * | 3 | write and execute | - * | 2 | write only | - * | 1 | execute only | - * | 0 | no permission | - * - * NOTE: This API currently throws on Windows - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function chmod(path: string | URL, mode: number): Promise; - - /** Synchronously changes the permission of a specific file/directory of - * specified path. Ignores the process's umask. - * - * ```ts - * Deno.chmodSync("/path/to/file", 0o666); - * ``` - * - * For a full description, see {@linkcode Deno.chmod}. - * - * NOTE: This API currently throws on Windows - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function chmodSync(path: string | URL, mode: number): void; - - /** Change owner of a regular file or directory. - * - * This functionality is not available on Windows. - * - * ```ts - * await Deno.chown("myFile.txt", 1000, 1002); - * ``` - * - * Requires `allow-write` permission. - * - * Throws Error (not implemented) if executed on Windows. - * - * @tags allow-write - * @category File System - * - * @param path path to the file - * @param uid user id (UID) of the new owner, or `null` for no change - * @param gid group id (GID) of the new owner, or `null` for no change - */ - export function chown( - path: string | URL, - uid: number | null, - gid: number | null, - ): Promise; - - /** Synchronously change owner of a regular file or directory. - * - * This functionality is not available on Windows. - * - * ```ts - * Deno.chownSync("myFile.txt", 1000, 1002); - * ``` - * - * Requires `allow-write` permission. - * - * Throws Error (not implemented) if executed on Windows. - * - * @tags allow-write - * @category File System - * - * @param path path to the file - * @param uid user id (UID) of the new owner, or `null` for no change - * @param gid group id (GID) of the new owner, or `null` for no change - */ - export function chownSync( - path: string | URL, - uid: number | null, - gid: number | null, - ): void; - - /** - * Options which can be set when using {@linkcode Deno.remove} and - * {@linkcode Deno.removeSync}. - * - * @category File System */ - export interface RemoveOptions { - /** Defaults to `false`. If set to `true`, path will be removed even if - * it's a non-empty directory. */ - recursive?: boolean; - } - - /** Removes the named file or directory. - * - * ```ts - * await Deno.remove("/path/to/empty_dir/or/file"); - * await Deno.remove("/path/to/populated_dir/or/file", { recursive: true }); - * ``` - * - * Throws error if permission denied, path not found, or path is a non-empty - * directory and the `recursive` option isn't set to `true`. - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function remove( - path: string | URL, - options?: RemoveOptions, - ): Promise; - - /** Synchronously removes the named file or directory. - * - * ```ts - * Deno.removeSync("/path/to/empty_dir/or/file"); - * Deno.removeSync("/path/to/populated_dir/or/file", { recursive: true }); - * ``` - * - * Throws error if permission denied, path not found, or path is a non-empty - * directory and the `recursive` option isn't set to `true`. - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function removeSync(path: string | URL, options?: RemoveOptions): void; - - /** Synchronously renames (moves) `oldpath` to `newpath`. Paths may be files or - * directories. If `newpath` already exists and is not a directory, - * `renameSync()` replaces it. OS-specific restrictions may apply when - * `oldpath` and `newpath` are in different directories. - * - * ```ts - * Deno.renameSync("old/path", "new/path"); - * ``` - * - * On Unix-like OSes, this operation does not follow symlinks at either path. - * - * It varies between platforms when the operation throws errors, and if so what - * they are. It's always an error to rename anything to a non-empty directory. - * - * Requires `allow-read` and `allow-write` permissions. - * - * @tags allow-read, allow-write - * @category File System - */ - export function renameSync( - oldpath: string | URL, - newpath: string | URL, - ): void; - - /** Renames (moves) `oldpath` to `newpath`. Paths may be files or directories. - * If `newpath` already exists and is not a directory, `rename()` replaces it. - * OS-specific restrictions may apply when `oldpath` and `newpath` are in - * different directories. - * - * ```ts - * await Deno.rename("old/path", "new/path"); - * ``` - * - * On Unix-like OSes, this operation does not follow symlinks at either path. - * - * It varies between platforms when the operation throws errors, and if so - * what they are. It's always an error to rename anything to a non-empty - * directory. - * - * Requires `allow-read` and `allow-write` permissions. - * - * @tags allow-read, allow-write - * @category File System - */ - export function rename( - oldpath: string | URL, - newpath: string | URL, - ): Promise; - - /** Asynchronously reads and returns the entire contents of a file as an UTF-8 - * decoded string. Reading a directory throws an error. - * - * ```ts - * const data = await Deno.readTextFile("hello.txt"); - * console.log(data); - * ``` - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function readTextFile( - path: string | URL, - options?: ReadFileOptions, - ): Promise; - - /** Synchronously reads and returns the entire contents of a file as an UTF-8 - * decoded string. Reading a directory throws an error. - * - * ```ts - * const data = Deno.readTextFileSync("hello.txt"); - * console.log(data); - * ``` - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function readTextFileSync(path: string | URL): string; - - /** Reads and resolves to the entire contents of a file as an array of bytes. - * `TextDecoder` can be used to transform the bytes to string if required. - * Reading a directory returns an empty data array. - * - * ```ts - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello.txt"); - * console.log(decoder.decode(data)); - * ``` - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function readFile( - path: string | URL, - options?: ReadFileOptions, - ): Promise; - - /** Synchronously reads and returns the entire contents of a file as an array - * of bytes. `TextDecoder` can be used to transform the bytes to string if - * required. Reading a directory returns an empty data array. - * - * ```ts - * const decoder = new TextDecoder("utf-8"); - * const data = Deno.readFileSync("hello.txt"); - * console.log(decoder.decode(data)); - * ``` - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function readFileSync(path: string | URL): Uint8Array; - - /** Provides information about a file and is returned by - * {@linkcode Deno.stat}, {@linkcode Deno.lstat}, {@linkcode Deno.statSync}, - * and {@linkcode Deno.lstatSync} or from calling `stat()` and `statSync()` - * on an {@linkcode Deno.FsFile} instance. - * - * @category File System - */ - export interface FileInfo { - /** True if this is info for a regular file. Mutually exclusive to - * `FileInfo.isDirectory` and `FileInfo.isSymlink`. */ - isFile: boolean; - /** True if this is info for a regular directory. Mutually exclusive to - * `FileInfo.isFile` and `FileInfo.isSymlink`. */ - isDirectory: boolean; - /** True if this is info for a symlink. Mutually exclusive to - * `FileInfo.isFile` and `FileInfo.isDirectory`. */ - isSymlink: boolean; - /** The size of the file, in bytes. */ - size: number; - /** The last modification time of the file. This corresponds to the `mtime` - * field from `stat` on Linux/Mac OS and `ftLastWriteTime` on Windows. This - * may not be available on all platforms. */ - mtime: Date | null; - /** The last access time of the file. This corresponds to the `atime` - * field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not - * be available on all platforms. */ - atime: Date | null; - /** The creation time of the file. This corresponds to the `birthtime` - * field from `stat` on Mac/BSD and `ftCreationTime` on Windows. This may - * not be available on all platforms. */ - birthtime: Date | null; - /** ID of the device containing the file. - * - * _Linux/Mac OS only._ */ - dev: number | null; - /** Inode number. - * - * _Linux/Mac OS only._ */ - ino: number | null; - /** **UNSTABLE**: Match behavior with Go on Windows for `mode`. - * - * The underlying raw `st_mode` bits that contain the standard Unix - * permissions for this file/directory. */ - mode: number | null; - /** Number of hard links pointing to this file. - * - * _Linux/Mac OS only._ */ - nlink: number | null; - /** User ID of the owner of this file. - * - * _Linux/Mac OS only._ */ - uid: number | null; - /** Group ID of the owner of this file. - * - * _Linux/Mac OS only._ */ - gid: number | null; - /** Device ID of this file. - * - * _Linux/Mac OS only._ */ - rdev: number | null; - /** Blocksize for filesystem I/O. - * - * _Linux/Mac OS only._ */ - blksize: number | null; - /** Number of blocks allocated to the file, in 512-byte units. - * - * _Linux/Mac OS only._ */ - blocks: number | null; - } - - /** Resolves to the absolute normalized path, with symbolic links resolved. - * - * ```ts - * // e.g. given /home/alice/file.txt and current directory /home/alice - * await Deno.symlink("file.txt", "symlink_file.txt"); - * const realPath = await Deno.realPath("./file.txt"); - * const realSymLinkPath = await Deno.realPath("./symlink_file.txt"); - * console.log(realPath); // outputs "/home/alice/file.txt" - * console.log(realSymLinkPath); // outputs "/home/alice/file.txt" - * ``` - * - * Requires `allow-read` permission for the target path. - * - * Also requires `allow-read` permission for the `CWD` if the target path is - * relative. - * - * @tags allow-read - * @category File System - */ - export function realPath(path: string | URL): Promise; - - /** Synchronously returns absolute normalized path, with symbolic links - * resolved. - * - * ```ts - * // e.g. given /home/alice/file.txt and current directory /home/alice - * Deno.symlinkSync("file.txt", "symlink_file.txt"); - * const realPath = Deno.realPathSync("./file.txt"); - * const realSymLinkPath = Deno.realPathSync("./symlink_file.txt"); - * console.log(realPath); // outputs "/home/alice/file.txt" - * console.log(realSymLinkPath); // outputs "/home/alice/file.txt" - * ``` - * - * Requires `allow-read` permission for the target path. - * - * Also requires `allow-read` permission for the `CWD` if the target path is - * relative. - * - * @tags allow-read - * @category File System - */ - export function realPathSync(path: string | URL): string; - - /** - * Information about a directory entry returned from {@linkcode Deno.readDir} - * and {@linkcode Deno.readDirSync}. - * - * @category File System */ - export interface DirEntry { - /** The file name of the entry. It is just the entity name and does not - * include the full path. */ - name: string; - /** True if this is info for a regular file. Mutually exclusive to - * `DirEntry.isDirectory` and `DirEntry.isSymlink`. */ - isFile: boolean; - /** True if this is info for a regular directory. Mutually exclusive to - * `DirEntry.isFile` and `DirEntry.isSymlink`. */ - isDirectory: boolean; - /** True if this is info for a symlink. Mutually exclusive to - * `DirEntry.isFile` and `DirEntry.isDirectory`. */ - isSymlink: boolean; - } - - /** Reads the directory given by `path` and returns an async iterable of - * {@linkcode Deno.DirEntry}. - * - * ```ts - * for await (const dirEntry of Deno.readDir("/")) { - * console.log(dirEntry.name); - * } - * ``` - * - * Throws error if `path` is not a directory. - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function readDir(path: string | URL): AsyncIterable; - - /** Synchronously reads the directory given by `path` and returns an iterable - * of `Deno.DirEntry`. - * - * ```ts - * for (const dirEntry of Deno.readDirSync("/")) { - * console.log(dirEntry.name); - * } - * ``` - * - * Throws error if `path` is not a directory. - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function readDirSync(path: string | URL): Iterable; - - /** Copies the contents and permissions of one file to another specified path, - * by default creating a new file if needed, else overwriting. Fails if target - * path is a directory or is unwritable. - * - * ```ts - * await Deno.copyFile("from.txt", "to.txt"); - * ``` - * - * Requires `allow-read` permission on `fromPath`. - * - * Requires `allow-write` permission on `toPath`. - * - * @tags allow-read, allow-write - * @category File System - */ - export function copyFile( - fromPath: string | URL, - toPath: string | URL, - ): Promise; - - /** Synchronously copies the contents and permissions of one file to another - * specified path, by default creating a new file if needed, else overwriting. - * Fails if target path is a directory or is unwritable. - * - * ```ts - * Deno.copyFileSync("from.txt", "to.txt"); - * ``` - * - * Requires `allow-read` permission on `fromPath`. - * - * Requires `allow-write` permission on `toPath`. - * - * @tags allow-read, allow-write - * @category File System - */ - export function copyFileSync( - fromPath: string | URL, - toPath: string | URL, - ): void; - - /** Resolves to the full path destination of the named symbolic link. - * - * ```ts - * await Deno.symlink("./test.txt", "./test_link.txt"); - * const target = await Deno.readLink("./test_link.txt"); // full path of ./test.txt - * ``` - * - * Throws TypeError if called with a hard link. - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function readLink(path: string | URL): Promise; - - /** Synchronously returns the full path destination of the named symbolic - * link. - * - * ```ts - * Deno.symlinkSync("./test.txt", "./test_link.txt"); - * const target = Deno.readLinkSync("./test_link.txt"); // full path of ./test.txt - * ``` - * - * Throws TypeError if called with a hard link. - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function readLinkSync(path: string | URL): string; - - /** Resolves to a {@linkcode Deno.FileInfo} for the specified `path`. If - * `path` is a symlink, information for the symlink will be returned instead - * of what it points to. - * - * ```ts - * import { assert } from "https://deno.land/std/testing/asserts.ts"; - * const fileInfo = await Deno.lstat("hello.txt"); - * assert(fileInfo.isFile); - * ``` - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function lstat(path: string | URL): Promise; - - /** Synchronously returns a {@linkcode Deno.FileInfo} for the specified - * `path`. If `path` is a symlink, information for the symlink will be - * returned instead of what it points to. - * - * ```ts - * import { assert } from "https://deno.land/std/testing/asserts.ts"; - * const fileInfo = Deno.lstatSync("hello.txt"); - * assert(fileInfo.isFile); - * ``` - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function lstatSync(path: string | URL): FileInfo; - - /** Resolves to a {@linkcode Deno.FileInfo} for the specified `path`. Will - * always follow symlinks. - * - * ```ts - * import { assert } from "https://deno.land/std/testing/asserts.ts"; - * const fileInfo = await Deno.stat("hello.txt"); - * assert(fileInfo.isFile); - * ``` - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function stat(path: string | URL): Promise; - - /** Synchronously returns a {@linkcode Deno.FileInfo} for the specified - * `path`. Will always follow symlinks. - * - * ```ts - * import { assert } from "https://deno.land/std/testing/asserts.ts"; - * const fileInfo = Deno.statSync("hello.txt"); - * assert(fileInfo.isFile); - * ``` - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function statSync(path: string | URL): FileInfo; - - /** Options for writing to a file. - * - * @category File System - */ - export interface WriteFileOptions { - /** Defaults to `false`. If set to `true`, will append to a file instead of - * overwriting previous contents. */ - append?: boolean; - /** Sets the option to allow creating a new file, if one doesn't already - * exist at the specified path (defaults to `true`). */ - create?: boolean; - /** Permissions always applied to file. */ - mode?: number; - /** An abort signal to allow cancellation of the file write operation. - * - * If the signal becomes aborted the write file operation will be stopped - * and the promise returned will be rejected with an {@linkcode AbortError}. - */ - signal?: AbortSignal; - } - - /** Write `data` to the given `path`, by default creating a new file if - * needed, else overwriting. - * - * ```ts - * const encoder = new TextEncoder(); - * const data = encoder.encode("Hello world\n"); - * await Deno.writeFile("hello1.txt", data); // overwrite "hello1.txt" or create it - * await Deno.writeFile("hello2.txt", data, { create: false }); // only works if "hello2.txt" exists - * await Deno.writeFile("hello3.txt", data, { mode: 0o777 }); // set permissions on new file - * await Deno.writeFile("hello4.txt", data, { append: true }); // add data to the end of the file - * ``` - * - * Requires `allow-write` permission, and `allow-read` if `options.create` is - * `false`. - * - * @tags allow-read, allow-write - * @category File System - */ - export function writeFile( - path: string | URL, - data: Uint8Array, - options?: WriteFileOptions, - ): Promise; - - /** Synchronously write `data` to the given `path`, by default creating a new - * file if needed, else overwriting. - * - * ```ts - * const encoder = new TextEncoder(); - * const data = encoder.encode("Hello world\n"); - * Deno.writeFileSync("hello1.txt", data); // overwrite "hello1.txt" or create it - * Deno.writeFileSync("hello2.txt", data, { create: false }); // only works if "hello2.txt" exists - * Deno.writeFileSync("hello3.txt", data, { mode: 0o777 }); // set permissions on new file - * Deno.writeFileSync("hello4.txt", data, { append: true }); // add data to the end of the file - * ``` - * - * Requires `allow-write` permission, and `allow-read` if `options.create` is - * `false`. - * - * @tags allow-read, allow-write - * @category File System - */ - export function writeFileSync( - path: string | URL, - data: Uint8Array, - options?: WriteFileOptions, - ): void; - - /** Write string `data` to the given `path`, by default creating a new file if - * needed, else overwriting. - * - * ```ts - * await Deno.writeTextFile("hello1.txt", "Hello world\n"); // overwrite "hello1.txt" or create it - * ``` - * - * Requires `allow-write` permission, and `allow-read` if `options.create` is - * `false`. - * - * @tags allow-read, allow-write - * @category File System - */ - export function writeTextFile( - path: string | URL, - data: string, - options?: WriteFileOptions, - ): Promise; - - /** Synchronously write string `data` to the given `path`, by default creating - * a new file if needed, else overwriting. - * - * ```ts - * Deno.writeTextFileSync("hello1.txt", "Hello world\n"); // overwrite "hello1.txt" or create it - * ``` - * - * Requires `allow-write` permission, and `allow-read` if `options.create` is - * `false`. - * - * @tags allow-read, allow-write - * @category File System - */ - export function writeTextFileSync( - path: string | URL, - data: string, - options?: WriteFileOptions, - ): void; - - /** Truncates (or extends) the specified file, to reach the specified `len`. - * If `len` is not specified then the entire file contents are truncated. - * - * ### Truncate the entire file - * ```ts - * await Deno.truncate("my_file.txt"); - * ``` - * - * ### Truncate part of the file - * - * ``` - * const file = await Deno.makeTempFile(); - * await Deno.writeFile(file, new TextEncoder().encode("Hello World")); - * await Deno.truncate(file, 7); - * const data = await Deno.readFile(file); - * console.log(new TextDecoder().decode(data)); // "Hello W" - * ``` - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function truncate(name: string, len?: number): Promise; - - /** Synchronously truncates (or extends) the specified file, to reach the - * specified `len`. If `len` is not specified then the entire file contents - * are truncated. - * - * ### Truncate the entire file - * - * ```ts - * Deno.truncateSync("my_file.txt"); - * ``` - * - * ### Truncate part of the file - * - * ```ts - * const file = Deno.makeTempFileSync(); - * Deno.writeFileSync(file, new TextEncoder().encode("Hello World")); - * Deno.truncateSync(file, 7); - * const data = Deno.readFileSync(file); - * console.log(new TextDecoder().decode(data)); - * ``` - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function truncateSync(name: string, len?: number): void; - - /** @category Observability */ - export interface OpMetrics { - opsDispatched: number; - opsDispatchedSync: number; - opsDispatchedAsync: number; - opsDispatchedAsyncUnref: number; - opsCompleted: number; - opsCompletedSync: number; - opsCompletedAsync: number; - opsCompletedAsyncUnref: number; - bytesSentControl: number; - bytesSentData: number; - bytesReceived: number; - } - - /** @category Observability */ - export interface Metrics extends OpMetrics { - ops: Record; - } - - /** Receive metrics from the privileged side of Deno. This is primarily used - * in the development of Deno. _Ops_, also called _bindings_, are the - * go-between between Deno JavaScript sandbox and the rest of Deno. - * - * ```shell - * > console.table(Deno.metrics()) - * ┌─────────────────────────┬────────┐ - * │ (index) │ Values │ - * ├─────────────────────────┼────────┤ - * │ opsDispatched │ 3 │ - * │ opsDispatchedSync │ 2 │ - * │ opsDispatchedAsync │ 1 │ - * │ opsDispatchedAsyncUnref │ 0 │ - * │ opsCompleted │ 3 │ - * │ opsCompletedSync │ 2 │ - * │ opsCompletedAsync │ 1 │ - * │ opsCompletedAsyncUnref │ 0 │ - * │ bytesSentControl │ 73 │ - * │ bytesSentData │ 0 │ - * │ bytesReceived │ 375 │ - * └─────────────────────────┴────────┘ - * ``` - * - * @category Observability - */ - export function metrics(): Metrics; - - /** - * A map of open resources that Deno is tracking. The key is the resource ID - * (_rid_) and the value is its representation. - * - * @category Observability */ - interface ResourceMap { - [rid: number]: unknown; - } - - /** Returns a map of open resource IDs (_rid_) along with their string - * representations. This is an internal API and as such resource - * representation has `unknown` type; that means it can change any time and - * should not be depended upon. - * - * ```ts - * console.log(Deno.resources()); - * // { 0: "stdin", 1: "stdout", 2: "stderr" } - * Deno.openSync('../test.file'); - * console.log(Deno.resources()); - * // { 0: "stdin", 1: "stdout", 2: "stderr", 3: "fsFile" } - * ``` - * - * @category Observability - */ - export function resources(): ResourceMap; - - /** - * Additional information for FsEvent objects with the "other" kind. - * - * - `"rescan"`: rescan notices indicate either a lapse in the events or a - * change in the filesystem such that events received so far can no longer - * be relied on to represent the state of the filesystem now. An - * application that simply reacts to file changes may not care about this. - * An application that keeps an in-memory representation of the filesystem - * will need to care, and will need to refresh that representation directly - * from the filesystem. - * - * @category File System - */ - export type FsEventFlag = "rescan"; - - /** - * Represents a unique file system event yielded by a - * {@linkcode Deno.FsWatcher}. - * - * @category File System */ - export interface FsEvent { - /** The kind/type of the file system event. */ - kind: "any" | "access" | "create" | "modify" | "remove" | "other"; - /** An array of paths that are associated with the file system event. */ - paths: string[]; - /** Any additional flags associated with the event. */ - flag?: FsEventFlag; - } - - /** - * Returned by {@linkcode Deno.watchFs}. It is an async iterator yielding up - * system events. To stop watching the file system by calling `.close()` - * method. - * - * @category File System - */ - export interface FsWatcher extends AsyncIterable { - /** The resource id. */ - readonly rid: number; - /** Stops watching the file system and closes the watcher resource. */ - close(): void; - /** - * Stops watching the file system and closes the watcher resource. - * - * @deprecated Will be removed in the future. - */ - return?(value?: any): Promise>; - [Symbol.asyncIterator](): AsyncIterableIterator; - } - - /** Watch for file system events against one or more `paths`, which can be - * files or directories. These paths must exist already. One user action (e.g. - * `touch test.file`) can generate multiple file system events. Likewise, - * one user action can result in multiple file paths in one event (e.g. `mv - * old_name.txt new_name.txt`). - * - * The recursive option is `true` by default and, for directories, will watch - * the specified directory and all sub directories. - * - * Note that the exact ordering of the events can vary between operating - * systems. - * - * ```ts - * const watcher = Deno.watchFs("/"); - * for await (const event of watcher) { - * console.log(">>>> event", event); - * // { kind: "create", paths: [ "/foo.txt" ] } - * } - * ``` - * - * Call `watcher.close()` to stop watching. - * - * ```ts - * const watcher = Deno.watchFs("/"); - * - * setTimeout(() => { - * watcher.close(); - * }, 5000); - * - * for await (const event of watcher) { - * console.log(">>>> event", event); - * } - * ``` - * - * Requires `allow-read` permission. - * - * @tags allow-read - * @category File System - */ - export function watchFs( - paths: string | string[], - options?: { recursive: boolean }, - ): FsWatcher; - - /** Options which can be used with {@linkcode Deno.run}. - * - * @category Sub Process */ - export interface RunOptions { - /** Arguments to pass. - * - * _Note_: the first element needs to be a path to the executable that is - * being run. */ - cmd: readonly string[] | [string | URL, ...string[]]; - /** The current working directory that should be used when running the - * sub-process. */ - cwd?: string; - /** Any environment variables to be set when running the sub-process. */ - env?: Record; - /** By default subprocess inherits `stdout` of parent process. To change - * this this option can be set to a resource ID (_rid_) of an open file, - * `"inherit"`, `"piped"`, or `"null"`: - * - * - _number_: the resource ID of an open file/resource. This allows you to - * write to a file. - * - `"inherit"`: The default if unspecified. The subprocess inherits from the - * parent. - * - `"piped"`: A new pipe should be arranged to connect the parent and child - * sub-process. - * - `"null"`: This stream will be ignored. This is the equivalent of attaching - * the stream to `/dev/null`. - */ - stdout?: "inherit" | "piped" | "null" | number; - /** By default subprocess inherits `stderr` of parent process. To change - * this this option can be set to a resource ID (_rid_) of an open file, - * `"inherit"`, `"piped"`, or `"null"`: - * - * - _number_: the resource ID of an open file/resource. This allows you to - * write to a file. - * - `"inherit"`: The default if unspecified. The subprocess inherits from the - * parent. - * - `"piped"`: A new pipe should be arranged to connect the parent and child - * sub-process. - * - `"null"`: This stream will be ignored. This is the equivalent of attaching - * the stream to `/dev/null`. - */ - stderr?: "inherit" | "piped" | "null" | number; - /** By default subprocess inherits `stdin` of parent process. To change - * this this option can be set to a resource ID (_rid_) of an open file, - * `"inherit"`, `"piped"`, or `"null"`: - * - * - _number_: the resource ID of an open file/resource. This allows you to - * read from a file. - * - `"inherit"`: The default if unspecified. The subprocess inherits from the - * parent. - * - `"piped"`: A new pipe should be arranged to connect the parent and child - * sub-process. - * - `"null"`: This stream will be ignored. This is the equivalent of attaching - * the stream to `/dev/null`. - */ - stdin?: "inherit" | "piped" | "null" | number; - } - - /** The status resolved from the `.status()` method of a - * {@linkcode Deno.Process} instance. - * - * If `success` is `true`, then `code` will be `0`, but if `success` is - * `false`, the sub-process exit code will be set in `code`. - * - * @category Sub Process */ - export type ProcessStatus = - | { - success: true; - code: 0; - signal?: undefined; - } - | { - success: false; - code: number; - signal?: number; - }; - - /** - * Represents an instance of a sub process that is returned from - * {@linkcode Deno.run} which can be used to manage the sub-process. - * - * @category Sub Process */ - export class Process { - /** The resource ID of the sub-process. */ - readonly rid: number; - /** The operating system's process ID for the sub-process. */ - readonly pid: number; - /** A reference to the sub-processes `stdin`, which allows interacting with - * the sub-process at a low level. */ - readonly stdin: T["stdin"] extends "piped" ? Writer & Closer & { - writable: WritableStream; - } - : (Writer & Closer & { writable: WritableStream }) | null; - /** A reference to the sub-processes `stdout`, which allows interacting with - * the sub-process at a low level. */ - readonly stdout: T["stdout"] extends "piped" ? Reader & Closer & { - readable: ReadableStream; - } - : (Reader & Closer & { readable: ReadableStream }) | null; - /** A reference to the sub-processes `stderr`, which allows interacting with - * the sub-process at a low level. */ - readonly stderr: T["stderr"] extends "piped" ? Reader & Closer & { - readable: ReadableStream; - } - : (Reader & Closer & { readable: ReadableStream }) | null; - /** Wait for the process to exit and return its exit status. - * - * Calling this function multiple times will return the same status. - * - * The `stdin` reference to the process will be closed before waiting to - * avoid a deadlock. - * - * If `stdout` and/or `stderr` were set to `"piped"`, they must be closed - * manually before the process can exit. - * - * To run process to completion and collect output from both `stdout` and - * `stderr` use: - * - * ```ts - * const p = Deno.run({ cmd: [ "echo", "hello world" ], stderr: 'piped', stdout: 'piped' }); - * const [status, stdout, stderr] = await Promise.all([ - * p.status(), - * p.output(), - * p.stderrOutput() - * ]); - * p.close(); - * ``` - */ - status(): Promise; - /** Buffer the stdout until EOF and return it as `Uint8Array`. - * - * You must set `stdout` to `"piped"` when creating the process. - * - * This calls `close()` on stdout after its done. */ - output(): Promise; - /** Buffer the stderr until EOF and return it as `Uint8Array`. - * - * You must set `stderr` to `"piped"` when creating the process. - * - * This calls `close()` on stderr after its done. */ - stderrOutput(): Promise; - /** Clean up resources associated with the sub-process instance. */ - close(): void; - /** Send a signal to process. - * Default signal is `"SIGTERM"`. - * - * ```ts - * const p = Deno.run({ cmd: [ "sleep", "20" ]}); - * p.kill("SIGTERM"); - * p.close(); - * ``` - */ - kill(signo?: Signal): void; - } - - /** Operating signals which can be listened for or sent to sub-processes. What - * signals and what their standard behaviors are OS dependent. - * - * @category Runtime Environment */ - export type Signal = - | "SIGABRT" - | "SIGALRM" - | "SIGBREAK" - | "SIGBUS" - | "SIGCHLD" - | "SIGCONT" - | "SIGEMT" - | "SIGFPE" - | "SIGHUP" - | "SIGILL" - | "SIGINFO" - | "SIGINT" - | "SIGIO" - | "SIGKILL" - | "SIGPIPE" - | "SIGPROF" - | "SIGPWR" - | "SIGQUIT" - | "SIGSEGV" - | "SIGSTKFLT" - | "SIGSTOP" - | "SIGSYS" - | "SIGTERM" - | "SIGTRAP" - | "SIGTSTP" - | "SIGTTIN" - | "SIGTTOU" - | "SIGURG" - | "SIGUSR1" - | "SIGUSR2" - | "SIGVTALRM" - | "SIGWINCH" - | "SIGXCPU" - | "SIGXFSZ"; - - /** Registers the given function as a listener of the given signal event. - * - * ```ts - * Deno.addSignalListener( - * "SIGTERM", - * () => { - * console.log("SIGTERM!") - * } - * ); - * ``` - * - * _Note_: On Windows only `"SIGINT"` (CTRL+C) and `"SIGBREAK"` (CTRL+Break) - * are supported. - * - * @category Runtime Environment - */ - export function addSignalListener(signal: Signal, handler: () => void): void; - - /** Removes the given signal listener that has been registered with - * {@linkcode Deno.addSignalListener}. - * - * ```ts - * const listener = () => { - * console.log("SIGTERM!") - * }; - * Deno.addSignalListener("SIGTERM", listener); - * Deno.removeSignalListener("SIGTERM", listener); - * ``` - * - * _Note_: On Windows only `"SIGINT"` (CTRL+C) and `"SIGBREAK"` (CTRL+Break) - * are supported. - * - * @category Runtime Environment - */ - export function removeSignalListener( - signal: Signal, - handler: () => void, - ): void; - - /** Spawns new subprocess. RunOptions must contain at a minimum the `opt.cmd`, - * an array of program arguments, the first of which is the binary. - * - * ```ts - * const p = Deno.run({ - * cmd: ["curl", "https://example.com"], - * }); - * const status = await p.status(); - * ``` - * - * Subprocess uses same working directory as parent process unless `opt.cwd` - * is specified. - * - * Environmental variables from parent process can be cleared using `opt.clearEnv`. - * Doesn't guarantee that only `opt.env` variables are present, - * as the OS may set environmental variables for processes. - * - * Environmental variables for subprocess can be specified using `opt.env` - * mapping. - * - * `opt.uid` sets the child process’s user ID. This translates to a setuid call - * in the child process. Failure in the setuid call will cause the spawn to fail. - * - * `opt.gid` is similar to `opt.uid`, but sets the group ID of the child process. - * This has the same semantics as the uid field. - * - * By default subprocess inherits stdio of parent process. To change - * this this, `opt.stdin`, `opt.stdout`, and `opt.stderr` can be set - * independently to a resource ID (_rid_) of an open file, `"inherit"`, - * `"piped"`, or `"null"`: - * - * - _number_: the resource ID of an open file/resource. This allows you to - * read or write to a file. - * - `"inherit"`: The default if unspecified. The subprocess inherits from the - * parent. - * - `"piped"`: A new pipe should be arranged to connect the parent and child - * sub-process. - * - `"null"`: This stream will be ignored. This is the equivalent of attaching - * the stream to `/dev/null`. - * - * Details of the spawned process are returned as an instance of - * {@linkcode Deno.Process}. - * - * Requires `allow-run` permission. - * - * @tags allow-run - * @category Sub Process - */ - export function run(opt: T): Process; - - /** Option which can be specified when performing {@linkcode Deno.inspect}. - * - * @category Console and Debugging */ - export interface InspectOptions { - /** Stylize output with ANSI colors. Defaults to `false`. */ - colors?: boolean; - /** Try to fit more than one entry of a collection on the same line. - * Defaults to `true`. */ - compact?: boolean; - /** Traversal depth for nested objects. Defaults to `4`. */ - depth?: number; - /** The maximum number of iterable entries to print. Defaults to `100`. */ - iterableLimit?: number; - /** Show a Proxy's target and handler. Defaults to `false`. */ - showProxy?: boolean; - /** Sort Object, Set and Map entries by key. Defaults to `false`. */ - sorted?: boolean; - /** Add a trailing comma for multiline collections. Defaults to `false`. */ - trailingComma?: boolean; - /*** Evaluate the result of calling getters. Defaults to `false`. */ - getters?: boolean; - /** Show an object's non-enumerable properties. Defaults to `false`. */ - showHidden?: boolean; - /** The maximum length of a string before it is truncated with an - * ellipsis. */ - strAbbreviateSize?: number; - } - - /** Converts the input into a string that has the same format as printed by - * `console.log()`. - * - * ```ts - * const obj = { - * a: 10, - * b: "hello", - * }; - * const objAsString = Deno.inspect(obj); // { a: 10, b: "hello" } - * console.log(obj); // prints same value as objAsString, e.g. { a: 10, b: "hello" } - * ``` - * - * A custom inspect functions can be registered on objects, via the symbol - * `Symbol.for("Deno.customInspect")`, to control and customize the output - * of `inspect()` or when using `console` logging: - * - * ```ts - * class A { - * x = 10; - * y = "hello"; - * [Symbol.for("Deno.customInspect")]() { - * return `x=${this.x}, y=${this.y}`; - * } - * } - * - * const inStringFormat = Deno.inspect(new A()); // "x=10, y=hello" - * console.log(inStringFormat); // prints "x=10, y=hello" - * ``` - * - * A depth can be specified by using the `depth` option: - * - * ```ts - * Deno.inspect({a: {b: {c: {d: 'hello'}}}}, {depth: 2}); // { a: { b: [Object] } } - * ``` - * - * @category Console and Debugging - */ - export function inspect(value: unknown, options?: InspectOptions): string; - - /** The name of a privileged feature which needs permission. - * - * @category Permissions - */ - export type PermissionName = - | "run" - | "read" - | "write" - | "net" - | "env" - | "sys" - | "ffi" - | "hrtime"; - - /** The current status of the permission: - * - * - `"granted"` - the permission has been granted. - * - `"denied"` - the permission has been explicitly denied. - * - `"prompt"` - the permission has not explicitly granted nor denied. - * - * @category Permissions - */ - export type PermissionState = "granted" | "denied" | "prompt"; - - /** The permission descriptor for the `allow-run` permission, which controls - * access to what sub-processes can be executed by Deno. The option `command` - * allows scoping the permission to a specific executable. - * - * **Warning, in practice, `allow-run` is effectively the same as `allow-all` - * in the sense that malicious code could execute any arbitrary code on the - * host.** - * - * @category Permissions */ - export interface RunPermissionDescriptor { - name: "run"; - /** The `allow-run` permission can be scoped to a specific executable, - * which would be relative to the start-up CWD of the Deno CLI. */ - command?: string | URL; - } - - /** The permission descriptor for the `allow-read` permissions, which controls - * access to reading resources from the local host. The option `path` allows - * scoping the permission to a specific path (and if the path is a directory - * any sub paths). - * - * Permission granted under `allow-read` only allows runtime code to attempt - * to read, the underlying operating system may apply additional permissions. - * - * @category Permissions */ - export interface ReadPermissionDescriptor { - name: "read"; - /** The `allow-read` permission can be scoped to a specific path (and if - * the path is a directory, any sub paths). */ - path?: string | URL; - } - - /** The permission descriptor for the `allow-write` permissions, which - * controls access to writing to resources from the local host. The option - * `path` allow scoping the permission to a specific path (and if the path is - * a directory any sub paths). - * - * Permission granted under `allow-write` only allows runtime code to attempt - * to write, the underlying operating system may apply additional permissions. - * - * @category Permissions */ - export interface WritePermissionDescriptor { - name: "write"; - /** The `allow-write` permission can be scoped to a specific path (and if - * the path is a directory, any sub paths). */ - path?: string | URL; - } - - /** The permission descriptor for the `allow-net` permissions, which controls - * access to opening network ports and connecting to remote hosts via the - * network. The option `host` allows scoping the permission for outbound - * connection to a specific host and port. - * - * @category Permissions */ - export interface NetPermissionDescriptor { - name: "net"; - /** Optional host string of the form `"[:]"`. Examples: - * - * "github.com" - * "deno.land:8080" - */ - host?: string; - } - - /** The permission descriptor for the `allow-env` permissions, which controls - * access to being able to read and write to the process environment variables - * as well as access other information about the environment. The option - * `variable` allows scoping the permission to a specific environment - * variable. - * - * @category Permissions */ - export interface EnvPermissionDescriptor { - name: "env"; - /** Optional environment variable name (e.g. `PATH`). */ - variable?: string; - } - - /** The permission descriptor for the `allow-sys` permissions, which controls - * access to sensitive host system information, which malicious code might - * attempt to exploit. The option `kind` allows scoping the permission to a - * specific piece of information. - * - * @category Permissions */ - export interface SysPermissionDescriptor { - name: "sys"; - /** The specific information to scope the permission to. */ - kind?: - | "loadavg" - | "hostname" - | "systemMemoryInfo" - | "networkInterfaces" - | "osRelease" - | "uid" - | "gid"; - } - - /** The permission descriptor for the `allow-ffi` permissions, which controls - * access to loading _foreign_ code and interfacing with it via the - * [Foreign Function Interface API](https://deno.land/manual/runtime/ffi_api) - * available in Deno. The option `path` allows scoping the permission to a - * specific path on the host. - * - * @category Permissions */ - export interface FfiPermissionDescriptor { - name: "ffi"; - /** Optional path on the local host to scope the permission to. */ - path?: string | URL; - } - - /** The permission descriptor for the `allow-hrtime` permission, which - * controls if the runtime code has access to high resolution time. High - * resolution time is consider sensitive information, because it can be used - * by malicious code to gain information about the host that it might - * otherwise have access to. - * - * @category Permissions */ - export interface HrtimePermissionDescriptor { - name: "hrtime"; - } - - /** Permission descriptors which define a permission and can be queried, - * requested, or revoked. - * - * View the specifics of the individual descriptors for more information about - * each permission kind. - * - * @category Permissions - */ - export type PermissionDescriptor = - | RunPermissionDescriptor - | ReadPermissionDescriptor - | WritePermissionDescriptor - | NetPermissionDescriptor - | EnvPermissionDescriptor - | SysPermissionDescriptor - | FfiPermissionDescriptor - | HrtimePermissionDescriptor; - - /** The interface which defines what event types are supported by - * {@linkcode PermissionStatus} instances. - * - * @category Permissions */ - export interface PermissionStatusEventMap { - "change": Event; - } - - /** An {@linkcode EventTarget} returned from the {@linkcode Deno.permissions} - * API which can provide updates to any state changes of the permission. - * - * @category Permissions */ - export class PermissionStatus extends EventTarget { - // deno-lint-ignore no-explicit-any - onchange: ((this: PermissionStatus, ev: Event) => any) | null; - readonly state: PermissionState; - addEventListener( - type: K, - listener: ( - this: PermissionStatus, - ev: PermissionStatusEventMap[K], - ) => any, - options?: boolean | AddEventListenerOptions, - ): void; - addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | AddEventListenerOptions, - ): void; - removeEventListener( - type: K, - listener: ( - this: PermissionStatus, - ev: PermissionStatusEventMap[K], - ) => any, - options?: boolean | EventListenerOptions, - ): void; - removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | EventListenerOptions, - ): void; - } - - /** - * Deno's permission management API. - * - * The class which provides the interface for the {@linkcode Deno.permissions} - * global instance and is based on the web platform - * [Permissions API](https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API), - * though some proposed parts of the API which are useful in a server side - * runtime context were removed or abandoned in the web platform specification - * which is why it was chosen to locate it in the {@linkcode Deno} namespace - * instead. - * - * By default, if the `stdin`/`stdout` is TTY for the Deno CLI (meaning it can - * send and receive text), then the CLI will prompt the user to grant - * permission when an un-granted permission is requested. This behavior can - * be changed by using the `--no-prompt` command at startup. When prompting - * the CLI will request the narrowest permission possible, potentially making - * it annoying to the user. The permissions APIs allow the code author to - * request a wider set of permissions at one time in order to provide a better - * user experience. - * - * @category Permissions */ - export class Permissions { - /** Resolves to the current status of a permission. - * - * Note, if the permission is already granted, `request()` will not prompt - * the user again, therefore `query()` is only necessary if you are going - * to react differently existing permissions without wanting to modify them - * or prompt the user to modify them. - * - * ```ts - * const status = await Deno.permissions.query({ name: "read", path: "/etc" }); - * console.log(status.state); - * ``` - */ - query(desc: PermissionDescriptor): Promise; - - /** Revokes a permission, and resolves to the state of the permission. - * - * ```ts - * import { assert } from "https://deno.land/std/testing/asserts.ts"; - * - * const status = await Deno.permissions.revoke({ name: "run" }); - * assert(status.state !== "granted") - * ``` - */ - revoke(desc: PermissionDescriptor): Promise; - - /** Requests the permission, and resolves to the state of the permission. - * - * If the permission is already granted, the user will not be prompted to - * grant the permission again. - * - * ```ts - * const status = await Deno.permissions.request({ name: "env" }); - * if (status.state === "granted") { - * console.log("'env' permission is granted."); - * } else { - * console.log("'env' permission is denied."); - * } - * ``` - */ - request(desc: PermissionDescriptor): Promise; - } - - /** Deno's permission management API. - * - * It is a singleton instance of the {@linkcode Permissions} object and is - * based on the web platform - * [Permissions API](https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API), - * though some proposed parts of the API which are useful in a server side - * runtime context were removed or abandoned in the web platform specification - * which is why it was chosen to locate it in the {@linkcode Deno} namespace - * instead. - * - * By default, if the `stdin`/`stdout` is TTY for the Deno CLI (meaning it can - * send and receive text), then the CLI will prompt the user to grant - * permission when an un-granted permission is requested. This behavior can - * be changed by using the `--no-prompt` command at startup. When prompting - * the CLI will request the narrowest permission possible, potentially making - * it annoying to the user. The permissions APIs allow the code author to - * request a wider set of permissions at one time in order to provide a better - * user experience. - * - * Requesting already granted permissions will not prompt the user and will - * return that the permission was granted. - * - * ### Querying - * - * ```ts - * const status = await Deno.permissions.query({ name: "read", path: "/etc" }); - * console.log(status.state); - * ``` - * - * ### Revoking - * - * ```ts - * import { assert } from "https://deno.land/std/testing/asserts.ts"; - * - * const status = await Deno.permissions.revoke({ name: "run" }); - * assert(status.state !== "granted") - * ``` - * - * ### Requesting - * - * ```ts - * const status = await Deno.permissions.request({ name: "env" }); - * if (status.state === "granted") { - * console.log("'env' permission is granted."); - * } else { - * console.log("'env' permission is denied."); - * } - * ``` - * - * @category Permissions - */ - export const permissions: Permissions; - - /** Information related to the build of the current Deno runtime. - * - * Users are discouraged from code branching based on this information, as - * assumptions about what is available in what build environment might change - * over time. Developers should specifically sniff out the features they - * intend to use. - * - * The intended use for the information is for logging and debugging purposes. - * - * @category Runtime Environment - */ - export const build: { - /** The [LLVM](https://llvm.org/) target triple, which is the combination - * of `${arch}-${vendor}-${os}` and represent the specific build target that - * the current runtime was built for. */ - target: string; - /** Instruction set architecture that the Deno CLI was built for. */ - arch: "x86_64" | "aarch64"; - /** The operating system that the Deno CLI was built for. `"darwin"` is - * also known as OSX or MacOS. */ - os: "darwin" | "linux" | "windows"; - /** The computer vendor that the Deno CLI was built for. */ - vendor: string; - /** Optional environment flags that were set for this build of Deno CLI. */ - env?: string; - }; - - /** Version information related to the current Deno CLI runtime environment. - * - * Users are discouraged from code branching based on this information, as - * assumptions about what is available in what build environment might change - * over time. Developers should specifically sniff out the features they - * intend to use. - * - * The intended use for the information is for logging and debugging purposes. - * - * @category Runtime Environment - */ - export const version: { - /** Deno CLI's version. For example: `"1.26.0"`. */ - deno: string; - /** The V8 version used by Deno. For example: `"10.7.100.0"`. - * - * V8 is the underlying JavaScript runtime platform that Deno is built on - * top of. */ - v8: string; - /** The TypeScript version used by Deno. For example: `"4.8.3"`. - * - * A version of the TypeScript type checker and language server is built-in - * to the Deno CLI. */ - typescript: string; - }; - - /** Returns the script arguments to the program. - * - * Give the following command line invocation of Deno: - * - * ```sh - * deno run --allow-read https://deno.land/std/examples/cat.ts /etc/passwd - * ``` - * - * Then `Deno.args` will contain: - * - * ``` - * [ "/etc/passwd" ] - * ``` - * - * If you are looking for a structured way to parse arguments, there is the - * [`std/flags`](https://deno.land/std/flags) module as part of the Deno - * standard library. - * - * @category Runtime Environment - */ - export const args: string[]; - - /** - * A symbol which can be used as a key for a custom method which will be - * called when `Deno.inspect()` is called, or when the object is logged to - * the console. - * - * @deprecated This symbol is deprecated since 1.9. Use - * `Symbol.for("Deno.customInspect")` instead. - * - * @category Console and Debugging - */ - export const customInspect: unique symbol; - - /** The URL of the entrypoint module entered from the command-line. It - * requires read permission to the CWD. - * - * Also see {@linkcode ImportMeta} for other related information. - * - * @tags allow-read - * @category Runtime Environment - */ - export const mainModule: string; - - /** Options that can be used with {@linkcode symlink} and - * {@linkcode symlinkSync}. - * - * @category File System */ - export interface SymlinkOptions { - /** If the symbolic link should be either a file or directory. This option - * only applies to Windows and is ignored on other operating systems. */ - type: "file" | "dir"; - } - - /** - * Creates `newpath` as a symbolic link to `oldpath`. - * - * The `options.type` parameter can be set to `"file"` or `"dir"`. This - * argument is only available on Windows and ignored on other platforms. - * - * ```ts - * await Deno.symlink("old/name", "new/name"); - * ``` - * - * Requires full `allow-read` and `allow-write` permissions. - * - * @tags allow-read, allow-write - * @category File System - */ - export function symlink( - oldpath: string | URL, - newpath: string | URL, - options?: SymlinkOptions, - ): Promise; - - /** - * Creates `newpath` as a symbolic link to `oldpath`. - * - * The `options.type` parameter can be set to `"file"` or `"dir"`. This - * argument is only available on Windows and ignored on other platforms. - * - * ```ts - * Deno.symlinkSync("old/name", "new/name"); - * ``` - * - * Requires full `allow-read` and `allow-write` permissions. - * - * @tags allow-read, allow-write - * @category File System - */ - export function symlinkSync( - oldpath: string | URL, - newpath: string | URL, - options?: SymlinkOptions, - ): void; - - /** - * Truncates or extends the specified file stream, to reach the specified - * `len`. - * - * If `len` is not specified then the entire file contents are truncated as if - * `len` was set to `0`. - * - * If the file previously was larger than this new length, the extra data is - * lost. - * - * If the file previously was shorter, it is extended, and the extended part - * reads as null bytes ('\0'). - * - * ### Truncate the entire file - * - * ```ts - * const file = await Deno.open( - * "my_file.txt", - * { read: true, write: true, create: true } - * ); - * await Deno.ftruncate(file.rid); - * ``` - * - * ### Truncate part of the file - * - * ```ts - * const file = await Deno.open( - * "my_file.txt", - * { read: true, write: true, create: true } - * ); - * await Deno.write(file.rid, new TextEncoder().encode("Hello World")); - * await Deno.ftruncate(file.rid, 7); - * const data = new Uint8Array(32); - * await Deno.read(file.rid, data); - * console.log(new TextDecoder().decode(data)); // Hello W - * ``` - * - * @category File System - */ - export function ftruncate(rid: number, len?: number): Promise; - - /** - * Synchronously truncates or extends the specified file stream, to reach the - * specified `len`. - * - * If `len` is not specified then the entire file contents are truncated as if - * `len` was set to `0`. - * - * If the file previously was larger than this new length, the extra data is - * lost. - * - * If the file previously was shorter, it is extended, and the extended part - * reads as null bytes ('\0'). - * - * ### Truncate the entire file - * - * ```ts - * const file = Deno.openSync( - * "my_file.txt", - * { read: true, write: true, truncate: true, create: true } - * ); - * Deno.ftruncateSync(file.rid); - * ``` - * - * ### Truncate part of the file - * - * ```ts - * const file = Deno.openSync( - * "my_file.txt", - * { read: true, write: true, create: true } - * ); - * Deno.writeSync(file.rid, new TextEncoder().encode("Hello World")); - * Deno.ftruncateSync(file.rid, 7); - * Deno.seekSync(file.rid, 0, Deno.SeekMode.Start); - * const data = new Uint8Array(32); - * Deno.readSync(file.rid, data); - * console.log(new TextDecoder().decode(data)); // Hello W - * ``` - * - * @category File System - */ - export function ftruncateSync(rid: number, len?: number): void; - - /** - * Synchronously changes the access (`atime`) and modification (`mtime`) times - * of a file stream resource referenced by `rid`. Given times are either in - * seconds (UNIX epoch time) or as `Date` objects. - * - * ```ts - * const file = Deno.openSync("file.txt", { create: true, write: true }); - * Deno.futimeSync(file.rid, 1556495550, new Date()); - * ``` - * - * @category File System - */ - export function futimeSync( - rid: number, - atime: number | Date, - mtime: number | Date, - ): void; - - /** - * Changes the access (`atime`) and modification (`mtime`) times of a file - * stream resource referenced by `rid`. Given times are either in seconds - * (UNIX epoch time) or as `Date` objects. - * - * ```ts - * const file = await Deno.open("file.txt", { create: true, write: true }); - * await Deno.futime(file.rid, 1556495550, new Date()); - * ``` - * - * @category File System - */ - export function futime( - rid: number, - atime: number | Date, - mtime: number | Date, - ): Promise; - - /** - * Returns a `Deno.FileInfo` for the given file stream. - * - * ```ts - * import { assert } from "https://deno.land/std/testing/asserts.ts"; - * - * const file = await Deno.open("file.txt", { read: true }); - * const fileInfo = await Deno.fstat(file.rid); - * assert(fileInfo.isFile); - * ``` - * - * @category File System - */ - export function fstat(rid: number): Promise; - - /** - * Synchronously returns a {@linkcode Deno.FileInfo} for the given file - * stream. - * - * ```ts - * import { assert } from "https://deno.land/std/testing/asserts.ts"; - * - * const file = Deno.openSync("file.txt", { read: true }); - * const fileInfo = Deno.fstatSync(file.rid); - * assert(fileInfo.isFile); - * ``` - * - * @category File System - */ - export function fstatSync(rid: number): FileInfo; - - /** - * Synchronously changes the access (`atime`) and modification (`mtime`) times - * of a file system object referenced by `path`. Given times are either in - * seconds (UNIX epoch time) or as `Date` objects. - * - * ```ts - * Deno.utimeSync("myfile.txt", 1556495550, new Date()); - * ``` - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function utimeSync( - path: string | URL, - atime: number | Date, - mtime: number | Date, - ): void; - - /** - * Changes the access (`atime`) and modification (`mtime`) times of a file - * system object referenced by `path`. Given times are either in seconds - * (UNIX epoch time) or as `Date` objects. - * - * ```ts - * await Deno.utime("myfile.txt", 1556495550, new Date()); - * ``` - * - * Requires `allow-write` permission. - * - * @tags allow-write - * @category File System - */ - export function utime( - path: string | URL, - atime: number | Date, - mtime: number | Date, - ): Promise; - - /** The event yielded from an {@linkcode HttpConn} which represents an HTTP - * request from a remote client. - * - * @category HTTP Server */ - export interface RequestEvent { - /** The request from the client in the form of the web platform - * {@linkcode Request}. */ - readonly request: Request; - /** The method to be used to respond to the event. The response needs to - * either be an instance of {@linkcode Response} or a promise that resolves - * with an instance of `Response`. - * - * When the response is successfully processed then the promise returned - * will be resolved. If there are any issues with sending the response, - * the promise will be rejected. */ - respondWith(r: Response | PromiseLike): Promise; - } - - /** The async iterable that is returned from {@linkcode Deno.serveHttp} which - * yields up {@linkcode RequestEvent} events, representing individual - * requests on the HTTP server connection. - * - * @category HTTP Server */ - export interface HttpConn extends AsyncIterable { - /** The resource ID associated with this connection. Generally users do not - * need to be aware of this identifier. */ - readonly rid: number; - - /** An alternative to the async iterable interface which provides promises - * which resolve with either a {@linkcode RequestEvent} when there is - * another request or `null` when the client has closed the connection. */ - nextRequest(): Promise; - /** Initiate a server side closure of the connection, indicating to the - * client that you refuse to accept any more requests on this connection. - * - * Typically the client closes the connection, which will result in the - * async iterable terminating or the `nextRequest()` method returning - * `null`. */ - close(): void; - } - - /** - * Provides an interface to handle HTTP request and responses over TCP or TLS - * connections. The method returns an {@linkcode HttpConn} which yields up - * {@linkcode RequestEvent} events, which utilize the web platform standard - * {@linkcode Request} and {@linkcode Response} objects to handle the request. - * - * ```ts - * const conn = Deno.listen({ port: 80 }); - * const httpConn = Deno.serveHttp(await conn.accept()); - * const e = await httpConn.nextRequest(); - * if (e) { - * e.respondWith(new Response("Hello World")); - * } - * ``` - * - * Alternatively, you can also use the async iterator approach: - * - * ```ts - * async function handleHttp(conn: Deno.Conn) { - * for await (const e of Deno.serveHttp(conn)) { - * e.respondWith(new Response("Hello World")); - * } - * } - * - * for await (const conn of Deno.listen({ port: 80 })) { - * handleHttp(conn); - * } - * ``` - * - * If `httpConn.nextRequest()` encounters an error or returns `null` then the - * underlying {@linkcode HttpConn} resource is closed automatically. - * - * Also see the experimental Flash HTTP server {@linkcode Deno.serve} which - * provides a ground up rewrite of handling of HTTP requests and responses - * within the Deno CLI. - * - * Note that this function *consumes* the given connection passed to it, thus - * the original connection will be unusable after calling this. Additionally, - * you need to ensure that the connection is not being used elsewhere when - * calling this function in order for the connection to be consumed properly. - * - * For instance, if there is a `Promise` that is waiting for read operation on - * the connection to complete, it is considered that the connection is being - * used elsewhere. In such a case, this function will fail. - * - * @category HTTP Server - */ - export function serveHttp(conn: Conn): HttpConn; - - /** The object that is returned from a {@linkcode Deno.upgradeWebSocket} - * request. - * - * @category Web Sockets */ - export interface WebSocketUpgrade { - /** The response object that represents the HTTP response to the client, - * which should be used to the {@linkcode RequestEvent} `.respondWith()` for - * the upgrade to be successful. */ - response: Response; - /** The {@linkcode WebSocket} interface to communicate to the client via a - * web socket. */ - socket: WebSocket; - } - - /** Options which can be set when performing a - * {@linkcode Deno.upgradeWebSocket} upgrade of a {@linkcode Request} - * - * @category Web Sockets */ - export interface UpgradeWebSocketOptions { - /** Sets the `.protocol` property on the client side web socket to the - * value provided here, which should be one of the strings specified in the - * `protocols` parameter when requesting the web socket. This is intended - * for clients and servers to specify sub-protocols to use to communicate to - * each other. */ - protocol?: string; - /** If the client does not respond to this frame with a - * `pong` within the timeout specified, the connection is deemed - * unhealthy and is closed. The `close` and `error` event will be emitted. - * - * The default is 120 seconds. Set to `0` to disable timeouts. */ - idleTimeout?: number; - } - - /** - * Upgrade an incoming HTTP request to a WebSocket. - * - * Given a {@linkcode Request}, returns a pair of {@linkcode WebSocket} and - * {@linkcode Response} instances. The original request must be responded to - * with the returned response for the websocket upgrade to be successful. - * - * ```ts - * const conn = Deno.listen({ port: 80 }); - * const httpConn = Deno.serveHttp(await conn.accept()); - * const e = await httpConn.nextRequest(); - * if (e) { - * const { socket, response } = Deno.upgradeWebSocket(e.request); - * socket.onopen = () => { - * socket.send("Hello World!"); - * }; - * socket.onmessage = (e) => { - * console.log(e.data); - * socket.close(); - * }; - * socket.onclose = () => console.log("WebSocket has been closed."); - * socket.onerror = (e) => console.error("WebSocket error:", e); - * e.respondWith(response); - * } - * ``` - * - * If the request body is disturbed (read from) before the upgrade is - * completed, upgrading fails. - * - * This operation does not yet consume the request or open the websocket. This - * only happens once the returned response has been passed to `respondWith()`. - * - * @category Web Sockets - */ - export function upgradeWebSocket( - request: Request, - options?: UpgradeWebSocketOptions, - ): WebSocketUpgrade; - - /** Send a signal to process under given `pid`. The value and meaning of the - * `signal` to the process is operating system and process dependant. - * {@linkcode Signal} provides the most common signals. Default signal - * is `"SIGTERM"`. - * - * The term `kill` is adopted from the UNIX-like command line command `kill` - * which also signals processes. - * - * If `pid` is negative, the signal will be sent to the process group - * identified by `pid`. An error will be thrown if a negative `pid` is used on - * Windows. - * - * ```ts - * const p = Deno.run({ - * cmd: ["sleep", "10000"] - * }); - * - * Deno.kill(p.pid, "SIGINT"); - * ``` - * - * Requires `allow-run` permission. - * - * @tags allow-run - * @category Sub Process - */ - export function kill(pid: number, signo?: Signal): void; - - /** The type of the resource record to resolve via DNS using - * {@linkcode Deno.resolveDns}. - * - * Only the listed types are supported currently. - * - * @category Network - */ - export type RecordType = - | "A" - | "AAAA" - | "ANAME" - | "CAA" - | "CNAME" - | "MX" - | "NAPTR" - | "NS" - | "PTR" - | "SOA" - | "SRV" - | "TXT"; - - /** - * Options which can be set when using {@linkcode Deno.resolveDns}. - * - * @category Network */ - export interface ResolveDnsOptions { - /** The name server to be used for lookups. - * - * If not specified, defaults to the system configuration. For example - * `/etc/resolv.conf` on Unix-like systems. */ - nameServer?: { - /** The IP address of the name server. */ - ipAddr: string; - /** The port number the query will be sent to. - * - * If not specified, defaults to `53`. */ - port?: number; - }; - } - - /** If {@linkcode Deno.resolveDns} is called with `"CAA"` record type - * specified, it will resolve with an array of objects with this interface. - * - * @category Network - */ - export interface CAARecord { - /** If `true`, indicates that the corresponding property tag **must** be - * understood if the semantics of the CAA record are to be correctly - * interpreted by an issuer. - * - * Issuers **must not** issue certificates for a domain if the relevant CAA - * Resource Record set contains unknown property tags that have `critical` - * set. */ - critical: boolean; - /** An string that represents the identifier of the property represented by - * the record. */ - tag: string; - /** The value associated with the tag. */ - value: string; - } - - /** If {@linkcode Deno.resolveDns} is called with `"MX"` record type - * specified, it will return an array of objects with this interface. - * - * @category Network */ - export interface MXRecord { - /** A priority value, which is a relative value compared to the other - * preferences of MX records for the domain. */ - preference: number; - /** The server that mail should be delivered to. */ - exchange: string; - } - - /** If {@linkcode Deno.resolveDns} is called with `"NAPTR"` record type - * specified, it will return an array of objects with this interface. - * - * @category Network */ - export interface NAPTRRecord { - order: number; - preference: number; - flags: string; - services: string; - regexp: string; - replacement: string; - } - - /** If {@linkcode Deno.resolveDns} is called with `"SOA"` record type - * specified, it will return an array of objects with this interface. - * - * @category Network */ - export interface SOARecord { - mname: string; - rname: string; - serial: number; - refresh: number; - retry: number; - expire: number; - minimum: number; - } - - /** If {@linkcode Deno.resolveDns} is called with `"SRV"` record type - * specified, it will return an array of objects with this interface. - * - * @category Network - */ - export interface SRVRecord { - priority: number; - weight: number; - port: number; - target: string; - } - - /** - * Performs DNS resolution against the given query, returning resolved - * records. - * - * Fails in the cases such as: - * - * - the query is in invalid format. - * - the options have an invalid parameter. For example `nameServer.port` is - * beyond the range of 16-bit unsigned integer. - * - the request timed out. - * - * ```ts - * const a = await Deno.resolveDns("example.com", "A"); - * - * const aaaa = await Deno.resolveDns("example.com", "AAAA", { - * nameServer: { ipAddr: "8.8.8.8", port: 53 }, - * }); - * ``` - * - * Requires `allow-net` permission. - * - * @tags allow-net - * @category Network - */ - export function resolveDns( - query: string, - recordType: "A" | "AAAA" | "ANAME" | "CNAME" | "NS" | "PTR", - options?: ResolveDnsOptions, - ): Promise; - - /** - * Performs DNS resolution against the given query, returning resolved - * records. - * - * Fails in the cases such as: - * - * - the query is in invalid format. - * - the options have an invalid parameter. For example `nameServer.port` is - * beyond the range of 16-bit unsigned integer. - * - the request timed out. - * - * ```ts - * const a = await Deno.resolveDns("example.com", "A"); - * - * const aaaa = await Deno.resolveDns("example.com", "AAAA", { - * nameServer: { ipAddr: "8.8.8.8", port: 53 }, - * }); - * ``` - * - * Requires `allow-net` permission. - * - * @tags allow-net - * @category Network - */ - export function resolveDns( - query: string, - recordType: "CAA", - options?: ResolveDnsOptions, - ): Promise; - - /** - * Performs DNS resolution against the given query, returning resolved - * records. - * - * Fails in the cases such as: - * - * - the query is in invalid format. - * - the options have an invalid parameter. For example `nameServer.port` is - * beyond the range of 16-bit unsigned integer. - * - the request timed out. - * - * ```ts - * const a = await Deno.resolveDns("example.com", "A"); - * - * const aaaa = await Deno.resolveDns("example.com", "AAAA", { - * nameServer: { ipAddr: "8.8.8.8", port: 53 }, - * }); - * ``` - * - * Requires `allow-net` permission. - * - * @tags allow-net - * @category Network - */ - export function resolveDns( - query: string, - recordType: "MX", - options?: ResolveDnsOptions, - ): Promise; - - /** - * Performs DNS resolution against the given query, returning resolved - * records. - * - * Fails in the cases such as: - * - * - the query is in invalid format. - * - the options have an invalid parameter. For example `nameServer.port` is - * beyond the range of 16-bit unsigned integer. - * - the request timed out. - * - * ```ts - * const a = await Deno.resolveDns("example.com", "A"); - * - * const aaaa = await Deno.resolveDns("example.com", "AAAA", { - * nameServer: { ipAddr: "8.8.8.8", port: 53 }, - * }); - * ``` - * - * Requires `allow-net` permission. - * - * @tags allow-net - * @category Network - */ - export function resolveDns( - query: string, - recordType: "NAPTR", - options?: ResolveDnsOptions, - ): Promise; - - /** - * Performs DNS resolution against the given query, returning resolved - * records. - * - * Fails in the cases such as: - * - * - the query is in invalid format. - * - the options have an invalid parameter. For example `nameServer.port` is - * beyond the range of 16-bit unsigned integer. - * - the request timed out. - * - * ```ts - * const a = await Deno.resolveDns("example.com", "A"); - * - * const aaaa = await Deno.resolveDns("example.com", "AAAA", { - * nameServer: { ipAddr: "8.8.8.8", port: 53 }, - * }); - * ``` - * - * Requires `allow-net` permission. - * - * @tags allow-net - * @category Network - */ - export function resolveDns( - query: string, - recordType: "SOA", - options?: ResolveDnsOptions, - ): Promise; - - /** - * Performs DNS resolution against the given query, returning resolved - * records. - * - * Fails in the cases such as: - * - * - the query is in invalid format. - * - the options have an invalid parameter. For example `nameServer.port` is - * beyond the range of 16-bit unsigned integer. - * - the request timed out. - * - * ```ts - * const a = await Deno.resolveDns("example.com", "A"); - * - * const aaaa = await Deno.resolveDns("example.com", "AAAA", { - * nameServer: { ipAddr: "8.8.8.8", port: 53 }, - * }); - * ``` - * - * Requires `allow-net` permission. - * - * @tags allow-net - * @category Network - */ - export function resolveDns( - query: string, - recordType: "SRV", - options?: ResolveDnsOptions, - ): Promise; - - /** - * Performs DNS resolution against the given query, returning resolved - * records. - * - * Fails in the cases such as: - * - * - the query is in invalid format. - * - the options have an invalid parameter. For example `nameServer.port` is - * beyond the range of 16-bit unsigned integer. - * - the request timed out. - * - * ```ts - * const a = await Deno.resolveDns("example.com", "A"); - * - * const aaaa = await Deno.resolveDns("example.com", "AAAA", { - * nameServer: { ipAddr: "8.8.8.8", port: 53 }, - * }); - * ``` - * - * Requires `allow-net` permission. - * - * @tags allow-net - * @category Network - */ - export function resolveDns( - query: string, - recordType: "TXT", - options?: ResolveDnsOptions, - ): Promise; - - /** - * Performs DNS resolution against the given query, returning resolved - * records. - * - * Fails in the cases such as: - * - * - the query is in invalid format. - * - the options have an invalid parameter. For example `nameServer.port` is - * beyond the range of 16-bit unsigned integer. - * - the request timed out. - * - * ```ts - * const a = await Deno.resolveDns("example.com", "A"); - * - * const aaaa = await Deno.resolveDns("example.com", "AAAA", { - * nameServer: { ipAddr: "8.8.8.8", port: 53 }, - * }); - * ``` - * - * Requires `allow-net` permission. - * - * @tags allow-net - * @category Network - */ - export function resolveDns( - query: string, - recordType: RecordType, - options?: ResolveDnsOptions, - ): Promise< - | string[] - | CAARecord[] - | MXRecord[] - | NAPTRRecord[] - | SOARecord[] - | SRVRecord[] - | string[][] - >; - - /** - * Make the timer of the given `id` block the event loop from finishing. - * - * @category Timers - */ - export function refTimer(id: number): void; - - /** - * Make the timer of the given `id` not block the event loop from finishing. - * - * @category Timers - */ - export function unrefTimer(id: number): void; - - /** - * Returns the user id of the process on POSIX platforms. Returns null on Windows. - * - * ```ts - * console.log(Deno.uid()); - * ``` - * - * Requires `allow-sys` permission. - * - * @tags allow-sys - * @category Runtime Environment - */ - export function uid(): number | null; - - /** - * Returns the group id of the process on POSIX platforms. Returns null on windows. - * - * ```ts - * console.log(Deno.gid()); - * ``` - * - * Requires `allow-sys` permission. - * - * @tags allow-sys - * @category Runtime Environment - */ - export function gid(): number | null; -} diff --git a/cli/dts/lib.deno.shared_globals.d.ts b/cli/dts/lib.deno.shared_globals.d.ts deleted file mode 100644 index 5b30c0a87..000000000 --- a/cli/dts/lib.deno.shared_globals.d.ts +++ /dev/null @@ -1,684 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. - -// Documentation partially adapted from [MDN](https://developer.mozilla.org/), -// by Mozilla Contributors, which is licensed under CC-BY-SA 2.5. - -/// -/// -/// -/// -/// -/// -/// -/// -/// - -/** @category WebAssembly */ -declare namespace WebAssembly { - /** - * The `WebAssembly.CompileError` object indicates an error during WebAssembly decoding or validation. - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError) - * - * @category WebAssembly - */ - export class CompileError extends Error { - /** Creates a new `WebAssembly.CompileError` object. */ - constructor(message?: string, options?: ErrorOptions); - } - - /** - * A `WebAssembly.Global` object represents a global variable instance, accessible from - * both JavaScript and importable/exportable across one or more `WebAssembly.Module` - * instances. This allows dynamic linking of multiple modules. - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global) - * - * @category WebAssembly - */ - export class Global { - /** Creates a new `Global` object. */ - constructor(descriptor: GlobalDescriptor, v?: any); - - /** - * The value contained inside the global variable — this can be used to directly set - * and get the global's value. - */ - value: any; - - /** Old-style method that returns the value contained inside the global variable. */ - valueOf(): any; - } - - /** - * A `WebAssembly.Instance` object is a stateful, executable instance of a `WebAssembly.Module`. - * Instance objects contain all the Exported WebAssembly functions that allow calling into - * WebAssembly code from JavaScript. - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance) - * - * @category WebAssembly - */ - export class Instance { - /** Creates a new Instance object. */ - constructor(module: Module, importObject?: Imports); - - /** - * Returns an object containing as its members all the functions exported from the - * WebAssembly module instance, to allow them to be accessed and used by JavaScript. - * Read-only. - */ - readonly exports: Exports; - } - - /** - * The `WebAssembly.LinkError` object indicates an error during module instantiation - * (besides traps from the start function). - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError) - * - * @category WebAssembly - */ - export class LinkError extends Error { - /** Creates a new WebAssembly.LinkError object. */ - constructor(message?: string, options?: ErrorOptions); - } - - /** - * The `WebAssembly.Memory` object is a resizable `ArrayBuffer` or `SharedArrayBuffer` that - * holds the raw bytes of memory accessed by a WebAssembly Instance. - * - * A memory created by JavaScript or in WebAssembly code will be accessible and mutable - * from both JavaScript and WebAssembly. - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) - * - * @category WebAssembly - */ - export class Memory { - /** Creates a new `Memory` object. */ - constructor(descriptor: MemoryDescriptor); - - /** An accessor property that returns the buffer contained in the memory. */ - readonly buffer: ArrayBuffer | SharedArrayBuffer; - - /** - * Increases the size of the memory instance by a specified number of WebAssembly - * pages (each one is 64KB in size). - */ - grow(delta: number): number; - } - - /** - * A `WebAssembly.Module` object contains stateless WebAssembly code that has already been compiled - * by the browser — this can be efficiently shared with Workers, and instantiated multiple times. - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module) - * - * @category WebAssembly - */ - export class Module { - /** Creates a new `Module` object. */ - constructor(bytes: BufferSource); - - /** - * Given a `Module` and string, returns a copy of the contents of all custom sections in the - * module with the given string name. - */ - static customSections( - moduleObject: Module, - sectionName: string, - ): ArrayBuffer[]; - - /** Given a `Module`, returns an array containing descriptions of all the declared exports. */ - static exports(moduleObject: Module): ModuleExportDescriptor[]; - - /** Given a `Module`, returns an array containing descriptions of all the declared imports. */ - static imports(moduleObject: Module): ModuleImportDescriptor[]; - } - - /** - * The `WebAssembly.RuntimeError` object is the error type that is thrown whenever WebAssembly - * specifies a trap. - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError) - * - * @category WebAssembly - */ - export class RuntimeError extends Error { - /** Creates a new `WebAssembly.RuntimeError` object. */ - constructor(message?: string, options?: ErrorOptions); - } - - /** - * The `WebAssembly.Table()` object is a JavaScript wrapper object — an array-like structure - * representing a WebAssembly Table, which stores function references. A table created by - * JavaScript or in WebAssembly code will be accessible and mutable from both JavaScript - * and WebAssembly. - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table) - * - * @category WebAssembly - */ - export class Table { - /** Creates a new `Table` object. */ - constructor(descriptor: TableDescriptor); - - /** Returns the length of the table, i.e. the number of elements. */ - readonly length: number; - - /** Accessor function — gets the element stored at a given index. */ - get(index: number): Function | null; - - /** Increases the size of the `Table` instance by a specified number of elements. */ - grow(delta: number): number; - - /** Sets an element stored at a given index to a given value. */ - set(index: number, value: Function | null): void; - } - - /** The `GlobalDescriptor` describes the options you can pass to - * `new WebAssembly.Global()`. - * - * @category WebAssembly - */ - export interface GlobalDescriptor { - mutable?: boolean; - value: ValueType; - } - - /** The `MemoryDescriptor` describes the options you can pass to - * `new WebAssembly.Memory()`. - * - * @category WebAssembly - */ - export interface MemoryDescriptor { - initial: number; - maximum?: number; - shared?: boolean; - } - - /** A `ModuleExportDescriptor` is the description of a declared export in a - * `WebAssembly.Module`. - * - * @category WebAssembly - */ - export interface ModuleExportDescriptor { - kind: ImportExportKind; - name: string; - } - - /** A `ModuleImportDescriptor` is the description of a declared import in a - * `WebAssembly.Module`. - * - * @category WebAssembly - */ - export interface ModuleImportDescriptor { - kind: ImportExportKind; - module: string; - name: string; - } - - /** The `TableDescriptor` describes the options you can pass to - * `new WebAssembly.Table()`. - * - * @category WebAssembly - */ - export interface TableDescriptor { - element: TableKind; - initial: number; - maximum?: number; - } - - /** The value returned from `WebAssembly.instantiate`. - * - * @category WebAssembly - */ - export interface WebAssemblyInstantiatedSource { - /* A `WebAssembly.Instance` object that contains all the exported WebAssembly functions. */ - instance: Instance; - - /** - * A `WebAssembly.Module` object representing the compiled WebAssembly module. - * This `Module` can be instantiated again, or shared via postMessage(). - */ - module: Module; - } - - /** @category WebAssembly */ - export type ImportExportKind = "function" | "global" | "memory" | "table"; - /** @category WebAssembly */ - export type TableKind = "anyfunc"; - /** @category WebAssembly */ - export type ValueType = "f32" | "f64" | "i32" | "i64"; - /** @category WebAssembly */ - export type ExportValue = Function | Global | Memory | Table; - /** @category WebAssembly */ - export type Exports = Record; - /** @category WebAssembly */ - export type ImportValue = ExportValue | number; - /** @category WebAssembly */ - export type ModuleImports = Record; - /** @category WebAssembly */ - export type Imports = Record; - - /** - * The `WebAssembly.compile()` function compiles WebAssembly binary code into a - * `WebAssembly.Module` object. This function is useful if it is necessary to compile - * a module before it can be instantiated (otherwise, the `WebAssembly.instantiate()` - * function should be used). - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile) - * - * @category WebAssembly - */ - export function compile(bytes: BufferSource): Promise; - - /** - * The `WebAssembly.compileStreaming()` function compiles a `WebAssembly.Module` - * directly from a streamed underlying source. This function is useful if it is - * necessary to a compile a module before it can be instantiated (otherwise, the - * `WebAssembly.instantiateStreaming()` function should be used). - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming) - * - * @category WebAssembly - */ - export function compileStreaming( - source: Response | Promise, - ): Promise; - - /** - * The WebAssembly.instantiate() function allows you to compile and instantiate - * WebAssembly code. - * - * This overload takes the WebAssembly binary code, in the form of a typed - * array or ArrayBuffer, and performs both compilation and instantiation in one step. - * The returned Promise resolves to both a compiled WebAssembly.Module and its first - * WebAssembly.Instance. - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate) - * - * @category WebAssembly - */ - export function instantiate( - bytes: BufferSource, - importObject?: Imports, - ): Promise; - - /** - * The WebAssembly.instantiate() function allows you to compile and instantiate - * WebAssembly code. - * - * This overload takes an already-compiled WebAssembly.Module and returns - * a Promise that resolves to an Instance of that Module. This overload is useful - * if the Module has already been compiled. - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate) - * - * @category WebAssembly - */ - export function instantiate( - moduleObject: Module, - importObject?: Imports, - ): Promise; - - /** - * The `WebAssembly.instantiateStreaming()` function compiles and instantiates a - * WebAssembly module directly from a streamed underlying source. This is the most - * efficient, optimized way to load wasm code. - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming) - * - * @category WebAssembly - */ - export function instantiateStreaming( - response: Response | PromiseLike, - importObject?: Imports, - ): Promise; - - /** - * The `WebAssembly.validate()` function validates a given typed array of - * WebAssembly binary code, returning whether the bytes form a valid wasm - * module (`true`) or not (`false`). - * - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate) - * - * @category WebAssembly - */ - export function validate(bytes: BufferSource): boolean; -} - -/** Sets a timer which executes a function once after the timer expires. Returns - * an id which may be used to cancel the timeout. - * - * ```ts - * setTimeout(() => { console.log('hello'); }, 500); - * ``` - * - * @category Timers - */ -declare function setTimeout( - /** callback function to execute when timer expires */ - cb: (...args: any[]) => void, - /** delay in ms */ - delay?: number, - /** arguments passed to callback function */ - ...args: any[] -): number; - -/** Repeatedly calls a function , with a fixed time delay between each call. - * - * ```ts - * // Outputs 'hello' to the console every 500ms - * setInterval(() => { console.log('hello'); }, 500); - * ``` - * - * @category Timers - */ -declare function setInterval( - /** callback function to execute when timer expires */ - cb: (...args: any[]) => void, - /** delay in ms */ - delay?: number, - /** arguments passed to callback function */ - ...args: any[] -): number; - -/** Cancels a timed, repeating action which was previously started by a call - * to `setInterval()` - * - * ```ts - * const id = setInterval(() => {console.log('hello');}, 500); - * // ... - * clearInterval(id); - * ``` - * - * @category Timers - */ -declare function clearInterval(id?: number): void; - -/** Cancels a scheduled action initiated by `setTimeout()` - * - * ```ts - * const id = setTimeout(() => {console.log('hello');}, 500); - * // ... - * clearTimeout(id); - * ``` - * - * @category Timers - */ -declare function clearTimeout(id?: number): void; - -/** @category Scheduling */ -interface VoidFunction { - (): void; -} - -/** A microtask is a short function which is executed after the function or - * module which created it exits and only if the JavaScript execution stack is - * empty, but before returning control to the event loop being used to drive the - * script's execution environment. This event loop may be either the main event - * loop or the event loop driving a web worker. - * - * ```ts - * queueMicrotask(() => { console.log('This event loop stack is complete'); }); - * ``` - * - * @category Scheduling - */ -declare function queueMicrotask(func: VoidFunction): void; - -/** Dispatches an event in the global scope, synchronously invoking any - * registered event listeners for this event in the appropriate order. Returns - * false if event is cancelable and at least one of the event handlers which - * handled this event called Event.preventDefault(). Otherwise it returns true. - * - * ```ts - * dispatchEvent(new Event('unload')); - * ``` - * - * @category DOM Events - */ -declare function dispatchEvent(event: Event): boolean; - -/** @category DOM APIs */ -interface DOMStringList { - /** Returns the number of strings in strings. */ - readonly length: number; - /** Returns true if strings contains string, and false otherwise. */ - contains(string: string): boolean; - /** Returns the string with index index from strings. */ - item(index: number): string | null; - [index: number]: string; -} - -/** @category Typed Arrays */ -type BufferSource = ArrayBufferView | ArrayBuffer; - -/** @category Console and Debugging */ -declare var console: Console; - -/** @category DOM Events */ -interface ErrorEventInit extends EventInit { - message?: string; - filename?: string; - lineno?: number; - colno?: number; - error?: any; -} - -/** @category DOM Events */ -declare class ErrorEvent extends Event { - readonly message: string; - readonly filename: string; - readonly lineno: number; - readonly colno: number; - readonly error: any; - constructor(type: string, eventInitDict?: ErrorEventInit); -} - -/** @category Observability */ -interface PromiseRejectionEventInit extends EventInit { - promise: Promise; - reason?: any; -} - -/** @category Observability */ -declare class PromiseRejectionEvent extends Event { - readonly promise: Promise; - readonly reason: any; - constructor(type: string, eventInitDict?: PromiseRejectionEventInit); -} - -/** @category Web Workers */ -interface AbstractWorkerEventMap { - "error": ErrorEvent; -} - -/** @category Web Workers */ -interface WorkerEventMap extends AbstractWorkerEventMap { - "message": MessageEvent; - "messageerror": MessageEvent; -} - -/** @category Web Workers */ -interface WorkerOptions { - type?: "classic" | "module"; - name?: string; -} - -/** @category Web Workers */ -declare class Worker extends EventTarget { - onerror?: (e: ErrorEvent) => void; - onmessage?: (e: MessageEvent) => void; - onmessageerror?: (e: MessageEvent) => void; - constructor( - specifier: string | URL, - options?: WorkerOptions, - ); - postMessage(message: any, transfer: Transferable[]): void; - postMessage(message: any, options?: StructuredSerializeOptions): void; - addEventListener( - type: K, - listener: (this: Worker, ev: WorkerEventMap[K]) => any, - options?: boolean | AddEventListenerOptions, - ): void; - addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | AddEventListenerOptions, - ): void; - removeEventListener( - type: K, - listener: (this: Worker, ev: WorkerEventMap[K]) => any, - options?: boolean | EventListenerOptions, - ): void; - removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | EventListenerOptions, - ): void; - terminate(): void; -} - -/** @category Performance */ -declare type PerformanceEntryList = PerformanceEntry[]; - -/** @category Performance */ -declare class Performance extends EventTarget { - /** Returns a timestamp representing the start of the performance measurement. */ - readonly timeOrigin: number; - constructor(); - - /** Removes the stored timestamp with the associated name. */ - clearMarks(markName?: string): void; - - /** Removes stored timestamp with the associated name. */ - clearMeasures(measureName?: string): void; - - getEntries(): PerformanceEntryList; - getEntriesByName(name: string, type?: string): PerformanceEntryList; - getEntriesByType(type: string): PerformanceEntryList; - - /** Stores a timestamp with the associated name (a "mark"). */ - mark(markName: string, options?: PerformanceMarkOptions): PerformanceMark; - - /** Stores the `DOMHighResTimeStamp` duration between two marks along with the - * associated name (a "measure"). */ - measure( - measureName: string, - options?: PerformanceMeasureOptions, - ): PerformanceMeasure; - /** Stores the `DOMHighResTimeStamp` duration between two marks along with the - * associated name (a "measure"). */ - measure( - measureName: string, - startMark?: string, - endMark?: string, - ): PerformanceMeasure; - - /** Returns a current time from Deno's start in milliseconds. - * - * Use the permission flag `--allow-hrtime` return a precise value. - * - * ```ts - * const t = performance.now(); - * console.log(`${t} ms since start!`); - * ``` - * - * @tags allow-hrtime - */ - now(): number; - - /** Returns a JSON representation of the performance object. */ - toJSON(): any; -} - -/** @category Performance */ -declare var performance: Performance; - -/** @category Performance */ -declare interface PerformanceMarkOptions { - /** Metadata to be included in the mark. */ - detail?: any; - - /** Timestamp to be used as the mark time. */ - startTime?: number; -} - -declare interface PerformanceMeasureOptions { - /** Metadata to be included in the measure. */ - detail?: any; - - /** Timestamp to be used as the start time or string to be used as start - * mark. */ - start?: string | number; - - /** Duration between the start and end times. */ - duration?: number; - - /** Timestamp to be used as the end time or string to be used as end mark. */ - end?: string | number; -} - -/** Encapsulates a single performance metric that is part of the performance - * timeline. A performance entry can be directly created by making a performance - * mark or measure (for example by calling the `.mark()` method) at an explicit - * point in an application. - * - * @category Performance - */ -declare class PerformanceEntry { - readonly duration: number; - readonly entryType: string; - readonly name: string; - readonly startTime: number; - toJSON(): any; -} - -/** `PerformanceMark` is an abstract interface for `PerformanceEntry` objects - * with an entryType of `"mark"`. Entries of this type are created by calling - * `performance.mark()` to add a named `DOMHighResTimeStamp` (the mark) to the - * performance timeline. - * - * @category Performance - */ -declare class PerformanceMark extends PerformanceEntry { - readonly detail: any; - readonly entryType: "mark"; - constructor(name: string, options?: PerformanceMarkOptions); -} - -/** `PerformanceMeasure` is an abstract interface for `PerformanceEntry` objects - * with an entryType of `"measure"`. Entries of this type are created by calling - * `performance.measure()` to add a named `DOMHighResTimeStamp` (the measure) - * between two marks to the performance timeline. - * - * @category Performance - */ -declare class PerformanceMeasure extends PerformanceEntry { - readonly detail: any; - readonly entryType: "measure"; -} - -/** @category DOM Events */ -declare interface CustomEventInit extends EventInit { - detail?: T; -} - -/** @category DOM Events */ -declare class CustomEvent extends Event { - constructor(typeArg: string, eventInitDict?: CustomEventInit); - /** Returns any custom data event was created with. Typically used for - * synthetic events. */ - readonly detail: T; -} - -/** @category DOM APIs */ -interface ErrorConstructor { - /** See https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions. */ - captureStackTrace(error: Object, constructor?: Function): void; - // TODO(nayeemrmn): Support `Error.prepareStackTrace()`. We currently use this - // internally in a way that makes it unavailable for users. -} diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts deleted file mode 100644 index eaa40abc5..000000000 --- a/cli/dts/lib.deno.unstable.d.ts +++ /dev/null @@ -1,1911 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. - -/// -/// - -declare namespace Deno { - export {}; // stop default export type behavior - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Retrieve the process umask. If `mask` is provided, sets the process umask. - * This call always returns what the umask was before the call. - * - * ```ts - * console.log(Deno.umask()); // e.g. 18 (0o022) - * const prevUmaskValue = Deno.umask(0o077); // e.g. 18 (0o022) - * console.log(Deno.umask()); // e.g. 63 (0o077) - * ``` - * - * This API is under consideration to determine if permissions are required to - * call it. - * - * *Note*: This API is not implemented on Windows - * - * @category File System - */ - export function umask(mask?: number): number; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * All plain number types for interfacing with foreign functions. - * - * @category FFI - */ - type NativeNumberType = - | "u8" - | "i8" - | "u16" - | "i16" - | "u32" - | "i32" - | "f32" - | "f64"; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * All BigInt number types for interfacing with foreign functions. - * - * @category FFI - */ - type NativeBigIntType = - | "u64" - | "i64" - | "usize" - | "isize"; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * The native boolean type for interfacing to foreign functions. - * - * @category FFI - */ - type NativeBooleanType = "bool"; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * The native pointer type for interfacing to foreign functions. - * - * @category FFI - */ - type NativePointerType = "pointer"; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * The native buffer type for interfacing to foreign functions. - * - * @category FFI - */ - type NativeBufferType = "buffer"; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * The native function type for interfacing with foreign functions. - * - * @category FFI - */ - type NativeFunctionType = "function"; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * The native void type for interfacing with foreign functions. - * - * @category FFI - */ - type NativeVoidType = "void"; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * All supported types for interfacing with foreign functions. - * - * @category FFI - */ - export type NativeType = - | NativeNumberType - | NativeBigIntType - | NativeBooleanType - | NativePointerType - | NativeBufferType - | NativeFunctionType; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category FFI - */ - export type NativeResultType = NativeType | NativeVoidType; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A utility type conversion for foreign symbol parameters and unsafe callback - * return types. - * - * @category FFI - */ - type ToNativeTypeMap = - & Record - & Record - & Record - & Record - & Record - & Record; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Type conversion for foreign symbol parameters and unsafe callback return - * types. - * - * @category FFI - */ - type ToNativeType = ToNativeTypeMap[T]; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A utility type for conversion for unsafe callback return types. - * - * @category FFI - */ - type ToNativeResultTypeMap = ToNativeTypeMap & Record; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Type conversion for unsafe callback return types. - * - * @category FFI - */ - type ToNativeResultType = - ToNativeResultTypeMap[T]; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A utility type for conversion of parameter types of foreign functions. - * - * @category FFI - */ - type ToNativeParameterTypes = - // - [(T[number])[]] extends [T] ? ToNativeType[] - : [readonly (T[number])[]] extends [T] - ? readonly ToNativeType[] - : T extends readonly [...NativeType[]] ? { - [K in keyof T]: ToNativeType; - } - : never; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A utility type for conversion of foreign symbol return types and unsafe - * callback parameters. - * - * @category FFI - */ - type FromNativeTypeMap = - & Record - & Record - & Record - & Record - & Record - & Record; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Type conversion for foreign symbol return types and unsafe callback - * parameters. - * - * @category FFI - */ - type FromNativeType = FromNativeTypeMap[T]; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A utility type for conversion for foreign symbol return types. - * - * @category FFI - */ - type FromNativeResultTypeMap = - & FromNativeTypeMap - & Record; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Type conversion for foreign symbol return types. - * - * @category FFI - */ - type FromNativeResultType = - FromNativeResultTypeMap[T]; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category FFI - */ - type FromNativeParameterTypes< - T extends readonly NativeType[], - > = - // - [(T[number])[]] extends [T] ? FromNativeType[] - : [readonly (T[number])[]] extends [T] - ? readonly FromNativeType[] - : T extends readonly [...NativeType[]] ? { - [K in keyof T]: FromNativeType; - } - : never; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * The interface for a foreign function as defined by its parameter and result - * types. - * - * @category FFI - */ - export interface ForeignFunction< - Parameters extends readonly NativeType[] = readonly NativeType[], - Result extends NativeResultType = NativeResultType, - NonBlocking extends boolean = boolean, - > { - /** Name of the symbol. - * - * Defaults to the key name in symbols object. */ - name?: string; - /** The parameters of the foreign function. */ - parameters: Parameters; - /** The result (return value) of the foreign function. */ - result: Result; - /** When `true`, function calls will run on a dedicated blocking thread and - * will return a `Promise` resolving to the `result`. */ - nonblocking?: NonBlocking; - /** When `true`, function calls can safely callback into JavaScript or - * trigger a garbage collection event. - * - * Default is `false`. */ - callback?: boolean; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category FFI - */ - export interface ForeignStatic { - /** Name of the symbol, defaults to the key name in symbols object. */ - name?: string; - /** The type of the foreign static value. */ - type: Type; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A foreign library interface descriptor. - * - * @category FFI - */ - export interface ForeignLibraryInterface { - [name: string]: ForeignFunction | ForeignStatic; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A utility type that infers a foreign symbol. - * - * @category FFI - */ - type StaticForeignSymbol = - T extends ForeignFunction ? FromForeignFunction - : T extends ForeignStatic ? FromNativeType - : never; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category FFI - */ - type FromForeignFunction = T["parameters"] extends - readonly [] ? () => StaticForeignSymbolReturnType - : ( - ...args: ToNativeParameterTypes - ) => StaticForeignSymbolReturnType; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category FFI - */ - type StaticForeignSymbolReturnType = - ConditionalAsync>; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category FFI - */ - type ConditionalAsync = - IsAsync extends true ? Promise : T; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A utility type that infers a foreign library interface. - * - * @category FFI - */ - type StaticForeignLibraryInterface = { - [K in keyof T]: StaticForeignSymbol; - }; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Pointer type depends on the architecture and actual pointer value. - * - * On a 32 bit host system all pointer values are plain numbers. On a 64 bit - * host system pointer values are represented as numbers if the value is below - * `Number.MAX_SAFE_INTEGER`, otherwise they are provided as bigints. - * - * @category FFI - */ - export type PointerValue = number | bigint; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * An unsafe pointer to a memory location for passing and returning pointers - * to and from the FFI. - * - * @category FFI - */ - export class UnsafePointer { - /** Return the direct memory pointer to the typed array in memory. */ - static of(value: Deno.UnsafeCallback | BufferSource): PointerValue; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * An unsafe pointer view to a memory location as specified by the `pointer` - * value. The `UnsafePointerView` API follows the standard built in interface - * {@linkcode DataView} for accessing the underlying types at an memory - * location (numbers, strings and raw bytes). - * - * @category FFI - */ - export class UnsafePointerView { - constructor(pointer: PointerValue); - - pointer: PointerValue; - - /** Gets a boolean at the specified byte offset from the pointer. */ - getBool(offset?: number): boolean; - /** Gets an unsigned 8-bit integer at the specified byte offset from the - * pointer. */ - getUint8(offset?: number): number; - /** Gets a signed 8-bit integer at the specified byte offset from the - * pointer. */ - getInt8(offset?: number): number; - /** Gets an unsigned 16-bit integer at the specified byte offset from the - * pointer. */ - getUint16(offset?: number): number; - /** Gets a signed 16-bit integer at the specified byte offset from the - * pointer. */ - getInt16(offset?: number): number; - /** Gets an unsigned 32-bit integer at the specified byte offset from the - * pointer. */ - getUint32(offset?: number): number; - /** Gets a signed 32-bit integer at the specified byte offset from the - * pointer. */ - getInt32(offset?: number): number; - /** Gets an unsigned 64-bit integer at the specified byte offset from the - * pointer. */ - getBigUint64(offset?: number): PointerValue; - /** Gets a signed 64-bit integer at the specified byte offset from the - * pointer. */ - getBigInt64(offset?: number): PointerValue; - /** Gets a signed 32-bit float at the specified byte offset from the - * pointer. */ - getFloat32(offset?: number): number; - /** Gets a signed 64-bit float at the specified byte offset from the - * pointer. */ - getFloat64(offset?: number): number; - /** Gets a C string (`null` terminated string) at the specified byte offset - * from the pointer. */ - getCString(offset?: number): string; - /** Gets a C string (`null` terminated string) at the specified byte offset - * from the specified pointer. */ - static getCString(pointer: PointerValue, offset?: number): string; - /** Gets an `ArrayBuffer` of length `byteLength` at the specified byte - * offset from the pointer. */ - getArrayBuffer(byteLength: number, offset?: number): ArrayBuffer; - /** Gets an `ArrayBuffer` of length `byteLength` at the specified byte - * offset from the specified pointer. */ - static getArrayBuffer( - pointer: PointerValue, - byteLength: number, - offset?: number, - ): ArrayBuffer; - /** Copies the memory of the pointer into a typed array. - * - * Length is determined from the typed array's `byteLength`. - * - * Also takes optional byte offset from the pointer. */ - copyInto(destination: BufferSource, offset?: number): void; - /** Copies the memory of the specified pointer into a typed array. - * - * Length is determined from the typed array's `byteLength`. - * - * Also takes optional byte offset from the pointer. */ - static copyInto( - pointer: PointerValue, - destination: BufferSource, - offset?: number, - ): void; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * An unsafe pointer to a function, for calling functions that are not present - * as symbols. - * - * @category FFI - */ - export class UnsafeFnPointer { - /** The pointer to the function. */ - pointer: PointerValue; - /** The definition of the function. */ - definition: Fn; - - constructor(pointer: PointerValue, definition: Fn); - - /** Call the foreign function. */ - call: FromForeignFunction; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Definition of a unsafe callback function. - * - * @category FFI - */ - export interface UnsafeCallbackDefinition< - Parameters extends readonly NativeType[] = readonly NativeType[], - Result extends NativeResultType = NativeResultType, - > { - /** The parameters of the callbacks. */ - parameters: Parameters; - /** The current result of the callback. */ - result: Result; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * An unsafe callback function. - * - * @category FFI - */ - type UnsafeCallbackFunction< - Parameters extends readonly NativeType[] = readonly NativeType[], - Result extends NativeResultType = NativeResultType, - > = Parameters extends readonly [] ? () => ToNativeResultType : ( - ...args: FromNativeParameterTypes - ) => ToNativeResultType; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * An unsafe function pointer for passing JavaScript functions as C function - * pointers to foreign function calls. - * - * The function pointer remains valid until the `close()` method is called. - * - * The callback can be explicitly referenced via `ref()` and dereferenced via - * `deref()` to stop Deno's process from exiting. - * - * @category FFI - */ - export class UnsafeCallback< - Definition extends UnsafeCallbackDefinition = UnsafeCallbackDefinition, - > { - constructor( - definition: Definition, - callback: UnsafeCallbackFunction< - Definition["parameters"], - Definition["result"] - >, - ); - - /** The pointer to the unsafe callback. */ - pointer: PointerValue; - /** The definition of the unsafe callback. */ - definition: Definition; - /** The callback function. */ - callback: UnsafeCallbackFunction< - Definition["parameters"], - Definition["result"] - >; - - /** - * Adds one to this callback's reference counting and returns the new - * reference count. - * - * If the callback's reference count is non-zero, it will keep Deno's - * process from exiting. - */ - ref(): number; - - /** - * Removes one from this callback's reference counting and returns the new - * reference count. - * - * If the callback's reference counter is zero, it will no longer keep - * Deno's process from exiting. - */ - unref(): number; - - /** - * Removes the C function pointer associated with this instance. - * - * Continuing to use the instance after calling this object will lead to - * errors and crashes. - * - * Calling this method will also immediately set the callback's reference - * counting to zero and it will no longer keep Deno's process from exiting. - */ - close(): void; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A dynamic library resource. Use {@linkcode Deno.dlopen} to load a dynamic - * library and return this interface. - * - * @category FFI - */ - export interface DynamicLibrary { - /** All of the registered library along with functions for calling them. */ - symbols: StaticForeignLibraryInterface; - /** Removes the pointers associated with the library symbols. - * - * Continuing to use symbols that are part of the library will lead to - * errors and crashes. - * - * Calling this method will also immediately set any references to zero and - * will no longer keep Deno's process from exiting. - */ - close(): void; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Opens an external dynamic library and registers symbols, making foreign - * functions available to be called. - * - * Requires `allow-ffi` permission. Loading foreign dynamic libraries can in - * theory bypass all of the sandbox permissions. While it is a separate - * permission users should acknowledge in practice that is effectively the - * same as running with the `allow-all` permission. - * - * An example, given a C library which exports a foreign function named - * `add()`: - * - * ```ts - * // Determine library extension based on - * // your OS. - * let libSuffix = ""; - * switch (Deno.build.os) { - * case "windows": - * libSuffix = "dll"; - * break; - * case "darwin": - * libSuffix = "dylib"; - * break; - * default: - * libSuffix = "so"; - * break; - * } - * - * const libName = `./libadd.${libSuffix}`; - * // Open library and define exported symbols - * const dylib = Deno.dlopen( - * libName, - * { - * "add": { parameters: ["isize", "isize"], result: "isize" }, - * } as const, - * ); - * - * // Call the symbol `add` - * const result = dylib.symbols.add(35, 34); // 69 - * - * console.log(`Result from external addition of 35 and 34: ${result}`); - * ``` - * - * @tags allow-ffi - * @category FFI - */ - export function dlopen( - filename: string | URL, - symbols: S, - ): DynamicLibrary; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * These are unstable options which can be used with {@linkcode Deno.run}. - * - * @category Sub Process - */ - interface UnstableRunOptions extends RunOptions { - /** If `true`, clears the environment variables before executing the - * sub-process. Defaults to `false`. */ - clearEnv?: boolean; - /** For POSIX systems, sets the group ID for the sub process. */ - gid?: number; - /** For POSIX systems, sets the user ID for the sub process. */ - uid?: number; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Spawns new subprocess. RunOptions must contain at a minimum the `opt.cmd`, - * an array of program arguments, the first of which is the binary. - * - * ```ts - * const p = Deno.run({ - * cmd: ["curl", "https://example.com"], - * }); - * const status = await p.status(); - * ``` - * - * Subprocess uses same working directory as parent process unless `opt.cwd` - * is specified. - * - * Environmental variables from parent process can be cleared using `opt.clearEnv`. - * Doesn't guarantee that only `opt.env` variables are present, - * as the OS may set environmental variables for processes. - * - * Environmental variables for subprocess can be specified using `opt.env` - * mapping. - * - * `opt.uid` sets the child process’s user ID. This translates to a setuid call - * in the child process. Failure in the setuid call will cause the spawn to fail. - * - * `opt.gid` is similar to `opt.uid`, but sets the group ID of the child process. - * This has the same semantics as the uid field. - * - * By default subprocess inherits stdio of parent process. To change - * this this, `opt.stdin`, `opt.stdout`, and `opt.stderr` can be set - * independently to a resource ID (_rid_) of an open file, `"inherit"`, - * `"piped"`, or `"null"`: - * - * - _number_: the resource ID of an open file/resource. This allows you to - * read or write to a file. - * - `"inherit"`: The default if unspecified. The subprocess inherits from the - * parent. - * - `"piped"`: A new pipe should be arranged to connect the parent and child - * sub-process. - * - `"null"`: This stream will be ignored. This is the equivalent of attaching - * the stream to `/dev/null`. - * - * Details of the spawned process are returned as an instance of - * {@linkcode Deno.Process}. - * - * Requires `allow-run` permission. - * - * @tags allow-run - * @category Sub Process - */ - export function run( - opt: T, - ): Process; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A custom `HttpClient` for use with {@linkcode fetch} function. This is - * designed to allow custom certificates or proxies to be used with `fetch()`. - * - * ```ts - * const caCert = await Deno.readTextFile("./ca.pem"); - * const client = Deno.createHttpClient({ caCerts: [ caCert ] }); - * const req = await fetch("https://myserver.com", { client }); - * ``` - * - * @category Fetch API - */ - export interface HttpClient { - /** The resource ID associated with the client. */ - rid: number; - /** Close the HTTP client. */ - close(): void; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * The options used when creating a {@linkcode Deno.HttpClient}. - * - * @category Fetch API - */ - export interface CreateHttpClientOptions { - /** A list of root certificates that will be used in addition to the - * default root certificates to verify the peer's certificate. - * - * Must be in PEM format. */ - caCerts?: string[]; - /** A HTTP proxy to use for new connections. */ - proxy?: Proxy; - /** PEM formatted client certificate chain. */ - certChain?: string; - /** PEM formatted (RSA or PKCS8) private key of client certificate. */ - privateKey?: string; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * The definition of a proxy when specifying - * {@linkcode Deno.CreateHttpClientOptions}. - * - * @category Fetch API - */ - export interface Proxy { - /** The string URL of the proxy server to use. */ - url: string; - /** The basic auth credentials to be used against the proxy server. */ - basicAuth?: BasicAuth; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Basic authentication credentials to be used with a {@linkcode Deno.Proxy} - * server when specifying {@linkcode Deno.CreateHttpClientOptions}. - * - * @category Fetch API - */ - export interface BasicAuth { - /** The username to be used against the proxy server. */ - username: string; - /** The password to be used against the proxy server. */ - password: string; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Create a custom HttpClient for to use with {@linkcode fetch}. This is an - * extension of the web platform Fetch API which allows Deno to use custom - * TLS certificates and connect via a proxy while using `fetch()`. - * - * ```ts - * const caCert = await Deno.readTextFile("./ca.pem"); - * const client = Deno.createHttpClient({ caCerts: [ caCert ] }); - * const response = await fetch("https://myserver.com", { client }); - * ``` - * - * ```ts - * const client = Deno.createHttpClient({ - * proxy: { url: "http://myproxy.com:8080" } - * }); - * const response = await fetch("https://myserver.com", { client }); - * ``` - * - * @category Fetch API - */ - export function createHttpClient( - options: CreateHttpClientOptions, - ): HttpClient; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A generic transport listener for message-oriented protocols. - * - * @category Network - */ - export interface DatagramConn extends AsyncIterable<[Uint8Array, Addr]> { - /** Waits for and resolves to the next message to the instance. - * - * Messages are received in the format of a tuple containing the data array - * and the address information. - */ - receive(p?: Uint8Array): Promise<[Uint8Array, Addr]>; - /** Sends a message to the target via the connection. The method resolves - * with the number of bytes sent. */ - send(p: Uint8Array, addr: Addr): Promise; - /** Close closes the socket. Any pending message promises will be rejected - * with errors. */ - close(): void; - /** Return the address of the instance. */ - readonly addr: Addr; - [Symbol.asyncIterator](): AsyncIterableIterator<[Uint8Array, Addr]>; - } - - /** - * @category Network - */ - export interface TcpListenOptions extends ListenOptions { - /** When `true` the SO_REUSEPORT flag will be set on the listener. This - * allows multiple processes to listen on the same address and port. - * - * On Linux this will cause the kernel to distribute incoming connections - * across the different processes that are listening on the same address and - * port. - * - * This flag is only supported on Linux. It is silently ignored on other - * platforms. Defaults to `false`. */ - reusePort?: boolean; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Unstable options which can be set when opening a Unix listener via - * {@linkcode Deno.listen} or {@linkcode Deno.listenDatagram}. - * - * @category Network - */ - export interface UnixListenOptions { - /** A path to the Unix Socket. */ - path: string; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Unstable options which can be set when opening a datagram listener via - * {@linkcode Deno.listenDatagram}. - * - * @category Network - */ - export interface UdpListenOptions extends ListenOptions { - /** When `true` the specified address will be reused, even if another - * process has already bound a socket on it. This effectively steals the - * socket from the listener. - * - * Defaults to `false`. */ - reuseAddress?: boolean; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Listen announces on the local transport address. - * - * ```ts - * const listener = Deno.listen({ path: "/foo/bar.sock", transport: "unix" }) - * ``` - * - * Requires `allow-read` and `allow-write` permission. - * - * @tags allow-read, allow-write - * @category Network - */ - export function listen( - options: UnixListenOptions & { transport: "unix" }, - ): Listener; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Listen announces on the local transport address. - * - * ```ts - * const listener1 = Deno.listenDatagram({ - * port: 80, - * transport: "udp" - * }); - * const listener2 = Deno.listenDatagram({ - * hostname: "golang.org", - * port: 80, - * transport: "udp" - * }); - * ``` - * - * Requires `allow-net` permission. - * - * @tags allow-net - * @category Network - */ - export function listenDatagram( - options: UdpListenOptions & { transport: "udp" }, - ): DatagramConn; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Listen announces on the local transport address. - * - * ```ts - * const listener = Deno.listenDatagram({ - * path: "/foo/bar.sock", - * transport: "unixpacket" - * }); - * ``` - * - * Requires `allow-read` and `allow-write` permission. - * - * @tags allow-read, allow-write - * @category Network - */ - export function listenDatagram( - options: UnixListenOptions & { transport: "unixpacket" }, - ): DatagramConn; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category Network - */ - export interface UnixConnectOptions { - transport: "unix"; - path: string; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Connects to the hostname (default is "127.0.0.1") and port on the named - * transport (default is "tcp"), and resolves to the connection (`Conn`). - * - * ```ts - * const conn1 = await Deno.connect({ port: 80 }); - * const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 }); - * const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 }); - * const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" }); - * const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" }); - * ``` - * - * Requires `allow-net` permission for "tcp" and `allow-read` for "unix". - * - * @tags allow-net, allow-read - * @category Network - */ - export function connect(options: ConnectOptions): Promise; - /** **UNSTABLE**: New API, yet to be vetted. - * - * Connects to the hostname (default is "127.0.0.1") and port on the named - * transport (default is "tcp"), and resolves to the connection (`Conn`). - * - * ```ts - * const conn1 = await Deno.connect({ port: 80 }); - * const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 }); - * const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 }); - * const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" }); - * const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" }); - * ``` - * - * Requires `allow-net` permission for "tcp" and `allow-read` for "unix". - * - * @tags allow-net, allow-read - * @category Network - */ - export function connect(options: UnixConnectOptions): Promise; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category Network - */ - export interface ConnectTlsOptions { - /** **UNSTABLE**: New API, yet to be vetted. - * - * PEM formatted client certificate chain. - */ - certChain?: string; - /** **UNSTABLE**: New API, yet to be vetted. - * - * PEM formatted (RSA or PKCS8) private key of client certificate. - */ - privateKey?: string; - /** **UNSTABLE**: New API, yet to be vetted. - * - * Application-Layer Protocol Negotiation (ALPN) protocols supported by - * the client. If not specified, no ALPN extension will be included in the - * TLS handshake. - */ - alpnProtocols?: string[]; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category Network - */ - export interface TlsHandshakeInfo { - /** **UNSTABLE**: New API, yet to be vetted. - * - * Contains the ALPN protocol selected during negotiation with the server. - * If no ALPN protocol selected, returns `null`. - */ - alpnProtocol: string | null; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category Network - */ - export interface TlsConn extends Conn { - /** **UNSTABLE**: New API, yet to be vetted. - * - * Runs the client or server handshake protocol to completion if that has - * not happened yet. Calling this method is optional; the TLS handshake - * will be completed automatically as soon as data is sent or received. - */ - handshake(): Promise; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Create a TLS connection with an attached client certificate. - * - * ```ts - * const conn = await Deno.connectTls({ - * hostname: "deno.land", - * port: 443, - * certChain: "---- BEGIN CERTIFICATE ----\n ...", - * privateKey: "---- BEGIN PRIVATE KEY ----\n ...", - * }); - * ``` - * - * Requires `allow-net` permission. - * - * @tags allow-net - * @category Network - */ - export function connectTls(options: ConnectTlsOptions): Promise; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category Network - */ - export interface ListenTlsOptions { - /** **UNSTABLE**: New API, yet to be vetted. - * - * Application-Layer Protocol Negotiation (ALPN) protocols to announce to - * the client. If not specified, no ALPN extension will be included in the - * TLS handshake. - */ - alpnProtocols?: string[]; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category Network - */ - export interface StartTlsOptions { - /** **UNSTABLE**: New API, yet to be vetted. - * - * Application-Layer Protocol Negotiation (ALPN) protocols to announce to - * the client. If not specified, no ALPN extension will be included in the - * TLS handshake. - */ - alpnProtocols?: string[]; - } - - /** @category Network */ - export interface Listener extends AsyncIterable { - /** **UNSTABLE**: New API, yet to be vetted. - * - * Make the listener block the event loop from finishing. - * - * Note: the listener blocks the event loop from finishing by default. - * This method is only meaningful after `.unref()` is called. - */ - ref(): void; - /** **UNSTABLE**: New API, yet to be vetted. - * - * Make the listener not block the event loop from finishing. - */ - unref(): void; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Acquire an advisory file-system lock for the provided file. `exclusive` - * defaults to `false`. - * - * @category File System - */ - export function flock(rid: number, exclusive?: boolean): Promise; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Acquire an advisory file-system lock synchronously for the provided file. - * `exclusive` defaults to `false`. - * - * @category File System - */ - export function flockSync(rid: number, exclusive?: boolean): void; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Release an advisory file-system lock for the provided file. - * - * @category File System - */ - export function funlock(rid: number): Promise; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Release an advisory file-system lock for the provided file synchronously. - * - * @category File System - */ - export function funlockSync(rid: number): void; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * A handler for HTTP requests. Consumes a request and returns a response. - * - * If a handler throws, the server calling the handler will assume the impact - * of the error is isolated to the individual request. It will catch the error - * and if necessary will close the underlying connection. - * - * @category HTTP Server - */ - export type ServeHandler = (request: Request) => Response | Promise; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Options which can be set when calling {@linkcode Deno.serve}. - * - * @category HTTP Server - */ - export interface ServeOptions extends Partial { - /** An {@linkcode AbortSignal} to close the server and all connections. */ - signal?: AbortSignal; - - /** Sets `SO_REUSEPORT` on POSIX systems. */ - reusePort?: boolean; - - /** The handler to invoke when route handlers throw an error. */ - onError?: (error: unknown) => Response | Promise; - - /** The callback which is called when the server starts listening. */ - onListen?: (params: { hostname: string; port: number }) => void; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Additional options which are used when opening a TLS (HTTPS) server. - * - * @category HTTP Server - */ - export interface ServeTlsOptions extends ServeOptions { - /** Server private key in PEM format */ - cert: string; - - /** Cert chain in PEM format */ - key: string; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category HTTP Server - */ - export interface ServeInit { - /** The handler to invoke to process each incoming request. */ - handler: ServeHandler; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Serves HTTP requests with the given handler. - * - * You can specify an object with a port and hostname option, which is the - * address to listen on. The default is port `9000` on hostname `"127.0.0.1"`. - * - * The below example serves with the port `9000`. - * - * ```ts - * Deno.serve((_req) => new Response("Hello, world")); - * ``` - * - * You can change the address to listen on using the `hostname` and `port` - * options. The below example serves on port `3000`. - * - * ```ts - * Deno.serve({ port: 3000 }, (_req) => new Response("Hello, world")); - * ``` - * - * You can stop the server with an {@linkcode AbortSignal}. The abort signal - * needs to be passed as the `signal` option in the options bag. The server - * aborts when the abort signal is aborted. To wait for the server to close, - * await the promise returned from the `Deno.serve` API. - * - * ```ts - * const ac = new AbortController(); - * - * Deno.serve({ signal: ac.signal }, (_req) => new Response("Hello, world")) - * .then(() => console.log("Server closed")); - * - * console.log("Closing server..."); - * ac.abort(); - * ``` - * - * By default `Deno.serve` prints the message - * `Listening on http://:/` on listening. If you like to - * change this behavior, you can specify a custom `onListen` callback. - * - * ```ts - * Deno.serve({ - * onListen({ port, hostname }) { - * console.log(`Server started at http://${hostname}:${port}`); - * // ... more info specific to your server .. - * }, - * handler: (_req) => new Response("Hello, world"), - * }); - * ``` - * - * To enable TLS you must specify the `key` and `cert` options. - * - * ```ts - * const cert = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n"; - * const key = "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"; - * Deno.serve({ cert, key }, (_req) => new Response("Hello, world")); - * ``` - * - * @category HTTP Server - */ - export function serve( - handler: ServeHandler, - options?: ServeOptions | ServeTlsOptions, - ): Promise; - /** **UNSTABLE**: New API, yet to be vetted. - * - * Serves HTTP requests with the given handler. - * - * You can specify an object with a port and hostname option, which is the - * address to listen on. The default is port `9000` on hostname `"127.0.0.1"`. - * - * The below example serves with the port `9000`. - * - * ```ts - * Deno.serve((_req) => new Response("Hello, world")); - * ``` - * - * You can change the address to listen on using the `hostname` and `port` - * options. The below example serves on port `3000`. - * - * ```ts - * Deno.serve({ port: 3000 }, (_req) => new Response("Hello, world")); - * ``` - * - * You can stop the server with an {@linkcode AbortSignal}. The abort signal - * needs to be passed as the `signal` option in the options bag. The server - * aborts when the abort signal is aborted. To wait for the server to close, - * await the promise returned from the `Deno.serve` API. - * - * ```ts - * const ac = new AbortController(); - * - * Deno.serve({ signal: ac.signal }, (_req) => new Response("Hello, world")) - * .then(() => console.log("Server closed")); - * - * console.log("Closing server..."); - * ac.abort(); - * ``` - * - * By default `Deno.serve` prints the message - * `Listening on http://:/` on listening. If you like to - * change this behavior, you can specify a custom `onListen` callback. - * - * ```ts - * Deno.serve({ - * onListen({ port, hostname }) { - * console.log(`Server started at http://${hostname}:${port}`); - * // ... more info specific to your server .. - * }, - * handler: (_req) => new Response("Hello, world"), - * }); - * ``` - * - * To enable TLS you must specify the `key` and `cert` options. - * - * ```ts - * const cert = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n"; - * const key = "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"; - * Deno.serve({ cert, key }, (_req) => new Response("Hello, world")); - * ``` - * - * @category HTTP Server - */ - export function serve( - options: ServeOptions | ServeTlsOptions, - handler: ServeHandler, - ): Promise; - /** **UNSTABLE**: New API, yet to be vetted. - * - * Serves HTTP requests with the given handler. - * - * You can specify an object with a port and hostname option, which is the - * address to listen on. The default is port `9000` on hostname `"127.0.0.1"`. - * - * The below example serves with the port `9000`. - * - * ```ts - * Deno.serve((_req) => new Response("Hello, world")); - * ``` - * - * You can change the address to listen on using the `hostname` and `port` - * options. The below example serves on port `3000`. - * - * ```ts - * Deno.serve({ port: 3000 }, (_req) => new Response("Hello, world")); - * ``` - * - * You can stop the server with an {@linkcode AbortSignal}. The abort signal - * needs to be passed as the `signal` option in the options bag. The server - * aborts when the abort signal is aborted. To wait for the server to close, - * await the promise returned from the `Deno.serve` API. - * - * ```ts - * const ac = new AbortController(); - * - * Deno.serve({ signal: ac.signal }, (_req) => new Response("Hello, world")) - * .then(() => console.log("Server closed")); - * - * console.log("Closing server..."); - * ac.abort(); - * ``` - * - * By default `Deno.serve` prints the message - * `Listening on http://:/` on listening. If you like to - * change this behavior, you can specify a custom `onListen` callback. - * - * ```ts - * Deno.serve({ - * onListen({ port, hostname }) { - * console.log(`Server started at http://${hostname}:${port}`); - * // ... more info specific to your server .. - * }, - * handler: (_req) => new Response("Hello, world"), - * }); - * ``` - * - * To enable TLS you must specify the `key` and `cert` options. - * - * ```ts - * const cert = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n"; - * const key = "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"; - * Deno.serve({ cert, key }, (_req) => new Response("Hello, world")); - * ``` - * - * @category HTTP Server - */ - export function serve( - options: ServeInit & (ServeOptions | ServeTlsOptions), - ): Promise; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Allows "hijacking" the connection that the request is associated with. This - * can be used to implement protocols that build on top of HTTP (eg. - * {@linkcode WebSocket}). - * - * The returned promise returns underlying connection and first packet - * received. The promise shouldn't be awaited before responding to the - * `request`, otherwise event loop might deadlock. - * - * ```ts - * function handler(req: Request): Response { - * Deno.upgradeHttp(req).then(([conn, firstPacket]) => { - * // ... - * }); - * return new Response(null, { status: 101 }); - * } - * ``` - * - * This method can only be called on requests originating the - * {@linkcode Deno.serveHttp} server. - * - * @category HTTP Server - */ - export function upgradeHttp( - request: Request, - ): Promise<[Deno.Conn, Uint8Array]>; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Allows "hijacking" the connection that the request is associated with. - * This can be used to implement protocols that build on top of HTTP (eg. - * {@linkcode WebSocket}). - * - * Unlike {@linkcode Deno.upgradeHttp} this function does not require that you - * respond to the request with a {@linkcode Response} object. Instead this - * function returns the underlying connection and first packet received - * immediately, and then the caller is responsible for writing the response to - * the connection. - * - * This method can only be called on requests originating the - * {@linkcode Deno.serve} server. - * - * @category HTTP Server - */ - export function upgradeHttpRaw(request: Request): [Deno.Conn, Uint8Array]; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @deprecated Use the Deno.Command API instead. - * - * Options which can be set when calling {@linkcode Deno.spawn}, - * {@linkcode Deno.spawnSync}, and {@linkcode Deno.spawnChild}. - * - * @category Sub Process - */ - export interface SpawnOptions { - /** Arguments to pass to the process. */ - args?: string[]; - /** - * The working directory of the process. - * - * If not specified, the `cwd` of the parent process is used. - */ - cwd?: string | URL; - /** - * Clear environmental variables from parent process. - * - * Doesn't guarantee that only `env` variables are present, as the OS may - * set environmental variables for processes. - */ - clearEnv?: boolean; - /** Environmental variables to pass to the subprocess. */ - env?: Record; - /** - * Sets the child process’s user ID. This translates to a setuid call in the - * child process. Failure in the set uid call will cause the spawn to fail. - */ - uid?: number; - /** Similar to `uid`, but sets the group ID of the child process. */ - gid?: number; - /** - * An {@linkcode AbortSignal} that allows closing the process using the - * corresponding {@linkcode AbortController} by sending the process a - * SIGTERM signal. - * - * Not supported in {@linkcode Deno.spawnSync}. - */ - signal?: AbortSignal; - - /** How `stdin` of the spawned process should be handled. - * - * Defaults to `"null"`. */ - stdin?: "piped" | "inherit" | "null"; - /** How `stdout` of the spawned process should be handled. - * - * Defaults to `"piped"`. */ - stdout?: "piped" | "inherit" | "null"; - /** How `stderr` of the spawned process should be handled. - * - * Defaults to "piped". */ - stderr?: "piped" | "inherit" | "null"; - - /** Skips quoting and escaping of the arguments on windows. This option - * is ignored on non-windows platforms. Defaults to `false`. */ - windowsRawArguments?: boolean; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @deprecated Use the Deno.Command API instead. - * - * Spawns a child process. - * - * If any stdio options are not set to `"piped"`, accessing the corresponding - * field on the `Child` or its `SpawnOutput` will throw a `TypeError`. - * - * If `stdin` is set to `"piped"`, the `stdin` {@linkcode WritableStream} - * needs to be closed manually. - * - * ```ts - * const child = Deno.spawnChild(Deno.execPath(), { - * args: [ - * "eval", - * "console.log('Hello World')", - * ], - * stdin: "piped", - * }); - * - * // open a file and pipe the subprocess output to it. - * child.stdout.pipeTo(Deno.openSync("output").writable); - * - * // manually close stdin - * child.stdin.close(); - * const status = await child.status; - * ``` - * - * @category Sub Process - */ - export function spawnChild( - command: string | URL, - options?: SpawnOptions, - ): Child; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @deprecated Use the Deno.Command API instead. - * - * The interface for handling a child process returned from - * {@linkcode Deno.spawnChild}. - * - * @category Sub Process - */ - export class Child { - get stdin(): WritableStream; - get stdout(): ReadableStream; - get stderr(): ReadableStream; - readonly pid: number; - /** Get the status of the child. */ - readonly status: Promise; - - /** Waits for the child to exit completely, returning all its output and - * status. */ - output(): Promise; - /** Kills the process with given {@linkcode Deno.Signal}. Defaults to - * `"SIGTERM"`. */ - kill(signo?: Signal): void; - - /** Ensure that the status of the child process prevents the Deno process - * from exiting. */ - ref(): void; - /** Ensure that the status of the child process does not block the Deno - * process from exiting. */ - unref(): void; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @deprecated Use the Deno.Command API instead. - * - * Executes a subprocess, waiting for it to finish and collecting all of its - * output. - * - * Will throw an error if `stdin: "piped"` is passed. - * - * If options `stdout` or `stderr` are not set to `"piped"`, accessing the - * corresponding field on `SpawnOutput` will throw a `TypeError`. - * - * ```ts - * const { code, stdout, stderr } = await Deno.spawn(Deno.execPath(), { - * args: [ - * "eval", - * "console.log('hello'); console.error('world')", - * ], - * }); - * console.assert(code === 0); - * console.assert("hello\n" === new TextDecoder().decode(stdout)); - * console.assert("world\n" === new TextDecoder().decode(stderr)); - * ``` - * - * @category Sub Process - */ - export function spawn( - command: string | URL, - options?: SpawnOptions, - ): Promise; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @deprecated Use the Deno.Command API instead. - * - * Synchronously executes a subprocess, waiting for it to finish and - * collecting all of its output. - * - * Will throw an error if `stdin: "piped"` is passed. - * - * If options `stdout` or `stderr` are not set to `"piped"`, accessing the - * corresponding field on `SpawnOutput` will throw a `TypeError`. - * - * ```ts - * const { code, stdout, stderr } = Deno.spawnSync(Deno.execPath(), { - * args: [ - * "eval", - * "console.log('hello'); console.error('world')", - * ], - * }); - * console.assert(code === 0); - * console.assert("hello\n" === new TextDecoder().decode(stdout)); - * console.assert("world\n" === new TextDecoder().decode(stderr)); - * ``` - * - * @category Sub Process - */ - export function spawnSync( - command: string | URL, - options?: SpawnOptions, - ): SpawnOutput; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @deprecated Use the Deno.Command API instead. - * - * @category Sub Process - */ - export interface ChildStatus { - /** If the child process exits with a 0 status code, `success` will be set - * to `true`, otherwise `false`. */ - success: boolean; - /** The exit code of the child process. */ - code: number; - /** The signal associated with the child process, present if - * {@linkcode Deno.spawn} was called. */ - signal: Signal | null; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @deprecated Use the Deno.Command API instead. - * - * The interface returned from calling {@linkcode Deno.spawn} or - * {@linkcode Deno.spawnSync} which represents the result of spawning the - * child process. - * - * @category Sub Process - */ - export interface SpawnOutput extends ChildStatus { - /** The buffered output from the child processes `stdout`. */ - readonly stdout: Uint8Array; - /** The buffered output from the child processes `stderr`. */ - readonly stderr: Uint8Array; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Create a child process. - * - * If any stdio options are not set to `"piped"`, accessing the corresponding - * field on the `Command` or its `CommandOutput` will throw a `TypeError`. - * - * If `stdin` is set to `"piped"`, the `stdin` {@linkcode WritableStream} - * needs to be closed manually. - * - * ```ts - * const command = new Deno.Command(Deno.execPath(), { - * args: [ - * "eval", - * "console.log('Hello World')", - * ], - * stdin: "piped", - * }); - * command.spawn(); - * - * // open a file and pipe the subprocess output to it. - * command.stdout.pipeTo(Deno.openSync("output").writable); - * - * // manually close stdin - * command.stdin.close(); - * const status = await command.status; - * ``` - * - * ```ts - * const command = new Deno.Command(Deno.execPath(), { - * args: [ - * "eval", - * "console.log('hello'); console.error('world')", - * ], - * }); - * const { code, stdout, stderr } = await command.output(); - * console.assert(code === 0); - * console.assert("hello\n" === new TextDecoder().decode(stdout)); - * console.assert("world\n" === new TextDecoder().decode(stderr)); - * ``` - * - * ```ts - * const command = new Deno.Command(Deno.execPath(), { - * args: [ - * "eval", - * "console.log('hello'); console.error('world')", - * ], - * }); - * const { code, stdout, stderr } = command.outputSync(); - * console.assert(code === 0); - * console.assert("hello\n" === new TextDecoder().decode(stdout)); - * console.assert("world\n" === new TextDecoder().decode(stderr)); - * ``` - * - * @category Sub Process - */ - export class Command { - get stdin(): WritableStream; - get stdout(): ReadableStream; - get stderr(): ReadableStream; - readonly pid: number; - /** Get the status of the child process. */ - readonly status: Promise; - - constructor(command: string | URL, options?: CommandOptions); - /** - * Executes the {@linkcode Deno.Command}, waiting for it to finish and - * collecting all of its output. - * If `spawn()` was called, calling this function will collect the remaining - * output. - * - * Will throw an error if `stdin: "piped"` is set. - * - * If options `stdout` or `stderr` are not set to `"piped"`, accessing the - * corresponding field on {@linkcode Deno.CommandOutput} will throw a `TypeError`. - */ - output(): Promise; - /** - * Synchronously executes the {@linkcode Deno.Command}, waiting for it to - * finish and collecting all of its output. - * - * Will throw an error if `stdin: "piped"` is set. - * - * If options `stdout` or `stderr` are not set to `"piped"`, accessing the - * corresponding field on {@linkcode Deno.CommandOutput} will throw a `TypeError`. - */ - outputSync(): CommandOutput; - /** - * Spawns a streamable subprocess, allowing to use the other methods. - */ - spawn(): void; - - /** Kills the process with given {@linkcode Deno.Signal}. Defaults to - * `"SIGTERM"`. */ - kill(signo?: Signal): void; - - /** Ensure that the status of the child process prevents the Deno process - * from exiting. */ - ref(): void; - /** Ensure that the status of the child process does not block the Deno - * process from exiting. */ - unref(): void; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Options which can be set when calling {@linkcode Deno.command}. - * - * @category Sub Process - */ - export interface CommandOptions { - /** Arguments to pass to the process. */ - args?: string[]; - /** - * The working directory of the process. - * - * If not specified, the `cwd` of the parent process is used. - */ - cwd?: string | URL; - /** - * Clear environmental variables from parent process. - * - * Doesn't guarantee that only `env` variables are present, as the OS may - * set environmental variables for processes. - */ - clearEnv?: boolean; - /** Environmental variables to pass to the subprocess. */ - env?: Record; - /** - * Sets the child process’s user ID. This translates to a setuid call in the - * child process. Failure in the set uid call will cause the spawn to fail. - */ - uid?: number; - /** Similar to `uid`, but sets the group ID of the child process. */ - gid?: number; - /** - * An {@linkcode AbortSignal} that allows closing the process using the - * corresponding {@linkcode AbortController} by sending the process a - * SIGTERM signal. - * - * Ignored by {@linkcode Command.outputSync}. - */ - signal?: AbortSignal; - - /** How `stdin` of the spawned process should be handled. - * - * Defaults to `"null"`. */ - stdin?: "piped" | "inherit" | "null"; - /** How `stdout` of the spawned process should be handled. - * - * Defaults to `"piped"`. */ - stdout?: "piped" | "inherit" | "null"; - /** How `stderr` of the spawned process should be handled. - * - * Defaults to "piped". */ - stderr?: "piped" | "inherit" | "null"; - - /** Skips quoting and escaping of the arguments on Windows. This option - * is ignored on non-windows platforms. Defaults to `false`. */ - windowsRawArguments?: boolean; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category Sub Process - */ - export interface CommandStatus { - /** If the child process exits with a 0 status code, `success` will be set - * to `true`, otherwise `false`. */ - success: boolean; - /** The exit code of the child process. */ - code: number; - /** The signal associated with the child process. */ - signal: Signal | null; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * The interface returned from calling {@linkcode Command.output} or - * {@linkcode Command.outputSync} which represents the result of spawning the - * child process. - * - * @category Sub Process - */ - export interface CommandOutput extends CommandStatus { - /** The buffered output from the child process' `stdout`. */ - readonly stdout: Uint8Array; - /** The buffered output from the child process' `stderr`. */ - readonly stderr: Uint8Array; - } -} - -/** **UNSTABLE**: New API, yet to be vetted. - * - * The [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) - * which also supports setting a {@linkcode Deno.HttpClient} which provides a - * way to connect via proxies and use custom TLS certificates. - * - * @tags allow-net, allow-read - * @category Fetch API - */ -declare function fetch( - input: Request | URL | string, - init?: RequestInit & { client: Deno.HttpClient }, -): Promise; - -/** **UNSTABLE**: New API, yet to be vetted. - * - * @category Web Workers - */ -declare interface WorkerOptions { - /** **UNSTABLE**: New API, yet to be vetted. - * - * Configure permissions options to change the level of access the worker will - * have. By default it will have no permissions. Note that the permissions - * of a worker can't be extended beyond its parent's permissions reach. - * - * - `"inherit"` will take the permissions of the thread the worker is created - * in. - * - `"none"` will use the default behavior and have no permission - * - A list of routes can be provided that are relative to the file the worker - * is created in to limit the access of the worker (read/write permissions - * only) - * - * Example: - * - * ```ts - * // mod.ts - * const worker = new Worker( - * new URL("deno_worker.ts", import.meta.url).href, { - * type: "module", - * deno: { - * permissions: { - * read: true, - * }, - * }, - * } - * ); - * ``` - */ - deno?: { - /** Set to `"none"` to disable all the permissions in the worker. */ - permissions?: Deno.PermissionOptions; - }; -} - -/** **UNSTABLE**: New API, yet to be vetted. - * - * @category Web Sockets - */ -declare interface WebSocketStreamOptions { - protocols?: string[]; - signal?: AbortSignal; - headers?: HeadersInit; -} - -/** **UNSTABLE**: New API, yet to be vetted. - * - * @category Web Sockets - */ -declare interface WebSocketConnection { - readable: ReadableStream; - writable: WritableStream; - extensions: string; - protocol: string; -} - -/** **UNSTABLE**: New API, yet to be vetted. - * - * @category Web Sockets - */ -declare interface WebSocketCloseInfo { - code?: number; - reason?: string; -} - -/** **UNSTABLE**: New API, yet to be vetted. - * - * @tags allow-net - * @category Web Sockets - */ -declare class WebSocketStream { - constructor(url: string, options?: WebSocketStreamOptions); - url: string; - connection: Promise; - closed: Promise; - close(closeInfo?: WebSocketCloseInfo): void; -} diff --git a/cli/dts/lib.deno.window.d.ts b/cli/dts/lib.deno.window.d.ts deleted file mode 100644 index 4ce288a4d..000000000 --- a/cli/dts/lib.deno.window.d.ts +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. - -/// -/// -/// -/// -/// -/// -/// - -/** @category Web APIs */ -interface WindowEventMap { - "error": ErrorEvent; - "unhandledrejection": PromiseRejectionEvent; -} - -/** @category Web APIs */ -declare class Window extends EventTarget { - new(): Window; - readonly window: Window & typeof globalThis; - readonly self: Window & typeof globalThis; - onerror: ((this: Window, ev: ErrorEvent) => any) | null; - onload: ((this: Window, ev: Event) => any) | null; - onbeforeunload: ((this: Window, ev: Event) => any) | null; - onunload: ((this: Window, ev: Event) => any) | null; - onunhandledrejection: - | ((this: Window, ev: PromiseRejectionEvent) => any) - | null; - close: () => void; - readonly closed: boolean; - alert: (message?: string) => void; - confirm: (message?: string) => boolean; - prompt: (message?: string, defaultValue?: string) => string | null; - Deno: typeof Deno; - Navigator: typeof Navigator; - navigator: Navigator; - Location: typeof Location; - location: Location; - localStorage: Storage; - sessionStorage: Storage; - caches: CacheStorage; - - addEventListener( - type: K, - listener: ( - this: Window, - ev: WindowEventMap[K], - ) => any, - options?: boolean | AddEventListenerOptions, - ): void; - addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | AddEventListenerOptions, - ): void; - removeEventListener( - type: K, - listener: ( - this: Window, - ev: WindowEventMap[K], - ) => any, - options?: boolean | EventListenerOptions, - ): void; - removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | EventListenerOptions, - ): void; -} - -/** @category Web APIs */ -declare var window: Window & typeof globalThis; -/** @category Web APIs */ -declare var self: Window & typeof globalThis; -/** @category DOM Events */ -declare var onerror: ((this: Window, ev: ErrorEvent) => any) | null; -/** @category DOM Events */ -declare var onload: ((this: Window, ev: Event) => any) | null; -/** @category DOM Events */ -declare var onbeforeunload: ((this: Window, ev: Event) => any) | null; -/** @category DOM Events */ -declare var onunload: ((this: Window, ev: Event) => any) | null; -/** @category Observability */ -declare var onunhandledrejection: - | ((this: Window, ev: PromiseRejectionEvent) => any) - | null; -/** @category Web Storage API */ -declare var localStorage: Storage; -/** @category Web Storage API */ -declare var sessionStorage: Storage; -/** @category Cache API */ -declare var caches: CacheStorage; - -/** @category Web APIs */ -declare class Navigator { - constructor(); - readonly gpu: GPU; - readonly hardwareConcurrency: number; - readonly userAgent: string; - readonly language: string; - readonly languages: string[]; -} - -/** @category Web APIs */ -declare var navigator: Navigator; - -/** - * Shows the given message and waits for the enter key pressed. - * - * If the stdin is not interactive, it does nothing. - * - * @category Web APIs - * - * @param message - */ -declare function alert(message?: string): void; - -/** - * Shows the given message and waits for the answer. Returns the user's answer as boolean. - * - * Only `y` and `Y` are considered as true. - * - * If the stdin is not interactive, it returns false. - * - * @category Web APIs - * - * @param message - */ -declare function confirm(message?: string): boolean; - -/** - * Shows the given message and waits for the user's input. Returns the user's input as string. - * - * If the default value is given and the user inputs the empty string, then it returns the given - * default value. - * - * If the default value is not given and the user inputs the empty string, it returns null. - * - * If the stdin is not interactive, it returns null. - * - * @category Web APIs - * - * @param message - * @param defaultValue - */ -declare function prompt(message?: string, defaultValue?: string): string | null; - -/** Registers an event listener in the global scope, which will be called - * synchronously whenever the event `type` is dispatched. - * - * ```ts - * addEventListener('unload', () => { console.log('All finished!'); }); - * ... - * dispatchEvent(new Event('unload')); - * ``` - * - * @category DOM Events - */ -declare function addEventListener< - K extends keyof WindowEventMap, ->( - type: K, - listener: (this: Window, ev: WindowEventMap[K]) => any, - options?: boolean | AddEventListenerOptions, -): void; -/** @category DOM Events */ -declare function addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | AddEventListenerOptions, -): void; - -/** Remove a previously registered event listener from the global scope - * - * ```ts - * const listener = () => { console.log('hello'); }; - * addEventListener('load', listener); - * removeEventListener('load', listener); - * ``` - * - * @category DOM Events - */ -declare function removeEventListener< - K extends keyof WindowEventMap, ->( - type: K, - listener: (this: Window, ev: WindowEventMap[K]) => any, - options?: boolean | EventListenerOptions, -): void; -declare function removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | EventListenerOptions, -): void; - -// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is. -// The types there must first be split into window, worker and global types. -/** The location (URL) of the object it is linked to. Changes done on it are - * reflected on the object it relates to. Accessible via - * `globalThis.location`. - * - * @category Web APIs - */ -declare class Location { - constructor(); - /** Returns a DOMStringList object listing the origins of the ancestor - * browsing contexts, from the parent browsing context to the top-level - * browsing context. - * - * Always empty in Deno. */ - readonly ancestorOrigins: DOMStringList; - /** Returns the Location object's URL's fragment (includes leading "#" if - * non-empty). - * - * Cannot be set in Deno. */ - hash: string; - /** Returns the Location object's URL's host and port (if different from the - * default port for the scheme). - * - * Cannot be set in Deno. */ - host: string; - /** Returns the Location object's URL's host. - * - * Cannot be set in Deno. */ - hostname: string; - /** Returns the Location object's URL. - * - * Cannot be set in Deno. */ - href: string; - toString(): string; - /** Returns the Location object's URL's origin. */ - readonly origin: string; - /** Returns the Location object's URL's path. - * - * Cannot be set in Deno. */ - pathname: string; - /** Returns the Location object's URL's port. - * - * Cannot be set in Deno. */ - port: string; - /** Returns the Location object's URL's scheme. - * - * Cannot be set in Deno. */ - protocol: string; - /** Returns the Location object's URL's query (includes leading "?" if - * non-empty). - * - * Cannot be set in Deno. */ - search: string; - /** Navigates to the given URL. - * - * Cannot be set in Deno. */ - assign(url: string): void; - /** Reloads the current page. - * - * Disabled in Deno. */ - reload(): void; - /** @deprecated */ - reload(forcedReload: boolean): void; - /** Removes the current page from the session history and navigates to the - * given URL. - * - * Disabled in Deno. */ - replace(url: string): void; -} - -// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is. -// The types there must first be split into window, worker and global types. -/** @category Web APIs */ -declare var location: Location; diff --git a/cli/dts/lib.deno.worker.d.ts b/cli/dts/lib.deno.worker.d.ts deleted file mode 100644 index d274d4c05..000000000 --- a/cli/dts/lib.deno.worker.d.ts +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. - -/// -/// -/// -/// -/// -/// - -/** @category Web Workers */ -interface WorkerGlobalScopeEventMap { - "error": ErrorEvent; - "unhandledrejection": PromiseRejectionEvent; -} - -/** @category Web Workers */ -declare class WorkerGlobalScope extends EventTarget { - readonly location: WorkerLocation; - readonly navigator: WorkerNavigator; - onerror: ((this: WorkerGlobalScope, ev: ErrorEvent) => any) | null; - onunhandledrejection: - | ((this: WorkerGlobalScope, ev: PromiseRejectionEvent) => any) - | null; - - readonly self: WorkerGlobalScope & typeof globalThis; - - addEventListener( - type: K, - listener: ( - this: WorkerGlobalScope, - ev: WorkerGlobalScopeEventMap[K], - ) => any, - options?: boolean | AddEventListenerOptions, - ): void; - addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | AddEventListenerOptions, - ): void; - removeEventListener( - type: K, - listener: ( - this: WorkerGlobalScope, - ev: WorkerGlobalScopeEventMap[K], - ) => any, - options?: boolean | EventListenerOptions, - ): void; - removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | EventListenerOptions, - ): void; - - Deno: typeof Deno; - caches: CacheStorage; -} - -/** @category Web APIs */ -declare class WorkerNavigator { - constructor(); - readonly gpu: GPU; - readonly hardwareConcurrency: number; - readonly userAgent: string; - readonly language: string; - readonly languages: string[]; -} - -/** @category Web APIs */ -declare var navigator: WorkerNavigator; - -/** @category Web Workers */ -interface DedicatedWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap { - "message": MessageEvent; - "messageerror": MessageEvent; -} - -/** @category Web APIs */ -declare class DedicatedWorkerGlobalScope extends WorkerGlobalScope { - readonly name: string; - onmessage: - | ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) - | null; - onmessageerror: - | ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) - | null; - close(): void; - postMessage(message: any, transfer: Transferable[]): void; - postMessage(message: any, options?: StructuredSerializeOptions): void; - addEventListener( - type: K, - listener: ( - this: DedicatedWorkerGlobalScope, - ev: DedicatedWorkerGlobalScopeEventMap[K], - ) => any, - options?: boolean | AddEventListenerOptions, - ): void; - addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | AddEventListenerOptions, - ): void; - removeEventListener( - type: K, - listener: ( - this: DedicatedWorkerGlobalScope, - ev: DedicatedWorkerGlobalScopeEventMap[K], - ) => any, - options?: boolean | EventListenerOptions, - ): void; - removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | EventListenerOptions, - ): void; -} - -/** @category Web Workers */ -declare var name: string; -/** @category Web Workers */ -declare var onmessage: - | ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) - | null; -/** @category Web Workers */ -declare var onmessageerror: - | ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) - | null; -/** @category Web Workers */ -declare function close(): void; -/** @category Web Workers */ -declare function postMessage(message: any, transfer: Transferable[]): void; -/** @category Web Workers */ -declare function postMessage( - message: any, - options?: StructuredSerializeOptions, -): void; -/** @category Web APIs */ -declare var navigator: WorkerNavigator; -/** @category Web APIs */ -declare var onerror: - | ((this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any) - | null; -/** @category Observability */ -declare var onunhandledrejection: - | ((this: DedicatedWorkerGlobalScope, ev: PromiseRejectionEvent) => any) - | null; -/** @category Web Workers */ -declare var self: WorkerGlobalScope & typeof globalThis; -/** @category DOM Events */ -declare function addEventListener< - K extends keyof DedicatedWorkerGlobalScopeEventMap, ->( - type: K, - listener: ( - this: DedicatedWorkerGlobalScope, - ev: DedicatedWorkerGlobalScopeEventMap[K], - ) => any, - options?: boolean | AddEventListenerOptions, -): void; -/** @category DOM Events */ -declare function addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | AddEventListenerOptions, -): void; -/** @category DOM Events */ -declare function removeEventListener< - K extends keyof DedicatedWorkerGlobalScopeEventMap, ->( - type: K, - listener: ( - this: DedicatedWorkerGlobalScope, - ev: DedicatedWorkerGlobalScopeEventMap[K], - ) => any, - options?: boolean | EventListenerOptions, -): void; -/** @category DOM Events */ -declare function removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | EventListenerOptions, -): void; - -// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is. -// The types there must first be split into window, worker and global types. -/** The absolute location of the script executed by the Worker. Such an object - * is initialized for each worker and is available via the - * WorkerGlobalScope.location property obtained by calling self.location. - * - * @category Web APIs - */ -declare class WorkerLocation { - constructor(); - readonly hash: string; - readonly host: string; - readonly hostname: string; - readonly href: string; - toString(): string; - readonly origin: string; - readonly pathname: string; - readonly port: string; - readonly protocol: string; - readonly search: string; -} - -// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is. -// The types there must first be split into window, worker and global types. -/** @category Web APIs */ -declare var location: WorkerLocation; diff --git a/cli/dts/lib.deno_webgpu.d.ts b/cli/dts/lib.deno_webgpu.d.ts deleted file mode 100644 index 32f142768..000000000 --- a/cli/dts/lib.deno_webgpu.d.ts +++ /dev/null @@ -1,1322 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. - -// deno-lint-ignore-file no-explicit-any no-empty-interface - -/// -/// - -/** @category WebGPU */ -interface GPUObjectBase { - label: string; -} - -/** @category WebGPU */ -declare interface GPUObjectDescriptorBase { - label?: string; -} - -/** @category WebGPU */ -declare class GPUSupportedLimits { - maxTextureDimension1D?: number; - maxTextureDimension2D?: number; - maxTextureDimension3D?: number; - maxTextureArrayLayers?: number; - maxBindGroups?: number; - maxDynamicUniformBuffersPerPipelineLayout?: number; - maxDynamicStorageBuffersPerPipelineLayout?: number; - maxSampledTexturesPerShaderStage?: number; - maxSamplersPerShaderStage?: number; - maxStorageBuffersPerShaderStage?: number; - maxStorageTexturesPerShaderStage?: number; - maxUniformBuffersPerShaderStage?: number; - maxUniformBufferBindingSize?: number; - maxStorageBufferBindingSize?: number; - minUniformBufferOffsetAlignment?: number; - minStorageBufferOffsetAlignment?: number; - maxVertexBuffers?: number; - maxVertexAttributes?: number; - maxVertexBufferArrayStride?: number; - maxInterStageShaderComponents?: number; - maxComputeWorkgroupStorageSize?: number; - maxComputeInvocationsPerWorkgroup?: number; - maxComputeWorkgroupSizeX?: number; - maxComputeWorkgroupSizeY?: number; - maxComputeWorkgroupSizeZ?: number; - maxComputeWorkgroupsPerDimension?: number; -} - -/** @category WebGPU */ -declare class GPUSupportedFeatures { - forEach( - callbackfn: ( - value: GPUFeatureName, - value2: GPUFeatureName, - set: Set, - ) => void, - thisArg?: any, - ): void; - has(value: GPUFeatureName): boolean; - size: number; - [ - Symbol - .iterator - ](): IterableIterator; - entries(): IterableIterator<[GPUFeatureName, GPUFeatureName]>; - keys(): IterableIterator; - values(): IterableIterator; -} - -/** @category WebGPU */ -declare class GPUAdapterInfo { - readonly vendor: string; - readonly architecture: string; - readonly device: string; - readonly description: string; -} - -/** @category WebGPU */ -declare class GPU { - requestAdapter( - options?: GPURequestAdapterOptions, - ): Promise; -} - -/** @category WebGPU */ -declare interface GPURequestAdapterOptions { - powerPreference?: GPUPowerPreference; - forceFallbackAdapter?: boolean; -} - -/** @category WebGPU */ -declare type GPUPowerPreference = "low-power" | "high-performance"; - -/** @category WebGPU */ -declare class GPUAdapter { - readonly features: GPUSupportedFeatures; - readonly limits: GPUSupportedLimits; - readonly isFallbackAdapter: boolean; - - requestDevice(descriptor?: GPUDeviceDescriptor): Promise; - requestAdapterInfo(unmaskHints?: string[]): Promise; -} - -/** @category WebGPU */ -declare interface GPUDeviceDescriptor extends GPUObjectDescriptorBase { - requiredFeatures?: GPUFeatureName[]; - requiredLimits?: Record; -} - -/** @category WebGPU */ -declare type GPUFeatureName = - | "depth-clip-control" - | "depth24unorm-stencil8" - | "depth32float-stencil8" - | "pipeline-statistics-query" - | "texture-compression-bc" - | "texture-compression-etc2" - | "texture-compression-astc" - | "timestamp-query" - | "indirect-first-instance" - | "shader-f16" - // extended from spec - | "mappable-primary-buffers" - | "sampled-texture-binding-array" - | "sampled-texture-array-dynamic-indexing" - | "sampled-texture-array-non-uniform-indexing" - | "unsized-binding-array" - | "multi-draw-indirect" - | "multi-draw-indirect-count" - | "push-constants" - | "address-mode-clamp-to-border" - | "texture-adapter-specific-format-features" - | "shader-float64" - | "vertex-attribute-64bit"; - -/** @category WebGPU */ -declare class GPUDevice extends EventTarget implements GPUObjectBase { - label: string; - - readonly lost: Promise; - pushErrorScope(filter: GPUErrorFilter): undefined; - popErrorScope(): Promise; - onuncapturederror: - | ((this: GPUDevice, ev: GPUUncapturedErrorEvent) => any) - | null; - - readonly features: GPUSupportedFeatures; - readonly limits: GPUSupportedLimits; - readonly queue: GPUQueue; - - destroy(): undefined; - - createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer; - createTexture(descriptor: GPUTextureDescriptor): GPUTexture; - createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler; - - createBindGroupLayout( - descriptor: GPUBindGroupLayoutDescriptor, - ): GPUBindGroupLayout; - createPipelineLayout( - descriptor: GPUPipelineLayoutDescriptor, - ): GPUPipelineLayout; - createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup; - - createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule; - createComputePipeline( - descriptor: GPUComputePipelineDescriptor, - ): GPUComputePipeline; - createRenderPipeline( - descriptor: GPURenderPipelineDescriptor, - ): GPURenderPipeline; - createComputePipelineAsync( - descriptor: GPUComputePipelineDescriptor, - ): Promise; - createRenderPipelineAsync( - descriptor: GPURenderPipelineDescriptor, - ): Promise; - - createCommandEncoder( - descriptor?: GPUCommandEncoderDescriptor, - ): GPUCommandEncoder; - createRenderBundleEncoder( - descriptor: GPURenderBundleEncoderDescriptor, - ): GPURenderBundleEncoder; - - createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet; -} - -/** @category WebGPU */ -declare class GPUBuffer implements GPUObjectBase { - label: string; - - mapAsync( - mode: GPUMapModeFlags, - offset?: number, - size?: number, - ): Promise; - getMappedRange(offset?: number, size?: number): ArrayBuffer; - unmap(): undefined; - - destroy(): undefined; -} - -/** @category WebGPU */ -declare interface GPUBufferDescriptor extends GPUObjectDescriptorBase { - size: number; - usage: GPUBufferUsageFlags; - mappedAtCreation?: boolean; -} - -/** @category WebGPU */ -declare type GPUBufferUsageFlags = number; - -/** @category WebGPU */ -declare class GPUBufferUsage { - static MAP_READ: 0x0001; - static MAP_WRITE: 0x0002; - static COPY_SRC: 0x0004; - static COPY_DST: 0x0008; - static INDEX: 0x0010; - static VERTEX: 0x0020; - static UNIFORM: 0x0040; - static STORAGE: 0x0080; - static INDIRECT: 0x0100; - static QUERY_RESOLVE: 0x0200; -} - -/** @category WebGPU */ -declare type GPUMapModeFlags = number; - -/** @category WebGPU */ -declare class GPUMapMode { - static READ: 0x0001; - static WRITE: 0x0002; -} - -/** @category WebGPU */ -declare class GPUTexture implements GPUObjectBase { - label: string; - - createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView; - destroy(): undefined; -} - -/** @category WebGPU */ -declare interface GPUTextureDescriptor extends GPUObjectDescriptorBase { - size: GPUExtent3D; - mipLevelCount?: number; - sampleCount?: number; - dimension?: GPUTextureDimension; - format: GPUTextureFormat; - usage: GPUTextureUsageFlags; -} - -/** @category WebGPU */ -declare type GPUTextureDimension = "1d" | "2d" | "3d"; - -/** @category WebGPU */ -declare type GPUTextureUsageFlags = number; - -/** @category WebGPU */ -declare class GPUTextureUsage { - static COPY_SRC: 0x01; - static COPY_DST: 0x02; - static TEXTURE_BINDING: 0x04; - static STORAGE_BINDING: 0x08; - static RENDER_ATTACHMENT: 0x10; -} - -/** @category WebGPU */ -declare class GPUTextureView implements GPUObjectBase { - label: string; -} - -/** @category WebGPU */ -declare interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase { - format?: GPUTextureFormat; - dimension?: GPUTextureViewDimension; - aspect?: GPUTextureAspect; - baseMipLevel?: number; - mipLevelCount?: number; - baseArrayLayer?: number; - arrayLayerCount?: number; -} - -/** @category WebGPU */ -declare type GPUTextureViewDimension = - | "1d" - | "2d" - | "2d-array" - | "cube" - | "cube-array" - | "3d"; - -/** @category WebGPU */ -declare type GPUTextureAspect = "all" | "stencil-only" | "depth-only"; - -/** @category WebGPU */ -declare type GPUTextureFormat = - | "r8unorm" - | "r8snorm" - | "r8uint" - | "r8sint" - | "r16uint" - | "r16sint" - | "r16float" - | "rg8unorm" - | "rg8snorm" - | "rg8uint" - | "rg8sint" - | "r32uint" - | "r32sint" - | "r32float" - | "rg16uint" - | "rg16sint" - | "rg16float" - | "rgba8unorm" - | "rgba8unorm-srgb" - | "rgba8snorm" - | "rgba8uint" - | "rgba8sint" - | "bgra8unorm" - | "bgra8unorm-srgb" - | "rgb9e5ufloat" - | "rgb10a2unorm" - | "rg11b10ufloat" - | "rg32uint" - | "rg32sint" - | "rg32float" - | "rgba16uint" - | "rgba16sint" - | "rgba16float" - | "rgba32uint" - | "rgba32sint" - | "rgba32float" - | "stencil8" - | "depth16unorm" - | "depth24plus" - | "depth24plus-stencil8" - | "depth32float" - | "depth24unorm-stencil8" - | "depth32float-stencil8" - | "bc1-rgba-unorm" - | "bc1-rgba-unorm-srgb" - | "bc2-rgba-unorm" - | "bc2-rgba-unorm-srgb" - | "bc3-rgba-unorm" - | "bc3-rgba-unorm-srgb" - | "bc4-r-unorm" - | "bc4-r-snorm" - | "bc5-rg-unorm" - | "bc5-rg-snorm" - | "bc6h-rgb-ufloat" - | "bc6h-rgb-float" - | "bc7-rgba-unorm" - | "bc7-rgba-unorm-srgb" - | "etc2-rgb8unorm" - | "etc2-rgb8unorm-srgb" - | "etc2-rgb8a1unorm" - | "etc2-rgb8a1unorm-srgb" - | "etc2-rgba8unorm" - | "etc2-rgba8unorm-srgb" - | "eac-r11unorm" - | "eac-r11snorm" - | "eac-rg11unorm" - | "eac-rg11snorm" - | "astc-4x4-unorm" - | "astc-4x4-unorm-srgb" - | "astc-5x4-unorm" - | "astc-5x4-unorm-srgb" - | "astc-5x5-unorm" - | "astc-5x5-unorm-srgb" - | "astc-6x5-unorm" - | "astc-6x5-unorm-srgb" - | "astc-6x6-unorm" - | "astc-6x6-unorm-srgb" - | "astc-8x5-unorm" - | "astc-8x5-unorm-srgb" - | "astc-8x6-unorm" - | "astc-8x6-unorm-srgb" - | "astc-8x8-unorm" - | "astc-8x8-unorm-srgb" - | "astc-10x5-unorm" - | "astc-10x5-unorm-srgb" - | "astc-10x6-unorm" - | "astc-10x6-unorm-srgb" - | "astc-10x8-unorm" - | "astc-10x8-unorm-srgb" - | "astc-10x10-unorm" - | "astc-10x10-unorm-srgb" - | "astc-12x10-unorm" - | "astc-12x10-unorm-srgb" - | "astc-12x12-unorm" - | "astc-12x12-unorm-srgb"; - -/** @category WebGPU */ -declare class GPUSampler implements GPUObjectBase { - label: string; -} - -/** @category WebGPU */ -declare interface GPUSamplerDescriptor extends GPUObjectDescriptorBase { - addressModeU?: GPUAddressMode; - addressModeV?: GPUAddressMode; - addressModeW?: GPUAddressMode; - magFilter?: GPUFilterMode; - minFilter?: GPUFilterMode; - mipmapFilter?: GPUMipmapFilterMode; - lodMinClamp?: number; - lodMaxClamp?: number; - compare?: GPUCompareFunction; - maxAnisotropy?: number; -} - -/** @category WebGPU */ -declare type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat"; - -/** @category WebGPU */ -declare type GPUFilterMode = "nearest" | "linear"; - -/** @category WebGPU */ -declare type GPUMipmapFilterMode = "nearest" | "linear"; - -/** @category WebGPU */ -declare type GPUCompareFunction = - | "never" - | "less" - | "equal" - | "less-equal" - | "greater" - | "not-equal" - | "greater-equal" - | "always"; - -/** @category WebGPU */ -declare class GPUBindGroupLayout implements GPUObjectBase { - label: string; -} - -/** @category WebGPU */ -declare interface GPUBindGroupLayoutDescriptor extends GPUObjectDescriptorBase { - entries: GPUBindGroupLayoutEntry[]; -} - -/** @category WebGPU */ -declare interface GPUBindGroupLayoutEntry { - binding: number; - visibility: GPUShaderStageFlags; - - buffer?: GPUBufferBindingLayout; - sampler?: GPUSamplerBindingLayout; - texture?: GPUTextureBindingLayout; - storageTexture?: GPUStorageTextureBindingLayout; -} - -/** @category WebGPU */ -declare type GPUShaderStageFlags = number; - -/** @category WebGPU */ -declare class GPUShaderStage { - static VERTEX: 0x1; - static FRAGMENT: 0x2; - static COMPUTE: 0x4; -} - -/** @category WebGPU */ -declare interface GPUBufferBindingLayout { - type?: GPUBufferBindingType; - hasDynamicOffset?: boolean; - minBindingSize?: number; -} - -/** @category WebGPU */ -declare type GPUBufferBindingType = "uniform" | "storage" | "read-only-storage"; - -/** @category WebGPU */ -declare interface GPUSamplerBindingLayout { - type?: GPUSamplerBindingType; -} - -/** @category WebGPU */ -declare type GPUSamplerBindingType = - | "filtering" - | "non-filtering" - | "comparison"; - -/** @category WebGPU */ -declare interface GPUTextureBindingLayout { - sampleType?: GPUTextureSampleType; - viewDimension?: GPUTextureViewDimension; - multisampled?: boolean; -} - -/** @category WebGPU */ -declare type GPUTextureSampleType = - | "float" - | "unfilterable-float" - | "depth" - | "sint" - | "uint"; - -/** @category WebGPU */ -declare type GPUStorageTextureAccess = "write-only"; - -/** @category WebGPU */ -declare interface GPUStorageTextureBindingLayout { - access: GPUStorageTextureAccess; - format: GPUTextureFormat; - viewDimension?: GPUTextureViewDimension; -} - -/** @category WebGPU */ -declare class GPUBindGroup implements GPUObjectBase { - label: string; -} - -/** @category WebGPU */ -declare interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase { - layout: GPUBindGroupLayout; - entries: GPUBindGroupEntry[]; -} - -/** @category WebGPU */ -declare type GPUBindingResource = - | GPUSampler - | GPUTextureView - | GPUBufferBinding; - -/** @category WebGPU */ -declare interface GPUBindGroupEntry { - binding: number; - resource: GPUBindingResource; -} - -/** @category WebGPU */ -declare interface GPUBufferBinding { - buffer: GPUBuffer; - offset?: number; - size?: number; -} - -/** @category WebGPU */ -declare class GPUPipelineLayout implements GPUObjectBase { - label: string; -} - -/** @category WebGPU */ -declare interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase { - bindGroupLayouts: GPUBindGroupLayout[]; -} - -/** @category WebGPU */ -declare type GPUCompilationMessageType = "error" | "warning" | "info"; - -/** @category WebGPU */ -declare interface GPUCompilationMessage { - readonly message: string; - readonly type: GPUCompilationMessageType; - readonly lineNum: number; - readonly linePos: number; -} - -/** @category WebGPU */ -declare interface GPUCompilationInfo { - readonly messages: ReadonlyArray; -} - -/** @category WebGPU */ -declare class GPUShaderModule implements GPUObjectBase { - label: string; - - compilationInfo(): Promise; -} - -/** @category WebGPU */ -declare interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase { - code: string; - sourceMap?: any; -} - -/** @category WebGPU */ -declare type GPUAutoLayoutMode = "auto"; - -/** @category WebGPU */ -declare interface GPUPipelineDescriptorBase extends GPUObjectDescriptorBase { - layout: GPUPipelineLayout | GPUAutoLayoutMode; -} - -/** @category WebGPU */ -declare interface GPUPipelineBase { - getBindGroupLayout(index: number): GPUBindGroupLayout; -} - -/** @category WebGPU */ -declare interface GPUProgrammableStage { - module: GPUShaderModule; - entryPoint: string; -} - -/** @category WebGPU */ -declare class GPUComputePipeline implements GPUObjectBase, GPUPipelineBase { - label: string; - - getBindGroupLayout(index: number): GPUBindGroupLayout; -} - -/** @category WebGPU */ -declare interface GPUComputePipelineDescriptor - extends GPUPipelineDescriptorBase { - compute: GPUProgrammableStage; -} - -/** @category WebGPU */ -declare class GPURenderPipeline implements GPUObjectBase, GPUPipelineBase { - label: string; - - getBindGroupLayout(index: number): GPUBindGroupLayout; -} - -/** @category WebGPU */ -declare interface GPURenderPipelineDescriptor - extends GPUPipelineDescriptorBase { - vertex: GPUVertexState; - primitive?: GPUPrimitiveState; - depthStencil?: GPUDepthStencilState; - multisample?: GPUMultisampleState; - fragment?: GPUFragmentState; -} - -/** @category WebGPU */ -declare interface GPUPrimitiveState { - topology?: GPUPrimitiveTopology; - stripIndexFormat?: GPUIndexFormat; - frontFace?: GPUFrontFace; - cullMode?: GPUCullMode; - unclippedDepth?: boolean; -} - -/** @category WebGPU */ -declare type GPUPrimitiveTopology = - | "point-list" - | "line-list" - | "line-strip" - | "triangle-list" - | "triangle-strip"; - -/** @category WebGPU */ -declare type GPUFrontFace = "ccw" | "cw"; - -/** @category WebGPU */ -declare type GPUCullMode = "none" | "front" | "back"; - -/** @category WebGPU */ -declare interface GPUMultisampleState { - count?: number; - mask?: number; - alphaToCoverageEnabled?: boolean; -} - -/** @category WebGPU */ -declare interface GPUFragmentState extends GPUProgrammableStage { - targets: (GPUColorTargetState | null)[]; -} - -/** @category WebGPU */ -declare interface GPUColorTargetState { - format: GPUTextureFormat; - - blend?: GPUBlendState; - writeMask?: GPUColorWriteFlags; -} - -/** @category WebGPU */ -declare interface GPUBlendState { - color: GPUBlendComponent; - alpha: GPUBlendComponent; -} - -/** @category WebGPU */ -declare type GPUColorWriteFlags = number; - -/** @category WebGPU */ -declare class GPUColorWrite { - static RED: 0x1; - static GREEN: 0x2; - static BLUE: 0x4; - static ALPHA: 0x8; - static ALL: 0xF; -} - -/** @category WebGPU */ -declare interface GPUBlendComponent { - operation?: GPUBlendOperation; - srcFactor?: GPUBlendFactor; - dstFactor?: GPUBlendFactor; -} - -/** @category WebGPU */ -declare type GPUBlendFactor = - | "zero" - | "one" - | "src" - | "one-minus-src" - | "src-alpha" - | "one-minus-src-alpha" - | "dst" - | "one-minus-dst" - | "dst-alpha" - | "one-minus-dst-alpha" - | "src-alpha-saturated" - | "constant" - | "one-minus-constant"; - -/** @category WebGPU */ -declare type GPUBlendOperation = - | "add" - | "subtract" - | "reverse-subtract" - | "min" - | "max"; - -/** @category WebGPU */ -declare interface GPUDepthStencilState { - format: GPUTextureFormat; - - depthWriteEnabled?: boolean; - depthCompare?: GPUCompareFunction; - - stencilFront?: GPUStencilFaceState; - stencilBack?: GPUStencilFaceState; - - stencilReadMask?: number; - stencilWriteMask?: number; - - depthBias?: number; - depthBiasSlopeScale?: number; - depthBiasClamp?: number; -} - -/** @category WebGPU */ -declare interface GPUStencilFaceState { - compare?: GPUCompareFunction; - failOp?: GPUStencilOperation; - depthFailOp?: GPUStencilOperation; - passOp?: GPUStencilOperation; -} - -/** @category WebGPU */ -declare type GPUStencilOperation = - | "keep" - | "zero" - | "replace" - | "invert" - | "increment-clamp" - | "decrement-clamp" - | "increment-wrap" - | "decrement-wrap"; - -/** @category WebGPU */ -declare type GPUIndexFormat = "uint16" | "uint32"; - -/** @category WebGPU */ -declare type GPUVertexFormat = - | "uint8x2" - | "uint8x4" - | "sint8x2" - | "sint8x4" - | "unorm8x2" - | "unorm8x4" - | "snorm8x2" - | "snorm8x4" - | "uint16x2" - | "uint16x4" - | "sint16x2" - | "sint16x4" - | "unorm16x2" - | "unorm16x4" - | "snorm16x2" - | "snorm16x4" - | "float16x2" - | "float16x4" - | "float32" - | "float32x2" - | "float32x3" - | "float32x4" - | "uint32" - | "uint32x2" - | "uint32x3" - | "uint32x4" - | "sint32" - | "sint32x2" - | "sint32x3" - | "sint32x4"; - -/** @category WebGPU */ -declare type GPUVertexStepMode = "vertex" | "instance"; - -/** @category WebGPU */ -declare interface GPUVertexState extends GPUProgrammableStage { - buffers?: (GPUVertexBufferLayout | null)[]; -} - -/** @category WebGPU */ -declare interface GPUVertexBufferLayout { - arrayStride: number; - stepMode?: GPUVertexStepMode; - attributes: GPUVertexAttribute[]; -} - -/** @category WebGPU */ -declare interface GPUVertexAttribute { - format: GPUVertexFormat; - offset: number; - - shaderLocation: number; -} - -/** @category WebGPU */ -declare class GPUCommandBuffer implements GPUObjectBase { - label: string; -} - -/** @category WebGPU */ -declare interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase {} - -/** @category WebGPU */ -declare class GPUCommandEncoder implements GPUObjectBase { - label: string; - - beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder; - beginComputePass( - descriptor?: GPUComputePassDescriptor, - ): GPUComputePassEncoder; - - copyBufferToBuffer( - source: GPUBuffer, - sourceOffset: number, - destination: GPUBuffer, - destinationOffset: number, - size: number, - ): undefined; - - copyBufferToTexture( - source: GPUImageCopyBuffer, - destination: GPUImageCopyTexture, - copySize: GPUExtent3D, - ): undefined; - - copyTextureToBuffer( - source: GPUImageCopyTexture, - destination: GPUImageCopyBuffer, - copySize: GPUExtent3D, - ): undefined; - - copyTextureToTexture( - source: GPUImageCopyTexture, - destination: GPUImageCopyTexture, - copySize: GPUExtent3D, - ): undefined; - - clearBuffer( - destination: GPUBuffer, - destinationOffset?: number, - size?: number, - ): undefined; - - pushDebugGroup(groupLabel: string): undefined; - popDebugGroup(): undefined; - insertDebugMarker(markerLabel: string): undefined; - - writeTimestamp(querySet: GPUQuerySet, queryIndex: number): undefined; - - resolveQuerySet( - querySet: GPUQuerySet, - firstQuery: number, - queryCount: number, - destination: GPUBuffer, - destinationOffset: number, - ): undefined; - - finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer; -} - -/** @category WebGPU */ -declare interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {} - -/** @category WebGPU */ -declare interface GPUImageDataLayout { - offset?: number; - bytesPerRow?: number; - rowsPerImage?: number; -} - -/** @category WebGPU */ -declare interface GPUImageCopyBuffer extends GPUImageDataLayout { - buffer: GPUBuffer; -} - -/** @category WebGPU */ -declare interface GPUImageCopyTexture { - texture: GPUTexture; - mipLevel?: number; - origin?: GPUOrigin3D; - aspect?: GPUTextureAspect; -} - -/** @category WebGPU */ -interface GPUProgrammablePassEncoder { - setBindGroup( - index: number, - bindGroup: GPUBindGroup, - dynamicOffsets?: number[], - ): undefined; - - setBindGroup( - index: number, - bindGroup: GPUBindGroup, - dynamicOffsetsData: Uint32Array, - dynamicOffsetsDataStart: number, - dynamicOffsetsDataLength: number, - ): undefined; - - pushDebugGroup(groupLabel: string): undefined; - popDebugGroup(): undefined; - insertDebugMarker(markerLabel: string): undefined; -} - -/** @category WebGPU */ -declare class GPUComputePassEncoder - implements GPUObjectBase, GPUProgrammablePassEncoder { - label: string; - setBindGroup( - index: number, - bindGroup: GPUBindGroup, - dynamicOffsets?: number[], - ): undefined; - setBindGroup( - index: number, - bindGroup: GPUBindGroup, - dynamicOffsetsData: Uint32Array, - dynamicOffsetsDataStart: number, - dynamicOffsetsDataLength: number, - ): undefined; - pushDebugGroup(groupLabel: string): undefined; - popDebugGroup(): undefined; - insertDebugMarker(markerLabel: string): undefined; - setPipeline(pipeline: GPUComputePipeline): undefined; - dispatchWorkgroups(x: number, y?: number, z?: number): undefined; - dispatchWorkgroupsIndirect( - indirectBuffer: GPUBuffer, - indirectOffset: number, - ): undefined; - - beginPipelineStatisticsQuery( - querySet: GPUQuerySet, - queryIndex: number, - ): undefined; - endPipelineStatisticsQuery(): undefined; - - writeTimestamp(querySet: GPUQuerySet, queryIndex: number): undefined; - - end(): undefined; -} - -/** @category WebGPU */ -declare interface GPUComputePassDescriptor extends GPUObjectDescriptorBase {} - -/** @category WebGPU */ -interface GPURenderEncoderBase { - setPipeline(pipeline: GPURenderPipeline): undefined; - - setIndexBuffer( - buffer: GPUBuffer, - indexFormat: GPUIndexFormat, - offset?: number, - size?: number, - ): undefined; - setVertexBuffer( - slot: number, - buffer: GPUBuffer, - offset?: number, - size?: number, - ): undefined; - - draw( - vertexCount: number, - instanceCount?: number, - firstVertex?: number, - firstInstance?: number, - ): undefined; - drawIndexed( - indexCount: number, - instanceCount?: number, - firstIndex?: number, - baseVertex?: number, - firstInstance?: number, - ): undefined; - - drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): undefined; - drawIndexedIndirect( - indirectBuffer: GPUBuffer, - indirectOffset: number, - ): undefined; -} - -/** @category WebGPU */ -declare class GPURenderPassEncoder - implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase { - label: string; - setBindGroup( - index: number, - bindGroup: GPUBindGroup, - dynamicOffsets?: number[], - ): undefined; - setBindGroup( - index: number, - bindGroup: GPUBindGroup, - dynamicOffsetsData: Uint32Array, - dynamicOffsetsDataStart: number, - dynamicOffsetsDataLength: number, - ): undefined; - pushDebugGroup(groupLabel: string): undefined; - popDebugGroup(): undefined; - insertDebugMarker(markerLabel: string): undefined; - setPipeline(pipeline: GPURenderPipeline): undefined; - setIndexBuffer( - buffer: GPUBuffer, - indexFormat: GPUIndexFormat, - offset?: number, - size?: number, - ): undefined; - setVertexBuffer( - slot: number, - buffer: GPUBuffer, - offset?: number, - size?: number, - ): undefined; - draw( - vertexCount: number, - instanceCount?: number, - firstVertex?: number, - firstInstance?: number, - ): undefined; - drawIndexed( - indexCount: number, - instanceCount?: number, - firstIndex?: number, - baseVertex?: number, - firstInstance?: number, - ): undefined; - drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): undefined; - drawIndexedIndirect( - indirectBuffer: GPUBuffer, - indirectOffset: number, - ): undefined; - - setViewport( - x: number, - y: number, - width: number, - height: number, - minDepth: number, - maxDepth: number, - ): undefined; - - setScissorRect( - x: number, - y: number, - width: number, - height: number, - ): undefined; - - setBlendConstant(color: GPUColor): undefined; - setStencilReference(reference: number): undefined; - - beginOcclusionQuery(queryIndex: number): undefined; - endOcclusionQuery(): undefined; - - beginPipelineStatisticsQuery( - querySet: GPUQuerySet, - queryIndex: number, - ): undefined; - endPipelineStatisticsQuery(): undefined; - - writeTimestamp(querySet: GPUQuerySet, queryIndex: number): undefined; - - executeBundles(bundles: GPURenderBundle[]): undefined; - end(): undefined; -} - -/** @category WebGPU */ -declare interface GPURenderPassDescriptor extends GPUObjectDescriptorBase { - colorAttachments: (GPURenderPassColorAttachment | null)[]; - depthStencilAttachment?: GPURenderPassDepthStencilAttachment; - occlusionQuerySet?: GPUQuerySet; -} - -/** @category WebGPU */ -declare interface GPURenderPassColorAttachment { - view: GPUTextureView; - resolveTarget?: GPUTextureView; - - clearValue?: GPUColor; - loadOp: GPULoadOp; - storeOp: GPUStoreOp; -} - -/** @category WebGPU */ -declare interface GPURenderPassDepthStencilAttachment { - view: GPUTextureView; - - depthClearValue?: number; - depthLoadOp?: GPULoadOp; - depthStoreOp?: GPUStoreOp; - depthReadOnly?: boolean; - - stencilClearValue?: number; - stencilLoadOp?: GPULoadOp; - stencilStoreOp?: GPUStoreOp; - stencilReadOnly?: boolean; -} - -/** @category WebGPU */ -declare type GPULoadOp = "load" | "clear"; - -/** @category WebGPU */ -declare type GPUStoreOp = "store" | "discard"; - -/** @category WebGPU */ -declare class GPURenderBundle implements GPUObjectBase { - label: string; -} - -/** @category WebGPU */ -declare interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase {} - -/** @category WebGPU */ -declare class GPURenderBundleEncoder - implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase { - label: string; - draw( - vertexCount: number, - instanceCount?: number, - firstVertex?: number, - firstInstance?: number, - ): undefined; - drawIndexed( - indexCount: number, - instanceCount?: number, - firstIndex?: number, - baseVertex?: number, - firstInstance?: number, - ): undefined; - drawIndexedIndirect( - indirectBuffer: GPUBuffer, - indirectOffset: number, - ): undefined; - drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): undefined; - insertDebugMarker(markerLabel: string): undefined; - popDebugGroup(): undefined; - pushDebugGroup(groupLabel: string): undefined; - setBindGroup( - index: number, - bindGroup: GPUBindGroup, - dynamicOffsets?: number[], - ): undefined; - setBindGroup( - index: number, - bindGroup: GPUBindGroup, - dynamicOffsetsData: Uint32Array, - dynamicOffsetsDataStart: number, - dynamicOffsetsDataLength: number, - ): undefined; - setIndexBuffer( - buffer: GPUBuffer, - indexFormat: GPUIndexFormat, - offset?: number, - size?: number, - ): undefined; - setPipeline(pipeline: GPURenderPipeline): undefined; - setVertexBuffer( - slot: number, - buffer: GPUBuffer, - offset?: number, - size?: number, - ): undefined; - - finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle; -} - -/** @category WebGPU */ -declare interface GPURenderPassLayout extends GPUObjectDescriptorBase { - colorFormats: (GPUTextureFormat | null)[]; - depthStencilFormat?: GPUTextureFormat; - sampleCount?: number; -} - -/** @category WebGPU */ -declare interface GPURenderBundleEncoderDescriptor extends GPURenderPassLayout { - depthReadOnly?: boolean; - stencilReadOnly?: boolean; -} - -/** @category WebGPU */ -declare class GPUQueue implements GPUObjectBase { - label: string; - - submit(commandBuffers: GPUCommandBuffer[]): undefined; - - onSubmittedWorkDone(): Promise; - - writeBuffer( - buffer: GPUBuffer, - bufferOffset: number, - data: BufferSource, - dataOffset?: number, - size?: number, - ): undefined; - - writeTexture( - destination: GPUImageCopyTexture, - data: BufferSource, - dataLayout: GPUImageDataLayout, - size: GPUExtent3D, - ): undefined; -} - -/** @category WebGPU */ -declare class GPUQuerySet implements GPUObjectBase { - label: string; - - destroy(): undefined; -} - -/** @category WebGPU */ -declare interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase { - type: GPUQueryType; - count: number; - pipelineStatistics?: GPUPipelineStatisticName[]; -} - -/** @category WebGPU */ -declare type GPUQueryType = "occlusion" | "pipeline-statistics" | "timestamp"; - -/** @category WebGPU */ -declare type GPUPipelineStatisticName = - | "vertex-shader-invocations" - | "clipper-invocations" - | "clipper-primitives-out" - | "fragment-shader-invocations" - | "compute-shader-invocations"; - -/** @category WebGPU */ -declare type GPUDeviceLostReason = "destroyed"; - -/** @category WebGPU */ -declare interface GPUDeviceLostInfo { - readonly reason: GPUDeviceLostReason | undefined; - readonly message: string; -} - -/** @category WebGPU */ -declare class GPUError { - readonly message: string; -} - -/** @category WebGPU */ -declare type GPUErrorFilter = "out-of-memory" | "validation"; - -/** @category WebGPU */ -declare class GPUOutOfMemoryError extends GPUError { - constructor(message: string); -} - -/** @category WebGPU */ -declare class GPUValidationError extends GPUError { - constructor(message: string); -} - -/** @category WebGPU */ -declare class GPUUncapturedErrorEvent extends Event { - constructor( - type: string, - gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit, - ); - readonly error: GPUError; -} - -/** @category WebGPU */ -declare interface GPUUncapturedErrorEventInit extends EventInit { - error?: GPUError; -} - -/** @category WebGPU */ -declare interface GPUColorDict { - r: number; - g: number; - b: number; - a: number; -} - -/** @category WebGPU */ -declare type GPUColor = number[] | GPUColorDict; - -/** @category WebGPU */ -declare interface GPUOrigin3DDict { - x?: number; - y?: number; - z?: number; -} - -/** @category WebGPU */ -declare type GPUOrigin3D = number[] | GPUOrigin3DDict; - -/** @category WebGPU */ -declare interface GPUExtent3DDict { - width: number; - height?: number; - depthOrArrayLayers?: number; -} - -/** @category WebGPU */ -declare type GPUExtent3D = number[] | GPUExtent3DDict; diff --git a/cli/dts/lib.dom.asynciterable.d.ts b/cli/dts/lib.dom.asynciterable.d.ts deleted file mode 100644 index 27f9f3ede..000000000 --- a/cli/dts/lib.dom.asynciterable.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. - -/// - -interface ReadableStream { - [Symbol.asyncIterator](options?: { - preventCancel?: boolean; - }): AsyncIterableIterator; -} diff --git a/cli/dts/lib.dom.d.ts b/cli/dts/lib.dom.d.ts deleted file mode 100644 index 6f9964efc..000000000 --- a/cli/dts/lib.dom.d.ts +++ /dev/null @@ -1,18269 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - - - -/// -/// - - -///////////////////////////// -/// Window APIs -///////////////////////////// - -interface AddEventListenerOptions extends EventListenerOptions { - once?: boolean; - passive?: boolean; - signal?: AbortSignal; -} - -interface AesCbcParams extends Algorithm { - iv: BufferSource; -} - -interface AesCtrParams extends Algorithm { - counter: BufferSource; - length: number; -} - -interface AesDerivedKeyParams extends Algorithm { - length: number; -} - -interface AesGcmParams extends Algorithm { - additionalData?: BufferSource; - iv: BufferSource; - tagLength?: number; -} - -interface AesKeyAlgorithm extends KeyAlgorithm { - length: number; -} - -interface AesKeyGenParams extends Algorithm { - length: number; -} - -interface Algorithm { - name: string; -} - -interface AnalyserOptions extends AudioNodeOptions { - fftSize?: number; - maxDecibels?: number; - minDecibels?: number; - smoothingTimeConstant?: number; -} - -interface AnimationEventInit extends EventInit { - animationName?: string; - elapsedTime?: number; - pseudoElement?: string; -} - -interface AnimationPlaybackEventInit extends EventInit { - currentTime?: CSSNumberish | null; - timelineTime?: CSSNumberish | null; -} - -interface AssignedNodesOptions { - flatten?: boolean; -} - -interface AudioBufferOptions { - length: number; - numberOfChannels?: number; - sampleRate: number; -} - -interface AudioBufferSourceOptions { - buffer?: AudioBuffer | null; - detune?: number; - loop?: boolean; - loopEnd?: number; - loopStart?: number; - playbackRate?: number; -} - -interface AudioConfiguration { - bitrate?: number; - channels?: string; - contentType: string; - samplerate?: number; - spatialRendering?: boolean; -} - -interface AudioContextOptions { - latencyHint?: AudioContextLatencyCategory | number; - sampleRate?: number; -} - -interface AudioNodeOptions { - channelCount?: number; - channelCountMode?: ChannelCountMode; - channelInterpretation?: ChannelInterpretation; -} - -interface AudioProcessingEventInit extends EventInit { - inputBuffer: AudioBuffer; - outputBuffer: AudioBuffer; - playbackTime: number; -} - -interface AudioTimestamp { - contextTime?: number; - performanceTime?: DOMHighResTimeStamp; -} - -interface AudioWorkletNodeOptions extends AudioNodeOptions { - numberOfInputs?: number; - numberOfOutputs?: number; - outputChannelCount?: number[]; - parameterData?: Record; - processorOptions?: any; -} - -interface AuthenticationExtensionsClientInputs { - appid?: string; - appidExclude?: string; - credProps?: boolean; - uvm?: boolean; -} - -interface AuthenticationExtensionsClientOutputs { - appid?: boolean; - credProps?: CredentialPropertiesOutput; - uvm?: UvmEntries; -} - -interface AuthenticatorSelectionCriteria { - authenticatorAttachment?: AuthenticatorAttachment; - requireResidentKey?: boolean; - residentKey?: ResidentKeyRequirement; - userVerification?: UserVerificationRequirement; -} - -interface BiquadFilterOptions extends AudioNodeOptions { - Q?: number; - detune?: number; - frequency?: number; - gain?: number; - type?: BiquadFilterType; -} - -interface BlobEventInit { - data: Blob; - timecode?: DOMHighResTimeStamp; -} - -interface BlobPropertyBag { - endings?: EndingType; - type?: string; -} - -interface CSSStyleSheetInit { - baseURL?: string; - disabled?: boolean; - media?: MediaList | string; -} - -interface CacheQueryOptions { - ignoreMethod?: boolean; - ignoreSearch?: boolean; - ignoreVary?: boolean; -} - -interface CanvasRenderingContext2DSettings { - alpha?: boolean; - colorSpace?: PredefinedColorSpace; - desynchronized?: boolean; - willReadFrequently?: boolean; -} - -interface ChannelMergerOptions extends AudioNodeOptions { - numberOfInputs?: number; -} - -interface ChannelSplitterOptions extends AudioNodeOptions { - numberOfOutputs?: number; -} - -interface ClientQueryOptions { - includeUncontrolled?: boolean; - type?: ClientTypes; -} - -interface ClipboardEventInit extends EventInit { - clipboardData?: DataTransfer | null; -} - -interface ClipboardItemOptions { - presentationStyle?: PresentationStyle; -} - -interface CloseEventInit extends EventInit { - code?: number; - reason?: string; - wasClean?: boolean; -} - -interface CompositionEventInit extends UIEventInit { - data?: string; -} - -interface ComputedEffectTiming extends EffectTiming { - activeDuration?: CSSNumberish; - currentIteration?: number | null; - endTime?: CSSNumberish; - localTime?: CSSNumberish | null; - progress?: number | null; - startTime?: CSSNumberish; -} - -interface ComputedKeyframe { - composite: CompositeOperationOrAuto; - computedOffset: number; - easing: string; - offset: number | null; - [property: string]: string | number | null | undefined; -} - -interface ConstantSourceOptions { - offset?: number; -} - -interface ConstrainBooleanParameters { - exact?: boolean; - ideal?: boolean; -} - -interface ConstrainDOMStringParameters { - exact?: string | string[]; - ideal?: string | string[]; -} - -interface ConstrainDoubleRange extends DoubleRange { - exact?: number; - ideal?: number; -} - -interface ConstrainULongRange extends ULongRange { - exact?: number; - ideal?: number; -} - -interface ConvolverOptions extends AudioNodeOptions { - buffer?: AudioBuffer | null; - disableNormalization?: boolean; -} - -interface CredentialCreationOptions { - publicKey?: PublicKeyCredentialCreationOptions; - signal?: AbortSignal; -} - -interface CredentialPropertiesOutput { - rk?: boolean; -} - -interface CredentialRequestOptions { - mediation?: CredentialMediationRequirement; - publicKey?: PublicKeyCredentialRequestOptions; - signal?: AbortSignal; -} - -interface CryptoKeyPair { - privateKey: CryptoKey; - publicKey: CryptoKey; -} - -interface CustomEventInit extends EventInit { - detail?: T; -} - -interface DOMMatrix2DInit { - a?: number; - b?: number; - c?: number; - d?: number; - e?: number; - f?: number; - m11?: number; - m12?: number; - m21?: number; - m22?: number; - m41?: number; - m42?: number; -} - -interface DOMMatrixInit extends DOMMatrix2DInit { - is2D?: boolean; - m13?: number; - m14?: number; - m23?: number; - m24?: number; - m31?: number; - m32?: number; - m33?: number; - m34?: number; - m43?: number; - m44?: number; -} - -interface DOMPointInit { - w?: number; - x?: number; - y?: number; - z?: number; -} - -interface DOMQuadInit { - p1?: DOMPointInit; - p2?: DOMPointInit; - p3?: DOMPointInit; - p4?: DOMPointInit; -} - -interface DOMRectInit { - height?: number; - width?: number; - x?: number; - y?: number; -} - -interface DelayOptions extends AudioNodeOptions { - delayTime?: number; - maxDelayTime?: number; -} - -interface DeviceMotionEventAccelerationInit { - x?: number | null; - y?: number | null; - z?: number | null; -} - -interface DeviceMotionEventInit extends EventInit { - acceleration?: DeviceMotionEventAccelerationInit; - accelerationIncludingGravity?: DeviceMotionEventAccelerationInit; - interval?: number; - rotationRate?: DeviceMotionEventRotationRateInit; -} - -interface DeviceMotionEventRotationRateInit { - alpha?: number | null; - beta?: number | null; - gamma?: number | null; -} - -interface DeviceOrientationEventInit extends EventInit { - absolute?: boolean; - alpha?: number | null; - beta?: number | null; - gamma?: number | null; -} - -interface DisplayMediaStreamConstraints { - audio?: boolean | MediaTrackConstraints; - video?: boolean | MediaTrackConstraints; -} - -interface DocumentTimelineOptions { - originTime?: DOMHighResTimeStamp; -} - -interface DoubleRange { - max?: number; - min?: number; -} - -interface DragEventInit extends MouseEventInit { - dataTransfer?: DataTransfer | null; -} - -interface DynamicsCompressorOptions extends AudioNodeOptions { - attack?: number; - knee?: number; - ratio?: number; - release?: number; - threshold?: number; -} - -interface EcKeyAlgorithm extends KeyAlgorithm { - namedCurve: NamedCurve; -} - -interface EcKeyGenParams extends Algorithm { - namedCurve: NamedCurve; -} - -interface EcKeyImportParams extends Algorithm { - namedCurve: NamedCurve; -} - -interface EcdhKeyDeriveParams extends Algorithm { - public: CryptoKey; -} - -interface EcdsaParams extends Algorithm { - hash: HashAlgorithmIdentifier; -} - -interface EffectTiming { - delay?: number; - direction?: PlaybackDirection; - duration?: number | string; - easing?: string; - endDelay?: number; - fill?: FillMode; - iterationStart?: number; - iterations?: number; - playbackRate?: number; -} - -interface ElementCreationOptions { - is?: string; -} - -interface ElementDefinitionOptions { - extends?: string; -} - -interface ErrorEventInit extends EventInit { - colno?: number; - error?: any; - filename?: string; - lineno?: number; - message?: string; -} - -interface EventInit { - bubbles?: boolean; - cancelable?: boolean; - composed?: boolean; -} - -interface EventListenerOptions { - capture?: boolean; -} - -interface EventModifierInit extends UIEventInit { - altKey?: boolean; - ctrlKey?: boolean; - metaKey?: boolean; - modifierAltGraph?: boolean; - modifierCapsLock?: boolean; - modifierFn?: boolean; - modifierFnLock?: boolean; - modifierHyper?: boolean; - modifierNumLock?: boolean; - modifierScrollLock?: boolean; - modifierSuper?: boolean; - modifierSymbol?: boolean; - modifierSymbolLock?: boolean; - shiftKey?: boolean; -} - -interface EventSourceInit { - withCredentials?: boolean; -} - -interface FilePropertyBag extends BlobPropertyBag { - lastModified?: number; -} - -interface FileSystemFlags { - create?: boolean; - exclusive?: boolean; -} - -interface FileSystemGetDirectoryOptions { - create?: boolean; -} - -interface FileSystemGetFileOptions { - create?: boolean; -} - -interface FileSystemRemoveOptions { - recursive?: boolean; -} - -interface FocusEventInit extends UIEventInit { - relatedTarget?: EventTarget | null; -} - -interface FocusOptions { - preventScroll?: boolean; -} - -interface FontFaceDescriptors { - display?: string; - featureSettings?: string; - stretch?: string; - style?: string; - unicodeRange?: string; - variant?: string; - weight?: string; -} - -interface FontFaceSetLoadEventInit extends EventInit { - fontfaces?: FontFace[]; -} - -interface FormDataEventInit extends EventInit { - formData: FormData; -} - -interface FullscreenOptions { - navigationUI?: FullscreenNavigationUI; -} - -interface GainOptions extends AudioNodeOptions { - gain?: number; -} - -interface GamepadEventInit extends EventInit { - gamepad: Gamepad; -} - -interface GetAnimationsOptions { - subtree?: boolean; -} - -interface GetNotificationOptions { - tag?: string; -} - -interface GetRootNodeOptions { - composed?: boolean; -} - -interface HashChangeEventInit extends EventInit { - newURL?: string; - oldURL?: string; -} - -interface HkdfParams extends Algorithm { - hash: HashAlgorithmIdentifier; - info: BufferSource; - salt: BufferSource; -} - -interface HmacImportParams extends Algorithm { - hash: HashAlgorithmIdentifier; - length?: number; -} - -interface HmacKeyAlgorithm extends KeyAlgorithm { - hash: KeyAlgorithm; - length: number; -} - -interface HmacKeyGenParams extends Algorithm { - hash: HashAlgorithmIdentifier; - length?: number; -} - -interface IDBDatabaseInfo { - name?: string; - version?: number; -} - -interface IDBIndexParameters { - multiEntry?: boolean; - unique?: boolean; -} - -interface IDBObjectStoreParameters { - autoIncrement?: boolean; - keyPath?: string | string[] | null; -} - -interface IDBTransactionOptions { - durability?: IDBTransactionDurability; -} - -interface IDBVersionChangeEventInit extends EventInit { - newVersion?: number | null; - oldVersion?: number; -} - -interface IIRFilterOptions extends AudioNodeOptions { - feedback: number[]; - feedforward: number[]; -} - -interface IdleRequestOptions { - timeout?: number; -} - -interface ImageBitmapOptions { - colorSpaceConversion?: ColorSpaceConversion; - imageOrientation?: ImageOrientation; - premultiplyAlpha?: PremultiplyAlpha; - resizeHeight?: number; - resizeQuality?: ResizeQuality; - resizeWidth?: number; -} - -interface ImageBitmapRenderingContextSettings { - alpha?: boolean; -} - -interface ImageDataSettings { - colorSpace?: PredefinedColorSpace; -} - -interface ImportMeta { - url: string; -} - -interface InputEventInit extends UIEventInit { - data?: string | null; - dataTransfer?: DataTransfer | null; - inputType?: string; - isComposing?: boolean; - targetRanges?: StaticRange[]; -} - -interface IntersectionObserverEntryInit { - boundingClientRect: DOMRectInit; - intersectionRatio: number; - intersectionRect: DOMRectInit; - isIntersecting: boolean; - rootBounds: DOMRectInit | null; - target: Element; - time: DOMHighResTimeStamp; -} - -interface IntersectionObserverInit { - root?: Element | Document | null; - rootMargin?: string; - threshold?: number | number[]; -} - -interface JsonWebKey { - alg?: string; - crv?: string; - d?: string; - dp?: string; - dq?: string; - e?: string; - ext?: boolean; - k?: string; - key_ops?: string[]; - kty?: string; - n?: string; - oth?: RsaOtherPrimesInfo[]; - p?: string; - q?: string; - qi?: string; - use?: string; - x?: string; - y?: string; -} - -interface KeyAlgorithm { - name: string; -} - -interface KeyboardEventInit extends EventModifierInit { - /** @deprecated */ - charCode?: number; - code?: string; - isComposing?: boolean; - key?: string; - /** @deprecated */ - keyCode?: number; - location?: number; - repeat?: boolean; -} - -interface Keyframe { - composite?: CompositeOperationOrAuto; - easing?: string; - offset?: number | null; - [property: string]: string | number | null | undefined; -} - -interface KeyframeAnimationOptions extends KeyframeEffectOptions { - id?: string; -} - -interface KeyframeEffectOptions extends EffectTiming { - composite?: CompositeOperation; - iterationComposite?: IterationCompositeOperation; - pseudoElement?: string | null; -} - -interface LockInfo { - clientId?: string; - mode?: LockMode; - name?: string; -} - -interface LockManagerSnapshot { - held?: LockInfo[]; - pending?: LockInfo[]; -} - -interface LockOptions { - ifAvailable?: boolean; - mode?: LockMode; - signal?: AbortSignal; - steal?: boolean; -} - -interface MediaCapabilitiesDecodingInfo extends MediaCapabilitiesInfo { - configuration?: MediaDecodingConfiguration; -} - -interface MediaCapabilitiesEncodingInfo extends MediaCapabilitiesInfo { - configuration?: MediaEncodingConfiguration; -} - -interface MediaCapabilitiesInfo { - powerEfficient: boolean; - smooth: boolean; - supported: boolean; -} - -interface MediaConfiguration { - audio?: AudioConfiguration; - video?: VideoConfiguration; -} - -interface MediaDecodingConfiguration extends MediaConfiguration { - type: MediaDecodingType; -} - -interface MediaElementAudioSourceOptions { - mediaElement: HTMLMediaElement; -} - -interface MediaEncodingConfiguration extends MediaConfiguration { - type: MediaEncodingType; -} - -interface MediaEncryptedEventInit extends EventInit { - initData?: ArrayBuffer | null; - initDataType?: string; -} - -interface MediaImage { - sizes?: string; - src: string; - type?: string; -} - -interface MediaKeyMessageEventInit extends EventInit { - message: ArrayBuffer; - messageType: MediaKeyMessageType; -} - -interface MediaKeySystemConfiguration { - audioCapabilities?: MediaKeySystemMediaCapability[]; - distinctiveIdentifier?: MediaKeysRequirement; - initDataTypes?: string[]; - label?: string; - persistentState?: MediaKeysRequirement; - sessionTypes?: string[]; - videoCapabilities?: MediaKeySystemMediaCapability[]; -} - -interface MediaKeySystemMediaCapability { - contentType?: string; - encryptionScheme?: string | null; - robustness?: string; -} - -interface MediaMetadataInit { - album?: string; - artist?: string; - artwork?: MediaImage[]; - title?: string; -} - -interface MediaPositionState { - duration?: number; - playbackRate?: number; - position?: number; -} - -interface MediaQueryListEventInit extends EventInit { - matches?: boolean; - media?: string; -} - -interface MediaRecorderErrorEventInit extends EventInit { - error: DOMException; -} - -interface MediaRecorderOptions { - audioBitsPerSecond?: number; - bitsPerSecond?: number; - mimeType?: string; - videoBitsPerSecond?: number; -} - -interface MediaSessionActionDetails { - action: MediaSessionAction; - fastSeek?: boolean | null; - seekOffset?: number | null; - seekTime?: number | null; -} - -interface MediaStreamAudioSourceOptions { - mediaStream: MediaStream; -} - -interface MediaStreamConstraints { - audio?: boolean | MediaTrackConstraints; - peerIdentity?: string; - preferCurrentTab?: boolean; - video?: boolean | MediaTrackConstraints; -} - -interface MediaStreamTrackEventInit extends EventInit { - track: MediaStreamTrack; -} - -interface MediaTrackCapabilities { - aspectRatio?: DoubleRange; - autoGainControl?: boolean[]; - channelCount?: ULongRange; - cursor?: string[]; - deviceId?: string; - displaySurface?: string; - echoCancellation?: boolean[]; - facingMode?: string[]; - frameRate?: DoubleRange; - groupId?: string; - height?: ULongRange; - latency?: DoubleRange; - logicalSurface?: boolean; - noiseSuppression?: boolean[]; - resizeMode?: string[]; - sampleRate?: ULongRange; - sampleSize?: ULongRange; - width?: ULongRange; -} - -interface MediaTrackConstraintSet { - aspectRatio?: ConstrainDouble; - autoGainControl?: ConstrainBoolean; - channelCount?: ConstrainULong; - deviceId?: ConstrainDOMString; - echoCancellation?: ConstrainBoolean; - facingMode?: ConstrainDOMString; - frameRate?: ConstrainDouble; - groupId?: ConstrainDOMString; - height?: ConstrainULong; - latency?: ConstrainDouble; - noiseSuppression?: ConstrainBoolean; - sampleRate?: ConstrainULong; - sampleSize?: ConstrainULong; - suppressLocalAudioPlayback?: ConstrainBoolean; - width?: ConstrainULong; -} - -interface MediaTrackConstraints extends MediaTrackConstraintSet { - advanced?: MediaTrackConstraintSet[]; -} - -interface MediaTrackSettings { - aspectRatio?: number; - autoGainControl?: boolean; - deviceId?: string; - echoCancellation?: boolean; - facingMode?: string; - frameRate?: number; - groupId?: string; - height?: number; - noiseSuppression?: boolean; - restrictOwnAudio?: boolean; - sampleRate?: number; - sampleSize?: number; - width?: number; -} - -interface MediaTrackSupportedConstraints { - aspectRatio?: boolean; - autoGainControl?: boolean; - deviceId?: boolean; - echoCancellation?: boolean; - facingMode?: boolean; - frameRate?: boolean; - groupId?: boolean; - height?: boolean; - noiseSuppression?: boolean; - sampleRate?: boolean; - sampleSize?: boolean; - suppressLocalAudioPlayback?: boolean; - width?: boolean; -} - -interface MessageEventInit extends EventInit { - data?: T; - lastEventId?: string; - origin?: string; - ports?: MessagePort[]; - source?: MessageEventSource | null; -} - -interface MouseEventInit extends EventModifierInit { - button?: number; - buttons?: number; - clientX?: number; - clientY?: number; - movementX?: number; - movementY?: number; - relatedTarget?: EventTarget | null; - screenX?: number; - screenY?: number; -} - -interface MultiCacheQueryOptions extends CacheQueryOptions { - cacheName?: string; -} - -interface MutationObserverInit { - /** Set to a list of attribute local names (without namespace) if not all attribute mutations need to be observed and attributes is true or omitted. */ - attributeFilter?: string[]; - /** Set to true if attributes is true or omitted and target's attribute value before the mutation needs to be recorded. */ - attributeOldValue?: boolean; - /** Set to true if mutations to target's attributes are to be observed. Can be omitted if attributeOldValue or attributeFilter is specified. */ - attributes?: boolean; - /** Set to true if mutations to target's data are to be observed. Can be omitted if characterDataOldValue is specified. */ - characterData?: boolean; - /** Set to true if characterData is set to true or omitted and target's data before the mutation needs to be recorded. */ - characterDataOldValue?: boolean; - /** Set to true if mutations to target's children are to be observed. */ - childList?: boolean; - /** Set to true if mutations to not just target, but also target's descendants are to be observed. */ - subtree?: boolean; -} - -interface NavigationPreloadState { - enabled?: boolean; - headerValue?: string; -} - -interface NotificationAction { - action: string; - icon?: string; - title: string; -} - -interface NotificationOptions { - actions?: NotificationAction[]; - badge?: string; - body?: string; - data?: any; - dir?: NotificationDirection; - icon?: string; - image?: string; - lang?: string; - renotify?: boolean; - requireInteraction?: boolean; - silent?: boolean; - tag?: string; - timestamp?: EpochTimeStamp; - vibrate?: VibratePattern; -} - -interface OfflineAudioCompletionEventInit extends EventInit { - renderedBuffer: AudioBuffer; -} - -interface OfflineAudioContextOptions { - length: number; - numberOfChannels?: number; - sampleRate: number; -} - -interface OptionalEffectTiming { - delay?: number; - direction?: PlaybackDirection; - duration?: number | string; - easing?: string; - endDelay?: number; - fill?: FillMode; - iterationStart?: number; - iterations?: number; - playbackRate?: number; -} - -interface OscillatorOptions extends AudioNodeOptions { - detune?: number; - frequency?: number; - periodicWave?: PeriodicWave; - type?: OscillatorType; -} - -interface PageTransitionEventInit extends EventInit { - persisted?: boolean; -} - -interface PannerOptions extends AudioNodeOptions { - coneInnerAngle?: number; - coneOuterAngle?: number; - coneOuterGain?: number; - distanceModel?: DistanceModelType; - maxDistance?: number; - orientationX?: number; - orientationY?: number; - orientationZ?: number; - panningModel?: PanningModelType; - positionX?: number; - positionY?: number; - positionZ?: number; - refDistance?: number; - rolloffFactor?: number; -} - -interface PaymentCurrencyAmount { - currency: string; - value: string; -} - -interface PaymentDetailsBase { - displayItems?: PaymentItem[]; - modifiers?: PaymentDetailsModifier[]; -} - -interface PaymentDetailsInit extends PaymentDetailsBase { - id?: string; - total: PaymentItem; -} - -interface PaymentDetailsModifier { - additionalDisplayItems?: PaymentItem[]; - data?: any; - supportedMethods: string; - total?: PaymentItem; -} - -interface PaymentDetailsUpdate extends PaymentDetailsBase { - paymentMethodErrors?: any; - total?: PaymentItem; -} - -interface PaymentItem { - amount: PaymentCurrencyAmount; - label: string; - pending?: boolean; -} - -interface PaymentMethodChangeEventInit extends PaymentRequestUpdateEventInit { - methodDetails?: any; - methodName?: string; -} - -interface PaymentMethodData { - data?: any; - supportedMethods: string; -} - -interface PaymentRequestUpdateEventInit extends EventInit { -} - -interface PaymentValidationErrors { - error?: string; - paymentMethod?: any; -} - -interface Pbkdf2Params extends Algorithm { - hash: HashAlgorithmIdentifier; - iterations: number; - salt: BufferSource; -} - -interface PerformanceMarkOptions { - detail?: any; - startTime?: DOMHighResTimeStamp; -} - -interface PerformanceMeasureOptions { - detail?: any; - duration?: DOMHighResTimeStamp; - end?: string | DOMHighResTimeStamp; - start?: string | DOMHighResTimeStamp; -} - -interface PerformanceObserverInit { - buffered?: boolean; - entryTypes?: string[]; - type?: string; -} - -interface PeriodicWaveConstraints { - disableNormalization?: boolean; -} - -interface PeriodicWaveOptions extends PeriodicWaveConstraints { - imag?: number[] | Float32Array; - real?: number[] | Float32Array; -} - -interface PermissionDescriptor { - name: PermissionName; -} - -interface PointerEventInit extends MouseEventInit { - coalescedEvents?: PointerEvent[]; - height?: number; - isPrimary?: boolean; - pointerId?: number; - pointerType?: string; - predictedEvents?: PointerEvent[]; - pressure?: number; - tangentialPressure?: number; - tiltX?: number; - tiltY?: number; - twist?: number; - width?: number; -} - -interface PopStateEventInit extends EventInit { - state?: any; -} - -interface PositionOptions { - enableHighAccuracy?: boolean; - maximumAge?: number; - timeout?: number; -} - -interface ProgressEventInit extends EventInit { - lengthComputable?: boolean; - loaded?: number; - total?: number; -} - -interface PromiseRejectionEventInit extends EventInit { - promise: Promise; - reason?: any; -} - -interface PropertyIndexedKeyframes { - composite?: CompositeOperationOrAuto | CompositeOperationOrAuto[]; - easing?: string | string[]; - offset?: number | (number | null)[]; - [property: string]: string | string[] | number | null | (number | null)[] | undefined; -} - -interface PublicKeyCredentialCreationOptions { - attestation?: AttestationConveyancePreference; - authenticatorSelection?: AuthenticatorSelectionCriteria; - challenge: BufferSource; - excludeCredentials?: PublicKeyCredentialDescriptor[]; - extensions?: AuthenticationExtensionsClientInputs; - pubKeyCredParams: PublicKeyCredentialParameters[]; - rp: PublicKeyCredentialRpEntity; - timeout?: number; - user: PublicKeyCredentialUserEntity; -} - -interface PublicKeyCredentialDescriptor { - id: BufferSource; - transports?: AuthenticatorTransport[]; - type: PublicKeyCredentialType; -} - -interface PublicKeyCredentialEntity { - name: string; -} - -interface PublicKeyCredentialParameters { - alg: COSEAlgorithmIdentifier; - type: PublicKeyCredentialType; -} - -interface PublicKeyCredentialRequestOptions { - allowCredentials?: PublicKeyCredentialDescriptor[]; - challenge: BufferSource; - extensions?: AuthenticationExtensionsClientInputs; - rpId?: string; - timeout?: number; - userVerification?: UserVerificationRequirement; -} - -interface PublicKeyCredentialRpEntity extends PublicKeyCredentialEntity { - id?: string; -} - -interface PublicKeyCredentialUserEntity extends PublicKeyCredentialEntity { - displayName: string; - id: BufferSource; -} - -interface PushSubscriptionJSON { - endpoint?: string; - expirationTime?: EpochTimeStamp | null; - keys?: Record; -} - -interface PushSubscriptionOptionsInit { - applicationServerKey?: BufferSource | string | null; - userVisibleOnly?: boolean; -} - -interface QueuingStrategy { - highWaterMark?: number; - size?: QueuingStrategySize; -} - -interface QueuingStrategyInit { - /** - * Creates a new ByteLengthQueuingStrategy with the provided high water mark. - * - * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw. - */ - highWaterMark: number; -} - -interface RTCAnswerOptions extends RTCOfferAnswerOptions { -} - -interface RTCCertificateExpiration { - expires?: number; -} - -interface RTCConfiguration { - bundlePolicy?: RTCBundlePolicy; - certificates?: RTCCertificate[]; - iceCandidatePoolSize?: number; - iceServers?: RTCIceServer[]; - iceTransportPolicy?: RTCIceTransportPolicy; - rtcpMuxPolicy?: RTCRtcpMuxPolicy; -} - -interface RTCDTMFToneChangeEventInit extends EventInit { - tone?: string; -} - -interface RTCDataChannelEventInit extends EventInit { - channel: RTCDataChannel; -} - -interface RTCDataChannelInit { - id?: number; - maxPacketLifeTime?: number; - maxRetransmits?: number; - negotiated?: boolean; - ordered?: boolean; - protocol?: string; -} - -interface RTCDtlsFingerprint { - algorithm?: string; - value?: string; -} - -interface RTCEncodedAudioFrameMetadata { - contributingSources?: number[]; - synchronizationSource?: number; -} - -interface RTCEncodedVideoFrameMetadata { - contributingSources?: number[]; - dependencies?: number[]; - frameId?: number; - height?: number; - spatialIndex?: number; - synchronizationSource?: number; - temporalIndex?: number; - width?: number; -} - -interface RTCErrorEventInit extends EventInit { - error: RTCError; -} - -interface RTCErrorInit { - errorDetail: RTCErrorDetailType; - httpRequestStatusCode?: number; - receivedAlert?: number; - sctpCauseCode?: number; - sdpLineNumber?: number; - sentAlert?: number; -} - -interface RTCIceCandidateInit { - candidate?: string; - sdpMLineIndex?: number | null; - sdpMid?: string | null; - usernameFragment?: string | null; -} - -interface RTCIceCandidatePairStats extends RTCStats { - availableIncomingBitrate?: number; - availableOutgoingBitrate?: number; - bytesReceived?: number; - bytesSent?: number; - currentRoundTripTime?: number; - localCandidateId: string; - nominated?: boolean; - remoteCandidateId: string; - requestsReceived?: number; - requestsSent?: number; - responsesReceived?: number; - responsesSent?: number; - state: RTCStatsIceCandidatePairState; - totalRoundTripTime?: number; - transportId: string; -} - -interface RTCIceServer { - credential?: string; - credentialType?: RTCIceCredentialType; - urls: string | string[]; - username?: string; -} - -interface RTCInboundRtpStreamStats extends RTCReceivedRtpStreamStats { - firCount?: number; - framesDecoded?: number; - nackCount?: number; - pliCount?: number; - qpSum?: number; - remoteId?: string; -} - -interface RTCLocalSessionDescriptionInit { - sdp?: string; - type?: RTCSdpType; -} - -interface RTCOfferAnswerOptions { -} - -interface RTCOfferOptions extends RTCOfferAnswerOptions { - iceRestart?: boolean; - offerToReceiveAudio?: boolean; - offerToReceiveVideo?: boolean; -} - -interface RTCOutboundRtpStreamStats extends RTCSentRtpStreamStats { - firCount?: number; - framesEncoded?: number; - nackCount?: number; - pliCount?: number; - qpSum?: number; - remoteId?: string; -} - -interface RTCPeerConnectionIceErrorEventInit extends EventInit { - address?: string | null; - errorCode: number; - errorText?: string; - port?: number | null; - url?: string; -} - -interface RTCPeerConnectionIceEventInit extends EventInit { - candidate?: RTCIceCandidate | null; - url?: string | null; -} - -interface RTCReceivedRtpStreamStats extends RTCRtpStreamStats { - jitter?: number; - packetsDiscarded?: number; - packetsLost?: number; - packetsReceived?: number; -} - -interface RTCRtcpParameters { - cname?: string; - reducedSize?: boolean; -} - -interface RTCRtpCapabilities { - codecs: RTCRtpCodecCapability[]; - headerExtensions: RTCRtpHeaderExtensionCapability[]; -} - -interface RTCRtpCodecCapability { - channels?: number; - clockRate: number; - mimeType: string; - sdpFmtpLine?: string; -} - -interface RTCRtpCodecParameters { - channels?: number; - clockRate: number; - mimeType: string; - payloadType: number; - sdpFmtpLine?: string; -} - -interface RTCRtpCodingParameters { - rid?: string; -} - -interface RTCRtpContributingSource { - audioLevel?: number; - rtpTimestamp: number; - source: number; - timestamp: DOMHighResTimeStamp; -} - -interface RTCRtpEncodingParameters extends RTCRtpCodingParameters { - active?: boolean; - maxBitrate?: number; - priority?: RTCPriorityType; - scaleResolutionDownBy?: number; -} - -interface RTCRtpHeaderExtensionCapability { - uri?: string; -} - -interface RTCRtpHeaderExtensionParameters { - encrypted?: boolean; - id: number; - uri: string; -} - -interface RTCRtpParameters { - codecs: RTCRtpCodecParameters[]; - headerExtensions: RTCRtpHeaderExtensionParameters[]; - rtcp: RTCRtcpParameters; -} - -interface RTCRtpReceiveParameters extends RTCRtpParameters { -} - -interface RTCRtpSendParameters extends RTCRtpParameters { - degradationPreference?: RTCDegradationPreference; - encodings: RTCRtpEncodingParameters[]; - transactionId: string; -} - -interface RTCRtpStreamStats extends RTCStats { - codecId?: string; - kind: string; - ssrc: number; - transportId?: string; -} - -interface RTCRtpSynchronizationSource extends RTCRtpContributingSource { -} - -interface RTCRtpTransceiverInit { - direction?: RTCRtpTransceiverDirection; - sendEncodings?: RTCRtpEncodingParameters[]; - streams?: MediaStream[]; -} - -interface RTCSentRtpStreamStats extends RTCRtpStreamStats { - bytesSent?: number; - packetsSent?: number; -} - -interface RTCSessionDescriptionInit { - sdp?: string; - type: RTCSdpType; -} - -interface RTCStats { - id: string; - timestamp: DOMHighResTimeStamp; - type: RTCStatsType; -} - -interface RTCTrackEventInit extends EventInit { - receiver: RTCRtpReceiver; - streams?: MediaStream[]; - track: MediaStreamTrack; - transceiver: RTCRtpTransceiver; -} - -interface RTCTransportStats extends RTCStats { - bytesReceived?: number; - bytesSent?: number; - dtlsCipher?: string; - dtlsState: RTCDtlsTransportState; - localCertificateId?: string; - remoteCertificateId?: string; - rtcpTransportStatsId?: string; - selectedCandidatePairId?: string; - srtpCipher?: string; - tlsVersion?: string; -} - -interface ReadableStreamReadDoneResult { - done: true; - value?: undefined; -} - -interface ReadableStreamReadValueResult { - done: false; - value: T; -} - -interface ReadableWritablePair { - readable: ReadableStream; - /** - * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use. - * - * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. - */ - writable: WritableStream; -} - -interface RegistrationOptions { - scope?: string; - type?: WorkerType; - updateViaCache?: ServiceWorkerUpdateViaCache; -} - -interface RequestInit { - /** A BodyInit object or null to set request's body. */ - body?: BodyInit | null; - /** A string indicating how the request will interact with the browser's cache to set request's cache. */ - cache?: RequestCache; - /** A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. */ - credentials?: RequestCredentials; - /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */ - headers?: HeadersInit; - /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */ - integrity?: string; - /** A boolean to set request's keepalive. */ - keepalive?: boolean; - /** A string to set request's method. */ - method?: string; - /** A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. */ - mode?: RequestMode; - /** A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */ - redirect?: RequestRedirect; - /** A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. */ - referrer?: string; - /** A referrer policy to set request's referrerPolicy. */ - referrerPolicy?: ReferrerPolicy; - /** An AbortSignal to set request's signal. */ - signal?: AbortSignal | null; - /** Can only be null. Used to disassociate request from any Window. */ - window?: null; -} - -interface ResizeObserverOptions { - box?: ResizeObserverBoxOptions; -} - -interface ResponseInit { - headers?: HeadersInit; - status?: number; - statusText?: string; -} - -interface RsaHashedImportParams extends Algorithm { - hash: HashAlgorithmIdentifier; -} - -interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm { - hash: KeyAlgorithm; -} - -interface RsaHashedKeyGenParams extends RsaKeyGenParams { - hash: HashAlgorithmIdentifier; -} - -interface RsaKeyAlgorithm extends KeyAlgorithm { - modulusLength: number; - publicExponent: BigInteger; -} - -interface RsaKeyGenParams extends Algorithm { - modulusLength: number; - publicExponent: BigInteger; -} - -interface RsaOaepParams extends Algorithm { - label?: BufferSource; -} - -interface RsaOtherPrimesInfo { - d?: string; - r?: string; - t?: string; -} - -interface RsaPssParams extends Algorithm { - saltLength: number; -} - -interface SVGBoundingBoxOptions { - clipped?: boolean; - fill?: boolean; - markers?: boolean; - stroke?: boolean; -} - -interface ScrollIntoViewOptions extends ScrollOptions { - block?: ScrollLogicalPosition; - inline?: ScrollLogicalPosition; -} - -interface ScrollOptions { - behavior?: ScrollBehavior; -} - -interface ScrollToOptions extends ScrollOptions { - left?: number; - top?: number; -} - -interface SecurityPolicyViolationEventInit extends EventInit { - blockedURI?: string; - columnNumber?: number; - disposition: SecurityPolicyViolationEventDisposition; - documentURI: string; - effectiveDirective: string; - lineNumber?: number; - originalPolicy: string; - referrer?: string; - sample?: string; - sourceFile?: string; - statusCode: number; - violatedDirective: string; -} - -interface ShadowRootInit { - delegatesFocus?: boolean; - mode: ShadowRootMode; - slotAssignment?: SlotAssignmentMode; -} - -interface ShareData { - files?: File[]; - text?: string; - title?: string; - url?: string; -} - -interface SpeechSynthesisErrorEventInit extends SpeechSynthesisEventInit { - error: SpeechSynthesisErrorCode; -} - -interface SpeechSynthesisEventInit extends EventInit { - charIndex?: number; - charLength?: number; - elapsedTime?: number; - name?: string; - utterance: SpeechSynthesisUtterance; -} - -interface StaticRangeInit { - endContainer: Node; - endOffset: number; - startContainer: Node; - startOffset: number; -} - -interface StereoPannerOptions extends AudioNodeOptions { - pan?: number; -} - -interface StorageEstimate { - quota?: number; - usage?: number; -} - -interface StorageEventInit extends EventInit { - key?: string | null; - newValue?: string | null; - oldValue?: string | null; - storageArea?: Storage | null; - url?: string; -} - -interface StreamPipeOptions { - preventAbort?: boolean; - preventCancel?: boolean; - /** - * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. - * - * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. - * - * Errors and closures of the source and destination streams propagate as follows: - * - * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination. - * - * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source. - * - * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error. - * - * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source. - * - * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set. - */ - preventClose?: boolean; - signal?: AbortSignal; -} - -interface StructuredSerializeOptions { - transfer?: Transferable[]; -} - -interface SubmitEventInit extends EventInit { - submitter?: HTMLElement | null; -} - -interface TextDecodeOptions { - stream?: boolean; -} - -interface TextDecoderOptions { - fatal?: boolean; - ignoreBOM?: boolean; -} - -interface TextEncoderEncodeIntoResult { - read?: number; - written?: number; -} - -interface TouchEventInit extends EventModifierInit { - changedTouches?: Touch[]; - targetTouches?: Touch[]; - touches?: Touch[]; -} - -interface TouchInit { - altitudeAngle?: number; - azimuthAngle?: number; - clientX?: number; - clientY?: number; - force?: number; - identifier: number; - pageX?: number; - pageY?: number; - radiusX?: number; - radiusY?: number; - rotationAngle?: number; - screenX?: number; - screenY?: number; - target: EventTarget; - touchType?: TouchType; -} - -interface TrackEventInit extends EventInit { - track?: TextTrack | null; -} - -interface Transformer { - flush?: TransformerFlushCallback; - readableType?: undefined; - start?: TransformerStartCallback; - transform?: TransformerTransformCallback; - writableType?: undefined; -} - -interface TransitionEventInit extends EventInit { - elapsedTime?: number; - propertyName?: string; - pseudoElement?: string; -} - -interface UIEventInit extends EventInit { - detail?: number; - view?: Window | null; - /** @deprecated */ - which?: number; -} - -interface ULongRange { - max?: number; - min?: number; -} - -interface UnderlyingSink { - abort?: UnderlyingSinkAbortCallback; - close?: UnderlyingSinkCloseCallback; - start?: UnderlyingSinkStartCallback; - type?: undefined; - write?: UnderlyingSinkWriteCallback; -} - -interface UnderlyingSource { - cancel?: UnderlyingSourceCancelCallback; - pull?: UnderlyingSourcePullCallback; - start?: UnderlyingSourceStartCallback; - type?: undefined; -} - -interface ValidityStateFlags { - badInput?: boolean; - customError?: boolean; - patternMismatch?: boolean; - rangeOverflow?: boolean; - rangeUnderflow?: boolean; - stepMismatch?: boolean; - tooLong?: boolean; - tooShort?: boolean; - typeMismatch?: boolean; - valueMissing?: boolean; -} - -interface VideoColorSpaceInit { - fullRange?: boolean; - matrix?: VideoMatrixCoefficients; - primaries?: VideoColorPrimaries; - transfer?: VideoTransferCharacteristics; -} - -interface VideoConfiguration { - bitrate: number; - colorGamut?: ColorGamut; - contentType: string; - framerate: number; - hdrMetadataType?: HdrMetadataType; - height: number; - scalabilityMode?: string; - transferFunction?: TransferFunction; - width: number; -} - -interface VideoFrameMetadata { - captureTime?: DOMHighResTimeStamp; - expectedDisplayTime: DOMHighResTimeStamp; - height: number; - mediaTime: number; - presentationTime: DOMHighResTimeStamp; - presentedFrames: number; - processingDuration?: number; - receiveTime?: DOMHighResTimeStamp; - rtpTimestamp?: number; - width: number; -} - -interface WaveShaperOptions extends AudioNodeOptions { - curve?: number[] | Float32Array; - oversample?: OverSampleType; -} - -interface WebGLContextAttributes { - alpha?: boolean; - antialias?: boolean; - depth?: boolean; - desynchronized?: boolean; - failIfMajorPerformanceCaveat?: boolean; - powerPreference?: WebGLPowerPreference; - premultipliedAlpha?: boolean; - preserveDrawingBuffer?: boolean; - stencil?: boolean; -} - -interface WebGLContextEventInit extends EventInit { - statusMessage?: string; -} - -interface WheelEventInit extends MouseEventInit { - deltaMode?: number; - deltaX?: number; - deltaY?: number; - deltaZ?: number; -} - -interface WindowPostMessageOptions extends StructuredSerializeOptions { - targetOrigin?: string; -} - -interface WorkerOptions { - credentials?: RequestCredentials; - name?: string; - type?: WorkerType; -} - -interface WorkletOptions { - credentials?: RequestCredentials; -} - -type NodeFilter = ((node: Node) => number) | { acceptNode(node: Node): number; }; - -declare var NodeFilter: { - readonly FILTER_ACCEPT: number; - readonly FILTER_REJECT: number; - readonly FILTER_SKIP: number; - readonly SHOW_ALL: number; - readonly SHOW_ATTRIBUTE: number; - readonly SHOW_CDATA_SECTION: number; - readonly SHOW_COMMENT: number; - readonly SHOW_DOCUMENT: number; - readonly SHOW_DOCUMENT_FRAGMENT: number; - readonly SHOW_DOCUMENT_TYPE: number; - readonly SHOW_ELEMENT: number; - readonly SHOW_ENTITY: number; - readonly SHOW_ENTITY_REFERENCE: number; - readonly SHOW_NOTATION: number; - readonly SHOW_PROCESSING_INSTRUCTION: number; - readonly SHOW_TEXT: number; -}; - -type XPathNSResolver = ((prefix: string | null) => string | null) | { lookupNamespaceURI(prefix: string | null): string | null; }; - -/** The ANGLE_instanced_arrays extension is part of the WebGL API and allows to draw the same object, or groups of similar objects multiple times, if they share the same vertex data, primitive count and type. */ -interface ANGLE_instanced_arrays { - drawArraysInstancedANGLE(mode: GLenum, first: GLint, count: GLsizei, primcount: GLsizei): void; - drawElementsInstancedANGLE(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, primcount: GLsizei): void; - vertexAttribDivisorANGLE(index: GLuint, divisor: GLuint): void; - readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: GLenum; -} - -interface ARIAMixin { - ariaAtomic: string | null; - ariaAutoComplete: string | null; - ariaBusy: string | null; - ariaChecked: string | null; - ariaColCount: string | null; - ariaColIndex: string | null; - ariaColSpan: string | null; - ariaCurrent: string | null; - ariaDisabled: string | null; - ariaExpanded: string | null; - ariaHasPopup: string | null; - ariaHidden: string | null; - ariaKeyShortcuts: string | null; - ariaLabel: string | null; - ariaLevel: string | null; - ariaLive: string | null; - ariaModal: string | null; - ariaMultiLine: string | null; - ariaMultiSelectable: string | null; - ariaOrientation: string | null; - ariaPlaceholder: string | null; - ariaPosInSet: string | null; - ariaPressed: string | null; - ariaReadOnly: string | null; - ariaRequired: string | null; - ariaRoleDescription: string | null; - ariaRowCount: string | null; - ariaRowIndex: string | null; - ariaRowSpan: string | null; - ariaSelected: string | null; - ariaSetSize: string | null; - ariaSort: string | null; - ariaValueMax: string | null; - ariaValueMin: string | null; - ariaValueNow: string | null; - ariaValueText: string | null; -} - -/** A controller object that allows you to abort one or more DOM requests as and when desired. */ -interface AbortController { - /** Returns the AbortSignal object associated with this object. */ - readonly signal: AbortSignal; - /** Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted. */ - abort(reason?: any): void; -} - -declare var AbortController: { - prototype: AbortController; - new(): AbortController; -}; - -interface AbortSignalEventMap { - "abort": Event; -} - -/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */ -interface AbortSignal extends EventTarget { - /** Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */ - readonly aborted: boolean; - onabort: ((this: AbortSignal, ev: Event) => any) | null; - readonly reason: any; - throwIfAborted(): void; - addEventListener(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var AbortSignal: { - prototype: AbortSignal; - new(): AbortSignal; - // abort(): AbortSignal; - To be re-added in the future -}; - -interface AbstractRange { - /** Returns true if range is collapsed, and false otherwise. */ - readonly collapsed: boolean; - /** Returns range's end node. */ - readonly endContainer: Node; - /** Returns range's end offset. */ - readonly endOffset: number; - /** Returns range's start node. */ - readonly startContainer: Node; - /** Returns range's start offset. */ - readonly startOffset: number; -} - -declare var AbstractRange: { - prototype: AbstractRange; - new(): AbstractRange; -}; - -interface AbstractWorkerEventMap { - "error": ErrorEvent; -} - -interface AbstractWorker { - onerror: ((this: AbstractWorker, ev: ErrorEvent) => any) | null; - addEventListener(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -/** A node able to provide real-time frequency and time-domain analysis information. It is an AudioNode that passes the audio stream unchanged from the input to the output, but allows you to take the generated data, process it, and create audio visualizations. */ -interface AnalyserNode extends AudioNode { - fftSize: number; - readonly frequencyBinCount: number; - maxDecibels: number; - minDecibels: number; - smoothingTimeConstant: number; - getByteFrequencyData(array: Uint8Array): void; - getByteTimeDomainData(array: Uint8Array): void; - getFloatFrequencyData(array: Float32Array): void; - getFloatTimeDomainData(array: Float32Array): void; -} - -declare var AnalyserNode: { - prototype: AnalyserNode; - new(context: BaseAudioContext, options?: AnalyserOptions): AnalyserNode; -}; - -interface Animatable { - animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions): Animation; - getAnimations(options?: GetAnimationsOptions): Animation[]; -} - -interface AnimationEventMap { - "cancel": AnimationPlaybackEvent; - "finish": AnimationPlaybackEvent; - "remove": Event; -} - -interface Animation extends EventTarget { - currentTime: CSSNumberish | null; - effect: AnimationEffect | null; - readonly finished: Promise; - id: string; - oncancel: ((this: Animation, ev: AnimationPlaybackEvent) => any) | null; - onfinish: ((this: Animation, ev: AnimationPlaybackEvent) => any) | null; - onremove: ((this: Animation, ev: Event) => any) | null; - readonly pending: boolean; - readonly playState: AnimationPlayState; - playbackRate: number; - readonly ready: Promise; - readonly replaceState: AnimationReplaceState; - startTime: CSSNumberish | null; - timeline: AnimationTimeline | null; - cancel(): void; - commitStyles(): void; - finish(): void; - pause(): void; - persist(): void; - play(): void; - reverse(): void; - updatePlaybackRate(playbackRate: number): void; - addEventListener(type: K, listener: (this: Animation, ev: AnimationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: Animation, ev: AnimationEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var Animation: { - prototype: Animation; - new(effect?: AnimationEffect | null, timeline?: AnimationTimeline | null): Animation; -}; - -interface AnimationEffect { - getComputedTiming(): ComputedEffectTiming; - getTiming(): EffectTiming; - updateTiming(timing?: OptionalEffectTiming): void; -} - -declare var AnimationEffect: { - prototype: AnimationEffect; - new(): AnimationEffect; -}; - -/** Events providing information related to animations. */ -interface AnimationEvent extends Event { - readonly animationName: string; - readonly elapsedTime: number; - readonly pseudoElement: string; -} - -declare var AnimationEvent: { - prototype: AnimationEvent; - new(type: string, animationEventInitDict?: AnimationEventInit): AnimationEvent; -}; - -interface AnimationFrameProvider { - cancelAnimationFrame(handle: number): void; - requestAnimationFrame(callback: FrameRequestCallback): number; -} - -interface AnimationPlaybackEvent extends Event { - readonly currentTime: CSSNumberish | null; - readonly timelineTime: CSSNumberish | null; -} - -declare var AnimationPlaybackEvent: { - prototype: AnimationPlaybackEvent; - new(type: string, eventInitDict?: AnimationPlaybackEventInit): AnimationPlaybackEvent; -}; - -interface AnimationTimeline { - readonly currentTime: number | null; -} - -declare var AnimationTimeline: { - prototype: AnimationTimeline; - new(): AnimationTimeline; -}; - -/** A DOM element's attribute as an object. In most DOM methods, you will probably directly retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g., Element.getAttributeNode()) or means of iterating give Attr types. */ -interface Attr extends Node { - readonly localName: string; - readonly name: string; - readonly namespaceURI: string | null; - readonly ownerDocument: Document; - readonly ownerElement: Element | null; - readonly prefix: string | null; - readonly specified: boolean; - value: string; -} - -declare var Attr: { - prototype: Attr; - new(): Attr; -}; - -/** A short audio asset residing in memory, created from an audio file using the AudioContext.decodeAudioData() method, or from raw data using AudioContext.createBuffer(). Once put into an AudioBuffer, the audio can then be played by being passed into an AudioBufferSourceNode. */ -interface AudioBuffer { - readonly duration: number; - readonly length: number; - readonly numberOfChannels: number; - readonly sampleRate: number; - copyFromChannel(destination: Float32Array, channelNumber: number, bufferOffset?: number): void; - copyToChannel(source: Float32Array, channelNumber: number, bufferOffset?: number): void; - getChannelData(channel: number): Float32Array; -} - -declare var AudioBuffer: { - prototype: AudioBuffer; - new(options: AudioBufferOptions): AudioBuffer; -}; - -/** An AudioScheduledSourceNode which represents an audio source consisting of in-memory audio data, stored in an AudioBuffer. It's especially useful for playing back audio which has particularly stringent timing accuracy requirements, such as for sounds that must match a specific rhythm and can be kept in memory rather than being played from disk or the network. */ -interface AudioBufferSourceNode extends AudioScheduledSourceNode { - buffer: AudioBuffer | null; - readonly detune: AudioParam; - loop: boolean; - loopEnd: number; - loopStart: number; - readonly playbackRate: AudioParam; - start(when?: number, offset?: number, duration?: number): void; - addEventListener(type: K, listener: (this: AudioBufferSourceNode, ev: AudioScheduledSourceNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: AudioBufferSourceNode, ev: AudioScheduledSourceNodeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var AudioBufferSourceNode: { - prototype: AudioBufferSourceNode; - new(context: BaseAudioContext, options?: AudioBufferSourceOptions): AudioBufferSourceNode; -}; - -/** An audio-processing graph built from audio modules linked together, each represented by an AudioNode. */ -interface AudioContext extends BaseAudioContext { - readonly baseLatency: number; - readonly outputLatency: number; - close(): Promise; - createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; - createMediaStreamDestination(): MediaStreamAudioDestinationNode; - createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; - getOutputTimestamp(): AudioTimestamp; - resume(): Promise; - suspend(): Promise; - addEventListener(type: K, listener: (this: AudioContext, ev: BaseAudioContextEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: AudioContext, ev: BaseAudioContextEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var AudioContext: { - prototype: AudioContext; - new(contextOptions?: AudioContextOptions): AudioContext; -}; - -/** AudioDestinationNode has no output (as it is the output, no more AudioNode can be linked after it in the audio graph) and one input. The number of channels in the input must be between 0 and the maxChannelCount value or an exception is raised. */ -interface AudioDestinationNode extends AudioNode { - readonly maxChannelCount: number; -} - -declare var AudioDestinationNode: { - prototype: AudioDestinationNode; - new(): AudioDestinationNode; -}; - -/** The position and orientation of the unique person listening to the audio scene, and is used in audio spatialization. All PannerNodes spatialize in relation to the AudioListener stored in the BaseAudioContext.listener attribute. */ -interface AudioListener { - readonly forwardX: AudioParam; - readonly forwardY: AudioParam; - readonly forwardZ: AudioParam; - readonly positionX: AudioParam; - readonly positionY: AudioParam; - readonly positionZ: AudioParam; - readonly upX: AudioParam; - readonly upY: AudioParam; - readonly upZ: AudioParam; - /** @deprecated */ - setOrientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): void; - /** @deprecated */ - setPosition(x: number, y: number, z: number): void; -} - -declare var AudioListener: { - prototype: AudioListener; - new(): AudioListener; -}; - -/** A generic interface for representing an audio processing module. Examples include: */ -interface AudioNode extends EventTarget { - channelCount: number; - channelCountMode: ChannelCountMode; - channelInterpretation: ChannelInterpretation; - readonly context: BaseAudioContext; - readonly numberOfInputs: number; - readonly numberOfOutputs: number; - connect(destinationNode: AudioNode, output?: number, input?: number): AudioNode; - connect(destinationParam: AudioParam, output?: number): void; - disconnect(): void; - disconnect(output: number): void; - disconnect(destinationNode: AudioNode): void; - disconnect(destinationNode: AudioNode, output: number): void; - disconnect(destinationNode: AudioNode, output: number, input: number): void; - disconnect(destinationParam: AudioParam): void; - disconnect(destinationParam: AudioParam, output: number): void; -} - -declare var AudioNode: { - prototype: AudioNode; - new(): AudioNode; -}; - -/** The Web Audio API's AudioParam interface represents an audio-related parameter, usually a parameter of an AudioNode (such as GainNode.gain). */ -interface AudioParam { - automationRate: AutomationRate; - readonly defaultValue: number; - readonly maxValue: number; - readonly minValue: number; - value: number; - cancelAndHoldAtTime(cancelTime: number): AudioParam; - cancelScheduledValues(cancelTime: number): AudioParam; - exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; - linearRampToValueAtTime(value: number, endTime: number): AudioParam; - setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; - setValueAtTime(value: number, startTime: number): AudioParam; - setValueCurveAtTime(values: number[] | Float32Array, startTime: number, duration: number): AudioParam; -} - -declare var AudioParam: { - prototype: AudioParam; - new(): AudioParam; -}; - -interface AudioParamMap { - forEach(callbackfn: (value: AudioParam, key: string, parent: AudioParamMap) => void, thisArg?: any): void; -} - -declare var AudioParamMap: { - prototype: AudioParamMap; - new(): AudioParamMap; -}; - -/** - * The Web Audio API events that occur when a ScriptProcessorNode input buffer is ready to be processed. - * @deprecated As of the August 29 2014 Web Audio API spec publication, this feature has been marked as deprecated, and is soon to be replaced by AudioWorklet. - */ -interface AudioProcessingEvent extends Event { - /** @deprecated */ - readonly inputBuffer: AudioBuffer; - /** @deprecated */ - readonly outputBuffer: AudioBuffer; - /** @deprecated */ - readonly playbackTime: number; -} - -/** @deprecated */ -declare var AudioProcessingEvent: { - prototype: AudioProcessingEvent; - new(type: string, eventInitDict: AudioProcessingEventInit): AudioProcessingEvent; -}; - -interface AudioScheduledSourceNodeEventMap { - "ended": Event; -} - -interface AudioScheduledSourceNode extends AudioNode { - onended: ((this: AudioScheduledSourceNode, ev: Event) => any) | null; - start(when?: number): void; - stop(when?: number): void; - addEventListener(type: K, listener: (this: AudioScheduledSourceNode, ev: AudioScheduledSourceNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: AudioScheduledSourceNode, ev: AudioScheduledSourceNodeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var AudioScheduledSourceNode: { - prototype: AudioScheduledSourceNode; - new(): AudioScheduledSourceNode; -}; - -/** Available only in secure contexts. */ -interface AudioWorklet extends Worklet { -} - -declare var AudioWorklet: { - prototype: AudioWorklet; - new(): AudioWorklet; -}; - -interface AudioWorkletNodeEventMap { - "processorerror": Event; -} - -/** Available only in secure contexts. */ -interface AudioWorkletNode extends AudioNode { - onprocessorerror: ((this: AudioWorkletNode, ev: Event) => any) | null; - readonly parameters: AudioParamMap; - readonly port: MessagePort; - addEventListener(type: K, listener: (this: AudioWorkletNode, ev: AudioWorkletNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: AudioWorkletNode, ev: AudioWorkletNodeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var AudioWorkletNode: { - prototype: AudioWorkletNode; - new(context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode; -}; - -/** Available only in secure contexts. */ -interface AuthenticatorAssertionResponse extends AuthenticatorResponse { - readonly authenticatorData: ArrayBuffer; - readonly signature: ArrayBuffer; - readonly userHandle: ArrayBuffer | null; -} - -declare var AuthenticatorAssertionResponse: { - prototype: AuthenticatorAssertionResponse; - new(): AuthenticatorAssertionResponse; -}; - -/** Available only in secure contexts. */ -interface AuthenticatorAttestationResponse extends AuthenticatorResponse { - readonly attestationObject: ArrayBuffer; -} - -declare var AuthenticatorAttestationResponse: { - prototype: AuthenticatorAttestationResponse; - new(): AuthenticatorAttestationResponse; -}; - -/** Available only in secure contexts. */ -interface AuthenticatorResponse { - readonly clientDataJSON: ArrayBuffer; -} - -declare var AuthenticatorResponse: { - prototype: AuthenticatorResponse; - new(): AuthenticatorResponse; -}; - -interface BarProp { - readonly visible: boolean; -} - -declare var BarProp: { - prototype: BarProp; - new(): BarProp; -}; - -interface BaseAudioContextEventMap { - "statechange": Event; -} - -interface BaseAudioContext extends EventTarget { - /** Available only in secure contexts. */ - readonly audioWorklet: AudioWorklet; - readonly currentTime: number; - readonly destination: AudioDestinationNode; - readonly listener: AudioListener; - onstatechange: ((this: BaseAudioContext, ev: Event) => any) | null; - readonly sampleRate: number; - readonly state: AudioContextState; - createAnalyser(): AnalyserNode; - createBiquadFilter(): BiquadFilterNode; - createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; - createBufferSource(): AudioBufferSourceNode; - createChannelMerger(numberOfInputs?: number): ChannelMergerNode; - createChannelSplitter(numberOfOutputs?: number): ChannelSplitterNode; - createConstantSource(): ConstantSourceNode; - createConvolver(): ConvolverNode; - createDelay(maxDelayTime?: number): DelayNode; - createDynamicsCompressor(): DynamicsCompressorNode; - createGain(): GainNode; - createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; - createOscillator(): OscillatorNode; - createPanner(): PannerNode; - createPeriodicWave(real: number[] | Float32Array, imag: number[] | Float32Array, constraints?: PeriodicWaveConstraints): PeriodicWave; - /** @deprecated */ - createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; - createStereoPanner(): StereoPannerNode; - createWaveShaper(): WaveShaperNode; - decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback | null, errorCallback?: DecodeErrorCallback | null): Promise; - addEventListener(type: K, listener: (this: BaseAudioContext, ev: BaseAudioContextEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: BaseAudioContext, ev: BaseAudioContextEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var BaseAudioContext: { - prototype: BaseAudioContext; - new(): BaseAudioContext; -}; - -/** The beforeunload event is fired when the window, the document and its resources are about to be unloaded. */ -interface BeforeUnloadEvent extends Event { - returnValue: any; -} - -declare var BeforeUnloadEvent: { - prototype: BeforeUnloadEvent; - new(): BeforeUnloadEvent; -}; - -/** A simple low-order filter, and is created using the AudioContext.createBiquadFilter() method. It is an AudioNode that can represent different kinds of filters, tone control devices, and graphic equalizers. */ -interface BiquadFilterNode extends AudioNode { - readonly Q: AudioParam; - readonly detune: AudioParam; - readonly frequency: AudioParam; - readonly gain: AudioParam; - type: BiquadFilterType; - getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; -} - -declare var BiquadFilterNode: { - prototype: BiquadFilterNode; - new(context: BaseAudioContext, options?: BiquadFilterOptions): BiquadFilterNode; -}; - -/** A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. */ -interface Blob { - readonly size: number; - readonly type: string; - arrayBuffer(): Promise; - slice(start?: number, end?: number, contentType?: string): Blob; - stream(): ReadableStream; - text(): Promise; -} - -declare var Blob: { - prototype: Blob; - new(blobParts?: BlobPart[], options?: BlobPropertyBag): Blob; -}; - -interface BlobEvent extends Event { - readonly data: Blob; - readonly timecode: DOMHighResTimeStamp; -} - -declare var BlobEvent: { - prototype: BlobEvent; - new(type: string, eventInitDict: BlobEventInit): BlobEvent; -}; - -interface Body { - readonly body: ReadableStream | null; - readonly bodyUsed: boolean; - arrayBuffer(): Promise; - blob(): Promise; - formData(): Promise; - json(): Promise; - text(): Promise; -} - -interface BroadcastChannelEventMap { - "message": MessageEvent; - "messageerror": MessageEvent; -} - -interface BroadcastChannel extends EventTarget { - /** Returns the channel name (as passed to the constructor). */ - readonly name: string; - onmessage: ((this: BroadcastChannel, ev: MessageEvent) => any) | null; - onmessageerror: ((this: BroadcastChannel, ev: MessageEvent) => any) | null; - /** Closes the BroadcastChannel object, opening it up to garbage collection. */ - close(): void; - /** Sends the given message to other BroadcastChannel objects set up for this channel. Messages can be structured objects, e.g. nested objects and arrays. */ - postMessage(message: any): void; - addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var BroadcastChannel: { - prototype: BroadcastChannel; - new(name: string): BroadcastChannel; -}; - -/** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */ -interface ByteLengthQueuingStrategy extends QueuingStrategy { - readonly highWaterMark: number; - readonly size: QueuingStrategySize; -} - -declare var ByteLengthQueuingStrategy: { - prototype: ByteLengthQueuingStrategy; - new(init: QueuingStrategyInit): ByteLengthQueuingStrategy; -}; - -/** A CDATA section that can be used within XML to include extended portions of unescaped text. The symbols < and & don’t need escaping as they normally do when inside a CDATA section. */ -interface CDATASection extends Text { -} - -declare var CDATASection: { - prototype: CDATASection; - new(): CDATASection; -}; - -interface CSSAnimation extends Animation { - readonly animationName: string; - addEventListener(type: K, listener: (this: CSSAnimation, ev: AnimationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: CSSAnimation, ev: AnimationEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var CSSAnimation: { - prototype: CSSAnimation; - new(): CSSAnimation; -}; - -/** A single condition CSS at-rule, which consists of a condition and a statement block. It is a child of CSSGroupingRule. */ -interface CSSConditionRule extends CSSGroupingRule { - readonly conditionText: string; -} - -declare var CSSConditionRule: { - prototype: CSSConditionRule; - new(): CSSConditionRule; -}; - -interface CSSCounterStyleRule extends CSSRule { - additiveSymbols: string; - fallback: string; - name: string; - negative: string; - pad: string; - prefix: string; - range: string; - speakAs: string; - suffix: string; - symbols: string; - system: string; -} - -declare var CSSCounterStyleRule: { - prototype: CSSCounterStyleRule; - new(): CSSCounterStyleRule; -}; - -interface CSSFontFaceRule extends CSSRule { - readonly style: CSSStyleDeclaration; -} - -declare var CSSFontFaceRule: { - prototype: CSSFontFaceRule; - new(): CSSFontFaceRule; -}; - -/** Any CSS at-rule that contains other rules nested within it. */ -interface CSSGroupingRule extends CSSRule { - readonly cssRules: CSSRuleList; - deleteRule(index: number): void; - insertRule(rule: string, index?: number): number; -} - -declare var CSSGroupingRule: { - prototype: CSSGroupingRule; - new(): CSSGroupingRule; -}; - -interface CSSImportRule extends CSSRule { - readonly href: string; - readonly media: MediaList; - readonly styleSheet: CSSStyleSheet; -} - -declare var CSSImportRule: { - prototype: CSSImportRule; - new(): CSSImportRule; -}; - -/** An object representing a set of style for a given keyframe. It corresponds to the contains of a single keyframe of a @keyframes at-rule. It implements the CSSRule interface with a type value of 8 (CSSRule.KEYFRAME_RULE). */ -interface CSSKeyframeRule extends CSSRule { - keyText: string; - readonly style: CSSStyleDeclaration; -} - -declare var CSSKeyframeRule: { - prototype: CSSKeyframeRule; - new(): CSSKeyframeRule; -}; - -/** An object representing a complete set of keyframes for a CSS animation. It corresponds to the contains of a whole @keyframes at-rule. It implements the CSSRule interface with a type value of 7 (CSSRule.KEYFRAMES_RULE). */ -interface CSSKeyframesRule extends CSSRule { - readonly cssRules: CSSRuleList; - name: string; - appendRule(rule: string): void; - deleteRule(select: string): void; - findRule(select: string): CSSKeyframeRule | null; -} - -declare var CSSKeyframesRule: { - prototype: CSSKeyframesRule; - new(): CSSKeyframesRule; -}; - -/** A single CSS @media rule. It implements the CSSConditionRule interface, and therefore the CSSGroupingRule and the CSSRule interface with a type value of 4 (CSSRule.MEDIA_RULE). */ -interface CSSMediaRule extends CSSConditionRule { - readonly media: MediaList; -} - -declare var CSSMediaRule: { - prototype: CSSMediaRule; - new(): CSSMediaRule; -}; - -/** An object representing a single CSS @namespace at-rule. It implements the CSSRule interface, with a type value of 10 (CSSRule.NAMESPACE_RULE). */ -interface CSSNamespaceRule extends CSSRule { - readonly namespaceURI: string; - readonly prefix: string; -} - -declare var CSSNamespaceRule: { - prototype: CSSNamespaceRule; - new(): CSSNamespaceRule; -}; - -/** CSSPageRule is an interface representing a single CSS @page rule. It implements the CSSRule interface with a type value of 6 (CSSRule.PAGE_RULE). */ -interface CSSPageRule extends CSSGroupingRule { - selectorText: string; - readonly style: CSSStyleDeclaration; -} - -declare var CSSPageRule: { - prototype: CSSPageRule; - new(): CSSPageRule; -}; - -/** A single CSS rule. There are several types of rules, listed in the Type constants section below. */ -interface CSSRule { - cssText: string; - readonly parentRule: CSSRule | null; - readonly parentStyleSheet: CSSStyleSheet | null; - /** @deprecated */ - readonly type: number; - readonly CHARSET_RULE: number; - readonly FONT_FACE_RULE: number; - readonly IMPORT_RULE: number; - readonly KEYFRAMES_RULE: number; - readonly KEYFRAME_RULE: number; - readonly MEDIA_RULE: number; - readonly NAMESPACE_RULE: number; - readonly PAGE_RULE: number; - readonly STYLE_RULE: number; - readonly SUPPORTS_RULE: number; -} - -declare var CSSRule: { - prototype: CSSRule; - new(): CSSRule; - readonly CHARSET_RULE: number; - readonly FONT_FACE_RULE: number; - readonly IMPORT_RULE: number; - readonly KEYFRAMES_RULE: number; - readonly KEYFRAME_RULE: number; - readonly MEDIA_RULE: number; - readonly NAMESPACE_RULE: number; - readonly PAGE_RULE: number; - readonly STYLE_RULE: number; - readonly SUPPORTS_RULE: number; -}; - -/** A CSSRuleList is an (indirect-modify only) array-like object containing an ordered collection of CSSRule objects. */ -interface CSSRuleList { - readonly length: number; - item(index: number): CSSRule | null; - [index: number]: CSSRule; -} - -declare var CSSRuleList: { - prototype: CSSRuleList; - new(): CSSRuleList; -}; - -/** An object that is a CSS declaration block, and exposes style information and various style-related methods and properties. */ -interface CSSStyleDeclaration { - accentColor: string; - alignContent: string; - alignItems: string; - alignSelf: string; - alignmentBaseline: string; - all: string; - animation: string; - animationDelay: string; - animationDirection: string; - animationDuration: string; - animationFillMode: string; - animationIterationCount: string; - animationName: string; - animationPlayState: string; - animationTimingFunction: string; - appearance: string; - aspectRatio: string; - backfaceVisibility: string; - background: string; - backgroundAttachment: string; - backgroundBlendMode: string; - backgroundClip: string; - backgroundColor: string; - backgroundImage: string; - backgroundOrigin: string; - backgroundPosition: string; - backgroundPositionX: string; - backgroundPositionY: string; - backgroundRepeat: string; - backgroundSize: string; - baselineShift: string; - blockSize: string; - border: string; - borderBlock: string; - borderBlockColor: string; - borderBlockEnd: string; - borderBlockEndColor: string; - borderBlockEndStyle: string; - borderBlockEndWidth: string; - borderBlockStart: string; - borderBlockStartColor: string; - borderBlockStartStyle: string; - borderBlockStartWidth: string; - borderBlockStyle: string; - borderBlockWidth: string; - borderBottom: string; - borderBottomColor: string; - borderBottomLeftRadius: string; - borderBottomRightRadius: string; - borderBottomStyle: string; - borderBottomWidth: string; - borderCollapse: string; - borderColor: string; - borderEndEndRadius: string; - borderEndStartRadius: string; - borderImage: string; - borderImageOutset: string; - borderImageRepeat: string; - borderImageSlice: string; - borderImageSource: string; - borderImageWidth: string; - borderInline: string; - borderInlineColor: string; - borderInlineEnd: string; - borderInlineEndColor: string; - borderInlineEndStyle: string; - borderInlineEndWidth: string; - borderInlineStart: string; - borderInlineStartColor: string; - borderInlineStartStyle: string; - borderInlineStartWidth: string; - borderInlineStyle: string; - borderInlineWidth: string; - borderLeft: string; - borderLeftColor: string; - borderLeftStyle: string; - borderLeftWidth: string; - borderRadius: string; - borderRight: string; - borderRightColor: string; - borderRightStyle: string; - borderRightWidth: string; - borderSpacing: string; - borderStartEndRadius: string; - borderStartStartRadius: string; - borderStyle: string; - borderTop: string; - borderTopColor: string; - borderTopLeftRadius: string; - borderTopRightRadius: string; - borderTopStyle: string; - borderTopWidth: string; - borderWidth: string; - bottom: string; - boxShadow: string; - boxSizing: string; - breakAfter: string; - breakBefore: string; - breakInside: string; - captionSide: string; - caretColor: string; - clear: string; - /** @deprecated */ - clip: string; - clipPath: string; - clipRule: string; - color: string; - colorInterpolation: string; - colorInterpolationFilters: string; - colorScheme: string; - columnCount: string; - columnFill: string; - columnGap: string; - columnRule: string; - columnRuleColor: string; - columnRuleStyle: string; - columnRuleWidth: string; - columnSpan: string; - columnWidth: string; - columns: string; - contain: string; - content: string; - counterIncrement: string; - counterReset: string; - counterSet: string; - cssFloat: string; - cssText: string; - cursor: string; - direction: string; - display: string; - dominantBaseline: string; - emptyCells: string; - fill: string; - fillOpacity: string; - fillRule: string; - filter: string; - flex: string; - flexBasis: string; - flexDirection: string; - flexFlow: string; - flexGrow: string; - flexShrink: string; - flexWrap: string; - float: string; - floodColor: string; - floodOpacity: string; - font: string; - fontFamily: string; - fontFeatureSettings: string; - fontKerning: string; - fontOpticalSizing: string; - fontSize: string; - fontSizeAdjust: string; - fontStretch: string; - fontStyle: string; - fontSynthesis: string; - fontVariant: string; - fontVariantAlternates: string; - fontVariantCaps: string; - fontVariantEastAsian: string; - fontVariantLigatures: string; - fontVariantNumeric: string; - fontVariantPosition: string; - fontVariationSettings: string; - fontWeight: string; - gap: string; - grid: string; - gridArea: string; - gridAutoColumns: string; - gridAutoFlow: string; - gridAutoRows: string; - gridColumn: string; - gridColumnEnd: string; - /** @deprecated This is a legacy alias of `columnGap`. */ - gridColumnGap: string; - gridColumnStart: string; - /** @deprecated This is a legacy alias of `gap`. */ - gridGap: string; - gridRow: string; - gridRowEnd: string; - /** @deprecated This is a legacy alias of `rowGap`. */ - gridRowGap: string; - gridRowStart: string; - gridTemplate: string; - gridTemplateAreas: string; - gridTemplateColumns: string; - gridTemplateRows: string; - height: string; - hyphens: string; - /** @deprecated */ - imageOrientation: string; - imageRendering: string; - inlineSize: string; - inset: string; - insetBlock: string; - insetBlockEnd: string; - insetBlockStart: string; - insetInline: string; - insetInlineEnd: string; - insetInlineStart: string; - isolation: string; - justifyContent: string; - justifyItems: string; - justifySelf: string; - left: string; - readonly length: number; - letterSpacing: string; - lightingColor: string; - lineBreak: string; - lineHeight: string; - listStyle: string; - listStyleImage: string; - listStylePosition: string; - listStyleType: string; - margin: string; - marginBlock: string; - marginBlockEnd: string; - marginBlockStart: string; - marginBottom: string; - marginInline: string; - marginInlineEnd: string; - marginInlineStart: string; - marginLeft: string; - marginRight: string; - marginTop: string; - marker: string; - markerEnd: string; - markerMid: string; - markerStart: string; - mask: string; - maskClip: string; - maskComposite: string; - maskImage: string; - maskMode: string; - maskOrigin: string; - maskPosition: string; - maskRepeat: string; - maskSize: string; - maskType: string; - maxBlockSize: string; - maxHeight: string; - maxInlineSize: string; - maxWidth: string; - minBlockSize: string; - minHeight: string; - minInlineSize: string; - minWidth: string; - mixBlendMode: string; - objectFit: string; - objectPosition: string; - offset: string; - offsetDistance: string; - offsetPath: string; - offsetRotate: string; - opacity: string; - order: string; - orphans: string; - outline: string; - outlineColor: string; - outlineOffset: string; - outlineStyle: string; - outlineWidth: string; - overflow: string; - overflowAnchor: string; - overflowWrap: string; - overflowX: string; - overflowY: string; - overscrollBehavior: string; - overscrollBehaviorBlock: string; - overscrollBehaviorInline: string; - overscrollBehaviorX: string; - overscrollBehaviorY: string; - padding: string; - paddingBlock: string; - paddingBlockEnd: string; - paddingBlockStart: string; - paddingBottom: string; - paddingInline: string; - paddingInlineEnd: string; - paddingInlineStart: string; - paddingLeft: string; - paddingRight: string; - paddingTop: string; - pageBreakAfter: string; - pageBreakBefore: string; - pageBreakInside: string; - paintOrder: string; - readonly parentRule: CSSRule | null; - perspective: string; - perspectiveOrigin: string; - placeContent: string; - placeItems: string; - placeSelf: string; - pointerEvents: string; - position: string; - printColorAdjust: string; - quotes: string; - resize: string; - right: string; - rotate: string; - rowGap: string; - rubyPosition: string; - scale: string; - scrollBehavior: string; - scrollMargin: string; - scrollMarginBlock: string; - scrollMarginBlockEnd: string; - scrollMarginBlockStart: string; - scrollMarginBottom: string; - scrollMarginInline: string; - scrollMarginInlineEnd: string; - scrollMarginInlineStart: string; - scrollMarginLeft: string; - scrollMarginRight: string; - scrollMarginTop: string; - scrollPadding: string; - scrollPaddingBlock: string; - scrollPaddingBlockEnd: string; - scrollPaddingBlockStart: string; - scrollPaddingBottom: string; - scrollPaddingInline: string; - scrollPaddingInlineEnd: string; - scrollPaddingInlineStart: string; - scrollPaddingLeft: string; - scrollPaddingRight: string; - scrollPaddingTop: string; - scrollSnapAlign: string; - scrollSnapStop: string; - scrollSnapType: string; - scrollbarGutter: string; - shapeImageThreshold: string; - shapeMargin: string; - shapeOutside: string; - shapeRendering: string; - stopColor: string; - stopOpacity: string; - stroke: string; - strokeDasharray: string; - strokeDashoffset: string; - strokeLinecap: string; - strokeLinejoin: string; - strokeMiterlimit: string; - strokeOpacity: string; - strokeWidth: string; - tabSize: string; - tableLayout: string; - textAlign: string; - textAlignLast: string; - textAnchor: string; - textCombineUpright: string; - textDecoration: string; - textDecorationColor: string; - textDecorationLine: string; - textDecorationSkipInk: string; - textDecorationStyle: string; - textDecorationThickness: string; - textEmphasis: string; - textEmphasisColor: string; - textEmphasisPosition: string; - textEmphasisStyle: string; - textIndent: string; - textOrientation: string; - textOverflow: string; - textRendering: string; - textShadow: string; - textTransform: string; - textUnderlineOffset: string; - textUnderlinePosition: string; - top: string; - touchAction: string; - transform: string; - transformBox: string; - transformOrigin: string; - transformStyle: string; - transition: string; - transitionDelay: string; - transitionDuration: string; - transitionProperty: string; - transitionTimingFunction: string; - translate: string; - unicodeBidi: string; - userSelect: string; - verticalAlign: string; - visibility: string; - /** @deprecated This is a legacy alias of `alignContent`. */ - webkitAlignContent: string; - /** @deprecated This is a legacy alias of `alignItems`. */ - webkitAlignItems: string; - /** @deprecated This is a legacy alias of `alignSelf`. */ - webkitAlignSelf: string; - /** @deprecated This is a legacy alias of `animation`. */ - webkitAnimation: string; - /** @deprecated This is a legacy alias of `animationDelay`. */ - webkitAnimationDelay: string; - /** @deprecated This is a legacy alias of `animationDirection`. */ - webkitAnimationDirection: string; - /** @deprecated This is a legacy alias of `animationDuration`. */ - webkitAnimationDuration: string; - /** @deprecated This is a legacy alias of `animationFillMode`. */ - webkitAnimationFillMode: string; - /** @deprecated This is a legacy alias of `animationIterationCount`. */ - webkitAnimationIterationCount: string; - /** @deprecated This is a legacy alias of `animationName`. */ - webkitAnimationName: string; - /** @deprecated This is a legacy alias of `animationPlayState`. */ - webkitAnimationPlayState: string; - /** @deprecated This is a legacy alias of `animationTimingFunction`. */ - webkitAnimationTimingFunction: string; - /** @deprecated This is a legacy alias of `appearance`. */ - webkitAppearance: string; - /** @deprecated This is a legacy alias of `backfaceVisibility`. */ - webkitBackfaceVisibility: string; - /** @deprecated This is a legacy alias of `backgroundClip`. */ - webkitBackgroundClip: string; - /** @deprecated This is a legacy alias of `backgroundOrigin`. */ - webkitBackgroundOrigin: string; - /** @deprecated This is a legacy alias of `backgroundSize`. */ - webkitBackgroundSize: string; - /** @deprecated This is a legacy alias of `borderBottomLeftRadius`. */ - webkitBorderBottomLeftRadius: string; - /** @deprecated This is a legacy alias of `borderBottomRightRadius`. */ - webkitBorderBottomRightRadius: string; - /** @deprecated This is a legacy alias of `borderRadius`. */ - webkitBorderRadius: string; - /** @deprecated This is a legacy alias of `borderTopLeftRadius`. */ - webkitBorderTopLeftRadius: string; - /** @deprecated This is a legacy alias of `borderTopRightRadius`. */ - webkitBorderTopRightRadius: string; - /** @deprecated This is a legacy alias of `boxAlign`. */ - webkitBoxAlign: string; - /** @deprecated This is a legacy alias of `boxFlex`. */ - webkitBoxFlex: string; - /** @deprecated This is a legacy alias of `boxOrdinalGroup`. */ - webkitBoxOrdinalGroup: string; - /** @deprecated This is a legacy alias of `boxOrient`. */ - webkitBoxOrient: string; - /** @deprecated This is a legacy alias of `boxPack`. */ - webkitBoxPack: string; - /** @deprecated This is a legacy alias of `boxShadow`. */ - webkitBoxShadow: string; - /** @deprecated This is a legacy alias of `boxSizing`. */ - webkitBoxSizing: string; - /** @deprecated This is a legacy alias of `filter`. */ - webkitFilter: string; - /** @deprecated This is a legacy alias of `flex`. */ - webkitFlex: string; - /** @deprecated This is a legacy alias of `flexBasis`. */ - webkitFlexBasis: string; - /** @deprecated This is a legacy alias of `flexDirection`. */ - webkitFlexDirection: string; - /** @deprecated This is a legacy alias of `flexFlow`. */ - webkitFlexFlow: string; - /** @deprecated This is a legacy alias of `flexGrow`. */ - webkitFlexGrow: string; - /** @deprecated This is a legacy alias of `flexShrink`. */ - webkitFlexShrink: string; - /** @deprecated This is a legacy alias of `flexWrap`. */ - webkitFlexWrap: string; - /** @deprecated This is a legacy alias of `justifyContent`. */ - webkitJustifyContent: string; - webkitLineClamp: string; - /** @deprecated This is a legacy alias of `mask`. */ - webkitMask: string; - /** @deprecated This is a legacy alias of `maskBorder`. */ - webkitMaskBoxImage: string; - /** @deprecated This is a legacy alias of `maskBorderOutset`. */ - webkitMaskBoxImageOutset: string; - /** @deprecated This is a legacy alias of `maskBorderRepeat`. */ - webkitMaskBoxImageRepeat: string; - /** @deprecated This is a legacy alias of `maskBorderSlice`. */ - webkitMaskBoxImageSlice: string; - /** @deprecated This is a legacy alias of `maskBorderSource`. */ - webkitMaskBoxImageSource: string; - /** @deprecated This is a legacy alias of `maskBorderWidth`. */ - webkitMaskBoxImageWidth: string; - /** @deprecated This is a legacy alias of `maskClip`. */ - webkitMaskClip: string; - webkitMaskComposite: string; - /** @deprecated This is a legacy alias of `maskImage`. */ - webkitMaskImage: string; - /** @deprecated This is a legacy alias of `maskOrigin`. */ - webkitMaskOrigin: string; - /** @deprecated This is a legacy alias of `maskPosition`. */ - webkitMaskPosition: string; - /** @deprecated This is a legacy alias of `maskRepeat`. */ - webkitMaskRepeat: string; - /** @deprecated This is a legacy alias of `maskSize`. */ - webkitMaskSize: string; - /** @deprecated This is a legacy alias of `order`. */ - webkitOrder: string; - /** @deprecated This is a legacy alias of `perspective`. */ - webkitPerspective: string; - /** @deprecated This is a legacy alias of `perspectiveOrigin`. */ - webkitPerspectiveOrigin: string; - webkitTextFillColor: string; - /** @deprecated This is a legacy alias of `textSizeAdjust`. */ - webkitTextSizeAdjust: string; - webkitTextStroke: string; - webkitTextStrokeColor: string; - webkitTextStrokeWidth: string; - /** @deprecated This is a legacy alias of `transform`. */ - webkitTransform: string; - /** @deprecated This is a legacy alias of `transformOrigin`. */ - webkitTransformOrigin: string; - /** @deprecated This is a legacy alias of `transformStyle`. */ - webkitTransformStyle: string; - /** @deprecated This is a legacy alias of `transition`. */ - webkitTransition: string; - /** @deprecated This is a legacy alias of `transitionDelay`. */ - webkitTransitionDelay: string; - /** @deprecated This is a legacy alias of `transitionDuration`. */ - webkitTransitionDuration: string; - /** @deprecated This is a legacy alias of `transitionProperty`. */ - webkitTransitionProperty: string; - /** @deprecated This is a legacy alias of `transitionTimingFunction`. */ - webkitTransitionTimingFunction: string; - /** @deprecated This is a legacy alias of `userSelect`. */ - webkitUserSelect: string; - whiteSpace: string; - widows: string; - width: string; - willChange: string; - wordBreak: string; - wordSpacing: string; - /** @deprecated */ - wordWrap: string; - writingMode: string; - zIndex: string; - getPropertyPriority(property: string): string; - getPropertyValue(property: string): string; - item(index: number): string; - removeProperty(property: string): string; - setProperty(property: string, value: string | null, priority?: string): void; - [index: number]: string; -} - -declare var CSSStyleDeclaration: { - prototype: CSSStyleDeclaration; - new(): CSSStyleDeclaration; -}; - -/** CSSStyleRule represents a single CSS style rule. It implements the CSSRule interface with a type value of 1 (CSSRule.STYLE_RULE). */ -interface CSSStyleRule extends CSSRule { - selectorText: string; - readonly style: CSSStyleDeclaration; -} - -declare var CSSStyleRule: { - prototype: CSSStyleRule; - new(): CSSStyleRule; -}; - -/** A single CSS style sheet. It inherits properties and methods from its parent, StyleSheet. */ -interface CSSStyleSheet extends StyleSheet { - readonly cssRules: CSSRuleList; - readonly ownerRule: CSSRule | null; - /** @deprecated */ - readonly rules: CSSRuleList; - /** @deprecated */ - addRule(selector?: string, style?: string, index?: number): number; - deleteRule(index: number): void; - insertRule(rule: string, index?: number): number; - /** @deprecated */ - removeRule(index?: number): void; - replace(text: string): Promise; - replaceSync(text: string): void; -} - -declare var CSSStyleSheet: { - prototype: CSSStyleSheet; - new(options?: CSSStyleSheetInit): CSSStyleSheet; -}; - -/** An object representing a single CSS @supports at-rule. It implements the CSSConditionRule interface, and therefore the CSSRule and CSSGroupingRule interfaces with a type value of 12 (CSSRule.SUPPORTS_RULE). */ -interface CSSSupportsRule extends CSSConditionRule { -} - -declare var CSSSupportsRule: { - prototype: CSSSupportsRule; - new(): CSSSupportsRule; -}; - -interface CSSTransition extends Animation { - readonly transitionProperty: string; - addEventListener(type: K, listener: (this: CSSTransition, ev: AnimationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: CSSTransition, ev: AnimationEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var CSSTransition: { - prototype: CSSTransition; - new(): CSSTransition; -}; - -/** - * Provides a storage mechanism for Request / Response object pairs that are cached, for example as part of the ServiceWorker life cycle. Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec. - * Available only in secure contexts. - */ -interface Cache { - add(request: RequestInfo | URL): Promise; - addAll(requests: RequestInfo[]): Promise; - delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise; - keys(request?: RequestInfo | URL, options?: CacheQueryOptions): Promise>; - match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise; - matchAll(request?: RequestInfo | URL, options?: CacheQueryOptions): Promise>; - put(request: RequestInfo | URL, response: Response): Promise; -} - -declare var Cache: { - prototype: Cache; - new(): Cache; -}; - -/** - * The storage for Cache objects. - * Available only in secure contexts. - */ -interface CacheStorage { - delete(cacheName: string): Promise; - has(cacheName: string): Promise; - keys(): Promise; - match(request: RequestInfo | URL, options?: MultiCacheQueryOptions): Promise; - open(cacheName: string): Promise; -} - -declare var CacheStorage: { - prototype: CacheStorage; - new(): CacheStorage; -}; - -interface CanvasCaptureMediaStreamTrack extends MediaStreamTrack { - readonly canvas: HTMLCanvasElement; - requestFrame(): void; - addEventListener(type: K, listener: (this: CanvasCaptureMediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: CanvasCaptureMediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var CanvasCaptureMediaStreamTrack: { - prototype: CanvasCaptureMediaStreamTrack; - new(): CanvasCaptureMediaStreamTrack; -}; - -interface CanvasCompositing { - globalAlpha: number; - globalCompositeOperation: GlobalCompositeOperation; -} - -interface CanvasDrawImage { - drawImage(image: CanvasImageSource, dx: number, dy: number): void; - drawImage(image: CanvasImageSource, dx: number, dy: number, dw: number, dh: number): void; - drawImage(image: CanvasImageSource, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void; -} - -interface CanvasDrawPath { - beginPath(): void; - clip(fillRule?: CanvasFillRule): void; - clip(path: Path2D, fillRule?: CanvasFillRule): void; - fill(fillRule?: CanvasFillRule): void; - fill(path: Path2D, fillRule?: CanvasFillRule): void; - isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean; - isPointInPath(path: Path2D, x: number, y: number, fillRule?: CanvasFillRule): boolean; - isPointInStroke(x: number, y: number): boolean; - isPointInStroke(path: Path2D, x: number, y: number): boolean; - stroke(): void; - stroke(path: Path2D): void; -} - -interface CanvasFillStrokeStyles { - fillStyle: string | CanvasGradient | CanvasPattern; - strokeStyle: string | CanvasGradient | CanvasPattern; - createConicGradient(startAngle: number, x: number, y: number): CanvasGradient; - createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; - createPattern(image: CanvasImageSource, repetition: string | null): CanvasPattern | null; - createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; -} - -interface CanvasFilters { - filter: string; -} - -/** An opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or CanvasRenderingContext2D.createRadialGradient(). */ -interface CanvasGradient { - /** - * Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end. - * - * Throws an "IndexSizeError" DOMException if the offset is out of range. Throws a "SyntaxError" DOMException if the color cannot be parsed. - */ - addColorStop(offset: number, color: string): void; -} - -declare var CanvasGradient: { - prototype: CanvasGradient; - new(): CanvasGradient; -}; - -interface CanvasImageData { - createImageData(sw: number, sh: number, settings?: ImageDataSettings): ImageData; - createImageData(imagedata: ImageData): ImageData; - getImageData(sx: number, sy: number, sw: number, sh: number, settings?: ImageDataSettings): ImageData; - putImageData(imagedata: ImageData, dx: number, dy: number): void; - putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX: number, dirtyY: number, dirtyWidth: number, dirtyHeight: number): void; -} - -interface CanvasImageSmoothing { - imageSmoothingEnabled: boolean; - imageSmoothingQuality: ImageSmoothingQuality; -} - -interface CanvasPath { - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; - bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; - closePath(): void; - ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void; - lineTo(x: number, y: number): void; - moveTo(x: number, y: number): void; - quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; - rect(x: number, y: number, w: number, h: number): void; -} - -interface CanvasPathDrawingStyles { - lineCap: CanvasLineCap; - lineDashOffset: number; - lineJoin: CanvasLineJoin; - lineWidth: number; - miterLimit: number; - getLineDash(): number[]; - setLineDash(segments: number[]): void; -} - -/** An opaque object describing a pattern, based on an image, a canvas, or a video, created by the CanvasRenderingContext2D.createPattern() method. */ -interface CanvasPattern { - /** Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation. */ - setTransform(transform?: DOMMatrix2DInit): void; -} - -declare var CanvasPattern: { - prototype: CanvasPattern; - new(): CanvasPattern; -}; - -interface CanvasRect { - clearRect(x: number, y: number, w: number, h: number): void; - fillRect(x: number, y: number, w: number, h: number): void; - strokeRect(x: number, y: number, w: number, h: number): void; -} - -/** The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a element. It is used for drawing shapes, text, images, and other objects. */ -interface CanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface { - readonly canvas: HTMLCanvasElement; - getContextAttributes(): CanvasRenderingContext2DSettings; -} - -declare var CanvasRenderingContext2D: { - prototype: CanvasRenderingContext2D; - new(): CanvasRenderingContext2D; -}; - -interface CanvasShadowStyles { - shadowBlur: number; - shadowColor: string; - shadowOffsetX: number; - shadowOffsetY: number; -} - -interface CanvasState { - restore(): void; - save(): void; -} - -interface CanvasText { - fillText(text: string, x: number, y: number, maxWidth?: number): void; - measureText(text: string): TextMetrics; - strokeText(text: string, x: number, y: number, maxWidth?: number): void; -} - -interface CanvasTextDrawingStyles { - direction: CanvasDirection; - font: string; - textAlign: CanvasTextAlign; - textBaseline: CanvasTextBaseline; -} - -interface CanvasTransform { - getTransform(): DOMMatrix; - resetTransform(): void; - rotate(angle: number): void; - scale(x: number, y: number): void; - setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void; - setTransform(transform?: DOMMatrix2DInit): void; - transform(a: number, b: number, c: number, d: number, e: number, f: number): void; - translate(x: number, y: number): void; -} - -interface CanvasUserInterface { - drawFocusIfNeeded(element: Element): void; - drawFocusIfNeeded(path: Path2D, element: Element): void; -} - -/** The ChannelMergerNode interface, often used in conjunction with its opposite, ChannelSplitterNode, reunites different mono inputs into a single output. Each input is used to fill a channel of the output. This is useful for accessing each channels separately, e.g. for performing channel mixing where gain must be separately controlled on each channel. */ -interface ChannelMergerNode extends AudioNode { -} - -declare var ChannelMergerNode: { - prototype: ChannelMergerNode; - new(context: BaseAudioContext, options?: ChannelMergerOptions): ChannelMergerNode; -}; - -/** The ChannelSplitterNode interface, often used in conjunction with its opposite, ChannelMergerNode, separates the different channels of an audio source into a set of mono outputs. This is useful for accessing each channel separately, e.g. for performing channel mixing where gain must be separately controlled on each channel. */ -interface ChannelSplitterNode extends AudioNode { -} - -declare var ChannelSplitterNode: { - prototype: ChannelSplitterNode; - new(context: BaseAudioContext, options?: ChannelSplitterOptions): ChannelSplitterNode; -}; - -/** The CharacterData abstract interface represents a Node object that contains characters. This is an abstract interface, meaning there aren't any object of type CharacterData: it is implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't abstract. */ -interface CharacterData extends Node, ChildNode, NonDocumentTypeChildNode { - data: string; - readonly length: number; - readonly ownerDocument: Document; - appendData(data: string): void; - deleteData(offset: number, count: number): void; - insertData(offset: number, data: string): void; - replaceData(offset: number, count: number, data: string): void; - substringData(offset: number, count: number): string; -} - -declare var CharacterData: { - prototype: CharacterData; - new(): CharacterData; -}; - -interface ChildNode extends Node { - /** - * Inserts nodes just after node, while replacing strings in nodes with equivalent Text nodes. - * - * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. - */ - after(...nodes: (Node | string)[]): void; - /** - * Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes. - * - * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. - */ - before(...nodes: (Node | string)[]): void; - /** Removes node. */ - remove(): void; - /** - * Replaces node with nodes, while replacing strings in nodes with equivalent Text nodes. - * - * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. - */ - replaceWith(...nodes: (Node | string)[]): void; -} - -/** @deprecated */ -interface ClientRect extends DOMRect { -} - -/** Available only in secure contexts. */ -interface Clipboard extends EventTarget { - read(): Promise; - readText(): Promise; - write(data: ClipboardItems): Promise; - writeText(data: string): Promise; -} - -declare var Clipboard: { - prototype: Clipboard; - new(): Clipboard; -}; - -/** Events providing information related to modification of the clipboard, that is cut, copy, and paste events. */ -interface ClipboardEvent extends Event { - readonly clipboardData: DataTransfer | null; -} - -declare var ClipboardEvent: { - prototype: ClipboardEvent; - new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent; -}; - -/** Available only in secure contexts. */ -interface ClipboardItem { - readonly types: ReadonlyArray; - getType(type: string): Promise; -} - -declare var ClipboardItem: { - prototype: ClipboardItem; - new(items: Record>, options?: ClipboardItemOptions): ClipboardItem; -}; - -/** A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute. */ -interface CloseEvent extends Event { - /** Returns the WebSocket connection close code provided by the server. */ - readonly code: number; - /** Returns the WebSocket connection close reason provided by the server. */ - readonly reason: string; - /** Returns true if the connection closed cleanly; false otherwise. */ - readonly wasClean: boolean; -} - -declare var CloseEvent: { - prototype: CloseEvent; - new(type: string, eventInitDict?: CloseEventInit): CloseEvent; -}; - -/** Textual notations within markup; although it is generally not visually shown, such comments are available to be read in the source view. */ -interface Comment extends CharacterData { -} - -declare var Comment: { - prototype: Comment; - new(data?: string): Comment; -}; - -/** The DOM CompositionEvent represents events that occur due to the user indirectly entering text. */ -interface CompositionEvent extends UIEvent { - readonly data: string; - /** @deprecated */ - initCompositionEvent(typeArg: string, bubblesArg?: boolean, cancelableArg?: boolean, viewArg?: WindowProxy | null, dataArg?: string): void; -} - -declare var CompositionEvent: { - prototype: CompositionEvent; - new(type: string, eventInitDict?: CompositionEventInit): CompositionEvent; -}; - -interface ConstantSourceNode extends AudioScheduledSourceNode { - readonly offset: AudioParam; - addEventListener(type: K, listener: (this: ConstantSourceNode, ev: AudioScheduledSourceNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: ConstantSourceNode, ev: AudioScheduledSourceNodeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var ConstantSourceNode: { - prototype: ConstantSourceNode; - new(context: BaseAudioContext, options?: ConstantSourceOptions): ConstantSourceNode; -}; - -/** An AudioNode that performs a Linear Convolution on a given AudioBuffer, often used to achieve a reverb effect. A ConvolverNode always has exactly one input and one output. */ -interface ConvolverNode extends AudioNode { - buffer: AudioBuffer | null; - normalize: boolean; -} - -declare var ConvolverNode: { - prototype: ConvolverNode; - new(context: BaseAudioContext, options?: ConvolverOptions): ConvolverNode; -}; - -/** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */ -interface CountQueuingStrategy extends QueuingStrategy { - readonly highWaterMark: number; - readonly size: QueuingStrategySize; -} - -declare var CountQueuingStrategy: { - prototype: CountQueuingStrategy; - new(init: QueuingStrategyInit): CountQueuingStrategy; -}; - -/** Available only in secure contexts. */ -interface Credential { - readonly id: string; - readonly type: string; -} - -declare var Credential: { - prototype: Credential; - new(): Credential; -}; - -/** Available only in secure contexts. */ -interface CredentialsContainer { - create(options?: CredentialCreationOptions): Promise; - get(options?: CredentialRequestOptions): Promise; - preventSilentAccess(): Promise; - store(credential: Credential): Promise; -} - -declare var CredentialsContainer: { - prototype: CredentialsContainer; - new(): CredentialsContainer; -}; - -/** Basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives. */ -interface Crypto { - /** Available only in secure contexts. */ - readonly subtle: SubtleCrypto; - getRandomValues(array: T): T; - /** Available only in secure contexts. */ - randomUUID(): string; -} - -declare var Crypto: { - prototype: Crypto; - new(): Crypto; -}; - -/** - * The CryptoKey dictionary of the Web Crypto API represents a cryptographic key. - * Available only in secure contexts. - */ -interface CryptoKey { - readonly algorithm: KeyAlgorithm; - readonly extractable: boolean; - readonly type: KeyType; - readonly usages: KeyUsage[]; -} - -declare var CryptoKey: { - prototype: CryptoKey; - new(): CryptoKey; -}; - -interface CustomElementRegistry { - define(name: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions): void; - get(name: string): CustomElementConstructor | undefined; - upgrade(root: Node): void; - whenDefined(name: string): Promise; -} - -declare var CustomElementRegistry: { - prototype: CustomElementRegistry; - new(): CustomElementRegistry; -}; - -interface CustomEvent extends Event { - /** Returns any custom data event was created with. Typically used for synthetic events. */ - readonly detail: T; - /** @deprecated */ - initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void; -} - -declare var CustomEvent: { - prototype: CustomEvent; - new(type: string, eventInitDict?: CustomEventInit): CustomEvent; -}; - -/** An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. */ -interface DOMException extends Error { - /** @deprecated */ - readonly code: number; - readonly message: string; - readonly name: string; - readonly ABORT_ERR: number; - readonly DATA_CLONE_ERR: number; - readonly DOMSTRING_SIZE_ERR: number; - readonly HIERARCHY_REQUEST_ERR: number; - readonly INDEX_SIZE_ERR: number; - readonly INUSE_ATTRIBUTE_ERR: number; - readonly INVALID_ACCESS_ERR: number; - readonly INVALID_CHARACTER_ERR: number; - readonly INVALID_MODIFICATION_ERR: number; - readonly INVALID_NODE_TYPE_ERR: number; - readonly INVALID_STATE_ERR: number; - readonly NAMESPACE_ERR: number; - readonly NETWORK_ERR: number; - readonly NOT_FOUND_ERR: number; - readonly NOT_SUPPORTED_ERR: number; - readonly NO_DATA_ALLOWED_ERR: number; - readonly NO_MODIFICATION_ALLOWED_ERR: number; - readonly QUOTA_EXCEEDED_ERR: number; - readonly SECURITY_ERR: number; - readonly SYNTAX_ERR: number; - readonly TIMEOUT_ERR: number; - readonly TYPE_MISMATCH_ERR: number; - readonly URL_MISMATCH_ERR: number; - readonly VALIDATION_ERR: number; - readonly WRONG_DOCUMENT_ERR: number; -} - -declare var DOMException: { - prototype: DOMException; - new(message?: string, name?: string): DOMException; - readonly ABORT_ERR: number; - readonly DATA_CLONE_ERR: number; - readonly DOMSTRING_SIZE_ERR: number; - readonly HIERARCHY_REQUEST_ERR: number; - readonly INDEX_SIZE_ERR: number; - readonly INUSE_ATTRIBUTE_ERR: number; - readonly INVALID_ACCESS_ERR: number; - readonly INVALID_CHARACTER_ERR: number; - readonly INVALID_MODIFICATION_ERR: number; - readonly INVALID_NODE_TYPE_ERR: number; - readonly INVALID_STATE_ERR: number; - readonly NAMESPACE_ERR: number; - readonly NETWORK_ERR: number; - readonly NOT_FOUND_ERR: number; - readonly NOT_SUPPORTED_ERR: number; - readonly NO_DATA_ALLOWED_ERR: number; - readonly NO_MODIFICATION_ALLOWED_ERR: number; - readonly QUOTA_EXCEEDED_ERR: number; - readonly SECURITY_ERR: number; - readonly SYNTAX_ERR: number; - readonly TIMEOUT_ERR: number; - readonly TYPE_MISMATCH_ERR: number; - readonly URL_MISMATCH_ERR: number; - readonly VALIDATION_ERR: number; - readonly WRONG_DOCUMENT_ERR: number; -}; - -/** An object providing methods which are not dependent on any particular document. Such an object is returned by the Document.implementation property. */ -interface DOMImplementation { - createDocument(namespace: string | null, qualifiedName: string | null, doctype?: DocumentType | null): XMLDocument; - createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; - createHTMLDocument(title?: string): Document; - /** @deprecated */ - hasFeature(...args: any[]): true; -} - -declare var DOMImplementation: { - prototype: DOMImplementation; - new(): DOMImplementation; -}; - -interface DOMMatrix extends DOMMatrixReadOnly { - a: number; - b: number; - c: number; - d: number; - e: number; - f: number; - m11: number; - m12: number; - m13: number; - m14: number; - m21: number; - m22: number; - m23: number; - m24: number; - m31: number; - m32: number; - m33: number; - m34: number; - m41: number; - m42: number; - m43: number; - m44: number; - invertSelf(): DOMMatrix; - multiplySelf(other?: DOMMatrixInit): DOMMatrix; - preMultiplySelf(other?: DOMMatrixInit): DOMMatrix; - rotateAxisAngleSelf(x?: number, y?: number, z?: number, angle?: number): DOMMatrix; - rotateFromVectorSelf(x?: number, y?: number): DOMMatrix; - rotateSelf(rotX?: number, rotY?: number, rotZ?: number): DOMMatrix; - scale3dSelf(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix; - scaleSelf(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix; - setMatrixValue(transformList: string): DOMMatrix; - skewXSelf(sx?: number): DOMMatrix; - skewYSelf(sy?: number): DOMMatrix; - translateSelf(tx?: number, ty?: number, tz?: number): DOMMatrix; -} - -declare var DOMMatrix: { - prototype: DOMMatrix; - new(init?: string | number[]): DOMMatrix; - fromFloat32Array(array32: Float32Array): DOMMatrix; - fromFloat64Array(array64: Float64Array): DOMMatrix; - fromMatrix(other?: DOMMatrixInit): DOMMatrix; -}; - -type SVGMatrix = DOMMatrix; -declare var SVGMatrix: typeof DOMMatrix; - -type WebKitCSSMatrix = DOMMatrix; -declare var WebKitCSSMatrix: typeof DOMMatrix; - -interface DOMMatrixReadOnly { - readonly a: number; - readonly b: number; - readonly c: number; - readonly d: number; - readonly e: number; - readonly f: number; - readonly is2D: boolean; - readonly isIdentity: boolean; - readonly m11: number; - readonly m12: number; - readonly m13: number; - readonly m14: number; - readonly m21: number; - readonly m22: number; - readonly m23: number; - readonly m24: number; - readonly m31: number; - readonly m32: number; - readonly m33: number; - readonly m34: number; - readonly m41: number; - readonly m42: number; - readonly m43: number; - readonly m44: number; - flipX(): DOMMatrix; - flipY(): DOMMatrix; - inverse(): DOMMatrix; - multiply(other?: DOMMatrixInit): DOMMatrix; - rotate(rotX?: number, rotY?: number, rotZ?: number): DOMMatrix; - rotateAxisAngle(x?: number, y?: number, z?: number, angle?: number): DOMMatrix; - rotateFromVector(x?: number, y?: number): DOMMatrix; - scale(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix; - scale3d(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix; - /** @deprecated */ - scaleNonUniform(scaleX?: number, scaleY?: number): DOMMatrix; - skewX(sx?: number): DOMMatrix; - skewY(sy?: number): DOMMatrix; - toFloat32Array(): Float32Array; - toFloat64Array(): Float64Array; - toJSON(): any; - transformPoint(point?: DOMPointInit): DOMPoint; - translate(tx?: number, ty?: number, tz?: number): DOMMatrix; - toString(): string; -} - -declare var DOMMatrixReadOnly: { - prototype: DOMMatrixReadOnly; - new(init?: string | number[]): DOMMatrixReadOnly; - fromFloat32Array(array32: Float32Array): DOMMatrixReadOnly; - fromFloat64Array(array64: Float64Array): DOMMatrixReadOnly; - fromMatrix(other?: DOMMatrixInit): DOMMatrixReadOnly; - toString(): string; -}; - -/** Provides the ability to parse XML or HTML source code from a string into a DOM Document. */ -interface DOMParser { - /** - * Parses string using either the HTML or XML parser, according to type, and returns the resulting Document. type can be "text/html" (which will invoke the HTML parser), or any of "text/xml", "application/xml", "application/xhtml+xml", or "image/svg+xml" (which will invoke the XML parser). - * - * For the XML parser, if string cannot be parsed, then the returned Document will contain elements describing the resulting error. - * - * Note that script elements are not evaluated during parsing, and the resulting document's encoding will always be UTF-8. - * - * Values other than the above for type will cause a TypeError exception to be thrown. - */ - parseFromString(string: string, type: DOMParserSupportedType): Document; -} - -declare var DOMParser: { - prototype: DOMParser; - new(): DOMParser; -}; - -interface DOMPoint extends DOMPointReadOnly { - w: number; - x: number; - y: number; - z: number; -} - -declare var DOMPoint: { - prototype: DOMPoint; - new(x?: number, y?: number, z?: number, w?: number): DOMPoint; - fromPoint(other?: DOMPointInit): DOMPoint; -}; - -type SVGPoint = DOMPoint; -declare var SVGPoint: typeof DOMPoint; - -interface DOMPointReadOnly { - readonly w: number; - readonly x: number; - readonly y: number; - readonly z: number; - matrixTransform(matrix?: DOMMatrixInit): DOMPoint; - toJSON(): any; -} - -declare var DOMPointReadOnly: { - prototype: DOMPointReadOnly; - new(x?: number, y?: number, z?: number, w?: number): DOMPointReadOnly; - fromPoint(other?: DOMPointInit): DOMPointReadOnly; -}; - -interface DOMQuad { - readonly p1: DOMPoint; - readonly p2: DOMPoint; - readonly p3: DOMPoint; - readonly p4: DOMPoint; - getBounds(): DOMRect; - toJSON(): any; -} - -declare var DOMQuad: { - prototype: DOMQuad; - new(p1?: DOMPointInit, p2?: DOMPointInit, p3?: DOMPointInit, p4?: DOMPointInit): DOMQuad; - fromQuad(other?: DOMQuadInit): DOMQuad; - fromRect(other?: DOMRectInit): DOMQuad; -}; - -interface DOMRect extends DOMRectReadOnly { - height: number; - width: number; - x: number; - y: number; -} - -declare var DOMRect: { - prototype: DOMRect; - new(x?: number, y?: number, width?: number, height?: number): DOMRect; - fromRect(other?: DOMRectInit): DOMRect; -}; - -type SVGRect = DOMRect; -declare var SVGRect: typeof DOMRect; - -interface DOMRectList { - readonly length: number; - item(index: number): DOMRect | null; - [index: number]: DOMRect; -} - -declare var DOMRectList: { - prototype: DOMRectList; - new(): DOMRectList; -}; - -interface DOMRectReadOnly { - readonly bottom: number; - readonly height: number; - readonly left: number; - readonly right: number; - readonly top: number; - readonly width: number; - readonly x: number; - readonly y: number; - toJSON(): any; -} - -declare var DOMRectReadOnly: { - prototype: DOMRectReadOnly; - new(x?: number, y?: number, width?: number, height?: number): DOMRectReadOnly; - fromRect(other?: DOMRectInit): DOMRectReadOnly; -}; - -/** A type returned by some APIs which contains a list of DOMString (strings). */ -interface DOMStringList { - /** Returns the number of strings in strings. */ - readonly length: number; - /** Returns true if strings contains string, and false otherwise. */ - contains(string: string): boolean; - /** Returns the string with index index from strings. */ - item(index: number): string | null; - [index: number]: string; -} - -declare var DOMStringList: { - prototype: DOMStringList; - new(): DOMStringList; -}; - -/** Used by the dataset HTML attribute to represent data for custom attributes added to elements. */ -interface DOMStringMap { - [name: string]: string | undefined; -} - -declare var DOMStringMap: { - prototype: DOMStringMap; - new(): DOMStringMap; -}; - -/** A set of space-separated tokens. Such a set is returned by Element.classList, HTMLLinkElement.relList, HTMLAnchorElement.relList, HTMLAreaElement.relList, HTMLIframeElement.sandbox, or HTMLOutputElement.htmlFor. It is indexed beginning with 0 as with JavaScript Array objects. DOMTokenList is always case-sensitive. */ -interface DOMTokenList { - /** Returns the number of tokens. */ - readonly length: number; - /** - * Returns the associated set as string. - * - * Can be set, to change the associated attribute. - */ - value: string; - toString(): string; - /** - * Adds all arguments passed, except those already present. - * - * Throws a "SyntaxError" DOMException if one of the arguments is the empty string. - * - * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace. - */ - add(...tokens: string[]): void; - /** Returns true if token is present, and false otherwise. */ - contains(token: string): boolean; - /** Returns the token with index index. */ - item(index: number): string | null; - /** - * Removes arguments passed, if they are present. - * - * Throws a "SyntaxError" DOMException if one of the arguments is the empty string. - * - * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace. - */ - remove(...tokens: string[]): void; - /** - * Replaces token with newToken. - * - * Returns true if token was replaced with newToken, and false otherwise. - * - * Throws a "SyntaxError" DOMException if one of the arguments is the empty string. - * - * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace. - */ - replace(token: string, newToken: string): boolean; - /** - * Returns true if token is in the associated attribute's supported tokens. Returns false otherwise. - * - * Throws a TypeError if the associated attribute has no supported tokens defined. - */ - supports(token: string): boolean; - /** - * If force is not given, "toggles" token, removing it if it's present and adding it if it's not present. If force is true, adds token (same as add()). If force is false, removes token (same as remove()). - * - * Returns true if token is now present, and false otherwise. - * - * Throws a "SyntaxError" DOMException if token is empty. - * - * Throws an "InvalidCharacterError" DOMException if token contains any spaces. - */ - toggle(token: string, force?: boolean): boolean; - forEach(callbackfn: (value: string, key: number, parent: DOMTokenList) => void, thisArg?: any): void; - [index: number]: string; -} - -declare var DOMTokenList: { - prototype: DOMTokenList; - new(): DOMTokenList; -}; - -/** Used to hold the data that is being dragged during a drag and drop operation. It may hold one or more data items, each of one or more data types. For more information about drag and drop, see HTML Drag and Drop API. */ -interface DataTransfer { - /** - * Returns the kind of operation that is currently selected. If the kind of operation isn't one of those that is allowed by the effectAllowed attribute, then the operation will fail. - * - * Can be set, to change the selected operation. - * - * The possible values are "none", "copy", "link", and "move". - */ - dropEffect: "none" | "copy" | "link" | "move"; - /** - * Returns the kinds of operations that are to be allowed. - * - * Can be set (during the dragstart event), to change the allowed operations. - * - * The possible values are "none", "copy", "copyLink", "copyMove", "link", "linkMove", "move", "all", and "uninitialized", - */ - effectAllowed: "none" | "copy" | "copyLink" | "copyMove" | "link" | "linkMove" | "move" | "all" | "uninitialized"; - /** Returns a FileList of the files being dragged, if any. */ - readonly files: FileList; - /** Returns a DataTransferItemList object, with the drag data. */ - readonly items: DataTransferItemList; - /** Returns a frozen array listing the formats that were set in the dragstart event. In addition, if any files are being dragged, then one of the types will be the string "Files". */ - readonly types: ReadonlyArray; - /** Removes the data of the specified formats. Removes all data if the argument is omitted. */ - clearData(format?: string): void; - /** Returns the specified data. If there is no such data, returns the empty string. */ - getData(format: string): string; - /** Adds the specified data. */ - setData(format: string, data: string): void; - /** Uses the given element to update the drag feedback, replacing any previously specified feedback. */ - setDragImage(image: Element, x: number, y: number): void; -} - -declare var DataTransfer: { - prototype: DataTransfer; - new(): DataTransfer; -}; - -/** One drag data item. During a drag operation, each drag event has a dataTransfer property which contains a list of drag data items. Each item in the list is a DataTransferItem object. */ -interface DataTransferItem { - /** Returns the drag data item kind, one of: "string", "file". */ - readonly kind: string; - /** Returns the drag data item type string. */ - readonly type: string; - /** Returns a File object, if the drag data item kind is File. */ - getAsFile(): File | null; - /** Invokes the callback with the string data as the argument, if the drag data item kind is text. */ - getAsString(callback: FunctionStringCallback | null): void; - webkitGetAsEntry(): FileSystemEntry | null; -} - -declare var DataTransferItem: { - prototype: DataTransferItem; - new(): DataTransferItem; -}; - -/** A list of DataTransferItem objects representing items being dragged. During a drag operation, each DragEvent has a dataTransfer property and that property is a DataTransferItemList. */ -interface DataTransferItemList { - /** Returns the number of items in the drag data store. */ - readonly length: number; - /** Adds a new entry for the given data to the drag data store. If the data is plain text then a type string has to be provided also. */ - add(data: string, type: string): DataTransferItem | null; - add(data: File): DataTransferItem | null; - /** Removes all the entries in the drag data store. */ - clear(): void; - /** Removes the indexth entry in the drag data store. */ - remove(index: number): void; - [index: number]: DataTransferItem; -} - -declare var DataTransferItemList: { - prototype: DataTransferItemList; - new(): DataTransferItemList; -}; - -/** A delay-line; an AudioNode audio-processing module that causes a delay between the arrival of an input data and its propagation to the output. */ -interface DelayNode extends AudioNode { - readonly delayTime: AudioParam; -} - -declare var DelayNode: { - prototype: DelayNode; - new(context: BaseAudioContext, options?: DelayOptions): DelayNode; -}; - -/** - * The DeviceMotionEvent provides web developers with information about the speed of changes for the device's position and orientation. - * Available only in secure contexts. - */ -interface DeviceMotionEvent extends Event { - readonly acceleration: DeviceMotionEventAcceleration | null; - readonly accelerationIncludingGravity: DeviceMotionEventAcceleration | null; - readonly interval: number; - readonly rotationRate: DeviceMotionEventRotationRate | null; -} - -declare var DeviceMotionEvent: { - prototype: DeviceMotionEvent; - new(type: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; -}; - -/** Available only in secure contexts. */ -interface DeviceMotionEventAcceleration { - readonly x: number | null; - readonly y: number | null; - readonly z: number | null; -} - -/** Available only in secure contexts. */ -interface DeviceMotionEventRotationRate { - readonly alpha: number | null; - readonly beta: number | null; - readonly gamma: number | null; -} - -/** - * The DeviceOrientationEvent provides web developers with information from the physical orientation of the device running the web page. - * Available only in secure contexts. - */ -interface DeviceOrientationEvent extends Event { - readonly absolute: boolean; - readonly alpha: number | null; - readonly beta: number | null; - readonly gamma: number | null; -} - -declare var DeviceOrientationEvent: { - prototype: DeviceOrientationEvent; - new(type: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; -}; - -interface DocumentEventMap extends DocumentAndElementEventHandlersEventMap, GlobalEventHandlersEventMap { - "DOMContentLoaded": Event; - "fullscreenchange": Event; - "fullscreenerror": Event; - "pointerlockchange": Event; - "pointerlockerror": Event; - "readystatechange": Event; - "visibilitychange": Event; -} - -/** Any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree. */ -interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShadowRoot, FontFaceSource, GlobalEventHandlers, NonElementParentNode, ParentNode, XPathEvaluatorBase { - /** Sets or gets the URL for the current document. */ - readonly URL: string; - /** - * Sets or gets the color of all active links in the document. - * @deprecated - */ - alinkColor: string; - /** - * Returns a reference to the collection of elements contained by the object. - * @deprecated - */ - readonly all: HTMLAllCollection; - /** - * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. - * @deprecated - */ - readonly anchors: HTMLCollectionOf; - /** - * Retrieves a collection of all applet objects in the document. - * @deprecated - */ - readonly applets: HTMLCollection; - /** - * Deprecated. Sets or retrieves a value that indicates the background color behind the object. - * @deprecated - */ - bgColor: string; - /** Specifies the beginning and end of the document body. */ - body: HTMLElement; - /** Returns document's encoding. */ - readonly characterSet: string; - /** - * Gets or sets the character set used to encode the object. - * @deprecated This is a legacy alias of `characterSet`. - */ - readonly charset: string; - /** Gets a value that indicates whether standards-compliant mode is switched on for the object. */ - readonly compatMode: string; - /** Returns document's content type. */ - readonly contentType: string; - /** - * Returns the HTTP cookies that apply to the Document. If there are no cookies or cookies can't be applied to this resource, the empty string will be returned. - * - * Can be set, to add a new cookie to the element's set of HTTP cookies. - * - * If the contents are sandboxed into a unique origin (e.g. in an iframe with the sandbox attribute), a "SecurityError" DOMException will be thrown on getting and setting. - */ - cookie: string; - /** - * Returns the script element, or the SVG script element, that is currently executing, as long as the element represents a classic script. In the case of reentrant script execution, returns the one that most recently started executing amongst those that have not yet finished executing. - * - * Returns null if the Document is not currently executing a script or SVG script element (e.g., because the running script is an event handler, or a timeout), or if the currently executing script or SVG script element represents a module script. - */ - readonly currentScript: HTMLOrSVGScriptElement | null; - /** Returns the Window object of the active document. */ - readonly defaultView: (WindowProxy & typeof globalThis) | null; - /** Sets or gets a value that indicates whether the document can be edited. */ - designMode: string; - /** Sets or retrieves a value that indicates the reading order of the object. */ - dir: string; - /** Gets an object representing the document type declaration associated with the current document. */ - readonly doctype: DocumentType | null; - /** Gets a reference to the root node of the document. */ - readonly documentElement: HTMLElement; - /** Returns document's URL. */ - readonly documentURI: string; - /** Sets or gets the security domain of the document. */ - domain: string; - /** Retrieves a collection of all embed objects in the document. */ - readonly embeds: HTMLCollectionOf; - /** - * Sets or gets the foreground (text) color of the document. - * @deprecated - */ - fgColor: string; - /** Retrieves a collection, in source order, of all form objects in the document. */ - readonly forms: HTMLCollectionOf; - /** @deprecated */ - readonly fullscreen: boolean; - /** Returns true if document has the ability to display elements fullscreen and fullscreen is supported, or false otherwise. */ - readonly fullscreenEnabled: boolean; - /** Returns the head element. */ - readonly head: HTMLHeadElement; - readonly hidden: boolean; - /** Retrieves a collection, in source order, of img objects in the document. */ - readonly images: HTMLCollectionOf; - /** Gets the implementation object of the current document. */ - readonly implementation: DOMImplementation; - /** - * Returns the character encoding used to create the webpage that is loaded into the document object. - * @deprecated This is a legacy alias of `characterSet`. - */ - readonly inputEncoding: string; - /** Gets the date that the page was last modified, if the page supplies one. */ - readonly lastModified: string; - /** - * Sets or gets the color of the document links. - * @deprecated - */ - linkColor: string; - /** Retrieves a collection of all a objects that specify the href property and all area objects in the document. */ - readonly links: HTMLCollectionOf; - /** Contains information about the current URL. */ - get location(): Location; - set location(href: string | Location); - onfullscreenchange: ((this: Document, ev: Event) => any) | null; - onfullscreenerror: ((this: Document, ev: Event) => any) | null; - onpointerlockchange: ((this: Document, ev: Event) => any) | null; - onpointerlockerror: ((this: Document, ev: Event) => any) | null; - /** - * Fires when the state of the object has changed. - * @param ev The event - */ - onreadystatechange: ((this: Document, ev: Event) => any) | null; - onvisibilitychange: ((this: Document, ev: Event) => any) | null; - readonly ownerDocument: null; - readonly pictureInPictureEnabled: boolean; - /** Return an HTMLCollection of the embed elements in the Document. */ - readonly plugins: HTMLCollectionOf; - /** Retrieves a value that indicates the current state of the object. */ - readonly readyState: DocumentReadyState; - /** Gets the URL of the location that referred the user to the current page. */ - readonly referrer: string; - /** @deprecated */ - readonly rootElement: SVGSVGElement | null; - /** Retrieves a collection of all script objects in the document. */ - readonly scripts: HTMLCollectionOf; - readonly scrollingElement: Element | null; - readonly timeline: DocumentTimeline; - /** Contains the title of the document. */ - title: string; - readonly visibilityState: DocumentVisibilityState; - /** - * Sets or gets the color of the links that the user has visited. - * @deprecated - */ - vlinkColor: string; - /** - * Moves node from another document and returns it. - * - * If node is a document, throws a "NotSupportedError" DOMException or, if node is a shadow root, throws a "HierarchyRequestError" DOMException. - */ - adoptNode(node: T): T; - /** @deprecated */ - captureEvents(): void; - /** @deprecated */ - caretRangeFromPoint(x: number, y: number): Range | null; - /** @deprecated */ - clear(): void; - /** Closes an output stream and forces the sent data to display. */ - close(): void; - /** - * Creates an attribute object with a specified name. - * @param name String that sets the attribute object's name. - */ - createAttribute(localName: string): Attr; - createAttributeNS(namespace: string | null, qualifiedName: string): Attr; - /** Returns a CDATASection node whose data is data. */ - createCDATASection(data: string): CDATASection; - /** - * Creates a comment object with the specified data. - * @param data Sets the comment object's data. - */ - createComment(data: string): Comment; - /** Creates a new document. */ - createDocumentFragment(): DocumentFragment; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K]; - /** @deprecated */ - createElement(tagName: K, options?: ElementCreationOptions): HTMLElementDeprecatedTagNameMap[K]; - createElement(tagName: string, options?: ElementCreationOptions): HTMLElement; - /** - * Returns an element with namespace namespace. Its namespace prefix will be everything before ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E) in qualifiedName or qualifiedName. - * - * If localName does not match the Name production an "InvalidCharacterError" DOMException will be thrown. - * - * If one of the following conditions is true a "NamespaceError" DOMException will be thrown: - * - * localName does not match the QName production. - * Namespace prefix is not null and namespace is the empty string. - * Namespace prefix is "xml" and namespace is not the XML namespace. - * qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace. - * namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns". - * - * When supplied, options's is can be used to create a customized built-in element. - */ - createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement; - createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: K): SVGElementTagNameMap[K]; - createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement; - createElementNS(namespaceURI: string | null, qualifiedName: string, options?: ElementCreationOptions): Element; - createElementNS(namespace: string | null, qualifiedName: string, options?: string | ElementCreationOptions): Element; - createEvent(eventInterface: "AnimationEvent"): AnimationEvent; - createEvent(eventInterface: "AnimationPlaybackEvent"): AnimationPlaybackEvent; - createEvent(eventInterface: "AudioProcessingEvent"): AudioProcessingEvent; - createEvent(eventInterface: "BeforeUnloadEvent"): BeforeUnloadEvent; - createEvent(eventInterface: "BlobEvent"): BlobEvent; - createEvent(eventInterface: "ClipboardEvent"): ClipboardEvent; - createEvent(eventInterface: "CloseEvent"): CloseEvent; - createEvent(eventInterface: "CompositionEvent"): CompositionEvent; - createEvent(eventInterface: "CustomEvent"): CustomEvent; - createEvent(eventInterface: "DeviceMotionEvent"): DeviceMotionEvent; - createEvent(eventInterface: "DeviceOrientationEvent"): DeviceOrientationEvent; - createEvent(eventInterface: "DragEvent"): DragEvent; - createEvent(eventInterface: "ErrorEvent"): ErrorEvent; - createEvent(eventInterface: "Event"): Event; - createEvent(eventInterface: "Events"): Event; - createEvent(eventInterface: "FocusEvent"): FocusEvent; - createEvent(eventInterface: "FontFaceSetLoadEvent"): FontFaceSetLoadEvent; - createEvent(eventInterface: "FormDataEvent"): FormDataEvent; - createEvent(eventInterface: "GamepadEvent"): GamepadEvent; - createEvent(eventInterface: "HashChangeEvent"): HashChangeEvent; - createEvent(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent; - createEvent(eventInterface: "InputEvent"): InputEvent; - createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent; - createEvent(eventInterface: "MediaEncryptedEvent"): MediaEncryptedEvent; - createEvent(eventInterface: "MediaKeyMessageEvent"): MediaKeyMessageEvent; - createEvent(eventInterface: "MediaQueryListEvent"): MediaQueryListEvent; - createEvent(eventInterface: "MediaRecorderErrorEvent"): MediaRecorderErrorEvent; - createEvent(eventInterface: "MediaStreamTrackEvent"): MediaStreamTrackEvent; - createEvent(eventInterface: "MessageEvent"): MessageEvent; - createEvent(eventInterface: "MouseEvent"): MouseEvent; - createEvent(eventInterface: "MouseEvents"): MouseEvent; - createEvent(eventInterface: "MutationEvent"): MutationEvent; - createEvent(eventInterface: "MutationEvents"): MutationEvent; - createEvent(eventInterface: "OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; - createEvent(eventInterface: "PageTransitionEvent"): PageTransitionEvent; - createEvent(eventInterface: "PaymentMethodChangeEvent"): PaymentMethodChangeEvent; - createEvent(eventInterface: "PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; - createEvent(eventInterface: "PointerEvent"): PointerEvent; - createEvent(eventInterface: "PopStateEvent"): PopStateEvent; - createEvent(eventInterface: "ProgressEvent"): ProgressEvent; - createEvent(eventInterface: "PromiseRejectionEvent"): PromiseRejectionEvent; - createEvent(eventInterface: "RTCDTMFToneChangeEvent"): RTCDTMFToneChangeEvent; - createEvent(eventInterface: "RTCDataChannelEvent"): RTCDataChannelEvent; - createEvent(eventInterface: "RTCErrorEvent"): RTCErrorEvent; - createEvent(eventInterface: "RTCPeerConnectionIceErrorEvent"): RTCPeerConnectionIceErrorEvent; - createEvent(eventInterface: "RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; - createEvent(eventInterface: "RTCTrackEvent"): RTCTrackEvent; - createEvent(eventInterface: "SecurityPolicyViolationEvent"): SecurityPolicyViolationEvent; - createEvent(eventInterface: "SpeechSynthesisErrorEvent"): SpeechSynthesisErrorEvent; - createEvent(eventInterface: "SpeechSynthesisEvent"): SpeechSynthesisEvent; - createEvent(eventInterface: "StorageEvent"): StorageEvent; - createEvent(eventInterface: "SubmitEvent"): SubmitEvent; - createEvent(eventInterface: "TouchEvent"): TouchEvent; - createEvent(eventInterface: "TrackEvent"): TrackEvent; - createEvent(eventInterface: "TransitionEvent"): TransitionEvent; - createEvent(eventInterface: "UIEvent"): UIEvent; - createEvent(eventInterface: "UIEvents"): UIEvent; - createEvent(eventInterface: "WebGLContextEvent"): WebGLContextEvent; - createEvent(eventInterface: "WheelEvent"): WheelEvent; - createEvent(eventInterface: string): Event; - /** - * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. - * @param root The root element or node to start traversing on. - * @param whatToShow The type of nodes or elements to appear in the node list - * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. - */ - createNodeIterator(root: Node, whatToShow?: number, filter?: NodeFilter | null): NodeIterator; - /** Returns a ProcessingInstruction node whose target is target and data is data. If target does not match the Name production an "InvalidCharacterError" DOMException will be thrown. If data contains "?>" an "InvalidCharacterError" DOMException will be thrown. */ - createProcessingInstruction(target: string, data: string): ProcessingInstruction; - /** Returns an empty range object that has both of its boundary points positioned at the beginning of the document. */ - createRange(): Range; - /** - * Creates a text string from the specified value. - * @param data String that specifies the nodeValue property of the text node. - */ - createTextNode(data: string): Text; - /** - * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. - * @param root The root element or node to start traversing on. - * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. - * @param filter A custom NodeFilter function to use. - */ - createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter | null): TreeWalker; - /** - * Executes a command on the current document, current selection, or the given range. - * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. - * @param showUI Display the user interface, defaults to false. - * @param value Value to assign. - * @deprecated - */ - execCommand(commandId: string, showUI?: boolean, value?: string): boolean; - /** Stops document's fullscreen element from being displayed fullscreen and resolves promise when done. */ - exitFullscreen(): Promise; - exitPictureInPicture(): Promise; - exitPointerLock(): void; - /** - * Returns a reference to the first object with the specified value of the ID attribute. - * @param elementId String that specifies the ID value. - */ - getElementById(elementId: string): HTMLElement | null; - /** Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. */ - getElementsByClassName(classNames: string): HTMLCollectionOf; - /** - * Gets a collection of objects based on the value of the NAME or ID attribute. - * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. - */ - getElementsByName(elementName: string): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(qualifiedName: K): HTMLCollectionOf; - getElementsByTagName(qualifiedName: K): HTMLCollectionOf; - getElementsByTagName(qualifiedName: string): HTMLCollectionOf; - /** - * If namespace and localName are "*" returns a HTMLCollection of all descendant elements. - * - * If only namespace is "*" returns a HTMLCollection of all descendant elements whose local name is localName. - * - * If only localName is "*" returns a HTMLCollection of all descendant elements whose namespace is namespace. - * - * Otherwise, returns a HTMLCollection of all descendant elements whose namespace is namespace and local name is localName. - */ - getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; - getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; - getElementsByTagNameNS(namespace: string | null, localName: string): HTMLCollectionOf; - /** Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. */ - getSelection(): Selection | null; - /** Gets a value indicating whether the object currently has focus. */ - hasFocus(): boolean; - hasStorageAccess(): Promise; - /** - * Returns a copy of node. If deep is true, the copy also includes the node's descendants. - * - * If node is a document or a shadow root, throws a "NotSupportedError" DOMException. - */ - importNode(node: T, deep?: boolean): T; - /** - * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. - * @param url Specifies a MIME type for the document. - * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. - * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. - * @param replace Specifies whether the existing entry for the document is replaced in the history list. - */ - open(unused1?: string, unused2?: string): Document; - open(url: string | URL, name: string, features: string): WindowProxy | null; - /** - * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. - * @param commandId Specifies a command identifier. - * @deprecated - */ - queryCommandEnabled(commandId: string): boolean; - /** - * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. - * @param commandId String that specifies a command identifier. - */ - queryCommandIndeterm(commandId: string): boolean; - /** - * Returns a Boolean value that indicates the current state of the command. - * @param commandId String that specifies a command identifier. - * @deprecated - */ - queryCommandState(commandId: string): boolean; - /** - * Returns a Boolean value that indicates whether the current command is supported on the current range. - * @param commandId Specifies a command identifier. - * @deprecated - */ - queryCommandSupported(commandId: string): boolean; - /** - * Returns the current value of the document, range, or current selection for the given command. - * @param commandId String that specifies a command identifier. - */ - queryCommandValue(commandId: string): string; - /** @deprecated */ - releaseEvents(): void; - requestStorageAccess(): Promise; - /** - * Writes one or more HTML expressions to a document in the specified window. - * @param content Specifies the text and HTML tags to write. - */ - write(...text: string[]): void; - /** - * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. - * @param content The text and HTML tags to write. - */ - writeln(...text: string[]): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var Document: { - prototype: Document; - new(): Document; -}; - -interface DocumentAndElementEventHandlersEventMap { - "copy": ClipboardEvent; - "cut": ClipboardEvent; - "paste": ClipboardEvent; -} - -interface DocumentAndElementEventHandlers { - oncopy: ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | null; - oncut: ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | null; - onpaste: ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | null; - addEventListener(type: K, listener: (this: DocumentAndElementEventHandlers, ev: DocumentAndElementEventHandlersEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: DocumentAndElementEventHandlers, ev: DocumentAndElementEventHandlersEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -/** A minimal document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. The key difference is that because the document fragment isn't part of the active document tree structure, changes made to the fragment don't affect the document, cause reflow, or incur any performance impact that can occur when changes are made. */ -interface DocumentFragment extends Node, NonElementParentNode, ParentNode { - readonly ownerDocument: Document; - getElementById(elementId: string): HTMLElement | null; -} - -declare var DocumentFragment: { - prototype: DocumentFragment; - new(): DocumentFragment; -}; - -interface DocumentOrShadowRoot { - /** - * Returns the deepest element in the document through which or to which key events are being routed. This is, roughly speaking, the focused element in the document. - * - * For the purposes of this API, when a child browsing context is focused, its container is focused in the parent browsing context. For example, if the user moves the focus to a text control in an iframe, the iframe is the element returned by the activeElement API in the iframe's node document. - * - * Similarly, when the focused element is in a different node tree than documentOrShadowRoot, the element returned will be the host that's located in the same node tree as documentOrShadowRoot if documentOrShadowRoot is a shadow-including inclusive ancestor of the focused element, and null if not. - */ - readonly activeElement: Element | null; - adoptedStyleSheets: CSSStyleSheet[]; - /** Returns document's fullscreen element. */ - readonly fullscreenElement: Element | null; - readonly pictureInPictureElement: Element | null; - readonly pointerLockElement: Element | null; - /** Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. */ - readonly styleSheets: StyleSheetList; - /** - * Returns the element for the specified x coordinate and the specified y coordinate. - * @param x The x-offset - * @param y The y-offset - */ - elementFromPoint(x: number, y: number): Element | null; - elementsFromPoint(x: number, y: number): Element[]; - getAnimations(): Animation[]; -} - -interface DocumentTimeline extends AnimationTimeline { -} - -declare var DocumentTimeline: { - prototype: DocumentTimeline; - new(options?: DocumentTimelineOptions): DocumentTimeline; -}; - -/** A Node containing a doctype. */ -interface DocumentType extends Node, ChildNode { - readonly name: string; - readonly ownerDocument: Document; - readonly publicId: string; - readonly systemId: string; -} - -declare var DocumentType: { - prototype: DocumentType; - new(): DocumentType; -}; - -/** A DOM event that represents a drag and drop interaction. The user initiates a drag by placing a pointer device (such as a mouse) on the touch surface and then dragging the pointer to a new location (such as another DOM element). Applications are free to interpret a drag and drop interaction in an application-specific way. */ -interface DragEvent extends MouseEvent { - /** Returns the DataTransfer object for the event. */ - readonly dataTransfer: DataTransfer | null; -} - -declare var DragEvent: { - prototype: DragEvent; - new(type: string, eventInitDict?: DragEventInit): DragEvent; -}; - -/** Inherits properties from its parent, AudioNode. */ -interface DynamicsCompressorNode extends AudioNode { - readonly attack: AudioParam; - readonly knee: AudioParam; - readonly ratio: AudioParam; - readonly reduction: number; - readonly release: AudioParam; - readonly threshold: AudioParam; -} - -declare var DynamicsCompressorNode: { - prototype: DynamicsCompressorNode; - new(context: BaseAudioContext, options?: DynamicsCompressorOptions): DynamicsCompressorNode; -}; - -interface EXT_blend_minmax { - readonly MAX_EXT: GLenum; - readonly MIN_EXT: GLenum; -} - -interface EXT_color_buffer_float { -} - -interface EXT_color_buffer_half_float { - readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: GLenum; - readonly RGB16F_EXT: GLenum; - readonly RGBA16F_EXT: GLenum; - readonly UNSIGNED_NORMALIZED_EXT: GLenum; -} - -interface EXT_float_blend { -} - -/** The EXT_frag_depth extension is part of the WebGL API and enables to set a depth value of a fragment from within the fragment shader. */ -interface EXT_frag_depth { -} - -interface EXT_sRGB { - readonly FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: GLenum; - readonly SRGB8_ALPHA8_EXT: GLenum; - readonly SRGB_ALPHA_EXT: GLenum; - readonly SRGB_EXT: GLenum; -} - -interface EXT_shader_texture_lod { -} - -interface EXT_texture_compression_rgtc { - readonly COMPRESSED_RED_GREEN_RGTC2_EXT: GLenum; - readonly COMPRESSED_RED_RGTC1_EXT: GLenum; - readonly COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: GLenum; - readonly COMPRESSED_SIGNED_RED_RGTC1_EXT: GLenum; -} - -/** The EXT_texture_filter_anisotropic extension is part of the WebGL API and exposes two constants for anisotropic filtering (AF). */ -interface EXT_texture_filter_anisotropic { - readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: GLenum; - readonly TEXTURE_MAX_ANISOTROPY_EXT: GLenum; -} - -interface ElementEventMap { - "fullscreenchange": Event; - "fullscreenerror": Event; -} - -/** Element is the most general base class from which all objects in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element. */ -interface Element extends Node, ARIAMixin, Animatable, ChildNode, InnerHTML, NonDocumentTypeChildNode, ParentNode, Slottable { - readonly attributes: NamedNodeMap; - /** Allows for manipulation of element's class content attribute as a set of whitespace-separated tokens through a DOMTokenList object. */ - readonly classList: DOMTokenList; - /** Returns the value of element's class content attribute. Can be set to change it. */ - className: string; - readonly clientHeight: number; - readonly clientLeft: number; - readonly clientTop: number; - readonly clientWidth: number; - /** Returns the value of element's id content attribute. Can be set to change it. */ - id: string; - /** Returns the local name. */ - readonly localName: string; - /** Returns the namespace. */ - readonly namespaceURI: string | null; - onfullscreenchange: ((this: Element, ev: Event) => any) | null; - onfullscreenerror: ((this: Element, ev: Event) => any) | null; - outerHTML: string; - readonly ownerDocument: Document; - readonly part: DOMTokenList; - /** Returns the namespace prefix. */ - readonly prefix: string | null; - readonly scrollHeight: number; - scrollLeft: number; - scrollTop: number; - readonly scrollWidth: number; - /** Returns element's shadow root, if any, and if shadow root's mode is "open", and null otherwise. */ - readonly shadowRoot: ShadowRoot | null; - /** Returns the value of element's slot content attribute. Can be set to change it. */ - slot: string; - /** Returns the HTML-uppercased qualified name. */ - readonly tagName: string; - /** Creates a shadow root for element and returns it. */ - attachShadow(init: ShadowRootInit): ShadowRoot; - /** Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise. */ - closest(selector: K): HTMLElementTagNameMap[K] | null; - closest(selector: K): SVGElementTagNameMap[K] | null; - closest(selectors: string): E | null; - /** Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise. */ - getAttribute(qualifiedName: string): string | null; - /** Returns element's attribute whose namespace is namespace and local name is localName, and null if there is no such attribute otherwise. */ - getAttributeNS(namespace: string | null, localName: string): string | null; - /** Returns the qualified names of all element's attributes. Can contain duplicates. */ - getAttributeNames(): string[]; - getAttributeNode(qualifiedName: string): Attr | null; - getAttributeNodeNS(namespace: string | null, localName: string): Attr | null; - getBoundingClientRect(): DOMRect; - getClientRects(): DOMRectList; - /** Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. */ - getElementsByClassName(classNames: string): HTMLCollectionOf; - getElementsByTagName(qualifiedName: K): HTMLCollectionOf; - getElementsByTagName(qualifiedName: K): HTMLCollectionOf; - getElementsByTagName(qualifiedName: string): HTMLCollectionOf; - getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; - getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; - getElementsByTagNameNS(namespace: string | null, localName: string): HTMLCollectionOf; - /** Returns true if element has an attribute whose qualified name is qualifiedName, and false otherwise. */ - hasAttribute(qualifiedName: string): boolean; - /** Returns true if element has an attribute whose namespace is namespace and local name is localName. */ - hasAttributeNS(namespace: string | null, localName: string): boolean; - /** Returns true if element has attributes, and false otherwise. */ - hasAttributes(): boolean; - hasPointerCapture(pointerId: number): boolean; - insertAdjacentElement(where: InsertPosition, element: Element): Element | null; - insertAdjacentHTML(position: InsertPosition, text: string): void; - insertAdjacentText(where: InsertPosition, data: string): void; - /** Returns true if matching selectors against element's root yields element, and false otherwise. */ - matches(selectors: string): boolean; - releasePointerCapture(pointerId: number): void; - /** Removes element's first attribute whose qualified name is qualifiedName. */ - removeAttribute(qualifiedName: string): void; - /** Removes element's attribute whose namespace is namespace and local name is localName. */ - removeAttributeNS(namespace: string | null, localName: string): void; - removeAttributeNode(attr: Attr): Attr; - /** - * Displays element fullscreen and resolves promise when done. - * - * When supplied, options's navigationUI member indicates whether showing navigation UI while in fullscreen is preferred or not. If set to "show", navigation simplicity is preferred over screen space, and if set to "hide", more screen space is preferred. User agents are always free to honor user preference over the application's. The default value "auto" indicates no application preference. - */ - requestFullscreen(options?: FullscreenOptions): Promise; - requestPointerLock(): void; - scroll(options?: ScrollToOptions): void; - scroll(x: number, y: number): void; - scrollBy(options?: ScrollToOptions): void; - scrollBy(x: number, y: number): void; - scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void; - scrollTo(options?: ScrollToOptions): void; - scrollTo(x: number, y: number): void; - /** Sets the value of element's first attribute whose qualified name is qualifiedName to value. */ - setAttribute(qualifiedName: string, value: string): void; - /** Sets the value of element's attribute whose namespace is namespace and local name is localName to value. */ - setAttributeNS(namespace: string | null, qualifiedName: string, value: string): void; - setAttributeNode(attr: Attr): Attr | null; - setAttributeNodeNS(attr: Attr): Attr | null; - setPointerCapture(pointerId: number): void; - /** - * If force is not given, "toggles" qualifiedName, removing it if it is present and adding it if it is not present. If force is true, adds qualifiedName. If force is false, removes qualifiedName. - * - * Returns true if qualifiedName is now present, and false otherwise. - */ - toggleAttribute(qualifiedName: string, force?: boolean): boolean; - /** @deprecated This is a legacy alias of `matches`. */ - webkitMatchesSelector(selectors: string): boolean; - addEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var Element: { - prototype: Element; - new(): Element; -}; - -interface ElementCSSInlineStyle { - readonly style: CSSStyleDeclaration; -} - -interface ElementContentEditable { - contentEditable: string; - enterKeyHint: string; - inputMode: string; - readonly isContentEditable: boolean; -} - -interface ElementInternals extends ARIAMixin { - /** Returns the form owner of internals's target element. */ - readonly form: HTMLFormElement | null; - /** Returns a NodeList of all the label elements that internals's target element is associated with. */ - readonly labels: NodeList; - /** Returns the ShadowRoot for internals's target element, if the target element is a shadow host, or null otherwise. */ - readonly shadowRoot: ShadowRoot | null; - /** Returns the error message that would be shown to the user if internals's target element was to be checked for validity. */ - readonly validationMessage: string; - /** Returns the ValidityState object for internals's target element. */ - readonly validity: ValidityState; - /** Returns true if internals's target element will be validated when the form is submitted; false otherwise. */ - readonly willValidate: boolean; - /** Returns true if internals's target element has no validity problems; false otherwise. Fires an invalid event at the element in the latter case. */ - checkValidity(): boolean; - /** Returns true if internals's target element has no validity problems; otherwise, returns false, fires an invalid event at the element, and (if the event isn't canceled) reports the problem to the user. */ - reportValidity(): boolean; - /** - * Sets both the state and submission value of internals's target element to value. - * - * If value is null, the element won't participate in form submission. - */ - setFormValue(value: File | string | FormData | null, state?: File | string | FormData | null): void; - /** Marks internals's target element as suffering from the constraints indicated by the flags argument, and sets the element's validation message to message. If anchor is specified, the user agent might use it to indicate problems with the constraints of internals's target element when the form owner is validated interactively or reportValidity() is called. */ - setValidity(flags?: ValidityStateFlags, message?: string, anchor?: HTMLElement): void; -} - -declare var ElementInternals: { - prototype: ElementInternals; - new(): ElementInternals; -}; - -/** Events providing information related to errors in scripts or in files. */ -interface ErrorEvent extends Event { - readonly colno: number; - readonly error: any; - readonly filename: string; - readonly lineno: number; - readonly message: string; -} - -declare var ErrorEvent: { - prototype: ErrorEvent; - new(type: string, eventInitDict?: ErrorEventInit): ErrorEvent; -}; - -/** An event which takes place in the DOM. */ -interface Event { - /** Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise. */ - readonly bubbles: boolean; - cancelBubble: boolean; - /** Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method. */ - readonly cancelable: boolean; - /** Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. */ - readonly composed: boolean; - /** Returns the object whose event listener's callback is currently being invoked. */ - readonly currentTarget: EventTarget | null; - /** Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. */ - readonly defaultPrevented: boolean; - /** Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE. */ - readonly eventPhase: number; - /** Returns true if event was dispatched by the user agent, and false otherwise. */ - readonly isTrusted: boolean; - /** @deprecated */ - returnValue: boolean; - /** @deprecated */ - readonly srcElement: EventTarget | null; - /** Returns the object to which event is dispatched (its target). */ - readonly target: EventTarget | null; - /** Returns the event's timestamp as the number of milliseconds measured relative to the time origin. */ - readonly timeStamp: DOMHighResTimeStamp; - /** Returns the type of event, e.g. "click", "hashchange", or "submit". */ - readonly type: string; - /** Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget. */ - composedPath(): EventTarget[]; - /** @deprecated */ - initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void; - /** If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled. */ - preventDefault(): void; - /** Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects. */ - stopImmediatePropagation(): void; - /** When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object. */ - stopPropagation(): void; - readonly AT_TARGET: number; - readonly BUBBLING_PHASE: number; - readonly CAPTURING_PHASE: number; - readonly NONE: number; -} - -declare var Event: { - prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; - readonly AT_TARGET: number; - readonly BUBBLING_PHASE: number; - readonly CAPTURING_PHASE: number; - readonly NONE: number; -}; - -interface EventCounts { - forEach(callbackfn: (value: number, key: string, parent: EventCounts) => void, thisArg?: any): void; -} - -declare var EventCounts: { - prototype: EventCounts; - new(): EventCounts; -}; - -interface EventListener { - (evt: Event): void; -} - -interface EventListenerObject { - handleEvent(object: Event): void; -} - -interface EventSourceEventMap { - "error": Event; - "message": MessageEvent; - "open": Event; -} - -interface EventSource extends EventTarget { - onerror: ((this: EventSource, ev: Event) => any) | null; - onmessage: ((this: EventSource, ev: MessageEvent) => any) | null; - onopen: ((this: EventSource, ev: Event) => any) | null; - /** Returns the state of this EventSource object's connection. It can have the values described below. */ - readonly readyState: number; - /** Returns the URL providing the event stream. */ - readonly url: string; - /** Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise. */ - readonly withCredentials: boolean; - /** Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED. */ - close(): void; - readonly CLOSED: number; - readonly CONNECTING: number; - readonly OPEN: number; - addEventListener(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: (this: EventSource, event: MessageEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: (this: EventSource, event: MessageEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var EventSource: { - prototype: EventSource; - new(url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource; - readonly CLOSED: number; - readonly CONNECTING: number; - readonly OPEN: number; -}; - -/** EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. */ -interface EventTarget { - /** - * Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. - * - * The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. - * - * When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET. - * - * When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. - * - * When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. - * - * If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted. - * - * The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. - */ - addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void; - /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */ - dispatchEvent(event: Event): boolean; - /** Removes the event listener in target's event listener list with the same type, callback, and options. */ - removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void; -} - -declare var EventTarget: { - prototype: EventTarget; - new(): EventTarget; -}; - -/** @deprecated */ -interface External { - /** @deprecated */ - AddSearchProvider(): void; - /** @deprecated */ - IsSearchProviderInstalled(): void; -} - -/** @deprecated */ -declare var External: { - prototype: External; - new(): External; -}; - -/** Provides information about files and allows JavaScript in a web page to access their content. */ -interface File extends Blob { - readonly lastModified: number; - readonly name: string; - readonly webkitRelativePath: string; -} - -declare var File: { - prototype: File; - new(fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File; -}; - -/** An object of this type is returned by the files property of the HTML element; this lets you access the list of files selected with the element. It's also used for a list of files dropped into web content when using the drag and drop API; see the DataTransfer object for details on this usage. */ -interface FileList { - readonly length: number; - item(index: number): File | null; - [index: number]: File; -} - -declare var FileList: { - prototype: FileList; - new(): FileList; -}; - -interface FileReaderEventMap { - "abort": ProgressEvent; - "error": ProgressEvent; - "load": ProgressEvent; - "loadend": ProgressEvent; - "loadstart": ProgressEvent; - "progress": ProgressEvent; -} - -/** Lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read. */ -interface FileReader extends EventTarget { - readonly error: DOMException | null; - onabort: ((this: FileReader, ev: ProgressEvent) => any) | null; - onerror: ((this: FileReader, ev: ProgressEvent) => any) | null; - onload: ((this: FileReader, ev: ProgressEvent) => any) | null; - onloadend: ((this: FileReader, ev: ProgressEvent) => any) | null; - onloadstart: ((this: FileReader, ev: ProgressEvent) => any) | null; - onprogress: ((this: FileReader, ev: ProgressEvent) => any) | null; - readonly readyState: number; - readonly result: string | ArrayBuffer | null; - abort(): void; - readAsArrayBuffer(blob: Blob): void; - readAsBinaryString(blob: Blob): void; - readAsDataURL(blob: Blob): void; - readAsText(blob: Blob, encoding?: string): void; - readonly DONE: number; - readonly EMPTY: number; - readonly LOADING: number; - addEventListener(type: K, listener: (this: FileReader, ev: FileReaderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: FileReader, ev: FileReaderEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var FileReader: { - prototype: FileReader; - new(): FileReader; - readonly DONE: number; - readonly EMPTY: number; - readonly LOADING: number; -}; - -interface FileSystem { - readonly name: string; - readonly root: FileSystemDirectoryEntry; -} - -declare var FileSystem: { - prototype: FileSystem; - new(): FileSystem; -}; - -interface FileSystemDirectoryEntry extends FileSystemEntry { - createReader(): FileSystemDirectoryReader; - getDirectory(path?: string | null, options?: FileSystemFlags, successCallback?: FileSystemEntryCallback, errorCallback?: ErrorCallback): void; - getFile(path?: string | null, options?: FileSystemFlags, successCallback?: FileSystemEntryCallback, errorCallback?: ErrorCallback): void; -} - -declare var FileSystemDirectoryEntry: { - prototype: FileSystemDirectoryEntry; - new(): FileSystemDirectoryEntry; -}; - -/** Available only in secure contexts. */ -interface FileSystemDirectoryHandle extends FileSystemHandle { - readonly kind: "directory"; - getDirectoryHandle(name: string, options?: FileSystemGetDirectoryOptions): Promise; - getFileHandle(name: string, options?: FileSystemGetFileOptions): Promise; - removeEntry(name: string, options?: FileSystemRemoveOptions): Promise; - resolve(possibleDescendant: FileSystemHandle): Promise; -} - -declare var FileSystemDirectoryHandle: { - prototype: FileSystemDirectoryHandle; - new(): FileSystemDirectoryHandle; -}; - -interface FileSystemDirectoryReader { - readEntries(successCallback: FileSystemEntriesCallback, errorCallback?: ErrorCallback): void; -} - -declare var FileSystemDirectoryReader: { - prototype: FileSystemDirectoryReader; - new(): FileSystemDirectoryReader; -}; - -interface FileSystemEntry { - readonly filesystem: FileSystem; - readonly fullPath: string; - readonly isDirectory: boolean; - readonly isFile: boolean; - readonly name: string; - getParent(successCallback?: FileSystemEntryCallback, errorCallback?: ErrorCallback): void; -} - -declare var FileSystemEntry: { - prototype: FileSystemEntry; - new(): FileSystemEntry; -}; - -interface FileSystemFileEntry extends FileSystemEntry { - file(successCallback: FileCallback, errorCallback?: ErrorCallback): void; -} - -declare var FileSystemFileEntry: { - prototype: FileSystemFileEntry; - new(): FileSystemFileEntry; -}; - -/** Available only in secure contexts. */ -interface FileSystemFileHandle extends FileSystemHandle { - readonly kind: "file"; - getFile(): Promise; -} - -declare var FileSystemFileHandle: { - prototype: FileSystemFileHandle; - new(): FileSystemFileHandle; -}; - -/** Available only in secure contexts. */ -interface FileSystemHandle { - readonly kind: FileSystemHandleKind; - readonly name: string; - isSameEntry(other: FileSystemHandle): Promise; -} - -declare var FileSystemHandle: { - prototype: FileSystemHandle; - new(): FileSystemHandle; -}; - -/** Focus-related events like focus, blur, focusin, or focusout. */ -interface FocusEvent extends UIEvent { - readonly relatedTarget: EventTarget | null; -} - -declare var FocusEvent: { - prototype: FocusEvent; - new(type: string, eventInitDict?: FocusEventInit): FocusEvent; -}; - -interface FontFace { - ascentOverride: string; - descentOverride: string; - display: string; - family: string; - featureSettings: string; - lineGapOverride: string; - readonly loaded: Promise; - readonly status: FontFaceLoadStatus; - stretch: string; - style: string; - unicodeRange: string; - variant: string; - variationSettings: string; - weight: string; - load(): Promise; -} - -declare var FontFace: { - prototype: FontFace; - new(family: string, source: string | BinaryData, descriptors?: FontFaceDescriptors): FontFace; -}; - -interface FontFaceSetEventMap { - "loading": Event; - "loadingdone": Event; - "loadingerror": Event; -} - -interface FontFaceSet extends EventTarget { - onloading: ((this: FontFaceSet, ev: Event) => any) | null; - onloadingdone: ((this: FontFaceSet, ev: Event) => any) | null; - onloadingerror: ((this: FontFaceSet, ev: Event) => any) | null; - readonly ready: Promise; - readonly status: FontFaceSetLoadStatus; - check(font: string, text?: string): boolean; - load(font: string, text?: string): Promise; - forEach(callbackfn: (value: FontFace, key: FontFace, parent: FontFaceSet) => void, thisArg?: any): void; - addEventListener(type: K, listener: (this: FontFaceSet, ev: FontFaceSetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: FontFaceSet, ev: FontFaceSetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var FontFaceSet: { - prototype: FontFaceSet; - new(initialFaces: FontFace[]): FontFaceSet; -}; - -interface FontFaceSetLoadEvent extends Event { - readonly fontfaces: ReadonlyArray; -} - -declare var FontFaceSetLoadEvent: { - prototype: FontFaceSetLoadEvent; - new(type: string, eventInitDict?: FontFaceSetLoadEventInit): FontFaceSetLoadEvent; -}; - -interface FontFaceSource { - readonly fonts: FontFaceSet; -} - -/** Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data". */ -interface FormData { - append(name: string, value: string | Blob, fileName?: string): void; - delete(name: string): void; - get(name: string): FormDataEntryValue | null; - getAll(name: string): FormDataEntryValue[]; - has(name: string): boolean; - set(name: string, value: string | Blob, fileName?: string): void; - forEach(callbackfn: (value: FormDataEntryValue, key: string, parent: FormData) => void, thisArg?: any): void; -} - -declare var FormData: { - prototype: FormData; - new(form?: HTMLFormElement): FormData; -}; - -interface FormDataEvent extends Event { - /** Returns a FormData object representing names and values of elements associated to the target form. Operations on the FormData object will affect form data to be submitted. */ - readonly formData: FormData; -} - -declare var FormDataEvent: { - prototype: FormDataEvent; - new(type: string, eventInitDict: FormDataEventInit): FormDataEvent; -}; - -/** A change in volume. It is an AudioNode audio-processing module that causes a given gain to be applied to the input data before its propagation to the output. A GainNode always has exactly one input and one output, both with the same number of channels. */ -interface GainNode extends AudioNode { - readonly gain: AudioParam; -} - -declare var GainNode: { - prototype: GainNode; - new(context: BaseAudioContext, options?: GainOptions): GainNode; -}; - -/** - * This Gamepad API interface defines an individual gamepad or other controller, allowing access to information such as button presses, axis positions, and id. - * Available only in secure contexts. - */ -interface Gamepad { - readonly axes: ReadonlyArray; - readonly buttons: ReadonlyArray; - readonly connected: boolean; - readonly hapticActuators: ReadonlyArray; - readonly id: string; - readonly index: number; - readonly mapping: GamepadMappingType; - readonly timestamp: DOMHighResTimeStamp; -} - -declare var Gamepad: { - prototype: Gamepad; - new(): Gamepad; -}; - -/** - * An individual button of a gamepad or other controller, allowing access to the current state of different types of buttons available on the control device. - * Available only in secure contexts. - */ -interface GamepadButton { - readonly pressed: boolean; - readonly touched: boolean; - readonly value: number; -} - -declare var GamepadButton: { - prototype: GamepadButton; - new(): GamepadButton; -}; - -/** - * This Gamepad API interface contains references to gamepads connected to the system, which is what the gamepad events Window.gamepadconnected and Window.gamepaddisconnected are fired in response to. - * Available only in secure contexts. - */ -interface GamepadEvent extends Event { - readonly gamepad: Gamepad; -} - -declare var GamepadEvent: { - prototype: GamepadEvent; - new(type: string, eventInitDict: GamepadEventInit): GamepadEvent; -}; - -/** This Gamepad API interface represents hardware in the controller designed to provide haptic feedback to the user (if available), most commonly vibration hardware. */ -interface GamepadHapticActuator { - readonly type: GamepadHapticActuatorType; -} - -declare var GamepadHapticActuator: { - prototype: GamepadHapticActuator; - new(): GamepadHapticActuator; -}; - -interface GenericTransformStream { - readonly readable: ReadableStream; - readonly writable: WritableStream; -} - -/** An object able to programmatically obtain the position of the device. It gives Web content access to the location of the device. This allows a Web site or app to offer customized results based on the user's location. */ -interface Geolocation { - clearWatch(watchId: number): void; - getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback | null, options?: PositionOptions): void; - watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback | null, options?: PositionOptions): number; -} - -declare var Geolocation: { - prototype: Geolocation; - new(): Geolocation; -}; - -/** Available only in secure contexts. */ -interface GeolocationCoordinates { - readonly accuracy: number; - readonly altitude: number | null; - readonly altitudeAccuracy: number | null; - readonly heading: number | null; - readonly latitude: number; - readonly longitude: number; - readonly speed: number | null; -} - -declare var GeolocationCoordinates: { - prototype: GeolocationCoordinates; - new(): GeolocationCoordinates; -}; - -/** Available only in secure contexts. */ -interface GeolocationPosition { - readonly coords: GeolocationCoordinates; - readonly timestamp: EpochTimeStamp; -} - -declare var GeolocationPosition: { - prototype: GeolocationPosition; - new(): GeolocationPosition; -}; - -interface GeolocationPositionError { - readonly code: number; - readonly message: string; - readonly PERMISSION_DENIED: number; - readonly POSITION_UNAVAILABLE: number; - readonly TIMEOUT: number; -} - -declare var GeolocationPositionError: { - prototype: GeolocationPositionError; - new(): GeolocationPositionError; - readonly PERMISSION_DENIED: number; - readonly POSITION_UNAVAILABLE: number; - readonly TIMEOUT: number; -}; - -interface GlobalEventHandlersEventMap { - "abort": UIEvent; - "animationcancel": AnimationEvent; - "animationend": AnimationEvent; - "animationiteration": AnimationEvent; - "animationstart": AnimationEvent; - "auxclick": MouseEvent; - "beforeinput": InputEvent; - "blur": FocusEvent; - "canplay": Event; - "canplaythrough": Event; - "change": Event; - "click": MouseEvent; - "close": Event; - "compositionend": CompositionEvent; - "compositionstart": CompositionEvent; - "compositionupdate": CompositionEvent; - "contextmenu": MouseEvent; - "cuechange": Event; - "dblclick": MouseEvent; - "drag": DragEvent; - "dragend": DragEvent; - "dragenter": DragEvent; - "dragleave": DragEvent; - "dragover": DragEvent; - "dragstart": DragEvent; - "drop": DragEvent; - "durationchange": Event; - "emptied": Event; - "ended": Event; - "error": ErrorEvent; - "focus": FocusEvent; - "focusin": FocusEvent; - "focusout": FocusEvent; - "formdata": FormDataEvent; - "gotpointercapture": PointerEvent; - "input": Event; - "invalid": Event; - "keydown": KeyboardEvent; - "keypress": KeyboardEvent; - "keyup": KeyboardEvent; - "load": Event; - "loadeddata": Event; - "loadedmetadata": Event; - "loadstart": Event; - "lostpointercapture": PointerEvent; - "mousedown": MouseEvent; - "mouseenter": MouseEvent; - "mouseleave": MouseEvent; - "mousemove": MouseEvent; - "mouseout": MouseEvent; - "mouseover": MouseEvent; - "mouseup": MouseEvent; - "pause": Event; - "play": Event; - "playing": Event; - "pointercancel": PointerEvent; - "pointerdown": PointerEvent; - "pointerenter": PointerEvent; - "pointerleave": PointerEvent; - "pointermove": PointerEvent; - "pointerout": PointerEvent; - "pointerover": PointerEvent; - "pointerup": PointerEvent; - "progress": ProgressEvent; - "ratechange": Event; - "reset": Event; - "resize": UIEvent; - "scroll": Event; - "securitypolicyviolation": SecurityPolicyViolationEvent; - "seeked": Event; - "seeking": Event; - "select": Event; - "selectionchange": Event; - "selectstart": Event; - "slotchange": Event; - "stalled": Event; - "submit": SubmitEvent; - "suspend": Event; - "timeupdate": Event; - "toggle": Event; - "touchcancel": TouchEvent; - "touchend": TouchEvent; - "touchmove": TouchEvent; - "touchstart": TouchEvent; - "transitioncancel": TransitionEvent; - "transitionend": TransitionEvent; - "transitionrun": TransitionEvent; - "transitionstart": TransitionEvent; - "volumechange": Event; - "waiting": Event; - "webkitanimationend": Event; - "webkitanimationiteration": Event; - "webkitanimationstart": Event; - "webkittransitionend": Event; - "wheel": WheelEvent; -} - -interface GlobalEventHandlers { - /** - * Fires when the user aborts the download. - * @param ev The event. - */ - onabort: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null; - onanimationcancel: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; - onanimationend: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; - onanimationiteration: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; - onanimationstart: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; - onauxclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - /** - * Fires when the object loses the input focus. - * @param ev The focus event. - */ - onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null; - /** - * Occurs when playback is possible, but would require further buffering. - * @param ev The event. - */ - oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null; - oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Fires when the contents of the object or selection have changed. - * @param ev The event. - */ - onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Fires when the user clicks the left mouse button on the object - * @param ev The mouse event. - */ - onclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Fires when the user clicks the right mouse button in the client area, opening the context menu. - * @param ev The mouse event. - */ - oncontextmenu: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Fires when the user double-clicks the object. - * @param ev The mouse event. - */ - ondblclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - /** - * Fires on the source object continuously during a drag operation. - * @param ev The event. - */ - ondrag: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; - /** - * Fires on the source object when the user releases the mouse at the close of a drag operation. - * @param ev The event. - */ - ondragend: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; - /** - * Fires on the target element when the user drags the object to a valid drop target. - * @param ev The drag event. - */ - ondragenter: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; - /** - * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation. - * @param ev The drag event. - */ - ondragleave: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; - /** - * Fires on the target element continuously while the user drags the object over a valid drop target. - * @param ev The event. - */ - ondragover: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; - /** - * Fires on the source object when the user starts to drag a text selection or selected object. - * @param ev The event. - */ - ondragstart: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; - ondrop: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; - /** - * Occurs when the duration attribute is updated. - * @param ev The event. - */ - ondurationchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs when the media element is reset to its initial state. - * @param ev The event. - */ - onemptied: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs when the end of playback is reached. - * @param ev The event - */ - onended: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Fires when an error occurs during object loading. - * @param ev The event. - */ - onerror: OnErrorEventHandler; - /** - * Fires when the object receives focus. - * @param ev The event. - */ - onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null; - onformdata: ((this: GlobalEventHandlers, ev: FormDataEvent) => any) | null; - ongotpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; - oninput: ((this: GlobalEventHandlers, ev: Event) => any) | null; - oninvalid: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Fires when the user presses a key. - * @param ev The keyboard event - */ - onkeydown: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null; - /** - * Fires when the user presses an alphanumeric key. - * @param ev The event. - * @deprecated - */ - onkeypress: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null; - /** - * Fires when the user releases a key. - * @param ev The keyboard event - */ - onkeyup: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null; - /** - * Fires immediately after the browser loads the object. - * @param ev The event. - */ - onload: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs when media data is loaded at the current playback position. - * @param ev The event. - */ - onloadeddata: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs when the duration and dimensions of the media have been determined. - * @param ev The event. - */ - onloadedmetadata: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs when Internet Explorer begins looking for media data. - * @param ev The event. - */ - onloadstart: ((this: GlobalEventHandlers, ev: Event) => any) | null; - onlostpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; - /** - * Fires when the user clicks the object with either mouse button. - * @param ev The mouse event. - */ - onmousedown: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - onmouseenter: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - onmouseleave: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - /** - * Fires when the user moves the mouse over the object. - * @param ev The mouse event. - */ - onmousemove: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - /** - * Fires when the user moves the mouse pointer outside the boundaries of the object. - * @param ev The mouse event. - */ - onmouseout: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - /** - * Fires when the user moves the mouse pointer into the object. - * @param ev The mouse event. - */ - onmouseover: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - /** - * Fires when the user releases a mouse button while the mouse is over the object. - * @param ev The mouse event. - */ - onmouseup: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; - /** - * Occurs when playback is paused. - * @param ev The event. - */ - onpause: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs when the play method is requested. - * @param ev The event. - */ - onplay: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs when the audio or video has started playing. - * @param ev The event. - */ - onplaying: ((this: GlobalEventHandlers, ev: Event) => any) | null; - onpointercancel: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; - onpointerdown: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; - onpointerenter: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; - onpointerleave: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; - onpointermove: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; - onpointerout: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; - onpointerover: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; - onpointerup: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; - /** - * Occurs to indicate progress while downloading media data. - * @param ev The event. - */ - onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null; - /** - * Occurs when the playback rate is increased or decreased. - * @param ev The event. - */ - onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Fires when the user resets a form. - * @param ev The event. - */ - onreset: ((this: GlobalEventHandlers, ev: Event) => any) | null; - onresize: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null; - /** - * Fires when the user repositions the scroll box in the scroll bar on the object. - * @param ev The event. - */ - onscroll: ((this: GlobalEventHandlers, ev: Event) => any) | null; - onsecuritypolicyviolation: ((this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any) | null; - /** - * Occurs when the seek operation ends. - * @param ev The event. - */ - onseeked: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs when the current playback position is moved. - * @param ev The event. - */ - onseeking: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Fires when the current selection changes. - * @param ev The event. - */ - onselect: ((this: GlobalEventHandlers, ev: Event) => any) | null; - onselectionchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; - onselectstart: ((this: GlobalEventHandlers, ev: Event) => any) | null; - onslotchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs when the download has stopped. - * @param ev The event. - */ - onstalled: ((this: GlobalEventHandlers, ev: Event) => any) | null; - onsubmit: ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | null; - /** - * Occurs if the load operation has been intentionally halted. - * @param ev The event. - */ - onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs to indicate the current playback position. - * @param ev The event. - */ - ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null; - ontoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null; - ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined; - ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined; - ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined; - ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined; - ontransitioncancel: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; - ontransitionend: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; - ontransitionrun: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; - ontransitionstart: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; - /** - * Occurs when the volume is changed, or playback is muted or unmuted. - * @param ev The event. - */ - onvolumechange: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** - * Occurs when playback stops because the next frame of a video resource is not available. - * @param ev The event. - */ - onwaiting: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** @deprecated This is a legacy alias of `onanimationend`. */ - onwebkitanimationend: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** @deprecated This is a legacy alias of `onanimationiteration`. */ - onwebkitanimationiteration: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** @deprecated This is a legacy alias of `onanimationstart`. */ - onwebkitanimationstart: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** @deprecated This is a legacy alias of `ontransitionend`. */ - onwebkittransitionend: ((this: GlobalEventHandlers, ev: Event) => any) | null; - onwheel: ((this: GlobalEventHandlers, ev: WheelEvent) => any) | null; - addEventListener(type: K, listener: (this: GlobalEventHandlers, ev: GlobalEventHandlersEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: GlobalEventHandlers, ev: GlobalEventHandlersEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -interface HTMLAllCollection { - /** Returns the number of elements in the collection. */ - readonly length: number; - /** Returns the item with index index from the collection (determined by tree order). */ - item(nameOrIndex?: string): HTMLCollection | Element | null; - /** - * Returns the item with ID or name name from the collection. - * - * If there are multiple matching items, then an HTMLCollection object containing all those elements is returned. - * - * Only button, form, iframe, input, map, meta, object, select, and textarea elements can have a name for the purpose of this method; their name is given by the value of their name attribute. - */ - namedItem(name: string): HTMLCollection | Element | null; - [index: number]: Element; -} - -declare var HTMLAllCollection: { - prototype: HTMLAllCollection; - new(): HTMLAllCollection; -}; - -/** Hyperlink elements and provides special properties and methods (beyond those of the regular HTMLElement object interface that they inherit from) for manipulating the layout and presentation of such elements. */ -interface HTMLAnchorElement extends HTMLElement, HTMLHyperlinkElementUtils { - /** - * Sets or retrieves the character set used to encode the object. - * @deprecated - */ - charset: string; - /** - * Sets or retrieves the coordinates of the object. - * @deprecated - */ - coords: string; - download: string; - /** Sets or retrieves the language code of the object. */ - hreflang: string; - /** - * Sets or retrieves the shape of the object. - * @deprecated - */ - name: string; - ping: string; - referrerPolicy: string; - /** Sets or retrieves the relationship between the object and the destination of the link. */ - rel: string; - readonly relList: DOMTokenList; - /** - * Sets or retrieves the relationship between the object and the destination of the link. - * @deprecated - */ - rev: string; - /** - * Sets or retrieves the shape of the object. - * @deprecated - */ - shape: string; - /** Sets or retrieves the window or frame at which to target content. */ - target: string; - /** Retrieves or sets the text of the object as a string. */ - text: string; - type: string; - addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var HTMLAnchorElement: { - prototype: HTMLAnchorElement; - new(): HTMLAnchorElement; -}; - -/** Provides special properties and methods (beyond those of the regular object HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of elements. */ -interface HTMLAreaElement extends HTMLElement, HTMLHyperlinkElementUtils { - /** Sets or retrieves a text alternative to the graphic. */ - alt: string; - /** Sets or retrieves the coordinates of the object. */ - coords: string; - download: string; - /** - * Sets or gets whether clicks in this region cause action. - * @deprecated - */ - noHref: boolean; - ping: string; - referrerPolicy: string; - rel: string; - readonly relList: DOMTokenList; - /** Sets or retrieves the shape of the object. */ - shape: string; - /** Sets or retrieves the window or frame at which to target content. */ - target: string; - addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var HTMLAreaElement: { - prototype: HTMLAreaElement; - new(): HTMLAreaElement; -}; - -/** Provides access to the properties of