botframework-webchat-api 4.14.1 → 4.15.2-main.20220413.af6e8a3
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/.eslintrc.yml +4 -105
- package/.prettierrc.yml +1 -1
- package/lib/StyleOptions.d.ts +244 -14
- package/lib/StyleOptions.d.ts.map +1 -1
- package/lib/defaultStyleOptions.d.ts.map +1 -1
- package/lib/defaultStyleOptions.js +67 -14
- package/lib/hooks/Composer.d.ts +3 -3
- package/lib/hooks/Composer.d.ts.map +1 -1
- package/lib/hooks/Composer.js +29 -11
- package/lib/hooks/index.d.ts +11 -1
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/index.js +81 -1
- package/lib/hooks/internal/WebChatAPIContext.d.ts +3 -3
- package/lib/hooks/internal/WebChatAPIContext.d.ts.map +1 -1
- package/lib/hooks/internal/WebChatAPIContext.js +1 -1
- package/lib/hooks/internal/useCreateActivityRendererInternal.d.ts.map +1 -1
- package/lib/hooks/internal/useCreateActivityRendererInternal.js +1 -1
- package/lib/hooks/internal/useDebugDeps.js +10 -4
- package/lib/hooks/internal/usePrevious.d.ts +2 -0
- package/lib/hooks/internal/usePrevious.d.ts.map +1 -0
- package/lib/hooks/internal/usePrevious.js +17 -0
- package/lib/hooks/internal/useReadTelemetryDimensions.js +2 -2
- package/lib/hooks/internal/useValueRef.d.ts +3 -0
- package/lib/hooks/internal/useValueRef.d.ts.map +1 -0
- package/lib/hooks/internal/useValueRef.js +24 -0
- package/lib/hooks/middleware/UserlandBoundary.js +1 -1
- package/lib/hooks/middleware/applyMiddleware.js +1 -1
- package/lib/hooks/middleware/concatMiddleware.d.ts.map +1 -1
- package/lib/hooks/middleware/concatMiddleware.js +2 -2
- package/lib/hooks/middleware/createDefaultCardActionMiddleware.d.ts.map +1 -1
- package/lib/hooks/middleware/createDefaultCardActionMiddleware.js +1 -1
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.d.ts.map +1 -1
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.js +19 -3
- package/lib/hooks/useActiveTyping.d.ts.map +1 -1
- package/lib/hooks/useActiveTyping.js +5 -4
- package/lib/hooks/useActivities.d.ts +2 -2
- package/lib/hooks/useActivities.d.ts.map +1 -1
- package/lib/hooks/useActivities.js +1 -1
- package/lib/hooks/useActivityKeys.d.ts +3 -0
- package/lib/hooks/useActivityKeys.d.ts.map +1 -0
- package/lib/hooks/useActivityKeys.js +14 -0
- package/lib/hooks/useActivityKeysByRead.d.ts +3 -0
- package/lib/hooks/useActivityKeysByRead.d.ts.map +1 -0
- package/lib/hooks/useActivityKeysByRead.js +14 -0
- package/lib/hooks/useCreateActivityStatusRenderer.d.ts +3 -3
- package/lib/hooks/useCreateActivityStatusRenderer.d.ts.map +1 -1
- package/lib/hooks/useCreateActivityStatusRenderer.js +47 -16
- package/lib/hooks/useCreateAvatarRenderer.d.ts +5 -3
- package/lib/hooks/useCreateAvatarRenderer.d.ts.map +1 -1
- package/lib/hooks/useCreateAvatarRenderer.js +1 -1
- package/lib/hooks/useDateFormatter.d.ts.map +1 -1
- package/lib/hooks/useDateFormatter.js +1 -1
- package/lib/hooks/useDebouncedNotifications.js +3 -3
- package/lib/hooks/useGetActivityByKey.d.ts +3 -0
- package/lib/hooks/useGetActivityByKey.d.ts.map +1 -0
- package/lib/hooks/useGetActivityByKey.js +14 -0
- package/lib/hooks/useGetHasAcknowledgedByActivityKey.d.ts +3 -0
- package/lib/hooks/useGetHasAcknowledgedByActivityKey.d.ts.map +1 -0
- package/lib/hooks/useGetHasAcknowledgedByActivityKey.js +14 -0
- package/lib/hooks/useGetKeyByActivity.d.ts +3 -0
- package/lib/hooks/useGetKeyByActivity.d.ts.map +1 -0
- package/lib/hooks/useGetKeyByActivity.js +14 -0
- package/lib/hooks/useGetKeyByActivityId.d.ts +3 -0
- package/lib/hooks/useGetKeyByActivityId.d.ts.map +1 -0
- package/lib/hooks/useGetKeyByActivityId.js +14 -0
- package/lib/hooks/useGetSendTimeoutForActivity.d.ts +2 -2
- package/lib/hooks/useGetSendTimeoutForActivity.d.ts.map +1 -1
- package/lib/hooks/useGetSendTimeoutForActivity.js +4 -2
- package/lib/hooks/useGroupActivities.d.ts +4 -4
- package/lib/hooks/useGroupActivities.d.ts.map +1 -1
- package/lib/hooks/useGroupActivities.js +1 -1
- package/lib/hooks/useLastAcknowledgedActivityKey.d.ts +3 -0
- package/lib/hooks/useLastAcknowledgedActivityKey.d.ts.map +1 -0
- package/lib/hooks/useLastAcknowledgedActivityKey.js +14 -0
- package/lib/hooks/useLastReadActivityKey.d.ts +3 -0
- package/lib/hooks/useLastReadActivityKey.d.ts.map +1 -0
- package/lib/hooks/useLastReadActivityKey.js +14 -0
- package/lib/hooks/useLocalizer.d.ts +1 -1
- package/lib/hooks/useLocalizer.d.ts.map +1 -1
- package/lib/hooks/useLocalizer.js +9 -3
- package/lib/hooks/useMarkActivityAsSpoken.d.ts +2 -2
- package/lib/hooks/useMarkActivityAsSpoken.d.ts.map +1 -1
- package/lib/hooks/useMarkActivityAsSpoken.js +1 -1
- package/lib/hooks/useMarkActivityKeyAsRead.d.ts +3 -0
- package/lib/hooks/useMarkActivityKeyAsRead.d.ts.map +1 -0
- package/lib/hooks/useMarkActivityKeyAsRead.js +14 -0
- package/lib/hooks/useMarkAllAsAcknowledged.d.ts +3 -0
- package/lib/hooks/useMarkAllAsAcknowledged.d.ts.map +1 -0
- package/lib/hooks/useMarkAllAsAcknowledged.js +14 -0
- package/lib/hooks/usePerformCardAction.d.ts +2 -2
- package/lib/hooks/usePerformCardAction.d.ts.map +1 -1
- package/lib/hooks/usePerformCardAction.js +1 -1
- package/lib/hooks/usePostActivity.d.ts +2 -2
- package/lib/hooks/usePostActivity.d.ts.map +1 -1
- package/lib/hooks/usePostActivity.js +1 -1
- package/lib/hooks/useSendFiles.d.ts +8 -1
- package/lib/hooks/useSendFiles.d.ts.map +1 -1
- package/lib/hooks/useSendFiles.js +1 -1
- package/lib/hooks/useSendTimeoutForActivity.d.ts +2 -2
- package/lib/hooks/useSendTimeoutForActivity.d.ts.map +1 -1
- package/lib/hooks/useSendTimeoutForActivity.js +1 -1
- package/lib/hooks/useSubmitSendBox.d.ts.map +1 -1
- package/lib/hooks/useSubmitSendBox.js +8 -5
- package/lib/hooks/useSuggestedActions.d.ts +1 -1
- package/lib/hooks/useSuggestedActions.d.ts.map +1 -1
- package/lib/hooks/useSuggestedActions.js +1 -1
- package/lib/hooks/useTimeoutForSend.d.ts +2 -2
- package/lib/hooks/useTimeoutForSend.d.ts.map +1 -1
- package/lib/hooks/useTimeoutForSend.js +1 -1
- package/lib/hooks/useTrackException.js +2 -2
- package/lib/hooks/utils/ErrorBoundary.js +4 -4
- package/lib/index.js +8 -8
- package/lib/localization/Localize.d.ts.map +1 -1
- package/lib/localization/Localize.js +12 -6
- package/lib/localization/ar-SA.json +23 -4
- package/lib/localization/bg-BG.json +23 -4
- package/lib/localization/ca-ES.json +23 -4
- package/lib/localization/cs-CZ.json +23 -4
- package/lib/localization/da-DK.json +23 -4
- package/lib/localization/de-DE.json +23 -4
- package/lib/localization/el-GR.json +23 -4
- package/lib/localization/en-US.json +34 -9
- package/lib/localization/es-ES.json +23 -4
- package/lib/localization/et-EE.json +23 -4
- package/lib/localization/eu-ES.json +23 -4
- package/lib/localization/fi-FI.json +23 -4
- package/lib/localization/fr-FR.json +23 -4
- package/lib/localization/gl-ES.json +23 -4
- package/lib/localization/he-IL.json +23 -4
- package/lib/localization/hi-IN.json +23 -4
- package/lib/localization/hr-HR.json +23 -4
- package/lib/localization/hu-HU.json +23 -4
- package/lib/localization/id-ID.json +23 -4
- package/lib/localization/it-IT.json +23 -4
- package/lib/localization/ja-JP.json +23 -4
- package/lib/localization/kk-KZ.json +23 -4
- package/lib/localization/ko-KR.json +23 -4
- package/lib/localization/lt-LT.json +23 -4
- package/lib/localization/lv-LV.json +23 -4
- package/lib/localization/mergeLocalizedStrings.d.ts.map +1 -1
- package/lib/localization/mergeLocalizedStrings.js +13 -6
- package/lib/localization/ms-MY.json +23 -4
- package/lib/localization/nb-NO.json +23 -4
- package/lib/localization/nl-NL.json +23 -4
- package/lib/localization/pl-PL.json +23 -4
- package/lib/localization/pt-BR.json +23 -4
- package/lib/localization/pt-PT.json +23 -4
- package/lib/localization/ro-RO.json +23 -4
- package/lib/localization/ru-RU.json +23 -4
- package/lib/localization/sk-SK.json +23 -4
- package/lib/localization/sl-SI.json +23 -4
- package/lib/localization/sr-Cyrl-CS.json +23 -4
- package/lib/localization/sr-Latn-CS.json +23 -4
- package/lib/localization/sv-SE.json +23 -4
- package/lib/localization/th-TH.json +23 -4
- package/lib/localization/tr-TR.json +23 -4
- package/lib/localization/uk-UA.json +23 -4
- package/lib/localization/vi-VN.json +23 -4
- package/lib/localization/yue.json +26 -7
- package/lib/localization/zh-CN.json +23 -4
- package/lib/localization/zh-HK.json +23 -4
- package/lib/localization/zh-TW.json +23 -4
- package/lib/normalizeStyleOptions.d.ts.map +1 -1
- package/lib/normalizeStyleOptions.js +49 -4
- package/lib/patchStyleOptionsFromDeprecatedProps.js +1 -2
- package/lib/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.d.ts +5 -0
- package/lib/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.js +184 -0
- package/lib/providers/ActivityAcknowledgement/private/Context.d.ts +13 -0
- package/lib/providers/ActivityAcknowledgement/private/Context.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/private/Context.js +13 -0
- package/lib/providers/ActivityAcknowledgement/private/types.d.ts +6 -0
- package/lib/providers/ActivityAcknowledgement/private/types.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/private/types.js +2 -0
- package/lib/providers/ActivityAcknowledgement/private/useContext.d.ts +3 -0
- package/lib/providers/ActivityAcknowledgement/private/useContext.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/private/useContext.js +24 -0
- package/lib/providers/ActivityAcknowledgement/useActivityKeysByRead.d.ts +5 -0
- package/lib/providers/ActivityAcknowledgement/useActivityKeysByRead.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useActivityKeysByRead.js +18 -0
- package/lib/providers/ActivityAcknowledgement/useGetHasAcknowledgedByActivityKey.d.ts +2 -0
- package/lib/providers/ActivityAcknowledgement/useGetHasAcknowledgedByActivityKey.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useGetHasAcknowledgedByActivityKey.js +15 -0
- package/lib/providers/ActivityAcknowledgement/useLastAcknowledgedActivityKey.d.ts +2 -0
- package/lib/providers/ActivityAcknowledgement/useLastAcknowledgedActivityKey.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useLastAcknowledgedActivityKey.js +15 -0
- package/lib/providers/ActivityAcknowledgement/useLastReadActivityKey.d.ts +2 -0
- package/lib/providers/ActivityAcknowledgement/useLastReadActivityKey.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useLastReadActivityKey.js +15 -0
- package/lib/providers/ActivityAcknowledgement/useMarkActivityKeyAsRead.d.ts +2 -0
- package/lib/providers/ActivityAcknowledgement/useMarkActivityKeyAsRead.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useMarkActivityKeyAsRead.js +15 -0
- package/lib/providers/ActivityAcknowledgement/useMarkAllAsAcknowledged.d.ts +2 -0
- package/lib/providers/ActivityAcknowledgement/useMarkAllAsAcknowledged.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useMarkAllAsAcknowledged.js +15 -0
- package/lib/providers/ActivityKeyer/ActivityKeyerComposer.d.ts +18 -0
- package/lib/providers/ActivityKeyer/ActivityKeyerComposer.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/ActivityKeyerComposer.js +153 -0
- package/lib/providers/ActivityKeyer/private/Context.d.ts +12 -0
- package/lib/providers/ActivityKeyer/private/Context.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/Context.js +13 -0
- package/lib/providers/ActivityKeyer/private/getActivityId.d.ts +3 -0
- package/lib/providers/ActivityKeyer/private/getActivityId.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/getActivityId.js +11 -0
- package/lib/providers/ActivityKeyer/private/getClientActivityId.d.ts +3 -0
- package/lib/providers/ActivityKeyer/private/getClientActivityId.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/getClientActivityId.js +13 -0
- package/lib/providers/ActivityKeyer/private/uniqueId.d.ts +2 -0
- package/lib/providers/ActivityKeyer/private/uniqueId.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/uniqueId.js +18 -0
- package/lib/providers/ActivityKeyer/private/useContext.d.ts +3 -0
- package/lib/providers/ActivityKeyer/private/useContext.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/useContext.js +24 -0
- package/lib/providers/ActivityKeyer/useActivityKeys.d.ts +2 -0
- package/lib/providers/ActivityKeyer/useActivityKeys.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/useActivityKeys.js +15 -0
- package/lib/providers/ActivityKeyer/useGetActivityByKey.d.ts +3 -0
- package/lib/providers/ActivityKeyer/useGetActivityByKey.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/useGetActivityByKey.js +15 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivity.d.ts +3 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivity.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivity.js +15 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivityId.d.ts +2 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivityId.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivityId.js +15 -0
- package/lib/types/ActivityMiddleware.d.ts +3 -3
- package/lib/types/ActivityMiddleware.d.ts.map +1 -1
- package/lib/types/ActivityStatusMiddleware.d.ts +3 -3
- package/lib/types/ActivityStatusMiddleware.d.ts.map +1 -1
- package/lib/types/AttachmentForScreenReaderMiddleware.d.ts +2 -2
- package/lib/types/AttachmentForScreenReaderMiddleware.d.ts.map +1 -1
- package/lib/types/AttachmentMiddleware.d.ts +2 -2
- package/lib/types/AttachmentMiddleware.d.ts.map +1 -1
- package/lib/types/AvatarMiddleware.d.ts +2 -2
- package/lib/types/AvatarMiddleware.d.ts.map +1 -1
- package/lib/types/CardActionMiddleware.d.ts +4 -2
- package/lib/types/CardActionMiddleware.d.ts.map +1 -1
- package/lib/types/GroupActivitiesMiddleware.d.ts +7 -7
- package/lib/types/GroupActivitiesMiddleware.d.ts.map +1 -1
- package/lib/types/WebSpeechPonyfill.d.ts +1 -0
- package/lib/types/WebSpeechPonyfill.d.ts.map +1 -1
- package/lib/utils/createCustomEvent.d.ts.map +1 -1
- package/lib/utils/createCustomEvent.js +8 -2
- package/lib/utils/findLastIndex.d.ts +2 -0
- package/lib/utils/findLastIndex.d.ts.map +1 -0
- package/lib/utils/findLastIndex.js +32 -0
- package/lib/utils/findMin.js +1 -1
- package/lib/utils/mapMap.d.ts.map +1 -1
- package/lib/utils/mapMap.js +9 -2
- package/lib/utils/randomId.d.ts.map +1 -1
- package/lib/utils/randomId.js +1 -1
- package/package.json +26 -29
- package/src/StyleOptions.ts +295 -14
- package/src/defaultStyleOptions.ts +71 -13
- package/src/hooks/Composer.tsx +90 -54
- package/src/hooks/index.ts +20 -0
- package/src/hooks/internal/WebChatAPIContext.ts +3 -3
- package/src/hooks/internal/useCreateActivityRendererInternal.ts +21 -20
- package/src/hooks/internal/useDebugDeps.js +9 -2
- package/src/hooks/internal/usePrevious.ts +11 -0
- package/src/hooks/internal/useValueRef.ts +21 -0
- package/src/hooks/middleware/concatMiddleware.ts +6 -4
- package/src/hooks/middleware/createDefaultCardActionMiddleware.ts +29 -27
- package/src/hooks/middleware/createDefaultGroupActivitiesMiddleware.ts +18 -6
- package/src/hooks/useActiveTyping.ts +5 -3
- package/src/hooks/useActivities.ts +2 -2
- package/src/hooks/useActivityKeys.ts +3 -0
- package/src/hooks/useActivityKeysByRead.ts +3 -0
- package/src/hooks/useCreateActivityStatusRenderer.tsx +65 -34
- package/src/hooks/useCreateAvatarRenderer.ts +24 -20
- package/src/hooks/useDateFormatter.ts +4 -3
- package/src/hooks/useGetActivityByKey.ts +3 -0
- package/src/hooks/useGetHasAcknowledgedByActivityKey.ts +3 -0
- package/src/hooks/useGetKeyByActivity.ts +3 -0
- package/src/hooks/useGetKeyByActivityId.ts +3 -0
- package/src/hooks/useGetSendTimeoutForActivity.ts +9 -8
- package/src/hooks/useGroupActivities.ts +4 -8
- package/src/hooks/useLastAcknowledgedActivityKey.ts +3 -0
- package/src/hooks/useLastReadActivityKey.ts +3 -0
- package/src/hooks/useLocalizer.ts +7 -2
- package/src/hooks/useMarkActivityAsSpoken.ts +2 -2
- package/src/hooks/useMarkActivityKeyAsRead.ts +3 -0
- package/src/hooks/useMarkAllAsAcknowledged.ts +3 -0
- package/src/hooks/usePerformCardAction.ts +2 -3
- package/src/hooks/usePostActivity.ts +2 -2
- package/src/hooks/useSendFiles.ts +8 -1
- package/src/hooks/useSendTimeoutForActivity.ts +2 -2
- package/src/hooks/useSubmitSendBox.ts +2 -5
- package/src/hooks/useSuggestedActions.ts +1 -1
- package/src/hooks/useTimeoutForSend.ts +2 -2
- package/src/localization/Localize.ts +9 -2
- package/src/localization/ar-SA.json +23 -4
- package/src/localization/bg-BG.json +23 -4
- package/src/localization/ca-ES.json +23 -4
- package/src/localization/cs-CZ.json +23 -4
- package/src/localization/da-DK.json +23 -4
- package/src/localization/de-DE.json +23 -4
- package/src/localization/el-GR.json +23 -4
- package/src/localization/en-US.json +34 -9
- package/src/localization/es-ES.json +23 -4
- package/src/localization/et-EE.json +23 -4
- package/src/localization/eu-ES.json +23 -4
- package/src/localization/fi-FI.json +23 -4
- package/src/localization/fr-FR.json +23 -4
- package/src/localization/gl-ES.json +23 -4
- package/src/localization/he-IL.json +23 -4
- package/src/localization/hi-IN.json +23 -4
- package/src/localization/hr-HR.json +23 -4
- package/src/localization/hu-HU.json +23 -4
- package/src/localization/id-ID.json +23 -4
- package/src/localization/it-IT.json +23 -4
- package/src/localization/ja-JP.json +23 -4
- package/src/localization/kk-KZ.json +23 -4
- package/src/localization/ko-KR.json +23 -4
- package/src/localization/lt-LT.json +23 -4
- package/src/localization/lv-LV.json +23 -4
- package/src/localization/mergeLocalizedStrings.ts +7 -1
- package/src/localization/ms-MY.json +23 -4
- package/src/localization/nb-NO.json +23 -4
- package/src/localization/nl-NL.json +23 -4
- package/src/localization/pl-PL.json +23 -4
- package/src/localization/pt-BR.json +23 -4
- package/src/localization/pt-PT.json +23 -4
- package/src/localization/ro-RO.json +23 -4
- package/src/localization/ru-RU.json +23 -4
- package/src/localization/sk-SK.json +23 -4
- package/src/localization/sl-SI.json +23 -4
- package/src/localization/sr-Cyrl-CS.json +23 -4
- package/src/localization/sr-Latn-CS.json +23 -4
- package/src/localization/sv-SE.json +23 -4
- package/src/localization/th-TH.json +23 -4
- package/src/localization/tr-TR.json +23 -4
- package/src/localization/uk-UA.json +23 -4
- package/src/localization/vi-VN.json +23 -4
- package/src/localization/yue.json +26 -7
- package/src/localization/zh-CN.json +23 -4
- package/src/localization/zh-HK.json +23 -4
- package/src/localization/zh-TW.json +23 -4
- package/src/normalizeStyleOptions.ts +70 -0
- package/src/patchStyleOptionsFromDeprecatedProps.js +0 -2
- package/src/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.tsx +180 -0
- package/src/providers/ActivityAcknowledgement/private/Context.ts +18 -0
- package/src/providers/ActivityAcknowledgement/private/types.ts +6 -0
- package/src/providers/ActivityAcknowledgement/private/useContext.ts +19 -0
- package/src/providers/ActivityAcknowledgement/useActivityKeysByRead.tsx +8 -0
- package/src/providers/ActivityAcknowledgement/useGetHasAcknowledgedByActivityKey.ts +5 -0
- package/src/providers/ActivityAcknowledgement/useLastAcknowledgedActivityKey.ts +5 -0
- package/src/providers/ActivityAcknowledgement/useLastReadActivityKey.ts +5 -0
- package/src/providers/ActivityAcknowledgement/useMarkActivityKeyAsRead.ts +5 -0
- package/src/providers/ActivityAcknowledgement/useMarkAllAsAcknowledged.ts +5 -0
- package/src/providers/ActivityKeyer/ActivityKeyerComposer.tsx +150 -0
- package/src/providers/ActivityKeyer/private/Context.ts +13 -0
- package/src/providers/ActivityKeyer/private/getActivityId.ts +5 -0
- package/src/providers/ActivityKeyer/private/getClientActivityId.ts +5 -0
- package/src/providers/ActivityKeyer/private/uniqueId.ts +8 -0
- package/src/providers/ActivityKeyer/private/useContext.ts +15 -0
- package/src/providers/ActivityKeyer/useActivityKeys.ts +5 -0
- package/src/providers/ActivityKeyer/useGetActivityByKey.ts +7 -0
- package/src/providers/ActivityKeyer/useGetKeyByActivity.ts +7 -0
- package/src/providers/ActivityKeyer/useGetKeyByActivityId.ts +5 -0
- package/src/types/ActivityMiddleware.ts +3 -3
- package/src/types/ActivityStatusMiddleware.ts +3 -3
- package/src/types/AttachmentForScreenReaderMiddleware.ts +2 -2
- package/src/types/AttachmentMiddleware.ts +2 -2
- package/src/types/AvatarMiddleware.ts +2 -2
- package/src/types/CardActionMiddleware.ts +2 -2
- package/src/types/GroupActivitiesMiddleware.ts +7 -7
- package/src/utils/createCustomEvent.ts +7 -1
- package/src/utils/findLastIndex.spec.js +31 -0
- package/src/utils/findLastIndex.ts +11 -0
- package/src/utils/mapMap.ts +7 -1
- package/src/utils/randomId.ts +1 -1
- package/.eslintignore +0 -1
package/src/hooks/Composer.tsx
CHANGED
|
@@ -2,18 +2,14 @@ import { Provider } from 'react-redux';
|
|
|
2
2
|
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
|
-
|
|
6
5
|
import {
|
|
7
6
|
clearSuggestedActions,
|
|
8
7
|
connect as createConnectAction,
|
|
9
8
|
createStore,
|
|
10
|
-
DirectLineActivity,
|
|
11
|
-
DirectLineJSBotConnection,
|
|
12
9
|
disconnect,
|
|
13
10
|
dismissNotification,
|
|
14
11
|
emitTypingIndicator,
|
|
15
12
|
markActivity,
|
|
16
|
-
OneOrMany,
|
|
17
13
|
postActivity,
|
|
18
14
|
sendEvent,
|
|
19
15
|
sendFiles,
|
|
@@ -34,8 +30,11 @@ import {
|
|
|
34
30
|
stopSpeakingActivity,
|
|
35
31
|
submitSendBox
|
|
36
32
|
} from 'botframework-webchat-core';
|
|
33
|
+
import type { DirectLineJSBotConnection, OneOrMany, WebChatActivity } from 'botframework-webchat-core';
|
|
37
34
|
|
|
38
35
|
import { default as WebChatAPIContext } from './internal/WebChatAPIContext';
|
|
36
|
+
import ActivityAcknowledgementComposer from '../providers/ActivityAcknowledgement/ActivityAcknowledgementComposer';
|
|
37
|
+
import ActivityKeyerComposer from '../providers/ActivityKeyer/ActivityKeyerComposer';
|
|
39
38
|
import ActivityMiddleware from '../types/ActivityMiddleware';
|
|
40
39
|
import ActivityStatusMiddleware from '../types/ActivityStatusMiddleware';
|
|
41
40
|
import AttachmentForScreenReaderMiddleware from '../types/AttachmentForScreenReaderMiddleware';
|
|
@@ -63,6 +62,7 @@ import TelemetryMeasurementEvent, { TelemetryExceptionMeasurementEvent } from '.
|
|
|
63
62
|
import ToastMiddleware from '../types/ToastMiddleware';
|
|
64
63
|
import Tracker from './internal/Tracker';
|
|
65
64
|
import TypingIndicatorMiddleware from '../types/TypingIndicatorMiddleware';
|
|
65
|
+
import useMarkAllAsAcknowledged from './useMarkAllAsAcknowledged';
|
|
66
66
|
import WebChatReduxContext, { useDispatch } from './internal/WebChatReduxContext';
|
|
67
67
|
|
|
68
68
|
import applyMiddleware, {
|
|
@@ -98,7 +98,7 @@ const DISPATCHERS = {
|
|
|
98
98
|
submitSendBox
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
function createCardActionContext({ cardActionMiddleware, directLine, dispatch }) {
|
|
101
|
+
function createCardActionContext({ cardActionMiddleware, directLine, dispatch, markAllAsAcknowledged }) {
|
|
102
102
|
const runMiddleware = applyMiddleware(
|
|
103
103
|
'card action',
|
|
104
104
|
...singleToArray(cardActionMiddleware),
|
|
@@ -106,8 +106,10 @@ function createCardActionContext({ cardActionMiddleware, directLine, dispatch })
|
|
|
106
106
|
)({ dispatch });
|
|
107
107
|
|
|
108
108
|
return {
|
|
109
|
-
onCardAction: (cardAction, { target }: { target?: any } = {}) =>
|
|
110
|
-
|
|
109
|
+
onCardAction: (cardAction, { target }: { target?: any } = {}) => {
|
|
110
|
+
markAllAsAcknowledged();
|
|
111
|
+
|
|
112
|
+
return runMiddleware({
|
|
111
113
|
cardAction,
|
|
112
114
|
getSignInUrl:
|
|
113
115
|
cardAction.type === 'signin'
|
|
@@ -131,7 +133,8 @@ function createCardActionContext({ cardActionMiddleware, directLine, dispatch })
|
|
|
131
133
|
}
|
|
132
134
|
: null,
|
|
133
135
|
target
|
|
134
|
-
})
|
|
136
|
+
});
|
|
137
|
+
}
|
|
135
138
|
};
|
|
136
139
|
}
|
|
137
140
|
|
|
@@ -167,6 +170,12 @@ function mergeStringsOverrides(localizedStrings, language, overrideLocalizedStri
|
|
|
167
170
|
return { ...localizedStrings, ...overrideLocalizedStrings };
|
|
168
171
|
}
|
|
169
172
|
|
|
173
|
+
// It seems "react/require-default-props" did not pick up `ComposerCore.defaultProps`.
|
|
174
|
+
// And it falsely complaint `optional?: string` must have a corresponding `ComposerCore.defaultProps.optional = undefined`, even we already set it below.
|
|
175
|
+
// Since we set both TypeScript `Props` class and `ComposerCore.propTypes`, this check will be done there as well.
|
|
176
|
+
// Ignoring it in TypeScript version should be safe, as we have `propTypes` version to protect us.
|
|
177
|
+
|
|
178
|
+
/* eslint-disable react/require-default-props */
|
|
170
179
|
type ComposerCoreProps = {
|
|
171
180
|
activityMiddleware?: OneOrMany<ActivityMiddleware>;
|
|
172
181
|
activityStatusMiddleware?: OneOrMany<ActivityStatusMiddleware>;
|
|
@@ -182,13 +191,12 @@ type ComposerCoreProps = {
|
|
|
182
191
|
grammars?: any;
|
|
183
192
|
groupActivitiesMiddleware?: OneOrMany<GroupActivitiesMiddleware>;
|
|
184
193
|
internalErrorBoxClass?: React.Component | Function;
|
|
185
|
-
internalRenderErrorBox?: any;
|
|
186
194
|
locale?: string;
|
|
187
195
|
onTelemetry?: (event: TelemetryMeasurementEvent) => void;
|
|
188
196
|
overrideLocalizedStrings?: LocalizedStrings | ((strings: LocalizedStrings, language: string) => LocalizedStrings);
|
|
189
197
|
renderMarkdown?: (markdown: string, { markdownRespectCRLF: boolean }, { externalLinkAlt: string }) => string;
|
|
190
198
|
scrollToEndButtonMiddleware?: OneOrMany<ScrollToEndButtonMiddleware>;
|
|
191
|
-
selectVoice?: (voices: typeof window.SpeechSynthesisVoice[], activity:
|
|
199
|
+
selectVoice?: (voices: typeof window.SpeechSynthesisVoice[], activity: WebChatActivity) => void;
|
|
192
200
|
sendTypingIndicator?: boolean;
|
|
193
201
|
styleOptions?: StyleOptions;
|
|
194
202
|
toastMiddleware?: OneOrMany<ToastMiddleware>;
|
|
@@ -213,6 +221,7 @@ type ComposerCoreProps = {
|
|
|
213
221
|
/** @deprecated Please use "typingIndicatorRenderer" instead. */
|
|
214
222
|
typingIndicatorRenderer?: any; // TODO: [P4] Remove on or after 2022-06-15.
|
|
215
223
|
};
|
|
224
|
+
/* eslint-enable react/require-default-props */
|
|
216
225
|
|
|
217
226
|
const ComposerCore: FC<ComposerCoreProps> = ({
|
|
218
227
|
activityMiddleware,
|
|
@@ -289,16 +298,17 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
289
298
|
};
|
|
290
299
|
}, [dispatch, directLine, userID, username]);
|
|
291
300
|
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
dispatch
|
|
296
|
-
|
|
301
|
+
const markAllAsAcknowledged = useMarkAllAsAcknowledged();
|
|
302
|
+
|
|
303
|
+
const cardActionContext = useMemo(
|
|
304
|
+
() => createCardActionContext({ cardActionMiddleware, directLine, dispatch, markAllAsAcknowledged }),
|
|
305
|
+
[cardActionMiddleware, directLine, dispatch, markAllAsAcknowledged]
|
|
306
|
+
);
|
|
297
307
|
|
|
298
|
-
const patchedSelectVoice = useMemo(
|
|
299
|
-
locale,
|
|
300
|
-
selectVoice
|
|
301
|
-
|
|
308
|
+
const patchedSelectVoice = useMemo(
|
|
309
|
+
() => selectVoice || defaultSelectVoice.bind(null, { language: locale }),
|
|
310
|
+
[locale, selectVoice]
|
|
311
|
+
);
|
|
302
312
|
|
|
303
313
|
const groupActivitiesContext = useMemo(
|
|
304
314
|
() =>
|
|
@@ -310,7 +320,13 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
310
320
|
);
|
|
311
321
|
|
|
312
322
|
const hoistedDispatchers = useMemo(
|
|
313
|
-
() =>
|
|
323
|
+
() =>
|
|
324
|
+
mapMap(
|
|
325
|
+
DISPATCHERS,
|
|
326
|
+
dispatcher =>
|
|
327
|
+
(...args) =>
|
|
328
|
+
dispatch(dispatcher(...args))
|
|
329
|
+
),
|
|
314
330
|
[dispatch]
|
|
315
331
|
);
|
|
316
332
|
|
|
@@ -358,13 +374,15 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
358
374
|
'activity',
|
|
359
375
|
{ strict: false },
|
|
360
376
|
...singleToArray(activityMiddleware),
|
|
361
|
-
() =>
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
377
|
+
() =>
|
|
378
|
+
() =>
|
|
379
|
+
({ activity }) => {
|
|
380
|
+
if (activity) {
|
|
381
|
+
throw new Error(`No renderer for activity of type "${activity.type}"`);
|
|
382
|
+
} else {
|
|
383
|
+
throw new Error('No activity to render');
|
|
384
|
+
}
|
|
366
385
|
}
|
|
367
|
-
}
|
|
368
386
|
)({})
|
|
369
387
|
);
|
|
370
388
|
}, [activityMiddleware, activityRenderer]);
|
|
@@ -392,19 +410,21 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
392
410
|
'attachment for screen reader',
|
|
393
411
|
{ strict: true },
|
|
394
412
|
...singleToArray(attachmentForScreenReaderMiddleware),
|
|
395
|
-
() =>
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
413
|
+
() =>
|
|
414
|
+
() =>
|
|
415
|
+
({ attachment }) => {
|
|
416
|
+
if (attachment) {
|
|
417
|
+
console.warn(`No renderer for attachment for screen reader of type "${attachment.contentType}"`);
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return () => {
|
|
422
|
+
/**
|
|
423
|
+
* @todo TODO: [P4] Might be able to throw without returning a function -- investigate and possibly fix
|
|
424
|
+
*/
|
|
425
|
+
throw new Error('No attachment to render');
|
|
426
|
+
};
|
|
399
427
|
}
|
|
400
|
-
|
|
401
|
-
return () => {
|
|
402
|
-
/**
|
|
403
|
-
* @todo TODO: [P4] Might be able to throw without returning a function -- investigate and possibly fix
|
|
404
|
-
*/
|
|
405
|
-
throw new Error('No attachment to render');
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
428
|
)({}),
|
|
409
429
|
[attachmentForScreenReaderMiddleware]
|
|
410
430
|
);
|
|
@@ -422,13 +442,15 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
422
442
|
return applyMiddlewareForLegacyRenderer(
|
|
423
443
|
'attachment',
|
|
424
444
|
...singleToArray(attachmentMiddleware),
|
|
425
|
-
() =>
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
445
|
+
() =>
|
|
446
|
+
() =>
|
|
447
|
+
({ attachment }) => {
|
|
448
|
+
if (attachment) {
|
|
449
|
+
throw new Error(`No renderer for attachment of type "${attachment.contentType}"`);
|
|
450
|
+
} else {
|
|
451
|
+
throw new Error('No attachment to render');
|
|
452
|
+
}
|
|
430
453
|
}
|
|
431
|
-
}
|
|
432
454
|
)({});
|
|
433
455
|
}, [attachmentMiddleware, attachmentRenderer]);
|
|
434
456
|
|
|
@@ -440,8 +462,11 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
440
462
|
|
|
441
463
|
return (
|
|
442
464
|
avatarRenderer ||
|
|
443
|
-
applyMiddlewareForRenderer(
|
|
444
|
-
|
|
465
|
+
applyMiddlewareForRenderer(
|
|
466
|
+
'avatar',
|
|
467
|
+
{ strict: false },
|
|
468
|
+
...singleToArray(avatarMiddleware),
|
|
469
|
+
() => () => () => false
|
|
445
470
|
)({})
|
|
446
471
|
);
|
|
447
472
|
}, [avatarMiddleware, avatarRenderer]);
|
|
@@ -458,13 +483,15 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
458
483
|
'toast',
|
|
459
484
|
{ strict: false },
|
|
460
485
|
...singleToArray(toastMiddleware),
|
|
461
|
-
() =>
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
486
|
+
() =>
|
|
487
|
+
() =>
|
|
488
|
+
({ notification }) => {
|
|
489
|
+
if (notification) {
|
|
490
|
+
throw new Error(`No renderer for notification of type "${notification.contentType}"`);
|
|
491
|
+
} else {
|
|
492
|
+
throw new Error('No notification to render');
|
|
493
|
+
}
|
|
466
494
|
}
|
|
467
|
-
}
|
|
468
495
|
)({})
|
|
469
496
|
);
|
|
470
497
|
}, [toastMiddleware, toastRenderer]);
|
|
@@ -636,6 +663,8 @@ ComposerCore.propTypes = {
|
|
|
636
663
|
cardActionMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
|
|
637
664
|
children: PropTypes.any,
|
|
638
665
|
dir: PropTypes.oneOf(['auto', 'ltr', 'rtl']),
|
|
666
|
+
// PropTypes.shape({ ... }) did not honor isRequired for its members.
|
|
667
|
+
// @ts-ignore
|
|
639
668
|
directLine: PropTypes.shape({
|
|
640
669
|
activity$: PropTypes.shape({
|
|
641
670
|
subscribe: PropTypes.func.isRequired
|
|
@@ -672,7 +701,10 @@ ComposerCore.propTypes = {
|
|
|
672
701
|
username: PropTypes.string
|
|
673
702
|
};
|
|
674
703
|
|
|
675
|
-
type ComposerProps = ComposerCoreProps & {
|
|
704
|
+
type ComposerProps = ComposerCoreProps & {
|
|
705
|
+
internalRenderErrorBox?: any;
|
|
706
|
+
store?: any;
|
|
707
|
+
};
|
|
676
708
|
|
|
677
709
|
// We will create a Redux store if it was not passed in
|
|
678
710
|
const Composer: FC<ComposerProps> = ({ internalRenderErrorBox, onTelemetry, store, ...props }) => {
|
|
@@ -696,7 +728,11 @@ const Composer: FC<ComposerProps> = ({ internalRenderErrorBox, onTelemetry, stor
|
|
|
696
728
|
) : (
|
|
697
729
|
<ErrorBoundary onError={handleError}>
|
|
698
730
|
<Provider context={WebChatReduxContext} store={memoizedStore}>
|
|
699
|
-
<
|
|
731
|
+
<ActivityKeyerComposer>
|
|
732
|
+
<ActivityAcknowledgementComposer>
|
|
733
|
+
<ComposerCore onTelemetry={onTelemetry} {...props} />
|
|
734
|
+
</ActivityAcknowledgementComposer>
|
|
735
|
+
</ActivityKeyerComposer>
|
|
700
736
|
</Provider>
|
|
701
737
|
</ErrorBoundary>
|
|
702
738
|
);
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import useActiveTyping from './useActiveTyping';
|
|
2
2
|
import useActivities from './useActivities';
|
|
3
|
+
import useActivityKeys from './useActivityKeys';
|
|
4
|
+
import useActivityKeysByRead from './useActivityKeysByRead';
|
|
3
5
|
import useAvatarForBot from './useAvatarForBot';
|
|
4
6
|
import useAvatarForUser from './useAvatarForUser';
|
|
5
7
|
import useByteFormatter from './useByteFormatter';
|
|
@@ -17,16 +19,24 @@ import useDirection from './useDirection';
|
|
|
17
19
|
import useDisabled from './useDisabled';
|
|
18
20
|
import useDismissNotification from './useDismissNotification';
|
|
19
21
|
import useEmitTypingIndicator from './useEmitTypingIndicator';
|
|
22
|
+
import useGetActivityByKey from './useGetActivityByKey';
|
|
23
|
+
import useGetHasAcknowledgedByActivityKey from './useGetHasAcknowledgedByActivityKey';
|
|
24
|
+
import useGetKeyByActivity from './useGetKeyByActivity';
|
|
25
|
+
import useGetKeyByActivityId from './useGetKeyByActivityId';
|
|
20
26
|
import useGetSendTimeoutForActivity from './useGetSendTimeoutForActivity';
|
|
21
27
|
import useGrammars from './useGrammars';
|
|
22
28
|
import useGroupActivities from './useGroupActivities';
|
|
23
29
|
import useGroupTimestamp from './useGroupTimestamp';
|
|
24
30
|
import useLanguage from './useLanguage';
|
|
31
|
+
import useLastAcknowledgedActivityKey from './useLastAcknowledgedActivityKey';
|
|
32
|
+
import useLastReadActivityKey from './useLastReadActivityKey';
|
|
25
33
|
import useLastTypingAt from './useLastTypingAt';
|
|
26
34
|
import useLocalize from './useLocalize'; // Deprecated on or after 2022-02-12
|
|
27
35
|
import useLocalizeDate from './useLocalizeDate'; // Deprecated on or after 2022-02-12
|
|
28
36
|
import useLocalizer from './useLocalizer';
|
|
29
37
|
import useMarkActivityAsSpoken from './useMarkActivityAsSpoken';
|
|
38
|
+
import useMarkActivityKeyAsRead from './useMarkActivityKeyAsRead';
|
|
39
|
+
import useMarkAllAsAcknowledged from './useMarkAllAsAcknowledged';
|
|
30
40
|
import usePerformCardAction from './usePerformCardAction';
|
|
31
41
|
import usePostActivity from './usePostActivity';
|
|
32
42
|
import useReferenceGrammarID from './useReferenceGrammarID';
|
|
@@ -64,6 +74,8 @@ import useVoiceSelector from './useVoiceSelector';
|
|
|
64
74
|
export {
|
|
65
75
|
useActiveTyping,
|
|
66
76
|
useActivities,
|
|
77
|
+
useActivityKeys,
|
|
78
|
+
useActivityKeysByRead,
|
|
67
79
|
useAvatarForBot,
|
|
68
80
|
useAvatarForUser,
|
|
69
81
|
useByteFormatter,
|
|
@@ -81,16 +93,24 @@ export {
|
|
|
81
93
|
useDisabled,
|
|
82
94
|
useDismissNotification,
|
|
83
95
|
useEmitTypingIndicator,
|
|
96
|
+
useGetActivityByKey,
|
|
97
|
+
useGetHasAcknowledgedByActivityKey,
|
|
98
|
+
useGetKeyByActivity,
|
|
99
|
+
useGetKeyByActivityId,
|
|
84
100
|
useGetSendTimeoutForActivity,
|
|
85
101
|
useGrammars,
|
|
86
102
|
useGroupActivities,
|
|
87
103
|
useGroupTimestamp,
|
|
88
104
|
useLanguage,
|
|
105
|
+
useLastAcknowledgedActivityKey,
|
|
106
|
+
useLastReadActivityKey,
|
|
89
107
|
useLastTypingAt,
|
|
90
108
|
useLocalize,
|
|
91
109
|
useLocalizeDate,
|
|
92
110
|
useLocalizer,
|
|
93
111
|
useMarkActivityAsSpoken,
|
|
112
|
+
useMarkActivityKeyAsRead,
|
|
113
|
+
useMarkAllAsAcknowledged,
|
|
94
114
|
usePerformCardAction,
|
|
95
115
|
usePostActivity,
|
|
96
116
|
useReferenceGrammarID,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { DirectLineJSBotConnection, WebChatActivity } from 'botframework-webchat-core';
|
|
3
3
|
|
|
4
4
|
import { AttachmentForScreenReaderComponentFactory } from '../../types/AttachmentForScreenReaderMiddleware';
|
|
5
5
|
import { AvatarComponentFactory } from '../../types/AvatarMiddleware';
|
|
@@ -38,10 +38,10 @@ type WebChatAPIContext = {
|
|
|
38
38
|
markActivity?: ({ id: string }, name: string, value?: any) => void;
|
|
39
39
|
onCardAction?: PerformCardAction;
|
|
40
40
|
onTelemetry?: (event: TelemetryMeasurementEvent) => void;
|
|
41
|
-
postActivity?: (activity:
|
|
41
|
+
postActivity?: (activity: WebChatActivity) => Observable<string>;
|
|
42
42
|
renderMarkdown?: (markdown: string, { markdownRespectCRLF: boolean }, { externalLinkAlt: string }) => string;
|
|
43
43
|
scrollToEndButtonRenderer?: ScrollToEndButtonComponentFactory;
|
|
44
|
-
selectVoice?: (voices: typeof window.SpeechSynthesisVoice[], activity:
|
|
44
|
+
selectVoice?: (voices: typeof window.SpeechSynthesisVoice[], activity: WebChatActivity) => void;
|
|
45
45
|
sendEvent?: (name: string, value: any) => void;
|
|
46
46
|
sendFiles?: (files: File[]) => void;
|
|
47
47
|
sendMessage?: (text: string, method?: string, { channelData }?: { channelData?: any }) => void;
|
|
@@ -14,32 +14,33 @@ export default function useCreateActivityRendererInternal(
|
|
|
14
14
|
const renderAttachment: RenderAttachment = renderAttachmentOverride || defaultRenderAttachment;
|
|
15
15
|
|
|
16
16
|
return useMemo(
|
|
17
|
-
() =>
|
|
18
|
-
|
|
17
|
+
() =>
|
|
18
|
+
(...createActivityRendererOptions) => {
|
|
19
|
+
const renderActivity = createActivityRenderer(...createActivityRendererOptions);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return renderActivityOptions => {
|
|
25
|
-
if (isValidElement(renderActivity)) {
|
|
26
|
-
return renderActivity;
|
|
21
|
+
if (!renderActivity) {
|
|
22
|
+
return false;
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
return renderActivityOptions => {
|
|
26
|
+
if (isValidElement(renderActivity)) {
|
|
27
|
+
return renderActivity;
|
|
28
|
+
}
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'botframework-webchat: To hide an activity, the activity renderer should return false. It should not return a function that will return false when called.'
|
|
30
|
+
const activityElement = renderActivity(
|
|
31
|
+
(...renderAttachmentArgs) => renderAttachment(...renderAttachmentArgs),
|
|
32
|
+
renderActivityOptions
|
|
38
33
|
);
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
// "activityElement" cannot be false. If the middleware want to hide the "activityElement", it should return "false" when we call createActivityRenderer().
|
|
36
|
+
activityElement ||
|
|
37
|
+
console.warn(
|
|
38
|
+
'botframework-webchat: To hide an activity, the activity renderer should return false. It should not return a function that will return false when called.'
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return activityElement;
|
|
42
|
+
};
|
|
43
|
+
},
|
|
43
44
|
[createActivityRenderer, renderAttachment]
|
|
44
45
|
);
|
|
45
46
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint no-console: "off" */
|
|
2
2
|
|
|
3
|
+
import { isForbiddenPropertyNames } from 'botframework-webchat-core';
|
|
3
4
|
import { useRef } from 'react';
|
|
4
5
|
|
|
5
6
|
export default function useDebugDeps(depsMap, name) {
|
|
@@ -7,13 +8,19 @@ export default function useDebugDeps(depsMap, name) {
|
|
|
7
8
|
|
|
8
9
|
const { current: lastDepsMap } = lastDepsMapRef;
|
|
9
10
|
const keys = new Set([...Object.keys(depsMap), ...Object.keys(lastDepsMap)]);
|
|
10
|
-
const keysChanged = Array.from(keys).filter(
|
|
11
|
+
const keysChanged = Array.from(keys).filter(
|
|
12
|
+
// Mitigation through denylisting.
|
|
13
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
14
|
+
key => !isForbiddenPropertyNames(key) && !Object.is(depsMap[key], lastDepsMap[key])
|
|
15
|
+
);
|
|
11
16
|
|
|
12
17
|
if (keysChanged.length) {
|
|
13
18
|
console.groupCollapsed(`Changes found in ${name}`);
|
|
14
19
|
|
|
15
20
|
keysChanged.forEach(key => {
|
|
16
|
-
|
|
21
|
+
// Mitigation through denylisting.
|
|
22
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
23
|
+
isForbiddenPropertyNames(key) || console.log(key, { from: lastDepsMap[key], to: depsMap[key] });
|
|
17
24
|
});
|
|
18
25
|
|
|
19
26
|
console.groupEnd();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RefObject, useMemo, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
export default function useValueRef<T>(value: T): RefObject<T> {
|
|
4
|
+
const ref = useRef<T>();
|
|
5
|
+
const readOnlyRef = useMemo(
|
|
6
|
+
() =>
|
|
7
|
+
Object.create(
|
|
8
|
+
{},
|
|
9
|
+
{
|
|
10
|
+
current: {
|
|
11
|
+
get: () => ref.current
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
),
|
|
15
|
+
[]
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
ref.current = value;
|
|
19
|
+
|
|
20
|
+
return readOnlyRef;
|
|
21
|
+
}
|
|
@@ -13,11 +13,13 @@ export default function concatMiddleware<Setup, Result>(
|
|
|
13
13
|
|
|
14
14
|
return last => {
|
|
15
15
|
const stack = setup.slice();
|
|
16
|
-
const work =
|
|
17
|
-
|
|
16
|
+
const work =
|
|
17
|
+
(index: number) =>
|
|
18
|
+
(...runArgs) => {
|
|
19
|
+
const next = stack[+index];
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
return (next ? next(work(index + 1)) : last)(...runArgs);
|
|
22
|
+
};
|
|
21
23
|
|
|
22
24
|
return work(0);
|
|
23
25
|
};
|
|
@@ -3,38 +3,40 @@ import { sendMessage, sendMessageBack, sendPostBack } from 'botframework-webchat
|
|
|
3
3
|
import CardActionMiddleware from '../../types/CardActionMiddleware';
|
|
4
4
|
|
|
5
5
|
export default function createDefaultCardActionMiddleware(): CardActionMiddleware {
|
|
6
|
-
return ({ dispatch }) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// We cannot use destructured "type" here because TypeScript don't recognize "messageBack" is "MessageBackCardAction".
|
|
15
|
-
switch (cardAction.type) {
|
|
16
|
-
case 'imBack':
|
|
17
|
-
if (typeof value === 'string') {
|
|
18
|
-
// TODO: [P4] Instead of calling dispatch, we should move to dispatchers instead for completeness
|
|
19
|
-
dispatch(sendMessage(value, 'imBack'));
|
|
20
|
-
} else {
|
|
21
|
-
throw new Error('cannot send "imBack" with a non-string value');
|
|
6
|
+
return ({ dispatch }) =>
|
|
7
|
+
next =>
|
|
8
|
+
(...args) => {
|
|
9
|
+
const [
|
|
10
|
+
{
|
|
11
|
+
cardAction,
|
|
12
|
+
cardAction: { value }
|
|
22
13
|
}
|
|
14
|
+
] = args;
|
|
15
|
+
|
|
16
|
+
// We cannot use destructured "type" here because TypeScript don't recognize "messageBack" is "MessageBackCardAction".
|
|
17
|
+
switch (cardAction.type) {
|
|
18
|
+
case 'imBack':
|
|
19
|
+
if (typeof value === 'string') {
|
|
20
|
+
// TODO: [P4] Instead of calling dispatch, we should move to dispatchers instead for completeness
|
|
21
|
+
dispatch(sendMessage(value, 'imBack'));
|
|
22
|
+
} else {
|
|
23
|
+
throw new Error('cannot send "imBack" with a non-string value');
|
|
24
|
+
}
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
break;
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
case 'messageBack':
|
|
29
|
+
dispatch(sendMessageBack(value, cardAction.text, cardAction.displayText));
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
break;
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
case 'postBack':
|
|
34
|
+
dispatch(sendPostBack(value));
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
break;
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
default:
|
|
39
|
+
return next(...args);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
40
42
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Constants
|
|
1
|
+
import { Constants } from 'botframework-webchat-core';
|
|
2
|
+
import type { WebChatActivity } from 'botframework-webchat-core';
|
|
2
3
|
|
|
3
4
|
import GroupActivitiesMiddleware from '../../types/GroupActivitiesMiddleware';
|
|
4
5
|
|
|
5
6
|
const {
|
|
6
|
-
ActivityClientState: { SENT }
|
|
7
|
+
ActivityClientState: { SENDING, SEND_FAILED, SENT }
|
|
7
8
|
} = Constants;
|
|
8
9
|
|
|
9
10
|
function bin<T>(items: T[], grouping: (last: T, current: T) => boolean): T[][] {
|
|
@@ -25,13 +26,24 @@ function bin<T>(items: T[], grouping: (last: T, current: T) => boolean): T[][] {
|
|
|
25
26
|
return bins;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
function sending(activity
|
|
29
|
-
|
|
29
|
+
function sending(activity) {
|
|
30
|
+
if (activity.from.role === 'user') {
|
|
31
|
+
const state = activity.channelData?.state;
|
|
32
|
+
|
|
33
|
+
switch (state) {
|
|
34
|
+
case SENDING:
|
|
35
|
+
case SEND_FAILED:
|
|
36
|
+
return state;
|
|
37
|
+
|
|
38
|
+
default:
|
|
39
|
+
return SENT;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
30
42
|
}
|
|
31
43
|
|
|
32
44
|
function shouldGroupTimestamp(
|
|
33
|
-
activityX:
|
|
34
|
-
activityY:
|
|
45
|
+
activityX: WebChatActivity,
|
|
46
|
+
activityY: WebChatActivity,
|
|
35
47
|
groupTimestamp: boolean | number
|
|
36
48
|
): boolean {
|
|
37
49
|
if (groupTimestamp === false) {
|
|
@@ -10,15 +10,17 @@ function useActiveTyping(expireAfter?: number): [{ [userId: string]: Typing }] {
|
|
|
10
10
|
|
|
11
11
|
const [{ typingAnimationDuration }] = useStyleOptions();
|
|
12
12
|
const forceRender = useForceRender();
|
|
13
|
-
const typing: { [userId: string]: { at: number; name: string; role: string } } = useSelector(
|
|
13
|
+
const typing: { [userId: string]: { at: number; last: number; name: string; role: string } } = useSelector(
|
|
14
|
+
({ typing }) => typing
|
|
15
|
+
);
|
|
14
16
|
|
|
15
17
|
if (typeof expireAfter !== 'number') {
|
|
16
18
|
expireAfter = typingAnimationDuration;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
const activeTyping: { [userId: string]: Typing } = Object.entries(typing).reduce(
|
|
20
|
-
(activeTyping, [id, { at, name, role }]) => {
|
|
21
|
-
const until =
|
|
22
|
+
(activeTyping, [id, { at, last, name, role }]) => {
|
|
23
|
+
const until = last + expireAfter;
|
|
22
24
|
|
|
23
25
|
if (until > now) {
|
|
24
26
|
return { ...activeTyping, [id]: { at, expireAt: until, name, role } };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { WebChatActivity } from 'botframework-webchat-core';
|
|
2
2
|
|
|
3
3
|
import { useSelector } from './internal/WebChatReduxContext';
|
|
4
4
|
|
|
5
|
-
export default function useActivities(): [
|
|
5
|
+
export default function useActivities(): [WebChatActivity[]] {
|
|
6
6
|
return [useSelector(({ activities }) => activities)];
|
|
7
7
|
}
|