@mpxjs/webpack-plugin 2.10.16-beta.6 → 2.10.16-perf.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/lib/config.js +0 -60
- package/lib/dependencies/AppEntryDependency.js +2 -2
- package/lib/dependencies/ResolveDependency.js +1 -1
- package/lib/file-loader.js +3 -13
- package/lib/helpers.js +0 -2
- package/lib/index.js +15 -40
- package/lib/json-compiler/helper.js +2 -72
- package/lib/json-compiler/index.js +56 -16
- package/lib/json-compiler/plugin.js +2 -2
- package/lib/loader.js +4 -10
- package/lib/native-loader.js +3 -6
- package/lib/platform/json/wx/index.js +29 -30
- package/lib/platform/style/wx/index.js +1 -8
- package/lib/platform/template/wx/component-config/ad.js +0 -5
- package/lib/platform/template/wx/component-config/button.js +5 -21
- package/lib/platform/template/wx/component-config/camera.js +3 -25
- package/lib/platform/template/wx/component-config/canvas.js +1 -8
- package/lib/platform/template/wx/component-config/component.js +33 -31
- package/lib/platform/template/wx/component-config/cover-image.js +2 -7
- package/lib/platform/template/wx/component-config/cover-view.js +1 -3
- package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
- package/lib/platform/template/wx/component-config/form.js +2 -27
- package/lib/platform/template/wx/component-config/image.js +0 -5
- package/lib/platform/template/wx/component-config/input.js +0 -10
- package/lib/platform/template/wx/component-config/label.js +2 -10
- package/lib/platform/template/wx/component-config/map.js +0 -11
- package/lib/platform/template/wx/component-config/movable-area.js +1 -4
- package/lib/platform/template/wx/component-config/movable-view.js +2 -17
- package/lib/platform/template/wx/component-config/navigator.js +0 -26
- package/lib/platform/template/wx/component-config/picker-view.js +0 -12
- package/lib/platform/template/wx/component-config/picker.js +1 -3
- package/lib/platform/template/wx/component-config/progress.js +1 -11
- package/lib/platform/template/wx/component-config/rich-text.js +0 -5
- package/lib/platform/template/wx/component-config/scroll-view.js +1 -12
- package/lib/platform/template/wx/component-config/slider.js +0 -8
- package/lib/platform/template/wx/component-config/swiper-item.js +2 -5
- package/lib/platform/template/wx/component-config/swiper.js +0 -10
- package/lib/platform/template/wx/component-config/text.js +0 -5
- package/lib/platform/template/wx/component-config/textarea.js +2 -19
- package/lib/platform/template/wx/component-config/unsupported.js +1 -10
- package/lib/platform/template/wx/component-config/video.js +0 -10
- package/lib/platform/template/wx/index.js +1 -21
- package/lib/react/index.js +0 -2
- package/lib/react/processJSON.js +71 -39
- package/lib/react/processStyles.js +2 -3
- package/lib/react/processTemplate.js +6 -8
- package/lib/react/script-helper.js +16 -6
- package/lib/react/style-helper.js +2 -10
- package/lib/runtime/components/react/context.ts +6 -12
- package/lib/runtime/components/react/dist/context.js +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +62 -100
- package/lib/runtime/components/react/dist/mpx-input.jsx +9 -35
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +50 -58
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +18 -12
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +11 -8
- package/lib/runtime/components/react/dist/mpx-portal/index.jsx +1 -5
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +14 -6
- package/lib/runtime/components/react/dist/mpx-text.jsx +5 -33
- package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/utils.jsx +6 -16
- package/lib/runtime/components/react/mpx-image.tsx +82 -123
- package/lib/runtime/components/react/mpx-input.tsx +16 -41
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +49 -66
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +2 -5
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +21 -26
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +12 -8
- package/lib/runtime/components/react/mpx-portal/index.tsx +2 -8
- package/lib/runtime/components/react/mpx-scroll-view.tsx +17 -6
- package/lib/runtime/components/react/mpx-text.tsx +5 -38
- package/lib/runtime/components/react/mpx-view.tsx +1 -1
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- package/lib/runtime/components/react/types/common.d.ts +0 -19
- package/lib/runtime/components/react/utils.tsx +6 -15
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/script-setup-compiler/index.js +2 -2
- package/lib/style-compiler/index.js +2 -3
- package/lib/style-compiler/load-postcss-config.js +1 -1
- package/lib/style-compiler/plugins/trans-special.js +2 -10
- package/lib/style-compiler/strip-conditional-loader.js +15 -178
- package/lib/template-compiler/bind-this.js +2 -2
- package/lib/template-compiler/compiler.js +72 -270
- package/lib/template-compiler/gen-node-react.js +6 -18
- package/lib/template-compiler/index.js +10 -12
- package/lib/template-compiler/parse-exps.js +1 -1
- package/lib/utils/const.js +1 -2
- package/lib/utils/dom-tag-config.js +6 -6
- package/lib/utils/env.js +1 -6
- package/lib/utils/pre-process-json.js +0 -5
- package/lib/web/index.js +0 -2
- package/lib/web/processJSON.js +16 -44
- package/lib/web/processScript.js +1 -1
- package/lib/web/processTemplate.js +4 -6
- package/lib/web/script-helper.js +9 -19
- package/lib/wxs/pre-loader.js +1 -1
- package/lib/wxss/loader.js +9 -1
- package/package.json +2 -13
- package/lib/dependencies/RecordModuleIdMapDependency.js +0 -49
- package/lib/runtime/components/react/dist/context.d.ts +0 -75
- package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/event.config.d.ts +0 -8
- package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -8
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -13
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -69
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -28
- package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.jsx +0 -102
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -24
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -9
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -11
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -3
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -33
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -53
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -33
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -28
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -19
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -22
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -50
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -13
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -66
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -9
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.jsx +0 -132
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -10
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -3
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -107
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -33
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -9
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -24
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +0 -20
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -17
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -13
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -12
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -23
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -17
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -16
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -30
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -10
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -24
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -27
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -25
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -15
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -55
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -31
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -18
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -16
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -19
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +0 -53
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -27
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -23
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -102
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts +0 -35
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -23
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/parser.d.ts +0 -40
- package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -12
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts +0 -123
- package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/mpx-camera.tsx +0 -167
- package/lib/runtime/components/react/mpx-nav.tsx +0 -155
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -55
- package/lib/utils/get-build-tag-component.js +0 -35
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const JSON5 = require('json5')
|
|
2
2
|
const he = require('he')
|
|
3
3
|
const config = require('../config')
|
|
4
|
-
const { MPX_ROOT_VIEW, MPX_APP_MODULE_ID, PARENT_MODULE_ID
|
|
4
|
+
const { MPX_ROOT_VIEW, MPX_APP_MODULE_ID, PARENT_MODULE_ID } = require('../utils/const')
|
|
5
5
|
const normalize = require('../utils/normalize')
|
|
6
6
|
const { normalizeCondition } = require('../utils/match-condition')
|
|
7
7
|
const isValidIdentifierStr = require('../utils/is-valid-identifier-str')
|
|
@@ -15,8 +15,7 @@ const { isNonPhrasingTag } = require('../utils/dom-tag-config')
|
|
|
15
15
|
const setBaseWxml = require('../runtime-render/base-wxml')
|
|
16
16
|
const { parseExp } = require('./parse-exps')
|
|
17
17
|
const shallowStringify = require('../utils/shallow-stringify')
|
|
18
|
-
const { isReact, isWeb
|
|
19
|
-
const { capitalToHyphen } = require('../utils/string')
|
|
18
|
+
const { isReact, isWeb } = require('../utils/env')
|
|
20
19
|
|
|
21
20
|
const no = function () {
|
|
22
21
|
return false
|
|
@@ -120,8 +119,6 @@ const rulesResultMap = new Map()
|
|
|
120
119
|
let usingComponents = []
|
|
121
120
|
let usingComponentsInfo = {}
|
|
122
121
|
let componentGenerics = {}
|
|
123
|
-
// 跨平台语法检测的配置,在模块加载时初始化一次
|
|
124
|
-
let crossPlatformConfig = null
|
|
125
122
|
|
|
126
123
|
function updateForScopesMap () {
|
|
127
124
|
forScopesMap = {}
|
|
@@ -150,11 +147,11 @@ const deleteErrorInResultMap = (node) => {
|
|
|
150
147
|
}
|
|
151
148
|
|
|
152
149
|
function baseWarn (msg) {
|
|
153
|
-
console.warn(('[
|
|
150
|
+
console.warn(('[template compiler]: ' + msg))
|
|
154
151
|
}
|
|
155
152
|
|
|
156
153
|
function baseError (msg) {
|
|
157
|
-
console.error(('[
|
|
154
|
+
console.error(('[template compiler]: ' + msg))
|
|
158
155
|
}
|
|
159
156
|
|
|
160
157
|
const decodeMap = {
|
|
@@ -640,9 +637,8 @@ function parse (template, options) {
|
|
|
640
637
|
processingTemplate = false
|
|
641
638
|
rulesResultMap.clear()
|
|
642
639
|
componentGenerics = options.componentGenerics || {}
|
|
643
|
-
// 初始化跨平台语法检测配置(每次解析时只初始化一次)
|
|
644
|
-
crossPlatformConfig = initCrossPlatformConfig()
|
|
645
640
|
|
|
641
|
+
if (typeof options.usingComponentsInfo === 'string') options.usingComponentsInfo = JSON.parse(options.usingComponentsInfo)
|
|
646
642
|
usingComponents = Object.keys(options.usingComponentsInfo)
|
|
647
643
|
usingComponentsInfo = options.usingComponentsInfo
|
|
648
644
|
|
|
@@ -685,6 +681,7 @@ function parse (template, options) {
|
|
|
685
681
|
meta.options.virtualHost = true
|
|
686
682
|
}
|
|
687
683
|
let currentParent
|
|
684
|
+
let multiRootError
|
|
688
685
|
// 用于记录模板用到的组件,匹配引用组件,看是否有冗余
|
|
689
686
|
const tagNames = new Set()
|
|
690
687
|
|
|
@@ -763,10 +760,7 @@ function parse (template, options) {
|
|
|
763
760
|
if (!currentParent) genTempRoot()
|
|
764
761
|
|
|
765
762
|
const children = currentParent.children
|
|
766
|
-
|
|
767
|
-
const isTextLikeParent = currentParent.tag === 'text' || currentParent.tag === 'mpx-text' || currentParent.tag === 'Text' || currentParent.tag === 'mpx-simple-text'
|
|
768
|
-
|
|
769
|
-
if (!isTextLikeParent) {
|
|
763
|
+
if (currentParent.tag !== 'text') {
|
|
770
764
|
text = text.trim()
|
|
771
765
|
} else {
|
|
772
766
|
text = text.trim() ? text : ''
|
|
@@ -799,10 +793,9 @@ function parse (template, options) {
|
|
|
799
793
|
}
|
|
800
794
|
})
|
|
801
795
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
// }
|
|
796
|
+
if (multiRootError) {
|
|
797
|
+
error$1('Template fields should has one single root, considering wrapping your template content with <view> or <text> tag!')
|
|
798
|
+
}
|
|
806
799
|
|
|
807
800
|
if (hasI18n) {
|
|
808
801
|
if (i18nInjectableComputed.length) {
|
|
@@ -1007,34 +1000,12 @@ function processComponentIs (el, options) {
|
|
|
1007
1000
|
}
|
|
1008
1001
|
|
|
1009
1002
|
const range = getAndRemoveAttr(el, 'range').val
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
ranges = range.split(',').map(i => i.trim()).filter(i => i)
|
|
1015
|
-
} else {
|
|
1016
|
-
// 根据原始用户写的usingComponents字段生成ranges
|
|
1017
|
-
ranges = options.originalUsingComponents
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
const rangeMap = new Map()
|
|
1021
|
-
ranges.forEach(name => {
|
|
1022
|
-
rangeMap.set(['ali', 'swan'].includes(mode) ? capitalToHyphen(name) : name, name)
|
|
1003
|
+
const isInRange = makeMap(range || '')
|
|
1004
|
+
el.components = (usingComponents).filter(i => {
|
|
1005
|
+
if (!range) return true
|
|
1006
|
+
return isInRange(i)
|
|
1023
1007
|
})
|
|
1024
|
-
|
|
1025
|
-
// Map<CurrentName, SourceName>
|
|
1026
|
-
el.componentMap = new Map()
|
|
1027
|
-
usingComponents.forEach((name) => {
|
|
1028
|
-
if (rangeMap.size === 0) {
|
|
1029
|
-
el.componentMap.set(name, name)
|
|
1030
|
-
} else {
|
|
1031
|
-
if (rangeMap.has(name)) {
|
|
1032
|
-
el.componentMap.set(name, rangeMap.get(name))
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
})
|
|
1036
|
-
|
|
1037
|
-
if (el.componentMap.size === 0) {
|
|
1008
|
+
if (!el.components.length) {
|
|
1038
1009
|
warn$1('Component in which <component> tag is used must have a non blank usingComponents field')
|
|
1039
1010
|
}
|
|
1040
1011
|
|
|
@@ -1621,7 +1592,7 @@ function parseOptionalChaining (str) {
|
|
|
1621
1592
|
}
|
|
1622
1593
|
if (grammarMap.checkState() && haveNotGetValue) {
|
|
1623
1594
|
// 值查找结束但是语法未闭合或者处理到边界还未结束,抛异常
|
|
1624
|
-
throw new Error('[
|
|
1595
|
+
throw new Error('[optionChain] option value illegal!!!')
|
|
1625
1596
|
}
|
|
1626
1597
|
haveNotGetValue = true
|
|
1627
1598
|
let keyValue = ''
|
|
@@ -1671,7 +1642,7 @@ function parseOptionalChaining (str) {
|
|
|
1671
1642
|
}
|
|
1672
1643
|
if (grammarMap.checkState() && haveNotGetValue) {
|
|
1673
1644
|
// key值查找结束但是语法未闭合或者处理到边界还未结束,抛异常
|
|
1674
|
-
throw new Error('[
|
|
1645
|
+
throw new Error('[optionChain] option key illegal!!!')
|
|
1675
1646
|
}
|
|
1676
1647
|
if (keyValue) {
|
|
1677
1648
|
chainKey += `,'${keyValue}'`
|
|
@@ -1884,25 +1855,24 @@ function processRefReact (el, meta) {
|
|
|
1884
1855
|
/**
|
|
1885
1856
|
* selectorsConf: [type, [[prefix, selector], [prefix, selector]]]
|
|
1886
1857
|
*/
|
|
1887
|
-
if (val) {
|
|
1858
|
+
if (!val) {
|
|
1859
|
+
const rawId = el.attrsMap.id
|
|
1860
|
+
const rawClass = el.attrsMap.class
|
|
1861
|
+
const rawDynamicClass = el.attrsMap[config[mode].directive.dynamicClass]
|
|
1862
|
+
|
|
1863
|
+
if (rawId) {
|
|
1864
|
+
const staticId = parseMustacheWithContext(rawId).result
|
|
1865
|
+
selectors.push({ prefix: '#', selector: `${staticId}` })
|
|
1866
|
+
}
|
|
1867
|
+
if (rawClass || rawDynamicClass) {
|
|
1868
|
+
const staticClass = parseMustacheWithContext(rawClass).result
|
|
1869
|
+
const dynamicClass = parseMustacheWithContext(rawDynamicClass).result
|
|
1870
|
+
selectors.push({ prefix: '.', selector: `this.__getClass(${staticClass}, ${dynamicClass})` })
|
|
1871
|
+
}
|
|
1872
|
+
} else {
|
|
1888
1873
|
meta.refs.push(refConf)
|
|
1889
1874
|
selectors.push({ prefix: '', selector: `"${refConf.key}"` })
|
|
1890
1875
|
}
|
|
1891
|
-
|
|
1892
|
-
const rawId = el.attrsMap.id
|
|
1893
|
-
const rawClass = el.attrsMap.class
|
|
1894
|
-
const rawDynamicClass = el.attrsMap[config[mode].directive.dynamicClass]
|
|
1895
|
-
|
|
1896
|
-
if (rawId) {
|
|
1897
|
-
const staticId = parseMustacheWithContext(rawId).result
|
|
1898
|
-
selectors.push({ prefix: '#', selector: `${staticId}` })
|
|
1899
|
-
}
|
|
1900
|
-
if (rawClass || rawDynamicClass) {
|
|
1901
|
-
const staticClass = parseMustacheWithContext(rawClass).result
|
|
1902
|
-
const dynamicClass = parseMustacheWithContext(rawDynamicClass).result
|
|
1903
|
-
selectors.push({ prefix: '.', selector: `this.__getClass(${staticClass}, ${dynamicClass})` })
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
1876
|
const selectorsConf = selectors.map(item => `["${item.prefix}", ${item.selector}]`)
|
|
1907
1877
|
const refFnId = forScopes.reduce((preV, curV) => {
|
|
1908
1878
|
return `${preV} + "_" + ${curV.index}`
|
|
@@ -2114,24 +2084,13 @@ function postProcessIf (el) {
|
|
|
2114
2084
|
replaceNode(el, getTempNode())._if = false
|
|
2115
2085
|
}
|
|
2116
2086
|
} else {
|
|
2117
|
-
el._if = null
|
|
2118
2087
|
attrs = [{
|
|
2119
2088
|
name: config[mode].directive.if,
|
|
2120
2089
|
value: el.if.raw
|
|
2121
2090
|
}]
|
|
2122
2091
|
}
|
|
2123
2092
|
} else if (el.elseif) {
|
|
2124
|
-
if (el.for) {
|
|
2125
|
-
error$1(`wx:elif (wx:elif="${el.elseif.raw}") invalidly used on the for-list <"${el.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the elif-directive to it`)
|
|
2126
|
-
return
|
|
2127
|
-
}
|
|
2128
|
-
|
|
2129
2093
|
prevNode = findPrevNode(el)
|
|
2130
|
-
if (!prevNode || prevNode._if === undefined) {
|
|
2131
|
-
error$1(`wx:elif="${el.elseif.raw}" used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
|
|
2132
|
-
return
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
2094
|
if (prevNode._if === true) {
|
|
2136
2095
|
removeNode(el)
|
|
2137
2096
|
} else if (prevNode._if === false) {
|
|
@@ -2151,7 +2110,6 @@ function postProcessIf (el) {
|
|
|
2151
2110
|
removeNode(el)
|
|
2152
2111
|
}
|
|
2153
2112
|
} else {
|
|
2154
|
-
el._if = null
|
|
2155
2113
|
attrs = [{
|
|
2156
2114
|
name: config[mode].directive.elseif,
|
|
2157
2115
|
value: el.elseif.raw
|
|
@@ -2159,17 +2117,7 @@ function postProcessIf (el) {
|
|
|
2159
2117
|
}
|
|
2160
2118
|
}
|
|
2161
2119
|
} else if (el.else) {
|
|
2162
|
-
if (el.for) {
|
|
2163
|
-
error$1(`wx:else invalidly used on the for-list <"${el.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the else-directive to it`)
|
|
2164
|
-
return
|
|
2165
|
-
}
|
|
2166
|
-
|
|
2167
2120
|
prevNode = findPrevNode(el)
|
|
2168
|
-
if (!prevNode || prevNode._if === undefined) {
|
|
2169
|
-
error$1(`wx:else used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
|
|
2170
|
-
return
|
|
2171
|
-
}
|
|
2172
|
-
|
|
2173
2121
|
if (prevNode._if === true) {
|
|
2174
2122
|
removeNode(el)
|
|
2175
2123
|
} else if (prevNode._if === false) {
|
|
@@ -2193,100 +2141,23 @@ function addIfCondition (el, condition) {
|
|
|
2193
2141
|
el.ifConditions.push(condition)
|
|
2194
2142
|
}
|
|
2195
2143
|
|
|
2196
|
-
function getIfConditions (el) {
|
|
2197
|
-
return el?.ifConditions || []
|
|
2198
|
-
}
|
|
2199
|
-
|
|
2200
2144
|
function postProcessIfReact (el) {
|
|
2201
|
-
let prevNode
|
|
2145
|
+
let prevNode
|
|
2202
2146
|
if (el.if) {
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
} else {
|
|
2213
|
-
replaceNode(el, getTempNode())._if = false
|
|
2214
|
-
}
|
|
2215
|
-
} else {
|
|
2216
|
-
el._if = null
|
|
2217
|
-
addIfCondition(el, {
|
|
2218
|
-
exp: el.if.exp,
|
|
2219
|
-
block: el
|
|
2220
|
-
})
|
|
2221
|
-
}
|
|
2222
|
-
} else if (el.elseif) {
|
|
2223
|
-
if (el.for) {
|
|
2224
|
-
error$1(`wx:elif (wx:elif="${el.elseif.raw}") invalidly used on the for-list <"${el.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the elif-directive to it`)
|
|
2225
|
-
return
|
|
2226
|
-
}
|
|
2227
|
-
|
|
2228
|
-
ifNode = findPrevNode(el)
|
|
2229
|
-
ifConditions = getIfConditions(ifNode)
|
|
2230
|
-
prevNode = ifConditions.length > 0 ? ifConditions[ifConditions.length - 1].block : ifNode
|
|
2231
|
-
|
|
2232
|
-
if (!prevNode || prevNode._if === undefined) {
|
|
2233
|
-
error$1(`wx:elif="${el.elseif.raw}" used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
|
|
2234
|
-
return
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
|
-
if (prevNode._if === true) {
|
|
2238
|
-
removeNode(el)
|
|
2239
|
-
} else if (prevNode._if === false) {
|
|
2240
|
-
el.if = el.elseif
|
|
2241
|
-
delete el.elseif
|
|
2242
|
-
postProcessIfReact(el)
|
|
2243
|
-
} else {
|
|
2244
|
-
result = evalExp(el.elseif.exp)
|
|
2245
|
-
if (result.success) {
|
|
2246
|
-
if (result.result) {
|
|
2247
|
-
delete el.elseif
|
|
2248
|
-
el._if = true
|
|
2249
|
-
addIfCondition(ifNode, {
|
|
2250
|
-
exp: el.elseif.exp,
|
|
2251
|
-
block: el
|
|
2252
|
-
})
|
|
2253
|
-
removeNode(el, true)
|
|
2254
|
-
} else {
|
|
2255
|
-
removeNode(el)
|
|
2256
|
-
}
|
|
2257
|
-
} else {
|
|
2258
|
-
el._if = null
|
|
2259
|
-
addIfCondition(ifNode, {
|
|
2260
|
-
exp: el.elseif.exp,
|
|
2261
|
-
block: el
|
|
2262
|
-
})
|
|
2263
|
-
removeNode(el, true)
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
} else if (el.else) {
|
|
2267
|
-
if (el.for) {
|
|
2268
|
-
error$1(`wx:else invalidly used on the for-list <"${el.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the else-directive to it`)
|
|
2269
|
-
return
|
|
2270
|
-
}
|
|
2271
|
-
|
|
2272
|
-
ifNode = findPrevNode(el)
|
|
2273
|
-
ifConditions = getIfConditions(ifNode)
|
|
2274
|
-
prevNode = ifConditions.length > 0 ? ifConditions[ifConditions.length - 1].block : ifNode
|
|
2275
|
-
|
|
2276
|
-
if (!prevNode || prevNode._if === undefined) {
|
|
2277
|
-
error$1(`wx:else used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
|
|
2278
|
-
return
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
if (prevNode._if === true) {
|
|
2282
|
-
removeNode(el)
|
|
2283
|
-
} else if (prevNode._if === false) {
|
|
2284
|
-
delete el.else
|
|
2285
|
-
} else {
|
|
2286
|
-
addIfCondition(ifNode, {
|
|
2147
|
+
addIfCondition(el, {
|
|
2148
|
+
exp: el.if.exp,
|
|
2149
|
+
block: el
|
|
2150
|
+
})
|
|
2151
|
+
} else if (el.elseif || el.else) {
|
|
2152
|
+
prevNode = findPrevNode(el)
|
|
2153
|
+
if (prevNode && prevNode.if) {
|
|
2154
|
+
addIfCondition(prevNode, {
|
|
2155
|
+
exp: el.elseif && el.elseif.exp,
|
|
2287
2156
|
block: el
|
|
2288
2157
|
})
|
|
2289
2158
|
removeNode(el, true)
|
|
2159
|
+
} else {
|
|
2160
|
+
warn$1(`wx:${el.elseif ? `elif="${el.elseif.raw}"` : 'else'} used on element [${el.tag}] without corresponding wx:if.`)
|
|
2290
2161
|
}
|
|
2291
2162
|
}
|
|
2292
2163
|
}
|
|
@@ -2653,16 +2524,6 @@ function getVirtualHostRoot (options, meta) {
|
|
|
2653
2524
|
if (isWeb(mode) && ctorType === 'page') {
|
|
2654
2525
|
return createASTElement('page')
|
|
2655
2526
|
}
|
|
2656
|
-
if (isReact(mode) && ctorType === 'page') {
|
|
2657
|
-
const rootView = createASTElement('view', [
|
|
2658
|
-
{
|
|
2659
|
-
name: 'class',
|
|
2660
|
-
value: MPX_TAG_PAGE_SELECTOR
|
|
2661
|
-
}
|
|
2662
|
-
])
|
|
2663
|
-
processElement(rootView, rootView, options, meta)
|
|
2664
|
-
return rootView
|
|
2665
|
-
}
|
|
2666
2527
|
}
|
|
2667
2528
|
return getTempNode()
|
|
2668
2529
|
}
|
|
@@ -2720,7 +2581,7 @@ function postProcessTemplate (el) {
|
|
|
2720
2581
|
}
|
|
2721
2582
|
}
|
|
2722
2583
|
|
|
2723
|
-
const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,tenon,ios,android,harmony,
|
|
2584
|
+
const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,tenon,ios,android,harmony,noMode')
|
|
2724
2585
|
|
|
2725
2586
|
function isValidModeP (i) {
|
|
2726
2587
|
return isValidMode(i[0] === '_' ? i.slice(1) : i)
|
|
@@ -2856,78 +2717,6 @@ function processNoTransAttrs (el) {
|
|
|
2856
2717
|
}
|
|
2857
2718
|
}
|
|
2858
2719
|
|
|
2859
|
-
function initCrossPlatformConfig () {
|
|
2860
|
-
// 定义平台与前缀的双向映射关系
|
|
2861
|
-
const platformPrefixMap = {
|
|
2862
|
-
wx: 'wx:',
|
|
2863
|
-
ali: 'a:',
|
|
2864
|
-
swan: 's-',
|
|
2865
|
-
qq: 'qq:',
|
|
2866
|
-
tt: 'tt:',
|
|
2867
|
-
dd: 'dd:',
|
|
2868
|
-
jd: 'jd:',
|
|
2869
|
-
qa: 'qa:',
|
|
2870
|
-
web: 'v-'
|
|
2871
|
-
}
|
|
2872
|
-
|
|
2873
|
-
if (isNoMode(mode)) {
|
|
2874
|
-
return null
|
|
2875
|
-
}
|
|
2876
|
-
|
|
2877
|
-
return {
|
|
2878
|
-
currentPrefix: platformPrefixMap[mode] || 'wx:',
|
|
2879
|
-
platformPrefixMap
|
|
2880
|
-
}
|
|
2881
|
-
}
|
|
2882
|
-
|
|
2883
|
-
// 检测跨平台语法使用情况并给出警告
|
|
2884
|
-
function processCrossPlatformSyntaxWarning (el) {
|
|
2885
|
-
// 使用转换后的属性列表进行检查
|
|
2886
|
-
if (!el.attrsList || el.attrsList.length === 0) {
|
|
2887
|
-
return
|
|
2888
|
-
}
|
|
2889
|
-
|
|
2890
|
-
// 如果配置为空,说明不需要检测
|
|
2891
|
-
if (!crossPlatformConfig) {
|
|
2892
|
-
return
|
|
2893
|
-
}
|
|
2894
|
-
|
|
2895
|
-
const { currentPrefix, platformPrefixMap } = crossPlatformConfig
|
|
2896
|
-
|
|
2897
|
-
// 检查转换后的属性列表
|
|
2898
|
-
el.attrsList.forEach(attr => {
|
|
2899
|
-
const attrName = attr.name
|
|
2900
|
-
|
|
2901
|
-
// 检查是否使用了平台前缀
|
|
2902
|
-
for (const [platformName, prefix] of Object.entries(platformPrefixMap)) {
|
|
2903
|
-
if (attrName.startsWith(prefix)) {
|
|
2904
|
-
if (isReact(mode)) {
|
|
2905
|
-
// React Native 平台:只允许使用 wx: 前缀,其他前缀报错
|
|
2906
|
-
if (prefix !== 'wx:') {
|
|
2907
|
-
error$1(
|
|
2908
|
-
`React Native mode "${mode}" does not support "${prefix}" prefix. ` +
|
|
2909
|
-
`Use "wx:" prefix instead. Found: "${attrName}"`
|
|
2910
|
-
)
|
|
2911
|
-
}
|
|
2912
|
-
} else {
|
|
2913
|
-
// 小程序平台:检测跨平台语法使用
|
|
2914
|
-
if (platformName !== mode) {
|
|
2915
|
-
// 构建建议的正确属性名
|
|
2916
|
-
const suffixPart = attrName.substring(prefix.length)
|
|
2917
|
-
const suggestedAttr = currentPrefix + suffixPart
|
|
2918
|
-
|
|
2919
|
-
warn$1(
|
|
2920
|
-
`Your target mode is "${mode}", but used "${attrName}". ` +
|
|
2921
|
-
`Did you mean "${suggestedAttr}"?`
|
|
2922
|
-
)
|
|
2923
|
-
}
|
|
2924
|
-
}
|
|
2925
|
-
break
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
|
-
})
|
|
2929
|
-
}
|
|
2930
|
-
|
|
2931
2720
|
function processMpxTagName (el) {
|
|
2932
2721
|
const mpxTagName = getAndRemoveAttr(el, 'mpxTagName').val
|
|
2933
2722
|
if (mpxTagName) {
|
|
@@ -2957,9 +2746,6 @@ function processElement (el, root, options, meta) {
|
|
|
2957
2746
|
|
|
2958
2747
|
processDuplicateAttrsList(el)
|
|
2959
2748
|
|
|
2960
|
-
// 检测跨平台语法使用情况并给出警告
|
|
2961
|
-
processCrossPlatformSyntaxWarning(el)
|
|
2962
|
-
|
|
2963
2749
|
processInjectWxs(el, meta, options)
|
|
2964
2750
|
|
|
2965
2751
|
const transAli = mode === 'ali' && srcMode === 'wx'
|
|
@@ -3104,7 +2890,7 @@ function cloneAttrsList (attrsList) {
|
|
|
3104
2890
|
}
|
|
3105
2891
|
|
|
3106
2892
|
function postProcessComponentIs (el, postProcessChild) {
|
|
3107
|
-
if (el.is && el.
|
|
2893
|
+
if (el.is && el.components) {
|
|
3108
2894
|
let tempNode
|
|
3109
2895
|
if (el.for || el.if || el.elseif || el.else) {
|
|
3110
2896
|
tempNode = createASTElement('block')
|
|
@@ -3114,12 +2900,11 @@ function postProcessComponentIs (el, postProcessChild) {
|
|
|
3114
2900
|
replaceNode(el, tempNode, true)
|
|
3115
2901
|
postMoveBaseDirective(tempNode, el)
|
|
3116
2902
|
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
const newChild = createASTElement(name, cloneAttrsList(el.attrsList), tempNode)
|
|
2903
|
+
el.components.forEach(function (component) {
|
|
2904
|
+
const newChild = createASTElement(component, cloneAttrsList(el.attrsList), tempNode)
|
|
3120
2905
|
newChild.if = {
|
|
3121
|
-
raw: `{{${el.is} === ${stringify(
|
|
3122
|
-
exp: `${el.is} === ${stringify(
|
|
2906
|
+
raw: `{{${el.is} === ${stringify(component)}}}`,
|
|
2907
|
+
exp: `${el.is} === ${stringify(component)}`
|
|
3123
2908
|
}
|
|
3124
2909
|
el.children.forEach((child) => {
|
|
3125
2910
|
addChild(newChild, cloneNode(child))
|
|
@@ -3244,12 +3029,30 @@ function genIf (node) {
|
|
|
3244
3029
|
|
|
3245
3030
|
function genElseif (node) {
|
|
3246
3031
|
node.elseifProcessed = true
|
|
3247
|
-
|
|
3032
|
+
if (node.for) {
|
|
3033
|
+
error$1(`wx:elif (wx:elif="${node.elseif.raw}") invalidly used on the for-list <"${node.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the if-directive to it`)
|
|
3034
|
+
return
|
|
3035
|
+
}
|
|
3036
|
+
const preNode = findPrevNode(node)
|
|
3037
|
+
if (preNode && (preNode.if || preNode.elseif)) {
|
|
3038
|
+
return `else if(${node.elseif.exp}){\n${genNode(node)}}\n`
|
|
3039
|
+
} else {
|
|
3040
|
+
error$1(`wx:elif (wx:elif="${node.elseif.raw}") invalidly used on the element <"${node.tag}"> without corresponding wx:if or wx:elif.`)
|
|
3041
|
+
}
|
|
3248
3042
|
}
|
|
3249
3043
|
|
|
3250
3044
|
function genElse (node) {
|
|
3251
3045
|
node.elseProcessed = true
|
|
3252
|
-
|
|
3046
|
+
if (node.for) {
|
|
3047
|
+
error$1(`wx:else invalidly used on the for-list <"${node.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the if-directive to it`)
|
|
3048
|
+
return
|
|
3049
|
+
}
|
|
3050
|
+
const preNode = findPrevNode(node)
|
|
3051
|
+
if (preNode && (preNode.if || preNode.elseif)) {
|
|
3052
|
+
return `else{\n${genNode(node)}}\n`
|
|
3053
|
+
} else {
|
|
3054
|
+
error$1(`wx:else invalidly used on the element <"${node.tag}"> without corresponding wx:if or wx:elif.`)
|
|
3055
|
+
}
|
|
3253
3056
|
}
|
|
3254
3057
|
|
|
3255
3058
|
function genExps (node) {
|
|
@@ -3262,7 +3065,7 @@ function genFor (node) {
|
|
|
3262
3065
|
node.forProcessed = true
|
|
3263
3066
|
const index = node.for.index || 'index'
|
|
3264
3067
|
const item = node.for.item || 'item'
|
|
3265
|
-
return `
|
|
3068
|
+
return `_i(${node.for.exp}, function(${item},${index}){\n${genNode(node)}});\n`
|
|
3266
3069
|
}
|
|
3267
3070
|
|
|
3268
3071
|
function genNode (node) {
|
|
@@ -3460,6 +3263,5 @@ module.exports = {
|
|
|
3460
3263
|
findPrevNode,
|
|
3461
3264
|
removeNode,
|
|
3462
3265
|
replaceNode,
|
|
3463
|
-
createASTElement
|
|
3464
|
-
evalExp
|
|
3266
|
+
createASTElement
|
|
3465
3267
|
}
|
|
@@ -9,8 +9,7 @@ function genIfConditions (conditions) {
|
|
|
9
9
|
if (!conditions.length) return 'null'
|
|
10
10
|
const condition = conditions.shift()
|
|
11
11
|
if (condition.exp) {
|
|
12
|
-
|
|
13
|
-
return `${condition.exp}?${genNode(condition.block)}:${genIfConditions(conditions)}`
|
|
12
|
+
return `(${condition.exp})?${genNode(condition.block)}:${genIfConditions(conditions)}`
|
|
14
13
|
} else {
|
|
15
14
|
return genNode(condition.block)
|
|
16
15
|
}
|
|
@@ -31,7 +30,7 @@ function mapAttrName (name) {
|
|
|
31
30
|
return name
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
function genNode (node
|
|
33
|
+
function genNode (node) {
|
|
35
34
|
let exp = ''
|
|
36
35
|
if (node) {
|
|
37
36
|
if (node.type === 3) {
|
|
@@ -73,29 +72,18 @@ function genNode (node, isRoot = false) {
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
if (!node.unary && node.children.length) {
|
|
76
|
-
|
|
75
|
+
exp += ','
|
|
76
|
+
exp += node.children.map((child) => {
|
|
77
77
|
return genNode(child)
|
|
78
78
|
}).filter(fragment => fragment).join(',')
|
|
79
|
-
|
|
80
|
-
// child可能为temp-node等无效节点,所以增加判断确保存在childNode再添加逗号
|
|
81
|
-
if (childNode) {
|
|
82
|
-
exp += ','
|
|
83
|
-
exp += childNode
|
|
84
|
-
}
|
|
85
79
|
}
|
|
86
80
|
exp += ')'
|
|
87
81
|
}
|
|
88
82
|
}
|
|
89
83
|
} else {
|
|
90
|
-
|
|
84
|
+
exp += node.children.map((child) => {
|
|
91
85
|
return genNode(child)
|
|
92
|
-
}).filter(fragment => fragment
|
|
93
|
-
if (isRoot && nodes.length > 1) {
|
|
94
|
-
// 如果存在多个根节点,使用 block 包裹
|
|
95
|
-
exp = `createElement(getComponent("block"), null, ${nodes.join(',')})`
|
|
96
|
-
} else {
|
|
97
|
-
exp += nodes.join(',')
|
|
98
|
-
}
|
|
86
|
+
}).filter(fragment => fragment).join(',')
|
|
99
87
|
}
|
|
100
88
|
}
|
|
101
89
|
}
|
|
@@ -24,15 +24,14 @@ module.exports = function (raw) {
|
|
|
24
24
|
const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
|
|
25
25
|
const wxsContentMap = mpx.wxsContentMap
|
|
26
26
|
const optimizeRenderRules = mpx.optimizeRenderRules
|
|
27
|
-
const usingComponentsInfo = queryObj.usingComponentsInfo
|
|
28
|
-
const originalUsingComponents = queryObj.originalUsingComponents ? JSON.parse(queryObj.originalUsingComponents) : []
|
|
27
|
+
const usingComponentsInfo = queryObj.usingComponentsInfo || {}
|
|
29
28
|
const componentPlaceholder = queryObj.componentPlaceholder || []
|
|
30
29
|
const hasComment = queryObj.hasComment
|
|
31
30
|
const isNative = queryObj.isNative
|
|
32
31
|
const ctorType = queryObj.ctorType
|
|
33
32
|
const hasScoped = queryObj.hasScoped
|
|
34
33
|
const runtimeCompile = queryObj.isDynamic
|
|
35
|
-
const moduleId = queryObj.moduleId || mpx.getModuleId(resourcePath
|
|
34
|
+
const moduleId = queryObj.moduleId || mpx.getModuleId(resourcePath)
|
|
36
35
|
|
|
37
36
|
let optimizeRenderLevel = 0
|
|
38
37
|
for (const rule of optimizeRenderRules) {
|
|
@@ -44,13 +43,13 @@ module.exports = function (raw) {
|
|
|
44
43
|
|
|
45
44
|
const warn = (msg) => {
|
|
46
45
|
this.emitWarning(
|
|
47
|
-
new Error('[
|
|
46
|
+
new Error('[template compiler][' + this.resource + ']: ' + msg)
|
|
48
47
|
)
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
const error = (msg) => {
|
|
52
51
|
this.emitError(
|
|
53
|
-
new Error('[
|
|
52
|
+
new Error('[template compiler][' + this.resource + ']: ' + msg)
|
|
54
53
|
)
|
|
55
54
|
}
|
|
56
55
|
|
|
@@ -71,7 +70,6 @@ module.exports = function (raw) {
|
|
|
71
70
|
hasScoped,
|
|
72
71
|
moduleId,
|
|
73
72
|
usingComponentsInfo,
|
|
74
|
-
originalUsingComponents,
|
|
75
73
|
// 这里需传递rawResourcePath和wxsContentMap保持一致
|
|
76
74
|
filePath: rawResourcePath,
|
|
77
75
|
i18n,
|
|
@@ -112,10 +110,10 @@ module.exports = function (raw) {
|
|
|
112
110
|
if (rawCode) {
|
|
113
111
|
try {
|
|
114
112
|
const ignoreMap = Object.assign({
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
_i: true,
|
|
114
|
+
_c: true,
|
|
115
|
+
_sc: true,
|
|
116
|
+
_r: true
|
|
119
117
|
}, meta.wxsModuleMap)
|
|
120
118
|
const bindResult = optimizeRenderLevel === 2
|
|
121
119
|
? bindThis.transformSimple(rawCode, {
|
|
@@ -126,9 +124,9 @@ module.exports = function (raw) {
|
|
|
126
124
|
renderReduce: optimizeRenderLevel === 1,
|
|
127
125
|
ignoreMap
|
|
128
126
|
})
|
|
129
|
-
resultSource += `global.currentInject.render = function (
|
|
127
|
+
resultSource += `global.currentInject.render = function (_i, _c, _r, _sc) {
|
|
130
128
|
${bindResult.code}
|
|
131
|
-
|
|
129
|
+
_r(${optimizeRenderLevel === 2 ? 'true' : ''});
|
|
132
130
|
};\n`
|
|
133
131
|
if ((mode === 'tt' || mode === 'swan') && bindResult.propKeys) {
|
|
134
132
|
resultSource += `global.currentInject.propKeys = ${JSON.stringify(bindResult.propKeys)};\n`
|
package/lib/utils/const.js
CHANGED