Coder Social home page Coder Social logo

dystudio / webusb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blazorextensions/webusb

0.0 1.0 0.0 102 KB

HTML5 WebUSB APIs for Microsoft ASP.Net Core Blazor

License: MIT License

TypeScript 29.29% JavaScript 0.93% C# 65.88% HTML 3.90%

webusb's Introduction

Canvas

HTML5 WebUSB API implementation for Microsoft Blazor

Build Package Version NuGet Downloads License

Blazor Extensions

Blazor Extensions are a set of packages with the goal of adding useful things to Blazor.

Blazor Extensions WebUSB

This package wraps HTML5 WebUSB APIs.

Installation

Install-Package Blazor.Extensions.WebUSB

Sample

Usage

  • First add the USB services on Blazor IServiceCollection:
public void ConfigureServices(IServiceCollection services)
{
    services.UseWebUSB(); // Makes IUSB available to the DI container
}

To consume on your .cshtml:

  • On your _ViewImports.cshtml add the using entry:
@using Blazor.Extensions.WebUSB
  • Then, on your .cshtml inject the IUSB:
@inject IUSB usb

And then use the usb object to interact with connected USB devices thru your Blazor application.

To inject on a BlazorComponent class:

Define a property of type IUSB and mark it as [Injectable]:

[Inject] private IUSB _usb { get; set; }

Then use the _usb variable to interact with the connected USB devices.

Note: For now, you have to call await IUSB.Initialize() once in your application. This is a temporary requirement and we are looking on a better way to automatically register to Connect/Disconnect events.

Contributions and feedback

Please feel free to use the component, open issues, fix bugs or provide feedback.

Contributors

The following people are the maintainers of the Blazor Extensions projects:

webusb's People

Contributors

galvesribeiro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.