@types/node 20.17.58 → 20.19.0
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 v20.17 → node v20.19}/README.md +1 -1
- {node v20.17 → node v20.19}/globals.d.ts +4 -0
- {node v20.17 → node v20.19}/inspector.d.ts +272 -2
- {node v20.17 → node v20.19}/package.json +3 -3
- {node v20.17 → node v20.19}/perf_hooks.d.ts +29 -0
- {node v20.17 → node v20.19}/process.d.ts +54 -10
- {node v20.17 → node v20.19}/test.d.ts +49 -0
- {node v20.17 → node v20.19}/tls.d.ts +6 -0
- {node v20.17 → node v20.19}/url.d.ts +9 -0
- {node v20.17 → node v20.19}/util.d.ts +12 -0
- {node v20.17 → node v20.19}/vm.d.ts +79 -24
- {node v20.17 → node v20.19}/worker_threads.d.ts +18 -0
- {node v20.17 → node v20.19}/LICENSE +0 -0
- {node v20.17 → node v20.19}/assert/strict.d.ts +0 -0
- {node v20.17 → node v20.19}/assert.d.ts +0 -0
- {node v20.17 → node v20.19}/async_hooks.d.ts +0 -0
- {node v20.17 → node v20.19}/buffer.buffer.d.ts +0 -0
- {node v20.17 → node v20.19}/buffer.d.ts +0 -0
- {node v20.17 → node v20.19}/child_process.d.ts +0 -0
- {node v20.17 → node v20.19}/cluster.d.ts +0 -0
- {node v20.17 → node v20.19}/compatibility/disposable.d.ts +0 -0
- {node v20.17 → node v20.19}/compatibility/index.d.ts +0 -0
- {node v20.17 → node v20.19}/compatibility/indexable.d.ts +0 -0
- {node v20.17 → node v20.19}/compatibility/iterators.d.ts +0 -0
- {node v20.17 → node v20.19}/console.d.ts +0 -0
- {node v20.17 → node v20.19}/constants.d.ts +0 -0
- {node v20.17 → node v20.19}/crypto.d.ts +0 -0
- {node v20.17 → node v20.19}/dgram.d.ts +0 -0
- {node v20.17 → node v20.19}/diagnostics_channel.d.ts +0 -0
- {node v20.17 → node v20.19}/dns/promises.d.ts +0 -0
- {node v20.17 → node v20.19}/dns.d.ts +0 -0
- {node v20.17 → node v20.19}/dom-events.d.ts +0 -0
- {node v20.17 → node v20.19}/domain.d.ts +0 -0
- {node v20.17 → node v20.19}/events.d.ts +0 -0
- {node v20.17 → node v20.19}/fs/promises.d.ts +0 -0
- {node v20.17 → node v20.19}/fs.d.ts +0 -0
- {node v20.17 → node v20.19}/globals.typedarray.d.ts +0 -0
- {node v20.17 → node v20.19}/http.d.ts +0 -0
- {node v20.17 → node v20.19}/http2.d.ts +0 -0
- {node v20.17 → node v20.19}/https.d.ts +0 -0
- {node v20.17 → node v20.19}/index.d.ts +0 -0
- {node v20.17 → node v20.19}/module.d.ts +0 -0
- {node v20.17 → node v20.19}/net.d.ts +0 -0
- {node v20.17 → node v20.19}/os.d.ts +0 -0
- {node v20.17 → node v20.19}/path.d.ts +0 -0
- {node v20.17 → node v20.19}/punycode.d.ts +0 -0
- {node v20.17 → node v20.19}/querystring.d.ts +0 -0
- {node v20.17 → node v20.19}/readline/promises.d.ts +0 -0
- {node v20.17 → node v20.19}/readline.d.ts +0 -0
- {node v20.17 → node v20.19}/repl.d.ts +0 -0
- {node v20.17 → node v20.19}/sea.d.ts +0 -0
- {node v20.17 → node v20.19}/stream/consumers.d.ts +0 -0
- {node v20.17 → node v20.19}/stream/promises.d.ts +0 -0
- {node v20.17 → node v20.19}/stream/web.d.ts +0 -0
- {node v20.17 → node v20.19}/stream.d.ts +0 -0
- {node v20.17 → node v20.19}/string_decoder.d.ts +0 -0
- {node v20.17 → node v20.19}/timers/promises.d.ts +0 -0
- {node v20.17 → node v20.19}/timers.d.ts +0 -0
- {node v20.17 → node v20.19}/trace_events.d.ts +0 -0
- {node v20.17 → node v20.19}/ts5.6/buffer.buffer.d.ts +0 -0
- {node v20.17 → node v20.19}/ts5.6/globals.typedarray.d.ts +0 -0
- {node v20.17 → node v20.19}/ts5.6/index.d.ts +0 -0
- {node v20.17 → node v20.19}/tty.d.ts +0 -0
- {node v20.17 → node v20.19}/v8.d.ts +0 -0
- {node v20.17 → node v20.19}/wasi.d.ts +0 -0
- {node v20.17 → node v20.19}/zlib.d.ts +0 -0
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v20.
|
9
9
|
|
10
10
|
### Additional Details
|
11
|
-
* Last updated:
|
11
|
+
* Last updated: Fri, 06 Jun 2025 03:49:26 GMT
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
13
13
|
|
14
14
|
# Credits
|
@@ -12,6 +12,7 @@ type _RequestInit = typeof globalThis extends { onmessage: any } ? {}
|
|
12
12
|
: import("undici-types").RequestInit;
|
13
13
|
type _ResponseInit = typeof globalThis extends { onmessage: any } ? {}
|
14
14
|
: import("undici-types").ResponseInit;
|
15
|
+
type _EventSource = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").EventSource;
|
15
16
|
// #endregion Fetch and friends
|
16
17
|
|
17
18
|
// #region DOMException
|
@@ -327,5 +328,8 @@ declare global {
|
|
327
328
|
} ? T
|
328
329
|
: typeof import("undici-types").MessageEvent;
|
329
330
|
|
331
|
+
interface EventSource extends _EventSource {}
|
332
|
+
var EventSource: typeof globalThis extends { onmessage: any; EventSource: infer T } ? T
|
333
|
+
: typeof import("undici-types").EventSource;
|
330
334
|
// #endregion fetch
|
331
335
|
}
|
@@ -1703,6 +1703,110 @@ declare module 'inspector' {
|
|
1703
1703
|
message: string;
|
1704
1704
|
}
|
1705
1705
|
}
|
1706
|
+
namespace Network {
|
1707
|
+
/**
|
1708
|
+
* Resource type as it was perceived by the rendering engine.
|
1709
|
+
*/
|
1710
|
+
type ResourceType = string;
|
1711
|
+
/**
|
1712
|
+
* Unique request identifier.
|
1713
|
+
*/
|
1714
|
+
type RequestId = string;
|
1715
|
+
/**
|
1716
|
+
* UTC time in seconds, counted from January 1, 1970.
|
1717
|
+
*/
|
1718
|
+
type TimeSinceEpoch = number;
|
1719
|
+
/**
|
1720
|
+
* Monotonically increasing time in seconds since an arbitrary point in the past.
|
1721
|
+
*/
|
1722
|
+
type MonotonicTime = number;
|
1723
|
+
/**
|
1724
|
+
* HTTP request data.
|
1725
|
+
*/
|
1726
|
+
interface Request {
|
1727
|
+
url: string;
|
1728
|
+
method: string;
|
1729
|
+
headers: Headers;
|
1730
|
+
}
|
1731
|
+
/**
|
1732
|
+
* HTTP response data.
|
1733
|
+
*/
|
1734
|
+
interface Response {
|
1735
|
+
url: string;
|
1736
|
+
status: number;
|
1737
|
+
statusText: string;
|
1738
|
+
headers: Headers;
|
1739
|
+
}
|
1740
|
+
/**
|
1741
|
+
* Request / response headers as keys / values of JSON object.
|
1742
|
+
*/
|
1743
|
+
interface Headers {
|
1744
|
+
}
|
1745
|
+
interface RequestWillBeSentEventDataType {
|
1746
|
+
/**
|
1747
|
+
* Request identifier.
|
1748
|
+
*/
|
1749
|
+
requestId: RequestId;
|
1750
|
+
/**
|
1751
|
+
* Request data.
|
1752
|
+
*/
|
1753
|
+
request: Request;
|
1754
|
+
/**
|
1755
|
+
* Timestamp.
|
1756
|
+
*/
|
1757
|
+
timestamp: MonotonicTime;
|
1758
|
+
/**
|
1759
|
+
* Timestamp.
|
1760
|
+
*/
|
1761
|
+
wallTime: TimeSinceEpoch;
|
1762
|
+
}
|
1763
|
+
interface ResponseReceivedEventDataType {
|
1764
|
+
/**
|
1765
|
+
* Request identifier.
|
1766
|
+
*/
|
1767
|
+
requestId: RequestId;
|
1768
|
+
/**
|
1769
|
+
* Timestamp.
|
1770
|
+
*/
|
1771
|
+
timestamp: MonotonicTime;
|
1772
|
+
/**
|
1773
|
+
* Resource type.
|
1774
|
+
*/
|
1775
|
+
type: ResourceType;
|
1776
|
+
/**
|
1777
|
+
* Response data.
|
1778
|
+
*/
|
1779
|
+
response: Response;
|
1780
|
+
}
|
1781
|
+
interface LoadingFailedEventDataType {
|
1782
|
+
/**
|
1783
|
+
* Request identifier.
|
1784
|
+
*/
|
1785
|
+
requestId: RequestId;
|
1786
|
+
/**
|
1787
|
+
* Timestamp.
|
1788
|
+
*/
|
1789
|
+
timestamp: MonotonicTime;
|
1790
|
+
/**
|
1791
|
+
* Resource type.
|
1792
|
+
*/
|
1793
|
+
type: ResourceType;
|
1794
|
+
/**
|
1795
|
+
* Error message.
|
1796
|
+
*/
|
1797
|
+
errorText: string;
|
1798
|
+
}
|
1799
|
+
interface LoadingFinishedEventDataType {
|
1800
|
+
/**
|
1801
|
+
* Request identifier.
|
1802
|
+
*/
|
1803
|
+
requestId: RequestId;
|
1804
|
+
/**
|
1805
|
+
* Timestamp.
|
1806
|
+
*/
|
1807
|
+
timestamp: MonotonicTime;
|
1808
|
+
}
|
1809
|
+
}
|
1706
1810
|
namespace NodeRuntime {
|
1707
1811
|
interface NotifyWhenWaitingForDisconnectParameterType {
|
1708
1812
|
enabled: boolean;
|
@@ -2076,6 +2180,14 @@ declare module 'inspector' {
|
|
2076
2180
|
*/
|
2077
2181
|
post(method: 'NodeWorker.detach', params?: NodeWorker.DetachParameterType, callback?: (err: Error | null) => void): void;
|
2078
2182
|
post(method: 'NodeWorker.detach', callback?: (err: Error | null) => void): void;
|
2183
|
+
/**
|
2184
|
+
* Disables network tracking, prevents network events from being sent to the client.
|
2185
|
+
*/
|
2186
|
+
post(method: 'Network.disable', callback?: (err: Error | null) => void): void;
|
2187
|
+
/**
|
2188
|
+
* Enables network tracking, network events will now be delivered to the client.
|
2189
|
+
*/
|
2190
|
+
post(method: 'Network.enable', callback?: (err: Error | null) => void): void;
|
2079
2191
|
/**
|
2080
2192
|
* Enable the NodeRuntime events except by `NodeRuntime.waitingForDisconnect`.
|
2081
2193
|
*/
|
@@ -2185,6 +2297,16 @@ declare module 'inspector' {
|
|
2185
2297
|
* (session ID is provided in attachedToWorker notification).
|
2186
2298
|
*/
|
2187
2299
|
addListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>) => void): this;
|
2300
|
+
/**
|
2301
|
+
* Fired when page is about to send HTTP request.
|
2302
|
+
*/
|
2303
|
+
addListener(event: 'Network.requestWillBeSent', listener: (message: InspectorNotification<Network.RequestWillBeSentEventDataType>) => void): this;
|
2304
|
+
/**
|
2305
|
+
* Fired when HTTP response is available.
|
2306
|
+
*/
|
2307
|
+
addListener(event: 'Network.responseReceived', listener: (message: InspectorNotification<Network.ResponseReceivedEventDataType>) => void): this;
|
2308
|
+
addListener(event: 'Network.loadingFailed', listener: (message: InspectorNotification<Network.LoadingFailedEventDataType>) => void): this;
|
2309
|
+
addListener(event: 'Network.loadingFinished', listener: (message: InspectorNotification<Network.LoadingFinishedEventDataType>) => void): this;
|
2188
2310
|
/**
|
2189
2311
|
* This event is fired instead of `Runtime.executionContextDestroyed` when
|
2190
2312
|
* enabled.
|
@@ -2224,6 +2346,10 @@ declare module 'inspector' {
|
|
2224
2346
|
emit(event: 'NodeWorker.attachedToWorker', message: InspectorNotification<NodeWorker.AttachedToWorkerEventDataType>): boolean;
|
2225
2347
|
emit(event: 'NodeWorker.detachedFromWorker', message: InspectorNotification<NodeWorker.DetachedFromWorkerEventDataType>): boolean;
|
2226
2348
|
emit(event: 'NodeWorker.receivedMessageFromWorker', message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>): boolean;
|
2349
|
+
emit(event: 'Network.requestWillBeSent', message: InspectorNotification<Network.RequestWillBeSentEventDataType>): boolean;
|
2350
|
+
emit(event: 'Network.responseReceived', message: InspectorNotification<Network.ResponseReceivedEventDataType>): boolean;
|
2351
|
+
emit(event: 'Network.loadingFailed', message: InspectorNotification<Network.LoadingFailedEventDataType>): boolean;
|
2352
|
+
emit(event: 'Network.loadingFinished', message: InspectorNotification<Network.LoadingFinishedEventDataType>): boolean;
|
2227
2353
|
emit(event: 'NodeRuntime.waitingForDisconnect'): boolean;
|
2228
2354
|
emit(event: 'NodeRuntime.waitingForDebugger'): boolean;
|
2229
2355
|
on(event: string, listener: (...args: any[]) => void): this;
|
@@ -2321,6 +2447,16 @@ declare module 'inspector' {
|
|
2321
2447
|
* (session ID is provided in attachedToWorker notification).
|
2322
2448
|
*/
|
2323
2449
|
on(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>) => void): this;
|
2450
|
+
/**
|
2451
|
+
* Fired when page is about to send HTTP request.
|
2452
|
+
*/
|
2453
|
+
on(event: 'Network.requestWillBeSent', listener: (message: InspectorNotification<Network.RequestWillBeSentEventDataType>) => void): this;
|
2454
|
+
/**
|
2455
|
+
* Fired when HTTP response is available.
|
2456
|
+
*/
|
2457
|
+
on(event: 'Network.responseReceived', listener: (message: InspectorNotification<Network.ResponseReceivedEventDataType>) => void): this;
|
2458
|
+
on(event: 'Network.loadingFailed', listener: (message: InspectorNotification<Network.LoadingFailedEventDataType>) => void): this;
|
2459
|
+
on(event: 'Network.loadingFinished', listener: (message: InspectorNotification<Network.LoadingFinishedEventDataType>) => void): this;
|
2324
2460
|
/**
|
2325
2461
|
* This event is fired instead of `Runtime.executionContextDestroyed` when
|
2326
2462
|
* enabled.
|
@@ -2428,6 +2564,16 @@ declare module 'inspector' {
|
|
2428
2564
|
* (session ID is provided in attachedToWorker notification).
|
2429
2565
|
*/
|
2430
2566
|
once(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>) => void): this;
|
2567
|
+
/**
|
2568
|
+
* Fired when page is about to send HTTP request.
|
2569
|
+
*/
|
2570
|
+
once(event: 'Network.requestWillBeSent', listener: (message: InspectorNotification<Network.RequestWillBeSentEventDataType>) => void): this;
|
2571
|
+
/**
|
2572
|
+
* Fired when HTTP response is available.
|
2573
|
+
*/
|
2574
|
+
once(event: 'Network.responseReceived', listener: (message: InspectorNotification<Network.ResponseReceivedEventDataType>) => void): this;
|
2575
|
+
once(event: 'Network.loadingFailed', listener: (message: InspectorNotification<Network.LoadingFailedEventDataType>) => void): this;
|
2576
|
+
once(event: 'Network.loadingFinished', listener: (message: InspectorNotification<Network.LoadingFinishedEventDataType>) => void): this;
|
2431
2577
|
/**
|
2432
2578
|
* This event is fired instead of `Runtime.executionContextDestroyed` when
|
2433
2579
|
* enabled.
|
@@ -2535,6 +2681,16 @@ declare module 'inspector' {
|
|
2535
2681
|
* (session ID is provided in attachedToWorker notification).
|
2536
2682
|
*/
|
2537
2683
|
prependListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>) => void): this;
|
2684
|
+
/**
|
2685
|
+
* Fired when page is about to send HTTP request.
|
2686
|
+
*/
|
2687
|
+
prependListener(event: 'Network.requestWillBeSent', listener: (message: InspectorNotification<Network.RequestWillBeSentEventDataType>) => void): this;
|
2688
|
+
/**
|
2689
|
+
* Fired when HTTP response is available.
|
2690
|
+
*/
|
2691
|
+
prependListener(event: 'Network.responseReceived', listener: (message: InspectorNotification<Network.ResponseReceivedEventDataType>) => void): this;
|
2692
|
+
prependListener(event: 'Network.loadingFailed', listener: (message: InspectorNotification<Network.LoadingFailedEventDataType>) => void): this;
|
2693
|
+
prependListener(event: 'Network.loadingFinished', listener: (message: InspectorNotification<Network.LoadingFinishedEventDataType>) => void): this;
|
2538
2694
|
/**
|
2539
2695
|
* This event is fired instead of `Runtime.executionContextDestroyed` when
|
2540
2696
|
* enabled.
|
@@ -2642,6 +2798,16 @@ declare module 'inspector' {
|
|
2642
2798
|
* (session ID is provided in attachedToWorker notification).
|
2643
2799
|
*/
|
2644
2800
|
prependOnceListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>) => void): this;
|
2801
|
+
/**
|
2802
|
+
* Fired when page is about to send HTTP request.
|
2803
|
+
*/
|
2804
|
+
prependOnceListener(event: 'Network.requestWillBeSent', listener: (message: InspectorNotification<Network.RequestWillBeSentEventDataType>) => void): this;
|
2805
|
+
/**
|
2806
|
+
* Fired when HTTP response is available.
|
2807
|
+
*/
|
2808
|
+
prependOnceListener(event: 'Network.responseReceived', listener: (message: InspectorNotification<Network.ResponseReceivedEventDataType>) => void): this;
|
2809
|
+
prependOnceListener(event: 'Network.loadingFailed', listener: (message: InspectorNotification<Network.LoadingFailedEventDataType>) => void): this;
|
2810
|
+
prependOnceListener(event: 'Network.loadingFinished', listener: (message: InspectorNotification<Network.LoadingFinishedEventDataType>) => void): this;
|
2645
2811
|
/**
|
2646
2812
|
* This event is fired instead of `Runtime.executionContextDestroyed` when
|
2647
2813
|
* enabled.
|
@@ -2699,7 +2865,7 @@ declare module 'inspector' {
|
|
2699
2865
|
|
2700
2866
|
/**
|
2701
2867
|
* Blocks until a client (existing or connected later) has sent `Runtime.runIfWaitingForDebugger` command.
|
2702
|
-
*
|
2868
|
+
*
|
2703
2869
|
* An exception will be thrown if there is no active inspector.
|
2704
2870
|
* @since v12.7.0
|
2705
2871
|
*/
|
@@ -2737,6 +2903,46 @@ declare module 'inspector' {
|
|
2737
2903
|
* @since v11.0.0
|
2738
2904
|
*/
|
2739
2905
|
const console: InspectorConsole;
|
2906
|
+
|
2907
|
+
// DevTools protocol event broadcast methods
|
2908
|
+
namespace Network {
|
2909
|
+
/**
|
2910
|
+
* This feature is only available with the `--experimental-network-inspection` flag enabled.
|
2911
|
+
*
|
2912
|
+
* Broadcasts the `Network.requestWillBeSent` event to connected frontends. This event indicates that
|
2913
|
+
* the application is about to send an HTTP request.
|
2914
|
+
* @since v22.6.0
|
2915
|
+
* @experimental
|
2916
|
+
*/
|
2917
|
+
function requestWillBeSent(params: RequestWillBeSentEventDataType): void;
|
2918
|
+
/**
|
2919
|
+
* This feature is only available with the `--experimental-network-inspection` flag enabled.
|
2920
|
+
*
|
2921
|
+
* Broadcasts the `Network.responseReceived` event to connected frontends. This event indicates that
|
2922
|
+
* HTTP response is available.
|
2923
|
+
* @since v22.6.0
|
2924
|
+
* @experimental
|
2925
|
+
*/
|
2926
|
+
function responseReceived(params: ResponseReceivedEventDataType): void;
|
2927
|
+
/**
|
2928
|
+
* This feature is only available with the `--experimental-network-inspection` flag enabled.
|
2929
|
+
*
|
2930
|
+
* Broadcasts the `Network.loadingFinished` event to connected frontends. This event indicates that
|
2931
|
+
* HTTP request has finished loading.
|
2932
|
+
* @since v22.6.0
|
2933
|
+
* @experimental
|
2934
|
+
*/
|
2935
|
+
function loadingFinished(params: LoadingFinishedEventDataType): void;
|
2936
|
+
/**
|
2937
|
+
* This feature is only available with the `--experimental-network-inspection` flag enabled.
|
2938
|
+
*
|
2939
|
+
* Broadcasts the `Network.loadingFailed` event to connected frontends. This event indicates that
|
2940
|
+
* HTTP request has failed to load.
|
2941
|
+
* @since v22.7.0
|
2942
|
+
* @experimental
|
2943
|
+
*/
|
2944
|
+
function loadingFailed(params: LoadingFailedEventDataType): void;
|
2945
|
+
}
|
2740
2946
|
}
|
2741
2947
|
|
2742
2948
|
/**
|
@@ -2770,6 +2976,7 @@ declare module 'inspector/promises' {
|
|
2770
2976
|
HeapProfiler,
|
2771
2977
|
NodeTracing,
|
2772
2978
|
NodeWorker,
|
2979
|
+
Network,
|
2773
2980
|
NodeRuntime,
|
2774
2981
|
} from 'inspector';
|
2775
2982
|
|
@@ -2816,7 +3023,7 @@ declare module 'inspector/promises' {
|
|
2816
3023
|
* } catch (error) {
|
2817
3024
|
* console.error(error);
|
2818
3025
|
* }
|
2819
|
-
* // Output: { result: { type: 'number', value: 4, description: '4' } }
|
3026
|
+
* // Output: { result: { type: 'number', value: 4, description: '4' } }
|
2820
3027
|
* ```
|
2821
3028
|
*
|
2822
3029
|
* The latest version of the V8 inspector protocol is published on the
|
@@ -3087,6 +3294,14 @@ declare module 'inspector/promises' {
|
|
3087
3294
|
* Detached from the worker with given sessionId.
|
3088
3295
|
*/
|
3089
3296
|
post(method: 'NodeWorker.detach', params?: NodeWorker.DetachParameterType): Promise<void>;
|
3297
|
+
/**
|
3298
|
+
* Disables network tracking, prevents network events from being sent to the client.
|
3299
|
+
*/
|
3300
|
+
post(method: 'Network.disable'): Promise<void>;
|
3301
|
+
/**
|
3302
|
+
* Enables network tracking, network events will now be delivered to the client.
|
3303
|
+
*/
|
3304
|
+
post(method: 'Network.enable'): Promise<void>;
|
3090
3305
|
/**
|
3091
3306
|
* Enable the NodeRuntime events except by `NodeRuntime.waitingForDisconnect`.
|
3092
3307
|
*/
|
@@ -3195,6 +3410,16 @@ declare module 'inspector/promises' {
|
|
3195
3410
|
* (session ID is provided in attachedToWorker notification).
|
3196
3411
|
*/
|
3197
3412
|
addListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>) => void): this;
|
3413
|
+
/**
|
3414
|
+
* Fired when page is about to send HTTP request.
|
3415
|
+
*/
|
3416
|
+
addListener(event: 'Network.requestWillBeSent', listener: (message: InspectorNotification<Network.RequestWillBeSentEventDataType>) => void): this;
|
3417
|
+
/**
|
3418
|
+
* Fired when HTTP response is available.
|
3419
|
+
*/
|
3420
|
+
addListener(event: 'Network.responseReceived', listener: (message: InspectorNotification<Network.ResponseReceivedEventDataType>) => void): this;
|
3421
|
+
addListener(event: 'Network.loadingFailed', listener: (message: InspectorNotification<Network.LoadingFailedEventDataType>) => void): this;
|
3422
|
+
addListener(event: 'Network.loadingFinished', listener: (message: InspectorNotification<Network.LoadingFinishedEventDataType>) => void): this;
|
3198
3423
|
/**
|
3199
3424
|
* This event is fired instead of `Runtime.executionContextDestroyed` when
|
3200
3425
|
* enabled.
|
@@ -3234,6 +3459,10 @@ declare module 'inspector/promises' {
|
|
3234
3459
|
emit(event: 'NodeWorker.attachedToWorker', message: InspectorNotification<NodeWorker.AttachedToWorkerEventDataType>): boolean;
|
3235
3460
|
emit(event: 'NodeWorker.detachedFromWorker', message: InspectorNotification<NodeWorker.DetachedFromWorkerEventDataType>): boolean;
|
3236
3461
|
emit(event: 'NodeWorker.receivedMessageFromWorker', message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>): boolean;
|
3462
|
+
emit(event: 'Network.requestWillBeSent', message: InspectorNotification<Network.RequestWillBeSentEventDataType>): boolean;
|
3463
|
+
emit(event: 'Network.responseReceived', message: InspectorNotification<Network.ResponseReceivedEventDataType>): boolean;
|
3464
|
+
emit(event: 'Network.loadingFailed', message: InspectorNotification<Network.LoadingFailedEventDataType>): boolean;
|
3465
|
+
emit(event: 'Network.loadingFinished', message: InspectorNotification<Network.LoadingFinishedEventDataType>): boolean;
|
3237
3466
|
emit(event: 'NodeRuntime.waitingForDisconnect'): boolean;
|
3238
3467
|
emit(event: 'NodeRuntime.waitingForDebugger'): boolean;
|
3239
3468
|
on(event: string, listener: (...args: any[]) => void): this;
|
@@ -3331,6 +3560,16 @@ declare module 'inspector/promises' {
|
|
3331
3560
|
* (session ID is provided in attachedToWorker notification).
|
3332
3561
|
*/
|
3333
3562
|
on(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>) => void): this;
|
3563
|
+
/**
|
3564
|
+
* Fired when page is about to send HTTP request.
|
3565
|
+
*/
|
3566
|
+
on(event: 'Network.requestWillBeSent', listener: (message: InspectorNotification<Network.RequestWillBeSentEventDataType>) => void): this;
|
3567
|
+
/**
|
3568
|
+
* Fired when HTTP response is available.
|
3569
|
+
*/
|
3570
|
+
on(event: 'Network.responseReceived', listener: (message: InspectorNotification<Network.ResponseReceivedEventDataType>) => void): this;
|
3571
|
+
on(event: 'Network.loadingFailed', listener: (message: InspectorNotification<Network.LoadingFailedEventDataType>) => void): this;
|
3572
|
+
on(event: 'Network.loadingFinished', listener: (message: InspectorNotification<Network.LoadingFinishedEventDataType>) => void): this;
|
3334
3573
|
/**
|
3335
3574
|
* This event is fired instead of `Runtime.executionContextDestroyed` when
|
3336
3575
|
* enabled.
|
@@ -3438,6 +3677,16 @@ declare module 'inspector/promises' {
|
|
3438
3677
|
* (session ID is provided in attachedToWorker notification).
|
3439
3678
|
*/
|
3440
3679
|
once(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>) => void): this;
|
3680
|
+
/**
|
3681
|
+
* Fired when page is about to send HTTP request.
|
3682
|
+
*/
|
3683
|
+
once(event: 'Network.requestWillBeSent', listener: (message: InspectorNotification<Network.RequestWillBeSentEventDataType>) => void): this;
|
3684
|
+
/**
|
3685
|
+
* Fired when HTTP response is available.
|
3686
|
+
*/
|
3687
|
+
once(event: 'Network.responseReceived', listener: (message: InspectorNotification<Network.ResponseReceivedEventDataType>) => void): this;
|
3688
|
+
once(event: 'Network.loadingFailed', listener: (message: InspectorNotification<Network.LoadingFailedEventDataType>) => void): this;
|
3689
|
+
once(event: 'Network.loadingFinished', listener: (message: InspectorNotification<Network.LoadingFinishedEventDataType>) => void): this;
|
3441
3690
|
/**
|
3442
3691
|
* This event is fired instead of `Runtime.executionContextDestroyed` when
|
3443
3692
|
* enabled.
|
@@ -3545,6 +3794,16 @@ declare module 'inspector/promises' {
|
|
3545
3794
|
* (session ID is provided in attachedToWorker notification).
|
3546
3795
|
*/
|
3547
3796
|
prependListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>) => void): this;
|
3797
|
+
/**
|
3798
|
+
* Fired when page is about to send HTTP request.
|
3799
|
+
*/
|
3800
|
+
prependListener(event: 'Network.requestWillBeSent', listener: (message: InspectorNotification<Network.RequestWillBeSentEventDataType>) => void): this;
|
3801
|
+
/**
|
3802
|
+
* Fired when HTTP response is available.
|
3803
|
+
*/
|
3804
|
+
prependListener(event: 'Network.responseReceived', listener: (message: InspectorNotification<Network.ResponseReceivedEventDataType>) => void): this;
|
3805
|
+
prependListener(event: 'Network.loadingFailed', listener: (message: InspectorNotification<Network.LoadingFailedEventDataType>) => void): this;
|
3806
|
+
prependListener(event: 'Network.loadingFinished', listener: (message: InspectorNotification<Network.LoadingFinishedEventDataType>) => void): this;
|
3548
3807
|
/**
|
3549
3808
|
* This event is fired instead of `Runtime.executionContextDestroyed` when
|
3550
3809
|
* enabled.
|
@@ -3652,6 +3911,16 @@ declare module 'inspector/promises' {
|
|
3652
3911
|
* (session ID is provided in attachedToWorker notification).
|
3653
3912
|
*/
|
3654
3913
|
prependOnceListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification<NodeWorker.ReceivedMessageFromWorkerEventDataType>) => void): this;
|
3914
|
+
/**
|
3915
|
+
* Fired when page is about to send HTTP request.
|
3916
|
+
*/
|
3917
|
+
prependOnceListener(event: 'Network.requestWillBeSent', listener: (message: InspectorNotification<Network.RequestWillBeSentEventDataType>) => void): this;
|
3918
|
+
/**
|
3919
|
+
* Fired when HTTP response is available.
|
3920
|
+
*/
|
3921
|
+
prependOnceListener(event: 'Network.responseReceived', listener: (message: InspectorNotification<Network.ResponseReceivedEventDataType>) => void): this;
|
3922
|
+
prependOnceListener(event: 'Network.loadingFailed', listener: (message: InspectorNotification<Network.LoadingFailedEventDataType>) => void): this;
|
3923
|
+
prependOnceListener(event: 'Network.loadingFinished', listener: (message: InspectorNotification<Network.LoadingFinishedEventDataType>) => void): this;
|
3655
3924
|
/**
|
3656
3925
|
* This event is fired instead of `Runtime.executionContextDestroyed` when
|
3657
3926
|
* enabled.
|
@@ -3682,6 +3951,7 @@ declare module 'inspector/promises' {
|
|
3682
3951
|
HeapProfiler,
|
3683
3952
|
NodeTracing,
|
3684
3953
|
NodeWorker,
|
3954
|
+
Network,
|
3685
3955
|
NodeRuntime,
|
3686
3956
|
};
|
3687
3957
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/node",
|
3
|
-
"version": "20.
|
3
|
+
"version": "20.19.0",
|
4
4
|
"description": "TypeScript definitions for node",
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
6
6
|
"license": "MIT",
|
@@ -212,9 +212,9 @@
|
|
212
212
|
},
|
213
213
|
"scripts": {},
|
214
214
|
"dependencies": {
|
215
|
-
"undici-types": "~6.
|
215
|
+
"undici-types": "~6.21.0"
|
216
216
|
},
|
217
217
|
"peerDependencies": {},
|
218
|
-
"typesPublisherContentHash": "
|
218
|
+
"typesPublisherContentHash": "9ff3002c444137adbf46a444e8e7f187130fb26e40a4cabb38bf96d37cb95012",
|
219
219
|
"typeScriptVersion": "5.1"
|
220
220
|
}
|
@@ -116,6 +116,20 @@ declare module "perf_hooks" {
|
|
116
116
|
class PerformanceMeasure extends PerformanceEntry {
|
117
117
|
readonly entryType: "measure";
|
118
118
|
}
|
119
|
+
interface UVMetrics {
|
120
|
+
/**
|
121
|
+
* Number of event loop iterations.
|
122
|
+
*/
|
123
|
+
readonly loopCount: number;
|
124
|
+
/**
|
125
|
+
* Number of events that have been processed by the event handler.
|
126
|
+
*/
|
127
|
+
readonly events: number;
|
128
|
+
/**
|
129
|
+
* Number of events that were waiting to be processed when the event provider was called.
|
130
|
+
*/
|
131
|
+
readonly eventsWaiting: number;
|
132
|
+
}
|
119
133
|
/**
|
120
134
|
* _This property is an extension by Node.js. It is not available in Web browsers._
|
121
135
|
*
|
@@ -165,6 +179,16 @@ declare module "perf_hooks" {
|
|
165
179
|
* @since v8.5.0
|
166
180
|
*/
|
167
181
|
readonly nodeStart: number;
|
182
|
+
/**
|
183
|
+
* This is a wrapper to the `uv_metrics_info` function.
|
184
|
+
* It returns the current set of event loop metrics.
|
185
|
+
*
|
186
|
+
* It is recommended to use this property inside a function whose execution was
|
187
|
+
* scheduled using `setImmediate` to avoid collecting metrics before finishing all
|
188
|
+
* operations scheduled during the current loop iteration.
|
189
|
+
* @since v20.18.0
|
190
|
+
*/
|
191
|
+
readonly uvMetricsInfo: UVMetrics;
|
168
192
|
/**
|
169
193
|
* The high resolution millisecond timestamp at which the V8 platform was
|
170
194
|
* initialized.
|
@@ -563,6 +587,11 @@ declare module "perf_hooks" {
|
|
563
587
|
buffered?: boolean | undefined;
|
564
588
|
},
|
565
589
|
): void;
|
590
|
+
/**
|
591
|
+
* @since v16.0.0
|
592
|
+
* @returns Current list of entries stored in the performance observer, emptying it out.
|
593
|
+
*/
|
594
|
+
takeRecords(): PerformanceEntry[];
|
566
595
|
}
|
567
596
|
/**
|
568
597
|
* Provides detailed network timing data regarding the loading of an application's resources.
|
@@ -168,6 +168,59 @@ declare module "process" {
|
|
168
168
|
libUrl?: string | undefined;
|
169
169
|
lts?: string | undefined;
|
170
170
|
}
|
171
|
+
interface ProcessFeatures {
|
172
|
+
/**
|
173
|
+
* A boolean value that is `true` if the current Node.js build is caching builtin modules.
|
174
|
+
* @since v12.0.0
|
175
|
+
*/
|
176
|
+
readonly cached_builtins: boolean;
|
177
|
+
/**
|
178
|
+
* A boolean value that is `true` if the current Node.js build is a debug build.
|
179
|
+
* @since v0.5.5
|
180
|
+
*/
|
181
|
+
readonly debug: boolean;
|
182
|
+
/**
|
183
|
+
* A boolean value that is `true` if the current Node.js build includes the inspector.
|
184
|
+
* @since v11.10.0
|
185
|
+
*/
|
186
|
+
readonly inspector: boolean;
|
187
|
+
/**
|
188
|
+
* A boolean value that is `true` if the current Node.js build includes support for IPv6.
|
189
|
+
* @since v0.5.3
|
190
|
+
*/
|
191
|
+
readonly ipv6: boolean;
|
192
|
+
/**
|
193
|
+
* A boolean value that is `true` if the current Node.js build supports
|
194
|
+
* [loading ECMAScript modules using `require()`](https://nodejs.org/docs/latest-v20.x/api/modules.html#loading-ecmascript-modules-using-require).
|
195
|
+
* @since v20.19.0
|
196
|
+
*/
|
197
|
+
readonly require_module: boolean;
|
198
|
+
/**
|
199
|
+
* A boolean value that is `true` if the current Node.js build includes support for TLS.
|
200
|
+
* @since v0.5.3
|
201
|
+
*/
|
202
|
+
readonly tls: boolean;
|
203
|
+
/**
|
204
|
+
* A boolean value that is `true` if the current Node.js build includes support for ALPN in TLS.
|
205
|
+
* @since v4.8.0
|
206
|
+
*/
|
207
|
+
readonly tls_alpn: boolean;
|
208
|
+
/**
|
209
|
+
* A boolean value that is `true` if the current Node.js build includes support for OCSP in TLS.
|
210
|
+
* @since v0.11.13
|
211
|
+
*/
|
212
|
+
readonly tls_ocsp: boolean;
|
213
|
+
/**
|
214
|
+
* A boolean value that is `true` if the current Node.js build includes support for SNI in TLS.
|
215
|
+
* @since v0.5.3
|
216
|
+
*/
|
217
|
+
readonly tls_sni: boolean;
|
218
|
+
/**
|
219
|
+
* A boolean value that is `true` if the current Node.js build includes support for libuv.
|
220
|
+
* @since v0.5.3
|
221
|
+
*/
|
222
|
+
readonly uv: boolean;
|
223
|
+
}
|
171
224
|
interface ProcessVersions extends Dict<string> {
|
172
225
|
http_parser: string;
|
173
226
|
node: string;
|
@@ -1612,16 +1665,7 @@ declare module "process" {
|
|
1612
1665
|
* @since v3.0.0
|
1613
1666
|
*/
|
1614
1667
|
readonly release: ProcessRelease;
|
1615
|
-
features:
|
1616
|
-
inspector: boolean;
|
1617
|
-
debug: boolean;
|
1618
|
-
uv: boolean;
|
1619
|
-
ipv6: boolean;
|
1620
|
-
tls_alpn: boolean;
|
1621
|
-
tls_sni: boolean;
|
1622
|
-
tls_ocsp: boolean;
|
1623
|
-
tls: boolean;
|
1624
|
-
};
|
1668
|
+
readonly features: ProcessFeatures;
|
1625
1669
|
/**
|
1626
1670
|
* `process.umask()` returns the Node.js process's file mode creation mask. Child
|
1627
1671
|
* processes inherit the mask from the parent process.
|
@@ -853,6 +853,30 @@ declare module "node:test" {
|
|
853
853
|
type FunctionPropertyNames<T> = {
|
854
854
|
[K in keyof T]: T[K] extends Function ? K : never;
|
855
855
|
}[keyof T];
|
856
|
+
interface MockModuleOptions {
|
857
|
+
/**
|
858
|
+
* If false, each call to `require()` or `import()` generates a new mock module.
|
859
|
+
* If true, subsequent calls will return the same module mock, and the mock module is inserted into the CommonJS cache.
|
860
|
+
* @default false
|
861
|
+
*/
|
862
|
+
cache?: boolean | undefined;
|
863
|
+
/**
|
864
|
+
* The value to use as the mocked module's default export.
|
865
|
+
*
|
866
|
+
* If this value is not provided, ESM mocks do not include a default export.
|
867
|
+
* If the mock is a CommonJS or builtin module, this setting is used as the value of `module.exports`.
|
868
|
+
* If this value is not provided, CJS and builtin mocks use an empty object as the value of `module.exports`.
|
869
|
+
*/
|
870
|
+
defaultExport?: any;
|
871
|
+
/**
|
872
|
+
* An object whose keys and values are used to create the named exports of the mock module.
|
873
|
+
*
|
874
|
+
* If the mock is a CommonJS or builtin module, these values are copied onto `module.exports`.
|
875
|
+
* Therefore, if a mock is created with both named exports and a non-object default export,
|
876
|
+
* the mock will throw an exception when used as a CJS or builtin module.
|
877
|
+
*/
|
878
|
+
namedExports?: object | undefined;
|
879
|
+
}
|
856
880
|
/**
|
857
881
|
* The `MockTracker` class is used to manage mocking functionality. The test runner
|
858
882
|
* module provides a top level `mock` export which is a `MockTracker` instance.
|
@@ -1015,6 +1039,19 @@ declare module "node:test" {
|
|
1015
1039
|
implementation?: Implementation,
|
1016
1040
|
options?: MockFunctionOptions,
|
1017
1041
|
): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
|
1042
|
+
|
1043
|
+
/**
|
1044
|
+
* This function is used to mock the exports of ECMAScript modules, CommonJS modules, and Node.js builtin modules.
|
1045
|
+
* Any references to the original module prior to mocking are not impacted.
|
1046
|
+
*
|
1047
|
+
* Only available through the [--experimental-test-module-mocks](https://nodejs.org/api/cli.html#--experimental-test-module-mocks) flag.
|
1048
|
+
* @since v20.18.0
|
1049
|
+
* @experimental
|
1050
|
+
* @param specifier A string identifying the module to mock.
|
1051
|
+
* @param options Optional configuration options for the mock module.
|
1052
|
+
*/
|
1053
|
+
module(specifier: string, options?: MockModuleOptions): MockModuleContext;
|
1054
|
+
|
1018
1055
|
/**
|
1019
1056
|
* This function restores the default behavior of all mocks that were previously
|
1020
1057
|
* 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
|
@@ -1173,6 +1210,18 @@ declare module "node:test" {
|
|
1173
1210
|
*/
|
1174
1211
|
restore(): void;
|
1175
1212
|
}
|
1213
|
+
/**
|
1214
|
+
* @since v20.18.0
|
1215
|
+
* @experimental
|
1216
|
+
*/
|
1217
|
+
class MockModuleContext {
|
1218
|
+
/**
|
1219
|
+
* Resets the implementation of the mock module.
|
1220
|
+
* @since v20.18.0
|
1221
|
+
*/
|
1222
|
+
restore(): void;
|
1223
|
+
}
|
1224
|
+
|
1176
1225
|
type Timer = "setInterval" | "setTimeout" | "setImmediate" | "Date";
|
1177
1226
|
|
1178
1227
|
interface MockTimersOptions {
|
@@ -817,6 +817,12 @@ declare module "tls" {
|
|
817
817
|
* This option cannot be used with the `ALPNProtocols` option, and setting both options will throw an error.
|
818
818
|
*/
|
819
819
|
ALPNCallback?: ((arg: { servername: string; protocols: string[] }) => string | undefined) | undefined;
|
820
|
+
/**
|
821
|
+
* Treat intermediate (non-self-signed)
|
822
|
+
* certificates in the trust CA certificate list as trusted.
|
823
|
+
* @since v22.9.0, v20.18.0
|
824
|
+
*/
|
825
|
+
allowPartialTrustChain?: boolean | undefined;
|
820
826
|
/**
|
821
827
|
* Optionally override the trusted CA certificates. Default is to trust
|
822
828
|
* the well-known CAs curated by Mozilla. Mozilla's CAs are completely
|
@@ -437,6 +437,15 @@ declare module "url" {
|
|
437
437
|
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
|
438
438
|
*/
|
439
439
|
static canParse(input: string, base?: string): boolean;
|
440
|
+
/**
|
441
|
+
* Parses a string as a URL. If `base` is provided, it will be used as the base URL for the purpose of resolving non-absolute `input` URLs.
|
442
|
+
* Returns `null` if `input` is not a valid.
|
443
|
+
* @param input The absolute or relative input URL to parse. If `input` is relative, then `base` is required. If `input` is absolute, the `base` is ignored. If `input` is not a string, it is
|
444
|
+
* `converted to a string` first.
|
445
|
+
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
|
446
|
+
* @since v20.18.0
|
447
|
+
*/
|
448
|
+
static parse(input: string, base?: string): URL | null;
|
440
449
|
constructor(input: string | { toString: () => string }, base?: string | URL);
|
441
450
|
/**
|
442
451
|
* Gets and sets the fragment portion of the URL.
|
@@ -1865,6 +1865,18 @@ declare module "util/types" {
|
|
1865
1865
|
* @since v10.0.0
|
1866
1866
|
*/
|
1867
1867
|
function isBigInt64Array(value: unknown): value is BigInt64Array;
|
1868
|
+
/**
|
1869
|
+
* Returns `true` if the value is a BigInt object, e.g. created
|
1870
|
+
* by `Object(BigInt(123))`.
|
1871
|
+
*
|
1872
|
+
* ```js
|
1873
|
+
* util.types.isBigIntObject(Object(BigInt(123))); // Returns true
|
1874
|
+
* util.types.isBigIntObject(BigInt(123)); // Returns false
|
1875
|
+
* util.types.isBigIntObject(123); // Returns false
|
1876
|
+
* ```
|
1877
|
+
* @since v10.4.0
|
1878
|
+
*/
|
1879
|
+
function isBigIntObject(object: unknown): object is BigInt;
|
1868
1880
|
/**
|
1869
1881
|
* Returns `true` if the value is a `BigUint64Array` instance.
|
1870
1882
|
*
|
@@ -275,16 +275,23 @@ declare module "vm" {
|
|
275
275
|
*/
|
276
276
|
runInContext(contextifiedObject: Context, options?: RunningScriptOptions): any;
|
277
277
|
/**
|
278
|
-
*
|
279
|
-
*
|
280
|
-
*
|
278
|
+
* This method is a shortcut to `script.runInContext(vm.createContext(options), options)`.
|
279
|
+
* It does several things at once:
|
280
|
+
*
|
281
|
+
* 1. Creates a new context.
|
282
|
+
* 2. If `contextObject` is an object, contextifies it with the new context.
|
283
|
+
* If `contextObject` is undefined, creates a new object and contextifies it.
|
284
|
+
* If `contextObject` is `vm.constants.DONT_CONTEXTIFY`, don't contextify anything.
|
285
|
+
* 3. Runs the compiled code contained by the `vm.Script` object within the created context. The code
|
286
|
+
* does not have access to the scope in which this method is called.
|
287
|
+
* 4. Returns the result.
|
281
288
|
*
|
282
289
|
* The following example compiles code that sets a global variable, then executes
|
283
290
|
* the code multiple times in different contexts. The globals are set on and
|
284
291
|
* contained within each individual `context`.
|
285
292
|
*
|
286
293
|
* ```js
|
287
|
-
*
|
294
|
+
* const vm = require('node:vm');
|
288
295
|
*
|
289
296
|
* const script = new vm.Script('globalVar = "set"');
|
290
297
|
*
|
@@ -295,12 +302,22 @@ declare module "vm" {
|
|
295
302
|
*
|
296
303
|
* console.log(contexts);
|
297
304
|
* // Prints: [{ globalVar: 'set' }, { globalVar: 'set' }, { globalVar: 'set' }]
|
305
|
+
*
|
306
|
+
* // This would throw if the context is created from a contextified object.
|
307
|
+
* // vm.constants.DONT_CONTEXTIFY allows creating contexts with ordinary
|
308
|
+
* // global objects that can be frozen.
|
309
|
+
* const freezeScript = new vm.Script('Object.freeze(globalThis); globalThis;');
|
310
|
+
* const frozenContext = freezeScript.runInNewContext(vm.constants.DONT_CONTEXTIFY);
|
298
311
|
* ```
|
299
312
|
* @since v0.3.1
|
300
|
-
* @param contextObject
|
313
|
+
* @param contextObject Either `vm.constants.DONT_CONTEXTIFY` or an object that will be contextified.
|
314
|
+
* If `undefined`, an empty contextified object will be created for backwards compatibility.
|
301
315
|
* @return the result of the very last statement executed in the script.
|
302
316
|
*/
|
303
|
-
runInNewContext(
|
317
|
+
runInNewContext(
|
318
|
+
contextObject?: Context | typeof constants.DONT_CONTEXTIFY,
|
319
|
+
options?: RunningScriptInNewContextOptions,
|
320
|
+
): any;
|
304
321
|
/**
|
305
322
|
* Runs the compiled code contained by the `vm.Script` within the context of the
|
306
323
|
* current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object.
|
@@ -392,17 +409,17 @@ declare module "vm" {
|
|
392
409
|
sourceMapURL?: string | undefined;
|
393
410
|
}
|
394
411
|
/**
|
395
|
-
* If given
|
412
|
+
* If the given `contextObject` is an object, the `vm.createContext()` method will
|
396
413
|
* [prepare that object](https://nodejs.org/docs/latest-v20.x/api/vm.html#what-does-it-mean-to-contextify-an-object)
|
397
|
-
* and return a reference to it so that it can be used in
|
398
|
-
* [`script.runInContext()`](https://nodejs.org/docs/latest-v20.x/api/vm.html#scriptrunincontextcontextifiedobject-options).
|
399
|
-
* scripts, the
|
400
|
-
* existing properties but also having the built-in objects and functions any
|
401
|
-
*
|
414
|
+
* and return a reference to it so that it can be used in calls to {@link runInContext} or
|
415
|
+
* [`script.runInContext()`](https://nodejs.org/docs/latest-v20.x/api/vm.html#scriptrunincontextcontextifiedobject-options).
|
416
|
+
* Inside such scripts, the global object will be wrapped by the `contextObject`, retaining all of its
|
417
|
+
* existing properties but also having the built-in objects and functions any standard
|
418
|
+
* [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global
|
402
419
|
* variables will remain unchanged.
|
403
420
|
*
|
404
421
|
* ```js
|
405
|
-
*
|
422
|
+
* const vm = require('node:vm');
|
406
423
|
*
|
407
424
|
* global.globalVar = 3;
|
408
425
|
*
|
@@ -419,7 +436,12 @@ declare module "vm" {
|
|
419
436
|
* ```
|
420
437
|
*
|
421
438
|
* If `contextObject` is omitted (or passed explicitly as `undefined`), a new,
|
422
|
-
* empty
|
439
|
+
* empty contextified object will be returned.
|
440
|
+
*
|
441
|
+
* When the global object in the newly created context is contextified, it has some quirks
|
442
|
+
* compared to ordinary global objects. For example, it cannot be frozen. To create a context
|
443
|
+
* without the contextifying quirks, pass `vm.constants.DONT_CONTEXTIFY` as the `contextObject`
|
444
|
+
* argument. See the documentation of `vm.constants.DONT_CONTEXTIFY` for details.
|
423
445
|
*
|
424
446
|
* The `vm.createContext()` method is primarily useful for creating a single
|
425
447
|
* context that can be used to run multiple scripts. For instance, if emulating a
|
@@ -430,11 +452,17 @@ declare module "vm" {
|
|
430
452
|
* The provided `name` and `origin` of the context are made visible through the
|
431
453
|
* Inspector API.
|
432
454
|
* @since v0.3.1
|
455
|
+
* @param contextObject Either `vm.constants.DONT_CONTEXTIFY` or an object that will be contextified.
|
456
|
+
* If `undefined`, an empty contextified object will be created for backwards compatibility.
|
433
457
|
* @return contextified object.
|
434
458
|
*/
|
435
|
-
function createContext(
|
459
|
+
function createContext(
|
460
|
+
contextObject?: Context | typeof constants.DONT_CONTEXTIFY,
|
461
|
+
options?: CreateContextOptions,
|
462
|
+
): Context;
|
436
463
|
/**
|
437
|
-
* Returns `true` if the given `object` object has been
|
464
|
+
* Returns `true` if the given `object` object has been contextified using {@link createContext},
|
465
|
+
* or if it's the global object of a context created using `vm.constants.DONT_CONTEXTIFY`.
|
438
466
|
* @since v0.11.7
|
439
467
|
*/
|
440
468
|
function isContext(sandbox: Context): boolean;
|
@@ -467,18 +495,26 @@ declare module "vm" {
|
|
467
495
|
*/
|
468
496
|
function runInContext(code: string, contextifiedObject: Context, options?: RunningCodeOptions | string): any;
|
469
497
|
/**
|
470
|
-
*
|
471
|
-
*
|
472
|
-
* runs it within the created context, then returns the result. Running code
|
473
|
-
* does not have access to the local scope.
|
474
|
-
*
|
498
|
+
* This method is a shortcut to
|
499
|
+
* `(new vm.Script(code, options)).runInContext(vm.createContext(options), options)`.
|
475
500
|
* If `options` is a string, then it specifies the filename.
|
476
501
|
*
|
502
|
+
* It does several things at once:
|
503
|
+
*
|
504
|
+
* 1. Creates a new context.
|
505
|
+
* 2. If `contextObject` is an object, contextifies it with the new context.
|
506
|
+
* If `contextObject` is undefined, creates a new object and contextifies it.
|
507
|
+
* If `contextObject` is `vm.constants.DONT_CONTEXTIFY`, don't contextify anything.
|
508
|
+
* 3. Compiles the code as a`vm.Script`
|
509
|
+
* 4. Runs the compield code within the created context. The code does not have access to the scope in
|
510
|
+
* which this method is called.
|
511
|
+
* 5. Returns the result.
|
512
|
+
*
|
477
513
|
* The following example compiles and executes code that increments a global
|
478
514
|
* variable and sets a new one. These globals are contained in the `contextObject`.
|
479
515
|
*
|
480
516
|
* ```js
|
481
|
-
*
|
517
|
+
* const vm = require('node:vm');
|
482
518
|
*
|
483
519
|
* const contextObject = {
|
484
520
|
* animal: 'cat',
|
@@ -488,15 +524,21 @@ declare module "vm" {
|
|
488
524
|
* vm.runInNewContext('count += 1; name = "kitty"', contextObject);
|
489
525
|
* console.log(contextObject);
|
490
526
|
* // Prints: { animal: 'cat', count: 3, name: 'kitty' }
|
527
|
+
*
|
528
|
+
* // This would throw if the context is created from a contextified object.
|
529
|
+
* // vm.constants.DONT_CONTEXTIFY allows creating contexts with ordinary global objects that
|
530
|
+
* // can be frozen.
|
531
|
+
* const frozenContext = vm.runInNewContext('Object.freeze(globalThis); globalThis;', vm.constants.DONT_CONTEXTIFY);
|
491
532
|
* ```
|
492
533
|
* @since v0.3.1
|
493
534
|
* @param code The JavaScript code to compile and run.
|
494
|
-
* @param contextObject
|
535
|
+
* @param contextObject Either `vm.constants.DONT_CONTEXTIFY` or an object that will be contextified.
|
536
|
+
* If `undefined`, an empty contextified object will be created for backwards compatibility.
|
495
537
|
* @return the result of the very last statement executed in the script.
|
496
538
|
*/
|
497
539
|
function runInNewContext(
|
498
540
|
code: string,
|
499
|
-
contextObject?: Context,
|
541
|
+
contextObject?: Context | typeof constants.DONT_CONTEXTIFY,
|
500
542
|
options?: RunningCodeInNewContextOptions | string,
|
501
543
|
): any;
|
502
544
|
/**
|
@@ -968,6 +1010,19 @@ declare module "vm" {
|
|
968
1010
|
* @since v20.12.0
|
969
1011
|
*/
|
970
1012
|
const USE_MAIN_CONTEXT_DEFAULT_LOADER: number;
|
1013
|
+
/**
|
1014
|
+
* This constant, when used as the `contextObject` argument in vm APIs, instructs Node.js to create
|
1015
|
+
* a context without wrapping its global object with another object in a Node.js-specific manner.
|
1016
|
+
* As a result, the `globalThis` value inside the new context would behave more closely to an ordinary
|
1017
|
+
* one.
|
1018
|
+
*
|
1019
|
+
* When `vm.constants.DONT_CONTEXTIFY` is used as the `contextObject` argument to {@link createContext},
|
1020
|
+
* the returned object is a proxy-like object to the global object in the newly created context with
|
1021
|
+
* fewer Node.js-specific quirks. It is reference equal to the `globalThis` value in the new context,
|
1022
|
+
* can be modified from outside the context, and can be used to access built-ins in the new context directly.
|
1023
|
+
* @since v20.18.0
|
1024
|
+
*/
|
1025
|
+
const DONT_CONTEXTIFY: number;
|
971
1026
|
}
|
972
1027
|
}
|
973
1028
|
declare module "node:vm" {
|
@@ -417,6 +417,24 @@ declare module "worker_threads" {
|
|
417
417
|
* @since v10.5.0
|
418
418
|
*/
|
419
419
|
postMessage(value: any, transferList?: readonly Transferable[]): void;
|
420
|
+
/**
|
421
|
+
* Sends a value to another worker, identified by its thread ID.
|
422
|
+
* @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
|
423
|
+
* If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
|
424
|
+
* @param value The value to send.
|
425
|
+
* @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
|
426
|
+
* or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
|
427
|
+
* @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
|
428
|
+
* If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
|
429
|
+
* @since v20.19.0
|
430
|
+
*/
|
431
|
+
postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
|
432
|
+
postMessageToThread(
|
433
|
+
threadId: number,
|
434
|
+
value: any,
|
435
|
+
transferList: readonly Transferable[],
|
436
|
+
timeout?: number,
|
437
|
+
): Promise<void>;
|
420
438
|
/**
|
421
439
|
* Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker does _not_ let the program exit if it's the only active handle left (the default
|
422
440
|
* behavior). If the worker is `ref()`ed, calling `ref()` again has
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|