@@ -53,13 +53,22 @@ class Session extends EventEmitter {
53
53
this [ messageCallbacksSymbol ] = new SafeMap ( ) ;
54
54
}
55
55
56
+ /**
57
+ * Connects the session to the inspector back-end.
58
+ * @returns {void }
59
+ */
56
60
connect ( ) {
57
61
if ( this [ connectionSymbol ] )
58
62
throw new ERR_INSPECTOR_ALREADY_CONNECTED ( 'The inspector session' ) ;
59
63
this [ connectionSymbol ] =
60
64
new Connection ( ( message ) => this [ onMessageSymbol ] ( message ) ) ;
61
65
}
62
66
67
+ /**
68
+ * Connects the session to the main thread
69
+ * inspector back-end.
70
+ * @returns {void }
71
+ */
63
72
connectToMainThread ( ) {
64
73
if ( isMainThread )
65
74
throw new ERR_INSPECTOR_NOT_WORKER ( ) ;
@@ -93,6 +102,13 @@ class Session extends EventEmitter {
93
102
}
94
103
}
95
104
105
+ /**
106
+ * Posts a message to the inspector back-end.
107
+ * @param {string } method
108
+ * @param {Record<unknown, unknown> } [params]
109
+ * @param {Function } [callback]
110
+ * @returns {void }
111
+ */
96
112
post ( method , params , callback ) {
97
113
validateString ( method , 'method' ) ;
98
114
if ( ! callback && typeof params === 'function' ) {
@@ -120,6 +136,12 @@ class Session extends EventEmitter {
120
136
this [ connectionSymbol ] . dispatch ( JSONStringify ( message ) ) ;
121
137
}
122
138
139
+ /**
140
+ * Immediately closes the session, all pending
141
+ * message callbacks will be called with an
142
+ * error.
143
+ * @returns {void }
144
+ */
123
145
disconnect ( ) {
124
146
if ( ! this [ connectionSymbol ] )
125
147
return ;
@@ -134,6 +156,13 @@ class Session extends EventEmitter {
134
156
}
135
157
}
136
158
159
+ /**
160
+ * Activates inspector on host and port.
161
+ * @param {number } [port]
162
+ * @param {string } [host]
163
+ * @param {boolean } [wait]
164
+ * @returns {void }
165
+ */
137
166
function inspectorOpen ( port , host , wait ) {
138
167
if ( isEnabled ( ) ) {
139
168
throw new ERR_INSPECTOR_ALREADY_ACTIVATED ( ) ;
@@ -143,6 +172,12 @@ function inspectorOpen(port, host, wait) {
143
172
waitForDebugger ( ) ;
144
173
}
145
174
175
+ /**
176
+ * Blocks until a client (existing or connected later)
177
+ * has sent the `Runtime.runIfWaitingForDebugger`
178
+ * command.
179
+ * @returns {void }
180
+ */
146
181
function inspectorWaitForDebugger ( ) {
147
182
if ( ! waitForDebugger ( ) )
148
183
throw new ERR_INSPECTOR_NOT_ACTIVE ( ) ;
@@ -151,7 +186,7 @@ function inspectorWaitForDebugger() {
151
186
module . exports = {
152
187
open : inspectorOpen ,
153
188
close : process . _debugEnd ,
154
- url : url ,
189
+ url,
155
190
waitForDebugger : inspectorWaitForDebugger ,
156
191
// This is dynamically added during bootstrap,
157
192
// where the console from the VM is still available
0 commit comments