mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
typings: add JSDoc typings for inspector
Added JSDoc typings for the `inspector` lib module. PR-URL: https://github.com/nodejs/node/pull/38390 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Adrian Estrada <edsadr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
b5aa08d2f9
commit
8768012370
1 changed files with 36 additions and 1 deletions
|
@ -53,6 +53,10 @@ class Session extends EventEmitter {
|
|||
this[messageCallbacksSymbol] = new SafeMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects the session to the inspector back-end.
|
||||
* @returns {void}
|
||||
*/
|
||||
connect() {
|
||||
if (this[connectionSymbol])
|
||||
throw new ERR_INSPECTOR_ALREADY_CONNECTED('The inspector session');
|
||||
|
@ -60,6 +64,11 @@ class Session extends EventEmitter {
|
|||
new Connection((message) => this[onMessageSymbol](message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects the session to the main thread
|
||||
* inspector back-end.
|
||||
* @returns {void}
|
||||
*/
|
||||
connectToMainThread() {
|
||||
if (isMainThread)
|
||||
throw new ERR_INSPECTOR_NOT_WORKER();
|
||||
|
@ -93,6 +102,13 @@ class Session extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts a message to the inspector back-end.
|
||||
* @param {string} method
|
||||
* @param {Record<unknown, unknown>} [params]
|
||||
* @param {Function} [callback]
|
||||
* @returns {void}
|
||||
*/
|
||||
post(method, params, callback) {
|
||||
validateString(method, 'method');
|
||||
if (!callback && typeof params === 'function') {
|
||||
|
@ -120,6 +136,12 @@ class Session extends EventEmitter {
|
|||
this[connectionSymbol].dispatch(JSONStringify(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately closes the session, all pending
|
||||
* message callbacks will be called with an
|
||||
* error.
|
||||
* @returns {void}
|
||||
*/
|
||||
disconnect() {
|
||||
if (!this[connectionSymbol])
|
||||
return;
|
||||
|
@ -134,6 +156,13 @@ class Session extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates inspector on host and port.
|
||||
* @param {number} [port]
|
||||
* @param {string} [host]
|
||||
* @param {boolean} [wait]
|
||||
* @returns {void}
|
||||
*/
|
||||
function inspectorOpen(port, host, wait) {
|
||||
if (isEnabled()) {
|
||||
throw new ERR_INSPECTOR_ALREADY_ACTIVATED();
|
||||
|
@ -143,6 +172,12 @@ function inspectorOpen(port, host, wait) {
|
|||
waitForDebugger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks until a client (existing or connected later)
|
||||
* has sent the `Runtime.runIfWaitingForDebugger`
|
||||
* command.
|
||||
* @returns {void}
|
||||
*/
|
||||
function inspectorWaitForDebugger() {
|
||||
if (!waitForDebugger())
|
||||
throw new ERR_INSPECTOR_NOT_ACTIVE();
|
||||
|
@ -151,7 +186,7 @@ function inspectorWaitForDebugger() {
|
|||
module.exports = {
|
||||
open: inspectorOpen,
|
||||
close: process._debugEnd,
|
||||
url: url,
|
||||
url,
|
||||
waitForDebugger: inspectorWaitForDebugger,
|
||||
// This is dynamically added during bootstrap,
|
||||
// where the console from the VM is still available
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue