niimbluelib — browser client for NIIMBOT printers
https://github.com/MultiMote/niimbluelib
MIT licence (see LICENSE alongside this file).

File:    niimbluelib.min.js (UMD build, exposes window.niimbluelib)
Version: 0.0.1-alpha.42          <- PINNED. Do not float this.
Source:  https://cdn.jsdelivr.net/npm/@mmote/niimbluelib@0.0.1-alpha.42/dist/umd/niimbluelib.min.js
Size:    100,714 bytes


TAKE THE PLAIN BUILD, NEVER THE "-node" ONE
-------------------------------------------
npm tags the -node variant as `latest`. As of 2026-08-13 that is
0.0.1-alpha.42-node, while the plain current build is 0.0.1-alpha.42.

The -node build compiles the Node serialport bindings into the same UMD bundle:
403 KB instead of 98 KB, carrying require("stream") and __dirname, neither of
which exists in a browser.

This trap has been hit once already, in the Fragnatium implementation this code
was ported from. If you re-vendor, verify:

    wc -c niimbluelib.min.js                 # ~100 KB, not ~400 KB
    grep -c 'require("stream")' *.min.js     # must be 0
    grep -c '__dirname'         *.min.js     # must be 0


IT IS ALPHA SOFTWARE
--------------------
Every release so far is 0.0.1-alpha.N. That is acceptable — it is the only
implementation of this protocol that exists, it is actively maintained, and it
is MIT — but it means:

  * Pin the exact version (done, above).
  * On upgrade, RE-VERIFY THE MODEL TABLE against src/printer_models.ts
    upstream. Tagloom reads dpi, print direction, printhead width and density
    bounds from it, and an alpha library may change any of them. Those numbers
    decide what physically comes out of a customer's printer.
  * Upgrade deliberately, never routinely. A dependency bump that changes what
    comes out of a printer is not a chore commit.


WHAT TAGLOOM USES FROM IT
------------------------
  NiimbotBluetoothClient   Web Bluetooth transport
  ImageEncoder             canvas -> wire format, honouring printDirection
  LabelType                media enum (WithGaps=1, Black=2, Continuous=3,
                           Perforated=4, Transparent=5, PvcTag=6,
                           BlackMarkGap=10, HeatShrinkTube=11)
  PrinterModel             model-name enum
  PrinterErrorCode         38 error codes -> see docs/specs/printer-errors-and-recovery.md
  getPrinterMetaById       hardware id -> capability row
  findPrintTask            model -> print task implementation


IDENTIFICATION IS NOT CAPABILITY
--------------------------------
Verified against this build on 2026-08-13:

  PrinterModel enum names ....... 80
  capability table rows ......... 76

Four names have NO capability row: UNKNOWN, DXX, and the shipping products
D41 and D61. So a D41 owner connects, the library identifies the model by
name, and there is still no dpi, print direction, printhead width or density
range to render with.

Resolve the ROW, not the name. Treat a missing row as Unknown however
confidently the printer announced itself, and report the hardware id so the row
can be added upstream.


WHAT THE BUNDLE EMBEDS
----------------------
The UMD build inlines two small MIT-licensed dependencies, both visible as
attribution comments near the top of the minified file:

  Capacitor   https://capacitorjs.com/          MIT
  crc32.js    (C) 2014-present SheetJS          MIT

Both are compatible with GPL-2.0-or-later and neither makes a network request —
they are a platform shim and a checksum. They are noted here because a
wordpress.org reviewer reading the bundle will find two URLs in a plugin that
claims to make no external requests, and the answer should be written down
rather than reconstructed.

The plugin itself issues no cross-origin request of any kind: every fetch goes
to this site's own REST API. `no-external-requests.test.js` enforces that.
