usb 2.0.0-alpha.2 → 2.1.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.
- package/.gitmodules +1 -1
- package/CHANGELOG.md +100 -0
- package/README.md +573 -0
- package/binding.gyp +12 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/dist/usb/bindings.d.ts +13 -0
- package/dist/usb/bindings.js +2 -1
- package/dist/usb/bindings.js.map +1 -1
- package/dist/usb/index.js +86 -2
- package/dist/usb/index.js.map +1 -1
- package/dist/usb/interface.js.map +1 -1
- package/dist/webusb/index.d.ts +32 -19
- package/dist/webusb/index.js +163 -67
- package/dist/webusb/index.js.map +1 -1
- package/dist/webusb/webusb-device.d.ts +1 -1
- package/dist/webusb/webusb-device.js +27 -15
- package/dist/webusb/webusb-device.js.map +1 -1
- package/libusb/.private/pre-commit.sh +7 -1
- package/libusb/.travis.yml +49 -0
- package/libusb/AUTHORS +44 -3
- package/libusb/Brewfile +4 -0
- package/libusb/ChangeLog +74 -2
- package/libusb/README.md +32 -0
- package/libusb/TODO +1 -1
- package/libusb/Xcode/common.xcconfig +12 -0
- package/libusb/Xcode/config.h +25 -0
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +959 -1
- package/libusb/android/README +4 -2
- package/libusb/android/config.h +75 -0
- package/libusb/appveyor.yml +41 -0
- package/libusb/appveyor_cygwin.bat +11 -0
- package/libusb/appveyor_minGW.bat +19 -0
- package/libusb/autogen.sh +1 -1
- package/libusb/bootstrap.sh +3 -16
- package/libusb/configure.ac +108 -80
- package/libusb/doc/doxygen.cfg.in +1785 -739
- package/libusb/examples/Makefile.am +1 -1
- package/libusb/examples/dpfp.c +3 -1
- package/libusb/examples/dpfp_threaded.c +23 -10
- package/libusb/examples/ezusb.c +3 -3
- package/libusb/examples/ezusb.h +2 -2
- package/libusb/examples/fxload.c +31 -9
- package/libusb/examples/hotplugtest.c +35 -7
- package/libusb/examples/listdevs.c +3 -1
- package/libusb/examples/sam3u_benchmark.c +3 -3
- package/libusb/examples/testlibusb.c +277 -0
- package/libusb/examples/xusb.c +40 -34
- package/libusb/libusb/Makefile.am +49 -23
- package/libusb/libusb/core.c +855 -457
- package/libusb/libusb/descriptor.c +72 -78
- package/libusb/libusb/hotplug.c +122 -76
- package/libusb/libusb/hotplug.h +42 -25
- package/libusb/libusb/io.c +625 -390
- package/libusb/libusb/libusb-1.0.def +12 -0
- package/libusb/libusb/libusb.h +218 -150
- package/libusb/libusb/libusbi.h +346 -176
- package/libusb/libusb/os/darwin_usb.c +604 -319
- package/libusb/libusb/os/darwin_usb.h +61 -20
- package/libusb/libusb/os/haiku_pollfs.cpp +367 -0
- package/libusb/libusb/os/haiku_usb.h +113 -0
- package/libusb/libusb/os/haiku_usb_backend.cpp +533 -0
- package/libusb/libusb/os/haiku_usb_raw.cpp +267 -0
- package/libusb/libusb/os/haiku_usb_raw.h +188 -0
- package/libusb/libusb/os/linux_netlink.c +186 -146
- package/libusb/libusb/os/linux_udev.c +36 -14
- package/libusb/libusb/os/linux_usbfs.c +426 -225
- package/libusb/libusb/os/linux_usbfs.h +5 -3
- package/libusb/libusb/os/netbsd_usb.c +21 -77
- package/libusb/libusb/os/openbsd_usb.c +32 -115
- package/libusb/libusb/os/poll_posix.c +38 -5
- package/libusb/libusb/os/poll_posix.h +3 -0
- package/libusb/libusb/os/poll_windows.c +277 -626
- package/libusb/libusb/os/poll_windows.h +11 -44
- package/libusb/libusb/os/sunos_usb.c +1695 -0
- package/libusb/libusb/os/sunos_usb.h +80 -0
- package/libusb/libusb/os/threads_posix.c +24 -26
- package/libusb/libusb/os/threads_posix.h +73 -21
- package/libusb/libusb/os/threads_windows.c +71 -157
- package/libusb/libusb/os/threads_windows.h +68 -44
- package/libusb/libusb/os/wince_usb.c +276 -420
- package/libusb/libusb/os/wince_usb.h +23 -28
- package/libusb/libusb/os/windows_common.h +78 -58
- package/libusb/libusb/os/windows_nt_common.c +1010 -0
- package/libusb/libusb/os/windows_nt_common.h +110 -0
- package/libusb/libusb/os/windows_nt_shared_types.h +147 -0
- package/libusb/libusb/os/windows_usbdk.c +830 -0
- package/libusb/libusb/os/windows_usbdk.h +103 -0
- package/libusb/libusb/os/windows_winusb.c +4391 -0
- package/libusb/libusb/os/windows_winusb.h +783 -0
- package/libusb/libusb/strerror.c +41 -7
- package/libusb/libusb/sync.c +41 -13
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/libusb-1.0.pc.in +1 -1
- package/libusb/msvc/appveyor.bat +27 -0
- package/libusb/msvc/config.h +5 -4
- package/libusb/msvc/ddk_build.cmd +87 -43
- package/libusb/msvc/fxload_2010.vcxproj +24 -104
- package/libusb/msvc/fxload_2012.vcxproj +24 -107
- package/libusb/msvc/fxload_2013.vcxproj +24 -107
- package/libusb/msvc/fxload_2015.vcxproj +91 -0
- package/libusb/msvc/fxload_2017.vcxproj +114 -0
- package/libusb/msvc/fxload_sources +1 -1
- package/libusb/msvc/getopt_2010.vcxproj +16 -75
- package/libusb/msvc/getopt_2012.vcxproj +16 -79
- package/libusb/msvc/getopt_2013.vcxproj +16 -79
- package/libusb/msvc/getopt_2015.vcxproj +73 -0
- package/libusb/msvc/getopt_2017.vcxproj +98 -0
- package/libusb/msvc/getopt_sources +6 -2
- package/libusb/msvc/hotplugtest_2010.vcxproj +18 -99
- package/libusb/msvc/hotplugtest_2012.vcxproj +18 -102
- package/libusb/msvc/hotplugtest_2013.vcxproj +18 -102
- package/libusb/msvc/hotplugtest_2015.vcxproj +83 -0
- package/libusb/msvc/hotplugtest_2017.vcxproj +106 -0
- package/libusb/msvc/hotplugtest_sources +1 -1
- package/libusb/msvc/libusb_2005.sln +20 -20
- package/libusb/msvc/libusb_2010.sln +57 -46
- package/libusb/msvc/libusb_2012.sln +57 -46
- package/libusb/msvc/libusb_2013.sln +57 -50
- package/libusb/msvc/libusb_2015.sln +59 -52
- package/libusb/msvc/libusb_2017.sln +186 -0
- package/libusb/msvc/libusb_dll.dsp +2 -2
- package/libusb/msvc/libusb_dll_2005.vcproj +30 -2
- package/libusb/msvc/libusb_dll_2010.vcxproj +26 -90
- package/libusb/msvc/libusb_dll_2012.vcxproj +28 -96
- package/libusb/msvc/libusb_dll_2013.vcxproj +28 -96
- package/libusb/msvc/libusb_dll_2015.vcxproj +107 -0
- package/libusb/msvc/libusb_dll_2017.vcxproj +134 -0
- package/libusb/msvc/libusb_dll_wince.vcproj +9 -1
- package/libusb/msvc/libusb_sources +10 -5
- package/libusb/msvc/libusb_static.dsp +2 -2
- package/libusb/msvc/libusb_static_2005.vcproj +32 -4
- package/libusb/msvc/libusb_static_2010.vcxproj +24 -83
- package/libusb/msvc/libusb_static_2012.vcxproj +25 -87
- package/libusb/msvc/libusb_static_2013.vcxproj +25 -87
- package/libusb/msvc/libusb_static_2015.vcxproj +98 -0
- package/libusb/msvc/libusb_static_2017.vcxproj +117 -0
- package/libusb/msvc/libusb_static_wince.vcproj +20 -26
- package/libusb/msvc/libusb_wince.sln +88 -88
- package/libusb/msvc/listdevs_2010.vcxproj +16 -99
- package/libusb/msvc/listdevs_2012.vcxproj +16 -102
- package/libusb/msvc/listdevs_2013.vcxproj +16 -102
- package/libusb/msvc/listdevs_2015.vcxproj +83 -0
- package/libusb/msvc/listdevs_2017.vcxproj +106 -0
- package/libusb/msvc/listdevs_sources +2 -1
- package/libusb/msvc/stress_2010.vcxproj +20 -101
- package/libusb/msvc/stress_2012.vcxproj +20 -104
- package/libusb/msvc/stress_2013.vcxproj +20 -104
- package/libusb/msvc/stress_2015.vcxproj +87 -0
- package/libusb/msvc/stress_2017.vcxproj +110 -0
- package/libusb/msvc/stress_sources +21 -0
- package/libusb/msvc/testlibusb_2010.vcxproj +82 -0
- package/libusb/msvc/testlibusb_2012.vcxproj +83 -0
- package/libusb/msvc/testlibusb_2013.vcxproj +83 -0
- package/libusb/msvc/testlibusb_2015.vcxproj +83 -0
- package/libusb/msvc/testlibusb_2017.vcxproj +106 -0
- package/libusb/msvc/testlibusb_sources +20 -0
- package/libusb/msvc/xusb_2010.vcxproj +17 -98
- package/libusb/msvc/xusb_2012.vcxproj +17 -101
- package/libusb/msvc/xusb_2013.vcxproj +17 -101
- package/libusb/msvc/xusb_2015.vcxproj +83 -0
- package/libusb/msvc/xusb_2017.vcxproj +106 -0
- package/libusb/msvc/xusb_sources +1 -1
- package/libusb/tests/stress.c +2 -2
- package/libusb/tests/testlib.c +0 -4
- package/libusb/travis-autogen.sh +39 -0
- package/libusb.gypi +21 -2
- package/package.json +18 -13
- package/prebuilds/android-arm/node.napi.node +0 -0
- package/prebuilds/android-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm/node.napi.node +0 -0
- package/prebuilds/linux-arm64/node.napi.node +0 -0
- package/prebuilds/linux-ia32/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/device.cc +7 -7
- package/src/node_usb.cc +43 -1
- package/src/node_usb.h +1 -0
- package/src/uv_async_queue.h +33 -25
- package/test/usb.coffee +6 -0
- package/tsc/index.ts +13 -7
- package/tsc/usb/bindings.ts +19 -1
- package/tsc/usb/index.ts +67 -19
- package/tsc/usb/interface.ts +2 -2
- package/tsc/webusb/index.ts +197 -74
- package/tsc/webusb/webusb-device.ts +30 -17
- package/.github/workflows/prebuild.yml +0 -48
- package/Readme.md +0 -339
- package/dist/webusb/typed-event-target.d.ts +0 -11
- package/dist/webusb/typed-event-target.js +0 -21
- package/dist/webusb/typed-event-target.js.map +0 -1
- package/docs/assets/css/main.css +0 -2660
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
- package/docs/classes/usb_bindings.device.html +0 -1338
- package/docs/classes/usb_bindings.libusbexception.html +0 -234
- package/docs/classes/usb_bindings.transfer.html +0 -344
- package/docs/classes/usb_capability.capability.html +0 -297
- package/docs/classes/usb_device.extendeddevice.html +0 -766
- package/docs/classes/usb_endpoint.endpoint.html +0 -472
- package/docs/classes/usb_endpoint.inendpoint.html +0 -766
- package/docs/classes/usb_endpoint.outendpoint.html +0 -582
- package/docs/classes/usb_interface.interface.html +0 -648
- package/docs/classes/webusb.webusb-1.html +0 -615
- package/docs/classes/webusb_mutex.mutex.html +0 -270
- package/docs/classes/webusb_typed_event_target.typedeventtarget.html +0 -443
- package/docs/classes/webusb_webusb_device.webusbdevice.html +0 -904
- package/docs/index.html +0 -500
- package/docs/interfaces/usb.deviceevents.html +0 -242
- package/docs/interfaces/usb_descriptors.bosdescriptor.html +0 -293
- package/docs/interfaces/usb_descriptors.capabilitydescriptor.html +0 -274
- package/docs/interfaces/usb_descriptors.configdescriptor.html +0 -388
- package/docs/interfaces/usb_descriptors.devicedescriptor.html +0 -464
- package/docs/interfaces/usb_descriptors.endpointdescriptor.html +0 -370
- package/docs/interfaces/usb_descriptors.interfacedescriptor.html +0 -407
- package/docs/interfaces/webusb.usboptions.html +0 -226
- package/docs/modules/index.html +0 -304
- package/docs/modules/usb.html +0 -173
- package/docs/modules/usb_bindings.html +0 -2248
- package/docs/modules/usb_capability.html +0 -156
- package/docs/modules/usb_descriptors.html +0 -176
- package/docs/modules/usb_device.html +0 -156
- package/docs/modules/usb_endpoint.html +0 -164
- package/docs/modules/usb_interface.html +0 -156
- package/docs/modules/webusb.html +0 -165
- package/docs/modules/webusb_mutex.html +0 -156
- package/docs/modules/webusb_typed_event_target.html +0 -156
- package/docs/modules/webusb_webusb_device.html +0 -156
- package/docs/modules.html +0 -156
- package/libusb/INSTALL +0 -234
- package/libusb/README +0 -28
- package/libusb/libusb/os/windows_usb.c +0 -5347
- package/libusb/libusb/os/windows_usb.h +0 -971
- package/libusb/msvc/fxload_2010.vcxproj.filters +0 -25
- package/libusb/msvc/fxload_2012.vcxproj.filters +0 -25
- package/libusb/msvc/getopt_2010.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2012.vcxproj.filters +0 -26
- package/libusb/msvc/hotplugtest_2010.vcxproj.filters +0 -14
- package/libusb/msvc/hotplugtest_2012.vcxproj.filters +0 -14
- package/libusb/msvc/libusb_dll_2010.vcxproj.filters +0 -81
- package/libusb/msvc/libusb_dll_2012.vcxproj.filters +0 -84
- package/libusb/msvc/libusb_static_2010.vcxproj.filters +0 -74
- package/libusb/msvc/libusb_static_2012.vcxproj.filters +0 -74
- package/libusb/msvc/listdevs_2010.vcxproj.filters +0 -14
- package/libusb/msvc/listdevs_2012.vcxproj.filters +0 -14
- package/libusb/msvc/stress_2010.vcxproj.filters +0 -25
- package/libusb/msvc/stress_2012.vcxproj.filters +0 -25
- package/libusb/msvc/xusb_2010.vcxproj.filters +0 -14
- package/libusb/msvc/xusb_2012.vcxproj.filters +0 -14
- package/tsc/webusb/typed-event-target.ts +0 -23
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { WebUSB } from './webusb';
|
|
1
|
+
import { WebUSB, getWebUsb } from './webusb';
|
|
2
2
|
import { WebUSBDevice } from './webusb/webusb-device';
|
|
3
3
|
import * as usb from './usb';
|
|
4
|
+
declare const webusb: WebUSB;
|
|
5
|
+
declare const getDeviceList: typeof usb.getDeviceList;
|
|
4
6
|
/**
|
|
5
7
|
* Convenience method to get the first device with the specified VID and PID, or `undefined` if no such device is present.
|
|
6
8
|
* @param vid
|
|
@@ -12,6 +14,4 @@ declare const findByIds: (vid: number, pid: number) => usb.Device | undefined;
|
|
|
12
14
|
* @param serialNumber
|
|
13
15
|
*/
|
|
14
16
|
declare const findBySerialNumber: (serialNumber: string) => Promise<usb.Device | undefined>;
|
|
15
|
-
|
|
16
|
-
declare const getDeviceList: typeof usb.getDeviceList;
|
|
17
|
-
export { usb, getDeviceList, findByIds, findBySerialNumber, webusb, WebUSB, WebUSBDevice };
|
|
17
|
+
export { usb, getDeviceList, findByIds, findBySerialNumber, getWebUsb, webusb, WebUSB, WebUSBDevice };
|
package/dist/index.js
CHANGED
|
@@ -47,14 +47,19 @@ var __values = (this && this.__values) || function(o) {
|
|
|
47
47
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.WebUSBDevice = exports.WebUSB = exports.webusb = exports.findBySerialNumber = exports.findByIds = exports.getDeviceList = exports.usb = void 0;
|
|
50
|
+
exports.WebUSBDevice = exports.WebUSB = exports.webusb = exports.getWebUsb = exports.findBySerialNumber = exports.findByIds = exports.getDeviceList = exports.usb = void 0;
|
|
51
51
|
var util_1 = require("util");
|
|
52
52
|
var webusb_1 = require("./webusb");
|
|
53
53
|
Object.defineProperty(exports, "WebUSB", { enumerable: true, get: function () { return webusb_1.WebUSB; } });
|
|
54
|
+
Object.defineProperty(exports, "getWebUsb", { enumerable: true, get: function () { return webusb_1.getWebUsb; } });
|
|
54
55
|
var webusb_device_1 = require("./webusb/webusb-device");
|
|
55
56
|
Object.defineProperty(exports, "WebUSBDevice", { enumerable: true, get: function () { return webusb_device_1.WebUSBDevice; } });
|
|
56
57
|
var usb = require("./usb");
|
|
57
58
|
exports.usb = usb;
|
|
59
|
+
var webusb = new webusb_1.WebUSB();
|
|
60
|
+
exports.webusb = webusb;
|
|
61
|
+
var getDeviceList = usb.getDeviceList;
|
|
62
|
+
exports.getDeviceList = getDeviceList;
|
|
58
63
|
/**
|
|
59
64
|
* Convenience method to get the first device with the specified VID and PID, or `undefined` if no such device is present.
|
|
60
65
|
* @param vid
|
|
@@ -70,12 +75,13 @@ exports.findByIds = findByIds;
|
|
|
70
75
|
* @param serialNumber
|
|
71
76
|
*/
|
|
72
77
|
var findBySerialNumber = function (serialNumber) { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var devices, devices_1, devices_1_1, device, getStringDescriptor, buffer, _a, e_1_1;
|
|
78
|
+
var devices, opened, devices_1, devices_1_1, device, getStringDescriptor, buffer, _a, e_1_1;
|
|
74
79
|
var e_1, _b;
|
|
75
80
|
return __generator(this, function (_c) {
|
|
76
81
|
switch (_c.label) {
|
|
77
82
|
case 0:
|
|
78
83
|
devices = usb.getDeviceList();
|
|
84
|
+
opened = function (device) { return !!device.interfaces; };
|
|
79
85
|
_c.label = 1;
|
|
80
86
|
case 1:
|
|
81
87
|
_c.trys.push([1, 9, 10, 11]);
|
|
@@ -87,7 +93,9 @@ var findBySerialNumber = function (serialNumber) { return __awaiter(void 0, void
|
|
|
87
93
|
_c.label = 3;
|
|
88
94
|
case 3:
|
|
89
95
|
_c.trys.push([3, 5, 6, 7]);
|
|
90
|
-
device
|
|
96
|
+
if (!opened(device)) {
|
|
97
|
+
device.open();
|
|
98
|
+
}
|
|
91
99
|
getStringDescriptor = util_1.promisify(device.getStringDescriptor).bind(device);
|
|
92
100
|
return [4 /*yield*/, getStringDescriptor(device.deviceDescriptor.iSerialNumber)];
|
|
93
101
|
case 4:
|
|
@@ -101,7 +109,9 @@ var findBySerialNumber = function (serialNumber) { return __awaiter(void 0, void
|
|
|
101
109
|
return [3 /*break*/, 7];
|
|
102
110
|
case 6:
|
|
103
111
|
try {
|
|
104
|
-
device
|
|
112
|
+
if (opened(device)) {
|
|
113
|
+
device.close();
|
|
114
|
+
}
|
|
105
115
|
}
|
|
106
116
|
catch (_d) {
|
|
107
117
|
// Ignore any errors, device may be a system device or inaccessible
|
|
@@ -126,8 +136,4 @@ var findBySerialNumber = function (serialNumber) { return __awaiter(void 0, void
|
|
|
126
136
|
});
|
|
127
137
|
}); };
|
|
128
138
|
exports.findBySerialNumber = findBySerialNumber;
|
|
129
|
-
var webusb = new webusb_1.WebUSB();
|
|
130
|
-
exports.webusb = webusb;
|
|
131
|
-
var getDeviceList = usb.getDeviceList;
|
|
132
|
-
exports.getDeviceList = getDeviceList;
|
|
133
139
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../tsc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../tsc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAiC;AACjC,mCAA6C;AAmEzC,uFAnEK,eAAM,OAmEL;AANN,0FA7Da,kBAAS,OA6Db;AA5Db,wDAAsD;AAqElD,6FArEK,4BAAY,OAqEL;AApEhB,2BAA6B;AAqDzB,kBAAG;AAnDP,IAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;AA4DxB,wBAAM;AA3DV,IAAM,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC;AAqDpC,sCAAa;AAnDjB;;;;GAIG;AACH,IAAM,SAAS,GAAG,UAAC,GAAW,EAAE,GAAW;IACvC,IAAM,OAAO,GAAG,GAAG,CAAC,aAAa,EAAE,CAAC;IACpC,OAAO,OAAO,CAAC,IAAI,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,gBAAgB,CAAC,QAAQ,KAAK,GAAG,IAAI,IAAI,CAAC,gBAAgB,CAAC,SAAS,KAAK,GAAG,EAAjF,CAAiF,CAAC,CAAC;AACnH,CAAC,CAAC;AA4CE,8BAAS;AA1Cb;;;GAGG;AACH,IAAM,kBAAkB,GAAG,UAAO,YAAoB;;;;;;gBAC5C,OAAO,GAAG,GAAG,CAAC,aAAa,EAAE,CAAC;gBAC9B,MAAM,GAAG,UAAC,MAAkB,IAAc,OAAA,CAAC,CAAC,MAAM,CAAC,UAAU,EAAnB,CAAmB,CAAC;;;;gBAE/C,YAAA,SAAA,OAAO,CAAA;;;;gBAAjB,MAAM;;;;gBAET,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;oBACjB,MAAM,CAAC,IAAI,EAAE,CAAC;iBACjB;gBAEK,mBAAmB,GAAG,gBAAS,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAChE,qBAAM,mBAAmB,CAAC,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAA;;gBAAzE,MAAM,GAAG,SAAgE;gBAE/E,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK,YAAY,EAAE;oBAC9C,sBAAO,MAAM,EAAC;iBACjB;;;;;;gBAID,IAAI;oBACA,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE;wBAChB,MAAM,CAAC,KAAK,EAAE,CAAC;qBAClB;iBACJ;gBAAC,WAAM;oBACJ,mEAAmE;iBACtE;;;;;;;;;;;;;;;;qBAIT,sBAAO,SAAS,EAAC;;;KACpB,CAAC;AASE,gDAAkB"}
|
package/dist/usb/bindings.d.ts
CHANGED
|
@@ -15,6 +15,15 @@ export declare class LibUSBException extends Error {
|
|
|
15
15
|
export declare function setDebugLevel(level: number): void;
|
|
16
16
|
export declare function _enableHotplugEvents(): void;
|
|
17
17
|
export declare function _disableHotplugEvents(): void;
|
|
18
|
+
export declare function _getLibusbCapability(capability: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* Restore (re-reference) the hotplug events unreferenced by `unrefHotplugEvents()`
|
|
21
|
+
*/
|
|
22
|
+
export declare function refHotplugEvents(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Unreference the hotplug events from the event loop, allowing the process to exit even when listening for the `attach` and `detach` events
|
|
25
|
+
*/
|
|
26
|
+
export declare function unrefHotplugEvents(): void;
|
|
18
27
|
/** Represents a USB transfer */
|
|
19
28
|
export declare class Transfer {
|
|
20
29
|
constructor(device: Device, endpointAddr: number, type: number, timeout: number, callback: (error: LibUSBException, buf: Buffer, actual: number) => void);
|
|
@@ -212,6 +221,10 @@ export declare const LIBUSB_RECIPIENT_ENDPOINT: number;
|
|
|
212
221
|
export declare const LIBUSB_RECIPIENT_OTHER: number;
|
|
213
222
|
export declare const LIBUSB_CONTROL_SETUP_SIZE: number;
|
|
214
223
|
export declare const LIBUSB_DT_BOS_SIZE: number;
|
|
224
|
+
export declare const LIBUSB_CAP_HAS_CAPABILITY: number;
|
|
225
|
+
export declare const LIBUSB_CAP_HAS_HOTPLUG: number;
|
|
226
|
+
export declare const LIBUSB_CAP_HAS_HID_ACCESS: number;
|
|
227
|
+
export declare const LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER: number;
|
|
215
228
|
/** Input/output error */
|
|
216
229
|
export declare const LIBUSB_ERROR_IO: number;
|
|
217
230
|
/** Invalid parameter */
|
package/dist/usb/bindings.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// Eric Brody <https://github.com/underscorebrody>
|
|
4
4
|
// Rob Moran <https://github.com/thegecko>
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var path_1 = require("path");
|
|
6
7
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
7
|
-
var usb = require('
|
|
8
|
+
var usb = require('node-gyp-build')(path_1.join(__dirname, '..', '..'));
|
|
8
9
|
module.exports = usb;
|
|
9
10
|
//# sourceMappingURL=bindings.js.map
|
package/dist/usb/bindings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../tsc/usb/bindings.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,mDAAmD;AACnD,2CAA2C;;
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../tsc/usb/bindings.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,mDAAmD;AACnD,2CAA2C;;AAE3C,6BAA4B;AAG5B,uDAAuD;AACvD,IAAM,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,WAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACnE,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC"}
|
package/dist/usb/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
2
13
|
var events_1 = require("events");
|
|
3
14
|
var device_1 = require("./device");
|
|
4
15
|
var usb = require("./bindings");
|
|
@@ -10,13 +21,81 @@ Object.setPrototypeOf(usb, events_1.EventEmitter.prototype);
|
|
|
10
21
|
Object.getOwnPropertyNames(device_1.ExtendedDevice.prototype).forEach(function (name) {
|
|
11
22
|
Object.defineProperty(usb.Device.prototype, name, Object.getOwnPropertyDescriptor(device_1.ExtendedDevice.prototype, name) || Object.create(null));
|
|
12
23
|
});
|
|
24
|
+
// Polling mechanism for discovering device changes until this is fixed:
|
|
25
|
+
// https://github.com/libusb/libusb/issues/86
|
|
26
|
+
var pollTimeout = 500;
|
|
27
|
+
var hotplugSupported = usb._getLibusbCapability(usb.LIBUSB_CAP_HAS_HOTPLUG) > 0;
|
|
28
|
+
var pollingHotplug = false;
|
|
29
|
+
var pollDevices = [];
|
|
30
|
+
var pollHotplug = function (start) {
|
|
31
|
+
var e_1, _a, e_2, _b;
|
|
32
|
+
if (start === void 0) { start = false; }
|
|
33
|
+
if (start) {
|
|
34
|
+
pollingHotplug = true;
|
|
35
|
+
}
|
|
36
|
+
else if (!pollingHotplug) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var devices = usb.getDeviceList();
|
|
40
|
+
if (!start) {
|
|
41
|
+
var _loop_1 = function (device) {
|
|
42
|
+
var found = pollDevices.find(function (item) { return item.deviceAddress === device.deviceAddress; });
|
|
43
|
+
if (!found) {
|
|
44
|
+
usb.emit('attach', device);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
// Find attached devices
|
|
49
|
+
for (var devices_1 = __values(devices), devices_1_1 = devices_1.next(); !devices_1_1.done; devices_1_1 = devices_1.next()) {
|
|
50
|
+
var device = devices_1_1.value;
|
|
51
|
+
_loop_1(device);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
55
|
+
finally {
|
|
56
|
+
try {
|
|
57
|
+
if (devices_1_1 && !devices_1_1.done && (_a = devices_1.return)) _a.call(devices_1);
|
|
58
|
+
}
|
|
59
|
+
finally { if (e_1) throw e_1.error; }
|
|
60
|
+
}
|
|
61
|
+
var _loop_2 = function (device) {
|
|
62
|
+
var found = devices.find(function (item) { return item.deviceAddress === device.deviceAddress; });
|
|
63
|
+
if (!found) {
|
|
64
|
+
usb.emit('detach', device);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
try {
|
|
68
|
+
// Find detached devices
|
|
69
|
+
for (var pollDevices_1 = __values(pollDevices), pollDevices_1_1 = pollDevices_1.next(); !pollDevices_1_1.done; pollDevices_1_1 = pollDevices_1.next()) {
|
|
70
|
+
var device = pollDevices_1_1.value;
|
|
71
|
+
_loop_2(device);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
75
|
+
finally {
|
|
76
|
+
try {
|
|
77
|
+
if (pollDevices_1_1 && !pollDevices_1_1.done && (_b = pollDevices_1.return)) _b.call(pollDevices_1);
|
|
78
|
+
}
|
|
79
|
+
finally { if (e_2) throw e_2.error; }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
pollDevices = devices;
|
|
83
|
+
setTimeout(function () {
|
|
84
|
+
pollHotplug();
|
|
85
|
+
}, pollTimeout);
|
|
86
|
+
};
|
|
13
87
|
usb.on('newListener', function (event) {
|
|
14
88
|
if (event !== 'attach' && event !== 'detach') {
|
|
15
89
|
return;
|
|
16
90
|
}
|
|
17
91
|
var listenerCount = usb.listenerCount('attach') + usb.listenerCount('detach');
|
|
18
92
|
if (listenerCount === 0) {
|
|
19
|
-
|
|
93
|
+
if (hotplugSupported) {
|
|
94
|
+
usb._enableHotplugEvents();
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
pollHotplug(true);
|
|
98
|
+
}
|
|
20
99
|
}
|
|
21
100
|
});
|
|
22
101
|
usb.on('removeListener', function (event) {
|
|
@@ -25,7 +104,12 @@ usb.on('removeListener', function (event) {
|
|
|
25
104
|
}
|
|
26
105
|
var listenerCount = usb.listenerCount('attach') + usb.listenerCount('detach');
|
|
27
106
|
if (listenerCount === 0) {
|
|
28
|
-
|
|
107
|
+
if (hotplugSupported) {
|
|
108
|
+
usb._disableHotplugEvents();
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
pollingHotplug = false;
|
|
112
|
+
}
|
|
29
113
|
}
|
|
30
114
|
});
|
|
31
115
|
module.exports = usb;
|
package/dist/usb/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tsc/usb/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tsc/usb/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAsC;AACtC,mCAA0C;AAC1C,gCAAkC;AAElC,IAAI,GAAG,CAAC,UAAU,EAAE;IAChB,+BAA+B;IAC/B,OAAO,CAAC,IAAI,CAAC,8B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F,IAAI,aAAa,KAAK,CAAC,EAAE;QACrB,IAAI,gBAAgB,EAAE;YAClB,GAAG,CAAC,qBAAqB,EAAE,CAAC;SAC/B;aAAM;YACH,cAAc,GAAG,KAAK,CAAC;SAC1B;KACJ;AACL,CAAC,CAAC,CAAC;AAEH,iBAAS,GAAG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../tsc/usb/interface.ts"],"names":[],"mappings":";;;AAAA,uCAAyE;AAEzE,uCAA+D;AAE/D;IAaI,mBAAsB,MAAc,EAAY,EAAU;QAApC,WAAM,GAAN,MAAM,CAAQ;QAAY,OAAE,GAAF,EAAE,CAAQ;QAT1D,wCAAwC;QACjC,eAAU,GAAG,CAAC,CAAC;QASlB,IAAI,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;IAES,2BAAO,GAAjB;QACI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE;YAC/B,OAAO;SACV;QAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACpF,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACxD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC;QAC7C,KAAK,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../tsc/usb/interface.ts"],"names":[],"mappings":";;;AAAA,uCAAyE;AAEzE,uCAA+D;AAE/D;IAaI,mBAAsB,MAAc,EAAY,EAAU;QAApC,WAAM,GAAN,MAAM,CAAQ;QAAY,OAAE,GAAF,EAAE,CAAQ;QAT1D,wCAAwC;QACjC,eAAU,GAAG,CAAC,CAAC;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OAIG;IACI,sCAAkB,GAAzB;QACI,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;OAMG;IACI,iCAAa,GAApB,UAAqB,UAAkB,EAAE,QAAuD;QAAhG,iBAUC;QATG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,UAAA,KAAK;YACjD,IAAI,CAAC,KAAK,EAAE;gBACR,KAAI,CAAC,UAAU,GAAG,UAAU,CAAC;gBAC7B,KAAI,CAAC,OAAO,EAAE,CAAC;aAClB;YACD,IAAI,QAAQ,EAAE;gBACV,QAAQ,CAAC,IAAI,CAAC,KAAI,EAAE,KAAK,CAAC,CAAC;aAC9B;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACI,4BAAQ,GAAf,UAAgB,IAAY;QACxB,IAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,OAAO,KAAK,IAAI,EAArB,CAAqB,CAAC,CAAC;QACpE,IAAI,CAAC,QAAQ,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,qCAAmC,IAAM,CAAC,CAAC;SAC9D;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;IACL,gBAAC;AAAD,CAAC,AAvKD,IAuKC;AAvKY,8BAAS"}
|
package/dist/webusb/index.d.ts
CHANGED
|
@@ -1,33 +1,46 @@
|
|
|
1
1
|
/// <reference types="w3c-web-usb" />
|
|
2
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
3
4
|
/**
|
|
4
5
|
* USB Options
|
|
5
6
|
*/
|
|
6
7
|
export interface USBOptions {
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Optional `device found` callback function to allow the user to select a device
|
|
9
10
|
*/
|
|
10
|
-
devicesFound?: (devices:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare type USBEvents = {
|
|
11
|
+
devicesFound?: (devices: USBDevice[]) => Promise<USBDevice | void>;
|
|
12
|
+
/**
|
|
13
|
+
* Optional array of preconfigured allowed devices
|
|
14
|
+
*/
|
|
15
|
+
allowedDevices?: USBDeviceFilter[];
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Optional flag to automatically allow all devices
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
allowAllDevices?: boolean;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Optional timeout (in milliseconds) to use for the device control transfers
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
23
|
+
deviceTimeout?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convenience method to get the WebUSB interface available
|
|
27
|
+
*/
|
|
28
|
+
export declare const getWebUsb: () => USB;
|
|
29
|
+
export declare class WebUSB implements USB {
|
|
26
30
|
private options;
|
|
27
|
-
|
|
31
|
+
protected emitter: EventEmitter;
|
|
32
|
+
protected knownDevices: Map<string, USBDevice>;
|
|
33
|
+
protected allowedDevices: USBDeviceFilter[];
|
|
28
34
|
constructor(options?: USBOptions);
|
|
29
|
-
|
|
30
|
-
set
|
|
35
|
+
private _onconnect;
|
|
36
|
+
set onconnect(fn: (ev: USBConnectionEvent) => void);
|
|
37
|
+
private _ondisconnect;
|
|
38
|
+
set ondisconnect(fn: (ev: USBConnectionEvent) => void);
|
|
39
|
+
addEventListener(type: 'connect' | 'disconnect', listener: (this: this, ev: USBConnectionEvent) => void): void;
|
|
40
|
+
addEventListener(type: 'connect' | 'disconnect', listener: EventListener): void;
|
|
41
|
+
removeEventListener(type: 'connect' | 'disconnect', callback: (this: this, ev: USBConnectionEvent) => void): void;
|
|
42
|
+
removeEventListener(type: 'connect' | 'disconnect', callback: EventListener): void;
|
|
43
|
+
dispatchEvent(_event: Event): boolean;
|
|
31
44
|
/**
|
|
32
45
|
* Requests a single Web USB device
|
|
33
46
|
* @param options The options to use when scanning
|
|
@@ -41,7 +54,7 @@ export declare class WebUSB extends TypedEventTarget<USBEvents> implements USB {
|
|
|
41
54
|
getDevices(): Promise<USBDevice[]>;
|
|
42
55
|
private loadDevices;
|
|
43
56
|
private preFilterDevices;
|
|
44
|
-
private isSameDevice;
|
|
45
|
-
private replaceAllowedDevice;
|
|
46
57
|
private filterDevice;
|
|
58
|
+
private getDeviceId;
|
|
59
|
+
private isAllowedDevice;
|
|
47
60
|
}
|