@carbon/ai-chat 0.4.0-rc.2 → 0.4.0-rc.4
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/dist/es/aiChatEntry.js +220 -14
- package/dist/es/chat.AppContainer.js +6491 -0
- package/dist/es/chat.AppState.js +40 -0
- package/dist/es/{chat/shared/components/BasePanelComponent.js → chat.BasePanelComponent.js} +3 -3
- package/dist/es/{chat/shared/components/panels/BodyAndFooterPanelComponent.js → chat.BodyAndFooterPanelComponent.js} +92 -9
- package/dist/es/chat.BodyWithFooterComponent.js +140 -0
- package/dist/es/{chat/shared/components/header/BotHeader.js → chat.BotHeader.js} +7 -9
- package/dist/es/{chat/shared/components/responseTypes/carousel/Carousel.js → chat.Carousel.js} +3 -3
- package/dist/es/chat.CatastrophicError.js +381 -0
- package/dist/es/chat.Chat.js +2009 -0
- package/dist/es/chat.Disclaimer.js +553 -0
- package/dist/es/chat.Header.js +1025 -0
- package/dist/es/{chat/shared/components/util/HideComponent.js → chat.HideComponent.js} +9 -2
- package/dist/es/{types/config/HomeScreenConfig.js → chat.HomeScreenConfig.js} +1 -1
- package/dist/es/{chat/shared/components/homeScreen/HomeScreen.js → chat.HomeScreenContainer.js} +159 -14
- package/dist/es/{chat/shared/components/homeScreen/HomeScreenHeader.js → chat.HomeScreenHeader.js} +3 -3
- package/dist/es/{chat/shared/services/haa/HumanAgentServiceImpl.js → chat.HumanAgentServiceImpl.js} +215 -17
- package/dist/es/{chat/shared/components/responseTypes/iframe/IFrameComponent.js → chat.IFrameComponent.js} +4 -8
- package/dist/es/chat.IFramePanel.js +151 -0
- package/dist/es/{chat/shared/components/input/Input.js → chat.Input.js} +214 -18
- package/dist/es/{types/config/ServiceDeskConfig.js → chat.LocalMessageItem.js} +17 -1
- package/dist/es/chat.MessageTypeComponent.js +3580 -0
- package/dist/es/{types/messaging/Messages.js → chat.Messages.js} +1 -1
- package/dist/es/chat.MountChildrenOnDelay.js +97 -0
- package/dist/es/{chat/shared/components/OverlayPanel.js → chat.PageObjectId.js} +70 -4
- package/dist/es/{chat/web-components/components/markdownText/src/markdownText.scss.js → chat.RichText.js} +347 -1
- package/dist/es/chat.TourContainer.js +524 -0
- package/dist/es/{chat/languages/en.json.js → chat.VideoComponent.js} +561 -1
- package/dist/es/chat.ViewSourcePanel.js +187 -0
- package/dist/es/{chat/shared/store/actions.js → chat.actions.js} +2 -2
- package/dist/es/{chat/shared/utils/browserUtils.js → chat.browserUtils.js} +1 -1
- package/dist/es/{types/utilities/carbonTypes.js → chat.carbonTypes.js} +2 -2
- package/dist/es/{chat/web-components/components/codeElement/src/codeElement.scss.js → chat.cds-aichat-code.js} +64 -1
- package/dist/es/{chat/shared/utils/constants.js → chat.constants.js} +4 -7
- package/dist/es/{types/events/eventBusTypes.js → chat.customElement.js} +32 -1
- package/dist/es/chat.dynamic-imports.js +192 -0
- package/dist/es/{chat/shared/utils/htmlUtils.js → chat.htmlUtils.js} +16 -2
- package/dist/es/{chat/shared/utils/messageUtils.js → chat.messageUtils.js} +54 -7
- package/dist/es/{chat/shared/utils/miscUtils.js → chat.miscUtils.js} +24 -5
- package/dist/es/chat.resolvablePromise.js +315 -0
- package/dist/es/{chat/shared/store/selectors.js → chat.selectors.js} +1 -1
- package/dist/es/{chat/shared/utils/lang/stringUtils.js → chat.stringUtils.js} +2 -2
- package/dist/es/{chat/shared/hooks/useCounter.js → chat.useCounter.js} +1 -1
- package/dist/es/{chat/shared/hooks/useOnMount.js → chat.useOnMount.js} +1 -1
- package/dist/es/{chat/shared/utils/domUtils.js → chat.usePrevious.js} +47 -1
- package/dist/es/{chat/shared/utils/lang/UUIDType.js → chat.uuid.js} +15 -3
- package/dist/es/web-components/cds-aichat-container/index.js +73 -4
- package/dist/es/web-components/cds-aichat-custom-element/index.js +1 -3
- package/dist/types/aiChatEntry.d.ts +4767 -0
- package/package.json +5 -4
- package/dist/es/chat/dynamic-imports/dynamic-imports.js +0 -96
- package/dist/es/chat/react/components/AppContainer.js +0 -197
- package/dist/es/chat/react/components/UserDefinedResponsePortalsContainer.js +0 -31
- package/dist/es/chat/react/components/WriteableElementsPortalsContainer.js +0 -28
- package/dist/es/chat/react/components/chainOfThought/ChainOfThought.js +0 -20
- package/dist/es/chat/react/components/chatHeader/ChatHeaderAvatar.js +0 -20
- package/dist/es/chat/react/components/chatHeader/ChatHeaderLink.js +0 -22
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenu.js +0 -27
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuButton.js +0 -60
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuItem.js +0 -24
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuItemRadioGroup.js +0 -28
- package/dist/es/chat/react/components/chatHeader/ChatHeaderOverflowMenu.js +0 -69
- package/dist/es/chat/react/components/chatHeader/ChatHeaderTitle.js +0 -22
- package/dist/es/chat/react/components/feedback/FeedbackButtonsComponent.js +0 -20
- package/dist/es/chat/react/components/feedback/FeedbackComponent.js +0 -20
- package/dist/es/chat/react/components/inlineLoading/InlineLoadingComponent.js +0 -20
- package/dist/es/chat/react/components/markdownText/MarkdownText.js +0 -20
- package/dist/es/chat/react/components/stopStreamingButton/StopStreamingButton.js +0 -20
- package/dist/es/chat/react/components/table/Table.js +0 -20
- package/dist/es/chat/shared/Chat.js +0 -115
- package/dist/es/chat/shared/ChatInstanceImpl.js +0 -360
- package/dist/es/chat/shared/chatEntryFunctions.js +0 -46
- package/dist/es/chat/shared/components/Avatar.js +0 -286
- package/dist/es/chat/shared/components/BodyWithFooterComponent.js +0 -56
- package/dist/es/chat/shared/components/CatastrophicError.js +0 -77
- package/dist/es/chat/shared/components/Chat.js +0 -244
- package/dist/es/chat/shared/components/ChatBubbleDark.js +0 -124
- package/dist/es/chat/shared/components/ChatBubbleLight.js +0 -216
- package/dist/es/chat/shared/components/Disclaimer.js +0 -86
- package/dist/es/chat/shared/components/ErrorIcon.js +0 -20
- package/dist/es/chat/shared/components/ErrorMessageDark.js +0 -89
- package/dist/es/chat/shared/components/ErrorMessageLight.js +0 -135
- package/dist/es/chat/shared/components/HydrationPanel.js +0 -58
- package/dist/es/chat/shared/components/LatestWelcomeNodes.js +0 -26
- package/dist/es/chat/shared/components/ResponseStopped.js +0 -19
- package/dist/es/chat/shared/components/SkeletonPicker.js +0 -32
- package/dist/es/chat/shared/components/WriteableElement.js +0 -22
- package/dist/es/chat/shared/components/agent/AgentAvatar.js +0 -54
- package/dist/es/chat/shared/components/agent/AgentBanner.js +0 -109
- package/dist/es/chat/shared/components/agent/AgentBannerContainer.js +0 -28
- package/dist/es/chat/shared/components/agent/AvailabilityMessage.js +0 -49
- package/dist/es/chat/shared/components/aria/AriaAnnouncerComponent.js +0 -122
- package/dist/es/chat/shared/components/aria/AriaAnnouncerProvider.js +0 -48
- package/dist/es/chat/shared/components/aria/AriaLiveMessage.js +0 -22
- package/dist/es/chat/shared/components/header/AISlug.js +0 -22
- package/dist/es/chat/shared/components/header/Header.js +0 -460
- package/dist/es/chat/shared/components/header/SimpleHeader.js +0 -27
- package/dist/es/chat/shared/components/homeScreen/HomeScreenContainer.js +0 -68
- package/dist/es/chat/shared/components/launcher/Launcher.js +0 -88
- package/dist/es/chat/shared/components/launcher/LauncherComplex.js +0 -63
- package/dist/es/chat/shared/components/launcher/LauncherContainer.js +0 -73
- package/dist/es/chat/shared/components/launcher/LauncherDesktopContainer.js +0 -221
- package/dist/es/chat/shared/components/launcher/LauncherExtended.js +0 -244
- package/dist/es/chat/shared/components/launcher/LauncherMobileContainer.js +0 -175
- package/dist/es/chat/shared/components/launcher/launcherUtils.js +0 -16
- package/dist/es/chat/shared/components/modals/ConfirmModal.js +0 -67
- package/dist/es/chat/shared/components/modals/EndAgentChatModal.js +0 -46
- package/dist/es/chat/shared/components/modals/RequestScreenShareModal.js +0 -43
- package/dist/es/chat/shared/components/notifications/Notifications.js +0 -58
- package/dist/es/chat/shared/components/panels/CustomPanel.js +0 -136
- package/dist/es/chat/shared/components/responseTypes/agent/ConnectToAgent.js +0 -30
- package/dist/es/chat/shared/components/responseTypes/agent/RealConnectToAgent.js +0 -102
- package/dist/es/chat/shared/components/responseTypes/audio/AudioComponent.js +0 -26
- package/dist/es/chat/shared/components/responseTypes/buttonItem/BaseButtonItemComponent.js +0 -69
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemComponent.js +0 -48
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemCustomEventComponent.js +0 -42
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemPostBackComponent.js +0 -54
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemShowPanelComponent.js +0 -36
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemURLComponent.js +0 -42
- package/dist/es/chat/shared/components/responseTypes/card/CardItemComponent.js +0 -34
- package/dist/es/chat/shared/components/responseTypes/carousel/CarouselItemComponent.js +0 -39
- package/dist/es/chat/shared/components/responseTypes/conversationalSearch/ConversationalSearch.js +0 -92
- package/dist/es/chat/shared/components/responseTypes/conversationalSearch/ConversationalSearchText.js +0 -158
- package/dist/es/chat/shared/components/responseTypes/custom/UserDefinedResponse.js +0 -33
- package/dist/es/chat/shared/components/responseTypes/datePicker/DatePickerComponent.js +0 -176
- package/dist/es/chat/shared/components/responseTypes/error/InlineError.js +0 -32
- package/dist/es/chat/shared/components/responseTypes/grid/GridItemComponent.js +0 -109
- package/dist/es/chat/shared/components/responseTypes/iframe/IFrameMessage.js +0 -32
- package/dist/es/chat/shared/components/responseTypes/iframe/IFramePanel.js +0 -51
- package/dist/es/chat/shared/components/responseTypes/iframe/IFramePreviewCard.js +0 -64
- package/dist/es/chat/shared/components/responseTypes/iframe/InlineIFrame.js +0 -55
- package/dist/es/chat/shared/components/responseTypes/image/Image.js +0 -120
- package/dist/es/chat/shared/components/responseTypes/options/OptionComponent.js +0 -83
- package/dist/es/chat/shared/components/responseTypes/options/SelectComponent.js +0 -84
- package/dist/es/chat/shared/components/responseTypes/table/TableContainer.js +0 -96
- package/dist/es/chat/shared/components/responseTypes/text/TextArea.js +0 -68
- package/dist/es/chat/shared/components/responseTypes/tour/TourCard.js +0 -73
- package/dist/es/chat/shared/components/responseTypes/util/BodyMessageComponents.js +0 -65
- package/dist/es/chat/shared/components/responseTypes/util/ClickableImage.js +0 -36
- package/dist/es/chat/shared/components/responseTypes/util/Description.js +0 -21
- package/dist/es/chat/shared/components/responseTypes/util/FooterButtonComponents.js +0 -36
- package/dist/es/chat/shared/components/responseTypes/util/MediaPlayer.js +0 -157
- package/dist/es/chat/shared/components/responseTypes/util/Metablock.js +0 -27
- package/dist/es/chat/shared/components/responseTypes/util/RichText.js +0 -31
- package/dist/es/chat/shared/components/responseTypes/util/SearchResultBody.js +0 -53
- package/dist/es/chat/shared/components/responseTypes/util/StreamingRichText.js +0 -38
- package/dist/es/chat/shared/components/responseTypes/util/TextHolderTile.js +0 -35
- package/dist/es/chat/shared/components/responseTypes/util/citations/CitationCard.js +0 -65
- package/dist/es/chat/shared/components/responseTypes/util/citations/CitationCardContent.js +0 -62
- package/dist/es/chat/shared/components/responseTypes/util/citations/CitationClickableCard.js +0 -23
- package/dist/es/chat/shared/components/responseTypes/util/citations/ExpandToPanelCard.js +0 -50
- package/dist/es/chat/shared/components/responseTypes/util/citations/ViewSourcePanel.js +0 -57
- package/dist/es/chat/shared/components/responseTypes/video/VideoComponent.js +0 -23
- package/dist/es/chat/shared/components/tour/TourCloseMinimizeComponent.js +0 -44
- package/dist/es/chat/shared/components/tour/TourContainer.js +0 -212
- package/dist/es/chat/shared/components/tour/TourControlsComponent.js +0 -98
- package/dist/es/chat/shared/components/tour/TourStepContentComponent.js +0 -156
- package/dist/es/chat/shared/components/tour/TourStepSkeletonComponent.js +0 -20
- package/dist/es/chat/shared/components/util/AnnounceOnMountComponent.js +0 -42
- package/dist/es/chat/shared/components/util/IconHolder.js +0 -16
- package/dist/es/chat/shared/components/util/ImageWithFallback.js +0 -31
- package/dist/es/chat/shared/components/util/MaybeDangerouslySetInnerHTML.js +0 -42
- package/dist/es/chat/shared/components/util/MountChildrenOnDelay.js +0 -40
- package/dist/es/chat/shared/components/util/VisuallyHidden.js +0 -18
- package/dist/es/chat/shared/containers/App.js +0 -181
- package/dist/es/chat/shared/containers/MessageComponent.js +0 -465
- package/dist/es/chat/shared/containers/MessageTypeComponent.js +0 -496
- package/dist/es/chat/shared/containers/MessagesComponent.js +0 -469
- package/dist/es/chat/shared/containers/ModalPortal.js +0 -53
- package/dist/es/chat/shared/containers/main/MainWindow.js +0 -708
- package/dist/es/chat/shared/contexts/AriaAnnouncerContext.js +0 -12
- package/dist/es/chat/shared/contexts/HideComponentContext.js +0 -12
- package/dist/es/chat/shared/contexts/LanguagePackContext.js +0 -12
- package/dist/es/chat/shared/contexts/ModalPortalRootContext.js +0 -12
- package/dist/es/chat/shared/contexts/ServiceManagerContext.js +0 -12
- package/dist/es/chat/shared/contexts/WindowSizeContext.js +0 -12
- package/dist/es/chat/shared/environmentVariables.js +0 -13
- package/dist/es/chat/shared/events/ChatActionsImpl.js +0 -783
- package/dist/es/chat/shared/events/EventBus.js +0 -161
- package/dist/es/chat/shared/hocs/withAriaAnnouncer.js +0 -25
- package/dist/es/chat/shared/hocs/withServiceManager.js +0 -25
- package/dist/es/chat/shared/hooks/useAriaAnnouncer.js +0 -16
- package/dist/es/chat/shared/hooks/useCSSCustomProperties.js +0 -21
- package/dist/es/chat/shared/hooks/useCallbackOnChange.js +0 -24
- package/dist/es/chat/shared/hooks/useEffectDidUpdate.js +0 -21
- package/dist/es/chat/shared/hooks/useLanguagePack.js +0 -16
- package/dist/es/chat/shared/hooks/usePrevious.js +0 -18
- package/dist/es/chat/shared/hooks/useServiceManager.js +0 -16
- package/dist/es/chat/shared/hooks/useShouldSanitizeHTML.js +0 -15
- package/dist/es/chat/shared/hooks/useUUID.js +0 -22
- package/dist/es/chat/shared/hooks/useWindowSize.js +0 -16
- package/dist/es/chat/shared/loadServices.js +0 -72
- package/dist/es/chat/shared/schema/historyToMessages.js +0 -231
- package/dist/es/chat/shared/schema/inputItemToLocalItem.js +0 -30
- package/dist/es/chat/shared/schema/outputItemToLocalItem.js +0 -124
- package/dist/es/chat/shared/services/CustomPanelInstance.js +0 -26
- package/dist/es/chat/shared/services/CustomPanelManager.js +0 -23
- package/dist/es/chat/shared/services/HistoryService.js +0 -59
- package/dist/es/chat/shared/services/MessageService.js +0 -351
- package/dist/es/chat/shared/services/NamespaceService.js +0 -26
- package/dist/es/chat/shared/services/ServiceManager.js +0 -19
- package/dist/es/chat/shared/services/UserSessionStorageService.js +0 -89
- package/dist/es/chat/shared/services/haa/agentStatusMessage.js +0 -108
- package/dist/es/chat/shared/services/haa/humanAgentUtils.js +0 -114
- package/dist/es/chat/shared/services/mockStorage.js +0 -30
- package/dist/es/chat/shared/store/agentActions.js +0 -125
- package/dist/es/chat/shared/store/agentReducers.js +0 -215
- package/dist/es/chat/shared/store/doCreateStore.js +0 -142
- package/dist/es/chat/shared/store/reducerUtils.js +0 -320
- package/dist/es/chat/shared/store/reducers.js +0 -871
- package/dist/es/chat/shared/store/subscriptions.js +0 -55
- package/dist/es/chat/shared/store/tourReducerUtils.js +0 -51
- package/dist/es/chat/shared/utils/ListenerList.js +0 -26
- package/dist/es/chat/shared/utils/PageObjectId.js +0 -25
- package/dist/es/chat/shared/utils/animationUtils.js +0 -77
- package/dist/es/chat/shared/utils/colors.js +0 -71
- package/dist/es/chat/shared/utils/customizers.js +0 -16
- package/dist/es/chat/shared/utils/dateUtils.js +0 -38
- package/dist/es/chat/shared/utils/homeScreenUtils.js +0 -27
- package/dist/es/chat/shared/utils/intlUtils.js +0 -21
- package/dist/es/chat/shared/utils/lang/arrayUtils.js +0 -53
- package/dist/es/chat/shared/utils/lang/langUtils.js +0 -13
- package/dist/es/chat/shared/utils/lang/objectUtils.js +0 -19
- package/dist/es/chat/shared/utils/lang/promiseUtils.js +0 -25
- package/dist/es/chat/shared/utils/lang/uuid.js +0 -16
- package/dist/es/chat/shared/utils/languages.js +0 -156
- package/dist/es/chat/shared/utils/memoizerUtils.js +0 -38
- package/dist/es/chat/shared/utils/messageServiceUtils.js +0 -36
- package/dist/es/chat/shared/utils/resolvablePromise.js +0 -32
- package/dist/es/chat/shared/utils/styleUtils.js +0 -231
- package/dist/es/chat/shared/utils/timeUtils.js +0 -14
- package/dist/es/chat/shared/utils/viewStateUtils.js +0 -38
- package/dist/es/chat/web-components/components/chainOfThought/cds-aichat-chain-of-thought.js +0 -26
- package/dist/es/chat/web-components/components/chainOfThought/src/ChainOfThoughtElement.js +0 -130
- package/dist/es/chat/web-components/components/chainOfThought/src/chainOfThoughtElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/chainOfThought/src/chainOfThoughtElement.template.js +0 -186
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/cds-aichat-chat-header-avatar.js +0 -26
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatar.template.js +0 -32
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatarElement.js +0 -52
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatarElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderLink/cds-aichat-chat-header-link.js +0 -44
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderLink/src/chatHeaderLinkElement.template.js +0 -28
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/cds-aichat-chat-header-title.js +0 -42
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/src/chatHeaderTitle.scss.js +0 -3
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/src/chatHeaderTitle.template.js +0 -20
- package/dist/es/chat/web-components/components/codeElement/cds-aichat-code.js +0 -66
- package/dist/es/chat/web-components/components/feedbackButtonsElement/cds-aichat-feedback-buttons.js +0 -26
- package/dist/es/chat/web-components/components/feedbackButtonsElement/src/FeedbackButtonsElement.js +0 -93
- package/dist/es/chat/web-components/components/feedbackButtonsElement/src/feedbackButtonsElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/feedbackButtonsElement/src/feedbackButtonsElement.template.js +0 -84
- package/dist/es/chat/web-components/components/feedbackElement/cds-aichat-feedback.js +0 -30
- package/dist/es/chat/web-components/components/feedbackElement/src/FeedbackElement.js +0 -157
- package/dist/es/chat/web-components/components/feedbackElement/src/feedbackElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/feedbackElement/src/feedbackElement.template.js +0 -95
- package/dist/es/chat/web-components/components/inlineLoadingElement/cds-aichat-inline-loading.js +0 -85
- package/dist/es/chat/web-components/components/inlineLoadingElement/src/styles.scss.js +0 -3
- package/dist/es/chat/web-components/components/markdownText/cds-aichat-markdown-text.js +0 -32
- package/dist/es/chat/web-components/components/markdownText/markdown/markdownToHTML.js +0 -28
- package/dist/es/chat/web-components/components/markdownText/markdown/utils/renderTokenTree.js +0 -191
- package/dist/es/chat/web-components/components/markdownText/markdown/workers/workerManager.js +0 -16
- package/dist/es/chat/web-components/components/markdownText/src/MarkdownElement.js +0 -70
- package/dist/es/chat/web-components/components/markdownText/src/markdownElement.template.js +0 -19
- package/dist/es/chat/web-components/components/roundedButton/cds-aichat-rounded-button.js +0 -29
- package/dist/es/chat/web-components/components/stopStreamingButton/cds-aichat-stop-streaming-button.js +0 -26
- package/dist/es/chat/web-components/components/stopStreamingButton/src/StopStreamingButtonElement.js +0 -49
- package/dist/es/chat/web-components/components/stopStreamingButton/src/stopStreamingButton.scss.js +0 -3
- package/dist/es/chat/web-components/components/stopStreamingButton/src/stopStreamingButton.template.js +0 -44
- package/dist/es/chat/web-components/components/table/cds-aichat-table.js +0 -229
- package/dist/es/chat/web-components/components/table/src/table.scss.js +0 -3
- package/dist/es/chat/web-components/components/table/src/table.template.js +0 -81
- package/dist/es/chat/web-components/components/table/src/tablePagination.template.js +0 -43
- package/dist/es/chat/web-components/components/table/src/tableSkeleton.template.js +0 -17
- package/dist/es/chat/web-components/components/tagListElement/cds-aichat-tag-list.js +0 -28
- package/dist/es/chat/web-components/components/tagListElement/src/TagListElement.js +0 -70
- package/dist/es/chat/web-components/components/tagListElement/src/tagListElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/tagListElement/src/tagListElement.template.js +0 -40
- package/dist/es/chat/web-components/decorators/customElement.js +0 -33
- package/dist/es/chat/web-components/internal/cds-aichat-internal.js +0 -78
- package/dist/es/chat/web-components/settings.js +0 -13
- package/dist/es/node_modules/@carbon/colors/es/index.js +0 -11
- package/dist/es/react/ChatContainer.js +0 -162
- package/dist/es/react/ChatCustomElement.js +0 -58
- package/dist/es/types/config/ChatHeaderConfig.js +0 -18
- package/dist/es/types/config/CornersType.js +0 -16
- package/dist/es/types/config/LauncherConfig.js +0 -19
- package/dist/es/types/config/PublicConfig.js +0 -36
- package/dist/es/types/instance/ChatInstance.js +0 -31
- package/dist/es/types/instance/apiTypes.js +0 -33
- package/dist/es/types/messaging/LocalMessageItem.js +0 -18
- package/dist/es/types/state/AppState.js +0 -18
- package/dist/es/types/utilities/Animation.js +0 -31
- package/dist/es/types/utilities/HasAddRemoveClassName.js +0 -27
- /package/dist/es/{chat/shared/styles/export.carbon.scss.js → chat.export.carbon.js} +0 -0
- /package/dist/es/{chat/shared/styles/export.scss.js → chat.export.js} +0 -0
- /package/dist/es/{chat/web-components/components/markdownText/markdown/utils/markdown.js → chat.markdown.js} +0 -0
- /package/dist/es/{chat/web-components/components/markdownText/markdown/utils/tokenTree.js → chat.tokenTree.js} +0 -0
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
const UNREAD_COUNT_TITLE_TIME = 1e4;
|
|
10
|
-
|
|
11
|
-
function copyToSessionStorage(serviceManager) {
|
|
12
|
-
let previousPersistedToBrowserStorage = serviceManager.store.getState().persistedToBrowserStorage;
|
|
13
|
-
return () => {
|
|
14
|
-
const {persistedToBrowserStorage: persistedToBrowserStorage} = serviceManager.store.getState();
|
|
15
|
-
const persistChatSession = previousPersistedToBrowserStorage !== persistedToBrowserStorage;
|
|
16
|
-
if (persistChatSession) {
|
|
17
|
-
previousPersistedToBrowserStorage = persistedToBrowserStorage;
|
|
18
|
-
serviceManager.userSessionStorageService.persistChatSession(persistedToBrowserStorage.chatState);
|
|
19
|
-
serviceManager.userSessionStorageService.persistLauncherSession(persistedToBrowserStorage.launcherState);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function createHandleWindowTitle(serviceManager) {
|
|
25
|
-
const {store: store} = serviceManager;
|
|
26
|
-
let originalTitle;
|
|
27
|
-
let changeTitleTimer;
|
|
28
|
-
let previousState = store.getState();
|
|
29
|
-
return () => {
|
|
30
|
-
const state = store.getState();
|
|
31
|
-
const {agentState: agentState} = store.getState();
|
|
32
|
-
const {numUnreadMessages: numUnreadMessages} = agentState;
|
|
33
|
-
if (numUnreadMessages !== previousState.agentState.numUnreadMessages) {
|
|
34
|
-
if (!numUnreadMessages) {
|
|
35
|
-
clearTimeout(changeTitleTimer);
|
|
36
|
-
if (originalTitle) {
|
|
37
|
-
window.document.title = originalTitle;
|
|
38
|
-
originalTitle = null;
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
clearTimeout(changeTitleTimer);
|
|
42
|
-
if (!originalTitle) {
|
|
43
|
-
originalTitle = window.document.title;
|
|
44
|
-
}
|
|
45
|
-
window.document.title = state.languagePack.agent_newMessage;
|
|
46
|
-
changeTitleTimer = setTimeout(() => {
|
|
47
|
-
window.document.title = `(${numUnreadMessages}) ${originalTitle}`;
|
|
48
|
-
}, UNREAD_COUNT_TITLE_TIME);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
previousState = state;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export { copyToSessionStorage, createHandleWindowTitle };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
function populateTourStepItems(state) {
|
|
10
|
-
const {activeTourID: activeTourID} = state.persistedToBrowserStorage.chatState.persistedTourState;
|
|
11
|
-
if (activeTourID) {
|
|
12
|
-
const originalMessage = state.allMessagesByID[activeTourID];
|
|
13
|
-
const tourMessageItem = originalMessage?.output?.generic?.find(message => Boolean(message.user_defined?.steps));
|
|
14
|
-
if (tourMessageItem) {
|
|
15
|
-
return {
|
|
16
|
-
...state,
|
|
17
|
-
tourState: {
|
|
18
|
-
...state.tourState,
|
|
19
|
-
activeTourStepItems: tourMessageItem.user_defined?.steps
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return clearTourState(state);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function clearTourState(state) {
|
|
28
|
-
return {
|
|
29
|
-
...state,
|
|
30
|
-
persistedToBrowserStorage: {
|
|
31
|
-
...state.persistedToBrowserStorage,
|
|
32
|
-
chatState: {
|
|
33
|
-
...state.persistedToBrowserStorage.chatState,
|
|
34
|
-
persistedTourState: {
|
|
35
|
-
activeTourID: null,
|
|
36
|
-
activeTourCurrentStepIndex: null
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
launcherState: {
|
|
40
|
-
...state.persistedToBrowserStorage.launcherState,
|
|
41
|
-
activeTour: false
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
tourState: {
|
|
45
|
-
...state.tourState,
|
|
46
|
-
activeTourStepItems: null
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export { clearTourState, populateTourStepItems };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
class ListenerList {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.listeners = [];
|
|
12
|
-
}
|
|
13
|
-
addListener(listenerToAdd) {
|
|
14
|
-
this.listeners = [ ...this.listeners, listenerToAdd ];
|
|
15
|
-
}
|
|
16
|
-
removeListener(listenerToRemove) {
|
|
17
|
-
this.listeners = this.listeners.filter(listener => listener !== listenerToRemove);
|
|
18
|
-
}
|
|
19
|
-
fireListeners(...args) {
|
|
20
|
-
if (this.listeners.length) {
|
|
21
|
-
this.listeners.forEach(listener => listener(...args));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { ListenerList };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
var PageObjectId;
|
|
10
|
-
|
|
11
|
-
(function(PageObjectId) {
|
|
12
|
-
PageObjectId["CLOSE_CHAT"] = "close_chat";
|
|
13
|
-
PageObjectId["LAUNCHER"] = "launcher_open_chat";
|
|
14
|
-
PageObjectId["INPUT"] = "input_field";
|
|
15
|
-
PageObjectId["INPUT_SEND"] = "input_send";
|
|
16
|
-
})(PageObjectId || (PageObjectId = {}));
|
|
17
|
-
|
|
18
|
-
function makeTestId(id, panel) {
|
|
19
|
-
if (panel) {
|
|
20
|
-
return `${panel}-${id}`;
|
|
21
|
-
}
|
|
22
|
-
return id;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { PageObjectId, makeTestId };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
function animateWithClass(element, className, endAnimationNameOrDelay, endAnimationCallback) {
|
|
10
|
-
if (element) {
|
|
11
|
-
element.classList.add(className);
|
|
12
|
-
if (typeof endAnimationNameOrDelay === "number") {
|
|
13
|
-
setTimeout(() => {
|
|
14
|
-
element.classList.remove(className);
|
|
15
|
-
if (endAnimationCallback) {
|
|
16
|
-
endAnimationCallback();
|
|
17
|
-
}
|
|
18
|
-
}, endAnimationNameOrDelay);
|
|
19
|
-
} else {
|
|
20
|
-
const listener = event => {
|
|
21
|
-
if (!endAnimationNameOrDelay || event.animationName === endAnimationNameOrDelay) {
|
|
22
|
-
element.removeEventListener("animationend", listener);
|
|
23
|
-
element.removeEventListener("animationcancel", listener);
|
|
24
|
-
element.classList.remove(className);
|
|
25
|
-
if (endAnimationCallback) {
|
|
26
|
-
endAnimationCallback();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
element.addEventListener("animationend", listener);
|
|
31
|
-
element.addEventListener("animationcancel", listener);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function setAnimationTimeouts(element, animation, timeouts, options) {
|
|
37
|
-
const {startingIndex: startingIndex, beforeAll: beforeAll, afterAll: afterAll, beforeEach: beforeEach, afterEach: afterEach} = options;
|
|
38
|
-
let index = startingIndex || 0;
|
|
39
|
-
let terminate = false;
|
|
40
|
-
let timeoutID = null;
|
|
41
|
-
function playAnimation() {
|
|
42
|
-
if (beforeAll && index === 0) {
|
|
43
|
-
beforeAll();
|
|
44
|
-
}
|
|
45
|
-
const isComplete = index === timeouts.length;
|
|
46
|
-
if (!isComplete && !terminate) {
|
|
47
|
-
timeoutID = setTimeout(setAnimationListener, timeouts[index]);
|
|
48
|
-
} else if (isComplete && afterAll) {
|
|
49
|
-
afterAll();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function replayAnimation() {
|
|
53
|
-
if (afterEach) {
|
|
54
|
-
afterEach();
|
|
55
|
-
}
|
|
56
|
-
index++;
|
|
57
|
-
element.removeEventListener("animationend", replayAnimation);
|
|
58
|
-
element.classList.remove(animation);
|
|
59
|
-
playAnimation();
|
|
60
|
-
}
|
|
61
|
-
function setAnimationListener() {
|
|
62
|
-
if (beforeEach) {
|
|
63
|
-
beforeEach();
|
|
64
|
-
}
|
|
65
|
-
element.addEventListener("animationend", replayAnimation);
|
|
66
|
-
element.classList.add(animation);
|
|
67
|
-
}
|
|
68
|
-
playAnimation();
|
|
69
|
-
return () => {
|
|
70
|
-
terminate = true;
|
|
71
|
-
clearTimeout(timeoutID);
|
|
72
|
-
element.classList.remove(animation);
|
|
73
|
-
element.removeEventListener("animationend", replayAnimation);
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export { animateWithClass, setAnimationTimeouts };
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { gray100, white } from "../../../node_modules/@carbon/colors/es/index.js";
|
|
2
|
-
|
|
3
|
-
import Color from "color";
|
|
4
|
-
|
|
5
|
-
import { consoleError } from "./miscUtils.js";
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
* Copyright IBM Corp. 2025
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*
|
|
13
|
-
* @license
|
|
14
|
-
*/
|
|
15
|
-
const MIN_CONTRAST = 4.5;
|
|
16
|
-
|
|
17
|
-
function hexCodeToRGB(color) {
|
|
18
|
-
if (color.length === 7) {
|
|
19
|
-
const red = color.substring(1, 3);
|
|
20
|
-
const blue = color.substring(3, 5);
|
|
21
|
-
const green = color.substring(5, 7);
|
|
22
|
-
return [ parseInt(red, 16), parseInt(blue, 16), parseInt(green, 16) ];
|
|
23
|
-
}
|
|
24
|
-
if (color.length === 4) {
|
|
25
|
-
const red = color.substring(1, 2);
|
|
26
|
-
const blue = color.substring(2, 3);
|
|
27
|
-
const green = color.substring(3, 4);
|
|
28
|
-
return [ parseInt(red + red, 16), parseInt(blue + blue, 16), parseInt(green + green, 16) ];
|
|
29
|
-
}
|
|
30
|
-
consoleError(`Unsupported color code: "${color}"`);
|
|
31
|
-
return [ 0, 0, 0 ];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function calculateContrast(color1, color2) {
|
|
35
|
-
const rgb1 = hexCodeToRGB(color1);
|
|
36
|
-
const rgb2 = hexCodeToRGB(color2);
|
|
37
|
-
const luminance1 = calculateRelativeLuminance(rgb1);
|
|
38
|
-
const luminance2 = calculateRelativeLuminance(rgb2);
|
|
39
|
-
let contrast;
|
|
40
|
-
if (luminance1 > luminance2) {
|
|
41
|
-
contrast = (luminance1 + .05) / (luminance2 + .05);
|
|
42
|
-
} else {
|
|
43
|
-
contrast = (luminance2 + .05) / (luminance1 + .05);
|
|
44
|
-
}
|
|
45
|
-
return contrast;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function calculateRelativeLuminance([r8, g8, b8]) {
|
|
49
|
-
const rRGB = r8 / 255;
|
|
50
|
-
const gRGB = g8 / 255;
|
|
51
|
-
const bRGB = b8 / 255;
|
|
52
|
-
const R = rRGB <= .03928 ? rRGB / 12.92 : ((rRGB + .055) / 1.055) ** 2.4;
|
|
53
|
-
const G = gRGB <= .03928 ? gRGB / 12.92 : ((gRGB + .055) / 1.055) ** 2.4;
|
|
54
|
-
const B = bRGB <= .03928 ? bRGB / 12.92 : ((bRGB + .055) / 1.055) ** 2.4;
|
|
55
|
-
const luminance = .2126 * R + .7152 * G + .0722 * B;
|
|
56
|
-
return luminance;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function whiteOrBlackText(background) {
|
|
60
|
-
return calculateContrast(gray100, background) >= MIN_CONTRAST ? gray100 : white;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function adjustLightness(token, shift) {
|
|
64
|
-
const original = Color(token).hsl().object();
|
|
65
|
-
return Color({
|
|
66
|
-
...original,
|
|
67
|
-
l: original.l + shift
|
|
68
|
-
}).round().hex().toLowerCase();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { MIN_CONTRAST, adjustLightness, calculateContrast, hexCodeToRGB, whiteOrBlackText };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
function replaceCurrentArrayValue(currentValue, newValue) {
|
|
10
|
-
if (Array.isArray(newValue)) {
|
|
11
|
-
return newValue;
|
|
12
|
-
}
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { replaceCurrentArrayValue };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { RIGHT_TO_LEFT_MARK } from "./constants.js";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright IBM Corp. 2025
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license
|
|
10
|
-
*/
|
|
11
|
-
const UNWANTED_CHARACTERS_REGEX = new RegExp(`[ ${RIGHT_TO_LEFT_MARK}]|\\.$`, "g");
|
|
12
|
-
|
|
13
|
-
function sanitizeDateFormat(value) {
|
|
14
|
-
let format = value.replace(UNWANTED_CHARACTERS_REGEX, "");
|
|
15
|
-
if (!format.includes("mm")) {
|
|
16
|
-
format = format.replace("m", "mm");
|
|
17
|
-
}
|
|
18
|
-
if (!format.includes("dd")) {
|
|
19
|
-
format = format.replace("d", "dd");
|
|
20
|
-
}
|
|
21
|
-
return format;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function toUserDateFormat(date, format) {
|
|
25
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
26
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
27
|
-
const year = String(date.getFullYear());
|
|
28
|
-
return format.replace("dd", day).replace("mm", month).replace("yyyy", year);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function toAssistantDateFormat(date) {
|
|
32
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
33
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
34
|
-
const year = String(date.getFullYear());
|
|
35
|
-
return `${year}-${month}-${day}`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { sanitizeDateFormat, toAssistantDateFormat, toUserDateFormat };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
function withoutEmptyStarters(config) {
|
|
10
|
-
let newConfig = config;
|
|
11
|
-
if (config?.starters?.buttons?.length) {
|
|
12
|
-
newConfig = {
|
|
13
|
-
allow_return: true,
|
|
14
|
-
...config,
|
|
15
|
-
starters: {
|
|
16
|
-
...config.starters,
|
|
17
|
-
buttons: config.starters.buttons.filter(button => Boolean(button.label?.trim()))
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
if (!newConfig?.starters?.buttons?.length) {
|
|
21
|
-
newConfig.starters.is_on = false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return newConfig;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { withoutEmptyStarters };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createIntl } from "react-intl";
|
|
2
|
-
|
|
3
|
-
import actions from "../store/actions.js";
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Copyright IBM Corp. 2025
|
|
7
|
-
*
|
|
8
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
9
|
-
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*
|
|
11
|
-
* @license
|
|
12
|
-
*/ function setIntl(serviceManager, locale, messages) {
|
|
13
|
-
serviceManager.intl = createIntl({
|
|
14
|
-
locale: locale,
|
|
15
|
-
messages: messages
|
|
16
|
-
});
|
|
17
|
-
serviceManager.store.dispatch(actions.setAppStateValue("languagePack", messages));
|
|
18
|
-
serviceManager.store.dispatch(actions.setAppStateValue("locale", locale));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { setIntl };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
function asArray(value) {
|
|
10
|
-
return Array.isArray(value) ? value : [ value ];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async function asyncForEach(array, callbackFunction) {
|
|
14
|
-
for (let index = 0; index < array.length; index++) {
|
|
15
|
-
const value = array[index];
|
|
16
|
-
await callbackFunction(value, index, array);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function findLast(array, predicate, startAt) {
|
|
21
|
-
const lastIndex = findLastIndex(array, predicate);
|
|
22
|
-
return lastIndex === -1 ? undefined : array[lastIndex];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function findLastIndex(array, predicate, startAt) {
|
|
26
|
-
if (array) {
|
|
27
|
-
const startingIndex = array.length - 1;
|
|
28
|
-
for (let index = startingIndex; index >= 0; index--) {
|
|
29
|
-
const value = array[index];
|
|
30
|
-
if (predicate(value, index, array)) {
|
|
31
|
-
return index;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return -1;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function findLastWithMap(keys, map, predicate) {
|
|
39
|
-
for (let index = keys.length - 1; index >= 0; index--) {
|
|
40
|
-
const key = keys[index];
|
|
41
|
-
const value = map[key];
|
|
42
|
-
if (predicate(value, index, keys)) {
|
|
43
|
-
return value;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function arrayLastValue(array) {
|
|
50
|
-
return array && array.length ? array[array.length - 1] : null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { arrayLastValue, asArray, asyncForEach, findLast, findLastWithMap };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
function isNil(value) {
|
|
10
|
-
return value === undefined || value === null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { isNil };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
function deepFreeze(object) {
|
|
10
|
-
Object.freeze(object);
|
|
11
|
-
Object.getOwnPropertyNames(object).forEach(prop => {
|
|
12
|
-
if (Object.prototype.hasOwnProperty.call(object, prop) && object[prop] !== null && (typeof object[prop] === "object" || typeof object[prop] === "function") && !Object.isFrozen(object[prop])) {
|
|
13
|
-
deepFreeze(object[prop]);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
return object;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { deepFreeze };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @license
|
|
8
|
-
*/
|
|
9
|
-
async function sleep(milliseconds) {
|
|
10
|
-
await new Promise(resolve => {
|
|
11
|
-
setTimeout(resolve, milliseconds);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function resolveOrTimeout(promise, duration, errorMessage) {
|
|
16
|
-
const timeout = new Promise((resolve, reject) => {
|
|
17
|
-
setTimeout(() => {
|
|
18
|
-
const message = errorMessage || `The operation timed out after ${duration}ms`;
|
|
19
|
-
reject(message);
|
|
20
|
-
}, duration);
|
|
21
|
-
});
|
|
22
|
-
return Promise.race([ promise, timeout ]);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { resolveOrTimeout, sleep };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { v4 } from "uuid";
|
|
2
|
-
|
|
3
|
-
export { UUIDType } from "./UUIDType.js";
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Copyright IBM Corp. 2025
|
|
7
|
-
*
|
|
8
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
9
|
-
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*
|
|
11
|
-
* @license
|
|
12
|
-
*/ function uuid(_type) {
|
|
13
|
-
return v4();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { uuid };
|