|
| 1 | +/* eslint dot-notation: ["error", { "allowPattern": "^WebChat$" }] */ |
| 2 | +// window['WebChat'] is required for TypeScript |
| 3 | + |
| 4 | +export * from './index-minimal'; |
| 5 | +export type { ComposerRef } from './index-minimal'; |
| 6 | + |
| 7 | +import { Components as MinimalComponents, hooks, version, withEmoji } from './index-minimal'; |
| 8 | +import AdaptiveCardContent from './adaptiveCards/Attachment/AdaptiveCardContent'; |
| 9 | +import addVersion from './addVersion'; |
| 10 | +import AnimationCardContent from './adaptiveCards/Attachment/AnimationCardContent'; |
| 11 | +import AudioCardContent from './adaptiveCards/Attachment/AudioCardContent'; |
| 12 | +import coreRenderWebChat from './renderWebChat'; |
| 13 | +import createAdaptiveCardsAttachmentMiddleware from './adaptiveCards/createAdaptiveCardsAttachmentMiddleware'; |
| 14 | +import createAdaptiveCardsAttachmentForScreenReaderMiddleware from './adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware'; |
| 15 | +import createCognitiveServicesSpeechServicesPonyfillFactory from './createCognitiveServicesSpeechServicesPonyfillFactory'; |
| 16 | +import createDirectLineSpeechAdapters from './createDirectLineSpeechAdapters'; |
| 17 | +import createStyleSet from './createFullStyleSet'; |
| 18 | +import defaultCreateDirectLine from './createDirectLine'; |
| 19 | +import defaultCreateDirectLineAppServiceExtension from './createDirectLineAppServiceExtension'; |
| 20 | +import FullBundleStyleOptions, { StrictFullBundleStyleOptions } from './types/FullBundleStyleOptions'; |
| 21 | +import FullComposer from './FullComposer'; |
| 22 | +import HeroCardContent from './adaptiveCards/Attachment/HeroCardContent'; |
| 23 | +import OAuthCardContent from './adaptiveCards/Attachment/OAuthCardContent'; |
| 24 | +import ReactWebChat from './FullReactWebChat'; |
| 25 | +import ReceiptCardContent from './adaptiveCards/Attachment/ReceiptCardContent'; |
| 26 | +import renderMarkdown from './markdown/renderMarkdown'; |
| 27 | +import SignInCardContent from './adaptiveCards/Attachment/SignInCardContent'; |
| 28 | +import ThumbnailCardContent from './adaptiveCards/Attachment/ThumbnailCardContent'; |
| 29 | +import useAdaptiveCardsHostConfig from './adaptiveCards/hooks/useAdaptiveCardsHostConfig'; |
| 30 | +import useAdaptiveCardsPackage from './adaptiveCards/hooks/useAdaptiveCardsPackage'; |
| 31 | +import useStyleOptions from './hooks/useStyleOptions'; |
| 32 | +import useStyleSet from './hooks/useStyleSet'; |
| 33 | +import VideoCardContent from './adaptiveCards/Attachment/VideoCardContent'; |
| 34 | + |
| 35 | +const renderWebChat = coreRenderWebChat.bind(null, ReactWebChat); |
| 36 | + |
| 37 | +export const createDirectLine = (options: Omit<Parameters<typeof defaultCreateDirectLine>[0], 'botAgent'>) => { |
| 38 | + (options as any).botAgent && |
| 39 | + console.warn( |
| 40 | + 'Web Chat: Developers are not currently allowed to set botAgent. See https://github.com/microsoft/BotFramework-WebChat/issues/2119 for more details.' |
| 41 | + ); |
| 42 | + |
| 43 | + return defaultCreateDirectLine({ ...options, botAgent: `WebChat/${version} (Full)` }); |
| 44 | +}; |
| 45 | + |
| 46 | +export const createDirectLineAppServiceExtension = ( |
| 47 | + options: Omit<Parameters<typeof defaultCreateDirectLineAppServiceExtension>[0], 'botAgent'> |
| 48 | +) => { |
| 49 | + (options as any).botAgent && |
| 50 | + console.warn( |
| 51 | + 'Web Chat: Developers are not currently allowed to set botAgent. See https://github.com/microsoft/BotFramework-WebChat/issues/2119 for more details.' |
| 52 | + ); |
| 53 | + |
| 54 | + return defaultCreateDirectLineAppServiceExtension({ ...options, botAgent: `WebChat/${version} (Full)` }); |
| 55 | +}; |
| 56 | + |
| 57 | +const patchedHooks = { |
| 58 | + ...hooks, |
| 59 | + useAdaptiveCardsHostConfig, |
| 60 | + useAdaptiveCardsPackage, |
| 61 | + useStyleOptions, |
| 62 | + useStyleSet |
| 63 | +}; |
| 64 | + |
| 65 | +const AdditionalComponents = { |
| 66 | + AdaptiveCardContent, |
| 67 | + AnimationCardContent, |
| 68 | + AudioCardContent, |
| 69 | + Composer: FullComposer, |
| 70 | + HeroCardContent, |
| 71 | + OAuthCardContent, |
| 72 | + ReceiptCardContent, |
| 73 | + SignInCardContent, |
| 74 | + ThumbnailCardContent, |
| 75 | + VideoCardContent |
| 76 | +}; |
| 77 | + |
| 78 | +const Components: typeof MinimalComponents & typeof AdditionalComponents = { |
| 79 | + ...MinimalComponents, |
| 80 | + ...AdditionalComponents |
| 81 | +}; |
| 82 | + |
| 83 | +type StyleOptions = FullBundleStyleOptions; |
| 84 | +type StrictStyleOptions = StrictFullBundleStyleOptions; |
| 85 | + |
| 86 | +export default ReactWebChat; |
| 87 | + |
| 88 | +export { |
| 89 | + Components, |
| 90 | + createAdaptiveCardsAttachmentMiddleware, |
| 91 | + createAdaptiveCardsAttachmentForScreenReaderMiddleware, |
| 92 | + createCognitiveServicesSpeechServicesPonyfillFactory, |
| 93 | + createDirectLineSpeechAdapters, |
| 94 | + createStyleSet, |
| 95 | + patchedHooks as hooks, |
| 96 | + renderMarkdown, |
| 97 | + renderWebChat, |
| 98 | + withEmoji |
| 99 | +}; |
| 100 | + |
| 101 | +export type { StyleOptions, StrictStyleOptions }; |
| 102 | + |
| 103 | +window['WebChat'] = { |
| 104 | + ...window['WebChat'], |
| 105 | + Components, |
| 106 | + createAdaptiveCardsAttachmentMiddleware, |
| 107 | + createAdaptiveCardsAttachmentForScreenReaderMiddleware, |
| 108 | + createCognitiveServicesSpeechServicesPonyfillFactory, |
| 109 | + createDirectLine, |
| 110 | + createDirectLineAppServiceExtension, |
| 111 | + createDirectLineSpeechAdapters, |
| 112 | + createStyleSet, |
| 113 | + hooks: patchedHooks, |
| 114 | + ReactWebChat, |
| 115 | + renderMarkdown, |
| 116 | + renderWebChat, |
| 117 | + withEmoji |
| 118 | +}; |
| 119 | + |
| 120 | +addVersion('full'); |
0 commit comments