usb 2.17.0 → 3.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -4
- package/README.md +25 -516
- package/dist/index.d.ts +67 -13
- package/dist/index.js +333 -64
- package/index.d.ts +89 -0
- package/index.js +583 -0
- package/package.json +53 -33
- package/CHANGELOG.md +0 -294
- package/binding.gyp +0 -128
- package/dist/index.js.map +0 -1
- package/dist/usb/bindings.d.ts +0 -266
- package/dist/usb/bindings.js +0 -10
- package/dist/usb/bindings.js.map +0 -1
- package/dist/usb/capability.d.ts +0 -13
- package/dist/usb/capability.js +0 -17
- package/dist/usb/capability.js.map +0 -1
- package/dist/usb/descriptors.d.ts +0 -128
- package/dist/usb/descriptors.js +0 -3
- package/dist/usb/descriptors.js.map +0 -1
- package/dist/usb/device.d.ts +0 -100
- package/dist/usb/device.js +0 -297
- package/dist/usb/device.js.map +0 -1
- package/dist/usb/endpoint.d.ts +0 -94
- package/dist/usb/endpoint.js +0 -219
- package/dist/usb/endpoint.js.map +0 -1
- package/dist/usb/index.d.ts +0 -31
- package/dist/usb/index.js +0 -116
- package/dist/usb/index.js.map +0 -1
- package/dist/usb/interface.d.ts +0 -80
- package/dist/usb/interface.js +0 -133
- package/dist/usb/interface.js.map +0 -1
- package/dist/webusb/index.d.ts +0 -64
- package/dist/webusb/index.js +0 -295
- package/dist/webusb/index.js.map +0 -1
- package/dist/webusb/webusb-device.d.ts +0 -54
- package/dist/webusb/webusb-device.js +0 -434
- package/dist/webusb/webusb-device.js.map +0 -1
- package/libusb/.clang-tidy +0 -34
- package/libusb/.codespellrc +0 -3
- package/libusb/.private/README.txt +0 -5
- package/libusb/.private/appveyor_build.sh +0 -26
- package/libusb/.private/bm.sh +0 -54
- package/libusb/.private/ci-build.sh +0 -92
- package/libusb/.private/ci-container-build.sh +0 -67
- package/libusb/.private/post-rewrite.sh +0 -32
- package/libusb/.private/pre-commit.sh +0 -52
- package/libusb/.private/wbs.txt +0 -43
- package/libusb/.travis.yml +0 -58
- package/libusb/AUTHORS +0 -231
- package/libusb/COPYING +0 -504
- package/libusb/ChangeLog +0 -365
- package/libusb/HACKING +0 -25
- package/libusb/INSTALL_WIN.txt +0 -52
- package/libusb/KEYS +0 -123
- package/libusb/Makefile.am +0 -50
- package/libusb/NEWS +0 -2
- package/libusb/PORTING +0 -94
- package/libusb/README +0 -29
- package/libusb/README.git +0 -41
- package/libusb/TODO +0 -2
- package/libusb/Xcode/common.xcconfig +0 -92
- package/libusb/Xcode/config.h +0 -31
- package/libusb/Xcode/debug.xcconfig +0 -32
- package/libusb/Xcode/libusb.xcconfig +0 -21
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +0 -1391
- package/libusb/Xcode/libusb_debug.xcconfig +0 -21
- package/libusb/Xcode/libusb_release.xcconfig +0 -21
- package/libusb/Xcode/release.xcconfig +0 -30
- package/libusb/android/README +0 -152
- package/libusb/android/config.h +0 -55
- package/libusb/android/examples/unrooted_android.c +0 -301
- package/libusb/android/examples/unrooted_android.h +0 -36
- package/libusb/android/jni/Android.mk +0 -23
- package/libusb/android/jni/Application.mk +0 -40
- package/libusb/android/jni/examples.mk +0 -168
- package/libusb/android/jni/libusb.mk +0 -60
- package/libusb/android/jni/tests.mk +0 -45
- package/libusb/appveyor.yml +0 -108
- package/libusb/autogen.sh +0 -10
- package/libusb/bootstrap.sh +0 -10
- package/libusb/configure.ac +0 -450
- package/libusb/doc/Makefile.in +0 -22
- package/libusb/doc/doxygen.cfg.in +0 -2571
- package/libusb/doc/libusb.png +0 -0
- package/libusb/examples/Makefile.am +0 -12
- package/libusb/examples/dpfp.c +0 -711
- package/libusb/examples/ezusb.c +0 -846
- package/libusb/examples/ezusb.h +0 -109
- package/libusb/examples/fxload.c +0 -310
- package/libusb/examples/hotplugtest.c +0 -147
- package/libusb/examples/listdevs.c +0 -73
- package/libusb/examples/sam3u_benchmark.c +0 -228
- package/libusb/examples/testlibusb.c +0 -312
- package/libusb/examples/xusb.c +0 -1254
- package/libusb/libusb/Makefile.am +0 -98
- package/libusb/libusb/Makefile.am.extra +0 -26
- package/libusb/libusb/core.c +0 -2925
- package/libusb/libusb/descriptor.c +0 -1558
- package/libusb/libusb/hotplug.c +0 -489
- package/libusb/libusb/io.c +0 -2865
- package/libusb/libusb/libusb-1.0.def +0 -199
- package/libusb/libusb/libusb-1.0.rc +0 -53
- package/libusb/libusb/libusb.h +0 -2421
- package/libusb/libusb/libusbi.h +0 -1535
- package/libusb/libusb/os/darwin_usb.c +0 -2977
- package/libusb/libusb/os/darwin_usb.h +0 -156
- package/libusb/libusb/os/emscripten_webusb.cpp +0 -875
- package/libusb/libusb/os/events_posix.c +0 -340
- package/libusb/libusb/os/events_posix.h +0 -62
- package/libusb/libusb/os/events_windows.c +0 -214
- package/libusb/libusb/os/events_windows.h +0 -46
- package/libusb/libusb/os/haiku_pollfs.cpp +0 -372
- package/libusb/libusb/os/haiku_usb.h +0 -113
- package/libusb/libusb/os/haiku_usb_backend.cpp +0 -532
- package/libusb/libusb/os/haiku_usb_raw.cpp +0 -231
- package/libusb/libusb/os/haiku_usb_raw.h +0 -188
- package/libusb/libusb/os/linux_netlink.c +0 -401
- package/libusb/libusb/os/linux_udev.c +0 -321
- package/libusb/libusb/os/linux_usbfs.c +0 -2829
- package/libusb/libusb/os/linux_usbfs.h +0 -221
- package/libusb/libusb/os/netbsd_usb.c +0 -617
- package/libusb/libusb/os/null_usb.c +0 -111
- package/libusb/libusb/os/openbsd_usb.c +0 -700
- package/libusb/libusb/os/sunos_usb.c +0 -1619
- package/libusb/libusb/os/sunos_usb.h +0 -79
- package/libusb/libusb/os/threads_posix.c +0 -126
- package/libusb/libusb/os/threads_posix.h +0 -98
- package/libusb/libusb/os/threads_windows.c +0 -40
- package/libusb/libusb/os/threads_windows.h +0 -113
- package/libusb/libusb/os/windows_common.c +0 -923
- package/libusb/libusb/os/windows_common.h +0 -424
- package/libusb/libusb/os/windows_usbdk.c +0 -724
- package/libusb/libusb/os/windows_usbdk.h +0 -106
- package/libusb/libusb/os/windows_winusb.c +0 -4766
- package/libusb/libusb/os/windows_winusb.h +0 -787
- package/libusb/libusb/strerror.c +0 -223
- package/libusb/libusb/sync.c +0 -342
- package/libusb/libusb/version.h +0 -18
- package/libusb/libusb/version_nano.h +0 -1
- package/libusb/libusb-1.0.pc.in +0 -11
- package/libusb/msvc/Base.props +0 -60
- package/libusb/msvc/Configuration.Application.props +0 -7
- package/libusb/msvc/Configuration.Base.props +0 -47
- package/libusb/msvc/Configuration.DynamicLibrary.props +0 -21
- package/libusb/msvc/Configuration.StaticLibrary.props +0 -7
- package/libusb/msvc/ProjectConfigurations.Base.props +0 -69
- package/libusb/msvc/build_all.ps1 +0 -17
- package/libusb/msvc/config.h +0 -58
- package/libusb/msvc/dpfp.vcxproj +0 -33
- package/libusb/msvc/dpfp_threaded.vcxproj +0 -38
- package/libusb/msvc/fxload.vcxproj +0 -46
- package/libusb/msvc/getopt/getopt.c +0 -1060
- package/libusb/msvc/getopt/getopt.h +0 -180
- package/libusb/msvc/getopt/getopt1.c +0 -188
- package/libusb/msvc/getopt.vcxproj +0 -33
- package/libusb/msvc/hotplugtest.vcxproj +0 -32
- package/libusb/msvc/init_context.vcxproj +0 -35
- package/libusb/msvc/libusb.sln +0 -542
- package/libusb/msvc/libusb_dll.vcxproj +0 -61
- package/libusb/msvc/libusb_static.vcxproj +0 -49
- package/libusb/msvc/listdevs.vcxproj +0 -32
- package/libusb/msvc/sam3u_benchmark.vcxproj +0 -33
- package/libusb/msvc/set_option.vcxproj +0 -35
- package/libusb/msvc/stress.vcxproj +0 -35
- package/libusb/msvc/stress_mt.vcxproj +0 -33
- package/libusb/msvc/testlibusb.vcxproj +0 -32
- package/libusb/msvc/xusb.vcxproj +0 -38
- package/libusb/tests/Makefile.am +0 -40
- package/libusb/tests/init_context.c +0 -153
- package/libusb/tests/libusb_testlib.h +0 -76
- package/libusb/tests/macos.c +0 -130
- package/libusb/tests/set_option.c +0 -253
- package/libusb/tests/stress.c +0 -172
- package/libusb/tests/stress_mt.c +0 -267
- package/libusb/tests/testlib.c +0 -184
- package/libusb/tests/umockdev.c +0 -1175
- package/libusb/tests/webusb-test-shim/index.js +0 -12
- package/libusb/tests/webusb-test-shim/package-lock.json +0 -50
- package/libusb/tests/webusb-test-shim/package.json +0 -10
- package/libusb.gypi +0 -154
- package/libusb_config/config.h +0 -1
- 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-arm64/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 +0 -439
- package/src/helpers.h +0 -64
- package/src/hotplug/hotplug.h +0 -22
- package/src/hotplug/libusb.cc +0 -90
- package/src/hotplug/windows.cc +0 -168
- package/src/node_usb.cc +0 -314
- package/src/node_usb.h +0 -131
- package/src/thread_name.cc +0 -79
- package/src/thread_name.h +0 -11
- package/src/transfer.cc +0 -143
- package/src/uv_async_queue.h +0 -41
- package/test/usb.coffee +0 -250
- package/test/webusb.coffee +0 -227
- package/test/worker.cjs +0 -13
package/dist/usb/device.js
DELETED
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtendedDevice = void 0;
|
|
4
|
-
const usb = require("./bindings");
|
|
5
|
-
const interface_1 = require("./interface");
|
|
6
|
-
const capability_1 = require("./capability");
|
|
7
|
-
const isBuffer = (obj) => !!obj && obj instanceof Uint8Array;
|
|
8
|
-
const DEFAULT_TIMEOUT = 1000;
|
|
9
|
-
class ExtendedDevice {
|
|
10
|
-
constructor() {
|
|
11
|
-
this._timeout = DEFAULT_TIMEOUT;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Timeout in milliseconds to use for control transfers.
|
|
15
|
-
*/
|
|
16
|
-
get timeout() {
|
|
17
|
-
return this._timeout || DEFAULT_TIMEOUT;
|
|
18
|
-
}
|
|
19
|
-
set timeout(value) {
|
|
20
|
-
this._timeout = value;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Object with properties for the fields of the active configuration descriptor.
|
|
24
|
-
*/
|
|
25
|
-
get configDescriptor() {
|
|
26
|
-
try {
|
|
27
|
-
return this.__getConfigDescriptor();
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
// Check descriptor exists
|
|
31
|
-
const errno = e.errno;
|
|
32
|
-
if (errno === usb.LIBUSB_ERROR_NOT_FOUND ||
|
|
33
|
-
errno === usb.LIBUSB_ERROR_NO_DEVICE) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
throw e;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Contains all config descriptors of the device (same structure as .configDescriptor above)
|
|
41
|
-
*/
|
|
42
|
-
get allConfigDescriptors() {
|
|
43
|
-
try {
|
|
44
|
-
return this.__getAllConfigDescriptors();
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
// Check descriptors exist
|
|
48
|
-
const errno = e.errno;
|
|
49
|
-
if (errno === usb.LIBUSB_ERROR_NOT_FOUND ||
|
|
50
|
-
errno === usb.LIBUSB_ERROR_NO_DEVICE) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
throw e;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Contains the parent of the device, such as a hub. If there is no parent this property is set to `null`.
|
|
58
|
-
*/
|
|
59
|
-
get parent() {
|
|
60
|
-
return this.__getParent();
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Open the device.
|
|
64
|
-
* @param defaultConfig
|
|
65
|
-
*/
|
|
66
|
-
open(defaultConfig = true) {
|
|
67
|
-
this.__open();
|
|
68
|
-
// The presence of interfaces is used to determine if the device is open
|
|
69
|
-
this.interfaces = [];
|
|
70
|
-
if (defaultConfig === false) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const len = this.configDescriptor ? this.configDescriptor.interfaces.length : 0;
|
|
74
|
-
for (let i = 0; i < len; i++) {
|
|
75
|
-
this.interfaces[i] = new interface_1.Interface(this, i);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Close the device.
|
|
80
|
-
*
|
|
81
|
-
* The device must be open to use this method.
|
|
82
|
-
*/
|
|
83
|
-
close() {
|
|
84
|
-
this.__close();
|
|
85
|
-
this.interfaces = undefined;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Set the device configuration to something other than the default (0). To use this, first call `.open(false)` (which tells it not to auto configure),
|
|
89
|
-
* then before claiming an interface, call this method.
|
|
90
|
-
*
|
|
91
|
-
* The device must be open to use this method.
|
|
92
|
-
* @param desired
|
|
93
|
-
* @param callback
|
|
94
|
-
*/
|
|
95
|
-
setConfiguration(desired, callback) {
|
|
96
|
-
this.__setConfiguration(desired, error => {
|
|
97
|
-
if (!error) {
|
|
98
|
-
this.interfaces = [];
|
|
99
|
-
const len = this.configDescriptor ? this.configDescriptor.interfaces.length : 0;
|
|
100
|
-
for (let i = 0; i < len; i++) {
|
|
101
|
-
this.interfaces[i] = new interface_1.Interface(this, i);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (callback) {
|
|
105
|
-
callback.call(this, error);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Enable/disable libusb's automatic kernel driver detachment
|
|
111
|
-
* When this is enabled libusb will automatically detach the kernel driver on an interface when claiming the interface, and attach it when releasing the interface
|
|
112
|
-
*
|
|
113
|
-
* The device must be open to use this method.
|
|
114
|
-
*/
|
|
115
|
-
setAutoDetachKernelDriver(enable) {
|
|
116
|
-
return this.__setAutoDetachKernelDriver(enable ? 1 : 0);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Perform a control transfer with `libusb_control_transfer`.
|
|
120
|
-
*
|
|
121
|
-
* Parameter `data_or_length` can be an integer length for an IN transfer, or a `Buffer` for an OUT transfer. The type must match the direction specified in the MSB of bmRequestType.
|
|
122
|
-
*
|
|
123
|
-
* The `data` parameter of the callback is actual transferred for OUT transfers, or will be passed a Buffer for IN transfers.
|
|
124
|
-
*
|
|
125
|
-
* The device must be open to use this method.
|
|
126
|
-
* @param bmRequestType
|
|
127
|
-
* @param bRequest
|
|
128
|
-
* @param wValue
|
|
129
|
-
* @param wIndex
|
|
130
|
-
* @param data_or_length
|
|
131
|
-
* @param callback
|
|
132
|
-
*/
|
|
133
|
-
controlTransfer(bmRequestType, bRequest, wValue, wIndex, data_or_length, callback) {
|
|
134
|
-
const isIn = !!(bmRequestType & usb.LIBUSB_ENDPOINT_IN);
|
|
135
|
-
const wLength = isIn ? data_or_length : data_or_length.length;
|
|
136
|
-
if (isIn) {
|
|
137
|
-
if (wLength < 0) {
|
|
138
|
-
throw new TypeError('Expected size number for IN transfer (based on bmRequestType)');
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
if (!isBuffer(data_or_length)) {
|
|
143
|
-
throw new TypeError('Expected buffer for OUT transfer (based on bmRequestType)');
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
// Buffer for the setup packet
|
|
147
|
-
// http://libusbx.sourceforge.net/api-1.0/structlibusb__control__setup.html
|
|
148
|
-
const buf = Buffer.alloc(wLength + usb.LIBUSB_CONTROL_SETUP_SIZE);
|
|
149
|
-
buf.writeUInt8(bmRequestType, 0);
|
|
150
|
-
buf.writeUInt8(bRequest, 1);
|
|
151
|
-
buf.writeUInt16LE(wValue, 2);
|
|
152
|
-
buf.writeUInt16LE(wIndex, 4);
|
|
153
|
-
buf.writeUInt16LE(wLength, 6);
|
|
154
|
-
if (!isIn) {
|
|
155
|
-
buf.set(data_or_length, usb.LIBUSB_CONTROL_SETUP_SIZE);
|
|
156
|
-
}
|
|
157
|
-
const transfer = new usb.Transfer(this, 0, usb.LIBUSB_TRANSFER_TYPE_CONTROL, this.timeout, (error, buf, actual) => {
|
|
158
|
-
if (callback) {
|
|
159
|
-
if (isIn) {
|
|
160
|
-
callback.call(this, error, buf.slice(usb.LIBUSB_CONTROL_SETUP_SIZE, usb.LIBUSB_CONTROL_SETUP_SIZE + actual));
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
callback.call(this, error, actual);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
try {
|
|
168
|
-
transfer.submit(buf);
|
|
169
|
-
}
|
|
170
|
-
catch (e) {
|
|
171
|
-
if (callback) {
|
|
172
|
-
process.nextTick(() => callback.call(this, e, undefined));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return this;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Return the interface with the specified interface number.
|
|
179
|
-
*
|
|
180
|
-
* The device must be open to use this method.
|
|
181
|
-
* @param addr
|
|
182
|
-
*/
|
|
183
|
-
interface(addr) {
|
|
184
|
-
if (!this.interfaces) {
|
|
185
|
-
throw new Error('Device must be open before searching for interfaces');
|
|
186
|
-
}
|
|
187
|
-
addr = addr || 0;
|
|
188
|
-
for (let i = 0; i < this.interfaces.length; i++) {
|
|
189
|
-
if (this.interfaces[i].interfaceNumber === addr) {
|
|
190
|
-
return this.interfaces[i];
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
throw new Error(`Interface not found for address: ${addr}`);
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Perform a control transfer to retrieve a string descriptor
|
|
197
|
-
*
|
|
198
|
-
* The device must be open to use this method.
|
|
199
|
-
* @param desc_index
|
|
200
|
-
* @param callback
|
|
201
|
-
*/
|
|
202
|
-
getStringDescriptor(desc_index, callback) {
|
|
203
|
-
// Index 0 indicates null
|
|
204
|
-
if (desc_index === 0) {
|
|
205
|
-
callback();
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
const langid = 0x0409;
|
|
209
|
-
const length = 255;
|
|
210
|
-
this.controlTransfer(usb.LIBUSB_ENDPOINT_IN, usb.LIBUSB_REQUEST_GET_DESCRIPTOR, ((usb.LIBUSB_DT_STRING << 8) | desc_index), langid, length, (error, buffer) => {
|
|
211
|
-
if (error) {
|
|
212
|
-
return callback(error);
|
|
213
|
-
}
|
|
214
|
-
callback(undefined, isBuffer(buffer) ? buffer.toString('utf16le', 2) : undefined);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Perform a control transfer to retrieve an object with properties for the fields of the Binary Object Store descriptor.
|
|
219
|
-
*
|
|
220
|
-
* The device must be open to use this method.
|
|
221
|
-
* @param callback
|
|
222
|
-
*/
|
|
223
|
-
getBosDescriptor(callback) {
|
|
224
|
-
if (this._bosDescriptor) {
|
|
225
|
-
// Cached descriptor
|
|
226
|
-
return callback(undefined, this._bosDescriptor);
|
|
227
|
-
}
|
|
228
|
-
if (this.deviceDescriptor.bcdUSB < 0x201) {
|
|
229
|
-
// BOS is only supported from USB 2.0.1
|
|
230
|
-
return callback(undefined, undefined);
|
|
231
|
-
}
|
|
232
|
-
this.controlTransfer(usb.LIBUSB_ENDPOINT_IN, usb.LIBUSB_REQUEST_GET_DESCRIPTOR, (usb.LIBUSB_DT_BOS << 8), 0, usb.LIBUSB_DT_BOS_SIZE, (error, buffer) => {
|
|
233
|
-
if (error) {
|
|
234
|
-
// Check BOS descriptor exists
|
|
235
|
-
if (error.errno === usb.LIBUSB_TRANSFER_STALL)
|
|
236
|
-
return callback(undefined, undefined);
|
|
237
|
-
return callback(error, undefined);
|
|
238
|
-
}
|
|
239
|
-
if (!isBuffer(buffer)) {
|
|
240
|
-
return callback(undefined, undefined);
|
|
241
|
-
}
|
|
242
|
-
const totalLength = buffer.readUInt16LE(2);
|
|
243
|
-
this.controlTransfer(usb.LIBUSB_ENDPOINT_IN, usb.LIBUSB_REQUEST_GET_DESCRIPTOR, (usb.LIBUSB_DT_BOS << 8), 0, totalLength, (error, buffer) => {
|
|
244
|
-
if (error) {
|
|
245
|
-
// Check BOS descriptor exists
|
|
246
|
-
if (error.errno === usb.LIBUSB_TRANSFER_STALL)
|
|
247
|
-
return callback(undefined, undefined);
|
|
248
|
-
return callback(error, undefined);
|
|
249
|
-
}
|
|
250
|
-
if (!isBuffer(buffer)) {
|
|
251
|
-
return callback(undefined, undefined);
|
|
252
|
-
}
|
|
253
|
-
const descriptor = {
|
|
254
|
-
bLength: buffer.readUInt8(0),
|
|
255
|
-
bDescriptorType: buffer.readUInt8(1),
|
|
256
|
-
wTotalLength: buffer.readUInt16LE(2),
|
|
257
|
-
bNumDeviceCaps: buffer.readUInt8(4),
|
|
258
|
-
capabilities: []
|
|
259
|
-
};
|
|
260
|
-
let i = usb.LIBUSB_DT_BOS_SIZE;
|
|
261
|
-
while (i < descriptor.wTotalLength) {
|
|
262
|
-
const capability = {
|
|
263
|
-
bLength: buffer.readUInt8(i + 0),
|
|
264
|
-
bDescriptorType: buffer.readUInt8(i + 1),
|
|
265
|
-
bDevCapabilityType: buffer.readUInt8(i + 2),
|
|
266
|
-
dev_capability_data: buffer.slice(i + 3, i + buffer.readUInt8(i + 0))
|
|
267
|
-
};
|
|
268
|
-
descriptor.capabilities.push(capability);
|
|
269
|
-
i += capability.bLength;
|
|
270
|
-
}
|
|
271
|
-
// Cache descriptor
|
|
272
|
-
this._bosDescriptor = descriptor;
|
|
273
|
-
callback(undefined, this._bosDescriptor);
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Retrieve a list of Capability objects for the Binary Object Store capabilities of the device.
|
|
279
|
-
*
|
|
280
|
-
* The device must be open to use this method.
|
|
281
|
-
* @param callback
|
|
282
|
-
*/
|
|
283
|
-
getCapabilities(callback) {
|
|
284
|
-
const capabilities = [];
|
|
285
|
-
this.getBosDescriptor((error, descriptor) => {
|
|
286
|
-
if (error)
|
|
287
|
-
return callback(error, undefined);
|
|
288
|
-
const len = descriptor ? descriptor.capabilities.length : 0;
|
|
289
|
-
for (let i = 0; i < len; i++) {
|
|
290
|
-
capabilities.push(new capability_1.Capability(this, i));
|
|
291
|
-
}
|
|
292
|
-
callback(undefined, capabilities);
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
exports.ExtendedDevice = ExtendedDevice;
|
|
297
|
-
//# sourceMappingURL=device.js.map
|
package/dist/usb/device.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../tsc/usb/device.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,2CAAwC;AACxC,6CAA0C;AAG1C,MAAM,QAAQ,GAAG,CAAC,GAAoC,EAAqB,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,YAAY,UAAU,CAAC;AACjH,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,MAAa,cAAc;IAA3B;QAMY,aAAQ,GAAG,eAAe,CAAC;IAgVvC,CAAC;IA/UG;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,IAAI,eAAe,CAAC;IAC5C,CAAC;IACD,IAAW,OAAO,CAAC,KAAa;QAC5B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAW,gBAAgB;QACvB,IAAI,CAAC;YACD,OAAQ,IAA8B,CAAC,qBAAq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CAAC,CAAC,CAAC,CAAC;YAC/C,CAAC;YAED,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAtVD,wCAsVC"}
|
package/dist/usb/endpoint.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { LibUSBException, Transfer, Device } from './bindings';
|
|
3
|
-
import { EndpointDescriptor } from './descriptors';
|
|
4
|
-
/** Common base for InEndpoint and OutEndpoint. */
|
|
5
|
-
export declare abstract class Endpoint extends EventEmitter {
|
|
6
|
-
protected device: Device;
|
|
7
|
-
address: number;
|
|
8
|
-
/** Endpoint direction: `"in"` or `"out"`. */
|
|
9
|
-
abstract direction: 'in' | 'out';
|
|
10
|
-
/** Endpoint type: `usb.LIBUSB_TRANSFER_TYPE_BULK`, `usb.LIBUSB_TRANSFER_TYPE_INTERRUPT`, or `usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS`. */
|
|
11
|
-
transferType: number;
|
|
12
|
-
/** Sets the timeout in milliseconds for transfers on this endpoint. The default, `0`, is infinite timeout. */
|
|
13
|
-
timeout: number;
|
|
14
|
-
/** Object with fields from the endpoint descriptor -- see libusb documentation or USB spec. */
|
|
15
|
-
descriptor: EndpointDescriptor;
|
|
16
|
-
constructor(device: Device, descriptor: EndpointDescriptor);
|
|
17
|
-
/** Clear the halt/stall condition for this endpoint. */
|
|
18
|
-
clearHalt(callback: (error: LibUSBException | undefined) => void): void;
|
|
19
|
-
/**
|
|
20
|
-
* Create a new `Transfer` object for this endpoint.
|
|
21
|
-
*
|
|
22
|
-
* The passed callback will be called when the transfer is submitted and finishes. Its arguments are the error (if any), the submitted buffer, and the amount of data actually written (for
|
|
23
|
-
* OUT transfers) or read (for IN transfers).
|
|
24
|
-
*
|
|
25
|
-
* @param timeout Timeout for the transfer (0 means unlimited).
|
|
26
|
-
* @param callback Transfer completion callback.
|
|
27
|
-
*/
|
|
28
|
-
makeTransfer(timeout: number, callback: (error: LibUSBException | undefined, buffer: Buffer, actualLength: number) => void): Transfer;
|
|
29
|
-
}
|
|
30
|
-
/** Endpoints in the IN direction (device->PC) have this type. */
|
|
31
|
-
export declare class InEndpoint extends Endpoint {
|
|
32
|
-
/** Endpoint direction. */
|
|
33
|
-
direction: 'in' | 'out';
|
|
34
|
-
protected pollTransfers: Transfer[];
|
|
35
|
-
protected pollTransferSize: number;
|
|
36
|
-
protected pollPending: number;
|
|
37
|
-
pollActive: boolean;
|
|
38
|
-
transferAsync: (length: number) => Promise<Buffer | undefined>;
|
|
39
|
-
constructor(device: Device, descriptor: EndpointDescriptor);
|
|
40
|
-
/**
|
|
41
|
-
* Perform a transfer to read data from the endpoint.
|
|
42
|
-
*
|
|
43
|
-
* If length is greater than maxPacketSize, libusb will automatically split the transfer in multiple packets, and you will receive one callback with all data once all packets are complete.
|
|
44
|
-
*
|
|
45
|
-
* `this` in the callback is the InEndpoint object.
|
|
46
|
-
*
|
|
47
|
-
* The device must be open to use this method.
|
|
48
|
-
* @param length
|
|
49
|
-
* @param callback
|
|
50
|
-
*/
|
|
51
|
-
transfer(length: number, callback: (error: LibUSBException | undefined, data?: Buffer) => void): InEndpoint;
|
|
52
|
-
/**
|
|
53
|
-
* Start polling the endpoint.
|
|
54
|
-
*
|
|
55
|
-
* The library will keep `nTransfers` transfers of size `transferSize` pending in the kernel at all times to ensure continuous data flow.
|
|
56
|
-
* This is handled by the libusb event thread, so it continues even if the Node v8 thread is busy. The `data` and `error` events are emitted as transfers complete.
|
|
57
|
-
*
|
|
58
|
-
* The device must be open to use this method.
|
|
59
|
-
* @param nTransfers
|
|
60
|
-
* @param transferSize
|
|
61
|
-
* @param callback
|
|
62
|
-
*/
|
|
63
|
-
startPoll(nTransfers?: number, transferSize?: number, callback?: (error: LibUSBException | undefined, buffer: Buffer, actualLength: number, cancelled: boolean) => void): Transfer[];
|
|
64
|
-
protected startPollTransfers(nTransfers: number | undefined, transferSize: number | undefined, callback: (error: LibUSBException | undefined, buffer: Buffer, actualLength: number) => void): Transfer[];
|
|
65
|
-
/**
|
|
66
|
-
* Stop polling.
|
|
67
|
-
*
|
|
68
|
-
* Further data may still be received. The `end` event is emitted and the callback is called once all transfers have completed or canceled.
|
|
69
|
-
*
|
|
70
|
-
* The device must be open to use this method.
|
|
71
|
-
* @param callback
|
|
72
|
-
*/
|
|
73
|
-
stopPoll(callback?: () => void): void;
|
|
74
|
-
}
|
|
75
|
-
/** Endpoints in the OUT direction (PC->device) have this type. */
|
|
76
|
-
export declare class OutEndpoint extends Endpoint {
|
|
77
|
-
/** Endpoint direction. */
|
|
78
|
-
direction: 'in' | 'out';
|
|
79
|
-
transferAsync: (buffer: Buffer) => Promise<number>;
|
|
80
|
-
constructor(device: Device, descriptor: EndpointDescriptor);
|
|
81
|
-
/**
|
|
82
|
-
* Perform a transfer to write `data` to the endpoint.
|
|
83
|
-
*
|
|
84
|
-
* If length is greater than maxPacketSize, libusb will automatically split the transfer in multiple packets, and you will receive one callback once all packets are complete.
|
|
85
|
-
*
|
|
86
|
-
* `this` in the callback is the OutEndpoint object.
|
|
87
|
-
*
|
|
88
|
-
* The device must be open to use this method.
|
|
89
|
-
* @param buffer
|
|
90
|
-
* @param callback
|
|
91
|
-
*/
|
|
92
|
-
transfer(buffer: Buffer, callback?: (error: LibUSBException | undefined, actual: number) => void): OutEndpoint;
|
|
93
|
-
transferWithZLP(buffer: Buffer, callback: (error: LibUSBException | undefined) => void): void;
|
|
94
|
-
}
|
package/dist/usb/endpoint.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OutEndpoint = exports.InEndpoint = exports.Endpoint = void 0;
|
|
4
|
-
const events_1 = require("events");
|
|
5
|
-
const bindings_1 = require("./bindings");
|
|
6
|
-
const util_1 = require("util");
|
|
7
|
-
const isBuffer = (obj) => obj && obj instanceof Buffer;
|
|
8
|
-
/** Common base for InEndpoint and OutEndpoint. */
|
|
9
|
-
class Endpoint extends events_1.EventEmitter {
|
|
10
|
-
constructor(device, descriptor) {
|
|
11
|
-
super();
|
|
12
|
-
this.device = device;
|
|
13
|
-
/** Sets the timeout in milliseconds for transfers on this endpoint. The default, `0`, is infinite timeout. */
|
|
14
|
-
this.timeout = 0;
|
|
15
|
-
this.descriptor = descriptor;
|
|
16
|
-
this.address = descriptor.bEndpointAddress;
|
|
17
|
-
this.transferType = descriptor.bmAttributes & 0x03;
|
|
18
|
-
}
|
|
19
|
-
/** Clear the halt/stall condition for this endpoint. */
|
|
20
|
-
clearHalt(callback) {
|
|
21
|
-
return this.device.__clearHalt(this.address, callback);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Create a new `Transfer` object for this endpoint.
|
|
25
|
-
*
|
|
26
|
-
* The passed callback will be called when the transfer is submitted and finishes. Its arguments are the error (if any), the submitted buffer, and the amount of data actually written (for
|
|
27
|
-
* OUT transfers) or read (for IN transfers).
|
|
28
|
-
*
|
|
29
|
-
* @param timeout Timeout for the transfer (0 means unlimited).
|
|
30
|
-
* @param callback Transfer completion callback.
|
|
31
|
-
*/
|
|
32
|
-
makeTransfer(timeout, callback) {
|
|
33
|
-
return new bindings_1.Transfer(this.device, this.address, this.transferType, timeout, callback);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.Endpoint = Endpoint;
|
|
37
|
-
/** Endpoints in the IN direction (device->PC) have this type. */
|
|
38
|
-
class InEndpoint extends Endpoint {
|
|
39
|
-
constructor(device, descriptor) {
|
|
40
|
-
super(device, descriptor);
|
|
41
|
-
/** Endpoint direction. */
|
|
42
|
-
this.direction = 'in';
|
|
43
|
-
this.pollTransfers = [];
|
|
44
|
-
this.pollTransferSize = 0;
|
|
45
|
-
this.pollPending = 0;
|
|
46
|
-
this.pollActive = false;
|
|
47
|
-
this.transferAsync = (0, util_1.promisify)(this.transfer).bind(this);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Perform a transfer to read data from the endpoint.
|
|
51
|
-
*
|
|
52
|
-
* If length is greater than maxPacketSize, libusb will automatically split the transfer in multiple packets, and you will receive one callback with all data once all packets are complete.
|
|
53
|
-
*
|
|
54
|
-
* `this` in the callback is the InEndpoint object.
|
|
55
|
-
*
|
|
56
|
-
* The device must be open to use this method.
|
|
57
|
-
* @param length
|
|
58
|
-
* @param callback
|
|
59
|
-
*/
|
|
60
|
-
transfer(length, callback) {
|
|
61
|
-
const buffer = Buffer.alloc(length);
|
|
62
|
-
const cb = (error, _buffer, actualLength) => {
|
|
63
|
-
callback.call(this, error, buffer.slice(0, actualLength));
|
|
64
|
-
};
|
|
65
|
-
try {
|
|
66
|
-
this.makeTransfer(this.timeout, cb).submit(buffer);
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
process.nextTick(() => callback.call(this, e));
|
|
70
|
-
}
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Start polling the endpoint.
|
|
75
|
-
*
|
|
76
|
-
* The library will keep `nTransfers` transfers of size `transferSize` pending in the kernel at all times to ensure continuous data flow.
|
|
77
|
-
* This is handled by the libusb event thread, so it continues even if the Node v8 thread is busy. The `data` and `error` events are emitted as transfers complete.
|
|
78
|
-
*
|
|
79
|
-
* The device must be open to use this method.
|
|
80
|
-
* @param nTransfers
|
|
81
|
-
* @param transferSize
|
|
82
|
-
* @param callback
|
|
83
|
-
*/
|
|
84
|
-
startPoll(nTransfers, transferSize, callback) {
|
|
85
|
-
const transferDone = (error, transfer, buffer, actualLength) => {
|
|
86
|
-
if (!error) {
|
|
87
|
-
this.emit('data', buffer.slice(0, actualLength));
|
|
88
|
-
}
|
|
89
|
-
else if (error.errno !== bindings_1.LIBUSB_TRANSFER_CANCELLED) {
|
|
90
|
-
if (this.pollActive) {
|
|
91
|
-
this.emit('error', error);
|
|
92
|
-
this.stopPoll();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (this.pollActive) {
|
|
96
|
-
startTransfer(transfer);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
this.pollPending--;
|
|
100
|
-
if (this.pollPending === 0) {
|
|
101
|
-
this.pollTransfers = [];
|
|
102
|
-
this.pollActive = false;
|
|
103
|
-
this.emit('end');
|
|
104
|
-
if (callback) {
|
|
105
|
-
const cancelled = (error === null || error === void 0 ? void 0 : error.errno) === bindings_1.LIBUSB_TRANSFER_CANCELLED;
|
|
106
|
-
callback(cancelled ? undefined : error, buffer, actualLength, cancelled);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const startTransfer = (transfer) => {
|
|
112
|
-
try {
|
|
113
|
-
transfer.submit(Buffer.alloc(this.pollTransferSize), (error, buffer, actualLength) => {
|
|
114
|
-
transferDone(error, transfer, buffer, actualLength);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
this.emit('error', e);
|
|
119
|
-
this.stopPoll();
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
this.pollTransfers = this.startPollTransfers(nTransfers, transferSize, function (error, buffer, actualLength) {
|
|
123
|
-
transferDone(error, this, buffer, actualLength);
|
|
124
|
-
});
|
|
125
|
-
this.pollTransfers.forEach(startTransfer);
|
|
126
|
-
this.pollPending = this.pollTransfers.length;
|
|
127
|
-
return this.pollTransfers;
|
|
128
|
-
}
|
|
129
|
-
startPollTransfers(nTransfers = 3, transferSize = this.descriptor.wMaxPacketSize, callback) {
|
|
130
|
-
if (this.pollActive) {
|
|
131
|
-
throw new Error('Polling already active');
|
|
132
|
-
}
|
|
133
|
-
this.pollTransferSize = transferSize;
|
|
134
|
-
this.pollActive = true;
|
|
135
|
-
this.pollPending = 0;
|
|
136
|
-
const transfers = [];
|
|
137
|
-
for (let i = 0; i < nTransfers; i++) {
|
|
138
|
-
const transfer = this.makeTransfer(0, callback);
|
|
139
|
-
transfers[i] = transfer;
|
|
140
|
-
}
|
|
141
|
-
return transfers;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Stop polling.
|
|
145
|
-
*
|
|
146
|
-
* Further data may still be received. The `end` event is emitted and the callback is called once all transfers have completed or canceled.
|
|
147
|
-
*
|
|
148
|
-
* The device must be open to use this method.
|
|
149
|
-
* @param callback
|
|
150
|
-
*/
|
|
151
|
-
stopPoll(callback) {
|
|
152
|
-
if (!this.pollActive) {
|
|
153
|
-
throw new Error('Polling is not active.');
|
|
154
|
-
}
|
|
155
|
-
for (let i = 0; i < this.pollTransfers.length; i++) {
|
|
156
|
-
try {
|
|
157
|
-
this.pollTransfers[i].cancel();
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
this.emit('error', error);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
this.pollActive = false;
|
|
164
|
-
if (callback)
|
|
165
|
-
this.once('end', callback);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
exports.InEndpoint = InEndpoint;
|
|
169
|
-
/** Endpoints in the OUT direction (PC->device) have this type. */
|
|
170
|
-
class OutEndpoint extends Endpoint {
|
|
171
|
-
constructor(device, descriptor) {
|
|
172
|
-
super(device, descriptor);
|
|
173
|
-
/** Endpoint direction. */
|
|
174
|
-
this.direction = 'out';
|
|
175
|
-
this.transferAsync = (0, util_1.promisify)(this.transfer).bind(this);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Perform a transfer to write `data` to the endpoint.
|
|
179
|
-
*
|
|
180
|
-
* If length is greater than maxPacketSize, libusb will automatically split the transfer in multiple packets, and you will receive one callback once all packets are complete.
|
|
181
|
-
*
|
|
182
|
-
* `this` in the callback is the OutEndpoint object.
|
|
183
|
-
*
|
|
184
|
-
* The device must be open to use this method.
|
|
185
|
-
* @param buffer
|
|
186
|
-
* @param callback
|
|
187
|
-
*/
|
|
188
|
-
transfer(buffer, callback) {
|
|
189
|
-
if (!buffer) {
|
|
190
|
-
buffer = Buffer.alloc(0);
|
|
191
|
-
}
|
|
192
|
-
else if (!isBuffer(buffer)) {
|
|
193
|
-
buffer = Buffer.from(buffer);
|
|
194
|
-
}
|
|
195
|
-
const cb = (error, _buffer, actual) => {
|
|
196
|
-
if (callback) {
|
|
197
|
-
callback.call(this, error, actual || 0);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
try {
|
|
201
|
-
this.makeTransfer(this.timeout, cb).submit(buffer);
|
|
202
|
-
}
|
|
203
|
-
catch (e) {
|
|
204
|
-
process.nextTick(() => cb(e));
|
|
205
|
-
}
|
|
206
|
-
return this;
|
|
207
|
-
}
|
|
208
|
-
transferWithZLP(buffer, callback) {
|
|
209
|
-
if (buffer.length % this.descriptor.wMaxPacketSize === 0) {
|
|
210
|
-
this.transfer(buffer);
|
|
211
|
-
this.transfer(Buffer.alloc(0), callback);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
this.transfer(buffer, callback);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
exports.OutEndpoint = OutEndpoint;
|
|
219
|
-
//# sourceMappingURL=endpoint.js.map
|
package/dist/usb/endpoint.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../tsc/usb/endpoint.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AACtC,yCAA0F;AAE1F,+BAAiC;AAEjC,MAAM,QAAQ,GAAG,CAAC,GAAyB,EAAiB,EAAE,CAAC,GAAG,IAAI,GAAG,YAAY,MAAM,CAAC;AAE5F,kDAAkD;AAClD,MAAsB,QAAS,SAAQ,qBAAY;IAe/C,YAAsB,MAAc,EAAE,UAA8B;QAChE,KAAK,EAAE,CAAC;QADU,WAAM,GAAN,MAAM,CAAQ;QANpC,8GAA8G;QACvG,YAAO,GAAG,CAAC,CAAC;QAOf,IAAI,CAAC,UAAU,GAAG,UAAU,CA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QAAQ,CAAC,MAAM,CAAC,CAAC;YACtB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACpC,CAAC;IACL,CAAC;CACJ;AArDD,kCAqDC"}
|
package/dist/usb/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ExtendedDevice } from './device';
|
|
2
|
-
import * as usb from './bindings';
|
|
3
|
-
interface EventListeners<T> {
|
|
4
|
-
newListener: keyof T;
|
|
5
|
-
removeListener: keyof T;
|
|
6
|
-
}
|
|
7
|
-
interface DeviceIds {
|
|
8
|
-
idVendor: number;
|
|
9
|
-
idProduct: number;
|
|
10
|
-
}
|
|
11
|
-
declare module './bindings' {
|
|
12
|
-
interface Device extends ExtendedDevice {
|
|
13
|
-
}
|
|
14
|
-
interface DeviceEvents extends EventListeners<DeviceEvents> {
|
|
15
|
-
attach: Device;
|
|
16
|
-
detach: Device;
|
|
17
|
-
attachIds: DeviceIds;
|
|
18
|
-
detachIds: DeviceIds;
|
|
19
|
-
}
|
|
20
|
-
function addListener<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
21
|
-
function removeListener<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
22
|
-
function on<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
23
|
-
function off<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
24
|
-
function once<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
25
|
-
function listeners<K extends keyof DeviceEvents>(event: K): ((arg: DeviceEvents[K]) => void)[];
|
|
26
|
-
function rawListeners<K extends keyof DeviceEvents>(event: K): ((arg: DeviceEvents[K]) => void)[];
|
|
27
|
-
function removeAllListeners<K extends keyof DeviceEvents>(event?: K): void;
|
|
28
|
-
function emit<K extends keyof DeviceEvents>(event: K, arg: DeviceEvents[K]): boolean;
|
|
29
|
-
function listenerCount<K extends keyof DeviceEvents>(event: K): number;
|
|
30
|
-
}
|
|
31
|
-
export = usb;
|