@mpxjs/webpack-plugin 2.9.70-alpha.0 → 2.9.71
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/LICENSE +433 -0
- package/README.md +1 -1
- package/lib/config.js +0 -14
- package/lib/dependencies/ResolveDependency.js +0 -5
- package/lib/index.js +7 -38
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +0 -53
- package/lib/parser.js +1 -1
- package/lib/platform/json/wx/index.js +21 -8
- package/lib/platform/style/wx/index.js +51 -54
- package/lib/platform/template/wx/component-config/button.js +2 -14
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/image.js +0 -4
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +0 -4
- package/lib/platform/template/wx/component-config/movable-view.js +8 -1
- package/lib/platform/template/wx/component-config/picker-view.js +1 -5
- package/lib/platform/template/wx/component-config/rich-text.js +6 -2
- package/lib/platform/template/wx/component-config/scroll-view.js +1 -5
- package/lib/platform/template/wx/component-config/switch.js +0 -4
- package/lib/platform/template/wx/component-config/text.js +0 -4
- package/lib/platform/template/wx/component-config/textarea.js +0 -5
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/platform/template/wx/component-config/view.js +0 -4
- package/lib/platform/template/wx/index.js +1 -131
- package/lib/resolve-loader.js +1 -4
- package/lib/runtime/components/react/context.ts +8 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +39 -37
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -44
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +5 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +93 -58
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +10 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +94 -81
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +19 -16
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +10 -11
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +11 -4
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +31 -8
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +435 -371
- package/lib/runtime/components/react/dist/mpx-view.jsx +18 -53
- package/lib/runtime/components/react/dist/pickerFaces.js +3 -8
- package/lib/runtime/components/react/dist/pickerVIewContext.js +5 -0
- package/lib/runtime/components/react/dist/{pickerViewOverlay.jsx → pickerViewIndicator.jsx} +6 -6
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +2 -2
- package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -10
- package/lib/runtime/components/react/dist/utils.jsx +162 -70
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +236 -182
- package/lib/runtime/components/react/mpx-button.tsx +27 -69
- package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
- package/lib/runtime/components/react/mpx-canvas/index.tsx +44 -46
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +15 -13
- package/lib/runtime/components/react/mpx-checkbox.tsx +20 -21
- package/lib/runtime/components/react/mpx-form.tsx +15 -20
- package/lib/runtime/components/react/mpx-icon.tsx +2 -2
- package/lib/runtime/components/react/mpx-image.tsx +87 -47
- package/lib/runtime/components/react/mpx-input.tsx +24 -32
- package/lib/runtime/components/react/mpx-label.tsx +12 -14
- package/lib/runtime/components/react/mpx-movable-area.tsx +10 -16
- package/lib/runtime/components/react/mpx-movable-view.tsx +133 -92
- package/lib/runtime/components/react/mpx-navigator.tsx +3 -9
- package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +76 -0
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +206 -183
- package/lib/runtime/components/react/mpx-picker-view.tsx +49 -48
- package/lib/runtime/components/react/mpx-radio-group.tsx +13 -15
- package/lib/runtime/components/react/mpx-radio.tsx +19 -25
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +115 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
- package/lib/runtime/components/react/mpx-scroll-view.tsx +53 -43
- package/lib/runtime/components/react/mpx-swiper-item.tsx +45 -11
- package/lib/runtime/components/react/mpx-swiper.tsx +742 -0
- package/lib/runtime/components/react/mpx-switch.tsx +19 -15
- package/lib/runtime/components/react/mpx-text.tsx +8 -16
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +28 -77
- package/lib/runtime/components/react/mpx-web-view.tsx +94 -59
- package/lib/runtime/components/react/pickerFaces.ts +10 -7
- package/lib/runtime/components/react/pickerVIewContext.ts +27 -0
- package/lib/runtime/components/react/pickerViewIndicator.tsx +34 -0
- package/lib/runtime/components/react/pickerViewMask.tsx +30 -0
- package/lib/runtime/components/react/types/{getInnerListeners.ts → getInnerListeners.d.ts} +4 -5
- package/lib/runtime/components/react/types/global.d.ts +12 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +60 -15
- package/lib/runtime/components/react/utils.tsx +175 -71
- package/lib/runtime/components/web/mpx-checkbox.vue +1 -1
- package/lib/runtime/components/web/mpx-picker-view-column.vue +9 -4
- package/lib/runtime/components/web/mpx-web-view.vue +34 -20
- package/lib/runtime/optionProcessor.js +0 -22
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/compiler.js +91 -39
- package/lib/utils/env.js +1 -6
- package/lib/utils/pre-process-json.js +9 -5
- package/lib/wxss/loader.js +15 -2
- package/package.json +4 -7
- package/lib/dependencies/AddEntryDependency.js +0 -24
- package/lib/runtime/components/react/dist/types/common.js +0 -1
- package/lib/runtime/components/react/dist/types/getInnerListeners.js +0 -1
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +0 -527
- package/lib/runtime/components/react/mpx-swiper/index.tsx +0 -80
- package/lib/runtime/components/react/mpx-swiper/type.ts +0 -87
- package/lib/runtime/components/react/pickerOverlay.tsx +0 -32
- package/lib/runtime/components/tenon/getInnerListeners.js +0 -334
- package/lib/runtime/components/tenon/tenon-button.vue +0 -309
- package/lib/runtime/components/tenon/tenon-image.vue +0 -66
- package/lib/runtime/components/tenon/tenon-input.vue +0 -171
- package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -26
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -127
- package/lib/runtime/components/tenon/tenon-switch.vue +0 -96
- package/lib/runtime/components/tenon/tenon-text.vue +0 -70
- package/lib/runtime/components/tenon/tenon-textarea.vue +0 -86
- package/lib/runtime/components/tenon/tenon-view.vue +0 -93
- package/lib/runtime/components/web/event.js +0 -105
- package/lib/runtime/optionProcessor.tenon.js +0 -84
- package/lib/style-compiler/plugins/hm.js +0 -20
- package/lib/tenon/index.js +0 -117
- package/lib/tenon/processJSON.js +0 -352
- package/lib/tenon/processScript.js +0 -203
- package/lib/tenon/processStyles.js +0 -21
- package/lib/tenon/processTemplate.js +0 -126
- package/lib/tenon/script-helper.js +0 -223
- package/lib/utils/get-relative-path.js +0 -25
- /package/lib/runtime/components/react/types/{common.ts → common.d.ts} +0 -0
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { h } from "@hummer/tenon-vue";
|
|
3
|
-
import getInnerListeners from "./getInnerListeners";
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
name: "mpx-view",
|
|
7
|
-
props: {
|
|
8
|
-
hoverClass: {
|
|
9
|
-
type: String,
|
|
10
|
-
default: "none",
|
|
11
|
-
},
|
|
12
|
-
hoverStopPropagation: {
|
|
13
|
-
type: Boolean,
|
|
14
|
-
default: false,
|
|
15
|
-
},
|
|
16
|
-
hoverStartTime: {
|
|
17
|
-
type: Number,
|
|
18
|
-
default: 50,
|
|
19
|
-
},
|
|
20
|
-
hoverStayTime: {
|
|
21
|
-
type: Number,
|
|
22
|
-
default: 400,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
render() {
|
|
26
|
-
let mergeAfter;
|
|
27
|
-
if (this.hoverClass && this.hoverClass !== "none") {
|
|
28
|
-
mergeAfter = {
|
|
29
|
-
listeners: {
|
|
30
|
-
onTouchstart: this.handleTouchstart,
|
|
31
|
-
onTouchend: this.handleTouchend,
|
|
32
|
-
},
|
|
33
|
-
force: true,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return h(
|
|
37
|
-
"view",
|
|
38
|
-
{
|
|
39
|
-
class: this.className,
|
|
40
|
-
...getInnerListeners(this, { mergeAfter }),
|
|
41
|
-
ref: "mpx-view"
|
|
42
|
-
},
|
|
43
|
-
this.$slots.default && this.$slots.default() || ''
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
data() {
|
|
47
|
-
return {
|
|
48
|
-
hover: false,
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
computed: {
|
|
52
|
-
className() {
|
|
53
|
-
let result = {};
|
|
54
|
-
if (this.hoverClass && this.hoverClass !== "none" && this.hover) {
|
|
55
|
-
result = {
|
|
56
|
-
"mpx-view": true,
|
|
57
|
-
[this.hoverClass]: true,
|
|
58
|
-
};
|
|
59
|
-
} else {
|
|
60
|
-
result = {
|
|
61
|
-
"mpx-view": true,
|
|
62
|
-
[this.hoverClass]: false,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return result;
|
|
66
|
-
},
|
|
67
|
-
originRef() {
|
|
68
|
-
return this.$refs["mpx-view"]
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
pageConfig: {
|
|
72
|
-
canScroll: false,
|
|
73
|
-
},
|
|
74
|
-
methods: {
|
|
75
|
-
handleTouchstart(e) {
|
|
76
|
-
if (e.__hoverStopPropagation) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
e.__hoverStopPropagation = this.hoverStopPropagation;
|
|
80
|
-
clearTimeout(this.startTimer);
|
|
81
|
-
this.startTimer = setTimeout(() => {
|
|
82
|
-
this.hover = true;
|
|
83
|
-
}, this.hoverStartTime);
|
|
84
|
-
},
|
|
85
|
-
handleTouchend() {
|
|
86
|
-
clearTimeout(this.endTimer);
|
|
87
|
-
this.endTimer = setTimeout(() => {
|
|
88
|
-
this.hover = false;
|
|
89
|
-
}, this.hoverStayTime);
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
</script>
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { extendEvent } from './getInnerListeners'
|
|
2
|
-
import { isBrowser } from '../../env'
|
|
3
|
-
|
|
4
|
-
function MpxEvent (layer) {
|
|
5
|
-
this.targetElement = null
|
|
6
|
-
|
|
7
|
-
this.touches = []
|
|
8
|
-
|
|
9
|
-
this.touchStartX = 0
|
|
10
|
-
|
|
11
|
-
this.touchStartY = 0
|
|
12
|
-
|
|
13
|
-
this.startTimer = null
|
|
14
|
-
|
|
15
|
-
this.needTap = true
|
|
16
|
-
|
|
17
|
-
this.isTouchDevice = document && ('ontouchstart' in document.documentElement)
|
|
18
|
-
|
|
19
|
-
this.onTouchStart = (event) => {
|
|
20
|
-
if (event.targetTouches?.length > 1) {
|
|
21
|
-
return true
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
this.touches = event.targetTouches
|
|
25
|
-
this.targetElement = event.target
|
|
26
|
-
this.needTap = true
|
|
27
|
-
this.startTimer = null
|
|
28
|
-
this.touchStartX = this.touches[0].pageX
|
|
29
|
-
this.touchStartY = this.touches[0].pageY
|
|
30
|
-
this.startTimer = setTimeout(() => {
|
|
31
|
-
this.needTap = false
|
|
32
|
-
this.sendEvent(this.targetElement, 'longpress', event)
|
|
33
|
-
this.sendEvent(this.targetElement, 'longtap', event)
|
|
34
|
-
}, 350)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this.onTouchMove = (event) => {
|
|
38
|
-
const touch = event.changedTouches[0]
|
|
39
|
-
if (Math.abs(touch.pageX - this.touchStartX) > 1 || Math.abs(touch.pageY - this.touchStartY) > 1) {
|
|
40
|
-
this.needTap = false
|
|
41
|
-
this.startTimer && clearTimeout(this.startTimer)
|
|
42
|
-
this.startTimer = null
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
this.onTouchEnd = (event) => {
|
|
47
|
-
if (event.targetTouches?.length > 1) {
|
|
48
|
-
return true
|
|
49
|
-
}
|
|
50
|
-
this.startTimer && clearTimeout(this.startTimer)
|
|
51
|
-
this.startTimer = null
|
|
52
|
-
if (this.needTap) {
|
|
53
|
-
this.sendEvent(this.targetElement, 'tap', event)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
this.onClick = (event) => {
|
|
58
|
-
this.targetElement = event.target
|
|
59
|
-
this.sendEvent(this.targetElement, 'tap', event)
|
|
60
|
-
}
|
|
61
|
-
this.sendEvent = (targetElement, type, event) => {
|
|
62
|
-
const touchEvent = new CustomEvent(type, {
|
|
63
|
-
bubbles: true,
|
|
64
|
-
cancelable: true
|
|
65
|
-
})
|
|
66
|
-
const changedTouches = event.changedTouches || []
|
|
67
|
-
extendEvent(touchEvent, {
|
|
68
|
-
timeStamp: event.timeStamp,
|
|
69
|
-
changedTouches,
|
|
70
|
-
touches: changedTouches,
|
|
71
|
-
detail: {
|
|
72
|
-
// pc端点击事件可能没有changedTouches,所以直接从 event中取
|
|
73
|
-
x: changedTouches[0]?.pageX || event.pageX || 0,
|
|
74
|
-
y: changedTouches[0]?.pageY || event.pageY || 0
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
targetElement && targetElement.dispatchEvent(touchEvent)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
this.addListener = () => {
|
|
81
|
-
if (this.isTouchDevice) {
|
|
82
|
-
layer.addEventListener('touchstart', this.onTouchStart, true)
|
|
83
|
-
layer.addEventListener('touchmove', this.onTouchMove, true)
|
|
84
|
-
layer.addEventListener('touchend', this.onTouchEnd, true)
|
|
85
|
-
} else {
|
|
86
|
-
layer.addEventListener('click', this.onClick, true)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
this.addListener()
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function createEvent () {
|
|
93
|
-
if (isBrowser && !global.__mpxCreatedEvent) {
|
|
94
|
-
global.__mpxCreatedEvent = true
|
|
95
|
-
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
96
|
-
// eslint-disable-next-line no-new
|
|
97
|
-
new MpxEvent(document.body)
|
|
98
|
-
} else {
|
|
99
|
-
document.addEventListener('DOMContentLoaded', function () {
|
|
100
|
-
// eslint-disable-next-line no-new
|
|
101
|
-
new MpxEvent(document.body)
|
|
102
|
-
}, false)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// import { inBrowser } from '../utils/env'
|
|
2
|
-
|
|
3
|
-
import { hasOwn } from './utils'
|
|
4
|
-
|
|
5
|
-
export function processComponentOption (
|
|
6
|
-
{
|
|
7
|
-
option,
|
|
8
|
-
ctorType,
|
|
9
|
-
outputPath,
|
|
10
|
-
pageConfig,
|
|
11
|
-
componentsMap,
|
|
12
|
-
componentGenerics,
|
|
13
|
-
genericsInfo,
|
|
14
|
-
wxsMixin,
|
|
15
|
-
hasApp,
|
|
16
|
-
}
|
|
17
|
-
) {
|
|
18
|
-
if (ctorType === 'app') {
|
|
19
|
-
// 对于app中的组件需要全局注册
|
|
20
|
-
for (const componentName in componentsMap) {
|
|
21
|
-
if (hasOwn(componentsMap, componentName)) {
|
|
22
|
-
const component = componentsMap[componentName]
|
|
23
|
-
Vue.component(componentName, component)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
// 局部注册页面和组件中依赖的组件
|
|
28
|
-
for (const componentName in componentsMap) {
|
|
29
|
-
if (hasOwn(componentsMap, componentName)) {
|
|
30
|
-
const component = componentsMap[componentName]
|
|
31
|
-
if (!option.components) {
|
|
32
|
-
option.components = {}
|
|
33
|
-
}
|
|
34
|
-
option.components[componentName] = component
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (ctorType === 'page') {
|
|
39
|
-
(option.mixins ? option.mixins : (option.mixins = [])).push({
|
|
40
|
-
// cache page instance in tenon
|
|
41
|
-
created () {
|
|
42
|
-
global.__currentPageInstance = this
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
option.__mpxPageConfig = Object.assign({}, global.__mpxPageConfig, pageConfig)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (wxsMixin) {
|
|
50
|
-
if (option.mixins) {
|
|
51
|
-
option.mixins.push(mixin)
|
|
52
|
-
} else {
|
|
53
|
-
option.mixins = [mixin]
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (outputPath) {
|
|
58
|
-
option.componentPath = '/' + outputPath
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return option
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function getComponent (component, extendOptions) {
|
|
65
|
-
component = component.__esModule ? component.default : component
|
|
66
|
-
// eslint-disable-next-line
|
|
67
|
-
if (extendOptions) Object.assign(component, extendOptions)
|
|
68
|
-
return component
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function getWxsMixin (wxsModules) {
|
|
72
|
-
if (!wxsModules) return {}
|
|
73
|
-
return {
|
|
74
|
-
created () {
|
|
75
|
-
Object.keys(wxsModules).forEach((key) => {
|
|
76
|
-
if (key in this) {
|
|
77
|
-
console.error(`[Mpx runtime error]: The wxs module key [${key}] exist in the component/page instance already, please check and rename it!`)
|
|
78
|
-
} else {
|
|
79
|
-
this[key] = wxsModules[key]
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const postcss = require('postcss')
|
|
2
|
-
const rpxRegExp = /\b(\d+(\.\d+)?)rpx\b/
|
|
3
|
-
const rpxRegExpG = /\b(\d+(\.\d+)?)rpx\b/g
|
|
4
|
-
|
|
5
|
-
module.exports = postcss.plugin('hm', (options = {}) => root => {
|
|
6
|
-
function transHm (declaration) {
|
|
7
|
-
if (rpxRegExp.test(declaration.value)) {
|
|
8
|
-
declaration.value = declaration.value.replace(rpxRegExpG, function (match, $1) {
|
|
9
|
-
if ($1 === '0') return $1
|
|
10
|
-
return `${$1}hm`
|
|
11
|
-
})
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
root.walkRules(rule => {
|
|
16
|
-
rule.walkDecls(declaration => {
|
|
17
|
-
transHm(declaration)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
})
|
package/lib/tenon/index.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
const async = require('async')
|
|
2
|
-
const processJSON = require('./processJSON')
|
|
3
|
-
// const processMainScript = require('./processMainScript')
|
|
4
|
-
const processTemplate = require('./processTemplate')
|
|
5
|
-
const processStyles = require('./processStyles')
|
|
6
|
-
const processScript = require('./processScript')
|
|
7
|
-
const RecordLoaderContentDependency = require('../dependencies/RecordLoaderContentDependency')
|
|
8
|
-
const {stringifyRequest} = require('./script-helper')
|
|
9
|
-
const addQuery = require('../utils/add-query')
|
|
10
|
-
const parseRequest = require('../utils/parse-request')
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
module.exports = function ({
|
|
15
|
-
parts,
|
|
16
|
-
jsonContent,
|
|
17
|
-
loaderContext,
|
|
18
|
-
pagesMap,
|
|
19
|
-
componentsMap,
|
|
20
|
-
queryObj,
|
|
21
|
-
ctorType,
|
|
22
|
-
srcMode,
|
|
23
|
-
moduleId,
|
|
24
|
-
isProduction,
|
|
25
|
-
hasScoped,
|
|
26
|
-
hasComment,
|
|
27
|
-
isNative,
|
|
28
|
-
usingComponentsInfo,
|
|
29
|
-
componentGenerics,
|
|
30
|
-
autoScope,
|
|
31
|
-
callback
|
|
32
|
-
}) {
|
|
33
|
-
|
|
34
|
-
let output = ''
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const mpx = loaderContext.getMpx()
|
|
38
|
-
// const hasComment = parts.template && parts.template.attrs && parts.template.attrs.comments
|
|
39
|
-
// const isNative = false
|
|
40
|
-
const mode = mpx.mode
|
|
41
|
-
// const srcMode = mpx.srcMode
|
|
42
|
-
const env = mpx.env
|
|
43
|
-
const defs = mpx.defs
|
|
44
|
-
const resolveMode = mpx.resolveMode
|
|
45
|
-
// const pagesMap = mpx.pagesMap
|
|
46
|
-
const projectRoot = mpx.projectRoot
|
|
47
|
-
|
|
48
|
-
// 通过RecordLoaderContentDependency和loaderContentCache确保子request不再重复生成loaderContent
|
|
49
|
-
const cacheContent = mpx.loaderContentCache.get(loaderContext.resourcePath)
|
|
50
|
-
if (cacheContent) return callback(null, cacheContent)
|
|
51
|
-
return async.waterfall([
|
|
52
|
-
(callback) => {
|
|
53
|
-
async.parallel([
|
|
54
|
-
(callback) => {
|
|
55
|
-
processTemplate(parts.template, {
|
|
56
|
-
loaderContext,
|
|
57
|
-
hasScoped,
|
|
58
|
-
hasComment,
|
|
59
|
-
isNative,
|
|
60
|
-
srcMode,
|
|
61
|
-
moduleId,
|
|
62
|
-
ctorType,
|
|
63
|
-
usingComponentsInfo,
|
|
64
|
-
componentGenerics
|
|
65
|
-
}, callback)
|
|
66
|
-
},
|
|
67
|
-
(callback) => {
|
|
68
|
-
processStyles(parts.styles, {
|
|
69
|
-
ctorType,
|
|
70
|
-
autoScope,
|
|
71
|
-
moduleId
|
|
72
|
-
}, callback)
|
|
73
|
-
},
|
|
74
|
-
(callback) => {
|
|
75
|
-
processJSON(jsonContent, {
|
|
76
|
-
mode,
|
|
77
|
-
env,
|
|
78
|
-
defs,
|
|
79
|
-
resolveMode,
|
|
80
|
-
loaderContext,
|
|
81
|
-
pagesMap,
|
|
82
|
-
pathHash: mpx.pathHash,
|
|
83
|
-
componentsMap,
|
|
84
|
-
projectRoot
|
|
85
|
-
}, callback)
|
|
86
|
-
}
|
|
87
|
-
], (err, res) => {
|
|
88
|
-
callback(err, res)
|
|
89
|
-
})
|
|
90
|
-
},
|
|
91
|
-
([templateRes, stylesRes, jsonRes], callback) => {
|
|
92
|
-
output += templateRes.output
|
|
93
|
-
output += stylesRes.output
|
|
94
|
-
output += jsonRes.output
|
|
95
|
-
processScript(parts.script, {
|
|
96
|
-
loaderContext,
|
|
97
|
-
ctorType,
|
|
98
|
-
srcMode,
|
|
99
|
-
moduleId,
|
|
100
|
-
isProduction,
|
|
101
|
-
componentGenerics,
|
|
102
|
-
jsonConfig: jsonRes.jsonObj,
|
|
103
|
-
outputPath: queryObj.outputPath || '',
|
|
104
|
-
builtInComponentsMap: templateRes.builtInComponentsMap,
|
|
105
|
-
localPagesMap: jsonRes.localPagesMap,
|
|
106
|
-
genericsInfo: templateRes.genericsInfo,
|
|
107
|
-
wxsModuleMap: templateRes.wxsModuleMap,
|
|
108
|
-
localComponentsMap: jsonRes.localComponentsMap
|
|
109
|
-
}, callback)
|
|
110
|
-
}
|
|
111
|
-
], (err, scriptRes) => {
|
|
112
|
-
if (err) return callback(err)
|
|
113
|
-
output += scriptRes.output
|
|
114
|
-
loaderContext._module.addPresentationalDependency(new RecordLoaderContentDependency(loaderContext.resourcePath, output))
|
|
115
|
-
callback(null, output)
|
|
116
|
-
})
|
|
117
|
-
}
|