usb 2.12.1 → 2.14.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 (228) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +11 -1
  3. package/dist/index.js +6 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/usb/bindings.d.ts +0 -1
  6. package/dist/usb/bindings.js +1 -1
  7. package/dist/usb/bindings.js.map +1 -1
  8. package/dist/usb/capability.d.ts +0 -1
  9. package/dist/usb/capability.js.map +1 -1
  10. package/dist/usb/descriptors.d.ts +0 -1
  11. package/dist/usb/device.d.ts +0 -1
  12. package/dist/usb/device.js.map +1 -1
  13. package/dist/usb/endpoint.d.ts +0 -1
  14. package/dist/usb/endpoint.js +2 -2
  15. package/dist/usb/endpoint.js.map +1 -1
  16. package/dist/usb/index.js.map +1 -1
  17. package/dist/usb/interface.js +2 -2
  18. package/dist/usb/interface.js.map +1 -1
  19. package/dist/webusb/index.d.ts +1 -3
  20. package/dist/webusb/index.js.map +1 -1
  21. package/dist/webusb/webusb-device.d.ts +0 -1
  22. package/dist/webusb/webusb-device.js +10 -10
  23. package/dist/webusb/webusb-device.js.map +1 -1
  24. package/libusb/.codespellrc +3 -0
  25. package/libusb/.private/appveyor_build.sh +5 -1
  26. package/libusb/.private/ci-build.sh +26 -1
  27. package/libusb/.private/ci-container-build.sh +2 -5
  28. package/libusb/.private/wbs.txt +5 -8
  29. package/libusb/AUTHORS +22 -0
  30. package/libusb/ChangeLog +19 -2
  31. package/libusb/HACKING +25 -0
  32. package/libusb/INSTALL_WIN.txt +11 -10
  33. package/libusb/NEWS +2 -2
  34. package/libusb/README +3 -2
  35. package/libusb/README.git +1 -1
  36. package/libusb/Xcode/common.xcconfig +8 -1
  37. package/libusb/Xcode/config.h +0 -6
  38. package/libusb/Xcode/debug.xcconfig +4 -1
  39. package/libusb/Xcode/libusb.xcconfig +1 -1
  40. package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +60 -30
  41. package/libusb/Xcode/libusb_debug.xcconfig +1 -1
  42. package/libusb/Xcode/libusb_release.xcconfig +1 -1
  43. package/libusb/Xcode/release.xcconfig +1 -1
  44. package/libusb/appveyor.yml +33 -9
  45. package/libusb/configure.ac +68 -37
  46. package/libusb/examples/dpfp.c +2 -2
  47. package/libusb/examples/fxload.c +2 -2
  48. package/libusb/examples/hotplugtest.c +28 -13
  49. package/libusb/examples/listdevs.c +1 -1
  50. package/libusb/examples/sam3u_benchmark.c +1 -1
  51. package/libusb/examples/testlibusb.c +1 -1
  52. package/libusb/examples/xusb.c +74 -19
  53. package/libusb/libusb/Makefile.am +11 -1
  54. package/libusb/libusb/core.c +364 -186
  55. package/libusb/libusb/descriptor.c +276 -16
  56. package/libusb/libusb/hotplug.c +5 -4
  57. package/libusb/libusb/io.c +72 -61
  58. package/libusb/libusb/libusb-1.0.def +14 -1
  59. package/libusb/libusb/libusb.h +245 -76
  60. package/libusb/libusb/libusbi.h +35 -13
  61. package/libusb/libusb/os/darwin_usb.c +542 -279
  62. package/libusb/libusb/os/darwin_usb.h +44 -115
  63. package/libusb/libusb/os/emscripten_webusb.cpp +870 -0
  64. package/libusb/libusb/os/events_posix.c +40 -0
  65. package/libusb/libusb/os/events_posix.h +3 -0
  66. package/libusb/libusb/os/linux_usbfs.c +27 -16
  67. package/libusb/libusb/os/netbsd_usb.c +36 -36
  68. package/libusb/libusb/os/openbsd_usb.c +34 -34
  69. package/libusb/libusb/os/sunos_usb.c +25 -15
  70. package/libusb/libusb/os/threads_posix.c +1 -5
  71. package/libusb/libusb/os/windows_common.c +13 -5
  72. package/libusb/libusb/os/windows_common.h +8 -0
  73. package/libusb/libusb/os/windows_winusb.c +366 -174
  74. package/libusb/libusb/os/windows_winusb.h +13 -9
  75. package/libusb/libusb/strerror.c +5 -5
  76. package/libusb/libusb/sync.c +24 -19
  77. package/libusb/libusb/version.h +1 -1
  78. package/libusb/libusb/version_nano.h +1 -1
  79. package/libusb/msvc/Base.props +60 -0
  80. package/libusb/msvc/Configuration.Application.props +7 -0
  81. package/libusb/msvc/Configuration.Base.props +47 -0
  82. package/libusb/msvc/Configuration.DynamicLibrary.props +21 -0
  83. package/libusb/msvc/Configuration.StaticLibrary.props +7 -0
  84. package/libusb/msvc/ProjectConfigurations.Base.props +69 -0
  85. package/libusb/msvc/build_all.ps1 +17 -0
  86. package/libusb/msvc/config.h +2 -2
  87. package/libusb/msvc/dpfp.vcxproj +33 -0
  88. package/libusb/msvc/dpfp_threaded.vcxproj +38 -0
  89. package/libusb/msvc/fxload.vcxproj +46 -0
  90. package/libusb/msvc/getopt.vcxproj +33 -0
  91. package/libusb/msvc/hotplugtest.vcxproj +32 -0
  92. package/libusb/msvc/init_context.vcxproj +35 -0
  93. package/libusb/msvc/libusb.sln +542 -0
  94. package/libusb/msvc/libusb_dll.vcxproj +61 -0
  95. package/libusb/msvc/libusb_static.vcxproj +49 -0
  96. package/libusb/msvc/listdevs.vcxproj +32 -0
  97. package/libusb/msvc/sam3u_benchmark.vcxproj +33 -0
  98. package/libusb/msvc/set_option.vcxproj +35 -0
  99. package/libusb/msvc/stress.vcxproj +35 -0
  100. package/libusb/msvc/stress_mt.vcxproj +33 -0
  101. package/libusb/msvc/testlibusb.vcxproj +32 -0
  102. package/libusb/msvc/xusb.vcxproj +38 -0
  103. package/libusb/tests/Makefile.am +25 -3
  104. package/libusb/tests/init_context.c +153 -0
  105. package/libusb/tests/macos.c +130 -0
  106. package/libusb/tests/set_option.c +253 -0
  107. package/libusb/tests/stress.c +17 -14
  108. package/libusb/tests/stress_mt.c +265 -0
  109. package/libusb/tests/testlib.c +1 -1
  110. package/libusb/tests/umockdev.c +9 -9
  111. package/libusb/tests/webusb-test-shim/index.js +12 -0
  112. package/libusb/tests/webusb-test-shim/package-lock.json +50 -0
  113. package/libusb/tests/webusb-test-shim/package.json +10 -0
  114. package/package.json +8 -8
  115. package/prebuilds/android-arm/node.napi.armv7.node +0 -0
  116. package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
  117. package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
  118. package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
  119. package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
  120. package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
  121. package/prebuilds/linux-ia32/node.napi.node +0 -0
  122. package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  123. package/prebuilds/linux-x64/node.napi.musl.node +0 -0
  124. package/prebuilds/win32-arm64/node.napi.node +0 -0
  125. package/prebuilds/win32-ia32/node.napi.node +0 -0
  126. package/prebuilds/win32-x64/node.napi.node +0 -0
  127. package/src/device.cc +16 -6
  128. package/src/transfer.cc +1 -1
  129. package/libusb/msvc/dpfp_2013.vcxproj +0 -87
  130. package/libusb/msvc/dpfp_2013.vcxproj.filters +0 -26
  131. package/libusb/msvc/dpfp_2015.vcxproj +0 -87
  132. package/libusb/msvc/dpfp_2015.vcxproj.filters +0 -26
  133. package/libusb/msvc/dpfp_2017.vcxproj +0 -106
  134. package/libusb/msvc/dpfp_2017.vcxproj.filters +0 -26
  135. package/libusb/msvc/dpfp_2019.vcxproj +0 -106
  136. package/libusb/msvc/dpfp_2019.vcxproj.filters +0 -26
  137. package/libusb/msvc/dpfp_threaded_2013.vcxproj +0 -87
  138. package/libusb/msvc/dpfp_threaded_2013.vcxproj.filters +0 -26
  139. package/libusb/msvc/dpfp_threaded_2015.vcxproj +0 -87
  140. package/libusb/msvc/dpfp_threaded_2015.vcxproj.filters +0 -26
  141. package/libusb/msvc/dpfp_threaded_2017.vcxproj +0 -106
  142. package/libusb/msvc/dpfp_threaded_2017.vcxproj.filters +0 -26
  143. package/libusb/msvc/dpfp_threaded_2019.vcxproj +0 -106
  144. package/libusb/msvc/dpfp_threaded_2019.vcxproj.filters +0 -26
  145. package/libusb/msvc/fxload_2013.vcxproj +0 -94
  146. package/libusb/msvc/fxload_2013.vcxproj.filters +0 -35
  147. package/libusb/msvc/fxload_2015.vcxproj +0 -94
  148. package/libusb/msvc/fxload_2015.vcxproj.filters +0 -35
  149. package/libusb/msvc/fxload_2017.vcxproj +0 -113
  150. package/libusb/msvc/fxload_2017.vcxproj.filters +0 -35
  151. package/libusb/msvc/fxload_2019.vcxproj +0 -113
  152. package/libusb/msvc/fxload_2019.vcxproj.filters +0 -35
  153. package/libusb/msvc/getopt_2013.vcxproj +0 -72
  154. package/libusb/msvc/getopt_2013.vcxproj.filters +0 -26
  155. package/libusb/msvc/getopt_2015.vcxproj +0 -73
  156. package/libusb/msvc/getopt_2015.vcxproj.filters +0 -26
  157. package/libusb/msvc/getopt_2017.vcxproj +0 -92
  158. package/libusb/msvc/getopt_2017.vcxproj.filters +0 -26
  159. package/libusb/msvc/getopt_2019.vcxproj +0 -92
  160. package/libusb/msvc/getopt_2019.vcxproj.filters +0 -26
  161. package/libusb/msvc/hotplugtest_2013.vcxproj +0 -86
  162. package/libusb/msvc/hotplugtest_2013.vcxproj.filters +0 -23
  163. package/libusb/msvc/hotplugtest_2015.vcxproj +0 -86
  164. package/libusb/msvc/hotplugtest_2015.vcxproj.filters +0 -23
  165. package/libusb/msvc/hotplugtest_2017.vcxproj +0 -105
  166. package/libusb/msvc/hotplugtest_2017.vcxproj.filters +0 -23
  167. package/libusb/msvc/hotplugtest_2019.vcxproj +0 -105
  168. package/libusb/msvc/hotplugtest_2019.vcxproj.filters +0 -23
  169. package/libusb/msvc/libusb_2013.sln +0 -137
  170. package/libusb/msvc/libusb_2015.sln +0 -137
  171. package/libusb/msvc/libusb_2017.sln +0 -240
  172. package/libusb/msvc/libusb_2019.sln +0 -240
  173. package/libusb/msvc/libusb_dll_2013.vcxproj +0 -104
  174. package/libusb/msvc/libusb_dll_2013.vcxproj.filters +0 -94
  175. package/libusb/msvc/libusb_dll_2015.vcxproj +0 -105
  176. package/libusb/msvc/libusb_dll_2015.vcxproj.filters +0 -94
  177. package/libusb/msvc/libusb_dll_2017.vcxproj +0 -124
  178. package/libusb/msvc/libusb_dll_2017.vcxproj.filters +0 -94
  179. package/libusb/msvc/libusb_dll_2019.vcxproj +0 -124
  180. package/libusb/msvc/libusb_dll_2019.vcxproj.filters +0 -94
  181. package/libusb/msvc/libusb_static_2013.vcxproj +0 -94
  182. package/libusb/msvc/libusb_static_2013.vcxproj.filters +0 -80
  183. package/libusb/msvc/libusb_static_2015.vcxproj +0 -95
  184. package/libusb/msvc/libusb_static_2015.vcxproj.filters +0 -80
  185. package/libusb/msvc/libusb_static_2017.vcxproj +0 -114
  186. package/libusb/msvc/libusb_static_2017.vcxproj.filters +0 -80
  187. package/libusb/msvc/libusb_static_2019.vcxproj +0 -114
  188. package/libusb/msvc/libusb_static_2019.vcxproj.filters +0 -80
  189. package/libusb/msvc/listdevs_2013.vcxproj +0 -86
  190. package/libusb/msvc/listdevs_2013.vcxproj.filters +0 -23
  191. package/libusb/msvc/listdevs_2015.vcxproj +0 -86
  192. package/libusb/msvc/listdevs_2015.vcxproj.filters +0 -23
  193. package/libusb/msvc/listdevs_2017.vcxproj +0 -105
  194. package/libusb/msvc/listdevs_2017.vcxproj.filters +0 -23
  195. package/libusb/msvc/listdevs_2019.vcxproj +0 -105
  196. package/libusb/msvc/listdevs_2019.vcxproj.filters +0 -23
  197. package/libusb/msvc/sam3u_benchmark_2013.vcxproj +0 -87
  198. package/libusb/msvc/sam3u_benchmark_2013.vcxproj.filters +0 -26
  199. package/libusb/msvc/sam3u_benchmark_2015.vcxproj +0 -87
  200. package/libusb/msvc/sam3u_benchmark_2015.vcxproj.filters +0 -26
  201. package/libusb/msvc/sam3u_benchmark_2017.vcxproj +0 -106
  202. package/libusb/msvc/sam3u_benchmark_2017.vcxproj.filters +0 -26
  203. package/libusb/msvc/sam3u_benchmark_2019.vcxproj +0 -106
  204. package/libusb/msvc/sam3u_benchmark_2019.vcxproj.filters +0 -26
  205. package/libusb/msvc/stress_2013.vcxproj +0 -89
  206. package/libusb/msvc/stress_2013.vcxproj.filters +0 -32
  207. package/libusb/msvc/stress_2015.vcxproj +0 -89
  208. package/libusb/msvc/stress_2015.vcxproj.filters +0 -32
  209. package/libusb/msvc/stress_2017.vcxproj +0 -108
  210. package/libusb/msvc/stress_2017.vcxproj.filters +0 -32
  211. package/libusb/msvc/stress_2019.vcxproj +0 -108
  212. package/libusb/msvc/stress_2019.vcxproj.filters +0 -32
  213. package/libusb/msvc/testlibusb_2013.vcxproj +0 -86
  214. package/libusb/msvc/testlibusb_2013.vcxproj.filters +0 -23
  215. package/libusb/msvc/testlibusb_2015.vcxproj +0 -86
  216. package/libusb/msvc/testlibusb_2015.vcxproj.filters +0 -23
  217. package/libusb/msvc/testlibusb_2017.vcxproj +0 -105
  218. package/libusb/msvc/testlibusb_2017.vcxproj.filters +0 -23
  219. package/libusb/msvc/testlibusb_2019.vcxproj +0 -105
  220. package/libusb/msvc/testlibusb_2019.vcxproj.filters +0 -23
  221. package/libusb/msvc/xusb_2013.vcxproj +0 -86
  222. package/libusb/msvc/xusb_2013.vcxproj.filters +0 -23
  223. package/libusb/msvc/xusb_2015.vcxproj +0 -86
  224. package/libusb/msvc/xusb_2015.vcxproj.filters +0 -23
  225. package/libusb/msvc/xusb_2017.vcxproj +0 -105
  226. package/libusb/msvc/xusb_2017.vcxproj.filters +0 -23
  227. package/libusb/msvc/xusb_2019.vcxproj +0 -105
  228. package/libusb/msvc/xusb_2019.vcxproj.filters +0 -23
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "webusb-test-runner",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "webusb-test-runner",
9
+ "version": "1.0.0",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "usb": "^2.11.0"
13
+ }
14
+ },
15
+ "node_modules/@types/w3c-web-usb": {
16
+ "version": "1.0.10",
17
+ "resolved": "https://registry.npmjs.org/@types/w3c-web-usb/-/w3c-web-usb-1.0.10.tgz",
18
+ "integrity": "sha512-CHgUI5kTc/QLMP8hODUHhge0D4vx+9UiAwIGiT0sTy/B2XpdX1U5rJt6JSISgr6ikRT7vxV9EVAFeYZqUnl1gQ=="
19
+ },
20
+ "node_modules/node-addon-api": {
21
+ "version": "7.0.0",
22
+ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.0.0.tgz",
23
+ "integrity": "sha512-vgbBJTS4m5/KkE16t5Ly0WW9hz46swAstv0hYYwMtbG7AznRhNyfLRe8HZAiWIpcHzoO7HxhLuBQj9rJ/Ho0ZA=="
24
+ },
25
+ "node_modules/node-gyp-build": {
26
+ "version": "4.7.0",
27
+ "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.7.0.tgz",
28
+ "integrity": "sha512-PbZERfeFdrHQOOXiAKOY0VPbykZy90ndPKk0d+CFDegTKmWp1VgOTz2xACVbr1BjCWxrQp68CXtvNsveFhqDJg==",
29
+ "bin": {
30
+ "node-gyp-build": "bin.js",
31
+ "node-gyp-build-optional": "optional.js",
32
+ "node-gyp-build-test": "build-test.js"
33
+ }
34
+ },
35
+ "node_modules/usb": {
36
+ "version": "2.11.0",
37
+ "resolved": "https://registry.npmjs.org/usb/-/usb-2.11.0.tgz",
38
+ "integrity": "sha512-u5+NZ6DtoW8TIBtuSArQGAZZ/K15i3lYvZBAYmcgI+RcDS9G50/KPrUd3CrU8M92ahyCvg5e0gc8BDvr5Hwejg==",
39
+ "hasInstallScript": true,
40
+ "dependencies": {
41
+ "@types/w3c-web-usb": "^1.0.6",
42
+ "node-addon-api": "^7.0.0",
43
+ "node-gyp-build": "^4.5.0"
44
+ },
45
+ "engines": {
46
+ "node": ">=12.22.0 <13.0 || >=14.17.0"
47
+ }
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "webusb-test-runner",
3
+ "private": true,
4
+ "license": "LGPL-2.1",
5
+ "main": "index.js",
6
+ "author": "Ingvar Stepanyan <me@rreverser.com>",
7
+ "dependencies": {
8
+ "usb": "^2.11.0"
9
+ }
10
+ }
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.12.1",
5
+ "version": "2.14.0",
6
6
  "main": "dist/index.js",
