@red-hat-developer-hub/backstage-plugin-intelligent-assistant 5.2.0 → 5.3.1
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/CHANGELOG.md +21 -0
- package/README.md +14 -2
- package/dist/alpha.d.ts +24 -0
- package/dist/components/AttachmentContext.esm.js +1 -1
- package/dist/components/ChatLoadingFallback.esm.js +37 -0
- package/dist/components/ChatLoadingFallback.esm.js.map +1 -0
- package/dist/components/CollapsedHistoryStrip.esm.js +1 -1
- package/dist/components/LightSpeedChat.esm.js +76 -29
- package/dist/components/LightSpeedChat.esm.js.map +1 -1
- package/dist/components/LightspeedChatBox.esm.js +2 -2
- package/dist/components/LightspeedChatBoxHeader.esm.js +30 -2
- package/dist/components/LightspeedChatBoxHeader.esm.js.map +1 -1
- package/dist/components/LightspeedChatContainer.esm.js +20 -4
- package/dist/components/LightspeedChatContainer.esm.js.map +1 -1
- package/dist/components/LightspeedDrawerContext.esm.js.map +1 -1
- package/dist/components/LightspeedDrawerProvider.esm.js +11 -25
- package/dist/components/LightspeedDrawerProvider.esm.js.map +1 -1
- package/dist/components/LightspeedFABContent.esm.js +14 -2
- package/dist/components/LightspeedFABContent.esm.js.map +1 -1
- package/dist/components/LightspeedOverlayChat.esm.js +39 -0
- package/dist/components/LightspeedOverlayChat.esm.js.map +1 -0
- package/dist/components/McpConfigureServerModal.esm.js +2 -2
- package/dist/components/MessageBarModelSelector.esm.js +105 -13
- package/dist/components/MessageBarModelSelector.esm.js.map +1 -1
- package/dist/components/ScreenContextChip.esm.js +172 -0
- package/dist/components/ScreenContextChip.esm.js.map +1 -0
- package/dist/components/ToastAlertGroup.esm.js +1 -1
- package/dist/components/criticalFabBundle.esm.js +3 -0
- package/dist/components/criticalFabBundle.esm.js.map +1 -0
- package/dist/components/loaders.esm.js +11 -0
- package/dist/components/loaders.esm.js.map +1 -0
- package/dist/components/notebooks/AddDocumentModal.esm.js +2 -2
- package/dist/components/notebooks/DocumentSidebar.esm.js +1 -1
- package/dist/components/notebooks/NotebookCard.esm.js +1 -1
- package/dist/components/notebooks/NotebookStreamProvider.esm.js +1 -1
- package/dist/components/notebooks/NotebookView.esm.js +3 -3
- package/dist/components/notebooks/OverwriteConfirmModal.esm.js +1 -1
- package/dist/components/notebooks/UploadResourceScreen.esm.js +1 -1
- package/dist/components/notebooks/notebookStreamStore.esm.js +1 -1
- package/dist/components/notebooks/notebookStreamStore.esm.js.map +1 -1
- package/dist/const.esm.js +9 -1
- package/dist/const.esm.js.map +1 -1
- package/dist/fabModule.esm.js +51 -0
- package/dist/fabModule.esm.js.map +1 -0
- package/dist/hooks/screenContextLabelSubscription.esm.js +113 -0
- package/dist/hooks/screenContextLabelSubscription.esm.js.map +1 -0
- package/dist/hooks/useConversationMessages.esm.js +2 -1
- package/dist/hooks/useConversationMessages.esm.js.map +1 -1
- package/dist/hooks/useDisplayModeSettings.esm.js +1 -1
- package/dist/hooks/useDisplayModeSettings.esm.js.map +1 -1
- package/dist/hooks/useLightspeedProviderState.esm.js +1 -2
- package/dist/hooks/useLightspeedProviderState.esm.js.map +1 -1
- package/dist/hooks/useScreenContextLabelRevision.esm.js +13 -0
- package/dist/hooks/useScreenContextLabelRevision.esm.js.map +1 -0
- package/dist/hooks/useScreenContextSettings.esm.js +110 -0
- package/dist/hooks/useScreenContextSettings.esm.js.map +1 -0
- package/dist/hooks/useWindowLocation.esm.js +28 -0
- package/dist/hooks/useWindowLocation.esm.js.map +1 -0
- package/dist/index.d.ts +1 -15
- package/dist/index.esm.js +7 -69
- package/dist/index.esm.js.map +1 -1
- package/dist/intelligent-assistant-fab-module.d.ts +12 -4
- package/dist/intelligent-assistant-fab-module.esm.js +1 -1
- package/dist/intelligent-assistant-translations-module.d.ts +10 -4
- package/dist/intelligent-assistant-translations-module.esm.js +1 -1
- package/dist/lazy/LazyLightspeedChatDrawerContent.esm.js +13 -0
- package/dist/lazy/LazyLightspeedChatDrawerContent.esm.js.map +1 -0
- package/dist/lazy/LazyLightspeedFabRootWrapper.esm.js +17 -0
- package/dist/lazy/LazyLightspeedFabRootWrapper.esm.js.map +1 -0
- package/dist/legacy.d.ts +14 -16
- package/dist/legacy.esm.js +2 -9
- package/dist/legacy.esm.js.map +1 -1
- package/dist/loadChatPatternflyStyles.esm.js +14 -0
- package/dist/loadChatPatternflyStyles.esm.js.map +1 -0
- package/dist/muiClassNameConfig.esm.js +6 -0
- package/dist/muiClassNameConfig.esm.js.map +1 -0
- package/dist/plugin.esm.js +4 -4
- package/dist/plugin.esm.js.map +1 -1
- package/dist/translations/de.esm.js +24 -0
- package/dist/translations/de.esm.js.map +1 -1
- package/dist/translations/es.esm.js +24 -0
- package/dist/translations/es.esm.js.map +1 -1
- package/dist/translations/fr.esm.js +24 -0
- package/dist/translations/fr.esm.js.map +1 -1
- package/dist/translations/it.esm.js +24 -0
- package/dist/translations/it.esm.js.map +1 -1
- package/dist/translations/ja.esm.js +24 -0
- package/dist/translations/ja.esm.js.map +1 -1
- package/dist/translations/ref.esm.js +24 -0
- package/dist/translations/ref.esm.js.map +1 -1
- package/dist/translationsModule.esm.js +18 -0
- package/dist/translationsModule.esm.js.map +1 -0
- package/dist/types.esm.js.map +1 -1
- package/dist/utils/dom-selectors.esm.js +22 -2
- package/dist/utils/dom-selectors.esm.js.map +1 -1
- package/dist/utils/lightspeed-chatbox-message-utils.esm.js +145 -0
- package/dist/utils/lightspeed-chatbox-message-utils.esm.js.map +1 -0
- package/dist/utils/lightspeed-chatbox-utils.esm.js +20 -144
- package/dist/utils/lightspeed-chatbox-utils.esm.js.map +1 -1
- package/dist/utils/screen-capture.esm.js +116 -0
- package/dist/utils/screen-capture.esm.js.map +1 -0
- package/dist/utils/screen-context-utils.esm.js +343 -0
- package/dist/utils/screen-context-utils.esm.js.map +1 -0
- package/dist/utils/sensitive-data-redactor.esm.js +39 -1
- package/dist/utils/sensitive-data-redactor.esm.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useState, useCallback, useRef, useEffect, useMemo } from 'react';
|
|
2
2
|
import { useNavigate, useLocation, useMatch } from 'react-router-dom';
|
|
3
|
-
import { ChatbotDisplayMode } from '@patternfly/chatbot';
|
|
4
3
|
import { useAppDrawer } from '@red-hat-developer-hub/backstage-plugin-app-react';
|
|
5
|
-
import { LIGHTSPEED_PATH, LIGHTSPEED_APP_DRAWER_ID } from '../const.esm.js';
|
|
4
|
+
import { ChatbotDisplayMode, LIGHTSPEED_PATH, LIGHTSPEED_APP_DRAWER_ID } from '../const.esm.js';
|
|
6
5
|
import { useBackstageUserIdentity } from './useBackstageUserIdentity.esm.js';
|
|
7
6
|
import { useDisplayModeSettings } from './useDisplayModeSettings.esm.js';
|
|
8
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLightspeedProviderState.esm.js","sources":["../../src/hooks/useLightspeedProviderState.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useLocation, useMatch, useNavigate } from 'react-router-dom';\n\nimport { ChatbotDisplayMode } from '@patternfly/chatbot';\n\nimport { useAppDrawer } from '@red-hat-developer-hub/backstage-plugin-app-react';\n\nimport type {\n LightspeedDrawerContextType,\n LightspeedEmbeddedNotebooksTarget,\n} from '../components/LightspeedDrawerContext';\nimport { LIGHTSPEED_APP_DRAWER_ID, LIGHTSPEED_PATH } from '../const';\nimport type { FileContent } from '../types';\nimport { useBackstageUserIdentity } from './useBackstageUserIdentity';\nimport { useDisplayModeSettings } from './useDisplayModeSettings';\nimport type { SettingsTab } from './useSettingsPanelUrlState';\n\nfunction lightspeedRoutePath(conversationId?: string): string {\n return conversationId\n ? `${LIGHTSPEED_PATH}/conversation/${conversationId}`\n : LIGHTSPEED_PATH;\n}\n\n/**\n * Encapsulates LightspeedDrawerProvider state, routing, and ApplicationDrawer sync.\n *\n * @internal\n */\nexport function useLightspeedProviderState(): {\n contextValue: LightspeedDrawerContextType;\n shouldRenderOverlayModal: boolean;\n closeChatbot: () => void;\n} {\n const navigate = useNavigate();\n const location = useLocation();\n const { openDrawer, closeDrawer } = useAppDrawer();\n const user = useBackstageUserIdentity();\n const {\n displayMode: persistedDisplayMode,\n setDisplayMode: setPersistedDisplayMode,\n } = useDisplayModeSettings(user, ChatbotDisplayMode.default);\n\n const [displayModeState, setDisplayModeState] =\n useState<ChatbotDisplayMode>(persistedDisplayMode);\n const [isOpen, setIsOpen] = useState(false);\n const [drawerWidth, setDrawerWidth] = useState(400);\n const [currentConversationIdState, setCurrentConversationIdState] = useState<\n string | undefined\n >(undefined);\n const [draftMessage, setDraftMessageState] = useState('');\n const [draftFileContents, setDraftFileContentsState] = useState<\n FileContent[]\n >([]);\n const [shellViewTab, setShellViewTabState] = useState(0);\n const [activeNotebookId, setActiveNotebookId] = useState<string | undefined>(\n undefined,\n );\n const [settingsTab, setSettingsTabState] = useState<SettingsTab | null>(null);\n const setSettingsTab = useCallback((tab: SettingsTab | null) => {\n setSettingsTabState(tab);\n }, []);\n const shellViewTabRef = useRef(shellViewTab);\n shellViewTabRef.current = shellViewTab;\n const setShellViewTab = useCallback((tab: number) => {\n const next = tab === 1 ? 1 : 0;\n shellViewTabRef.current = next;\n setShellViewTabState(next);\n }, []);\n const openedViaFABRef = useRef(false);\n const dockedAfterLeavingFullscreenRef = useRef(false);\n /** True while navigating off /lightspeed after user chose overlay/docked (URL can lag persisted mode). */\n const leavingLightspeedForNonEmbeddedShellRef = useRef(false);\n /** True until overlay/docked LightspeedChat consumes it (new mount after leaving fullscreen route). */\n const pendingOverlayThreadHandoffRef = useRef(false);\n /** Used to detect in-app moves (e.g. Chat ↔ Notebooks) so display mode is not reset to embedded. */\n const lightspeedPathnamePrevRef = useRef<string | null>(null);\n\n const isLightspeedRouteRef = useRef(false);\n const isOnNotebooksPathRef = useRef(false);\n const persistedDisplayModeRef = useRef(persistedDisplayMode);\n\n const isLightspeedRoute = location.pathname.startsWith(LIGHTSPEED_PATH);\n isLightspeedRouteRef.current = isLightspeedRoute;\n isOnNotebooksPathRef.current = location.pathname.startsWith(\n `${LIGHTSPEED_PATH}/notebooks`,\n );\n persistedDisplayModeRef.current = persistedDisplayMode;\n const conversationMatch = useMatch(\n `${LIGHTSPEED_PATH}/conversation/:conversationId`,\n );\n const conversationId = conversationMatch?.params?.conversationId;\n\n const syncShellDrawerForMode = useCallback(\n (mode: ChatbotDisplayMode) => {\n if (mode === ChatbotDisplayMode.docked) {\n if (isLightspeedRoute) {\n dockedAfterLeavingFullscreenRef.current = true;\n } else {\n openDrawer(LIGHTSPEED_APP_DRAWER_ID);\n }\n } else {\n dockedAfterLeavingFullscreenRef.current = false;\n closeDrawer(LIGHTSPEED_APP_DRAWER_ID);\n }\n },\n [closeDrawer, isLightspeedRoute, openDrawer],\n );\n\n const navigateBackOrGoToCatalog = useCallback(() => {\n if (!openedViaFABRef.current) {\n navigate('/catalog');\n openedViaFABRef.current = true;\n return;\n }\n navigate(-1);\n }, [navigate]);\n\n /**\n * Leaving /lightspeed for overlay/docked must not use navigate(-1): after the first FAB\n * open, navigateBackOrGoToCatalog uses -1 and can land back on /lightspeed (fullscreen).\n */\n const leaveLightspeedRouteForShellDisplayMode = useCallback(() => {\n navigate('/catalog', { replace: true });\n }, [navigate]);\n\n useEffect(() => {\n const pathname = location.pathname;\n const prevPathname = lightspeedPathnamePrevRef.current;\n const isUnderLightspeedPath = (p: string | null) =>\n Boolean(p && p.startsWith(LIGHTSPEED_PATH));\n const isInternalLightspeedRouteChange =\n isUnderLightspeedPath(prevPathname) &&\n isUnderLightspeedPath(pathname) &&\n prevPathname !== pathname;\n\n if (!isLightspeedRoute) {\n leavingLightspeedForNonEmbeddedShellRef.current = false;\n }\n\n if (conversationId) {\n setCurrentConversationIdState(conversationId);\n } else if (isLightspeedRoute) {\n // On `/lightspeed` without a `:conversationId` segment, URL implies a fresh thread.\n // When navigating to another app route (overlay/docked), keep the last id so display\n // mode switches and re-entry to fullscreen stay on the active conversation.\n setCurrentConversationIdState(undefined);\n }\n\n if (isLightspeedRoute) {\n if (!isInternalLightspeedRouteChange) {\n if (\n leavingLightspeedForNonEmbeddedShellRef.current &&\n persistedDisplayMode !== ChatbotDisplayMode.embedded\n ) {\n setDisplayModeState(persistedDisplayMode);\n } else {\n setDisplayModeState(ChatbotDisplayMode.embedded);\n }\n }\n setIsOpen(true);\n if (!dockedAfterLeavingFullscreenRef.current) {\n closeDrawer(LIGHTSPEED_APP_DRAWER_ID);\n }\n } else if (persistedDisplayMode === ChatbotDisplayMode.embedded) {\n // Off /lightspeed there is no fullscreen surface; use overlay so FAB stays available.\n // (Persisted preference remains \"fullscreen\" for the next open.)\n setDisplayModeState(ChatbotDisplayMode.default);\n } else {\n setDisplayModeState(persistedDisplayMode);\n }\n\n lightspeedPathnamePrevRef.current = pathname;\n }, [\n closeDrawer,\n conversationId,\n isLightspeedRoute,\n location.pathname,\n persistedDisplayMode,\n ]);\n\n useEffect(() => {\n if (\n !isLightspeedRoute &&\n isOpen &&\n displayModeState === ChatbotDisplayMode.docked\n ) {\n openDrawer(LIGHTSPEED_APP_DRAWER_ID);\n dockedAfterLeavingFullscreenRef.current = false;\n }\n }, [displayModeState, isLightspeedRoute, isOpen, openDrawer]);\n\n const openChatbot = useCallback(() => {\n openedViaFABRef.current = true;\n const rawMode = persistedDisplayMode || ChatbotDisplayMode.default;\n\n if (rawMode === ChatbotDisplayMode.embedded) {\n if (!isLightspeedRoute) {\n if (shellViewTabRef.current === 1) {\n navigate(`${LIGHTSPEED_PATH}/notebooks`);\n } else {\n navigate(lightspeedRoutePath(currentConversationIdState));\n }\n }\n setDisplayModeState(ChatbotDisplayMode.embedded);\n closeDrawer(LIGHTSPEED_APP_DRAWER_ID);\n setIsOpen(true);\n return;\n }\n\n setDisplayModeState(rawMode);\n\n if (rawMode === ChatbotDisplayMode.docked) {\n openDrawer(LIGHTSPEED_APP_DRAWER_ID);\n } else {\n closeDrawer(LIGHTSPEED_APP_DRAWER_ID);\n }\n\n setIsOpen(true);\n }, [\n closeDrawer,\n currentConversationIdState,\n isLightspeedRoute,\n navigate,\n openDrawer,\n persistedDisplayMode,\n ]);\n\n const closeChatbot = useCallback(() => {\n dockedAfterLeavingFullscreenRef.current = false;\n if (displayModeState === ChatbotDisplayMode.embedded && isLightspeedRoute) {\n navigateBackOrGoToCatalog();\n }\n if (displayModeState === ChatbotDisplayMode.docked) {\n closeDrawer(LIGHTSPEED_APP_DRAWER_ID);\n }\n setIsOpen(false);\n }, [\n closeDrawer,\n displayModeState,\n isLightspeedRoute,\n navigateBackOrGoToCatalog,\n ]);\n\n const toggleChatbot = useCallback(() => {\n if (isOpen) {\n closeChatbot();\n } else {\n openChatbot();\n }\n }, [isOpen, openChatbot, closeChatbot]);\n\n const setCurrentConversationId = useCallback(\n (id: string | undefined) => {\n setCurrentConversationIdState(id);\n // Refs: first-stream completion calls onStart after unmount / mode change; a stale\n // embedded + /lightspeed closure would navigate back to fullscreen without this.\n // Skip navigation when the user is on a notebooks path — conversation route updates\n // must not overwrite the notebooks URL (fixes notebook closing on mode switch).\n if (\n persistedDisplayModeRef.current === ChatbotDisplayMode.embedded &&\n isLightspeedRouteRef.current &&\n !isOnNotebooksPathRef.current\n ) {\n navigate(\n {\n pathname: lightspeedRoutePath(id),\n search: location.search,\n },\n { replace: true },\n );\n }\n },\n [navigate, location.search],\n );\n\n const setDraftMessage = useCallback((message: string) => {\n setDraftMessageState(message);\n }, []);\n\n const setDraftFileContents = useCallback((files: FileContent[]) => {\n setDraftFileContentsState(files);\n }, []);\n\n const consumePendingOverlayThreadHandoff = useCallback(() => {\n if (!pendingOverlayThreadHandoffRef.current) {\n return false;\n }\n pendingOverlayThreadHandoffRef.current = false;\n return true;\n }, []);\n\n const setDisplayMode = useCallback(\n (\n mode: ChatbotDisplayMode,\n conversationIdParam?: string,\n embeddedNotebooks?: LightspeedEmbeddedNotebooksTarget,\n ) => {\n if (mode === displayModeState) {\n return;\n }\n setPersistedDisplayMode(mode);\n syncShellDrawerForMode(mode);\n\n if (mode === ChatbotDisplayMode.embedded) {\n if (embeddedNotebooks) {\n const path =\n embeddedNotebooks === 'notebooks'\n ? `${LIGHTSPEED_PATH}/notebooks`\n : `${LIGHTSPEED_PATH}/notebooks/${embeddedNotebooks.notebookSessionId}`;\n navigate(path);\n } else if (shellViewTabRef.current === 1) {\n navigate(`${LIGHTSPEED_PATH}/notebooks`);\n } else {\n const convId = conversationIdParam ?? currentConversationIdState;\n navigate(lightspeedRoutePath(convId));\n }\n setIsOpen(true);\n } else {\n if (isLightspeedRoute) {\n leavingLightspeedForNonEmbeddedShellRef.current = true;\n pendingOverlayThreadHandoffRef.current = true;\n leaveLightspeedRouteForShellDisplayMode();\n }\n setIsOpen(true);\n }\n },\n [\n currentConversationIdState,\n displayModeState,\n isLightspeedRoute,\n leaveLightspeedRouteForShellDisplayMode,\n navigate,\n setPersistedDisplayMode,\n syncShellDrawerForMode,\n ],\n );\n\n const shouldRenderOverlayModal =\n isOpen &&\n displayModeState === ChatbotDisplayMode.default &&\n !isLightspeedRoute;\n\n const contextValue = useMemo(\n () => ({\n isChatbotActive: isOpen,\n toggleChatbot,\n displayMode: displayModeState,\n setDisplayMode,\n drawerWidth,\n setDrawerWidth,\n currentConversationId: currentConversationIdState,\n setCurrentConversationId,\n draftMessage,\n setDraftMessage,\n draftFileContents,\n setDraftFileContents,\n consumePendingOverlayThreadHandoff,\n shellViewTab,\n setShellViewTab,\n activeNotebookId,\n setActiveNotebookId,\n settingsTab,\n setSettingsTab,\n }),\n [\n isOpen,\n toggleChatbot,\n displayModeState,\n setDisplayMode,\n drawerWidth,\n currentConversationIdState,\n setCurrentConversationId,\n draftMessage,\n setDraftMessage,\n draftFileContents,\n setDraftFileContents,\n consumePendingOverlayThreadHandoff,\n shellViewTab,\n setShellViewTab,\n activeNotebookId,\n setActiveNotebookId,\n settingsTab,\n setSettingsTab,\n ],\n );\n\n return {\n contextValue,\n shouldRenderOverlayModal,\n closeChatbot,\n };\n}\n"],"names":[],"mappings":";;;;;;;;AAiCA,SAAS,oBAAoB,cAAA,EAAiC;AAC5D,EAAA,OAAO,cAAA,GACH,CAAA,EAAG,eAAe,CAAA,cAAA,EAAiB,cAAc,CAAA,CAAA,GACjD,eAAA;AACN;AAOO,SAAS,0BAAA,GAId;AACA,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,EAAE,UAAA,EAAY,WAAA,EAAY,GAAI,YAAA,EAAa;AACjD,EAAA,MAAM,OAAO,wBAAA,EAAyB;AACtC,EAAA,MAAM;AAAA,IACJ,WAAA,EAAa,oBAAA;AAAA,IACb,cAAA,EAAgB;AAAA,GAClB,GAAI,sBAAA,CAAuB,IAAA,EAAM,kBAAA,CAAmB,OAAO,CAAA;AAE3D,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAC1C,SAA6B,oBAAoB,CAAA;AACnD,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAS,KAAK,CAAA;AAC1C,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,GAAG,CAAA;AAClD,EAAA,MAAM,CAAC,0BAAA,EAA4B,6BAA6B,CAAA,GAAI,SAElE,MAAS,CAAA;AACX,EAAA,MAAM,CAAC,YAAA,EAAc,oBAAoB,CAAA,GAAI,SAAS,EAAE,CAAA;AACxD,EAAA,MAAM,CAAC,iBAAA,EAAmB,yBAAyB,CAAA,GAAI,QAAA,CAErD,EAAE,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wBAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,iBAAA;AAAA,MACA,oBAAA;AAAA,MACA,kCAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,gBAAA;AAAA,MACA,mBAAA;AAAA,MACA,WAAA;AAAA,MACA;AAAA;AACF,GACF;AAEA,EAAA,OAAO;AAAA,IACL,YAAA;AAAA,IACA,wBAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useLightspeedProviderState.esm.js","sources":["../../src/hooks/useLightspeedProviderState.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useLocation, useMatch, useNavigate } from 'react-router-dom';\n\nimport { useAppDrawer } from '@red-hat-developer-hub/backstage-plugin-app-react';\n\nimport type {\n LightspeedDrawerContextType,\n LightspeedEmbeddedNotebooksTarget,\n} from '../components/LightspeedDrawerContext';\nimport {\n ChatbotDisplayMode,\n LIGHTSPEED_APP_DRAWER_ID,\n LIGHTSPEED_PATH,\n} from '../const';\nimport type { FileContent } from '../types';\nimport { useBackstageUserIdentity } from './useBackstageUserIdentity';\nimport { useDisplayModeSettings } from './useDisplayModeSettings';\nimport type { SettingsTab } from './useSettingsPanelUrlState';\n\nfunction lightspeedRoutePath(conversationId?: string): string {\n return conversationId\n ? `${LIGHTSPEED_PATH}/conversation/${conversationId}`\n : LIGHTSPEED_PATH;\n}\n\n/**\n * Encapsulates LightspeedDrawerProvider state, routing, and ApplicationDrawer sync.\n *\n * @internal\n */\nexport function useLightspeedProviderState(): {\n contextValue: LightspeedDrawerContextType;\n shouldRenderOverlayModal: boolean;\n closeChatbot: () => void;\n} {\n const navigate = useNavigate();\n const location = useLocation();\n const { openDrawer, closeDrawer } = useAppDrawer();\n const user = useBackstageUserIdentity();\n const {\n displayMode: persistedDisplayMode,\n setDisplayMode: setPersistedDisplayMode,\n } = useDisplayModeSettings(user, ChatbotDisplayMode.default);\n\n const [displayModeState, setDisplayModeState] =\n useState<ChatbotDisplayMode>(persistedDisplayMode);\n const [isOpen, setIsOpen] = useState(false);\n const [drawerWidth, setDrawerWidth] = useState(400);\n const [currentConversationIdState, setCurrentConversationIdState] = useState<\n string | undefined\n >(undefined);\n const [draftMessage, setDraftMessageState] = useState('');\n const [draftFileContents, setDraftFileContentsState] = useState<\n FileContent[]\n >([]);\n const [shellViewTab, setShellViewTabState] = useState(0);\n const [activeNotebookId, setActiveNotebookId] = useState<string | undefined>(\n undefined,\n );\n const [settingsTab, setSettingsTabState] = useState<SettingsTab | null>(null);\n const setSettingsTab = useCallback((tab: SettingsTab | null) => {\n setSettingsTabState(tab);\n }, []);\n const shellViewTabRef = useRef(shellViewTab);\n shellViewTabRef.current = shellViewTab;\n const setShellViewTab = useCallback((tab: number) => {\n const next = tab === 1 ? 1 : 0;\n shellViewTabRef.current = next;\n setShellViewTabState(next);\n }, []);\n const openedViaFABRef = useRef(false);\n const dockedAfterLeavingFullscreenRef = useRef(false);\n /** True while navigating off /lightspeed after user chose overlay/docked (URL can lag persisted mode). */\n const leavingLightspeedForNonEmbeddedShellRef = useRef(false);\n /** True until overlay/docked LightspeedChat consumes it (new mount after leaving fullscreen route). */\n const pendingOverlayThreadHandoffRef = useRef(false);\n /** Used to detect in-app moves (e.g. Chat ↔ Notebooks) so display mode is not reset to embedded. */\n const lightspeedPathnamePrevRef = useRef<string | null>(null);\n\n const isLightspeedRouteRef = useRef(false);\n const isOnNotebooksPathRef = useRef(false);\n const persistedDisplayModeRef = useRef(persistedDisplayMode);\n\n const isLightspeedRoute = location.pathname.startsWith(LIGHTSPEED_PATH);\n isLightspeedRouteRef.current = isLightspeedRoute;\n isOnNotebooksPathRef.current = location.pathname.startsWith(\n `${LIGHTSPEED_PATH}/notebooks`,\n );\n persistedDisplayModeRef.current = persistedDisplayMode;\n const conversationMatch = useMatch(\n `${LIGHTSPEED_PATH}/conversation/:conversationId`,\n );\n const conversationId = conversationMatch?.params?.conversationId;\n\n const syncShellDrawerForMode = useCallback(\n (mode: ChatbotDisplayMode) => {\n if (mode === ChatbotDisplayMode.docked) {\n if (isLightspeedRoute) {\n dockedAfterLeavingFullscreenRef.current = true;\n } else {\n openDrawer(LIGHTSPEED_APP_DRAWER_ID);\n }\n } else {\n dockedAfterLeavingFullscreenRef.current = false;\n closeDrawer(LIGHTSPEED_APP_DRAWER_ID);\n }\n },\n [closeDrawer, isLightspeedRoute, openDrawer],\n );\n\n const navigateBackOrGoToCatalog = useCallback(() => {\n if (!openedViaFABRef.current) {\n navigate('/catalog');\n openedViaFABRef.current = true;\n return;\n }\n navigate(-1);\n }, [navigate]);\n\n /**\n * Leaving /lightspeed for overlay/docked must not use navigate(-1): after the first FAB\n * open, navigateBackOrGoToCatalog uses -1 and can land back on /lightspeed (fullscreen).\n */\n const leaveLightspeedRouteForShellDisplayMode = useCallback(() => {\n navigate('/catalog', { replace: true });\n }, [navigate]);\n\n useEffect(() => {\n const pathname = location.pathname;\n const prevPathname = lightspeedPathnamePrevRef.current;\n const isUnderLightspeedPath = (p: string | null) =>\n Boolean(p && p.startsWith(LIGHTSPEED_PATH));\n const isInternalLightspeedRouteChange =\n isUnderLightspeedPath(prevPathname) &&\n isUnderLightspeedPath(pathname) &&\n prevPathname !== pathname;\n\n if (!isLightspeedRoute) {\n leavingLightspeedForNonEmbeddedShellRef.current = false;\n }\n\n if (conversationId) {\n setCurrentConversationIdState(conversationId);\n } else if (isLightspeedRoute) {\n // On `/lightspeed` without a `:conversationId` segment, URL implies a fresh thread.\n // When navigating to another app route (overlay/docked), keep the last id so display\n // mode switches and re-entry to fullscreen stay on the active conversation.\n setCurrentConversationIdState(undefined);\n }\n\n if (isLightspeedRoute) {\n if (!isInternalLightspeedRouteChange) {\n if (\n leavingLightspeedForNonEmbeddedShellRef.current &&\n persistedDisplayMode !== ChatbotDisplayMode.embedded\n ) {\n setDisplayModeState(persistedDisplayMode);\n } else {\n setDisplayModeState(ChatbotDisplayMode.embedded);\n }\n }\n setIsOpen(true);\n if (!dockedAfterLeavingFullscreenRef.current) {\n closeDrawer(LIGHTSPEED_APP_DRAWER_ID);\n }\n } else if (persistedDisplayMode === ChatbotDisplayMode.embedded) {\n // Off /lightspeed there is no fullscreen surface; use overlay so FAB stays available.\n // (Persisted preference remains \"fullscreen\" for the next open.)\n setDisplayModeState(ChatbotDisplayMode.default);\n } else {\n setDisplayModeState(persistedDisplayMode);\n }\n\n lightspeedPathnamePrevRef.current = pathname;\n }, [\n closeDrawer,\n conversationId,\n isLightspeedRoute,\n location.pathname,\n persistedDisplayMode,\n ]);\n\n useEffect(() => {\n if (\n !isLightspeedRoute &&\n isOpen &&\n displayModeState === ChatbotDisplayMode.docked\n ) {\n openDrawer(LIGHTSPEED_APP_DRAWER_ID);\n dockedAfterLeavingFullscreenRef.current = false;\n }\n }, [displayModeState, isLightspeedRoute, isOpen, openDrawer]);\n\n const openChatbot = useCallback(() => {\n openedViaFABRef.current = true;\n const rawMode = persistedDisplayMode || ChatbotDisplayMode.default;\n\n if (rawMode === ChatbotDisplayMode.embedded) {\n if (!isLightspeedRoute) {\n if (shellViewTabRef.current === 1) {\n navigate(`${LIGHTSPEED_PATH}/notebooks`);\n } else {\n navigate(lightspeedRoutePath(currentConversationIdState));\n }\n }\n setDisplayModeState(ChatbotDisplayMode.embedded);\n closeDrawer(LIGHTSPEED_APP_DRAWER_ID);\n setIsOpen(true);\n return;\n }\n\n setDisplayModeState(rawMode);\n\n if (rawMode === ChatbotDisplayMode.docked) {\n openDrawer(LIGHTSPEED_APP_DRAWER_ID);\n } else {\n closeDrawer(LIGHTSPEED_APP_DRAWER_ID);\n }\n\n setIsOpen(true);\n }, [\n closeDrawer,\n currentConversationIdState,\n isLightspeedRoute,\n navigate,\n openDrawer,\n persistedDisplayMode,\n ]);\n\n const closeChatbot = useCallback(() => {\n dockedAfterLeavingFullscreenRef.current = false;\n if (displayModeState === ChatbotDisplayMode.embedded && isLightspeedRoute) {\n navigateBackOrGoToCatalog();\n }\n if (displayModeState === ChatbotDisplayMode.docked) {\n closeDrawer(LIGHTSPEED_APP_DRAWER_ID);\n }\n setIsOpen(false);\n }, [\n closeDrawer,\n displayModeState,\n isLightspeedRoute,\n navigateBackOrGoToCatalog,\n ]);\n\n const toggleChatbot = useCallback(() => {\n if (isOpen) {\n closeChatbot();\n } else {\n openChatbot();\n }\n }, [isOpen, openChatbot, closeChatbot]);\n\n const setCurrentConversationId = useCallback(\n (id: string | undefined) => {\n setCurrentConversationIdState(id);\n // Refs: first-stream completion calls onStart after unmount / mode change; a stale\n // embedded + /lightspeed closure would navigate back to fullscreen without this.\n // Skip navigation when the user is on a notebooks path — conversation route updates\n // must not overwrite the notebooks URL (fixes notebook closing on mode switch).\n if (\n persistedDisplayModeRef.current === ChatbotDisplayMode.embedded &&\n isLightspeedRouteRef.current &&\n !isOnNotebooksPathRef.current\n ) {\n navigate(\n {\n pathname: lightspeedRoutePath(id),\n search: location.search,\n },\n { replace: true },\n );\n }\n },\n [navigate, location.search],\n );\n\n const setDraftMessage = useCallback((message: string) => {\n setDraftMessageState(message);\n }, []);\n\n const setDraftFileContents = useCallback((files: FileContent[]) => {\n setDraftFileContentsState(files);\n }, []);\n\n const consumePendingOverlayThreadHandoff = useCallback(() => {\n if (!pendingOverlayThreadHandoffRef.current) {\n return false;\n }\n pendingOverlayThreadHandoffRef.current = false;\n return true;\n }, []);\n\n const setDisplayMode = useCallback(\n (\n mode: ChatbotDisplayMode,\n conversationIdParam?: string,\n embeddedNotebooks?: LightspeedEmbeddedNotebooksTarget,\n ) => {\n if (mode === displayModeState) {\n return;\n }\n setPersistedDisplayMode(mode);\n syncShellDrawerForMode(mode);\n\n if (mode === ChatbotDisplayMode.embedded) {\n if (embeddedNotebooks) {\n const path =\n embeddedNotebooks === 'notebooks'\n ? `${LIGHTSPEED_PATH}/notebooks`\n : `${LIGHTSPEED_PATH}/notebooks/${embeddedNotebooks.notebookSessionId}`;\n navigate(path);\n } else if (shellViewTabRef.current === 1) {\n navigate(`${LIGHTSPEED_PATH}/notebooks`);\n } else {\n const convId = conversationIdParam ?? currentConversationIdState;\n navigate(lightspeedRoutePath(convId));\n }\n setIsOpen(true);\n } else {\n if (isLightspeedRoute) {\n leavingLightspeedForNonEmbeddedShellRef.current = true;\n pendingOverlayThreadHandoffRef.current = true;\n leaveLightspeedRouteForShellDisplayMode();\n }\n setIsOpen(true);\n }\n },\n [\n currentConversationIdState,\n displayModeState,\n isLightspeedRoute,\n leaveLightspeedRouteForShellDisplayMode,\n navigate,\n setPersistedDisplayMode,\n syncShellDrawerForMode,\n ],\n );\n\n const shouldRenderOverlayModal =\n isOpen &&\n displayModeState === ChatbotDisplayMode.default &&\n !isLightspeedRoute;\n\n const contextValue = useMemo(\n () => ({\n isChatbotActive: isOpen,\n toggleChatbot,\n displayMode: displayModeState,\n setDisplayMode,\n drawerWidth,\n setDrawerWidth,\n currentConversationId: currentConversationIdState,\n setCurrentConversationId,\n draftMessage,\n setDraftMessage,\n draftFileContents,\n setDraftFileContents,\n consumePendingOverlayThreadHandoff,\n shellViewTab,\n setShellViewTab,\n activeNotebookId,\n setActiveNotebookId,\n settingsTab,\n setSettingsTab,\n }),\n [\n isOpen,\n toggleChatbot,\n displayModeState,\n setDisplayMode,\n drawerWidth,\n currentConversationIdState,\n setCurrentConversationId,\n draftMessage,\n setDraftMessage,\n draftFileContents,\n setDraftFileContents,\n consumePendingOverlayThreadHandoff,\n shellViewTab,\n setShellViewTab,\n activeNotebookId,\n setActiveNotebookId,\n settingsTab,\n setSettingsTab,\n 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AEA,EAAA,OAAO;AAAA,IACL,YAAA;AAAA,IACA,wBAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
import { subscribeToScreenContextLabel, getScreenContextLabelSnapshot } from './screenContextLabelSubscription.esm.js';
|
|
3
|
+
|
|
4
|
+
function useScreenContextLabelRevision() {
|
|
5
|
+
return useSyncExternalStore(
|
|
6
|
+
subscribeToScreenContextLabel,
|
|
7
|
+
getScreenContextLabelSnapshot,
|
|
8
|
+
getScreenContextLabelSnapshot
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { useScreenContextLabelRevision };
|
|
13
|
+
//# sourceMappingURL=useScreenContextLabelRevision.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScreenContextLabelRevision.esm.js","sources":["../../src/hooks/useScreenContextLabelRevision.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useSyncExternalStore } from 'react';\n\nimport {\n getScreenContextLabelSnapshot,\n subscribeToScreenContextLabel,\n} from './screenContextLabelSubscription';\n\n/**\n * Re-renders when the browser URL or main page chrome title changes\n * (history navigation, async header updates after route transitions).\n */\nexport function useScreenContextLabelRevision(): string {\n return useSyncExternalStore(\n subscribeToScreenContextLabel,\n getScreenContextLabelSnapshot,\n getScreenContextLabelSnapshot,\n );\n}\n"],"names":[],"mappings":";;;AA2BO,SAAS,6BAAA,GAAwC;AACtD,EAAA,OAAO,oBAAA;AAAA,IACL,6BAAA;AAAA,IACA,6BAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import { useApi, storageApiRef } from '@backstage/core-plugin-api';
|
|
3
|
+
import { isGuestUser } from '../utils/user-utils.esm.js';
|
|
4
|
+
|
|
5
|
+
const BUCKET_NAME = "lightspeed";
|
|
6
|
+
const SHARING_ENABLED_KEY = "screenContextSharingEnabled";
|
|
7
|
+
const PAUSED_KEY = "screenContextPaused";
|
|
8
|
+
const useScreenContextSettings = (user) => {
|
|
9
|
+
const storageApi = useApi(storageApiRef);
|
|
10
|
+
const bucket = storageApi.forBucket(BUCKET_NAME);
|
|
11
|
+
const [isScreenContextSharingEnabled, setIsScreenContextSharingEnabled] = useState(false);
|
|
12
|
+
const [isScreenContextPaused, setIsScreenContextPaused] = useState(false);
|
|
13
|
+
const shouldPersist = Boolean(user) && !isGuestUser(user);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!user) {
|
|
16
|
+
setIsScreenContextSharingEnabled(false);
|
|
17
|
+
setIsScreenContextPaused(false);
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
if (isGuestUser(user)) {
|
|
21
|
+
setIsScreenContextSharingEnabled(false);
|
|
22
|
+
setIsScreenContextPaused(false);
|
|
23
|
+
return void 0;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const sharingSnapshot = bucket.snapshot(SHARING_ENABLED_KEY);
|
|
27
|
+
const pausedSnapshot = bucket.snapshot(PAUSED_KEY);
|
|
28
|
+
setIsScreenContextSharingEnabled(sharingSnapshot.value ?? false);
|
|
29
|
+
setIsScreenContextPaused(pausedSnapshot.value ?? false);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error(
|
|
32
|
+
"Error reading screen context settings from storage:",
|
|
33
|
+
error
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
const sharingSubscription = bucket.observe$(SHARING_ENABLED_KEY).subscribe({
|
|
37
|
+
next: (snapshot) => {
|
|
38
|
+
setIsScreenContextSharingEnabled(snapshot.value ?? false);
|
|
39
|
+
},
|
|
40
|
+
error: (error) => {
|
|
41
|
+
console.error("Error observing screenContextSharingEnabled:", error);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const pausedSubscription = bucket.observe$(PAUSED_KEY).subscribe({
|
|
45
|
+
next: (snapshot) => {
|
|
46
|
+
setIsScreenContextPaused(snapshot.value ?? false);
|
|
47
|
+
},
|
|
48
|
+
error: (error) => {
|
|
49
|
+
console.error("Error observing screenContextPaused:", error);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return () => {
|
|
53
|
+
sharingSubscription.unsubscribe();
|
|
54
|
+
pausedSubscription.unsubscribe();
|
|
55
|
+
};
|
|
56
|
+
}, [bucket, user]);
|
|
57
|
+
const persistSharing = useCallback(
|
|
58
|
+
(enabled) => {
|
|
59
|
+
if (!shouldPersist) return;
|
|
60
|
+
try {
|
|
61
|
+
bucket.set(SHARING_ENABLED_KEY, enabled);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error("Error saving screen context sharing state:", error);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
[bucket, shouldPersist]
|
|
67
|
+
);
|
|
68
|
+
const persistPaused = useCallback(
|
|
69
|
+
(paused) => {
|
|
70
|
+
if (!shouldPersist) return;
|
|
71
|
+
try {
|
|
72
|
+
bucket.set(PAUSED_KEY, paused);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error("Error saving screen context paused state:", error);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
[bucket, shouldPersist]
|
|
78
|
+
);
|
|
79
|
+
const handleScreenContextSharingToggle = useCallback(
|
|
80
|
+
(enabled) => {
|
|
81
|
+
if (!user) return;
|
|
82
|
+
setIsScreenContextSharingEnabled(enabled);
|
|
83
|
+
setIsScreenContextPaused(false);
|
|
84
|
+
persistPaused(false);
|
|
85
|
+
persistSharing(enabled);
|
|
86
|
+
},
|
|
87
|
+
[user, persistSharing, persistPaused]
|
|
88
|
+
);
|
|
89
|
+
const setScreenContextPaused = useCallback(
|
|
90
|
+
(paused) => {
|
|
91
|
+
if (!user) return;
|
|
92
|
+
setIsScreenContextPaused(paused);
|
|
93
|
+
persistPaused(paused);
|
|
94
|
+
},
|
|
95
|
+
[user, persistPaused]
|
|
96
|
+
);
|
|
97
|
+
const toggleScreenContextPaused = useCallback(() => {
|
|
98
|
+
setScreenContextPaused(!isScreenContextPaused);
|
|
99
|
+
}, [isScreenContextPaused, setScreenContextPaused]);
|
|
100
|
+
return {
|
|
101
|
+
isScreenContextSharingEnabled,
|
|
102
|
+
isScreenContextPaused,
|
|
103
|
+
handleScreenContextSharingToggle,
|
|
104
|
+
toggleScreenContextPaused,
|
|
105
|
+
setScreenContextPaused
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export { useScreenContextSettings };
|
|
110
|
+
//# sourceMappingURL=useScreenContextSettings.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScreenContextSettings.esm.js","sources":["../../src/hooks/useScreenContextSettings.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useState } from 'react';\n\nimport { storageApiRef, useApi } from '@backstage/core-plugin-api';\n\nimport { isGuestUser } from '../utils/user-utils';\n\nconst BUCKET_NAME = 'lightspeed';\nconst SHARING_ENABLED_KEY = 'screenContextSharingEnabled';\nconst PAUSED_KEY = 'screenContextPaused';\n\ntype UseScreenContextSettingsReturn = {\n isScreenContextSharingEnabled: boolean;\n isScreenContextPaused: boolean;\n handleScreenContextSharingToggle: (enabled: boolean) => void;\n toggleScreenContextPaused: () => void;\n setScreenContextPaused: (paused: boolean) => void;\n};\n\n/**\n * Persists screen context user preference (opt-in sharing + pause state).\n */\nexport const useScreenContextSettings = (\n user: string | undefined,\n): UseScreenContextSettingsReturn => {\n const storageApi = useApi(storageApiRef);\n const bucket = storageApi.forBucket(BUCKET_NAME);\n\n const [isScreenContextSharingEnabled, setIsScreenContextSharingEnabled] =\n useState(false);\n const [isScreenContextPaused, setIsScreenContextPaused] = useState(false);\n\n const shouldPersist = Boolean(user) && !isGuestUser(user);\n\n useEffect(() => {\n if (!user) {\n setIsScreenContextSharingEnabled(false);\n setIsScreenContextPaused(false);\n return undefined;\n }\n\n if (isGuestUser(user)) {\n setIsScreenContextSharingEnabled(false);\n setIsScreenContextPaused(false);\n return undefined;\n }\n\n try {\n const sharingSnapshot = bucket.snapshot<boolean>(SHARING_ENABLED_KEY);\n const pausedSnapshot = bucket.snapshot<boolean>(PAUSED_KEY);\n setIsScreenContextSharingEnabled(sharingSnapshot.value ?? false);\n setIsScreenContextPaused(pausedSnapshot.value ?? false);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\n 'Error reading screen context settings from storage:',\n error,\n );\n }\n\n const sharingSubscription = bucket\n .observe$<boolean>(SHARING_ENABLED_KEY)\n .subscribe({\n next: snapshot => {\n setIsScreenContextSharingEnabled(snapshot.value ?? false);\n },\n error: error => {\n // eslint-disable-next-line no-console\n console.error('Error observing screenContextSharingEnabled:', error);\n },\n });\n\n const pausedSubscription = bucket.observe$<boolean>(PAUSED_KEY).subscribe({\n next: snapshot => {\n setIsScreenContextPaused(snapshot.value ?? false);\n },\n error: error => {\n // eslint-disable-next-line no-console\n console.error('Error observing screenContextPaused:', error);\n },\n });\n\n return () => {\n sharingSubscription.unsubscribe();\n pausedSubscription.unsubscribe();\n };\n }, [bucket, user]);\n\n const persistSharing = useCallback(\n (enabled: boolean) => {\n if (!shouldPersist) return;\n try {\n bucket.set(SHARING_ENABLED_KEY, enabled);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error saving screen context sharing state:', error);\n }\n },\n [bucket, shouldPersist],\n );\n\n const persistPaused = useCallback(\n (paused: boolean) => {\n if (!shouldPersist) return;\n try {\n bucket.set(PAUSED_KEY, paused);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error saving screen context paused state:', error);\n }\n },\n [bucket, shouldPersist],\n );\n\n const handleScreenContextSharingToggle = useCallback(\n (enabled: boolean) => {\n if (!user) return;\n\n setIsScreenContextSharingEnabled(enabled);\n setIsScreenContextPaused(false);\n persistPaused(false);\n persistSharing(enabled);\n },\n [user, persistSharing, persistPaused],\n );\n\n const setScreenContextPaused = useCallback(\n (paused: boolean) => {\n if (!user) return;\n setIsScreenContextPaused(paused);\n persistPaused(paused);\n },\n [user, persistPaused],\n );\n\n const toggleScreenContextPaused = useCallback(() => {\n setScreenContextPaused(!isScreenContextPaused);\n }, [isScreenContextPaused, setScreenContextPaused]);\n\n return {\n isScreenContextSharingEnabled,\n isScreenContextPaused,\n handleScreenContextSharingToggle,\n toggleScreenContextPaused,\n setScreenContextPaused,\n };\n};\n"],"names":[],"mappings":";;;;AAqBA,MAAM,WAAA,GAAc,YAAA;AACpB,MAAM,mBAAA,GAAsB,6BAAA;AAC5B,MAAM,UAAA,GAAa,qBAAA;AAaZ,MAAM,wBAAA,GAA2B,CACtC,IAAA,KACmC;AACnC,EAAA,MAAM,UAAA,GAAa,OAAO,aAAa,CAAA;AACvC,EAAA,MAAM,MAAA,GAAS,UAAA,CAAW,SAAA,CAAU,WAAW,CAAA;AAE/C,EAAA,MAAM,CAAC,6BAAA,EAA+B,gCAAgC,CAAA,GACpE,SAAS,KAAK,CAAA;AAChB,EAAA,MAAM,CAAC,qBAAA,EAAuB,wBAAwB,CAAA,GAAI,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AAA,CAAyB,KAAK,CAAA;AAC9B,MAAA,aAAA,CAAc,KAAK,CAAA;AACnB,MAAA,cAAA,CAAe,OAAO,CAAA;AAAA,IACxB,CAAA;AAAA,IACA,CAAC,IAAA,EAAM,cAAA,EAAgB,aAAa;AAAA,GACtC;AAEA,EAAA,MAAM,sBAAA,GAAyB,WAAA;AAAA,IAC7B,CAAC,MAAA,KAAoB;AACnB,MAAA,IAAI,CAAC,IAAA,EAAM;AACX,MAAA,wBAAA,CAAyB,MAAM,CAAA;AAC/B,MAAA,aAAA,CAAc,MAAM,CAAA;AAAA,IACtB,CAAA;AAAA,IACA,CAAC,MAAM,aAAa;AAAA,GACtB;AAEA,EAAA,MAAM,yBAAA,GAA4B,YAAY,MAAM;AAClD,IAAA,sBAAA,CAAuB,CAAC,qBAAqB,CAAA;AAAA,EAC/C,CAAA,EAAG,CAAC,qBAAA,EAAuB,sBAAsB,CAAC,CAAA;AAElD,EAAA,OAAO;AAAA,IACL,6BAAA;AAAA,IACA,qBAAA;AAAA,IACA,gCAAA;AAAA,IACA,yBAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
import { subscribeToScreenContextLabel } from './screenContextLabelSubscription.esm.js';
|
|
3
|
+
|
|
4
|
+
let cachedSnapshot = {
|
|
5
|
+
pathname: "",
|
|
6
|
+
search: ""
|
|
7
|
+
};
|
|
8
|
+
function getWindowLocationSnapshot() {
|
|
9
|
+
const pathname = window.location.pathname;
|
|
10
|
+
const search = window.location.search;
|
|
11
|
+
if (cachedSnapshot.pathname !== pathname || cachedSnapshot.search !== search) {
|
|
12
|
+
cachedSnapshot = { pathname, search };
|
|
13
|
+
}
|
|
14
|
+
return cachedSnapshot;
|
|
15
|
+
}
|
|
16
|
+
function subscribeToWindowLocation(onStoreChange) {
|
|
17
|
+
return subscribeToScreenContextLabel(onStoreChange);
|
|
18
|
+
}
|
|
19
|
+
function useWindowLocation() {
|
|
20
|
+
return useSyncExternalStore(
|
|
21
|
+
subscribeToWindowLocation,
|
|
22
|
+
getWindowLocationSnapshot,
|
|
23
|
+
getWindowLocationSnapshot
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { useWindowLocation };
|
|
28
|
+
//# sourceMappingURL=useWindowLocation.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindowLocation.esm.js","sources":["../../src/hooks/useWindowLocation.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useSyncExternalStore } from 'react';\n\nimport { subscribeToScreenContextLabel } from './screenContextLabelSubscription';\n\nexport type WindowLocationSnapshot = {\n pathname: string;\n search: string;\n};\n\nlet cachedSnapshot: WindowLocationSnapshot = {\n pathname: '',\n search: '',\n};\n\nfunction getWindowLocationSnapshot(): WindowLocationSnapshot {\n const pathname = window.location.pathname;\n const search = window.location.search;\n if (\n cachedSnapshot.pathname !== pathname ||\n cachedSnapshot.search !== search\n ) {\n cachedSnapshot = { pathname, search };\n }\n return cachedSnapshot;\n}\n\nfunction subscribeToWindowLocation(onStoreChange: () => void): () => void {\n return subscribeToScreenContextLabel(onStoreChange);\n}\n\n/**\n * Subscribes to browser URL changes (including history.pushState/replaceState).\n * Use when the host app navigates outside the same React Router tree as Lightspeed.\n * History patching is installed on first subscribe via subscribeToScreenContextLabel.\n */\nexport function useWindowLocation(): WindowLocationSnapshot {\n return useSyncExternalStore(\n subscribeToWindowLocation,\n getWindowLocationSnapshot,\n getWindowLocationSnapshot,\n );\n}\n"],"names":[],"mappings":";;;AAyBA,IAAI,cAAA,GAAyC;AAAA,EAC3C,QAAA,EAAU,EAAA;AAAA,EACV,MAAA,EAAQ;AACV,CAAA;AAEA,SAAS,yBAAA,GAAoD;AAC3D,EAAA,MAAM,QAAA,GAAW,OAAO,QAAA,CAAS,QAAA;AACjC,EAAA,MAAM,MAAA,GAAS,OAAO,QAAA,CAAS,MAAA;AAC/B,EAAA,IACE,cAAA,CAAe,QAAA,KAAa,QAAA,IAC5B,cAAA,CAAe,WAAW,MAAA,EAC1B;AACA,IAAA,cAAA,GAAiB,EAAE,UAAU,MAAA,EAAO;AAAA,EACtC;AACA,EAAA,OAAO,cAAA;AACT;AAEA,SAAS,0BAA0B,aAAA,EAAuC;AACxE,EAAA,OAAO,8BAA8B,aAAa,CAAA;AACpD;AAOO,SAAS,iBAAA,GAA4C;AAC1D,EAAA,OAAO,oBAAA;AAAA,IACL,yBAAA;AAAA,IACA,yBAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,20 +2,6 @@ import * as react from 'react';
|
|
|
2
2
|
import * as _red_hat_developer_hub_backstage_plugin_app_react from '@red-hat-developer-hub/backstage-plugin-app-react';
|
|
3
3
|
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
declare const intelligentAssistantRedirectModule: _backstage_frontend_plugin_api.FrontendModule;
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
declare const intelligentAssistantFABModule: _backstage_frontend_plugin_api.FrontendModule;
|
|
13
|
-
/**
|
|
14
|
-
* Translation wiring for the language selector (app-config `app.extensions`).
|
|
15
|
-
*
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
declare const intelligentAssistantTranslationsModule: _backstage_frontend_plugin_api.FrontendModule;
|
|
19
5
|
/**
|
|
20
6
|
* Lightspeed plugin for the Backstage new frontend system.
|
|
21
7
|
*
|
|
@@ -110,4 +96,4 @@ declare const _default: _backstage_frontend_plugin_api.OverridableFrontendPlugin
|
|
|
110
96
|
}>;
|
|
111
97
|
}>;
|
|
112
98
|
|
|
113
|
-
export { _default as default
|
|
99
|
+
export { _default as default };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import {
|
|
3
|
-
import { useLocation, useNavigate } from 'react-router-dom';
|
|
4
|
-
import { createRouteRef, createSubRouteRef, ApiBlueprint, createApiFactory, fetchApiRef, configApiRef, PageBlueprint, createFrontendModule, createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
5
|
-
import { AppRootWrapperBlueprint, TranslationBlueprint } from '@backstage/plugin-app-react';
|
|
6
|
-
import { unstable_ClassNameGenerator } from '@mui/material/className';
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createRouteRef, createSubRouteRef, ApiBlueprint, createApiFactory, fetchApiRef, configApiRef, PageBlueprint, createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
7
3
|
import { AppDrawerContentBlueprint } from '@red-hat-developer-hub/backstage-plugin-app-react';
|
|
8
4
|
import { lightspeedApiRef } from './api/api.esm.js';
|
|
9
5
|
import { LightspeedApiClient } from './api/LightspeedApiClient.esm.js';
|
|
10
6
|
import { notebooksApiRef } from './api/notebooksApi.esm.js';
|
|
11
7
|
import { NotebooksApiClient } from './api/NotebooksApiClient.esm.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import { LIGHTSPEED_PATH, LIGHTSPEED_APP_DRAWER_ID, LIGHTSPEED_LEGACY_PATH } from './const.esm.js';
|
|
16
|
-
import { lightspeedTranslations } from './translations/index.esm.js';
|
|
8
|
+
import { LIGHTSPEED_PATH, LIGHTSPEED_APP_DRAWER_ID } from './const.esm.js';
|
|
9
|
+
import { LazyLightspeedChatDrawerContent } from './lazy/LazyLightspeedChatDrawerContent.esm.js';
|
|
10
|
+
import './muiClassNameConfig.esm.js';
|
|
17
11
|
|
|
18
|
-
unstable_ClassNameGenerator.configure(
|
|
19
|
-
(componentName) => componentName.startsWith("v5-") ? componentName : `v5-${componentName}`
|
|
20
|
-
);
|
|
21
12
|
const nfsRootRouteRef = createRouteRef();
|
|
22
13
|
const nfsConversationRouteRef = createSubRouteRef({
|
|
23
14
|
parent: nfsRootRouteRef,
|
|
@@ -61,65 +52,12 @@ const intelligentAssistantDrawer = AppDrawerContentBlueprint.make({
|
|
|
61
52
|
name: "intelligent-assistant",
|
|
62
53
|
params: {
|
|
63
54
|
id: LIGHTSPEED_APP_DRAWER_ID,
|
|
64
|
-
element: /* @__PURE__ */ jsx(
|
|
55
|
+
element: /* @__PURE__ */ jsx(LazyLightspeedChatDrawerContent, {}),
|
|
65
56
|
resizable: true,
|
|
66
57
|
defaultWidth: 400,
|
|
67
58
|
priority: 100
|
|
68
59
|
}
|
|
69
60
|
});
|
|
70
|
-
const LightspeedLegacyRedirect = ({ children }) => {
|
|
71
|
-
const location = useLocation();
|
|
72
|
-
const navigate = useNavigate();
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (location.pathname.startsWith(LIGHTSPEED_LEGACY_PATH)) {
|
|
75
|
-
const newPath = location.pathname.replace(
|
|
76
|
-
LIGHTSPEED_LEGACY_PATH,
|
|
77
|
-
LIGHTSPEED_PATH
|
|
78
|
-
);
|
|
79
|
-
navigate(newPath + location.search + location.hash, {
|
|
80
|
-
replace: true
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}, [location, navigate]);
|
|
84
|
-
useLayoutEffect(() => {
|
|
85
|
-
document.documentElement.style.containerType = "normal";
|
|
86
|
-
}, []);
|
|
87
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
88
|
-
};
|
|
89
|
-
const intelligentAssistantRedirect = AppRootWrapperBlueprint.make({
|
|
90
|
-
name: "intelligent-assistant-redirect",
|
|
91
|
-
params: {
|
|
92
|
-
component: LightspeedLegacyRedirect
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
const intelligentAssistantRedirectModule = createFrontendModule({
|
|
96
|
-
pluginId: "app",
|
|
97
|
-
extensions: [intelligentAssistantRedirect]
|
|
98
|
-
});
|
|
99
|
-
const intelligentAssistantFABExtension = AppRootWrapperBlueprint.make({
|
|
100
|
-
name: "intelligent-assistant-fab",
|
|
101
|
-
params: {
|
|
102
|
-
component: ({ children }) => /* @__PURE__ */ jsxs(LightspeedDrawerProvider, { children: [
|
|
103
|
-
/* @__PURE__ */ jsx(LightspeedFABContent, {}),
|
|
104
|
-
children
|
|
105
|
-
] })
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
const intelligentAssistantFABModule = createFrontendModule({
|
|
109
|
-
pluginId: "app",
|
|
110
|
-
extensions: [intelligentAssistantFABExtension, intelligentAssistantRedirect]
|
|
111
|
-
});
|
|
112
|
-
const intelligentAssistantTranslationsModule = createFrontendModule({
|
|
113
|
-
pluginId: "app",
|
|
114
|
-
extensions: [
|
|
115
|
-
TranslationBlueprint.make({
|
|
116
|
-
name: "intelligent-assistant-translations",
|
|
117
|
-
params: {
|
|
118
|
-
resource: lightspeedTranslations
|
|
119
|
-
}
|
|
120
|
-
})
|
|
121
|
-
]
|
|
122
|
-
});
|
|
123
61
|
var index = createFrontendPlugin({
|
|
124
62
|
pluginId: "intelligent-assistant",
|
|
125
63
|
extensions: [
|
|
@@ -134,5 +72,5 @@ var index = createFrontendPlugin({
|
|
|
134
72
|
}
|
|
135
73
|
});
|
|
136
74
|
|
|
137
|
-
export { index as default
|
|
75
|
+
export { index as default };
|
|
138
76
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/index.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/index.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiBlueprint,\n configApiRef,\n createApiFactory,\n createFrontendPlugin,\n createRouteRef,\n createSubRouteRef,\n fetchApiRef,\n PageBlueprint,\n} from '@backstage/frontend-plugin-api';\n\nimport { AppDrawerContentBlueprint } from '@red-hat-developer-hub/backstage-plugin-app-react';\n\nimport { lightspeedApiRef } from './api/api';\nimport { LightspeedApiClient } from './api/LightspeedApiClient';\nimport { notebooksApiRef } from './api/notebooksApi';\nimport { NotebooksApiClient } from './api/NotebooksApiClient';\nimport { LIGHTSPEED_APP_DRAWER_ID, LIGHTSPEED_PATH } from './const';\nimport { LazyLightspeedChatDrawerContent } from './lazy/LazyLightspeedChatDrawerContent';\n\nimport './muiClassNameConfig';\n\nconst nfsRootRouteRef = createRouteRef();\nconst nfsConversationRouteRef = createSubRouteRef({\n parent: nfsRootRouteRef,\n path: '/conversation/:conversationId',\n});\n\nconst intelligentAssistantApi = ApiBlueprint.make({\n name: 'intelligent-assistant',\n params: defineParams =>\n defineParams(\n createApiFactory({\n api: lightspeedApiRef,\n deps: {\n configApi: configApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ configApi, fetchApi }) =>\n new LightspeedApiClient({ configApi, fetchApi }),\n }),\n ),\n});\n\nconst notebooksApi = ApiBlueprint.make({\n name: 'notebooks',\n params: defineParams =>\n defineParams(\n createApiFactory({\n api: notebooksApiRef,\n deps: {\n configApi: configApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ configApi, fetchApi }) =>\n new NotebooksApiClient({ configApi, fetchApi }),\n }),\n ),\n});\n\nconst intelligentAssistantPage = PageBlueprint.make({\n params: {\n path: LIGHTSPEED_PATH,\n routeRef: nfsRootRouteRef,\n noHeader: true,\n loader: () => import('./components/Router').then(m => <m.Router />),\n },\n});\n\nconst intelligentAssistantDrawer = AppDrawerContentBlueprint.make({\n name: 'intelligent-assistant',\n params: {\n id: LIGHTSPEED_APP_DRAWER_ID,\n element: <LazyLightspeedChatDrawerContent />,\n resizable: true,\n defaultWidth: 400,\n priority: 100,\n },\n});\n\n/**\n * Lightspeed plugin for the Backstage new frontend system.\n *\n * @public\n */\nexport default createFrontendPlugin({\n pluginId: 'intelligent-assistant',\n extensions: [\n intelligentAssistantApi,\n notebooksApi,\n intelligentAssistantPage,\n intelligentAssistantDrawer,\n ],\n routes: {\n root: nfsRootRouteRef,\n lightspeedConversation: nfsConversationRouteRef,\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;AAsCA,MAAM,kBAAkB,cAAA,EAAe;AACvC,MAAM,0BAA0B,iBAAA,CAAkB;AAAA,EAChD,MAAA,EAAQ,eAAA;AAAA,EACR,IAAA,EAAM;AACR,CAAC,CAAA;AAED,MAAM,uBAAA,GAA0B,aAAa,IAAA,CAAK;AAAA,EAChD,IAAA,EAAM,uBAAA;AAAA,EACN,QAAQ,CAAA,YAAA,KACN,YAAA;AAAA,IACE,gBAAA,CAAiB;AAAA,MACf,GAAA,EAAK,gBAAA;AAAA,MACL,IAAA,EAAM;AAAA,QACJ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oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,uBAAA;AAAA,EACV,UAAA,EAAY;AAAA,IACV,uBAAA;AAAA,IACA,YAAA;AAAA,IACA,wBAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,eAAA;AAAA,IACN,sBAAA,EAAwB;AAAA;AAE5B,CAAC,CAAA;;;;"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
declare const intelligentAssistantRedirectModule: _backstage_frontend_plugin_api.FrontendModule;
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
declare const intelligentAssistantFABModule: _backstage_frontend_plugin_api.FrontendModule;
|
|
11
|
+
|
|
12
|
+
export { intelligentAssistantFABModule as default, intelligentAssistantRedirectModule };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { intelligentAssistantFABModule as default } from './
|
|
1
|
+
export { intelligentAssistantFABModule as default, intelligentAssistantRedirectModule } from './fabModule.esm.js';
|
|
2
2
|
//# sourceMappingURL=intelligent-assistant-fab-module.esm.js.map
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Translation wiring for the language selector (app-config `app.extensions`).
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
declare const intelligentAssistantTranslationsModule: _backstage_frontend_plugin_api.FrontendModule;
|
|
9
|
+
|
|
10
|
+
export { intelligentAssistantTranslationsModule as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { intelligentAssistantTranslationsModule as default } from './
|
|
1
|
+
export { intelligentAssistantTranslationsModule as default } from './translationsModule.esm.js';
|
|
2
2
|
//# sourceMappingURL=intelligent-assistant-translations-module.esm.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { lazy, Suspense } from 'react';
|
|
3
|
+
import { ChatLoadingFallback } from '../components/ChatLoadingFallback.esm.js';
|
|
4
|
+
|
|
5
|
+
const LazyLightspeedChatContainer = lazy(
|
|
6
|
+
() => import('../components/LightspeedChatContainer.esm.js').then((m) => ({
|
|
7
|
+
default: m.LightspeedChatContainer
|
|
8
|
+
}))
|
|
9
|
+
);
|
|
10
|
+
const LazyLightspeedChatDrawerContent = () => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(ChatLoadingFallback, {}), children: /* @__PURE__ */ jsx(LazyLightspeedChatContainer, {}) });
|
|
11
|
+
|
|
12
|
+
export { LazyLightspeedChatDrawerContent };
|
|
13
|
+
//# sourceMappingURL=LazyLightspeedChatDrawerContent.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LazyLightspeedChatDrawerContent.esm.js","sources":["../../src/lazy/LazyLightspeedChatDrawerContent.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { lazy, Suspense } from 'react';\n\nimport { ChatLoadingFallback } from '../components/ChatLoadingFallback';\n\nconst LazyLightspeedChatContainer = lazy(() =>\n import('../components/LightspeedChatContainer').then(m => ({\n default: m.LightspeedChatContainer,\n })),\n);\n\n/**\n * Thin sync boundary for AppDrawerContentBlueprint — heavy chat UI loads asynchronously.\n */\nexport const LazyLightspeedChatDrawerContent = () => (\n <Suspense fallback={<ChatLoadingFallback />}>\n <LazyLightspeedChatContainer />\n </Suspense>\n);\n"],"names":[],"mappings":";;;;AAoBA,MAAM,2BAAA,GAA8B,IAAA;AAAA,EAAK,MACvC,OAAO,8CAAuC,CAAA,CAAE,KAAK,CAAA,CAAA,MAAM;AAAA,IACzD,SAAS,CAAA,CAAE;AAAA,GACb,CAAE;AACJ,CAAA;AAKO,MAAM,+BAAA,GAAkC,sBAC7C,GAAA,CAAC,QAAA,EAAA,EAAS,QAAA,sBAAW,mBAAA,EAAA,EAAoB,CAAA,EACvC,QAAA,kBAAA,GAAA,CAAC,2BAAA,EAAA,EAA4B,CAAA,EAC/B;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { lazy, Suspense } from 'react';
|
|
3
|
+
import { loadCriticalFabBundle } from '../components/loaders.esm.js';
|
|
4
|
+
|
|
5
|
+
const LazyCriticalFabRoot = lazy(async () => {
|
|
6
|
+
const { LightspeedDrawerProvider, LightspeedFABContent } = await loadCriticalFabBundle();
|
|
7
|
+
return {
|
|
8
|
+
default: ({ children }) => /* @__PURE__ */ jsxs(LightspeedDrawerProvider, { children: [
|
|
9
|
+
/* @__PURE__ */ jsx(LightspeedFABContent, {}),
|
|
10
|
+
children
|
|
11
|
+
] })
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
const LazyLightspeedFabRootWrapper = ({ children }) => /* @__PURE__ */ jsx(Suspense, { fallback: children, children: /* @__PURE__ */ jsx(LazyCriticalFabRoot, { children }) });
|
|
15
|
+
|
|
16
|
+
export { LazyLightspeedFabRootWrapper };
|
|
17
|
+
//# sourceMappingURL=LazyLightspeedFabRootWrapper.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LazyLightspeedFabRootWrapper.esm.js","sources":["../../src/lazy/LazyLightspeedFabRootWrapper.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { lazy, Suspense, type ReactNode } from 'react';\n\nimport { loadCriticalFabBundle } from '../components/loaders';\n\nconst LazyCriticalFabRoot = lazy(async () => {\n const { LightspeedDrawerProvider, LightspeedFABContent } =\n await loadCriticalFabBundle();\n\n return {\n default: ({ children }: { children: ReactNode }) => (\n <LightspeedDrawerProvider>\n <LightspeedFABContent />\n {children}\n </LightspeedDrawerProvider>\n ),\n };\n});\n\ntype Props = {\n children: ReactNode;\n};\n\n/**\n * App root wrapper that defers FAB + drawer provider off the sync chunk.\n * DrawerProvider and FABContent share one async chunk via loadCriticalFabBundle().\n */\nexport const LazyLightspeedFabRootWrapper = ({ children }: Props) => (\n <Suspense fallback={children}>\n <LazyCriticalFabRoot>{children}</LazyCriticalFabRoot>\n </Suspense>\n);\n"],"names":[],"mappings":";;;;AAoBA,MAAM,mBAAA,GAAsB,KAAK,YAAY;AAC3C,EAAA,MAAM,EAAE,wBAAA,EAA0B,oBAAA,EAAqB,GACrD,MAAM,qBAAA,EAAsB;AAE9B,EAAA,OAAO;AAAA,IACL,SAAS,CAAC,EAAE,QAAA,EAAS,0BAClB,wBAAA,EAAA,EACC,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,oBAAA,EAAA,EAAqB,CAAA;AAAA,MACrB;AAAA,KAAA,EACH;AAAA,GAEJ;AACF,CAAC,CAAA;AAUM,MAAM,4BAAA,GAA+B,CAAC,EAAE,QAAA,EAAS,qBACtD,GAAA,CAAC,QAAA,EAAA,EAAS,QAAA,EAAU,QAAA,EAClB,QAAA,kBAAA,GAAA,CAAC,mBAAA,EAAA,EAAqB,QAAA,EAAS,CAAA,EACjC;;;;"}
|
package/dist/legacy.d.ts
CHANGED
|
@@ -23,24 +23,31 @@ declare const LightspeedPage: () => react_jsx_runtime.JSX.Element;
|
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
declare const LightspeedDrawerProvider: React.ComponentType<PropsWithChildren>;
|
|
26
|
-
|
|
27
26
|
/**
|
|
27
|
+
* Lightspeed FAB for global floating action button fot LightspeedAI
|
|
28
|
+
*
|
|
28
29
|
* @public
|
|
29
|
-
* Intelligent Assistant Icon
|
|
30
30
|
*/
|
|
31
|
-
declare const
|
|
32
|
-
|
|
31
|
+
declare const LightspeedFAB: React.ComponentType;
|
|
33
32
|
/**
|
|
33
|
+
* Lightspeed Drawer State Exposer exposes its drawer state
|
|
34
|
+
*
|
|
34
35
|
* @public
|
|
35
|
-
* Lightspeed Floating action button to open/close the lightspeed chatbot
|
|
36
36
|
*/
|
|
37
|
-
declare const
|
|
38
|
-
|
|
37
|
+
declare const LightspeedDrawerStateExposer: ({ onStateChange, }: DrawerStateExposerProps) => null;
|
|
39
38
|
/**
|
|
39
|
+
* Lightspeed Chat Container component extension
|
|
40
|
+
*
|
|
40
41
|
* @public
|
|
41
42
|
*/
|
|
42
43
|
declare const LightspeedChatContainer: () => react_jsx_runtime.JSX.Element;
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @public
|
|
47
|
+
* Intelligent Assistant Icon
|
|
48
|
+
*/
|
|
49
|
+
declare const LightspeedIcon: () => react_jsx_runtime.JSX.Element;
|
|
50
|
+
|
|
44
51
|
/**
|
|
45
52
|
* @public
|
|
46
53
|
* Partial Lightspeed drawer state exposed to the ApplicationDrawer
|
|
@@ -62,14 +69,5 @@ type DrawerStateExposerProps = {
|
|
|
62
69
|
*/
|
|
63
70
|
onStateChange: (state: DrawerState) => void;
|
|
64
71
|
};
|
|
65
|
-
/**
|
|
66
|
-
* @public
|
|
67
|
-
* This exposes LightspeedDrawer's partial context to the ApplicationDrawer
|
|
68
|
-
*
|
|
69
|
-
* It reads the LightspeedDrawerContext and calls the onStateChange callback with the
|
|
70
|
-
* partial state (id, isDrawerOpen, drawerWidth, setDrawerWidth).
|
|
71
|
-
|
|
72
|
-
*/
|
|
73
|
-
declare const LightspeedDrawerStateExposer: ({ onStateChange, }: DrawerStateExposerProps) => null;
|
|
74
72
|
|
|
75
73
|
export { type DrawerState, type DrawerStateExposerProps, LightspeedChatContainer, LightspeedDrawerProvider, LightspeedDrawerStateExposer, LightspeedFAB, LightspeedIcon, LightspeedPage, lightspeedPlugin };
|