@lobehub/chat 0.145.2 → 0.145.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.145.4](https://github.com/lobehub/lobe-chat/compare/v0.145.3...v0.145.4)
6
+
7
+ <sup>Released on **2024-03-29**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix plugin install loading state error.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix plugin install loading state error, closes [#1815](https://github.com/lobehub/lobe-chat/issues/1815) ([2412a73](https://github.com/lobehub/lobe-chat/commit/2412a73))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 0.145.3](https://github.com/lobehub/lobe-chat/compare/v0.145.2...v0.145.3)
31
+
32
+ <sup>Released on **2024-03-29**</sup>
33
+
34
+ #### 🐛 Bug Fixes
35
+
36
+ - **misc**: Fix antd locale.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's fixed
44
+
45
+ - **misc**: Fix antd locale, closes [#1814](https://github.com/lobehub/lobe-chat/issues/1814) ([e7fc148](https://github.com/lobehub/lobe-chat/commit/e7fc148))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ### [Version 0.145.2](https://github.com/lobehub/lobe-chat/compare/v0.145.1...v0.145.2)
6
56
 
7
57
  <sup>Released on **2024-03-29**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.145.2",
3
+ "version": "0.145.4",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -0,0 +1,20 @@
1
+ // Entry component
2
+ import { App } from 'antd';
3
+ import type { MessageInstance } from 'antd/es/message/interface';
4
+ import type { ModalStaticFunctions } from 'antd/es/modal/confirm';
5
+ import type { NotificationInstance } from 'antd/es/notification/interface';
6
+ import { memo } from 'react';
7
+
8
+ let message: MessageInstance;
9
+ let notification: NotificationInstance;
10
+ let modal: Omit<ModalStaticFunctions, 'warn'>;
11
+
12
+ export default memo(() => {
13
+ const staticFunction = App.useApp();
14
+ message = staticFunction.message;
15
+ modal = staticFunction.modal;
16
+ notification = staticFunction.notification;
17
+ return null;
18
+ });
19
+
20
+ export { message, modal, notification };
@@ -7,6 +7,7 @@ import 'antd/dist/reset.css';
7
7
  import Image from 'next/image';
8
8
  import { PropsWithChildren, ReactNode, memo, useEffect } from 'react';
9
9
 
10
+ import AntdStaticMethods from '@/components/AntdStaticMethods';
10
11
  import {
11
12
  LOBE_THEME_APPEARANCE,
12
13
  LOBE_THEME_NEUTRAL_COLOR,
@@ -76,6 +77,7 @@ const AppTheme = memo<AppThemeProps>(
76
77
  themeMode={themeMode}
77
78
  >
78
79
  <GlobalStyle />
80
+ <AntdStaticMethods />
79
81
  <ConfigProvider config={{ imgAs: Image, imgUnoptimized: true }}>
80
82
  <Container>{children}</Container>
81
83
  </ConfigProvider>
@@ -44,17 +44,17 @@ const GlobalLayout = async ({ children }: GlobalLayoutProps) => {
44
44
 
45
45
  return (
46
46
  <StyleRegistry>
47
- <AppTheme
48
- defaultAppearance={appearance?.value}
49
- defaultNeutralColor={neutralColor?.value as any}
50
- defaultPrimaryColor={primaryColor?.value as any}
51
- >
52
- <Locale antdLocale={antdLocale} defaultLang={defaultLang?.value}>
47
+ <Locale antdLocale={antdLocale} defaultLang={defaultLang?.value}>
48
+ <AppTheme
49
+ defaultAppearance={appearance?.value}
50
+ defaultNeutralColor={neutralColor?.value as any}
51
+ defaultPrimaryColor={primaryColor?.value as any}
52
+ >
53
53
  <StoreHydration />
54
54
  {children}
55
55
  <DebugUI />
56
- </Locale>
57
- </AppTheme>
56
+ </AppTheme>
57
+ </Locale>
58
58
  </StyleRegistry>
59
59
  );
60
60
  };
@@ -1,9 +1,9 @@
1
- import { message } from 'antd';
2
1
  import { t } from 'i18next';
3
2
  import useSWR, { SWRResponse, mutate } from 'swr';
4
3
  import { DeepPartial } from 'utility-types';
5
4
  import { StateCreator } from 'zustand/vanilla';
6
5
 
6
+ import { message } from '@/components/AntdStaticMethods';
7
7
  import { INBOX_SESSION_ID } from '@/const/session';
8
8
  import { useClientDataSWR } from '@/libs/swr';
9
9
  import { sessionService } from '@/services/session';
@@ -1,8 +1,8 @@
1
- import { notification } from 'antd';
2
1
  import { t } from 'i18next';
3
2
  import { merge } from 'lodash-es';
4
3
  import { StateCreator } from 'zustand/vanilla';
5
4
 
5
+ import { notification } from '@/components/AntdStaticMethods';
6
6
  import { pluginService } from '@/services/plugin';
7
7
  import { pluginHelpers } from '@/store/tool/helpers';
8
8
  import { LobeToolCustomPlugin, PluginInstallError } from '@/types/tool/plugin';
@@ -1,14 +1,19 @@
1
1
  import { LobeChatPluginManifest, LobeChatPluginMeta } from '@lobehub/chat-plugin-sdk';
2
2
  import { act, renderHook } from '@testing-library/react';
3
- import { notification } from 'antd';
4
3
  import useSWR from 'swr';
5
4
  import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
5
 
6
+ import { notification } from '@/components/AntdStaticMethods';
7
7
  import { pluginService } from '@/services/plugin';
8
- import { LobeToolCustomPlugin } from '@/types/tool/plugin';
9
8
 
10
9
  import { useToolStore } from '../../store';
11
10
 
11
+ // Mock necessary modules and functions
12
+ vi.mock('@/components/AntdStaticMethods', () => ({
13
+ notification: {
14
+ error: vi.fn(),
15
+ },
16
+ }));
12
17
  // Mock the pluginService.getPluginList method
13
18
  vi.mock('@/services/plugin', () => ({
14
19
  pluginService: {
@@ -173,8 +178,6 @@ describe('useToolStore:pluginStore', () => {
173
178
 
174
179
  describe('installPlugin', () => {
175
180
  it('should install a plugin with valid manifest', async () => {
176
- vi.spyOn(notification, 'error');
177
-
178
181
  const pluginIdentifier = 'plugin1';
179
182
 
180
183
  const originalUpdateInstallLoadingState = useToolStore.getState().updateInstallLoadingState;
@@ -250,7 +253,6 @@ describe('useToolStore:pluginStore', () => {
250
253
  const error = new TypeError('noManifest');
251
254
 
252
255
  // Mock necessary modules and functions
253
- vi.spyOn(notification, 'error');
254
256
  (pluginService.getPluginManifest as Mock).mockRejectedValue(error);
255
257
 
256
258
  useToolStore.setState({
@@ -1,10 +1,10 @@
1
1
  import { LobeChatPluginsMarketIndex } from '@lobehub/chat-plugin-sdk';
2
- import { notification } from 'antd';
3
2
  import { t } from 'i18next';
4
3
  import { produce } from 'immer';
5
4
  import useSWR, { SWRResponse, mutate } from 'swr';
6
5
  import { StateCreator } from 'zustand/vanilla';
7
6
 
7
+ import { notification } from '@/components/AntdStaticMethods';
8
8
  import { pluginService } from '@/services/plugin';
9
9
  import { pluginStoreSelectors } from '@/store/tool/selectors';
10
10
  import { LobeTool } from '@/types/tool';
@@ -40,9 +40,8 @@ export const createPluginStoreSlice: StateCreator<
40
40
  const plugin = pluginStoreSelectors.getPluginById(name)(get());
41
41
  if (!plugin) return;
42
42
 
43
+ const { updateInstallLoadingState, refreshPlugins } = get();
43
44
  try {
44
- const { updateInstallLoadingState, refreshPlugins } = get();
45
-
46
45
  updateInstallLoadingState(name, true);
47
46
  const data = await pluginService.getPluginManifest(plugin.manifest);
48
47
  updateInstallLoadingState(name, undefined);
@@ -52,8 +51,9 @@ export const createPluginStoreSlice: StateCreator<
52
51
  await refreshPlugins();
53
52
  } catch (error) {
54
53
  console.error(error);
55
- const err = error as PluginInstallError;
54
+ updateInstallLoadingState(name, undefined);
56
55
 
56
+ const err = error as PluginInstallError;
57
57
  notification.error({
58
58
  description: t(`error.${err.message}`, { ns: 'plugin' }),
59
59
  message: t('error.installError', { name: plugin.meta.title, ns: 'plugin' }),
@@ -1,5 +1,4 @@
1
- import { notification } from 'antd';
2
-
1
+ import { notification } from '@/components/AntdStaticMethods';
3
2
  import { CURRENT_CONFIG_VERSION, Migration } from '@/migrations';
4
3
  import {
5
4
  ConfigFile,