@mpxjs/core 2.10.16-beta.2 → 2.10.16-beta.5
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 +1 -1
- package/src/convertor/convertor.js +3 -1
- package/src/convertor/getConvertMode.js +2 -1
- package/src/convertor/wxToKs.js +21 -0
- package/src/core/proxy.js +6 -6
- package/src/platform/builtInMixins/renderHelperMixin.js +4 -4
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' | 'ks'
|
|
3
3
|
|
|
4
4
|
// declaration for mpx env
|
|
5
5
|
declare let __mpx_env__: string
|
package/@types/index.d.ts
CHANGED
|
@@ -405,7 +405,7 @@ interface MpxConfig {
|
|
|
405
405
|
rnConfig: RnConfig,
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
-
type SupportedMode = 'wx' | 'ali' | 'qq' | 'swan' | 'tt' | 'web' | 'qa'
|
|
408
|
+
type SupportedMode = 'wx' | 'ali' | 'qq' | 'swan' | 'tt' | 'web' | 'qa'| 'ks' | 'jd' | 'dd'
|
|
409
409
|
|
|
410
410
|
interface ImplementOptions {
|
|
411
411
|
modes?: Array<SupportedMode>
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ 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'
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* 转换规则包含四点
|
|
@@ -38,7 +39,8 @@ const rulesMap = {
|
|
|
38
39
|
wxToJd: extend({}, defaultConvertRule, wxToJdRule),
|
|
39
40
|
wxToIos: extend({}, defaultConvertRule, wxToReactRule),
|
|
40
41
|
wxToAndroid: extend({}, defaultConvertRule, wxToReactRule),
|
|
41
|
-
wxToHarmony: extend({}, defaultConvertRule, wxToReactRule)
|
|
42
|
+
wxToHarmony: extend({}, defaultConvertRule, wxToReactRule),
|
|
43
|
+
wxToKs: extend({}, defaultConvertRule, wxToKsRule)
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export function getConvertRule (convertMode) {
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
package/src/core/proxy.js
CHANGED
|
@@ -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 mpx_i = this.target.mpx_i.bind(this.target)
|
|
735
|
+
const mpx_c = this.target.mpx_c.bind(this.target)
|
|
736
|
+
const mpx_r = this.target.mpx_r.bind(this.target)
|
|
737
|
+
const mpx_sc = this.target.mpx_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 mpx_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(mpx_i, mpx_c, mpx_r, mpx_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
|
+
mpx_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
|
+
mpx_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
|
+
mpx_sc (key) {
|
|
37
37
|
return (this.__mpxProxy.renderData[key] = this[key])
|
|
38
38
|
},
|
|
39
|
-
|
|
39
|
+
mpx_r (skipPre, vnode) {
|
|
40
40
|
this.__mpxProxy.renderWithData(skipPre, vnode)
|
|
41
41
|
}
|
|
42
42
|
}
|