Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2: Ignore other devices #48

Merged
merged 3 commits into from
Jan 8, 2024
Merged

Conversation

Cellivar
Copy link
Owner

@Cellivar Cellivar commented Jan 8, 2024

An early design oversight has lead to a v2 release. The connectedDevice event performs no checking to ensure the device that connected is one the library cares about. I never tested the scenario of connecting something other than a bunch of laser printers at the same time until now. Since that required an API change I figured I'd add as much API-breaking-changes in one go as I could.

Anyway.

This includes a switch to Vite, which I've found a VERY pleasant ecosystem to work within for building the package.

Breaking changes:

  • USBDeviceManager is the new manager class.
  • LabelPrinter is the new Printer class.
  • A few other ancillary classes became interfaces and names changes slightly. The types should be self-explanatory to follow.

Copy link

github-actions bot commented Jan 8, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 34.77% 1991 / 5726
🔵 Statements 34.77% 1991 / 5726
🔵 Functions 23% 49 / 213
🔵 Branches 68.84% 95 / 138
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
demo/test_advanced.ts 0% 0% 0% 0% 1-475
demo/test_index.ts 0% 0% 0% 0% 1-437
demo/ts-browser.js 0% 0% 0% 0% 1-54
src/NumericRange.ts 50% 100% 33.33% 50% 16-30, 33-34
src/PrinterUsbManager.ts 18.18% 0% 0% 18.18% 35-187
src/WebZlpError.ts 57.14% 100% 0% 57.14% 4-6
src/index.ts 100% 100% 100% 100%
src/Documents/BitmapGRF.ts 77.61% 86.95% 75% 77.61% 60-61, 123-135, 149-193, 217-218, 220-221, 279-314, 363-366, 475-477
src/Documents/Commands.ts 46.04% 31.25% 16.27% 46.04% 89-95, 101-102, 112, 122-129, 132-138, 141-147, 151-157, 164-165, 174-175, 184-185, 191-207, 211-225, 229-243, 247-272, 275-283, 287-295, 299-307, 311-319, 323-335, 339-347, 351-372, 376-382, 389-393, 404-416, 420-432, 440-442
src/Documents/ConfigDocument.ts 64.08% 83.33% 26.31% 64.08% 37-38, 41-42, 57-60, 63-64, 67-95, 100-101, 104-110, 113-116, 119-122, 125-131, 134-138, 141-151, 154-166, 275-284
src/Documents/Document.ts 81.7% 100% 45.45% 81.7% 24-25, 31-34, 41-42, 59-60, 64-66, 70-71
src/Documents/LabelDocument.ts 74.52% 75% 12.5% 74.52% 33-34, 41-42, 45-46, 49-50, 53-54, 59-60, 63-66, 69-70, 73-74, 79-88, 91-95, 98-106, 109-110, 113-120
src/Documents/ReadyToPrintDocuments.ts 43.61% 100% 16.66% 43.61% 13-14, 20-21, 26-27, 44-78, 82-93
src/Documents/index.ts 100% 100% 100% 100%
src/Printers/Printer.ts 9.58% 0% 0% 9.58% 22-219
src/Printers/index.ts 100% 100% 100% 100%
src/Printers/Communication/DeviceCommunication.ts 90.21% 50% 0% 90.21% 79-85, 90-91
src/Printers/Communication/LineBreakTransformer.ts 7.14% 0% 0% 7.14% 2-14
src/Printers/Communication/UsbPrinterDeviceChannel.ts 7.49% 0% 0% 7.49% 16-30, 34-298, 303-306
src/Printers/Configuration/MediaOptions.ts 83.09% 100% 66.66% 83.09% 93-127
src/Printers/Configuration/PrinterOptions.ts 71.53% 100% 20% 71.53% 23-24, 27-28, 31-32, 36-37, 40-41, 45-46, 60-61, 65-66, 70-71, 74-75, 93-95, 98-111
src/Printers/Configuration/SerialPortSettings.ts 100% 100% 100% 100%
src/Printers/Languages/EplPrinterCommandSet.ts 16.78% 100% 19.04% 16.78% 21-22, 25-28, 31-34, 56-130, 133-423, 426-430, 433-437, 440-445, 448-459, 462-471, 474-479, 482-488, 491-496, 499-505, 508-513, 540-558, 561-571
src/Printers/Languages/PrinterCommandSet.ts 47.22% 71.42% 21.05% 47.22% 27-28, 83-101, 104-135, 138-149, 152-187, 193-198, 201-204, 210-212, 216-220, 224-235, 253-254, 265-279, 293-296, 302-310, 315-324
src/Printers/Languages/ZplPrinterCommandSet.ts 2.4% 0% 0% 2.4% 14-540
src/Printers/Models/EplPrinterModels.ts 47.45% 0% 0% 47.45% 7-8, 11-12, 17-35, 39-40, 45-46, 51-52, 57-58
src/Printers/Models/PrinterModel.ts 72.07% 100% 0% 72.07% 83-84, 88-90, 94-105, 111-112, 114-115, 117-118, 120-121, 123-124, 133-134, 136-137, 139-140, 142-143, 146-153
src/Printers/Models/PrinterModelDb.ts 14.56% 100% 0% 14.56% 10-51, 55-75, 78-102
Generated in workflow #109

Cellivar added a commit to Cellivar/WebReceiptLinePrinter that referenced this pull request Jan 8, 2024
A bug that only arose when I was testing with my [other
library](Cellivar/WebZLP#48), connecting device
events would react to _any_ devices connecting. This caused some
fighting.

This adds filtering identical to the filtering done when prompting the
user for a new device.
@Cellivar Cellivar merged commit 6b5ed1f into main Jan 8, 2024
1 check passed
@Cellivar Cellivar deleted the feature/ignore-other-usb-devices branch January 8, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant