1 | module.exports = {
|
2 | wx: {
|
3 | typeExtMap: {
|
4 | json: '.json',
|
5 | script: '.js',
|
6 | template: '.wxml',
|
7 | styles: '.wxss'
|
8 | },
|
9 | tabBar: {
|
10 | itemKey: 'list',
|
11 | iconKey: 'iconPath',
|
12 | activeIconKey: 'selectedIconPath'
|
13 | },
|
14 | event: {
|
15 | parseEvent (attr) {
|
16 | let match = /^(bind|catch|capture-bind|capture-catch):?(.*?)(?:\.(.*))?$/.exec(attr)
|
17 | if (match) {
|
18 | return {
|
19 | prefix: match[1],
|
20 | eventName: match[2],
|
21 | modifier: match[3]
|
22 | }
|
23 | }
|
24 | },
|
25 | getEvent (eventName, prefix = 'bind') {
|
26 | return prefix + eventName
|
27 | },
|
28 | defaultModelProp: 'value',
|
29 | defaultModelEvent: 'input',
|
30 | defaultModelValuePath: 'value',
|
31 | shallowStringify (obj) {
|
32 | let arr = []
|
33 | for (let key in obj) {
|
34 | let value = obj[key]
|
35 | if (Array.isArray(value)) {
|
36 | value = `[${value.join(',')}]`
|
37 | }
|
38 | arr.push(`${key}:${value}`)
|
39 | }
|
40 | return ` {${arr.join(',')}} `
|
41 | }
|
42 | },
|
43 | wxs: {
|
44 | tag: 'wxs',
|
45 | module: 'module',
|
46 | src: 'src',
|
47 | ext: '.wxs',
|
48 | templatePrefix: 'module.exports = \n'
|
49 | },
|
50 | directive: {
|
51 | if: 'wx:if',
|
52 | elseif: 'wx:elif',
|
53 | else: 'wx:else',
|
54 | model: 'wx:model',
|
55 | modelProp: 'wx:model-prop',
|
56 | modelEvent: 'wx:model-event',
|
57 | modelValuePath: 'wx:model-value-path',
|
58 | modelFilter: 'wx:model-filter',
|
59 | for: 'wx:for',
|
60 | forIndex: 'wx:for-index',
|
61 | forItem: 'wx:for-item',
|
62 | key: 'wx:key',
|
63 | dynamicClass: 'wx:class',
|
64 | dynamicStyle: 'wx:style',
|
65 | ref: 'wx:ref',
|
66 | show: 'wx:show'
|
67 | }
|
68 | },
|
69 | ali: {
|
70 | typeExtMap: {
|
71 | json: '.json',
|
72 | script: '.js',
|
73 | template: '.axml',
|
74 | styles: '.acss'
|
75 | },
|
76 | tabBar: {
|
77 | itemKey: 'items',
|
78 | iconKey: 'icon',
|
79 | activeIconKey: 'activeIcon'
|
80 | },
|
81 | optionMenu: {
|
82 | iconKey: 'icon'
|
83 | },
|
84 | event: {
|
85 | parseEvent (attr) {
|
86 | let match = /^(on|catch)([A-Z].*?)(?:\.(.*))?$/.exec(attr)
|
87 | if (match) {
|
88 | return {
|
89 | prefix: match[1],
|
90 | eventName: match[2].replace(/^./, function (match) {
|
91 | return match.toLowerCase()
|
92 | }),
|
93 | modifier: match[3]
|
94 | }
|
95 | }
|
96 | },
|
97 | getEvent (eventName, prefix = 'on') {
|
98 | return prefix + eventName.replace(/^./, (matched) => {
|
99 | return matched.toUpperCase()
|
100 | })
|
101 | },
|
102 | defaultModelProp: 'value',
|
103 | defaultModelEvent: 'input',
|
104 | defaultModelValuePath: 'value',
|
105 | shallowStringify (obj) {
|
106 | let arr = []
|
107 | for (let key in obj) {
|
108 | let value = obj[key]
|
109 | if (Array.isArray(value)) {
|
110 | value = `[${value.join(',')}]`
|
111 | }
|
112 | arr.push(`${key}:${value}`)
|
113 | }
|
114 | return ` {${arr.join(',')}} `
|
115 | }
|
116 | },
|
117 | wxs: {
|
118 | tag: 'import-sjs',
|
119 | module: 'name',
|
120 | src: 'from',
|
121 | ext: '.sjs',
|
122 | templatePrefix: 'export default \n'
|
123 | },
|
124 | directive: {
|
125 | if: 'a:if',
|
126 | elseif: 'a:elif',
|
127 | else: 'a:else',
|
128 | model: 'a:model',
|
129 | modelProp: 'a:model-prop',
|
130 | modelEvent: 'a:model-event',
|
131 | modelValuePath: 'a:model-value-path',
|
132 | modelFilter: 'a:model-filter',
|
133 | for: 'a:for',
|
134 | forIndex: 'a:for-index',
|
135 | forItem: 'a:for-item',
|
136 | key: 'a:key',
|
137 | dynamicClass: 'a:class',
|
138 | dynamicStyle: 'a:style',
|
139 | ref: 'a:ref',
|
140 | show: 'a:show'
|
141 | },
|
142 | eventProxyIgnoreTagArr: ['map']
|
143 | },
|
144 | swan: {
|
145 | typeExtMap: {
|
146 | json: '.json',
|
147 | script: '.js',
|
148 | template: '.swan',
|
149 | styles: '.css'
|
150 | },
|
151 | tabBar: {
|
152 | itemKey: 'list',
|
153 | iconKey: 'iconPath',
|
154 | activeIconKey: 'selectedIconPath'
|
155 | },
|
156 | event: {
|
157 | parseEvent (attr) {
|
158 | let match = /^(bind|catch|capture-bind|capture-catch):?(.*?)(?:\.(.*))?$/.exec(attr)
|
159 | if (match) {
|
160 | return {
|
161 | prefix: match[1],
|
162 | eventName: match[2],
|
163 | modifier: match[3]
|
164 | }
|
165 | }
|
166 | },
|
167 | getEvent (eventName, prefix = 'bind') {
|
168 | return prefix + eventName
|
169 | },
|
170 | defaultModelProp: 'value',
|
171 | defaultModelEvent: 'input',
|
172 | defaultModelValuePath: 'value',
|
173 | shallowStringify (obj) {
|
174 | let arr = []
|
175 | for (let key in obj) {
|
176 | let value = obj[key]
|
177 | if (Array.isArray(value)) {
|
178 | value = `[${value.join(',')}]`
|
179 | }
|
180 | arr.push(`${key}:${value}`)
|
181 | }
|
182 | return ` {${arr.join(',')}} `
|
183 | }
|
184 | },
|
185 | wxs: {
|
186 | tag: 'filter',
|
187 | module: 'module',
|
188 | src: 'src',
|
189 | ext: '.filter.js',
|
190 | templatePrefix: 'var __swan_exports__ = \n'
|
191 | },
|
192 | directive: {
|
193 | if: 's-if',
|
194 | elseif: 's-elif',
|
195 | else: 's-else',
|
196 | model: 's-model',
|
197 | modelProp: 's-model-prop',
|
198 | modelEvent: 's-model-event',
|
199 | modelValuePath: 's-model-value-path',
|
200 | modelFilter: 's-model-filter',
|
201 | for: 's-for',
|
202 | forIndex: 's-for-index',
|
203 | forItem: 's-for-item',
|
204 | key: 's-key',
|
205 | dynamicClass: 's-class',
|
206 | dynamicStyle: 's-style',
|
207 | ref: 's-ref',
|
208 | show: 's-show'
|
209 | }
|
210 | },
|
211 | qq: {
|
212 | typeExtMap: {
|
213 | json: '.json',
|
214 | script: '.js',
|
215 | template: '.qml',
|
216 | styles: '.qss'
|
217 | },
|
218 | tabBar: {
|
219 | itemKey: 'list',
|
220 | iconKey: 'iconPath',
|
221 | activeIconKey: 'selectedIconPath'
|
222 | },
|
223 | event: {
|
224 | parseEvent (attr) {
|
225 | let match = /^(bind|catch|capture-bind|capture-catch):?(.*?)(?:\.(.*))?$/.exec(attr)
|
226 | if (match) {
|
227 | return {
|
228 | prefix: match[1],
|
229 | eventName: match[2],
|
230 | modifier: match[3]
|
231 | }
|
232 | }
|
233 | },
|
234 | getEvent (eventName, prefix = 'bind') {
|
235 | return prefix + eventName
|
236 | },
|
237 | defaultModelProp: 'value',
|
238 | defaultModelEvent: 'input',
|
239 | defaultModelValuePath: 'value',
|
240 | shallowStringify (obj) {
|
241 | let arr = []
|
242 | for (let key in obj) {
|
243 | let value = obj[key]
|
244 | if (Array.isArray(value)) {
|
245 | value = `[${value.join(',')}]`
|
246 | }
|
247 | arr.push(`${key}:${value}`)
|
248 | }
|
249 | return `({${arr.join(',')}})`
|
250 | }
|
251 | },
|
252 | wxs: {
|
253 | tag: 'qs',
|
254 | module: 'module',
|
255 | src: 'src',
|
256 | ext: '.qs',
|
257 | templatePrefix: 'module.exports = \n'
|
258 | },
|
259 | directive: {
|
260 | if: 'qq:if',
|
261 | elseif: 'qq:elif',
|
262 | else: 'qq:else',
|
263 | model: 'qq:model',
|
264 | modelProp: 'qq:model-prop',
|
265 | modelEvent: 'qq:model-event',
|
266 | modelValuePath: 'qq:model-value-path',
|
267 | modelFilter: 'qq:model-filter',
|
268 | for: 'qq:for',
|
269 | forIndex: 'qq:for-index',
|
270 | forItem: 'qq:for-item',
|
271 | key: 'qq:key',
|
272 | dynamicClass: 'qq:class',
|
273 | dynamicStyle: 'qq:style',
|
274 | ref: 'qq:ref',
|
275 | show: 'qq:show'
|
276 | }
|
277 | },
|
278 | tt: {
|
279 | typeExtMap: {
|
280 | json: '.json',
|
281 | script: '.js',
|
282 | template: '.ttml',
|
283 | styles: '.ttss'
|
284 | },
|
285 | tabBar: {
|
286 | itemKey: 'list',
|
287 | iconKey: 'iconPath',
|
288 | activeIconKey: 'selectedIconPath'
|
289 | },
|
290 | event: {
|
291 | parseEvent (attr) {
|
292 | let match = /^(bind)(.*?)(?:\.(.*))?$/.exec(attr)
|
293 | if (match) {
|
294 | return {
|
295 | prefix: match[1],
|
296 | eventName: match[2],
|
297 | modifier: match[3]
|
298 | }
|
299 | }
|
300 | },
|
301 | getEvent (eventName, prefix = 'bind') {
|
302 | return prefix + eventName
|
303 | },
|
304 | defaultModelProp: 'value',
|
305 | defaultModelEvent: 'input',
|
306 | defaultModelValuePath: 'value',
|
307 | shallowStringify (obj) {
|
308 | let arr = []
|
309 | for (let key in obj) {
|
310 | let value = obj[key]
|
311 | if (Array.isArray(value)) {
|
312 | value = `[${value.join(',')}]`
|
313 | }
|
314 | arr.push(`${key}:${value}`)
|
315 | }
|
316 | return ` {${arr.join(',')}} `
|
317 | }
|
318 | },
|
319 | wxs: {
|
320 | tag: 'ts',
|
321 | module: 'module',
|
322 | src: 'src',
|
323 | ext: '.ts',
|
324 | templatePrefix: 'module.exports = \n'
|
325 | },
|
326 | directive: {
|
327 | if: 'tt:if',
|
328 | elseif: 'tt:elif',
|
329 | else: 'tt:else',
|
330 | model: 'tt:model',
|
331 | modelProp: 'tt:model-prop',
|
332 | modelEvent: 'tt:model-event',
|
333 | modelValuePath: 'tt:model-value-path',
|
334 | modelFilter: 'tt:model-filter',
|
335 | for: 'tt:for',
|
336 | forIndex: 'tt:for-index',
|
337 | forItem: 'tt:for-item',
|
338 | key: 'tt:key',
|
339 | dynamicClass: 'tt:class',
|
340 | dynamicStyle: 'tt:style',
|
341 | ref: 'tt:ref',
|
342 | show: 'tt:show'
|
343 | }
|
344 | },
|
345 | web: {
|
346 | directive: {
|
347 | if: 'v-if',
|
348 | elseif: 'v-else-if',
|
349 | else: 'v-else'
|
350 | }
|
351 | }
|
352 | }
|