@coze-arch/cli 0.1.4-alpha.5377b5 → 0.1.4-alpha.8c3e03
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/lib/__templates__/expo/client/components/Screen.tsx +65 -25
- package/lib/__templates__/expo/client/heroui/components/toast/toast.tsx +6 -2
- package/lib/__templates__/expo/client/heroui/helpers/internal/hooks/use-controllable-state.ts +1 -1
- package/lib/__templates__/nextjs/next.config.ts +9 -0
- package/lib/__templates__/nextjs/package.json +0 -3
- package/lib/__templates__/nextjs/pnpm-lock.yaml +0 -931
- package/lib/__templates__/nextjs/scripts/dev.sh +2 -3
- package/lib/__templates__/nextjs/src/app/layout.tsx +0 -4
- package/lib/cli.js +1 -1
- package/package.json +1 -1
- package/lib/__templates__/nextjs/.babelrc +0 -15
|
@@ -6,13 +6,19 @@ import {
|
|
|
6
6
|
View,
|
|
7
7
|
TouchableWithoutFeedback,
|
|
8
8
|
Keyboard,
|
|
9
|
-
ViewStyle,
|
|
9
|
+
type ViewStyle,
|
|
10
10
|
FlatList,
|
|
11
|
+
type FlatListProps,
|
|
11
12
|
SectionList,
|
|
13
|
+
type SectionListProps,
|
|
14
|
+
type ScrollViewProps,
|
|
12
15
|
Modal,
|
|
13
16
|
} from 'react-native';
|
|
14
17
|
import { withUniwind } from 'uniwind';
|
|
15
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
useSafeAreaInsets,
|
|
20
|
+
type Edge,
|
|
21
|
+
} from 'react-native-safe-area-context';
|
|
16
22
|
import { StatusBar } from 'expo-status-bar';
|
|
17
23
|
// 引入 KeyboardAware 系列组件
|
|
18
24
|
import {
|
|
@@ -86,58 +92,92 @@ type KeyboardAwareProps = {
|
|
|
86
92
|
contentInsetBehaviorIOS: 'automatic' | 'never';
|
|
87
93
|
};
|
|
88
94
|
|
|
95
|
+
type NativeScrollableProps = Pick<
|
|
96
|
+
ScrollViewProps,
|
|
97
|
+
| 'contentContainerStyle'
|
|
98
|
+
| 'keyboardShouldPersistTaps'
|
|
99
|
+
| 'keyboardDismissMode'
|
|
100
|
+
| 'contentInsetAdjustmentBehavior'
|
|
101
|
+
>;
|
|
102
|
+
|
|
89
103
|
const KeyboardAwareScrollable = ({
|
|
90
104
|
element,
|
|
91
105
|
extraPadding,
|
|
92
106
|
contentInsetBehaviorIOS,
|
|
93
107
|
}: KeyboardAwareProps) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
const createEnhancedContentStyle = (
|
|
109
|
+
contentContainerStyle: ScrollViewProps['contentContainerStyle'],
|
|
110
|
+
) => {
|
|
111
|
+
const mergedStyle = StyleSheet.flatten(contentContainerStyle) ?? {};
|
|
112
|
+
const currentPaddingBottom =
|
|
113
|
+
typeof mergedStyle.paddingBottom === 'number'
|
|
114
|
+
? mergedStyle.paddingBottom
|
|
115
|
+
: 0;
|
|
100
116
|
|
|
101
|
-
|
|
102
|
-
|
|
117
|
+
return [
|
|
118
|
+
{
|
|
119
|
+
...mergedStyle,
|
|
120
|
+
paddingBottom: currentPaddingBottom + extraPadding,
|
|
121
|
+
},
|
|
122
|
+
];
|
|
123
|
+
};
|
|
103
124
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
125
|
+
const createKeyboardAwareProps = <Props extends NativeScrollableProps>(
|
|
126
|
+
childProps: Props,
|
|
127
|
+
) => ({
|
|
128
|
+
...childProps,
|
|
129
|
+
contentContainerStyle: createEnhancedContentStyle(
|
|
130
|
+
childProps.contentContainerStyle,
|
|
131
|
+
),
|
|
132
|
+
keyboardShouldPersistTaps:
|
|
133
|
+
childProps.keyboardShouldPersistTaps ?? 'handled',
|
|
134
|
+
keyboardDismissMode: childProps.keyboardDismissMode ?? 'on-drag',
|
|
110
135
|
enableOnAndroid: true,
|
|
111
136
|
// 类似于原代码中的 setTimeout/scrollToEnd 逻辑,这里设置额外的滚动高度确保输入框可见
|
|
112
137
|
extraHeight: 100,
|
|
113
138
|
// 禁用自带的 ScrollView 自动 inset,由外部 padding 控制
|
|
114
139
|
enableAutomaticScroll: true,
|
|
115
140
|
...(Platform.OS === 'ios'
|
|
116
|
-
? {
|
|
141
|
+
? {
|
|
142
|
+
contentInsetAdjustmentBehavior:
|
|
143
|
+
childProps.contentInsetAdjustmentBehavior ??
|
|
144
|
+
contentInsetBehaviorIOS,
|
|
145
|
+
}
|
|
117
146
|
: {}),
|
|
118
|
-
};
|
|
147
|
+
});
|
|
119
148
|
|
|
120
|
-
const t =
|
|
149
|
+
const t = element.type;
|
|
121
150
|
|
|
122
151
|
// 根据组件类型返回对应的 KeyboardAware 版本
|
|
123
152
|
// 注意:不再使用 KeyboardAvoidingView,直接替换为增强版 ScrollView
|
|
124
153
|
if (t === ScrollView) {
|
|
125
|
-
|
|
154
|
+
const childProps = element.props as ScrollViewProps;
|
|
155
|
+
return (
|
|
156
|
+
<KeyboardAwareScrollView {...createKeyboardAwareProps(childProps)} />
|
|
157
|
+
);
|
|
126
158
|
}
|
|
127
159
|
|
|
128
160
|
if (t === FlatList) {
|
|
129
|
-
|
|
161
|
+
const childProps = element.props as FlatListProps<unknown>;
|
|
162
|
+
return <KeyboardAwareFlatList {...createKeyboardAwareProps(childProps)} />;
|
|
130
163
|
}
|
|
131
164
|
|
|
132
165
|
if (t === SectionList) {
|
|
133
|
-
|
|
166
|
+
const childProps = element.props as SectionListProps<unknown>;
|
|
167
|
+
return (
|
|
168
|
+
<KeyboardAwareSectionList {...createKeyboardAwareProps(childProps)} />
|
|
169
|
+
);
|
|
134
170
|
}
|
|
135
171
|
|
|
136
172
|
// 理论上不应运行到这里,如果是非标准组件则原样返回,仅修改样式
|
|
173
|
+
const childProps = element.props as NativeScrollableProps;
|
|
137
174
|
return React.cloneElement(element, {
|
|
138
|
-
contentContainerStyle:
|
|
139
|
-
|
|
140
|
-
|
|
175
|
+
contentContainerStyle: createEnhancedContentStyle(
|
|
176
|
+
childProps.contentContainerStyle,
|
|
177
|
+
),
|
|
178
|
+
keyboardShouldPersistTaps:
|
|
179
|
+
childProps.keyboardShouldPersistTaps ?? 'handled',
|
|
180
|
+
keyboardDismissMode: childProps.keyboardDismissMode ?? 'on-drag',
|
|
141
181
|
});
|
|
142
182
|
};
|
|
143
183
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef, useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type GestureResponderEvent,
|
|
4
|
+
View,
|
|
5
|
+
Text as RNText,
|
|
6
|
+
} from 'react-native';
|
|
3
7
|
import { GestureDetector } from 'react-native-gesture-handler';
|
|
4
8
|
import Animated from 'react-native-reanimated';
|
|
5
9
|
import { useThemeColor } from '../../helpers/external/hooks';
|
|
@@ -339,7 +343,7 @@ const ToastClose = forwardRef<View, ToastCloseProps>((props, ref) => {
|
|
|
339
343
|
* If hide and id are available from context, use them to hide the toast
|
|
340
344
|
* Otherwise, use the provided onPress handler
|
|
341
345
|
*/
|
|
342
|
-
const handlePress = (event:
|
|
346
|
+
const handlePress = (event: GestureResponderEvent) => {
|
|
343
347
|
if (hide && id) {
|
|
344
348
|
hide(id);
|
|
345
349
|
}
|
package/lib/__templates__/expo/client/heroui/helpers/internal/hooks/use-controllable-state.ts
CHANGED
|
@@ -108,7 +108,7 @@ function useUncontrolledState<T>({
|
|
|
108
108
|
* A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
109
109
|
* prop or avoid re-executing effects when passed as a dependency
|
|
110
110
|
*/
|
|
111
|
-
function useCallbackRef<T extends (...args:
|
|
111
|
+
function useCallbackRef<T extends (...args: never[]) => unknown>(
|
|
112
112
|
callback: T | undefined
|
|
113
113
|
): T {
|
|
114
114
|
const callbackRef = useRef(callback);
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { NextConfig } from 'next';
|
|
2
|
+
import path from 'path';
|
|
2
3
|
|
|
3
4
|
const nextConfig: NextConfig = {
|
|
4
5
|
// outputFileTracingRoot: path.resolve(__dirname, '../../'), // Uncomment and add 'import path from "path"' if needed
|
|
5
6
|
/* config options here */
|
|
6
7
|
serverExternalPackages: ['coze-coding-dev-sdk'],
|
|
8
|
+
webpack: (config, { dev }) => {
|
|
9
|
+
if (dev && config.cache && config.cache.type === 'filesystem') {
|
|
10
|
+
config.cache.cacheDirectory = path.resolve(
|
|
11
|
+
'node_modules/.cache/next-webpack',
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
return config;
|
|
15
|
+
},
|
|
7
16
|
allowedDevOrigins: ['*.dev.coze.site'],
|
|
8
17
|
images: {
|
|
9
18
|
remotePatterns: [
|
|
@@ -73,8 +73,6 @@
|
|
|
73
73
|
"zod": "^4.3.5"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@react-dev-inspector/babel-plugin": "^2.0.1",
|
|
77
|
-
"@react-dev-inspector/middleware": "^2.0.1",
|
|
78
76
|
"@tailwindcss/postcss": "^4",
|
|
79
77
|
"@types/node": "^20",
|
|
80
78
|
"@types/pg": "^8.16.0",
|
|
@@ -83,7 +81,6 @@
|
|
|
83
81
|
"eslint": "^9",
|
|
84
82
|
"eslint-config-next": "16.1.1",
|
|
85
83
|
"only-allow": "^1.2.2",
|
|
86
|
-
"react-dev-inspector": "^2.0.1",
|
|
87
84
|
"shadcn": "latest",
|
|
88
85
|
"stylelint": "^16.4.0",
|
|
89
86
|
"stylelint-config-standard": "^38.0.0",
|