Skip to content

husky-dev/niimbot

Repository files navigation

Niimbot Web Client

A Niimbot client for web browsers written in TypeScript.

Installation

yarn add niimbot
# or
npm install niimbot

Usage

Import:

import { Niimbot } from 'niimbot';

Check if Niimbot is available at the current browser:

const isAvailable = Niimbot.available();

Create a Niimbot instance:

const niimbot = new Niimbot();

Add events listeners:

niimbot.addEventListener('connect', handleConnect);
niimbot.addEventListener('disconnect', handleDisconnect);
niimbot.addEventListener('printStart', handlePrintStart);
niimbot.addEventListener('printEnd', handlePrintEnd);

Connect to the printer:

const port = await niimbot.requestPort();
if (port) {
  await niimbot.connect(port);
}

Print a sticker drawed on a canvas:

const canvas = document.getElementById('canvas') as HTMLCanvasElement;
const ctx = canvas.getContext('2d');
if (ctx) {
  await niimbot.printImage(ctx, canvas.width, canvas.height);
}

Check src/demo.tsx for a complete example.

Development

yarn install
yarn dev

Contacts

Jaroslav Khorishchenko

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published