usb 2.3.0 → 2.3.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/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.3.1] - 2022-04-11
4
+
5
+ ### Changed
6
+ - Removed device access mutex from WebUSB API - [`501`](https://github.com/node-usb/node-usb/pull/501) ([Rob Moran](https://github.com/thegecko))
7
+
3
8
  ## [2.3.0] - 2022-04-11
4
9
 
5
10
  ### Changed
6
11
  - Changed libusb dependency to upstream v1.0.26 - [`505`](https://github.com/node-usb/node-usb/pull/505) ([Rob Moran](https://github.com/thegecko))
7
-
8
12
  - Cleaned up Windows device polling method - [`496`](https://github.com/node-usb/node-usb/pull/496) ([Alba Mendez](https://github.com/mildsunrise))
9
13
 
10
14
  ## [2.2.0] - 2022-03-25
@@ -21,7 +21,6 @@ export declare class WebUSBDevice implements USBDevice {
21
21
  productName?: string | undefined;
22
22
  serialNumber?: string | undefined;
23
23
  configurations: USBConfiguration[];
24
- private deviceMutex;
25
24
  private constructor();
26
25
  get configuration(): USBConfiguration | undefined;
27
26
  get opened(): boolean;
@@ -50,7 +50,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
50
50
  exports.WebUSBDevice = void 0;
51
51
  var usb = require("../usb");
52
52
  var util_1 = require("util");
53
- var mutex_1 = require("./mutex");
54
53
  var LIBUSB_TRANSFER_TYPE_MASK = 0x03;
55
54
  var ENDPOINT_NUMBER_MASK = 0x7f;
56
55
  var CLEAR_FEATURE = 0x01;
@@ -62,7 +61,6 @@ var WebUSBDevice = /** @class */ (function () {
62
61
  function WebUSBDevice(device) {
63
62
  this.device = device;
64
63
  this.configurations = [];
65
- this.deviceMutex = new mutex_1.Mutex();
66
64
  var usbVersion = this.decodeVersion(device.deviceDescriptor.bcdUSB);
67
65
  this.usbVersionMajor = usbVersion.major;
68
66
  this.usbVersionMinor = usbVersion.minor;
@@ -117,59 +115,46 @@ var WebUSBDevice = /** @class */ (function () {
117
115
  });
118
116
  WebUSBDevice.prototype.open = function () {
119
117
  return __awaiter(this, void 0, void 0, function () {
120
- var error_1;
121
118
  return __generator(this, function (_a) {
122
- switch (_a.label) {
123
- case 0:
124
- _a.trys.push([0, 2, 3, 4]);
125
- return [4 /*yield*/, this.deviceMutex.lock()];
126
- case 1:
127
- _a.sent();
128
- if (this.opened) {
129
- return [2 /*return*/];
130
- }
131
- this.device.open();
132
- return [3 /*break*/, 4];
133
- case 2:
134
- error_1 = _a.sent();
135
- throw new Error("open error: " + error_1);
136
- case 3:
137
- this.deviceMutex.unlock();
138
- return [7 /*endfinally*/];
139
- case 4: return [2 /*return*/];
119
+ try {
120
+ if (this.opened) {
121
+ return [2 /*return*/];
122
+ }
123
+ this.device.open();
124
+ }
125
+ catch (error) {
126
+ throw new Error("open error: " + error);
140
127
  }
128
+ return [2 /*return*/];
141
129
  });
142
130
  });
143
131
  };
144
132
  WebUSBDevice.prototype.close = function () {
145
133
  var _a;
146
134
  return __awaiter(this, void 0, void 0, function () {
147
- var _b, _c, iface, e_1_1, _error_1, error_2;
135
+ var _b, _c, iface, e_1_1, _error_1, error_1;
148
136
  var e_1, _d;
149
137
  return __generator(this, function (_e) {
150
138
  switch (_e.label) {
151
139
  case 0:
152
- _e.trys.push([0, 13, 14, 15]);
153
- return [4 /*yield*/, this.deviceMutex.lock()];
154
- case 1:
155
- _e.sent();
140
+ _e.trys.push([0, 12, , 13]);
156
141
  if (!this.opened) {
157
142
  return [2 /*return*/];
158
143
  }
144
+ _e.label = 1;
145
+ case 1:
146
+ _e.trys.push([1, 10, , 11]);
147
+ if (!this.configuration) return [3 /*break*/, 9];
159
148
  _e.label = 2;
160
149
  case 2:
161
- _e.trys.push([2, 11, , 12]);
162
- if (!this.configuration) return [3 /*break*/, 10];
150
+ _e.trys.push([2, 7, 8, 9]);
151
+ _b = __values((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.interfaces), _c = _b.next();
163
152
  _e.label = 3;
164
153
  case 3:
165
- _e.trys.push([3, 8, 9, 10]);
166
- _b = __values((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.interfaces), _c = _b.next();
167
- _e.label = 4;
168
- case 4:
169
- if (!!_c.done) return [3 /*break*/, 7];
154
+ if (!!_c.done) return [3 /*break*/, 6];
170
155
  iface = _c.value;
171
156
  return [4 /*yield*/, this._releaseInterface(iface.interfaceNumber)];
172
- case 5:
157
+ case 4:
173
158
  _e.sent();
174
159
  // Re-create the USBInterface to set the claimed attribute
175
160
  this.configuration.interfaces[this.configuration.interfaces.indexOf(iface)] = {
@@ -178,49 +163,42 @@ var WebUSBDevice = /** @class */ (function () {
178
163
  alternates: iface.alternates,
179
164
  claimed: false
180
165
  };
181
- _e.label = 6;
182
- case 6:
166
+ _e.label = 5;
167
+ case 5:
183
168
  _c = _b.next();
184
- return [3 /*break*/, 4];
185
- case 7: return [3 /*break*/, 10];
186
- case 8:
169
+ return [3 /*break*/, 3];
170
+ case 6: return [3 /*break*/, 9];
171
+ case 7:
187
172
  e_1_1 = _e.sent();
188
173
  e_1 = { error: e_1_1 };
189
- return [3 /*break*/, 10];
190
- case 9:
174
+ return [3 /*break*/, 9];
175
+ case 8:
191
176
  try {
192
177
  if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
193
178
  }
194
179
  finally { if (e_1) throw e_1.error; }
195
180
  return [7 /*endfinally*/];
196
- case 10: return [3 /*break*/, 12];
197
- case 11:
181
+ case 9: return [3 /*break*/, 11];
182
+ case 10:
198
183
  _error_1 = _e.sent();
199
- return [3 /*break*/, 12];
200
- case 12:
184
+ return [3 /*break*/, 11];
185
+ case 11:
201
186
  this.device.close();
202
- return [3 /*break*/, 15];
203
- case 13:
204
- error_2 = _e.sent();
205
- throw new Error("close error: " + error_2);
206
- case 14:
207
- this.deviceMutex.unlock();
208
- return [7 /*endfinally*/];
209
- case 15: return [2 /*return*/];
187
+ return [3 /*break*/, 13];
188
+ case 12:
189
+ error_1 = _e.sent();
190
+ throw new Error("close error: " + error_1);
191
+ case 13: return [2 /*return*/];
210
192
  }
211
193
  });
212
194
  });
213
195
  };
214
196
  WebUSBDevice.prototype.selectConfiguration = function (configurationValue) {
215
197
  return __awaiter(this, void 0, void 0, function () {
216
- var config, setConfiguration, error_3;
198
+ var config, setConfiguration, error_2;
217
199
  return __generator(this, function (_a) {
218
200
  switch (_a.label) {
219
201
  case 0:
220
- _a.trys.push([0, , 6, 7]);
221
- return [4 /*yield*/, this.deviceMutex.lock()];
222
- case 1:
223
- _a.sent();
224
202
  if (!this.opened || !this.device.configDescriptor) {
225
203
  throw new Error('selectConfiguration error: invalid state');
226
204
  }
@@ -231,22 +209,18 @@ var WebUSBDevice = /** @class */ (function () {
231
209
  if (!config) {
232
210
  throw new Error('selectConfiguration error: configuration not found');
233
211
  }
234
- _a.label = 2;
235
- case 2:
236
- _a.trys.push([2, 4, , 5]);
212
+ _a.label = 1;
213
+ case 1:
214
+ _a.trys.push([1, 3, , 4]);
237
215
  setConfiguration = util_1.promisify(this.device.setConfiguration).bind(this.device);
238
216
  return [4 /*yield*/, setConfiguration(configurationValue)];
239
- case 3:
217
+ case 2:
240
218
  _a.sent();
241
- return [3 /*break*/, 5];
242
- case 4:
243
- error_3 = _a.sent();
244
- throw new Error("selectConfiguration error: " + error_3);
245
- case 5: return [3 /*break*/, 7];
246
- case 6:
247
- this.deviceMutex.unlock();
248
- return [7 /*endfinally*/];
249
- case 7: return [2 /*return*/];
219
+ return [3 /*break*/, 4];
220
+ case 3:
221
+ error_2 = _a.sent();
222
+ throw new Error("selectConfiguration error: " + error_2);
223
+ case 4: return [2 /*return*/];
250
224
  }
251
225
  });
252
226
  });
@@ -255,44 +229,33 @@ var WebUSBDevice = /** @class */ (function () {
255
229
  return __awaiter(this, void 0, void 0, function () {
256
230
  var iface;
257
231
  return __generator(this, function (_a) {
258
- switch (_a.label) {
259
- case 0:
260
- _a.trys.push([0, , 2, 3]);
261
- return [4 /*yield*/, this.deviceMutex.lock()];
262
- case 1:
263
- _a.sent();
264
- if (!this.opened) {
265
- throw new Error('claimInterface error: invalid state');
266
- }
267
- if (!this.configuration) {
268
- throw new Error('claimInterface error: interface not found');
269
- }
270
- iface = this.configuration.interfaces.find(function (usbInterface) { return usbInterface.interfaceNumber === interfaceNumber; });
271
- if (!iface) {
272
- throw new Error('claimInterface error: interface not found');
273
- }
274
- if (iface.claimed) {
275
- return [2 /*return*/];
276
- }
277
- try {
278
- this.device.interface(interfaceNumber).claim();
279
- // Re-create the USBInterface to set the claimed attribute
280
- this.configuration.interfaces[this.configuration.interfaces.indexOf(iface)] = {
281
- interfaceNumber: interfaceNumber,
282
- alternate: iface.alternate,
283
- alternates: iface.alternates,
284
- claimed: true
285
- };
286
- }
287
- catch (error) {
288
- throw new Error("claimInterface error: " + error);
289
- }
290
- return [3 /*break*/, 3];
291
- case 2:
292
- this.deviceMutex.unlock();
293
- return [7 /*endfinally*/];
294
- case 3: return [2 /*return*/];
232
+ if (!this.opened) {
233
+ throw new Error('claimInterface error: invalid state');
295
234
  }
235
+ if (!this.configuration) {
236
+ throw new Error('claimInterface error: interface not found');
237
+ }
238
+ iface = this.configuration.interfaces.find(function (usbInterface) { return usbInterface.interfaceNumber === interfaceNumber; });
239
+ if (!iface) {
240
+ throw new Error('claimInterface error: interface not found');
241
+ }
242
+ if (iface.claimed) {
243
+ return [2 /*return*/];
244
+ }
245
+ try {
246
+ this.device.interface(interfaceNumber).claim();
247
+ // Re-create the USBInterface to set the claimed attribute
248
+ this.configuration.interfaces[this.configuration.interfaces.indexOf(iface)] = {
249
+ interfaceNumber: interfaceNumber,
250
+ alternate: iface.alternate,
251
+ alternates: iface.alternates,
252
+ claimed: true
253
+ };
254
+ }
255
+ catch (error) {
256
+ throw new Error("claimInterface error: " + error);
257
+ }
258
+ return [2 /*return*/];
296
259
  });
297
260
  });
298
261
  };
@@ -301,13 +264,8 @@ var WebUSBDevice = /** @class */ (function () {
301
264
  var iface;
302
265
  return __generator(this, function (_a) {
303
266
  switch (_a.label) {
304
- case 0:
305
- _a.trys.push([0, , 3, 4]);
306
- return [4 /*yield*/, this.deviceMutex.lock()];
267
+ case 0: return [4 /*yield*/, this._releaseInterface(interfaceNumber)];
307
268
  case 1:
308
- _a.sent();
309
- return [4 /*yield*/, this._releaseInterface(interfaceNumber)];
310
- case 2:
311
269
  _a.sent();
312
270
  if (this.configuration) {
313
271
  iface = this.configuration.interfaces.find(function (usbInterface) { return usbInterface.interfaceNumber === interfaceNumber; });
@@ -321,25 +279,17 @@ var WebUSBDevice = /** @class */ (function () {
321
279
  };
322
280
  }
323
281
  }
324
- return [3 /*break*/, 4];
325
- case 3:
326
- this.deviceMutex.unlock();
327
- return [7 /*endfinally*/];
328
- case 4: return [2 /*return*/];
282
+ return [2 /*return*/];
329
283
  }
330
284
  });
331
285
  });
332
286
  };
333
287
  WebUSBDevice.prototype.selectAlternateInterface = function (interfaceNumber, alternateSetting) {
334
288
  return __awaiter(this, void 0, void 0, function () {
335
- var iface, iface_1, setAltSetting, error_4;
289
+ var iface, iface_1, setAltSetting, error_3;
336
290
  return __generator(this, function (_a) {
337
291
  switch (_a.label) {
338
292
  case 0:
339
- _a.trys.push([0, , 6, 7]);
340
- return [4 /*yield*/, this.deviceMutex.lock()];
341
- case 1:
342
- _a.sent();
343
293
  if (!this.opened) {
344
294
  throw new Error('selectAlternateInterface error: invalid state');
345
295
  }
@@ -353,230 +303,190 @@ var WebUSBDevice = /** @class */ (function () {
353
303
  if (!iface.claimed) {
354
304
  throw new Error('selectAlternateInterface error: invalid state');
355
305
  }
356
- _a.label = 2;
357
- case 2:
358
- _a.trys.push([2, 4, , 5]);
306
+ _a.label = 1;
307
+ case 1:
308
+ _a.trys.push([1, 3, , 4]);
359
309
  iface_1 = this.device.interface(interfaceNumber);
360
310
  setAltSetting = util_1.promisify(iface_1.setAltSetting).bind(iface_1);
361
311
  return [4 /*yield*/, setAltSetting(alternateSetting)];
362
- case 3:
312
+ case 2:
363
313
  _a.sent();
364
- return [3 /*break*/, 5];
365
- case 4:
366
- error_4 = _a.sent();
367
- throw new Error("selectAlternateInterface error: " + error_4);
368
- case 5: return [3 /*break*/, 7];
369
- case 6:
370
- this.deviceMutex.unlock();
371
- return [7 /*endfinally*/];
372
- case 7: return [2 /*return*/];
314
+ return [3 /*break*/, 4];
315
+ case 3:
316
+ error_3 = _a.sent();
317
+ throw new Error("selectAlternateInterface error: " + error_3);
318
+ case 4: return [2 /*return*/];
373
319
  }
374
320
  });
375
321
  });
376
322
  };
377
323
  WebUSBDevice.prototype.controlTransferIn = function (setup, length) {
378
324
  return __awaiter(this, void 0, void 0, function () {
379
- var type, controlTransfer, result, error_5;
325
+ var type, controlTransfer, result, error_4;
380
326
  return __generator(this, function (_a) {
381
327
  switch (_a.label) {
382
328
  case 0:
383
- _a.trys.push([0, 3, 4, 5]);
384
- return [4 /*yield*/, this.deviceMutex.lock()];
385
- case 1:
386
- _a.sent();
329
+ _a.trys.push([0, 2, , 3]);
387
330
  type = this.controlTransferParamsToType(setup, usb.LIBUSB_ENDPOINT_IN);
388
331
  controlTransfer = util_1.promisify(this.device.controlTransfer).bind(this.device);
389
332
  return [4 /*yield*/, controlTransfer(type, setup.request, setup.value, setup.index, length)];
390
- case 2:
333
+ case 1:
391
334
  result = _a.sent();
392
335
  return [2 /*return*/, {
393
336
  data: result ? new DataView(new Uint8Array(result).buffer) : undefined,
394
337
  status: 'ok'
395
338
  }];
396
- case 3:
397
- error_5 = _a.sent();
398
- if (error_5.errno === usb.LIBUSB_TRANSFER_STALL) {
339
+ case 2:
340
+ error_4 = _a.sent();
341
+ if (error_4.errno === usb.LIBUSB_TRANSFER_STALL) {
399
342
  return [2 /*return*/, {
400
343
  status: 'stall'
401
344
  }];
402
345
  }
403
- if (error_5.errno === usb.LIBUSB_TRANSFER_OVERFLOW) {
346
+ if (error_4.errno === usb.LIBUSB_TRANSFER_OVERFLOW) {
404
347
  return [2 /*return*/, {
405
348
  status: 'babble'
406
349
  }];
407
350
  }
408
- throw new Error("controlTransferIn error: " + error_5);
409
- case 4:
410
- this.deviceMutex.unlock();
411
- return [7 /*endfinally*/];
412
- case 5: return [2 /*return*/];
351
+ throw new Error("controlTransferIn error: " + error_4);
352
+ case 3: return [2 /*return*/];
413
353
  }
414
354
  });
415
355
  });
416
356
  };
417
357
  WebUSBDevice.prototype.controlTransferOut = function (setup, data) {
418
358
  return __awaiter(this, void 0, void 0, function () {
419
- var type, controlTransfer, buffer, bytesWritten, error_6;
359
+ var type, controlTransfer, buffer, bytesWritten, error_5;
420
360
  return __generator(this, function (_a) {
421
361
  switch (_a.label) {
422
362
  case 0:
423
- _a.trys.push([0, 3, 4, 5]);
424
- return [4 /*yield*/, this.deviceMutex.lock()];
425
- case 1:
426
- _a.sent();
363
+ _a.trys.push([0, 2, , 3]);
427
364
  type = this.controlTransferParamsToType(setup, usb.LIBUSB_ENDPOINT_OUT);
428
365
  controlTransfer = util_1.promisify(this.device.controlTransfer).bind(this.device);
429
366
  buffer = data ? Buffer.from(data) : Buffer.alloc(0);
430
367
  return [4 /*yield*/, controlTransfer(type, setup.request, setup.value, setup.index, buffer)];
431
- case 2:
368
+ case 1:
432
369
  bytesWritten = _a.sent();
433
370
  return [2 /*return*/, {
434
371
  bytesWritten: bytesWritten,
435
372
  status: 'ok'
436
373
  }];
437
- case 3:
438
- error_6 = _a.sent();
439
- if (error_6.errno === usb.LIBUSB_TRANSFER_STALL) {
374
+ case 2:
375
+ error_5 = _a.sent();
376
+ if (error_5.errno === usb.LIBUSB_TRANSFER_STALL) {
440
377
  return [2 /*return*/, {
441
378
  bytesWritten: 0,
442
379
  status: 'stall'
443
380
  }];
444
381
  }
445
- throw new Error("controlTransferOut error: " + error_6);
446
- case 4:
447
- this.deviceMutex.unlock();
448
- return [7 /*endfinally*/];
449
- case 5: return [2 /*return*/];
382
+ throw new Error("controlTransferOut error: " + error_5);
383
+ case 3: return [2 /*return*/];
450
384
  }
451
385
  });
452
386
  });
453
387
  };
454
388
  WebUSBDevice.prototype.clearHalt = function (direction, endpointNumber) {
455
389
  return __awaiter(this, void 0, void 0, function () {
456
- var wIndex, controlTransfer, error_7;
390
+ var wIndex, controlTransfer, error_6;
457
391
  return __generator(this, function (_a) {
458
392
  switch (_a.label) {
459
393
  case 0:
460
- _a.trys.push([0, 3, 4, 5]);
461
- return [4 /*yield*/, this.deviceMutex.lock()];
462
- case 1:
463
- _a.sent();
394
+ _a.trys.push([0, 2, , 3]);
464
395
  wIndex = endpointNumber | (direction === 'in' ? usb.LIBUSB_ENDPOINT_IN : usb.LIBUSB_ENDPOINT_OUT);
465
396
  controlTransfer = util_1.promisify(this.device.controlTransfer).bind(this.device);
466
397
  return [4 /*yield*/, controlTransfer(usb.LIBUSB_RECIPIENT_ENDPOINT, CLEAR_FEATURE, ENDPOINT_HALT, wIndex, 0)];
467
- case 2:
398
+ case 1:
468
399
  _a.sent();
469
- return [3 /*break*/, 5];
470
- case 3:
471
- error_7 = _a.sent();
472
- throw new Error("clearHalt error: " + error_7);
473
- case 4:
474
- this.deviceMutex.unlock();
475
- return [7 /*endfinally*/];
476
- case 5: return [2 /*return*/];
400
+ return [3 /*break*/, 3];
401
+ case 2:
402
+ error_6 = _a.sent();
403
+ throw new Error("clearHalt error: " + error_6);
404
+ case 3: return [2 /*return*/];
477
405
  }
478
406
  });
479
407
  });
480
408
  };
481
409
  WebUSBDevice.prototype.transferIn = function (endpointNumber, length) {
482
410
  return __awaiter(this, void 0, void 0, function () {
483
- var endpoint, transfer, result, error_8;
411
+ var endpoint, transfer, result, error_7;
484
412
  return __generator(this, function (_a) {
485
413
  switch (_a.label) {
486
414
  case 0:
487
- _a.trys.push([0, 3, 4, 5]);
488
- return [4 /*yield*/, this.deviceMutex.lock()];
489
- case 1:
490
- _a.sent();
415
+ _a.trys.push([0, 2, , 3]);
491
416
  endpoint = this.getEndpoint(endpointNumber | usb.LIBUSB_ENDPOINT_IN);
492
417
  transfer = util_1.promisify(endpoint.transfer).bind(endpoint);
493
418
  return [4 /*yield*/, transfer(length)];
494
- case 2:
419
+ case 1:
495
420
  result = _a.sent();
496
421
  return [2 /*return*/, {
497
422
  data: result ? new DataView(new Uint8Array(result).buffer) : undefined,
498
423
  status: 'ok'
499
424
  }];
500
- case 3:
501
- error_8 = _a.sent();
502
- if (error_8.errno === usb.LIBUSB_TRANSFER_STALL) {
425
+ case 2:
426
+ error_7 = _a.sent();
427
+ if (error_7.errno === usb.LIBUSB_TRANSFER_STALL) {
503
428
  return [2 /*return*/, {
504
429
  status: 'stall'
505
430
  }];
506
431
  }
507
- if (error_8.errno === usb.LIBUSB_TRANSFER_OVERFLOW) {
432
+ if (error_7.errno === usb.LIBUSB_TRANSFER_OVERFLOW) {
508
433
  return [2 /*return*/, {
509
434
  status: 'babble'
510
435
  }];
511
436
  }
512
- throw new Error("transferIn error: " + error_8);
513
- case 4:
514
- this.deviceMutex.unlock();
515
- return [7 /*endfinally*/];
516
- case 5: return [2 /*return*/];
437
+ throw new Error("transferIn error: " + error_7);
438
+ case 3: return [2 /*return*/];
517
439
  }
518
440
  });
519
441
  });
520
442
  };
521
443
  WebUSBDevice.prototype.transferOut = function (endpointNumber, data) {
522
444
  return __awaiter(this, void 0, void 0, function () {
523
- var endpoint, transfer, buffer, bytesWritten, error_9;
445
+ var endpoint, transfer, buffer, bytesWritten, error_8;
524
446
  return __generator(this, function (_a) {
525
447
  switch (_a.label) {
526
448
  case 0:
527
- _a.trys.push([0, 3, 4, 5]);
528
- return [4 /*yield*/, this.deviceMutex.lock()];
529
- case 1:
530
- _a.sent();
449
+ _a.trys.push([0, 2, , 3]);
531
450
  endpoint = this.getEndpoint(endpointNumber | usb.LIBUSB_ENDPOINT_OUT);
532
451
  transfer = util_1.promisify(endpoint.transfer).bind(endpoint);
533
452
  buffer = Buffer.from(data);
534
453
  return [4 /*yield*/, transfer(buffer)];
535
- case 2:
454
+ case 1:
536
455
  bytesWritten = _a.sent();
537
456
  return [2 /*return*/, {
538
457
  bytesWritten: bytesWritten,
539
458
  status: 'ok'
540
459
  }];
541
- case 3:
542
- error_9 = _a.sent();
543
- if (error_9.errno === usb.LIBUSB_TRANSFER_STALL) {
460
+ case 2:
461
+ error_8 = _a.sent();
462
+ if (error_8.errno === usb.LIBUSB_TRANSFER_STALL) {
544
463
  return [2 /*return*/, {
545
464
  bytesWritten: 0,
546
465
  status: 'stall'
547
466
  }];
548
467
  }
549
- throw new Error("transferOut error: " + error_9);
550
- case 4:
551
- this.deviceMutex.unlock();
552
- return [7 /*endfinally*/];
553
- case 5: return [2 /*return*/];
468
+ throw new Error("transferOut error: " + error_8);
469
+ case 3: return [2 /*return*/];
554
470
  }
555
471
  });
556
472
  });
557
473
  };
558
474
  WebUSBDevice.prototype.reset = function () {
559
475
  return __awaiter(this, void 0, void 0, function () {
560
- var reset, error_10;
476
+ var reset, error_9;
561
477
  return __generator(this, function (_a) {
562
478
  switch (_a.label) {
563
479
  case 0:
564
- _a.trys.push([0, 3, 4, 5]);
565
- return [4 /*yield*/, this.deviceMutex.lock()];
566
- case 1:
567
- _a.sent();
480
+ _a.trys.push([0, 2, , 3]);
568
481
  reset = util_1.promisify(this.device.reset).bind(this.device);
569
482
  return [4 /*yield*/, reset()];
570
- case 2:
483
+ case 1:
571
484
  _a.sent();
572
- return [3 /*break*/, 5];
573
- case 3:
574
- error_10 = _a.sent();
575
- throw new Error("reset error: " + error_10);
576
- case 4:
577
- this.deviceMutex.unlock();
578
- return [7 /*endfinally*/];
579
- case 5: return [2 /*return*/];
485
+ return [3 /*break*/, 3];
486
+ case 2:
487
+ error_9 = _a.sent();
488
+ throw new Error("reset error: " + error_9);
489
+ case 3: return [2 /*return*/];
580
490
  }
581
491
  });
582
492
  });
@@ -604,44 +514,40 @@ var WebUSBDevice = /** @class */ (function () {
604
514
  };
605
515
  WebUSBDevice.prototype.initialize = function () {
606
516
  return __awaiter(this, void 0, void 0, function () {
607
- var _a, _b, _c, _d, error_11;
517
+ var _a, _b, _c, _d, error_10;
608
518
  return __generator(this, function (_e) {
609
519
  switch (_e.label) {
610
520
  case 0:
611
- _e.trys.push([0, 6, 7, 8]);
612
- return [4 /*yield*/, this.deviceMutex.lock()];
613
- case 1:
614
- _e.sent();
521
+ _e.trys.push([0, 5, 6, 7]);
615
522
  if (!this.opened) {
616
523
  this.device.open();
617
524
  }
618
525
  _a = this;
619
526
  return [4 /*yield*/, this.getStringDescriptor(this.device.deviceDescriptor.iManufacturer)];
620
- case 2:
527
+ case 1:
621
528
  _a.manufacturerName = _e.sent();
622
529
  _b = this;
623
530
  return [4 /*yield*/, this.getStringDescriptor(this.device.deviceDescriptor.iProduct)];
624
- case 3:
531
+ case 2:
625
532
  _b.productName = _e.sent();
626
533
  _c = this;
627
534
  return [4 /*yield*/, this.getStringDescriptor(this.device.deviceDescriptor.iSerialNumber)];
628
- case 4:
535
+ case 3:
629
536
  _c.serialNumber = _e.sent();
630
537
  _d = this;
631
538
  return [4 /*yield*/, this.getConfigurations()];
632
- case 5:
539
+ case 4:
633
540
  _d.configurations = _e.sent();
634
- return [3 /*break*/, 8];
541
+ return [3 /*break*/, 7];
542
+ case 5:
543
+ error_10 = _e.sent();
544
+ throw new Error("initialize error: " + error_10);
635
545
  case 6:
636
- error_11 = _e.sent();
637
- throw new Error("initialize error: " + error_11);
638
- case 7:
639
546
  if (this.opened) {
640
547
  this.device.close();
641
548
  }
642
- this.deviceMutex.unlock();
643
549
  return [7 /*endfinally*/];
644
- case 8: return [2 /*return*/];
550
+ case 7: return [2 /*return*/];
645
551
  }
646
552
  });
647
553
  });
@@ -656,7 +562,7 @@ var WebUSBDevice = /** @class */ (function () {
656
562
  };
657
563
  WebUSBDevice.prototype.getStringDescriptor = function (index) {
658
564
  return __awaiter(this, void 0, void 0, function () {
659
- var getStringDescriptor, buffer, error_12;
565
+ var getStringDescriptor, buffer, error_11;
660
566
  return __generator(this, function (_a) {
661
567
  switch (_a.label) {
662
568
  case 0:
@@ -667,7 +573,7 @@ var WebUSBDevice = /** @class */ (function () {
667
573
  buffer = _a.sent();
668
574
  return [2 /*return*/, buffer ? buffer.toString() : ''];
669
575
  case 2:
670
- error_12 = _a.sent();
576
+ error_11 = _a.sent();
671
577
  return [2 /*return*/, ''];
672
578
  case 3: return [2 /*return*/];
673
579
  }
@@ -862,7 +768,7 @@ var WebUSBDevice = /** @class */ (function () {
862
768
  };
863
769
  WebUSBDevice.prototype._releaseInterface = function (interfaceNumber) {
864
770
  return __awaiter(this, void 0, void 0, function () {
865
- var iface, iface_3, release, error_13;
771
+ var iface, iface_3, release, error_12;
866
772
  return __generator(this, function (_a) {
867
773
  switch (_a.label) {
868
774
  case 0:
@@ -889,8 +795,8 @@ var WebUSBDevice = /** @class */ (function () {
889
795
  _a.sent();
890
796
  return [3 /*break*/, 4];
891
797
  case 3:
892
- error_13 = _a.sent();
893
- throw new Error("releaseInterface error: " + error_13);
798
+ error_12 = _a.sent();
799
+ throw new Error("releaseInterface error: " + error_12);
894
800
  case 4: return [2 /*return*/];
895
801
  }
896
802
  });
@@ -1 +1 @@
1
- {"version":3,"file":"webusb-device.js","sourceRoot":"","sources":["../../tsc/webusb/webusb-device.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA8B;AAC9B,6BAAiC;AAEjC,iCAAgC;AAEhC,IAAM,yBAAyB,GAAG,IAAI,CAAC;AACvC,IAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,IAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,IAAM,aAAa,GAAG,IAAI,CAAC;AAE3B;;GAEG;AACH;IA8BI,sBAA4B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAJvC,mBAAc,GAAuB,EAAE,CAAC;QAEvC,gBAAW,GAAG,IAAI,aAAK,EAAE,CAAC;QAG9B,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACtE,IAAI,CAAC,eAAe,GAA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C,yBAAyB;gBAC3D,CAAC,CAAC,GAAG,CAAC,0BAA0B,CAAC;QAEzC,OAAO,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;IAC/C,CAAC;IAEa,wCAAiB,GAA/B,UAAgC,eAAuB;;;;;;wBACnD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;4BACd,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;yBAC5D;wBAED,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;4BACrB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;yBAClE;wBAEK,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,UAAA,YAAY,IAAI,OAAA,YAAY,CAAC,eAAe,KAAK,eAAe,EAAhD,CAAgD,CAAC,CAAC;wBACnH,IAAI,CAAC,KAAK,EAAE;4BACR,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;yBAClE;wBAED,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;4BAChB,sBAAO;yBACV;;;;wBAGS,UAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;wBAC/C,OAAO,GAAG,gBAAS,CAAC,OAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAK,CAAC,CAAC;wBACrD,qBAAM,OAAO,EAAE,EAAA;;wBAAf,SAAe,CAAC;;;;wBAEhB,MAAM,IAAI,KAAK,CAAC,6BAA2B,QAAO,CAAC,CAAC;;;;;KAE3D;IACL,mBAAC;AAAD,CAAC,AA7dD,IA6dC;AA7dY,oCAAY"}
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.3.0",
5
+ "version": "2.3.1",
6
6
  "main": "dist/index.js",
7
7
  "engines": {
8
8
  "node": ">=10.16.0"
Binary file
Binary file
@@ -1,7 +1,6 @@
1
1
  import * as usb from '../usb';
2
2
  import { promisify } from 'util';
3
3
  import { Endpoint, InEndpoint, OutEndpoint } from '../usb/endpoint';
4
- import { Mutex } from './mutex';
5
4
 
6
5
  const LIBUSB_TRANSFER_TYPE_MASK = 0x03;
7
6
  const ENDPOINT_NUMBER_MASK = 0x7f;
@@ -39,8 +38,6 @@ export class WebUSBDevice implements USBDevice {
39
38
  public serialNumber?: string | undefined;
40
39
  public configurations: USBConfiguration[] = [];
41
40
 
42
- private deviceMutex = new Mutex();
43
-
44
41
  private constructor(private device: usb.Device) {
45
42
  const usbVersion = this.decodeVersion(device.deviceDescriptor.bcdUSB);
46
43
  this.usbVersionMajor = usbVersion.major;
@@ -73,8 +70,6 @@ export class WebUSBDevice implements USBDevice {
73
70
 
74
71
  public async open(): Promise<void> {
75
72
  try {
76
- await this.deviceMutex.lock();
77
-
78
73
  if (this.opened) {
79
74
  return;
80
75
  }
@@ -82,15 +77,11 @@ export class WebUSBDevice implements USBDevice {
82
77
  this.device.open();
83
78
  } catch (error) {
84
79
  throw new Error(`open error: ${error}`);
85
- } finally {
86
- this.deviceMutex.unlock();
87
80
  }
88
81
  }
89
82
 
90
83
  public async close(): Promise<void> {
91
84
  try {
92
- await this.deviceMutex.lock();
93
-
94
85
  if (!this.opened) {
95
86
  return;
96
87
  }
@@ -115,137 +106,110 @@ export class WebUSBDevice implements USBDevice {
115
106
  this.device.close();
116
107
  } catch (error) {
117
108
  throw new Error(`close error: ${error}`);
118
- } finally {
119
- this.deviceMutex.unlock();
120
109
  }
121
110
  }
122
111
 
123
112
  public async selectConfiguration(configurationValue: number): Promise<void> {
124
- try {
125
- await this.deviceMutex.lock();
126
-
127
- if (!this.opened || !this.device.configDescriptor) {
128
- throw new Error('selectConfiguration error: invalid state');
129
- }
113
+ if (!this.opened || !this.device.configDescriptor) {
114
+ throw new Error('selectConfiguration error: invalid state');
115
+ }
130
116
 
131
- if (this.device.configDescriptor.bConfigurationValue === configurationValue) {
132
- return;
133
- }
117
+ if (this.device.configDescriptor.bConfigurationValue === configurationValue) {
118
+ return;
119
+ }
134
120
 
135
- const config = this.configurations.find(configuration => configuration.configurationValue === configurationValue);
136
- if (!config) {
137
- throw new Error('selectConfiguration error: configuration not found');
138
- }
121
+ const config = this.configurations.find(configuration => configuration.configurationValue === configurationValue);
122
+ if (!config) {
123
+ throw new Error('selectConfiguration error: configuration not found');
124
+ }
139
125
 
140
- try {
141
- const setConfiguration = promisify(this.device.setConfiguration).bind(this.device);
142
- await setConfiguration(configurationValue);
143
- } catch (error) {
144
- throw new Error(`selectConfiguration error: ${error}`);
145
- }
146
- } finally {
147
- this.deviceMutex.unlock();
126
+ try {
127
+ const setConfiguration = promisify(this.device.setConfiguration).bind(this.device);
128
+ await setConfiguration(configurationValue);
129
+ } catch (error) {
130
+ throw new Error(`selectConfiguration error: ${error}`);
148
131
  }
149
132
  }
150
133
 
151
134
  public async claimInterface(interfaceNumber: number): Promise<void> {
152
- try {
153
- await this.deviceMutex.lock();
135
+ if (!this.opened) {
136
+ throw new Error('claimInterface error: invalid state');
137
+ }
154
138
 
155
- if (!this.opened) {
156
- throw new Error('claimInterface error: invalid state');
157
- }
139
+ if (!this.configuration) {
140
+ throw new Error('claimInterface error: interface not found');
141
+ }
158
142
 
159
- if (!this.configuration) {
160
- throw new Error('claimInterface error: interface not found');
161
- }
143
+ const iface = this.configuration.interfaces.find(usbInterface => usbInterface.interfaceNumber === interfaceNumber);
144
+ if (!iface) {
145
+ throw new Error('claimInterface error: interface not found');
146
+ }
162
147
 
163
- const iface = this.configuration.interfaces.find(usbInterface => usbInterface.interfaceNumber === interfaceNumber);
164
- if (!iface) {
165
- throw new Error('claimInterface error: interface not found');
166
- }
148
+ if (iface.claimed) {
149
+ return;
150
+ }
167
151
 
168
- if (iface.claimed) {
169
- return;
170
- }
152
+ try {
153
+ this.device.interface(interfaceNumber).claim();
154
+
155
+ // Re-create the USBInterface to set the claimed attribute
156
+ this.configuration.interfaces[this.configuration.interfaces.indexOf(iface)] = {
157
+ interfaceNumber,
158
+ alternate: iface.alternate,
159
+ alternates: iface.alternates,
160
+ claimed: true
161
+ };
162
+ } catch (error) {
163
+ throw new Error(`claimInterface error: ${error}`);
164
+ }
165
+ }
171
166
 
172
- try {
173
- this.device.interface(interfaceNumber).claim();
167
+ public async releaseInterface(interfaceNumber: number): Promise<void> {
168
+ await this._releaseInterface(interfaceNumber);
174
169
 
170
+ if (this.configuration) {
171
+ const iface = this.configuration.interfaces.find(usbInterface => usbInterface.interfaceNumber === interfaceNumber);
172
+ if (iface) {
175
173
  // Re-create the USBInterface to set the claimed attribute
176
174
  this.configuration.interfaces[this.configuration.interfaces.indexOf(iface)] = {
177
175
  interfaceNumber,
178
176
  alternate: iface.alternate,
179
177
  alternates: iface.alternates,
180
- claimed: true
178
+ claimed: false
181
179
  };
182
- } catch (error) {
183
- throw new Error(`claimInterface error: ${error}`);
184
- }
185
- } finally {
186
- this.deviceMutex.unlock();
187
- }
188
- }
189
-
190
- public async releaseInterface(interfaceNumber: number): Promise<void> {
191
- try {
192
- await this.deviceMutex.lock();
193
- await this._releaseInterface(interfaceNumber);
194
-
195
- if (this.configuration) {
196
- const iface = this.configuration.interfaces.find(usbInterface => usbInterface.interfaceNumber === interfaceNumber);
197
- if (iface) {
198
- // Re-create the USBInterface to set the claimed attribute
199
- this.configuration.interfaces[this.configuration.interfaces.indexOf(iface)] = {
200
- interfaceNumber,
201
- alternate: iface.alternate,
202
- alternates: iface.alternates,
203
- claimed: false
204
- };
205
- }
206
180
  }
207
-
208
- } finally {
209
- this.deviceMutex.unlock();
210
181
  }
211
182
  }
212
183
 
213
184
  public async selectAlternateInterface(interfaceNumber: number, alternateSetting: number): Promise<void> {
214
- try {
215
- await this.deviceMutex.lock();
216
-
217
- if (!this.opened) {
218
- throw new Error('selectAlternateInterface error: invalid state');
219
- }
185
+ if (!this.opened) {
186
+ throw new Error('selectAlternateInterface error: invalid state');
187
+ }
220
188
 
221
- if (!this.configuration) {
222
- throw new Error('selectAlternateInterface error: interface not found');
223
- }
189
+ if (!this.configuration) {
190
+ throw new Error('selectAlternateInterface error: interface not found');
191
+ }
224
192
 
225
- const iface = this.configuration.interfaces.find(usbInterface => usbInterface.interfaceNumber === interfaceNumber);
226
- if (!iface) {
227
- throw new Error('selectAlternateInterface error: interface not found');
228
- }
193
+ const iface = this.configuration.interfaces.find(usbInterface => usbInterface.interfaceNumber === interfaceNumber);
194
+ if (!iface) {
195
+ throw new Error('selectAlternateInterface error: interface not found');
196
+ }
229
197
 
230
- if (!iface.claimed) {
231
- throw new Error('selectAlternateInterface error: invalid state');
232
- }
198
+ if (!iface.claimed) {
199
+ throw new Error('selectAlternateInterface error: invalid state');
200
+ }
233
201
 
234
- try {
235
- const iface = this.device.interface(interfaceNumber);
236
- const setAltSetting = promisify(iface.setAltSetting).bind(iface);
237
- await setAltSetting(alternateSetting);
238
- } catch (error) {
239
- throw new Error(`selectAlternateInterface error: ${error}`);
240
- }
241
- } finally {
242
- this.deviceMutex.unlock();
202
+ try {
203
+ const iface = this.device.interface(interfaceNumber);
204
+ const setAltSetting = promisify(iface.setAltSetting).bind(iface);
205
+ await setAltSetting(alternateSetting);
206
+ } catch (error) {
207
+ throw new Error(`selectAlternateInterface error: ${error}`);
243
208
  }
244
209
  }
245
210
 
246
211
  public async controlTransferIn(setup: USBControlTransferParameters, length: number): Promise<USBInTransferResult> {
247
212
  try {
248
- await this.deviceMutex.lock();
249
213
  const type = this.controlTransferParamsToType(setup, usb.LIBUSB_ENDPOINT_IN);
250
214
  const controlTransfer = promisify(this.device.controlTransfer).bind(this.device);
251
215
  const result = await controlTransfer(type, setup.request, setup.value, setup.index, length);
@@ -268,14 +232,11 @@ export class WebUSBDevice implements USBDevice {
268
232
  }
269
233
 
270
234
  throw new Error(`controlTransferIn error: ${error}`);
271
- } finally {
272
- this.deviceMutex.unlock();
273
235
  }
274
236
  }
275
237
 
276
238
  public async controlTransferOut(setup: USBControlTransferParameters, data?: ArrayBuffer): Promise<USBOutTransferResult> {
277
239
  try {
278
- await this.deviceMutex.lock();
279
240
  const type = this.controlTransferParamsToType(setup, usb.LIBUSB_ENDPOINT_OUT);
280
241
  const controlTransfer = promisify(this.device.controlTransfer).bind(this.device);
281
242
  const buffer = data ? Buffer.from(data) : Buffer.alloc(0);
@@ -294,27 +255,21 @@ export class WebUSBDevice implements USBDevice {
294
255
  }
295
256
 
296
257
  throw new Error(`controlTransferOut error: ${error}`);
297
- } finally {
298
- this.deviceMutex.unlock();
299
258
  }
300
259
  }
301
260
 
302
261
  public async clearHalt(direction: USBDirection, endpointNumber: number): Promise<void> {
303
262
  try {
304
- await this.deviceMutex.lock();
305
263
  const wIndex = endpointNumber | (direction === 'in' ? usb.LIBUSB_ENDPOINT_IN : usb.LIBUSB_ENDPOINT_OUT);
306
264
  const controlTransfer = promisify(this.device.controlTransfer).bind(this.device);
307
265
  await controlTransfer(usb.LIBUSB_RECIPIENT_ENDPOINT, CLEAR_FEATURE, ENDPOINT_HALT, wIndex, 0);
308
266
  } catch (error) {
309
267
  throw new Error(`clearHalt error: ${error}`);
310
- } finally {
311
- this.deviceMutex.unlock();
312
268
  }
313
269
  }
314
270
 
315
271
  public async transferIn(endpointNumber: number, length: number): Promise<USBInTransferResult> {
316
272
  try {
317
- await this.deviceMutex.lock();
318
273
  const endpoint = this.getEndpoint(endpointNumber | usb.LIBUSB_ENDPOINT_IN) as InEndpoint;
319
274
  const transfer = promisify(endpoint.transfer).bind(endpoint);
320
275
  const result = await transfer(length);
@@ -337,14 +292,11 @@ export class WebUSBDevice implements USBDevice {
337
292
  }
338
293
 
339
294
  throw new Error(`transferIn error: ${error}`);
340
- } finally {
341
- this.deviceMutex.unlock();
342
295
  }
343
296
  }
344
297
 
345
298
  public async transferOut(endpointNumber: number, data: ArrayBuffer): Promise<USBOutTransferResult> {
346
299
  try {
347
- await this.deviceMutex.lock();
348
300
  const endpoint = this.getEndpoint(endpointNumber | usb.LIBUSB_ENDPOINT_OUT) as OutEndpoint;
349
301
  const transfer = promisify(endpoint.transfer).bind(endpoint);
350
302
  const buffer = Buffer.from(data);
@@ -363,20 +315,15 @@ export class WebUSBDevice implements USBDevice {
363
315
  }
364
316
 
365
317
  throw new Error(`transferOut error: ${error}`);
366
- } finally {
367
- this.deviceMutex.unlock();
368
318
  }
369
319
  }
370
320
 
371
321
  public async reset(): Promise<void> {
372
322
  try {
373
- await this.deviceMutex.lock();
374
323
  const reset = promisify(this.device.reset).bind(this.device);
375
324
  await reset();
376
325
  } catch (error) {
377
326
  throw new Error(`reset error: ${error}`);
378
- } finally {
379
- this.deviceMutex.unlock();
380
327
  }
381
328
  }
382
329
 
@@ -394,8 +341,6 @@ export class WebUSBDevice implements USBDevice {
394
341
 
395
342
  private async initialize(): Promise<void> {
396
343
  try {
397
- await this.deviceMutex.lock();
398
-
399
344
  if (!this.opened) {
400
345
  this.device.open();
401
346
  }
@@ -410,8 +355,6 @@ export class WebUSBDevice implements USBDevice {
410
355
  if (this.opened) {
411
356
  this.device.close();
412
357
  }
413
-
414
- this.deviceMutex.unlock();
415
358
  }
416
359
  }
417
360
 
@@ -1,22 +0,0 @@
1
- /**
2
- * A mutex implementation that can be used to lock access between concurrent async functions
3
- */
4
- export declare class Mutex {
5
- private locked;
6
- /**
7
- * Create a new Mutex
8
- */
9
- constructor();
10
- /**
11
- * Yield the current execution context, effectively moving it to the back of the promise queue
12
- */
13
- private sleep;
14
- /**
15
- * Wait until the Mutex is available and claim it
16
- */
17
- lock(): Promise<void>;
18
- /**
19
- * Unlock the Mutex
20
- */
21
- unlock(): void;
22
- }
@@ -1,89 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Mutex = void 0;
40
- /**
41
- * A mutex implementation that can be used to lock access between concurrent async functions
42
- */
43
- var Mutex = /** @class */ (function () {
44
- /**
45
- * Create a new Mutex
46
- */
47
- function Mutex() {
48
- this.locked = false;
49
- }
50
- /**
51
- * Yield the current execution context, effectively moving it to the back of the promise queue
52
- */
53
- Mutex.prototype.sleep = function () {
54
- return __awaiter(this, void 0, void 0, function () {
55
- return __generator(this, function (_a) {
56
- return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, 1); })];
57
- });
58
- });
59
- };
60
- /**
61
- * Wait until the Mutex is available and claim it
62
- */
63
- Mutex.prototype.lock = function () {
64
- return __awaiter(this, void 0, void 0, function () {
65
- return __generator(this, function (_a) {
66
- switch (_a.label) {
67
- case 0:
68
- if (!this.locked) return [3 /*break*/, 2];
69
- return [4 /*yield*/, this.sleep()];
70
- case 1:
71
- _a.sent();
72
- return [3 /*break*/, 0];
73
- case 2:
74
- this.locked = true;
75
- return [2 /*return*/];
76
- }
77
- });
78
- });
79
- };
80
- /**
81
- * Unlock the Mutex
82
- */
83
- Mutex.prototype.unlock = function () {
84
- this.locked = false;
85
- };
86
- return Mutex;
87
- }());
88
- exports.Mutex = Mutex;
89
- //# sourceMappingURL=mutex.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mutex.js","sourceRoot":"","sources":["../../tsc/webusb/mutex.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH;IAGI;;OAEG;IACH;QACI,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAED;;OAEG;IACW,qBAAK,GAAnB;;;gBACI,sBAAO,IAAI,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,EAAtB,CAAsB,CAAC,EAAC;;;KACzD;IAED;;OAEG;IACU,oBAAI,GAAjB;;;;;6BACW,IAAI,CAAC,MAAM;wBACd,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;;;wBAGvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;;;;KACtB;IAED;;OAEG;IACI,sBAAM,GAAb;QACI,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IACL,YAAC;AAAD,CAAC,AAlCD,IAkCC;AAlCY,sBAAK"}
@@ -1,38 +0,0 @@
1
- /**
2
- * A mutex implementation that can be used to lock access between concurrent async functions
3
- */
4
- export class Mutex {
5
- private locked: boolean;
6
-
7
- /**
8
- * Create a new Mutex
9
- */
10
- constructor() {
11
- this.locked = false;
12
- }
13
-
14
- /**
15
- * Yield the current execution context, effectively moving it to the back of the promise queue
16
- */
17
- private async sleep(): Promise<void> {
18
- return new Promise(resolve => setTimeout(resolve, 1));
19
- }
20
-
21
- /**
22
- * Wait until the Mutex is available and claim it
23
- */
24
- public async lock(): Promise<void> {
25
- while (this.locked) {
26
- await this.sleep();
27
- }
28
-
29
- this.locked = true;
30
- }
31
-
32
- /**
33
- * Unlock the Mutex
34
- */
35
- public unlock(): void {
36
- this.locked = false;
37
- }
38
- }