7
7
  "engines": {
8
8
  "node": ">=12.22.0 <13.0 || >=14.17.0"
@@ -46,14 +46,14 @@
46
46
  "full-test": "mocha --timeout 10000 --require coffeescript/register test/*.coffee",
47
47
  "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",
48
48
  "docs": "typedoc",
49
- "prebuild": "prebuildify --napi --strip",
50
- "prebuild-cross": "prebuildify-cross --napi --strip",
49
+ "prebuild": "prebuildify --napi --strip --name node.napi",
50
+ "prebuild-cross": "prebuildify-cross --napi --strip --name node.napi",
51
51
  "prepublishOnly": "prebuildify-ci download",
52
52
  "prebuild-download": "prebuildify-ci download"
53
53
  },
54
54
  "dependencies": {
55
55
  "@types/w3c-web-usb": "^1.0.6",
56
- "node-addon-api": "^7.0.0",
56
+ "node-addon-api": "^8.0.0",
57
57
  "node-gyp-build": "^4.5.0"
58
58
  },
59
59
  "devDependencies": {
@@ -64,11 +64,11 @@
64
64
  "eslint": "^8.29.0",
65
65
  "mocha": "^10.1.0",
66
66
  "node-gyp": "^10.0.1",
67
- "prebuildify": "^5.0.1",
67
+ "prebuildify": "^6.0.1",
68
68
  "prebuildify-ci": "^1.0.5",
69
- "prebuildify-cross": "^5.0.0",
70
- "typedoc": "^0.22.10",
71
- "typescript": "~4.2.4"
69
+ "prebuildify-cross": "thegecko/prebuildify-cross#fix-docker",
70
+ "typedoc": "^0.26.7",
71
+ "typescript": "^5.4.5"
72
72
  },
