content-security-toolkit 1.0.1 → 1.0.2
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 +22 -0
- package/dist/core/mediator/handlers/baseEventHandler.d.ts +65 -0
- package/dist/core/mediator/handlers/baseEventHandler.js +99 -0
- package/dist/core/mediator/handlers/index.d.ts +9 -0
- package/dist/core/mediator/handlers/index.js +34 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/otel.d.ts +24 -0
- package/dist/otel.js +87 -0
- package/dist/strategies/AbstractStrategy.mediator.d.ts +162 -0
- package/dist/strategies/AbstractStrategy.mediator.js +349 -0
- package/dist/strategies/DevToolsStrategy copy.d.ts +85 -0
- package/dist/strategies/DevToolsStrategy copy.js +362 -0
- package/dist/strategies/DevToolsStrategy-detectorManager.d.ts +70 -0
- package/dist/strategies/DevToolsStrategy-detectorManager.js +309 -0
- package/dist/strategies/DevToolsStrategy-simple.d.ts +75 -0
- package/dist/strategies/DevToolsStrategy-simple.js +366 -0
- package/dist/strategies/StrategyRegistry.d.ts +133 -0
- package/dist/strategies/StrategyRegistry.js +379 -0
- package/dist/utils/base/LoggableComponent.d.ts +62 -0
- package/dist/utils/base/LoggableComponent.js +95 -0
- package/dist/utils/debuggerDetector/debuggerDetectionWorker.d.ts +6 -0
- package/dist/utils/debuggerDetector/debuggerDetectionWorker.js +24 -0
- package/dist/utils/debuggerDetector/debuggerDetector.d.ts +55 -0
- package/dist/utils/debuggerDetector/debuggerDetector.js +158 -0
- package/dist/utils/debuggerDetector/firefoxDetector.d.ts +8 -0
- package/dist/utils/debuggerDetector/firefoxDetector.js +64 -0
- package/dist/utils/detection.d.ts +29 -0
- package/dist/utils/detection.js +267 -0
- package/dist/utils/detectors/debuggerDetectionWorker.d.ts +6 -0
- package/dist/utils/detectors/debuggerDetectionWorker.js +24 -0
- package/dist/utils/detectors/firefoxDetector.d.ts +8 -0
- package/dist/utils/detectors/firefoxDetector.js +64 -0
- package/dist/utils/logging/LogLevel.d.ts +21 -0
- package/dist/utils/logging/LogLevel.js +46 -0
- package/dist/utils/logging/LoggingConfig.d.ts +68 -0
- package/dist/utils/logging/LoggingConfig.js +64 -0
- package/dist/utils/logging/LoggingFactory.d.ts +22 -0
- package/dist/utils/logging/LoggingFactory.js +61 -0
- package/dist/utils/logging/LoggingService.d.ts +235 -0
- package/dist/utils/logging/LoggingService.js +385 -0
- package/dist/utils/logging/SimpleLoggingService.d.ts +39 -0
- package/dist/utils/logging/SimpleLoggingService.js +58 -0
- package/dist/utils/logging/advanced/LogLevel.d.ts +21 -0
- package/dist/utils/logging/advanced/LogLevel.js +46 -0
- package/dist/utils/logging/advanced/LoggingConfig.d.ts +68 -0
- package/dist/utils/logging/advanced/LoggingConfig.js +64 -0
- package/dist/utils/logging/advanced/LoggingFactory.d.ts +22 -0
- package/dist/utils/logging/advanced/LoggingFactory.js +61 -0
- package/dist/utils/logging/advanced/LoggingService.d.ts +235 -0
- package/dist/utils/logging/advanced/LoggingService.js +385 -0
- package/dist/utils/protectedContentManager-simple.d.ts +86 -0
- package/dist/utils/protectedContentManager-simple.js +180 -0
- package/dist/utils/securityOverlayManager-observer-pause.d.ts +283 -0
- package/dist/utils/securityOverlayManager-observer-pause.js +878 -0
- package/dist/utils/securityOverlayManager-simple.d.ts +197 -0
- package/dist/utils/securityOverlayManager-simple.js +552 -0
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { MediatorAware, ProtectionMediator } from "../core/mediator/types";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the protected content placeholder
|
|
4
|
+
*/
|
|
5
|
+
export interface PlaceholderOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Title to display in the placeholder
|
|
8
|
+
*/
|
|
9
|
+
title?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Main message to display
|
|
12
|
+
*/
|
|
13
|
+
message?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Secondary message to display
|
|
16
|
+
*/
|
|
17
|
+
secondaryMessage?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Text color for the placeholder
|
|
20
|
+
*/
|
|
21
|
+
textColor?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Background color for the placeholder
|
|
24
|
+
*/
|
|
25
|
+
backgroundColor?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Utility class to manage protected content by hiding and revealing it
|
|
29
|
+
*/
|
|
30
|
+
export declare class ProtectedContentManager implements MediatorAware {
|
|
31
|
+
readonly COMPONENT_NAME = "ProtectedContentManager";
|
|
32
|
+
private mediator;
|
|
33
|
+
private targetElement;
|
|
34
|
+
private originalContent;
|
|
35
|
+
private debugMode;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new ProtectedContentManager
|
|
38
|
+
* @param targetElement Element containing sensitive content to protect
|
|
39
|
+
* @param debugMode Enable debug mode for troubleshooting
|
|
40
|
+
*/
|
|
41
|
+
constructor(targetElement: HTMLElement, debugMode?: boolean);
|
|
42
|
+
/**
|
|
43
|
+
* Set the mediator
|
|
44
|
+
* to communicate with the other components
|
|
45
|
+
*/
|
|
46
|
+
setMediator(mediator: ProtectionMediator): void;
|
|
47
|
+
/**
|
|
48
|
+
* Handle content hidden event
|
|
49
|
+
*/
|
|
50
|
+
private handleContentHidden;
|
|
51
|
+
/**
|
|
52
|
+
* Handle content restored event
|
|
53
|
+
*/
|
|
54
|
+
private handleContentRestored;
|
|
55
|
+
/**
|
|
56
|
+
* Hide the original content and replace it with a placeholder
|
|
57
|
+
* @param options Options for customizing the placeholder
|
|
58
|
+
* @returns True if content was hidden, false if there was no content to hide
|
|
59
|
+
*/
|
|
60
|
+
hideContent(options: PlaceholderOptions): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Restore the original content
|
|
63
|
+
* @returns True if content was restored, false if there was no content to restore
|
|
64
|
+
*/
|
|
65
|
+
restoreContent(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Check if content is currently hidden
|
|
68
|
+
* @returns True if content is hidden, false otherwise
|
|
69
|
+
*/
|
|
70
|
+
isContentHidden(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Update the target element
|
|
73
|
+
* @param element New target element
|
|
74
|
+
*/
|
|
75
|
+
updateTargetElement(element: HTMLElement): void;
|
|
76
|
+
/**
|
|
77
|
+
* Get the current target element
|
|
78
|
+
* @returns The current target element
|
|
79
|
+
*/
|
|
80
|
+
getTargetElement(): HTMLElement;
|
|
81
|
+
/**
|
|
82
|
+
* Set debug mode
|
|
83
|
+
* @param enabled Whether debug mode should be enabled
|
|
84
|
+
*/
|
|
85
|
+
setDebugMode(enabled: boolean): void;
|
|
86
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { ProtectionEventType } from "../core/mediator/protection-event";
|
|
2
|
+
/**
|
|
3
|
+
* Utility class to manage protected content by hiding and revealing it
|
|
4
|
+
*/
|
|
5
|
+
export class ProtectedContentManager {
|
|
6
|
+
/**
|
|
7
|
+
* Create a new ProtectedContentManager
|
|
8
|
+
* @param targetElement Element containing sensitive content to protect
|
|
9
|
+
* @param debugMode Enable debug mode for troubleshooting
|
|
10
|
+
*/
|
|
11
|
+
constructor(targetElement, debugMode = false) {
|
|
12
|
+
this.COMPONENT_NAME = "ProtectedContentManager";
|
|
13
|
+
this.mediator = null;
|
|
14
|
+
this.originalContent = null;
|
|
15
|
+
this.targetElement = targetElement;
|
|
16
|
+
this.debugMode = debugMode;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Set the mediator
|
|
20
|
+
* to communicate with the other components
|
|
21
|
+
*/
|
|
22
|
+
setMediator(mediator) {
|
|
23
|
+
this.mediator = mediator;
|
|
24
|
+
// Subscribe only to general events directly related to content management
|
|
25
|
+
this.mediator.subscribe(ProtectionEventType.CONTENT_HIDDEN, this.handleContentHidden.bind(this), {
|
|
26
|
+
context: this.COMPONENT_NAME,
|
|
27
|
+
});
|
|
28
|
+
this.mediator.subscribe(ProtectionEventType.CONTENT_RESTORED, this.handleContentRestored.bind(this), {
|
|
29
|
+
context: this.COMPONENT_NAME,
|
|
30
|
+
});
|
|
31
|
+
if (this.debugMode) {
|
|
32
|
+
console.log("ProtectedContentManager: Mediator set and subscriptions established");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Handle content hidden event
|
|
37
|
+
*/
|
|
38
|
+
handleContentHidden(event) {
|
|
39
|
+
try {
|
|
40
|
+
if (this.debugMode) {
|
|
41
|
+
console.log(`ProtectedContentManager: Received content hidden event from ${event.source}`, event.data);
|
|
42
|
+
}
|
|
43
|
+
const data = event.data;
|
|
44
|
+
if (!data || !data.options)
|
|
45
|
+
return;
|
|
46
|
+
// Only process if this is for our target element or we're the default handler
|
|
47
|
+
if (data.targetElement && data.targetElement !== this.targetElement)
|
|
48
|
+
return;
|
|
49
|
+
this.hideContent(data.options);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error("ProtectedContentManager: Error handling content hidden event", error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Handle content restored event
|
|
57
|
+
*/
|
|
58
|
+
handleContentRestored(event) {
|
|
59
|
+
try {
|
|
60
|
+
if (this.debugMode) {
|
|
61
|
+
console.log(`ProtectedContentManager: Received content restored event from ${event.source}`, event.data);
|
|
62
|
+
}
|
|
63
|
+
const data = event.data;
|
|
64
|
+
// Only process if this is for our target element or we're the default handler
|
|
65
|
+
if (data && data.targetElement && data.targetElement !== this.targetElement)
|
|
66
|
+
return;
|
|
67
|
+
this.restoreContent();
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error("ProtectedContentManager: Error handling content restored event", error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Hide the original content and replace it with a placeholder
|
|
75
|
+
* @param options Options for customizing the placeholder
|
|
76
|
+
* @returns True if content was hidden, false if there was no content to hide
|
|
77
|
+
*/
|
|
78
|
+
hideContent(options) {
|
|
79
|
+
if (!this.targetElement)
|
|
80
|
+
return false;
|
|
81
|
+
// Store original content if not already stored
|
|
82
|
+
if (this.originalContent === null) {
|
|
83
|
+
this.originalContent = this.targetElement.innerHTML;
|
|
84
|
+
if (this.debugMode) {
|
|
85
|
+
console.log("ProtectedContentManager: Original content stored");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Create placeholder content with custom styles
|
|
89
|
+
const placeholderStyles = {
|
|
90
|
+
padding: "20px",
|
|
91
|
+
textAlign: "center",
|
|
92
|
+
color: options.textColor || "white",
|
|
93
|
+
backgroundColor: options.backgroundColor || "rgba(0, 0, 0, 0.05)",
|
|
94
|
+
borderRadius: "8px",
|
|
95
|
+
margin: "20px",
|
|
96
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)",
|
|
97
|
+
};
|
|
98
|
+
// Convert styles object to inline style string
|
|
99
|
+
const styleString = Object.entries(placeholderStyles)
|
|
100
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
101
|
+
.join("; ");
|
|
102
|
+
// Replace content with a placeholder that uses the options text
|
|
103
|
+
this.targetElement.innerHTML = `
|
|
104
|
+
<div style="${styleString}">
|
|
105
|
+
<h2 style="font-size: 24px; margin-bottom: 20px; color: ${options.textColor || "black"};">
|
|
106
|
+
${options.title || "Content Protected"}
|
|
107
|
+
</h2>
|
|
108
|
+
<p style="font-size: 16px; margin-bottom: 15px; color: ${options.textColor || "black"};">
|
|
109
|
+
${options.message || "This content is protected for security reasons."}
|
|
110
|
+
</p>
|
|
111
|
+
${options.secondaryMessage
|
|
112
|
+
? `
|
|
113
|
+
<p style="font-size: 16px; color: ${options.textColor || "black"};">
|
|
114
|
+
${options.secondaryMessage}
|
|
115
|
+
</p>
|
|
116
|
+
`
|
|
117
|
+
: ""}
|
|
118
|
+
<div style="margin-top: 20px; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, 0.2);">
|
|
119
|
+
<p style="font-size: 14px; color: ${options.textColor || "black"}; opacity: 0.8;">
|
|
120
|
+
This content is protected by ContentSecurityToolkit
|
|
121
|
+
</p>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
`;
|
|
125
|
+
if (this.debugMode) {
|
|
126
|
+
console.log("ProtectedContentManager: Content hidden");
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Restore the original content
|
|
132
|
+
* @returns True if content was restored, false if there was no content to restore
|
|
133
|
+
*/
|
|
134
|
+
restoreContent() {
|
|
135
|
+
if (!this.targetElement || this.originalContent === null)
|
|
136
|
+
return false;
|
|
137
|
+
// Restore the original content
|
|
138
|
+
this.targetElement.innerHTML = this.originalContent;
|
|
139
|
+
this.originalContent = null;
|
|
140
|
+
if (this.debugMode) {
|
|
141
|
+
console.log("ProtectedContentManager: Original content restored");
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Check if content is currently hidden
|
|
147
|
+
* @returns True if content is hidden, false otherwise
|
|
148
|
+
*/
|
|
149
|
+
isContentHidden() {
|
|
150
|
+
return this.originalContent !== null;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Update the target element
|
|
154
|
+
* @param element New target element
|
|
155
|
+
*/
|
|
156
|
+
updateTargetElement(element) {
|
|
157
|
+
// If content is hidden, restore it before changing the target
|
|
158
|
+
if (this.isContentHidden()) {
|
|
159
|
+
this.restoreContent();
|
|
160
|
+
}
|
|
161
|
+
this.targetElement = element;
|
|
162
|
+
if (this.debugMode) {
|
|
163
|
+
console.log("ProtectedContentManager: Target element updated");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get the current target element
|
|
168
|
+
* @returns The current target element
|
|
169
|
+
*/
|
|
170
|
+
getTargetElement() {
|
|
171
|
+
return this.targetElement;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Set debug mode
|
|
175
|
+
* @param enabled Whether debug mode should be enabled
|
|
176
|
+
*/
|
|
177
|
+
setDebugMode(enabled) {
|
|
178
|
+
this.debugMode = enabled;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import type { MediatorAware, ProtectionMediator } from "../core/mediator/types";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the security overlay
|
|
4
|
+
*/
|
|
5
|
+
export interface OverlayOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Title to display in the overlay
|
|
8
|
+
*/
|
|
9
|
+
title?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Main message to display
|
|
12
|
+
*/
|
|
13
|
+
message?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Secondary message to display
|
|
16
|
+
*/
|
|
17
|
+
secondaryMessage?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Text color for the overlay
|
|
20
|
+
*/
|
|
21
|
+
textColor?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Background color for the overlay
|
|
24
|
+
*/
|
|
25
|
+
backgroundColor?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Z-index for the overlay (default: 2147483647)
|
|
28
|
+
*/
|
|
29
|
+
zIndex?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to show a close button
|
|
32
|
+
*/
|
|
33
|
+
showCloseButton?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Text for the close button
|
|
36
|
+
*/
|
|
37
|
+
closeButtonText?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Callback when close button is clicked
|
|
40
|
+
*/
|
|
41
|
+
onCloseButtonClick?: () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Duration in milliseconds to show the overlay (0 for indefinite)
|
|
44
|
+
*/
|
|
45
|
+
duration?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Additional custom styles for the overlay
|
|
48
|
+
*/
|
|
49
|
+
customStyles?: Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
* Additional custom styles for the text
|
|
52
|
+
*/
|
|
53
|
+
textStyles?: Record<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* Font size (ScreenshotStrategy - refactor)
|
|
56
|
+
*/
|
|
57
|
+
fontSize?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Additional HTML content to display in the overlay
|
|
60
|
+
*/
|
|
61
|
+
additionalContent?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Whether to block events (create an event blocker)
|
|
64
|
+
*/
|
|
65
|
+
blockEvents?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Whether to automatically restore the overlay if it's removed from the DOM
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
autoRestore?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Utility class to manage security overlays
|
|
74
|
+
*/
|
|
75
|
+
export declare class SecurityOverlayManager implements MediatorAware {
|
|
76
|
+
readonly COMPONENT_NAME = "SecurityOverlayManager";
|
|
77
|
+
private mediator;
|
|
78
|
+
private debugMode;
|
|
79
|
+
private logger;
|
|
80
|
+
private domObserver;
|
|
81
|
+
private overlays;
|
|
82
|
+
private activeOverlayId;
|
|
83
|
+
private overlayQueue;
|
|
84
|
+
private isObserverPaused;
|
|
85
|
+
private onElementsRemovedCallbacks;
|
|
86
|
+
/**
|
|
87
|
+
* Create a new SecurityOverlayManager
|
|
88
|
+
* @param debugMode Enable debug mode for troubleshooting
|
|
89
|
+
*/
|
|
90
|
+
constructor(debugMode?: boolean);
|
|
91
|
+
/**
|
|
92
|
+
* Set the mediator to communicate with the other components
|
|
93
|
+
* @param mediator The protection mediator
|
|
94
|
+
*/
|
|
95
|
+
setMediator(mediator: ProtectionMediator): void;
|
|
96
|
+
/**
|
|
97
|
+
* Handle overlay shown event
|
|
98
|
+
* @param event The protection event
|
|
99
|
+
*/
|
|
100
|
+
private handleOverlayShown;
|
|
101
|
+
/**
|
|
102
|
+
* Handle overlay removed event
|
|
103
|
+
* @param event The protection event
|
|
104
|
+
*/
|
|
105
|
+
private handleOverlayRemoved;
|
|
106
|
+
/**
|
|
107
|
+
* Handle overlay restored event
|
|
108
|
+
* @param event The protection event
|
|
109
|
+
*/
|
|
110
|
+
private handleOverlayRestored;
|
|
111
|
+
/**
|
|
112
|
+
* Register a new overlay
|
|
113
|
+
* @param owner The strategy or component that owns this overlay
|
|
114
|
+
* @param overlayType The type of overlay (e.g., "screenshot", "devtools")
|
|
115
|
+
* @param options Options for the overlay
|
|
116
|
+
* @param priority Priority for display order (higher displays on top)
|
|
117
|
+
* @returns The ID of the registered overlay
|
|
118
|
+
*/
|
|
119
|
+
registerOverlay(owner: string, overlayType: string, options: OverlayOptions, priority?: number): string;
|
|
120
|
+
/**
|
|
121
|
+
* Add an overlay to the queue
|
|
122
|
+
* @param overlayId ID of the overlay to add to queue
|
|
123
|
+
*/
|
|
124
|
+
private addToQueue;
|
|
125
|
+
/**
|
|
126
|
+
* Show a specific overlay by ID
|
|
127
|
+
* @param overlayId ID of the overlay to show
|
|
128
|
+
* @returns True if the overlay was shown successfully
|
|
129
|
+
*/
|
|
130
|
+
private showOverlayById;
|
|
131
|
+
/**
|
|
132
|
+
* Hide a specific overlay by ID without removing it from storage
|
|
133
|
+
* @param overlayId ID of the overlay to hide
|
|
134
|
+
* @param processQueue Whether to process the queue after hiding
|
|
135
|
+
* @returns True if the overlay was hidden successfully
|
|
136
|
+
*/
|
|
137
|
+
private hideOverlayById;
|
|
138
|
+
/**
|
|
139
|
+
* Create overlay and blocker elements
|
|
140
|
+
* @param overlay The stored overlay information
|
|
141
|
+
* @returns Object containing the created elements
|
|
142
|
+
*/
|
|
143
|
+
private createOverlayElements;
|
|
144
|
+
/**
|
|
145
|
+
* Remove a specific overlay by ID
|
|
146
|
+
* @param overlayId ID of the overlay to remove
|
|
147
|
+
* @param disableAutoRestore Whether to disable auto-restoration for this overlay
|
|
148
|
+
* @returns True if the overlay was removed successfully
|
|
149
|
+
*/
|
|
150
|
+
removeOverlayById(overlayId: string, disableAutoRestore?: boolean): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Remove all overlays for a specific owner
|
|
153
|
+
* @param owner The owner to remove overlays for
|
|
154
|
+
* @param disableAutoRestore Whether to disable auto-restoration for these overlays
|
|
155
|
+
* @returns The number of overlays removed
|
|
156
|
+
*/
|
|
157
|
+
removeOverlaysByOwner(owner: string, disableAutoRestore?: boolean): number;
|
|
158
|
+
/**
|
|
159
|
+
* Check and restore overlays for a specific owner
|
|
160
|
+
* @param owner The owner to check overlays for
|
|
161
|
+
* @returns The number of overlays restored
|
|
162
|
+
*/
|
|
163
|
+
checkAndRestoreOverlaysByOwner(owner: string): number;
|
|
164
|
+
/**
|
|
165
|
+
* Create an overlay element
|
|
166
|
+
* @param options Options for the overlay
|
|
167
|
+
* @param owner The owner of the overlay (for data attribute)
|
|
168
|
+
* @returns The created overlay element
|
|
169
|
+
*/
|
|
170
|
+
private createOverlay;
|
|
171
|
+
/**
|
|
172
|
+
* Create an event blocker that prevents interaction with the page
|
|
173
|
+
* @returns The created event blocker element
|
|
174
|
+
*/
|
|
175
|
+
private createEventBlocker;
|
|
176
|
+
/**
|
|
177
|
+
* Pause the DOM observer to prevent auto-restoration during intentional removal
|
|
178
|
+
*/
|
|
179
|
+
private pauseObserver;
|
|
180
|
+
/**
|
|
181
|
+
* Resume the DOM observer after intentional removal
|
|
182
|
+
*/
|
|
183
|
+
private resumeObserver;
|
|
184
|
+
/**
|
|
185
|
+
* Set up DOM observer to detect when overlay elements are removed
|
|
186
|
+
* @param overlay The overlay to observe
|
|
187
|
+
*/
|
|
188
|
+
private setupObserver;
|
|
189
|
+
/**
|
|
190
|
+
* Set up DOM observer for multiple overlays
|
|
191
|
+
* @param overlays Array of overlays to observe
|
|
192
|
+
*/
|
|
193
|
+
private setupObserverForMultipleOverlays;
|
|
194
|
+
/**
|
|
195
|
+
* Remove global event listeners that were added to document and window
|
|
196
|
+
*/
|
|
197
|
+
private removeGlobalEventListeners;
|
|
198
|
+
/**
|
|
199
|
+
* Notify all callbacks when elements are removed
|
|
200
|
+
* @param removedElements The elements that were removed
|
|
201
|
+
*/
|
|
202
|
+
private notifyElementsRemovedCallbacks;
|
|
203
|
+
/**
|
|
204
|
+
* Add a callback to be called when overlay elements are removed
|
|
205
|
+
* @param callback Callback function
|
|
206
|
+
*/
|
|
207
|
+
addElementsRemovedCallback(callback: (removedElements: HTMLElement[]) => void): void;
|
|
208
|
+
/**
|
|
209
|
+
* Remove a callback
|
|
210
|
+
* @param callback Callback function to remove
|
|
211
|
+
*/
|
|
212
|
+
removeElementsRemovedCallback(callback: (removedElements: HTMLElement[]) => void): void;
|
|
213
|
+
/**
|
|
214
|
+
* Disable auto-restoration for a specific overlay
|
|
215
|
+
* @param overlayId ID of the overlay to disable auto-restoration for
|
|
216
|
+
* @returns True if the overlay was found and updated
|
|
217
|
+
*/
|
|
218
|
+
disableAutoRestoreForOverlay(overlayId: string): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Disable auto-restoration for all overlays owned by a specific owner
|
|
221
|
+
* @param owner The owner to disable auto-restoration for
|
|
222
|
+
* @returns The number of overlays updated
|
|
223
|
+
*/
|
|
224
|
+
disableAutoRestoreForOwner(owner: string): number;
|
|
225
|
+
/**
|
|
226
|
+
* Get all overlays for a specific owner
|
|
227
|
+
* @param owner The owner to get overlays for
|
|
228
|
+
* @returns Array of overlay IDs
|
|
229
|
+
*/
|
|
230
|
+
getOverlaysByOwner(owner: string): string[];
|
|
231
|
+
/**
|
|
232
|
+
* Get all active overlays
|
|
233
|
+
* @returns Array of active overlay IDs
|
|
234
|
+
*/
|
|
235
|
+
getActiveOverlays(): string[];
|
|
236
|
+
/**
|
|
237
|
+
* Check if an overlay exists
|
|
238
|
+
* @param overlayId The overlay ID
|
|
239
|
+
* @returns True if the overlay exists
|
|
240
|
+
*/
|
|
241
|
+
hasOverlay(overlayId: string): boolean;
|
|
242
|
+
/**
|
|
243
|
+
* Get the currently active overlay ID
|
|
244
|
+
* @returns The active overlay ID or null if none is active
|
|
245
|
+
*/
|
|
246
|
+
getActiveOverlayId(): string | null;
|
|
247
|
+
/**
|
|
248
|
+
* Get the overlay queue
|
|
249
|
+
* @returns Array of overlay IDs in the queue
|
|
250
|
+
*/
|
|
251
|
+
getOverlayQueue(): string[];
|
|
252
|
+
/**
|
|
253
|
+
* Clear all overlays
|
|
254
|
+
* @returns The number of overlays removed
|
|
255
|
+
*/
|
|
256
|
+
clearAllOverlays(): number;
|
|
257
|
+
/**
|
|
258
|
+
* Set debug mode
|
|
259
|
+
* @param enabled Whether debug mode should be enabled
|
|
260
|
+
*/
|
|
261
|
+
setDebugMode(enabled: boolean): void;
|
|
262
|
+
/**
|
|
263
|
+
* Get debug information about registered overlays
|
|
264
|
+
* @returns Object with debug information
|
|
265
|
+
*/
|
|
266
|
+
getDebugInfo(): {
|
|
267
|
+
totalOverlays: number;
|
|
268
|
+
overlaysByOwner: Record<string, number>;
|
|
269
|
+
overlaysByType: Record<string, number>;
|
|
270
|
+
activeOverlayId: string | null;
|
|
271
|
+
queueLength: number;
|
|
272
|
+
observerPaused: boolean;
|
|
273
|
+
overlayDetails: Array<{
|
|
274
|
+
id: string;
|
|
275
|
+
owner: string;
|
|
276
|
+
type: string;
|
|
277
|
+
isVisible: boolean;
|
|
278
|
+
priority: number;
|
|
279
|
+
autoRestoreEnabled: boolean;
|
|
280
|
+
createdAt: number;
|
|
281
|
+
}>;
|
|
282
|
+
};
|
|
283
|
+
}
|