Skip to content

Commit 8762357

Browse files
authored
Merge pull request #2453 from didi/rn-template
Rn template
2 parents 2b4da25 + cc645a5 commit 8762357

20 files changed

Lines changed: 970 additions & 203 deletions

File tree

.agents/skills/mpx-development-guides/SKILL.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

.agents/skills/mpx-rn-style-guide/others/rn-style-detail.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -761,14 +761,10 @@ background: #f0f0f0;
761761

762762
### 7.7 使用限制
763763

764-
> [!tip] 编译时 vs 运行时
765-
>
766-
> - ✅ `class` 类样式中的简写属性会在编译时自动展开
767-
> - ❌ `style` 属性不会做简写展开,RN 不支持的简写在运行时不可用
768-
>
769-
> **CSS 变量限制**
770-
> - ❌ 简写属性不支持单个 `var()`(如 `margin: var(--spacing)`)
771-
> - ✅ 多值简写可使用多个 `var()`,按顺序展开到各子属性
764+
- ✅ `class` 类样式中的简写属性会在编译时自动展开
765+
- ❌ `style` 属性在运行时不会做简写展开,RN 原生不支持的简写属性在 `style` 属性中不可用
766+
- ❌ 简写属性不支持单个 `var()`(如 `margin: var(--spacing)`)
767+
- ✅ 多值简写可使用多个 `var()`,按顺序展开到各子属性
772768

773769
## 8. CSS 变量支持
774770

