@coze-arch/cli 0.1.4-alpha.5377b5 → 0.1.4-alpha.703f82
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/.cozeproj/scripts/prepare-node-modules.sh +4 -4
- 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/eslint.config.mjs +11 -5
- package/lib/__templates__/nextjs/next.config.ts +9 -0
- package/lib/__templates__/nextjs/package.json +1 -4
- package/lib/__templates__/nextjs/pnpm-lock.yaml +0 -931
- package/lib/__templates__/nextjs/scripts/build.sh +1 -0
- package/lib/__templates__/nextjs/scripts/dev.ps1 +2 -2
- package/lib/__templates__/nextjs/scripts/dev.sh +19 -5
- package/lib/__templates__/nextjs/scripts/prepare-next-output.sh +62 -0
- package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +4 -4
- package/lib/__templates__/nextjs/src/app/layout.tsx +0 -4
- package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +4 -4
- package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +4 -4
- package/lib/__templates__/vite/scripts/prepare-node-modules.sh +4 -4
- package/lib/cli.js +1 -1
- package/package.json +1 -1
- package/lib/__templates__/nextjs/.babelrc +0 -15
|
@@ -48,14 +48,14 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
48
48
|
|
|
49
49
|
mkdir -p "$WORK_DIR"
|
|
50
50
|
|
|
51
|
-
# Mirror the project with symlinks. node_modules
|
|
52
|
-
#
|
|
51
|
+
# Mirror the project with symlinks. node_modules and managed compiler output
|
|
52
|
+
# stay real in WORK_DIR; workspace directories stay real there too.
|
|
53
53
|
mirror_root() {
|
|
54
54
|
local entry name
|
|
55
55
|
while IFS= read -r -d '' entry; do
|
|
56
56
|
name="$(basename "$entry")"
|
|
57
57
|
case "$name" in
|
|
58
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
58
|
+
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
59
59
|
client|server)
|
|
60
60
|
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
61
|
;;
|
|
@@ -66,7 +66,7 @@ mirror_root() {
|
|
|
66
66
|
while IFS= read -r -d '' entry; do
|
|
67
67
|
name="$(basename "$entry")"
|
|
68
68
|
case "$name" in
|
|
69
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
69
|
+
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
70
70
|
client|server)
|
|
71
71
|
[ -f "$entry/package.json" ] && continue
|
|
72
72
|
;;
|
|
@@ -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);
|
|
@@ -23,6 +23,11 @@ const eslintConfig = defineConfig([
|
|
|
23
23
|
...nextVitals,
|
|
24
24
|
...nextTs,
|
|
25
25
|
{
|
|
26
|
+
settings: {
|
|
27
|
+
// node_modules 里的 barrel 包(lucide-react 等)不参与 ExportMap 构建,
|
|
28
|
+
// import/no-cycle 只需要项目源码的依赖图。
|
|
29
|
+
'import/ignore': ['/node_modules/'],
|
|
30
|
+
},
|
|
26
31
|
rules: {
|
|
27
32
|
'import/no-cycle': ['error', { ignoreExternal: true }],
|
|
28
33
|
'react-hooks/set-state-in-effect': 'off',
|
|
@@ -37,14 +42,15 @@ const eslintConfig = defineConfig([
|
|
|
37
42
|
},
|
|
38
43
|
// Override default ignores of eslint-config-next.
|
|
39
44
|
globalIgnores([
|
|
40
|
-
// Default ignores of eslint-config-next
|
|
41
|
-
|
|
42
|
-
'
|
|
43
|
-
'
|
|
45
|
+
// Default ignores of eslint-config-next (trailing slash prunes the whole
|
|
46
|
+
// directory instead of walking into it):
|
|
47
|
+
'.next/',
|
|
48
|
+
'out/',
|
|
49
|
+
'build/',
|
|
44
50
|
'next-env.d.ts',
|
|
45
51
|
// Build artifacts:
|
|
46
52
|
'server.js',
|
|
47
|
-
'dist
|
|
53
|
+
'dist/',
|
|
48
54
|
// Script files (CommonJS):
|
|
49
55
|
'scripts/**/*.js',
|
|
50
56
|
]),
|
|
@@ -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: [
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"build": "bash ./scripts/build.sh",
|
|
7
7
|
"dev": "bash ./scripts/dev.sh",
|
|
8
8
|
"preinstall": "npx only-allow pnpm",
|
|
9
|
-
"lint": "eslint",
|
|
9
|
+
"lint": "eslint --cache --cache-location node_modules/.cache/eslint/",
|
|
10
10
|
"lint:build": "eslint . --quiet",
|
|
11
11
|
"lint:style": "stylelint \"src/**/*.css\"",
|
|
12
12
|
"start": "bash ./scripts/start.sh",
|
|
@@ -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",
|