1+ /* eslint-disable react/require-default-props */
2+
13import {
24 Composer as APIComposer ,
35 extractSendBoxMiddleware ,
@@ -9,7 +11,6 @@ import {
911 type SendBoxToolbarMiddleware
1012} from 'botframework-webchat-api' ;
1113import { DecoratorComposer , type DecoratorMiddleware } from 'botframework-webchat-api/decorator' ;
12- import { useRootDebugAPI } from 'botframework-webchat-api/hook' ;
1314import { type Polymiddleware } from 'botframework-webchat-api/middleware' ;
1415import { singleToArray } from 'botframework-webchat-core' ;
1516import classNames from 'classnames' ;
@@ -18,6 +19,7 @@ import PropTypes from 'prop-types';
1819import React , { memo , useCallback , useEffect , useMemo , useRef , useState , type ReactNode } from 'react' ;
1920import { Composer as SayComposer } from 'react-say' ;
2021
22+ import { StoreDebugAPIRegistry , type StoreDebugAPI } from 'botframework-webchat-core/internal' ;
2123import createDefaultAttachmentMiddleware from './Attachment/createMiddleware' ;
2224import BuiltInDecorator from './BuiltInDecorator' ;
2325import Dictation from './Dictation' ;
@@ -65,9 +67,9 @@ function styleSetToEmotionObjects(styleToEmotionObject, styleSet) {
6567}
6668
6769type ComposerCoreUIProps = {
68- // eslint-disable-next-line react/require-default-props
6970 readonly children ?: ReactNode | undefined ;
7071 readonly nonce : string | undefined ;
72+ readonly storeDebugAPI ?: StoreDebugAPI | undefined ;
7173} ;
7274
7375const ROOT_STYLE = {
@@ -84,9 +86,8 @@ const ROOT_STYLE = {
8486 }
8587} ;
8688
87- const ComposerCoreUI = memo ( ( { children, nonce } : ComposerCoreUIProps ) => {
89+ const ComposerCoreUI = memo ( ( { children, nonce, storeDebugAPI } : ComposerCoreUIProps ) => {
8890 const [ { internalLiveRegionFadeAfter } ] = useStyleOptions ( ) ;
89- const [ rootDebugAPI ] = useRootDebugAPI ( ) ;
9091 const rootClassName = useStyleToEmotionObject ( ) ( ROOT_STYLE ) + '' ;
9192 const rootRef = useRef < HTMLDivElement > ( null ) ;
9293 const trackException = useTrackException ( ) ;
@@ -110,15 +111,15 @@ const ComposerCoreUI = memo(({ children, nonce }: ComposerCoreUIProps) => {
110111 const { current } = rootRef ;
111112
112113 if ( current ) {
113- current [ 'webChat' ] = rootDebugAPI ;
114+ current [ 'webChat' ] = storeDebugAPI ;
114115
115116 return ( ) => delete current [ 'webChat' ] ;
116117 }
117118
118119 return ( ) => {
119120 // Intentionally left blank.
120121 } ;
121- } , [ rootDebugAPI ] ) ;
122+ } , [ storeDebugAPI ] ) ;
122123
123124 return (
124125 < CSSCustomPropertiesContainer
@@ -158,6 +159,7 @@ type ComposerCoreProps = Readonly<{
158159 newLineOptions : { markdownRespectCRLF : boolean } ,
159160 linkOptions : { externalLinkAlt : string }
160161 ) => string ;
162+ storeDebugAPI ?: StoreDebugAPI | undefined ;
161163 styleSet ?: any ;
162164 suggestedActionsAccessKey ?: boolean | string ;
163165 webSpeechPonyfillFactory ?: WebSpeechPonyfillFactory ;
@@ -168,6 +170,7 @@ const ComposerCore = ({
168170 extraStyleSet,
169171 nonce,
170172 renderMarkdown,
173+ storeDebugAPI,
171174 styleSet,
172175 suggestedActionsAccessKey,
173176 webSpeechPonyfillFactory
@@ -309,7 +312,9 @@ const ComposerCore = ({
309312 return (
310313 < SayComposer ponyfill = { webSpeechPonyfill } >
311314 < WebChatUIContext . Provider value = { context } >
312- < ComposerCoreUI nonce = { nonce } > { children } </ ComposerCoreUI >
315+ < ComposerCoreUI nonce = { nonce } storeDebugAPI = { storeDebugAPI } >
316+ { children }
317+ </ ComposerCoreUI >
313318 </ WebChatUIContext . Provider >
314319 </ SayComposer >
315320 ) ;
@@ -458,6 +463,8 @@ const Composer = ({
458463 [ sendBoxToolbarMiddlewareFromProps , theme . sendBoxToolbarMiddleware ]
459464 ) ;
460465
466+ const storeDebugAPI = useMemo ( ( ) => StoreDebugAPIRegistry . get ( composerProps . store ) , [ composerProps . store ] ) ;
467+
461468 return (
462469 < APIComposer
463470 activityMiddleware = { patchedActivityMiddleware }
@@ -487,6 +494,7 @@ const Composer = ({
487494 extraStyleSet = { extraStyleSet }
488495 nonce = { nonce }
489496 renderMarkdown = { renderMarkdown }
497+ storeDebugAPI = { storeDebugAPI }
490498 styleSet = { styleSet }
491499 suggestedActionsAccessKey = { suggestedActionsAccessKey }
492500 webSpeechPonyfillFactory = { webSpeechPonyfillFactory }
0 commit comments