flagmint-js-sdk 1.0.13 → 1.2.1
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.
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import type { Transport } from './Transport';
|
|
2
2
|
export interface LongPollingOptions {
|
|
3
|
-
/** Minimum delay (ms) between each poll iteration */
|
|
4
3
|
pollIntervalMs?: number;
|
|
4
|
+
maxBackoffMs?: number;
|
|
5
|
+
backoffMultiplier?: number;
|
|
5
6
|
}
|
|
6
7
|
export declare class LongPollingTransport<C, T> implements Transport<C, T> {
|
|
7
8
|
private endpoint;
|
|
8
9
|
private apiKey;
|
|
9
|
-
private context;
|
|
10
10
|
private isStopped;
|
|
11
11
|
private pollIntervalMs;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
private maxBackoffMs;
|
|
13
|
+
private backoffMultiplier;
|
|
14
|
+
private pollTimeoutId;
|
|
15
|
+
private onUpdateCallback?;
|
|
16
|
+
private currentContext;
|
|
17
|
+
private currentFlags;
|
|
18
|
+
private consecutiveErrors;
|
|
19
|
+
private currentBackoffMs;
|
|
20
|
+
constructor(endpoint: string, apiKey: string, initialContext: C, options?: LongPollingOptions);
|
|
21
|
+
init(): Promise<void>;
|
|
22
|
+
private scheduleNextPoll;
|
|
23
|
+
private poll;
|
|
24
|
+
private applyBackoff;
|
|
25
|
+
private flagsChanged;
|
|
14
26
|
fetchFlags(context: C): Promise<Record<string, T>>;
|
|
27
|
+
onFlagsUpdated(callback: (flags: Record<string, T>) => void): void;
|
|
15
28
|
destroy(): void;
|
|
16
29
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Transport } from './Transport';
|
|
2
|
+
type ConnectionState = 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'failed';
|
|
2
3
|
export declare class WebSocketTransport<C, T> implements Transport<C, T> {
|
|
3
4
|
private wsUrl;
|
|
4
5
|
private apiKey;
|
|
@@ -8,17 +9,28 @@ export declare class WebSocketTransport<C, T> implements Transport<C, T> {
|
|
|
8
9
|
private flags;
|
|
9
10
|
private context;
|
|
10
11
|
private isReady;
|
|
12
|
+
private initialFlagsReceived;
|
|
13
|
+
private initialFlagsPromise;
|
|
11
14
|
private onFlagsUpdatedCallback?;
|
|
15
|
+
private onConnectionStateCallback?;
|
|
12
16
|
private retries;
|
|
17
|
+
private reconnectTimeoutId;
|
|
18
|
+
private heartbeatIntervalId;
|
|
19
|
+
private lastHeartbeatTime;
|
|
20
|
+
private readonly heartbeatTimeoutMs;
|
|
13
21
|
constructor(wsUrl: string, apiKey: string, maxRetries?: number, initialBackoffMs?: number);
|
|
14
22
|
init(): Promise<void>;
|
|
15
|
-
|
|
16
|
-
* Attempts to connect to the WebSocket server with retry logic.
|
|
17
|
-
* If the connection fails, it will retry with exponential backoff.
|
|
18
|
-
*/
|
|
23
|
+
private waitForInitialFlags;
|
|
19
24
|
private connectWithRetry;
|
|
25
|
+
private cleanupSocket;
|
|
26
|
+
private startHeartbeat;
|
|
27
|
+
private stopHeartbeat;
|
|
28
|
+
private setConnectionState;
|
|
29
|
+
private getWebSocketImplementation;
|
|
20
30
|
fetchFlags(context: C): Promise<Record<string, T>>;
|
|
21
31
|
onFlagsUpdated(callback: (flags: Record<string, T>) => void): void;
|
|
32
|
+
onConnectionStateChanged(callback: (state: ConnectionState) => void): void;
|
|
22
33
|
destroy(): void;
|
|
23
34
|
private sendContext;
|
|
24
35
|
}
|
|
36
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flagmint-js-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Framework-agnostic JavaScript SDK for managing feature flags in Flagmint applications.",
|
|
5
5
|
"author": "Flagmint Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"vite-plugin-dts": "^2.0.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"buffer": "^6.0.3"
|
|
45
|
+
"buffer": "^6.0.3",
|
|
46
|
+
"ws": "^8.0.0"
|
|
46
47
|
}
|
|
47
48
|
}
|