usb 2.0.0-alpha.1 → 2.0.3
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/.gitattributes +1 -0
- package/.gitmodules +1 -1
- package/CHANGELOG.md +91 -0
- package/README.md +570 -0
- package/binding.gyp +2 -2
- package/dist/index.d.ts +16 -5
- package/dist/index.js +135 -5
- 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.d.ts +0 -2
- package/dist/usb/index.js +75 -112
- package/dist/usb/index.js.map +1 -1
- package/dist/usb/interface.js.map +1 -1
- package/dist/webusb/index.d.ts +28 -19
- package/dist/webusb/index.js +152 -66
- package/dist/webusb/index.js.map +1 -1
- package/dist/webusb/webusb-device.d.ts +1 -1
- package/dist/webusb/webusb-device.js +15 -6
- 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 +0 -3
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +959 -1
- package/libusb/android/README +4 -2
- package/libusb/android/config.h +0 -6
- 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 +13 -2
- package/package.json +23 -13
- package/prebuilds/android-arm/node.napi.armv7.node +0 -0
- package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/linux-ia32/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.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 +12 -4
- package/tsc/index.ts +68 -8
- package/tsc/usb/bindings.ts +19 -1
- package/tsc/usb/index.ts +66 -68
- package/tsc/usb/interface.ts +2 -2
- package/tsc/webusb/index.ts +187 -75
- package/tsc/webusb/webusb-device.ts +28 -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 -173
- package/docs/modules/usb.html +0 -173
- package/docs/modules/usb_bindings.html +0 -2319
- 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,17 @@
|
|
|
1
|
-
import * as usb from './usb';
|
|
2
1
|
import { WebUSB } from './webusb';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { WebUSBDevice } from './webusb/webusb-device';
|
|
3
|
+
import * as usb from './usb';
|
|
4
|
+
/**
|
|
5
|
+
* Convenience method to get the first device with the specified VID and PID, or `undefined` if no such device is present.
|
|
6
|
+
* @param vid
|
|
7
|
+
* @param pid
|
|
8
|
+
*/
|
|
9
|
+
declare const findByIds: (vid: number, pid: number) => usb.Device | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Convenience method to get the device with the specified serial number, or `undefined` if no such device is present.
|
|
12
|
+
* @param serialNumber
|
|
13
|
+
*/
|
|
14
|
+
declare const findBySerialNumber: (serialNumber: string) => Promise<usb.Device | undefined>;
|
|
15
|
+
declare const webusb: WebUSB;
|
|
16
|
+
declare const getDeviceList: typeof usb.getDeviceList;
|
|
17
|
+
export { usb, getDeviceList, findByIds, findBySerialNumber, webusb, WebUSB, WebUSBDevice };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,138 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.WebUSBDevice = exports.WebUSB = exports.webusb = exports.findBySerialNumber = exports.findByIds = exports.getDeviceList = exports.usb = void 0;
|
|
51
|
+
var util_1 = require("util");
|
|
3
52
|
var webusb_1 = require("./webusb");
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
|
|
53
|
+
Object.defineProperty(exports, "WebUSB", { enumerable: true, get: function () { return webusb_1.WebUSB; } });
|
|
54
|
+
var webusb_device_1 = require("./webusb/webusb-device");
|
|
55
|
+
Object.defineProperty(exports, "WebUSBDevice", { enumerable: true, get: function () { return webusb_device_1.WebUSBDevice; } });
|
|
56
|
+
var usb = require("./usb");
|
|
57
|
+
exports.usb = usb;
|
|
58
|
+
/**
|
|
59
|
+
* Convenience method to get the first device with the specified VID and PID, or `undefined` if no such device is present.
|
|
60
|
+
* @param vid
|
|
61
|
+
* @param pid
|
|
62
|
+
*/
|
|
63
|
+
var findByIds = function (vid, pid) {
|
|
64
|
+
var devices = usb.getDeviceList();
|
|
65
|
+
return devices.find(function (item) { return item.deviceDescriptor.idVendor === vid && item.deviceDescriptor.idProduct === pid; });
|
|
66
|
+
};
|
|
67
|
+
exports.findByIds = findByIds;
|
|
68
|
+
/**
|
|
69
|
+
* Convenience method to get the device with the specified serial number, or `undefined` if no such device is present.
|
|
70
|
+
* @param serialNumber
|
|
71
|
+
*/
|
|
72
|
+
var findBySerialNumber = function (serialNumber) { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
+
var devices, opened, devices_1, devices_1_1, device, getStringDescriptor, buffer, _a, e_1_1;
|
|
74
|
+
var e_1, _b;
|
|
75
|
+
return __generator(this, function (_c) {
|
|
76
|
+
switch (_c.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
devices = usb.getDeviceList();
|
|
79
|
+
opened = function (device) { return !!device.interfaces; };
|
|
80
|
+
_c.label = 1;
|
|
81
|
+
case 1:
|
|
82
|
+
_c.trys.push([1, 9, 10, 11]);
|
|
83
|
+
devices_1 = __values(devices), devices_1_1 = devices_1.next();
|
|
84
|
+
_c.label = 2;
|
|
85
|
+
case 2:
|
|
86
|
+
if (!!devices_1_1.done) return [3 /*break*/, 8];
|
|
87
|
+
device = devices_1_1.value;
|
|
88
|
+
_c.label = 3;
|
|
89
|
+
case 3:
|
|
90
|
+
_c.trys.push([3, 5, 6, 7]);
|
|
91
|
+
if (!opened(device)) {
|
|
92
|
+
device.open();
|
|
93
|
+
}
|
|
94
|
+
getStringDescriptor = util_1.promisify(device.getStringDescriptor).bind(device);
|
|
95
|
+
return [4 /*yield*/, getStringDescriptor(device.deviceDescriptor.iSerialNumber)];
|
|
96
|
+
case 4:
|
|
97
|
+
buffer = _c.sent();
|
|
98
|
+
if (buffer && buffer.toString() === serialNumber) {
|
|
99
|
+
return [2 /*return*/, device];
|
|
100
|
+
}
|
|
101
|
+
return [3 /*break*/, 7];
|
|
102
|
+
case 5:
|
|
103
|
+
_a = _c.sent();
|
|
104
|
+
return [3 /*break*/, 7];
|
|
105
|
+
case 6:
|
|
106
|
+
try {
|
|
107
|
+
if (opened(device)) {
|
|
108
|
+
device.close();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (_d) {
|
|
112
|
+
// Ignore any errors, device may be a system device or inaccessible
|
|
113
|
+
}
|
|
114
|
+
return [7 /*endfinally*/];
|
|
115
|
+
case 7:
|
|
116
|
+
devices_1_1 = devices_1.next();
|
|
117
|
+
return [3 /*break*/, 2];
|
|
118
|
+
case 8: return [3 /*break*/, 11];
|
|
119
|
+
case 9:
|
|
120
|
+
e_1_1 = _c.sent();
|
|
121
|
+
e_1 = { error: e_1_1 };
|
|
122
|
+
return [3 /*break*/, 11];
|
|
123
|
+
case 10:
|
|
124
|
+
try {
|
|
125
|
+
if (devices_1_1 && !devices_1_1.done && (_b = devices_1.return)) _b.call(devices_1);
|
|
126
|
+
}
|
|
127
|
+
finally { if (e_1) throw e_1.error; }
|
|
128
|
+
return [7 /*endfinally*/];
|
|
129
|
+
case 11: return [2 /*return*/, undefined];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}); };
|
|
133
|
+
exports.findBySerialNumber = findBySerialNumber;
|
|
134
|
+
var webusb = new webusb_1.WebUSB();
|
|
135
|
+
exports.webusb = webusb;
|
|
136
|
+
var getDeviceList = usb.getDeviceList;
|
|
137
|
+
exports.getDeviceList = getDeviceList;
|
|
8
138
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../tsc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAiC;AACjC,mCAAkC;AAkE9B,uFAlEK,eAAM,OAkEL;AAjEV,wDAAsD;AAoElD,6FApEK,4BAAY,OAoEL;AAnEhB,2BAA6B;AAqDzB,kBAAG;AAnDP;;;;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;AA+CE,8BAAS;AA7Cb;;;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;AAYE,gDAAkB;AAVtB,IAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;AAaxB,wBAAM;AAZV,IAAM,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC;AAOpC,sCAAa"}
|
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.d.ts
CHANGED
|
@@ -21,7 +21,5 @@ declare module './bindings' {
|
|
|
21
21
|
function removeAllListeners<K extends keyof DeviceEvents>(event?: K): void;
|
|
22
22
|
function emit<K extends keyof DeviceEvents>(event: K, arg: DeviceEvents[K]): boolean;
|
|
23
23
|
function listenerCount<K extends keyof DeviceEvents>(event: K): number;
|
|
24
|
-
function findByIds(vid: number, pid: number): usb.Device | undefined;
|
|
25
|
-
function findBySerialNumber(serialNumber: string): Promise<usb.Device | undefined>;
|
|
26
24
|
}
|
|
27
25
|
export = usb;
|
package/dist/usb/index.js
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __values = (this && this.__values) || function(o) {
|
|
39
3
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
4
|
if (m) return m.call(o);
|
|
@@ -46,7 +10,6 @@ var __values = (this && this.__values) || function(o) {
|
|
|
46
10
|
};
|
|
47
11
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
12
|
};
|
|
49
|
-
var util_1 = require("util");
|
|
50
13
|
var events_1 = require("events");
|
|
51
14
|
var device_1 = require("./device");
|
|
52
15
|
var usb = require("./bindings");
|
|
@@ -58,13 +21,81 @@ Object.setPrototypeOf(usb, events_1.EventEmitter.prototype);
|
|
|
58
21
|
Object.getOwnPropertyNames(device_1.ExtendedDevice.prototype).forEach(function (name) {
|
|
59
22
|
Object.defineProperty(usb.Device.prototype, name, Object.getOwnPropertyDescriptor(device_1.ExtendedDevice.prototype, name) || Object.create(null));
|
|
60
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
|
+
};
|
|
61
87
|
usb.on('newListener', function (event) {
|
|
62
88
|
if (event !== 'attach' && event !== 'detach') {
|
|
63
89
|
return;
|
|
64
90
|
}
|
|
65
91
|
var listenerCount = usb.listenerCount('attach') + usb.listenerCount('detach');
|
|
66
92
|
if (listenerCount === 0) {
|
|
67
|
-
|
|
93
|
+
if (hotplugSupported) {
|
|
94
|
+
usb._enableHotplugEvents();
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
pollHotplug(true);
|
|
98
|
+
}
|
|
68
99
|
}
|
|
69
100
|
});
|
|
70
101
|
usb.on('removeListener', function (event) {
|
|
@@ -73,81 +104,13 @@ usb.on('removeListener', function (event) {
|
|
|
73
104
|
}
|
|
74
105
|
var listenerCount = usb.listenerCount('attach') + usb.listenerCount('detach');
|
|
75
106
|
if (listenerCount === 0) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
* @param vid
|
|
82
|
-
* @param pid
|
|
83
|
-
*/
|
|
84
|
-
var findByIds = function (vid, pid) {
|
|
85
|
-
var devices = usb.getDeviceList();
|
|
86
|
-
return devices.find(function (item) { return item.deviceDescriptor.idVendor === vid && item.deviceDescriptor.idProduct === pid; });
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Convenience method to get the device with the specified serial number, or `undefined` if no such device is present.
|
|
90
|
-
* @param serialNumber
|
|
91
|
-
*/
|
|
92
|
-
var findBySerialNumber = function (serialNumber) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
-
var devices, devices_1, devices_1_1, device, getStringDescriptor, buffer, _a, e_1_1;
|
|
94
|
-
var e_1, _b;
|
|
95
|
-
return __generator(this, function (_c) {
|
|
96
|
-
switch (_c.label) {
|
|
97
|
-
case 0:
|
|
98
|
-
devices = usb.getDeviceList();
|
|
99
|
-
_c.label = 1;
|
|
100
|
-
case 1:
|
|
101
|
-
_c.trys.push([1, 9, 10, 11]);
|
|
102
|
-
devices_1 = __values(devices), devices_1_1 = devices_1.next();
|
|
103
|
-
_c.label = 2;
|
|
104
|
-
case 2:
|
|
105
|
-
if (!!devices_1_1.done) return [3 /*break*/, 8];
|
|
106
|
-
device = devices_1_1.value;
|
|
107
|
-
_c.label = 3;
|
|
108
|
-
case 3:
|
|
109
|
-
_c.trys.push([3, 5, 6, 7]);
|
|
110
|
-
device.open();
|
|
111
|
-
getStringDescriptor = util_1.promisify(device.getStringDescriptor).bind(device);
|
|
112
|
-
return [4 /*yield*/, getStringDescriptor(device.deviceDescriptor.iSerialNumber)];
|
|
113
|
-
case 4:
|
|
114
|
-
buffer = _c.sent();
|
|
115
|
-
if (buffer && buffer.toString() === serialNumber) {
|
|
116
|
-
return [2 /*return*/, device];
|
|
117
|
-
}
|
|
118
|
-
return [3 /*break*/, 7];
|
|
119
|
-
case 5:
|
|
120
|
-
_a = _c.sent();
|
|
121
|
-
return [3 /*break*/, 7];
|
|
122
|
-
case 6:
|
|
123
|
-
try {
|
|
124
|
-
device.close();
|
|
125
|
-
}
|
|
126
|
-
catch (_d) {
|
|
127
|
-
// Ignore any errors, device may be a system device or inaccessible
|
|
128
|
-
}
|
|
129
|
-
return [7 /*endfinally*/];
|
|
130
|
-
case 7:
|
|
131
|
-
devices_1_1 = devices_1.next();
|
|
132
|
-
return [3 /*break*/, 2];
|
|
133
|
-
case 8: return [3 /*break*/, 11];
|
|
134
|
-
case 9:
|
|
135
|
-
e_1_1 = _c.sent();
|
|
136
|
-
e_1 = { error: e_1_1 };
|
|
137
|
-
return [3 /*break*/, 11];
|
|
138
|
-
case 10:
|
|
139
|
-
try {
|
|
140
|
-
if (devices_1_1 && !devices_1_1.done && (_b = devices_1.return)) _b.call(devices_1);
|
|
141
|
-
}
|
|
142
|
-
finally { if (e_1) throw e_1.error; }
|
|
143
|
-
return [7 /*endfinally*/];
|
|
144
|
-
case 11: return [2 /*return*/, undefined];
|
|
107
|
+
if (hotplugSupported) {
|
|
108
|
+
usb._disableHotplugEvents();
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
pollingHotplug = false;
|
|
145
112
|
}
|
|
146
|
-
}
|
|
147
|
-
}); };
|
|
148
|
-
Object.assign(usb, {
|
|
149
|
-
findByIds: findByIds,
|
|
150
|
-
findBySerialNumber: findBySerialNumber
|
|
113
|
+
}
|
|
151
114
|
});
|
|
152
115
|
module.exports = usb;
|
|
153
116
|
//# sourceMappingURL=index.js.map
|
package/dist/usb/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tsc/usb/index.ts"],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|
|
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
|
-
* @hidden
|
|
14
|
-
*/
|
|
15
|
-
export declare type USBEvents = {
|
|
11
|
+
devicesFound?: (devices: USBDevice[]) => Promise<USBDevice | void>;
|
|
16
12
|
/**
|
|
17
|
-
*
|
|
13
|
+
* Optional array of preconfigured allowed devices
|
|
18
14
|
*/
|
|
19
|
-
|
|
15
|
+
allowedDevices?: USBDeviceFilter[];
|
|
20
16
|
/**
|
|
21
|
-
*
|
|
17
|
+
* Optional flag to automatically allow all devices
|
|
22
18
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
allowAllDevices?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Optional timeout (in milliseconds) to use for the device control transfers
|
|
22
|
+
*/
|
|
23
|
+
deviceTimeout?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare class WebUSB implements USB {
|
|
26
26
|
private options;
|
|
27
|
-
|
|
27
|
+
protected emitter: EventEmitter;
|
|
28
|
+
protected knownDevices: Map<string, USBDevice>;
|
|
29
|
+
protected allowedDevices: USBDeviceFilter[];
|
|
28
30
|
constructor(options?: USBOptions);
|
|
29
|
-
|
|
30
|
-
set
|
|
31
|
+
private _onconnect;
|
|
32
|
+
set onconnect(fn: (ev: USBConnectionEvent) => void);
|
|
33
|
+
private _ondisconnect;
|
|
34
|
+
set ondisconnect(fn: (ev: USBConnectionEvent) => void);
|
|
35
|
+
addEventListener(type: 'connect' | 'disconnect', listener: (this: this, ev: USBConnectionEvent) => void): void;
|
|
36
|
+
addEventListener(type: 'connect' | 'disconnect', listener: EventListener): void;
|
|
37
|
+
removeEventListener(type: 'connect' | 'disconnect', callback: (this: this, ev: USBConnectionEvent) => void): void;
|
|
38
|
+
removeEventListener(type: 'connect' | 'disconnect', callback: EventListener): void;
|
|
39
|
+
dispatchEvent(_event: Event): boolean;
|
|
31
40
|
/**
|
|
32
41
|
* Requests a single Web USB device
|
|
33
42
|
* @param options The options to use when scanning
|
|
@@ -41,7 +50,7 @@ export declare class WebUSB extends TypedEventTarget<USBEvents> implements USB {
|
|
|
41
50
|
getDevices(): Promise<USBDevice[]>;
|
|
42
51
|
private loadDevices;
|
|
43
52
|
private preFilterDevices;
|
|
44
|
-
private isSameDevice;
|
|
45
|
-
private replaceAllowedDevice;
|
|
46
53
|
private filterDevice;
|
|
54
|
+
private getDeviceId;
|
|
55
|
+
private isAllowedDevice;
|
|
47
56
|
}
|