@widgetic/embed-sdk 2.0.16 → 2.1.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.
Files changed (50) hide show
  1. package/README.md +36 -10
  2. package/dist/browser/chunks/ABTestManager.js +1 -1
  3. package/dist/browser/chunks/api.js +1 -1
  4. package/dist/browser/chunks/core.js +1 -1
  5. package/dist/browser/chunks/renderers.js +1 -1
  6. package/dist/browser/chunks/scanner.js +1 -1
  7. package/dist/browser/chunks/security.js +1 -1
  8. package/dist/browser/chunks/workflows.js +1 -0
  9. package/dist/browser/embed-bootstrap.js +1 -1
  10. package/dist/browser/embed-sdk.js +1 -1
  11. package/dist/esm/chunks/ABTestManager.js +1 -1
  12. package/dist/esm/chunks/api.js +1 -1
  13. package/dist/esm/chunks/core.js +1 -1
  14. package/dist/esm/chunks/renderers.js +1 -1
  15. package/dist/esm/chunks/scanner.js +1 -1
  16. package/dist/esm/chunks/security.js +1 -1
  17. package/dist/esm/chunks/workflows.js +1 -0
  18. package/dist/esm/embed-bootstrap.js +1 -1
  19. package/dist/esm/embed-sdk.js +1 -1
  20. package/dist/esm/types/abTesting/abVisitor.d.ts +2 -0
  21. package/dist/esm/types/core/advanced-security-manager.d.ts +3 -0
  22. package/dist/esm/types/core/autoscale-manager.d.ts +6 -0
  23. package/dist/esm/types/core/widget-manager.d.ts +8 -43
  24. package/dist/esm/types/embed-sdk.d.ts +1 -0
  25. package/dist/esm/types/sdk/embed-sdk.d.ts +1 -0
  26. package/dist/esm/types/utils/declarative-embed-parser.d.ts +5 -0
  27. package/dist/esm/types/utils/host-workflow-watch.d.ts +62 -0
  28. package/dist/esm/types/utils/hydrate-published-host.d.ts +8 -4
  29. package/dist/esm/types/utils/mount-direct-widget.d.ts +12 -0
  30. package/dist/esm/types/utils/public-embed-lookup.d.ts +5 -0
  31. package/dist/esm/types/utils/published-host-bridge.d.ts +10 -0
  32. package/dist/esm/types/utils/workflow-code-loader.d.ts +14 -0
  33. package/dist/esm/types/utils/workflow-code-loader.umd.d.ts +32 -0
  34. package/dist/esm/types/utils/workflow-embed-registry.d.ts +15 -0
  35. package/dist/esm/types/utils/workflow-page-events.d.ts +41 -0
  36. package/dist/esm/types/utils/workflow-shared-contract.d.ts +35 -0
  37. package/dist/esm/types/utils/workflow-shared-services.d.ts +84 -0
  38. package/dist/esm/types/workflows/umd-entry.d.ts +1 -0
  39. package/dist/esm/types/workflows/visitor-position.d.ts +32 -0
  40. package/dist/esm/types/workflows/workflow-autoscale.d.ts +41 -0
  41. package/dist/esm/types/workflows/workflow-counts.d.ts +65 -0
  42. package/dist/esm/types/workflows/workflow-host.d.ts +71 -0
  43. package/dist/esm/types/workflows/workflow-lookup.d.ts +53 -0
  44. package/dist/esm/types/workflows/workflow-signals.d.ts +34 -0
  45. package/dist/esm/types/workflows/workflow-stage.d.ts +154 -0
  46. package/dist/umd/embed-bootstrap.js +1 -1
  47. package/dist/umd/embed-sdk-workflows.js +1 -0
  48. package/dist/umd/embed-sdk.js +1 -1
  49. package/package.json +2 -1
  50. 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.16",
3
+ "version": "2.1.0",
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",
@@ -102,6 +102,7 @@
102
102
  "@vitest/coverage-v8": "^5.0.3",
103
103
  "@vitest/ui": "^5.0.3",
104
104
  "@widgetic/api-sdk": "file:../api-sdk",
105
+ "@widgetic/workflows-engine": "^0.1.1",
105
106
  "benchmark": "^2.1.4",
106
107
  "cross-env": "^7.0.3",
107
108
  "eslint": "^9.0.0",
@@ -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 {};