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.
Files changed (207) hide show
  1. package/LICENSE +18 -4
  2. package/README.md +25 -516
  3. package/dist/index.d.ts +67 -13
  4. package/dist/index.js +333 -64
  5. package/index.d.ts +89 -0
  6. package/index.js +583 -0
  7. package/package.json +53 -33
  8. package/CHANGELOG.md +0 -294
  9. package/binding.gyp +0 -128
  10. package/dist/index.js.map +0 -1
  11. package/dist/usb/bindings.d.ts +0 -266
  12. package/dist/usb/bindings.js +0 -10
  13. package/dist/usb/bindings.js.map +0 -1
  14. package/dist/usb/capability.d.ts +0 -13
  15. package/dist/usb/capability.js +0 -17
  16. package/dist/usb/capability.js.map +0 -1
  17. package/dist/usb/descriptors.d.ts +0 -128
  18. package/dist/usb/descriptors.js +0 -3
  19. package/dist/usb/descriptors.js.map +0 -1
  20. package/dist/usb/device.d.ts +0 -100
  21. package/dist/usb/device.js +0 -297
  22. package/dist/usb/device.js.map +0 -1
  23. package/dist/usb/endpoint.d.ts +0 -94
  24. package/dist/usb/endpoint.js +0 -219
  25. package/dist/usb/endpoint.js.map +0 -1
  26. package/dist/usb/index.d.ts +0 -31
  27. package/dist/usb/index.js +0 -116
  28. package/dist/usb/index.js.map +0 -1
  29. package/dist/usb/interface.d.ts +0 -80
  30. package/dist/usb/interface.js +0 -133
  31. package/dist/usb/interface.js.map +0 -1
  32. package/dist/webusb/index.d.ts +0 -64
  33. package/dist/webusb/index.js +0 -295
  34. package/dist/webusb/index.js.map +0 -1
  35. package/dist/webusb/webusb-device.d.ts +0 -54
  36. package/dist/webusb/webusb-device.js +0 -434
  37. package/dist/webusb/webusb-device.js.map +0 -1
  38. package/libusb/.clang-tidy +0 -34
  39. package/libusb/.codespellrc +0 -3
  40. package/libusb/.private/README.txt +0 -5
  41. package/libusb/.private/appveyor_build.sh +0 -26
  42. package/libusb/.private/bm.sh +0 -54
  43. package/libusb/.private/ci-build.sh +0 -92
  44. package/libusb/.private/ci-container-build.sh +0 -67
  45. package/libusb/.private/post-rewrite.sh +0 -32
  46. package/libusb/.private/pre-commit.sh +0 -52
  47. package/libusb/.private/wbs.txt +0 -43
  48. package/libusb/.travis.yml +0 -58
  49. package/libusb/AUTHORS +0 -231
  50. package/libusb/COPYING +0 -504
  51. package/libusb/ChangeLog +0 -365
  52. package/libusb/HACKING +0 -25
  53. package/libusb/INSTALL_WIN.txt +0 -52
  54. package/libusb/KEYS +0 -123
  55. package/libusb/Makefile.am +0 -50
  56. package/libusb/NEWS +0 -2
  57. package/libusb/PORTING +0 -94
  58. package/libusb/README +0 -29
  59. package/libusb/README.git +0 -41
  60. package/libusb/TODO +0 -2
  61. package/libusb/Xcode/common.xcconfig +0 -92
  62. package/libusb/Xcode/config.h +0 -31
  63. package/libusb/Xcode/debug.xcconfig +0 -32
  64. package/libusb/Xcode/libusb.xcconfig +0 -21
  65. package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +0 -1391
  66. package/libusb/Xcode/libusb_debug.xcconfig +0 -21
  67. package/libusb/Xcode/libusb_release.xcconfig +0 -21
  68. package/libusb/Xcode/release.xcconfig +0 -30
  69. package/libusb/android/README +0 -152
  70. package/libusb/android/config.h +0 -55
  71. package/libusb/android/examples/unrooted_android.c +0 -301
  72. package/libusb/android/examples/unrooted_android.h +0 -36
  73. package/libusb/android/jni/Android.mk +0 -23
  74. package/libusb/android/jni/Application.mk +0 -40
  75. package/libusb/android/jni/examples.mk +0 -168
  76. package/libusb/android/jni/libusb.mk +0 -60
  77. package/libusb/android/jni/tests.mk +0 -45
  78. package/libusb/appveyor.yml +0 -108
  79. package/libusb/autogen.sh +0 -10
  80. package/libusb/bootstrap.sh +0 -10
  81. package/libusb/configure.ac +0 -450
  82. package/libusb/doc/Makefile.in +0 -22
  83. package/libusb/doc/doxygen.cfg.in +0 -2571
  84. package/libusb/doc/libusb.png +0 -0
  85. package/libusb/examples/Makefile.am +0 -12
  86. package/libusb/examples/dpfp.c +0 -711
  87. package/libusb/examples/ezusb.c +0 -846
  88. package/libusb/examples/ezusb.h +0 -109
  89. package/libusb/examples/fxload.c +0 -310
  90. package/libusb/examples/hotplugtest.c +0 -147
  91. package/libusb/examples/listdevs.c +0 -73
  92. package/libusb/examples/sam3u_benchmark.c +0 -228
  93. package/libusb/examples/testlibusb.c +0 -312
  94. package/libusb/examples/xusb.c +0 -1254
  95. package/libusb/libusb/Makefile.am +0 -98
  96. package/libusb/libusb/Makefile.am.extra +0 -26
  97. package/libusb/libusb/core.c +0 -2925
  98. package/libusb/libusb/descriptor.c +0 -1558
  99. package/libusb/libusb/hotplug.c +0 -489
  100. package/libusb/libusb/io.c +0 -2865
  101. package/libusb/libusb/libusb-1.0.def +0 -199
  102. package/libusb/libusb/libusb-1.0.rc +0 -53
  103. package/libusb/libusb/libusb.h +0 -2421
  104. package/libusb/libusb/libusbi.h +0 -1535
  105. package/libusb/libusb/os/darwin_usb.c +0 -2977
  106. package/libusb/libusb/os/darwin_usb.h +0 -156
  107. package/libusb/libusb/os/emscripten_webusb.cpp +0 -875
  108. package/libusb/libusb/os/events_posix.c +0 -340
  109. package/libusb/libusb/os/events_posix.h +0 -62
  110. package/libusb/libusb/os/events_windows.c +0 -214
  111. package/libusb/libusb/os/events_windows.h +0 -46
  112. package/libusb/libusb/os/haiku_pollfs.cpp +0 -372
  113. package/libusb/libusb/os/haiku_usb.h +0 -113
  114. package/libusb/libusb/os/haiku_usb_backend.cpp +0 -532
  115. package/libusb/libusb/os/haiku_usb_raw.cpp +0 -231
  116. package/libusb/libusb/os/haiku_usb_raw.h +0 -188
  117. package/libusb/libusb/os/linux_netlink.c +0 -401
  118. package/libusb/libusb/os/linux_udev.c +0 -321
  119. package/libusb/libusb/os/linux_usbfs.c +0 -2829
  120. package/libusb/libusb/os/linux_usbfs.h +0 -221
  121. package/libusb/libusb/os/netbsd_usb.c +0 -617
  122. package/libusb/libusb/os/null_usb.c +0 -111
  123. package/libusb/libusb/os/openbsd_usb.c +0 -700
  124. package/libusb/libusb/os/sunos_usb.c +0 -1619
  125. package/libusb/libusb/os/sunos_usb.h +0 -79
  126. package/libusb/libusb/os/threads_posix.c +0 -126
  127. package/libusb/libusb/os/threads_posix.h +0 -98
  128. package/libusb/libusb/os/threads_windows.c +0 -40
  129. package/libusb/libusb/os/threads_windows.h +0 -113
  130. package/libusb/libusb/os/windows_common.c +0 -923
  131. package/libusb/libusb/os/windows_common.h +0 -424
  132. package/libusb/libusb/os/windows_usbdk.c +0 -724
  133. package/libusb/libusb/os/windows_usbdk.h +0 -106
  134. package/libusb/libusb/os/windows_winusb.c +0 -4766
  135. package/libusb/libusb/os/windows_winusb.h +0 -787
  136. package/libusb/libusb/strerror.c +0 -223
  137. package/libusb/libusb/sync.c +0 -342
  138. package/libusb/libusb/version.h +0 -18
  139. package/libusb/libusb/version_nano.h +0 -1
  140. package/libusb/libusb-1.0.pc.in +0 -11
  141. package/libusb/msvc/Base.props +0 -60
  142. package/libusb/msvc/Configuration.Application.props +0 -7
  143. package/libusb/msvc/Configuration.Base.props +0 -47
  144. package/libusb/msvc/Configuration.DynamicLibrary.props +0 -21
  145. package/libusb/msvc/Configuration.StaticLibrary.props +0 -7
  146. package/libusb/msvc/ProjectConfigurations.Base.props +0 -69
  147. package/libusb/msvc/build_all.ps1 +0 -17
  148. package/libusb/msvc/config.h +0 -58
  149. package/libusb/msvc/dpfp.vcxproj +0 -33
  150. package/libusb/msvc/dpfp_threaded.vcxproj +0 -38
  151. package/libusb/msvc/fxload.vcxproj +0 -46
  152. package/libusb/msvc/getopt/getopt.c +0 -1060
  153. package/libusb/msvc/getopt/getopt.h +0 -180
  154. package/libusb/msvc/getopt/getopt1.c +0 -188
  155. package/libusb/msvc/getopt.vcxproj +0 -33
  156. package/libusb/msvc/hotplugtest.vcxproj +0 -32
  157. package/libusb/msvc/init_context.vcxproj +0 -35
  158. package/libusb/msvc/libusb.sln +0 -542
  159. package/libusb/msvc/libusb_dll.vcxproj +0 -61
  160. package/libusb/msvc/libusb_static.vcxproj +0 -49
  161. package/libusb/msvc/listdevs.vcxproj +0 -32
  162. package/libusb/msvc/sam3u_benchmark.vcxproj +0 -33
  163. package/libusb/msvc/set_option.vcxproj +0 -35
  164. package/libusb/msvc/stress.vcxproj +0 -35
  165. package/libusb/msvc/stress_mt.vcxproj +0 -33
  166. package/libusb/msvc/testlibusb.vcxproj +0 -32
  167. package/libusb/msvc/xusb.vcxproj +0 -38
  168. package/libusb/tests/Makefile.am +0 -40
  169. package/libusb/tests/init_context.c +0 -153
  170. package/libusb/tests/libusb_testlib.h +0 -76
  171. package/libusb/tests/macos.c +0 -130
  172. package/libusb/tests/set_option.c +0 -253
  173. package/libusb/tests/stress.c +0 -172
  174. package/libusb/tests/stress_mt.c +0 -267
  175. package/libusb/tests/testlib.c +0 -184
  176. package/libusb/tests/umockdev.c +0 -1175
  177. package/libusb/tests/webusb-test-shim/index.js +0 -12
  178. package/libusb/tests/webusb-test-shim/package-lock.json +0 -50
  179. package/libusb/tests/webusb-test-shim/package.json +0 -10
  180. package/libusb.gypi +0 -154
  181. package/libusb_config/config.h +0 -1
  182. package/prebuilds/android-arm/node.napi.armv7.node +0 -0
  183. package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
  184. package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
  185. package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
  186. package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
  187. package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
  188. package/prebuilds/linux-ia32/node.napi.node +0 -0
  189. package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  190. package/prebuilds/linux-x64/node.napi.musl.node +0 -0
  191. package/prebuilds/win32-arm64/node.napi.node +0 -0
  192. package/prebuilds/win32-ia32/node.napi.node +0 -0
  193. package/prebuilds/win32-x64/node.napi.node +0 -0
  194. package/src/device.cc +0 -439
  195. package/src/helpers.h +0 -64
  196. package/src/hotplug/hotplug.h +0 -22
  197. package/src/hotplug/libusb.cc +0 -90
  198. package/src/hotplug/windows.cc +0 -168
  199. package/src/node_usb.cc +0 -314
  200. package/src/node_usb.h +0 -131
  201. package/src/thread_name.cc +0 -79
  202. package/src/thread_name.h +0 -11
  203. package/src/transfer.cc +0 -143
  204. package/src/uv_async_queue.h +0 -41
  205. package/test/usb.coffee +0 -250
  206. package/test/webusb.coffee +0 -227
  207. package/test/worker.cjs +0 -13
