@lynx-js/devtool-connector 0.13.2 → 0.16.3
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 +19 -0
- package/LICENSE +1 -1
- package/README.md +18 -134
- package/dist/2.js +2019 -0
- package/dist/{346.js → a.js} +102 -143
- package/dist/client-id.d.ts +0 -6
- package/dist/command/client.d.ts +8 -7
- package/dist/command/contract.d.ts +82 -24
- package/dist/command/core.d.ts +11 -10
- package/dist/command/in-process-client.d.ts +16 -0
- package/dist/command/index.d.ts +28 -20
- package/dist/command/index.js +177 -159
- package/dist/command/list-clients.d.ts +6 -0
- package/dist/command/list-sessions.d.ts +5 -0
- package/dist/command/open.d.ts +5 -0
- package/dist/command/query.d.ts +1 -1
- package/dist/command/reactlynx/controller.d.ts +3 -3
- package/dist/command/reactlynx/model.d.ts +7 -7
- package/dist/command/reactlynx/protocol.d.ts +0 -1
- package/dist/command/reactlynx/session.d.ts +3 -3
- package/dist/command/reactlynx/types.d.ts +7 -7
- package/dist/command/ref-actions.d.ts +4 -4
- package/dist/command/result.d.ts +0 -1
- package/dist/command/screenshot-annotation.d.ts +2 -2
- package/dist/command/screenshot.d.ts +2 -2
- package/dist/command/snapshot.d.ts +2 -2
- package/dist/command/source-info.d.ts +20 -0
- package/dist/command/targets.d.ts +8 -10
- package/dist/command/timeout.d.ts +3 -0
- package/dist/command/wait-for-client.d.ts +5 -0
- package/dist/daemon/device-connection.d.ts +4 -3
- package/dist/daemon/entry.js +18 -20
- package/dist/daemon/index.d.ts +7 -2
- package/dist/daemon/index.js +7 -3
- package/dist/daemon/inspector-assets.d.ts +11 -0
- package/dist/daemon/manager.d.ts +12 -4
- package/dist/daemon/protocol.d.ts +20 -16
- package/dist/daemon/server.d.ts +7 -1
- package/dist/daemon/static-server.d.ts +3 -1
- package/dist/f.js +5790 -0
- package/dist/f1.js +737 -0
- package/dist/{962.js → h.js} +854 -3274
- package/dist/{712.js → hb.js} +26 -19
- package/dist/i.js +2505 -0
- package/dist/index.d.ts +13 -18
- package/dist/index.js +3 -2
- package/dist/main.d.ts +2 -0
- package/dist/main.js +3 -0
- package/dist/request-id.d.ts +1 -0
- package/dist/streams/cdp.d.ts +3 -3
- package/dist/streams/customized.d.ts +5 -5
- package/dist/streams/index.d.ts +4 -3
- package/dist/streams/index.js +1 -1
- package/dist/streams/utils.d.ts +3 -3
- package/dist/{872.js → t.js} +364 -301
- package/dist/transport/adb-shell-types.d.ts +14 -0
- package/dist/transport/android-app-icon-helper.d.ts +1 -0
- package/dist/transport/android.d.ts +13 -3
- package/dist/transport/base.d.ts +2 -9
- package/dist/transport/daemon.d.ts +3 -2
- package/dist/transport/desktop.d.ts +1 -1
- package/dist/transport/hdt.d.ts +13 -0
- package/dist/transport/index.d.ts +9 -9
- package/dist/transport/index.js +2 -3
- package/dist/transport/ios.d.ts +2 -2
- package/dist/transport/peertalk.d.ts +4 -3
- package/dist/transport/stream-lifecycle.d.ts +4 -0
- package/dist/transport/transport.d.ts +4 -8
- package/dist/transport/usbmux.d.ts +5 -5
- package/dist/transport/ws-stream.d.ts +3 -10
- package/dist/types.d.ts +28 -24
- package/dist/{63.js → ws-stream.js} +23 -24
- package/package.json +33 -23
- package/dist/390.js +0 -329
- package/dist/556.js +0 -258
- package/dist/61.js +0 -3432
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @lynx-js/devtool-connector
|
|
2
2
|
|
|
3
|
+
## 0.16.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependency `@yume-chan/adb-server-node-tcp` to `3.0.0-beta.4`.
|
|
8
|
+
- Updated dependency `@yume-chan/adb` to `3.0.0-beta.4`.
|
|
9
|
+
- Updated dependency `@yume-chan/stream-extra` to `3.0.0-beta.4`.
|
|
10
|
+
- Updated dependency `dprint` to `^0.62.0`.
|
|
11
|
+
- Updated dependency `@types/node` to `^24.19.2`.
|
|
12
|
+
- Updated dependency `ws` to `^8.22.0`.
|
|
13
|
+
- Use Node's stream read-result type in ReactLynx sessions to avoid declaration-build failures caused by mixing Node and DOM stream types. Runtime behavior is unchanged.
|
|
14
|
+
- Share the Connector, HDT transports, command engine and daemon lifecycle between the public and internal distributions. Align the public implementation with version 0.16.2 and allow cross-origin version discovery while retaining loopback control protections.
|
|
15
|
+
|
|
16
|
+
Use the Connector namespace for the Android app icon helper, including its embedded DEX artifact.
|
|
17
|
+
|
|
18
|
+
Keep host-specific protocol declarations in the internal facade while sharing the generic Customized response parser and request correlation logic.
|
|
19
|
+
|
|
20
|
+
The `/transport` entry point no longer exports `wsStreams`, `WsWebSocketStream` or `createWebSocketReadable`. Keep the WebSocket implementation internal and bundled for daemon and HDT transports so consumers do not need `ws` types.
|
|
21
|
+
|
|
3
22
|
## 0.13.2
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/LICENSE
CHANGED
|
@@ -199,4 +199,4 @@
|
|
|
199
199
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
200
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
201
|
See the License for the specific language governing permissions and
|
|
202
|
-
limitations under the License.
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,152 +1,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Lynx DevTool Connector
|
|
2
2
|
|
|
3
|
-
`@lynx-js/devtool-connector`
|
|
4
|
-
|
|
5
|
-
It can be used as a TypeScript library in higher-level services like `devtool-mcp-server`.
|
|
6
|
-
|
|
7
|
-
## Requirements
|
|
8
|
-
|
|
9
|
-
- Node.js >= 18.19
|
|
10
|
-
- At least one available device channel:
|
|
11
|
-
- Android: ADB (default `127.0.0.1:5037`)
|
|
12
|
-
- iOS: usbmuxd
|
|
13
|
-
- Desktop: local `127.0.0.1` port
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
pnpm add @lynx-js/devtool-connector
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Library usage
|
|
22
|
-
|
|
23
|
-
### 1) Initialize Connector
|
|
3
|
+
`@lynx-js/devtool-connector` is the standalone device and command layer shared by public and internal Lynx tools. It supports Android, iOS, Desktop, Peertalk, HDT and a persistent loopback daemon. Use Node 22.12+ or Node 24 for source development.
|
|
24
4
|
|
|
25
5
|
```ts
|
|
26
6
|
import { Connector } from "@lynx-js/devtool-connector";
|
|
7
|
+
import { HttpCommandClient } from "@lynx-js/devtool-connector/command";
|
|
27
8
|
import { DaemonTransport } from "@lynx-js/devtool-connector/transport";
|
|
28
9
|
|
|
29
|
-
const
|
|
30
|
-
new DaemonTransport(),
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const connector = new Connector(transports);
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Use `DaemonTransport` as the default transport. It automatically manages a local daemon process and reuses stable device connections, so it should be the primary path for client discovery and follow-up requests.
|
|
37
|
-
|
|
38
|
-
Add other transports only when you need fallback behavior for environments where the daemon is unavailable or cannot discover a target client. When fallback transports are present, `Connector` tries daemon-backed clients first, then the remaining direct platform transports.
|
|
39
|
-
|
|
40
|
-
Fallback example:
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
import { Connector } from "@lynx-js/devtool-connector";
|
|
44
|
-
import {
|
|
45
|
-
AndroidTransport,
|
|
46
|
-
DaemonTransport,
|
|
47
|
-
DesktopTransport,
|
|
48
|
-
iOSTransport,
|
|
49
|
-
} from "@lynx-js/devtool-connector/transport";
|
|
50
|
-
|
|
51
|
-
const connector = new Connector([
|
|
52
|
-
new DaemonTransport(),
|
|
53
|
-
new AndroidTransport(),
|
|
54
|
-
new iOSTransport(),
|
|
55
|
-
new DesktopTransport(),
|
|
56
|
-
]);
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### 2) List devices, clients, and sessions
|
|
60
|
-
|
|
61
|
-
```ts
|
|
62
|
-
const devices = await connector.listDevices();
|
|
10
|
+
const connector = new Connector([new DaemonTransport()]);
|
|
63
11
|
const clients = await connector.listClients();
|
|
64
|
-
|
|
65
|
-
if (clients
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const clientId = clients[0].id;
|
|
70
|
-
const sessions = await connector.sendListSessionMessage(clientId);
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### 3) Send CDP / App requests
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
const sessionId = sessions[0]?.session_id;
|
|
77
|
-
if (!sessionId) {
|
|
78
|
-
throw new Error("No session found");
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const dom = await connector.sendCDPMessage(
|
|
82
|
-
clientId,
|
|
83
|
-
sessionId,
|
|
84
|
-
"DOM.getDocument",
|
|
85
|
-
{ depth: -1 },
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const mainThreadEval = await connector.sendCDPMessage(
|
|
89
|
-
clientId,
|
|
90
|
-
sessionId,
|
|
91
|
-
"Runtime.evaluate",
|
|
92
|
-
{ expression: "2 + 2" },
|
|
93
|
-
// isMainThread
|
|
94
|
-
true,
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
await connector.sendAppMessage(clientId, "App.openPage", {
|
|
98
|
-
url: "https://lynxjs.org",
|
|
12
|
+
const client = clients[0];
|
|
13
|
+
if (!client) throw new Error("No Lynx clients found");
|
|
14
|
+
const commands = new HttpCommandClient();
|
|
15
|
+
const sessions = await commands.execute("list-sessions", {
|
|
16
|
+
clientId: client.id,
|
|
99
17
|
});
|
|
100
18
|
```
|
|
101
19
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
### 4) Streaming APIs (advanced)
|
|
20
|
+
The daemon owns physical connections; requests subscribe to them rather than opening a competing DebugRouter connection. Successful daemon/HDT discovery, including an empty result, is authoritative. Lifecycle conflicts never fall back to direct connections.
|
|
105
21
|
|
|
106
|
-
|
|
22
|
+
## Product adapters
|
|
107
23
|
|
|
108
|
-
|
|
109
|
-
- `sendStream(...)` (custom pipeline)
|
|
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.
|
|
110
25
|
|
|
111
|
-
|
|
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.
|
|
112
27
|
|
|
113
|
-
|
|
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.
|
|
114
29
|
|
|
115
|
-
|
|
30
|
+
## Migration from 0.13.2
|
|
116
31
|
|
|
117
|
-
|
|
118
|
-
import { ReadableStream } from "node:stream/web";
|
|
119
|
-
|
|
120
|
-
await using outputStream = await connector.sendCDPStream(
|
|
121
|
-
clientId,
|
|
122
|
-
sessionId,
|
|
123
|
-
ReadableStream.from([
|
|
124
|
-
{ method: "Runtime.enable" },
|
|
125
|
-
]),
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
for await (const message of outputStream) {
|
|
129
|
-
// `sendCDPStream` yields CDP events, e.g. { method: "Runtime.consoleAPICalled", params: ... }
|
|
130
|
-
console.log(message.method, message.params);
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Exported entry points
|
|
136
|
-
|
|
137
|
-
- `@lynx-js/devtool-connector`: `Connector`, `ClientId`, and protocol transform streams
|
|
138
|
-
- `@lynx-js/devtool-connector/transport`: platform transport implementations and type definitions
|
|
139
|
-
- `@lynx-js/devtool-connector/test-with-client`: helper for integration tests with real clients
|
|
140
|
-
|
|
141
|
-
## Debugging
|
|
142
|
-
|
|
143
|
-
Use the `debug` namespace to inspect connection/protocol send-receive details while running code that imports this package:
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
DEBUG=devtool-mcp-server:connector* node ./your-script.mjs
|
|
147
|
-
```
|
|
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.
|
|
148
33
|
|
|
149
|
-
##
|
|
34
|
+
## Development
|
|
150
35
|
|
|
151
|
-
|
|
152
|
-
- `listClients()` has snapshot semantics: each call re-scans ports and re-validates clients via handshake.
|
|
36
|
+
Run `pnpm build`, `pnpm test` and `pnpm format:check` in this package. Tests use `node:test`; device-independent tests are in `test/`, explicitly configured device tests in `e2e/`. The package retains its imported dprint source style to keep mechanical moves reviewable; the rest of the public repository uses Biome.
|