Skip to content

feat: adopt the CLDMV library layout with a tsup build - #81

Merged
Shinrai merged 4 commits into
nextfrom
feat/library-layout
Nov 1, 2026
Merged

Shinrai merged 4 commits into
nextfrom
feat/library-layout

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

🐛 Bug Fixes

📦 Dependencies

No dependency updates

🔧 Other Changes

👥 Contributors

Move the hand-written root entries to src/index.mjs and src/index.cjs and
build with tsup: dist/index.mjs is the bundle, dist/index.cjs a verbatim
copy of src/index.cjs. The "." export gets a node-android-tv-remote-dev
condition pointing at src/, and the package now ships dist/ plus
scripts/postinstall.mjs (the postinstall hook runs on consumer installs)
instead of src/ and scripts/. engines.node becomes ^20.19.0 || >=22.13.0,
matching what the CJS entry already enforces at runtime.

Vitest and test:cjs run with the condition; tests/cjs/entry.test.cjs now
checks the build, and a source-level entry test covers src/index.cjs.
eslint.config.mjs moves to .configs/. CI, release and bundle-size
workflows run the real build.

Closes #75
@cldmv-bot cldmv-bot Bot added ! feature → next v4 flow: contributor PR targeting the next integration branch type: feature Implements new functionality — a PR or issue that adds a feature area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure type: ci Changes to CI workflows, actions, or build pipelines type: config Changes to repository or project configuration files type: dependencies Relates to dependency updates, version bumps, or package management type: documentation Relates to docs, README updates, guides, or inline code comments labels Nov 1, 2026
Node 22.12 warns when require() loads the ESM entry, so the matrix starts where engines.node does.
The dev toolchain (chokidar 6, tsup 9) needs Node 22.22, so nothing older can be tested. engines, the CJS guard message and the CI matrix floor move together.
Shinrai
Shinrai previously approved these changes Nov 1, 2026
@cldmv-bot
cldmv-bot Bot dismissed Shinrai’s stale review November 1, 2026 22:10

The merge-base changed after approval.

Shinrai
Shinrai previously approved these changes Nov 1, 2026
@Shinrai
Shinrai dismissed their stale review November 1, 2026 22:11

The merge-base changed after approval.

@Shinrai
Shinrai enabled auto-merge November 1, 2026 22:11
@Shinrai
Shinrai merged commit 7318008 into next Nov 1, 2026
24 checks passed
@cldmv-bot
cldmv-bot Bot deleted the feat/library-layout branch November 1, 2026 22:12
cldmv-bot Bot added a commit that referenced this pull request Nov 2, 2026
# `@cldmv/node-android-tv-remote` v2.2.0 Changelog

**Release Date**: November 2026
**Release Type**: Minor
**Branch**: `release/2.2.0`

---

## Overview

Version 2.2.0 moves the package to the CLDMV library layout with a tsup build, moves the runtime dependency `@devicefarmer/adbkit` to its new major 4, and fixes two long-standing bugs: `waitBootComplete(timeout)` now actually stops waiting at its timeout, and `screencap()` with a `filepath` no longer reports the file saved before it is written.

