Skip to content

Commit 8e7b5a5

Browse files
Prettier
1 parent 8f330a0 commit 8e7b5a5

File tree

7 files changed

+42
-42
lines changed

7 files changed

+42
-42
lines changed

lib/accelerometer-service.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export class AccelerometerService
2020
constructor(
2121
private accelerometerDataCharacteristic: BluetoothRemoteGATTCharacteristic,
2222
// @ts-ignore temporarily unused characteristic
23-
private accelerometerPeriodCharacteristic: BluetoothRemoteGATTCharacteristic
23+
private accelerometerPeriodCharacteristic: BluetoothRemoteGATTCharacteristic,
2424
) {
2525
super();
2626
this.accelerometerDataCharacteristic.addEventListener(
2727
"characteristicvaluechanged",
28-
this.dataListener
28+
this.dataListener,
2929
);
3030
}
3131

@@ -34,19 +34,19 @@ export class AccelerometerService
3434
return this.accelerometerInstance;
3535
}
3636
const accelerometerService = await gattServer.getPrimaryService(
37-
profile.accelerometer.id
37+
profile.accelerometer.id,
3838
);
3939
const accelerometerDataCharacteristic =
4040
await accelerometerService.getCharacteristic(
41-
profile.accelerometer.characteristics.data.id
41+
profile.accelerometer.characteristics.data.id,
4242
);
4343
const accelerometerPeriodCharacteristic =
4444
await accelerometerService.getCharacteristic(
45-
profile.accelerometer.characteristics.period.id
45+
profile.accelerometer.characteristics.period.id,
4646
);
4747
this.accelerometerInstance = new AccelerometerService(
4848
accelerometerDataCharacteristic,
49-
accelerometerPeriodCharacteristic
49+
accelerometerPeriodCharacteristic,
5050
);
5151
return this.accelerometerInstance;
5252
}
@@ -70,7 +70,7 @@ export class AccelerometerService
7070
const data = this.dataViewToData(target.value);
7171
this.dispatchTypedEvent(
7272
"accelerometerdatachanged",
73-
new AccelerometerDataEvent(data)
73+
new AccelerometerDataEvent(data),
7474
);
7575
};
7676

