@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.
@@ -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,2 @@
1
+ // Export only type definitions to avoid bundling Noble into renderer process
2
+ export type { DeviceInfo, CharacteristicPair, NobleModule, Logger } from './noble-extended';
@@ -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
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.lib.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "types": [
6
+ "node",
7
+ "web-bluetooth"
8
+ ]
9
+ },
10
+ "include": ["./src"]
11
+ }