@mmote/niimblue-node 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,11 +6,19 @@ Command line interface, simple REST server are also included.
6
6
 
7
7
  Tested with:
8
8
 
9
+ Windows:
10
+
9
11
  * Windows 10
10
12
  * Bluetooth adapter (TP-LINK UB500)
11
13
  * USB serial connection
12
14
  * Printers: B1, D110
13
15
 
16
+ Mac:
17
+
18
+ * macOS 15.5
19
+ * Integrated Bluetooth adapter
20
+ * Printer: D110
21
+
14
22
  Usage example:
15
23
 
16
24
  * [src/service.ts](src/service.ts)
@@ -32,6 +40,11 @@ Windows requirements:
32
40
  - C++ build tools with `Windows SDK >=22000` must be installed
33
41
  * Python 3
34
42
 
43
+ Mac requirements:
44
+
45
+ * [Xcode](https://apps.apple.com/ca/app/xcode/id497799835)
46
+ * Permissions: Open "System Settings" → "Privacy & Security" → "Bluetooth" and then add your terminal to allowed applications.
47
+
35
48
  See [node-gyp](https://github.com/nodejs/node-gyp) and [noble](https://github.com/abandonware/noble) installation.
36
49
 
37
50
  ### Command-line usage
@@ -72,7 +85,15 @@ D110 BLE:
72
85
  niimblue-cli print -d -t ble -a 26:03:03:c3:f9:11 -p D110 -o left label_15x30.png
73
86
  ```
74
87
 
75
- B1 serial, long parameter names (will resize image to fit 50x30 label keeping aspect ration):
88
+ D110 BLE via name:
89
+
90
+ _Connecting via the Bluetooth device name instead of address is required on macOS. Find the device name with `niimblue-cli scan -t ble`._
91
+
92
+ ```bash
93
+ niimblue-cli print -d -t ble -a 'D110-XXXXXXXXXX' -p D110 -o left -w 192 -h 96 label_15x30.png
94
+ ```
95
+
96
+ B1 serial, long parameter names (will resize image to fit 50x30 label, keeping aspect ratio):
76
97
 
77
98
  ```bash
78
99
  niimblue-cli print --debug --transport serial --address COM8 --print-task B1 --print-direction top --label-width 384 --label-height 240 label_15x30.png
@@ -98,4 +119,4 @@ Enable debug logging, set host and port, enable CORS:
98
119
  niimblue-cli server -d -h 0.0.0.0 -p 5000 --cors
99
120
  ```
100
121
 
101
- [Server API docs](https://multimote.github.io/niimblue-node/server/)
122
+ [Server API docs](https://niimnode-docs.pages.dev/server/)
package/dist/cli/index.js CHANGED
@@ -17,7 +17,7 @@ extra_typings_1.program
17
17
  .description("Printer information")
18
18
  .requiredOption("-d, --debug", "Debug information", false)
19
19
  .addOption(new extra_typings_1.Option("-t, --transport <type>", "Transport").makeOptionMandatory().choices(["ble", "serial"]))
20
- .requiredOption("-a, --address <string>", "Device bluetooth address or serial port name/path")
20
+ .requiredOption("-a, --address <string>", "Device bluetooth address/name or serial port name/path")
21
21
  .action(worker_1.cliPrinterInfo);
22
22
  extra_typings_1.program
23
23
  .command("scan")
@@ -31,7 +31,7 @@ extra_typings_1.program
31
31
  .argument("<path>", "PNG image path")
32
32
  .requiredOption("-d, --debug", "Debug information", false)
33
33
  .addOption(new extra_typings_1.Option("-t, --transport <type>", "Transport").makeOptionMandatory().choices(["ble", "serial"]))
34
- .requiredOption("-a, --address <string>", "Device bluetooth address or serial port name/path")
34
+ .requiredOption("-a, --address <string>", "Device bluetooth address/name or serial port name/path")
35
35
  .addOption(new extra_typings_1.Option("-o, --print-direction <dir>", "Print direction").choices(["left", "top"]))
36
36
  .addOption(new extra_typings_1.Option("-p, --print-task <type>", "Print task").choices(niimbluelib_1.printTaskNames))
37
37
  .requiredOption("-l, --label-type <type number>", "Label type", intOption, 1)
@@ -46,7 +46,7 @@ extra_typings_1.program
46
46
  "fill",
47
47
  "inside",
48
48
  "outside",
49
- ]).default("contain"))
49
+ ]))
50
50
  .addOption(new extra_typings_1.Option("-m, --image-position <dir>", "Image position while resizing (label-width and label-height must be set)").choices([
51
51
  "left",
52
52
  "top",
@@ -57,7 +57,7 @@ extra_typings_1.program
57
57
  "bottom",
58
58
  "left bottom",
59
59
  "left top",
60
- ]).default("centre"))
60
+ ]))
61
61
  .action(worker_1.cliConnectAndPrintImageFile);
62
62
  extra_typings_1.program
63
63
  .command("server")
@@ -72,7 +72,7 @@ extra_typings_1.program
72
72
  .description("Flash firmware")
73
73
  .requiredOption("-d, --debug", "Debug information", false)
74
74
  .addOption(new extra_typings_1.Option("-t, --transport <type>", "Transport").makeOptionMandatory().choices(["ble", "serial"]))
75
- .requiredOption("-a, --address <string>", "Device bluetooth address or serial port name/path")
75
+ .requiredOption("-a, --address <string>", "Device bluetooth address/name or serial port name/path")
76
76
  .requiredOption("-f, --file <path>", "Firmware path")
77
77
  .requiredOption("-n, --new-version <version>", "New firmware version")
78
78
  .action(worker_1.cliFlashFirmware);
@@ -31,8 +31,8 @@ export interface PrintOptions {
31
31
  threshold: number;
32
32
  labelWidth?: number;
33
33
  labelHeight?: number;
34
- imageFit: SharpImageFit;
35
- imagePosition: SharpImagePosition;
34
+ imageFit?: SharpImageFit;
35
+ imagePosition?: SharpImagePosition;
36
36
  debug: boolean;
37
37
  }
38
38
  export declare const cliConnectAndPrintImageFile: (path: string, options: PrintOptions & TransportOptions) => Promise<never>;
@@ -20,8 +20,8 @@ const cliConnectAndPrintImageFile = async (path, options) => {
20
20
  if (options.labelWidth !== undefined && options.labelHeight !== undefined) {
21
21
  image = image.resize(options.labelWidth, options.labelHeight, {
22
22
  kernel: sharp_1.default.kernel.nearest,
23
- fit: options.imageFit,
24
- position: options.imagePosition,
23
+ fit: options.imageFit ?? "contain",
24
+ position: options.imagePosition ?? "centre",
25
25
  background: "#fff",
26
26
  });
27
27
  }
@@ -8,7 +8,7 @@ export declare class NiimbotHeadlessBleClient extends NiimbotAbstractClient {
8
8
  private device;
9
9
  private channel;
10
10
  constructor();
11
- /** Set device mac address for connect */
11
+ /** Set device mac address or name for connect */
12
12
  setAddress(address: string): void;
13
13
  static waitAdapterReady(): Promise<void>;
14
14
  static scan(timeoutMs?: number): Promise<ScanItem[]>;
@@ -11,9 +11,9 @@ class NiimbotHeadlessBleClient extends niimbluelib_1.NiimbotAbstractClient {
11
11
  super();
12
12
  this.addr = "";
13
13
  }
14
- /** Set device mac address for connect */
14
+ /** Set device mac address or name for connect */
15
15
  setAddress(address) {
16
- this.addr = address.toLowerCase();
16
+ this.addr = address;
17
17
  }
18
18
  static async waitAdapterReady() {
19
19
  if (noble_1.default._state === "poweredOn") {
@@ -63,7 +63,8 @@ class NiimbotHeadlessBleClient extends niimbluelib_1.NiimbotAbstractClient {
63
63
  return new Promise((resolve, reject) => {
64
64
  let timer;
65
65
  noble_1.default.on("discover", async (peripheral) => {
66
- if (peripheral.address === address) {
66
+ if (peripheral.address === address.toLowerCase() ||
67
+ peripheral.advertisement.localName === address) {
67
68
  clearTimeout(timer);
68
69
  resolve(peripheral);
69
70
  }
@@ -115,7 +116,7 @@ class NiimbotHeadlessBleClient extends niimbluelib_1.NiimbotAbstractClient {
115
116
  async connect() {
116
117
  await this.disconnect();
117
118
  if (!this.addr) {
118
- throw new Error("Device address not set");
119
+ throw new Error("Device address or name not set");
119
120
  }
120
121
  await this.connectToDevice(this.addr);
121
122
  try {
@@ -15,7 +15,7 @@ export declare const connected: () => Promise<{
15
15
  export declare const info: () => Promise<{
16
16
  printerInfo: import("@mmote/niimbluelib").PrinterInfo;
17
17
  modelMetadata: import("@mmote/niimbluelib").PrinterModelMeta | undefined;
18
- detectedPrintTask: "D11_V1" | "D110" | "B1" | "B21_V1" | "V5" | undefined;
18
+ detectedPrintTask: "D11_V1" | "D110" | "B1" | "B21_V1" | "D110M_V4" | undefined;
19
19
  }>;
20
20
  export declare const print: (r: IncomingMessage) => Promise<{
21
21
  message: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmote/niimblue-node",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Headless clients for niimbluelib. Command line interface, simple REST server are also included.",
5
5
  "keywords": [
6
6
  "command-line",
@@ -39,11 +39,12 @@
39
39
  "dependencies": {
40
40
  "@abandonware/noble": "^1.9.2-26",
41
41
  "@commander-js/extra-typings": "^12.1.0",
42
- "@mmote/niimbluelib": "0.0.1-alpha.24",
42
+ "@mmote/niimbluelib": "0.0.1-alpha.26",
43
43
  "async-mutex": "^0.5.0",
44
44
  "commander": "^12.1.0",
45
45
  "serialport": "^12.0.0",
46
46
  "sharp": "^0.33.5",
47
47
  "zod": "^3.23.8"
48
- }
48
+ },
49
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
49
50
  }