-
Notifications
You must be signed in to change notification settings - Fork 389
Expand file tree
/
Copy pathindex.js
More file actions
151 lines (148 loc) · 5.15 KB
/
index.js
File metadata and controls
151 lines (148 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
const ad = require('./ad')
const block = require('./block')
const button = require('./button')
const camera = require('./camera')
const canvas = require('./canvas')
const checkboxGroup = require('./checkbox-group')
const checkbox = require('./checkbox')
const coverImage = require('./cover-image')
const coverView = require('./cover-view')
const form = require('./form')
const hyphenTagName = require('./hypen-tag-name')
const icon = require('./icon')
const image = require('./image')
const input = require('./input')
const livePlayer = require('./live-player')
const livePusher = require('./live-pusher')
const map = require('./map')
const movableArea = require('./movable-area')
const movableView = require('./movable-view')
const navigator = require('./navigator')
const pickerViewColumn = require('./picker-view-column')
const pickerView = require('./picker-view')
const picker = require('./picker')
const pageContainer = require('./page-container')
const progress = require('./progress')
const radioGroup = require('./radio-group')
const radio = require('./radio')
const richText = require('./rich-text')
const scrollView = require('./scroll-view')
const slider = require('./slider')
const swiperItem = require('./swiper-item')
const swiper = require('./swiper')
const switchComponent = require('./switch')
const template = require('./template')
const text = require('./text')
const textarea = require('./textarea')
const unsupported = require('./unsupported')
const video = require('./video')
const view = require('./view')
const webView = require('./web-view')
const label = require('./label')
const wxs = require('./wxs')
const fixComponentName = require('./fix-component-name')
const customBuiltInComponent = require('./custom-built-in-component')
const rootPortal = require('./root-portal')
const stickyHeader = require('./sticky-header')
const stickySection = require('./sticky-section')
/**
* 未命中上方任一组件 test 的标签,仍须走 normalizeComponentRules 中的通用
* 指令 / 属性 / 事件链路(如 wx 源码输出 ali 时 bindtap → onTap)。
* 历史上在 template/wx/index.js 里通过 normalizeComponentRules(cfgs.concat({}), spec)
* 末尾塞入空对象,由 run-rules 对缺省 test 退化为恒 true;此处改为显式配置且必须排在最后。
*/
function defaultCatchAllComponentConfig () {
return {
test () {
return true
}
}
}
module.exports = function getComponentConfigs ({ warn, error }) {
/**
* universal print for detail component warn or error
* @param {object} config
* @param {string} config.platform
* @param {string} config.tag
* @param {string} config.type 可填tag/property/value/event
* @return {function(*): Function}
*/
const print = ({ platform, tag, type = 'property', isError = false }) => (arg) => {
if (type === 'tag') {
error(`<${arg}> is not supported in ${platform} environment!`)
return
}
let msg
switch (type) {
case 'event':
msg = `<${tag}> does not support [bind${arg}] event in ${platform} environment!`
break
case 'property':
msg = `<${tag}> does not support [${arg && arg.name}] property in ${platform} environment!`
break
case 'value':
msg = `<${tag}>'s property '${arg && arg.name}' does not support '[${arg && arg.value}]' value in ${platform} environment!`
break
case 'tagRequiredProps':
msg = `<${tag}> should have '${arg}' attr in ali environment!`
break
case 'value-attr-uniform':
msg = `The internal attribute name of the <${tag}>'s attribute '${arg && arg.value}' is not supported in the ali environment, Please check!`
break
default:
msg = `<${tag}>'s transform has some error happened!`
}
isError ? error(msg) : warn(msg)
}
// 转换规则只需以微信为基准配置微信和支付宝的差异部分,比如微信和支付宝都支持但是写法不一致,或者微信支持而支付宝不支持的部分(抛出错误或警告)
return [
fixComponentName({ print }),
customBuiltInComponent(),
...unsupported({ print }),
ad({ print }),
view({ print }),
scrollView({ print }),
swiper({ print }),
swiperItem({ print }),
movableView({ print }),
movableArea({ print }),
coverView({ print }),
coverImage({ print }),
text({ print }),
richText({ print }),
progress({ print }),
button({ print }),
checkboxGroup({ print }),
checkbox({ print }),
radioGroup({ print }),
radio({ print }),
form({ print }),
input({ print }),
picker({ print }),
pageContainer({ print }),
pickerView({ print }),
pickerViewColumn({ print }),
slider({ print }),
switchComponent({ print }),
textarea({ print }),
navigator({ print }),
image({ print }),
map({ print }),
canvas({ print }),
wxs({ print }),
template(),
block(),
icon(),
webView({ print }),
video({ print }),
camera({ print }),
livePlayer({ print }),
livePusher({ print }),
hyphenTagName({ print }),
label({ print }),
rootPortal({ print }),
stickyHeader({ print }),
stickySection({ print }),
defaultCatchAllComponentConfig()
]
}