usb 2.4.2 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitmodules +2 -2
- package/CHANGELOG.md +16 -0
- package/README.md +42 -2
- package/binding.gyp +48 -25
- package/dist/usb/bindings.d.ts +1 -0
- package/dist/usb/endpoint.d.ts +1 -1
- package/dist/usb/endpoint.js +4 -2
- package/dist/usb/endpoint.js.map +1 -1
- package/dist/usb/index.d.ts +6 -0
- package/dist/usb/index.js +82 -53
- package/dist/usb/index.js.map +1 -1
- package/package.json +4 -5
- 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 +309 -309
- package/src/helpers.h +36 -36
- package/src/hotplug/hotplug.h +22 -0
- package/src/hotplug/libusb.cc +90 -0
- package/src/hotplug/windows.cc +161 -0
- package/src/node_usb.cc +246 -282
- package/src/node_usb.h +64 -67
- package/src/thread_name.cc +1 -1
- package/src/transfer.cc +114 -114
- package/test/usb.coffee +178 -178
- package/test/webusb.coffee +140 -140
- package/tsc/usb/bindings.ts +1 -0
- package/tsc/usb/endpoint.ts +4 -3
- package/tsc/usb/index.ts +73 -32
package/.gitmodules
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
[submodule "libusb"]
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
path = libusb
|
|
3
|
+
url = https://github.com/libusb/libusb.git
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.5.1] - 2022-08-29
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- USB device plug/unplug detection on Windows when devce already attached - [`531`](https://github.com/node-usb/node-usb/pull/531) ([Rob Moran](https://github.com/thegecko))
|
|
7
|
+
- Removed dependency on yarn in package.json scripts - [`535`](https://github.com/node-usb/node-usb/pull/535) ([Rob Moran](https://github.com/thegecko))
|
|
8
|
+
|
|
9
|
+
## [2.5.0] - 2022-07-30
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- Native USB device plug/unplug detection on Windows - [`524`](https://github.com/node-usb/node-usb/pull/524) ([Julian Waller](https://github.com/Julusian))
|
|
13
|
+
|
|
14
|
+
## [2.4.3] - 2022-06-21
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Fixed poll transfer tracking - [`522`](https://github.com/node-usb/node-usb/pull/522) ([Rob Moran](https://github.com/thegecko))
|
|
18
|
+
|
|
3
19
|
## [2.4.2] - 2022-05-27
|
|
4
20
|
|
|
5
21
|
### Fixed
|
package/README.md
CHANGED
|
@@ -547,6 +547,40 @@ Restore (re-reference) the hotplug events unreferenced by `unrefHotplugEvents()`
|
|
|
547
547
|
#### usb.unrefHotplugEvents();
|
|
548
548
|
Listening to events will prevent the process to exit. By calling this function, hotplug events will be unreferenced by the event loop, allowing the process to exit even when listening for the `attach` and `detach` events.
|
|
549
549
|
|
|
550
|
+
# Migrating from node-usb-detection
|
|
551
|
+
|
|
552
|
+
If you have been referred here by `node-usb-detection`, the following may be helpful for you to update your existing code.
|
|
553
|
+
|
|
554
|
+
## usbDetect.startMonitoring() & usbDetect.stopMonitoring()
|
|
555
|
+
|
|
556
|
+
There is no direct equivalent to these methods. This is handled automatically for you when you add and remove event listeners.
|
|
557
|
+
|
|
558
|
+
You may find `usb.unrefHotplugEvents()` useful as it is intended to help with exit conditions.
|
|
559
|
+
|
|
560
|
+
## usbDetect.find()
|
|
561
|
+
|
|
562
|
+
You can instead use `usb.getDeviceList()`. Be aware that this will do an enumeration to find all of the devices, and not look at a cache of the known devices. If you call it too often it may have a performance impact.
|
|
563
|
+
|
|
564
|
+
To find a specific device by vid and pid, call `usb.findByIds`. e.g. `usb.findByIds(0x12, 0x34)`.
|
|
565
|
+
|
|
566
|
+
## usbDetect.on('add', function(device) { ... })
|
|
567
|
+
|
|
568
|
+
These should be changed to `usb.on('attach', function(device) { ... })`.
|
|
569
|
+
|
|
570
|
+
There is no equivalent to filter based on the vid or pid, instead you should do a check inside the callback you provide.
|
|
571
|
+
The contents of the device object has also changed.
|
|
572
|
+
|
|
573
|
+
## usbDetect.on('remove', function(device) { ... })
|
|
574
|
+
|
|
575
|
+
These should be changed to `usb.on('detach', function(device) { ... })`.
|
|
576
|
+
|
|
577
|
+
There is no equivalent to filter based on the vid or pid, instead you should do a check inside the callback you provide.
|
|
578
|
+
The contents of the device object has also changed.
|
|
579
|
+
|
|
580
|
+
## usbDetect.on('change', function(device) { ... })
|
|
581
|
+
|
|
582
|
+
There is no direct equivalent to this. Instead you can listen to both `attach` and `detach` to get the same behaviour.
|
|
583
|
+
|
|
550
584
|
# Development
|
|
551
585
|
The library is based on native bindings wrapping the [libusb](https://github.com/libusb/libusb) library.
|
|
552
586
|
|
|
@@ -560,11 +594,17 @@ git submodule update --init
|
|
|
560
594
|
```
|
|
561
595
|
|
|
562
596
|
## Building
|
|
563
|
-
The package uses `
|
|
597
|
+
The package uses `prebuildify` to generate the native binaries using an `install` script and `TypeScript` for the binding code using the `compile` script. The package can be built as follows:
|
|
564
598
|
|
|
565
599
|
```bash
|
|
566
600
|
yarn
|
|
567
|
-
yarn
|
|
601
|
+
yarn compile
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
The native binaries can be rebuilt with:
|
|
605
|
+
|
|
606
|
+
```bash
|
|
607
|
+
yarn rebuild
|
|
568
608
|
```
|
|
569
609
|
|
|
570
610
|
__Note:__ On Linux, you'll need libudev to build libusb. On Ubuntu/Debian:
|
package/binding.gyp
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
'variables': {
|
|
3
3
|
'use_udev%': 1,
|
|
4
|
-
'use_system_libusb%': 'false'
|
|
4
|
+
'use_system_libusb%': 'false'
|
|
5
5
|
},
|
|
6
6
|
'targets': [
|
|
7
7
|
{
|
|
8
8
|
'target_name': 'usb_bindings',
|
|
9
|
-
'cflags!': [
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
'cflags!': [
|
|
10
|
+
'-fno-exceptions'
|
|
11
|
+
],
|
|
12
|
+
'cflags_cc!': [
|
|
13
|
+
'-fno-exceptions'
|
|
14
|
+
],
|
|
15
|
+
'xcode_settings': {
|
|
16
|
+
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
|
|
12
17
|
'CLANG_CXX_LIBRARY': 'libc++',
|
|
13
|
-
'MACOSX_DEPLOYMENT_TARGET': '10.7'
|
|
18
|
+
'MACOSX_DEPLOYMENT_TARGET': '10.7'
|
|
14
19
|
},
|
|
15
20
|
'msvs_settings': {
|
|
16
|
-
'VCCLCompilerTool': {
|
|
21
|
+
'VCCLCompilerTool': {
|
|
22
|
+
'ExceptionHandling': 1
|
|
23
|
+
}
|
|
17
24
|
},
|
|
18
25
|
'sources': [
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
26
|
+
'src/node_usb.cc',
|
|
27
|
+
'src/device.cc',
|
|
28
|
+
'src/transfer.cc',
|
|
29
|
+
'src/thread_name.cc'
|
|
23
30
|
],
|
|
24
31
|
'cflags_cc': [
|
|
25
32
|
'-std=c++14'
|
|
@@ -27,7 +34,7 @@
|
|
|
27
34
|
'defines': [
|
|
28
35
|
'_FILE_OFFSET_BITS=64',
|
|
29
36
|
'_LARGEFILE_SOURCE',
|
|
30
|
-
'NAPI_VERSION=6'
|
|
37
|
+
'NAPI_VERSION=6'
|
|
31
38
|
],
|
|
32
39
|
'include_dirs+': [
|
|
33
40
|
'src/',
|
|
@@ -37,7 +44,7 @@
|
|
|
37
44
|
['use_system_libusb=="false" and OS!="freebsd"', {
|
|
38
45
|
'dependencies': [
|
|
39
46
|
'libusb.gypi:libusb',
|
|
40
|
-
]
|
|
47
|
+
]
|
|
41
48
|
}],
|
|
42
49
|
['use_system_libusb=="true" or OS=="freebsd"', {
|
|
43
50
|
'include_dirs+': [
|
|
@@ -45,7 +52,7 @@
|
|
|
45
52
|
],
|
|
46
53
|
'libraries': [
|
|
47
54
|
'<!@(pkg-config libusb-1.0 --libs)'
|
|
48
|
-
]
|
|
55
|
+
]
|
|
49
56
|
}],
|
|
50
57
|
['OS=="mac"', {
|
|
51
58
|
'xcode_settings': {
|
|
@@ -62,40 +69,56 @@
|
|
|
62
69
|
'-arch arm64'
|
|
63
70
|
],
|
|
64
71
|
'SDKROOT': 'macosx',
|
|
65
|
-
'MACOSX_DEPLOYMENT_TARGET': '10.7'
|
|
66
|
-
}
|
|
72
|
+
'MACOSX_DEPLOYMENT_TARGET': '10.7'
|
|
73
|
+
}
|
|
74
|
+
}],
|
|
75
|
+
['OS!="win"', {
|
|
76
|
+
'sources': [
|
|
77
|
+
'src/hotplug/libusb.cc'
|
|
78
|
+
],
|
|
67
79
|
}],
|
|
68
80
|
['OS=="win"', {
|
|
81
|
+
'sources': [
|
|
82
|
+
'src/hotplug/windows.cc'
|
|
83
|
+
],
|
|
69
84
|
'defines':[
|
|
70
85
|
'WIN32_LEAN_AND_MEAN'
|
|
71
86
|
],
|
|
87
|
+
'libraries': [
|
|
88
|
+
'cfgmgr32.lib'
|
|
89
|
+
],
|
|
72
90
|
'default_configuration': 'Debug',
|
|
73
91
|
'configurations': {
|
|
74
92
|
'Debug': {
|
|
75
|
-
'defines': [
|
|
93
|
+
'defines': [
|
|
94
|
+
'DEBUG',
|
|
95
|
+
'_DEBUG'
|
|
96
|
+
],
|
|
76
97
|
'msvs_settings': {
|
|
77
98
|
'VCCLCompilerTool': {
|
|
78
99
|
'RuntimeLibrary': 1, # static debug
|
|
79
|
-
}
|
|
80
|
-
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
81
102
|
},
|
|
82
103
|
'Release': {
|
|
83
|
-
'defines': [
|
|
104
|
+
'defines': [
|
|
105
|
+
'NDEBUG'
|
|
106
|
+
],
|
|
84
107
|
'msvs_settings': {
|
|
85
108
|
'VCCLCompilerTool': {
|
|
86
109
|
'RuntimeLibrary': 0, # static release
|
|
87
|
-
}
|
|
88
|
-
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
89
112
|
}
|
|
90
113
|
},
|
|
91
114
|
'msvs_settings': {
|
|
92
115
|
'VCCLCompilerTool': {
|
|
93
|
-
'AdditionalOptions': [ '/EHsc' ]
|
|
94
|
-
}
|
|
95
|
-
}
|
|
116
|
+
'AdditionalOptions': [ '/EHsc' ]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
96
119
|
}
|
|
97
120
|
]
|
|
98
121
|
]
|
|
99
|
-
}
|
|
122
|
+
}
|
|
100
123
|
]
|
|
101
124
|
}
|
package/dist/usb/bindings.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare function setDebugLevel(level: number): void;
|
|
|
17
17
|
* Use USBDK Backend (Windows only)
|
|
18
18
|
*/
|
|
19
19
|
export declare function useUsbDkBackend(): void;
|
|
20
|
+
export declare function _supportedHotplugEvents(): number;
|
|
20
21
|
export declare function _enableHotplugEvents(): void;
|
|
21
22
|
export declare function _disableHotplugEvents(): void;
|
|
22
23
|
export declare function _getLibusbCapability(capability: number): number;
|
package/dist/usb/endpoint.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare abstract class Endpoint extends EventEmitter {
|
|
|
32
32
|
export declare class InEndpoint extends Endpoint {
|
|
33
33
|
/** Endpoint direction. */
|
|
34
34
|
direction: 'in' | 'out';
|
|
35
|
-
protected pollTransfers: Transfer[]
|
|
35
|
+
protected pollTransfers: Transfer[];
|
|
36
36
|
protected pollTransferSize: number;
|
|
37
37
|
protected pollPending: number;
|
|
38
38
|
pollActive: boolean;
|
package/dist/usb/endpoint.js
CHANGED
|
@@ -58,6 +58,7 @@ var InEndpoint = /** @class */ (function (_super) {
|
|
|
58
58
|
var _this = _super.call(this, device, descriptor) || this;
|
|
59
59
|
/** Endpoint direction. */
|
|
60
60
|
_this.direction = 'in';
|
|
61
|
+
_this.pollTransfers = [];
|
|
61
62
|
_this.pollTransferSize = 0;
|
|
62
63
|
_this.pollPending = 0;
|
|
63
64
|
_this.pollActive = false;
|
|
@@ -115,6 +116,7 @@ var InEndpoint = /** @class */ (function (_super) {
|
|
|
115
116
|
_this.pollPending--;
|
|
116
117
|
if (_this.pollPending === 0) {
|
|
117
118
|
_this.pollTransfers = [];
|
|
119
|
+
_this.pollActive = false;
|
|
118
120
|
_this.emit('end');
|
|
119
121
|
}
|
|
120
122
|
}
|
|
@@ -140,7 +142,7 @@ var InEndpoint = /** @class */ (function (_super) {
|
|
|
140
142
|
InEndpoint.prototype.startPollTransfers = function (nTransfers, transferSize, callback) {
|
|
141
143
|
if (nTransfers === void 0) { nTransfers = 3; }
|
|
142
144
|
if (transferSize === void 0) { transferSize = this.descriptor.wMaxPacketSize; }
|
|
143
|
-
if (this.
|
|
145
|
+
if (this.pollActive) {
|
|
144
146
|
throw new Error('Polling already active');
|
|
145
147
|
}
|
|
146
148
|
this.pollTransferSize = transferSize;
|
|
@@ -162,7 +164,7 @@ var InEndpoint = /** @class */ (function (_super) {
|
|
|
162
164
|
* @param callback
|
|
163
165
|
*/
|
|
164
166
|
InEndpoint.prototype.stopPoll = function (callback) {
|
|
165
|
-
if (!this.
|
|
167
|
+
if (!this.pollActive) {
|
|
166
168
|
throw new Error('Polling is not active.');
|
|
167
169
|
}
|
|
168
170
|
for (var i = 0; i < this.pollTransfers.length; i++) {
|
package/dist/usb/endpoint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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C;AA9CY,kCAAW"}
|
package/dist/usb/index.d.ts
CHANGED
|
@@ -4,12 +4,18 @@ interface EventListeners<T> {
|
|
|
4
4
|
newListener: keyof T;
|
|
5
5
|
removeListener: keyof T;
|
|
6
6
|
}
|
|
7
|
+
interface DeviceIds {
|
|
8
|
+
idVendor: number;
|
|
9
|
+
idProduct: number;
|
|
10
|
+
}
|
|
7
11
|
declare module './bindings' {
|
|
8
12
|
interface Device extends ExtendedDevice {
|
|
9
13
|
}
|
|
10
14
|
interface DeviceEvents extends EventListeners<DeviceEvents> {
|
|
11
15
|
attach: Device;
|
|
12
16
|
detach: Device;
|
|
17
|
+
attachIds: DeviceIds;
|
|
18
|
+
detachIds: DeviceIds;
|
|
13
19
|
}
|
|
14
20
|
function addListener<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
|
15
21
|
function removeListener<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
package/dist/usb/index.js
CHANGED
|
@@ -21,14 +21,52 @@ Object.setPrototypeOf(usb, events_1.EventEmitter.prototype);
|
|
|
21
21
|
Object.getOwnPropertyNames(device_1.ExtendedDevice.prototype).forEach(function (name) {
|
|
22
22
|
Object.defineProperty(usb.Device.prototype, name, Object.getOwnPropertyDescriptor(device_1.ExtendedDevice.prototype, name) || Object.create(null));
|
|
23
23
|
});
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
// Hotplug support
|
|
25
|
+
var hotplugSupported = usb._supportedHotplugEvents();
|
|
26
|
+
// Devices delta support for non-libusb hotplug events
|
|
27
|
+
// This methd needs to be used for attach/detach IDs (hotplugSupportType === 2) rather than a lookup because vid/pid are not unique
|
|
28
|
+
var hotPlugDevices = new Set();
|
|
29
|
+
var emitHotplugEvents = function () {
|
|
30
|
+
var e_1, _a, e_2, _b;
|
|
31
|
+
// Collect current devices
|
|
32
|
+
var devices = new Set(usb.getDeviceList());
|
|
33
|
+
try {
|
|
34
|
+
// Find attached devices
|
|
35
|
+
for (var devices_1 = __values(devices), devices_1_1 = devices_1.next(); !devices_1_1.done; devices_1_1 = devices_1.next()) {
|
|
36
|
+
var device = devices_1_1.value;
|
|
37
|
+
if (!hotPlugDevices.has(device)) {
|
|
38
|
+
usb.emit('attach', device);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
43
|
+
finally {
|
|
44
|
+
try {
|
|
45
|
+
if (devices_1_1 && !devices_1_1.done && (_a = devices_1.return)) _a.call(devices_1);
|
|
46
|
+
}
|
|
47
|
+
finally { if (e_1) throw e_1.error; }
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
// Find detached devices
|
|
51
|
+
for (var hotPlugDevices_1 = __values(hotPlugDevices), hotPlugDevices_1_1 = hotPlugDevices_1.next(); !hotPlugDevices_1_1.done; hotPlugDevices_1_1 = hotPlugDevices_1.next()) {
|
|
52
|
+
var device = hotPlugDevices_1_1.value;
|
|
53
|
+
if (!devices.has(device)) {
|
|
54
|
+
usb.emit('detach', device);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
59
|
+
finally {
|
|
60
|
+
try {
|
|
61
|
+
if (hotPlugDevices_1_1 && !hotPlugDevices_1_1.done && (_b = hotPlugDevices_1.return)) _b.call(hotPlugDevices_1);
|
|
62
|
+
}
|
|
63
|
+
finally { if (e_2) throw e_2.error; }
|
|
64
|
+
}
|
|
65
|
+
hotPlugDevices = devices;
|
|
66
|
+
};
|
|
67
|
+
// Polling mechanism for checking device changes where hotplug detection is not available
|
|
28
68
|
var pollingHotplug = false;
|
|
29
|
-
var pollDevices = new Set();
|
|
30
69
|
var pollHotplug = function (start) {
|
|
31
|
-
var e_1, _a, e_2, _b;
|
|
32
70
|
if (start === void 0) { start = false; }
|
|
33
71
|
if (start) {
|
|
34
72
|
pollingHotplug = true;
|
|
@@ -36,44 +74,45 @@ var pollHotplug = function (start) {
|
|
|
36
74
|
else if (!pollingHotplug) {
|
|
37
75
|
return;
|
|
38
76
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
// Find detached devices
|
|
59
|
-
for (var pollDevices_1 = __values(pollDevices), pollDevices_1_1 = pollDevices_1.next(); !pollDevices_1_1.done; pollDevices_1_1 = pollDevices_1.next()) {
|
|
60
|
-
var device = pollDevices_1_1.value;
|
|
61
|
-
if (!devices.has(device))
|
|
62
|
-
usb.emit('detach', device);
|
|
63
|
-
}
|
|
77
|
+
else {
|
|
78
|
+
emitHotplugEvents();
|
|
79
|
+
}
|
|
80
|
+
setTimeout(function () { return pollHotplug(); }, 500);
|
|
81
|
+
};
|
|
82
|
+
// Hotplug control
|
|
83
|
+
var startHotplug = function () {
|
|
84
|
+
if (hotplugSupported !== 1) {
|
|
85
|
+
// Collect initial devices when not using libusb
|
|
86
|
+
hotPlugDevices = new Set(usb.getDeviceList());
|
|
87
|
+
}
|
|
88
|
+
if (hotplugSupported) {
|
|
89
|
+
// Use hotplug event emitters
|
|
90
|
+
usb._enableHotplugEvents();
|
|
91
|
+
if (hotplugSupported === 2) {
|
|
92
|
+
// Use hotplug ID events to trigger a change check
|
|
93
|
+
usb.on('attachIds', emitHotplugEvents);
|
|
94
|
+
usb.on('detachIds', emitHotplugEvents);
|
|
64
95
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// Fallback to using polling to check for changes
|
|
99
|
+
pollHotplug(true);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var stopHotplug = function () {
|
|
103
|
+
if (hotplugSupported) {
|
|
104
|
+
// Disable hotplug events
|
|
105
|
+
usb._disableHotplugEvents();
|
|
106
|
+
if (hotplugSupported === 2) {
|
|
107
|
+
// Remove hotplug ID event listeners
|
|
108
|
+
usb.off('attachIds', emitHotplugEvents);
|
|
109
|
+
usb.off('detachIds', emitHotplugEvents);
|
|
71
110
|
}
|
|
72
111
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
112
|
+
else {
|
|
113
|
+
// Stop polling
|
|
114
|
+
pollingHotplug = false;
|
|
115
|
+
}
|
|
77
116
|
};
|
|
78
117
|
usb.on('newListener', function (event) {
|
|
79
118
|
if (event !== 'attach' && event !== 'detach') {
|
|
@@ -81,12 +120,7 @@ usb.on('newListener', function (event) {
|
|
|
81
120
|
}
|
|
82
121
|
var listenerCount = usb.listenerCount('attach') + usb.listenerCount('detach');
|
|
83
122
|
if (listenerCount === 0) {
|
|
84
|
-
|
|
85
|
-
usb._enableHotplugEvents();
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
pollHotplug(true);
|
|
89
|
-
}
|
|
123
|
+
startHotplug();
|
|
90
124
|
}
|
|
91
125
|
});
|
|
92
126
|
usb.on('removeListener', function (event) {
|
|
@@ -95,12 +129,7 @@ usb.on('removeListener', function (event) {
|
|
|
95
129
|
}
|
|
96
130
|
var listenerCount = usb.listenerCount('attach') + usb.listenerCount('detach');
|
|
97
131
|
if (listenerCount === 0) {
|
|
98
|
-
|
|
99
|
-
usb._disableHotplugEvents();
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
pollingHotplug = false;
|
|
103
|
-
}
|
|
132
|
+
stopHotplug();
|
|
104
133
|
}
|
|
105
134
|
});
|
|
106
135
|
module.exports = usb;
|
package/dist/usb/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tsc/usb/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAsC;AACtC,mCAA0C;AAC1C,gCAAkC;AAElC,IAAI,GAAG,CAAC,UAAU,EAAE;IAChB,+BAA+B;IAC/B,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;CAChD;AAED,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,qBAAY,CAAC,SAAS,CAAC,CAAC;AAEnD,MAAM,CAAC,mBAAmB,CAAC,uBAAc,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,UAAA,IAAI;IAC7D,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,wBAAwB,CAAC,uBAAc,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9I,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tsc/usb/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAsC;AACtC,mCAA0C;AAC1C,gCAAkC;AAElC,IAAI,GAAG,CAAC,UAAU,EAAE;IAChB,+BAA+B;IAC/B,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;CAChD;AAED,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,qBAAY,CAAC,SAAS,CAAC,CAAC;AAEnD,MAAM,CAAC,mBAAmB,CAAC,uBAAc,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,UAAA,IAAI;IAC7D,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,wBAAwB,CAAC,uBAAc,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9I,CAAC,CAA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KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,QAAQ,EAAE;QAC1C,OAAO;KACV;IACD,IAAM,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChF,IAAI,aAAa,KAAK,CAAC,EAAE;QACrB,WAAW,EAAE,CAAC;KACjB;AACL,CAAC,CAAC,CAAC;AAEH,iBAAS,GAAG,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "usb",
|
|
3
3
|
"description": "Library to access USB devices",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.5.1",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=10.20.0 <11.x || >=12.17.0 <13.0 || >=14.0.0"
|
|
@@ -36,12 +36,11 @@
|
|
|
36
36
|
"hardware"
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
|
-
"prepare": "yarn compile",
|
|
40
39
|
"install": "node-gyp-build",
|
|
41
40
|
"rebuild": "node-gyp rebuild",
|
|
42
|
-
"clean": "git clean -
|
|
43
|
-
"compile": "tsc
|
|
44
|
-
"
|
|
41
|
+
"clean": "git clean -fx ./build ./prebuilds ./dist ./docs ./node_modules",
|
|
42
|
+
"compile": "tsc",
|
|
43
|
+
"postcompile": "eslint . --ext .ts",
|
|
45
44
|
"watch": "tsc -w --preserveWatchOutput",
|
|
46
45
|
"test": "mocha --require coffeescript/register --grep Module test/*",
|
|
47
46
|
"full-test": "mocha --require coffeescript/register test/*.coffee",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|