Skip to content

Commit 325a2d2

Browse files
committed
Fixed USBConnectionEvent type
1 parent 183e468 commit 325a2d2

File tree

5 files changed

+11
-20
lines changed

5 files changed

+11
-20
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webusb",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Node.js implementation of the WebUSB Specification",
55
"homepage": "https://github.com/thegecko/webusb",
66
"author": "Rob Moran <[email protected]>",

src/events.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@
2323
* SOFTWARE.
2424
*/
2525

26-
import { DOMEvent, W3CUSBConnectionEvent } from "./interfaces";
27-
2826
// tslint:disable:max-classes-per-file
2927

3028
/**
3129
* @hidden
3230
*/
33-
export class Event implements DOMEvent {
31+
export class DOMEvent implements Event {
3432

3533
/**
3634
* Type of the event
@@ -155,10 +153,13 @@ export class Event implements DOMEvent {
155153
}
156154
}
157155

158-
export class USBConnectionEvent extends Event implements W3CUSBConnectionEvent {
156+
/**
157+
* @hidden
158+
*/
159+
export class W3CUSBConnectionEvent extends DOMEvent implements USBConnectionEvent {
159160

160161
/**
161-
* {@link USBDevice} connected or disconnected
162+
* Device connected or disconnected
162163
*/
163164
public readonly device: USBDevice;
164165

src/interfaces.ts

-10
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@
2323
* SOFTWARE.
2424
*/
2525

26-
/**
27-
* @hidden
28-
*/
29-
export interface DOMEvent extends Event {}
30-
31-
/**
32-
* @hidden
33-
*/
34-
export interface W3CUSBConnectionEvent extends USBConnectionEvent {}
35-
3626
/**
3727
* @hidden
3828
*/

src/usb.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import { EventDispatcher, TypedDispatcher } from "./dispatcher";
2727
import { USBAdapter, adapter } from "./adapter";
28-
import { USBConnectionEvent } from "./events";
28+
import { W3CUSBConnectionEvent } from "./events";
2929
import { USBDevice } from "./device";
3030
import { W3CUSB } from "./interfaces";
3131

@@ -92,7 +92,7 @@ export class USB extends (EventDispatcher as new() => TypedDispatcher<USBEvents>
9292
const deviceConnectCallback = device => {
9393
// When connected, emit an event if it was a known allowed device
9494
if (this.replaceAllowedDevice(device)) {
95-
const event = new USBConnectionEvent(this as EventTarget, "connect", { device }) as USBConnectionEvent;
95+
const event = new W3CUSBConnectionEvent(this as EventTarget, "connect", { device }) as USBConnectionEvent;
9696
this.dispatchEvent(event);
9797

9898
if (this.onconnect) {
@@ -106,7 +106,7 @@ export class USB extends (EventDispatcher as new() => TypedDispatcher<USBEvents>
106106
const device = this.allowedDevices.find(allowedDevices => allowedDevices._handle === handle);
107107

108108
if (device) {
109-
const event = new USBConnectionEvent(this as EventTarget, "disconnect", { device }) as USBConnectionEvent;
109+
const event = new W3CUSBConnectionEvent(this as EventTarget, "disconnect", { device }) as USBConnectionEvent;
110110
this.dispatchEvent(event);
111111

112112
if (this.ondisconnect) {

0 commit comments

Comments
 (0)