diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index 99e4001..ffaff4e 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -38,7 +38,7 @@ declare namespace Deno { enum TestStatus { Passed = "passed", Failed = "failed", - Ignored = "ignored" + Ignored = "ignored", } interface TestResult { @@ -60,7 +60,7 @@ declare namespace Deno { Start = "start", TestStart = "testStart", TestEnd = "testEnd", - End = "end" + End = "end", } interface TestEventStart { @@ -134,9 +134,11 @@ declare namespace Deno { */ export function loadavg(): number[]; - /** Get the `hostname`. Requires `allow-env` permission. + /** Get the `hostname` of the machine the Deno process is running on. * * console.log(Deno.hostname()); + * + * Requires `allow-env` permission. */ export function hostname(): string; @@ -146,34 +148,35 @@ declare namespace Deno { */ export function osRelease(): string; - /** Exit the Deno process with optional exit code. */ + /** Exit the Deno process with optional exit code. If no exit code is supplied + * then Deno will exit with return code of 0. + * + * Deno.exit(5); + */ export function exit(code?: number): never; - /** Returns a snapshot of the environment variables at invocation. Mutating a - * property in the object will set that variable in the environment for the - * process. The environment object will only accept `string`s as values. + /** Without any parameters, this will return a snapshot of the environment + * variables at invocation. Changing a property in the object will set that + * variable in the environment for the process. The environment object will + * only accept `string`s as values. + * + * Passing in a `string` key parameter will return the value for that environment + * variable, or undefined if that key doesn't exist. * * const myEnv = Deno.env(); * console.log(myEnv.SHELL); * myEnv.TEST_VAR = "HELLO"; * const newEnv = Deno.env(); - * console.log(myEnv.TEST_VAR == newEnv.TEST_VAR); + * console.log(myEnv.TEST_VAR === newEnv.TEST_VAR); //outputs "true" + * console.log(Deno.env("TEST_VAR")); //outputs "HELLO" + * console.log(Deno.env("MADE_UP_VAR")); //outputs "Undefined" * * Requires `allow-env` permission. */ export function env(): { [index: string]: string; }; - /** Returns the value of an environment variable at invocation. If the - * variable is not present, `undefined` will be returned. - * - * const myEnv = Deno.env(); - * console.log(myEnv.SHELL); - * myEnv.TEST_VAR = "HELLO"; - * const newEnv = Deno.env(); - * console.log(myEnv.TEST_VAR == newEnv.TEST_VAR); - * - * Requires `allow-env` permission. */ + /** See overloaded parent function Deno.env() */ export function env(key: string): string | undefined; /** **UNSTABLE** */ @@ -195,12 +198,14 @@ declare namespace Deno { | "tmp" | "video"; - // TODO(ry) markdown in jsdoc broken https://deno.land/typedoc/index.html#dir /** - * **UNSTABLE**: Might rename method `dir` and type alias `DirKind`. + * **UNSTABLE**: Currently under evaluation to decide if method name `dir` and + * parameter type alias name `DirKind` should be renamed. * * Returns the user and platform specific directories. * + * const homeDirectory = Deno.dir("home"); + * * Requires `allow-env` permission. * * Returns `null` if there is no applicable directory or if any other error @@ -210,6 +215,14 @@ declare namespace Deno { * `"data_local"`, `"audio"`, `"desktop"`, `"document"`, `"download"`, * `"font"`, `"picture"`, `"public"`, `"template"`, `"tmp"`, `"video"` * + * `"home"` + * + * |Platform | Value | Example | + * | ------- | -----------------------------------------| -----------------------| + * | Linux | `$HOME` | /home/alice | + * | macOS | `$HOME` | /Users/alice | + * | Windows | `{FOLDERID_Profile}` | C:\Users\Alice | + * * `"cache"` * * |Platform | Value | Example | @@ -336,18 +349,23 @@ declare namespace Deno { /** * Returns the path to the current deno executable. * + * console.log(Deno.execPath()); //e.g. "/home/alice/.local/bin/deno" + * * Requires `allow-env` permission. */ export function execPath(): string; /** - * **UNSTABLE**: maybe needs permissions. + * **UNSTABLE**: Currently under evaluation to decide if explicit permission is + * required to get the value of the current working directory. * * 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. * + * const currentWorkingDirectory = Deno.cwd(); + * * Throws `Deno.errors.NotFound` if directory not available. */ export function cwd(): string; @@ -384,7 +402,7 @@ declare namespace Deno { export enum SeekMode { SEEK_START = 0, SEEK_CURRENT = 1, - SEEK_END = 2 + SEEK_END = 2, } /** **UNSTABLE**: might make `Reader` into iterator of some sort. */ @@ -501,8 +519,16 @@ declare namespace Deno { * error occurs. It resolves to the number of bytes copied or rejects with * the first error encountered while copying. * + * const source = await Deno.open("my_file.txt"); + * const buffer = new Deno.Buffer() + * const bytesCopied1 = await Deno.copy(Deno.stdout, source); + * const bytesCopied2 = await Deno.copy(buffer, source); + * * Because `copy()` is defined to read from `src` until `EOF`, it does not * treat an `EOF` from `read()` as an error to be reported. + * + * @param dst The destination to copy to + * @param src The source to copy from */ export function copy(dst: Writer, src: Reader): Promise; @@ -634,7 +660,9 @@ declare namespace Deno { * as via opening or creating a file. Closing a file when you are finished * with it is important to avoid leaking resources. * - * Deno.close(4); + * const file = await Deno.open("my_file.txt"); + * // do work with "file" object + * Deno.close(file.rid); */ export function close(rid: number): void; @@ -715,12 +743,21 @@ declare namespace Deno { */ export type OpenMode = "r" | "r+" | "w" | "w+" | "a" | "a+" | "x" | "x+"; - /** **UNSTABLE**: newly added API + /** **UNSTABLE**: new API, yet to be vetted + * + * Check if a given resource id (`rid`) is a TTY. * - * Check if a given resource is TTY. */ + * //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); + */ export function isatty(rid: number): boolean; - /** **UNSTABLE**: newly added API + /** **UNSTABLE**: new API, yet to be vetted * * Set TTY to be under raw mode or not. */ export function setRaw(rid: number, mode: boolean): void; @@ -729,12 +766,6 @@ declare namespace Deno { * * Based on [Go Buffer](https://golang.org/pkg/bytes/#Buffer). */ export class Buffer implements Reader, SyncReader, Writer, SyncWriter { - private buf; - private off; - private _tryGrowByReslice; - private _reslice; - private _grow; - constructor(ab?: ArrayBuffer); /** Returns a slice holding the unread portion of the buffer. * @@ -975,7 +1006,7 @@ declare namespace Deno { /** Synchronously change owner of a regular file or directory. This functionality * is not available on Windows. * - * Deno.chownSync('myFile.txt', 1000, 1002); + * Deno.chownSync("myFile.txt", 1000, 1002); * * Requires `allow-write` permission. * @@ -990,7 +1021,7 @@ declare namespace Deno { /** Change owner of a regular file or directory. This functionality * is not available on Windows. * - * await Deno.chown('myFile.txt', 1000, 1002); + * await Deno.chown("myFile.txt", 1000, 1002); * * Requires `allow-write` permission. * @@ -1546,21 +1577,18 @@ declare namespace Deno { * * Requires `allow-plugin` permission. */ export function openPlugin(filename: string): Plugin; - - export type Transport = "tcp" | "udp"; - - export interface Addr { - transport: Transport; + export interface NetAddr { + transport: "tcp" | "udp"; hostname: string; port: number; } - export interface UDPAddr { - port: number; - transport?: Transport; - hostname?: string; + export interface UnixAddr { + transport: "unix" | "unixpacket"; + address: string; } + export type Addr = NetAddr | UnixAddr; /** **UNSTABLE**: Maybe remove `ShutdownMode` entirely. * * Corresponds to `SHUT_RD`, `SHUT_WR`, `SHUT_RDWR` on POSIX-like systems. @@ -1569,7 +1597,7 @@ declare namespace Deno { export enum ShutdownMode { Read = 0, Write, - ReadWrite // TODO(ry) panics on ReadWrite. + ReadWrite, // TODO(ry) panics on ReadWrite. } /** **UNSTABLE**: Maybe should remove `how` parameter maybe remove @@ -1585,18 +1613,10 @@ declare namespace Deno { */ export function shutdown(rid: number, how: ShutdownMode): void; - /** **UNSTABLE**: new API, yet to be vetted. - * - * Waits for the next message to the passed `rid` and writes it on the passed - * `Uint8Array`. - * - * Resolves to the number of bytes written and the remote address. */ - export function recvfrom(rid: number, p: Uint8Array): Promise<[number, Addr]>; - /** **UNSTABLE**: new API, yet to be vetted. * * A generic transport listener for message-oriented protocols. */ - export interface UDPConn extends AsyncIterable<[Uint8Array, Addr]> { + export interface DatagramConn extends AsyncIterable<[Uint8Array, Addr]> { /** **UNSTABLE**: new API, yet to be vetted. * * Waits for and resolves to the next message to the `UDPConn`. */ @@ -1604,7 +1624,7 @@ declare namespace Deno { /** UNSTABLE: new API, yet to be vetted. * * Sends a message to the target. */ - send(p: Uint8Array, addr: UDPAddr): Promise; + send(p: Uint8Array, addr: Addr): Promise; /** UNSTABLE: new API, yet to be vetted. * * Close closes the socket. Any pending message promises will be rejected @@ -1624,6 +1644,7 @@ declare namespace Deno { close(): void; /** Return the address of the `Listener`. */ readonly addr: Addr; + [Symbol.asyncIterator](): AsyncIterator; } @@ -1648,13 +1669,12 @@ declare namespace Deno { /** A literal IP address or host name that can be resolved to an IP address. * If not specified, defaults to `0.0.0.0`. */ hostname?: string; - /** Either `"tcp"` or `"udp"`. Defaults to `"tcp"`. - * - * In the future: `"tcp4"`, `"tcp6"`, `"udp4"`, `"udp6"`, `"ip"`, `"ip4"`, - * `"ip6"`, `"unix"`, `"unixgram"`, and `"unixpacket"`. */ - transport?: Transport; } + export interface UnixListenOptions { + /** A Path to the Unix Socket. */ + address: string; + } /** **UNSTABLE**: new API * * Listen announces on the local transport address. @@ -1672,32 +1692,41 @@ declare namespace Deno { * * Listen announces on the local transport address. * - * Deno.listen({ port: 80 }) - * Deno.listen({ hostname: "192.0.2.1", port: 80 }) - * Deno.listen({ hostname: "[2001:db8::1]", port: 80 }); - * Deno.listen({ hostname: "golang.org", port: 80, transport: "tcp" }); + * Deno.listen({ address: "/foo/bar.sock", transport: "unix" }) + * + * Requires `allow-read` permission. */ + export function listen( + options: UnixListenOptions & { transport: "unix" } + ): Listener; + /** **UNSTABLE**: new API + * + * Listen announces on the local transport address. + * + * Deno.listen({ port: 80, transport: "udp" }) + * Deno.listen({ hostname: "golang.org", port: 80, transport: "udp" }); * * Requires `allow-net` permission. */ export function listen( options: ListenOptions & { transport: "udp" } - ): UDPConn; + ): DatagramConn; /** **UNSTABLE**: new API * * Listen announces on the local transport address. * - * Deno.listen({ port: 80 }) - * Deno.listen({ hostname: "192.0.2.1", port: 80 }) - * Deno.listen({ hostname: "[2001:db8::1]", port: 80 }); - * Deno.listen({ hostname: "golang.org", port: 80, transport: "tcp" }); + * Deno.listen({ address: "/foo/bar.sock", transport: "unixpacket" }) * - * Requires `allow-net` permission. */ - export function listen(options: ListenOptions): Listener | UDPConn; + * Requires `allow-read` permission. */ + export function listen( + options: UnixListenOptions & { transport: "unixpacket" } + ): DatagramConn; export interface ListenTLSOptions extends ListenOptions { /** Server certificate file. */ certFile: string; /** Server public key file. */ keyFile: string; + + transport?: "tcp"; } /** Listen announces on the local transport address over TLS (transport layer @@ -1714,24 +1743,28 @@ declare namespace Deno { /** A literal IP address or host name that can be resolved to an IP address. * If not specified, defaults to `127.0.0.1`. */ hostname?: string; - /** Either `"tcp"` or `"udp"`. Defaults to `"tcp"`. - * - * In the future: `"tcp4"`, `"tcp6"`, `"udp4"`, `"udp6"`, `"ip"`, `"ip4"`, - * `"ip6"`, `"unix"`, `"unixgram"`, and `"unixpacket"`. */ - transport?: Transport; + transport?: "tcp"; + } + + export interface UnixConnectOptions { + transport: "unix"; + address: string; } /** * Connects to the hostname (default is "127.0.0.1") and port on the named * transport (default is "tcp"). * - * const conn1 = await Deno.connect({ port: 80 }) - * const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 }) + * 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 conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" }); + * const conn5 = await Deno.connect({ address: "/foo/bar.sock", transport: "unix" }); * - * Requires `allow-net` permission. */ - export function connect(options: ConnectOptions): Promise; + * Requires `allow-net` permission for "tcp" and `allow-read` for unix. */ + export function connect( + options: ConnectOptions | UnixConnectOptions + ): Promise; export interface ConnectTLSOptions { /** The port to connect to. */ @@ -1743,9 +1776,18 @@ declare namespace Deno { certFile?: string; } - /** Establishes a secure connection over TLS (transport layer security). + /** Establishes a secure connection over TLS (transport layer security) using + * an optional cert file, hostname (default is "127.0.0.1") and port. The + * cert file is optional and if not included Mozilla's root certificates will + * be used (see also https://github.com/ctz/webpki-roots for specifics) * - * Requires `allow-net` permission. */ + * const conn1 = await Deno.connectTLS({ port: 80 }); + * const conn2 = await Deno.connectTLS({ certFile: "./certs/my_custom_root_CA.pem", hostname: "192.0.2.1", port: 80 }); + * const conn3 = await Deno.connectTLS({ hostname: "[2001:db8::1]", port: 80 }); + * const conn4 = await Deno.connectTLS({ certFile: "./certs/my_custom_root_CA.pem", hostname: "golang.org", port: 80}); + * + * Requires `allow-net` permission. + */ export function connectTLS(options: ConnectTLSOptions): Promise; /** **UNSTABLE**: not sure if broken or not */ @@ -1803,9 +1845,23 @@ declare namespace Deno { paths: string[]; } - /** **UNSTABLE**: new API. Needs docs. + /** **UNSTABLE**: new API, yet to be vetted. + * + * 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`). 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. * - * Recursive option is `true` by default. */ + * const iter = Deno.fsEvents("/"); + * for await (const event of iter) { + * console.log(">>>> event", event); //e.g. { kind: "create", paths: [ "/foo.txt" ] } + * } + * + * Requires `allow-read` permission. + */ export function fsEvents( paths: string | string[], options?: { recursive: boolean } @@ -1823,15 +1879,22 @@ declare namespace Deno { * the stream to `/dev/null`. */ type ProcessStdio = "inherit" | "piped" | "null"; - /** **UNSTABLE**: the `signo` argument maybe shouldn't be number. Should throw - * on Windows instead of silently succeeding. + /** **UNSTABLE**: The `signo` argument may change to require the Deno.Signal + * enum. * - * Send a signal to process under given `pid`. Linux/Mac OS only currently. + * Send a signal to process under given `pid`. This functionality currently + * only works on Linux and Mac OS. * * If `pid` is negative, the signal will be sent to the process group * identified by `pid`. * - * Currently no-op on Windows. + * const p = Deno.run({ + * cmd: ["python", "-c", "from time import sleep; sleep(10000)"] + * }); + * + * Deno.kill(p.pid, Deno.Signal.SIGINT); + * + * Throws Error (not yet implemented) on Windows * * Requires `allow-run` permission. */ export function kill(pid: number, signo: number): void; @@ -1929,7 +1992,7 @@ declare namespace Deno { SIGWINCH = 28, SIGIO = 29, SIGPWR = 30, - SIGSYS = 31 + SIGSYS = 31, } enum MacOSSignal { SIGHUP = 1, @@ -1962,7 +2025,7 @@ declare namespace Deno { SIGWINCH = 28, SIGINFO = 29, SIGUSR1 = 30, - SIGUSR2 = 31 + SIGUSR2 = 31, } /** **UNSTABLE**: make platform independent. @@ -1970,20 +2033,45 @@ declare namespace Deno { * Signals numbers. This is platform dependent. */ export const Signal: typeof MacOSSignal | typeof LinuxSignal; - /** **UNSTABLE**: rename to `InspectOptions`. */ - interface ConsoleOptions { + interface InspectOptions { showHidden?: boolean; depth?: number; colors?: boolean; indentLevel?: number; } - /** **UNSTABLE**: `ConsoleOptions` rename to `InspectOptions`. Also the exact - * form of string output subject to change. + /** **UNSTABLE**: The exact form of the string output is under consideration + * and may change. + * + * Converts the input into a string that has the same format as printed by + * `console.log()`. + * + * const obj = {}; + * obj.propA = 10; + * obj.propB = "hello" + * const objAsString = Deno.inspect(obj); //{ propA: 10, propB: "hello" } + * console.log(obj); //prints same value as objAsString, e.g. { propA: 10, propB: "hello" } * - * Converts input into string that has the same format as printed by - * `console.log()`. */ - export function inspect(value: unknown, options?: ConsoleOptions): string; + * You can also register custom inspect functions, via the `customInspect` Deno + * symbol on objects, to control and customize the output. + * + * class A { + * x = 10; + * y = "hello"; + * [Deno.symbols.customInspect](): string { + * 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" + * + * Finally, a number of output options are also available. + * + * const out = Deno.inspect(obj, {showHidden: true, depth: 4, colors: true, indentLevel: 2}); + * + */ + export function inspect(value: unknown, options?: InspectOptions): string; export type OperatingSystem = "mac" | "win" | "linux"; @@ -2014,7 +2102,7 @@ declare namespace Deno { Info = 2, Error = 3, Warning = 4, - Suggestion = 5 + Suggestion = 5, } export interface DiagnosticMessageChain { @@ -2059,7 +2147,13 @@ declare namespace Deno { /** **UNSTABLE**: new API, yet to be vetted. * - * Format an array of diagnostic items and return them as a single string. + * Format an array of diagnostic items and return them as a single string in a + * user friendly format. + * + * const [diagnostics, result] = Deno.compile("file_with_compile_issues.ts"); + * console.table(diagnostics); //Prints raw diagnostic data + * console.log(Deno.formatDiagnostics(diagnostics)); //User friendly output of diagnostics + * * @param items An array of diagnostic items to format */ export function formatDiagnostics(items: DiagnosticItem[]): string; diff --git a/cli/js/lib.deno.shared_globals.d.ts b/cli/js/lib.deno.shared_globals.d.ts index 1be54ad..565121b 100644 --- a/cli/js/lib.deno.shared_globals.d.ts +++ b/cli/js/lib.deno.shared_globals.d.ts @@ -18,8 +18,8 @@ declare interface WindowOrWorkerGlobalScope { clearInterval: typeof __timers.clearInterval; clearTimeout: typeof __timers.clearTimeout; fetch: typeof __fetch.fetch; - queueMicrotask: (task: () => void) => void; setInterval: typeof __timers.setInterval; + queueMicrotask: typeof __timers.queueMicrotask; setTimeout: typeof __timers.setTimeout; // properties console: __console.Console; @@ -232,6 +232,7 @@ declare const clearTimeout: typeof __timers.clearTimeout; declare const fetch: typeof __fetch.fetch; declare const setInterval: typeof __timers.setInterval; declare const setTimeout: typeof __timers.setTimeout; +declare const queueMicrotask: typeof __timers.queueMicrotask; declare const console: __console.Console; declare const Blob: typeof __blob.DenoBlob; @@ -338,12 +339,8 @@ declare namespace __domTypes { export enum NodeType { ELEMENT_NODE = 1, TEXT_NODE = 3, - DOCUMENT_FRAGMENT_NODE = 11 + DOCUMENT_FRAGMENT_NODE = 11, } - export const eventTargetHost: unique symbol; - export const eventTargetListeners: unique symbol; - export const eventTargetMode: unique symbol; - export const eventTargetNodeType: unique symbol; export interface EventListener { (evt: Event): void | Promise; } @@ -357,11 +354,11 @@ declare namespace __domTypes { callback: EventListenerOrEventListenerObject; options: AddEventListenerOptions; } + export const eventTargetHost: unique symbol; + export const eventTargetListeners: unique symbol; + export const eventTargetMode: unique symbol; + export const eventTargetNodeType: unique symbol; export interface EventTarget { - [eventTargetHost]: EventTarget | null; - [eventTargetListeners]: { [type in string]: EventListener[] }; - [eventTargetMode]: string; - [eventTargetNodeType]: NodeType; addEventListener( type: string, callback: EventListenerOrEventListenerObject | null, @@ -437,7 +434,7 @@ declare namespace __domTypes { NONE = 0, CAPTURING_PHASE = 1, AT_TARGET = 2, - BUBBLING_PHASE = 3 + BUBBLING_PHASE = 3, } export interface EventPath { item: EventTarget; @@ -531,16 +528,78 @@ declare namespace __domTypes { options?: boolean | EventListenerOptions ): void; } - export interface ReadableStream { + export interface ReadableStreamReadDoneResult { + done: true; + value?: T; + } + export interface ReadableStreamReadValueResult { + done: false; + value: T; + } + export type ReadableStreamReadResult = + | ReadableStreamReadValueResult + | ReadableStreamReadDoneResult; + export interface ReadableStreamDefaultReader { + readonly closed: Promise; + cancel(reason?: any): Promise; + read(): Promise>; + releaseLock(): void; + } + export interface PipeOptions { + preventAbort?: boolean; + preventCancel?: boolean; + preventClose?: boolean; + signal?: AbortSignal; + } + /** This Streams API interface represents a readable stream of byte data. The + * Fetch API offers a concrete instance of a ReadableStream through the body + * property of a Response object. */ + export interface ReadableStream { readonly locked: boolean; - cancel(): Promise; - getReader(): ReadableStreamReader; - tee(): [ReadableStream, ReadableStream]; + cancel(reason?: any): Promise; + getReader(options: { mode: "byob" }): ReadableStreamBYOBReader; + getReader(): ReadableStreamDefaultReader; + /* disabled for now + pipeThrough( + { + writable, + readable + }: { + writable: WritableStream; + readable: ReadableStream; + }, + options?: PipeOptions + ): ReadableStream; + pipeTo(dest: WritableStream, options?: PipeOptions): Promise; + */ + tee(): [ReadableStream, ReadableStream]; + } + export interface ReadableStreamReader { + cancel(reason: any): Promise; + read(): Promise>; + releaseLock(): void; } - export interface ReadableStreamReader { - cancel(): Promise; - read(): Promise; + export interface ReadableStreamBYOBReader { + readonly closed: Promise; + cancel(reason?: any): Promise; + read( + view: T + ): Promise>; + releaseLock(): void; + } + export interface WritableStream { + readonly locked: boolean; + abort(reason?: any): Promise; + getWriter(): WritableStreamDefaultWriter; + } + export interface WritableStreamDefaultWriter { + readonly closed: Promise; + readonly desiredSize: number | null; + readonly ready: Promise; + abort(reason?: any): Promise; + close(): Promise; releaseLock(): void; + write(chunk: W): Promise; } export interface FormData extends DomIterable { append(name: string, value: string | Blob, fileName?: string): void; @@ -569,7 +628,7 @@ declare namespace __domTypes { } export interface Body { /** A simple getter used to expose a `ReadableStream` of the body contents. */ - readonly body: ReadableStream | null; + readonly body: ReadableStream | null; /** Stores a `Boolean` that declares whether the body has been used in a * response yet. */ @@ -798,58 +857,63 @@ declare namespace __domTypes { /** Creates a clone of a `Response` object. */ clone(): Response; } + export 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; + } + /** The location (URL) of the object it is linked to. Changes done on it are + * reflected on the object it relates to. Both the Document and Window + * interface have such a linked Location, accessible via Document.location and + * Window.location respectively. */ export interface Location { - /** - * Returns a DOMStringList object listing the origins of the ancestor browsing - * contexts, from the parent browsing context to the top-level browsing - * context. - */ - readonly ancestorOrigins: string[]; - /** - * Returns the Location object's URL's fragment (includes leading "#" if + /** Returns a DOMStringList object listing the origins of the ancestor + * browsing contexts, from the parent browsing context to the top-level + * browsing context. */ + readonly ancestorOrigins: DOMStringList; + /** Returns the Location object's URL's fragment (includes leading "#" if * non-empty). + * * Can be set, to navigate to the same URL with a changed fragment (ignores - * leading "#"). - */ + * leading "#"). */ hash: string; - /** - * Returns the Location object's URL's host and port (if different from the - * default port for the scheme). Can be set, to navigate to the same URL with - * a changed host and port. - */ + /** Returns the Location object's URL's host and port (if different from the + * default port for the scheme). + * + * Can be set, to navigate to the same URL with a changed host and port. */ host: string; - /** - * Returns the Location object's URL's host. Can be set, to navigate to the - * same URL with a changed host. - */ + /** Returns the Location object's URL's host. + * + * Can be set, to navigate to the same URL with a changed host. */ hostname: string; - /** - * Returns the Location object's URL. Can be set, to navigate to the given - * URL. - */ + /** Returns the Location object's URL. + * + * Can be set, to navigate to the given URL. */ href: string; + toString(): string; /** Returns the Location object's URL's origin. */ readonly origin: string; - /** - * Returns the Location object's URL's path. - * Can be set, to navigate to the same URL with a changed path. - */ + /** Returns the Location object's URL's path. + * + * Can be set, to navigate to the same URL with a changed path. */ pathname: string; - /** - * Returns the Location object's URL's port. - * Can be set, to navigate to the same URL with a changed port. - */ + /** Returns the Location object's URL's port. + * + * Can be set, to navigate to the same URL with a changed port. */ port: string; - /** - * Returns the Location object's URL's scheme. - * Can be set, to navigate to the same URL with a changed scheme. - */ + /** Returns the Location object's URL's scheme. + * + * Can be set, to navigate to the same URL with a changed scheme. */ protocol: string; - /** - * Returns the Location object's URL's query (includes leading "?" if - * non-empty). Can be set, to navigate to the same URL with a changed query - * (ignores leading "?"). - */ + /** Returns the Location object's URL's query (includes leading "?" if + * non-empty). + * + * Can be set, to navigate to the same URL with a changed query (ignores + * leading "?"). */ search: string; /** * Navigates to the given URL. @@ -859,21 +923,14 @@ declare namespace __domTypes { * Reloads the current page. */ reload(): void; - /** @deprecated */ - reload(forcedReload: boolean): void; - /** - * Removes the current page from the session history and navigates to the - * given URL. - */ + /** Removes the current page from the session history and navigates to the + * given URL. */ replace(url: string): void; } } declare namespace __blob { - export const bytesSymbol: unique symbol; - export const blobBytesWeakMap: WeakMap<__domTypes.Blob, Uint8Array>; export class DenoBlob implements __domTypes.Blob { - private readonly [bytesSymbol]; readonly size: number; readonly type: string; /** A blob object represents a file-like object of immutable, raw data. */ @@ -886,7 +943,7 @@ declare namespace __blob { } declare namespace __console { - type ConsoleOptions = Partial<{ + type InspectOptions = Partial<{ showHidden: boolean; depth: number; colors: boolean; @@ -898,7 +955,6 @@ declare namespace __console { } const isConsoleInstance: unique symbol; export class Console { - private printFunc; indentLevel: number; [isConsoleInstance]: boolean; /** Writes the arguments to stdout */ @@ -969,7 +1025,7 @@ declare namespace __console { * `inspect()` converts input into string that has the same format * as printed by `console.log(...)`; */ - export function inspect(value: unknown, options?: ConsoleOptions): string; + export function inspect(value: unknown, options?: InspectOptions): string; } declare namespace __event { @@ -981,7 +1037,7 @@ declare namespace __event { constructor({ bubbles, cancelable, - composed + composed, }?: { bubbles?: boolean | undefined; cancelable?: boolean | undefined; @@ -1052,7 +1108,7 @@ declare namespace __customEvent { bubbles, cancelable, composed, - detail + detail, }: __domTypes.CustomEventInit); } export class CustomEvent extends __event.Event @@ -1082,7 +1138,7 @@ declare namespace __eventTarget { constructor({ capture, passive, - once + once, }?: { capture?: boolean | undefined; passive?: boolean | undefined; @@ -1122,7 +1178,7 @@ declare namespace __io { export enum SeekMode { SEEK_START = 0, SEEK_CURRENT = 1, - SEEK_END = 2 + SEEK_END = 2, } export interface Reader { /** Reads up to p.byteLength bytes into `p`. It resolves to the number @@ -1212,16 +1268,15 @@ declare namespace __io { declare namespace __fetch { class Body - implements __domTypes.Body, __domTypes.ReadableStream, __io.ReadCloser { - private rid; + implements + __domTypes.Body, + __domTypes.ReadableStream, + __io.ReadCloser { readonly contentType: string; bodyUsed: boolean; - private _bodyPromise; - private _data; readonly locked: boolean; - readonly body: null | Body; + readonly body: __domTypes.ReadableStream; constructor(rid: number, contentType: string); - private _bodyBuffer; arrayBuffer(): Promise; blob(): Promise<__domTypes.Blob>; formData(): Promise<__domTypes.FormData>; @@ -1230,7 +1285,9 @@ declare namespace __fetch { read(p: Uint8Array): Promise; close(): void; cancel(): Promise; - getReader(): __domTypes.ReadableStreamReader; + getReader(options: { mode: "byob" }): __domTypes.ReadableStreamBYOBReader; + getReader(): __domTypes.ReadableStreamDefaultReader; + getReader(): __domTypes.ReadableStreamBYOBReader; tee(): [__domTypes.ReadableStream, __domTypes.ReadableStream]; [Symbol.asyncIterator](): AsyncIterableIterator; } @@ -1282,7 +1339,6 @@ declare namespace __textEncoding { ignoreBOM?: boolean; } export class TextDecoder { - private _encoding; /** Returns encoding's name, lowercased. */ readonly encoding: string; /** Returns `true` if error mode is "fatal", and `false` otherwise. */ @@ -1327,14 +1383,12 @@ declare namespace __timers { ): number; export function clearTimeout(id?: number): void; export function clearInterval(id?: number): void; + export function queueMicrotask(func: Function): void; } declare namespace __urlSearchParams { export class URLSearchParams { - private params; - private url; constructor(init?: string | string[][] | Record); - private updateSteps; /** Appends a specified key/value pair as a new search parameter. * * searchParams.append('name', 'first'); @@ -1429,8 +1483,6 @@ declare namespace __urlSearchParams { * searchParams.toString(); */ toString(): string; - private _handleStringInitialization; - private _handleArrayInitialization; } } @@ -1473,16 +1525,12 @@ declare namespace __workers { name?: string; } export class WorkerImpl implements Worker { - private readonly id; - private isClosing; - private readonly isClosedPromise; onerror?: (e: Event) => void; onmessage?: (data: any) => void; onmessageerror?: () => void; constructor(specifier: string, options?: WorkerOptions); postMessage(data: any): void; terminate(): void; - private run; } } diff --git a/cli/js/lib.deno.window.d.ts b/cli/js/lib.deno.window.d.ts index 737971d..e4ab6b7 100644 --- a/cli/js/lib.deno.window.d.ts +++ b/cli/js/lib.deno.window.d.ts @@ -13,6 +13,8 @@ declare interface Window extends WindowOrWorkerGlobalScope { onload: Function | undefined; onunload: Function | undefined; crypto: Crypto; + close: () => void; + closed: boolean; Deno: typeof Deno; }