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

bluestar-android

v1.0.0

Published

Android WebView 桥接工具集,提供拍照、权限请求、分享等原生交互能力

Readme

bluestar-android

Android WebView 桥接工具集,用于在 WebView 中调用 Android 原生能力。

环境要求

  • window.Android 桥接对象(Android 端注入,实现 AndroidBridge 接口)

安装

npm install bluestar-android

API

takePhoto()

调用 Android 相机拍照,返回图片元素。

import { takePhoto } from 'bluestar-android';

const img = await takePhoto();
document.body.appendChild(img);

share()

拍照后直接分享到 Android 应用。

import { share } from 'bluestar-android';

await share();

requestLocationPermission(permissionCode, title, message)

请求 Android 权限。

import { requestLocationPermission, ANDROID_PERMISSIONS } from 'bluestar-android';

const granted = await requestLocationPermission(
    ANDROID_PERMISSIONS.CAMERA,
    '请求相机权限',
    '本应用需要获取您的相机权限'
);

checkVersion()

检测 Chrome 浏览器版本号。

import { checkVersion } from 'bluestar-android';

const version = checkVersion(); // 如 "120.0.6099.144"

convertImageToBase64(image)

将 HTMLImageElement 转换为 Base64 编码的 PNG 字符串。

import { convertImageToBase64 } from 'bluestar-android';

const base64 = convertImageToBase64(imgElement);

ANDROID_PERMISSIONS

Android 权限常量。

| 常量 | 值 | |---|---| | INTERNET | android.permission.INTERNET | | ACCESS_FINE_LOCATION | android.permission.ACCESS_FINE_LOCATION | | ACCESS_COARSE_LOCATION | android.permission.ACCESS_COARSE_LOCATION | | ACCESS_WIFI_STATE | android.permission.ACCESS_WIFI_STATE | | ACCESS_NETWORK_STATE | android.permission.ACCESS_NETWORK_STATE | | ACCESS_LOCATION_EXTRA_COMMANDS | android.permission.ACCESS_LOCATION_EXTRA_COMMANDS | | MODIFY_AUDIO_SETTINGS | android.permission.MODIFY_AUDIO_SETTINGS | | CAMERA | android.permission.CAMERA | | RECORD_AUDIO | android.permission.RECORD_AUDIO |

Android 端要求

Android 原生侧需在 WebView 中注入 window.Android 对象,实现以下接口:

interface AndroidBridge {
    fun takePhoto()
    fun share(base64: String)
    fun requestPermission(permissionCode: String, title: String, message: String)
}

并回调以下 Window 方法:

  • window.onAndroidPermissionRequest(message: string, status: boolean) — 权限请求结果
  • window.onAndroidBridgeMessage(type: string, eventString: string) — 拍照等事件回调,eventString{ result: boolean, uri: string } 的 JSON