@mpxjs/core 2.10.20 → 2.10.21
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/@types/index.d.ts
CHANGED
|
@@ -279,6 +279,14 @@ export interface WebviewConfig {
|
|
|
279
279
|
* 输出为 ReactNative 时使用的特殊配置,用于与容器进行功能桥接
|
|
280
280
|
*/
|
|
281
281
|
export interface RnConfig {
|
|
282
|
+
/**
|
|
283
|
+
* RN 节点未显式声明 box-sizing 时使用的默认盒模型。
|
|
284
|
+
*
|
|
285
|
+
* 默认值为 content-box,用于对齐小程序 / Web 的默认行为。
|
|
286
|
+
* 如需保留 RN 原始默认盒模型,可配置为 border-box。
|
|
287
|
+
*/
|
|
288
|
+
defaultBoxSizing?: 'border-box' | 'content-box'
|
|
289
|
+
|
|
282
290
|
/**
|
|
283
291
|
* 当导航状态发生变化时触发,例如页面跳转、返回等。
|
|
284
292
|
*
|
|
@@ -312,6 +320,13 @@ export interface RnConfig {
|
|
|
312
320
|
*/
|
|
313
321
|
disableAppStateListener?: boolean
|
|
314
322
|
|
|
323
|
+
/**
|
|
324
|
+
* RN 文本类组件是否允许跟随系统字体缩放。
|
|
325
|
+
*
|
|
326
|
+
* @default false
|
|
327
|
+
*/
|
|
328
|
+
allowFontScaling?: boolean
|
|
329
|
+
|
|
315
330
|
/**
|
|
316
331
|
* 控制首页回退按钮是否展示,并监听点击事件。
|
|
317
332
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.21",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -19,13 +19,15 @@
|
|
|
19
19
|
],
|
|
20
20
|
"main": "src/index.js",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@mpxjs/
|
|
22
|
+
"@mpxjs/perf": "^2.10.21",
|
|
23
|
+
"@mpxjs/utils": "^2.10.21",
|
|
23
24
|
"lodash": "^4.1.1",
|
|
24
25
|
"miniprogram-api-typings": "^3.10.0"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"@d11/react-native-fast-image": "*",
|
|
28
|
-
"@mpxjs/api-proxy": "
|
|
29
|
+
"@mpxjs/api-proxy": "*",
|
|
30
|
+
"@mpxjs/store": "*",
|
|
29
31
|
"@react-navigation/native": "*",
|
|
30
32
|
"@react-navigation/native-stack": "*",
|
|
31
33
|
"react": "*",
|
|
@@ -44,9 +46,6 @@
|
|
|
44
46
|
"vue-i18n-bridge": "^9.2.2"
|
|
45
47
|
},
|
|
46
48
|
"peerDependenciesMeta": {
|
|
47
|
-
"@mpxjs/api-proxy": {
|
|
48
|
-
"optional": true
|
|
49
|
-
},
|
|
50
49
|
"@d11/react-native-fast-image": {
|
|
51
50
|
"optional": true
|
|
52
51
|
},
|
|
@@ -119,5 +118,5 @@
|
|
|
119
118
|
"url": "https://github.com/didi/mpx/issues"
|
|
120
119
|
},
|
|
121
120
|
"sideEffects": false,
|
|
122
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "a2cbdad9f8dcc376f2098d217485525953b64cd9"
|
|
123
122
|
}
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isObject, isArray, dash2hump, cached, isEmptyObject, hasOwn, getFocusedNavigation } from '@mpxjs/utils'
|
|
2
|
+
import * as perf from '@mpxjs/perf'
|
|
2
3
|
import { StyleSheet, Dimensions } from 'react-native'
|
|
3
4
|
import { reactive } from '../../observer/reactive'
|
|
4
5
|
import Mpx from '../../index'
|
|
@@ -81,12 +82,12 @@ const empty = {}
|
|
|
81
82
|
|
|
82
83
|
function formatValue (value, unitType) {
|
|
83
84
|
if (!dimensionsInfoInitialized) useDimensionsInfo(global.__mpxAppDimensionsInfo)
|
|
84
|
-
if (unitType === 'hairlineWidth') {
|
|
85
|
-
return StyleSheet.hairlineWidth
|
|
86
|
-
}
|
|
87
85
|
if (unitType && typeof unit[unitType] === 'function') {
|
|
88
86
|
return unit[unitType](+value)
|
|
89
87
|
}
|
|
88
|
+
if (value === 'hairlineWidth') {
|
|
89
|
+
return StyleSheet.hairlineWidth
|
|
90
|
+
}
|
|
90
91
|
const matched = unitRegExp.exec(value)
|
|
91
92
|
if (matched) {
|
|
92
93
|
if (!matched[2] || matched[2] === 'px') {
|
|
@@ -95,7 +96,6 @@ function formatValue (value, unitType) {
|
|
|
95
96
|
return unit[matched[2]](+matched[1])
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
|
-
if (hairlineRegExp.test(value)) return StyleSheet.hairlineWidth
|
|
99
99
|
return value
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -171,7 +171,6 @@ function stringifyDynamicClass (value) {
|
|
|
171
171
|
const listDelimiter = /;(?![^(]*[)])/g
|
|
172
172
|
const propertyDelimiter = /:(.+)/
|
|
173
173
|
const unitRegExp = /^\s*(-?\d+(?:\.\d+)?)(rpx|vw|vh|px)?\s*$/
|
|
174
|
-
const hairlineRegExp = /^\s*hairlineWidth\s*$/
|
|
175
174
|
const varRegExp = /^--/
|
|
176
175
|
|
|
177
176
|
const parseStyleText = cached((cssText) => {
|
|
@@ -254,6 +253,9 @@ export default function styleHelperMixin () {
|
|
|
254
253
|
return concat(staticClass, stringifyDynamicClass(dynamicClass))
|
|
255
254
|
},
|
|
256
255
|
__getStyle (staticClass, dynamicClass, staticStyle, dynamicStyle, hide) {
|
|
256
|
+
let stopTotal
|
|
257
|
+
if (__mpx_perf_framework__) stopTotal = perf.scope('getStyle:total')
|
|
258
|
+
|
|
257
259
|
const isNativeStaticStyle = staticStyle && isNativeStyle(staticStyle)
|
|
258
260
|
let result = isNativeStaticStyle ? [] : {}
|
|
259
261
|
const mergeResult = isNativeStaticStyle ? (...args) => result.push(...args) : (...args) => Object.assign(result, ...args)
|
|
@@ -261,6 +263,8 @@ export default function styleHelperMixin () {
|
|
|
261
263
|
this.__getSizeCount()
|
|
262
264
|
|
|
263
265
|
if (staticClass || dynamicClass) {
|
|
266
|
+
let stopClass
|
|
267
|
+
if (__mpx_perf_framework__) stopClass = perf.scope('getStyle:class')
|
|
264
268
|
// todo 当前为了复用小程序unocss产物,暂时进行mpEscape,等后续正式支持unocss后可不进行mpEscape
|
|
265
269
|
const classString = mpEscape(concat(staticClass, stringifyDynamicClass(dynamicClass)))
|
|
266
270
|
|
|
@@ -283,9 +287,12 @@ export default function styleHelperMixin () {
|
|
|
283
287
|
mergeResult(this.__props[className])
|
|
284
288
|
}
|
|
285
289
|
})
|
|
290
|
+
if (__mpx_perf_framework__) stopClass()
|
|
286
291
|
}
|
|
287
292
|
|
|
288
293
|
if (staticStyle || dynamicStyle) {
|
|
294
|
+
let stopStyle
|
|
295
|
+
if (__mpx_perf_framework__) stopStyle = perf.scope('getStyle:style')
|
|
289
296
|
const styleObj = {}
|
|
290
297
|
if (isNativeStaticStyle) {
|
|
291
298
|
if (Array.isArray(staticStyle)) {
|
|
@@ -298,6 +305,7 @@ export default function styleHelperMixin () {
|
|
|
298
305
|
}
|
|
299
306
|
Object.assign(styleObj, normalizeDynamicStyle(dynamicStyle))
|
|
300
307
|
mergeResult(transformStyleObj(styleObj))
|
|
308
|
+
if (__mpx_perf_framework__) stopStyle()
|
|
301
309
|
}
|
|
302
310
|
|
|
303
311
|
if (hide) {
|
|
@@ -319,6 +327,7 @@ export default function styleHelperMixin () {
|
|
|
319
327
|
})
|
|
320
328
|
}
|
|
321
329
|
const isEmpty = isNativeStaticStyle ? !result.length : isEmptyObject(result)
|
|
330
|
+
if (__mpx_perf_framework__) stopTotal()
|
|
322
331
|
return isEmpty ? empty : result
|
|
323
332
|
}
|
|
324
333
|
}
|