@mpxjs/webpack-plugin 2.10.16-beta.9 → 2.10.16-xp.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 -13
- 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 +11 -37
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +50 -61
- 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-swiper.jsx +9 -5
- 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 +17 -44
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +49 -69
- 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-swiper.tsx +9 -5
- 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 +71 -267
- 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 +4 -15
- package/lib/dependencies/RecordModuleIdMapDependency.js +0 -49
- package/lib/runtime/components/react/dist/context.d.ts +0 -76
- 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 -27
- package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.jsx +0 -197
- 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 -51
- 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 -275
- 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,7 +760,6 @@ function parse (template, options) {
|
|
|
763
760
|
if (!currentParent) genTempRoot()
|
|
764
761
|
|
|
765
762
|
const children = currentParent.children
|
|
766
|
-
|
|
767
763
|
if (currentParent.tag !== 'text') {
|
|
768
764
|
text = text.trim()
|
|
769
765
|
} else {
|
|
@@ -797,10 +793,9 @@ function parse (template, options) {
|
|
|
797
793
|
}
|
|
798
794
|
})
|
|
799
795
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
// }
|
|
796
|
+
if (multiRootError) {
|
|
797
|
+
error$1('Template fields should has one single root, considering wrapping your template content with <view> or <text> tag!')
|
|
798
|
+
}
|
|
804
799
|
|
|
805
800
|
if (hasI18n) {
|
|
806
801
|
if (i18nInjectableComputed.length) {
|
|
@@ -1005,34 +1000,12 @@ function processComponentIs (el, options) {
|
|
|
1005
1000
|
}
|
|
1006
1001
|
|
|
1007
1002
|
const range = getAndRemoveAttr(el, 'range').val
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
ranges = range.split(',').map(i => i.trim()).filter(i => i)
|
|
1013
|
-
} else {
|
|
1014
|
-
// 根据原始用户写的usingComponents字段生成ranges
|
|
1015
|
-
ranges = options.originalUsingComponents
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
const rangeMap = new Map()
|
|
1019
|
-
ranges.forEach(name => {
|
|
1020
|
-
rangeMap.set(['ali', 'swan'].includes(mode) ? capitalToHyphen(name) : name, name)
|
|
1021
|
-
})
|
|
1022
|
-
|
|
1023
|
-
// Map<CurrentName, SourceName>
|
|
1024
|
-
el.componentMap = new Map()
|
|
1025
|
-
usingComponents.forEach((name) => {
|
|
1026
|
-
if (rangeMap.size === 0) {
|
|
1027
|
-
el.componentMap.set(name, name)
|
|
1028
|
-
} else {
|
|
1029
|
-
if (rangeMap.has(name)) {
|
|
1030
|
-
el.componentMap.set(name, rangeMap.get(name))
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1003
|
+
const isInRange = makeMap(range || '')
|
|
1004
|
+
el.components = (usingComponents).filter(i => {
|
|
1005
|
+
if (!range) return true
|
|
1006
|
+
return isInRange(i)
|
|
1033
1007
|
})
|
|
1034
|
-
|
|
1035
|
-
if (el.componentMap.size === 0) {
|
|
1008
|
+
if (!el.components.length) {
|
|
1036
1009
|
warn$1('Component in which <component> tag is used must have a non blank usingComponents field')
|
|
1037
1010
|
}
|
|
1038
1011
|
|
|
@@ -1619,7 +1592,7 @@ function parseOptionalChaining (str) {
|
|
|
1619
1592
|
}
|
|
1620
1593
|
if (grammarMap.checkState() && haveNotGetValue) {
|
|
1621
1594
|
// 值查找结束但是语法未闭合或者处理到边界还未结束,抛异常
|
|
1622
|
-
throw new Error('[
|
|
1595
|
+
throw new Error('[optionChain] option value illegal!!!')
|
|
1623
1596
|
}
|
|
1624
1597
|
haveNotGetValue = true
|
|
1625
1598
|
let keyValue = ''
|
|
@@ -1669,7 +1642,7 @@ function parseOptionalChaining (str) {
|
|
|
1669
1642
|
}
|
|
1670
1643
|
if (grammarMap.checkState() && haveNotGetValue) {
|
|
1671
1644
|
// key值查找结束但是语法未闭合或者处理到边界还未结束,抛异常
|
|
1672
|
-
throw new Error('[
|
|
1645
|
+
throw new Error('[optionChain] option key illegal!!!')
|
|
1673
1646
|
}
|
|
1674
1647
|
if (keyValue) {
|
|
1675
1648
|
chainKey += `,'${keyValue}'`
|
|
@@ -1882,25 +1855,24 @@ function processRefReact (el, meta) {
|
|
|
1882
1855
|
/**
|
|
1883
1856
|
* selectorsConf: [type, [[prefix, selector], [prefix, selector]]]
|
|
1884
1857
|
*/
|
|
1885
|
-
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 {
|
|
1886
1873
|
meta.refs.push(refConf)
|
|
1887
1874
|
selectors.push({ prefix: '', selector: `"${refConf.key}"` })
|
|
1888
1875
|
}
|
|
1889
|
-
|
|
1890
|
-
const rawId = el.attrsMap.id
|
|
1891
|
-
const rawClass = el.attrsMap.class
|
|
1892
|
-
const rawDynamicClass = el.attrsMap[config[mode].directive.dynamicClass]
|
|
1893
|
-
|
|
1894
|
-
if (rawId) {
|
|
1895
|
-
const staticId = parseMustacheWithContext(rawId).result
|
|
1896
|
-
selectors.push({ prefix: '#', selector: `${staticId}` })
|
|
1897
|
-
}
|
|
1898
|
-
if (rawClass || rawDynamicClass) {
|
|
1899
|
-
const staticClass = parseMustacheWithContext(rawClass).result
|
|
1900
|
-
const dynamicClass = parseMustacheWithContext(rawDynamicClass).result
|
|
1901
|
-
selectors.push({ prefix: '.', selector: `this.__getClass(${staticClass}, ${dynamicClass})` })
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
1876
|
const selectorsConf = selectors.map(item => `["${item.prefix}", ${item.selector}]`)
|
|
1905
1877
|
const refFnId = forScopes.reduce((preV, curV) => {
|
|
1906
1878
|
return `${preV} + "_" + ${curV.index}`
|
|
@@ -2112,24 +2084,13 @@ function postProcessIf (el) {
|
|
|
2112
2084
|
replaceNode(el, getTempNode())._if = false
|
|
2113
2085
|
}
|
|
2114
2086
|
} else {
|
|
2115
|
-
el._if = null
|
|
2116
2087
|
attrs = [{
|
|
2117
2088
|
name: config[mode].directive.if,
|
|
2118
2089
|
value: el.if.raw
|
|
2119
2090
|
}]
|
|
2120
2091
|
}
|
|
2121
2092
|
} else if (el.elseif) {
|
|
2122
|
-
if (el.for) {
|
|
2123
|
-
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`)
|
|
2124
|
-
return
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
2093
|
prevNode = findPrevNode(el)
|
|
2128
|
-
if (!prevNode || prevNode._if === undefined) {
|
|
2129
|
-
error$1(`wx:elif="${el.elseif.raw}" used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
|
|
2130
|
-
return
|
|
2131
|
-
}
|
|
2132
|
-
|
|
2133
2094
|
if (prevNode._if === true) {
|
|
2134
2095
|
removeNode(el)
|
|
2135
2096
|
} else if (prevNode._if === false) {
|
|
@@ -2149,7 +2110,6 @@ function postProcessIf (el) {
|
|
|
2149
2110
|
removeNode(el)
|
|
2150
2111
|
}
|
|
2151
2112
|
} else {
|
|
2152
|
-
el._if = null
|
|
2153
2113
|
attrs = [{
|
|
2154
2114
|
name: config[mode].directive.elseif,
|
|
2155
2115
|
value: el.elseif.raw
|
|
@@ -2157,17 +2117,7 @@ function postProcessIf (el) {
|
|
|
2157
2117
|
}
|
|
2158
2118
|
}
|
|
2159
2119
|
} else if (el.else) {
|
|
2160
|
-
if (el.for) {
|
|
2161
|
-
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`)
|
|
2162
|
-
return
|
|
2163
|
-
}
|
|
2164
|
-
|
|
2165
2120
|
prevNode = findPrevNode(el)
|
|
2166
|
-
if (!prevNode || prevNode._if === undefined) {
|
|
2167
|
-
error$1(`wx:else used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
|
|
2168
|
-
return
|
|
2169
|
-
}
|
|
2170
|
-
|
|
2171
2121
|
if (prevNode._if === true) {
|
|
2172
2122
|
removeNode(el)
|
|
2173
2123
|
} else if (prevNode._if === false) {
|
|
@@ -2191,100 +2141,23 @@ function addIfCondition (el, condition) {
|
|
|
2191
2141
|
el.ifConditions.push(condition)
|
|
2192
2142
|
}
|
|
2193
2143
|
|
|
2194
|
-
function getIfConditions (el) {
|
|
2195
|
-
return el?.ifConditions || []
|
|
2196
|
-
}
|
|
2197
|
-
|
|
2198
2144
|
function postProcessIfReact (el) {
|
|
2199
|
-
let prevNode
|
|
2145
|
+
let prevNode
|
|
2200
2146
|
if (el.if) {
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
} else {
|
|
2211
|
-
replaceNode(el, getTempNode())._if = false
|
|
2212
|
-
}
|
|
2213
|
-
} else {
|
|
2214
|
-
el._if = null
|
|
2215
|
-
addIfCondition(el, {
|
|
2216
|
-
exp: el.if.exp,
|
|
2217
|
-
block: el
|
|
2218
|
-
})
|
|
2219
|
-
}
|
|
2220
|
-
} else if (el.elseif) {
|
|
2221
|
-
if (el.for) {
|
|
2222
|
-
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`)
|
|
2223
|
-
return
|
|
2224
|
-
}
|
|
2225
|
-
|
|
2226
|
-
ifNode = findPrevNode(el)
|
|
2227
|
-
ifConditions = getIfConditions(ifNode)
|
|
2228
|
-
prevNode = ifConditions.length > 0 ? ifConditions[ifConditions.length - 1].block : ifNode
|
|
2229
|
-
|
|
2230
|
-
if (!prevNode || prevNode._if === undefined) {
|
|
2231
|
-
error$1(`wx:elif="${el.elseif.raw}" used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
|
|
2232
|
-
return
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
if (prevNode._if === true) {
|
|
2236
|
-
removeNode(el)
|
|
2237
|
-
} else if (prevNode._if === false) {
|
|
2238
|
-
el.if = el.elseif
|
|
2239
|
-
delete el.elseif
|
|
2240
|
-
postProcessIfReact(el)
|
|
2241
|
-
} else {
|
|
2242
|
-
result = evalExp(el.elseif.exp)
|
|
2243
|
-
if (result.success) {
|
|
2244
|
-
if (result.result) {
|
|
2245
|
-
delete el.elseif
|
|
2246
|
-
el._if = true
|
|
2247
|
-
addIfCondition(ifNode, {
|
|
2248
|
-
exp: el.elseif.exp,
|
|
2249
|
-
block: el
|
|
2250
|
-
})
|
|
2251
|
-
removeNode(el, true)
|
|
2252
|
-
} else {
|
|
2253
|
-
removeNode(el)
|
|
2254
|
-
}
|
|
2255
|
-
} else {
|
|
2256
|
-
el._if = null
|
|
2257
|
-
addIfCondition(ifNode, {
|
|
2258
|
-
exp: el.elseif.exp,
|
|
2259
|
-
block: el
|
|
2260
|
-
})
|
|
2261
|
-
removeNode(el, true)
|
|
2262
|
-
}
|
|
2263
|
-
}
|
|
2264
|
-
} else if (el.else) {
|
|
2265
|
-
if (el.for) {
|
|
2266
|
-
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`)
|
|
2267
|
-
return
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2270
|
-
ifNode = findPrevNode(el)
|
|
2271
|
-
ifConditions = getIfConditions(ifNode)
|
|
2272
|
-
prevNode = ifConditions.length > 0 ? ifConditions[ifConditions.length - 1].block : ifNode
|
|
2273
|
-
|
|
2274
|
-
if (!prevNode || prevNode._if === undefined) {
|
|
2275
|
-
error$1(`wx:else used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
|
|
2276
|
-
return
|
|
2277
|
-
}
|
|
2278
|
-
|
|
2279
|
-
if (prevNode._if === true) {
|
|
2280
|
-
removeNode(el)
|
|
2281
|
-
} else if (prevNode._if === false) {
|
|
2282
|
-
delete el.else
|
|
2283
|
-
} else {
|
|
2284
|
-
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,
|
|
2285
2156
|
block: el
|
|
2286
2157
|
})
|
|
2287
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.`)
|
|
2288
2161
|
}
|
|
2289
2162
|
}
|
|
2290
2163
|
}
|
|
@@ -2651,16 +2524,6 @@ function getVirtualHostRoot (options, meta) {
|
|
|
2651
2524
|
if (isWeb(mode) && ctorType === 'page') {
|
|
2652
2525
|
return createASTElement('page')
|
|
2653
2526
|
}
|
|
2654
|
-
if (isReact(mode) && ctorType === 'page') {
|
|
2655
|
-
const rootView = createASTElement('view', [
|
|
2656
|
-
{
|
|
2657
|
-
name: 'class',
|
|
2658
|
-
value: MPX_TAG_PAGE_SELECTOR
|
|
2659
|
-
}
|
|
2660
|
-
])
|
|
2661
|
-
processElement(rootView, rootView, options, meta)
|
|
2662
|
-
return rootView
|
|
2663
|
-
}
|
|
2664
2527
|
}
|
|
2665
2528
|
return getTempNode()
|
|
2666
2529
|
}
|
|
@@ -2718,7 +2581,7 @@ function postProcessTemplate (el) {
|
|
|
2718
2581
|
}
|
|
2719
2582
|
}
|
|
2720
2583
|
|
|
2721
|
-
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')
|
|
2722
2585
|
|
|
2723
2586
|
function isValidModeP (i) {
|
|
2724
2587
|
return isValidMode(i[0] === '_' ? i.slice(1) : i)
|
|
@@ -2854,78 +2717,6 @@ function processNoTransAttrs (el) {
|
|
|
2854
2717
|
}
|
|
2855
2718
|
}
|
|
2856
2719
|
|
|
2857
|
-
function initCrossPlatformConfig () {
|
|
2858
|
-
// 定义平台与前缀的双向映射关系
|
|
2859
|
-
const platformPrefixMap = {
|
|
2860
|
-
wx: 'wx:',
|
|
2861
|
-
ali: 'a:',
|
|
2862
|
-
swan: 's-',
|
|
2863
|
-
qq: 'qq:',
|
|
2864
|
-
tt: 'tt:',
|
|
2865
|
-
dd: 'dd:',
|
|
2866
|
-
jd: 'jd:',
|
|
2867
|
-
qa: 'qa:',
|
|
2868
|
-
web: 'v-'
|
|
2869
|
-
}
|
|
2870
|
-
|
|
2871
|
-
if (isNoMode(mode)) {
|
|
2872
|
-
return null
|
|
2873
|
-
}
|
|
2874
|
-
|
|
2875
|
-
return {
|
|
2876
|
-
currentPrefix: platformPrefixMap[mode] || 'wx:',
|
|
2877
|
-
platformPrefixMap
|
|
2878
|
-
}
|
|
2879
|
-
}
|
|
2880
|
-
|
|
2881
|
-
// 检测跨平台语法使用情况并给出警告
|
|
2882
|
-
function processCrossPlatformSyntaxWarning (el) {
|
|
2883
|
-
// 使用转换后的属性列表进行检查
|
|
2884
|
-
if (!el.attrsList || el.attrsList.length === 0) {
|
|
2885
|
-
return
|
|
2886
|
-
}
|
|
2887
|
-
|
|
2888
|
-
// 如果配置为空,说明不需要检测
|
|
2889
|
-
if (!crossPlatformConfig) {
|
|
2890
|
-
return
|
|
2891
|
-
}
|
|
2892
|
-
|
|
2893
|
-
const { currentPrefix, platformPrefixMap } = crossPlatformConfig
|
|
2894
|
-
|
|
2895
|
-
// 检查转换后的属性列表
|
|
2896
|
-
el.attrsList.forEach(attr => {
|
|
2897
|
-
const attrName = attr.name
|
|
2898
|
-
|
|
2899
|
-
// 检查是否使用了平台前缀
|
|
2900
|
-
for (const [platformName, prefix] of Object.entries(platformPrefixMap)) {
|
|
2901
|
-
if (attrName.startsWith(prefix)) {
|
|
2902
|
-
if (isReact(mode)) {
|
|
2903
|
-
// React Native 平台:只允许使用 wx: 前缀,其他前缀报错
|
|
2904
|
-
if (prefix !== 'wx:') {
|
|
2905
|
-
error$1(
|
|
2906
|
-
`React Native mode "${mode}" does not support "${prefix}" prefix. ` +
|
|
2907
|
-
`Use "wx:" prefix instead. Found: "${attrName}"`
|
|
2908
|
-
)
|
|
2909
|
-
}
|
|
2910
|
-
} else {
|
|
2911
|
-
// 小程序平台:检测跨平台语法使用
|
|
2912
|
-
if (platformName !== mode) {
|
|
2913
|
-
// 构建建议的正确属性名
|
|
2914
|
-
const suffixPart = attrName.substring(prefix.length)
|
|
2915
|
-
const suggestedAttr = currentPrefix + suffixPart
|
|
2916
|
-
|
|
2917
|
-
warn$1(
|
|
2918
|
-
`Your target mode is "${mode}", but used "${attrName}". ` +
|
|
2919
|
-
`Did you mean "${suggestedAttr}"?`
|
|
2920
|
-
)
|
|
2921
|
-
}
|
|
2922
|
-
}
|
|
2923
|
-
break
|
|
2924
|
-
}
|
|
2925
|
-
}
|
|
2926
|
-
})
|
|
2927
|
-
}
|
|
2928
|
-
|
|
2929
2720
|
function processMpxTagName (el) {
|
|
2930
2721
|
const mpxTagName = getAndRemoveAttr(el, 'mpxTagName').val
|
|
2931
2722
|
if (mpxTagName) {
|
|
@@ -2955,9 +2746,6 @@ function processElement (el, root, options, meta) {
|
|
|
2955
2746
|
|
|
2956
2747
|
processDuplicateAttrsList(el)
|
|
2957
2748
|
|
|
2958
|
-
// 检测跨平台语法使用情况并给出警告
|
|
2959
|
-
processCrossPlatformSyntaxWarning(el)
|
|
2960
|
-
|
|
2961
2749
|
processInjectWxs(el, meta, options)
|
|
2962
2750
|
|
|
2963
2751
|
const transAli = mode === 'ali' && srcMode === 'wx'
|
|
@@ -3102,7 +2890,7 @@ function cloneAttrsList (attrsList) {
|
|
|
3102
2890
|
}
|
|
3103
2891
|
|
|
3104
2892
|
function postProcessComponentIs (el, postProcessChild) {
|
|
3105
|
-
if (el.is && el.
|
|
2893
|
+
if (el.is && el.components) {
|
|
3106
2894
|
let tempNode
|
|
3107
2895
|
if (el.for || el.if || el.elseif || el.else) {
|
|
3108
2896
|
tempNode = createASTElement('block')
|
|
@@ -3112,12 +2900,11 @@ function postProcessComponentIs (el, postProcessChild) {
|
|
|
3112
2900
|
replaceNode(el, tempNode, true)
|
|
3113
2901
|
postMoveBaseDirective(tempNode, el)
|
|
3114
2902
|
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
const newChild = createASTElement(name, cloneAttrsList(el.attrsList), tempNode)
|
|
2903
|
+
el.components.forEach(function (component) {
|
|
2904
|
+
const newChild = createASTElement(component, cloneAttrsList(el.attrsList), tempNode)
|
|
3118
2905
|
newChild.if = {
|
|
3119
|
-
raw: `{{${el.is} === ${stringify(
|
|
3120
|
-
exp: `${el.is} === ${stringify(
|
|
2906
|
+
raw: `{{${el.is} === ${stringify(component)}}}`,
|
|
2907
|
+
exp: `${el.is} === ${stringify(component)}`
|
|
3121
2908
|
}
|
|
3122
2909
|
el.children.forEach((child) => {
|
|
3123
2910
|
addChild(newChild, cloneNode(child))
|
|
@@ -3242,12 +3029,30 @@ function genIf (node) {
|
|
|
3242
3029
|
|
|
3243
3030
|
function genElseif (node) {
|
|
3244
3031
|
node.elseifProcessed = true
|
|
3245
|
-
|
|
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
|
+
}
|
|
3246
3042
|
}
|
|
3247
3043
|
|
|
3248
3044
|
function genElse (node) {
|
|
3249
3045
|
node.elseProcessed = true
|
|
3250
|
-
|
|
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
|
+
}
|
|
3251
3056
|
}
|
|
3252
3057
|
|
|
3253
3058
|
function genExps (node) {
|
|
@@ -3260,7 +3065,7 @@ function genFor (node) {
|
|
|
3260
3065
|
node.forProcessed = true
|
|
3261
3066
|
const index = node.for.index || 'index'
|
|
3262
3067
|
const item = node.for.item || 'item'
|
|
3263
|
-
return `
|
|
3068
|
+
return `_i(${node.for.exp}, function(${item},${index}){\n${genNode(node)}});\n`
|
|
3264
3069
|
}
|
|
3265
3070
|
|
|
3266
3071
|
function genNode (node) {
|
|
@@ -3458,6 +3263,5 @@ module.exports = {
|
|
|
3458
3263
|
findPrevNode,
|
|
3459
3264
|
removeNode,
|
|
3460
3265
|
replaceNode,
|
|
3461
|
-
createASTElement
|
|
3462
|
-
evalExp
|
|
3266
|
+
createASTElement
|
|
3463
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