@coze-arch/cli 0.0.1-alpha.ef0249 → 0.0.1-alpha.f11735

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.
@@ -6,6 +6,7 @@ import reactHooks from 'eslint-plugin-react-hooks';
6
6
  import regexp from 'eslint-plugin-regexp';
7
7
  import pluginImport from 'eslint-plugin-import';
8
8
  import fontawesome6 from '../eslint-plugins/fontawesome6/index.js';
9
+ import reanimated from '../eslint-plugins/reanimated/index.js'
9
10
 
10
11
  export default [
11
12
  {
@@ -16,6 +17,7 @@ export default [
16
17
  'src/api/**', // 排除 src 下的自动生成 API
17
18
  '.expo/**', // 排除 Expo 自动生成的文件
18
19
  'tailwind.config.js', // 排除 Tailwind 配置文件
20
+ '**/*.d.ts',
19
21
  ],
20
22
  },
21
23
  regexp.configs["flat/recommended"],
@@ -54,6 +56,7 @@ export default [
54
56
  plugins: {
55
57
  import: pluginImport,
56
58
  fontawesome6,
59
+ reanimated,
57
60
  },
58
61
  rules: {
59
62
  // 关闭代码风格规则
@@ -73,6 +76,7 @@ export default [
73
76
  'react/react-in-jsx-scope': 'off',
74
77
  'react/jsx-uses-react': 'off',
75
78
  'fontawesome6/valid-name': 'error',
79
+ 'reanimated/ban-mix-use': 'error',
76
80
  },
77
81
  },
78
82
 
@@ -1,19 +1,21 @@
1
- import { useEffect, useState } from 'react';
1
+ import { createContext, Dispatch, ReactNode, SetStateAction, useContext, useEffect, useState } from 'react';
2
2
  import { ColorSchemeName, useColorScheme as useReactNativeColorScheme, Platform } from 'react-native';
3
3
 
4
- export function useColorScheme() {
4
+ const ColorSchemeContext = createContext<'light' | 'dark' | null | undefined>(null);
5
+
6
+ const ColorSchemeProvider = function ({ children }: { children?: ReactNode }) {
5
7
  const systemColorScheme = useReactNativeColorScheme();
6
- const [colorScheme, setColorScheme] = useState<ColorSchemeName>(systemColorScheme);
8
+ const [colorScheme, setColorScheme] = useState(systemColorScheme);
7
9
 
8
10
  useEffect(() => {
9
11
  setColorScheme(systemColorScheme);
10
- }, [systemColorScheme])
12
+ }, [systemColorScheme]);
11
13
 
12
14
  useEffect(() => {
13
15
  function handleMessage(e: MessageEvent<{ event: string; colorScheme: ColorSchemeName; } | undefined>) {
14
16
  if (e.data?.event === 'coze.workbench.colorScheme') {
15
17
  const cs = e.data.colorScheme;
16
- if (typeof cs === 'string') {
18
+ if (typeof cs === 'string' && typeof setColorScheme === 'function') {
17
19
  setColorScheme(cs);
18
20
  }
19
21
  }
@@ -28,7 +30,19 @@ export function useColorScheme() {
28
30
  window.removeEventListener('message', handleMessage, false);
29
31
  }
30
32
  }
31
- }, []);
33
+ }, [setColorScheme]);
34
+
35
+ return <ColorSchemeContext.Provider value={colorScheme}>
36
+ {children}
37
+ </ColorSchemeContext.Provider>
38
+ };
32
39
 
40
+ function useColorScheme() {
41
+ const colorScheme = useContext(ColorSchemeContext);
33
42
  return colorScheme;
34
43
  }
44
+
45
+ export {
46
+ ColorSchemeProvider,
47
+ useColorScheme,
48
+ }