botframework-webchat-api 4.18.1-main.20260518.2a3d1d3 → 4.18.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/decorator.js +1 -1
- package/dist/botframework-webchat-api.d.mts +1250 -173
- package/dist/botframework-webchat-api.decorator.d.mts +26 -71
- package/dist/botframework-webchat-api.decorator.mjs +2 -1
- package/dist/botframework-webchat-api.decorator.mjs.LEGAL.txt +0 -0
- package/dist/botframework-webchat-api.decorator.mjs.map +1 -1
- package/dist/botframework-webchat-api.internal.d.mts +1 -66
- package/dist/botframework-webchat-api.internal.mjs +2 -1
- package/dist/botframework-webchat-api.internal.mjs.LEGAL.txt +0 -0
- package/dist/botframework-webchat-api.internal.mjs.map +1 -1
- package/dist/botframework-webchat-api.mjs +139 -1
- package/dist/botframework-webchat-api.mjs.LEGAL.txt +27 -2
- package/dist/botframework-webchat-api.mjs.map +1 -1
- package/dist/chunk-2S76JUVM.mjs +3 -0
- package/dist/chunk-2S76JUVM.mjs.LEGAL.txt +0 -0
- package/dist/chunk-2S76JUVM.mjs.map +1 -0
- package/dist/{chunk-VAX7AB37.mjs → chunk-J6D5YEY6.mjs} +2 -1
- package/dist/chunk-J6D5YEY6.mjs.LEGAL.txt +0 -0
- package/dist/chunk-ZAMHKQQC.mjs +3 -0
- package/dist/chunk-ZAMHKQQC.mjs.LEGAL.txt +0 -0
- package/dist/chunk-ZAMHKQQC.mjs.map +1 -0
- package/dist/metafile-esm.json +1 -1
- package/internal.js +1 -1
- package/lib/StyleOptions.d.ts +697 -0
- package/lib/StyleOptions.d.ts.map +1 -0
- package/lib/StyleOptions.js +2 -0
- package/lib/decorator/index.d.ts +5 -0
- package/lib/decorator/index.d.ts.map +1 -0
- package/lib/decorator/index.js +28 -0
- package/lib/decorator/private/ActivityBorderDecoratorMiddleware.d.ts +27 -0
- package/lib/decorator/private/ActivityBorderDecoratorMiddleware.d.ts.map +1 -0
- package/lib/decorator/private/ActivityBorderDecoratorMiddleware.js +19 -0
- package/lib/decorator/private/ActivityDecorator.d.ts +9 -0
- package/lib/decorator/private/ActivityDecorator.d.ts.map +1 -0
- package/lib/decorator/private/ActivityDecorator.js +36 -0
- package/lib/decorator/private/DecoratorComposer.d.ts +3 -0
- package/lib/decorator/private/DecoratorComposer.d.ts.map +1 -0
- package/lib/decorator/private/DecoratorComposer.js +13 -0
- package/lib/decorator/private/activityDecoratorRequest.d.ts +6 -0
- package/lib/decorator/private/activityDecoratorRequest.d.ts.map +1 -0
- package/lib/decorator/private/activityDecoratorRequest.js +2 -0
- package/lib/decorator/private/createDecoratorComposer.d.ts +11 -0
- package/lib/decorator/private/createDecoratorComposer.d.ts.map +1 -0
- package/lib/decorator/private/createDecoratorComposer.js +27 -0
- package/lib/decorator/private/templateMiddleware.d.ts +30 -0
- package/lib/decorator/private/templateMiddleware.d.ts.map +1 -0
- package/lib/decorator/private/templateMiddleware.js +53 -0
- package/lib/decorator/private/templateMiddleware.test.d.ts +3 -0
- package/lib/decorator/private/templateMiddleware.test.d.ts.map +1 -0
- package/lib/defaultStyleOptions.d.ts +4 -0
- package/lib/defaultStyleOptions.d.ts.map +1 -0
- package/lib/defaultStyleOptions.js +277 -0
- package/lib/external/PrecompiledGlobalize.js +6361 -0
- package/lib/hooks/Composer.d.ts +88 -0
- package/lib/hooks/Composer.d.ts.map +1 -0
- package/lib/hooks/Composer.js +605 -0
- package/lib/hooks/index.d.ts +73 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/index.js +504 -0
- package/lib/hooks/internal/ErrorBox.js +47 -0
- package/lib/hooks/internal/SendBoxMiddleware.d.ts +37 -0
- package/lib/hooks/internal/SendBoxMiddleware.d.ts.map +1 -0
- package/lib/hooks/internal/SendBoxMiddleware.js +17 -0
- package/lib/hooks/internal/SendBoxToolbarMiddleware.d.ts +37 -0
- package/lib/hooks/internal/SendBoxToolbarMiddleware.d.ts.map +1 -0
- package/lib/hooks/internal/SendBoxToolbarMiddleware.js +17 -0
- package/lib/hooks/internal/Tracker.d.ts +4 -0
- package/lib/hooks/internal/Tracker.d.ts.map +1 -0
- package/lib/hooks/internal/Tracker.js +15 -0
- package/lib/hooks/internal/WebChatAPIContext.d.ts +80 -0
- package/lib/hooks/internal/WebChatAPIContext.d.ts.map +1 -0
- package/lib/hooks/internal/WebChatAPIContext.js +12 -0
- package/lib/hooks/internal/WebChatReduxContext.js +17 -0
- package/lib/hooks/internal/defaultSelectVoice.js +28 -0
- package/lib/hooks/internal/private/templateMiddleware.d.ts +3 -0
- package/lib/hooks/internal/private/templateMiddleware.d.ts.map +1 -0
- package/lib/hooks/internal/private/templateMiddleware.js +12 -0
- 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 +37 -0
- package/lib/hooks/internal/useDebugDeps.js +39 -0
- package/lib/hooks/internal/useDirFromProps.js +12 -0
- package/lib/hooks/internal/useErrorBoxClass.js +14 -0
- package/lib/hooks/internal/useForceRender.js +24 -0
- package/lib/hooks/internal/useLocalizedGlobalize.js +12 -0
- package/lib/hooks/internal/useLocalizedStrings.js +14 -0
- package/lib/hooks/internal/useMarkActivity.js +12 -0
- package/lib/hooks/internal/usePrevious.d.ts +3 -0
- package/lib/hooks/internal/usePrevious.d.ts.map +1 -0
- package/lib/hooks/internal/usePrevious.js +15 -0
- package/lib/hooks/internal/useReadTelemetryDimensions.js +20 -0
- package/lib/hooks/internal/useSetDictateState.d.ts +2 -0
- package/lib/hooks/internal/useSetDictateState.d.ts.map +1 -0
- package/lib/hooks/internal/useSetDictateState.js +12 -0
- package/lib/hooks/internal/useTimer.d.ts +5 -0
- package/lib/hooks/internal/useTimer.d.ts.map +1 -0
- package/lib/hooks/internal/useTimer.js +43 -0
- package/lib/hooks/internal/useTracker.js +42 -0
- 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 +22 -0
- package/lib/hooks/internal/useWebChatAPIContext.d.ts +83 -0
- package/lib/hooks/internal/useWebChatAPIContext.d.ts.map +1 -0
- package/lib/hooks/internal/useWebChatAPIContext.js +17 -0
- package/lib/hooks/middleware/UserlandBoundary.js +48 -0
- package/lib/hooks/middleware/applyMiddleware.js +122 -0
- 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 +33 -0
- 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 +43 -0
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.d.ts +7 -0
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.d.ts.map +1 -0
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.js +68 -0
- package/lib/hooks/private/numberWithInfinity.d.ts +3 -0
- package/lib/hooks/private/numberWithInfinity.d.ts.map +1 -0
- package/lib/hooks/private/numberWithInfinity.js +17 -0
- package/lib/hooks/private/numberWithInfinity.spec.d.ts +2 -0
- package/lib/hooks/private/numberWithInfinity.spec.d.ts.map +1 -0
- package/lib/hooks/private/reduceIterable.d.ts +2 -0
- package/lib/hooks/private/reduceIterable.d.ts.map +1 -0
- package/lib/hooks/private/reduceIterable.js +26 -0
- package/lib/hooks/private/reduceIterable.spec.d.ts +2 -0
- package/lib/hooks/private/reduceIterable.spec.d.ts.map +1 -0
- package/lib/hooks/useActiveTyping.d.ts +4 -0
- package/lib/hooks/useActiveTyping.d.ts.map +1 -0
- package/lib/hooks/useActiveTyping.js +81 -0
- package/lib/hooks/useActivities.d.ts +3 -0
- package/lib/hooks/useActivities.d.ts.map +1 -0
- package/lib/hooks/useActivities.js +14 -0
- package/lib/hooks/useActivityKeys.d.ts +3 -0
- package/lib/hooks/useActivityKeys.d.ts.map +1 -0
- package/lib/hooks/useActivityKeys.js +11 -0
- package/lib/hooks/useActivityKeysByRead.d.ts +3 -0
- package/lib/hooks/useActivityKeysByRead.d.ts.map +1 -0
- package/lib/hooks/useActivityKeysByRead.js +11 -0
- package/lib/hooks/useAvatarForBot.d.ts +5 -0
- package/lib/hooks/useAvatarForBot.d.ts.map +1 -0
- package/lib/hooks/useAvatarForBot.js +26 -0
- package/lib/hooks/useAvatarForUser.d.ts +5 -0
- package/lib/hooks/useAvatarForUser.d.ts.map +1 -0
- package/lib/hooks/useAvatarForUser.js +26 -0
- package/lib/hooks/useByteFormatter.d.ts +2 -0
- package/lib/hooks/useByteFormatter.d.ts.map +1 -0
- package/lib/hooks/useByteFormatter.js +43 -0
- package/lib/hooks/useConnectivityStatus.d.ts +2 -0
- package/lib/hooks/useConnectivityStatus.d.ts.map +1 -0
- package/lib/hooks/useConnectivityStatus.js +14 -0
- package/lib/hooks/useCreateActivityRenderer.d.ts +3 -0
- package/lib/hooks/useCreateActivityRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateActivityRenderer.js +14 -0
- package/lib/hooks/useCreateActivityStatusRenderer.d.ts +10 -0
- package/lib/hooks/useCreateActivityStatusRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateActivityStatusRenderer.js +72 -0
- package/lib/hooks/useCreateAttachmentForScreenReaderRenderer.d.ts +3 -0
- package/lib/hooks/useCreateAttachmentForScreenReaderRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateAttachmentForScreenReaderRenderer.js +12 -0
- package/lib/hooks/useCreateAvatarRenderer.d.ts +6 -0
- package/lib/hooks/useCreateAvatarRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateAvatarRenderer.js +44 -0
- package/lib/hooks/useCreateScrollToEndButtonRenderer.d.ts +3 -0
- package/lib/hooks/useCreateScrollToEndButtonRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateScrollToEndButtonRenderer.js +12 -0
- package/lib/hooks/useDateFormatter.d.ts +2 -0
- package/lib/hooks/useDateFormatter.d.ts.map +1 -0
- package/lib/hooks/useDateFormatter.js +35 -0
- package/lib/hooks/useDebouncedNotifications.d.ts +13 -0
- package/lib/hooks/useDebouncedNotifications.d.ts.map +1 -0
- package/lib/hooks/useDebouncedNotifications.js +118 -0
- package/lib/hooks/useDictateInterims.d.ts +2 -0
- package/lib/hooks/useDictateInterims.d.ts.map +1 -0
- package/lib/hooks/useDictateInterims.js +16 -0
- package/lib/hooks/useDictateState.d.ts +2 -0
- package/lib/hooks/useDictateState.d.ts.map +1 -0
- package/lib/hooks/useDictateState.js +15 -0
- package/lib/hooks/useDirection.d.ts +2 -0
- package/lib/hooks/useDirection.d.ts.map +1 -0
- package/lib/hooks/useDirection.js +38 -0
- package/lib/hooks/useDisabled.d.ts +2 -0
- package/lib/hooks/useDisabled.d.ts.map +1 -0
- package/lib/hooks/useDisabled.js +12 -0
- package/lib/hooks/useDismissNotification.d.ts +2 -0
- package/lib/hooks/useDismissNotification.d.ts.map +1 -0
- package/lib/hooks/useDismissNotification.js +12 -0
- package/lib/hooks/useEmitTypingIndicator.d.ts +2 -0
- package/lib/hooks/useEmitTypingIndicator.d.ts.map +1 -0
- package/lib/hooks/useEmitTypingIndicator.js +12 -0
- package/lib/hooks/useGetActivitiesByKey.d.ts +3 -0
- package/lib/hooks/useGetActivitiesByKey.d.ts.map +1 -0
- package/lib/hooks/useGetActivitiesByKey.js +11 -0
- package/lib/hooks/useGetActivityByKey.d.ts +3 -0
- package/lib/hooks/useGetActivityByKey.d.ts.map +1 -0
- package/lib/hooks/useGetActivityByKey.js +11 -0
- package/lib/hooks/useGetHasAcknowledgedByActivityKey.d.ts +3 -0
- package/lib/hooks/useGetHasAcknowledgedByActivityKey.d.ts.map +1 -0
- package/lib/hooks/useGetHasAcknowledgedByActivityKey.js +11 -0
- package/lib/hooks/useGetKeyByActivity.d.ts +3 -0
- package/lib/hooks/useGetKeyByActivity.d.ts.map +1 -0
- package/lib/hooks/useGetKeyByActivity.js +11 -0
- package/lib/hooks/useGetKeyByActivityId.d.ts +3 -0
- package/lib/hooks/useGetKeyByActivityId.d.ts.map +1 -0
- package/lib/hooks/useGetKeyByActivityId.js +11 -0
- package/lib/hooks/useGetSendTimeoutForActivity.d.ts +5 -0
- package/lib/hooks/useGetSendTimeoutForActivity.d.ts.map +1 -0
- package/lib/hooks/useGetSendTimeoutForActivity.js +33 -0
- package/lib/hooks/useGrammars.d.ts +2 -0
- package/lib/hooks/useGrammars.d.ts.map +1 -0
- package/lib/hooks/useGrammars.js +12 -0
- package/lib/hooks/useGroupActivities.d.ts +8 -0
- package/lib/hooks/useGroupActivities.d.ts.map +1 -0
- package/lib/hooks/useGroupActivities.js +12 -0
- package/lib/hooks/useGroupTimestamp.d.ts +2 -0
- package/lib/hooks/useGroupTimestamp.d.ts.map +1 -0
- package/lib/hooks/useGroupTimestamp.js +21 -0
- package/lib/hooks/useLanguage.d.ts +2 -0
- package/lib/hooks/useLanguage.d.ts.map +1 -0
- package/lib/hooks/useLanguage.js +19 -0
- package/lib/hooks/useLastAcknowledgedActivityKey.d.ts +3 -0
- package/lib/hooks/useLastAcknowledgedActivityKey.d.ts.map +1 -0
- package/lib/hooks/useLastAcknowledgedActivityKey.js +11 -0
- package/lib/hooks/useLastReadActivityKey.d.ts +3 -0
- package/lib/hooks/useLastReadActivityKey.d.ts.map +1 -0
- package/lib/hooks/useLastReadActivityKey.js +11 -0
- package/lib/hooks/useLocalizer.d.ts +13 -0
- package/lib/hooks/useLocalizer.d.ts.map +1 -0
- package/lib/hooks/useLocalizer.js +75 -0
- package/lib/hooks/useMarkActivityAsSpoken.d.ts +3 -0
- package/lib/hooks/useMarkActivityAsSpoken.d.ts.map +1 -0
- package/lib/hooks/useMarkActivityAsSpoken.js +16 -0
- package/lib/hooks/useMarkActivityKeyAsRead.d.ts +3 -0
- package/lib/hooks/useMarkActivityKeyAsRead.d.ts.map +1 -0
- package/lib/hooks/useMarkActivityKeyAsRead.js +11 -0
- package/lib/hooks/useMarkAllAsAcknowledged.d.ts +3 -0
- package/lib/hooks/useMarkAllAsAcknowledged.d.ts.map +1 -0
- package/lib/hooks/useMarkAllAsAcknowledged.js +11 -0
- package/lib/hooks/useNotifications.d.ts +3 -0
- package/lib/hooks/useNotifications.d.ts.map +1 -0
- package/lib/hooks/useNotifications.js +14 -0
- package/lib/hooks/usePerformCardAction.d.ts +3 -0
- package/lib/hooks/usePerformCardAction.d.ts.map +1 -0
- package/lib/hooks/usePerformCardAction.js +12 -0
- package/lib/hooks/usePonyfill.d.ts +3 -0
- package/lib/hooks/usePonyfill.d.ts.map +1 -0
- package/lib/hooks/usePonyfill.js +11 -0
- package/lib/hooks/usePostActivity.d.ts +3 -0
- package/lib/hooks/usePostActivity.d.ts.map +1 -0
- package/lib/hooks/usePostActivity.js +12 -0
- package/lib/hooks/useReferenceGrammarID.d.ts +2 -0
- package/lib/hooks/useReferenceGrammarID.d.ts.map +1 -0
- package/lib/hooks/useReferenceGrammarID.js +14 -0
- package/lib/hooks/useRelativeTimeFormatter.d.ts +2 -0
- package/lib/hooks/useRelativeTimeFormatter.d.ts.map +1 -0
- package/lib/hooks/useRelativeTimeFormatter.js +61 -0
- package/lib/hooks/useRenderAttachment.d.ts +3 -0
- package/lib/hooks/useRenderAttachment.d.ts.map +1 -0
- package/lib/hooks/useRenderAttachment.js +14 -0
- package/lib/hooks/useRenderToast.d.ts +3 -0
- package/lib/hooks/useRenderToast.d.ts.map +1 -0
- package/lib/hooks/useRenderToast.js +12 -0
- package/lib/hooks/useRenderTypingIndicator.d.ts +3 -0
- package/lib/hooks/useRenderTypingIndicator.d.ts.map +1 -0
- package/lib/hooks/useRenderTypingIndicator.js +12 -0
- package/lib/hooks/useSendBoxAttachments.d.ts +6 -0
- package/lib/hooks/useSendBoxAttachments.d.ts.map +1 -0
- package/lib/hooks/useSendBoxAttachments.js +23 -0
- package/lib/hooks/useSendBoxValue.d.ts +2 -0
- package/lib/hooks/useSendBoxValue.d.ts.map +1 -0
- package/lib/hooks/useSendBoxValue.js +16 -0
- package/lib/hooks/useSendEvent.d.ts +2 -0
- package/lib/hooks/useSendEvent.d.ts.map +1 -0
- package/lib/hooks/useSendEvent.js +12 -0
- package/lib/hooks/useSendFiles.d.ts +10 -0
- package/lib/hooks/useSendFiles.d.ts.map +1 -0
- package/lib/hooks/useSendFiles.js +35 -0
- package/lib/hooks/useSendMessage.d.ts +6 -0
- package/lib/hooks/useSendMessage.d.ts.map +1 -0
- package/lib/hooks/useSendMessage.js +33 -0
- package/lib/hooks/useSendMessageBack.d.ts +2 -0
- package/lib/hooks/useSendMessageBack.d.ts.map +1 -0
- package/lib/hooks/useSendMessageBack.js +12 -0
- package/lib/hooks/useSendPostBack.d.ts +2 -0
- package/lib/hooks/useSendPostBack.d.ts.map +1 -0
- package/lib/hooks/useSendPostBack.js +12 -0
- package/lib/hooks/useSendStatusByActivityKey.d.ts +22 -0
- package/lib/hooks/useSendStatusByActivityKey.d.ts.map +1 -0
- package/lib/hooks/useSendStatusByActivityKey.js +31 -0
- package/lib/hooks/useSendTimeoutForActivity.d.ts +4 -0
- package/lib/hooks/useSendTimeoutForActivity.d.ts.map +1 -0
- package/lib/hooks/useSendTimeoutForActivity.js +22 -0
- package/lib/hooks/useSendTypingIndicator.d.ts +2 -0
- package/lib/hooks/useSendTypingIndicator.d.ts.map +1 -0
- package/lib/hooks/useSendTypingIndicator.js +14 -0
- package/lib/hooks/useSetNotification.d.ts +3 -0
- package/lib/hooks/useSetNotification.d.ts.map +1 -0
- package/lib/hooks/useSetNotification.js +12 -0
- package/lib/hooks/useShouldSpeakIncomingActivity.d.ts +2 -0
- package/lib/hooks/useShouldSpeakIncomingActivity.d.ts.map +1 -0
- package/lib/hooks/useShouldSpeakIncomingActivity.js +22 -0
- package/lib/hooks/useStartDictate.d.ts +2 -0
- package/lib/hooks/useStartDictate.d.ts.map +1 -0
- package/lib/hooks/useStartDictate.js +12 -0
- package/lib/hooks/useStopDictate.d.ts +2 -0
- package/lib/hooks/useStopDictate.d.ts.map +1 -0
- package/lib/hooks/useStopDictate.js +12 -0
- package/lib/hooks/useStyleOptions.d.ts +3 -0
- package/lib/hooks/useStyleOptions.d.ts.map +1 -0
- package/lib/hooks/useStyleOptions.js +12 -0
- package/lib/hooks/useSubmitSendBox.d.ts +4 -0
- package/lib/hooks/useSubmitSendBox.d.ts.map +1 -0
- package/lib/hooks/useSubmitSendBox.js +49 -0
- package/lib/hooks/useSuggestedActions.d.ts +3 -0
- package/lib/hooks/useSuggestedActions.d.ts.map +1 -0
- package/lib/hooks/useSuggestedActions.js +25 -0
- package/lib/hooks/useTimeoutForSend.d.ts +3 -0
- package/lib/hooks/useTimeoutForSend.d.ts.map +1 -0
- package/lib/hooks/useTimeoutForSend.js +21 -0
- package/lib/hooks/useTrackDimension.d.ts +2 -0
- package/lib/hooks/useTrackDimension.d.ts.map +1 -0
- package/lib/hooks/useTrackDimension.js +14 -0
- package/lib/hooks/useTrackEvent.d.ts +10 -0
- package/lib/hooks/useTrackEvent.d.ts.map +1 -0
- package/lib/hooks/useTrackEvent.js +51 -0
- package/lib/hooks/useTrackException.d.ts +2 -0
- package/lib/hooks/useTrackException.d.ts.map +1 -0
- package/lib/hooks/useTrackException.js +31 -0
- package/lib/hooks/useTrackTiming.d.ts +2 -0
- package/lib/hooks/useTrackTiming.d.ts.map +1 -0
- package/lib/hooks/useTrackTiming.js +93 -0
- package/lib/hooks/useUserID.d.ts +2 -0
- package/lib/hooks/useUserID.d.ts.map +1 -0
- package/lib/hooks/useUserID.js +12 -0
- package/lib/hooks/useUsername.d.ts +2 -0
- package/lib/hooks/useUsername.d.ts.map +1 -0
- package/lib/hooks/useUsername.js +12 -0
- package/lib/hooks/useVoiceSelector.d.ts +2 -0
- package/lib/hooks/useVoiceSelector.d.ts.map +1 -0
- package/lib/hooks/useVoiceSelector.js +16 -0
- package/lib/hooks/utils/ErrorBoundary.js +68 -0
- 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 +28 -0
- package/lib/index.d.ts +37 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +88 -0
- package/lib/internal.d.ts +3 -0
- package/lib/internal.d.ts.map +1 -0
- package/lib/internal.js +14 -0
- package/lib/localization/Localize.d.ts +4 -0
- package/lib/localization/Localize.d.ts.map +1 -0
- package/lib/localization/Localize.js +50 -0
- package/lib/localization/ar-EG.json +42 -0
- package/lib/localization/ar-JO.json +45 -0
- package/lib/localization/ar-SA.json +112 -0
- package/lib/localization/bg-BG.json +112 -0
- package/lib/localization/ca-ES.json +112 -0
- package/lib/localization/cs-CZ.json +112 -0
- package/lib/localization/da-DK.json +112 -0
- package/lib/localization/de-DE.json +112 -0
- package/lib/localization/el-GR.json +112 -0
- package/lib/localization/en-US.json +183 -0
- package/lib/localization/es-ES.json +112 -0
- package/lib/localization/et-EE.json +112 -0
- package/lib/localization/eu-ES.json +112 -0
- package/lib/localization/fi-FI.json +112 -0
- package/lib/localization/fr-FR.json +112 -0
- package/lib/localization/getAllLocalizedStrings.d.ts +6 -0
- package/lib/localization/getAllLocalizedStrings.d.ts.map +1 -0
- package/lib/localization/getAllLocalizedStrings.js +117 -0
- package/lib/localization/getRTLList.d.ts +2 -0
- package/lib/localization/getRTLList.d.ts.map +1 -0
- package/lib/localization/getRTLList.js +46 -0
- package/lib/localization/gl-ES.json +112 -0
- package/lib/localization/he-IL.json +112 -0
- package/lib/localization/hi-IN.json +112 -0
- package/lib/localization/hr-HR.json +112 -0
- package/lib/localization/hu-HU.json +112 -0
- package/lib/localization/id-ID.json +112 -0
- package/lib/localization/it-IT.json +112 -0
- package/lib/localization/ja-JP.json +112 -0
- package/lib/localization/kk-KZ.json +112 -0
- package/lib/localization/ko-KR.json +112 -0
- package/lib/localization/lt-LT.json +112 -0
- package/lib/localization/lv-LV.json +112 -0
- package/lib/localization/mergeLocalizedStrings.d.ts +7 -0
- package/lib/localization/mergeLocalizedStrings.d.ts.map +1 -0
- package/lib/localization/mergeLocalizedStrings.js +49 -0
- package/lib/localization/ms-MY.json +112 -0
- package/lib/localization/nb-NO.json +112 -0
- package/lib/localization/nl-NL.json +112 -0
- package/lib/localization/overrides.json +257 -0
- package/lib/localization/pl-PL.json +112 -0
- package/lib/localization/pt-BR.json +112 -0
- package/lib/localization/pt-PT.json +112 -0
- package/lib/localization/ro-RO.json +112 -0
- package/lib/localization/ru-RU.json +112 -0
- package/lib/localization/sk-SK.json +112 -0
- package/lib/localization/sl-SI.json +112 -0
- package/lib/localization/sl-SL.json +3 -0
- package/lib/localization/sr-Cyrl-CS.json +112 -0
- package/lib/localization/sr-Cyrl.json +3 -0
- package/lib/localization/sr-Latn-CS.json +112 -0
- package/lib/localization/sr-Latn.json +3 -0
- package/lib/localization/sv-SE.json +112 -0
- package/lib/localization/th-TH.json +112 -0
- package/lib/localization/tr-TR.json +112 -0
- package/lib/localization/uk-UA.json +112 -0
- package/lib/localization/vi-VN.json +112 -0
- package/lib/localization/yue.json +115 -0
- package/lib/localization/zh-CN.json +112 -0
- package/lib/localization/zh-HK.json +112 -0
- package/lib/localization/zh-TW.json +112 -0
- package/lib/normalizeStyleOptions.d.ts +3 -0
- package/lib/normalizeStyleOptions.d.ts.map +1 -0
- package/lib/normalizeStyleOptions.js +147 -0
- package/lib/patchStyleOptionsFromDeprecatedProps.js +21 -0
- package/lib/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.d.ts +6 -0
- package/lib/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.js +153 -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 +14 -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 +18 -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 +15 -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 +12 -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 +12 -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 +12 -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 +12 -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 +12 -0
- package/lib/providers/ActivityKeyer/ActivityKeyerComposer.d.ts +20 -0
- package/lib/providers/ActivityKeyer/ActivityKeyerComposer.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/ActivityKeyerComposer.js +149 -0
- package/lib/providers/ActivityKeyer/private/Context.d.ts +13 -0
- package/lib/providers/ActivityKeyer/private/Context.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/Context.js +10 -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 +10 -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 +11 -0
- package/lib/providers/ActivityKeyer/private/lastOf.d.ts +2 -0
- package/lib/providers/ActivityKeyer/private/lastOf.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/lastOf.js +10 -0
- package/lib/providers/ActivityKeyer/private/lastOf.spec.d.ts +2 -0
- package/lib/providers/ActivityKeyer/private/lastOf.spec.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/someIterable.d.ts +2 -0
- package/lib/providers/ActivityKeyer/private/someIterable.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/someIterable.js +27 -0
- package/lib/providers/ActivityKeyer/private/someIterable.spec.d.ts +2 -0
- package/lib/providers/ActivityKeyer/private/someIterable.spec.d.ts.map +1 -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 +15 -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 +18 -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 +12 -0
- package/lib/providers/ActivityKeyer/useGetActivitiesByKey.d.ts +3 -0
- package/lib/providers/ActivityKeyer/useGetActivitiesByKey.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/useGetActivitiesByKey.js +12 -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 +12 -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 +12 -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 +12 -0
- package/lib/providers/ActivityListener/ActivityListenerComposer.d.ts +7 -0
- package/lib/providers/ActivityListener/ActivityListenerComposer.d.ts.map +1 -0
- package/lib/providers/ActivityListener/ActivityListenerComposer.js +55 -0
- package/lib/providers/ActivityListener/private/Context.d.ts +8 -0
- package/lib/providers/ActivityListener/private/Context.d.ts.map +1 -0
- package/lib/providers/ActivityListener/private/Context.js +15 -0
- package/lib/providers/ActivityListener/private/useContext.d.ts +2 -0
- package/lib/providers/ActivityListener/private/useContext.d.ts.map +1 -0
- package/lib/providers/ActivityListener/private/useContext.js +13 -0
- package/lib/providers/ActivityListener/useUpsertedActivities.d.ts +3 -0
- package/lib/providers/ActivityListener/useUpsertedActivities.d.ts.map +1 -0
- package/lib/providers/ActivityListener/useUpsertedActivities.js +12 -0
- package/lib/providers/ActivitySendStatus/ActivitySendStatusComposer.d.ts +4 -0
- package/lib/providers/ActivitySendStatus/ActivitySendStatusComposer.d.ts.map +1 -0
- package/lib/providers/ActivitySendStatus/ActivitySendStatusComposer.js +149 -0
- package/lib/providers/ActivitySendStatus/private/Context.d.ts +9 -0
- package/lib/providers/ActivitySendStatus/private/Context.d.ts.map +1 -0
- package/lib/providers/ActivitySendStatus/private/Context.js +13 -0
- package/lib/providers/ActivitySendStatus/private/isMapEqual.d.ts +7 -0
- package/lib/providers/ActivitySendStatus/private/isMapEqual.d.ts.map +1 -0
- package/lib/providers/ActivitySendStatus/private/isMapEqual.js +55 -0
- package/lib/providers/ActivitySendStatus/private/useContext.d.ts +3 -0
- package/lib/providers/ActivitySendStatus/private/useContext.d.ts.map +1 -0
- package/lib/providers/ActivitySendStatus/private/useContext.js +18 -0
- package/lib/providers/ActivitySendStatus/useSendStatusByActivityKey.d.ts +22 -0
- package/lib/providers/ActivitySendStatus/useSendStatusByActivityKey.d.ts.map +1 -0
- package/lib/providers/ActivitySendStatus/useSendStatusByActivityKey.js +31 -0
- package/lib/providers/ActivitySendStatusTelemetry/ActivitySendStatusTelemetryComposer.d.ts +3 -0
- package/lib/providers/ActivitySendStatusTelemetry/ActivitySendStatusTelemetryComposer.d.ts.map +1 -0
- package/lib/providers/ActivitySendStatusTelemetry/ActivitySendStatusTelemetryComposer.js +71 -0
- package/lib/providers/ActivityTyping/ActivityTypingComposer.d.ts +9 -0
- package/lib/providers/ActivityTyping/ActivityTypingComposer.d.ts.map +1 -0
- package/lib/providers/ActivityTyping/ActivityTypingComposer.js +98 -0
- package/lib/providers/ActivityTyping/private/Context.d.ts +8 -0
- package/lib/providers/ActivityTyping/private/Context.d.ts.map +1 -0
- package/lib/providers/ActivityTyping/private/Context.js +15 -0
- package/lib/providers/ActivityTyping/private/useContext.d.ts +3 -0
- package/lib/providers/ActivityTyping/private/useContext.d.ts.map +1 -0
- package/lib/providers/ActivityTyping/private/useContext.js +13 -0
- package/lib/providers/ActivityTyping/private/useMemoWithPrevious.d.ts +3 -0
- package/lib/providers/ActivityTyping/private/useMemoWithPrevious.d.ts.map +1 -0
- package/lib/providers/ActivityTyping/private/useMemoWithPrevious.js +22 -0
- package/lib/providers/ActivityTyping/types/AllTyping.d.ts +9 -0
- package/lib/providers/ActivityTyping/types/AllTyping.d.ts.map +1 -0
- package/lib/providers/ActivityTyping/types/AllTyping.js +2 -0
- package/lib/providers/ActivityTyping/useAllTyping.d.ts +3 -0
- package/lib/providers/ActivityTyping/useAllTyping.d.ts.map +1 -0
- package/lib/providers/ActivityTyping/useAllTyping.js +12 -0
- package/lib/providers/Ponyfill/PonyfillComposer.d.ts +17 -0
- package/lib/providers/Ponyfill/PonyfillComposer.d.ts.map +1 -0
- package/lib/providers/Ponyfill/PonyfillComposer.js +87 -0
- package/lib/providers/Ponyfill/private/PonyfillContext.d.ts +8 -0
- package/lib/providers/Ponyfill/private/PonyfillContext.d.ts.map +1 -0
- package/lib/providers/Ponyfill/private/PonyfillContext.js +10 -0
- package/lib/providers/Ponyfill/private/useContext.d.ts +6 -0
- package/lib/providers/Ponyfill/private/useContext.d.ts.map +1 -0
- package/lib/providers/Ponyfill/private/useContext.js +17 -0
- package/lib/providers/Ponyfill/usePonyfill.d.ts +3 -0
- package/lib/providers/Ponyfill/usePonyfill.d.ts.map +1 -0
- package/lib/providers/Ponyfill/usePonyfill.js +12 -0
- package/lib/tsconfig.json +18 -0
- package/lib/types/ActivityMiddleware.d.ts +24 -0
- package/lib/types/ActivityMiddleware.d.ts.map +1 -0
- package/lib/types/ActivityMiddleware.js +2 -0
- package/lib/types/ActivityStatusMiddleware.d.ts +17 -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 +19 -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/ContextOf.d.ts +4 -0
- package/lib/types/ContextOf.d.ts.map +1 -0
- package/lib/types/ContextOf.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/SendStatus.d.ts +3 -0
- package/lib/types/SendStatus.d.ts.map +1 -0
- package/lib/types/SendStatus.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 +19 -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 +34 -0
- package/lib/utils/findLastIndex.d.ts +2 -0
- package/lib/utils/findLastIndex.d.ts.map +1 -0
- package/lib/utils/findLastIndex.js +22 -0
- package/lib/utils/findMin.d.ts +7 -0
- package/lib/utils/findMin.d.ts.map +1 -0
- package/lib/utils/findMin.js +46 -0
- package/lib/utils/freezeArray.d.ts +8 -0
- package/lib/utils/freezeArray.d.ts.map +1 -0
- package/lib/utils/freezeArray.js +19 -0
- package/lib/utils/isObject.js +12 -0
- package/lib/utils/mapMap.d.ts +6 -0
- package/lib/utils/mapMap.d.ts.map +1 -0
- package/lib/utils/mapMap.js +27 -0
- package/lib/utils/normalizeLanguage.d.ts +2 -0
- package/lib/utils/normalizeLanguage.d.ts.map +1 -0
- package/lib/utils/normalizeLanguage.js +115 -0
- package/lib/utils/randomId.d.ts +2 -0
- package/lib/utils/randomId.d.ts.map +1 -0
- package/lib/utils/randomId.js +15 -0
- package/lib/utils/warnOnce.d.ts +2 -0
- package/lib/utils/warnOnce.d.ts.map +1 -0
- package/lib/utils/warnOnce.js +16 -0
- package/package.json +90 -158
- package/src/StyleOptions.ts +285 -400
- package/src/decorator/index.ts +4 -0
- package/src/decorator/private/ActivityBorderDecoratorMiddleware.ts +31 -0
- package/src/decorator/private/ActivityDecorator.tsx +31 -0
- package/src/decorator/private/DecoratorComposer.tsx +6 -0
- package/src/decorator/private/activityDecoratorRequest.ts +6 -0
- package/src/decorator/private/createDecoratorComposer.tsx +36 -0
- package/src/{middleware → decorator}/private/templateMiddleware.test.tsx +17 -19
- package/src/decorator/private/templateMiddleware.ts +58 -0
- package/src/defaultStyleOptions.ts +23 -40
- package/src/hooks/Composer.tsx +142 -204
- package/src/hooks/index.ts +2 -19
- package/src/hooks/internal/ErrorBox.js +34 -0
- package/src/hooks/internal/SendBoxMiddleware.ts +21 -0
- package/src/hooks/internal/SendBoxToolbarMiddleware.ts +21 -0
- package/src/hooks/internal/Tracker.ts +1 -1
- package/src/hooks/internal/WebChatAPIContext.ts +12 -7
- package/src/hooks/internal/WebChatReduxContext.js +2 -3
- package/src/hooks/internal/private/templateMiddleware.ts +4 -0
- package/src/hooks/internal/useCreateActivityRendererInternal.ts +46 -0
- package/src/hooks/internal/useDebugDeps.js +30 -0
- package/src/hooks/internal/useErrorBoxClass.js +7 -0
- package/src/hooks/middleware/UserlandBoundary.js +2 -2
- package/src/hooks/middleware/applyMiddleware.js +5 -5
- package/src/hooks/middleware/concatMiddleware.spec.js +0 -20
- package/src/hooks/middleware/concatMiddleware.ts +6 -7
- package/src/hooks/middleware/createDefaultGroupActivitiesMiddleware.ts +75 -0
- package/src/hooks/private/reduceIterable.spec.ts +2 -0
- package/src/hooks/useActiveTyping.ts +2 -3
- package/src/hooks/useActivities.ts +3 -62
- package/src/hooks/useCreateActivityRenderer.ts +6 -27
- package/src/hooks/useCreateActivityStatusRenderer.tsx +33 -13
- package/src/hooks/useCreateAvatarRenderer.ts +33 -19
- package/src/hooks/useDebouncedNotifications.spec.js +0 -1
- package/src/hooks/useDisabled.ts +2 -8
- package/src/hooks/useGroupActivities.ts +10 -0
- package/src/hooks/useLocalizer.ts +3 -3
- package/src/hooks/useRenderAttachment.ts +2 -2
- package/src/hooks/useSendBoxAttachments.ts +0 -2
- package/src/hooks/useSendFiles.ts +1 -1
- package/src/hooks/useSendTimeoutForActivity.ts +0 -2
- package/src/hooks/useStyleOptions.ts +6 -1
- package/src/hooks/useSuggestedActions.ts +23 -9
- package/src/hooks/useTrackEvent.ts +3 -3
- package/src/index.ts +94 -52
- package/src/internal.ts +3 -0
- package/src/localization/ar-SA.json +111 -134
- package/src/localization/bg-BG.json +111 -134
- package/src/localization/ca-ES.json +111 -134
- package/src/localization/cs-CZ.json +111 -134
- package/src/localization/da-DK.json +111 -134
- package/src/localization/de-DE.json +111 -134
- package/src/localization/el-GR.json +111 -134
- package/src/localization/en-US.json +19 -45
- package/src/localization/es-ES.json +111 -134
- package/src/localization/et-EE.json +111 -134
- package/src/localization/eu-ES.json +111 -134
- package/src/localization/fi-FI.json +111 -134
- package/src/localization/fr-FR.json +111 -134
- package/src/localization/gl-ES.json +111 -134
- package/src/localization/he-IL.json +111 -134
- package/src/localization/hi-IN.json +111 -134
- package/src/localization/hr-HR.json +111 -134
- package/src/localization/hu-HU.json +111 -134
- package/src/localization/id-ID.json +111 -134
- package/src/localization/it-IT.json +111 -134
- package/src/localization/ja-JP.json +111 -134
- package/src/localization/kk-KZ.json +111 -134
- package/src/localization/ko-KR.json +111 -134
- package/src/localization/lt-LT.json +111 -134
- package/src/localization/lv-LV.json +111 -134
- package/src/localization/ms-MY.json +111 -134
- package/src/localization/nb-NO.json +111 -134
- package/src/localization/nl-NL.json +111 -134
- package/src/localization/pl-PL.json +111 -134
- package/src/localization/pt-BR.json +111 -134
- package/src/localization/pt-PT.json +111 -134
- package/src/localization/ro-RO.json +111 -134
- package/src/localization/ru-RU.json +111 -134
- package/src/localization/sk-SK.json +111 -134
- package/src/localization/sl-SI.json +111 -134
- package/src/localization/sr-Cyrl-CS.json +111 -134
- package/src/localization/sr-Latn-CS.json +111 -134
- package/src/localization/sv-SE.json +111 -134
- package/src/localization/th-TH.json +111 -134
- package/src/localization/tr-TR.json +111 -134
- package/src/localization/uk-UA.json +111 -134
- package/src/localization/vi-VN.json +111 -134
- package/src/localization/yue.json +16 -5
- package/src/localization/zh-CN.json +111 -134
- package/src/localization/zh-HK.json +111 -134
- package/src/localization/zh-TW.json +111 -134
- package/src/normalizeStyleOptions.ts +76 -51
- package/src/patchStyleOptionsFromDeprecatedProps.js +14 -0
- package/src/providers/ActivityKeyer/ActivityKeyerComposer.tsx +40 -197
- package/src/providers/ActivityKeyer/private/someIterable.spec.ts +2 -0
- package/src/providers/ActivityListener/ActivityListenerComposer.tsx +1 -1
- package/src/providers/ActivitySendStatus/ActivitySendStatusComposer.tsx +3 -6
- package/src/providers/ActivityTyping/ActivityTypingComposer.tsx +59 -145
- package/src/providers/ActivityTyping/private/useMemoWithPrevious.ts +17 -0
- package/src/tsconfig.json +14 -5
- package/src/types/ActivityMiddleware.ts +36 -0
- package/src/types/ActivityStatusMiddleware.ts +9 -1
- package/src/types/AttachmentForScreenReaderMiddleware.ts +2 -9
- package/src/types/AttachmentMiddleware.ts +16 -0
- package/src/types/AvatarMiddleware.ts +1 -12
- package/src/types/CardActionMiddleware.ts +0 -2
- package/src/types/ComponentMiddleware.ts +1 -1
- package/src/types/GroupActivitiesMiddleware.ts +11 -7
- package/src/utils/isObject.js +5 -0
- package/src/utils/warnOnce.ts +10 -0
- package/LICENSE +0 -21
- package/boot/deprecated/decorator.js +0 -7
- package/boot/deprecated/decorator.mjs +0 -5
- package/boot/deprecated/graph.js +0 -7
- package/boot/deprecated/graph.mjs +0 -5
- package/boot/deprecated/hook.js +0 -7
- package/boot/deprecated/hook.mjs +0 -5
- package/boot/deprecated/internal.js +0 -7
- package/boot/deprecated/internal.mjs +0 -5
- package/boot/deprecated/middleware.js +0 -7
- package/boot/deprecated/middleware.mjs +0 -5
- package/dist/StyleOptions-4TkRjGbQ.d.mts +0 -802
- package/dist/StyleOptions-4TkRjGbQ.d.ts +0 -802
- package/dist/_dtsroll-chunks/B1b7R2eH-avatarMiddleware-CHa011_j.d.ts +0 -109
- package/dist/_dtsroll-chunks/CEcj2Npa-botframework-webchat-redux-store.d.ts +0 -16
- package/dist/_dtsroll-chunks/CZE5KEv8-botframework-webchat-api-middleware.d.ts +0 -230
- package/dist/_dtsroll-chunks/Dtb0H_Ee-handler-chain.d.ts +0 -4
- package/dist/_dtsroll-chunks/N-ttGLxs-botframework-webchat-base.utils.d.ts +0 -4
- package/dist/_dtsroll-chunks/qKTV3q17-avatarMiddleware-CHa011_j.d.ts +0 -93
- package/dist/botframework-webchat-api.d.ts +0 -387
- package/dist/botframework-webchat-api.decorator.d.ts +0 -81
- package/dist/botframework-webchat-api.decorator.js +0 -2
- package/dist/botframework-webchat-api.decorator.js.map +0 -1
- package/dist/botframework-webchat-api.graph.d.mts +0 -5
- package/dist/botframework-webchat-api.graph.d.ts +0 -2
- package/dist/botframework-webchat-api.graph.js +0 -2
- package/dist/botframework-webchat-api.graph.js.map +0 -1
- package/dist/botframework-webchat-api.graph.mjs +0 -2
- package/dist/botframework-webchat-api.hook.d.mts +0 -9
- package/dist/botframework-webchat-api.hook.d.ts +0 -9
- package/dist/botframework-webchat-api.hook.js +0 -2
- package/dist/botframework-webchat-api.hook.js.map +0 -1
- package/dist/botframework-webchat-api.hook.mjs +0 -2
- package/dist/botframework-webchat-api.hook.mjs.map +0 -1
- package/dist/botframework-webchat-api.internal.d.ts +0 -68
- package/dist/botframework-webchat-api.internal.js +0 -2
- package/dist/botframework-webchat-api.internal.js.map +0 -1
- package/dist/botframework-webchat-api.js +0 -2
- package/dist/botframework-webchat-api.js.map +0 -1
- package/dist/botframework-webchat-api.middleware.d.mts +0 -45
- package/dist/botframework-webchat-api.middleware.d.ts +0 -45
- package/dist/botframework-webchat-api.middleware.js +0 -2
- package/dist/botframework-webchat-api.middleware.js.map +0 -1
- package/dist/botframework-webchat-api.middleware.mjs +0 -2
- package/dist/botframework-webchat-api.middleware.mjs.map +0 -1
- package/dist/chunk-3YCFZWVR.js +0 -2
- package/dist/chunk-3YCFZWVR.js.map +0 -1
- package/dist/chunk-3ZWCT7YW.js +0 -2
- package/dist/chunk-3ZWCT7YW.js.map +0 -1
- package/dist/chunk-5HALOM2E.mjs +0 -2
- package/dist/chunk-5HALOM2E.mjs.map +0 -1
- package/dist/chunk-5JETBPYY.mjs +0 -2
- package/dist/chunk-5JETBPYY.mjs.map +0 -1
- package/dist/chunk-5X4VJZOM.js +0 -2
- package/dist/chunk-5X4VJZOM.js.map +0 -1
- package/dist/chunk-7GV72C4W.js +0 -2
- package/dist/chunk-7GV72C4W.js.map +0 -1
- package/dist/chunk-7IP5FN7Q.mjs +0 -2
- package/dist/chunk-7IP5FN7Q.mjs.map +0 -1
- package/dist/chunk-A6GQOZT3.js +0 -2
- package/dist/chunk-A6GQOZT3.js.map +0 -1
- package/dist/chunk-CIL5QUZ4.js +0 -2
- package/dist/chunk-CIL5QUZ4.js.map +0 -1
- package/dist/chunk-FA2GLWPN.mjs +0 -2
- package/dist/chunk-FA2GLWPN.mjs.map +0 -1
- package/dist/chunk-FD7QXXVX.js +0 -2
- package/dist/chunk-FD7QXXVX.js.map +0 -1
- package/dist/chunk-FOKVXAWC.mjs +0 -2
- package/dist/chunk-FOKVXAWC.mjs.map +0 -1
- package/dist/chunk-G5ZR6XJL.js +0 -2
- package/dist/chunk-G5ZR6XJL.js.map +0 -1
- package/dist/chunk-HIYAS5EE.js +0 -2
- package/dist/chunk-HIYAS5EE.js.map +0 -1
- package/dist/chunk-HJXXCOFT.js +0 -2
- package/dist/chunk-HJXXCOFT.js.map +0 -1
- package/dist/chunk-JKWDQH6P.mjs +0 -2
- package/dist/chunk-JKWDQH6P.mjs.map +0 -1
- package/dist/chunk-KDDULPEL.js +0 -2
- package/dist/chunk-KDDULPEL.js.map +0 -1
- package/dist/chunk-KGCBCAKG.js +0 -2
- package/dist/chunk-KGCBCAKG.js.map +0 -1
- package/dist/chunk-RLEJOP6E.mjs +0 -2
- package/dist/chunk-RLEJOP6E.mjs.map +0 -1
- package/dist/chunk-SOXBB2PI.mjs +0 -2
- package/dist/chunk-SOXBB2PI.mjs.map +0 -1
- package/dist/chunk-TU4357L3.mjs +0 -2
- package/dist/chunk-TU4357L3.mjs.map +0 -1
- package/dist/chunk-TWUVYAF5.mjs +0 -2
- package/dist/chunk-TWUVYAF5.mjs.map +0 -1
- package/dist/chunk-VAX7AB37.mjs.map +0 -1
- package/dist/chunk-VNGDFILB.mjs +0 -2
- package/dist/chunk-VNGDFILB.mjs.map +0 -1
- package/dist/hook-BXcgekzo.d.mts +0 -536
- package/dist/hook-C8NHjp6P.d.ts +0 -536
- package/dist/metafile-cjs.json +0 -1
- package/dist/templateMiddleware-BEttHPJk.d.mts +0 -20
- package/dist/templateMiddleware-BEttHPJk.d.ts +0 -20
- package/dist/types-BKuj7f2p.d.ts +0 -228
- package/dist/types-BZzd7aAk.d.mts +0 -228
- package/graph.js +0 -3
- package/hook.js +0 -3
- package/middleware.js +0 -3
- package/src/__tests__/addMetaTag.spec.js +0 -9
- package/src/__tests__/addMetaTag.spec.mjs +0 -9
- package/src/boot/decorator.ts +0 -21
- package/src/boot/graph.ts +0 -1
- package/src/boot/hook.ts +0 -82
- package/src/boot/internal.ts +0 -7
- package/src/boot/middleware.ts +0 -60
- package/src/buildInfo.ts +0 -9
- package/src/decorator/ActivityBorder/ActivityBorderDecorator.tsx +0 -57
- package/src/decorator/ActivityBorder/private/ActivityBorderDecoratorMiddleware.ts +0 -34
- package/src/decorator/ActivityBorder/private/ActivityBorderDecoratorRequestContext.ts +0 -48
- package/src/decorator/ActivityGrouping/ActivityGroupingDecorator.tsx +0 -43
- package/src/decorator/ActivityGrouping/private/ActivityGroupingDecoratorMiddleware.ts +0 -40
- package/src/decorator/DecoratorComposer.tsx +0 -51
- package/src/decorator/internal/InternalDecoratorComposer.tsx +0 -33
- package/src/decorator/internal/LowPriorityDecoratorComposer.tsx +0 -19
- package/src/decorator/private/DecoratorComposerContext.ts +0 -16
- package/src/decorator/private/PassthroughFallback.tsx +0 -12
- package/src/decorator/private/templateDecorator.tsx +0 -113
- package/src/decorator/types.ts +0 -4
- package/src/decorator/useDecoratorRequest.ts +0 -15
- package/src/env.d.ts +0 -9
- package/src/errorBox/errorBoxTelemetryPolymiddleware.ts +0 -53
- package/src/hooks/internal/usePostVoiceActivity.ts +0 -18
- package/src/hooks/internal/useRegisterVoiceHandler.ts +0 -23
- package/src/hooks/internal/useShouldShowMicrophoneButton.ts +0 -22
- package/src/hooks/internal/useVoiceHandlers.ts +0 -11
- package/src/hooks/internal/useVoiceStateWritable.ts +0 -18
- package/src/hooks/middleware/activityFallbackPolymiddleware.ts +0 -23
- package/src/hooks/useStartVoice.ts +0 -9
- package/src/hooks/useStopVoice.ts +0 -9
- package/src/hooks/useUIState.ts +0 -18
- package/src/hooks/useVoiceRecordingMuted.ts +0 -24
- package/src/hooks/useVoiceState.ts +0 -15
- package/src/hooks/validation/uiState.parseUIState.spec.ts +0 -21
- package/src/hooks/validation/uiState.ts +0 -10
- package/src/legacy/LegacyActivityBridge.tsx +0 -77
- package/src/legacy/LegacyActivityBridgeContext.ts +0 -23
- package/src/legacy/createActivityPolymiddlewareFromLegacy.tsx +0 -123
- package/src/legacy/createAvatarPolymiddlewareFromLegacy.tsx +0 -102
- package/src/middleware/AvatarPolymiddlewareProxy.tsx +0 -46
- package/src/middleware/SendBoxMiddleware.ts +0 -28
- package/src/middleware/SendBoxToolbarMiddleware.ts +0 -28
- package/src/middleware/private/templateMiddleware.check.test.tsx +0 -47
- package/src/middleware/private/templateMiddleware.tsx +0 -106
- package/src/middleware/useBuildRenderAvatarCallback.ts +0 -37
- package/src/providers/ActivityTyping/private/useReduceActivities.spec.tsx +0 -236
- package/src/providers/ActivityTyping/private/useReduceActivities.ts +0 -49
- package/src/providers/Capabilities/CapabilitiesComposer.tsx +0 -53
- package/src/providers/Capabilities/private/Context.ts +0 -13
- package/src/providers/Capabilities/private/capabilityRegistry.ts +0 -45
- package/src/providers/Capabilities/private/fetchCapabilitiesFromAdapter.ts +0 -59
- package/src/providers/Capabilities/private/shallowEqual.ts +0 -18
- package/src/providers/Capabilities/private/useContext.ts +0 -12
- package/src/providers/Capabilities/types/Capabilities.ts +0 -16
- package/src/providers/Capabilities/useCapabilities.ts +0 -25
- package/src/providers/GroupActivities/GroupActivitiesComposer.tsx +0 -116
- package/src/providers/GroupActivities/private/GroupActivitiesContext.ts +0 -23
- package/src/providers/GroupActivities/private/createDefaultGroupActivitiesMiddleware.ts +0 -113
- package/src/providers/GroupActivities/private/isGroupingValid.ts +0 -41
- package/src/providers/GroupActivities/private/useGroupActivitiesContext.ts +0 -6
- package/src/providers/GroupActivities/useGroupActivities.ts +0 -20
- package/src/providers/GroupActivities/useGroupActivitiesByName.ts +0 -17
- package/src/providers/SpeechToSpeech/SpeechToSpeechComposer.tsx +0 -20
- package/src/providers/SpeechToSpeech/private/VoiceHandlerBridge.tsx +0 -23
- package/src/providers/SpeechToSpeech/private/VoiceRecorderBridge.tsx +0 -49
- package/src/providers/SpeechToSpeech/private/useAudioPlayer.spec.tsx +0 -355
- package/src/providers/SpeechToSpeech/private/useAudioPlayer.ts +0 -92
- package/src/providers/SpeechToSpeech/private/useRecorder.spec.tsx +0 -344
- package/src/providers/SpeechToSpeech/private/useRecorder.ts +0 -220
- package/src/providers/StyleOptions/StyleOptionsComposer.tsx +0 -46
- package/src/providers/StyleOptions/private/StyleOptionsContext.ts +0 -20
- package/src/providers/StyleOptions/private/rectifyStyleOptions.ts +0 -6
- package/src/providers/StyleOptions/useStyleOptions.ts +0 -6
- /package/dist/{botframework-webchat-api.graph.mjs.map → chunk-J6D5YEY6.mjs.map} +0 -0
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { warnOnce } from '@msinternal/botframework-webchat-base/utils';
|
|
2
|
-
import React, { memo, type ReactNode } from 'react';
|
|
3
|
-
import { createChainOfResponsibility, type ComponentMiddleware } from 'react-chain-of-responsibility';
|
|
4
|
-
import { array, function_, is, type InferOutput } from 'valibot';
|
|
5
|
-
|
|
6
|
-
type MiddlewareWithInit<M extends ComponentMiddleware<any, any, any>, I> = (init: I) => ReturnType<M> | false;
|
|
7
|
-
|
|
8
|
-
const arrayOfFunctionSchema = array(function_());
|
|
9
|
-
|
|
10
|
-
/** @deprecated New middleware should use `templatePolymiddleware`. */
|
|
11
|
-
const middlewareFactoryMarker = Symbol();
|
|
12
|
-
|
|
13
|
-
const isArrayOfFunction = (middleware: unknown): middleware is InferOutput<typeof arrayOfFunctionSchema> =>
|
|
14
|
-
is(arrayOfFunctionSchema, middleware);
|
|
15
|
-
|
|
16
|
-
const EMPTY_ARRAY = Object.freeze([]);
|
|
17
|
-
|
|
18
|
-
/** @deprecated New middleware should use `templatePolymiddleware`. */
|
|
19
|
-
// Following @types/react to use {} for props.
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
21
|
-
function templateMiddleware<Request, Props extends {}>(name: string) {
|
|
22
|
-
type Middleware = ComponentMiddleware<Request, Props, string>;
|
|
23
|
-
|
|
24
|
-
const createMiddleware = (enhancer: ReturnType<Middleware>): Middleware => {
|
|
25
|
-
const factory: Middleware = init => init === name && enhancer;
|
|
26
|
-
|
|
27
|
-
// This is for checking if the middleware is created via factory function or not.
|
|
28
|
-
// We recommend middleware to be created using factory function.
|
|
29
|
-
factory[middlewareFactoryMarker satisfies symbol] = middlewareFactoryMarker;
|
|
30
|
-
|
|
31
|
-
return factory;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const warnInvalidExtraction = warnOnce(`Middleware passed for extraction of "${name}" must be an array of function`);
|
|
35
|
-
|
|
36
|
-
const extractMiddleware = (
|
|
37
|
-
middleware: readonly MiddlewareWithInit<ComponentMiddleware<unknown, unknown>, string>[] | undefined
|
|
38
|
-
): readonly Middleware[] => {
|
|
39
|
-
if (middleware) {
|
|
40
|
-
if (isArrayOfFunction(middleware)) {
|
|
41
|
-
return Object.freeze(
|
|
42
|
-
middleware
|
|
43
|
-
.map(middleware => {
|
|
44
|
-
const result = middleware(name);
|
|
45
|
-
|
|
46
|
-
if (typeof result !== 'function' && result !== false) {
|
|
47
|
-
console.warn(`botframework-webchat: ${name}.middleware must return enhancer function or false`);
|
|
48
|
-
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return result;
|
|
53
|
-
})
|
|
54
|
-
.filter((enhancer): enhancer is ReturnType<Middleware> => !!enhancer)
|
|
55
|
-
.map(enhancer => () => enhancer)
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
warnInvalidExtraction();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return EMPTY_ARRAY;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const { Provider, Proxy } = createChainOfResponsibility<Request, Props, string>();
|
|
66
|
-
|
|
67
|
-
type TemplatedProviderProps = {
|
|
68
|
-
readonly children?: ReactNode | undefined;
|
|
69
|
-
readonly middleware: readonly Middleware[];
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// eslint-disable-next-line prefer-arrow-callback
|
|
73
|
-
const TemplatedProvider = memo(function TemplatedProvider({ children, middleware }: TemplatedProviderProps) {
|
|
74
|
-
return (
|
|
75
|
-
<Provider init={name} middleware={middleware}>
|
|
76
|
-
{children}
|
|
77
|
-
</Provider>
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
TemplatedProvider.displayName = `${name}Provider`;
|
|
82
|
-
|
|
83
|
-
Proxy.displayName = `${name}Proxy`;
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
createMiddleware,
|
|
87
|
-
extractMiddleware,
|
|
88
|
-
Provider: TemplatedProvider,
|
|
89
|
-
Proxy,
|
|
90
|
-
'~types': undefined as {
|
|
91
|
-
middleware: Middleware;
|
|
92
|
-
props: Props;
|
|
93
|
-
request: Request;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** @deprecated New middleware should use `templatePolymiddleware`. */
|
|
99
|
-
type InferMiddleware<T extends { '~types': { middleware } }> = T['~types']['middleware'];
|
|
100
|
-
/** @deprecated New middleware should use `templatePolymiddleware`. */
|
|
101
|
-
type InferProps<T extends { '~types': { props } }> = T['~types']['props'];
|
|
102
|
-
/** @deprecated New middleware should use `templatePolymiddleware`. */
|
|
103
|
-
type InferRequest<T extends { '~types': { request } }> = T['~types']['request'];
|
|
104
|
-
|
|
105
|
-
export default templateMiddleware;
|
|
106
|
-
export { middlewareFactoryMarker, type InferMiddleware, type InferProps, type InferRequest };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// We need to patch `useBuildRenderAvatarCallback()` from `api-middleware`.
|
|
2
|
-
//
|
|
3
|
-
// - Request of `useBuildRenderAvatarCallback()` should not need `styleOptions`
|
|
4
|
-
// - We should call `useStyleOptions()` to get style options
|
|
5
|
-
// - However, `api-middleware` is before `api`, so it do not have access to `useStyleOptions`
|
|
6
|
-
//
|
|
7
|
-
// Until we have `api-style-options`, we have to patch `useBuildRenderAvatarCallback()` inside `api`.
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
__INTERNAL_DO_NOT_USE__avatarPolymiddlewareRequestStyleOptionsSymbol,
|
|
11
|
-
useBuildRenderAvatarCallback as useBuildRenderAvatarCallbackRaw
|
|
12
|
-
} from '@msinternal/botframework-webchat-api-middleware';
|
|
13
|
-
import type { WebChatActivity } from 'botframework-webchat-core';
|
|
14
|
-
import { useCallback } from 'react';
|
|
15
|
-
import type { ComponentRenderer } from 'react-chain-of-responsibility/preview';
|
|
16
|
-
import { useRefFrom } from 'use-ref-from';
|
|
17
|
-
import { useStyleOptions } from '../hooks';
|
|
18
|
-
|
|
19
|
-
export default function useBuildRenderAvatarCallback(): (request: {
|
|
20
|
-
readonly activity: WebChatActivity;
|
|
21
|
-
}) => ComponentRenderer<{ children?: never }> {
|
|
22
|
-
const [styleOptions] = useStyleOptions();
|
|
23
|
-
|
|
24
|
-
const renderAvatar = useBuildRenderAvatarCallbackRaw();
|
|
25
|
-
const styleOptionsRef = useRefFrom(styleOptions);
|
|
26
|
-
|
|
27
|
-
return useCallback<(request: { readonly activity: WebChatActivity }) => ReturnType<typeof renderAvatar>>(
|
|
28
|
-
request =>
|
|
29
|
-
renderAvatar(
|
|
30
|
-
Object.freeze({
|
|
31
|
-
activity: request.activity,
|
|
32
|
-
[__INTERNAL_DO_NOT_USE__avatarPolymiddlewareRequestStyleOptionsSymbol]: styleOptionsRef.current
|
|
33
|
-
})
|
|
34
|
-
),
|
|
35
|
-
[renderAvatar, styleOptionsRef]
|
|
36
|
-
);
|
|
37
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/** @jest-environment @happy-dom/jest-environment */
|
|
2
|
-
/// <reference types="jest" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
|
|
5
|
-
import { render, type RenderResult } from '@testing-library/react';
|
|
6
|
-
import type { WebChatActivity } from 'botframework-webchat-core';
|
|
7
|
-
import type { LocalId } from 'botframework-webchat-core/activity.js';
|
|
8
|
-
import React, { type ComponentType } from 'react';
|
|
9
|
-
import { type useActivities as UseActivitiesType } from '../../../hooks';
|
|
10
|
-
import type UseReduceActivitiesType from './useReduceActivities';
|
|
11
|
-
|
|
12
|
-
type UseReduceActivitiesFn = Parameters<typeof UseReduceActivitiesType>[0];
|
|
13
|
-
|
|
14
|
-
const ACTIVITY_TEMPLATE = {
|
|
15
|
-
channelData: {
|
|
16
|
-
'webchat:internal:local-id': '_:a-00001' as LocalId,
|
|
17
|
-
'webchat:internal:position': 0,
|
|
18
|
-
'webchat:sequence-id': 0,
|
|
19
|
-
'webchat:send-status': undefined
|
|
20
|
-
},
|
|
21
|
-
from: { id: 'bot', role: 'bot' },
|
|
22
|
-
id: 'a-00001',
|
|
23
|
-
text: '',
|
|
24
|
-
timestamp: '2025-03-10T12:34:56.789Z',
|
|
25
|
-
type: 'message'
|
|
26
|
-
} satisfies WebChatActivity & { type: 'message' };
|
|
27
|
-
|
|
28
|
-
describe('setup', () => {
|
|
29
|
-
let HookApp: ComponentType<{ fn: UseReduceActivitiesFn }>;
|
|
30
|
-
let useActivities: jest.Mock<ReturnType<typeof UseActivitiesType>, Parameters<typeof UseActivitiesType>>;
|
|
31
|
-
let useReduceActivities: jest.Mock<
|
|
32
|
-
ReturnType<typeof UseReduceActivitiesType>,
|
|
33
|
-
Parameters<typeof UseReduceActivitiesType>
|
|
34
|
-
>;
|
|
35
|
-
let fn: jest.Mock<ReturnType<UseReduceActivitiesFn>, Parameters<UseReduceActivitiesFn>>;
|
|
36
|
-
let renderResult: RenderResult;
|
|
37
|
-
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
jest.mock('../../../hooks', () => ({ __esModule: true, useActivities: jest.fn(() => [[]]) }));
|
|
40
|
-
|
|
41
|
-
({ useActivities } = require('../../../hooks'));
|
|
42
|
-
|
|
43
|
-
useReduceActivities = jest.fn(require('./useReduceActivities').default);
|
|
44
|
-
|
|
45
|
-
fn = jest.fn().mockImplementation((prevResult, activity) => ({
|
|
46
|
-
maxText: prevResult?.maxText > activity['text'] ? prevResult?.maxText : activity['text']
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
|
-
HookApp = ({ fn }) => {
|
|
50
|
-
useReduceActivities(fn);
|
|
51
|
-
|
|
52
|
-
return null;
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('reduce nothing', () => {
|
|
57
|
-
render(<HookApp fn={fn} />);
|
|
58
|
-
|
|
59
|
-
expect(fn).toHaveBeenCalledTimes(0);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('when the first activity is received', () => {
|
|
63
|
-
let firstActivity: WebChatActivity;
|
|
64
|
-
|
|
65
|
-
beforeEach(() => {
|
|
66
|
-
firstActivity = { ...ACTIVITY_TEMPLATE, id: 'a-00001', text: 'Aloha!' };
|
|
67
|
-
|
|
68
|
-
useActivities.mockImplementationOnce(() => [[firstActivity]]);
|
|
69
|
-
|
|
70
|
-
renderResult = render(<HookApp fn={fn} />);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe('fn() should have been called', () => {
|
|
74
|
-
test('once', () => expect(fn).toHaveBeenCalledTimes(1));
|
|
75
|
-
test('with the activity', () =>
|
|
76
|
-
expect(fn).toHaveBeenLastCalledWith(undefined, firstActivity, 0, expect.arrayContaining([])));
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('return value should be derived from the first activity', () =>
|
|
80
|
-
expect(useReduceActivities).toHaveLastReturnedWith({ maxText: 'Aloha!' }));
|
|
81
|
-
|
|
82
|
-
describe('when the second activity is received', () => {
|
|
83
|
-
let secondActivity: WebChatActivity;
|
|
84
|
-
|
|
85
|
-
beforeEach(() => {
|
|
86
|
-
secondActivity = { ...ACTIVITY_TEMPLATE, id: 'a-00002', text: 'Hello, World!' };
|
|
87
|
-
|
|
88
|
-
useActivities.mockImplementationOnce(() => [[firstActivity, secondActivity]]);
|
|
89
|
-
|
|
90
|
-
renderResult.rerender(<HookApp fn={fn} />);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe('fn() should have been called', () => {
|
|
94
|
-
test('twice in total', () => expect(fn).toHaveBeenCalledTimes(2));
|
|
95
|
-
test('with the second activity', () =>
|
|
96
|
-
expect(fn).toHaveBeenLastCalledWith({ maxText: 'Aloha!' }, secondActivity, 1, expect.arrayContaining([])));
|
|
97
|
-
|
|
98
|
-
test('return value should be derived from the second activity', () =>
|
|
99
|
-
expect(useReduceActivities).toHaveLastReturnedWith({ maxText: 'Hello, World!' }));
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
describe('when the third activity is inserted between the first and second activity', () => {
|
|
103
|
-
let thirdActivity: WebChatActivity;
|
|
104
|
-
|
|
105
|
-
beforeEach(() => {
|
|
106
|
-
thirdActivity = { ...ACTIVITY_TEMPLATE, id: 'a-00003', text: 'Morning!' };
|
|
107
|
-
|
|
108
|
-
useActivities.mockImplementationOnce(() => [[firstActivity, thirdActivity, secondActivity]]);
|
|
109
|
-
|
|
110
|
-
renderResult.rerender(<HookApp fn={fn} />);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe('fn() should have been called', () => {
|
|
114
|
-
// It should call 2 more times because the first one should be from cache.
|
|
115
|
-
test('4 times in total', () => expect(fn).toHaveBeenCalledTimes(4));
|
|
116
|
-
|
|
117
|
-
test('with the third activity on 3rd call', () =>
|
|
118
|
-
expect(fn).toHaveBeenNthCalledWith(3, { maxText: 'Aloha!' }, thirdActivity, 1, expect.arrayContaining([])));
|
|
119
|
-
test('with the second activity on 4th call', () =>
|
|
120
|
-
expect(fn).toHaveBeenNthCalledWith(
|
|
121
|
-
4,
|
|
122
|
-
{ maxText: 'Morning!' },
|
|
123
|
-
secondActivity,
|
|
124
|
-
2,
|
|
125
|
-
expect.arrayContaining([])
|
|
126
|
-
));
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test('return value should be derived from the third activity', () =>
|
|
130
|
-
expect(useReduceActivities).toHaveLastReturnedWith({ maxText: 'Morning!' }));
|
|
131
|
-
|
|
132
|
-
describe('when all activities are removed', () => {
|
|
133
|
-
beforeEach(() => {
|
|
134
|
-
useActivities.mockImplementationOnce(() => [[]]);
|
|
135
|
-
|
|
136
|
-
renderResult.rerender(<HookApp fn={fn} />);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test('should not call fn()', () => expect(fn).toHaveBeenCalledTimes(4));
|
|
140
|
-
test('return value should be undefined', () => expect(useReduceActivities).toHaveLastReturnedWith(undefined));
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
describe('when the third activity is being replaced', () => {
|
|
144
|
-
let fourthActivity: WebChatActivity;
|
|
145
|
-
|
|
146
|
-
beforeEach(() => {
|
|
147
|
-
fourthActivity = { ...ACTIVITY_TEMPLATE, id: 'a-00004', text: 'Good morning!' };
|
|
148
|
-
|
|
149
|
-
useActivities.mockImplementationOnce(() => [[firstActivity, fourthActivity, secondActivity]]);
|
|
150
|
-
|
|
151
|
-
renderResult.rerender(<HookApp fn={fn} />);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe('fn() should have been called', () => {
|
|
155
|
-
// It should call 2 more times because the first one should be from cache.
|
|
156
|
-
test('6 times in total', () => expect(fn).toHaveBeenCalledTimes(6));
|
|
157
|
-
|
|
158
|
-
test('with the fourth activity on 5rd call', () =>
|
|
159
|
-
expect(fn).toHaveBeenNthCalledWith(
|
|
160
|
-
5,
|
|
161
|
-
{ maxText: 'Aloha!' },
|
|
162
|
-
fourthActivity,
|
|
163
|
-
1,
|
|
164
|
-
expect.arrayContaining([])
|
|
165
|
-
));
|
|
166
|
-
|
|
167
|
-
test('with the second activity on 6th call', () =>
|
|
168
|
-
expect(fn).toHaveBeenNthCalledWith(
|
|
169
|
-
6,
|
|
170
|
-
{ maxText: 'Good morning!' },
|
|
171
|
-
secondActivity,
|
|
172
|
-
2,
|
|
173
|
-
expect.arrayContaining([])
|
|
174
|
-
));
|
|
175
|
-
|
|
176
|
-
test('return value should be derived from the second activity', () =>
|
|
177
|
-
expect(useReduceActivities).toHaveLastReturnedWith({ maxText: 'Hello, World!' }));
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
describe('when the first activity is removed', () => {
|
|
183
|
-
beforeEach(() => {
|
|
184
|
-
useActivities.mockImplementationOnce(() => [[secondActivity]]);
|
|
185
|
-
|
|
186
|
-
renderResult.rerender(<HookApp fn={fn} />);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
describe('should call fn', () => {
|
|
190
|
-
test('3 times in total', () => expect(fn).toHaveBeenCalledTimes(3));
|
|
191
|
-
test('with the second activity only', () =>
|
|
192
|
-
expect(fn).toHaveBeenLastCalledWith(undefined, secondActivity, 0, expect.arrayContaining([])));
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
test('return value should be derived from the second activity', () =>
|
|
196
|
-
expect(useReduceActivities).toHaveLastReturnedWith({ maxText: 'Hello, World!' }));
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
describe('when the second activity is removed', () => {
|
|
200
|
-
beforeEach(() => {
|
|
201
|
-
useActivities.mockImplementationOnce(() => [[firstActivity]]);
|
|
202
|
-
|
|
203
|
-
renderResult.rerender(<HookApp fn={fn} />);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
describe('should not call fn()', () => test('once', () => expect(fn).toHaveBeenCalledTimes(2)));
|
|
207
|
-
|
|
208
|
-
test('return value should be derived from the first activity', () =>
|
|
209
|
-
expect(useReduceActivities).toHaveLastReturnedWith({ maxText: 'Aloha!' }));
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
describe('when all activities are removed', () => {
|
|
214
|
-
beforeEach(() => {
|
|
215
|
-
useActivities.mockImplementationOnce(() => [[]]);
|
|
216
|
-
|
|
217
|
-
renderResult.rerender(<HookApp fn={fn} />);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
test('should not call fn()', () => expect(fn).toHaveBeenCalledTimes(1));
|
|
221
|
-
test('return value should be undefined', () => expect(useReduceActivities).toHaveLastReturnedWith(undefined));
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
describe('when activities are unchanged', () => {
|
|
225
|
-
beforeEach(() => {
|
|
226
|
-
useActivities.mockImplementationOnce(() => [[firstActivity]]);
|
|
227
|
-
|
|
228
|
-
renderResult.rerender(<HookApp fn={fn} />);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
test('should not call fn()', () => expect(fn).toHaveBeenCalledTimes(1));
|
|
232
|
-
test('return value should be derived from the first activity', () =>
|
|
233
|
-
expect(useReduceActivities).toHaveLastReturnedWith({ maxText: 'Aloha!' }));
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { useMemoWithPrevious } from '@msinternal/botframework-webchat-react-hooks';
|
|
2
|
-
import { type WebChatActivity } from 'botframework-webchat-core';
|
|
3
|
-
|
|
4
|
-
import { useActivities } from '../../../hooks';
|
|
5
|
-
|
|
6
|
-
type Entry<T> = Readonly<{
|
|
7
|
-
activity: WebChatActivity;
|
|
8
|
-
value: T | undefined;
|
|
9
|
-
}>;
|
|
10
|
-
|
|
11
|
-
export default function useReduceActivities<T>(
|
|
12
|
-
fn: (prevValue: T, activity: WebChatActivity, index: number, activities: Readonly<WebChatActivity[]>) => T
|
|
13
|
-
): T {
|
|
14
|
-
const [activities] = useActivities();
|
|
15
|
-
|
|
16
|
-
const state = useMemoWithPrevious<readonly Entry<T>[]>(
|
|
17
|
-
(state = Object.freeze([])) => {
|
|
18
|
-
let changed = activities.length !== state.length;
|
|
19
|
-
let prevValue: T | undefined;
|
|
20
|
-
let shouldRecompute = false;
|
|
21
|
-
|
|
22
|
-
const nextState = activities.map<Entry<T>>((activity, index) => {
|
|
23
|
-
const entry = state[+index];
|
|
24
|
-
|
|
25
|
-
if (!shouldRecompute && Object.is(entry?.activity, activity)) {
|
|
26
|
-
prevValue = entry?.value;
|
|
27
|
-
|
|
28
|
-
// Skips the activity if it has been reduced in the past render loop.
|
|
29
|
-
return entry;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
changed = true;
|
|
33
|
-
shouldRecompute = true;
|
|
34
|
-
|
|
35
|
-
return Object.freeze({
|
|
36
|
-
activity,
|
|
37
|
-
value: (prevValue = fn(prevValue, activity, index, activities))
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Returns the original array if nothing changed.
|
|
42
|
-
return changed ? nextState : state;
|
|
43
|
-
},
|
|
44
|
-
[activities, fn]
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
// eslint-disable-next-line no-magic-numbers
|
|
48
|
-
return state.at(-1)?.value;
|
|
49
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React, { memo, useCallback, useEffect, useMemo, useState, type ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
import useWebChatAPIContext from '../../hooks/internal/useWebChatAPIContext';
|
|
4
|
-
import CapabilitiesContext from './private/Context';
|
|
5
|
-
import fetchCapabilitiesFromAdapter from './private/fetchCapabilitiesFromAdapter';
|
|
6
|
-
import type { Capabilities } from './types/Capabilities';
|
|
7
|
-
|
|
8
|
-
type Props = Readonly<{ children?: ReactNode | undefined }>;
|
|
9
|
-
|
|
10
|
-
const EMPTY_CAPABILITIES: Capabilities = Object.freeze({});
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Composer that provides capabilities from the adapter via EventTarget pattern.
|
|
14
|
-
*
|
|
15
|
-
* Design principles:
|
|
16
|
-
* 1. Initial fetch: Pulls capabilities from adapter on mount
|
|
17
|
-
* 2. Event-driven updates: Re-fetches when adapter dispatches 'capabilitieschanged' event
|
|
18
|
-
* 3. Stable references: Individual capability objects maintain reference equality if unchanged
|
|
19
|
-
* - This ensures consumers using selectors only re-render when their capability changes
|
|
20
|
-
*/
|
|
21
|
-
const CapabilitiesComposer = memo(({ children }: Props) => {
|
|
22
|
-
const { directLine } = useWebChatAPIContext();
|
|
23
|
-
|
|
24
|
-
const getAllCapabilities = useCallback(
|
|
25
|
-
() => fetchCapabilitiesFromAdapter(directLine, EMPTY_CAPABILITIES).capabilities,
|
|
26
|
-
[directLine]
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const [capabilities, setCapabilities] = useState<Capabilities>(() => getAllCapabilities());
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
const handleCapabilitiesChange = () => {
|
|
33
|
-
setCapabilities(prevCapabilities => {
|
|
34
|
-
const { capabilities, hasChanged } = fetchCapabilitiesFromAdapter(directLine, prevCapabilities);
|
|
35
|
-
return hasChanged ? capabilities : prevCapabilities;
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
if (typeof directLine?.addEventListener === 'function') {
|
|
40
|
-
directLine.addEventListener('capabilitieschanged', handleCapabilitiesChange);
|
|
41
|
-
|
|
42
|
-
return () => directLine.removeEventListener('capabilitieschanged', handleCapabilitiesChange);
|
|
43
|
-
}
|
|
44
|
-
}, [directLine]);
|
|
45
|
-
|
|
46
|
-
const contextValue = useMemo(() => Object.freeze({ capabilities }), [capabilities]);
|
|
47
|
-
|
|
48
|
-
return <CapabilitiesContext.Provider value={contextValue}>{children}</CapabilitiesContext.Provider>;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
CapabilitiesComposer.displayName = 'CapabilitiesComposer';
|
|
52
|
-
|
|
53
|
-
export default CapabilitiesComposer;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
2
|
-
import type { Capabilities } from '../types/Capabilities';
|
|
3
|
-
|
|
4
|
-
type CapabilitiesContextType = Readonly<{
|
|
5
|
-
capabilities: Capabilities;
|
|
6
|
-
}>;
|
|
7
|
-
|
|
8
|
-
const CapabilitiesContext = createContext<CapabilitiesContextType | undefined>(undefined);
|
|
9
|
-
|
|
10
|
-
CapabilitiesContext.displayName = 'CapabilitiesContext';
|
|
11
|
-
|
|
12
|
-
export default CapabilitiesContext;
|
|
13
|
-
export type { CapabilitiesContextType };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { Capabilities } from '../types/Capabilities';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Descriptor for a capability that can be fetched from the adapter.
|
|
5
|
-
*/
|
|
6
|
-
export type CapabilityDescriptor<K extends keyof Capabilities> = {
|
|
7
|
-
/** The key in the Capabilities object */
|
|
8
|
-
readonly key: K;
|
|
9
|
-
/** The getter function name on the adapter (e.g., 'getVoiceConfiguration') */
|
|
10
|
-
readonly getterName: string;
|
|
11
|
-
/**
|
|
12
|
-
* Custom equality comparator for this capability.
|
|
13
|
-
* If not provided, uses shallow object comparison.
|
|
14
|
-
* Return true if values are equal (should reuse previous reference).
|
|
15
|
-
*/
|
|
16
|
-
readonly isEqual?: (a: Capabilities[K], b: Capabilities[K]) => boolean;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Registry of all capabilities.
|
|
21
|
-
*
|
|
22
|
-
* To add a new capability:
|
|
23
|
-
* 1. Add type to Capabilities interface in types/Capabilities.ts
|
|
24
|
-
* 2. Add entry here with key, getterName, and optional custom isEqual
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* // Simple capability (uses default shallowEqual)
|
|
28
|
-
* { key: 'voiceConfiguration', getterName: 'getVoiceConfiguration' }
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* // Capability with custom equality check
|
|
32
|
-
* {
|
|
33
|
-
* key: 'complexConfig',
|
|
34
|
-
* getterName: 'getComplexConfig',
|
|
35
|
-
* isEqual: (a, b) => a?.nested?.value === b?.nested?.value
|
|
36
|
-
* }
|
|
37
|
-
*/
|
|
38
|
-
const CAPABILITY_REGISTRY: readonly CapabilityDescriptor<keyof Capabilities>[] = Object.freeze([
|
|
39
|
-
{
|
|
40
|
-
key: 'voiceConfiguration',
|
|
41
|
-
getterName: 'getVoiceConfiguration'
|
|
42
|
-
}
|
|
43
|
-
]);
|
|
44
|
-
|
|
45
|
-
export default CAPABILITY_REGISTRY;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { DirectLineJSBotConnection, isForbiddenPropertyName } from 'botframework-webchat-core';
|
|
2
|
-
import type { Capabilities } from '../types/Capabilities';
|
|
3
|
-
import CAPABILITY_REGISTRY from './capabilityRegistry';
|
|
4
|
-
import shallowEqual from './shallowEqual';
|
|
5
|
-
|
|
6
|
-
type FetchResult = {
|
|
7
|
-
capabilities: Capabilities;
|
|
8
|
-
hasChanged: boolean;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Fetches all capabilities from the adapter based on the registry.
|
|
13
|
-
* Returns a new capabilities object with values fetched from the adapter.
|
|
14
|
-
*/
|
|
15
|
-
export default function fetchCapabilitiesFromAdapter(
|
|
16
|
-
directLine: DirectLineJSBotConnection,
|
|
17
|
-
prevCapabilities: Capabilities
|
|
18
|
-
): FetchResult {
|
|
19
|
-
let hasChanged = false;
|
|
20
|
-
|
|
21
|
-
const entries: [string, unknown][] = [];
|
|
22
|
-
|
|
23
|
-
for (const descriptor of CAPABILITY_REGISTRY) {
|
|
24
|
-
const { key, getterName, isEqual = shallowEqual } = descriptor;
|
|
25
|
-
|
|
26
|
-
if (isForbiddenPropertyName(key) || isForbiddenPropertyName(getterName)) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
31
|
-
const getter = directLine?.[getterName];
|
|
32
|
-
|
|
33
|
-
if (typeof getter === 'function') {
|
|
34
|
-
try {
|
|
35
|
-
const fetchedValue = getter.call(directLine);
|
|
36
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
37
|
-
const prevValue = prevCapabilities[key];
|
|
38
|
-
|
|
39
|
-
if (fetchedValue) {
|
|
40
|
-
if (typeof prevValue !== 'undefined' && isEqual(prevValue, fetchedValue)) {
|
|
41
|
-
entries.push([key, prevValue]);
|
|
42
|
-
} else {
|
|
43
|
-
entries.push([key, Object.freeze({ ...fetchedValue })]);
|
|
44
|
-
hasChanged = true;
|
|
45
|
-
}
|
|
46
|
-
} else if (typeof prevValue !== 'undefined') {
|
|
47
|
-
hasChanged = true;
|
|
48
|
-
}
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.warn(`botframework-webchat: Error calling capability ${getterName}:`, error);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
capabilities: Object.freeze(Object.fromEntries(entries)) as Capabilities,
|
|
57
|
-
hasChanged
|
|
58
|
-
};
|
|
59
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { isForbiddenPropertyName } from 'botframework-webchat-core';
|
|
2
|
-
|
|
3
|
-
// TODO: [P2] Move this file to `base` package.
|
|
4
|
-
export default function shallowEqual(x, y) {
|
|
5
|
-
if (x === y) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const xKeys = Object.keys(x);
|
|
10
|
-
const yKeys = Object.keys(y);
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
xKeys.length === yKeys.length &&
|
|
14
|
-
// Mitigated through denylisting.
|
|
15
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
16
|
-
xKeys.every(key => !isForbiddenPropertyName(key) && yKeys.includes(key) && x[key] === y[key])
|
|
17
|
-
);
|
|
18
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import CapabilitiesContext, { type CapabilitiesContextType } from './Context';
|
|
3
|
-
|
|
4
|
-
export default function useCapabilitiesContext(): CapabilitiesContextType {
|
|
5
|
-
const context = useContext(CapabilitiesContext);
|
|
6
|
-
|
|
7
|
-
if (!context) {
|
|
8
|
-
throw new Error('botframework-webchat internal: This hook can only be used under <CapabilitiesComposer>.');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return context;
|
|
12
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All capabilities are optional as they depend on adapter/server support.
|
|
3
|
-
*/
|
|
4
|
-
type Capabilities = Readonly<{
|
|
5
|
-
voiceConfiguration?: VoiceConfiguration | undefined;
|
|
6
|
-
}>;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Optional for adapter/server to provide these configs for speech-to-speech.
|
|
10
|
-
*/
|
|
11
|
-
type VoiceConfiguration = Readonly<{
|
|
12
|
-
chunkIntervalMs: number;
|
|
13
|
-
sampleRate: number;
|
|
14
|
-
}>;
|
|
15
|
-
|
|
16
|
-
export type { Capabilities, VoiceConfiguration };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useMemo, useRef } from 'react';
|
|
2
|
-
import useCapabilitiesContext from './private/useContext';
|
|
3
|
-
import type { Capabilities } from './types/Capabilities';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Hook to access adapter capabilities with a selector function.
|
|
7
|
-
* Only triggers re-render when the selected value changes (shallow comparison).
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Get voice configuration only
|
|
11
|
-
* const voiceConfig = useCapabilities(caps => caps.voiceConfiguration);
|
|
12
|
-
*/
|
|
13
|
-
export default function useCapabilities<T>(selector: (capabilities: Capabilities) => T): T {
|
|
14
|
-
const { capabilities } = useCapabilitiesContext();
|
|
15
|
-
const selectedValue = selector(capabilities);
|
|
16
|
-
const prevSelectedValueRef = useRef<T>(selectedValue);
|
|
17
|
-
|
|
18
|
-
return useMemo(() => {
|
|
19
|
-
if (Object.is(prevSelectedValueRef.current, selectedValue)) {
|
|
20
|
-
return prevSelectedValueRef.current;
|
|
21
|
-
}
|
|
22
|
-
prevSelectedValueRef.current = selectedValue;
|
|
23
|
-
return selectedValue;
|
|
24
|
-
}, [selectedValue]);
|
|
25
|
-
}
|