The supported Node.js range changes: `engines.node` goes from `>=20.9.0` to `>=22.22.0`, and `@devicefarmer/adbkit` 4 itself requires Node.js 22.12 or later. That is a real requirement change even though it ships in a minor release; see [Breaking Changes](#-breaking-changes) and the upgrade notes. The exported API (`createRemote`, `createAndroidTVRemote` and the default export, from both `import` and `require()`) is unchanged.

---

## 💥 Breaking Changes

### Node.js `>=22.22.0` is now required ([#81](#81))

`engines.node` was `>=20.9.0` in v2.1.9 (set by `sharp`), with `require()` documented as needing `^20.19.0` or `>=22.12.0`. Both are now `>=22.22.0`. The new build toolchain no longer runs on Node.js 20 (tsup 9 alone declares `^22.18.0 || ^24.11.0 || >=26.0.0`), and `@devicefarmer/adbkit` 4 declares `>= 22.12`, so Node.js 20 is no longer supported at runtime either. The floor is set to 22.22.0, the oldest version the CI and publish matrices now test. The `ERR_REQUIRE_ESM` message that `require()` throws on a Node.js without `require(esm)` now names `>=22.22.0`.

npm prints an `EBADENGINE` warning when installing on an older Node.js, and the install fails when `engine-strict` is set.

### `waitBootComplete()` now rejects at its timeout ([#84](#84), fixes [#85](#85))

This is a bug fix, listed here because it changes what a caller sees. `waitBootComplete(timeout = 60000)` documented a timeout but never passed it on, so the call waited until the device finished booting, however long that took. See [Bug Fixes](#-bug-fixes) for the details.

---

## 🐛 Bug Fixes

### `waitBootComplete(timeout)` honors its timeout ([#84](#84), fixes [#85](#85))

The remote now hands adbkit 4 an `AbortSignal.timeout(timeout)`. When it fires, adbkit closes the connection and rejects with a `TimeoutError`; the remote logs the existing "Boot completion timeout after …ms" message, emits the error, and rejects. A call with no argument now gives up after the documented 60 seconds instead of waiting indefinitely.

### `screencap()` finishes writing a resized screenshot before reporting it saved ([#84](#84), fixes [#86](#86))

With a `filepath` (and optionally `width` / `height`), the background save ended the file stream and emitted `screencap-saved` and `screencap-complete` straight away, before the data reached the file, and the file stream had no `error` listener. The capture, resize and file write now run through `stream/promises` `pipeline()`: the two events fire, and `lastScreencapData` is set, only after the file is fully written. A capture, resize or write failure tears the whole pipeline down and is reported as a `screencap` error with no completion events.

---

## ✨ Features

### Library layout: `src/` entries and a tsup build ([#81](#81), fixes [#75](#75))

The hand-written root `index.mjs` / `index.cjs` moved to `src/index.mjs` / `src/index.cjs`, and `build` is now tsup (`tsup.config.mjs`) instead of an `echo` stub:

- `dist/index.mjs` is a minified ESM bundle of `src/index.mjs`, with names and `node:` specifiers kept. The keycode, keyboard and remote-key JSON tables are inlined. The runtime dependencies (`@devicefarmer/adbkit`, `sharp`) stay external.
- `dist/index.cjs` is not a second bundle. It is a verbatim copy of `src/index.cjs`, the thin wrapper that loads `./index.mjs` through Node's synchronous `require(esm)` and keeps the historical CommonJS shape (`module.exports` is `createRemote`, with `createRemote`, `createAndroidTVRemote` and `default` on it).

`main` / `module` point at `dist/`, `exports` adds `./package.json`, and `prepack` runs the build so `dist/` is never committed. The published files are now `dist/` (without source maps) and `scripts/postinstall.mjs`, which still runs on install to check for `adb`. `src/` and the other two helper scripts are no longer published: `scripts/setup-device.mjs` and `scripts/wake-tv.mjs` import `src/`, so they are checkout tools (`npm run setup-device` in a clone of this repository).

### `node-android-tv-remote-dev` export condition ([#81](#81))

The `"."` export carries a `node-android-tv-remote-dev` condition that points `import` and `require` at `src/`. In a checkout, `node --conditions=node-android-tv-remote-dev` runs the unbuilt source; without it the package resolves to `dist/`, which `npm run build` produces. Installed copies only ship `dist/`.

---

## 🔧 CI & tooling

- CI, release and bundle-size workflows run the real build (`npm run build:ci`: `lint`, `format:check`, then tsup), including the coverage legs (`coverage_build_command`) ([#81](#81)).
- The bundle-size check measures `dist/**.mjs` / `dist/**.cjs` instead of the root entries, `src/` and `scripts/` ([#81](#81)).
- The CI and publish test matrices start at Node.js 22.22.0, the new package floor ([#81](#81)).
- vitest and `test:cjs` run with the `node-android-tv-remote-dev` condition, so the suite tests `src/`; `test:cjs` builds first and checks `dist/`. `eslint.config.mjs` moved into `.configs/` ([#81](#81)).
- `tmp/` is gitignored ([#80](#80)).

## 🧪 Tests

- `adb-client.test.vitest.mjs` mocks the adbkit client and device and drives every path that calls into adbkit: client creation, connect / disconnect, the heartbeat and connection check, auto-disconnect, key, long-press and text shell commands, `setSettings`, `ensureAwake`, `reboot`, `screencap` / thumbnail and `waitBootComplete`, plus a check that the real adbkit package still has every client, device and util method the remote calls. Line coverage of `src/lib/android-tv-remote.mjs` goes from 24% to 95% ([#84](#84)).
- `entry.test.vitest.mjs` covers `src/index.cjs` at the source level ([#81](#81)).

## 📚 Documentation

- The README states the `>=22.22.0` requirement and documents `npm run build` and the `node-android-tv-remote-dev` condition for working from a checkout ([#81](#81)).
- **NEW:** [docs/changelog/v2/v2.2.0.md](./v2.2.0.md) — this changelog.

## 🔧 Dependencies

Runtime:

- `@devicefarmer/adbkit` `^3.3.8` → `^4.0.1` (3.3.9 → 4.0.1 in the lockfile) ([#84](#84)). adbkit 4 replaces bluebird with native promises, makes cancellation explicit with `AbortSignal`, adds an `exports` map that blocks deep imports, requires Node.js 22.12 or later, and moves to `adbkit-logcat` 3 and `adbkit-monkey` 2. The remote only imports the package root, only uses `.then` / `.catch` / `await` on adbkit promises, and doesn't use trackers, sync transfers, logcat or monkey, so no source change was needed beyond passing the new `signal` to `waitBootComplete`. `bluebird` is no longer installed.
- `sharp` `^0.35.3` → `^0.35.5` (the lockfile was already on 0.35.5) ([#82](#82)).

Development only:

- `tsup` `^9.0.0` and `typescript` added with the build ([#81](#81)); `typescript` is pinned to `^6.0.3`, since TypeScript 7's JavaScript declaration emit isn't complete yet ([#83](#83)).
- `overrides` for `katex` (`>=0.19.1 <1.0.0`, 0.16.47 → 0.19.1) and `minimatch` (`^11.0.3`, 10.2.6 → 11.0.3) clear the dev-only advisories that come in through `eslint` and `@eslint/markdown` ([#83](#83)).
- Toolchain refresh ([#82](#82)): `@cldmv/configs` 1.2.4 → 1.3.0, `@cldmv/fix-headers` 2.2.0 → 2.2.4, `@cldmv/vitest-runner` 1.5.3 → 1.5.6, `vitest` / `@vitest/coverage-v8` 5.0.3 → 5.0.5, `eslint` 10.12.0 → 10.14.0, `@eslint/css` 2.0.0 → 2.0.1, `@eslint/json` 2.1.0 → 2.1.1, `globals` 17.13.0 → 17.14.0, plus transitive fixes from `npm audit fix` (`vite` 8.3.2 → 8.3.5 among them).
- `prettier` 3.9.9 → 3.9.10 ([#66](#66)).

---

## Upgrade notes

- **Node.js `>=22.22.0` is required.** Upgrade Node.js before upgrading the package. On Node.js 20, stay on [v2.1.9](./v2.1.9.md).
- `waitBootComplete()` now rejects once its timeout (60 seconds by default) passes. A caller that relied on it waiting indefinitely for a slow boot should pass a larger timeout and handle the rejection.
- `screencap-saved` and `screencap-complete` now fire after the file is on disk, and a write failure arrives as a `screencap` error. Code that worked around the early events (for example by polling for the file) can drop the workaround.
- The exported API is unchanged for both `import` and `require()`. Code that reached into `src/` or `scripts/setup-device.mjs` / `scripts/wake-tv.mjs` inside the installed package must stop doing so; those files are no longer published.



<details>
<summary>👥 Contributors</summary>

- @Shinrai

</details>

---

<!-- coverage-start -->

![coverage](https://img.shields.io/badge/coverage-93.6%25-brightgreen?style=for-the-badge&logo=vitest&logoColor=white)

| Metric | Coverage |
|--------|----------|
| Statements | 94.8% |
| Branches   | 86.6% |
| Functions  | 97.5% |
| Lines      | 95.6% |

*Avg: **93.6%** · `b8963e3` · Node lts/**

<!-- coverage-end -->

<!-- co-authors -->

Co-authored-by: Shinrai <[email protected]>
Shinrai added a commit that referenced this pull request Nov 8, 2026
# `@cldmv/node-android-tv-remote` v2.2.0 Changelog

**Release Date**: November 2026
**Release Type**: Minor
**Branch**: `release/2.2.0`

---

## Overview

Version 2.2.0 moves the package to the CLDMV library layout with a tsup build, moves the runtime dependency `@devicefarmer/adbkit` to its new major 4, and fixes two long-standing bugs: `waitBootComplete(timeout)` now actually stops waiting at its timeout, and `screencap()` with a `filepath` no longer reports the file saved before it is written.

The supported Node.js range changes: `engines.node` goes from `>=20.9.0` to `>=22.22.0`, and `@devicefarmer/adbkit` 4 itself requires Node.js 22.12 or later. That is a real requirement change even though it ships in a minor release; see [Breaking Changes](#-breaking-changes) and the upgrade notes. The exported API (`createRemote`, `createAndroidTVRemote` and the default export, from both `import` and `require()`) is unchanged.

---

## 💥 Breaking Changes

### Node.js `>=22.22.0` is now required ([#81](#81))

`engines.node` was `>=20.9.0` in v2.1.9 (set by `sharp`), with `require()` documented as needing `^20.19.0` or `>=22.12.0`. Both are now `>=22.22.0`. The new build toolchain no longer runs on Node.js 20 (tsup 9 alone declares `^22.18.0 || ^24.11.0 || >=26.0.0`), and `@devicefarmer/adbkit` 4 declares `>= 22.12`, so Node.js 20 is no longer supported at runtime either. The floor is set to 22.22.0, the oldest version the CI and publish matrices now test. The `ERR_REQUIRE_ESM` message that `require()` throws on a Node.js without `require(esm)` now names `>=22.22.0`.

npm prints an `EBADENGINE` warning when installing on an older Node.js, and the install fails when `engine-strict` is set.

### `waitBootComplete()` now rejects at its timeout ([#84](#84), fixes [#85](#85))

This is a bug fix, listed here because it changes what a caller sees. `waitBootComplete(timeout = 60000)` documented a timeout but never passed it on, so the call waited until the device finished booting, however long that took. See [Bug Fixes](#-bug-fixes) for the details.

---

## 🐛 Bug Fixes

### `waitBootComplete(timeout)` honors its timeout ([#84](#84), fixes [#85](#85))

The remote now hands adbkit 4 an `AbortSignal.timeout(timeout)`. When it fires, adbkit closes the connection and rejects with a `TimeoutError`; the remote logs the existing "Boot completion timeout after …ms" message, emits the error, and rejects. A call with no argument now gives up after the documented 60 seconds instead of waiting indefinitely.

### `screencap()` finishes writing a resized screenshot before reporting it saved ([#84](#84), fixes [#86](#86))

With a `filepath` (and optionally `width` / `height`), the background save ended the file stream and emitted `screencap-saved` and `screencap-complete` straight away, before the data reached the file, and the file stream had no `error` listener. The capture, resize and file write now run through `stream/promises` `pipeline()`: the two events fire, and `lastScreencapData` is set, only after the file is fully written. A capture, resize or write failure tears the whole pipeline down and is reported as a `screencap` error with no completion events.

---

## ✨ Features

### Library layout: `src/` entries and a tsup build ([#81](#81), fixes [#75](#75))

The hand-written root `index.mjs` / `index.cjs` moved to `src/index.mjs` / `src/index.cjs`, and `build` is now tsup (`tsup.config.mjs`) instead of an `echo` stub:

- `dist/index.mjs` is a minified ESM bundle of `src/index.mjs`, with names and `node:` specifiers kept. The keycode, keyboard and remote-key JSON tables are inlined. The runtime dependencies (`@devicefarmer/adbkit`, `sharp`) stay external.
- `dist/index.cjs` is not a second bundle. It is a verbatim copy of `src/index.cjs`, the thin wrapper that loads `./index.mjs` through Node's synchronous `require(esm)` and keeps the historical CommonJS shape (`module.exports` is `createRemote`, with `createRemote`, `createAndroidTVRemote` and `default` on it).

`main` / `module` point at `dist/`, `exports` adds `./package.json`, and `prepack` runs the build so `dist/` is never committed. The published files are now `dist/` (without source maps) and `scripts/postinstall.mjs`, which still runs on install to check for `adb`. `src/` and the other two helper scripts are no longer published: `scripts/setup-device.mjs` and `scripts/wake-tv.mjs` import `src/`, so they are checkout tools (`npm run setup-device` in a clone of this repository).

### `node-android-tv-remote-dev` export condition ([#81](#81))

The `"."` export carries a `node-android-tv-remote-dev` condition that points `import` and `require` at `src/`. In a checkout, `node --conditions=node-android-tv-remote-dev` runs the unbuilt source; without it the package resolves to `dist/`, which `npm run build` produces. Installed copies only ship `dist/`.

---

## 🔧 CI & tooling

- CI, release and bundle-size workflows run the real build (`npm run build:ci`: `lint`, `format:check`, then tsup), including the coverage legs (`coverage_build_command`) ([#81](#81)).
- The bundle-size check measures `dist/**.mjs` / `dist/**.cjs` instead of the root entries, `src/` and `scripts/` ([#81](#81)).
- The CI and publish test matrices start at Node.js 22.22.0, the new package floor ([#81](#81)).
- vitest and `test:cjs` run with the `node-android-tv-remote-dev` condition, so the suite tests `src/`; `test:cjs` builds first and checks `dist/`. `eslint.config.mjs` moved into `.configs/` ([#81](#81)).
- `tmp/` is gitignored ([#80](#80)).

## 🧪 Tests

- `adb-client.test.vitest.mjs` mocks the adbkit client and device and drives every path that calls into adbkit: client creation, connect / disconnect, the heartbeat and connection check, auto-disconnect, key, long-press and text shell commands, `setSettings`, `ensureAwake`, `reboot`, `screencap` / thumbnail and `waitBootComplete`, plus a check that the real adbkit package still has every client, device and util method the remote calls. Line coverage of `src/lib/android-tv-remote.mjs` goes from 24% to 95% ([#84](#84)).
- `entry.test.vitest.mjs` covers `src/index.cjs` at the source level ([#81](#81)).

## 📚 Documentation

- The README states the `>=22.22.0` requirement and documents `npm run build` and the `node-android-tv-remote-dev` condition for working from a checkout ([#81](#81)).
- **NEW:** [docs/changelog/v2/v2.2.0.md](./v2.2.0.md) — this changelog.

## 🔧 Dependencies

Runtime:

- `@devicefarmer/adbkit` `^3.3.8` → `^4.0.1` (3.3.9 → 4.0.1 in the lockfile) ([#84](#84)). adbkit 4 replaces bluebird with native promises, makes cancellation explicit with `AbortSignal`, adds an `exports` map that blocks deep imports, requires Node.js 22.12 or later, and moves to `adbkit-logcat` 3 and `adbkit-monkey` 2. The remote only imports the package root, only uses `.then` / `.catch` / `await` on adbkit promises, and doesn't use trackers, sync transfers, logcat or monkey, so no source change was needed beyond passing the new `signal` to `waitBootComplete`. `bluebird` is no longer installed.
- `sharp` `^0.35.3` → `^0.35.5` (the lockfile was already on 0.35.5) ([#82](#82)).

Development only:

- `tsup` `^9.0.0` and `typescript` added with the build ([#81](#81)); `typescript` is pinned to `^6.0.3`, since TypeScript 7's JavaScript declaration emit isn't complete yet ([#83](#83)).
- `overrides` for `katex` (`>=0.19.1 <1.0.0`, 0.16.47 → 0.19.1) and `minimatch` (`^11.0.3`, 10.2.6 → 11.0.3) clear the dev-only advisories that come in through `eslint` and `@eslint/markdown` ([#83](#83)).
- Toolchain refresh ([#82](#82)): `@cldmv/configs` 1.2.4 → 1.3.0, `@cldmv/fix-headers` 2.2.0 → 2.2.4, `@cldmv/vitest-runner` 1.5.3 → 1.5.6, `vitest` / `@vitest/coverage-v8` 5.0.3 → 5.0.5, `eslint` 10.12.0 → 10.14.0, `@eslint/css` 2.0.0 → 2.0.1, `@eslint/json` 2.1.0 → 2.1.1, `globals` 17.13.0 → 17.14.0, plus transitive fixes from `npm audit fix` (`vite` 8.3.2 → 8.3.5 among them).
- `prettier` 3.9.9 → 3.9.10 ([#66](#66)).

---

## Upgrade notes

- **Node.js `>=22.22.0` is required.** Upgrade Node.js before upgrading the package. On Node.js 20, stay on [v2.1.9](./v2.1.9.md).
- `waitBootComplete()` now rejects once its timeout (60 seconds by default) passes. A caller that relied on it waiting indefinitely for a slow boot should pass a larger timeout and handle the rejection.
- `screencap-saved` and `screencap-complete` now fire after the file is on disk, and a write failure arrives as a `screencap` error. Code that worked around the early events (for example by polling for the file) can drop the workaround.
- The exported API is unchanged for both `import` and `require()`. Code that reached into `src/` or `scripts/setup-device.mjs` / `scripts/wake-tv.mjs` inside the installed package must stop doing so; those files are no longer published.



<details>
<summary>👥 Contributors</summary>

- @Shinrai

</details>

---

<!-- coverage-start -->

![coverage](https://img.shields.io/badge/coverage-93.6%25-brightgreen?style=for-the-badge&logo=vitest&logoColor=white)

| Metric | Coverage |
|--------|----------|
| Statements | 94.8% |
| Branches   | 86.6% |
| Functions  | 97.5% |
| Lines      | 95.6% |

*Avg: **93.6%** · `b8963e3` · Node lts/**

<!-- coverage-end -->

<!-- co-authors -->

Co-authored-by: Shinrai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure ! feature → next v4 flow: contributor PR targeting the next integration branch type: ci Changes to CI workflows, actions, or build pipelines type: config Changes to repository or project configuration files type: dependencies Relates to dependency updates, version bumps, or package management type: documentation Relates to docs, README updates, guides, or inline code comments type: feature Implements new functionality — a PR or issue that adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant