@lobehub/chat 1.96.19 → 1.97.0
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/.env.example +7 -0
- package/CHANGELOG.md +50 -0
- package/apps/desktop/package.json +1 -1
- package/apps/desktop/src/main/core/Browser.ts +2 -1
- package/apps/desktop/src/main/utils/next-electron-rsc.ts +15 -8
- package/changelog/v1.json +18 -0
- package/locales/ar/discover.json +452 -12
- package/locales/ar/metadata.json +4 -0
- package/locales/ar/plugin.json +89 -2
- package/locales/ar/setting.json +1 -0
- package/locales/bg-BG/discover.json +452 -12
- package/locales/bg-BG/metadata.json +4 -0
- package/locales/bg-BG/plugin.json +89 -2
- package/locales/bg-BG/setting.json +1 -0
- package/locales/de-DE/discover.json +452 -12
- package/locales/de-DE/metadata.json +4 -0
- package/locales/de-DE/plugin.json +89 -2
- package/locales/de-DE/setting.json +1 -0
- package/locales/en-US/discover.json +452 -12
- package/locales/en-US/metadata.json +4 -0
- package/locales/en-US/plugin.json +89 -2
- package/locales/en-US/setting.json +1 -0
- package/locales/es-ES/discover.json +452 -12
- package/locales/es-ES/metadata.json +4 -0
- package/locales/es-ES/plugin.json +89 -2
- package/locales/es-ES/setting.json +1 -0
- package/locales/fa-IR/discover.json +452 -12
- package/locales/fa-IR/metadata.json +4 -0
- package/locales/fa-IR/plugin.json +89 -2
- package/locales/fa-IR/setting.json +1 -0
- package/locales/fr-FR/discover.json +452 -12
- package/locales/fr-FR/metadata.json +4 -0
- package/locales/fr-FR/plugin.json +89 -2
- package/locales/fr-FR/setting.json +1 -0
- package/locales/it-IT/discover.json +452 -12
- package/locales/it-IT/metadata.json +4 -0
- package/locales/it-IT/plugin.json +89 -2
- package/locales/it-IT/setting.json +1 -0
- package/locales/ja-JP/discover.json +452 -12
- package/locales/ja-JP/metadata.json +4 -0
- package/locales/ja-JP/plugin.json +89 -2
- package/locales/ja-JP/setting.json +1 -0
- package/locales/ko-KR/discover.json +452 -12
- package/locales/ko-KR/metadata.json +4 -0
- package/locales/ko-KR/plugin.json +89 -2
- package/locales/ko-KR/setting.json +1 -0
- package/locales/nl-NL/discover.json +452 -12
- package/locales/nl-NL/metadata.json +4 -0
- package/locales/nl-NL/plugin.json +89 -2
- package/locales/nl-NL/setting.json +1 -0
- package/locales/pl-PL/discover.json +452 -12
- package/locales/pl-PL/metadata.json +4 -0
- package/locales/pl-PL/plugin.json +89 -2
- package/locales/pl-PL/setting.json +1 -0
- package/locales/pt-BR/discover.json +452 -12
- package/locales/pt-BR/metadata.json +4 -0
- package/locales/pt-BR/plugin.json +89 -2
- package/locales/pt-BR/setting.json +1 -0
- package/locales/ru-RU/discover.json +452 -12
- package/locales/ru-RU/metadata.json +4 -0
- package/locales/ru-RU/plugin.json +89 -2
- package/locales/ru-RU/setting.json +1 -0
- package/locales/tr-TR/discover.json +452 -12
- package/locales/tr-TR/metadata.json +4 -0
- package/locales/tr-TR/plugin.json +89 -2
- package/locales/tr-TR/setting.json +1 -0
- package/locales/vi-VN/discover.json +452 -12
- package/locales/vi-VN/metadata.json +4 -0
- package/locales/vi-VN/plugin.json +89 -2
- package/locales/vi-VN/setting.json +1 -0
- package/locales/zh-CN/discover.json +452 -12
- package/locales/zh-CN/metadata.json +8 -4
- package/locales/zh-CN/plugin.json +89 -2
- package/locales/zh-CN/setting.json +1 -0
- package/locales/zh-TW/discover.json +452 -12
- package/locales/zh-TW/metadata.json +4 -0
- package/locales/zh-TW/plugin.json +89 -2
- package/locales/zh-TW/setting.json +1 -0
- package/next.config.ts +70 -19
- package/package.json +6 -2
- package/scripts/buildSitemapIndex/index.ts +9 -4
- package/src/app/(backend)/trpc/lambda/[trpc]/route.ts +5 -0
- package/src/app/[variants]/(main)/_layout/Mobile/index.tsx +5 -4
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/InboxWelcome/AgentsSuggest.tsx +31 -45
- package/src/app/[variants]/(main)/discover/(detail)/_layout/Desktop.tsx +8 -6
- package/src/app/[variants]/(main)/discover/(detail)/_layout/Mobile/Header.tsx +3 -2
- package/src/app/[variants]/(main)/discover/(detail)/_layout/Mobile/index.tsx +5 -1
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/Client.tsx +40 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/DetailProvider.tsx +19 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Capabilities/Block.tsx +27 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Capabilities/Knowledge.tsx +33 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Capabilities/KnowledgeItem.tsx +58 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Capabilities/PluginItem.tsx +68 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Capabilities/Plugins.tsx +32 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Capabilities/index.tsx +37 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Nav.tsx +121 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Overview/TagList.tsx +47 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Overview/index.tsx +96 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Related/index.tsx +31 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/SystemRole/TagList.tsx +47 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/SystemRole/index.tsx +54 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/index.tsx +49 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Header.tsx +176 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[slug]/features → [...slugs]/features/Sidebar/ActionButton}/AddAgent.tsx +22 -21
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/ActionButton/index.tsx +31 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/Related/Item.tsx +57 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/Related/index.tsx +43 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/Summary/index.tsx +38 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/TocList/index.tsx +77 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/index.tsx +46 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/loading.tsx +48 -0
- package/src/app/[variants]/(main)/discover/(detail)/{plugin/[slug] → assistant/[...slugs]}/page.tsx +39 -42
- package/src/app/[variants]/(main)/discover/(detail)/features/Breadcrumb.tsx +56 -0
- package/src/app/[variants]/(main)/discover/(detail)/features/DetailLayout.tsx +0 -1
- package/src/app/[variants]/(main)/discover/(detail)/features/MakedownRender.tsx +44 -0
- package/src/app/[variants]/(main)/discover/(detail)/features/ShareButton.tsx +4 -3
- package/src/app/[variants]/(main)/discover/(detail)/features/Toc/Heading.tsx +108 -0
- package/src/app/[variants]/(main)/discover/(detail)/features/Toc/index.tsx +92 -0
- package/src/app/[variants]/(main)/discover/(detail)/features/Toc/useToc.tsx +66 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/Client.tsx +43 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Details/Related/index.tsx +32 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Details/Versions/index.tsx +76 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Details/index.tsx +59 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Sidebar/ActionButton/index.tsx +84 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Sidebar/ConnectionTypeAlert.tsx +35 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Sidebar/Related/Item.tsx +57 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Sidebar/Related/index.tsx +44 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Sidebar/ServerConfig.tsx +36 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Sidebar/TocList/index.tsx +98 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Sidebar/index.tsx +58 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/page.tsx +103 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/Client.tsx +40 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/DetailProvider.tsx +19 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Details/Nav.tsx +90 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Details/Overview/ProviderList/index.tsx +179 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Details/Overview/index.tsx +22 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/{ParameterList → Details/Parameter}/ParameterItem.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/{ParameterList → Details/Parameter}/index.tsx +11 -11
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Details/Related/index.tsx +31 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Details/index.tsx +47 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Header.tsx +84 -59
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/ActionButton/ChatWithModel.tsx +92 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/ActionButton/index.tsx +32 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/Related/Item.tsx +60 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/Related/index.tsx +43 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/RelatedProviders/Item.tsx +60 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/RelatedProviders/index.tsx +34 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/index.tsx +44 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/page.tsx +22 -45
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/Client.tsx +40 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/DetailProvider.tsx +19 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Details/Guide/index.tsx +25 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Details/Nav.tsx +99 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Details/Overview/ModelList/index.tsx +142 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Details/Overview/index.tsx +23 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Details/Related/index.tsx +22 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Details/index.tsx +47 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Header.tsx +99 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/{[slug]/features → [...slugs]/features/Sidebar/ActionButton}/ProviderConfig.tsx +9 -14
- package/src/app/[variants]/(main)/discover/(detail)/provider/{[slug]/features/Actions.tsx → [...slugs]/features/Sidebar/ActionButton/index.tsx} +14 -18
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Sidebar/Related/Item.tsx +60 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Sidebar/Related/index.tsx +34 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Sidebar/RelatedModels/Item.tsx +60 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Sidebar/RelatedModels/index.tsx +43 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Sidebar/index.tsx +44 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/page.tsx +103 -0
- package/src/app/[variants]/(main)/discover/(list)/(home)/Client.tsx +24 -21
- package/src/app/[variants]/(main)/discover/(list)/(home)/loading.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(list)/(home)/page.tsx +13 -38
- package/src/app/[variants]/(main)/discover/(list)/_layout/Desktop/Nav.tsx +15 -8
- package/src/app/[variants]/(main)/discover/(list)/_layout/Mobile/Header.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(list)/_layout/Mobile/Nav.tsx +2 -1
- package/src/app/[variants]/(main)/discover/(list)/assistant/Client.tsx +44 -0
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/Category/index.tsx +84 -0
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/Category/useCategory.tsx +112 -0
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/List/Item.tsx +189 -0
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/List/TokenTag.tsx +70 -0
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/List/index.tsx +33 -0
- package/src/app/[variants]/(main)/discover/(list)/assistant/page.tsx +46 -0
- package/src/app/[variants]/(main)/discover/(list)/features/Pagination.tsx +67 -0
- package/src/app/[variants]/(main)/discover/(list)/features/SortButton/index.tsx +184 -0
- package/src/app/[variants]/(main)/discover/(list)/mcp/Client.tsx +44 -0
- package/src/app/[variants]/(main)/discover/(list)/mcp/features/Category/index.tsx +83 -0
- package/src/app/[variants]/(main)/discover/(list)/mcp/features/List/ConnectionTypeTag.tsx +51 -0
- package/src/app/[variants]/(main)/discover/(list)/mcp/features/List/Item.tsx +225 -0
- package/src/app/[variants]/(main)/discover/(list)/mcp/features/List/MetaInfo.tsx +33 -0
- package/src/app/[variants]/(main)/discover/(list)/mcp/features/List/index.tsx +33 -0
- package/src/app/[variants]/(main)/discover/(list)/mcp/page.tsx +46 -0
- package/src/app/[variants]/(main)/discover/(list)/model/Client.tsx +44 -0
- package/src/app/[variants]/(main)/discover/(list)/{models → model}/_layout/Desktop.tsx +1 -7
- package/src/app/[variants]/(main)/discover/(list)/model/features/Category/index.tsx +82 -0
- package/src/app/[variants]/(main)/discover/(list)/model/features/Category/useCategory.tsx +41 -0
- package/src/app/[variants]/(main)/discover/(list)/model/features/List/Item.tsx +190 -0
- package/src/app/[variants]/(main)/discover/(list)/model/features/List/ModelTypeIcon.tsx +39 -0
- package/src/app/[variants]/(main)/discover/(list)/model/features/List/index.tsx +33 -0
- package/src/app/[variants]/(main)/discover/(list)/model/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(list)/model/page.tsx +44 -0
- package/src/app/[variants]/(main)/discover/(list)/provider/Client.tsx +43 -0
- package/src/app/[variants]/(main)/discover/(list)/provider/features/List/Item.tsx +136 -0
- package/src/app/[variants]/(main)/discover/(list)/provider/features/List/index.tsx +33 -0
- package/src/app/[variants]/(main)/discover/(list)/provider/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(list)/provider/page.tsx +44 -0
- package/src/app/[variants]/(main)/discover/_layout/Desktop/Header.tsx +1 -1
- package/src/app/[variants]/(main)/discover/components/CategoryContainer.tsx +7 -5
- package/src/app/[variants]/(main)/discover/components/CategoryMenu.tsx +28 -30
- package/src/app/[variants]/(main)/discover/components/ListLoading.tsx +56 -46
- package/src/app/[variants]/(main)/discover/components/Statistic.tsx +5 -6
- package/src/app/[variants]/(main)/discover/features/Search.tsx +62 -0
- package/src/app/[variants]/(main)/discover/features/Title.tsx +83 -0
- package/src/app/[variants]/(main)/discover/features/__tests__/calculateScore.test.ts +185 -0
- package/src/app/[variants]/(main)/discover/features/useNav.tsx +32 -12
- package/src/app/robots.tsx +7 -5
- package/src/app/sitemap.tsx +81 -13
- package/src/components/CopyableLabel/index.tsx +37 -0
- package/src/components/Descriptions/index.tsx +119 -0
- package/src/components/InlineTable/index.tsx +69 -0
- package/src/{features/PluginSettings/PluginSettingRender.tsx → components/JSONSchemaConfig/ItemRender.tsx} +3 -3
- package/src/components/MCPDepsIcon/Java.tsx +23 -0
- package/src/components/MCPDepsIcon/PowerShell.tsx +23 -0
- package/src/components/MCPDepsIcon/Terminal.tsx +23 -0
- package/src/components/MCPDepsIcon/UV.tsx +23 -0
- package/src/components/MCPDepsIcon/index.tsx +72 -0
- package/src/components/MCPStdioCommandInput/index.tsx +47 -0
- package/src/components/OfficialIcon.tsx +23 -0
- package/src/components/Plugins/MCPTag.tsx +18 -0
- package/src/components/Plugins/PluginTag.tsx +50 -0
- package/src/components/PublishedTime.tsx +71 -0
- package/src/config/__tests__/app.test.ts +6 -2
- package/src/const/discover.ts +8 -34
- package/src/database/models/message.ts +1 -0
- package/src/database/models/plugin.ts +13 -3
- package/src/envs/app.ts +1 -1
- package/src/features/AgentSetting/AgentPlugin/index.tsx +2 -2
- package/src/features/ChatInput/ActionBar/Tools/ToolItem.tsx +1 -1
- package/src/features/ChatInput/ActionBar/Tools/useControls.tsx +5 -5
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/index.tsx +25 -11
- package/src/features/MCP/MCPInstallProgress/InstallError/ErrorDetails.tsx +110 -0
- package/src/features/MCP/MCPInstallProgress/InstallError/index.tsx +51 -0
- package/src/features/MCP/MCPInstallProgress/MCPConfigForm.tsx +151 -0
- package/src/features/MCP/MCPInstallProgress/MCPDependenciesGuide.tsx +217 -0
- package/src/features/MCP/MCPInstallProgress/index.tsx +118 -0
- package/src/features/MCP/Scores.tsx +268 -0
- package/src/features/MCP/calculateScore.ts +324 -0
- package/src/features/MCP/useScoreList.ts +126 -0
- package/src/features/MCP/utils.ts +225 -0
- package/src/features/MCPPluginDetail/CollapseDesc.tsx +44 -0
- package/src/features/MCPPluginDetail/CollapseLayout.tsx +34 -0
- package/src/features/MCPPluginDetail/Deployment/Platform/index.tsx +47 -0
- package/src/features/MCPPluginDetail/Deployment/index.tsx +322 -0
- package/src/features/MCPPluginDetail/DetailProvider.tsx +19 -0
- package/src/features/MCPPluginDetail/Header.tsx +218 -0
- package/src/features/MCPPluginDetail/Nav.tsx +196 -0
- package/src/features/MCPPluginDetail/Overview/TagList.tsx +47 -0
- package/src/features/MCPPluginDetail/Overview/index.tsx +57 -0
- package/src/features/MCPPluginDetail/Schema/Block.tsx +50 -0
- package/src/features/MCPPluginDetail/Schema/Prompts.tsx +125 -0
- package/src/features/MCPPluginDetail/Schema/Resources.tsx +70 -0
- package/src/features/MCPPluginDetail/Schema/Tools.tsx +146 -0
- package/src/features/MCPPluginDetail/Schema/index.tsx +63 -0
- package/src/features/MCPPluginDetail/Schema/style.ts +9 -0
- package/src/features/MCPPluginDetail/Schema/types.ts +4 -0
- package/src/features/MCPPluginDetail/Score/GithubBadge/index.tsx +82 -0
- package/src/features/MCPPluginDetail/Score/ScoreItem.tsx +34 -0
- package/src/features/MCPPluginDetail/Score/ScoreList.tsx +24 -0
- package/src/features/MCPPluginDetail/Score/TotalScore.tsx +289 -0
- package/src/features/MCPPluginDetail/Score/index.tsx +88 -0
- package/src/features/PluginAvatar/index.tsx +1 -1
- package/src/features/PluginDetailModal/Meta.tsx +3 -4
- package/src/features/PluginDevModal/MCPManifestForm/MCPTypeSelect.tsx +3 -4
- package/src/features/PluginDevModal/MCPManifestForm/index.tsx +4 -41
- package/src/features/PluginDevModal/PluginPreview/EmptyState.tsx +5 -7
- package/src/features/PluginDevModal/PluginPreview/index.tsx +6 -6
- package/src/features/PluginSettings/index.tsx +2 -2
- package/src/features/PluginStore/AddPluginButton.tsx +1 -1
- package/src/features/PluginStore/Content.tsx +59 -0
- package/src/features/PluginStore/InstalledList/Detail/CustomPluginEmptyState.tsx +81 -0
- package/src/features/PluginStore/InstalledList/Detail/index.tsx +21 -0
- package/src/features/PluginStore/InstalledList/EditCustomPlugin.tsx +52 -0
- package/src/features/PluginStore/{PluginItem → InstalledList/List/Item}/Action.tsx +33 -13
- package/src/features/PluginStore/InstalledList/List/Item/index.tsx +62 -0
- package/src/features/PluginStore/InstalledList/List/index.tsx +77 -0
- package/src/features/PluginStore/InstalledList/index.tsx +85 -0
- package/src/features/PluginStore/Loading.tsx +2 -2
- package/src/features/PluginStore/McpList/Detail/Loading.tsx +44 -0
- package/src/features/PluginStore/McpList/Detail/Settings/index.tsx +381 -0
- package/src/features/PluginStore/McpList/Detail/index.tsx +71 -0
- package/src/features/PluginStore/McpList/List/Action.tsx +94 -0
- package/src/features/PluginStore/McpList/List/Item.tsx +84 -0
- package/src/features/PluginStore/McpList/List/index.tsx +97 -0
- package/src/features/PluginStore/McpList/index.tsx +54 -0
- package/src/features/PluginStore/PluginList/Detail/DetailProvider.tsx +19 -0
- package/src/features/PluginStore/PluginList/Detail/EmptyState.tsx +58 -0
- package/src/features/PluginStore/PluginList/Detail/Header.tsx +132 -0
- package/src/features/PluginStore/PluginList/Detail/InstallDetail/Nav.tsx +75 -0
- package/src/features/PluginStore/PluginList/Detail/InstallDetail/Settings.tsx +19 -0
- package/src/features/PluginStore/PluginList/Detail/InstallDetail/Tools.tsx +109 -0
- package/src/features/PluginStore/PluginList/Detail/InstallDetail/index.tsx +24 -0
- package/src/features/PluginStore/PluginList/Detail/Loading.tsx +44 -0
- package/src/features/PluginStore/PluginList/Detail/TagList.tsx +37 -0
- package/src/features/PluginStore/PluginList/Detail/index.tsx +39 -0
- package/src/features/PluginStore/PluginList/Detail/useCategory.tsx +76 -0
- package/src/features/PluginStore/PluginList/List/Action.tsx +72 -0
- package/src/features/PluginStore/PluginList/List/Item.tsx +94 -0
- package/src/features/PluginStore/PluginList/List/index.tsx +91 -0
- package/src/features/PluginStore/PluginList/index.tsx +47 -0
- package/src/features/PluginStore/Search/index.tsx +29 -0
- package/src/features/PluginStore/VirtuosoLoading.tsx +16 -0
- package/src/features/PluginStore/index.tsx +7 -31
- package/src/features/PluginTag/index.tsx +6 -4
- package/src/hooks/useInterceptingRoutes.test.ts +6 -0
- package/src/hooks/useMCPCategory.tsx +133 -0
- package/src/hooks/useQuery.ts +8 -0
- package/src/hooks/useQueryRoute.test.ts +7 -0
- package/src/hooks/useQueryRoute.ts +5 -3
- package/src/libs/mcp/client.ts +265 -13
- package/src/libs/mcp/types.ts +99 -0
- package/src/libs/trpc/client/desktop.ts +2 -3
- package/src/libs/trpc/lambda/context.ts +36 -5
- package/src/libs/trpc/lambda/index.ts +1 -1
- package/src/libs/trpc/lambda/init.ts +8 -1
- package/src/locales/default/discover.ts +457 -12
- package/src/locales/default/metadata.ts +9 -4
- package/src/locales/default/plugin.ts +89 -1
- package/src/locales/default/setting.ts +1 -0
- package/src/locales/resources.ts +1 -1
- package/src/middleware.ts +13 -3
- package/src/server/ld.ts +4 -3
- package/src/server/modules/AssistantStore/index.test.ts +10 -8
- package/src/server/modules/AssistantStore/index.ts +37 -17
- package/src/server/modules/PluginStore/index.test.ts +1 -1
- package/src/server/modules/PluginStore/index.ts +24 -1
- package/src/server/routers/desktop/mcp.ts +36 -2
- package/src/server/routers/edge/index.ts +0 -6
- package/src/server/routers/{edge → lambda}/config/index.ts +1 -1
- package/src/server/routers/lambda/index.ts +4 -0
- package/src/server/routers/lambda/market/index.ts +621 -0
- package/src/server/routers/lambda/plugin.ts +2 -0
- package/src/server/routers/tools/mcp.ts +22 -0
- package/src/server/services/discover/index.test.ts +573 -250
- package/src/server/services/discover/index.ts +1096 -241
- package/src/server/services/mcp/deps/MCPSystemDepsCheckService.ts +238 -0
- package/src/server/services/mcp/deps/checkers/ManualInstallationChecker.ts +20 -0
- package/src/server/services/mcp/deps/checkers/NpmInstallationChecker.ts +51 -0
- package/src/server/services/mcp/deps/checkers/PythonInstallationChecker.ts +69 -0
- package/src/server/services/mcp/deps/index.ts +14 -0
- package/src/server/services/mcp/deps/types.ts +49 -0
- package/src/server/services/mcp/index.ts +251 -33
- package/src/server/sitemap.test.ts +203 -46
- package/src/server/sitemap.ts +159 -52
- package/src/services/__tests__/global.test.ts +4 -7
- package/src/services/__tests__/tool.test.ts +1 -29
- package/src/services/discover.ts +365 -0
- package/src/services/global.ts +3 -3
- package/src/services/mcp.ts +131 -10
- package/src/services/plugin/_deprecated.ts +1 -1
- package/src/services/plugin/type.ts +3 -1
- package/src/services/tool.ts +9 -6
- package/src/store/chat/slices/plugin/action.test.ts +2 -3
- package/src/store/chat/slices/plugin/action.ts +22 -4
- package/src/store/discover/index.ts +1 -0
- package/src/store/discover/slices/assistant/action.ts +73 -0
- package/src/store/discover/slices/assistant/index.ts +1 -0
- package/src/store/discover/slices/mcp/action.ts +70 -0
- package/src/store/discover/slices/mcp/index.ts +1 -0
- package/src/store/discover/slices/model/action.ts +70 -0
- package/src/store/discover/slices/model/index.ts +1 -0
- package/src/store/discover/slices/plugin/action.ts +76 -0
- package/src/store/discover/slices/plugin/index.ts +1 -0
- package/src/store/discover/slices/provider/action.ts +61 -0
- package/src/store/discover/slices/provider/index.ts +1 -0
- package/src/store/discover/store.ts +39 -0
- package/src/store/tool/initialState.ts +8 -2
- package/src/store/tool/selectors/index.ts +2 -1
- package/src/store/tool/selectors/tool.test.ts +3 -1
- package/src/store/tool/selectors/tool.ts +14 -2
- package/src/store/tool/slices/mcpStore/action.ts +496 -0
- package/src/store/tool/slices/mcpStore/initialState.ts +40 -0
- package/src/store/tool/slices/mcpStore/selectors.ts +62 -0
- package/src/store/tool/slices/{store → oldStore}/action.test.ts +24 -19
- package/src/store/tool/slices/oldStore/action.ts +269 -0
- package/src/store/tool/slices/oldStore/index.ts +3 -0
- package/src/store/tool/slices/oldStore/initialState.ts +54 -0
- package/src/store/tool/slices/{store → oldStore}/selectors.test.ts +6 -3
- package/src/store/tool/slices/{store → oldStore}/selectors.ts +18 -5
- package/src/store/tool/slices/plugin/action.test.ts +2 -1
- package/src/store/tool/slices/plugin/action.ts +22 -4
- package/src/store/tool/slices/plugin/selectors.test.ts +12 -4
- package/src/store/tool/slices/plugin/selectors.ts +20 -9
- package/src/store/tool/store.ts +5 -2
- package/src/types/discover/assistants.ts +72 -0
- package/src/types/discover/index.ts +41 -0
- package/src/types/discover/mcp.ts +59 -0
- package/src/types/discover/models.ts +51 -0
- package/src/types/discover/plugins.ts +52 -0
- package/src/types/discover/providers.ts +47 -0
- package/src/types/message/tools.ts +3 -0
- package/src/types/plugins/index.ts +53 -0
- package/src/types/plugins/mcp.ts +188 -0
- package/src/types/plugins/mcpDeps.ts +30 -0
- package/src/types/tool/index.ts +10 -0
- package/src/types/tool/plugin.ts +3 -2
- package/src/types/tool/tool.ts +4 -1
- package/src/utils/client/cookie.ts +5 -2
- package/src/utils/locale.ts +2 -17
- package/src/utils/object.ts +10 -0
- package/src/utils/server/pageProps.ts +9 -0
- package/src/utils/toolCall.ts +5 -1
- package/src/utils/toolManifest.ts +1 -2
- package/vercel.json +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[slug]/features/Actions.tsx +0 -35
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[slug]/features/ConversationExample/TopicList.tsx +0 -75
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[slug]/features/ConversationExample/index.tsx +0 -105
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[slug]/features/Header.tsx +0 -115
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[slug]/features/InfoSidebar/SuggestionItem.tsx +0 -62
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[slug]/features/InfoSidebar/ToolItem.tsx +0 -19
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[slug]/features/InfoSidebar/index.tsx +0 -60
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[slug]/features/SystemRole.tsx +0 -35
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[slug]/features/Temp.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[slug]/page.tsx +0 -124
- package/src/app/[variants]/(main)/discover/(detail)/loading.tsx +0 -38
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Actions.tsx +0 -40
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/ChatWithModel.tsx +0 -93
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/InfoSidebar/SuggestionItem.tsx +0 -74
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/InfoSidebar/index.tsx +0 -45
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/ProviderList/ProviderItem.tsx +0 -139
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/ProviderList/index.tsx +0 -45
- package/src/app/[variants]/(main)/discover/(detail)/plugin/[slug]/features/Actions.tsx +0 -35
- package/src/app/[variants]/(main)/discover/(detail)/plugin/[slug]/features/Header.tsx +0 -119
- package/src/app/[variants]/(main)/discover/(detail)/plugin/[slug]/features/InfoSidebar/SuggestionItem.tsx +0 -64
- package/src/app/[variants]/(main)/discover/(detail)/plugin/[slug]/features/InfoSidebar/index.tsx +0 -45
- package/src/app/[variants]/(main)/discover/(detail)/plugin/[slug]/features/InstallPlugin.tsx +0 -83
- package/src/app/[variants]/(main)/discover/(detail)/plugin/[slug]/features/ParameterList.tsx +0 -95
- package/src/app/[variants]/(main)/discover/(detail)/plugin/[slug]/features/Schema.tsx +0 -23
- package/src/app/[variants]/(main)/discover/(detail)/provider/[slug]/features/Header.tsx +0 -73
- package/src/app/[variants]/(main)/discover/(detail)/provider/[slug]/features/InfoSidebar/SuggestionItem.tsx +0 -77
- package/src/app/[variants]/(main)/discover/(detail)/provider/[slug]/features/InfoSidebar/index.tsx +0 -45
- package/src/app/[variants]/(main)/discover/(detail)/provider/[slug]/features/ModelList/ModelItem.tsx +0 -152
- package/src/app/[variants]/(main)/discover/(detail)/provider/[slug]/features/ModelList/index.tsx +0 -60
- package/src/app/[variants]/(main)/discover/(detail)/provider/[slug]/page.tsx +0 -126
- package/src/app/[variants]/(main)/discover/(list)/(home)/features/AssistantList.tsx +0 -33
- package/src/app/[variants]/(main)/discover/(list)/(home)/features/ModelList.tsx +0 -19
- package/src/app/[variants]/(main)/discover/(list)/(home)/features/PluginList.tsx +0 -25
- package/src/app/[variants]/(main)/discover/(list)/assistants/[slug]/page.tsx +0 -75
- package/src/app/[variants]/(main)/discover/(list)/assistants/features/Card.tsx +0 -195
- package/src/app/[variants]/(main)/discover/(list)/assistants/features/Category.tsx +0 -48
- package/src/app/[variants]/(main)/discover/(list)/assistants/features/List.tsx +0 -98
- package/src/app/[variants]/(main)/discover/(list)/assistants/features/useCategory.tsx +0 -116
- package/src/app/[variants]/(main)/discover/(list)/assistants/page.tsx +0 -64
- package/src/app/[variants]/(main)/discover/(list)/loading.tsx +0 -39
- package/src/app/[variants]/(main)/discover/(list)/models/[slug]/page.tsx +0 -78
- package/src/app/[variants]/(main)/discover/(list)/models/features/Card.tsx +0 -118
- package/src/app/[variants]/(main)/discover/(list)/models/features/Category.tsx +0 -67
- package/src/app/[variants]/(main)/discover/(list)/models/features/List.tsx +0 -71
- package/src/app/[variants]/(main)/discover/(list)/models/loading.tsx +0 -1
- package/src/app/[variants]/(main)/discover/(list)/models/page.tsx +0 -73
- package/src/app/[variants]/(main)/discover/(list)/plugins/[slug]/page.tsx +0 -75
- package/src/app/[variants]/(main)/discover/(list)/plugins/features/Card.tsx +0 -161
- package/src/app/[variants]/(main)/discover/(list)/plugins/features/Category.tsx +0 -45
- package/src/app/[variants]/(main)/discover/(list)/plugins/features/List.tsx +0 -97
- package/src/app/[variants]/(main)/discover/(list)/plugins/features/useCategory.tsx +0 -80
- package/src/app/[variants]/(main)/discover/(list)/plugins/page.tsx +0 -64
- package/src/app/[variants]/(main)/discover/(list)/providers/features/Card.tsx +0 -119
- package/src/app/[variants]/(main)/discover/(list)/providers/features/List.tsx +0 -67
- package/src/app/[variants]/(main)/discover/(list)/providers/loading.tsx +0 -1
- package/src/app/[variants]/(main)/discover/(list)/providers/page.tsx +0 -64
- package/src/app/[variants]/(main)/discover/features/StoreSearchBar.tsx +0 -87
- package/src/app/[variants]/(main)/discover/loading.tsx +0 -3
- package/src/app/[variants]/(main)/discover/search/_layout/Desktop.tsx +0 -42
- package/src/app/[variants]/(main)/discover/search/_layout/Mobile/Header.tsx +0 -31
- package/src/app/[variants]/(main)/discover/search/_layout/Mobile/Nav.tsx +0 -56
- package/src/app/[variants]/(main)/discover/search/_layout/Mobile/index.tsx +0 -32
- package/src/app/[variants]/(main)/discover/search/features/AssistantsResult.tsx +0 -27
- package/src/app/[variants]/(main)/discover/search/features/Category.tsx +0 -41
- package/src/app/[variants]/(main)/discover/search/features/ModelsResult.tsx +0 -27
- package/src/app/[variants]/(main)/discover/search/features/PluginsResult.tsx +0 -27
- package/src/app/[variants]/(main)/discover/search/features/ProvidersResult.tsx +0 -26
- package/src/app/[variants]/(main)/discover/search/layout.tsx +0 -12
- package/src/app/[variants]/(main)/discover/search/loading.tsx +0 -1
- package/src/app/[variants]/(main)/discover/search/page.tsx +0 -82
- package/src/features/PluginStore/InstalledPluginList.tsx +0 -59
- package/src/features/PluginStore/OnlineList.tsx +0 -87
- package/src/features/PluginStore/PluginItem/EditCustomPlugin.tsx +0 -55
- package/src/features/PluginStore/PluginItem/PluginTag.tsx +0 -29
- package/src/features/PluginStore/PluginItem/index.tsx +0 -83
- package/src/server/routers/edge/market/index.ts +0 -108
- package/src/services/__tests__/assistant.test.ts +0 -87
- package/src/services/assistant.ts +0 -25
- package/src/store/tool/slices/store/action.ts +0 -113
- package/src/store/tool/slices/store/initialState.ts +0 -17
- package/src/types/discover.ts +0 -179
- package/src/types/requestCache.ts +0 -3
- /package/src/app/[variants]/(main)/discover/(list)/{assistants → assistant}/_layout/Desktop.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(list)/{assistants → assistant}/_layout/Mobile.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(list)/{assistants → assistant}/layout.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(list)/{assistants → assistant}/loading.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(list)/{plugins → mcp}/_layout/Desktop.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(list)/{plugins → mcp}/_layout/Mobile.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(list)/{plugins → mcp}/layout.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(list)/{plugins → mcp}/loading.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(list)/{models → model}/_layout/Mobile.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(list)/{models → model}/features/const.ts +0 -0
- /package/src/app/[variants]/(main)/discover/(list)/{models → model}/layout.tsx +0 -0
- /package/src/{features/PluginStore/PluginItem → components/Plugins}/PluginAvatar.tsx +0 -0
- /package/src/server/routers/{edge → lambda}/config/__snapshots__/index.test.ts.snap +0 -0
- /package/src/server/routers/{edge → lambda}/config/index.test.ts +0 -0
- /package/src/store/tool/slices/{store → mcpStore}/index.ts +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import { LobeChatPluginManifest
|
1
|
+
import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
|
2
2
|
import { act, renderHook } from '@testing-library/react';
|
3
3
|
import useSWR from 'swr';
|
4
4
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
@@ -6,6 +6,7 @@ import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
6
6
|
import { notification } from '@/components/AntdStaticMethods';
|
7
7
|
import { pluginService } from '@/services/plugin';
|
8
8
|
import { toolService } from '@/services/tool';
|
9
|
+
import { DiscoverPluginItem } from '@/types/discover';
|
9
10
|
|
10
11
|
import { useToolStore } from '../../store';
|
11
12
|
|
@@ -27,6 +28,7 @@ vi.mock('@/services/tool', () => ({
|
|
27
28
|
toolService: {
|
28
29
|
getToolManifest: vi.fn(),
|
29
30
|
getToolList: vi.fn(),
|
31
|
+
getOldPluginList: vi.fn(),
|
30
32
|
},
|
31
33
|
}));
|
32
34
|
|
@@ -83,13 +85,13 @@ const logError = console.error;
|
|
83
85
|
beforeEach(() => {
|
84
86
|
vi.restoreAllMocks();
|
85
87
|
useToolStore.setState({
|
86
|
-
|
88
|
+
oldPluginItems: [
|
87
89
|
{
|
88
90
|
identifier: 'plugin1',
|
89
|
-
|
91
|
+
title: 'plugin1',
|
92
|
+
avatar: '🍏',
|
90
93
|
manifest: 'https://abc.com/manifest.json',
|
91
|
-
|
92
|
-
} as LobeChatPluginMeta,
|
94
|
+
} as DiscoverPluginItem,
|
93
95
|
],
|
94
96
|
});
|
95
97
|
console.error = () => {};
|
@@ -103,7 +105,7 @@ describe('useToolStore:pluginStore', () => {
|
|
103
105
|
it('should load plugin list and update state', async () => {
|
104
106
|
// Given
|
105
107
|
const pluginListMock = [{ identifier: 'plugin1' }, { identifier: 'plugin2' }];
|
106
|
-
(toolService.
|
108
|
+
(toolService.getOldPluginList as Mock).mockResolvedValue({ items: pluginListMock });
|
107
109
|
|
108
110
|
// When
|
109
111
|
let pluginList;
|
@@ -112,15 +114,15 @@ describe('useToolStore:pluginStore', () => {
|
|
112
114
|
});
|
113
115
|
|
114
116
|
// Then
|
115
|
-
expect(toolService.
|
117
|
+
expect(toolService.getOldPluginList).toHaveBeenCalled();
|
116
118
|
expect(pluginList).toEqual(pluginListMock);
|
117
|
-
expect(useToolStore.getState().
|
119
|
+
expect(useToolStore.getState().oldPluginItems).toEqual(pluginListMock);
|
118
120
|
});
|
119
121
|
|
120
122
|
it('should handle errors when loading plugin list', async () => {
|
121
123
|
// Given
|
122
124
|
const error = new Error('Failed to load plugin list');
|
123
|
-
(toolService.
|
125
|
+
(toolService.getOldPluginList as Mock).mockRejectedValue(error);
|
124
126
|
|
125
127
|
// When
|
126
128
|
let pluginList;
|
@@ -134,11 +136,11 @@ describe('useToolStore:pluginStore', () => {
|
|
134
136
|
}
|
135
137
|
|
136
138
|
// Then
|
137
|
-
expect(toolService.
|
139
|
+
expect(toolService.getOldPluginList).toHaveBeenCalled();
|
138
140
|
expect(errorOccurred).toBe(true);
|
139
141
|
expect(pluginList).toBeUndefined();
|
140
142
|
// Ensure the state is not updated with an undefined value
|
141
|
-
expect(useToolStore.getState().
|
143
|
+
expect(useToolStore.getState().oldPluginItems).not.toBeUndefined();
|
142
144
|
});
|
143
145
|
});
|
144
146
|
|
@@ -270,11 +272,12 @@ describe('useToolStore:pluginStore', () => {
|
|
270
272
|
(toolService.getToolManifest as Mock).mockRejectedValue(error);
|
271
273
|
|
272
274
|
useToolStore.setState({
|
273
|
-
|
275
|
+
oldPluginItems: [
|
274
276
|
{
|
275
277
|
identifier: 'plugin1',
|
276
|
-
|
277
|
-
|
278
|
+
title: 'plugin1',
|
279
|
+
avatar: '🍏',
|
280
|
+
} as DiscoverPluginItem,
|
278
281
|
],
|
279
282
|
});
|
280
283
|
|
@@ -294,17 +297,19 @@ describe('useToolStore:pluginStore', () => {
|
|
294
297
|
// Given
|
295
298
|
act(() => {
|
296
299
|
useToolStore.setState({
|
297
|
-
|
300
|
+
oldPluginItems: [
|
298
301
|
{
|
299
302
|
identifier: 'plugin1',
|
300
|
-
|
303
|
+
title: 'plugin1',
|
304
|
+
avatar: '🍏',
|
301
305
|
manifest: 'https://abc.com/manifest.json',
|
302
|
-
} as
|
306
|
+
} as DiscoverPluginItem,
|
303
307
|
{
|
304
308
|
identifier: 'plugin2',
|
305
|
-
|
309
|
+
title: 'plugin2',
|
310
|
+
avatar: '🍏',
|
306
311
|
manifest: 'https://abc.com/manifest.json',
|
307
|
-
} as
|
312
|
+
} as DiscoverPluginItem,
|
308
313
|
],
|
309
314
|
});
|
310
315
|
});
|
@@ -0,0 +1,269 @@
|
|
1
|
+
import { t } from 'i18next';
|
2
|
+
import { produce } from 'immer';
|
3
|
+
import { uniqBy } from 'lodash-es';
|
4
|
+
import useSWR, { SWRResponse, mutate } from 'swr';
|
5
|
+
import { StateCreator } from 'zustand/vanilla';
|
6
|
+
|
7
|
+
import { notification } from '@/components/AntdStaticMethods';
|
8
|
+
import { pluginService } from '@/services/plugin';
|
9
|
+
import { toolService } from '@/services/tool';
|
10
|
+
import { globalHelpers } from '@/store/global/helpers';
|
11
|
+
import { pluginStoreSelectors } from '@/store/tool/selectors';
|
12
|
+
import { DiscoverPluginItem, PluginListResponse, PluginQueryParams } from '@/types/discover';
|
13
|
+
import { LobeTool } from '@/types/tool';
|
14
|
+
import { PluginInstallError } from '@/types/tool/plugin';
|
15
|
+
import { sleep } from '@/utils/sleep';
|
16
|
+
import { setNamespace } from '@/utils/storeDebug';
|
17
|
+
|
18
|
+
import { ToolStore } from '../../store';
|
19
|
+
import { PluginInstallProgress, PluginInstallStep, PluginStoreState } from './initialState';
|
20
|
+
|
21
|
+
const n = setNamespace('pluginStore');
|
22
|
+
|
23
|
+
const INSTALLED_PLUGINS = 'loadInstalledPlugins';
|
24
|
+
|
25
|
+
export interface PluginStoreAction {
|
26
|
+
installOldPlugin: (identifier: string, source?: 'plugin' | 'customPlugin') => Promise<void>;
|
27
|
+
installPlugin: (identifier: string, source?: 'plugin' | 'customPlugin') => Promise<void>;
|
28
|
+
installPlugins: (plugins: string[]) => Promise<void>;
|
29
|
+
loadMorePlugins: () => void;
|
30
|
+
loadPluginStore: () => Promise<DiscoverPluginItem[]>;
|
31
|
+
refreshPlugins: () => Promise<void>;
|
32
|
+
|
33
|
+
resetPluginList: (keywords?: string) => void;
|
34
|
+
uninstallPlugin: (identifier: string) => Promise<void>;
|
35
|
+
updateInstallLoadingState: (key: string, value: boolean | undefined) => void;
|
36
|
+
updatePluginInstallProgress: (
|
37
|
+
identifier: string,
|
38
|
+
progress: PluginInstallProgress | undefined,
|
39
|
+
) => void;
|
40
|
+
|
41
|
+
useFetchInstalledPlugins: (enabled: boolean) => SWRResponse<LobeTool[]>;
|
42
|
+
useFetchPluginList: (params: PluginQueryParams) => SWRResponse<PluginListResponse>;
|
43
|
+
useFetchPluginStore: () => SWRResponse<DiscoverPluginItem[]>;
|
44
|
+
}
|
45
|
+
|
46
|
+
export const createPluginStoreSlice: StateCreator<
|
47
|
+
ToolStore,
|
48
|
+
[['zustand/devtools', never]],
|
49
|
+
[],
|
50
|
+
PluginStoreAction
|
51
|
+
> = (set, get) => ({
|
52
|
+
installOldPlugin: async (name, type = 'plugin') => {
|
53
|
+
const plugin = pluginStoreSelectors.getPluginById(name)(get());
|
54
|
+
if (!plugin) return;
|
55
|
+
|
56
|
+
const { updateInstallLoadingState, refreshPlugins, updatePluginInstallProgress } = get();
|
57
|
+
|
58
|
+
try {
|
59
|
+
// 开始安装流程
|
60
|
+
updateInstallLoadingState(name, true);
|
61
|
+
|
62
|
+
// 步骤 1: 获取插件清单
|
63
|
+
updatePluginInstallProgress(name, {
|
64
|
+
progress: 25,
|
65
|
+
step: PluginInstallStep.FETCHING_MANIFEST,
|
66
|
+
});
|
67
|
+
|
68
|
+
const data = await toolService.getToolManifest(plugin.manifest);
|
69
|
+
|
70
|
+
// 步骤 2: 安装插件
|
71
|
+
updatePluginInstallProgress(name, {
|
72
|
+
progress: 60,
|
73
|
+
step: PluginInstallStep.INSTALLING_PLUGIN,
|
74
|
+
});
|
75
|
+
|
76
|
+
await pluginService.installPlugin({ identifier: plugin.identifier, manifest: data, type });
|
77
|
+
|
78
|
+
updatePluginInstallProgress(name, {
|
79
|
+
progress: 85,
|
80
|
+
step: PluginInstallStep.INSTALLING_PLUGIN,
|
81
|
+
});
|
82
|
+
|
83
|
+
await refreshPlugins();
|
84
|
+
|
85
|
+
// 步骤 4: 完成安装
|
86
|
+
updatePluginInstallProgress(name, {
|
87
|
+
progress: 100,
|
88
|
+
step: PluginInstallStep.COMPLETED,
|
89
|
+
});
|
90
|
+
|
91
|
+
// 短暂显示完成状态后清除进度
|
92
|
+
await sleep(1000);
|
93
|
+
|
94
|
+
updatePluginInstallProgress(name, undefined);
|
95
|
+
updateInstallLoadingState(name, undefined);
|
96
|
+
} catch (error) {
|
97
|
+
console.error(error);
|
98
|
+
|
99
|
+
const err = error as PluginInstallError;
|
100
|
+
|
101
|
+
// 设置错误状态
|
102
|
+
updatePluginInstallProgress(name, {
|
103
|
+
error: err.message,
|
104
|
+
progress: 0,
|
105
|
+
step: PluginInstallStep.ERROR,
|
106
|
+
});
|
107
|
+
|
108
|
+
updateInstallLoadingState(name, undefined);
|
109
|
+
|
110
|
+
notification.error({
|
111
|
+
description: t(`error.${err.message}`, { ns: 'plugin' }),
|
112
|
+
message: t('error.installError', { name: plugin.title, ns: 'plugin' }),
|
113
|
+
});
|
114
|
+
}
|
115
|
+
},
|
116
|
+
installPlugin: async (name, type = 'plugin') => {
|
117
|
+
const plugin = pluginStoreSelectors.getPluginById(name)(get());
|
118
|
+
if (!plugin) return;
|
119
|
+
|
120
|
+
const { updateInstallLoadingState, refreshPlugins } = get();
|
121
|
+
try {
|
122
|
+
updateInstallLoadingState(name, true);
|
123
|
+
const data = await toolService.getToolManifest(plugin.manifest);
|
124
|
+
|
125
|
+
await pluginService.installPlugin({ identifier: plugin.identifier, manifest: data, type });
|
126
|
+
await refreshPlugins();
|
127
|
+
|
128
|
+
updateInstallLoadingState(name, undefined);
|
129
|
+
} catch (error) {
|
130
|
+
console.error(error);
|
131
|
+
|
132
|
+
const err = error as PluginInstallError;
|
133
|
+
|
134
|
+
updateInstallLoadingState(name, undefined);
|
135
|
+
|
136
|
+
notification.error({
|
137
|
+
description: t(`error.${err.message}`, { ns: 'plugin' }),
|
138
|
+
message: t('error.installError', { name: plugin.title, ns: 'plugin' }),
|
139
|
+
});
|
140
|
+
}
|
141
|
+
},
|
142
|
+
installPlugins: async (plugins) => {
|
143
|
+
const { installPlugin } = get();
|
144
|
+
|
145
|
+
await Promise.all(plugins.map((identifier) => installPlugin(identifier)));
|
146
|
+
},
|
147
|
+
loadMorePlugins: () => {
|
148
|
+
const { oldPluginItems, pluginTotalCount, currentPluginPage } = get();
|
149
|
+
|
150
|
+
// 检查是否还有更多数据可以加载
|
151
|
+
if (oldPluginItems.length < (pluginTotalCount || 0)) {
|
152
|
+
set(
|
153
|
+
produce((draft: PluginStoreState) => {
|
154
|
+
draft.currentPluginPage = currentPluginPage + 1;
|
155
|
+
}),
|
156
|
+
false,
|
157
|
+
n('loadMorePlugins'),
|
158
|
+
);
|
159
|
+
}
|
160
|
+
},
|
161
|
+
loadPluginStore: async () => {
|
162
|
+
const locale = globalHelpers.getCurrentLanguage();
|
163
|
+
|
164
|
+
const data = await toolService.getOldPluginList({
|
165
|
+
locale,
|
166
|
+
page: 1,
|
167
|
+
pageSize: 50,
|
168
|
+
});
|
169
|
+
|
170
|
+
set({ oldPluginItems: data.items }, false, n('loadPluginList'));
|
171
|
+
|
172
|
+
return data.items;
|
173
|
+
},
|
174
|
+
refreshPlugins: async () => {
|
175
|
+
await mutate(INSTALLED_PLUGINS);
|
176
|
+
},
|
177
|
+
resetPluginList: (keywords) => {
|
178
|
+
set(
|
179
|
+
produce((draft: PluginStoreState) => {
|
180
|
+
draft.oldPluginItems = [];
|
181
|
+
draft.currentPluginPage = 1;
|
182
|
+
draft.pluginSearchKeywords = keywords;
|
183
|
+
}),
|
184
|
+
false,
|
185
|
+
n('resetPluginList'),
|
186
|
+
);
|
187
|
+
},
|
188
|
+
uninstallPlugin: async (identifier) => {
|
189
|
+
await pluginService.uninstallPlugin(identifier);
|
190
|
+
await get().refreshPlugins();
|
191
|
+
},
|
192
|
+
updateInstallLoadingState: (key, value) => {
|
193
|
+
set(
|
194
|
+
produce((draft: PluginStoreState) => {
|
195
|
+
draft.pluginInstallLoading[key] = value;
|
196
|
+
}),
|
197
|
+
false,
|
198
|
+
n('updateInstallLoadingState'),
|
199
|
+
);
|
200
|
+
},
|
201
|
+
updatePluginInstallProgress: (identifier, progress) => {
|
202
|
+
set(
|
203
|
+
produce((draft: PluginStoreState) => {
|
204
|
+
draft.pluginInstallProgress[identifier] = progress;
|
205
|
+
}),
|
206
|
+
false,
|
207
|
+
n(`updatePluginInstallProgress/${progress?.step || 'clear'}`),
|
208
|
+
);
|
209
|
+
},
|
210
|
+
|
211
|
+
useFetchInstalledPlugins: (enabled: boolean) =>
|
212
|
+
useSWR<LobeTool[]>(enabled ? INSTALLED_PLUGINS : null, pluginService.getInstalledPlugins, {
|
213
|
+
fallbackData: [],
|
214
|
+
onSuccess: (data) => {
|
215
|
+
set(
|
216
|
+
{ installedPlugins: data, loadingInstallPlugins: false },
|
217
|
+
false,
|
218
|
+
n('useFetchInstalledPlugins'),
|
219
|
+
);
|
220
|
+
},
|
221
|
+
revalidateOnFocus: false,
|
222
|
+
suspense: true,
|
223
|
+
}),
|
224
|
+
useFetchPluginList: (params) => {
|
225
|
+
const locale = globalHelpers.getCurrentLanguage();
|
226
|
+
|
227
|
+
return useSWR<PluginListResponse>(
|
228
|
+
['useFetchPluginList', locale, ...Object.values(params)].filter(Boolean).join('-'),
|
229
|
+
async () => toolService.getOldPluginList(params),
|
230
|
+
{
|
231
|
+
onSuccess(data) {
|
232
|
+
set(
|
233
|
+
produce((draft: PluginStoreState) => {
|
234
|
+
draft.pluginSearchLoading = false;
|
235
|
+
|
236
|
+
// 设置基础信息
|
237
|
+
if (!draft.isPluginListInit) {
|
238
|
+
draft.activePluginIdentifier = data.items?.[0]?.identifier;
|
239
|
+
draft.isPluginListInit = true;
|
240
|
+
draft.pluginTotalCount = data.totalCount;
|
241
|
+
}
|
242
|
+
|
243
|
+
// 累积数据逻辑
|
244
|
+
if (params.page === 1) {
|
245
|
+
// 第一页,直接设置
|
246
|
+
draft.oldPluginItems = uniqBy(data.items, 'identifier');
|
247
|
+
} else {
|
248
|
+
// 后续页面,累积数据
|
249
|
+
draft.oldPluginItems = uniqBy(
|
250
|
+
[...draft.oldPluginItems, ...data.items],
|
251
|
+
'identifier',
|
252
|
+
);
|
253
|
+
}
|
254
|
+
}),
|
255
|
+
false,
|
256
|
+
n('useFetchPluginList/onSuccess'),
|
257
|
+
);
|
258
|
+
},
|
259
|
+
revalidateOnFocus: false,
|
260
|
+
},
|
261
|
+
);
|
262
|
+
},
|
263
|
+
useFetchPluginStore: () =>
|
264
|
+
useSWR<DiscoverPluginItem[]>('loadPluginStore', get().loadPluginStore, {
|
265
|
+
fallbackData: [],
|
266
|
+
revalidateOnFocus: false,
|
267
|
+
suspense: true,
|
268
|
+
}),
|
269
|
+
});
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { isDesktop } from '@/const/version';
|
2
|
+
import { DiscoverPluginItem } from '@/types/discover';
|
3
|
+
|
4
|
+
export type PluginInstallLoadingMap = Record<string, boolean | undefined>;
|
5
|
+
|
6
|
+
export enum PluginStoreTabs {
|
7
|
+
Installed = 'installed',
|
8
|
+
MCP = 'mcp',
|
9
|
+
Plugin = 'old',
|
10
|
+
}
|
11
|
+
|
12
|
+
/* eslint-disable typescript-sort-keys/string-enum */
|
13
|
+
export enum PluginInstallStep {
|
14
|
+
FETCHING_MANIFEST = 'FETCHING_MANIFEST',
|
15
|
+
INSTALLING_PLUGIN = 'INSTALLING_PLUGIN',
|
16
|
+
COMPLETED = 'COMPLETED',
|
17
|
+
ERROR = 'ERROR',
|
18
|
+
}
|
19
|
+
/* eslint-enable */
|
20
|
+
|
21
|
+
export interface PluginInstallProgress {
|
22
|
+
// 错误信息
|
23
|
+
error?: string;
|
24
|
+
// 0-100
|
25
|
+
progress: number;
|
26
|
+
step: PluginInstallStep;
|
27
|
+
}
|
28
|
+
|
29
|
+
export type PluginInstallProgressMap = Record<string, PluginInstallProgress | undefined>;
|
30
|
+
|
31
|
+
export interface PluginStoreState {
|
32
|
+
activePluginIdentifier?: string;
|
33
|
+
currentPluginPage: number;
|
34
|
+
displayMode: 'grid' | 'list';
|
35
|
+
isPluginListInit?: boolean;
|
36
|
+
|
37
|
+
listType: PluginStoreTabs;
|
38
|
+
oldPluginItems: DiscoverPluginItem[];
|
39
|
+
pluginInstallLoading: PluginInstallLoadingMap;
|
40
|
+
pluginInstallProgress: PluginInstallProgressMap;
|
41
|
+
pluginSearchKeywords?: string;
|
42
|
+
pluginSearchLoading?: boolean;
|
43
|
+
pluginTotalCount?: number;
|
44
|
+
}
|
45
|
+
|
46
|
+
export const initialPluginStoreState: PluginStoreState = {
|
47
|
+
// Plugin list state management initial values
|
48
|
+
currentPluginPage: 1,
|
49
|
+
displayMode: 'grid',
|
50
|
+
listType: isDesktop ? PluginStoreTabs.MCP : PluginStoreTabs.Plugin,
|
51
|
+
oldPluginItems: [],
|
52
|
+
pluginInstallLoading: {},
|
53
|
+
pluginInstallProgress: {},
|
54
|
+
};
|
@@ -5,19 +5,22 @@ import { pluginStoreSelectors } from './selectors';
|
|
5
5
|
|
6
6
|
const mockState = {
|
7
7
|
...initialState,
|
8
|
-
|
8
|
+
listType: 'old',
|
9
|
+
oldPluginItems: [
|
9
10
|
{
|
10
11
|
identifier: 'plugin-1',
|
11
12
|
author: 'Author 1',
|
12
13
|
createdAt: '2021-01-01',
|
13
|
-
|
14
|
+
avatar: 'avatar-url-1',
|
15
|
+
title: 'Plugin 1',
|
14
16
|
homepage: 'http://homepage-1.com',
|
15
17
|
},
|
16
18
|
{
|
17
19
|
identifier: 'plugin-2',
|
18
20
|
author: 'Author 2',
|
19
21
|
createdAt: '2022-02-02',
|
20
|
-
|
22
|
+
avatar: 'avatar-url-2',
|
23
|
+
title: 'Plugin 2',
|
21
24
|
homepage: 'http://homepage-2.com',
|
22
25
|
},
|
23
26
|
],
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { PluginStoreTabs } from '@/store/tool/slices/oldStore/initialState';
|
1
2
|
import { InstallPluginMeta } from '@/types/tool/plugin';
|
2
3
|
|
3
4
|
import type { ToolStoreState } from '../../initialState';
|
@@ -5,28 +6,40 @@ import type { ToolStoreState } from '../../initialState';
|
|
5
6
|
const onlinePluginStore = (s: ToolStoreState) => {
|
6
7
|
const installedPluginIds = new Set(s.installedPlugins.map((i) => i.identifier));
|
7
8
|
const list =
|
8
|
-
s.listType ===
|
9
|
-
? s.
|
10
|
-
: s.
|
9
|
+
s.listType === PluginStoreTabs.Plugin
|
10
|
+
? s.oldPluginItems
|
11
|
+
: s.oldPluginItems.filter((p) => installedPluginIds.has(p.identifier));
|
11
12
|
|
12
13
|
return list.map<InstallPluginMeta>((p) => ({
|
13
14
|
author: p.author,
|
14
15
|
createdAt: p.createdAt,
|
15
16
|
homepage: p.homepage,
|
16
17
|
identifier: p.identifier,
|
17
|
-
meta:
|
18
|
+
meta: {
|
19
|
+
avatar: p.avatar,
|
20
|
+
description: p.description,
|
21
|
+
tags: p.tags,
|
22
|
+
title: p.title,
|
23
|
+
},
|
18
24
|
type: 'plugin',
|
19
25
|
}));
|
20
26
|
};
|
21
27
|
|
22
28
|
const isPluginInstallLoading = (id: string) => (s: ToolStoreState) => s.pluginInstallLoading[id];
|
23
29
|
|
30
|
+
const getPluginInstallProgress = (id: string) => (s: ToolStoreState) => s.pluginInstallProgress[id];
|
31
|
+
|
32
|
+
const isOldPluginInInstallProgress = (id: string) => (s: ToolStoreState) =>
|
33
|
+
!!s.pluginInstallProgress[id];
|
34
|
+
|
24
35
|
const getPluginById = (id: string) => (s: ToolStoreState) => {
|
25
|
-
return s.
|
36
|
+
return s.oldPluginItems.find((i) => i.identifier === id);
|
26
37
|
};
|
27
38
|
|
28
39
|
export const pluginStoreSelectors = {
|
29
40
|
getPluginById,
|
41
|
+
getPluginInstallProgress,
|
42
|
+
isOldPluginInInstallProgress,
|
30
43
|
isPluginInstallLoading,
|
31
44
|
onlinePluginStore,
|
32
45
|
};
|
@@ -3,6 +3,7 @@ import { act, renderHook } from '@testing-library/react';
|
|
3
3
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
4
4
|
|
5
5
|
import { pluginService } from '@/services/plugin';
|
6
|
+
import { DiscoverPluginItem } from '@/types/discover';
|
6
7
|
import { LobeTool } from '@/types/tool';
|
7
8
|
import { merge } from '@/utils/merge';
|
8
9
|
|
@@ -65,7 +66,7 @@ describe('useToolStore:plugin', () => {
|
|
65
66
|
loadPluginStore: loadPluginStoreMock,
|
66
67
|
installPlugins: installPluginsMock,
|
67
68
|
installedPlugins: [{ identifier: 'abc' }] as LobeTool[],
|
68
|
-
|
69
|
+
oldPluginItems: [{ identifier: 'abc' }] as DiscoverPluginItem[],
|
69
70
|
});
|
70
71
|
|
71
72
|
const { result } = renderHook(() => useToolStore());
|
@@ -8,7 +8,7 @@ import { pluginService } from '@/services/plugin';
|
|
8
8
|
import { merge } from '@/utils/merge';
|
9
9
|
|
10
10
|
import { ToolStore } from '../../store';
|
11
|
-
import { pluginStoreSelectors } from '../
|
11
|
+
import { pluginStoreSelectors } from '../oldStore/selectors';
|
12
12
|
import { pluginSelectors } from './selectors';
|
13
13
|
|
14
14
|
/**
|
@@ -17,7 +17,12 @@ import { pluginSelectors } from './selectors';
|
|
17
17
|
export interface PluginAction {
|
18
18
|
checkPluginsIsInstalled: (plugins: string[]) => Promise<void>;
|
19
19
|
removeAllPlugins: () => Promise<void>;
|
20
|
-
|
20
|
+
updateInstallMcpPlugin: (id: string, value: any) => Promise<void>;
|
21
|
+
updatePluginSettings: <T>(
|
22
|
+
id: string,
|
23
|
+
settings: Partial<T>,
|
24
|
+
options?: { override?: boolean },
|
25
|
+
) => Promise<void>;
|
21
26
|
useCheckPluginsIsInstalled: (enable: boolean, plugins: string[]) => SWRResponse;
|
22
27
|
validatePluginSettings: (identifier: string) => Promise<ValidationResult | undefined>;
|
23
28
|
}
|
@@ -46,14 +51,27 @@ export const createPluginSlice: StateCreator<
|
|
46
51
|
await pluginService.removeAllPlugins();
|
47
52
|
await get().refreshPlugins();
|
48
53
|
},
|
49
|
-
|
54
|
+
|
55
|
+
updateInstallMcpPlugin: async (id, value) => {
|
56
|
+
const installedPlugin = pluginSelectors.getInstalledPluginById(id)(get());
|
57
|
+
|
58
|
+
if (!installedPlugin) return;
|
59
|
+
|
60
|
+
await pluginService.updatePlugin(id, {
|
61
|
+
customParams: { mcp: merge(installedPlugin.customParams?.mcp, value) },
|
62
|
+
});
|
63
|
+
|
64
|
+
await get().refreshPlugins();
|
65
|
+
},
|
66
|
+
|
67
|
+
updatePluginSettings: async (id, settings, { override } = {}) => {
|
50
68
|
const signal = get().updatePluginSettingsSignal;
|
51
69
|
if (signal) signal.abort(MESSAGE_CANCEL_FLAT);
|
52
70
|
|
53
71
|
const newSignal = new AbortController();
|
54
72
|
|
55
73
|
const previousSettings = pluginSelectors.getPluginSettingsById(id)(get());
|
56
|
-
const nextSettings = merge(previousSettings, settings);
|
74
|
+
const nextSettings = override ? settings : merge(previousSettings, settings);
|
57
75
|
|
58
76
|
set({ updatePluginSettingsSignal: newSignal }, false, 'create new Signal');
|
59
77
|
await pluginService.updatePluginSettings(id, nextSettings, newSignal.signal);
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { LobeChatPluginManifest, LobeChatPluginMeta } from '@lobehub/chat-plugin-sdk';
|
2
2
|
import { describe, expect, it } from 'vitest';
|
3
3
|
|
4
|
+
import { DiscoverPluginItem } from '@/types/discover';
|
5
|
+
|
4
6
|
import { initialState } from '../../initialState';
|
5
7
|
import { ToolStoreState } from '../../initialState';
|
6
8
|
import { pluginSelectors } from './selectors';
|
@@ -39,14 +41,15 @@ const mockState = {
|
|
39
41
|
type: 'customPlugin',
|
40
42
|
},
|
41
43
|
],
|
42
|
-
|
44
|
+
oldPluginItems: [
|
43
45
|
{
|
44
46
|
identifier: 'plugin-1',
|
45
47
|
author: 'Author 1',
|
46
48
|
createdAt: '2021-01-01',
|
47
|
-
|
49
|
+
avatar: 'avatar-url-1',
|
50
|
+
title: 'Plugin 1',
|
48
51
|
homepage: 'http://homepage-1.com',
|
49
|
-
} as
|
52
|
+
} as DiscoverPluginItem,
|
50
53
|
{
|
51
54
|
identifier: 'plugin-2',
|
52
55
|
author: 'Author 2',
|
@@ -68,7 +71,11 @@ describe('pluginSelectors', () => {
|
|
68
71
|
describe('getPluginMetaById', () => {
|
69
72
|
it('should return the plugin metadata by id', () => {
|
70
73
|
const result = pluginSelectors.getPluginMetaById('plugin-1')(mockState);
|
71
|
-
|
74
|
+
const item = mockState.oldPluginItems[0];
|
75
|
+
expect(result).toEqual({
|
76
|
+
title: item.title,
|
77
|
+
avatar: item.avatar,
|
78
|
+
});
|
72
79
|
});
|
73
80
|
});
|
74
81
|
|
@@ -182,6 +189,7 @@ describe('pluginSelectors', () => {
|
|
182
189
|
identifier: p.identifier,
|
183
190
|
meta: pluginSelectors.getPluginMetaById(p.identifier)(mockState),
|
184
191
|
type: p.type,
|
192
|
+
...pluginSelectors.getPluginMetaById(p.identifier)(mockState),
|
185
193
|
}));
|
186
194
|
expect(result).toEqual(expectedMetaList);
|
187
195
|
});
|