Skip to content

Commit f0c73db

Browse files
Audit js.node inspector externs for Node 24 + Haxe 4. (#258)
Refresh copyrights to 2014-2026, add missing inspector console methods, and modernize Session callback/event typing and docs. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent cd2d335 commit f0c73db

8 files changed

Lines changed: 77 additions & 35 deletions

File tree

src/js/node/Inspector.hx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C)2014-2020 Haxe Foundation
2+
* Copyright (C)2014-2026 Haxe Foundation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -25,7 +25,9 @@ package js.node;
2525
import js.node.inspector.InspectorConsole;
2626

2727
/**
28-
The `inspector` module provides an API for interacting with the V8 inspector.
28+
The `node:inspector` module provides an API for interacting with the V8 inspector.
29+
30+
Stability: 2 - Stable.
2931
3032
Related types live under `js.node.inspector` (`Session`, `Network`, `NetworkResources`, `DomStorage`).
3133
Use those types directly (e.g. `js.node.inspector.Network.requestWillBeSent(...)`) — they map to
@@ -42,9 +44,12 @@ extern class Inspector {
4244
If `wait` is `true`, will block until a client has connected to the inspect port
4345
and flow control has been passed to the debugger client.
4446
45-
Returns a Disposable (`{ [Symbol.dispose](): void }`) that calls `inspector.close()`.
47+
See the Node.js security warning regarding the `host` parameter (binding the inspector
48+
to a public IP/port combination is insecure).
4649
47-
// TODO: model Web IDL `Disposable` / `Symbol.dispose` instead of `Dynamic`.
50+
Returns a Disposable (`{ [Symbol.dispose](): void }`) that calls `inspector.close()`.
51+
Typed as `Dynamic` because the returned object only exposes `Symbol.dispose` (no named
52+
`dispose()` method) and hxnodejs does not yet model Web IDL `Disposable`.
4853
**/
4954
static function open(?port:Int, ?host:String, ?wait:Bool):Dynamic;
5055

src/js/node/InspectorPromises.hx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C)2014-2020 Haxe Foundation
2+
* Copyright (C)2014-2026 Haxe Foundation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -23,16 +23,16 @@
2323
package js.node;
2424

2525
import js.node.inspector.InspectorConsole;
26-
import js.node.inspector.promises.Session;
2726

