@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,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutoScale Manager - Automatic height adjustment based on content
|
|
3
|
+
* Monitors widget content height and adjusts container to fit perfectly
|
|
4
|
+
*/
|
|
5
|
+
export interface AutoScaleState {
|
|
6
|
+
/** Widget composition ID */
|
|
7
|
+
compositionId: string;
|
|
8
|
+
/** Stored height from previous session */
|
|
9
|
+
height: number;
|
|
10
|
+
/** Timestamp when height was last updated */
|
|
11
|
+
lastUpdated: number;
|
|
12
|
+
/** Original configured height */
|
|
13
|
+
originalHeight: number;
|
|
14
|
+
}
|
|
15
|
+
export interface AutoScaleConfig {
|
|
16
|
+
/** Enable autoscale functionality */
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
/** Minimum height in pixels */
|
|
19
|
+
minHeight?: number;
|
|
20
|
+
/** Maximum height in pixels */
|
|
21
|
+
maxHeight?: number;
|
|
22
|
+
/** Debounce delay for height changes in milliseconds */
|
|
23
|
+
debounceDelay?: number;
|
|
24
|
+
/** Threshold for height change detection in pixels */
|
|
25
|
+
threshold?: number;
|
|
26
|
+
/** Whether to animate height changes */
|
|
27
|
+
animate?: boolean;
|
|
28
|
+
/** Animation duration in milliseconds */
|
|
29
|
+
animationDuration?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare class AutoScaleManager {
|
|
32
|
+
private static instance;
|
|
33
|
+
private observers;
|
|
34
|
+
private mutationObservers;
|
|
35
|
+
private timeouts;
|
|
36
|
+
private animationIds;
|
|
37
|
+
private readonly storageKey;
|
|
38
|
+
static getInstance(): AutoScaleManager;
|
|
39
|
+
/**
|
|
40
|
+
* Enable autoscale for a widget container
|
|
41
|
+
*/
|
|
42
|
+
enableAutoScale(element: HTMLElement, compositionId: string, config?: AutoScaleConfig): void;
|
|
43
|
+
/**
|
|
44
|
+
* Disable autoscale for a widget
|
|
45
|
+
*/
|
|
46
|
+
disableAutoScale(compositionId: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Get stored height from localStorage
|
|
49
|
+
*/
|
|
50
|
+
private getStoredHeight;
|
|
51
|
+
/**
|
|
52
|
+
* Store height in localStorage
|
|
53
|
+
*/
|
|
54
|
+
private storeHeight;
|
|
55
|
+
/**
|
|
56
|
+
* Set up content monitoring for height changes
|
|
57
|
+
*/
|
|
58
|
+
private setupContentMonitoring;
|
|
59
|
+
/**
|
|
60
|
+
* Find the content element to monitor (iframe content or custom element)
|
|
61
|
+
*/
|
|
62
|
+
private findContentElement;
|
|
63
|
+
/**
|
|
64
|
+
* Set up PostMessage listener for iframe AutoScale communication
|
|
65
|
+
*/
|
|
66
|
+
private setupIframePostMessageListener;
|
|
67
|
+
/**
|
|
68
|
+
* Get configuration for a specific widget (simplified version)
|
|
69
|
+
*/
|
|
70
|
+
private getConfigForWidget;
|
|
71
|
+
/**
|
|
72
|
+
* Create debounced height update function
|
|
73
|
+
*/
|
|
74
|
+
private createDebouncedHeightUpdate;
|
|
75
|
+
/**
|
|
76
|
+
* Set element height with optional animation
|
|
77
|
+
*/
|
|
78
|
+
private setElementHeight;
|
|
79
|
+
/**
|
|
80
|
+
* Clear all stored heights (utility method)
|
|
81
|
+
*/
|
|
82
|
+
clearStoredHeights(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Get all stored heights (utility method)
|
|
85
|
+
*/
|
|
86
|
+
getStoredHeights(): Record<string, AutoScaleState>;
|
|
87
|
+
/**
|
|
88
|
+
* Clean up all observers and timeouts
|
|
89
|
+
*/
|
|
90
|
+
destroy(): void;
|
|
91
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Responsive Breakpoints Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines standard breakpoints for widget responsiveness and provides utilities
|
|
5
|
+
* for detecting device types and determining which layout to use.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RESPONSIVE_BREAKPOINTS: {
|
|
8
|
+
readonly MOBILE: 480;
|
|
9
|
+
readonly TABLET: 768;
|
|
10
|
+
readonly DESKTOP: 1024;
|
|
11
|
+
};
|
|
12
|
+
export declare const DEFAULT_BREAKPOINTS: {
|
|
13
|
+
mobile: 480;
|
|
14
|
+
tablet: 768;
|
|
15
|
+
desktop: 1024;
|
|
16
|
+
};
|
|
17
|
+
export interface BreakpointConfig {
|
|
18
|
+
useBreakpoints: boolean;
|
|
19
|
+
mobile?: number;
|
|
20
|
+
tablet?: number;
|
|
21
|
+
desktop?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface DeviceLayoutInfo {
|
|
24
|
+
deviceType: 'mobile' | 'tablet' | 'desktop';
|
|
25
|
+
currentBreakpoint: number;
|
|
26
|
+
nextBreakpoint?: number;
|
|
27
|
+
shouldUseAdaptedLayout: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Determine device type and layout info based on current width and breakpoint config
|
|
31
|
+
*/
|
|
32
|
+
export declare function getDeviceLayoutInfo(currentWidth: number, config: BreakpointConfig): DeviceLayoutInfo;
|
|
33
|
+
/**
|
|
34
|
+
* Parse breakpoint configuration from widget attributes
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseBreakpointConfig(element: HTMLElement): BreakpointConfig;
|
|
37
|
+
/**
|
|
38
|
+
* Generate CSS media queries for breakpoints
|
|
39
|
+
*/
|
|
40
|
+
export declare function generateBreakpointCSS(config: BreakpointConfig): string;
|
|
41
|
+
/**
|
|
42
|
+
* Check if viewport size has crossed a breakpoint threshold
|
|
43
|
+
*/
|
|
44
|
+
export declare function hasBreakpointChanged(oldWidth: number, newWidth: number, config: BreakpointConfig): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Get all active breakpoints for a configuration
|
|
47
|
+
*/
|
|
48
|
+
export declare function getActiveBreakpoints(config: BreakpointConfig): number[];
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Configuration Management
|
|
3
|
+
*
|
|
4
|
+
* Centralizes all SDK configuration including:
|
|
5
|
+
* - Environment variables (API keys only)
|
|
6
|
+
* - Configuration from constants
|
|
7
|
+
* - SDK settings
|
|
8
|
+
* - Configuration validation
|
|
9
|
+
* - Helper functions
|
|
10
|
+
*/
|
|
11
|
+
import type { TokenProvider } from './token-provider.js';
|
|
12
|
+
import { AuthManager } from './auth-manager.js';
|
|
13
|
+
export declare const VERSION: string;
|
|
14
|
+
export interface SDKConfig {
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
basePath?: string;
|
|
17
|
+
tokenProvider?: TokenProvider;
|
|
18
|
+
}
|
|
19
|
+
export declare const config: {
|
|
20
|
+
readonly API_URL: string;
|
|
21
|
+
readonly API_VERSION: string;
|
|
22
|
+
readonly CLIENT_URL: string;
|
|
23
|
+
readonly PRODUCTION_URL: string;
|
|
24
|
+
readonly NODE_ENV: "development" | "production";
|
|
25
|
+
readonly ENABLE_EDITING: boolean;
|
|
26
|
+
readonly API_KEY: string;
|
|
27
|
+
readonly AXIOM_API_KEY: string;
|
|
28
|
+
readonly STATSIG_KEY: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Sets the global token provider for the SDK
|
|
32
|
+
* This should be called before initializing the SDK
|
|
33
|
+
*/
|
|
34
|
+
export declare function setTokenProvider(provider: TokenProvider): void;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the current global token provider
|
|
37
|
+
*/
|
|
38
|
+
export declare function getTokenProvider(): TokenProvider | null;
|
|
39
|
+
/**
|
|
40
|
+
* Initialize and get the global auth manager
|
|
41
|
+
*/
|
|
42
|
+
export declare function getAuthManager(): AuthManager;
|
|
43
|
+
/**
|
|
44
|
+
* Set API key for authentication (will use short-lived tokens)
|
|
45
|
+
*/
|
|
46
|
+
export declare function setApiKey(apiKey: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Gets a token for API requests
|
|
49
|
+
* Uses auth manager for short-lived tokens, falls back to token provider, then API keys
|
|
50
|
+
*/
|
|
51
|
+
export declare function getAuthToken(): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates SDK configuration for API clients
|
|
54
|
+
* Used by core and modules
|
|
55
|
+
* Priority: passed tokenProvider > global tokenProvider > passed apiKey > env API_KEY
|
|
56
|
+
*/
|
|
57
|
+
export declare function createSdkConfig(options?: {
|
|
58
|
+
apiKey?: string;
|
|
59
|
+
basePath?: string;
|
|
60
|
+
tokenProvider?: TokenProvider;
|
|
61
|
+
}): SDKConfig;
|
|
62
|
+
/**
|
|
63
|
+
* Gets the full API URL for the current environment
|
|
64
|
+
*/
|
|
65
|
+
export declare function getApiUrl(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the CDN URL for module loading
|
|
68
|
+
*/
|
|
69
|
+
export declare function getCdnUrl(): string;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the full API URL with version for the current environment
|
|
72
|
+
*/
|
|
73
|
+
export declare function getVersionedApiUrl(): string;
|
|
74
|
+
/**
|
|
75
|
+
* Environment-specific settings
|
|
76
|
+
*/
|
|
77
|
+
export declare const environment: {
|
|
78
|
+
readonly isProduction: boolean;
|
|
79
|
+
readonly apiUrl: string;
|
|
80
|
+
readonly apiKey: string;
|
|
81
|
+
};
|
|
82
|
+
export declare const DEFAULT_WIDGET_CONFIG: {
|
|
83
|
+
readonly renderMode: "auto";
|
|
84
|
+
readonly displayMode: "inline";
|
|
85
|
+
readonly resize: "fixed";
|
|
86
|
+
readonly width: number;
|
|
87
|
+
readonly height: number;
|
|
88
|
+
readonly autoscale: boolean;
|
|
89
|
+
};
|
|
90
|
+
export declare const BROWSER_FEATURES: {
|
|
91
|
+
readonly customElements: boolean;
|
|
92
|
+
readonly http3: boolean;
|
|
93
|
+
readonly resizeObserver: boolean;
|
|
94
|
+
};
|
|
95
|
+
export declare const PERFORMANCE: {
|
|
96
|
+
readonly batchSize: number;
|
|
97
|
+
readonly loadTimeout: number;
|
|
98
|
+
readonly retryAttempts: number;
|
|
99
|
+
};
|
|
100
|
+
export declare const DEBUG: {
|
|
101
|
+
readonly enabled: boolean;
|
|
102
|
+
readonly logLevel: "info";
|
|
103
|
+
};
|
|
104
|
+
export declare const PERFORMANCE_CONFIG: {
|
|
105
|
+
AXIOM_API_KEY: string;
|
|
106
|
+
AXIOM_DATASET: string;
|
|
107
|
+
AXIOM_API_ENDPOINT: string;
|
|
108
|
+
STATSIG_API_KEY: string;
|
|
109
|
+
STATSIG_API_ENDPOINT: string;
|
|
110
|
+
ENABLE_PERFORMANCE_TRACKING: boolean;
|
|
111
|
+
PERFORMANCE_SAMPLE_RATE: number;
|
|
112
|
+
PERFORMANCE_REPORTING_ENDPOINT: string;
|
|
113
|
+
LCP_THRESHOLD: number;
|
|
114
|
+
LCP_WARNING_THRESHOLD: number;
|
|
115
|
+
FID_THRESHOLD: number;
|
|
116
|
+
FID_WARNING_THRESHOLD: number;
|
|
117
|
+
CLS_THRESHOLD: number;
|
|
118
|
+
CLS_WARNING_THRESHOLD: number;
|
|
119
|
+
FCP_THRESHOLD: number;
|
|
120
|
+
FCP_WARNING_THRESHOLD: number;
|
|
121
|
+
TTFB_THRESHOLD: number;
|
|
122
|
+
TTFB_WARNING_THRESHOLD: number;
|
|
123
|
+
WIDGET_LOAD_THRESHOLD: number;
|
|
124
|
+
WIDGET_LOAD_WARNING_THRESHOLD: number;
|
|
125
|
+
BUNDLE_SIZE_THRESHOLD: number;
|
|
126
|
+
BUNDLE_SIZE_WARNING_THRESHOLD: number;
|
|
127
|
+
MAX_METRICS_BUFFER: number;
|
|
128
|
+
};
|
|
129
|
+
export declare const LAZY_LOADING_CONFIG: {
|
|
130
|
+
ROOT_MARGIN: string;
|
|
131
|
+
THRESHOLD: number;
|
|
132
|
+
MAX_CONCURRENT: number;
|
|
133
|
+
RETRY_ATTEMPTS: number;
|
|
134
|
+
RETRY_DELAY: number;
|
|
135
|
+
};
|
|
136
|
+
export declare const RESOURCE_CONFIG: {
|
|
137
|
+
MAX_PRELOAD_REQUESTS: number;
|
|
138
|
+
PREFETCH_TIMEOUT: number;
|
|
139
|
+
CACHE_DURATION: number;
|
|
140
|
+
MAX_CONCURRENT_REQUESTS: number;
|
|
141
|
+
DNS_PREFETCH_ENABLED: boolean;
|
|
142
|
+
PRECONNECT_ENABLED: boolean;
|
|
143
|
+
};
|
|
144
|
+
export declare const SDK_CONFIG: {
|
|
145
|
+
DEBUG: boolean;
|
|
146
|
+
LOG_LEVEL: "info";
|
|
147
|
+
VERSION: string;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Get SDK configuration as a simple object
|
|
151
|
+
*/
|
|
152
|
+
export declare function getConfiguration(): SDKConfig;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export declare const ANALYTICS_DEFAULTS: {
|
|
2
|
+
AXIOM_API_ENDPOINT: string;
|
|
3
|
+
AXIOM_DATASET: string;
|
|
4
|
+
STATSIG_API_ENDPOINT: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const PERFORMANCE_DEFAULTS: {
|
|
7
|
+
ENABLE_TRACKING: boolean;
|
|
8
|
+
SAMPLE_RATE: number;
|
|
9
|
+
MAX_METRICS_BUFFER: number;
|
|
10
|
+
REPORTING_ENDPOINT: string;
|
|
11
|
+
LCP_THRESHOLD: number;
|
|
12
|
+
LCP_WARNING_THRESHOLD: number;
|
|
13
|
+
FID_THRESHOLD: number;
|
|
14
|
+
FID_WARNING_THRESHOLD: number;
|
|
15
|
+
CLS_THRESHOLD: number;
|
|
16
|
+
CLS_WARNING_THRESHOLD: number;
|
|
17
|
+
FCP_THRESHOLD: number;
|
|
18
|
+
FCP_WARNING_THRESHOLD: number;
|
|
19
|
+
TTFB_THRESHOLD: number;
|
|
20
|
+
TTFB_WARNING_THRESHOLD: number;
|
|
21
|
+
WIDGET_LOAD_THRESHOLD: number;
|
|
22
|
+
WIDGET_LOAD_WARNING_THRESHOLD: number;
|
|
23
|
+
BUNDLE_SIZE_THRESHOLD: number;
|
|
24
|
+
BUNDLE_SIZE_WARNING_THRESHOLD: number;
|
|
25
|
+
};
|
|
26
|
+
export declare const LAZY_LOADING_DEFAULTS: {
|
|
27
|
+
ROOT_MARGIN: string;
|
|
28
|
+
THRESHOLD: number;
|
|
29
|
+
MAX_CONCURRENT: number;
|
|
30
|
+
RETRY_ATTEMPTS: number;
|
|
31
|
+
RETRY_DELAY: number;
|
|
32
|
+
};
|
|
33
|
+
export declare const RESOURCE_DEFAULTS: {
|
|
34
|
+
MAX_PRELOAD_REQUESTS: number;
|
|
35
|
+
PREFETCH_TIMEOUT: number;
|
|
36
|
+
CACHE_DURATION: number;
|
|
37
|
+
MAX_CONCURRENT_REQUESTS: number;
|
|
38
|
+
DNS_PREFETCH_ENABLED: boolean;
|
|
39
|
+
PRECONNECT_ENABLED: boolean;
|
|
40
|
+
};
|
|
41
|
+
export declare const SDK_DEFAULTS: {
|
|
42
|
+
DEBUG: boolean;
|
|
43
|
+
LOG_LEVEL: "info";
|
|
44
|
+
VERSION: string;
|
|
45
|
+
};
|
|
46
|
+
export declare const SDK_VERSION = "2.0.3";
|
|
47
|
+
export declare function getDefaultVersionedApiUrl(): string;
|
|
48
|
+
export declare const API_DEFAULTS: {
|
|
49
|
+
DEV_API_URL: string;
|
|
50
|
+
DEV_CLIENT_URL: string;
|
|
51
|
+
PROD_API_URL: string;
|
|
52
|
+
PROD_CLIENT_URL: string;
|
|
53
|
+
PROD_CDN_URL: string;
|
|
54
|
+
VERSION: string;
|
|
55
|
+
NODE_ENV: string;
|
|
56
|
+
ENABLE_EDITING: boolean;
|
|
57
|
+
};
|
|
58
|
+
export declare const WIDGET_DEFAULTS: {
|
|
59
|
+
RENDER_MODE: "auto";
|
|
60
|
+
DISPLAY_MODE: "inline";
|
|
61
|
+
RESIZE: "fixed";
|
|
62
|
+
WIDTH: number;
|
|
63
|
+
HEIGHT: number;
|
|
64
|
+
AUTOSCALE: boolean;
|
|
65
|
+
};
|
|
66
|
+
export declare const BROWSER_DEFAULTS: {
|
|
67
|
+
CUSTOM_ELEMENTS: boolean;
|
|
68
|
+
HTTP3: boolean;
|
|
69
|
+
RESIZE_OBSERVER: boolean;
|
|
70
|
+
};
|
|
71
|
+
export declare const PERFORMANCE_SETTINGS_DEFAULTS: {
|
|
72
|
+
BATCH_SIZE: number;
|
|
73
|
+
LOAD_TIMEOUT: number;
|
|
74
|
+
RETRY_ATTEMPTS: number;
|
|
75
|
+
};
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Position Manager - Centralized content progression tracking
|
|
3
|
+
* Tracks and persists current position in sequential content widgets
|
|
4
|
+
* (galleries, carousels, sliders, step-by-step content, etc.)
|
|
5
|
+
*/
|
|
6
|
+
export interface ContentPositionState {
|
|
7
|
+
/** Widget composition ID */
|
|
8
|
+
compositionId: string;
|
|
9
|
+
/** Type of content being tracked */
|
|
10
|
+
contentType: 'gallery' | 'carousel' | 'slider' | 'stepper' | 'tabs' | 'list' | 'custom';
|
|
11
|
+
/** Current position/index in the content sequence */
|
|
12
|
+
currentIndex: number;
|
|
13
|
+
/** Total number of items in the sequence */
|
|
14
|
+
totalItems: number;
|
|
15
|
+
/** Optional item identifier for the current item */
|
|
16
|
+
currentItemId?: string;
|
|
17
|
+
/** Optional title/name of current item */
|
|
18
|
+
currentItemTitle?: string;
|
|
19
|
+
/** Timestamp when position was last updated */
|
|
20
|
+
lastUpdated: number;
|
|
21
|
+
/** Whether this widget should auto-resume position on page load */
|
|
22
|
+
autoResume?: boolean;
|
|
23
|
+
/** Last user interaction timestamp */
|
|
24
|
+
lastInteraction?: number;
|
|
25
|
+
/** Additional metadata specific to the content type */
|
|
26
|
+
metadata?: {
|
|
27
|
+
/** For galleries: current zoom level, view mode */
|
|
28
|
+
zoomLevel?: number;
|
|
29
|
+
viewMode?: 'grid' | 'list' | 'single';
|
|
30
|
+
/** For carousels: autoplay state, transition speed */
|
|
31
|
+
autoPlay?: boolean;
|
|
32
|
+
transitionSpeed?: number;
|
|
33
|
+
/** For steppers: completion status, validation state */
|
|
34
|
+
completedSteps?: number[];
|
|
35
|
+
validationErrors?: string[];
|
|
36
|
+
/** Generic key-value pairs for custom data */
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface ContentPositionConfig {
|
|
41
|
+
/** Type of content being tracked */
|
|
42
|
+
contentType?: 'gallery' | 'carousel' | 'slider' | 'stepper' | 'tabs' | 'list' | 'custom';
|
|
43
|
+
/** Whether to persist position state in localStorage */
|
|
44
|
+
persistState?: boolean;
|
|
45
|
+
/** Whether to auto-resume position after page refresh */
|
|
46
|
+
autoResume?: boolean;
|
|
47
|
+
/** Maximum time since last interaction to allow auto-resume (ms, default: 24 hours) */
|
|
48
|
+
autoResumeTimeout?: number;
|
|
49
|
+
/** Debounce delay for position updates (ms, default: 500ms) */
|
|
50
|
+
debounceDelay?: number;
|
|
51
|
+
/** Whether to track additional metadata */
|
|
52
|
+
trackMetadata?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface ContentPositionEvent {
|
|
55
|
+
/** Event type */
|
|
56
|
+
type: 'position' | 'navigate' | 'complete' | 'reset' | 'metadata';
|
|
57
|
+
/** Widget composition ID */
|
|
58
|
+
compositionId: string;
|
|
59
|
+
/** Content configuration */
|
|
60
|
+
config: ContentPositionConfig;
|
|
61
|
+
/** Event data */
|
|
62
|
+
data?: {
|
|
63
|
+
currentIndex?: number;
|
|
64
|
+
totalItems?: number;
|
|
65
|
+
currentItemId?: string;
|
|
66
|
+
currentItemTitle?: string;
|
|
67
|
+
direction?: 'next' | 'previous' | 'jump';
|
|
68
|
+
metadata?: any;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface ResumePositionOptions {
|
|
72
|
+
/** Whether to auto-resume widgets that have saved positions */
|
|
73
|
+
autoResumePosition?: boolean;
|
|
74
|
+
/** Maximum age of state to consider for auto-resume (ms, default: 24 hours) */
|
|
75
|
+
maxStateAge?: number;
|
|
76
|
+
/** Specific widget to resume (if not provided, resumes all eligible) */
|
|
77
|
+
compositionId?: string;
|
|
78
|
+
/** Whether to respect auto-resume timeouts */
|
|
79
|
+
respectTimeouts?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export declare class ContentPositionManager {
|
|
82
|
+
private static instance;
|
|
83
|
+
private contentStates;
|
|
84
|
+
private widgetConfigs;
|
|
85
|
+
private readonly storageKey;
|
|
86
|
+
private readonly storageVersion;
|
|
87
|
+
private eventListeners;
|
|
88
|
+
private autoResumeEnabled;
|
|
89
|
+
private readonly defaultAutoResumeTimeout;
|
|
90
|
+
private debounceTimers;
|
|
91
|
+
static getInstance(): ContentPositionManager;
|
|
92
|
+
constructor();
|
|
93
|
+
/**
|
|
94
|
+
* Register a widget for content position tracking
|
|
95
|
+
*/
|
|
96
|
+
registerWidget(compositionId: string, config?: ContentPositionConfig): void;
|
|
97
|
+
/**
|
|
98
|
+
* Unregister a widget from content position tracking
|
|
99
|
+
*/
|
|
100
|
+
unregisterWidget(compositionId: string): void;
|
|
101
|
+
/**
|
|
102
|
+
* Handle content position events from widgets
|
|
103
|
+
*/
|
|
104
|
+
handleContentPositionEvent(event: ContentPositionEvent): void;
|
|
105
|
+
/**
|
|
106
|
+
* Handle position change events
|
|
107
|
+
*/
|
|
108
|
+
private handlePositionChangeEvent;
|
|
109
|
+
/**
|
|
110
|
+
* Handle completion events
|
|
111
|
+
*/
|
|
112
|
+
private handleCompleteEvent;
|
|
113
|
+
/**
|
|
114
|
+
* Handle reset events
|
|
115
|
+
*/
|
|
116
|
+
private handleResetEvent;
|
|
117
|
+
/**
|
|
118
|
+
* Handle metadata events
|
|
119
|
+
*/
|
|
120
|
+
private handleMetadataEvent;
|
|
121
|
+
/**
|
|
122
|
+
* Load persisted state from localStorage
|
|
123
|
+
*/
|
|
124
|
+
private loadPersistedState;
|
|
125
|
+
/**
|
|
126
|
+
* Persist current state to localStorage (debounced)
|
|
127
|
+
*/
|
|
128
|
+
private debouncedPersistState;
|
|
129
|
+
/**
|
|
130
|
+
* Persist current state to localStorage
|
|
131
|
+
*/
|
|
132
|
+
private persistState;
|
|
133
|
+
/**
|
|
134
|
+
* Set up page unload handler
|
|
135
|
+
*/
|
|
136
|
+
private setupUnloadHandler;
|
|
137
|
+
/**
|
|
138
|
+
* Auto-resume widgets that had saved positions
|
|
139
|
+
*/
|
|
140
|
+
private autoResumePositions;
|
|
141
|
+
/**
|
|
142
|
+
* Resume a specific widget to its previous position
|
|
143
|
+
*/
|
|
144
|
+
resumeWidgetPosition(compositionId: string): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Send restore position command to a widget
|
|
147
|
+
*/
|
|
148
|
+
private sendRestorePositionCommand;
|
|
149
|
+
/**
|
|
150
|
+
* Get all content position widgets
|
|
151
|
+
*/
|
|
152
|
+
getAllContentWidgets(): ContentPositionState[];
|
|
153
|
+
/**
|
|
154
|
+
* Get persisted state for a specific widget
|
|
155
|
+
*/
|
|
156
|
+
getPersistedPosition(compositionId: string): ContentPositionState | null;
|
|
157
|
+
/**
|
|
158
|
+
* Update widget state (for external state synchronization)
|
|
159
|
+
*/
|
|
160
|
+
updateWidgetPosition(compositionId: string, stateUpdate: Partial<ContentPositionState>): void;
|
|
161
|
+
/**
|
|
162
|
+
* Clear all persisted state
|
|
163
|
+
*/
|
|
164
|
+
clearPersistedState(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Get content position statistics
|
|
167
|
+
*/
|
|
168
|
+
getStats(): {
|
|
169
|
+
totalWidgets: number;
|
|
170
|
+
trackedWidgets: number;
|
|
171
|
+
autoResumeEnabled: boolean;
|
|
172
|
+
storageVersion: string;
|
|
173
|
+
contentTypes: Record<string, number>;
|
|
174
|
+
allWidgets: {
|
|
175
|
+
compositionId: string;
|
|
176
|
+
contentType: "gallery" | "carousel" | "slider" | "stepper" | "tabs" | "list" | "custom";
|
|
177
|
+
currentIndex: number;
|
|
178
|
+
totalItems: number;
|
|
179
|
+
progress: number;
|
|
180
|
+
lastInteraction: number;
|
|
181
|
+
autoResume: boolean;
|
|
182
|
+
metadata: {
|
|
183
|
+
[key: string]: any;
|
|
184
|
+
/** For galleries: current zoom level, view mode */
|
|
185
|
+
zoomLevel?: number;
|
|
186
|
+
viewMode?: "grid" | "list" | "single";
|
|
187
|
+
/** For carousels: autoplay state, transition speed */
|
|
188
|
+
autoPlay?: boolean;
|
|
189
|
+
transitionSpeed?: number;
|
|
190
|
+
/** For steppers: completion status, validation state */
|
|
191
|
+
completedSteps?: number[];
|
|
192
|
+
validationErrors?: string[];
|
|
193
|
+
};
|
|
194
|
+
}[];
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Add event listener for a specific widget
|
|
198
|
+
*/
|
|
199
|
+
addEventListener(compositionId: string, listener: (event: ContentPositionEvent) => void): () => void;
|
|
200
|
+
/**
|
|
201
|
+
* Emit event to widget-specific listeners
|
|
202
|
+
*/
|
|
203
|
+
private emitToListeners;
|
|
204
|
+
/**
|
|
205
|
+
* Dispatch global event
|
|
206
|
+
*/
|
|
207
|
+
private dispatchGlobalEvent;
|
|
208
|
+
/**
|
|
209
|
+
* Enable or disable auto-resume functionality
|
|
210
|
+
*/
|
|
211
|
+
setAutoResumeEnabled(enabled: boolean): void;
|
|
212
|
+
/**
|
|
213
|
+
* Manually trigger auto-resume for eligible widgets
|
|
214
|
+
*/
|
|
215
|
+
triggerAutoResume(options?: ResumePositionOptions): void;
|
|
216
|
+
/**
|
|
217
|
+
* Cleanup all content position management
|
|
218
|
+
*/
|
|
219
|
+
destroy(): void;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Get global content position manager instance
|
|
223
|
+
*/
|
|
224
|
+
export declare function getContentPositionManager(): ContentPositionManager;
|
|
225
|
+
/**
|
|
226
|
+
* Reset content position manager (for testing)
|
|
227
|
+
*/
|
|
228
|
+
export declare function resetContentPositionManager(): void;
|