# @bam\.tech/lrud 中文文档

规范地址：https://npmcn.com/package/%40bam.tech/lrud/

版本：8\.0\.2
npm 元数据更新时间：2026-10-13T12:37:53.714Z
中文译文更新时间：2026-11-07T15:56:54.811Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40bam.tech/lrud
原文对照：https://npmcn.com/package/%40bam.tech/lrud/?lang=original
项目主页：https://github.com/bamlab/lrud
源码仓库：https://github.com/bamlab/lrud

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：175 kB，10 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：1 个
- 首次发布：2023-07-17T12:37:21.674Z
- 最新版本发布：2024-09-17T12:14:36.725Z
- 近 30 天下载量：15354（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：3（近 12 个月 0 个）

## 中文简介

左边,右边,上,下。 通过方向控制输入设备的空间导航库

## 安装

```sh
npm install @bam.tech/lrud
```

也可以使用：`pnpm add @bam.tech/lrud`、`yarn add @bam.tech/lrud`、`bun add @bam.tech/lrud`

## README

# 法语 ![Build Status](https://github.com/bbc/lrud/actions/workflows/github-actions.yml/badge.svg?branch=master)

通过方向控制输入设备的空间导航库

## : nut 和 bolt:维护模式 : nut 和 bolt:

LRUD目前处于维护模式;已存在的bug将会被固定,但不会添加新的特性. 一个新的图书馆叫 [空间空间](https://github.com/bbc/lrud-spatial) 现在开放源码社区可以使用.

## 从V2升级

**v3是主要的重写,涵盖许多新特性. 然而,不幸的是,它打破了一些倒向相容性.**

我们目前正在为升级进程编写更详细的文件。 然而,目前需要注意的主要问题;

-   事件的变化、排放的和排放的
-   删除 `grid` 赞成: `isIndexAligned` 行为

## 开始

```bash
git clone git@github.com:bbc/lrud.git lrud
cd lrud
npm install
```

路德写在 [字体](https://www.typescriptlang.org/) 并使用 [手套](https://github.com/developit/mitt)。 。 。 .

## 使用量

```bash
npm install lrud
```

```js
const { Lrud } = require('Lrud')

// create an instance, register some nodes and assign a default focus
var navigation = new Lrud()
navigation
  .registerNode('root', { orientation: 'vertical' })
  .registerNode('item-a', { parent: 'root', isFocusable: true })
  .registerNode('item-b', { parent: 'root', isFocusable: true })
  .assignFocus('item-a')

// handle a key event
document.addEventListener('keypress', (event) => {
  navigation.handleKeyEvent(event)
});

// Lrud will output an event when it handles a move
navigation.on('move', (moveEvent) => {
  myApp.doSomethingOnNodeFocus(moveEvent.enter)
})
```

见 [使用文档](https://npmcn.com/package/%40bam.tech/lrud/docs/usage.md) 详细信息 API 详细信息.

更多“ 完整” 的例子, 包括常用例, 请检查 [食谱](https://npmcn.com/package/%40bam.tech/lrud/docs/recipes.md)

## 运行测试

所有代码都用打字符写,所以我们使用 `tsconfig.json` 财务报告和审定财务报表 `jest.config.js` 以确保测试运行正确.

测试文件被相当任意地分开,目的是把更大的一组测试破解成自己的文件.

```bash
npm test
```

要运行一个特定的测试文件, 请使用 `npx jest` 从项目根.

```bash
npx jest src/lrud.test.js
```

也可以用动词输出来进行所有测试. 这有助于列出各种试验方案,以确保涵盖行为.

```bash
npm run test:verbose
```

您也可以使用覆盖输出进行所有测试

```bash
npm run test:coverage
```

一些测试有相关的图表,以更好地解释测试的内容。 这些可以在 `./docs/test-diagrams`。 。 。 .

我们也有一个特定的测试文件( :`src/build.test.js`),以确保我们没有打破Typescript/rollup.js积分.

## 版本

```bash
npm version <patch:minor:major>
npm publish
```

## 与

-   [字体](https://www.typescriptlang.org/)
-   [滚出.js](https://rollupjs.org/)
-   [手套](https://github.com/developit/mitt)

## 灵感

-   [BBC - 电视应用层(TAL)](http://bbc.github.io/tal/widgets/focus-management.html)
-   [Netflix - 通过远程](https://medium.com/netflix-techblog/pass-the-remote-user-input-on-tv-devices-923f6920c9a8)
-   [Mozilla - 实施电视遥控导航](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS_for_TV/TV_remote_control_navigation)

## 替代品

-   [塔尔](https://github.com/bbc/tal)
-   [反应- tv- 导航](https://github.com/react-tv/react-tv-navigation)
-   [反应键导航](https://github.com/dead/react-key-navigation)
-   [js-空间导航](https://github.com/luke-chang/js-spatial-navigation)

# 许可证

LRUD是BBC TAL 库的一部分,根据Apache 2开源许可证(Apache-2.0)的规定,每个人都可以使用. 看看密码里的LICENSE文件.

版权 (c) 2018 BBC

## 常见问题

### @bam\.tech/lrud 是什么？

左边,右边,上,下。 通过方向控制输入设备的空间导航库

### 如何安装 @bam\.tech/lrud？

在项目目录运行 npm install @bam\.tech/lrud，或使用 pnpm add / yarn add / bun add。

### @bam\.tech/lrud 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @bam\.tech/lrud 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @bam\.tech/lrud 可以商用吗？

@bam\.tech/lrud 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @bam\.tech/lrud 的下载量有多少？

根据 npm 官方下载统计，@bam\.tech/lrud 在 2026/10/08 – 2026/11/06 这 30 天内被下载 15,354 次，日均约 512 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @bam\.tech/lrud 还在维护吗？

最新版本 8\.0\.2 发布于 2024/09/17（2 年前）；至今共发布 3 个版本，其中过去 12 个月发布了 0 个；首次发布于 2023/07/17。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

