botframework-webchat-api 4.13.0 → 4.14.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/.eslintignore +1 -9
- package/.eslintrc.yml +43 -38
- package/lib/StyleOptions.d.ts +28 -3
- package/lib/StyleOptions.d.ts.map +1 -1
- package/lib/defaultStyleOptions.d.ts +4 -0
- package/lib/defaultStyleOptions.d.ts.map +1 -0
- package/lib/defaultStyleOptions.js +7 -3
- package/lib/external/PrecompiledGlobalize.js +24 -6
- package/lib/hooks/Composer.d.ts +71 -0
- package/lib/hooks/Composer.d.ts.map +1 -0
- package/lib/hooks/Composer.js +104 -88
- package/lib/hooks/index.d.ts +64 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/index.js +9 -1
- package/lib/hooks/internal/ErrorBox.js +2 -2
- package/lib/hooks/internal/Tracker.d.ts +4 -0
- package/lib/hooks/internal/Tracker.d.ts.map +1 -0
- package/lib/hooks/internal/WebChatAPIContext.d.ts +81 -0
- package/lib/hooks/internal/WebChatAPIContext.d.ts.map +1 -0
- package/lib/hooks/internal/WebChatAPIContext.js +2 -4
- package/lib/hooks/internal/useCreateActivityRendererInternal.d.ts +4 -0
- package/lib/hooks/internal/useCreateActivityRendererInternal.d.ts.map +1 -0
- package/lib/hooks/internal/useCreateActivityRendererInternal.js +1 -1
- package/lib/hooks/internal/useDebugDeps.js +2 -2
- package/lib/hooks/internal/useDownscaleImageToDataURL.js +1 -1
- package/lib/hooks/internal/useErrorBoxClass.js +1 -1
- package/lib/hooks/internal/useForceRender.js +2 -2
- package/lib/hooks/internal/useLocalizedStrings.js +1 -1
- package/lib/hooks/internal/useReadTelemetryDimensions.js +2 -2
- package/lib/hooks/internal/useTimePassed.js +2 -2
- package/lib/hooks/internal/useTracker.js +2 -2
- package/lib/hooks/middleware/UserlandBoundary.js +4 -4
- package/lib/hooks/middleware/applyMiddleware.js +6 -6
- package/lib/hooks/middleware/concatMiddleware.d.ts +6 -0
- package/lib/hooks/middleware/concatMiddleware.d.ts.map +1 -0
- package/lib/hooks/middleware/concatMiddleware.js +2 -2
- package/lib/hooks/middleware/createDefaultCardActionMiddleware.d.ts +3 -0
- package/lib/hooks/middleware/createDefaultCardActionMiddleware.d.ts.map +1 -0
- package/lib/hooks/middleware/createDefaultCardActionMiddleware.js +6 -8
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.d.ts +5 -0
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.d.ts.map +1 -0
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.js +1 -1
- package/lib/hooks/useActiveTyping.d.ts +6 -0
- package/lib/hooks/useActiveTyping.d.ts.map +1 -0
- package/lib/hooks/useActiveTyping.js +4 -4
- package/lib/hooks/useActivities.d.ts +3 -0
- package/lib/hooks/useActivities.d.ts.map +1 -0
- package/lib/hooks/useActivities.js +1 -1
- package/lib/hooks/useAvatarForBot.d.ts +5 -0
- package/lib/hooks/useAvatarForBot.d.ts.map +1 -0
- package/lib/hooks/useAvatarForBot.js +2 -2
- package/lib/hooks/useAvatarForUser.d.ts +5 -0
- package/lib/hooks/useAvatarForUser.d.ts.map +1 -0
- package/lib/hooks/useAvatarForUser.js +2 -2
- package/lib/hooks/useByteFormatter.d.ts +2 -0
- package/lib/hooks/useByteFormatter.d.ts.map +1 -0
- package/lib/hooks/useByteFormatter.js +2 -2
- package/lib/hooks/useConnectivityStatus.d.ts +2 -0
- package/lib/hooks/useConnectivityStatus.d.ts.map +1 -0
- package/lib/hooks/useConnectivityStatus.js +1 -1
- package/lib/hooks/useCreateActivityRenderer.d.ts +3 -0
- package/lib/hooks/useCreateActivityRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateActivityRenderer.js +1 -2
- package/lib/hooks/useCreateActivityStatusRenderer.d.ts +9 -0
- package/lib/hooks/useCreateActivityStatusRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateActivityStatusRenderer.js +6 -4
- package/lib/hooks/useCreateAvatarRenderer.d.ts +4 -0
- package/lib/hooks/useCreateAvatarRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateAvatarRenderer.js +2 -2
- package/lib/hooks/useCreateScrollToEndButtonRenderer.d.ts +3 -0
- package/lib/hooks/useCreateScrollToEndButtonRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateScrollToEndButtonRenderer.js +15 -0
- package/lib/hooks/useDateFormatter.d.ts +2 -0
- package/lib/hooks/useDateFormatter.d.ts.map +1 -0
- package/lib/hooks/useDateFormatter.js +2 -2
- package/lib/hooks/useDebouncedNotifications.d.ts +13 -0
- package/lib/hooks/useDebouncedNotifications.d.ts.map +1 -0
- package/lib/hooks/useDebouncedNotifications.js +6 -6
- package/lib/hooks/useDictateInterims.d.ts +2 -0
- package/lib/hooks/useDictateInterims.d.ts.map +1 -0
- package/lib/hooks/useDictateInterims.js +1 -1
- package/lib/hooks/useDictateState.d.ts +2 -0
- package/lib/hooks/useDictateState.d.ts.map +1 -0
- package/lib/hooks/useDictateState.js +1 -1
- package/lib/hooks/useDirection.d.ts +2 -0
- package/lib/hooks/useDirection.d.ts.map +1 -0
- package/lib/hooks/useDirection.js +2 -2
- package/lib/hooks/useDisabled.d.ts +2 -0
- package/lib/hooks/useDisabled.d.ts.map +1 -0
- package/lib/hooks/useDisabled.js +1 -1
- package/lib/hooks/useDismissNotification.d.ts +2 -0
- package/lib/hooks/useDismissNotification.d.ts.map +1 -0
- package/lib/hooks/useDismissNotification.js +1 -1
- package/lib/hooks/useEmitTypingIndicator.d.ts +2 -0
- package/lib/hooks/useEmitTypingIndicator.d.ts.map +1 -0
- package/lib/hooks/useEmitTypingIndicator.js +1 -1
- package/lib/hooks/useGetSendTimeoutForActivity.d.ts +5 -0
- package/lib/hooks/useGetSendTimeoutForActivity.d.ts.map +1 -0
- package/lib/hooks/useGetSendTimeoutForActivity.js +2 -2
- package/lib/hooks/useGrammars.d.ts +2 -0
- package/lib/hooks/useGrammars.d.ts.map +1 -0
- package/lib/hooks/useGrammars.js +1 -1
- package/lib/hooks/useGroupActivities.d.ts +8 -0
- package/lib/hooks/useGroupActivities.d.ts.map +1 -0
- package/lib/hooks/useGroupActivities.js +1 -1
- package/lib/hooks/useGroupTimestamp.d.ts +2 -0
- package/lib/hooks/useGroupTimestamp.d.ts.map +1 -0
- package/lib/hooks/useGroupTimestamp.js +2 -2
- package/lib/hooks/useLanguage.d.ts +2 -0
- package/lib/hooks/useLanguage.d.ts.map +1 -0
- package/lib/hooks/useLanguage.js +1 -1
- package/lib/hooks/useLastTypingAt.d.ts +5 -0
- package/lib/hooks/useLastTypingAt.d.ts.map +1 -0
- package/lib/hooks/useLastTypingAt.js +2 -1
- package/lib/hooks/useLocalize.d.ts +3 -0
- package/lib/hooks/useLocalize.d.ts.map +1 -0
- package/lib/hooks/useLocalize.js +5 -2
- package/lib/hooks/useLocalizeDate.d.ts +3 -0
- package/lib/hooks/useLocalizeDate.d.ts.map +1 -0
- package/lib/hooks/useLocalizeDate.js +3 -2
- package/lib/hooks/useLocalizer.d.ts +13 -0
- package/lib/hooks/useLocalizer.d.ts.map +1 -0
- package/lib/hooks/useLocalizer.js +10 -6
- package/lib/hooks/useMarkActivityAsSpoken.d.ts +3 -0
- package/lib/hooks/useMarkActivityAsSpoken.d.ts.map +1 -0
- package/lib/hooks/useMarkActivityAsSpoken.js +1 -1
- package/lib/hooks/useNotifications.d.ts +3 -0
- package/lib/hooks/useNotifications.d.ts.map +1 -0
- package/lib/hooks/useNotifications.js +1 -1
- package/lib/hooks/usePerformCardAction.d.ts +3 -0
- package/lib/hooks/usePerformCardAction.d.ts.map +1 -0
- package/lib/hooks/usePerformCardAction.js +1 -1
- package/lib/hooks/usePostActivity.d.ts +4 -0
- package/lib/hooks/usePostActivity.d.ts.map +1 -0
- package/lib/hooks/usePostActivity.js +1 -1
- package/lib/hooks/useReferenceGrammarID.d.ts +2 -0
- package/lib/hooks/useReferenceGrammarID.d.ts.map +1 -0
- package/lib/hooks/useReferenceGrammarID.js +1 -1
- package/lib/hooks/useRelativeTimeFormatter.d.ts +2 -0
- package/lib/hooks/useRelativeTimeFormatter.d.ts.map +1 -0
- package/lib/hooks/useRelativeTimeFormatter.js +2 -2
- package/lib/hooks/useRenderActivity.js +2 -1
- package/lib/hooks/useRenderActivityStatus.js +2 -1
- package/lib/hooks/useRenderAttachment.js +1 -1
- package/lib/hooks/useRenderAvatar.js +2 -1
- package/lib/hooks/useRenderToast.d.ts +3 -0
- package/lib/hooks/useRenderToast.d.ts.map +1 -0
- package/lib/hooks/useRenderToast.js +1 -1
- package/lib/hooks/useRenderTypingIndicator.d.ts +3 -0
- package/lib/hooks/useRenderTypingIndicator.d.ts.map +1 -0
- package/lib/hooks/useRenderTypingIndicator.js +1 -1
- package/lib/hooks/useSendBoxValue.d.ts +2 -0
- package/lib/hooks/useSendBoxValue.d.ts.map +1 -0
- package/lib/hooks/useSendBoxValue.js +1 -1
- package/lib/hooks/useSendEvent.d.ts +2 -0
- package/lib/hooks/useSendEvent.d.ts.map +1 -0
- package/lib/hooks/useSendEvent.js +1 -1
- package/lib/hooks/useSendFiles.d.ts +2 -0
- package/lib/hooks/useSendFiles.d.ts.map +1 -0
- package/lib/hooks/useSendFiles.js +1 -1
- package/lib/hooks/useSendMessage.d.ts +4 -0
- package/lib/hooks/useSendMessage.d.ts.map +1 -0
- package/lib/hooks/useSendMessage.js +1 -1
- package/lib/hooks/useSendMessageBack.d.ts +2 -0
- package/lib/hooks/useSendMessageBack.d.ts.map +1 -0
- package/lib/hooks/useSendMessageBack.js +1 -1
- package/lib/hooks/useSendPostBack.d.ts +2 -0
- package/lib/hooks/useSendPostBack.d.ts.map +1 -0
- package/lib/hooks/useSendPostBack.js +1 -1
- package/lib/hooks/useSendTimeoutForActivity.d.ts +4 -0
- package/lib/hooks/useSendTimeoutForActivity.d.ts.map +1 -0
- package/lib/hooks/useSendTimeoutForActivity.js +2 -1
- package/lib/hooks/useSendTypingIndicator.d.ts +2 -0
- package/lib/hooks/useSendTypingIndicator.d.ts.map +1 -0
- package/lib/hooks/useSendTypingIndicator.js +1 -1
- package/lib/hooks/useSetNotification.d.ts +3 -0
- package/lib/hooks/useSetNotification.d.ts.map +1 -0
- package/lib/hooks/useSetNotification.js +1 -1
- package/lib/hooks/useShouldSpeakIncomingActivity.d.ts +2 -0
- package/lib/hooks/useShouldSpeakIncomingActivity.d.ts.map +1 -0
- package/lib/hooks/useShouldSpeakIncomingActivity.js +1 -1
- package/lib/hooks/useStartDictate.d.ts +2 -0
- package/lib/hooks/useStartDictate.d.ts.map +1 -0
- package/lib/hooks/useStartDictate.js +1 -1
- package/lib/hooks/useStopDictate.d.ts +2 -0
- package/lib/hooks/useStopDictate.d.ts.map +1 -0
- package/lib/hooks/useStopDictate.js +1 -1
- package/lib/hooks/useStyleOptions.d.ts +3 -0
- package/lib/hooks/useStyleOptions.d.ts.map +1 -0
- package/lib/hooks/useStyleOptions.js +1 -1
- package/lib/hooks/useSubmitSendBox.d.ts +4 -0
- package/lib/hooks/useSubmitSendBox.d.ts.map +1 -0
- package/lib/hooks/useSubmitSendBox.js +1 -1
- package/lib/hooks/useSuggestedActions.d.ts +6 -0
- package/lib/hooks/useSuggestedActions.d.ts.map +1 -0
- package/lib/hooks/useSuggestedActions.js +1 -1
- package/lib/hooks/useTimeoutForSend.d.ts +3 -0
- package/lib/hooks/useTimeoutForSend.d.ts.map +1 -0
- package/lib/hooks/useTimeoutForSend.js +2 -2
- package/lib/hooks/useTrackDimension.d.ts +2 -0
- package/lib/hooks/useTrackDimension.d.ts.map +1 -0
- package/lib/hooks/useTrackDimension.js +1 -1
- package/lib/hooks/useTrackEvent.d.ts +10 -0
- package/lib/hooks/useTrackEvent.d.ts.map +1 -0
- package/lib/hooks/useTrackEvent.js +1 -1
- package/lib/hooks/useTrackException.d.ts +2 -0
- package/lib/hooks/useTrackException.d.ts.map +1 -0
- package/lib/hooks/useTrackException.js +2 -2
- package/lib/hooks/useTrackTiming.d.ts +2 -0
- package/lib/hooks/useTrackTiming.d.ts.map +1 -0
- package/lib/hooks/useTrackTiming.js +1 -1
- package/lib/hooks/useUserID.d.ts +2 -0
- package/lib/hooks/useUserID.d.ts.map +1 -0
- package/lib/hooks/useUserID.js +1 -1
- package/lib/hooks/useUsername.d.ts +2 -0
- package/lib/hooks/useUsername.d.ts.map +1 -0
- package/lib/hooks/useUsername.js +1 -1
- package/lib/hooks/useVoiceSelector.d.ts +2 -0
- package/lib/hooks/useVoiceSelector.d.ts.map +1 -0
- package/lib/hooks/useVoiceSelector.js +1 -1
- package/lib/hooks/utils/ErrorBoundary.js +3 -3
- package/lib/hooks/utils/observableToPromise.d.ts +3 -0
- package/lib/hooks/utils/observableToPromise.d.ts.map +1 -0
- package/lib/hooks/utils/observableToPromise.js +1 -1
- package/lib/index.d.ts +20 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/localization/Localize.d.ts +10 -0
- package/lib/localization/Localize.d.ts.map +1 -0
- package/lib/localization/Localize.js +7 -7
- package/lib/localization/ar-SA.json +1 -0
- package/lib/localization/bg-BG.json +1 -0
- package/lib/localization/ca-ES.json +1 -0
- package/lib/localization/cs-CZ.json +1 -0
- package/lib/localization/da-DK.json +1 -0
- package/lib/localization/de-DE.json +1 -0
- package/lib/localization/el-GR.json +1 -0
- package/lib/localization/en-US.json +1 -0
- package/lib/localization/es-ES.json +1 -0
- package/lib/localization/et-EE.json +1 -0
- package/lib/localization/eu-ES.json +1 -0
- package/lib/localization/fi-FI.json +1 -0
- package/lib/localization/fr-FR.json +1 -0
- package/lib/localization/getAllLocalizedStrings.d.ts +6 -0
- package/lib/localization/getAllLocalizedStrings.d.ts.map +1 -0
- package/lib/localization/getAllLocalizedStrings.js +1 -1
- package/lib/localization/getLocaleString.d.ts +2 -0
- package/lib/localization/getLocaleString.d.ts.map +1 -0
- package/lib/localization/getLocaleString.js +3 -3
- package/lib/localization/getRTLList.d.ts +2 -0
- package/lib/localization/getRTLList.d.ts.map +1 -0
- package/lib/localization/getRTLList.js +1 -1
- package/lib/localization/gl-ES.json +1 -0
- package/lib/localization/he-IL.json +1 -0
- package/lib/localization/hi-IN.json +1 -0
- package/lib/localization/hr-HR.json +1 -0
- package/lib/localization/hu-HU.json +1 -0
- package/lib/localization/id-ID.json +1 -0
- package/lib/localization/it-IT.json +1 -0
- package/lib/localization/ja-JP.json +1 -0
- package/lib/localization/kk-KZ.json +1 -0
- package/lib/localization/ko-KR.json +1 -0
- package/lib/localization/lt-LT.json +1 -0
- package/lib/localization/lv-LV.json +1 -0
- package/lib/localization/mergeLocalizedStrings.d.ts +7 -0
- package/lib/localization/mergeLocalizedStrings.d.ts.map +1 -0
- package/lib/localization/mergeLocalizedStrings.js +4 -4
- package/lib/localization/ms-MY.json +1 -0
- package/lib/localization/nb-NO.json +1 -0
- package/lib/localization/nl-NL.json +1 -0
- package/lib/localization/pl-PL.json +1 -0
- package/lib/localization/pt-BR.json +1 -0
- package/lib/localization/pt-PT.json +1 -0
- package/lib/localization/ro-RO.json +1 -0
- package/lib/localization/ru-RU.json +1 -0
- package/lib/localization/sk-SK.json +1 -0
- package/lib/localization/sl-SI.json +1 -0
- package/lib/localization/sr-Cyrl-CS.json +1 -0
- package/lib/localization/sr-Latn-CS.json +1 -0
- package/lib/localization/sv-SE.json +1 -0
- package/lib/localization/th-TH.json +1 -0
- package/lib/localization/tr-TR.json +1 -0
- package/lib/localization/uk-UA.json +1 -0
- package/lib/localization/vi-VN.json +1 -0
- package/lib/localization/yue.json +1 -0
- package/lib/localization/zh-CN.json +1 -0
- package/lib/localization/zh-HK.json +1 -0
- package/lib/localization/zh-TW.json +1 -0
- package/lib/normalizeStyleOptions.d.ts +3 -0
- package/lib/normalizeStyleOptions.d.ts.map +1 -0
- package/lib/normalizeStyleOptions.js +40 -5
- package/lib/tsconfig.json +3 -1
- package/lib/types/ActivityMiddleware.d.ts +25 -0
- package/lib/types/ActivityMiddleware.d.ts.map +1 -0
- package/lib/types/ActivityMiddleware.js +2 -0
- package/lib/types/ActivityStatusMiddleware.d.ts +18 -0
- package/lib/types/ActivityStatusMiddleware.d.ts.map +1 -0
- package/lib/types/ActivityStatusMiddleware.js +2 -0
- package/lib/types/AttachmentForScreenReaderMiddleware.d.ts +14 -0
- package/lib/types/AttachmentForScreenReaderMiddleware.d.ts.map +1 -0
- package/lib/types/AttachmentForScreenReaderMiddleware.js +2 -0
- package/lib/types/AttachmentMiddleware.d.ts +12 -0
- package/lib/types/AttachmentMiddleware.d.ts.map +1 -0
- package/lib/types/AttachmentMiddleware.js +2 -0
- package/lib/types/AvatarMiddleware.d.ts +15 -0
- package/lib/types/AvatarMiddleware.d.ts.map +1 -0
- package/lib/types/AvatarMiddleware.js +2 -0
- package/lib/types/CardActionMiddleware.d.ts +17 -0
- package/lib/types/CardActionMiddleware.d.ts.map +1 -0
- package/lib/types/CardActionMiddleware.js +2 -0
- package/lib/types/ComponentMiddleware.d.ts +31 -0
- package/lib/types/ComponentMiddleware.d.ts.map +1 -0
- package/lib/types/ComponentMiddleware.js +2 -0
- package/lib/types/FunctionMiddleware.d.ts +6 -0
- package/lib/types/FunctionMiddleware.d.ts.map +1 -0
- package/lib/types/FunctionMiddleware.js +2 -0
- package/lib/types/GroupActivitiesMiddleware.d.ts +22 -0
- package/lib/types/GroupActivitiesMiddleware.d.ts.map +1 -0
- package/lib/types/GroupActivitiesMiddleware.js +2 -0
- package/lib/types/LocalizedStrings.d.ts +5 -0
- package/lib/types/LocalizedStrings.d.ts.map +1 -0
- package/lib/types/LocalizedStrings.js +2 -0
- package/lib/types/Notification.d.ts +10 -0
- package/lib/types/Notification.d.ts.map +1 -0
- package/lib/types/Notification.js +2 -0
- package/lib/types/PrecompiledGlobalize.d.ts +13 -0
- package/lib/types/PrecompiledGlobalize.d.ts.map +1 -0
- package/lib/types/PrecompiledGlobalize.js +2 -0
- package/lib/types/ScrollToEndButtonMiddleware.d.ts +30 -0
- package/lib/types/ScrollToEndButtonMiddleware.d.ts.map +1 -0
- package/lib/types/ScrollToEndButtonMiddleware.js +2 -0
- package/lib/types/SendState.d.ts +3 -0
- package/lib/types/SendState.d.ts.map +1 -0
- package/lib/types/SendState.js +2 -0
- package/lib/types/TelemetryMeasurementEvent.d.ts +31 -0
- package/lib/types/TelemetryMeasurementEvent.d.ts.map +1 -0
- package/lib/types/TelemetryMeasurementEvent.js +2 -0
- package/lib/types/ToastMiddleware.d.ts +11 -0
- package/lib/types/ToastMiddleware.d.ts.map +1 -0
- package/lib/types/ToastMiddleware.js +2 -0
- package/lib/types/Typing.d.ts +8 -0
- package/lib/types/Typing.d.ts.map +1 -0
- package/lib/types/Typing.js +2 -0
- package/lib/types/TypingIndicatorMiddleware.d.ts +17 -0
- package/lib/types/TypingIndicatorMiddleware.d.ts.map +1 -0
- package/lib/types/TypingIndicatorMiddleware.js +2 -0
- package/lib/types/WebSpeechPonyfill.d.ts +18 -0
- package/lib/types/WebSpeechPonyfill.d.ts.map +1 -0
- package/lib/types/WebSpeechPonyfill.js +2 -0
- package/lib/types/WebSpeechPonyfillFactory.d.ts +6 -0
- package/lib/types/WebSpeechPonyfillFactory.d.ts.map +1 -0
- package/lib/types/WebSpeechPonyfillFactory.js +2 -0
- package/lib/utils/createCustomEvent.d.ts +4 -0
- package/lib/utils/createCustomEvent.d.ts.map +1 -0
- package/lib/utils/createCustomEvent.js +2 -2
- package/lib/utils/findMin.d.ts +7 -0
- package/lib/utils/findMin.d.ts.map +1 -0
- package/lib/utils/findMin.js +2 -2
- package/lib/utils/isObject.js +1 -1
- package/lib/utils/mapMap.d.ts +6 -0
- package/lib/utils/mapMap.d.ts.map +1 -0
- package/lib/utils/mapMap.js +2 -2
- package/lib/utils/normalizeLanguage.d.ts +2 -0
- package/lib/utils/normalizeLanguage.d.ts.map +1 -0
- package/lib/utils/normalizeLanguage.js +1 -1
- package/lib/utils/randomId.d.ts +2 -0
- package/lib/utils/randomId.d.ts.map +1 -0
- package/lib/utils/randomId.js +1 -1
- package/lib/utils/warnOnce.js +17 -0
- package/package.json +32 -31
- package/scripts/createPrecompiledGlobalize.mjs +44 -0
- package/src/StyleOptions.ts +39 -3
- package/src/defaultStyleOptions.ts +4 -2
- package/src/hooks/Composer.tsx +141 -99
- package/src/hooks/{index.js → index.ts} +2 -0
- package/src/hooks/internal/WebChatAPIContext.ts +68 -3
- package/src/hooks/internal/{useCreateActivityRendererInternal.js → useCreateActivityRendererInternal.ts} +6 -2
- package/src/hooks/middleware/applyMiddleware.js +2 -3
- package/src/hooks/middleware/concatMiddleware.spec.js +4 -6
- package/src/hooks/middleware/{concatMiddleware.js → concatMiddleware.ts} +7 -1
- package/src/hooks/middleware/{createDefaultCardActionMiddleware.js → createDefaultCardActionMiddleware.ts} +8 -4
- package/src/hooks/middleware/{createDefaultGroupActivitiesMiddleware.js → createDefaultGroupActivitiesMiddleware.ts} +20 -12
- package/src/hooks/{useActiveTyping.js → useActiveTyping.ts} +13 -9
- package/src/hooks/useActivities.ts +7 -0
- package/src/hooks/{useAvatarForBot.js → useAvatarForBot.ts} +1 -1
- package/src/hooks/{useAvatarForUser.js → useAvatarForUser.ts} +1 -1
- package/src/hooks/{useByteFormatter.js → useByteFormatter.ts} +1 -1
- package/src/hooks/{useConnectivityStatus.js → useConnectivityStatus.ts} +1 -1
- package/src/hooks/{useCreateActivityRenderer.js → useCreateActivityRenderer.ts} +2 -3
- package/src/hooks/{useCreateActivityStatusRenderer.js → useCreateActivityStatusRenderer.tsx} +24 -5
- package/src/hooks/{useCreateAvatarRenderer.js → useCreateAvatarRenderer.ts} +6 -3
- package/src/hooks/useCreateScrollToEndButtonRenderer.ts +6 -0
- package/src/hooks/{useDateFormatter.js → useDateFormatter.ts} +1 -1
- package/src/hooks/useDebouncedNotifications.spec.js +2 -0
- package/src/hooks/{useDebouncedNotifications.js → useDebouncedNotifications.ts} +10 -2
- package/src/hooks/{useDictateInterims.js → useDictateInterims.ts} +1 -1
- package/src/hooks/{useDictateState.js → useDictateState.ts} +1 -1
- package/src/hooks/{useDirection.js → useDirection.ts} +1 -1
- package/src/hooks/{useDisabled.js → useDisabled.ts} +1 -1
- package/src/hooks/{useDismissNotification.js → useDismissNotification.ts} +1 -1
- package/src/hooks/{useEmitTypingIndicator.js → useEmitTypingIndicator.ts} +1 -1
- package/src/hooks/{useGetSendTimeoutForActivity.js → useGetSendTimeoutForActivity.ts} +2 -1
- package/src/hooks/{useGrammars.js → useGrammars.ts} +1 -1
- package/src/hooks/useGroupActivities.ts +14 -0
- package/src/hooks/{useGroupTimestamp.js → useGroupTimestamp.ts} +1 -1
- package/src/hooks/{useLanguage.js → useLanguage.ts} +1 -1
- package/src/hooks/{useLastTypingAt.js → useLastTypingAt.ts} +2 -1
- package/src/hooks/{useLocalize.js → useLocalize.ts} +3 -1
- package/src/hooks/{useLocalizeDate.js → useLocalizeDate.ts} +2 -1
- package/src/hooks/{useLocalizer.js → useLocalizer.ts} +19 -6
- package/src/hooks/{useMarkActivityAsSpoken.js → useMarkActivityAsSpoken.ts} +2 -1
- package/src/hooks/{useNotifications.js → useNotifications.ts} +2 -1
- package/src/hooks/usePerformCardAction.ts +7 -0
- package/src/hooks/usePostActivity.ts +8 -0
- package/src/hooks/{useReferenceGrammarID.js → useReferenceGrammarID.ts} +1 -1
- package/src/hooks/{useRelativeTimeFormatter.js → useRelativeTimeFormatter.ts} +1 -1
- package/src/hooks/useRenderActivity.js +12 -10
- package/src/hooks/useRenderActivityStatus.js +1 -0
- package/src/hooks/useRenderAvatar.js +1 -0
- package/src/hooks/{useRenderToast.js → useRenderToast.ts} +2 -1
- package/src/hooks/useRenderTypingIndicator.ts +6 -0
- package/src/hooks/{useSendBoxValue.js → useSendBoxValue.ts} +1 -1
- package/src/hooks/{useSendEvent.js → useSendEvent.ts} +1 -1
- package/src/hooks/{useSendFiles.js → useSendFiles.ts} +1 -1
- package/src/hooks/useSendMessage.ts +9 -0
- package/src/hooks/{useSendMessageBack.js → useSendMessageBack.ts} +1 -1
- package/src/hooks/{useSendPostBack.js → useSendPostBack.ts} +1 -1
- package/src/hooks/{useSendTimeoutForActivity.js → useSendTimeoutForActivity.ts} +4 -1
- package/src/hooks/{useSendTypingIndicator.js → useSendTypingIndicator.ts} +1 -1
- package/src/hooks/useSetNotification.ts +6 -0
- package/src/hooks/{useShouldSpeakIncomingActivity.js → useShouldSpeakIncomingActivity.ts} +1 -1
- package/src/hooks/{useStartDictate.js → useStartDictate.ts} +1 -1
- package/src/hooks/{useStopDictate.js → useStopDictate.ts} +1 -1
- package/src/hooks/useStyleOptions.ts +6 -0
- package/src/hooks/{useSubmitSendBox.js → useSubmitSendBox.ts} +1 -1
- package/src/hooks/{useSuggestedActions.js → useSuggestedActions.ts} +5 -1
- package/src/hooks/useTimeoutForSend.ts +9 -0
- package/src/hooks/{useTrackDimension.js → useTrackDimension.ts} +1 -1
- package/src/hooks/{useTrackEvent.js → useTrackEvent.ts} +10 -2
- package/src/hooks/{useTrackException.js → useTrackException.ts} +1 -1
- package/src/hooks/{useTrackTiming.js → useTrackTiming.ts} +4 -1
- package/src/hooks/{useUserID.js → useUserID.ts} +1 -1
- package/src/hooks/{useUsername.js → useUsername.ts} +1 -1
- package/src/hooks/{useVoiceSelector.js → useVoiceSelector.ts} +4 -1
- package/src/hooks/utils/{observableToPromise.js → observableToPromise.ts} +5 -3
- package/src/index.ts +51 -0
- package/src/localization/Localize.spec.js +2 -0
- package/src/localization/{Localize.js → Localize.ts} +6 -6
- package/src/localization/ar-SA.json +1 -0
- package/src/localization/bg-BG.json +1 -0
- package/src/localization/ca-ES.json +1 -0
- package/src/localization/cs-CZ.json +1 -0
- package/src/localization/da-DK.json +1 -0
- package/src/localization/de-DE.json +1 -0
- package/src/localization/el-GR.json +1 -0
- package/src/localization/en-US.json +1 -0
- package/src/localization/es-ES.json +1 -0
- package/src/localization/et-EE.json +1 -0
- package/src/localization/eu-ES.json +1 -0
- package/src/localization/fi-FI.json +1 -0
- package/src/localization/fr-FR.json +1 -0
- package/src/localization/getAllLocalizedStrings.spec.js +3 -1
- package/src/localization/{getAllLocalizedStrings.js → getAllLocalizedStrings.ts} +2 -1
- package/src/localization/getLocaleString.spec.js +4 -2
- package/src/localization/{getLocaleString.js → getLocaleString.ts} +2 -2
- package/src/localization/{getRTLList.js → getRTLList.ts} +1 -1
- package/src/localization/gl-ES.json +1 -0
- package/src/localization/he-IL.json +1 -0
- package/src/localization/hi-IN.json +1 -0
- package/src/localization/hr-HR.json +1 -0
- package/src/localization/hu-HU.json +1 -0
- package/src/localization/id-ID.json +1 -0
- package/src/localization/it-IT.json +1 -0
- package/src/localization/ja-JP.json +1 -0
- package/src/localization/kk-KZ.json +1 -0
- package/src/localization/ko-KR.json +1 -0
- package/src/localization/lt-LT.json +1 -0
- package/src/localization/lv-LV.json +1 -0
- package/src/localization/{mergeLocalizedStrings.js → mergeLocalizedStrings.ts} +5 -1
- package/src/localization/ms-MY.json +1 -0
- package/src/localization/nb-NO.json +1 -0
- package/src/localization/nl-NL.json +1 -0
- package/src/localization/pl-PL.json +1 -0
- package/src/localization/pt-BR.json +1 -0
- package/src/localization/pt-PT.json +1 -0
- package/src/localization/ro-RO.json +1 -0
- package/src/localization/ru-RU.json +1 -0
- package/src/localization/sk-SK.json +1 -0
- package/src/localization/sl-SI.json +1 -0
- package/src/localization/sr-Cyrl-CS.json +1 -0
- package/src/localization/sr-Latn-CS.json +1 -0
- package/src/localization/sv-SE.json +1 -0
- package/src/localization/th-TH.json +1 -0
- package/src/localization/tr-TR.json +1 -0
- package/src/localization/uk-UA.json +1 -0
- package/src/localization/vi-VN.json +1 -0
- package/src/localization/yue.json +1 -0
- package/src/localization/zh-CN.json +1 -0
- package/src/localization/zh-HK.json +1 -0
- package/src/localization/zh-TW.json +1 -0
- package/src/normalizeStyleOptions.ts +43 -2
- package/src/tsconfig.json +3 -1
- package/src/types/ActivityMiddleware.ts +38 -0
- package/src/types/ActivityStatusMiddleware.ts +28 -0
- package/src/types/AttachmentForScreenReaderMiddleware.ts +24 -0
- package/src/types/AttachmentMiddleware.ts +16 -0
- package/src/types/AvatarMiddleware.ts +20 -0
- package/src/types/CardActionMiddleware.ts +21 -0
- package/src/types/ComponentMiddleware.ts +42 -0
- package/src/types/FunctionMiddleware.ts +13 -0
- package/src/types/GroupActivitiesMiddleware.ts +24 -0
- package/src/types/LocalizedStrings.ts +5 -0
- package/src/types/Notification.ts +10 -0
- package/src/types/PrecompiledGlobalize.ts +9 -0
- package/src/types/ScrollToEndButtonMiddleware.ts +34 -0
- package/src/types/SendState.ts +3 -0
- package/src/types/TelemetryMeasurementEvent.ts +44 -0
- package/src/types/ToastMiddleware.ts +16 -0
- package/src/types/Typing.ts +8 -0
- package/src/types/TypingIndicatorMiddleware.ts +18 -0
- package/src/types/WebSpeechPonyfill.ts +24 -0
- package/src/types/WebSpeechPonyfillFactory.ts +5 -0
- package/src/utils/{createCustomEvent.js → createCustomEvent.ts} +8 -3
- package/src/utils/findMin.spec.js +2 -0
- package/src/utils/{findMin.js → findMin.ts} +3 -3
- package/src/utils/mapMap.spec.js +2 -0
- package/src/utils/{mapMap.js → mapMap.ts} +4 -1
- package/src/utils/{normalizeLanguage.js → normalizeLanguage.ts} +1 -1
- package/src/utils/{randomId.js → randomId.ts} +1 -1
- package/src/utils/warnOnce.ts +10 -0
- package/lib/hooks/utils/singleToArray.js +0 -11
- package/scripts/createPrecompiledGlobalize.js +0 -41
- package/src/hooks/useActivities.js +0 -5
- package/src/hooks/useGroupActivities.js +0 -5
- package/src/hooks/usePerformCardAction.js +0 -5
- package/src/hooks/usePostActivity.js +0 -5
- package/src/hooks/useRenderTypingIndicator.js +0 -5
- package/src/hooks/useSendMessage.js +0 -5
- package/src/hooks/useSetNotification.js +0 -5
- package/src/hooks/useStyleOptions.js +0 -5
- package/src/hooks/useTimeoutForSend.js +0 -7
- package/src/hooks/utils/singleToArray.js +0 -3
- package/src/index.js +0 -10
- package/src/index.tsx +0 -10
package/src/hooks/Composer.tsx
CHANGED
|
@@ -3,23 +3,17 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import React, { FC, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import updateIn from 'simple-update-in';
|
|
5
5
|
|
|
6
|
-
import createCustomEvent from '../utils/createCustomEvent';
|
|
7
|
-
import ErrorBoundary from './utils/ErrorBoundary';
|
|
8
|
-
import getAllLocalizedStrings from '../localization/getAllLocalizedStrings';
|
|
9
|
-
import isObject from '../utils/isObject';
|
|
10
|
-
import normalizeLanguage from '../utils/normalizeLanguage';
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
import PrecompiledGlobalize from '../external/PrecompiledGlobalize';
|
|
13
|
-
import StyleOptions from '../StyleOptions';
|
|
14
|
-
|
|
15
6
|
import {
|
|
16
7
|
clearSuggestedActions,
|
|
17
8
|
connect as createConnectAction,
|
|
18
9
|
createStore,
|
|
10
|
+
DirectLineActivity,
|
|
11
|
+
DirectLineJSBotConnection,
|
|
19
12
|
disconnect,
|
|
20
13
|
dismissNotification,
|
|
21
14
|
emitTypingIndicator,
|
|
22
15
|
markActivity,
|
|
16
|
+
OneOrMany,
|
|
23
17
|
postActivity,
|
|
24
18
|
sendEvent,
|
|
25
19
|
sendFiles,
|
|
@@ -33,6 +27,7 @@ import {
|
|
|
33
27
|
setSendBox,
|
|
34
28
|
setSendTimeout,
|
|
35
29
|
setSendTypingIndicator,
|
|
30
|
+
singleToArray,
|
|
36
31
|
startDictate,
|
|
37
32
|
startSpeakingActivity,
|
|
38
33
|
stopDictate,
|
|
@@ -40,23 +35,44 @@ import {
|
|
|
40
35
|
submitSendBox
|
|
41
36
|
} from 'botframework-webchat-core';
|
|
42
37
|
|
|
38
|
+
import { default as WebChatAPIContext } from './internal/WebChatAPIContext';
|
|
39
|
+
import ActivityMiddleware from '../types/ActivityMiddleware';
|
|
40
|
+
import ActivityStatusMiddleware from '../types/ActivityStatusMiddleware';
|
|
41
|
+
import AttachmentForScreenReaderMiddleware from '../types/AttachmentForScreenReaderMiddleware';
|
|
42
|
+
import AttachmentMiddleware from '../types/AttachmentMiddleware';
|
|
43
|
+
import AvatarMiddleware from '../types/AvatarMiddleware';
|
|
44
|
+
import CardActionMiddleware from '../types/CardActionMiddleware';
|
|
45
|
+
import createCustomEvent from '../utils/createCustomEvent';
|
|
43
46
|
import createDefaultCardActionMiddleware from './middleware/createDefaultCardActionMiddleware';
|
|
44
47
|
import createDefaultGroupActivitiesMiddleware from './middleware/createDefaultGroupActivitiesMiddleware';
|
|
45
48
|
import defaultSelectVoice from './internal/defaultSelectVoice';
|
|
49
|
+
import ErrorBoundary from './utils/ErrorBoundary';
|
|
50
|
+
import getAllLocalizedStrings from '../localization/getAllLocalizedStrings';
|
|
51
|
+
import GroupActivitiesMiddleware from '../types/GroupActivitiesMiddleware';
|
|
52
|
+
import isObject from '../utils/isObject';
|
|
53
|
+
import LocalizedStrings from '../types/LocalizedStrings';
|
|
46
54
|
import mapMap from '../utils/mapMap';
|
|
55
|
+
import normalizeLanguage from '../utils/normalizeLanguage';
|
|
56
|
+
import normalizeStyleOptions from '../normalizeStyleOptions';
|
|
47
57
|
import observableToPromise from './utils/observableToPromise';
|
|
58
|
+
import patchStyleOptionsFromDeprecatedProps from '../patchStyleOptionsFromDeprecatedProps';
|
|
59
|
+
import PrecompiledGlobalizeType from '../types/PrecompiledGlobalize';
|
|
60
|
+
import ScrollToEndButtonMiddleware, { ScrollToEndButtonComponentFactory } from '../types/ScrollToEndButtonMiddleware';
|
|
61
|
+
import StyleOptions from '../StyleOptions';
|
|
62
|
+
import TelemetryMeasurementEvent, { TelemetryExceptionMeasurementEvent } from '../types/TelemetryMeasurementEvent';
|
|
63
|
+
import ToastMiddleware from '../types/ToastMiddleware';
|
|
48
64
|
import Tracker from './internal/Tracker';
|
|
65
|
+
import TypingIndicatorMiddleware from '../types/TypingIndicatorMiddleware';
|
|
49
66
|
import WebChatReduxContext, { useDispatch } from './internal/WebChatReduxContext';
|
|
50
|
-
import { default as WebChatAPIContext } from './internal/WebChatAPIContext';
|
|
51
67
|
|
|
52
68
|
import applyMiddleware, {
|
|
53
69
|
forLegacyRenderer as applyMiddlewareForLegacyRenderer,
|
|
54
70
|
forRenderer as applyMiddlewareForRenderer
|
|
55
71
|
} from './middleware/applyMiddleware';
|
|
56
72
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
import
|
|
73
|
+
// PrecompileGlobalize is a generated file and is not ES module. TypeScript don't work with UMD.
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
import PrecompiledGlobalize from '../external/PrecompiledGlobalize';
|
|
60
76
|
|
|
61
77
|
// List of Redux actions factory we are hoisting as Web Chat functions
|
|
62
78
|
const DISPATCHERS = {
|
|
@@ -151,44 +167,54 @@ function mergeStringsOverrides(localizedStrings, language, overrideLocalizedStri
|
|
|
151
167
|
return { ...localizedStrings, ...overrideLocalizedStrings };
|
|
152
168
|
}
|
|
153
169
|
|
|
154
|
-
type
|
|
155
|
-
activityMiddleware
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
170
|
+
type ComposerCoreProps = {
|
|
171
|
+
activityMiddleware?: OneOrMany<ActivityMiddleware>;
|
|
172
|
+
activityStatusMiddleware?: OneOrMany<ActivityStatusMiddleware>;
|
|
173
|
+
attachmentForScreenReaderMiddleware?: OneOrMany<AttachmentForScreenReaderMiddleware>;
|
|
174
|
+
attachmentMiddleware?: OneOrMany<AttachmentMiddleware>;
|
|
175
|
+
avatarMiddleware?: OneOrMany<AvatarMiddleware>;
|
|
176
|
+
cardActionMiddleware?: OneOrMany<CardActionMiddleware>;
|
|
177
|
+
children?: ReactNode;
|
|
178
|
+
dir?: string;
|
|
179
|
+
directLine: DirectLineJSBotConnection;
|
|
180
|
+
disabled?: boolean;
|
|
181
|
+
downscaleImageToDataURL?: (blob: Blob, maxWidth: number, maxHeight: number, type: string, quality: number) => string;
|
|
182
|
+
grammars?: any;
|
|
183
|
+
groupActivitiesMiddleware?: OneOrMany<GroupActivitiesMiddleware>;
|
|
184
|
+
internalErrorBoxClass?: React.Component | Function;
|
|
185
|
+
internalRenderErrorBox?: any;
|
|
186
|
+
locale?: string;
|
|
187
|
+
onTelemetry?: (event: TelemetryMeasurementEvent) => void;
|
|
188
|
+
overrideLocalizedStrings?: LocalizedStrings | ((strings: LocalizedStrings, language: string) => LocalizedStrings);
|
|
189
|
+
renderMarkdown?: (markdown: string, { markdownRespectCRLF: boolean }, { externalLinkAlt: string }) => string;
|
|
190
|
+
scrollToEndButtonMiddleware?: OneOrMany<ScrollToEndButtonMiddleware>;
|
|
191
|
+
selectVoice?: (voices: typeof window.SpeechSynthesisVoice[], activity: DirectLineActivity) => void;
|
|
192
|
+
sendTypingIndicator?: boolean;
|
|
193
|
+
styleOptions?: StyleOptions;
|
|
194
|
+
toastMiddleware?: OneOrMany<ToastMiddleware>;
|
|
195
|
+
typingIndicatorMiddleware?: OneOrMany<TypingIndicatorMiddleware>;
|
|
196
|
+
userID?: string;
|
|
197
|
+
username?: string;
|
|
198
|
+
|
|
199
|
+
/** @deprecated Please use "activityMiddleware" instead. */
|
|
200
|
+
activityRenderer?: any; // TODO: [P4] Remove on or after 2022-06-15.
|
|
201
|
+
/** @deprecated Please use "activityStatusMiddleware" instead. */
|
|
202
|
+
activityStatusRenderer?: any; // TODO: [P4] Remove on or after 2022-06-15.
|
|
203
|
+
/** @deprecated Please use "attachmentMiddleware" instead. */
|
|
204
|
+
attachmentRenderer?: any; // TODO: [P4] Remove on or after 2022-06-15.
|
|
205
|
+
/** @deprecated Please use "avatarMiddleware" instead. */
|
|
206
|
+
avatarRenderer?: any; // TODO: [P4] Remove on or after 2022-06-15.
|
|
207
|
+
/** @deprecated Please use "styleOptions.groupTimestamp" instead. */
|
|
208
|
+
groupTimestamp?: boolean | number; // TODO: [P4] Remove on or after 2022-01-01
|
|
209
|
+
/** @deprecated Please use "styleOptions.sendTimeout" instead. */
|
|
210
|
+
sendTimeout?: number; // TODO: [P4] Remove on or after 2022-01-01.
|
|
211
|
+
/** @deprecated Please use "toastMiddleware" instead. */
|
|
212
|
+
toastRenderer?: any; // TODO: [P4] Remove on or after 2022-06-15.
|
|
213
|
+
/** @deprecated Please use "typingIndicatorRenderer" instead. */
|
|
214
|
+
typingIndicatorRenderer?: any; // TODO: [P4] Remove on or after 2022-06-15.
|
|
189
215
|
};
|
|
190
216
|
|
|
191
|
-
const
|
|
217
|
+
const ComposerCore: FC<ComposerCoreProps> = ({
|
|
192
218
|
activityMiddleware,
|
|
193
219
|
activityRenderer,
|
|
194
220
|
activityStatusMiddleware,
|
|
@@ -212,6 +238,7 @@ const Composer: FC<ComposerProps> = ({
|
|
|
212
238
|
onTelemetry,
|
|
213
239
|
overrideLocalizedStrings,
|
|
214
240
|
renderMarkdown,
|
|
241
|
+
scrollToEndButtonMiddleware,
|
|
215
242
|
selectVoice,
|
|
216
243
|
sendTimeout,
|
|
217
244
|
sendTypingIndicator,
|
|
@@ -292,14 +319,14 @@ const Composer: FC<ComposerProps> = ({
|
|
|
292
319
|
[locale, overrideLocalizedStrings]
|
|
293
320
|
);
|
|
294
321
|
|
|
295
|
-
const localizedGlobalize = useMemo(() => {
|
|
322
|
+
const localizedGlobalize = useMemo<PrecompiledGlobalizeType>(() => {
|
|
296
323
|
const { GLOBALIZE, GLOBALIZE_LANGUAGE } = patchedLocalizedStrings || {};
|
|
297
324
|
|
|
298
325
|
return GLOBALIZE || (GLOBALIZE_LANGUAGE && PrecompiledGlobalize(GLOBALIZE_LANGUAGE)) || PrecompiledGlobalize('en');
|
|
299
326
|
}, [patchedLocalizedStrings]);
|
|
300
327
|
|
|
301
328
|
const trackDimension = useCallback(
|
|
302
|
-
(name, data) => {
|
|
329
|
+
(name: string, data: any) => {
|
|
303
330
|
if (!name || typeof name !== 'string') {
|
|
304
331
|
return console.warn('botframework-webchat: Telemetry dimension name must be a string.');
|
|
305
332
|
}
|
|
@@ -459,6 +486,17 @@ const Composer: FC<ComposerProps> = ({
|
|
|
459
486
|
);
|
|
460
487
|
}, [typingIndicatorMiddleware, typingIndicatorRenderer]);
|
|
461
488
|
|
|
489
|
+
const scrollToEndButtonRenderer: ScrollToEndButtonComponentFactory = useMemo(
|
|
490
|
+
() =>
|
|
491
|
+
applyMiddlewareForRenderer(
|
|
492
|
+
'scroll to end button',
|
|
493
|
+
{ strict: true },
|
|
494
|
+
...singleToArray(scrollToEndButtonMiddleware),
|
|
495
|
+
() => () => () => false
|
|
496
|
+
)() as any,
|
|
497
|
+
[scrollToEndButtonMiddleware]
|
|
498
|
+
);
|
|
499
|
+
|
|
462
500
|
/**
|
|
463
501
|
* This is a heavy function, and it is expected to be only called when there is a need to recreate business logic, e.g.
|
|
464
502
|
* - User ID changed, causing all send* functions to be updated
|
|
@@ -491,6 +529,7 @@ const Composer: FC<ComposerProps> = ({
|
|
|
491
529
|
localizedStrings: patchedLocalizedStrings,
|
|
492
530
|
onTelemetry,
|
|
493
531
|
renderMarkdown,
|
|
532
|
+
scrollToEndButtonRenderer,
|
|
494
533
|
selectVoice: patchedSelectVoice,
|
|
495
534
|
sendTypingIndicator,
|
|
496
535
|
styleOptions: patchedStyleOptions,
|
|
@@ -525,6 +564,7 @@ const Composer: FC<ComposerProps> = ({
|
|
|
525
564
|
patchedToastRenderer,
|
|
526
565
|
patchedTypingIndicatorRenderer,
|
|
527
566
|
renderMarkdown,
|
|
567
|
+
scrollToEndButtonRenderer,
|
|
528
568
|
sendTypingIndicator,
|
|
529
569
|
telemetryDimensionsRef,
|
|
530
570
|
trackDimension,
|
|
@@ -541,59 +581,13 @@ const Composer: FC<ComposerProps> = ({
|
|
|
541
581
|
);
|
|
542
582
|
};
|
|
543
583
|
|
|
544
|
-
// We will create a Redux store if it was not passed in
|
|
545
|
-
const ComposeWithStore: FC<ComposerProps & { store: any }> = ({
|
|
546
|
-
internalRenderErrorBox,
|
|
547
|
-
onTelemetry,
|
|
548
|
-
store,
|
|
549
|
-
...props
|
|
550
|
-
}) => {
|
|
551
|
-
const [error, setError] = useState();
|
|
552
|
-
|
|
553
|
-
const handleError = useCallback(
|
|
554
|
-
error => {
|
|
555
|
-
console.error('botframework-webchat: Uncaught exception', { error });
|
|
556
|
-
|
|
557
|
-
onTelemetry && onTelemetry(createCustomEvent('exception', { error, fatal: true }));
|
|
558
|
-
setError(error);
|
|
559
|
-
},
|
|
560
|
-
[onTelemetry, setError]
|
|
561
|
-
);
|
|
562
|
-
|
|
563
|
-
const memoizedStore = useMemo(() => store || createStore(), [store]);
|
|
564
|
-
|
|
565
|
-
return error ? (
|
|
566
|
-
!!internalRenderErrorBox && internalRenderErrorBox({ error, type: 'uncaught exception' })
|
|
567
|
-
) : (
|
|
568
|
-
<ErrorBoundary onError={handleError}>
|
|
569
|
-
<Provider context={WebChatReduxContext} store={memoizedStore}>
|
|
570
|
-
<Composer internalRenderErrorBox={internalRenderErrorBox} onTelemetry={onTelemetry} {...props} />
|
|
571
|
-
</Provider>
|
|
572
|
-
</ErrorBoundary>
|
|
573
|
-
);
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
ComposeWithStore.defaultProps = {
|
|
577
|
-
internalRenderErrorBox: undefined,
|
|
578
|
-
onTelemetry: undefined,
|
|
579
|
-
store: undefined
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
ComposeWithStore.propTypes = {
|
|
583
|
-
internalRenderErrorBox: PropTypes.any,
|
|
584
|
-
onTelemetry: PropTypes.func,
|
|
585
|
-
store: PropTypes.any
|
|
586
|
-
};
|
|
587
|
-
|
|
588
|
-
export default ComposeWithStore;
|
|
589
|
-
|
|
590
584
|
/**
|
|
591
585
|
* @todo TODO: [P3] We should consider moving some data from Redux store to props
|
|
592
586
|
* Although we use `connectToWebChat` to hide the details of accessor of Redux store,
|
|
593
587
|
* we should clean up the responsibility between Context and Redux store
|
|
594
588
|
* We should decide which data is needed for React but not in other environment such as CLI/VSCode
|
|
595
589
|
*/
|
|
596
|
-
|
|
590
|
+
ComposerCore.defaultProps = {
|
|
597
591
|
activityMiddleware: undefined,
|
|
598
592
|
activityRenderer: undefined,
|
|
599
593
|
activityStatusMiddleware: undefined,
|
|
@@ -616,6 +610,7 @@ Composer.defaultProps = {
|
|
|
616
610
|
onTelemetry: undefined,
|
|
617
611
|
overrideLocalizedStrings: undefined,
|
|
618
612
|
renderMarkdown: undefined,
|
|
613
|
+
scrollToEndButtonMiddleware: undefined,
|
|
619
614
|
selectVoice: undefined,
|
|
620
615
|
sendTimeout: undefined,
|
|
621
616
|
sendTypingIndicator: false,
|
|
@@ -628,7 +623,7 @@ Composer.defaultProps = {
|
|
|
628
623
|
username: ''
|
|
629
624
|
};
|
|
630
625
|
|
|
631
|
-
|
|
626
|
+
ComposerCore.propTypes = {
|
|
632
627
|
activityMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
|
|
633
628
|
activityRenderer: PropTypes.func,
|
|
634
629
|
activityStatusMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
|
|
@@ -664,6 +659,7 @@ Composer.propTypes = {
|
|
|
664
659
|
onTelemetry: PropTypes.func,
|
|
665
660
|
overrideLocalizedStrings: PropTypes.oneOfType([PropTypes.any, PropTypes.func]),
|
|
666
661
|
renderMarkdown: PropTypes.func,
|
|
662
|
+
scrollToEndButtonMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
|
|
667
663
|
selectVoice: PropTypes.func,
|
|
668
664
|
sendTimeout: PropTypes.number,
|
|
669
665
|
sendTypingIndicator: PropTypes.bool,
|
|
@@ -675,3 +671,49 @@ Composer.propTypes = {
|
|
|
675
671
|
userID: PropTypes.string,
|
|
676
672
|
username: PropTypes.string
|
|
677
673
|
};
|
|
674
|
+
|
|
675
|
+
type ComposerProps = ComposerCoreProps & { store?: any };
|
|
676
|
+
|
|
677
|
+
// We will create a Redux store if it was not passed in
|
|
678
|
+
const Composer: FC<ComposerProps> = ({ internalRenderErrorBox, onTelemetry, store, ...props }) => {
|
|
679
|
+
const [error, setError] = useState();
|
|
680
|
+
|
|
681
|
+
const handleError = useCallback(
|
|
682
|
+
error => {
|
|
683
|
+
console.error('botframework-webchat: Uncaught exception', { error });
|
|
684
|
+
|
|
685
|
+
onTelemetry &&
|
|
686
|
+
onTelemetry(createCustomEvent('exception', { error, fatal: true }) as TelemetryExceptionMeasurementEvent);
|
|
687
|
+
setError(error);
|
|
688
|
+
},
|
|
689
|
+
[onTelemetry, setError]
|
|
690
|
+
);
|
|
691
|
+
|
|
692
|
+
const memoizedStore = useMemo(() => store || createStore(), [store]);
|
|
693
|
+
|
|
694
|
+
return error ? (
|
|
695
|
+
!!internalRenderErrorBox && internalRenderErrorBox({ error, type: 'uncaught exception' })
|
|
696
|
+
) : (
|
|
697
|
+
<ErrorBoundary onError={handleError}>
|
|
698
|
+
<Provider context={WebChatReduxContext} store={memoizedStore}>
|
|
699
|
+
<ComposerCore internalRenderErrorBox={internalRenderErrorBox} onTelemetry={onTelemetry} {...props} />
|
|
700
|
+
</Provider>
|
|
701
|
+
</ErrorBoundary>
|
|
702
|
+
);
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
Composer.defaultProps = {
|
|
706
|
+
internalRenderErrorBox: undefined,
|
|
707
|
+
onTelemetry: undefined,
|
|
708
|
+
store: undefined
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
Composer.propTypes = {
|
|
712
|
+
internalRenderErrorBox: PropTypes.any,
|
|
713
|
+
onTelemetry: PropTypes.func,
|
|
714
|
+
store: PropTypes.any
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
export default Composer;
|
|
718
|
+
|
|
719
|
+
export type { ComposerProps };
|
|
@@ -8,6 +8,7 @@ import useCreateActivityRenderer from './useCreateActivityRenderer';
|
|
|
8
8
|
import useCreateActivityStatusRenderer from './useCreateActivityStatusRenderer';
|
|
9
9
|
import useCreateAttachmentForScreenReaderRenderer from './useCreateAttachmentForScreenReaderRenderer';
|
|
10
10
|
import useCreateAvatarRenderer from './useCreateAvatarRenderer';
|
|
11
|
+
import useCreateScrollToEndButtonRenderer from './useCreateScrollToEndButtonRenderer';
|
|
11
12
|
import useDateFormatter from './useDateFormatter';
|
|
12
13
|
import useDebouncedNotifications from './useDebouncedNotifications';
|
|
13
14
|
import useDictateInterims from './useDictateInterims';
|
|
@@ -71,6 +72,7 @@ export {
|
|
|
71
72
|
useCreateActivityStatusRenderer,
|
|
72
73
|
useCreateAttachmentForScreenReaderRenderer,
|
|
73
74
|
useCreateAvatarRenderer,
|
|
75
|
+
useCreateScrollToEndButtonRenderer,
|
|
74
76
|
useDateFormatter,
|
|
75
77
|
useDebouncedNotifications,
|
|
76
78
|
useDictateInterims,
|
|
@@ -1,8 +1,73 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
|
+
import { DirectLineActivity, DirectLineJSBotConnection } from 'botframework-webchat-core';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
4
|
+
import { AttachmentForScreenReaderComponentFactory } from '../../types/AttachmentForScreenReaderMiddleware';
|
|
5
|
+
import { AvatarComponentFactory } from '../../types/AvatarMiddleware';
|
|
6
|
+
import { GroupActivities } from '../../types/GroupActivitiesMiddleware';
|
|
7
|
+
import { LegacyActivityRenderer } from '../../types/ActivityMiddleware';
|
|
8
|
+
import { Observable } from 'redux';
|
|
9
|
+
import { PerformCardAction } from '../../types/CardActionMiddleware';
|
|
10
|
+
import { RenderActivityStatus } from '../../types/ActivityStatusMiddleware';
|
|
11
|
+
import { RenderAttachment } from '../../types/AttachmentMiddleware';
|
|
12
|
+
import { RenderToast } from '../../types/ToastMiddleware';
|
|
13
|
+
import { ScrollToEndButtonComponentFactory } from '../../types/ScrollToEndButtonMiddleware';
|
|
14
|
+
import { StrictStyleOptions } from '../../StyleOptions';
|
|
15
|
+
import LocalizedStrings from '../../types/LocalizedStrings';
|
|
16
|
+
import PrecompiledGlobalize from '../../types/PrecompiledGlobalize';
|
|
17
|
+
import TelemetryMeasurementEvent from '../../types/TelemetryMeasurementEvent';
|
|
18
|
+
|
|
19
|
+
type WebChatAPIContext = {
|
|
20
|
+
activityRenderer?: LegacyActivityRenderer;
|
|
21
|
+
activityStatusRenderer?: RenderActivityStatus;
|
|
22
|
+
attachmentForScreenReaderRenderer?: AttachmentForScreenReaderComponentFactory;
|
|
23
|
+
attachmentRenderer?: RenderAttachment;
|
|
24
|
+
avatarRenderer?: AvatarComponentFactory;
|
|
25
|
+
clearSuggestedActions?: () => void;
|
|
26
|
+
dir?: string;
|
|
27
|
+
directLine?: DirectLineJSBotConnection;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
dismissNotification?: (id: string) => void;
|
|
30
|
+
downscaleImageToDataURL?: (blob: Blob, maxWidth: number, maxHeight: number, type: string, quality: number) => string;
|
|
31
|
+
emitTypingIndicator?: () => void;
|
|
32
|
+
grammars?: any;
|
|
33
|
+
groupActivities?: GroupActivities;
|
|
34
|
+
internalErrorBoxClass?: React.Component | Function;
|
|
35
|
+
language?: string;
|
|
36
|
+
localizedGlobalizeState?: PrecompiledGlobalize[];
|
|
37
|
+
localizedStrings?: { [language: string]: LocalizedStrings };
|
|
38
|
+
markActivity?: ({ id: string }, name: string, value?: any) => void;
|
|
39
|
+
onCardAction?: PerformCardAction;
|
|
40
|
+
onTelemetry?: (event: TelemetryMeasurementEvent) => void;
|
|
41
|
+
postActivity?: (activity: DirectLineActivity) => Observable<string>;
|
|
42
|
+
renderMarkdown?: (markdown: string, { markdownRespectCRLF: boolean }, { externalLinkAlt: string }) => string;
|
|
43
|
+
scrollToEndButtonRenderer?: ScrollToEndButtonComponentFactory;
|
|
44
|
+
selectVoice?: (voices: typeof window.SpeechSynthesisVoice[], activity: DirectLineActivity) => void;
|
|
45
|
+
sendEvent?: (name: string, value: any) => void;
|
|
46
|
+
sendFiles?: (files: File[]) => void;
|
|
47
|
+
sendMessage?: (text: string, method?: string, { channelData }?: { channelData?: any }) => void;
|
|
48
|
+
sendMessageBack?: (value: any, text?: string, displayText?: string) => void;
|
|
49
|
+
sendPostBack?: (value?: any) => void;
|
|
50
|
+
sendTypingIndicator?: boolean;
|
|
51
|
+
setDictateInterims?: (interims: string[]) => void;
|
|
52
|
+
setDictateState?: (dictateState: number) => void;
|
|
53
|
+
setNotification?: (notification: Notification) => void;
|
|
54
|
+
setSendBox?: (value: string) => void;
|
|
55
|
+
setSendTimeout?: (timeout: number) => void;
|
|
56
|
+
startDictate?: () => void;
|
|
57
|
+
startSpeakingActivity?: () => void;
|
|
58
|
+
stopDictate?: () => void;
|
|
59
|
+
stopSpeakingActivity?: () => void;
|
|
60
|
+
styleOptions?: StrictStyleOptions;
|
|
61
|
+
submitSendBox?: (method?: string, { channelData }?: { channelData: any }) => void;
|
|
62
|
+
telemetryDimensionsRef?: React.Ref<any>;
|
|
63
|
+
toastRenderer?: RenderToast;
|
|
64
|
+
trackDimension?: (name: string, data: any) => void;
|
|
65
|
+
typingIndicatorRenderer?: any; // TODO
|
|
66
|
+
userID?: string;
|
|
67
|
+
username?: string;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const context = createContext<WebChatAPIContext>(undefined);
|
|
6
71
|
|
|
7
72
|
context.displayName = 'WebChatAPIContext';
|
|
8
73
|
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { isValidElement, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
+
import { ActivityComponentFactory } from '../../types/ActivityMiddleware';
|
|
4
|
+
import { RenderAttachment } from '../../types/AttachmentMiddleware';
|
|
3
5
|
import useRenderAttachment from '../useRenderAttachment';
|
|
4
6
|
import useWebChatAPIContext from './useWebChatAPIContext';
|
|
5
7
|
|
|
6
|
-
export default function useCreateActivityRendererInternal(
|
|
8
|
+
export default function useCreateActivityRendererInternal(
|
|
9
|
+
renderAttachmentOverride?: RenderAttachment
|
|
10
|
+
): ActivityComponentFactory {
|
|
7
11
|
const { activityRenderer: createActivityRenderer } = useWebChatAPIContext();
|
|
8
12
|
const defaultRenderAttachment = useRenderAttachment();
|
|
9
13
|
|
|
10
|
-
const renderAttachment = renderAttachmentOverride || defaultRenderAttachment;
|
|
14
|
+
const renderAttachment: RenderAttachment = renderAttachmentOverride || defaultRenderAttachment;
|
|
11
15
|
|
|
12
16
|
return useMemo(
|
|
13
17
|
() => (...createActivityRendererOptions) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { isValidElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import concatMiddleware from './concatMiddleware';
|
|
4
2
|
import ErrorBox from '../internal/ErrorBox';
|
|
3
|
+
import concatMiddleware from './concatMiddleware';
|
|
5
4
|
import UserlandBoundary from './UserlandBoundary';
|
|
6
5
|
|
|
7
6
|
export default function applyMiddleware(type, ...middleware) {
|
|
@@ -35,7 +34,7 @@ export function forLegacyRenderer(type, ...middleware) {
|
|
|
35
34
|
*
|
|
36
35
|
* @param {string} type Required. String equivalent of type of container to be rendered.
|
|
37
36
|
* @param { strict = false } - Used to enforce new middleware format which cooperates with new activity grouping.
|
|
38
|
-
* @see See {@link https://github.com/microsoft/BotFramework-WebChat/blob/
|
|
37
|
+
* @see See {@link https://github.com/microsoft/BotFramework-WebChat/blob/main/CHANGELOG.md#4100---2020-08-18} and {@link https://github.com/microsoft/BotFramework-WebChat/pull/3365} for middleware breaking changes.
|
|
39
38
|
* @param {middleware[]} middleware list of middleware to be applied.
|
|
40
39
|
* 'createRendererArgs' is "what to render"; for example, an activity.
|
|
41
40
|
* @returns Returns a function if there is a renderer *committed* to render OR returns false if nothing should be rendered.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint no-magic-numbers: "off" */
|
|
2
|
+
|
|
1
3
|
import concatMiddleware from './concatMiddleware';
|
|
2
4
|
|
|
3
5
|
describe('two middleware concatenated and ran', () => {
|
|
@@ -26,9 +28,7 @@ describe('two middleware concatenated and ran', () => {
|
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
test('by a single upstream middleware', () => {
|
|
29
|
-
const combine = () => next => value =>
|
|
30
|
-
return next(value) + next(value + 1);
|
|
31
|
-
};
|
|
31
|
+
const combine = () => next => value => next(value) + next(value + 1);
|
|
32
32
|
|
|
33
33
|
const middleware = concatMiddleware(combine, oddMultiplyByTen, evenMultiplyByHundred);
|
|
34
34
|
const work = middleware()(value => value);
|
|
@@ -38,9 +38,7 @@ describe('two middleware concatenated and ran', () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
test('one middleware ran twice by a single upstream middleware', () => {
|
|
41
|
-
const combine = () => next => value =>
|
|
42
|
-
return next(value) + next(value + 1);
|
|
43
|
-
};
|
|
41
|
+
const combine = () => next => value => next(value) + next(value + 1);
|
|
44
42
|
|
|
45
43
|
const oddMultiplyByTenAndEvenMultiplyByHundred = () => () => value => {
|
|
46
44
|
if (value % 2) {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
type Work<T> = (...args: any[]) => T;
|
|
2
|
+
type Enhancer<T> = (next: Work<T>) => Work<T>;
|
|
3
|
+
type Middleware<Setup, Result> = (setup: Setup) => Enhancer<Result>;
|
|
4
|
+
|
|
5
|
+
export default function concatMiddleware<Setup, Result>(
|
|
6
|
+
...middleware: Middleware<Setup, Result>[]
|
|
7
|
+
): Middleware<Setup, Result> {
|
|
2
8
|
return setupArgs => {
|
|
3
9
|
const setup = middleware.reduce(
|
|
4
10
|
(setup, middleware) => (middleware ? [...setup, middleware(setupArgs)] : setup),
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { sendMessage, sendMessageBack, sendPostBack } from 'botframework-webchat-core';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import CardActionMiddleware from '../../types/CardActionMiddleware';
|
|
4
|
+
|
|
5
|
+
export default function createDefaultCardActionMiddleware(): CardActionMiddleware {
|
|
4
6
|
return ({ dispatch }) => next => (...args) => {
|
|
5
7
|
const [
|
|
6
8
|
{
|
|
7
|
-
cardAction
|
|
9
|
+
cardAction,
|
|
10
|
+
cardAction: { value }
|
|
8
11
|
}
|
|
9
12
|
] = args;
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
// We cannot use destructured "type" here because TypeScript don't recognize "messageBack" is "MessageBackCardAction".
|
|
15
|
+
switch (cardAction.type) {
|
|
12
16
|
case 'imBack':
|
|
13
17
|
if (typeof value === 'string') {
|
|
14
18
|
// TODO: [P4] Instead of calling dispatch, we should move to dispatchers instead for completeness
|
|
@@ -20,7 +24,7 @@ export default function createDefaultCardActionMiddleware() {
|
|
|
20
24
|
break;
|
|
21
25
|
|
|
22
26
|
case 'messageBack':
|
|
23
|
-
dispatch(sendMessageBack(value, text, displayText));
|
|
27
|
+
dispatch(sendMessageBack(value, cardAction.text, cardAction.displayText));
|
|
24
28
|
|
|
25
29
|
break;
|
|
26
30
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { Constants } from 'botframework-webchat-core';
|
|
1
|
+
import { Constants, DirectLineActivity } from 'botframework-webchat-core';
|
|
2
|
+
|
|
3
|
+
import GroupActivitiesMiddleware from '../../types/GroupActivitiesMiddleware';
|
|
2
4
|
|
|
3
5
|
const {
|
|
4
6
|
ActivityClientState: { SENT }
|
|
5
7
|
} = Constants;
|
|
6
8
|
|
|
7
|
-
function bin(items, grouping) {
|
|
8
|
-
let lastBin;
|
|
9
|
-
const bins = [];
|
|
10
|
-
let lastItem;
|
|
9
|
+
function bin<T>(items: T[], grouping: (last: T, current: T) => boolean): T[][] {
|
|
10
|
+
let lastBin: T[];
|
|
11
|
+
const bins: T[][] = [];
|
|
12
|
+
let lastItem: T;
|
|
11
13
|
|
|
12
14
|
items.forEach(item => {
|
|
13
15
|
if (lastItem && grouping(lastItem, item)) {
|
|
@@ -23,11 +25,15 @@ function bin(items, grouping) {
|
|
|
23
25
|
return bins;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
function sending(activity) {
|
|
28
|
+
function sending(activity: DirectLineActivity): boolean {
|
|
27
29
|
return activity.from.role === 'user' && activity.channelData && activity.channelData.state !== SENT;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
function shouldGroupTimestamp(
|
|
32
|
+
function shouldGroupTimestamp(
|
|
33
|
+
activityX: DirectLineActivity,
|
|
34
|
+
activityY: DirectLineActivity,
|
|
35
|
+
groupTimestamp: boolean | number
|
|
36
|
+
): boolean {
|
|
31
37
|
if (groupTimestamp === false) {
|
|
32
38
|
// Hide timestamp for all activities.
|
|
33
39
|
return true;
|
|
@@ -47,9 +53,11 @@ function shouldGroupTimestamp(activityX, activityY, groupTimestamp) {
|
|
|
47
53
|
return false;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
export default function createDefaultGroupActivityMiddleware({ groupTimestamp }) {
|
|
51
|
-
return () =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
export default function createDefaultGroupActivityMiddleware({ groupTimestamp }): GroupActivitiesMiddleware {
|
|
57
|
+
return () =>
|
|
58
|
+
() =>
|
|
59
|
+
({ activities }) => ({
|
|
60
|
+
sender: bin(activities, (x, y) => x.from.role === y.from.role),
|
|
61
|
+
status: bin(activities, (x, y) => shouldGroupTimestamp(x, y, groupTimestamp))
|
|
62
|
+
});
|
|
55
63
|
}
|