summaryrefslogtreecommitdiff
path: root/cli/dts/lib.deno.unstable.d.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/dts/lib.deno.unstable.d.ts')
-rw-r--r--cli/dts/lib.deno.unstable.d.ts257
1 files changed, 190 insertions, 67 deletions
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts
index 5be1db05b..7cc6a9e60 100644
--- a/cli/dts/lib.deno.unstable.d.ts
+++ b/cli/dts/lib.deno.unstable.d.ts
@@ -6,6 +6,7 @@
declare namespace Deno {
export {}; // stop default export type behavior
+ /** @category Testing */
export interface BenchDefinition {
fn: () => void | Promise<void>;
name: string;
@@ -62,6 +63,8 @@ declare namespace Deno {
* }
* });
* ```
+ *
+ * @category Testing
*/
export function bench(t: BenchDefinition): void;
@@ -82,6 +85,8 @@ declare namespace Deno {
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
+ *
+ * @category Testing
*/
export function bench(
name: string,
@@ -105,6 +110,8 @@ declare namespace Deno {
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
+ *
+ * @category Testing
*/
export function bench(fn: () => void | Promise<void>): void;
@@ -125,6 +132,8 @@ declare namespace Deno {
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
+ *
+ * @category Testing
*/
export function bench(
name: string,
@@ -149,6 +158,8 @@ declare namespace Deno {
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
+ *
+ * @category Testing
*/
export function bench(
options: Omit<BenchDefinition, "fn">,
@@ -172,6 +183,8 @@ declare namespace Deno {
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
+ *
+ * @category Testing
*/
export function bench(
options: Omit<BenchDefinition, "fn" | "name">,
@@ -192,6 +205,8 @@ declare namespace Deno {
* ```
*
* NOTE: This API is not implemented on Windows
+ *
+ * @category File System
*/
export function umask(mask?: number): number;
@@ -202,6 +217,8 @@ declare namespace Deno {
* ```ts
* const { columns, rows } = Deno.consoleSize(Deno.stdout.rid);
* ```
+ *
+ * @category I/O
*/
export function consoleSize(
rid: number,
@@ -224,6 +241,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-env` permission.
+ *
+ * @category Observability
*/
export function loadavg(): number[];
@@ -238,6 +257,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-env` permission.
+ *
+ * @category Runtime Environment
*/
export function osRelease(): string;
@@ -253,6 +274,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-env` permission.
+ *
+ * @category Runtime Environment
*/
export function systemMemoryInfo(): SystemMemoryInfo;
@@ -277,7 +300,10 @@ declare namespace Deno {
swapFree: number;
}
- /** The information of the network interface */
+ /** The information of the network interface.
+ *
+ * @category Network
+ */
export interface NetworkInterfaceInfo {
/** The network interface name */
name: string;
@@ -304,6 +330,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-env` permission.
+ *
+ * @category Network
*/
export function networkInterfaces(): NetworkInterfaceInfo[];
@@ -316,6 +344,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-env` permission.
+ *
+ * @category Runtime Environment
*/
export function getUid(): number | null;
@@ -328,10 +358,15 @@ declare namespace Deno {
* ```
*
* Requires `allow-env` permission.
+ *
+ * @category Runtime Environment
*/
export function getGid(): number | null;
- /** All plain number types for interfacing with foreign functions */
+ /** All plain number types for interfacing with foreign functions.
+ *
+ * @category FFI
+ */
type NativeNumberType =
| "u8"
| "i8"
@@ -342,7 +377,10 @@ declare namespace Deno {
| "f32"
| "f64";
- /** All BigInt number types for interfacing with foreign functions */
+ /** All BigInt number types for interfacing with foreign functions.
+ *
+ * @category FFI
+ */
type NativeBigIntType =
| "u64"
| "i64"
@@ -355,30 +393,44 @@ declare namespace Deno {
type NativeVoidType = "void";
- /** All possible types for interfacing with foreign functions */
+ /** All possible types for interfacing with foreign functions.
+ *
+ * @category FFI
+ */
export type NativeType =
| NativeNumberType
| NativeBigIntType
| NativePointerType
| NativeFunctionType;
+ /** @category FFI */
export type NativeResultType = NativeType | NativeVoidType;
+ /** @category FFI */
type ToNativeTypeMap =
& Record<NativeNumberType, number>
& Record<NativeBigIntType, PointerValue>
& Record<NativePointerType, TypedArray | PointerValue | null>
& Record<NativeFunctionType, PointerValue | null>;
- /** Type conversion for foreign symbol parameters and unsafe callback return types */
+ /** Type conversion for foreign symbol parameters and unsafe callback return
+ * types.
+ *
+ * @category FFI
+ */
type ToNativeType<T extends NativeType = NativeType> = ToNativeTypeMap[T];
+ /** @category FFI */
type ToNativeResultTypeMap = ToNativeTypeMap & Record<NativeVoidType, void>;
- /** Type conversion for unsafe callback return types */
+ /** Type conversion for unsafe callback return types.
+ *
+ * @category FFI
+ */
type ToNativeResultType<T extends NativeResultType = NativeResultType> =
ToNativeResultTypeMap[T];
+ /** @category FFI */
type ToNativeParameterTypes<T extends readonly NativeType[]> =
//
[(T[number])[]] extends [T] ? ToNativeType<T[number]>[]
@@ -389,23 +441,33 @@ declare namespace Deno {
}
: never;
+ /** @category FFI */
type FromNativeTypeMap =
& Record<NativeNumberType, number>
& Record<NativeBigIntType, PointerValue>
& Record<NativePointerType, PointerValue>
& Record<NativeFunctionType, PointerValue>;
- /** Type conversion for foreign symbol return types and unsafe callback parameters */
+ /** Type conversion for foreign symbol return types and unsafe callback
+ * parameters.
+ *
+ * @category FFI
+ */
type FromNativeType<T extends NativeType = NativeType> = FromNativeTypeMap[T];
+ /** @category FFI */
type FromNativeResultTypeMap =
& FromNativeTypeMap
& Record<NativeVoidType, void>;
- /** Type conversion for foregin symbol return types */
+ /** Type conversion for foreign symbol return types.
+ *
+ * @category FFI
+ */
type FromNativeResultType<T extends NativeResultType = NativeResultType> =
FromNativeResultTypeMap[T];
+ /** @category FFI */
type FromNativeParameterTypes<
T extends readonly NativeType[],
> =
@@ -418,7 +480,10 @@ declare namespace Deno {
}
: never;
- /** A foreign function as defined by its parameter and result types */
+ /** 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,
@@ -434,40 +499,54 @@ declare namespace Deno {
callback?: boolean;
}
+ /** @category FFI */
export interface ForeignStatic<Type extends NativeType = NativeType> {
/** Name of the symbol, defaults to the key name in symbols object. */
name?: string;
type: Type;
}
- /** A foreign library interface descriptor */
+ /** A foreign library interface descriptor.
+ *
+ * @category FFI
+ */
export interface ForeignLibraryInterface {
[name: string]: ForeignFunction | ForeignStatic;
}
- /** Infers a foreign symbol */
+ /** Infers a foreign symbol.
+ *
+ * @category FFI
+ */
type StaticForeignSymbol<T extends ForeignFunction | ForeignStatic> =
T extends ForeignFunction ? FromForeignFunction<T>
: T extends ForeignStatic ? FromNativeType<T["type"]>
: never;
+ /** @category FFI */
type FromForeignFunction<T extends ForeignFunction> = T["parameters"] extends
readonly [] ? () => StaticForeignSymbolReturnType<T>
: (
...args: ToNativeParameterTypes<T["parameters"]>
) => StaticForeignSymbolReturnType<T>;
+ /** @category FFI */
type StaticForeignSymbolReturnType<T extends ForeignFunction> =
ConditionalAsync<T["nonblocking"], FromNativeResultType<T["result"]>>;
+ /** @category FFI */
type ConditionalAsync<IsAsync extends boolean | undefined, T> =
IsAsync extends true ? Promise<T> : T;
- /** Infers a foreign library interface */
+ /** Infers a foreign library interface.
+ *
+ * @category FFI
+ */
type StaticForeignLibraryInterface<T extends ForeignLibraryInterface> = {
[K in keyof T]: StaticForeignSymbol<T[K]>;
};
+ /** @category FFI */
type TypedArray =
| Int8Array
| Uint8Array
@@ -487,12 +566,17 @@ declare namespace Deno {
* On a 32 bit system all pointer values are plain numbers. On a 64 bit
* system pointer values are represented as numbers if the value is below
* `Number.MAX_SAFE_INTEGER`.
+ *
+ * @category FFI
*/
export type PointerValue = number | bigint;
/** **UNSTABLE**: Unsafe and new API, beware!
*
- * An unsafe pointer to a memory location for passing and returning pointers to and from the ffi
+ * An unsafe pointer to a memory location for passing and returning pointers
+ * to and from the FFI.
+ *
+ * @category FFI
*/
export class UnsafePointer {
/**
@@ -507,6 +591,8 @@ declare namespace Deno {
* value. The `UnsafePointerView` API mimics the standard built in interface
* `DataView` for accessing the underlying types at an memory location
* (numbers, strings and raw bytes).
+ *
+ * @category FFI
*/
export class UnsafePointerView {
constructor(pointer: bigint);
@@ -560,6 +646,8 @@ declare namespace Deno {
*
* An unsafe pointer to a function, for calling functions that are not
* present as symbols.
+ *
+ * @category FFI
*/
export class UnsafeFnPointer<Fn extends ForeignFunction> {
pointer: bigint;
@@ -595,6 +683,8 @@ declare namespace Deno {
*
* The callback can be explicitly ref'ed and deref'ed to stop Deno's
* process from exiting.
+ *
+ * @category FFI
*/
export class UnsafeCallback<
Definition extends UnsafeCallbackDefinition = UnsafeCallbackDefinition,
@@ -651,56 +741,15 @@ declare namespace Deno {
/** **UNSTABLE**: Unsafe and new API, beware!
*
* Opens a dynamic library and registers symbols
+ *
+ * @category FFI
*/
export function dlopen<S extends ForeignLibraryInterface>(
filename: string | URL,
symbols: S,
): DynamicLibrary<S>;
- /** The log category for a diagnostic message. */
- export enum DiagnosticCategory {
- Warning = 0,
- Error = 1,
- Suggestion = 2,
- Message = 3,
- }
-
- export interface DiagnosticMessageChain {
- messageText: string;
- category: DiagnosticCategory;
- code: number;
- next?: DiagnosticMessageChain[];
- }
-
- export interface Diagnostic {
- /** A string message summarizing the diagnostic. */
- messageText?: string;
- /** An ordered array of further diagnostics. */
- messageChain?: DiagnosticMessageChain;
- /** Information related to the diagnostic. This is present when there is a
- * suggestion or other additional diagnostic information */
- relatedInformation?: Diagnostic[];
- /** The text of the source line related to the diagnostic. */
- sourceLine?: string;
- source?: string;
- /** The start position of the error. Zero based index. */
- start?: {
- line: number;
- character: number;
- };
- /** The end position of the error. Zero based index. */
- end?: {
- line: number;
- character: number;
- };
- /** The filename of the resource related to the diagnostic message. */
- fileName?: string;
- /** The category of the diagnostic. */
- category: DiagnosticCategory;
- /** A number identifier. */
- code: number;
- }
-
+ /** @category I/O */
export type SetRawOptions = {
cbreak: boolean;
};
@@ -720,6 +769,8 @@ declare namespace Deno {
* ```ts
* Deno.setRaw(Deno.stdin.rid, true, { cbreak: true });
* ```
+ *
+ * @category I/O
*/
export function setRaw(
rid: number,
@@ -737,7 +788,10 @@ declare namespace Deno {
* Deno.utimeSync("myfile.txt", 1556495550, new Date());
* ```
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function utimeSync(
path: string | URL,
atime: number | Date,
@@ -754,13 +808,17 @@ declare namespace Deno {
* await Deno.utime("myfile.txt", 1556495550, new Date());
* ```
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function utime(
path: string | URL,
atime: number | Date,
mtime: number | Date,
): Promise<void>;
+ /** @category Sub Process */
export function run<
T extends RunOptions & {
clearEnv?: boolean;
@@ -783,6 +841,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-env` permission.
+ *
+ * @category Runtime Environment
*/
export function hostname(): string;
@@ -794,6 +854,8 @@ declare namespace Deno {
* const client = Deno.createHttpClient({ caCerts: [ caCert ] });
* const req = await fetch("https://myserver.com", { client });
* ```
+ *
+ * @category Fetch API
*/
export class HttpClient {
rid: number;
@@ -802,6 +864,8 @@ declare namespace Deno {
/** **UNSTABLE**: New API, yet to be vetted.
* The options used when creating a [HttpClient].
+ *
+ * @category Fetch API
*/
export interface CreateHttpClientOptions {
/** A list of root certificates that will be used in addition to the
@@ -817,11 +881,13 @@ declare namespace Deno {
privateKey?: string;
}
+ /** @category Fetch API */
export interface Proxy {
url: string;
basicAuth?: BasicAuth;
}
+ /** @category Fetch API */
export interface BasicAuth {
username: string;
password: string;
@@ -840,6 +906,8 @@ declare namespace Deno {
* 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,
@@ -855,6 +923,8 @@ declare namespace Deno {
* 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,
@@ -872,6 +942,8 @@ declare namespace Deno {
* 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,
@@ -881,7 +953,10 @@ declare namespace Deno {
/** **UNSTABLE**: new API, yet to be vetted.
*
- * A generic transport listener for message-oriented protocols. */
+ * A generic transport listener for message-oriented protocols.
+ *
+ * @category Network
+ */
export interface DatagramConn extends AsyncIterable<[Uint8Array, Addr]> {
/** **UNSTABLE**: new API, yet to be vetted.
*
@@ -901,6 +976,7 @@ declare namespace Deno {
[Symbol.asyncIterator](): AsyncIterableIterator<[Uint8Array, Addr]>;
}
+ /** @category Network */
export interface UnixListenOptions {
/** A Path to the Unix Socket. */
path: string;
@@ -914,7 +990,10 @@ declare namespace Deno {
* const listener = Deno.listen({ path: "/foo/bar.sock", transport: "unix" })
* ```
*
- * Requires `allow-read` and `allow-write` permission. */
+ * Requires `allow-read` and `allow-write` permission.
+ *
+ * @category Network
+ */
export function listen(
options: UnixListenOptions & { transport: "unix" },
): Listener;
@@ -935,7 +1014,10 @@ declare namespace Deno {
* });
* ```
*
- * Requires `allow-net` permission. */
+ * Requires `allow-net` permission.
+ *
+ * @category Network
+ */
export function listenDatagram(
options: ListenOptions & { transport: "udp" },
): DatagramConn;
@@ -951,7 +1033,10 @@ declare namespace Deno {
* });
* ```
*
- * Requires `allow-read` and `allow-write` permission. */
+ * Requires `allow-read` and `allow-write` permission.
+ *
+ * @category Network
+ */
export function listenDatagram(
options: UnixListenOptions & { transport: "unixpacket" },
): DatagramConn;
@@ -975,7 +1060,10 @@ declare namespace Deno {
* const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
* ```
*
- * Requires `allow-net` permission for "tcp" and `allow-read` for "unix". */
+ * Requires `allow-net` permission for "tcp" and `allow-read` for "unix".
+ *
+ * @category Network
+ */
export function connect(
options: ConnectOptions,
): Promise<TcpConn>;
@@ -997,6 +1085,7 @@ declare namespace Deno {
alpnProtocols?: string[];
}
+ /** @category Network */
export interface TlsHandshakeInfo {
/** **UNSTABLE**: new API, yet to be vetted.
*
@@ -1006,6 +1095,7 @@ declare namespace Deno {
alpnProtocol: string | null;
}
+ /** @category Network */
export interface TlsConn extends Conn {
/** Runs the client or server handshake protocol to completion if that has
* not happened yet. Calling this method is optional; the TLS handshake
@@ -1027,9 +1117,12 @@ declare namespace Deno {
* ```
*
* Requires `allow-net` permission.
+ *
+ * @category Network
*/
export function connectTls(options: ConnectTlsOptions): Promise<TlsConn>;
+ /** @category Network */
export interface ListenTlsOptions {
/** **UNSTABLE**: new API, yet to be vetted.
*
@@ -1040,6 +1133,7 @@ declare namespace Deno {
alpnProtocols?: string[];
}
+ /** @category Network */
export interface StartTlsOptions {
/** **UNSTABLE**: new API, yet to be vetted.
*
@@ -1050,6 +1144,7 @@ declare namespace Deno {
alpnProtocols?: string[];
}
+ /** @category Network */
export interface Listener extends AsyncIterable<Conn> {
/** **UNSTABLE**: new API, yet to be vetted.
*
@@ -1070,6 +1165,8 @@ declare namespace Deno {
*
* 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<void>;
@@ -1077,34 +1174,44 @@ declare namespace Deno {
*
* Acquire an advisory file-system lock for the provided file. `exclusive`
* defaults to `false`.
+ *
+ * @category File System
*/
export function flockSync(rid: number, exclusive?: boolean): void;
/** **UNSTABLE**: New API should be tested first.
*
* Release an advisory file-system lock for the provided file.
+ *
+ * @category File System
*/
export function funlock(rid: number): Promise<void>;
/** **UNSTABLE**: New API should be tested first.
*
* Release an advisory file-system lock for the provided file.
+ *
+ * @category File System
*/
export function funlockSync(rid: number): void;
/** **UNSTABLE**: new API, yet to be vetted.
*
- * Make the timer of the given id blocking the event loop from finishing
+ * Make the timer of the given id blocking the event loop from finishing.
+ *
+ * @category Timers
*/
export function refTimer(id: number): void;
/** **UNSTABLE**: new API, yet to be vetted.
*
- * Make the timer of the given id not blocking the event loop from finishing
+ * Make the timer of the given id not blocking the event loop from finishing.
+ *
+ * @category Timers
*/
export function unrefTimer(id: number): void;
- /** **UNSTABLE**: new API, yet to be vetter.
+ /** **UNSTABLE**: new API, yet to be vetted.
*
* Allows to "hijack" a connection that the request is associated with.
* Can be used to implement protocols that build on top of HTTP (eg.
@@ -1113,11 +1220,14 @@ declare namespace Deno {
* 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.
+ *
+ * @category HTTP Server
*/
export function upgradeHttp(
request: Request,
): Promise<[Deno.Conn, Uint8Array]>;
+ /** @category Sub Process */
export interface SpawnOptions {
/** Arguments to pass to the process. */
args?: string[];
@@ -1181,12 +1291,15 @@ declare namespace Deno {
* child.stdin.close();
* const status = await child.status;
* ```
+ *
+ * @category Sub Process
*/
export function spawnChild(
command: string | URL,
options?: SpawnOptions,
): Child;
+ /** @category Sub Process */
export class Child {
get stdin(): WritableStream<Uint8Array>;
get stdout(): ReadableStream<Uint8Array>;
@@ -1223,6 +1336,8 @@ declare namespace Deno {
* 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,
@@ -1248,6 +1363,8 @@ declare namespace Deno {
* 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,
@@ -1266,11 +1383,13 @@ declare namespace Deno {
}
}
+/** @category Fetch API */
declare function fetch(
input: Request | URL | string,
init?: RequestInit & { client: Deno.HttpClient },
): Promise<Response>;
+/** @category Web Workers */
declare interface WorkerOptions {
/** UNSTABLE: New API.
*
@@ -1304,12 +1423,14 @@ declare interface WorkerOptions {
};
}
+/** @category Web Sockets */
declare interface WebSocketStreamOptions {
protocols?: string[];
signal?: AbortSignal;
headers?: HeadersInit;
}
+/** @category Web Sockets */
declare interface WebSocketConnection {
readable: ReadableStream<string | Uint8Array>;
writable: WritableStream<string | Uint8Array>;
@@ -1317,11 +1438,13 @@ declare interface WebSocketConnection {
protocol: string;
}
+/** @category Web Sockets */
declare interface WebSocketCloseInfo {
code?: number;
reason?: string;
}
+/** @category Web Sockets */
declare class WebSocketStream {
constructor(url: string, options?: WebSocketStreamOptions);
url: string;