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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yume-chan/adb-backend-webusb

v0.0.19

Published

Backend for `@yume-chan/adb` using WebUSB API.

Downloads

3,231

Readme

@yume-chan/adb-backend-webusb

Backend for @yume-chan/adb using WebUSB (MDN, Spec) API.

Use in browser

| Chrome | Edge | Firefox | Internet Explorer | Safari | | -------------- | -------------- | ------- | ----------------- | ------ | | 611 | 791 | No | No | No |

1: Chrome for Android is supported, Chrome for iOS is NOT supported.

Use in Node.js

| Node.js | usb NPM Package | | ------- | ----------------- | | 10.5 | 2.8.1 |

Node.js doesn't have native support for WebUSB API, but the usb NPM package provides a WebUSB compatible API.

To use a custom WebUSB API implementation, pass it to the constructor of AdbWebUsbBackend, AdbWebUsbBackendManager and AdbWebUsbBackendWatcher via the usb parameter.

AdbWebUsbBackend

constructor

public constructor(
    device: USBDevice,
    filters: AdbDeviceFilter[] = [ADB_DEFAULT_DEVICE_FILTER]
    usb: USB
);

Create a new instance of AdbWebBackend using a specified USBDevice instance.

USBDevice and USB types are from WebUSB API.

The filters parameter specifies the classCode, subclassCode and protocolCode to use when searching for ADB interface. The default value is [{ classCode: 0xff, subclassCode: 0x42, protocolCode: 0x1 }], defined by Google.

connect

public async connect(): Promise<
    ReadableWritablePair<AdbPacketData, AdbPacketInit>
>

Claim the device and create a pair of AdbPacket streams to the ADB interface.

AdbWebUsbBackendManager

A helper class that wraps the WebUSB API.

BROWSER

public static readonly BROWSER: AdbWebUsbBackendManager | undefined;

Gets the instance of AdbWebUsbBackendManager using browser WebUSB implementation.

May be undefined if the browser does not support WebUSB.

constructor

public constructor(usb: USB);

Create a new instance of AdbWebUsbBackendManager using the specified WebUSB API implementation.

requestDevice

public async requestDevice(
    filters: AdbDeviceFilter[] = [ADB_DEFAULT_DEVICE_FILTER]
): Promise<AdbWebUsbBackend | undefined>

Request access to a connected device. This is a convince method for usb.requestDevice().

The filters parameter must have classCode, subclassCode and protocolCode fields for selecting the ADB interface. It can also have vendorId, productId or serialNumber fields to limit the displayed device list.

Returns an AdbWebUsbBackend instance, or undefined if the user cancelled the picker.

getDevices

public async getDevices(
    filters: AdbDeviceFilter[] = [ADB_DEFAULT_DEVICE_FILTER]
): Promise<AdbWebUsbBackend[]>

Get all connected and authenticated devices.

This is a convince method for usb.getDevices().

Note on secure context

WebUSB requires a secure context (HTTPS).

localhost is considered secure, so local development works. But to access a self-hosted server running on another machine, either add a certificate, or add the domain name to the allowlist on each client machine:

  1. Open chrome://flags/#unsafely-treat-insecure-origin-as-secure
  2. Add the protocol and domain part of your url (e.g. http://192.168.0.100:9000) to the input box
  3. Choose Enable from the dropdown menu
  4. Restart browser