Execute oxfmt (#1166)

Ran
pnpm oxfmt .

This should get the web repo aligned so that we can better enforce oxfmt going forward.
This commit is contained in:
Austin
2026-06-16 20:30:08 -04:00
committed by GitHub
parent c5690d1edb
commit d2cb51d489
378 changed files with 5548 additions and 1974 deletions
@@ -28,7 +28,11 @@ function stubWebBluetooth() {
const fromRadioCharacteristic: BluetoothRemoteGATTCharacteristic = {
async readValue() {
const next = incomingQueue.shift() ?? new Uint8Array();
return new DataView(next.buffer, next.byteOffset, next.byteLength) as unknown as DataView;
return new DataView(
next.buffer,
next.byteOffset,
next.byteLength,
) as unknown as DataView;
},
addEventListener() {},
removeEventListener() {},
@@ -54,7 +58,11 @@ function stubWebBluetooth() {
const u8 =
bufferSource instanceof ArrayBuffer
? new Uint8Array(bufferSource)
: new Uint8Array(bufferSource.buffer, bufferSource.byteOffset, bufferSource.byteLength);
: new Uint8Array(
bufferSource.buffer,
bufferSource.byteOffset,
bufferSource.byteLength,
);
lastWritten = new Uint8Array(u8);
},
} as unknown as BluetoothRemoteGATTCharacteristic;
@@ -96,10 +104,20 @@ function stubWebBluetooth() {
return primaryService;
},
device: {
addEventListener: (...args: Parameters<EventTarget["addEventListener"]>) =>
deviceEmitter.addEventListener(args[0] as string, args[1] as (e: Event) => void),
removeEventListener: (...args: Parameters<EventTarget["removeEventListener"]>) =>
deviceEmitter.removeEventListener(args[0] as string, args[1] as (e: Event) => void),
addEventListener: (
...args: Parameters<EventTarget["addEventListener"]>
) =>
deviceEmitter.addEventListener(
args[0] as string,
args[1] as (e: Event) => void,
),
removeEventListener: (
...args: Parameters<EventTarget["removeEventListener"]>
) =>
deviceEmitter.removeEventListener(
args[0] as string,
args[1] as (e: Event) => void,
),
} as unknown as BluetoothDevice,
} as unknown as BluetoothRemoteGATTServer;
@@ -116,7 +134,10 @@ function stubWebBluetooth() {
},
};
vi.stubGlobal("navigator", Object.assign({}, globalThis.navigator, fakeNavigator));
vi.stubGlobal(
"navigator",
Object.assign({}, globalThis.navigator, fakeNavigator),
);
// helper actions for tests/contract
return {
@@ -144,20 +165,25 @@ describe("TransportWebBluetooth (contract)", () => {
name: "TransportWebBluetooth",
setup: () => {},
teardown: () => {
(globalThis as unknown as { __ble?: ReturnType<typeof stubWebBluetooth> }).__ble?.cleanup();
(globalThis as unknown as { __ble?: ReturnType<typeof stubWebBluetooth> }).__ble = undefined;
(
globalThis as unknown as { __ble?: ReturnType<typeof stubWebBluetooth> }
).__ble?.cleanup();
(
globalThis as unknown as { __ble?: ReturnType<typeof stubWebBluetooth> }
).__ble = undefined;
vi.restoreAllMocks();
vi.unstubAllGlobals();
},
create: async () => {
(globalThis as unknown as { __ble: ReturnType<typeof stubWebBluetooth> }).__ble =
stubWebBluetooth();
(
globalThis as unknown as { __ble: ReturnType<typeof stubWebBluetooth> }
).__ble = stubWebBluetooth();
return await TransportWebBluetooth.create();
},
pushIncoming: async (bytes) => {
(globalThis as unknown as { __ble: ReturnType<typeof stubWebBluetooth> }).__ble.pushIncoming(
bytes,
);
(
globalThis as unknown as { __ble: ReturnType<typeof stubWebBluetooth> }
).__ble.pushIncoming(bytes);
await Promise.resolve();
},
assertLastWritten: (bytes) => {
@@ -1,4 +1,8 @@
import { DeviceStatusEnum, type DeviceOutput, type Transport } from "@meshtastic/sdk";
import {
DeviceStatusEnum,
type DeviceOutput,
type Transport,
} from "@meshtastic/sdk";
/**
* Typed error thrown when establishing the GATT connection fails. `kind`
@@ -96,7 +100,9 @@ export class TransportWebBluetooth implements Transport {
/**
* Creates a transport from an existing, user-provided {@link BluetoothDevice}.
*/
public static async createFromDevice(device: BluetoothDevice): Promise<TransportWebBluetooth> {
public static async createFromDevice(
device: BluetoothDevice,
): Promise<TransportWebBluetooth> {
return await TransportWebBluetooth.prepareConnection(device);
}
@@ -112,12 +118,16 @@ export class TransportWebBluetooth implements Transport {
* fails, the BluetoothDevice has no `gatt`, or the Meshtastic GATT
* service / characteristics aren't found on the device.
*/
public static async prepareConnection(device: BluetoothDevice): Promise<TransportWebBluetooth> {
public static async prepareConnection(
device: BluetoothDevice,
): Promise<TransportWebBluetooth> {
const gattServer = await TransportWebBluetooth.connectGatt(device);
let service: BluetoothRemoteGATTService;
try {
service = await gattServer.getPrimaryService(TransportWebBluetooth.ServiceUuid);
service = await gattServer.getPrimaryService(
TransportWebBluetooth.ServiceUuid,
);
} catch (cause) {
throw new BluetoothConnectError(
"missing-service",
@@ -136,7 +146,11 @@ export class TransportWebBluetooth implements Transport {
TransportWebBluetooth.FromNumUuid,
);
if (!toRadioCharacteristic || !fromRadioCharacteristic || !fromNumCharacteristic) {
if (
!toRadioCharacteristic ||
!fromRadioCharacteristic ||
!fromNumCharacteristic
) {
throw new BluetoothConnectError(
"missing-service",
"Meshtastic GATT characteristics not found on this device.",
@@ -151,7 +165,9 @@ export class TransportWebBluetooth implements Transport {
);
}
private static async connectGatt(device: BluetoothDevice): Promise<BluetoothRemoteGATTServer> {
private static async connectGatt(
device: BluetoothDevice,
): Promise<BluetoothRemoteGATTServer> {
if (!device.gatt) {
throw new BluetoothConnectError(
"unavailable",
@@ -205,7 +221,10 @@ export class TransportWebBluetooth implements Transport {
this.fromDeviceController = ctrl;
this.emitStatus(DeviceStatusEnum.DeviceConnecting);
this.gattServer.device.addEventListener("gattserverdisconnected", this.onGattDisconnected);
this.gattServer.device.addEventListener(
"gattserverdisconnected",
this.onGattDisconnected,
);
try {
await this.fromNumCharacteristic.startNotifications();
@@ -264,7 +283,10 @@ export class TransportWebBluetooth implements Transport {
"characteristicvaluechanged",
this.onFromNumChanged,
);
this.gattServer.device.removeEventListener("gattserverdisconnected", this.onGattDisconnected);
this.gattServer.device.removeEventListener(
"gattserverdisconnected",
this.onGattDisconnected,
);
this.gattServer.disconnect();
} finally {