usb 1.8.1 → 1.8.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.8.2] - 2022-01-07
4
+
5
+ ### Added
6
+ - Added definition for `NAPI_VERSION 4` and added N-API v4 target to prebuildify - ([Rob Moran](https://github.com/thegecko))
7
+
8
+ ### Fixed
9
+ - Fixed exit delay and hang by moving queue start/stop to device open/close - [`460`](https://github.com/node-usb/node-usb/pull/460) ([MikeColeGuru](https://github.com/MikeColeGuru))
10
+
3
11
  ## [1.8.1] - 2021-11-08
4
12
 
5
13
  ### Added
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "usb",
3
3
  "description": "Library to access USB devices",
4
- "version": "1.8.1",
4
+ "version": "1.8.2",
5
5
  "engines": {
6
6
  "node": ">=10.16.0"
7
7
  },
@@ -37,16 +37,16 @@
37
37
  "scripts": {
38
38
  "install": "node-gyp-build",
39
39
  "test": "mocha --require coffeescript/register --grep Module test/*",
40
- "full-test": "mocha --require coffeescript/register test/*",
41
- "valgrind": "coffee -c test/usb.coffee; valgrind --leak-check=full --show-possibly-lost=no node --expose-gc --trace-gc node_modules/mocha/bin/_mocha -R spec",
42
- "prebuild": "prebuildify --napi --strip",
43
- "prebuild-darwin": "prebuildify --napi --strip --arch x64+arm64",
44
- "prebuild-win32-x86": "prebuildify --napi --strip",
45
- "prebuild-win32-x64": "prebuildify --napi --strip",
46
- "prebuild-linux-x86": "prebuildify-cross -i ghcr.io/node-usb/linux-x86 --napi --strip",
47
- "prebuild-linux-x64": "prebuildify-cross -i ghcr.io/node-usb/centos7-devtoolset7 -i ghcr.io/node-usb/alpine --napi --strip --tag-libc",
48
- "prebuild-linux-arm": "prebuildify-cross -i ghcr.io/node-usb/linux-arm64 -i ghcr.io/node-usb/linux-armv7 -i ghcr.io/node-usb/linux-armv6 --napi --strip --tag-armv",
49
- "prebuild-android-arm": "prebuildify-cross -i ghcr.io/node-usb/android-arm64 -i ghcr.io/node-usb/android-armv7 --napi --strip --tag-armv",
40
+ "full-test": "mocha --require coffeescript/register test/*.coffee",
41
+ "valgrind": "coffee -c test/*.coffee; valgrind --leak-check=full --show-possibly-lost=no node --expose-gc --trace-gc node_modules/mocha/bin/_mocha -R spec",
42
+ "prebuild": "prebuildify --napi --target 10.16.0 --strip",
43
+ "prebuild-darwin": "prebuildify --napi --target 10.16.0 --strip --arch x64+arm64",
44
+ "prebuild-win32-x86": "prebuildify --napi --target 10.16.0 --strip",
45
+ "prebuild-win32-x64": "prebuildify --napi --target 10.16.0 --strip",
46
+ "prebuild-linux-x86": "prebuildify-cross -i ghcr.io/node-usb/linux-x86 --napi --target 10.16.0 --strip",
47
+ "prebuild-linux-x64": "prebuildify-cross -i ghcr.io/node-usb/centos7-devtoolset7 -i ghcr.io/node-usb/alpine --napi --target 10.16.0 --strip --tag-libc",
48
+ "prebuild-linux-arm": "prebuildify-cross -i ghcr.io/node-usb/linux-arm64 -i ghcr.io/node-usb/linux-armv7 -i ghcr.io/node-usb/linux-armv6 --napi --target 10.16.0 --strip --tag-armv",
49
+ "prebuild-android-arm": "prebuildify-cross -i ghcr.io/node-usb/android-arm64 -i ghcr.io/node-usb/android-armv7 --napi --target 10.16.0 --strip --tag-armv",
50
50
  "prebuild-download": "prebuildify-ci download"
51
51
  },
52
52
  "dependencies": {
Binary file
Binary file
Binary file
package/src/device.cc CHANGED
@@ -19,11 +19,6 @@ Device::Device(const Napi::CallbackInfo & info) : Napi::ObjectWrap<Device>(info)
19
19
  device = info[0].As<Napi::External<libusb_device>>().Data();
20
20
  libusb_ref_device(device);
21
21
  byPtr.insert(std::make_pair(device, this));
22
- #ifndef USE_POLL
23
- completionQueue.start(info.Env());
24
- // Unref threadsafe function immediately to avoid delay in program exit
25
- completionQueue.unref(info.Env());
26
- #endif
27
22
  DEBUG_LOG("Created device %p", this);
28
23
  Constructor(info);
29
24
  }
@@ -193,6 +188,9 @@ Napi::Value Device::Open(const Napi::CallbackInfo& info) {
193
188
  ENTER_METHOD(Device, 0);
194
189
  if (!self->device_handle){
195
190
  CHECK_USB(libusb_open(self->device, &self->device_handle));
191
+ #ifndef USE_POLL
192
+ completionQueue.start(info.Env());
193
+ #endif
196
194
  }
197
195
  return env.Undefined();
198
196
  }
@@ -202,6 +200,9 @@ Napi::Value Device::Close(const Napi::CallbackInfo& info) {
202
200
  if (self->canClose()){
203
201
  libusb_close(self->device_handle);
204
202
  self->device_handle = NULL;
203
+ #ifndef USE_POLL
204
+ completionQueue.stop();
205
+ #endif
205
206
  }else{
206
207
  THROW_ERROR("Can't close device with a pending request");
207
208
  }
package/src/node_usb.h CHANGED
@@ -10,6 +10,7 @@
10
10
  #endif
11
11
  #include <libusb.h>
12
12
 
13
+ #define NAPI_VERSION 4
13
14
  #include <napi.h>
14
15
  #include <node_buffer.h>
15
16