@microsoft/omnichannel-chat-widget 1.8.3 → 1.8.4-main.4478bbf
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/lib/cjs/common/Constants.js +5 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
- package/lib/cjs/common/telemetry/AppInsightsEvents.js +4 -5
- package/lib/cjs/common/telemetry/TelemetryConstants.js +43 -2
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +26 -10
- package/lib/cjs/common/utils/SecureEventBus.js +307 -0
- package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
- package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +284 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +7 -1
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +7 -5
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
- package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +12 -3
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +29 -2
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +31 -5
- package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +18 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +44 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
- package/lib/esm/common/Constants.js +5 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
- package/lib/esm/common/telemetry/AppInsightsEvents.js +4 -5
- package/lib/esm/common/telemetry/TelemetryConstants.js +41 -1
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +27 -11
- package/lib/esm/common/utils/SecureEventBus.js +328 -0
- package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
- package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +277 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +7 -1
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +7 -5
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +7 -3
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
- package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +13 -4
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -4
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +34 -5
- package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
- package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +42 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/esm/plugins/newMessageEventHandler.js +4 -1
- package/lib/types/common/Constants.d.ts +4 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +38 -2
- package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
- package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
- package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
|
|
2
|
+
import { IPersistentChatHistoryProps } from "../interfaces/IPersistentChatHistoryProps";
|
|
3
|
+
/**
|
|
4
|
+
* Class responsible for handling persistent conversation history
|
|
5
|
+
*/
|
|
6
|
+
declare class PersistentConversationHandler {
|
|
7
|
+
private appliedProps;
|
|
8
|
+
private isLastPull;
|
|
9
|
+
private pageToken;
|
|
10
|
+
private facadeChatSDK;
|
|
11
|
+
private lastMessage;
|
|
12
|
+
private count;
|
|
13
|
+
private pageSize;
|
|
14
|
+
private isCurrentlyPulling;
|
|
15
|
+
private pageTokenInTransitSet;
|
|
16
|
+
constructor(facadeChatSDK: FacadeChatSDK, props: IPersistentChatHistoryProps);
|
|
17
|
+
private appliedPropsHandler;
|
|
18
|
+
private resetEventListener;
|
|
19
|
+
reset(): void;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
pullHistory(): Promise<void>;
|
|
22
|
+
private processHistoryMessages;
|
|
23
|
+
private fetchHistoryMessages;
|
|
24
|
+
private shouldPull;
|
|
25
|
+
private processMessageToActivity;
|
|
26
|
+
private createDividerActivity;
|
|
27
|
+
}
|
|
28
|
+
export default PersistentConversationHandler;
|
|
@@ -4,4 +4,5 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
|
|
|
4
4
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
5
5
|
export declare const handleStartChatError: (dispatch: Dispatch<ILiveChatWidgetAction>, facadeChatSDK: FacadeChatSDK, props: ILiveChatWidgetProps | undefined, ex: any, isStartChatSuccessful: boolean) => void;
|
|
6
6
|
export declare const logWidgetLoadComplete: (additionalMessage?: string) => void;
|
|
7
|
+
export declare const logStartChatComplete: (additionalMessage?: string) => void;
|
|
7
8
|
export declare const logWidgetLoadWithUnexpectedError: (ex: any) => void;
|
|
@@ -20,6 +20,7 @@ import { ILoadingPaneProps } from "@microsoft/omnichannel-chat-components/lib/ty
|
|
|
20
20
|
import { IMockProps } from "./IMockProps";
|
|
21
21
|
import { INotificationPaneProps } from "@microsoft/omnichannel-chat-components/lib/types/components/notificationpane/interfaces/INotificationPaneProps";
|
|
22
22
|
import { IOOOHPaneProps } from "@microsoft/omnichannel-chat-components/lib/types/components/outofofficehourspane/interfaces/IOOOHPaneProps";
|
|
23
|
+
import { IPersistentChatHistoryProps } from "./IPersistentChatHistoryProps";
|
|
23
24
|
import { IPostChatSurveyPaneStatefulProps } from "../../postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps";
|
|
24
25
|
import { IPreChatSurveyPaneProps } from "@microsoft/omnichannel-chat-components/lib/types/components/prechatsurveypane/interfaces/IPreChatSurveyPaneProps";
|
|
25
26
|
import { IProactiveChatPaneStatefulProps } from "../../proactivechatpanestateful/interfaces/IProactiveChatPaneStatefulProps";
|
|
@@ -69,4 +70,5 @@ export interface ILiveChatWidgetProps {
|
|
|
69
70
|
mock?: IMockProps;
|
|
70
71
|
featureConfigProps?: IFeatureConfigProps;
|
|
71
72
|
appInsightsConfig?: IAppInsightsConfig;
|
|
73
|
+
persistentChatHistoryProps?: IPersistentChatHistoryProps;
|
|
72
74
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
|
|
2
|
+
import { IPersistentChatHistoryProps } from "../../livechatwidget/interfaces/IPersistentChatHistoryProps";
|
|
3
|
+
declare const usePersistentChatHistory: (facadeChatSDK: FacadeChatSDK | undefined, props: IPersistentChatHistoryProps) => void;
|
|
4
|
+
export default usePersistentChatHistory;
|
package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IPersistentChatHistoryProps } from "../../livechatwidget/interfaces/IPersistentChatHistoryProps";
|
|
2
|
+
/**
|
|
3
|
+
* Component to handle persistent chat history events.
|
|
4
|
+
* Uses WebChatStoreLoader instead of hooks to avoid context issues.
|
|
5
|
+
*/
|
|
6
|
+
declare const WebChatEventSubscribers: (props: IPersistentChatHistoryProps) => null;
|
|
7
|
+
export default WebChatEventSubscribers;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IPersistentChatHistoryProps } from "../../../../../livechatwidget/interfaces/IPersistentChatHistoryProps";
|
|
2
|
+
import React from "react";
|
|
3
|
+
declare const ConversationDividerActivity: (props: IPersistentChatHistoryProps) => React.JSX.Element;
|
|
4
|
+
export default ConversationDividerActivity;
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LazyLoadActivity Component
|
|
3
|
+
*
|
|
4
|
+
* This component implements a sophisticated lazy loading system for chat history in the webchat widget.
|
|
5
|
+
* It uses an IntersectionObserver to detect when the user scrolls near the top of the chat container
|
|
6
|
+
* and then triggers the loading of previous chat messages.
|
|
7
|
+
*
|
|
8
|
+
* Key Features:
|
|
9
|
+
* - Intersection Observer based detection for optimal performance
|
|
10
|
+
* - Reliable scroll management with retry mechanisms
|
|
11
|
+
* - Immediate user feedback even during initialization delays
|
|
12
|
+
* - Handles edge cases like minimize/maximize widget scenarios
|
|
13
|
+
* - Memory leak prevention with proper cleanup
|
|
14
|
+
*
|
|
15
|
+
* Architecture:
|
|
16
|
+
* - LazyLoadHandler: Static class managing all lazy load logic
|
|
17
|
+
* - LazyLoadActivity: React component providing the UI and lifecycle integration for lazy loading
|
|
18
|
+
*
|
|
19
|
+
* Flow:
|
|
20
|
+
* 1. Component renders a trigger element at the top of chat history
|
|
21
|
+
* 2. IntersectionObserver watches when this element becomes visible
|
|
22
|
+
* 3. When visible, dispatches event to fetch more chat history
|
|
23
|
+
* 4. Performs controlled scroll to maintain user position
|
|
24
|
+
* 5. Resets observer for next lazy load cycle
|
|
25
|
+
*/
|
|
26
|
+
import { TelemetryEvent } from "../../../../../../common/telemetry/TelemetryConstants";
|
|
27
|
+
import React from "react";
|
|
28
|
+
import { ILiveChatWidgetProps } from "../../../../../livechatwidget/interfaces/ILiveChatWidgetProps";
|
|
29
|
+
/**
|
|
30
|
+
* LazyLoadHandler - Static class managing all lazy loading functionality
|
|
31
|
+
*
|
|
32
|
+
* This class uses a singleton pattern with static methods to ensure consistent
|
|
33
|
+
* state management across component re-renders and widget lifecycle events.
|
|
34
|
+
*
|
|
35
|
+
* State Management:
|
|
36
|
+
* - initialized: Tracks if the IntersectionObserver has been set up
|
|
37
|
+
* - paused: Temporarily disables lazy loading (during initialization/loading)
|
|
38
|
+
* - pendingScrollAction: Prevents overlapping scroll operations
|
|
39
|
+
* - isReady: Indicates when the system is fully ready for user interactions
|
|
40
|
+
* - initializationQueue: Stores user actions while system initializes
|
|
41
|
+
*
|
|
42
|
+
* Reliability Features:
|
|
43
|
+
* - Retry mechanisms with exponential backoff
|
|
44
|
+
* - Scroll verification with tolerance checking
|
|
45
|
+
* - Multiple container detection strategies
|
|
46
|
+
* - Immediate user feedback during delays
|
|
47
|
+
* - Proper memory management and cleanup
|
|
48
|
+
*/
|
|
49
|
+
declare class LazyLoadHandler {
|
|
50
|
+
static rootId: string;
|
|
51
|
+
static targetId: string;
|
|
52
|
+
static initialized: boolean;
|
|
53
|
+
static paused: boolean;
|
|
54
|
+
static observer: IntersectionObserver | null;
|
|
55
|
+
private static scrollState;
|
|
56
|
+
private static pendingScrollAction;
|
|
57
|
+
private static retryTimeouts;
|
|
58
|
+
static resetPending: boolean;
|
|
59
|
+
private static initTimer;
|
|
60
|
+
static logLifecycleEvent(event: TelemetryEvent, description: string, elapsedTime?: number): void;
|
|
61
|
+
private static resetEventListener;
|
|
62
|
+
static isReady: boolean;
|
|
63
|
+
private static initializationQueue;
|
|
64
|
+
static hasMoreHistoryAvailable: boolean;
|
|
65
|
+
static setHasMoreHistoryAvailable(value: boolean): void;
|
|
66
|
+
/**
|
|
67
|
+
* Direct reset method that can be called externally
|
|
68
|
+
* This bypasses the broadcast system for more reliable resets
|
|
69
|
+
*/
|
|
70
|
+
static directReset(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Main initialization method for the lazy loading system
|
|
73
|
+
*
|
|
74
|
+
* This method sets up the IntersectionObserver that watches for when the trigger
|
|
75
|
+
* element becomes visible, indicating the user has scrolled near the top.
|
|
76
|
+
*
|
|
77
|
+
* Process:
|
|
78
|
+
* 1. Prevents duplicate initialization
|
|
79
|
+
* 2. Sets up intersection callback to handle visibility events
|
|
80
|
+
* 3. Finds appropriate scroll container with fallback strategies
|
|
81
|
+
* 4. Configures observer with optimal settings for chat history loading
|
|
82
|
+
* 5. Waits for target element availability with exponential backoff
|
|
83
|
+
*
|
|
84
|
+
* Observer Configuration:
|
|
85
|
+
* - root: The scrollable container (webchat or fallback)
|
|
86
|
+
* - rootMargin: 20px top margin to trigger slightly before element is visible
|
|
87
|
+
* - threshold: 0.05 (5%) visibility required to trigger
|
|
88
|
+
*/
|
|
89
|
+
static useLazyLoadObserver(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Waits for the target element to be available in the DOM
|
|
92
|
+
*
|
|
93
|
+
* Uses exponential backoff to retry finding the target element.
|
|
94
|
+
* This is necessary because the target element may not be immediately
|
|
95
|
+
* available when the observer is being set up.
|
|
96
|
+
*
|
|
97
|
+
* @param callback - Function to call when target element is found
|
|
98
|
+
* @param maxAttempts - Maximum number of retry attempts (default: 10)
|
|
99
|
+
* @param attempt - Current attempt number (default: 1)
|
|
100
|
+
*/
|
|
101
|
+
private static waitForTargetElement;
|
|
102
|
+
/**
|
|
103
|
+
* Handles immediate scroll requests when system might not be ready
|
|
104
|
+
*
|
|
105
|
+
* This is crucial for handling minimize/maximize scenarios where users
|
|
106
|
+
* immediately scroll up before the observer is fully initialized.
|
|
107
|
+
*
|
|
108
|
+
* Two-Path Strategy:
|
|
109
|
+
* 1. If ready: Execute normal lazy load trigger
|
|
110
|
+
* 2. If not ready: Provide immediate feedback + queue action for later
|
|
111
|
+
*
|
|
112
|
+
* This ensures users always get visual feedback even during initialization delays.
|
|
113
|
+
*/
|
|
114
|
+
static handleImmediateScrollRequest(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Provides immediate scroll feedback during initialization
|
|
117
|
+
*
|
|
118
|
+
* When the system isn't ready but user scrolls up, this provides
|
|
119
|
+
* immediate visual feedback (20px scroll) so the user knows their
|
|
120
|
+
* action was recognized.
|
|
121
|
+
*/
|
|
122
|
+
private static executeImmediateScrollFeedback;
|
|
123
|
+
/**
|
|
124
|
+
* Forces faster initialization attempts
|
|
125
|
+
*
|
|
126
|
+
* When user interacts before system is ready, this tries to
|
|
127
|
+
* speed up the initialization process.
|
|
128
|
+
*/
|
|
129
|
+
private static expediteInitialization;
|
|
130
|
+
/**
|
|
131
|
+
* Processes all queued actions once system is ready
|
|
132
|
+
*
|
|
133
|
+
* During initialization, user actions are queued. Once the system
|
|
134
|
+
* is ready, this processes all queued actions with small delays
|
|
135
|
+
* between them to prevent overwhelming the system.
|
|
136
|
+
*/
|
|
137
|
+
private static processInitializationQueue;
|
|
138
|
+
/**
|
|
139
|
+
* Manually checks if target element is visible and triggers lazy load
|
|
140
|
+
*
|
|
141
|
+
* This is used when the intersection observer might not be ready yet
|
|
142
|
+
* but we need to check if the trigger element is already in view.
|
|
143
|
+
*
|
|
144
|
+
* Uses getBoundingClientRect() to calculate visibility manually.
|
|
145
|
+
*/
|
|
146
|
+
static checkVisibilityAndTrigger(): void;
|
|
147
|
+
/**
|
|
148
|
+
* Main lazy load trigger handler
|
|
149
|
+
*
|
|
150
|
+
* This is the core method that executes when the trigger element becomes visible.
|
|
151
|
+
* It coordinates the entire lazy loading process:
|
|
152
|
+
*
|
|
153
|
+
* 1. Sets flags to prevent concurrent operations
|
|
154
|
+
* 2. Dispatches event to fetch more chat history
|
|
155
|
+
* 3. Waits for content to load
|
|
156
|
+
* 4. Executes scroll adjustment to maintain user position
|
|
157
|
+
*
|
|
158
|
+
* Timing: Uses 300ms delay to allow content loading before scroll adjustment
|
|
159
|
+
*/
|
|
160
|
+
private static handleLazyLoadTrigger;
|
|
161
|
+
/**
|
|
162
|
+
* Executes reliable scroll with validation and retry logic
|
|
163
|
+
*
|
|
164
|
+
* This method implements a robust scroll system that:
|
|
165
|
+
* 1. Finds and validates the scroll container
|
|
166
|
+
* 2. Calculates target scroll position (current + 35px)
|
|
167
|
+
* 3. Sets up scroll state for tracking and retries
|
|
168
|
+
* 4. Initiates the scroll attempt process
|
|
169
|
+
*
|
|
170
|
+
* If no suitable container is found, schedules a retry.
|
|
171
|
+
*/
|
|
172
|
+
private static executeReliableScroll;
|
|
173
|
+
/**
|
|
174
|
+
* Attempts to perform scroll with verification and retry logic
|
|
175
|
+
*
|
|
176
|
+
* This method implements a sophisticated scroll system:
|
|
177
|
+
*
|
|
178
|
+
* 1. Uses requestAnimationFrame for smooth execution
|
|
179
|
+
* 2. Performs the scroll operation
|
|
180
|
+
* 3. Verifies scroll actually occurred (5px tolerance)
|
|
181
|
+
* 4. Retries with exponential backoff if failed
|
|
182
|
+
* 5. Continues operation after max attempts
|
|
183
|
+
*
|
|
184
|
+
* The two-frame approach ensures scroll is applied and then verified
|
|
185
|
+
* after the browser has had time to process the scroll change.
|
|
186
|
+
*/
|
|
187
|
+
private static attemptScroll;
|
|
188
|
+
/**
|
|
189
|
+
* Finishes scroll action and prepares for next cycle
|
|
190
|
+
*
|
|
191
|
+
* Cleans up scroll state and schedules the reset cycle.
|
|
192
|
+
* Uses delays to allow content stabilization before re-enabling
|
|
193
|
+
* the intersection observer for the next lazy load cycle.
|
|
194
|
+
*/
|
|
195
|
+
private static finishScrollAction;
|
|
196
|
+
/**
|
|
197
|
+
* Schedules retry for failed scroll operations
|
|
198
|
+
*
|
|
199
|
+
* Used when scroll container is not available or scrollable.
|
|
200
|
+
* Provides a longer delay to allow container to become ready.
|
|
201
|
+
*/
|
|
202
|
+
private static scheduleScrollRetry;
|
|
203
|
+
/**
|
|
204
|
+
* Schedules observer reset for next lazy load cycle
|
|
205
|
+
*
|
|
206
|
+
* After a lazy load operation completes, the observer needs to be reset
|
|
207
|
+
* to detect the next time the user scrolls to the top.
|
|
208
|
+
*/
|
|
209
|
+
private static scheduleReset;
|
|
210
|
+
/**
|
|
211
|
+
* Finds the appropriate scroll container using multiple strategies
|
|
212
|
+
*
|
|
213
|
+
* Container Detection Priority:
|
|
214
|
+
* 1. Primary: Specific webchat scroll container (.webchat__basic-transcript__scrollable)
|
|
215
|
+
* 2. Secondary: Widget root container (ms_lcw_webchat_root)
|
|
216
|
+
* 3. Tertiary: Any scrollable parent of the target element
|
|
217
|
+
* 4. Fallback: Best available container (even if not scrollable)
|
|
218
|
+
*
|
|
219
|
+
* Returns both the container and whether it's actually scrollable.
|
|
220
|
+
*
|
|
221
|
+
* @returns Object containing container element and scrollability status
|
|
222
|
+
*/
|
|
223
|
+
static findScrollContainer(): {
|
|
224
|
+
container: HTMLElement | null;
|
|
225
|
+
isScrollable: boolean;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Determines if an element is scrollable
|
|
229
|
+
*
|
|
230
|
+
* Checks two conditions:
|
|
231
|
+
* 1. Content overflow: scrollHeight > clientHeight (content extends beyond visible area)
|
|
232
|
+
* 2. CSS overflow settings: overflow/overflowY set to 'auto' or 'scroll'
|
|
233
|
+
*
|
|
234
|
+
* @param element - The element to check for scrollability
|
|
235
|
+
* @returns true if element is scrollable, false otherwise
|
|
236
|
+
*/
|
|
237
|
+
private static isElementScrollable;
|
|
238
|
+
/**
|
|
239
|
+
* Traverses up the DOM tree to find a scrollable parent element
|
|
240
|
+
*
|
|
241
|
+
* Starting from the given element, walks up the parent chain
|
|
242
|
+
* until it finds a scrollable element or reaches document.body.
|
|
243
|
+
*
|
|
244
|
+
* @param element - Starting element to search from
|
|
245
|
+
* @returns Scrollable parent element or null if none found
|
|
246
|
+
*/
|
|
247
|
+
private static findScrollableParent;
|
|
248
|
+
/**
|
|
249
|
+
* Legacy method - redirects to new reliable scroll system
|
|
250
|
+
*
|
|
251
|
+
* Maintained for backwards compatibility with existing code
|
|
252
|
+
* that might call this method directly.
|
|
253
|
+
*/
|
|
254
|
+
static moveScrollDown(): void;
|
|
255
|
+
/**
|
|
256
|
+
* Legacy scroll adjustment method with enhancements
|
|
257
|
+
*
|
|
258
|
+
* Enhanced version of the original adjustScroll method:
|
|
259
|
+
* - Validates container scrollability before attempting scroll
|
|
260
|
+
* - Uses requestAnimationFrame for smooth execution
|
|
261
|
+
* - Provides logging for debugging
|
|
262
|
+
*
|
|
263
|
+
* @param scrollContainer - The container element to scroll
|
|
264
|
+
*/
|
|
265
|
+
static adjustScroll(scrollContainer: HTMLElement): void;
|
|
266
|
+
/**
|
|
267
|
+
* Handles the NO_MORE_HISTORY_AVAILABLE event
|
|
268
|
+
*
|
|
269
|
+
* Called when there's no more chat history to load.
|
|
270
|
+
* Disables further lazy loading attempts and cleans up the observer.
|
|
271
|
+
* Also removes the trigger element from the DOM to prevent further triggering.
|
|
272
|
+
*/
|
|
273
|
+
static handleNoMoreHistoryAvailable(): void;
|
|
274
|
+
/**
|
|
275
|
+
* Resets the lazy load system for the next cycle
|
|
276
|
+
*
|
|
277
|
+
* This method prepares the system for the next lazy load operation:
|
|
278
|
+
* 1. Cleans up current state
|
|
279
|
+
* 2. Resets all flags and queues
|
|
280
|
+
* 3. Reinitializes the observer with faster timing
|
|
281
|
+
*
|
|
282
|
+
* Called after each lazy load cycle completes.
|
|
283
|
+
*/
|
|
284
|
+
static reset(): void;
|
|
285
|
+
/**
|
|
286
|
+
* Comprehensive cleanup method
|
|
287
|
+
*
|
|
288
|
+
* Performs complete cleanup of all lazy load resources:
|
|
289
|
+
* - Clears all pending timeouts to prevent memory leaks
|
|
290
|
+
* - Removes intersection observer and event listeners
|
|
291
|
+
* - Resets all state variables to initial values
|
|
292
|
+
* - Clears action queue
|
|
293
|
+
*
|
|
294
|
+
* Critical for preventing memory leaks and ensuring clean component unmounting.
|
|
295
|
+
*/
|
|
296
|
+
static unmount(): void;
|
|
297
|
+
/**
|
|
298
|
+
* Complete cleanup including broadcast event listener
|
|
299
|
+
*
|
|
300
|
+
* This method is used for final cleanup when the LazyLoadActivity component is being destroyed completely.
|
|
301
|
+
* It includes unsubscribing from broadcast events and performing complete cleanup.
|
|
302
|
+
* This is different from reset() which prepares the system for a new chat session.
|
|
303
|
+
*/
|
|
304
|
+
static destroy(): void;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* LazyLoadActivity React Component
|
|
308
|
+
*
|
|
309
|
+
* This component serves as the React wrapper for the LazyLoadHandler system.
|
|
310
|
+
* It renders the trigger element and manages the component lifecycle.
|
|
311
|
+
*
|
|
312
|
+
* Component Lifecycle:
|
|
313
|
+
* 1. Mount: Initializes lazy load observer and sets up scroll listener
|
|
314
|
+
* 2. Active: Monitors user scroll behavior and responds to interactions
|
|
315
|
+
* 3. Unmount: Cleans up all resources and prevents memory leaks
|
|
316
|
+
*
|
|
317
|
+
* Key Features:
|
|
318
|
+
* - Automatic initialization on mount
|
|
319
|
+
* - Scroll event monitoring for immediate responsiveness
|
|
320
|
+
* - Proper cleanup on unmount
|
|
321
|
+
* - Handles minimize/maximize scenarios
|
|
322
|
+
* - Reactive rendering based on history availability
|
|
323
|
+
*/
|
|
324
|
+
declare const LazyLoadActivity: (props?: Partial<ILiveChatWidgetProps>) => React.JSX.Element | null;
|
|
325
|
+
export default LazyLoadActivity;
|
|
326
|
+
export { LazyLoadHandler };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ILiveChatWidgetProps } from "../../../../../livechatwidget/interfaces/ILiveChatWidgetProps";
|
|
3
|
+
declare const LoadInlineBannerActivity: ({ webChatContainerProps, persistentChatHistory, id }: {
|
|
4
|
+
webChatContainerProps?: ILiveChatWidgetProps["webChatContainerProps"];
|
|
5
|
+
persistentChatHistory?: ILiveChatWidgetProps["persistentChatHistoryProps"];
|
|
6
|
+
id: string;
|
|
7
|
+
}) => React.JSX.Element;
|
|
8
|
+
export default LoadInlineBannerActivity;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4-main.4478bbf",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@azure/core-tracing": "^1.2.0",
|
|
88
88
|
"@microsoft/applicationinsights-web": "^3.3.6",
|
|
89
|
-
"@microsoft/omnichannel-chat-components": "1.1.
|
|
90
|
-
"@microsoft/omnichannel-chat-sdk": "^1.11.
|
|
89
|
+
"@microsoft/omnichannel-chat-components": "1.1.16",
|
|
90
|
+
"@microsoft/omnichannel-chat-sdk": "^1.11.7-main.3418dc3",
|
|
91
91
|
"@opentelemetry/api": "^1.9.0",
|
|
92
92
|
"abort-controller": "^3",
|
|
93
93
|
"abort-controller-es5": "^2.0.1",
|