73
73
  "binary": {
74
74
  "napi_versions": [
Binary file
Binary file
Binary file
package/src/device.cc CHANGED
@@ -104,8 +104,11 @@ Napi::Object Device::cdesc2V8(Napi::Env env, libusb_config_descriptor * cdesc) {
104
104
  STRUCT_TO_V8(v8cdesc, *cdesc, bmAttributes)
105
105
  // Libusb 1.0 typo'd bMaxPower as MaxPower
106
106
  v8cdesc.DefineProperty(Napi::PropertyDescriptor::Value("bMaxPower", Napi::Number::New(env, (uint32_t)cdesc->MaxPower), CONST_PROP));
107
+ const auto config_extras = (cdesc->extra && cdesc->extra_length)
108
+ ? Napi::Buffer<const char>::Copy(env, (const char*)cdesc->extra, cdesc->extra_length)
109
+ : Napi::Buffer<const char>::New(env, 0);
107
110
 
108
- v8cdesc.DefineProperty(Napi::PropertyDescriptor::Value("extra", Napi::Buffer<const char>::Copy(env, (const char*)cdesc->extra, cdesc->extra_length), CONST_PROP));
111
+ v8cdesc.DefineProperty(Napi::PropertyDescriptor::Value("extra", config_extras, CONST_PROP));
109
112
 
110
113
  Napi::Array v8interfaces = Napi::Array::New(env, cdesc->bNumInterfaces);
111
114
  v8cdesc.DefineProperty(Napi::PropertyDescriptor::Value("interfaces", v8interfaces, CONST_PROP));
@@ -133,7 +136,10 @@ Napi::Object Device::cdesc2V8(Napi::Env env, libusb_config_descriptor * cdesc) {
133
136
  STRUCT_TO_V8(v8idesc, idesc, bInterfaceProtocol)
134
137
  STRUCT_TO_V8(v8idesc, idesc, iInterface)
135
138
 
136
- v8idesc.DefineProperty(Napi::PropertyDescriptor::Value("extra", Napi::Buffer<const char>::Copy(env, (const char*)idesc.extra, idesc.extra_length), CONST_PROP));
139
+ auto interface_extras = (idesc.extra && idesc.extra_length)
140
+ ? Napi::Buffer<const char>::Copy(env, (const char*)idesc.extra, idesc.extra_length)
141
+ : Napi::Buffer<const char>::New(env, 0);
142
+ v8idesc.DefineProperty(Napi::PropertyDescriptor::Value("extra", interface_extras, CONST_PROP));
137
143
 
138
144
  Napi::Array v8endpoints = Napi::Array::New(env, idesc.bNumEndpoints);
139
145
  v8idesc.DefineProperty(Napi::PropertyDescriptor::Value("endpoints", v8endpoints, CONST_PROP));
@@ -151,8 +157,10 @@ Napi::Object Device::cdesc2V8(Napi::Env env, libusb_config_descriptor * cdesc) {
151
157
  STRUCT_TO_V8(v8edesc, edesc, bInterval)
152
158
  STRUCT_TO_V8(v8edesc, edesc, bRefresh)
153
159
  STRUCT_TO_V8(v8edesc, edesc, bSynchAddress)
154
-
155
- v8edesc.DefineProperty(Napi::PropertyDescriptor::Value("extra", Napi::Buffer<const char>::Copy(env, (const char*)edesc.extra, edesc.extra_length), CONST_PROP));
160
+ auto endpoint_extras = (edesc.extra && edesc.extra_length)
161
+ ? Napi::Buffer<const char>::Copy(env, (const char*)edesc.extra, edesc.extra_length)
162
+ : Napi::Buffer<const char>::New(env, 0);
163
+ v8edesc.DefineProperty(Napi::PropertyDescriptor::Value("extra", endpoint_extras, CONST_PROP));
156
164
  }
157
165
  }
158
166
  }
@@ -175,7 +183,9 @@ Napi::Value Device::GetAllConfigDescriptors(const Napi::CallbackInfo& info) {
175
183
  libusb_get_device_descriptor(self->device, &dd);
176
184
  Napi::Array v8cdescriptors = Napi::Array::New(env, dd.bNumConfigurations);
177
185
  for(uint8_t i = 0; i < dd.bNumConfigurations; i++){
178
- libusb_get_config_descriptor(device, i, &cdesc);
186
+ // libusb_get_config_descriptor is nonblocking but allocates and those allocates
187
+ // may fail
188
+ CHECK_USB(libusb_get_config_descriptor(device, i, &cdesc));
179
189
  v8cdescriptors.Set(i, Device::cdesc2V8(env, cdesc));
180
190
  libusb_free_config_descriptor(cdesc);
181
191
  }
@@ -236,7 +246,7 @@ struct Req: Napi::AsyncWorker {
236
246
  Callback().Call(device->Value(), { error });
237
247
  }
238
248
  catch (const Napi::Error& e) {
239
- Napi::Error::Fatal("", e.what());
249
+ e.ThrowAsJavaScriptException();
240
250
  }
241
251
  }
242
252
  };
package/src/transfer.cc CHANGED
@@ -110,7 +110,7 @@ void handleCompletion(Transfer* self){
110
110
  Napi::Number::New(env, (uint32_t)self->transfer->actual_length) });
