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/index.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const events_1 = require("events");
|
|
3
|
-
const device_1 = require("./device");
|
|
4
|
-
const usb = require("./bindings");
|
|
5
|
-
if (usb.INIT_ERROR) {
|
|
6
|
-
/* eslint-disable no-console */
|
|
7
|
-
console.warn('Failed to initialize libusb.');
|
|
8
|
-
}
|
|
9
|
-
Object.setPrototypeOf(usb, events_1.EventEmitter.prototype);
|
|
10
|
-
Object.defineProperty(usb, 'pollHotplug', {
|
|
11
|
-
value: false,
|
|
12
|
-
writable: true
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(usb, 'pollHotplugDelay', {
|
|
15
|
-
value: 500,
|
|
16
|
-
writable: true
|
|
17
|
-
});
|
|
18
|
-
// `usb.Device` is not defined when `usb.INIT_ERROR` is true
|
|
19
|
-
if (usb.Device) {
|
|
20
|
-
Object.getOwnPropertyNames(device_1.ExtendedDevice.prototype).forEach(name => {
|
|
21
|
-
Object.defineProperty(usb.Device.prototype, name, Object.getOwnPropertyDescriptor(device_1.ExtendedDevice.prototype, name) || Object.create(null));
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
// Devices delta support for non-libusb hotplug events
|
|
25
|
-
let hotPlugDevices = new Set();
|
|
26
|
-
// This method needs to be used for attach/detach IDs (hotplugSupportType === 2) rather than a lookup because vid/pid are not unique
|
|
27
|
-
const emitHotplugEvents = () => {
|
|
28
|
-
// Collect current devices
|
|
29
|
-
const devices = new Set(usb.getDeviceList());
|
|
30
|
-
// Find attached devices
|
|
31
|
-
for (const device of devices) {
|
|
32
|
-
if (!hotPlugDevices.has(device)) {
|
|
33
|
-
usb.emit('attach', device);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// Find detached devices
|
|
37
|
-
for (const device of hotPlugDevices) {
|
|
38
|
-
if (!devices.has(device)) {
|
|
39
|
-
usb.emit('detach', device);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
hotPlugDevices = devices;
|
|
43
|
-
};
|
|
44
|
-
// Polling mechanism for checking device changes where hotplug detection is not available
|
|
45
|
-
let pollingHotplug = false;
|
|
46
|
-
const pollHotplug = (start = false) => {
|
|
47
|
-
if (start) {
|
|
48
|
-
pollingHotplug = true;
|
|
49
|
-
}
|
|
50
|
-
else if (!pollingHotplug) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
emitHotplugEvents();
|
|
55
|
-
}
|
|
56
|
-
setTimeout(() => pollHotplug(), usb.pollHotplugDelay);
|
|
57
|
-
};
|
|
58
|
-
// Devices changed event handler
|
|
59
|
-
const devicesChanged = () => setTimeout(() => emitHotplugEvents(), usb.pollHotplugDelay);
|
|
60
|
-
// Hotplug control
|
|
61
|
-
let hotplugSupported = 0;
|
|
62
|
-
const startHotplug = () => {
|
|
63
|
-
hotplugSupported = usb.pollHotplug ? 0 : usb._supportedHotplugEvents();
|
|
64
|
-
if (hotplugSupported !== 1) {
|
|
65
|
-
// Collect initial devices when not using libusb
|
|
66
|
-
hotPlugDevices = new Set(usb.getDeviceList());
|
|
67
|
-
}
|
|
68
|
-
if (hotplugSupported) {
|
|
69
|
-
// Use hotplug event emitters
|
|
70
|
-
usb._enableHotplugEvents();
|
|
71
|
-
if (hotplugSupported === 2) {
|
|
72
|
-
// Use hotplug ID events to trigger a change check
|
|
73
|
-
usb.on('attachIds', devicesChanged);
|
|
74
|
-
usb.on('detachIds', devicesChanged);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
// Fallback to using polling to check for changes
|
|
79
|
-
pollHotplug(true);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const stopHotplug = () => {
|
|
83
|
-
if (hotplugSupported) {
|
|
84
|
-
// Disable hotplug events
|
|
85
|
-
usb._disableHotplugEvents();
|
|
86
|
-
if (hotplugSupported === 2) {
|
|
87
|
-
// Remove hotplug ID event listeners
|
|
88
|
-
usb.off('attachIds', devicesChanged);
|
|
89
|
-
usb.off('detachIds', devicesChanged);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
// Stop polling
|
|
94
|
-
pollingHotplug = false;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
usb.on('newListener', event => {
|
|
98
|
-
if (event !== 'attach' && event !== 'detach') {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const listenerCount = usb.listenerCount('attach') + usb.listenerCount('detach');
|
|
102
|
-
if (listenerCount === 0) {
|
|
103
|
-
startHotplug();
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
usb.on('removeListener', event => {
|
|
107
|
-
if (event !== 'attach' && event !== 'detach') {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const listenerCount = usb.listenerCount('attach') + usb.listenerCount('detach');
|
|
111
|
-
if (listenerCount === 0) {
|
|
112
|
-
stopHotplug();
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
module.exports = usb;
|
|
116
|
-
//# sourceMappingURL=index.js.map
|
package/dist/usb/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tsc/usb/index.ts"],"names":[],"mappings":";AAAA,mCAAsC;AACtC,qCAA0C;AAC1C,kCAAkC;AAElC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;IACjB,+BAA+B;IAC/B,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,qBAAY,CAAC,SAAS,CAAC,CAAC;AACnD,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,aAAa,EAAE;IACtC,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,IAAI;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,kBAAkB,EAAE;IAC3C,KAAK,EAAE,GAAG;IACV,QAAQ,EAAE,IAAI;CACjB,CAAC,CAAC;AAEH,4DAA4D;AAC5D,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;IACb,MAAM,CAAC,mBAAmB,CAAC,uBAAc,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAChE,MAAM,CAAC,cAAc,CAAC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ACzC,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,eAAe;QACf,cAAc,GAAG,KAAK,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEF,GAAG,CAAC,EAAE,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE;IAC1B,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3C,OAAO;IACX,CAAC;IACD,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChF,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;QACtB,YAAY,EAAE,CAAC;IACnB,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,CAAC,EAAE;IAC7B,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3C,OAAO;IACX,CAAC;IACD,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChF,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;QACtB,WAAW,EAAE,CAAC;IAClB,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,iBAAS,GAAG,CAAC"}
|
package/dist/usb/interface.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { LibUSBException, Device } from './bindings';
|
|
2
|
-
import { InterfaceDescriptor } from './descriptors';
|
|
3
|
-
import { Endpoint } from './endpoint';
|
|
4
|
-
export declare class Interface {
|
|
5
|
-
protected device: Device;
|
|
6
|
-
protected id: number;
|
|
7
|
-
/** Integer interface number. */
|
|
8
|
-
interfaceNumber: number;
|
|
9
|
-
/** Integer alternate setting number. */
|
|
10
|
-
altSetting: number;
|
|
11
|
-
/** Object with fields from the interface descriptor -- see libusb documentation or USB spec. */
|
|
12
|
-
descriptor: InterfaceDescriptor;
|
|
13
|
-
/** List of endpoints on this interface: InEndpoint and OutEndpoint objects. */
|
|
14
|
-
endpoints: Endpoint[];
|
|
15
|
-
releaseAsync: () => Promise<void>;
|
|
16
|
-
setAltSettingAsync: (alternateSetting: number) => Promise<void>;
|
|
17
|
-
constructor(device: Device, id: number);
|
|
18
|
-
protected refresh(): void;
|
|
19
|
-
/**
|
|
20
|
-
* Claims the interface. This method must be called before using any endpoints of this interface.
|
|
21
|
-
*
|
|
22
|
-
* The device must be open to use this method.
|
|
23
|
-
*/
|
|
24
|
-
claim(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Releases the interface and resets the alternate setting. Calls callback when complete.
|
|
27
|
-
*
|
|
28
|
-
* It is an error to release an interface with pending transfers.
|
|
29
|
-
*
|
|
30
|
-
* The device must be open to use this method.
|
|
31
|
-
* @param callback
|
|
32
|
-
*/
|
|
33
|
-
release(callback?: (error?: LibUSBException) => void): void;
|
|
34
|
-
/**
|
|
35
|
-
* Releases the interface and resets the alternate setting. Calls callback when complete.
|
|
36
|
-
*
|
|
37
|
-
* It is an error to release an interface with pending transfers. If the optional closeEndpoints
|
|
38
|
-
* parameter is true, any active endpoint streams are stopped (see `Endpoint.stopStream`),
|
|
39
|
-
* and the interface is released after the stream transfers are cancelled. Transfers submitted
|
|
40
|
-
* individually with `Endpoint.transfer` are not affected by this parameter.
|
|
41
|
-
*
|
|
42
|
-
* The device must be open to use this method.
|
|
43
|
-
* @param closeEndpoints
|
|
44
|
-
* @param callback
|
|
45
|
-
*/
|
|
46
|
-
release(closeEndpoints?: boolean, callback?: (error?: LibUSBException) => void): void;
|
|
47
|
-
/**
|
|
48
|
-
* Returns `false` if a kernel driver is not active; `true` if active.
|
|
49
|
-
*
|
|
50
|
-
* The device must be open to use this method.
|
|
51
|
-
*/
|
|
52
|
-
isKernelDriverActive(): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Detaches the kernel driver from the interface.
|
|
55
|
-
*
|
|
56
|
-
* The device must be open to use this method.
|
|
57
|
-
*/
|
|
58
|
-
detachKernelDriver(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Re-attaches the kernel driver for the interface.
|
|
61
|
-
*
|
|
62
|
-
* The device must be open to use this method.
|
|
63
|
-
*/
|
|
64
|
-
attachKernelDriver(): void;
|
|
65
|
-
/**
|
|
66
|
-
* Sets the alternate setting. It updates the `interface.endpoints` array to reflect the endpoints found in the alternate setting.
|
|
67
|
-
*
|
|
68
|
-
* The device must be open to use this method.
|
|
69
|
-
* @param altSetting
|
|
70
|
-
* @param callback
|
|
71
|
-
*/
|
|
72
|
-
setAltSetting(altSetting: number, callback?: (error: LibUSBException | undefined) => void): void;
|
|
73
|
-
/**
|
|
74
|
-
* Return the InEndpoint or OutEndpoint with the specified address.
|
|
75
|
-
*
|
|
76
|
-
* The device must be open to use this method.
|
|
77
|
-
* @param addr
|
|
78
|
-
*/
|
|
79
|
-
endpoint(addr: number): Endpoint | undefined;
|
|
80
|
-
}
|
package/dist/usb/interface.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Interface = void 0;
|
|
4
|
-
const bindings_1 = require("./bindings");
|
|
5
|
-
const endpoint_1 = require("./endpoint");
|
|
6
|
-
const util_1 = require("util");
|
|
7
|
-
class Interface {
|
|
8
|
-
constructor(device, id) {
|
|
9
|
-
this.device = device;
|
|
10
|
-
this.id = id;
|
|
11
|
-
/** Integer alternate setting number. */
|
|
12
|
-
this.altSetting = 0;
|
|
13
|
-
this.refresh();
|
|
14
|
-
this.releaseAsync = (0, util_1.promisify)(this.release).bind(this);
|
|
15
|
-
this.setAltSettingAsync = (0, util_1.promisify)(this.setAltSetting).bind(this);
|
|
16
|
-
}
|
|
17
|
-
refresh() {
|
|
18
|
-
if (!this.device.configDescriptor) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
this.descriptor = this.device.configDescriptor.interfaces[this.id][this.altSetting];
|
|
22
|
-
this.interfaceNumber = this.descriptor.bInterfaceNumber;
|
|
23
|
-
this.endpoints = [];
|
|
24
|
-
const len = this.descriptor.endpoints.length;
|
|
25
|
-
for (let i = 0; i < len; i++) {
|
|
26
|
-
const desc = this.descriptor.endpoints[i];
|
|
27
|
-
const c = (desc.bEndpointAddress & bindings_1.LIBUSB_ENDPOINT_IN) ? endpoint_1.InEndpoint : endpoint_1.OutEndpoint;
|
|
28
|
-
this.endpoints[i] = new c(this.device, desc);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Claims the interface. This method must be called before using any endpoints of this interface.
|
|
33
|
-
*
|
|
34
|
-
* The device must be open to use this method.
|
|
35
|
-
*/
|
|
36
|
-
claim() {
|
|
37
|
-
this.device.__claimInterface(this.id);
|
|
38
|
-
}
|
|
39
|
-
release(closeEndpointsOrCallback, callback) {
|
|
40
|
-
let closeEndpoints = false;
|
|
41
|
-
if (typeof closeEndpointsOrCallback === 'boolean') {
|
|
42
|
-
closeEndpoints = closeEndpointsOrCallback;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
callback = closeEndpointsOrCallback;
|
|
46
|
-
}
|
|
47
|
-
const next = () => {
|
|
48
|
-
this.device.__releaseInterface(this.id, error => {
|
|
49
|
-
if (!error) {
|
|
50
|
-
this.altSetting = 0;
|
|
51
|
-
this.refresh();
|
|
52
|
-
}
|
|
53
|
-
if (callback) {
|
|
54
|
-
callback.call(this, error);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
if (!closeEndpoints || this.endpoints.length === 0) {
|
|
59
|
-
next();
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
let n = this.endpoints.length;
|
|
63
|
-
this.endpoints.forEach(ep => {
|
|
64
|
-
if (ep.direction === 'in' && ep.pollActive) {
|
|
65
|
-
ep.once('end', () => {
|
|
66
|
-
if (--n === 0) {
|
|
67
|
-
next();
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
ep.stopPoll();
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
if (--n === 0) {
|
|
74
|
-
next();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Returns `false` if a kernel driver is not active; `true` if active.
|
|
82
|
-
*
|
|
83
|
-
* The device must be open to use this method.
|
|
84
|
-
*/
|
|
85
|
-
isKernelDriverActive() {
|
|
86
|
-
return this.device.__isKernelDriverActive(this.id);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Detaches the kernel driver from the interface.
|
|
90
|
-
*
|
|
91
|
-
* The device must be open to use this method.
|
|
92
|
-
*/
|
|
93
|
-
detachKernelDriver() {
|
|
94
|
-
return this.device.__detachKernelDriver(this.id);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Re-attaches the kernel driver for the interface.
|
|
98
|
-
*
|
|
99
|
-
* The device must be open to use this method.
|
|
100
|
-
*/
|
|
101
|
-
attachKernelDriver() {
|
|
102
|
-
return this.device.__attachKernelDriver(this.id);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Sets the alternate setting. It updates the `interface.endpoints` array to reflect the endpoints found in the alternate setting.
|
|
106
|
-
*
|
|
107
|
-
* The device must be open to use this method.
|
|
108
|
-
* @param altSetting
|
|
109
|
-
* @param callback
|
|
110
|
-
*/
|
|
111
|
-
setAltSetting(altSetting, callback) {
|
|
112
|
-
this.device.__setInterface(this.id, altSetting, error => {
|
|
113
|
-
if (!error) {
|
|
114
|
-
this.altSetting = altSetting;
|
|
115
|
-
this.refresh();
|
|
116
|
-
}
|
|
117
|
-
if (callback) {
|
|
118
|
-
callback.call(this, error);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Return the InEndpoint or OutEndpoint with the specified address.
|
|
124
|
-
*
|
|
125
|
-
* The device must be open to use this method.
|
|
126
|
-
* @param addr
|
|
127
|
-
*/
|
|
128
|
-
endpoint(addr) {
|
|
129
|
-
return this.endpoints.find(item => item.address === addr);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
exports.Interface = Interface;
|
|
133
|
-
//# sourceMappingURL=interface.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../tsc/usb/interface.ts"],"names":[],"mappings":";;;AAAA,yCAAyE;AAEzE,yCAA+D;AAC/D,+BAAiC;AAEjC,MAAa,SAAS;IAgBlB,YAAsB,MAAc,EAAY,EAAU;QAApC,WAAM,GAAN,MAAM,CAAQ;QAAY,OAAE,GAAF,EAAE,CAAQ;QAZ1D,wCAAwC;QACjC,eAAU,GAAG,CAAC,CAAC;QAYlB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,IAAA,gBAAS,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,IAAI,CAAC,kBAAkB,GAAG,IAAA,gBAAS,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvE,CAAC;IAES,OAAO;QACb,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAChC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACpF,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACxD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MA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GAAG,UAAU,CAAC;gBAC7B,IAAI,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;YACD,IAAI,QAAQ,EAAE,CAAC;gBACX,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;IAC9D,CAAC;CACJ;AAvKD,8BAuKC"}
|
package/dist/webusb/index.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import * as usb from '../usb';
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import { WebUSBDevice } from './webusb-device';
|
|
4
|
-
/**
|
|
5
|
-
* USB Options
|
|
6
|
-
*/
|
|
7
|
-
export interface USBOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Optional `device found` callback function to allow the user to select a device
|
|
10
|
-
*/
|
|
11
|
-
devicesFound?: (devices: USBDevice[]) => Promise<USBDevice | void>;
|
|
12
|
-
/**
|
|
13
|
-
* Optional array of preconfigured allowed devices
|
|
14
|
-
*/
|
|
15
|
-
allowedDevices?: USBDeviceFilter[];
|
|
16
|
-
/**
|
|
17
|
-
* Optional flag to automatically allow all devices
|
|
18
|
-
*/
|
|
19
|
-
allowAllDevices?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Optional timeout (in milliseconds) to use for the device control transfers
|
|
22
|
-
*/
|
|
23
|
-
deviceTimeout?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Optional flag to enable/disable automatic kernal driver detaching (defaults to true)
|
|
26
|
-
*/
|
|
27
|
-
autoDetachKernelDriver?: boolean;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Convenience method to get the WebUSB interface available
|
|
31
|
-
*/
|
|
32
|
-
export declare const getWebUsb: () => USB;
|
|
33
|
-
export declare class WebUSB implements USB {
|
|
34
|
-
private options;
|
|
35
|
-
protected emitter: EventEmitter<any>;
|
|
36
|
-
protected knownDevices: Map<usb.Device, WebUSBDevice>;
|
|
37
|
-
protected authorisedDevices: Set<USBDeviceFilter>;
|
|
38
|
-
constructor(options?: USBOptions);
|
|
39
|
-
private _onconnect;
|
|
40
|
-
set onconnect(fn: (ev: USBConnectionEvent) => void);
|
|
41
|
-
private _ondisconnect;
|
|
42
|
-
set ondisconnect(fn: (ev: USBConnectionEvent) => void);
|
|
43
|
-
addEventListener(type: 'connect' | 'disconnect', listener: (this: this, ev: USBConnectionEvent) => void): void;
|
|
44
|
-
addEventListener(type: 'connect' | 'disconnect', listener: EventListener): void;
|
|
45
|
-
removeEventListener(type: 'connect' | 'disconnect', callback: (this: this, ev: USBConnectionEvent) => void): void;
|
|
46
|
-
removeEventListener(type: 'connect' | 'disconnect', callback: EventListener): void;
|
|
47
|
-
dispatchEvent(_event: Event): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Requests a single Web USB device
|
|
50
|
-
* @param options The options to use when scanning
|
|
51
|
-
* @returns Promise containing the selected device
|
|
52
|
-
*/
|
|
53
|
-
requestDevice(options?: USBDeviceRequestOptions): Promise<USBDevice>;
|
|
54
|
-
/**
|
|
55
|
-
* Gets all allowed Web USB devices which are connected
|
|
56
|
-
* @returns Promise containing an array of devices
|
|
57
|
-
*/
|
|
58
|
-
getDevices(): Promise<USBDevice[]>;
|
|
59
|
-
private loadDevices;
|
|
60
|
-
private getWebDevice;
|
|
61
|
-
private quickFilter;
|
|
62
|
-
private filterDevice;
|
|
63
|
-
private isAuthorisedDevice;
|
|
64
|
-
}
|