@cldmv/node-android-tv-remote 2.0.0 → 2.1.7
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/README.md +202 -25
- package/index.cjs +20 -9
- package/index.mjs +7 -6
- package/package.json +41 -7
- package/scripts/postinstall.mjs +16 -1
- package/scripts/setup-device.mjs +14 -1
- package/scripts/wake-tv.mjs +53 -0
- package/src/data/keyboard-keys.json +73 -0
- package/src/lib/android-tv-remote.mjs +981 -189
- package/.gitattributes +0 -8
- package/.prettierrc +0 -15
- package/docs/KEYBOARD_KEYS.md +0 -80
- package/docs/KEYCODES.md +0 -55
- package/eslint.config.mjs +0 -45
- package/src/lib/adb/setup.mjs +0 -291
- package/test/android-tv-remote.test.mjs +0 -87
- package/test/api-surface.test.mjs +0 -63
- package/test/connect-readall.mjs +0 -130
- package/test/dual/device1.mjs +0 -137
- package/test/dual/device2.mjs +0 -137
- package/test/dual/spawn-dual-servers.mjs +0 -214
- package/test/dual-device-ensureawake.mjs +0 -236
- package/test/event-system-demo.mjs +0 -106
- package/test/interactive-remote.mjs +0 -82
- package/test/retry-init-adb.test.mjs +0 -78
package/README.md
CHANGED
|
@@ -18,16 +18,21 @@
|
|
|
18
18
|
|
|
19
19
|
## Overview
|
|
20
20
|
|
|
21
|
-
A modern, **event-driven** Node.js module for controlling Android TV devices via ADB. Supports sending keycodes, keyboard input, and remote control commands. Designed for compatibility with a wide range of Android TV devices, including Fire TV, Chromecast with Google TV, and more.
|
|
21
|
+
A modern, **event-driven** Node.js module for controlling Android TV devices via ADB. Supports sending keycodes, comprehensive keyboard input (71 characters with smart shift detection), and remote control commands. Designed for compatibility with a wide range of Android TV devices, including Fire TV, Chromecast with Google TV, and more.
|
|
22
22
|
|
|
23
23
|
### Key Features
|
|
24
24
|
|
|
25
|
-
- 🎯 **Event-driven architecture** -
|
|
25
|
+
- 🎯 **Event-driven architecture** - Comprehensive event system with structured data
|
|
26
|
+
- ⌨️ **Comprehensive keyboard input** - 71 characters with smart shift detection and special symbols
|
|
26
27
|
- 🔄 **ESM & CommonJS support** - Works with both `import` and `require`
|
|
27
28
|
- 🛡️ **Error resilience** - Errors emit events instead of crashing your app
|
|
28
29
|
- 🔗 **Method chaining** - Fluent API for event listener management
|
|
29
30
|
- 📊 **Structured logging** - Timestamped, categorized log events with source tracking
|
|
30
31
|
- 🚀 **Promise-based** - Modern async/await support with callback compatibility
|
|
32
|
+
- 📸 **Advanced screencap** - High-performance PNG screenshots with resizing and thumbnails
|
|
33
|
+
- ⚡ **Performance optimized** - Direct PNG streaming with 20x speed improvements
|
|
34
|
+
- 🔄 **Device management** - Reboot, wake, settings configuration with event tracking
|
|
35
|
+
- 📱 **Universal compatibility** - Works with Fire TV, Chromecast, Shield, and more
|
|
31
36
|
|
|
32
37
|
## Installation
|
|
33
38
|
|
|
@@ -73,25 +78,25 @@ npm install android-tv-remote
|
|
|
73
78
|
### Basic Usage
|
|
74
79
|
|
|
75
80
|
```js
|
|
76
|
-
// ESM
|
|
81
|
+
// ESM (Node.js with type: "module" in package.json)
|
|
77
82
|
import createRemote from "android-tv-remote";
|
|
78
83
|
|
|
79
|
-
//
|
|
84
|
+
// CommonJS
|
|
80
85
|
const createRemote = require("android-tv-remote");
|
|
81
86
|
|
|
82
|
-
|
|
87
|
+
// Create remote (async function)
|
|
88
|
+
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
83
89
|
|
|
84
|
-
//
|
|
85
|
-
await remote.connect();
|
|
86
|
-
|
|
87
|
-
// Press Home
|
|
90
|
+
// Use with async/await (recommended)
|
|
88
91
|
await remote.press.home();
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
await remote.press.up();
|
|
93
|
+
await remote.press.ok();
|
|
94
|
+
|
|
95
|
+
// Or chain promises
|
|
96
|
+
createRemote({ ip: "192.168.1.100" })
|
|
97
|
+
.then((remote) => remote.press.home())
|
|
98
|
+
.then(() => remote.press.up())
|
|
99
|
+
.then(() => remote.press.ok());
|
|
95
100
|
```
|
|
96
101
|
|
|
97
102
|
### Event-Driven Usage (Recommended)
|
|
@@ -101,7 +106,7 @@ This module uses an **event-driven architecture** instead of console logging. Al
|
|
|
101
106
|
```js
|
|
102
107
|
import createRemote from "android-tv-remote";
|
|
103
108
|
|
|
104
|
-
const remote = createRemote({ ip: "192.168.1.100" });
|
|
109
|
+
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
105
110
|
|
|
106
111
|
// Listen for log events (info, warn, error, debug)
|
|
107
112
|
remote.on("log", (data) => {
|
|
@@ -118,20 +123,162 @@ remote.on("error", (data) => {
|
|
|
118
123
|
}
|
|
119
124
|
});
|
|
120
125
|
|
|
126
|
+
// Listen for screenshot events
|
|
127
|
+
remote.on("screencap-complete", (data) => {
|
|
128
|
+
console.log(`Screenshot completed in ${data.timing.total}ms`);
|
|
129
|
+
});
|
|
130
|
+
|
|
121
131
|
// Use the remote
|
|
122
132
|
await remote.press.home();
|
|
133
|
+
await remote.screencap({ filepath: "./screenshot.png" });
|
|
123
134
|
```
|
|
124
135
|
|
|
125
|
-
###
|
|
136
|
+
### Async Initialization
|
|
126
137
|
|
|
127
|
-
|
|
138
|
+
The createRemote function is async and returns a Promise:
|
|
128
139
|
|
|
129
140
|
```js
|
|
130
|
-
import
|
|
141
|
+
import createRemote from "android-tv-remote";
|
|
131
142
|
|
|
132
|
-
|
|
143
|
+
// Async initialization with await
|
|
144
|
+
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
133
145
|
remote.on("log", console.log);
|
|
134
146
|
await remote.press.play();
|
|
147
|
+
|
|
148
|
+
// Or use .then()
|
|
149
|
+
createRemote({ ip: "192.168.1.100" }).then((remote) => {
|
|
150
|
+
remote.on("log", console.log);
|
|
151
|
+
return remote.press.play();
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Screenshot Functionality
|
|
156
|
+
|
|
157
|
+
Advanced screencap with resizing, thumbnails, and file saving:
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
import createRemote from "android-tv-remote";
|
|
161
|
+
|
|
162
|
+
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
163
|
+
|
|
164
|
+
// Basic screenshot (returns PNG stream)
|
|
165
|
+
const stream = await remote.screencap();
|
|
166
|
+
|
|
167
|
+
// Screenshot with resizing
|
|
168
|
+
const resizedStream = await remote.screencap({ width: 1280, height: 720 });
|
|
169
|
+
|
|
170
|
+
// Save screenshot to file (non-blocking)
|
|
171
|
+
await remote.screencap({ filepath: "./screenshot.png" });
|
|
172
|
+
|
|
173
|
+
// Resized screenshot saved to file
|
|
174
|
+
await remote.screencap({
|
|
175
|
+
width: 640,
|
|
176
|
+
height: 360,
|
|
177
|
+
filepath: "./thumbnail.png"
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Quick thumbnail (default 240px width)
|
|
181
|
+
const thumbStream = await remote.thumbnail();
|
|
182
|
+
|
|
183
|
+
// Custom thumbnail dimensions
|
|
184
|
+
const customThumb = await remote.thumbnail({
|
|
185
|
+
width: 320,
|
|
186
|
+
height: 180,
|
|
187
|
+
filepath: "./thumb.png"
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Access last screenshot data
|
|
191
|
+
console.log("Last screenshot available:", !!remote.lastScreencapData);
|
|
192
|
+
|
|
193
|
+
// Listen for screenshot events
|
|
194
|
+
remote.on("screencap-complete", (data) => {
|
|
195
|
+
console.log(`Screenshot completed in ${data.timing.total}ms`);
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Device Management
|
|
200
|
+
|
|
201
|
+
Comprehensive device control with event tracking:
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
import createRemote from "android-tv-remote";
|
|
205
|
+
|
|
206
|
+
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
207
|
+
|
|
208
|
+
// Reboot the device
|
|
209
|
+
await remote.reboot();
|
|
210
|
+
|
|
211
|
+
// Ensure device is awake and responsive
|
|
212
|
+
const isAwake = await remote.ensureAwake();
|
|
213
|
+
|
|
214
|
+
// Configure optimal settings for remote control
|
|
215
|
+
await remote.setSettings(); // Set optimal settings
|
|
216
|
+
await remote.setSettings("get"); // Get current settings
|
|
217
|
+
|
|
218
|
+
// Wait for device to finish booting (after reboot)
|
|
219
|
+
await remote.waitBootComplete(60000); // 60 second timeout
|
|
220
|
+
|
|
221
|
+
// Connection management
|
|
222
|
+
await remote.connect();
|
|
223
|
+
console.log("Connected:", remote.isConnected);
|
|
224
|
+
await remote.disconnect();
|
|
225
|
+
|
|
226
|
+
// Listen for device management events
|
|
227
|
+
remote.on("log", (data) => {
|
|
228
|
+
if (data.source === "reboot") {
|
|
229
|
+
console.log(`Reboot: ${data.message}`);
|
|
230
|
+
}
|
|
231
|
+
if (data.source === "ensureAwake") {
|
|
232
|
+
console.log(`Wake: ${data.message}`);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Keyboard Input
|
|
238
|
+
|
|
239
|
+
Comprehensive text input with individual key support and smart shift detection:
|
|
240
|
+
|
|
241
|
+
```js
|
|
242
|
+
import createRemote from "android-tv-remote";
|
|
243
|
+
|
|
244
|
+
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
245
|
+
|
|
246
|
+
// Text input (recommended for typing sentences)
|
|
247
|
+
await remote.keyboard.text("Hello World!");
|
|
248
|
+
await remote.keyboard.text("user@example.com");
|
|
249
|
+
|
|
250
|
+
// Individual character input
|
|
251
|
+
await remote.keyboard.key.h(); // Types "h"
|
|
252
|
+
await remote.keyboard.key.e(); // Types "e"
|
|
253
|
+
await remote.keyboard.key.l(); // Types "l"
|
|
254
|
+
await remote.keyboard.key.l(); // Types "l"
|
|
255
|
+
await remote.keyboard.key.o(); // Types "o"
|
|
256
|
+
|
|
257
|
+
// Shifted characters (only available for keys that change when shifted)
|
|
258
|
+
await remote.keyboard.key.shift.h(); // Types "H"
|
|
259
|
+
await remote.keyboard.key.shift.one(); // Types "!"
|
|
260
|
+
await remote.keyboard.key.shift.semicolon(); // Types ":"
|
|
261
|
+
|
|
262
|
+
// Special characters and symbols
|
|
263
|
+
await remote.keyboard.key.space(); // Types " "
|
|
264
|
+
await remote.keyboard.key.exclamation(); // Types "!"
|
|
265
|
+
await remote.keyboard.key.at(); // Types "@"
|
|
266
|
+
await remote.keyboard.key.hash(); // Types "#"
|
|
267
|
+
await remote.keyboard.key.dollar(); // Types "$"
|
|
268
|
+
|
|
269
|
+
// Control keys
|
|
270
|
+
await remote.keyboard.key.tab(); // Tab character
|
|
271
|
+
await remote.keyboard.key.enter(); // Enter/Return
|
|
272
|
+
await remote.keyboard.key.backspace(); // Backspace
|
|
273
|
+
|
|
274
|
+
// Using keycode fallback (when available for regular keys)
|
|
275
|
+
await remote.keyboard.key.a.keycode(); // Sends keycode instead of character
|
|
276
|
+
|
|
277
|
+
// Note: Shift variants are only available for keys that actually change
|
|
278
|
+
// when shifted (letters, numbers, and some symbols). Special characters
|
|
279
|
+
// like @, #, !, etc. don't have shift variants since they're already
|
|
280
|
+
// the shifted form. Shift keys only support text input, not keycodes,
|
|
281
|
+
// since Android ADB doesn't support sending multiple keycodes simultaneously.
|
|
135
282
|
```
|
|
136
283
|
|
|
137
284
|
### Event Data Structure
|
|
@@ -142,7 +289,7 @@ await remote.press.play();
|
|
|
142
289
|
{
|
|
143
290
|
level: 'info' | 'warn' | 'error' | 'debug',
|
|
144
291
|
message: 'Human readable message',
|
|
145
|
-
source: 'connect' | 'disconnect' | '
|
|
292
|
+
source: 'connect' | 'disconnect' | 'screencap' | 'reboot' | 'ensureAwake' | etc,
|
|
146
293
|
timestamp: '2025-10-15T18:37:44.854Z',
|
|
147
294
|
data?: any // Optional additional data
|
|
148
295
|
}
|
|
@@ -153,12 +300,30 @@ await remote.press.play();
|
|
|
153
300
|
```js
|
|
154
301
|
{
|
|
155
302
|
error: Error, // The actual error object
|
|
156
|
-
source: 'connect' | 'adb' | '
|
|
303
|
+
source: 'connect' | 'adb' | 'screencap' | 'reboot' | etc,
|
|
157
304
|
message: 'Human readable error message',
|
|
158
305
|
timestamp: '2025-10-15T18:37:44.854Z'
|
|
159
306
|
}
|
|
160
307
|
```
|
|
161
308
|
|
|
309
|
+
**Screenshot Events:**
|
|
310
|
+
|
|
311
|
+
```js
|
|
312
|
+
// screencap-complete event
|
|
313
|
+
{
|
|
314
|
+
timestamp: '2025-10-15T18:37:44.854Z',
|
|
315
|
+
filepath?: './screenshot.png', // If saved to file
|
|
316
|
+
processed: true, // Whether Sharp processing was used
|
|
317
|
+
width?: 1280,
|
|
318
|
+
height?: 720,
|
|
319
|
+
timing: {
|
|
320
|
+
capture: 25.4, // ADB capture time in ms
|
|
321
|
+
sharpProcess?: 1.2, // Sharp processing time in ms
|
|
322
|
+
total: 26.6 // Total operation time in ms
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
162
327
|
## API
|
|
163
328
|
|
|
164
329
|
### Main Methods
|
|
@@ -166,10 +331,15 @@ await remote.press.play();
|
|
|
166
331
|
- `connect()` / `disconnect()` - Device connection management
|
|
167
332
|
- `press.<key>()` / `press.long.<key>()` - Remote control buttons
|
|
168
333
|
- `keyboard.text(text)` - Text input
|
|
169
|
-
- `keyboard.key.<key>()` / `keyboard.key.<key>.keycode()` - Individual keys
|
|
170
|
-
- `keyboard.key.shift.<key>()`
|
|
334
|
+
- `keyboard.key.<key>()` / `keyboard.key.<key>.keycode()` - Individual keys (71 available)
|
|
335
|
+
- `keyboard.key.shift.<key>()` - Shifted keys (47 available, text input only)
|
|
171
336
|
- `inputKeycode(code)` - Raw Android keycodes
|
|
172
|
-
- `
|
|
337
|
+
- `reboot()` - Reboot the Android TV device
|
|
338
|
+
- `ensureAwake()` - Ensure device is awake and responsive
|
|
339
|
+
- `setSettings(mode)` - Configure optimal Android TV settings
|
|
340
|
+
- `waitBootComplete(timeout)` - Wait for device boot completion
|
|
341
|
+
- `screencap(options)` - Take PNG screenshots with optional resizing and file saving
|
|
342
|
+
- `thumbnail(options)` - Take thumbnail screenshots (default 240px width)
|
|
173
343
|
|
|
174
344
|
### Event Methods
|
|
175
345
|
|
|
@@ -182,11 +352,18 @@ await remote.press.play();
|
|
|
182
352
|
|
|
183
353
|
- `log` - Emitted for all operations (info, warn, error, debug levels)
|
|
184
354
|
- `error` - Emitted when errors occur (structured error data)
|
|
355
|
+
- `screencap-start` - Emitted when screenshot capture begins
|
|
356
|
+
- `screencap-captured` - Emitted when raw screenshot is captured
|
|
357
|
+
- `screencap-processing` - Emitted when image processing begins
|
|
358
|
+
- `screencap-ready` - Emitted when processed stream is ready
|
|
359
|
+
- `screencap-saved` - Emitted when screenshot is saved to file
|
|
360
|
+
- `screencap-complete` - Emitted when entire screenshot operation completes
|
|
185
361
|
|
|
186
362
|
### Properties
|
|
187
363
|
|
|
188
364
|
- `isConnected` - Boolean indicating connection status
|
|
189
365
|
- `initPromise` - Promise that resolves when initialization completes
|
|
366
|
+
- `lastScreencapData` - Buffer/Stream containing the last captured screenshot data
|
|
190
367
|
|
|
191
368
|
See JSDoc comments in source code for full API documentation.
|
|
192
369
|
|
package/index.cjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
+
*
|
|
2
3
|
* @Project: @cldmv/node-android-tv-remote
|
|
3
4
|
* @Filename: /index.cjs
|
|
4
|
-
* @Date: 2025-10-
|
|
5
|
-
* @Author: Nate
|
|
5
|
+
* @Date: 2025-10-15T10:29:19-07:00 (1760549359)
|
|
6
|
+
* @Author: Nate Corcoran <CLDMV>
|
|
6
7
|
* @Email: <Shinrai@users.noreply.github.com>
|
|
7
8
|
* -----
|
|
8
|
-
* @Last modified by: Nate
|
|
9
|
-
* @Last modified time:
|
|
9
|
+
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
+
* @Last modified time: 2026-10-02T12:16:13-07:00 (1790968573)
|
|
10
11
|
* -----
|
|
11
|
-
* @Copyright: Copyright (c) 2013-
|
|
12
|
+
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
+
*
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -19,13 +21,22 @@
|
|
|
19
21
|
*
|
|
20
22
|
* @module @cldmv/node-android-tv-remote/cjs
|
|
21
23
|
*/
|
|
24
|
+
"use strict";
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
// index.cjs is a thin wrapper: it loads index.mjs through Node's synchronous require(esm).
|
|
27
|
+
// Node.js versions without require(esm) would fail with a bare ERR_REQUIRE_ESM, so fail
|
|
28
|
+
// early with a message that says what to do instead.
|
|
29
|
+
if (!process.features?.require_module) {
|
|
30
|
+
const error = new Error(
|
|
31
|
+
`@cldmv/node-android-tv-remote: require() needs Node.js ^20.19.0 or >=22.12.0 (this is ${process.version}). On older Node.js, load the package with import() instead.`
|
|
32
|
+
);
|
|
33
|
+
error.code = "ERR_REQUIRE_ESM";
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
25
36
|
|
|
26
|
-
const { default: createRemote,
|
|
37
|
+
const { default: createRemote, createAndroidTVRemote } = require("./index.mjs");
|
|
27
38
|
|
|
28
39
|
module.exports = createRemote;
|
|
29
40
|
module.exports.createRemote = createRemote;
|
|
30
|
-
module.exports.
|
|
41
|
+
module.exports.createAndroidTVRemote = createAndroidTVRemote;
|
|
31
42
|
module.exports.default = createRemote;
|
package/index.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
+
*
|
|
2
3
|
* @Project: @cldmv/node-android-tv-remote
|
|
3
4
|
* @Filename: /index.mjs
|
|
4
|
-
* @Date: 2025-10-
|
|
5
|
-
* @Author: Nate
|
|
5
|
+
* @Date: 2025-10-15T10:29:19-07:00 (1760549359)
|
|
6
|
+
* @Author: Nate Corcoran <CLDMV>
|
|
6
7
|
* @Email: <Shinrai@users.noreply.github.com>
|
|
7
8
|
* -----
|
|
8
|
-
* @Last modified by: Nate
|
|
9
|
-
* @Last modified time:
|
|
9
|
+
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
+
* @Last modified time: 2026-10-02T12:16:14-07:00 (1790968574)
|
|
10
11
|
* -----
|
|
11
|
-
* @Copyright: Copyright (c) 2013-
|
|
12
|
+
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
+
*
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -22,4 +24,3 @@
|
|
|
22
24
|
|
|
23
25
|
export { default } from "./src/lib/android-tv-remote.mjs";
|
|
24
26
|
export { default as createRemote, createAndroidTVRemote } from "./src/lib/android-tv-remote.mjs";
|
|
25
|
-
export { default as AndroidTVSetup } from "./src/lib/adb/setup.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cldmv/node-android-tv-remote",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "A Node.js library for controlling Android TV devices via ADB keycodes and text input.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -10,9 +10,20 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "jest",
|
|
14
13
|
"postinstall": "node scripts/postinstall.mjs",
|
|
15
|
-
"setup-device": "node scripts/setup-device.mjs"
|
|
14
|
+
"setup-device": "node scripts/setup-device.mjs",
|
|
15
|
+
"build": "echo '✓ no build step'",
|
|
16
|
+
"build:ci": "echo '✓ no build step'",
|
|
17
|
+
"test": "node tests/run-vitest.mjs && npm run test:cjs",
|
|
18
|
+
"test:cjs": "node --test tests/cjs/entry.test.cjs",
|
|
19
|
+
"test:watch": "vitest --config .configs/vitest.config.mjs",
|
|
20
|
+
"coverage": "node tests/run-vitest.mjs --coverage-quiet && npm run test:cjs",
|
|
21
|
+
"ci:coverage": "npm run coverage",
|
|
22
|
+
"lint": "eslint --config eslint.config.mjs .",
|
|
23
|
+
"lint:fix": "eslint --config eslint.config.mjs . --fix",
|
|
24
|
+
"format": "prettier --config .prettierrc --write .",
|
|
25
|
+
"format:check": "prettier --config .prettierrc --check .",
|
|
26
|
+
"fix:headers": "fix-headers --config .configs/fix-headers.json"
|
|
16
27
|
},
|
|
17
28
|
"keywords": [
|
|
18
29
|
"android",
|
|
@@ -42,13 +53,36 @@
|
|
|
42
53
|
},
|
|
43
54
|
"homepage": "https://github.com/CLDMV/node-android-tv-remote#readme",
|
|
44
55
|
"license": "MIT",
|
|
56
|
+
"files": [
|
|
57
|
+
"src/",
|
|
58
|
+
"scripts/",
|
|
59
|
+
"index.mjs",
|
|
60
|
+
"index.cjs",
|
|
61
|
+
"README.md",
|
|
62
|
+
"package.json"
|
|
63
|
+
],
|
|
45
64
|
"dependencies": {
|
|
46
|
-
"@devicefarmer/adbkit": "^3.3.8"
|
|
47
|
-
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"jest": "^30.0.5"
|
|
65
|
+
"@devicefarmer/adbkit": "^3.3.8",
|
|
66
|
+
"sharp": "^0.35.3"
|
|
50
67
|
},
|
|
51
68
|
"publishConfig": {
|
|
52
69
|
"access": "public"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=20.9.0"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@cldmv/configs": "^1.2.0",
|
|
76
|
+
"@cldmv/fix-headers": "^2.1.1",
|
|
77
|
+
"@cldmv/vitest-runner": "^1.2.0",
|
|
78
|
+
"@eslint/css": "^2.0.0",
|
|
79
|
+
"@eslint/js": "^10.0.1",
|
|
80
|
+
"@eslint/json": "^2.0.1",
|
|
81
|
+
"@eslint/markdown": "^8.0.3",
|
|
82
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
83
|
+
"eslint": "^10.8.0",
|
|
84
|
+
"globals": "^17.9.0",
|
|
85
|
+
"prettier": "^3.9.6",
|
|
86
|
+
"vitest": "^5.0.0"
|
|
53
87
|
}
|
|
54
88
|
}
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @Project: @cldmv/node-android-tv-remote
|
|
4
|
+
* @Filename: /scripts/postinstall.mjs
|
|
5
|
+
* @Date: 2025-10-15T10:19:05-07:00 (1760548745)
|
|
6
|
+
* @Author: Nate Corcoran <CLDMV>
|
|
7
|
+
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
|
+
* -----
|
|
9
|
+
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
+
* @Last modified time: 2026-10-02T12:16:14-07:00 (1790968574)
|
|
11
|
+
* -----
|
|
12
|
+
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* Postinstall script to check for adb and print install instructions if missing.
|
|
3
18
|
*/
|
|
@@ -8,7 +23,7 @@ function hasAdb() {
|
|
|
8
23
|
try {
|
|
9
24
|
execSync("adb version", { stdio: "ignore" });
|
|
10
25
|
return true;
|
|
11
|
-
} catch (
|
|
26
|
+
} catch (_) {
|
|
12
27
|
return false;
|
|
13
28
|
}
|
|
14
29
|
}
|
package/scripts/setup-device.mjs
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @Project: @cldmv/node-android-tv-remote
|
|
4
|
+
* @Filename: /scripts/setup-device.mjs
|
|
5
|
+
* @Date: 2025-10-15T10:19:05-07:00 (1760548745)
|
|
6
|
+
* @Author: Nate Corcoran <CLDMV>
|
|
7
|
+
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
|
+
* -----
|
|
9
|
+
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
+
* @Last modified time: 2026-10-02T12:16:14-07:00 (1790968574)
|
|
11
|
+
* -----
|
|
12
|
+
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
2
15
|
|
|
3
16
|
import readline from "readline";
|
|
4
17
|
import AndroidTVSetup from "../src/lib/adb/setup.mjs";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @Project: @cldmv/node-android-tv-remote
|
|
4
|
+
* @Filename: /scripts/wake-tv.mjs
|
|
5
|
+
* @Date: 2025-10-15T20:44:49-07:00 (1760586289)
|
|
6
|
+
* @Author: Nate Corcoran <CLDMV>
|
|
7
|
+
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
|
+
* -----
|
|
9
|
+
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
+
* @Last modified time: 2026-10-02T12:16:14-07:00 (1790968574)
|
|
11
|
+
* -----
|
|
12
|
+
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Wake up Android TV/Fire TV script
|
|
18
|
+
* Usage: node wake-tv.mjs <ip_address>
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import createRemote from "../src/lib/android-tv-remote.mjs";
|
|
22
|
+
|
|
23
|
+
// Get IP address from command line arguments
|
|
24
|
+
const ip = process.argv[2];
|
|
25
|
+
|
|
26
|
+
if (!ip) {
|
|
27
|
+
console.error("❌ Usage: node wake-tv.mjs <ip_address>");
|
|
28
|
+
console.error(" Example: node wake-tv.mjs 10.6.0.133");
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log(`🔌 Waking up TV at ${ip}...`);
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const remote = await createRemote({
|
|
36
|
+
ip: ip,
|
|
37
|
+
autoConnect: true,
|
|
38
|
+
quiet: false
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
console.log("✅ Connected to device");
|
|
42
|
+
|
|
43
|
+
// Wake up the device
|
|
44
|
+
await remote.ensureAwake();
|
|
45
|
+
console.log("🎉 TV should now be awake and ready!");
|
|
46
|
+
|
|
47
|
+
// Disconnect
|
|
48
|
+
await remote.disconnect();
|
|
49
|
+
console.log("✅ Disconnected from device");
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error("❌ Failed to wake up TV:", error.message);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"a": "a",
|
|
3
|
+
"b": "b",
|
|
4
|
+
"c": "c",
|
|
5
|
+
"d": "d",
|
|
6
|
+
"e": "e",
|
|
7
|
+
"f": "f",
|
|
8
|
+
"g": "g",
|
|
9
|
+
"h": "h",
|
|
10
|
+
"i": "i",
|
|
11
|
+
"j": "j",
|
|
12
|
+
"k": "k",
|
|
13
|
+
"l": "l",
|
|
14
|
+
"m": "m",
|
|
15
|
+
"n": "n",
|
|
16
|
+
"o": "o",
|
|
17
|
+
"p": "p",
|
|
18
|
+
"q": "q",
|
|
19
|
+
"r": "r",
|
|
20
|
+
"s": "s",
|
|
21
|
+
"t": "t",
|
|
22
|
+
"u": "u",
|
|
23
|
+
"v": "v",
|
|
24
|
+
"w": "w",
|
|
25
|
+
"x": "x",
|
|
26
|
+
"y": "y",
|
|
27
|
+
"z": "z",
|
|
28
|
+
"0": "0",
|
|
29
|
+
"1": "1",
|
|
30
|
+
"2": "2",
|
|
31
|
+
"3": "3",
|
|
32
|
+
"4": "4",
|
|
33
|
+
"5": "5",
|
|
34
|
+
"6": "6",
|
|
35
|
+
"7": "7",
|
|
36
|
+
"8": "8",
|
|
37
|
+
"9": "9",
|
|
38
|
+
"space": " ",
|
|
39
|
+
"comma": ",",
|
|
40
|
+
"period": ".",
|
|
41
|
+
"semicolon": ";",
|
|
42
|
+
"apostrophe": "'",
|
|
43
|
+
"slash": "/",
|
|
44
|
+
"backslash": "\\",
|
|
45
|
+
"leftBracket": "[",
|
|
46
|
+
"rightBracket": "]",
|
|
47
|
+
"minus": "-",
|
|
48
|
+
"equals": "=",
|
|
49
|
+
"grave": "`",
|
|
50
|
+
"tab": "\t",
|
|
51
|
+
"enter": "\n",
|
|
52
|
+
"exclamation": "!",
|
|
53
|
+
"at": "@",
|
|
54
|
+
"hash": "#",
|
|
55
|
+
"dollar": "$",
|
|
56
|
+
"percent": "%",
|
|
57
|
+
"caret": "^",
|
|
58
|
+
"ampersand": "&",
|
|
59
|
+
"asterisk": "*",
|
|
60
|
+
"leftParen": "(",
|
|
61
|
+
"rightParen": ")",
|
|
62
|
+
"underscore": "_",
|
|
63
|
+
"plus": "+",
|
|
64
|
+
"leftBrace": "{",
|
|
65
|
+
"rightBrace": "}",
|
|
66
|
+
"pipe": "|",
|
|
67
|
+
"colon": ":",
|
|
68
|
+
"quote": "\"",
|
|
69
|
+
"lessThan": "<",
|
|
70
|
+
"greaterThan": ">",
|
|
71
|
+
"question": "?",
|
|
72
|
+
"tilde": "~"
|
|
73
|
+
}
|