usb 2.2.0 → 2.3.0

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +16 -2
  3. package/dist/usb/index.js +7 -16
  4. package/dist/usb/index.js.map +1 -1
  5. package/libusb/.private/ci-container-build.sh +70 -0
  6. package/libusb/AUTHORS +10 -0
  7. package/libusb/ChangeLog +13 -0
  8. package/libusb/android/examples/unrooted_android.c +3 -4
  9. package/libusb/appveyor.yml +4 -0
  10. package/libusb/configure.ac +14 -1
  11. package/libusb/libusb/Makefile.am +1 -1
  12. package/libusb/libusb/core.c +17 -5
  13. package/libusb/libusb/hotplug.c +3 -0
  14. package/libusb/libusb/io.c +32 -8
  15. package/libusb/libusb/libusb.h +7 -0
  16. package/libusb/libusb/libusbi.h +22 -4
  17. package/libusb/libusb/os/darwin_usb.c +77 -20
  18. package/libusb/libusb/os/linux_usbfs.c +1 -1
  19. package/libusb/libusb/os/windows_common.c +14 -3
  20. package/libusb/libusb/os/windows_common.h +2 -1
  21. package/libusb/libusb/os/windows_winusb.c +30 -3
  22. package/libusb/libusb/version.h +1 -1
  23. package/libusb/libusb/version_nano.h +1 -1
  24. package/libusb/tests/Makefile.am +12 -1
  25. package/libusb/tests/umockdev.c +1175 -0
  26. package/package.json +1 -1
  27. package/prebuilds/android-arm/node.napi.armv7.node +0 -0
  28. package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
  29. package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
  30. package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
  31. package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
  32. package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
  33. package/prebuilds/linux-ia32/node.napi.node +0 -0
  34. package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  35. package/prebuilds/linux-x64/node.napi.musl.node +0 -0
  36. package/prebuilds/win32-ia32/node.napi.node +0 -0
  37. package/prebuilds/win32-x64/node.napi.node +0 -0
  38. package/tsc/usb/index.ts +5 -8
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "usb",
3
3
  "description": "Library to access USB devices",
4
4
  "license": "MIT",
5
- "version": "2.2.0",
5
+ "version": "2.3.0",
6
6
  "main": "dist/index.js",
7
7
  "engines": {
8
8
  "node": ">=10.16.0"
Binary file
Binary file
Binary file
package/tsc/usb/index.ts CHANGED
@@ -45,7 +45,7 @@ declare module './bindings' {
45
45
  const pollTimeout = 500;
46
46
  const hotplugSupported = usb._getLibusbCapability(usb.LIBUSB_CAP_HAS_HOTPLUG) > 0;
47
47
  let pollingHotplug = false;
48
- let pollDevices: usb.Device[] = [];
48
+ let pollDevices = new Set<usb.Device>();
49
49
 
50
50
  const pollHotplug = (start = false) => {
51
51
  if (start) {
@@ -54,23 +54,20 @@ const pollHotplug = (start = false) => {
54
54
  return;
55
55
  }
56
56
 
57
- const devices = usb.getDeviceList();
57
+ // Collect current devices
58
+ const devices = new Set(usb.getDeviceList());
58
59
 
59
60
  if (!start) {
60
61
  // Find attached devices
61
62
  for (const device of devices) {
62
- const found = pollDevices.find(item => item.deviceAddress === device.deviceAddress);
63
- if (!found) {
63
+ if (!pollDevices.has(device))
64
64
  usb.emit('attach', device);
65
- }
66
65
  }
67
66
 
68
67
  // Find detached devices
69
68
  for (const device of pollDevices) {
70
- const found = devices.find(item => item.deviceAddress === device.deviceAddress);
71
- if (!found) {
69
+ if (!devices.has(device))
72
70
  usb.emit('detach', device);
73
- }
74
71
  }
75
72
  }
76
73