tauri-plugin-serialplugin-api 2.18.0
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/LICENSE.spdx +20 -0
- package/README.md +1678 -0
- package/dist-js/auto-reconnect-manager.d.ts +69 -0
- package/dist-js/index.cjs +1114 -0
- package/dist-js/index.d.ts +372 -0
- package/dist-js/index.js +1112 -0
- package/dist-js/listener-manager.d.ts +34 -0
- package/package.json +55 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-reconnect manager for serial ports
|
|
3
|
+
* Handles automatic reconnection logic with configurable settings
|
|
4
|
+
*/
|
|
5
|
+
export declare class AutoReconnectManager {
|
|
6
|
+
private enabled;
|
|
7
|
+
private interval;
|
|
8
|
+
private maxAttempts;
|
|
9
|
+
private currentAttempts;
|
|
10
|
+
private timer;
|
|
11
|
+
private callback?;
|
|
12
|
+
private reconnectFunction?;
|
|
13
|
+
/**
|
|
14
|
+
* @description Enables auto-reconnect functionality
|
|
15
|
+
* @param {Object} options Auto-reconnect configuration options
|
|
16
|
+
* @param {number} [options.interval=5000] Reconnection interval in milliseconds
|
|
17
|
+
* @param {number | null} [options.maxAttempts=10] Maximum number of reconnection attempts (null for infinite)
|
|
18
|
+
* @param {Function} [options.onReconnect] Callback function called on each reconnection attempt
|
|
19
|
+
* @param {Function} options.reconnectFunction Function that performs the actual reconnection
|
|
20
|
+
* @returns {Promise<void>} A promise that resolves when auto-reconnect is enabled
|
|
21
|
+
*/
|
|
22
|
+
enable(options: {
|
|
23
|
+
interval?: number;
|
|
24
|
+
maxAttempts?: number | null;
|
|
25
|
+
onReconnect?: (success: boolean, attempt: number) => void;
|
|
26
|
+
reconnectFunction: () => Promise<boolean>;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* @description Disables auto-reconnect functionality
|
|
30
|
+
* @returns {Promise<void>} A promise that resolves when auto-reconnect is disabled
|
|
31
|
+
*/
|
|
32
|
+
disable(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* @description Gets auto-reconnect status and configuration
|
|
35
|
+
* @returns {Object} Auto-reconnect information
|
|
36
|
+
*/
|
|
37
|
+
getInfo(): {
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
interval: number;
|
|
40
|
+
maxAttempts: number | null;
|
|
41
|
+
currentAttempts: number;
|
|
42
|
+
hasCallback: boolean;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @description Starts the auto-reconnect process
|
|
46
|
+
* @returns {Promise<void>} A promise that resolves when auto-reconnect process starts
|
|
47
|
+
*/
|
|
48
|
+
start(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* @description Stops the auto-reconnect process (clears timer but keeps enabled)
|
|
51
|
+
* @returns {Promise<void>} A promise that resolves when auto-reconnect process stops
|
|
52
|
+
*/
|
|
53
|
+
stop(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* @description Resets the attempt counter
|
|
56
|
+
* @returns {Promise<void>} A promise that resolves when counter is reset
|
|
57
|
+
*/
|
|
58
|
+
reset(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* @description Internal method to perform a single reconnection attempt
|
|
61
|
+
* @returns {Promise<void>} A promise that resolves when the attempt is complete
|
|
62
|
+
*/
|
|
63
|
+
private performAttempt;
|
|
64
|
+
isEnabled(): boolean;
|
|
65
|
+
getInterval(): number;
|
|
66
|
+
getMaxAttempts(): number | null;
|
|
67
|
+
getCurrentAttempts(): number;
|
|
68
|
+
hasCallback(): boolean;
|
|
69
|
+
}
|