AGENTS.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# 开发指南
2+
3+
本仓库是 Mpx 的核心仓库,Mpx 是一款在微信原生小程序语法基础上进行了类 Vue 增强的跨端开发框架,能够以类似 Vue 的开发体验开发小程序及跨端应用,支持输出到多小程序平台、Web 和 React Native 环境中。
4+
5+
下面是本仓库中进行开发需要遵循的偏好指引及强制约束。
6+
7+
## 偏好指引
8+
9+
- 开发新特性时尽量参考具有相似性的已有的流程实现,尽可能复用当前已有的流程实现,或者保持与已有流程实现的相似性
10+
- 编写代码时尽可能保持简洁精炼,避免无效的冗余代码,例如:
11+
- 避免声明不必要的中间变量
12+
- 避免编写不必要的中间步骤
13+
- 避免添加不必要的兜底值
14+
- 避免添加不必要的容错判断
15+
16+
17+
## 强制约束
18+
19+
### 编码约束
20+
21+
- 所有运行时代码中禁止使用Object spread特性进行对象合并,应当使用Object.assign或者内部等效工具方法进行合并
22+
23+
### 代码检查约束
24+
25+
- 新增功能编写单元测试时仅需覆盖核心功能,无需全量覆盖
26+
- 任何过程中执行单元测试不通过时,仅尝试进行**2次**修复,如仍未通过则终止尝试,输出详细的错误信息以及对错误信息的分析
27+
- 进行代码变更后仅需重新执行与当前变更代码相关的单元测试、eslint或类型检查,无需全量执行
28+
29+
30+
31+

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"lerna:publish": "lerna publish from-package --yes",
1313
"docs:dev": "npm run dev -w docs-vitepress",
1414
"docs:build": "npm run build -w docs-vitepress",
15-
"docs:preview": "npm run preview -w docs-vitepress"
15+
"docs:preview": "npm run preview -w docs-vitepress",
16+
"test:debug": "jest packages/webpack-plugin/test/platform/wx/template/"
1617
},
1718
"devDependencies": {
1819
"@babel/core": "^7.25.2",

packages/core/package.json

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
"miniprogram-api-typings": "^3.10.0"
2525
},
2626
"peerDependencies": {
27-
"@d11/react-native-fast-image": "*",
2827
"@mpxjs/api-proxy": "^2.9.0",
29-
"@mpxjs/store": "^2.9.0",
28+
"@d11/react-native-fast-image": "*",
3029
"@react-navigation/native": "*",
3130
"@react-navigation/native-stack": "*",
3231
"react": "*",
@@ -38,22 +37,23 @@
3837
"react-native-screens": "*",
3938
"react-native-video": "*",
4039
"react-native-webview": "*",
40+
"react-native-vision-camera": "*",
4141
"vue": "^2.7.10",
4242
"vue-demi": "^0.14.6",
4343
"vue-i18n": "^8.27.2",
4444
"vue-i18n-bridge": "^9.2.2"
4545
},
4646
"peerDependenciesMeta": {
47-
"vue": {
47+
"@mpxjs/api-proxy": {
4848
"optional": true
4949
},
50-
"vue-demi": {
50+
"@d11/react-native-fast-image": {
5151
"optional": true
5252
},
53-
"vue-i18n": {
53+
"@react-navigation/native": {
5454
"optional": true
5555
},
56-
"vue-i18n-bridge": {
56+
"@react-navigation/native-stack": {
5757
"optional": true
5858
},
5959
"react": {
@@ -62,13 +62,13 @@
6262
"react-native": {
6363
"optional": true
6464
},
65-
"react-native-reanimated": {
65+
"react-native-gesture-handler": {
6666
"optional": true
6767
},
68-
"@react-navigation/native": {
68+
"react-native-linear-gradient": {
6969
"optional": true
7070
},
71-
"@react-navigation/native-stack": {
71+
"react-native-reanimated": {
7272
"optional": true
7373
},
7474
"react-native-safe-area-context": {
@@ -77,19 +77,25 @@
7777
"react-native-screens": {
7878
"optional": true
7979
},
80+
"react-native-video": {
81+
"optional": true
82+
},
8083
"react-native-webview": {
8184
"optional": true
8285
},
83-
"react-native-gesture-handler": {
86+
"react-native-vision-camera": {
8487
"optional": true
8588
},
86-
"react-native-linear-gradient": {
89+
"vue": {
8790
"optional": true
8891
},
89-
"@d11/react-native-fast-image": {
92+
"vue-demi": {
9093
"optional": true
9194
},
92-
"react-native-video": {
95+
"vue-i18n": {
96+
"optional": true
97+
},
98+
"vue-i18n-bridge": {
9399
"optional": true
94100
}
95101
},

packages/webpack-plugin/lib/platform/style/wx/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { parseValues } = require('../../../utils/string')
33

44
module.exports = function getSpec({ warn, error }) {
55
// React Native 双端都不支持的 CSS property
6-
const unsupportedPropExp = /^(white-space|text-overflow|animation|font-variant-caps|font-variant-numeric|font-variant-east-asian|font-variant-alternates|font-variant-ligatures|background-position|caret-color)$/
6+
const unsupportedPropExp = /^(white-space|text-overflow|animation|font-variant-caps|font-variant-numeric|font-variant-east-asian|font-variant-alternates|font-variant-ligatures|caret-color)$/
77
const unsupportedPropMode = {
88
// React Native ios 不支持的 CSS property
99
ios: /^(vertical-align)$/,

packages/webpack-plugin/lib/platform/template/wx/component-config/component.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/webpack-plugin/lib/platform/template/wx/component-config/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const view = require('./view')
3939
const webView = require('./web-view')
4040
const label = require('./label')
4141
const wxs = require('./wxs')
42-
const component = require('./component')
4342
const fixComponentName = require('./fix-component-name')
4443
const rootPortal = require('./root-portal')
4544
const stickyHeader = require('./sticky-header')
@@ -126,7 +125,6 @@ module.exports = function getComponentConfigs ({ warn, error }) {
126125
livePusher({ print }),
127126
hyphenTagName({ print }),
128127
label({ print }),
129-
component(),
130128
rootPortal({ print }),
131129
stickyHeader({ print }),
132130
stickySection({ print })

packages/webpack-plugin/lib/platform/template/wx/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ module.exports = function getSpec ({ warn, error }) {
119119
}
120120
}
121121
if (el) {
122-
const injectWxsProp = {
123-
injectWxsPath: '~' + normalize.lib('runtime/swanHelper.wxs'),
122+
const injectWxsInfo = {
123+
injectWxsRequest: '~' + normalize.lib('runtime/swanHelper.wxs'),
124124
injectWxsModuleName: 'mpxSwanHelper'
125125
}
126-
if (el.injectWxsProps && Array.isArray(el.injectWxsProps)) {
127-
el.injectWxsProps.push(injectWxsProp)
126+
if (el.injectWxsInfos && Array.isArray(el.injectWxsInfos)) {
127+
el.injectWxsInfos.push(injectWxsInfo)
128128
} else {
129-
el.injectWxsProps = [injectWxsProp]
129+
el.injectWxsInfos = [injectWxsInfo]
130130
}
131131
}
132132
return {

0 commit comments

Comments
 (0)