@mpxjs/core 2.10.16-beta.8 → 2.10.17-beta.1
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/global.d.ts +1 -1
- package/@types/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/convertor/convertor.js +1 -3
- package/src/convertor/getConvertMode.js +1 -2
- package/src/core/proxy.js +7 -7
- package/src/platform/builtInMixins/renderHelperMixin.js +4 -4
- package/src/platform/createApp.ios.js +5 -2
- package/src/platform/patch/getDefaultOptions.ios.js +12 -8
- package/src/convertor/wxToKs.js +0 -21
package/@types/global.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// declaration for mpx mode
|
|
2
|
-
declare let __mpx_mode__: 'wx' | 'ali' | 'swan' | 'qq' | 'tt' | 'web' | 'dd' | 'qa' | 'jd' | 'android' | 'ios' | 'harmony'
|
|
2
|
+
declare let __mpx_mode__: 'wx' | 'ali' | 'swan' | 'qq' | 'tt' | 'web' | 'dd' | 'qa' | 'jd' | 'android' | 'ios' | 'harmony'
|
|
3
3
|
|
|
4
4
|
// declaration for mpx env
|
|
5
5
|
declare let __mpx_env__: string
|
package/@types/index.d.ts
CHANGED
|
@@ -412,7 +412,7 @@ interface MpxConfig {
|
|
|
412
412
|
rnConfig: RnConfig,
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
type SupportedMode = 'wx' | 'ali' | 'qq' | 'swan' | 'tt' | 'web' | 'qa'
|
|
415
|
+
type SupportedMode = 'wx' | 'ali' | 'qq' | 'swan' | 'tt' | 'web' | 'qa'
|
|
416
416
|
|
|
417
417
|
interface ImplementOptions {
|
|
418
418
|
modes?: Array<SupportedMode>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.17-beta.1",
|
|
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.10.
|
|
22
|
+
"@mpxjs/utils": "^2.10.17",
|
|
23
23
|
"lodash": "^4.1.1",
|
|
24
24
|
"miniprogram-api-typings": "^3.10.0"
|
|
25
25
|
},
|
|
@@ -9,7 +9,6 @@ import wxToTtRule from './wxToTt'
|
|
|
9
9
|
import wxToDdRule from './wxToDd'
|
|
10
10
|
import wxToJdRule from './wxToJd'
|
|
11
11
|
import wxToReactRule from './wxToReact'
|
|
12
|
-
import wxToKsRule from './wxToKs'
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* 转换规则包含四点
|
|
@@ -39,8 +38,7 @@ const rulesMap = {
|
|
|
39
38
|
wxToJd: extend({}, defaultConvertRule, wxToJdRule),
|
|
40
39
|
wxToIos: extend({}, defaultConvertRule, wxToReactRule),
|
|
41
40
|
wxToAndroid: extend({}, defaultConvertRule, wxToReactRule),
|
|
42
|
-
wxToHarmony: extend({}, defaultConvertRule, wxToReactRule)
|
|
43
|
-
wxToKs: extend({}, defaultConvertRule, wxToKsRule)
|
|
41
|
+
wxToHarmony: extend({}, defaultConvertRule, wxToReactRule)
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
export function getConvertRule (convertMode) {
|
package/src/core/proxy.js
CHANGED
|
@@ -335,7 +335,7 @@ export default class MpxProxy {
|
|
|
335
335
|
createSelectorQuery: this.target.createSelectorQuery ? this.target.createSelectorQuery.bind(this.target) : envObj.createSelectorQuery.bind(envObj),
|
|
336
336
|
createIntersectionObserver: this.target.createIntersectionObserver ? this.target.createIntersectionObserver.bind(this.target) : envObj.createIntersectionObserver.bind(envObj),
|
|
337
337
|
getPageId: this.target.getPageId.bind(this.target),
|
|
338
|
-
getOpenerEventChannel: this.target.getOpenerEventChannel
|
|
338
|
+
getOpenerEventChannel: this.target.getOpenerEventChannel.bind(this.target)
|
|
339
339
|
}
|
|
340
340
|
])
|
|
341
341
|
if (!isObject(setupResult)) {
|
|
@@ -731,10 +731,10 @@ export default class MpxProxy {
|
|
|
731
731
|
initRender () {
|
|
732
732
|
if (this.options.__nativeRender__) return this.doRender()
|
|
733
733
|
|
|
734
|
-
const
|
|
735
|
-
const
|
|
736
|
-
const
|
|
737
|
-
const
|
|
734
|
+
const _i = this.target._i.bind(this.target)
|
|
735
|
+
const _c = this.target._c.bind(this.target)
|
|
736
|
+
const _r = this.target._r.bind(this.target)
|
|
737
|
+
const _sc = this.target._sc.bind(this.target)
|
|
738
738
|
const _g = this.target._g?.bind(this.target)
|
|
739
739
|
const __getAst = this.target.__getAst?.bind(this.target)
|
|
740
740
|
const moduleId = this.target.__moduleId
|
|
@@ -748,7 +748,7 @@ export default class MpxProxy {
|
|
|
748
748
|
if (dynamicTarget || __getAst) {
|
|
749
749
|
try {
|
|
750
750
|
const ast = getAst(__getAst, moduleId)
|
|
751
|
-
return
|
|
751
|
+
return _r(false, _g(ast, moduleId))
|
|
752
752
|
} catch (e) {
|
|
753
753
|
e.errType = 'mpx-dynamic-render'
|
|
754
754
|
e.errmsg = e.message
|
|
@@ -761,7 +761,7 @@ export default class MpxProxy {
|
|
|
761
761
|
}
|
|
762
762
|
if (this.target.__injectedRender) {
|
|
763
763
|
try {
|
|
764
|
-
return this.target.__injectedRender(
|
|
764
|
+
return this.target.__injectedRender(_i, _c, _r, _sc)
|
|
765
765
|
} catch (e) {
|
|
766
766
|
warn('Failed to execute render function, degrade to full-set-data mode.', this.options.mpxFileResource, e)
|
|
767
767
|
this.render()
|
|
@@ -3,7 +3,7 @@ import { getByPath, hasOwn, isObject } from '@mpxjs/utils'
|
|
|
3
3
|
export default function renderHelperMixin () {
|
|
4
4
|
return {
|
|
5
5
|
methods: {
|
|
6
|
-
|
|
6
|
+
_i (val, handler) {
|
|
7
7
|
let i, l, keys, key
|
|
8
8
|
if (Array.isArray(val) || typeof val === 'string') {
|
|
9
9
|
for (i = 0, l = val.length; i < l; i++) {
|
|
@@ -22,7 +22,7 @@ export default function renderHelperMixin () {
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
// collect
|
|
25
|
-
|
|
25
|
+
_c (key, value) {
|
|
26
26
|
if (hasOwn(this.__mpxProxy.renderData, key)) {
|
|
27
27
|
return this.__mpxProxy.renderData[key]
|
|
28
28
|
}
|
|
@@ -33,10 +33,10 @@ export default function renderHelperMixin () {
|
|
|
33
33
|
return value
|
|
34
34
|
},
|
|
35
35
|
// simple collect
|
|
36
|
-
|
|
36
|
+
_sc (key) {
|
|
37
37
|
return (this.__mpxProxy.renderData[key] = this[key])
|
|
38
38
|
},
|
|
39
|
-
|
|
39
|
+
_r (skipPre, vnode) {
|
|
40
40
|
this.__mpxProxy.renderWithData(skipPre, vnode)
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -80,7 +80,6 @@ export default function createApp (options) {
|
|
|
80
80
|
return createElement(Stack.Screen, {
|
|
81
81
|
name: key,
|
|
82
82
|
getComponent,
|
|
83
|
-
initialParams,
|
|
84
83
|
layout: headerLayout
|
|
85
84
|
})
|
|
86
85
|
}
|
|
@@ -228,9 +227,13 @@ export default function createApp (options) {
|
|
|
228
227
|
}, [])
|
|
229
228
|
|
|
230
229
|
const { initialRouteName, initialParams } = initialRouteRef.current
|
|
230
|
+
if (!global.__mpxAppHotLaunched) {
|
|
231
|
+
global.__mpxInitialRouteName = initialRouteName
|
|
232
|
+
global.__mpxInitialRunParams = initialParams
|
|
233
|
+
}
|
|
231
234
|
const navScreenOpts = {
|
|
232
235
|
headerShown: false,
|
|
233
|
-
statusBarTranslucent: true,
|
|
236
|
+
statusBarTranslucent: Mpx.config.rnConfig.statusBarTranslucent ?? true,
|
|
234
237
|
statusBarBackgroundColor: 'transparent'
|
|
235
238
|
}
|
|
236
239
|
|
|
@@ -3,7 +3,7 @@ import * as ReactNative from 'react-native'
|
|
|
3
3
|
import { ReactiveEffect } from '../../observer/effect'
|
|
4
4
|
import { watch } from '../../observer/watch'
|
|
5
5
|
import { del, reactive, set } from '../../observer/reactive'
|
|
6
|
-
import { hasOwn, isFunction, noop, isObject, isArray, getByPath, collectDataset, hump2dash, dash2hump, callWithErrorHandling, wrapMethodsWithErrorHandling, error,
|
|
6
|
+
import { hasOwn, isFunction, noop, isObject, isArray, getByPath, collectDataset, hump2dash, dash2hump, callWithErrorHandling, wrapMethodsWithErrorHandling, error, setFocusedNavigation } from '@mpxjs/utils'
|
|
7
7
|
import MpxProxy from '../../core/proxy'
|
|
8
8
|
import { BEFOREUPDATE, ONLOAD, UPDATED, ONSHOW, ONHIDE, ONRESIZE, REACTHOOKSEXEC } from '../../core/innerLifecycle'
|
|
9
9
|
import mergeOptions from '../../core/mergeOptions'
|
|
@@ -295,13 +295,17 @@ function createInstance ({ propsRef, type, rawOptions, currentInject, validProps
|
|
|
295
295
|
instance[key] = method.bind(instance)
|
|
296
296
|
})
|
|
297
297
|
}
|
|
298
|
-
|
|
298
|
+
const loadParams = {}
|
|
299
299
|
if (type === 'page') {
|
|
300
300
|
const props = propsRef.current
|
|
301
301
|
instance.route = props.route.name
|
|
302
302
|
global.__mpxPagesMap = global.__mpxPagesMap || {}
|
|
303
303
|
global.__mpxPagesMap[props.route.key] = [instance, props.navigation]
|
|
304
304
|
setFocusedNavigation(props.navigation)
|
|
305
|
+
|
|
306
|
+
if (!global.__mpxAppHotLaunched && global.__mpxInitialRunParams) {
|
|
307
|
+
Object.assign(loadParams, global.__mpxInitialRunParams)
|
|
308
|
+
}
|
|
305
309
|
// App onLaunch 在 Page created 之前执行
|
|
306
310
|
if (!global.__mpxAppHotLaunched && global.__mpxAppOnLaunch) {
|
|
307
311
|
global.__mpxAppOnLaunch(props.navigation)
|
|
@@ -313,7 +317,6 @@ function createInstance ({ propsRef, type, rawOptions, currentInject, validProps
|
|
|
313
317
|
|
|
314
318
|
if (type === 'page') {
|
|
315
319
|
const props = propsRef.current
|
|
316
|
-
const loadParams = {}
|
|
317
320
|
// 此处拿到的props.route.params内属性的value被进行过了一次decode, 不符合预期,此处额外进行一次encode来与微信对齐
|
|
318
321
|
if (isObject(props.route.params)) {
|
|
319
322
|
for (const key in props.route.params) {
|
|
@@ -420,6 +423,11 @@ function usePageStatus (navigation, pageId) {
|
|
|
420
423
|
set(pageStatusMap, pageId, '')
|
|
421
424
|
}
|
|
422
425
|
useEffect(() => {
|
|
426
|
+
if (navigation.isFocused && navigation.isFocused()) {
|
|
427
|
+
Promise.resolve().then(() => {
|
|
428
|
+
pageStatusMap[pageId] = 'show'
|
|
429
|
+
})
|
|
430
|
+
}
|
|
423
431
|
const focusSubscription = navigation.addListener('focus', () => {
|
|
424
432
|
pageStatusMap[pageId] = 'show'
|
|
425
433
|
})
|
|
@@ -592,7 +600,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
592
600
|
const instanceRef = useRef(null)
|
|
593
601
|
const propsRef = useRef(null)
|
|
594
602
|
const intersectionCtx = useContext(IntersectionObserverContext)
|
|
595
|
-
const { pageId
|
|
603
|
+
const { pageId } = useContext(RouteContext) || {}
|
|
596
604
|
const parentProvides = useContext(ProviderContext)
|
|
597
605
|
let relation = null
|
|
598
606
|
if (hasDescendantRelation || hasAncestorRelation) {
|
|
@@ -651,10 +659,6 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
651
659
|
usePageEffect(proxy, pageId)
|
|
652
660
|
useEffect(() => {
|
|
653
661
|
proxy.mounted()
|
|
654
|
-
if (navigation.camera?.multi) {
|
|
655
|
-
navigation.camera.multi = false
|
|
656
|
-
warn('<camera>: 一个页面只能插入一个')
|
|
657
|
-
}
|
|
658
662
|
return () => {
|
|
659
663
|
proxy.unmounted()
|
|
660
664
|
proxy.target.__resetInstance()
|
package/src/convertor/wxToKs.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { error } from '@mpxjs/utils'
|
|
2
|
-
|
|
3
|
-
const BEHAVIORS_MAP = [
|
|
4
|
-
'wx://form-field',
|
|
5
|
-
'wx://form-field-group',
|
|
6
|
-
'wx://form-field-button',
|
|
7
|
-
'wx://component-export'
|
|
8
|
-
]
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
convert (options) {
|
|
12
|
-
if (options.behaviors) {
|
|
13
|
-
options.behaviors.forEach((behavior, idx) => {
|
|
14
|
-
if (BEHAVIORS_MAP.includes(behavior)) {
|
|
15
|
-
error(`Built-in behavior "${behavior}" is not supported in ks environment!`, global.currentResource || global.currentModuleId)
|
|
16
|
-
options.behaviors.splice(idx, 1)
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|