@ukeyfe/hardware-transport-electron 1.1.13
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/dist/ble-ops.d.ts +19 -0
- package/dist/ble-ops.d.ts.map +1 -0
- package/dist/index-60176982.js +41 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/noble-ble-handler-37d3b074.js +1214 -0
- package/dist/noble-ble-handler.d.ts +3 -0
- package/dist/noble-ble-handler.d.ts.map +1 -0
- package/dist/types/desktop-api.d.ts +30 -0
- package/dist/types/desktop-api.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/noble-extended.d.ts +26 -0
- package/dist/types/noble-extended.d.ts.map +1 -0
- package/package.json +39 -0
- package/src/ble-ops.ts +77 -0
- package/src/index.ts +11 -0
- package/src/noble-ble-handler.ts +1679 -0
- package/src/types/desktop-api.ts +28 -0
- package/src/types/index.ts +2 -0
- package/src/types/noble-extended.ts +55 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Desktop API types for Electron preload script
|
|
3
|
+
* These types define the core interface for Noble BLE communication
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Noble BLE API interface - core BLE functionality
|
|
7
|
+
export interface NobleBleAPI {
|
|
8
|
+
enumerate: () => Promise<{ id: string; name: string }[]>;
|
|
9
|
+
getDevice: (uuid: string) => Promise<{ id: string; name: string } | null>;
|
|
10
|
+
connect: (uuid: string) => Promise<void>;
|
|
11
|
+
disconnect: (uuid: string) => Promise<void>;
|
|
12
|
+
subscribe: (uuid: string) => Promise<void>;
|
|
13
|
+
unsubscribe: (uuid: string) => Promise<void>;
|
|
14
|
+
write: (uuid: string, data: string) => Promise<void>;
|
|
15
|
+
onNotification: (callback: (deviceId: string, data: string) => void) => () => void;
|
|
16
|
+
onDeviceDisconnected: (callback: (device: { id: string; name: string }) => void) => () => void;
|
|
17
|
+
checkAvailability: () => Promise<{
|
|
18
|
+
available: boolean;
|
|
19
|
+
state: string;
|
|
20
|
+
unsupported: boolean;
|
|
21
|
+
initialized: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Base Desktop API interface - contains only Noble BLE functionality
|
|
26
|
+
export interface DesktopAPI {
|
|
27
|
+
nobleBle?: NobleBleAPI;
|
|
28
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Extended type definitions for Noble BLE
|
|
3
|
+
* Supplements @types/noble with additional interfaces
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Peripheral, Characteristic } from '@stoprocent/noble';
|
|
7
|
+
|
|
8
|
+
// Device info interface for our API
|
|
9
|
+
export interface DeviceInfo {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
state: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Characteristic pair interface
|
|
16
|
+
export interface CharacteristicPair {
|
|
17
|
+
write: Characteristic;
|
|
18
|
+
notify: Characteristic;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Noble module interface for dynamic import
|
|
22
|
+
export interface NobleModule {
|
|
23
|
+
state: string;
|
|
24
|
+
startScanning(
|
|
25
|
+
serviceUUIDs: string[],
|
|
26
|
+
allowDuplicates: boolean,
|
|
27
|
+
callback?: (error?: Error) => void
|
|
28
|
+
): void;
|
|
29
|
+
stopScanning(callback?: () => void): void;
|
|
30
|
+
on(event: 'stateChange', listener: (state: string) => void): void;
|
|
31
|
+
on(event: 'discover', listener: (peripheral: Peripheral) => void): void;
|
|
32
|
+
removeListener(event: 'stateChange', listener: (state: string) => void): void;
|
|
33
|
+
removeListener(event: 'discover', listener: (peripheral: Peripheral) => void): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Logger interface
|
|
37
|
+
export interface Logger {
|
|
38
|
+
info(message: string, ...args: any[]): void;
|
|
39
|
+
debug(message: string, ...args: any[]): void;
|
|
40
|
+
error(message: string, ...args: any[]): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Safe logger utility
|
|
44
|
+
export function safeLog(
|
|
45
|
+
logger: Logger | null,
|
|
46
|
+
level: 'info' | 'debug' | 'error',
|
|
47
|
+
message: string,
|
|
48
|
+
...args: any[]
|
|
49
|
+
): void {
|
|
50
|
+
if (logger) {
|
|
51
|
+
logger[level](message, ...args);
|
|
52
|
+
} else {
|
|
53
|
+
console[level](`[NobleBLE] ${message}`, ...args);
|
|
54
|
+
}
|
|
55
|
+
}
|