@mpxjs/core 2.9.64 → 2.9.65
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
|
@@ -114,7 +114,7 @@ interface Context {
|
|
|
114
114
|
refs: ObjectOf<WechatMiniprogram.NodesRef & ComponentIns<{}, {}, {}, {}, []>>
|
|
115
115
|
asyncRefs: ObjectOf<Promise<WechatMiniprogram.NodesRef & ComponentIns<{}, {}, {}, {}, []>>>
|
|
116
116
|
|
|
117
|
-
forceUpdate (params?: object, callback?: () => void): void
|
|
117
|
+
forceUpdate (params?: object, options?: object | (() => void), callback?: () => void): void
|
|
118
118
|
|
|
119
119
|
selectComponent: ReplaceWxComponentIns['selectComponent']
|
|
120
120
|
selectAllComponents: ReplaceWxComponentIns['selectAllComponents']
|
|
@@ -183,7 +183,7 @@ export interface MpxComponentIns {
|
|
|
183
183
|
|
|
184
184
|
$watch (expr: string | (() => any), handler: WatchHandler | WatchOptWithHandler, options?: WatchOpt): () => void
|
|
185
185
|
|
|
186
|
-
$forceUpdate (params?: object, callback?: () => void): void
|
|
186
|
+
$forceUpdate (params?: object, options?: object | (() => void), callback?: () => void): void
|
|
187
187
|
|
|
188
188
|
$nextTick (fn: () => void): void
|
|
189
189
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.65",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"main": "src/index.js",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@mpxjs/utils": "^2.9.
|
|
22
|
+
"@mpxjs/utils": "^2.9.65",
|
|
23
23
|
"lodash": "^4.1.1",
|
|
24
24
|
"miniprogram-api-typings": "^3.10.0"
|
|
25
25
|
},
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"react": "*",
|
|
33
33
|
"react-native": "*",
|
|
34
34
|
"react-native-gesture-handler": "^2.19.0",
|
|
35
|
+
"react-native-linear-gradient": "^2.8.3",
|
|
35
36
|
"react-native-safe-area-context": "^4.10.1",
|
|
36
37
|
"react-native-webview": "^13.10.5",
|
|
37
38
|
"vue": "^2.7.10",
|
|
@@ -75,6 +76,9 @@
|
|
|
75
76
|
},
|
|
76
77
|
"react-native-gesture-handler": {
|
|
77
78
|
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"react-native-linear-gradient": {
|
|
81
|
+
"optional": true
|
|
78
82
|
}
|
|
79
83
|
},
|
|
80
84
|
"publishConfig": {
|
|
@@ -93,5 +97,5 @@
|
|
|
93
97
|
"url": "https://github.com/didi/mpx/issues"
|
|
94
98
|
},
|
|
95
99
|
"sideEffects": false,
|
|
96
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "24efa90e90b4d42c285ca61739cb9e4d0696976c"
|
|
97
101
|
}
|
|
@@ -14,23 +14,21 @@ function refreshMs () {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
let loading = null
|
|
18
|
-
|
|
19
17
|
function showLoading (vm) {
|
|
20
18
|
const { backgroundColor = 'transparent', backgroundTextStyle = 'dark' } = vm.$options.__mpxPageConfig
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
vm.__mpxloading = document.createElement('div')
|
|
20
|
+
vm.__mpxloading.className = 'pull-down-loading'
|
|
21
|
+
vm.__mpxloading.style.cssText = `background-color: ${backgroundColor};`
|
|
24
22
|
const dot = document.createElement('div')
|
|
25
23
|
dot.className = `dot-flashing ${backgroundTextStyle}`
|
|
26
|
-
|
|
27
|
-
vm.$el.prepend(
|
|
24
|
+
vm.__mpxloading.append(dot)
|
|
25
|
+
vm.$el.prepend(vm.__mpxloading)
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
function hideLoading (vm) {
|
|
31
|
-
if (
|
|
32
|
-
vm.$el.removeChild(
|
|
33
|
-
|
|
29
|
+
if (vm.__mpxloading) {
|
|
30
|
+
vm.$el.removeChild(vm.__mpxloading)
|
|
31
|
+
vm.__mpxloading = null
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
|
|
@@ -16,12 +16,25 @@ function vh (value) {
|
|
|
16
16
|
return value * height / 100
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const unit = {
|
|
20
20
|
rpx,
|
|
21
21
|
vw,
|
|
22
22
|
vh
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
function formatValue (value) {
|
|
26
|
+
let matched
|
|
27
|
+
if ((matched = numberRegExp.exec(value))) {
|
|
28
|
+
value = +matched[1]
|
|
29
|
+
} else if ((matched = unitRegExp.exec(value))) {
|
|
30
|
+
value = unit[matched[2]](+matched[1])
|
|
31
|
+
} else if (hairlineRegExp.test(value)) {
|
|
32
|
+
value = StyleSheet.hairlineWidth
|
|
33
|
+
}
|
|
34
|
+
return value
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
global.__formatValue = formatValue
|
|
25
38
|
|
|
26
39
|
const escapeReg = /[()[\]{}#!.:,%'"+$]/g
|
|
27
40
|
const escapeMap = {
|
|
@@ -97,7 +110,8 @@ const numberRegExp = /^\s*(-?\d+(\.\d+)?)(px)?\s*$/
|
|
|
97
110
|
const hairlineRegExp = /^\s*hairlineWidth\s*$/
|
|
98
111
|
const varRegExp = /^--/
|
|
99
112
|
|
|
100
|
-
const parseStyleText = cached((cssText
|
|
113
|
+
const parseStyleText = cached((cssText) => {
|
|
114
|
+
if (typeof cssText !== 'string') return cssText
|
|
101
115
|
const res = {}
|
|
102
116
|
const arr = cssText.split(listDelimiter)
|
|
103
117
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -134,19 +148,9 @@ function mergeObjectArray (arr) {
|
|
|
134
148
|
}
|
|
135
149
|
|
|
136
150
|
function transformStyleObj (styleObj) {
|
|
137
|
-
const keys = Object.keys(styleObj)
|
|
138
151
|
const transformed = {}
|
|
139
|
-
keys.forEach((prop) => {
|
|
140
|
-
|
|
141
|
-
let matched
|
|
142
|
-
if ((matched = numberRegExp.exec(value))) {
|
|
143
|
-
value = +matched[1]
|
|
144
|
-
} else if ((matched = unitRegExp.exec(value))) {
|
|
145
|
-
value = global.__unit[matched[2]](+matched[1])
|
|
146
|
-
} else if (hairlineRegExp.test(value)) {
|
|
147
|
-
value = StyleSheet.hairlineWidth
|
|
148
|
-
}
|
|
149
|
-
transformed[prop] = value
|
|
152
|
+
Object.keys(styleObj).forEach((prop) => {
|
|
153
|
+
transformed[prop] = formatValue(styleObj[prop])
|
|
150
154
|
})
|
|
151
155
|
return transformed
|
|
152
156
|
}
|
|
@@ -40,13 +40,18 @@ function createEffect (proxy, components) {
|
|
|
40
40
|
}
|
|
41
41
|
update.id = proxy.uid
|
|
42
42
|
const getComponent = (tagName) => {
|
|
43
|
+
if (!tagName) return null
|
|
43
44
|
if (tagName === 'block') return Fragment
|
|
44
45
|
return components[tagName] || getByPath(ReactNative, tagName)
|
|
45
46
|
}
|
|
47
|
+
const innerCreateElement = (type, ...rest) => {
|
|
48
|
+
if (!type) return null
|
|
49
|
+
return createElement(type, ...rest)
|
|
50
|
+
}
|
|
46
51
|
proxy.effect = new ReactiveEffect(() => {
|
|
47
52
|
// reset instance
|
|
48
53
|
proxy.target.__resetInstance()
|
|
49
|
-
return proxy.target.__injectedRender(
|
|
54
|
+
return proxy.target.__injectedRender(innerCreateElement, getComponent)
|
|
50
55
|
}, () => queueJob(update), proxy.scope)
|
|
51
56
|
}
|
|
52
57
|
|
|
@@ -412,17 +417,37 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
412
417
|
const { Provider, useSafeAreaInsets, GestureHandlerRootView } = global.__navigationHelper
|
|
413
418
|
const pageConfig = Object.assign({}, global.__mpxPageConfig, currentInject.pageConfig)
|
|
414
419
|
const Page = ({ navigation, route }) => {
|
|
420
|
+
const rootRef = useRef(null)
|
|
415
421
|
const currentPageId = useMemo(() => ++pageId, [])
|
|
416
422
|
usePageStatus(navigation, currentPageId)
|
|
417
423
|
|
|
418
424
|
useLayoutEffect(() => {
|
|
425
|
+
rootRef.current?.measureInWindow((x, y, width, height) => {
|
|
426
|
+
navigation.layout = { x, y, width, height }
|
|
427
|
+
})
|
|
428
|
+
const isCustom = pageConfig.navigationStyle === 'custom'
|
|
429
|
+
let opt = {}
|
|
430
|
+
if (__mpx_mode__ === 'android') {
|
|
431
|
+
opt = {
|
|
432
|
+
statusBarTranslucent: isCustom,
|
|
433
|
+
statusBarStyle: pageConfig.statusBarStyle, // 枚举值 'auto' | 'dark' | 'light' 控制statusbar字体颜色
|
|
434
|
+
statusBarColor: isCustom ? 'transparent' : pageConfig.statusBarColor // 控制statusbar背景颜色
|
|
435
|
+
}
|
|
436
|
+
} else if (__mpx_mode__ === 'ios') {
|
|
437
|
+
opt = {
|
|
438
|
+
headerBackTitleVisible: false
|
|
439
|
+
}
|
|
440
|
+
}
|
|
419
441
|
navigation.setOptions({
|
|
420
|
-
headerShown:
|
|
442
|
+
headerShown: !isCustom,
|
|
443
|
+
headerShadowVisible: false,
|
|
421
444
|
headerTitle: pageConfig.navigationBarTitleText || '',
|
|
422
445
|
headerStyle: {
|
|
423
446
|
backgroundColor: pageConfig.navigationBarBackgroundColor || '#000000'
|
|
424
447
|
},
|
|
425
|
-
|
|
448
|
+
headerTitleAlign: 'center',
|
|
449
|
+
headerTintColor: pageConfig.navigationBarTextStyle || 'white',
|
|
450
|
+
...opt
|
|
426
451
|
})
|
|
427
452
|
}, [])
|
|
428
453
|
|
|
@@ -434,9 +459,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
434
459
|
flex: 1,
|
|
435
460
|
backgroundColor: pageConfig.backgroundColor || '#ffffff'
|
|
436
461
|
},
|
|
437
|
-
|
|
438
|
-
navigation.layout = e.nativeEvent.layout
|
|
439
|
-
}
|
|
462
|
+
ref: rootRef
|
|
440
463
|
},
|
|
441
464
|
// todo custom portal host for active route
|
|
442
465
|
createElement(Provider,
|