From 22a6ee251d6f13c6ab1ecb200d974f1a6feb1b8d Mon Sep 17 00:00:00 2001 From: James Ives Date: Fri, 26 May 2023 12:26:43 +0000 Subject: [PATCH] =?UTF-8?q?Deploy=20Production=20Code=20for=20Commit=20f08?= =?UTF-8?q?10b12e31c6356ab553b573327d08c28d3bdea=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants.d.ts | 2 +- lib/execute.d.ts | 2 +- node_modules/@actions/io/lib/io-util.d.ts | 4 +- node_modules/@actions/io/lib/io-util.js | 10 +- node_modules/@actions/io/lib/io-util.js.map | 2 +- node_modules/@actions/io/lib/io.js | 64 +- node_modules/@actions/io/lib/io.js.map | 2 +- node_modules/@actions/io/package.json | 2 +- node_modules/@types/node/README.md | 4 +- node_modules/@types/node/assert.d.ts | 197 +- node_modules/@types/node/async_hooks.d.ts | 103 +- node_modules/@types/node/buffer.d.ts | 305 ++- node_modules/@types/node/child_process.d.ts | 138 +- node_modules/@types/node/cluster.d.ts | 24 +- node_modules/@types/node/console.d.ts | 10 +- node_modules/@types/node/crypto.d.ts | 473 ++--- node_modules/@types/node/dgram.d.ts | 30 +- .../@types/node/diagnostics_channel.d.ts | 80 +- node_modules/@types/node/dns.d.ts | 43 +- node_modules/@types/node/dns/promises.d.ts | 56 +- node_modules/@types/node/dom-events.d.ts | 126 ++ node_modules/@types/node/domain.d.ts | 8 +- node_modules/@types/node/events.d.ts | 221 +- node_modules/@types/node/fs.d.ts | 315 ++- node_modules/@types/node/fs/promises.d.ts | 156 +- node_modules/@types/node/globals.d.ts | 35 +- node_modules/@types/node/http.d.ts | 439 ++-- node_modules/@types/node/http2.d.ts | 109 +- node_modules/@types/node/https.d.ts | 206 +- node_modules/@types/node/index.d.ts | 4 +- node_modules/@types/node/inspector.d.ts | 13 +- node_modules/@types/node/module.d.ts | 10 +- node_modules/@types/node/net.d.ts | 47 +- node_modules/@types/node/os.d.ts | 43 +- node_modules/@types/node/package.json | 13 +- node_modules/@types/node/path.d.ts | 12 +- node_modules/@types/node/perf_hooks.d.ts | 56 +- node_modules/@types/node/process.d.ts | 95 +- node_modules/@types/node/punycode.d.ts | 2 +- node_modules/@types/node/querystring.d.ts | 12 +- node_modules/@types/node/readline.d.ts | 191 +- .../@types/node/readline/promises.d.ts | 128 +- node_modules/@types/node/repl.d.ts | 40 +- node_modules/@types/node/stream.d.ts | 1820 +++++++++-------- .../@types/node/stream/consumers.d.ts | 16 +- node_modules/@types/node/string_decoder.d.ts | 12 +- node_modules/@types/node/test.d.ts | 1016 +++++++-- node_modules/@types/node/timers.d.ts | 129 +- node_modules/@types/node/timers/promises.d.ts | 27 +- node_modules/@types/node/tls.d.ts | 149 +- node_modules/@types/node/trace_events.d.ts | 29 +- node_modules/@types/node/ts4.8/assert.d.ts | 197 +- .../@types/node/ts4.8/async_hooks.d.ts | 103 +- node_modules/@types/node/ts4.8/buffer.d.ts | 305 ++- .../@types/node/ts4.8/child_process.d.ts | 138 +- node_modules/@types/node/ts4.8/cluster.d.ts | 24 +- node_modules/@types/node/ts4.8/console.d.ts | 10 +- node_modules/@types/node/ts4.8/crypto.d.ts | 468 ++--- node_modules/@types/node/ts4.8/dgram.d.ts | 30 +- .../node/ts4.8/diagnostics_channel.d.ts | 80 +- node_modules/@types/node/ts4.8/dns.d.ts | 43 +- .../@types/node/ts4.8/dns/promises.d.ts | 56 +- .../@types/node/ts4.8/dom-events.d.ts | 126 ++ node_modules/@types/node/ts4.8/domain.d.ts | 8 +- node_modules/@types/node/ts4.8/events.d.ts | 221 +- node_modules/@types/node/ts4.8/fs.d.ts | 315 ++- .../@types/node/ts4.8/fs/promises.d.ts | 153 +- node_modules/@types/node/ts4.8/globals.d.ts | 35 +- node_modules/@types/node/ts4.8/http.d.ts | 439 ++-- node_modules/@types/node/ts4.8/http2.d.ts | 109 +- node_modules/@types/node/ts4.8/https.d.ts | 206 +- node_modules/@types/node/ts4.8/index.d.ts | 1 + node_modules/@types/node/ts4.8/inspector.d.ts | 13 +- node_modules/@types/node/ts4.8/module.d.ts | 10 +- node_modules/@types/node/ts4.8/net.d.ts | 49 +- node_modules/@types/node/ts4.8/os.d.ts | 43 +- node_modules/@types/node/ts4.8/path.d.ts | 12 +- .../@types/node/ts4.8/perf_hooks.d.ts | 56 +- node_modules/@types/node/ts4.8/process.d.ts | 95 +- node_modules/@types/node/ts4.8/punycode.d.ts | 2 +- .../@types/node/ts4.8/querystring.d.ts | 12 +- node_modules/@types/node/ts4.8/readline.d.ts | 191 +- .../@types/node/ts4.8/readline/promises.d.ts | 128 +- node_modules/@types/node/ts4.8/repl.d.ts | 40 +- node_modules/@types/node/ts4.8/stream.d.ts | 333 +-- .../@types/node/ts4.8/stream/consumers.d.ts | 16 +- .../@types/node/ts4.8/string_decoder.d.ts | 12 +- node_modules/@types/node/ts4.8/test.d.ts | 1042 +++++++++- node_modules/@types/node/ts4.8/timers.d.ts | 129 +- .../@types/node/ts4.8/timers/promises.d.ts | 27 +- node_modules/@types/node/ts4.8/tls.d.ts | 149 +- .../@types/node/ts4.8/trace_events.d.ts | 29 +- node_modules/@types/node/ts4.8/tty.d.ts | 9 +- node_modules/@types/node/ts4.8/url.d.ts | 100 +- node_modules/@types/node/ts4.8/util.d.ts | 488 +++-- node_modules/@types/node/ts4.8/v8.d.ts | 267 ++- node_modules/@types/node/ts4.8/vm.d.ts | 449 +++- node_modules/@types/node/ts4.8/wasi.d.ts | 32 +- .../@types/node/ts4.8/worker_threads.d.ts | 109 +- node_modules/@types/node/ts4.8/zlib.d.ts | 22 +- node_modules/@types/node/tty.d.ts | 9 +- node_modules/@types/node/url.d.ts | 100 +- node_modules/@types/node/util.d.ts | 488 +++-- node_modules/@types/node/v8.d.ts | 267 ++- node_modules/@types/node/vm.d.ts | 449 +++- node_modules/@types/node/wasi.d.ts | 32 +- node_modules/@types/node/worker_threads.d.ts | 109 +- node_modules/@types/node/zlib.d.ts | 22 +- 108 files changed, 10552 insertions(+), 4885 deletions(-) create mode 100755 node_modules/@types/node/dom-events.d.ts create mode 100755 node_modules/@types/node/ts4.8/dom-events.d.ts diff --git a/lib/constants.d.ts b/lib/constants.d.ts index 59086ad03..b8c5245b2 100644 --- a/lib/constants.d.ts +++ b/lib/constants.d.ts @@ -73,7 +73,7 @@ export interface NodeActionInterface { } export declare const action: ActionInterface; /** Types for the required action parameters. */ -export declare type RequiredActionParameters = Pick; +export type RequiredActionParameters = Pick; /** Status codes for the action. */ export declare enum Status { SUCCESS = "success", diff --git a/lib/execute.d.ts b/lib/execute.d.ts index 12f397e61..c60948013 100644 --- a/lib/execute.d.ts +++ b/lib/execute.d.ts @@ -1,5 +1,5 @@ /// -declare type ExecuteOutput = { +type ExecuteOutput = { stdout: string; stderr: string; }; diff --git a/node_modules/@actions/io/lib/io-util.d.ts b/node_modules/@actions/io/lib/io-util.d.ts index 0cddd318d..0241e72bb 100644 --- a/node_modules/@actions/io/lib/io-util.d.ts +++ b/node_modules/@actions/io/lib/io-util.d.ts @@ -1,7 +1,9 @@ /// import * as fs from 'fs'; -export declare const chmod: typeof fs.promises.chmod, copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, readdir: typeof fs.promises.readdir, readlink: typeof fs.promises.readlink, rename: typeof fs.promises.rename, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, symlink: typeof fs.promises.symlink, unlink: typeof fs.promises.unlink; +export declare const chmod: typeof fs.promises.chmod, copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, open: typeof fs.promises.open, readdir: typeof fs.promises.readdir, readlink: typeof fs.promises.readlink, rename: typeof fs.promises.rename, rm: typeof fs.promises.rm, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, symlink: typeof fs.promises.symlink, unlink: typeof fs.promises.unlink; export declare const IS_WINDOWS: boolean; +export declare const UV_FS_O_EXLOCK = 268435456; +export declare const READONLY: number; export declare function exists(fsPath: string): Promise; export declare function isDirectory(fsPath: string, useStat?: boolean): Promise; /** diff --git a/node_modules/@actions/io/lib/io-util.js b/node_modules/@actions/io/lib/io-util.js index aae903cba..f12e5b0d2 100644 --- a/node_modules/@actions/io/lib/io-util.js +++ b/node_modules/@actions/io/lib/io-util.js @@ -29,11 +29,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; var _a; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0; +exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readlink = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0; const fs = __importStar(require("fs")); const path = __importStar(require("path")); -_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; +_a = fs.promises +// export const {open} = 'fs' +, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; +// export const {open} = 'fs' exports.IS_WINDOWS = process.platform === 'win32'; +// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691 +exports.UV_FS_O_EXLOCK = 0x10000000; +exports.READONLY = fs.constants.O_RDONLY; function exists(fsPath) { return __awaiter(this, void 0, void 0, function* () { try { diff --git a/node_modules/@actions/io/lib/io-util.js.map b/node_modules/@actions/io/lib/io-util.js.map index ad5eebbb8..9a587b300 100644 --- a/node_modules/@actions/io/lib/io-util.js.map +++ b/node_modules/@actions/io/lib/io-util.js.map @@ -1 +1 @@ -{"version":3,"file":"io-util.js","sourceRoot":"","sources":["../src/io-util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AAEf,KAYT,EAAE,CAAC,QAAQ,EAXb,aAAK,aACL,gBAAQ,gBACR,aAAK,aACL,aAAK,aACL,eAAO,eACP,gBAAQ,gBACR,cAAM,cACN,aAAK,aACL,YAAI,YACJ,eAAO,eACP,cAAM,aACO;AAEF,QAAA,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;AAEtD,SAAsB,MAAM,CAAC,MAAc;;QACzC,IAAI;YACF,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;SACnB;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,OAAO,KAAK,CAAA;aACb;YAED,MAAM,GAAG,CAAA;SACV;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAAA;AAZD,wBAYC;AAED,SAAsB,WAAW,CAC/B,MAAc,EACd,OAAO,GAAG,KAAK;;QAEf,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,YAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;QAChE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAA;IAC5B,CAAC;CAAA;AAND,kCAMC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,CAAS;IAChC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;KAC5D;IAED,IAAI,kBAAU,EAAE;QACd,OAAO,CACL,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,8BAA8B;SACxE,CAAA,CAAC,sBAAsB;KACzB;IAED,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC;AAbD,4BAaC;AAED;;;;;GAKG;AACH,SAAsB,oBAAoB,CACxC,QAAgB,EAChB,UAAoB;;QAEpB,IAAI,KAAK,GAAyB,SAAS,CAAA;QAC3C,IAAI;YACF,mBAAmB;YACnB,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;SAC7B;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;aACF;SACF;QACD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAC3B,IAAI,kBAAU,EAAE;gBACd,uCAAuC;gBACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;gBACrD,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,EAAE;oBACpE,OAAO,QAAQ,CAAA;iBAChB;aACF;iBAAM;gBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;oBAC3B,OAAO,QAAQ,CAAA;iBAChB;aACF;SACF;QAED,qBAAqB;QACrB,MAAM,gBAAgB,GAAG,QAAQ,CAAA;QACjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,QAAQ,GAAG,gBAAgB,GAAG,SAAS,CAAA;YAEvC,KAAK,GAAG,SAAS,CAAA;YACjB,IAAI;gBACF,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;aAC7B;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACzB,sCAAsC;oBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;iBACF;aACF;YAED,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;gBAC3B,IAAI,kBAAU,EAAE;oBACd,yEAAyE;oBACzE,IAAI;wBACF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;wBACxC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;wBACvD,KAAK,MAAM,UAAU,IAAI,MAAM,eAAO,CAAC,SAAS,CAAC,EAAE;4BACjD,IAAI,SAAS,KAAK,UAAU,CAAC,WAAW,EAAE,EAAE;gCAC1C,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;gCAC3C,MAAK;6BACN;yBACF;qBACF;oBAAC,OAAO,GAAG,EAAE;wBACZ,sCAAsC;wBACtC,OAAO,CAAC,GAAG,CACT,yEAAyE,QAAQ,MAAM,GAAG,EAAE,CAC7F,CAAA;qBACF;oBAED,OAAO,QAAQ,CAAA;iBAChB;qBAAM;oBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;wBAC3B,OAAO,QAAQ,CAAA;qBAChB;iBACF;aACF;SACF;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AA5ED,oDA4EC;AAED,SAAS,mBAAmB,CAAC,CAAS;IACpC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IACX,IAAI,kBAAU,EAAE;QACd,6BAA6B;QAC7B,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAE1B,2BAA2B;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;KACjC;IAED,2BAA2B;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC;AAED,qCAAqC;AACrC,6BAA6B;AAC7B,6BAA6B;AAC7B,SAAS,gBAAgB,CAAC,KAAe;IACvC,OAAO,CACL,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QACxD,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAC1D,CAAA;AACH,CAAC;AAED,qCAAqC;AACrC,SAAgB,UAAU;;IACxB,aAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,mCAAI,SAAS,CAAA;AAC5C,CAAC;AAFD,gCAEC"} \ No newline at end of file +{"version":3,"file":"io-util.js","sourceRoot":"","sources":["../src/io-util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AAEf,KAcT,EAAE,CAAC,QAAQ;AACf,6BAA6B;EAd3B,aAAK,aACL,gBAAQ,gBACR,aAAK,aACL,aAAK,aACL,YAAI,YACJ,eAAO,eACP,gBAAQ,gBACR,cAAM,cACN,UAAE,UACF,aAAK,aACL,YAAI,YACJ,eAAO,eACP,cAAM,aACO;AACf,6BAA6B;AAChB,QAAA,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;AACtD,iHAAiH;AACpG,QAAA,cAAc,GAAG,UAAU,CAAA;AAC3B,QAAA,QAAQ,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAA;AAE7C,SAAsB,MAAM,CAAC,MAAc;;QACzC,IAAI;YACF,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;SACnB;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,OAAO,KAAK,CAAA;aACb;YAED,MAAM,GAAG,CAAA;SACV;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAAA;AAZD,wBAYC;AAED,SAAsB,WAAW,CAC/B,MAAc,EACd,OAAO,GAAG,KAAK;;QAEf,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,YAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;QAChE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAA;IAC5B,CAAC;CAAA;AAND,kCAMC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,CAAS;IAChC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;KAC5D;IAED,IAAI,kBAAU,EAAE;QACd,OAAO,CACL,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,8BAA8B;SACxE,CAAA,CAAC,sBAAsB;KACzB;IAED,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC;AAbD,4BAaC;AAED;;;;;GAKG;AACH,SAAsB,oBAAoB,CACxC,QAAgB,EAChB,UAAoB;;QAEpB,IAAI,KAAK,GAAyB,SAAS,CAAA;QAC3C,IAAI;YACF,mBAAmB;YACnB,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;SAC7B;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;aACF;SACF;QACD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAC3B,IAAI,kBAAU,EAAE;gBACd,uCAAuC;gBACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;gBACrD,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,EAAE;oBACpE,OAAO,QAAQ,CAAA;iBAChB;aACF;iBAAM;gBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;oBAC3B,OAAO,QAAQ,CAAA;iBAChB;aACF;SACF;QAED,qBAAqB;QACrB,MAAM,gBAAgB,GAAG,QAAQ,CAAA;QACjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,QAAQ,GAAG,gBAAgB,GAAG,SAAS,CAAA;YAEvC,KAAK,GAAG,SAAS,CAAA;YACjB,IAAI;gBACF,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;aAC7B;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACzB,sCAAsC;oBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;iBACF;aACF;YAED,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;gBAC3B,IAAI,kBAAU,EAAE;oBACd,yEAAyE;oBACzE,IAAI;wBACF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;wBACxC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;wBACvD,KAAK,MAAM,UAAU,IAAI,MAAM,eAAO,CAAC,SAAS,CAAC,EAAE;4BACjD,IAAI,SAAS,KAAK,UAAU,CAAC,WAAW,EAAE,EAAE;gCAC1C,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;gCAC3C,MAAK;6BACN;yBACF;qBACF;oBAAC,OAAO,GAAG,EAAE;wBACZ,sCAAsC;wBACtC,OAAO,CAAC,GAAG,CACT,yEAAyE,QAAQ,MAAM,GAAG,EAAE,CAC7F,CAAA;qBACF;oBAED,OAAO,QAAQ,CAAA;iBAChB;qBAAM;oBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;wBAC3B,OAAO,QAAQ,CAAA;qBAChB;iBACF;aACF;SACF;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AA5ED,oDA4EC;AAED,SAAS,mBAAmB,CAAC,CAAS;IACpC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IACX,IAAI,kBAAU,EAAE;QACd,6BAA6B;QAC7B,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAE1B,2BAA2B;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;KACjC;IAED,2BAA2B;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC;AAED,qCAAqC;AACrC,6BAA6B;AAC7B,6BAA6B;AAC7B,SAAS,gBAAgB,CAAC,KAAe;IACvC,OAAO,CACL,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QACxD,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAC1D,CAAA;AACH,CAAC;AAED,qCAAqC;AACrC,SAAgB,UAAU;;IACxB,aAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,mCAAI,SAAS,CAAA;AAC5C,CAAC;AAFD,gCAEC"} \ No newline at end of file diff --git a/node_modules/@actions/io/lib/io.js b/node_modules/@actions/io/lib/io.js index 4dc1fc34b..15f7d7cf5 100644 --- a/node_modules/@actions/io/lib/io.js +++ b/node_modules/@actions/io/lib/io.js @@ -30,12 +30,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", { value: true }); exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0; const assert_1 = require("assert"); -const childProcess = __importStar(require("child_process")); const path = __importStar(require("path")); -const util_1 = require("util"); const ioUtil = __importStar(require("./io-util")); -const exec = util_1.promisify(childProcess.exec); -const execFile = util_1.promisify(childProcess.execFile); /** * Copies a file or folder. * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js @@ -116,61 +112,23 @@ exports.mv = mv; function rmRF(inputPath) { return __awaiter(this, void 0, void 0, function* () { if (ioUtil.IS_WINDOWS) { - // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another - // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del. // Check for invalid characters // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file if (/[*"<>|]/.test(inputPath)) { throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows'); } - try { - const cmdPath = ioUtil.getCmdPath(); - if (yield ioUtil.isDirectory(inputPath, true)) { - yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, { - env: { inputPath } - }); - } - else { - yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, { - env: { inputPath } - }); - } - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - } - // Shelling out fails to remove a symlink folder with missing source, this unlink catches that - try { - yield ioUtil.unlink(inputPath); - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - } } - else { - let isDir = false; - try { - isDir = yield ioUtil.isDirectory(inputPath); - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - return; - } - if (isDir) { - yield execFile(`rm`, [`-rf`, `${inputPath}`]); - } - else { - yield ioUtil.unlink(inputPath); - } + try { + // note if path does not exist, error is silent + yield ioUtil.rm(inputPath, { + force: true, + maxRetries: 3, + recursive: true, + retryDelay: 300 + }); + } + catch (err) { + throw new Error(`File was unable to be removed ${err}`); } }); } diff --git a/node_modules/@actions/io/lib/io.js.map b/node_modules/@actions/io/lib/io.js.map index 3249d7d85..4021d2898 100644 --- a/node_modules/@actions/io/lib/io.js.map +++ b/node_modules/@actions/io/lib/io.js.map @@ -1 +1 @@ -{"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAyB;AACzB,4DAA6C;AAC7C,2CAA4B;AAC5B,+BAA8B;AAC9B,kDAAmC;AAEnC,MAAM,IAAI,GAAG,gBAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;AACzC,MAAM,QAAQ,GAAG,gBAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;AAsBjD;;;;;;;GAOG;AACH,SAAsB,EAAE,CACtB,MAAc,EACd,IAAY,EACZ,UAAuB,EAAE;;QAEzB,MAAM,EAAC,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;QAExE,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC7E,4CAA4C;QAC5C,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE;YAC3C,OAAM;SACP;QAED,wDAAwD;QACxD,MAAM,OAAO,GACX,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE,IAAI,mBAAmB;YACvD,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC,CAAC,IAAI,CAAA;QAEV,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAA;SACxD;QACD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAE5C,IAAI,UAAU,CAAC,WAAW,EAAE,EAAE;YAC5B,IAAI,CAAC,SAAS,EAAE;gBACd,MAAM,IAAI,KAAK,CACb,mBAAmB,MAAM,4DAA4D,CACtF,CAAA;aACF;iBAAM;gBACL,MAAM,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;aAChD;SACF;aAAM;YACL,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE;gBACzC,oCAAoC;gBACpC,MAAM,IAAI,KAAK,CAAC,IAAI,OAAO,UAAU,MAAM,qBAAqB,CAAC,CAAA;aAClE;YAED,MAAM,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;SACvC;IACH,CAAC;CAAA;AAxCD,gBAwCC;AAED;;;;;;GAMG;AACH,SAAsB,EAAE,CACtB,MAAc,EACd,IAAY,EACZ,UAAuB,EAAE;;QAEzB,IAAI,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC7B,IAAI,UAAU,GAAG,IAAI,CAAA;YACrB,IAAI,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;gBAClC,0CAA0C;gBAC1C,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;gBAC7C,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;aACvC;YAED,IAAI,UAAU,EAAE;gBACd,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE;oBAC1C,MAAM,IAAI,CAAC,IAAI,CAAC,CAAA;iBACjB;qBAAM;oBACL,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;iBAC9C;aACF;SACF;QACD,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;QAChC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACnC,CAAC;CAAA;AAvBD,gBAuBC;AAED;;;;GAIG;AACH,SAAsB,IAAI,CAAC,SAAiB;;QAC1C,IAAI,MAAM,CAAC,UAAU,EAAE;YACrB,yHAAyH;YACzH,mGAAmG;YAEnG,+BAA+B;YAC/B,sEAAsE;YACtE,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBAC7B,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAA;aACF;YACD,IAAI;gBACF,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAA;gBACnC,IAAI,MAAM,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE;oBAC7C,MAAM,IAAI,CAAC,GAAG,OAAO,iCAAiC,EAAE;wBACtD,GAAG,EAAE,EAAC,SAAS,EAAC;qBACjB,CAAC,CAAA;iBACH;qBAAM;oBACL,MAAM,IAAI,CAAC,GAAG,OAAO,kCAAkC,EAAE;wBACvD,GAAG,EAAE,EAAC,SAAS,EAAC;qBACjB,CAAC,CAAA;iBACH;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,6EAA6E;gBAC7E,yBAAyB;gBACzB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ;oBAAE,MAAM,GAAG,CAAA;aACrC;YAED,8FAA8F;YAC9F,IAAI;gBACF,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;aAC/B;YAAC,OAAO,GAAG,EAAE;gBACZ,6EAA6E;gBAC7E,yBAAyB;gBACzB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ;oBAAE,MAAM,GAAG,CAAA;aACrC;SACF;aAAM;YACL,IAAI,KAAK,GAAG,KAAK,CAAA;YACjB,IAAI;gBACF,KAAK,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;aAC5C;YAAC,OAAO,GAAG,EAAE;gBACZ,6EAA6E;gBAC7E,yBAAyB;gBACzB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ;oBAAE,MAAM,GAAG,CAAA;gBACpC,OAAM;aACP;YAED,IAAI,KAAK,EAAE;gBACT,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC,CAAA;aAC9C;iBAAM;gBACL,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;aAC/B;SACF;IACH,CAAC;CAAA;AAtDD,oBAsDC;AAED;;;;;;GAMG;AACH,SAAsB,MAAM,CAAC,MAAc;;QACzC,WAAE,CAAC,MAAM,EAAE,kCAAkC,CAAC,CAAA;QAC9C,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAA;IAC/C,CAAC;CAAA;AAHD,wBAGC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAC,IAAY,EAAE,KAAe;;QACvD,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;SAChD;QAED,4BAA4B;QAC5B,IAAI,KAAK,EAAE;YACT,MAAM,MAAM,GAAW,MAAM,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;YAE/C,IAAI,CAAC,MAAM,EAAE;gBACX,IAAI,MAAM,CAAC,UAAU,EAAE;oBACrB,MAAM,IAAI,KAAK,CACb,qCAAqC,IAAI,wMAAwM,CAClP,CAAA;iBACF;qBAAM;oBACL,MAAM,IAAI,KAAK,CACb,qCAAqC,IAAI,gMAAgM,CAC1O,CAAA;iBACF;aACF;YAED,OAAO,MAAM,CAAA;SACd;QAED,MAAM,OAAO,GAAa,MAAM,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhD,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACjC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;SAClB;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AA/BD,sBA+BC;AAED;;;;GAIG;AACH,SAAsB,UAAU,CAAC,IAAY;;QAC3C,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;SAChD;QAED,sCAAsC;QACtC,MAAM,UAAU,GAAa,EAAE,CAAA;QAC/B,IAAI,MAAM,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC/C,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBACpE,IAAI,SAAS,EAAE;oBACb,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;iBAC3B;aACF;SACF;QAED,+DAA+D;QAC/D,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,MAAM,QAAQ,GAAW,MAAM,MAAM,CAAC,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;YAE5E,IAAI,QAAQ,EAAE;gBACZ,OAAO,CAAC,QAAQ,CAAC,CAAA;aAClB;YAED,OAAO,EAAE,CAAA;SACV;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAC3B,OAAO,EAAE,CAAA;SACV;QAED,gCAAgC;QAChC,EAAE;QACF,iGAAiG;QACjG,+FAA+F;QAC/F,iGAAiG;QACjG,oBAAoB;QACpB,MAAM,WAAW,GAAa,EAAE,CAAA;QAEhC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE;YACpB,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBACtD,IAAI,CAAC,EAAE;oBACL,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;iBACpB;aACF;SACF;QAED,mBAAmB;QACnB,MAAM,OAAO,GAAa,EAAE,CAAA;QAE5B,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE;YACnC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAChD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAC1B,UAAU,CACX,CAAA;YACD,IAAI,QAAQ,EAAE;gBACZ,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;aACvB;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CAAA;AA7DD,gCA6DC;AAED,SAAS,eAAe,CAAC,OAAoB;IAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAA;IAC1D,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAC5C,MAAM,mBAAmB,GACvB,OAAO,CAAC,mBAAmB,IAAI,IAAI;QACjC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAC1C,OAAO,EAAC,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAC,CAAA;AAChD,CAAC;AAED,SAAe,cAAc,CAC3B,SAAiB,EACjB,OAAe,EACf,YAAoB,EACpB,KAAc;;QAEd,gDAAgD;QAChD,IAAI,YAAY,IAAI,GAAG;YAAE,OAAM;QAC/B,YAAY,EAAE,CAAA;QAEd,MAAM,MAAM,CAAC,OAAO,CAAC,CAAA;QAErB,MAAM,KAAK,GAAa,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAEvD,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE;YAC5B,MAAM,OAAO,GAAG,GAAG,SAAS,IAAI,QAAQ,EAAE,CAAA;YAC1C,MAAM,QAAQ,GAAG,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAA;YACzC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YAE/C,IAAI,WAAW,CAAC,WAAW,EAAE,EAAE;gBAC7B,UAAU;gBACV,MAAM,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,CAAA;aAC7D;iBAAM;gBACL,MAAM,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;aACzC;SACF;QAED,kDAAkD;QAClD,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAClE,CAAC;CAAA;AAED,qBAAqB;AACrB,SAAe,QAAQ,CACrB,OAAe,EACf,QAAgB,EAChB,KAAc;;QAEd,IAAI,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE;YAClD,oBAAoB;YACpB,IAAI;gBACF,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;gBAC5B,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;aAC9B;YAAC,OAAO,CAAC,EAAE;gBACV,kCAAkC;gBAClC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE;oBACtB,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;oBACpC,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;iBAC9B;gBACD,iDAAiD;aAClD;YAED,oBAAoB;YACpB,MAAM,WAAW,GAAW,MAAM,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;YAC1D,MAAM,MAAM,CAAC,OAAO,CAClB,WAAW,EACX,QAAQ,EACR,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CACtC,CAAA;SACF;aAAM,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,KAAK,EAAE;YACpD,MAAM,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;SACzC;IACH,CAAC;CAAA"} \ No newline at end of file +{"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAyB;AACzB,2CAA4B;AAC5B,kDAAmC;AAsBnC;;;;;;;GAOG;AACH,SAAsB,EAAE,CACtB,MAAc,EACd,IAAY,EACZ,UAAuB,EAAE;;QAEzB,MAAM,EAAC,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;QAExE,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC7E,4CAA4C;QAC5C,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE;YAC3C,OAAM;SACP;QAED,wDAAwD;QACxD,MAAM,OAAO,GACX,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE,IAAI,mBAAmB;YACvD,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC,CAAC,IAAI,CAAA;QAEV,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAA;SACxD;QACD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAE5C,IAAI,UAAU,CAAC,WAAW,EAAE,EAAE;YAC5B,IAAI,CAAC,SAAS,EAAE;gBACd,MAAM,IAAI,KAAK,CACb,mBAAmB,MAAM,4DAA4D,CACtF,CAAA;aACF;iBAAM;gBACL,MAAM,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;aAChD;SACF;aAAM;YACL,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE;gBACzC,oCAAoC;gBACpC,MAAM,IAAI,KAAK,CAAC,IAAI,OAAO,UAAU,MAAM,qBAAqB,CAAC,CAAA;aAClE;YAED,MAAM,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;SACvC;IACH,CAAC;CAAA;AAxCD,gBAwCC;AAED;;;;;;GAMG;AACH,SAAsB,EAAE,CACtB,MAAc,EACd,IAAY,EACZ,UAAuB,EAAE;;QAEzB,IAAI,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC7B,IAAI,UAAU,GAAG,IAAI,CAAA;YACrB,IAAI,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;gBAClC,0CAA0C;gBAC1C,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;gBAC7C,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;aACvC;YAED,IAAI,UAAU,EAAE;gBACd,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE;oBAC1C,MAAM,IAAI,CAAC,IAAI,CAAC,CAAA;iBACjB;qBAAM;oBACL,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;iBAC9C;aACF;SACF;QACD,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;QAChC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACnC,CAAC;CAAA;AAvBD,gBAuBC;AAED;;;;GAIG;AACH,SAAsB,IAAI,CAAC,SAAiB;;QAC1C,IAAI,MAAM,CAAC,UAAU,EAAE;YACrB,+BAA+B;YAC/B,sEAAsE;YACtE,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBAC7B,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAA;aACF;SACF;QACD,IAAI;YACF,+CAA+C;YAC/C,MAAM,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE;gBACzB,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,CAAC;gBACb,SAAS,EAAE,IAAI;gBACf,UAAU,EAAE,GAAG;aAChB,CAAC,CAAA;SACH;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAA;SACxD;IACH,CAAC;CAAA;AArBD,oBAqBC;AAED;;;;;;GAMG;AACH,SAAsB,MAAM,CAAC,MAAc;;QACzC,WAAE,CAAC,MAAM,EAAE,kCAAkC,CAAC,CAAA;QAC9C,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAA;IAC/C,CAAC;CAAA;AAHD,wBAGC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAC,IAAY,EAAE,KAAe;;QACvD,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;SAChD;QAED,4BAA4B;QAC5B,IAAI,KAAK,EAAE;YACT,MAAM,MAAM,GAAW,MAAM,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;YAE/C,IAAI,CAAC,MAAM,EAAE;gBACX,IAAI,MAAM,CAAC,UAAU,EAAE;oBACrB,MAAM,IAAI,KAAK,CACb,qCAAqC,IAAI,wMAAwM,CAClP,CAAA;iBACF;qBAAM;oBACL,MAAM,IAAI,KAAK,CACb,qCAAqC,IAAI,gMAAgM,CAC1O,CAAA;iBACF;aACF;YAED,OAAO,MAAM,CAAA;SACd;QAED,MAAM,OAAO,GAAa,MAAM,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhD,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACjC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;SAClB;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AA/BD,sBA+BC;AAED;;;;GAIG;AACH,SAAsB,UAAU,CAAC,IAAY;;QAC3C,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;SAChD;QAED,sCAAsC;QACtC,MAAM,UAAU,GAAa,EAAE,CAAA;QAC/B,IAAI,MAAM,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC/C,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBACpE,IAAI,SAAS,EAAE;oBACb,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;iBAC3B;aACF;SACF;QAED,+DAA+D;QAC/D,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,MAAM,QAAQ,GAAW,MAAM,MAAM,CAAC,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;YAE5E,IAAI,QAAQ,EAAE;gBACZ,OAAO,CAAC,QAAQ,CAAC,CAAA;aAClB;YAED,OAAO,EAAE,CAAA;SACV;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAC3B,OAAO,EAAE,CAAA;SACV;QAED,gCAAgC;QAChC,EAAE;QACF,iGAAiG;QACjG,+FAA+F;QAC/F,iGAAiG;QACjG,oBAAoB;QACpB,MAAM,WAAW,GAAa,EAAE,CAAA;QAEhC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE;YACpB,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBACtD,IAAI,CAAC,EAAE;oBACL,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;iBACpB;aACF;SACF;QAED,mBAAmB;QACnB,MAAM,OAAO,GAAa,EAAE,CAAA;QAE5B,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE;YACnC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAChD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAC1B,UAAU,CACX,CAAA;YACD,IAAI,QAAQ,EAAE;gBACZ,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;aACvB;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CAAA;AA7DD,gCA6DC;AAED,SAAS,eAAe,CAAC,OAAoB;IAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAA;IAC1D,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAC5C,MAAM,mBAAmB,GACvB,OAAO,CAAC,mBAAmB,IAAI,IAAI;QACjC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAC1C,OAAO,EAAC,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAC,CAAA;AAChD,CAAC;AAED,SAAe,cAAc,CAC3B,SAAiB,EACjB,OAAe,EACf,YAAoB,EACpB,KAAc;;QAEd,gDAAgD;QAChD,IAAI,YAAY,IAAI,GAAG;YAAE,OAAM;QAC/B,YAAY,EAAE,CAAA;QAEd,MAAM,MAAM,CAAC,OAAO,CAAC,CAAA;QAErB,MAAM,KAAK,GAAa,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAEvD,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE;YAC5B,MAAM,OAAO,GAAG,GAAG,SAAS,IAAI,QAAQ,EAAE,CAAA;YAC1C,MAAM,QAAQ,GAAG,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAA;YACzC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YAE/C,IAAI,WAAW,CAAC,WAAW,EAAE,EAAE;gBAC7B,UAAU;gBACV,MAAM,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,CAAA;aAC7D;iBAAM;gBACL,MAAM,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;aACzC;SACF;QAED,kDAAkD;QAClD,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAClE,CAAC;CAAA;AAED,qBAAqB;AACrB,SAAe,QAAQ,CACrB,OAAe,EACf,QAAgB,EAChB,KAAc;;QAEd,IAAI,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE;YAClD,oBAAoB;YACpB,IAAI;gBACF,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;gBAC5B,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;aAC9B;YAAC,OAAO,CAAC,EAAE;gBACV,kCAAkC;gBAClC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE;oBACtB,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;oBACpC,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;iBAC9B;gBACD,iDAAiD;aAClD;YAED,oBAAoB;YACpB,MAAM,WAAW,GAAW,MAAM,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;YAC1D,MAAM,MAAM,CAAC,OAAO,CAClB,WAAW,EACX,QAAQ,EACR,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CACtC,CAAA;SACF;aAAM,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,KAAK,EAAE;YACpD,MAAM,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;SACzC;IACH,CAAC;CAAA"} \ No newline at end of file diff --git a/node_modules/@actions/io/package.json b/node_modules/@actions/io/package.json index 5ebc63a43..e8c8d8fb3 100644 --- a/node_modules/@actions/io/package.json +++ b/node_modules/@actions/io/package.json @@ -1,6 +1,6 @@ { "name": "@actions/io", - "version": "1.1.2", + "version": "1.1.3", "description": "Actions io lib", "keywords": [ "github", diff --git a/node_modules/@types/node/README.md b/node_modules/@types/node/README.md index 7147596aa..d41c4d4a4 100755 --- a/node_modules/@types/node/README.md +++ b/node_modules/@types/node/README.md @@ -8,9 +8,9 @@ This package contains type definitions for Node.js (https://nodejs.org/). Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node. ### Additional Details - * Last updated: Sun, 02 Oct 2022 19:33:03 GMT + * Last updated: Thu, 25 May 2023 20:34:26 GMT * Dependencies: none * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone` # Credits -These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), and [Matteo Collina](https://github.com/mcollina). +These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky). diff --git a/node_modules/@types/node/assert.d.ts b/node_modules/@types/node/assert.d.ts index 8e02a66a0..e309252c1 100755 --- a/node_modules/@types/node/assert.d.ts +++ b/node_modules/@types/node/assert.d.ts @@ -1,7 +1,7 @@ /** - * The `assert` module provides a set of assertion functions for verifying + * The `node:assert` module provides a set of assertion functions for verifying * invariants. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/assert.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/assert.js) */ declare module 'assert' { /** @@ -12,14 +12,28 @@ declare module 'assert' { function assert(value: unknown, message?: string | Error): asserts value; namespace assert { /** - * Indicates the failure of an assertion. All errors thrown by the `assert` module - * will be instances of the `AssertionError` class. + * Indicates the failure of an assertion. All errors thrown by the `node:assert`module will be instances of the `AssertionError` class. */ class AssertionError extends Error { + /** + * Set to the `actual` argument for methods such as {@link assert.strictEqual()}. + */ actual: unknown; + /** + * Set to the `expected` argument for methods such as {@link assert.strictEqual()}. + */ expected: unknown; + /** + * Set to the passed in operator value. + */ operator: string; + /** + * Indicates if the message was auto-generated (`true`) or not. + */ generatedMessage: boolean; + /** + * Value is always `ERR_ASSERTION` to show that the error is an assertion error. + */ code: 'ERR_ASSERTION'; constructor(options?: { /** If provided, the error message is set to this value. */ @@ -36,9 +50,10 @@ declare module 'assert' { }); } /** - * This feature is currently experimental and behavior might still change. + * This feature is deprecated and will be removed in a future version. + * Please consider using alternatives such as the `mock` helper function. * @since v14.2.0, v12.19.0 - * @experimental + * @deprecated Deprecated */ class CallTracker { /** @@ -47,7 +62,7 @@ declare module 'assert' { * error. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * // Creates call tracker. * const tracker = new assert.CallTracker(); @@ -65,26 +80,44 @@ declare module 'assert' { */ calls(exact?: number): () => void; calls any>(fn?: Func, exact?: number): Func; + /** + * Example: + * + * ```js + * import assert from 'node:assert'; + * + * const tracker = new assert.CallTracker(); + * + * function func() {} + * const callsfunc = tracker.calls(func); + * callsfunc(1, 2, 3); + * + * assert.deepStrictEqual(tracker.getCalls(callsfunc), + * [{ thisArg: undefined, arguments: [1, 2, 3] }]); + * ``` + * @since v18.8.0, v16.18.0 + * @param fn + * @return An Array with all the calls to a tracked function. + */ + getCalls(fn: Function): CallTrackerCall[]; /** * The arrays contains information about the expected and actual number of calls of * the functions that have not been called the expected number of times. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * // Creates call tracker. * const tracker = new assert.CallTracker(); * * function func() {} * - * function foo() {} - * * // Returns a function that wraps func() that must be called exact times * // before tracker.verify(). * const callsfunc = tracker.calls(func, 2); * * // Returns an array containing information on callsfunc() - * tracker.report(); + * console.log(tracker.report()); * // [ * // { * // message: 'Expected the func function to be executed 2 time(s) but was @@ -97,15 +130,39 @@ declare module 'assert' { * // ] * ``` * @since v14.2.0, v12.19.0 - * @return of objects containing information about the wrapper functions returned by `calls`. + * @return An Array of objects containing information about the wrapper functions returned by `calls`. */ report(): CallTrackerReportInformation[]; + /** + * Reset calls of the call tracker. + * If a tracked function is passed as an argument, the calls will be reset for it. + * If no arguments are passed, all tracked functions will be reset. + * + * ```js + * import assert from 'node:assert'; + * + * const tracker = new assert.CallTracker(); + * + * function func() {} + * const callsfunc = tracker.calls(func); + * + * callsfunc(); + * // Tracker was called once + * assert.strictEqual(tracker.getCalls(callsfunc).length, 1); + * + * tracker.reset(callsfunc); + * assert.strictEqual(tracker.getCalls(callsfunc).length, 0); + * ``` + * @since v18.8.0, v16.18.0 + * @param fn a tracked function to reset. + */ + reset(fn?: Function): void; /** * Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that * have not been called the expected number of times. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * // Creates call tracker. * const tracker = new assert.CallTracker(); @@ -125,6 +182,10 @@ declare module 'assert' { */ verify(): void; } + interface CallTrackerCall { + thisArg: object; + arguments: unknown[]; + } interface CallTrackerReportInformation { message: string; /** The actual number of times the function was called. */ @@ -143,7 +204,7 @@ declare module 'assert' { * it will be thrown instead of the `AssertionError`. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.fail(); * // AssertionError [ERR_ASSERTION]: Failed @@ -181,7 +242,7 @@ declare module 'assert' { * thrown in a file! See below for further details. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.ok(true); * // OK @@ -216,7 +277,7 @@ declare module 'assert' { * ``` * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * // Using `assert()` works the same: * assert(0); @@ -241,7 +302,7 @@ declare module 'assert' { * and treated as being identical if both sides are `NaN`. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * assert.equal(1, 1); * // OK, 1 == 1 @@ -274,7 +335,7 @@ declare module 'assert' { * specially handled and treated as being identical if both sides are `NaN`. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * assert.notEqual(1, 2); * // OK @@ -321,24 +382,24 @@ declare module 'assert' { * Tests for any deep inequality. Opposite of {@link deepEqual}. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * const obj1 = { * a: { - * b: 1 - * } + * b: 1, + * }, * }; * const obj2 = { * a: { - * b: 2 - * } + * b: 2, + * }, * }; * const obj3 = { * a: { - * b: 1 - * } + * b: 1, + * }, * }; - * const obj4 = Object.create(obj1); + * const obj4 = { __proto__: obj1 }; * * assert.notDeepEqual(obj1, obj1); * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } } @@ -364,7 +425,7 @@ declare module 'assert' { * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.strictEqual(1, 2); * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal: @@ -402,7 +463,7 @@ declare module 'assert' { * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.notStrictEqual(1, 2); * // OK @@ -433,7 +494,7 @@ declare module 'assert' { * Tests for deep strict inequality. Opposite of {@link deepStrictEqual}. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.notDeepStrictEqual({ a: 1 }, { a: '1' }); * // OK @@ -464,14 +525,14 @@ declare module 'assert' { * Custom validation object/error instance: * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * const err = new TypeError('Wrong value'); * err.code = 404; * err.foo = 'bar'; * err.info = { * nested: true, - * baz: 'text' + * baz: 'text', * }; * err.reg = /abc/i; * @@ -484,16 +545,16 @@ declare module 'assert' { * message: 'Wrong value', * info: { * nested: true, - * baz: 'text' - * } + * baz: 'text', + * }, * // Only properties on the validation object will be tested for. * // Using nested objects requires all properties to be present. Otherwise * // the validation is going to fail. - * } + * }, * ); * * // Using regular expressions to validate error properties: - * throws( + * assert.throws( * () => { * throw err; * }, @@ -507,17 +568,17 @@ declare module 'assert' { * info: { * nested: true, * // It is not possible to use regular expressions for nested properties! - * baz: 'text' + * baz: 'text', * }, * // The `reg` property contains a regular expression and only if the * // validation object contains an identical regular expression, it is going * // to pass. - * reg: /abc/i - * } + * reg: /abc/i, + * }, * ); * * // Fails due to the different `message` and `name` properties: - * throws( + * assert.throws( * () => { * const otherErr = new Error('Not found'); * // Copy all enumerable properties from `err` to `otherErr`. @@ -528,20 +589,20 @@ declare module 'assert' { * }, * // The error's `message` and `name` properties will also be checked when using * // an error as validation object. - * err + * err, * ); * ``` * * Validate instanceof using constructor: * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.throws( * () => { * throw new Error('Wrong value'); * }, - * Error + * Error, * ); * ``` * @@ -551,13 +612,13 @@ declare module 'assert' { * therefore also include the error name. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.throws( * () => { * throw new Error('Wrong value'); * }, - * /^Error: Wrong value$/ + * /^Error: Wrong value$/, * ); * ``` * @@ -567,7 +628,7 @@ declare module 'assert' { * It will otherwise fail with an `AssertionError`. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.throws( * () => { @@ -583,7 +644,7 @@ declare module 'assert' { * // possible. * return true; * }, - * 'unexpected error' + * 'unexpected error', * ); * ``` * @@ -593,7 +654,7 @@ declare module 'assert' { * a string as the second argument gets considered: * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * function throwingFirst() { * throw new Error('First'); @@ -649,20 +710,20 @@ declare module 'assert' { * propagated back to the caller. * * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), - * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation * function. See {@link throws} for more details. * * The following, for instance, will throw the `TypeError` because there is no * matching error type in the assertion: * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.doesNotThrow( * () => { * throw new TypeError('Wrong value'); * }, - * SyntaxError + * SyntaxError, * ); * ``` * @@ -670,27 +731,27 @@ declare module 'assert' { * 'Got unwanted exception...': * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.doesNotThrow( * () => { * throw new TypeError('Wrong value'); * }, - * TypeError + * TypeError, * ); * ``` * * If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message: * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.doesNotThrow( * () => { * throw new TypeError('Wrong value'); * }, * /Wrong value/, - * 'Whoops' + * 'Whoops', * ); * // Throws: AssertionError: Got unwanted exception: Whoops * ``` @@ -704,7 +765,7 @@ declare module 'assert' { * from the error passed to `ifError()` including the potential new frames for`ifError()` itself. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.ifError(null); * // OK @@ -750,7 +811,7 @@ declare module 'assert' { * If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * await assert.rejects( * async () => { @@ -758,13 +819,13 @@ declare module 'assert' { * }, * { * name: 'TypeError', - * message: 'Wrong value' - * } + * message: 'Wrong value', + * }, * ); * ``` * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * await assert.rejects( * async () => { @@ -774,16 +835,16 @@ declare module 'assert' { * assert.strictEqual(err.name, 'TypeError'); * assert.strictEqual(err.message, 'Wrong value'); * return true; - * } + * }, * ); * ``` * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.rejects( * Promise.reject(new Error('Wrong value')), - * Error + * Error, * ).then(() => { * // ... * }); @@ -813,24 +874,24 @@ declare module 'assert' { * error messages as expressive as possible. * * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), - * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation * function. See {@link throws} for more details. * * Besides the async nature to await the completion behaves identically to {@link doesNotThrow}. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * await assert.doesNotReject( * async () => { * throw new TypeError('Wrong value'); * }, - * SyntaxError + * SyntaxError, * ); * ``` * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.doesNotReject(Promise.reject(new TypeError('Wrong value'))) * .then(() => { @@ -845,7 +906,7 @@ declare module 'assert' { * Expects the `string` input to match the regular expression. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.match('I will fail', /pass/); * // AssertionError [ERR_ASSERTION]: The input did not match the regular ... @@ -868,7 +929,7 @@ declare module 'assert' { * Expects the `string` input not to match the regular expression. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.doesNotMatch('I will fail', /fail/); * // AssertionError [ERR_ASSERTION]: The input was expected to not match the ... diff --git a/node_modules/@types/node/async_hooks.d.ts b/node_modules/@types/node/async_hooks.d.ts index 0bf473965..e994f02e7 100755 --- a/node_modules/@types/node/async_hooks.d.ts +++ b/node_modules/@types/node/async_hooks.d.ts @@ -1,17 +1,24 @@ /** - * The `async_hooks` module provides an API to track asynchronous resources. It - * can be accessed using: + * We strongly discourage the use of the `async_hooks` API. + * Other APIs that can cover most of its use cases include: + * + * * `AsyncLocalStorage` tracks async context + * * `process.getActiveResourcesInfo()` tracks active resources + * + * The `node:async_hooks` module provides an API to track asynchronous resources. + * It can be accessed using: * * ```js - * import async_hooks from 'async_hooks'; + * import async_hooks from 'node:async_hooks'; * ``` * @experimental - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/async_hooks.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/async_hooks.js) */ declare module 'async_hooks' { /** * ```js - * import { executionAsyncId } from 'async_hooks'; + * import { executionAsyncId } from 'node:async_hooks'; + * import fs from 'node:fs'; * * console.log(executionAsyncId()); // 1 - bootstrap * fs.open(path, 'r', (err, fd) => { @@ -51,8 +58,8 @@ declare module 'async_hooks' { * but having an object representing the top-level can be helpful. * * ```js - * import { open } from 'fs'; - * import { executionAsyncId, executionAsyncResource } from 'async_hooks'; + * import { open } from 'node:fs'; + * import { executionAsyncId, executionAsyncResource } from 'node:async_hooks'; * * console.log(executionAsyncId(), executionAsyncResource()); // 1 {} * open(new URL(import.meta.url), 'r', (err, fd) => { @@ -64,11 +71,11 @@ declare module 'async_hooks' { * use of a tracking `Map` to store the metadata: * * ```js - * import { createServer } from 'http'; + * import { createServer } from 'node:http'; * import { * executionAsyncId, * executionAsyncResource, - * createHook + * createHook, * } from 'async_hooks'; * const sym = Symbol('state'); // Private symbol to avoid pollution * @@ -78,7 +85,7 @@ declare module 'async_hooks' { * if (cr) { * resource[sym] = cr[sym]; * } - * } + * }, * }).enable(); * * const server = createServer((req, res) => { @@ -167,11 +174,11 @@ declare module 'async_hooks' { * specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section. * * ```js - * import { createHook } from 'async_hooks'; + * import { createHook } from 'node:async_hooks'; * * const asyncHook = createHook({ * init(asyncId, type, triggerAsyncId, resource) { }, - * destroy(asyncId) { } + * destroy(asyncId) { }, * }); * ``` * @@ -223,13 +230,13 @@ declare module 'async_hooks' { * The following is an overview of the `AsyncResource` API. * * ```js - * import { AsyncResource, executionAsyncId } from 'async_hooks'; + * import { AsyncResource, executionAsyncId } from 'node:async_hooks'; * * // AsyncResource() is meant to be extended. Instantiating a * // new AsyncResource() also triggers init. If triggerAsyncId is omitted then * // async_hook.executionAsyncId() is used. * const asyncResource = new AsyncResource( - * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false } + * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false }, * ); * * // Run a function in the execution context of the resource. This will @@ -263,33 +270,17 @@ declare module 'async_hooks' { constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions); /** * Binds the given function to the current execution context. - * - * The returned function will have an `asyncResource` property referencing - * the `AsyncResource` to which the function is bound. * @since v14.8.0, v12.19.0 * @param fn The function to bind to the current execution context. * @param type An optional name to associate with the underlying `AsyncResource`. */ - static bind any, ThisArg>( - fn: Func, - type?: string, - thisArg?: ThisArg - ): Func & { - asyncResource: AsyncResource; - }; + static bind any, ThisArg>(fn: Func, type?: string, thisArg?: ThisArg): Func; /** * Binds the given function to execute to this `AsyncResource`'s scope. - * - * The returned function will have an `asyncResource` property referencing - * the `AsyncResource` to which the function is bound. * @since v14.8.0, v12.19.0 * @param fn The function to bind to the current `AsyncResource`. */ - bind any>( - fn: Func - ): Func & { - asyncResource: AsyncResource; - }; + bind any>(fn: Func): Func; /** * Call the provided function with the provided arguments in the execution context * of the async resource. This will establish the context, trigger the AsyncHooks @@ -322,17 +313,17 @@ declare module 'async_hooks' { /** * This class creates stores that stay coherent through asynchronous operations. * - * While you can create your own implementation on top of the `async_hooks` module,`AsyncLocalStorage` should be preferred as it is a performant and memory safe - * implementation that involves significant optimizations that are non-obvious to - * implement. + * While you can create your own implementation on top of the `node:async_hooks`module, `AsyncLocalStorage` should be preferred as it is a performant and memory + * safe implementation that involves significant optimizations that are non-obvious + * to implement. * * The following example uses `AsyncLocalStorage` to build a simple logger * that assigns IDs to incoming HTTP requests and includes them in messages * logged within each request. * * ```js - * import http from 'http'; - * import { AsyncLocalStorage } from 'async_hooks'; + * import http from 'node:http'; + * import { AsyncLocalStorage } from 'node:async_hooks'; * * const asyncLocalStorage = new AsyncLocalStorage(); * @@ -368,6 +359,44 @@ declare module 'async_hooks' { * @since v13.10.0, v12.17.0 */ class AsyncLocalStorage { + /** + * Binds the given function to the current execution context. + * @since v19.8.0 + * @experimental + * @param fn The function to bind to the current execution context. + * @return A new function that calls `fn` within the captured execution context. + */ + static bind any>(fn: Func): Func; + /** + * Captures the current execution context and returns a function that accepts a + * function as an argument. Whenever the returned function is called, it + * calls the function passed to it within the captured context. + * + * ```js + * const asyncLocalStorage = new AsyncLocalStorage(); + * const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot()); + * const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore())); + * console.log(result); // returns 123 + * ``` + * + * AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple + * async context tracking purposes, for example: + * + * ```js + * class Foo { + * #runInAsyncScope = AsyncLocalStorage.snapshot(); + * + * get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); } + * } + * + * const foo = asyncLocalStorage.run(123, () => new Foo()); + * console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123 + * ``` + * @since v19.8.0 + * @experimental + * @return A new function with the signature `(fn: (...args) : R, ...args) : R`. + */ + static snapshot(): (fn: (...args: TArgs) => R, ...args: TArgs) => R; /** * Disables the instance of `AsyncLocalStorage`. All subsequent calls * to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again. diff --git a/node_modules/@types/node/buffer.d.ts b/node_modules/@types/node/buffer.d.ts index 13ab33546..bf537b8a1 100755 --- a/node_modules/@types/node/buffer.d.ts +++ b/node_modules/@types/node/buffer.d.ts @@ -10,7 +10,7 @@ * recommended to explicitly reference it via an import or require statement. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Creates a zero-filled Buffer of length 10. * const buf1 = Buffer.alloc(10); @@ -41,10 +41,29 @@ * // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74]. * const buf7 = Buffer.from('tést', 'latin1'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/buffer.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/buffer.js) */ declare module 'buffer' { import { BinaryLike } from 'node:crypto'; + import { ReadableStream as WebReadableStream } from 'node:stream/web'; + /** + * This function returns `true` if `input` contains only valid UTF-8-encoded data, + * including the case in which `input` is empty. + * + * Throws if the `input` is a detached array buffer. + * @since v19.4.0, v18.14.0 + * @param input The input to validate. + */ + export function isUtf8(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean; + /** + * This function returns `true` if `input` contains only valid ASCII-encoded data, + * including the case in which `input` is empty. + * + * Throws if the `input` is a detached array buffer. + * @since v19.6.0, v18.15.0 + * @param input The input to validate. + */ + export function isAscii(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean; export const INSPECT_MAX_BYTES: number; export const kMaxLength: number; export const kStringMaxLength: number; @@ -66,7 +85,7 @@ declare module 'buffer' { * sequence cannot be adequately represented in the target encoding. For instance: * * ```js - * import { Buffer, transcode } from 'buffer'; + * import { Buffer, transcode } from 'node:buffer'; * * const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii'); * console.log(newBuf.toString('ascii')); @@ -160,13 +179,59 @@ declare module 'buffer' { * Returns a new `ReadableStream` that allows the content of the `Blob` to be read. * @since v16.7.0 */ - stream(): unknown; // pending web streams types + stream(): WebReadableStream; + } + export interface FileOptions { + /** + * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be + * converted to the platform native line-ending as specified by `require('node:os').EOL`. + */ + endings?: 'native' | 'transparent'; + /** The File content-type. */ + type?: string; + /** The last modified date of the file. `Default`: Date.now(). */ + lastModified?: number; + } + /** + * A [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) provides information about files. + * @since v19.2.0, v18.13.0 + */ + export class File extends Blob { + constructor(sources: Array, fileName: string, options?: FileOptions); + /** + * The name of the `File`. + * @since v19.2.0, v18.13.0 + */ + readonly name: string; + /** + * The last modified date of the `File`. + * @since v19.2.0, v18.13.0 + */ + readonly lastModified: number; } export import atob = globalThis.atob; export import btoa = globalThis.btoa; + import { Blob as NodeBlob } from 'buffer'; + // This conditional type will be the existing global Blob in a browser, or + // the copy below in a Node environment. + type __Blob = typeof globalThis extends { onmessage: any; Blob: infer T } ? T : NodeBlob; global { + namespace NodeJS { + export { BufferEncoding }; + } // Buffer class - type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex'; + type BufferEncoding = + | 'ascii' + | 'utf8' + | 'utf-8' + | 'utf16le' + | 'ucs2' + | 'ucs-2' + | 'base64' + | 'base64url' + | 'latin1' + | 'binary' + | 'hex'; type WithImplicitCoercion = | T | { @@ -228,7 +293,7 @@ declare module 'buffer' { * Array entries outside that range will be truncated to fit into it. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'. * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); @@ -240,7 +305,11 @@ declare module 'buffer' { * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does. * @since v5.10.0 */ - from(arrayBuffer: WithImplicitCoercion, byteOffset?: number, length?: number): Buffer; + from( + arrayBuffer: WithImplicitCoercion, + byteOffset?: number, + length?: number, + ): Buffer; /** * Creates a new Buffer using the passed {data} * @param data data to create a new Buffer @@ -258,7 +327,7 @@ declare module 'buffer' { | { [Symbol.toPrimitive](hint: 'string'): string; }, - encoding?: BufferEncoding + encoding?: BufferEncoding, ): Buffer; /** * Creates a new Buffer using the passed {data} @@ -269,7 +338,7 @@ declare module 'buffer' { * Returns `true` if `obj` is a `Buffer`, `false` otherwise. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * Buffer.isBuffer(Buffer.alloc(10)); // true * Buffer.isBuffer(Buffer.from('foo')); // true @@ -285,7 +354,7 @@ declare module 'buffer' { * or `false` otherwise. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * console.log(Buffer.isEncoding('utf8')); * // Prints: true @@ -314,7 +383,7 @@ declare module 'buffer' { * string. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const str = '\u00bd + \u00bc = \u00be'; * @@ -332,7 +401,10 @@ declare module 'buffer' { * @param [encoding='utf8'] If `string` is a string, this is its encoding. * @return The number of bytes contained within `string`. */ - byteLength(string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number; + byteLength( + string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer, + encoding?: BufferEncoding, + ): number; /** * Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together. * @@ -346,7 +418,7 @@ declare module 'buffer' { * truncated to `totalLength`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Create a single `Buffer` from a list of three `Buffer` instances. * @@ -372,11 +444,28 @@ declare module 'buffer' { * @param totalLength Total length of the `Buffer` instances in `list` when concatenated. */ concat(list: ReadonlyArray, totalLength?: number): Buffer; + /** + * Copies the underlying memory of `view` into a new `Buffer`. + * + * ```js + * const u16 = new Uint16Array([0, 0xffff]); + * const buf = Buffer.copyBytesFrom(u16, 1, 1); + * u16[1] = 0; + * console.log(buf.length); // 2 + * console.log(buf[0]); // 255 + * console.log(buf[1]); // 255 + * ``` + * @since v19.8.0 + * @param view The {TypedArray} to copy. + * @param [offset=': 0'] The starting offset within `view`. + * @param [length=view.length - offset] The number of elements from `view` to copy. + */ + copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer; /** * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from('1234'); * const buf2 = Buffer.from('0123'); @@ -394,7 +483,7 @@ declare module 'buffer' { * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.alloc(5); * @@ -402,12 +491,12 @@ declare module 'buffer' { * // Prints: * ``` * - * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown. + * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. * * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.alloc(5, 'a'); * @@ -419,7 +508,7 @@ declare module 'buffer' { * initialized by calling `buf.fill(fill, encoding)`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); * @@ -439,13 +528,13 @@ declare module 'buffer' { */ alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer; /** - * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown. + * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. * * The underlying memory for `Buffer` instances created in this way is _not_ * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(10); * @@ -476,15 +565,15 @@ declare module 'buffer' { */ allocUnsafe(size: number): Buffer; /** - * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown. A zero-length `Buffer` is created - * if `size` is 0. + * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if + * `size` is 0. * * The underlying memory for `Buffer` instances created in this way is _not_ * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize * such `Buffer` instances with zeroes. * * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances, - * allocations under 4 KB are sliced from a single pre-allocated `Buffer`. This + * allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This * allows applications to avoid the garbage collection overhead of creating many * individually allocated `Buffer` instances. This approach improves both * performance and memory usage by eliminating the need to track and clean up as @@ -496,7 +585,7 @@ declare module 'buffer' { * then copying out the relevant bits. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Need to keep around a few small chunks of memory. * const store = []; @@ -534,7 +623,7 @@ declare module 'buffer' { * written. However, partially encoded characters will not be written. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.alloc(256); * @@ -570,7 +659,7 @@ declare module 'buffer' { * as {@link constants.MAX_STRING_LENGTH}. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.allocUnsafe(26); * @@ -607,7 +696,7 @@ declare module 'buffer' { * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]); * const json = JSON.stringify(buf); @@ -634,7 +723,7 @@ declare module 'buffer' { * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from('ABC'); * const buf2 = Buffer.from('414243', 'hex'); @@ -658,7 +747,7 @@ declare module 'buffer' { * * `-1` is returned if `target` should come _after_`buf` when sorted. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from('ABC'); * const buf2 = Buffer.from('BCD'); @@ -682,7 +771,7 @@ declare module 'buffer' { * The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]); * const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]); @@ -703,7 +792,13 @@ declare module 'buffer' { * @param [sourceStart=0] The offset within `buf` at which to begin comparison. * @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive). */ - compare(target: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1; + compare( + target: Uint8Array, + targetStart?: number, + targetEnd?: number, + sourceStart?: number, + sourceEnd?: number, + ): -1 | 0 | 1; /** * Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`. * @@ -712,7 +807,7 @@ declare module 'buffer' { * different function arguments. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Create two `Buffer` instances. * const buf1 = Buffer.allocUnsafe(26); @@ -733,7 +828,7 @@ declare module 'buffer' { * ``` * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Create a `Buffer` and copy data from one region to an overlapping region * // within the same `Buffer`. @@ -766,7 +861,7 @@ declare module 'buffer' { * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('buffer'); * @@ -804,7 +899,7 @@ declare module 'buffer' { * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte * // from the original `Buffer`. @@ -831,7 +926,7 @@ declare module 'buffer' { * end of `buf` rather than the beginning. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('buffer'); * @@ -858,7 +953,7 @@ declare module 'buffer' { * `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -879,7 +974,7 @@ declare module 'buffer' { * `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -900,7 +995,7 @@ declare module 'buffer' { * This function is also available under the `writeBigUint64BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -924,7 +1019,7 @@ declare module 'buffer' { * Writes `value` to `buf` at the specified `offset` as little-endian * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -953,7 +1048,7 @@ declare module 'buffer' { * This function is also available under the `writeUintLE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(6); * @@ -981,7 +1076,7 @@ declare module 'buffer' { * This function is also available under the `writeUintBE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(6); * @@ -1007,7 +1102,7 @@ declare module 'buffer' { * when `value` is anything other than a signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(6); * @@ -1028,7 +1123,7 @@ declare module 'buffer' { * signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(6); * @@ -1050,7 +1145,7 @@ declare module 'buffer' { * This function is also available under the `readBigUint64BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]); * @@ -1072,7 +1167,7 @@ declare module 'buffer' { * This function is also available under the `readBigUint64LE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]); * @@ -1113,7 +1208,7 @@ declare module 'buffer' { * This function is also available under the `readUintLE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); * @@ -1137,7 +1232,7 @@ declare module 'buffer' { * This function is also available under the `readUintBE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); * @@ -1161,7 +1256,7 @@ declare module 'buffer' { * supporting up to 48 bits of accuracy. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); * @@ -1178,7 +1273,7 @@ declare module 'buffer' { * supporting up to 48 bits of accuracy. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); * @@ -1200,7 +1295,7 @@ declare module 'buffer' { * This function is also available under the `readUint8` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([1, -2]); * @@ -1226,7 +1321,7 @@ declare module 'buffer' { * This function is also available under the `readUint16LE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56]); * @@ -1252,7 +1347,7 @@ declare module 'buffer' { * This function is also available under the `readUint16BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56]); * @@ -1276,7 +1371,7 @@ declare module 'buffer' { * This function is also available under the `readUint32LE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); * @@ -1300,7 +1395,7 @@ declare module 'buffer' { * This function is also available under the `readUint32BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); * @@ -1322,7 +1417,7 @@ declare module 'buffer' { * Integers read from a `Buffer` are interpreted as two's complement signed values. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([-1, 5]); * @@ -1343,7 +1438,7 @@ declare module 'buffer' { * Integers read from a `Buffer` are interpreted as two's complement signed values. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0, 5]); * @@ -1362,7 +1457,7 @@ declare module 'buffer' { * Integers read from a `Buffer` are interpreted as two's complement signed values. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0, 5]); * @@ -1379,7 +1474,7 @@ declare module 'buffer' { * Integers read from a `Buffer` are interpreted as two's complement signed values. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0, 0, 0, 5]); * @@ -1398,7 +1493,7 @@ declare module 'buffer' { * Integers read from a `Buffer` are interpreted as two's complement signed values. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0, 0, 0, 5]); * @@ -1413,7 +1508,7 @@ declare module 'buffer' { * Reads a 32-bit, little-endian float from `buf` at the specified `offset`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([1, 2, 3, 4]); * @@ -1430,7 +1525,7 @@ declare module 'buffer' { * Reads a 32-bit, big-endian float from `buf` at the specified `offset`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([1, 2, 3, 4]); * @@ -1445,7 +1540,7 @@ declare module 'buffer' { * Reads a 64-bit, little-endian double from `buf` at the specified `offset`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); * @@ -1462,7 +1557,7 @@ declare module 'buffer' { * Reads a 64-bit, big-endian double from `buf` at the specified `offset`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); * @@ -1479,7 +1574,7 @@ declare module 'buffer' { * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); * @@ -1501,7 +1596,7 @@ declare module 'buffer' { * between UTF-16 little-endian and UTF-16 big-endian: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('This is little-endian UTF-16', 'utf16le'); * buf.swap16(); // Convert to big-endian UTF-16 text. @@ -1515,7 +1610,7 @@ declare module 'buffer' { * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); * @@ -1541,7 +1636,7 @@ declare module 'buffer' { * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); * @@ -1570,7 +1665,7 @@ declare module 'buffer' { * This function is also available under the `writeUint8` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1600,7 +1695,7 @@ declare module 'buffer' { * This function is also available under the `writeUint16LE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1628,7 +1723,7 @@ declare module 'buffer' { * This function is also available under the `writeUint16BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1656,7 +1751,7 @@ declare module 'buffer' { * This function is also available under the `writeUint32LE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1683,7 +1778,7 @@ declare module 'buffer' { * This function is also available under the `writeUint32BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1711,7 +1806,7 @@ declare module 'buffer' { * `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(2); * @@ -1734,7 +1829,7 @@ declare module 'buffer' { * The `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(2); * @@ -1756,7 +1851,7 @@ declare module 'buffer' { * The `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(2); * @@ -1778,7 +1873,7 @@ declare module 'buffer' { * The `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1800,7 +1895,7 @@ declare module 'buffer' { * The `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1820,7 +1915,7 @@ declare module 'buffer' { * undefined when `value` is anything other than a JavaScript number. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1840,7 +1935,7 @@ declare module 'buffer' { * undefined when `value` is anything other than a JavaScript number. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1860,7 +1955,7 @@ declare module 'buffer' { * other than a JavaScript number. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -1880,7 +1975,7 @@ declare module 'buffer' { * other than a JavaScript number. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -1900,7 +1995,7 @@ declare module 'buffer' { * the entire `buf` will be filled: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Fill a `Buffer` with the ASCII character 'h'. * @@ -1908,6 +2003,12 @@ declare module 'buffer' { * * console.log(b.toString()); * // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh + * + * // Fill a buffer with empty string + * const c = Buffer.allocUnsafe(5).fill(''); + * + * console.log(c.fill('')); + * // Prints: * ``` * * `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or @@ -1918,7 +2019,7 @@ declare module 'buffer' { * then only the bytes of that character that fit into `buf` are written: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Fill a `Buffer` with character that takes up two bytes in UTF-8. * @@ -1930,7 +2031,7 @@ declare module 'buffer' { * fill data remains, an exception is thrown: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(5); * @@ -1942,7 +2043,7 @@ declare module 'buffer' { * // Throws an exception. * ``` * @since v0.5.0 - * @param value The value with which to fill `buf`. + * @param value The value with which to fill `buf`. Empty value (string, Uint8Array, Buffer) is coerced to `0`. * @param [offset=0] Number of bytes to skip before starting to fill `buf`. * @param [end=buf.length] Where to stop filling `buf` (not inclusive). * @param [encoding='utf8'] The encoding for `value` if `value` is a string. @@ -1959,7 +2060,7 @@ declare module 'buffer' { * value between `0` and `255`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('this is a buffer'); * @@ -1992,7 +2093,7 @@ declare module 'buffer' { * behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf). * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const b = Buffer.from('abcdef'); * @@ -2023,7 +2124,7 @@ declare module 'buffer' { * rather than the first occurrence. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('this buffer is a buffer'); * @@ -2058,7 +2159,7 @@ declare module 'buffer' { * This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf). * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const b = Buffer.from('abcdef'); * @@ -2091,7 +2192,7 @@ declare module 'buffer' { * of `buf`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Log the entire contents of a `Buffer`. * @@ -2115,7 +2216,7 @@ declare module 'buffer' { * Equivalent to `buf.indexOf() !== -1`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('this is a buffer'); * @@ -2145,7 +2246,7 @@ declare module 'buffer' { * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices). * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('buffer'); * @@ -2168,7 +2269,7 @@ declare module 'buffer' { * called automatically when a `Buffer` is used in a `for..of` statement. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('buffer'); * @@ -2211,7 +2312,7 @@ declare module 'buffer' { * **For code running using Node.js APIs, converting between base64-encoded strings** * **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.** * @since v15.13.0, v14.17.0 - * @deprecated Use `Buffer.from(data, 'base64')` instead. + * @legacy Use `Buffer.from(data, 'base64')` instead. * @param data The Base64-encoded input string. */ function atob(data: string): string; @@ -2227,10 +2328,22 @@ declare module 'buffer' { * **For code running using Node.js APIs, converting between base64-encoded strings** * **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.** * @since v15.13.0, v14.17.0 - * @deprecated Use `buf.toString('base64')` instead. + * @legacy Use `buf.toString('base64')` instead. * @param data An ASCII (Latin1) string. */ function btoa(data: string): string; + interface Blob extends __Blob {} + /** + * `Blob` class is a global reference for `require('node:buffer').Blob` + * https://nodejs.org/api/buffer.html#class-blob + * @since v18.0.0 + */ + var Blob: typeof globalThis extends { + onmessage: any; + Blob: infer T; + } + ? T + : typeof NodeBlob; } } declare module 'node:buffer' { diff --git a/node_modules/@types/node/child_process.d.ts b/node_modules/@types/node/child_process.d.ts index 79c7290e0..771d39da5 100755 --- a/node_modules/@types/node/child_process.d.ts +++ b/node_modules/@types/node/child_process.d.ts @@ -1,10 +1,10 @@ /** - * The `child_process` module provides the ability to spawn subprocesses in + * The `node:child_process` module provides the ability to spawn subprocesses in * a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability * is primarily provided by the {@link spawn} function: * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const ls = spawn('ls', ['-lh', '/usr']); * * ls.stdout.on('data', (data) => { @@ -44,8 +44,8 @@ * without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks * the event loop until the spawned process either exits or is terminated. * - * For convenience, the `child_process` module provides a handful of synchronous - * and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on + * For convenience, the `node:child_process` module provides a handful of + * synchronous and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on * top of {@link spawn} or {@link spawnSync}. * * * {@link exec}: spawns a shell and runs a command within that @@ -63,7 +63,7 @@ * For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however, * the synchronous methods can have significant impact on performance due to * stalling the event loop while spawned processes complete. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/child_process.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/child_process.js) */ declare module 'child_process' { import { ObjectEncodingOptions } from 'node:fs'; @@ -94,8 +94,7 @@ declare module 'child_process' { * `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will * refer to the same value. * - * The `subprocess.stdin` property can be `undefined` if the child process could - * not be successfully spawned. + * The `subprocess.stdin` property can be `null` or `undefined`if the child process could not be successfully spawned. * @since v0.1.90 */ stdin: Writable | null; @@ -109,7 +108,7 @@ declare module 'child_process' { * refer to the same value. * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * * const subprocess = spawn('ls'); * @@ -118,8 +117,7 @@ declare module 'child_process' { * }); * ``` * - * The `subprocess.stdout` property can be `null` if the child process could - * not be successfully spawned. + * The `subprocess.stdout` property can be `null` or `undefined`if the child process could not be successfully spawned. * @since v0.1.90 */ stdout: Readable | null; @@ -132,14 +130,13 @@ declare module 'child_process' { * `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will * refer to the same value. * - * The `subprocess.stderr` property can be `null` if the child process could - * not be successfully spawned. + * The `subprocess.stderr` property can be `null` or `undefined`if the child process could not be successfully spawned. * @since v0.1.90 */ stderr: Readable | null; /** * The `subprocess.channel` property is a reference to the child's IPC channel. If - * no IPC channel currently exists, this property is `undefined`. + * no IPC channel exists, this property is `undefined`. * @since v7.1.0 */ readonly channel?: Pipe | null | undefined; @@ -154,16 +151,16 @@ declare module 'child_process' { * in the array are `null`. * * ```js - * const assert = require('assert'); - * const fs = require('fs'); - * const child_process = require('child_process'); + * const assert = require('node:assert'); + * const fs = require('node:fs'); + * const child_process = require('node:child_process'); * * const subprocess = child_process.spawn('ls', { * stdio: [ * 0, // Use parent's stdin for child. * 'pipe', // Pipe child's stdout to parent. * fs.openSync('err.out', 'w'), // Direct child's stderr to a file. - * ] + * ], * }); * * assert.strictEqual(subprocess.stdio[0], null); @@ -204,7 +201,7 @@ declare module 'child_process' { * emitted. * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const grep = spawn('grep', ['ssh']); * * console.log(`Spawned child pid: ${grep.pid}`); @@ -251,7 +248,7 @@ declare module 'child_process' { * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise. * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const grep = spawn('grep', ['ssh']); * * grep.on('close', (code, signal) => { @@ -284,7 +281,7 @@ declare module 'child_process' { * * ```js * 'use strict'; - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * * const subprocess = spawn( * 'sh', @@ -294,8 +291,8 @@ declare module 'child_process' { * console.log(process.pid, 'is alive') * }, 500);"`, * ], { - * stdio: ['inherit', 'inherit', 'inherit'] - * } + * stdio: ['inherit', 'inherit', 'inherit'], + * }, * ); * * setTimeout(() => { @@ -317,7 +314,7 @@ declare module 'child_process' { * For example, in the parent script: * * ```js - * const cp = require('child_process'); + * const cp = require('node:child_process'); * const n = cp.fork(`${__dirname}/sub.js`); * * n.on('message', (m) => { @@ -371,10 +368,10 @@ declare module 'child_process' { * a TCP server object to the child process as illustrated in the example below: * * ```js - * const subprocess = require('child_process').fork('subprocess.js'); + * const subprocess = require('node:child_process').fork('subprocess.js'); * * // Open up the server object and send the handle. - * const server = require('net').createServer(); + * const server = require('node:net').createServer(); * server.on('connection', (socket) => { * socket.end('handled by parent'); * }); @@ -398,10 +395,9 @@ declare module 'child_process' { * Once the server is now shared between the parent and child, some connections * can be handled by the parent and some by the child. * - * While the example above uses a server created using the `net` module, `dgram`module servers use exactly the same workflow with the exceptions of listening on - * a `'message'` event instead of `'connection'` and using `server.bind()` instead - * of `server.listen()`. This is, however, currently only supported on Unix - * platforms. + * While the example above uses a server created using the `node:net` module,`node:dgram` module servers use exactly the same workflow with the exceptions of + * listening on a `'message'` event instead of `'connection'` and using`server.bind()` instead of `server.listen()`. This is, however, only + * supported on Unix platforms. * * #### Example: sending a socket object * @@ -410,13 +406,13 @@ declare module 'child_process' { * handle connections with "normal" or "special" priority: * * ```js - * const { fork } = require('child_process'); + * const { fork } = require('node:child_process'); * const normal = fork('subprocess.js', ['normal']); * const special = fork('subprocess.js', ['special']); * * // Open up the server and send sockets to child. Use pauseOnConnect to prevent * // the sockets from being read before they are sent to the child process. - * const server = require('net').createServer({ pauseOnConnect: true }); + * const server = require('node:net').createServer({ pauseOnConnect: true }); * server.on('connection', (socket) => { * * // If this is special priority... @@ -482,11 +478,11 @@ declare module 'child_process' { * the child and the parent. * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * * const subprocess = spawn(process.argv[0], ['child_program.js'], { * detached: true, - * stdio: 'ignore' + * stdio: 'ignore', * }); * * subprocess.unref(); @@ -500,11 +496,11 @@ declare module 'child_process' { * to wait for the child to exit before exiting itself. * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * * const subprocess = spawn(process.argv[0], ['child_program.js'], { * detached: true, - * stdio: 'ignore' + * stdio: 'ignore', * }); * * subprocess.unref(); @@ -624,7 +620,7 @@ declare module 'child_process' { } interface CommonOptions extends ProcessEnvOptions { /** - * @default true + * @default false */ windowsHide?: boolean | undefined; /** @@ -634,6 +630,15 @@ declare module 'child_process' { } interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable { argv0?: string | undefined; + /** + * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ stdio?: StdioOptions | undefined; shell?: boolean | string | undefined; windowsVerbatimArguments?: boolean | undefined; @@ -663,7 +668,7 @@ declare module 'child_process' { * ```js * const defaults = { * cwd: undefined, - * env: process.env + * env: process.env, * }; * ``` * @@ -682,7 +687,7 @@ declare module 'child_process' { * exit code: * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const ls = spawn('ls', ['-lh', '/usr']); * * ls.stdout.on('data', (data) => { @@ -701,7 +706,7 @@ declare module 'child_process' { * Example: A very elaborate way to run `ps ax | grep ssh` * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const ps = spawn('ps', ['ax']); * const grep = spawn('grep', ['ssh']); * @@ -738,7 +743,7 @@ declare module 'child_process' { * Example of checking for failed `spawn`: * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const subprocess = spawn('bad_command'); * * subprocess.on('error', (err) => { @@ -749,14 +754,14 @@ declare module 'child_process' { * Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process * title while others (Windows, SunOS) will use `command`. * - * Node.js currently overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent, - * retrieve it with the`process.argv0` property instead. + * Node.js overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent. Retrieve + * it with the`process.argv0` property instead. * * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except * the error passed to the callback will be an `AbortError`: * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const controller = new AbortController(); * const { signal } = controller; * const grep = spawn('grep', ['ssh'], { signal }); @@ -815,7 +820,7 @@ declare module 'child_process' { * need to be dealt with accordingly: * * ```js - * const { exec } = require('child_process'); + * const { exec } = require('node:child_process'); * * exec('"/path/to/test file/test.sh" arg1 arg2'); * // Double quotes are used so that the space in the path is not interpreted as @@ -841,7 +846,7 @@ declare module 'child_process' { * encoding, `Buffer` objects will be passed to the callback instead. * * ```js - * const { exec } = require('child_process'); + * const { exec } = require('node:child_process'); * exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => { * if (error) { * console.error(`exec error: ${error}`); @@ -866,8 +871,8 @@ declare module 'child_process' { * callback, but with two additional properties `stdout` and `stderr`. * * ```js - * const util = require('util'); - * const exec = util.promisify(require('child_process').exec); + * const util = require('node:util'); + * const exec = util.promisify(require('node:child_process').exec); * * async function lsExample() { * const { stdout, stderr } = await exec('ls'); @@ -881,11 +886,11 @@ declare module 'child_process' { * the error passed to the callback will be an `AbortError`: * * ```js - * const { exec } = require('child_process'); + * const { exec } = require('node:child_process'); * const controller = new AbortController(); * const { signal } = controller; * const child = exec('grep ssh', { signal }, (error) => { - * console.log(error); // an AbortError + * console.error(error); // an AbortError * }); * controller.abort(); * ``` @@ -984,7 +989,10 @@ declare module 'child_process' { interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions { encoding: BufferEncoding; } - type ExecFileException = ExecException & NodeJS.ErrnoException; + type ExecFileException = + & Omit + & Omit + & { code?: string | number | undefined | null }; /** * The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified * executable `file` is spawned directly as a new process making it slightly more @@ -995,7 +1003,7 @@ declare module 'child_process' { * supported. * * ```js - * const { execFile } = require('child_process'); + * const { execFile } = require('node:child_process'); * const child = execFile('node', ['--version'], (error, stdout, stderr) => { * if (error) { * throw error; @@ -1018,8 +1026,8 @@ declare module 'child_process' { * callback, but with two additional properties `stdout` and `stderr`. * * ```js - * const util = require('util'); - * const execFile = util.promisify(require('child_process').execFile); + * const util = require('node:util'); + * const execFile = util.promisify(require('node:child_process').execFile); * async function getVersion() { * const { stdout } = await execFile('node', ['--version']); * console.log(stdout); @@ -1035,11 +1043,11 @@ declare module 'child_process' { * the error passed to the callback will be an `AbortError`: * * ```js - * const { execFile } = require('child_process'); + * const { execFile } = require('node:child_process'); * const controller = new AbortController(); * const { signal } = controller; * const child = execFile('node', ['--version'], { signal }, (error) => { - * console.log(error); // an AbortError + * console.error(error); // an AbortError * }); * controller.abort(); * ``` @@ -1192,6 +1200,15 @@ declare module 'child_process' { execPath?: string | undefined; execArgv?: string[] | undefined; silent?: boolean | undefined; + /** + * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ stdio?: StdioOptions | undefined; detached?: boolean | undefined; windowsVerbatimArguments?: boolean | undefined; @@ -1231,7 +1248,7 @@ declare module 'child_process' { * console.log(`Hello from ${process.argv[2]}!`); * }, 1_000); * } else { - * const { fork } = require('child_process'); + * const { fork } = require('node:child_process'); * const controller = new AbortController(); * const { signal } = controller; * const child = fork(__filename, ['child'], { signal }); @@ -1292,6 +1309,15 @@ declare module 'child_process' { function spawnSync(command: string, args?: ReadonlyArray, options?: SpawnSyncOptions): SpawnSyncReturns; interface CommonExecOptions extends CommonOptions { input?: string | NodeJS.ArrayBufferView | undefined; + /** + * Can be set to 'pipe', 'inherit, or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ stdio?: StdioOptions | undefined; killSignal?: NodeJS.Signals | number | undefined; maxBuffer?: number | undefined; diff --git a/node_modules/@types/node/cluster.d.ts b/node_modules/@types/node/cluster.d.ts index 37dbc5746..6ee517720 100755 --- a/node_modules/@types/node/cluster.d.ts +++ b/node_modules/@types/node/cluster.d.ts @@ -8,12 +8,12 @@ * server ports. * * ```js - * import cluster from 'cluster'; - * import http from 'http'; - * import { cpus } from 'os'; - * import process from 'process'; + * import cluster from 'node:cluster'; + * import http from 'node:http'; + * import { availableParallelism } from 'node:os'; + * import process from 'node:process'; * - * const numCPUs = cpus().length; + * const numCPUs = availableParallelism(); * * if (cluster.isPrimary) { * console.log(`Primary ${process.pid} is running`); @@ -50,7 +50,7 @@ * ``` * * On Windows, it is not yet possible to set up a named pipe server in a worker. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/cluster.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/cluster.js) */ declare module 'cluster' { import * as child from 'node:child_process'; @@ -183,7 +183,7 @@ declare module 'cluster' { * }); * * } else if (cluster.isWorker) { - * const net = require('net'); + * const net = require('node:net'); * const server = net.createServer((socket) => { * // Connections never end * }); @@ -213,12 +213,12 @@ declare module 'cluster' { * because of exiting or being signaled). Otherwise, it returns `false`. * * ```js - * import cluster from 'cluster'; - * import http from 'http'; - * import { cpus } from 'os'; - * import process from 'process'; + * import cluster from 'node:cluster'; + * import http from 'node:http'; + * import { availableParallelism } from 'node:os'; + * import process from 'node:process'; * - * const numCPUs = cpus().length; + * const numCPUs = availableParallelism(); * * if (cluster.isPrimary) { * console.log(`Primary ${process.pid} is running`); diff --git a/node_modules/@types/node/console.d.ts b/node_modules/@types/node/console.d.ts index 16c9137ad..7e35638df 100755 --- a/node_modules/@types/node/console.d.ts +++ b/node_modules/@types/node/console.d.ts @@ -1,11 +1,11 @@ /** - * The `console` module provides a simple debugging console that is similar to the - * JavaScript console mechanism provided by web browsers. + * The `node:console` module provides a simple debugging console that is similar to + * the JavaScript console mechanism provided by web browsers. * * The module exports two specific components: * - * * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream. - * * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`. + * * A `Console` class with methods such as `console.log()`, `console.error()`, and`console.warn()` that can be used to write to any Node.js stream. + * * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('node:console')`. * * _**Warning**_: The global console object's methods are neither consistently * synchronous like the browser APIs they resemble, nor are they consistently @@ -53,7 +53,7 @@ * myConsole.warn(`Danger ${name}! Danger!`); * // Prints: Danger Will Robinson! Danger!, to err * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/console.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/console.js) */ declare module 'console' { import console = require('node:console'); diff --git a/node_modules/@types/node/crypto.d.ts b/node_modules/@types/node/crypto.d.ts index 6135090b0..9d5a27266 100755 --- a/node_modules/@types/node/crypto.d.ts +++ b/node_modules/@types/node/crypto.d.ts @@ -1,9 +1,10 @@ /** - * The `crypto` module provides cryptographic functionality that includes a set of - * wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions. + * The `node:crypto` module provides cryptographic functionality that includes a + * set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify + * functions. * * ```js - * const { createHmac } = await import('crypto'); + * const { createHmac } = await import('node:crypto'); * * const secret = 'abcdefg'; * const hash = createHmac('sha256', secret) @@ -13,7 +14,7 @@ * // Prints: * // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/crypto.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/crypto.js) */ declare module 'crypto' { import * as stream from 'node:stream'; @@ -25,7 +26,7 @@ declare module 'crypto' { * `` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects * should not use this element anymore. * - * The `crypto` module provides the `Certificate` class for working with SPKAC + * The `node:crypto` module provides the `Certificate` class for working with SPKAC * data. The most common usage is handling output generated by the HTML5`` element. Node.js uses [OpenSSL's SPKAC * implementation](https://www.openssl.org/docs/man1.1.0/apps/openssl-spkac.html) internally. * @since v0.11.8 @@ -33,7 +34,7 @@ declare module 'crypto' { class Certificate { /** * ```js - * const { Certificate } = await import('crypto'); + * const { Certificate } = await import('node:crypto'); * const spkac = getSpkacSomehow(); * const challenge = Certificate.exportChallenge(spkac); * console.log(challenge.toString('utf8')); @@ -46,7 +47,7 @@ declare module 'crypto' { static exportChallenge(spkac: BinaryLike): Buffer; /** * ```js - * const { Certificate } = await import('crypto'); + * const { Certificate } = await import('node:crypto'); * const spkac = getSpkacSomehow(); * const publicKey = Certificate.exportPublicKey(spkac); * console.log(publicKey); @@ -59,8 +60,8 @@ declare module 'crypto' { static exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer; /** * ```js - * import { Buffer } from 'buffer'; - * const { Certificate } = await import('crypto'); + * import { Buffer } from 'node:buffer'; + * const { Certificate } = await import('node:crypto'); * * const spkac = getSpkacSomehow(); * console.log(Certificate.verifySpkac(Buffer.from(spkac))); @@ -95,7 +96,7 @@ declare module 'crypto' { verifySpkac(spkac: NodeJS.ArrayBufferView): boolean; } namespace constants { - // https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants + // https://nodejs.org/dist/latest-v20.x/docs/api/crypto.html#crypto-constants const OPENSSL_VERSION_NUMBER: number; /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */ const SSL_OP_ALL: number; @@ -111,18 +112,8 @@ declare module 'crypto' { const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; /** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */ const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; - /** Instructs OpenSSL to always use the tmp_rsa key when performing RSA operations. */ - const SSL_OP_EPHEMERAL_RSA: number; /** Allows initial connection to servers that do not support RI. */ const SSL_OP_LEGACY_SERVER_CONNECT: number; - const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; - const SSL_OP_MICROSOFT_SESS_ID_BUG: number; - /** Instructs OpenSSL to disable the workaround for a man-in-the-middle protocol-version vulnerability in the SSL 2.0 server implementation. */ - const SSL_OP_MSIE_SSLV2_RSA_PADDING: number; - const SSL_OP_NETSCAPE_CA_DN_BUG: number; - const SSL_OP_NETSCAPE_CHALLENGE_BUG: number; - const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; - const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; /** Instructs OpenSSL to disable support for SSL/TLS compression. */ const SSL_OP_NO_COMPRESSION: number; const SSL_OP_NO_QUERY_MTU: number; @@ -134,16 +125,6 @@ declare module 'crypto' { const SSL_OP_NO_TLSv1: number; const SSL_OP_NO_TLSv1_1: number; const SSL_OP_NO_TLSv1_2: number; - const SSL_OP_PKCS1_CHECK_1: number; - const SSL_OP_PKCS1_CHECK_2: number; - /** Instructs OpenSSL to always create a new key when using temporary/ephemeral DH parameters. */ - const SSL_OP_SINGLE_DH_USE: number; - /** Instructs OpenSSL to always create a new key when using temporary/ephemeral ECDH parameters. */ - const SSL_OP_SINGLE_ECDH_USE: number; - const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; - const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; - const SSL_OP_TLS_BLOCK_PADDING_BUG: number; - const SSL_OP_TLS_D5_BUG: number; /** Instructs OpenSSL to disable version rollback attack detection. */ const SSL_OP_TLS_ROLLBACK_BUG: number; const ENGINE_METHOD_RSA: number; @@ -161,7 +142,6 @@ declare module 'crypto' { const DH_CHECK_P_NOT_PRIME: number; const DH_UNABLE_TO_CHECK_GENERATOR: number; const DH_NOT_SUITABLE_GENERATOR: number; - const ALPN_ENABLED: number; const RSA_PKCS1_PADDING: number; const RSA_SSLV23_PADDING: number; const RSA_NO_PADDING: number; @@ -206,12 +186,12 @@ declare module 'crypto' { * * ```js * import { - * createReadStream - * } from 'fs'; - * import { argv } from 'process'; + * createReadStream, + * } from 'node:fs'; + * import { argv } from 'node:process'; * const { - * createHash - * } = await import('crypto'); + * createHash, + * } = await import('node:crypto'); * * const filename = argv[2]; * @@ -249,12 +229,12 @@ declare module 'crypto' { * * ```js * import { - * createReadStream - * } from 'fs'; - * import { argv } from 'process'; + * createReadStream, + * } from 'node:fs'; + * import { argv } from 'node:process'; * const { - * createHmac - * } = await import('crypto'); + * createHmac, + * } = await import('node:crypto'); * * const filename = argv[2]; * @@ -297,8 +277,8 @@ declare module 'crypto' { * * ```js * const { - * createHash - * } = await import('crypto'); + * createHash, + * } = await import('node:crypto'); * * const hash = createHash('sha256'); * @@ -320,9 +300,9 @@ declare module 'crypto' { * Example: Using `Hash` and piped streams: * * ```js - * import { createReadStream } from 'fs'; - * import { stdout } from 'process'; - * const { createHash } = await import('crypto'); + * import { createReadStream } from 'node:fs'; + * import { stdout } from 'node:process'; + * const { createHash } = await import('node:crypto'); * * const hash = createHash('sha256'); * @@ -334,8 +314,8 @@ declare module 'crypto' { * * ```js * const { - * createHash - * } = await import('crypto'); + * createHash, + * } = await import('node:crypto'); * * const hash = createHash('sha256'); * @@ -362,8 +342,8 @@ declare module 'crypto' { * ```js * // Calculate a rolling hash. * const { - * createHash - * } = await import('crypto'); + * createHash, + * } = await import('node:crypto'); * * const hash = createHash('sha256'); * @@ -422,8 +402,8 @@ declare module 'crypto' { * * ```js * const { - * createHmac - * } = await import('crypto'); + * createHmac, + * } = await import('node:crypto'); * * const hmac = createHmac('sha256', 'a secret'); * @@ -445,11 +425,11 @@ declare module 'crypto' { * Example: Using `Hmac` and piped streams: * * ```js - * import { createReadStream } from 'fs'; - * import { stdout } from 'process'; + * import { createReadStream } from 'node:fs'; + * import { stdout } from 'node:process'; * const { - * createHmac - * } = await import('crypto'); + * createHmac, + * } = await import('node:crypto'); * * const hmac = createHmac('sha256', 'a secret'); * @@ -461,8 +441,8 @@ declare module 'crypto' { * * ```js * const { - * createHmac - * } = await import('crypto'); + * createHmac, + * } = await import('node:crypto'); * * const hmac = createHmac('sha256', 'a secret'); * @@ -575,13 +555,13 @@ declare module 'crypto' { * Example: Converting a `CryptoKey` instance to a `KeyObject`: * * ```js - * const { webcrypto, KeyObject } = await import('crypto'); - * const { subtle } = webcrypto; + * const { KeyObject } = await import('node:crypto'); + * const { subtle } = globalThis.crypto; * * const key = await subtle.generateKey({ * name: 'HMAC', * hash: 'SHA-256', - * length: 256 + * length: 256, * }, true, ['sign', 'verify']); * * const keyObject = KeyObject.from(key); @@ -698,6 +678,10 @@ declare module 'crypto' { * The `password` is used to derive the cipher key and initialization vector (IV). * The value must be either a `'latin1'` encoded string, a `Buffer`, a`TypedArray`, or a `DataView`. * + * **This function is semantically insecure for all** + * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,** + * **GCM, or CCM).** + * * The implementation of `crypto.createCipher()` derives keys using the OpenSSL * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one * iteration, and no salt. The lack of salt allows dictionary attacks as the same @@ -773,8 +757,8 @@ declare module 'crypto' { * const { * scrypt, * randomFill, - * createCipheriv - * } = await import('crypto'); + * createCipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -808,17 +792,17 @@ declare module 'crypto' { * import { * createReadStream, * createWriteStream, - * } from 'fs'; + * } from 'node:fs'; * * import { - * pipeline - * } from 'stream'; + * pipeline, + * } from 'node:stream'; * * const { * scrypt, * randomFill, - * createCipheriv - * } = await import('crypto'); + * createCipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -849,8 +833,8 @@ declare module 'crypto' { * const { * scrypt, * randomFill, - * createCipheriv - * } = await import('crypto'); + * createCipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -955,6 +939,10 @@ declare module 'crypto' { * authentication tag in bytes, see `CCM mode`. * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes. * + * **This function is semantically insecure for all** + * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,** + * **GCM, or CCM).** + * * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one * iteration, and no salt. The lack of salt allows dictionary attacks as the same @@ -1023,11 +1011,11 @@ declare module 'crypto' { * Example: Using `Decipher` objects as streams: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * const { * scryptSync, - * createDecipheriv - * } = await import('crypto'); + * createDecipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -1042,6 +1030,7 @@ declare module 'crypto' { * * let decrypted = ''; * decipher.on('readable', () => { + * let chunk; * while (null !== (chunk = decipher.read())) { * decrypted += chunk.toString('utf8'); * } @@ -1064,12 +1053,12 @@ declare module 'crypto' { * import { * createReadStream, * createWriteStream, - * } from 'fs'; - * import { Buffer } from 'buffer'; + * } from 'node:fs'; + * import { Buffer } from 'node:buffer'; * const { * scryptSync, - * createDecipheriv - * } = await import('crypto'); + * createDecipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -1089,11 +1078,11 @@ declare module 'crypto' { * Example: Using the `decipher.update()` and `decipher.final()` methods: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * const { * scryptSync, - * createDecipheriv - * } = await import('crypto'); + * createDecipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -1190,19 +1179,21 @@ declare module 'crypto' { format?: KeyFormat | undefined; type?: 'pkcs1' | 'pkcs8' | 'sec1' | undefined; passphrase?: string | Buffer | undefined; + encoding?: string | undefined; } interface PublicKeyInput { key: string | Buffer; format?: KeyFormat | undefined; type?: 'pkcs1' | 'spki' | undefined; + encoding?: string | undefined; } /** * Asynchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`. * * ```js * const { - * generateKey - * } = await import('crypto'); + * generateKey, + * } = await import('node:crypto'); * * generateKey('hmac', { length: 64 }, (err, key) => { * if (err) throw err; @@ -1224,8 +1215,8 @@ declare module 'crypto' { * * ```js * const { - * generateKeySync - * } = await import('crypto'); + * generateKeySync, + * } = await import('node:crypto'); * * const key = generateKeySync('hmac', { length: 64 }); * console.log(key.export().toString('hex')); // e89..........41e @@ -1291,7 +1282,7 @@ declare module 'crypto' { type DSAEncoding = 'der' | 'ieee-p1363'; interface SigningOptions { /** - * @See crypto.constants.RSA_PKCS1_PADDING + * @see crypto.constants.RSA_PKCS1_PADDING */ padding?: number | undefined; saltLength?: number | undefined; @@ -1305,6 +1296,7 @@ declare module 'crypto' { interface VerifyKeyObjectInput extends SigningOptions { key: KeyObject; } + interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {} type KeyLike = string | Buffer | KeyObject; /** * The `Sign` class is a utility for generating signatures. It can be used in one @@ -1324,11 +1316,11 @@ declare module 'crypto' { * const { * generateKeyPairSync, * createSign, - * createVerify - * } = await import('crypto'); + * createVerify, + * } = await import('node:crypto'); * * const { privateKey, publicKey } = generateKeyPairSync('ec', { - * namedCurve: 'sect239k1' + * namedCurve: 'sect239k1', * }); * * const sign = createSign('SHA256'); @@ -1349,8 +1341,8 @@ declare module 'crypto' { * const { * generateKeyPairSync, * createSign, - * createVerify - * } = await import('crypto'); + * createVerify, + * } = await import('node:crypto'); * * const { privateKey, publicKey } = generateKeyPairSync('rsa', { * modulusLength: 2048, @@ -1459,8 +1451,8 @@ declare module 'crypto' { * be passed instead of a public key. * @since v0.1.92 */ - verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean; - verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean; + verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView): boolean; + verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean; } /** * Creates a `DiffieHellman` key exchange object using the supplied `prime` and an @@ -1490,11 +1482,11 @@ declare module 'crypto' { * Instances of the `DiffieHellman` class can be created using the {@link createDiffieHellman} function. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * const { - * createDiffieHellman - * } = await import('crypto'); + * createDiffieHellman, + * } = await import('node:crypto'); * * // Generate Alice's keys... * const alice = createDiffieHellman(2048); @@ -1600,7 +1592,7 @@ declare module 'crypto' { * A bit field containing any warnings and/or errors resulting from a check * performed during initialization of the `DiffieHellman` object. * - * The following values are valid for this property (as defined in `constants`module): + * The following values are valid for this property (as defined in `node:constants` module): * * * `DH_CHECK_P_NOT_SAFE_PRIME` * * `DH_CHECK_P_NOT_PRIME` @@ -1635,16 +1627,16 @@ declare module 'crypto' { */ const DiffieHellmanGroup: DiffieHellmanGroupConstructor; interface DiffieHellmanGroupConstructor { - new(name: string): DiffieHellmanGroup; + new (name: string): DiffieHellmanGroup; (name: string): DiffieHellmanGroup; readonly prototype: DiffieHellmanGroup; } type DiffieHellmanGroup = Omit; /** * Creates a predefined `DiffieHellmanGroup` key exchange object. The - * supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in [RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt), but see `Caveats`) and `'modp14'`, `'modp15'`,`'modp16'`, `'modp17'`, - * `'modp18'` (defined in [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt)). The - * returned object mimics the interface of objects created by {@link createDiffieHellman}, but will not allow changing + * supported groups are listed in the documentation for `DiffieHellmanGroup`. + * + * The returned object mimics the interface of objects created by {@link createDiffieHellman}, but will not allow changing * the keys (with `diffieHellman.setPublicKey()`, for example). The * advantage of using this method is that the parties do not have to * generate nor exchange a group modulus beforehand, saving both processor @@ -1654,8 +1646,8 @@ declare module 'crypto' { * * ```js * const { - * getDiffieHellman - * } = await import('crypto'); + * getDiffieHellman, + * } = await import('node:crypto'); * const alice = getDiffieHellman('modp14'); * const bob = getDiffieHellman('modp14'); * @@ -1685,9 +1677,6 @@ declare module 'crypto' { * otherwise `err` will be `null`. By default, the successfully generated`derivedKey` will be passed to the callback as a `Buffer`. An error will be * thrown if any of the input arguments specify invalid values or types. * - * If `digest` is `null`, `'sha1'` will be used. This behavior is deprecated, - * please specify a `digest` explicitly. - * * The `iterations` argument must be a number set as high as possible. The * higher the number of iterations, the more secure the derived key will be, * but will take a longer amount of time to complete. @@ -1699,8 +1688,8 @@ declare module 'crypto' { * * ```js * const { - * pbkdf2 - * } = await import('crypto'); + * pbkdf2, + * } = await import('node:crypto'); * * pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => { * if (err) throw err; @@ -1708,18 +1697,6 @@ declare module 'crypto' { * }); * ``` * - * The `crypto.DEFAULT_ENCODING` property can be used to change the way the`derivedKey` is passed to the callback. This property, however, has been - * deprecated and use should be avoided. - * - * ```js - * import crypto from 'crypto'; - * crypto.DEFAULT_ENCODING = 'hex'; - * crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, derivedKey) => { - * if (err) throw err; - * console.log(derivedKey); // '3745e48...aa39b34' - * }); - * ``` - * * An array of supported digest functions can be retrieved using {@link getHashes}. * * This API uses libuv's threadpool, which can have surprising and @@ -1735,9 +1712,6 @@ declare module 'crypto' { * If an error occurs an `Error` will be thrown, otherwise the derived key will be * returned as a `Buffer`. * - * If `digest` is `null`, `'sha1'` will be used. This behavior is deprecated, - * please specify a `digest` explicitly. - * * The `iterations` argument must be a number set as high as possible. The * higher the number of iterations, the more secure the derived key will be, * but will take a longer amount of time to complete. @@ -1749,23 +1723,13 @@ declare module 'crypto' { * * ```js * const { - * pbkdf2Sync - * } = await import('crypto'); + * pbkdf2Sync, + * } = await import('node:crypto'); * * const key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512'); * console.log(key.toString('hex')); // '3745e48...08d59ae' * ``` * - * The `crypto.DEFAULT_ENCODING` property may be used to change the way the`derivedKey` is returned. This property, however, is deprecated and use - * should be avoided. - * - * ```js - * import crypto from 'crypto'; - * crypto.DEFAULT_ENCODING = 'hex'; - * const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 512, 'sha512'); - * console.log(key); // '3745e48...aa39b34' - * ``` - * * An array of supported digest functions can be retrieved using {@link getHashes}. * @since v0.9.3 */ @@ -1781,8 +1745,8 @@ declare module 'crypto' { * ```js * // Asynchronous * const { - * randomBytes - * } = await import('crypto'); + * randomBytes, + * } = await import('node:crypto'); * * randomBytes(256, (err, buf) => { * if (err) throw err; @@ -1797,8 +1761,8 @@ declare module 'crypto' { * ```js * // Synchronous * const { - * randomBytes - * } = await import('crypto'); + * randomBytes, + * } = await import('node:crypto'); * * const buf = randomBytes(256); * console.log( @@ -1839,8 +1803,8 @@ declare module 'crypto' { * ```js * // Asynchronous * const { - * randomInt - * } = await import('crypto'); + * randomInt, + * } = await import('node:crypto'); * * randomInt(3, (err, n) => { * if (err) throw err; @@ -1851,8 +1815,8 @@ declare module 'crypto' { * ```js * // Synchronous * const { - * randomInt - * } = await import('crypto'); + * randomInt, + * } = await import('node:crypto'); * * const n = randomInt(3); * console.log(`Random number chosen from (0, 1, 2): ${n}`); @@ -1861,8 +1825,8 @@ declare module 'crypto' { * ```js * // With `min` argument * const { - * randomInt - * } = await import('crypto'); + * randomInt, + * } = await import('node:crypto'); * * const n = randomInt(1, 7); * console.log(`The dice rolled: ${n}`); @@ -1880,8 +1844,8 @@ declare module 'crypto' { * Synchronous version of {@link randomFill}. * * ```js - * import { Buffer } from 'buffer'; - * const { randomFillSync } = await import('crypto'); + * import { Buffer } from 'node:buffer'; + * const { randomFillSync } = await import('node:crypto'); * * const buf = Buffer.alloc(10); * console.log(randomFillSync(buf).toString('hex')); @@ -1897,8 +1861,8 @@ declare module 'crypto' { * Any `ArrayBuffer`, `TypedArray` or `DataView` instance may be passed as`buffer`. * * ```js - * import { Buffer } from 'buffer'; - * const { randomFillSync } = await import('crypto'); + * import { Buffer } from 'node:buffer'; + * const { randomFillSync } = await import('node:crypto'); * * const a = new Uint32Array(10); * console.log(Buffer.from(randomFillSync(a).buffer, @@ -1926,8 +1890,8 @@ declare module 'crypto' { * If the `callback` function is not provided, an error will be thrown. * * ```js - * import { Buffer } from 'buffer'; - * const { randomFill } = await import('crypto'); + * import { Buffer } from 'node:buffer'; + * const { randomFill } = await import('node:crypto'); * * const buf = Buffer.alloc(10); * randomFill(buf, (err, buf) => { @@ -1956,8 +1920,8 @@ declare module 'crypto' { * distribution and have no meaningful lower or upper bounds. * * ```js - * import { Buffer } from 'buffer'; - * const { randomFill } = await import('crypto'); + * import { Buffer } from 'node:buffer'; + * const { randomFill } = await import('node:crypto'); * * const a = new Uint32Array(10); * randomFill(a, (err, buf) => { @@ -2023,8 +1987,8 @@ declare module 'crypto' { * * ```js * const { - * scrypt - * } = await import('crypto'); + * scrypt, + * } = await import('node:crypto'); * * // Using the factory defaults. * scrypt('password', 'salt', 64, (err, derivedKey) => { @@ -2059,8 +2023,8 @@ declare module 'crypto' { * * ```js * const { - * scryptSync - * } = await import('crypto'); + * scryptSync, + * } = await import('node:crypto'); * // Using the factory defaults. * * const key1 = scryptSync('password', 'salt', 64); @@ -2131,8 +2095,8 @@ declare module 'crypto' { /** * ```js * const { - * getCiphers - * } = await import('crypto'); + * getCiphers, + * } = await import('node:crypto'); * * console.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...] * ``` @@ -2143,8 +2107,8 @@ declare module 'crypto' { /** * ```js * const { - * getCurves - * } = await import('crypto'); + * getCurves, + * } = await import('node:crypto'); * * console.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...] * ``` @@ -2158,7 +2122,8 @@ declare module 'crypto' { */ function getFips(): 1 | 0; /** - * Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build. Throws an error if FIPS mode is not available. + * Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build. + * Throws an error if FIPS mode is not available. * @since v10.0.0 * @param bool `true` to enable FIPS mode. */ @@ -2166,8 +2131,8 @@ declare module 'crypto' { /** * ```js * const { - * getHashes - * } = await import('crypto'); + * getHashes, + * } = await import('node:crypto'); * * console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...] * ``` @@ -2182,11 +2147,11 @@ declare module 'crypto' { * Instances of the `ECDH` class can be created using the {@link createECDH} function. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * const { - * createECDH - * } = await import('crypto'); + * createECDH, + * } = await import('node:crypto'); * * // Generate Alice's keys... * const alice = createECDH('secp521r1'); @@ -2227,8 +2192,8 @@ declare module 'crypto' { * ```js * const { * createECDH, - * ECDH - * } = await import('crypto'); + * ECDH, + * } = await import('node:crypto'); * * const ecdh = createECDH('secp256k1'); * ecdh.generateKeys(); @@ -2306,7 +2271,7 @@ declare module 'crypto' { * If `encoding` is specified, a string is returned; otherwise a `Buffer` is * returned. * @since v0.11.14 - * @param [encoding] The `encoding` of the return value. + * @param encoding The `encoding` of the return value. * @param [format='uncompressed'] * @return The EC Diffie-Hellman public key in the specified `encoding` and `format`. */ @@ -2335,8 +2300,10 @@ declare module 'crypto' { */ function createECDH(curveName: string): ECDH; /** - * This function is based on a constant-time algorithm. - * Returns true if `a` is equal to `b`, without leaking timing information that + * This function compares the underlying bytes that represent the given`ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time + * algorithm. + * + * This function does not leak timing information that * would allow an attacker to guess one of the values. This is suitable for * comparing HMAC digests or secret values like authentication cookies or [capability urls](https://www.w3.org/TR/capability-urls/). * @@ -2348,16 +2315,18 @@ declare module 'crypto' { * entry, such as `Uint16Array`, the result will be computed using the platform * byte order. * + * **When both of the inputs are `Float32Array`s or`Float64Array`s, this function might return unexpected results due to IEEE 754** + * **encoding of floating-point numbers. In particular, neither `x === y` nor`Object.is(x, y)` implies that the byte representations of two floating-point** + * **numbers `x` and `y` are equal.** + * * Use of `crypto.timingSafeEqual` does not guarantee that the _surrounding_ code * is timing-safe. Care should be taken to ensure that the surrounding code does * not introduce timing vulnerabilities. * @since v6.6.0 */ function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean; - /** @deprecated since v10.0.0 */ - const DEFAULT_ENCODING: BufferEncoding; type KeyType = 'rsa' | 'rsa-pss' | 'dsa' | 'ec' | 'ed25519' | 'ed448' | 'x25519' | 'x448'; - type KeyFormat = 'pem' | 'der'; + type KeyFormat = 'pem' | 'der' | 'jwk'; interface BasePrivateKeyEncodingOptions { format: T; cipher?: string | undefined; @@ -2553,8 +2522,8 @@ declare module 'crypto' { * * ```js * const { - * generateKeyPairSync - * } = await import('crypto'); + * generateKeyPairSync, + * } = await import('node:crypto'); * * const { * publicKey, @@ -2563,14 +2532,14 @@ declare module 'crypto' { * modulusLength: 4096, * publicKeyEncoding: { * type: 'spki', - * format: 'pem' + * format: 'pem', * }, * privateKeyEncoding: { * type: 'pkcs8', * format: 'pem', * cipher: 'aes-256-cbc', - * passphrase: 'top secret' - * } + * passphrase: 'top secret', + * }, * }); * ``` * @@ -2632,21 +2601,21 @@ declare module 'crypto' { * * ```js * const { - * generateKeyPair - * } = await import('crypto'); + * generateKeyPair, + * } = await import('node:crypto'); * * generateKeyPair('rsa', { * modulusLength: 4096, * publicKeyEncoding: { * type: 'spki', - * format: 'pem' + * format: 'pem', * }, * privateKeyEncoding: { * type: 'pkcs8', * format: 'pem', * cipher: 'aes-256-cbc', - * passphrase: 'top secret' - * } + * passphrase: 'top secret', + * }, * }, (err, publicKey, privateKey) => { * // Handle errors and use the generated key pair. * }); @@ -2968,11 +2937,16 @@ declare module 'crypto' { * If the `callback` function is provided this function uses libuv's threadpool. * @since v12.0.0 */ - function verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean; function verify( algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, - key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, + key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, + signature: NodeJS.ArrayBufferView + ): boolean; + function verify( + algorithm: string | null | undefined, + data: NodeJS.ArrayBufferView, + key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView, callback: (error: Error | null, result: boolean) => void ): void; @@ -3042,10 +3016,10 @@ declare module 'crypto' { * of the input arguments specify invalid values or types. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * const { - * hkdf - * } = await import('crypto'); + * hkdf, + * } = await import('node:crypto'); * * hkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => { * if (err) throw err; @@ -3054,7 +3028,7 @@ declare module 'crypto' { * ``` * @since v15.0.0 * @param digest The digest algorithm to use. - * @param ikm The input keying material. It must be at least one byte in length. + * @param ikm The input keying material. Must be provided but can be zero-length. * @param salt The salt value. Must be provided but can be zero-length. * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes. * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512` @@ -3071,17 +3045,17 @@ declare module 'crypto' { * types, or if the derived key cannot be generated. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * const { - * hkdfSync - * } = await import('crypto'); + * hkdfSync, + * } = await import('node:crypto'); * * const derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64); * console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653' * ``` * @since v15.0.0 * @param digest The digest algorithm to use. - * @param ikm The input keying material. It must be at least one byte in length. + * @param ikm The input keying material. Must be provided but can be zero-length. * @param salt The salt value. Must be provided but can be zero-length. * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes. * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512` @@ -3121,40 +3095,41 @@ declare module 'crypto' { */ disableEntropyCache?: boolean | undefined; } + type UUID = `${string}-${string}-${string}-${string}-${string}`; /** * Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a * cryptographic pseudorandom number generator. * @since v15.6.0, v14.17.0 */ - function randomUUID(options?: RandomUUIDOptions): string; + function randomUUID(options?: RandomUUIDOptions): UUID; interface X509CheckOptions { /** * @default 'always' */ - subject: 'always' | 'never'; + subject?: 'always' | 'default' | 'never'; /** * @default true */ - wildcards: boolean; + wildcards?: boolean; /** * @default true */ - partialWildcards: boolean; + partialWildcards?: boolean; /** * @default false */ - multiLabelWildcards: boolean; + multiLabelWildcards?: boolean; /** * @default false */ - singleLabelSubdomains: boolean; + singleLabelSubdomains?: boolean; } /** * Encapsulates an X509 certificate and provides read-only access to * its information. * * ```js - * const { X509Certificate } = await import('crypto'); + * const { X509Certificate } = await import('node:crypto'); * * const x509 = new X509Certificate('{... pem encoded cert ...}'); * @@ -3184,23 +3159,53 @@ declare module 'crypto' { readonly fingerprint256: string; /** * The SHA-512 fingerprint of this certificate. - * @since v16.14.0 + * + * Because computing the SHA-256 fingerprint is usually faster and because it is + * only half the size of the SHA-512 fingerprint, `x509.fingerprint256` may be + * a better choice. While SHA-512 presumably provides a higher level of security in + * general, the security of SHA-256 matches that of most algorithms that are + * commonly used to sign certificates. + * @since v17.2.0, v16.14.0 */ - readonly fingerprint512: string; + readonly fingerprint512: string; /** * The complete subject of this certificate. * @since v15.6.0 */ readonly subject: string; /** - * The subject alternative name specified for this certificate or `undefined` - * if not available. + * The subject alternative name specified for this certificate. + * + * This is a comma-separated list of subject alternative names. Each entry begins + * with a string identifying the kind of the subject alternative name followed by + * a colon and the value associated with the entry. + * + * Earlier versions of Node.js incorrectly assumed that it is safe to split this + * property at the two-character sequence `', '` (see [CVE-2021-44532](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532)). However, + * both malicious and legitimate certificates can contain subject alternative names + * that include this sequence when represented as a string. + * + * After the prefix denoting the type of the entry, the remainder of each entry + * might be enclosed in quotes to indicate that the value is a JSON string literal. + * For backward compatibility, Node.js only uses JSON string literals within this + * property when necessary to avoid ambiguity. Third-party code should be prepared + * to handle both possible entry formats. * @since v15.6.0 */ readonly subjectAltName: string | undefined; /** - * The information access content of this certificate or `undefined` if not - * available. + * A textual representation of the certificate's authority information access + * extension. + * + * This is a line feed separated list of access descriptions. Each line begins with + * the access method and the kind of the access location, followed by a colon and + * the value associated with the access location. + * + * After the prefix denoting the access method and the kind of the access location, + * the remainder of each line might be enclosed in quotes to indicate that the + * value is a JSON string literal. For backward compatibility, Node.js only uses + * JSON string literals within this property when necessary to avoid ambiguity. + * Third-party code should be prepared to handle both possible entry formats. * @since v15.6.0 */ readonly infoAccess: string | undefined; @@ -3417,7 +3422,7 @@ declare module 'crypto' { interface CheckPrimeOptions { /** * The number of Miller-Rabin probabilistic primality iterations to perform. - * When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most 2-64 for random input. + * When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most `2**-64` for random input. * Care must be used when selecting a number of checks. * Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details. * @@ -3444,36 +3449,29 @@ declare module 'crypto' { * * `engine` could be either an id or a path to the engine's shared library. * - * The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. - * The `flags` is a bit field taking one of or a mix of the following flags (defined in `crypto.constants`): - * - * - `crypto.constants.ENGINE_METHOD_RSA` - * - `crypto.constants.ENGINE_METHOD_DSA` - * - `crypto.constants.ENGINE_METHOD_DH` - * - `crypto.constants.ENGINE_METHOD_RAND` - * - `crypto.constants.ENGINE_METHOD_EC` - * - `crypto.constants.ENGINE_METHOD_CIPHERS` - * - `crypto.constants.ENGINE_METHOD_DIGESTS` - * - `crypto.constants.ENGINE_METHOD_PKEY_METHS` - * - `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS` - * - `crypto.constants.ENGINE_METHOD_ALL` - * - `crypto.constants.ENGINE_METHOD_NONE` - * - * The flags below are deprecated in OpenSSL-1.1.0. - * - * - `crypto.constants.ENGINE_METHOD_ECDH` - * - `crypto.constants.ENGINE_METHOD_ECDSA` - * - `crypto.constants.ENGINE_METHOD_STORE` + * The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`is a bit field taking one of or a mix of the following flags (defined in`crypto.constants`): + * + * * `crypto.constants.ENGINE_METHOD_RSA` + * * `crypto.constants.ENGINE_METHOD_DSA` + * * `crypto.constants.ENGINE_METHOD_DH` + * * `crypto.constants.ENGINE_METHOD_RAND` + * * `crypto.constants.ENGINE_METHOD_EC` + * * `crypto.constants.ENGINE_METHOD_CIPHERS` + * * `crypto.constants.ENGINE_METHOD_DIGESTS` + * * `crypto.constants.ENGINE_METHOD_PKEY_METHS` + * * `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS` + * * `crypto.constants.ENGINE_METHOD_ALL` + * * `crypto.constants.ENGINE_METHOD_NONE` * @since v0.11.11 - * @param [flags=crypto.constants.ENGINE_METHOD_ALL] + * @param flags */ function setEngine(engine: string, flags?: number): void; /** - * A convenient alias for `crypto.webcrypto.getRandomValues()`. - * This implementation is not compliant with the Web Crypto spec, - * to write web-compatible code use `crypto.webcrypto.getRandomValues()` instead. + * A convenient alias for {@link webcrypto.getRandomValues}. This + * implementation is not compliant with the Web Crypto spec, to write + * web-compatible code use {@link webcrypto.getRandomValues} instead. * @since v17.4.0 - * @returns Returns `typedArray`. + * @return Returns `typedArray`. */ function getRandomValues(typedArray: T): T; /** @@ -3638,7 +3636,7 @@ declare module 'crypto' { * The UUID is generated using a cryptographic pseudorandom number generator. * @since v16.7.0 */ - randomUUID(): string; + randomUUID(): UUID; CryptoKey: CryptoKeyConstructor; } // This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable. @@ -3723,7 +3721,9 @@ declare module 'crypto' { /** * Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`, * `subtle.deriveBits()` attempts to generate `length` bits. - * The Node.js implementation requires that `length` is a multiple of `8`. + * The Node.js implementation requires that when `length` is a number it must be multiple of `8`. + * When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed + * for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms. * If successful, the returned promise will be resolved with an `` containing the generated data. * * The algorithms currently supported include: @@ -3735,7 +3735,8 @@ declare module 'crypto' { * - `'PBKDF2'` * @since v15.0.0 */ - deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise; + deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: number | null): Promise; + deriveBits(algorithm: AlgorithmIdentifier | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise; /** * Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`, * `subtle.deriveKey()` attempts to generate a new ` based on the method and parameters in `derivedKeyAlgorithm`. diff --git a/node_modules/@types/node/dgram.d.ts b/node_modules/@types/node/dgram.d.ts index 247328d28..02d71061e 100755 --- a/node_modules/@types/node/dgram.d.ts +++ b/node_modules/@types/node/dgram.d.ts @@ -1,13 +1,13 @@ /** - * The `dgram` module provides an implementation of UDP datagram sockets. + * The `node:dgram` module provides an implementation of UDP datagram sockets. * * ```js - * import dgram from 'dgram'; + * import dgram from 'node:dgram'; * * const server = dgram.createSocket('udp4'); * * server.on('error', (err) => { - * console.log(`server error:\n${err.stack}`); + * console.error(`server error:\n${err.stack}`); * server.close(); * }); * @@ -23,7 +23,7 @@ * server.bind(41234); * // Prints: server listening 0.0.0.0:41234 * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dgram.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dgram.js) */ declare module 'dgram' { import { AddressInfo } from 'node:net'; @@ -98,8 +98,8 @@ declare module 'dgram' { * When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur: * * ```js - * import cluster from 'cluster'; - * import dgram from 'dgram'; + * import cluster from 'node:cluster'; + * import dgram from 'node:dgram'; * * if (cluster.isPrimary) { * cluster.fork(); // Works ok. @@ -116,7 +116,7 @@ declare module 'dgram' { addMembership(multicastAddress: string, multicastInterface?: string): void; /** * Returns an object containing the address information for a socket. - * For UDP sockets, this object will contain `address`, `family` and `port`properties. + * For UDP sockets, this object will contain `address`, `family`, and `port`properties. * * This method throws `EBADF` if called on an unbound socket. * @since v0.1.99 @@ -142,12 +142,12 @@ declare module 'dgram' { * Example of a UDP server listening on port 41234: * * ```js - * import dgram from 'dgram'; + * import dgram from 'node:dgram'; * * const server = dgram.createSocket('udp4'); * * server.on('error', (err) => { - * console.log(`server error:\n${err.stack}`); + * console.error(`server error:\n${err.stack}`); * server.close(); * }); * @@ -284,8 +284,8 @@ declare module 'dgram' { * Example of sending a UDP packet to a port on `localhost`; * * ```js - * import dgram from 'dgram'; - * import { Buffer } from 'buffer'; + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; * * const message = Buffer.from('Some bytes'); * const client = dgram.createSocket('udp4'); @@ -297,8 +297,8 @@ declare module 'dgram' { * Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`; * * ```js - * import dgram from 'dgram'; - * import { Buffer } from 'buffer'; + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from('Some '); * const buf2 = Buffer.from('bytes'); @@ -316,8 +316,8 @@ declare module 'dgram' { * Example of sending a UDP packet using a socket connected to a port on`localhost`: * * ```js - * import dgram from 'dgram'; - * import { Buffer } from 'buffer'; + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; * * const message = Buffer.from('Some bytes'); * const client = dgram.createSocket('udp4'); diff --git a/node_modules/@types/node/diagnostics_channel.d.ts b/node_modules/@types/node/diagnostics_channel.d.ts index a87ba8ca9..5f19b201d 100755 --- a/node_modules/@types/node/diagnostics_channel.d.ts +++ b/node_modules/@types/node/diagnostics_channel.d.ts @@ -1,11 +1,11 @@ /** - * The `diagnostics_channel` module provides an API to create named channels + * The `node:diagnostics_channel` module provides an API to create named channels * to report arbitrary message data for diagnostics purposes. * * It can be accessed using: * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * ``` * * It is intended that a module writer wanting to report diagnostics messages @@ -19,8 +19,8 @@ * channels are used along with the shape of the message data. Channel names * should generally include the module name to avoid collisions with data from * other modules. - * @experimental - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/diagnostics_channel.js) + * @since v15.1.0, v14.17.0 + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/diagnostics_channel.js) */ declare module 'diagnostics_channel' { /** @@ -31,7 +31,7 @@ declare module 'diagnostics_channel' { * performance-sensitive code. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * if (diagnostics_channel.hasSubscribers('my-channel')) { * // There are subscribers, prepare and publish message @@ -41,14 +41,14 @@ declare module 'diagnostics_channel' { * @param name The channel name * @return If there are active subscribers */ - function hasSubscribers(name: string): boolean; + function hasSubscribers(name: string | symbol): boolean; /** - * This is the primary entry-point for anyone wanting to interact with a named + * This is the primary entry-point for anyone wanting to publish to a named * channel. It produces a channel object which is optimized to reduce overhead at * publish time as much as possible. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * const channel = diagnostics_channel.channel('my-channel'); * ``` @@ -56,11 +56,48 @@ declare module 'diagnostics_channel' { * @param name The channel name * @return The named channel object */ - function channel(name: string): Channel; - type ChannelListener = (message: unknown, name: string) => void; + function channel(name: string | symbol): Channel; + type ChannelListener = (message: unknown, name: string | symbol) => void; + /** + * Register a message handler to subscribe to this channel. This message handler + * will be run synchronously whenever a message is published to the channel. Any + * errors thrown in the message handler will trigger an `'uncaughtException'`. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * diagnostics_channel.subscribe('my-channel', (message, name) => { + * // Received data + * }); + * ``` + * @since v18.7.0, v16.17.0 + * @param name The channel name + * @param onMessage The handler to receive channel messages + */ + function subscribe(name: string | symbol, onMessage: ChannelListener): void; + /** + * Remove a message handler previously registered to this channel with {@link subscribe}. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * function onMessage(message, name) { + * // Received data + * } + * + * diagnostics_channel.subscribe('my-channel', onMessage); + * + * diagnostics_channel.unsubscribe('my-channel', onMessage); + * ``` + * @since v18.7.0, v16.17.0 + * @param name The channel name + * @param onMessage The previous subscribed handler to remove + * @return `true` if the handler was found, `false` otherwise. + */ + function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean; /** * The class `Channel` represents an individual named channel within the data - * pipeline. It is use to track subscribers and to publish messages when there + * pipeline. It is used to track subscribers and to publish messages when there * are subscribers present. It exists as a separate object to avoid channel * lookups at publish time, enabling very fast publish speeds and allowing * for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly @@ -68,7 +105,7 @@ declare module 'diagnostics_channel' { * @since v15.1.0, v14.17.0 */ class Channel { - readonly name: string; + readonly name: string | symbol; /** * Check if there are active subscribers to this channel. This is helpful if * the message you want to send might be expensive to prepare. @@ -77,7 +114,7 @@ declare module 'diagnostics_channel' { * performance-sensitive code. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * const channel = diagnostics_channel.channel('my-channel'); * @@ -88,19 +125,18 @@ declare module 'diagnostics_channel' { * @since v15.1.0, v14.17.0 */ readonly hasSubscribers: boolean; - private constructor(name: string); + private constructor(name: string | symbol); /** - * Publish a message to any subscribers to the channel. This will - * trigger message handlers synchronously so they will execute within - * the same context. + * Publish a message to any subscribers to the channel. This will trigger + * message handlers synchronously so they will execute within the same context. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * const channel = diagnostics_channel.channel('my-channel'); * * channel.publish({ - * some: 'message' + * some: 'message', * }); * ``` * @since v15.1.0, v14.17.0 @@ -113,7 +149,7 @@ declare module 'diagnostics_channel' { * errors thrown in the message handler will trigger an `'uncaughtException'`. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * const channel = diagnostics_channel.channel('my-channel'); * @@ -122,6 +158,7 @@ declare module 'diagnostics_channel' { * }); * ``` * @since v15.1.0, v14.17.0 + * @deprecated Since v18.7.0,v16.17.0 - Use {@link subscribe(name, onMessage)} * @param onMessage The handler to receive channel messages */ subscribe(onMessage: ChannelListener): void; @@ -129,7 +166,7 @@ declare module 'diagnostics_channel' { * Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * const channel = diagnostics_channel.channel('my-channel'); * @@ -142,6 +179,7 @@ declare module 'diagnostics_channel' { * channel.unsubscribe(onMessage); * ``` * @since v15.1.0, v14.17.0 + * @deprecated Since v18.7.0,v16.17.0 - Use {@link unsubscribe(name, onMessage)} * @param onMessage The previous subscribed handler to remove * @return `true` if the handler was found, `false` otherwise. */ diff --git a/node_modules/@types/node/dns.d.ts b/node_modules/@types/node/dns.d.ts index 305367b81..db3febcd3 100755 --- a/node_modules/@types/node/dns.d.ts +++ b/node_modules/@types/node/dns.d.ts @@ -1,5 +1,5 @@ /** - * The `dns` module enables name resolution. For example, use it to look up IP + * The `node:dns` module enables name resolution. For example, use it to look up IP * addresses of host names. * * Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the @@ -9,7 +9,7 @@ * system do, use {@link lookup}. * * ```js - * const dns = require('dns'); + * const dns = require('node:dns'); * * dns.lookup('example.org', (err, address, family) => { * console.log('address: %j family: IPv%s', address, family); @@ -17,13 +17,13 @@ * // address: "93.184.216.34" family: IPv4 * ``` * - * All other functions in the `dns` module connect to an actual DNS server to + * All other functions in the `node:dns` module connect to an actual DNS server to * perform name resolution. They will always use the network to perform DNS * queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform * DNS queries, bypassing other name-resolution facilities. * * ```js - * const dns = require('dns'); + * const dns = require('node:dns'); * * dns.resolve4('archive.org', (err, addresses) => { * if (err) throw err; @@ -42,7 +42,7 @@ * ``` * * See the `Implementation considerations section` for more information. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dns.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dns.js) */ declare module 'dns' { import * as dnsPromises from 'node:dns/promises'; @@ -76,8 +76,8 @@ declare module 'dns' { /** * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or * AAAA (IPv6) record. All `option` properties are optional. If `options` is an - * integer, then it must be `4` or `6` – if `options` is not provided, then IPv4 - * and IPv6 addresses are both returned if found. + * integer, then it must be `4` or `6` – if `options` is `0` or not provided, then + * IPv4 and IPv6 addresses are both returned if found. * * With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the * properties `address` and `family`. @@ -89,14 +89,14 @@ declare module 'dns' { * * `dns.lookup()` does not necessarily have anything to do with the DNS protocol. * The implementation uses an operating system facility that can associate names - * with addresses, and vice versa. This implementation can have subtle but + * with addresses and vice versa. This implementation can have subtle but * important consequences on the behavior of any Node.js program. Please take some * time to consult the `Implementation considerations section` before using`dns.lookup()`. * * Example usage: * * ```js - * const dns = require('dns'); + * const dns = require('node:dns'); * const options = { * family: 6, * hints: dns.ADDRCONFIG | dns.V4MAPPED, @@ -135,7 +135,7 @@ declare module 'dns' { * On an error, `err` is an `Error` object, where `err.code` is the error code. * * ```js - * const dns = require('dns'); + * const dns = require('node:dns'); * dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { * console.log(hostname, service); * // Prints: localhost ssh @@ -174,7 +174,7 @@ declare module 'dns' { type: 'AAAA'; } export interface CaaRecord { - critial: number; + critical: number; issue?: string | undefined; issuewild?: string | undefined; iodef?: string | undefined; @@ -291,7 +291,7 @@ declare module 'dns' { function __promisify__(hostname: string, options?: ResolveOptions): Promise; } /** - * Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function + * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function * will contain an array of IPv6 addresses. * @since v0.1.16 * @param hostname Host name to resolve. @@ -333,7 +333,7 @@ declare module 'dns' { function __promisify__(hostname: string): Promise; } /** - * Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of + * Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of * objects with the following properties: * * * `flags` @@ -484,6 +484,14 @@ declare module 'dns' { * @since v0.1.16 */ export function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void; + /** + * Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be: + * + * * `ipv4first`: for `verbatim` defaulting to `false`. + * * `verbatim`: for `verbatim` defaulting to `true`. + * @since v20.1.0 + */ + export function getDefaultResultOrder(): 'ipv4first' | 'verbatim'; /** * Sets the IP address and port of servers to be used when performing DNS * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted @@ -535,7 +543,7 @@ declare module 'dns' { * * `ipv4first`: sets default `verbatim` `false`. * * `verbatim`: sets default `verbatim` `true`. * - * The default is `ipv4first` and {@link setDefaultResultOrder} have higher + * The default is `verbatim` and {@link setDefaultResultOrder} have higher * priority than `--dns-result-order`. When using `worker threads`,{@link setDefaultResultOrder} from the main thread won't affect the default * dns orders in workers. * @since v16.4.0, v14.18.0 @@ -582,7 +590,7 @@ declare module 'dns' { * other resolvers: * * ```js - * const { Resolver } = require('dns'); + * const { Resolver } = require('node:dns'); * const resolver = new Resolver(); * resolver.setServers(['4.4.4.4']); * @@ -592,7 +600,7 @@ declare module 'dns' { * }); * ``` * - * The following methods from the `dns` module are available: + * The following methods from the `node:dns` module are available: * * * `resolver.getServers()` * * `resolver.resolve()` @@ -625,6 +633,7 @@ declare module 'dns' { resolve4: typeof resolve4; resolve6: typeof resolve6; resolveAny: typeof resolveAny; + resolveCaa: typeof resolveCaa; resolveCname: typeof resolveCname; resolveMx: typeof resolveMx; resolveNaptr: typeof resolveNaptr; @@ -639,7 +648,7 @@ declare module 'dns' { * This allows programs to specify outbound interfaces when used on multi-homed * systems. * - * If a v4 or v6 address is not specified, it is set to the default, and the + * If a v4 or v6 address is not specified, it is set to the default and the * operating system will choose a local address automatically. * * The resolver will use the v4 local address when making requests to IPv4 DNS diff --git a/node_modules/@types/node/dns/promises.d.ts b/node_modules/@types/node/dns/promises.d.ts index 77cd807bd..4c151e440 100755 --- a/node_modules/@types/node/dns/promises.d.ts +++ b/node_modules/@types/node/dns/promises.d.ts @@ -1,7 +1,7 @@ /** * The `dns.promises` API provides an alternative set of asynchronous DNS methods * that return `Promise` objects rather than using callbacks. The API is accessible - * via `require('dns').promises` or `require('dns/promises')`. + * via `require('node:dns').promises` or `require('node:dns/promises')`. * @since v10.6.0 */ declare module 'dns/promises' { @@ -52,7 +52,7 @@ declare module 'dns/promises' { * * `dnsPromises.lookup()` does not necessarily have anything to do with the DNS * protocol. The implementation uses an operating system facility that can - * associate names with addresses, and vice versa. This implementation can have + * associate names with addresses and vice versa. This implementation can have * subtle but important consequences on the behavior of any Node.js program. Please * take some time to consult the `Implementation considerations section` before * using `dnsPromises.lookup()`. @@ -60,7 +60,7 @@ declare module 'dns/promises' { * Example usage: * * ```js - * const dns = require('dns'); + * const dns = require('node:dns'); * const dnsPromises = dns.promises; * const options = { * family: 6, @@ -96,7 +96,7 @@ declare module 'dns/promises' { * On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code. * * ```js - * const dnsPromises = require('dns').promises; + * const dnsPromises = require('node:dns').promises; * dnsPromises.lookupService('127.0.0.1', 22).then((result) => { * console.log(result.hostname, result.service); * // Prints: localhost ssh @@ -206,7 +206,7 @@ declare module 'dns/promises' { */ function resolveMx(hostname: string): Promise; /** - * Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array + * Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array * of objects with the following properties: * * * `flags` @@ -337,13 +337,56 @@ declare module 'dns/promises' { * * `ipv4first`: sets default `verbatim` `false`. * * `verbatim`: sets default `verbatim` `true`. * - * The default is `ipv4first` and `dnsPromises.setDefaultResultOrder()` have + * The default is `verbatim` and `dnsPromises.setDefaultResultOrder()` have * higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.setDefaultResultOrder()` from the main thread won't affect the * default dns orders in workers. * @since v16.4.0, v14.18.0 * @param order must be `'ipv4first'` or `'verbatim'`. */ function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void; + /** + * An independent resolver for DNS requests. + * + * Creating a new resolver uses the default server settings. Setting + * the servers used for a resolver using `resolver.setServers()` does not affect + * other resolvers: + * + * ```js + * const { Resolver } = require('node:dns').promises; + * const resolver = new Resolver(); + * resolver.setServers(['4.4.4.4']); + * + * // This request will use the server at 4.4.4.4, independent of global settings. + * resolver.resolve4('example.org').then((addresses) => { + * // ... + * }); + * + * // Alternatively, the same code can be written using async-await style. + * (async function() { + * const addresses = await resolver.resolve4('example.org'); + * })(); + * ``` + * + * The following methods from the `dnsPromises` API are available: + * + * * `resolver.getServers()` + * * `resolver.resolve()` + * * `resolver.resolve4()` + * * `resolver.resolve6()` + * * `resolver.resolveAny()` + * * `resolver.resolveCaa()` + * * `resolver.resolveCname()` + * * `resolver.resolveMx()` + * * `resolver.resolveNaptr()` + * * `resolver.resolveNs()` + * * `resolver.resolvePtr()` + * * `resolver.resolveSoa()` + * * `resolver.resolveSrv()` + * * `resolver.resolveTxt()` + * * `resolver.reverse()` + * * `resolver.setServers()` + * @since v10.6.0 + */ class Resolver { constructor(options?: ResolverOptions); cancel(): void; @@ -352,6 +395,7 @@ declare module 'dns/promises' { resolve4: typeof resolve4; resolve6: typeof resolve6; resolveAny: typeof resolveAny; + resolveCaa: typeof resolveCaa; resolveCname: typeof resolveCname; resolveMx: typeof resolveMx; resolveNaptr: typeof resolveNaptr; diff --git a/node_modules/@types/node/dom-events.d.ts b/node_modules/@types/node/dom-events.d.ts new file mode 100755 index 000000000..b9c1c3aa4 --- /dev/null +++ b/node_modules/@types/node/dom-events.d.ts @@ -0,0 +1,126 @@ +export {}; // Don't export anything! + +//// DOM-like Events +// NB: The Event / EventTarget / EventListener implementations below were copied +// from lib.dom.d.ts, then edited to reflect Node's documentation at +// https://nodejs.org/api/events.html#class-eventtarget. +// Please read that link to understand important implementation differences. + +// This conditional type will be the existing global Event in a browser, or +// the copy below in a Node environment. +type __Event = typeof globalThis extends { onmessage: any, Event: any } +? {} +: { + /** This is not used in Node.js and is provided purely for completeness. */ + readonly bubbles: boolean; + /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */ + cancelBubble: () => void; + /** True if the event was created with the cancelable option */ + readonly cancelable: boolean; + /** This is not used in Node.js and is provided purely for completeness. */ + readonly composed: boolean; + /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */ + composedPath(): [EventTarget?] + /** Alias for event.target. */ + readonly currentTarget: EventTarget | null; + /** Is true if cancelable is true and event.preventDefault() has been called. */ + readonly defaultPrevented: boolean; + /** This is not used in Node.js and is provided purely for completeness. */ + readonly eventPhase: 0 | 2; + /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */ + readonly isTrusted: boolean; + /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */ + preventDefault(): void; + /** This is not used in Node.js and is provided purely for completeness. */ + returnValue: boolean; + /** Alias for event.target. */ + readonly srcElement: EventTarget | null; + /** Stops the invocation of event listeners after the current one completes. */ + stopImmediatePropagation(): void; + /** This is not used in Node.js and is provided purely for completeness. */ + stopPropagation(): void; + /** The `EventTarget` dispatching the event */ + readonly target: EventTarget | null; + /** The millisecond timestamp when the Event object was created. */ + readonly timeStamp: number; + /** Returns the type of event, e.g. "click", "hashchange", or "submit". */ + readonly type: string; +}; + +// See comment above explaining conditional type +type __EventTarget = typeof globalThis extends { onmessage: any, EventTarget: any } +? {} +: { + /** + * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value. + * + * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched. + * + * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification. + * Specifically, the `capture` option is used as part of the key when registering a `listener`. + * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`. + */ + addEventListener( + type: string, + listener: EventListener | EventListenerObject, + options?: AddEventListenerOptions | boolean, + ): void; + /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */ + dispatchEvent(event: Event): boolean; + /** Removes the event listener in target's event listener list with the same type, callback, and options. */ + removeEventListener( + type: string, + listener: EventListener | EventListenerObject, + options?: EventListenerOptions | boolean, + ): void; +}; + +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; + composed?: boolean; +} + +interface EventListenerOptions { + /** Not directly used by Node.js. Added for API completeness. Default: `false`. */ + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */ + once?: boolean; + /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */ + passive?: boolean; +} + +interface EventListener { + (evt: Event): void; +} + +interface EventListenerObject { + handleEvent(object: Event): void; +} + +import {} from 'events'; // Make this an ambient declaration +declare global { + /** An event which takes place in the DOM. */ + interface Event extends __Event {} + var Event: typeof globalThis extends { onmessage: any, Event: infer T } + ? T + : { + prototype: __Event; + new (type: string, eventInitDict?: EventInit): __Event; + }; + + /** + * EventTarget is a DOM interface implemented by objects that can + * receive events and may have listeners for them. + */ + interface EventTarget extends __EventTarget {} + var EventTarget: typeof globalThis extends { onmessage: any, EventTarget: infer T } + ? T + : { + prototype: __EventTarget; + new (): __EventTarget; + }; +} diff --git a/node_modules/@types/node/domain.d.ts b/node_modules/@types/node/domain.d.ts index fafe68a5d..e49b87fc1 100755 --- a/node_modules/@types/node/domain.d.ts +++ b/node_modules/@types/node/domain.d.ts @@ -12,7 +12,7 @@ * will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to * exit immediately with an error code. * @deprecated Since v1.4.2 - Deprecated - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/domain.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/domain.js) */ declare module 'domain' { import EventEmitter = require('node:events'); @@ -56,15 +56,15 @@ declare module 'domain' { exit(): void; /** * Run the supplied function in the context of the domain, implicitly - * binding all event emitters, timers, and lowlevel requests that are + * binding all event emitters, timers, and low-level requests that are * created in that context. Optionally, arguments can be passed to * the function. * * This is the most basic way to use a domain. * * ```js - * const domain = require('domain'); - * const fs = require('fs'); + * const domain = require('node:domain'); + * const fs = require('node:fs'); * const d = domain.create(); * d.on('error', (er) => { * console.error('Caught error!', er); diff --git a/node_modules/@types/node/events.d.ts b/node_modules/@types/node/events.d.ts index b8283ac95..29616e123 100755 --- a/node_modules/@types/node/events.d.ts +++ b/node_modules/@types/node/events.d.ts @@ -22,7 +22,7 @@ * the `eventEmitter.emit()` method is used to trigger the event. * * ```js - * const EventEmitter = require('events'); + * import { EventEmitter } from 'node:events'; * * class MyEmitter extends EventEmitter {} * @@ -32,19 +32,54 @@ * }); * myEmitter.emit('event'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/events.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/events.js) */ declare module 'events' { + // NOTE: This class is in the docs but is **not actually exported** by Node. + // If https://github.com/nodejs/node/issues/39903 gets resolved and Node + // actually starts exporting the class, uncomment below. + // import { EventListener, EventListenerObject } from '__dom-events'; + // /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */ + // interface NodeEventTarget extends EventTarget { + // /** + // * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API. + // * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget. + // */ + // addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this; + // /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */ + // eventNames(): string[]; + // /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */ + // listenerCount(type: string): number; + // /** Node.js-specific alias for `eventTarget.removeListener()`. */ + // off(type: string, listener: EventListener | EventListenerObject): this; + // /** Node.js-specific alias for `eventTarget.addListener()`. */ + // on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this; + // /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */ + // once(type: string, listener: EventListener | EventListenerObject): this; + // /** + // * Node.js-specific extension to the `EventTarget` class. + // * If `type` is specified, removes all registered listeners for `type`, + // * otherwise removes all registered listeners. + // */ + // removeAllListeners(type: string): this; + // /** + // * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`. + // * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`. + // */ + // removeListener(type: string, listener: EventListener | EventListenerObject): this; + // } interface EventEmitterOptions { /** * Enables automatic capturing of promise rejection. */ captureRejections?: boolean | undefined; } - interface NodeEventTarget { + // Any EventTarget with a Node-style `once` function + interface _NodeEventTarget { once(eventName: string | symbol, listener: (...args: any[]) => void): this; } - interface DOMEventTarget { + // Any EventTarget with a DOM-style `addEventListener` + interface _DOMEventTarget { addEventListener( eventName: string, listener: (...args: any[]) => void, @@ -58,10 +93,10 @@ declare module 'events' { } interface EventEmitter extends NodeJS.EventEmitter {} /** - * The `EventEmitter` class is defined and exposed by the `events` module: + * The `EventEmitter` class is defined and exposed by the `node:events` module: * * ```js - * const EventEmitter = require('events'); + * import { EventEmitter } from 'node:events'; * ``` * * All `EventEmitter`s emit the event `'newListener'` when new listeners are @@ -82,31 +117,28 @@ declare module 'events' { * semantics and does not listen to the `'error'` event. * * ```js - * const { once, EventEmitter } = require('events'); + * import { once, EventEmitter } from 'node:events'; + * import process from 'node:process'; * - * async function run() { - * const ee = new EventEmitter(); + * const ee = new EventEmitter(); * - * process.nextTick(() => { - * ee.emit('myevent', 42); - * }); + * process.nextTick(() => { + * ee.emit('myevent', 42); + * }); * - * const [value] = await once(ee, 'myevent'); - * console.log(value); + * const [value] = await once(ee, 'myevent'); + * console.log(value); * - * const err = new Error('kaboom'); - * process.nextTick(() => { - * ee.emit('error', err); - * }); + * const err = new Error('kaboom'); + * process.nextTick(() => { + * ee.emit('error', err); + * }); * - * try { - * await once(ee, 'myevent'); - * } catch (err) { - * console.log('error happened', err); - * } + * try { + * await once(ee, 'myevent'); + * } catch (err) { + * console.error('error happened', err); * } - * - * run(); * ``` * * The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the @@ -114,13 +146,13 @@ declare module 'events' { * special handling: * * ```js - * const { EventEmitter, once } = require('events'); + * import { EventEmitter, once } from 'node:events'; * * const ee = new EventEmitter(); * * once(ee, 'error') * .then(([err]) => console.log('ok', err.message)) - * .catch((err) => console.log('error', err.message)); + * .catch((err) => console.error('error', err.message)); * * ee.emit('error', new Error('boom')); * @@ -130,7 +162,7 @@ declare module 'events' { * An `AbortSignal` can be used to cancel waiting for the event: * * ```js - * const { EventEmitter, once } = require('events'); + * import { EventEmitter, once } from 'node:events'; * * const ee = new EventEmitter(); * const ac = new AbortController(); @@ -154,29 +186,28 @@ declare module 'events' { * ``` * @since v11.13.0, v10.16.0 */ - static once(emitter: NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise; - static once(emitter: DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise; + static once(emitter: _NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise; + static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise; /** * ```js - * const { on, EventEmitter } = require('events'); - * - * (async () => { - * const ee = new EventEmitter(); + * import { on, EventEmitter } from 'node:events'; + * import process from 'node:process'; * - * // Emit later on - * process.nextTick(() => { - * ee.emit('foo', 'bar'); - * ee.emit('foo', 42); - * }); + * const ee = new EventEmitter(); * - * for await (const event of on(ee, 'foo')) { - * // The execution of this inner block is synchronous and it - * // processes one event at a time (even with await). Do not use - * // if concurrent execution is required. - * console.log(event); // prints ['bar'] [42] - * } - * // Unreachable here - * })(); + * // Emit later on + * process.nextTick(() => { + * ee.emit('foo', 'bar'); + * ee.emit('foo', 42); + * }); + * + * for await (const event of on(ee, 'foo')) { + * // The execution of this inner block is synchronous and it + * // processes one event at a time (even with await). Do not use + * // if concurrent execution is required. + * console.log(event); // prints ['bar'] [42] + * } + * // Unreachable here * ``` * * Returns an `AsyncIterator` that iterates `eventName` events. It will throw @@ -187,7 +218,9 @@ declare module 'events' { * An `AbortSignal` can be used to cancel waiting on events: * * ```js - * const { on, EventEmitter } = require('events'); + * import { on, EventEmitter } from 'node:events'; + * import process from 'node:process'; + * * const ac = new AbortController(); * * (async () => { @@ -219,7 +252,8 @@ declare module 'events' { * A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`. * * ```js - * const { EventEmitter, listenerCount } = require('events'); + * import { EventEmitter, listenerCount } from 'node:events'; + * * const myEmitter = new EventEmitter(); * myEmitter.on('event', () => {}); * myEmitter.on('event', () => {}); @@ -242,30 +276,27 @@ declare module 'events' { * event target. This is useful for debugging and diagnostic purposes. * * ```js - * const { getEventListeners, EventEmitter } = require('events'); + * import { getEventListeners, EventEmitter } from 'node:events'; * * { * const ee = new EventEmitter(); * const listener = () => console.log('Events are fun'); * ee.on('foo', listener); - * getEventListeners(ee, 'foo'); // [listener] + * console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ] * } * { * const et = new EventTarget(); * const listener = () => console.log('Events are fun'); * et.addEventListener('foo', listener); - * getEventListeners(et, 'foo'); // [listener] + * console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ] * } * ``` * @since v15.2.0, v14.17.0 */ - static getEventListeners(emitter: DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[]; + static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[]; /** * ```js - * const { - * setMaxListeners, - * EventEmitter - * } = require('events'); + * import { setMaxListeners, EventEmitter } from 'node:events'; * * const target = new EventTarget(); * const emitter = new EventEmitter(); @@ -277,23 +308,65 @@ declare module 'events' { * @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter} * objects. */ - static setMaxListeners(n?: number, ...eventTargets: Array): void; + static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void; /** - * This symbol shall be used to install a listener for only monitoring `'error'` - * events. Listeners installed using this symbol are called before the regular - * `'error'` listeners are called. + * This symbol shall be used to install a listener for only monitoring `'error'`events. Listeners installed using this symbol are called before the regular`'error'` listeners are called. * - * Installing a listener using this symbol does not change the behavior once an - * `'error'` event is emitted, therefore the process will still crash if no + * Installing a listener using this symbol does not change the behavior once an`'error'` event is emitted. Therefore, the process will still crash if no * regular `'error'` listener is installed. + * @since v13.6.0, v12.17.0 */ static readonly errorMonitor: unique symbol; + /** + * Value: `Symbol.for('nodejs.rejection')` + * + * See how to write a custom `rejection handler`. + * @since v13.4.0, v12.16.0 + */ static readonly captureRejectionSymbol: unique symbol; /** - * Sets or gets the default captureRejection value for all emitters. + * Value: [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) + * + * Change the default `captureRejections` option on all new `EventEmitter` objects. + * @since v13.4.0, v12.16.0 */ - // TODO: These should be described using static getter/setter pairs: static captureRejections: boolean; + /** + * By default, a maximum of `10` listeners can be registered for any single + * event. This limit can be changed for individual `EventEmitter` instances + * using the `emitter.setMaxListeners(n)` method. To change the default + * for _all_`EventEmitter` instances, the `events.defaultMaxListeners`property can be used. If this value is not a positive number, a `RangeError`is thrown. + * + * Take caution when setting the `events.defaultMaxListeners` because the + * change affects _all_`EventEmitter` instances, including those created before + * the change is made. However, calling `emitter.setMaxListeners(n)` still has + * precedence over `events.defaultMaxListeners`. + * + * This is not a hard limit. The `EventEmitter` instance will allow + * more listeners to be added but will output a trace warning to stderr indicating + * that a "possible EventEmitter memory leak" has been detected. For any single`EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()`methods can be used to + * temporarily avoid this warning: + * + * ```js + * import { EventEmitter } from 'node:events'; + * const emitter = new EventEmitter(); + * emitter.setMaxListeners(emitter.getMaxListeners() + 1); + * emitter.once('event', () => { + * // do stuff + * emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0)); + * }); + * ``` + * + * The `--trace-warnings` command-line flag can be used to display the + * stack trace for such warnings. + * + * The emitted warning can be inspected with `process.on('warning')` and will + * have the additional `emitter`, `type`, and `count` properties, referring to + * the event emitter instance, the event's name and the number of attached + * listeners, respectively. + * Its `name` property is set to `'MaxListenersExceededWarning'`. + * @since v0.11.2 + */ static defaultMaxListeners: number; } import internal = require('node:events'); @@ -333,6 +406,7 @@ declare module 'events' { * event listener to the beginning of the listeners array. * * ```js + * import { EventEmitter } from 'node:events'; * const myEE = new EventEmitter(); * myEE.on('foo', () => console.log('a')); * myEE.prependListener('foo', () => console.log('b')); @@ -362,6 +436,7 @@ declare module 'events' { * event listener to the beginning of the listeners array. * * ```js + * import { EventEmitter } from 'node:events'; * const myEE = new EventEmitter(); * myEE.once('foo', () => console.log('a')); * myEE.prependOnceListener('foo', () => console.log('b')); @@ -397,6 +472,8 @@ declare module 'events' { * will not remove them from`emit()` in progress. Subsequent events behave as expected. * * ```js + * import { EventEmitter } from 'node:events'; + * class MyEmitter extends EventEmitter {} * const myEmitter = new MyEmitter(); * * const callbackA = () => { @@ -437,6 +514,7 @@ declare module 'events' { * recently added instance. In the example the `once('ping')`listener is removed: * * ```js + * import { EventEmitter } from 'node:events'; * const ee = new EventEmitter(); * * function pong() { @@ -505,6 +583,7 @@ declare module 'events' { * including any wrappers (such as those created by `.once()`). * * ```js + * import { EventEmitter } from 'node:events'; * const emitter = new EventEmitter(); * emitter.once('log', () => console.log('log once')); * @@ -537,7 +616,7 @@ declare module 'events' { * Returns `true` if the event had listeners, `false` otherwise. * * ```js - * const EventEmitter = require('events'); + * import { EventEmitter } from 'node:events'; * const myEmitter = new EventEmitter(); * * // First listener @@ -572,11 +651,14 @@ declare module 'events' { */ emit(eventName: string | symbol, ...args: any[]): boolean; /** - * Returns the number of listeners listening to the event named `eventName`. + * Returns the number of listeners listening for the event named `eventName`. + * If `listener` is provided, it will return how many times the listener is found + * in the list of the listeners of the event. * @since v3.2.0 * @param eventName The name of the event being listened for + * @param listener The event handler function */ - listenerCount(eventName: string | symbol): number; + listenerCount(eventName: string | symbol, listener?: Function): number; /** * Adds the `listener` function to the _beginning_ of the listeners array for the * event named `eventName`. No checks are made to see if the `listener` has @@ -616,7 +698,8 @@ declare module 'events' { * listeners. The values in the array are strings or `Symbol`s. * * ```js - * const EventEmitter = require('events'); + * import { EventEmitter } from 'node:events'; + * * const myEE = new EventEmitter(); * myEE.on('foo', () => {}); * myEE.on('bar', () => {}); diff --git a/node_modules/@types/node/fs.d.ts b/node_modules/@types/node/fs.d.ts index 75c53fb0d..9ede55db9 100755 --- a/node_modules/@types/node/fs.d.ts +++ b/node_modules/@types/node/fs.d.ts @@ -1,22 +1,22 @@ /** - * The `fs` module enables interacting with the file system in a + * The `node:fs` module enables interacting with the file system in a * way modeled on standard POSIX functions. * * To use the promise-based APIs: * * ```js - * import * as fs from 'fs/promises'; + * import * as fs from 'node:fs/promises'; * ``` * * To use the callback and sync APIs: * * ```js - * import * as fs from 'fs'; + * import * as fs from 'node:fs'; * ``` * * All file system operations have synchronous, callback, and promise-based * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM). - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/fs.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/fs.js) */ declare module 'fs' { import * as stream from 'node:stream'; @@ -73,7 +73,7 @@ declare module 'fs' { /** * A `fs.Stats` object provides information about a file. * - * Objects returned from {@link stat}, {@link lstat} and {@link fstat} and + * Objects returned from {@link stat}, {@link lstat}, {@link fstat}, and * their synchronous counterparts are of this type. * If `bigint` in the `options` passed to those methods is true, the numeric values * will be `bigint` instead of `number`, and the object will contain additional @@ -131,6 +131,62 @@ declare module 'fs' { * @since v0.1.21 */ export class Stats {} + export interface StatsFsBase { + /** Type of file system. */ + type: T; + /** Optimal transfer block size. */ + bsize: T; + /** Total data blocks in file system. */ + blocks: T; + /** Free blocks in file system. */ + bfree: T; + /** Available blocks for unprivileged users */ + bavail: T; + /** Total file nodes in file system. */ + files: T; + /** Free file nodes in file system. */ + ffree: T; + } + export interface StatsFs extends StatsFsBase {} + /** + * Provides information about a mounted file system. + * + * Objects returned from {@link statfs} and its synchronous counterpart are of + * this type. If `bigint` in the `options` passed to those methods is `true`, the + * numeric values will be `bigint` instead of `number`. + * + * ```console + * StatFs { + * type: 1397114950, + * bsize: 4096, + * blocks: 121938943, + * bfree: 61058895, + * bavail: 61058895, + * files: 999, + * ffree: 1000000 + * } + * ``` + * + * `bigint` version: + * + * ```console + * StatFs { + * type: 1397114950n, + * bsize: 4096n, + * blocks: 121938943n, + * bfree: 61058895n, + * bavail: 61058895n, + * files: 999n, + * ffree: 1000000n + * } + * ``` + * @since v19.6.0, v18.15.0 + */ + export class StatsFs {} + export interface BigIntStatsFs extends StatsFsBase {} + export interface StatFsOptions { + bigint?: boolean | undefined; + } /** * A representation of a directory entry, which can be a file or a subdirectory * within the directory, as returned by reading from an `fs.Dir`. The @@ -184,6 +240,11 @@ declare module 'fs' { * @since v10.10.0 */ name: string; + /** + * The base path that this `fs.Dirent` object refers to. + * @since v20.1.0 + */ + path: string; } /** * A class representing a directory stream. @@ -191,7 +252,7 @@ declare module 'fs' { * Created by {@link opendir}, {@link opendirSync}, or `fsPromises.opendir()`. * * ```js - * import { opendir } from 'fs/promises'; + * import { opendir } from 'node:fs/promises'; * * try { * const dir = await opendir('./'); @@ -494,7 +555,7 @@ declare module 'fs' { * See also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html). * * ```js - * import { rename } from 'fs'; + * import { rename } from 'node:fs'; * * rename('oldFile.txt', 'newFile.txt', (err) => { * if (err) throw err; @@ -527,7 +588,7 @@ declare module 'fs' { * first argument. In this case, `fs.ftruncate()` is called. * * ```js - * import { truncate } from 'fs'; + * import { truncate } from 'node:fs'; * // Assuming that 'path/file.txt' is a regular file. * truncate('path/file.txt', (err) => { * if (err) throw err; @@ -579,7 +640,7 @@ declare module 'fs' { * file: * * ```js - * import { open, close, ftruncate } from 'fs'; + * import { open, close, ftruncate } from 'node:fs'; * * function closeFd(fd) { * close(fd, (err) => { @@ -736,7 +797,7 @@ declare module 'fs' { * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail. * * ```js - * import { chmod } from 'fs'; + * import { chmod } from 'node:fs'; * * chmod('my_file.txt', 0o775, (err) => { * if (err) throw err; @@ -818,7 +879,10 @@ declare module 'fs' { * * In case of an error, the `err.code` will be one of `Common System Errors`. * - * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. + * {@link stat} follows symbolic links. Use {@link lstat} to look at the + * links themselves. + * + * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. * Instead, user code should open/read/write the file directly and handle the * error raised if the file is not available. * @@ -835,7 +899,7 @@ declare module 'fs' { * The next program will check for the stats of the given paths: * * ```js - * import { stat } from 'fs'; + * import { stat } from 'node:fs'; * * const pathsToCheck = ['./txtDir', './txtDir/file.txt']; * @@ -1081,6 +1145,72 @@ declare module 'fs' { ): Promise; function __promisify__(path: PathLike, options?: StatOptions): Promise; } + /** + * Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which + * contains `path`. The callback gets two arguments `(err, stats)` where `stats`is an `fs.StatFs` object. + * + * In case of an error, the `err.code` will be one of `Common System Errors`. + * @since v19.6.0, v18.15.0 + * @param path A path to an existing file or directory on the file system to be queried. + */ + export function statfs(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void): void; + export function statfs( + path: PathLike, + options: + | (StatFsOptions & { + bigint?: false | undefined; + }) + | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void + ): void; + export function statfs( + path: PathLike, + options: StatFsOptions & { + bigint: true; + }, + callback: (err: NodeJS.ErrnoException | null, stats: BigIntStatsFs) => void + ): void; + export function statfs(path: PathLike, options: StatFsOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs | BigIntStatsFs) => void): void; + export namespace statfs { + /** + * Asynchronous statfs(2) - Returns information about the mounted file system which contains path. The callback gets two arguments (err, stats) where stats is an object. + * @param path A path to an existing file or directory on the file system to be queried. + */ + function __promisify__( + path: PathLike, + options?: StatFsOptions & { + bigint?: false | undefined; + } + ): Promise; + function __promisify__( + path: PathLike, + options: StatFsOptions & { + bigint: true; + } + ): Promise; + function __promisify__(path: PathLike, options?: StatFsOptions): Promise; + } + /** + * Synchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which + * contains `path`. + * + * In case of an error, the `err.code` will be one of `Common System Errors`. + * @since v19.6.0, v18.15.0 + * @param path A path to an existing file or directory on the file system to be queried. + */ + export function statfsSync( + path: PathLike, + options?: StatFsOptions & { + bigint?: false | undefined; + } + ): StatsFs; + export function statfsSync( + path: PathLike, + options: StatFsOptions & { + bigint: true; + } + ): BigIntStatsFs; + export function statfsSync(path: PathLike, options?: StatFsOptions): StatsFs | BigIntStatsFs; /** * Synchronous lstat(2) - Get file status. Does not dereference symbolic links. * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. @@ -1114,14 +1244,15 @@ declare module 'fs' { * * The `type` argument is only available on Windows and ignored on other platforms. * It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is - * not set, Node.js will autodetect `target` type and use `'file'` or `'dir'`. If - * the `target` does not exist, `'file'` will be used. Windows junction points - * require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path. + * not a string, Node.js will autodetect `target` type and use `'file'` or `'dir'`. + * If the `target` does not exist, `'file'` will be used. Windows junction points + * require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path. Junction + * points on NTFS volumes can only point to directories. * - * Relative targets are relative to the link’s parent directory. + * Relative targets are relative to the link's parent directory. * * ```js - * import { symlink } from 'fs'; + * import { symlink } from 'node:fs'; * * symlink('./mew', './mewtwo', callback); * ``` @@ -1136,6 +1267,7 @@ declare module 'fs' { * └── mewtwo -> ./mew * ``` * @since v0.1.31 + * @param [type='null'] */ export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void; /** @@ -1161,6 +1293,7 @@ declare module 'fs' { * For detailed information, see the documentation of the asynchronous version of * this API: {@link symlink}. * @since v0.1.31 + * @param [type='null'] */ export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void; /** @@ -1238,7 +1371,7 @@ declare module 'fs' { */ export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer; /** - * Asynchronously computes the canonical pathname by resolving `.`, `..` and + * Asynchronously computes the canonical pathname by resolving `.`, `..`, and * symbolic links. * * A canonical pathname is not necessarily unique. Hard links and bind mounts can @@ -1352,7 +1485,7 @@ declare module 'fs' { * possible exception are given to the completion callback. * * ```js - * import { unlink } from 'fs'; + * import { unlink } from 'node:fs'; * // Assuming that 'path/file.txt' is a regular file. * unlink('path/file.txt', (err) => { * if (err) throw err; @@ -1507,7 +1640,7 @@ declare module 'fs' { * when `recursive` is false. * * ```js - * import { mkdir } from 'fs'; + * import { mkdir } from 'node:fs'; * * // Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist. * mkdir('/tmp/a/apple', { recursive: true }, (err) => { @@ -1519,7 +1652,7 @@ declare module 'fs' { * result in an error: * * ```js - * import { mkdir } from 'fs'; + * import { mkdir } from 'node:fs'; * * mkdir('/', { recursive: true }, (err) => { * // => [Error: EPERM: operation not permitted, mkdir 'C:\'] @@ -1651,9 +1784,11 @@ declare module 'fs' { * object with an `encoding` property specifying the character encoding to use. * * ```js - * import { mkdtemp } from 'fs'; + * import { mkdtemp } from 'node:fs'; + * import { join } from 'node:path'; + * import { tmpdir } from 'node:os'; * - * mkdtemp(path.join(os.tmpdir(), 'foo-'), (err, directory) => { + * mkdtemp(join(tmpdir(), 'foo-'), (err, directory) => { * if (err) throw err; * console.log(directory); * // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2 @@ -1663,11 +1798,11 @@ declare module 'fs' { * The `fs.mkdtemp()` method will append the six randomly selected characters * directly to the `prefix` string. For instance, given a directory `/tmp`, if the * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator - * (`require('path').sep`). + * (`require('node:path').sep`). * * ```js - * import { tmpdir } from 'os'; - * import { mkdtemp } from 'fs'; + * import { tmpdir } from 'node:os'; + * import { mkdtemp } from 'node:fs'; * * // The parent directory for the new temporary directory * const tmpDir = tmpdir(); @@ -1682,7 +1817,7 @@ declare module 'fs' { * }); * * // This method is *CORRECT*: - * import { sep } from 'path'; + * import { sep } from 'node:path'; * mkdtemp(`${tmpDir}${sep}`, (err, directory) => { * if (err) throw err; * console.log(directory); @@ -1781,6 +1916,7 @@ declare module 'fs' { | { encoding: BufferEncoding | null; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | BufferEncoding | undefined @@ -1798,6 +1934,7 @@ declare module 'fs' { | { encoding: 'buffer'; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | 'buffer', callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void @@ -1812,6 +1949,7 @@ declare module 'fs' { options: | (ObjectEncodingOptions & { withFileTypes?: false | undefined; + recursive?: boolean | undefined; }) | BufferEncoding | undefined @@ -1832,6 +1970,7 @@ declare module 'fs' { path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true; + recursive?: boolean | undefined; }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void ): void; @@ -1847,6 +1986,7 @@ declare module 'fs' { | { encoding: BufferEncoding | null; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | BufferEncoding | null @@ -1863,6 +2003,7 @@ declare module 'fs' { | { encoding: 'buffer'; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } ): Promise; /** @@ -1875,6 +2016,7 @@ declare module 'fs' { options?: | (ObjectEncodingOptions & { withFileTypes?: false | undefined; + recursive?: boolean | undefined; }) | BufferEncoding | null @@ -1888,6 +2030,7 @@ declare module 'fs' { path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true; + recursive?: boolean | undefined; } ): Promise; } @@ -1910,6 +2053,7 @@ declare module 'fs' { | { encoding: BufferEncoding | null; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | BufferEncoding | null @@ -1925,6 +2069,7 @@ declare module 'fs' { | { encoding: 'buffer'; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | 'buffer' ): Buffer[]; @@ -1938,6 +2083,7 @@ declare module 'fs' { options?: | (ObjectEncodingOptions & { withFileTypes?: false | undefined; + recursive?: boolean | undefined; }) | BufferEncoding | null @@ -1951,6 +2097,7 @@ declare module 'fs' { path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true; + recursive?: boolean | undefined; } ): Dirent[]; /** @@ -2010,7 +2157,6 @@ declare module 'fs' { * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. */ export function open(path: PathLike, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; - export namespace open { /** * Asynchronous open(2) - open and possibly create a file. @@ -2035,7 +2181,7 @@ declare module 'fs' { * The `atime` and `mtime` arguments follow these rules: * * * Values can be either numbers representing Unix epoch time in seconds,`Date`s, or a numeric string like `'123456789.0'`. - * * If the value can not be converted to a number, or is `NaN`, `Infinity` or`-Infinity`, an `Error` will be thrown. + * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown. * @since v0.4.2 */ export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void; @@ -2121,6 +2267,9 @@ declare module 'fs' { * The kernel ignores the position argument and always appends the data to * the end of the file. * @since v0.0.2 + * @param [offset=0] + * @param [length=buffer.byteLength - offset] + * @param [position='null'] */ export function write( fd: number, @@ -2225,6 +2374,9 @@ declare module 'fs' { * For detailed information, see the documentation of the asynchronous version of * this API: {@link write}. * @since v0.1.21 + * @param [offset=0] + * @param [length=buffer.byteLength - offset] + * @param [position='null'] * @return The number of bytes written. */ export function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number; @@ -2330,6 +2482,7 @@ declare module 'fs' { * For detailed information, see the documentation of the asynchronous version of * this API: {@link read}. * @since v0.1.21 + * @param [position='null'] */ export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: ReadPosition | null): number; /** @@ -2341,7 +2494,7 @@ declare module 'fs' { * Asynchronously reads the entire contents of a file. * * ```js - * import { readFile } from 'fs'; + * import { readFile } from 'node:fs'; * * readFile('/etc/passwd', (err, data) => { * if (err) throw err; @@ -2357,7 +2510,7 @@ declare module 'fs' { * If `options` is a string, then it specifies the encoding: * * ```js - * import { readFile } from 'fs'; + * import { readFile } from 'node:fs'; * * readFile('/etc/passwd', 'utf8', callback); * ``` @@ -2367,7 +2520,7 @@ declare module 'fs' { * will be returned. * * ```js - * import { readFile } from 'fs'; + * import { readFile } from 'node:fs'; * * // macOS, Linux, and Windows * readFile('', (err, data) => { @@ -2384,7 +2537,7 @@ declare module 'fs' { * request is aborted the callback is called with an `AbortError`: * * ```js - * import { readFile } from 'fs'; + * import { readFile } from 'node:fs'; * * const controller = new AbortController(); * const signal = controller.signal; @@ -2517,7 +2670,7 @@ declare module 'fs' { * Similar to {@link readFile}, when the path is a directory, the behavior of`fs.readFileSync()` is platform-specific. * * ```js - * import { readFileSync } from 'fs'; + * import { readFileSync } from 'node:fs'; * * // macOS, Linux, and Windows * readFileSync(''); @@ -2588,8 +2741,8 @@ declare module 'fs' { * The `mode` option only affects the newly created file. See {@link open} for more details. * * ```js - * import { writeFile } from 'fs'; - * import { Buffer } from 'buffer'; + * import { writeFile } from 'node:fs'; + * import { Buffer } from 'node:buffer'; * * const data = new Uint8Array(Buffer.from('Hello Node.js')); * writeFile('message.txt', data, (err) => { @@ -2601,7 +2754,7 @@ declare module 'fs' { * If `options` is a string, then it specifies the encoding: * * ```js - * import { writeFile } from 'fs'; + * import { writeFile } from 'node:fs'; * * writeFile('message.txt', 'Hello Node.js', 'utf8', callback); * ``` @@ -2619,8 +2772,8 @@ declare module 'fs' { * to be written. * * ```js - * import { writeFile } from 'fs'; - * import { Buffer } from 'buffer'; + * import { writeFile } from 'node:fs'; + * import { Buffer } from 'node:buffer'; * * const controller = new AbortController(); * const { signal } = controller; @@ -2678,7 +2831,7 @@ declare module 'fs' { * The `mode` option only affects the newly created file. See {@link open} for more details. * * ```js - * import { appendFile } from 'fs'; + * import { appendFile } from 'node:fs'; * * appendFile('message.txt', 'data to append', (err) => { * if (err) throw err; @@ -2689,7 +2842,7 @@ declare module 'fs' { * If `options` is a string, then it specifies the encoding: * * ```js - * import { appendFile } from 'fs'; + * import { appendFile } from 'node:fs'; * * appendFile('message.txt', 'data to append', 'utf8', callback); * ``` @@ -2699,7 +2852,7 @@ declare module 'fs' { * not be closed automatically. * * ```js - * import { open, close, appendFile } from 'fs'; + * import { open, close, appendFile } from 'node:fs'; * * function closeFd(fd) { * close(fd, (err) => { @@ -2754,7 +2907,7 @@ declare module 'fs' { * The `mode` option only affects the newly created file. See {@link open} for more details. * * ```js - * import { appendFileSync } from 'fs'; + * import { appendFileSync } from 'node:fs'; * * try { * appendFileSync('message.txt', 'data to append'); @@ -2767,7 +2920,7 @@ declare module 'fs' { * If `options` is a string, then it specifies the encoding: * * ```js - * import { appendFileSync } from 'fs'; + * import { appendFileSync } from 'node:fs'; * * appendFileSync('message.txt', 'data to append', 'utf8'); * ``` @@ -2777,7 +2930,7 @@ declare module 'fs' { * not be closed automatically. * * ```js - * import { openSync, closeSync, appendFileSync } from 'fs'; + * import { openSync, closeSync, appendFileSync } from 'node:fs'; * * let fd; * @@ -2859,7 +3012,7 @@ declare module 'fs' { * stat object: * * ```js - * import { watchFile } from 'fs'; + * import { watchFile } from 'node:fs'; * * watchFile('message.text', (curr, prev) => { * console.log(`the current mtime is: ${curr.mtime}`); @@ -2899,7 +3052,7 @@ declare module 'fs' { bigint?: false | undefined; }) | undefined, - listener: (curr: Stats, prev: Stats) => void + listener: StatsListener ): StatWatcher; export function watchFile( filename: PathLike, @@ -2908,13 +3061,13 @@ declare module 'fs' { bigint: true; }) | undefined, - listener: (curr: BigIntStats, prev: BigIntStats) => void + listener: BigIntStatsListener ): StatWatcher; /** * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed. * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. */ - export function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): StatWatcher; + export function watchFile(filename: PathLike, listener: StatsListener): StatWatcher; /** * Stop watching for changes on `filename`. If `listener` is specified, only that * particular listener is removed. Otherwise, _all_ listeners are removed, @@ -2927,7 +3080,8 @@ declare module 'fs' { * @since v0.1.31 * @param listener Optional, a listener previously attached using `fs.watchFile()` */ - export function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void; + export function unwatchFile(filename: PathLike, listener?: StatsListener): void; + export function unwatchFile(filename: PathLike, listener?: BigIntStatsListener): void; export interface WatchOptions extends Abortable { encoding?: BufferEncoding | 'buffer' | undefined; persistent?: boolean | undefined; @@ -2935,6 +3089,8 @@ declare module 'fs' { } export type WatchEventType = 'rename' | 'change'; export type WatchListener = (event: WatchEventType, filename: T) => void; + export type StatsListener = (curr: Stats, prev: Stats) => void; + export type BigIntStatsListener = (curr: BigIntStats, prev: BigIntStats) => void; /** * Watch for changes on `filename`, where `filename` is either a file or a * directory. @@ -2992,7 +3148,7 @@ declare module 'fs' { * Then call the `callback` argument with either true or false: * * ```js - * import { exists } from 'fs'; + * import { exists } from 'node:fs'; * * exists('/etc/passwd', (e) => { * console.log(e ? 'it exists' : 'no passwd!'); @@ -3004,7 +3160,7 @@ declare module 'fs' { * has only one boolean parameter. This is one reason `fs.access()` is recommended * instead of `fs.exists()`. * - * Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. Doing + * Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. Doing * so introduces a race condition, since other processes may change the file's * state between the two calls. Instead, user code should open/read/write the * file directly and handle the error raised if the file does not exist. @@ -3012,7 +3168,7 @@ declare module 'fs' { * **write (NOT RECOMMENDED)** * * ```js - * import { exists, open, close } from 'fs'; + * import { exists, open, close } from 'node:fs'; * * exists('myfile', (e) => { * if (e) { @@ -3036,7 +3192,7 @@ declare module 'fs' { * **write (RECOMMENDED)** * * ```js - * import { open, close } from 'fs'; + * import { open, close } from 'node:fs'; * open('myfile', 'wx', (err, fd) => { * if (err) { * if (err.code === 'EEXIST') { @@ -3060,7 +3216,7 @@ declare module 'fs' { * **read (NOT RECOMMENDED)** * * ```js - * import { open, close, exists } from 'fs'; + * import { open, close, exists } from 'node:fs'; * * exists('myfile', (e) => { * if (e) { @@ -3084,7 +3240,7 @@ declare module 'fs' { * **read (RECOMMENDED)** * * ```js - * import { open, close } from 'fs'; + * import { open, close } from 'node:fs'; * * open('myfile', 'r', (err, fd) => { * if (err) { @@ -3110,7 +3266,7 @@ declare module 'fs' { * file; the "recommended" examples are better because they use the file directly * and handle the error, if any. * - * In general, check for the existence of a file only if the file won’t be + * In general, check for the existence of a file only if the file won't be * used directly, for example when its existence is a signal from another * process. * @since v0.0.2 @@ -3135,7 +3291,7 @@ declare module 'fs' { * Node.js callbacks. `fs.existsSync()` does not use a callback. * * ```js - * import { existsSync } from 'fs'; + * import { existsSync } from 'node:fs'; * * if (existsSync('/etc/passwd')) * console.log('The path exists.'); @@ -3269,7 +3425,7 @@ declare module 'fs' { * argument will be an `Error` object. The following examples check if`package.json` exists, and if it is readable or writable. * * ```js - * import { access, constants } from 'fs'; + * import { access, constants } from 'node:fs'; * * const file = 'package.json'; * @@ -3294,7 +3450,7 @@ declare module 'fs' { * }); * ``` * - * Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()`. Doing + * Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()`. Doing * so introduces a race condition, since other processes may change the file's * state between the two calls. Instead, user code should open/read/write the * file directly and handle the error raised if the file is not accessible. @@ -3302,7 +3458,7 @@ declare module 'fs' { * **write (NOT RECOMMENDED)** * * ```js - * import { access, open, close } from 'fs'; + * import { access, open, close } from 'node:fs'; * * access('myfile', (err) => { * if (!err) { @@ -3327,7 +3483,7 @@ declare module 'fs' { * **write (RECOMMENDED)** * * ```js - * import { open, close } from 'fs'; + * import { open, close } from 'node:fs'; * * open('myfile', 'wx', (err, fd) => { * if (err) { @@ -3352,7 +3508,7 @@ declare module 'fs' { * **read (NOT RECOMMENDED)** * * ```js - * import { access, open, close } from 'fs'; + * import { access, open, close } from 'node:fs'; * access('myfile', (err) => { * if (err) { * if (err.code === 'ENOENT') { @@ -3380,7 +3536,7 @@ declare module 'fs' { * **read (RECOMMENDED)** * * ```js - * import { open, close } from 'fs'; + * import { open, close } from 'node:fs'; * * open('myfile', 'r', (err, fd) => { * if (err) { @@ -3442,7 +3598,7 @@ declare module 'fs' { * the method will return `undefined`. * * ```js - * import { accessSync, constants } from 'fs'; + * import { accessSync, constants } from 'node:fs'; * * try { * accessSync('etc/passwd', constants.R_OK | constants.W_OK); @@ -3472,8 +3628,8 @@ declare module 'fs' { end?: number | undefined; } /** - * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream - * returned by this method has a default `highWaterMark` of 64 kb. + * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream + * returned by this method has a default `highWaterMark` of 64 KiB. * * `options` can include `start` and `end` values to read a range of bytes from * the file instead of the entire file. Both `start` and `end` are inclusive and @@ -3499,7 +3655,7 @@ declare module 'fs' { * also required. * * ```js - * import { createReadStream } from 'fs'; + * import { createReadStream } from 'node:fs'; * * // Create a stream from some character device. * const stream = createReadStream('/dev/input/event0'); @@ -3527,7 +3683,7 @@ declare module 'fs' { * An example to read the last 10 bytes of a file which is 100 bytes long: * * ```js - * import { createReadStream } from 'fs'; + * import { createReadStream } from 'node:fs'; * * createReadStream('sample.txt', { start: 90, end: 99 }); * ``` @@ -3551,7 +3707,7 @@ declare module 'fs' { * By default, the stream will emit a `'close'` event after it has been * destroyed. Set the `emitClose` option to `false` to change this behavior. * - * By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev` and `close`. Overriding `write()`without `writev()` can reduce + * By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev`, and `close`. Overriding `write()`without `writev()` can reduce * performance as some optimizations (`_writev()`) * will be disabled. When providing the `fs` option, overrides for at least one of`write` and `writev` are required. If no `fd` option is supplied, an override * for `open` is also required. If `autoClose` is `true`, an override for `close`is also required. @@ -3606,7 +3762,7 @@ declare module 'fs' { * copy-on-write, then the operation will fail. * * ```js - * import { copyFile, constants } from 'fs'; + * import { copyFile, constants } from 'node:fs'; * * function callback(err) { * if (err) throw err; @@ -3649,7 +3805,7 @@ declare module 'fs' { * copy-on-write, then the operation will fail. * * ```js - * import { copyFileSync, constants } from 'fs'; + * import { copyFileSync, constants } from 'node:fs'; * * // destination.txt will be created or overwritten by default. * copyFileSync('source.txt', 'destination.txt'); @@ -3682,6 +3838,7 @@ declare module 'fs' { * The kernel ignores the position argument and always appends the data to * the end of the file. * @since v12.9.0 + * @param [position='null'] */ export function writev(fd: number, buffers: ReadonlyArray, cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void; export function writev( @@ -3701,6 +3858,7 @@ declare module 'fs' { * For detailed information, see the documentation of the asynchronous version of * this API: {@link writev}. * @since v12.9.0 + * @param [position='null'] * @return The number of bytes written. */ export function writevSync(fd: number, buffers: ReadonlyArray, position?: number): number; @@ -3717,6 +3875,7 @@ declare module 'fs' { * If this method is invoked as its `util.promisify()` ed version, it returns * a promise for an `Object` with `bytesRead` and `buffers` properties. * @since v13.13.0, v12.17.0 + * @param [position='null'] */ export function readv(fd: number, buffers: ReadonlyArray, cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void): void; export function readv( @@ -3736,10 +3895,14 @@ declare module 'fs' { * For detailed information, see the documentation of the asynchronous version of * this API: {@link readv}. * @since v13.13.0, v12.17.0 + * @param [position='null'] * @return The number of bytes read. */ export function readvSync(fd: number, buffers: ReadonlyArray, position?: number): number; export interface OpenDirOptions { + /** + * @default 'utf8' + */ encoding?: BufferEncoding | undefined; /** * Number of directory entries that are buffered @@ -3748,6 +3911,10 @@ declare module 'fs' { * @default 32 */ bufferSize?: number | undefined; + /** + * @default false + */ + recursive?: boolean; } /** * Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html). @@ -3810,6 +3977,10 @@ declare module 'fs' { * @default true */ force?: boolean; + /** + * Modifiers for copy operation. See `mode` flag of {@link copyFileSync()} + */ + mode?: number; /** * When `true` timestamps from `src` will * be preserved. diff --git a/node_modules/@types/node/fs/promises.d.ts b/node_modules/@types/node/fs/promises.d.ts index 9d0b5f109..70560a95b 100755 --- a/node_modules/@types/node/fs/promises.d.ts +++ b/node_modules/@types/node/fs/promises.d.ts @@ -14,6 +14,7 @@ declare module 'fs/promises' { import { ReadableStream } from 'node:stream/web'; import { BigIntStats, + BigIntStatsFs, BufferEncodingOption, constants as fsConstants, CopyOptions, @@ -30,14 +31,16 @@ declare module 'fs/promises' { RmDirOptions, RmOptions, StatOptions, + StatFsOptions, Stats, + StatsFs, TimeLike, WatchEventType, WatchOptions, WriteStream, WriteVResult, } from 'node:fs'; - + import { Interface as ReadlineInterface } from 'node:readline'; interface FileChangeInfo { eventType: WatchEventType; filename: T; @@ -111,8 +114,8 @@ declare module 'fs/promises' { */ chmod(mode: Mode): Promise; /** - * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream - * returned by this method has a default `highWaterMark` of 64 kb. + * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream + * returned by this method has a default `highWaterMark` of 64 KiB. * * `options` can include `start` and `end` values to read a range of bytes from * the file instead of the entire file. Both `start` and `end` are inclusive and @@ -130,7 +133,7 @@ declare module 'fs/promises' { * destroyed. Set the `emitClose` option to `false` to change this behavior. * * ```js - * import { open } from 'fs/promises'; + * import { open } from 'node:fs/promises'; * * const fd = await open('/dev/input/event0'); * // Create a stream from some character device. @@ -156,7 +159,7 @@ declare module 'fs/promises' { * An example to read the last 10 bytes of a file which is 100 bytes long: * * ```js - * import { open } from 'fs/promises'; + * import { open } from 'node:fs/promises'; * * const fd = await open('sample.txt'); * fd.createReadStream({ start: 90, end: 99 }); @@ -195,7 +198,7 @@ declare module 'fs/promises' { * device. The specific implementation is operating system and device specific. * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. * @since v10.0.0 - * @return Fufills with `undefined` upon success. + * @return Fulfills with `undefined` upon success. */ sync(): Promise; /** @@ -216,11 +219,13 @@ declare module 'fs/promises' { /** * Returns a `ReadableStream` that may be used to read the files data. * - * An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed - * or closing. + * An error will be thrown if this method is called more than once or is called + * after the `FileHandle` is closed or closing. * * ```js - * import { open } from 'node:fs/promises'; + * import { + * open, + * } from 'node:fs/promises'; * * const file = await open('./some/file/to/read'); * @@ -230,8 +235,8 @@ declare module 'fs/promises' { * await file.close(); * ``` * - * While the `ReadableStream` will read the file to completion, it will not close the `FileHandle` automatically. User code must still call the `fileHandle.close()` method. - * + * While the `ReadableStream` will read the file to completion, it will not + * close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method. * @since v17.0.0 * @experimental */ @@ -284,6 +289,22 @@ declare module 'fs/promises' { | BufferEncoding | null ): Promise; + /** + * Convenience method to create a `readline` interface and stream over the file. + * See `filehandle.createReadStream()` for the options. + * + * ```js + * import { open } from 'node:fs/promises'; + * + * const file = await open('./some/file/to/read'); + * + * for await (const line of file.readLines()) { + * console.log(line); + * } + * ``` + * @since v18.11.0 + */ + readLines(options?: CreateReadStreamOptions): ReadlineInterface; /** * @since v10.0.0 * @return Fulfills with an {fs.Stats} for the file. @@ -308,7 +329,7 @@ declare module 'fs/promises' { * The following example retains only the first four bytes of the file: * * ```js - * import { open } from 'fs/promises'; + * import { open } from 'node:fs/promises'; * * let filehandle = null; * try { @@ -335,7 +356,7 @@ declare module 'fs/promises' { utimes(atime: TimeLike, mtime: TimeLike): Promise; /** * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an - * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or + * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object. * The promise is resolved with no arguments upon success. * @@ -365,10 +386,10 @@ declare module 'fs/promises' { * The kernel ignores the position argument and always appends the data to * the end of the file. * @since v10.0.0 - * @param [offset=0] The start position from within `buffer` where the data to write begins. + * @param offset The start position from within `buffer` where the data to write begins. * @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write. - * @param position The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current position. - * See the POSIX pwrite(2) documentation for more detail. + * @param [position='null'] The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current + * position. See the POSIX pwrite(2) documentation for more detail. */ write( buffer: TBuffer, @@ -399,14 +420,14 @@ declare module 'fs/promises' { * The kernel ignores the position argument and always appends the data to * the end of the file. * @since v12.9.0 - * @param position The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current + * @param [position='null'] The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current * position. */ writev(buffers: ReadonlyArray, position?: number): Promise; /** * Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s * @since v13.13.0, v12.17.0 - * @param position The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position. + * @param [position='null'] The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position. * @return Fulfills upon success an object containing two properties: */ readv(buffers: ReadonlyArray, position?: number): Promise; @@ -415,7 +436,7 @@ declare module 'fs/promises' { * complete. * * ```js - * import { open } from 'fs/promises'; + * import { open } from 'node:fs/promises'; * * let filehandle; * try { @@ -429,9 +450,7 @@ declare module 'fs/promises' { */ close(): Promise; } - const constants: typeof fsConstants; - /** * Tests a user's permissions for the file or directory specified by `path`. * The `mode` argument is an optional integer that specifies the accessibility @@ -445,8 +464,7 @@ declare module 'fs/promises' { * written by the current process. * * ```js - * import { access } from 'fs/promises'; - * import { constants } from 'fs'; + * import { access, constants } from 'node:fs/promises'; * * try { * await access('/etc/passwd', constants.R_OK | constants.W_OK); @@ -475,14 +493,13 @@ declare module 'fs/promises' { * will be made to remove the destination. * * ```js - * import { constants } from 'fs'; - * import { copyFile } from 'fs/promises'; + * import { copyFile, constants } from 'node:fs/promises'; * * try { * await copyFile('source.txt', 'destination.txt'); * console.log('source.txt was copied to destination.txt'); * } catch { - * console.log('The file could not be copied'); + * console.error('The file could not be copied'); * } * * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists. @@ -490,7 +507,7 @@ declare module 'fs/promises' { * await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL); * console.log('source.txt was copied to destination.txt'); * } catch { - * console.log('The file could not be copied'); + * console.error('The file could not be copied'); * } * ``` * @since v10.0.0 @@ -552,6 +569,19 @@ declare module 'fs/promises' { * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fsPromises.mkdir()` when `path` is a directory * that exists results in a * rejection only when `recursive` is false. + * + * ```js + * import { mkdir } from 'node:fs/promises'; + * + * try { + * const projectFolder = new URL('./test/project/', import.meta.url); + * const createDir = await mkdir(projectFolder, { recursive: true }); + * + * console.log(`created ${createDir}`); + * } catch (err) { + * console.error(err.message); + * } + * ``` * @since v10.0.0 * @return Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`. */ @@ -594,7 +624,7 @@ declare module 'fs/promises' { * If `options.withFileTypes` is set to `true`, the resolved array will contain `fs.Dirent` objects. * * ```js - * import { readdir } from 'fs/promises'; + * import { readdir } from 'node:fs/promises'; * * try { * const files = await readdir(path); @@ -612,6 +642,7 @@ declare module 'fs/promises' { options?: | (ObjectEncodingOptions & { withFileTypes?: false | undefined; + recursive?: boolean | undefined; }) | BufferEncoding | null @@ -627,6 +658,7 @@ declare module 'fs/promises' { | { encoding: 'buffer'; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | 'buffer' ): Promise; @@ -640,6 +672,7 @@ declare module 'fs/promises' { options?: | (ObjectEncodingOptions & { withFileTypes?: false | undefined; + recursive?: boolean | undefined; }) | BufferEncoding | null @@ -653,6 +686,7 @@ declare module 'fs/promises' { path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true; + recursive?: boolean | undefined; } ): Promise; /** @@ -682,11 +716,14 @@ declare module 'fs/promises' { /** * Creates a symbolic link. * - * The `type` argument is only used on Windows platforms and can be one of `'dir'`,`'file'`, or `'junction'`. Windows junction points require the destination path - * to be absolute. When using `'junction'`, the `target` argument will - * automatically be normalized to absolute path. + * The `type` argument is only used on Windows platforms and can be one of `'dir'`,`'file'`, or `'junction'`. If the `type` argument is not a string, Node.js will + * autodetect `target` type and use `'file'` or `'dir'`. If the `target` does not + * exist, `'file'` will be used. Windows junction points require the destination + * path to be absolute. When using `'junction'`, the `target` argument will + * automatically be normalized to absolute path. Junction points on NTFS volumes + * can only point to directories. * @since v10.0.0 - * @param [type='file'] + * @param [type='null'] * @return Fulfills with `undefined` upon success. */ function symlink(target: PathLike, path: PathLike, type?: string | null): Promise; @@ -727,6 +764,23 @@ declare module 'fs/promises' { } ): Promise; function stat(path: PathLike, opts?: StatOptions): Promise; + /** + * @since v19.6.0, v18.15.0 + * @return Fulfills with the {fs.StatFs} object for the given `path`. + */ + function statfs( + path: PathLike, + opts?: StatFsOptions & { + bigint?: false | undefined; + } + ): Promise; + function statfs( + path: PathLike, + opts: StatFsOptions & { + bigint: true; + } + ): Promise; + function statfs(path: PathLike, opts?: StatFsOptions): Promise; /** * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. * @since v10.0.0 @@ -782,7 +836,7 @@ declare module 'fs/promises' { * * * Values can be either numbers representing Unix epoch time, `Date`s, or a * numeric string like `'123456789.0'`. - * * If the value can not be converted to a number, or is `NaN`, `Infinity` or`-Infinity`, an `Error` will be thrown. + * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown. * @since v10.0.0 * @return Fulfills with `undefined` upon success. */ @@ -827,10 +881,12 @@ declare module 'fs/promises' { * object with an `encoding` property specifying the character encoding to use. * * ```js - * import { mkdtemp } from 'fs/promises'; + * import { mkdtemp } from 'node:fs/promises'; + * import { join } from 'node:path'; + * import { tmpdir } from 'node:os'; * * try { - * await mkdtemp(path.join(os.tmpdir(), 'foo-')); + * await mkdtemp(join(tmpdir(), 'foo-')); * } catch (err) { * console.error(err); * } @@ -839,9 +895,9 @@ declare module 'fs/promises' { * The `fsPromises.mkdtemp()` method will append the six randomly selected * characters directly to the `prefix` string. For instance, given a directory`/tmp`, if the intention is to create a temporary directory _within_`/tmp`, the`prefix` must end with a trailing * platform-specific path separator - * (`require('path').sep`). + * (`require('node:path').sep`). * @since v10.0.0 - * @return Fulfills with a string containing the filesystem path of the newly created temporary directory. + * @return Fulfills with a string containing the file system path of the newly created temporary directory. */ function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; /** @@ -858,7 +914,7 @@ declare module 'fs/promises' { function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; /** * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an - * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or + * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object. * * The `encoding` option is ignored if `data` is a buffer. @@ -881,8 +937,8 @@ declare module 'fs/promises' { * to be written. * * ```js - * import { writeFile } from 'fs/promises'; - * import { Buffer } from 'buffer'; + * import { writeFile } from 'node:fs/promises'; + * import { Buffer } from 'node:buffer'; * * try { * const controller = new AbortController(); @@ -945,11 +1001,25 @@ declare module 'fs/promises' { * with an error. On FreeBSD, a representation of the directory's contents will be * returned. * + * An example of reading a `package.json` file located in the same directory of the + * running code: + * + * ```js + * import { readFile } from 'node:fs/promises'; + * try { + * const filePath = new URL('./package.json', import.meta.url); + * const contents = await readFile(filePath, { encoding: 'utf8' }); + * console.log(contents); + * } catch (err) { + * console.error(err.message); + * } + * ``` + * * It is possible to abort an ongoing `readFile` using an `AbortSignal`. If a * request is aborted the promise returned is rejected with an `AbortError`: * * ```js - * import { readFile } from 'fs/promises'; + * import { readFile } from 'node:fs/promises'; * * try { * const controller = new AbortController(); @@ -1028,7 +1098,7 @@ declare module 'fs/promises' { * Example using async iteration: * * ```js - * import { opendir } from 'fs/promises'; + * import { opendir } from 'node:fs/promises'; * * try { * const dir = await opendir('./'); @@ -1049,7 +1119,7 @@ declare module 'fs/promises' { * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory. * * ```js - * const { watch } = require('fs/promises'); + * const { watch } = require('node:fs/promises'); * * const ac = new AbortController(); * const { signal } = ac; diff --git a/node_modules/@types/node/globals.d.ts b/node_modules/@types/node/globals.d.ts index 903786116..7414561da 100755 --- a/node_modules/@types/node/globals.d.ts +++ b/node_modules/@types/node/globals.d.ts @@ -53,28 +53,35 @@ interface AbortController { /** * Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted. */ - abort(): void; + abort(reason?: any): void; } /** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */ -interface AbortSignal { +interface AbortSignal extends EventTarget { /** * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */ readonly aborted: boolean; + readonly reason: any; + onabort: null | ((this: AbortSignal, event: Event) => any); + throwIfAborted(): void; } -declare var AbortController: { - prototype: AbortController; - new(): AbortController; -}; - -declare var AbortSignal: { - prototype: AbortSignal; - new(): AbortSignal; - // TODO: Add abort() static - timeout(milliseconds: number): AbortSignal; -}; +declare var AbortController: typeof globalThis extends {onmessage: any; AbortController: infer T} + ? T + : { + prototype: AbortController; + new(): AbortController; + }; + +declare var AbortSignal: typeof globalThis extends {onmessage: any; AbortSignal: infer T} + ? T + : { + prototype: AbortSignal; + new(): AbortSignal; + abort(reason?: any): AbortSignal; + timeout(milliseconds: number): AbortSignal; + }; //#endregion borrowed //#region ArrayLike.at() @@ -153,7 +160,7 @@ declare namespace NodeJS { /** * Name of the script [if this function was defined in a script] */ - getFileName(): string | null; + getFileName(): string | undefined; /** * Current line number [if this function was defined in a script] diff --git a/node_modules/@types/node/http.d.ts b/node_modules/@types/node/http.d.ts index 24bc5e78d..cb5033575 100755 --- a/node_modules/@types/node/http.d.ts +++ b/node_modules/@types/node/http.d.ts @@ -1,5 +1,5 @@ /** - * To use the HTTP server and client one must `require('http')`. + * To use the HTTP server and client one must `require('node:http')`. * * The HTTP interfaces in Node.js are designed to support many features * of the protocol which have been traditionally difficult to use. @@ -37,11 +37,13 @@ * 'Host', 'example.com', * 'accepT', '*' ] * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http.js) */ declare module 'http' { import * as stream from 'node:stream'; import { URL } from 'node:url'; + import { LookupOptions } from 'node:dns'; + import { EventEmitter } from 'node:events'; import { TcpSocketConnectOpts, Socket, Server as NetServer, LookupFunction } from 'node:net'; // incoming headers will never contain number interface IncomingHttpHeaders extends NodeJS.Dict { @@ -113,56 +115,101 @@ declare module 'http' { type OutgoingHttpHeader = number | string | string[]; interface OutgoingHttpHeaders extends NodeJS.Dict {} interface ClientRequestArgs { - signal?: AbortSignal | undefined; - protocol?: string | null | undefined; + _defaultAgent?: Agent | undefined; + agent?: Agent | boolean | undefined; + auth?: string | null | undefined; + // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278 + createConnection?: + | ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket) + | undefined; + defaultPort?: number | string | undefined; + family?: number | undefined; + headers?: OutgoingHttpHeaders | undefined; + hints?: LookupOptions['hints']; host?: string | null | undefined; hostname?: string | null | undefined; - family?: number | undefined; - port?: number | string | null | undefined; - defaultPort?: number | string | undefined; + insecureHTTPParser?: boolean | undefined; localAddress?: string | undefined; - socketPath?: string | undefined; + localPort?: number | undefined; + lookup?: LookupFunction | undefined; /** - * @default 8192 + * @default 16384 */ maxHeaderSize?: number | undefined; method?: string | undefined; path?: string | null | undefined; - headers?: OutgoingHttpHeaders | undefined; - auth?: string | null | undefined; - agent?: Agent | boolean | undefined; - _defaultAgent?: Agent | undefined; - timeout?: number | undefined; + port?: number | string | null | undefined; + protocol?: string | null | undefined; setHost?: boolean | undefined; - // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278 - createConnection?: - | ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket) - | undefined; - lookup?: LookupFunction | undefined; + signal?: AbortSignal | undefined; + socketPath?: string | undefined; + timeout?: number | undefined; + uniqueHeaders?: Array | undefined; + joinDuplicateHeaders?: boolean; } interface ServerOptions< Request extends typeof IncomingMessage = typeof IncomingMessage, Response extends typeof ServerResponse = typeof ServerResponse, > { + /** + * Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`. + */ IncomingMessage?: Request | undefined; + /** + * Specifies the `ServerResponse` class to be used. Useful for extending the original `ServerResponse`. + */ ServerResponse?: Response | undefined; /** - * Optionally overrides the value of - * `--max-http-header-size` for requests received by this server, i.e. - * the maximum length of request headers in bytes. - * @default 8192 + * Sets the timeout value in milliseconds for receiving the entire request from the client. + * @see Server.requestTimeout for more information. + * @default 300000 + * @since v18.0.0 */ - maxHeaderSize?: number | undefined; + requestTimeout?: number | undefined; + /** + * It joins the field line values of multiple headers in a request with `, ` instead of discarding the duplicates. + * @default false + * @since v18.14.0 + */ + joinDuplicateHeaders?: boolean; + /** + * The number of milliseconds of inactivity a server needs to wait for additional incoming data, + * after it has finished writing the last response, before a socket will be destroyed. + * @see Server.keepAliveTimeout for more information. + * @default 5000 + * @since v18.0.0 + */ + keepAliveTimeout?: number | undefined; + /** + * Sets the interval value in milliseconds to check for request and headers timeout in incomplete requests. + * @default 30000 + */ + connectionsCheckingInterval?: number | undefined; + /** + * Optionally overrides all `socket`s' `readableHighWaterMark` and `writableHighWaterMark`. + * This affects `highWaterMark` property of both `IncomingMessage` and `ServerResponse`. + * Default: @see stream.getDefaultHighWaterMark(). + * @since v20.1.0 + */ + highWaterMark?: number | undefined; /** - * Use an insecure HTTP parser that accepts invalid HTTP headers when true. + * Use an insecure HTTP parser that accepts invalid HTTP headers when `true`. * Using the insecure parser should be avoided. * See --insecure-http-parser for more information. * @default false */ insecureHTTPParser?: boolean | undefined; + /** + * Optionally overrides the value of + * `--max-http-header-size` for requests received by this server, i.e. + * the maximum length of request headers in bytes. + * @default 16384 + * @since v13.3.0 + */ + maxHeaderSize?: number | undefined; /** * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received. - * @default false + * @default true * @since v16.5.0 */ noDelay?: boolean | undefined; @@ -179,6 +226,11 @@ declare module 'http' { * @since v16.5.0 */ keepAliveInitialDelay?: number | undefined; + /** + * A list of response headers that should be sent only once. + * If the header's value is an array, the items will be joined using `; `. + */ + uniqueHeaders?: Array | undefined; } type RequestListener< Request extends typeof IncomingMessage = typeof IncomingMessage, @@ -285,7 +337,8 @@ declare module 'http' { */ closeAllConnections(): void; /** - * Closes all connections connected to this server which are not sending a request or waiting for a response. + * Closes all connections connected to this server which are not sending a request + * or waiting for a response. * @since v18.2.0 */ closeIdleConnections(): void; @@ -297,15 +350,10 @@ declare module 'http' { addListener(event: 'checkContinue', listener: RequestListener): this; addListener(event: 'checkExpectation', listener: RequestListener): this; addListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this; - addListener( - event: 'connect', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + addListener(event: 'connect', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + addListener(event: 'dropRequest', listener: (req: InstanceType, socket: stream.Duplex) => void): this; addListener(event: 'request', listener: RequestListener): this; - addListener( - event: 'upgrade', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + addListener(event: 'upgrade', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; emit(event: string, ...args: any[]): boolean; emit(event: 'close'): boolean; emit(event: 'connection', socket: Socket): boolean; @@ -323,6 +371,7 @@ declare module 'http' { ): boolean; emit(event: 'clientError', err: Error, socket: stream.Duplex): boolean; emit(event: 'connect', req: InstanceType, socket: stream.Duplex, head: Buffer): boolean; + emit(event: 'dropRequest', req: InstanceType, socket: stream.Duplex): boolean; emit( event: 'request', req: InstanceType, @@ -338,6 +387,7 @@ declare module 'http' { on(event: 'checkExpectation', listener: RequestListener): this; on(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this; on(event: 'connect', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + on(event: 'dropRequest', listener: (req: InstanceType, socket: stream.Duplex) => void): this; on(event: 'request', listener: RequestListener): this; on(event: 'upgrade', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; once(event: string, listener: (...args: any[]) => void): this; @@ -348,15 +398,10 @@ declare module 'http' { once(event: 'checkContinue', listener: RequestListener): this; once(event: 'checkExpectation', listener: RequestListener): this; once(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this; - once( - event: 'connect', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + once(event: 'connect', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + once(event: 'dropRequest', listener: (req: InstanceType, socket: stream.Duplex) => void): this; once(event: 'request', listener: RequestListener): this; - once( - event: 'upgrade', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + once(event: 'upgrade', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: 'close', listener: () => void): this; prependListener(event: 'connection', listener: (socket: Socket) => void): this; @@ -365,15 +410,10 @@ declare module 'http' { prependListener(event: 'checkContinue', listener: RequestListener): this; prependListener(event: 'checkExpectation', listener: RequestListener): this; prependListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this; - prependListener( - event: 'connect', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + prependListener(event: 'connect', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + prependListener(event: 'dropRequest', listener: (req: InstanceType, socket: stream.Duplex) => void): this; prependListener(event: 'request', listener: RequestListener): this; - prependListener( - event: 'upgrade', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + prependListener(event: 'upgrade', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: 'close', listener: () => void): this; prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this; @@ -382,19 +422,14 @@ declare module 'http' { prependOnceListener(event: 'checkContinue', listener: RequestListener): this; prependOnceListener(event: 'checkExpectation', listener: RequestListener): this; prependOnceListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this; - prependOnceListener( - event: 'connect', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + prependOnceListener(event: 'connect', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + prependOnceListener(event: 'dropRequest', listener: (req: InstanceType, socket: stream.Duplex) => void): this; prependOnceListener(event: 'request', listener: RequestListener): this; - prependOnceListener( - event: 'upgrade', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + prependOnceListener(event: 'upgrade', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; } /** - * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract of outgoing message from - * the perspective of the participants of HTTP transaction. + * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract outgoing message from + * the perspective of the participants of an HTTP transaction. * @since v0.1.17 */ class OutgoingMessage extends stream.Writable { @@ -413,7 +448,7 @@ declare module 'http' { */ readonly headersSent: boolean; /** - * Aliases of `outgoingMessage.socket` + * Alias of `outgoingMessage.socket`. * @since v0.3.0 * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead. */ @@ -434,15 +469,33 @@ declare module 'http' { */ setTimeout(msecs: number, callback?: () => void): this; /** - * Sets a single header value for the header object. + * Sets a single header value. If the header already exists in the to-be-sent + * headers, its value will be replaced. Use an array of strings to send multiple + * headers with the same name. * @since v0.4.0 * @param name Header name * @param value Header value */ setHeader(name: string, value: number | string | ReadonlyArray): this; /** - * Gets the value of HTTP header with the given name. If such a name doesn't - * exist in message, it will be `undefined`. + * Append a single header value for the header object. + * + * If the value is an array, this is equivalent of calling this method multiple + * times. + * + * If there were no previous value for the header, this is equivalent of calling `outgoingMessage.setHeader(name, value)`. + * + * Depending of the value of `options.uniqueHeaders` when the client request or the + * server were created, this will end up in the header being sent multiple times or + * a single time with values joined using `; `. + * @since v18.3.0, v16.17.0 + * @param name Header name + * @param value Header value + */ + appendHeader(name: string, value: string | ReadonlyArray): this; + /** + * Gets the value of the HTTP header with the given name. If that header is not + * set, the returned value will be `undefined`. * @since v0.4.0 * @param name Name of header */ @@ -455,8 +508,8 @@ declare module 'http' { * values. All header names are lowercase. * * The object returned by the `outgoingMessage.getHeaders()` method does - * not prototypically inherit from the JavaScript Object. This means that - * typical Object methods such as `obj.toString()`, `obj.hasOwnProperty()`, + * not prototypically inherit from the JavaScript `Object`. This means that + * typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`, * and others are not defined and will not work. * * ```js @@ -470,8 +523,8 @@ declare module 'http' { */ getHeaders(): OutgoingHttpHeaders; /** - * Returns an array of names of headers of the outgoing outgoingMessage. All - * names are lowercase. + * Returns an array containing the unique names of the current outgoing headers. + * All names are lowercase. * @since v7.7.0 */ getHeaderNames(): string[]; @@ -498,11 +551,11 @@ declare module 'http' { /** * Adds HTTP trailers (headers but at the end of the message) to the message. * - * Trailers are **only** be emitted if the message is chunked encoded. If not, - * the trailer will be silently discarded. + * Trailers will **only** be emitted if the message is chunked encoded. If not, + * the trailers will be silently discarded. * * HTTP requires the `Trailer` header to be sent to emit trailers, - * with a list of header fields in its value, e.g. + * with a list of header field names in its value, e.g. * * ```js * message.writeHead(200, { 'Content-Type': 'text/plain', @@ -518,7 +571,7 @@ declare module 'http' { */ addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void; /** - * Compulsorily flushes the message headers + * Flushes the message headers. * * For efficiency reason, Node.js normally buffers the message headers * until `outgoingMessage.end()` is called or the first chunk of message data @@ -526,7 +579,7 @@ declare module 'http' { * packet. * * It is usually desired (it saves a TCP round-trip), but not when the first - * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the request. + * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the message. * @since v1.6.0 */ flushHeaders(): void; @@ -566,15 +619,56 @@ declare module 'http' { * @since v0.11.8 */ statusMessage: string; + /** + * If set to `true`, Node.js will check whether the `Content-Length`header value and the size of the body, in bytes, are equal. + * Mismatching the `Content-Length` header value will result + * in an `Error` being thrown, identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`. + * @since v18.10.0, v16.18.0 + */ + strictContentLength: boolean; constructor(req: Request); assignSocket(socket: Socket): void; detachSocket(socket: Socket): void; /** - * Sends a HTTP/1.1 100 Continue message to the client, indicating that + * Sends an HTTP/1.1 100 Continue message to the client, indicating that * the request body should be sent. See the `'checkContinue'` event on`Server`. * @since v0.3.0 */ writeContinue(callback?: () => void): void; + /** + * Sends an HTTP/1.1 103 Early Hints message to the client with a Link header, + * indicating that the user agent can preload/preconnect the linked resources. + * The `hints` is an object containing the values of headers to be sent with + * early hints message. The optional `callback` argument will be called when + * the response message has been written. + * + * **Example** + * + * ```js + * const earlyHintsLink = '; rel=preload; as=style'; + * response.writeEarlyHints({ + * 'link': earlyHintsLink, + * }); + * + * const earlyHintsLinks = [ + * '; rel=preload; as=style', + * '; rel=preload; as=script', + * ]; + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * 'x-trace-id': 'id for diagnostics', + * }); + * + * const earlyHintsCallback = () => console.log('early hints message sent'); + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * }, earlyHintsCallback); + * ``` + * @since v18.11.0 + * @param hints An object containing the values of headers + * @param callback Will be called when the response message has been written + */ + writeEarlyHints(hints: Record, callback?: () => void): void; /** * Sends a response header to the request. The status code is a 3-digit HTTP * status code, like `404`. The last argument, `headers`, are the response headers. @@ -593,7 +687,7 @@ declare module 'http' { * response * .writeHead(200, { * 'Content-Length': Buffer.byteLength(body), - * 'Content-Type': 'text/plain' + * 'Content-Type': 'text/plain', * }) * .end(body); * ``` @@ -624,12 +718,12 @@ declare module 'http' { * }); * ``` * - * `Content-Length` is given in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js - * does not check whether `Content-Length` and the length of the body which has + * `Content-Length` is read in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js + * will check whether `Content-Length` and the length of the body which has * been transmitted are equal or not. * * Attempting to set a header field name or value that contains invalid characters - * will result in a `TypeError` being thrown. + * will result in a \[`Error`\]\[\] being thrown. * @since v0.1.30 */ writeHead( @@ -678,8 +772,11 @@ declare module 'http' { * * For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered. * - * Node.js does not check whether Content-Length and the length of the - * body which has been transmitted are equal or not. + * Set `Content-Length` header to limit the response body size. + * If `response.strictContentLength` is set to `true`, mismatching the`Content-Length` header value will result in an `Error` being thrown, + * identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`. + * + * `Content-Length` value should be in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. * @since v0.1.17 */ class ClientRequest extends OutgoingMessage { @@ -706,7 +803,7 @@ declare module 'http' { * may run into a 'ECONNRESET' error. * * ```js - * const http = require('http'); + * const http = require('node:http'); * * // Server has a 5 seconds keep-alive timeout by default * http @@ -730,7 +827,7 @@ declare module 'http' { * automatic error retry base on it. * * ```js - * const http = require('http'); + * const http = require('node:http'); * const agent = new http.Agent({ keepAlive: true }); * * function retriableRequest() { @@ -809,19 +906,13 @@ declare module 'http' { * @deprecated */ addListener(event: 'abort', listener: () => void): this; - addListener( - event: 'connect', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + addListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; addListener(event: 'continue', listener: () => void): this; addListener(event: 'information', listener: (info: InformationEvent) => void): this; addListener(event: 'response', listener: (response: IncomingMessage) => void): this; addListener(event: 'socket', listener: (socket: Socket) => void): this; addListener(event: 'timeout', listener: () => void): this; - addListener( - event: 'upgrade', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + addListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; addListener(event: 'close', listener: () => void): this; addListener(event: 'drain', listener: () => void): this; addListener(event: 'error', listener: (err: Error) => void): this; @@ -869,19 +960,13 @@ declare module 'http' { * @deprecated */ prependListener(event: 'abort', listener: () => void): this; - prependListener( - event: 'connect', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + prependListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; prependListener(event: 'continue', listener: () => void): this; prependListener(event: 'information', listener: (info: InformationEvent) => void): this; prependListener(event: 'response', listener: (response: IncomingMessage) => void): this; prependListener(event: 'socket', listener: (socket: Socket) => void): this; prependListener(event: 'timeout', listener: () => void): this; - prependListener( - event: 'upgrade', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + prependListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; prependListener(event: 'close', listener: () => void): this; prependListener(event: 'drain', listener: () => void): this; prependListener(event: 'error', listener: (err: Error) => void): this; @@ -893,19 +978,13 @@ declare module 'http' { * @deprecated */ prependOnceListener(event: 'abort', listener: () => void): this; - prependOnceListener( - event: 'connect', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + prependOnceListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; prependOnceListener(event: 'continue', listener: () => void): this; prependOnceListener(event: 'information', listener: (info: InformationEvent) => void): this; prependOnceListener(event: 'response', listener: (response: IncomingMessage) => void): this; prependOnceListener(event: 'socket', listener: (socket: Socket) => void): this; prependOnceListener(event: 'timeout', listener: () => void): this; - prependOnceListener( - event: 'upgrade', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + prependOnceListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; prependOnceListener(event: 'close', listener: () => void): this; prependOnceListener(event: 'drain', listener: () => void): this; prependOnceListener(event: 'error', listener: (err: Error) => void): this; @@ -917,7 +996,7 @@ declare module 'http' { /** * An `IncomingMessage` object is created by {@link Server} or {@link ClientRequest} and passed as the first argument to the `'request'` and `'response'` event respectively. It may be used to * access response - * status, headers and data. + * status, headers, and data. * * Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to * parse and emit the incoming HTTP headers and payload, as the underlying socket @@ -955,7 +1034,7 @@ declare module 'http' { * const req = http.request({ * host: '127.0.0.1', * port: 8080, - * method: 'POST' + * method: 'POST', * }, (res) => { * res.resume(); * res.on('end', () => { @@ -997,7 +1076,7 @@ declare module 'http' { * // { 'user-agent': 'curl/7.22.0', * // host: '127.0.0.1:8000', * // accept: '*' } - * console.log(request.getHeaders()); + * console.log(request.headers); * ``` * * Duplicates in raw headers are handled in the following ways, depending on the @@ -1005,12 +1084,30 @@ declare module 'http' { * * * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`, * `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded. + * To allow duplicate values of the headers listed above to be joined, + * use the option `joinDuplicateHeaders` in {@link request} and {@link createServer}. See RFC 9110 Section 5.3 for more + * information. * * `set-cookie` is always an array. Duplicates are added to the array. - * * For duplicate `cookie` headers, the values are joined together with '; '. - * * For all other headers, the values are joined together with ', '. + * * For duplicate `cookie` headers, the values are joined together with `; `. + * * For all other headers, the values are joined together with `, `. * @since v0.1.5 */ headers: IncomingHttpHeaders; + /** + * Similar to `message.headers`, but there is no join logic and the values are + * always arrays of strings, even for headers received just once. + * + * ```js + * // Prints something like: + * // + * // { 'user-agent': ['curl/7.22.0'], + * // host: ['127.0.0.1:8000'], + * // accept: ['*'] } + * console.log(request.headersDistinct); + * ``` + * @since v18.3.0, v16.17.0 + */ + headersDistinct: NodeJS.Dict; /** * The raw request/response headers list exactly as they were received. * @@ -1041,6 +1138,13 @@ declare module 'http' { * @since v0.3.0 */ trailers: NodeJS.Dict; + /** + * Similar to `message.trailers`, but there is no join logic and the values are + * always arrays of strings, even for headers received just once. + * Only populated at the `'end'` event. + * @since v18.3.0, v16.17.0 + */ + trailersDistinct: NodeJS.Dict; /** * The raw request/response trailer keys and values exactly as they were * received. Only populated at the `'end'` event. @@ -1073,14 +1177,14 @@ declare module 'http' { * To parse the URL into its parts: * * ```js - * new URL(request.url, `http://${request.getHeaders().host}`); + * new URL(request.url, `http://${request.headers.host}`); * ``` * - * When `request.url` is `'/status?name=ryan'` and`request.getHeaders().host` is `'localhost:3000'`: + * When `request.url` is `'/status?name=ryan'` and `request.headers.host` is`'localhost:3000'`: * * ```console * $ node - * > new URL(request.url, `http://${request.getHeaders().host}`) + * > new URL(request.url, `http://${request.headers.host}`) * URL { * href: 'http://localhost:3000/status?name=ryan', * origin: 'http://localhost:3000', @@ -1200,16 +1304,16 @@ declare module 'http' { * hostname: 'localhost', * port: 80, * path: '/', - * agent: false // Create a new agent just for this one request + * agent: false, // Create a new agent just for this one request * }, (res) => { * // Do stuff with response * }); * ``` * @since v0.3.4 */ - class Agent { + class Agent extends EventEmitter { /** - * By default set to 256\. For agents with `keepAlive` enabled, this + * By default set to 256. For agents with `keepAlive` enabled, this * sets the maximum number of sockets that will be left open in the free * state. * @since v0.11.7 @@ -1305,10 +1409,10 @@ declare module 'http' { * upload a file with a POST request, then write to the `ClientRequest` object. * * ```js - * const http = require('http'); + * const http = require('node:http'); * * const postData = JSON.stringify({ - * 'msg': 'Hello World!' + * 'msg': 'Hello World!', * }); * * const options = { @@ -1318,8 +1422,8 @@ declare module 'http' { * method: 'POST', * headers: { * 'Content-Type': 'application/json', - * 'Content-Length': Buffer.byteLength(postData) - * } + * 'Content-Length': Buffer.byteLength(postData), + * }, * }; * * const req = http.request(options, (res) => { @@ -1406,7 +1510,7 @@ declare module 'http' { * * `'data'` any number of times, on the `res` object * * (connection closed here) * * `'aborted'` on the `res` object - * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`. + * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'` * * `'close'` * * `'close'` on the `res` object * @@ -1414,7 +1518,7 @@ declare module 'http' { * events will be emitted in the following order: * * * (`req.destroy()` called here) - * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'` + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called * * `'close'` * * If `req.destroy()` is called before the connection succeeds, the following @@ -1422,7 +1526,7 @@ declare module 'http' { * * * `'socket'` * * (`req.destroy()` called here) - * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'` + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called * * `'close'` * * If `req.destroy()` is called after the response is received, the following @@ -1433,7 +1537,7 @@ declare module 'http' { * * `'data'` any number of times, on the `res` object * * (`req.destroy()` called here) * * `'aborted'` on the `res` object - * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`. + * * `'error'` on the `res` object with an error with message `'Error: aborted'`and code `'ECONNRESET'`, or the error with which `req.destroy()` was called * * `'close'` * * `'close'` on the `res` object * @@ -1469,16 +1573,13 @@ declare module 'http' { * Setting the `timeout` option or using the `setTimeout()` function will * not abort the request or do anything besides add a `'timeout'` event. * - * Passing an `AbortSignal` and then calling `abort` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the - * request itself. + * Passing an `AbortSignal` and then calling `abort()` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the + * request. Specifically, the `'error'` event will be emitted with an error with + * the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`and the `cause`, if one was provided. * @since v0.3.6 */ function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; - function request( - url: string | URL, - options: RequestOptions, - callback?: (res: IncomingMessage) => void, - ): ClientRequest; + function request(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; /** * Since most requests are GET requests without bodies, Node.js provides this * convenience method. The only difference between this method and {@link request} is that it sets the method to GET and calls `req.end()`automatically. The callback must take care to consume the @@ -1530,7 +1631,7 @@ declare module 'http' { * const server = http.createServer((req, res) => { * res.writeHead(200, { 'Content-Type': 'application/json' }); * res.end(JSON.stringify({ - * data: 'Hello World!' + * data: 'Hello World!', * })); * }); * @@ -1541,6 +1642,76 @@ declare module 'http' { */ function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + /** + * Performs the low-level validations on the provided `name` that are done when`res.setHeader(name, value)` is called. + * + * Passing illegal value as `name` will result in a `TypeError` being thrown, + * identified by `code: 'ERR_INVALID_HTTP_TOKEN'`. + * + * It is not necessary to use this method before passing headers to an HTTP request + * or response. The HTTP module will automatically validate such headers. + * Examples: + * + * Example: + * + * ```js + * const { validateHeaderName } = require('node:http'); + * + * try { + * validateHeaderName(''); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN' + * console.error(err.message); // --> 'Header name must be a valid HTTP token [""]' + * } + * ``` + * @since v14.3.0 + * @param [label='Header name'] Label for error message. + */ + function validateHeaderName(name: string): void; + /** + * Performs the low-level validations on the provided `value` that are done when`res.setHeader(name, value)` is called. + * + * Passing illegal value as `value` will result in a `TypeError` being thrown. + * + * * Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`. + * * Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`. + * + * It is not necessary to use this method before passing headers to an HTTP request + * or response. The HTTP module will automatically validate such headers. + * + * Examples: + * + * ```js + * const { validateHeaderValue } = require('node:http'); + * + * try { + * validateHeaderValue('x-my-header', undefined); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true + * console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"' + * } + * + * try { + * validateHeaderValue('x-my-header', 'oʊmɪɡə'); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code === 'ERR_INVALID_CHAR'); // --> true + * console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]' + * } + * ``` + * @since v14.3.0 + * @param name Header name + * @param value Header value + */ + function validateHeaderValue(name: string, value: string): void; + /** + * Set the maximum number of idle HTTP parsers. + * @since v18.8.0, v16.18.0 + * @param [max=1000] + */ + function setMaxIdleHTTPParsers(max: number): void; let globalAgent: Agent; /** * Read-only property specifying the maximum allowed size of HTTP headers in bytes. diff --git a/node_modules/@types/node/http2.d.ts b/node_modules/@types/node/http2.d.ts index 0f628b9d7..80057093f 100755 --- a/node_modules/@types/node/http2.d.ts +++ b/node_modules/@types/node/http2.d.ts @@ -1,12 +1,12 @@ /** - * The `http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol. It - * can be accessed using: + * The `node:http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol. + * It can be accessed using: * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * ``` * @since v8.4.0 - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http2.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http2.js) */ declare module 'http2' { import EventEmitter = require('node:events'); @@ -151,7 +151,7 @@ declare module 'http2' { priority(options: StreamPriorityOptions): void; /** * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const client = http2.connect('http://example.org:8000'); * const { NGHTTP2_CANCEL } = http2.constants; * const req = client.request({ ':path': '/' }); @@ -171,7 +171,7 @@ declare module 'http2' { * trailers can be sent. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * stream.respond(undefined, { waitForTrailers: true }); @@ -332,7 +332,7 @@ declare module 'http2' { * Initiates a push stream. The callback is invoked with the new `Http2Stream`instance created for the push stream passed as the second argument, or an`Error` passed as the first argument. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * stream.respond({ ':status': 200 }); @@ -357,7 +357,7 @@ declare module 'http2' { pushStream(headers: OutgoingHttpHeaders, options?: StreamPriorityOptions, callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void): void; /** * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * stream.respond({ ':status': 200 }); @@ -365,16 +365,15 @@ declare module 'http2' { * }); * ``` * - * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event - * will be emitted immediately after queuing the last chunk of payload data to be - * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing - * header fields to the peer. + * Initiates a response. When the `options.waitForTrailers` option is set, the`'wantTrailers'` event will be emitted immediately after queuing the last chunk + * of payload data to be sent. The `http2stream.sendTrailers()` method can then be + * used to sent trailing header fields to the peer. * * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * stream.respond({ ':status': 200 }, { waitForTrailers: true }); @@ -397,8 +396,8 @@ declare module 'http2' { * automatically. * * ```js - * const http2 = require('http2'); - * const fs = require('fs'); + * const http2 = require('node:http2'); + * const fs = require('node:fs'); * * const server = http2.createServer(); * server.on('stream', (stream) => { @@ -408,7 +407,7 @@ declare module 'http2' { * const headers = { * 'content-length': stat.size, * 'last-modified': stat.mtime.toUTCString(), - * 'content-type': 'text/plain; charset=utf-8' + * 'content-type': 'text/plain; charset=utf-8', * }; * stream.respondWithFD(fd, headers); * stream.on('close', () => fs.closeSync(fd)); @@ -439,8 +438,8 @@ declare module 'http2' { * close when the final `DATA` frame is transmitted. User code _must_ call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. * * ```js - * const http2 = require('http2'); - * const fs = require('fs'); + * const http2 = require('node:http2'); + * const fs = require('node:fs'); * * const server = http2.createServer(); * server.on('stream', (stream) => { @@ -450,7 +449,7 @@ declare module 'http2' { * const headers = { * 'content-length': stat.size, * 'last-modified': stat.mtime.toUTCString(), - * 'content-type': 'text/plain; charset=utf-8' + * 'content-type': 'text/plain; charset=utf-8', * }; * stream.respondWithFD(fd, headers, { waitForTrailers: true }); * stream.on('wantTrailers', () => { @@ -482,7 +481,7 @@ declare module 'http2' { * Example using a file path: * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * function statCheck(stat, headers) { @@ -500,7 +499,7 @@ declare module 'http2' { * } * } catch (err) { * // Perform actual error handling. - * console.log(err); + * console.error(err); * } * stream.end(); * } @@ -516,7 +515,7 @@ declare module 'http2' { * results to determine if the file has been modified to return an appropriate`304` response: * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * function statCheck(stat, headers) { @@ -549,7 +548,7 @@ declare module 'http2' { * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * stream.respondWithFile('/some/file', @@ -748,7 +747,7 @@ declare module 'http2' { * the delta. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * * const server = http2.createServer(); * const expectedWindowSize = 2 ** 20; @@ -854,11 +853,11 @@ declare module 'http2' { * This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const clientSession = http2.connect('https://localhost:1234'); * const { * HTTP2_HEADER_PATH, - * HTTP2_HEADER_STATUS + * HTTP2_HEADER_STATUS, * } = http2.constants; * * const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' }); @@ -928,7 +927,7 @@ declare module 'http2' { * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * * const server = http2.createServer(); * server.on('session', (session) => { @@ -969,7 +968,7 @@ declare module 'http2' { * authoritative responses. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const options = getSecureOptionsSomehow(); * const server = http2.createSecureServer(options); * server.on('stream', (stream) => { @@ -995,7 +994,7 @@ declare module 'http2' { * server using the `http2.createSecureServer()` method: * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const options = getSecureOptionsSomehow(); * options.origins = ['https://example.com', 'https://example.org']; * const server = http2.createSecureServer(options); @@ -1053,7 +1052,6 @@ declare module 'http2' { */ unknownProtocolTimeout?: number | undefined; selectPadding?(frameLen: number, maxFrameLen: number): number; - createConnection?(authority: url.URL, option: SessionOptions): stream.Duplex; } export interface ClientSessionOptions extends SessionOptions { maxReservedRemoteStreams?: number | undefined; @@ -1437,7 +1435,7 @@ declare module 'http2' { */ readonly headersSent: boolean; /** - * A reference to the original HTTP2 request object. + * A reference to the original HTTP2 `request` object. * @since v15.7.0 */ readonly req: Http2ServerRequest; @@ -1458,7 +1456,7 @@ declare module 'http2' { * All other interactions will be routed directly to the socket. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer((req, res) => { * const ip = req.socket.remoteAddress; * const port = req.socket.remotePort; @@ -1641,7 +1639,7 @@ declare module 'http2' { * This sends a chunk of the response body. This method may * be called multiple times to provide successive parts of the body. * - * In the `http` module, the response body is omitted when the + * In the `node:http` module, the response body is omitted when the * request is a HEAD request. Similarly, the `204` and `304` responses _must not_ include a message body. * * `chunk` can be a string or a buffer. If `chunk` is a string, @@ -1670,6 +1668,31 @@ declare module 'http2' { * @since v8.4.0 */ writeContinue(): void; + /** + * Sends a status `103 Early Hints` to the client with a Link header, + * indicating that the user agent can preload/preconnect the linked resources. + * The `hints` is an object containing the values of headers to be sent with + * early hints message. + * + * **Example** + * + * ```js + * const earlyHintsLink = '; rel=preload; as=style'; + * response.writeEarlyHints({ + * 'link': earlyHintsLink, + * }); + * + * const earlyHintsLinks = [ + * '; rel=preload; as=style', + * '; rel=preload; as=script', + * ]; + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * }); + * ``` + * @since v18.11.0 + */ + writeEarlyHints(hints: Record): void; /** * Sends a response header to the request. The status code is a 3-digit HTTP * status code, like `404`. The last argument, `headers`, are the response headers. @@ -2000,7 +2023,7 @@ declare module 'http2' { * for use with the `HTTP2-Settings` header field. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * * const packed = http2.getPackedSettings({ enablePush: false }); * @@ -2025,7 +2048,7 @@ declare module 'http2' { * with browser clients. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * * // Create an unencrypted HTTP/2 server. * // Since there are no browsers known that support @@ -2036,12 +2059,12 @@ declare module 'http2' { * server.on('stream', (stream, headers) => { * stream.respond({ * 'content-type': 'text/html; charset=utf-8', - * ':status': 200 + * ':status': 200, * }); * stream.end('

Hello World

'); * }); * - * server.listen(80); + * server.listen(8000); * ``` * @since v8.4.0 * @param onRequestHandler See `Compatibility API` @@ -2052,12 +2075,12 @@ declare module 'http2' { * Returns a `tls.Server` instance that creates and manages `Http2Session`instances. * * ```js - * const http2 = require('http2'); - * const fs = require('fs'); + * const http2 = require('node:http2'); + * const fs = require('node:fs'); * * const options = { * key: fs.readFileSync('server-key.pem'), - * cert: fs.readFileSync('server-cert.pem') + * cert: fs.readFileSync('server-cert.pem'), * }; * * // Create a secure HTTP/2 server @@ -2066,12 +2089,12 @@ declare module 'http2' { * server.on('stream', (stream, headers) => { * stream.respond({ * 'content-type': 'text/html; charset=utf-8', - * ':status': 200 + * ':status': 200, * }); * stream.end('

Hello World

'); * }); * - * server.listen(80); + * server.listen(8443); * ``` * @since v8.4.0 * @param onRequestHandler See `Compatibility API` @@ -2082,7 +2105,7 @@ declare module 'http2' { * Returns a `ClientHttp2Session` instance. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const client = http2.connect('https://localhost:1234'); * * // Use the client diff --git a/node_modules/@types/node/https.d.ts b/node_modules/@types/node/https.d.ts index aae4a9584..76fca92c0 100755 --- a/node_modules/@types/node/https.d.ts +++ b/node_modules/@types/node/https.d.ts @@ -1,7 +1,7 @@ /** * HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a * separate module. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/https.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/https.js) */ declare module 'https' { import { Duplex } from 'node:stream'; @@ -14,6 +14,7 @@ declare module 'https' { > = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions; type RequestOptions = http.RequestOptions & tls.SecureContextOptions & { + checkServerIdentity?: typeof tls.checkServerIdentity | undefined; rejectUnauthorized?: boolean | undefined; // Defaults to true servername?: string | undefined; // SNI TLS Extension }; @@ -58,22 +59,9 @@ declare module 'https' { closeIdleConnections(): void; addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; - addListener( - event: 'newSession', - listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, - ): this; - addListener( - event: 'OCSPRequest', - listener: ( - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ) => void, - ): this; - addListener( - event: 'resumeSession', - listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, - ): this; + addListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this; + addListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this; + addListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this; addListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this; addListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; addListener(event: 'close', listener: () => void): this; @@ -83,29 +71,13 @@ declare module 'https' { addListener(event: 'checkContinue', listener: http.RequestListener): this; addListener(event: 'checkExpectation', listener: http.RequestListener): this; addListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this; - addListener( - event: 'connect', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + addListener(event: 'connect', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; addListener(event: 'request', listener: http.RequestListener): this; - addListener( - event: 'upgrade', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + addListener(event: 'upgrade', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; emit(event: string, ...args: any[]): boolean; emit(event: 'keylog', line: Buffer, tlsSocket: tls.TLSSocket): boolean; - emit( - event: 'newSession', - sessionId: Buffer, - sessionData: Buffer, - callback: (err: Error, resp: Buffer) => void, - ): boolean; - emit( - event: 'OCSPRequest', - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ): boolean; + emit(event: 'newSession', sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void): boolean; + emit(event: 'OCSPRequest', certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void): boolean; emit(event: 'resumeSession', sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean; emit(event: 'secureConnection', tlsSocket: tls.TLSSocket): boolean; emit(event: 'tlsClientError', err: Error, tlsSocket: tls.TLSSocket): boolean; @@ -116,39 +88,32 @@ declare module 'https' { emit( event: 'checkContinue', req: InstanceType, - res: InstanceType & { req: InstanceType }, + res: InstanceType & { + req: InstanceType; + } ): boolean; emit( event: 'checkExpectation', req: InstanceType, - res: InstanceType & { req: InstanceType }, + res: InstanceType & { + req: InstanceType; + } ): boolean; emit(event: 'clientError', err: Error, socket: Duplex): boolean; emit(event: 'connect', req: InstanceType, socket: Duplex, head: Buffer): boolean; emit( event: 'request', req: InstanceType, - res: InstanceType & { req: InstanceType }, + res: InstanceType & { + req: InstanceType; + } ): boolean; emit(event: 'upgrade', req: InstanceType, socket: Duplex, head: Buffer): boolean; on(event: string, listener: (...args: any[]) => void): this; on(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; - on( - event: 'newSession', - listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, - ): this; - on( - event: 'OCSPRequest', - listener: ( - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ) => void, - ): this; - on( - event: 'resumeSession', - listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, - ): this; + on(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this; + on(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this; + on(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this; on(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this; on(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; on(event: 'close', listener: () => void): this; @@ -163,22 +128,9 @@ declare module 'https' { on(event: 'upgrade', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; once(event: string, listener: (...args: any[]) => void): this; once(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; - once( - event: 'newSession', - listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, - ): this; - once( - event: 'OCSPRequest', - listener: ( - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ) => void, - ): this; - once( - event: 'resumeSession', - listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, - ): this; + once(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this; + once(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this; + once(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this; once(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this; once(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; once(event: 'close', listener: () => void): this; @@ -193,22 +145,9 @@ declare module 'https' { once(event: 'upgrade', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; - prependListener( - event: 'newSession', - listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, - ): this; - prependListener( - event: 'OCSPRequest', - listener: ( - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ) => void, - ): this; - prependListener( - event: 'resumeSession', - listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, - ): this; + prependListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this; + prependListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this; + prependListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this; prependListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this; prependListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; prependListener(event: 'close', listener: () => void): this; @@ -218,33 +157,14 @@ declare module 'https' { prependListener(event: 'checkContinue', listener: http.RequestListener): this; prependListener(event: 'checkExpectation', listener: http.RequestListener): this; prependListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this; - prependListener( - event: 'connect', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + prependListener(event: 'connect', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; prependListener(event: 'request', listener: http.RequestListener): this; - prependListener( - event: 'upgrade', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + prependListener(event: 'upgrade', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; - prependOnceListener( - event: 'newSession', - listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, - ): this; - prependOnceListener( - event: 'OCSPRequest', - listener: ( - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ) => void, - ): this; - prependOnceListener( - event: 'resumeSession', - listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, - ): this; + prependOnceListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this; + prependOnceListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this; + prependOnceListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this; prependOnceListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this; prependOnceListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; prependOnceListener(event: 'close', listener: () => void): this; @@ -254,25 +174,19 @@ declare module 'https' { prependOnceListener(event: 'checkContinue', listener: http.RequestListener): this; prependOnceListener(event: 'checkExpectation', listener: http.RequestListener): this; prependOnceListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this; - prependOnceListener( - event: 'connect', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + prependOnceListener(event: 'connect', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; prependOnceListener(event: 'request', listener: http.RequestListener): this; - prependOnceListener( - event: 'upgrade', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + prependOnceListener(event: 'upgrade', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; } /** * ```js * // curl -k https://localhost:8000/ - * const https = require('https'); - * const fs = require('fs'); + * const https = require('node:https'); + * const fs = require('node:fs'); * * const options = { * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), - * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem') + * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), * }; * * https.createServer(options, (req, res) => { @@ -284,12 +198,12 @@ declare module 'https' { * Or * * ```js - * const https = require('https'); - * const fs = require('fs'); + * const https = require('node:https'); + * const fs = require('node:fs'); * * const options = { * pfx: fs.readFileSync('test/fixtures/test_cert.pfx'), - * passphrase: 'sample' + * passphrase: 'sample', * }; * * https.createServer(options, (req, res) => { @@ -325,13 +239,13 @@ declare module 'https' { * upload a file with a POST request, then write to the `ClientRequest` object. * * ```js - * const https = require('https'); + * const https = require('node:https'); * * const options = { * hostname: 'encrypted.google.com', * port: 443, * path: '/', - * method: 'GET' + * method: 'GET', * }; * * const req = https.request(options, (res) => { @@ -358,7 +272,7 @@ declare module 'https' { * path: '/', * method: 'GET', * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), - * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem') + * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), * }; * options.agent = new https.Agent(options); * @@ -377,7 +291,7 @@ declare module 'https' { * method: 'GET', * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), - * agent: false + * agent: false, * }; * * const req = https.request(options, (res) => { @@ -398,9 +312,9 @@ declare module 'https' { * Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`): * * ```js - * const tls = require('tls'); - * const https = require('https'); - * const crypto = require('crypto'); + * const tls = require('node:tls'); + * const https = require('node:https'); + * const crypto = require('node:crypto'); * * function sha256(s) { * return crypto.createHash('sha256').update(s).digest('base64'); @@ -417,7 +331,7 @@ declare module 'https' { * return err; * } * - * // Pin the public key, similar to HPKP pin-sha25 pinning + * // Pin the public key, similar to HPKP pin-sha256 pinning * const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU='; * if (sha256(cert.pubkey) !== pubkey256) { * const msg = 'Certificate verification error: ' + @@ -492,15 +406,8 @@ declare module 'https' { * @since v0.3.6 * @param options Accepts all `options` from `request`, with some differences in default values: */ - function request( - options: RequestOptions | string | URL, - callback?: (res: http.IncomingMessage) => void, - ): http.ClientRequest; - function request( - url: string | URL, - options: RequestOptions, - callback?: (res: http.IncomingMessage) => void, - ): http.ClientRequest; + function request(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + function request(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; /** * Like `http.get()` but for HTTPS. * @@ -508,7 +415,7 @@ declare module 'https' { * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object. * * ```js - * const https = require('https'); + * const https = require('node:https'); * * https.get('https://encrypted.google.com/', (res) => { * console.log('statusCode:', res.statusCode); @@ -525,15 +432,8 @@ declare module 'https' { * @since v0.3.6 * @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`. */ - function get( - options: RequestOptions | string | URL, - callback?: (res: http.IncomingMessage) => void, - ): http.ClientRequest; - function get( - url: string | URL, - options: RequestOptions, - callback?: (res: http.IncomingMessage) => void, - ): http.ClientRequest; + function get(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + function get(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; let globalAgent: Agent; } declare module 'node:https' { diff --git a/node_modules/@types/node/index.d.ts b/node_modules/@types/node/index.d.ts index 152c75555..97cb955b6 100755 --- a/node_modules/@types/node/index.d.ts +++ b/node_modules/@types/node/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for non-npm package Node.js 18.8 +// Type definitions for non-npm package Node.js 20.2 // Project: https://nodejs.org/ // Definitions by: Microsoft TypeScript // DefinitelyTyped @@ -41,6 +41,7 @@ // Linus Unnebäck // wafuwafu13 // Matteo Collina +// Dmitry Semigradsky // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** @@ -92,6 +93,7 @@ /// /// /// +/// /// /// /// diff --git a/node_modules/@types/node/inspector.d.ts b/node_modules/@types/node/inspector.d.ts index eba0b55d8..48920de3e 100755 --- a/node_modules/@types/node/inspector.d.ts +++ b/node_modules/@types/node/inspector.d.ts @@ -8,14 +8,21 @@ // tslint:disable:max-line-length /** - * The `inspector` module provides an API for interacting with the V8 inspector. + * The `node:inspector` module provides an API for interacting with the V8 + * inspector. * * It can be accessed using: * * ```js - * const inspector = require('inspector'); + * import * as inspector from 'node:inspector/promises'; * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/inspector.js) + * + * or + * + * ```js + * import * as inspector from 'node:inspector'; + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/inspector.js) */ declare module 'inspector' { import EventEmitter = require('node:events'); diff --git a/node_modules/@types/node/module.d.ts b/node_modules/@types/node/module.d.ts index d83aec94a..e884f32cc 100755 --- a/node_modules/@types/node/module.d.ts +++ b/node_modules/@types/node/module.d.ts @@ -10,9 +10,9 @@ declare module 'module' { * does not add or remove exported names from the `ES Modules`. * * ```js - * const fs = require('fs'); - * const assert = require('assert'); - * const { syncBuiltinESMExports } = require('module'); + * const fs = require('node:fs'); + * const assert = require('node:assert'); + * const { syncBuiltinESMExports } = require('node:module'); * * fs.readFile = newAPI; * @@ -26,7 +26,7 @@ declare module 'module' { * * syncBuiltinESMExports(); * - * import('fs').then((esmFS) => { + * import('node:fs').then((esmFS) => { * // It syncs the existing readFile property with the new value * assert.strictEqual(esmFS.readFile, newAPI); * // readFileSync has been deleted from the required fs @@ -44,6 +44,7 @@ declare module 'module' { * `path` is the resolved path for the file for which a corresponding source map * should be fetched. * @since v13.7.0, v12.17.0 + * @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise. */ function findSourceMap(path: string, error?: Error): SourceMap; interface SourceMapPayload { @@ -85,6 +86,7 @@ declare module 'module' { static wrap(code: string): string; static createRequire(path: string | URL): NodeRequire; static builtinModules: string[]; + static isBuiltin(moduleName: string): boolean; static Module: typeof Module; constructor(id: string, parent?: Module); } diff --git a/node_modules/@types/node/net.d.ts b/node_modules/@types/node/net.d.ts index b7355383f..d180fa076 100755 --- a/node_modules/@types/node/net.d.ts +++ b/node_modules/@types/node/net.d.ts @@ -1,16 +1,16 @@ /** * > Stability: 2 - Stable * - * The `net` module provides an asynchronous network API for creating stream-based + * The `node:net` module provides an asynchronous network API for creating stream-based * TCP or `IPC` servers ({@link createServer}) and clients * ({@link createConnection}). * * It can be accessed using: * * ```js - * const net = require('net'); + * const net = require('node:net'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/net.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/net.js) */ declare module 'net' { import * as stream from 'node:stream'; @@ -57,6 +57,14 @@ declare module 'net' { noDelay?: boolean | undefined; keepAlive?: boolean | undefined; keepAliveInitialDelay?: number | undefined; + /** + * @since v18.13.0 + */ + autoSelectFamily?: boolean | undefined; + /** + * @since v18.13.0 + */ + autoSelectFamilyAttemptTimeout?: number | undefined; } interface IpcSocketConnectOpts extends ConnectOpts { path: string; @@ -133,13 +141,10 @@ declare module 'net' { pause(): this; /** * Close the TCP connection by sending an RST packet and destroy the stream. - * If this TCP socket is in connecting status, it will send an RST packet - * and destroy this TCP socket once it is connected. Otherwise, it will call - * `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. If this is not a TCP socket - * (for example, a pipe), calling this method will immediately throw - * an `ERR_INVALID_HANDLE_TYPE` Error. - * @since v18.3.0 - * @return The socket itself. + * If this TCP socket is in connecting status, it will send an RST packet and destroy this TCP socket once it is connected. + * Otherwise, it will call `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. + * If this is not a TCP socket (for example, a pipe), calling this method will immediately throw an `ERR_INVALID_HANDLE_TYPE` Error. + * @since v18.3.0, v16.17.0 */ resetAndDestroy(): this; /** @@ -261,6 +266,12 @@ declare module 'net' { * @since v6.1.0 */ readonly connecting: boolean; + /** + * This is `true` if the socket is not connected yet, either because `.connect()`has not yet been called or because it is still in the process of connecting + * (see `socket.connecting`). + * @since v11.2.0, v10.16.0 + */ + readonly pending: boolean; /** * See `writable.destroyed` for further details. */ @@ -279,12 +290,16 @@ declare module 'net' { readonly localPort?: number; /** * The string representation of the local IP family. `'IPv4'` or `'IPv6'`. - * @since v18.8.0 + * @since v18.8.0, v16.18.0 */ readonly localFamily?: string; /** * This property represents the state of the connection as a string. - * @see {https://nodejs.org/api/net.html#socketreadystate} + * + * * If the stream is connecting `socket.readyState` is `opening`. + * * If the stream is readable and writable, it is `open`. + * * If the stream is readable and not writable, it is `readOnly`. + * * If the stream is not readable and writable, it is `writeOnly`. * @since v0.5.0 */ readonly readyState: SocketReadyState; @@ -305,7 +320,8 @@ declare module 'net' { */ readonly remotePort?: number | undefined; /** - * The socket timeout in milliseconds as set by socket.setTimeout(). It is undefined if a timeout has not been set. + * The socket timeout in milliseconds as set by `socket.setTimeout()`. + * It is `undefined` if a timeout has not been set. * @since v10.7.0 */ readonly timeout?: number | undefined; @@ -486,7 +502,7 @@ declare module 'net' { * ```js * server.on('error', (e) => { * if (e.code === 'EADDRINUSE') { - * console.log('Address in use, retrying...'); + * console.error('Address in use, retrying...'); * setTimeout(() => { * server.close(); * server.listen(PORT, HOST); @@ -708,7 +724,7 @@ declare module 'net' { * on port 8124: * * ```js - * const net = require('net'); + * const net = require('node:net'); * const server = net.createServer((c) => { * // 'connection' listener. * console.log('client connected'); @@ -846,6 +862,7 @@ declare module 'net' { class SocketAddress { constructor(options: SocketAddressInitOptions); /** + * Either \`'ipv4'\` or \`'ipv6'\`. * @since v15.14.0, v14.18.0 */ readonly address: string; diff --git a/node_modules/@types/node/os.d.ts b/node_modules/@types/node/os.d.ts index 3c555992d..3d2086468 100755 --- a/node_modules/@types/node/os.d.ts +++ b/node_modules/@types/node/os.d.ts @@ -1,11 +1,11 @@ /** - * The `os` module provides operating system-related utility methods and + * The `node:os` module provides operating system-related utility methods and * properties. It can be accessed using: * * ```js - * const os = require('os'); + * const os = require('node:os'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/os.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/os.js) */ declare module 'os' { interface CpuInfo { @@ -75,6 +75,7 @@ declare module 'os' { function totalmem(): number; /** * Returns an array of objects containing information about each logical CPU core. + * The array will be empty if no CPU information is available, such as if the`/proc` file system is unavailable. * * The properties included on each object include: * @@ -88,8 +89,8 @@ declare module 'os' { * nice: 0, * sys: 30340, * idle: 1070356870, - * irq: 0 - * } + * irq: 0, + * }, * }, * { * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', @@ -99,8 +100,8 @@ declare module 'os' { * nice: 0, * sys: 26980, * idle: 1071569080, - * irq: 0 - * } + * irq: 0, + * }, * }, * { * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', @@ -110,8 +111,8 @@ declare module 'os' { * nice: 0, * sys: 21750, * idle: 1070919370, - * irq: 0 - * } + * irq: 0, + * }, * }, * { * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', @@ -121,17 +122,28 @@ declare module 'os' { * nice: 0, * sys: 19430, * idle: 1070905480, - * irq: 20 - * } + * irq: 20, + * }, * }, * ] * ``` * * `nice` values are POSIX-only. On Windows, the `nice` values of all processors * are always 0. + * + * `os.cpus().length` should not be used to calculate the amount of parallelism + * available to an application. Use {@link availableParallelism} for this purpose. * @since v0.3.3 */ function cpus(): CpuInfo[]; + /** + * Returns an estimate of the default amount of parallelism a program should use. + * Always returns a value greater than zero. + * + * This function is a small wrapper about libuv's [`uv_available_parallelism()`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_available_parallelism). + * @since v19.4.0, v18.14.0 + */ + function availableParallelism(): number; /** * Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it * returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows. @@ -415,12 +427,11 @@ declare module 'os' { */ function platform(): NodeJS.Platform; /** - * Returns the machine type as a string, such as arm, aarch64, mips, mips64, ppc64, ppc64le, s390, s390x, i386, i686, x86_64. + * Returns the machine type as a string, such as `arm`, `arm64`, `aarch64`,`mips`, `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`. * - * On POSIX systems, the machine type is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). - * On Windows, `RtlGetVersion()` is used, and if it is not available, `GetVersionExW()` will be used. - * See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information. - * @since v18.9.0 + * On POSIX systems, the machine type is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not + * available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information. + * @since v18.9.0, v16.18.0 */ function machine(): string; /** diff --git a/node_modules/@types/node/package.json b/node_modules/@types/node/package.json index 66ccb47e6..13e578dc7 100755 --- a/node_modules/@types/node/package.json +++ b/node_modules/@types/node/package.json @@ -1,6 +1,6 @@ { "name": "@types/node", - "version": "18.8.0", + "version": "20.2.4", "description": "TypeScript definitions for Node.js", "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node", "license": "MIT", @@ -209,12 +209,17 @@ "name": "Matteo Collina", "url": "https://github.com/mcollina", "githubUsername": "mcollina" + }, + { + "name": "Dmitry Semigradsky", + "url": "https://github.com/Semigradsky", + "githubUsername": "Semigradsky" } ], "main": "", "types": "index.d.ts", "typesVersions": { - "<4.9.0-0": { + "<=4.8": { "*": [ "ts4.8/*" ] @@ -227,6 +232,6 @@ }, "scripts": {}, "dependencies": {}, - "typesPublisherContentHash": "54f0b73dedc6d751a0945c330043a807365cb735a3530635a46ca3432f8b140e", - "typeScriptVersion": "4.1" + "typesPublisherContentHash": "2e3b2377433bb56f46cc48c2ae626cac278d92bddb803373733d72c8da681f19", + "typeScriptVersion": "4.3" } \ No newline at end of file diff --git a/node_modules/@types/node/path.d.ts b/node_modules/@types/node/path.d.ts index 2d643b29b..723d5daab 100755 --- a/node_modules/@types/node/path.d.ts +++ b/node_modules/@types/node/path.d.ts @@ -7,13 +7,13 @@ declare module 'path/win32' { export = path; } /** - * The `path` module provides utilities for working with file and directory paths. - * It can be accessed using: + * The `node:path` module provides utilities for working with file and directory + * paths. It can be accessed using: * * ```js - * const path = require('path'); + * const path = require('node:path'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/path.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/path.js) */ declare module 'path' { namespace path { @@ -122,10 +122,10 @@ declare module 'path' { * Often used to extract the file name from a fully qualified path. * * @param path the path to evaluate. - * @param ext optionally, an extension to remove from the result. + * @param suffix optionally, an extension to remove from the result. * @throws {TypeError} if `path` is not a string or if `ext` is given and is not a string. */ - basename(path: string, ext?: string): string; + basename(path: string, suffix?: string): string; /** * Return the extension of the path, from the last '.' to end of string in the last portion of the path. * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string. diff --git a/node_modules/@types/node/perf_hooks.d.ts b/node_modules/@types/node/perf_hooks.d.ts index cf02a16e7..c090e1df6 100755 --- a/node_modules/@types/node/perf_hooks.d.ts +++ b/node_modules/@types/node/perf_hooks.d.ts @@ -7,9 +7,10 @@ * * [High Resolution Time](https://www.w3.org/TR/hr-time-2) * * [Performance Timeline](https://w3c.github.io/performance-timeline/) * * [User Timing](https://www.w3.org/TR/user-timing/) + * * [Resource Timing](https://www.w3.org/TR/resource-timing-2/) * * ```js - * const { PerformanceObserver, performance } = require('perf_hooks'); + * const { PerformanceObserver, performance } = require('node:perf_hooks'); * * const obs = new PerformanceObserver((items) => { * console.log(items.getEntries()[0].duration); @@ -26,7 +27,7 @@ * performance.measure('A to B', 'A', 'B'); * }); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/perf_hooks.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/perf_hooks.js) */ declare module 'perf_hooks' { import { AsyncResource } from 'node:async_hooks'; @@ -46,6 +47,7 @@ declare module 'perf_hooks' { readonly flags?: number | undefined; } /** + * The constructor of this class is not exposed to users directly. * @since v8.5.0 */ class PerformanceEntry { @@ -87,10 +89,20 @@ declare module 'perf_hooks' { readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type. toJSON(): any; } + /** + * Exposes marks created via the `Performance.mark()` method. + * @since v18.2.0, v16.17.0 + */ class PerformanceMark extends PerformanceEntry { readonly duration: 0; readonly entryType: 'mark'; } + /** + * Exposes measures created via the `Performance.measure()` method. + * + * The constructor of this class is not exposed to users directly. + * @since v18.2.0, v16.17.0 + */ class PerformanceMeasure extends PerformanceEntry { readonly entryType: 'measure'; } @@ -288,8 +300,8 @@ declare module 'perf_hooks' { * ```js * const { * performance, - * PerformanceObserver - * } = require('perf_hooks'); + * PerformanceObserver, + * } = require('node:perf_hooks'); * * const obs = new PerformanceObserver((perfObserverList, observer) => { * console.log(perfObserverList.getEntries()); @@ -330,8 +342,8 @@ declare module 'perf_hooks' { * ```js * const { * performance, - * PerformanceObserver - * } = require('perf_hooks'); + * PerformanceObserver, + * } = require('node:perf_hooks'); * * const obs = new PerformanceObserver((perfObserverList, observer) => { * console.log(perfObserverList.getEntriesByName('meow')); @@ -379,8 +391,8 @@ declare module 'perf_hooks' { * ```js * const { * performance, - * PerformanceObserver - * } = require('perf_hooks'); + * PerformanceObserver, + * } = require('node:perf_hooks'); * * const obs = new PerformanceObserver((perfObserverList, observer) => { * console.log(perfObserverList.getEntriesByType('mark')); @@ -414,6 +426,9 @@ declare module 'perf_hooks' { getEntriesByType(type: EntryType): PerformanceEntry[]; } type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void; + /** + * @since v8.5.0 + */ class PerformanceObserver extends AsyncResource { constructor(callback: PerformanceObserverCallback); /** @@ -427,8 +442,8 @@ declare module 'perf_hooks' { * ```js * const { * performance, - * PerformanceObserver - * } = require('perf_hooks'); + * PerformanceObserver, + * } = require('node:perf_hooks'); * * const obs = new PerformanceObserver((list, observer) => { * // Called once asynchronously. `list` contains three items. @@ -547,11 +562,10 @@ declare module 'perf_hooks' { */ recordDelta(): void; /** - * Adds the values from other to this histogram. + * Adds the values from `other` to this histogram. * @since v17.4.0, v16.14.0 - * @param other Recordable Histogram to combine with */ - add(other: RecordableHistogram): void; + add(other: RecordableHistogram): void; } /** * _This property is an extension by Node.js. It is not available in Web browsers._ @@ -566,7 +580,7 @@ declare module 'perf_hooks' { * detect. * * ```js - * const { monitorEventLoopDelay } = require('perf_hooks'); + * const { monitorEventLoopDelay } = require('node:perf_hooks'); * const h = monitorEventLoopDelay({ resolution: 20 }); * h.enable(); * // Do something. @@ -604,6 +618,20 @@ declare module 'perf_hooks' { * @since v15.9.0, v14.18.0 */ function createHistogram(options?: CreateHistogramOptions): RecordableHistogram; + import { performance as _performance } from 'perf_hooks'; + global { + /** + * `performance` is a global reference for `require('perf_hooks').performance` + * https://nodejs.org/api/globals.html#performance + * @since v16.0.0 + */ + var performance: typeof globalThis extends { + onmessage: any; + performance: infer T; + } + ? T + : typeof _performance; + } } declare module 'node:perf_hooks' { export * from 'perf_hooks'; diff --git a/node_modules/@types/node/process.d.ts b/node_modules/@types/node/process.d.ts index 12148f911..8f093ee91 100755 --- a/node_modules/@types/node/process.d.ts +++ b/node_modules/@types/node/process.d.ts @@ -250,7 +250,7 @@ declare module 'process' { * For example, to copy `process.stdin` to `process.stdout`: * * ```js - * import { stdin, stdout } from 'process'; + * import { stdin, stdout } from 'node:process'; * * stdin.pipe(stdout); * ``` @@ -297,7 +297,7 @@ declare module 'process' { * For example, assuming the following script for `process-args.js`: * * ```js - * import { argv } from 'process'; + * import { argv } from 'node:process'; * * // print process.argv * argv.forEach((val, index) => { @@ -389,7 +389,7 @@ declare module 'process' { * the specified `directory` does not exist). * * ```js - * import { chdir, cwd } from 'process'; + * import { chdir, cwd } from 'node:process'; * * console.log(`Starting directory: ${cwd()}`); * try { @@ -409,7 +409,7 @@ declare module 'process' { * process. * * ```js - * import { cwd } from 'process'; + * import { cwd } from 'node:process'; * * console.log(`Current directory: ${cwd()}`); * ``` @@ -420,7 +420,7 @@ declare module 'process' { * The port used by the Node.js debugger when enabled. * * ```js - * import process from 'process'; + * import process from 'node:process'; * * process.debugPort = 5858; * ``` @@ -432,12 +432,12 @@ declare module 'process' { * specific process warnings. These can be listened for by adding a handler to the `'warning'` event. * * ```js - * import { emitWarning } from 'process'; + * import { emitWarning } from 'node:process'; * * // Emit a warning with a code and additional detail. * emitWarning('Something happened!', { * code: 'MY_WARNING', - * detail: 'This is some additional information' + * detail: 'This is some additional information', * }); * // Emits: * // (node:56338) [MY_WARNING] Warning: Something happened! @@ -447,7 +447,7 @@ declare module 'process' { * In this example, an `Error` object is generated internally by`process.emitWarning()` and passed through to the `'warning'` handler. * * ```js - * import process from 'process'; + * import process from 'node:process'; * * process.on('warning', (warning) => { * console.warn(warning.name); // 'Warning' @@ -499,7 +499,7 @@ declare module 'process' { * While the following will: * * ```js - * import { env } from 'process'; + * import { env } from 'node:process'; * * env.foo = 'bar'; * console.log(env.foo); @@ -510,7 +510,7 @@ declare module 'process' { * throw an error when the value is not a string, number, or boolean. * * ```js - * import { env } from 'process'; + * import { env } from 'node:process'; * * env.test = null; * console.log(env.test); @@ -523,7 +523,7 @@ declare module 'process' { * Use `delete` to delete a property from `process.env`. * * ```js - * import { env } from 'process'; + * import { env } from 'node:process'; * * env.TEST = 1; * delete env.TEST; @@ -534,7 +534,7 @@ declare module 'process' { * On Windows operating systems, environment variables are case-insensitive. * * ```js - * import { env } from 'process'; + * import { env } from 'node:process'; * * env.TEST = 1; * console.log(env.test); @@ -543,7 +543,7 @@ declare module 'process' { * * Unless explicitly specified when creating a `Worker` instance, * each `Worker` thread has its own copy of `process.env`, based on its - * parent thread’s `process.env`, or whatever was specified as the `env` option + * parent thread's `process.env`, or whatever was specified as the `env` option * to the `Worker` constructor. Changes to `process.env` will not be visible * across `Worker` threads, and only the main thread can make changes that * are visible to the operating system or to native add-ons. @@ -560,7 +560,7 @@ declare module 'process' { * To exit with a 'failure' code: * * ```js - * import { exit } from 'process'; + * import { exit } from 'node:process'; * * exit(1); * ``` @@ -579,7 +579,7 @@ declare module 'process' { * truncated and lost: * * ```js - * import { exit } from 'process'; + * import { exit } from 'node:process'; * * // This is an example of what *not* to do: * if (someConditionNotMet()) { @@ -596,7 +596,7 @@ declare module 'process' { * scheduling any additional work for the event loop: * * ```js - * import process from 'process'; + * import process from 'node:process'; * * // How to properly set the exit code while letting * // the process exit gracefully. @@ -613,7 +613,7 @@ declare module 'process' { * In `Worker` threads, this function stops the current thread rather * than the current process. * @since v0.1.13 - * @param [code=0] The exit code. + * @param [code=0] The exit code. For string type, only integer strings (e.g.,'1') are allowed. */ exit(code?: number): never; /** @@ -873,7 +873,7 @@ declare module 'process' { * The `process.version` property contains the Node.js version string. * * ```js - * import { version } from 'process'; + * import { version } from 'node:process'; * * console.log(`Version: ${version}`); * // Version: v14.8.0 @@ -890,7 +890,7 @@ declare module 'process' { * to load modules that were compiled against a different module ABI version. * * ```js - * import { versions } from 'process'; + * import { versions } from 'node:process'; * * console.log(versions); * ``` @@ -918,10 +918,10 @@ declare module 'process' { */ readonly versions: ProcessVersions; /** - * The `process.config` property returns an `Object` containing the JavaScript - * representation of the configure options used to compile the current Node.js - * executable. This is the same as the `config.gypi` file that was produced when - * running the `./configure` script. + * The `process.config` property returns a frozen `Object` containing the + * JavaScript representation of the configure options used to compile the current + * Node.js executable. This is the same as the `config.gypi` file that was produced + * when running the `./configure` script. * * An example of the possible output looks like: * @@ -943,7 +943,6 @@ declare module 'process' { * node_shared_http_parser: 'false', * node_shared_libuv: 'false', * node_shared_zlib: 'false', - * node_use_dtrace: 'false', * node_use_openssl: 'true', * node_shared_openssl: 'false', * strict_aliasing: 'true', @@ -952,13 +951,6 @@ declare module 'process' { * } * } * ``` - * - * The `process.config` property is **not** read-only and there are existing - * modules in the ecosystem that are known to extend, modify, or entirely replace - * the value of `process.config`. - * - * Modifying the `process.config` property, or any child-property of the`process.config` object has been deprecated. The `process.config` will be made - * read-only in a future release. * @since v0.7.7 */ readonly config: ProcessConfig; @@ -977,7 +969,7 @@ declare module 'process' { * other than kill the target process. * * ```js - * import process, { kill } from 'process'; + * import process, { kill } from 'node:process'; * * process.on('SIGHUP', () => { * console.log('Got SIGHUP signal.'); @@ -1002,7 +994,7 @@ declare module 'process' { * The `process.pid` property returns the PID of the process. * * ```js - * import { pid } from 'process'; + * import { pid } from 'node:process'; * * console.log(`This process is pid ${pid}`); * ``` @@ -1014,7 +1006,7 @@ declare module 'process' { * current process. * * ```js - * import { ppid } from 'process'; + * import { ppid } from 'node:process'; * * console.log(`The parent process is pid ${ppid}`); * ``` @@ -1044,7 +1036,7 @@ declare module 'process' { * Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`,`'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`. * * ```js - * import { arch } from 'process'; + * import { arch } from 'node:process'; * * console.log(`This processor architecture is ${arch}`); * ``` @@ -1066,7 +1058,7 @@ declare module 'process' { * * `'win32'` * * ```js - * import { platform } from 'process'; + * import { platform } from 'node:process'; * * console.log(`This platform is ${platform}`); * ``` @@ -1089,6 +1081,17 @@ declare module 'process' { */ mainModule?: Module | undefined; memoryUsage: MemoryUsageFn; + /** + * Gets the amount of memory available to the process (in bytes) based on + * limits imposed by the OS. If there is no such constraint, or the constraint + * is unknown, `undefined` is returned. + * + * See [`uv_get_constrained_memory`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_get_constrained_memory) for more + * information. + * @since v19.6.0, v18.15.0 + * @experimental + */ + constrainedMemory(): number | undefined; /** * The `process.cpuUsage()` method returns the user and system CPU time usage of * the current process, in an object with properties `user` and `system`, whose @@ -1100,7 +1103,7 @@ declare module 'process' { * argument to the function, to get a diff reading. * * ```js - * import { cpuUsage } from 'process'; + * import { cpuUsage } from 'node:process'; * * const startUsage = cpuUsage(); * // { user: 38579, system: 6986 } @@ -1124,7 +1127,7 @@ declare module 'process' { * See the [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick) guide for more background. * * ```js - * import { nextTick } from 'process'; + * import { nextTick } from 'node:process'; * * console.log('start'); * nextTick(() => { @@ -1142,7 +1145,7 @@ declare module 'process' { * I/O has occurred: * * ```js - * import { nextTick } from 'process'; + * import { nextTick } from 'node:process'; * * function MyThing(options) { * this.setupOptions(options); @@ -1190,7 +1193,7 @@ declare module 'process' { * The following approach is much better: * * ```js - * import { nextTick } from 'process'; + * import { nextTick } from 'node:process'; * * function definitelyAsync(arg, cb) { * if (arg) { @@ -1215,10 +1218,10 @@ declare module 'process' { * ```js * { * name: 'node', - * lts: 'Erbium', - * sourceUrl: 'https://nodejs.org/download/release/v12.18.1/node-v12.18.1.tar.gz', - * headersUrl: 'https://nodejs.org/download/release/v12.18.1/node-v12.18.1-headers.tar.gz', - * libUrl: 'https://nodejs.org/download/release/v12.18.1/win-x64/node.lib' + * lts: 'Hydrogen', + * sourceUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0.tar.gz', + * headersUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0-headers.tar.gz', + * libUrl: 'https://nodejs.org/download/release/v18.12.0/win-x64/node.lib' * } * ``` * @@ -1322,7 +1325,7 @@ declare module 'process' { * dashes: * * ```js - * import { allowedNodeEnvironmentFlags } from 'process'; + * import { allowedNodeEnvironmentFlags } from 'node:process'; * * allowedNodeEnvironmentFlags.forEach((flag) => { * // -r @@ -1348,7 +1351,7 @@ declare module 'process' { report?: ProcessReport | undefined; /** * ```js - * import { resourceUsage } from 'process'; + * import { resourceUsage } from 'node:process'; * * console.log(resourceUsage()); * /* diff --git a/node_modules/@types/node/punycode.d.ts b/node_modules/@types/node/punycode.d.ts index 87ebbb904..892720728 100755 --- a/node_modules/@types/node/punycode.d.ts +++ b/node_modules/@types/node/punycode.d.ts @@ -24,7 +24,7 @@ * made available to developers as a convenience. Fixes or other modifications to * the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project. * @deprecated Since v7.0.0 - Deprecated - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/punycode.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/punycode.js) */ declare module 'punycode' { /** diff --git a/node_modules/@types/node/querystring.d.ts b/node_modules/@types/node/querystring.d.ts index e694d8c84..e9d087c27 100755 --- a/node_modules/@types/node/querystring.d.ts +++ b/node_modules/@types/node/querystring.d.ts @@ -1,15 +1,15 @@ /** - * The `querystring` module provides utilities for parsing and formatting URL + * The `node:querystring` module provides utilities for parsing and formatting URL * query strings. It can be accessed using: * * ```js - * const querystring = require('querystring'); + * const querystring = require('node:querystring'); * ``` * - * The `querystring` API is considered Legacy. While it is still maintained, - * new code should use the `URLSearchParams` API instead. - * @deprecated Legacy - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/querystring.js) + * `querystring` is more performant than `URLSearchParams` but is not a + * standardized API. Use `URLSearchParams` when performance is not critical or + * when compatibility with browser code is desirable. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/querystring.js) */ declare module 'querystring' { interface StringifyOptions { diff --git a/node_modules/@types/node/readline.d.ts b/node_modules/@types/node/readline.d.ts index 6ab64acbb..e6f7b0abb 100755 --- a/node_modules/@types/node/readline.d.ts +++ b/node_modules/@types/node/readline.d.ts @@ -1,5 +1,5 @@ /** - * The `readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time. + * The `node:readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time. * * To use the promise-based APIs: * @@ -13,7 +13,7 @@ * import * as readline from 'node:readline'; * ``` * - * The following simple example illustrates the basic use of the `readline` module. + * The following simple example illustrates the basic use of the `node:readline`module. * * ```js * import * as readline from 'node:readline/promises'; @@ -30,12 +30,11 @@ * * Once this code is invoked, the Node.js application will not terminate until the`readline.Interface` is closed because the interface waits for data to be * received on the `input` stream. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/readline.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/readline.js) */ declare module 'readline' { import { Abortable, EventEmitter } from 'node:events'; import * as promises from 'node:readline/promises'; - export { promises }; export interface Key { sequence?: string | undefined; @@ -74,7 +73,7 @@ declare module 'readline' { * const showResults = debounce(() => { * console.log( * '\n', - * values.filter((val) => val.startsWith(rl.line)).join(' ') + * values.filter((val) => val.startsWith(rl.line)).join(' '), * ); * }, 300); * process.stdin.on('keypress', (c, k) => { @@ -100,7 +99,7 @@ declare module 'readline' { * > Instances of the `readline.Interface` class are constructed using the * > `readline.createInterface()` method. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor */ protected constructor(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean); /** @@ -109,12 +108,12 @@ declare module 'readline' { * > Instances of the `readline.Interface` class are constructed using the * > `readline.createInterface()` method. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor */ protected constructor(options: ReadLineOptions); /** * The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`. - * @since v15.3.0 + * @since v15.3.0, v14.17.0 * @return the current prompt string */ getPrompt(): string; @@ -124,13 +123,13 @@ declare module 'readline' { */ setPrompt(prompt: string): void; /** - * The `rl.prompt()` method writes the `readline.Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new + * The `rl.prompt()` method writes the `Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new * location at which to provide input. * * When called, `rl.prompt()` will resume the `input` stream if it has been * paused. * - * If the `readline.Interface` was created with `output` set to `null` or`undefined` the prompt is not written. + * If the `Interface` was created with `output` set to `null` or`undefined` the prompt is not written. * @since v0.1.98 * @param preserveCursor If `true`, prevents the cursor placement from being reset to `0`. */ @@ -142,12 +141,14 @@ declare module 'readline' { * When called, `rl.question()` will resume the `input` stream if it has been * paused. * - * If the `readline.Interface` was created with `output` set to `null` or`undefined` the `query` is not written. + * If the `Interface` was created with `output` set to `null` or`undefined` the `query` is not written. * * The `callback` function passed to `rl.question()` does not follow the typical * pattern of accepting an `Error` object or `null` as the first argument. * The `callback` is called with the provided answer as the only argument. * + * An error will be thrown if calling `rl.question()` after `rl.close()`. + * * Example usage: * * ```js @@ -172,25 +173,6 @@ declare module 'readline' { * * setTimeout(() => ac.abort(), 10000); * ``` - * - * If this method is invoked as it's util.promisify()ed version, it returns a - * Promise that fulfills with the answer. If the question is canceled using - * an `AbortController` it will reject with an `AbortError`. - * - * ```js - * const util = require('util'); - * const question = util.promisify(rl.question).bind(rl); - * - * async function questionExample() { - * try { - * const answer = await question('What is you favorite food? '); - * console.log(`Oh, so your favorite food is ${answer}`); - * } catch (err) { - * console.error('Question rejected', err); - * } - * } - * questionExample(); - * ``` * @since v0.3.3 * @param query A statement or query to write to `output`, prepended to the prompt. * @param callback A callback function that is invoked with the user's input in response to the `query`. @@ -201,7 +183,7 @@ declare module 'readline' { * The `rl.pause()` method pauses the `input` stream, allowing it to be resumed * later if necessary. * - * Calling `rl.pause()` does not immediately pause other events (including`'line'`) from being emitted by the `readline.Interface` instance. + * Calling `rl.pause()` does not immediately pause other events (including`'line'`) from being emitted by the `Interface` instance. * @since v0.3.4 */ pause(): this; @@ -211,12 +193,12 @@ declare module 'readline' { */ resume(): this; /** - * The `rl.close()` method closes the `readline.Interface` instance and + * The `rl.close()` method closes the `Interface` instance and * relinquishes control over the `input` and `output` streams. When called, * the `'close'` event will be emitted. * * Calling `rl.close()` does not immediately stop other events (including `'line'`) - * from being emitted by the `readline.Interface` instance. + * from being emitted by the `Interface` instance. * @since v0.1.98 */ close(): void; @@ -231,7 +213,7 @@ declare module 'readline' { * When called, `rl.write()` will resume the `input` stream if it has been * paused. * - * If the `readline.Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written. + * If the `Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written. * * ```js * rl.write('Delete this!'); @@ -351,10 +333,10 @@ declare module 'readline' { * The `readline.createInterface()` method creates a new `readline.Interface`instance. * * ```js - * const readline = require('readline'); + * const readline = require('node:readline'); * const rl = readline.createInterface({ * input: process.stdin, - * output: process.stdout + * output: process.stdout, * }); * ``` * @@ -373,14 +355,8 @@ declare module 'readline' { * (`process.stdout` does this automatically when it is a TTY). * * When creating a `readline.Interface` using `stdin` as input, the program - * will not terminate until it receives `EOF` (Ctrl+D on - * Linux/macOS, Ctrl+Z followed by Return on - * Windows). - * If you want your application to exit without waiting for user input, you can `unref()` the standard input stream: - * - * ```js - * process.stdin.unref(); - * ``` + * will not terminate until it receives an [EOF character](https://en.wikipedia.org/wiki/End-of-file#EOF_character). To exit without + * waiting for user input, call `process.stdin.unref()`. * @since v0.1.98 */ export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface; @@ -408,11 +384,11 @@ declare module 'readline' { * implement a small command-line interface: * * ```js - * const readline = require('readline'); + * const readline = require('node:readline'); * const rl = readline.createInterface({ * input: process.stdin, * output: process.stdout, - * prompt: 'OHAI> ' + * prompt: 'OHAI> ', * }); * * rl.prompt(); @@ -440,15 +416,15 @@ declare module 'readline' { * well as a `for await...of` loop: * * ```js - * const fs = require('fs'); - * const readline = require('readline'); + * const fs = require('node:fs'); + * const readline = require('node:readline'); * * async function processLineByLine() { * const fileStream = fs.createReadStream('input.txt'); * * const rl = readline.createInterface({ * input: fileStream, - * crlfDelay: Infinity + * crlfDelay: Infinity, * }); * // Note: we use the crlfDelay option to recognize all instances of CR LF * // ('\r\n') in input.txt as a single line break. @@ -465,12 +441,12 @@ declare module 'readline' { * Alternatively, one could use the `'line'` event: * * ```js - * const fs = require('fs'); - * const readline = require('readline'); + * const fs = require('node:fs'); + * const readline = require('node:readline'); * * const rl = readline.createInterface({ * input: fs.createReadStream('sample.txt'), - * crlfDelay: Infinity + * crlfDelay: Infinity, * }); * * rl.on('line', (line) => { @@ -481,15 +457,15 @@ declare module 'readline' { * Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied: * * ```js - * const { once } = require('events'); - * const { createReadStream } = require('fs'); - * const { createInterface } = require('readline'); + * const { once } = require('node:events'); + * const { createReadStream } = require('node:fs'); + * const { createInterface } = require('node:readline'); * * (async function processLineByLine() { * try { * const rl = createInterface({ * input: createReadStream('big-file.txt'), - * crlfDelay: Infinity + * crlfDelay: Infinity, * }); * * rl.on('line', (line) => { @@ -539,109 +515,6 @@ declare module 'readline' { /** * The `readline.moveCursor()` method moves the cursor _relative_ to its current * position in a given `TTY` `stream`. - * - * ## Example: Tiny CLI - * - * The following example illustrates the use of `readline.Interface` class to - * implement a small command-line interface: - * - * ```js - * const readline = require('readline'); - * const rl = readline.createInterface({ - * input: process.stdin, - * output: process.stdout, - * prompt: 'OHAI> ' - * }); - * - * rl.prompt(); - * - * rl.on('line', (line) => { - * switch (line.trim()) { - * case 'hello': - * console.log('world!'); - * break; - * default: - * console.log(`Say what? I might have heard '${line.trim()}'`); - * break; - * } - * rl.prompt(); - * }).on('close', () => { - * console.log('Have a great day!'); - * process.exit(0); - * }); - * ``` - * - * ## Example: Read file stream line-by-Line - * - * A common use case for `readline` is to consume an input file one line at a - * time. The easiest way to do so is leveraging the `fs.ReadStream` API as - * well as a `for await...of` loop: - * - * ```js - * const fs = require('fs'); - * const readline = require('readline'); - * - * async function processLineByLine() { - * const fileStream = fs.createReadStream('input.txt'); - * - * const rl = readline.createInterface({ - * input: fileStream, - * crlfDelay: Infinity - * }); - * // Note: we use the crlfDelay option to recognize all instances of CR LF - * // ('\r\n') in input.txt as a single line break. - * - * for await (const line of rl) { - * // Each line in input.txt will be successively available here as `line`. - * console.log(`Line from file: ${line}`); - * } - * } - * - * processLineByLine(); - * ``` - * - * Alternatively, one could use the `'line'` event: - * - * ```js - * const fs = require('fs'); - * const readline = require('readline'); - * - * const rl = readline.createInterface({ - * input: fs.createReadStream('sample.txt'), - * crlfDelay: Infinity - * }); - * - * rl.on('line', (line) => { - * console.log(`Line from file: ${line}`); - * }); - * ``` - * - * Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied: - * - * ```js - * const { once } = require('events'); - * const { createReadStream } = require('fs'); - * const { createInterface } = require('readline'); - * - * (async function processLineByLine() { - * try { - * const rl = createInterface({ - * input: createReadStream('big-file.txt'), - * crlfDelay: Infinity - * }); - * - * rl.on('line', (line) => { - * // Process the line. - * }); - * - * await once(rl, 'close'); - * - * console.log('File processed.'); - * } catch (err) { - * console.error(err); - * } - * })(); - * ``` * @since v0.7.7 * @param callback Invoked once the operation completes. * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. diff --git a/node_modules/@types/node/readline/promises.d.ts b/node_modules/@types/node/readline/promises.d.ts index 8f9f06f0b..079fbdf86 100755 --- a/node_modules/@types/node/readline/promises.d.ts +++ b/node_modules/@types/node/readline/promises.d.ts @@ -1,23 +1,28 @@ /** - * The `readline/promise` module provides an API for reading lines of input from a Readable stream one line at a time. - * - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/readline/promises.js) * @since v17.0.0 + * @experimental */ declare module 'readline/promises' { import { Interface as _Interface, ReadLineOptions, Completer, AsyncCompleter, Direction } from 'node:readline'; import { Abortable } from 'node:events'; - + /** + * Instances of the `readlinePromises.Interface` class are constructed using the`readlinePromises.createInterface()` method. Every instance is associated with a + * single `input` `Readable` stream and a single `output` `Writable` stream. + * The `output` stream is used to print prompts for user input that arrives on, + * and is read from, the `input` stream. + * @since v17.0.0 + */ class Interface extends _Interface { /** - * The rl.question() method displays the query by writing it to the output, waits for user input to be provided on input, - * then invokes the callback function passing the provided input as the first argument. + * The `rl.question()` method displays the `query` by writing it to the `output`, + * waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument. * - * When called, rl.question() will resume the input stream if it has been paused. + * When called, `rl.question()` will resume the `input` stream if it has been + * paused. * - * If the readlinePromises.Interface was created with output set to null or undefined the query is not written. + * If the `Interface` was created with `output` set to `null` or`undefined` the `query` is not written. * - * If the question is called after rl.close(), it returns a rejected promise. + * If the question is called after `rl.close()`, it returns a rejected promise. * * Example usage: * @@ -26,7 +31,7 @@ declare module 'readline/promises' { * console.log(`Oh, so your favorite food is ${answer}`); * ``` * - * Using an AbortSignal to cancel a question. + * Using an `AbortSignal` to cancel a question. * * ```js * const signal = AbortSignal.timeout(10_000); @@ -38,61 +43,87 @@ declare module 'readline/promises' { * const answer = await rl.question('What is your favorite food? ', { signal }); * console.log(`Oh, so your favorite food is ${answer}`); * ``` - * * @since v17.0.0 - * @param query A statement or query to write to output, prepended to the prompt. + * @param query A statement or query to write to `output`, prepended to the prompt. + * @return A promise that is fulfilled with the user's input in response to the `query`. */ question(query: string): Promise; question(query: string, options: Abortable): Promise; } - + /** + * @since v17.0.0 + */ class Readline { /** * @param stream A TTY stream. */ - constructor(stream: NodeJS.WritableStream, options?: { autoCommit?: boolean }); + constructor( + stream: NodeJS.WritableStream, + options?: { + autoCommit?: boolean; + } + ); /** - * The `rl.clearLine()` method adds to the internal list of pending action an action that clears current line of the associated `stream` in a specified direction identified by `dir`. - * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor. + * The `rl.clearLine()` method adds to the internal list of pending action an + * action that clears current line of the associated `stream` in a specified + * direction identified by `dir`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this */ clearLine(dir: Direction): this; /** - * The `rl.clearScreenDown()` method adds to the internal list of pending action an action that clears the associated `stream` from the current position of the cursor down. - * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor. + * The `rl.clearScreenDown()` method adds to the internal list of pending action an + * action that clears the associated stream from the current position of the + * cursor down. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this */ clearScreenDown(): this; /** - * The `rl.commit()` method sends all the pending actions to the associated `stream` and clears the internal list of pending actions. + * The `rl.commit()` method sends all the pending actions to the associated`stream` and clears the internal list of pending actions. + * @since v17.0.0 */ commit(): Promise; /** - * The `rl.cursorTo()` method adds to the internal list of pending action an action that moves cursor to the specified position in the associated `stream`. - * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor. + * The `rl.cursorTo()` method adds to the internal list of pending action an action + * that moves cursor to the specified position in the associated `stream`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this */ cursorTo(x: number, y?: number): this; /** - * The `rl.moveCursor()` method adds to the internal list of pending action an action that moves the cursor relative to its current position in the associated `stream`. - * Call `rl.commit()` to see the effect of this method, unless autoCommit: true was passed to the constructor. + * The `rl.moveCursor()` method adds to the internal list of pending action an + * action that moves the cursor _relative_ to its current position in the + * associated `stream`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this */ moveCursor(dx: number, dy: number): this; /** - * The `rl.rollback()` method clears the internal list of pending actions without sending it to the associated `stream`. + * The `rl.rollback` methods clears the internal list of pending actions without + * sending it to the associated `stream`. + * @since v17.0.0 + * @return this */ rollback(): this; } - /** - * The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface` instance. + * The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface`instance. * * ```js * const readlinePromises = require('node:readline/promises'); * const rl = readlinePromises.createInterface({ * input: process.stdin, - * output: process.stdout + * output: process.stdout, * }); * ``` * - * Once the `readlinePromises.Interface` instance is created, the most common case is to listen for the `'line'` event: + * Once the `readlinePromises.Interface` instance is created, the most common case + * is to listen for the `'line'` event: * * ```js * rl.on('line', (line) => { @@ -100,42 +131,13 @@ declare module 'readline/promises' { * }); * ``` * - * If `terminal` is `true` for this instance then the `output` stream will get the best compatibility if it defines an `output.columns` property, - * and emits a `'resize'` event on the `output`, if or when the columns ever change (`process.stdout` does this automatically when it is a TTY). - * - * ## Use of the `completer` function - * - * The `completer` function takes the current line entered by the user as an argument, and returns an `Array` with 2 entries: - * - * - An Array with matching entries for the completion. - * - The substring that was used for the matching. - * - * For instance: `[[substr1, substr2, ...], originalsubstring]`. - * - * ```js - * function completer(line) { - * const completions = '.help .error .exit .quit .q'.split(' '); - * const hits = completions.filter((c) => c.startsWith(line)); - * // Show all completions if none found - * return [hits.length ? hits : completions, line]; - * } - * ``` - * - * The `completer` function can also returns a `Promise`, or be asynchronous: - * - * ```js - * async function completer(linePartial) { - * await someAsyncWork(); - * return [['123'], linePartial]; - * } - * ``` + * If `terminal` is `true` for this instance then the `output` stream will get + * the best compatibility if it defines an `output.columns` property and emits + * a `'resize'` event on the `output` if or when the columns ever change + * (`process.stdout` does this automatically when it is a TTY). + * @since v17.0.0 */ - function createInterface( - input: NodeJS.ReadableStream, - output?: NodeJS.WritableStream, - completer?: Completer | AsyncCompleter, - terminal?: boolean, - ): Interface; + function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface; function createInterface(options: ReadLineOptions): Interface; } declare module 'node:readline/promises' { diff --git a/node_modules/@types/node/repl.d.ts b/node_modules/@types/node/repl.d.ts index be42ccc4a..c8147ed1b 100755 --- a/node_modules/@types/node/repl.d.ts +++ b/node_modules/@types/node/repl.d.ts @@ -1,12 +1,12 @@ /** - * The `repl` module provides a Read-Eval-Print-Loop (REPL) implementation that - * is available both as a standalone program or includible in other applications. - * It can be accessed using: + * The `node:repl` module provides a Read-Eval-Print-Loop (REPL) implementation + * that is available both as a standalone program or includible in other + * applications. It can be accessed using: * * ```js - * const repl = require('repl'); + * const repl = require('node:repl'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/repl.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/repl.js) */ declare module 'repl' { import { Interface, Completer, AsyncCompleter } from 'node:readline'; @@ -41,8 +41,8 @@ declare module 'repl' { * error with `repl.Recoverable` to indicate the input was incomplete and prompt for * additional lines. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_default_evaluation - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_custom_evaluation_functions + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_default_evaluation + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_custom_evaluation_functions */ eval?: REPLEval | undefined; /** @@ -74,13 +74,13 @@ declare module 'repl' { * The function to invoke to format the output of each command before writing to `output`. * Default: a wrapper for `util.inspect`. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_customizing_repl_output + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_customizing_repl_output */ writer?: REPLWriter | undefined; /** * An optional function used for custom Tab auto completion. * - * @see https://nodejs.org/dist/latest-v11.x/docs/api/readline.html#readline_use_of_the_completer_function + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#readline_use_of_the_completer_function */ completer?: Completer | AsyncCompleter | undefined; /** @@ -124,7 +124,7 @@ declare module 'repl' { * or directly using the JavaScript `new` keyword. * * ```js - * const repl = require('repl'); + * const repl = require('node:repl'); * * const options = { useColors: true }; * @@ -162,33 +162,33 @@ declare module 'repl' { /** * A value indicating whether the REPL is currently in "editor mode". * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_commands_and_special_keys + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_commands_and_special_keys */ readonly editorMode: boolean; /** * A value indicating whether the `_` variable has been assigned. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable */ readonly underscoreAssigned: boolean; /** * The last evaluation result from the REPL (assigned to the `_` variable inside of the REPL). * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable */ readonly last: any; /** * A value indicating whether the `_error` variable has been assigned. * * @since v9.8.0 - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable */ readonly underscoreErrAssigned: boolean; /** * The last error raised inside the REPL (assigned to the `_error` variable inside of the REPL). * * @since v9.8.0 - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable */ readonly lastError: any; /** @@ -240,7 +240,7 @@ declare module 'repl' { * * `REPLServer` cannot be subclassed due to implementation specifics in NodeJS. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_class_replserver + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_class_replserver */ private constructor(); /** @@ -251,7 +251,7 @@ declare module 'repl' { * The following example shows two new commands added to the REPL instance: * * ```js - * const repl = require('repl'); + * const repl = require('node:repl'); * * const replServer = repl.start({ prompt: '> ' }); * replServer.defineCommand('sayhello', { @@ -260,7 +260,7 @@ declare module 'repl' { * this.clearBufferedCommand(); * console.log(`Hello, ${name}!`); * this.displayPrompt(); - * } + * }, * }); * replServer.defineCommand('saybye', function saybye() { * console.log('Goodbye!'); @@ -401,7 +401,7 @@ declare module 'repl' { * If `options` is a string, then it specifies the input prompt: * * ```js - * const repl = require('repl'); + * const repl = require('node:repl'); * * // a Unix style prompt * repl.start('$ '); @@ -412,7 +412,7 @@ declare module 'repl' { /** * Indicates a recoverable error that a `REPLServer` can use to support multi-line input. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_recoverable_errors + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_recoverable_errors */ class Recoverable extends SyntaxError { err: Error; diff --git a/node_modules/@types/node/stream.d.ts b/node_modules/@types/node/stream.d.ts index d478f335c..7f7b793d8 100755 --- a/node_modules/@types/node/stream.d.ts +++ b/node_modules/@types/node/stream.d.ts @@ -1,23 +1,24 @@ /** * A stream is an abstract interface for working with streaming data in Node.js. - * The `stream` module provides an API for implementing the stream interface. + * The `node:stream` module provides an API for implementing the stream interface. * * There are many stream objects provided by Node.js. For instance, a `request to an HTTP server` and `process.stdout` are both stream instances. * * Streams can be readable, writable, or both. All streams are instances of `EventEmitter`. * - * To access the `stream` module: + * To access the `node:stream` module: * * ```js - * const stream = require('stream'); + * const stream = require('node:stream'); * ``` * - * The `stream` module is useful for creating new types of stream instances. It is - * usually not necessary to use the `stream` module to consume streams. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/stream.js) + * The `node:stream` module is useful for creating new types of stream instances. + * It is usually not necessary to use the `node:stream` module to consume streams. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/stream.js) */ declare module 'stream' { import { EventEmitter, Abortable } from 'node:events'; + import { Blob as NodeBlob } from 'node:buffer'; import * as streamPromises from 'node:stream/promises'; import * as streamConsumers from 'node:stream/consumers'; import * as streamWeb from 'node:stream/web'; @@ -29,6 +30,739 @@ declare module 'stream' { } ): T; } + import Stream = internal.Stream; + import Readable = internal.Readable; + import ReadableOptions = internal.ReadableOptions; + class ReadableBase extends Stream implements NodeJS.ReadableStream { + /** + * A utility method for creating Readable Streams out of iterators. + */ + static from(iterable: Iterable | AsyncIterable, options?: ReadableOptions): Readable; + /** + * Returns whether the stream has been read from or cancelled. + * @since v16.8.0 + */ + static isDisturbed(stream: Readable | NodeJS.ReadableStream): boolean; + /** + * Returns whether the stream was destroyed or errored before emitting `'end'`. + * @since v16.8.0 + * @experimental + */ + readonly readableAborted: boolean; + /** + * Is `true` if it is safe to call `readable.read()`, which means + * the stream has not been destroyed or emitted `'error'` or `'end'`. + * @since v11.4.0 + */ + readable: boolean; + /** + * Returns whether `'data'` has been emitted. + * @since v16.7.0, v14.18.0 + * @experimental + */ + readonly readableDidRead: boolean; + /** + * Getter for the property `encoding` of a given `Readable` stream. The `encoding`property can be set using the `readable.setEncoding()` method. + * @since v12.7.0 + */ + readonly readableEncoding: BufferEncoding | null; + /** + * Becomes `true` when `'end'` event is emitted. + * @since v12.9.0 + */ + readonly readableEnded: boolean; + /** + * This property reflects the current state of a `Readable` stream as described + * in the `Three states` section. + * @since v9.4.0 + */ + readonly readableFlowing: boolean | null; + /** + * Returns the value of `highWaterMark` passed when creating this `Readable`. + * @since v9.3.0 + */ + readonly readableHighWaterMark: number; + /** + * This property contains the number of bytes (or objects) in the queue + * ready to be read. The value provides introspection data regarding + * the status of the `highWaterMark`. + * @since v9.4.0 + */ + readonly readableLength: number; + /** + * Getter for the property `objectMode` of a given `Readable` stream. + * @since v12.3.0 + */ + readonly readableObjectMode: boolean; + /** + * Is `true` after `readable.destroy()` has been called. + * @since v8.0.0 + */ + destroyed: boolean; + /** + * Is `true` after `'close'` has been emitted. + * @since v18.0.0 + */ + readonly closed: boolean; + /** + * Returns error if the stream has been destroyed with an error. + * @since v18.0.0 + */ + readonly errored: Error | null; + constructor(opts?: ReadableOptions); + _construct?(callback: (error?: Error | null) => void): void; + _read(size: number): void; + /** + * The `readable.read()` method reads data out of the internal buffer and + * returns it. If no data is available to be read, `null` is returned. By default, + * the data is returned as a `Buffer` object unless an encoding has been + * specified using the `readable.setEncoding()` method or the stream is operating + * in object mode. + * + * The optional `size` argument specifies a specific number of bytes to read. If`size` bytes are not available to be read, `null` will be returned _unless_the stream has ended, in which + * case all of the data remaining in the internal + * buffer will be returned. + * + * If the `size` argument is not specified, all of the data contained in the + * internal buffer will be returned. + * + * The `size` argument must be less than or equal to 1 GiB. + * + * The `readable.read()` method should only be called on `Readable` streams + * operating in paused mode. In flowing mode, `readable.read()` is called + * automatically until the internal buffer is fully drained. + * + * ```js + * const readable = getReadableStreamSomehow(); + * + * // 'readable' may be triggered multiple times as data is buffered in + * readable.on('readable', () => { + * let chunk; + * console.log('Stream is readable (new data received in buffer)'); + * // Use a loop to make sure we read all currently available data + * while (null !== (chunk = readable.read())) { + * console.log(`Read ${chunk.length} bytes of data...`); + * } + * }); + * + * // 'end' will be triggered once when there is no more data available + * readable.on('end', () => { + * console.log('Reached end of stream.'); + * }); + * ``` + * + * Each call to `readable.read()` returns a chunk of data, or `null`. The chunks + * are not concatenated. A `while` loop is necessary to consume all data + * currently in the buffer. When reading a large file `.read()` may return `null`, + * having consumed all buffered content so far, but there is still more data to + * come not yet buffered. In this case a new `'readable'` event will be emitted + * when there is more data in the buffer. Finally the `'end'` event will be + * emitted when there is no more data to come. + * + * Therefore to read a file's whole contents from a `readable`, it is necessary + * to collect chunks across multiple `'readable'` events: + * + * ```js + * const chunks = []; + * + * readable.on('readable', () => { + * let chunk; + * while (null !== (chunk = readable.read())) { + * chunks.push(chunk); + * } + * }); + * + * readable.on('end', () => { + * const content = chunks.join(''); + * }); + * ``` + * + * A `Readable` stream in object mode will always return a single item from + * a call to `readable.read(size)`, regardless of the value of the`size` argument. + * + * If the `readable.read()` method returns a chunk of data, a `'data'` event will + * also be emitted. + * + * Calling {@link read} after the `'end'` event has + * been emitted will return `null`. No runtime error will be raised. + * @since v0.9.4 + * @param size Optional argument to specify how much data to read. + */ + read(size?: number): any; + /** + * The `readable.setEncoding()` method sets the character encoding for + * data read from the `Readable` stream. + * + * By default, no encoding is assigned and stream data will be returned as`Buffer` objects. Setting an encoding causes the stream data + * to be returned as strings of the specified encoding rather than as `Buffer`objects. For instance, calling `readable.setEncoding('utf8')` will cause the + * output data to be interpreted as UTF-8 data, and passed as strings. Calling`readable.setEncoding('hex')` will cause the data to be encoded in hexadecimal + * string format. + * + * The `Readable` stream will properly handle multi-byte characters delivered + * through the stream that would otherwise become improperly decoded if simply + * pulled from the stream as `Buffer` objects. + * + * ```js + * const readable = getReadableStreamSomehow(); + * readable.setEncoding('utf8'); + * readable.on('data', (chunk) => { + * assert.equal(typeof chunk, 'string'); + * console.log('Got %d characters of string data:', chunk.length); + * }); + * ``` + * @since v0.9.4 + * @param encoding The encoding to use. + */ + setEncoding(encoding: BufferEncoding): this; + /** + * The `readable.pause()` method will cause a stream in flowing mode to stop + * emitting `'data'` events, switching out of flowing mode. Any data that + * becomes available will remain in the internal buffer. + * + * ```js + * const readable = getReadableStreamSomehow(); + * readable.on('data', (chunk) => { + * console.log(`Received ${chunk.length} bytes of data.`); + * readable.pause(); + * console.log('There will be no additional data for 1 second.'); + * setTimeout(() => { + * console.log('Now data will start flowing again.'); + * readable.resume(); + * }, 1000); + * }); + * ``` + * + * The `readable.pause()` method has no effect if there is a `'readable'`event listener. + * @since v0.9.4 + */ + pause(): this; + /** + * The `readable.resume()` method causes an explicitly paused `Readable` stream to + * resume emitting `'data'` events, switching the stream into flowing mode. + * + * The `readable.resume()` method can be used to fully consume the data from a + * stream without actually processing any of that data: + * + * ```js + * getReadableStreamSomehow() + * .resume() + * .on('end', () => { + * console.log('Reached the end, but did not read anything.'); + * }); + * ``` + * + * The `readable.resume()` method has no effect if there is a `'readable'`event listener. + * @since v0.9.4 + */ + resume(): this; + /** + * The `readable.isPaused()` method returns the current operating state of the`Readable`. This is used primarily by the mechanism that underlies the`readable.pipe()` method. In most + * typical cases, there will be no reason to + * use this method directly. + * + * ```js + * const readable = new stream.Readable(); + * + * readable.isPaused(); // === false + * readable.pause(); + * readable.isPaused(); // === true + * readable.resume(); + * readable.isPaused(); // === false + * ``` + * @since v0.11.14 + */ + isPaused(): boolean; + /** + * The `readable.unpipe()` method detaches a `Writable` stream previously attached + * using the {@link pipe} method. + * + * If the `destination` is not specified, then _all_ pipes are detached. + * + * If the `destination` is specified, but no pipe is set up for it, then + * the method does nothing. + * + * ```js + * const fs = require('node:fs'); + * const readable = getReadableStreamSomehow(); + * const writable = fs.createWriteStream('file.txt'); + * // All the data from readable goes into 'file.txt', + * // but only for the first second. + * readable.pipe(writable); + * setTimeout(() => { + * console.log('Stop writing to file.txt.'); + * readable.unpipe(writable); + * console.log('Manually close the file stream.'); + * writable.end(); + * }, 1000); + * ``` + * @since v0.9.4 + * @param destination Optional specific stream to unpipe + */ + unpipe(destination?: NodeJS.WritableStream): this; + /** + * Passing `chunk` as `null` signals the end of the stream (EOF) and behaves the + * same as `readable.push(null)`, after which no more data can be written. The EOF + * signal is put at the end of the buffer and any buffered data will still be + * flushed. + * + * The `readable.unshift()` method pushes a chunk of data back into the internal + * buffer. This is useful in certain situations where a stream is being consumed by + * code that needs to "un-consume" some amount of data that it has optimistically + * pulled out of the source, so that the data can be passed on to some other party. + * + * The `stream.unshift(chunk)` method cannot be called after the `'end'` event + * has been emitted or a runtime error will be thrown. + * + * Developers using `stream.unshift()` often should consider switching to + * use of a `Transform` stream instead. See the `API for stream implementers` section for more information. + * + * ```js + * // Pull off a header delimited by \n\n. + * // Use unshift() if we get too much. + * // Call the callback with (error, header, stream). + * const { StringDecoder } = require('node:string_decoder'); + * function parseHeader(stream, callback) { + * stream.on('error', callback); + * stream.on('readable', onReadable); + * const decoder = new StringDecoder('utf8'); + * let header = ''; + * function onReadable() { + * let chunk; + * while (null !== (chunk = stream.read())) { + * const str = decoder.write(chunk); + * if (str.includes('\n\n')) { + * // Found the header boundary. + * const split = str.split(/\n\n/); + * header += split.shift(); + * const remaining = split.join('\n\n'); + * const buf = Buffer.from(remaining, 'utf8'); + * stream.removeListener('error', callback); + * // Remove the 'readable' listener before unshifting. + * stream.removeListener('readable', onReadable); + * if (buf.length) + * stream.unshift(buf); + * // Now the body of the message can be read from the stream. + * callback(null, header, stream); + * return; + * } + * // Still reading the header. + * header += str; + * } + * } + * } + * ``` + * + * Unlike {@link push}, `stream.unshift(chunk)` will not + * end the reading process by resetting the internal reading state of the stream. + * This can cause unexpected results if `readable.unshift()` is called during a + * read (i.e. from within a {@link _read} implementation on a + * custom stream). Following the call to `readable.unshift()` with an immediate {@link push} will reset the reading state appropriately, + * however it is best to simply avoid calling `readable.unshift()` while in the + * process of performing a read. + * @since v0.9.11 + * @param chunk Chunk of data to unshift onto the read queue. For streams not operating in object mode, `chunk` must be a string, `Buffer`, `Uint8Array`, or `null`. For object mode + * streams, `chunk` may be any JavaScript value. + * @param encoding Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`. + */ + unshift(chunk: any, encoding?: BufferEncoding): void; + /** + * Prior to Node.js 0.10, streams did not implement the entire `node:stream`module API as it is currently defined. (See `Compatibility` for more + * information.) + * + * When using an older Node.js library that emits `'data'` events and has a {@link pause} method that is advisory only, the`readable.wrap()` method can be used to create a `Readable` + * stream that uses + * the old stream as its data source. + * + * It will rarely be necessary to use `readable.wrap()` but the method has been + * provided as a convenience for interacting with older Node.js applications and + * libraries. + * + * ```js + * const { OldReader } = require('./old-api-module.js'); + * const { Readable } = require('node:stream'); + * const oreader = new OldReader(); + * const myReader = new Readable().wrap(oreader); + * + * myReader.on('readable', () => { + * myReader.read(); // etc. + * }); + * ``` + * @since v0.9.4 + * @param stream An "old style" readable stream + */ + wrap(stream: NodeJS.ReadableStream): this; + push(chunk: any, encoding?: BufferEncoding): boolean; + _destroy(error: Error | null, callback: (error?: Error | null) => void): void; + /** + * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable + * stream will release any internal resources and subsequent calls to `push()`will be ignored. + * + * Once `destroy()` has been called any further calls will be a no-op and no + * further errors except from `_destroy()` may be emitted as `'error'`. + * + * Implementors should not override this method, but instead implement `readable._destroy()`. + * @since v8.0.0 + * @param error Error which will be passed as payload in `'error'` event + */ + destroy(error?: Error): this; + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. data + * 3. end + * 4. error + * 5. pause + * 6. readable + * 7. resume + */ + addListener(event: 'close', listener: () => void): this; + addListener(event: 'data', listener: (chunk: any) => void): this; + addListener(event: 'end', listener: () => void): this; + addListener(event: 'error', listener: (err: Error) => void): this; + addListener(event: 'pause', listener: () => void): this; + addListener(event: 'readable', listener: () => void): this; + addListener(event: 'resume', listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: 'close'): boolean; + emit(event: 'data', chunk: any): boolean; + emit(event: 'end'): boolean; + emit(event: 'error', err: Error): boolean; + emit(event: 'pause'): boolean; + emit(event: 'readable'): boolean; + emit(event: 'resume'): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: 'close', listener: () => void): this; + on(event: 'data', listener: (chunk: any) => void): this; + on(event: 'end', listener: () => void): this; + on(event: 'error', listener: (err: Error) => void): this; + on(event: 'pause', listener: () => void): this; + on(event: 'readable', listener: () => void): this; + on(event: 'resume', listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: 'close', listener: () => void): this; + once(event: 'data', listener: (chunk: any) => void): this; + once(event: 'end', listener: () => void): this; + once(event: 'error', listener: (err: Error) => void): this; + once(event: 'pause', listener: () => void): this; + once(event: 'readable', listener: () => void): this; + once(event: 'resume', listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: 'close', listener: () => void): this; + prependListener(event: 'data', listener: (chunk: any) => void): this; + prependListener(event: 'end', listener: () => void): this; + prependListener(event: 'error', listener: (err: Error) => void): this; + prependListener(event: 'pause', listener: () => void): this; + prependListener(event: 'readable', listener: () => void): this; + prependListener(event: 'resume', listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: 'close', listener: () => void): this; + prependOnceListener(event: 'data', listener: (chunk: any) => void): this; + prependOnceListener(event: 'end', listener: () => void): this; + prependOnceListener(event: 'error', listener: (err: Error) => void): this; + prependOnceListener(event: 'pause', listener: () => void): this; + prependOnceListener(event: 'readable', listener: () => void): this; + prependOnceListener(event: 'resume', listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: 'close', listener: () => void): this; + removeListener(event: 'data', listener: (chunk: any) => void): this; + removeListener(event: 'end', listener: () => void): this; + removeListener(event: 'error', listener: (err: Error) => void): this; + removeListener(event: 'pause', listener: () => void): this; + removeListener(event: 'readable', listener: () => void): this; + removeListener(event: 'resume', listener: () => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; + [Symbol.asyncIterator](): AsyncIterableIterator; + } + import WritableOptions = internal.WritableOptions; + class WritableBase extends Stream implements NodeJS.WritableStream { + /** + * Is `true` if it is safe to call `writable.write()`, which means + * the stream has not been destroyed, errored, or ended. + * @since v11.4.0 + */ + readonly writable: boolean; + /** + * Is `true` after `writable.end()` has been called. This property + * does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead. + * @since v12.9.0 + */ + readonly writableEnded: boolean; + /** + * Is set to `true` immediately before the `'finish'` event is emitted. + * @since v12.6.0 + */ + readonly writableFinished: boolean; + /** + * Return the value of `highWaterMark` passed when creating this `Writable`. + * @since v9.3.0 + */ + readonly writableHighWaterMark: number; + /** + * This property contains the number of bytes (or objects) in the queue + * ready to be written. The value provides introspection data regarding + * the status of the `highWaterMark`. + * @since v9.4.0 + */ + readonly writableLength: number; + /** + * Getter for the property `objectMode` of a given `Writable` stream. + * @since v12.3.0 + */ + readonly writableObjectMode: boolean; + /** + * Number of times `writable.uncork()` needs to be + * called in order to fully uncork the stream. + * @since v13.2.0, v12.16.0 + */ + readonly writableCorked: number; + /** + * Is `true` after `writable.destroy()` has been called. + * @since v8.0.0 + */ + destroyed: boolean; + /** + * Is `true` after `'close'` has been emitted. + * @since v18.0.0 + */ + readonly closed: boolean; + /** + * Returns error if the stream has been destroyed with an error. + * @since v18.0.0 + */ + readonly errored: Error | null; + /** + * Is `true` if the stream's buffer has been full and stream will emit `'drain'`. + * @since v15.2.0, v14.17.0 + */ + readonly writableNeedDrain: boolean; + constructor(opts?: WritableOptions); + _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; + _writev?( + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void + ): void; + _construct?(callback: (error?: Error | null) => void): void; + _destroy(error: Error | null, callback: (error?: Error | null) => void): void; + _final(callback: (error?: Error | null) => void): void; + /** + * The `writable.write()` method writes some data to the stream, and calls the + * supplied `callback` once the data has been fully handled. If an error + * occurs, the `callback` will be called with the error as its + * first argument. The `callback` is called asynchronously and before `'error'` is + * emitted. + * + * The return value is `true` if the internal buffer is less than the`highWaterMark` configured when the stream was created after admitting `chunk`. + * If `false` is returned, further attempts to write data to the stream should + * stop until the `'drain'` event is emitted. + * + * While a stream is not draining, calls to `write()` will buffer `chunk`, and + * return false. Once all currently buffered chunks are drained (accepted for + * delivery by the operating system), the `'drain'` event will be emitted. + * Once `write()` returns false, do not write more chunks + * until the `'drain'` event is emitted. While calling `write()` on a stream that + * is not draining is allowed, Node.js will buffer all written chunks until + * maximum memory usage occurs, at which point it will abort unconditionally. + * Even before it aborts, high memory usage will cause poor garbage collector + * performance and high RSS (which is not typically released back to the system, + * even after the memory is no longer required). Since TCP sockets may never + * drain if the remote peer does not read the data, writing a socket that is + * not draining may lead to a remotely exploitable vulnerability. + * + * Writing data while the stream is not draining is particularly + * problematic for a `Transform`, because the `Transform` streams are paused + * by default until they are piped or a `'data'` or `'readable'` event handler + * is added. + * + * If the data to be written can be generated or fetched on demand, it is + * recommended to encapsulate the logic into a `Readable` and use {@link pipe}. However, if calling `write()` is preferred, it is + * possible to respect backpressure and avoid memory issues using the `'drain'` event: + * + * ```js + * function write(data, cb) { + * if (!stream.write(data)) { + * stream.once('drain', cb); + * } else { + * process.nextTick(cb); + * } + * } + * + * // Wait for cb to be called before doing any other write. + * write('hello', () => { + * console.log('Write completed, do more writes now.'); + * }); + * ``` + * + * A `Writable` stream in object mode will always ignore the `encoding` argument. + * @since v0.9.4 + * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any + * JavaScript value other than `null`. + * @param [encoding='utf8'] The encoding, if `chunk` is a string. + * @param callback Callback for when this chunk of data is flushed. + * @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + write(chunk: any, callback?: (error: Error | null | undefined) => void): boolean; + write(chunk: any, encoding: BufferEncoding, callback?: (error: Error | null | undefined) => void): boolean; + /** + * The `writable.setDefaultEncoding()` method sets the default `encoding` for a `Writable` stream. + * @since v0.11.15 + * @param encoding The new default encoding + */ + setDefaultEncoding(encoding: BufferEncoding): this; + /** + * Calling the `writable.end()` method signals that no more data will be written + * to the `Writable`. The optional `chunk` and `encoding` arguments allow one + * final additional chunk of data to be written immediately before closing the + * stream. + * + * Calling the {@link write} method after calling {@link end} will raise an error. + * + * ```js + * // Write 'hello, ' and then end with 'world!'. + * const fs = require('node:fs'); + * const file = fs.createWriteStream('example.txt'); + * file.write('hello, '); + * file.end('world!'); + * // Writing more now is not allowed! + * ``` + * @since v0.9.4 + * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any + * JavaScript value other than `null`. + * @param encoding The encoding if `chunk` is a string + * @param callback Callback for when the stream is finished. + */ + end(cb?: () => void): this; + end(chunk: any, cb?: () => void): this; + end(chunk: any, encoding: BufferEncoding, cb?: () => void): this; + /** + * The `writable.cork()` method forces all written data to be buffered in memory. + * The buffered data will be flushed when either the {@link uncork} or {@link end} methods are called. + * + * The primary intent of `writable.cork()` is to accommodate a situation in which + * several small chunks are written to the stream in rapid succession. Instead of + * immediately forwarding them to the underlying destination, `writable.cork()`buffers all the chunks until `writable.uncork()` is called, which will pass them + * all to `writable._writev()`, if present. This prevents a head-of-line blocking + * situation where data is being buffered while waiting for the first small chunk + * to be processed. However, use of `writable.cork()` without implementing`writable._writev()` may have an adverse effect on throughput. + * + * See also: `writable.uncork()`, `writable._writev()`. + * @since v0.11.2 + */ + cork(): void; + /** + * The `writable.uncork()` method flushes all data buffered since {@link cork} was called. + * + * When using `writable.cork()` and `writable.uncork()` to manage the buffering + * of writes to a stream, defer calls to `writable.uncork()` using`process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event + * loop phase. + * + * ```js + * stream.cork(); + * stream.write('some '); + * stream.write('data '); + * process.nextTick(() => stream.uncork()); + * ``` + * + * If the `writable.cork()` method is called multiple times on a stream, the + * same number of calls to `writable.uncork()` must be called to flush the buffered + * data. + * + * ```js + * stream.cork(); + * stream.write('some '); + * stream.cork(); + * stream.write('data '); + * process.nextTick(() => { + * stream.uncork(); + * // The data will not be flushed until uncork() is called a second time. + * stream.uncork(); + * }); + * ``` + * + * See also: `writable.cork()`. + * @since v0.11.2 + */ + uncork(): void; + /** + * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the writable + * stream has ended and subsequent calls to `write()` or `end()` will result in + * an `ERR_STREAM_DESTROYED` error. + * This is a destructive and immediate way to destroy a stream. Previous calls to`write()` may not have drained, and may trigger an `ERR_STREAM_DESTROYED` error. + * Use `end()` instead of destroy if data should flush before close, or wait for + * the `'drain'` event before destroying the stream. + * + * Once `destroy()` has been called any further calls will be a no-op and no + * further errors except from `_destroy()` may be emitted as `'error'`. + * + * Implementors should not override this method, + * but instead implement `writable._destroy()`. + * @since v8.0.0 + * @param error Optional, an error to emit with `'error'` event. + */ + destroy(error?: Error): this; + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. drain + * 3. error + * 4. finish + * 5. pipe + * 6. unpipe + */ + addListener(event: 'close', listener: () => void): this; + addListener(event: 'drain', listener: () => void): this; + addListener(event: 'error', listener: (err: Error) => void): this; + addListener(event: 'finish', listener: () => void): this; + addListener(event: 'pipe', listener: (src: Readable) => void): this; + addListener(event: 'unpipe', listener: (src: Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: 'close'): boolean; + emit(event: 'drain'): boolean; + emit(event: 'error', err: Error): boolean; + emit(event: 'finish'): boolean; + emit(event: 'pipe', src: Readable): boolean; + emit(event: 'unpipe', src: Readable): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: 'close', listener: () => void): this; + on(event: 'drain', listener: () => void): this; + on(event: 'error', listener: (err: Error) => void): this; + on(event: 'finish', listener: () => void): this; + on(event: 'pipe', listener: (src: Readable) => void): this; + on(event: 'unpipe', listener: (src: Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: 'close', listener: () => void): this; + once(event: 'drain', listener: () => void): this; + once(event: 'error', listener: (err: Error) => void): this; + once(event: 'finish', listener: () => void): this; + once(event: 'pipe', listener: (src: Readable) => void): this; + once(event: 'unpipe', listener: (src: Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: 'close', listener: () => void): this; + prependListener(event: 'drain', listener: () => void): this; + prependListener(event: 'error', listener: (err: Error) => void): this; + prependListener(event: 'finish', listener: () => void): this; + prependListener(event: 'pipe', listener: (src: Readable) => void): this; + prependListener(event: 'unpipe', listener: (src: Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: 'close', listener: () => void): this; + prependOnceListener(event: 'drain', listener: () => void): this; + prependOnceListener(event: 'error', listener: (err: Error) => void): this; + prependOnceListener(event: 'finish', listener: () => void): this; + prependOnceListener(event: 'pipe', listener: (src: Readable) => void): this; + prependOnceListener(event: 'unpipe', listener: (src: Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: 'close', listener: () => void): this; + removeListener(event: 'drain', listener: () => void): this; + removeListener(event: 'error', listener: (err: Error) => void): this; + removeListener(event: 'finish', listener: () => void): this; + removeListener(event: 'pipe', listener: (src: Readable) => void): this; + removeListener(event: 'unpipe', listener: (src: Readable) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; + } namespace internal { class Stream extends internal { constructor(opts?: ReadableOptions); @@ -48,775 +782,50 @@ declare module 'stream' { /** * @since v0.9.4 */ - class Readable extends Stream implements NodeJS.ReadableStream { - /** - * A utility method for creating Readable Streams out of iterators. - */ - static from(iterable: Iterable | AsyncIterable, options?: ReadableOptions): Readable; + class Readable extends ReadableBase { /** * A utility method for creating a `Readable` from a web `ReadableStream`. * @since v17.0.0 * @experimental */ static fromWeb(readableStream: streamWeb.ReadableStream, options?: Pick): Readable; - /** - * Returns whether the stream has been read from or cancelled. - * @since v16.8.0 - */ - static isDisturbed(stream: Readable | NodeJS.ReadableStream): boolean; /** * A utility method for creating a web `ReadableStream` from a `Readable`. * @since v17.0.0 * @experimental */ static toWeb(streamReadable: Readable): streamWeb.ReadableStream; - /** - * Returns whether the stream was destroyed or errored before emitting `'end'`. - * @since v16.8.0 - * @experimental - */ - readonly readableAborted: boolean; - /** - * Is `true` if it is safe to call `readable.read()`, which means - * the stream has not been destroyed or emitted `'error'` or `'end'`. - * @since v11.4.0 - */ - readable: boolean; - /** - * Returns whether `'data'` has been emitted. - * @since v16.7.0, v14.18.0 - * @experimental - */ - readonly readableDidRead: boolean; - /** - * Getter for the property `encoding` of a given `Readable` stream. The `encoding`property can be set using the `readable.setEncoding()` method. - * @since v12.7.0 - */ - readonly readableEncoding: BufferEncoding | null; - /** - * Becomes `true` when `'end'` event is emitted. - * @since v12.9.0 - */ - readonly readableEnded: boolean; - /** - * This property reflects the current state of a `Readable` stream as described - * in the `Three states` section. - * @since v9.4.0 - */ - readonly readableFlowing: boolean | null; - /** - * Returns the value of `highWaterMark` passed when creating this `Readable`. - * @since v9.3.0 - */ - readonly readableHighWaterMark: number; - /** - * This property contains the number of bytes (or objects) in the queue - * ready to be read. The value provides introspection data regarding - * the status of the `highWaterMark`. - * @since v9.4.0 - */ - readonly readableLength: number; - /** - * Getter for the property `objectMode` of a given `Readable` stream. - * @since v12.3.0 - */ - readonly readableObjectMode: boolean; - /** - * Is `true` after `readable.destroy()` has been called. - * @since v18.0.0 - */ - destroyed: boolean; - /** - * Is true after 'close' has been emitted. - * @since v8.0.0 - */ - readonly closed: boolean; - /** - * Returns error if the stream has been destroyed with an error. - * @since v18.0.0 - */ - readonly errored: Error | null; - constructor(opts?: ReadableOptions); - _construct?(callback: (error?: Error | null) => void): void; - _read(size: number): void; - /** - * The `readable.read()` method reads data out of the internal buffer and - * returns it. If no data is available to be read, `null` is returned. By default, - * the data is returned as a `Buffer` object unless an encoding has been - * specified using the `readable.setEncoding()` method or the stream is operating - * in object mode. - * - * The optional `size` argument specifies a specific number of bytes to read. If`size` bytes are not available to be read, `null` will be returned _unless_the stream has ended, in which - * case all of the data remaining in the internal - * buffer will be returned. - * - * If the `size` argument is not specified, all of the data contained in the - * internal buffer will be returned. - * - * The `size` argument must be less than or equal to 1 GiB. - * - * The `readable.read()` method should only be called on `Readable` streams - * operating in paused mode. In flowing mode, `readable.read()` is called - * automatically until the internal buffer is fully drained. - * - * ```js - * const readable = getReadableStreamSomehow(); - * - * // 'readable' may be triggered multiple times as data is buffered in - * readable.on('readable', () => { - * let chunk; - * console.log('Stream is readable (new data received in buffer)'); - * // Use a loop to make sure we read all currently available data - * while (null !== (chunk = readable.read())) { - * console.log(`Read ${chunk.length} bytes of data...`); - * } - * }); - * - * // 'end' will be triggered once when there is no more data available - * readable.on('end', () => { - * console.log('Reached end of stream.'); - * }); - * ``` - * - * Each call to `readable.read()` returns a chunk of data, or `null`. The chunks - * are not concatenated. A `while` loop is necessary to consume all data - * currently in the buffer. When reading a large file `.read()` may return `null`, - * having consumed all buffered content so far, but there is still more data to - * come not yet buffered. In this case a new `'readable'` event will be emitted - * when there is more data in the buffer. Finally the `'end'` event will be - * emitted when there is no more data to come. - * - * Therefore to read a file's whole contents from a `readable`, it is necessary - * to collect chunks across multiple `'readable'` events: - * - * ```js - * const chunks = []; - * - * readable.on('readable', () => { - * let chunk; - * while (null !== (chunk = readable.read())) { - * chunks.push(chunk); - * } - * }); - * - * readable.on('end', () => { - * const content = chunks.join(''); - * }); - * ``` - * - * A `Readable` stream in object mode will always return a single item from - * a call to `readable.read(size)`, regardless of the value of the`size` argument. - * - * If the `readable.read()` method returns a chunk of data, a `'data'` event will - * also be emitted. - * - * Calling {@link read} after the `'end'` event has - * been emitted will return `null`. No runtime error will be raised. - * @since v0.9.4 - * @param size Optional argument to specify how much data to read. - */ - read(size?: number): any; - /** - * The `readable.setEncoding()` method sets the character encoding for - * data read from the `Readable` stream. - * - * By default, no encoding is assigned and stream data will be returned as`Buffer` objects. Setting an encoding causes the stream data - * to be returned as strings of the specified encoding rather than as `Buffer`objects. For instance, calling `readable.setEncoding('utf8')` will cause the - * output data to be interpreted as UTF-8 data, and passed as strings. Calling`readable.setEncoding('hex')` will cause the data to be encoded in hexadecimal - * string format. - * - * The `Readable` stream will properly handle multi-byte characters delivered - * through the stream that would otherwise become improperly decoded if simply - * pulled from the stream as `Buffer` objects. - * - * ```js - * const readable = getReadableStreamSomehow(); - * readable.setEncoding('utf8'); - * readable.on('data', (chunk) => { - * assert.equal(typeof chunk, 'string'); - * console.log('Got %d characters of string data:', chunk.length); - * }); - * ``` - * @since v0.9.4 - * @param encoding The encoding to use. - */ - setEncoding(encoding: BufferEncoding): this; - /** - * The `readable.pause()` method will cause a stream in flowing mode to stop - * emitting `'data'` events, switching out of flowing mode. Any data that - * becomes available will remain in the internal buffer. - * - * ```js - * const readable = getReadableStreamSomehow(); - * readable.on('data', (chunk) => { - * console.log(`Received ${chunk.length} bytes of data.`); - * readable.pause(); - * console.log('There will be no additional data for 1 second.'); - * setTimeout(() => { - * console.log('Now data will start flowing again.'); - * readable.resume(); - * }, 1000); - * }); - * ``` - * - * The `readable.pause()` method has no effect if there is a `'readable'`event listener. - * @since v0.9.4 - */ - pause(): this; - /** - * The `readable.resume()` method causes an explicitly paused `Readable` stream to - * resume emitting `'data'` events, switching the stream into flowing mode. - * - * The `readable.resume()` method can be used to fully consume the data from a - * stream without actually processing any of that data: - * - * ```js - * getReadableStreamSomehow() - * .resume() - * .on('end', () => { - * console.log('Reached the end, but did not read anything.'); - * }); - * ``` - * - * The `readable.resume()` method has no effect if there is a `'readable'`event listener. - * @since v0.9.4 - */ - resume(): this; - /** - * The `readable.isPaused()` method returns the current operating state of the`Readable`. This is used primarily by the mechanism that underlies the`readable.pipe()` method. In most - * typical cases, there will be no reason to - * use this method directly. - * - * ```js - * const readable = new stream.Readable(); - * - * readable.isPaused(); // === false - * readable.pause(); - * readable.isPaused(); // === true - * readable.resume(); - * readable.isPaused(); // === false - * ``` - * @since v0.11.14 - */ - isPaused(): boolean; - /** - * The `readable.unpipe()` method detaches a `Writable` stream previously attached - * using the {@link pipe} method. - * - * If the `destination` is not specified, then _all_ pipes are detached. - * - * If the `destination` is specified, but no pipe is set up for it, then - * the method does nothing. - * - * ```js - * const fs = require('fs'); - * const readable = getReadableStreamSomehow(); - * const writable = fs.createWriteStream('file.txt'); - * // All the data from readable goes into 'file.txt', - * // but only for the first second. - * readable.pipe(writable); - * setTimeout(() => { - * console.log('Stop writing to file.txt.'); - * readable.unpipe(writable); - * console.log('Manually close the file stream.'); - * writable.end(); - * }, 1000); - * ``` - * @since v0.9.4 - * @param destination Optional specific stream to unpipe - */ - unpipe(destination?: NodeJS.WritableStream): this; - /** - * Passing `chunk` as `null` signals the end of the stream (EOF) and behaves the - * same as `readable.push(null)`, after which no more data can be written. The EOF - * signal is put at the end of the buffer and any buffered data will still be - * flushed. - * - * The `readable.unshift()` method pushes a chunk of data back into the internal - * buffer. This is useful in certain situations where a stream is being consumed by - * code that needs to "un-consume" some amount of data that it has optimistically - * pulled out of the source, so that the data can be passed on to some other party. - * - * The `stream.unshift(chunk)` method cannot be called after the `'end'` event - * has been emitted or a runtime error will be thrown. - * - * Developers using `stream.unshift()` often should consider switching to - * use of a `Transform` stream instead. See the `API for stream implementers` section for more information. - * - * ```js - * // Pull off a header delimited by \n\n. - * // Use unshift() if we get too much. - * // Call the callback with (error, header, stream). - * const { StringDecoder } = require('string_decoder'); - * function parseHeader(stream, callback) { - * stream.on('error', callback); - * stream.on('readable', onReadable); - * const decoder = new StringDecoder('utf8'); - * let header = ''; - * function onReadable() { - * let chunk; - * while (null !== (chunk = stream.read())) { - * const str = decoder.write(chunk); - * if (str.includes('\n\n')) { - * // Found the header boundary. - * const split = str.split(/\n\n/); - * header += split.shift(); - * const remaining = split.join('\n\n'); - * const buf = Buffer.from(remaining, 'utf8'); - * stream.removeListener('error', callback); - * // Remove the 'readable' listener before unshifting. - * stream.removeListener('readable', onReadable); - * if (buf.length) - * stream.unshift(buf); - * // Now the body of the message can be read from the stream. - * callback(null, header, stream); - * return; - * } - * // Still reading the header. - * header += str; - * } - * } - * } - * ``` - * - * Unlike {@link push}, `stream.unshift(chunk)` will not - * end the reading process by resetting the internal reading state of the stream. - * This can cause unexpected results if `readable.unshift()` is called during a - * read (i.e. from within a {@link _read} implementation on a - * custom stream). Following the call to `readable.unshift()` with an immediate {@link push} will reset the reading state appropriately, - * however it is best to simply avoid calling `readable.unshift()` while in the - * process of performing a read. - * @since v0.9.11 - * @param chunk Chunk of data to unshift onto the read queue. For streams not operating in object mode, `chunk` must be a string, `Buffer`, `Uint8Array` or `null`. For object mode - * streams, `chunk` may be any JavaScript value. - * @param encoding Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`. - */ - unshift(chunk: any, encoding?: BufferEncoding): void; - /** - * Prior to Node.js 0.10, streams did not implement the entire `stream` module API - * as it is currently defined. (See `Compatibility` for more information.) - * - * When using an older Node.js library that emits `'data'` events and has a {@link pause} method that is advisory only, the`readable.wrap()` method can be used to create a `Readable` - * stream that uses - * the old stream as its data source. - * - * It will rarely be necessary to use `readable.wrap()` but the method has been - * provided as a convenience for interacting with older Node.js applications and - * libraries. - * - * ```js - * const { OldReader } = require('./old-api-module.js'); - * const { Readable } = require('stream'); - * const oreader = new OldReader(); - * const myReader = new Readable().wrap(oreader); - * - * myReader.on('readable', () => { - * myReader.read(); // etc. - * }); - * ``` - * @since v0.9.4 - * @param stream An "old style" readable stream - */ - wrap(stream: NodeJS.ReadableStream): this; - push(chunk: any, encoding?: BufferEncoding): boolean; - _destroy(error: Error | null, callback: (error?: Error | null) => void): void; - /** - * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable - * stream will release any internal resources and subsequent calls to `push()`will be ignored. - * - * Once `destroy()` has been called any further calls will be a no-op and no - * further errors except from `_destroy()` may be emitted as `'error'`. - * - * Implementors should not override this method, but instead implement `readable._destroy()`. - * @since v8.0.0 - * @param error Error which will be passed as payload in `'error'` event - */ - destroy(error?: Error): this; - /** - * Event emitter - * The defined events on documents including: - * 1. close - * 2. data - * 3. end - * 4. error - * 5. pause - * 6. readable - * 7. resume - */ - addListener(event: 'close', listener: () => void): this; - addListener(event: 'data', listener: (chunk: any) => void): this; - addListener(event: 'end', listener: () => void): this; - addListener(event: 'error', listener: (err: Error) => void): this; - addListener(event: 'pause', listener: () => void): this; - addListener(event: 'readable', listener: () => void): this; - addListener(event: 'resume', listener: () => void): this; - addListener(event: string | symbol, listener: (...args: any[]) => void): this; - emit(event: 'close'): boolean; - emit(event: 'data', chunk: any): boolean; - emit(event: 'end'): boolean; - emit(event: 'error', err: Error): boolean; - emit(event: 'pause'): boolean; - emit(event: 'readable'): boolean; - emit(event: 'resume'): boolean; - emit(event: string | symbol, ...args: any[]): boolean; - on(event: 'close', listener: () => void): this; - on(event: 'data', listener: (chunk: any) => void): this; - on(event: 'end', listener: () => void): this; - on(event: 'error', listener: (err: Error) => void): this; - on(event: 'pause', listener: () => void): this; - on(event: 'readable', listener: () => void): this; - on(event: 'resume', listener: () => void): this; - on(event: string | symbol, listener: (...args: any[]) => void): this; - once(event: 'close', listener: () => void): this; - once(event: 'data', listener: (chunk: any) => void): this; - once(event: 'end', listener: () => void): this; - once(event: 'error', listener: (err: Error) => void): this; - once(event: 'pause', listener: () => void): this; - once(event: 'readable', listener: () => void): this; - once(event: 'resume', listener: () => void): this; - once(event: string | symbol, listener: (...args: any[]) => void): this; - prependListener(event: 'close', listener: () => void): this; - prependListener(event: 'data', listener: (chunk: any) => void): this; - prependListener(event: 'end', listener: () => void): this; - prependListener(event: 'error', listener: (err: Error) => void): this; - prependListener(event: 'pause', listener: () => void): this; - prependListener(event: 'readable', listener: () => void): this; - prependListener(event: 'resume', listener: () => void): this; - prependListener(event: string | symbol, listener: (...args: any[]) => void): this; - prependOnceListener(event: 'close', listener: () => void): this; - prependOnceListener(event: 'data', listener: (chunk: any) => void): this; - prependOnceListener(event: 'end', listener: () => void): this; - prependOnceListener(event: 'error', listener: (err: Error) => void): this; - prependOnceListener(event: 'pause', listener: () => void): this; - prependOnceListener(event: 'readable', listener: () => void): this; - prependOnceListener(event: 'resume', listener: () => void): this; - prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; - removeListener(event: 'close', listener: () => void): this; - removeListener(event: 'data', listener: (chunk: any) => void): this; - removeListener(event: 'end', listener: () => void): this; - removeListener(event: 'error', listener: (err: Error) => void): this; - removeListener(event: 'pause', listener: () => void): this; - removeListener(event: 'readable', listener: () => void): this; - removeListener(event: 'resume', listener: () => void): this; - removeListener(event: string | symbol, listener: (...args: any[]) => void): this; - [Symbol.asyncIterator](): AsyncIterableIterator; } interface WritableOptions extends StreamOptions { decodeStrings?: boolean | undefined; defaultEncoding?: BufferEncoding | undefined; write?(this: Writable, chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; - writev?( - this: Writable, - chunks: Array<{ - chunk: any; - encoding: BufferEncoding; - }>, - callback: (error?: Error | null) => void - ): void; - final?(this: Writable, callback: (error?: Error | null) => void): void; - } - /** - * @since v0.9.4 - */ - class Writable extends Stream implements NodeJS.WritableStream { - /** - * A utility method for creating a `Writable` from a web `WritableStream`. - * @since v17.0.0 - * @experimental - */ - static fromWeb(writableStream: streamWeb.WritableStream, options?: Pick): Writable; - /** - * A utility method for creating a web `WritableStream` from a `Writable`. - * @since v17.0.0 - * @experimental - */ - static toWeb(streamWritable: Writable): streamWeb.WritableStream; - /** - * Is `true` if it is safe to call `writable.write()`, which means - * the stream has not been destroyed, errored or ended. - * @since v11.4.0 - */ - readonly writable: boolean; - /** - * Is `true` after `writable.end()` has been called. This property - * does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead. - * @since v12.9.0 - */ - readonly writableEnded: boolean; - /** - * Is set to `true` immediately before the `'finish'` event is emitted. - * @since v12.6.0 - */ - readonly writableFinished: boolean; - /** - * Return the value of `highWaterMark` passed when creating this `Writable`. - * @since v9.3.0 - */ - readonly writableHighWaterMark: number; - /** - * This property contains the number of bytes (or objects) in the queue - * ready to be written. The value provides introspection data regarding - * the status of the `highWaterMark`. - * @since v9.4.0 - */ - readonly writableLength: number; - /** - * Getter for the property `objectMode` of a given `Writable` stream. - * @since v12.3.0 - */ - readonly writableObjectMode: boolean; - /** - * Number of times `writable.uncork()` needs to be - * called in order to fully uncork the stream. - * @since v13.2.0, v12.16.0 - */ - readonly writableCorked: number; - /** - * Is `true` after `writable.destroy()` has been called. - * @since v8.0.0 - */ - destroyed: boolean; - /** - * Is true after 'close' has been emitted. - * @since v8.0.0 - */ - readonly closed: boolean; - /** - * Returns error if the stream has been destroyed with an error. - * @since v18.0.0 - */ - readonly errored: Error | null; - /** - * Is `true` if the stream's buffer has been full and stream will emit 'drain'. - * @since v15.2.0, v14.17.0 - */ - readonly writableNeedDrain: boolean; - constructor(opts?: WritableOptions); - _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; - _writev?( + writev?( + this: Writable, chunks: Array<{ chunk: any; encoding: BufferEncoding; }>, callback: (error?: Error | null) => void ): void; - _construct?(callback: (error?: Error | null) => void): void; - _destroy(error: Error | null, callback: (error?: Error | null) => void): void; - _final(callback: (error?: Error | null) => void): void; - /** - * The `writable.write()` method writes some data to the stream, and calls the - * supplied `callback` once the data has been fully handled. If an error - * occurs, the `callback` will be called with the error as its - * first argument. The `callback` is called asynchronously and before `'error'` is - * emitted. - * - * The return value is `true` if the internal buffer is less than the`highWaterMark` configured when the stream was created after admitting `chunk`. - * If `false` is returned, further attempts to write data to the stream should - * stop until the `'drain'` event is emitted. - * - * While a stream is not draining, calls to `write()` will buffer `chunk`, and - * return false. Once all currently buffered chunks are drained (accepted for - * delivery by the operating system), the `'drain'` event will be emitted. - * Once `write()` returns false, do not write more chunks - * until the `'drain'` event is emitted. While calling `write()` on a stream that - * is not draining is allowed, Node.js will buffer all written chunks until - * maximum memory usage occurs, at which point it will abort unconditionally. - * Even before it aborts, high memory usage will cause poor garbage collector - * performance and high RSS (which is not typically released back to the system, - * even after the memory is no longer required). Since TCP sockets may never - * drain if the remote peer does not read the data, writing a socket that is - * not draining may lead to a remotely exploitable vulnerability. - * - * Writing data while the stream is not draining is particularly - * problematic for a `Transform`, because the `Transform` streams are paused - * by default until they are piped or a `'data'` or `'readable'` event handler - * is added. - * - * If the data to be written can be generated or fetched on demand, it is - * recommended to encapsulate the logic into a `Readable` and use {@link pipe}. However, if calling `write()` is preferred, it is - * possible to respect backpressure and avoid memory issues using the `'drain'` event: - * - * ```js - * function write(data, cb) { - * if (!stream.write(data)) { - * stream.once('drain', cb); - * } else { - * process.nextTick(cb); - * } - * } - * - * // Wait for cb to be called before doing any other write. - * write('hello', () => { - * console.log('Write completed, do more writes now.'); - * }); - * ``` - * - * A `Writable` stream in object mode will always ignore the `encoding` argument. - * @since v0.9.4 - * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any - * JavaScript value other than `null`. - * @param [encoding='utf8'] The encoding, if `chunk` is a string. - * @param callback Callback for when this chunk of data is flushed. - * @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. - */ - write(chunk: any, callback?: (error: Error | null | undefined) => void): boolean; - write(chunk: any, encoding: BufferEncoding, callback?: (error: Error | null | undefined) => void): boolean; - /** - * The `writable.setDefaultEncoding()` method sets the default `encoding` for a `Writable` stream. - * @since v0.11.15 - * @param encoding The new default encoding - */ - setDefaultEncoding(encoding: BufferEncoding): this; - /** - * Calling the `writable.end()` method signals that no more data will be written - * to the `Writable`. The optional `chunk` and `encoding` arguments allow one - * final additional chunk of data to be written immediately before closing the - * stream. - * - * Calling the {@link write} method after calling {@link end} will raise an error. - * - * ```js - * // Write 'hello, ' and then end with 'world!'. - * const fs = require('fs'); - * const file = fs.createWriteStream('example.txt'); - * file.write('hello, '); - * file.end('world!'); - * // Writing more now is not allowed! - * ``` - * @since v0.9.4 - * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any - * JavaScript value other than `null`. - * @param encoding The encoding if `chunk` is a string - * @param callback Callback for when the stream is finished. - */ - end(cb?: () => void): this; - end(chunk: any, cb?: () => void): this; - end(chunk: any, encoding: BufferEncoding, cb?: () => void): this; - /** - * The `writable.cork()` method forces all written data to be buffered in memory. - * The buffered data will be flushed when either the {@link uncork} or {@link end} methods are called. - * - * The primary intent of `writable.cork()` is to accommodate a situation in which - * several small chunks are written to the stream in rapid succession. Instead of - * immediately forwarding them to the underlying destination, `writable.cork()`buffers all the chunks until `writable.uncork()` is called, which will pass them - * all to `writable._writev()`, if present. This prevents a head-of-line blocking - * situation where data is being buffered while waiting for the first small chunk - * to be processed. However, use of `writable.cork()` without implementing`writable._writev()` may have an adverse effect on throughput. - * - * See also: `writable.uncork()`, `writable._writev()`. - * @since v0.11.2 - */ - cork(): void; - /** - * The `writable.uncork()` method flushes all data buffered since {@link cork} was called. - * - * When using `writable.cork()` and `writable.uncork()` to manage the buffering - * of writes to a stream, defer calls to `writable.uncork()` using`process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event - * loop phase. - * - * ```js - * stream.cork(); - * stream.write('some '); - * stream.write('data '); - * process.nextTick(() => stream.uncork()); - * ``` - * - * If the `writable.cork()` method is called multiple times on a stream, the - * same number of calls to `writable.uncork()` must be called to flush the buffered - * data. - * - * ```js - * stream.cork(); - * stream.write('some '); - * stream.cork(); - * stream.write('data '); - * process.nextTick(() => { - * stream.uncork(); - * // The data will not be flushed until uncork() is called a second time. - * stream.uncork(); - * }); - * ``` - * - * See also: `writable.cork()`. - * @since v0.11.2 - */ - uncork(): void; + final?(this: Writable, callback: (error?: Error | null) => void): void; + } + /** + * @since v0.9.4 + */ + class Writable extends WritableBase { /** - * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the writable - * stream has ended and subsequent calls to `write()` or `end()` will result in - * an `ERR_STREAM_DESTROYED` error. - * This is a destructive and immediate way to destroy a stream. Previous calls to`write()` may not have drained, and may trigger an `ERR_STREAM_DESTROYED` error. - * Use `end()` instead of destroy if data should flush before close, or wait for - * the `'drain'` event before destroying the stream. - * - * Once `destroy()` has been called any further calls will be a no-op and no - * further errors except from `_destroy()` may be emitted as `'error'`. - * - * Implementors should not override this method, - * but instead implement `writable._destroy()`. - * @since v8.0.0 - * @param error Optional, an error to emit with `'error'` event. + * A utility method for creating a `Writable` from a web `WritableStream`. + * @since v17.0.0 + * @experimental */ - destroy(error?: Error): this; + static fromWeb(writableStream: streamWeb.WritableStream, options?: Pick): Writable; /** - * Event emitter - * The defined events on documents including: - * 1. close - * 2. drain - * 3. error - * 4. finish - * 5. pipe - * 6. unpipe + * A utility method for creating a web `WritableStream` from a `Writable`. + * @since v17.0.0 + * @experimental */ - addListener(event: 'close', listener: () => void): this; - addListener(event: 'drain', listener: () => void): this; - addListener(event: 'error', listener: (err: Error) => void): this; - addListener(event: 'finish', listener: () => void): this; - addListener(event: 'pipe', listener: (src: Readable) => void): this; - addListener(event: 'unpipe', listener: (src: Readable) => void): this; - addListener(event: string | symbol, listener: (...args: any[]) => void): this; - emit(event: 'close'): boolean; - emit(event: 'drain'): boolean; - emit(event: 'error', err: Error): boolean; - emit(event: 'finish'): boolean; - emit(event: 'pipe', src: Readable): boolean; - emit(event: 'unpipe', src: Readable): boolean; - emit(event: string | symbol, ...args: any[]): boolean; - on(event: 'close', listener: () => void): this; - on(event: 'drain', listener: () => void): this; - on(event: 'error', listener: (err: Error) => void): this; - on(event: 'finish', listener: () => void): this; - on(event: 'pipe', listener: (src: Readable) => void): this; - on(event: 'unpipe', listener: (src: Readable) => void): this; - on(event: string | symbol, listener: (...args: any[]) => void): this; - once(event: 'close', listener: () => void): this; - once(event: 'drain', listener: () => void): this; - once(event: 'error', listener: (err: Error) => void): this; - once(event: 'finish', listener: () => void): this; - once(event: 'pipe', listener: (src: Readable) => void): this; - once(event: 'unpipe', listener: (src: Readable) => void): this; - once(event: string | symbol, listener: (...args: any[]) => void): this; - prependListener(event: 'close', listener: () => void): this; - prependListener(event: 'drain', listener: () => void): this; - prependListener(event: 'error', listener: (err: Error) => void): this; - prependListener(event: 'finish', listener: () => void): this; - prependListener(event: 'pipe', listener: (src: Readable) => void): this; - prependListener(event: 'unpipe', listener: (src: Readable) => void): this; - prependListener(event: string | symbol, listener: (...args: any[]) => void): this; - prependOnceListener(event: 'close', listener: () => void): this; - prependOnceListener(event: 'drain', listener: () => void): this; - prependOnceListener(event: 'error', listener: (err: Error) => void): this; - prependOnceListener(event: 'finish', listener: () => void): this; - prependOnceListener(event: 'pipe', listener: (src: Readable) => void): this; - prependOnceListener(event: 'unpipe', listener: (src: Readable) => void): this; - prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; - removeListener(event: 'close', listener: () => void): this; - removeListener(event: 'drain', listener: () => void): this; - removeListener(event: 'error', listener: (err: Error) => void): this; - removeListener(event: 'finish', listener: () => void): this; - removeListener(event: 'pipe', listener: (src: Readable) => void): this; - removeListener(event: 'unpipe', listener: (src: Readable) => void): this; - removeListener(event: string | symbol, listener: (...args: any[]) => void): this; + static toWeb(streamWritable: Writable): streamWeb.WritableStream; } interface DuplexOptions extends ReadableOptions, WritableOptions { allowHalfOpen?: boolean | undefined; @@ -849,7 +858,7 @@ declare module 'stream' { * * `crypto streams` * @since v0.9.4 */ - class Duplex extends Readable implements Writable { + class Duplex extends ReadableBase implements WritableBase { readonly writable: boolean; readonly writableEnded: boolean; readonly writableFinished: boolean; @@ -863,7 +872,7 @@ declare module 'stream' { /** * If `false` then the stream will automatically end the writable side when the * readable side ends. Set initially by the `allowHalfOpen` constructor option, - * which defaults to `false`. + * which defaults to `true`. * * This can be changed manually to change the half-open behavior of an existing`Duplex` stream instance, but must be changed before the `'end'` event is * emitted. @@ -892,7 +901,7 @@ declare module 'stream' { * * @since v16.8.0 */ - static from(src: Stream | Blob | ArrayBuffer | string | Iterable | AsyncIterable | AsyncGeneratorFunction | Promise | Object): Duplex; + static from(src: Stream | NodeBlob | ArrayBuffer | string | Iterable | AsyncIterable | AsyncGeneratorFunction | Promise | Object): Duplex; _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; _writev?( chunks: Array<{ @@ -911,6 +920,126 @@ declare module 'stream' { end(chunk: any, encoding?: BufferEncoding, cb?: () => void): this; cork(): void; uncork(): void; + /** + * A utility method for creating a web `ReadableStream` and `WritableStream` from a `Duplex`. + * @since v17.0.0 + * @experimental + */ + static toWeb(streamDuplex: Duplex): { + readable: streamWeb.ReadableStream; + writable: streamWeb.WritableStream; + }; + /** + * A utility method for creating a `Duplex` from a web `ReadableStream` and `WritableStream`. + * @since v17.0.0 + * @experimental + */ + static fromWeb( + duplexStream: { + readable: streamWeb.ReadableStream; + writable: streamWeb.WritableStream; + }, + options?: Pick + ): Duplex; + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. data + * 3. drain + * 4. end + * 5. error + * 6. finish + * 7. pause + * 8. pipe + * 9. readable + * 10. resume + * 11. unpipe + */ + addListener(event: 'close', listener: () => void): this; + addListener(event: 'data', listener: (chunk: any) => void): this; + addListener(event: 'drain', listener: () => void): this; + addListener(event: 'end', listener: () => void): this; + addListener(event: 'error', listener: (err: Error) => void): this; + addListener(event: 'finish', listener: () => void): this; + addListener(event: 'pause', listener: () => void): this; + addListener(event: 'pipe', listener: (src: Readable) => void): this; + addListener(event: 'readable', listener: () => void): this; + addListener(event: 'resume', listener: () => void): this; + addListener(event: 'unpipe', listener: (src: Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: 'close'): boolean; + emit(event: 'data', chunk: any): boolean; + emit(event: 'drain'): boolean; + emit(event: 'end'): boolean; + emit(event: 'error', err: Error): boolean; + emit(event: 'finish'): boolean; + emit(event: 'pause'): boolean; + emit(event: 'pipe', src: Readable): boolean; + emit(event: 'readable'): boolean; + emit(event: 'resume'): boolean; + emit(event: 'unpipe', src: Readable): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: 'close', listener: () => void): this; + on(event: 'data', listener: (chunk: any) => void): this; + on(event: 'drain', listener: () => void): this; + on(event: 'end', listener: () => void): this; + on(event: 'error', listener: (err: Error) => void): this; + on(event: 'finish', listener: () => void): this; + on(event: 'pause', listener: () => void): this; + on(event: 'pipe', listener: (src: Readable) => void): this; + on(event: 'readable', listener: () => void): this; + on(event: 'resume', listener: () => void): this; + on(event: 'unpipe', listener: (src: Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: 'close', listener: () => void): this; + once(event: 'data', listener: (chunk: any) => void): this; + once(event: 'drain', listener: () => void): this; + once(event: 'end', listener: () => void): this; + once(event: 'error', listener: (err: Error) => void): this; + once(event: 'finish', listener: () => void): this; + once(event: 'pause', listener: () => void): this; + once(event: 'pipe', listener: (src: Readable) => void): this; + once(event: 'readable', listener: () => void): this; + once(event: 'resume', listener: () => void): this; + once(event: 'unpipe', listener: (src: Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: 'close', listener: () => void): this; + prependListener(event: 'data', listener: (chunk: any) => void): this; + prependListener(event: 'drain', listener: () => void): this; + prependListener(event: 'end', listener: () => void): this; + prependListener(event: 'error', listener: (err: Error) => void): this; + prependListener(event: 'finish', listener: () => void): this; + prependListener(event: 'pause', listener: () => void): this; + prependListener(event: 'pipe', listener: (src: Readable) => void): this; + prependListener(event: 'readable', listener: () => void): this; + prependListener(event: 'resume', listener: () => void): this; + prependListener(event: 'unpipe', listener: (src: Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: 'close', listener: () => void): this; + prependOnceListener(event: 'data', listener: (chunk: any) => void): this; + prependOnceListener(event: 'drain', listener: () => void): this; + prependOnceListener(event: 'end', listener: () => void): this; + prependOnceListener(event: 'error', listener: (err: Error) => void): this; + prependOnceListener(event: 'finish', listener: () => void): this; + prependOnceListener(event: 'pause', listener: () => void): this; + prependOnceListener(event: 'pipe', listener: (src: Readable) => void): this; + prependOnceListener(event: 'readable', listener: () => void): this; + prependOnceListener(event: 'resume', listener: () => void): this; + prependOnceListener(event: 'unpipe', listener: (src: Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: 'close', listener: () => void): this; + removeListener(event: 'data', listener: (chunk: any) => void): this; + removeListener(event: 'drain', listener: () => void): this; + removeListener(event: 'end', listener: () => void): this; + removeListener(event: 'error', listener: (err: Error) => void): this; + removeListener(event: 'finish', listener: () => void): this; + removeListener(event: 'pause', listener: () => void): this; + removeListener(event: 'pipe', listener: (src: Readable) => void): this; + removeListener(event: 'readable', listener: () => void): this; + removeListener(event: 'resume', listener: () => void): this; + removeListener(event: 'unpipe', listener: (src: Readable) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; } type TransformCallback = (error?: Error | null, data?: any) => void; interface TransformOptions extends DuplexOptions { @@ -952,18 +1081,21 @@ declare module 'stream' { */ class PassThrough extends Transform {} /** + * A stream to attach a signal to. + * * Attaches an AbortSignal to a readable or writeable stream. This lets code * control stream destruction using an `AbortController`. * - * Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`on the stream. + * Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`on the stream, and `controller.error(new + * AbortError())` for webstreams. * * ```js - * const fs = require('fs'); + * const fs = require('node:fs'); * * const controller = new AbortController(); * const read = addAbortSignal( * controller.signal, - * fs.createReadStream(('object.json')) + * fs.createReadStream(('object.json')), * ); * // Later, abort the operation closing the stream * controller.abort(); @@ -976,7 +1108,7 @@ declare module 'stream' { * setTimeout(() => controller.abort(), 10_000); // set a timeout * const stream = addAbortSignal( * controller.signal, - * fs.createReadStream(('object.json')) + * fs.createReadStream(('object.json')), * ); * (async () => { * try { @@ -992,22 +1124,70 @@ declare module 'stream' { * } * })(); * ``` + * + * Or using an `AbortSignal` with a ReadableStream: + * + * ```js + * const controller = new AbortController(); + * const rs = new ReadableStream({ + * start(controller) { + * controller.enqueue('hello'); + * controller.enqueue('world'); + * controller.close(); + * }, + * }); + * + * addAbortSignal(controller.signal, rs); + * + * finished(rs, (err) => { + * if (err) { + * if (err.name === 'AbortError') { + * // The operation was cancelled + * } + * } + * }); + * + * const reader = rs.getReader(); + * + * reader.read().then(({ value, done }) => { + * console.log(value); // hello + * console.log(done); // false + * controller.abort(); + * }); + * ``` * @since v15.4.0 * @param signal A signal representing possible cancellation * @param stream a stream to attach a signal to */ function addAbortSignal(signal: AbortSignal, stream: T): T; + /** + * Returns the default highWaterMark used by streams. + * Defaults to `16384` (16 KiB), or `16` for `objectMode`. + * @since v19.9.0 + * @param objectMode + */ + function getDefaultHighWaterMark(objectMode: boolean): number; + /** + * Sets the default highWaterMark used by streams. + * @since v19.9.0 + * @param objectMode + * @param value highWaterMark value + */ + function setDefaultHighWaterMark(objectMode: boolean, value: number): void; interface FinishedOptions extends Abortable { error?: boolean | undefined; readable?: boolean | undefined; writable?: boolean | undefined; } /** + * A readable and/or writable stream/webstream. + * * A function to get notified when a stream is no longer readable, writable * or has experienced an error or a premature close event. * * ```js - * const { finished } = require('stream'); + * const { finished } = require('node:stream'); + * const fs = require('node:fs'); * * const rs = fs.createReadStream('archive.tar'); * @@ -1025,21 +1205,7 @@ declare module 'stream' { * Especially useful in error handling scenarios where a stream is destroyed * prematurely (like an aborted HTTP request), and will not emit `'end'`or `'finish'`. * - * The `finished` API provides promise version: - * - * ```js - * const { finished } = require('stream/promises'); - * - * const rs = fs.createReadStream('archive.tar'); - * - * async function run() { - * await finished(rs); - * console.log('Stream is done reading.'); - * } - * - * run().catch(console.error); - * rs.resume(); // Drain the stream. - * ``` + * The `finished` API provides `promise version`. * * `stream.finished()` leaves dangling event listeners (in particular`'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been * invoked. The reason for this is so that unexpected `'error'` events (due to @@ -1079,16 +1245,17 @@ declare module 'stream' { : (err: NodeJS.ErrnoException | null) => void; type PipelinePromise> = S extends PipelineDestinationPromiseFunction ? Promise

: Promise; interface PipelineOptions { - signal: AbortSignal; + signal?: AbortSignal | undefined; + end?: boolean | undefined; } /** * A module method to pipe between streams and generators forwarding errors and * properly cleaning up and provide a callback when the pipeline is complete. * * ```js - * const { pipeline } = require('stream'); - * const fs = require('fs'); - * const zlib = require('zlib'); + * const { pipeline } = require('node:stream'); + * const fs = require('node:fs'); + * const zlib = require('node:zlib'); * * // Use the pipeline API to easily pipe a series of streams * // together and get notified when the pipeline is fully done. @@ -1105,95 +1272,11 @@ declare module 'stream' { * } else { * console.log('Pipeline succeeded.'); * } - * } + * }, * ); * ``` * - * The `pipeline` API provides a promise version, which can also - * receive an options argument as the last parameter with a`signal` `AbortSignal` property. When the signal is aborted,`destroy` will be called on the underlying pipeline, with - * an`AbortError`. - * - * ```js - * const { pipeline } = require('stream/promises'); - * - * async function run() { - * await pipeline( - * fs.createReadStream('archive.tar'), - * zlib.createGzip(), - * fs.createWriteStream('archive.tar.gz') - * ); - * console.log('Pipeline succeeded.'); - * } - * - * run().catch(console.error); - * ``` - * - * To use an `AbortSignal`, pass it inside an options object, - * as the last argument: - * - * ```js - * const { pipeline } = require('stream/promises'); - * - * async function run() { - * const ac = new AbortController(); - * const signal = ac.signal; - * - * setTimeout(() => ac.abort(), 1); - * await pipeline( - * fs.createReadStream('archive.tar'), - * zlib.createGzip(), - * fs.createWriteStream('archive.tar.gz'), - * { signal }, - * ); - * } - * - * run().catch(console.error); // AbortError - * ``` - * - * The `pipeline` API also supports async generators: - * - * ```js - * const { pipeline } = require('stream/promises'); - * const fs = require('fs'); - * - * async function run() { - * await pipeline( - * fs.createReadStream('lowercase.txt'), - * async function* (source, { signal }) { - * source.setEncoding('utf8'); // Work with strings rather than `Buffer`s. - * for await (const chunk of source) { - * yield await processChunk(chunk, { signal }); - * } - * }, - * fs.createWriteStream('uppercase.txt') - * ); - * console.log('Pipeline succeeded.'); - * } - * - * run().catch(console.error); - * ``` - * - * Remember to handle the `signal` argument passed into the async generator. - * Especially in the case where the async generator is the source for the - * pipeline (i.e. first argument) or the pipeline will never complete. - * - * ```js - * const { pipeline } = require('stream/promises'); - * const fs = require('fs'); - * - * async function run() { - * await pipeline( - * async function* ({ signal }) { - * await someLongRunningfn({ signal }); - * yield 'asd'; - * }, - * fs.createWriteStream('uppercase.txt') - * ); - * console.log('Pipeline succeeded.'); - * } - * - * run().catch(console.error); - * ``` + * The `pipeline` API provides a `promise version`. * * `stream.pipeline()` will call `stream.destroy(err)` on all streams except: * @@ -1212,9 +1295,9 @@ declare module 'stream' { * See the example below: * * ```js - * const fs = require('fs'); - * const http = require('http'); - * const { pipeline } = require('stream'); + * const fs = require('node:fs'); + * const http = require('node:http'); + * const { pipeline } = require('node:stream'); * * const server = http.createServer((req, res) => { * const fileStream = fs.createReadStream('./fileNotExist.txt'); @@ -1315,19 +1398,18 @@ declare module 'stream' { ref(): void; unref(): void; } - /** * Returns whether the stream has encountered an error. - * @since v17.3.0 + * @since v17.3.0, v16.14.0 + * @experimental */ function isErrored(stream: Readable | Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean; - /** * Returns whether the stream is readable. - * @since v17.4.0 + * @since v17.4.0, v16.14.0 + * @experimental */ function isReadable(stream: Readable | NodeJS.ReadableStream): boolean; - const promises: typeof streamPromises; const consumers: typeof streamConsumers; } diff --git a/node_modules/@types/node/stream/consumers.d.ts b/node_modules/@types/node/stream/consumers.d.ts index ce6c9bb78..2fd942443 100755 --- a/node_modules/@types/node/stream/consumers.d.ts +++ b/node_modules/@types/node/stream/consumers.d.ts @@ -1,22 +1,10 @@ -// Duplicates of interface in lib.dom.ts. -// Duplicated here rather than referencing lib.dom.ts because doing so causes lib.dom.ts to be loaded for "test-all" -// Which in turn causes tests to pass that shouldn't pass. -// -// This interface is not, and should not be, exported. -interface Blob { - readonly size: number; - readonly type: string; - arrayBuffer(): Promise; - slice(start?: number, end?: number, contentType?: string): Blob; - stream(): NodeJS.ReadableStream; - text(): Promise; -} declare module 'stream/consumers' { + import { Blob as NodeBlob } from 'node:buffer'; import { Readable } from 'node:stream'; function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; - function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; + function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; function json(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; } declare module 'node:stream/consumers' { diff --git a/node_modules/@types/node/string_decoder.d.ts b/node_modules/@types/node/string_decoder.d.ts index a58580411..a069bb894 100755 --- a/node_modules/@types/node/string_decoder.d.ts +++ b/node_modules/@types/node/string_decoder.d.ts @@ -1,16 +1,16 @@ /** - * The `string_decoder` module provides an API for decoding `Buffer` objects into - * strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 + * The `node:string_decoder` module provides an API for decoding `Buffer` objects + * into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 * characters. It can be accessed using: * * ```js - * const { StringDecoder } = require('string_decoder'); + * const { StringDecoder } = require('node:string_decoder'); * ``` * * The following example shows the basic use of the `StringDecoder` class. * * ```js - * const { StringDecoder } = require('string_decoder'); + * const { StringDecoder } = require('node:string_decoder'); * const decoder = new StringDecoder('utf8'); * * const cent = Buffer.from([0xC2, 0xA2]); @@ -29,14 +29,14 @@ * symbol (`€`) are written over three separate operations: * * ```js - * const { StringDecoder } = require('string_decoder'); + * const { StringDecoder } = require('node:string_decoder'); * const decoder = new StringDecoder('utf8'); * * decoder.write(Buffer.from([0xE2])); * decoder.write(Buffer.from([0x82])); * console.log(decoder.end(Buffer.from([0xAC]))); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/string_decoder.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/string_decoder.js) */ declare module 'string_decoder' { class StringDecoder { diff --git a/node_modules/@types/node/test.d.ts b/node_modules/@types/node/test.d.ts index a9b4eeb5e..520245445 100755 --- a/node_modules/@types/node/test.d.ts +++ b/node_modules/@types/node/test.d.ts @@ -1,28 +1,112 @@ /** - * The `node:test` module provides a standalone testing module. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/test.js) + * The `node:test` module facilitates the creation of JavaScript tests. + * To access it: + * + * ```js + * import test from 'node:test'; + * ``` + * + * This module is only available under the `node:` scheme. The following will not + * work: + * + * ```js + * import test from 'test'; + * ``` + * + * Tests created via the `test` module consist of a single function that is + * processed in one of three ways: + * + * 1. A synchronous function that is considered failing if it throws an exception, + * and is considered passing otherwise. + * 2. A function that returns a `Promise` that is considered failing if the`Promise` rejects, and is considered passing if the `Promise` resolves. + * 3. A function that receives a callback function. If the callback receives any + * truthy value as its first argument, the test is considered failing. If a + * falsy value is passed as the first argument to the callback, the test is + * considered passing. If the test function receives a callback function and + * also returns a `Promise`, the test will fail. + * + * The following example illustrates how tests are written using the`test` module. + * + * ```js + * test('synchronous passing test', (t) => { + * // This test passes because it does not throw an exception. + * assert.strictEqual(1, 1); + * }); + * + * test('synchronous failing test', (t) => { + * // This test fails because it throws an exception. + * assert.strictEqual(1, 2); + * }); + * + * test('asynchronous passing test', async (t) => { + * // This test passes because the Promise returned by the async + * // function is not rejected. + * assert.strictEqual(1, 1); + * }); + * + * test('asynchronous failing test', async (t) => { + * // This test fails because the Promise returned by the async + * // function is rejected. + * assert.strictEqual(1, 2); + * }); + * + * test('failing test using Promises', (t) => { + * // Promises can be used directly as well. + * return new Promise((resolve, reject) => { + * setImmediate(() => { + * reject(new Error('this will cause the test to fail')); + * }); + * }); + * }); + * + * test('callback passing test', (t, done) => { + * // done() is the callback function. When the setImmediate() runs, it invokes + * // done() with no arguments. + * setImmediate(done); + * }); + * + * test('callback failing test', (t, done) => { + * // When the setImmediate() runs, done() is invoked with an Error object and + * // the test fails. + * setImmediate(() => { + * done(new Error('callback failure')); + * }); + * }); + * ``` + * + * If any tests fail, the process exit code is set to `1`. + * @since v18.0.0, v16.17.0 + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/test.js) */ declare module 'node:test' { + import { Readable } from 'node:stream'; /** - * Programmatically start the test runner. - * @since v18.9.0 - * @param options Configuration options for running tests. - * @returns A {@link TapStream} that emits events about the test execution. + * ```js + * import { tap } from 'node:test/reporters'; + * import process from 'node:process'; + * + * run({ files: [path.resolve('./tests/test.js')] }) + * .compose(tap) + * .pipe(process.stdout); + * ``` + * @since v18.9.0, v16.19.0 + * @param options Configuration options for running tests. The following properties are supported: */ - function run(options?: RunOptions): TapStream; - + function run(options?: RunOptions): TestsStream; /** - * The `test()` function is the value imported from the test module. Each invocation of this - * function results in the creation of a test point in the TAP output. + * The `test()` function is the value imported from the `test` module. Each + * invocation of this function results in reporting the test to the `TestsStream`. * - * The {@link TestContext} object passed to the fn argument can be used to perform actions - * related to the current test. Examples include skipping the test, adding additional TAP - * diagnostic information, or creating subtests. + * The `TestContext` object passed to the `fn` argument can be used to perform + * actions related to the current test. Examples include skipping the test, adding + * additional diagnostic information, or creating subtests. * - * `test()` returns a {@link Promise} that resolves once the test completes. The return value - * can usually be discarded for top level tests. However, the return value from subtests should - * be used to prevent the parent test from finishing first and cancelling the subtest as shown - * in the following example. + * `test()` returns a `Promise` that resolves once the test completes. + * if `test()` is called within a `describe()` block, it resolve immediately. + * The return value can usually be discarded for top level tests. + * However, the return value from subtests should be used to prevent the parent + * test from finishing first and cancelling the subtest + * as shown in the following example. * * ```js * test('top level test', async (t) => { @@ -36,221 +120,438 @@ declare module 'node:test' { * }); * }); * ``` - * @since v18.0.0 - * @param name The name of the test, which is displayed when reporting test results. - * Default: The `name` property of fn, or `''` if `fn` does not have a name. - * @param options Configuration options for the test - * @param fn The function under test. The first argument to this function is a - * {@link TestContext} object. If the test uses callbacks, the callback function is - * passed as the second argument. Default: A no-op function. - * @returns A {@link Promise} resolved with `undefined` once the test completes. + * + * The `timeout` option can be used to fail the test if it takes longer than`timeout` milliseconds to complete. However, it is not a reliable mechanism for + * canceling tests because a running test might block the application thread and + * thus prevent the scheduled cancellation. + * @since v18.0.0, v16.17.0 + * @param [name='The name'] The name of the test, which is displayed when reporting test results. + * @param options Configuration options for the test. The following properties are supported: + * @param [fn='A no-op function'] The function under test. The first argument to this function is a {@link TestContext} object. If the test uses callbacks, the callback function is passed as the + * second argument. + * @return Resolved with `undefined` once the test completes, or immediately if the test runs within {@link describe}. */ function test(name?: string, fn?: TestFn): Promise; function test(name?: string, options?: TestOptions, fn?: TestFn): Promise; function test(options?: TestOptions, fn?: TestFn): Promise; function test(fn?: TestFn): Promise; - + namespace test { + export { + after, + afterEach, + before, + beforeEach, + describe, + it, + run, + mock, + test, + skip, + todo, + only + }; + } /** - * @since v18.6.0 - * @param name The name of the suite, which is displayed when reporting suite results. - * Default: The `name` property of fn, or `''` if `fn` does not have a name. - * @param options Configuration options for the suite - * @param fn The function under suite. Default: A no-op function. + * The `describe()` function imported from the `node:test` module. Each + * invocation of this function results in the creation of a Subtest. + * After invocation of top level `describe` functions, + * all top level tests and suites will execute. + * @param [name='The name'] The name of the suite, which is displayed when reporting test results. + * @param options Configuration options for the suite. supports the same options as `test([name][, options][, fn])`. + * @param [fn='A no-op function'] The function under suite declaring all subtests and subsuites. The first argument to this function is a {@link SuiteContext} object. + * @return `undefined`. */ function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void; function describe(name?: string, fn?: SuiteFn): void; function describe(options?: TestOptions, fn?: SuiteFn): void; function describe(fn?: SuiteFn): void; - + namespace describe { + /** + * Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`. + */ + function skip(name?: string, options?: TestOptions, fn?: SuiteFn): void; + function skip(name?: string, fn?: SuiteFn): void; + function skip(options?: TestOptions, fn?: SuiteFn): void; + function skip(fn?: SuiteFn): void; + /** + * Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`. + */ + function todo(name?: string, options?: TestOptions, fn?: SuiteFn): void; + function todo(name?: string, fn?: SuiteFn): void; + function todo(options?: TestOptions, fn?: SuiteFn): void; + function todo(fn?: SuiteFn): void; + /** + * Shorthand for marking a suite as `only`, same as `describe([name], { only: true }[, fn])`. + * @since v18.15.0 + */ + function only(name?: string, options?: TestOptions, fn?: SuiteFn): void; + function only(name?: string, fn?: SuiteFn): void; + function only(options?: TestOptions, fn?: SuiteFn): void; + function only(fn?: SuiteFn): void; + } /** - * @since v18.6.0 - * @param name The name of the test, which is displayed when reporting test results. - * Default: The `name` property of fn, or `''` if `fn` does not have a name. - * @param options Configuration options for the test - * @param fn The function under test. If the test uses callbacks, the callback function is - * passed as the second argument. Default: A no-op function. + * Shorthand for `test()`. + * + * The `it()` function is imported from the `node:test` module. + * @since v18.6.0, v16.17.0 */ - function it(name?: string, options?: TestOptions, fn?: ItFn): void; - function it(name?: string, fn?: ItFn): void; - function it(options?: TestOptions, fn?: ItFn): void; - function it(fn?: ItFn): void; - + function it(name?: string, options?: TestOptions, fn?: TestFn): void; + function it(name?: string, fn?: TestFn): void; + function it(options?: TestOptions, fn?: TestFn): void; + function it(fn?: TestFn): void; + namespace it { + /** + * Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`. + */ + function skip(name?: string, options?: TestOptions, fn?: TestFn): void; + function skip(name?: string, fn?: TestFn): void; + function skip(options?: TestOptions, fn?: TestFn): void; + function skip(fn?: TestFn): void; + /** + * Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`. + */ + function todo(name?: string, options?: TestOptions, fn?: TestFn): void; + function todo(name?: string, fn?: TestFn): void; + function todo(options?: TestOptions, fn?: TestFn): void; + function todo(fn?: TestFn): void; + /** + * Shorthand for marking a test as `only`, same as `it([name], { only: true }[, fn])`. + * @since v18.15.0 + */ + function only(name?: string, options?: TestOptions, fn?: TestFn): void; + function only(name?: string, fn?: TestFn): void; + function only(options?: TestOptions, fn?: TestFn): void; + function only(fn?: TestFn): void; + } + /** + * Shorthand for skipping a test, same as `test([name], { skip: true }[, fn])`. + * @since v20.2.0 + */ + function skip(name?: string, options?: TestOptions, fn?: TestFn): void; + function skip(name?: string, fn?: TestFn): void; + function skip(options?: TestOptions, fn?: TestFn): void; + function skip(fn?: TestFn): void; + /** + * Shorthand for marking a test as `TODO`, same as `test([name], { todo: true }[, fn])`. + * @since v20.2.0 + */ + function todo(name?: string, options?: TestOptions, fn?: TestFn): void; + function todo(name?: string, fn?: TestFn): void; + function todo(options?: TestOptions, fn?: TestFn): void; + function todo(fn?: TestFn): void; + /** + * Shorthand for marking a test as `only`, same as `test([name], { only: true }[, fn])`. + * @since v20.2.0 + */ + function only(name?: string, options?: TestOptions, fn?: TestFn): void; + function only(name?: string, fn?: TestFn): void; + function only(options?: TestOptions, fn?: TestFn): void; + function only(fn?: TestFn): void; /** * The type of a function under test. The first argument to this function is a * {@link TestContext} object. If the test uses callbacks, the callback function is passed as * the second argument. */ type TestFn = (t: TestContext, done: (result?: any) => void) => any; - /** * The type of a function under Suite. * If the test uses callbacks, the callback function is passed as an argument */ type SuiteFn = (done: (result?: any) => void) => void; - - /** - * The type of a function under test. - * If the test uses callbacks, the callback function is passed as an argument - */ - type ItFn = (done: (result?: any) => void) => any; - interface RunOptions { /** - * @default false + * If a number is provided, then that many files would run in parallel. + * If truthy, it would run (number of cpu cores - 1) files in parallel. + * If falsy, it would only run one file at a time. + * If unspecified, subtests inherit this value from their parent. + * @default true */ - concurrency?: number | boolean; - + concurrency?: number | boolean | undefined; /** - * An array containing the list of files to run. If unspecified, the test runner execution model will be used. + * An array containing the list of files to run. + * If unspecified, the test runner execution model will be used. */ - files?: readonly string[]; - + files?: readonly string[] | undefined; /** - * Allows aborting an in-progress test. + * Allows aborting an in-progress test execution. * @default undefined */ - signal?: AbortSignal; - + signal?: AbortSignal | undefined; /** - * A number of milliseconds the test will fail after. If unspecified, subtests inherit this - * value from their parent. + * A number of milliseconds the test will fail after. + * If unspecified, subtests inherit this value from their parent. * @default Infinity */ - timeout?: number; + timeout?: number | undefined; + /** + * Sets inspector port of test child process. + * If a nullish value is provided, each process gets its own port, + * incremented from the primary's `process.debugPort`. + */ + inspectPort?: number | (() => number) | undefined; + /** + * That can be used to only run tests whose name matches the provided pattern. + * Test name patterns are interpreted as JavaScript regular expressions. + * For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run. + */ + testNamePatterns?: string | RegExp | string[] | RegExp[]; } - /** - * A successful call of the run() method will return a new TapStream object, streaming a TAP output. - * TapStream will emit events in the order of the tests' definitions. - * @since v18.9.0 + * A successful call to `run()` method will return a new `TestsStream` object, streaming a series of events representing the execution of the tests.`TestsStream` will emit events, in the + * order of the tests definition + * @since v18.9.0, v16.19.0 */ - interface TapStream extends NodeJS.ReadableStream { - addListener(event: 'test:diagnostic', listener: (message: string) => void): this; + class TestsStream extends Readable implements NodeJS.ReadableStream { + addListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; addListener(event: 'test:fail', listener: (data: TestFail) => void): this; addListener(event: 'test:pass', listener: (data: TestPass) => void): this; + addListener(event: 'test:plan', listener: (data: TestPlan) => void): this; + addListener(event: 'test:start', listener: (data: TestStart) => void): this; addListener(event: string, listener: (...args: any[]) => void): this; - emit(event: 'test:diagnostic', message: string): boolean; + emit(event: 'test:diagnostic', data: DiagnosticData): boolean; emit(event: 'test:fail', data: TestFail): boolean; emit(event: 'test:pass', data: TestPass): boolean; + emit(event: 'test:plan', data: TestPlan): boolean; + emit(event: 'test:start', data: TestStart): boolean; emit(event: string | symbol, ...args: any[]): boolean; - on(event: 'test:diagnostic', listener: (message: string) => void): this; + on(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; on(event: 'test:fail', listener: (data: TestFail) => void): this; on(event: 'test:pass', listener: (data: TestPass) => void): this; + on(event: 'test:plan', listener: (data: TestPlan) => void): this; + on(event: 'test:start', listener: (data: TestStart) => void): this; on(event: string, listener: (...args: any[]) => void): this; - once(event: 'test:diagnostic', listener: (message: string) => void): this; + once(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; once(event: 'test:fail', listener: (data: TestFail) => void): this; once(event: 'test:pass', listener: (data: TestPass) => void): this; + once(event: 'test:plan', listener: (data: TestPlan) => void): this; + once(event: 'test:start', listener: (data: TestStart) => void): this; once(event: string, listener: (...args: any[]) => void): this; - prependListener(event: 'test:diagnostic', listener: (message: string) => void): this; + prependListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; prependListener(event: 'test:fail', listener: (data: TestFail) => void): this; prependListener(event: 'test:pass', listener: (data: TestPass) => void): this; + prependListener(event: 'test:plan', listener: (data: TestPlan) => void): this; + prependListener(event: 'test:start', listener: (data: TestStart) => void): this; prependListener(event: string, listener: (...args: any[]) => void): this; - prependOnceListener(event: 'test:diagnostic', listener: (message: string) => void): this; + prependOnceListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this; prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this; + prependOnceListener(event: 'test:plan', listener: (data: TestPlan) => void): this; + prependOnceListener(event: 'test:start', listener: (data: TestStart) => void): this; prependOnceListener(event: string, listener: (...args: any[]) => void): this; } - - interface TestFail { + interface DiagnosticData { /** - * The test duration. + * The diagnostic message. */ - duration: number; - + message: string; /** - * The failure casing test to fail. + * The nesting level of the test. */ - error: Error; - + nesting: number; + } + interface TestFail { + /** + * Additional execution metadata. + */ + details: { + /** + * The duration of the test in milliseconds. + */ + duration: number; + /** + * The error thrown by the test. + */ + error: Error; + }; /** * The test name. */ name: string; - + /** + * The nesting level of the test. + */ + nesting: number; /** * The ordinal number of the test. */ testNumber: number; - /** * Present if `context.todo` is called. */ - todo?: string; - + todo?: string | boolean; /** * Present if `context.skip` is called. */ - skip?: string; + skip?: string | boolean; } - interface TestPass { /** - * The test duration. + * Additional execution metadata. */ - duration: number; - + details: { + /** + * The duration of the test in milliseconds. + */ + duration: number; + }; /** * The test name. */ name: string; - + /** + * The nesting level of the test. + */ + nesting: number; /** * The ordinal number of the test. */ testNumber: number; - /** * Present if `context.todo` is called. */ - todo?: string; - + todo?: string | boolean; /** * Present if `context.skip` is called. */ - skip?: string; + skip?: string | boolean; + } + interface TestPlan { + /** + * The nesting level of the test. + */ + nesting: number; + /** + * The number of subtests that have ran. + */ + count: number; + } + interface TestStart { + /** + * The test name. + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; } - /** - * An instance of `TestContext` is passed to each test function in order to interact with the - * test runner. However, the `TestContext` constructor is not exposed as part of the API. - * @since v18.0.0 + * An instance of `TestContext` is passed to each test function in order to + * interact with the test runner. However, the `TestContext` constructor is not + * exposed as part of the API. + * @since v18.0.0, v16.17.0 */ - interface TestContext { + class TestContext { /** - * This function is used to write TAP diagnostics to the output. Any diagnostic information is - * included at the end of the test's results. This function does not return a value. - * @param message Message to be displayed as a TAP diagnostic. - * @since v18.0.0 + * This function is used to create a hook running before subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v20.1.0 + */ + before: typeof before; + /** + * This function is used to create a hook running before each subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.8.0 + */ + beforeEach: typeof beforeEach; + /** + * This function is used to create a hook that runs after the current test finishes. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.13.0 + */ + after: typeof after; + /** + * This function is used to create a hook running after each subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.8.0 + */ + afterEach: typeof afterEach; + /** + * This function is used to write diagnostics to the output. Any diagnostic + * information is included at the end of the test's results. This function does + * not return a value. + * + * ```js + * test('top level test', (t) => { + * t.diagnostic('A diagnostic message'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Message to be reported. */ diagnostic(message: string): void; - /** - * If `shouldRunOnlyTests` is truthy, the test context will only run tests that have the `only` - * option set. Otherwise, all tests are run. If Node.js was not started with the `--test-only` - * command-line option, this function is a no-op. + * The name of the test. + * @since v18.8.0, v16.18.0 + */ + readonly name: string; + /** + * If `shouldRunOnlyTests` is truthy, the test context will only run tests that + * have the `only` option set. Otherwise, all tests are run. If Node.js was not + * started with the `--test-only` command-line option, this function is a + * no-op. + * + * ```js + * test('top level test', (t) => { + * // The test context can be set to run subtests with the 'only' option. + * t.runOnly(true); + * return Promise.all([ + * t.test('this subtest is now skipped'), + * t.test('this subtest is run', { only: true }), + * ]); + * }); + * ``` + * @since v18.0.0, v16.17.0 * @param shouldRunOnlyTests Whether or not to run `only` tests. - * @since v18.0.0 */ runOnly(shouldRunOnlyTests: boolean): void; - /** - * This function causes the test's output to indicate the test as skipped. If `message` is - * provided, it is included in the TAP output. Calling `skip()` does not terminate execution of - * the test function. This function does not return a value. - * @param message Optional skip message to be displayed in TAP output. - * @since v18.0.0 + * ```js + * test('top level test', async (t) => { + * await fetch('some/uri', { signal: t.signal }); + * }); + * ``` + * @since v18.7.0, v16.17.0 + */ + readonly signal: AbortSignal; + /** + * This function causes the test's output to indicate the test as skipped. If`message` is provided, it is included in the output. Calling `skip()` does + * not terminate execution of the test function. This function does not return a + * value. + * + * ```js + * test('top level test', (t) => { + * // Make sure to return here as well if the test contains additional logic. + * t.skip('this is skipped'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Optional skip message. */ skip(message?: string): void; - /** - * This function adds a `TODO` directive to the test's output. If `message` is provided, it is - * included in the TAP output. Calling `todo()` does not terminate execution of the test - * function. This function does not return a value. - * @param message Optional `TODO` message to be displayed in TAP output. - * @since v18.0.0 + * This function adds a `TODO` directive to the test's output. If `message` is + * provided, it is included in the output. Calling `todo()` does not terminate + * execution of the test function. This function does not return a value. + * + * ```js + * test('top level test', (t) => { + * // This test is marked as `TODO` + * t.todo('this is a todo'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Optional `TODO` message. */ todo(message?: string): void; - /** * This function is used to create subtests under the current test. This function behaves in * the same fashion as the top level {@link test} function. @@ -264,51 +565,488 @@ declare module 'node:test' { * @returns A {@link Promise} resolved with `undefined` once the test completes. */ test: typeof test; + /** + * Each test provides its own MockTracker instance. + */ + readonly mock: MockTracker; } - interface TestOptions { /** - * The number of tests that can be run at the same time. If unspecified, subtests inherit this - * value from their parent. - * @default 1 + * If a number is provided, then that many tests would run in parallel. + * If truthy, it would run (number of cpu cores - 1) tests in parallel. + * For subtests, it will be `Infinity` tests in parallel. + * If falsy, it would only run one test at a time. + * If unspecified, subtests inherit this value from their parent. + * @default false */ - concurrency?: number; - + concurrency?: number | boolean | undefined; /** * If truthy, and the test context is configured to run `only` tests, then this test will be * run. Otherwise, the test is skipped. * @default false */ - only?: boolean; - + only?: boolean | undefined; /** * Allows aborting an in-progress test. * @since v18.8.0 */ - signal?: AbortSignal; - + signal?: AbortSignal | undefined; /** * If truthy, the test is skipped. If a string is provided, that string is displayed in the * test results as the reason for skipping the test. * @default false */ - skip?: boolean | string; - + skip?: boolean | string | undefined; /** * A number of milliseconds the test will fail after. If unspecified, subtests inherit this * value from their parent. * @default Infinity * @since v18.7.0 */ - timeout?: number; - + timeout?: number | undefined; /** * If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in * the test results as the reason why the test is `TODO`. * @default false */ - todo?: boolean | string; + todo?: boolean | string | undefined; + } + /** + * This function is used to create a hook running before running a suite. + * + * ```js + * describe('tests', async () => { + * before(() => console.log('about to run some test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function before(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running after running a suite. + * + * ```js + * describe('tests', async () => { + * after(() => console.log('finished running tests')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function after(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running + * before each subtest of the current suite. + * + * ```js + * describe('tests', async () => { + * beforeEach(() => console.log('about to run a test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function beforeEach(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running + * after each subtest of the current test. + * + * ```js + * describe('tests', async () => { + * afterEach(() => console.log('finished running a test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function afterEach(fn?: HookFn, options?: HookOptions): void; + /** + * The hook function. If the hook uses callbacks, the callback function is passed as the + * second argument. + */ + type HookFn = (done: (result?: any) => void) => any; + /** + * Configuration options for hooks. + * @since v18.8.0 + */ + interface HookOptions { + /** + * Allows aborting an in-progress hook. + */ + signal?: AbortSignal | undefined; + /** + * A number of milliseconds the hook will fail after. If unspecified, subtests inherit this + * value from their parent. + * @default Infinity + */ + timeout?: number | undefined; + } + interface MockFunctionOptions { + /** + * The number of times that the mock will use the behavior of `implementation`. + * Once the mock function has been called `times` times, + * it will automatically restore the behavior of `original`. + * This value must be an integer greater than zero. + * @default Infinity + */ + times?: number | undefined; } + interface MockMethodOptions extends MockFunctionOptions { + /** + * If `true`, `object[methodName]` is treated as a getter. + * This option cannot be used with the `setter` option. + */ + getter?: boolean | undefined; + /** + * If `true`, `object[methodName]` is treated as a setter. + * This option cannot be used with the `getter` option. + */ + setter?: boolean | undefined; + } + type Mock = F & { + mock: MockFunctionContext; + }; + type NoOpFunction = (...args: any[]) => undefined; + type FunctionPropertyNames = { + [K in keyof T]: T[K] extends Function ? K : never; + }[keyof T]; + /** + * The `MockTracker` class is used to manage mocking functionality. The test runner + * module provides a top level `mock` export which is a `MockTracker` instance. + * Each test also provides its own `MockTracker` instance via the test context's`mock` property. + * @since v19.1.0, v18.13.0 + */ + class MockTracker { + /** + * This function is used to create a mock function. + * + * The following example creates a mock function that increments a counter by one + * on each invocation. The `times` option is used to modify the mock behavior such + * that the first two invocations add two to the counter instead of one. + * + * ```js + * test('mocks a counting function', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne, addTwo, { times: 2 }); + * + * assert.strictEqual(fn(), 2); + * assert.strictEqual(fn(), 4); + * assert.strictEqual(fn(), 5); + * assert.strictEqual(fn(), 6); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param [original='A no-op function'] An optional function to create a mock on. + * @param implementation An optional function used as the mock implementation for `original`. This is useful for creating mocks that exhibit one behavior for a specified number of calls and + * then restore the behavior of `original`. + * @param options Optional configuration options for the mock function. The following properties are supported: + * @return The mocked function. The mocked function contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the + * behavior of the mocked function. + */ + fn(original?: F, options?: MockFunctionOptions): Mock; + fn(original?: F, implementation?: Implementation, options?: MockFunctionOptions): Mock; + /** + * This function is used to create a mock on an existing object method. The + * following example demonstrates how a mock is created on an existing object + * method. + * + * ```js + * test('spies on an object method', (t) => { + * const number = { + * value: 5, + * subtract(a) { + * return this.value - a; + * }, + * }; + * + * t.mock.method(number, 'subtract'); + * assert.strictEqual(number.subtract.mock.calls.length, 0); + * assert.strictEqual(number.subtract(3), 2); + * assert.strictEqual(number.subtract.mock.calls.length, 1); + * + * const call = number.subtract.mock.calls[0]; + * + * assert.deepStrictEqual(call.arguments, [3]); + * assert.strictEqual(call.result, 2); + * assert.strictEqual(call.error, undefined); + * assert.strictEqual(call.target, undefined); + * assert.strictEqual(call.this, number); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param object The object whose method is being mocked. + * @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown. + * @param implementation An optional function used as the mock implementation for `object[methodName]`. + * @param options Optional configuration options for the mock method. The following properties are supported: + * @return The mocked method. The mocked method contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the + * behavior of the mocked method. + */ + method< + MockedObject extends object, + MethodName extends FunctionPropertyNames, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): MockedObject[MethodName] extends Function + ? Mock + : never; + method< + MockedObject extends object, + MethodName extends FunctionPropertyNames, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation: Implementation, + options?: MockFunctionOptions, + ): MockedObject[MethodName] extends Function + ? Mock + : never; + method( + object: MockedObject, + methodName: keyof MockedObject, + options: MockMethodOptions, + ): Mock; + method( + object: MockedObject, + methodName: keyof MockedObject, + implementation: Function, + options: MockMethodOptions, + ): Mock; - export { test as default, run, test, describe, it }; + /** + * This function is syntax sugar for `MockTracker.method` with `options.getter`set to `true`. + * @since v19.3.0, v18.13.0 + */ + getter< + MockedObject extends object, + MethodName extends keyof MockedObject, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): Mock<() => MockedObject[MethodName]>; + getter< + MockedObject extends object, + MethodName extends keyof MockedObject, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation?: Implementation, + options?: MockFunctionOptions, + ): Mock<(() => MockedObject[MethodName]) | Implementation>; + /** + * This function is syntax sugar for `MockTracker.method` with `options.setter`set to `true`. + * @since v19.3.0, v18.13.0 + */ + setter< + MockedObject extends object, + MethodName extends keyof MockedObject, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): Mock<(value: MockedObject[MethodName]) => void>; + setter< + MockedObject extends object, + MethodName extends keyof MockedObject, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation?: Implementation, + options?: MockFunctionOptions, + ): Mock<((value: MockedObject[MethodName]) => void) | Implementation>; + /** + * This function restores the default behavior of all mocks that were previously + * created by this `MockTracker` and disassociates the mocks from the`MockTracker` instance. Once disassociated, the mocks can still be used, but the`MockTracker` instance can no longer be + * used to reset their behavior or + * otherwise interact with them. + * + * After each test completes, this function is called on the test context's`MockTracker`. If the global `MockTracker` is used extensively, calling this + * function manually is recommended. + * @since v19.1.0, v18.13.0 + */ + reset(): void; + /** + * This function restores the default behavior of all mocks that were previously + * created by this `MockTracker`. Unlike `mock.reset()`, `mock.restoreAll()` does + * not disassociate the mocks from the `MockTracker` instance. + * @since v19.1.0, v18.13.0 + */ + restoreAll(): void; + } + const mock: MockTracker; + interface MockFunctionCall< + F extends Function, + ReturnType = F extends (...args: any) => infer T + ? T + : F extends abstract new (...args: any) => infer T + ? T + : unknown, + Args = F extends (...args: infer Y) => any + ? Y + : F extends abstract new (...args: infer Y) => any + ? Y + : unknown[], + > { + /** + * An array of the arguments passed to the mock function. + */ + arguments: Args; + /** + * If the mocked function threw then this property contains the thrown value. + */ + error: unknown | undefined; + /** + * The value returned by the mocked function. + * + * If the mocked function threw, it will be `undefined`. + */ + result: ReturnType | undefined; + /** + * An `Error` object whose stack can be used to determine the callsite of the mocked function invocation. + */ + stack: Error; + /** + * If the mocked function is a constructor, this field contains the class being constructed. + * Otherwise this will be `undefined`. + */ + target: F extends abstract new (...args: any) => any ? F : undefined; + /** + * The mocked function's `this` value. + */ + this: unknown; + } + /** + * The `MockFunctionContext` class is used to inspect or manipulate the behavior of + * mocks created via the `MockTracker` APIs. + * @since v19.1.0, v18.13.0 + */ + class MockFunctionContext { + /** + * A getter that returns a copy of the internal array used to track calls to the + * mock. Each entry in the array is an object with the following properties. + * @since v19.1.0, v18.13.0 + */ + readonly calls: Array>; + /** + * This function returns the number of times that this mock has been invoked. This + * function is more efficient than checking `ctx.calls.length` because `ctx.calls`is a getter that creates a copy of the internal call tracking array. + * @since v19.1.0, v18.13.0 + * @return The number of times that this mock has been invoked. + */ + callCount(): number; + /** + * This function is used to change the behavior of an existing mock. + * + * The following example creates a mock function using `t.mock.fn()`, calls the + * mock function, and then changes the mock implementation to a different function. + * + * ```js + * test('changes a mock behavior', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne); + * + * assert.strictEqual(fn(), 1); + * fn.mock.mockImplementation(addTwo); + * assert.strictEqual(fn(), 3); + * assert.strictEqual(fn(), 5); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param implementation The function to be used as the mock's new implementation. + */ + mockImplementation(implementation: Function): void; + /** + * This function is used to change the behavior of an existing mock for a single + * invocation. Once invocation `onCall` has occurred, the mock will revert to + * whatever behavior it would have used had `mockImplementationOnce()` not been + * called. + * + * The following example creates a mock function using `t.mock.fn()`, calls the + * mock function, changes the mock implementation to a different function for the + * next invocation, and then resumes its previous behavior. + * + * ```js + * test('changes a mock behavior once', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne); + * + * assert.strictEqual(fn(), 1); + * fn.mock.mockImplementationOnce(addTwo); + * assert.strictEqual(fn(), 3); + * assert.strictEqual(fn(), 4); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`. + * @param onCall The invocation number that will use `implementation`. If the specified invocation has already occurred then an exception is thrown. + */ + mockImplementationOnce(implementation: Function, onCall?: number): void; + /** + * Resets the call history of the mock function. + * @since v19.3.0, v18.13.0 + */ + resetCalls(): void; + /** + * Resets the implementation of the mock function to its original behavior. The + * mock can still be used after calling this function. + * @since v19.1.0, v18.13.0 + */ + restore(): void; + } + export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock, skip, only, todo }; } diff --git a/node_modules/@types/node/timers.d.ts b/node_modules/@types/node/timers.d.ts index b26f3ceda..5abcdca8d 100755 --- a/node_modules/@types/node/timers.d.ts +++ b/node_modules/@types/node/timers.d.ts @@ -1,12 +1,12 @@ /** * The `timer` module exposes a global API for scheduling functions to * be called at some future period of time. Because the timer functions are - * globals, there is no need to call `require('timers')` to use the API. + * globals, there is no need to call `require('node:timers')` to use the API. * * The timer functions within Node.js implement a similar API as the timers API * provided by Web Browsers but use a different internal implementation that is * built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout). - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/timers.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/timers.js) */ declare module 'timers' { import { Abortable } from 'node:events'; @@ -33,7 +33,35 @@ declare module 'timers' { refresh(): this; [Symbol.toPrimitive](): number; } - interface Immediate extends RefCounted { + /** + * This object is created internally and is returned from `setImmediate()`. It + * can be passed to `clearImmediate()` in order to cancel the scheduled + * actions. + * + * By default, when an immediate is scheduled, the Node.js event loop will continue + * running as long as the immediate is active. The `Immediate` object returned by `setImmediate()` exports both `immediate.ref()` and `immediate.unref()`functions that can be used to + * control this default behavior. + */ + class Immediate implements RefCounted { + /** + * When called, requests that the Node.js event loop _not_ exit so long as the`Immediate` is active. Calling `immediate.ref()` multiple times will have no + * effect. + * + * By default, all `Immediate` objects are "ref'ed", making it normally unnecessary + * to call `immediate.ref()` unless `immediate.unref()` had been called previously. + * @since v9.7.0 + * @return a reference to `immediate` + */ + ref(): this; + /** + * When called, the active `Immediate` object will not require the Node.js event + * loop to remain active. If there is no other activity keeping the event loop + * running, the process may exit before the `Immediate` object's callback is + * invoked. Calling `immediate.unref()` multiple times will have no effect. + * @since v9.7.0 + * @return a reference to `immediate` + */ + unref(): this; /** * If true, the `Immediate` object will keep the Node.js event loop active. * @since v11.0.0 @@ -41,7 +69,33 @@ declare module 'timers' { hasRef(): boolean; _onImmediate: Function; // to distinguish it from the Timeout class } - interface Timeout extends Timer { + /** + * This object is created internally and is returned from `setTimeout()` and `setInterval()`. It can be passed to either `clearTimeout()` or `clearInterval()` in order to cancel the + * scheduled actions. + * + * By default, when a timer is scheduled using either `setTimeout()` or `setInterval()`, the Node.js event loop will continue running as long as the + * timer is active. Each of the `Timeout` objects returned by these functions + * export both `timeout.ref()` and `timeout.unref()` functions that can be used to + * control this default behavior. + */ + class Timeout implements Timer { + /** + * When called, requests that the Node.js event loop _not_ exit so long as the`Timeout` is active. Calling `timeout.ref()` multiple times will have no effect. + * + * By default, all `Timeout` objects are "ref'ed", making it normally unnecessary + * to call `timeout.ref()` unless `timeout.unref()` had been called previously. + * @since v0.9.1 + * @return a reference to `timeout` + */ + ref(): this; + /** + * When called, the active `Timeout` object will not require the Node.js event loop + * to remain active. If there is no other activity keeping the event loop running, + * the process may exit before the `Timeout` object's callback is invoked. Calling`timeout.unref()` multiple times will have no effect. + * @since v0.9.1 + * @return a reference to `timeout` + */ + unref(): this; /** * If true, the `Timeout` object will keep the Node.js event loop active. * @since v11.0.0 @@ -62,6 +116,25 @@ declare module 'timers' { [Symbol.toPrimitive](): number; } } + /** + * Schedules execution of a one-time `callback` after `delay` milliseconds. + * + * The `callback` will likely not be invoked in precisely `delay` milliseconds. + * Node.js makes no guarantees about the exact timing of when callbacks will fire, + * nor of their ordering. The callback will be called as close as possible to the + * time specified. + * + * When `delay` is larger than `2147483647` or less than `1`, the `delay`will be set to `1`. Non-integer delays are truncated to an integer. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setTimeout()`. + * @since v0.0.1 + * @param callback The function to call when the timer elapses. + * @param [delay=1] The number of milliseconds to wait before calling the `callback`. + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearTimeout} + */ function setTimeout(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timeout; // util.promisify no rest args compability // tslint:disable-next-line void-return @@ -69,7 +142,27 @@ declare module 'timers' { namespace setTimeout { const __promisify__: typeof setTimeoutPromise; } + /** + * Cancels a `Timeout` object created by `setTimeout()`. + * @since v0.0.1 + * @param timeout A `Timeout` object as returned by {@link setTimeout} or the `primitive` of the `Timeout` object as a string or a number. + */ function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void; + /** + * Schedules repeated execution of `callback` every `delay` milliseconds. + * + * When `delay` is larger than `2147483647` or less than `1`, the `delay` will be + * set to `1`. Non-integer delays are truncated to an integer. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setInterval()`. + * @since v0.0.1 + * @param callback The function to call when the timer elapses. + * @param [delay=1] The number of milliseconds to wait before calling the `callback`. + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearInterval} + */ function setInterval(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timer; // util.promisify no rest args compability // tslint:disable-next-line void-return @@ -77,7 +170,30 @@ declare module 'timers' { namespace setInterval { const __promisify__: typeof setIntervalPromise; } + /** + * Cancels a `Timeout` object created by `setInterval()`. + * @since v0.0.1 + * @param timeout A `Timeout` object as returned by {@link setInterval} or the `primitive` of the `Timeout` object as a string or a number. + */ function clearInterval(intervalId: NodeJS.Timeout | string | number | undefined): void; + /** + * Schedules the "immediate" execution of the `callback` after I/O events' + * callbacks. + * + * When multiple calls to `setImmediate()` are made, the `callback` functions are + * queued for execution in the order in which they are created. The entire callback + * queue is processed every event loop iteration. If an immediate timer is queued + * from inside an executing callback, that timer will not be triggered until the + * next event loop iteration. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setImmediate()`. + * @since v0.9.1 + * @param callback The function to call at the end of this turn of the Node.js `Event Loop` + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearImmediate} + */ function setImmediate(callback: (...args: TArgs) => void, ...args: TArgs): NodeJS.Immediate; // util.promisify no rest args compability // tslint:disable-next-line void-return @@ -85,6 +201,11 @@ declare module 'timers' { namespace setImmediate { const __promisify__: typeof setImmediatePromise; } + /** + * Cancels an `Immediate` object created by `setImmediate()`. + * @since v0.9.1 + * @param immediate An `Immediate` object as returned by {@link setImmediate}. + */ function clearImmediate(immediateId: NodeJS.Immediate | undefined): void; function queueMicrotask(callback: () => void): void; } diff --git a/node_modules/@types/node/timers/promises.d.ts b/node_modules/@types/node/timers/promises.d.ts index fd778880e..299a35525 100755 --- a/node_modules/@types/node/timers/promises.d.ts +++ b/node_modules/@types/node/timers/promises.d.ts @@ -1,6 +1,6 @@ /** * The `timers/promises` API provides an alternative set of timer functions - * that return `Promise` objects. The API is accessible via`require('timers/promises')`. + * that return `Promise` objects. The API is accessible via`require('node:timers/promises')`. * * ```js * import { @@ -44,6 +44,8 @@ declare module 'timers/promises' { function setImmediate(value?: T, options?: TimerOptions): Promise; /** * Returns an async iterator that generates values in an interval of `delay` ms. + * If `ref` is `true`, you need to call `next()` of async iterator explicitly + * or implicitly to keep the event loop alive. * * ```js * import { @@ -62,6 +64,29 @@ declare module 'timers/promises' { * @since v15.9.0 */ function setInterval(delay?: number, value?: T, options?: TimerOptions): AsyncIterable; + interface Scheduler { + /** + * ```js + * import { scheduler } from 'node:timers/promises'; + * + * await scheduler.wait(1000); // Wait one second before continuing + * ``` + * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. + * Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported. + * @since v16.14.0 + * @experimental + * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. + */ + wait: (delay?: number, options?: TimerOptions) => Promise; + /** + * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. + * Calling timersPromises.scheduler.yield() is equivalent to calling timersPromises.setImmediate() with no arguments. + * @since v16.14.0 + * @experimental + */ + yield: () => Promise; + } + const scheduler: Scheduler; } declare module 'node:timers/promises' { export * from 'timers/promises'; diff --git a/node_modules/@types/node/tls.d.ts b/node_modules/@types/node/tls.d.ts index 2cbc71658..13ee56353 100755 --- a/node_modules/@types/node/tls.d.ts +++ b/node_modules/@types/node/tls.d.ts @@ -1,12 +1,12 @@ /** - * The `tls` module provides an implementation of the Transport Layer Security + * The `node:tls` module provides an implementation of the Transport Layer Security * (TLS) and Secure Socket Layer (SSL) protocols that is built on top of OpenSSL. * The module can be accessed using: * * ```js - * const tls = require('tls'); + * const tls = require('node:tls'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/tls.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/tls.js) */ declare module 'tls' { import { X509Certificate } from 'node:crypto'; @@ -41,21 +41,100 @@ declare module 'tls' { CN: string; } interface PeerCertificate { + /** + * `true` if a Certificate Authority (CA), `false` otherwise. + * @since v18.13.0 + */ + ca: boolean; + /** + * The DER encoded X.509 certificate data. + */ + raw: Buffer; + /** + * The certificate subject. + */ subject: Certificate; + /** + * The certificate issuer, described in the same terms as the `subject`. + */ issuer: Certificate; - subjectaltname: string; - infoAccess: NodeJS.Dict; - modulus: string; - exponent: string; + /** + * The date-time the certificate is valid from. + */ valid_from: string; + /** + * The date-time the certificate is valid to. + */ valid_to: string; + /** + * The certificate serial number, as a hex string. + */ + serialNumber: string; + /** + * The SHA-1 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ fingerprint: string; + /** + * The SHA-256 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ fingerprint256: string; - ext_key_usage: string[]; - serialNumber: string; - raw: Buffer; + /** + * The SHA-512 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ + fingerprint512: string; + /** + * The extended key usage, a set of OIDs. + */ + ext_key_usage?: string[]; + /** + * A string containing concatenated names for the subject, + * an alternative to the `subject` names. + */ + subjectaltname?: string; + /** + * An array describing the AuthorityInfoAccess, used with OCSP. + */ + infoAccess?: NodeJS.Dict; + /** + * For RSA keys: The RSA bit size. + * + * For EC keys: The key size in bits. + */ + bits?: number; + /** + * The RSA exponent, as a string in hexadecimal number notation. + */ + exponent?: string; + /** + * The RSA modulus, as a hexadecimal string. + */ + modulus?: string; + /** + * The public key. + */ + pubkey?: Buffer; + /** + * The ASN.1 name of the OID of the elliptic curve. + * Well-known curves are identified by an OID. + * While it is unusual, it is possible that the curve + * is identified by its mathematical properties, + * in which case it will not have an OID. + */ + asn1Curve?: string; + /** + * The NIST name for the elliptic curve,if it has one + * (not all well-known curves have been assigned names by NIST). + */ + nistCurve?: string; } interface DetailedPeerCertificate extends PeerCertificate { + /** + * The issuer certificate object. + * For self-signed certificates, this may be a circular reference. + */ issuerCertificate: DetailedPeerCertificate; } interface CipherNameAndProtocol { @@ -133,7 +212,7 @@ declare module 'tls' { * * Instances of `tls.TLSSocket` implement the duplex `Stream` interface. * - * Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate} will only return data while the + * Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate}) will only return data while the * connection is open. * @since v0.11.4 */ @@ -180,13 +259,13 @@ declare module 'tls' { /** * Returns an object containing information on the negotiated cipher suite. * - * For example: + * For example, a TLSv1.2 protocol with AES256-SHA cipher: * * ```json * { - * "name": "AES128-SHA256", - * "standardName": "TLS_RSA_WITH_AES_128_CBC_SHA256", - * "version": "TLSv1.2" + * "name": "AES256-SHA", + * "standardName": "TLS_RSA_WITH_AES_256_CBC_SHA", + * "version": "SSLv3" * } * ``` * @@ -558,7 +637,8 @@ declare module 'tls' { * used. * @since v0.5.3 * @param hostname A SNI host name or wildcard (e.g. `'*'`) - * @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc). + * @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc), or a TLS context object created + * with {@link createSecureContext} itself. */ addContext(hostname: string, context: SecureContextOptions): void; /** @@ -689,12 +769,9 @@ declare module 'tls' { */ crl?: string | Buffer | Array | undefined; /** - * Diffie Hellman parameters, required for Perfect Forward Secrecy. Use - * openssl dhparam to create the parameters. The key length must be - * greater than or equal to 1024 bits or else an error will be thrown. - * Although 1024 bits is permissible, use 2048 bits or larger for - * stronger security. If omitted or invalid, the parameters are - * silently discarded and DHE ciphers will not be available. + * `'auto'` or custom Diffie-Hellman parameters, required for non-ECDHE perfect forward secrecy. + * If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available. + * ECDHE-based perfect forward secrecy will still be available. */ dhparam?: string | Buffer | undefined; /** @@ -836,14 +913,14 @@ declare module 'tls' { * Creates a new {@link Server}. The `secureConnectionListener`, if provided, is * automatically set as a listener for the `'secureConnection'` event. * - * The `ticketKeys` options is automatically shared between `cluster` module + * The `ticketKeys` options is automatically shared between `node:cluster` module * workers. * * The following illustrates a simple echo server: * * ```js - * const tls = require('tls'); - * const fs = require('fs'); + * const tls = require('node:tls'); + * const fs = require('node:fs'); * * const options = { * key: fs.readFileSync('server-key.pem'), @@ -853,7 +930,7 @@ declare module 'tls' { * requestCert: true, * * // This is necessary only if the client uses a self-signed certificate. - * ca: [ fs.readFileSync('client-cert.pem') ] + * ca: [ fs.readFileSync('client-cert.pem') ], * }; * * const server = tls.createServer(options, (socket) => { @@ -888,8 +965,8 @@ declare module 'tls' { * * ```js * // Assumes an echo server that is listening on port 8000. - * const tls = require('tls'); - * const fs = require('fs'); + * const tls = require('node:tls'); + * const fs = require('node:fs'); * * const options = { * // Necessary only if the server requires client certificate authentication. @@ -965,12 +1042,19 @@ declare module 'tls' { * APIs that create secure contexts have no default value. * * The `tls.createSecureContext()` method creates a `SecureContext` object. It is - * usable as an argument to several `tls` APIs, such as {@link createServer} and `server.addContext()`, but has no public methods. + * usable as an argument to several `tls` APIs, such as `server.addContext()`, + * but has no public methods. The {@link Server} constructor and the {@link createServer} method do not support the `secureContext` option. * * A key is _required_ for ciphers that use certificates. Either `key` or`pfx` can be used to provide it. * * If the `ca` option is not given, then Node.js will default to using [Mozilla's publicly trusted list of * CAs](https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt). + * + * Custom DHE parameters are discouraged in favor of the new `dhparam: 'auto'`option. When set to `'auto'`, well-known DHE parameters of sufficient strength + * will be selected automatically. Otherwise, if necessary, `openssl dhparam` can + * be used to create custom parameters. The key length must be greater than or + * equal to 1024 bits or else an error will be thrown. Although 1024 bits is + * permissible, use 2048 bits or larger for stronger security. * @since v0.11.13 */ function createSecureContext(options?: SecureContextOptions): SecureContext; @@ -1016,6 +1100,13 @@ declare module 'tls' { * are provided, the lowest minimum is used. */ let DEFAULT_MIN_VERSION: SecureVersion; + /** + * The default value of the ciphers option of tls.createSecureContext(). + * It can be assigned any of the supported OpenSSL ciphers. + * Defaults to the content of crypto.constants.defaultCoreCipherList, unless + * changed using CLI options using --tls-default-ciphers. + */ + let DEFAULT_CIPHERS: string; /** * An immutable array of strings representing the root certificates (in PEM * format) used for verifying peer certificates. This is the default value diff --git a/node_modules/@types/node/trace_events.d.ts b/node_modules/@types/node/trace_events.d.ts index d47aa9311..ca8baede3 100755 --- a/node_modules/@types/node/trace_events.d.ts +++ b/node_modules/@types/node/trace_events.d.ts @@ -1,9 +1,9 @@ /** - * The `trace_events` module provides a mechanism to centralize tracing information - * generated by V8, Node.js core, and userspace code. + * The `node:trace_events` module provides a mechanism to centralize tracing + * information generated by V8, Node.js core, and userspace code. * * Tracing can be enabled with the `--trace-event-categories` command-line flag - * or by using the `trace_events` module. The `--trace-event-categories` flag + * or by using the `node:trace_events` module. The `--trace-event-categories` flag * accepts a list of comma-separated category names. * * The available categories are: @@ -13,9 +13,19 @@ * The `async_hooks` events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property. * * `node.bootstrap`: Enables capture of Node.js bootstrap milestones. * * `node.console`: Enables capture of `console.time()` and `console.count()`output. + * * `node.threadpoolwork.sync`: Enables capture of trace data for threadpool + * synchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`. + * * `node.threadpoolwork.async`: Enables capture of trace data for threadpool + * asynchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`. * * `node.dns.native`: Enables capture of trace data for DNS queries. + * * `node.net.native`: Enables capture of trace data for network. * * `node.environment`: Enables capture of Node.js Environment milestones. * * `node.fs.sync`: Enables capture of trace data for file system sync methods. + * * `node.fs_dir.sync`: Enables capture of trace data for file system sync + * directory methods. + * * `node.fs.async`: Enables capture of trace data for file system async methods. + * * `node.fs_dir.async`: Enables capture of trace data for file system async + * directory methods. * * `node.perf`: Enables capture of `Performance API` measurements. * * `node.perf.usertiming`: Enables capture of only Performance API User Timing * measures and marks. @@ -23,8 +33,9 @@ * measurements. * * `node.promises.rejections`: Enables capture of trace data tracking the number * of unhandled Promise rejections and handled-after-rejections. - * * `node.vm.script`: Enables capture of trace data for the `vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods. + * * `node.vm.script`: Enables capture of trace data for the `node:vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods. * * `v8`: The `V8` events are GC, compiling, and execution related. + * * `node.http`: Enables capture of trace data for http request / response. * * By default the `node`, `node.async_hooks`, and `v8` categories are enabled. * @@ -43,10 +54,10 @@ * node --trace-event-categories v8,node,node.async_hooks * ``` * - * Alternatively, trace events may be enabled using the `trace_events` module: + * Alternatively, trace events may be enabled using the `node:trace_events` module: * * ```js - * const trace_events = require('trace_events'); + * const trace_events = require('node:trace_events'); * const tracing = trace_events.createTracing({ categories: ['node.perf'] }); * tracing.enable(); // Enable trace event capture for the 'node.perf' category * @@ -83,7 +94,7 @@ * * The features from this module are not available in `Worker` threads. * @experimental - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/trace_events.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/trace_events.js) */ declare module 'trace_events' { /** @@ -132,7 +143,7 @@ declare module 'trace_events' { * Creates and returns a `Tracing` object for the given set of `categories`. * * ```js - * const trace_events = require('trace_events'); + * const trace_events = require('node:trace_events'); * const categories = ['node.perf', 'node.async_hooks']; * const tracing = trace_events.createTracing({ categories }); * tracing.enable(); @@ -152,7 +163,7 @@ declare module 'trace_events' { * Given the file `test.js` below, the command`node --trace-event-categories node.perf test.js` will print`'node.async_hooks,node.perf'` to the console. * * ```js - * const trace_events = require('trace_events'); + * const trace_events = require('node:trace_events'); * const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] }); * const t2 = trace_events.createTracing({ categories: ['node.perf'] }); * const t3 = trace_events.createTracing({ categories: ['v8'] }); diff --git a/node_modules/@types/node/ts4.8/assert.d.ts b/node_modules/@types/node/ts4.8/assert.d.ts index 8e02a66a0..e309252c1 100755 --- a/node_modules/@types/node/ts4.8/assert.d.ts +++ b/node_modules/@types/node/ts4.8/assert.d.ts @@ -1,7 +1,7 @@ /** - * The `assert` module provides a set of assertion functions for verifying + * The `node:assert` module provides a set of assertion functions for verifying * invariants. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/assert.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/assert.js) */ declare module 'assert' { /** @@ -12,14 +12,28 @@ declare module 'assert' { function assert(value: unknown, message?: string | Error): asserts value; namespace assert { /** - * Indicates the failure of an assertion. All errors thrown by the `assert` module - * will be instances of the `AssertionError` class. + * Indicates the failure of an assertion. All errors thrown by the `node:assert`module will be instances of the `AssertionError` class. */ class AssertionError extends Error { + /** + * Set to the `actual` argument for methods such as {@link assert.strictEqual()}. + */ actual: unknown; + /** + * Set to the `expected` argument for methods such as {@link assert.strictEqual()}. + */ expected: unknown; + /** + * Set to the passed in operator value. + */ operator: string; + /** + * Indicates if the message was auto-generated (`true`) or not. + */ generatedMessage: boolean; + /** + * Value is always `ERR_ASSERTION` to show that the error is an assertion error. + */ code: 'ERR_ASSERTION'; constructor(options?: { /** If provided, the error message is set to this value. */ @@ -36,9 +50,10 @@ declare module 'assert' { }); } /** - * This feature is currently experimental and behavior might still change. + * This feature is deprecated and will be removed in a future version. + * Please consider using alternatives such as the `mock` helper function. * @since v14.2.0, v12.19.0 - * @experimental + * @deprecated Deprecated */ class CallTracker { /** @@ -47,7 +62,7 @@ declare module 'assert' { * error. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * // Creates call tracker. * const tracker = new assert.CallTracker(); @@ -65,26 +80,44 @@ declare module 'assert' { */ calls(exact?: number): () => void; calls any>(fn?: Func, exact?: number): Func; + /** + * Example: + * + * ```js + * import assert from 'node:assert'; + * + * const tracker = new assert.CallTracker(); + * + * function func() {} + * const callsfunc = tracker.calls(func); + * callsfunc(1, 2, 3); + * + * assert.deepStrictEqual(tracker.getCalls(callsfunc), + * [{ thisArg: undefined, arguments: [1, 2, 3] }]); + * ``` + * @since v18.8.0, v16.18.0 + * @param fn + * @return An Array with all the calls to a tracked function. + */ + getCalls(fn: Function): CallTrackerCall[]; /** * The arrays contains information about the expected and actual number of calls of * the functions that have not been called the expected number of times. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * // Creates call tracker. * const tracker = new assert.CallTracker(); * * function func() {} * - * function foo() {} - * * // Returns a function that wraps func() that must be called exact times * // before tracker.verify(). * const callsfunc = tracker.calls(func, 2); * * // Returns an array containing information on callsfunc() - * tracker.report(); + * console.log(tracker.report()); * // [ * // { * // message: 'Expected the func function to be executed 2 time(s) but was @@ -97,15 +130,39 @@ declare module 'assert' { * // ] * ``` * @since v14.2.0, v12.19.0 - * @return of objects containing information about the wrapper functions returned by `calls`. + * @return An Array of objects containing information about the wrapper functions returned by `calls`. */ report(): CallTrackerReportInformation[]; + /** + * Reset calls of the call tracker. + * If a tracked function is passed as an argument, the calls will be reset for it. + * If no arguments are passed, all tracked functions will be reset. + * + * ```js + * import assert from 'node:assert'; + * + * const tracker = new assert.CallTracker(); + * + * function func() {} + * const callsfunc = tracker.calls(func); + * + * callsfunc(); + * // Tracker was called once + * assert.strictEqual(tracker.getCalls(callsfunc).length, 1); + * + * tracker.reset(callsfunc); + * assert.strictEqual(tracker.getCalls(callsfunc).length, 0); + * ``` + * @since v18.8.0, v16.18.0 + * @param fn a tracked function to reset. + */ + reset(fn?: Function): void; /** * Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that * have not been called the expected number of times. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * // Creates call tracker. * const tracker = new assert.CallTracker(); @@ -125,6 +182,10 @@ declare module 'assert' { */ verify(): void; } + interface CallTrackerCall { + thisArg: object; + arguments: unknown[]; + } interface CallTrackerReportInformation { message: string; /** The actual number of times the function was called. */ @@ -143,7 +204,7 @@ declare module 'assert' { * it will be thrown instead of the `AssertionError`. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.fail(); * // AssertionError [ERR_ASSERTION]: Failed @@ -181,7 +242,7 @@ declare module 'assert' { * thrown in a file! See below for further details. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.ok(true); * // OK @@ -216,7 +277,7 @@ declare module 'assert' { * ``` * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * // Using `assert()` works the same: * assert(0); @@ -241,7 +302,7 @@ declare module 'assert' { * and treated as being identical if both sides are `NaN`. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * assert.equal(1, 1); * // OK, 1 == 1 @@ -274,7 +335,7 @@ declare module 'assert' { * specially handled and treated as being identical if both sides are `NaN`. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * assert.notEqual(1, 2); * // OK @@ -321,24 +382,24 @@ declare module 'assert' { * Tests for any deep inequality. Opposite of {@link deepEqual}. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * const obj1 = { * a: { - * b: 1 - * } + * b: 1, + * }, * }; * const obj2 = { * a: { - * b: 2 - * } + * b: 2, + * }, * }; * const obj3 = { * a: { - * b: 1 - * } + * b: 1, + * }, * }; - * const obj4 = Object.create(obj1); + * const obj4 = { __proto__: obj1 }; * * assert.notDeepEqual(obj1, obj1); * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } } @@ -364,7 +425,7 @@ declare module 'assert' { * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.strictEqual(1, 2); * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal: @@ -402,7 +463,7 @@ declare module 'assert' { * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.notStrictEqual(1, 2); * // OK @@ -433,7 +494,7 @@ declare module 'assert' { * Tests for deep strict inequality. Opposite of {@link deepStrictEqual}. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.notDeepStrictEqual({ a: 1 }, { a: '1' }); * // OK @@ -464,14 +525,14 @@ declare module 'assert' { * Custom validation object/error instance: * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * const err = new TypeError('Wrong value'); * err.code = 404; * err.foo = 'bar'; * err.info = { * nested: true, - * baz: 'text' + * baz: 'text', * }; * err.reg = /abc/i; * @@ -484,16 +545,16 @@ declare module 'assert' { * message: 'Wrong value', * info: { * nested: true, - * baz: 'text' - * } + * baz: 'text', + * }, * // Only properties on the validation object will be tested for. * // Using nested objects requires all properties to be present. Otherwise * // the validation is going to fail. - * } + * }, * ); * * // Using regular expressions to validate error properties: - * throws( + * assert.throws( * () => { * throw err; * }, @@ -507,17 +568,17 @@ declare module 'assert' { * info: { * nested: true, * // It is not possible to use regular expressions for nested properties! - * baz: 'text' + * baz: 'text', * }, * // The `reg` property contains a regular expression and only if the * // validation object contains an identical regular expression, it is going * // to pass. - * reg: /abc/i - * } + * reg: /abc/i, + * }, * ); * * // Fails due to the different `message` and `name` properties: - * throws( + * assert.throws( * () => { * const otherErr = new Error('Not found'); * // Copy all enumerable properties from `err` to `otherErr`. @@ -528,20 +589,20 @@ declare module 'assert' { * }, * // The error's `message` and `name` properties will also be checked when using * // an error as validation object. - * err + * err, * ); * ``` * * Validate instanceof using constructor: * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.throws( * () => { * throw new Error('Wrong value'); * }, - * Error + * Error, * ); * ``` * @@ -551,13 +612,13 @@ declare module 'assert' { * therefore also include the error name. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.throws( * () => { * throw new Error('Wrong value'); * }, - * /^Error: Wrong value$/ + * /^Error: Wrong value$/, * ); * ``` * @@ -567,7 +628,7 @@ declare module 'assert' { * It will otherwise fail with an `AssertionError`. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.throws( * () => { @@ -583,7 +644,7 @@ declare module 'assert' { * // possible. * return true; * }, - * 'unexpected error' + * 'unexpected error', * ); * ``` * @@ -593,7 +654,7 @@ declare module 'assert' { * a string as the second argument gets considered: * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * function throwingFirst() { * throw new Error('First'); @@ -649,20 +710,20 @@ declare module 'assert' { * propagated back to the caller. * * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), - * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation * function. See {@link throws} for more details. * * The following, for instance, will throw the `TypeError` because there is no * matching error type in the assertion: * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.doesNotThrow( * () => { * throw new TypeError('Wrong value'); * }, - * SyntaxError + * SyntaxError, * ); * ``` * @@ -670,27 +731,27 @@ declare module 'assert' { * 'Got unwanted exception...': * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.doesNotThrow( * () => { * throw new TypeError('Wrong value'); * }, - * TypeError + * TypeError, * ); * ``` * * If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message: * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.doesNotThrow( * () => { * throw new TypeError('Wrong value'); * }, * /Wrong value/, - * 'Whoops' + * 'Whoops', * ); * // Throws: AssertionError: Got unwanted exception: Whoops * ``` @@ -704,7 +765,7 @@ declare module 'assert' { * from the error passed to `ifError()` including the potential new frames for`ifError()` itself. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.ifError(null); * // OK @@ -750,7 +811,7 @@ declare module 'assert' { * If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * await assert.rejects( * async () => { @@ -758,13 +819,13 @@ declare module 'assert' { * }, * { * name: 'TypeError', - * message: 'Wrong value' - * } + * message: 'Wrong value', + * }, * ); * ``` * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * await assert.rejects( * async () => { @@ -774,16 +835,16 @@ declare module 'assert' { * assert.strictEqual(err.name, 'TypeError'); * assert.strictEqual(err.message, 'Wrong value'); * return true; - * } + * }, * ); * ``` * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.rejects( * Promise.reject(new Error('Wrong value')), - * Error + * Error, * ).then(() => { * // ... * }); @@ -813,24 +874,24 @@ declare module 'assert' { * error messages as expressive as possible. * * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), - * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation * function. See {@link throws} for more details. * * Besides the async nature to await the completion behaves identically to {@link doesNotThrow}. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * await assert.doesNotReject( * async () => { * throw new TypeError('Wrong value'); * }, - * SyntaxError + * SyntaxError, * ); * ``` * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.doesNotReject(Promise.reject(new TypeError('Wrong value'))) * .then(() => { @@ -845,7 +906,7 @@ declare module 'assert' { * Expects the `string` input to match the regular expression. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.match('I will fail', /pass/); * // AssertionError [ERR_ASSERTION]: The input did not match the regular ... @@ -868,7 +929,7 @@ declare module 'assert' { * Expects the `string` input not to match the regular expression. * * ```js - * import assert from 'assert/strict'; + * import assert from 'node:assert/strict'; * * assert.doesNotMatch('I will fail', /fail/); * // AssertionError [ERR_ASSERTION]: The input was expected to not match the ... diff --git a/node_modules/@types/node/ts4.8/async_hooks.d.ts b/node_modules/@types/node/ts4.8/async_hooks.d.ts index 0bf473965..e994f02e7 100755 --- a/node_modules/@types/node/ts4.8/async_hooks.d.ts +++ b/node_modules/@types/node/ts4.8/async_hooks.d.ts @@ -1,17 +1,24 @@ /** - * The `async_hooks` module provides an API to track asynchronous resources. It - * can be accessed using: + * We strongly discourage the use of the `async_hooks` API. + * Other APIs that can cover most of its use cases include: + * + * * `AsyncLocalStorage` tracks async context + * * `process.getActiveResourcesInfo()` tracks active resources + * + * The `node:async_hooks` module provides an API to track asynchronous resources. + * It can be accessed using: * * ```js - * import async_hooks from 'async_hooks'; + * import async_hooks from 'node:async_hooks'; * ``` * @experimental - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/async_hooks.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/async_hooks.js) */ declare module 'async_hooks' { /** * ```js - * import { executionAsyncId } from 'async_hooks'; + * import { executionAsyncId } from 'node:async_hooks'; + * import fs from 'node:fs'; * * console.log(executionAsyncId()); // 1 - bootstrap * fs.open(path, 'r', (err, fd) => { @@ -51,8 +58,8 @@ declare module 'async_hooks' { * but having an object representing the top-level can be helpful. * * ```js - * import { open } from 'fs'; - * import { executionAsyncId, executionAsyncResource } from 'async_hooks'; + * import { open } from 'node:fs'; + * import { executionAsyncId, executionAsyncResource } from 'node:async_hooks'; * * console.log(executionAsyncId(), executionAsyncResource()); // 1 {} * open(new URL(import.meta.url), 'r', (err, fd) => { @@ -64,11 +71,11 @@ declare module 'async_hooks' { * use of a tracking `Map` to store the metadata: * * ```js - * import { createServer } from 'http'; + * import { createServer } from 'node:http'; * import { * executionAsyncId, * executionAsyncResource, - * createHook + * createHook, * } from 'async_hooks'; * const sym = Symbol('state'); // Private symbol to avoid pollution * @@ -78,7 +85,7 @@ declare module 'async_hooks' { * if (cr) { * resource[sym] = cr[sym]; * } - * } + * }, * }).enable(); * * const server = createServer((req, res) => { @@ -167,11 +174,11 @@ declare module 'async_hooks' { * specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section. * * ```js - * import { createHook } from 'async_hooks'; + * import { createHook } from 'node:async_hooks'; * * const asyncHook = createHook({ * init(asyncId, type, triggerAsyncId, resource) { }, - * destroy(asyncId) { } + * destroy(asyncId) { }, * }); * ``` * @@ -223,13 +230,13 @@ declare module 'async_hooks' { * The following is an overview of the `AsyncResource` API. * * ```js - * import { AsyncResource, executionAsyncId } from 'async_hooks'; + * import { AsyncResource, executionAsyncId } from 'node:async_hooks'; * * // AsyncResource() is meant to be extended. Instantiating a * // new AsyncResource() also triggers init. If triggerAsyncId is omitted then * // async_hook.executionAsyncId() is used. * const asyncResource = new AsyncResource( - * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false } + * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false }, * ); * * // Run a function in the execution context of the resource. This will @@ -263,33 +270,17 @@ declare module 'async_hooks' { constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions); /** * Binds the given function to the current execution context. - * - * The returned function will have an `asyncResource` property referencing - * the `AsyncResource` to which the function is bound. * @since v14.8.0, v12.19.0 * @param fn The function to bind to the current execution context. * @param type An optional name to associate with the underlying `AsyncResource`. */ - static bind any, ThisArg>( - fn: Func, - type?: string, - thisArg?: ThisArg - ): Func & { - asyncResource: AsyncResource; - }; + static bind any, ThisArg>(fn: Func, type?: string, thisArg?: ThisArg): Func; /** * Binds the given function to execute to this `AsyncResource`'s scope. - * - * The returned function will have an `asyncResource` property referencing - * the `AsyncResource` to which the function is bound. * @since v14.8.0, v12.19.0 * @param fn The function to bind to the current `AsyncResource`. */ - bind any>( - fn: Func - ): Func & { - asyncResource: AsyncResource; - }; + bind any>(fn: Func): Func; /** * Call the provided function with the provided arguments in the execution context * of the async resource. This will establish the context, trigger the AsyncHooks @@ -322,17 +313,17 @@ declare module 'async_hooks' { /** * This class creates stores that stay coherent through asynchronous operations. * - * While you can create your own implementation on top of the `async_hooks` module,`AsyncLocalStorage` should be preferred as it is a performant and memory safe - * implementation that involves significant optimizations that are non-obvious to - * implement. + * While you can create your own implementation on top of the `node:async_hooks`module, `AsyncLocalStorage` should be preferred as it is a performant and memory + * safe implementation that involves significant optimizations that are non-obvious + * to implement. * * The following example uses `AsyncLocalStorage` to build a simple logger * that assigns IDs to incoming HTTP requests and includes them in messages * logged within each request. * * ```js - * import http from 'http'; - * import { AsyncLocalStorage } from 'async_hooks'; + * import http from 'node:http'; + * import { AsyncLocalStorage } from 'node:async_hooks'; * * const asyncLocalStorage = new AsyncLocalStorage(); * @@ -368,6 +359,44 @@ declare module 'async_hooks' { * @since v13.10.0, v12.17.0 */ class AsyncLocalStorage { + /** + * Binds the given function to the current execution context. + * @since v19.8.0 + * @experimental + * @param fn The function to bind to the current execution context. + * @return A new function that calls `fn` within the captured execution context. + */ + static bind any>(fn: Func): Func; + /** + * Captures the current execution context and returns a function that accepts a + * function as an argument. Whenever the returned function is called, it + * calls the function passed to it within the captured context. + * + * ```js + * const asyncLocalStorage = new AsyncLocalStorage(); + * const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot()); + * const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore())); + * console.log(result); // returns 123 + * ``` + * + * AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple + * async context tracking purposes, for example: + * + * ```js + * class Foo { + * #runInAsyncScope = AsyncLocalStorage.snapshot(); + * + * get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); } + * } + * + * const foo = asyncLocalStorage.run(123, () => new Foo()); + * console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123 + * ``` + * @since v19.8.0 + * @experimental + * @return A new function with the signature `(fn: (...args) : R, ...args) : R`. + */ + static snapshot(): (fn: (...args: TArgs) => R, ...args: TArgs) => R; /** * Disables the instance of `AsyncLocalStorage`. All subsequent calls * to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again. diff --git a/node_modules/@types/node/ts4.8/buffer.d.ts b/node_modules/@types/node/ts4.8/buffer.d.ts index 13ab33546..bf537b8a1 100755 --- a/node_modules/@types/node/ts4.8/buffer.d.ts +++ b/node_modules/@types/node/ts4.8/buffer.d.ts @@ -10,7 +10,7 @@ * recommended to explicitly reference it via an import or require statement. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Creates a zero-filled Buffer of length 10. * const buf1 = Buffer.alloc(10); @@ -41,10 +41,29 @@ * // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74]. * const buf7 = Buffer.from('tést', 'latin1'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/buffer.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/buffer.js) */ declare module 'buffer' { import { BinaryLike } from 'node:crypto'; + import { ReadableStream as WebReadableStream } from 'node:stream/web'; + /** + * This function returns `true` if `input` contains only valid UTF-8-encoded data, + * including the case in which `input` is empty. + * + * Throws if the `input` is a detached array buffer. + * @since v19.4.0, v18.14.0 + * @param input The input to validate. + */ + export function isUtf8(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean; + /** + * This function returns `true` if `input` contains only valid ASCII-encoded data, + * including the case in which `input` is empty. + * + * Throws if the `input` is a detached array buffer. + * @since v19.6.0, v18.15.0 + * @param input The input to validate. + */ + export function isAscii(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean; export const INSPECT_MAX_BYTES: number; export const kMaxLength: number; export const kStringMaxLength: number; @@ -66,7 +85,7 @@ declare module 'buffer' { * sequence cannot be adequately represented in the target encoding. For instance: * * ```js - * import { Buffer, transcode } from 'buffer'; + * import { Buffer, transcode } from 'node:buffer'; * * const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii'); * console.log(newBuf.toString('ascii')); @@ -160,13 +179,59 @@ declare module 'buffer' { * Returns a new `ReadableStream` that allows the content of the `Blob` to be read. * @since v16.7.0 */ - stream(): unknown; // pending web streams types + stream(): WebReadableStream; + } + export interface FileOptions { + /** + * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be + * converted to the platform native line-ending as specified by `require('node:os').EOL`. + */ + endings?: 'native' | 'transparent'; + /** The File content-type. */ + type?: string; + /** The last modified date of the file. `Default`: Date.now(). */ + lastModified?: number; + } + /** + * A [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) provides information about files. + * @since v19.2.0, v18.13.0 + */ + export class File extends Blob { + constructor(sources: Array, fileName: string, options?: FileOptions); + /** + * The name of the `File`. + * @since v19.2.0, v18.13.0 + */ + readonly name: string; + /** + * The last modified date of the `File`. + * @since v19.2.0, v18.13.0 + */ + readonly lastModified: number; } export import atob = globalThis.atob; export import btoa = globalThis.btoa; + import { Blob as NodeBlob } from 'buffer'; + // This conditional type will be the existing global Blob in a browser, or + // the copy below in a Node environment. + type __Blob = typeof globalThis extends { onmessage: any; Blob: infer T } ? T : NodeBlob; global { + namespace NodeJS { + export { BufferEncoding }; + } // Buffer class - type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex'; + type BufferEncoding = + | 'ascii' + | 'utf8' + | 'utf-8' + | 'utf16le' + | 'ucs2' + | 'ucs-2' + | 'base64' + | 'base64url' + | 'latin1' + | 'binary' + | 'hex'; type WithImplicitCoercion = | T | { @@ -228,7 +293,7 @@ declare module 'buffer' { * Array entries outside that range will be truncated to fit into it. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'. * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); @@ -240,7 +305,11 @@ declare module 'buffer' { * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does. * @since v5.10.0 */ - from(arrayBuffer: WithImplicitCoercion, byteOffset?: number, length?: number): Buffer; + from( + arrayBuffer: WithImplicitCoercion, + byteOffset?: number, + length?: number, + ): Buffer; /** * Creates a new Buffer using the passed {data} * @param data data to create a new Buffer @@ -258,7 +327,7 @@ declare module 'buffer' { | { [Symbol.toPrimitive](hint: 'string'): string; }, - encoding?: BufferEncoding + encoding?: BufferEncoding, ): Buffer; /** * Creates a new Buffer using the passed {data} @@ -269,7 +338,7 @@ declare module 'buffer' { * Returns `true` if `obj` is a `Buffer`, `false` otherwise. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * Buffer.isBuffer(Buffer.alloc(10)); // true * Buffer.isBuffer(Buffer.from('foo')); // true @@ -285,7 +354,7 @@ declare module 'buffer' { * or `false` otherwise. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * console.log(Buffer.isEncoding('utf8')); * // Prints: true @@ -314,7 +383,7 @@ declare module 'buffer' { * string. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const str = '\u00bd + \u00bc = \u00be'; * @@ -332,7 +401,10 @@ declare module 'buffer' { * @param [encoding='utf8'] If `string` is a string, this is its encoding. * @return The number of bytes contained within `string`. */ - byteLength(string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number; + byteLength( + string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer, + encoding?: BufferEncoding, + ): number; /** * Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together. * @@ -346,7 +418,7 @@ declare module 'buffer' { * truncated to `totalLength`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Create a single `Buffer` from a list of three `Buffer` instances. * @@ -372,11 +444,28 @@ declare module 'buffer' { * @param totalLength Total length of the `Buffer` instances in `list` when concatenated. */ concat(list: ReadonlyArray, totalLength?: number): Buffer; + /** + * Copies the underlying memory of `view` into a new `Buffer`. + * + * ```js + * const u16 = new Uint16Array([0, 0xffff]); + * const buf = Buffer.copyBytesFrom(u16, 1, 1); + * u16[1] = 0; + * console.log(buf.length); // 2 + * console.log(buf[0]); // 255 + * console.log(buf[1]); // 255 + * ``` + * @since v19.8.0 + * @param view The {TypedArray} to copy. + * @param [offset=': 0'] The starting offset within `view`. + * @param [length=view.length - offset] The number of elements from `view` to copy. + */ + copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer; /** * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from('1234'); * const buf2 = Buffer.from('0123'); @@ -394,7 +483,7 @@ declare module 'buffer' { * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.alloc(5); * @@ -402,12 +491,12 @@ declare module 'buffer' { * // Prints: * ``` * - * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown. + * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. * * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.alloc(5, 'a'); * @@ -419,7 +508,7 @@ declare module 'buffer' { * initialized by calling `buf.fill(fill, encoding)`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); * @@ -439,13 +528,13 @@ declare module 'buffer' { */ alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer; /** - * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown. + * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. * * The underlying memory for `Buffer` instances created in this way is _not_ * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(10); * @@ -476,15 +565,15 @@ declare module 'buffer' { */ allocUnsafe(size: number): Buffer; /** - * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown. A zero-length `Buffer` is created - * if `size` is 0. + * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if + * `size` is 0. * * The underlying memory for `Buffer` instances created in this way is _not_ * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize * such `Buffer` instances with zeroes. * * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances, - * allocations under 4 KB are sliced from a single pre-allocated `Buffer`. This + * allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This * allows applications to avoid the garbage collection overhead of creating many * individually allocated `Buffer` instances. This approach improves both * performance and memory usage by eliminating the need to track and clean up as @@ -496,7 +585,7 @@ declare module 'buffer' { * then copying out the relevant bits. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Need to keep around a few small chunks of memory. * const store = []; @@ -534,7 +623,7 @@ declare module 'buffer' { * written. However, partially encoded characters will not be written. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.alloc(256); * @@ -570,7 +659,7 @@ declare module 'buffer' { * as {@link constants.MAX_STRING_LENGTH}. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.allocUnsafe(26); * @@ -607,7 +696,7 @@ declare module 'buffer' { * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]); * const json = JSON.stringify(buf); @@ -634,7 +723,7 @@ declare module 'buffer' { * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from('ABC'); * const buf2 = Buffer.from('414243', 'hex'); @@ -658,7 +747,7 @@ declare module 'buffer' { * * `-1` is returned if `target` should come _after_`buf` when sorted. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from('ABC'); * const buf2 = Buffer.from('BCD'); @@ -682,7 +771,7 @@ declare module 'buffer' { * The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]); * const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]); @@ -703,7 +792,13 @@ declare module 'buffer' { * @param [sourceStart=0] The offset within `buf` at which to begin comparison. * @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive). */ - compare(target: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1; + compare( + target: Uint8Array, + targetStart?: number, + targetEnd?: number, + sourceStart?: number, + sourceEnd?: number, + ): -1 | 0 | 1; /** * Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`. * @@ -712,7 +807,7 @@ declare module 'buffer' { * different function arguments. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Create two `Buffer` instances. * const buf1 = Buffer.allocUnsafe(26); @@ -733,7 +828,7 @@ declare module 'buffer' { * ``` * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Create a `Buffer` and copy data from one region to an overlapping region * // within the same `Buffer`. @@ -766,7 +861,7 @@ declare module 'buffer' { * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('buffer'); * @@ -804,7 +899,7 @@ declare module 'buffer' { * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte * // from the original `Buffer`. @@ -831,7 +926,7 @@ declare module 'buffer' { * end of `buf` rather than the beginning. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('buffer'); * @@ -858,7 +953,7 @@ declare module 'buffer' { * `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -879,7 +974,7 @@ declare module 'buffer' { * `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -900,7 +995,7 @@ declare module 'buffer' { * This function is also available under the `writeBigUint64BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -924,7 +1019,7 @@ declare module 'buffer' { * Writes `value` to `buf` at the specified `offset` as little-endian * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -953,7 +1048,7 @@ declare module 'buffer' { * This function is also available under the `writeUintLE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(6); * @@ -981,7 +1076,7 @@ declare module 'buffer' { * This function is also available under the `writeUintBE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(6); * @@ -1007,7 +1102,7 @@ declare module 'buffer' { * when `value` is anything other than a signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(6); * @@ -1028,7 +1123,7 @@ declare module 'buffer' { * signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(6); * @@ -1050,7 +1145,7 @@ declare module 'buffer' { * This function is also available under the `readBigUint64BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]); * @@ -1072,7 +1167,7 @@ declare module 'buffer' { * This function is also available under the `readBigUint64LE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]); * @@ -1113,7 +1208,7 @@ declare module 'buffer' { * This function is also available under the `readUintLE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); * @@ -1137,7 +1232,7 @@ declare module 'buffer' { * This function is also available under the `readUintBE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); * @@ -1161,7 +1256,7 @@ declare module 'buffer' { * supporting up to 48 bits of accuracy. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); * @@ -1178,7 +1273,7 @@ declare module 'buffer' { * supporting up to 48 bits of accuracy. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); * @@ -1200,7 +1295,7 @@ declare module 'buffer' { * This function is also available under the `readUint8` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([1, -2]); * @@ -1226,7 +1321,7 @@ declare module 'buffer' { * This function is also available under the `readUint16LE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56]); * @@ -1252,7 +1347,7 @@ declare module 'buffer' { * This function is also available under the `readUint16BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56]); * @@ -1276,7 +1371,7 @@ declare module 'buffer' { * This function is also available under the `readUint32LE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); * @@ -1300,7 +1395,7 @@ declare module 'buffer' { * This function is also available under the `readUint32BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); * @@ -1322,7 +1417,7 @@ declare module 'buffer' { * Integers read from a `Buffer` are interpreted as two's complement signed values. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([-1, 5]); * @@ -1343,7 +1438,7 @@ declare module 'buffer' { * Integers read from a `Buffer` are interpreted as two's complement signed values. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0, 5]); * @@ -1362,7 +1457,7 @@ declare module 'buffer' { * Integers read from a `Buffer` are interpreted as two's complement signed values. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0, 5]); * @@ -1379,7 +1474,7 @@ declare module 'buffer' { * Integers read from a `Buffer` are interpreted as two's complement signed values. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0, 0, 0, 5]); * @@ -1398,7 +1493,7 @@ declare module 'buffer' { * Integers read from a `Buffer` are interpreted as two's complement signed values. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([0, 0, 0, 5]); * @@ -1413,7 +1508,7 @@ declare module 'buffer' { * Reads a 32-bit, little-endian float from `buf` at the specified `offset`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([1, 2, 3, 4]); * @@ -1430,7 +1525,7 @@ declare module 'buffer' { * Reads a 32-bit, big-endian float from `buf` at the specified `offset`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([1, 2, 3, 4]); * @@ -1445,7 +1540,7 @@ declare module 'buffer' { * Reads a 64-bit, little-endian double from `buf` at the specified `offset`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); * @@ -1462,7 +1557,7 @@ declare module 'buffer' { * Reads a 64-bit, big-endian double from `buf` at the specified `offset`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); * @@ -1479,7 +1574,7 @@ declare module 'buffer' { * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); * @@ -1501,7 +1596,7 @@ declare module 'buffer' { * between UTF-16 little-endian and UTF-16 big-endian: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('This is little-endian UTF-16', 'utf16le'); * buf.swap16(); // Convert to big-endian UTF-16 text. @@ -1515,7 +1610,7 @@ declare module 'buffer' { * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); * @@ -1541,7 +1636,7 @@ declare module 'buffer' { * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); * @@ -1570,7 +1665,7 @@ declare module 'buffer' { * This function is also available under the `writeUint8` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1600,7 +1695,7 @@ declare module 'buffer' { * This function is also available under the `writeUint16LE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1628,7 +1723,7 @@ declare module 'buffer' { * This function is also available under the `writeUint16BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1656,7 +1751,7 @@ declare module 'buffer' { * This function is also available under the `writeUint32LE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1683,7 +1778,7 @@ declare module 'buffer' { * This function is also available under the `writeUint32BE` alias. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1711,7 +1806,7 @@ declare module 'buffer' { * `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(2); * @@ -1734,7 +1829,7 @@ declare module 'buffer' { * The `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(2); * @@ -1756,7 +1851,7 @@ declare module 'buffer' { * The `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(2); * @@ -1778,7 +1873,7 @@ declare module 'buffer' { * The `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1800,7 +1895,7 @@ declare module 'buffer' { * The `value` is interpreted and written as a two's complement signed integer. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1820,7 +1915,7 @@ declare module 'buffer' { * undefined when `value` is anything other than a JavaScript number. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1840,7 +1935,7 @@ declare module 'buffer' { * undefined when `value` is anything other than a JavaScript number. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(4); * @@ -1860,7 +1955,7 @@ declare module 'buffer' { * other than a JavaScript number. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -1880,7 +1975,7 @@ declare module 'buffer' { * other than a JavaScript number. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(8); * @@ -1900,7 +1995,7 @@ declare module 'buffer' { * the entire `buf` will be filled: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Fill a `Buffer` with the ASCII character 'h'. * @@ -1908,6 +2003,12 @@ declare module 'buffer' { * * console.log(b.toString()); * // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh + * + * // Fill a buffer with empty string + * const c = Buffer.allocUnsafe(5).fill(''); + * + * console.log(c.fill('')); + * // Prints: * ``` * * `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or @@ -1918,7 +2019,7 @@ declare module 'buffer' { * then only the bytes of that character that fit into `buf` are written: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Fill a `Buffer` with character that takes up two bytes in UTF-8. * @@ -1930,7 +2031,7 @@ declare module 'buffer' { * fill data remains, an exception is thrown: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.allocUnsafe(5); * @@ -1942,7 +2043,7 @@ declare module 'buffer' { * // Throws an exception. * ``` * @since v0.5.0 - * @param value The value with which to fill `buf`. + * @param value The value with which to fill `buf`. Empty value (string, Uint8Array, Buffer) is coerced to `0`. * @param [offset=0] Number of bytes to skip before starting to fill `buf`. * @param [end=buf.length] Where to stop filling `buf` (not inclusive). * @param [encoding='utf8'] The encoding for `value` if `value` is a string. @@ -1959,7 +2060,7 @@ declare module 'buffer' { * value between `0` and `255`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('this is a buffer'); * @@ -1992,7 +2093,7 @@ declare module 'buffer' { * behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf). * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const b = Buffer.from('abcdef'); * @@ -2023,7 +2124,7 @@ declare module 'buffer' { * rather than the first occurrence. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('this buffer is a buffer'); * @@ -2058,7 +2159,7 @@ declare module 'buffer' { * This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf). * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const b = Buffer.from('abcdef'); * @@ -2091,7 +2192,7 @@ declare module 'buffer' { * of `buf`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * // Log the entire contents of a `Buffer`. * @@ -2115,7 +2216,7 @@ declare module 'buffer' { * Equivalent to `buf.indexOf() !== -1`. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('this is a buffer'); * @@ -2145,7 +2246,7 @@ declare module 'buffer' { * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices). * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('buffer'); * @@ -2168,7 +2269,7 @@ declare module 'buffer' { * called automatically when a `Buffer` is used in a `for..of` statement. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * * const buf = Buffer.from('buffer'); * @@ -2211,7 +2312,7 @@ declare module 'buffer' { * **For code running using Node.js APIs, converting between base64-encoded strings** * **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.** * @since v15.13.0, v14.17.0 - * @deprecated Use `Buffer.from(data, 'base64')` instead. + * @legacy Use `Buffer.from(data, 'base64')` instead. * @param data The Base64-encoded input string. */ function atob(data: string): string; @@ -2227,10 +2328,22 @@ declare module 'buffer' { * **For code running using Node.js APIs, converting between base64-encoded strings** * **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.** * @since v15.13.0, v14.17.0 - * @deprecated Use `buf.toString('base64')` instead. + * @legacy Use `buf.toString('base64')` instead. * @param data An ASCII (Latin1) string. */ function btoa(data: string): string; + interface Blob extends __Blob {} + /** + * `Blob` class is a global reference for `require('node:buffer').Blob` + * https://nodejs.org/api/buffer.html#class-blob + * @since v18.0.0 + */ + var Blob: typeof globalThis extends { + onmessage: any; + Blob: infer T; + } + ? T + : typeof NodeBlob; } } declare module 'node:buffer' { diff --git a/node_modules/@types/node/ts4.8/child_process.d.ts b/node_modules/@types/node/ts4.8/child_process.d.ts index 79c7290e0..771d39da5 100755 --- a/node_modules/@types/node/ts4.8/child_process.d.ts +++ b/node_modules/@types/node/ts4.8/child_process.d.ts @@ -1,10 +1,10 @@ /** - * The `child_process` module provides the ability to spawn subprocesses in + * The `node:child_process` module provides the ability to spawn subprocesses in * a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability * is primarily provided by the {@link spawn} function: * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const ls = spawn('ls', ['-lh', '/usr']); * * ls.stdout.on('data', (data) => { @@ -44,8 +44,8 @@ * without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks * the event loop until the spawned process either exits or is terminated. * - * For convenience, the `child_process` module provides a handful of synchronous - * and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on + * For convenience, the `node:child_process` module provides a handful of + * synchronous and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on * top of {@link spawn} or {@link spawnSync}. * * * {@link exec}: spawns a shell and runs a command within that @@ -63,7 +63,7 @@ * For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however, * the synchronous methods can have significant impact on performance due to * stalling the event loop while spawned processes complete. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/child_process.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/child_process.js) */ declare module 'child_process' { import { ObjectEncodingOptions } from 'node:fs'; @@ -94,8 +94,7 @@ declare module 'child_process' { * `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will * refer to the same value. * - * The `subprocess.stdin` property can be `undefined` if the child process could - * not be successfully spawned. + * The `subprocess.stdin` property can be `null` or `undefined`if the child process could not be successfully spawned. * @since v0.1.90 */ stdin: Writable | null; @@ -109,7 +108,7 @@ declare module 'child_process' { * refer to the same value. * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * * const subprocess = spawn('ls'); * @@ -118,8 +117,7 @@ declare module 'child_process' { * }); * ``` * - * The `subprocess.stdout` property can be `null` if the child process could - * not be successfully spawned. + * The `subprocess.stdout` property can be `null` or `undefined`if the child process could not be successfully spawned. * @since v0.1.90 */ stdout: Readable | null; @@ -132,14 +130,13 @@ declare module 'child_process' { * `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will * refer to the same value. * - * The `subprocess.stderr` property can be `null` if the child process could - * not be successfully spawned. + * The `subprocess.stderr` property can be `null` or `undefined`if the child process could not be successfully spawned. * @since v0.1.90 */ stderr: Readable | null; /** * The `subprocess.channel` property is a reference to the child's IPC channel. If - * no IPC channel currently exists, this property is `undefined`. + * no IPC channel exists, this property is `undefined`. * @since v7.1.0 */ readonly channel?: Pipe | null | undefined; @@ -154,16 +151,16 @@ declare module 'child_process' { * in the array are `null`. * * ```js - * const assert = require('assert'); - * const fs = require('fs'); - * const child_process = require('child_process'); + * const assert = require('node:assert'); + * const fs = require('node:fs'); + * const child_process = require('node:child_process'); * * const subprocess = child_process.spawn('ls', { * stdio: [ * 0, // Use parent's stdin for child. * 'pipe', // Pipe child's stdout to parent. * fs.openSync('err.out', 'w'), // Direct child's stderr to a file. - * ] + * ], * }); * * assert.strictEqual(subprocess.stdio[0], null); @@ -204,7 +201,7 @@ declare module 'child_process' { * emitted. * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const grep = spawn('grep', ['ssh']); * * console.log(`Spawned child pid: ${grep.pid}`); @@ -251,7 +248,7 @@ declare module 'child_process' { * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise. * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const grep = spawn('grep', ['ssh']); * * grep.on('close', (code, signal) => { @@ -284,7 +281,7 @@ declare module 'child_process' { * * ```js * 'use strict'; - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * * const subprocess = spawn( * 'sh', @@ -294,8 +291,8 @@ declare module 'child_process' { * console.log(process.pid, 'is alive') * }, 500);"`, * ], { - * stdio: ['inherit', 'inherit', 'inherit'] - * } + * stdio: ['inherit', 'inherit', 'inherit'], + * }, * ); * * setTimeout(() => { @@ -317,7 +314,7 @@ declare module 'child_process' { * For example, in the parent script: * * ```js - * const cp = require('child_process'); + * const cp = require('node:child_process'); * const n = cp.fork(`${__dirname}/sub.js`); * * n.on('message', (m) => { @@ -371,10 +368,10 @@ declare module 'child_process' { * a TCP server object to the child process as illustrated in the example below: * * ```js - * const subprocess = require('child_process').fork('subprocess.js'); + * const subprocess = require('node:child_process').fork('subprocess.js'); * * // Open up the server object and send the handle. - * const server = require('net').createServer(); + * const server = require('node:net').createServer(); * server.on('connection', (socket) => { * socket.end('handled by parent'); * }); @@ -398,10 +395,9 @@ declare module 'child_process' { * Once the server is now shared between the parent and child, some connections * can be handled by the parent and some by the child. * - * While the example above uses a server created using the `net` module, `dgram`module servers use exactly the same workflow with the exceptions of listening on - * a `'message'` event instead of `'connection'` and using `server.bind()` instead - * of `server.listen()`. This is, however, currently only supported on Unix - * platforms. + * While the example above uses a server created using the `node:net` module,`node:dgram` module servers use exactly the same workflow with the exceptions of + * listening on a `'message'` event instead of `'connection'` and using`server.bind()` instead of `server.listen()`. This is, however, only + * supported on Unix platforms. * * #### Example: sending a socket object * @@ -410,13 +406,13 @@ declare module 'child_process' { * handle connections with "normal" or "special" priority: * * ```js - * const { fork } = require('child_process'); + * const { fork } = require('node:child_process'); * const normal = fork('subprocess.js', ['normal']); * const special = fork('subprocess.js', ['special']); * * // Open up the server and send sockets to child. Use pauseOnConnect to prevent * // the sockets from being read before they are sent to the child process. - * const server = require('net').createServer({ pauseOnConnect: true }); + * const server = require('node:net').createServer({ pauseOnConnect: true }); * server.on('connection', (socket) => { * * // If this is special priority... @@ -482,11 +478,11 @@ declare module 'child_process' { * the child and the parent. * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * * const subprocess = spawn(process.argv[0], ['child_program.js'], { * detached: true, - * stdio: 'ignore' + * stdio: 'ignore', * }); * * subprocess.unref(); @@ -500,11 +496,11 @@ declare module 'child_process' { * to wait for the child to exit before exiting itself. * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * * const subprocess = spawn(process.argv[0], ['child_program.js'], { * detached: true, - * stdio: 'ignore' + * stdio: 'ignore', * }); * * subprocess.unref(); @@ -624,7 +620,7 @@ declare module 'child_process' { } interface CommonOptions extends ProcessEnvOptions { /** - * @default true + * @default false */ windowsHide?: boolean | undefined; /** @@ -634,6 +630,15 @@ declare module 'child_process' { } interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable { argv0?: string | undefined; + /** + * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ stdio?: StdioOptions | undefined; shell?: boolean | string | undefined; windowsVerbatimArguments?: boolean | undefined; @@ -663,7 +668,7 @@ declare module 'child_process' { * ```js * const defaults = { * cwd: undefined, - * env: process.env + * env: process.env, * }; * ``` * @@ -682,7 +687,7 @@ declare module 'child_process' { * exit code: * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const ls = spawn('ls', ['-lh', '/usr']); * * ls.stdout.on('data', (data) => { @@ -701,7 +706,7 @@ declare module 'child_process' { * Example: A very elaborate way to run `ps ax | grep ssh` * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const ps = spawn('ps', ['ax']); * const grep = spawn('grep', ['ssh']); * @@ -738,7 +743,7 @@ declare module 'child_process' { * Example of checking for failed `spawn`: * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const subprocess = spawn('bad_command'); * * subprocess.on('error', (err) => { @@ -749,14 +754,14 @@ declare module 'child_process' { * Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process * title while others (Windows, SunOS) will use `command`. * - * Node.js currently overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent, - * retrieve it with the`process.argv0` property instead. + * Node.js overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent. Retrieve + * it with the`process.argv0` property instead. * * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except * the error passed to the callback will be an `AbortError`: * * ```js - * const { spawn } = require('child_process'); + * const { spawn } = require('node:child_process'); * const controller = new AbortController(); * const { signal } = controller; * const grep = spawn('grep', ['ssh'], { signal }); @@ -815,7 +820,7 @@ declare module 'child_process' { * need to be dealt with accordingly: * * ```js - * const { exec } = require('child_process'); + * const { exec } = require('node:child_process'); * * exec('"/path/to/test file/test.sh" arg1 arg2'); * // Double quotes are used so that the space in the path is not interpreted as @@ -841,7 +846,7 @@ declare module 'child_process' { * encoding, `Buffer` objects will be passed to the callback instead. * * ```js - * const { exec } = require('child_process'); + * const { exec } = require('node:child_process'); * exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => { * if (error) { * console.error(`exec error: ${error}`); @@ -866,8 +871,8 @@ declare module 'child_process' { * callback, but with two additional properties `stdout` and `stderr`. * * ```js - * const util = require('util'); - * const exec = util.promisify(require('child_process').exec); + * const util = require('node:util'); + * const exec = util.promisify(require('node:child_process').exec); * * async function lsExample() { * const { stdout, stderr } = await exec('ls'); @@ -881,11 +886,11 @@ declare module 'child_process' { * the error passed to the callback will be an `AbortError`: * * ```js - * const { exec } = require('child_process'); + * const { exec } = require('node:child_process'); * const controller = new AbortController(); * const { signal } = controller; * const child = exec('grep ssh', { signal }, (error) => { - * console.log(error); // an AbortError + * console.error(error); // an AbortError * }); * controller.abort(); * ``` @@ -984,7 +989,10 @@ declare module 'child_process' { interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions { encoding: BufferEncoding; } - type ExecFileException = ExecException & NodeJS.ErrnoException; + type ExecFileException = + & Omit + & Omit + & { code?: string | number | undefined | null }; /** * The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified * executable `file` is spawned directly as a new process making it slightly more @@ -995,7 +1003,7 @@ declare module 'child_process' { * supported. * * ```js - * const { execFile } = require('child_process'); + * const { execFile } = require('node:child_process'); * const child = execFile('node', ['--version'], (error, stdout, stderr) => { * if (error) { * throw error; @@ -1018,8 +1026,8 @@ declare module 'child_process' { * callback, but with two additional properties `stdout` and `stderr`. * * ```js - * const util = require('util'); - * const execFile = util.promisify(require('child_process').execFile); + * const util = require('node:util'); + * const execFile = util.promisify(require('node:child_process').execFile); * async function getVersion() { * const { stdout } = await execFile('node', ['--version']); * console.log(stdout); @@ -1035,11 +1043,11 @@ declare module 'child_process' { * the error passed to the callback will be an `AbortError`: * * ```js - * const { execFile } = require('child_process'); + * const { execFile } = require('node:child_process'); * const controller = new AbortController(); * const { signal } = controller; * const child = execFile('node', ['--version'], { signal }, (error) => { - * console.log(error); // an AbortError + * console.error(error); // an AbortError * }); * controller.abort(); * ``` @@ -1192,6 +1200,15 @@ declare module 'child_process' { execPath?: string | undefined; execArgv?: string[] | undefined; silent?: boolean | undefined; + /** + * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ stdio?: StdioOptions | undefined; detached?: boolean | undefined; windowsVerbatimArguments?: boolean | undefined; @@ -1231,7 +1248,7 @@ declare module 'child_process' { * console.log(`Hello from ${process.argv[2]}!`); * }, 1_000); * } else { - * const { fork } = require('child_process'); + * const { fork } = require('node:child_process'); * const controller = new AbortController(); * const { signal } = controller; * const child = fork(__filename, ['child'], { signal }); @@ -1292,6 +1309,15 @@ declare module 'child_process' { function spawnSync(command: string, args?: ReadonlyArray, options?: SpawnSyncOptions): SpawnSyncReturns; interface CommonExecOptions extends CommonOptions { input?: string | NodeJS.ArrayBufferView | undefined; + /** + * Can be set to 'pipe', 'inherit, or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ stdio?: StdioOptions | undefined; killSignal?: NodeJS.Signals | number | undefined; maxBuffer?: number | undefined; diff --git a/node_modules/@types/node/ts4.8/cluster.d.ts b/node_modules/@types/node/ts4.8/cluster.d.ts index 37dbc5746..6ee517720 100755 --- a/node_modules/@types/node/ts4.8/cluster.d.ts +++ b/node_modules/@types/node/ts4.8/cluster.d.ts @@ -8,12 +8,12 @@ * server ports. * * ```js - * import cluster from 'cluster'; - * import http from 'http'; - * import { cpus } from 'os'; - * import process from 'process'; + * import cluster from 'node:cluster'; + * import http from 'node:http'; + * import { availableParallelism } from 'node:os'; + * import process from 'node:process'; * - * const numCPUs = cpus().length; + * const numCPUs = availableParallelism(); * * if (cluster.isPrimary) { * console.log(`Primary ${process.pid} is running`); @@ -50,7 +50,7 @@ * ``` * * On Windows, it is not yet possible to set up a named pipe server in a worker. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/cluster.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/cluster.js) */ declare module 'cluster' { import * as child from 'node:child_process'; @@ -183,7 +183,7 @@ declare module 'cluster' { * }); * * } else if (cluster.isWorker) { - * const net = require('net'); + * const net = require('node:net'); * const server = net.createServer((socket) => { * // Connections never end * }); @@ -213,12 +213,12 @@ declare module 'cluster' { * because of exiting or being signaled). Otherwise, it returns `false`. * * ```js - * import cluster from 'cluster'; - * import http from 'http'; - * import { cpus } from 'os'; - * import process from 'process'; + * import cluster from 'node:cluster'; + * import http from 'node:http'; + * import { availableParallelism } from 'node:os'; + * import process from 'node:process'; * - * const numCPUs = cpus().length; + * const numCPUs = availableParallelism(); * * if (cluster.isPrimary) { * console.log(`Primary ${process.pid} is running`); diff --git a/node_modules/@types/node/ts4.8/console.d.ts b/node_modules/@types/node/ts4.8/console.d.ts index 16c9137ad..7e35638df 100755 --- a/node_modules/@types/node/ts4.8/console.d.ts +++ b/node_modules/@types/node/ts4.8/console.d.ts @@ -1,11 +1,11 @@ /** - * The `console` module provides a simple debugging console that is similar to the - * JavaScript console mechanism provided by web browsers. + * The `node:console` module provides a simple debugging console that is similar to + * the JavaScript console mechanism provided by web browsers. * * The module exports two specific components: * - * * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream. - * * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`. + * * A `Console` class with methods such as `console.log()`, `console.error()`, and`console.warn()` that can be used to write to any Node.js stream. + * * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('node:console')`. * * _**Warning**_: The global console object's methods are neither consistently * synchronous like the browser APIs they resemble, nor are they consistently @@ -53,7 +53,7 @@ * myConsole.warn(`Danger ${name}! Danger!`); * // Prints: Danger Will Robinson! Danger!, to err * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/console.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/console.js) */ declare module 'console' { import console = require('node:console'); diff --git a/node_modules/@types/node/ts4.8/crypto.d.ts b/node_modules/@types/node/ts4.8/crypto.d.ts index 6135090b0..036abacfb 100755 --- a/node_modules/@types/node/ts4.8/crypto.d.ts +++ b/node_modules/@types/node/ts4.8/crypto.d.ts @@ -1,9 +1,10 @@ /** - * The `crypto` module provides cryptographic functionality that includes a set of - * wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions. + * The `node:crypto` module provides cryptographic functionality that includes a + * set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify + * functions. * * ```js - * const { createHmac } = await import('crypto'); + * const { createHmac } = await import('node:crypto'); * * const secret = 'abcdefg'; * const hash = createHmac('sha256', secret) @@ -13,7 +14,7 @@ * // Prints: * // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/crypto.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/crypto.js) */ declare module 'crypto' { import * as stream from 'node:stream'; @@ -25,7 +26,7 @@ declare module 'crypto' { * `` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects * should not use this element anymore. * - * The `crypto` module provides the `Certificate` class for working with SPKAC + * The `node:crypto` module provides the `Certificate` class for working with SPKAC * data. The most common usage is handling output generated by the HTML5`` element. Node.js uses [OpenSSL's SPKAC * implementation](https://www.openssl.org/docs/man1.1.0/apps/openssl-spkac.html) internally. * @since v0.11.8 @@ -33,7 +34,7 @@ declare module 'crypto' { class Certificate { /** * ```js - * const { Certificate } = await import('crypto'); + * const { Certificate } = await import('node:crypto'); * const spkac = getSpkacSomehow(); * const challenge = Certificate.exportChallenge(spkac); * console.log(challenge.toString('utf8')); @@ -46,7 +47,7 @@ declare module 'crypto' { static exportChallenge(spkac: BinaryLike): Buffer; /** * ```js - * const { Certificate } = await import('crypto'); + * const { Certificate } = await import('node:crypto'); * const spkac = getSpkacSomehow(); * const publicKey = Certificate.exportPublicKey(spkac); * console.log(publicKey); @@ -59,8 +60,8 @@ declare module 'crypto' { static exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer; /** * ```js - * import { Buffer } from 'buffer'; - * const { Certificate } = await import('crypto'); + * import { Buffer } from 'node:buffer'; + * const { Certificate } = await import('node:crypto'); * * const spkac = getSpkacSomehow(); * console.log(Certificate.verifySpkac(Buffer.from(spkac))); @@ -95,7 +96,7 @@ declare module 'crypto' { verifySpkac(spkac: NodeJS.ArrayBufferView): boolean; } namespace constants { - // https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants + // https://nodejs.org/dist/latest-v20.x/docs/api/crypto.html#crypto-constants const OPENSSL_VERSION_NUMBER: number; /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */ const SSL_OP_ALL: number; @@ -111,18 +112,8 @@ declare module 'crypto' { const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; /** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */ const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; - /** Instructs OpenSSL to always use the tmp_rsa key when performing RSA operations. */ - const SSL_OP_EPHEMERAL_RSA: number; /** Allows initial connection to servers that do not support RI. */ const SSL_OP_LEGACY_SERVER_CONNECT: number; - const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; - const SSL_OP_MICROSOFT_SESS_ID_BUG: number; - /** Instructs OpenSSL to disable the workaround for a man-in-the-middle protocol-version vulnerability in the SSL 2.0 server implementation. */ - const SSL_OP_MSIE_SSLV2_RSA_PADDING: number; - const SSL_OP_NETSCAPE_CA_DN_BUG: number; - const SSL_OP_NETSCAPE_CHALLENGE_BUG: number; - const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; - const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; /** Instructs OpenSSL to disable support for SSL/TLS compression. */ const SSL_OP_NO_COMPRESSION: number; const SSL_OP_NO_QUERY_MTU: number; @@ -134,16 +125,6 @@ declare module 'crypto' { const SSL_OP_NO_TLSv1: number; const SSL_OP_NO_TLSv1_1: number; const SSL_OP_NO_TLSv1_2: number; - const SSL_OP_PKCS1_CHECK_1: number; - const SSL_OP_PKCS1_CHECK_2: number; - /** Instructs OpenSSL to always create a new key when using temporary/ephemeral DH parameters. */ - const SSL_OP_SINGLE_DH_USE: number; - /** Instructs OpenSSL to always create a new key when using temporary/ephemeral ECDH parameters. */ - const SSL_OP_SINGLE_ECDH_USE: number; - const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; - const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; - const SSL_OP_TLS_BLOCK_PADDING_BUG: number; - const SSL_OP_TLS_D5_BUG: number; /** Instructs OpenSSL to disable version rollback attack detection. */ const SSL_OP_TLS_ROLLBACK_BUG: number; const ENGINE_METHOD_RSA: number; @@ -161,7 +142,6 @@ declare module 'crypto' { const DH_CHECK_P_NOT_PRIME: number; const DH_UNABLE_TO_CHECK_GENERATOR: number; const DH_NOT_SUITABLE_GENERATOR: number; - const ALPN_ENABLED: number; const RSA_PKCS1_PADDING: number; const RSA_SSLV23_PADDING: number; const RSA_NO_PADDING: number; @@ -206,12 +186,12 @@ declare module 'crypto' { * * ```js * import { - * createReadStream - * } from 'fs'; - * import { argv } from 'process'; + * createReadStream, + * } from 'node:fs'; + * import { argv } from 'node:process'; * const { - * createHash - * } = await import('crypto'); + * createHash, + * } = await import('node:crypto'); * * const filename = argv[2]; * @@ -249,12 +229,12 @@ declare module 'crypto' { * * ```js * import { - * createReadStream - * } from 'fs'; - * import { argv } from 'process'; + * createReadStream, + * } from 'node:fs'; + * import { argv } from 'node:process'; * const { - * createHmac - * } = await import('crypto'); + * createHmac, + * } = await import('node:crypto'); * * const filename = argv[2]; * @@ -297,8 +277,8 @@ declare module 'crypto' { * * ```js * const { - * createHash - * } = await import('crypto'); + * createHash, + * } = await import('node:crypto'); * * const hash = createHash('sha256'); * @@ -320,9 +300,9 @@ declare module 'crypto' { * Example: Using `Hash` and piped streams: * * ```js - * import { createReadStream } from 'fs'; - * import { stdout } from 'process'; - * const { createHash } = await import('crypto'); + * import { createReadStream } from 'node:fs'; + * import { stdout } from 'node:process'; + * const { createHash } = await import('node:crypto'); * * const hash = createHash('sha256'); * @@ -334,8 +314,8 @@ declare module 'crypto' { * * ```js * const { - * createHash - * } = await import('crypto'); + * createHash, + * } = await import('node:crypto'); * * const hash = createHash('sha256'); * @@ -362,8 +342,8 @@ declare module 'crypto' { * ```js * // Calculate a rolling hash. * const { - * createHash - * } = await import('crypto'); + * createHash, + * } = await import('node:crypto'); * * const hash = createHash('sha256'); * @@ -422,8 +402,8 @@ declare module 'crypto' { * * ```js * const { - * createHmac - * } = await import('crypto'); + * createHmac, + * } = await import('node:crypto'); * * const hmac = createHmac('sha256', 'a secret'); * @@ -445,11 +425,11 @@ declare module 'crypto' { * Example: Using `Hmac` and piped streams: * * ```js - * import { createReadStream } from 'fs'; - * import { stdout } from 'process'; + * import { createReadStream } from 'node:fs'; + * import { stdout } from 'node:process'; * const { - * createHmac - * } = await import('crypto'); + * createHmac, + * } = await import('node:crypto'); * * const hmac = createHmac('sha256', 'a secret'); * @@ -461,8 +441,8 @@ declare module 'crypto' { * * ```js * const { - * createHmac - * } = await import('crypto'); + * createHmac, + * } = await import('node:crypto'); * * const hmac = createHmac('sha256', 'a secret'); * @@ -575,13 +555,13 @@ declare module 'crypto' { * Example: Converting a `CryptoKey` instance to a `KeyObject`: * * ```js - * const { webcrypto, KeyObject } = await import('crypto'); - * const { subtle } = webcrypto; + * const { KeyObject } = await import('node:crypto'); + * const { subtle } = globalThis.crypto; * * const key = await subtle.generateKey({ * name: 'HMAC', * hash: 'SHA-256', - * length: 256 + * length: 256, * }, true, ['sign', 'verify']); * * const keyObject = KeyObject.from(key); @@ -698,6 +678,10 @@ declare module 'crypto' { * The `password` is used to derive the cipher key and initialization vector (IV). * The value must be either a `'latin1'` encoded string, a `Buffer`, a`TypedArray`, or a `DataView`. * + * **This function is semantically insecure for all** + * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,** + * **GCM, or CCM).** + * * The implementation of `crypto.createCipher()` derives keys using the OpenSSL * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one * iteration, and no salt. The lack of salt allows dictionary attacks as the same @@ -773,8 +757,8 @@ declare module 'crypto' { * const { * scrypt, * randomFill, - * createCipheriv - * } = await import('crypto'); + * createCipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -808,17 +792,17 @@ declare module 'crypto' { * import { * createReadStream, * createWriteStream, - * } from 'fs'; + * } from 'node:fs'; * * import { - * pipeline - * } from 'stream'; + * pipeline, + * } from 'node:stream'; * * const { * scrypt, * randomFill, - * createCipheriv - * } = await import('crypto'); + * createCipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -849,8 +833,8 @@ declare module 'crypto' { * const { * scrypt, * randomFill, - * createCipheriv - * } = await import('crypto'); + * createCipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -955,6 +939,10 @@ declare module 'crypto' { * authentication tag in bytes, see `CCM mode`. * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes. * + * **This function is semantically insecure for all** + * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,** + * **GCM, or CCM).** + * * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one * iteration, and no salt. The lack of salt allows dictionary attacks as the same @@ -1023,11 +1011,11 @@ declare module 'crypto' { * Example: Using `Decipher` objects as streams: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * const { * scryptSync, - * createDecipheriv - * } = await import('crypto'); + * createDecipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -1042,6 +1030,7 @@ declare module 'crypto' { * * let decrypted = ''; * decipher.on('readable', () => { + * let chunk; * while (null !== (chunk = decipher.read())) { * decrypted += chunk.toString('utf8'); * } @@ -1064,12 +1053,12 @@ declare module 'crypto' { * import { * createReadStream, * createWriteStream, - * } from 'fs'; - * import { Buffer } from 'buffer'; + * } from 'node:fs'; + * import { Buffer } from 'node:buffer'; * const { * scryptSync, - * createDecipheriv - * } = await import('crypto'); + * createDecipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -1089,11 +1078,11 @@ declare module 'crypto' { * Example: Using the `decipher.update()` and `decipher.final()` methods: * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * const { * scryptSync, - * createDecipheriv - * } = await import('crypto'); + * createDecipheriv, + * } = await import('node:crypto'); * * const algorithm = 'aes-192-cbc'; * const password = 'Password used to generate key'; @@ -1190,19 +1179,21 @@ declare module 'crypto' { format?: KeyFormat | undefined; type?: 'pkcs1' | 'pkcs8' | 'sec1' | undefined; passphrase?: string | Buffer | undefined; + encoding?: string | undefined; } interface PublicKeyInput { key: string | Buffer; format?: KeyFormat | undefined; type?: 'pkcs1' | 'spki' | undefined; + encoding?: string | undefined; } /** * Asynchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`. * * ```js * const { - * generateKey - * } = await import('crypto'); + * generateKey, + * } = await import('node:crypto'); * * generateKey('hmac', { length: 64 }, (err, key) => { * if (err) throw err; @@ -1224,8 +1215,8 @@ declare module 'crypto' { * * ```js * const { - * generateKeySync - * } = await import('crypto'); + * generateKeySync, + * } = await import('node:crypto'); * * const key = generateKeySync('hmac', { length: 64 }); * console.log(key.export().toString('hex')); // e89..........41e @@ -1291,7 +1282,7 @@ declare module 'crypto' { type DSAEncoding = 'der' | 'ieee-p1363'; interface SigningOptions { /** - * @See crypto.constants.RSA_PKCS1_PADDING + * @see crypto.constants.RSA_PKCS1_PADDING */ padding?: number | undefined; saltLength?: number | undefined; @@ -1305,6 +1296,7 @@ declare module 'crypto' { interface VerifyKeyObjectInput extends SigningOptions { key: KeyObject; } + interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {} type KeyLike = string | Buffer | KeyObject; /** * The `Sign` class is a utility for generating signatures. It can be used in one @@ -1324,11 +1316,11 @@ declare module 'crypto' { * const { * generateKeyPairSync, * createSign, - * createVerify - * } = await import('crypto'); + * createVerify, + * } = await import('node:crypto'); * * const { privateKey, publicKey } = generateKeyPairSync('ec', { - * namedCurve: 'sect239k1' + * namedCurve: 'sect239k1', * }); * * const sign = createSign('SHA256'); @@ -1349,8 +1341,8 @@ declare module 'crypto' { * const { * generateKeyPairSync, * createSign, - * createVerify - * } = await import('crypto'); + * createVerify, + * } = await import('node:crypto'); * * const { privateKey, publicKey } = generateKeyPairSync('rsa', { * modulusLength: 2048, @@ -1459,8 +1451,8 @@ declare module 'crypto' { * be passed instead of a public key. * @since v0.1.92 */ - verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean; - verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean; + verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView): boolean; + verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean; } /** * Creates a `DiffieHellman` key exchange object using the supplied `prime` and an @@ -1490,11 +1482,11 @@ declare module 'crypto' { * Instances of the `DiffieHellman` class can be created using the {@link createDiffieHellman} function. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * const { - * createDiffieHellman - * } = await import('crypto'); + * createDiffieHellman, + * } = await import('node:crypto'); * * // Generate Alice's keys... * const alice = createDiffieHellman(2048); @@ -1600,7 +1592,7 @@ declare module 'crypto' { * A bit field containing any warnings and/or errors resulting from a check * performed during initialization of the `DiffieHellman` object. * - * The following values are valid for this property (as defined in `constants`module): + * The following values are valid for this property (as defined in `node:constants` module): * * * `DH_CHECK_P_NOT_SAFE_PRIME` * * `DH_CHECK_P_NOT_PRIME` @@ -1635,16 +1627,16 @@ declare module 'crypto' { */ const DiffieHellmanGroup: DiffieHellmanGroupConstructor; interface DiffieHellmanGroupConstructor { - new(name: string): DiffieHellmanGroup; + new (name: string): DiffieHellmanGroup; (name: string): DiffieHellmanGroup; readonly prototype: DiffieHellmanGroup; } type DiffieHellmanGroup = Omit; /** * Creates a predefined `DiffieHellmanGroup` key exchange object. The - * supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in [RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt), but see `Caveats`) and `'modp14'`, `'modp15'`,`'modp16'`, `'modp17'`, - * `'modp18'` (defined in [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt)). The - * returned object mimics the interface of objects created by {@link createDiffieHellman}, but will not allow changing + * supported groups are listed in the documentation for `DiffieHellmanGroup`. + * + * The returned object mimics the interface of objects created by {@link createDiffieHellman}, but will not allow changing * the keys (with `diffieHellman.setPublicKey()`, for example). The * advantage of using this method is that the parties do not have to * generate nor exchange a group modulus beforehand, saving both processor @@ -1654,8 +1646,8 @@ declare module 'crypto' { * * ```js * const { - * getDiffieHellman - * } = await import('crypto'); + * getDiffieHellman, + * } = await import('node:crypto'); * const alice = getDiffieHellman('modp14'); * const bob = getDiffieHellman('modp14'); * @@ -1685,9 +1677,6 @@ declare module 'crypto' { * otherwise `err` will be `null`. By default, the successfully generated`derivedKey` will be passed to the callback as a `Buffer`. An error will be * thrown if any of the input arguments specify invalid values or types. * - * If `digest` is `null`, `'sha1'` will be used. This behavior is deprecated, - * please specify a `digest` explicitly. - * * The `iterations` argument must be a number set as high as possible. The * higher the number of iterations, the more secure the derived key will be, * but will take a longer amount of time to complete. @@ -1699,8 +1688,8 @@ declare module 'crypto' { * * ```js * const { - * pbkdf2 - * } = await import('crypto'); + * pbkdf2, + * } = await import('node:crypto'); * * pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => { * if (err) throw err; @@ -1708,18 +1697,6 @@ declare module 'crypto' { * }); * ``` * - * The `crypto.DEFAULT_ENCODING` property can be used to change the way the`derivedKey` is passed to the callback. This property, however, has been - * deprecated and use should be avoided. - * - * ```js - * import crypto from 'crypto'; - * crypto.DEFAULT_ENCODING = 'hex'; - * crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, derivedKey) => { - * if (err) throw err; - * console.log(derivedKey); // '3745e48...aa39b34' - * }); - * ``` - * * An array of supported digest functions can be retrieved using {@link getHashes}. * * This API uses libuv's threadpool, which can have surprising and @@ -1735,9 +1712,6 @@ declare module 'crypto' { * If an error occurs an `Error` will be thrown, otherwise the derived key will be * returned as a `Buffer`. * - * If `digest` is `null`, `'sha1'` will be used. This behavior is deprecated, - * please specify a `digest` explicitly. - * * The `iterations` argument must be a number set as high as possible. The * higher the number of iterations, the more secure the derived key will be, * but will take a longer amount of time to complete. @@ -1749,23 +1723,13 @@ declare module 'crypto' { * * ```js * const { - * pbkdf2Sync - * } = await import('crypto'); + * pbkdf2Sync, + * } = await import('node:crypto'); * * const key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512'); * console.log(key.toString('hex')); // '3745e48...08d59ae' * ``` * - * The `crypto.DEFAULT_ENCODING` property may be used to change the way the`derivedKey` is returned. This property, however, is deprecated and use - * should be avoided. - * - * ```js - * import crypto from 'crypto'; - * crypto.DEFAULT_ENCODING = 'hex'; - * const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 512, 'sha512'); - * console.log(key); // '3745e48...aa39b34' - * ``` - * * An array of supported digest functions can be retrieved using {@link getHashes}. * @since v0.9.3 */ @@ -1781,8 +1745,8 @@ declare module 'crypto' { * ```js * // Asynchronous * const { - * randomBytes - * } = await import('crypto'); + * randomBytes, + * } = await import('node:crypto'); * * randomBytes(256, (err, buf) => { * if (err) throw err; @@ -1797,8 +1761,8 @@ declare module 'crypto' { * ```js * // Synchronous * const { - * randomBytes - * } = await import('crypto'); + * randomBytes, + * } = await import('node:crypto'); * * const buf = randomBytes(256); * console.log( @@ -1839,8 +1803,8 @@ declare module 'crypto' { * ```js * // Asynchronous * const { - * randomInt - * } = await import('crypto'); + * randomInt, + * } = await import('node:crypto'); * * randomInt(3, (err, n) => { * if (err) throw err; @@ -1851,8 +1815,8 @@ declare module 'crypto' { * ```js * // Synchronous * const { - * randomInt - * } = await import('crypto'); + * randomInt, + * } = await import('node:crypto'); * * const n = randomInt(3); * console.log(`Random number chosen from (0, 1, 2): ${n}`); @@ -1861,8 +1825,8 @@ declare module 'crypto' { * ```js * // With `min` argument * const { - * randomInt - * } = await import('crypto'); + * randomInt, + * } = await import('node:crypto'); * * const n = randomInt(1, 7); * console.log(`The dice rolled: ${n}`); @@ -1880,8 +1844,8 @@ declare module 'crypto' { * Synchronous version of {@link randomFill}. * * ```js - * import { Buffer } from 'buffer'; - * const { randomFillSync } = await import('crypto'); + * import { Buffer } from 'node:buffer'; + * const { randomFillSync } = await import('node:crypto'); * * const buf = Buffer.alloc(10); * console.log(randomFillSync(buf).toString('hex')); @@ -1897,8 +1861,8 @@ declare module 'crypto' { * Any `ArrayBuffer`, `TypedArray` or `DataView` instance may be passed as`buffer`. * * ```js - * import { Buffer } from 'buffer'; - * const { randomFillSync } = await import('crypto'); + * import { Buffer } from 'node:buffer'; + * const { randomFillSync } = await import('node:crypto'); * * const a = new Uint32Array(10); * console.log(Buffer.from(randomFillSync(a).buffer, @@ -1926,8 +1890,8 @@ declare module 'crypto' { * If the `callback` function is not provided, an error will be thrown. * * ```js - * import { Buffer } from 'buffer'; - * const { randomFill } = await import('crypto'); + * import { Buffer } from 'node:buffer'; + * const { randomFill } = await import('node:crypto'); * * const buf = Buffer.alloc(10); * randomFill(buf, (err, buf) => { @@ -1956,8 +1920,8 @@ declare module 'crypto' { * distribution and have no meaningful lower or upper bounds. * * ```js - * import { Buffer } from 'buffer'; - * const { randomFill } = await import('crypto'); + * import { Buffer } from 'node:buffer'; + * const { randomFill } = await import('node:crypto'); * * const a = new Uint32Array(10); * randomFill(a, (err, buf) => { @@ -2023,8 +1987,8 @@ declare module 'crypto' { * * ```js * const { - * scrypt - * } = await import('crypto'); + * scrypt, + * } = await import('node:crypto'); * * // Using the factory defaults. * scrypt('password', 'salt', 64, (err, derivedKey) => { @@ -2059,8 +2023,8 @@ declare module 'crypto' { * * ```js * const { - * scryptSync - * } = await import('crypto'); + * scryptSync, + * } = await import('node:crypto'); * // Using the factory defaults. * * const key1 = scryptSync('password', 'salt', 64); @@ -2131,8 +2095,8 @@ declare module 'crypto' { /** * ```js * const { - * getCiphers - * } = await import('crypto'); + * getCiphers, + * } = await import('node:crypto'); * * console.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...] * ``` @@ -2143,8 +2107,8 @@ declare module 'crypto' { /** * ```js * const { - * getCurves - * } = await import('crypto'); + * getCurves, + * } = await import('node:crypto'); * * console.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...] * ``` @@ -2158,7 +2122,8 @@ declare module 'crypto' { */ function getFips(): 1 | 0; /** - * Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build. Throws an error if FIPS mode is not available. + * Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build. + * Throws an error if FIPS mode is not available. * @since v10.0.0 * @param bool `true` to enable FIPS mode. */ @@ -2166,8 +2131,8 @@ declare module 'crypto' { /** * ```js * const { - * getHashes - * } = await import('crypto'); + * getHashes, + * } = await import('node:crypto'); * * console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...] * ``` @@ -2182,11 +2147,11 @@ declare module 'crypto' { * Instances of the `ECDH` class can be created using the {@link createECDH} function. * * ```js - * import assert from 'assert'; + * import assert from 'node:assert'; * * const { - * createECDH - * } = await import('crypto'); + * createECDH, + * } = await import('node:crypto'); * * // Generate Alice's keys... * const alice = createECDH('secp521r1'); @@ -2227,8 +2192,8 @@ declare module 'crypto' { * ```js * const { * createECDH, - * ECDH - * } = await import('crypto'); + * ECDH, + * } = await import('node:crypto'); * * const ecdh = createECDH('secp256k1'); * ecdh.generateKeys(); @@ -2306,7 +2271,7 @@ declare module 'crypto' { * If `encoding` is specified, a string is returned; otherwise a `Buffer` is * returned. * @since v0.11.14 - * @param [encoding] The `encoding` of the return value. + * @param encoding The `encoding` of the return value. * @param [format='uncompressed'] * @return The EC Diffie-Hellman public key in the specified `encoding` and `format`. */ @@ -2335,8 +2300,10 @@ declare module 'crypto' { */ function createECDH(curveName: string): ECDH; /** - * This function is based on a constant-time algorithm. - * Returns true if `a` is equal to `b`, without leaking timing information that + * This function compares the underlying bytes that represent the given`ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time + * algorithm. + * + * This function does not leak timing information that * would allow an attacker to guess one of the values. This is suitable for * comparing HMAC digests or secret values like authentication cookies or [capability urls](https://www.w3.org/TR/capability-urls/). * @@ -2348,16 +2315,18 @@ declare module 'crypto' { * entry, such as `Uint16Array`, the result will be computed using the platform * byte order. * + * **When both of the inputs are `Float32Array`s or`Float64Array`s, this function might return unexpected results due to IEEE 754** + * **encoding of floating-point numbers. In particular, neither `x === y` nor`Object.is(x, y)` implies that the byte representations of two floating-point** + * **numbers `x` and `y` are equal.** + * * Use of `crypto.timingSafeEqual` does not guarantee that the _surrounding_ code * is timing-safe. Care should be taken to ensure that the surrounding code does * not introduce timing vulnerabilities. * @since v6.6.0 */ function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean; - /** @deprecated since v10.0.0 */ - const DEFAULT_ENCODING: BufferEncoding; type KeyType = 'rsa' | 'rsa-pss' | 'dsa' | 'ec' | 'ed25519' | 'ed448' | 'x25519' | 'x448'; - type KeyFormat = 'pem' | 'der'; + type KeyFormat = 'pem' | 'der' | 'jwk'; interface BasePrivateKeyEncodingOptions { format: T; cipher?: string | undefined; @@ -2553,8 +2522,8 @@ declare module 'crypto' { * * ```js * const { - * generateKeyPairSync - * } = await import('crypto'); + * generateKeyPairSync, + * } = await import('node:crypto'); * * const { * publicKey, @@ -2563,14 +2532,14 @@ declare module 'crypto' { * modulusLength: 4096, * publicKeyEncoding: { * type: 'spki', - * format: 'pem' + * format: 'pem', * }, * privateKeyEncoding: { * type: 'pkcs8', * format: 'pem', * cipher: 'aes-256-cbc', - * passphrase: 'top secret' - * } + * passphrase: 'top secret', + * }, * }); * ``` * @@ -2632,21 +2601,21 @@ declare module 'crypto' { * * ```js * const { - * generateKeyPair - * } = await import('crypto'); + * generateKeyPair, + * } = await import('node:crypto'); * * generateKeyPair('rsa', { * modulusLength: 4096, * publicKeyEncoding: { * type: 'spki', - * format: 'pem' + * format: 'pem', * }, * privateKeyEncoding: { * type: 'pkcs8', * format: 'pem', * cipher: 'aes-256-cbc', - * passphrase: 'top secret' - * } + * passphrase: 'top secret', + * }, * }, (err, publicKey, privateKey) => { * // Handle errors and use the generated key pair. * }); @@ -2968,11 +2937,16 @@ declare module 'crypto' { * If the `callback` function is provided this function uses libuv's threadpool. * @since v12.0.0 */ - function verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean; function verify( algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, - key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, + key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, + signature: NodeJS.ArrayBufferView + ): boolean; + function verify( + algorithm: string | null | undefined, + data: NodeJS.ArrayBufferView, + key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView, callback: (error: Error | null, result: boolean) => void ): void; @@ -3042,10 +3016,10 @@ declare module 'crypto' { * of the input arguments specify invalid values or types. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * const { - * hkdf - * } = await import('crypto'); + * hkdf, + * } = await import('node:crypto'); * * hkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => { * if (err) throw err; @@ -3054,7 +3028,7 @@ declare module 'crypto' { * ``` * @since v15.0.0 * @param digest The digest algorithm to use. - * @param ikm The input keying material. It must be at least one byte in length. + * @param ikm The input keying material. Must be provided but can be zero-length. * @param salt The salt value. Must be provided but can be zero-length. * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes. * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512` @@ -3071,17 +3045,17 @@ declare module 'crypto' { * types, or if the derived key cannot be generated. * * ```js - * import { Buffer } from 'buffer'; + * import { Buffer } from 'node:buffer'; * const { - * hkdfSync - * } = await import('crypto'); + * hkdfSync, + * } = await import('node:crypto'); * * const derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64); * console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653' * ``` * @since v15.0.0 * @param digest The digest algorithm to use. - * @param ikm The input keying material. It must be at least one byte in length. + * @param ikm The input keying material. Must be provided but can be zero-length. * @param salt The salt value. Must be provided but can be zero-length. * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes. * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512` @@ -3131,30 +3105,30 @@ declare module 'crypto' { /** * @default 'always' */ - subject: 'always' | 'never'; + subject?: 'always' | 'default' | 'never'; /** * @default true */ - wildcards: boolean; + wildcards?: boolean; /** * @default true */ - partialWildcards: boolean; + partialWildcards?: boolean; /** * @default false */ - multiLabelWildcards: boolean; + multiLabelWildcards?: boolean; /** * @default false */ - singleLabelSubdomains: boolean; + singleLabelSubdomains?: boolean; } /** * Encapsulates an X509 certificate and provides read-only access to * its information. * * ```js - * const { X509Certificate } = await import('crypto'); + * const { X509Certificate } = await import('node:crypto'); * * const x509 = new X509Certificate('{... pem encoded cert ...}'); * @@ -3184,23 +3158,53 @@ declare module 'crypto' { readonly fingerprint256: string; /** * The SHA-512 fingerprint of this certificate. - * @since v16.14.0 + * + * Because computing the SHA-256 fingerprint is usually faster and because it is + * only half the size of the SHA-512 fingerprint, `x509.fingerprint256` may be + * a better choice. While SHA-512 presumably provides a higher level of security in + * general, the security of SHA-256 matches that of most algorithms that are + * commonly used to sign certificates. + * @since v17.2.0, v16.14.0 */ - readonly fingerprint512: string; + readonly fingerprint512: string; /** * The complete subject of this certificate. * @since v15.6.0 */ readonly subject: string; /** - * The subject alternative name specified for this certificate or `undefined` - * if not available. + * The subject alternative name specified for this certificate. + * + * This is a comma-separated list of subject alternative names. Each entry begins + * with a string identifying the kind of the subject alternative name followed by + * a colon and the value associated with the entry. + * + * Earlier versions of Node.js incorrectly assumed that it is safe to split this + * property at the two-character sequence `', '` (see [CVE-2021-44532](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532)). However, + * both malicious and legitimate certificates can contain subject alternative names + * that include this sequence when represented as a string. + * + * After the prefix denoting the type of the entry, the remainder of each entry + * might be enclosed in quotes to indicate that the value is a JSON string literal. + * For backward compatibility, Node.js only uses JSON string literals within this + * property when necessary to avoid ambiguity. Third-party code should be prepared + * to handle both possible entry formats. * @since v15.6.0 */ readonly subjectAltName: string | undefined; /** - * The information access content of this certificate or `undefined` if not - * available. + * A textual representation of the certificate's authority information access + * extension. + * + * This is a line feed separated list of access descriptions. Each line begins with + * the access method and the kind of the access location, followed by a colon and + * the value associated with the access location. + * + * After the prefix denoting the access method and the kind of the access location, + * the remainder of each line might be enclosed in quotes to indicate that the + * value is a JSON string literal. For backward compatibility, Node.js only uses + * JSON string literals within this property when necessary to avoid ambiguity. + * Third-party code should be prepared to handle both possible entry formats. * @since v15.6.0 */ readonly infoAccess: string | undefined; @@ -3417,7 +3421,7 @@ declare module 'crypto' { interface CheckPrimeOptions { /** * The number of Miller-Rabin probabilistic primality iterations to perform. - * When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most 2-64 for random input. + * When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most `2**-64` for random input. * Care must be used when selecting a number of checks. * Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details. * @@ -3444,36 +3448,29 @@ declare module 'crypto' { * * `engine` could be either an id or a path to the engine's shared library. * - * The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. - * The `flags` is a bit field taking one of or a mix of the following flags (defined in `crypto.constants`): - * - * - `crypto.constants.ENGINE_METHOD_RSA` - * - `crypto.constants.ENGINE_METHOD_DSA` - * - `crypto.constants.ENGINE_METHOD_DH` - * - `crypto.constants.ENGINE_METHOD_RAND` - * - `crypto.constants.ENGINE_METHOD_EC` - * - `crypto.constants.ENGINE_METHOD_CIPHERS` - * - `crypto.constants.ENGINE_METHOD_DIGESTS` - * - `crypto.constants.ENGINE_METHOD_PKEY_METHS` - * - `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS` - * - `crypto.constants.ENGINE_METHOD_ALL` - * - `crypto.constants.ENGINE_METHOD_NONE` - * - * The flags below are deprecated in OpenSSL-1.1.0. - * - * - `crypto.constants.ENGINE_METHOD_ECDH` - * - `crypto.constants.ENGINE_METHOD_ECDSA` - * - `crypto.constants.ENGINE_METHOD_STORE` + * The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`is a bit field taking one of or a mix of the following flags (defined in`crypto.constants`): + * + * * `crypto.constants.ENGINE_METHOD_RSA` + * * `crypto.constants.ENGINE_METHOD_DSA` + * * `crypto.constants.ENGINE_METHOD_DH` + * * `crypto.constants.ENGINE_METHOD_RAND` + * * `crypto.constants.ENGINE_METHOD_EC` + * * `crypto.constants.ENGINE_METHOD_CIPHERS` + * * `crypto.constants.ENGINE_METHOD_DIGESTS` + * * `crypto.constants.ENGINE_METHOD_PKEY_METHS` + * * `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS` + * * `crypto.constants.ENGINE_METHOD_ALL` + * * `crypto.constants.ENGINE_METHOD_NONE` * @since v0.11.11 - * @param [flags=crypto.constants.ENGINE_METHOD_ALL] + * @param flags */ function setEngine(engine: string, flags?: number): void; /** - * A convenient alias for `crypto.webcrypto.getRandomValues()`. - * This implementation is not compliant with the Web Crypto spec, - * to write web-compatible code use `crypto.webcrypto.getRandomValues()` instead. + * A convenient alias for {@link webcrypto.getRandomValues}. This + * implementation is not compliant with the Web Crypto spec, to write + * web-compatible code use {@link webcrypto.getRandomValues} instead. * @since v17.4.0 - * @returns Returns `typedArray`. + * @return Returns `typedArray`. */ function getRandomValues(typedArray: T): T; /** @@ -3723,7 +3720,9 @@ declare module 'crypto' { /** * Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`, * `subtle.deriveBits()` attempts to generate `length` bits. - * The Node.js implementation requires that `length` is a multiple of `8`. + * The Node.js implementation requires that when `length` is a number it must be multiple of `8`. + * When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed + * for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms. * If successful, the returned promise will be resolved with an `` containing the generated data. * * The algorithms currently supported include: @@ -3735,7 +3734,8 @@ declare module 'crypto' { * - `'PBKDF2'` * @since v15.0.0 */ - deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise; + deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: number | null): Promise; + deriveBits(algorithm: AlgorithmIdentifier | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise; /** * Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`, * `subtle.deriveKey()` attempts to generate a new ` based on the method and parameters in `derivedKeyAlgorithm`. diff --git a/node_modules/@types/node/ts4.8/dgram.d.ts b/node_modules/@types/node/ts4.8/dgram.d.ts index 247328d28..02d71061e 100755 --- a/node_modules/@types/node/ts4.8/dgram.d.ts +++ b/node_modules/@types/node/ts4.8/dgram.d.ts @@ -1,13 +1,13 @@ /** - * The `dgram` module provides an implementation of UDP datagram sockets. + * The `node:dgram` module provides an implementation of UDP datagram sockets. * * ```js - * import dgram from 'dgram'; + * import dgram from 'node:dgram'; * * const server = dgram.createSocket('udp4'); * * server.on('error', (err) => { - * console.log(`server error:\n${err.stack}`); + * console.error(`server error:\n${err.stack}`); * server.close(); * }); * @@ -23,7 +23,7 @@ * server.bind(41234); * // Prints: server listening 0.0.0.0:41234 * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dgram.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dgram.js) */ declare module 'dgram' { import { AddressInfo } from 'node:net'; @@ -98,8 +98,8 @@ declare module 'dgram' { * When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur: * * ```js - * import cluster from 'cluster'; - * import dgram from 'dgram'; + * import cluster from 'node:cluster'; + * import dgram from 'node:dgram'; * * if (cluster.isPrimary) { * cluster.fork(); // Works ok. @@ -116,7 +116,7 @@ declare module 'dgram' { addMembership(multicastAddress: string, multicastInterface?: string): void; /** * Returns an object containing the address information for a socket. - * For UDP sockets, this object will contain `address`, `family` and `port`properties. + * For UDP sockets, this object will contain `address`, `family`, and `port`properties. * * This method throws `EBADF` if called on an unbound socket. * @since v0.1.99 @@ -142,12 +142,12 @@ declare module 'dgram' { * Example of a UDP server listening on port 41234: * * ```js - * import dgram from 'dgram'; + * import dgram from 'node:dgram'; * * const server = dgram.createSocket('udp4'); * * server.on('error', (err) => { - * console.log(`server error:\n${err.stack}`); + * console.error(`server error:\n${err.stack}`); * server.close(); * }); * @@ -284,8 +284,8 @@ declare module 'dgram' { * Example of sending a UDP packet to a port on `localhost`; * * ```js - * import dgram from 'dgram'; - * import { Buffer } from 'buffer'; + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; * * const message = Buffer.from('Some bytes'); * const client = dgram.createSocket('udp4'); @@ -297,8 +297,8 @@ declare module 'dgram' { * Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`; * * ```js - * import dgram from 'dgram'; - * import { Buffer } from 'buffer'; + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; * * const buf1 = Buffer.from('Some '); * const buf2 = Buffer.from('bytes'); @@ -316,8 +316,8 @@ declare module 'dgram' { * Example of sending a UDP packet using a socket connected to a port on`localhost`: * * ```js - * import dgram from 'dgram'; - * import { Buffer } from 'buffer'; + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; * * const message = Buffer.from('Some bytes'); * const client = dgram.createSocket('udp4'); diff --git a/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts b/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts index a87ba8ca9..5f19b201d 100755 --- a/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +++ b/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts @@ -1,11 +1,11 @@ /** - * The `diagnostics_channel` module provides an API to create named channels + * The `node:diagnostics_channel` module provides an API to create named channels * to report arbitrary message data for diagnostics purposes. * * It can be accessed using: * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * ``` * * It is intended that a module writer wanting to report diagnostics messages @@ -19,8 +19,8 @@ * channels are used along with the shape of the message data. Channel names * should generally include the module name to avoid collisions with data from * other modules. - * @experimental - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/diagnostics_channel.js) + * @since v15.1.0, v14.17.0 + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/diagnostics_channel.js) */ declare module 'diagnostics_channel' { /** @@ -31,7 +31,7 @@ declare module 'diagnostics_channel' { * performance-sensitive code. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * if (diagnostics_channel.hasSubscribers('my-channel')) { * // There are subscribers, prepare and publish message @@ -41,14 +41,14 @@ declare module 'diagnostics_channel' { * @param name The channel name * @return If there are active subscribers */ - function hasSubscribers(name: string): boolean; + function hasSubscribers(name: string | symbol): boolean; /** - * This is the primary entry-point for anyone wanting to interact with a named + * This is the primary entry-point for anyone wanting to publish to a named * channel. It produces a channel object which is optimized to reduce overhead at * publish time as much as possible. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * const channel = diagnostics_channel.channel('my-channel'); * ``` @@ -56,11 +56,48 @@ declare module 'diagnostics_channel' { * @param name The channel name * @return The named channel object */ - function channel(name: string): Channel; - type ChannelListener = (message: unknown, name: string) => void; + function channel(name: string | symbol): Channel; + type ChannelListener = (message: unknown, name: string | symbol) => void; + /** + * Register a message handler to subscribe to this channel. This message handler + * will be run synchronously whenever a message is published to the channel. Any + * errors thrown in the message handler will trigger an `'uncaughtException'`. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * diagnostics_channel.subscribe('my-channel', (message, name) => { + * // Received data + * }); + * ``` + * @since v18.7.0, v16.17.0 + * @param name The channel name + * @param onMessage The handler to receive channel messages + */ + function subscribe(name: string | symbol, onMessage: ChannelListener): void; + /** + * Remove a message handler previously registered to this channel with {@link subscribe}. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * function onMessage(message, name) { + * // Received data + * } + * + * diagnostics_channel.subscribe('my-channel', onMessage); + * + * diagnostics_channel.unsubscribe('my-channel', onMessage); + * ``` + * @since v18.7.0, v16.17.0 + * @param name The channel name + * @param onMessage The previous subscribed handler to remove + * @return `true` if the handler was found, `false` otherwise. + */ + function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean; /** * The class `Channel` represents an individual named channel within the data - * pipeline. It is use to track subscribers and to publish messages when there + * pipeline. It is used to track subscribers and to publish messages when there * are subscribers present. It exists as a separate object to avoid channel * lookups at publish time, enabling very fast publish speeds and allowing * for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly @@ -68,7 +105,7 @@ declare module 'diagnostics_channel' { * @since v15.1.0, v14.17.0 */ class Channel { - readonly name: string; + readonly name: string | symbol; /** * Check if there are active subscribers to this channel. This is helpful if * the message you want to send might be expensive to prepare. @@ -77,7 +114,7 @@ declare module 'diagnostics_channel' { * performance-sensitive code. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * const channel = diagnostics_channel.channel('my-channel'); * @@ -88,19 +125,18 @@ declare module 'diagnostics_channel' { * @since v15.1.0, v14.17.0 */ readonly hasSubscribers: boolean; - private constructor(name: string); + private constructor(name: string | symbol); /** - * Publish a message to any subscribers to the channel. This will - * trigger message handlers synchronously so they will execute within - * the same context. + * Publish a message to any subscribers to the channel. This will trigger + * message handlers synchronously so they will execute within the same context. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * const channel = diagnostics_channel.channel('my-channel'); * * channel.publish({ - * some: 'message' + * some: 'message', * }); * ``` * @since v15.1.0, v14.17.0 @@ -113,7 +149,7 @@ declare module 'diagnostics_channel' { * errors thrown in the message handler will trigger an `'uncaughtException'`. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * const channel = diagnostics_channel.channel('my-channel'); * @@ -122,6 +158,7 @@ declare module 'diagnostics_channel' { * }); * ``` * @since v15.1.0, v14.17.0 + * @deprecated Since v18.7.0,v16.17.0 - Use {@link subscribe(name, onMessage)} * @param onMessage The handler to receive channel messages */ subscribe(onMessage: ChannelListener): void; @@ -129,7 +166,7 @@ declare module 'diagnostics_channel' { * Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`. * * ```js - * import diagnostics_channel from 'diagnostics_channel'; + * import diagnostics_channel from 'node:diagnostics_channel'; * * const channel = diagnostics_channel.channel('my-channel'); * @@ -142,6 +179,7 @@ declare module 'diagnostics_channel' { * channel.unsubscribe(onMessage); * ``` * @since v15.1.0, v14.17.0 + * @deprecated Since v18.7.0,v16.17.0 - Use {@link unsubscribe(name, onMessage)} * @param onMessage The previous subscribed handler to remove * @return `true` if the handler was found, `false` otherwise. */ diff --git a/node_modules/@types/node/ts4.8/dns.d.ts b/node_modules/@types/node/ts4.8/dns.d.ts index 305367b81..db3febcd3 100755 --- a/node_modules/@types/node/ts4.8/dns.d.ts +++ b/node_modules/@types/node/ts4.8/dns.d.ts @@ -1,5 +1,5 @@ /** - * The `dns` module enables name resolution. For example, use it to look up IP + * The `node:dns` module enables name resolution. For example, use it to look up IP * addresses of host names. * * Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the @@ -9,7 +9,7 @@ * system do, use {@link lookup}. * * ```js - * const dns = require('dns'); + * const dns = require('node:dns'); * * dns.lookup('example.org', (err, address, family) => { * console.log('address: %j family: IPv%s', address, family); @@ -17,13 +17,13 @@ * // address: "93.184.216.34" family: IPv4 * ``` * - * All other functions in the `dns` module connect to an actual DNS server to + * All other functions in the `node:dns` module connect to an actual DNS server to * perform name resolution. They will always use the network to perform DNS * queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform * DNS queries, bypassing other name-resolution facilities. * * ```js - * const dns = require('dns'); + * const dns = require('node:dns'); * * dns.resolve4('archive.org', (err, addresses) => { * if (err) throw err; @@ -42,7 +42,7 @@ * ``` * * See the `Implementation considerations section` for more information. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dns.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dns.js) */ declare module 'dns' { import * as dnsPromises from 'node:dns/promises'; @@ -76,8 +76,8 @@ declare module 'dns' { /** * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or * AAAA (IPv6) record. All `option` properties are optional. If `options` is an - * integer, then it must be `4` or `6` – if `options` is not provided, then IPv4 - * and IPv6 addresses are both returned if found. + * integer, then it must be `4` or `6` – if `options` is `0` or not provided, then + * IPv4 and IPv6 addresses are both returned if found. * * With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the * properties `address` and `family`. @@ -89,14 +89,14 @@ declare module 'dns' { * * `dns.lookup()` does not necessarily have anything to do with the DNS protocol. * The implementation uses an operating system facility that can associate names - * with addresses, and vice versa. This implementation can have subtle but + * with addresses and vice versa. This implementation can have subtle but * important consequences on the behavior of any Node.js program. Please take some * time to consult the `Implementation considerations section` before using`dns.lookup()`. * * Example usage: * * ```js - * const dns = require('dns'); + * const dns = require('node:dns'); * const options = { * family: 6, * hints: dns.ADDRCONFIG | dns.V4MAPPED, @@ -135,7 +135,7 @@ declare module 'dns' { * On an error, `err` is an `Error` object, where `err.code` is the error code. * * ```js - * const dns = require('dns'); + * const dns = require('node:dns'); * dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { * console.log(hostname, service); * // Prints: localhost ssh @@ -174,7 +174,7 @@ declare module 'dns' { type: 'AAAA'; } export interface CaaRecord { - critial: number; + critical: number; issue?: string | undefined; issuewild?: string | undefined; iodef?: string | undefined; @@ -291,7 +291,7 @@ declare module 'dns' { function __promisify__(hostname: string, options?: ResolveOptions): Promise; } /** - * Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function + * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function * will contain an array of IPv6 addresses. * @since v0.1.16 * @param hostname Host name to resolve. @@ -333,7 +333,7 @@ declare module 'dns' { function __promisify__(hostname: string): Promise; } /** - * Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of + * Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of * objects with the following properties: * * * `flags` @@ -484,6 +484,14 @@ declare module 'dns' { * @since v0.1.16 */ export function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void; + /** + * Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be: + * + * * `ipv4first`: for `verbatim` defaulting to `false`. + * * `verbatim`: for `verbatim` defaulting to `true`. + * @since v20.1.0 + */ + export function getDefaultResultOrder(): 'ipv4first' | 'verbatim'; /** * Sets the IP address and port of servers to be used when performing DNS * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted @@ -535,7 +543,7 @@ declare module 'dns' { * * `ipv4first`: sets default `verbatim` `false`. * * `verbatim`: sets default `verbatim` `true`. * - * The default is `ipv4first` and {@link setDefaultResultOrder} have higher + * The default is `verbatim` and {@link setDefaultResultOrder} have higher * priority than `--dns-result-order`. When using `worker threads`,{@link setDefaultResultOrder} from the main thread won't affect the default * dns orders in workers. * @since v16.4.0, v14.18.0 @@ -582,7 +590,7 @@ declare module 'dns' { * other resolvers: * * ```js - * const { Resolver } = require('dns'); + * const { Resolver } = require('node:dns'); * const resolver = new Resolver(); * resolver.setServers(['4.4.4.4']); * @@ -592,7 +600,7 @@ declare module 'dns' { * }); * ``` * - * The following methods from the `dns` module are available: + * The following methods from the `node:dns` module are available: * * * `resolver.getServers()` * * `resolver.resolve()` @@ -625,6 +633,7 @@ declare module 'dns' { resolve4: typeof resolve4; resolve6: typeof resolve6; resolveAny: typeof resolveAny; + resolveCaa: typeof resolveCaa; resolveCname: typeof resolveCname; resolveMx: typeof resolveMx; resolveNaptr: typeof resolveNaptr; @@ -639,7 +648,7 @@ declare module 'dns' { * This allows programs to specify outbound interfaces when used on multi-homed * systems. * - * If a v4 or v6 address is not specified, it is set to the default, and the + * If a v4 or v6 address is not specified, it is set to the default and the * operating system will choose a local address automatically. * * The resolver will use the v4 local address when making requests to IPv4 DNS diff --git a/node_modules/@types/node/ts4.8/dns/promises.d.ts b/node_modules/@types/node/ts4.8/dns/promises.d.ts index 77cd807bd..4c151e440 100755 --- a/node_modules/@types/node/ts4.8/dns/promises.d.ts +++ b/node_modules/@types/node/ts4.8/dns/promises.d.ts @@ -1,7 +1,7 @@ /** * The `dns.promises` API provides an alternative set of asynchronous DNS methods * that return `Promise` objects rather than using callbacks. The API is accessible - * via `require('dns').promises` or `require('dns/promises')`. + * via `require('node:dns').promises` or `require('node:dns/promises')`. * @since v10.6.0 */ declare module 'dns/promises' { @@ -52,7 +52,7 @@ declare module 'dns/promises' { * * `dnsPromises.lookup()` does not necessarily have anything to do with the DNS * protocol. The implementation uses an operating system facility that can - * associate names with addresses, and vice versa. This implementation can have + * associate names with addresses and vice versa. This implementation can have * subtle but important consequences on the behavior of any Node.js program. Please * take some time to consult the `Implementation considerations section` before * using `dnsPromises.lookup()`. @@ -60,7 +60,7 @@ declare module 'dns/promises' { * Example usage: * * ```js - * const dns = require('dns'); + * const dns = require('node:dns'); * const dnsPromises = dns.promises; * const options = { * family: 6, @@ -96,7 +96,7 @@ declare module 'dns/promises' { * On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code. * * ```js - * const dnsPromises = require('dns').promises; + * const dnsPromises = require('node:dns').promises; * dnsPromises.lookupService('127.0.0.1', 22).then((result) => { * console.log(result.hostname, result.service); * // Prints: localhost ssh @@ -206,7 +206,7 @@ declare module 'dns/promises' { */ function resolveMx(hostname: string): Promise; /** - * Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array + * Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array * of objects with the following properties: * * * `flags` @@ -337,13 +337,56 @@ declare module 'dns/promises' { * * `ipv4first`: sets default `verbatim` `false`. * * `verbatim`: sets default `verbatim` `true`. * - * The default is `ipv4first` and `dnsPromises.setDefaultResultOrder()` have + * The default is `verbatim` and `dnsPromises.setDefaultResultOrder()` have * higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.setDefaultResultOrder()` from the main thread won't affect the * default dns orders in workers. * @since v16.4.0, v14.18.0 * @param order must be `'ipv4first'` or `'verbatim'`. */ function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void; + /** + * An independent resolver for DNS requests. + * + * Creating a new resolver uses the default server settings. Setting + * the servers used for a resolver using `resolver.setServers()` does not affect + * other resolvers: + * + * ```js + * const { Resolver } = require('node:dns').promises; + * const resolver = new Resolver(); + * resolver.setServers(['4.4.4.4']); + * + * // This request will use the server at 4.4.4.4, independent of global settings. + * resolver.resolve4('example.org').then((addresses) => { + * // ... + * }); + * + * // Alternatively, the same code can be written using async-await style. + * (async function() { + * const addresses = await resolver.resolve4('example.org'); + * })(); + * ``` + * + * The following methods from the `dnsPromises` API are available: + * + * * `resolver.getServers()` + * * `resolver.resolve()` + * * `resolver.resolve4()` + * * `resolver.resolve6()` + * * `resolver.resolveAny()` + * * `resolver.resolveCaa()` + * * `resolver.resolveCname()` + * * `resolver.resolveMx()` + * * `resolver.resolveNaptr()` + * * `resolver.resolveNs()` + * * `resolver.resolvePtr()` + * * `resolver.resolveSoa()` + * * `resolver.resolveSrv()` + * * `resolver.resolveTxt()` + * * `resolver.reverse()` + * * `resolver.setServers()` + * @since v10.6.0 + */ class Resolver { constructor(options?: ResolverOptions); cancel(): void; @@ -352,6 +395,7 @@ declare module 'dns/promises' { resolve4: typeof resolve4; resolve6: typeof resolve6; resolveAny: typeof resolveAny; + resolveCaa: typeof resolveCaa; resolveCname: typeof resolveCname; resolveMx: typeof resolveMx; resolveNaptr: typeof resolveNaptr; diff --git a/node_modules/@types/node/ts4.8/dom-events.d.ts b/node_modules/@types/node/ts4.8/dom-events.d.ts new file mode 100755 index 000000000..b9c1c3aa4 --- /dev/null +++ b/node_modules/@types/node/ts4.8/dom-events.d.ts @@ -0,0 +1,126 @@ +export {}; // Don't export anything! + +//// DOM-like Events +// NB: The Event / EventTarget / EventListener implementations below were copied +// from lib.dom.d.ts, then edited to reflect Node's documentation at +// https://nodejs.org/api/events.html#class-eventtarget. +// Please read that link to understand important implementation differences. + +// This conditional type will be the existing global Event in a browser, or +// the copy below in a Node environment. +type __Event = typeof globalThis extends { onmessage: any, Event: any } +? {} +: { + /** This is not used in Node.js and is provided purely for completeness. */ + readonly bubbles: boolean; + /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */ + cancelBubble: () => void; + /** True if the event was created with the cancelable option */ + readonly cancelable: boolean; + /** This is not used in Node.js and is provided purely for completeness. */ + readonly composed: boolean; + /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */ + composedPath(): [EventTarget?] + /** Alias for event.target. */ + readonly currentTarget: EventTarget | null; + /** Is true if cancelable is true and event.preventDefault() has been called. */ + readonly defaultPrevented: boolean; + /** This is not used in Node.js and is provided purely for completeness. */ + readonly eventPhase: 0 | 2; + /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */ + readonly isTrusted: boolean; + /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */ + preventDefault(): void; + /** This is not used in Node.js and is provided purely for completeness. */ + returnValue: boolean; + /** Alias for event.target. */ + readonly srcElement: EventTarget | null; + /** Stops the invocation of event listeners after the current one completes. */ + stopImmediatePropagation(): void; + /** This is not used in Node.js and is provided purely for completeness. */ + stopPropagation(): void; + /** The `EventTarget` dispatching the event */ + readonly target: EventTarget | null; + /** The millisecond timestamp when the Event object was created. */ + readonly timeStamp: number; + /** Returns the type of event, e.g. "click", "hashchange", or "submit". */ + readonly type: string; +}; + +// See comment above explaining conditional type +type __EventTarget = typeof globalThis extends { onmessage: any, EventTarget: any } +? {} +: { + /** + * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value. + * + * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched. + * + * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification. + * Specifically, the `capture` option is used as part of the key when registering a `listener`. + * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`. + */ + addEventListener( + type: string, + listener: EventListener | EventListenerObject, + options?: AddEventListenerOptions | boolean, + ): void; + /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */ + dispatchEvent(event: Event): boolean; + /** Removes the event listener in target's event listener list with the same type, callback, and options. */ + removeEventListener( + type: string, + listener: EventListener | EventListenerObject, + options?: EventListenerOptions | boolean, + ): void; +}; + +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; + composed?: boolean; +} + +interface EventListenerOptions { + /** Not directly used by Node.js. Added for API completeness. Default: `false`. */ + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */ + once?: boolean; + /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */ + passive?: boolean; +} + +interface EventListener { + (evt: Event): void; +} + +interface EventListenerObject { + handleEvent(object: Event): void; +} + +import {} from 'events'; // Make this an ambient declaration +declare global { + /** An event which takes place in the DOM. */ + interface Event extends __Event {} + var Event: typeof globalThis extends { onmessage: any, Event: infer T } + ? T + : { + prototype: __Event; + new (type: string, eventInitDict?: EventInit): __Event; + }; + + /** + * EventTarget is a DOM interface implemented by objects that can + * receive events and may have listeners for them. + */ + interface EventTarget extends __EventTarget {} + var EventTarget: typeof globalThis extends { onmessage: any, EventTarget: infer T } + ? T + : { + prototype: __EventTarget; + new (): __EventTarget; + }; +} diff --git a/node_modules/@types/node/ts4.8/domain.d.ts b/node_modules/@types/node/ts4.8/domain.d.ts index fafe68a5d..e49b87fc1 100755 --- a/node_modules/@types/node/ts4.8/domain.d.ts +++ b/node_modules/@types/node/ts4.8/domain.d.ts @@ -12,7 +12,7 @@ * will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to * exit immediately with an error code. * @deprecated Since v1.4.2 - Deprecated - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/domain.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/domain.js) */ declare module 'domain' { import EventEmitter = require('node:events'); @@ -56,15 +56,15 @@ declare module 'domain' { exit(): void; /** * Run the supplied function in the context of the domain, implicitly - * binding all event emitters, timers, and lowlevel requests that are + * binding all event emitters, timers, and low-level requests that are * created in that context. Optionally, arguments can be passed to * the function. * * This is the most basic way to use a domain. * * ```js - * const domain = require('domain'); - * const fs = require('fs'); + * const domain = require('node:domain'); + * const fs = require('node:fs'); * const d = domain.create(); * d.on('error', (er) => { * console.error('Caught error!', er); diff --git a/node_modules/@types/node/ts4.8/events.d.ts b/node_modules/@types/node/ts4.8/events.d.ts index b8283ac95..29616e123 100755 --- a/node_modules/@types/node/ts4.8/events.d.ts +++ b/node_modules/@types/node/ts4.8/events.d.ts @@ -22,7 +22,7 @@ * the `eventEmitter.emit()` method is used to trigger the event. * * ```js - * const EventEmitter = require('events'); + * import { EventEmitter } from 'node:events'; * * class MyEmitter extends EventEmitter {} * @@ -32,19 +32,54 @@ * }); * myEmitter.emit('event'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/events.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/events.js) */ declare module 'events' { + // NOTE: This class is in the docs but is **not actually exported** by Node. + // If https://github.com/nodejs/node/issues/39903 gets resolved and Node + // actually starts exporting the class, uncomment below. + // import { EventListener, EventListenerObject } from '__dom-events'; + // /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */ + // interface NodeEventTarget extends EventTarget { + // /** + // * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API. + // * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget. + // */ + // addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this; + // /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */ + // eventNames(): string[]; + // /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */ + // listenerCount(type: string): number; + // /** Node.js-specific alias for `eventTarget.removeListener()`. */ + // off(type: string, listener: EventListener | EventListenerObject): this; + // /** Node.js-specific alias for `eventTarget.addListener()`. */ + // on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this; + // /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */ + // once(type: string, listener: EventListener | EventListenerObject): this; + // /** + // * Node.js-specific extension to the `EventTarget` class. + // * If `type` is specified, removes all registered listeners for `type`, + // * otherwise removes all registered listeners. + // */ + // removeAllListeners(type: string): this; + // /** + // * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`. + // * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`. + // */ + // removeListener(type: string, listener: EventListener | EventListenerObject): this; + // } interface EventEmitterOptions { /** * Enables automatic capturing of promise rejection. */ captureRejections?: boolean | undefined; } - interface NodeEventTarget { + // Any EventTarget with a Node-style `once` function + interface _NodeEventTarget { once(eventName: string | symbol, listener: (...args: any[]) => void): this; } - interface DOMEventTarget { + // Any EventTarget with a DOM-style `addEventListener` + interface _DOMEventTarget { addEventListener( eventName: string, listener: (...args: any[]) => void, @@ -58,10 +93,10 @@ declare module 'events' { } interface EventEmitter extends NodeJS.EventEmitter {} /** - * The `EventEmitter` class is defined and exposed by the `events` module: + * The `EventEmitter` class is defined and exposed by the `node:events` module: * * ```js - * const EventEmitter = require('events'); + * import { EventEmitter } from 'node:events'; * ``` * * All `EventEmitter`s emit the event `'newListener'` when new listeners are @@ -82,31 +117,28 @@ declare module 'events' { * semantics and does not listen to the `'error'` event. * * ```js - * const { once, EventEmitter } = require('events'); + * import { once, EventEmitter } from 'node:events'; + * import process from 'node:process'; * - * async function run() { - * const ee = new EventEmitter(); + * const ee = new EventEmitter(); * - * process.nextTick(() => { - * ee.emit('myevent', 42); - * }); + * process.nextTick(() => { + * ee.emit('myevent', 42); + * }); * - * const [value] = await once(ee, 'myevent'); - * console.log(value); + * const [value] = await once(ee, 'myevent'); + * console.log(value); * - * const err = new Error('kaboom'); - * process.nextTick(() => { - * ee.emit('error', err); - * }); + * const err = new Error('kaboom'); + * process.nextTick(() => { + * ee.emit('error', err); + * }); * - * try { - * await once(ee, 'myevent'); - * } catch (err) { - * console.log('error happened', err); - * } + * try { + * await once(ee, 'myevent'); + * } catch (err) { + * console.error('error happened', err); * } - * - * run(); * ``` * * The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the @@ -114,13 +146,13 @@ declare module 'events' { * special handling: * * ```js - * const { EventEmitter, once } = require('events'); + * import { EventEmitter, once } from 'node:events'; * * const ee = new EventEmitter(); * * once(ee, 'error') * .then(([err]) => console.log('ok', err.message)) - * .catch((err) => console.log('error', err.message)); + * .catch((err) => console.error('error', err.message)); * * ee.emit('error', new Error('boom')); * @@ -130,7 +162,7 @@ declare module 'events' { * An `AbortSignal` can be used to cancel waiting for the event: * * ```js - * const { EventEmitter, once } = require('events'); + * import { EventEmitter, once } from 'node:events'; * * const ee = new EventEmitter(); * const ac = new AbortController(); @@ -154,29 +186,28 @@ declare module 'events' { * ``` * @since v11.13.0, v10.16.0 */ - static once(emitter: NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise; - static once(emitter: DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise; + static once(emitter: _NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise; + static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise; /** * ```js - * const { on, EventEmitter } = require('events'); - * - * (async () => { - * const ee = new EventEmitter(); + * import { on, EventEmitter } from 'node:events'; + * import process from 'node:process'; * - * // Emit later on - * process.nextTick(() => { - * ee.emit('foo', 'bar'); - * ee.emit('foo', 42); - * }); + * const ee = new EventEmitter(); * - * for await (const event of on(ee, 'foo')) { - * // The execution of this inner block is synchronous and it - * // processes one event at a time (even with await). Do not use - * // if concurrent execution is required. - * console.log(event); // prints ['bar'] [42] - * } - * // Unreachable here - * })(); + * // Emit later on + * process.nextTick(() => { + * ee.emit('foo', 'bar'); + * ee.emit('foo', 42); + * }); + * + * for await (const event of on(ee, 'foo')) { + * // The execution of this inner block is synchronous and it + * // processes one event at a time (even with await). Do not use + * // if concurrent execution is required. + * console.log(event); // prints ['bar'] [42] + * } + * // Unreachable here * ``` * * Returns an `AsyncIterator` that iterates `eventName` events. It will throw @@ -187,7 +218,9 @@ declare module 'events' { * An `AbortSignal` can be used to cancel waiting on events: * * ```js - * const { on, EventEmitter } = require('events'); + * import { on, EventEmitter } from 'node:events'; + * import process from 'node:process'; + * * const ac = new AbortController(); * * (async () => { @@ -219,7 +252,8 @@ declare module 'events' { * A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`. * * ```js - * const { EventEmitter, listenerCount } = require('events'); + * import { EventEmitter, listenerCount } from 'node:events'; + * * const myEmitter = new EventEmitter(); * myEmitter.on('event', () => {}); * myEmitter.on('event', () => {}); @@ -242,30 +276,27 @@ declare module 'events' { * event target. This is useful for debugging and diagnostic purposes. * * ```js - * const { getEventListeners, EventEmitter } = require('events'); + * import { getEventListeners, EventEmitter } from 'node:events'; * * { * const ee = new EventEmitter(); * const listener = () => console.log('Events are fun'); * ee.on('foo', listener); - * getEventListeners(ee, 'foo'); // [listener] + * console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ] * } * { * const et = new EventTarget(); * const listener = () => console.log('Events are fun'); * et.addEventListener('foo', listener); - * getEventListeners(et, 'foo'); // [listener] + * console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ] * } * ``` * @since v15.2.0, v14.17.0 */ - static getEventListeners(emitter: DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[]; + static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[]; /** * ```js - * const { - * setMaxListeners, - * EventEmitter - * } = require('events'); + * import { setMaxListeners, EventEmitter } from 'node:events'; * * const target = new EventTarget(); * const emitter = new EventEmitter(); @@ -277,23 +308,65 @@ declare module 'events' { * @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter} * objects. */ - static setMaxListeners(n?: number, ...eventTargets: Array): void; + static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void; /** - * This symbol shall be used to install a listener for only monitoring `'error'` - * events. Listeners installed using this symbol are called before the regular - * `'error'` listeners are called. + * This symbol shall be used to install a listener for only monitoring `'error'`events. Listeners installed using this symbol are called before the regular`'error'` listeners are called. * - * Installing a listener using this symbol does not change the behavior once an - * `'error'` event is emitted, therefore the process will still crash if no + * Installing a listener using this symbol does not change the behavior once an`'error'` event is emitted. Therefore, the process will still crash if no * regular `'error'` listener is installed. + * @since v13.6.0, v12.17.0 */ static readonly errorMonitor: unique symbol; + /** + * Value: `Symbol.for('nodejs.rejection')` + * + * See how to write a custom `rejection handler`. + * @since v13.4.0, v12.16.0 + */ static readonly captureRejectionSymbol: unique symbol; /** - * Sets or gets the default captureRejection value for all emitters. + * Value: [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) + * + * Change the default `captureRejections` option on all new `EventEmitter` objects. + * @since v13.4.0, v12.16.0 */ - // TODO: These should be described using static getter/setter pairs: static captureRejections: boolean; + /** + * By default, a maximum of `10` listeners can be registered for any single + * event. This limit can be changed for individual `EventEmitter` instances + * using the `emitter.setMaxListeners(n)` method. To change the default + * for _all_`EventEmitter` instances, the `events.defaultMaxListeners`property can be used. If this value is not a positive number, a `RangeError`is thrown. + * + * Take caution when setting the `events.defaultMaxListeners` because the + * change affects _all_`EventEmitter` instances, including those created before + * the change is made. However, calling `emitter.setMaxListeners(n)` still has + * precedence over `events.defaultMaxListeners`. + * + * This is not a hard limit. The `EventEmitter` instance will allow + * more listeners to be added but will output a trace warning to stderr indicating + * that a "possible EventEmitter memory leak" has been detected. For any single`EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()`methods can be used to + * temporarily avoid this warning: + * + * ```js + * import { EventEmitter } from 'node:events'; + * const emitter = new EventEmitter(); + * emitter.setMaxListeners(emitter.getMaxListeners() + 1); + * emitter.once('event', () => { + * // do stuff + * emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0)); + * }); + * ``` + * + * The `--trace-warnings` command-line flag can be used to display the + * stack trace for such warnings. + * + * The emitted warning can be inspected with `process.on('warning')` and will + * have the additional `emitter`, `type`, and `count` properties, referring to + * the event emitter instance, the event's name and the number of attached + * listeners, respectively. + * Its `name` property is set to `'MaxListenersExceededWarning'`. + * @since v0.11.2 + */ static defaultMaxListeners: number; } import internal = require('node:events'); @@ -333,6 +406,7 @@ declare module 'events' { * event listener to the beginning of the listeners array. * * ```js + * import { EventEmitter } from 'node:events'; * const myEE = new EventEmitter(); * myEE.on('foo', () => console.log('a')); * myEE.prependListener('foo', () => console.log('b')); @@ -362,6 +436,7 @@ declare module 'events' { * event listener to the beginning of the listeners array. * * ```js + * import { EventEmitter } from 'node:events'; * const myEE = new EventEmitter(); * myEE.once('foo', () => console.log('a')); * myEE.prependOnceListener('foo', () => console.log('b')); @@ -397,6 +472,8 @@ declare module 'events' { * will not remove them from`emit()` in progress. Subsequent events behave as expected. * * ```js + * import { EventEmitter } from 'node:events'; + * class MyEmitter extends EventEmitter {} * const myEmitter = new MyEmitter(); * * const callbackA = () => { @@ -437,6 +514,7 @@ declare module 'events' { * recently added instance. In the example the `once('ping')`listener is removed: * * ```js + * import { EventEmitter } from 'node:events'; * const ee = new EventEmitter(); * * function pong() { @@ -505,6 +583,7 @@ declare module 'events' { * including any wrappers (such as those created by `.once()`). * * ```js + * import { EventEmitter } from 'node:events'; * const emitter = new EventEmitter(); * emitter.once('log', () => console.log('log once')); * @@ -537,7 +616,7 @@ declare module 'events' { * Returns `true` if the event had listeners, `false` otherwise. * * ```js - * const EventEmitter = require('events'); + * import { EventEmitter } from 'node:events'; * const myEmitter = new EventEmitter(); * * // First listener @@ -572,11 +651,14 @@ declare module 'events' { */ emit(eventName: string | symbol, ...args: any[]): boolean; /** - * Returns the number of listeners listening to the event named `eventName`. + * Returns the number of listeners listening for the event named `eventName`. + * If `listener` is provided, it will return how many times the listener is found + * in the list of the listeners of the event. * @since v3.2.0 * @param eventName The name of the event being listened for + * @param listener The event handler function */ - listenerCount(eventName: string | symbol): number; + listenerCount(eventName: string | symbol, listener?: Function): number; /** * Adds the `listener` function to the _beginning_ of the listeners array for the * event named `eventName`. No checks are made to see if the `listener` has @@ -616,7 +698,8 @@ declare module 'events' { * listeners. The values in the array are strings or `Symbol`s. * * ```js - * const EventEmitter = require('events'); + * import { EventEmitter } from 'node:events'; + * * const myEE = new EventEmitter(); * myEE.on('foo', () => {}); * myEE.on('bar', () => {}); diff --git a/node_modules/@types/node/ts4.8/fs.d.ts b/node_modules/@types/node/ts4.8/fs.d.ts index 75c53fb0d..9ede55db9 100755 --- a/node_modules/@types/node/ts4.8/fs.d.ts +++ b/node_modules/@types/node/ts4.8/fs.d.ts @@ -1,22 +1,22 @@ /** - * The `fs` module enables interacting with the file system in a + * The `node:fs` module enables interacting with the file system in a * way modeled on standard POSIX functions. * * To use the promise-based APIs: * * ```js - * import * as fs from 'fs/promises'; + * import * as fs from 'node:fs/promises'; * ``` * * To use the callback and sync APIs: * * ```js - * import * as fs from 'fs'; + * import * as fs from 'node:fs'; * ``` * * All file system operations have synchronous, callback, and promise-based * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM). - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/fs.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/fs.js) */ declare module 'fs' { import * as stream from 'node:stream'; @@ -73,7 +73,7 @@ declare module 'fs' { /** * A `fs.Stats` object provides information about a file. * - * Objects returned from {@link stat}, {@link lstat} and {@link fstat} and + * Objects returned from {@link stat}, {@link lstat}, {@link fstat}, and * their synchronous counterparts are of this type. * If `bigint` in the `options` passed to those methods is true, the numeric values * will be `bigint` instead of `number`, and the object will contain additional @@ -131,6 +131,62 @@ declare module 'fs' { * @since v0.1.21 */ export class Stats {} + export interface StatsFsBase { + /** Type of file system. */ + type: T; + /** Optimal transfer block size. */ + bsize: T; + /** Total data blocks in file system. */ + blocks: T; + /** Free blocks in file system. */ + bfree: T; + /** Available blocks for unprivileged users */ + bavail: T; + /** Total file nodes in file system. */ + files: T; + /** Free file nodes in file system. */ + ffree: T; + } + export interface StatsFs extends StatsFsBase {} + /** + * Provides information about a mounted file system. + * + * Objects returned from {@link statfs} and its synchronous counterpart are of + * this type. If `bigint` in the `options` passed to those methods is `true`, the + * numeric values will be `bigint` instead of `number`. + * + * ```console + * StatFs { + * type: 1397114950, + * bsize: 4096, + * blocks: 121938943, + * bfree: 61058895, + * bavail: 61058895, + * files: 999, + * ffree: 1000000 + * } + * ``` + * + * `bigint` version: + * + * ```console + * StatFs { + * type: 1397114950n, + * bsize: 4096n, + * blocks: 121938943n, + * bfree: 61058895n, + * bavail: 61058895n, + * files: 999n, + * ffree: 1000000n + * } + * ``` + * @since v19.6.0, v18.15.0 + */ + export class StatsFs {} + export interface BigIntStatsFs extends StatsFsBase {} + export interface StatFsOptions { + bigint?: boolean | undefined; + } /** * A representation of a directory entry, which can be a file or a subdirectory * within the directory, as returned by reading from an `fs.Dir`. The @@ -184,6 +240,11 @@ declare module 'fs' { * @since v10.10.0 */ name: string; + /** + * The base path that this `fs.Dirent` object refers to. + * @since v20.1.0 + */ + path: string; } /** * A class representing a directory stream. @@ -191,7 +252,7 @@ declare module 'fs' { * Created by {@link opendir}, {@link opendirSync}, or `fsPromises.opendir()`. * * ```js - * import { opendir } from 'fs/promises'; + * import { opendir } from 'node:fs/promises'; * * try { * const dir = await opendir('./'); @@ -494,7 +555,7 @@ declare module 'fs' { * See also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html). * * ```js - * import { rename } from 'fs'; + * import { rename } from 'node:fs'; * * rename('oldFile.txt', 'newFile.txt', (err) => { * if (err) throw err; @@ -527,7 +588,7 @@ declare module 'fs' { * first argument. In this case, `fs.ftruncate()` is called. * * ```js - * import { truncate } from 'fs'; + * import { truncate } from 'node:fs'; * // Assuming that 'path/file.txt' is a regular file. * truncate('path/file.txt', (err) => { * if (err) throw err; @@ -579,7 +640,7 @@ declare module 'fs' { * file: * * ```js - * import { open, close, ftruncate } from 'fs'; + * import { open, close, ftruncate } from 'node:fs'; * * function closeFd(fd) { * close(fd, (err) => { @@ -736,7 +797,7 @@ declare module 'fs' { * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail. * * ```js - * import { chmod } from 'fs'; + * import { chmod } from 'node:fs'; * * chmod('my_file.txt', 0o775, (err) => { * if (err) throw err; @@ -818,7 +879,10 @@ declare module 'fs' { * * In case of an error, the `err.code` will be one of `Common System Errors`. * - * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. + * {@link stat} follows symbolic links. Use {@link lstat} to look at the + * links themselves. + * + * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. * Instead, user code should open/read/write the file directly and handle the * error raised if the file is not available. * @@ -835,7 +899,7 @@ declare module 'fs' { * The next program will check for the stats of the given paths: * * ```js - * import { stat } from 'fs'; + * import { stat } from 'node:fs'; * * const pathsToCheck = ['./txtDir', './txtDir/file.txt']; * @@ -1081,6 +1145,72 @@ declare module 'fs' { ): Promise; function __promisify__(path: PathLike, options?: StatOptions): Promise; } + /** + * Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which + * contains `path`. The callback gets two arguments `(err, stats)` where `stats`is an `fs.StatFs` object. + * + * In case of an error, the `err.code` will be one of `Common System Errors`. + * @since v19.6.0, v18.15.0 + * @param path A path to an existing file or directory on the file system to be queried. + */ + export function statfs(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void): void; + export function statfs( + path: PathLike, + options: + | (StatFsOptions & { + bigint?: false | undefined; + }) + | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void + ): void; + export function statfs( + path: PathLike, + options: StatFsOptions & { + bigint: true; + }, + callback: (err: NodeJS.ErrnoException | null, stats: BigIntStatsFs) => void + ): void; + export function statfs(path: PathLike, options: StatFsOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs | BigIntStatsFs) => void): void; + export namespace statfs { + /** + * Asynchronous statfs(2) - Returns information about the mounted file system which contains path. The callback gets two arguments (err, stats) where stats is an object. + * @param path A path to an existing file or directory on the file system to be queried. + */ + function __promisify__( + path: PathLike, + options?: StatFsOptions & { + bigint?: false | undefined; + } + ): Promise; + function __promisify__( + path: PathLike, + options: StatFsOptions & { + bigint: true; + } + ): Promise; + function __promisify__(path: PathLike, options?: StatFsOptions): Promise; + } + /** + * Synchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which + * contains `path`. + * + * In case of an error, the `err.code` will be one of `Common System Errors`. + * @since v19.6.0, v18.15.0 + * @param path A path to an existing file or directory on the file system to be queried. + */ + export function statfsSync( + path: PathLike, + options?: StatFsOptions & { + bigint?: false | undefined; + } + ): StatsFs; + export function statfsSync( + path: PathLike, + options: StatFsOptions & { + bigint: true; + } + ): BigIntStatsFs; + export function statfsSync(path: PathLike, options?: StatFsOptions): StatsFs | BigIntStatsFs; /** * Synchronous lstat(2) - Get file status. Does not dereference symbolic links. * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. @@ -1114,14 +1244,15 @@ declare module 'fs' { * * The `type` argument is only available on Windows and ignored on other platforms. * It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is - * not set, Node.js will autodetect `target` type and use `'file'` or `'dir'`. If - * the `target` does not exist, `'file'` will be used. Windows junction points - * require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path. + * not a string, Node.js will autodetect `target` type and use `'file'` or `'dir'`. + * If the `target` does not exist, `'file'` will be used. Windows junction points + * require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path. Junction + * points on NTFS volumes can only point to directories. * - * Relative targets are relative to the link’s parent directory. + * Relative targets are relative to the link's parent directory. * * ```js - * import { symlink } from 'fs'; + * import { symlink } from 'node:fs'; * * symlink('./mew', './mewtwo', callback); * ``` @@ -1136,6 +1267,7 @@ declare module 'fs' { * └── mewtwo -> ./mew * ``` * @since v0.1.31 + * @param [type='null'] */ export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void; /** @@ -1161,6 +1293,7 @@ declare module 'fs' { * For detailed information, see the documentation of the asynchronous version of * this API: {@link symlink}. * @since v0.1.31 + * @param [type='null'] */ export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void; /** @@ -1238,7 +1371,7 @@ declare module 'fs' { */ export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer; /** - * Asynchronously computes the canonical pathname by resolving `.`, `..` and + * Asynchronously computes the canonical pathname by resolving `.`, `..`, and * symbolic links. * * A canonical pathname is not necessarily unique. Hard links and bind mounts can @@ -1352,7 +1485,7 @@ declare module 'fs' { * possible exception are given to the completion callback. * * ```js - * import { unlink } from 'fs'; + * import { unlink } from 'node:fs'; * // Assuming that 'path/file.txt' is a regular file. * unlink('path/file.txt', (err) => { * if (err) throw err; @@ -1507,7 +1640,7 @@ declare module 'fs' { * when `recursive` is false. * * ```js - * import { mkdir } from 'fs'; + * import { mkdir } from 'node:fs'; * * // Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist. * mkdir('/tmp/a/apple', { recursive: true }, (err) => { @@ -1519,7 +1652,7 @@ declare module 'fs' { * result in an error: * * ```js - * import { mkdir } from 'fs'; + * import { mkdir } from 'node:fs'; * * mkdir('/', { recursive: true }, (err) => { * // => [Error: EPERM: operation not permitted, mkdir 'C:\'] @@ -1651,9 +1784,11 @@ declare module 'fs' { * object with an `encoding` property specifying the character encoding to use. * * ```js - * import { mkdtemp } from 'fs'; + * import { mkdtemp } from 'node:fs'; + * import { join } from 'node:path'; + * import { tmpdir } from 'node:os'; * - * mkdtemp(path.join(os.tmpdir(), 'foo-'), (err, directory) => { + * mkdtemp(join(tmpdir(), 'foo-'), (err, directory) => { * if (err) throw err; * console.log(directory); * // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2 @@ -1663,11 +1798,11 @@ declare module 'fs' { * The `fs.mkdtemp()` method will append the six randomly selected characters * directly to the `prefix` string. For instance, given a directory `/tmp`, if the * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator - * (`require('path').sep`). + * (`require('node:path').sep`). * * ```js - * import { tmpdir } from 'os'; - * import { mkdtemp } from 'fs'; + * import { tmpdir } from 'node:os'; + * import { mkdtemp } from 'node:fs'; * * // The parent directory for the new temporary directory * const tmpDir = tmpdir(); @@ -1682,7 +1817,7 @@ declare module 'fs' { * }); * * // This method is *CORRECT*: - * import { sep } from 'path'; + * import { sep } from 'node:path'; * mkdtemp(`${tmpDir}${sep}`, (err, directory) => { * if (err) throw err; * console.log(directory); @@ -1781,6 +1916,7 @@ declare module 'fs' { | { encoding: BufferEncoding | null; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | BufferEncoding | undefined @@ -1798,6 +1934,7 @@ declare module 'fs' { | { encoding: 'buffer'; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | 'buffer', callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void @@ -1812,6 +1949,7 @@ declare module 'fs' { options: | (ObjectEncodingOptions & { withFileTypes?: false | undefined; + recursive?: boolean | undefined; }) | BufferEncoding | undefined @@ -1832,6 +1970,7 @@ declare module 'fs' { path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true; + recursive?: boolean | undefined; }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void ): void; @@ -1847,6 +1986,7 @@ declare module 'fs' { | { encoding: BufferEncoding | null; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | BufferEncoding | null @@ -1863,6 +2003,7 @@ declare module 'fs' { | { encoding: 'buffer'; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } ): Promise; /** @@ -1875,6 +2016,7 @@ declare module 'fs' { options?: | (ObjectEncodingOptions & { withFileTypes?: false | undefined; + recursive?: boolean | undefined; }) | BufferEncoding | null @@ -1888,6 +2030,7 @@ declare module 'fs' { path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true; + recursive?: boolean | undefined; } ): Promise; } @@ -1910,6 +2053,7 @@ declare module 'fs' { | { encoding: BufferEncoding | null; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | BufferEncoding | null @@ -1925,6 +2069,7 @@ declare module 'fs' { | { encoding: 'buffer'; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | 'buffer' ): Buffer[]; @@ -1938,6 +2083,7 @@ declare module 'fs' { options?: | (ObjectEncodingOptions & { withFileTypes?: false | undefined; + recursive?: boolean | undefined; }) | BufferEncoding | null @@ -1951,6 +2097,7 @@ declare module 'fs' { path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true; + recursive?: boolean | undefined; } ): Dirent[]; /** @@ -2010,7 +2157,6 @@ declare module 'fs' { * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. */ export function open(path: PathLike, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; - export namespace open { /** * Asynchronous open(2) - open and possibly create a file. @@ -2035,7 +2181,7 @@ declare module 'fs' { * The `atime` and `mtime` arguments follow these rules: * * * Values can be either numbers representing Unix epoch time in seconds,`Date`s, or a numeric string like `'123456789.0'`. - * * If the value can not be converted to a number, or is `NaN`, `Infinity` or`-Infinity`, an `Error` will be thrown. + * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown. * @since v0.4.2 */ export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void; @@ -2121,6 +2267,9 @@ declare module 'fs' { * The kernel ignores the position argument and always appends the data to * the end of the file. * @since v0.0.2 + * @param [offset=0] + * @param [length=buffer.byteLength - offset] + * @param [position='null'] */ export function write( fd: number, @@ -2225,6 +2374,9 @@ declare module 'fs' { * For detailed information, see the documentation of the asynchronous version of * this API: {@link write}. * @since v0.1.21 + * @param [offset=0] + * @param [length=buffer.byteLength - offset] + * @param [position='null'] * @return The number of bytes written. */ export function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number; @@ -2330,6 +2482,7 @@ declare module 'fs' { * For detailed information, see the documentation of the asynchronous version of * this API: {@link read}. * @since v0.1.21 + * @param [position='null'] */ export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: ReadPosition | null): number; /** @@ -2341,7 +2494,7 @@ declare module 'fs' { * Asynchronously reads the entire contents of a file. * * ```js - * import { readFile } from 'fs'; + * import { readFile } from 'node:fs'; * * readFile('/etc/passwd', (err, data) => { * if (err) throw err; @@ -2357,7 +2510,7 @@ declare module 'fs' { * If `options` is a string, then it specifies the encoding: * * ```js - * import { readFile } from 'fs'; + * import { readFile } from 'node:fs'; * * readFile('/etc/passwd', 'utf8', callback); * ``` @@ -2367,7 +2520,7 @@ declare module 'fs' { * will be returned. * * ```js - * import { readFile } from 'fs'; + * import { readFile } from 'node:fs'; * * // macOS, Linux, and Windows * readFile('', (err, data) => { @@ -2384,7 +2537,7 @@ declare module 'fs' { * request is aborted the callback is called with an `AbortError`: * * ```js - * import { readFile } from 'fs'; + * import { readFile } from 'node:fs'; * * const controller = new AbortController(); * const signal = controller.signal; @@ -2517,7 +2670,7 @@ declare module 'fs' { * Similar to {@link readFile}, when the path is a directory, the behavior of`fs.readFileSync()` is platform-specific. * * ```js - * import { readFileSync } from 'fs'; + * import { readFileSync } from 'node:fs'; * * // macOS, Linux, and Windows * readFileSync(''); @@ -2588,8 +2741,8 @@ declare module 'fs' { * The `mode` option only affects the newly created file. See {@link open} for more details. * * ```js - * import { writeFile } from 'fs'; - * import { Buffer } from 'buffer'; + * import { writeFile } from 'node:fs'; + * import { Buffer } from 'node:buffer'; * * const data = new Uint8Array(Buffer.from('Hello Node.js')); * writeFile('message.txt', data, (err) => { @@ -2601,7 +2754,7 @@ declare module 'fs' { * If `options` is a string, then it specifies the encoding: * * ```js - * import { writeFile } from 'fs'; + * import { writeFile } from 'node:fs'; * * writeFile('message.txt', 'Hello Node.js', 'utf8', callback); * ``` @@ -2619,8 +2772,8 @@ declare module 'fs' { * to be written. * * ```js - * import { writeFile } from 'fs'; - * import { Buffer } from 'buffer'; + * import { writeFile } from 'node:fs'; + * import { Buffer } from 'node:buffer'; * * const controller = new AbortController(); * const { signal } = controller; @@ -2678,7 +2831,7 @@ declare module 'fs' { * The `mode` option only affects the newly created file. See {@link open} for more details. * * ```js - * import { appendFile } from 'fs'; + * import { appendFile } from 'node:fs'; * * appendFile('message.txt', 'data to append', (err) => { * if (err) throw err; @@ -2689,7 +2842,7 @@ declare module 'fs' { * If `options` is a string, then it specifies the encoding: * * ```js - * import { appendFile } from 'fs'; + * import { appendFile } from 'node:fs'; * * appendFile('message.txt', 'data to append', 'utf8', callback); * ``` @@ -2699,7 +2852,7 @@ declare module 'fs' { * not be closed automatically. * * ```js - * import { open, close, appendFile } from 'fs'; + * import { open, close, appendFile } from 'node:fs'; * * function closeFd(fd) { * close(fd, (err) => { @@ -2754,7 +2907,7 @@ declare module 'fs' { * The `mode` option only affects the newly created file. See {@link open} for more details. * * ```js - * import { appendFileSync } from 'fs'; + * import { appendFileSync } from 'node:fs'; * * try { * appendFileSync('message.txt', 'data to append'); @@ -2767,7 +2920,7 @@ declare module 'fs' { * If `options` is a string, then it specifies the encoding: * * ```js - * import { appendFileSync } from 'fs'; + * import { appendFileSync } from 'node:fs'; * * appendFileSync('message.txt', 'data to append', 'utf8'); * ``` @@ -2777,7 +2930,7 @@ declare module 'fs' { * not be closed automatically. * * ```js - * import { openSync, closeSync, appendFileSync } from 'fs'; + * import { openSync, closeSync, appendFileSync } from 'node:fs'; * * let fd; * @@ -2859,7 +3012,7 @@ declare module 'fs' { * stat object: * * ```js - * import { watchFile } from 'fs'; + * import { watchFile } from 'node:fs'; * * watchFile('message.text', (curr, prev) => { * console.log(`the current mtime is: ${curr.mtime}`); @@ -2899,7 +3052,7 @@ declare module 'fs' { bigint?: false | undefined; }) | undefined, - listener: (curr: Stats, prev: Stats) => void + listener: StatsListener ): StatWatcher; export function watchFile( filename: PathLike, @@ -2908,13 +3061,13 @@ declare module 'fs' { bigint: true; }) | undefined, - listener: (curr: BigIntStats, prev: BigIntStats) => void + listener: BigIntStatsListener ): StatWatcher; /** * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed. * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. */ - export function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): StatWatcher; + export function watchFile(filename: PathLike, listener: StatsListener): StatWatcher; /** * Stop watching for changes on `filename`. If `listener` is specified, only that * particular listener is removed. Otherwise, _all_ listeners are removed, @@ -2927,7 +3080,8 @@ declare module 'fs' { * @since v0.1.31 * @param listener Optional, a listener previously attached using `fs.watchFile()` */ - export function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void; + export function unwatchFile(filename: PathLike, listener?: StatsListener): void; + export function unwatchFile(filename: PathLike, listener?: BigIntStatsListener): void; export interface WatchOptions extends Abortable { encoding?: BufferEncoding | 'buffer' | undefined; persistent?: boolean | undefined; @@ -2935,6 +3089,8 @@ declare module 'fs' { } export type WatchEventType = 'rename' | 'change'; export type WatchListener = (event: WatchEventType, filename: T) => void; + export type StatsListener = (curr: Stats, prev: Stats) => void; + export type BigIntStatsListener = (curr: BigIntStats, prev: BigIntStats) => void; /** * Watch for changes on `filename`, where `filename` is either a file or a * directory. @@ -2992,7 +3148,7 @@ declare module 'fs' { * Then call the `callback` argument with either true or false: * * ```js - * import { exists } from 'fs'; + * import { exists } from 'node:fs'; * * exists('/etc/passwd', (e) => { * console.log(e ? 'it exists' : 'no passwd!'); @@ -3004,7 +3160,7 @@ declare module 'fs' { * has only one boolean parameter. This is one reason `fs.access()` is recommended * instead of `fs.exists()`. * - * Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. Doing + * Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. Doing * so introduces a race condition, since other processes may change the file's * state between the two calls. Instead, user code should open/read/write the * file directly and handle the error raised if the file does not exist. @@ -3012,7 +3168,7 @@ declare module 'fs' { * **write (NOT RECOMMENDED)** * * ```js - * import { exists, open, close } from 'fs'; + * import { exists, open, close } from 'node:fs'; * * exists('myfile', (e) => { * if (e) { @@ -3036,7 +3192,7 @@ declare module 'fs' { * **write (RECOMMENDED)** * * ```js - * import { open, close } from 'fs'; + * import { open, close } from 'node:fs'; * open('myfile', 'wx', (err, fd) => { * if (err) { * if (err.code === 'EEXIST') { @@ -3060,7 +3216,7 @@ declare module 'fs' { * **read (NOT RECOMMENDED)** * * ```js - * import { open, close, exists } from 'fs'; + * import { open, close, exists } from 'node:fs'; * * exists('myfile', (e) => { * if (e) { @@ -3084,7 +3240,7 @@ declare module 'fs' { * **read (RECOMMENDED)** * * ```js - * import { open, close } from 'fs'; + * import { open, close } from 'node:fs'; * * open('myfile', 'r', (err, fd) => { * if (err) { @@ -3110,7 +3266,7 @@ declare module 'fs' { * file; the "recommended" examples are better because they use the file directly * and handle the error, if any. * - * In general, check for the existence of a file only if the file won’t be + * In general, check for the existence of a file only if the file won't be * used directly, for example when its existence is a signal from another * process. * @since v0.0.2 @@ -3135,7 +3291,7 @@ declare module 'fs' { * Node.js callbacks. `fs.existsSync()` does not use a callback. * * ```js - * import { existsSync } from 'fs'; + * import { existsSync } from 'node:fs'; * * if (existsSync('/etc/passwd')) * console.log('The path exists.'); @@ -3269,7 +3425,7 @@ declare module 'fs' { * argument will be an `Error` object. The following examples check if`package.json` exists, and if it is readable or writable. * * ```js - * import { access, constants } from 'fs'; + * import { access, constants } from 'node:fs'; * * const file = 'package.json'; * @@ -3294,7 +3450,7 @@ declare module 'fs' { * }); * ``` * - * Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()`. Doing + * Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()`. Doing * so introduces a race condition, since other processes may change the file's * state between the two calls. Instead, user code should open/read/write the * file directly and handle the error raised if the file is not accessible. @@ -3302,7 +3458,7 @@ declare module 'fs' { * **write (NOT RECOMMENDED)** * * ```js - * import { access, open, close } from 'fs'; + * import { access, open, close } from 'node:fs'; * * access('myfile', (err) => { * if (!err) { @@ -3327,7 +3483,7 @@ declare module 'fs' { * **write (RECOMMENDED)** * * ```js - * import { open, close } from 'fs'; + * import { open, close } from 'node:fs'; * * open('myfile', 'wx', (err, fd) => { * if (err) { @@ -3352,7 +3508,7 @@ declare module 'fs' { * **read (NOT RECOMMENDED)** * * ```js - * import { access, open, close } from 'fs'; + * import { access, open, close } from 'node:fs'; * access('myfile', (err) => { * if (err) { * if (err.code === 'ENOENT') { @@ -3380,7 +3536,7 @@ declare module 'fs' { * **read (RECOMMENDED)** * * ```js - * import { open, close } from 'fs'; + * import { open, close } from 'node:fs'; * * open('myfile', 'r', (err, fd) => { * if (err) { @@ -3442,7 +3598,7 @@ declare module 'fs' { * the method will return `undefined`. * * ```js - * import { accessSync, constants } from 'fs'; + * import { accessSync, constants } from 'node:fs'; * * try { * accessSync('etc/passwd', constants.R_OK | constants.W_OK); @@ -3472,8 +3628,8 @@ declare module 'fs' { end?: number | undefined; } /** - * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream - * returned by this method has a default `highWaterMark` of 64 kb. + * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream + * returned by this method has a default `highWaterMark` of 64 KiB. * * `options` can include `start` and `end` values to read a range of bytes from * the file instead of the entire file. Both `start` and `end` are inclusive and @@ -3499,7 +3655,7 @@ declare module 'fs' { * also required. * * ```js - * import { createReadStream } from 'fs'; + * import { createReadStream } from 'node:fs'; * * // Create a stream from some character device. * const stream = createReadStream('/dev/input/event0'); @@ -3527,7 +3683,7 @@ declare module 'fs' { * An example to read the last 10 bytes of a file which is 100 bytes long: * * ```js - * import { createReadStream } from 'fs'; + * import { createReadStream } from 'node:fs'; * * createReadStream('sample.txt', { start: 90, end: 99 }); * ``` @@ -3551,7 +3707,7 @@ declare module 'fs' { * By default, the stream will emit a `'close'` event after it has been * destroyed. Set the `emitClose` option to `false` to change this behavior. * - * By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev` and `close`. Overriding `write()`without `writev()` can reduce + * By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev`, and `close`. Overriding `write()`without `writev()` can reduce * performance as some optimizations (`_writev()`) * will be disabled. When providing the `fs` option, overrides for at least one of`write` and `writev` are required. If no `fd` option is supplied, an override * for `open` is also required. If `autoClose` is `true`, an override for `close`is also required. @@ -3606,7 +3762,7 @@ declare module 'fs' { * copy-on-write, then the operation will fail. * * ```js - * import { copyFile, constants } from 'fs'; + * import { copyFile, constants } from 'node:fs'; * * function callback(err) { * if (err) throw err; @@ -3649,7 +3805,7 @@ declare module 'fs' { * copy-on-write, then the operation will fail. * * ```js - * import { copyFileSync, constants } from 'fs'; + * import { copyFileSync, constants } from 'node:fs'; * * // destination.txt will be created or overwritten by default. * copyFileSync('source.txt', 'destination.txt'); @@ -3682,6 +3838,7 @@ declare module 'fs' { * The kernel ignores the position argument and always appends the data to * the end of the file. * @since v12.9.0 + * @param [position='null'] */ export function writev(fd: number, buffers: ReadonlyArray, cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void; export function writev( @@ -3701,6 +3858,7 @@ declare module 'fs' { * For detailed information, see the documentation of the asynchronous version of * this API: {@link writev}. * @since v12.9.0 + * @param [position='null'] * @return The number of bytes written. */ export function writevSync(fd: number, buffers: ReadonlyArray, position?: number): number; @@ -3717,6 +3875,7 @@ declare module 'fs' { * If this method is invoked as its `util.promisify()` ed version, it returns * a promise for an `Object` with `bytesRead` and `buffers` properties. * @since v13.13.0, v12.17.0 + * @param [position='null'] */ export function readv(fd: number, buffers: ReadonlyArray, cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void): void; export function readv( @@ -3736,10 +3895,14 @@ declare module 'fs' { * For detailed information, see the documentation of the asynchronous version of * this API: {@link readv}. * @since v13.13.0, v12.17.0 + * @param [position='null'] * @return The number of bytes read. */ export function readvSync(fd: number, buffers: ReadonlyArray, position?: number): number; export interface OpenDirOptions { + /** + * @default 'utf8' + */ encoding?: BufferEncoding | undefined; /** * Number of directory entries that are buffered @@ -3748,6 +3911,10 @@ declare module 'fs' { * @default 32 */ bufferSize?: number | undefined; + /** + * @default false + */ + recursive?: boolean; } /** * Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html). @@ -3810,6 +3977,10 @@ declare module 'fs' { * @default true */ force?: boolean; + /** + * Modifiers for copy operation. See `mode` flag of {@link copyFileSync()} + */ + mode?: number; /** * When `true` timestamps from `src` will * be preserved. diff --git a/node_modules/@types/node/ts4.8/fs/promises.d.ts b/node_modules/@types/node/ts4.8/fs/promises.d.ts index 9d0b5f109..a06968b70 100755 --- a/node_modules/@types/node/ts4.8/fs/promises.d.ts +++ b/node_modules/@types/node/ts4.8/fs/promises.d.ts @@ -14,6 +14,7 @@ declare module 'fs/promises' { import { ReadableStream } from 'node:stream/web'; import { BigIntStats, + BigIntStatsFs, BufferEncodingOption, constants as fsConstants, CopyOptions, @@ -30,14 +31,16 @@ declare module 'fs/promises' { RmDirOptions, RmOptions, StatOptions, + StatFsOptions, Stats, + StatsFs, TimeLike, WatchEventType, WatchOptions, WriteStream, WriteVResult, } from 'node:fs'; - + import { Interface as ReadlineInterface } from 'node:readline'; interface FileChangeInfo { eventType: WatchEventType; filename: T; @@ -111,8 +114,8 @@ declare module 'fs/promises' { */ chmod(mode: Mode): Promise; /** - * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream - * returned by this method has a default `highWaterMark` of 64 kb. + * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream + * returned by this method has a default `highWaterMark` of 64 KiB. * * `options` can include `start` and `end` values to read a range of bytes from * the file instead of the entire file. Both `start` and `end` are inclusive and @@ -130,7 +133,7 @@ declare module 'fs/promises' { * destroyed. Set the `emitClose` option to `false` to change this behavior. * * ```js - * import { open } from 'fs/promises'; + * import { open } from 'node:fs/promises'; * * const fd = await open('/dev/input/event0'); * // Create a stream from some character device. @@ -156,7 +159,7 @@ declare module 'fs/promises' { * An example to read the last 10 bytes of a file which is 100 bytes long: * * ```js - * import { open } from 'fs/promises'; + * import { open } from 'node:fs/promises'; * * const fd = await open('sample.txt'); * fd.createReadStream({ start: 90, end: 99 }); @@ -195,7 +198,7 @@ declare module 'fs/promises' { * device. The specific implementation is operating system and device specific. * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. * @since v10.0.0 - * @return Fufills with `undefined` upon success. + * @return Fulfills with `undefined` upon success. */ sync(): Promise; /** @@ -216,11 +219,13 @@ declare module 'fs/promises' { /** * Returns a `ReadableStream` that may be used to read the files data. * - * An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed - * or closing. + * An error will be thrown if this method is called more than once or is called + * after the `FileHandle` is closed or closing. * * ```js - * import { open } from 'node:fs/promises'; + * import { + * open, + * } from 'node:fs/promises'; * * const file = await open('./some/file/to/read'); * @@ -230,8 +235,8 @@ declare module 'fs/promises' { * await file.close(); * ``` * - * While the `ReadableStream` will read the file to completion, it will not close the `FileHandle` automatically. User code must still call the `fileHandle.close()` method. - * + * While the `ReadableStream` will read the file to completion, it will not + * close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method. * @since v17.0.0 * @experimental */ @@ -284,6 +289,22 @@ declare module 'fs/promises' { | BufferEncoding | null ): Promise; + /** + * Convenience method to create a `readline` interface and stream over the file. + * See `filehandle.createReadStream()` for the options. + * + * ```js + * import { open } from 'node:fs/promises'; + * + * const file = await open('./some/file/to/read'); + * + * for await (const line of file.readLines()) { + * console.log(line); + * } + * ``` + * @since v18.11.0 + */ + readLines(options?: CreateReadStreamOptions): ReadlineInterface; /** * @since v10.0.0 * @return Fulfills with an {fs.Stats} for the file. @@ -308,7 +329,7 @@ declare module 'fs/promises' { * The following example retains only the first four bytes of the file: * * ```js - * import { open } from 'fs/promises'; + * import { open } from 'node:fs/promises'; * * let filehandle = null; * try { @@ -335,7 +356,7 @@ declare module 'fs/promises' { utimes(atime: TimeLike, mtime: TimeLike): Promise; /** * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an - * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or + * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object. * The promise is resolved with no arguments upon success. * @@ -365,10 +386,10 @@ declare module 'fs/promises' { * The kernel ignores the position argument and always appends the data to * the end of the file. * @since v10.0.0 - * @param [offset=0] The start position from within `buffer` where the data to write begins. + * @param offset The start position from within `buffer` where the data to write begins. * @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write. - * @param position The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current position. - * See the POSIX pwrite(2) documentation for more detail. + * @param [position='null'] The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current + * position. See the POSIX pwrite(2) documentation for more detail. */ write( buffer: TBuffer, @@ -399,14 +420,14 @@ declare module 'fs/promises' { * The kernel ignores the position argument and always appends the data to * the end of the file. * @since v12.9.0 - * @param position The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current + * @param [position='null'] The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current * position. */ writev(buffers: ReadonlyArray, position?: number): Promise; /** * Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s * @since v13.13.0, v12.17.0 - * @param position The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position. + * @param [position='null'] The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position. * @return Fulfills upon success an object containing two properties: */ readv(buffers: ReadonlyArray, position?: number): Promise; @@ -415,7 +436,7 @@ declare module 'fs/promises' { * complete. * * ```js - * import { open } from 'fs/promises'; + * import { open } from 'node:fs/promises'; * * let filehandle; * try { @@ -429,9 +450,7 @@ declare module 'fs/promises' { */ close(): Promise; } - const constants: typeof fsConstants; - /** * Tests a user's permissions for the file or directory specified by `path`. * The `mode` argument is an optional integer that specifies the accessibility @@ -445,8 +464,7 @@ declare module 'fs/promises' { * written by the current process. * * ```js - * import { access } from 'fs/promises'; - * import { constants } from 'fs'; + * import { access, constants } from 'node:fs/promises'; * * try { * await access('/etc/passwd', constants.R_OK | constants.W_OK); @@ -475,14 +493,13 @@ declare module 'fs/promises' { * will be made to remove the destination. * * ```js - * import { constants } from 'fs'; - * import { copyFile } from 'fs/promises'; + * import { copyFile, constants } from 'node:fs/promises'; * * try { * await copyFile('source.txt', 'destination.txt'); * console.log('source.txt was copied to destination.txt'); * } catch { - * console.log('The file could not be copied'); + * console.error('The file could not be copied'); * } * * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists. @@ -490,7 +507,7 @@ declare module 'fs/promises' { * await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL); * console.log('source.txt was copied to destination.txt'); * } catch { - * console.log('The file could not be copied'); + * console.error('The file could not be copied'); * } * ``` * @since v10.0.0 @@ -552,6 +569,19 @@ declare module 'fs/promises' { * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fsPromises.mkdir()` when `path` is a directory * that exists results in a * rejection only when `recursive` is false. + * + * ```js + * import { mkdir } from 'node:fs/promises'; + * + * try { + * const projectFolder = new URL('./test/project/', import.meta.url); + * const createDir = await mkdir(projectFolder, { recursive: true }); + * + * console.log(`created ${createDir}`); + * } catch (err) { + * console.error(err.message); + * } + * ``` * @since v10.0.0 * @return Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`. */ @@ -594,7 +624,7 @@ declare module 'fs/promises' { * If `options.withFileTypes` is set to `true`, the resolved array will contain `fs.Dirent` objects. * * ```js - * import { readdir } from 'fs/promises'; + * import { readdir } from 'node:fs/promises'; * * try { * const files = await readdir(path); @@ -612,6 +642,7 @@ declare module 'fs/promises' { options?: | (ObjectEncodingOptions & { withFileTypes?: false | undefined; + recursive?: boolean | undefined; }) | BufferEncoding | null @@ -627,6 +658,7 @@ declare module 'fs/promises' { | { encoding: 'buffer'; withFileTypes?: false | undefined; + recursive?: boolean | undefined; } | 'buffer' ): Promise; @@ -640,6 +672,7 @@ declare module 'fs/promises' { options?: | (ObjectEncodingOptions & { withFileTypes?: false | undefined; + recursive?: boolean | undefined; }) | BufferEncoding | null @@ -653,6 +686,7 @@ declare module 'fs/promises' { path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true; + recursive?: boolean | undefined; } ): Promise; /** @@ -682,11 +716,13 @@ declare module 'fs/promises' { /** * Creates a symbolic link. * - * The `type` argument is only used on Windows platforms and can be one of `'dir'`,`'file'`, or `'junction'`. Windows junction points require the destination path - * to be absolute. When using `'junction'`, the `target` argument will + * The `type` argument is only used on Windows platforms and can be one of `'dir'`,`'file'`, or `'junction'`. If the `type` argument is not a string, Node.js will + * autodetect `target` type and use `'file'` or `'dir'`. If the `target` does not + * exist, `'file'` will be used. Windows junction points require the destination + * path to be absolute. When using `'junction'`, the `target` argument will * automatically be normalized to absolute path. * @since v10.0.0 - * @param [type='file'] + * @param [type='null'] * @return Fulfills with `undefined` upon success. */ function symlink(target: PathLike, path: PathLike, type?: string | null): Promise; @@ -727,6 +763,23 @@ declare module 'fs/promises' { } ): Promise; function stat(path: PathLike, opts?: StatOptions): Promise; + /** + * @since v19.6.0, v18.15.0 + * @return Fulfills with the {fs.StatFs} object for the given `path`. + */ + function statfs( + path: PathLike, + opts?: StatFsOptions & { + bigint?: false | undefined; + } + ): Promise; + function statfs( + path: PathLike, + opts: StatFsOptions & { + bigint: true; + } + ): Promise; + function statfs(path: PathLike, opts?: StatFsOptions): Promise; /** * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. * @since v10.0.0 @@ -782,7 +835,7 @@ declare module 'fs/promises' { * * * Values can be either numbers representing Unix epoch time, `Date`s, or a * numeric string like `'123456789.0'`. - * * If the value can not be converted to a number, or is `NaN`, `Infinity` or`-Infinity`, an `Error` will be thrown. + * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown. * @since v10.0.0 * @return Fulfills with `undefined` upon success. */ @@ -827,10 +880,12 @@ declare module 'fs/promises' { * object with an `encoding` property specifying the character encoding to use. * * ```js - * import { mkdtemp } from 'fs/promises'; + * import { mkdtemp } from 'node:fs/promises'; + * import { join } from 'node:path'; + * import { tmpdir } from 'node:os'; * * try { - * await mkdtemp(path.join(os.tmpdir(), 'foo-')); + * await mkdtemp(join(tmpdir(), 'foo-')); * } catch (err) { * console.error(err); * } @@ -839,9 +894,9 @@ declare module 'fs/promises' { * The `fsPromises.mkdtemp()` method will append the six randomly selected * characters directly to the `prefix` string. For instance, given a directory`/tmp`, if the intention is to create a temporary directory _within_`/tmp`, the`prefix` must end with a trailing * platform-specific path separator - * (`require('path').sep`). + * (`require('node:path').sep`). * @since v10.0.0 - * @return Fulfills with a string containing the filesystem path of the newly created temporary directory. + * @return Fulfills with a string containing the file system path of the newly created temporary directory. */ function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; /** @@ -858,7 +913,7 @@ declare module 'fs/promises' { function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; /** * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an - * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or + * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object. * * The `encoding` option is ignored if `data` is a buffer. @@ -881,8 +936,8 @@ declare module 'fs/promises' { * to be written. * * ```js - * import { writeFile } from 'fs/promises'; - * import { Buffer } from 'buffer'; + * import { writeFile } from 'node:fs/promises'; + * import { Buffer } from 'node:buffer'; * * try { * const controller = new AbortController(); @@ -945,11 +1000,25 @@ declare module 'fs/promises' { * with an error. On FreeBSD, a representation of the directory's contents will be * returned. * + * An example of reading a `package.json` file located in the same directory of the + * running code: + * + * ```js + * import { readFile } from 'node:fs/promises'; + * try { + * const filePath = new URL('./package.json', import.meta.url); + * const contents = await readFile(filePath, { encoding: 'utf8' }); + * console.log(contents); + * } catch (err) { + * console.error(err.message); + * } + * ``` + * * It is possible to abort an ongoing `readFile` using an `AbortSignal`. If a * request is aborted the promise returned is rejected with an `AbortError`: * * ```js - * import { readFile } from 'fs/promises'; + * import { readFile } from 'node:fs/promises'; * * try { * const controller = new AbortController(); @@ -1028,7 +1097,7 @@ declare module 'fs/promises' { * Example using async iteration: * * ```js - * import { opendir } from 'fs/promises'; + * import { opendir } from 'node:fs/promises'; * * try { * const dir = await opendir('./'); @@ -1049,7 +1118,7 @@ declare module 'fs/promises' { * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory. * * ```js - * const { watch } = require('fs/promises'); + * const { watch } = require('node:fs/promises'); * * const ac = new AbortController(); * const { signal } = ac; diff --git a/node_modules/@types/node/ts4.8/globals.d.ts b/node_modules/@types/node/ts4.8/globals.d.ts index da499940e..7414561da 100755 --- a/node_modules/@types/node/ts4.8/globals.d.ts +++ b/node_modules/@types/node/ts4.8/globals.d.ts @@ -53,27 +53,35 @@ interface AbortController { /** * Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted. */ - abort(): void; + abort(reason?: any): void; } /** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */ -interface AbortSignal { +interface AbortSignal extends EventTarget { /** * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */ readonly aborted: boolean; + readonly reason: any; + onabort: null | ((this: AbortSignal, event: Event) => any); + throwIfAborted(): void; } -declare var AbortController: { - prototype: AbortController; - new(): AbortController; -}; - -declare var AbortSignal: { - prototype: AbortSignal; - new(): AbortSignal; - // TODO: Add abort() static -}; +declare var AbortController: typeof globalThis extends {onmessage: any; AbortController: infer T} + ? T + : { + prototype: AbortController; + new(): AbortController; + }; + +declare var AbortSignal: typeof globalThis extends {onmessage: any; AbortSignal: infer T} + ? T + : { + prototype: AbortSignal; + new(): AbortSignal; + abort(reason?: any): AbortSignal; + timeout(milliseconds: number): AbortSignal; + }; //#endregion borrowed //#region ArrayLike.at() @@ -87,6 +95,7 @@ interface RelativeIndexable { } interface String extends RelativeIndexable {} interface Array extends RelativeIndexable {} +interface ReadonlyArray extends RelativeIndexable {} interface Int8Array extends RelativeIndexable {} interface Uint8Array extends RelativeIndexable {} interface Uint8ClampedArray extends RelativeIndexable {} @@ -151,7 +160,7 @@ declare namespace NodeJS { /** * Name of the script [if this function was defined in a script] */ - getFileName(): string | null; + getFileName(): string | undefined; /** * Current line number [if this function was defined in a script] diff --git a/node_modules/@types/node/ts4.8/http.d.ts b/node_modules/@types/node/ts4.8/http.d.ts index 24bc5e78d..cb5033575 100755 --- a/node_modules/@types/node/ts4.8/http.d.ts +++ b/node_modules/@types/node/ts4.8/http.d.ts @@ -1,5 +1,5 @@ /** - * To use the HTTP server and client one must `require('http')`. + * To use the HTTP server and client one must `require('node:http')`. * * The HTTP interfaces in Node.js are designed to support many features * of the protocol which have been traditionally difficult to use. @@ -37,11 +37,13 @@ * 'Host', 'example.com', * 'accepT', '*' ] * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http.js) */ declare module 'http' { import * as stream from 'node:stream'; import { URL } from 'node:url'; + import { LookupOptions } from 'node:dns'; + import { EventEmitter } from 'node:events'; import { TcpSocketConnectOpts, Socket, Server as NetServer, LookupFunction } from 'node:net'; // incoming headers will never contain number interface IncomingHttpHeaders extends NodeJS.Dict { @@ -113,56 +115,101 @@ declare module 'http' { type OutgoingHttpHeader = number | string | string[]; interface OutgoingHttpHeaders extends NodeJS.Dict {} interface ClientRequestArgs { - signal?: AbortSignal | undefined; - protocol?: string | null | undefined; + _defaultAgent?: Agent | undefined; + agent?: Agent | boolean | undefined; + auth?: string | null | undefined; + // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278 + createConnection?: + | ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket) + | undefined; + defaultPort?: number | string | undefined; + family?: number | undefined; + headers?: OutgoingHttpHeaders | undefined; + hints?: LookupOptions['hints']; host?: string | null | undefined; hostname?: string | null | undefined; - family?: number | undefined; - port?: number | string | null | undefined; - defaultPort?: number | string | undefined; + insecureHTTPParser?: boolean | undefined; localAddress?: string | undefined; - socketPath?: string | undefined; + localPort?: number | undefined; + lookup?: LookupFunction | undefined; /** - * @default 8192 + * @default 16384 */ maxHeaderSize?: number | undefined; method?: string | undefined; path?: string | null | undefined; - headers?: OutgoingHttpHeaders | undefined; - auth?: string | null | undefined; - agent?: Agent | boolean | undefined; - _defaultAgent?: Agent | undefined; - timeout?: number | undefined; + port?: number | string | null | undefined; + protocol?: string | null | undefined; setHost?: boolean | undefined; - // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278 - createConnection?: - | ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket) - | undefined; - lookup?: LookupFunction | undefined; + signal?: AbortSignal | undefined; + socketPath?: string | undefined; + timeout?: number | undefined; + uniqueHeaders?: Array | undefined; + joinDuplicateHeaders?: boolean; } interface ServerOptions< Request extends typeof IncomingMessage = typeof IncomingMessage, Response extends typeof ServerResponse = typeof ServerResponse, > { + /** + * Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`. + */ IncomingMessage?: Request | undefined; + /** + * Specifies the `ServerResponse` class to be used. Useful for extending the original `ServerResponse`. + */ ServerResponse?: Response | undefined; /** - * Optionally overrides the value of - * `--max-http-header-size` for requests received by this server, i.e. - * the maximum length of request headers in bytes. - * @default 8192 + * Sets the timeout value in milliseconds for receiving the entire request from the client. + * @see Server.requestTimeout for more information. + * @default 300000 + * @since v18.0.0 */ - maxHeaderSize?: number | undefined; + requestTimeout?: number | undefined; + /** + * It joins the field line values of multiple headers in a request with `, ` instead of discarding the duplicates. + * @default false + * @since v18.14.0 + */ + joinDuplicateHeaders?: boolean; + /** + * The number of milliseconds of inactivity a server needs to wait for additional incoming data, + * after it has finished writing the last response, before a socket will be destroyed. + * @see Server.keepAliveTimeout for more information. + * @default 5000 + * @since v18.0.0 + */ + keepAliveTimeout?: number | undefined; + /** + * Sets the interval value in milliseconds to check for request and headers timeout in incomplete requests. + * @default 30000 + */ + connectionsCheckingInterval?: number | undefined; + /** + * Optionally overrides all `socket`s' `readableHighWaterMark` and `writableHighWaterMark`. + * This affects `highWaterMark` property of both `IncomingMessage` and `ServerResponse`. + * Default: @see stream.getDefaultHighWaterMark(). + * @since v20.1.0 + */ + highWaterMark?: number | undefined; /** - * Use an insecure HTTP parser that accepts invalid HTTP headers when true. + * Use an insecure HTTP parser that accepts invalid HTTP headers when `true`. * Using the insecure parser should be avoided. * See --insecure-http-parser for more information. * @default false */ insecureHTTPParser?: boolean | undefined; + /** + * Optionally overrides the value of + * `--max-http-header-size` for requests received by this server, i.e. + * the maximum length of request headers in bytes. + * @default 16384 + * @since v13.3.0 + */ + maxHeaderSize?: number | undefined; /** * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received. - * @default false + * @default true * @since v16.5.0 */ noDelay?: boolean | undefined; @@ -179,6 +226,11 @@ declare module 'http' { * @since v16.5.0 */ keepAliveInitialDelay?: number | undefined; + /** + * A list of response headers that should be sent only once. + * If the header's value is an array, the items will be joined using `; `. + */ + uniqueHeaders?: Array | undefined; } type RequestListener< Request extends typeof IncomingMessage = typeof IncomingMessage, @@ -285,7 +337,8 @@ declare module 'http' { */ closeAllConnections(): void; /** - * Closes all connections connected to this server which are not sending a request or waiting for a response. + * Closes all connections connected to this server which are not sending a request + * or waiting for a response. * @since v18.2.0 */ closeIdleConnections(): void; @@ -297,15 +350,10 @@ declare module 'http' { addListener(event: 'checkContinue', listener: RequestListener): this; addListener(event: 'checkExpectation', listener: RequestListener): this; addListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this; - addListener( - event: 'connect', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + addListener(event: 'connect', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + addListener(event: 'dropRequest', listener: (req: InstanceType, socket: stream.Duplex) => void): this; addListener(event: 'request', listener: RequestListener): this; - addListener( - event: 'upgrade', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + addListener(event: 'upgrade', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; emit(event: string, ...args: any[]): boolean; emit(event: 'close'): boolean; emit(event: 'connection', socket: Socket): boolean; @@ -323,6 +371,7 @@ declare module 'http' { ): boolean; emit(event: 'clientError', err: Error, socket: stream.Duplex): boolean; emit(event: 'connect', req: InstanceType, socket: stream.Duplex, head: Buffer): boolean; + emit(event: 'dropRequest', req: InstanceType, socket: stream.Duplex): boolean; emit( event: 'request', req: InstanceType, @@ -338,6 +387,7 @@ declare module 'http' { on(event: 'checkExpectation', listener: RequestListener): this; on(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this; on(event: 'connect', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + on(event: 'dropRequest', listener: (req: InstanceType, socket: stream.Duplex) => void): this; on(event: 'request', listener: RequestListener): this; on(event: 'upgrade', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; once(event: string, listener: (...args: any[]) => void): this; @@ -348,15 +398,10 @@ declare module 'http' { once(event: 'checkContinue', listener: RequestListener): this; once(event: 'checkExpectation', listener: RequestListener): this; once(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this; - once( - event: 'connect', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + once(event: 'connect', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + once(event: 'dropRequest', listener: (req: InstanceType, socket: stream.Duplex) => void): this; once(event: 'request', listener: RequestListener): this; - once( - event: 'upgrade', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + once(event: 'upgrade', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: 'close', listener: () => void): this; prependListener(event: 'connection', listener: (socket: Socket) => void): this; @@ -365,15 +410,10 @@ declare module 'http' { prependListener(event: 'checkContinue', listener: RequestListener): this; prependListener(event: 'checkExpectation', listener: RequestListener): this; prependListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this; - prependListener( - event: 'connect', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + prependListener(event: 'connect', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + prependListener(event: 'dropRequest', listener: (req: InstanceType, socket: stream.Duplex) => void): this; prependListener(event: 'request', listener: RequestListener): this; - prependListener( - event: 'upgrade', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + prependListener(event: 'upgrade', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: 'close', listener: () => void): this; prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this; @@ -382,19 +422,14 @@ declare module 'http' { prependOnceListener(event: 'checkContinue', listener: RequestListener): this; prependOnceListener(event: 'checkExpectation', listener: RequestListener): this; prependOnceListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this; - prependOnceListener( - event: 'connect', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + prependOnceListener(event: 'connect', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + prependOnceListener(event: 'dropRequest', listener: (req: InstanceType, socket: stream.Duplex) => void): this; prependOnceListener(event: 'request', listener: RequestListener): this; - prependOnceListener( - event: 'upgrade', - listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, - ): this; + prependOnceListener(event: 'upgrade', listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; } /** - * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract of outgoing message from - * the perspective of the participants of HTTP transaction. + * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract outgoing message from + * the perspective of the participants of an HTTP transaction. * @since v0.1.17 */ class OutgoingMessage extends stream.Writable { @@ -413,7 +448,7 @@ declare module 'http' { */ readonly headersSent: boolean; /** - * Aliases of `outgoingMessage.socket` + * Alias of `outgoingMessage.socket`. * @since v0.3.0 * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead. */ @@ -434,15 +469,33 @@ declare module 'http' { */ setTimeout(msecs: number, callback?: () => void): this; /** - * Sets a single header value for the header object. + * Sets a single header value. If the header already exists in the to-be-sent + * headers, its value will be replaced. Use an array of strings to send multiple + * headers with the same name. * @since v0.4.0 * @param name Header name * @param value Header value */ setHeader(name: string, value: number | string | ReadonlyArray): this; /** - * Gets the value of HTTP header with the given name. If such a name doesn't - * exist in message, it will be `undefined`. + * Append a single header value for the header object. + * + * If the value is an array, this is equivalent of calling this method multiple + * times. + * + * If there were no previous value for the header, this is equivalent of calling `outgoingMessage.setHeader(name, value)`. + * + * Depending of the value of `options.uniqueHeaders` when the client request or the + * server were created, this will end up in the header being sent multiple times or + * a single time with values joined using `; `. + * @since v18.3.0, v16.17.0 + * @param name Header name + * @param value Header value + */ + appendHeader(name: string, value: string | ReadonlyArray): this; + /** + * Gets the value of the HTTP header with the given name. If that header is not + * set, the returned value will be `undefined`. * @since v0.4.0 * @param name Name of header */ @@ -455,8 +508,8 @@ declare module 'http' { * values. All header names are lowercase. * * The object returned by the `outgoingMessage.getHeaders()` method does - * not prototypically inherit from the JavaScript Object. This means that - * typical Object methods such as `obj.toString()`, `obj.hasOwnProperty()`, + * not prototypically inherit from the JavaScript `Object`. This means that + * typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`, * and others are not defined and will not work. * * ```js @@ -470,8 +523,8 @@ declare module 'http' { */ getHeaders(): OutgoingHttpHeaders; /** - * Returns an array of names of headers of the outgoing outgoingMessage. All - * names are lowercase. + * Returns an array containing the unique names of the current outgoing headers. + * All names are lowercase. * @since v7.7.0 */ getHeaderNames(): string[]; @@ -498,11 +551,11 @@ declare module 'http' { /** * Adds HTTP trailers (headers but at the end of the message) to the message. * - * Trailers are **only** be emitted if the message is chunked encoded. If not, - * the trailer will be silently discarded. + * Trailers will **only** be emitted if the message is chunked encoded. If not, + * the trailers will be silently discarded. * * HTTP requires the `Trailer` header to be sent to emit trailers, - * with a list of header fields in its value, e.g. + * with a list of header field names in its value, e.g. * * ```js * message.writeHead(200, { 'Content-Type': 'text/plain', @@ -518,7 +571,7 @@ declare module 'http' { */ addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void; /** - * Compulsorily flushes the message headers + * Flushes the message headers. * * For efficiency reason, Node.js normally buffers the message headers * until `outgoingMessage.end()` is called or the first chunk of message data @@ -526,7 +579,7 @@ declare module 'http' { * packet. * * It is usually desired (it saves a TCP round-trip), but not when the first - * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the request. + * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the message. * @since v1.6.0 */ flushHeaders(): void; @@ -566,15 +619,56 @@ declare module 'http' { * @since v0.11.8 */ statusMessage: string; + /** + * If set to `true`, Node.js will check whether the `Content-Length`header value and the size of the body, in bytes, are equal. + * Mismatching the `Content-Length` header value will result + * in an `Error` being thrown, identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`. + * @since v18.10.0, v16.18.0 + */ + strictContentLength: boolean; constructor(req: Request); assignSocket(socket: Socket): void; detachSocket(socket: Socket): void; /** - * Sends a HTTP/1.1 100 Continue message to the client, indicating that + * Sends an HTTP/1.1 100 Continue message to the client, indicating that * the request body should be sent. See the `'checkContinue'` event on`Server`. * @since v0.3.0 */ writeContinue(callback?: () => void): void; + /** + * Sends an HTTP/1.1 103 Early Hints message to the client with a Link header, + * indicating that the user agent can preload/preconnect the linked resources. + * The `hints` is an object containing the values of headers to be sent with + * early hints message. The optional `callback` argument will be called when + * the response message has been written. + * + * **Example** + * + * ```js + * const earlyHintsLink = '; rel=preload; as=style'; + * response.writeEarlyHints({ + * 'link': earlyHintsLink, + * }); + * + * const earlyHintsLinks = [ + * '; rel=preload; as=style', + * '; rel=preload; as=script', + * ]; + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * 'x-trace-id': 'id for diagnostics', + * }); + * + * const earlyHintsCallback = () => console.log('early hints message sent'); + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * }, earlyHintsCallback); + * ``` + * @since v18.11.0 + * @param hints An object containing the values of headers + * @param callback Will be called when the response message has been written + */ + writeEarlyHints(hints: Record, callback?: () => void): void; /** * Sends a response header to the request. The status code is a 3-digit HTTP * status code, like `404`. The last argument, `headers`, are the response headers. @@ -593,7 +687,7 @@ declare module 'http' { * response * .writeHead(200, { * 'Content-Length': Buffer.byteLength(body), - * 'Content-Type': 'text/plain' + * 'Content-Type': 'text/plain', * }) * .end(body); * ``` @@ -624,12 +718,12 @@ declare module 'http' { * }); * ``` * - * `Content-Length` is given in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js - * does not check whether `Content-Length` and the length of the body which has + * `Content-Length` is read in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js + * will check whether `Content-Length` and the length of the body which has * been transmitted are equal or not. * * Attempting to set a header field name or value that contains invalid characters - * will result in a `TypeError` being thrown. + * will result in a \[`Error`\]\[\] being thrown. * @since v0.1.30 */ writeHead( @@ -678,8 +772,11 @@ declare module 'http' { * * For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered. * - * Node.js does not check whether Content-Length and the length of the - * body which has been transmitted are equal or not. + * Set `Content-Length` header to limit the response body size. + * If `response.strictContentLength` is set to `true`, mismatching the`Content-Length` header value will result in an `Error` being thrown, + * identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`. + * + * `Content-Length` value should be in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. * @since v0.1.17 */ class ClientRequest extends OutgoingMessage { @@ -706,7 +803,7 @@ declare module 'http' { * may run into a 'ECONNRESET' error. * * ```js - * const http = require('http'); + * const http = require('node:http'); * * // Server has a 5 seconds keep-alive timeout by default * http @@ -730,7 +827,7 @@ declare module 'http' { * automatic error retry base on it. * * ```js - * const http = require('http'); + * const http = require('node:http'); * const agent = new http.Agent({ keepAlive: true }); * * function retriableRequest() { @@ -809,19 +906,13 @@ declare module 'http' { * @deprecated */ addListener(event: 'abort', listener: () => void): this; - addListener( - event: 'connect', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + addListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; addListener(event: 'continue', listener: () => void): this; addListener(event: 'information', listener: (info: InformationEvent) => void): this; addListener(event: 'response', listener: (response: IncomingMessage) => void): this; addListener(event: 'socket', listener: (socket: Socket) => void): this; addListener(event: 'timeout', listener: () => void): this; - addListener( - event: 'upgrade', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + addListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; addListener(event: 'close', listener: () => void): this; addListener(event: 'drain', listener: () => void): this; addListener(event: 'error', listener: (err: Error) => void): this; @@ -869,19 +960,13 @@ declare module 'http' { * @deprecated */ prependListener(event: 'abort', listener: () => void): this; - prependListener( - event: 'connect', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + prependListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; prependListener(event: 'continue', listener: () => void): this; prependListener(event: 'information', listener: (info: InformationEvent) => void): this; prependListener(event: 'response', listener: (response: IncomingMessage) => void): this; prependListener(event: 'socket', listener: (socket: Socket) => void): this; prependListener(event: 'timeout', listener: () => void): this; - prependListener( - event: 'upgrade', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + prependListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; prependListener(event: 'close', listener: () => void): this; prependListener(event: 'drain', listener: () => void): this; prependListener(event: 'error', listener: (err: Error) => void): this; @@ -893,19 +978,13 @@ declare module 'http' { * @deprecated */ prependOnceListener(event: 'abort', listener: () => void): this; - prependOnceListener( - event: 'connect', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + prependOnceListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; prependOnceListener(event: 'continue', listener: () => void): this; prependOnceListener(event: 'information', listener: (info: InformationEvent) => void): this; prependOnceListener(event: 'response', listener: (response: IncomingMessage) => void): this; prependOnceListener(event: 'socket', listener: (socket: Socket) => void): this; prependOnceListener(event: 'timeout', listener: () => void): this; - prependOnceListener( - event: 'upgrade', - listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, - ): this; + prependOnceListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; prependOnceListener(event: 'close', listener: () => void): this; prependOnceListener(event: 'drain', listener: () => void): this; prependOnceListener(event: 'error', listener: (err: Error) => void): this; @@ -917,7 +996,7 @@ declare module 'http' { /** * An `IncomingMessage` object is created by {@link Server} or {@link ClientRequest} and passed as the first argument to the `'request'` and `'response'` event respectively. It may be used to * access response - * status, headers and data. + * status, headers, and data. * * Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to * parse and emit the incoming HTTP headers and payload, as the underlying socket @@ -955,7 +1034,7 @@ declare module 'http' { * const req = http.request({ * host: '127.0.0.1', * port: 8080, - * method: 'POST' + * method: 'POST', * }, (res) => { * res.resume(); * res.on('end', () => { @@ -997,7 +1076,7 @@ declare module 'http' { * // { 'user-agent': 'curl/7.22.0', * // host: '127.0.0.1:8000', * // accept: '*' } - * console.log(request.getHeaders()); + * console.log(request.headers); * ``` * * Duplicates in raw headers are handled in the following ways, depending on the @@ -1005,12 +1084,30 @@ declare module 'http' { * * * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`, * `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded. + * To allow duplicate values of the headers listed above to be joined, + * use the option `joinDuplicateHeaders` in {@link request} and {@link createServer}. See RFC 9110 Section 5.3 for more + * information. * * `set-cookie` is always an array. Duplicates are added to the array. - * * For duplicate `cookie` headers, the values are joined together with '; '. - * * For all other headers, the values are joined together with ', '. + * * For duplicate `cookie` headers, the values are joined together with `; `. + * * For all other headers, the values are joined together with `, `. * @since v0.1.5 */ headers: IncomingHttpHeaders; + /** + * Similar to `message.headers`, but there is no join logic and the values are + * always arrays of strings, even for headers received just once. + * + * ```js + * // Prints something like: + * // + * // { 'user-agent': ['curl/7.22.0'], + * // host: ['127.0.0.1:8000'], + * // accept: ['*'] } + * console.log(request.headersDistinct); + * ``` + * @since v18.3.0, v16.17.0 + */ + headersDistinct: NodeJS.Dict; /** * The raw request/response headers list exactly as they were received. * @@ -1041,6 +1138,13 @@ declare module 'http' { * @since v0.3.0 */ trailers: NodeJS.Dict; + /** + * Similar to `message.trailers`, but there is no join logic and the values are + * always arrays of strings, even for headers received just once. + * Only populated at the `'end'` event. + * @since v18.3.0, v16.17.0 + */ + trailersDistinct: NodeJS.Dict; /** * The raw request/response trailer keys and values exactly as they were * received. Only populated at the `'end'` event. @@ -1073,14 +1177,14 @@ declare module 'http' { * To parse the URL into its parts: * * ```js - * new URL(request.url, `http://${request.getHeaders().host}`); + * new URL(request.url, `http://${request.headers.host}`); * ``` * - * When `request.url` is `'/status?name=ryan'` and`request.getHeaders().host` is `'localhost:3000'`: + * When `request.url` is `'/status?name=ryan'` and `request.headers.host` is`'localhost:3000'`: * * ```console * $ node - * > new URL(request.url, `http://${request.getHeaders().host}`) + * > new URL(request.url, `http://${request.headers.host}`) * URL { * href: 'http://localhost:3000/status?name=ryan', * origin: 'http://localhost:3000', @@ -1200,16 +1304,16 @@ declare module 'http' { * hostname: 'localhost', * port: 80, * path: '/', - * agent: false // Create a new agent just for this one request + * agent: false, // Create a new agent just for this one request * }, (res) => { * // Do stuff with response * }); * ``` * @since v0.3.4 */ - class Agent { + class Agent extends EventEmitter { /** - * By default set to 256\. For agents with `keepAlive` enabled, this + * By default set to 256. For agents with `keepAlive` enabled, this * sets the maximum number of sockets that will be left open in the free * state. * @since v0.11.7 @@ -1305,10 +1409,10 @@ declare module 'http' { * upload a file with a POST request, then write to the `ClientRequest` object. * * ```js - * const http = require('http'); + * const http = require('node:http'); * * const postData = JSON.stringify({ - * 'msg': 'Hello World!' + * 'msg': 'Hello World!', * }); * * const options = { @@ -1318,8 +1422,8 @@ declare module 'http' { * method: 'POST', * headers: { * 'Content-Type': 'application/json', - * 'Content-Length': Buffer.byteLength(postData) - * } + * 'Content-Length': Buffer.byteLength(postData), + * }, * }; * * const req = http.request(options, (res) => { @@ -1406,7 +1510,7 @@ declare module 'http' { * * `'data'` any number of times, on the `res` object * * (connection closed here) * * `'aborted'` on the `res` object - * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`. + * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'` * * `'close'` * * `'close'` on the `res` object * @@ -1414,7 +1518,7 @@ declare module 'http' { * events will be emitted in the following order: * * * (`req.destroy()` called here) - * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'` + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called * * `'close'` * * If `req.destroy()` is called before the connection succeeds, the following @@ -1422,7 +1526,7 @@ declare module 'http' { * * * `'socket'` * * (`req.destroy()` called here) - * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'` + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called * * `'close'` * * If `req.destroy()` is called after the response is received, the following @@ -1433,7 +1537,7 @@ declare module 'http' { * * `'data'` any number of times, on the `res` object * * (`req.destroy()` called here) * * `'aborted'` on the `res` object - * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`. + * * `'error'` on the `res` object with an error with message `'Error: aborted'`and code `'ECONNRESET'`, or the error with which `req.destroy()` was called * * `'close'` * * `'close'` on the `res` object * @@ -1469,16 +1573,13 @@ declare module 'http' { * Setting the `timeout` option or using the `setTimeout()` function will * not abort the request or do anything besides add a `'timeout'` event. * - * Passing an `AbortSignal` and then calling `abort` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the - * request itself. + * Passing an `AbortSignal` and then calling `abort()` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the + * request. Specifically, the `'error'` event will be emitted with an error with + * the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`and the `cause`, if one was provided. * @since v0.3.6 */ function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; - function request( - url: string | URL, - options: RequestOptions, - callback?: (res: IncomingMessage) => void, - ): ClientRequest; + function request(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; /** * Since most requests are GET requests without bodies, Node.js provides this * convenience method. The only difference between this method and {@link request} is that it sets the method to GET and calls `req.end()`automatically. The callback must take care to consume the @@ -1530,7 +1631,7 @@ declare module 'http' { * const server = http.createServer((req, res) => { * res.writeHead(200, { 'Content-Type': 'application/json' }); * res.end(JSON.stringify({ - * data: 'Hello World!' + * data: 'Hello World!', * })); * }); * @@ -1541,6 +1642,76 @@ declare module 'http' { */ function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + /** + * Performs the low-level validations on the provided `name` that are done when`res.setHeader(name, value)` is called. + * + * Passing illegal value as `name` will result in a `TypeError` being thrown, + * identified by `code: 'ERR_INVALID_HTTP_TOKEN'`. + * + * It is not necessary to use this method before passing headers to an HTTP request + * or response. The HTTP module will automatically validate such headers. + * Examples: + * + * Example: + * + * ```js + * const { validateHeaderName } = require('node:http'); + * + * try { + * validateHeaderName(''); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN' + * console.error(err.message); // --> 'Header name must be a valid HTTP token [""]' + * } + * ``` + * @since v14.3.0 + * @param [label='Header name'] Label for error message. + */ + function validateHeaderName(name: string): void; + /** + * Performs the low-level validations on the provided `value` that are done when`res.setHeader(name, value)` is called. + * + * Passing illegal value as `value` will result in a `TypeError` being thrown. + * + * * Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`. + * * Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`. + * + * It is not necessary to use this method before passing headers to an HTTP request + * or response. The HTTP module will automatically validate such headers. + * + * Examples: + * + * ```js + * const { validateHeaderValue } = require('node:http'); + * + * try { + * validateHeaderValue('x-my-header', undefined); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true + * console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"' + * } + * + * try { + * validateHeaderValue('x-my-header', 'oʊmɪɡə'); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code === 'ERR_INVALID_CHAR'); // --> true + * console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]' + * } + * ``` + * @since v14.3.0 + * @param name Header name + * @param value Header value + */ + function validateHeaderValue(name: string, value: string): void; + /** + * Set the maximum number of idle HTTP parsers. + * @since v18.8.0, v16.18.0 + * @param [max=1000] + */ + function setMaxIdleHTTPParsers(max: number): void; let globalAgent: Agent; /** * Read-only property specifying the maximum allowed size of HTTP headers in bytes. diff --git a/node_modules/@types/node/ts4.8/http2.d.ts b/node_modules/@types/node/ts4.8/http2.d.ts index 0f628b9d7..80057093f 100755 --- a/node_modules/@types/node/ts4.8/http2.d.ts +++ b/node_modules/@types/node/ts4.8/http2.d.ts @@ -1,12 +1,12 @@ /** - * The `http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol. It - * can be accessed using: + * The `node:http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol. + * It can be accessed using: * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * ``` * @since v8.4.0 - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http2.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http2.js) */ declare module 'http2' { import EventEmitter = require('node:events'); @@ -151,7 +151,7 @@ declare module 'http2' { priority(options: StreamPriorityOptions): void; /** * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const client = http2.connect('http://example.org:8000'); * const { NGHTTP2_CANCEL } = http2.constants; * const req = client.request({ ':path': '/' }); @@ -171,7 +171,7 @@ declare module 'http2' { * trailers can be sent. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * stream.respond(undefined, { waitForTrailers: true }); @@ -332,7 +332,7 @@ declare module 'http2' { * Initiates a push stream. The callback is invoked with the new `Http2Stream`instance created for the push stream passed as the second argument, or an`Error` passed as the first argument. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * stream.respond({ ':status': 200 }); @@ -357,7 +357,7 @@ declare module 'http2' { pushStream(headers: OutgoingHttpHeaders, options?: StreamPriorityOptions, callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void): void; /** * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * stream.respond({ ':status': 200 }); @@ -365,16 +365,15 @@ declare module 'http2' { * }); * ``` * - * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event - * will be emitted immediately after queuing the last chunk of payload data to be - * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing - * header fields to the peer. + * Initiates a response. When the `options.waitForTrailers` option is set, the`'wantTrailers'` event will be emitted immediately after queuing the last chunk + * of payload data to be sent. The `http2stream.sendTrailers()` method can then be + * used to sent trailing header fields to the peer. * * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * stream.respond({ ':status': 200 }, { waitForTrailers: true }); @@ -397,8 +396,8 @@ declare module 'http2' { * automatically. * * ```js - * const http2 = require('http2'); - * const fs = require('fs'); + * const http2 = require('node:http2'); + * const fs = require('node:fs'); * * const server = http2.createServer(); * server.on('stream', (stream) => { @@ -408,7 +407,7 @@ declare module 'http2' { * const headers = { * 'content-length': stat.size, * 'last-modified': stat.mtime.toUTCString(), - * 'content-type': 'text/plain; charset=utf-8' + * 'content-type': 'text/plain; charset=utf-8', * }; * stream.respondWithFD(fd, headers); * stream.on('close', () => fs.closeSync(fd)); @@ -439,8 +438,8 @@ declare module 'http2' { * close when the final `DATA` frame is transmitted. User code _must_ call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. * * ```js - * const http2 = require('http2'); - * const fs = require('fs'); + * const http2 = require('node:http2'); + * const fs = require('node:fs'); * * const server = http2.createServer(); * server.on('stream', (stream) => { @@ -450,7 +449,7 @@ declare module 'http2' { * const headers = { * 'content-length': stat.size, * 'last-modified': stat.mtime.toUTCString(), - * 'content-type': 'text/plain; charset=utf-8' + * 'content-type': 'text/plain; charset=utf-8', * }; * stream.respondWithFD(fd, headers, { waitForTrailers: true }); * stream.on('wantTrailers', () => { @@ -482,7 +481,7 @@ declare module 'http2' { * Example using a file path: * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * function statCheck(stat, headers) { @@ -500,7 +499,7 @@ declare module 'http2' { * } * } catch (err) { * // Perform actual error handling. - * console.log(err); + * console.error(err); * } * stream.end(); * } @@ -516,7 +515,7 @@ declare module 'http2' { * results to determine if the file has been modified to return an appropriate`304` response: * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * function statCheck(stat, headers) { @@ -549,7 +548,7 @@ declare module 'http2' { * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer(); * server.on('stream', (stream) => { * stream.respondWithFile('/some/file', @@ -748,7 +747,7 @@ declare module 'http2' { * the delta. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * * const server = http2.createServer(); * const expectedWindowSize = 2 ** 20; @@ -854,11 +853,11 @@ declare module 'http2' { * This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const clientSession = http2.connect('https://localhost:1234'); * const { * HTTP2_HEADER_PATH, - * HTTP2_HEADER_STATUS + * HTTP2_HEADER_STATUS, * } = http2.constants; * * const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' }); @@ -928,7 +927,7 @@ declare module 'http2' { * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * * const server = http2.createServer(); * server.on('session', (session) => { @@ -969,7 +968,7 @@ declare module 'http2' { * authoritative responses. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const options = getSecureOptionsSomehow(); * const server = http2.createSecureServer(options); * server.on('stream', (stream) => { @@ -995,7 +994,7 @@ declare module 'http2' { * server using the `http2.createSecureServer()` method: * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const options = getSecureOptionsSomehow(); * options.origins = ['https://example.com', 'https://example.org']; * const server = http2.createSecureServer(options); @@ -1053,7 +1052,6 @@ declare module 'http2' { */ unknownProtocolTimeout?: number | undefined; selectPadding?(frameLen: number, maxFrameLen: number): number; - createConnection?(authority: url.URL, option: SessionOptions): stream.Duplex; } export interface ClientSessionOptions extends SessionOptions { maxReservedRemoteStreams?: number | undefined; @@ -1437,7 +1435,7 @@ declare module 'http2' { */ readonly headersSent: boolean; /** - * A reference to the original HTTP2 request object. + * A reference to the original HTTP2 `request` object. * @since v15.7.0 */ readonly req: Http2ServerRequest; @@ -1458,7 +1456,7 @@ declare module 'http2' { * All other interactions will be routed directly to the socket. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const server = http2.createServer((req, res) => { * const ip = req.socket.remoteAddress; * const port = req.socket.remotePort; @@ -1641,7 +1639,7 @@ declare module 'http2' { * This sends a chunk of the response body. This method may * be called multiple times to provide successive parts of the body. * - * In the `http` module, the response body is omitted when the + * In the `node:http` module, the response body is omitted when the * request is a HEAD request. Similarly, the `204` and `304` responses _must not_ include a message body. * * `chunk` can be a string or a buffer. If `chunk` is a string, @@ -1670,6 +1668,31 @@ declare module 'http2' { * @since v8.4.0 */ writeContinue(): void; + /** + * Sends a status `103 Early Hints` to the client with a Link header, + * indicating that the user agent can preload/preconnect the linked resources. + * The `hints` is an object containing the values of headers to be sent with + * early hints message. + * + * **Example** + * + * ```js + * const earlyHintsLink = '; rel=preload; as=style'; + * response.writeEarlyHints({ + * 'link': earlyHintsLink, + * }); + * + * const earlyHintsLinks = [ + * '; rel=preload; as=style', + * '; rel=preload; as=script', + * ]; + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * }); + * ``` + * @since v18.11.0 + */ + writeEarlyHints(hints: Record): void; /** * Sends a response header to the request. The status code is a 3-digit HTTP * status code, like `404`. The last argument, `headers`, are the response headers. @@ -2000,7 +2023,7 @@ declare module 'http2' { * for use with the `HTTP2-Settings` header field. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * * const packed = http2.getPackedSettings({ enablePush: false }); * @@ -2025,7 +2048,7 @@ declare module 'http2' { * with browser clients. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * * // Create an unencrypted HTTP/2 server. * // Since there are no browsers known that support @@ -2036,12 +2059,12 @@ declare module 'http2' { * server.on('stream', (stream, headers) => { * stream.respond({ * 'content-type': 'text/html; charset=utf-8', - * ':status': 200 + * ':status': 200, * }); * stream.end('

Hello World

'); * }); * - * server.listen(80); + * server.listen(8000); * ``` * @since v8.4.0 * @param onRequestHandler See `Compatibility API` @@ -2052,12 +2075,12 @@ declare module 'http2' { * Returns a `tls.Server` instance that creates and manages `Http2Session`instances. * * ```js - * const http2 = require('http2'); - * const fs = require('fs'); + * const http2 = require('node:http2'); + * const fs = require('node:fs'); * * const options = { * key: fs.readFileSync('server-key.pem'), - * cert: fs.readFileSync('server-cert.pem') + * cert: fs.readFileSync('server-cert.pem'), * }; * * // Create a secure HTTP/2 server @@ -2066,12 +2089,12 @@ declare module 'http2' { * server.on('stream', (stream, headers) => { * stream.respond({ * 'content-type': 'text/html; charset=utf-8', - * ':status': 200 + * ':status': 200, * }); * stream.end('

Hello World

'); * }); * - * server.listen(80); + * server.listen(8443); * ``` * @since v8.4.0 * @param onRequestHandler See `Compatibility API` @@ -2082,7 +2105,7 @@ declare module 'http2' { * Returns a `ClientHttp2Session` instance. * * ```js - * const http2 = require('http2'); + * const http2 = require('node:http2'); * const client = http2.connect('https://localhost:1234'); * * // Use the client diff --git a/node_modules/@types/node/ts4.8/https.d.ts b/node_modules/@types/node/ts4.8/https.d.ts index aae4a9584..76fca92c0 100755 --- a/node_modules/@types/node/ts4.8/https.d.ts +++ b/node_modules/@types/node/ts4.8/https.d.ts @@ -1,7 +1,7 @@ /** * HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a * separate module. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/https.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/https.js) */ declare module 'https' { import { Duplex } from 'node:stream'; @@ -14,6 +14,7 @@ declare module 'https' { > = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions; type RequestOptions = http.RequestOptions & tls.SecureContextOptions & { + checkServerIdentity?: typeof tls.checkServerIdentity | undefined; rejectUnauthorized?: boolean | undefined; // Defaults to true servername?: string | undefined; // SNI TLS Extension }; @@ -58,22 +59,9 @@ declare module 'https' { closeIdleConnections(): void; addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; - addListener( - event: 'newSession', - listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, - ): this; - addListener( - event: 'OCSPRequest', - listener: ( - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ) => void, - ): this; - addListener( - event: 'resumeSession', - listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, - ): this; + addListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this; + addListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this; + addListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this; addListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this; addListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; addListener(event: 'close', listener: () => void): this; @@ -83,29 +71,13 @@ declare module 'https' { addListener(event: 'checkContinue', listener: http.RequestListener): this; addListener(event: 'checkExpectation', listener: http.RequestListener): this; addListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this; - addListener( - event: 'connect', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + addListener(event: 'connect', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; addListener(event: 'request', listener: http.RequestListener): this; - addListener( - event: 'upgrade', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + addListener(event: 'upgrade', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; emit(event: string, ...args: any[]): boolean; emit(event: 'keylog', line: Buffer, tlsSocket: tls.TLSSocket): boolean; - emit( - event: 'newSession', - sessionId: Buffer, - sessionData: Buffer, - callback: (err: Error, resp: Buffer) => void, - ): boolean; - emit( - event: 'OCSPRequest', - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ): boolean; + emit(event: 'newSession', sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void): boolean; + emit(event: 'OCSPRequest', certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void): boolean; emit(event: 'resumeSession', sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean; emit(event: 'secureConnection', tlsSocket: tls.TLSSocket): boolean; emit(event: 'tlsClientError', err: Error, tlsSocket: tls.TLSSocket): boolean; @@ -116,39 +88,32 @@ declare module 'https' { emit( event: 'checkContinue', req: InstanceType, - res: InstanceType & { req: InstanceType }, + res: InstanceType & { + req: InstanceType; + } ): boolean; emit( event: 'checkExpectation', req: InstanceType, - res: InstanceType & { req: InstanceType }, + res: InstanceType & { + req: InstanceType; + } ): boolean; emit(event: 'clientError', err: Error, socket: Duplex): boolean; emit(event: 'connect', req: InstanceType, socket: Duplex, head: Buffer): boolean; emit( event: 'request', req: InstanceType, - res: InstanceType & { req: InstanceType }, + res: InstanceType & { + req: InstanceType; + } ): boolean; emit(event: 'upgrade', req: InstanceType, socket: Duplex, head: Buffer): boolean; on(event: string, listener: (...args: any[]) => void): this; on(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; - on( - event: 'newSession', - listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, - ): this; - on( - event: 'OCSPRequest', - listener: ( - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ) => void, - ): this; - on( - event: 'resumeSession', - listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, - ): this; + on(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this; + on(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this; + on(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this; on(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this; on(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; on(event: 'close', listener: () => void): this; @@ -163,22 +128,9 @@ declare module 'https' { on(event: 'upgrade', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; once(event: string, listener: (...args: any[]) => void): this; once(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; - once( - event: 'newSession', - listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, - ): this; - once( - event: 'OCSPRequest', - listener: ( - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ) => void, - ): this; - once( - event: 'resumeSession', - listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, - ): this; + once(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this; + once(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this; + once(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this; once(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this; once(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; once(event: 'close', listener: () => void): this; @@ -193,22 +145,9 @@ declare module 'https' { once(event: 'upgrade', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; - prependListener( - event: 'newSession', - listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, - ): this; - prependListener( - event: 'OCSPRequest', - listener: ( - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ) => void, - ): this; - prependListener( - event: 'resumeSession', - listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, - ): this; + prependListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this; + prependListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this; + prependListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this; prependListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this; prependListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; prependListener(event: 'close', listener: () => void): this; @@ -218,33 +157,14 @@ declare module 'https' { prependListener(event: 'checkContinue', listener: http.RequestListener): this; prependListener(event: 'checkExpectation', listener: http.RequestListener): this; prependListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this; - prependListener( - event: 'connect', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + prependListener(event: 'connect', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; prependListener(event: 'request', listener: http.RequestListener): this; - prependListener( - event: 'upgrade', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + prependListener(event: 'upgrade', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; - prependOnceListener( - event: 'newSession', - listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, - ): this; - prependOnceListener( - event: 'OCSPRequest', - listener: ( - certificate: Buffer, - issuer: Buffer, - callback: (err: Error | null, resp: Buffer) => void, - ) => void, - ): this; - prependOnceListener( - event: 'resumeSession', - listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, - ): this; + prependOnceListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this; + prependOnceListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this; + prependOnceListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this; prependOnceListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this; prependOnceListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; prependOnceListener(event: 'close', listener: () => void): this; @@ -254,25 +174,19 @@ declare module 'https' { prependOnceListener(event: 'checkContinue', listener: http.RequestListener): this; prependOnceListener(event: 'checkExpectation', listener: http.RequestListener): this; prependOnceListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this; - prependOnceListener( - event: 'connect', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + prependOnceListener(event: 'connect', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; prependOnceListener(event: 'request', listener: http.RequestListener): this; - prependOnceListener( - event: 'upgrade', - listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, - ): this; + prependOnceListener(event: 'upgrade', listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; } /** * ```js * // curl -k https://localhost:8000/ - * const https = require('https'); - * const fs = require('fs'); + * const https = require('node:https'); + * const fs = require('node:fs'); * * const options = { * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), - * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem') + * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), * }; * * https.createServer(options, (req, res) => { @@ -284,12 +198,12 @@ declare module 'https' { * Or * * ```js - * const https = require('https'); - * const fs = require('fs'); + * const https = require('node:https'); + * const fs = require('node:fs'); * * const options = { * pfx: fs.readFileSync('test/fixtures/test_cert.pfx'), - * passphrase: 'sample' + * passphrase: 'sample', * }; * * https.createServer(options, (req, res) => { @@ -325,13 +239,13 @@ declare module 'https' { * upload a file with a POST request, then write to the `ClientRequest` object. * * ```js - * const https = require('https'); + * const https = require('node:https'); * * const options = { * hostname: 'encrypted.google.com', * port: 443, * path: '/', - * method: 'GET' + * method: 'GET', * }; * * const req = https.request(options, (res) => { @@ -358,7 +272,7 @@ declare module 'https' { * path: '/', * method: 'GET', * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), - * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem') + * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), * }; * options.agent = new https.Agent(options); * @@ -377,7 +291,7 @@ declare module 'https' { * method: 'GET', * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), - * agent: false + * agent: false, * }; * * const req = https.request(options, (res) => { @@ -398,9 +312,9 @@ declare module 'https' { * Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`): * * ```js - * const tls = require('tls'); - * const https = require('https'); - * const crypto = require('crypto'); + * const tls = require('node:tls'); + * const https = require('node:https'); + * const crypto = require('node:crypto'); * * function sha256(s) { * return crypto.createHash('sha256').update(s).digest('base64'); @@ -417,7 +331,7 @@ declare module 'https' { * return err; * } * - * // Pin the public key, similar to HPKP pin-sha25 pinning + * // Pin the public key, similar to HPKP pin-sha256 pinning * const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU='; * if (sha256(cert.pubkey) !== pubkey256) { * const msg = 'Certificate verification error: ' + @@ -492,15 +406,8 @@ declare module 'https' { * @since v0.3.6 * @param options Accepts all `options` from `request`, with some differences in default values: */ - function request( - options: RequestOptions | string | URL, - callback?: (res: http.IncomingMessage) => void, - ): http.ClientRequest; - function request( - url: string | URL, - options: RequestOptions, - callback?: (res: http.IncomingMessage) => void, - ): http.ClientRequest; + function request(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + function request(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; /** * Like `http.get()` but for HTTPS. * @@ -508,7 +415,7 @@ declare module 'https' { * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object. * * ```js - * const https = require('https'); + * const https = require('node:https'); * * https.get('https://encrypted.google.com/', (res) => { * console.log('statusCode:', res.statusCode); @@ -525,15 +432,8 @@ declare module 'https' { * @since v0.3.6 * @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`. */ - function get( - options: RequestOptions | string | URL, - callback?: (res: http.IncomingMessage) => void, - ): http.ClientRequest; - function get( - url: string | URL, - options: RequestOptions, - callback?: (res: http.IncomingMessage) => void, - ): http.ClientRequest; + function get(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + function get(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; let globalAgent: Agent; } declare module 'node:https' { diff --git a/node_modules/@types/node/ts4.8/index.d.ts b/node_modules/@types/node/ts4.8/index.d.ts index 2faf25e1f..7c8b38c63 100755 --- a/node_modules/@types/node/ts4.8/index.d.ts +++ b/node_modules/@types/node/ts4.8/index.d.ts @@ -47,6 +47,7 @@ /// /// /// +/// /// /// /// diff --git a/node_modules/@types/node/ts4.8/inspector.d.ts b/node_modules/@types/node/ts4.8/inspector.d.ts index eba0b55d8..48920de3e 100755 --- a/node_modules/@types/node/ts4.8/inspector.d.ts +++ b/node_modules/@types/node/ts4.8/inspector.d.ts @@ -8,14 +8,21 @@ // tslint:disable:max-line-length /** - * The `inspector` module provides an API for interacting with the V8 inspector. + * The `node:inspector` module provides an API for interacting with the V8 + * inspector. * * It can be accessed using: * * ```js - * const inspector = require('inspector'); + * import * as inspector from 'node:inspector/promises'; * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/inspector.js) + * + * or + * + * ```js + * import * as inspector from 'node:inspector'; + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/inspector.js) */ declare module 'inspector' { import EventEmitter = require('node:events'); diff --git a/node_modules/@types/node/ts4.8/module.d.ts b/node_modules/@types/node/ts4.8/module.d.ts index d83aec94a..e884f32cc 100755 --- a/node_modules/@types/node/ts4.8/module.d.ts +++ b/node_modules/@types/node/ts4.8/module.d.ts @@ -10,9 +10,9 @@ declare module 'module' { * does not add or remove exported names from the `ES Modules`. * * ```js - * const fs = require('fs'); - * const assert = require('assert'); - * const { syncBuiltinESMExports } = require('module'); + * const fs = require('node:fs'); + * const assert = require('node:assert'); + * const { syncBuiltinESMExports } = require('node:module'); * * fs.readFile = newAPI; * @@ -26,7 +26,7 @@ declare module 'module' { * * syncBuiltinESMExports(); * - * import('fs').then((esmFS) => { + * import('node:fs').then((esmFS) => { * // It syncs the existing readFile property with the new value * assert.strictEqual(esmFS.readFile, newAPI); * // readFileSync has been deleted from the required fs @@ -44,6 +44,7 @@ declare module 'module' { * `path` is the resolved path for the file for which a corresponding source map * should be fetched. * @since v13.7.0, v12.17.0 + * @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise. */ function findSourceMap(path: string, error?: Error): SourceMap; interface SourceMapPayload { @@ -85,6 +86,7 @@ declare module 'module' { static wrap(code: string): string; static createRequire(path: string | URL): NodeRequire; static builtinModules: string[]; + static isBuiltin(moduleName: string): boolean; static Module: typeof Module; constructor(id: string, parent?: Module); } diff --git a/node_modules/@types/node/ts4.8/net.d.ts b/node_modules/@types/node/ts4.8/net.d.ts index 72cebc825..d180fa076 100755 --- a/node_modules/@types/node/ts4.8/net.d.ts +++ b/node_modules/@types/node/ts4.8/net.d.ts @@ -1,16 +1,16 @@ /** * > Stability: 2 - Stable * - * The `net` module provides an asynchronous network API for creating stream-based + * The `node:net` module provides an asynchronous network API for creating stream-based * TCP or `IPC` servers ({@link createServer}) and clients * ({@link createConnection}). * * It can be accessed using: * * ```js - * const net = require('net'); + * const net = require('node:net'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/net.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/net.js) */ declare module 'net' { import * as stream from 'node:stream'; @@ -57,6 +57,14 @@ declare module 'net' { noDelay?: boolean | undefined; keepAlive?: boolean | undefined; keepAliveInitialDelay?: number | undefined; + /** + * @since v18.13.0 + */ + autoSelectFamily?: boolean | undefined; + /** + * @since v18.13.0 + */ + autoSelectFamilyAttemptTimeout?: number | undefined; } interface IpcSocketConnectOpts extends ConnectOpts { path: string; @@ -133,13 +141,10 @@ declare module 'net' { pause(): this; /** * Close the TCP connection by sending an RST packet and destroy the stream. - * If this TCP socket is in connecting status, it will send an RST packet - * and destroy this TCP socket once it is connected. Otherwise, it will call - * `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. If this is not a TCP socket - * (for example, a pipe), calling this method will immediately throw - * an `ERR_INVALID_HANDLE_TYPE` Error. - * @since v18.3.0 - * @return The socket itself. + * If this TCP socket is in connecting status, it will send an RST packet and destroy this TCP socket once it is connected. + * Otherwise, it will call `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. + * If this is not a TCP socket (for example, a pipe), calling this method will immediately throw an `ERR_INVALID_HANDLE_TYPE` Error. + * @since v18.3.0, v16.17.0 */ resetAndDestroy(): this; /** @@ -261,6 +266,12 @@ declare module 'net' { * @since v6.1.0 */ readonly connecting: boolean; + /** + * This is `true` if the socket is not connected yet, either because `.connect()`has not yet been called or because it is still in the process of connecting + * (see `socket.connecting`). + * @since v11.2.0, v10.16.0 + */ + readonly pending: boolean; /** * See `writable.destroyed` for further details. */ @@ -279,12 +290,16 @@ declare module 'net' { readonly localPort?: number; /** * The string representation of the local IP family. `'IPv4'` or `'IPv6'`. - * @since v18.8.0 + * @since v18.8.0, v16.18.0 */ - readonly localFamily?: string; + readonly localFamily?: string; /** * This property represents the state of the connection as a string. - * @see {https://nodejs.org/api/net.html#socketreadystate} + * + * * If the stream is connecting `socket.readyState` is `opening`. + * * If the stream is readable and writable, it is `open`. + * * If the stream is readable and not writable, it is `readOnly`. + * * If the stream is not readable and writable, it is `writeOnly`. * @since v0.5.0 */ readonly readyState: SocketReadyState; @@ -305,7 +320,8 @@ declare module 'net' { */ readonly remotePort?: number | undefined; /** - * The socket timeout in milliseconds as set by socket.setTimeout(). It is undefined if a timeout has not been set. + * The socket timeout in milliseconds as set by `socket.setTimeout()`. + * It is `undefined` if a timeout has not been set. * @since v10.7.0 */ readonly timeout?: number | undefined; @@ -486,7 +502,7 @@ declare module 'net' { * ```js * server.on('error', (e) => { * if (e.code === 'EADDRINUSE') { - * console.log('Address in use, retrying...'); + * console.error('Address in use, retrying...'); * setTimeout(() => { * server.close(); * server.listen(PORT, HOST); @@ -708,7 +724,7 @@ declare module 'net' { * on port 8124: * * ```js - * const net = require('net'); + * const net = require('node:net'); * const server = net.createServer((c) => { * // 'connection' listener. * console.log('client connected'); @@ -846,6 +862,7 @@ declare module 'net' { class SocketAddress { constructor(options: SocketAddressInitOptions); /** + * Either \`'ipv4'\` or \`'ipv6'\`. * @since v15.14.0, v14.18.0 */ readonly address: string; diff --git a/node_modules/@types/node/ts4.8/os.d.ts b/node_modules/@types/node/ts4.8/os.d.ts index 3c555992d..3d2086468 100755 --- a/node_modules/@types/node/ts4.8/os.d.ts +++ b/node_modules/@types/node/ts4.8/os.d.ts @@ -1,11 +1,11 @@ /** - * The `os` module provides operating system-related utility methods and + * The `node:os` module provides operating system-related utility methods and * properties. It can be accessed using: * * ```js - * const os = require('os'); + * const os = require('node:os'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/os.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/os.js) */ declare module 'os' { interface CpuInfo { @@ -75,6 +75,7 @@ declare module 'os' { function totalmem(): number; /** * Returns an array of objects containing information about each logical CPU core. + * The array will be empty if no CPU information is available, such as if the`/proc` file system is unavailable. * * The properties included on each object include: * @@ -88,8 +89,8 @@ declare module 'os' { * nice: 0, * sys: 30340, * idle: 1070356870, - * irq: 0 - * } + * irq: 0, + * }, * }, * { * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', @@ -99,8 +100,8 @@ declare module 'os' { * nice: 0, * sys: 26980, * idle: 1071569080, - * irq: 0 - * } + * irq: 0, + * }, * }, * { * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', @@ -110,8 +111,8 @@ declare module 'os' { * nice: 0, * sys: 21750, * idle: 1070919370, - * irq: 0 - * } + * irq: 0, + * }, * }, * { * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', @@ -121,17 +122,28 @@ declare module 'os' { * nice: 0, * sys: 19430, * idle: 1070905480, - * irq: 20 - * } + * irq: 20, + * }, * }, * ] * ``` * * `nice` values are POSIX-only. On Windows, the `nice` values of all processors * are always 0. + * + * `os.cpus().length` should not be used to calculate the amount of parallelism + * available to an application. Use {@link availableParallelism} for this purpose. * @since v0.3.3 */ function cpus(): CpuInfo[]; + /** + * Returns an estimate of the default amount of parallelism a program should use. + * Always returns a value greater than zero. + * + * This function is a small wrapper about libuv's [`uv_available_parallelism()`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_available_parallelism). + * @since v19.4.0, v18.14.0 + */ + function availableParallelism(): number; /** * Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it * returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows. @@ -415,12 +427,11 @@ declare module 'os' { */ function platform(): NodeJS.Platform; /** - * Returns the machine type as a string, such as arm, aarch64, mips, mips64, ppc64, ppc64le, s390, s390x, i386, i686, x86_64. + * Returns the machine type as a string, such as `arm`, `arm64`, `aarch64`,`mips`, `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`. * - * On POSIX systems, the machine type is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). - * On Windows, `RtlGetVersion()` is used, and if it is not available, `GetVersionExW()` will be used. - * See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information. - * @since v18.9.0 + * On POSIX systems, the machine type is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not + * available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information. + * @since v18.9.0, v16.18.0 */ function machine(): string; /** diff --git a/node_modules/@types/node/ts4.8/path.d.ts b/node_modules/@types/node/ts4.8/path.d.ts index 2d643b29b..723d5daab 100755 --- a/node_modules/@types/node/ts4.8/path.d.ts +++ b/node_modules/@types/node/ts4.8/path.d.ts @@ -7,13 +7,13 @@ declare module 'path/win32' { export = path; } /** - * The `path` module provides utilities for working with file and directory paths. - * It can be accessed using: + * The `node:path` module provides utilities for working with file and directory + * paths. It can be accessed using: * * ```js - * const path = require('path'); + * const path = require('node:path'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/path.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/path.js) */ declare module 'path' { namespace path { @@ -122,10 +122,10 @@ declare module 'path' { * Often used to extract the file name from a fully qualified path. * * @param path the path to evaluate. - * @param ext optionally, an extension to remove from the result. + * @param suffix optionally, an extension to remove from the result. * @throws {TypeError} if `path` is not a string or if `ext` is given and is not a string. */ - basename(path: string, ext?: string): string; + basename(path: string, suffix?: string): string; /** * Return the extension of the path, from the last '.' to end of string in the last portion of the path. * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string. diff --git a/node_modules/@types/node/ts4.8/perf_hooks.d.ts b/node_modules/@types/node/ts4.8/perf_hooks.d.ts index cf02a16e7..c090e1df6 100755 --- a/node_modules/@types/node/ts4.8/perf_hooks.d.ts +++ b/node_modules/@types/node/ts4.8/perf_hooks.d.ts @@ -7,9 +7,10 @@ * * [High Resolution Time](https://www.w3.org/TR/hr-time-2) * * [Performance Timeline](https://w3c.github.io/performance-timeline/) * * [User Timing](https://www.w3.org/TR/user-timing/) + * * [Resource Timing](https://www.w3.org/TR/resource-timing-2/) * * ```js - * const { PerformanceObserver, performance } = require('perf_hooks'); + * const { PerformanceObserver, performance } = require('node:perf_hooks'); * * const obs = new PerformanceObserver((items) => { * console.log(items.getEntries()[0].duration); @@ -26,7 +27,7 @@ * performance.measure('A to B', 'A', 'B'); * }); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/perf_hooks.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/perf_hooks.js) */ declare module 'perf_hooks' { import { AsyncResource } from 'node:async_hooks'; @@ -46,6 +47,7 @@ declare module 'perf_hooks' { readonly flags?: number | undefined; } /** + * The constructor of this class is not exposed to users directly. * @since v8.5.0 */ class PerformanceEntry { @@ -87,10 +89,20 @@ declare module 'perf_hooks' { readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type. toJSON(): any; } + /** + * Exposes marks created via the `Performance.mark()` method. + * @since v18.2.0, v16.17.0 + */ class PerformanceMark extends PerformanceEntry { readonly duration: 0; readonly entryType: 'mark'; } + /** + * Exposes measures created via the `Performance.measure()` method. + * + * The constructor of this class is not exposed to users directly. + * @since v18.2.0, v16.17.0 + */ class PerformanceMeasure extends PerformanceEntry { readonly entryType: 'measure'; } @@ -288,8 +300,8 @@ declare module 'perf_hooks' { * ```js * const { * performance, - * PerformanceObserver - * } = require('perf_hooks'); + * PerformanceObserver, + * } = require('node:perf_hooks'); * * const obs = new PerformanceObserver((perfObserverList, observer) => { * console.log(perfObserverList.getEntries()); @@ -330,8 +342,8 @@ declare module 'perf_hooks' { * ```js * const { * performance, - * PerformanceObserver - * } = require('perf_hooks'); + * PerformanceObserver, + * } = require('node:perf_hooks'); * * const obs = new PerformanceObserver((perfObserverList, observer) => { * console.log(perfObserverList.getEntriesByName('meow')); @@ -379,8 +391,8 @@ declare module 'perf_hooks' { * ```js * const { * performance, - * PerformanceObserver - * } = require('perf_hooks'); + * PerformanceObserver, + * } = require('node:perf_hooks'); * * const obs = new PerformanceObserver((perfObserverList, observer) => { * console.log(perfObserverList.getEntriesByType('mark')); @@ -414,6 +426,9 @@ declare module 'perf_hooks' { getEntriesByType(type: EntryType): PerformanceEntry[]; } type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void; + /** + * @since v8.5.0 + */ class PerformanceObserver extends AsyncResource { constructor(callback: PerformanceObserverCallback); /** @@ -427,8 +442,8 @@ declare module 'perf_hooks' { * ```js * const { * performance, - * PerformanceObserver - * } = require('perf_hooks'); + * PerformanceObserver, + * } = require('node:perf_hooks'); * * const obs = new PerformanceObserver((list, observer) => { * // Called once asynchronously. `list` contains three items. @@ -547,11 +562,10 @@ declare module 'perf_hooks' { */ recordDelta(): void; /** - * Adds the values from other to this histogram. + * Adds the values from `other` to this histogram. * @since v17.4.0, v16.14.0 - * @param other Recordable Histogram to combine with */ - add(other: RecordableHistogram): void; + add(other: RecordableHistogram): void; } /** * _This property is an extension by Node.js. It is not available in Web browsers._ @@ -566,7 +580,7 @@ declare module 'perf_hooks' { * detect. * * ```js - * const { monitorEventLoopDelay } = require('perf_hooks'); + * const { monitorEventLoopDelay } = require('node:perf_hooks'); * const h = monitorEventLoopDelay({ resolution: 20 }); * h.enable(); * // Do something. @@ -604,6 +618,20 @@ declare module 'perf_hooks' { * @since v15.9.0, v14.18.0 */ function createHistogram(options?: CreateHistogramOptions): RecordableHistogram; + import { performance as _performance } from 'perf_hooks'; + global { + /** + * `performance` is a global reference for `require('perf_hooks').performance` + * https://nodejs.org/api/globals.html#performance + * @since v16.0.0 + */ + var performance: typeof globalThis extends { + onmessage: any; + performance: infer T; + } + ? T + : typeof _performance; + } } declare module 'node:perf_hooks' { export * from 'perf_hooks'; diff --git a/node_modules/@types/node/ts4.8/process.d.ts b/node_modules/@types/node/ts4.8/process.d.ts index 12148f911..8f093ee91 100755 --- a/node_modules/@types/node/ts4.8/process.d.ts +++ b/node_modules/@types/node/ts4.8/process.d.ts @@ -250,7 +250,7 @@ declare module 'process' { * For example, to copy `process.stdin` to `process.stdout`: * * ```js - * import { stdin, stdout } from 'process'; + * import { stdin, stdout } from 'node:process'; * * stdin.pipe(stdout); * ``` @@ -297,7 +297,7 @@ declare module 'process' { * For example, assuming the following script for `process-args.js`: * * ```js - * import { argv } from 'process'; + * import { argv } from 'node:process'; * * // print process.argv * argv.forEach((val, index) => { @@ -389,7 +389,7 @@ declare module 'process' { * the specified `directory` does not exist). * * ```js - * import { chdir, cwd } from 'process'; + * import { chdir, cwd } from 'node:process'; * * console.log(`Starting directory: ${cwd()}`); * try { @@ -409,7 +409,7 @@ declare module 'process' { * process. * * ```js - * import { cwd } from 'process'; + * import { cwd } from 'node:process'; * * console.log(`Current directory: ${cwd()}`); * ``` @@ -420,7 +420,7 @@ declare module 'process' { * The port used by the Node.js debugger when enabled. * * ```js - * import process from 'process'; + * import process from 'node:process'; * * process.debugPort = 5858; * ``` @@ -432,12 +432,12 @@ declare module 'process' { * specific process warnings. These can be listened for by adding a handler to the `'warning'` event. * * ```js - * import { emitWarning } from 'process'; + * import { emitWarning } from 'node:process'; * * // Emit a warning with a code and additional detail. * emitWarning('Something happened!', { * code: 'MY_WARNING', - * detail: 'This is some additional information' + * detail: 'This is some additional information', * }); * // Emits: * // (node:56338) [MY_WARNING] Warning: Something happened! @@ -447,7 +447,7 @@ declare module 'process' { * In this example, an `Error` object is generated internally by`process.emitWarning()` and passed through to the `'warning'` handler. * * ```js - * import process from 'process'; + * import process from 'node:process'; * * process.on('warning', (warning) => { * console.warn(warning.name); // 'Warning' @@ -499,7 +499,7 @@ declare module 'process' { * While the following will: * * ```js - * import { env } from 'process'; + * import { env } from 'node:process'; * * env.foo = 'bar'; * console.log(env.foo); @@ -510,7 +510,7 @@ declare module 'process' { * throw an error when the value is not a string, number, or boolean. * * ```js - * import { env } from 'process'; + * import { env } from 'node:process'; * * env.test = null; * console.log(env.test); @@ -523,7 +523,7 @@ declare module 'process' { * Use `delete` to delete a property from `process.env`. * * ```js - * import { env } from 'process'; + * import { env } from 'node:process'; * * env.TEST = 1; * delete env.TEST; @@ -534,7 +534,7 @@ declare module 'process' { * On Windows operating systems, environment variables are case-insensitive. * * ```js - * import { env } from 'process'; + * import { env } from 'node:process'; * * env.TEST = 1; * console.log(env.test); @@ -543,7 +543,7 @@ declare module 'process' { * * Unless explicitly specified when creating a `Worker` instance, * each `Worker` thread has its own copy of `process.env`, based on its - * parent thread’s `process.env`, or whatever was specified as the `env` option + * parent thread's `process.env`, or whatever was specified as the `env` option * to the `Worker` constructor. Changes to `process.env` will not be visible * across `Worker` threads, and only the main thread can make changes that * are visible to the operating system or to native add-ons. @@ -560,7 +560,7 @@ declare module 'process' { * To exit with a 'failure' code: * * ```js - * import { exit } from 'process'; + * import { exit } from 'node:process'; * * exit(1); * ``` @@ -579,7 +579,7 @@ declare module 'process' { * truncated and lost: * * ```js - * import { exit } from 'process'; + * import { exit } from 'node:process'; * * // This is an example of what *not* to do: * if (someConditionNotMet()) { @@ -596,7 +596,7 @@ declare module 'process' { * scheduling any additional work for the event loop: * * ```js - * import process from 'process'; + * import process from 'node:process'; * * // How to properly set the exit code while letting * // the process exit gracefully. @@ -613,7 +613,7 @@ declare module 'process' { * In `Worker` threads, this function stops the current thread rather * than the current process. * @since v0.1.13 - * @param [code=0] The exit code. + * @param [code=0] The exit code. For string type, only integer strings (e.g.,'1') are allowed. */ exit(code?: number): never; /** @@ -873,7 +873,7 @@ declare module 'process' { * The `process.version` property contains the Node.js version string. * * ```js - * import { version } from 'process'; + * import { version } from 'node:process'; * * console.log(`Version: ${version}`); * // Version: v14.8.0 @@ -890,7 +890,7 @@ declare module 'process' { * to load modules that were compiled against a different module ABI version. * * ```js - * import { versions } from 'process'; + * import { versions } from 'node:process'; * * console.log(versions); * ``` @@ -918,10 +918,10 @@ declare module 'process' { */ readonly versions: ProcessVersions; /** - * The `process.config` property returns an `Object` containing the JavaScript - * representation of the configure options used to compile the current Node.js - * executable. This is the same as the `config.gypi` file that was produced when - * running the `./configure` script. + * The `process.config` property returns a frozen `Object` containing the + * JavaScript representation of the configure options used to compile the current + * Node.js executable. This is the same as the `config.gypi` file that was produced + * when running the `./configure` script. * * An example of the possible output looks like: * @@ -943,7 +943,6 @@ declare module 'process' { * node_shared_http_parser: 'false', * node_shared_libuv: 'false', * node_shared_zlib: 'false', - * node_use_dtrace: 'false', * node_use_openssl: 'true', * node_shared_openssl: 'false', * strict_aliasing: 'true', @@ -952,13 +951,6 @@ declare module 'process' { * } * } * ``` - * - * The `process.config` property is **not** read-only and there are existing - * modules in the ecosystem that are known to extend, modify, or entirely replace - * the value of `process.config`. - * - * Modifying the `process.config` property, or any child-property of the`process.config` object has been deprecated. The `process.config` will be made - * read-only in a future release. * @since v0.7.7 */ readonly config: ProcessConfig; @@ -977,7 +969,7 @@ declare module 'process' { * other than kill the target process. * * ```js - * import process, { kill } from 'process'; + * import process, { kill } from 'node:process'; * * process.on('SIGHUP', () => { * console.log('Got SIGHUP signal.'); @@ -1002,7 +994,7 @@ declare module 'process' { * The `process.pid` property returns the PID of the process. * * ```js - * import { pid } from 'process'; + * import { pid } from 'node:process'; * * console.log(`This process is pid ${pid}`); * ``` @@ -1014,7 +1006,7 @@ declare module 'process' { * current process. * * ```js - * import { ppid } from 'process'; + * import { ppid } from 'node:process'; * * console.log(`The parent process is pid ${ppid}`); * ``` @@ -1044,7 +1036,7 @@ declare module 'process' { * Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`,`'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`. * * ```js - * import { arch } from 'process'; + * import { arch } from 'node:process'; * * console.log(`This processor architecture is ${arch}`); * ``` @@ -1066,7 +1058,7 @@ declare module 'process' { * * `'win32'` * * ```js - * import { platform } from 'process'; + * import { platform } from 'node:process'; * * console.log(`This platform is ${platform}`); * ``` @@ -1089,6 +1081,17 @@ declare module 'process' { */ mainModule?: Module | undefined; memoryUsage: MemoryUsageFn; + /** + * Gets the amount of memory available to the process (in bytes) based on + * limits imposed by the OS. If there is no such constraint, or the constraint + * is unknown, `undefined` is returned. + * + * See [`uv_get_constrained_memory`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_get_constrained_memory) for more + * information. + * @since v19.6.0, v18.15.0 + * @experimental + */ + constrainedMemory(): number | undefined; /** * The `process.cpuUsage()` method returns the user and system CPU time usage of * the current process, in an object with properties `user` and `system`, whose @@ -1100,7 +1103,7 @@ declare module 'process' { * argument to the function, to get a diff reading. * * ```js - * import { cpuUsage } from 'process'; + * import { cpuUsage } from 'node:process'; * * const startUsage = cpuUsage(); * // { user: 38579, system: 6986 } @@ -1124,7 +1127,7 @@ declare module 'process' { * See the [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick) guide for more background. * * ```js - * import { nextTick } from 'process'; + * import { nextTick } from 'node:process'; * * console.log('start'); * nextTick(() => { @@ -1142,7 +1145,7 @@ declare module 'process' { * I/O has occurred: * * ```js - * import { nextTick } from 'process'; + * import { nextTick } from 'node:process'; * * function MyThing(options) { * this.setupOptions(options); @@ -1190,7 +1193,7 @@ declare module 'process' { * The following approach is much better: * * ```js - * import { nextTick } from 'process'; + * import { nextTick } from 'node:process'; * * function definitelyAsync(arg, cb) { * if (arg) { @@ -1215,10 +1218,10 @@ declare module 'process' { * ```js * { * name: 'node', - * lts: 'Erbium', - * sourceUrl: 'https://nodejs.org/download/release/v12.18.1/node-v12.18.1.tar.gz', - * headersUrl: 'https://nodejs.org/download/release/v12.18.1/node-v12.18.1-headers.tar.gz', - * libUrl: 'https://nodejs.org/download/release/v12.18.1/win-x64/node.lib' + * lts: 'Hydrogen', + * sourceUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0.tar.gz', + * headersUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0-headers.tar.gz', + * libUrl: 'https://nodejs.org/download/release/v18.12.0/win-x64/node.lib' * } * ``` * @@ -1322,7 +1325,7 @@ declare module 'process' { * dashes: * * ```js - * import { allowedNodeEnvironmentFlags } from 'process'; + * import { allowedNodeEnvironmentFlags } from 'node:process'; * * allowedNodeEnvironmentFlags.forEach((flag) => { * // -r @@ -1348,7 +1351,7 @@ declare module 'process' { report?: ProcessReport | undefined; /** * ```js - * import { resourceUsage } from 'process'; + * import { resourceUsage } from 'node:process'; * * console.log(resourceUsage()); * /* diff --git a/node_modules/@types/node/ts4.8/punycode.d.ts b/node_modules/@types/node/ts4.8/punycode.d.ts index 87ebbb904..892720728 100755 --- a/node_modules/@types/node/ts4.8/punycode.d.ts +++ b/node_modules/@types/node/ts4.8/punycode.d.ts @@ -24,7 +24,7 @@ * made available to developers as a convenience. Fixes or other modifications to * the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project. * @deprecated Since v7.0.0 - Deprecated - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/punycode.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/punycode.js) */ declare module 'punycode' { /** diff --git a/node_modules/@types/node/ts4.8/querystring.d.ts b/node_modules/@types/node/ts4.8/querystring.d.ts index e694d8c84..e9d087c27 100755 --- a/node_modules/@types/node/ts4.8/querystring.d.ts +++ b/node_modules/@types/node/ts4.8/querystring.d.ts @@ -1,15 +1,15 @@ /** - * The `querystring` module provides utilities for parsing and formatting URL + * The `node:querystring` module provides utilities for parsing and formatting URL * query strings. It can be accessed using: * * ```js - * const querystring = require('querystring'); + * const querystring = require('node:querystring'); * ``` * - * The `querystring` API is considered Legacy. While it is still maintained, - * new code should use the `URLSearchParams` API instead. - * @deprecated Legacy - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/querystring.js) + * `querystring` is more performant than `URLSearchParams` but is not a + * standardized API. Use `URLSearchParams` when performance is not critical or + * when compatibility with browser code is desirable. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/querystring.js) */ declare module 'querystring' { interface StringifyOptions { diff --git a/node_modules/@types/node/ts4.8/readline.d.ts b/node_modules/@types/node/ts4.8/readline.d.ts index 6ab64acbb..e6f7b0abb 100755 --- a/node_modules/@types/node/ts4.8/readline.d.ts +++ b/node_modules/@types/node/ts4.8/readline.d.ts @@ -1,5 +1,5 @@ /** - * The `readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time. + * The `node:readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time. * * To use the promise-based APIs: * @@ -13,7 +13,7 @@ * import * as readline from 'node:readline'; * ``` * - * The following simple example illustrates the basic use of the `readline` module. + * The following simple example illustrates the basic use of the `node:readline`module. * * ```js * import * as readline from 'node:readline/promises'; @@ -30,12 +30,11 @@ * * Once this code is invoked, the Node.js application will not terminate until the`readline.Interface` is closed because the interface waits for data to be * received on the `input` stream. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/readline.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/readline.js) */ declare module 'readline' { import { Abortable, EventEmitter } from 'node:events'; import * as promises from 'node:readline/promises'; - export { promises }; export interface Key { sequence?: string | undefined; @@ -74,7 +73,7 @@ declare module 'readline' { * const showResults = debounce(() => { * console.log( * '\n', - * values.filter((val) => val.startsWith(rl.line)).join(' ') + * values.filter((val) => val.startsWith(rl.line)).join(' '), * ); * }, 300); * process.stdin.on('keypress', (c, k) => { @@ -100,7 +99,7 @@ declare module 'readline' { * > Instances of the `readline.Interface` class are constructed using the * > `readline.createInterface()` method. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor */ protected constructor(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean); /** @@ -109,12 +108,12 @@ declare module 'readline' { * > Instances of the `readline.Interface` class are constructed using the * > `readline.createInterface()` method. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor */ protected constructor(options: ReadLineOptions); /** * The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`. - * @since v15.3.0 + * @since v15.3.0, v14.17.0 * @return the current prompt string */ getPrompt(): string; @@ -124,13 +123,13 @@ declare module 'readline' { */ setPrompt(prompt: string): void; /** - * The `rl.prompt()` method writes the `readline.Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new + * The `rl.prompt()` method writes the `Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new * location at which to provide input. * * When called, `rl.prompt()` will resume the `input` stream if it has been * paused. * - * If the `readline.Interface` was created with `output` set to `null` or`undefined` the prompt is not written. + * If the `Interface` was created with `output` set to `null` or`undefined` the prompt is not written. * @since v0.1.98 * @param preserveCursor If `true`, prevents the cursor placement from being reset to `0`. */ @@ -142,12 +141,14 @@ declare module 'readline' { * When called, `rl.question()` will resume the `input` stream if it has been * paused. * - * If the `readline.Interface` was created with `output` set to `null` or`undefined` the `query` is not written. + * If the `Interface` was created with `output` set to `null` or`undefined` the `query` is not written. * * The `callback` function passed to `rl.question()` does not follow the typical * pattern of accepting an `Error` object or `null` as the first argument. * The `callback` is called with the provided answer as the only argument. * + * An error will be thrown if calling `rl.question()` after `rl.close()`. + * * Example usage: * * ```js @@ -172,25 +173,6 @@ declare module 'readline' { * * setTimeout(() => ac.abort(), 10000); * ``` - * - * If this method is invoked as it's util.promisify()ed version, it returns a - * Promise that fulfills with the answer. If the question is canceled using - * an `AbortController` it will reject with an `AbortError`. - * - * ```js - * const util = require('util'); - * const question = util.promisify(rl.question).bind(rl); - * - * async function questionExample() { - * try { - * const answer = await question('What is you favorite food? '); - * console.log(`Oh, so your favorite food is ${answer}`); - * } catch (err) { - * console.error('Question rejected', err); - * } - * } - * questionExample(); - * ``` * @since v0.3.3 * @param query A statement or query to write to `output`, prepended to the prompt. * @param callback A callback function that is invoked with the user's input in response to the `query`. @@ -201,7 +183,7 @@ declare module 'readline' { * The `rl.pause()` method pauses the `input` stream, allowing it to be resumed * later if necessary. * - * Calling `rl.pause()` does not immediately pause other events (including`'line'`) from being emitted by the `readline.Interface` instance. + * Calling `rl.pause()` does not immediately pause other events (including`'line'`) from being emitted by the `Interface` instance. * @since v0.3.4 */ pause(): this; @@ -211,12 +193,12 @@ declare module 'readline' { */ resume(): this; /** - * The `rl.close()` method closes the `readline.Interface` instance and + * The `rl.close()` method closes the `Interface` instance and * relinquishes control over the `input` and `output` streams. When called, * the `'close'` event will be emitted. * * Calling `rl.close()` does not immediately stop other events (including `'line'`) - * from being emitted by the `readline.Interface` instance. + * from being emitted by the `Interface` instance. * @since v0.1.98 */ close(): void; @@ -231,7 +213,7 @@ declare module 'readline' { * When called, `rl.write()` will resume the `input` stream if it has been * paused. * - * If the `readline.Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written. + * If the `Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written. * * ```js * rl.write('Delete this!'); @@ -351,10 +333,10 @@ declare module 'readline' { * The `readline.createInterface()` method creates a new `readline.Interface`instance. * * ```js - * const readline = require('readline'); + * const readline = require('node:readline'); * const rl = readline.createInterface({ * input: process.stdin, - * output: process.stdout + * output: process.stdout, * }); * ``` * @@ -373,14 +355,8 @@ declare module 'readline' { * (`process.stdout` does this automatically when it is a TTY). * * When creating a `readline.Interface` using `stdin` as input, the program - * will not terminate until it receives `EOF` (Ctrl+D on - * Linux/macOS, Ctrl+Z followed by Return on - * Windows). - * If you want your application to exit without waiting for user input, you can `unref()` the standard input stream: - * - * ```js - * process.stdin.unref(); - * ``` + * will not terminate until it receives an [EOF character](https://en.wikipedia.org/wiki/End-of-file#EOF_character). To exit without + * waiting for user input, call `process.stdin.unref()`. * @since v0.1.98 */ export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface; @@ -408,11 +384,11 @@ declare module 'readline' { * implement a small command-line interface: * * ```js - * const readline = require('readline'); + * const readline = require('node:readline'); * const rl = readline.createInterface({ * input: process.stdin, * output: process.stdout, - * prompt: 'OHAI> ' + * prompt: 'OHAI> ', * }); * * rl.prompt(); @@ -440,15 +416,15 @@ declare module 'readline' { * well as a `for await...of` loop: * * ```js - * const fs = require('fs'); - * const readline = require('readline'); + * const fs = require('node:fs'); + * const readline = require('node:readline'); * * async function processLineByLine() { * const fileStream = fs.createReadStream('input.txt'); * * const rl = readline.createInterface({ * input: fileStream, - * crlfDelay: Infinity + * crlfDelay: Infinity, * }); * // Note: we use the crlfDelay option to recognize all instances of CR LF * // ('\r\n') in input.txt as a single line break. @@ -465,12 +441,12 @@ declare module 'readline' { * Alternatively, one could use the `'line'` event: * * ```js - * const fs = require('fs'); - * const readline = require('readline'); + * const fs = require('node:fs'); + * const readline = require('node:readline'); * * const rl = readline.createInterface({ * input: fs.createReadStream('sample.txt'), - * crlfDelay: Infinity + * crlfDelay: Infinity, * }); * * rl.on('line', (line) => { @@ -481,15 +457,15 @@ declare module 'readline' { * Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied: * * ```js - * const { once } = require('events'); - * const { createReadStream } = require('fs'); - * const { createInterface } = require('readline'); + * const { once } = require('node:events'); + * const { createReadStream } = require('node:fs'); + * const { createInterface } = require('node:readline'); * * (async function processLineByLine() { * try { * const rl = createInterface({ * input: createReadStream('big-file.txt'), - * crlfDelay: Infinity + * crlfDelay: Infinity, * }); * * rl.on('line', (line) => { @@ -539,109 +515,6 @@ declare module 'readline' { /** * The `readline.moveCursor()` method moves the cursor _relative_ to its current * position in a given `TTY` `stream`. - * - * ## Example: Tiny CLI - * - * The following example illustrates the use of `readline.Interface` class to - * implement a small command-line interface: - * - * ```js - * const readline = require('readline'); - * const rl = readline.createInterface({ - * input: process.stdin, - * output: process.stdout, - * prompt: 'OHAI> ' - * }); - * - * rl.prompt(); - * - * rl.on('line', (line) => { - * switch (line.trim()) { - * case 'hello': - * console.log('world!'); - * break; - * default: - * console.log(`Say what? I might have heard '${line.trim()}'`); - * break; - * } - * rl.prompt(); - * }).on('close', () => { - * console.log('Have a great day!'); - * process.exit(0); - * }); - * ``` - * - * ## Example: Read file stream line-by-Line - * - * A common use case for `readline` is to consume an input file one line at a - * time. The easiest way to do so is leveraging the `fs.ReadStream` API as - * well as a `for await...of` loop: - * - * ```js - * const fs = require('fs'); - * const readline = require('readline'); - * - * async function processLineByLine() { - * const fileStream = fs.createReadStream('input.txt'); - * - * const rl = readline.createInterface({ - * input: fileStream, - * crlfDelay: Infinity - * }); - * // Note: we use the crlfDelay option to recognize all instances of CR LF - * // ('\r\n') in input.txt as a single line break. - * - * for await (const line of rl) { - * // Each line in input.txt will be successively available here as `line`. - * console.log(`Line from file: ${line}`); - * } - * } - * - * processLineByLine(); - * ``` - * - * Alternatively, one could use the `'line'` event: - * - * ```js - * const fs = require('fs'); - * const readline = require('readline'); - * - * const rl = readline.createInterface({ - * input: fs.createReadStream('sample.txt'), - * crlfDelay: Infinity - * }); - * - * rl.on('line', (line) => { - * console.log(`Line from file: ${line}`); - * }); - * ``` - * - * Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied: - * - * ```js - * const { once } = require('events'); - * const { createReadStream } = require('fs'); - * const { createInterface } = require('readline'); - * - * (async function processLineByLine() { - * try { - * const rl = createInterface({ - * input: createReadStream('big-file.txt'), - * crlfDelay: Infinity - * }); - * - * rl.on('line', (line) => { - * // Process the line. - * }); - * - * await once(rl, 'close'); - * - * console.log('File processed.'); - * } catch (err) { - * console.error(err); - * } - * })(); - * ``` * @since v0.7.7 * @param callback Invoked once the operation completes. * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. diff --git a/node_modules/@types/node/ts4.8/readline/promises.d.ts b/node_modules/@types/node/ts4.8/readline/promises.d.ts index 8f9f06f0b..079fbdf86 100755 --- a/node_modules/@types/node/ts4.8/readline/promises.d.ts +++ b/node_modules/@types/node/ts4.8/readline/promises.d.ts @@ -1,23 +1,28 @@ /** - * The `readline/promise` module provides an API for reading lines of input from a Readable stream one line at a time. - * - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/readline/promises.js) * @since v17.0.0 + * @experimental */ declare module 'readline/promises' { import { Interface as _Interface, ReadLineOptions, Completer, AsyncCompleter, Direction } from 'node:readline'; import { Abortable } from 'node:events'; - + /** + * Instances of the `readlinePromises.Interface` class are constructed using the`readlinePromises.createInterface()` method. Every instance is associated with a + * single `input` `Readable` stream and a single `output` `Writable` stream. + * The `output` stream is used to print prompts for user input that arrives on, + * and is read from, the `input` stream. + * @since v17.0.0 + */ class Interface extends _Interface { /** - * The rl.question() method displays the query by writing it to the output, waits for user input to be provided on input, - * then invokes the callback function passing the provided input as the first argument. + * The `rl.question()` method displays the `query` by writing it to the `output`, + * waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument. * - * When called, rl.question() will resume the input stream if it has been paused. + * When called, `rl.question()` will resume the `input` stream if it has been + * paused. * - * If the readlinePromises.Interface was created with output set to null or undefined the query is not written. + * If the `Interface` was created with `output` set to `null` or`undefined` the `query` is not written. * - * If the question is called after rl.close(), it returns a rejected promise. + * If the question is called after `rl.close()`, it returns a rejected promise. * * Example usage: * @@ -26,7 +31,7 @@ declare module 'readline/promises' { * console.log(`Oh, so your favorite food is ${answer}`); * ``` * - * Using an AbortSignal to cancel a question. + * Using an `AbortSignal` to cancel a question. * * ```js * const signal = AbortSignal.timeout(10_000); @@ -38,61 +43,87 @@ declare module 'readline/promises' { * const answer = await rl.question('What is your favorite food? ', { signal }); * console.log(`Oh, so your favorite food is ${answer}`); * ``` - * * @since v17.0.0 - * @param query A statement or query to write to output, prepended to the prompt. + * @param query A statement or query to write to `output`, prepended to the prompt. + * @return A promise that is fulfilled with the user's input in response to the `query`. */ question(query: string): Promise; question(query: string, options: Abortable): Promise; } - + /** + * @since v17.0.0 + */ class Readline { /** * @param stream A TTY stream. */ - constructor(stream: NodeJS.WritableStream, options?: { autoCommit?: boolean }); + constructor( + stream: NodeJS.WritableStream, + options?: { + autoCommit?: boolean; + } + ); /** - * The `rl.clearLine()` method adds to the internal list of pending action an action that clears current line of the associated `stream` in a specified direction identified by `dir`. - * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor. + * The `rl.clearLine()` method adds to the internal list of pending action an + * action that clears current line of the associated `stream` in a specified + * direction identified by `dir`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this */ clearLine(dir: Direction): this; /** - * The `rl.clearScreenDown()` method adds to the internal list of pending action an action that clears the associated `stream` from the current position of the cursor down. - * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor. + * The `rl.clearScreenDown()` method adds to the internal list of pending action an + * action that clears the associated stream from the current position of the + * cursor down. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this */ clearScreenDown(): this; /** - * The `rl.commit()` method sends all the pending actions to the associated `stream` and clears the internal list of pending actions. + * The `rl.commit()` method sends all the pending actions to the associated`stream` and clears the internal list of pending actions. + * @since v17.0.0 */ commit(): Promise; /** - * The `rl.cursorTo()` method adds to the internal list of pending action an action that moves cursor to the specified position in the associated `stream`. - * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor. + * The `rl.cursorTo()` method adds to the internal list of pending action an action + * that moves cursor to the specified position in the associated `stream`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this */ cursorTo(x: number, y?: number): this; /** - * The `rl.moveCursor()` method adds to the internal list of pending action an action that moves the cursor relative to its current position in the associated `stream`. - * Call `rl.commit()` to see the effect of this method, unless autoCommit: true was passed to the constructor. + * The `rl.moveCursor()` method adds to the internal list of pending action an + * action that moves the cursor _relative_ to its current position in the + * associated `stream`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this */ moveCursor(dx: number, dy: number): this; /** - * The `rl.rollback()` method clears the internal list of pending actions without sending it to the associated `stream`. + * The `rl.rollback` methods clears the internal list of pending actions without + * sending it to the associated `stream`. + * @since v17.0.0 + * @return this */ rollback(): this; } - /** - * The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface` instance. + * The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface`instance. * * ```js * const readlinePromises = require('node:readline/promises'); * const rl = readlinePromises.createInterface({ * input: process.stdin, - * output: process.stdout + * output: process.stdout, * }); * ``` * - * Once the `readlinePromises.Interface` instance is created, the most common case is to listen for the `'line'` event: + * Once the `readlinePromises.Interface` instance is created, the most common case + * is to listen for the `'line'` event: * * ```js * rl.on('line', (line) => { @@ -100,42 +131,13 @@ declare module 'readline/promises' { * }); * ``` * - * If `terminal` is `true` for this instance then the `output` stream will get the best compatibility if it defines an `output.columns` property, - * and emits a `'resize'` event on the `output`, if or when the columns ever change (`process.stdout` does this automatically when it is a TTY). - * - * ## Use of the `completer` function - * - * The `completer` function takes the current line entered by the user as an argument, and returns an `Array` with 2 entries: - * - * - An Array with matching entries for the completion. - * - The substring that was used for the matching. - * - * For instance: `[[substr1, substr2, ...], originalsubstring]`. - * - * ```js - * function completer(line) { - * const completions = '.help .error .exit .quit .q'.split(' '); - * const hits = completions.filter((c) => c.startsWith(line)); - * // Show all completions if none found - * return [hits.length ? hits : completions, line]; - * } - * ``` - * - * The `completer` function can also returns a `Promise`, or be asynchronous: - * - * ```js - * async function completer(linePartial) { - * await someAsyncWork(); - * return [['123'], linePartial]; - * } - * ``` + * If `terminal` is `true` for this instance then the `output` stream will get + * the best compatibility if it defines an `output.columns` property and emits + * a `'resize'` event on the `output` if or when the columns ever change + * (`process.stdout` does this automatically when it is a TTY). + * @since v17.0.0 */ - function createInterface( - input: NodeJS.ReadableStream, - output?: NodeJS.WritableStream, - completer?: Completer | AsyncCompleter, - terminal?: boolean, - ): Interface; + function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface; function createInterface(options: ReadLineOptions): Interface; } declare module 'node:readline/promises' { diff --git a/node_modules/@types/node/ts4.8/repl.d.ts b/node_modules/@types/node/ts4.8/repl.d.ts index be42ccc4a..c8147ed1b 100755 --- a/node_modules/@types/node/ts4.8/repl.d.ts +++ b/node_modules/@types/node/ts4.8/repl.d.ts @@ -1,12 +1,12 @@ /** - * The `repl` module provides a Read-Eval-Print-Loop (REPL) implementation that - * is available both as a standalone program or includible in other applications. - * It can be accessed using: + * The `node:repl` module provides a Read-Eval-Print-Loop (REPL) implementation + * that is available both as a standalone program or includible in other + * applications. It can be accessed using: * * ```js - * const repl = require('repl'); + * const repl = require('node:repl'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/repl.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/repl.js) */ declare module 'repl' { import { Interface, Completer, AsyncCompleter } from 'node:readline'; @@ -41,8 +41,8 @@ declare module 'repl' { * error with `repl.Recoverable` to indicate the input was incomplete and prompt for * additional lines. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_default_evaluation - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_custom_evaluation_functions + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_default_evaluation + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_custom_evaluation_functions */ eval?: REPLEval | undefined; /** @@ -74,13 +74,13 @@ declare module 'repl' { * The function to invoke to format the output of each command before writing to `output`. * Default: a wrapper for `util.inspect`. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_customizing_repl_output + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_customizing_repl_output */ writer?: REPLWriter | undefined; /** * An optional function used for custom Tab auto completion. * - * @see https://nodejs.org/dist/latest-v11.x/docs/api/readline.html#readline_use_of_the_completer_function + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#readline_use_of_the_completer_function */ completer?: Completer | AsyncCompleter | undefined; /** @@ -124,7 +124,7 @@ declare module 'repl' { * or directly using the JavaScript `new` keyword. * * ```js - * const repl = require('repl'); + * const repl = require('node:repl'); * * const options = { useColors: true }; * @@ -162,33 +162,33 @@ declare module 'repl' { /** * A value indicating whether the REPL is currently in "editor mode". * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_commands_and_special_keys + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_commands_and_special_keys */ readonly editorMode: boolean; /** * A value indicating whether the `_` variable has been assigned. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable */ readonly underscoreAssigned: boolean; /** * The last evaluation result from the REPL (assigned to the `_` variable inside of the REPL). * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable */ readonly last: any; /** * A value indicating whether the `_error` variable has been assigned. * * @since v9.8.0 - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable */ readonly underscoreErrAssigned: boolean; /** * The last error raised inside the REPL (assigned to the `_error` variable inside of the REPL). * * @since v9.8.0 - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable */ readonly lastError: any; /** @@ -240,7 +240,7 @@ declare module 'repl' { * * `REPLServer` cannot be subclassed due to implementation specifics in NodeJS. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_class_replserver + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_class_replserver */ private constructor(); /** @@ -251,7 +251,7 @@ declare module 'repl' { * The following example shows two new commands added to the REPL instance: * * ```js - * const repl = require('repl'); + * const repl = require('node:repl'); * * const replServer = repl.start({ prompt: '> ' }); * replServer.defineCommand('sayhello', { @@ -260,7 +260,7 @@ declare module 'repl' { * this.clearBufferedCommand(); * console.log(`Hello, ${name}!`); * this.displayPrompt(); - * } + * }, * }); * replServer.defineCommand('saybye', function saybye() { * console.log('Goodbye!'); @@ -401,7 +401,7 @@ declare module 'repl' { * If `options` is a string, then it specifies the input prompt: * * ```js - * const repl = require('repl'); + * const repl = require('node:repl'); * * // a Unix style prompt * repl.start('$ '); @@ -412,7 +412,7 @@ declare module 'repl' { /** * Indicates a recoverable error that a `REPLServer` can use to support multi-line input. * - * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_recoverable_errors + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_recoverable_errors */ class Recoverable extends SyntaxError { err: Error; diff --git a/node_modules/@types/node/ts4.8/stream.d.ts b/node_modules/@types/node/ts4.8/stream.d.ts index d478f335c..a6c80f9fc 100755 --- a/node_modules/@types/node/ts4.8/stream.d.ts +++ b/node_modules/@types/node/ts4.8/stream.d.ts @@ -1,23 +1,24 @@ /** * A stream is an abstract interface for working with streaming data in Node.js. - * The `stream` module provides an API for implementing the stream interface. + * The `node:stream` module provides an API for implementing the stream interface. * * There are many stream objects provided by Node.js. For instance, a `request to an HTTP server` and `process.stdout` are both stream instances. * * Streams can be readable, writable, or both. All streams are instances of `EventEmitter`. * - * To access the `stream` module: + * To access the `node:stream` module: * * ```js - * const stream = require('stream'); + * const stream = require('node:stream'); * ``` * - * The `stream` module is useful for creating new types of stream instances. It is - * usually not necessary to use the `stream` module to consume streams. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/stream.js) + * The `node:stream` module is useful for creating new types of stream instances. + * It is usually not necessary to use the `node:stream` module to consume streams. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/stream.js) */ declare module 'stream' { import { EventEmitter, Abortable } from 'node:events'; + import { Blob as NodeBlob } from 'node:buffer'; import * as streamPromises from 'node:stream/promises'; import * as streamConsumers from 'node:stream/consumers'; import * as streamWeb from 'node:stream/web'; @@ -123,12 +124,12 @@ declare module 'stream' { readonly readableObjectMode: boolean; /** * Is `true` after `readable.destroy()` has been called. - * @since v18.0.0 + * @since v8.0.0 */ destroyed: boolean; /** - * Is true after 'close' has been emitted. - * @since v8.0.0 + * Is `true` after `'close'` has been emitted. + * @since v18.0.0 */ readonly closed: boolean; /** @@ -309,7 +310,7 @@ declare module 'stream' { * the method does nothing. * * ```js - * const fs = require('fs'); + * const fs = require('node:fs'); * const readable = getReadableStreamSomehow(); * const writable = fs.createWriteStream('file.txt'); * // All the data from readable goes into 'file.txt', @@ -347,7 +348,7 @@ declare module 'stream' { * // Pull off a header delimited by \n\n. * // Use unshift() if we get too much. * // Call the callback with (error, header, stream). - * const { StringDecoder } = require('string_decoder'); + * const { StringDecoder } = require('node:string_decoder'); * function parseHeader(stream, callback) { * stream.on('error', callback); * stream.on('readable', onReadable); @@ -387,14 +388,14 @@ declare module 'stream' { * however it is best to simply avoid calling `readable.unshift()` while in the * process of performing a read. * @since v0.9.11 - * @param chunk Chunk of data to unshift onto the read queue. For streams not operating in object mode, `chunk` must be a string, `Buffer`, `Uint8Array` or `null`. For object mode + * @param chunk Chunk of data to unshift onto the read queue. For streams not operating in object mode, `chunk` must be a string, `Buffer`, `Uint8Array`, or `null`. For object mode * streams, `chunk` may be any JavaScript value. * @param encoding Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`. */ unshift(chunk: any, encoding?: BufferEncoding): void; /** - * Prior to Node.js 0.10, streams did not implement the entire `stream` module API - * as it is currently defined. (See `Compatibility` for more information.) + * Prior to Node.js 0.10, streams did not implement the entire `node:stream`module API as it is currently defined. (See `Compatibility` for more + * information.) * * When using an older Node.js library that emits `'data'` events and has a {@link pause} method that is advisory only, the`readable.wrap()` method can be used to create a `Readable` * stream that uses @@ -406,7 +407,7 @@ declare module 'stream' { * * ```js * const { OldReader } = require('./old-api-module.js'); - * const { Readable } = require('stream'); + * const { Readable } = require('node:stream'); * const oreader = new OldReader(); * const myReader = new Readable().wrap(oreader); * @@ -533,7 +534,7 @@ declare module 'stream' { static toWeb(streamWritable: Writable): streamWeb.WritableStream; /** * Is `true` if it is safe to call `writable.write()`, which means - * the stream has not been destroyed, errored or ended. + * the stream has not been destroyed, errored, or ended. * @since v11.4.0 */ readonly writable: boolean; @@ -577,8 +578,8 @@ declare module 'stream' { */ destroyed: boolean; /** - * Is true after 'close' has been emitted. - * @since v8.0.0 + * Is `true` after `'close'` has been emitted. + * @since v18.0.0 */ readonly closed: boolean; /** @@ -587,7 +588,7 @@ declare module 'stream' { */ readonly errored: Error | null; /** - * Is `true` if the stream's buffer has been full and stream will emit 'drain'. + * Is `true` if the stream's buffer has been full and stream will emit `'drain'`. * @since v15.2.0, v14.17.0 */ readonly writableNeedDrain: boolean; @@ -677,7 +678,7 @@ declare module 'stream' { * * ```js * // Write 'hello, ' and then end with 'world!'. - * const fs = require('fs'); + * const fs = require('node:fs'); * const file = fs.createWriteStream('example.txt'); * file.write('hello, '); * file.end('world!'); @@ -863,7 +864,7 @@ declare module 'stream' { /** * If `false` then the stream will automatically end the writable side when the * readable side ends. Set initially by the `allowHalfOpen` constructor option, - * which defaults to `false`. + * which defaults to `true`. * * This can be changed manually to change the half-open behavior of an existing`Duplex` stream instance, but must be changed before the `'end'` event is * emitted. @@ -892,7 +893,7 @@ declare module 'stream' { * * @since v16.8.0 */ - static from(src: Stream | Blob | ArrayBuffer | string | Iterable | AsyncIterable | AsyncGeneratorFunction | Promise | Object): Duplex; + static from(src: Stream | NodeBlob | ArrayBuffer | string | Iterable | AsyncIterable | AsyncGeneratorFunction | Promise | Object): Duplex; _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; _writev?( chunks: Array<{ @@ -911,6 +912,105 @@ declare module 'stream' { end(chunk: any, encoding?: BufferEncoding, cb?: () => void): this; cork(): void; uncork(): void; + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. data + * 3. drain + * 4. end + * 5. error + * 6. finish + * 7. pause + * 8. pipe + * 9. readable + * 10. resume + * 11. unpipe + */ + addListener(event: 'close', listener: () => void): this; + addListener(event: 'data', listener: (chunk: any) => void): this; + addListener(event: 'drain', listener: () => void): this; + addListener(event: 'end', listener: () => void): this; + addListener(event: 'error', listener: (err: Error) => void): this; + addListener(event: 'finish', listener: () => void): this; + addListener(event: 'pause', listener: () => void): this; + addListener(event: 'pipe', listener: (src: Readable) => void): this; + addListener(event: 'readable', listener: () => void): this; + addListener(event: 'resume', listener: () => void): this; + addListener(event: 'unpipe', listener: (src: Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: 'close'): boolean; + emit(event: 'data', chunk: any): boolean; + emit(event: 'drain'): boolean; + emit(event: 'end'): boolean; + emit(event: 'error', err: Error): boolean; + emit(event: 'finish'): boolean; + emit(event: 'pause'): boolean; + emit(event: 'pipe', src: Readable): boolean; + emit(event: 'readable'): boolean; + emit(event: 'resume'): boolean; + emit(event: 'unpipe', src: Readable): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: 'close', listener: () => void): this; + on(event: 'data', listener: (chunk: any) => void): this; + on(event: 'drain', listener: () => void): this; + on(event: 'end', listener: () => void): this; + on(event: 'error', listener: (err: Error) => void): this; + on(event: 'finish', listener: () => void): this; + on(event: 'pause', listener: () => void): this; + on(event: 'pipe', listener: (src: Readable) => void): this; + on(event: 'readable', listener: () => void): this; + on(event: 'resume', listener: () => void): this; + on(event: 'unpipe', listener: (src: Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: 'close', listener: () => void): this; + once(event: 'data', listener: (chunk: any) => void): this; + once(event: 'drain', listener: () => void): this; + once(event: 'end', listener: () => void): this; + once(event: 'error', listener: (err: Error) => void): this; + once(event: 'finish', listener: () => void): this; + once(event: 'pause', listener: () => void): this; + once(event: 'pipe', listener: (src: Readable) => void): this; + once(event: 'readable', listener: () => void): this; + once(event: 'resume', listener: () => void): this; + once(event: 'unpipe', listener: (src: Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: 'close', listener: () => void): this; + prependListener(event: 'data', listener: (chunk: any) => void): this; + prependListener(event: 'drain', listener: () => void): this; + prependListener(event: 'end', listener: () => void): this; + prependListener(event: 'error', listener: (err: Error) => void): this; + prependListener(event: 'finish', listener: () => void): this; + prependListener(event: 'pause', listener: () => void): this; + prependListener(event: 'pipe', listener: (src: Readable) => void): this; + prependListener(event: 'readable', listener: () => void): this; + prependListener(event: 'resume', listener: () => void): this; + prependListener(event: 'unpipe', listener: (src: Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: 'close', listener: () => void): this; + prependOnceListener(event: 'data', listener: (chunk: any) => void): this; + prependOnceListener(event: 'drain', listener: () => void): this; + prependOnceListener(event: 'end', listener: () => void): this; + prependOnceListener(event: 'error', listener: (err: Error) => void): this; + prependOnceListener(event: 'finish', listener: () => void): this; + prependOnceListener(event: 'pause', listener: () => void): this; + prependOnceListener(event: 'pipe', listener: (src: Readable) => void): this; + prependOnceListener(event: 'readable', listener: () => void): this; + prependOnceListener(event: 'resume', listener: () => void): this; + prependOnceListener(event: 'unpipe', listener: (src: Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: 'close', listener: () => void): this; + removeListener(event: 'data', listener: (chunk: any) => void): this; + removeListener(event: 'drain', listener: () => void): this; + removeListener(event: 'end', listener: () => void): this; + removeListener(event: 'error', listener: (err: Error) => void): this; + removeListener(event: 'finish', listener: () => void): this; + removeListener(event: 'pause', listener: () => void): this; + removeListener(event: 'pipe', listener: (src: Readable) => void): this; + removeListener(event: 'readable', listener: () => void): this; + removeListener(event: 'resume', listener: () => void): this; + removeListener(event: 'unpipe', listener: (src: Readable) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; } type TransformCallback = (error?: Error | null, data?: any) => void; interface TransformOptions extends DuplexOptions { @@ -952,18 +1052,21 @@ declare module 'stream' { */ class PassThrough extends Transform {} /** + * A stream to attach a signal to. + * * Attaches an AbortSignal to a readable or writeable stream. This lets code * control stream destruction using an `AbortController`. * - * Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`on the stream. + * Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`on the stream, and `controller.error(new + * AbortError())` for webstreams. * * ```js - * const fs = require('fs'); + * const fs = require('node:fs'); * * const controller = new AbortController(); * const read = addAbortSignal( * controller.signal, - * fs.createReadStream(('object.json')) + * fs.createReadStream(('object.json')), * ); * // Later, abort the operation closing the stream * controller.abort(); @@ -976,7 +1079,7 @@ declare module 'stream' { * setTimeout(() => controller.abort(), 10_000); // set a timeout * const stream = addAbortSignal( * controller.signal, - * fs.createReadStream(('object.json')) + * fs.createReadStream(('object.json')), * ); * (async () => { * try { @@ -992,22 +1095,70 @@ declare module 'stream' { * } * })(); * ``` + * + * Or using an `AbortSignal` with a ReadableStream: + * + * ```js + * const controller = new AbortController(); + * const rs = new ReadableStream({ + * start(controller) { + * controller.enqueue('hello'); + * controller.enqueue('world'); + * controller.close(); + * }, + * }); + * + * addAbortSignal(controller.signal, rs); + * + * finished(rs, (err) => { + * if (err) { + * if (err.name === 'AbortError') { + * // The operation was cancelled + * } + * } + * }); + * + * const reader = rs.getReader(); + * + * reader.read().then(({ value, done }) => { + * console.log(value); // hello + * console.log(done); // false + * controller.abort(); + * }); + * ``` * @since v15.4.0 * @param signal A signal representing possible cancellation * @param stream a stream to attach a signal to */ function addAbortSignal(signal: AbortSignal, stream: T): T; + /** + * Returns the default highWaterMark used by streams. + * Defaults to `16384` (16 KiB), or `16` for `objectMode`. + * @since v19.9.0 + * @param objectMode + */ + function getDefaultHighWaterMark(objectMode: boolean): number; + /** + * Sets the default highWaterMark used by streams. + * @since v19.9.0 + * @param objectMode + * @param value highWaterMark value + */ + function setDefaultHighWaterMark(objectMode: boolean, value: number): void; interface FinishedOptions extends Abortable { error?: boolean | undefined; readable?: boolean | undefined; writable?: boolean | undefined; } /** + * A readable and/or writable stream/webstream. + * * A function to get notified when a stream is no longer readable, writable * or has experienced an error or a premature close event. * * ```js - * const { finished } = require('stream'); + * const { finished } = require('node:stream'); + * const fs = require('node:fs'); * * const rs = fs.createReadStream('archive.tar'); * @@ -1025,21 +1176,7 @@ declare module 'stream' { * Especially useful in error handling scenarios where a stream is destroyed * prematurely (like an aborted HTTP request), and will not emit `'end'`or `'finish'`. * - * The `finished` API provides promise version: - * - * ```js - * const { finished } = require('stream/promises'); - * - * const rs = fs.createReadStream('archive.tar'); - * - * async function run() { - * await finished(rs); - * console.log('Stream is done reading.'); - * } - * - * run().catch(console.error); - * rs.resume(); // Drain the stream. - * ``` + * The `finished` API provides `promise version`. * * `stream.finished()` leaves dangling event listeners (in particular`'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been * invoked. The reason for this is so that unexpected `'error'` events (due to @@ -1079,16 +1216,17 @@ declare module 'stream' { : (err: NodeJS.ErrnoException | null) => void; type PipelinePromise> = S extends PipelineDestinationPromiseFunction ? Promise

: Promise; interface PipelineOptions { - signal: AbortSignal; + signal?: AbortSignal | undefined; + end?: boolean | undefined; } /** * A module method to pipe between streams and generators forwarding errors and * properly cleaning up and provide a callback when the pipeline is complete. * * ```js - * const { pipeline } = require('stream'); - * const fs = require('fs'); - * const zlib = require('zlib'); + * const { pipeline } = require('node:stream'); + * const fs = require('node:fs'); + * const zlib = require('node:zlib'); * * // Use the pipeline API to easily pipe a series of streams * // together and get notified when the pipeline is fully done. @@ -1105,95 +1243,11 @@ declare module 'stream' { * } else { * console.log('Pipeline succeeded.'); * } - * } + * }, * ); * ``` * - * The `pipeline` API provides a promise version, which can also - * receive an options argument as the last parameter with a`signal` `AbortSignal` property. When the signal is aborted,`destroy` will be called on the underlying pipeline, with - * an`AbortError`. - * - * ```js - * const { pipeline } = require('stream/promises'); - * - * async function run() { - * await pipeline( - * fs.createReadStream('archive.tar'), - * zlib.createGzip(), - * fs.createWriteStream('archive.tar.gz') - * ); - * console.log('Pipeline succeeded.'); - * } - * - * run().catch(console.error); - * ``` - * - * To use an `AbortSignal`, pass it inside an options object, - * as the last argument: - * - * ```js - * const { pipeline } = require('stream/promises'); - * - * async function run() { - * const ac = new AbortController(); - * const signal = ac.signal; - * - * setTimeout(() => ac.abort(), 1); - * await pipeline( - * fs.createReadStream('archive.tar'), - * zlib.createGzip(), - * fs.createWriteStream('archive.tar.gz'), - * { signal }, - * ); - * } - * - * run().catch(console.error); // AbortError - * ``` - * - * The `pipeline` API also supports async generators: - * - * ```js - * const { pipeline } = require('stream/promises'); - * const fs = require('fs'); - * - * async function run() { - * await pipeline( - * fs.createReadStream('lowercase.txt'), - * async function* (source, { signal }) { - * source.setEncoding('utf8'); // Work with strings rather than `Buffer`s. - * for await (const chunk of source) { - * yield await processChunk(chunk, { signal }); - * } - * }, - * fs.createWriteStream('uppercase.txt') - * ); - * console.log('Pipeline succeeded.'); - * } - * - * run().catch(console.error); - * ``` - * - * Remember to handle the `signal` argument passed into the async generator. - * Especially in the case where the async generator is the source for the - * pipeline (i.e. first argument) or the pipeline will never complete. - * - * ```js - * const { pipeline } = require('stream/promises'); - * const fs = require('fs'); - * - * async function run() { - * await pipeline( - * async function* ({ signal }) { - * await someLongRunningfn({ signal }); - * yield 'asd'; - * }, - * fs.createWriteStream('uppercase.txt') - * ); - * console.log('Pipeline succeeded.'); - * } - * - * run().catch(console.error); - * ``` + * The `pipeline` API provides a `promise version`. * * `stream.pipeline()` will call `stream.destroy(err)` on all streams except: * @@ -1212,9 +1266,9 @@ declare module 'stream' { * See the example below: * * ```js - * const fs = require('fs'); - * const http = require('http'); - * const { pipeline } = require('stream'); + * const fs = require('node:fs'); + * const http = require('node:http'); + * const { pipeline } = require('node:stream'); * * const server = http.createServer((req, res) => { * const fileStream = fs.createReadStream('./fileNotExist.txt'); @@ -1315,19 +1369,18 @@ declare module 'stream' { ref(): void; unref(): void; } - /** * Returns whether the stream has encountered an error. - * @since v17.3.0 + * @since v17.3.0, v16.14.0 + * @experimental */ function isErrored(stream: Readable | Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean; - /** * Returns whether the stream is readable. - * @since v17.4.0 + * @since v17.4.0, v16.14.0 + * @experimental */ function isReadable(stream: Readable | NodeJS.ReadableStream): boolean; - const promises: typeof streamPromises; const consumers: typeof streamConsumers; } diff --git a/node_modules/@types/node/ts4.8/stream/consumers.d.ts b/node_modules/@types/node/ts4.8/stream/consumers.d.ts index ce6c9bb78..2fd942443 100755 --- a/node_modules/@types/node/ts4.8/stream/consumers.d.ts +++ b/node_modules/@types/node/ts4.8/stream/consumers.d.ts @@ -1,22 +1,10 @@ -// Duplicates of interface in lib.dom.ts. -// Duplicated here rather than referencing lib.dom.ts because doing so causes lib.dom.ts to be loaded for "test-all" -// Which in turn causes tests to pass that shouldn't pass. -// -// This interface is not, and should not be, exported. -interface Blob { - readonly size: number; - readonly type: string; - arrayBuffer(): Promise; - slice(start?: number, end?: number, contentType?: string): Blob; - stream(): NodeJS.ReadableStream; - text(): Promise; -} declare module 'stream/consumers' { + import { Blob as NodeBlob } from 'node:buffer'; import { Readable } from 'node:stream'; function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; - function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; + function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; function json(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; } declare module 'node:stream/consumers' { diff --git a/node_modules/@types/node/ts4.8/string_decoder.d.ts b/node_modules/@types/node/ts4.8/string_decoder.d.ts index a58580411..a069bb894 100755 --- a/node_modules/@types/node/ts4.8/string_decoder.d.ts +++ b/node_modules/@types/node/ts4.8/string_decoder.d.ts @@ -1,16 +1,16 @@ /** - * The `string_decoder` module provides an API for decoding `Buffer` objects into - * strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 + * The `node:string_decoder` module provides an API for decoding `Buffer` objects + * into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 * characters. It can be accessed using: * * ```js - * const { StringDecoder } = require('string_decoder'); + * const { StringDecoder } = require('node:string_decoder'); * ``` * * The following example shows the basic use of the `StringDecoder` class. * * ```js - * const { StringDecoder } = require('string_decoder'); + * const { StringDecoder } = require('node:string_decoder'); * const decoder = new StringDecoder('utf8'); * * const cent = Buffer.from([0xC2, 0xA2]); @@ -29,14 +29,14 @@ * symbol (`€`) are written over three separate operations: * * ```js - * const { StringDecoder } = require('string_decoder'); + * const { StringDecoder } = require('node:string_decoder'); * const decoder = new StringDecoder('utf8'); * * decoder.write(Buffer.from([0xE2])); * decoder.write(Buffer.from([0x82])); * console.log(decoder.end(Buffer.from([0xAC]))); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/string_decoder.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/string_decoder.js) */ declare module 'string_decoder' { class StringDecoder { diff --git a/node_modules/@types/node/ts4.8/test.d.ts b/node_modules/@types/node/ts4.8/test.d.ts index 85908ed85..520245445 100755 --- a/node_modules/@types/node/ts4.8/test.d.ts +++ b/node_modules/@types/node/ts4.8/test.d.ts @@ -1,20 +1,112 @@ /** - * The `node:test` module provides a standalone testing module. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/test.js) + * The `node:test` module facilitates the creation of JavaScript tests. + * To access it: + * + * ```js + * import test from 'node:test'; + * ``` + * + * This module is only available under the `node:` scheme. The following will not + * work: + * + * ```js + * import test from 'test'; + * ``` + * + * Tests created via the `test` module consist of a single function that is + * processed in one of three ways: + * + * 1. A synchronous function that is considered failing if it throws an exception, + * and is considered passing otherwise. + * 2. A function that returns a `Promise` that is considered failing if the`Promise` rejects, and is considered passing if the `Promise` resolves. + * 3. A function that receives a callback function. If the callback receives any + * truthy value as its first argument, the test is considered failing. If a + * falsy value is passed as the first argument to the callback, the test is + * considered passing. If the test function receives a callback function and + * also returns a `Promise`, the test will fail. + * + * The following example illustrates how tests are written using the`test` module. + * + * ```js + * test('synchronous passing test', (t) => { + * // This test passes because it does not throw an exception. + * assert.strictEqual(1, 1); + * }); + * + * test('synchronous failing test', (t) => { + * // This test fails because it throws an exception. + * assert.strictEqual(1, 2); + * }); + * + * test('asynchronous passing test', async (t) => { + * // This test passes because the Promise returned by the async + * // function is not rejected. + * assert.strictEqual(1, 1); + * }); + * + * test('asynchronous failing test', async (t) => { + * // This test fails because the Promise returned by the async + * // function is rejected. + * assert.strictEqual(1, 2); + * }); + * + * test('failing test using Promises', (t) => { + * // Promises can be used directly as well. + * return new Promise((resolve, reject) => { + * setImmediate(() => { + * reject(new Error('this will cause the test to fail')); + * }); + * }); + * }); + * + * test('callback passing test', (t, done) => { + * // done() is the callback function. When the setImmediate() runs, it invokes + * // done() with no arguments. + * setImmediate(done); + * }); + * + * test('callback failing test', (t, done) => { + * // When the setImmediate() runs, done() is invoked with an Error object and + * // the test fails. + * setImmediate(() => { + * done(new Error('callback failure')); + * }); + * }); + * ``` + * + * If any tests fail, the process exit code is set to `1`. + * @since v18.0.0, v16.17.0 + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/test.js) */ declare module 'node:test' { + import { Readable } from 'node:stream'; /** - * The `test()` function is the value imported from the test module. Each invocation of this - * function results in the creation of a test point in the TAP output. + * ```js + * import { tap } from 'node:test/reporters'; + * import process from 'node:process'; * - * The {@link TestContext} object passed to the fn argument can be used to perform actions - * related to the current test. Examples include skipping the test, adding additional TAP - * diagnostic information, or creating subtests. + * run({ files: [path.resolve('./tests/test.js')] }) + * .compose(tap) + * .pipe(process.stdout); + * ``` + * @since v18.9.0, v16.19.0 + * @param options Configuration options for running tests. The following properties are supported: + */ + function run(options?: RunOptions): TestsStream; + /** + * The `test()` function is the value imported from the `test` module. Each + * invocation of this function results in reporting the test to the `TestsStream`. * - * `test()` returns a {@link Promise} that resolves once the test completes. The return value - * can usually be discarded for top level tests. However, the return value from subtests should - * be used to prevent the parent test from finishing first and cancelling the subtest as shown - * in the following example. + * The `TestContext` object passed to the `fn` argument can be used to perform + * actions related to the current test. Examples include skipping the test, adding + * additional diagnostic information, or creating subtests. + * + * `test()` returns a `Promise` that resolves once the test completes. + * if `test()` is called within a `describe()` block, it resolve immediately. + * The return value can usually be discarded for top level tests. + * However, the return value from subtests should be used to prevent the parent + * test from finishing first and cancelling the subtest + * as shown in the following example. * * ```js * test('top level test', async (t) => { @@ -28,105 +120,438 @@ declare module 'node:test' { * }); * }); * ``` - * @since v18.0.0 - * @param name The name of the test, which is displayed when reporting test results. - * Default: The `name` property of fn, or `''` if `fn` does not have a name. - * @param options Configuration options for the test - * @param fn The function under test. The first argument to this function is a - * {@link TestContext} object. If the test uses callbacks, the callback function is - * passed as the second argument. Default: A no-op function. - * @returns A {@link Promise} resolved with `undefined` once the test completes. + * + * The `timeout` option can be used to fail the test if it takes longer than`timeout` milliseconds to complete. However, it is not a reliable mechanism for + * canceling tests because a running test might block the application thread and + * thus prevent the scheduled cancellation. + * @since v18.0.0, v16.17.0 + * @param [name='The name'] The name of the test, which is displayed when reporting test results. + * @param options Configuration options for the test. The following properties are supported: + * @param [fn='A no-op function'] The function under test. The first argument to this function is a {@link TestContext} object. If the test uses callbacks, the callback function is passed as the + * second argument. + * @return Resolved with `undefined` once the test completes, or immediately if the test runs within {@link describe}. */ function test(name?: string, fn?: TestFn): Promise; function test(name?: string, options?: TestOptions, fn?: TestFn): Promise; function test(options?: TestOptions, fn?: TestFn): Promise; function test(fn?: TestFn): Promise; - - /* - * @since v18.6.0 - * @param name The name of the suite, which is displayed when reporting suite results. - * Default: The `name` property of fn, or `''` if `fn` does not have a name. - * @param options Configuration options for the suite - * @param fn The function under suite. Default: A no-op function. + namespace test { + export { + after, + afterEach, + before, + beforeEach, + describe, + it, + run, + mock, + test, + skip, + todo, + only + }; + } + /** + * The `describe()` function imported from the `node:test` module. Each + * invocation of this function results in the creation of a Subtest. + * After invocation of top level `describe` functions, + * all top level tests and suites will execute. + * @param [name='The name'] The name of the suite, which is displayed when reporting test results. + * @param options Configuration options for the suite. supports the same options as `test([name][, options][, fn])`. + * @param [fn='A no-op function'] The function under suite declaring all subtests and subsuites. The first argument to this function is a {@link SuiteContext} object. + * @return `undefined`. */ function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void; function describe(name?: string, fn?: SuiteFn): void; function describe(options?: TestOptions, fn?: SuiteFn): void; function describe(fn?: SuiteFn): void; - - /* - * @since v18.6.0 - * @param name The name of the test, which is displayed when reporting test results. - * Default: The `name` property of fn, or `''` if `fn` does not have a name. - * @param options Configuration options for the test - * @param fn The function under test. If the test uses callbacks, the callback function is - * passed as the second argument. Default: A no-op function. - */ - function it(name?: string, options?: TestOptions, fn?: ItFn): void; - function it(name?: string, fn?: ItFn): void; - function it(options?: TestOptions, fn?: ItFn): void; - function it(fn?: ItFn): void; - + namespace describe { + /** + * Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`. + */ + function skip(name?: string, options?: TestOptions, fn?: SuiteFn): void; + function skip(name?: string, fn?: SuiteFn): void; + function skip(options?: TestOptions, fn?: SuiteFn): void; + function skip(fn?: SuiteFn): void; + /** + * Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`. + */ + function todo(name?: string, options?: TestOptions, fn?: SuiteFn): void; + function todo(name?: string, fn?: SuiteFn): void; + function todo(options?: TestOptions, fn?: SuiteFn): void; + function todo(fn?: SuiteFn): void; + /** + * Shorthand for marking a suite as `only`, same as `describe([name], { only: true }[, fn])`. + * @since v18.15.0 + */ + function only(name?: string, options?: TestOptions, fn?: SuiteFn): void; + function only(name?: string, fn?: SuiteFn): void; + function only(options?: TestOptions, fn?: SuiteFn): void; + function only(fn?: SuiteFn): void; + } + /** + * Shorthand for `test()`. + * + * The `it()` function is imported from the `node:test` module. + * @since v18.6.0, v16.17.0 + */ + function it(name?: string, options?: TestOptions, fn?: TestFn): void; + function it(name?: string, fn?: TestFn): void; + function it(options?: TestOptions, fn?: TestFn): void; + function it(fn?: TestFn): void; + namespace it { + /** + * Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`. + */ + function skip(name?: string, options?: TestOptions, fn?: TestFn): void; + function skip(name?: string, fn?: TestFn): void; + function skip(options?: TestOptions, fn?: TestFn): void; + function skip(fn?: TestFn): void; + /** + * Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`. + */ + function todo(name?: string, options?: TestOptions, fn?: TestFn): void; + function todo(name?: string, fn?: TestFn): void; + function todo(options?: TestOptions, fn?: TestFn): void; + function todo(fn?: TestFn): void; + /** + * Shorthand for marking a test as `only`, same as `it([name], { only: true }[, fn])`. + * @since v18.15.0 + */ + function only(name?: string, options?: TestOptions, fn?: TestFn): void; + function only(name?: string, fn?: TestFn): void; + function only(options?: TestOptions, fn?: TestFn): void; + function only(fn?: TestFn): void; + } + /** + * Shorthand for skipping a test, same as `test([name], { skip: true }[, fn])`. + * @since v20.2.0 + */ + function skip(name?: string, options?: TestOptions, fn?: TestFn): void; + function skip(name?: string, fn?: TestFn): void; + function skip(options?: TestOptions, fn?: TestFn): void; + function skip(fn?: TestFn): void; + /** + * Shorthand for marking a test as `TODO`, same as `test([name], { todo: true }[, fn])`. + * @since v20.2.0 + */ + function todo(name?: string, options?: TestOptions, fn?: TestFn): void; + function todo(name?: string, fn?: TestFn): void; + function todo(options?: TestOptions, fn?: TestFn): void; + function todo(fn?: TestFn): void; + /** + * Shorthand for marking a test as `only`, same as `test([name], { only: true }[, fn])`. + * @since v20.2.0 + */ + function only(name?: string, options?: TestOptions, fn?: TestFn): void; + function only(name?: string, fn?: TestFn): void; + function only(options?: TestOptions, fn?: TestFn): void; + function only(fn?: TestFn): void; /** * The type of a function under test. The first argument to this function is a * {@link TestContext} object. If the test uses callbacks, the callback function is passed as * the second argument. */ type TestFn = (t: TestContext, done: (result?: any) => void) => any; - /** * The type of a function under Suite. * If the test uses callbacks, the callback function is passed as an argument */ type SuiteFn = (done: (result?: any) => void) => void; - + interface RunOptions { + /** + * If a number is provided, then that many files would run in parallel. + * If truthy, it would run (number of cpu cores - 1) files in parallel. + * If falsy, it would only run one file at a time. + * If unspecified, subtests inherit this value from their parent. + * @default true + */ + concurrency?: number | boolean | undefined; + /** + * An array containing the list of files to run. + * If unspecified, the test runner execution model will be used. + */ + files?: readonly string[] | undefined; + /** + * Allows aborting an in-progress test execution. + * @default undefined + */ + signal?: AbortSignal | undefined; + /** + * A number of milliseconds the test will fail after. + * If unspecified, subtests inherit this value from their parent. + * @default Infinity + */ + timeout?: number | undefined; + /** + * Sets inspector port of test child process. + * If a nullish value is provided, each process gets its own port, + * incremented from the primary's `process.debugPort`. + */ + inspectPort?: number | (() => number) | undefined; + /** + * That can be used to only run tests whose name matches the provided pattern. + * Test name patterns are interpreted as JavaScript regular expressions. + * For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run. + */ + testNamePatterns?: string | RegExp | string[] | RegExp[]; + } /** - * The type of a function under test. - * If the test uses callbacks, the callback function is passed as an argument + * A successful call to `run()` method will return a new `TestsStream` object, streaming a series of events representing the execution of the tests.`TestsStream` will emit events, in the + * order of the tests definition + * @since v18.9.0, v16.19.0 */ - type ItFn = (done: (result?: any) => void) => any; - + class TestsStream extends Readable implements NodeJS.ReadableStream { + addListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; + addListener(event: 'test:fail', listener: (data: TestFail) => void): this; + addListener(event: 'test:pass', listener: (data: TestPass) => void): this; + addListener(event: 'test:plan', listener: (data: TestPlan) => void): this; + addListener(event: 'test:start', listener: (data: TestStart) => void): this; + addListener(event: string, listener: (...args: any[]) => void): this; + emit(event: 'test:diagnostic', data: DiagnosticData): boolean; + emit(event: 'test:fail', data: TestFail): boolean; + emit(event: 'test:pass', data: TestPass): boolean; + emit(event: 'test:plan', data: TestPlan): boolean; + emit(event: 'test:start', data: TestStart): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; + on(event: 'test:fail', listener: (data: TestFail) => void): this; + on(event: 'test:pass', listener: (data: TestPass) => void): this; + on(event: 'test:plan', listener: (data: TestPlan) => void): this; + on(event: 'test:start', listener: (data: TestStart) => void): this; + on(event: string, listener: (...args: any[]) => void): this; + once(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; + once(event: 'test:fail', listener: (data: TestFail) => void): this; + once(event: 'test:pass', listener: (data: TestPass) => void): this; + once(event: 'test:plan', listener: (data: TestPlan) => void): this; + once(event: 'test:start', listener: (data: TestStart) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + prependListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; + prependListener(event: 'test:fail', listener: (data: TestFail) => void): this; + prependListener(event: 'test:pass', listener: (data: TestPass) => void): this; + prependListener(event: 'test:plan', listener: (data: TestPlan) => void): this; + prependListener(event: 'test:start', listener: (data: TestStart) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; + prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this; + prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this; + prependOnceListener(event: 'test:plan', listener: (data: TestPlan) => void): this; + prependOnceListener(event: 'test:start', listener: (data: TestStart) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + } + interface DiagnosticData { + /** + * The diagnostic message. + */ + message: string; + /** + * The nesting level of the test. + */ + nesting: number; + } + interface TestFail { + /** + * Additional execution metadata. + */ + details: { + /** + * The duration of the test in milliseconds. + */ + duration: number; + /** + * The error thrown by the test. + */ + error: Error; + }; + /** + * The test name. + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; + /** + * The ordinal number of the test. + */ + testNumber: number; + /** + * Present if `context.todo` is called. + */ + todo?: string | boolean; + /** + * Present if `context.skip` is called. + */ + skip?: string | boolean; + } + interface TestPass { + /** + * Additional execution metadata. + */ + details: { + /** + * The duration of the test in milliseconds. + */ + duration: number; + }; + /** + * The test name. + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; + /** + * The ordinal number of the test. + */ + testNumber: number; + /** + * Present if `context.todo` is called. + */ + todo?: string | boolean; + /** + * Present if `context.skip` is called. + */ + skip?: string | boolean; + } + interface TestPlan { + /** + * The nesting level of the test. + */ + nesting: number; + /** + * The number of subtests that have ran. + */ + count: number; + } + interface TestStart { + /** + * The test name. + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; + } /** - * An instance of `TestContext` is passed to each test function in order to interact with the - * test runner. However, the `TestContext` constructor is not exposed as part of the API. - * @since v18.0.0 + * An instance of `TestContext` is passed to each test function in order to + * interact with the test runner. However, the `TestContext` constructor is not + * exposed as part of the API. + * @since v18.0.0, v16.17.0 */ - interface TestContext { + class TestContext { /** - * This function is used to write TAP diagnostics to the output. Any diagnostic information is - * included at the end of the test's results. This function does not return a value. - * @param message Message to be displayed as a TAP diagnostic. - * @since v18.0.0 + * This function is used to create a hook running before subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v20.1.0 + */ + before: typeof before; + /** + * This function is used to create a hook running before each subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.8.0 + */ + beforeEach: typeof beforeEach; + /** + * This function is used to create a hook that runs after the current test finishes. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.13.0 + */ + after: typeof after; + /** + * This function is used to create a hook running after each subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.8.0 + */ + afterEach: typeof afterEach; + /** + * This function is used to write diagnostics to the output. Any diagnostic + * information is included at the end of the test's results. This function does + * not return a value. + * + * ```js + * test('top level test', (t) => { + * t.diagnostic('A diagnostic message'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Message to be reported. */ diagnostic(message: string): void; - /** - * If `shouldRunOnlyTests` is truthy, the test context will only run tests that have the `only` - * option set. Otherwise, all tests are run. If Node.js was not started with the `--test-only` - * command-line option, this function is a no-op. + * The name of the test. + * @since v18.8.0, v16.18.0 + */ + readonly name: string; + /** + * If `shouldRunOnlyTests` is truthy, the test context will only run tests that + * have the `only` option set. Otherwise, all tests are run. If Node.js was not + * started with the `--test-only` command-line option, this function is a + * no-op. + * + * ```js + * test('top level test', (t) => { + * // The test context can be set to run subtests with the 'only' option. + * t.runOnly(true); + * return Promise.all([ + * t.test('this subtest is now skipped'), + * t.test('this subtest is run', { only: true }), + * ]); + * }); + * ``` + * @since v18.0.0, v16.17.0 * @param shouldRunOnlyTests Whether or not to run `only` tests. - * @since v18.0.0 */ runOnly(shouldRunOnlyTests: boolean): void; - /** - * This function causes the test's output to indicate the test as skipped. If `message` is - * provided, it is included in the TAP output. Calling `skip()` does not terminate execution of - * the test function. This function does not return a value. - * @param message Optional skip message to be displayed in TAP output. - * @since v18.0.0 + * ```js + * test('top level test', async (t) => { + * await fetch('some/uri', { signal: t.signal }); + * }); + * ``` + * @since v18.7.0, v16.17.0 + */ + readonly signal: AbortSignal; + /** + * This function causes the test's output to indicate the test as skipped. If`message` is provided, it is included in the output. Calling `skip()` does + * not terminate execution of the test function. This function does not return a + * value. + * + * ```js + * test('top level test', (t) => { + * // Make sure to return here as well if the test contains additional logic. + * t.skip('this is skipped'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Optional skip message. */ skip(message?: string): void; - /** - * This function adds a `TODO` directive to the test's output. If `message` is provided, it is - * included in the TAP output. Calling `todo()` does not terminate execution of the test - * function. This function does not return a value. - * @param message Optional `TODO` message to be displayed in TAP output. - * @since v18.0.0 + * This function adds a `TODO` directive to the test's output. If `message` is + * provided, it is included in the output. Calling `todo()` does not terminate + * execution of the test function. This function does not return a value. + * + * ```js + * test('top level test', (t) => { + * // This test is marked as `TODO` + * t.todo('this is a todo'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Optional `TODO` message. */ todo(message?: string): void; - /** * This function is used to create subtests under the current test. This function behaves in * the same fashion as the top level {@link test} function. @@ -140,51 +565,488 @@ declare module 'node:test' { * @returns A {@link Promise} resolved with `undefined` once the test completes. */ test: typeof test; + /** + * Each test provides its own MockTracker instance. + */ + readonly mock: MockTracker; } - interface TestOptions { /** - * The number of tests that can be run at the same time. If unspecified, subtests inherit this - * value from their parent. - * @default 1 + * If a number is provided, then that many tests would run in parallel. + * If truthy, it would run (number of cpu cores - 1) tests in parallel. + * For subtests, it will be `Infinity` tests in parallel. + * If falsy, it would only run one test at a time. + * If unspecified, subtests inherit this value from their parent. + * @default false */ - concurrency?: number; - + concurrency?: number | boolean | undefined; /** * If truthy, and the test context is configured to run `only` tests, then this test will be * run. Otherwise, the test is skipped. * @default false */ - only?: boolean; - + only?: boolean | undefined; /** * Allows aborting an in-progress test. - * @since 8.7.0 + * @since v18.8.0 */ - signal?: AbortSignal; - + signal?: AbortSignal | undefined; /** * If truthy, the test is skipped. If a string is provided, that string is displayed in the * test results as the reason for skipping the test. * @default false */ - skip?: boolean | string; - + skip?: boolean | string | undefined; /** * A number of milliseconds the test will fail after. If unspecified, subtests inherit this * value from their parent. * @default Infinity - * @since 8.7.0 + * @since v18.7.0 */ - timeout?: number; - + timeout?: number | undefined; /** * If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in * the test results as the reason why the test is `TODO`. * @default false */ - todo?: boolean | string; + todo?: boolean | string | undefined; } + /** + * This function is used to create a hook running before running a suite. + * + * ```js + * describe('tests', async () => { + * before(() => console.log('about to run some test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function before(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running after running a suite. + * + * ```js + * describe('tests', async () => { + * after(() => console.log('finished running tests')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function after(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running + * before each subtest of the current suite. + * + * ```js + * describe('tests', async () => { + * beforeEach(() => console.log('about to run a test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function beforeEach(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running + * after each subtest of the current test. + * + * ```js + * describe('tests', async () => { + * afterEach(() => console.log('finished running a test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function afterEach(fn?: HookFn, options?: HookOptions): void; + /** + * The hook function. If the hook uses callbacks, the callback function is passed as the + * second argument. + */ + type HookFn = (done: (result?: any) => void) => any; + /** + * Configuration options for hooks. + * @since v18.8.0 + */ + interface HookOptions { + /** + * Allows aborting an in-progress hook. + */ + signal?: AbortSignal | undefined; + /** + * A number of milliseconds the hook will fail after. If unspecified, subtests inherit this + * value from their parent. + * @default Infinity + */ + timeout?: number | undefined; + } + interface MockFunctionOptions { + /** + * The number of times that the mock will use the behavior of `implementation`. + * Once the mock function has been called `times` times, + * it will automatically restore the behavior of `original`. + * This value must be an integer greater than zero. + * @default Infinity + */ + times?: number | undefined; + } + interface MockMethodOptions extends MockFunctionOptions { + /** + * If `true`, `object[methodName]` is treated as a getter. + * This option cannot be used with the `setter` option. + */ + getter?: boolean | undefined; + /** + * If `true`, `object[methodName]` is treated as a setter. + * This option cannot be used with the `getter` option. + */ + setter?: boolean | undefined; + } + type Mock = F & { + mock: MockFunctionContext; + }; + type NoOpFunction = (...args: any[]) => undefined; + type FunctionPropertyNames = { + [K in keyof T]: T[K] extends Function ? K : never; + }[keyof T]; + /** + * The `MockTracker` class is used to manage mocking functionality. The test runner + * module provides a top level `mock` export which is a `MockTracker` instance. + * Each test also provides its own `MockTracker` instance via the test context's`mock` property. + * @since v19.1.0, v18.13.0 + */ + class MockTracker { + /** + * This function is used to create a mock function. + * + * The following example creates a mock function that increments a counter by one + * on each invocation. The `times` option is used to modify the mock behavior such + * that the first two invocations add two to the counter instead of one. + * + * ```js + * test('mocks a counting function', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne, addTwo, { times: 2 }); + * + * assert.strictEqual(fn(), 2); + * assert.strictEqual(fn(), 4); + * assert.strictEqual(fn(), 5); + * assert.strictEqual(fn(), 6); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param [original='A no-op function'] An optional function to create a mock on. + * @param implementation An optional function used as the mock implementation for `original`. This is useful for creating mocks that exhibit one behavior for a specified number of calls and + * then restore the behavior of `original`. + * @param options Optional configuration options for the mock function. The following properties are supported: + * @return The mocked function. The mocked function contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the + * behavior of the mocked function. + */ + fn(original?: F, options?: MockFunctionOptions): Mock; + fn(original?: F, implementation?: Implementation, options?: MockFunctionOptions): Mock; + /** + * This function is used to create a mock on an existing object method. The + * following example demonstrates how a mock is created on an existing object + * method. + * + * ```js + * test('spies on an object method', (t) => { + * const number = { + * value: 5, + * subtract(a) { + * return this.value - a; + * }, + * }; + * + * t.mock.method(number, 'subtract'); + * assert.strictEqual(number.subtract.mock.calls.length, 0); + * assert.strictEqual(number.subtract(3), 2); + * assert.strictEqual(number.subtract.mock.calls.length, 1); + * + * const call = number.subtract.mock.calls[0]; + * + * assert.deepStrictEqual(call.arguments, [3]); + * assert.strictEqual(call.result, 2); + * assert.strictEqual(call.error, undefined); + * assert.strictEqual(call.target, undefined); + * assert.strictEqual(call.this, number); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param object The object whose method is being mocked. + * @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown. + * @param implementation An optional function used as the mock implementation for `object[methodName]`. + * @param options Optional configuration options for the mock method. The following properties are supported: + * @return The mocked method. The mocked method contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the + * behavior of the mocked method. + */ + method< + MockedObject extends object, + MethodName extends FunctionPropertyNames, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): MockedObject[MethodName] extends Function + ? Mock + : never; + method< + MockedObject extends object, + MethodName extends FunctionPropertyNames, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation: Implementation, + options?: MockFunctionOptions, + ): MockedObject[MethodName] extends Function + ? Mock + : never; + method( + object: MockedObject, + methodName: keyof MockedObject, + options: MockMethodOptions, + ): Mock; + method( + object: MockedObject, + methodName: keyof MockedObject, + implementation: Function, + options: MockMethodOptions, + ): Mock; - export { test as default, test, describe, it }; + /** + * This function is syntax sugar for `MockTracker.method` with `options.getter`set to `true`. + * @since v19.3.0, v18.13.0 + */ + getter< + MockedObject extends object, + MethodName extends keyof MockedObject, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): Mock<() => MockedObject[MethodName]>; + getter< + MockedObject extends object, + MethodName extends keyof MockedObject, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation?: Implementation, + options?: MockFunctionOptions, + ): Mock<(() => MockedObject[MethodName]) | Implementation>; + /** + * This function is syntax sugar for `MockTracker.method` with `options.setter`set to `true`. + * @since v19.3.0, v18.13.0 + */ + setter< + MockedObject extends object, + MethodName extends keyof MockedObject, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): Mock<(value: MockedObject[MethodName]) => void>; + setter< + MockedObject extends object, + MethodName extends keyof MockedObject, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation?: Implementation, + options?: MockFunctionOptions, + ): Mock<((value: MockedObject[MethodName]) => void) | Implementation>; + /** + * This function restores the default behavior of all mocks that were previously + * created by this `MockTracker` and disassociates the mocks from the`MockTracker` instance. Once disassociated, the mocks can still be used, but the`MockTracker` instance can no longer be + * used to reset their behavior or + * otherwise interact with them. + * + * After each test completes, this function is called on the test context's`MockTracker`. If the global `MockTracker` is used extensively, calling this + * function manually is recommended. + * @since v19.1.0, v18.13.0 + */ + reset(): void; + /** + * This function restores the default behavior of all mocks that were previously + * created by this `MockTracker`. Unlike `mock.reset()`, `mock.restoreAll()` does + * not disassociate the mocks from the `MockTracker` instance. + * @since v19.1.0, v18.13.0 + */ + restoreAll(): void; + } + const mock: MockTracker; + interface MockFunctionCall< + F extends Function, + ReturnType = F extends (...args: any) => infer T + ? T + : F extends abstract new (...args: any) => infer T + ? T + : unknown, + Args = F extends (...args: infer Y) => any + ? Y + : F extends abstract new (...args: infer Y) => any + ? Y + : unknown[], + > { + /** + * An array of the arguments passed to the mock function. + */ + arguments: Args; + /** + * If the mocked function threw then this property contains the thrown value. + */ + error: unknown | undefined; + /** + * The value returned by the mocked function. + * + * If the mocked function threw, it will be `undefined`. + */ + result: ReturnType | undefined; + /** + * An `Error` object whose stack can be used to determine the callsite of the mocked function invocation. + */ + stack: Error; + /** + * If the mocked function is a constructor, this field contains the class being constructed. + * Otherwise this will be `undefined`. + */ + target: F extends abstract new (...args: any) => any ? F : undefined; + /** + * The mocked function's `this` value. + */ + this: unknown; + } + /** + * The `MockFunctionContext` class is used to inspect or manipulate the behavior of + * mocks created via the `MockTracker` APIs. + * @since v19.1.0, v18.13.0 + */ + class MockFunctionContext { + /** + * A getter that returns a copy of the internal array used to track calls to the + * mock. Each entry in the array is an object with the following properties. + * @since v19.1.0, v18.13.0 + */ + readonly calls: Array>; + /** + * This function returns the number of times that this mock has been invoked. This + * function is more efficient than checking `ctx.calls.length` because `ctx.calls`is a getter that creates a copy of the internal call tracking array. + * @since v19.1.0, v18.13.0 + * @return The number of times that this mock has been invoked. + */ + callCount(): number; + /** + * This function is used to change the behavior of an existing mock. + * + * The following example creates a mock function using `t.mock.fn()`, calls the + * mock function, and then changes the mock implementation to a different function. + * + * ```js + * test('changes a mock behavior', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne); + * + * assert.strictEqual(fn(), 1); + * fn.mock.mockImplementation(addTwo); + * assert.strictEqual(fn(), 3); + * assert.strictEqual(fn(), 5); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param implementation The function to be used as the mock's new implementation. + */ + mockImplementation(implementation: Function): void; + /** + * This function is used to change the behavior of an existing mock for a single + * invocation. Once invocation `onCall` has occurred, the mock will revert to + * whatever behavior it would have used had `mockImplementationOnce()` not been + * called. + * + * The following example creates a mock function using `t.mock.fn()`, calls the + * mock function, changes the mock implementation to a different function for the + * next invocation, and then resumes its previous behavior. + * + * ```js + * test('changes a mock behavior once', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne); + * + * assert.strictEqual(fn(), 1); + * fn.mock.mockImplementationOnce(addTwo); + * assert.strictEqual(fn(), 3); + * assert.strictEqual(fn(), 4); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`. + * @param onCall The invocation number that will use `implementation`. If the specified invocation has already occurred then an exception is thrown. + */ + mockImplementationOnce(implementation: Function, onCall?: number): void; + /** + * Resets the call history of the mock function. + * @since v19.3.0, v18.13.0 + */ + resetCalls(): void; + /** + * Resets the implementation of the mock function to its original behavior. The + * mock can still be used after calling this function. + * @since v19.1.0, v18.13.0 + */ + restore(): void; + } + export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock, skip, only, todo }; } diff --git a/node_modules/@types/node/ts4.8/timers.d.ts b/node_modules/@types/node/ts4.8/timers.d.ts index b26f3ceda..5abcdca8d 100755 --- a/node_modules/@types/node/ts4.8/timers.d.ts +++ b/node_modules/@types/node/ts4.8/timers.d.ts @@ -1,12 +1,12 @@ /** * The `timer` module exposes a global API for scheduling functions to * be called at some future period of time. Because the timer functions are - * globals, there is no need to call `require('timers')` to use the API. + * globals, there is no need to call `require('node:timers')` to use the API. * * The timer functions within Node.js implement a similar API as the timers API * provided by Web Browsers but use a different internal implementation that is * built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout). - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/timers.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/timers.js) */ declare module 'timers' { import { Abortable } from 'node:events'; @@ -33,7 +33,35 @@ declare module 'timers' { refresh(): this; [Symbol.toPrimitive](): number; } - interface Immediate extends RefCounted { + /** + * This object is created internally and is returned from `setImmediate()`. It + * can be passed to `clearImmediate()` in order to cancel the scheduled + * actions. + * + * By default, when an immediate is scheduled, the Node.js event loop will continue + * running as long as the immediate is active. The `Immediate` object returned by `setImmediate()` exports both `immediate.ref()` and `immediate.unref()`functions that can be used to + * control this default behavior. + */ + class Immediate implements RefCounted { + /** + * When called, requests that the Node.js event loop _not_ exit so long as the`Immediate` is active. Calling `immediate.ref()` multiple times will have no + * effect. + * + * By default, all `Immediate` objects are "ref'ed", making it normally unnecessary + * to call `immediate.ref()` unless `immediate.unref()` had been called previously. + * @since v9.7.0 + * @return a reference to `immediate` + */ + ref(): this; + /** + * When called, the active `Immediate` object will not require the Node.js event + * loop to remain active. If there is no other activity keeping the event loop + * running, the process may exit before the `Immediate` object's callback is + * invoked. Calling `immediate.unref()` multiple times will have no effect. + * @since v9.7.0 + * @return a reference to `immediate` + */ + unref(): this; /** * If true, the `Immediate` object will keep the Node.js event loop active. * @since v11.0.0 @@ -41,7 +69,33 @@ declare module 'timers' { hasRef(): boolean; _onImmediate: Function; // to distinguish it from the Timeout class } - interface Timeout extends Timer { + /** + * This object is created internally and is returned from `setTimeout()` and `setInterval()`. It can be passed to either `clearTimeout()` or `clearInterval()` in order to cancel the + * scheduled actions. + * + * By default, when a timer is scheduled using either `setTimeout()` or `setInterval()`, the Node.js event loop will continue running as long as the + * timer is active. Each of the `Timeout` objects returned by these functions + * export both `timeout.ref()` and `timeout.unref()` functions that can be used to + * control this default behavior. + */ + class Timeout implements Timer { + /** + * When called, requests that the Node.js event loop _not_ exit so long as the`Timeout` is active. Calling `timeout.ref()` multiple times will have no effect. + * + * By default, all `Timeout` objects are "ref'ed", making it normally unnecessary + * to call `timeout.ref()` unless `timeout.unref()` had been called previously. + * @since v0.9.1 + * @return a reference to `timeout` + */ + ref(): this; + /** + * When called, the active `Timeout` object will not require the Node.js event loop + * to remain active. If there is no other activity keeping the event loop running, + * the process may exit before the `Timeout` object's callback is invoked. Calling`timeout.unref()` multiple times will have no effect. + * @since v0.9.1 + * @return a reference to `timeout` + */ + unref(): this; /** * If true, the `Timeout` object will keep the Node.js event loop active. * @since v11.0.0 @@ -62,6 +116,25 @@ declare module 'timers' { [Symbol.toPrimitive](): number; } } + /** + * Schedules execution of a one-time `callback` after `delay` milliseconds. + * + * The `callback` will likely not be invoked in precisely `delay` milliseconds. + * Node.js makes no guarantees about the exact timing of when callbacks will fire, + * nor of their ordering. The callback will be called as close as possible to the + * time specified. + * + * When `delay` is larger than `2147483647` or less than `1`, the `delay`will be set to `1`. Non-integer delays are truncated to an integer. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setTimeout()`. + * @since v0.0.1 + * @param callback The function to call when the timer elapses. + * @param [delay=1] The number of milliseconds to wait before calling the `callback`. + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearTimeout} + */ function setTimeout(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timeout; // util.promisify no rest args compability // tslint:disable-next-line void-return @@ -69,7 +142,27 @@ declare module 'timers' { namespace setTimeout { const __promisify__: typeof setTimeoutPromise; } + /** + * Cancels a `Timeout` object created by `setTimeout()`. + * @since v0.0.1 + * @param timeout A `Timeout` object as returned by {@link setTimeout} or the `primitive` of the `Timeout` object as a string or a number. + */ function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void; + /** + * Schedules repeated execution of `callback` every `delay` milliseconds. + * + * When `delay` is larger than `2147483647` or less than `1`, the `delay` will be + * set to `1`. Non-integer delays are truncated to an integer. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setInterval()`. + * @since v0.0.1 + * @param callback The function to call when the timer elapses. + * @param [delay=1] The number of milliseconds to wait before calling the `callback`. + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearInterval} + */ function setInterval(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timer; // util.promisify no rest args compability // tslint:disable-next-line void-return @@ -77,7 +170,30 @@ declare module 'timers' { namespace setInterval { const __promisify__: typeof setIntervalPromise; } + /** + * Cancels a `Timeout` object created by `setInterval()`. + * @since v0.0.1 + * @param timeout A `Timeout` object as returned by {@link setInterval} or the `primitive` of the `Timeout` object as a string or a number. + */ function clearInterval(intervalId: NodeJS.Timeout | string | number | undefined): void; + /** + * Schedules the "immediate" execution of the `callback` after I/O events' + * callbacks. + * + * When multiple calls to `setImmediate()` are made, the `callback` functions are + * queued for execution in the order in which they are created. The entire callback + * queue is processed every event loop iteration. If an immediate timer is queued + * from inside an executing callback, that timer will not be triggered until the + * next event loop iteration. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setImmediate()`. + * @since v0.9.1 + * @param callback The function to call at the end of this turn of the Node.js `Event Loop` + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearImmediate} + */ function setImmediate(callback: (...args: TArgs) => void, ...args: TArgs): NodeJS.Immediate; // util.promisify no rest args compability // tslint:disable-next-line void-return @@ -85,6 +201,11 @@ declare module 'timers' { namespace setImmediate { const __promisify__: typeof setImmediatePromise; } + /** + * Cancels an `Immediate` object created by `setImmediate()`. + * @since v0.9.1 + * @param immediate An `Immediate` object as returned by {@link setImmediate}. + */ function clearImmediate(immediateId: NodeJS.Immediate | undefined): void; function queueMicrotask(callback: () => void): void; } diff --git a/node_modules/@types/node/ts4.8/timers/promises.d.ts b/node_modules/@types/node/ts4.8/timers/promises.d.ts index fd778880e..299a35525 100755 --- a/node_modules/@types/node/ts4.8/timers/promises.d.ts +++ b/node_modules/@types/node/ts4.8/timers/promises.d.ts @@ -1,6 +1,6 @@ /** * The `timers/promises` API provides an alternative set of timer functions - * that return `Promise` objects. The API is accessible via`require('timers/promises')`. + * that return `Promise` objects. The API is accessible via`require('node:timers/promises')`. * * ```js * import { @@ -44,6 +44,8 @@ declare module 'timers/promises' { function setImmediate(value?: T, options?: TimerOptions): Promise; /** * Returns an async iterator that generates values in an interval of `delay` ms. + * If `ref` is `true`, you need to call `next()` of async iterator explicitly + * or implicitly to keep the event loop alive. * * ```js * import { @@ -62,6 +64,29 @@ declare module 'timers/promises' { * @since v15.9.0 */ function setInterval(delay?: number, value?: T, options?: TimerOptions): AsyncIterable; + interface Scheduler { + /** + * ```js + * import { scheduler } from 'node:timers/promises'; + * + * await scheduler.wait(1000); // Wait one second before continuing + * ``` + * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. + * Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported. + * @since v16.14.0 + * @experimental + * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. + */ + wait: (delay?: number, options?: TimerOptions) => Promise; + /** + * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. + * Calling timersPromises.scheduler.yield() is equivalent to calling timersPromises.setImmediate() with no arguments. + * @since v16.14.0 + * @experimental + */ + yield: () => Promise; + } + const scheduler: Scheduler; } declare module 'node:timers/promises' { export * from 'timers/promises'; diff --git a/node_modules/@types/node/ts4.8/tls.d.ts b/node_modules/@types/node/ts4.8/tls.d.ts index 2cbc71658..13ee56353 100755 --- a/node_modules/@types/node/ts4.8/tls.d.ts +++ b/node_modules/@types/node/ts4.8/tls.d.ts @@ -1,12 +1,12 @@ /** - * The `tls` module provides an implementation of the Transport Layer Security + * The `node:tls` module provides an implementation of the Transport Layer Security * (TLS) and Secure Socket Layer (SSL) protocols that is built on top of OpenSSL. * The module can be accessed using: * * ```js - * const tls = require('tls'); + * const tls = require('node:tls'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/tls.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/tls.js) */ declare module 'tls' { import { X509Certificate } from 'node:crypto'; @@ -41,21 +41,100 @@ declare module 'tls' { CN: string; } interface PeerCertificate { + /** + * `true` if a Certificate Authority (CA), `false` otherwise. + * @since v18.13.0 + */ + ca: boolean; + /** + * The DER encoded X.509 certificate data. + */ + raw: Buffer; + /** + * The certificate subject. + */ subject: Certificate; + /** + * The certificate issuer, described in the same terms as the `subject`. + */ issuer: Certificate; - subjectaltname: string; - infoAccess: NodeJS.Dict; - modulus: string; - exponent: string; + /** + * The date-time the certificate is valid from. + */ valid_from: string; + /** + * The date-time the certificate is valid to. + */ valid_to: string; + /** + * The certificate serial number, as a hex string. + */ + serialNumber: string; + /** + * The SHA-1 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ fingerprint: string; + /** + * The SHA-256 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ fingerprint256: string; - ext_key_usage: string[]; - serialNumber: string; - raw: Buffer; + /** + * The SHA-512 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ + fingerprint512: string; + /** + * The extended key usage, a set of OIDs. + */ + ext_key_usage?: string[]; + /** + * A string containing concatenated names for the subject, + * an alternative to the `subject` names. + */ + subjectaltname?: string; + /** + * An array describing the AuthorityInfoAccess, used with OCSP. + */ + infoAccess?: NodeJS.Dict; + /** + * For RSA keys: The RSA bit size. + * + * For EC keys: The key size in bits. + */ + bits?: number; + /** + * The RSA exponent, as a string in hexadecimal number notation. + */ + exponent?: string; + /** + * The RSA modulus, as a hexadecimal string. + */ + modulus?: string; + /** + * The public key. + */ + pubkey?: Buffer; + /** + * The ASN.1 name of the OID of the elliptic curve. + * Well-known curves are identified by an OID. + * While it is unusual, it is possible that the curve + * is identified by its mathematical properties, + * in which case it will not have an OID. + */ + asn1Curve?: string; + /** + * The NIST name for the elliptic curve,if it has one + * (not all well-known curves have been assigned names by NIST). + */ + nistCurve?: string; } interface DetailedPeerCertificate extends PeerCertificate { + /** + * The issuer certificate object. + * For self-signed certificates, this may be a circular reference. + */ issuerCertificate: DetailedPeerCertificate; } interface CipherNameAndProtocol { @@ -133,7 +212,7 @@ declare module 'tls' { * * Instances of `tls.TLSSocket` implement the duplex `Stream` interface. * - * Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate} will only return data while the + * Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate}) will only return data while the * connection is open. * @since v0.11.4 */ @@ -180,13 +259,13 @@ declare module 'tls' { /** * Returns an object containing information on the negotiated cipher suite. * - * For example: + * For example, a TLSv1.2 protocol with AES256-SHA cipher: * * ```json * { - * "name": "AES128-SHA256", - * "standardName": "TLS_RSA_WITH_AES_128_CBC_SHA256", - * "version": "TLSv1.2" + * "name": "AES256-SHA", + * "standardName": "TLS_RSA_WITH_AES_256_CBC_SHA", + * "version": "SSLv3" * } * ``` * @@ -558,7 +637,8 @@ declare module 'tls' { * used. * @since v0.5.3 * @param hostname A SNI host name or wildcard (e.g. `'*'`) - * @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc). + * @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc), or a TLS context object created + * with {@link createSecureContext} itself. */ addContext(hostname: string, context: SecureContextOptions): void; /** @@ -689,12 +769,9 @@ declare module 'tls' { */ crl?: string | Buffer | Array | undefined; /** - * Diffie Hellman parameters, required for Perfect Forward Secrecy. Use - * openssl dhparam to create the parameters. The key length must be - * greater than or equal to 1024 bits or else an error will be thrown. - * Although 1024 bits is permissible, use 2048 bits or larger for - * stronger security. If omitted or invalid, the parameters are - * silently discarded and DHE ciphers will not be available. + * `'auto'` or custom Diffie-Hellman parameters, required for non-ECDHE perfect forward secrecy. + * If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available. + * ECDHE-based perfect forward secrecy will still be available. */ dhparam?: string | Buffer | undefined; /** @@ -836,14 +913,14 @@ declare module 'tls' { * Creates a new {@link Server}. The `secureConnectionListener`, if provided, is * automatically set as a listener for the `'secureConnection'` event. * - * The `ticketKeys` options is automatically shared between `cluster` module + * The `ticketKeys` options is automatically shared between `node:cluster` module * workers. * * The following illustrates a simple echo server: * * ```js - * const tls = require('tls'); - * const fs = require('fs'); + * const tls = require('node:tls'); + * const fs = require('node:fs'); * * const options = { * key: fs.readFileSync('server-key.pem'), @@ -853,7 +930,7 @@ declare module 'tls' { * requestCert: true, * * // This is necessary only if the client uses a self-signed certificate. - * ca: [ fs.readFileSync('client-cert.pem') ] + * ca: [ fs.readFileSync('client-cert.pem') ], * }; * * const server = tls.createServer(options, (socket) => { @@ -888,8 +965,8 @@ declare module 'tls' { * * ```js * // Assumes an echo server that is listening on port 8000. - * const tls = require('tls'); - * const fs = require('fs'); + * const tls = require('node:tls'); + * const fs = require('node:fs'); * * const options = { * // Necessary only if the server requires client certificate authentication. @@ -965,12 +1042,19 @@ declare module 'tls' { * APIs that create secure contexts have no default value. * * The `tls.createSecureContext()` method creates a `SecureContext` object. It is - * usable as an argument to several `tls` APIs, such as {@link createServer} and `server.addContext()`, but has no public methods. + * usable as an argument to several `tls` APIs, such as `server.addContext()`, + * but has no public methods. The {@link Server} constructor and the {@link createServer} method do not support the `secureContext` option. * * A key is _required_ for ciphers that use certificates. Either `key` or`pfx` can be used to provide it. * * If the `ca` option is not given, then Node.js will default to using [Mozilla's publicly trusted list of * CAs](https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt). + * + * Custom DHE parameters are discouraged in favor of the new `dhparam: 'auto'`option. When set to `'auto'`, well-known DHE parameters of sufficient strength + * will be selected automatically. Otherwise, if necessary, `openssl dhparam` can + * be used to create custom parameters. The key length must be greater than or + * equal to 1024 bits or else an error will be thrown. Although 1024 bits is + * permissible, use 2048 bits or larger for stronger security. * @since v0.11.13 */ function createSecureContext(options?: SecureContextOptions): SecureContext; @@ -1016,6 +1100,13 @@ declare module 'tls' { * are provided, the lowest minimum is used. */ let DEFAULT_MIN_VERSION: SecureVersion; + /** + * The default value of the ciphers option of tls.createSecureContext(). + * It can be assigned any of the supported OpenSSL ciphers. + * Defaults to the content of crypto.constants.defaultCoreCipherList, unless + * changed using CLI options using --tls-default-ciphers. + */ + let DEFAULT_CIPHERS: string; /** * An immutable array of strings representing the root certificates (in PEM * format) used for verifying peer certificates. This is the default value diff --git a/node_modules/@types/node/ts4.8/trace_events.d.ts b/node_modules/@types/node/ts4.8/trace_events.d.ts index d47aa9311..ca8baede3 100755 --- a/node_modules/@types/node/ts4.8/trace_events.d.ts +++ b/node_modules/@types/node/ts4.8/trace_events.d.ts @@ -1,9 +1,9 @@ /** - * The `trace_events` module provides a mechanism to centralize tracing information - * generated by V8, Node.js core, and userspace code. + * The `node:trace_events` module provides a mechanism to centralize tracing + * information generated by V8, Node.js core, and userspace code. * * Tracing can be enabled with the `--trace-event-categories` command-line flag - * or by using the `trace_events` module. The `--trace-event-categories` flag + * or by using the `node:trace_events` module. The `--trace-event-categories` flag * accepts a list of comma-separated category names. * * The available categories are: @@ -13,9 +13,19 @@ * The `async_hooks` events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property. * * `node.bootstrap`: Enables capture of Node.js bootstrap milestones. * * `node.console`: Enables capture of `console.time()` and `console.count()`output. + * * `node.threadpoolwork.sync`: Enables capture of trace data for threadpool + * synchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`. + * * `node.threadpoolwork.async`: Enables capture of trace data for threadpool + * asynchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`. * * `node.dns.native`: Enables capture of trace data for DNS queries. + * * `node.net.native`: Enables capture of trace data for network. * * `node.environment`: Enables capture of Node.js Environment milestones. * * `node.fs.sync`: Enables capture of trace data for file system sync methods. + * * `node.fs_dir.sync`: Enables capture of trace data for file system sync + * directory methods. + * * `node.fs.async`: Enables capture of trace data for file system async methods. + * * `node.fs_dir.async`: Enables capture of trace data for file system async + * directory methods. * * `node.perf`: Enables capture of `Performance API` measurements. * * `node.perf.usertiming`: Enables capture of only Performance API User Timing * measures and marks. @@ -23,8 +33,9 @@ * measurements. * * `node.promises.rejections`: Enables capture of trace data tracking the number * of unhandled Promise rejections and handled-after-rejections. - * * `node.vm.script`: Enables capture of trace data for the `vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods. + * * `node.vm.script`: Enables capture of trace data for the `node:vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods. * * `v8`: The `V8` events are GC, compiling, and execution related. + * * `node.http`: Enables capture of trace data for http request / response. * * By default the `node`, `node.async_hooks`, and `v8` categories are enabled. * @@ -43,10 +54,10 @@ * node --trace-event-categories v8,node,node.async_hooks * ``` * - * Alternatively, trace events may be enabled using the `trace_events` module: + * Alternatively, trace events may be enabled using the `node:trace_events` module: * * ```js - * const trace_events = require('trace_events'); + * const trace_events = require('node:trace_events'); * const tracing = trace_events.createTracing({ categories: ['node.perf'] }); * tracing.enable(); // Enable trace event capture for the 'node.perf' category * @@ -83,7 +94,7 @@ * * The features from this module are not available in `Worker` threads. * @experimental - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/trace_events.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/trace_events.js) */ declare module 'trace_events' { /** @@ -132,7 +143,7 @@ declare module 'trace_events' { * Creates and returns a `Tracing` object for the given set of `categories`. * * ```js - * const trace_events = require('trace_events'); + * const trace_events = require('node:trace_events'); * const categories = ['node.perf', 'node.async_hooks']; * const tracing = trace_events.createTracing({ categories }); * tracing.enable(); @@ -152,7 +163,7 @@ declare module 'trace_events' { * Given the file `test.js` below, the command`node --trace-event-categories node.perf test.js` will print`'node.async_hooks,node.perf'` to the console. * * ```js - * const trace_events = require('trace_events'); + * const trace_events = require('node:trace_events'); * const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] }); * const t2 = trace_events.createTracing({ categories: ['node.perf'] }); * const t3 = trace_events.createTracing({ categories: ['v8'] }); diff --git a/node_modules/@types/node/ts4.8/tty.d.ts b/node_modules/@types/node/ts4.8/tty.d.ts index 6473f8db7..ca9ab823f 100755 --- a/node_modules/@types/node/ts4.8/tty.d.ts +++ b/node_modules/@types/node/ts4.8/tty.d.ts @@ -1,10 +1,9 @@ /** - * The `tty` module provides the `tty.ReadStream` and `tty.WriteStream` classes. - * In most cases, it will not be necessary or possible to use this module directly. - * However, it can be accessed using: + * The `node:tty` module provides the `tty.ReadStream` and `tty.WriteStream`classes. In most cases, it will not be necessary or possible to use this module + * directly. However, it can be accessed using: * * ```js - * const tty = require('tty'); + * const tty = require('node:tty'); * ``` * * When Node.js detects that it is being run with a text terminal ("TTY") @@ -22,7 +21,7 @@ * * In most cases, there should be little to no reason for an application to * manually create instances of the `tty.ReadStream` and `tty.WriteStream`classes. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/tty.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/tty.js) */ declare module 'tty' { import * as net from 'node:net'; diff --git a/node_modules/@types/node/ts4.8/url.d.ts b/node_modules/@types/node/ts4.8/url.d.ts index 18362c8aa..af8123db4 100755 --- a/node_modules/@types/node/ts4.8/url.d.ts +++ b/node_modules/@types/node/ts4.8/url.d.ts @@ -1,14 +1,14 @@ /** - * The `url` module provides utilities for URL resolution and parsing. It can be - * accessed using: + * The `node:url` module provides utilities for URL resolution and parsing. It can + * be accessed using: * * ```js - * import url from 'url'; + * import url from 'node:url'; * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/url.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/url.js) */ declare module 'url' { - import { Blob } from 'node:buffer'; + import { Blob as NodeBlob } from 'node:buffer'; import { ClientRequestArgs } from 'node:http'; import { ParsedUrlQuery, ParsedUrlQueryInput } from 'node:querystring'; // Input to `url.format` @@ -54,17 +54,11 @@ declare module 'url' { * * A `URIError` is thrown if the `auth` property is present but cannot be decoded. * - * Use of the legacy `url.parse()` method is discouraged. Users should - * use the WHATWG `URL` API. Because the `url.parse()` method uses a - * lenient, non-standard algorithm for parsing URL strings, security - * issues can be introduced. Specifically, issues with [host name spoofing](https://hackerone.com/reports/678487) and - * incorrect handling of usernames and passwords have been identified. - * - * Deprecation of this API has been shelved for now primarily due to the the - * inability of the [WHATWG API to parse relative URLs](https://github.com/nodejs/node/issues/12682#issuecomment-1154492373). - * [Discussions are ongoing](https://github.com/whatwg/url/issues/531) for the best way to resolve this. - * + * `url.parse()` uses a lenient, non-standard algorithm for parsing URL + * strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487) and incorrect handling of usernames and passwords. Do not use with untrusted + * input. CVEs are not issued for `url.parse()` vulnerabilities. Use the `WHATWG URL` API instead. * @since v0.1.25 + * @deprecated Use the WHATWG URL API instead. * @param urlString The URL string to parse. * @param [parseQueryString=false] If `true`, the `query` property will always be set to an object returned by the {@link querystring} module's `parse()` method. If `false`, the `query` property * on the returned URL object will be an unparsed, undecoded string. @@ -79,15 +73,15 @@ declare module 'url' { * The `url.format()` method returns a formatted URL string derived from`urlObject`. * * ```js - * const url = require('url'); + * const url = require('node:url'); * url.format({ * protocol: 'https', * hostname: 'example.com', * pathname: '/some/path', * query: { * page: 1, - * format: 'json' - * } + * format: 'json', + * }, * }); * * // => 'https://example.com/some/path?page=1&format=json' @@ -135,7 +129,7 @@ declare module 'url' { * string, an `Error` is thrown. * * `result` is returned. * @since v0.1.25 - * @deprecated Legacy: Use the WHATWG URL API instead. + * @legacy Use the WHATWG URL API instead. * @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`. */ function format(urlObject: URL, options?: URLFormatOptions): string; @@ -199,7 +193,7 @@ declare module 'url' { * string, an `Error` is thrown. * * `result` is returned. * @since v0.1.25 - * @deprecated Legacy: Use the WHATWG URL API instead. + * @legacy Use the WHATWG URL API instead. * @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`. */ function format(urlObject: UrlObject | string): string; @@ -208,7 +202,7 @@ declare module 'url' { * manner similar to that of a web browser resolving an anchor tag. * * ```js - * const url = require('url'); + * const url = require('node:url'); * url.resolve('/one/two/three', 'four'); // '/one/two/four' * url.resolve('http://example.com/', '/one'); // 'http://example.com/one' * url.resolve('http://example.com/one', '/two'); // 'http://example.com/two' @@ -232,7 +226,7 @@ declare module 'url' { * resolve('http://example.com/one', '/two'); // 'http://example.com/two' * ``` * @since v0.1.25 - * @deprecated Legacy: Use the WHATWG URL API instead. + * @legacy Use the WHATWG URL API instead. * @param from The base URL to use if `to` is a relative URL. * @param to The target URL to resolve. */ @@ -243,10 +237,8 @@ declare module 'url' { * * It performs the inverse operation to {@link domainToUnicode}. * - * This feature is only available if the `node` executable was compiled with `ICU` enabled. If not, the domain names are passed through unchanged. - * * ```js - * import url from 'url'; + * import url from 'node:url'; * * console.log(url.domainToASCII('español.com')); * // Prints xn--espaol-zwa.com @@ -264,10 +256,8 @@ declare module 'url' { * * It performs the inverse operation to {@link domainToASCII}. * - * This feature is only available if the `node` executable was compiled with `ICU` enabled. If not, the domain names are passed through unchanged. - * * ```js - * import url from 'url'; + * import url from 'node:url'; * * console.log(url.domainToUnicode('xn--espaol-zwa.com')); * // Prints español.com @@ -284,7 +274,7 @@ declare module 'url' { * well as ensuring a cross-platform valid absolute path string. * * ```js - * import { fileURLToPath } from 'url'; + * import { fileURLToPath } from 'node:url'; * * const __filename = fileURLToPath(import.meta.url); * @@ -310,7 +300,7 @@ declare module 'url' { * control characters are correctly encoded when converting into a File URL. * * ```js - * import { pathToFileURL } from 'url'; + * import { pathToFileURL } from 'node:url'; * * new URL('/foo#1', 'file:'); // Incorrect: file:///foo#1 * pathToFileURL('/foo#1'); // Correct: file:///foo%231 (POSIX) @@ -328,7 +318,7 @@ declare module 'url' { * expected by the `http.request()` and `https.request()` APIs. * * ```js - * import { urlToHttpOptions } from 'url'; + * import { urlToHttpOptions } from 'node:url'; * const myURL = new URL('https://a:b@測試?abc#foo'); * * console.log(urlToHttpOptions(myURL)); @@ -376,7 +366,7 @@ declare module 'url' { * const { * Blob, * resolveObjectURL, - * } = require('buffer'); + * } = require('node:buffer'); * * const blob = new Blob(['hello']); * const id = URL.createObjectURL(blob); @@ -395,10 +385,10 @@ declare module 'url' { * @since v16.7.0 * @experimental */ - static createObjectURL(blob: Blob): string; + static createObjectURL(blob: NodeBlob): string; /** * Removes the stored `Blob` identified by the given ID. Attempting to revoke a - * ID that isn’t registered will silently fail. + * ID that isn't registered will silently fail. * @since v16.7.0 * @experimental * @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`. @@ -449,7 +439,7 @@ declare module 'url' { * // Prints example.org * * // Setting the hostname does not change the port - * myURL.hostname = 'example.com:82'; + * myURL.hostname = 'example.com'; * console.log(myURL.href); * // Prints https://example.com:81/foo * @@ -512,7 +502,7 @@ declare module 'url' { * * myURL.password = '123'; * console.log(myURL.href); - * // Prints https://abc:123@example.com + * // Prints https://abc:123@example.com/ * ``` * * Invalid URL characters included in the value assigned to the `password` property @@ -656,14 +646,14 @@ declare module 'url' { * character, while `URLSearchParams` will always encode it: * * ```js - * const myUrl = new URL('https://example.org/abc?foo=~bar'); + * const myURL = new URL('https://example.org/abc?foo=~bar'); * - * console.log(myUrl.search); // prints ?foo=~bar + * console.log(myURL.search); // prints ?foo=~bar * * // Modify the URL via searchParams... - * myUrl.searchParams.sort(); + * myURL.searchParams.sort(); * - * console.log(myUrl.search); // prints ?foo=%7Ebar + * console.log(myURL.search); // prints ?foo=%7Ebar * ``` */ readonly searchParams: URLSearchParams; @@ -758,9 +748,12 @@ declare module 'url' { */ append(name: string, value: string): void; /** - * Remove all name-value pairs whose name is `name`. + * If `value` is provided, removes all name-value pairs + * where name is `name` and value is `value`.. + * + * If `value` is not provided, removes all name-value pairs whose name is `name`. */ - delete(name: string): void; + delete(name: string, value?: string): void; /** * Returns an ES6 `Iterator` over each of the name-value pairs in the query. * Each item of the iterator is a JavaScript `Array`. The first item of the `Array`is the `name`, the second item of the `Array` is the `value`. @@ -796,9 +789,15 @@ declare module 'url' { */ getAll(name: string): string[]; /** - * Returns `true` if there is at least one name-value pair whose name is `name`. + * Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument. + * + * If `value` is provided, returns `true` when name-value pair with + * same `name` and `value` exists. + * + * If `value` is not provided, returns `true` if there is at least one name-value + * pair whose name is `name`. */ - has(name: string): boolean; + has(name: string, value?: string): boolean; /** * Returns an ES6 `Iterator` over the names of each name-value pair. * @@ -833,6 +832,11 @@ declare module 'url' { * ``` */ set(name: string, value: string): void; + /** + * The total number of parameter entries. + * @since v19.8.0 + */ + readonly size: number; /** * Sort all existing name-value pairs in-place by their names. Sorting is done * with a [stable sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability), so relative order between name-value pairs @@ -875,9 +879,9 @@ declare module 'url' { */ var URL: typeof globalThis extends { onmessage: any; - URL: infer URL; + URL: infer T; } - ? URL + ? T : typeof _URL; /** * `URLSearchParams` class is a global reference for `require('url').URLSearchParams` @@ -886,9 +890,9 @@ declare module 'url' { */ var URLSearchParams: typeof globalThis extends { onmessage: any; - URLSearchParams: infer URLSearchParams; + URLSearchParams: infer T; } - ? URLSearchParams + ? T : typeof _URLSearchParams; } } diff --git a/node_modules/@types/node/ts4.8/util.d.ts b/node_modules/@types/node/ts4.8/util.d.ts index a08132568..228a2c89e 100755 --- a/node_modules/@types/node/ts4.8/util.d.ts +++ b/node_modules/@types/node/ts4.8/util.d.ts @@ -1,33 +1,49 @@ /** - * The `util` module supports the needs of Node.js internal APIs. Many of the + * The `node:util` module supports the needs of Node.js internal APIs. Many of the * utilities are useful for application and module developers as well. To access * it: * * ```js - * const util = require('util'); + * const util = require('node:util'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/util.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/util.js) */ declare module 'util' { import * as types from 'node:util/types'; export interface InspectOptions { /** - * If set to `true`, getters are going to be - * inspected as well. If set to `'get'` only getters without setter are going - * to be inspected. If set to `'set'` only getters having a corresponding - * setter are going to be inspected. This might cause side effects depending on - * the getter function. - * @default `false` + * If `true`, object's non-enumerable symbols and properties are included in the formatted result. + * `WeakMap` and `WeakSet` entries are also included as well as user defined prototype properties (excluding method properties). + * @default false */ - getters?: 'get' | 'set' | boolean | undefined; showHidden?: boolean | undefined; /** + * Specifies the number of times to recurse while formatting object. + * This is useful for inspecting large objects. + * To recurse up to the maximum call stack size pass `Infinity` or `null`. * @default 2 */ depth?: number | null | undefined; + /** + * If `true`, the output is styled with ANSI color codes. Colors are customizable. + */ colors?: boolean | undefined; + /** + * If `false`, `[util.inspect.custom](depth, opts, inspect)` functions are not invoked. + * @default true + */ customInspect?: boolean | undefined; + /** + * If `true`, `Proxy` inspection includes the target and handler objects. + * @default false + */ showProxy?: boolean | undefined; + /** + * Specifies the maximum number of `Array`, `TypedArray`, `WeakMap`, and `WeakSet` elements + * to include when formatting. Set to `null` or `Infinity` to show all elements. + * Set to `0` or negative to show no elements. + * @default 100 + */ maxArrayLength?: number | null | undefined; /** * Specifies the maximum number of characters to @@ -36,6 +52,12 @@ declare module 'util' { * @default 10000 */ maxStringLength?: number | null | undefined; + /** + * The length at which input values are split across multiple lines. + * Set to `Infinity` to format the input as a single line + * (in combination with `compact` set to `true` or any number >= `1`). + * @default 80 + */ breakLength?: number | undefined; /** * Setting this to `false` causes each object key @@ -45,13 +67,33 @@ declare module 'util' { * `breakLength`. Short array elements are also grouped together. Note that no * text will be reduced below 16 characters, no matter the `breakLength` size. * For more information, see the example below. - * @default `true` + * @default true */ compact?: boolean | number | undefined; + /** + * If set to `true` or a function, all properties of an object, and `Set` and `Map` + * entries are sorted in the resulting string. + * If set to `true` the default sort is used. + * If set to a function, it is used as a compare function. + */ sorted?: boolean | ((a: string, b: string) => number) | undefined; + /** + * If set to `true`, getters are going to be + * inspected as well. If set to `'get'` only getters without setter are going + * to be inspected. If set to `'set'` only getters having a corresponding + * setter are going to be inspected. This might cause side effects depending on + * the getter function. + * @default false + */ + getters?: 'get' | 'set' | boolean | undefined; + /** + * If set to `true`, an underscore is used to separate every three digits in all bigints and numbers. + * @default false + */ + numericSeparator?: boolean | undefined; } export type Style = 'special' | 'number' | 'bigint' | 'boolean' | 'undefined' | 'null' | 'string' | 'symbol' | 'date' | 'regexp' | 'module'; - export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => string; + export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => any; // TODO: , inspect: inspect export interface InspectOptionsStylized extends InspectOptions { stylize(text: string, styleType: Style): string; } @@ -147,7 +189,7 @@ declare module 'util' { * timestamp. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.log('Timestamped message.'); * ``` @@ -162,6 +204,52 @@ declare module 'util' { * @since v16.8.0, v14.18.0 */ export function toUSVString(string: string): string; + /** + * Creates and returns an `AbortController` instance whose `AbortSignal` is marked + * as transferable and can be used with `structuredClone()` or `postMessage()`. + * @since v18.11.0 + * @experimental + * @returns A transferable AbortController + */ + export function transferableAbortController(): AbortController; + /** + * Marks the given `AbortSignal` as transferable so that it can be used with`structuredClone()` and `postMessage()`. + * + * ```js + * const signal = transferableAbortSignal(AbortSignal.timeout(100)); + * const channel = new MessageChannel(); + * channel.port2.postMessage(signal, [signal]); + * ``` + * @since v18.11.0 + * @experimental + * @param signal The AbortSignal + * @returns The same AbortSignal + */ + export function transferableAbortSignal(signal: AbortSignal): AbortSignal; + /** + * Listens to abort event on the provided `signal` and + * returns a promise that is fulfilled when the `signal` is + * aborted. If the passed `resource` is garbage collected before the `signal` is + * aborted, the returned promise shall remain pending indefinitely. + * + * ```js + * import { aborted } from 'node:util'; + * + * const dependent = obtainSomethingAbortable(); + * + * aborted(dependent.signal, dependent).then(() => { + * // Do something when dependent is aborted. + * }); + * + * dependent.on('event', () => { + * dependent.abort(); + * }); + * ``` + * @since v19.7.0 + * @experimental + * @param resource Any non-null entity, reference to which is held weakly. + */ + export function aborted(signal: AbortSignal, resource: any): Promise; /** * The `util.inspect()` method returns a string representation of `object` that is * intended for debugging. The output of `util.inspect` may change at any time @@ -188,7 +276,7 @@ declare module 'util' { * Circular references point to their anchor by using a reference index: * * ```js - * const { inspect } = require('util'); + * const { inspect } = require('node:util'); * * const obj = {}; * obj.a = [obj]; @@ -206,7 +294,7 @@ declare module 'util' { * The following example inspects all properties of the `util` object: * * ```js - * const util = require('util'); + * const util = require('node:util'); * * console.log(util.inspect(util, { showHidden: true, depth: null })); * ``` @@ -214,7 +302,7 @@ declare module 'util' { * The following example highlights the effect of the `compact` option: * * ```js - * const util = require('util'); + * const util = require('node:util'); * * const o = { * a: [1, 2, [[ @@ -222,7 +310,7 @@ declare module 'util' { * 'eiusmod \ntempor incididunt ut labore et dolore magna aliqua.', * 'test', * 'foo']], 4], - * b: new Map([['za', 1], ['zb', 'test']]) + * b: new Map([['za', 1], ['zb', 'test']]), * }; * console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 })); * @@ -271,7 +359,7 @@ declare module 'util' { * with no remaining strong references may be garbage collected at any time. * * ```js - * const { inspect } = require('util'); + * const { inspect } = require('node:util'); * * const obj = { a: 1 }; * const obj2 = { b: 2 }; @@ -285,13 +373,13 @@ declare module 'util' { * impact the result of `util.inspect()`. * * ```js - * const { inspect } = require('util'); - * const assert = require('assert'); + * const { inspect } = require('node:util'); + * const assert = require('node:assert'); * * const o1 = { * b: [2, 3, 1], * a: '`a` comes before `b`', - * c: new Set([2, 3, 1]) + * c: new Set([2, 3, 1]), * }; * console.log(inspect(o1, { sorted: true })); * // { a: '`a` comes before `b`', b: [ 2, 3, 1 ], c: Set(3) { 1, 2, 3 } } @@ -301,11 +389,11 @@ declare module 'util' { * const o2 = { * c: new Set([2, 1, 3]), * a: '`a` comes before `b`', - * b: [2, 3, 1] + * b: [2, 3, 1], * }; * assert.strict.equal( * inspect(o1, { sorted: true }), - * inspect(o2, { sorted: true }) + * inspect(o2, { sorted: true }), * ); * ``` * @@ -313,7 +401,7 @@ declare module 'util' { * numbers. * * ```js - * const { inspect } = require('util'); + * const { inspect } = require('node:util'); * * const thousand = 1_000; * const million = 1_000_000; @@ -325,7 +413,7 @@ declare module 'util' { * ``` * * `util.inspect()` is a synchronous method intended for debugging. Its maximum - * output length is approximately 128 MB. Inputs that result in longer output will + * output length is approximately 128 MiB. Inputs that result in longer output will * be truncated. * @since v0.3.0 * @param object Any JavaScript primitive or `Object`. @@ -354,7 +442,7 @@ declare module 'util' { * Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isArray([]); * // Returns: true @@ -371,7 +459,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isRegExp(/some regexp/); * // Returns: true @@ -388,7 +476,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isDate(new Date()); * // Returns: true @@ -405,7 +493,7 @@ declare module 'util' { * Returns `true` if the given `object` is an `Error`. Otherwise, returns`false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isError(new Error()); * // Returns: true @@ -419,7 +507,7 @@ declare module 'util' { * possible to obtain an incorrect result when the `object` argument manipulates`@@toStringTag`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * const obj = { name: 'Error', message: 'an error occurred' }; * * util.isError(obj); @@ -444,8 +532,8 @@ declare module 'util' { * through the `constructor.super_` property. * * ```js - * const util = require('util'); - * const EventEmitter = require('events'); + * const util = require('node:util'); + * const EventEmitter = require('node:events'); * * function MyStream() { * EventEmitter.call(this); @@ -471,7 +559,7 @@ declare module 'util' { * ES6 example using `class` and `extends`: * * ```js - * const EventEmitter = require('events'); + * const EventEmitter = require('node:events'); * * class MyStream extends EventEmitter { * write(data) { @@ -487,7 +575,7 @@ declare module 'util' { * stream.write('With ES6'); * ``` * @since v0.3.0 - * @deprecated Legacy: Use ES2015 class syntax and `extends` keyword instead. + * @legacy Use ES2015 class syntax and `extends` keyword instead. */ export function inherits(constructor: unknown, superConstructor: unknown): void; export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void; @@ -500,7 +588,7 @@ declare module 'util' { * environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op. * * ```js - * const util = require('util'); + * const util = require('node:util'); * const debuglog = util.debuglog('foo'); * * debuglog('hello from foo [%d]', 123); @@ -519,7 +607,7 @@ declare module 'util' { * The `section` supports wildcard also: * * ```js - * const util = require('util'); + * const util = require('node:util'); * const debuglog = util.debuglog('foo-bar'); * * debuglog('hi there, it\'s foo-bar [%d]', 2333); @@ -539,7 +627,7 @@ declare module 'util' { * unnecessary wrapping. * * ```js - * const util = require('util'); + * const util = require('node:util'); * let debuglog = util.debuglog('internals', (debug) => { * // Replace with a logging function that optimizes out * // testing if the section is enabled @@ -557,7 +645,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isBoolean(1); * // Returns: false @@ -574,7 +662,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isBuffer({ length: 0 }); * // Returns: false @@ -591,7 +679,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Function`. Otherwise, returns`false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * function Foo() {} * const Bar = () => {}; @@ -611,7 +699,7 @@ declare module 'util' { * Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isNull(0); * // Returns: false @@ -629,7 +717,7 @@ declare module 'util' { * returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isNullOrUndefined(0); * // Returns: false @@ -646,7 +734,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isNumber(false); * // Returns: false @@ -666,7 +754,7 @@ declare module 'util' { * Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isObject(5); * // Returns: false @@ -678,14 +766,14 @@ declare module 'util' { * // Returns: false * ``` * @since v0.11.5 - * @deprecated Since v4.0.0 - Deprecated: Use `value !== null && typeof value === 'object'` instead. + * @deprecated Since v4.0.0 - Use `value !== null && typeof value === 'object'` instead. */ export function isObject(object: unknown): boolean; /** * Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isPrimitive(5); * // Returns: true @@ -714,7 +802,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `string`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isString(''); * // Returns: true @@ -733,7 +821,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isSymbol(5); * // Returns: false @@ -750,7 +838,7 @@ declare module 'util' { * Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * const foo = undefined; * util.isUndefined(5); @@ -769,7 +857,7 @@ declare module 'util' { * such a way that it is marked as deprecated. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * exports.obsoleteFunction = util.deprecate(() => { * // Do something here. @@ -785,7 +873,7 @@ declare module 'util' { * the warning will be emitted only once for that `code`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001'); * const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001'); @@ -839,7 +927,7 @@ declare module 'util' { * first argument will be the rejection reason (or `null` if the `Promise`resolved), and the second argument will be the resolved value. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * async function fn() { * return 'hello world'; @@ -878,7 +966,7 @@ declare module 'util' { * }); * ``` * @since v8.2.0 - * @param original An `async` function + * @param fn An `async` function * @return a callback style function */ export function callbackify(fn: () => Promise): (callback: (err: NodeJS.ErrnoException) => void) => void; @@ -922,8 +1010,8 @@ declare module 'util' { * that returns promises. * * ```js - * const util = require('util'); - * const fs = require('fs'); + * const util = require('node:util'); + * const fs = require('node:fs'); * * const stat = util.promisify(fs.stat); * stat('.').then((stats) => { @@ -936,8 +1024,8 @@ declare module 'util' { * Or, equivalently using `async function`s: * * ```js - * const util = require('util'); - * const fs = require('fs'); + * const util = require('node:util'); + * const fs = require('node:fs'); * * const stat = util.promisify(fs.stat); * @@ -958,7 +1046,7 @@ declare module 'util' { * work as expected unless handled specially: * * ```js - * const util = require('util'); + * const util = require('node:util'); * * class Foo { * constructor() { @@ -1047,7 +1135,7 @@ declare module 'util' { * internally and emitted after the next call to `textDecoder.decode()`. * * If `textDecoder.fatal` is `true`, decoding errors that occur will result in a`TypeError` being thrown. - * @param input An `ArrayBuffer`, `DataView` or `TypedArray` instance containing the encoded data. + * @param input An `ArrayBuffer`, `DataView`, or `TypedArray` instance containing the encoded data. */ decode( input?: NodeJS.ArrayBufferView | ArrayBuffer | null, @@ -1067,6 +1155,8 @@ declare module 'util' { written: number; } export { types }; + + //// TextEncoder/Decoder /** * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextEncoder` API. All * instances of `TextEncoder` only support UTF-8 encoding. @@ -1105,65 +1195,115 @@ declare module 'util' { */ encodeInto(src: string, dest: Uint8Array): EncodeIntoResult; } + import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from 'util'; + global { + /** + * `TextDecoder` class is a global reference for `require('util').TextDecoder` + * https://nodejs.org/api/globals.html#textdecoder + * @since v11.0.0 + */ + var TextDecoder: typeof globalThis extends { + onmessage: any; + TextDecoder: infer TextDecoder; + } + ? TextDecoder + : typeof _TextDecoder; + /** + * `TextEncoder` class is a global reference for `require('util').TextEncoder` + * https://nodejs.org/api/globals.html#textencoder + * @since v11.0.0 + */ + var TextEncoder: typeof globalThis extends { + onmessage: any; + TextEncoder: infer TextEncoder; + } + ? TextEncoder + : typeof _TextEncoder; + } - /** - * Provides a high-level API for command-line argument parsing. Takes a - * specification for the expected arguments and returns a structured object - * with the parsed values and positionals. - * - * `config` provides arguments for parsing and configures the parser. It - * supports the following properties: - * - * - `args` The array of argument strings. **Default:** `process.argv` with - * `execPath` and `filename` removed. - * - `options` Arguments known to the parser. Keys of `options` are the long - * names of options and values are objects accepting the following properties: - * - * - `type` Type of argument, which must be either `boolean` (for options - * which do not take values) or `string` (for options which do). - * - `multiple` Whether this option can be provided multiple - * times. If `true`, all values will be collected in an array. If - * `false`, values for the option are last-wins. **Default:** `false`. - * - `short` A single character alias for the option. - * - * - `strict`: Whether an error should be thrown when unknown arguments - * are encountered, or when arguments are passed that do not match the - * `type` configured in `options`. **Default:** `true`. - * - `allowPositionals`: Whether this command accepts positional arguments. - * **Default:** `false` if `strict` is `true`, otherwise `true`. - * - `tokens`: Whether tokens {boolean} Return the parsed tokens. This is useful - * for extending the built-in behavior, from adding additional checks through - * to reprocessing the tokens in different ways. - * **Default:** `false`. - * - * @returns The parsed command line arguments: - * - * - `values` A mapping of parsed option names with their string - * or boolean values. - * - `positionals` Positional arguments. - * - `tokens` Detailed parse information (only if `tokens` was specified). - * - */ - export function parseArgs(config: T): ParsedResults; - + //// parseArgs + /** + * Provides a higher level API for command-line argument parsing than interacting + * with `process.argv` directly. Takes a specification for the expected arguments + * and returns a structured object with the parsed options and positionals. + * + * ```js + * import { parseArgs } from 'node:util'; + * const args = ['-f', '--bar', 'b']; + * const options = { + * foo: { + * type: 'boolean', + * short: 'f', + * }, + * bar: { + * type: 'string', + * }, + * }; + * const { + * values, + * positionals, + * } = parseArgs({ args, options }); + * console.log(values, positionals); + * // Prints: [Object: null prototype] { foo: true, bar: 'b' } [] + * ``` + * @since v18.3.0, v16.17.0 + * @param config Used to provide arguments for parsing and to configure the parser. `config` supports the following properties: + * @return The parsed command line arguments: + */ + export function parseArgs(config?: T): ParsedResults; interface ParseArgsOptionConfig { + /** + * Type of argument. + */ type: 'string' | 'boolean'; - short?: string; - multiple?: boolean; + /** + * Whether this option can be provided multiple times. + * If `true`, all values will be collected in an array. + * If `false`, values for the option are last-wins. + * @default false. + */ + multiple?: boolean | undefined; + /** + * A single character alias for the option. + */ + short?: string | undefined; + /** + * The default option value when it is not set by args. + * It must be of the same type as the the `type` property. + * When `multiple` is `true`, it must be an array. + * @since v18.11.0 + */ + default?: string | boolean | string[] | boolean[] | undefined; } - interface ParseArgsOptionsConfig { [longOption: string]: ParseArgsOptionConfig; } - export interface ParseArgsConfig { - strict?: boolean; - allowPositionals?: boolean; - tokens?: boolean; - options?: ParseArgsOptionsConfig; - args?: string[]; + /** + * Array of argument strings. + */ + args?: string[] | undefined; + /** + * Used to describe arguments known to the parser. + */ + options?: ParseArgsOptionsConfig | undefined; + /** + * Should an error be thrown when unknown arguments are encountered, + * or when arguments are passed that do not match the `type` configured in `options`. + * @default true + */ + strict?: boolean | undefined; + /** + * Whether this command accepts positional arguments. + */ + allowPositionals?: boolean | undefined; + /** + * Return the parsed tokens. This is useful for extending the built-in behavior, + * from adding additional checks through to reprocessing the tokens in different ways. + * @default false + */ + tokens?: boolean | undefined; } - /* IfDefaultsTrue and IfDefaultsFalse are helpers to handle default values for missing boolean properties. TypeScript does not have exact types for objects: https://github.com/microsoft/TypeScript/issues/12936 @@ -1287,11 +1427,103 @@ declare module 'util' { // So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above. type ParsedResults = ParseArgsConfig extends T ? { - values: { [longOption: string]: undefined | string | boolean | Array }; + values: { + [longOption: string]: undefined | string | boolean | Array; + }; positionals: string[]; tokens?: Token[]; } : PreciseParsedResults; + + /** + * An implementation of [the MIMEType class](https://bmeck.github.io/node-proposal-mime-api/). + * + * In accordance with browser conventions, all properties of `MIMEType` objects + * are implemented as getters and setters on the class prototype, rather than as + * data properties on the object itself. + * + * A MIME string is a structured string containing multiple meaningful + * components. When parsed, a `MIMEType` object is returned containing + * properties for each of these components. + * @since v19.1.0, v18.13.0 + * @experimental + */ + export class MIMEType { + /** + * Creates a new MIMEType object by parsing the input. + * + * A `TypeError` will be thrown if the `input` is not a valid MIME. + * Note that an effort will be made to coerce the given values into strings. + * @param input The input MIME to parse. + */ + constructor(input: string | { toString: () => string }); + + /** + * Gets and sets the type portion of the MIME. + */ + type: string; + /** + * Gets and sets the subtype portion of the MIME. + */ + subtype: string; + /** + * Gets the essence of the MIME. + * + * Use `mime.type` or `mime.subtype` to alter the MIME. + */ + readonly essence: string; + /** + * Gets the `MIMEParams` object representing the parameters of the MIME. + */ + readonly params: MIMEParams; + /** + * Returns the serialized MIME. + * + * Because of the need for standard compliance, this method + * does not allow users to customize the serialization process of the MIME. + */ + toString(): string; + } + /** + * @since v18.13.0 + */ + export class MIMEParams { + /** + * Remove all name-value pairs whose name is `name`. + */ + delete(name: string): void; + /** + * Returns an iterator over each of the name-value pairs in the parameters. + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns the value of the first name-value pair whose name is `name`. + * If there are no such pairs, `null` is returned. + */ + get(name: string): string | null; + /** + * Returns `true` if there is at least one name-value pair whose name is `name`. + */ + has(name: string): boolean; + /** + * Returns an iterator over the names of each name-value pair. + */ + keys(): IterableIterator; + /** + * Sets the value in the `MIMEParams` object associated with `name` to `value`. + * If there are any pre-existing name-value pairs whose names are `name`, + * set the first such pair's value to `value`. + */ + set(name: string, value: string): void; + /** + * Returns an iterator over the values of each name-value pair. + */ + values(): IterableIterator; + /** + * Returns an iterator over each of the name-value pairs in the parameters. + */ + [Symbol.iterator]: typeof MIMEParams.prototype.entries; + } } declare module 'util/types' { export * from 'util/types'; @@ -1589,12 +1821,40 @@ declare module 'util/types' { */ function isModuleNamespaceObject(value: unknown): boolean; /** - * Returns `true` if the value is an instance of a built-in `Error` type. + * Returns `true` if the value was returned by the constructor of a [built-in `Error` type](https://tc39.es/ecma262/#sec-error-objects). + * + * ```js + * console.log(util.types.isNativeError(new Error())); // true + * console.log(util.types.isNativeError(new TypeError())); // true + * console.log(util.types.isNativeError(new RangeError())); // true + * ``` + * + * Subclasses of the native error types are also native errors: + * + * ```js + * class MyError extends Error {} + * console.log(util.types.isNativeError(new MyError())); // true + * ``` + * + * A value being `instanceof` a native error class is not equivalent to `isNativeError()`returning `true` for that value. `isNativeError()` returns `true` for errors + * which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false`for these errors: + * + * ```js + * const vm = require('node:vm'); + * const context = vm.createContext({}); + * const myError = vm.runInContext('new Error()', context); + * console.log(util.types.isNativeError(myError)); // true + * console.log(myError instanceof Error); // false + * ``` + * + * Conversely, `isNativeError()` returns `false` for all objects which were not + * returned by the constructor of a native error. That includes values + * which are `instanceof` native errors: * * ```js - * util.types.isNativeError(new Error()); // Returns true - * util.types.isNativeError(new TypeError()); // Returns true - * util.types.isNativeError(new RangeError()); // Returns true + * const myError = { __proto__: Error.prototype }; + * console.log(util.types.isNativeError(myError)); // false + * console.log(myError instanceof Error); // true * ``` * @since v10.0.0 */ diff --git a/node_modules/@types/node/ts4.8/v8.d.ts b/node_modules/@types/node/ts4.8/v8.d.ts index 6685dc253..064f5d59e 100755 --- a/node_modules/@types/node/ts4.8/v8.d.ts +++ b/node_modules/@types/node/ts4.8/v8.d.ts @@ -1,10 +1,10 @@ /** - * The `v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using: + * The `node:v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using: * * ```js - * const v8 = require('v8'); + * const v8 = require('node:v8'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/v8.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/v8.js) */ declare module 'v8' { import { Readable } from 'node:stream'; @@ -29,6 +29,9 @@ declare module 'v8' { does_zap_garbage: DoesZapCodeSpaceFlag; number_of_native_contexts: number; number_of_detached_contexts: number; + total_global_handles_size: number; + used_global_handles_size: number; + external_memory: number; } interface HeapCodeStatistics { code_and_metadata_size: number; @@ -68,6 +71,15 @@ declare module 'v8' { * of contexts that were detached and not yet garbage collected. This number * being non-zero indicates a potential memory leak. * + * `total_global_handles_size` The value of total\_global\_handles\_size is the + * total memory size of V8 global handles. + * + * `used_global_handles_size` The value of used\_global\_handles\_size is the + * used memory size of V8 global handles. + * + * `external_memory` The value of external\_memory is the memory size of array + * buffers and external strings. + * * ```js * { * total_heap_size: 7326976, @@ -80,7 +92,10 @@ declare module 'v8' { * peak_malloced_memory: 1127496, * does_zap_garbage: 0, * number_of_native_contexts: 1, - * number_of_detached_contexts: 0 + * number_of_detached_contexts: 0, + * total_global_handles_size: 8192, + * used_global_handles_size: 3296, + * external_memory: 318824 * } * ``` * @since v1.0.0 @@ -149,7 +164,7 @@ declare module 'v8' { * * ```js * // Print GC events to stdout for one minute. - * const v8 = require('v8'); + * const v8 = require('node:v8'); * v8.setFlagsFromString('--trace_gc'); * setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3); * ``` @@ -172,12 +187,12 @@ declare module 'v8' { * * ```js * // Print heap snapshot to the console - * const v8 = require('v8'); + * const v8 = require('node:v8'); * const stream = v8.getHeapSnapshot(); * stream.pipe(process.stdout); * ``` * @since v11.13.0 - * @return A Readable Stream containing the V8 heap snapshot + * @return A Readable containing the V8 heap snapshot. */ function getHeapSnapshot(): Readable; /** @@ -197,12 +212,12 @@ declare module 'v8' { * for a duration depending on the heap size. * * ```js - * const { writeHeapSnapshot } = require('v8'); + * const { writeHeapSnapshot } = require('node:v8'); * const { * Worker, * isMainThread, - * parentPort - * } = require('worker_threads'); + * parentPort, + * } = require('node:worker_threads'); * * if (isMainThread) { * const worker = new Worker(__filename); @@ -233,13 +248,16 @@ declare module 'v8' { */ function writeHeapSnapshot(filename?: string): string; /** - * Returns an object with the following properties: + * Get statistics about code and its metadata in the heap, see + * V8[`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the + * following properties: * * ```js * { * code_and_metadata_size: 212208, * bytecode_and_metadata_size: 161368, - * external_script_source_size: 1410794 + * external_script_source_size: 1410794, + * cpu_profiler_metadata_size: 0, * } * ``` * @since v12.8.0 @@ -289,7 +307,7 @@ declare module 'v8' { */ writeDouble(value: number): void; /** - * Write raw bytes into the serializer’s internal buffer. The deserializer + * Write raw bytes into the serializer's internal buffer. The deserializer * will require a way to compute the length of the buffer. * For use inside of a custom `serializer._writeHostObject()`. */ @@ -345,7 +363,7 @@ declare module 'v8' { */ readDouble(): number; /** - * Read raw bytes from the deserializer’s internal buffer. The `length` parameter + * Read raw bytes from the deserializer's internal buffer. The `length` parameter * must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`. * For use inside of a custom `deserializer._readHostObject()`. */ @@ -390,6 +408,227 @@ declare module 'v8' { * @since v15.1.0, v14.18.0, v12.22.0 */ function stopCoverage(): void; + /** + * This API collects GC data in current thread. + * @since v19.6.0, v18.15.0 + */ + class GCProfiler { + /** + * Start collecting GC data. + * @since v19.6.0, v18.15.0 + */ + start(): void; + /** + * Stop collecting GC data and return an object.The content of object + * is as follows. + * + * ```json + * { + * "version": 1, + * "startTime": 1674059033862, + * "statistics": [ + * { + * "gcType": "Scavenge", + * "beforeGC": { + * "heapStatistics": { + * "totalHeapSize": 5005312, + * "totalHeapSizeExecutable": 524288, + * "totalPhysicalSize": 5226496, + * "totalAvailableSize": 4341325216, + * "totalGlobalHandlesSize": 8192, + * "usedGlobalHandlesSize": 2112, + * "usedHeapSize": 4883840, + * "heapSizeLimit": 4345298944, + * "mallocedMemory": 254128, + * "externalMemory": 225138, + * "peakMallocedMemory": 181760 + * }, + * "heapSpaceStatistics": [ + * { + * "spaceName": "read_only_space", + * "spaceSize": 0, + * "spaceUsedSize": 0, + * "spaceAvailableSize": 0, + * "physicalSpaceSize": 0 + * } + * ] + * }, + * "cost": 1574.14, + * "afterGC": { + * "heapStatistics": { + * "totalHeapSize": 6053888, + * "totalHeapSizeExecutable": 524288, + * "totalPhysicalSize": 5500928, + * "totalAvailableSize": 4341101384, + * "totalGlobalHandlesSize": 8192, + * "usedGlobalHandlesSize": 2112, + * "usedHeapSize": 4059096, + * "heapSizeLimit": 4345298944, + * "mallocedMemory": 254128, + * "externalMemory": 225138, + * "peakMallocedMemory": 181760 + * }, + * "heapSpaceStatistics": [ + * { + * "spaceName": "read_only_space", + * "spaceSize": 0, + * "spaceUsedSize": 0, + * "spaceAvailableSize": 0, + * "physicalSpaceSize": 0 + * } + * ] + * } + * } + * ], + * "endTime": 1674059036865 + * } + * ``` + * + * Here's an example. + * + * ```js + * const { GCProfiler } = require('v8'); + * const profiler = new GCProfiler(); + * profiler.start(); + * setTimeout(() => { + * console.log(profiler.stop()); + * }, 1000); + * ``` + * @since v19.6.0, v18.15.0 + */ + stop(): GCProfilerResult; + } + interface GCProfilerResult { + version: number; + startTime: number; + endTime: number; + statistics: Array<{ + gcType: string; + cost: number; + beforeGC: { + heapStatistics: HeapStatistics; + heapSpaceStatistics: HeapSpaceStatistics[]; + }; + afterGC: { + heapStatistics: HeapStatistics; + heapSpaceStatistics: HeapSpaceStatistics[]; + }; + }>; + } + interface HeapStatistics { + totalHeapSize: number; + totalHeapSizeExecutable: number; + totalPhysicalSize: number; + totalAvailableSize: number; + totalGlobalHandlesSize: number; + usedGlobalHandlesSize: number; + usedHeapSize: number; + heapSizeLimit: number; + mallocedMemory: number; + externalMemory: number; + peakMallocedMemory: number; + } + interface HeapSpaceStatistics { + spaceName: string; + spaceSize: number; + spaceUsedSize: number; + spaceAvailableSize: number; + physicalSpaceSize: number; + } + /** + * Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will + * happen if a promise is created without ever getting a continuation. + * @since v17.1.0, v16.14.0 + * @param promise The promise being created. + * @param parent The promise continued from, if applicable. + */ + interface Init { + (promise: Promise, parent: Promise): void; + } + /** + * Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming. + * + * The before callback will be called 0 to N times. The before callback will typically be called 0 times if no continuation was ever made for the promise. + * The before callback may be called many times in the case where many continuations have been made from the same promise. + * @since v17.1.0, v16.14.0 + */ + interface Before { + (promise: Promise): void; + } + /** + * Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await. + * @since v17.1.0, v16.14.0 + */ + interface After { + (promise: Promise): void; + } + /** + * Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or + * {@link Promise.reject()}. + * @since v17.1.0, v16.14.0 + */ + interface Settled { + (promise: Promise): void; + } + /** + * Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or + * around an await, and when the promise resolves or rejects. + * + * Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and + * `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop. + * @since v17.1.0, v16.14.0 + */ + interface HookCallbacks { + init?: Init; + before?: Before; + after?: After; + settled?: Settled; + } + interface PromiseHooks { + /** + * The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param init The {@link Init | `init` callback} to call when a promise is created. + * @return Call to stop the hook. + */ + onInit: (init: Init) => Function; + /** + * The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param settled The {@link Settled | `settled` callback} to call when a promise is created. + * @return Call to stop the hook. + */ + onSettled: (settled: Settled) => Function; + /** + * The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param before The {@link Before | `before` callback} to call before a promise continuation executes. + * @return Call to stop the hook. + */ + onBefore: (before: Before) => Function; + /** + * The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param after The {@link After | `after` callback} to call after a promise continuation executes. + * @return Call to stop the hook. + */ + onAfter: (after: After) => Function; + /** + * Registers functions to be called for different lifetime events of each promise. + * The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime. + * All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed. + * The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param callbacks The {@link HookCallbacks | Hook Callbacks} to register + * @return Used for disabling hooks + */ + createHook: (callbacks: HookCallbacks) => Function; + } + /** + * The `promiseHooks` interface can be used to track promise lifecycle events. + * @since v17.1.0, v16.14.0 + */ + const promiseHooks: PromiseHooks; } declare module 'node:v8' { export * from 'v8'; diff --git a/node_modules/@types/node/ts4.8/vm.d.ts b/node_modules/@types/node/ts4.8/vm.d.ts index c96513a50..e293a50e4 100755 --- a/node_modules/@types/node/ts4.8/vm.d.ts +++ b/node_modules/@types/node/ts4.8/vm.d.ts @@ -1,8 +1,8 @@ /** - * The `vm` module enables compiling and running code within V8 Virtual + * The `node:vm` module enables compiling and running code within V8 Virtual * Machine contexts. * - * **The `vm` module is not a security** + * **The `node:vm` module is not a security** * **mechanism. Do not use it to run untrusted code.** * * JavaScript code can be compiled and run immediately or @@ -17,7 +17,7 @@ * code are reflected in the context object. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * const x = 1; * @@ -34,7 +34,7 @@ * * console.log(x); // 1; y is not defined. * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/vm.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/vm.js) */ declare module 'vm' { interface Context extends NodeJS.Dict {} @@ -56,11 +56,17 @@ declare module 'vm' { columnOffset?: number | undefined; } interface ScriptOptions extends BaseOptions { - displayErrors?: boolean | undefined; - timeout?: number | undefined; - cachedData?: Buffer | undefined; + /** + * V8's code cache data for the supplied source. + */ + cachedData?: Buffer | NodeJS.ArrayBufferView | undefined; /** @deprecated in favor of `script.createCachedData()` */ produceCachedData?: boolean | undefined; + /** + * Called during evaluation of this module when `import()` is called. + * If this option is not specified, calls to `import()` will reject with `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`. + */ + importModuleDynamically?: ((specifier: string, script: Script, importAssertions: Object) => Module) | undefined; } interface RunningScriptOptions extends BaseOptions { /** @@ -80,10 +86,31 @@ declare module 'vm' { * Default: `false`. */ breakOnSigint?: boolean | undefined; + } + interface RunningScriptInNewContextOptions extends RunningScriptOptions { + /** + * Human-readable name of the newly created context. + */ + contextName?: CreateContextOptions['name']; + /** + * Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL, + * but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object. + * Most notably, this string should omit the trailing slash, as that denotes a path. + */ + contextOrigin?: CreateContextOptions['origin']; + contextCodeGeneration?: CreateContextOptions['codeGeneration']; /** * If set to `afterEvaluate`, microtasks will be run immediately after the script has run. */ - microtaskMode?: 'afterEvaluate' | undefined; + microtaskMode?: CreateContextOptions['microtaskMode']; + } + interface RunningCodeOptions extends RunningScriptOptions { + cachedData?: ScriptOptions['cachedData']; + importModuleDynamically?: ScriptOptions['importModuleDynamically']; + } + interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions { + cachedData?: ScriptOptions['cachedData']; + importModuleDynamically?: ScriptOptions['importModuleDynamically']; } interface CompileFunctionOptions extends BaseOptions { /** @@ -144,7 +171,10 @@ declare module 'vm' { * @default 'summary' */ mode?: MeasureMemoryMode | undefined; - context?: Context | undefined; + /** + * @default 'default' + */ + execution?: 'default' | 'eager' | undefined; } interface MemoryMeasurement { total: { @@ -158,7 +188,7 @@ declare module 'vm' { * @since v0.3.1 */ class Script { - constructor(code: string, options?: ScriptOptions); + constructor(code: string, options?: ScriptOptions | string); /** * Runs the compiled code contained by the `vm.Script` object within the given`contextifiedObject` and returns the result. Running code does not have access * to local scope. @@ -168,11 +198,11 @@ declare module 'vm' { * The globals are contained in the `context` object. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * const context = { * animal: 'cat', - * count: 2 + * count: 2, * }; * * const script = new vm.Script('count += 1; name = "kitty";'); @@ -204,7 +234,7 @@ declare module 'vm' { * contained within each individual `context`. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * const script = new vm.Script('globalVar = "set"'); * @@ -220,7 +250,7 @@ declare module 'vm' { * @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created. * @return the result of the very last statement executed in the script. */ - runInNewContext(contextObject?: Context, options?: RunningScriptOptions): any; + runInNewContext(contextObject?: Context, options?: RunningScriptInNewContextOptions): any; /** * Runs the compiled code contained by the `vm.Script` within the context of the * current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object. @@ -229,7 +259,7 @@ declare module 'vm' { * executes that code multiple times: * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * global.globalVar = 0; * @@ -251,6 +281,16 @@ declare module 'vm' { * Creates a code cache that can be used with the `Script` constructor's`cachedData` option. Returns a `Buffer`. This method may be called at any * time and any number of times. * + * The code cache of the `Script` doesn't contain any JavaScript observable + * states. The code cache is safe to be saved along side the script source and + * used to construct new `Script` instances multiple times. + * + * Functions in the `Script` source can be marked as lazily compiled and they are + * not compiled at construction of the `Script`. These functions are going to be + * compiled when they are invoked the first time. The code cache serializes the + * metadata that V8 currently knows about the `Script` that it can use to speed up + * future compilations. + * * ```js * const script = new vm.Script(` * function add(a, b) { @@ -260,19 +300,46 @@ declare module 'vm' { * const x = add(1, 2); * `); * - * const cacheWithoutX = script.createCachedData(); + * const cacheWithoutAdd = script.createCachedData(); + * // In `cacheWithoutAdd` the function `add()` is marked for full compilation + * // upon invocation. * * script.runInThisContext(); * - * const cacheWithX = script.createCachedData(); + * const cacheWithAdd = script.createCachedData(); + * // `cacheWithAdd` contains fully compiled function `add()`. * ``` * @since v10.6.0 */ createCachedData(): Buffer; /** @deprecated in favor of `script.createCachedData()` */ cachedDataProduced?: boolean | undefined; + /** + * When `cachedData` is supplied to create the `vm.Script`, this value will be set + * to either `true` or `false` depending on acceptance of the data by V8\. + * Otherwise the value is `undefined`. + * @since v5.7.0 + */ cachedDataRejected?: boolean | undefined; cachedData?: Buffer | undefined; + /** + * When the script is compiled from a source that contains a source map magic + * comment, this property will be set to the URL of the source map. + * + * ```js + * import vm from 'node:vm'; + * + * const script = new vm.Script(` + * function myFunc() {} + * //# sourceMappingURL=sourcemap.json + * `); + * + * console.log(script.sourceMapURL); + * // Prints: sourcemap.json + * ``` + * @since v19.1.0, v18.13.0 + */ + sourceMapURL?: string | undefined; } /** * If given a `contextObject`, the `vm.createContext()` method will `prepare @@ -282,7 +349,7 @@ declare module 'vm' { * will remain unchanged. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * global.globalVar = 3; * @@ -329,7 +396,7 @@ declare module 'vm' { * The following example compiles and executes different scripts using a single `contextified` object: * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * const contextObject = { globalVar: 1 }; * vm.createContext(contextObject); @@ -345,7 +412,7 @@ declare module 'vm' { * @param contextifiedObject The `contextified` object that will be used as the `global` when the `code` is compiled and run. * @return the result of the very last statement executed in the script. */ - function runInContext(code: string, contextifiedObject: Context, options?: RunningScriptOptions | string): any; + function runInContext(code: string, contextifiedObject: Context, options?: RunningCodeOptions | string): any; /** * The `vm.runInNewContext()` first contextifies the given `contextObject` (or * creates a new `contextObject` if passed as `undefined`), compiles the `code`, @@ -358,11 +425,11 @@ declare module 'vm' { * variable and sets a new one. These globals are contained in the `contextObject`. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * const contextObject = { * animal: 'cat', - * count: 2 + * count: 2, * }; * * vm.runInNewContext('count += 1; name = "kitty"', contextObject); @@ -374,7 +441,7 @@ declare module 'vm' { * @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created. * @return the result of the very last statement executed in the script. */ - function runInNewContext(code: string, contextObject?: Context, options?: RunningScriptOptions | string): any; + function runInNewContext(code: string, contextObject?: Context, options?: RunningCodeInNewContextOptions | string): any; /** * `vm.runInThisContext()` compiles `code`, runs it within the context of the * current `global` and returns the result. Running code does not have access to @@ -386,7 +453,7 @@ declare module 'vm' { * the JavaScript [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) function to run the same code: * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * let localVar = 'initial value'; * * const vmResult = vm.runInThisContext('localVar = "vm";'); @@ -407,17 +474,17 @@ declare module 'vm' { * When using either `script.runInThisContext()` or {@link runInThisContext}, the code is executed within the current V8 global * context. The code passed to this VM context will have its own isolated scope. * - * In order to run a simple web server using the `http` module the code passed to - * the context must either call `require('http')` on its own, or have a reference - * to the `http` module passed to it. For instance: + * In order to run a simple web server using the `node:http` module the code passed + * to the context must either call `require('node:http')` on its own, or have a + * reference to the `node:http` module passed to it. For instance: * * ```js * 'use strict'; - * const vm = require('vm'); + * const vm = require('node:vm'); * * const code = ` * ((require) => { - * const http = require('http'); + * const http = require('node:http'); * * http.createServer((request, response) => { * response.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -437,7 +504,7 @@ declare module 'vm' { * @param code The JavaScript code to compile and run. * @return the result of the very last statement executed in the script. */ - function runInThisContext(code: string, options?: RunningScriptOptions | string): any; + function runInThisContext(code: string, options?: RunningCodeOptions | string): any; /** * Compiles the given code into the provided context (if no context is * supplied, the current context is used), and returns it wrapped inside a @@ -446,7 +513,15 @@ declare module 'vm' { * @param code The body of the function to compile. * @param params An array of strings containing all parameters for the function. */ - function compileFunction(code: string, params?: ReadonlyArray, options?: CompileFunctionOptions): Function; + function compileFunction( + code: string, + params?: ReadonlyArray, + options?: CompileFunctionOptions + ): Function & { + cachedData?: Script['cachedData'] | undefined; + cachedDataProduced?: Script['cachedDataProduced'] | undefined; + cachedDataRejected?: Script['cachedDataRejected'] | undefined; + }; /** * Measure the memory known to V8 and used by all contexts known to the * current V8 isolate, or the main context. @@ -460,7 +535,7 @@ declare module 'vm' { * the memory occupied by each heap space in the current V8 instance. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * // Measure the memory used by the main context. * vm.measureMemory({ mode: 'summary' }) * // This is the same as vm.measureMemory() @@ -503,6 +578,316 @@ declare module 'vm' { * @experimental */ function measureMemory(options?: MeasureMemoryOptions): Promise; + interface ModuleEvaluateOptions { + timeout?: RunningScriptOptions['timeout'] | undefined; + breakOnSigint?: RunningScriptOptions['breakOnSigint'] | undefined; + } + type ModuleLinker = ( + specifier: string, + referencingModule: Module, + extra: { + assert: Object; + } + ) => Module | Promise; + type ModuleStatus = 'unlinked' | 'linking' | 'linked' | 'evaluating' | 'evaluated' | 'errored'; + /** + * This feature is only available with the `--experimental-vm-modules` command + * flag enabled. + * + * The `vm.Module` class provides a low-level interface for using + * ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`class that closely mirrors [Module Record](https://www.ecma-international.org/ecma-262/#sec-abstract-module-records) + * s as defined in the ECMAScript + * specification. + * + * Unlike `vm.Script` however, every `vm.Module` object is bound to a context from + * its creation. Operations on `vm.Module` objects are intrinsically asynchronous, + * in contrast with the synchronous nature of `vm.Script` objects. The use of + * 'async' functions can help with manipulating `vm.Module` objects. + * + * Using a `vm.Module` object requires three distinct steps: creation/parsing, + * linking, and evaluation. These three steps are illustrated in the following + * example. + * + * This implementation lies at a lower level than the `ECMAScript Module + * loader`. There is also no way to interact with the Loader yet, though + * support is planned. + * + * ```js + * import vm from 'node:vm'; + * + * const contextifiedObject = vm.createContext({ + * secret: 42, + * print: console.log, + * }); + * + * // Step 1 + * // + * // Create a Module by constructing a new `vm.SourceTextModule` object. This + * // parses the provided source text, throwing a `SyntaxError` if anything goes + * // wrong. By default, a Module is created in the top context. But here, we + * // specify `contextifiedObject` as the context this Module belongs to. + * // + * // Here, we attempt to obtain the default export from the module "foo", and + * // put it into local binding "secret". + * + * const bar = new vm.SourceTextModule(` + * import s from 'foo'; + * s; + * print(s); + * `, { context: contextifiedObject }); + * + * // Step 2 + * // + * // "Link" the imported dependencies of this Module to it. + * // + * // The provided linking callback (the "linker") accepts two arguments: the + * // parent module (`bar` in this case) and the string that is the specifier of + * // the imported module. The callback is expected to return a Module that + * // corresponds to the provided specifier, with certain requirements documented + * // in `module.link()`. + * // + * // If linking has not started for the returned Module, the same linker + * // callback will be called on the returned Module. + * // + * // Even top-level Modules without dependencies must be explicitly linked. The + * // callback provided would never be called, however. + * // + * // The link() method returns a Promise that will be resolved when all the + * // Promises returned by the linker resolve. + * // + * // Note: This is a contrived example in that the linker function creates a new + * // "foo" module every time it is called. In a full-fledged module system, a + * // cache would probably be used to avoid duplicated modules. + * + * async function linker(specifier, referencingModule) { + * if (specifier === 'foo') { + * return new vm.SourceTextModule(` + * // The "secret" variable refers to the global variable we added to + * // "contextifiedObject" when creating the context. + * export default secret; + * `, { context: referencingModule.context }); + * + * // Using `contextifiedObject` instead of `referencingModule.context` + * // here would work as well. + * } + * throw new Error(`Unable to resolve dependency: ${specifier}`); + * } + * await bar.link(linker); + * + * // Step 3 + * // + * // Evaluate the Module. The evaluate() method returns a promise which will + * // resolve after the module has finished evaluating. + * + * // Prints 42. + * await bar.evaluate(); + * ``` + * @since v13.0.0, v12.16.0 + * @experimental + */ + class Module { + /** + * The specifiers of all dependencies of this module. The returned array is frozen + * to disallow any changes to it. + * + * Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in + * the ECMAScript specification. + */ + dependencySpecifiers: readonly string[]; + /** + * If the `module.status` is `'errored'`, this property contains the exception + * thrown by the module during evaluation. If the status is anything else, + * accessing this property will result in a thrown exception. + * + * The value `undefined` cannot be used for cases where there is not a thrown + * exception due to possible ambiguity with `throw undefined;`. + * + * Corresponds to the `[[EvaluationError]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s + * in the ECMAScript specification. + */ + error: any; + /** + * The identifier of the current module, as set in the constructor. + */ + identifier: string; + context: Context; + /** + * The namespace object of the module. This is only available after linking + * (`module.link()`) has completed. + * + * Corresponds to the [GetModuleNamespace](https://tc39.es/ecma262/#sec-getmodulenamespace) abstract operation in the ECMAScript + * specification. + */ + namespace: Object; + /** + * The current status of the module. Will be one of: + * + * * `'unlinked'`: `module.link()` has not yet been called. + * * `'linking'`: `module.link()` has been called, but not all Promises returned + * by the linker function have been resolved yet. + * * `'linked'`: The module has been linked successfully, and all of its + * dependencies are linked, but `module.evaluate()` has not yet been called. + * * `'evaluating'`: The module is being evaluated through a `module.evaluate()` on + * itself or a parent module. + * * `'evaluated'`: The module has been successfully evaluated. + * * `'errored'`: The module has been evaluated, but an exception was thrown. + * + * Other than `'errored'`, this status string corresponds to the specification's [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records)'s `[[Status]]` field. `'errored'` + * corresponds to`'evaluated'` in the specification, but with `[[EvaluationError]]` set to a + * value that is not `undefined`. + */ + status: ModuleStatus; + /** + * Evaluate the module. + * + * This must be called after the module has been linked; otherwise it will reject. + * It could be called also when the module has already been evaluated, in which + * case it will either do nothing if the initial evaluation ended in success + * (`module.status` is `'evaluated'`) or it will re-throw the exception that the + * initial evaluation resulted in (`module.status` is `'errored'`). + * + * This method cannot be called while the module is being evaluated + * (`module.status` is `'evaluating'`). + * + * Corresponds to the [Evaluate() concrete method](https://tc39.es/ecma262/#sec-moduleevaluation) field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in the + * ECMAScript specification. + * @return Fulfills with `undefined` upon success. + */ + evaluate(options?: ModuleEvaluateOptions): Promise; + /** + * Link module dependencies. This method must be called before evaluation, and + * can only be called once per module. + * + * The function is expected to return a `Module` object or a `Promise` that + * eventually resolves to a `Module` object. The returned `Module` must satisfy the + * following two invariants: + * + * * It must belong to the same context as the parent `Module`. + * * Its `status` must not be `'errored'`. + * + * If the returned `Module`'s `status` is `'unlinked'`, this method will be + * recursively called on the returned `Module` with the same provided `linker`function. + * + * `link()` returns a `Promise` that will either get resolved when all linking + * instances resolve to a valid `Module`, or rejected if the linker function either + * throws an exception or returns an invalid `Module`. + * + * The linker function roughly corresponds to the implementation-defined [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) abstract operation in the + * ECMAScript + * specification, with a few key differences: + * + * * The linker function is allowed to be asynchronous while [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) is synchronous. + * + * The actual [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) implementation used during module + * linking is one that returns the modules linked during linking. Since at + * that point all modules would have been fully linked already, the [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) implementation is fully synchronous per + * specification. + * + * Corresponds to the [Link() concrete method](https://tc39.es/ecma262/#sec-moduledeclarationlinking) field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in + * the ECMAScript specification. + */ + link(linker: ModuleLinker): Promise; + } + interface SourceTextModuleOptions { + /** + * String used in stack traces. + * @default 'vm:module(i)' where i is a context-specific ascending index. + */ + identifier?: string | undefined; + cachedData?: ScriptOptions['cachedData'] | undefined; + context?: Context | undefined; + lineOffset?: BaseOptions['lineOffset'] | undefined; + columnOffset?: BaseOptions['columnOffset'] | undefined; + /** + * Called during evaluation of this module to initialize the `import.meta`. + */ + initializeImportMeta?: ((meta: ImportMeta, module: SourceTextModule) => void) | undefined; + importModuleDynamically?: ScriptOptions['importModuleDynamically'] | undefined; + } + /** + * This feature is only available with the `--experimental-vm-modules` command + * flag enabled. + * + * + * + * The `vm.SourceTextModule` class provides the [Source Text Module Record](https://tc39.es/ecma262/#sec-source-text-module-records) as + * defined in the ECMAScript specification. + * @since v9.6.0 + * @experimental + */ + class SourceTextModule extends Module { + /** + * Creates a new `SourceTextModule` instance. + * @param code JavaScript Module code to parse + */ + constructor(code: string, options?: SourceTextModuleOptions); + } + interface SyntheticModuleOptions { + /** + * String used in stack traces. + * @default 'vm:module(i)' where i is a context-specific ascending index. + */ + identifier?: string | undefined; + /** + * The contextified object as returned by the `vm.createContext()` method, to compile and evaluate this module in. + */ + context?: Context | undefined; + } + /** + * This feature is only available with the `--experimental-vm-modules` command + * flag enabled. + * + * + * + * The `vm.SyntheticModule` class provides the [Synthetic Module Record](https://heycam.github.io/webidl/#synthetic-module-records) as + * defined in the WebIDL specification. The purpose of synthetic modules is to + * provide a generic interface for exposing non-JavaScript sources to ECMAScript + * module graphs. + * + * ```js + * const vm = require('node:vm'); + * + * const source = '{ "a": 1 }'; + * const module = new vm.SyntheticModule(['default'], function() { + * const obj = JSON.parse(source); + * this.setExport('default', obj); + * }); + * + * // Use `module` in linking... + * ``` + * @since v13.0.0, v12.16.0 + * @experimental + */ + class SyntheticModule extends Module { + /** + * Creates a new `SyntheticModule` instance. + * @param exportNames Array of names that will be exported from the module. + * @param evaluateCallback Called when the module is evaluated. + */ + constructor(exportNames: string[], evaluateCallback: (this: SyntheticModule) => void, options?: SyntheticModuleOptions); + /** + * This method is used after the module is linked to set the values of exports. If + * it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error + * will be thrown. + * + * ```js + * import vm from 'node:vm'; + * + * const m = new vm.SyntheticModule(['x'], () => { + * m.setExport('x', 1); + * }); + * + * await m.link(() => {}); + * await m.evaluate(); + * + * assert.strictEqual(m.namespace.x, 1); + * ``` + * @since v13.0.0, v12.16.0 + * @param name Name of the export to set. + * @param value The value to set the export to. + */ + setExport(name: string, value: any): void; + } } declare module 'node:vm' { export * from 'vm'; diff --git a/node_modules/@types/node/ts4.8/wasi.d.ts b/node_modules/@types/node/ts4.8/wasi.d.ts index d20b66bf4..9262e98bd 100755 --- a/node_modules/@types/node/ts4.8/wasi.d.ts +++ b/node_modules/@types/node/ts4.8/wasi.d.ts @@ -3,26 +3,23 @@ * underlying operating system via a collection of POSIX-like functions. * * ```js - * import { readFile } from 'fs/promises'; + * import { readFile } from 'node:fs/promises'; * import { WASI } from 'wasi'; - * import { argv, env } from 'process'; + * import { argv, env } from 'node:process'; * * const wasi = new WASI({ + * version: 'preview1', * args: argv, * env, * preopens: { - * '/sandbox': '/some/real/path/that/wasm/can/access' - * } + * '/sandbox': '/some/real/path/that/wasm/can/access', + * }, * }); * - * // Some WASI binaries require: - * // const importObject = { wasi_unstable: wasi.wasiImport }; - * const importObject = { wasi_snapshot_preview1: wasi.wasiImport }; - * * const wasm = await WebAssembly.compile( - * await readFile(new URL('./demo.wasm', import.meta.url)) + * await readFile(new URL('./demo.wasm', import.meta.url)), * ); - * const instance = await WebAssembly.instantiate(wasm, importObject); + * const instance = await WebAssembly.instantiate(wasm, wasi.getImportObject()); * * wasi.start(instance); * ``` @@ -64,11 +61,8 @@ * ```console * $ wat2wasm demo.wat * ``` - * - * The `--experimental-wasi-unstable-preview1` CLI argument is needed for this - * example to run. * @experimental - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/wasi.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/wasi.js) */ declare module 'wasi' { interface WASIOptions { @@ -91,11 +85,11 @@ declare module 'wasi' { */ preopens?: NodeJS.Dict | undefined; /** - * By default, WASI applications terminate the Node.js - * process via the `__wasi_proc_exit()` function. Setting this option to `true` - * causes `wasi.start()` to return the exit code rather than terminate the - * process. - * @default false + * By default, when WASI applications call `__wasi_proc_exit()` + * `wasi.start()` will return with the exit code specified rather than terminatng the process. + * Setting this option to `false` will cause the Node.js process to exit with + * the specified exit code instead. + * @default true */ returnOnExit?: boolean | undefined; /** diff --git a/node_modules/@types/node/ts4.8/worker_threads.d.ts b/node_modules/@types/node/ts4.8/worker_threads.d.ts index 81b71c283..e11932e42 100755 --- a/node_modules/@types/node/ts4.8/worker_threads.d.ts +++ b/node_modules/@types/node/ts4.8/worker_threads.d.ts @@ -1,9 +1,9 @@ /** - * The `worker_threads` module enables the use of threads that execute JavaScript - * in parallel. To access it: + * The `node:worker_threads` module enables the use of threads that execute + * JavaScript in parallel. To access it: * * ```js - * const worker = require('worker_threads'); + * const worker = require('node:worker_threads'); * ``` * * Workers (threads) are useful for performing CPU-intensive JavaScript operations. @@ -15,14 +15,14 @@ * * ```js * const { - * Worker, isMainThread, parentPort, workerData - * } = require('worker_threads'); + * Worker, isMainThread, parentPort, workerData, + * } = require('node:worker_threads'); * * if (isMainThread) { * module.exports = function parseJSAsync(script) { * return new Promise((resolve, reject) => { * const worker = new Worker(__filename, { - * workerData: script + * workerData: script, * }); * worker.on('message', resolve); * worker.on('error', reject); @@ -49,7 +49,7 @@ * * Worker threads inherit non-process-specific options by default. Refer to `Worker constructor options` to know how to customize worker thread options, * specifically `argv` and `execArgv` options. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/worker_threads.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/worker_threads.js) */ declare module 'worker_threads' { import { Blob } from 'node:buffer'; @@ -72,7 +72,7 @@ declare module 'worker_threads' { * The `MessageChannel` has no methods of its own. `new MessageChannel()`yields an object with `port1` and `port2` properties, which refer to linked `MessagePort` instances. * * ```js - * const { MessageChannel } = require('worker_threads'); + * const { MessageChannel } = require('node:worker_threads'); * * const { port1, port2 } = new MessageChannel(); * port1.on('message', (message) => console.log('received', message)); @@ -121,7 +121,7 @@ declare module 'worker_threads' { * * `value` may not contain native (C++-backed) objects other than: * * ```js - * const { MessageChannel } = require('worker_threads'); + * const { MessageChannel } = require('node:worker_threads'); * const { port1, port2 } = new MessageChannel(); * * port1.on('message', (message) => console.log(message)); @@ -132,7 +132,7 @@ declare module 'worker_threads' { * port2.postMessage(circularData); * ``` * - * `transferList` may be a list of [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), `MessagePort` and `FileHandle` objects. + * `transferList` may be a list of [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), `MessagePort`, and `FileHandle` objects. * After transferring, they are not usable on the sending side of the channel * anymore (even if they are not contained in `value`). Unlike with `child processes`, transferring handles such as network sockets is currently * not supported. @@ -143,7 +143,7 @@ declare module 'worker_threads' { * `value` may still contain `ArrayBuffer` instances that are not in`transferList`; in that case, the underlying memory is copied rather than moved. * * ```js - * const { MessageChannel } = require('worker_threads'); + * const { MessageChannel } = require('node:worker_threads'); * const { port1, port2 } = new MessageChannel(); * * port1.on('message', (message) => console.log(message)); @@ -170,7 +170,7 @@ declare module 'worker_threads' { * posting without having side effects. * * For more information on the serialization and deserialization mechanisms - * behind this API, see the `serialization API of the v8 module`. + * behind this API, see the `serialization API of the node:v8 module`. * @since v10.5.0 */ postMessage(value: any, transferList?: ReadonlyArray): void; @@ -262,6 +262,12 @@ declare module 'worker_threads' { * @default true */ trackUnmanagedFds?: boolean | undefined; + /** + * An optional `name` to be appended to the worker title + * for debuggin/identification purposes, making the final title as + * `[worker ${id}] ${name}`. + */ + name?: string | undefined; } interface ResourceLimits { /** @@ -288,9 +294,9 @@ declare module 'worker_threads' { * * Notable differences inside a Worker environment are: * - * * The `process.stdin`, `process.stdout` and `process.stderr` may be redirected by the parent thread. - * * The `require('worker_threads').isMainThread` property is set to `false`. - * * The `require('worker_threads').parentPort` message port is available. + * * The `process.stdin`, `process.stdout`, and `process.stderr` streams may be redirected by the parent thread. + * * The `require('node:worker_threads').isMainThread` property is set to `false`. + * * The `require('node:worker_threads').parentPort` message port is available. * * `process.exit()` does not stop the whole program, just the single thread, * and `process.abort()` is not available. * * `process.chdir()` and `process` methods that set group or user ids @@ -307,11 +313,11 @@ declare module 'worker_threads' { * * Creating `Worker` instances inside of other `Worker`s is possible. * - * Like [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the `cluster module`, two-way communication can be - * achieved through inter-thread message passing. Internally, a `Worker` has a - * built-in pair of `MessagePort` s that are already associated with each other - * when the `Worker` is created. While the `MessagePort` object on the parent side - * is not directly exposed, its functionalities are exposed through `worker.postMessage()` and the `worker.on('message')` event + * Like [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the `node:cluster module`, two-way communication + * can be achieved through inter-thread message passing. Internally, a `Worker` has + * a built-in pair of `MessagePort` s that are already associated with each + * other when the `Worker` is created. While the `MessagePort` object on the parent + * side is not directly exposed, its functionalities are exposed through `worker.postMessage()` and the `worker.on('message')` event * on the `Worker` object for the parent thread. * * To create custom messaging channels (which is encouraged over using the default @@ -324,10 +330,10 @@ declare module 'worker_threads' { * the thread barrier. * * ```js - * const assert = require('assert'); + * const assert = require('node:assert'); * const { - * Worker, MessageChannel, MessagePort, isMainThread, parentPort - * } = require('worker_threads'); + * Worker, MessageChannel, MessagePort, isMainThread, parentPort, + * } = require('node:worker_threads'); * if (isMainThread) { * const worker = new Worker(__filename); * const subChannel = new MessageChannel(); @@ -367,7 +373,7 @@ declare module 'worker_threads' { readonly stderr: Readable; /** * An integer identifier for the referenced thread. Inside the worker thread, - * it is available as `require('worker_threads').threadId`. + * it is available as `require('node:worker_threads').threadId`. * This value is unique for each `Worker` instance inside a single process. * @since v10.5.0 */ @@ -394,7 +400,7 @@ declare module 'worker_threads' { */ constructor(filename: string | URL, options?: WorkerOptions); /** - * Send a message to the worker that is received via `require('worker_threads').parentPort.on('message')`. + * Send a message to the worker that is received via `require('node:worker_threads').parentPort.on('message')`. * See `port.postMessage()` for more details. * @since v10.5.0 */ @@ -488,8 +494,8 @@ declare module 'worker_threads' { * const { * isMainThread, * BroadcastChannel, - * Worker - * } = require('worker_threads'); + * Worker, + * } = require('node:worker_threads'); * * const bc = new BroadcastChannel('hello'); * @@ -543,7 +549,7 @@ declare module 'worker_threads' { * This operation cannot be undone. * * ```js - * const { MessageChannel, markAsUntransferable } = require('worker_threads'); + * const { MessageChannel, markAsUntransferable } = require('node:worker_threads'); * * const pooledBuffer = new ArrayBuffer(8); * const typedArray1 = new Uint8Array(pooledBuffer); @@ -585,10 +591,10 @@ declare module 'worker_threads' { function moveMessagePortToContext(port: MessagePort, contextifiedSandbox: Context): MessagePort; /** * Receive a single message from a given `MessagePort`. If no message is available,`undefined` is returned, otherwise an object with a single `message` property - * that contains the message payload, corresponding to the oldest message in the`MessagePort`’s queue. + * that contains the message payload, corresponding to the oldest message in the`MessagePort`'s queue. * * ```js - * const { MessageChannel, receiveMessageOnPort } = require('worker_threads'); + * const { MessageChannel, receiveMessageOnPort } = require('node:worker_threads'); * const { port1, port2 } = new MessageChannel(); * port1.postMessage({ hello: 'world' }); * @@ -619,7 +625,7 @@ declare module 'worker_threads' { * isMainThread, * setEnvironmentData, * getEnvironmentData, - * } = require('worker_threads'); + * } = require('node:worker_threads'); * * if (isMainThread) { * setEnvironmentData('Hello', 'World!'); @@ -640,6 +646,47 @@ declare module 'worker_threads' { * for the `key` will be deleted. */ function setEnvironmentData(key: Serializable, value: Serializable): void; + + import { + BroadcastChannel as _BroadcastChannel, + MessageChannel as _MessageChannel, + MessagePort as _MessagePort, + } from 'worker_threads'; + global { + /** + * `BroadcastChannel` class is a global reference for `require('worker_threads').BroadcastChannel` + * https://nodejs.org/api/globals.html#broadcastchannel + * @since v18.0.0 + */ + var BroadcastChannel: typeof globalThis extends { + onmessage: any; + BroadcastChannel: infer T; + } + ? T + : typeof _BroadcastChannel; + /** + * `MessageChannel` class is a global reference for `require('worker_threads').MessageChannel` + * https://nodejs.org/api/globals.html#messagechannel + * @since v15.0.0 + */ + var MessageChannel: typeof globalThis extends { + onmessage: any; + MessageChannel: infer T; + } + ? T + : typeof _MessageChannel; + /** + * `MessagePort` class is a global reference for `require('worker_threads').MessagePort` + * https://nodejs.org/api/globals.html#messageport + * @since v15.0.0 + */ + var MessagePort: typeof globalThis extends { + onmessage: any; + MessagePort: infer T; + } + ? T + : typeof _MessagePort; + } } declare module 'node:worker_threads' { export * from 'worker_threads'; diff --git a/node_modules/@types/node/ts4.8/zlib.d.ts b/node_modules/@types/node/ts4.8/zlib.d.ts index 1d7f0c0e5..9d74cd27f 100755 --- a/node_modules/@types/node/ts4.8/zlib.d.ts +++ b/node_modules/@types/node/ts4.8/zlib.d.ts @@ -1,11 +1,11 @@ /** - * The `zlib` module provides compression functionality implemented using Gzip, - * Deflate/Inflate, and Brotli. + * The `node:zlib` module provides compression functionality implemented using + * Gzip, Deflate/Inflate, and Brotli. * * To access it: * * ```js - * const zlib = require('zlib'); + * const zlib = require('node:zlib'); * ``` * * Compression and decompression are built around the Node.js `Streams API`. @@ -15,12 +15,12 @@ * stream: * * ```js - * const { createGzip } = require('zlib'); - * const { pipeline } = require('stream'); + * const { createGzip } = require('node:zlib'); + * const { pipeline } = require('node:stream'); * const { * createReadStream, - * createWriteStream - * } = require('fs'); + * createWriteStream, + * } = require('node:fs'); * * const gzip = createGzip(); * const source = createReadStream('input.txt'); @@ -35,7 +35,7 @@ * * // Or, Promisified * - * const { promisify } = require('util'); + * const { promisify } = require('node:util'); * const pipe = promisify(pipeline); * * async function do_gzip(input, output) { @@ -55,7 +55,7 @@ * It is also possible to compress or decompress data in a single step: * * ```js - * const { deflate, unzip } = require('zlib'); + * const { deflate, unzip } = require('node:zlib'); * * const input = '.................................'; * deflate(input, (err, buffer) => { @@ -77,7 +77,7 @@ * * // Or, Promisified * - * const { promisify } = require('util'); + * const { promisify } = require('node:util'); * const do_unzip = promisify(unzip); * * do_unzip(buffer) @@ -88,7 +88,7 @@ * }); * ``` * @since v0.5.8 - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/zlib.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/zlib.js) */ declare module 'zlib' { import * as stream from 'node:stream'; diff --git a/node_modules/@types/node/tty.d.ts b/node_modules/@types/node/tty.d.ts index 6473f8db7..ca9ab823f 100755 --- a/node_modules/@types/node/tty.d.ts +++ b/node_modules/@types/node/tty.d.ts @@ -1,10 +1,9 @@ /** - * The `tty` module provides the `tty.ReadStream` and `tty.WriteStream` classes. - * In most cases, it will not be necessary or possible to use this module directly. - * However, it can be accessed using: + * The `node:tty` module provides the `tty.ReadStream` and `tty.WriteStream`classes. In most cases, it will not be necessary or possible to use this module + * directly. However, it can be accessed using: * * ```js - * const tty = require('tty'); + * const tty = require('node:tty'); * ``` * * When Node.js detects that it is being run with a text terminal ("TTY") @@ -22,7 +21,7 @@ * * In most cases, there should be little to no reason for an application to * manually create instances of the `tty.ReadStream` and `tty.WriteStream`classes. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/tty.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/tty.js) */ declare module 'tty' { import * as net from 'node:net'; diff --git a/node_modules/@types/node/url.d.ts b/node_modules/@types/node/url.d.ts index 18362c8aa..af8123db4 100755 --- a/node_modules/@types/node/url.d.ts +++ b/node_modules/@types/node/url.d.ts @@ -1,14 +1,14 @@ /** - * The `url` module provides utilities for URL resolution and parsing. It can be - * accessed using: + * The `node:url` module provides utilities for URL resolution and parsing. It can + * be accessed using: * * ```js - * import url from 'url'; + * import url from 'node:url'; * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/url.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/url.js) */ declare module 'url' { - import { Blob } from 'node:buffer'; + import { Blob as NodeBlob } from 'node:buffer'; import { ClientRequestArgs } from 'node:http'; import { ParsedUrlQuery, ParsedUrlQueryInput } from 'node:querystring'; // Input to `url.format` @@ -54,17 +54,11 @@ declare module 'url' { * * A `URIError` is thrown if the `auth` property is present but cannot be decoded. * - * Use of the legacy `url.parse()` method is discouraged. Users should - * use the WHATWG `URL` API. Because the `url.parse()` method uses a - * lenient, non-standard algorithm for parsing URL strings, security - * issues can be introduced. Specifically, issues with [host name spoofing](https://hackerone.com/reports/678487) and - * incorrect handling of usernames and passwords have been identified. - * - * Deprecation of this API has been shelved for now primarily due to the the - * inability of the [WHATWG API to parse relative URLs](https://github.com/nodejs/node/issues/12682#issuecomment-1154492373). - * [Discussions are ongoing](https://github.com/whatwg/url/issues/531) for the best way to resolve this. - * + * `url.parse()` uses a lenient, non-standard algorithm for parsing URL + * strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487) and incorrect handling of usernames and passwords. Do not use with untrusted + * input. CVEs are not issued for `url.parse()` vulnerabilities. Use the `WHATWG URL` API instead. * @since v0.1.25 + * @deprecated Use the WHATWG URL API instead. * @param urlString The URL string to parse. * @param [parseQueryString=false] If `true`, the `query` property will always be set to an object returned by the {@link querystring} module's `parse()` method. If `false`, the `query` property * on the returned URL object will be an unparsed, undecoded string. @@ -79,15 +73,15 @@ declare module 'url' { * The `url.format()` method returns a formatted URL string derived from`urlObject`. * * ```js - * const url = require('url'); + * const url = require('node:url'); * url.format({ * protocol: 'https', * hostname: 'example.com', * pathname: '/some/path', * query: { * page: 1, - * format: 'json' - * } + * format: 'json', + * }, * }); * * // => 'https://example.com/some/path?page=1&format=json' @@ -135,7 +129,7 @@ declare module 'url' { * string, an `Error` is thrown. * * `result` is returned. * @since v0.1.25 - * @deprecated Legacy: Use the WHATWG URL API instead. + * @legacy Use the WHATWG URL API instead. * @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`. */ function format(urlObject: URL, options?: URLFormatOptions): string; @@ -199,7 +193,7 @@ declare module 'url' { * string, an `Error` is thrown. * * `result` is returned. * @since v0.1.25 - * @deprecated Legacy: Use the WHATWG URL API instead. + * @legacy Use the WHATWG URL API instead. * @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`. */ function format(urlObject: UrlObject | string): string; @@ -208,7 +202,7 @@ declare module 'url' { * manner similar to that of a web browser resolving an anchor tag. * * ```js - * const url = require('url'); + * const url = require('node:url'); * url.resolve('/one/two/three', 'four'); // '/one/two/four' * url.resolve('http://example.com/', '/one'); // 'http://example.com/one' * url.resolve('http://example.com/one', '/two'); // 'http://example.com/two' @@ -232,7 +226,7 @@ declare module 'url' { * resolve('http://example.com/one', '/two'); // 'http://example.com/two' * ``` * @since v0.1.25 - * @deprecated Legacy: Use the WHATWG URL API instead. + * @legacy Use the WHATWG URL API instead. * @param from The base URL to use if `to` is a relative URL. * @param to The target URL to resolve. */ @@ -243,10 +237,8 @@ declare module 'url' { * * It performs the inverse operation to {@link domainToUnicode}. * - * This feature is only available if the `node` executable was compiled with `ICU` enabled. If not, the domain names are passed through unchanged. - * * ```js - * import url from 'url'; + * import url from 'node:url'; * * console.log(url.domainToASCII('español.com')); * // Prints xn--espaol-zwa.com @@ -264,10 +256,8 @@ declare module 'url' { * * It performs the inverse operation to {@link domainToASCII}. * - * This feature is only available if the `node` executable was compiled with `ICU` enabled. If not, the domain names are passed through unchanged. - * * ```js - * import url from 'url'; + * import url from 'node:url'; * * console.log(url.domainToUnicode('xn--espaol-zwa.com')); * // Prints español.com @@ -284,7 +274,7 @@ declare module 'url' { * well as ensuring a cross-platform valid absolute path string. * * ```js - * import { fileURLToPath } from 'url'; + * import { fileURLToPath } from 'node:url'; * * const __filename = fileURLToPath(import.meta.url); * @@ -310,7 +300,7 @@ declare module 'url' { * control characters are correctly encoded when converting into a File URL. * * ```js - * import { pathToFileURL } from 'url'; + * import { pathToFileURL } from 'node:url'; * * new URL('/foo#1', 'file:'); // Incorrect: file:///foo#1 * pathToFileURL('/foo#1'); // Correct: file:///foo%231 (POSIX) @@ -328,7 +318,7 @@ declare module 'url' { * expected by the `http.request()` and `https.request()` APIs. * * ```js - * import { urlToHttpOptions } from 'url'; + * import { urlToHttpOptions } from 'node:url'; * const myURL = new URL('https://a:b@測試?abc#foo'); * * console.log(urlToHttpOptions(myURL)); @@ -376,7 +366,7 @@ declare module 'url' { * const { * Blob, * resolveObjectURL, - * } = require('buffer'); + * } = require('node:buffer'); * * const blob = new Blob(['hello']); * const id = URL.createObjectURL(blob); @@ -395,10 +385,10 @@ declare module 'url' { * @since v16.7.0 * @experimental */ - static createObjectURL(blob: Blob): string; + static createObjectURL(blob: NodeBlob): string; /** * Removes the stored `Blob` identified by the given ID. Attempting to revoke a - * ID that isn’t registered will silently fail. + * ID that isn't registered will silently fail. * @since v16.7.0 * @experimental * @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`. @@ -449,7 +439,7 @@ declare module 'url' { * // Prints example.org * * // Setting the hostname does not change the port - * myURL.hostname = 'example.com:82'; + * myURL.hostname = 'example.com'; * console.log(myURL.href); * // Prints https://example.com:81/foo * @@ -512,7 +502,7 @@ declare module 'url' { * * myURL.password = '123'; * console.log(myURL.href); - * // Prints https://abc:123@example.com + * // Prints https://abc:123@example.com/ * ``` * * Invalid URL characters included in the value assigned to the `password` property @@ -656,14 +646,14 @@ declare module 'url' { * character, while `URLSearchParams` will always encode it: * * ```js - * const myUrl = new URL('https://example.org/abc?foo=~bar'); + * const myURL = new URL('https://example.org/abc?foo=~bar'); * - * console.log(myUrl.search); // prints ?foo=~bar + * console.log(myURL.search); // prints ?foo=~bar * * // Modify the URL via searchParams... - * myUrl.searchParams.sort(); + * myURL.searchParams.sort(); * - * console.log(myUrl.search); // prints ?foo=%7Ebar + * console.log(myURL.search); // prints ?foo=%7Ebar * ``` */ readonly searchParams: URLSearchParams; @@ -758,9 +748,12 @@ declare module 'url' { */ append(name: string, value: string): void; /** - * Remove all name-value pairs whose name is `name`. + * If `value` is provided, removes all name-value pairs + * where name is `name` and value is `value`.. + * + * If `value` is not provided, removes all name-value pairs whose name is `name`. */ - delete(name: string): void; + delete(name: string, value?: string): void; /** * Returns an ES6 `Iterator` over each of the name-value pairs in the query. * Each item of the iterator is a JavaScript `Array`. The first item of the `Array`is the `name`, the second item of the `Array` is the `value`. @@ -796,9 +789,15 @@ declare module 'url' { */ getAll(name: string): string[]; /** - * Returns `true` if there is at least one name-value pair whose name is `name`. + * Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument. + * + * If `value` is provided, returns `true` when name-value pair with + * same `name` and `value` exists. + * + * If `value` is not provided, returns `true` if there is at least one name-value + * pair whose name is `name`. */ - has(name: string): boolean; + has(name: string, value?: string): boolean; /** * Returns an ES6 `Iterator` over the names of each name-value pair. * @@ -833,6 +832,11 @@ declare module 'url' { * ``` */ set(name: string, value: string): void; + /** + * The total number of parameter entries. + * @since v19.8.0 + */ + readonly size: number; /** * Sort all existing name-value pairs in-place by their names. Sorting is done * with a [stable sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability), so relative order between name-value pairs @@ -875,9 +879,9 @@ declare module 'url' { */ var URL: typeof globalThis extends { onmessage: any; - URL: infer URL; + URL: infer T; } - ? URL + ? T : typeof _URL; /** * `URLSearchParams` class is a global reference for `require('url').URLSearchParams` @@ -886,9 +890,9 @@ declare module 'url' { */ var URLSearchParams: typeof globalThis extends { onmessage: any; - URLSearchParams: infer URLSearchParams; + URLSearchParams: infer T; } - ? URLSearchParams + ? T : typeof _URLSearchParams; } } diff --git a/node_modules/@types/node/util.d.ts b/node_modules/@types/node/util.d.ts index a08132568..ce46cb7d0 100755 --- a/node_modules/@types/node/util.d.ts +++ b/node_modules/@types/node/util.d.ts @@ -1,33 +1,49 @@ /** - * The `util` module supports the needs of Node.js internal APIs. Many of the + * The `node:util` module supports the needs of Node.js internal APIs. Many of the * utilities are useful for application and module developers as well. To access * it: * * ```js - * const util = require('util'); + * const util = require('node:util'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/util.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/util.js) */ declare module 'util' { import * as types from 'node:util/types'; export interface InspectOptions { /** - * If set to `true`, getters are going to be - * inspected as well. If set to `'get'` only getters without setter are going - * to be inspected. If set to `'set'` only getters having a corresponding - * setter are going to be inspected. This might cause side effects depending on - * the getter function. - * @default `false` + * If `true`, object's non-enumerable symbols and properties are included in the formatted result. + * `WeakMap` and `WeakSet` entries are also included as well as user defined prototype properties (excluding method properties). + * @default false */ - getters?: 'get' | 'set' | boolean | undefined; showHidden?: boolean | undefined; /** + * Specifies the number of times to recurse while formatting object. + * This is useful for inspecting large objects. + * To recurse up to the maximum call stack size pass `Infinity` or `null`. * @default 2 */ depth?: number | null | undefined; + /** + * If `true`, the output is styled with ANSI color codes. Colors are customizable. + */ colors?: boolean | undefined; + /** + * If `false`, `[util.inspect.custom](depth, opts, inspect)` functions are not invoked. + * @default true + */ customInspect?: boolean | undefined; + /** + * If `true`, `Proxy` inspection includes the target and handler objects. + * @default false + */ showProxy?: boolean | undefined; + /** + * Specifies the maximum number of `Array`, `TypedArray`, `WeakMap`, and `WeakSet` elements + * to include when formatting. Set to `null` or `Infinity` to show all elements. + * Set to `0` or negative to show no elements. + * @default 100 + */ maxArrayLength?: number | null | undefined; /** * Specifies the maximum number of characters to @@ -36,6 +52,12 @@ declare module 'util' { * @default 10000 */ maxStringLength?: number | null | undefined; + /** + * The length at which input values are split across multiple lines. + * Set to `Infinity` to format the input as a single line + * (in combination with `compact` set to `true` or any number >= `1`). + * @default 80 + */ breakLength?: number | undefined; /** * Setting this to `false` causes each object key @@ -45,13 +67,33 @@ declare module 'util' { * `breakLength`. Short array elements are also grouped together. Note that no * text will be reduced below 16 characters, no matter the `breakLength` size. * For more information, see the example below. - * @default `true` + * @default true */ compact?: boolean | number | undefined; + /** + * If set to `true` or a function, all properties of an object, and `Set` and `Map` + * entries are sorted in the resulting string. + * If set to `true` the default sort is used. + * If set to a function, it is used as a compare function. + */ sorted?: boolean | ((a: string, b: string) => number) | undefined; + /** + * If set to `true`, getters are going to be + * inspected as well. If set to `'get'` only getters without setter are going + * to be inspected. If set to `'set'` only getters having a corresponding + * setter are going to be inspected. This might cause side effects depending on + * the getter function. + * @default false + */ + getters?: 'get' | 'set' | boolean | undefined; + /** + * If set to `true`, an underscore is used to separate every three digits in all bigints and numbers. + * @default false + */ + numericSeparator?: boolean | undefined; } export type Style = 'special' | 'number' | 'bigint' | 'boolean' | 'undefined' | 'null' | 'string' | 'symbol' | 'date' | 'regexp' | 'module'; - export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => string; + export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => any; // TODO: , inspect: inspect export interface InspectOptionsStylized extends InspectOptions { stylize(text: string, styleType: Style): string; } @@ -147,7 +189,7 @@ declare module 'util' { * timestamp. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.log('Timestamped message.'); * ``` @@ -162,6 +204,52 @@ declare module 'util' { * @since v16.8.0, v14.18.0 */ export function toUSVString(string: string): string; + /** + * Creates and returns an `AbortController` instance whose `AbortSignal` is marked + * as transferable and can be used with `structuredClone()` or `postMessage()`. + * @since v18.11.0 + * @experimental + * @returns A transferable AbortController + */ + export function transferableAbortController(): AbortController; + /** + * Marks the given `AbortSignal` as transferable so that it can be used with`structuredClone()` and `postMessage()`. + * + * ```js + * const signal = transferableAbortSignal(AbortSignal.timeout(100)); + * const channel = new MessageChannel(); + * channel.port2.postMessage(signal, [signal]); + * ``` + * @since v18.11.0 + * @experimental + * @param signal The AbortSignal + * @returns The same AbortSignal + */ + export function transferableAbortSignal(signal: AbortSignal): AbortSignal; + /** + * Listens to abort event on the provided `signal` and + * returns a promise that is fulfilled when the `signal` is + * aborted. If the passed `resource` is garbage collected before the `signal` is + * aborted, the returned promise shall remain pending indefinitely. + * + * ```js + * import { aborted } from 'node:util'; + * + * const dependent = obtainSomethingAbortable(); + * + * aborted(dependent.signal, dependent).then(() => { + * // Do something when dependent is aborted. + * }); + * + * dependent.on('event', () => { + * dependent.abort(); + * }); + * ``` + * @since v19.7.0 + * @experimental + * @param resource Any non-null entity, reference to which is held weakly. + */ + export function aborted(signal: AbortSignal, resource: any): Promise; /** * The `util.inspect()` method returns a string representation of `object` that is * intended for debugging. The output of `util.inspect` may change at any time @@ -188,7 +276,7 @@ declare module 'util' { * Circular references point to their anchor by using a reference index: * * ```js - * const { inspect } = require('util'); + * const { inspect } = require('node:util'); * * const obj = {}; * obj.a = [obj]; @@ -206,7 +294,7 @@ declare module 'util' { * The following example inspects all properties of the `util` object: * * ```js - * const util = require('util'); + * const util = require('node:util'); * * console.log(util.inspect(util, { showHidden: true, depth: null })); * ``` @@ -214,7 +302,7 @@ declare module 'util' { * The following example highlights the effect of the `compact` option: * * ```js - * const util = require('util'); + * const util = require('node:util'); * * const o = { * a: [1, 2, [[ @@ -222,7 +310,7 @@ declare module 'util' { * 'eiusmod \ntempor incididunt ut labore et dolore magna aliqua.', * 'test', * 'foo']], 4], - * b: new Map([['za', 1], ['zb', 'test']]) + * b: new Map([['za', 1], ['zb', 'test']]), * }; * console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 })); * @@ -271,7 +359,7 @@ declare module 'util' { * with no remaining strong references may be garbage collected at any time. * * ```js - * const { inspect } = require('util'); + * const { inspect } = require('node:util'); * * const obj = { a: 1 }; * const obj2 = { b: 2 }; @@ -285,13 +373,13 @@ declare module 'util' { * impact the result of `util.inspect()`. * * ```js - * const { inspect } = require('util'); - * const assert = require('assert'); + * const { inspect } = require('node:util'); + * const assert = require('node:assert'); * * const o1 = { * b: [2, 3, 1], * a: '`a` comes before `b`', - * c: new Set([2, 3, 1]) + * c: new Set([2, 3, 1]), * }; * console.log(inspect(o1, { sorted: true })); * // { a: '`a` comes before `b`', b: [ 2, 3, 1 ], c: Set(3) { 1, 2, 3 } } @@ -301,11 +389,11 @@ declare module 'util' { * const o2 = { * c: new Set([2, 1, 3]), * a: '`a` comes before `b`', - * b: [2, 3, 1] + * b: [2, 3, 1], * }; * assert.strict.equal( * inspect(o1, { sorted: true }), - * inspect(o2, { sorted: true }) + * inspect(o2, { sorted: true }), * ); * ``` * @@ -313,7 +401,7 @@ declare module 'util' { * numbers. * * ```js - * const { inspect } = require('util'); + * const { inspect } = require('node:util'); * * const thousand = 1_000; * const million = 1_000_000; @@ -325,7 +413,7 @@ declare module 'util' { * ``` * * `util.inspect()` is a synchronous method intended for debugging. Its maximum - * output length is approximately 128 MB. Inputs that result in longer output will + * output length is approximately 128 MiB. Inputs that result in longer output will * be truncated. * @since v0.3.0 * @param object Any JavaScript primitive or `Object`. @@ -354,7 +442,7 @@ declare module 'util' { * Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isArray([]); * // Returns: true @@ -371,7 +459,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isRegExp(/some regexp/); * // Returns: true @@ -388,7 +476,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isDate(new Date()); * // Returns: true @@ -405,7 +493,7 @@ declare module 'util' { * Returns `true` if the given `object` is an `Error`. Otherwise, returns`false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isError(new Error()); * // Returns: true @@ -419,7 +507,7 @@ declare module 'util' { * possible to obtain an incorrect result when the `object` argument manipulates`@@toStringTag`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * const obj = { name: 'Error', message: 'an error occurred' }; * * util.isError(obj); @@ -444,8 +532,8 @@ declare module 'util' { * through the `constructor.super_` property. * * ```js - * const util = require('util'); - * const EventEmitter = require('events'); + * const util = require('node:util'); + * const EventEmitter = require('node:events'); * * function MyStream() { * EventEmitter.call(this); @@ -471,7 +559,7 @@ declare module 'util' { * ES6 example using `class` and `extends`: * * ```js - * const EventEmitter = require('events'); + * const EventEmitter = require('node:events'); * * class MyStream extends EventEmitter { * write(data) { @@ -487,7 +575,7 @@ declare module 'util' { * stream.write('With ES6'); * ``` * @since v0.3.0 - * @deprecated Legacy: Use ES2015 class syntax and `extends` keyword instead. + * @legacy Use ES2015 class syntax and `extends` keyword instead. */ export function inherits(constructor: unknown, superConstructor: unknown): void; export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void; @@ -500,7 +588,7 @@ declare module 'util' { * environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op. * * ```js - * const util = require('util'); + * const util = require('node:util'); * const debuglog = util.debuglog('foo'); * * debuglog('hello from foo [%d]', 123); @@ -519,7 +607,7 @@ declare module 'util' { * The `section` supports wildcard also: * * ```js - * const util = require('util'); + * const util = require('node:util'); * const debuglog = util.debuglog('foo-bar'); * * debuglog('hi there, it\'s foo-bar [%d]', 2333); @@ -539,7 +627,7 @@ declare module 'util' { * unnecessary wrapping. * * ```js - * const util = require('util'); + * const util = require('node:util'); * let debuglog = util.debuglog('internals', (debug) => { * // Replace with a logging function that optimizes out * // testing if the section is enabled @@ -557,7 +645,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isBoolean(1); * // Returns: false @@ -574,7 +662,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isBuffer({ length: 0 }); * // Returns: false @@ -591,7 +679,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Function`. Otherwise, returns`false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * function Foo() {} * const Bar = () => {}; @@ -611,7 +699,7 @@ declare module 'util' { * Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isNull(0); * // Returns: false @@ -629,7 +717,7 @@ declare module 'util' { * returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isNullOrUndefined(0); * // Returns: false @@ -646,7 +734,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isNumber(false); * // Returns: false @@ -666,7 +754,7 @@ declare module 'util' { * Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isObject(5); * // Returns: false @@ -678,14 +766,14 @@ declare module 'util' { * // Returns: false * ``` * @since v0.11.5 - * @deprecated Since v4.0.0 - Deprecated: Use `value !== null && typeof value === 'object'` instead. + * @deprecated Since v4.0.0 - Use `value !== null && typeof value === 'object'` instead. */ export function isObject(object: unknown): boolean; /** * Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isPrimitive(5); * // Returns: true @@ -714,7 +802,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `string`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isString(''); * // Returns: true @@ -733,7 +821,7 @@ declare module 'util' { * Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * util.isSymbol(5); * // Returns: false @@ -750,7 +838,7 @@ declare module 'util' { * Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * const foo = undefined; * util.isUndefined(5); @@ -769,7 +857,7 @@ declare module 'util' { * such a way that it is marked as deprecated. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * exports.obsoleteFunction = util.deprecate(() => { * // Do something here. @@ -785,7 +873,7 @@ declare module 'util' { * the warning will be emitted only once for that `code`. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001'); * const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001'); @@ -839,7 +927,7 @@ declare module 'util' { * first argument will be the rejection reason (or `null` if the `Promise`resolved), and the second argument will be the resolved value. * * ```js - * const util = require('util'); + * const util = require('node:util'); * * async function fn() { * return 'hello world'; @@ -878,7 +966,7 @@ declare module 'util' { * }); * ``` * @since v8.2.0 - * @param original An `async` function + * @param fn An `async` function * @return a callback style function */ export function callbackify(fn: () => Promise): (callback: (err: NodeJS.ErrnoException) => void) => void; @@ -922,8 +1010,8 @@ declare module 'util' { * that returns promises. * * ```js - * const util = require('util'); - * const fs = require('fs'); + * const util = require('node:util'); + * const fs = require('node:fs'); * * const stat = util.promisify(fs.stat); * stat('.').then((stats) => { @@ -936,8 +1024,8 @@ declare module 'util' { * Or, equivalently using `async function`s: * * ```js - * const util = require('util'); - * const fs = require('fs'); + * const util = require('node:util'); + * const fs = require('node:fs'); * * const stat = util.promisify(fs.stat); * @@ -958,7 +1046,7 @@ declare module 'util' { * work as expected unless handled specially: * * ```js - * const util = require('util'); + * const util = require('node:util'); * * class Foo { * constructor() { @@ -1047,7 +1135,7 @@ declare module 'util' { * internally and emitted after the next call to `textDecoder.decode()`. * * If `textDecoder.fatal` is `true`, decoding errors that occur will result in a`TypeError` being thrown. - * @param input An `ArrayBuffer`, `DataView` or `TypedArray` instance containing the encoded data. + * @param input An `ArrayBuffer`, `DataView`, or `TypedArray` instance containing the encoded data. */ decode( input?: NodeJS.ArrayBufferView | ArrayBuffer | null, @@ -1067,6 +1155,8 @@ declare module 'util' { written: number; } export { types }; + + //// TextEncoder/Decoder /** * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextEncoder` API. All * instances of `TextEncoder` only support UTF-8 encoding. @@ -1105,65 +1195,115 @@ declare module 'util' { */ encodeInto(src: string, dest: Uint8Array): EncodeIntoResult; } + import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from 'util'; + global { + /** + * `TextDecoder` class is a global reference for `require('util').TextDecoder` + * https://nodejs.org/api/globals.html#textdecoder + * @since v11.0.0 + */ + var TextDecoder: typeof globalThis extends { + onmessage: any; + TextDecoder: infer TextDecoder; + } + ? TextDecoder + : typeof _TextDecoder; + /** + * `TextEncoder` class is a global reference for `require('util').TextEncoder` + * https://nodejs.org/api/globals.html#textencoder + * @since v11.0.0 + */ + var TextEncoder: typeof globalThis extends { + onmessage: any; + TextEncoder: infer TextEncoder; + } + ? TextEncoder + : typeof _TextEncoder; + } - /** - * Provides a high-level API for command-line argument parsing. Takes a - * specification for the expected arguments and returns a structured object - * with the parsed values and positionals. - * - * `config` provides arguments for parsing and configures the parser. It - * supports the following properties: - * - * - `args` The array of argument strings. **Default:** `process.argv` with - * `execPath` and `filename` removed. - * - `options` Arguments known to the parser. Keys of `options` are the long - * names of options and values are objects accepting the following properties: - * - * - `type` Type of argument, which must be either `boolean` (for options - * which do not take values) or `string` (for options which do). - * - `multiple` Whether this option can be provided multiple - * times. If `true`, all values will be collected in an array. If - * `false`, values for the option are last-wins. **Default:** `false`. - * - `short` A single character alias for the option. - * - * - `strict`: Whether an error should be thrown when unknown arguments - * are encountered, or when arguments are passed that do not match the - * `type` configured in `options`. **Default:** `true`. - * - `allowPositionals`: Whether this command accepts positional arguments. - * **Default:** `false` if `strict` is `true`, otherwise `true`. - * - `tokens`: Whether tokens {boolean} Return the parsed tokens. This is useful - * for extending the built-in behavior, from adding additional checks through - * to reprocessing the tokens in different ways. - * **Default:** `false`. - * - * @returns The parsed command line arguments: - * - * - `values` A mapping of parsed option names with their string - * or boolean values. - * - `positionals` Positional arguments. - * - `tokens` Detailed parse information (only if `tokens` was specified). - * - */ - export function parseArgs(config: T): ParsedResults; - + //// parseArgs + /** + * Provides a higher level API for command-line argument parsing than interacting + * with `process.argv` directly. Takes a specification for the expected arguments + * and returns a structured object with the parsed options and positionals. + * + * ```js + * import { parseArgs } from 'node:util'; + * const args = ['-f', '--bar', 'b']; + * const options = { + * foo: { + * type: 'boolean', + * short: 'f', + * }, + * bar: { + * type: 'string', + * }, + * }; + * const { + * values, + * positionals, + * } = parseArgs({ args, options }); + * console.log(values, positionals); + * // Prints: [Object: null prototype] { foo: true, bar: 'b' } [] + * ``` + * @since v18.3.0, v16.17.0 + * @param config Used to provide arguments for parsing and to configure the parser. `config` supports the following properties: + * @return The parsed command line arguments: + */ + export function parseArgs(config?: T): ParsedResults; interface ParseArgsOptionConfig { + /** + * Type of argument. + */ type: 'string' | 'boolean'; - short?: string; - multiple?: boolean; + /** + * Whether this option can be provided multiple times. + * If `true`, all values will be collected in an array. + * If `false`, values for the option are last-wins. + * @default false. + */ + multiple?: boolean | undefined; + /** + * A single character alias for the option. + */ + short?: string | undefined; + /** + * The default option value when it is not set by args. + * It must be of the same type as the the `type` property. + * When `multiple` is `true`, it must be an array. + * @since v18.11.0 + */ + default?: string | boolean | string[] | boolean[] | undefined; } - interface ParseArgsOptionsConfig { [longOption: string]: ParseArgsOptionConfig; } - export interface ParseArgsConfig { - strict?: boolean; - allowPositionals?: boolean; - tokens?: boolean; - options?: ParseArgsOptionsConfig; - args?: string[]; + /** + * Array of argument strings. + */ + args?: string[] | undefined; + /** + * Used to describe arguments known to the parser. + */ + options?: ParseArgsOptionsConfig | undefined; + /** + * Should an error be thrown when unknown arguments are encountered, + * or when arguments are passed that do not match the `type` configured in `options`. + * @default true + */ + strict?: boolean | undefined; + /** + * Whether this command accepts positional arguments. + */ + allowPositionals?: boolean | undefined; + /** + * Return the parsed tokens. This is useful for extending the built-in behavior, + * from adding additional checks through to reprocessing the tokens in different ways. + * @default false + */ + tokens?: boolean | undefined; } - /* IfDefaultsTrue and IfDefaultsFalse are helpers to handle default values for missing boolean properties. TypeScript does not have exact types for objects: https://github.com/microsoft/TypeScript/issues/12936 @@ -1287,11 +1427,103 @@ declare module 'util' { // So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above. type ParsedResults = ParseArgsConfig extends T ? { - values: { [longOption: string]: undefined | string | boolean | Array }; + values: { + [longOption: string]: undefined | string | boolean | Array; + }; positionals: string[]; tokens?: Token[]; } : PreciseParsedResults; + + /** + * An implementation of [the MIMEType class](https://bmeck.github.io/node-proposal-mime-api/). + * + * In accordance with browser conventions, all properties of `MIMEType` objects + * are implemented as getters and setters on the class prototype, rather than as + * data properties on the object itself. + * + * A MIME string is a structured string containing multiple meaningful + * components. When parsed, a `MIMEType` object is returned containing + * properties for each of these components. + * @since v19.1.0, v18.13.0 + * @experimental + */ + export class MIMEType { + /** + * Creates a new MIMEType object by parsing the input. + * + * A `TypeError` will be thrown if the `input` is not a valid MIME. + * Note that an effort will be made to coerce the given values into strings. + * @param input The input MIME to parse. + */ + constructor(input: string | { toString: () => string }); + + /** + * Gets and sets the type portion of the MIME. + */ + type: string; + /** + * Gets and sets the subtype portion of the MIME. + */ + subtype: string; + /** + * Gets the essence of the MIME. + * + * Use `mime.type` or `mime.subtype` to alter the MIME. + */ + readonly essence: string; + /** + * Gets the `MIMEParams` object representing the parameters of the MIME. + */ + readonly params: MIMEParams; + /** + * Returns the serialized MIME. + * + * Because of the need for standard compliance, this method + * does not allow users to customize the serialization process of the MIME. + */ + toString(): string; + } + /** + * @since v18.13.0 + */ + export class MIMEParams { + /** + * Remove all name-value pairs whose name is `name`. + */ + delete(name: string): void; + /** + * Returns an iterator over each of the name-value pairs in the parameters. + */ + entries(): IterableIterator<[name: string, value: string]>; + /** + * Returns the value of the first name-value pair whose name is `name`. + * If there are no such pairs, `null` is returned. + */ + get(name: string): string | null; + /** + * Returns `true` if there is at least one name-value pair whose name is `name`. + */ + has(name: string): boolean; + /** + * Returns an iterator over the names of each name-value pair. + */ + keys(): IterableIterator; + /** + * Sets the value in the `MIMEParams` object associated with `name` to `value`. + * If there are any pre-existing name-value pairs whose names are `name`, + * set the first such pair's value to `value`. + */ + set(name: string, value: string): void; + /** + * Returns an iterator over the values of each name-value pair. + */ + values(): IterableIterator; + /** + * Returns an iterator over each of the name-value pairs in the parameters. + */ + [Symbol.iterator]: typeof MIMEParams.prototype.entries; + } } declare module 'util/types' { export * from 'util/types'; @@ -1589,12 +1821,40 @@ declare module 'util/types' { */ function isModuleNamespaceObject(value: unknown): boolean; /** - * Returns `true` if the value is an instance of a built-in `Error` type. + * Returns `true` if the value was returned by the constructor of a [built-in `Error` type](https://tc39.es/ecma262/#sec-error-objects). + * + * ```js + * console.log(util.types.isNativeError(new Error())); // true + * console.log(util.types.isNativeError(new TypeError())); // true + * console.log(util.types.isNativeError(new RangeError())); // true + * ``` + * + * Subclasses of the native error types are also native errors: + * + * ```js + * class MyError extends Error {} + * console.log(util.types.isNativeError(new MyError())); // true + * ``` + * + * A value being `instanceof` a native error class is not equivalent to `isNativeError()`returning `true` for that value. `isNativeError()` returns `true` for errors + * which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false`for these errors: + * + * ```js + * const vm = require('node:vm'); + * const context = vm.createContext({}); + * const myError = vm.runInContext('new Error()', context); + * console.log(util.types.isNativeError(myError)); // true + * console.log(myError instanceof Error); // false + * ``` + * + * Conversely, `isNativeError()` returns `false` for all objects which were not + * returned by the constructor of a native error. That includes values + * which are `instanceof` native errors: * * ```js - * util.types.isNativeError(new Error()); // Returns true - * util.types.isNativeError(new TypeError()); // Returns true - * util.types.isNativeError(new RangeError()); // Returns true + * const myError = { __proto__: Error.prototype }; + * console.log(util.types.isNativeError(myError)); // false + * console.log(myError instanceof Error); // true * ``` * @since v10.0.0 */ diff --git a/node_modules/@types/node/v8.d.ts b/node_modules/@types/node/v8.d.ts index 6685dc253..064f5d59e 100755 --- a/node_modules/@types/node/v8.d.ts +++ b/node_modules/@types/node/v8.d.ts @@ -1,10 +1,10 @@ /** - * The `v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using: + * The `node:v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using: * * ```js - * const v8 = require('v8'); + * const v8 = require('node:v8'); * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/v8.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/v8.js) */ declare module 'v8' { import { Readable } from 'node:stream'; @@ -29,6 +29,9 @@ declare module 'v8' { does_zap_garbage: DoesZapCodeSpaceFlag; number_of_native_contexts: number; number_of_detached_contexts: number; + total_global_handles_size: number; + used_global_handles_size: number; + external_memory: number; } interface HeapCodeStatistics { code_and_metadata_size: number; @@ -68,6 +71,15 @@ declare module 'v8' { * of contexts that were detached and not yet garbage collected. This number * being non-zero indicates a potential memory leak. * + * `total_global_handles_size` The value of total\_global\_handles\_size is the + * total memory size of V8 global handles. + * + * `used_global_handles_size` The value of used\_global\_handles\_size is the + * used memory size of V8 global handles. + * + * `external_memory` The value of external\_memory is the memory size of array + * buffers and external strings. + * * ```js * { * total_heap_size: 7326976, @@ -80,7 +92,10 @@ declare module 'v8' { * peak_malloced_memory: 1127496, * does_zap_garbage: 0, * number_of_native_contexts: 1, - * number_of_detached_contexts: 0 + * number_of_detached_contexts: 0, + * total_global_handles_size: 8192, + * used_global_handles_size: 3296, + * external_memory: 318824 * } * ``` * @since v1.0.0 @@ -149,7 +164,7 @@ declare module 'v8' { * * ```js * // Print GC events to stdout for one minute. - * const v8 = require('v8'); + * const v8 = require('node:v8'); * v8.setFlagsFromString('--trace_gc'); * setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3); * ``` @@ -172,12 +187,12 @@ declare module 'v8' { * * ```js * // Print heap snapshot to the console - * const v8 = require('v8'); + * const v8 = require('node:v8'); * const stream = v8.getHeapSnapshot(); * stream.pipe(process.stdout); * ``` * @since v11.13.0 - * @return A Readable Stream containing the V8 heap snapshot + * @return A Readable containing the V8 heap snapshot. */ function getHeapSnapshot(): Readable; /** @@ -197,12 +212,12 @@ declare module 'v8' { * for a duration depending on the heap size. * * ```js - * const { writeHeapSnapshot } = require('v8'); + * const { writeHeapSnapshot } = require('node:v8'); * const { * Worker, * isMainThread, - * parentPort - * } = require('worker_threads'); + * parentPort, + * } = require('node:worker_threads'); * * if (isMainThread) { * const worker = new Worker(__filename); @@ -233,13 +248,16 @@ declare module 'v8' { */ function writeHeapSnapshot(filename?: string): string; /** - * Returns an object with the following properties: + * Get statistics about code and its metadata in the heap, see + * V8[`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the + * following properties: * * ```js * { * code_and_metadata_size: 212208, * bytecode_and_metadata_size: 161368, - * external_script_source_size: 1410794 + * external_script_source_size: 1410794, + * cpu_profiler_metadata_size: 0, * } * ``` * @since v12.8.0 @@ -289,7 +307,7 @@ declare module 'v8' { */ writeDouble(value: number): void; /** - * Write raw bytes into the serializer’s internal buffer. The deserializer + * Write raw bytes into the serializer's internal buffer. The deserializer * will require a way to compute the length of the buffer. * For use inside of a custom `serializer._writeHostObject()`. */ @@ -345,7 +363,7 @@ declare module 'v8' { */ readDouble(): number; /** - * Read raw bytes from the deserializer’s internal buffer. The `length` parameter + * Read raw bytes from the deserializer's internal buffer. The `length` parameter * must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`. * For use inside of a custom `deserializer._readHostObject()`. */ @@ -390,6 +408,227 @@ declare module 'v8' { * @since v15.1.0, v14.18.0, v12.22.0 */ function stopCoverage(): void; + /** + * This API collects GC data in current thread. + * @since v19.6.0, v18.15.0 + */ + class GCProfiler { + /** + * Start collecting GC data. + * @since v19.6.0, v18.15.0 + */ + start(): void; + /** + * Stop collecting GC data and return an object.The content of object + * is as follows. + * + * ```json + * { + * "version": 1, + * "startTime": 1674059033862, + * "statistics": [ + * { + * "gcType": "Scavenge", + * "beforeGC": { + * "heapStatistics": { + * "totalHeapSize": 5005312, + * "totalHeapSizeExecutable": 524288, + * "totalPhysicalSize": 5226496, + * "totalAvailableSize": 4341325216, + * "totalGlobalHandlesSize": 8192, + * "usedGlobalHandlesSize": 2112, + * "usedHeapSize": 4883840, + * "heapSizeLimit": 4345298944, + * "mallocedMemory": 254128, + * "externalMemory": 225138, + * "peakMallocedMemory": 181760 + * }, + * "heapSpaceStatistics": [ + * { + * "spaceName": "read_only_space", + * "spaceSize": 0, + * "spaceUsedSize": 0, + * "spaceAvailableSize": 0, + * "physicalSpaceSize": 0 + * } + * ] + * }, + * "cost": 1574.14, + * "afterGC": { + * "heapStatistics": { + * "totalHeapSize": 6053888, + * "totalHeapSizeExecutable": 524288, + * "totalPhysicalSize": 5500928, + * "totalAvailableSize": 4341101384, + * "totalGlobalHandlesSize": 8192, + * "usedGlobalHandlesSize": 2112, + * "usedHeapSize": 4059096, + * "heapSizeLimit": 4345298944, + * "mallocedMemory": 254128, + * "externalMemory": 225138, + * "peakMallocedMemory": 181760 + * }, + * "heapSpaceStatistics": [ + * { + * "spaceName": "read_only_space", + * "spaceSize": 0, + * "spaceUsedSize": 0, + * "spaceAvailableSize": 0, + * "physicalSpaceSize": 0 + * } + * ] + * } + * } + * ], + * "endTime": 1674059036865 + * } + * ``` + * + * Here's an example. + * + * ```js + * const { GCProfiler } = require('v8'); + * const profiler = new GCProfiler(); + * profiler.start(); + * setTimeout(() => { + * console.log(profiler.stop()); + * }, 1000); + * ``` + * @since v19.6.0, v18.15.0 + */ + stop(): GCProfilerResult; + } + interface GCProfilerResult { + version: number; + startTime: number; + endTime: number; + statistics: Array<{ + gcType: string; + cost: number; + beforeGC: { + heapStatistics: HeapStatistics; + heapSpaceStatistics: HeapSpaceStatistics[]; + }; + afterGC: { + heapStatistics: HeapStatistics; + heapSpaceStatistics: HeapSpaceStatistics[]; + }; + }>; + } + interface HeapStatistics { + totalHeapSize: number; + totalHeapSizeExecutable: number; + totalPhysicalSize: number; + totalAvailableSize: number; + totalGlobalHandlesSize: number; + usedGlobalHandlesSize: number; + usedHeapSize: number; + heapSizeLimit: number; + mallocedMemory: number; + externalMemory: number; + peakMallocedMemory: number; + } + interface HeapSpaceStatistics { + spaceName: string; + spaceSize: number; + spaceUsedSize: number; + spaceAvailableSize: number; + physicalSpaceSize: number; + } + /** + * Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will + * happen if a promise is created without ever getting a continuation. + * @since v17.1.0, v16.14.0 + * @param promise The promise being created. + * @param parent The promise continued from, if applicable. + */ + interface Init { + (promise: Promise, parent: Promise): void; + } + /** + * Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming. + * + * The before callback will be called 0 to N times. The before callback will typically be called 0 times if no continuation was ever made for the promise. + * The before callback may be called many times in the case where many continuations have been made from the same promise. + * @since v17.1.0, v16.14.0 + */ + interface Before { + (promise: Promise): void; + } + /** + * Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await. + * @since v17.1.0, v16.14.0 + */ + interface After { + (promise: Promise): void; + } + /** + * Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or + * {@link Promise.reject()}. + * @since v17.1.0, v16.14.0 + */ + interface Settled { + (promise: Promise): void; + } + /** + * Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or + * around an await, and when the promise resolves or rejects. + * + * Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and + * `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop. + * @since v17.1.0, v16.14.0 + */ + interface HookCallbacks { + init?: Init; + before?: Before; + after?: After; + settled?: Settled; + } + interface PromiseHooks { + /** + * The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param init The {@link Init | `init` callback} to call when a promise is created. + * @return Call to stop the hook. + */ + onInit: (init: Init) => Function; + /** + * The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param settled The {@link Settled | `settled` callback} to call when a promise is created. + * @return Call to stop the hook. + */ + onSettled: (settled: Settled) => Function; + /** + * The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param before The {@link Before | `before` callback} to call before a promise continuation executes. + * @return Call to stop the hook. + */ + onBefore: (before: Before) => Function; + /** + * The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param after The {@link After | `after` callback} to call after a promise continuation executes. + * @return Call to stop the hook. + */ + onAfter: (after: After) => Function; + /** + * Registers functions to be called for different lifetime events of each promise. + * The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime. + * All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed. + * The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param callbacks The {@link HookCallbacks | Hook Callbacks} to register + * @return Used for disabling hooks + */ + createHook: (callbacks: HookCallbacks) => Function; + } + /** + * The `promiseHooks` interface can be used to track promise lifecycle events. + * @since v17.1.0, v16.14.0 + */ + const promiseHooks: PromiseHooks; } declare module 'node:v8' { export * from 'v8'; diff --git a/node_modules/@types/node/vm.d.ts b/node_modules/@types/node/vm.d.ts index c96513a50..e293a50e4 100755 --- a/node_modules/@types/node/vm.d.ts +++ b/node_modules/@types/node/vm.d.ts @@ -1,8 +1,8 @@ /** - * The `vm` module enables compiling and running code within V8 Virtual + * The `node:vm` module enables compiling and running code within V8 Virtual * Machine contexts. * - * **The `vm` module is not a security** + * **The `node:vm` module is not a security** * **mechanism. Do not use it to run untrusted code.** * * JavaScript code can be compiled and run immediately or @@ -17,7 +17,7 @@ * code are reflected in the context object. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * const x = 1; * @@ -34,7 +34,7 @@ * * console.log(x); // 1; y is not defined. * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/vm.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/vm.js) */ declare module 'vm' { interface Context extends NodeJS.Dict {} @@ -56,11 +56,17 @@ declare module 'vm' { columnOffset?: number | undefined; } interface ScriptOptions extends BaseOptions { - displayErrors?: boolean | undefined; - timeout?: number | undefined; - cachedData?: Buffer | undefined; + /** + * V8's code cache data for the supplied source. + */ + cachedData?: Buffer | NodeJS.ArrayBufferView | undefined; /** @deprecated in favor of `script.createCachedData()` */ produceCachedData?: boolean | undefined; + /** + * Called during evaluation of this module when `import()` is called. + * If this option is not specified, calls to `import()` will reject with `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`. + */ + importModuleDynamically?: ((specifier: string, script: Script, importAssertions: Object) => Module) | undefined; } interface RunningScriptOptions extends BaseOptions { /** @@ -80,10 +86,31 @@ declare module 'vm' { * Default: `false`. */ breakOnSigint?: boolean | undefined; + } + interface RunningScriptInNewContextOptions extends RunningScriptOptions { + /** + * Human-readable name of the newly created context. + */ + contextName?: CreateContextOptions['name']; + /** + * Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL, + * but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object. + * Most notably, this string should omit the trailing slash, as that denotes a path. + */ + contextOrigin?: CreateContextOptions['origin']; + contextCodeGeneration?: CreateContextOptions['codeGeneration']; /** * If set to `afterEvaluate`, microtasks will be run immediately after the script has run. */ - microtaskMode?: 'afterEvaluate' | undefined; + microtaskMode?: CreateContextOptions['microtaskMode']; + } + interface RunningCodeOptions extends RunningScriptOptions { + cachedData?: ScriptOptions['cachedData']; + importModuleDynamically?: ScriptOptions['importModuleDynamically']; + } + interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions { + cachedData?: ScriptOptions['cachedData']; + importModuleDynamically?: ScriptOptions['importModuleDynamically']; } interface CompileFunctionOptions extends BaseOptions { /** @@ -144,7 +171,10 @@ declare module 'vm' { * @default 'summary' */ mode?: MeasureMemoryMode | undefined; - context?: Context | undefined; + /** + * @default 'default' + */ + execution?: 'default' | 'eager' | undefined; } interface MemoryMeasurement { total: { @@ -158,7 +188,7 @@ declare module 'vm' { * @since v0.3.1 */ class Script { - constructor(code: string, options?: ScriptOptions); + constructor(code: string, options?: ScriptOptions | string); /** * Runs the compiled code contained by the `vm.Script` object within the given`contextifiedObject` and returns the result. Running code does not have access * to local scope. @@ -168,11 +198,11 @@ declare module 'vm' { * The globals are contained in the `context` object. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * const context = { * animal: 'cat', - * count: 2 + * count: 2, * }; * * const script = new vm.Script('count += 1; name = "kitty";'); @@ -204,7 +234,7 @@ declare module 'vm' { * contained within each individual `context`. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * const script = new vm.Script('globalVar = "set"'); * @@ -220,7 +250,7 @@ declare module 'vm' { * @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created. * @return the result of the very last statement executed in the script. */ - runInNewContext(contextObject?: Context, options?: RunningScriptOptions): any; + runInNewContext(contextObject?: Context, options?: RunningScriptInNewContextOptions): any; /** * Runs the compiled code contained by the `vm.Script` within the context of the * current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object. @@ -229,7 +259,7 @@ declare module 'vm' { * executes that code multiple times: * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * global.globalVar = 0; * @@ -251,6 +281,16 @@ declare module 'vm' { * Creates a code cache that can be used with the `Script` constructor's`cachedData` option. Returns a `Buffer`. This method may be called at any * time and any number of times. * + * The code cache of the `Script` doesn't contain any JavaScript observable + * states. The code cache is safe to be saved along side the script source and + * used to construct new `Script` instances multiple times. + * + * Functions in the `Script` source can be marked as lazily compiled and they are + * not compiled at construction of the `Script`. These functions are going to be + * compiled when they are invoked the first time. The code cache serializes the + * metadata that V8 currently knows about the `Script` that it can use to speed up + * future compilations. + * * ```js * const script = new vm.Script(` * function add(a, b) { @@ -260,19 +300,46 @@ declare module 'vm' { * const x = add(1, 2); * `); * - * const cacheWithoutX = script.createCachedData(); + * const cacheWithoutAdd = script.createCachedData(); + * // In `cacheWithoutAdd` the function `add()` is marked for full compilation + * // upon invocation. * * script.runInThisContext(); * - * const cacheWithX = script.createCachedData(); + * const cacheWithAdd = script.createCachedData(); + * // `cacheWithAdd` contains fully compiled function `add()`. * ``` * @since v10.6.0 */ createCachedData(): Buffer; /** @deprecated in favor of `script.createCachedData()` */ cachedDataProduced?: boolean | undefined; + /** + * When `cachedData` is supplied to create the `vm.Script`, this value will be set + * to either `true` or `false` depending on acceptance of the data by V8\. + * Otherwise the value is `undefined`. + * @since v5.7.0 + */ cachedDataRejected?: boolean | undefined; cachedData?: Buffer | undefined; + /** + * When the script is compiled from a source that contains a source map magic + * comment, this property will be set to the URL of the source map. + * + * ```js + * import vm from 'node:vm'; + * + * const script = new vm.Script(` + * function myFunc() {} + * //# sourceMappingURL=sourcemap.json + * `); + * + * console.log(script.sourceMapURL); + * // Prints: sourcemap.json + * ``` + * @since v19.1.0, v18.13.0 + */ + sourceMapURL?: string | undefined; } /** * If given a `contextObject`, the `vm.createContext()` method will `prepare @@ -282,7 +349,7 @@ declare module 'vm' { * will remain unchanged. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * global.globalVar = 3; * @@ -329,7 +396,7 @@ declare module 'vm' { * The following example compiles and executes different scripts using a single `contextified` object: * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * const contextObject = { globalVar: 1 }; * vm.createContext(contextObject); @@ -345,7 +412,7 @@ declare module 'vm' { * @param contextifiedObject The `contextified` object that will be used as the `global` when the `code` is compiled and run. * @return the result of the very last statement executed in the script. */ - function runInContext(code: string, contextifiedObject: Context, options?: RunningScriptOptions | string): any; + function runInContext(code: string, contextifiedObject: Context, options?: RunningCodeOptions | string): any; /** * The `vm.runInNewContext()` first contextifies the given `contextObject` (or * creates a new `contextObject` if passed as `undefined`), compiles the `code`, @@ -358,11 +425,11 @@ declare module 'vm' { * variable and sets a new one. These globals are contained in the `contextObject`. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * * const contextObject = { * animal: 'cat', - * count: 2 + * count: 2, * }; * * vm.runInNewContext('count += 1; name = "kitty"', contextObject); @@ -374,7 +441,7 @@ declare module 'vm' { * @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created. * @return the result of the very last statement executed in the script. */ - function runInNewContext(code: string, contextObject?: Context, options?: RunningScriptOptions | string): any; + function runInNewContext(code: string, contextObject?: Context, options?: RunningCodeInNewContextOptions | string): any; /** * `vm.runInThisContext()` compiles `code`, runs it within the context of the * current `global` and returns the result. Running code does not have access to @@ -386,7 +453,7 @@ declare module 'vm' { * the JavaScript [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) function to run the same code: * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * let localVar = 'initial value'; * * const vmResult = vm.runInThisContext('localVar = "vm";'); @@ -407,17 +474,17 @@ declare module 'vm' { * When using either `script.runInThisContext()` or {@link runInThisContext}, the code is executed within the current V8 global * context. The code passed to this VM context will have its own isolated scope. * - * In order to run a simple web server using the `http` module the code passed to - * the context must either call `require('http')` on its own, or have a reference - * to the `http` module passed to it. For instance: + * In order to run a simple web server using the `node:http` module the code passed + * to the context must either call `require('node:http')` on its own, or have a + * reference to the `node:http` module passed to it. For instance: * * ```js * 'use strict'; - * const vm = require('vm'); + * const vm = require('node:vm'); * * const code = ` * ((require) => { - * const http = require('http'); + * const http = require('node:http'); * * http.createServer((request, response) => { * response.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -437,7 +504,7 @@ declare module 'vm' { * @param code The JavaScript code to compile and run. * @return the result of the very last statement executed in the script. */ - function runInThisContext(code: string, options?: RunningScriptOptions | string): any; + function runInThisContext(code: string, options?: RunningCodeOptions | string): any; /** * Compiles the given code into the provided context (if no context is * supplied, the current context is used), and returns it wrapped inside a @@ -446,7 +513,15 @@ declare module 'vm' { * @param code The body of the function to compile. * @param params An array of strings containing all parameters for the function. */ - function compileFunction(code: string, params?: ReadonlyArray, options?: CompileFunctionOptions): Function; + function compileFunction( + code: string, + params?: ReadonlyArray, + options?: CompileFunctionOptions + ): Function & { + cachedData?: Script['cachedData'] | undefined; + cachedDataProduced?: Script['cachedDataProduced'] | undefined; + cachedDataRejected?: Script['cachedDataRejected'] | undefined; + }; /** * Measure the memory known to V8 and used by all contexts known to the * current V8 isolate, or the main context. @@ -460,7 +535,7 @@ declare module 'vm' { * the memory occupied by each heap space in the current V8 instance. * * ```js - * const vm = require('vm'); + * const vm = require('node:vm'); * // Measure the memory used by the main context. * vm.measureMemory({ mode: 'summary' }) * // This is the same as vm.measureMemory() @@ -503,6 +578,316 @@ declare module 'vm' { * @experimental */ function measureMemory(options?: MeasureMemoryOptions): Promise; + interface ModuleEvaluateOptions { + timeout?: RunningScriptOptions['timeout'] | undefined; + breakOnSigint?: RunningScriptOptions['breakOnSigint'] | undefined; + } + type ModuleLinker = ( + specifier: string, + referencingModule: Module, + extra: { + assert: Object; + } + ) => Module | Promise; + type ModuleStatus = 'unlinked' | 'linking' | 'linked' | 'evaluating' | 'evaluated' | 'errored'; + /** + * This feature is only available with the `--experimental-vm-modules` command + * flag enabled. + * + * The `vm.Module` class provides a low-level interface for using + * ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`class that closely mirrors [Module Record](https://www.ecma-international.org/ecma-262/#sec-abstract-module-records) + * s as defined in the ECMAScript + * specification. + * + * Unlike `vm.Script` however, every `vm.Module` object is bound to a context from + * its creation. Operations on `vm.Module` objects are intrinsically asynchronous, + * in contrast with the synchronous nature of `vm.Script` objects. The use of + * 'async' functions can help with manipulating `vm.Module` objects. + * + * Using a `vm.Module` object requires three distinct steps: creation/parsing, + * linking, and evaluation. These three steps are illustrated in the following + * example. + * + * This implementation lies at a lower level than the `ECMAScript Module + * loader`. There is also no way to interact with the Loader yet, though + * support is planned. + * + * ```js + * import vm from 'node:vm'; + * + * const contextifiedObject = vm.createContext({ + * secret: 42, + * print: console.log, + * }); + * + * // Step 1 + * // + * // Create a Module by constructing a new `vm.SourceTextModule` object. This + * // parses the provided source text, throwing a `SyntaxError` if anything goes + * // wrong. By default, a Module is created in the top context. But here, we + * // specify `contextifiedObject` as the context this Module belongs to. + * // + * // Here, we attempt to obtain the default export from the module "foo", and + * // put it into local binding "secret". + * + * const bar = new vm.SourceTextModule(` + * import s from 'foo'; + * s; + * print(s); + * `, { context: contextifiedObject }); + * + * // Step 2 + * // + * // "Link" the imported dependencies of this Module to it. + * // + * // The provided linking callback (the "linker") accepts two arguments: the + * // parent module (`bar` in this case) and the string that is the specifier of + * // the imported module. The callback is expected to return a Module that + * // corresponds to the provided specifier, with certain requirements documented + * // in `module.link()`. + * // + * // If linking has not started for the returned Module, the same linker + * // callback will be called on the returned Module. + * // + * // Even top-level Modules without dependencies must be explicitly linked. The + * // callback provided would never be called, however. + * // + * // The link() method returns a Promise that will be resolved when all the + * // Promises returned by the linker resolve. + * // + * // Note: This is a contrived example in that the linker function creates a new + * // "foo" module every time it is called. In a full-fledged module system, a + * // cache would probably be used to avoid duplicated modules. + * + * async function linker(specifier, referencingModule) { + * if (specifier === 'foo') { + * return new vm.SourceTextModule(` + * // The "secret" variable refers to the global variable we added to + * // "contextifiedObject" when creating the context. + * export default secret; + * `, { context: referencingModule.context }); + * + * // Using `contextifiedObject` instead of `referencingModule.context` + * // here would work as well. + * } + * throw new Error(`Unable to resolve dependency: ${specifier}`); + * } + * await bar.link(linker); + * + * // Step 3 + * // + * // Evaluate the Module. The evaluate() method returns a promise which will + * // resolve after the module has finished evaluating. + * + * // Prints 42. + * await bar.evaluate(); + * ``` + * @since v13.0.0, v12.16.0 + * @experimental + */ + class Module { + /** + * The specifiers of all dependencies of this module. The returned array is frozen + * to disallow any changes to it. + * + * Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in + * the ECMAScript specification. + */ + dependencySpecifiers: readonly string[]; + /** + * If the `module.status` is `'errored'`, this property contains the exception + * thrown by the module during evaluation. If the status is anything else, + * accessing this property will result in a thrown exception. + * + * The value `undefined` cannot be used for cases where there is not a thrown + * exception due to possible ambiguity with `throw undefined;`. + * + * Corresponds to the `[[EvaluationError]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s + * in the ECMAScript specification. + */ + error: any; + /** + * The identifier of the current module, as set in the constructor. + */ + identifier: string; + context: Context; + /** + * The namespace object of the module. This is only available after linking + * (`module.link()`) has completed. + * + * Corresponds to the [GetModuleNamespace](https://tc39.es/ecma262/#sec-getmodulenamespace) abstract operation in the ECMAScript + * specification. + */ + namespace: Object; + /** + * The current status of the module. Will be one of: + * + * * `'unlinked'`: `module.link()` has not yet been called. + * * `'linking'`: `module.link()` has been called, but not all Promises returned + * by the linker function have been resolved yet. + * * `'linked'`: The module has been linked successfully, and all of its + * dependencies are linked, but `module.evaluate()` has not yet been called. + * * `'evaluating'`: The module is being evaluated through a `module.evaluate()` on + * itself or a parent module. + * * `'evaluated'`: The module has been successfully evaluated. + * * `'errored'`: The module has been evaluated, but an exception was thrown. + * + * Other than `'errored'`, this status string corresponds to the specification's [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records)'s `[[Status]]` field. `'errored'` + * corresponds to`'evaluated'` in the specification, but with `[[EvaluationError]]` set to a + * value that is not `undefined`. + */ + status: ModuleStatus; + /** + * Evaluate the module. + * + * This must be called after the module has been linked; otherwise it will reject. + * It could be called also when the module has already been evaluated, in which + * case it will either do nothing if the initial evaluation ended in success + * (`module.status` is `'evaluated'`) or it will re-throw the exception that the + * initial evaluation resulted in (`module.status` is `'errored'`). + * + * This method cannot be called while the module is being evaluated + * (`module.status` is `'evaluating'`). + * + * Corresponds to the [Evaluate() concrete method](https://tc39.es/ecma262/#sec-moduleevaluation) field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in the + * ECMAScript specification. + * @return Fulfills with `undefined` upon success. + */ + evaluate(options?: ModuleEvaluateOptions): Promise; + /** + * Link module dependencies. This method must be called before evaluation, and + * can only be called once per module. + * + * The function is expected to return a `Module` object or a `Promise` that + * eventually resolves to a `Module` object. The returned `Module` must satisfy the + * following two invariants: + * + * * It must belong to the same context as the parent `Module`. + * * Its `status` must not be `'errored'`. + * + * If the returned `Module`'s `status` is `'unlinked'`, this method will be + * recursively called on the returned `Module` with the same provided `linker`function. + * + * `link()` returns a `Promise` that will either get resolved when all linking + * instances resolve to a valid `Module`, or rejected if the linker function either + * throws an exception or returns an invalid `Module`. + * + * The linker function roughly corresponds to the implementation-defined [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) abstract operation in the + * ECMAScript + * specification, with a few key differences: + * + * * The linker function is allowed to be asynchronous while [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) is synchronous. + * + * The actual [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) implementation used during module + * linking is one that returns the modules linked during linking. Since at + * that point all modules would have been fully linked already, the [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) implementation is fully synchronous per + * specification. + * + * Corresponds to the [Link() concrete method](https://tc39.es/ecma262/#sec-moduledeclarationlinking) field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in + * the ECMAScript specification. + */ + link(linker: ModuleLinker): Promise; + } + interface SourceTextModuleOptions { + /** + * String used in stack traces. + * @default 'vm:module(i)' where i is a context-specific ascending index. + */ + identifier?: string | undefined; + cachedData?: ScriptOptions['cachedData'] | undefined; + context?: Context | undefined; + lineOffset?: BaseOptions['lineOffset'] | undefined; + columnOffset?: BaseOptions['columnOffset'] | undefined; + /** + * Called during evaluation of this module to initialize the `import.meta`. + */ + initializeImportMeta?: ((meta: ImportMeta, module: SourceTextModule) => void) | undefined; + importModuleDynamically?: ScriptOptions['importModuleDynamically'] | undefined; + } + /** + * This feature is only available with the `--experimental-vm-modules` command + * flag enabled. + * + * + * + * The `vm.SourceTextModule` class provides the [Source Text Module Record](https://tc39.es/ecma262/#sec-source-text-module-records) as + * defined in the ECMAScript specification. + * @since v9.6.0 + * @experimental + */ + class SourceTextModule extends Module { + /** + * Creates a new `SourceTextModule` instance. + * @param code JavaScript Module code to parse + */ + constructor(code: string, options?: SourceTextModuleOptions); + } + interface SyntheticModuleOptions { + /** + * String used in stack traces. + * @default 'vm:module(i)' where i is a context-specific ascending index. + */ + identifier?: string | undefined; + /** + * The contextified object as returned by the `vm.createContext()` method, to compile and evaluate this module in. + */ + context?: Context | undefined; + } + /** + * This feature is only available with the `--experimental-vm-modules` command + * flag enabled. + * + * + * + * The `vm.SyntheticModule` class provides the [Synthetic Module Record](https://heycam.github.io/webidl/#synthetic-module-records) as + * defined in the WebIDL specification. The purpose of synthetic modules is to + * provide a generic interface for exposing non-JavaScript sources to ECMAScript + * module graphs. + * + * ```js + * const vm = require('node:vm'); + * + * const source = '{ "a": 1 }'; + * const module = new vm.SyntheticModule(['default'], function() { + * const obj = JSON.parse(source); + * this.setExport('default', obj); + * }); + * + * // Use `module` in linking... + * ``` + * @since v13.0.0, v12.16.0 + * @experimental + */ + class SyntheticModule extends Module { + /** + * Creates a new `SyntheticModule` instance. + * @param exportNames Array of names that will be exported from the module. + * @param evaluateCallback Called when the module is evaluated. + */ + constructor(exportNames: string[], evaluateCallback: (this: SyntheticModule) => void, options?: SyntheticModuleOptions); + /** + * This method is used after the module is linked to set the values of exports. If + * it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error + * will be thrown. + * + * ```js + * import vm from 'node:vm'; + * + * const m = new vm.SyntheticModule(['x'], () => { + * m.setExport('x', 1); + * }); + * + * await m.link(() => {}); + * await m.evaluate(); + * + * assert.strictEqual(m.namespace.x, 1); + * ``` + * @since v13.0.0, v12.16.0 + * @param name Name of the export to set. + * @param value The value to set the export to. + */ + setExport(name: string, value: any): void; + } } declare module 'node:vm' { export * from 'vm'; diff --git a/node_modules/@types/node/wasi.d.ts b/node_modules/@types/node/wasi.d.ts index d20b66bf4..9262e98bd 100755 --- a/node_modules/@types/node/wasi.d.ts +++ b/node_modules/@types/node/wasi.d.ts @@ -3,26 +3,23 @@ * underlying operating system via a collection of POSIX-like functions. * * ```js - * import { readFile } from 'fs/promises'; + * import { readFile } from 'node:fs/promises'; * import { WASI } from 'wasi'; - * import { argv, env } from 'process'; + * import { argv, env } from 'node:process'; * * const wasi = new WASI({ + * version: 'preview1', * args: argv, * env, * preopens: { - * '/sandbox': '/some/real/path/that/wasm/can/access' - * } + * '/sandbox': '/some/real/path/that/wasm/can/access', + * }, * }); * - * // Some WASI binaries require: - * // const importObject = { wasi_unstable: wasi.wasiImport }; - * const importObject = { wasi_snapshot_preview1: wasi.wasiImport }; - * * const wasm = await WebAssembly.compile( - * await readFile(new URL('./demo.wasm', import.meta.url)) + * await readFile(new URL('./demo.wasm', import.meta.url)), * ); - * const instance = await WebAssembly.instantiate(wasm, importObject); + * const instance = await WebAssembly.instantiate(wasm, wasi.getImportObject()); * * wasi.start(instance); * ``` @@ -64,11 +61,8 @@ * ```console * $ wat2wasm demo.wat * ``` - * - * The `--experimental-wasi-unstable-preview1` CLI argument is needed for this - * example to run. * @experimental - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/wasi.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/wasi.js) */ declare module 'wasi' { interface WASIOptions { @@ -91,11 +85,11 @@ declare module 'wasi' { */ preopens?: NodeJS.Dict | undefined; /** - * By default, WASI applications terminate the Node.js - * process via the `__wasi_proc_exit()` function. Setting this option to `true` - * causes `wasi.start()` to return the exit code rather than terminate the - * process. - * @default false + * By default, when WASI applications call `__wasi_proc_exit()` + * `wasi.start()` will return with the exit code specified rather than terminatng the process. + * Setting this option to `false` will cause the Node.js process to exit with + * the specified exit code instead. + * @default true */ returnOnExit?: boolean | undefined; /** diff --git a/node_modules/@types/node/worker_threads.d.ts b/node_modules/@types/node/worker_threads.d.ts index 81b71c283..e11932e42 100755 --- a/node_modules/@types/node/worker_threads.d.ts +++ b/node_modules/@types/node/worker_threads.d.ts @@ -1,9 +1,9 @@ /** - * The `worker_threads` module enables the use of threads that execute JavaScript - * in parallel. To access it: + * The `node:worker_threads` module enables the use of threads that execute + * JavaScript in parallel. To access it: * * ```js - * const worker = require('worker_threads'); + * const worker = require('node:worker_threads'); * ``` * * Workers (threads) are useful for performing CPU-intensive JavaScript operations. @@ -15,14 +15,14 @@ * * ```js * const { - * Worker, isMainThread, parentPort, workerData - * } = require('worker_threads'); + * Worker, isMainThread, parentPort, workerData, + * } = require('node:worker_threads'); * * if (isMainThread) { * module.exports = function parseJSAsync(script) { * return new Promise((resolve, reject) => { * const worker = new Worker(__filename, { - * workerData: script + * workerData: script, * }); * worker.on('message', resolve); * worker.on('error', reject); @@ -49,7 +49,7 @@ * * Worker threads inherit non-process-specific options by default. Refer to `Worker constructor options` to know how to customize worker thread options, * specifically `argv` and `execArgv` options. - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/worker_threads.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/worker_threads.js) */ declare module 'worker_threads' { import { Blob } from 'node:buffer'; @@ -72,7 +72,7 @@ declare module 'worker_threads' { * The `MessageChannel` has no methods of its own. `new MessageChannel()`yields an object with `port1` and `port2` properties, which refer to linked `MessagePort` instances. * * ```js - * const { MessageChannel } = require('worker_threads'); + * const { MessageChannel } = require('node:worker_threads'); * * const { port1, port2 } = new MessageChannel(); * port1.on('message', (message) => console.log('received', message)); @@ -121,7 +121,7 @@ declare module 'worker_threads' { * * `value` may not contain native (C++-backed) objects other than: * * ```js - * const { MessageChannel } = require('worker_threads'); + * const { MessageChannel } = require('node:worker_threads'); * const { port1, port2 } = new MessageChannel(); * * port1.on('message', (message) => console.log(message)); @@ -132,7 +132,7 @@ declare module 'worker_threads' { * port2.postMessage(circularData); * ``` * - * `transferList` may be a list of [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), `MessagePort` and `FileHandle` objects. + * `transferList` may be a list of [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), `MessagePort`, and `FileHandle` objects. * After transferring, they are not usable on the sending side of the channel * anymore (even if they are not contained in `value`). Unlike with `child processes`, transferring handles such as network sockets is currently * not supported. @@ -143,7 +143,7 @@ declare module 'worker_threads' { * `value` may still contain `ArrayBuffer` instances that are not in`transferList`; in that case, the underlying memory is copied rather than moved. * * ```js - * const { MessageChannel } = require('worker_threads'); + * const { MessageChannel } = require('node:worker_threads'); * const { port1, port2 } = new MessageChannel(); * * port1.on('message', (message) => console.log(message)); @@ -170,7 +170,7 @@ declare module 'worker_threads' { * posting without having side effects. * * For more information on the serialization and deserialization mechanisms - * behind this API, see the `serialization API of the v8 module`. + * behind this API, see the `serialization API of the node:v8 module`. * @since v10.5.0 */ postMessage(value: any, transferList?: ReadonlyArray): void; @@ -262,6 +262,12 @@ declare module 'worker_threads' { * @default true */ trackUnmanagedFds?: boolean | undefined; + /** + * An optional `name` to be appended to the worker title + * for debuggin/identification purposes, making the final title as + * `[worker ${id}] ${name}`. + */ + name?: string | undefined; } interface ResourceLimits { /** @@ -288,9 +294,9 @@ declare module 'worker_threads' { * * Notable differences inside a Worker environment are: * - * * The `process.stdin`, `process.stdout` and `process.stderr` may be redirected by the parent thread. - * * The `require('worker_threads').isMainThread` property is set to `false`. - * * The `require('worker_threads').parentPort` message port is available. + * * The `process.stdin`, `process.stdout`, and `process.stderr` streams may be redirected by the parent thread. + * * The `require('node:worker_threads').isMainThread` property is set to `false`. + * * The `require('node:worker_threads').parentPort` message port is available. * * `process.exit()` does not stop the whole program, just the single thread, * and `process.abort()` is not available. * * `process.chdir()` and `process` methods that set group or user ids @@ -307,11 +313,11 @@ declare module 'worker_threads' { * * Creating `Worker` instances inside of other `Worker`s is possible. * - * Like [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the `cluster module`, two-way communication can be - * achieved through inter-thread message passing. Internally, a `Worker` has a - * built-in pair of `MessagePort` s that are already associated with each other - * when the `Worker` is created. While the `MessagePort` object on the parent side - * is not directly exposed, its functionalities are exposed through `worker.postMessage()` and the `worker.on('message')` event + * Like [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the `node:cluster module`, two-way communication + * can be achieved through inter-thread message passing. Internally, a `Worker` has + * a built-in pair of `MessagePort` s that are already associated with each + * other when the `Worker` is created. While the `MessagePort` object on the parent + * side is not directly exposed, its functionalities are exposed through `worker.postMessage()` and the `worker.on('message')` event * on the `Worker` object for the parent thread. * * To create custom messaging channels (which is encouraged over using the default @@ -324,10 +330,10 @@ declare module 'worker_threads' { * the thread barrier. * * ```js - * const assert = require('assert'); + * const assert = require('node:assert'); * const { - * Worker, MessageChannel, MessagePort, isMainThread, parentPort - * } = require('worker_threads'); + * Worker, MessageChannel, MessagePort, isMainThread, parentPort, + * } = require('node:worker_threads'); * if (isMainThread) { * const worker = new Worker(__filename); * const subChannel = new MessageChannel(); @@ -367,7 +373,7 @@ declare module 'worker_threads' { readonly stderr: Readable; /** * An integer identifier for the referenced thread. Inside the worker thread, - * it is available as `require('worker_threads').threadId`. + * it is available as `require('node:worker_threads').threadId`. * This value is unique for each `Worker` instance inside a single process. * @since v10.5.0 */ @@ -394,7 +400,7 @@ declare module 'worker_threads' { */ constructor(filename: string | URL, options?: WorkerOptions); /** - * Send a message to the worker that is received via `require('worker_threads').parentPort.on('message')`. + * Send a message to the worker that is received via `require('node:worker_threads').parentPort.on('message')`. * See `port.postMessage()` for more details. * @since v10.5.0 */ @@ -488,8 +494,8 @@ declare module 'worker_threads' { * const { * isMainThread, * BroadcastChannel, - * Worker - * } = require('worker_threads'); + * Worker, + * } = require('node:worker_threads'); * * const bc = new BroadcastChannel('hello'); * @@ -543,7 +549,7 @@ declare module 'worker_threads' { * This operation cannot be undone. * * ```js - * const { MessageChannel, markAsUntransferable } = require('worker_threads'); + * const { MessageChannel, markAsUntransferable } = require('node:worker_threads'); * * const pooledBuffer = new ArrayBuffer(8); * const typedArray1 = new Uint8Array(pooledBuffer); @@ -585,10 +591,10 @@ declare module 'worker_threads' { function moveMessagePortToContext(port: MessagePort, contextifiedSandbox: Context): MessagePort; /** * Receive a single message from a given `MessagePort`. If no message is available,`undefined` is returned, otherwise an object with a single `message` property - * that contains the message payload, corresponding to the oldest message in the`MessagePort`’s queue. + * that contains the message payload, corresponding to the oldest message in the`MessagePort`'s queue. * * ```js - * const { MessageChannel, receiveMessageOnPort } = require('worker_threads'); + * const { MessageChannel, receiveMessageOnPort } = require('node:worker_threads'); * const { port1, port2 } = new MessageChannel(); * port1.postMessage({ hello: 'world' }); * @@ -619,7 +625,7 @@ declare module 'worker_threads' { * isMainThread, * setEnvironmentData, * getEnvironmentData, - * } = require('worker_threads'); + * } = require('node:worker_threads'); * * if (isMainThread) { * setEnvironmentData('Hello', 'World!'); @@ -640,6 +646,47 @@ declare module 'worker_threads' { * for the `key` will be deleted. */ function setEnvironmentData(key: Serializable, value: Serializable): void; + + import { + BroadcastChannel as _BroadcastChannel, + MessageChannel as _MessageChannel, + MessagePort as _MessagePort, + } from 'worker_threads'; + global { + /** + * `BroadcastChannel` class is a global reference for `require('worker_threads').BroadcastChannel` + * https://nodejs.org/api/globals.html#broadcastchannel + * @since v18.0.0 + */ + var BroadcastChannel: typeof globalThis extends { + onmessage: any; + BroadcastChannel: infer T; + } + ? T + : typeof _BroadcastChannel; + /** + * `MessageChannel` class is a global reference for `require('worker_threads').MessageChannel` + * https://nodejs.org/api/globals.html#messagechannel + * @since v15.0.0 + */ + var MessageChannel: typeof globalThis extends { + onmessage: any; + MessageChannel: infer T; + } + ? T + : typeof _MessageChannel; + /** + * `MessagePort` class is a global reference for `require('worker_threads').MessagePort` + * https://nodejs.org/api/globals.html#messageport + * @since v15.0.0 + */ + var MessagePort: typeof globalThis extends { + onmessage: any; + MessagePort: infer T; + } + ? T + : typeof _MessagePort; + } } declare module 'node:worker_threads' { export * from 'worker_threads'; diff --git a/node_modules/@types/node/zlib.d.ts b/node_modules/@types/node/zlib.d.ts index 1d7f0c0e5..9d74cd27f 100755 --- a/node_modules/@types/node/zlib.d.ts +++ b/node_modules/@types/node/zlib.d.ts @@ -1,11 +1,11 @@ /** - * The `zlib` module provides compression functionality implemented using Gzip, - * Deflate/Inflate, and Brotli. + * The `node:zlib` module provides compression functionality implemented using + * Gzip, Deflate/Inflate, and Brotli. * * To access it: * * ```js - * const zlib = require('zlib'); + * const zlib = require('node:zlib'); * ``` * * Compression and decompression are built around the Node.js `Streams API`. @@ -15,12 +15,12 @@ * stream: * * ```js - * const { createGzip } = require('zlib'); - * const { pipeline } = require('stream'); + * const { createGzip } = require('node:zlib'); + * const { pipeline } = require('node:stream'); * const { * createReadStream, - * createWriteStream - * } = require('fs'); + * createWriteStream, + * } = require('node:fs'); * * const gzip = createGzip(); * const source = createReadStream('input.txt'); @@ -35,7 +35,7 @@ * * // Or, Promisified * - * const { promisify } = require('util'); + * const { promisify } = require('node:util'); * const pipe = promisify(pipeline); * * async function do_gzip(input, output) { @@ -55,7 +55,7 @@ * It is also possible to compress or decompress data in a single step: * * ```js - * const { deflate, unzip } = require('zlib'); + * const { deflate, unzip } = require('node:zlib'); * * const input = '.................................'; * deflate(input, (err, buffer) => { @@ -77,7 +77,7 @@ * * // Or, Promisified * - * const { promisify } = require('util'); + * const { promisify } = require('node:util'); * const do_unzip = promisify(unzip); * * do_unzip(buffer) @@ -88,7 +88,7 @@ * }); * ``` * @since v0.5.8 - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/zlib.js) + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/zlib.js) */ declare module 'zlib' { import * as stream from 'node:stream';