@mpxjs/webpack-plugin 2.9.18 → 2.9.19-react.0
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/lib/config.js +59 -97
- package/lib/dependencies/ResolveDependency.js +2 -2
- package/lib/helpers.js +5 -1
- package/lib/index.js +21 -18
- package/lib/loader.js +44 -97
- package/lib/native-loader.js +1 -1
- package/lib/platform/index.js +3 -0
- package/lib/platform/style/wx/index.js +413 -0
- package/lib/platform/template/wx/component-config/button.js +36 -0
- package/lib/platform/template/wx/component-config/image.js +15 -0
- package/lib/platform/template/wx/component-config/input.js +36 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +27 -1
- package/lib/platform/template/wx/component-config/swiper-item.js +13 -1
- package/lib/platform/template/wx/component-config/swiper.js +25 -1
- package/lib/platform/template/wx/component-config/text.js +15 -0
- package/lib/platform/template/wx/component-config/textarea.js +39 -0
- package/lib/platform/template/wx/component-config/unsupported.js +18 -0
- package/lib/platform/template/wx/component-config/view.js +14 -0
- package/lib/platform/template/wx/index.js +88 -4
- package/lib/react/index.js +92 -0
- package/lib/react/processJSON.js +362 -0
- package/lib/react/processScript.js +40 -0
- package/lib/react/processStyles.js +63 -0
- package/lib/react/processTemplate.js +151 -0
- package/lib/react/script-helper.js +79 -0
- package/lib/react/style-helper.js +91 -0
- package/lib/runtime/components/react/event.config.ts +32 -0
- package/lib/runtime/components/react/getInnerListeners.ts +289 -0
- package/lib/runtime/components/react/getInnerListeners.type.ts +68 -0
- package/lib/runtime/components/react/mpx-button.tsx +402 -0
- package/lib/runtime/components/react/mpx-image/index.tsx +351 -0
- package/lib/runtime/components/react/mpx-image/svg.tsx +21 -0
- package/lib/runtime/components/react/mpx-input.tsx +389 -0
- package/lib/runtime/components/react/mpx-scroll-view.tsx +412 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +407 -0
- package/lib/runtime/components/react/mpx-swiper/index.tsx +68 -0
- package/lib/runtime/components/react/mpx-swiper/type.ts +69 -0
- package/lib/runtime/components/react/mpx-swiper-item.tsx +42 -0
- package/lib/runtime/components/react/mpx-text.tsx +106 -0
- package/lib/runtime/components/react/mpx-textarea.tsx +46 -0
- package/lib/runtime/components/react/mpx-view.tsx +397 -0
- package/lib/runtime/components/react/utils.ts +92 -0
- package/lib/runtime/stringify.wxs +3 -7
- package/lib/runtime/useNodesRef.ts +39 -0
- package/lib/style-compiler/index.js +2 -1
- package/lib/template-compiler/compiler.js +539 -287
- package/lib/template-compiler/gen-node-react.js +95 -0
- package/lib/template-compiler/index.js +19 -31
- package/lib/utils/env.js +17 -0
- package/lib/utils/make-map.js +1 -1
- package/lib/utils/shallow-stringify.js +17 -0
- package/lib/web/index.js +122 -0
- package/lib/web/processMainScript.js +3 -4
- package/lib/web/processScript.js +9 -5
- package/lib/web/processTemplate.js +14 -14
- package/lib/web/script-helper.js +11 -19
- package/package.json +7 -3
|
@@ -10,6 +10,10 @@ module.exports = function ({ print }) {
|
|
|
10
10
|
const jdEventLog = print({ platform: 'jd', tag: TAG_NAME, isError: false, type: 'event' })
|
|
11
11
|
const jdPropLog = print({ platform: 'jd', tag: TAG_NAME, isError: false })
|
|
12
12
|
const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
|
|
13
|
+
const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
|
|
14
|
+
const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
|
|
15
|
+
const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
|
|
16
|
+
const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
|
|
13
17
|
|
|
14
18
|
return {
|
|
15
19
|
test: TAG_NAME,
|
|
@@ -17,6 +21,14 @@ module.exports = function ({ print }) {
|
|
|
17
21
|
el.isBuiltIn = true
|
|
18
22
|
return 'mpx-swiper'
|
|
19
23
|
},
|
|
24
|
+
ios (tag, { el }) {
|
|
25
|
+
el.isBuiltIn = true
|
|
26
|
+
return 'mpx-swiper'
|
|
27
|
+
},
|
|
28
|
+
android (tag, { el }) {
|
|
29
|
+
el.isBuiltIn = true
|
|
30
|
+
return 'mpx-swiper'
|
|
31
|
+
},
|
|
20
32
|
props: [
|
|
21
33
|
{
|
|
22
34
|
test: /^(display-multiple-items|skip-hidden-item-layout|easing-function)$/,
|
|
@@ -45,6 +57,11 @@ module.exports = function ({ print }) {
|
|
|
45
57
|
{
|
|
46
58
|
test: /^(snap-to-edge|easing-function)$/,
|
|
47
59
|
qa: qaPropLog
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
test: /^(display-multiple-items|snap-to-edge|easing-function)$/,
|
|
63
|
+
ios: iosPropLog,
|
|
64
|
+
android: androidPropLog
|
|
48
65
|
}
|
|
49
66
|
],
|
|
50
67
|
event: [
|
|
@@ -61,7 +78,14 @@ module.exports = function ({ print }) {
|
|
|
61
78
|
{
|
|
62
79
|
test: /^(transition)$/,
|
|
63
80
|
swan: baiduEventLog,
|
|
64
|
-
jd: jdEventLog
|
|
81
|
+
jd: jdEventLog,
|
|
82
|
+
ios: iosEventLog,
|
|
83
|
+
android: androidEventLog
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
test: /^(animationfinish)$/,
|
|
87
|
+
ios: iosEventLog,
|
|
88
|
+
android: androidEventLog
|
|
65
89
|
}
|
|
66
90
|
]
|
|
67
91
|
}
|
|
@@ -6,6 +6,8 @@ module.exports = function ({ print }) {
|
|
|
6
6
|
const aliPropLog = print({ platform: 'ali', tag: TAG_NAME, isError: false })
|
|
7
7
|
const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
|
|
8
8
|
const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
|
|
9
|
+
const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
|
|
10
|
+
const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
|
|
9
11
|
|
|
10
12
|
return {
|
|
11
13
|
test: TAG_NAME,
|
|
@@ -20,6 +22,14 @@ module.exports = function ({ print }) {
|
|
|
20
22
|
return 'span'
|
|
21
23
|
}
|
|
22
24
|
},
|
|
25
|
+
ios (tag, { el }) {
|
|
26
|
+
el.isBuiltIn = true
|
|
27
|
+
return 'mpx-text'
|
|
28
|
+
},
|
|
29
|
+
android (tag, { el }) {
|
|
30
|
+
el.isBuiltIn = true
|
|
31
|
+
return 'mpx-text'
|
|
32
|
+
},
|
|
23
33
|
props: [
|
|
24
34
|
{
|
|
25
35
|
test: /^(decode|user-select)$/,
|
|
@@ -32,6 +42,11 @@ module.exports = function ({ print }) {
|
|
|
32
42
|
qq: qqPropLog,
|
|
33
43
|
qa: qaPropLog
|
|
34
44
|
},
|
|
45
|
+
{
|
|
46
|
+
test: /^(space|decode)$/,
|
|
47
|
+
ios: iosPropLog,
|
|
48
|
+
android: androidPropLog
|
|
49
|
+
},
|
|
35
50
|
{
|
|
36
51
|
test: /^(selectable|space|decode|use-built-in)$/,
|
|
37
52
|
web (prop, { el }) {
|
|
@@ -14,6 +14,12 @@ module.exports = function ({ print }) {
|
|
|
14
14
|
const qqEventLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'event' })
|
|
15
15
|
const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
|
|
16
16
|
const baiduPropLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })
|
|
17
|
+
const iosValueLogError = print({ platform: 'ios', tag: TAG_NAME, isError: true, type: 'value' })
|
|
18
|
+
const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
|
|
19
|
+
const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
|
|
20
|
+
const androidValueLogError = print({ platform: 'android', tag: TAG_NAME, isError: true, type: 'value' })
|
|
21
|
+
const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
|
|
22
|
+
const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
|
|
17
23
|
|
|
18
24
|
return {
|
|
19
25
|
test: TAG_NAME,
|
|
@@ -22,6 +28,14 @@ module.exports = function ({ print }) {
|
|
|
22
28
|
el.isBuiltIn = true
|
|
23
29
|
return 'mpx-textarea'
|
|
24
30
|
},
|
|
31
|
+
ios (tag, { el }) {
|
|
32
|
+
el.isBuiltIn = true
|
|
33
|
+
return 'mpx-textarea'
|
|
34
|
+
},
|
|
35
|
+
android (tag, { el }) {
|
|
36
|
+
el.isBuiltIn = true
|
|
37
|
+
return 'mpx-textarea'
|
|
38
|
+
},
|
|
25
39
|
props: [
|
|
26
40
|
{
|
|
27
41
|
test: /^(auto-focus|fixed|cursor-spacing|cursor|show-confirm-bar|selection-start|selection-end|adjust-position|hold-keyboard|disable-default-padding|confirm-type)$/,
|
|
@@ -47,6 +61,26 @@ module.exports = function ({ print }) {
|
|
|
47
61
|
{
|
|
48
62
|
test: /^(fixed|cursor-spacing|show-confirm-bar|adjust-position|hold-keyboard|auto-height)$/,
|
|
49
63
|
qa: qaPropLog
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
test: 'confirm-type',
|
|
67
|
+
ios ({ name, value }) {
|
|
68
|
+
const notSupported = ['return']
|
|
69
|
+
if (notSupported.includes(value)) {
|
|
70
|
+
iosValueLogError({ name, value })
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
android ({ name, value }) {
|
|
74
|
+
const notSupported = ['return']
|
|
75
|
+
if (notSupported.includes(value)) {
|
|
76
|
+
androidValueLogError({ name, value })
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|adjust-position|hold-keyboard|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
|
|
82
|
+
ios: iosPropLog,
|
|
83
|
+
android: androidPropLog
|
|
50
84
|
}
|
|
51
85
|
],
|
|
52
86
|
event: [
|
|
@@ -71,6 +105,11 @@ module.exports = function ({ print }) {
|
|
|
71
105
|
{
|
|
72
106
|
test: /^(linechange|keyboardheightchange)$/,
|
|
73
107
|
tt: ttEventLog
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
test: /^keyboard.+$/,
|
|
111
|
+
ios: iosEventLog,
|
|
112
|
+
android: androidEventLog
|
|
74
113
|
}
|
|
75
114
|
]
|
|
76
115
|
}
|
|
@@ -10,6 +10,10 @@ const TT_UNSUPPORTED_TAG_NAME_ARR = ['movable-view', 'cover-image', 'cover-view'
|
|
|
10
10
|
const JD_UNSUPPORTED_TAG_NAME_ARR = ['functional-page-navigator', 'live-pusher', 'live-player', 'rich-text', 'audio', 'video', 'camera']
|
|
11
11
|
// 快应用不支持的标签集合
|
|
12
12
|
const QA_UNSUPPORTED_TAG_NAME_ARR = ['movable-view', 'movable-area', 'open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'cover-image']
|
|
13
|
+
// RN不支持的标签集合
|
|
14
|
+
const RN_UNSUPPORTED_TAG_NAME_ARR = ['movable-view', 'movable-area', 'open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'cover-image',
|
|
15
|
+
'checkbox', 'checkbox-group', 'radio', 'radio-group', 'switch', 'movable-area', 'movable-view', 'icon', 'progress', 'rich-text', 'form', 'label', 'picker', 'picker-view', 'picker-view-column', 'slider',
|
|
16
|
+
'audio', 'camera', 'video', 'canvas', 'cover-image', 'cover-view', 'match-media', 'page-container', 'root-portal', 'editor', 'keyboard-accessory', 'navigator', 'map']
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* @param {function(object): function} print
|
|
@@ -22,6 +26,8 @@ module.exports = function ({ print }) {
|
|
|
22
26
|
const ttUnsupportedTagError = print({ platform: 'bytedance', isError: true, type: 'tag' })
|
|
23
27
|
const jdUnsupportedTagError = print({ platform: 'jd', isError: true, type: 'tag' })
|
|
24
28
|
const qaUnsupportedTagError = print({ platform: 'qa', isError: true, type: 'tag' })
|
|
29
|
+
const iosUnsupportedTagError = print({ platform: 'ios', isError: true, type: 'tag' })
|
|
30
|
+
const androidUnsupportedTagError = print({ platform: 'android', isError: true, type: 'tag' })
|
|
25
31
|
|
|
26
32
|
const aliUnsupportedExp = new RegExp('^(' + ALI_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
|
|
27
33
|
const baiduUnsupportedExp = new RegExp('^(' + BAIDU_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
|
|
@@ -29,6 +35,8 @@ module.exports = function ({ print }) {
|
|
|
29
35
|
const ttUnsupportedExp = new RegExp('^(' + TT_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
|
|
30
36
|
const jdUnsupportedExp = new RegExp('^(' + JD_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
|
|
31
37
|
const qaUnsupportedExp = new RegExp('^(' + QA_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
|
|
38
|
+
const iosUnsupportedExp = new RegExp('^(' + RN_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
|
|
39
|
+
const androidUnsupportedExp = new RegExp('^(' + RN_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
|
|
32
40
|
|
|
33
41
|
return [
|
|
34
42
|
{
|
|
@@ -60,6 +68,16 @@ module.exports = function ({ print }) {
|
|
|
60
68
|
supportedModes: ['qa'],
|
|
61
69
|
test: qaUnsupportedExp,
|
|
62
70
|
qa: qaUnsupportedTagError
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
supportedModes: ['ios'],
|
|
74
|
+
test: iosUnsupportedExp,
|
|
75
|
+
ios: iosUnsupportedTagError
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
supportedModes: ['android'],
|
|
79
|
+
test: androidUnsupportedExp,
|
|
80
|
+
android: androidUnsupportedTagError
|
|
63
81
|
}
|
|
64
82
|
]
|
|
65
83
|
}
|
|
@@ -3,6 +3,8 @@ const TAG_NAME = 'view'
|
|
|
3
3
|
module.exports = function ({ print }) {
|
|
4
4
|
const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
|
|
5
5
|
const qaEventLogError = print({ platform: 'qa', tag: TAG_NAME, isError: false, type: 'event' })
|
|
6
|
+
const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
|
|
7
|
+
const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
|
|
6
8
|
|
|
7
9
|
return {
|
|
8
10
|
// 匹配标签名,可传递正则
|
|
@@ -21,6 +23,14 @@ module.exports = function ({ print }) {
|
|
|
21
23
|
return 'div'
|
|
22
24
|
}
|
|
23
25
|
},
|
|
26
|
+
ios (tag, { el }) {
|
|
27
|
+
el.isBuiltIn = true
|
|
28
|
+
return 'mpx-view'
|
|
29
|
+
},
|
|
30
|
+
android (tag, { el }) {
|
|
31
|
+
el.isBuiltIn = true
|
|
32
|
+
return 'mpx-view'
|
|
33
|
+
},
|
|
24
34
|
qa (tag) {
|
|
25
35
|
return 'div'
|
|
26
36
|
},
|
|
@@ -33,6 +43,10 @@ module.exports = function ({ print }) {
|
|
|
33
43
|
el.isBuiltIn = true
|
|
34
44
|
},
|
|
35
45
|
qa: qaPropLog
|
|
46
|
+
}, {
|
|
47
|
+
test: /^(hover-stop-propagation)$/,
|
|
48
|
+
android: androidPropLog,
|
|
49
|
+
ios: iosPropLog
|
|
36
50
|
}
|
|
37
51
|
],
|
|
38
52
|
// 组件事件中的差异部分
|
|
@@ -8,7 +8,7 @@ const normalize = require('../../../utils/normalize')
|
|
|
8
8
|
|
|
9
9
|
module.exports = function getSpec ({ warn, error }) {
|
|
10
10
|
const spec = {
|
|
11
|
-
supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd'],
|
|
11
|
+
supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'ios', 'android'],
|
|
12
12
|
// props预处理
|
|
13
13
|
preProps: [],
|
|
14
14
|
// props后处理
|
|
@@ -393,6 +393,36 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
393
393
|
name: rPrefix + rEventName + meta.modifierStr,
|
|
394
394
|
value
|
|
395
395
|
}
|
|
396
|
+
},
|
|
397
|
+
ios ({ name, value }, { eventRules, el }) {
|
|
398
|
+
const match = this.test.exec(name)
|
|
399
|
+
const prefix = match[1]
|
|
400
|
+
const eventName = match[2]
|
|
401
|
+
const modifierStr = match[3] || ''
|
|
402
|
+
const meta = {
|
|
403
|
+
modifierStr
|
|
404
|
+
}
|
|
405
|
+
const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'ios' })
|
|
406
|
+
const rEventName = runRules(eventRules, eventName, { mode: 'ios', data: { el } })
|
|
407
|
+
return {
|
|
408
|
+
name: rPrefix + rEventName + meta.modifierStr,
|
|
409
|
+
value
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
android ({ name, value }, { eventRules, el }) {
|
|
413
|
+
const match = this.test.exec(name)
|
|
414
|
+
const prefix = match[1]
|
|
415
|
+
const eventName = match[2]
|
|
416
|
+
const modifierStr = match[3] || ''
|
|
417
|
+
const meta = {
|
|
418
|
+
modifierStr
|
|
419
|
+
}
|
|
420
|
+
const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'android' })
|
|
421
|
+
const rEventName = runRules(eventRules, eventName, { mode: 'android', data: { el } })
|
|
422
|
+
return {
|
|
423
|
+
name: rPrefix + rEventName + meta.modifierStr,
|
|
424
|
+
value
|
|
425
|
+
}
|
|
396
426
|
}
|
|
397
427
|
},
|
|
398
428
|
// 无障碍
|
|
@@ -444,6 +474,28 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
444
474
|
meta.modifierStr = tempModifierStr ? '.' + tempModifierStr : ''
|
|
445
475
|
return '@'
|
|
446
476
|
}
|
|
477
|
+
// ios (prefix) {
|
|
478
|
+
// const prefixMap = {
|
|
479
|
+
// bind: 'on',
|
|
480
|
+
// catch: 'catch'
|
|
481
|
+
// }
|
|
482
|
+
// if (!prefixMap[prefix]) {
|
|
483
|
+
// error(`React native environment does not support [${prefix}] event handling!`)
|
|
484
|
+
// return
|
|
485
|
+
// }
|
|
486
|
+
// return prefixMap[prefix]
|
|
487
|
+
// },
|
|
488
|
+
// android (prefix) {
|
|
489
|
+
// const prefixMap = {
|
|
490
|
+
// bind: 'on',
|
|
491
|
+
// catch: 'catch'
|
|
492
|
+
// }
|
|
493
|
+
// if (!prefixMap[prefix]) {
|
|
494
|
+
// error(`React native environment does not support [${prefix}] event handling!`)
|
|
495
|
+
// return
|
|
496
|
+
// }
|
|
497
|
+
// return prefixMap[prefix]
|
|
498
|
+
// }
|
|
447
499
|
}
|
|
448
500
|
],
|
|
449
501
|
rules: [
|
|
@@ -474,14 +526,46 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
474
526
|
if (eventName === 'touchforcechange') {
|
|
475
527
|
error(`Web environment does not support [${eventName}] event!`)
|
|
476
528
|
}
|
|
529
|
+
},
|
|
530
|
+
ios (eventName) {
|
|
531
|
+
const eventMap = {
|
|
532
|
+
tap: 'tap',
|
|
533
|
+
longtap: 'longpress',
|
|
534
|
+
longpress: 'longpress',
|
|
535
|
+
touchstart: 'touchstart',
|
|
536
|
+
touchmove: 'touchmove',
|
|
537
|
+
touchend: 'touchend',
|
|
538
|
+
touchcancel: 'touchcancel'
|
|
539
|
+
}
|
|
540
|
+
if (eventMap[eventName]) {
|
|
541
|
+
return eventMap[eventName]
|
|
542
|
+
} else {
|
|
543
|
+
error(`React native environment does not support [${eventName}] event!`)
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
android (eventName) {
|
|
547
|
+
const eventMap = {
|
|
548
|
+
tap: 'tap',
|
|
549
|
+
longtap: 'longpress',
|
|
550
|
+
longpress: 'longpress',
|
|
551
|
+
touchstart: 'touchstart',
|
|
552
|
+
touchmove: 'touchmove',
|
|
553
|
+
touchend: 'touchend',
|
|
554
|
+
touchcancel: 'touchcancel'
|
|
555
|
+
}
|
|
556
|
+
if (eventMap[eventName]) {
|
|
557
|
+
return eventMap[eventName]
|
|
558
|
+
} else {
|
|
559
|
+
error(`React native environment does not support [${eventName}] event!`)
|
|
560
|
+
}
|
|
477
561
|
}
|
|
478
562
|
},
|
|
479
|
-
//
|
|
563
|
+
// web event escape
|
|
480
564
|
{
|
|
481
565
|
test: /^click$/,
|
|
482
|
-
web (eventName,
|
|
566
|
+
web (eventName, { isComponent }) {
|
|
483
567
|
// 自定义组件根节点
|
|
484
|
-
if (
|
|
568
|
+
if (isComponent) {
|
|
485
569
|
return '_' + eventName
|
|
486
570
|
}
|
|
487
571
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const async = require('async')
|
|
2
|
+
const processJSON = require('./processJSON')
|
|
3
|
+
const processTemplate = require('./processTemplate')
|
|
4
|
+
const processStyles = require('./processStyles')
|
|
5
|
+
const processScript = require('./processScript')
|
|
6
|
+
const RecordVueContentDependency = require('../dependencies/RecordVueContentDependency')
|
|
7
|
+
|
|
8
|
+
module.exports = function ({
|
|
9
|
+
parts,
|
|
10
|
+
loaderContext,
|
|
11
|
+
pagesMap,
|
|
12
|
+
componentsMap,
|
|
13
|
+
queryObj,
|
|
14
|
+
ctorType,
|
|
15
|
+
srcMode,
|
|
16
|
+
moduleId,
|
|
17
|
+
isProduction,
|
|
18
|
+
hasScoped,
|
|
19
|
+
hasComment,
|
|
20
|
+
isNative,
|
|
21
|
+
usingComponents,
|
|
22
|
+
componentGenerics,
|
|
23
|
+
autoScope,
|
|
24
|
+
callback
|
|
25
|
+
}) {
|
|
26
|
+
const mpx = loaderContext.getMpx()
|
|
27
|
+
// 通过RecordVueContentDependency和vueContentCache确保子request不再重复生成vueContent
|
|
28
|
+
const cacheContent = mpx.vueContentCache.get(loaderContext.resourcePath)
|
|
29
|
+
if (cacheContent) return callback(null, cacheContent)
|
|
30
|
+
let output = ''
|
|
31
|
+
return async.waterfall([
|
|
32
|
+
(callback) => {
|
|
33
|
+
async.parallel([
|
|
34
|
+
(callback) => {
|
|
35
|
+
processTemplate(parts.template, {
|
|
36
|
+
loaderContext,
|
|
37
|
+
hasScoped,
|
|
38
|
+
hasComment,
|
|
39
|
+
isNative,
|
|
40
|
+
srcMode,
|
|
41
|
+
moduleId,
|
|
42
|
+
ctorType,
|
|
43
|
+
usingComponents,
|
|
44
|
+
componentGenerics
|
|
45
|
+
}, callback)
|
|
46
|
+
},
|
|
47
|
+
(callback) => {
|
|
48
|
+
processStyles(parts.styles, {
|
|
49
|
+
loaderContext,
|
|
50
|
+
srcMode,
|
|
51
|
+
ctorType,
|
|
52
|
+
autoScope,
|
|
53
|
+
moduleId
|
|
54
|
+
}, callback)
|
|
55
|
+
},
|
|
56
|
+
(callback) => {
|
|
57
|
+
processJSON(parts.json, {
|
|
58
|
+
loaderContext,
|
|
59
|
+
pagesMap,
|
|
60
|
+
componentsMap
|
|
61
|
+
}, callback)
|
|
62
|
+
}
|
|
63
|
+
], (err, res) => {
|
|
64
|
+
callback(err, res)
|
|
65
|
+
})
|
|
66
|
+
},
|
|
67
|
+
([templateRes, stylesRes, jsonRes], callback) => {
|
|
68
|
+
output += templateRes.output
|
|
69
|
+
output += stylesRes.output
|
|
70
|
+
output += jsonRes.output
|
|
71
|
+
processScript(parts.script, {
|
|
72
|
+
loaderContext,
|
|
73
|
+
ctorType,
|
|
74
|
+
srcMode,
|
|
75
|
+
moduleId,
|
|
76
|
+
isProduction,
|
|
77
|
+
componentGenerics,
|
|
78
|
+
jsonConfig: jsonRes.jsonObj,
|
|
79
|
+
outputPath: queryObj.outputPath || '',
|
|
80
|
+
builtInComponentsMap: templateRes.builtInComponentsMap,
|
|
81
|
+
genericsInfo: templateRes.genericsInfo,
|
|
82
|
+
wxsModuleMap: templateRes.wxsModuleMap,
|
|
83
|
+
localComponentsMap: jsonRes.localComponentsMap
|
|
84
|
+
}, callback)
|
|
85
|
+
}
|
|
86
|
+
], (err, scriptRes) => {
|
|
87
|
+
if (err) return callback(err)
|
|
88
|
+
output += scriptRes.output
|
|
89
|
+
loaderContext._module.addPresentationalDependency(new RecordVueContentDependency(loaderContext.resourcePath, output))
|
|
90
|
+
callback(null, output)
|
|
91
|
+
})
|
|
92
|
+
}
|