lib/bluetooth-device-wrapper.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ export class BluetoothDeviceWrapper {
5050

5151
constructor(
5252
public readonly device: BluetoothDevice,
53-
private logging: Logging = new NullLogging()
53+
private logging: Logging = new NullLogging(),
5454
) {
5555
device.addEventListener(
5656
"gattserverdisconnected",
57-
this.handleDisconnectEvent
57+
this.handleDisconnectEvent,
5858
);
5959
}
6060

@@ -65,7 +65,7 @@ export class BluetoothDeviceWrapper {
6565
});
6666
if (this.duringExplicitConnectDisconnect) {
6767
this.logging.log(
68-
"Skipping connect attempt when one is already in progress"
68+
"Skipping connect attempt when one is already in progress",
6969
);
7070
// Wait for the gattConnectPromise while showing a "connecting" dialog.
7171
// If the user clicks disconnect while the automatic reconnect is in progress,
@@ -76,7 +76,7 @@ export class BluetoothDeviceWrapper {
7676
this.duringExplicitConnectDisconnect++;
7777
if (this.device.gatt === undefined) {
7878
throw new Error(
79-
"BluetoothRemoteGATTServer for micro:bit device is undefined"
79+
"BluetoothRemoteGATTServer for micro:bit device is undefined",
8080
);
8181
}
8282
try {
@@ -95,15 +95,15 @@ export class BluetoothDeviceWrapper {
9595
// Do we still want to be connected?
9696
if (!this.connecting) {
9797
this.logging.log(
98-
"Bluetooth GATT server connect after timeout, triggering disconnect"
98+
"Bluetooth GATT server connect after timeout, triggering disconnect",
9999
);
100100
this.disconnectPromise = (async () => {
101101
await this.disconnectInternal(false);
102102
this.disconnectPromise = undefined;
103103
})();
104104
} else {
105105
this.logging.log(
106-
"Bluetooth GATT server connected when connecting"
106+
"Bluetooth GATT server connected when connecting",
107107
);
108108
}
109109
})
@@ -114,7 +114,7 @@ export class BluetoothDeviceWrapper {
114114
} else {
115115
this.logging.error(
116116
"Bluetooth GATT server connect error after our timeout",
117-
e
117+
e,
118118
);
119119
return undefined;
120120
}
@@ -129,7 +129,7 @@ export class BluetoothDeviceWrapper {
129129
const gattConnectResult = await Promise.race([
130130
this.gattConnectPromise,
131131
new Promise<"timeout">((resolve) =>
132-
setTimeout(() => resolve("timeout"), connectTimeoutDuration)
132+
setTimeout(() => resolve("timeout"), connectTimeoutDuration),
133133
),
134134
]);
135135
if (gattConnectResult === "timeout") {
@@ -163,7 +163,7 @@ export class BluetoothDeviceWrapper {
163163

164164
private async disconnectInternal(userTriggered: boolean): Promise<void> {
165165
this.logging.log(
166-
`Bluetooth disconnect ${userTriggered ? "(user triggered)" : "(programmatic)"}`
166+
`Bluetooth disconnect ${userTriggered ? "(user triggered)" : "(programmatic)"}`,
167167
);
168168
this.duringExplicitConnectDisconnect++;
169169
try {
@@ -177,7 +177,7 @@ export class BluetoothDeviceWrapper {
177177
this.duringExplicitConnectDisconnect--;
178178
}
179179
this.reconnectReadyPromise = new Promise((resolve) =>
180-
setTimeout(resolve, 3_500)
180+
setTimeout(resolve, 3_500),
181181
);
182182
}
183183

@@ -200,19 +200,19 @@ export class BluetoothDeviceWrapper {
200200
try {
201201
if (!this.duringExplicitConnectDisconnect) {
202202
this.logging.log(
203-
"Bluetooth GATT disconnected... automatically trying reconnect"
203+
"Bluetooth GATT disconnected... automatically trying reconnect",
204204
);
205205
// stateOnReconnectionAttempt();
206206
await this.reconnect();
207207
} else {
208208
this.logging.log(
209-
"Bluetooth GATT disconnect ignored during explicit disconnect"
209+
"Bluetooth GATT disconnect ignored during explicit disconnect",
210210
);
211211
}
212212
} catch (e) {
213213
this.logging.error(
214214
"Bluetooth connect triggered by disconnect listener failed",
215-
e
215+
e,
216216
);
217217
}
218218
};
@@ -229,10 +229,10 @@ export class BluetoothDeviceWrapper {
229229
const serviceMeta = profile.deviceInformation;
230230
try {
231231
const deviceInfo = await this.assertGattServer().getPrimaryService(
232-
serviceMeta.id
232+
serviceMeta.id,
233233
);
234234
const characteristic = await deviceInfo.getCharacteristic(
235-
serviceMeta.characteristics.modelNumber.id
235+
serviceMeta.characteristics.modelNumber.id,
236236
);
237237
const modelNumberBytes = await characteristic.readValue();
238238
const modelNumber = new TextDecoder().decode(modelNumberBytes);
@@ -260,7 +260,7 @@ export class BluetoothDeviceWrapper {
260260

261261
export const createBluetoothDeviceWrapper = async (
262262
device: BluetoothDevice,
263-
logging: Logging
263+
logging: Logging,
264264
): Promise<BluetoothDeviceWrapper | undefined> => {
265265
try {
266266
// Reuse our connection objects for the same device as they

lib/bluetooth.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class MicrobitWebBluetoothConnection
9292
* A progress callback. Called with undefined when the process is complete or has failed.
9393
*/
9494
progress: (percentage: number | undefined) => void;
95-
}
95+
},
9696
): Promise<void> {
9797
throw new Error("Unsupported");
9898
}
@@ -168,7 +168,7 @@ export class MicrobitWebBluetoothConnection
168168
}
169169
this.connection = await createBluetoothDeviceWrapper(
170170
device,
171-
this.logging
171+
this.logging,
172172
);
173173
}
174174
// TODO: timeout unification?
@@ -177,7 +177,7 @@ export class MicrobitWebBluetoothConnection
177177
}
178178

179179
private async chooseDevice(
180-
options: ConnectOptions
180+
options: ConnectOptions,
181181
): Promise<BluetoothDevice | undefined> {
182182
if (this.device) {
183183
return this.device;
@@ -209,7 +209,7 @@ export class MicrobitWebBluetoothConnection
209209
],
210210
}),
211211
new Promise<"timeout">((resolve) =>
212-
setTimeout(() => resolve("timeout"), requestDeviceTimeoutDuration)
212+
setTimeout(() => resolve("timeout"), requestDeviceTimeoutDuration),
213213
),
214214
]);
215215
if (result === "timeout") {

lib/device.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export interface DeviceConnection
221221
* The partial parameter reports the flash type currently in progress.
222222
*/
223223
progress: (percentage: number | undefined, partial: boolean) => void;
224-
}
224+
},
225225
): Promise<void>;
226226

