@companycam/vibe-check

中文文档
0.3.0发布于 2025/01/14MITTypeScriptESM + CJS近 30 天下载 2.1万

Hardware logging library for CompanyCam

原始使用文档
文档目录15 节
  1. Hardware logging library for CompanyCam
  2. Installation
  3. System Requirements
  4. iOS
  5. Android
  6. Usage
  7. API
  8. Methods
  9. getCurrentVibes()
  10. getBatteryVibe()
  11. getConnectionInfo()
  12. getRamUsage()
  13. getThermalState()
  14. Return object potential values
  15. Contributing

@companycam/vibe-check

Hardware logging library for CompanyCam

Welcome to the CompanyCam Vibe Check repo.

This library is largely for exposing hardware information not readily available. Maintaining a high level of performance in our apps is a large priority. Sometimes we can compensate for these issues, and sometimes we cannot. This library aims to expose hardware information commonly related to performance issues.

This library exposes the following information, through the getCurrentVibes method:

{
  battery: {
    batteryLevel: 0.70202270953611340,
    batteryState: 'charging',
    lowPowerMode: false,
  },
  connectivity: {
    connection: {
      isConnected: true,
      isInternetReachable: true,
      type: 'cellular',
      details: {
        isConnectionExpensive: false,
        cellularGeneration: '4g',
      },
    },
  },
  memoryInUse: 83193856,
  thermalState: 'nominal',
};

Installation

yarn install @companycam/vibe-check
yarn add @companycam/vibe-check

System Requirements

iOS

iOS Version: 15.0

Android

minSdkVersion: 24

Usage

import { getCurrentVibes, FullVibeCheck } from '@companycam/vibe-check';

// ...elsewhere in your code

const vibes: FullVibeCheck = yield call(getCurrentVibes);

API

Methods

getCurrentVibes()

Gets the device's current hardware information. This method is the main entry point for this library. Returns all of the results from the other functions this library exposes.

import { getCurrentVibes, FullVibeCheck } from '@companycam/vibe-check';

const vibes: FullVibeCheck = yield call(getCurrentVibes);

This method will return an object very similar to the below JSON object:

{
  battery: {
    batteryLevel: 0.70202270953611340,
    batteryState: 'charging',
    lowPowerMode: false,
  },
  connectivity: {
    connection: {
      isConnected: true,
      isInternetReachable: true,
      type: 'cellular',
      details: {
        isConnectionExpensive: false,
        cellularGeneration: '4g',
      },
    },
  },
  memoryInUse: 83193856,
  thermalState: 'nominal',
};

getBatteryVibe()

Gets the device's current Battery information.

import { VibeChecker } from '@companycam/companycam-vibe-check';

const { battery } = await NativeModules.VibeChecker.getBatteryVibe();

This method will return an object very similar to the below JSON object:

  battery: {
    batteryLevel: 0.5,
    batteryState: 'unplugged',
    lowPowerMode: false,
    isBatteryCharging: false,
  }

getConnectionInfo()

Gets the device's current Network Connection information.

import { getConnectionInfo } from '@companycam/vibe-check';

const { connection } = await getConnectionInfo();

This method will return an object very similar to the below JSON object:

  connection: {
    isConnected: true,
    isInternetReachable: true,
    type: 'cellular',
    details: {
      isConnectionExpensive: false,
      cellularGeneration: '4g',
    },
  }

getRamUsage()

Gets the device's current RAM usage, as a percentage.

import { getRamUsage } from '@companycam/vibe-check';

const { ramUsage } = await getRamUsage();

This method will return an object very similar to the below JSON object:

ramUsage: 0.8; // <-- percentage

getThermalState()

Gets the device's current thermal state.

import { getThermalState } from '@companycam/vibe-check';

const { thermalState } = await getThermalState();

This method will return an object very similar to the below JSON object:

thermalState: 'fair';

📝 NOTE: Since iOS and Android expose different thermal states, we've normalized them. Currently we use iOS nomenclature for the different thermal states. Please refer to the table below.

thermalStateiOS ValueAndroid Value
nominalnominalTHERMAL_STATUS_NONE / THERMAL_STATUS_LIGHT
fairfairTHERMAL_STATUS_MODERATE
seriousseriousTHERMAL_STATUS_SEVERE
criticalcriticalTHERMAL_STATUS_CRITICAL / THERMAL_STATUS_EMERGENCY
unknownunknownunknown

Return object potential values

Battery

PropertyTypeDescription
batteryLevelnumberThe battery level on the device, from 0.0 to 1.0
batteryStatestringunknown, unplugged, charging, full
lowPowerModeboolWhether or not the device is in low power mode

Connectivity

PropertyTypeDescription
isConnectedboolWhether or not the device is connected to the internet
isInternetReachableboolWhether or not the device is connected to the internet
typestringnone, unknown, cellular, wifi, bluetooth, ethernet, wimax, vpn
detailsobjectSee below
Connectivity Details
PropertyTypeDescription
isConnectionExpensiveboolWhether or not the connection is expensive
cellularGenerationstring2g, 3g, 4g, 5g, unknown

Thermal State

PropertyTypeDescription
thermalStatestringnominal, fair, serious, critical

RAM Usage

PropertyTypeDescription
ramUsagenumberRAM Usage on the device from 0.0 to 1.0

Contributing

This project uses conventional commits and semantic-release to automate the release process. Please follow the conventional commits format when making commits.

See the contributing guide to learn how to contribute to the repository and the development workflow.

Made with create-react-native-library

版本与发布记录

@companycam/vibe-check 共发布 5 个版本,首次发布于 2023/12/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.3.0latest2025/01/141.8 年前
0.3.0-beta.0beta2025/01/111.8 年前
0.2.02024/04/192 年前
0.1.02023/12/142 年前
0.0.12023/12/062 年前

关于 @companycam/vibe-check 的常见问题

@companycam/vibe-check 是什么?

Hardware logging library for CompanyCam

如何安装 @companycam/vibe-check?

在项目目录运行 npm install @companycam/vibe-check,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、react-native(*)、react-native-device-info(*)、@react-native-community/netinfo(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@companycam/vibe-check 支持 TypeScript 吗?

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

@companycam/vibe-check 支持 ESM 还是 CommonJS?

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

@companycam/vibe-check 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@companycam/vibe-check 可以商用吗?

@companycam/vibe-check 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@companycam/vibe-check 的下载量有多少?

根据 npm 官方下载统计,@companycam/vibe-check 在 2026/10/11 – 2026/11/09 这 30 天内被下载 20,860 次,日均约 695 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@companycam/vibe-check 还在维护吗?

最新版本 0.3.0 发布于 2025/01/14(1.8 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/12/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。