@widgetic/embed-sdk 0.0.0-stage → 2.0.6
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,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 3: Custom Elements Mode Implementation
|
|
3
|
+
* Widgetic Widget Custom Element with enhanced capabilities
|
|
4
|
+
*/
|
|
5
|
+
declare const BaseHTMLElement: {
|
|
6
|
+
new (): HTMLElement;
|
|
7
|
+
prototype: HTMLElement;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Enhanced WidgeticWidget Custom Element
|
|
11
|
+
* Implements comprehensive lifecycle management, CSS isolation, and state management
|
|
12
|
+
*/
|
|
13
|
+
export declare class WidgeticWidget extends BaseHTMLElement {
|
|
14
|
+
static get observedAttributes(): string[];
|
|
15
|
+
private svelteComponent;
|
|
16
|
+
private compositionData;
|
|
17
|
+
private widgetData;
|
|
18
|
+
private loadedModule;
|
|
19
|
+
private isInitialized;
|
|
20
|
+
private isWidgetConnected;
|
|
21
|
+
private instanceId;
|
|
22
|
+
private resizeObserver;
|
|
23
|
+
private cssNamespace;
|
|
24
|
+
private eventListeners;
|
|
25
|
+
private widgetState;
|
|
26
|
+
constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Called when element is connected to DOM
|
|
29
|
+
*/
|
|
30
|
+
connectedCallback(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Called when element is disconnected from DOM
|
|
33
|
+
*/
|
|
34
|
+
disconnectedCallback(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Called when observed attributes change
|
|
37
|
+
*/
|
|
38
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
39
|
+
/**
|
|
40
|
+
* Initialize CSS isolation without Shadow DOM
|
|
41
|
+
*/
|
|
42
|
+
private initializeCSSIsolation;
|
|
43
|
+
/**
|
|
44
|
+
* Add base styles for widget isolation
|
|
45
|
+
*/
|
|
46
|
+
private addBaseStyles;
|
|
47
|
+
/**
|
|
48
|
+
* Initialize CSS custom properties
|
|
49
|
+
*/
|
|
50
|
+
private initializeCSSCustomProperties;
|
|
51
|
+
/**
|
|
52
|
+
* Load composition and widget data
|
|
53
|
+
*/
|
|
54
|
+
private loadWidgetData;
|
|
55
|
+
/**
|
|
56
|
+
* Load widget module
|
|
57
|
+
*/
|
|
58
|
+
private loadWidgetModule;
|
|
59
|
+
/**
|
|
60
|
+
* Initialize widget component
|
|
61
|
+
*/
|
|
62
|
+
private initializeWidget;
|
|
63
|
+
/**
|
|
64
|
+
* Initialize React component
|
|
65
|
+
*/
|
|
66
|
+
private initializeReactComponent;
|
|
67
|
+
/**
|
|
68
|
+
* Initialize Vue component
|
|
69
|
+
*/
|
|
70
|
+
private initializeVueComponent;
|
|
71
|
+
/**
|
|
72
|
+
* Initialize Svelte or vanilla component
|
|
73
|
+
*/
|
|
74
|
+
private initializeSvelteOrVanillaComponent;
|
|
75
|
+
/**
|
|
76
|
+
* Get widget properties for component initialization
|
|
77
|
+
*/
|
|
78
|
+
private getWidgetProps;
|
|
79
|
+
/**
|
|
80
|
+
* Apply widget properties to container
|
|
81
|
+
*/
|
|
82
|
+
private applyWidgetProperties;
|
|
83
|
+
/**
|
|
84
|
+
* Set up responsive behavior
|
|
85
|
+
*/
|
|
86
|
+
private setupResponsiveBehavior;
|
|
87
|
+
/**
|
|
88
|
+
* Set up adaptive behavior for responsive design
|
|
89
|
+
*/
|
|
90
|
+
private setupAdaptiveBehavior;
|
|
91
|
+
/**
|
|
92
|
+
* Handle autoscaling
|
|
93
|
+
*/
|
|
94
|
+
private handleAutoscale;
|
|
95
|
+
/**
|
|
96
|
+
* Set up event handling
|
|
97
|
+
*/
|
|
98
|
+
private setupEventHandling;
|
|
99
|
+
/**
|
|
100
|
+
* Handle form submissions from widget
|
|
101
|
+
*/
|
|
102
|
+
private handleFormSubmission;
|
|
103
|
+
/**
|
|
104
|
+
* Handle state changes from widget
|
|
105
|
+
*/
|
|
106
|
+
private handleStateChange;
|
|
107
|
+
/**
|
|
108
|
+
* Handle resize events
|
|
109
|
+
*/
|
|
110
|
+
private handleResize;
|
|
111
|
+
/**
|
|
112
|
+
* Handle errors from widget
|
|
113
|
+
*/
|
|
114
|
+
private handleError;
|
|
115
|
+
/**
|
|
116
|
+
* Update methods for attribute changes
|
|
117
|
+
*/
|
|
118
|
+
private updateDimensions;
|
|
119
|
+
private updateResizeMode;
|
|
120
|
+
private updateAutoscale;
|
|
121
|
+
private updateAdaptive;
|
|
122
|
+
private updateTheme;
|
|
123
|
+
/**
|
|
124
|
+
* Notify widget component of property changes
|
|
125
|
+
*/
|
|
126
|
+
private notifyWidgetPropsChanged;
|
|
127
|
+
/**
|
|
128
|
+
* State management methods
|
|
129
|
+
*/
|
|
130
|
+
private setLoadingState;
|
|
131
|
+
private setWidgetReady;
|
|
132
|
+
private setErrorState;
|
|
133
|
+
/**
|
|
134
|
+
* Public API methods
|
|
135
|
+
*/
|
|
136
|
+
getState(): Record<string, any>;
|
|
137
|
+
setState(newState: Record<string, any>): void;
|
|
138
|
+
refresh(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Cleanup method
|
|
141
|
+
*/
|
|
142
|
+
private cleanup;
|
|
143
|
+
/**
|
|
144
|
+
* Generate unique instance ID
|
|
145
|
+
*/
|
|
146
|
+
private generateInstanceId;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Register the custom element
|
|
150
|
+
*/
|
|
151
|
+
export declare function registerWidgeticWidget(): void;
|
|
152
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display Manager
|
|
3
|
+
* Handles advanced widget display modes: fullscreen, overlay, popup, and modal
|
|
4
|
+
*/
|
|
5
|
+
import type { WidgetConfig, WidgetDisplayState } from "./types.js";
|
|
6
|
+
export interface DisplayManagerOptions {
|
|
7
|
+
enableFullscreen?: boolean;
|
|
8
|
+
enableOverlay?: boolean;
|
|
9
|
+
enablePopup?: boolean;
|
|
10
|
+
defaultOverlayZIndex?: number;
|
|
11
|
+
defaultPopupFeatures?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Display Manager for handling advanced widget display modes
|
|
15
|
+
*/
|
|
16
|
+
export declare class DisplayManager {
|
|
17
|
+
private options;
|
|
18
|
+
private instances;
|
|
19
|
+
private widgetElements;
|
|
20
|
+
private widgetConfigs;
|
|
21
|
+
private fullscreenListeners;
|
|
22
|
+
private keyboardListeners;
|
|
23
|
+
constructor(options?: DisplayManagerOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Initialize display state for a widget
|
|
26
|
+
*/
|
|
27
|
+
initializeWidget(widgetId: string, config: WidgetConfig, element: HTMLElement): WidgetDisplayState;
|
|
28
|
+
/**
|
|
29
|
+
* Setup display mode for a widget
|
|
30
|
+
*/
|
|
31
|
+
private setupDisplayMode;
|
|
32
|
+
/**
|
|
33
|
+
* Setup fullscreen mode for a widget
|
|
34
|
+
*/
|
|
35
|
+
private setupFullscreenMode;
|
|
36
|
+
/**
|
|
37
|
+
* Setup overlay mode for a widget
|
|
38
|
+
*/
|
|
39
|
+
private setupOverlayMode;
|
|
40
|
+
/**
|
|
41
|
+
* Setup popup mode for a widget
|
|
42
|
+
*/
|
|
43
|
+
private setupPopupMode;
|
|
44
|
+
/**
|
|
45
|
+
* Enter fullscreen mode
|
|
46
|
+
*/
|
|
47
|
+
enterFullscreen(widgetId: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Exit fullscreen mode
|
|
50
|
+
*/
|
|
51
|
+
exitFullscreen(widgetId: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Show widget in overlay mode
|
|
54
|
+
*/
|
|
55
|
+
showOverlay(widgetId: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Hide widget overlay
|
|
58
|
+
*/
|
|
59
|
+
hideOverlay(widgetId: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Open widget in popup window
|
|
62
|
+
*/
|
|
63
|
+
openPopup(widgetId: string): Promise<Window | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Close popup window
|
|
66
|
+
*/
|
|
67
|
+
closePopup(widgetId: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Get display state for a widget
|
|
70
|
+
*/
|
|
71
|
+
getDisplayState(widgetId: string): WidgetDisplayState | null;
|
|
72
|
+
/**
|
|
73
|
+
* Cleanup widget display state
|
|
74
|
+
*/
|
|
75
|
+
cleanup(widgetId: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Cleanup all display states
|
|
78
|
+
*/
|
|
79
|
+
cleanupAll(): void;
|
|
80
|
+
private getWidgetElement;
|
|
81
|
+
private getWidgetConfig;
|
|
82
|
+
private addFullscreenTrigger;
|
|
83
|
+
private addOverlayTrigger;
|
|
84
|
+
private addPopupTrigger;
|
|
85
|
+
private createExitButton;
|
|
86
|
+
private createOverlayContainer;
|
|
87
|
+
private styleOverlayWidget;
|
|
88
|
+
/**
|
|
89
|
+
* Apply overlay-specific resize mode to widget
|
|
90
|
+
*/
|
|
91
|
+
private applyOverlayResizeMode;
|
|
92
|
+
private buildPopupFeatures;
|
|
93
|
+
private generatePopupUrl;
|
|
94
|
+
private setupGlobalKeyHandlers;
|
|
95
|
+
private setupFullscreenKeyHandler;
|
|
96
|
+
private removeFullscreenKeyHandler;
|
|
97
|
+
private setupOverlayCloseHandlers;
|
|
98
|
+
private removeOverlayKeyHandler;
|
|
99
|
+
private monitorPopupClose;
|
|
100
|
+
private addFullscreenControls;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get global display manager instance
|
|
104
|
+
*/
|
|
105
|
+
export declare function getDisplayManager(options?: DisplayManagerOptions): DisplayManager;
|
|
106
|
+
/**
|
|
107
|
+
* Reset display manager (for testing)
|
|
108
|
+
*/
|
|
109
|
+
export declare function resetDisplayManager(): void;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor Overlay System
|
|
3
|
+
* Provides on-site editing interface for authenticated users
|
|
4
|
+
*/
|
|
5
|
+
import { type Portal } from "../utils/portal.js";
|
|
6
|
+
import { type WidgetController } from "./messaging.js";
|
|
7
|
+
export interface EditorOverlayOptions {
|
|
8
|
+
showEditButton?: boolean;
|
|
9
|
+
editButtonText?: string;
|
|
10
|
+
editButtonPosition?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
11
|
+
editButtonStyle?: Partial<CSSStyleDeclaration>;
|
|
12
|
+
overlayStyle?: Partial<CSSStyleDeclaration>;
|
|
13
|
+
enableClickToEdit?: boolean;
|
|
14
|
+
autoDetectAuth?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface EditorSession {
|
|
17
|
+
compositionId: string;
|
|
18
|
+
isOpen: boolean;
|
|
19
|
+
editorContainer?: HTMLElement;
|
|
20
|
+
editorInstance?: any;
|
|
21
|
+
widgetController?: WidgetController;
|
|
22
|
+
overlay?: HTMLElement;
|
|
23
|
+
portal?: Portal;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Editor Overlay Manager
|
|
27
|
+
*/
|
|
28
|
+
export declare class EditorOverlay {
|
|
29
|
+
private options;
|
|
30
|
+
private sessions;
|
|
31
|
+
private defaultOptions;
|
|
32
|
+
constructor(options?: EditorOverlayOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Add editor overlay to a widget element
|
|
35
|
+
*/
|
|
36
|
+
addOverlay(widgetElement: HTMLElement, compositionId: string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Create the actual overlay UI
|
|
39
|
+
*/
|
|
40
|
+
private createOverlay;
|
|
41
|
+
/**
|
|
42
|
+
* Create edit button
|
|
43
|
+
*/
|
|
44
|
+
private createEditButton;
|
|
45
|
+
/**
|
|
46
|
+
* Get button position styles based on configuration
|
|
47
|
+
*/
|
|
48
|
+
private getButtonPositionStyles;
|
|
49
|
+
/**
|
|
50
|
+
* Get custom button styles from options
|
|
51
|
+
*/
|
|
52
|
+
private getCustomButtonStyles;
|
|
53
|
+
/**
|
|
54
|
+
* Get overlay styles from options
|
|
55
|
+
*/
|
|
56
|
+
private getOverlayStyles;
|
|
57
|
+
/**
|
|
58
|
+
* Convert camelCase to kebab-case
|
|
59
|
+
*/
|
|
60
|
+
private camelToKebab;
|
|
61
|
+
/**
|
|
62
|
+
* Add click-to-edit functionality
|
|
63
|
+
*/
|
|
64
|
+
private addClickToEdit;
|
|
65
|
+
/**
|
|
66
|
+
* Create editor container (modal/overlay) using Portal
|
|
67
|
+
*/
|
|
68
|
+
private createEditorContainer;
|
|
69
|
+
/**
|
|
70
|
+
* Open editor for composition
|
|
71
|
+
*/
|
|
72
|
+
openEditor(compositionId: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Handle editor save
|
|
75
|
+
*/
|
|
76
|
+
private handleEditorSave;
|
|
77
|
+
/**
|
|
78
|
+
* Handle editor preview
|
|
79
|
+
*/
|
|
80
|
+
private handleEditorPreview;
|
|
81
|
+
/**
|
|
82
|
+
* Close editor
|
|
83
|
+
*/
|
|
84
|
+
closeEditor(compositionId: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Show error message to user
|
|
87
|
+
*/
|
|
88
|
+
private showError;
|
|
89
|
+
/**
|
|
90
|
+
* Remove overlay for a composition
|
|
91
|
+
*/
|
|
92
|
+
removeOverlay(compositionId: string): void;
|
|
93
|
+
/**
|
|
94
|
+
* Check if editor is open for composition
|
|
95
|
+
*/
|
|
96
|
+
isEditorOpen(compositionId: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Get all active sessions
|
|
99
|
+
*/
|
|
100
|
+
getActiveSessions(): string[];
|
|
101
|
+
/**
|
|
102
|
+
* Cleanup all overlays
|
|
103
|
+
*/
|
|
104
|
+
cleanup(): void;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get global editor overlay instance
|
|
108
|
+
*/
|
|
109
|
+
export declare function getEditorOverlay(options?: EditorOverlayOptions): EditorOverlay;
|
|
110
|
+
/**
|
|
111
|
+
* Reset editor overlay (for testing)
|
|
112
|
+
*/
|
|
113
|
+
export declare function resetEditorOverlay(): void;
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Embed SDK Entry Point
|
|
3
|
+
* Phase 1: Foundation & Core Architecture (v1.0)
|
|
4
|
+
*
|
|
5
|
+
* This is the main SDK class that handles:
|
|
6
|
+
* - Auto-initialization on page load
|
|
7
|
+
* - Page scanning for <widgetic> elements (customer-facing embed tag)
|
|
8
|
+
* - Widget rendering with Phase 2 enhanced capabilities
|
|
9
|
+
* - Instance management and coordination
|
|
10
|
+
* - Authentication detection and on-site editing
|
|
11
|
+
*/
|
|
12
|
+
import { type WidgetController } from "./messaging.js";
|
|
13
|
+
import { type AuthenticationStatus } from "./auth-detector.js";
|
|
14
|
+
import { type EditorOverlayOptions } from "./editor-overlay.js";
|
|
15
|
+
import { type DisplayManagerOptions } from "./display-manager.js";
|
|
16
|
+
import { type ResizeHandlerOptions } from "./resize-handler.js";
|
|
17
|
+
import { type OverlayConfig } from "./overlay-manager.js";
|
|
18
|
+
import type { WidgetInstance, WidgeticEmbedSDK } from "./types.js";
|
|
19
|
+
import type { PerformanceConfig } from './performance-monitor.js';
|
|
20
|
+
import type { LazyLoadConfig } from './lazy-loader.js';
|
|
21
|
+
import type { ResourceConfig } from './resource-optimizer.js';
|
|
22
|
+
export interface EmbedSDKConfig {
|
|
23
|
+
debug?: boolean;
|
|
24
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
25
|
+
messagingOptions?: {
|
|
26
|
+
enableSignatureValidation?: boolean;
|
|
27
|
+
allowedOrigins?: string[];
|
|
28
|
+
messageTimeout?: number;
|
|
29
|
+
enableHeartbeat?: boolean;
|
|
30
|
+
heartbeatInterval?: number;
|
|
31
|
+
};
|
|
32
|
+
enableEditing?: boolean;
|
|
33
|
+
editorOptions?: EditorOverlayOptions;
|
|
34
|
+
preloadUISDK?: boolean;
|
|
35
|
+
displayOptions?: DisplayManagerOptions;
|
|
36
|
+
resizeOptions?: ResizeHandlerOptions;
|
|
37
|
+
performance?: {
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
config: Partial<PerformanceConfig>;
|
|
40
|
+
};
|
|
41
|
+
lazyLoading?: {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
config: Partial<LazyLoadConfig>;
|
|
44
|
+
};
|
|
45
|
+
resourceOptimization?: {
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
config: Partial<ResourceConfig>;
|
|
48
|
+
};
|
|
49
|
+
renderMode?: 'auto' | 'iframe' | 'custom-element';
|
|
50
|
+
overlayConfig?: {
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
defaultMode?: string;
|
|
53
|
+
exitIntentEnabled?: boolean;
|
|
54
|
+
scrollTriggerEnabled?: boolean;
|
|
55
|
+
timeTriggerEnabled?: boolean;
|
|
56
|
+
engagementThresholdEnabled?: boolean;
|
|
57
|
+
externalTriggerEnabled?: boolean;
|
|
58
|
+
breakpoints?: {
|
|
59
|
+
useBreakpoints?: boolean;
|
|
60
|
+
mobile?: number;
|
|
61
|
+
tablet?: number;
|
|
62
|
+
desktop?: number;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export interface EmbedSDKStats {
|
|
67
|
+
version: string;
|
|
68
|
+
widgetsRendered: number;
|
|
69
|
+
renderMode: "auto" | "custom-element" | "iframe";
|
|
70
|
+
cacheStats: any;
|
|
71
|
+
messagingActive: boolean;
|
|
72
|
+
customEventSubscriptions: number;
|
|
73
|
+
functionHandlers: number;
|
|
74
|
+
authenticationStatus?: AuthenticationStatus;
|
|
75
|
+
editingSessions: number;
|
|
76
|
+
}
|
|
77
|
+
export interface ScanResult {
|
|
78
|
+
success: boolean;
|
|
79
|
+
widgets: Array<{
|
|
80
|
+
id: string;
|
|
81
|
+
dataId: string;
|
|
82
|
+
element: HTMLElement;
|
|
83
|
+
}>;
|
|
84
|
+
errors?: string[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Widgetic Embed SDK v1.0
|
|
88
|
+
* Enhanced with Phase 2 batch API, module loading, and on-site editing capabilities
|
|
89
|
+
*/
|
|
90
|
+
export declare class EmbedSDK implements WidgeticEmbedSDK {
|
|
91
|
+
readonly version: string;
|
|
92
|
+
private instances;
|
|
93
|
+
private isInitialized;
|
|
94
|
+
private browserCapabilities;
|
|
95
|
+
private renderer;
|
|
96
|
+
private messenger;
|
|
97
|
+
private widgetControllers;
|
|
98
|
+
private authDetector;
|
|
99
|
+
private editorOverlay;
|
|
100
|
+
private displayManager;
|
|
101
|
+
private resizeHandler;
|
|
102
|
+
private authenticationStatus;
|
|
103
|
+
private config;
|
|
104
|
+
private overlayManager;
|
|
105
|
+
constructor(config?: EmbedSDKConfig);
|
|
106
|
+
/**
|
|
107
|
+
* Initialize the SDK and scan for widgets
|
|
108
|
+
*/
|
|
109
|
+
init(): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Check user authentication status
|
|
112
|
+
*/
|
|
113
|
+
private checkAuthentication;
|
|
114
|
+
/**
|
|
115
|
+
* Scan page for widgets and enhance them (alias for scanPage for interface compatibility)
|
|
116
|
+
*/
|
|
117
|
+
enhance(): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Refresh - rescan and enhance new widgets
|
|
120
|
+
*/
|
|
121
|
+
refresh(): Promise<void>;
|
|
122
|
+
private hostObserverStarted;
|
|
123
|
+
private watchPublishedHosts;
|
|
124
|
+
/**
|
|
125
|
+
* Scan the page for <widgetic> host tags and render them.
|
|
126
|
+
* The public embed tag is `<widgetic>` (unknown HTML element). Autonomous
|
|
127
|
+
* custom elements must contain a hyphen, so the SDK hydrates `<widgetic>`
|
|
128
|
+
* in place rather than customElements.define("widgetic").
|
|
129
|
+
*/
|
|
130
|
+
scanPage(): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Render multiple widgets using Phase 2 batch capabilities
|
|
133
|
+
*/
|
|
134
|
+
private renderWidgetsBatch;
|
|
135
|
+
/**
|
|
136
|
+
* Render a single widget (fallback method)
|
|
137
|
+
*/
|
|
138
|
+
private renderSingleWidget;
|
|
139
|
+
private performActualWidgetRender;
|
|
140
|
+
private shouldUseLazyLoading;
|
|
141
|
+
private getWidgetPriority;
|
|
142
|
+
private getWidgetResourceUrls;
|
|
143
|
+
/**
|
|
144
|
+
* Maybe add editor overlay if conditions are met
|
|
145
|
+
*/
|
|
146
|
+
private maybeAddEditorOverlay;
|
|
147
|
+
/**
|
|
148
|
+
* Get all widget instances
|
|
149
|
+
*/
|
|
150
|
+
getInstances(): WidgetInstance[];
|
|
151
|
+
/**
|
|
152
|
+
* Get widget instance by ID
|
|
153
|
+
*/
|
|
154
|
+
getInstance(id: string): WidgetInstance | null;
|
|
155
|
+
/**
|
|
156
|
+
* Get widget instances by composition ID
|
|
157
|
+
*/
|
|
158
|
+
getInstancesByComposition(compositionId: string): WidgetInstance[];
|
|
159
|
+
/**
|
|
160
|
+
* Get SDK statistics
|
|
161
|
+
*/
|
|
162
|
+
getStats(): EmbedSDKStats;
|
|
163
|
+
/**
|
|
164
|
+
* Create a widget controller for external widget manipulation
|
|
165
|
+
*/
|
|
166
|
+
createWidgetController(compositionId: string): WidgetController | null;
|
|
167
|
+
/**
|
|
168
|
+
* Get existing widget controller
|
|
169
|
+
*/
|
|
170
|
+
getWidgetController(compositionId: string): WidgetController | null;
|
|
171
|
+
/**
|
|
172
|
+
* Subscribe to widget events (convenience method)
|
|
173
|
+
*/
|
|
174
|
+
subscribeToWidget(compositionId: string, eventName: string, callback: (data: any, metadata?: any) => void): () => void;
|
|
175
|
+
/**
|
|
176
|
+
* Call a function in a widget (convenience method)
|
|
177
|
+
*/
|
|
178
|
+
callWidgetFunction(compositionId: string, functionName: string, ...args: any[]): Promise<any>;
|
|
179
|
+
/**
|
|
180
|
+
* Update widget configuration (convenience method)
|
|
181
|
+
*/
|
|
182
|
+
updateWidgetConfig(compositionId: string, config: Record<string, any>): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Get widget state (convenience method)
|
|
185
|
+
*/
|
|
186
|
+
getWidgetState(compositionId: string, key?: string): Promise<any>;
|
|
187
|
+
/**
|
|
188
|
+
* Set widget state (convenience method)
|
|
189
|
+
*/
|
|
190
|
+
setWidgetState(compositionId: string, key: string, value: any): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* Emit custom event to widget (convenience method)
|
|
193
|
+
*/
|
|
194
|
+
emitToWidget(compositionId: string, eventName: string, data: any, metadata?: any): void;
|
|
195
|
+
/**
|
|
196
|
+
* Check if user can edit a specific composition
|
|
197
|
+
*/
|
|
198
|
+
canEditComposition(compositionId: string): Promise<boolean>;
|
|
199
|
+
/**
|
|
200
|
+
* Get current authentication status
|
|
201
|
+
*/
|
|
202
|
+
getAuthenticationStatus(): AuthenticationStatus | null;
|
|
203
|
+
/**
|
|
204
|
+
* Refresh authentication status
|
|
205
|
+
*/
|
|
206
|
+
refreshAuthentication(): Promise<AuthenticationStatus>;
|
|
207
|
+
/**
|
|
208
|
+
* Open editor for a specific composition (if user has permission)
|
|
209
|
+
*/
|
|
210
|
+
openEditor(compositionId: string): Promise<void>;
|
|
211
|
+
/**
|
|
212
|
+
* Check if editor is open for a composition
|
|
213
|
+
*/
|
|
214
|
+
isEditorOpen(compositionId: string): boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Close editor for a composition
|
|
217
|
+
*/
|
|
218
|
+
closeEditor(compositionId: string): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Enable/disable editing for all widgets
|
|
221
|
+
*/
|
|
222
|
+
setEditingEnabled(enabled: boolean): void;
|
|
223
|
+
/**
|
|
224
|
+
* ========================================
|
|
225
|
+
* DYNAMIC CONTENT API
|
|
226
|
+
* ========================================
|
|
227
|
+
*/
|
|
228
|
+
/**
|
|
229
|
+
* Set dynamic content for a widget composition
|
|
230
|
+
* @param compositionId - ID of the composition to update
|
|
231
|
+
* @param content - New content data
|
|
232
|
+
* @param options - Update options
|
|
233
|
+
*/
|
|
234
|
+
setContent(compositionId: string, content: any, options?: {
|
|
235
|
+
validate?: boolean;
|
|
236
|
+
partial?: boolean;
|
|
237
|
+
source?: string;
|
|
238
|
+
version?: string;
|
|
239
|
+
}): Promise<{
|
|
240
|
+
success: boolean;
|
|
241
|
+
error?: string;
|
|
242
|
+
validationResult?: any;
|
|
243
|
+
}>;
|
|
244
|
+
/**
|
|
245
|
+
* Get content schema for a widget composition
|
|
246
|
+
* @param compositionId - ID of the composition
|
|
247
|
+
*/
|
|
248
|
+
getContentSchema(compositionId: string): Promise<any>;
|
|
249
|
+
/**
|
|
250
|
+
* Get design schema for a widget composition
|
|
251
|
+
* @param compositionId - ID of the composition
|
|
252
|
+
*/
|
|
253
|
+
getDesignSchema(compositionId: string): Promise<any>;
|
|
254
|
+
/**
|
|
255
|
+
* Validate content against widget schema
|
|
256
|
+
* @param compositionId - ID of the composition
|
|
257
|
+
* @param content - Content to validate
|
|
258
|
+
*/
|
|
259
|
+
validateContent(compositionId: string, content: any): Promise<{
|
|
260
|
+
valid: boolean;
|
|
261
|
+
errors?: any[];
|
|
262
|
+
warnings?: any[];
|
|
263
|
+
sanitizedContent?: any;
|
|
264
|
+
}>;
|
|
265
|
+
/**
|
|
266
|
+
* Get current content for a composition
|
|
267
|
+
* @param compositionId - ID of the composition
|
|
268
|
+
*/
|
|
269
|
+
getContent(compositionId: string): any;
|
|
270
|
+
/**
|
|
271
|
+
* Listen for content updates on a composition
|
|
272
|
+
* @param compositionId - ID of the composition
|
|
273
|
+
* @param callback - Callback to execute when content updates
|
|
274
|
+
* @returns Unsubscribe function
|
|
275
|
+
*/
|
|
276
|
+
onContentUpdate(compositionId: string, callback: (content: any, metadata?: any) => void): () => void;
|
|
277
|
+
scan(): Promise<ScanResult>;
|
|
278
|
+
private loadWidgets;
|
|
279
|
+
private loadWidget;
|
|
280
|
+
private determineRenderMode;
|
|
281
|
+
private renderIframe;
|
|
282
|
+
private renderCustomElement;
|
|
283
|
+
getConfig(): EmbedSDKConfig;
|
|
284
|
+
/**
|
|
285
|
+
* ========================================
|
|
286
|
+
* OVERLAY API
|
|
287
|
+
* ========================================
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* Show overlay with specified configuration
|
|
291
|
+
*/
|
|
292
|
+
showOverlay(config: OverlayConfig): void;
|
|
293
|
+
/**
|
|
294
|
+
* Hide the active overlay
|
|
295
|
+
*/
|
|
296
|
+
hideOverlay(): void;
|
|
297
|
+
/**
|
|
298
|
+
* Trigger overlay manually with specified mode
|
|
299
|
+
*/
|
|
300
|
+
triggerOverlay(mode: string, config?: Partial<OverlayConfig>): void;
|
|
301
|
+
/**
|
|
302
|
+
* Check if overlay is currently active
|
|
303
|
+
*/
|
|
304
|
+
isOverlayActive(): boolean;
|
|
305
|
+
destroy?(): void;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Get or create global SDK instance
|
|
309
|
+
*/
|
|
310
|
+
export declare function getSDK(config?: EmbedSDKConfig): EmbedSDK;
|