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

@flatbiz/device

v2.0.0

Published

增强 H5 设备信息采集能力:`deviceInfo` 支持自定义/自动获取 IP、屏幕分辨率字符串,并合并 UA 解析结果;补充 Vitest 单测与 Vite 本地演示。

Downloads

253

Readme

@flatbiz/device

增强 H5 设备信息采集能力:deviceInfo 支持自定义/自动获取 IP、屏幕分辨率字符串,并合并 UA 解析结果;补充 Vitest 单测与 Vite 本地演示。

Breaking Changes

  • deviceInfo 改为异步 API:由同步函数改为 async,返回 Promise<FlatbizDevice>,调用方需使用 await deviceInfo().then()
  • 移除 utils 模块getDeviceId 统一从 helper-get-deviceId 导出,不再通过 src/utils.ts

Features

  • 新增 DeviceInfoOptions 可选参数:
    • ip:传入服务端下发的 IP,优先于自动获取
    • autoGetIp:为 true 时通过 https://api.ipify.org?format=json 拉取公网 IP(默认 false
    • isDebug:为 true 时在控制台输出非浏览器环境或解析失败等错误信息(默认 false
  • 新增返回字段 ipscreenSize(格式 {width}x{height},如 390x844
  • 非浏览器环境(typeof window === 'undefined')安全返回 {},避免 SSR/Node 直接调用抛错
  • 新增 helpers:getIpgetWindowSizegetDeviceId 独立为 helper-get-deviceId
  • 开发体验:补充 Vitest 单元测试;yarn demo(Vite)可本地预览 public/index.html

deviceInfo() 返回字段

H5 终端(FlatbizDeviceInfo

  • ipdeviceIdlanguage
  • screenWidthscreenHeightscreenSizescreenDensity
  • networkTypetimezonetimezoneOffsetsystemDatesystemTime
  • colorDepthtouchSupportpluginspluginNumcookiesEnable

UA 解析(FlatbizUaParserResult

  • userAgentbrowserNamebrowserVersion
  • engineNameengineVersion
  • osNameosVersioncpuModel
  • deviceTypedeviceVendordeviceModel

Usage

import { deviceInfo } from '@flatbiz/device';

// 自定义 IP(推荐由服务端下发)
const info = await deviceInfo({ ip: '203.0.113.1' });

// 自动获取公网 IP
const info2 = await deviceInfo({ autoGetIp: true });

// 调试模式
const info3 = await deviceInfo({ isDebug: true });