@cldmv/droidsock 0.1.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/LICENSE ADDED
@@ -0,0 +1,210 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License.
67
+
68
+ Subject to the terms and conditions of this License, each Contributor
69
+ hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
70
+ royalty-free, irrevocable copyright license to reproduce, prepare
71
+ Derivative Works of, publicly display, publicly perform, sublicense,
72
+ and distribute the Work and such Derivative Works in Source or Object
73
+ form.
74
+
75
+ 3. Grant of Patent License.
76
+
77
+ Subject to the terms and conditions of this License, each Contributor
78
+ hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
79
+ royalty-free, irrevocable (except as stated in this section) patent
80
+ license to make, have made, use, offer to sell, sell, import, and
81
+ otherwise transfer the Work, where such license applies only to those
82
+ patent claims licensable by such Contributor that are necessarily
83
+ infringed by their Contribution(s) alone or by combination of their
84
+ Contribution(s) with the Work to which such Contribution(s) was
85
+ submitted. If You institute patent litigation against any entity
86
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
87
+ the Work or a Contribution incorporated within the Work constitutes
88
+ direct or contributory patent infringement, then any patent licenses
89
+ granted to You under this License for that Work shall terminate as of
90
+ the date such litigation is filed.
91
+
92
+ 4. Redistribution.
93
+
94
+ You may reproduce and distribute copies of the Work or Derivative
95
+ Works thereof in any medium, with or without modifications, and in
96
+ Source or Object form, provided that You meet the following conditions:
97
+
98
+ (a) You must give any other recipients of the Work or Derivative Works
99
+ a copy of this License; and
100
+
101
+ (b) You must cause any modified files to carry prominent notices
102
+ stating that You changed the files; and
103
+
104
+ (c) You must retain, in the Source form of any Derivative Works that
105
+ You distribute, all copyright, patent, trademark, and attribution
106
+ notices from the Source form of the Work, excluding those notices
107
+ that do not pertain to any part of the Derivative Works; and
108
+
109
+ (d) If the Work includes a "NOTICE" text file as part of its
110
+ distribution, then any Derivative Works that You distribute must
111
+ include a readable copy of the attribution notices contained
112
+ within such NOTICE file, excluding those notices that do not
113
+ pertain to any part of the Derivative Works, in at least one
114
+ of the following places: within a NOTICE text file distributed
115
+ as part of the Derivative Works; within the Source form or
116
+ documentation, if provided along with the Derivative Works; or,
117
+ within a display generated by the Derivative Works, if and
118
+ wherever such third-party notices normally appear. The contents
119
+ of the NOTICE file are for informational purposes only and
120
+ do not modify the License. You may add Your own attribution
121
+ notices within Derivative Works that You distribute, alongside
122
+ or as an addendum to the NOTICE text from the Work, provided
123
+ that such additional attribution notices cannot be construed
124
+ as modifying the License.
125
+
126
+ You may add Your own copyright statement to Your modifications and
127
+ may provide additional or different license terms and conditions
128
+ for use, reproduction, or distribution of Your modifications, or
129
+ for any such Derivative Works as a whole, provided Your use,
130
+ reproduction, and distribution of the Work otherwise complies with
131
+ the conditions stated in this License.
132
+
133
+ 5. Submission of Contributions.
134
+
135
+ Unless You explicitly state otherwise, any Contribution intentionally
136
+ submitted for inclusion in the Work by You to the Licensor shall be
137
+ under the terms and conditions of this License, without any additional
138
+ terms or conditions. Notwithstanding the above, nothing herein shall
139
+ supersede or modify the terms of any separate license agreement you
140
+ may have executed with Licensor regarding such Contributions.
141
+
142
+ 6. Trademarks.
143
+
144
+ This License does not grant permission to use the trade names,
145
+ trademarks, service marks, or product names of the Licensor, except
146
+ as required for describing the origin of the Work and reproducing
147
+ the content of the NOTICE file.
148
+
149
+ 7. Disclaimer of Warranty.
150
+
151
+ Unless required by applicable law or agreed to in writing, Licensor
152
+ provides the Work (and each Contributor provides its Contributions)
153
+ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
154
+ either express or implied, including, without limitation, any
155
+ warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY,
156
+ or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
157
+ determining the appropriateness of using or redistributing the Work
158
+ and assume any risks associated with Your exercise of permissions
159
+ under this License.
160
+
161
+ 8. Limitation of Liability.
162
+
163
+ In no event and under no legal theory, whether in tort (including
164
+ negligence), contract, or otherwise, unless required by applicable
165
+ law (such as deliberate and grossly negligent acts) or agreed to in
166
+ writing, shall any Contributor be liable to You for damages, including
167
+ any direct, indirect, special, incidental, or consequential damages
168
+ of any character arising as a result of this License or out of the
169
+ use or inability to use the Work (including but not limited to damages
170
+ for loss of goodwill, work stoppage, computer failure or malfunction,
171
+ or any and all other commercial damages or losses), even if such
172
+ Contributor has been advised of the possibility of such damages.
173
+
174
+ 9. Accepting Warranty or Additional Liability.
175
+
176
+ While redistributing the Work or Derivative Works thereof, You may choose
177
+ to offer, and charge a fee for, acceptance of support, warranty, indemnity,
178
+ or other liability obligations and/or rights consistent with this License.
179
+ However, in accepting such obligations, You may act only on Your own behalf
180
+ and on Your sole responsibility, not on behalf of any other Contributor,
181
+ and only if You agree to indemnify, defend, and hold each Contributor
182
+ harmless for any liability incurred by, or claims asserted against, such
183
+ Contributor by reason of your accepting any such warranty or additional
184
+ liability.
185
+
186
+ END OF TERMS AND CONDITIONS
187
+
188
+ APPENDIX: How to apply the Apache License to your work.
189
+
190
+ To apply the Apache License to your work, attach the following boilerplate
191
+ notice, with the fields enclosed by brackets "[]" replaced with your own
192
+ identifying information. (Don't include the brackets!) The text should be
193
+ enclosed in the appropriate comment syntax for the file format. We also
194
+ recommend that a file or class name and description of purpose be included
195
+ on the same "printed page" as the copyright notice for easier
196
+ identification within third-party archives.
197
+
198
+ Copyright [yyyy] [name of copyright owner]
199
+
200
+ Licensed under the Apache License, Version 2.0 (the "License");
201
+ you may not use this file except in compliance with the License.
202
+ You may obtain a copy of the License at
203
+
204
+ http://www.apache.org/licenses/LICENSE-2.0
205
+
206
+ Unless required by applicable law or agreed to in writing, software
207
+ distributed under the License is distributed on an "AS IS" BASIS,
208
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209
+ See the License for the specific language governing permissions and
210
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,232 @@
1
+ # DroidSock
2
+
3
+ A complete, from-scratch implementation of the Android Debug Bridge (ADB) protocol in Node.js. This library provides full ADB functionality including device connection, RSA authentication, shell command execution, and file transfers - eliminating clicking sounds on Android TV devices!
4
+
5
+ ## Features
6
+
7
+ - ✅ **Complete ADB Protocol**: Full implementation from TCP connection to high-level APIs
8
+ - ✅ **RSA Authentication**: Automatic key generation and ADB-specific formatting
9
+ - ✅ **Stream Multiplexing**: Multiple concurrent operations over single connection
10
+ - ✅ **Shell Commands**: Execute commands, stream output, interactive sessions
11
+ - ✅ **File Transfers**: Push/pull files with SYNC protocol
12
+ - ✅ **Device Discovery**: Support for multiple devices via configuration
13
+ - ✅ **Error Handling**: Robust error handling and connection recovery
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @cldmv/droidsock
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```javascript
24
+ import DroidSock from "@cldmv/droidsock";
25
+
26
+ // Create client
27
+ const client = new DroidSock({
28
+ host: "10.6.0.108", // Device IP
29
+ port: 5555 // ADB port
30
+ });
31
+
32
+ // Connect
33
+ await client.connect();
34
+
35
+ // Execute shell command
36
+ const output = await client.shell("ls -la");
37
+ console.log(output);
38
+
39
+ // Get device info
40
+ const model = await client.getModel();
41
+ const version = await client.getAndroidVersion();
42
+
43
+ // File operations
44
+ await client.push("./local-file.txt", "/sdcard/remote-file.txt");
45
+ await client.pull("/sdcard/remote-file.txt", "./local-file.txt");
46
+
47
+ // Stream commands
48
+ const logcat = client.logcat({
49
+ onData: (data) => console.log(data)
50
+ });
51
+
52
+ // Clean up
53
+ client.disconnect();
54
+ ```
55
+
56
+ ## Device Configuration
57
+
58
+ Use the `references/devices.json` file to configure your devices:
59
+
60
+ ```json
61
+ {
62
+ "livingroom": {
63
+ "name": "Living Room TV",
64
+ "host": "10.6.0.108",
65
+ "port": 5555,
66
+ "description": "Main living room Android TV"
67
+ },
68
+ "bedroom": {
69
+ "name": "Master Bedroom TV",
70
+ "host": "10.6.0.118",
71
+ "port": 5555,
72
+ "description": "Master bedroom Android TV"
73
+ },
74
+ "default": "livingroom"
75
+ }
76
+ ```
77
+
78
+ ## API Reference
79
+
80
+ ### DroidSock
81
+
82
+ Main client class for ADB operations.
83
+
84
+ #### Constructor Options
85
+
86
+ - `host`: Device IP address
87
+ - `port`: ADB port (default: 5555)
88
+ - `keyDir`: Directory for RSA keys (default: ~/.adb)
89
+
90
+ #### Methods
91
+
92
+ ##### Connection
93
+
94
+ - `connect()`: Connect to device
95
+ - `disconnect()`: Disconnect from device
96
+ - `isConnected()`: Check connection status
97
+
98
+ ##### Shell Commands
99
+
100
+ - `shell(command, options)`: Execute shell command
101
+ - `startStreamingShell(command, options)`: Start streaming command
102
+ - `startInteractiveShell(command, options)`: Start interactive command
103
+
104
+ ##### Convenience Methods
105
+
106
+ - `ls(path)`: List directory
107
+ - `pwd()`: Get current directory
108
+ - `getprop(property)`: Get system property
109
+ - `getModel()`: Get device model
110
+ - `getAndroidVersion()`: Get Android version
111
+ - `getBattery()`: Get battery status
112
+ - `screenshot(filename)`: Take screenshot
113
+ - `logcat(options)`: Stream logcat
114
+ - `top(options)`: Stream top command
115
+
116
+ ##### File Operations
117
+
118
+ - `push(localPath, remotePath, options)`: Push file to device
119
+ - `pull(remotePath, localPath, options)`: Pull file from device
120
+ - `list(remotePath)`: List directory contents
121
+ - `stat(remotePath)`: Get file/directory stats
122
+
123
+ ## Examples
124
+
125
+ ### Basic Usage
126
+
127
+ ```bash
128
+ # Run basic example with default device
129
+ node examples/basic-usage.mjs
130
+
131
+ # Run with specific device
132
+ node examples/basic-usage.mjs livingroom
133
+ ```
134
+
135
+ ### Streaming Commands
136
+
137
+ ```bash
138
+ # Stream logcat
139
+ node examples/streaming-example.mjs logcat
140
+
141
+ # Stream top command
142
+ node examples/streaming-example.mjs top
143
+
144
+ # File transfer demo
145
+ node examples/streaming-example.mjs files
146
+ ```
147
+
148
+ ## Architecture
149
+
150
+ The implementation consists of several layers:
151
+
152
+ 1. **Packet Layer** (`packet.mjs`): Low-level ADB packet creation/parsing
153
+ 2. **Authentication Layer** (`auth.mjs`): RSA key management and ADB auth
154
+ 3. **Connection Layer** (`connection.mjs`): TCP connection and auth flow
155
+ 4. **Stream Layer** (`stream.mjs`): Service multiplexing and data flow
156
+ 5. **Shell Layer** (`shell.mjs`): Command execution APIs
157
+ 6. **SYNC Layer** (`sync.mjs`): File transfer protocol
158
+ 7. **Client Layer** (`adb.mjs`): Unified high-level API
159
+
160
+ ## Protocol Implementation Details
161
+
162
+ ### Packet Structure
163
+
164
+ All ADB packets follow a 24-byte header + optional data format:
165
+
166
+ - Command (4 bytes, little-endian)
167
+ - Arg0/Arg1 (4 bytes each, little-endian)
168
+ - Data length (4 bytes, little-endian)
169
+ - Checksum (4 bytes, sum of data bytes)
170
+ - Magic (4 bytes, command XOR 0xFFFFFFFF)
171
+
172
+ ### Authentication Flow
173
+
174
+ 1. Client sends CNXN packet
175
+ 2. Server responds with AUTH(TOKEN)
176
+ 3. Client signs token with RSA private key
177
+ 4. Client sends AUTH(SIGNATURE)
178
+ 5. If rejected, client sends AUTH(RSAPUBLICKEY)
179
+ 6. Server prompts user to authorize
180
+ 7. Server sends CNXN on successful auth
181
+
182
+ ### Stream Multiplexing
183
+
184
+ - Each service (shell, sync, etc.) gets unique local/remote ID pair
185
+ - WRTE packets carry data, OKAY packets acknowledge receipt
186
+ - CLSE packets close streams
187
+ - Multiple streams operate concurrently
188
+
189
+ ### File Transfer (SYNC)
190
+
191
+ - Uses "sync:" service with sub-protocol
192
+ - SEND/RECV commands for push/pull
193
+ - DATA packets for file chunks
194
+ - DONE packets signal completion
195
+
196
+ ## Troubleshooting
197
+
198
+ ### Connection Issues
199
+
200
+ - Ensure device is on same network
201
+ - Enable "ADB over network" in developer options
202
+ - Check firewall settings
203
+ - Verify IP address and port
204
+
205
+ ### Authentication Issues
206
+
207
+ - Delete existing keys to force re-authorization: `rm -rf ~/.adb`
208
+ - Ensure device shows authorization dialog
209
+ - Check device storage permissions
210
+
211
+ ### Common Errors
212
+
213
+ - "Command timeout": Increase timeout in options
214
+ - "Stream not open": Ensure connection is established
215
+ - "File not found": Check paths and permissions
216
+
217
+ ## Development
218
+
219
+ The implementation is based on:
220
+
221
+ - Working ADB client implementation analysis
222
+ - Kotlin reference implementation
223
+ - Extensive testing with real Android devices
224
+ - ADB protocol documentation
225
+
226
+ ## License
227
+
228
+ MIT License - see package.json for details.
229
+
230
+ ## Contributing
231
+
232
+ This is a complete implementation of the ADB protocol. For improvements or bug fixes, please submit issues or pull requests.
package/devcheck.mjs ADDED
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @Project: @cldmv/droidsock
3
+ * @Filename: /devcheck.mjs
4
+ * @Date: 2025-11-08 22:18:57 -08:00 (1762669137)
5
+ * @Author: Nate Hyson <CLDMV>
6
+ * @Email: <Shinrai@users.noreply.github.com>
7
+ * -----
8
+ * @Last modified by: Nate Hyson <CLDMV> (Shinrai@users.noreply.github.com)
9
+ * @Last modified time: 2025-11-21 14:50:46 -08:00 (1763765446)
10
+ * -----
11
+ * @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved.
12
+ */
13
+
14
+ import { existsSync } from "node:fs";
15
+ import { fileURLToPath } from "node:url";
16
+ import path from "node:path";
17
+
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = path.dirname(__filename);
20
+ const srcPath = path.join(__dirname, "src");
21
+ // const distPath = path.join(__dirname, "dist");
22
+
23
+ // Detect if we're running in a CI environment
24
+ const isCI = !!(
25
+ process.env.CI || // Generic CI flag
26
+ process.env.GITHUB_ACTIONS || // GitHub Actions
27
+ process.env.TRAVIS || // Travis CI
28
+ process.env.CIRCLECI || // CircleCI
29
+ process.env.GITLAB_CI || // GitLab CI
30
+ process.env.BUILDKITE || // Buildkite
31
+ process.env.JENKINS_URL || // Jenkins
32
+ process.env.TF_BUILD // Azure DevOps
33
+ );
34
+
35
+ if (existsSync(srcPath) && !isCI) {
36
+ // if (existsSync(srcPath) && !existsSync(distPath)) {
37
+ const nodeEnv = process.env.NODE_ENV?.toLowerCase();
38
+ const hasNodeOptions = process.env.NODE_OPTIONS?.includes("--conditions=development");
39
+
40
+ if (!nodeEnv || (!["dev", "development"].includes(nodeEnv) && !hasNodeOptions)) {
41
+ console.error("❌ Development environment not properly configured!");
42
+ console.error("📁 Source folder detected but NODE_ENV/NODE_OPTIONS not set for development.");
43
+ console.error("");
44
+ console.error("🔧 To fix this, run one of these commands:");
45
+ console.error(" Windows (cmd):");
46
+ console.error(" set NODE_ENV=development");
47
+ console.error(" set NODE_OPTIONS=--conditions=development");
48
+ console.error("");
49
+ console.error(" Windows (PowerShell):");
50
+ console.error(" $env:NODE_ENV='development'");
51
+ console.error(" $env:NODE_OPTIONS='--conditions=development'");
52
+ console.error("");
53
+ console.error(" Unix/Linux/macOS:");
54
+ console.error(" export NODE_ENV=development");
55
+ console.error(" export NODE_OPTIONS=--conditions=development");
56
+ console.error("");
57
+ console.error("💡 This ensures this module loads from src/ instead of dist/ for development.");
58
+ console.error("🚀 CI environments automatically skip this check.");
59
+ process.exit(1);
60
+ }
61
+ }
package/index.cjs ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @Project: @cldmv/droidsock
3
+ * @Filename: /index.cjs
4
+ * @Date: 2025-11-21 14:04:10 -08:00
5
+ * @Author: Nate Hyson <CLDMV>
6
+ * @Email: <Shinrai@users.noreply.github.com>
7
+ * -----
8
+ * @Last modified by: Nate Hyson <CLDMV> (Shinrai@users.noreply.github.com)
9
+ * @Last modified time: 2025-11-21 16:22:18 -08:00
10
+ * -----
11
+ * @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved.
12
+ */
13
+
14
+ /**
15
+ * CommonJS entry point for DroidSock
16
+ *
17
+ * This file provides CommonJS (require) support for the DroidSock library.
18
+ * It imports and re-exports the main DroidSock functions from the ESM module.
19
+ *
20
+ * @module droidsock
21
+ */
22
+
23
+ const { createRequire } = require("module");
24
+ const requireESM = createRequire(__filename);
25
+
26
+ const { default: createDroidSock, connect, listDevices } = requireESM("./index.mjs");
27
+
28
+ // Export main function
29
+ module.exports = createDroidSock; // Default export
30
+ module.exports.createDroidSock = createDroidSock;
31
+ module.exports.connect = connect;
32
+ module.exports.listDevices = listDevices;
33
+
34
+ // Common DroidSock aliases
35
+ module.exports.DroidSock = createDroidSock;
36
+ module.exports.ADB = createDroidSock;
37
+ module.exports.AndroidDebugBridge = createDroidSock;
package/index.mjs ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @Project: @cldmv/droidsock
3
+ * @Filename: /index.mjs
4
+ * @Date: 2025-11-21 14:04:10 -08:00
5
+ * @Author: Nate Hyson <CLDMV>
6
+ * @Email: <Shinrai@users.noreply.github.com>
7
+ * -----
8
+ * @Last modified by: Nate Hyson <CLDMV> (Shinrai@users.noreply.github.com)
9
+ * @Last modified time: 2025-11-21 14:47:33 -08:00 (1763765253)
10
+ * -----
11
+ * @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved.
12
+ */
13
+
14
+ // Development environment check (must happen before droidsock imports)
15
+ (async () => {
16
+ try {
17
+ await import("./devcheck.mjs");
18
+ } catch {
19
+ // ignore
20
+ }
21
+ })();
22
+
23
+ /**
24
+ * Creates a DroidSock instance for ADB communication
25
+ * @param {object} [options={}] - Configuration options
26
+ * @returns {Promise<object>} DroidSock instance
27
+ */
28
+ export default async function createDroidSock(options = {}) {
29
+ // Dynamic import after environment check
30
+ const mod = await import("@cldmv/droidsock/main");
31
+ const createDroidSockImpl = mod.default;
32
+ return await createDroidSockImpl(options);
33
+ }
34
+
35
+ /**
36
+ * Connect to a device
37
+ * @param {string} deviceId - Device ID to connect to
38
+ * @returns {Promise<object>} Connected device instance
39
+ */
40
+ export async function connect(deviceId) {
41
+ const mod = await import("@cldmv/droidsock/main");
42
+ return mod.connect(deviceId);
43
+ }
44
+
45
+ /**
46
+ * List available devices
47
+ * @returns {Promise<Array>} List of available devices
48
+ */
49
+ export async function listDevices() {
50
+ const mod = await import("@cldmv/droidsock/main");
51
+ return mod.listDevices();
52
+ }
53
+
54
+ // Named export aliases
55
+ export { createDroidSock as DroidSock };
56
+ export { createDroidSock as ADB };
57
+ export { createDroidSock as AndroidDebugBridge };
package/package.json ADDED
@@ -0,0 +1,118 @@
1
+ {
2
+ "name": "@cldmv/droidsock",
3
+ "version": "0.1.0",
4
+ "description": "Complete Node.js implementation of the Android Debug Bridge (ADB) protocol",
5
+ "main": "./index.cjs",
6
+ "module": "./index.mjs",
7
+ "types": "./types/index.d.mts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./types/index.d.mts",
11
+ "import": "./index.mjs",
12
+ "require": "./index.cjs"
13
+ },
14
+ "./devcheck": {
15
+ "types": "./types/devcheck.d.mts",
16
+ "import": "./devcheck.mjs"
17
+ },
18
+ "./main": {
19
+ "development": {
20
+ "types": "./types/src/droidsock.d.mts",
21
+ "import": "./src/droidsock.mjs"
22
+ },
23
+ "types": "./types/dist/droidsock.d.mts",
24
+ "import": "./dist/droidsock.mjs"
25
+ }
26
+ },
27
+ "type": "module",
28
+ "engines": {
29
+ "node": ">=18.12"
30
+ },
31
+ "scripts": {
32
+ "test": "vitest run --config .configs/vitest.config.mjs",
33
+ "test:run": "vitest run",
34
+ "test:coverage": "vitest run --coverage",
35
+ "test:types": "tsc --noEmit --project .configs/tsconfig.dts.jsonc",
36
+ "lint": "eslint --config .configs/eslint.config.mjs .",
37
+ "build": "node build.mjs",
38
+ "build:types": "tsc --project .configs/tsconfig.dts.jsonc",
39
+ "build:ci": "npm run build:types && npm run test:types && npm run build",
40
+ "precommit": "npm run build:types && npm run test:types && npm run lint && npm run test"
41
+ },
42
+ "keywords": [
43
+ "adb",
44
+ "android",
45
+ "debug",
46
+ "bridge",
47
+ "protocol",
48
+ "automation",
49
+ "mobile",
50
+ "android-tv",
51
+ "fire-tv",
52
+ "rsa",
53
+ "authentication",
54
+ "socket",
55
+ "tcp",
56
+ "nodejs",
57
+ "esm"
58
+ ],
59
+ "author": {
60
+ "name": "Shinrai",
61
+ "company": "CLDMV",
62
+ "email": "git+npm@cldmv.net",
63
+ "url": "https://cldmv.net"
64
+ },
65
+ "contributors": [
66
+ {
67
+ "name": "CLDMV",
68
+ "url": "https://github.com/CLDMV"
69
+ }
70
+ ],
71
+ "license": "Apache-2.0",
72
+ "funding": {
73
+ "type": "github",
74
+ "url": "https://github.com/sponsors/shinrai"
75
+ },
76
+ "repository": {
77
+ "type": "git",
78
+ "url": "git+https://github.com/CLDMV/droidsock.git"
79
+ },
80
+ "bugs": {
81
+ "url": "https://github.com/CLDMV/droidsock/issues"
82
+ },
83
+ "homepage": "https://github.com/CLDMV/droidsock#readme",
84
+ "publishConfig": {
85
+ "access": "public"
86
+ },
87
+ "files": [
88
+ "index.mjs",
89
+ "index.cjs",
90
+ "devcheck.mjs",
91
+ "README.md",
92
+ "LICENSE",
93
+ "types/dist/",
94
+ "types/index.d.mts",
95
+ "types/index.d.mts.map",
96
+ "types/devcheck.d.mts",
97
+ "dist/"
98
+ ],
99
+ "sideEffects": false,
100
+ "devDependencies": {
101
+ "@eslint/css": "^0.14.1",
102
+ "@eslint/js": "^9.39.1",
103
+ "@eslint/json": "^0.14.0",
104
+ "@eslint/markdown": "^7.5.1",
105
+ "@html-eslint/eslint-plugin": "^0.48.0",
106
+ "@html-eslint/parser": "^0.48.0",
107
+ "@types/node": "^20.0.0",
108
+ "@vitest/ui": "^4.0.8",
109
+ "eslint": "^9.39.1",
110
+ "globals": "^16.5.0",
111
+ "prettier": "^3.0.0",
112
+ "typescript": "^5.0.0",
113
+ "vitest": "^4.0.8"
114
+ },
115
+ "dependencies": {
116
+ "@cldmv/slothlet": "^2.6.1"
117
+ }
118
+ }