@cldmv/node-android-tv-remote 2.1.0 → 2.1.8
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 +202 -0
- package/README.md +188 -88
- package/index.cjs +20 -8
- package/index.mjs +7 -5
- package/package.json +31 -9
- package/scripts/postinstall.mjs +51 -36
- package/scripts/setup-device.mjs +62 -16
- package/scripts/wake-tv.mjs +45 -29
- package/src/lib/android-tv-remote.mjs +349 -258
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,31 +1,45 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cldmv/node-android-tv-remote
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**@cldmv/node-android-tv-remote** is a modern, **event-driven** Node.js module for controlling Android TV devices via ADB. It supports sending keycodes, comprehensive keyboard input (71 characters with smart shift detection), remote control commands, screenshots and device management. It is designed for compatibility with a wide range of Android TV devices, including Fire TV, Chromecast with Google TV, Nvidia Shield and more.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Every remote is an event source: operations report through structured `log` events and failures through structured `error` events instead of writing to the console, so the library slots into an application's own logging and error handling.
|
|
6
|
+
|
|
7
|
+
> _Drive any Android TV from Node.js — keys, text, screenshots and power — over ADB._
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
[![npm version]][npm_version_url] [![npm downloads]][npm_downloads_url] [![GitHub downloads]][github_downloads_url] [![Last commit]][last_commit_url] [![npm last update]][npm_last_update_url] [![coverage]][coverage_url]
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
- [Installation](#installation)
|
|
11
|
-
- [Usage](#usage)
|
|
12
|
-
- [API](#api)
|
|
13
|
-
- [Supported Devices](#supported-devices)
|
|
14
|
-
- [Keyboard Keys](./docs/KEYBOARD_KEYS.md)
|
|
15
|
-
- [Keycodes](./docs/KEYCODES.md)
|
|
11
|
+
[![Contributors]][contributors_url] [![Sponsor shinrai]][sponsor_url]
|
|
16
12
|
|
|
17
13
|
---
|
|
18
14
|
|
|
19
|
-
##
|
|
15
|
+
## ✨ What's New
|
|
16
|
+
|
|
17
|
+
### Latest: v2.1.8 (October 2026)
|
|
18
|
+
|
|
19
|
+
- **Independent remotes, and no crash on an unheard error** — each remote now has its own event emitter, so two TVs no longer receive each other's events. An `error` with no listener is logged (a `log` event with level `"error"`, and `NODE_DEBUG=android-tv-remote`) instead of thrown, while the failing call still rejects ([#46](https://github.com/CLDMV/node-android-tv-remote/pull/46)).
|
|
20
|
+
- **`npm run setup-device` works again** — the script, broken since v2.1.0, now runs the setup steps through the v2 remote ([#45](https://github.com/CLDMV/node-android-tv-remote/pull/45)). The package is also relicensed under Apache-2.0 ([#41](https://github.com/CLDMV/node-android-tv-remote/pull/41)).
|
|
21
|
+
- **Header tooling on fix-headers 2.2.0** — the `@cldmv/fix-headers` and `@cldmv/configs` dev dependencies move to 2.2.0 and 1.2.4, so `@Last modified by` now follows content edits only; no file was restamped ([#50](https://github.com/CLDMV/node-android-tv-remote/pull/50), [#52](https://github.com/CLDMV/node-android-tv-remote/pull/52)).
|
|
22
|
+
- [View full v2.1.8 Changelog](https://github.com/CLDMV/node-android-tv-remote/blob/master/docs/changelog/v2/v2.1.8.md)
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
### Recent Releases
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
- **v2.1.7** (October 2026) — CommonJS entry loads the ESM build directly, fails clearly without `require(esm)`, and exports `createAndroidTVRemote` ([Changelog](https://github.com/CLDMV/node-android-tv-remote/blob/master/docs/changelog/v2/v2.1.7.md))
|
|
27
|
+
- **v2.1.6** (October 2026) — CI only: the in-repo PR mirror job runs instead of being skipped; `sharp` lockfile and `@cldmv/vitest-runner` bumps ([Changelog](https://github.com/CLDMV/node-android-tv-remote/blob/master/docs/changelog/v2/v2.1.6.md))
|
|
28
|
+
- **v2.1.5** (October 2026) — maintenance: v4.29.2 workflow sync with bundle-size measurement, required-check mirror fix, uniform file headers; no runtime change ([Changelog](https://github.com/CLDMV/node-android-tv-remote/blob/master/docs/changelog/v2/v2.1.5.md))
|
|
29
|
+
- **v2.1.4** (September 2026) — `@devicefarmer/adbkit` 3.3.9 in the lockfile, dead code removed from the screencap path, bot signing secrets wired into the release workflows ([Changelog](https://github.com/CLDMV/node-android-tv-remote/blob/master/docs/changelog/v2/v2.1.4.md))
|
|
30
|
+
|
|
31
|
+
> **Note:** v2.1.1 through v2.1.6 were released on GitHub but never published to npm; npm went from v2.1.0 straight to v2.1.7. See the changelogs for what changed in between, including the Node.js 20.9.0 floor from v2.1.1.
|
|
32
|
+
|
|
33
|
+
📚 **For complete version history and detailed release notes, see the [docs/changelog/](https://github.com/CLDMV/node-android-tv-remote/tree/master/docs/changelog/) folder.**
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🚀 Key Features
|
|
24
38
|
|
|
25
39
|
- 🎯 **Event-driven architecture** - Comprehensive event system with structured data
|
|
26
40
|
- ⌨️ **Comprehensive keyboard input** - 71 characters with smart shift detection and special symbols
|
|
27
41
|
- 🔄 **ESM & CommonJS support** - Works with both `import` and `require`
|
|
28
|
-
- 🛡️ **Error resilience** - Errors
|
|
42
|
+
- 🛡️ **Error resilience** - Errors are reported as events instead of crashing your app; an `error` listener is optional (see [Event-Driven Usage](#event-driven-usage-recommended))
|
|
29
43
|
- 🔗 **Method chaining** - Fluent API for event listener management
|
|
30
44
|
- 📊 **Structured logging** - Timestamped, categorized log events with source tracking
|
|
31
45
|
- 🚀 **Promise-based** - Modern async/await support with callback compatibility
|
|
@@ -34,9 +48,22 @@ A modern, **event-driven** Node.js module for controlling Android TV devices via
|
|
|
34
48
|
- 🔄 **Device management** - Reboot, wake, settings configuration with event tracking
|
|
35
49
|
- 📱 **Universal compatibility** - Works with Fire TV, Chromecast, Shield, and more
|
|
36
50
|
|
|
37
|
-
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 📦 Installation
|
|
54
|
+
|
|
55
|
+
### Requirements
|
|
38
56
|
|
|
39
|
-
|
|
57
|
+
- **Node.js 20.9.0 or higher** for ESM `import` (the package's `engines` floor, set by the `sharp` dependency).
|
|
58
|
+
- **`require()`** loads the ESM build through Node's `require(esm)`, so it needs **Node.js ^20.19.0 or >=22.12.0**. On older Node.js, load the package with `import()` instead.
|
|
59
|
+
- The **Android Debug Bridge (ADB)** binary installed and available in your system PATH (see below). A `postinstall` check prints install instructions when `adb` is missing.
|
|
60
|
+
- `sharp` installs a platform-specific prebuilt binary; the install environment must be able to fetch it.
|
|
61
|
+
|
|
62
|
+
### Install
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
npm install @cldmv/node-android-tv-remote
|
|
66
|
+
```
|
|
40
67
|
|
|
41
68
|
### Install ADB
|
|
42
69
|
|
|
@@ -67,23 +94,16 @@ This module requires the Android Debug Bridge (ADB) binary to be installed and a
|
|
|
67
94
|
|
|
68
95
|
> **Note:** You must accept the ADB authorization prompt on your Android TV device the first time you connect.
|
|
69
96
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
```sh
|
|
73
|
-
npm install android-tv-remote
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Usage
|
|
97
|
+
---
|
|
77
98
|
|
|
78
|
-
|
|
99
|
+
## 🚀 Quick Start
|
|
79
100
|
|
|
80
|
-
```js
|
|
81
101
|
```js
|
|
82
102
|
// ESM (Node.js with type: "module" in package.json)
|
|
83
|
-
import createRemote from "android-tv-remote";
|
|
103
|
+
import createRemote from "@cldmv/node-android-tv-remote";
|
|
84
104
|
|
|
85
105
|
// CommonJS
|
|
86
|
-
const createRemote = require("android-tv-remote");
|
|
106
|
+
const createRemote = require("@cldmv/node-android-tv-remote");
|
|
87
107
|
|
|
88
108
|
// Create remote (async function)
|
|
89
109
|
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
@@ -94,19 +114,32 @@ await remote.press.up();
|
|
|
94
114
|
await remote.press.ok();
|
|
95
115
|
|
|
96
116
|
// Or chain promises
|
|
97
|
-
createRemote({ ip: "192.168.1.100" })
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
createRemote({ ip: "192.168.1.100" }).then(async (remote) => {
|
|
118
|
+
await remote.press.home();
|
|
119
|
+
await remote.press.up();
|
|
120
|
+
await remote.press.ok();
|
|
121
|
+
});
|
|
101
122
|
```
|
|
123
|
+
|
|
124
|
+
`createAndroidTVRemote(config)` is an alias of `createRemote(config)`, exported by name from both entries:
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
import { createAndroidTVRemote } from "@cldmv/node-android-tv-remote";
|
|
128
|
+
// or: const { createAndroidTVRemote } = require("@cldmv/node-android-tv-remote");
|
|
129
|
+
|
|
130
|
+
const remote = await createAndroidTVRemote({ ip: "192.168.1.100" });
|
|
102
131
|
```
|
|
103
132
|
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 🎯 Usage
|
|
136
|
+
|
|
104
137
|
### Event-Driven Usage (Recommended)
|
|
105
138
|
|
|
106
|
-
This module uses an **event-driven architecture** instead of console logging. All operations emit structured events that you can listen to:
|
|
139
|
+
This module uses an **event-driven architecture** instead of console logging. All operations emit structured events that you can listen to. The remote is a Node.js event emitter, but an `error` event is only emitted when a listener is attached, so an `error` listener is optional. Without one, the error is emitted as a `log` event with `level: 'error'` and written to `NODE_DEBUG=android-tv-remote`. Register an `error` listener to handle failures yourself:
|
|
107
140
|
|
|
108
141
|
```js
|
|
109
|
-
import createRemote from "android-tv-remote";
|
|
142
|
+
import createRemote from "@cldmv/node-android-tv-remote";
|
|
110
143
|
|
|
111
144
|
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
112
145
|
|
|
@@ -132,7 +165,7 @@ remote.on("screencap-complete", (data) => {
|
|
|
132
165
|
|
|
133
166
|
// Use the remote
|
|
134
167
|
await remote.press.home();
|
|
135
|
-
await remote.screencap({ filepath:
|
|
168
|
+
await remote.screencap({ filepath: "./screenshot.png" });
|
|
136
169
|
```
|
|
137
170
|
|
|
138
171
|
### Async Initialization
|
|
@@ -140,7 +173,7 @@ await remote.screencap({ filepath: './screenshot.png' });
|
|
|
140
173
|
The createRemote function is async and returns a Promise:
|
|
141
174
|
|
|
142
175
|
```js
|
|
143
|
-
import createRemote from "android-tv-remote";
|
|
176
|
+
import createRemote from "@cldmv/node-android-tv-remote";
|
|
144
177
|
|
|
145
178
|
// Async initialization with await
|
|
146
179
|
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
@@ -148,11 +181,10 @@ remote.on("log", console.log);
|
|
|
148
181
|
await remote.press.play();
|
|
149
182
|
|
|
150
183
|
// Or use .then()
|
|
151
|
-
createRemote({ ip: "192.168.1.100" })
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
});
|
|
184
|
+
createRemote({ ip: "192.168.1.100" }).then((remote) => {
|
|
185
|
+
remote.on("log", console.log);
|
|
186
|
+
return remote.press.play();
|
|
187
|
+
});
|
|
156
188
|
```
|
|
157
189
|
|
|
158
190
|
### Screenshot Functionality
|
|
@@ -160,7 +192,7 @@ createRemote({ ip: "192.168.1.100" })
|
|
|
160
192
|
Advanced screencap with resizing, thumbnails, and file saving:
|
|
161
193
|
|
|
162
194
|
```js
|
|
163
|
-
import createRemote from "android-tv-remote";
|
|
195
|
+
import createRemote from "@cldmv/node-android-tv-remote";
|
|
164
196
|
|
|
165
197
|
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
166
198
|
|
|
@@ -171,31 +203,31 @@ const stream = await remote.screencap();
|
|
|
171
203
|
const resizedStream = await remote.screencap({ width: 1280, height: 720 });
|
|
172
204
|
|
|
173
205
|
// Save screenshot to file (non-blocking)
|
|
174
|
-
await remote.screencap({ filepath:
|
|
206
|
+
await remote.screencap({ filepath: "./screenshot.png" });
|
|
175
207
|
|
|
176
208
|
// Resized screenshot saved to file
|
|
177
|
-
await remote.screencap({
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
209
|
+
await remote.screencap({
|
|
210
|
+
width: 640,
|
|
211
|
+
height: 360,
|
|
212
|
+
filepath: "./thumbnail.png"
|
|
181
213
|
});
|
|
182
214
|
|
|
183
215
|
// Quick thumbnail (default 240px width)
|
|
184
216
|
const thumbStream = await remote.thumbnail();
|
|
185
217
|
|
|
186
218
|
// Custom thumbnail dimensions
|
|
187
|
-
const customThumb = await remote.thumbnail({
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
219
|
+
const customThumb = await remote.thumbnail({
|
|
220
|
+
width: 320,
|
|
221
|
+
height: 180,
|
|
222
|
+
filepath: "./thumb.png"
|
|
191
223
|
});
|
|
192
224
|
|
|
193
225
|
// Access last screenshot data
|
|
194
|
-
console.log(
|
|
226
|
+
console.log("Last screenshot available:", !!remote.lastScreencapData);
|
|
195
227
|
|
|
196
228
|
// Listen for screenshot events
|
|
197
|
-
remote.on(
|
|
198
|
-
|
|
229
|
+
remote.on("screencap-complete", (data) => {
|
|
230
|
+
console.log(`Screenshot completed in ${data.timing.total}ms`);
|
|
199
231
|
});
|
|
200
232
|
```
|
|
201
233
|
|
|
@@ -204,7 +236,7 @@ remote.on('screencap-complete', (data) => {
|
|
|
204
236
|
Comprehensive device control with event tracking:
|
|
205
237
|
|
|
206
238
|
```js
|
|
207
|
-
import createRemote from "android-tv-remote";
|
|
239
|
+
import createRemote from "@cldmv/node-android-tv-remote";
|
|
208
240
|
|
|
209
241
|
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
210
242
|
|
|
@@ -216,24 +248,24 @@ const isAwake = await remote.ensureAwake();
|
|
|
216
248
|
|
|
217
249
|
// Configure optimal settings for remote control
|
|
218
250
|
await remote.setSettings(); // Set optimal settings
|
|
219
|
-
await remote.setSettings(
|
|
251
|
+
await remote.setSettings("get"); // Get current settings
|
|
220
252
|
|
|
221
253
|
// Wait for device to finish booting (after reboot)
|
|
222
254
|
await remote.waitBootComplete(60000); // 60 second timeout
|
|
223
255
|
|
|
224
256
|
// Connection management
|
|
225
257
|
await remote.connect();
|
|
226
|
-
console.log(
|
|
258
|
+
console.log("Connected:", remote.isConnected);
|
|
227
259
|
await remote.disconnect();
|
|
228
260
|
|
|
229
261
|
// Listen for device management events
|
|
230
|
-
remote.on(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
262
|
+
remote.on("log", (data) => {
|
|
263
|
+
if (data.source === "reboot") {
|
|
264
|
+
console.log(`Reboot: ${data.message}`);
|
|
265
|
+
}
|
|
266
|
+
if (data.source === "ensureAwake") {
|
|
267
|
+
console.log(`Wake: ${data.message}`);
|
|
268
|
+
}
|
|
237
269
|
});
|
|
238
270
|
```
|
|
239
271
|
|
|
@@ -242,7 +274,7 @@ remote.on('log', (data) => {
|
|
|
242
274
|
Comprehensive text input with individual key support and smart shift detection:
|
|
243
275
|
|
|
244
276
|
```js
|
|
245
|
-
import createRemote from "android-tv-remote";
|
|
277
|
+
import createRemote from "@cldmv/node-android-tv-remote";
|
|
246
278
|
|
|
247
279
|
const remote = await createRemote({ ip: "192.168.1.100" });
|
|
248
280
|
|
|
@@ -251,35 +283,35 @@ await remote.keyboard.text("Hello World!");
|
|
|
251
283
|
await remote.keyboard.text("user@example.com");
|
|
252
284
|
|
|
253
285
|
// Individual character input
|
|
254
|
-
await remote.keyboard.key.h();
|
|
255
|
-
await remote.keyboard.key.e();
|
|
256
|
-
await remote.keyboard.key.l();
|
|
257
|
-
await remote.keyboard.key.l();
|
|
258
|
-
await remote.keyboard.key.o();
|
|
286
|
+
await remote.keyboard.key.h(); // Types "h"
|
|
287
|
+
await remote.keyboard.key.e(); // Types "e"
|
|
288
|
+
await remote.keyboard.key.l(); // Types "l"
|
|
289
|
+
await remote.keyboard.key.l(); // Types "l"
|
|
290
|
+
await remote.keyboard.key.o(); // Types "o"
|
|
259
291
|
|
|
260
292
|
// Shifted characters (only available for keys that change when shifted)
|
|
261
|
-
await remote.keyboard.key.shift.h();
|
|
262
|
-
await remote.keyboard.key.shift.one();
|
|
293
|
+
await remote.keyboard.key.shift.h(); // Types "H"
|
|
294
|
+
await remote.keyboard.key.shift.one(); // Types "!"
|
|
263
295
|
await remote.keyboard.key.shift.semicolon(); // Types ":"
|
|
264
296
|
|
|
265
297
|
// Special characters and symbols
|
|
266
|
-
await remote.keyboard.key.space();
|
|
298
|
+
await remote.keyboard.key.space(); // Types " "
|
|
267
299
|
await remote.keyboard.key.exclamation(); // Types "!"
|
|
268
|
-
await remote.keyboard.key.at();
|
|
269
|
-
await remote.keyboard.key.hash();
|
|
270
|
-
await remote.keyboard.key.dollar();
|
|
300
|
+
await remote.keyboard.key.at(); // Types "@"
|
|
301
|
+
await remote.keyboard.key.hash(); // Types "#"
|
|
302
|
+
await remote.keyboard.key.dollar(); // Types "$"
|
|
271
303
|
|
|
272
304
|
// Control keys
|
|
273
|
-
await remote.keyboard.key.tab();
|
|
274
|
-
await remote.keyboard.key.enter();
|
|
275
|
-
await remote.keyboard.key.backspace();
|
|
305
|
+
await remote.keyboard.key.tab(); // Tab character
|
|
306
|
+
await remote.keyboard.key.enter(); // Enter/Return
|
|
307
|
+
await remote.keyboard.key.backspace(); // Backspace
|
|
276
308
|
|
|
277
309
|
// Using keycode fallback (when available for regular keys)
|
|
278
|
-
await remote.keyboard.key.a.keycode();
|
|
310
|
+
await remote.keyboard.key.a.keycode(); // Sends keycode instead of character
|
|
279
311
|
|
|
280
312
|
// Note: Shift variants are only available for keys that actually change
|
|
281
|
-
// when shifted (letters, numbers, and some symbols). Special characters
|
|
282
|
-
// like @, #, !, etc. don't have shift variants since they're already
|
|
313
|
+
// when shifted (letters, numbers, and some symbols). Special characters
|
|
314
|
+
// like @, #, !, etc. don't have shift variants since they're already
|
|
283
315
|
// the shifted form. Shift keys only support text input, not keycodes,
|
|
284
316
|
// since Android ADB doesn't support sending multiple keycodes simultaneously.
|
|
285
317
|
```
|
|
@@ -327,7 +359,9 @@ await remote.keyboard.key.a.keycode(); // Sends keycode instead of character
|
|
|
327
359
|
}
|
|
328
360
|
```
|
|
329
361
|
|
|
330
|
-
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## 🔧 API
|
|
331
365
|
|
|
332
366
|
### Main Methods
|
|
333
367
|
|
|
@@ -354,7 +388,7 @@ await remote.keyboard.key.a.keycode(); // Sends keycode instead of character
|
|
|
354
388
|
### Events
|
|
355
389
|
|
|
356
390
|
- `log` - Emitted for all operations (info, warn, error, debug levels)
|
|
357
|
-
- `error` - Emitted when errors occur (structured error data)
|
|
391
|
+
- `error` - Emitted when errors occur (structured error data). Each remote has its own listeners. With no `error` listener attached, the error is emitted as a `log` event with `level: 'error'` (the `Error` is in `data.error`) instead of throwing. The failing call still reports it: commands reject, and `connect()` / `disconnect()` resolve with the `Error` as before
|
|
358
392
|
- `screencap-start` - Emitted when screenshot capture begins
|
|
359
393
|
- `screencap-captured` - Emitted when raw screenshot is captured
|
|
360
394
|
- `screencap-processing` - Emitted when image processing begins
|
|
@@ -370,7 +404,9 @@ await remote.keyboard.key.a.keycode(); // Sends keycode instead of character
|
|
|
370
404
|
|
|
371
405
|
See JSDoc comments in source code for full API documentation.
|
|
372
406
|
|
|
373
|
-
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## 📺 Supported Devices
|
|
374
410
|
|
|
375
411
|
| Device | Supported | Native Remote Buttons |
|
|
376
412
|
| ------------------------ | --------- | ------------------------------------------- |
|
|
@@ -381,10 +417,74 @@ See JSDoc comments in source code for full API documentation.
|
|
|
381
417
|
| Xiaomi Mi Box | Yes | Home, Back, D-Pad, Volume |
|
|
382
418
|
| Sony Bravia (Android TV) | Yes | Home, Back, D-Pad, Volume, Input |
|
|
383
419
|
|
|
384
|
-
See [Keyboard Keys](
|
|
420
|
+
See [Keyboard Keys](https://github.com/CLDMV/node-android-tv-remote/blob/master/docs/KEYBOARD_KEYS.md) and [Keycodes](https://github.com/CLDMV/node-android-tv-remote/blob/master/docs/KEYCODES.md) for full lists.
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
## 📚 Documentation
|
|
425
|
+
|
|
426
|
+
- **[Keyboard Keys](https://github.com/CLDMV/node-android-tv-remote/blob/master/docs/KEYBOARD_KEYS.md)** — every `keyboard.key` character and its shifted variant
|
|
427
|
+
- **[Keycodes](https://github.com/CLDMV/node-android-tv-remote/blob/master/docs/KEYCODES.md)** — the Android keycodes behind `press.<key>()` and `inputKeycode()`
|
|
428
|
+
- **[Changelog](https://github.com/CLDMV/node-android-tv-remote/tree/master/docs/changelog/)** — release notes for every version
|
|
429
|
+
|
|
430
|
+
[![CodeFactor]][codefactor_url] [![OpenSSF Scorecard]][ossf_scorecard_url] [![npms.io score]][npms_url] [![npm unpacked size]][npm_size_url] [![Repo size]][repo_size_url]
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## 🤝 Contributing
|
|
435
|
+
|
|
436
|
+
Contributions are welcome — open an issue or a pull request on [GitHub](https://github.com/CLDMV/node-android-tv-remote).
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
npm test # Vitest, then the CommonJS entry tests
|
|
440
|
+
npm run lint # ESLint
|
|
441
|
+
npm run format # Prettier
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
[![Contributors]][contributors_url] [![Sponsor shinrai]][sponsor_url]
|
|
385
445
|
|
|
386
446
|
---
|
|
387
447
|
|
|
388
|
-
##
|
|
448
|
+
## 🔗 Links
|
|
449
|
+
|
|
450
|
+
- **npm**: [@cldmv/node-android-tv-remote](https://www.npmjs.com/package/@cldmv/node-android-tv-remote)
|
|
451
|
+
- **GitHub**: [CLDMV/node-android-tv-remote](https://github.com/CLDMV/node-android-tv-remote)
|
|
452
|
+
- **Issues**: [GitHub Issues](https://github.com/CLDMV/node-android-tv-remote/issues)
|
|
453
|
+
- **Changelog**: [docs/changelog/](https://github.com/CLDMV/node-android-tv-remote/tree/master/docs/changelog/)
|
|
454
|
+
|
|
455
|
+
---
|
|
389
456
|
|
|
390
|
-
|
|
457
|
+
## 📄 License
|
|
458
|
+
|
|
459
|
+
[![npm license]][npm_license_url]
|
|
460
|
+
|
|
461
|
+
Apache-2.0 © Shinrai / CLDMV. See [LICENSE](https://github.com/CLDMV/node-android-tv-remote/blob/master/LICENSE) for the full text.
|
|
462
|
+
|
|
463
|
+
[npm version]: https://img.shields.io/npm/v/%40cldmv%2Fnode-android-tv-remote.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
|
|
464
|
+
[npm_version_url]: https://www.npmjs.com/package/@cldmv/node-android-tv-remote
|
|
465
|
+
[last commit]: https://img.shields.io/github/last-commit/CLDMV/node-android-tv-remote?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
|
|
466
|
+
[last_commit_url]: https://github.com/CLDMV/node-android-tv-remote/commits
|
|
467
|
+
[npm last update]: https://img.shields.io/npm/last-update/%40cldmv%2Fnode-android-tv-remote?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
|
|
468
|
+
[npm_last_update_url]: https://www.npmjs.com/package/@cldmv/node-android-tv-remote
|
|
469
|
+
[codefactor]: https://img.shields.io/codefactor/grade/github/CLDMV/node-android-tv-remote?style=for-the-badge&logo=codefactor&logoColor=white&labelColor=F44A6A
|
|
470
|
+
[codefactor_url]: https://www.codefactor.io/repository/github/cldmv/node-android-tv-remote
|
|
471
|
+
[openssf scorecard]: https://img.shields.io/ossf-scorecard/github.com/CLDMV/node-android-tv-remote?style=for-the-badge&label=OpenSSF%20Scorecard
|
|
472
|
+
[ossf_scorecard_url]: https://scorecard.dev/viewer/?uri=github.com/CLDMV/node-android-tv-remote
|
|
473
|
+
[npms.io score]: https://img.shields.io/npms-io/final-score/%40cldmv%2Fnode-android-tv-remote?style=for-the-badge&logo=npms&logoColor=white&labelColor=0B5D57
|
|
474
|
+
[npms_url]: https://npms.io/search?q=%40cldmv%2Fnode-android-tv-remote
|
|
475
|
+
[npm downloads]: https://img.shields.io/npm/dm/%40cldmv%2Fnode-android-tv-remote.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
|
|
476
|
+
[npm_downloads_url]: https://www.npmjs.com/package/@cldmv/node-android-tv-remote
|
|
477
|
+
[github downloads]: https://img.shields.io/github/downloads/CLDMV/node-android-tv-remote/total?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
|
|
478
|
+
[github_downloads_url]: https://github.com/CLDMV/node-android-tv-remote/releases
|
|
479
|
+
[npm unpacked size]: https://img.shields.io/npm/unpacked-size/%40cldmv%2Fnode-android-tv-remote.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
|
|
480
|
+
[npm_size_url]: https://www.npmjs.com/package/@cldmv/node-android-tv-remote
|
|
481
|
+
[repo size]: https://img.shields.io/github/repo-size/CLDMV/node-android-tv-remote?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
|
|
482
|
+
[repo_size_url]: https://github.com/CLDMV/node-android-tv-remote
|
|
483
|
+
[npm license]: https://img.shields.io/npm/l/%40cldmv%2Fnode-android-tv-remote.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
|
|
484
|
+
[npm_license_url]: https://www.npmjs.com/package/@cldmv/node-android-tv-remote
|
|
485
|
+
[coverage]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FCLDMV%2Fnode-android-tv-remote%2Fbadges%2Fcoverage.json&style=for-the-badge&logo=vitest&logoColor=white
|
|
486
|
+
[coverage_url]: https://github.com/CLDMV/node-android-tv-remote/blob/badges/coverage.json
|
|
487
|
+
[contributors]: https://img.shields.io/github/contributors/CLDMV/node-android-tv-remote.svg?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
|
|
488
|
+
[contributors_url]: https://github.com/CLDMV/node-android-tv-remote/graphs/contributors
|
|
489
|
+
[sponsor shinrai]: https://img.shields.io/github/sponsors/shinrai?style=for-the-badge&logo=githubsponsors&logoColor=white&labelColor=EA4AAA&label=Sponsor
|
|
490
|
+
[sponsor_url]: https://github.com/sponsors/shinrai
|