@types/node 20.5.0 → 20.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
node/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Sun, 13 Aug 2023 19:32:51 GMT
11
+ * Last updated: Tue, 22 Aug 2023 09:03:14 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
14
 
node/fs.d.ts CHANGED
@@ -3900,6 +3900,31 @@ declare module 'fs' {
3900
3900
  * @return The number of bytes read.
3901
3901
  */
3902
3902
  export function readvSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
3903
+
3904
+ export interface OpenAsBlobOptions {
3905
+ /**
3906
+ * An optional mime type for the blob.
3907
+ *
3908
+ * @default 'undefined'
3909
+ */
3910
+ type?: string | undefined;
3911
+ }
3912
+
3913
+ /**
3914
+ * Returns a Blob whose data is backed by the given file.
3915
+ *
3916
+ * The file must not be modified after the `Blob` is created.
3917
+ * Any modifications will cause reading the `Blob` data to fail with a `DOMException` error.
3918
+ * Synchronous stat operations on the file when the `Blob` is created, and before each read in order to detect whether the file data has been modified on disk.
3919
+ *
3920
+ * @param path
3921
+ * @param [options]
3922
+ *
3923
+ * @experimental
3924
+ * @since v19.8.0
3925
+ */
3926
+ export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise<Blob>;
3927
+
3903
3928
  export interface OpenDirOptions {
3904
3929
  /**
3905
3930
  * @default 'utf8'
node/module.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  */
4
4
  declare module 'module' {
5
5
  import { URL } from 'node:url';
6
+ import { MessagePort } from 'node:worker_threads';
6
7
  namespace Module {
7
8
  /**
8
9
  * The `module.syncBuiltinESMExports()` method updates all the live bindings for
@@ -92,6 +93,101 @@ declare module 'module' {
92
93
  */
93
94
  findEntry(lineOffset: number, columnOffset: number): SourceMapping;
94
95
  }
96
+ type ModuleFormat = 'builtin' | 'commonjs' | 'json' | 'module' | 'wasm';
97
+ type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
98
+ interface GlobalPreloadContext {
99
+ port: MessagePort;
100
+ }
101
+ /**
102
+ * Sometimes it might be necessary to run some code inside of the same global scope that the application runs in.
103
+ * This hook allows the return of a string that is run as a sloppy-mode script on startup.
104
+ *
105
+ * @param context Information to assist the preload code
106
+ * @return Code to run before application startup
107
+ */
108
+ type GlobalPreloadHook = (context: GlobalPreloadContext) => string;
109
+ interface ResolveHookContext {
110
+ /**
111
+ * Export conditions of the relevant `package.json`
112
+ */
113
+ conditions: string[];
114
+ /**
115
+ * An object whose key-value pairs represent the assertions for the module to import
116
+ */
117
+ importAssertions: Object;
118
+ /**
119
+ * The module importing this one, or undefined if this is the Node.js entry point
120
+ */
121
+ parentURL: string | undefined;
122
+ }
123
+ interface ResolveFnOutput {
124
+ /**
125
+ * A hint to the load hook (it might be ignored)
126
+ */
127
+ format?: ModuleFormat | null | undefined;
128
+ /**
129
+ * The import assertions to use when caching the module (optional; if excluded the input will be used)
130
+ */
131
+ importAssertions?: Object | undefined;
132
+ /**
133
+ * A signal that this hook intends to terminate the chain of `resolve` hooks.
134
+ * @default false
135
+ */
136
+ shortCircuit?: boolean | undefined;
137
+ /**
138
+ * The absolute URL to which this input resolves
139
+ */
140
+ url: string;
141
+ }
142
+ /**
143
+ * The `resolve` hook chain is responsible for resolving file URL for a given module specifier and parent URL, and optionally its format (such as `'module'`) as a hint to the `load` hook.
144
+ * If a format is specified, the load hook is ultimately responsible for providing the final `format` value (and it is free to ignore the hint provided by `resolve`);
145
+ * if `resolve` provides a format, a custom `load` hook is required even if only to pass the value to the Node.js default `load` hook.
146
+ *
147
+ * @param specifier The specified URL path of the module to be resolved
148
+ * @param context
149
+ * @param nextResolve The subsequent `resolve` hook in the chain, or the Node.js default `resolve` hook after the last user-supplied resolve hook
150
+ */
151
+ type ResolveHook = (
152
+ specifier: string,
153
+ context: ResolveHookContext,
154
+ nextResolve: (specifier: string, context?: ResolveHookContext) => ResolveFnOutput
155
+ ) => ResolveFnOutput | Promise<ResolveFnOutput>;
156
+ interface LoadHookContext {
157
+ /**
158
+ * Export conditions of the relevant `package.json`
159
+ */
160
+ conditions: string[];
161
+ /**
162
+ * The format optionally supplied by the `resolve` hook chain
163
+ */
164
+ format: ModuleFormat;
165
+ /**
166
+ * An object whose key-value pairs represent the assertions for the module to import
167
+ */
168
+ importAssertions: Object;
169
+ }
170
+ interface LoadFnOutput {
171
+ format: ModuleFormat;
172
+ /**
173
+ * A signal that this hook intends to terminate the chain of `resolve` hooks.
174
+ * @default false
175
+ */
176
+ shortCircuit?: boolean | undefined;
177
+ /**
178
+ * The source for Node.js to evaluate
179
+ */
180
+ source?: ModuleSource;
181
+ }
182
+ /**
183
+ * The `load` hook provides a way to define a custom method of determining how a URL should be interpreted, retrieved, and parsed.
184
+ * It is also in charge of validating the import assertion.
185
+ *
186
+ * @param url The URL/path of the module to be loaded
187
+ * @param context Metadata about the module
188
+ * @param nextLoad The subsequent `load` hook in the chain, or the Node.js default `load` hook after the last user-supplied `load` hook
189
+ */
190
+ type LoadHook = (url: string, context: LoadHookContext, nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput) => LoadFnOutput | Promise<LoadFnOutput>;
95
191
  }
96
192
  interface Module extends NodeModule {}
97
193
  class Module {
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "20.5.0",
3
+ "version": "20.5.2",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -227,6 +227,6 @@
227
227
  },
228
228
  "scripts": {},
229
229
  "dependencies": {},
230
- "typesPublisherContentHash": "83e291a6a60ec56a2b56b6b885ae9a0ea199888a482d63f4a22270483f82f2a9",
230
+ "typesPublisherContentHash": "16c0c38215cd7cb1934b1390c501dfa15927a10c9b2e8a41a35779d5d94f8119",
231
231
  "typeScriptVersion": "4.3"
232
232
  }
node/ts4.8/fs.d.ts CHANGED
@@ -3900,6 +3900,31 @@ declare module 'fs' {
3900
3900
  * @return The number of bytes read.
3901
3901
  */
3902
3902
  export function readvSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
3903
+
3904
+ export interface OpenAsBlobOptions {
3905
+ /**
3906
+ * An optional mime type for the blob.
3907
+ *
3908
+ * @default 'undefined'
3909
+ */
3910
+ type?: string | undefined;
3911
+ }
3912
+
3913
+ /**
3914
+ * Returns a Blob whose data is backed by the given file.
3915
+ *
3916
+ * The file must not be modified after the `Blob` is created.
3917
+ * Any modifications will cause reading the `Blob` data to fail with a `DOMException` error.
3918
+ * Synchronous stat operations on the file when the `Blob` is created, and before each read in order to detect whether the file data has been modified on disk.
3919
+ *
3920
+ * @param path
3921
+ * @param [options]
3922
+ *
3923
+ * @experimental
3924
+ * @since v19.8.0
3925
+ */
3926
+ export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise<Blob>;
3927
+
3903
3928
  export interface OpenDirOptions {
3904
3929
  /**
3905
3930
  * @default 'utf8'
node/ts4.8/module.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  */
4
4
  declare module 'module' {
5
5
  import { URL } from 'node:url';
6
+ import { MessagePort } from 'node:worker_threads';
6
7
  namespace Module {
7
8
  /**
8
9
  * The `module.syncBuiltinESMExports()` method updates all the live bindings for
@@ -92,6 +93,101 @@ declare module 'module' {
92
93
  */
93
94
  findEntry(lineOffset: number, columnOffset: number): SourceMapping;
94
95
  }
96
+ type ModuleFormat = 'builtin' | 'commonjs' | 'json' | 'module' | 'wasm';
97
+ type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
98
+ interface GlobalPreloadContext {
99
+ port: MessagePort;
100
+ }
101
+ /**
102
+ * Sometimes it might be necessary to run some code inside of the same global scope that the application runs in.
103
+ * This hook allows the return of a string that is run as a sloppy-mode script on startup.
104
+ *
105
+ * @param context Information to assist the preload code
106
+ * @return Code to run before application startup
107
+ */
108
+ type GlobalPreloadHook = (context: GlobalPreloadContext) => string;
109
+ interface ResolveHookContext {
110
+ /**
111
+ * Export conditions of the relevant `package.json`
112
+ */
113
+ conditions: string[];
114
+ /**
115
+ * An object whose key-value pairs represent the assertions for the module to import
116
+ */
117
+ importAssertions: Object;
118
+ /**
119
+ * The module importing this one, or undefined if this is the Node.js entry point
120
+ */
121
+ parentURL: string | undefined;
122
+ }
123
+ interface ResolveFnOutput {
124
+ /**
125
+ * A hint to the load hook (it might be ignored)
126
+ */
127
+ format?: ModuleFormat | null | undefined;
128
+ /**
129
+ * The import assertions to use when caching the module (optional; if excluded the input will be used)
130
+ */
131
+ importAssertions?: Object | undefined;
132
+ /**
133
+ * A signal that this hook intends to terminate the chain of `resolve` hooks.
134
+ * @default false
135
+ */
136
+ shortCircuit?: boolean | undefined;
137
+ /**
138
+ * The absolute URL to which this input resolves
139
+ */
140
+ url: string;
141
+ }
142
+ /**
143
+ * The `resolve` hook chain is responsible for resolving file URL for a given module specifier and parent URL, and optionally its format (such as `'module'`) as a hint to the `load` hook.
144
+ * If a format is specified, the load hook is ultimately responsible for providing the final `format` value (and it is free to ignore the hint provided by `resolve`);
145
+ * if `resolve` provides a format, a custom `load` hook is required even if only to pass the value to the Node.js default `load` hook.
146
+ *
147
+ * @param specifier The specified URL path of the module to be resolved
148
+ * @param context
149
+ * @param nextResolve The subsequent `resolve` hook in the chain, or the Node.js default `resolve` hook after the last user-supplied resolve hook
150
+ */
151
+ type ResolveHook = (
152
+ specifier: string,
153
+ context: ResolveHookContext,
154
+ nextResolve: (specifier: string, context?: ResolveHookContext) => ResolveFnOutput
155
+ ) => ResolveFnOutput | Promise<ResolveFnOutput>;
156
+ interface LoadHookContext {
157
+ /**
158
+ * Export conditions of the relevant `package.json`
159
+ */
160
+ conditions: string[];
161
+ /**
162
+ * The format optionally supplied by the `resolve` hook chain
163
+ */
164
+ format: ModuleFormat;
165
+ /**
166
+ * An object whose key-value pairs represent the assertions for the module to import
167
+ */
168
+ importAssertions: Object;
169
+ }
170
+ interface LoadFnOutput {
171
+ format: ModuleFormat;
172
+ /**
173
+ * A signal that this hook intends to terminate the chain of `resolve` hooks.
174
+ * @default false
175
+ */
176
+ shortCircuit?: boolean | undefined;
177
+ /**
178
+ * The source for Node.js to evaluate
179
+ */
180
+ source?: ModuleSource;
181
+ }
182
+ /**
183
+ * The `load` hook provides a way to define a custom method of determining how a URL should be interpreted, retrieved, and parsed.
184
+ * It is also in charge of validating the import assertion.
185
+ *
186
+ * @param url The URL/path of the module to be loaded
187
+ * @param context Metadata about the module
188
+ * @param nextLoad The subsequent `load` hook in the chain, or the Node.js default `load` hook after the last user-supplied `load` hook
189
+ */
190
+ type LoadHook = (url: string, context: LoadHookContext, nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput) => LoadFnOutput | Promise<LoadFnOutput>;
95
191
  }
96
192
  interface Module extends NodeModule {}
97
193
  class Module {