@@ -1,295 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebUSB = exports.getWebUsb = void 0;
4
- const usb = require("../usb");
5
- const events_1 = require("events");
6
- const webusb_device_1 = require("./webusb-device");
7
- /**
8
- * Convenience method to get the WebUSB interface available
9
- */
10
- const getWebUsb = () => {
11
- if (navigator && navigator.usb) {
12
- return navigator.usb;
13
- }
14
- return new WebUSB();
15
- };
16
- exports.getWebUsb = getWebUsb;
17
- class NamedError extends Error {
18
- constructor(message, name) {
19
- super(message);
20
- this.name = name;
21
- }
22
- }
23
- class WebUSB {
24
- constructor(options = {}) {
25
- this.options = options;
26
- this.emitter = new events_1.EventEmitter();
27
- this.knownDevices = new Map();
28
- this.authorisedDevices = new Set();
29
- const deviceConnectCallback = async (device) => {
30
- const webDevice = await this.getWebDevice(device);
31
- // When connected, emit an event if it is an allowed device
32
- if (webDevice && this.isAuthorisedDevice(webDevice)) {
33
- const event = {
34
- type: 'connect',
35
- device: webDevice
36
- };
37
- this.emitter.emit('connect', event);
38
- }
39
- };
40
- const deviceDisconnectCallback = async (device) => {
41
- // When disconnected, emit an event if the device was a known allowed device
42
- if (this.knownDevices.has(device)) {
43
- const webDevice = this.knownDevices.get(device);
44
- if (webDevice && this.isAuthorisedDevice(webDevice)) {
45
- const event = {
46
- type: 'disconnect',
47
- device: webDevice
48
- };
49
- this.emitter.emit('disconnect', event);
50
- }
51
- }
52
- };
53
- this.emitter.on('newListener', event => {
54
- const listenerCount = this.emitter.listenerCount(event);
55
- if (listenerCount !== 0) {
56
- return;
57
- }
58
- if (event === 'connect') {
59
- usb.addListener('attach', deviceConnectCallback);
60
- }
61
- else if (event === 'disconnect') {
62
- usb.addListener('detach', deviceDisconnectCallback);
63
- }
64
- });
65
- this.emitter.on('removeListener', event => {
66
- const listenerCount = this.emitter.listenerCount(event);
67
- if (listenerCount !== 0) {
68
- return;
69
- }
70
- if (event === 'connect') {
71
- usb.removeListener('attach', deviceConnectCallback);
72
- }
73
- else if (event === 'disconnect') {
74
- usb.removeListener('detach', deviceDisconnectCallback);
75
- }
76
- });
77
- }
78
- set onconnect(fn) {
79
- if (this._onconnect) {
80
- this.removeEventListener('connect', this._onconnect);
81
- this._onconnect = undefined;
82
- }
83
- if (fn) {
84
- this._onconnect = fn;
85
- this.addEventListener('connect', this._onconnect);
86
- }
87
- }
88
- set ondisconnect(fn) {
89
- if (this._ondisconnect) {
90
- this.removeEventListener('disconnect', this._ondisconnect);
91
- this._ondisconnect = undefined;
92
- }
93
- if (fn) {
94
- this._ondisconnect = fn;
95
- this.addEventListener('disconnect', this._ondisconnect);
96
- }
97
- }
98
- addEventListener(type, listener) {
99
- this.emitter.addListener(type, listener);
100
- }
101
- removeEventListener(type, callback) {
102
- this.emitter.removeListener(type, callback);
103
- }
104
- dispatchEvent(_event) {
105
- // Don't dispatch from here
106
- return false;
107
- }
108
- /**
109
- * Requests a single Web USB device
110
- * @param options The options to use when scanning
111
- * @returns Promise containing the selected device
112
- */
113
- async requestDevice(options) {
114
- // Must have options
115
- if (!options) {
116
- throw new TypeError('requestDevice error: 1 argument required, but only 0 present');
117
- }
118
- // Options must be an object
119
- if (options.constructor !== {}.constructor) {
120
- throw new TypeError('requestDevice error: parameter 1 (options) is not an object');
121
- }
122
- // Must have a filter
123
- if (!options.filters) {
124
- throw new TypeError('requestDevice error: required member filters is undefined');
125
- }
126
- // Filter must be an array
127
- if (options.filters.constructor !== [].constructor) {
128
- throw new TypeError('requestDevice error: the provided value cannot be converted to a sequence');
129
- }
130
- // Check filters
131
- options.filters.forEach(filter => {
132
- // Protocol & Subclass
133
- if (filter.protocolCode && !filter.subclassCode) {
134
- throw new TypeError('requestDevice error: subclass code is required');
135
- }
136
- // Subclass & Class
137
- if (filter.subclassCode && !filter.classCode) {
138
- throw new TypeError('requestDevice error: class code is required');
139
- }
140
- });
141
- let devices = await this.loadDevices(options.filters);
142
- devices = devices.filter(device => this.filterDevice(device, options.filters));
143
- if (devices.length === 0) {
144
- throw new NamedError('Failed to execute \'requestDevice\' on \'USB\': No device selected.', 'NotFoundError');
145
- }
146
- try {
147
- // If no devicesFound function, select the first device found
148
- const device = this.options.devicesFound ? await this.options.devicesFound(devices) : devices[0];
149
- if (!device) {
150
- throw new NamedError('Failed to execute \'requestDevice\' on \'USB\': No device selected.', 'NotFoundError');
151
- }
152
- this.authorisedDevices.add({
153
- vendorId: device.vendorId,
154
- productId: device.productId,
155
- classCode: device.deviceClass,
156
- subclassCode: device.deviceSubclass,
157
- protocolCode: device.deviceProtocol,
158
- serialNumber: device.serialNumber || undefined
159
- });
160
- return device;
161
- }
162
- catch (error) {
163
- throw new NamedError('Failed to execute \'requestDevice\' on \'USB\': No device selected.', 'NotFoundError');
164
- }
165
- }
166
- /**
167
- * Gets all allowed Web USB devices which are connected
168
- * @returns Promise containing an array of devices
169
- */
170
- async getDevices() {
171
- const preFilters = this.options.allowAllDevices ? undefined : this.options.allowedDevices;
172
- // Refresh devices and filter for allowed ones
173
- const devices = await this.loadDevices(preFilters);
174
- return devices.filter(device => this.isAuthorisedDevice(device));
175
- }
176
- async loadDevices(preFilters) {
177
- let devices = usb.getDeviceList();
178
- // Pre-filter devices
179
- devices = this.quickFilter(devices, preFilters);
180
- const refreshedKnownDevices = new Map();
181
- for (const device of devices) {
182
- const webDevice = await this.getWebDevice(device);
183
- if (webDevice) {
184
- refreshedKnownDevices.set(device, webDevice);
185
- }
186
- }
187
- // Refresh knownDevices to remove old devices from the map
188
- this.knownDevices = refreshedKnownDevices;
189
- return [...this.knownDevices.values()];
190
- }
191
- // Get a WebUSBDevice corresponding to underlying device.
192
- // Returns undefined the device was not found and could not be created.
193
- async getWebDevice(device) {
194
- if (!this.knownDevices.has(device)) {
195
- if (this.options.deviceTimeout) {
196
- device.timeout = this.options.deviceTimeout;
197
- }
198
- try {
199
- const webDevice = await webusb_device_1.WebUSBDevice.createInstance(device, this.options.autoDetachKernelDriver);
200
- this.knownDevices.set(device, webDevice);
201
- }
202
- catch {
203
- // Ignore creation issues as this may be a system device
204
- }
205
- }
206
- return this.knownDevices.get(device);
207
- }
208
- // Undertake quick filter on devices before creating WebUSB devices if possible
209
- quickFilter(devices, preFilters) {
210
- if (!preFilters || !preFilters.length) {
211
- return devices;
212
- }
213
- // Just pre-filter on vid/pid
214
- return devices.filter(device => preFilters.some(filter => {
215
- // Vendor
216
- if (filter.vendorId && filter.vendorId !== device.deviceDescriptor.idVendor)
217
- return false;
218
- // Product
219
- if (filter.productId && filter.productId !== device.deviceDescriptor.idProduct)
220
- return false;
221
- // Ignore Class, Subclass and Protocol as these need to check interfaces, too
222
- // Ignore serial number for node-usb as it requires device connection
223
- return true;
224
- }));
225
- }
226
- // Filter WebUSB devices
227
- filterDevice(device, filters) {
228
- if (!filters || !filters.length) {
229
- return true;
230
- }
231
- return filters.some(filter => {
232
- // Vendor
233
- if (filter.vendorId && filter.vendorId !== device.vendorId)
234
- return false;
235
- // Product
236
- if (filter.productId && filter.productId !== device.productId)
237
- return false;
238
- // Class
239
- if (filter.classCode) {
240
- if (!device.configuration) {
241
- return false;
242
- }
243
- // Interface Descriptors
244
- const match = device.configuration.interfaces.some(iface => {
245
- // Class
246
- if (filter.classCode && filter.classCode !== iface.alternate.interfaceClass)
247
- return false;
248
- // Subclass
249
- if (filter.subclassCode && filter.subclassCode !== iface.alternate.interfaceSubclass)
250
- return false;
251
- // Protocol
252
- if (filter.protocolCode && filter.protocolCode !== iface.alternate.interfaceProtocol)
253
- return false;
254
- return true;
255
- });
256
- if (match) {
257
- return true;
258
- }
259
- }
260
- // Class
261
- if (filter.classCode && filter.classCode !== device.deviceClass)
262
- return false;
263
- // Subclass
264
- if (filter.subclassCode && filter.subclassCode !== device.deviceSubclass)
265
- return false;
266
- // Protocol
267
- if (filter.protocolCode && filter.protocolCode !== device.deviceProtocol)
268
- return false;
269
- // Serial
270
- if (filter.serialNumber && filter.serialNumber !== device.serialNumber)
271
- return false;
272
- return true;
273
- });
274
- }
275
- // Check whether a device is authorised
276
- isAuthorisedDevice(device) {
277
- // All devices are authorised
278
- if (this.options.allowAllDevices) {
279
- return true;
280
- }
281
- // Check any allowed device filters
282
- if (this.options.allowedDevices && this.filterDevice(device, this.options.allowedDevices)) {
283
- return true;
284
- }
285
- // Check authorised devices
286
- return [...this.authorisedDevices.values()].some(authorised => authorised.vendorId === device.vendorId
287
- && authorised.productId === device.productId
288
- && authorised.classCode === device.deviceClass
289
- && authorised.subclassCode === device.deviceSubclass
290
- && authorised.protocolCode === device.deviceProtocol
291
- && authorised.serialNumber === device.serialNumber);
292
- }
293
- }
294
- exports.WebUSB = WebUSB;
295
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../tsc/webusb/index.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,mCAAsC;AACtC,mDAA+C;AAgC/C;;GAEG;AACI,MAAM,SAAS,GAAG,GAAQ,EAAE;IAC/B,IAAI,SAAS,IAAI,SAAS,CAAC,GAAG,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,OAAO,IAAI,MAAM,EAAE,CAAC;AACxB,CAAC,CAAC;AANW,QAAA,SAAS,aAMpB;AAEF,MAAM,UAAW,SAAQ,KAAK;IAC1B,YAAmB,OAAe,EAAE,IAAY;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ;AAED,MAAa,MAAM;IAM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AAU,CAAC,YAAY,KAAK,MAAM,CAAC,cAAc;eACjD,UAAU,CAAC,YAAY,KAAK,MAAM,CAAC,cAAc;eACjD,UAAU,CAAC,YAAY,KAAK,MAAM,CAAC,YAAY,CACrD,CAAC;IACN,CAAC;CACJ;AAzUD,wBAyUC"}
@@ -1,54 +0,0 @@
1
- import * as usb from '../usb';
2
- /**
3
- * Wrapper to make a node-usb device look like a webusb device
4
- */
5
- export declare class WebUSBDevice implements USBDevice {
6
- private device;
7
- private autoDetachKernelDriver;
8
- static createInstance(device: usb.Device, autoDetachKernelDriver?: boolean): Promise<WebUSBDevice>;
9
- readonly usbVersionMajor: number;
10
- readonly usbVersionMinor: number;
11
- readonly usbVersionSubminor: number;
12
- readonly deviceClass: number;
13
- readonly deviceSubclass: number;
14
- readonly deviceProtocol: number;
15
- readonly vendorId: number;
16
- readonly productId: number;
17
- readonly deviceVersionMajor: number;
18
- readonly deviceVersionMinor: number;
19
- readonly deviceVersionSubminor: number;
20
- manufacturerName: string | null;
21
- productName: string | null;
22
- serialNumber: string | null;
23
- configurations: USBConfiguration[];
24
- private controlTransferAsync;
25
- private setConfigurationAsync;
26
- private resetAsync;
27
- private getStringDescriptorAsync;
28
- private constructor();
29
- get configuration(): USBConfiguration | null;
30
- get opened(): boolean;
31
- open(): Promise<void>;
32
- close(): Promise<void>;
33
- selectConfiguration(configurationValue: number): Promise<void>;
34
- claimInterface(interfaceNumber: number): Promise<void>;
35
- releaseInterface(interfaceNumber: number): Promise<void>;
36
- selectAlternateInterface(interfaceNumber: number, alternateSetting: number): Promise<void>;
37
- controlTransferIn(setup: USBControlTransferParameters, length: number): Promise<USBInTransferResult>;
38
- controlTransferOut(setup: USBControlTransferParameters, data?: ArrayBuffer): Promise<USBOutTransferResult>;
39
- clearHalt(direction: USBDirection, endpointNumber: number): Promise<void>;
40
- transferIn(endpointNumber: number, length: number): Promise<USBInTransferResult>;
41
- transferOut(endpointNumber: number, data: ArrayBuffer): Promise<USBOutTransferResult>;
42
- reset(): Promise<void>;
43
- isochronousTransferIn(_endpointNumber: number, _packetLengths: number[]): Promise<USBIsochronousInTransferResult>;
44
- isochronousTransferOut(_endpointNumber: number, _data: BufferSource, _packetLengths: number[]): Promise<USBIsochronousOutTransferResult>;
45
- forget(): Promise<void>;
46
- private initialize;
47
- private decodeVersion;
48
- private getStringDescriptor;
49
- private getConfigurations;
50
- private getEndpoint;
51
- private controlTransferParamsToType;
52
- private _releaseInterface;
53
- private checkDeviceOpen;
54
- }