@mpxjs/core 2.9.17 → 2.9.23
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/README.md
CHANGED
|
@@ -1,4 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
[Mpx](https://mpxjs.cn), 一款具有优秀开发体验和深度性能优化的增强型跨端小程序框架。
|
|
2
|
+
欢迎访问[https://mpxjs.cn](https://mpxjs.cn),跟随我们提供的文档指南使用Mpx进行跨端小程序开发。
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
Mpx具有以下功能特性:
|
|
5
|
+
* [数据响应](https://www.mpxjs.cn/guide/basic/reactive.html) (赋值响应 / [watch](https://www.mpxjs.cn/api/global-api.html#watch) / computed)
|
|
6
|
+
* [组合式 API](https://mpxjs.cn/guide/composition-api/composition-api.html)
|
|
7
|
+
* 增强模板语法 ([动态组件](https://www.mpxjs.cn/guide/basic/component.html#%E5%8A%A8%E6%80%81%E7%BB%84%E4%BB%B6) / [样式绑定 / 类名绑定 ](https://www.mpxjs.cn/guide/basic/class-style-binding.html#%E7%B1%BB%E5%90%8D%E7%BB%91%E5%AE%9A) / [内联事件函数](https://www.mpxjs.cn/guide/basic/event.html) / [双向绑定](https://www.mpxjs.cn/guide/basic/two-way-binding.html) / [refs](https://www.mpxjs.cn/guide/basic/refs.html))
|
|
8
|
+
* 极致性能 ([运行时性能优化](https://www.mpxjs.cn/guide/understand/runtime.html) / [包体积优化](https://www.mpxjs.cn/guide/understand/compile.html#%E5%88%86%E5%8C%85%E5%A4%84%E7%90%86) / 框架运行时体积14KB)
|
|
9
|
+
* [高效强大的编译构建](https://www.mpxjs.cn/guide/understand/compile.html#%E5%88%86%E5%8C%85%E5%A4%84%E7%90%86) (基于webpack5 / 支持持久化缓存 / 兼容webpack生态 / 兼容原生小程序 / 完善支持npm场景下的分包输出 / 高效调试)
|
|
10
|
+
* [单文件组件开发](https://www.mpxjs.cn/guide/basic/single-file.html)
|
|
11
|
+
* [渐进接入 / 原生组件支持](https://www.mpxjs.cn/guide/advance/progressive.html)
|
|
12
|
+
* [状态管理](https://www.mpxjs.cn/guide/advance/store.html) (Vuex规范 / 支持多实例Store)
|
|
13
|
+
* 跨团队开发 ([packages](https://www.mpxjs.cn/guide/advance/subpackage.html))
|
|
14
|
+
* 逻辑复用 ([mixins](https://www.mpxjs.cn/guide/advance/mixin.html))
|
|
15
|
+
* [周边能力](https://www.mpxjs.cn/guide/extend/) (fetch / api增强 / mock / webview-bridge)
|
|
16
|
+
* 脚手架支持
|
|
17
|
+
* 多平台增强 (支持在微信、支付宝、百度、qq、头条小程序平台中进行增强开发)
|
|
18
|
+
* [跨平台编译](https://www.mpxjs.cn/guide/advance/platform.html) (一套代码跨端输出到微信、支付宝、百度、字节、QQ、京东、快应用(web) 和 [web平台](https://www.mpxjs.cn/guide/advance/platform.html#%E8%B7%A8%E5%B9%B3%E5%8F%B0%E8%BE%93%E5%87%BAweb) 中运行)
|
|
19
|
+
* [TypeScript支持](https://www.mpxjs.cn/guide/tool/ts.html) (基于ThisType实现了完善的类型推导)
|
|
20
|
+
* [I18n国际化](https://www.mpxjs.cn/guide/tool/i18n.html)
|
|
21
|
+
* [单元测试](https://www.mpxjs.cn/guide/tool/unit-test.html)
|
|
22
|
+
* [E2E测试](https://www.mpxjs.cn/guide/tool/e2e-test.html)
|
|
23
|
+
* [原子类](https://mpxjs.cn/guide/advance/utility-first-css.html)
|
|
24
|
+
* [SSR](https://mpxjs.cn/guide/advance/ssr.html)
|
|
25
|
+
* [组件维度运行时渲染方案](https://github.com/didi/mpx/pull/919) (即将到来)
|
|
26
|
+
## @mpxjs/core
|
|
4
27
|
|
|
28
|
+
Mpx 小程序框架运行时核心库。
|
|
29
|
+
|
|
30
|
+
## 快速开始
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# 安装mpx脚手架工具
|
|
34
|
+
npm i -g @mpxjs/cli
|
|
35
|
+
|
|
36
|
+
# 初始化项目
|
|
37
|
+
mpx create mpx-project
|
|
38
|
+
|
|
39
|
+
# 进入项目目录
|
|
40
|
+
cd mpx-project
|
|
41
|
+
|
|
42
|
+
# 安装依赖
|
|
43
|
+
npm i
|
|
44
|
+
|
|
45
|
+
# development
|
|
46
|
+
npm run serve
|
|
47
|
+
|
|
48
|
+
# production
|
|
49
|
+
npm run build
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
使用小程序开发者工具打开项目文件夹下dist中对应平台的文件夹即可预览效果。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.23",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"url": "https://github.com/didi/mpx/issues"
|
|
48
48
|
},
|
|
49
49
|
"sideEffects": false,
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "3ee08746928dedae1bb6c86e66c1aaf4f273c8d2"
|
|
51
51
|
}
|
|
@@ -18,6 +18,12 @@ export default function proxyEventMixin () {
|
|
|
18
18
|
const originValue = valuePath.reduce((acc, cur) => acc[cur], $event.detail)
|
|
19
19
|
const value = filterMethod ? (innerFilter[filterMethod] ? innerFilter[filterMethod](originValue) : typeof this[filterMethod] === 'function' && this[filterMethod]) : originValue
|
|
20
20
|
setByPath(this, expr, value)
|
|
21
|
+
},
|
|
22
|
+
__invokeHandler (eventName, $event) {
|
|
23
|
+
const handler = this[eventName]
|
|
24
|
+
if (handler && typeof handler === 'function') {
|
|
25
|
+
handler.call(this, $event)
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isObject } from '@mpxjs/utils'
|
|
2
|
-
import {
|
|
2
|
+
import { BEFORECREATE, MOUNTED, BEFOREUNMOUNT } from '../../core/innerLifecycle'
|
|
3
3
|
|
|
4
4
|
const targets = []
|
|
5
5
|
let curTarget = null
|
|
@@ -177,8 +177,9 @@ export default function relationsMixin (mixinType) {
|
|
|
177
177
|
}
|
|
178
178
|
} else if (__mpx_mode__ === 'web' && mixinType === 'component') {
|
|
179
179
|
return {
|
|
180
|
-
[
|
|
180
|
+
[BEFORECREATE] () {
|
|
181
181
|
this.__mpxRelations = {}
|
|
182
|
+
this.__mpxRelationNodesMap = {} // 用于getRelationNodes关系查询
|
|
182
183
|
},
|
|
183
184
|
[MOUNTED] () {
|
|
184
185
|
this.__mpxCollectRelations()
|
|
@@ -186,8 +187,14 @@ export default function relationsMixin (mixinType) {
|
|
|
186
187
|
},
|
|
187
188
|
[BEFOREUNMOUNT] () {
|
|
188
189
|
this.__mpxExecRelations('unlinked')
|
|
190
|
+
// 重置缓存数据
|
|
191
|
+
this.__mpxRelations = {}
|
|
192
|
+
this.__mpxRelationNodesMap = {}
|
|
189
193
|
},
|
|
190
194
|
methods: {
|
|
195
|
+
getRelationNodes (path) {
|
|
196
|
+
return this.__mpxRelationNodesMap[path] || null
|
|
197
|
+
},
|
|
191
198
|
__mpxCollectRelations () {
|
|
192
199
|
const relations = this.__mpxProxy.options.relations
|
|
193
200
|
if (!relations) return
|
|
@@ -221,6 +228,7 @@ export default function relationsMixin (mixinType) {
|
|
|
221
228
|
targetRelation,
|
|
222
229
|
relation
|
|
223
230
|
}
|
|
231
|
+
this.__mpxRelationNodesMap[path] = [target] // 子级绑定父级
|
|
224
232
|
} else if (type === 'ancestor') {
|
|
225
233
|
// 当前匹配失败,但type为ancestor时,继续向上查找
|
|
226
234
|
return this.__mpxCheckParent(target, relation, path)
|
|
@@ -230,6 +238,12 @@ export default function relationsMixin (mixinType) {
|
|
|
230
238
|
__mpxExecRelations (type) {
|
|
231
239
|
Object.keys(this.__mpxRelations).forEach(path => {
|
|
232
240
|
const { target, targetRelation, relation } = this.__mpxRelations[path]
|
|
241
|
+
const currentPath = this.$options.componentPath
|
|
242
|
+
if (type === 'linked') {
|
|
243
|
+
this.__mpxLinkRelationNodes(target, currentPath)
|
|
244
|
+
} else if (type === 'unlinked') {
|
|
245
|
+
this.__mpxRemoveRelationNodes(target, currentPath)
|
|
246
|
+
}
|
|
233
247
|
if (typeof targetRelation[type] === 'function') {
|
|
234
248
|
targetRelation[type].call(target, this)
|
|
235
249
|
}
|
|
@@ -237,6 +251,15 @@ export default function relationsMixin (mixinType) {
|
|
|
237
251
|
relation[type].call(this, target)
|
|
238
252
|
}
|
|
239
253
|
})
|
|
254
|
+
},
|
|
255
|
+
__mpxLinkRelationNodes (target, path) {
|
|
256
|
+
target.__mpxRelationNodesMap[path] = target.__mpxRelationNodesMap[path] || [] // 父级绑定子级
|
|
257
|
+
target.__mpxRelationNodesMap[path].push(this)
|
|
258
|
+
},
|
|
259
|
+
__mpxRemoveRelationNodes (target, path) {
|
|
260
|
+
const arr = target.__mpxRelationNodesMap[path] || []
|
|
261
|
+
const index = arr.indexOf(this)
|
|
262
|
+
if (index !== -1) arr.splice(index, 1)
|
|
240
263
|
}
|
|
241
264
|
}
|
|
242
265
|
}
|