@widgetic/embed-sdk 0.0.0-stage → 2.0.7
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 +567 -2
- package/dist/browser/chunks/ABTestManager.js +1 -0
- package/dist/browser/chunks/advanced.js +1 -0
- package/dist/browser/chunks/api.js +1 -0
- package/dist/browser/chunks/core.js +1 -0
- package/dist/browser/chunks/display.js +1 -0
- package/dist/browser/chunks/media.js +1 -0
- package/dist/browser/chunks/messaging.js +1 -0
- package/dist/browser/chunks/performance.js +1 -0
- package/dist/browser/chunks/renderers.js +1 -0
- package/dist/browser/chunks/scanner.js +1 -0
- package/dist/browser/chunks/security.js +1 -0
- package/dist/browser/chunks/vendor.js +1 -0
- package/dist/browser/embed-bootstrap.js +1 -0
- package/dist/browser/embed-sdk.js +1 -0
- package/dist/esm/chunks/ABTestManager.js +1 -0
- package/dist/esm/chunks/advanced.js +1 -0
- package/dist/esm/chunks/api.js +1 -0
- package/dist/esm/chunks/core.js +1 -0
- package/dist/esm/chunks/display.js +1 -0
- package/dist/esm/chunks/media.js +1 -0
- package/dist/esm/chunks/messaging.js +1 -0
- package/dist/esm/chunks/performance.js +1 -0
- package/dist/esm/chunks/renderers.js +1 -0
- package/dist/esm/chunks/scanner.js +1 -0
- package/dist/esm/chunks/security.js +1 -0
- package/dist/esm/chunks/vendor.js +1 -0
- package/dist/esm/embed-bootstrap.js +1 -0
- package/dist/esm/embed-sdk.js +1 -0
- package/dist/esm/types/abTesting/ABTestElement.d.ts +120 -0
- package/dist/esm/types/abTesting/ABTestManager.d.ts +177 -0
- package/dist/esm/types/api/batch-client.d.ts +163 -0
- package/dist/esm/types/api/layers.d.ts +119 -0
- package/dist/esm/types/core/advanced-security-manager.d.ts +330 -0
- package/dist/esm/types/core/analytics-tracker.d.ts +224 -0
- package/dist/esm/types/core/auth-detector.d.ts +65 -0
- package/dist/esm/types/core/auth-manager.d.ts +90 -0
- package/dist/esm/types/core/autoscale-manager.d.ts +91 -0
- package/dist/esm/types/core/breakpoints.d.ts +48 -0
- package/dist/esm/types/core/config.d.ts +152 -0
- package/dist/esm/types/core/constants.d.ts +75 -0
- package/dist/esm/types/core/content-position-manager.d.ts +228 -0
- package/dist/esm/types/core/custom-element.d.ts +152 -0
- package/dist/esm/types/core/display-manager.d.ts +109 -0
- package/dist/esm/types/core/editor-overlay.d.ts +113 -0
- package/dist/esm/types/core/embed-sdk.d.ts +310 -0
- package/dist/esm/types/core/exit-intent-trigger.d.ts +114 -0
- package/dist/esm/types/core/lazy-loader.d.ts +111 -0
- package/dist/esm/types/core/media-manager.d.ts +364 -0
- package/dist/esm/types/core/messaging.d.ts +251 -0
- package/dist/esm/types/core/overlay-manager.d.ts +119 -0
- package/dist/esm/types/core/performance-monitor.d.ts +152 -0
- package/dist/esm/types/core/privacy-compliance.d.ts +236 -0
- package/dist/esm/types/core/realtime-manager.d.ts +279 -0
- package/dist/esm/types/core/resize-handler.d.ts +81 -0
- package/dist/esm/types/core/resource-optimizer.d.ts +133 -0
- package/dist/esm/types/core/responsive-manager.d.ts +49 -0
- package/dist/esm/types/core/scroll-trigger.d.ts +105 -0
- package/dist/esm/types/core/security-manager.d.ts +150 -0
- package/dist/esm/types/core/text-field-manager.d.ts +204 -0
- package/dist/esm/types/core/token-provider.d.ts +75 -0
- package/dist/esm/types/core/trigger-defaults.d.ts +36 -0
- package/dist/esm/types/core/trigger-manager.d.ts +248 -0
- package/dist/esm/types/core/types.d.ts +473 -0
- package/dist/esm/types/core/ui-sdk-loader.d.ts +90 -0
- package/dist/esm/types/core/widget-manager.d.ts +285 -0
- package/dist/esm/types/core/widget-metadata.d.ts +107 -0
- package/dist/esm/types/embed-sdk.d.ts +31 -0
- package/dist/esm/types/loaders/module-loader.d.ts +147 -0
- package/dist/esm/types/renderers/custom-element-renderer.d.ts +78 -0
- package/dist/esm/types/renderers/iframe-renderer.d.ts +185 -0
- package/dist/esm/types/renderers/widget-renderer.d.ts +173 -0
- package/dist/esm/types/sdk/embed-bootstrap.d.ts +84 -0
- package/dist/esm/types/sdk/embed-sdk.d.ts +31 -0
- package/dist/esm/types/translations/TranslationElement.d.ts +93 -0
- package/dist/esm/types/utils/browser.d.ts +29 -0
- package/dist/esm/types/utils/caseConversion.d.ts +2 -0
- package/dist/esm/types/utils/css-debug.d.ts +105 -0
- package/dist/esm/types/utils/device-detector.d.ts +100 -0
- package/dist/esm/types/utils/event-emitter.d.ts +14 -0
- package/dist/esm/types/utils/hydrate-published-host.d.ts +17 -0
- package/dist/esm/types/utils/logger.d.ts +31 -0
- package/dist/esm/types/utils/parser.d.ts +39 -0
- package/dist/esm/types/utils/portal.d.ts +74 -0
- package/dist/esm/types/utils/public-embed-lookup.d.ts +68 -0
- package/dist/esm/types/utils/published-host-display.d.ts +61 -0
- package/dist/umd/embed-bootstrap.js +1 -0
- package/dist/umd/embed-sdk.js +1 -0
- package/package.json +154 -4
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { TriggerManager } from "./trigger-manager.js";
|
|
2
|
+
import { type RealtimeConfig, type RealtimeSubscription } from "./realtime-manager.js";
|
|
3
|
+
import type { WidgetConfig, WidgetInstance, CompositionData, ResponsiveState } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Widget error types
|
|
6
|
+
*/
|
|
7
|
+
export interface WidgetError {
|
|
8
|
+
code: string;
|
|
9
|
+
message: string;
|
|
10
|
+
widgetId: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
details?: any;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Widget event types
|
|
16
|
+
*/
|
|
17
|
+
export interface WidgetEvent {
|
|
18
|
+
type: string;
|
|
19
|
+
widgetId: string;
|
|
20
|
+
data?: any;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Embed configuration for the SDK
|
|
25
|
+
*/
|
|
26
|
+
export interface EmbedConfig {
|
|
27
|
+
/** Enable real-time updates */
|
|
28
|
+
realtime?: RealtimeConfig;
|
|
29
|
+
/** Security configuration */
|
|
30
|
+
security?: {
|
|
31
|
+
enableSanitization?: boolean;
|
|
32
|
+
enableRateLimit?: boolean;
|
|
33
|
+
enableBotDetection?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/** Performance monitoring */
|
|
36
|
+
performance?: {
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
collectMetrics?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/** Development mode settings */
|
|
41
|
+
development?: {
|
|
42
|
+
debug?: boolean;
|
|
43
|
+
verbose?: boolean;
|
|
44
|
+
};
|
|
45
|
+
/** API configuration */
|
|
46
|
+
apiBaseUrl?: string;
|
|
47
|
+
/** API key */
|
|
48
|
+
apiKey?: string;
|
|
49
|
+
/** Access token */
|
|
50
|
+
accessToken?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Rendered widget with real-time capabilities
|
|
54
|
+
*/
|
|
55
|
+
export interface RenderedWidget extends WidgetInstance {
|
|
56
|
+
/** Real-time subscription for live updates */
|
|
57
|
+
realtimeSubscription?: RealtimeSubscription;
|
|
58
|
+
/** Last update timestamp */
|
|
59
|
+
lastUpdate?: number;
|
|
60
|
+
/** Update handlers */
|
|
61
|
+
updateHandlers?: Map<string, (data: any) => Promise<void>>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Security validation result
|
|
65
|
+
*/
|
|
66
|
+
export interface SecurityValidationResult {
|
|
67
|
+
allowed: boolean;
|
|
68
|
+
reason?: string;
|
|
69
|
+
severity?: 'low' | 'medium' | 'high' | 'critical';
|
|
70
|
+
sanitizedText?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Widget Manager - Core orchestrator for widget lifecycle with real-time support
|
|
74
|
+
*
|
|
75
|
+
* Note: Real-time updates are based on Compositions, not individual widgets.
|
|
76
|
+
* Multiple widget instances can render the same composition and will all
|
|
77
|
+
* receive updates when that composition is modified.
|
|
78
|
+
*/
|
|
79
|
+
export declare class WidgetManager {
|
|
80
|
+
private static instance;
|
|
81
|
+
private config;
|
|
82
|
+
private securityManager;
|
|
83
|
+
private displayManager;
|
|
84
|
+
private realtimeManager;
|
|
85
|
+
private performanceMonitor;
|
|
86
|
+
private apiConfig;
|
|
87
|
+
private widgetsApi;
|
|
88
|
+
private compositionsApi;
|
|
89
|
+
private widgets;
|
|
90
|
+
private widgetConfigs;
|
|
91
|
+
private compositionData;
|
|
92
|
+
private triggerManagers;
|
|
93
|
+
private compositionSubscriptions;
|
|
94
|
+
private compositionWidgets;
|
|
95
|
+
private eventListeners;
|
|
96
|
+
private errorHandlers;
|
|
97
|
+
private isInitialized;
|
|
98
|
+
private responsiveState;
|
|
99
|
+
private constructor();
|
|
100
|
+
/**
|
|
101
|
+
* Get singleton instance
|
|
102
|
+
*/
|
|
103
|
+
static getInstance(config?: EmbedConfig): WidgetManager;
|
|
104
|
+
/**
|
|
105
|
+
* Initialize the widget manager
|
|
106
|
+
*/
|
|
107
|
+
initialize(): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Register a widget instance with real-time support
|
|
110
|
+
*/
|
|
111
|
+
registerWidget(widgetId: string, config: WidgetConfig, element: HTMLElement): Promise<RenderedWidget>;
|
|
112
|
+
/**
|
|
113
|
+
* Set up real-time updates for a widget's composition
|
|
114
|
+
*/
|
|
115
|
+
private setupRealtimeUpdates;
|
|
116
|
+
/**
|
|
117
|
+
* Handle real-time update for a composition (affects all widgets rendering it)
|
|
118
|
+
*/
|
|
119
|
+
private handleCompositionUpdate;
|
|
120
|
+
/**
|
|
121
|
+
* Handle real-time update for a specific widget instance
|
|
122
|
+
*/
|
|
123
|
+
private handleWidgetUpdate;
|
|
124
|
+
/**
|
|
125
|
+
* Handle content updates
|
|
126
|
+
*/
|
|
127
|
+
private handleContentUpdate;
|
|
128
|
+
/**
|
|
129
|
+
* Handle style updates
|
|
130
|
+
*/
|
|
131
|
+
private handleStyleUpdate;
|
|
132
|
+
/**
|
|
133
|
+
* Handle configuration updates
|
|
134
|
+
*/
|
|
135
|
+
private handleConfigUpdate;
|
|
136
|
+
/**
|
|
137
|
+
* Handle data updates
|
|
138
|
+
*/
|
|
139
|
+
private handleDataUpdate;
|
|
140
|
+
/**
|
|
141
|
+
* Apply content to widget element
|
|
142
|
+
*/
|
|
143
|
+
private applyContentToWidget;
|
|
144
|
+
/**
|
|
145
|
+
* Apply styles to widget element
|
|
146
|
+
*/
|
|
147
|
+
private applyStylesToWidget;
|
|
148
|
+
/**
|
|
149
|
+
* Sanitize content for security
|
|
150
|
+
*/
|
|
151
|
+
private sanitizeContent;
|
|
152
|
+
/**
|
|
153
|
+
* Validate widget configuration
|
|
154
|
+
*/
|
|
155
|
+
private validateWidgetConfig;
|
|
156
|
+
/**
|
|
157
|
+
* ========================================
|
|
158
|
+
* DYNAMIC CONTENT METHODS
|
|
159
|
+
* ========================================
|
|
160
|
+
*/
|
|
161
|
+
/**
|
|
162
|
+
* Set dynamic content for a widget composition
|
|
163
|
+
* @param compositionId - ID of the composition to update
|
|
164
|
+
* @param content - New content data
|
|
165
|
+
* @param options - Update options
|
|
166
|
+
*/
|
|
167
|
+
setContent(compositionId: string, content: any, options?: {
|
|
168
|
+
validate?: boolean;
|
|
169
|
+
partial?: boolean;
|
|
170
|
+
source?: string;
|
|
171
|
+
version?: string;
|
|
172
|
+
}): Promise<{
|
|
173
|
+
success: boolean;
|
|
174
|
+
error?: string;
|
|
175
|
+
validationResult?: any;
|
|
176
|
+
}>;
|
|
177
|
+
/**
|
|
178
|
+
* Get content schema for a widget type
|
|
179
|
+
* @param widgetId - ID of the widget
|
|
180
|
+
*/
|
|
181
|
+
getContentSchema(widgetId: string): Promise<any>;
|
|
182
|
+
/**
|
|
183
|
+
* Get design schema for a widget type
|
|
184
|
+
* @param widgetId - ID of the widget
|
|
185
|
+
*/
|
|
186
|
+
getDesignSchema(widgetId: string): Promise<any>;
|
|
187
|
+
/**
|
|
188
|
+
* Validate content against widget schema
|
|
189
|
+
* @param compositionId - ID of the composition
|
|
190
|
+
* @param content - Content to validate
|
|
191
|
+
*/
|
|
192
|
+
validateContent(compositionId: string, content: any): Promise<{
|
|
193
|
+
valid: boolean;
|
|
194
|
+
errors?: any[];
|
|
195
|
+
warnings?: any[];
|
|
196
|
+
sanitizedContent?: any;
|
|
197
|
+
}>;
|
|
198
|
+
/**
|
|
199
|
+
* Get current content for a composition
|
|
200
|
+
* @param compositionId - ID of the composition
|
|
201
|
+
*/
|
|
202
|
+
getContent(compositionId: string): any;
|
|
203
|
+
/**
|
|
204
|
+
* Merge content for partial updates
|
|
205
|
+
* @param existingContent - Current content
|
|
206
|
+
* @param newContent - New content to merge
|
|
207
|
+
*/
|
|
208
|
+
private mergeContent;
|
|
209
|
+
/**
|
|
210
|
+
* Register custom update handler for a widget
|
|
211
|
+
*/
|
|
212
|
+
registerUpdateHandler(widgetId: string, updateType: 'content' | 'style' | 'config' | 'data', handler: (data: any) => Promise<void>): void;
|
|
213
|
+
/**
|
|
214
|
+
* Unregister a widget and cleanup resources
|
|
215
|
+
*/
|
|
216
|
+
unregisterWidget(widgetId: string): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Get widget instance by ID
|
|
219
|
+
*/
|
|
220
|
+
getWidget(widgetId: string): RenderedWidget | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* Get all widget instances
|
|
223
|
+
*/
|
|
224
|
+
getAllWidgets(): RenderedWidget[];
|
|
225
|
+
/**
|
|
226
|
+
* Get widgets by composition ID
|
|
227
|
+
*/
|
|
228
|
+
getWidgetsByComposition(compositionId: string): RenderedWidget[];
|
|
229
|
+
/**
|
|
230
|
+
* Setup responsive state tracking
|
|
231
|
+
*/
|
|
232
|
+
private setupResponsiveTracking;
|
|
233
|
+
/**
|
|
234
|
+
* Handle responsive state changes for all widgets
|
|
235
|
+
*/
|
|
236
|
+
private handleResponsiveChange;
|
|
237
|
+
/**
|
|
238
|
+
* Event management
|
|
239
|
+
*/
|
|
240
|
+
addEventListener(eventType: string, handler: (event: WidgetEvent) => void): void;
|
|
241
|
+
removeEventListener(eventType: string, handler: (event: WidgetEvent) => void): void;
|
|
242
|
+
addErrorHandler(handler: (error: WidgetError) => void): void;
|
|
243
|
+
removeErrorHandler(handler: (error: WidgetError) => void): void;
|
|
244
|
+
private emitEvent;
|
|
245
|
+
private emitError;
|
|
246
|
+
/**
|
|
247
|
+
* Setup global event listeners
|
|
248
|
+
*/
|
|
249
|
+
private setupEventListeners;
|
|
250
|
+
/**
|
|
251
|
+
* Get trigger manager for a widget
|
|
252
|
+
*/
|
|
253
|
+
getTriggerManager(widgetId: string): TriggerManager | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* Get all active trigger managers
|
|
256
|
+
*/
|
|
257
|
+
getAllTriggerManagers(): Map<string, TriggerManager>;
|
|
258
|
+
/**
|
|
259
|
+
* Get manager statistics
|
|
260
|
+
*/
|
|
261
|
+
getStats(): {
|
|
262
|
+
widgets: number;
|
|
263
|
+
compositions: number;
|
|
264
|
+
compositionSubscriptions: number;
|
|
265
|
+
triggerManagers: number;
|
|
266
|
+
responsiveState: ResponsiveState | null;
|
|
267
|
+
isInitialized: boolean;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Cleanup and disconnect
|
|
271
|
+
*/
|
|
272
|
+
destroy(): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* Get all compositions with active widgets
|
|
275
|
+
*/
|
|
276
|
+
getActiveCompositions(): string[];
|
|
277
|
+
/**
|
|
278
|
+
* Get composition data by ID
|
|
279
|
+
*/
|
|
280
|
+
getCompositionData(compositionId: string): CompositionData | undefined;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Get singleton instance of widget manager
|
|
284
|
+
*/
|
|
285
|
+
export declare function getWidgetManager(config?: EmbedConfig): WidgetManager;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget Metadata System
|
|
3
|
+
*
|
|
4
|
+
* Provides a standardized way to describe widget capabilities and requirements
|
|
5
|
+
* for proper feature loading and chunk optimization.
|
|
6
|
+
*/
|
|
7
|
+
export interface WidgetCapabilities {
|
|
8
|
+
type: 'media' | 'gallery' | 'form' | 'interactive' | 'custom';
|
|
9
|
+
version: string;
|
|
10
|
+
supportsAutoscale?: boolean;
|
|
11
|
+
supportsResponsive?: boolean;
|
|
12
|
+
supportsThemes?: boolean;
|
|
13
|
+
mediaCapabilities?: {
|
|
14
|
+
supportsPlay: boolean;
|
|
15
|
+
supportsPause: boolean;
|
|
16
|
+
supportsVolumeControl: boolean;
|
|
17
|
+
supportsSeek: boolean;
|
|
18
|
+
supportsGlobalVolume: boolean;
|
|
19
|
+
mediaType: 'audio' | 'video' | 'mixed';
|
|
20
|
+
};
|
|
21
|
+
contentCapabilities?: {
|
|
22
|
+
supportsPositionTracking: boolean;
|
|
23
|
+
supportsNavigation: boolean;
|
|
24
|
+
contentType: 'gallery' | 'carousel' | 'list' | 'grid';
|
|
25
|
+
totalItems?: number;
|
|
26
|
+
};
|
|
27
|
+
textCapabilities?: {
|
|
28
|
+
supportsTextPersistence: boolean;
|
|
29
|
+
supportsSanitization: boolean;
|
|
30
|
+
fields: string[];
|
|
31
|
+
maxLength?: number;
|
|
32
|
+
};
|
|
33
|
+
interactionCapabilities?: {
|
|
34
|
+
supportsClicks: boolean;
|
|
35
|
+
supportsFormSubmission: boolean;
|
|
36
|
+
supportsCustomEvents: boolean;
|
|
37
|
+
customEventTypes?: string[];
|
|
38
|
+
};
|
|
39
|
+
abTestingCapabilities?: {
|
|
40
|
+
supportsTracking: boolean;
|
|
41
|
+
trackableEvents: string[];
|
|
42
|
+
conversionGoals: string[];
|
|
43
|
+
};
|
|
44
|
+
displayCapabilities?: {
|
|
45
|
+
supportsFullscreen: boolean;
|
|
46
|
+
supportsOverlay: boolean;
|
|
47
|
+
supportsPopup: boolean;
|
|
48
|
+
supportsInline: boolean;
|
|
49
|
+
};
|
|
50
|
+
performanceRequirements?: {
|
|
51
|
+
requiresLazyLoading: boolean;
|
|
52
|
+
heavyAssets: boolean;
|
|
53
|
+
criticalRender: boolean;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export interface WidgetMetadata extends WidgetCapabilities {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
compositionId?: string;
|
|
61
|
+
breakpointConfig?: {
|
|
62
|
+
useBreakpoints: boolean;
|
|
63
|
+
mobile: number;
|
|
64
|
+
tablet: number;
|
|
65
|
+
desktop: number;
|
|
66
|
+
};
|
|
67
|
+
requiredChunks?: string[];
|
|
68
|
+
optionalChunks?: string[];
|
|
69
|
+
config?: Record<string, any>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Widget Metadata Analyzer
|
|
73
|
+
* Analyzes DOM elements and widget configurations to determine capabilities
|
|
74
|
+
*/
|
|
75
|
+
export declare class WidgetMetadataAnalyzer {
|
|
76
|
+
/**
|
|
77
|
+
* Analyze a widget element to determine its capabilities
|
|
78
|
+
*/
|
|
79
|
+
static analyzeElement(element: Element): WidgetCapabilities | null;
|
|
80
|
+
/**
|
|
81
|
+
* Get explicit metadata from data attributes or embedded config
|
|
82
|
+
*/
|
|
83
|
+
private static getExplicitMetadata;
|
|
84
|
+
/**
|
|
85
|
+
* Analyze element heuristically based on attributes, content, and structure
|
|
86
|
+
*/
|
|
87
|
+
private static analyzeHeuristically;
|
|
88
|
+
private static inferTypeFromStructure;
|
|
89
|
+
private static analyzeMediaCapabilities;
|
|
90
|
+
private static analyzeContentCapabilities;
|
|
91
|
+
private static analyzeTextCapabilities;
|
|
92
|
+
private static analyzeInteractionCapabilities;
|
|
93
|
+
private static analyzeDisplayCapabilities;
|
|
94
|
+
private static analyzeABTestingCapabilities;
|
|
95
|
+
private static checkResponsiveSupport;
|
|
96
|
+
private static checkAutoscaleSupport;
|
|
97
|
+
private static checkThemeSupport;
|
|
98
|
+
private static parseCapabilitiesString;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Convert widget capabilities to required chunks
|
|
102
|
+
*/
|
|
103
|
+
export declare function getRequiredChunks(capabilities: WidgetCapabilities): string[];
|
|
104
|
+
/**
|
|
105
|
+
* Enhanced widget requirements analyzer using metadata system
|
|
106
|
+
*/
|
|
107
|
+
export declare function analyzeWidgetRequirementsEnhanced(widgets: Element[]): string[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widgetic Embed SDK v1.0 - Distribution Entry Point
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for CDN and npm distribution.
|
|
5
|
+
* It provides a clean, complete API for embedding Widgetic widgets.
|
|
6
|
+
*/
|
|
7
|
+
export { EmbedSDK, getSDK } from "./core/embed-sdk.js";
|
|
8
|
+
export { config, getApiUrl, getCdnUrl, getConfiguration, setTokenProvider, getTokenProvider, getAuthToken, setApiKey, getAuthManager, } from "./core/config.js";
|
|
9
|
+
export type * from "./core/types.js";
|
|
10
|
+
export { type TokenProvider, StaticApiKeyProvider, EndpointTokenProvider, FunctionTokenProvider, DefaultTokenProvider, } from "./core/token-provider.js";
|
|
11
|
+
export { AuthManager, AuthError, type AuthManagerConfig, type TokenInfo, type TokenExchangeOptions, } from "./core/auth-manager.js";
|
|
12
|
+
export { BatchApiClient, getBatchClient, resetBatchClient, type CompositionData, type WidgetData, type BatchCompositionsResponse, type BatchWidgetsResponse, } from "./api/batch-client.js";
|
|
13
|
+
export { ModuleLoader, getModuleLoader, resetModuleLoader, type WidgetModule, type LoadedModule, type ModuleLoadOptions, } from "./loaders/module-loader.js";
|
|
14
|
+
export { WidgetRenderer, getWidgetRenderer, resetWidgetRenderer, type RenderMode, type WidgetRenderOptions, type RenderedWidget, } from "./renderers/widget-renderer.js";
|
|
15
|
+
export { CustomElementRenderer, type CustomElementRenderOptions, } from "./renderers/custom-element-renderer.js";
|
|
16
|
+
export { IframeRenderer, type IframeRenderOptions, } from "./renderers/iframe-renderer.js";
|
|
17
|
+
export { WidgeticWidget, registerWidgeticWidget, } from "./core/custom-element.js";
|
|
18
|
+
export { CSSDebugger, cssDebugger, enableCSSDebug, disableCSSDebug, analyzeWidgetCSS, monitorWidgetCSS, type CSSConflict, type StyleIsolationReport, } from "./utils/css-debug.js";
|
|
19
|
+
export { WidgeticMessenger, getMessenger, resetMessenger, type WidgeticMessage, type MessagingSecurityOptions, } from "./core/messaging.js";
|
|
20
|
+
export { ABTestManager, type ABTestConfig, type ABTestAssignment, } from "./abTesting/ABTestManager.js";
|
|
21
|
+
export { ABTestElement, } from "./abTesting/ABTestElement.js";
|
|
22
|
+
export { TranslationElement, } from "./translations/TranslationElement.js";
|
|
23
|
+
export { log } from "./utils/logger.js";
|
|
24
|
+
export { detectBrowserCapabilities, determineBestRenderMode, } from "./utils/browser.js";
|
|
25
|
+
export { parseWidgetConfig, generateInstanceId, isValidWidgetElement, } from "./utils/parser.js";
|
|
26
|
+
export { HighLevelAPI, MidLevelAPI, LowLevelAPI, type HighLevelAPIType, type MidLevelAPIType, type LowLevelAPIType, } from "./api/layers.js";
|
|
27
|
+
import { EmbedSDK } from "./core/embed-sdk.js";
|
|
28
|
+
declare const sdk: EmbedSDK;
|
|
29
|
+
export default sdk;
|
|
30
|
+
export { EmbedSDK as WidgeticEmbedSDK } from "./core/embed-sdk.js";
|
|
31
|
+
export { toCamel, toSnake } from "./utils/caseConversion";
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { WidgetData } from "../api/batch-client.js";
|
|
2
|
+
export interface WidgetModule {
|
|
3
|
+
id: string;
|
|
4
|
+
version: string;
|
|
5
|
+
component: any;
|
|
6
|
+
metadata?: Record<string, any>;
|
|
7
|
+
dependencies?: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface LoadedModule {
|
|
10
|
+
module: WidgetModule;
|
|
11
|
+
url: string;
|
|
12
|
+
loadTime: number;
|
|
13
|
+
cached: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ModuleLoadOptions {
|
|
16
|
+
version?: string;
|
|
17
|
+
force?: boolean;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
retries?: number;
|
|
20
|
+
}
|
|
21
|
+
interface ModuleLoaderConfig {
|
|
22
|
+
cacheTTL: number;
|
|
23
|
+
loadTimeout: number;
|
|
24
|
+
maxRetries: number;
|
|
25
|
+
retryDelay: number;
|
|
26
|
+
enableHttp3: boolean;
|
|
27
|
+
cdnBaseUrl?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Dynamic widget module loader with HTTP/3 support, caching, and version management
|
|
31
|
+
*/
|
|
32
|
+
export declare class ModuleLoader {
|
|
33
|
+
private moduleCache;
|
|
34
|
+
private loadingPromises;
|
|
35
|
+
private dependencyGraph;
|
|
36
|
+
private readonly config;
|
|
37
|
+
private http3Supported;
|
|
38
|
+
constructor(config?: Partial<ModuleLoaderConfig>);
|
|
39
|
+
/**
|
|
40
|
+
* Load widget module with automatic version resolution
|
|
41
|
+
*/
|
|
42
|
+
loadModule(widgetData: WidgetData, options?: ModuleLoadOptions): Promise<LoadedModule>;
|
|
43
|
+
/**
|
|
44
|
+
* Load multiple modules with dependency resolution
|
|
45
|
+
*/
|
|
46
|
+
loadModules(widgetDataList: WidgetData[], options?: ModuleLoadOptions): Promise<LoadedModule[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Get latest version for a widget
|
|
49
|
+
*/
|
|
50
|
+
getLatestVersion(widgetId: string): Promise<string | null>;
|
|
51
|
+
/**
|
|
52
|
+
* Preload modules for performance
|
|
53
|
+
*/
|
|
54
|
+
preloadModules(widgetDataList: WidgetData[]): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Invalidate cached module
|
|
57
|
+
*/
|
|
58
|
+
invalidateModule(widgetId: string, version?: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Clear all cached modules
|
|
61
|
+
*/
|
|
62
|
+
clearCache(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Get cache statistics
|
|
65
|
+
*/
|
|
66
|
+
getCacheStats(): {
|
|
67
|
+
size: number;
|
|
68
|
+
entries: {
|
|
69
|
+
key: string;
|
|
70
|
+
version: string;
|
|
71
|
+
age: number;
|
|
72
|
+
ttl: number;
|
|
73
|
+
url: string;
|
|
74
|
+
}[];
|
|
75
|
+
loading: number;
|
|
76
|
+
http3Supported: boolean;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Perform the actual module loading
|
|
80
|
+
*/
|
|
81
|
+
private doLoadModule;
|
|
82
|
+
/**
|
|
83
|
+
* Load module from URL with HTTP/3 support
|
|
84
|
+
*/
|
|
85
|
+
private loadModuleFromUrl;
|
|
86
|
+
/**
|
|
87
|
+
* Load ES module with timeout
|
|
88
|
+
*/
|
|
89
|
+
private loadEsModule;
|
|
90
|
+
/**
|
|
91
|
+
* Fetch module text with HTTP/3 support and timeout
|
|
92
|
+
*/
|
|
93
|
+
private fetchModuleText;
|
|
94
|
+
/**
|
|
95
|
+
* Fetch with HTTP/3 support and timeout
|
|
96
|
+
*/
|
|
97
|
+
private fetchWithHttp3;
|
|
98
|
+
/**
|
|
99
|
+
* Detect HTTP/3 support
|
|
100
|
+
*/
|
|
101
|
+
private detectHttp3Support;
|
|
102
|
+
/**
|
|
103
|
+
* Extract widget from ES module exports
|
|
104
|
+
*/
|
|
105
|
+
private extractWidgetFromEsModule;
|
|
106
|
+
/**
|
|
107
|
+
* Evaluate UMD module text
|
|
108
|
+
*/
|
|
109
|
+
private evaluateUmdModule;
|
|
110
|
+
/**
|
|
111
|
+
* Load module dependencies
|
|
112
|
+
*/
|
|
113
|
+
private loadDependencies;
|
|
114
|
+
/**
|
|
115
|
+
* Resolve dependency order for loading
|
|
116
|
+
*/
|
|
117
|
+
private resolveDependencyOrder;
|
|
118
|
+
/**
|
|
119
|
+
* Resolve module URL from widget data
|
|
120
|
+
*/
|
|
121
|
+
private resolveModuleUrl;
|
|
122
|
+
/**
|
|
123
|
+
* Validate module structure
|
|
124
|
+
*/
|
|
125
|
+
private validateModule;
|
|
126
|
+
/**
|
|
127
|
+
* Get module cache key
|
|
128
|
+
*/
|
|
129
|
+
private getModuleKey;
|
|
130
|
+
/**
|
|
131
|
+
* Get cached module if valid
|
|
132
|
+
*/
|
|
133
|
+
private getCachedModule;
|
|
134
|
+
/**
|
|
135
|
+
* Cache module
|
|
136
|
+
*/
|
|
137
|
+
private cacheModule;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get or create global module loader instance
|
|
141
|
+
*/
|
|
142
|
+
export declare function getModuleLoader(): ModuleLoader;
|
|
143
|
+
/**
|
|
144
|
+
* Reset global module loader (useful for testing)
|
|
145
|
+
*/
|
|
146
|
+
export declare function resetModuleLoader(): void;
|
|
147
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { CompositionData, WidgetData } from "../api/batch-client.js";
|
|
2
|
+
import type { LoadedModule } from "../loaders/module-loader.js";
|
|
3
|
+
import type { ResizeMode } from "../core/types.js";
|
|
4
|
+
import type { AutoScaleConfig } from "../core/autoscale-manager.js";
|
|
5
|
+
import type { RenderedWidget } from "./widget-renderer.js";
|
|
6
|
+
import type { MediaConfig } from '../core/types';
|
|
7
|
+
export interface CustomElementRenderOptions {
|
|
8
|
+
compositionId: string;
|
|
9
|
+
compositionData: CompositionData;
|
|
10
|
+
widgetData: WidgetData;
|
|
11
|
+
loadedModule: LoadedModule;
|
|
12
|
+
width?: string | number;
|
|
13
|
+
height?: string | number;
|
|
14
|
+
resize?: ResizeMode;
|
|
15
|
+
autoscale?: boolean | AutoScaleConfig;
|
|
16
|
+
adaptive?: number;
|
|
17
|
+
media?: MediaConfig;
|
|
18
|
+
content?: {
|
|
19
|
+
/** Type of content being tracked */
|
|
20
|
+
contentType?: 'gallery' | 'carousel' | 'slider' | 'stepper' | 'tabs' | 'list' | 'custom';
|
|
21
|
+
/** Whether to persist position state in localStorage */
|
|
22
|
+
persistState?: boolean;
|
|
23
|
+
/** Whether to auto-resume position after page refresh */
|
|
24
|
+
autoResume?: boolean;
|
|
25
|
+
/** Maximum time since last interaction to allow auto-resume (ms, default: 24 hours) */
|
|
26
|
+
autoResumeTimeout?: number;
|
|
27
|
+
/** Whether to track additional metadata */
|
|
28
|
+
trackMetadata?: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Enhanced custom element renderer with Phase 3 capabilities
|
|
33
|
+
* Uses the new WidgeticWidget custom element with full lifecycle management
|
|
34
|
+
*/
|
|
35
|
+
export declare class CustomElementRenderer {
|
|
36
|
+
private autoScaleManager;
|
|
37
|
+
constructor();
|
|
38
|
+
/**
|
|
39
|
+
* Render widget using the new Phase 3 custom element
|
|
40
|
+
*/
|
|
41
|
+
render(options: CustomElementRenderOptions): Promise<RenderedWidget>;
|
|
42
|
+
/**
|
|
43
|
+
* Legacy method for compatibility - use render() instead
|
|
44
|
+
*/
|
|
45
|
+
private initializeWidget;
|
|
46
|
+
/**
|
|
47
|
+
* Render framework components (React, Vue, etc.)
|
|
48
|
+
*/
|
|
49
|
+
private renderFrameworkComponent;
|
|
50
|
+
/**
|
|
51
|
+
* Apply element styling and responsive behavior
|
|
52
|
+
*/
|
|
53
|
+
private applyElementStyling;
|
|
54
|
+
/**
|
|
55
|
+
* Make element responsive
|
|
56
|
+
*/
|
|
57
|
+
private makeResponsive;
|
|
58
|
+
/**
|
|
59
|
+
* Enable autoscale functionality
|
|
60
|
+
*/
|
|
61
|
+
private enableAutoscale;
|
|
62
|
+
/**
|
|
63
|
+
* Show loading state
|
|
64
|
+
*/
|
|
65
|
+
private showLoadingState;
|
|
66
|
+
/**
|
|
67
|
+
* Show error state
|
|
68
|
+
*/
|
|
69
|
+
private showErrorState;
|
|
70
|
+
/**
|
|
71
|
+
* Set up event listeners for media events from custom element
|
|
72
|
+
*/
|
|
73
|
+
private setupCustomElementMediaListener;
|
|
74
|
+
/**
|
|
75
|
+
* Set up event listeners for content position events from custom element
|
|
76
|
+
*/
|
|
77
|
+
private setupCustomElementContentListener;
|
|
78
|
+
}
|