@widgetic/embed-sdk 2.0.14 → 2.0.17
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/README.md +31 -9
- package/dist/browser/chunks/ABTestManager.js +1 -1
- package/dist/browser/chunks/advanced.js +1 -1
- package/dist/browser/chunks/api.js +1 -1
- package/dist/browser/chunks/core.js +1 -1
- package/dist/browser/chunks/display.js +1 -1
- package/dist/browser/chunks/media.js +1 -1
- package/dist/browser/chunks/messaging.js +1 -1
- package/dist/browser/chunks/renderers.js +1 -1
- package/dist/browser/chunks/scanner.js +1 -1
- package/dist/browser/chunks/security.js +1 -1
- package/dist/browser/embed-bootstrap.js +1 -1
- package/dist/browser/embed-sdk.js +1 -1
- package/dist/esm/chunks/ABTestManager.js +1 -1
- package/dist/esm/chunks/advanced.js +1 -1
- package/dist/esm/chunks/api.js +1 -1
- package/dist/esm/chunks/core.js +1 -1
- package/dist/esm/chunks/display.js +1 -1
- package/dist/esm/chunks/media.js +1 -1
- package/dist/esm/chunks/messaging.js +1 -1
- package/dist/esm/chunks/renderers.js +1 -1
- package/dist/esm/chunks/scanner.js +1 -1
- package/dist/esm/chunks/security.js +1 -1
- package/dist/esm/embed-bootstrap.js +1 -1
- package/dist/esm/embed-sdk.js +1 -1
- package/dist/esm/types/abTesting/ABTestElement.d.ts +10 -0
- package/dist/esm/types/abTesting/ABTestManager.d.ts +54 -12
- package/dist/esm/types/abTesting/abVisitor.d.ts +31 -0
- package/dist/esm/types/core/advanced-security-manager.d.ts +3 -0
- package/dist/esm/types/core/widget-manager.d.ts +8 -43
- package/dist/esm/types/utils/declarative-embed-parser.d.ts +14 -0
- package/dist/esm/types/utils/hydrate-published-host.d.ts +7 -4
- package/dist/esm/types/utils/image-delivery.d.ts +54 -0
- package/dist/esm/types/utils/lookup-cache.d.ts +34 -0
- package/dist/esm/types/utils/preload-content-images.d.ts +21 -0
- package/dist/esm/types/utils/public-embed-lookup.d.ts +3 -0
- package/dist/esm/types/utils/published-host-bridge.d.ts +16 -0
- package/dist/umd/embed-bootstrap.js +1 -1
- package/dist/umd/embed-sdk.js +1 -1
- package/package.json +1 -1
- package/dist/esm/types/core/realtime-manager.d.ts +0 -286
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/embed-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.17",
|
|
4
4
|
"description": "Modern JavaScript SDK for embedding Widgetic widgets with support for custom elements, iframes, and batch API integration",
|
|
5
5
|
"main": "dist/umd/embed-sdk.js",
|
|
6
6
|
"module": "dist/esm/embed-sdk.js",
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Real-time Manager for Widgetic Embed SDK
|
|
3
|
-
*
|
|
4
|
-
* Handles WebSocket connections for live widget updates with:
|
|
5
|
-
* - Automatic reconnection with exponential backoff
|
|
6
|
-
* - Security validation through AdvancedSecurityManager
|
|
7
|
-
* - Error recovery and resilience
|
|
8
|
-
* - Message queuing and retry logic
|
|
9
|
-
* - Performance monitoring integration
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Real-time configuration
|
|
13
|
-
*/
|
|
14
|
-
export interface RealtimeConfig {
|
|
15
|
-
enabled: boolean;
|
|
16
|
-
wsUrl?: string;
|
|
17
|
-
authentication: {
|
|
18
|
-
type: 'jwt' | 'apikey' | 'session';
|
|
19
|
-
credentials: string;
|
|
20
|
-
};
|
|
21
|
-
features: {
|
|
22
|
-
contentUpdates: boolean;
|
|
23
|
-
styleUpdates: boolean;
|
|
24
|
-
configUpdates: boolean;
|
|
25
|
-
dataUpdates: boolean;
|
|
26
|
-
publishUpdates?: boolean;
|
|
27
|
-
};
|
|
28
|
-
security: {
|
|
29
|
-
validateUpdates: boolean;
|
|
30
|
-
rateLimitPerMinute: number;
|
|
31
|
-
allowedUpdateTypes: string[];
|
|
32
|
-
};
|
|
33
|
-
reconnection: {
|
|
34
|
-
enabled: boolean;
|
|
35
|
-
maxAttempts: number;
|
|
36
|
-
baseDelay: number;
|
|
37
|
-
maxDelay: number;
|
|
38
|
-
};
|
|
39
|
-
fallback: {
|
|
40
|
-
enabled: boolean;
|
|
41
|
-
pollInterval?: number;
|
|
42
|
-
};
|
|
43
|
-
heartbeat: {
|
|
44
|
-
enabled: boolean;
|
|
45
|
-
interval: number;
|
|
46
|
-
timeout: number;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Real-time update message structure
|
|
51
|
-
*/
|
|
52
|
-
export interface RealtimeUpdate {
|
|
53
|
-
type: 'content' | 'style' | 'config' | 'data' | 'published';
|
|
54
|
-
compositionId: string;
|
|
55
|
-
data: any;
|
|
56
|
-
userId?: string;
|
|
57
|
-
timestamp: number;
|
|
58
|
-
version?: string;
|
|
59
|
-
partial?: boolean;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* WebSocket message types
|
|
63
|
-
*/
|
|
64
|
-
export interface RealtimeMessage {
|
|
65
|
-
type: 'widget_update' | 'subscription_confirmed' | 'heartbeat' | 'error' | 'authentication' | 'widget.published' | 'publish:complete';
|
|
66
|
-
id?: string;
|
|
67
|
-
compositionId?: string;
|
|
68
|
-
widgetId?: string;
|
|
69
|
-
subscriptionId?: string;
|
|
70
|
-
data?: any;
|
|
71
|
-
timestamp: number;
|
|
72
|
-
version?: string;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Widget update message
|
|
76
|
-
*/
|
|
77
|
-
export interface WidgetUpdateMessage extends RealtimeMessage {
|
|
78
|
-
type: 'widget_update';
|
|
79
|
-
compositionId: string;
|
|
80
|
-
updateType: 'content' | 'style' | 'config' | 'data';
|
|
81
|
-
data: any;
|
|
82
|
-
userId?: string;
|
|
83
|
-
version?: string;
|
|
84
|
-
partial?: boolean;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Real-time update handler function
|
|
88
|
-
*/
|
|
89
|
-
export type RealtimeUpdateHandler = (update: RealtimeUpdate) => Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
* Real-time subscription
|
|
92
|
-
*/
|
|
93
|
-
export declare class RealtimeSubscription {
|
|
94
|
-
readonly id: string;
|
|
95
|
-
readonly compositionId: string;
|
|
96
|
-
readonly handler: RealtimeUpdateHandler;
|
|
97
|
-
private _active;
|
|
98
|
-
constructor(compositionId: string, handler: RealtimeUpdateHandler);
|
|
99
|
-
isActive(): boolean;
|
|
100
|
-
unsubscribe(): void;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Connection state
|
|
104
|
-
*/
|
|
105
|
-
type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'error' | 'reconnecting';
|
|
106
|
-
/**
|
|
107
|
-
* Real-time Manager
|
|
108
|
-
*/
|
|
109
|
-
export declare class RealtimeManager {
|
|
110
|
-
private static instance;
|
|
111
|
-
private config;
|
|
112
|
-
private securityManager;
|
|
113
|
-
private performanceMonitor;
|
|
114
|
-
private socket;
|
|
115
|
-
private connectionState;
|
|
116
|
-
private connectionId;
|
|
117
|
-
private subscriptions;
|
|
118
|
-
private allSubscriptions;
|
|
119
|
-
private reconnectAttempts;
|
|
120
|
-
private reconnectTimer;
|
|
121
|
-
private messageQueue;
|
|
122
|
-
private retryTimer;
|
|
123
|
-
private heartbeatTimer;
|
|
124
|
-
private lastHeartbeat;
|
|
125
|
-
private heartbeatTimeout;
|
|
126
|
-
private pollingFallback;
|
|
127
|
-
private connectionStartTime;
|
|
128
|
-
private messageStats;
|
|
129
|
-
private constructor();
|
|
130
|
-
/**
|
|
131
|
-
* Get singleton instance
|
|
132
|
-
*/
|
|
133
|
-
static getInstance(config?: RealtimeConfig): RealtimeManager;
|
|
134
|
-
/**
|
|
135
|
-
* Initialize and connect to real-time service
|
|
136
|
-
*/
|
|
137
|
-
initialize(): Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* Connect to WebSocket server
|
|
140
|
-
*/
|
|
141
|
-
connect(): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* Subscribe to real-time updates for a composition
|
|
144
|
-
*/
|
|
145
|
-
subscribe(compositionId: string, handler: RealtimeUpdateHandler): RealtimeSubscription;
|
|
146
|
-
/**
|
|
147
|
-
* Unsubscribe from real-time updates
|
|
148
|
-
*/
|
|
149
|
-
unsubscribe(subscription: RealtimeSubscription): void;
|
|
150
|
-
/**
|
|
151
|
-
* Get active subscription composition IDs
|
|
152
|
-
*/
|
|
153
|
-
getActiveSubscriptions(): Set<string>;
|
|
154
|
-
/**
|
|
155
|
-
* Get API key for authentication
|
|
156
|
-
*/
|
|
157
|
-
getApiKey(): string;
|
|
158
|
-
/**
|
|
159
|
-
* Handle polled update from fallback system
|
|
160
|
-
*/
|
|
161
|
-
handlePolledUpdate(update: any): Promise<void>;
|
|
162
|
-
/**
|
|
163
|
-
* Build WebSocket URL with authentication
|
|
164
|
-
*/
|
|
165
|
-
private buildWebSocketUrl;
|
|
166
|
-
/**
|
|
167
|
-
* Handle WebSocket connection open
|
|
168
|
-
*/
|
|
169
|
-
private handleConnect;
|
|
170
|
-
/**
|
|
171
|
-
* Handle WebSocket message
|
|
172
|
-
*/
|
|
173
|
-
private handleMessage;
|
|
174
|
-
/**
|
|
175
|
-
* Handle widget update message
|
|
176
|
-
*/
|
|
177
|
-
private handleWidgetUpdate;
|
|
178
|
-
/**
|
|
179
|
-
* Handle widget published message (triggering reload / hot-swap)
|
|
180
|
-
*/
|
|
181
|
-
private handlePublishComplete;
|
|
182
|
-
/**
|
|
183
|
-
* Process a real-time update with security validation
|
|
184
|
-
*/
|
|
185
|
-
private processUpdate;
|
|
186
|
-
/**
|
|
187
|
-
* Handle subscription confirmation
|
|
188
|
-
*/
|
|
189
|
-
private handleSubscriptionConfirmed;
|
|
190
|
-
/**
|
|
191
|
-
* Handle heartbeat message
|
|
192
|
-
*/
|
|
193
|
-
private handleHeartbeat;
|
|
194
|
-
/**
|
|
195
|
-
* Handle server error message
|
|
196
|
-
*/
|
|
197
|
-
private handleServerError;
|
|
198
|
-
/**
|
|
199
|
-
* Handle authentication message
|
|
200
|
-
*/
|
|
201
|
-
private handleAuthentication;
|
|
202
|
-
/**
|
|
203
|
-
* Handle WebSocket disconnection
|
|
204
|
-
*/
|
|
205
|
-
private handleDisconnect;
|
|
206
|
-
/**
|
|
207
|
-
* Handle WebSocket error
|
|
208
|
-
*/
|
|
209
|
-
private handleError;
|
|
210
|
-
/**
|
|
211
|
-
* Handle connection errors with recovery
|
|
212
|
-
*/
|
|
213
|
-
private handleConnectionError;
|
|
214
|
-
/**
|
|
215
|
-
* Schedule reconnection with exponential backoff
|
|
216
|
-
*/
|
|
217
|
-
private scheduleReconnection;
|
|
218
|
-
/**
|
|
219
|
-
* Enable polling fallback
|
|
220
|
-
*/
|
|
221
|
-
private enablePollingFallback;
|
|
222
|
-
/**
|
|
223
|
-
* Send message to WebSocket server
|
|
224
|
-
*/
|
|
225
|
-
private sendMessage;
|
|
226
|
-
/**
|
|
227
|
-
* Queue message for retry
|
|
228
|
-
*/
|
|
229
|
-
private queueMessage;
|
|
230
|
-
/**
|
|
231
|
-
* Process message retry queue
|
|
232
|
-
*/
|
|
233
|
-
private processRetryQueue;
|
|
234
|
-
/**
|
|
235
|
-
* Process queued messages when connection is established
|
|
236
|
-
*/
|
|
237
|
-
private processMessageQueue;
|
|
238
|
-
/**
|
|
239
|
-
* Re-establish subscriptions after reconnection
|
|
240
|
-
*/
|
|
241
|
-
private reestablishSubscriptions;
|
|
242
|
-
/**
|
|
243
|
-
* Start heartbeat mechanism
|
|
244
|
-
*/
|
|
245
|
-
private startHeartbeat;
|
|
246
|
-
/**
|
|
247
|
-
* Stop heartbeat mechanism
|
|
248
|
-
*/
|
|
249
|
-
private stopHeartbeat;
|
|
250
|
-
/**
|
|
251
|
-
* Setup event listeners
|
|
252
|
-
*/
|
|
253
|
-
private setupEventListeners;
|
|
254
|
-
/**
|
|
255
|
-
* Emit custom event
|
|
256
|
-
*/
|
|
257
|
-
private emitEvent;
|
|
258
|
-
/**
|
|
259
|
-
* Get connection state
|
|
260
|
-
*/
|
|
261
|
-
getConnectionState(): ConnectionState;
|
|
262
|
-
/**
|
|
263
|
-
* Get connection statistics
|
|
264
|
-
*/
|
|
265
|
-
getStats(): {
|
|
266
|
-
connectionState: ConnectionState;
|
|
267
|
-
subscriptions: number;
|
|
268
|
-
messageStats: {
|
|
269
|
-
sent: number;
|
|
270
|
-
received: number;
|
|
271
|
-
errors: number;
|
|
272
|
-
};
|
|
273
|
-
reconnectAttempts: number;
|
|
274
|
-
lastHeartbeat: number;
|
|
275
|
-
queuedMessages: number;
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* Disconnect and cleanup
|
|
279
|
-
*/
|
|
280
|
-
disconnect(): void;
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Get singleton instance of real-time manager
|
|
284
|
-
*/
|
|
285
|
-
export declare function getRealtimeManager(config?: RealtimeConfig): RealtimeManager;
|
|
286
|
-
export {};
|