@lynx-js/devtool-connector 0.16.6 → 0.17.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.
- package/CHANGELOG.md +11 -0
- package/README.md +23 -25
- package/dist/2.js +1 -1
- package/dist/3.js +9 -0
- package/dist/a.js +3 -1
- package/dist/f.js +36 -14
- package/dist/f1.js +4 -0
- package/dist/hb.js +2 -9
- package/dist/index.js +2 -1
- package/dist/streams/index.js +2 -1
- package/dist/t.js +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @lynx-js/devtool-connector
|
|
2
2
|
|
|
3
|
+
## 0.17.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Close aborted unary command responses during daemon shutdown so callers do not wait for their own timeout.
|
|
8
|
+
- Updated dependency `dprint` to `^0.64.3`.
|
|
9
|
+
- Updated dependency `@rslib/core` to `^1.0.4`.
|
|
10
|
+
- Scope HDT transport responses to the selected app for both direct and daemon connections, so another app's session list cannot close its streams or supply its CDP responses.
|
|
11
|
+
- Preserve the request timeout when its transport closes without a response instead of reporting a generic missing response.
|
|
12
|
+
- Wait for the runtime to confirm the screenshot frame acknowledgement before closing its connection, so the next capture is not blocked by an unprocessed acknowledgement.
|
|
13
|
+
|
|
3
14
|
## 0.16.6
|
|
4
15
|
|
|
5
16
|
No changes in this release.
|
package/README.md
CHANGED
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
# Lynx DevTool Connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Discover Lynx apps and send debugging requests from Node.js. Requires Node.js 18.19 or later and a reachable Lynx app with DevTool enabled.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lynx-js/devtool-connector
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
4
12
|
|
|
5
13
|
```ts
|
|
6
14
|
import { Connector } from "@lynx-js/devtool-connector";
|
|
7
|
-
import { HttpCommandClient } from "@lynx-js/devtool-connector/command";
|
|
8
15
|
import { DaemonTransport } from "@lynx-js/devtool-connector/transport";
|
|
9
16
|
|
|
10
17
|
const connector = new Connector([new DaemonTransport()]);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const [client] = await connector.listClients();
|
|
19
|
+
if (!client) throw new Error("No Lynx app found");
|
|
20
|
+
const [session] = await connector.sendListSessionMessage(client.id);
|
|
21
|
+
if (!session) throw new Error("No Lynx page found");
|
|
22
|
+
console.log(
|
|
23
|
+
await connector.sendCDPMessage(
|
|
24
|
+
client.id,
|
|
25
|
+
session.session_id,
|
|
26
|
+
"DOM.getDocument",
|
|
27
|
+
{ depth: 1 },
|
|
28
|
+
),
|
|
29
|
+
);
|
|
18
30
|
```
|
|
19
31
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## Product adapters
|
|
23
|
-
|
|
24
|
-
The public exports include `DaemonLifecycle`, `DevtoolDaemon`, `StaticServer`, `InspectorAssetProvider` and `DebugMetadataLoader`. A product may subclass the lifecycle to resolve its own entry and environment, bind its own daemon identity/command core/assets, and override the command client's and daemon transport's protected lifecycle method. HDT uses the shared implementation directly; it needs no discovery policy injection.
|
|
25
|
-
|
|
26
|
-
`ActionCore` accepts a metadata loader; source-info acquisition, caching and remapping remain shared. Android adapters may override `getKnownApp` for product-specific labels and activity names. Private integrations are not required to install or run this package.
|
|
27
|
-
|
|
28
|
-
The GET/OPTIONS version endpoint allows arbitrary origins (`*`) for discovery. Command, shutdown and WebSocket control remain restricted to same-origin loopback requests. The public Inspector uses the public Lynx DevTool frontend; it does not advertise the internal browser Preview protocol.
|
|
29
|
-
|
|
30
|
-
## Migration from 0.13.2
|
|
31
|
-
|
|
32
|
-
The implementation now includes the 0.16.2 command, ReactLynx, lifecycle and HDT capabilities. Existing source export paths remain available. `DaemonManager` is now the default `DaemonLifecycle` instance (its `ensureRunning`/`kill` call shape is unchanged). Product adapters should extend `DaemonLifecycle`, not duplicate the manager. Daemon metadata's `product` is a string and `browserPreviewProtocol` is optional because it describes actual product capability.
|
|
33
|
-
|
|
34
|
-
## Development
|
|
32
|
+
Select the intended app and page when several are connected. The default daemon shares persistent device connections across callers.
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
Contributor constraints and source entry points live in [AGENTS.md](https://github.com/lynx-community/skills/blob/main/packages/mcp-servers/devtool-connector/src/AGENTS.md).
|
package/dist/2.js
CHANGED
|
@@ -1659,7 +1659,7 @@ const DAEMON_SHUTDOWN_PATH = `${DAEMON_WS_PATH}/shutdown`;
|
|
|
1659
1659
|
const DAEMON_INSPECTOR_PATH = `${DAEMON_WS_PATH}/inspector`;
|
|
1660
1660
|
const DAEMON_COMMAND_PATH_PREFIX = "/command/";
|
|
1661
1661
|
var package_namespaceObject = {
|
|
1662
|
-
rE: "0.
|
|
1662
|
+
rE: "0.17.0"
|
|
1663
1663
|
};
|
|
1664
1664
|
const CONNECTOR_VERSION = package_namespaceObject.rE;
|
|
1665
1665
|
const node_modules_semver = __webpack_require__("../../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/index.js");
|
package/dist/3.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { randomInt } from "node:crypto";
|
|
2
|
+
const maxRequestId = 0x7FFFFFFF;
|
|
3
|
+
let requestId = randomInt(1, maxRequestId + 1);
|
|
4
|
+
function nextRequestId() {
|
|
5
|
+
const id = requestId;
|
|
6
|
+
requestId = id === maxRequestId ? 1 : id + 1;
|
|
7
|
+
return id;
|
|
8
|
+
}
|
|
9
|
+
export { nextRequestId };
|
package/dist/a.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReadableStream } from "node:stream/web";
|
|
2
|
-
import { isGetGlobalSwitchResponse, isInitializeResponse, AppResponseTransformStream, GlobalSwitchRequestTransformStream, isListSessionResponse, isHeadlessPrepareResponse, createCorrelatedFilter, isSetGlobalSwitchResponse, CDPResponseTransformStream, CDPOutputTransformStream, CustomizedResponseTransformStream, CDPRequestTransformStream, CustomizedRequestTransformStream, SessionGuardTransformStream, FilterTransformStream, InspectStream, CustomizedClientIdTransformStream
|
|
2
|
+
import { isGetGlobalSwitchResponse, isInitializeResponse, AppResponseTransformStream, GlobalSwitchRequestTransformStream, isListSessionResponse, isHeadlessPrepareResponse, createCorrelatedFilter, isSetGlobalSwitchResponse, CDPResponseTransformStream, CDPOutputTransformStream, CustomizedResponseTransformStream, CDPRequestTransformStream, CustomizedRequestTransformStream, SessionGuardTransformStream, FilterTransformStream, InspectStream, CustomizedClientIdTransformStream } from "./hb.js";
|
|
3
3
|
import { ansi_createDebug, isDaemonLifecycleError } from "./2.js";
|
|
4
|
+
import { nextRequestId } from "./3.js";
|
|
4
5
|
import { DaemonTransport, HDTTransport, ClientId } from "./f1.js";
|
|
5
6
|
function throwClientDiscoveryFailures(failures) {
|
|
6
7
|
if (1 === failures.length) throw failures[0];
|
|
@@ -443,6 +444,7 @@ class Connector {
|
|
|
443
444
|
const response = await read;
|
|
444
445
|
await outputStream.inputClosed;
|
|
445
446
|
if (response.done) {
|
|
447
|
+
options.signal?.throwIfAborted();
|
|
446
448
|
const clientId = ClientId.serialize(options.deviceId, options.port);
|
|
447
449
|
throw new Error(`No response found for clientId: ${clientId}`);
|
|
448
450
|
} else result = response.value;
|
package/dist/f.js
CHANGED
|
@@ -3,6 +3,7 @@ import { ReadableStream } from "node:stream/web";
|
|
|
3
3
|
import { remapUiTree } from "@lynx-js/debug-metadata";
|
|
4
4
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
5
5
|
import { ansi_createDebug } from "./2.js";
|
|
6
|
+
import { nextRequestId } from "./3.js";
|
|
6
7
|
__webpack_require__.add({
|
|
7
8
|
"../../../node_modules/.pnpm/jpeg-js@0.4.4/node_modules/jpeg-js/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
8
9
|
var encode = __webpack_require__("../../../node_modules/.pnpm/jpeg-js@0.4.4/node_modules/jpeg-js/lib/encoder.js"), decode = __webpack_require__("../../../node_modules/.pnpm/jpeg-js@0.4.4/node_modules/jpeg-js/lib/decoder.js");
|
|
@@ -4419,7 +4420,7 @@ function combineSignals(signals) {
|
|
|
4419
4420
|
}
|
|
4420
4421
|
class ScreenshotTimeoutError extends Error {
|
|
4421
4422
|
constructor(timeoutMs, phase = "frame"){
|
|
4422
|
-
super("frame" === phase ? `Failed to capture screenshot, no Page.screencastFrame event received within ${timeoutMs / 1000} seconds.` : `Failed to capture screenshot, the Page.screencastFrame acknowledgement was not
|
|
4423
|
+
super("frame" === phase ? `Failed to capture screenshot, no Page.screencastFrame event received within ${timeoutMs / 1000} seconds.` : `Failed to capture screenshot, the Page.screencastFrame acknowledgement was not confirmed within ${timeoutMs / 1000} seconds.`);
|
|
4423
4424
|
this.name = "ScreenshotTimeoutError";
|
|
4424
4425
|
}
|
|
4425
4426
|
}
|
|
@@ -4438,6 +4439,8 @@ async function captureScreenshotFrame(connector, clientId, sessionId, options =
|
|
|
4438
4439
|
timeout.unref();
|
|
4439
4440
|
let frame = deferred();
|
|
4440
4441
|
let ack = deferred();
|
|
4442
|
+
const acknowledgements = new Map();
|
|
4443
|
+
let usableFrameReceived = false;
|
|
4441
4444
|
let result;
|
|
4442
4445
|
let screencastStarted = false;
|
|
4443
4446
|
let primaryFailed = false;
|
|
@@ -4473,38 +4476,57 @@ async function captureScreenshotFrame(connector, clientId, sessionId, options =
|
|
|
4473
4476
|
frame.promise,
|
|
4474
4477
|
aborted
|
|
4475
4478
|
]);
|
|
4479
|
+
const id = nextRequestId();
|
|
4476
4480
|
controller.enqueue({
|
|
4481
|
+
id,
|
|
4477
4482
|
method: "Page.screencastFrameAck"
|
|
4478
4483
|
});
|
|
4479
|
-
ack.resolve();
|
|
4484
|
+
ack.resolve(id);
|
|
4480
4485
|
if (usable) break;
|
|
4481
4486
|
frame = deferred();
|
|
4482
4487
|
ack = deferred();
|
|
4483
4488
|
}
|
|
4484
4489
|
} finally{
|
|
4485
4490
|
controller.close();
|
|
4486
|
-
ack.resolve();
|
|
4491
|
+
ack.resolve(void 0);
|
|
4487
4492
|
}
|
|
4488
4493
|
}
|
|
4489
4494
|
}), {
|
|
4490
4495
|
signal
|
|
4491
4496
|
}), true);
|
|
4492
4497
|
try {
|
|
4493
|
-
for await (const
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
await
|
|
4502
|
-
|
|
4498
|
+
for await (const message of stream){
|
|
4499
|
+
const { method, params } = message;
|
|
4500
|
+
if ("Page.screencastFrame" === method) {
|
|
4501
|
+
if (usableFrameReceived) continue;
|
|
4502
|
+
const { data, metadata } = params;
|
|
4503
|
+
const usable = "string" == typeof data && data.length > 0;
|
|
4504
|
+
if (usable) timeoutPhase = "acknowledgement";
|
|
4505
|
+
frame.resolve(usable);
|
|
4506
|
+
const acknowledgementId = await ack.promise;
|
|
4507
|
+
if (void 0 === acknowledgementId) continue;
|
|
4508
|
+
const captured = usable ? null !== metadata && "object" == typeof metadata ? {
|
|
4503
4509
|
data,
|
|
4504
4510
|
metadata: metadata
|
|
4505
4511
|
} : {
|
|
4506
4512
|
data
|
|
4507
|
-
};
|
|
4513
|
+
} : void 0;
|
|
4514
|
+
acknowledgements.set(acknowledgementId, captured);
|
|
4515
|
+
if (usable) {
|
|
4516
|
+
await stream.inputClosed;
|
|
4517
|
+
usableFrameReceived = true;
|
|
4518
|
+
}
|
|
4519
|
+
continue;
|
|
4520
|
+
}
|
|
4521
|
+
const response = message;
|
|
4522
|
+
if (void 0 === response.id || !acknowledgements.has(response.id)) continue;
|
|
4523
|
+
const captured = acknowledgements.get(response.id);
|
|
4524
|
+
acknowledgements.delete(response.id);
|
|
4525
|
+
if (response.error) throw new Error(`CDP request error: ${response.error.message ?? "Unknown error"}`, {
|
|
4526
|
+
cause: message
|
|
4527
|
+
});
|
|
4528
|
+
if (void 0 !== captured) {
|
|
4529
|
+
result = captured;
|
|
4508
4530
|
break;
|
|
4509
4531
|
}
|
|
4510
4532
|
}
|
package/dist/f1.js
CHANGED
|
@@ -380,6 +380,10 @@ class JSONStringToObjectStream extends TransformStream {
|
|
|
380
380
|
sender: debugRouterId
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
|
+
if (isRecord(obj) && "Customized" === obj["event"] && isRecord(obj["data"])) {
|
|
384
|
+
const sender = obj["data"]["sender"];
|
|
385
|
+
if (void 0 !== sender && "-1" !== String(sender) && "4294967295" !== String(sender) && String(sender) !== String(debugRouterId ?? targetPort)) return;
|
|
386
|
+
}
|
|
383
387
|
if (void 0 !== debugRouterId && isRecord(obj) && "RouteRejected" === obj["event"]) {
|
|
384
388
|
const data = isRecord(obj["data"]) ? obj["data"] : {};
|
|
385
389
|
const rejectedId = "string" == typeof data["debugRouterId"] ? data["debugRouterId"] : debugRouterId;
|
package/dist/hb.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { randomInt } from "node:crypto";
|
|
2
1
|
import { TransformStream } from "node:stream/web";
|
|
3
|
-
|
|
4
|
-
let request_id_requestId = randomInt(1, maxRequestId + 1);
|
|
5
|
-
function nextRequestId() {
|
|
6
|
-
const id = request_id_requestId;
|
|
7
|
-
request_id_requestId = id === maxRequestId ? 1 : id + 1;
|
|
8
|
-
return id;
|
|
9
|
-
}
|
|
2
|
+
import { nextRequestId } from "./3.js";
|
|
10
3
|
function isInitializeResponse(response) {
|
|
11
4
|
return "Register" === response.event;
|
|
12
5
|
}
|
|
@@ -210,4 +203,4 @@ class SessionGuardTransformStream extends TransformStream {
|
|
|
210
203
|
});
|
|
211
204
|
}
|
|
212
205
|
}
|
|
213
|
-
export { AppResponseTransformStream, CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream, CustomizedClientIdTransformStream, CustomizedRequestTransformStream, CustomizedResponseTransformStream, FilterTransformStream, GlobalSwitchRequestTransformStream, InspectStream, ResponseParserTransformStream, SessionGuardTransformStream, createCorrelatedFilter, isCustomizedResponseWithType, isGetGlobalSwitchResponse, isHeadlessPrepareResponse, isInitializeResponse, isListSessionResponse, isSetGlobalSwitchResponse
|
|
206
|
+
export { AppResponseTransformStream, CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream, CustomizedClientIdTransformStream, CustomizedRequestTransformStream, CustomizedResponseTransformStream, FilterTransformStream, GlobalSwitchRequestTransformStream, InspectStream, ResponseParserTransformStream, SessionGuardTransformStream, createCorrelatedFilter, isCustomizedResponseWithType, isGetGlobalSwitchResponse, isHeadlessPrepareResponse, isInitializeResponse, isListSessionResponse, isSetGlobalSwitchResponse };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream, createCorrelatedFilter, isCustomizedResponseWithType, isGetGlobalSwitchResponse, isHeadlessPrepareResponse, isInitializeResponse, isListSessionResponse, isSetGlobalSwitchResponse
|
|
1
|
+
export { CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream, createCorrelatedFilter, isCustomizedResponseWithType, isGetGlobalSwitchResponse, isHeadlessPrepareResponse, isInitializeResponse, isListSessionResponse, isSetGlobalSwitchResponse } from "./hb.js";
|
|
2
2
|
export { ClientId } from "./f1.js";
|
|
3
3
|
export { Connector } from "./a.js";
|
|
4
|
+
export { nextRequestId } from "./3.js";
|
package/dist/streams/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { AppResponseTransformStream, CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream, CustomizedClientIdTransformStream, CustomizedRequestTransformStream, CustomizedResponseTransformStream, FilterTransformStream, GlobalSwitchRequestTransformStream, InspectStream, ResponseParserTransformStream, SessionGuardTransformStream
|
|
1
|
+
export { AppResponseTransformStream, CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream, CustomizedClientIdTransformStream, CustomizedRequestTransformStream, CustomizedResponseTransformStream, FilterTransformStream, GlobalSwitchRequestTransformStream, InspectStream, ResponseParserTransformStream, SessionGuardTransformStream } from "../hb.js";
|
|
2
|
+
export { nextRequestId } from "../3.js";
|
package/dist/t.js
CHANGED
|
@@ -697,6 +697,7 @@ class DevtoolDaemon {
|
|
|
697
697
|
req.off("aborted", onDisconnect);
|
|
698
698
|
res.off("close", onDisconnect);
|
|
699
699
|
this.#commandControllers.delete(controller);
|
|
700
|
+
if (controller.signal.aborted && !res.destroyed && !res.writableEnded) res.destroy();
|
|
700
701
|
}
|
|
701
702
|
}
|
|
702
703
|
async #handleCommandStream(req, res) {
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/devtool-connector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lynx-community/skills.git",
|
|
7
7
|
"directory": "packages/mcp-servers/devtool-connector"
|
|
8
8
|
},
|
|
9
|
-
"
|
|
10
|
-
"CHANGELOG.md",
|
|
11
|
-
"dist",
|
|
12
|
-
"public"
|
|
13
|
-
],
|
|
9
|
+
"license": "Apache-2.0",
|
|
14
10
|
"type": "module",
|
|
15
|
-
"main": "./dist/index.js",
|
|
16
|
-
"types": "./dist/index.d.ts",
|
|
17
11
|
"imports": {
|
|
18
12
|
"#daemon-entry": "./dist/daemon/entry.js"
|
|
19
13
|
},
|
|
@@ -45,21 +39,25 @@
|
|
|
45
39
|
},
|
|
46
40
|
"./package.json": "./package.json"
|
|
47
41
|
},
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
"main": "./dist/index.js",
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"files": [
|
|
45
|
+
"CHANGELOG.md",
|
|
46
|
+
"dist",
|
|
47
|
+
"public"
|
|
48
|
+
],
|
|
51
49
|
"dependencies": {
|
|
52
50
|
"@lynx-js/debug-metadata": "0.1.0",
|
|
53
51
|
"@yume-chan/adb": "3.0.0-beta.4"
|
|
54
52
|
},
|
|
55
53
|
"devDependencies": {
|
|
56
|
-
"@rslib/core": "1.0.
|
|
54
|
+
"@rslib/core": "^1.0.4",
|
|
57
55
|
"@types/node": "^24.19.2",
|
|
58
56
|
"@types/semver": "^7.8.0",
|
|
59
57
|
"@types/ws": "^8.18.2",
|
|
60
58
|
"@yume-chan/adb-server-node-tcp": "3.0.0-beta.4",
|
|
61
59
|
"@yume-chan/stream-extra": "3.0.0-beta.4",
|
|
62
|
-
"dprint": "^0.
|
|
60
|
+
"dprint": "^0.64.3",
|
|
63
61
|
"jpeg-js": "^0.4.4",
|
|
64
62
|
"obug": "^2.2.1",
|
|
65
63
|
"plist": "^5.0.0",
|
|
@@ -71,7 +69,9 @@
|
|
|
71
69
|
"engines": {
|
|
72
70
|
"node": ">=18.19"
|
|
73
71
|
},
|
|
74
|
-
"
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"access": "public"
|
|
74
|
+
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"build": "rslib build",
|
|
77
77
|
"test": "node --test --test-concurrency=1 \"test/**/*.test.ts\"",
|