diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c759b1e6ee2b3c..b6a224d458627a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1171,6 +1171,7 @@ /types/critters-webpack-plugin/ @JuanJoseGonGi @peterblazejewicz /types/crocks/ @jakubbarczyk /types/cronitor/ @alexpresthus +/types/cronofy-elements/ @agarciabz /types/croppie/ @connor4312 @dklmuc @sarunint @knuthelgesen /types/cross-domain-utils/ @ANovokmet /types/cross-spawn/ @Alorel @ExE-Boss @@ -2974,7 +2975,7 @@ /types/gtag.js/ @rokt33r @KsAkira10 /types/gtmetrix/ @peterblazejewicz /types/guacamole-client/ @KonstantinSimeonov @vakrilov @PetarMetodiev -/types/guacamole-common-js/ @KonstantinSimeonov @vakrilov @PetarMetodiev @Talent30 @linn-gith +/types/guacamole-common-js/ @KonstantinSimeonov @vakrilov @PetarMetodiev @linn-gith /types/guid/ @maroy1986 /types/gulp/ @GiedriusGrabauskas @pulsovi /types/gulp-angular-protractor/ @akwiatek @@ -4853,6 +4854,7 @@ /types/microsoftteams/ @WrathOfZombies @ydogandjiev @orty /types/microtime/ @vincekovacs /types/midi/ @mattsoulanille +/types/midtrans-client/ @MystiaFin /types/migrate-mongo/ @amitbeck /types/millisecond/ @xeoneux /types/mime-db/ @AJamesPhillips @LinusU @peterblazejewicz @bjohansebas @@ -5078,7 +5080,6 @@ /types/netease-captcha/ @norubidium /types/netgear/ @k-yle /types/netlify-auth-providers/ @drazisil -/types/netlify-identity-widget/ @nkprince007 /types/netmask/ @mhfrantz @JanST123 @yoursunny /types/network-interfaces/ @anderswestberg /types/neverbounce/ @georgenov @@ -5324,6 +5325,7 @@ /types/nuclear-js/ @patlillis /types/nuclear-js-react-addons-chefsplate/ @patlillis /types/num2fraction/ @sergey12313 +/types/number-abbreviate/ @altie122 /types/number-is-nan/ @mhegazy @peterblazejewicz /types/number-to-words/ @frederickfogerty /types/numeral/ @vbortone @klujanrosas @KarlosQ @peterblazejewicz @@ -7929,6 +7931,7 @@ /types/try-catch/ @coderaiser /types/try-to-catch/ @coderaiser /types/tryer/ @bengry +/types/tryghost__admin-api/ @josejj10 /types/tryghost__content-api/ @knguyen0125 @antonve @maveric1977 /types/ts-nameof/ @dsherret /types/tspromise/ @soywiz @@ -8108,7 +8111,7 @@ /types/uswds__uswds/ @lunchbreakdev @aduth /types/utf-8-validate/ @OpportunityLiu /types/utf8/ @peterblazejewicz -/types/utif/ @smajl @nkprince007 @massic80 +/types/utif/ @smajl @massic80 /types/util-deprecate/ @BendingBender /types/util.promisify/ @adamvoss @dex4er @ExE-Boss @ljharb /types/utils-merge/ @chrootsu @@ -8245,7 +8248,6 @@ /types/vue-tel-input/ @suryadana /types/vue-template-es2015-compiler/ @iam-medvedev /types/vue-the-mask/ @domschmidt -/types/vue-writer/ @BekYahia /types/vue2-datepicker/ @ChristianStornowski /types/vue2-editor/ @suryadana /types/vue2-hammer/ @ptandler diff --git a/types/node/v22/buffer.d.ts b/types/node/v22/buffer.d.ts index 2a561c06b229c6..e5092b4ea6fcd5 100644 --- a/types/node/v22/buffer.d.ts +++ b/types/node/v22/buffer.d.ts @@ -139,7 +139,7 @@ declare module "buffer" { type?: string | undefined; } /** - * A [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) encapsulates immutable, raw data that can be safely shared across + * A `Blob` encapsulates immutable, raw data that can be safely shared across * multiple worker threads. * @since v15.7.0, v14.18.0 */ diff --git a/types/node/v22/child_process.d.ts b/types/node/v22/child_process.d.ts index 644f4288a68257..51a30045cf9e76 100644 --- a/types/node/v22/child_process.d.ts +++ b/types/node/v22/child_process.d.ts @@ -24,7 +24,7 @@ * the parent Node.js process and the spawned subprocess. These pipes have * limited (and platform-specific) capacity. If the subprocess writes to * stdout in excess of that limit without the output being captured, the - * subprocess blocks waiting for the pipe buffer to accept more data. This is + * subprocess blocks, waiting for the pipe buffer to accept more data. This is * identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }` option if the output will not be consumed. * * The command lookup is performed using the `options.env.PATH` environment diff --git a/types/node/v22/fs.d.ts b/types/node/v22/fs.d.ts index ca3b0502ca34a2..c6d8817ac630d7 100644 --- a/types/node/v22/fs.d.ts +++ b/types/node/v22/fs.d.ts @@ -329,14 +329,15 @@ declare module "fs" { */ readSync(): Dirent | null; /** - * Calls `dir.close()` and returns a promise that fulfills when the - * dir is closed. + * Calls `dir.close()` if the directory handle is open, and returns a promise that + * fulfills when disposal is complete. * @since v22.17.0 * @experimental */ [Symbol.asyncDispose](): Promise; /** - * Calls `dir.closeSync()` and returns `undefined`. + * Calls `dir.closeSync()` if the directory handle is open, and returns + * `undefined`. * @since v22.17.0 * @experimental */ @@ -3340,6 +3341,12 @@ declare module "fs" { persistent?: boolean | undefined; recursive?: boolean | undefined; } + export interface WatchOptionsWithBufferEncoding extends WatchOptions { + encoding: "buffer"; + } + export interface WatchOptionsWithStringEncoding extends WatchOptions { + encoding?: BufferEncoding | undefined; + } export type WatchEventType = "rename" | "change"; export type WatchListener = (event: WatchEventType, filename: T | null) => void; export type StatsListener = (curr: Stats, prev: Stats) => void; @@ -3366,44 +3373,20 @@ declare module "fs" { */ export function watch( filename: PathLike, - options: - | (WatchOptions & { - encoding: "buffer"; - }) - | "buffer", - listener?: WatchListener, + options?: WatchOptionsWithStringEncoding | BufferEncoding | null, + listener?: WatchListener, ): FSWatcher; - /** - * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. - * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. - * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. - * If `encoding` is not supplied, the default of `'utf8'` is used. - * If `persistent` is not supplied, the default of `true` is used. - * If `recursive` is not supplied, the default of `false` is used. - */ export function watch( filename: PathLike, - options?: WatchOptions | BufferEncoding | null, - listener?: WatchListener, + options: WatchOptionsWithBufferEncoding | "buffer", + listener: WatchListener, ): FSWatcher; - /** - * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. - * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. - * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. - * If `encoding` is not supplied, the default of `'utf8'` is used. - * If `persistent` is not supplied, the default of `true` is used. - * If `recursive` is not supplied, the default of `false` is used. - */ export function watch( filename: PathLike, - options: WatchOptions | string, - listener?: WatchListener, + options: WatchOptions | BufferEncoding | "buffer" | null, + listener: WatchListener, ): FSWatcher; - /** - * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. - * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. - */ - export function watch(filename: PathLike, listener?: WatchListener): FSWatcher; + export function watch(filename: PathLike, listener: WatchListener): FSWatcher; /** * Test whether or not the given path exists by checking with the file system. * Then call the `callback` argument with either true or false: diff --git a/types/node/v22/fs/promises.d.ts b/types/node/v22/fs/promises.d.ts index b8186e93eb16b1..9538c8cc1cb591 100644 --- a/types/node/v22/fs/promises.d.ts +++ b/types/node/v22/fs/promises.d.ts @@ -40,7 +40,7 @@ declare module "fs/promises" { StatsFs, TimeLike, WatchEventType, - WatchOptions, + WatchOptions as _WatchOptions, WriteStream, WriteVResult, } from "node:fs"; @@ -1182,6 +1182,16 @@ declare module "fs/promises" { * @return Fulfills with an {fs.Dir}. */ function opendir(path: PathLike, options?: OpenDirOptions): Promise; + interface WatchOptions extends _WatchOptions { + maxQueue?: number | undefined; + overflow?: "ignore" | "throw" | undefined; + } + interface WatchOptionsWithBufferEncoding extends WatchOptions { + encoding: "buffer"; + } + interface WatchOptionsWithStringEncoding extends WatchOptions { + encoding?: BufferEncoding | undefined; + } /** * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory. * @@ -1214,33 +1224,16 @@ declare module "fs/promises" { */ function watch( filename: PathLike, - options: - | (WatchOptions & { - encoding: "buffer"; - }) - | "buffer", - ): AsyncIterable>; - /** - * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. - * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. - * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. - * If `encoding` is not supplied, the default of `'utf8'` is used. - * If `persistent` is not supplied, the default of `true` is used. - * If `recursive` is not supplied, the default of `false` is used. - */ - function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable>; - /** - * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. - * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. - * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. - * If `encoding` is not supplied, the default of `'utf8'` is used. - * If `persistent` is not supplied, the default of `true` is used. - * If `recursive` is not supplied, the default of `false` is used. - */ + options?: WatchOptionsWithStringEncoding | BufferEncoding, + ): NodeJS.AsyncIterator>; + function watch( + filename: PathLike, + options: WatchOptionsWithBufferEncoding | "buffer", + ): NodeJS.AsyncIterator>; function watch( filename: PathLike, - options: WatchOptions | string, - ): AsyncIterable> | AsyncIterable>; + options: WatchOptions | BufferEncoding | "buffer", + ): NodeJS.AsyncIterator>; /** * Asynchronously copies the entire directory structure from `src` to `dest`, * including subdirectories and files. diff --git a/types/node/v22/http.d.ts b/types/node/v22/http.d.ts index 96e0442d2740bf..946d90159d352f 100644 --- a/types/node/v22/http.d.ts +++ b/types/node/v22/http.d.ts @@ -2028,7 +2028,7 @@ declare module "http" { */ const maxHeaderSize: number; /** - * A browser-compatible implementation of [WebSocket](https://nodejs.org/docs/latest/api/http.html#websocket). + * A browser-compatible implementation of `WebSocket`. * @since v22.5.0 */ const WebSocket: import("undici-types").WebSocket; diff --git a/types/node/v22/inspector.d.ts b/types/node/v22/inspector.d.ts index ebcdb7a10e1b7e..7fcd3c03972c8a 100644 --- a/types/node/v22/inspector.d.ts +++ b/types/node/v22/inspector.d.ts @@ -268,7 +268,7 @@ declare module 'inspector' { /** * Embedder-specific auxiliary data. */ - auxData?: {} | undefined; + auxData?: object | undefined; } /** * Detailed information about exception (or error) that was thrown during script compilation or execution. @@ -701,7 +701,7 @@ declare module 'inspector' { } interface InspectRequestedEventDataType { object: RemoteObject; - hints: {}; + hints: object; } } namespace Debugger { @@ -1173,7 +1173,7 @@ declare module 'inspector' { /** * Embedder-specific auxiliary data. */ - executionContextAuxData?: {} | undefined; + executionContextAuxData?: object | undefined; /** * True, if this script is generated as a result of the live edit operation. * @experimental @@ -1237,7 +1237,7 @@ declare module 'inspector' { /** * Embedder-specific auxiliary data. */ - executionContextAuxData?: {} | undefined; + executionContextAuxData?: object | undefined; /** * URL of source map associated with script (if any). */ @@ -1282,7 +1282,7 @@ declare module 'inspector' { /** * Object containing break-specific auxiliary properties. */ - data?: {} | undefined; + data?: object | undefined; /** * Hit breakpoints IDs */ @@ -1649,7 +1649,7 @@ declare module 'inspector' { categories: string[]; } interface DataCollectedEventDataType { - value: Array<{}>; + value: object[]; } } namespace NodeWorker { @@ -1759,6 +1759,7 @@ declare module 'inspector' { url: string; method: string; headers: Headers; + hasPostData: boolean; } /** * HTTP response data. @@ -1776,17 +1777,45 @@ declare module 'inspector' { */ interface Headers { } + interface GetRequestPostDataParameterType { + /** + * Identifier of the network request to get content for. + */ + requestId: RequestId; + } + interface GetResponseBodyParameterType { + /** + * Identifier of the network request to get content for. + */ + requestId: RequestId; + } interface StreamResourceContentParameterType { /** * Identifier of the request to stream. */ requestId: RequestId; } + interface GetRequestPostDataReturnType { + /** + * Request body string, omitting files from multipart requests + */ + postData: string; + } + interface GetResponseBodyReturnType { + /** + * Response body. + */ + body: string; + /** + * True, if content was sent as base64. + */ + base64Encoded: boolean; + } interface StreamResourceContentReturnType { /** * Data that has been buffered until streaming is enabled. */ - bufferedData: never; + bufferedData: string; } interface RequestWillBeSentEventDataType { /** @@ -1877,7 +1906,7 @@ declare module 'inspector' { * Data that was received. * @experimental */ - data?: never | undefined; + data?: string | undefined; } } namespace NodeRuntime { @@ -2285,6 +2314,16 @@ declare module 'inspector' { * Enables network tracking, network events will now be delivered to the client. */ post(method: 'Network.enable', callback?: (err: Error | null) => void): void; + /** + * Returns post data sent with the request. Returns an error when no data was sent with the request. + */ + post(method: 'Network.getRequestPostData', params?: Network.GetRequestPostDataParameterType, callback?: (err: Error | null, params: Network.GetRequestPostDataReturnType) => void): void; + post(method: 'Network.getRequestPostData', callback?: (err: Error | null, params: Network.GetRequestPostDataReturnType) => void): void; + /** + * Returns content served for the given request. + */ + post(method: 'Network.getResponseBody', params?: Network.GetResponseBodyParameterType, callback?: (err: Error | null, params: Network.GetResponseBodyReturnType) => void): void; + post(method: 'Network.getResponseBody', callback?: (err: Error | null, params: Network.GetResponseBodyReturnType) => void): void; /** * Enables streaming of the response for the given requestId. * If enabled, the dataReceived event contains the data that was received during streaming. @@ -3049,22 +3088,31 @@ declare module 'inspector' { // DevTools protocol event broadcast methods namespace Network { + /** + * This feature is only available with the `--experimental-network-inspection` flag enabled. + * + * Broadcasts the `Network.requestWillBeSent` event to connected frontends. This event indicates that + * the application is about to send an HTTP request. + * @since v22.6.0 + */ + function requestWillBeSent(params: RequestWillBeSentEventDataType): void; /** * This feature is only available with the `--experimental-network-inspection` flag enabled. * * Broadcasts the `Network.dataReceived` event to connected frontends, or buffers the data if * `Network.streamResourceContent` command was not invoked for the given request yet. + * + * Also enables `Network.getResponseBody` command to retrieve the response data. * @since v22.17.0 */ function dataReceived(params: DataReceivedEventDataType): void; /** * This feature is only available with the `--experimental-network-inspection` flag enabled. * - * Broadcasts the `Network.requestWillBeSent` event to connected frontends. This event indicates that - * the application is about to send an HTTP request. - * @since v22.6.0 + * Enables `Network.getRequestPostData` command to retrieve the request data. + * @since v22.18.0 */ - function requestWillBeSent(params: RequestWillBeSentEventDataType): void; + function dataSent(params: unknown): void; /** * This feature is only available with the `--experimental-network-inspection` flag enabled. * @@ -3450,6 +3498,14 @@ declare module 'inspector/promises' { * Enables network tracking, network events will now be delivered to the client. */ post(method: 'Network.enable'): Promise; + /** + * Returns post data sent with the request. Returns an error when no data was sent with the request. + */ + post(method: 'Network.getRequestPostData', params?: Network.GetRequestPostDataParameterType): Promise; + /** + * Returns content served for the given request. + */ + post(method: 'Network.getResponseBody', params?: Network.GetResponseBodyParameterType): Promise; /** * Enables streaming of the response for the given requestId. * If enabled, the dataReceived event contains the data that was received during streaming. diff --git a/types/node/v22/module.d.ts b/types/node/v22/module.d.ts index ebd3abe5f66782..b48948e8a56573 100644 --- a/types/node/v22/module.d.ts +++ b/types/node/v22/module.d.ts @@ -684,6 +684,30 @@ declare module "module" { * @returns The absolute URL string that the specifier would resolve to. */ resolve(specifier: string, parent?: string | URL): string; + /** + * `true` when the current module is the entry point of the current process; `false` otherwise. + * + * Equivalent to `require.main === module` in CommonJS. + * + * Analogous to Python's `__name__ == "__main__"`. + * + * ```js + * export function foo() { + * return 'Hello, world'; + * } + * + * function main() { + * const message = foo(); + * console.log(message); + * } + * + * if (import.meta.main) main(); + * // `foo` can be imported from another module without possible side-effects from `main` + * ``` + * @since v22.18.0 + * @experimental + */ + main: boolean; } namespace NodeJS { interface Module { diff --git a/types/node/v22/package.json b/types/node/v22/package.json index 9578139decdfe2..550bb37809d259 100644 --- a/types/node/v22/package.json +++ b/types/node/v22/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/node", - "version": "22.17.9999", + "version": "22.18.9999", "nonNpm": "conflict", "nonNpmDescription": "Node.js", "projects": [ diff --git a/types/node/v22/process.d.ts b/types/node/v22/process.d.ts index 0a9f3a6575564c..7c70f9a51dfde8 100644 --- a/types/node/v22/process.d.ts +++ b/types/node/v22/process.d.ts @@ -231,8 +231,9 @@ declare module "process" { */ readonly tls_sni: boolean; /** - * A value that is `"strip"` if Node.js is run with `--experimental-strip-types`, - * `"transform"` if Node.js is run with `--experimental-transform-types`, and `false` otherwise. + * A value that is `"strip"` by default, + * `"transform"` if Node.js is run with `--experimental-transform-types`, and `false` if + * Node.js is run with `--no-experimental-strip-types`. * @since v22.10.0 */ readonly typescript: "strip" | "transform" | false; diff --git a/types/node/v22/sqlite.d.ts b/types/node/v22/sqlite.d.ts index 4e76b7a6e974ae..a1dcfec53fe1d4 100644 --- a/types/node/v22/sqlite.d.ts +++ b/types/node/v22/sqlite.d.ts @@ -89,6 +89,41 @@ declare module "node:sqlite" { * @default false */ allowExtension?: boolean | undefined; + /** + * The [busy timeout](https://sqlite.org/c3ref/busy_timeout.html) in milliseconds. This is the maximum amount of + * time that SQLite will wait for a database lock to be released before + * returning an error. + * @since v22.16.0 + * @default 0 + */ + timeout?: number | undefined; + /** + * If `true`, integer fields are read as JavaScript `BigInt` values. If `false`, + * integer fields are read as JavaScript numbers. + * @since v22.18.0 + * @default false + */ + readBigInts?: boolean | undefined; + /** + * If `true`, query results are returned as arrays instead of objects. + * @since v22.18.0 + * @default false + */ + returnArrays?: boolean | undefined; + /** + * If `true`, allows binding named parameters without the prefix + * character (e.g., `foo` instead of `:foo`). + * @since v22.18.0 + * @default true + */ + allowBareNamedParameters?: boolean | undefined; + /** + * If `true`, unknown named parameters are ignored when binding. + * If `false`, an exception is thrown for unknown named parameters. + * @since v22.18.0 + * @default false + */ + allowUnknownNamedParameters?: boolean | undefined; } interface CreateSessionOptions { /** diff --git a/types/node/v22/test/fs.ts b/types/node/v22/test/fs.ts index 51073b57a4aea3..9170fa123b692c 100644 --- a/types/node/v22/test/fs.ts +++ b/types/node/v22/test/fs.ts @@ -919,11 +919,14 @@ const bigIntStatFs: bigint = bigStatFs.bfree; const anyStatFs: fs.StatsFs | fs.BigIntStatsFs = fs.statfsSync(".", { bigint: Math.random() > 0.5 }); { - watchAsync("y33t"); // $ExpectType AsyncIterable> - watchAsync("y33t", "buffer"); // $ExpectType AsyncIterable> || AsyncIterable>> - watchAsync("y33t", { encoding: "buffer", signal: new AbortSignal() }); // $ExpectType AsyncIterable> || AsyncIterable>> - - watchAsync("test", { persistent: true, recursive: true, encoding: "utf-8" }); // $ExpectType AsyncIterable> + // $ExpectType AsyncIterator, any, any> + watchAsync("y33t"); + // $ExpectType AsyncIterator, any, any> || AsyncIterator>, any, any> + watchAsync("y33t", "buffer"); + // $ExpectType AsyncIterator, any, any> || AsyncIterator>, any, any> + watchAsync("y33t", { encoding: "buffer", signal: new AbortSignal() }); + // $ExpectType AsyncIterator, any, any> + watchAsync("test", { persistent: true, recursive: true, encoding: "utf-8", maxQueue: 2048, overflow: "ignore" }); } { diff --git a/types/node/v22/test/module.ts b/types/node/v22/test/module.ts index 6039404d2aa777..66a48bc2fec330 100644 --- a/types/node/v22/test/module.ts +++ b/types/node/v22/test/module.ts @@ -115,6 +115,7 @@ Module.Module === Module; importmeta.resolve("local", "/parent"); // $ExpectType string importmeta.resolve("local", undefined); // $ExpectType string importmeta.resolve("local", new URL("https://parent.module")); // $ExpectType string + importmeta.main; // $ExpectType boolean } // Globals diff --git a/types/node/v22/test/sqlite.ts b/types/node/v22/test/sqlite.ts index 2db8596e8e1f2b..c830905111fbba 100644 --- a/types/node/v22/test/sqlite.ts +++ b/types/node/v22/test/sqlite.ts @@ -68,6 +68,16 @@ import { TextEncoder } from "node:util"; new DatabaseSync(new URL("file:///var/lib/sqlite3/db")); } +{ + new DatabaseSync(":memory:", { + timeout: 10_000, + readBigInts: true, + returnArrays: true, + allowBareNamedParameters: false, + allowUnknownNamedParameters: true, + }); +} + { const database = new DatabaseSync(":memory:", { allowExtension: true }); database.loadExtension("/path/to/extension.so"); diff --git a/types/node/v22/test/url.ts b/types/node/v22/test/url.ts index c27a09730517ce..383edf63945b55 100644 --- a/types/node/v22/test/url.ts +++ b/types/node/v22/test/url.ts @@ -192,6 +192,12 @@ import * as url from "node:url"; path = url.fileURLToPath(new url.URL("file://test")); path = url.fileURLToPath(new url.URL("file://test"), { windows: false }); path = url.fileURLToPath(new url.URL("file://test"), { windows: true }); + + let buffer: Buffer; + buffer = url.fileURLToPathBuffer("file://test"); + buffer = url.fileURLToPathBuffer("file://test", { windows: true }); + buffer = url.fileURLToPathBuffer(new url.URL("file://test")); + buffer = url.fileURLToPathBuffer(new url.URL("file://test"), { windows: true }); } { diff --git a/types/node/v22/url.d.ts b/types/node/v22/url.d.ts index b1f84d98a979b2..33a6addf8bc356 100644 --- a/types/node/v22/url.d.ts +++ b/types/node/v22/url.d.ts @@ -315,6 +315,17 @@ declare module "url" { * @return The fully-resolved platform-specific Node.js file path. */ function fileURLToPath(url: string | URL, options?: FileUrlToPathOptions): string; + /** + * Like `url.fileURLToPath(...)` except that instead of returning a string + * representation of the path, a `Buffer` is returned. This conversion is + * helpful when the input URL contains percent-encoded segments that are + * not valid UTF-8 / Unicode sequences. + * @since v22.18.0 + * @param url The file URL string or URL object to convert to a path. + * @returns The fully-resolved platform-specific Node.js file path + * as a `Buffer`. + */ + function fileURLToPathBuffer(url: string | URL, options?: FileUrlToPathOptions): Buffer; /** * This function ensures that `path` is resolved absolutely, and that the URL * control characters are correctly encoded when converting into a File URL. diff --git a/types/node/v22/worker_threads.d.ts b/types/node/v22/worker_threads.d.ts index 979c234db5a797..9cb2923ee6c446 100644 --- a/types/node/v22/worker_threads.d.ts +++ b/types/node/v22/worker_threads.d.ts @@ -481,6 +481,18 @@ declare module "worker_threads" { * @since v22.16.0 */ getHeapStatistics(): Promise; + /** + * Calls `worker.terminate()` when the dispose scope is exited. + * + * ```js + * async function example() { + * await using worker = new Worker('for (;;) {}', { eval: true }); + * // Worker is automatically terminate when the scope is exited. + * } + * ``` + * @since v22.18.0 + */ + [Symbol.asyncDispose](): Promise; addListener(event: "error", listener: (err: Error) => void): this; addListener(event: "exit", listener: (exitCode: number) => void): this; addListener(event: "message", listener: (value: any) => void): this; diff --git a/types/sdp-transform/index.d.ts b/types/sdp-transform/index.d.ts index 39ae868642036d..906cb27c984f3a 100644 --- a/types/sdp-transform/index.d.ts +++ b/types/sdp-transform/index.d.ts @@ -1,112 +1,43 @@ // https://tools.ietf.org/html/rfc4566 // https://www.iana.org/assignments/sdp-parameters/sdp-parameters.xhtml -export function write(description: SessionDescription): string; -export function parse(description: string): SessionDescription; -export function parsePayloads(payloads: string): number[]; -export function parseRemoteCandidates(candidates: string): Array<{ - component: number; - ip: string; - port: number; -}>; -export function parseSimulcastStreamList(streams: string): Array< - Array<{ - scid: number | string; - paused: boolean; - }> ->; -export interface ParamMap { - [paramName: string]: number | string; -} -export function parseParams(params: string): ParamMap; -export function parseImageAttributes(params: string): ParamMap[]; - -export interface MediaDescription extends SharedDescriptionFields, MediaAttributes {} - /** - * Descriptor fields that exist only at the session level (before an m= block). + * Descriptor fields that exist only at the session level (before an m= + * block). * - * See the SDP grammar for more details: https://tools.ietf.org/html/rfc4566#section-9 + * @see https://tools.ietf.org/html/rfc4566#section-9 */ export interface SessionDescription extends SharedDescriptionFields, SessionAttributes { - version?: number | undefined; + // v= + version: number; // o= - origin?: { + origin: { username: string; sessionId: string | number; sessionVersion: number; netType: string; ipVer: number; address: string; - } | undefined; + }; // s= - name?: string | undefined; - // u= - uri?: string | undefined; - // e= - email?: string | undefined; - // p= - phone?: string | undefined; + name: string; // t=0 0 - timing?: { + timing: { start: number; stop: number; - } | undefined; + }; + // u= + uri?: string; + // e= + email?: string; + // p= + phone?: string; // z= - timezones?: string | undefined; + timezones?: string; // r= - repeats?: string | undefined; + repeats?: string; // m= - media: Array< - { - type: string; - port: number; - protocol: string; - payloads?: string | undefined; - } & MediaDescription - >; -} - -/** - * These attributes can exist on both the session level and the media level. - * - * https://www.iana.org/assignments/sdp-parameters/sdp-parameters.xhtml#sdp-parameters-8 - */ -export interface SharedAttributes { - // a=sendrecv - // a=recvonly - // a=sendonly - // a=inactive - direction?: "sendrecv" | "recvonly" | "sendonly" | "inactive" | undefined; - // a=control - control?: string | undefined; - // a=extmap - ext?: - | Array<{ - value: number; - direction?: string | undefined; - uri: string; - config?: string | undefined; - }> - | undefined; - // a=setup - setup?: string | undefined; - - iceUfrag?: string | undefined; - icePwd?: string | undefined; - fingerprint?: { - type: string; - hash: string; - } | undefined; - // a=source-filter: incl IN IP4 239.5.2.31 10.1.15.5 - sourceFilter?: { - filterMode: "excl" | "incl"; - netType: string; - addressTypes: string; - destAddress: string; - srcList: string; - } | undefined; - invalid?: Array<{ value: string }> | undefined; + media: MediaDescription[]; } /** @@ -115,21 +46,28 @@ export interface SharedAttributes { * https://www.iana.org/assignments/sdp-parameters/sdp-parameters.xhtml#sdp-parameters-7 */ export interface SessionAttributes extends SharedAttributes { - icelite?: string | undefined; - // a=ice-options:google-ice - iceOptions?: string | undefined; + // a=ice-lite + icelite?: "ice-lite"; // a=msid-semantic: WMS Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV msidSemantic?: { semantic: string; token: string; - } | undefined; + }; // a=group:BUNDLE audio video - groups?: - | Array<{ - type: string; - mids: string; - }> - | undefined; + groups?: { + type: string; + mids: string; + }[]; +} + +/** + * Descriptor fields that exist only at the media level (in each m= block). + */ +export interface MediaDescription extends SharedDescriptionFields, MediaAttributes { + type: string; + port: number; + protocol: string; + payloads?: string; } /** @@ -138,150 +76,253 @@ export interface SessionAttributes extends SharedAttributes { * https://www.iana.org/assignments/sdp-parameters/sdp-parameters.xhtml#sdp-parameters-9 */ export interface MediaAttributes extends SharedAttributes { - rtp: Array<{ + rtp: { payload: number; codec: string; - rate?: number | undefined; - encoding?: number | undefined; - }>; + rate?: number; + encoding?: number; + }[]; + // a=fmtp:108 profile-level-id=24;object=23;bitrate=64000 + // a=fmtp:111 minptime=10; useinbandfec=1 + fmtp: { + payload: number; + config: string; + }[]; rtcp?: { port: number; - netType?: string | undefined; - ipVer?: number | undefined; - address?: string | undefined; - } | undefined; + netType?: string; + ipVer?: number; + address?: string; + }; // a=rtcp-fb:98 nack rpsi - rtcpFb?: - | Array<{ - payload: number; - type: string; - subtype?: string | undefined; - }> - | undefined; + // a=rtcp-fb:* pli + rtcpFb?: { + payload: number | string; + type: string; + subtype?: string; + }[]; // a=rtcp-fb:98 trr-int 100 - rtcpFbTrrInt?: - | Array<{ - payload: number; - value: number; - }> - | undefined; - // a=fmtp - fmtp: Array<{ - payload: number; + rtcpFbTrrInt?: { + payload: number | string; + value: number; + }[]; + // a=mid:1 + // a=mid:foo + mid?: string; + // a=msid:0c8b064d-d807-43b4-b434-f92a889d8587 98178685-d409-46e0-8e16-7ef0db0db64a + msid?: string; + // a=ptime:20 + ptime?: number; + // a=maxptime:60 + maxptime?: number; + // a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR|2^20|1:32 + crypto?: { + id: number; + suite: string; config: string; - }>; - // a=mid - mid?: string | undefined; - // a=msid - msid?: string | undefined; - ptime?: number | undefined; - // a=maxptime - maxptime?: number | undefined; - // a=crypto - crypto?: - | Array<{ - id: number; - suite: string; - config: string; - sessionConfig?: string | undefined; - }> - | undefined; - // a=candidate - candidates?: - | Array<{ - foundation: string; - component: number; - transport: string; - priority: number | string; - ip: string; - port: number; - type: string; - raddr?: string | undefined; - rport?: number | undefined; - tcptype?: string | undefined; - generation?: number | undefined; - "network-id"?: number | undefined; - "network-cost"?: number | undefined; - }> - | undefined; + sessionConfig?: string; + }[]; + // a=bundle-only + bundleOnly?: "bundle-only"; + // a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host + // a=candidate:1162875081 1 udp 2113937151 192.168.34.75 60017 typ host generation 0 network-id 3 network-cost 10 + // a=candidate:3289912957 2 udp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 generation 0 network-id 3 network-cost 10 + // a=candidate:229815620 1 tcp 1518280447 192.168.150.19 60017 typ host tcptype active generation 0 network-id 3 network-cost 10 + // a=candidate:3289912957 2 tcp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 tcptype passive generation 0 network-id 3 network-cost 10 + candidates?: { + foundation: string; + component: number; + transport: string; + priority: number; + ip: string; + port: number; + type: string; + raddr?: string; + rport?: number; + tcptype?: string; + generation?: number; + "network-id"?: number; + "network-cost"?: number; + }[]; // a=end-of-candidates - endOfCandidates?: string | undefined; - // a=remote-candidates - remoteCandidates?: string | undefined; - // a=ssrc: - ssrcs?: - | Array<{ - id: number | string; - attribute: string; - value?: string | undefined; - }> - | undefined; - // a=ssrc-group: - ssrcGroups?: - | Array<{ - semantics: string; - ssrcs: string; - }> - | undefined; + endOfCandidates?: "end-of-candidates"; + // a=remote-candidates:1 203.0.113.1 54400 2 203.0.113.1 54401 ... + remoteCandidates?: string; + // a=ssrc:2566107569 cname:t9YU8M1UxTF8Y1A1 + ssrcs?: { + id: number; + attribute: string; + value?: string; + }[]; + // a=ssrc-group:FEC 1 2 + // a=ssrc-group:FEC-FR 3004364195 1080772241 + ssrcGroups?: { + semantics: string; + ssrcs: string; + }[]; // a=rtcp-mux - rtcpMux?: string | undefined; + rtcpMux?: "rtcp-mux"; // a=rtcp-rsize - rtcpRsize?: string | undefined; - // a=sctpmap + rtcpRsize?: "rtcp-rsize"; + // a=sctpmap:5000 webrtc-datachannel 1024 sctpmap?: { - sctpmapNumber: number | string; + sctpmapNumber: number; app: string; - maxMessageSize: number; - } | undefined; - // a=x-google-flag - xGoogleFlag?: string | undefined; - // a=rid - rids?: - | Array<{ - id: number | string; - direction: string; - params?: string | undefined; - }> - | undefined; - // a=imageattr - imageattrs?: - | Array<{ - pt: number | string; - dir1: string; - attrs1: string; - dir2?: string | undefined; - attrs2?: string | undefined; - }> - | undefined; + maxMessageSize?: number; + }; + // a=x-google-flag:conference + xGoogleFlag?: "conference"; + // a=rid:1 send max-width=1280;max-height=720;max-fps=30;depend=0 + rids?: { + id: number | string; + direction: string; + params?: string; + }[]; + // a=imageattr:97 send [x=800,y=640,sar=1.1,q=0.6] [x=480,y=320] recv [x=330,y=250] + // a=imageattr:* send [x=800,y=640] recv * + // a=imageattr:100 recv [x=320,y=240] + imageattrs?: { + pt: number | string; + dir1: "send" | "recv"; + attrs1: string; + dir2?: "send" | "recv"; + attrs2?: string; + }[]; + // a=simulcast:send 1,2,3;~4,~5 recv 6;~7,~8 + // a=simulcast:recv 1;4,5 send 6;7 simulcast?: { - dir1: string; + dir1: "send" | "recv"; list1: string; - dir2?: string | undefined; - list2?: string | undefined; - } | undefined; - simulcast_03?: { value: string } | undefined; - // a=framerate - framerate?: number | string | undefined; + dir2?: "send" | "recv"; + list2?: string; + }; + // Old simulcast draft 03 (implemented by old Firefox). + // @see https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-03 + // a=simulcast: recv pt=97;98 send pt=97 + // a=simulcast: send rid=5;6;7 paused=6,7 + simulcast_03?: { value: string }; + // a=framerate:25 + // a=framerate:29.97 + framerate?: number | string; + // a=label:1 + label?: string; + // a=sctp-port + // @see https://tools.ietf.org/html/draft-ietf-mmusic-sctp-sdp-26#section-5 + sctpPort?: number; + // a=max-message-size + // https://tools.ietf.org/html/draft-ietf-mmusic-sctp-sdp-26#section-6 + maxMessageSize?: number; + bfcpFloorCtrl?: string; + bfcpConfId?: string; + bfcpUserId?: string; + bfcpFloorId?: string; } /** * Descriptor fields that exist at both the session level and media level. * - * See the SDP grammar for more details: https://tools.ietf.org/html/rfc4566#section-9 + * @see https://tools.ietf.org/html/rfc4566#section-9 */ export interface SharedDescriptionFields { // i= - description?: string | undefined; + description?: string; // c=IN IP4 10.47.197.26 connection?: { version: number; ip: string; - } | undefined; + }; // b=AS:4000 - bandwidth?: - | Array<{ - type: "TIAS" | "AS" | "CT" | "RR" | "RS"; - limit: number | string; - }> - | undefined; + bandwidth?: { + type: "TIAS" | "AS" | "CT" | "RR" | "RS"; + limit: number; + }[]; +} + +/** + * These attributes can exist on both the session level and the media level. + * + * https://www.iana.org/assignments/sdp-parameters/sdp-parameters.xhtml#sdp-parameters-8 + */ +export interface SharedAttributes { + // a=sendrecv + // a=recvonly + // a=sendonly + // a=inactive + direction?: "sendrecv" | "recvonly" | "sendonly" | "inactive"; + // a=control:streamid=0 + control?: string; + // a=extmap:2 urn:ietf:params:rtp-hdrext:toffset + // a=extmap:1/recvonly URI-gps-string + // a=extmap:3 urn:ietf:params:rtp-hdrext:encrypt urn:ietf:params:rtp-hdrext:smpte-tc 25@600/24 + ext?: { + value: number; + direction?: string; + "encrypt-uri"?: string; + uri: string; + config?: string; + }[]; + // a=setup:actpass + setup?: string; + // a=connection:new + connectionType?: "new" | "existing"; + // a=ice-ufrag:F7gI + iceUfrag?: string; + // a=ice-pwd:x9cml/YzichV2+XlhiMu8g + icePwd?: string; + // a=fingerprint:SHA-1 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33 + fingerprint?: { + type: string; + hash: string; + }; + // a=source-filter: incl IN IP4 239.5.2.31 10.1.15.5 + sourceFilter?: { + filterMode: "excl" | "incl"; + netType: string; + addressTypes: string; + destAddress: string; + srcList: string; + }; + // a=ts-refclk:ptp=IEEE1588-2008:39-A7-94-FF-FE-07-CB-D0:37 + tsRefClocks?: { + clksrc: string; + clksrcExt?: string; + }; + // a=mediaclk:direct=963214424 + mediaClk?: { + id?: string; + mediaClockName?: string; + mediaClockValue?: string; + rateNumerator?: string; + rateDenominator?: string; + }; + // a=extmap-allow-mixed + extmapAllowMixed?: "extmap-allow-mixed"; + // a=ice-options:renomination + iceOptions?: string; + // Inalid or unsupported attributes. + invalid?: { value: string }[]; +} + +export interface ParamMap { + [paramName: string]: number | string; } + +export function write(description: SessionDescription): string; + +export function parse(description: string): SessionDescription; + +export function parsePayloads(payloads: string): number[]; + +export function parseParams(params: string): ParamMap; + +export function parseImageAttributes(params: string): ParamMap[]; + +export function parseRemoteCandidates(candidates: string): { + component: number; + ip: string; + port: number; +}[]; + +export function parseSimulcastStreamList( + streams: string, +): { scid: number | string; paused: boolean }[][]; diff --git a/types/sdp-transform/package.json b/types/sdp-transform/package.json index b5bc34f963500d..5f24ede1474201 100644 --- a/types/sdp-transform/package.json +++ b/types/sdp-transform/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/sdp-transform", - "version": "2.4.9999", + "version": "2.15.9999", "projects": [ "https://github.com/clux/sdp-transform#readme" ], @@ -16,6 +16,10 @@ { "name": "@muenchow", "githubUsername": "muenchow" + }, + { + "name": "IƱaki Baz Castillo", + "githubUsername": "ibc" } ] } diff --git a/types/sdp-transform/sdp-transform-tests.ts b/types/sdp-transform/sdp-transform-tests.ts index 9338040ea4dda0..8d5c3aea2cfc96 100644 --- a/types/sdp-transform/sdp-transform-tests.ts +++ b/types/sdp-transform/sdp-transform-tests.ts @@ -67,3 +67,57 @@ function test_crypto_attribute() { crypto.config; // $ExpectType string crypto.sessionConfig; // $ExpectType string | undefined } + +function test_rtcp_fb_attribute() { + const session: SessionDescription = parse(""); + session.media[0].rtcpFb = [ + { + payload: 98, + type: "nack", + subtype: "pli", + }, + ]; + session.media[1].rtcpFb = [ + { + payload: "*", + type: "transport-cc", + }, + ]; + const sdp: string = write(session); + const parsed = parse(sdp); + const rtcpFb0 = parsed.media[0].rtcpFb![0]; + rtcpFb0.payload; // $ExpectType number | string + rtcpFb0.type; // $ExpectType string + rtcpFb0.subtype; // $ExpectType string | undefined + const rtcpFb1 = parsed.media[0].rtcpFb![1]; + rtcpFb1.payload; // $ExpectType number | string + rtcpFb1.type; // $ExpectType string + rtcpFb1.subtype; // $ExpectType string | undefined +} + +function test_datachannel_media_description() { + const session: SessionDescription = parse(""); + session.media[0] = { + connection: { + version: 4, + ip: "0.0.0.0", + }, + type: "application", + protocol: "UDP/DTLS/SCTP", + port: 9, + rtp: [], + fmtp: [], + }; + + const sdp: string = write(session); + const parsed = parse(sdp); + const connection = parsed.media[0].connection!; + connection.version; // $ExpectType number + connection.ip; // $ExpectType string + const type = parsed.media[0].type; + type; // $ExpectType string + const protocol = parsed.media[0].protocol; + protocol; // $ExpectType string + const port = parsed.media[0].port; + port; // $ExpectType number +}