usb 3.0.0-alpha.2 → 3.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/index.d.ts +28 -20
- package/dist/index.js +102 -116
- package/index.d.ts +56 -17
- package/index.js +52 -52
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -92,6 +92,19 @@ https://wicg.github.io/webusb/
|
|
|
92
92
|
|
|
93
93
|
### Implementation Status
|
|
94
94
|
|
|
95
|
+
#### Architectures and Operating Systems
|
|
96
|
+
|
|
97
|
+
- i686-pc-windows-msvc
|
|
98
|
+
- x86_64-apple-darwin
|
|
99
|
+
- x86_64-pc-windows-msvc
|
|
100
|
+
- x86_64-unknown-linux-gnu
|
|
101
|
+
- x86_64-unknown-linux-musl
|
|
102
|
+
- aarch64-apple-darwin
|
|
103
|
+
- aarch64-pc-windows-msvc
|
|
104
|
+
- aarch64-unknown-linux-gnu
|
|
105
|
+
- aarch64-unknown-linux-musl
|
|
106
|
+
- armv7-unknown-linux-gnueabihf
|
|
107
|
+
|
|
95
108
|
#### USB
|
|
96
109
|
|
|
97
110
|
- [x] getDevices()
|
|
@@ -99,6 +112,8 @@ https://wicg.github.io/webusb/
|
|
|
99
112
|
|
|
100
113
|
#### USBDevice
|
|
101
114
|
|
|
115
|
+
##### WebUSB Features
|
|
116
|
+
|
|
102
117
|
- [x] usbVersionMajor
|
|
103
118
|
- [x] usbVersionMinor
|
|
104
119
|
- [x] usbVersionSubminor
|
|
@@ -132,6 +147,15 @@ https://wicg.github.io/webusb/
|
|
|
132
147
|
- [ ] isochronousTransferIn()
|
|
133
148
|
- [ ] isochronousTransferOut()
|
|
134
149
|
|
|
150
|
+
##### Extended Features
|
|
151
|
+
|
|
152
|
+
- [x] bus
|
|
153
|
+
- [x] address
|
|
154
|
+
- [x] ports
|
|
155
|
+
- [x] speed
|
|
156
|
+
- [x] detachKernelDriver() (Linux only)
|
|
157
|
+
- [x] attachKernelDriver() (Linux only)
|
|
158
|
+
|
|
135
159
|
#### Events
|
|
136
160
|
|
|
137
161
|
- [x] connect
|
|
@@ -140,6 +164,8 @@ https://wicg.github.io/webusb/
|
|
|
140
164
|
# Development
|
|
141
165
|
The library is based on native rust bindings wrapping the [nusb](https://docs.rs/nusb/latest/nusb) crate.
|
|
142
166
|
|
|
167
|
+
Ensure you have a working rust environment, instructions for setting this up are avalable at https://rust-lang.org/tools/install/
|
|
168
|
+
|
|
143
169
|
## Setup
|
|
144
170
|
|
|
145
171
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Emitter } from '../index.js';
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
1
|
+
import { UsbDevice, Emitter } from '../index.js';
|
|
3
2
|
/**
|
|
4
3
|
* USB Options
|
|
5
4
|
*/
|
|
@@ -7,7 +6,7 @@ interface USBOptions {
|
|
|
7
6
|
/**
|
|
8
7
|
* Optional `device found` callback function to allow the user to select a device
|
|
9
8
|
*/
|
|
10
|
-
devicesFound?: (devices:
|
|
9
|
+
devicesFound?: (devices: UsbDevice[]) => Promise<UsbDevice | void>;
|
|
11
10
|
/**
|
|
12
11
|
* Optional array of preconfigured allowed devices
|
|
13
12
|
*/
|
|
@@ -20,38 +19,44 @@ interface USBOptions {
|
|
|
20
19
|
* Optional timeout (in milliseconds) to use for the device control transfers
|
|
21
20
|
*/
|
|
22
21
|
deviceTimeout?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Optional flag to enable/disable automatic kernal driver detaching (defaults to true)
|
|
25
|
-
*/
|
|
26
|
-
autoDetachKernelDriver?: boolean;
|
|
27
22
|
}
|
|
28
|
-
|
|
23
|
+
interface WebUSB {
|
|
24
|
+
addEventListener(type: "connect" | "disconnect", listener: (this: this, ev: USBConnectionEvent) => any, useCapture?: boolean): void;
|
|
25
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
|
|
26
|
+
removeEventListener(type: "connect" | "disconnect", callback: (this: this, ev: USBConnectionEvent) => any, useCapture?: boolean): void;
|
|
27
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* WebUSB class
|
|
31
|
+
*
|
|
32
|
+
* ### Events
|
|
33
|
+
*
|
|
34
|
+
* | Name | Event | Description |
|
|
35
|
+
* | ---- | ----- | ----------- |
|
|
36
|
+
* | `connect` | {@link USBConnectionEvent} | Device connected |
|
|
37
|
+
* | `disconnect` | {@link USBConnectionEvent} | Device disconnected |
|
|
38
|
+
*/
|
|
39
|
+
declare class WebUSB extends EventTarget implements USB {
|
|
29
40
|
private options;
|
|
30
41
|
protected nativeEmitter: Emitter;
|
|
31
|
-
protected emitter: EventEmitter<any>;
|
|
32
42
|
protected authorisedDevices: Set<USBDeviceFilter>;
|
|
33
|
-
protected knownDevices: Map<string,
|
|
43
|
+
protected knownDevices: Map<string, UsbDevice>;
|
|
34
44
|
constructor(options?: USBOptions);
|
|
35
45
|
private _onconnect;
|
|
36
46
|
set onconnect(fn: (ev: USBConnectionEvent) => void);
|
|
37
47
|
private _ondisconnect;
|
|
38
48
|
set ondisconnect(fn: (ev: USBConnectionEvent) => void);
|
|
39
|
-
addEventListener(type: 'connect' | 'disconnect', listener: (this: this, ev: USBConnectionEvent) => void): void;
|
|
40
|
-
addEventListener(type: 'connect' | 'disconnect', listener: EventListener): void;
|
|
41
|
-
removeEventListener(type: 'connect' | 'disconnect', callback: (this: this, ev: USBConnectionEvent) => void): void;
|
|
42
|
-
removeEventListener(type: 'connect' | 'disconnect', callback: EventListener): void;
|
|
43
|
-
dispatchEvent(_event: Event): boolean;
|
|
44
49
|
/**
|
|
45
50
|
* Requests a single Web USB device
|
|
46
51
|
* @param options The options to use when scanning
|
|
47
52
|
* @returns Promise containing the selected device
|
|
48
53
|
*/
|
|
49
|
-
requestDevice(options?: USBDeviceRequestOptions): Promise<
|
|
54
|
+
requestDevice(options?: USBDeviceRequestOptions): Promise<UsbDevice>;
|
|
50
55
|
/**
|
|
51
56
|
* Gets all allowed Web USB devices which are connected
|
|
52
57
|
* @returns Promise containing an array of devices
|
|
53
58
|
*/
|
|
54
|
-
getDevices(): Promise<
|
|
59
|
+
getDevices(): Promise<UsbDevice[]>;
|
|
55
60
|
private loadDevices;
|
|
56
61
|
private quickFilter;
|
|
57
62
|
private filterDevice;
|
|
@@ -60,17 +65,20 @@ declare class WebUSB implements USB {
|
|
|
60
65
|
/**
|
|
61
66
|
* Convenience method to get an array of all connected devices.
|
|
62
67
|
*/
|
|
63
|
-
declare const getDeviceList: () => Promise<
|
|
68
|
+
declare const getDeviceList: () => Promise<UsbDevice[]>;
|
|
64
69
|
/**
|
|
65
70
|
* Convenience method to get the first device with the specified VID and PID, or `undefined` if no such device is present.
|
|
66
71
|
* @param vid
|
|
67
72
|
* @param pid
|
|
68
73
|
*/
|
|
69
|
-
declare const findByIds: (vid: number, pid: number) => Promise<
|
|
74
|
+
declare const findByIds: (vid: number, pid: number) => Promise<UsbDevice | undefined>;
|
|
70
75
|
/**
|
|
71
76
|
* Convenience method to get the device with the specified serial number, or `undefined` if no such device is present.
|
|
72
77
|
* @param serialNumber
|
|
73
78
|
*/
|
|
74
|
-
declare const findBySerialNumber: (serialNumber: string) => Promise<
|
|
79
|
+
declare const findBySerialNumber: (serialNumber: string) => Promise<UsbDevice | undefined>;
|
|
80
|
+
/**
|
|
81
|
+
* Default WebUSB object (mimics navigator.usb)
|
|
82
|
+
*/
|
|
75
83
|
declare const webusb: WebUSB | USB;
|
|
76
84
|
export { webusb, WebUSB, USBOptions, getDeviceList, findByIds, findBySerialNumber, };
|
package/dist/index.js
CHANGED
|
@@ -2,132 +2,125 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findBySerialNumber = exports.findByIds = exports.getDeviceList = exports.WebUSB = exports.webusb = void 0;
|
|
4
4
|
const index_js_1 = require("../index.js");
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Hidden
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_TIMEOUT = 1000;
|
|
9
|
+
/**
|
|
10
|
+
* Hidden
|
|
11
|
+
*/
|
|
12
|
+
const toUint8Array = (data) => {
|
|
13
|
+
if (data instanceof ArrayBuffer) {
|
|
14
|
+
return new Uint8Array(data);
|
|
15
|
+
}
|
|
16
|
+
// ArrayBufferView
|
|
17
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Hidden
|
|
21
|
+
*/
|
|
22
|
+
index_js_1.UsbDevice.prototype.controlTransferIn = async function (setup, length, timeout = DEFAULT_TIMEOUT) {
|
|
23
|
+
const res = await this.nativeControlTransferIn(setup, timeout, length);
|
|
24
|
+
return {
|
|
25
|
+
data: res ? new DataView(res.buffer) : undefined,
|
|
26
|
+
status: res ? 'ok' : 'stall',
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Hidden
|
|
31
|
+
*/
|
|
32
|
+
index_js_1.UsbDevice.prototype.controlTransferOut = async function (setup, data, timeout = DEFAULT_TIMEOUT) {
|
|
33
|
+
const res = await this.nativeControlTransferOut(setup, timeout, toUint8Array(data));
|
|
34
|
+
return {
|
|
35
|
+
bytesWritten: res,
|
|
36
|
+
status: res >= 0 ? 'ok' : 'stall',
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Hidden
|
|
41
|
+
*/
|
|
42
|
+
index_js_1.UsbDevice.prototype.transferIn = async function (endpointNumber, length, timeout = DEFAULT_TIMEOUT) {
|
|
43
|
+
const res = await this.nativeTransferIn(endpointNumber, timeout, length);
|
|
44
|
+
return {
|
|
45
|
+
data: res ? new DataView(res.buffer) : undefined,
|
|
46
|
+
status: res ? 'ok' : 'stall',
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Hidden
|
|
51
|
+
*/
|
|
52
|
+
index_js_1.UsbDevice.prototype.transferOut = async function (endpointNumber, data, timeout = DEFAULT_TIMEOUT) {
|
|
53
|
+
const res = await this.nativeTransferOut(endpointNumber, timeout, toUint8Array(data));
|
|
54
|
+
return {
|
|
55
|
+
bytesWritten: res,
|
|
56
|
+
status: res >= 0 ? 'ok' : 'stall',
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Hidden
|
|
61
|
+
*/
|
|
62
|
+
index_js_1.UsbDevice.prototype.isochronousTransferIn = async function (_endpointNumber, _packetLengths) {
|
|
63
|
+
throw new Error('isochronousTransferIn error: method not implemented');
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Hidden
|
|
67
|
+
*/
|
|
68
|
+
index_js_1.UsbDevice.prototype.isochronousTransferOut = async function (_endpointNumber, _data, _packetLengths) {
|
|
69
|
+
throw new Error('isochronousTransferOut error: method not implemented');
|
|
70
|
+
};
|
|
6
71
|
class NamedError extends Error {
|
|
7
72
|
constructor(message, name) {
|
|
8
73
|
super(message);
|
|
9
74
|
this.name = name;
|
|
10
75
|
}
|
|
11
76
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
enumerable: false,
|
|
33
|
-
configurable: false,
|
|
34
|
-
value: async function (setup, data) {
|
|
35
|
-
const res = await this.nativeControlTransferOut(setup, toUint8Array(data));
|
|
36
|
-
return {
|
|
37
|
-
bytesWritten: res,
|
|
38
|
-
status: res >= 0 ? 'ok' : 'stall',
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(device, 'transferIn', {
|
|
43
|
-
enumerable: false,
|
|
44
|
-
configurable: false,
|
|
45
|
-
value: async function (endpointNumber, length) {
|
|
46
|
-
const res = await this.nativeTransferIn(endpointNumber, length);
|
|
47
|
-
return {
|
|
48
|
-
data: res ? new DataView(res.buffer) : undefined,
|
|
49
|
-
status: res ? 'ok' : 'stall',
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(device, 'transferOut', {
|
|
54
|
-
enumerable: false,
|
|
55
|
-
configurable: false,
|
|
56
|
-
value: async function (endpointNumber, data) {
|
|
57
|
-
const res = await this.nativeTransferOut(endpointNumber, toUint8Array(data));
|
|
58
|
-
return {
|
|
59
|
-
bytesWritten: res,
|
|
60
|
-
status: res >= 0 ? 'ok' : 'stall',
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
return device;
|
|
65
|
-
};
|
|
66
|
-
class WebUSB {
|
|
77
|
+
class ConnectionEvent extends Event {
|
|
78
|
+
constructor(type, eventInitDict) {
|
|
79
|
+
super(type, eventInitDict);
|
|
80
|
+
this.eventInitDict = eventInitDict;
|
|
81
|
+
}
|
|
82
|
+
get device() {
|
|
83
|
+
return this.eventInitDict.device;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* WebUSB class
|
|
88
|
+
*
|
|
89
|
+
* ### Events
|
|
90
|
+
*
|
|
91
|
+
* | Name | Event | Description |
|
|
92
|
+
* | ---- | ----- | ----------- |
|
|
93
|
+
* | `connect` | {@link USBConnectionEvent} | Device connected |
|
|
94
|
+
* | `disconnect` | {@link USBConnectionEvent} | Device disconnected |
|
|
95
|
+
*/
|
|
96
|
+
class WebUSB extends EventTarget {
|
|
67
97
|
constructor(options = {}) {
|
|
98
|
+
super();
|
|
68
99
|
this.options = options;
|
|
69
100
|
this.nativeEmitter = new index_js_1.Emitter();
|
|
70
|
-
this.emitter = new events_1.EventEmitter();
|
|
71
101
|
this.authorisedDevices = new Set();
|
|
72
102
|
this.knownDevices = new Map();
|
|
73
103
|
const deviceConnectCallback = async (device) => {
|
|
74
|
-
|
|
75
|
-
this.knownDevices.set(device.handle, webDevice);
|
|
104
|
+
this.knownDevices.set(device.handle, device);
|
|
76
105
|
// When connected, emit an event if it is an allowed device
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
type: 'connect',
|
|
80
|
-
device: webDevice
|
|
81
|
-
};
|
|
82
|
-
this.emitter.emit('connect', event);
|
|
106
|
+
if (device && this.isAuthorisedDevice(device)) {
|
|
107
|
+
this.dispatchEvent(new ConnectionEvent('connect', { device }));
|
|
83
108
|
}
|
|
84
109
|
};
|
|
85
110
|
const deviceDisconnectCallback = async (handle) => {
|
|
86
111
|
// When disconnected, emit an event if the device was a known allowed device
|
|
87
112
|
if (this.knownDevices.has(handle)) {
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
type: 'disconnect',
|
|
92
|
-
device: webDevice
|
|
93
|
-
};
|
|
94
|
-
this.emitter.emit('disconnect', event);
|
|
113
|
+
const device = this.knownDevices.get(handle);
|
|
114
|
+
if (device && this.isAuthorisedDevice(device)) {
|
|
115
|
+
this.dispatchEvent(new ConnectionEvent('disconnect', { device }));
|
|
95
116
|
}
|
|
96
117
|
this.knownDevices.delete(handle);
|
|
97
118
|
}
|
|
98
119
|
};
|
|
99
|
-
this.emitter.on('newListener', async (event) => {
|
|
100
|
-
const listenerCount = this.emitter.listenerCount(event);
|
|
101
|
-
if (listenerCount !== 0) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (event === 'connect') {
|
|
105
|
-
this.nativeEmitter.addAttach(deviceConnectCallback);
|
|
106
|
-
}
|
|
107
|
-
else if (event === 'disconnect') {
|
|
108
|
-
// Ensure we know the current devices
|
|
109
|
-
this.knownDevices.clear();
|
|
110
|
-
const devices = await (0, index_js_1.nativeGetDeviceList)();
|
|
111
|
-
devices.forEach(device => {
|
|
112
|
-
this.knownDevices.set(device.handle, augmentDevice(device));
|
|
113
|
-
});
|
|
114
|
-
this.nativeEmitter.addDetach(deviceDisconnectCallback);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
this.emitter.on('removeListener', event => {
|
|
118
|
-
const listenerCount = this.emitter.listenerCount(event);
|
|
119
|
-
if (listenerCount !== 0) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (event === 'connect') {
|
|
123
|
-
this.nativeEmitter.removeAttach(deviceConnectCallback);
|
|
124
|
-
}
|
|
125
|
-
else if (event === 'disconnect') {
|
|
126
|
-
this.knownDevices.clear();
|
|
127
|
-
this.nativeEmitter.removeDetach(deviceDisconnectCallback);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
120
|
this.nativeEmitter.start();
|
|
121
|
+
this.nativeEmitter.addAttach(deviceConnectCallback);
|
|
122
|
+
this.nativeEmitter.addDetach(deviceDisconnectCallback);
|
|
123
|
+
getDeviceList().then(devices => devices.forEach(device => this.knownDevices.set(device.handle, device)));
|
|
131
124
|
}
|
|
132
125
|
set onconnect(fn) {
|
|
133
126
|
if (this._onconnect) {
|
|
@@ -149,16 +142,6 @@ class WebUSB {
|
|
|
149
142
|
this.addEventListener('disconnect', this._ondisconnect);
|
|
150
143
|
}
|
|
151
144
|
}
|
|
152
|
-
addEventListener(type, listener) {
|
|
153
|
-
this.emitter.addListener(type, listener);
|
|
154
|
-
}
|
|
155
|
-
removeEventListener(type, callback) {
|
|
156
|
-
this.emitter.removeListener(type, callback);
|
|
157
|
-
}
|
|
158
|
-
dispatchEvent(_event) {
|
|
159
|
-
// Don't dispatch from here
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
145
|
/**
|
|
163
146
|
* Requests a single Web USB device
|
|
164
147
|
* @param options The options to use when scanning
|
|
@@ -325,7 +308,7 @@ exports.WebUSB = WebUSB;
|
|
|
325
308
|
*/
|
|
326
309
|
const getDeviceList = async () => {
|
|
327
310
|
const devices = await (0, index_js_1.nativeGetDeviceList)();
|
|
328
|
-
return devices
|
|
311
|
+
return devices;
|
|
329
312
|
};
|
|
330
313
|
exports.getDeviceList = getDeviceList;
|
|
331
314
|
/**
|
|
@@ -335,7 +318,7 @@ exports.getDeviceList = getDeviceList;
|
|
|
335
318
|
*/
|
|
336
319
|
const findByIds = async (vid, pid) => {
|
|
337
320
|
const device = await (0, index_js_1.nativeFindByIds)(vid, pid);
|
|
338
|
-
return device
|
|
321
|
+
return device;
|
|
339
322
|
};
|
|
340
323
|
exports.findByIds = findByIds;
|
|
341
324
|
/**
|
|
@@ -344,9 +327,12 @@ exports.findByIds = findByIds;
|
|
|
344
327
|
*/
|
|
345
328
|
const findBySerialNumber = async (serialNumber) => {
|
|
346
329
|
const device = await (0, index_js_1.nativeFindBySerialNumber)(serialNumber);
|
|
347
|
-
return device
|
|
330
|
+
return device;
|
|
348
331
|
};
|
|
349
332
|
exports.findBySerialNumber = findBySerialNumber;
|
|
333
|
+
/**
|
|
334
|
+
* Default WebUSB object (mimics navigator.usb)
|
|
335
|
+
*/
|
|
350
336
|
const webusb = typeof navigator !== 'undefined' && navigator.usb ? navigator.usb : new WebUSB();
|
|
351
337
|
exports.webusb = webusb;
|
|
352
338
|
//# sourceMappingURL=index.js.map
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type USBSpeed = 'low' | 'full' | 'high' | 'super' | 'superPlus';
|
|
2
|
+
|
|
3
|
+
export declare interface UsbDevice extends USBDevice {
|
|
4
|
+
/**
|
|
5
|
+
* The USB bus the device is connected to (e.g. `1-1`, `2-3.4`, etc.)
|
|
6
|
+
*/
|
|
7
|
+
bus: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The USB address the device is connected to
|
|
11
|
+
*/
|
|
12
|
+
address: number;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The USB port numbers the device is connected through (e.g. `[1]`, `[3, 4]`, etc.)
|
|
16
|
+
*/
|
|
17
|
+
ports: Array<number>
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The USB speed of the device (e.g. `Low`, `Full`, `High`, `Super`, `SuperPlus` or `undefined` if unknown)
|
|
21
|
+
*/
|
|
22
|
+
speed?: USBSpeed;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Detaches the kernel driver from the specified interface number (Linux only)
|
|
26
|
+
* @param interfaceNumber
|
|
27
|
+
*/
|
|
28
|
+
detachKernelDriver(interfaceNumber: number): Promise<void>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Attaches the kernel driver for the specified interface number (Linux only)
|
|
32
|
+
* @param interfaceNumber
|
|
33
|
+
*/
|
|
34
|
+
attachKernelDriver(interfaceNumber: number): Promise<void>;
|
|
35
|
+
}
|
|
3
36
|
export declare class Emitter {
|
|
4
37
|
constructor()
|
|
5
38
|
start(): Promise<void>
|
|
@@ -21,12 +54,16 @@ export declare class UsbDevice {
|
|
|
21
54
|
deviceClass: number
|
|
22
55
|
deviceSubclass: number
|
|
23
56
|
deviceProtocol: number
|
|
57
|
+
bus: string
|
|
58
|
+
address: number
|
|
59
|
+
ports: Array<number>
|
|
60
|
+
speed?: USBSpeed
|
|
24
61
|
get handle(): string
|
|
25
62
|
get manufacturerName(): string | null
|
|
26
63
|
get productName(): string | null
|
|
27
64
|
get serialNumber(): string | null
|
|
28
65
|
get opened(): boolean
|
|
29
|
-
get configuration(): USBConfiguration
|
|
66
|
+
get configuration(): USBConfiguration
|
|
30
67
|
get configurations(): Array<USBConfiguration>
|
|
31
68
|
open(): Promise<void>
|
|
32
69
|
close(): Promise<void>
|
|
@@ -36,13 +73,15 @@ export declare class UsbDevice {
|
|
|
36
73
|
claimInterface(interfaceNumber: number): Promise<void>
|
|
37
74
|
releaseInterface(interfaceNumber: number): Promise<void>
|
|
38
75
|
selectAlternateInterface(interfaceNumber: number, alternateSetting: number): Promise<void>
|
|
39
|
-
nativeControlTransferIn(setup: USBControlTransferParameters, length: number): Promise<Uint8Array | null>
|
|
40
|
-
nativeControlTransferOut(setup: USBControlTransferParameters, data?: Uint8Array | undefined | null): Promise<number>
|
|
41
|
-
nativeTransferIn(endpointNumber: number, length: number): Promise<Uint8Array | null>
|
|
42
|
-
nativeTransferOut(endpointNumber: number, data: Uint8Array): Promise<number>
|
|
43
|
-
|
|
44
|
-
|
|
76
|
+
nativeControlTransferIn(setup: USBControlTransferParameters, timeout: number, length: number): Promise<Uint8Array | null>
|
|
77
|
+
nativeControlTransferOut(setup: USBControlTransferParameters, timeout: number, data?: Uint8Array | undefined | null): Promise<number>
|
|
78
|
+
nativeTransferIn(endpointNumber: number, timeout: number, length: number): Promise<Uint8Array | null>
|
|
79
|
+
nativeTransferOut(endpointNumber: number, timeout: number, data: Uint8Array): Promise<number>
|
|
80
|
+
nativeIsochronousTransferIn(endpointNumber: number, packetLengths: Array<number>): Promise<USBIsochronousInTransferResult>
|
|
81
|
+
nativeIsochronousTransferOut(endpointNumber: number, data: Uint8Array, packetLengths: Array<number>): Promise<USBIsochronousOutTransferResult>
|
|
45
82
|
clearHalt(direction: USBDirection, endpointNumber: number): Promise<void>
|
|
83
|
+
detachKernelDriver(interfaceNumber: number): Promise<void>
|
|
84
|
+
attachKernelDriver(interfaceNumber: number): Promise<void>
|
|
46
85
|
}
|
|
47
86
|
|
|
48
87
|
export declare function nativeFindByIds(vendorId: number, productId: number): Promise<UsbDevice>
|
|
@@ -51,19 +90,19 @@ export declare function nativeFindBySerialNumber(serialNumber: string): Promise<
|
|
|
51
90
|
|
|
52
91
|
export declare function nativeGetDeviceList(): Promise<Array<UsbDevice>>
|
|
53
92
|
|
|
54
|
-
export interface
|
|
93
|
+
export interface UsbAlternateInterface {
|
|
55
94
|
alternateSetting: number
|
|
56
95
|
interfaceClass: number
|
|
57
96
|
interfaceSubclass: number
|
|
58
97
|
interfaceProtocol: number
|
|
59
98
|
interfaceName?: string
|
|
60
|
-
endpoints: Array<
|
|
99
|
+
endpoints: Array<UsbEndpoint>
|
|
61
100
|
}
|
|
62
101
|
|
|
63
|
-
export interface
|
|
102
|
+
export interface UsbConfiguration {
|
|
64
103
|
configurationValue: number
|
|
65
104
|
configurationName?: string
|
|
66
|
-
interfaces: Array<
|
|
105
|
+
interfaces: Array<UsbInterface>
|
|
67
106
|
}
|
|
68
107
|
|
|
69
108
|
export interface USBControlTransferParameters {
|
|
@@ -74,16 +113,16 @@ export interface USBControlTransferParameters {
|
|
|
74
113
|
index: number
|
|
75
114
|
}
|
|
76
115
|
|
|
77
|
-
export interface
|
|
116
|
+
export interface UsbEndpoint {
|
|
78
117
|
endpointNumber: number
|
|
79
118
|
direction: USBDirection
|
|
80
119
|
type: USBEndpointType
|
|
81
120
|
packetSize: number
|
|
82
121
|
}
|
|
83
122
|
|
|
84
|
-
export interface
|
|
123
|
+
export interface UsbInterface {
|
|
85
124
|
interfaceNumber: number
|
|
86
125
|
claimed: boolean
|
|
87
|
-
alternate:
|
|
88
|
-
alternates: Array<
|
|
126
|
+
alternate: UsbAlternateInterface
|
|
127
|
+
alternates: Array<UsbAlternateInterface>
|
|
89
128
|
}
|
package/index.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('@node-usb/usb-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('@node-usb/usb-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
80
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('@node-usb/usb-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('@node-usb/usb-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
96
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('@node-usb/usb-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('@node-usb/usb-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
117
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('@node-usb/usb-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('@node-usb/usb-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
133
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('@node-usb/usb-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('@node-usb/usb-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
150
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('@node-usb/usb-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('@node-usb/usb-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
166
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('@node-usb/usb-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('@node-usb/usb-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
185
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('@node-usb/usb-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('@node-usb/usb-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
201
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('@node-usb/usb-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('@node-usb/usb-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
217
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('@node-usb/usb-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('@node-usb/usb-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
237
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('@node-usb/usb-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('@node-usb/usb-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
253
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('@node-usb/usb-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('@node-usb/usb-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
274
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('@node-usb/usb-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('@node-usb/usb-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
290
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('@node-usb/usb-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('@node-usb/usb-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
308
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('@node-usb/usb-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('@node-usb/usb-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
324
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('@node-usb/usb-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('@node-usb/usb-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
342
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('@node-usb/usb-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('@node-usb/usb-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
358
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('@node-usb/usb-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('@node-usb/usb-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
376
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('@node-usb/usb-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('@node-usb/usb-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
392
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('@node-usb/usb-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('@node-usb/usb-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
410
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('@node-usb/usb-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('@node-usb/usb-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
426
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('@node-usb/usb-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('@node-usb/usb-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
443
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('@node-usb/usb-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('@node-usb/usb-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
459
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('@node-usb/usb-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('@node-usb/usb-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
479
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('@node-usb/usb-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('@node-usb/usb-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
495
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('@node-usb/usb-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('@node-usb/usb-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '3.0.0-alpha.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.
|
|
511
|
+
if (bindingPackageVersion !== '3.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 3.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
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": "3.0.0-alpha.
|
|
5
|
+
"version": "3.0.0-alpha.3",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0"
|
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@napi-rs/cli": "^3.2.0",
|
|
60
|
-
"@types/node": "^25.0.10",
|
|
61
60
|
"coffeescript": "^2.7.0",
|
|
62
61
|
"mocha": "^11.7.5",
|
|
63
62
|
"typedoc": "^0.28.16",
|
|
@@ -66,6 +65,7 @@
|
|
|
66
65
|
"napi": {
|
|
67
66
|
"binaryName": "usb",
|
|
68
67
|
"packageName": "@node-usb/usb",
|
|
68
|
+
"dtsHeaderFile": "./header.d.ts",
|
|
69
69
|
"targets": [
|
|
70
70
|
"x86_64-pc-windows-msvc",
|
|
71
71
|
"x86_64-apple-darwin",
|
|
@@ -84,15 +84,15 @@
|
|
|
84
84
|
"index.js"
|
|
85
85
|
],
|
|
86
86
|
"optionalDependencies": {
|
|
87
|
-
"@node-usb/usb-win32-x64-msvc": "3.0.0-alpha.
|
|
88
|
-
"@node-usb/usb-darwin-x64": "3.0.0-alpha.
|
|
89
|
-
"@node-usb/usb-linux-x64-gnu": "3.0.0-alpha.
|
|
90
|
-
"@node-usb/usb-linux-x64-musl": "3.0.0-alpha.
|
|
91
|
-
"@node-usb/usb-linux-arm64-gnu": "3.0.0-alpha.
|
|
92
|
-
"@node-usb/usb-win32-ia32-msvc": "3.0.0-alpha.
|
|
93
|
-
"@node-usb/usb-linux-arm-gnueabihf": "3.0.0-alpha.
|
|
94
|
-
"@node-usb/usb-darwin-arm64": "3.0.0-alpha.
|
|
95
|
-
"@node-usb/usb-linux-arm64-musl": "3.0.0-alpha.
|
|
96
|
-
"@node-usb/usb-win32-arm64-msvc": "3.0.0-alpha.
|
|
87
|
+
"@node-usb/usb-win32-x64-msvc": "3.0.0-alpha.3",
|
|
88
|
+
"@node-usb/usb-darwin-x64": "3.0.0-alpha.3",
|
|
89
|
+
"@node-usb/usb-linux-x64-gnu": "3.0.0-alpha.3",
|
|
90
|
+
"@node-usb/usb-linux-x64-musl": "3.0.0-alpha.3",
|
|
91
|
+
"@node-usb/usb-linux-arm64-gnu": "3.0.0-alpha.3",
|
|
92
|
+
"@node-usb/usb-win32-ia32-msvc": "3.0.0-alpha.3",
|
|
93
|
+
"@node-usb/usb-linux-arm-gnueabihf": "3.0.0-alpha.3",
|
|
94
|
+
"@node-usb/usb-darwin-arm64": "3.0.0-alpha.3",
|
|
95
|
+
"@node-usb/usb-linux-arm64-musl": "3.0.0-alpha.3",
|
|
96
|
+
"@node-usb/usb-win32-arm64-msvc": "3.0.0-alpha.3"
|
|
97
97
|
}
|
|
98
98
|
}
|