@mpxjs/core 2.9.69-beta.5 → 2.9.69-beta.8
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/package.json
CHANGED
package/src/core/mergeOptions.js
CHANGED
|
@@ -122,9 +122,10 @@ function extractObservers (options) {
|
|
|
122
122
|
Object.keys(props).forEach(key => {
|
|
123
123
|
const prop = props[key]
|
|
124
124
|
if (prop && prop.observer) {
|
|
125
|
+
let callback = prop.observer
|
|
126
|
+
delete prop.observer
|
|
125
127
|
mergeWatch(key, {
|
|
126
128
|
handler (...rest) {
|
|
127
|
-
let callback = prop.observer
|
|
128
129
|
if (typeof callback === 'string') {
|
|
129
130
|
callback = this[callback]
|
|
130
131
|
}
|
package/src/core/proxy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { reactive } from '../observer/reactive'
|
|
1
|
+
import { reactive, defineReactive } from '../observer/reactive'
|
|
2
2
|
import { ReactiveEffect, pauseTracking, resetTracking } from '../observer/effect'
|
|
3
3
|
import { effectScope } from '../platform/export/index'
|
|
4
4
|
import { watch } from '../observer/watch'
|
|
@@ -111,7 +111,7 @@ export default class MpxProxy {
|
|
|
111
111
|
this.uid = uid++
|
|
112
112
|
this.name = options.name || ''
|
|
113
113
|
this.options = options
|
|
114
|
-
this.
|
|
114
|
+
this.shallowReactivePattern = this.options.options?.shallowReactivePattern
|
|
115
115
|
// beforeCreate -> created -> mounted -> unmounted
|
|
116
116
|
this.state = BEFORECREATE
|
|
117
117
|
this.ignoreProxyMap = makeMap(Mpx.config.ignoreProxyWhiteList)
|
|
@@ -145,10 +145,12 @@ export default class MpxProxy {
|
|
|
145
145
|
this.initApi()
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
if (this.
|
|
148
|
+
processShallowReactive (obj) {
|
|
149
|
+
if (this.shallowReactivePattern && isObject(obj)) {
|
|
150
150
|
Object.keys(obj).forEach((key) => {
|
|
151
|
-
if (this.
|
|
151
|
+
if (this.shallowReactivePattern.test(key)) {
|
|
152
|
+
// 命中shallowReactivePattern的属性将其设置为 shallowReactive
|
|
153
|
+
defineReactive(obj, key, obj[key], true)
|
|
152
154
|
Object.defineProperty(obj, key, {
|
|
153
155
|
enumerable: true,
|
|
154
156
|
// set configurable to false to skip defineReactive
|
|
@@ -290,10 +292,10 @@ export default class MpxProxy {
|
|
|
290
292
|
if (isReact) {
|
|
291
293
|
// react模式下props内部对象透传无需深clone,依赖对象深层的数据响应触发子组件更新
|
|
292
294
|
this.props = this.target.__getProps()
|
|
293
|
-
reactive(this.
|
|
295
|
+
reactive(this.processShallowReactive(this.props))
|
|
294
296
|
} else {
|
|
295
297
|
this.props = diffAndCloneA(this.target.__getProps(this.options)).clone
|
|
296
|
-
reactive(this.
|
|
298
|
+
reactive(this.processShallowReactive(this.props))
|
|
297
299
|
}
|
|
298
300
|
proxy(this.target, this.props, undefined, false, this.createProxyConflictHandler('props'))
|
|
299
301
|
}
|
|
@@ -333,7 +335,7 @@ export default class MpxProxy {
|
|
|
333
335
|
if (isFunction(dataFn)) {
|
|
334
336
|
Object.assign(this.data, callWithErrorHandling(dataFn.bind(this.target), this, 'data function'))
|
|
335
337
|
}
|
|
336
|
-
reactive(this.
|
|
338
|
+
reactive(this.processShallowReactive(this.data))
|
|
337
339
|
proxy(this.target, this.data, undefined, false, this.createProxyConflictHandler('data'))
|
|
338
340
|
this.collectLocalKeys(this.data)
|
|
339
341
|
}
|
|
@@ -514,7 +516,7 @@ export default class MpxProxy {
|
|
|
514
516
|
if (hasOwn(renderData, key)) {
|
|
515
517
|
const data = renderData[key]
|
|
516
518
|
const firstKey = getFirstKey(key)
|
|
517
|
-
if (!this.localKeysMap[firstKey]
|
|
519
|
+
if (!this.localKeysMap[firstKey]) {
|
|
518
520
|
continue
|
|
519
521
|
}
|
|
520
522
|
// 外部clone,用于只需要clone的场景
|
|
@@ -178,18 +178,23 @@ export default function createApp (options) {
|
|
|
178
178
|
|
|
179
179
|
const { initialRouteName, initialParams } = initialRouteRef.current
|
|
180
180
|
const headerBackImageProps = Mpx.config.rnConfig.headerBackImageProps || null
|
|
181
|
+
const headerBackImageSource = Mpx.config.rnConfig.headerBackImageSource || null
|
|
181
182
|
const navScreenOpts = {
|
|
182
183
|
// 7.x替换headerBackTitleVisible
|
|
183
184
|
// headerBackButtonDisplayMode: 'minimal',
|
|
184
185
|
headerBackTitleVisible: false,
|
|
185
186
|
// 安卓上会出现初始化时闪现导航条的问题
|
|
186
|
-
headerShown: false
|
|
187
|
+
headerShown: false,
|
|
188
|
+
headerShadowVisible: false
|
|
187
189
|
}
|
|
188
190
|
if (headerBackImageProps) {
|
|
189
191
|
navScreenOpts.headerBackImage = () => {
|
|
190
192
|
return createElement(Image, headerBackImageProps)
|
|
191
193
|
}
|
|
192
194
|
}
|
|
195
|
+
if (headerBackImageSource) {
|
|
196
|
+
navScreenOpts.headerBackImageSource = headerBackImageSource
|
|
197
|
+
}
|
|
193
198
|
return createElement(SafeAreaProvider,
|
|
194
199
|
null,
|
|
195
200
|
createElement(NavigationContainer,
|
|
@@ -491,7 +491,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
if (type === 'page') {
|
|
494
|
-
const { Provider, useSafeAreaInsets, GestureHandlerRootView } = global.__navigationHelper
|
|
494
|
+
const { Provider, useSafeAreaInsets, GestureHandlerRootView, useHeaderHeight } = global.__navigationHelper
|
|
495
495
|
const pageConfig = Object.assign({}, global.__mpxPageConfig, currentInject.pageConfig)
|
|
496
496
|
const Page = ({ navigation, route }) => {
|
|
497
497
|
const [enabled, setEnabled] = useState(false)
|
|
@@ -530,17 +530,13 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
530
530
|
}, [])
|
|
531
531
|
|
|
532
532
|
const rootRef = useRef(null)
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
}, 200)
|
|
541
|
-
});
|
|
542
|
-
return unsubscribe;
|
|
543
|
-
}, [navigation]);
|
|
533
|
+
const onLayout = useCallback(() => {
|
|
534
|
+
setTimeout(() => {
|
|
535
|
+
rootRef.current?.measureInWindow((x, y, width, height) => {
|
|
536
|
+
navigation.layout = { x, y, width, height }
|
|
537
|
+
})
|
|
538
|
+
}, 200)
|
|
539
|
+
}, [])
|
|
544
540
|
|
|
545
541
|
const withKeyboardAvoidingView = (element) => {
|
|
546
542
|
if (__mpx_mode__ === 'ios') {
|
|
@@ -575,10 +571,12 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
575
571
|
if (setStateRef.current !== setState) {
|
|
576
572
|
setStateRef.current = setState
|
|
577
573
|
}
|
|
578
|
-
|
|
579
574
|
return createElement(GestureHandlerRootView,
|
|
580
575
|
{
|
|
581
|
-
|
|
576
|
+
// https://github.com/software-mansion/react-native-reanimated/issues/6639 因存在此问题,iOS在页面上进行定宽来暂时规避
|
|
577
|
+
style: __mpx_mode__ === 'ios' && pageConfig.navigationStyle !== 'custom' ? {
|
|
578
|
+
height: ReactNative.Dimensions.get('screen').height - useHeaderHeight()
|
|
579
|
+
} : {
|
|
582
580
|
flex: 1
|
|
583
581
|
}
|
|
584
582
|
},
|
|
@@ -589,7 +587,8 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
589
587
|
flex: 1,
|
|
590
588
|
backgroundColor: pageConfig.backgroundColor || '#ffffff'
|
|
591
589
|
},
|
|
592
|
-
ref: rootRef
|
|
590
|
+
ref: rootRef,
|
|
591
|
+
onLayout
|
|
593
592
|
},
|
|
594
593
|
createElement(RouteContext.Provider,
|
|
595
594
|
{
|
|
@@ -23,13 +23,11 @@ function transformProperties (properties) {
|
|
|
23
23
|
} else {
|
|
24
24
|
newFiled = Object.assign({}, rawFiled)
|
|
25
25
|
}
|
|
26
|
-
const rawObserver = rawFiled?.observer
|
|
27
26
|
newFiled.observer = function (value, oldValue) {
|
|
28
27
|
if (this.__mpxProxy) {
|
|
29
28
|
this[key] = value
|
|
30
29
|
this.__mpxProxy.propsUpdated()
|
|
31
30
|
}
|
|
32
|
-
rawObserver && rawObserver.call(this, value, oldValue)
|
|
33
31
|
}
|
|
34
32
|
newProps[key] = newFiled
|
|
35
33
|
})
|