@lynx-js/devtool-connector 0.13.2 → 0.16.2

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.
Files changed (75) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +18 -134
  3. package/dist/2.js +2019 -0
  4. package/dist/{346.js → a.js} +102 -143
  5. package/dist/client-id.d.ts +0 -6
  6. package/dist/command/client.d.ts +8 -7
  7. package/dist/command/contract.d.ts +82 -24
  8. package/dist/command/core.d.ts +11 -10
  9. package/dist/command/in-process-client.d.ts +16 -0
  10. package/dist/command/index.d.ts +28 -20
  11. package/dist/command/index.js +177 -159
  12. package/dist/command/list-clients.d.ts +6 -0
  13. package/dist/command/list-sessions.d.ts +5 -0
  14. package/dist/command/open.d.ts +5 -0
  15. package/dist/command/query.d.ts +1 -1
  16. package/dist/command/reactlynx/controller.d.ts +3 -3
  17. package/dist/command/reactlynx/model.d.ts +7 -7
  18. package/dist/command/reactlynx/protocol.d.ts +0 -1
  19. package/dist/command/reactlynx/session.d.ts +3 -3
  20. package/dist/command/reactlynx/types.d.ts +7 -7
  21. package/dist/command/ref-actions.d.ts +4 -4
  22. package/dist/command/result.d.ts +0 -1
  23. package/dist/command/screenshot-annotation.d.ts +2 -2
  24. package/dist/command/screenshot.d.ts +2 -2
  25. package/dist/command/snapshot.d.ts +2 -2
  26. package/dist/command/source-info.d.ts +20 -0
  27. package/dist/command/targets.d.ts +8 -10
  28. package/dist/command/timeout.d.ts +3 -0
  29. package/dist/command/wait-for-client.d.ts +5 -0
  30. package/dist/daemon/device-connection.d.ts +4 -3
  31. package/dist/daemon/entry.js +18 -20
  32. package/dist/daemon/index.d.ts +7 -2
  33. package/dist/daemon/index.js +7 -3
  34. package/dist/daemon/inspector-assets.d.ts +11 -0
  35. package/dist/daemon/manager.d.ts +12 -4
  36. package/dist/daemon/protocol.d.ts +20 -16
  37. package/dist/daemon/server.d.ts +7 -1
  38. package/dist/daemon/static-server.d.ts +3 -1
  39. package/dist/f.js +5790 -0
  40. package/dist/f1.js +737 -0
  41. package/dist/{962.js → h.js} +841 -3259
  42. package/dist/{712.js → hb.js} +26 -19
  43. package/dist/i.js +2505 -0
  44. package/dist/index.d.ts +13 -18
  45. package/dist/index.js +3 -2
  46. package/dist/main.d.ts +2 -0
  47. package/dist/main.js +3 -0
  48. package/dist/request-id.d.ts +1 -0
  49. package/dist/streams/cdp.d.ts +3 -3
  50. package/dist/streams/customized.d.ts +5 -5
  51. package/dist/streams/index.d.ts +4 -3
  52. package/dist/streams/index.js +1 -1
  53. package/dist/streams/utils.d.ts +3 -3
  54. package/dist/{872.js → t.js} +364 -301
  55. package/dist/transport/adb-shell-types.d.ts +14 -0
  56. package/dist/transport/android-app-icon-helper.d.ts +1 -0
  57. package/dist/transport/android.d.ts +13 -3
  58. package/dist/transport/base.d.ts +2 -9
  59. package/dist/transport/daemon.d.ts +3 -2
  60. package/dist/transport/desktop.d.ts +1 -1
  61. package/dist/transport/hdt.d.ts +13 -0
  62. package/dist/transport/index.d.ts +9 -9
  63. package/dist/transport/index.js +2 -3
  64. package/dist/transport/ios.d.ts +2 -2
  65. package/dist/transport/peertalk.d.ts +4 -3
  66. package/dist/transport/stream-lifecycle.d.ts +4 -0
  67. package/dist/transport/transport.d.ts +4 -8
  68. package/dist/transport/usbmux.d.ts +5 -5
  69. package/dist/transport/ws-stream.d.ts +3 -10
  70. package/dist/types.d.ts +28 -24
  71. package/dist/{63.js → ws-stream.js} +23 -24
  72. package/package.json +32 -22
  73. package/dist/390.js +0 -329
  74. package/dist/556.js +0 -258
  75. package/dist/61.js +0 -3432
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
- # @lynx-js/devtool-connector
1
+ # Lynx DevTool Connector
2
2
 
3
- `@lynx-js/devtool-connector` provides low-level connectivity for Lynx DevTool. It unifies transport layers for Android / iOS / Desktop, and exposes stable request APIs (such as `CDP`, `App`, and `ListSession`).
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 transports = [
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.length === 0) {
66
- throw new Error("No available clients found");
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
- Pass `true` as the optional `isMainThread` argument to target the main-thread VM. Main-thread CDP requests currently support only `Debugger.*`, `Runtime.*`, `HeapProfiler.*`, and `Profiler.*` methods.
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
- The connector also supports streaming send/receive:
22
+ ## Product adapters
107
23
 
108
- - `sendCDPStream(...)`
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
- These APIs are useful for subscription-style logs, continuous requests, or protocol debugging.
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
- When you finish consuming the returned stream, make sure to close it (dispose the output stream) to release the underlying connection.
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
- Example: consume CDP events with `for await...of`
30
+ ## Migration from 0.13.2
116
31
 
117
- ```ts
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
- ## Known limitations
34
+ ## Development
150
35
 
151
- - USB-based iOS transport (`iOSTransport`) still does not implement `listAvailableApps` / `openApp`.
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.