npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@expo-harmony/expo-keep-awake

v57.0.2-harmony.1

Published

HarmonyOS port of expo-keep-awake

Readme

@expo-harmony/expo-keep-awake

GitHub 仓库 | 官方文档

为 HarmonyOS 上的 React Native 应用提供 Expo KeepAwake 的原生实现,与官方 expo-keep-awake 配套使用。

安装

本包适配 Expo SDK 57。

引入本包前,需要确保应用使用的 HarmonyOS SDK 至少为 API 13(HarmonyOS 5.0.1)。

npm install @expo-harmony/expo-keep-awake expo-keep-awake@~57.0.2

API 对照表

Hooks

useKeepAwake(tag?: string, options?: KeepAwakeOptions)

返回 void。组件挂载期间按标签请求屏幕常亮,卸载时释放该标签。省略 tag 时使用该组件唯一的 ID。HarmonyOS 应用进入后台时暂停常亮请求,回到前台后恢复;窗口未就绪或常亮请求失败时,无法保证屏幕保持常亮。options 见 KeepAwakeOptions。

Constants

ExpoKeepAwakeTag

值为 'ExpoKeepAwakeDefaultTag',是省略标签的常亮方法使用的默认标签。

Methods

activateKeepAwake(tag?: string)

已废弃,请改用 activateKeepAwakeAsync()。返回 Promise<void>,按标签请求屏幕常亮;省略 tag 时使用 ExpoKeepAwakeTag。

activateKeepAwakeAsync(tag?: string)

返回 Promise<void>,按标签请求屏幕常亮;省略 tag 时使用 ExpoKeepAwakeTag。同一标签重复激活不叠加,多个标签分别生效。应用在前台且至少有一个有效标签时,屏幕保持常亮;进入后台时暂停请求,回到前台后恢复。请求只作用于当前窗口,不会修改系统休眠设置。窗口未就绪或系统无法设置常亮时,Promise 会拒绝;系统仍可能自行关闭屏幕,异源虚拟屏也不保证常亮。

deactivateKeepAwake(tag?: string)

返回 Promise<void>,释放标签对应的常亮请求;省略 tag 时使用 ExpoKeepAwakeTag。释放未激活的标签不会报错。释放全部标签后,本模块不再阻止屏幕休眠,窗口上的其他常亮请求仍然生效。

isAvailableAsync(): Promise<boolean>

返回 Promise<boolean>。设备支持窗口管理,且当前运行时关联了已注册 Expo Ability 生命周期订阅器的 UIAbility 时返回 true。true 不表示窗口已就绪;在无界面任务中激活或释放常亮会导致 Promise 拒绝。

Event subscriptions

addListener(tagOrListener: string | KeepAwakeListener, listener?: KeepAwakeListener)

原方法返回 EventSubscription;HarmonyOS 不提供常亮状态变化事件,调用此方法会抛出不可用错误,不会返回订阅。

Types

KeepAwakeOptions

useKeepAwake 的可选配置。

suppressDeactivateWarnings?: boolean

默认为 false。设为 true 时,Hook 卸载时会捕获释放常亮请求产生的 Promise 拒绝;此选项不影响激活和主动释放操作。

listener?: KeepAwakeListener

类型为 KeepAwakeListener。

  • HarmonyOS 不提供常亮状态变化事件,因此不会调用此回调。

KeepAwakeEvent

事件对象包含 state: KeepAwakeEventState。

  • HarmonyOS 不发出常亮状态变化事件,因此不会产生此事件对象。

KeepAwakeListener

类型为接收 KeepAwakeEvent 的回调函数。

  • HarmonyOS 不发出常亮状态变化事件,因此不会调用此回调。

Enums

KeepAwakeEventState

RELEASE 的值为 'release'。

  • HarmonyOS 不发出常亮状态变化事件,因此不会传出此枚举值。

Error codes

ERR_KEEP_AWAKE_DESTROYED

运行环境已销毁时,激活或释放常亮请求会以此错误码拒绝。

ERR_KEEP_AWAKE_WINDOW

窗口不可用、窗口状态发生变化,或系统无法设置或释放常亮请求时,Promise 会以此错误码拒绝。

Permissions

屏幕常亮

不需要声明或请求额外权限。

Author

expo-harmony © Baoshuo, Released under the MIT License. Authored and maintained by Baoshuo with help from contributors.

Personal Website · Blog · GitHub @renbaoshuo · Twitter @renbaoshuo