visualknowledge 0.1.3 → 0.1.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.
@@ -5,7 +5,7 @@
5
5
  * 管理对话消息、流式状态、主题、模型选择、全屏 Widget。
6
6
  */
7
7
 
8
- import { createContext, useContext, useReducer } from 'react';
8
+ import React, { createContext, useContext, useReducer } from 'react';
9
9
 
10
10
  // ====== Action Types ======
11
11
 
@@ -134,10 +134,10 @@ export const AppContext = createContext(null);
134
134
  export function AppProvider({ children }) {
135
135
  const [state, dispatch] = useReducer(appReducer, initialState);
136
136
 
137
- return (
138
- AppContext.Provider value={{ state, dispatch }}>
139
- {children}
140
- </AppContext.Provider>
137
+ return React.createElement(
138
+ AppContext.Provider,
139
+ { value: { state, dispatch } },
140
+ children
141
141
  );
142
142
  }
143
143
 
@@ -5,7 +5,7 @@
5
5
  * 切换时更新 document.documentElement.dataset.theme。
6
6
  */
7
7
 
8
- import { useState, useCallback } from 'react';
8
+ import { useState, useEffect, useCallback } from 'react';
9
9
 
10
10
  const STORAGE_KEY = 'claude-chat-theme';
11
11
 
@@ -23,9 +23,9 @@ export function useTheme() {
23
23
  }, [theme]);
24
24
 
25
25
  // 初始化:设置 DOM 主题
26
- useState(() => {
26
+ useEffect(() => {
27
27
  document.documentElement.setAttribute('data-theme', theme);
28
- });
28
+ }, []);
29
29
 
30
30
  return { theme, toggleTheme };
31
31
  }
@@ -7,10 +7,11 @@
7
7
  import React from 'react';
8
8
  import { createRoot } from 'react-dom/client';
9
9
  import { App } from './App.jsx';
10
+ import { AppProvider } from './context/AppContext.jsx';
10
11
 
11
12
  const rootEl = document.getElementById('root');
12
13
  if (!rootEl) {
13
14
  throw new Error('Root element #root not found in DOM');
14
15
  }
15
16
 
16
- createRoot(rootEl).render(React.createElement(App));
17
+ createRoot(rootEl).render(React.createElement(AppProvider, null, React.createElement(App)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "visualknowledge",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Interactive AI Chat with Visualization - one-click launch via npx",
5
5
  "bin": {
6
6
  "visualknowledge": "./bin/visualknowledge.js"