mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-09 14:59:27 +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
|
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:
|
还需要安装你要使用的 AI SDK provider:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@ -3,7 +3,9 @@
|
|||||||
"version": "1.0.0-alpha.0",
|
"version": "1.0.0-alpha.0",
|
||||||
"description": "Cherry Studio AI Core - Unified AI Provider Interface Based on Vercel AI SDK",
|
"description": "Cherry Studio AI Core - Unified AI Provider Interface Based on Vercel AI SDK",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
"module": "dist/index.mjs",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
"react-native": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsdown",
|
"build": "tsdown",
|
||||||
"dev": "tsc -w",
|
"dev": "tsc -w",
|
||||||
@ -120,19 +122,27 @@
|
|||||||
"tsdown": "^0.12.9",
|
"tsdown": "^0.12.9",
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
},
|
},
|
||||||
|
"sideEffects": false,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
"react-native": "./dist/index.js",
|
||||||
"import": "./dist/index.mjs",
|
"import": "./dist/index.mjs",
|
||||||
"require": "./dist/index.js"
|
"require": "./dist/index.js",
|
||||||
|
"default": "./dist/index.js"
|
||||||
},
|
},
|
||||||
"./core/plugins/built-in": {
|
"./core/plugins/built-in": {
|
||||||
"types": "./dist/core/plugins/built-in/index.d.ts",
|
"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",
|
"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