@mpxjs/core 2.9.69-beta.7 → 2.9.69-beta.9

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/core",
3
- "version": "2.9.69-beta.7",
3
+ "version": "2.9.69-beta.9",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -26,21 +26,31 @@ export default function getRefsMixin () {
26
26
  })
27
27
  })
28
28
  },
29
- __getRefVal (type, selectorsConf) {
30
- return (instance) => {
31
- if (instance) {
29
+ __getRefVal (type, selectorsConf, refFnId) {
30
+ const target = this
31
+ if (!this[refFnId]) {
32
+ this[refFnId] = function (instance) {
32
33
  selectorsConf.forEach((item = []) => {
33
34
  const [prefix, selectors = ''] = item
34
35
  if (selectors) {
35
36
  selectors.trim().split(/\s+/).forEach(selector => {
36
37
  const refKey = prefix + selector
37
- this.__refs[refKey] = this.__refs[refKey] || []
38
- this.__refs[refKey].push({ type, instance })
38
+ const refVal = { type, instance, refFnId }
39
+ target.__refs[refKey] = target.__refs[refKey] || []
40
+ if (instance) { // mount
41
+ target.__refs[refKey].push(refVal)
42
+ } else { // unmount
43
+ const index = target.__refs[refKey].findIndex(item => item.refFnId === refFnId)
44
+ if (index > -1) {
45
+ target.__refs[refKey].splice(index, 1)
46
+ }
47
+ }
39
48
  })
40
49
  }
41
50
  })
42
51
  }
43
52
  }
53
+ return this[refFnId]
44
54
  },
45
55
  __selectRef (selector, refType, all = false) {
46
56
  const splitedSelector = selector.match(/(#|\.)?[^.#]+/g) || []
@@ -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,
@@ -115,7 +115,6 @@ const instanceProto = {
115
115
  return createIntersectionObserver(this, opt, this.__intersectionCtx)
116
116
  },
117
117
  __resetInstance () {
118
- this.__refs = {}
119
118
  this.__dispatchedSlotSet = new WeakSet()
120
119
  },
121
120
  __iter (val, fn) {
@@ -491,7 +490,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
491
490
  }
492
491
 
493
492
  if (type === 'page') {
494
- const { Provider, useSafeAreaInsets, GestureHandlerRootView } = global.__navigationHelper
493
+ const { Provider, useSafeAreaInsets, GestureHandlerRootView, useHeaderHeight } = global.__navigationHelper
495
494
  const pageConfig = Object.assign({}, global.__mpxPageConfig, currentInject.pageConfig)
496
495
  const Page = ({ navigation, route }) => {
497
496
  const [enabled, setEnabled] = useState(false)
@@ -530,17 +529,13 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
530
529
  }, [])
531
530
 
532
531
  const rootRef = useRef(null)
533
-
534
- useEffect(() => {
535
- const unsubscribe = navigation.addListener('transitionEnd', (e) => {
536
- setTimeout(() => {
537
- rootRef.current?.measureInWindow((x, y, width, height) => {
538
- navigation.layout = { x, y, width, height }
539
- })
540
- }, 200)
541
- });
542
- return unsubscribe;
543
- }, [navigation]);
532
+ const onLayout = useCallback(() => {
533
+ setTimeout(() => {
534
+ rootRef.current?.measureInWindow((x, y, width, height) => {
535
+ navigation.layout = { x, y, width, height }
536
+ })
537
+ }, 200)
538
+ }, [])
544
539
 
545
540
  const withKeyboardAvoidingView = (element) => {
546
541
  if (__mpx_mode__ === 'ios') {
@@ -575,10 +570,12 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
575
570
  if (setStateRef.current !== setState) {
576
571
  setStateRef.current = setState
577
572
  }
578
-
579
573
  return createElement(GestureHandlerRootView,
580
574
  {
581
- style: {
575
+ // https://github.com/software-mansion/react-native-reanimated/issues/6639 因存在此问题,iOS在页面上进行定宽来暂时规避
576
+ style: __mpx_mode__ === 'ios' && pageConfig.navigationStyle !== 'custom' ? {
577
+ height: ReactNative.Dimensions.get('screen').height - useHeaderHeight()
578
+ } : {
582
579
  flex: 1
583
580
  }
584
581
  },
@@ -589,7 +586,8 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
589
586
  flex: 1,
590
587
  backgroundColor: pageConfig.backgroundColor || '#ffffff'
591
588
  },
592
- ref: rootRef
589
+ ref: rootRef,
590
+ onLayout
593
591
  },
594
592
  createElement(RouteContext.Provider,
595
593
  {