合并受阻
感谢提交 Pull Requests!
Thanks for submitting a pull request.


【AI-Review】【致命】【基础代码问题】【代码逻辑错误】global.css 导入路径错误导致构建失败
● 问题: example/src/index.tsx 第1行 import "../../../global.css" 的相对路径解析错误。该文件位于 example/src/index.tsx,../../../global.css 从 example/src/ 向上解析三级到达仓库根目录的父目录,该位置不存在 global.css 文件。仓库中唯一的 global.css 位于 example/global.css(与 example/metro.config.js 中 withNativeWind(config2, { input: './global.css' }) 的 input 配置一致)。base 版本(SHA 01d02e57)的导入为 import "../global.css",能正确解析到 example/global.css,本 PR 将其改为 ../../../global.css 后路径失效。
● 影响: 致命。Metro 解析器(packages/react-native-css-interop/src/metro/index.ts 的 resolveRequest)先调用原始 resolver 解析导入路径,再比对 options.input。由于 ../../../global.css 不存在,Metro 抛出 Module not found 错误,导致 example 应用在 npm run dev(bundle-harmony 打包)和 npm start(Metro 开发模式)下均无法构建,整个示例应用无法启动。
● 建议: 将导入路径改回 ../global.css:
import "../global.css"


【AI-Review】【严重】【基础代码问题】【代码逻辑错误】组件与 cssInterop 在 App 函数体内定义导致重渲染时状态丢失
● 问题: example/src/index.tsx 第18-28行将 ThirdPartyButton、CustomizedButton = remapProps(ThirdPartyButton, ...)、MyInput、OverridenTextInput = remapProps(MyInput, ...) 以及第30、45行的 cssInterop(TextInput, ...)、cssInterop(Tester, ...) 全部定义在 App 函数体内部。每次 App 渲染都会创建新的函数引用和新的 HOC 实例。useColorScheme()(packages/react-native-css-interop/src/runtime/native/api.ts 第101行 useColorScheme)返回的 setColorScheme 被绑定到"切换主题"按钮(onPress 中调用 setColorScheme(colorScheme === 'light' ? 'dark' : 'light'))。当用户点击该按钮时,setColorScheme 触发 App 重新渲染,所有内部定义的组件获得新的函数引用,React 协调器判定为不同组件类型并执行卸载-重新挂载。
● 影响: 严重。用户在 OverridenTextInput(第27行 MyInput 包装的 TextInput)中输入文本后,点击"切换主题"按钮,App 重渲染导致 OverridenTextInput 被卸载并重新挂载,输入内容丢失、键盘收起、焦点丢失。CustomizedButton 同理丢失按压状态。这破坏了示例应用的演示效果。
● 建议: 将组件定义、remapProps/cssInterop 调用移到模块作用域(App 函数外部):
// 模块作用域
const ThirdPartyButton = ({ buttonStyle, labelStyle, children, ...props }) => ( ... );
const CustomizedButton = remapProps(ThirdPartyButton, { buttonClass: "buttonStyle", labelClass: "labelStyle" });
const MyInput = (props) => <TextInput {...props} />;
const OverridenTextInput = remapProps(MyInput, { className: "style" });
cssInterop(TextInput, { className: { target: "style", nativeStyleToProp: { textAlign: true } }, placeholderClassName: { target: false, nativeStyleToProp: { color: "placeholderTextColor" } } });
cssInterop(Tester, { className: { target: "style", nativeStyleToProp: { textAlign: true } } });
export default function App() {
const { colorScheme, setColorScheme } = useColorScheme();
// ...
}


【AI-Review】【严重】【基础代码问题】【代码逻辑错误】移除 ohos.permission.INTERNET 导致 Metro 开发模式无法加载 JS bundle
● 问题: example/harmony/entry/src/main/module.json5 本 PR 删除了 requestPermissions 中的 ohos.permission.INTERNET 权限。但 example/harmony/entry/src/main/ets/pages/Index.ets 第101行 jsBundleProvider 将 new MetroJSBundleProvider() 作为首个 JS bundle 提供者,该提供者通过 HTTP(localhost:8081)从 Metro 开发服务器拉取 JS bundle。example/package.json 的 start 脚本 hdc rport tcp:8081 tcp:8081 && react-native start 即为该模式准备(hdc 反向端口转发 + Metro 服务)。HarmonyOS 应用访问网络(包括 localhost TCP 连接)需要 ohos.permission.INTERNET 权限。
● 影响: 严重。移除该权限后,MetroJSBundleProvider 无法建立到 Metro 服务器的网络连接,npm start 开发模式(带热重载/Fast Refresh)失效。开发者只能依赖 npm run dev/npm run prod 预打包的 bundle(FileJSBundleProvider/ResourceJSBundleProvider)才能运行应用,丧失开发期的实时调试能力。
● 建议: 恢复 ohos.permission.INTERNET 权限声明:
"requestPermissions": [
{
"name": "ohos.permission.INTERNET"
},
],


【AI-Review】【建议】【软件设计】【冗余重复代码】.babelrc 与 babel.config.js 配置重复
● 问题: example/src/.babelrc(本 PR 新增)配置 {"presets": ["@react-native-ohos/nativewind/babel"]},而 example/babel.config.js 第2行已配置 presets: ['module:@react-native/babel-preset', '@react-native-ohos/nativewind/babel'],nativewind babel preset 已包含在内。Babel 解析 example/src/ 下的文件时会同时合并 babel.config.js(项目级)与 .babelrc(目录级)配置,导致 nativewind preset 被重复应用。
● 影响: 建议。nativewind babel 插件(packages/react-native-css-interop/src/babel-plugin.ts)将 React.createElement 替换为 createInteropElement,二次应用时首轮已替换完毕、第二轮无匹配项为空操作,不会导致运行时错误,但造成不必要的重复 AST 遍历,且两处配置并存易在后续维护中产生混淆(如修改 babel.config.js 时忽略 .babelrc 仍在生效)。
● 建议: 删除 example/src/.babelrc,统一由 example/babel.config.js 管理构建配置。


已审视,无问题


fix: 修改nativewind三方库AI文档质量扫描整改