111
111
  }
112
112
  catch (const Napi::Error& e) {
113
- Napi::Error::Fatal("", e.what());
113
+ e.ThrowAsJavaScriptException();
114
114
  }
115
115
  }
116
116
 
@@ -1,87 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <ItemGroup Label="ProjectConfigurations">
4
- <ProjectConfiguration Include="Debug|Win32">
5
- <Configuration>Debug</Configuration>
6
- <Platform>Win32</Platform>
7
- </ProjectConfiguration>
8
- <ProjectConfiguration Include="Debug|x64">
9
- <Configuration>Debug</Configuration>
10
- <Platform>x64</Platform>
11
- </ProjectConfiguration>
12
- <ProjectConfiguration Include="Release|Win32">
13
- <Configuration>Release</Configuration>
14
- <Platform>Win32</Platform>
15
- </ProjectConfiguration>
16
- <ProjectConfiguration Include="Release|x64">
17
- <Configuration>Release</Configuration>
18
- <Platform>x64</Platform>
19
- </ProjectConfiguration>
20
- </ItemGroup>
21
- <PropertyGroup Label="Globals">
22
- <ProjectName>dpfp</ProjectName>
23
- <ProjectGuid>{8c7814a1-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
24
- <RootNamespace>examples</RootNamespace>
25
- <Keyword>Win32Proj</Keyword>
26
- </PropertyGroup>
27
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28
- <PropertyGroup Label="Configuration">
29
- <ConfigurationType>Application</ConfigurationType>
30
- <CharacterSet>Unicode</CharacterSet>
31
- <PlatformToolset>v120</PlatformToolset>
32
- <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
33
- </PropertyGroup>
34
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
35
- <ImportGroup Label="ExtensionSettings">
36
- </ImportGroup>
37
- <ImportGroup Label="PropertySheets">
38
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
39
- </ImportGroup>
40
- <PropertyGroup Label="UserMacros" />
41
- <PropertyGroup>
42
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
43
- <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
44
- <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
45
- </PropertyGroup>
46
- <ItemDefinitionGroup>
47
- <ClCompile>
48
- <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
49
- <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
50
- <WarningLevel>Level3</WarningLevel>
51
- </ClCompile>
52
- <ClCompile Condition="'$(Configuration)'=='Debug'">
53
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
54
- <MinimalRebuild>true</MinimalRebuild>
55
- <Optimization>Disabled</Optimization>
56
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
57
- </ClCompile>
58
- <ClCompile Condition="'$(Configuration)'=='Release'">
59
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
60
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
61
- </ClCompile>
62
- <Link>
63
- <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
64
- <SubSystem>Console</SubSystem>
65
- <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
66
- </Link>
67
- <Link Condition="'$(Configuration)'=='Debug'">
68
- <GenerateDebugInformation>true</GenerateDebugInformation>
69
- </Link>
70
- </ItemDefinitionGroup>
71
- <ItemGroup>
72
- <ClCompile Include="..\examples\dpfp.c" />
73
- </ItemGroup>
74
- <ItemGroup>
75
- <ClInclude Include=".\config.h" />
76
- <ClInclude Include="..\libusb\libusb.h" />
77
- </ItemGroup>
78
- <ItemGroup>
79
- <ProjectReference Include=".\libusb_static_2013.vcxproj">
80
- <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
81
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
82
- </ProjectReference>
83
- </ItemGroup>
84
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
85
- <ImportGroup Label="ExtensionTargets">
86
- </ImportGroup>
87
- </Project>
@@ -1,26 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <ItemGroup>
4
- <Filter Include="Source Files">
5
- <UniqueIdentifier>{4fc737f1-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
6
- <Extensions>c</Extensions>
7
- </Filter>
8
- <Filter Include="Header Files">
9
- <UniqueIdentifier>{93995380-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
10
- <Extensions>h</Extensions>
11
- </Filter>
12
- </ItemGroup>
13
- <ItemGroup>
14
- <ClInclude Include=".\config.h">
15
- <Filter>Header Files</Filter>
16
- </ClInclude>
17
- <ClInclude Include="..\libusb\libusb.h">
18
- <Filter>Header Files</Filter>
19
- </ClInclude>
20
- </ItemGroup>
21
- <ItemGroup>
22
- <ClCompile Include="..\examples\dpfp.c">
23
- <Filter>Source Files</Filter>
24
- </ClCompile>
25
- </ItemGroup>
26
- </Project>
@@ -1,87 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <ItemGroup Label="ProjectConfigurations">
4
- <ProjectConfiguration Include="Debug|Win32">
5
- <Configuration>Debug</Configuration>
6
- <Platform>Win32</Platform>
7
- </ProjectConfiguration>
8
- <ProjectConfiguration Include="Debug|x64">
9
- <Configuration>Debug</Configuration>
10
- <Platform>x64</Platform>
11
- </ProjectConfiguration>
12
- <ProjectConfiguration Include="Release|Win32">
13
- <Configuration>Release</Configuration>
14
- <Platform>Win32</Platform>
15
- </ProjectConfiguration>
16
- <ProjectConfiguration Include="Release|x64">
17
- <Configuration>Release</Configuration>
18
- <Platform>x64</Platform>
19
- </ProjectConfiguration>
20
- </ItemGroup>
21
- <PropertyGroup Label="Globals">
22
- <ProjectName>dpfp</ProjectName>
23
- <ProjectGuid>{8c7814a1-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
24
- <RootNamespace>examples</RootNamespace>
25
- <Keyword>Win32Proj</Keyword>
26
- </PropertyGroup>
27
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28
- <PropertyGroup Label="Configuration">
29
- <ConfigurationType>Application</ConfigurationType>
30
- <CharacterSet>Unicode</CharacterSet>
31
- <PlatformToolset>v140</PlatformToolset>
32
- <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
33
- </PropertyGroup>
34
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
35
- <ImportGroup Label="ExtensionSettings">
36
- </ImportGroup>
37
- <ImportGroup Label="PropertySheets">
38
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
39
- </ImportGroup>
40
- <PropertyGroup Label="UserMacros" />
41
- <PropertyGroup>
42
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
43
- <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
44
- <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
45
- </PropertyGroup>
46
- <ItemDefinitionGroup>
47
- <ClCompile>
48
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
49
- <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
50
- <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
51
- <WarningLevel>Level3</WarningLevel>
52
- </ClCompile>
53
- <ClCompile Condition="'$(Configuration)'=='Debug'">
54
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
55
- <Optimization>Disabled</Optimization>
56
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
57
- </ClCompile>
58
- <ClCompile Condition="'$(Configuration)'=='Release'">
59
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
60
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
61
- </ClCompile>
62
- <Link>
63
- <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
64
- <SubSystem>Console</SubSystem>
65
- <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
66
- </Link>
67
- <Link Condition="'$(Configuration)'=='Debug'">
68
- <GenerateDebugInformation>true</GenerateDebugInformation>
69
- </Link>
70
- </ItemDefinitionGroup>
71
- <ItemGroup>
72
- <ClCompile Include="..\examples\dpfp.c" />
73
- </ItemGroup>
74
- <ItemGroup>
75
- <ClInclude Include=".\config.h" />
76
- <ClInclude Include="..\libusb\libusb.h" />
77
- </ItemGroup>
78
- <ItemGroup>
79
- <ProjectReference Include=".\libusb_static_2015.vcxproj">
80
- <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
81
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
82
- </ProjectReference>
83
- </ItemGroup>
84
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
85
- <ImportGroup Label="ExtensionTargets">
86
- </ImportGroup>
87
- </Project>
@@ -1,26 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <ItemGroup>
4
- <Filter Include="Source Files">
5
- <UniqueIdentifier>{4fc737f1-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
6
- <Extensions>c</Extensions>
7
- </Filter>
8
- <Filter Include="Header Files">
9
- <UniqueIdentifier>{93995380-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
10
- <Extensions>h</Extensions>
11
- </Filter>
12
- </ItemGroup>
13
- <ItemGroup>
14
- <ClInclude Include=".\config.h">
15
- <Filter>Header Files</Filter>
16
- </ClInclude>
17
- <ClInclude Include="..\libusb\libusb.h">
18
- <Filter>Header Files</Filter>
19
- </ClInclude>
20
- </ItemGroup>
21
- <ItemGroup>
22
- <ClCompile Include="..\examples\dpfp.c">
23
- <Filter>Source Files</Filter>
24
- </ClCompile>
25
- </ItemGroup>
26
- </Project>
@@ -1,106 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <ItemGroup Label="ProjectConfigurations">
4
- <ProjectConfiguration Include="Debug|ARM">
5
- <Configuration>Debug</Configuration>
6
- <Platform>ARM</Platform>
7
- </ProjectConfiguration>
8
- <ProjectConfiguration Include="Debug|ARM64">
9
- <Configuration>Debug</Configuration>
10
- <Platform>ARM64</Platform>
11
- </ProjectConfiguration>
12
- <ProjectConfiguration Include="Debug|Win32">
13
- <Configuration>Debug</Configuration>
14
- <Platform>Win32</Platform>
15
- </ProjectConfiguration>
16
- <ProjectConfiguration Include="Debug|x64">
17
- <Configuration>Debug</Configuration>
18
- <Platform>x64</Platform>
19
- </ProjectConfiguration>
20
- <ProjectConfiguration Include="Release|ARM">
21
- <Configuration>Release</Configuration>
22
- <Platform>ARM</Platform>
23
- </ProjectConfiguration>
24
- <ProjectConfiguration Include="Release|ARM64">
25
- <Configuration>Release</Configuration>
26
- <Platform>ARM64</Platform>
27
- </ProjectConfiguration>
28
- <ProjectConfiguration Include="Release|Win32">
29
- <Configuration>Release</Configuration>
30
- <Platform>Win32</Platform>
31
- </ProjectConfiguration>
32
- <ProjectConfiguration Include="Release|x64">
33
- <Configuration>Release</Configuration>
34
- <Platform>x64</Platform>
35
- </ProjectConfiguration>
36
- </ItemGroup>
37
- <PropertyGroup Label="Globals">
38
- <ProjectName>dpfp</ProjectName>
39
- <ProjectGuid>{8c7814a1-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
40
- <RootNamespace>examples</RootNamespace>
41
- <Keyword>Win32Proj</Keyword>
42
- <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
43
- <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
44
- <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
45
- </PropertyGroup>
46
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
47
- <PropertyGroup Label="Configuration">
48
- <ConfigurationType>Application</ConfigurationType>
49
- <CharacterSet>Unicode</CharacterSet>
50
- <PlatformToolset>v141</PlatformToolset>
51
- <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
52
- </PropertyGroup>
53
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
54
- <ImportGroup Label="ExtensionSettings">
55
- </ImportGroup>
56
- <ImportGroup Label="PropertySheets">
57
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
58
- </ImportGroup>
59
- <PropertyGroup Label="UserMacros" />
60
- <PropertyGroup>
61
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
62
- <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
63
- <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
64
- </PropertyGroup>
65
- <ItemDefinitionGroup>
66
- <ClCompile>
67
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
68
- <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
69
- <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
70
- <WarningLevel>Level3</WarningLevel>
71
- </ClCompile>
72
- <ClCompile Condition="'$(Configuration)'=='Debug'">
73
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
74
- <Optimization>Disabled</Optimization>
75
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
76
- </ClCompile>
77
- <ClCompile Condition="'$(Configuration)'=='Release'">
78
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
79
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
80
- </ClCompile>
81
- <Link>
82
- <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
83
- <SubSystem>Console</SubSystem>
84
- <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
85
- </Link>
86
- <Link Condition="'$(Configuration)'=='Debug'">
87
- <GenerateDebugInformation>true</GenerateDebugInformation>
88
- </Link>
89
- </ItemDefinitionGroup>
90
- <ItemGroup>
91
- <ClCompile Include="..\examples\dpfp.c" />
92
- </ItemGroup>
93
- <ItemGroup>
94
- <ClInclude Include=".\config.h" />
95
- <ClInclude Include="..\libusb\libusb.h" />
96
- </ItemGroup>
97
- <ItemGroup>
98
- <ProjectReference Include=".\libusb_static_2017.vcxproj">
99
- <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
100
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
101
- </ProjectReference>
102
- </ItemGroup>
103
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
104
- <ImportGroup Label="ExtensionTargets">
105
- </ImportGroup>
106
- </Project>
@@ -1,26 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <ItemGroup>
4
- <Filter Include="Source Files">
5
- <UniqueIdentifier>{4fc737f1-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
6
- <Extensions>c</Extensions>
7
- </Filter>
8
- <Filter Include="Header Files">
9
- <UniqueIdentifier>{93995380-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
10
- <Extensions>h</Extensions>
11
- </Filter>
12
- </ItemGroup>
13
- <ItemGroup>
14
- <ClInclude Include=".\config.h">
15
- <Filter>Header Files</Filter>
16
- </ClInclude>
17
- <ClInclude Include="..\libusb\libusb.h">
18
- <Filter>Header Files</Filter>
19
- </ClInclude>
20
- </ItemGroup>
21
- <ItemGroup>
22
- <ClCompile Include="..\examples\dpfp.c">
23
- <Filter>Source Files</Filter>
24
- </ClCompile>
25
- </ItemGroup>
26
- </Project>