2827
/**
29-
Promise-based `inspector` API (`inspector/promises`).
28+
Promise-based `node:inspector` API (`inspector/promises`).
3029
3130
Stability: 1 - Experimental.
3231
3332
Module-level helpers match `Inspector`; use `js.node.inspector.promises.Session`
34-
for a `Session` whose `post` returns a `Promise`. DevTools helpers live under
35-
`js.node.inspector` (`Network`, `NetworkResources`, `DomStorage`).
33+
for a `Session` whose `post` returns a `Promise`. DevTools helpers
34+
(`Network`, `NetworkResources`, `DOMStorage`) are also exported from this module
35+
in Node.js; prefer the typed externs under `js.node.inspector`.
3636
3737
@see https://nodejs.org/docs/latest-v24.x/api/inspector.html#promises-api
3838
**/
@@ -41,14 +41,18 @@ extern class InspectorPromises {
4141
/**
4242
Activate inspector on host and port.
4343
44-
Returns a Disposable (`{ [Symbol.dispose](): void }`) that calls `close()`.
44+
See the Node.js security warning regarding the `host` parameter (binding the inspector
45+
to a public IP/port combination is insecure).
4546
46-
// TODO: model Web IDL `Disposable` / `Symbol.dispose` instead of `Dynamic`.
47+
Returns a Disposable (`{ [Symbol.dispose](): void }`) that calls `close()`.
48+
Typed as `Dynamic` because the returned object only exposes `Symbol.dispose` (no named
49+
`dispose()` method) and hxnodejs does not yet model Web IDL `Disposable`.
4750
**/
4851
static function open(?port:Int, ?host:String, ?wait:Bool):Dynamic;
4952

5053
/**
5154
Attempts to close all remaining connections, blocking the event loop until all are closed.
55+
Once all connections are closed, deactivates the inspector.
5256
**/
5357
static function close():Void;
5458

@@ -58,12 +62,17 @@ extern class InspectorPromises {
5862
static function url():Null<String>;
5963

6064
/**
61-
Blocks until a client has sent `Runtime.runIfWaitingForDebugger`.
65+
Blocks until a client (existing or connected later) has sent
66+
`Runtime.runIfWaitingForDebugger` command.
67+
68+
An exception will be thrown if there is no active inspector.
6269
**/
6370
static function waitForDebugger():Void;
6471

6572
/**
6673
An object to send messages to the remote inspector console.
74+
75+
The inspector console does not have API parity with Node.js console.
6776
**/
6877
static var console(default, null):InspectorConsole;
6978
}

src/js/node/inspector/DomStorage.hx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C)2014-2020 Haxe Foundation
2+
* Copyright (C)2014-2026 Haxe Foundation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -25,12 +25,14 @@ package js.node.inspector;
2525
/**
2626
Helpers that broadcast Chrome DevTools Protocol `DOMStorage` events to connected frontends.
2727
28+
Stability: 1.1 - Active development.
29+
2830
Added in: v24.16.0 (Active LTS). Not available on Maintenance LTS 22.x.
2931
Only available with the `--experimental-storage-inspection` flag enabled.
3032
3133
Haxe type is `DomStorage` (acronyms are not uppercased); the Node.js export name is `DOMStorage`.
3234
33-
@see https://nodejs.org/api/inspector.html#inspectordomstoragedomstorageitemadded
35+
@see https://nodejs.org/docs/latest-v24.x/api/inspector.html#inspectordomstoragedomstorageitemadded
3436
**/
3537
@:jsRequire("inspector", "DOMStorage")
3638
extern class DomStorage {

src/js/node/inspector/InspectorConsole.hx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C)2014-2020 Haxe Foundation
2+
* Copyright (C)2014-2026 Haxe Foundation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -27,9 +27,10 @@ import haxe.extern.Rest;
2727
/**
2828
Object used to send messages to the remote inspector console.
2929
30-
The inspector console does not have API parity with Node.js console.
30+
Exposed by the V8 inspector console API; method signatures deliberately differ
31+
from (and are more permissive than) the Node.js `console` API.
3132
32-
@see https://nodejs.org/api/inspector.html#inspectorconsole
33+
@see https://nodejs.org/docs/latest-v24.x/api/inspector.html#inspectorconsole
3334
**/
3435
extern class InspectorConsole {
3536
function debug(data:Rest<Dynamic>):Void;
@@ -51,6 +52,12 @@ extern class InspectorConsole {
5152
function profile(?label:Dynamic):Void;
5253
function profileEnd(?label:Dynamic):Void;
5354
function time(?label:Dynamic):Void;
55+
function timeEnd(?label:Dynamic):Void;
5456
function timeLog(?label:Dynamic):Void;
5557
function timeStamp(?label:Dynamic):Void;
58+
59+
/**
60+
Creates a new inspector console context with the given name.
61+
**/
62+
function context(name:Dynamic):Void;
5663
}

src/js/node/inspector/Network.hx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C)2014-2020 Haxe Foundation
2+
* Copyright (C)2014-2026 Haxe Foundation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -27,11 +27,13 @@ import haxe.DynamicAccess;
2727
/**
2828
Broadcast helpers for Chrome DevTools Protocol `Network.*` events.
2929
30+
Stability: 1.1 - Active development.
31+
3032
These APIs require the `--experimental-network-inspection` flag.
3133
3234
Usage: `Network.requestWillBeSent({ ... })` (maps to `inspector.Network` in Node.js).
3335
34-
@see https://nodejs.org/api/inspector.html#integration-with-devtools
36+
@see https://nodejs.org/docs/latest-v24.x/api/inspector.html#integration-with-devtools
3537
**/
3638
@:jsRequire("inspector", "Network")
3739
extern class Network {
@@ -40,11 +42,15 @@ extern class Network {
4042
`Network.streamResourceContent` command was not invoked for the given request yet.
4143
4244
Also enables `Network.getResponseBody` command to retrieve the response data.
45+
46+
Added in: v24.2.0.
4347
**/
4448
static function dataReceived(?params:NetworkDataReceivedParams):Void;
4549

4650
/**
4751
Enables `Network.getRequestPostData` command to retrieve the request data.
52+
53+
Added in: v24.3.0.
4854
**/
4955
static function dataSent(?params:NetworkDataSentParams):Void;
5056

@@ -123,14 +129,14 @@ typedef NetworkResponse = {
123129
/**
124130
Pragmatic subset of CDP request initiator.
125131
126-
// TODO: model CDP `StackTrace` for `stack` instead of `Dynamic`.
132+
`stack` remains `Any` pending a CDP `StackTrace` model in hxnodejs.
127133
**/
128134
typedef NetworkInitiator = {
129135
var type:String;
130136
@:optional var url:String;
131137
@:optional var lineNumber:Float;
132138
@:optional var columnNumber:Float;
133-
@:optional var stack:Dynamic;
139+
@:optional var stack:Any;
134140
}
135141

136142
/**

src/js/node/inspector/NetworkResources.hx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C)2014-2020 Haxe Foundation
2+
* Copyright (C)2014-2026 Haxe Foundation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -26,11 +26,15 @@ package js.node.inspector;
2626
Provides responses for `Network.loadNetworkResource` CDP requests
2727
(e.g. source maps requested by a DevTools frontend).
2828
29+
Stability: 1.1 - Active development.
30+
2931
Requires the `--experimental-inspector-network-resource` flag.
3032
3133
Usage: `NetworkResources.put(url, data)` (maps to `inspector.NetworkResources` in Node.js).
3234
33-
@see https://nodejs.org/api/inspector.html#inspectornetworkresourcesput
35+
Added in: v24.5.0.
36+
37+
@see https://nodejs.org/docs/latest-v24.x/api/inspector.html#inspectornetworkresourcesput
3438
**/
3539
@:jsRequire("inspector", "NetworkResources")
3640
extern class NetworkResources {

src/js/node/inspector/Session.hx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C)2014-2020 Haxe Foundation
2+
* Copyright (C)2014-2026 Haxe Foundation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -22,8 +22,8 @@
2222

2323
package js.node.inspector;
2424

25-
import js.node.events.EventEmitter;
2625
import js.lib.Error;
26+
import js.node.events.EventEmitter;
2727

2828
/**
2929
Enumeration of events emitted by `inspector.Session`.
@@ -35,22 +35,22 @@ enum abstract SessionEvent<T:haxe.Constraints.Function>(Event<T>) to Event<T> {
3535
/**
3636
Emitted when any notification from the V8 Inspector is received.
3737
**/
38-
var InspectorNotification:SessionEvent<InspectorNotificationMessage->Void> = "inspectorNotification";
38+
var InspectorNotification:SessionEvent<(message:InspectorNotificationMessage) -> Void> = "inspectorNotification";
3939

4040
/**
4141
Emitted when an inspector notification is received with method `Debugger.paused`.
4242
**/
43-
var DebuggerPaused:SessionEvent<InspectorNotificationMessage->Void> = "Debugger.paused";
43+
var DebuggerPaused:SessionEvent<(message:InspectorNotificationMessage) -> Void> = "Debugger.paused";
4444

4545
/**
4646
Emitted when an inspector notification is received with method `Debugger.resumed`.
4747
**/
48-
var DebuggerResumed:SessionEvent<InspectorNotificationMessage->Void> = "Debugger.resumed";
48+
var DebuggerResumed:SessionEvent<(message:InspectorNotificationMessage) -> Void> = "Debugger.resumed";
4949

5050
/**
5151
Emitted when an inspector notification is received with method `HeapProfiler.addHeapSnapshotChunk`.
5252
**/
53-
var HeapProfilerAddHeapSnapshotChunk:SessionEvent<InspectorNotificationMessage->Void> = "HeapProfiler.addHeapSnapshotChunk";
53+
var HeapProfilerAddHeapSnapshotChunk:SessionEvent<(message:InspectorNotificationMessage) -> Void> = "HeapProfiler.addHeapSnapshotChunk";
5454
}
5555

5656
/**
@@ -67,7 +67,10 @@ typedef InspectorNotificationMessage = {
6767
The `inspector.Session` is used for dispatching messages to the V8 inspector
6868
back-end and receiving message responses and notifications.
6969
70-
@see https://nodejs.org/api/inspector.html#class-inspectorsession
70+
When using `Session`, objects outputted by the console API will not be released
71+
unless `Runtime.DiscardConsoleEntries` is posted manually.
72+
73+
@see https://nodejs.org/docs/latest-v24.x/api/inspector.html#class-inspectorsession
7174
**/
7275
@:jsRequire("inspector", "Session")
7376
extern class Session extends EventEmitter<Session> {
@@ -105,6 +108,6 @@ extern class Session extends EventEmitter<Session> {
105108
Protocol method names and parameter/result shapes follow the Chrome DevTools Protocol;
106109
they are typed as `String` / `Dynamic` rather than enumerating the full CDP schema.
107110
**/
108-
@:overload(function(method:String, ?callback:Null<Error>->Dynamic->Void):Void {})
109-
function post(method:String, ?params:Dynamic, ?callback:Null<Error>->Dynamic->Void):Void;
111+
@:overload(function(method:String, ?callback:(error:Null<Error>, result:Dynamic) -> Void):Void {})
112+
function post(method:String, ?params:Dynamic, ?callback:(error:Null<Error>, result:Dynamic) -> Void):Void;
110113
}

src/js/node/inspector/promises/Session.hx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C)2014-2020 Haxe Foundation
2+
* Copyright (C)2014-2026 Haxe Foundation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -22,8 +22,8 @@
2222

2323
package js.node.inspector.promises;
2424

25-
import js.node.events.EventEmitter;
2625
import js.lib.Promise;
26+
import js.node.events.EventEmitter;
2727

2828
/**
2929
Promise-based `inspector.Session` from `inspector/promises`.
@@ -33,7 +33,10 @@ import js.lib.Promise;
3333
Emits the same notification events as callback `inspector.Session`;
3434
use `js.node.inspector.SessionEvent` with `on` / `once` / `off`.
3535
36-
@see https://nodejs.org/api/inspector.html#promises-api
36+
When using `Session`, objects outputted by the console API will not be released
37+
unless `Runtime.DiscardConsoleEntries` is posted manually.
38+
39+
@see https://nodejs.org/docs/latest-v24.x/api/inspector.html#promises-api
3740
**/
3841
@:jsRequire("inspector/promises", "Session")
3942
extern class Session extends EventEmitter<Session> {
@@ -65,6 +68,9 @@ extern class Session extends EventEmitter<Session> {
6568
/**
6669
Posts a message to the inspector back-end and returns a Promise that resolves
6770
with the message-specific result object.
71+
72+
Protocol method names and parameter/result shapes follow the Chrome DevTools Protocol;
73+
they are typed as `String` / `Dynamic` rather than enumerating the full CDP schema.
6874
**/
6975
function post(method:String, ?params:Dynamic):Promise<Dynamic>;
7076
}

0 commit comments

Comments
 (0)