227227
/**

lib/mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class MockDeviceConnection
8484
* A progress callback. Called with undefined when the process is complete or has failed.
8585
*/
8686
progress: (percentage: number | undefined) => void;
87-
}
87+
},
8888
): Promise<void> {
8989
await new Promise((resolve) => setTimeout(resolve, 100));
9090
options.progress(0.5);

lib/webusb.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ export class MicrobitWebUSBConnection
125125
}
126126
}, assumePageIsStayingOpenDelay);
127127
},
128-
{ once: true }
128+
{ once: true },
129129
);
130130
};
131131

132132
private logging: Logging;
133133

134134
constructor(
135-
options: MicrobitWebUSBConnectionOptions = { logging: new NullLogging() }
135+
options: MicrobitWebUSBConnectionOptions = { logging: new NullLogging() },
136136
) {
137137
super();
138138
this.logging = options.logging;
@@ -151,7 +151,7 @@ export class MicrobitWebUSBConnection
151151
if (window.document) {
152152
window.document.addEventListener(
153153
"visibilitychange",
154-
this.visibilityChangeListener
154+
this.visibilityChangeListener,
155155
);
156156
}
157157
}
@@ -166,7 +166,7 @@ export class MicrobitWebUSBConnection
166166
if (window.document) {
167167
window.document.removeEventListener(
168168
"visibilitychange",
169-
this.visibilityChangeListener
169+
this.visibilityChangeListener,
170170
);
171171
}
172172
}
@@ -194,13 +194,13 @@ export class MicrobitWebUSBConnection
194194
* A progress callback. Called with undefined when the process is complete or has failed.
195195
*/
196196
progress: (percentage: number | undefined) => void;
197-
}
197+
},
198198
): Promise<void> {
199199
this.flashing = true;
200200
try {
201201
const startTime = new Date().getTime();
202202
await this.withEnrichedErrors(() =>
203-
this.flashInternal(dataSource, options)
203+
this.flashInternal(dataSource, options),
204204
);
205205
this.dispatchTypedEvent("flash", new FlashEvent());
206206

@@ -222,7 +222,7 @@ export class MicrobitWebUSBConnection
222222
options: {
223223
partial: boolean;
224224
progress: (percentage: number | undefined, partial: boolean) => void;
225-
}
225+
},
226226
): Promise<void> {
227227
this.log("Stopping serial before flash");
228228
await this.stopSerialInternal();
@@ -334,7 +334,7 @@ export class MicrobitWebUSBConnection
334334
// Log error to console for feedback
335335
this.log("An error occurred whilst attempting to use WebUSB.");
336336
this.log(
337-
"Details of the error can be found below, and may be useful when trying to replicate and debug the error."
337+
"Details of the error can be found below, and may be useful when trying to replicate and debug the error.",
338338
);
339339
this.log(e);
340340

src/demo.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ document.querySelector<HTMLDivElement>("#app")!.innerHTML = `
3434
`;
3535

3636
const transport = document.querySelector(
37-
"#flash > .transport"
37+
"#flash > .transport",
3838
)! as HTMLSelectElement;
3939
const connect = document.querySelector("#flash > .connect")!;
4040
const disconnect = document.querySelector("#flash > .disconnect")!;
4141
const flash = document.querySelector("#flash > .flash")!;
4242
const fileInput = document.querySelector(
43-
"#flash input[type=file]"
43+
"#flash input[type=file]",
4444
)! as HTMLInputElement;
4545
const statusParagraph = document.querySelector("#flash > .status")!;
4646
const accDataGet = document.querySelector(
47-
"#flash > .acc-controls > .acc-data-get"
47+
"#flash > .acc-controls > .acc-data-get",
4848
)!;
4949
const accDataListen = document.querySelector(
50-
"#flash > .acc-controls > .acc-data-listen"
50+
"#flash > .acc-controls > .acc-data-listen",
5151
)!;
5252
const accDataStop = document.querySelector(
53-
"#flash > .acc-controls > .acc-data-stop"
53+
"#flash > .acc-controls > .acc-data-stop",
5454
)!;
5555

5656
let connection: DeviceConnection = new MicrobitWebUSBConnection();

0 commit comments

Comments
 (0)