JSPM

raycast-hid

0.1.2
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • 0
    • Score
      100M100P100Q24082F
    • License MIT

    Access USB HID devices from Raycast

    Package Exports

    • raycast-hid
    • raycast-hid/distribution/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (raycast-hid) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    raycast-hid

    Access USB HID devices from Raycast

    Background

    Due to the problem of Raycast building extension, you need to manually copy HID prebuilds to your extension folder. Also, Raycast only allows attachments to be placed in the assets directory. However, node-hid can only find driver files in its own directory. This package prepares a set of methods to facilitate your HID-related development in Raycast.

    Install

    npm i raycast-hid

    Usage

    1. Setup prebuilds to your extension

    Run npx raycast-hid-setup under your extension project directory to setup HID prebuilds to the assets folder.

    2. Prepare prebuilds before running your extension

    Remember to run preparePrebuilds() before you use any function from the HID.

    import { useEffect, useState } from "react";
    import { List } from "@raycast/api";
    import { HID, preparePrebuilds } from "raycast-hid";
    
    export default function Command() {
        const [isLoading, setIsLoading] = useState(true);
    
        const loadPrebuilds = async () => {
            await preparePrebuilds();
            setIsLoading(false);
            console.log(HID.devices());
        };
    
        useEffect(() => {
            loadPrebuilds();
        }, []);
    
        return <List isLoading={isLoading} />;
    }

    API

    preparePrebuilds()

    This function programmatically copies the prebuilds files from assets/prebuilds to the correct directory for node-hid.

    HID

    This exposes all node-hid functions. For example:

    import { HID } from "raycast-hid";
    
    console.log(HID.devices());
    • node-hid - Access USB & Bluetooth HID devices through Node.js

    License

    MIT