mirror of
https://github.com/jhbruhn/respira.git
synced 2026-01-27 10:23:41 +00:00
Migrate to official @types/web-bluetooth package
Replace custom Web Bluetooth type declarations with the official @types/web-bluetooth package from npm. This provides better maintained and more comprehensive type definitions for the Web Bluetooth API. Changes: - Add @types/web-bluetooth dependency - Update tsconfig to include web-bluetooth types - Remove custom src/web-bluetooth.d.ts declarations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b7ea024df3
commit
9b536e9deb
4 changed files with 9 additions and 126 deletions
7
package-lock.json
generated
7
package-lock.json
generated
|
|
@ -10,6 +10,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@heroicons/react": "^2.2.0",
|
"@heroicons/react": "^2.2.0",
|
||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
|
"@types/web-bluetooth": "^0.0.21",
|
||||||
"konva": "^10.0.12",
|
"konva": "^10.0.12",
|
||||||
"pyodide": "^0.27.4",
|
"pyodide": "^0.27.4",
|
||||||
"react": "^19.2.0",
|
"react": "^19.2.0",
|
||||||
|
|
@ -1543,6 +1544,12 @@
|
||||||
"@types/react": "*"
|
"@types/react": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/web-bluetooth": {
|
||||||
|
"version": "0.0.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.21.tgz",
|
||||||
|
"integrity": "sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||||
"version": "8.48.0",
|
"version": "8.48.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.48.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.48.0.tgz",
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@heroicons/react": "^2.2.0",
|
"@heroicons/react": "^2.2.0",
|
||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
|
"@types/web-bluetooth": "^0.0.21",
|
||||||
"konva": "^10.0.12",
|
"konva": "^10.0.12",
|
||||||
"pyodide": "^0.27.4",
|
"pyodide": "^0.27.4",
|
||||||
"react": "^19.2.0",
|
"react": "^19.2.0",
|
||||||
|
|
|
||||||
125
src/web-bluetooth.d.ts
vendored
125
src/web-bluetooth.d.ts
vendored
|
|
@ -1,125 +0,0 @@
|
||||||
// WebBluetooth API type declarations
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/
|
|
||||||
|
|
||||||
interface BluetoothRemoteGATTServer {
|
|
||||||
device: BluetoothDevice;
|
|
||||||
connected: boolean;
|
|
||||||
connect(): Promise<BluetoothRemoteGATTServer>;
|
|
||||||
disconnect(): void;
|
|
||||||
getPrimaryService(service: BluetoothServiceUUID): Promise<BluetoothRemoteGATTService>;
|
|
||||||
getPrimaryServices(service?: BluetoothServiceUUID): Promise<BluetoothRemoteGATTService[]>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BluetoothDevice extends EventTarget {
|
|
||||||
id: string;
|
|
||||||
name?: string;
|
|
||||||
gatt?: BluetoothRemoteGATTServer;
|
|
||||||
watchingAdvertisements: boolean;
|
|
||||||
watchAdvertisements(options?: WatchAdvertisementsOptions): Promise<void>;
|
|
||||||
unwatchAdvertisements(): void;
|
|
||||||
forget(): Promise<void>;
|
|
||||||
addEventListener(
|
|
||||||
type: 'gattserverdisconnected' | 'advertisementreceived',
|
|
||||||
listener: EventListenerOrEventListenerObject,
|
|
||||||
options?: boolean | AddEventListenerOptions
|
|
||||||
): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface WatchAdvertisementsOptions {
|
|
||||||
signal?: AbortSignal;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BluetoothRemoteGATTService extends EventTarget {
|
|
||||||
device: BluetoothDevice;
|
|
||||||
uuid: string;
|
|
||||||
isPrimary: boolean;
|
|
||||||
getCharacteristic(characteristic: BluetoothCharacteristicUUID): Promise<BluetoothRemoteGATTCharacteristic>;
|
|
||||||
getCharacteristics(characteristic?: BluetoothCharacteristicUUID): Promise<BluetoothRemoteGATTCharacteristic[]>;
|
|
||||||
getIncludedService(service: BluetoothServiceUUID): Promise<BluetoothRemoteGATTService>;
|
|
||||||
getIncludedServices(service?: BluetoothServiceUUID): Promise<BluetoothRemoteGATTService[]>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BluetoothRemoteGATTCharacteristic extends EventTarget {
|
|
||||||
service: BluetoothRemoteGATTService;
|
|
||||||
uuid: string;
|
|
||||||
properties: BluetoothCharacteristicProperties;
|
|
||||||
value?: DataView;
|
|
||||||
getDescriptor(descriptor: BluetoothDescriptorUUID): Promise<BluetoothRemoteGATTDescriptor>;
|
|
||||||
getDescriptors(descriptor?: BluetoothDescriptorUUID): Promise<BluetoothRemoteGATTDescriptor[]>;
|
|
||||||
readValue(): Promise<DataView>;
|
|
||||||
writeValue(value: BufferSource): Promise<void>;
|
|
||||||
writeValueWithResponse(value: BufferSource): Promise<void>;
|
|
||||||
writeValueWithoutResponse(value: BufferSource): Promise<void>;
|
|
||||||
startNotifications(): Promise<BluetoothRemoteGATTCharacteristic>;
|
|
||||||
stopNotifications(): Promise<BluetoothRemoteGATTCharacteristic>;
|
|
||||||
addEventListener(
|
|
||||||
type: 'characteristicvaluechanged',
|
|
||||||
listener: EventListenerOrEventListenerObject,
|
|
||||||
options?: boolean | AddEventListenerOptions
|
|
||||||
): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BluetoothCharacteristicProperties {
|
|
||||||
broadcast: boolean;
|
|
||||||
read: boolean;
|
|
||||||
writeWithoutResponse: boolean;
|
|
||||||
write: boolean;
|
|
||||||
notify: boolean;
|
|
||||||
indicate: boolean;
|
|
||||||
authenticatedSignedWrites: boolean;
|
|
||||||
reliableWrite: boolean;
|
|
||||||
writableAuxiliaries: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BluetoothRemoteGATTDescriptor {
|
|
||||||
characteristic: BluetoothRemoteGATTCharacteristic;
|
|
||||||
uuid: string;
|
|
||||||
value?: DataView;
|
|
||||||
readValue(): Promise<DataView>;
|
|
||||||
writeValue(value: BufferSource): Promise<void>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RequestDeviceOptions {
|
|
||||||
filters?: BluetoothLEScanFilter[];
|
|
||||||
optionalServices?: BluetoothServiceUUID[];
|
|
||||||
acceptAllDevices?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BluetoothLEScanFilter {
|
|
||||||
services?: BluetoothServiceUUID[];
|
|
||||||
name?: string;
|
|
||||||
namePrefix?: string;
|
|
||||||
manufacturerData?: BluetoothManufacturerDataFilter[];
|
|
||||||
serviceData?: BluetoothServiceDataFilter[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BluetoothManufacturerDataFilter {
|
|
||||||
companyIdentifier: number;
|
|
||||||
dataPrefix?: BufferSource;
|
|
||||||
mask?: BufferSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BluetoothServiceDataFilter {
|
|
||||||
service: BluetoothServiceUUID;
|
|
||||||
dataPrefix?: BufferSource;
|
|
||||||
mask?: BufferSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
type BluetoothServiceUUID = number | string;
|
|
||||||
type BluetoothCharacteristicUUID = number | string;
|
|
||||||
type BluetoothDescriptorUUID = number | string;
|
|
||||||
|
|
||||||
interface Bluetooth extends EventTarget {
|
|
||||||
getAvailability(): Promise<boolean>;
|
|
||||||
requestDevice(options?: RequestDeviceOptions): Promise<BluetoothDevice>;
|
|
||||||
getDevices(): Promise<BluetoothDevice[]>;
|
|
||||||
addEventListener(
|
|
||||||
type: 'availabilitychanged',
|
|
||||||
listener: EventListenerOrEventListenerObject,
|
|
||||||
options?: boolean | AddEventListenerOptions
|
|
||||||
): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Navigator {
|
|
||||||
bluetooth: Bluetooth;
|
|
||||||
}
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"types": ["vite/client"],
|
"types": ["vite/client", "web-bluetooth"],
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|
||||||
/* Bundler mode */
|
/* Bundler mode */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue