@microsoft/omnichannel-chat-widget 1.8.4-main.cbab5fc → 1.8.4-main.cc63f01
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 +13 -3
- package/lib/cjs/common/Constants.js +5 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +235 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +14 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +6 -1
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +7 -7
- package/lib/cjs/common/telemetry/sanitizeSasInPayload.js +82 -0
- package/lib/cjs/common/utils/xssUtils.js +23 -51
- package/lib/cjs/common/utils.js +106 -17
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +8 -1
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -1
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +36 -13
- package/lib/cjs/components/errorboundary/ErrorBoundary.js +2 -1
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +9 -1
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +3 -2
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +98 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +6 -0
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +186 -1
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -5
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +15 -3
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -4
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +68 -2
- package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +2 -1
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +157 -34
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +5 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/utils/citationA11y.js +195 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +13 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -167
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +203 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -13
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +81 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +29 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +52 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/controller/componentController.js +13 -1
- package/lib/cjs/plugins/newMessageEventHandler.js +20 -3
- package/lib/esm/common/Constants.js +5 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +236 -10
- package/lib/esm/common/telemetry/TelemetryConstants.js +14 -0
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +7 -7
- package/lib/esm/common/telemetry/sanitizeSasInPayload.js +75 -0
- package/lib/esm/common/utils/xssUtils.js +23 -51
- package/lib/esm/common/utils.js +99 -14
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +8 -1
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -1
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +37 -14
- package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -2
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +9 -1
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/esm/components/livechatwidget/common/createAdapter.js +3 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +98 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +6 -0
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +186 -1
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
- package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +125 -6
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +16 -4
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -4
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +69 -3
- package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +2 -1
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -2
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +158 -35
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +5 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/utils/citationA11y.js +188 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +13 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -171
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +24 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +195 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -13
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +74 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +29 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +52 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/controller/componentController.js +13 -1
- package/lib/esm/plugins/newMessageEventHandler.js +20 -3
- package/lib/types/common/Constants.d.ts +4 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +29 -0
- package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +14 -2
- package/lib/types/common/telemetry/sanitizeSasInPayload.d.ts +24 -0
- package/lib/types/common/utils/xssUtils.d.ts +5 -21
- package/lib/types/common/utils.d.ts +12 -2
- package/lib/types/components/errorboundary/ErrorBoundary.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +9 -2
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
- package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/common/utils/citationA11y.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +14 -38
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.d.ts +18 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.d.ts +12 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.d.ts +7 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +17 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +37 -9
|
@@ -60,8 +60,10 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
60
60
|
// Temporary disable flag
|
|
61
61
|
// The intersection observer instance
|
|
62
62
|
|
|
63
|
-
// Scroll
|
|
64
|
-
//
|
|
63
|
+
// Scroll anchoring state (height-delta approach)
|
|
64
|
+
// scrollHeight before content loads
|
|
65
|
+
// scrollTop before content loads
|
|
66
|
+
// Tracks if the first batch has loaded
|
|
65
67
|
// Prevents concurrent scroll operations (public for event handlers)
|
|
66
68
|
|
|
67
69
|
// Timeout and queue management
|
|
@@ -105,6 +107,7 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
105
107
|
key: "directReset",
|
|
106
108
|
value: function directReset() {
|
|
107
109
|
LazyLoadHandler.resetPending = true;
|
|
110
|
+
LazyLoadHandler.initialLoadComplete = false; // New session — next batch is an initial load
|
|
108
111
|
LazyLoadHandler.setHasMoreHistoryAvailable(true);
|
|
109
112
|
LazyLoadHandler.unmount();
|
|
110
113
|
}
|
|
@@ -408,16 +411,15 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
408
411
|
|
|
409
412
|
/**
|
|
410
413
|
* Main lazy load trigger handler
|
|
411
|
-
*
|
|
414
|
+
*
|
|
412
415
|
* This is the core method that executes when the trigger element becomes visible.
|
|
413
416
|
* It coordinates the entire lazy loading process:
|
|
414
|
-
*
|
|
417
|
+
*
|
|
415
418
|
* 1. Sets flags to prevent concurrent operations
|
|
416
|
-
* 2.
|
|
417
|
-
* 3.
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
* Timing: Uses 300ms delay to allow content loading before scroll adjustment
|
|
419
|
+
* 2. Captures scroll state BEFORE content loads (for height-delta anchoring)
|
|
420
|
+
* 3. Dispatches event to fetch more chat history
|
|
421
|
+
*
|
|
422
|
+
* Scroll anchoring is triggered by HISTORY_BATCH_LOADED event (not a blind timeout).
|
|
421
423
|
*/
|
|
422
424
|
}, {
|
|
423
425
|
key: "handleLazyLoadTrigger",
|
|
@@ -431,138 +433,60 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
431
433
|
LazyLoadHandler.pendingScrollAction = true; // Block new scroll actions
|
|
432
434
|
LazyLoadHandler.paused = true; // Pause intersection observer
|
|
433
435
|
|
|
436
|
+
// Capture scroll geometry BEFORE new content loads — used for height-delta anchoring
|
|
437
|
+
const {
|
|
438
|
+
container,
|
|
439
|
+
isScrollable
|
|
440
|
+
} = LazyLoadHandler.findScrollContainer();
|
|
441
|
+
if (container && isScrollable) {
|
|
442
|
+
LazyLoadHandler.preLoadScrollHeight = container.scrollHeight;
|
|
443
|
+
LazyLoadHandler.preLoadScrollTop = container.scrollTop;
|
|
444
|
+
}
|
|
445
|
+
LazyLoadHandler.logLifecycleEvent(_TelemetryConstants.TelemetryEvent.LCWLazyLoadTriggerFired, "Lazy load trigger fired — fetching history");
|
|
446
|
+
|
|
434
447
|
// Dispatch custom event to trigger chat history fetching
|
|
435
|
-
// This event is handled by other parts of the chat system
|
|
436
448
|
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.FETCH_PERSISTENT_CHAT_HISTORY);
|
|
437
|
-
|
|
438
|
-
// Wait for content to load before performing scroll adjustment
|
|
439
|
-
// 200ms provides good balance between responsiveness and content loading
|
|
440
|
-
const timeoutId = window.setTimeout(() => {
|
|
441
|
-
LazyLoadHandler.retryTimeouts.delete(timeoutId);
|
|
442
|
-
LazyLoadHandler.executeReliableScroll();
|
|
443
|
-
}, 200); // Reduced from 300ms to 200ms for faster response
|
|
444
|
-
LazyLoadHandler.retryTimeouts.add(timeoutId);
|
|
445
449
|
}
|
|
446
450
|
|
|
447
451
|
/**
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* 4. Initiates the scroll attempt process
|
|
455
|
-
*
|
|
456
|
-
* If no suitable container is found, schedules a retry.
|
|
452
|
+
* Applies height-delta scroll anchoring after new history content is prepended.
|
|
453
|
+
*
|
|
454
|
+
* When content is added above the viewport, the browser keeps scrollTop constant
|
|
455
|
+
* but the content shifts down — making the viewport drift upward.
|
|
456
|
+
* Fix: scrollTop = savedScrollTop + (newScrollHeight - savedScrollHeight)
|
|
457
|
+
* This keeps the user looking at the same content they had before.
|
|
457
458
|
*/
|
|
458
459
|
}, {
|
|
459
|
-
key: "
|
|
460
|
-
value: function
|
|
461
|
-
// Guard: Don't execute scroll if no more history is available
|
|
462
|
-
if (!LazyLoadHandler.hasMoreHistoryAvailable) {
|
|
463
|
-
LazyLoadHandler.finishScrollAction();
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// Find container using multiple fallback strategies
|
|
460
|
+
key: "applyScrollAnchor",
|
|
461
|
+
value: function applyScrollAnchor() {
|
|
468
462
|
const {
|
|
469
463
|
container,
|
|
470
464
|
isScrollable
|
|
471
465
|
} = LazyLoadHandler.findScrollContainer();
|
|
472
466
|
if (!container || !isScrollable) {
|
|
473
|
-
LazyLoadHandler.scheduleScrollRetry();
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// Calculate scroll positions
|
|
478
|
-
const initialScrollTop = container.scrollTop;
|
|
479
|
-
const targetScrollTop = initialScrollTop + 35; // 35px down to maintain position
|
|
480
|
-
|
|
481
|
-
// Set up scroll state for tracking and retries
|
|
482
|
-
LazyLoadHandler.scrollState = {
|
|
483
|
-
container,
|
|
484
|
-
initialScrollTop,
|
|
485
|
-
targetScrollTop,
|
|
486
|
-
attemptCount: 0,
|
|
487
|
-
maxAttempts: 5 // Allow up to 5 retry attempts
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
// Begin the scroll attempt process
|
|
491
|
-
LazyLoadHandler.attemptScroll();
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Attempts to perform scroll with verification and retry logic
|
|
496
|
-
*
|
|
497
|
-
* This method implements a sophisticated scroll system:
|
|
498
|
-
*
|
|
499
|
-
* 1. Uses requestAnimationFrame for smooth execution
|
|
500
|
-
* 2. Performs the scroll operation
|
|
501
|
-
* 3. Verifies scroll actually occurred (5px tolerance)
|
|
502
|
-
* 4. Retries with exponential backoff if failed
|
|
503
|
-
* 5. Continues operation after max attempts
|
|
504
|
-
*
|
|
505
|
-
* The two-frame approach ensures scroll is applied and then verified
|
|
506
|
-
* after the browser has had time to process the scroll change.
|
|
507
|
-
*/
|
|
508
|
-
}, {
|
|
509
|
-
key: "attemptScroll",
|
|
510
|
-
value: function attemptScroll() {
|
|
511
|
-
// Guard: Don't attempt scroll if no more history is available
|
|
512
|
-
if (!LazyLoadHandler.hasMoreHistoryAvailable) {
|
|
513
467
|
LazyLoadHandler.finishScrollAction();
|
|
514
468
|
return;
|
|
515
469
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
470
|
+
const newScrollHeight = container.scrollHeight;
|
|
471
|
+
const heightDelta = newScrollHeight - LazyLoadHandler.preLoadScrollHeight;
|
|
472
|
+
if (heightDelta > 0) {
|
|
473
|
+
container.scrollTop = LazyLoadHandler.preLoadScrollTop + heightDelta;
|
|
519
474
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
// Perform scroll using requestAnimationFrame for smooth execution
|
|
531
|
-
// Frame 1: Apply the scroll
|
|
532
|
-
requestAnimationFrame(() => {
|
|
533
|
-
// Double-check history availability before applying scroll
|
|
534
|
-
if (!LazyLoadHandler.hasMoreHistoryAvailable) {
|
|
535
|
-
LazyLoadHandler.finishScrollAction();
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
if (container) {
|
|
539
|
-
container.scrollTop = targetScrollTop;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
// Frame 2: Verify scroll occurred after browser has processed the change
|
|
543
|
-
requestAnimationFrame(() => {
|
|
544
|
-
// Triple-check history availability before verification
|
|
545
|
-
if (!LazyLoadHandler.hasMoreHistoryAvailable) {
|
|
546
|
-
LazyLoadHandler.finishScrollAction();
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
const actualScrollTop = container ? container.scrollTop : 0;
|
|
550
|
-
const scrollSucceeded = Math.abs(actualScrollTop - targetScrollTop) < 5; // 5px tolerance for success
|
|
551
|
-
|
|
552
|
-
if (scrollSucceeded) {
|
|
553
|
-
LazyLoadHandler.finishScrollAction();
|
|
554
|
-
} else if (attemptCount < maxAttempts) {
|
|
555
|
-
// Retry with exponential backoff (100ms * attempt number)
|
|
556
|
-
const timeoutId = window.setTimeout(() => {
|
|
557
|
-
LazyLoadHandler.retryTimeouts.delete(timeoutId);
|
|
558
|
-
LazyLoadHandler.attemptScroll();
|
|
559
|
-
}, 100 * attemptCount); // Exponential backoff
|
|
560
|
-
LazyLoadHandler.retryTimeouts.add(timeoutId);
|
|
561
|
-
} else {
|
|
562
|
-
LazyLoadHandler.finishScrollAction();
|
|
475
|
+
try {
|
|
476
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
477
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWLazyLoadScrollAnchorApplied,
|
|
478
|
+
Description: "Scroll anchor applied after history batch",
|
|
479
|
+
CustomProperties: {
|
|
480
|
+
heightDelta,
|
|
481
|
+
preLoadScrollHeight: LazyLoadHandler.preLoadScrollHeight,
|
|
482
|
+
newScrollHeight,
|
|
483
|
+
newScrollTop: container.scrollTop
|
|
563
484
|
}
|
|
564
485
|
});
|
|
565
|
-
}
|
|
486
|
+
} catch {
|
|
487
|
+
// Silent fail — don't break scroll anchoring for telemetry issues
|
|
488
|
+
}
|
|
489
|
+
LazyLoadHandler.finishScrollAction();
|
|
566
490
|
}
|
|
567
491
|
|
|
568
492
|
/**
|
|
@@ -576,7 +500,6 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
576
500
|
key: "finishScrollAction",
|
|
577
501
|
value: function finishScrollAction() {
|
|
578
502
|
// Clean up scroll tracking state
|
|
579
|
-
LazyLoadHandler.scrollState = null;
|
|
580
503
|
LazyLoadHandler.pendingScrollAction = false;
|
|
581
504
|
|
|
582
505
|
// Schedule unpause and reset with delay for content stabilization
|
|
@@ -588,33 +511,9 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
588
511
|
LazyLoadHandler.retryTimeouts.add(timeoutId);
|
|
589
512
|
}
|
|
590
513
|
|
|
591
|
-
/**
|
|
592
|
-
* Schedules retry for failed scroll operations
|
|
593
|
-
*
|
|
594
|
-
* Used when scroll container is not available or scrollable.
|
|
595
|
-
* Provides a longer delay to allow container to become ready.
|
|
596
|
-
*/
|
|
597
|
-
}, {
|
|
598
|
-
key: "scheduleScrollRetry",
|
|
599
|
-
value: function scheduleScrollRetry() {
|
|
600
|
-
// Don't schedule retry if no more history is available
|
|
601
|
-
if (!LazyLoadHandler.hasMoreHistoryAvailable) {
|
|
602
|
-
LazyLoadHandler.finishScrollAction();
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
const timeoutId = window.setTimeout(() => {
|
|
606
|
-
LazyLoadHandler.retryTimeouts.delete(timeoutId);
|
|
607
|
-
// Only retry if we're still in a pending scroll action state and have more history
|
|
608
|
-
if (LazyLoadHandler.pendingScrollAction && LazyLoadHandler.hasMoreHistoryAvailable) {
|
|
609
|
-
LazyLoadHandler.executeReliableScroll();
|
|
610
|
-
}
|
|
611
|
-
}, 1000); // 1 second delay for container readiness
|
|
612
|
-
LazyLoadHandler.retryTimeouts.add(timeoutId);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
514
|
/**
|
|
616
515
|
* Schedules observer reset for next lazy load cycle
|
|
617
|
-
*
|
|
516
|
+
*
|
|
618
517
|
* After a lazy load operation completes, the observer needs to be reset
|
|
619
518
|
* to detect the next time the user scrolls to the top.
|
|
620
519
|
*/
|
|
@@ -732,7 +631,7 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
732
631
|
}, {
|
|
733
632
|
key: "moveScrollDown",
|
|
734
633
|
value: function moveScrollDown() {
|
|
735
|
-
LazyLoadHandler.
|
|
634
|
+
LazyLoadHandler.applyScrollAnchor();
|
|
736
635
|
}
|
|
737
636
|
|
|
738
637
|
/**
|
|
@@ -772,6 +671,9 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
772
671
|
}, {
|
|
773
672
|
key: "handleNoMoreHistoryAvailable",
|
|
774
673
|
value: function handleNoMoreHistoryAvailable() {
|
|
674
|
+
if (!LazyLoadHandler.initialLoadComplete) {
|
|
675
|
+
LazyLoadHandler.initialLoadComplete = true;
|
|
676
|
+
}
|
|
775
677
|
LazyLoadHandler.setHasMoreHistoryAvailable(false);
|
|
776
678
|
LazyLoadHandler.paused = true;
|
|
777
679
|
LazyLoadHandler.pendingScrollAction = false; // Reset this to prevent stuck states
|
|
@@ -789,9 +691,6 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
789
691
|
LazyLoadHandler.observer.disconnect();
|
|
790
692
|
LazyLoadHandler.observer = null;
|
|
791
693
|
}
|
|
792
|
-
|
|
793
|
-
// Clear scroll state
|
|
794
|
-
LazyLoadHandler.scrollState = null;
|
|
795
694
|
}
|
|
796
695
|
|
|
797
696
|
/**
|
|
@@ -813,6 +712,8 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
813
712
|
LazyLoadHandler.setHasMoreHistoryAvailable(true); // Reset history availability flag
|
|
814
713
|
LazyLoadHandler.initializationQueue = []; // Clear action queue
|
|
815
714
|
LazyLoadHandler.resetPending = false; // Clear pending reset flag
|
|
715
|
+
// Note: initialLoadComplete is NOT reset here — it persists across observer cycles.
|
|
716
|
+
// It's only reset on new chat sessions (directReset / PersistentConversationReset).
|
|
816
717
|
|
|
817
718
|
// Reinitialize with faster timing for better responsiveness
|
|
818
719
|
const timeoutId = window.setTimeout(() => {
|
|
@@ -852,8 +753,9 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
852
753
|
LazyLoadHandler.initialized = false;
|
|
853
754
|
LazyLoadHandler.paused = false;
|
|
854
755
|
LazyLoadHandler.pendingScrollAction = false;
|
|
855
|
-
LazyLoadHandler.scrollState = null;
|
|
856
756
|
LazyLoadHandler.isReady = false;
|
|
757
|
+
LazyLoadHandler.preLoadScrollHeight = 0;
|
|
758
|
+
LazyLoadHandler.preLoadScrollTop = 0;
|
|
857
759
|
LazyLoadHandler.initializationQueue = [];
|
|
858
760
|
// Note: Don't reset resetPending here as it needs to persist across unmount/mount cycles
|
|
859
761
|
}
|
|
@@ -903,7 +805,9 @@ _defineProperty(LazyLoadHandler, "targetId", "lazy-load-trigger-element");
|
|
|
903
805
|
_defineProperty(LazyLoadHandler, "initialized", false);
|
|
904
806
|
_defineProperty(LazyLoadHandler, "paused", false);
|
|
905
807
|
_defineProperty(LazyLoadHandler, "observer", null);
|
|
906
|
-
_defineProperty(LazyLoadHandler, "
|
|
808
|
+
_defineProperty(LazyLoadHandler, "preLoadScrollHeight", 0);
|
|
809
|
+
_defineProperty(LazyLoadHandler, "preLoadScrollTop", 0);
|
|
810
|
+
_defineProperty(LazyLoadHandler, "initialLoadComplete", false);
|
|
907
811
|
_defineProperty(LazyLoadHandler, "pendingScrollAction", false);
|
|
908
812
|
_defineProperty(LazyLoadHandler, "retryTimeouts", new Set());
|
|
909
813
|
_defineProperty(LazyLoadHandler, "resetPending", false);
|
|
@@ -911,6 +815,7 @@ _defineProperty(LazyLoadHandler, "initTimer", (0, _utils.createTimer)());
|
|
|
911
815
|
_defineProperty(LazyLoadHandler, "resetEventListener", _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.PersistentConversationReset).subscribe(() => {
|
|
912
816
|
LazyLoadHandler.logLifecycleEvent(_TelemetryConstants.TelemetryEvent.LCWLazyLoadReset, "LazyLoad reset triggered");
|
|
913
817
|
LazyLoadHandler.resetPending = true;
|
|
818
|
+
LazyLoadHandler.initialLoadComplete = false; // New session — next batch is an initial load
|
|
914
819
|
LazyLoadHandler.setHasMoreHistoryAvailable(true); // Reset this immediately so activityMiddleware doesn't block rendering
|
|
915
820
|
LazyLoadHandler.unmount(); // Clean up current state immediately
|
|
916
821
|
}));
|
|
@@ -934,19 +839,11 @@ const LazyLoadActivity = props => {
|
|
|
934
839
|
setHasMoreHistory(false);
|
|
935
840
|
};
|
|
936
841
|
|
|
937
|
-
// Event listener for HISTORY_LOAD_ERROR
|
|
842
|
+
// Event listener for HISTORY_LOAD_ERROR — dismiss banner on any error
|
|
938
843
|
const handleHistoryLoadError = () => {
|
|
939
|
-
|
|
940
|
-
LazyLoadHandler.
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
// Re-enable after a delay to allow retry on next scroll
|
|
944
|
-
// Note: This timeout is intentionally not tracked as it's scoped to the component lifecycle
|
|
945
|
-
window.setTimeout(() => {
|
|
946
|
-
LazyLoadHandler.paused = false;
|
|
947
|
-
}, 2000); // 2 second delay before allowing retry
|
|
948
|
-
|
|
949
|
-
LazyLoadHandler.logLifecycleEvent(_TelemetryConstants.TelemetryEvent.LCWLazyLoadHistoryError, "History load error - will retry on next scroll");
|
|
844
|
+
LazyLoadHandler.logLifecycleEvent(_TelemetryConstants.TelemetryEvent.LCWLazyLoadHistoryError, `History load error - dismissing banner. initialLoadComplete: ${LazyLoadHandler.initialLoadComplete}`);
|
|
845
|
+
LazyLoadHandler.handleNoMoreHistoryAvailable();
|
|
846
|
+
setHasMoreHistory(false);
|
|
950
847
|
};
|
|
951
848
|
|
|
952
849
|
// Event listener for PersistentConversationReset to sync React state
|
|
@@ -957,6 +854,97 @@ const LazyLoadActivity = props => {
|
|
|
957
854
|
setHasMoreHistory(true);
|
|
958
855
|
};
|
|
959
856
|
|
|
857
|
+
// Event listener for HISTORY_BATCH_LOADED — applies scroll anchoring after batch is processed
|
|
858
|
+
const handleBatchLoaded = () => {
|
|
859
|
+
LazyLoadHandler.logLifecycleEvent(_TelemetryConstants.TelemetryEvent.LCWLazyLoadBatchReceived, `Batch received — initialLoadComplete: ${LazyLoadHandler.initialLoadComplete}`);
|
|
860
|
+
if (!LazyLoadHandler.initialLoadComplete) {
|
|
861
|
+
// Initial load: use the same height-delta scroll anchoring as subsequent loads.
|
|
862
|
+
// This keeps the user at their current position while history is prepended above.
|
|
863
|
+
LazyLoadHandler.initialLoadComplete = true;
|
|
864
|
+
LazyLoadHandler.pendingScrollAction = false;
|
|
865
|
+
try {
|
|
866
|
+
const {
|
|
867
|
+
container
|
|
868
|
+
} = LazyLoadHandler.findScrollContainer();
|
|
869
|
+
if (container) {
|
|
870
|
+
const savedScrollTop = container.scrollTop;
|
|
871
|
+
const savedScrollHeight = container.scrollHeight;
|
|
872
|
+
|
|
873
|
+
// Freeze viewport while React renders new content above
|
|
874
|
+
container.style.overflow = "hidden";
|
|
875
|
+
let framesRemaining = 6;
|
|
876
|
+
const anchorScroll = () => {
|
|
877
|
+
const newScrollHeight = container.scrollHeight;
|
|
878
|
+
const heightDelta = newScrollHeight - savedScrollHeight;
|
|
879
|
+
if (heightDelta > 0) {
|
|
880
|
+
container.scrollTop = savedScrollTop + heightDelta;
|
|
881
|
+
}
|
|
882
|
+
framesRemaining--;
|
|
883
|
+
if (framesRemaining > 0) {
|
|
884
|
+
requestAnimationFrame(anchorScroll);
|
|
885
|
+
} else {
|
|
886
|
+
container.style.overflow = "";
|
|
887
|
+
LazyLoadHandler.paused = false;
|
|
888
|
+
LazyLoadHandler.scheduleReset();
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
requestAnimationFrame(anchorScroll);
|
|
892
|
+
} else {
|
|
893
|
+
LazyLoadHandler.paused = false;
|
|
894
|
+
LazyLoadHandler.scheduleReset();
|
|
895
|
+
}
|
|
896
|
+
} catch {
|
|
897
|
+
LazyLoadHandler.paused = false;
|
|
898
|
+
LazyLoadHandler.scheduleReset();
|
|
899
|
+
}
|
|
900
|
+
LazyLoadHandler.logLifecycleEvent(_TelemetryConstants.TelemetryEvent.LCWLazyLoadInitialLoadComplete, "Initial history load complete — scroll anchored to current position");
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
// Pagination: apply height-delta scroll anchoring repeatedly across frames.
|
|
904
|
+
//
|
|
905
|
+
// react-scroll-to-bottom uses useEffect + rAF to auto-scroll to bottom when new content
|
|
906
|
+
// arrives. This fires at unpredictable timing relative to our callbacks, so a single
|
|
907
|
+
// scrollTop assignment gets overridden intermittently.
|
|
908
|
+
//
|
|
909
|
+
// Fix: re-apply the correct scrollTop across several animation frames. After a few frames,
|
|
910
|
+
// react-scroll-to-bottom detects the user is NOT at the bottom (sticky=false) and stops
|
|
911
|
+
// auto-scrolling. We also temporarily freeze overflow to prevent visible flicker.
|
|
912
|
+
try {
|
|
913
|
+
const {
|
|
914
|
+
container
|
|
915
|
+
} = LazyLoadHandler.findScrollContainer();
|
|
916
|
+
if (container) {
|
|
917
|
+
// Re-capture scrollTop — user may have scrolled during the API fetch
|
|
918
|
+
const savedScrollTop = container.scrollTop;
|
|
919
|
+
const savedScrollHeight = LazyLoadHandler.preLoadScrollHeight;
|
|
920
|
+
|
|
921
|
+
// Freeze viewport to prevent visible flicker between competing scroll positions
|
|
922
|
+
container.style.overflow = "hidden";
|
|
923
|
+
let framesRemaining = 6; // ~100ms at 60fps — enough for react-scroll-to-bottom to settle
|
|
924
|
+
const anchorScroll = () => {
|
|
925
|
+
const newScrollHeight = container.scrollHeight;
|
|
926
|
+
const heightDelta = newScrollHeight - savedScrollHeight;
|
|
927
|
+
if (heightDelta > 0) {
|
|
928
|
+
container.scrollTop = savedScrollTop + heightDelta;
|
|
929
|
+
}
|
|
930
|
+
framesRemaining--;
|
|
931
|
+
if (framesRemaining > 0) {
|
|
932
|
+
requestAnimationFrame(anchorScroll);
|
|
933
|
+
} else {
|
|
934
|
+
// All frames applied — restore overflow and finish
|
|
935
|
+
container.style.overflow = "";
|
|
936
|
+
LazyLoadHandler.finishScrollAction();
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
requestAnimationFrame(anchorScroll);
|
|
940
|
+
} else {
|
|
941
|
+
LazyLoadHandler.finishScrollAction();
|
|
942
|
+
}
|
|
943
|
+
} catch {
|
|
944
|
+
LazyLoadHandler.finishScrollAction();
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
|
|
960
948
|
// Add secure event listener for no more history signal
|
|
961
949
|
const eventBus = _SecureEventBus.default.getInstance();
|
|
962
950
|
const unsubscribeNoMoreHistory = eventBus.subscribe(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE, handleNoMoreHistory);
|
|
@@ -964,6 +952,9 @@ const LazyLoadActivity = props => {
|
|
|
964
952
|
// Add event listener for history load errors
|
|
965
953
|
const unsubscribeHistoryError = eventBus.subscribe(_ChatWidgetEvents.default.HISTORY_LOAD_ERROR, handleHistoryLoadError);
|
|
966
954
|
|
|
955
|
+
// Add event listener for history batch loaded
|
|
956
|
+
const unsubscribeBatchLoaded = eventBus.subscribe(_ChatWidgetEvents.default.HISTORY_BATCH_LOADED, handleBatchLoaded);
|
|
957
|
+
|
|
967
958
|
// Add event listener for persistent conversation reset
|
|
968
959
|
const resetSubscription = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.PersistentConversationReset).subscribe(handlePersistentConversationReset);
|
|
969
960
|
|
|
@@ -981,6 +972,7 @@ const LazyLoadActivity = props => {
|
|
|
981
972
|
return () => {
|
|
982
973
|
unsubscribeNoMoreHistory();
|
|
983
974
|
unsubscribeHistoryError();
|
|
975
|
+
unsubscribeBatchLoaded();
|
|
984
976
|
resetSubscription.unsubscribe();
|
|
985
977
|
};
|
|
986
978
|
}
|
|
@@ -1034,6 +1026,7 @@ const LazyLoadActivity = props => {
|
|
|
1034
1026
|
// Remove event listeners
|
|
1035
1027
|
unsubscribeNoMoreHistory();
|
|
1036
1028
|
unsubscribeHistoryError();
|
|
1029
|
+
unsubscribeBatchLoaded();
|
|
1037
1030
|
resetSubscription.unsubscribe();
|
|
1038
1031
|
if (container) {
|
|
1039
1032
|
container.removeEventListener("scroll", handleScroll);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.createActivityMiddleware = void 0;
|
|
6
|
+
exports.resetActivityMiddlewareCache = exports.createActivityMiddleware = void 0;
|
|
7
7
|
var _LazyLoadActivity = _interopRequireWildcard(require("./activities/LazyLoadActivity"));
|
|
8
8
|
var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _Constants = require("../../../../../common/Constants");
|
|
@@ -32,9 +32,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
32
32
|
|
|
33
33
|
const loggedSystemMessages = new Array();
|
|
34
34
|
let lastRenderedAt = 0; // Track last rendered receivedAt timestamp for deduplication
|
|
35
|
+
// Cache original (pre-render) text per activity ID to prevent exponential <br> growth.
|
|
36
|
+
// BotFramework WebChat can mutate card.activity.text between renders (e.g. on minimize/open),
|
|
37
|
+
// so we always render from the original markdown source, not the possibly-HTML-mutated text.
|
|
38
|
+
const originalSystemMessageTexts = new Map();
|
|
35
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
40
|
const handleSystemMessage = (next, args, card, renderMarkdown, systemMessageStyleProps) => {
|
|
37
|
-
var _card$activity, _card$activity$channe, _card$activity$channe2, _card$activity2, _card$activity2$chann, _card$activity3, _card$activity3$chann, _card$activity3$chann2, _card$activity4, _card$activity4$chann, _card$activity5, _card$activity5$chann, _card$nextVisibleActi, _card$nextVisibleActi2, _card$activity6, _card$activity6$chann, _card$activity7, _card$nextVisibleActi3, _card$activity8;
|
|
41
|
+
var _card$activity, _card$activity$channe, _card$activity$channe2, _card$activity2, _card$activity2$chann, _card$activity3, _card$activity3$chann, _card$activity3$chann2, _card$activity4, _card$activity4$chann, _card$activity5, _card$activity5$chann, _card$nextVisibleActi, _card$nextVisibleActi2, _card$activity6, _card$activity6$chann, _card$activity7, _card$nextVisibleActi3, _card$activity8, _card$activity9, _card$activity9$chann;
|
|
38
42
|
const systemMessageStyles = {
|
|
39
43
|
..._defaultSystemMessageStyles.defaultSystemMessageStyles,
|
|
40
44
|
...systemMessageStyleProps
|
|
@@ -56,7 +60,14 @@ const handleSystemMessage = (next, args, card, renderMarkdown, systemMessageStyl
|
|
|
56
60
|
if ((_card$activity5 = card.activity) !== null && _card$activity5 !== void 0 && (_card$activity5$chann = _card$activity5.channelData) !== null && _card$activity5$chann !== void 0 && _card$activity5$chann.clientmessageid && ((_card$nextVisibleActi = card.nextVisibleActivity) === null || _card$nextVisibleActi === void 0 ? void 0 : (_card$nextVisibleActi2 = _card$nextVisibleActi.channelData) === null || _card$nextVisibleActi2 === void 0 ? void 0 : _card$nextVisibleActi2.clientmessageid) === ((_card$activity6 = card.activity) === null || _card$activity6 === void 0 ? void 0 : (_card$activity6$chann = _card$activity6.channelData) === null || _card$activity6$chann === void 0 ? void 0 : _card$activity6$chann.clientmessageid) || (_card$activity7 = card.activity) !== null && _card$activity7 !== void 0 && _card$activity7.messageid && ((_card$nextVisibleActi3 = card.nextVisibleActivity) === null || _card$nextVisibleActi3 === void 0 ? void 0 : _card$nextVisibleActi3.messageid) === ((_card$activity8 = card.activity) === null || _card$activity8 === void 0 ? void 0 : _card$activity8.messageid)) {
|
|
57
61
|
return () => false;
|
|
58
62
|
}
|
|
59
|
-
card.activity.
|
|
63
|
+
const activityKey = card.activity.id || ((_card$activity9 = card.activity) === null || _card$activity9 === void 0 ? void 0 : (_card$activity9$chann = _card$activity9.channelData) === null || _card$activity9$chann === void 0 ? void 0 : _card$activity9$chann.clientmessageid);
|
|
64
|
+
if (activityKey && !originalSystemMessageTexts.has(activityKey)) {
|
|
65
|
+
originalSystemMessageTexts.set(activityKey, card.activity.text);
|
|
66
|
+
}
|
|
67
|
+
const sourceText = (activityKey && originalSystemMessageTexts.get(activityKey)) ?? card.activity.text;
|
|
68
|
+
// renderMarkdown sanitizes the HTML using DOMPurify with allowlist-based configuration
|
|
69
|
+
// See initWebChatComposer.ts for sanitization details
|
|
70
|
+
const renderedHtml = renderMarkdown(sourceText);
|
|
60
71
|
// eslint-disable-next-line react/display-name
|
|
61
72
|
return () => /*#__PURE__*/_react.default.createElement("div", {
|
|
62
73
|
key: card.activity.id,
|
|
@@ -64,7 +75,7 @@ const handleSystemMessage = (next, args, card, renderMarkdown, systemMessageStyl
|
|
|
64
75
|
"aria-hidden": "false",
|
|
65
76
|
className: _Constants.Constants.markDownSystemMessageClass,
|
|
66
77
|
dangerouslySetInnerHTML: {
|
|
67
|
-
__html:
|
|
78
|
+
__html: renderedHtml
|
|
68
79
|
}
|
|
69
80
|
});
|
|
70
81
|
};
|
|
@@ -97,12 +108,12 @@ const createActivityMiddleware = (renderMarkdown, systemMessageStyleProps, userM
|
|
|
97
108
|
return handleSystemMessage(next, args, card, renderMarkdown, systemMessageStyleProps);
|
|
98
109
|
}
|
|
99
110
|
if (isTagIncluded(card, _Constants.Constants.persistentChatHistoryMessagePullTriggerTag)) {
|
|
100
|
-
var _card$
|
|
111
|
+
var _card$activity10, _card$activity10$chan, _card$activity10$chan2;
|
|
101
112
|
// Safety check: if this is a new chat session and flag is false, auto-correct it
|
|
102
113
|
if (!_LazyLoadActivity.LazyLoadHandler.hasMoreHistoryAvailable) {
|
|
103
114
|
_LazyLoadActivity.LazyLoadHandler.setHasMoreHistoryAvailable(true);
|
|
104
115
|
}
|
|
105
|
-
const receivedAt = card === null || card === void 0 ? void 0 : (_card$
|
|
116
|
+
const receivedAt = card === null || card === void 0 ? void 0 : (_card$activity10 = card.activity) === null || _card$activity10 === void 0 ? void 0 : (_card$activity10$chan = _card$activity10.channelData) === null || _card$activity10$chan === void 0 ? void 0 : (_card$activity10$chan2 = _card$activity10$chan.webChat) === null || _card$activity10$chan2 === void 0 ? void 0 : _card$activity10$chan2.receivedAt;
|
|
106
117
|
if (receivedAt < lastRenderedAt) {
|
|
107
118
|
card.activity = null;
|
|
108
119
|
return () => false;
|
|
@@ -133,7 +144,7 @@ const createActivityMiddleware = (renderMarkdown, systemMessageStyleProps, userM
|
|
|
133
144
|
if (isTagIncluded(card, _Constants.Constants.conversationDividerTag)) {
|
|
134
145
|
const conversationDividerLabel = (localizedTexts === null || localizedTexts === void 0 ? void 0 : localizedTexts.CONVERSATION_DIVIDER_ARIA_LABEL) || _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.CONVERSATION_DIVIDER_ARIA_LABEL;
|
|
135
146
|
// Pass the computed localized text to the divider component
|
|
136
|
-
return /*#__PURE__*/_react.default.createElement(_ConversationDividerActivity.default, {
|
|
147
|
+
return () => /*#__PURE__*/_react.default.createElement(_ConversationDividerActivity.default, {
|
|
137
148
|
dividerActivityAriaLabel: conversationDividerLabel
|
|
138
149
|
});
|
|
139
150
|
}
|
|
@@ -157,4 +168,12 @@ const createActivityMiddleware = (renderMarkdown, systemMessageStyleProps, userM
|
|
|
157
168
|
}
|
|
158
169
|
return next(...args);
|
|
159
170
|
};
|
|
160
|
-
|
|
171
|
+
|
|
172
|
+
/** Clear module-level caches. Call on conversation end / chat close. */
|
|
173
|
+
exports.createActivityMiddleware = createActivityMiddleware;
|
|
174
|
+
const resetActivityMiddlewareCache = () => {
|
|
175
|
+
loggedSystemMessages.length = 0;
|
|
176
|
+
lastRenderedAt = 0;
|
|
177
|
+
originalSystemMessageTexts.clear();
|
|
178
|
+
};
|
|
179
|
+
exports.resetActivityMiddlewareCache = resetActivityMiddlewareCache;
|
|
@@ -7,6 +7,7 @@ exports.createAttachmentMiddleware = void 0;
|
|
|
7
7
|
var _Constants = require("../../../../../common/Constants");
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _FileAttachmentIconManager = require("../../../common/utils/FileAttachmentIconManager");
|
|
10
|
+
var _AdaptiveCardAccessibilityWrapper = _interopRequireDefault(require("./attachments/AdaptiveCardAccessibilityWrapper"));
|
|
10
11
|
var _Attachment = _interopRequireDefault(require("./attachments/Attachment"));
|
|
11
12
|
var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
|
|
12
13
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
@@ -120,7 +121,7 @@ const createAttachmentMiddleware = enableInlinePlaying => {
|
|
|
120
121
|
...((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : _state$domainStates$r3.attachmentAdaptiveCardStyles)
|
|
121
122
|
};
|
|
122
123
|
if (type === _Constants.WebChatMiddlewareConstants.adaptiveCard || _Constants.Constants.supportedAdaptiveCardContentTypes.indexOf(contentType) >= 0) {
|
|
123
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
124
|
+
return /*#__PURE__*/_react.default.createElement(_AdaptiveCardAccessibilityWrapper.default, {
|
|
124
125
|
id: attachmentId,
|
|
125
126
|
style: atttachmentAdaptiveCardStyles
|
|
126
127
|
}, next(...args));
|