@psdk/device-webusb 0.5.12 → 0.5.13
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/build/index.js +8 -18
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/build/index.js
CHANGED
|
@@ -3,25 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DeviceFilter = exports.WebusbReadOptions = exports.Webusb = void 0;
|
|
4
4
|
const frame_father_1 = require("@psdk/frame-father");
|
|
5
5
|
class Webusb {
|
|
6
|
-
filters;
|
|
7
|
-
configuration;
|
|
8
|
-
interface;
|
|
9
|
-
readEndpoint;
|
|
10
|
-
writeEndpoint;
|
|
11
|
-
inputReadEndpoint;
|
|
12
|
-
inputWriteEndpoint;
|
|
13
|
-
state;
|
|
14
|
-
device;
|
|
15
6
|
constructor(options) {
|
|
7
|
+
var _a, _b, _c, _d;
|
|
16
8
|
if (options.filters.length == 0) {
|
|
17
9
|
throw new Error('Missing filters');
|
|
18
10
|
}
|
|
19
11
|
this.filters = options.filters;
|
|
20
|
-
this.configuration = options.configuration
|
|
21
|
-
this.interface = options.interface
|
|
12
|
+
this.configuration = (_a = options.configuration) !== null && _a !== void 0 ? _a : 1;
|
|
13
|
+
this.interface = (_b = options.interface) !== null && _b !== void 0 ? _b : 0;
|
|
22
14
|
this.state = frame_father_1.ConnectionState.DISCONNECTED;
|
|
23
|
-
this.inputReadEndpoint = options.readEndpoint
|
|
24
|
-
this.inputWriteEndpoint = options.writeEndpoint
|
|
15
|
+
this.inputReadEndpoint = (_c = options.readEndpoint) !== null && _c !== void 0 ? _c : 2;
|
|
16
|
+
this.inputWriteEndpoint = (_d = options.writeEndpoint) !== null && _d !== void 0 ? _d : 2;
|
|
25
17
|
}
|
|
26
18
|
static withFilter(filter) {
|
|
27
19
|
return this.withFilters([filter]);
|
|
@@ -88,7 +80,7 @@ class Webusb {
|
|
|
88
80
|
}
|
|
89
81
|
async read(options) {
|
|
90
82
|
const device = _device();
|
|
91
|
-
const _options = options
|
|
83
|
+
const _options = options !== null && options !== void 0 ? options : WebusbReadOptions.def();
|
|
92
84
|
const result = await device.transferIn(_readEndpoint(), _options.readLength);
|
|
93
85
|
const { status, data } = result;
|
|
94
86
|
if (status != 'ok') {
|
|
@@ -112,10 +104,10 @@ class Webusb {
|
|
|
112
104
|
}
|
|
113
105
|
exports.Webusb = Webusb;
|
|
114
106
|
class WebusbReadOptions extends frame_father_1.ReadOptions {
|
|
115
|
-
_length;
|
|
116
107
|
constructor(options) {
|
|
108
|
+
var _a;
|
|
117
109
|
super(options);
|
|
118
|
-
this._length = options
|
|
110
|
+
this._length = (_a = options === null || options === void 0 ? void 0 : options.length) !== null && _a !== void 0 ? _a : 1024;
|
|
119
111
|
}
|
|
120
112
|
static def() {
|
|
121
113
|
return new WebusbReadOptions();
|
|
@@ -126,8 +118,6 @@ class WebusbReadOptions extends frame_father_1.ReadOptions {
|
|
|
126
118
|
}
|
|
127
119
|
exports.WebusbReadOptions = WebusbReadOptions;
|
|
128
120
|
class DeviceFilter {
|
|
129
|
-
vendorId;
|
|
130
|
-
productId;
|
|
131
121
|
constructor(options) {
|
|
132
122
|
this.vendorId = options.vendorId;
|
|
133
123
|
this.productId = options.productId;
|