mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 21:01:32 +08:00
feat: add React Native support to aiCore package
Add React Native compatibility configuration to package.json, including the react-native field and updated exports mapping. Include documentation for React Native usage with metro.config.js setup instructions.
This commit is contained in:
parent
45405213fc
commit
36e20d545b
@ -45,6 +45,23 @@ Cherry Studio AI Core 是一个基于 Vercel AI SDK 的统一 AI Provider 接口
|
||||
npm install @cherrystudio/ai-core ai
|
||||
```
|
||||
|
||||
### React Native
|
||||
|
||||
如果你在 React Native 项目中使用此包,需要在 `metro.config.js` 中添加以下配置:
|
||||
|
||||
```javascript
|
||||
// metro.config.js
|
||||
const { getDefaultConfig } = require('expo/metro-config');
|
||||
|
||||
const config = getDefaultConfig(__dirname);
|
||||
|
||||
// 添加对 @cherrystudio/ai-core 的支持
|
||||
config.resolver.resolverMainFields = ['react-native', 'browser', 'main'];
|
||||
config.resolver.platforms = ['ios', 'android', 'native', 'web'];
|
||||
|
||||
module.exports = config;
|
||||
```
|
||||
|
||||
还需要安装你要使用的 AI SDK provider:
|
||||
|
||||
```bash
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
"version": "1.0.0-alpha.0",
|
||||
"description": "Cherry Studio AI Core - Unified AI Provider Interface Based on Vercel AI SDK",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"react-native": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "tsdown",
|
||||
"dev": "tsc -w",
|
||||
@ -120,19 +122,27 @@
|
||||
"tsdown": "^0.12.9",
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"react-native": "./dist/index.js",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js"
|
||||
"require": "./dist/index.js",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./core/plugins/built-in": {
|
||||
"types": "./dist/core/plugins/built-in/index.d.ts",
|
||||
"react-native": "./dist/core/plugins/built-in/index.js",
|
||||
"import": "./dist/core/plugins/built-in/index.mjs",
|
||||
"require": "./dist/core/plugins/built-in/index.js"
|
||||
"require": "./dist/core/plugins/built-in/index.js",
|
||||
"default": "./dist/core/plugins/built-in/index.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user