@mpxjs/core 2.10.19 → 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
  *
@@ -373,7 +388,7 @@ export interface RnConfig {
373
388
  * @param params.package 分包名
374
389
  * @returns Promise,表示加载完成
375
390
  */
376
- loadChunkAsync?: (params: { url: string; package: string }) => Promise<any>
391
+ loadChunkAsync?: (params: { url: string; package: string }) => Promise<null>
377
392
 
378
393
  /**
379
394
  * 下载多个异步分包的方法(不执行)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/core",
3
- "version": "2.10.19",
3
+ "version": "2.10.21",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -19,14 +19,15 @@
19
19
  ],
20
20
  "main": "src/index.js",
21
21
  "dependencies": {
22
- "@mpxjs/utils": "^2.10.18",
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": "^2.9.0",
29
- "@mpxjs/store": "^2.9.0",
29
+ "@mpxjs/api-proxy": "*",
30
+ "@mpxjs/store": "*",
30
31
  "@react-navigation/native": "*",
31
32
  "@react-navigation/native-stack": "*",
32
33
  "react": "*",
@@ -37,6 +38,7 @@
37
38
  "react-native-safe-area-context": "*",
38
39
  "react-native-screens": "*",
39
40
  "react-native-video": "*",
41
+ "react-native-vision-camera": "*",
40
42
  "react-native-webview": "*",
41
43
  "vue": "^2.7.10",
42
44
  "vue-demi": "^0.14.6",
@@ -44,16 +46,13 @@
44
46
  "vue-i18n-bridge": "^9.2.2"
45
47
  },
46
48
  "peerDependenciesMeta": {
47
- "vue": {
48
- "optional": true
49
- },
50
- "vue-demi": {
49
+ "@d11/react-native-fast-image": {
51
50
  "optional": true
52
51
  },
53
- "vue-i18n": {
52
+ "@react-navigation/native": {
54
53
  "optional": true
55
54
  },
56
- "vue-i18n-bridge": {
55
+ "@react-navigation/native-stack": {
57
56
  "optional": true
58
57
  },
59
58
  "react": {
@@ -62,13 +61,13 @@
62
61
  "react-native": {
63
62
  "optional": true
64
63
  },
65
- "react-native-reanimated": {
64
+ "react-native-gesture-handler": {
66
65
  "optional": true
67
66
  },
68
- "@react-navigation/native": {
67
+ "react-native-linear-gradient": {
69
68
  "optional": true
70
69
  },
71
- "@react-navigation/native-stack": {
70
+ "react-native-reanimated": {
72
71
  "optional": true
73
72
  },
74
73
  "react-native-safe-area-context": {
@@ -77,19 +76,25 @@
77
76
  "react-native-screens": {
78
77
  "optional": true
79
78
  },
79
+ "react-native-video": {
80
+ "optional": true
81
+ },
80
82
  "react-native-webview": {
81
83
  "optional": true
82
84
  },
83
- "react-native-gesture-handler": {
85
+ "react-native-vision-camera": {
84
86
  "optional": true
85
87
  },
86
- "react-native-linear-gradient": {
88
+ "vue": {
87
89
  "optional": true
88
90
  },
89
- "@d11/react-native-fast-image": {
91
+ "vue-demi": {
90
92
  "optional": true
91
93
  },
92
- "react-native-video": {
94
+ "vue-i18n": {
95
+ "optional": true
96
+ },
97
+ "vue-i18n-bridge": {
93
98
  "optional": true
94
99
  }
95
100
  },
@@ -113,5 +118,5 @@
113
118
  "url": "https://github.com/didi/mpx/issues"
114
119
  },
115
120
  "sideEffects": false,
116
- "gitHead": "ca50ba6b1361f3c7790746476dd8b8e6be802ea3"
121
+ "gitHead": "a2cbdad9f8dcc376f2098d217485525953b64cd9"
117
122
  }
package/src/index.js CHANGED
@@ -154,7 +154,9 @@ Mpx.config = {
154
154
  /**
155
155
  * react-native 相关配置,用于挂载事件等,如 onShareAppMessage
156
156
  */
157
- rnConfig: {}
157
+ rnConfig: {
158
+ defaultBoxSizing: 'content-box'
159
+ }
158
160
  }
159
161
 
160
162
  init(Mpx)
@@ -19,7 +19,11 @@ export default function pageStatusMixin (mixinType) {
19
19
  // 处理以上平台直接透传encode的结果,给到onload第二个参数供开发者使用
20
20
  if (isObject(rawQuery)) {
21
21
  for (const key in rawQuery) {
22
- decodedQuery[key] = decodeURIComponent(rawQuery[key])
22
+ try {
23
+ decodedQuery[key] = decodeURIComponent(rawQuery[key])
24
+ } catch (e) {
25
+ decodedQuery[key] = rawQuery[key]
26
+ }
23
27
  }
24
28
  }
25
29
  this.__mpxProxy.callHook(ONLOAD, [rawQuery, decodedQuery])
@@ -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
 
@@ -268,13 +272,13 @@ export default function styleHelperMixin () {
268
272
  let localStyle, appStyle
269
273
  if (localStyle = this.__getClassStyle?.(className)) {
270
274
  if (localStyle._media?.length) {
271
- mergeResult(localStyle._default, getMediaStyle(localStyle._media))
275
+ mergeResult(localStyle, getMediaStyle(localStyle._media))
272
276
  } else {
273
277
  mergeResult(localStyle)
274
278
  }
275
279
  } else if (appStyle = global.__getAppClassStyle?.(className)) {
276
280
  if (appStyle._media?.length) {
277
- mergeResult(appStyle._default, getMediaStyle(appStyle._media))
281
+ mergeResult(appStyle, getMediaStyle(appStyle._media))
278
282
  } else {
279
283
  mergeResult(appStyle)
280
284
  }
@@ -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
  }
@@ -318,7 +318,11 @@ function createInstance ({ propsRef, type, rawOptions, currentInject, validProps
318
318
  const rawQuery = props.route.params || {}
319
319
  if (isObject(rawQuery)) {
320
320
  for (const key in rawQuery) {
321
- decodedQuery[key] = decodeURIComponent(rawQuery[key])
321
+ try {
322
+ decodedQuery[key] = decodeURIComponent(rawQuery[key])
323
+ } catch (e) {
324
+ decodedQuery[key] = rawQuery[key]
325
+ }
322
326
  }
323
327
  }
324
328
  proxy.callHook(ONLOAD, [rawQuery, decodedQuery])