@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,185 @@
|
|
|
1
|
+
import type { CompositionData, WidgetData } from "../api/batch-client.js";
|
|
2
|
+
import type { WidgetRenderOptions, RenderedWidget } from "./widget-renderer.js";
|
|
3
|
+
export interface IframeRenderOptions extends WidgetRenderOptions {
|
|
4
|
+
/** Allow fullscreen for iframe */
|
|
5
|
+
allowFullscreen?: boolean;
|
|
6
|
+
/** Sandbox restrictions */
|
|
7
|
+
sandbox?: string[];
|
|
8
|
+
/** Loading strategy */
|
|
9
|
+
loading?: "lazy" | "eager";
|
|
10
|
+
/** Enable resize observer */
|
|
11
|
+
enableResize?: boolean;
|
|
12
|
+
/** Responsive breakpoint for mobile UI trigger */
|
|
13
|
+
responsive?: number;
|
|
14
|
+
/** Composition data for rendering */
|
|
15
|
+
compositionData?: CompositionData;
|
|
16
|
+
/** Widget data for rendering */
|
|
17
|
+
widgetData?: WidgetData;
|
|
18
|
+
/** Custom sandbox permissions */
|
|
19
|
+
allowedFeatures?: string[];
|
|
20
|
+
/** Security configuration */
|
|
21
|
+
security?: {
|
|
22
|
+
enableCSP?: boolean;
|
|
23
|
+
allowedOrigins?: string[];
|
|
24
|
+
signatureValidation?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/** Fallback configuration */
|
|
27
|
+
fallback?: {
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
timeout?: number;
|
|
30
|
+
retryCount?: number;
|
|
31
|
+
};
|
|
32
|
+
/** Media management configuration */
|
|
33
|
+
media?: {
|
|
34
|
+
/** Whether this widget should auto-pause others when playing */
|
|
35
|
+
autoPause?: boolean;
|
|
36
|
+
/** Type of media this widget can play */
|
|
37
|
+
mediaType?: 'audio' | 'video' | 'both';
|
|
38
|
+
/** Priority level for conflict resolution (0-10, default: 5) */
|
|
39
|
+
priority?: number;
|
|
40
|
+
/** Whether to persist playback state in localStorage */
|
|
41
|
+
persistState?: boolean;
|
|
42
|
+
/** Whether to allow simultaneous playback with specific media types */
|
|
43
|
+
allowSimultaneous?: ('audio' | 'video')[];
|
|
44
|
+
};
|
|
45
|
+
/** Content position tracking configuration */
|
|
46
|
+
content?: {
|
|
47
|
+
/** Type of content being tracked */
|
|
48
|
+
contentType?: 'gallery' | 'carousel' | 'slider' | 'stepper' | 'tabs' | 'list' | 'custom';
|
|
49
|
+
/** Whether to persist position state in localStorage */
|
|
50
|
+
persistState?: boolean;
|
|
51
|
+
/** Whether to auto-resume position after page refresh */
|
|
52
|
+
autoResume?: boolean;
|
|
53
|
+
/** Maximum time since last interaction to allow auto-resume (ms, default: 24 hours) */
|
|
54
|
+
autoResumeTimeout?: number;
|
|
55
|
+
/** Whether to track additional metadata */
|
|
56
|
+
trackMetadata?: boolean;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Enhanced iframe renderer with advanced sandboxing, security, and resize modes
|
|
61
|
+
*/
|
|
62
|
+
export declare class IframeRenderer {
|
|
63
|
+
private messageQueue;
|
|
64
|
+
private iframeRegistry;
|
|
65
|
+
private loadingTimeouts;
|
|
66
|
+
private autoScaleManager;
|
|
67
|
+
constructor();
|
|
68
|
+
/**
|
|
69
|
+
* Render widget in an iframe with enhanced capabilities
|
|
70
|
+
*/
|
|
71
|
+
renderWidget(options: IframeRenderOptions): Promise<RenderedWidget>;
|
|
72
|
+
/**
|
|
73
|
+
* Render multiple widgets in iframes
|
|
74
|
+
*/
|
|
75
|
+
renderWidgets(optionsArray: IframeRenderOptions[]): Promise<RenderedWidget[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Create secure iframe with advanced configuration
|
|
78
|
+
*/
|
|
79
|
+
private createSecureIframe;
|
|
80
|
+
/**
|
|
81
|
+
* Get default sandbox permissions (most restrictive secure set)
|
|
82
|
+
*/
|
|
83
|
+
private getDefaultSandboxPermissions;
|
|
84
|
+
/**
|
|
85
|
+
* Get default allowed features for Feature Policy
|
|
86
|
+
*/
|
|
87
|
+
private getDefaultAllowedFeatures;
|
|
88
|
+
/**
|
|
89
|
+
* Apply enhanced sandbox security
|
|
90
|
+
*/
|
|
91
|
+
private applySandboxSecurity;
|
|
92
|
+
/**
|
|
93
|
+
* Generate Content Security Policy
|
|
94
|
+
*/
|
|
95
|
+
private generateCSP;
|
|
96
|
+
/**
|
|
97
|
+
* Build secure iframe URL with enhanced security parameters
|
|
98
|
+
*/
|
|
99
|
+
private buildSecureIframeUrl;
|
|
100
|
+
/**
|
|
101
|
+
* Apply iframe styling and responsive behavior
|
|
102
|
+
*/
|
|
103
|
+
private applyIframeStyling;
|
|
104
|
+
/**
|
|
105
|
+
* Make iframe responsive
|
|
106
|
+
*/
|
|
107
|
+
private makeIframeResponsive;
|
|
108
|
+
/**
|
|
109
|
+
* Enable autoscale functionality for iframe
|
|
110
|
+
*/
|
|
111
|
+
private enableIframeAutoscale;
|
|
112
|
+
/**
|
|
113
|
+
* Setup loading optimization and fallback handling
|
|
114
|
+
*/
|
|
115
|
+
private setupLoadingOptimization;
|
|
116
|
+
/**
|
|
117
|
+
* Handle iframe fallback when loading fails
|
|
118
|
+
*/
|
|
119
|
+
private handleIframeFallback;
|
|
120
|
+
/**
|
|
121
|
+
* Setup enhanced iframe messaging with comprehensive PostMessage protocol
|
|
122
|
+
*/
|
|
123
|
+
private setupEnhancedIframeMessaging;
|
|
124
|
+
/**
|
|
125
|
+
* Handle enhanced messages received from iframe
|
|
126
|
+
*/
|
|
127
|
+
private handleEnhancedIframeMessage;
|
|
128
|
+
/**
|
|
129
|
+
* Handle resize messages from iframe
|
|
130
|
+
*/
|
|
131
|
+
private handleResizeMessage;
|
|
132
|
+
/**
|
|
133
|
+
* Handle ready messages from iframe
|
|
134
|
+
*/
|
|
135
|
+
private handleReadyMessage;
|
|
136
|
+
/**
|
|
137
|
+
* Handle error messages from iframe
|
|
138
|
+
*/
|
|
139
|
+
private handleErrorMessage;
|
|
140
|
+
/**
|
|
141
|
+
* Handle data messages from iframe
|
|
142
|
+
*/
|
|
143
|
+
private handleDataMessage;
|
|
144
|
+
/**
|
|
145
|
+
* Handle event messages from iframe
|
|
146
|
+
*/
|
|
147
|
+
private handleEventMessage;
|
|
148
|
+
/**
|
|
149
|
+
* Send message to iframe using enhanced messaging
|
|
150
|
+
*/
|
|
151
|
+
sendMessageToIframe(instanceId: string, messageType: string, payload: any): void;
|
|
152
|
+
/**
|
|
153
|
+
* Add loading indicator
|
|
154
|
+
*/
|
|
155
|
+
private addLoadingIndicator;
|
|
156
|
+
/**
|
|
157
|
+
* Remove loading indicator
|
|
158
|
+
*/
|
|
159
|
+
private removeLoadingIndicator;
|
|
160
|
+
/**
|
|
161
|
+
* Create error element for failed renders
|
|
162
|
+
*/
|
|
163
|
+
private createErrorElement;
|
|
164
|
+
/**
|
|
165
|
+
* Cleanup iframe widget
|
|
166
|
+
*/
|
|
167
|
+
cleanupWidget(iframe: HTMLIFrameElement): void;
|
|
168
|
+
/**
|
|
169
|
+
* Cleanup iframe and messaging resources
|
|
170
|
+
*/
|
|
171
|
+
cleanupIframe(compositionId: string): void;
|
|
172
|
+
/**
|
|
173
|
+
* Setup responsive breakpoint monitoring for iframe
|
|
174
|
+
*/
|
|
175
|
+
private setupResponsiveMonitoring;
|
|
176
|
+
/**
|
|
177
|
+
* Set up PostMessage listener for media events from iframe content
|
|
178
|
+
*/
|
|
179
|
+
private setupIframeMediaListener;
|
|
180
|
+
/**
|
|
181
|
+
* Set up PostMessage listener for content position events from iframe
|
|
182
|
+
*/
|
|
183
|
+
private setupIframeContentListener;
|
|
184
|
+
}
|
|
185
|
+
export declare function getIframeRenderer(): IframeRenderer;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { type CompositionData, type 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
|
+
export type RenderMode = "auto" | "custom-element" | "iframe";
|
|
6
|
+
export interface WidgetRenderOptions {
|
|
7
|
+
compositionId: string;
|
|
8
|
+
renderMode?: RenderMode;
|
|
9
|
+
width?: string | number;
|
|
10
|
+
height?: string | number;
|
|
11
|
+
resize?: ResizeMode;
|
|
12
|
+
autoscale?: boolean | AutoScaleConfig;
|
|
13
|
+
adaptive?: number;
|
|
14
|
+
container?: Element;
|
|
15
|
+
}
|
|
16
|
+
export interface RenderedWidget {
|
|
17
|
+
id: string;
|
|
18
|
+
element: Element;
|
|
19
|
+
compositionData: CompositionData;
|
|
20
|
+
widgetData: WidgetData;
|
|
21
|
+
loadedModule?: LoadedModule;
|
|
22
|
+
renderMode: RenderMode;
|
|
23
|
+
cleanup: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Enhanced widget renderer with Phase 2 capabilities:
|
|
27
|
+
* - Batch API integration
|
|
28
|
+
* - Dynamic module loading
|
|
29
|
+
* - Smart render mode selection
|
|
30
|
+
* - Performance optimizations
|
|
31
|
+
*/
|
|
32
|
+
export declare class WidgetRenderer {
|
|
33
|
+
private batchClient;
|
|
34
|
+
private moduleLoader;
|
|
35
|
+
private customElementRenderer;
|
|
36
|
+
private iframeRenderer;
|
|
37
|
+
private renderedWidgets;
|
|
38
|
+
/**
|
|
39
|
+
* Render a single widget with enhanced capabilities
|
|
40
|
+
*/
|
|
41
|
+
renderWidget(options: WidgetRenderOptions): Promise<RenderedWidget>;
|
|
42
|
+
/**
|
|
43
|
+
* Render multiple widgets efficiently with batch optimization
|
|
44
|
+
*/
|
|
45
|
+
renderWidgets(optionsList: WidgetRenderOptions[]): Promise<RenderedWidget[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Get rendered widget by ID
|
|
48
|
+
*/
|
|
49
|
+
getWidget(widgetId: string): RenderedWidget | null;
|
|
50
|
+
/**
|
|
51
|
+
* Get all rendered widgets
|
|
52
|
+
*/
|
|
53
|
+
getAllWidgets(): RenderedWidget[];
|
|
54
|
+
/**
|
|
55
|
+
* Refresh a widget (reload data and re-render)
|
|
56
|
+
*/
|
|
57
|
+
refreshWidget(widgetId: string): Promise<RenderedWidget | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Cleanup widget and remove from registry
|
|
60
|
+
*/
|
|
61
|
+
cleanupWidget(widgetId: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Cleanup all widgets
|
|
64
|
+
*/
|
|
65
|
+
cleanupAll(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Get performance statistics
|
|
68
|
+
*/
|
|
69
|
+
getStats(): {
|
|
70
|
+
renderedWidgets: number;
|
|
71
|
+
batchCache: {
|
|
72
|
+
compositions: {
|
|
73
|
+
size: number;
|
|
74
|
+
entries: {
|
|
75
|
+
id: string;
|
|
76
|
+
age: number;
|
|
77
|
+
ttl: number;
|
|
78
|
+
}[];
|
|
79
|
+
};
|
|
80
|
+
widgets: {
|
|
81
|
+
size: number;
|
|
82
|
+
entries: {
|
|
83
|
+
id: string;
|
|
84
|
+
age: number;
|
|
85
|
+
ttl: number;
|
|
86
|
+
}[];
|
|
87
|
+
};
|
|
88
|
+
pending: {
|
|
89
|
+
compositions: number;
|
|
90
|
+
widgets: number;
|
|
91
|
+
};
|
|
92
|
+
queues: {
|
|
93
|
+
compositions: number;
|
|
94
|
+
widgets: number;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
moduleCache: {
|
|
98
|
+
size: number;
|
|
99
|
+
entries: {
|
|
100
|
+
key: string;
|
|
101
|
+
version: string;
|
|
102
|
+
age: number;
|
|
103
|
+
ttl: number;
|
|
104
|
+
url: string;
|
|
105
|
+
}[];
|
|
106
|
+
loading: number;
|
|
107
|
+
http3Supported: boolean;
|
|
108
|
+
};
|
|
109
|
+
widgets: {
|
|
110
|
+
id: string;
|
|
111
|
+
compositionId: string;
|
|
112
|
+
widgetType: string;
|
|
113
|
+
renderMode: RenderMode;
|
|
114
|
+
hasModule: boolean;
|
|
115
|
+
}[];
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Render single widget with pre-fetched data
|
|
119
|
+
*/
|
|
120
|
+
private renderSingleWidgetWithData;
|
|
121
|
+
/**
|
|
122
|
+
* Render widget with custom element
|
|
123
|
+
*/
|
|
124
|
+
private renderWithCustomElement;
|
|
125
|
+
/**
|
|
126
|
+
* Render widget with iframe
|
|
127
|
+
*/
|
|
128
|
+
private renderWithIframe;
|
|
129
|
+
/**
|
|
130
|
+
* Fallback rendering when primary method fails
|
|
131
|
+
*/
|
|
132
|
+
private renderFallback;
|
|
133
|
+
/**
|
|
134
|
+
* Determine the optimal render mode
|
|
135
|
+
*/
|
|
136
|
+
private determineRenderMode;
|
|
137
|
+
/**
|
|
138
|
+
* Generate unique widget ID
|
|
139
|
+
*/
|
|
140
|
+
private generateWidgetId;
|
|
141
|
+
/**
|
|
142
|
+
* Emit widget events
|
|
143
|
+
*/
|
|
144
|
+
private emitWidgetEvent;
|
|
145
|
+
/**
|
|
146
|
+
* Create loading state element
|
|
147
|
+
*/
|
|
148
|
+
private createLoadingElement;
|
|
149
|
+
/**
|
|
150
|
+
* Remove loading state element
|
|
151
|
+
*/
|
|
152
|
+
private removeLoadingElement;
|
|
153
|
+
/**
|
|
154
|
+
* Create error state element with support CTA and specific messaging based on error type
|
|
155
|
+
*/
|
|
156
|
+
private createErrorElement;
|
|
157
|
+
/**
|
|
158
|
+
* Analyze error type and provide appropriate messaging and actions
|
|
159
|
+
*/
|
|
160
|
+
private analyzeError;
|
|
161
|
+
/**
|
|
162
|
+
* Add loading animation styles
|
|
163
|
+
*/
|
|
164
|
+
private addLoadingStyles;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get or create global widget renderer instance
|
|
168
|
+
*/
|
|
169
|
+
export declare function getWidgetRenderer(): WidgetRenderer;
|
|
170
|
+
/**
|
|
171
|
+
* Reset global widget renderer (useful for testing)
|
|
172
|
+
*/
|
|
173
|
+
export declare function resetWidgetRenderer(): void;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widgetic Embed SDK - Fast-Loading Bootstrap v1.0
|
|
3
|
+
*
|
|
4
|
+
* This is the minimal, fast-loading entry point for the Widgetic Embed SDK.
|
|
5
|
+
* It provides immediate widget detection and progressive loading of features.
|
|
6
|
+
*
|
|
7
|
+
* Size target: <5KB gzipped
|
|
8
|
+
* Load time target: <50ms
|
|
9
|
+
*/
|
|
10
|
+
interface BootstrapConfig {
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
preloadCritical?: boolean;
|
|
13
|
+
scanInterval?: number;
|
|
14
|
+
enableLazyLoading?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface WidgetElement extends Element {
|
|
17
|
+
'data-composition-id': string;
|
|
18
|
+
'data-widget-id': string;
|
|
19
|
+
'data-render-mode'?: string;
|
|
20
|
+
'data-priority'?: string;
|
|
21
|
+
}
|
|
22
|
+
interface BootstrapStats {
|
|
23
|
+
scanTime: number;
|
|
24
|
+
widgetsFound: number;
|
|
25
|
+
chunksLoaded: string[];
|
|
26
|
+
totalLoadTime: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Fast Widget Scanner - Minimal DOM scanning
|
|
30
|
+
*/
|
|
31
|
+
declare class FastWidgetScanner {
|
|
32
|
+
private foundWidgets;
|
|
33
|
+
private scanStartTime;
|
|
34
|
+
scan(): WidgetElement[];
|
|
35
|
+
private isValidWidget;
|
|
36
|
+
getScanTime(): number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Progressive Chunk Loader - Dynamic feature loading
|
|
40
|
+
*/
|
|
41
|
+
declare class ProgressiveChunkLoader {
|
|
42
|
+
private loadedChunks;
|
|
43
|
+
private loadingPromises;
|
|
44
|
+
private loadStartTime;
|
|
45
|
+
constructor();
|
|
46
|
+
loadCoreChunks(): Promise<void>;
|
|
47
|
+
loadRenderingChunks(): Promise<void>;
|
|
48
|
+
loadApiChunks(): Promise<void>;
|
|
49
|
+
loadFeatureChunk(feature: string): Promise<any>;
|
|
50
|
+
private loadChunk;
|
|
51
|
+
getLoadedChunks(): string[];
|
|
52
|
+
getTotalLoadTime(): number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Bootstrap Manager - Orchestrates the fast-loading strategy
|
|
56
|
+
*/
|
|
57
|
+
declare class BootstrapManager {
|
|
58
|
+
private scanner;
|
|
59
|
+
private loader;
|
|
60
|
+
private config;
|
|
61
|
+
private stats;
|
|
62
|
+
private initStartTime;
|
|
63
|
+
constructor(config?: BootstrapConfig);
|
|
64
|
+
initialize(): Promise<BootstrapStats>;
|
|
65
|
+
private analyzeWidgetRequirements;
|
|
66
|
+
/**
|
|
67
|
+
* Extract widget capabilities from metadata or embedded configuration
|
|
68
|
+
*/
|
|
69
|
+
private extractWidgetCapabilities;
|
|
70
|
+
private loadRequiredChunks;
|
|
71
|
+
private initializeFullSDK;
|
|
72
|
+
private finalizeStats;
|
|
73
|
+
getStats(): BootstrapStats;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Fast initialization function - the main entry point
|
|
77
|
+
*/
|
|
78
|
+
export declare function initializeWidgeticFast(config?: BootstrapConfig): Promise<BootstrapStats>;
|
|
79
|
+
/**
|
|
80
|
+
* Get bootstrap stats
|
|
81
|
+
*/
|
|
82
|
+
export declare function getBootstrapStats(): BootstrapStats | null;
|
|
83
|
+
export { BootstrapManager, FastWidgetScanner, ProgressiveChunkLoader };
|
|
84
|
+
export type { BootstrapConfig, BootstrapStats, WidgetElement };
|
|
@@ -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,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the <widgetic-translations experiment-id="xxx"></widgetic-translations> element
|
|
3
|
+
*
|
|
4
|
+
* This component automatically detects the user's browser language preferences
|
|
5
|
+
* and loads the appropriate translated composition for the experiment.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* <widgetic-translations experiment-id="12345"></widgetic-translations>
|
|
9
|
+
*/
|
|
10
|
+
declare const BaseHTMLElement: {
|
|
11
|
+
new (): HTMLElement;
|
|
12
|
+
prototype: HTMLElement;
|
|
13
|
+
};
|
|
14
|
+
export declare class TranslationElement extends BaseHTMLElement {
|
|
15
|
+
private widgetManager;
|
|
16
|
+
private widgetInstance;
|
|
17
|
+
private isInitialized;
|
|
18
|
+
private retryCount;
|
|
19
|
+
private maxRetries;
|
|
20
|
+
private retryDelay;
|
|
21
|
+
private experimentId;
|
|
22
|
+
private selectedLanguage;
|
|
23
|
+
private translationData;
|
|
24
|
+
constructor();
|
|
25
|
+
connectedCallback(): void;
|
|
26
|
+
disconnectedCallback(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize the translation experiment
|
|
29
|
+
*/
|
|
30
|
+
private initializeTranslation;
|
|
31
|
+
/**
|
|
32
|
+
* Detect browser language preferences
|
|
33
|
+
* Reuses logic from AuthHeroImage.svelte
|
|
34
|
+
*/
|
|
35
|
+
private detectBrowserLanguages;
|
|
36
|
+
/**
|
|
37
|
+
* Fetch translation experiment data from API
|
|
38
|
+
*/
|
|
39
|
+
private fetchTranslationExperiment;
|
|
40
|
+
/**
|
|
41
|
+
* Find the best matching language variant for the user
|
|
42
|
+
*/
|
|
43
|
+
private findBestLanguageMatch;
|
|
44
|
+
/**
|
|
45
|
+
* Get the composition ID for a specific language
|
|
46
|
+
*/
|
|
47
|
+
private getCompositionForLanguage;
|
|
48
|
+
/**
|
|
49
|
+
* Load the widget for the selected composition
|
|
50
|
+
*/
|
|
51
|
+
private loadWidget;
|
|
52
|
+
/**
|
|
53
|
+
* Track translation experiment view analytics
|
|
54
|
+
*/
|
|
55
|
+
private trackTranslationView;
|
|
56
|
+
/**
|
|
57
|
+
* Send analytics data to the backend
|
|
58
|
+
*/
|
|
59
|
+
private sendAnalytics;
|
|
60
|
+
/**
|
|
61
|
+
* Track fallback usage for analytics
|
|
62
|
+
*/
|
|
63
|
+
private trackFallbackUsage;
|
|
64
|
+
/**
|
|
65
|
+
* Handle initialization errors with retry logic
|
|
66
|
+
*/
|
|
67
|
+
private handleInitializationError;
|
|
68
|
+
/**
|
|
69
|
+
* Display error message to user
|
|
70
|
+
*/
|
|
71
|
+
private displayError;
|
|
72
|
+
/**
|
|
73
|
+
* Cleanup resources
|
|
74
|
+
*/
|
|
75
|
+
private cleanup;
|
|
76
|
+
/**
|
|
77
|
+
* Allow manual language switching (for future enhancement)
|
|
78
|
+
*/
|
|
79
|
+
switchLanguage(language: string): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Get current selected language
|
|
82
|
+
*/
|
|
83
|
+
getSelectedLanguage(): string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Get available languages for this experiment
|
|
86
|
+
*/
|
|
87
|
+
getAvailableLanguages(): string[];
|
|
88
|
+
/**
|
|
89
|
+
* Register the translation custom element
|
|
90
|
+
*/
|
|
91
|
+
static register(): void;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser Capability Detection
|
|
3
|
+
* Detect browser features and determine optimal render modes
|
|
4
|
+
*/
|
|
5
|
+
import type { BrowserCapabilities, RenderMode } from "../core/types";
|
|
6
|
+
/**
|
|
7
|
+
* Detect current browser capabilities
|
|
8
|
+
*/
|
|
9
|
+
export declare function detectBrowserCapabilities(): BrowserCapabilities;
|
|
10
|
+
/**
|
|
11
|
+
* Determine the best render mode based on browser capabilities and preferences
|
|
12
|
+
*/
|
|
13
|
+
export declare function determineBestRenderMode(preferredMode: RenderMode, capabilities: BrowserCapabilities): RenderMode;
|
|
14
|
+
/**
|
|
15
|
+
* Check if localStorage is available
|
|
16
|
+
*/
|
|
17
|
+
export declare function isLocalStorageAvailable(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Get or set SDK initialization flag to prevent duplicate execution
|
|
20
|
+
*/
|
|
21
|
+
export declare function checkSdkInitialization(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Clear SDK initialization flag (for testing or forced refresh)
|
|
24
|
+
*/
|
|
25
|
+
export declare function clearSdkInitialization(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Simple feature detection for intersection observer
|
|
28
|
+
*/
|
|
29
|
+
export declare function hasIntersectionObserver(): boolean;
|