Skip to content

Commit c7777ff

Browse files
committed
Merge branch 'master' of https://github.com/didi/mpx
2 parents 68ae36d + ecc4d4a commit c7777ff

File tree

14 files changed

+290
-40
lines changed

14 files changed

+290
-40
lines changed

docs-vitepress/guide/rn/style.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,10 @@ transform: scale(1.2) skewX(10deg);
13691369
/* RN 数组格式,仅 rn 支持 */
13701370
transform: [{translateX: 50}, {rotate: '45deg'}];
13711371
```
1372+
> [!tip] 注意
1373+
>
1374+
> 1.RN transform 不支持 scaleZ/scale3d/translateZ/translate3d/rotate3d/matrix3d
1375+
> 2.skew/skewX/skewY 在 RN Android 上不生效
13721376

13731377
### transform-origin
13741378

packages/core/src/platform/builtInMixins/pageStatusMixin.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { CREATED, ONLOAD, ONSHOW, ONHIDE, ONRESIZE } from '../../core/innerLifecycle'
2+
import { isObject } from '@mpxjs/utils'
23

34
export default function pageStatusMixin (mixinType) {
45
if (mixinType === 'page') {
@@ -13,7 +14,18 @@ export default function pageStatusMixin (mixinType) {
1314
this.__mpxProxy.callHook(ONRESIZE, [e])
1415
},
1516
onLoad (query) {
16-
this.__mpxProxy.callHook(ONLOAD, [query])
17+
if (__mpx_mode__ === 'wx') {
18+
const loadParams = {}
19+
// 此处单独处理微信与其他端保持一致,传入onload的参数都是经过decodeURIComponent处理过的
20+
if (isObject(query)) {
21+
for (const key in query) {
22+
loadParams[key] = decodeURIComponent(query[key])
23+
}
24+
}
25+
this.__mpxProxy.callHook(ONLOAD, [loadParams])
26+
} else {
27+
this.__mpxProxy.callHook(ONLOAD, [query])
28+
}
1729
}
1830
}
1931
if (__mpx_mode__ === 'ali') {

packages/core/src/platform/builtInMixins/styleHelperMixin.ios.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ global.__mpxAppDimensionsInfo = {
1010
global.__mpxSizeCount = 0
1111
global.__mpxPageSizeCountMap = reactive({})
1212

13-
global.__classCaches = []
1413
global.__GCC = function (className, classMap, classMapValueCache) {
1514
if (!classMapValueCache.has(className)) {
1615
const styleObj = classMap[className]?.()

packages/core/src/platform/createApp.ios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import transferOptions from '../core/transferOptions'
22
import builtInKeysMap from './patch/builtInKeysMap'
3-
import { makeMap, spreadProp, getFocusedNavigation, hasOwn } from '@mpxjs/utils'
3+
import { makeMap, spreadProp, getFocusedNavigation, hasOwn, callWithErrorHandling } from '@mpxjs/utils'
44
import { mergeLifecycle } from '../convertor/mergeLifecycle'
55
import { LIFECYCLE } from '../platform/patch/lifecycle/index'
66
import Mpx from '../index'
@@ -70,7 +70,7 @@ export default function createApp (options) {
7070
)
7171
}
7272
const getComponent = () => {
73-
return item.displayName ? item : item()
73+
return item.displayName ? item : callWithErrorHandling(item, null, 'require page script')
7474
}
7575
if (key === initialRouteName) {
7676
return createElement(Stack.Screen, {

packages/core/src/platform/patch/getDefaultOptions.ios.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,7 @@ function createInstance ({ propsRef, type, rawOptions, currentInject, validProps
314314

315315
if (type === 'page') {
316316
const props = propsRef.current
317-
const loadParams = {}
318-
// 此处拿到的props.route.params内属性的value被进行过了一次decode, 不符合预期,此处额外进行一次encode来与微信对齐
319-
if (isObject(props.route.params)) {
320-
for (const key in props.route.params) {
321-
loadParams[key] = encodeURIComponent(props.route.params[key])
322-
}
323-
}
324-
proxy.callHook(ONLOAD, [loadParams])
317+
proxy.callHook(ONLOAD, [props.route.params || {}])
325318
}
326319

327320
Object.assign(proxy, {

packages/webpack-plugin/lib/react/LoadAsyncChunkModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class LoadAsyncChunkRuntimeModule extends HelperRuntimeModule {
5454
]),
5555
'}',
5656
`var timeout = setTimeout(callback.bind(null, 'timeout'), ${this.timeout})`,
57-
'var loadChunkAsyncFn = global.__mpx.config.rnConfig && global.__mpx.config.rnConfig.loadChunkAsync',
57+
`var loadChunkAsyncFn = ${RuntimeGlobals.global}.__mpx.config.rnConfig && ${RuntimeGlobals.global}.__mpx.config.rnConfig.loadChunkAsync`,
5858
'try {',
5959
Template.indent([
6060
'loadChunkAsyncFn(config).then(callback).catch(callback)'

packages/webpack-plugin/lib/react/processStyles.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module.exports = function (styles, {
6464
}, '')
6565
if (ctorType === 'app') {
6666
output += `
67+
global.__classCaches = global.__classCaches || []
6768
const __classCache = new Map()
6869
global.__classCaches.push(__classCache)
6970
let __appClassMap
@@ -75,6 +76,7 @@ module.exports = function (styles, {
7576
};\n`
7677
} else {
7778
output += `
79+
global.__classCaches = global.__classCaches || []
7880
const __classCache = new Map()
7981
global.__classCaches.push(__classCache)
8082
let __classMap

packages/webpack-plugin/lib/react/style-helper.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ const hairlineRegExp = /^\s*hairlineWidth\s*$/
99
const varRegExp = /^--/
1010
const cssPrefixExp = /^-(webkit|moz|ms|o)-/
1111
function getClassMap ({ content, filename, mode, srcMode, ctorType, warn, error }) {
12-
const classMap = ctorType === 'page' ? { [MPX_TAG_PAGE_SELECTOR]: { flex: 1 } } : {}
12+
const classMap = ctorType === 'page'
13+
? {
14+
[MPX_TAG_PAGE_SELECTOR]: {
15+
_media: [],
16+
_default: { flex: 1, height: "'100%'" }
17+
}
18+
}
19+
: {}
1320

1421
const root = postcss.parse(content, {
1522
from: filename

packages/webpack-plugin/lib/runtime/components/react/mpx-input.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ export interface InputProps {
9595
'selection-start'?: number
9696
'selection-end'?: number
9797
'placeholder-style'?: { color?: string }
98-
'enable-offset'?: boolean,
98+
'enable-offset'?: boolean
9999
'enable-var'?: boolean
100100
'external-var-context'?: Record<string, any>
101101
'parent-font-size'?: number
102102
'parent-width'?: number
103103
'parent-height'?: number
104-
'adjust-position': boolean,
104+
// 只有 RN 环境读取
105+
'keyboard-type'?: string
106+
'adjust-position': boolean
105107
'hold-keyboard'?: boolean
106108
bindinput?: (evt: NativeSyntheticEvent<TextInputTextInputEventData> | unknown) => void
107109
bindfocus?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
@@ -119,11 +121,11 @@ export interface PrivateInputProps {
119121

120122
type FinalInputProps = InputProps & PrivateInputProps
121123

122-
const keyboardTypeMap: Record<Type, string> = {
123-
text: 'default',
124+
const inputModeMap: Record<Type, string> = {
125+
text: 'text',
124126
number: 'numeric',
125-
idcard: 'default',
126-
digit: isIOS ? 'decimal-pad' : 'numeric'
127+
idcard: 'text',
128+
digit: 'decimal'
127129
}
128130

129131
const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps>((props: FinalInputProps, ref): JSX.Element => {
@@ -151,6 +153,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
151153
'parent-width': parentWidth,
152154
'parent-height': parentHeight,
153155
'adjust-position': adjustPosition = true,
156+
'keyboard-type': originalKeyboardType,
154157
'hold-keyboard': holdKeyboard = false,
155158
bindinput,
156159
bindfocus,
@@ -184,7 +187,6 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
184187
return ''
185188
}
186189

187-
const keyboardType = keyboardTypeMap[type]
188190
const defaultValue = parseValue(value)
189191
const textAlignVertical = multiline ? 'top' : 'auto'
190192

@@ -465,7 +467,8 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
465467
ref: nodeRef,
466468
style: extendObject({}, normalStyle, layoutStyle),
467469
allowFontScaling,
468-
keyboardType: keyboardType,
470+
inputMode: originalKeyboardType ? undefined : inputModeMap[type],
471+
keyboardType: originalKeyboardType,
469472
secureTextEntry: !!password,
470473
defaultValue: defaultValue,
471474
value: inputValue,

packages/webpack-plugin/lib/runtime/components/react/mpx-portal/portal-manager.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const _PortalManager = forwardRef((props: PortalManagerProps, ref:ForwardedRef<u
1919
setState((prevState) => ({
2020
portals: [...prevState.portals, { key, children }]
2121
}))
22-
}, [state])
22+
}, [])
2323

2424
const update = useCallback((key: number, children: ReactNode) => {
2525
setState((prevState) => ({
@@ -30,7 +30,7 @@ const _PortalManager = forwardRef((props: PortalManagerProps, ref:ForwardedRef<u
3030
return item
3131
})
3232
}))
33-
}, [state])
33+
}, [])
3434

3535
const unmount = useCallback((key: number) => {
3636
setState((prevState) => ({

0 commit comments

Comments
 (0)