UNPKG

164 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
7var deindent = _interopDefault(require('de-indent'));
8var he = _interopDefault(require('he'));
9var babel = _interopDefault(require('babel-core'));
10var prettier = _interopDefault(require('prettier'));
11var t = require('babel-types');
12var generate = _interopDefault(require('babel-generator'));
13var template = _interopDefault(require('babel-template'));
14
15/* */
16
17// these helpers produces better vm code in JS engines due to their
18// explicitness and function inlining
19
20
21
22
23
24
25
26
27/**
28 * Check if value is primitive
29 */
30
31
32/**
33 * Quick object check - this is primarily used to tell
34 * Objects from primitive values when we know the value
35 * is a JSON-compliant type.
36 */
37function isObject (obj) {
38 return obj !== null && typeof obj === 'object'
39}
40
41var _toString = Object.prototype.toString;
42
43/**
44 * Strict object type check. Only returns true
45 * for plain JavaScript objects.
46 */
47function isPlainObject (obj) {
48 return _toString.call(obj) === '[object Object]'
49}
50
51
52
53/**
54 * Check if val is a valid array index.
55 */
56function isValidArrayIndex (val) {
57 var n = parseFloat(val);
58 return n >= 0 && Math.floor(n) === n && isFinite(val)
59}
60
61/**
62 * Convert a value to a string that is actually rendered.
63 */
64
65
66/**
67 * Convert a input value to a number for persistence.
68 * If the conversion fails, return original string.
69 */
70
71
72/**
73 * Make a map and return a function for checking if a key
74 * is in that map.
75 */
76function makeMap (
77 str,
78 expectsLowerCase
79) {
80 var map = Object.create(null);
81 var list = str.split(',');
82 for (var i = 0; i < list.length; i++) {
83 map[list[i]] = true;
84 }
85 return expectsLowerCase
86 ? function (val) { return map[val.toLowerCase()]; }
87 : function (val) { return map[val]; }
88}
89
90/**
91 * Check if a tag is a built-in tag.
92 */
93var isBuiltInTag = makeMap('slot,component', true);
94
95/**
96 * Check if a attribute is a reserved attribute.
97 */
98var isReservedAttribute = makeMap('key,ref,slot,is');
99
100/**
101 * Remove an item from an array
102 */
103function remove (arr, item) {
104 if (arr.length) {
105 var index = arr.indexOf(item);
106 if (index > -1) {
107 return arr.splice(index, 1)
108 }
109 }
110}
111
112/**
113 * Check whether the object has the property.
114 */
115var hasOwnProperty = Object.prototype.hasOwnProperty;
116function hasOwn (obj, key) {
117 return hasOwnProperty.call(obj, key)
118}
119
120/**
121 * Create a cached version of a pure function.
122 */
123function cached (fn) {
124 var cache = Object.create(null);
125 return (function cachedFn (str) {
126 var hit = cache[str];
127 return hit || (cache[str] = fn(str))
128 })
129}
130
131/**
132 * Camelize a hyphen-delimited string.
133 */
134var camelizeRE = /-(\w)/g;
135var camelize = cached(function (str) {
136 return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
137});
138
139/**
140 * Capitalize a string.
141 */
142
143
144/**
145 * Hyphenate a camelCase string.
146 */
147var hyphenateRE = /([^-])([A-Z])/g;
148var hyphenate = cached(function (str) {
149 return str
150 .replace(hyphenateRE, '$1-$2')
151 .replace(hyphenateRE, '$1-$2')
152 .toLowerCase()
153});
154
155/**
156 * Simple bind, faster than native
157 */
158
159
160/**
161 * Convert an Array-like object to a real Array.
162 */
163
164
165/**
166 * Mix properties into target object.
167 */
168function extend (to, _from) {
169 for (var key in _from) {
170 to[key] = _from[key];
171 }
172 return to
173}
174
175/**
176 * Merge an Array of Objects into a single Object.
177 */
178
179
180/**
181 * Perform no operation.
182 * Stubbing args to make Flow happy without leaving useless transpiled code
183 * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
184 */
185function noop (a, b, c) {}
186
187/**
188 * Always return false.
189 */
190var no = function (a, b, c) { return false; };
191
192/**
193 * Return same value
194 */
195var identity = function (_) { return _; };
196
197/**
198 * Generate a static keys string from compiler modules.
199 */
200function genStaticKeys (modules) {
201 return modules.reduce(function (keys, m) {
202 return keys.concat(m.staticKeys || [])
203 }, []).join(',')
204}
205
206/**
207 * Check if two values are loosely equal - that is,
208 * if they are plain objects, do they have the same shape?
209 */
210
211
212
213
214/**
215 * Ensure a function is called only once.
216 */
217
218/* */
219
220var isUnaryTag = makeMap(
221 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
222 'link,meta,param,source,track,wbr'
223);
224
225// Elements that you can, intentionally, leave open
226// (and which close themselves)
227var canBeLeftOpenTag = makeMap(
228 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
229);
230
231// HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
232// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
233var isNonPhrasingTag = makeMap(
234 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
235 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
236 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
237 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
238 'title,tr,track'
239);
240
241/**
242 * Not type-checking this file because it's mostly vendor code.
243 */
244
245/*!
246 * HTML Parser By John Resig (ejohn.org)
247 * Modified by Juriy "kangax" Zaytsev
248 * Original code by Erik Arvidsson, Mozilla Public License
249 * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
250 */
251
252// Regular Expressions for parsing tags and attributes
253var singleAttrIdentifier = /([^\s"'<>/=]+)/;
254var singleAttrAssign = /(?:=)/;
255var singleAttrValues = [
256 // attr value double quotes
257 /"([^"]*)"+/.source,
258 // attr value, single quotes
259 /'([^']*)'+/.source,
260 // attr value, no quotes
261 /([^\s"'=<>`]+)/.source
262];
263var attribute = new RegExp(
264 '^\\s*' + singleAttrIdentifier.source +
265 '(?:\\s*(' + singleAttrAssign.source + ')' +
266 '\\s*(?:' + singleAttrValues.join('|') + '))?'
267);
268
269// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
270// but for Vue templates we can enforce a simple charset
271var ncname = '[a-zA-Z_][\\w\\-\\.]*';
272var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
273var startTagOpen = new RegExp('^<' + qnameCapture);
274var startTagClose = /^\s*(\/?)>/;
275var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
276var doctype = /^<!DOCTYPE [^>]+>/i;
277var comment = /^<!--/;
278var conditionalComment = /^<!\[/;
279
280var IS_REGEX_CAPTURING_BROKEN = false;
281'x'.replace(/x(.)?/g, function (m, g) {
282 IS_REGEX_CAPTURING_BROKEN = g === '';
283});
284
285// Special Elements (can contain anything)
286var isPlainTextElement = makeMap('script,style,textarea', true);
287var reCache = {};
288
289var decodingMap = {
290 '&lt;': '<',
291 '&gt;': '>',
292 '&quot;': '"',
293 '&amp;': '&',
294 '&#10;': '\n'
295};
296var encodedAttr = /&(?:lt|gt|quot|amp);/g;
297var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g;
298
299// #5992
300var isIgnoreNewlineTag = makeMap('pre,textarea', true);
301var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
302
303function decodeAttr (value, shouldDecodeNewlines) {
304 var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
305 return value.replace(re, function (match) { return decodingMap[match]; })
306}
307
308function parseHTML (html, options) {
309 var stack = [];
310 var expectHTML = options.expectHTML;
311 var isUnaryTag$$1 = options.isUnaryTag || no;
312 var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
313 var index = 0;
314 var last, lastTag;
315 while (html) {
316 last = html;
317 // Make sure we're not in a plaintext content element like script/style
318 if (!lastTag || !isPlainTextElement(lastTag)) {
319 if (shouldIgnoreFirstNewline(lastTag, html)) {
320 advance(1);
321 }
322 var textEnd = html.indexOf('<');
323 if (textEnd === 0) {
324 // Comment:
325 if (comment.test(html)) {
326 var commentEnd = html.indexOf('-->');
327
328 if (commentEnd >= 0) {
329 if (options.shouldKeepComment) {
330 options.comment(html.substring(4, commentEnd));
331 }
332 advance(commentEnd + 3);
333 continue
334 }
335 }
336
337 // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
338 if (conditionalComment.test(html)) {
339 var conditionalEnd = html.indexOf(']>');
340
341 if (conditionalEnd >= 0) {
342 advance(conditionalEnd + 2);
343 continue
344 }
345 }
346
347 // Doctype:
348 var doctypeMatch = html.match(doctype);
349 if (doctypeMatch) {
350 advance(doctypeMatch[0].length);
351 continue
352 }
353
354 // End tag:
355 var endTagMatch = html.match(endTag);
356 if (endTagMatch) {
357 var curIndex = index;
358 advance(endTagMatch[0].length);
359 parseEndTag(endTagMatch[1], curIndex, index);
360 continue
361 }
362
363 // Start tag:
364 var startTagMatch = parseStartTag();
365 if (startTagMatch) {
366 handleStartTag(startTagMatch);
367 continue
368 }
369 }
370
371 var text = (void 0), rest = (void 0), next = (void 0);
372 if (textEnd >= 0) {
373 rest = html.slice(textEnd);
374 while (
375 !endTag.test(rest) &&
376 !startTagOpen.test(rest) &&
377 !comment.test(rest) &&
378 !conditionalComment.test(rest)
379 ) {
380 // < in plain text, be forgiving and treat it as text
381 next = rest.indexOf('<', 1);
382 if (next < 0) { break }
383 textEnd += next;
384 rest = html.slice(textEnd);
385 }
386 text = html.substring(0, textEnd);
387 advance(textEnd);
388 }
389
390 if (textEnd < 0) {
391 text = html;
392 html = '';
393 }
394
395 if (options.chars && text) {
396 options.chars(text);
397 }
398 } else {
399 var endTagLength = 0;
400 var stackedTag = lastTag.toLowerCase();
401 var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
402 var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
403 endTagLength = endTag.length;
404 if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
405 text = text
406 .replace(/<!--([\s\S]*?)-->/g, '$1')
407 .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
408 }
409 if (shouldIgnoreFirstNewline(stackedTag, text)) {
410 text = text.slice(1);
411 }
412 if (options.chars) {
413 options.chars(text);
414 }
415 return ''
416 });
417 index += html.length - rest$1.length;
418 html = rest$1;
419 parseEndTag(stackedTag, index - endTagLength, index);
420 }
421
422 if (html === last) {
423 options.chars && options.chars(html);
424 if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
425 options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
426 }
427 break
428 }
429 }
430
431 // Clean up any remaining tags
432 parseEndTag();
433
434 function advance (n) {
435 index += n;
436 html = html.substring(n);
437 }
438
439 function parseStartTag () {
440 var start = html.match(startTagOpen);
441 if (start) {
442 var match = {
443 tagName: start[1],
444 attrs: [],
445 start: index
446 };
447 advance(start[0].length);
448 var end, attr;
449 while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
450 advance(attr[0].length);
451 match.attrs.push(attr);
452 }
453 if (end) {
454 match.unarySlash = end[1];
455 advance(end[0].length);
456 match.end = index;
457 return match
458 }
459 }
460 }
461
462 function handleStartTag (match) {
463 var tagName = match.tagName;
464 var unarySlash = match.unarySlash;
465
466 if (expectHTML) {
467 if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
468 parseEndTag(lastTag);
469 }
470 if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
471 parseEndTag(tagName);
472 }
473 }
474
475 var unary = isUnaryTag$$1(tagName) || !!unarySlash;
476
477 var l = match.attrs.length;
478 var attrs = new Array(l);
479 for (var i = 0; i < l; i++) {
480 var args = match.attrs[i];
481 // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
482 if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
483 if (args[3] === '') { delete args[3]; }
484 if (args[4] === '') { delete args[4]; }
485 if (args[5] === '') { delete args[5]; }
486 }
487 var value = args[3] || args[4] || args[5] || '';
488 attrs[i] = {
489 name: args[1],
490 value: decodeAttr(
491 value,
492 options.shouldDecodeNewlines
493 )
494 };
495 }
496
497 if (!unary) {
498 stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
499 lastTag = tagName;
500 }
501
502 if (options.start) {
503 options.start(tagName, attrs, unary, match.start, match.end);
504 }
505 }
506
507 function parseEndTag (tagName, start, end) {
508 var pos, lowerCasedTagName;
509 if (start == null) { start = index; }
510 if (end == null) { end = index; }
511
512 if (tagName) {
513 lowerCasedTagName = tagName.toLowerCase();
514 }
515
516 // Find the closest opened tag of the same type
517 if (tagName) {
518 for (pos = stack.length - 1; pos >= 0; pos--) {
519 if (stack[pos].lowerCasedTag === lowerCasedTagName) {
520 break
521 }
522 }
523 } else {
524 // If no tag name is provided, clean shop
525 pos = 0;
526 }
527
528 if (pos >= 0) {
529 // Close all the open elements, up the stack
530 for (var i = stack.length - 1; i >= pos; i--) {
531 if (process.env.NODE_ENV !== 'production' &&
532 (i > pos || !tagName) &&
533 options.warn
534 ) {
535 options.warn(
536 ("tag <" + (stack[i].tag) + "> has no matching end tag.")
537 );
538 }
539 if (options.end) {
540 options.end(stack[i].tag, start, end);
541 }
542 }
543
544 // Remove the open elements from the stack
545 stack.length = pos;
546 lastTag = pos && stack[pos - 1].tag;
547 } else if (lowerCasedTagName === 'br') {
548 if (options.start) {
549 options.start(tagName, [], true, start, end);
550 }
551 } else if (lowerCasedTagName === 'p') {
552 if (options.start) {
553 options.start(tagName, [], false, start, end);
554 }
555 if (options.end) {
556 options.end(tagName, start, end);
557 }
558 }
559 }
560}
561
562/* */
563
564var splitRE = /\r?\n/g;
565var replaceRE = /./g;
566var isSpecialTag = makeMap('script,style,template', true);
567
568
569
570/**
571 * Parse a single-file component (*.vue) file into an SFC Descriptor Object.
572 */
573function parseComponent (
574 content,
575 options
576 ) {
577 if ( options === void 0 ) options = {};
578
579 var sfc = {
580 template: null,
581 script: null,
582 styles: [],
583 customBlocks: []
584 };
585 var depth = 0;
586 var currentBlock = null;
587
588 function start (
589 tag,
590 attrs,
591 unary,
592 start,
593 end
594 ) {
595 if (depth === 0) {
596 currentBlock = {
597 type: tag,
598 content: '',
599 start: end,
600 attrs: attrs.reduce(function (cumulated, ref) {
601 var name = ref.name;
602 var value = ref.value;
603
604 cumulated[name] = value || true;
605 return cumulated
606 }, Object.create(null))
607 };
608 if (isSpecialTag(tag)) {
609 checkAttrs(currentBlock, attrs);
610 if (tag === 'style') {
611 sfc.styles.push(currentBlock);
612 } else {
613 sfc[tag] = currentBlock;
614 }
615 } else { // custom blocks
616 sfc.customBlocks.push(currentBlock);
617 }
618 }
619 if (!unary) {
620 depth++;
621 }
622 }
623
624 function checkAttrs (block, attrs) {
625 for (var i = 0; i < attrs.length; i++) {
626 var attr = attrs[i];
627 if (attr.name === 'lang') {
628 block.lang = attr.value;
629 }
630 if (attr.name === 'scoped') {
631 block.scoped = true;
632 }
633 if (attr.name === 'module') {
634 block.module = attr.value || true;
635 }
636 if (attr.name === 'src') {
637 block.src = attr.value;
638 }
639 }
640 }
641
642 function end (tag, start, end) {
643 if (depth === 1 && currentBlock) {
644 currentBlock.end = start;
645 var text = deindent(content.slice(currentBlock.start, currentBlock.end));
646 // pad content so that linters and pre-processors can output correct
647 // line numbers in errors and warnings
648 if (currentBlock.type !== 'template' && options.pad) {
649 text = padContent(currentBlock, options.pad) + text;
650 }
651 currentBlock.content = text;
652 currentBlock = null;
653 }
654 depth--;
655 }
656
657 function padContent (block, pad) {
658 if (pad === 'space') {
659 return content.slice(0, block.start).replace(replaceRE, ' ')
660 } else {
661 var offset = content.slice(0, block.start).split(splitRE).length;
662 var padChar = block.type === 'script' && !block.lang
663 ? '//\n'
664 : '\n';
665 return Array(offset).join(padChar)
666 }
667 }
668
669 parseHTML(content, {
670 start: start,
671 end: end
672 });
673
674 return sfc
675}
676
677/* globals renderer */
678
679var isPreTag = function (tag) { return tag === 'pre'; };
680
681var isReservedTag = makeMap(
682 'template,script,style,element,content,slot,link,meta,svg,view,' +
683 'a,div,img,image,text,span,richtext,input,switch,textarea,spinner,select,' +
684 'slider,slider-neighbor,indicator,trisition,trisition-group,canvas,' +
685 'list,cell,header,loading,loading-indicator,refresh,scrollable,scroller,' +
686 'video,web,embed,tabbar,tabheader,datepicker,timepicker,marquee,countdown',
687 true
688);
689
690// these are reserved for web because they are directly compiled away
691// during template compilation
692var isReservedAttr = makeMap('style,class');
693
694// Elements that you can, intentionally, leave open (and which close themselves)
695// more flexable than web
696var canBeLeftOpenTag$1 = makeMap(
697 'web,spinner,switch,video,textarea,canvas,' +
698 'indicator,marquee,countdown',
699 true
700);
701
702var isUnaryTag$1 = makeMap(
703 'embed,img,image,input,link,meta',
704 true
705);
706
707function mustUseProp () { /* console.log('mustUseProp') */ }
708function getTagNamespace () { /* console.log('getTagNamespace') */ }
709
710
711
712
713
714
715// 用于小程序的 event type 到 web 的 event
716
717/* */
718
719var validDivisionCharRE = /[\w).+\-_$\]]/;
720
721function parseFilters (exp) {
722 var inSingle = false;
723 var inDouble = false;
724 var inTemplateString = false;
725 var inRegex = false;
726 var curly = 0;
727 var square = 0;
728 var paren = 0;
729 var lastFilterIndex = 0;
730 var c, prev, i, expression, filters;
731
732 for (i = 0; i < exp.length; i++) {
733 prev = c;
734 c = exp.charCodeAt(i);
735 if (inSingle) {
736 if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
737 } else if (inDouble) {
738 if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
739 } else if (inTemplateString) {
740 if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
741 } else if (inRegex) {
742 if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
743 } else if (
744 c === 0x7C && // pipe
745 exp.charCodeAt(i + 1) !== 0x7C &&
746 exp.charCodeAt(i - 1) !== 0x7C &&
747 !curly && !square && !paren
748 ) {
749 if (expression === undefined) {
750 // first filter, end of expression
751 lastFilterIndex = i + 1;
752 expression = exp.slice(0, i).trim();
753 } else {
754 pushFilter();
755 }
756 } else {
757 switch (c) {
758 case 0x22: inDouble = true; break // "
759 case 0x27: inSingle = true; break // '
760 case 0x60: inTemplateString = true; break // `
761 case 0x28: paren++; break // (
762 case 0x29: paren--; break // )
763 case 0x5B: square++; break // [
764 case 0x5D: square--; break // ]
765 case 0x7B: curly++; break // {
766 case 0x7D: curly--; break // }
767 }
768 if (c === 0x2f) { // /
769 var j = i - 1;
770 var p = (void 0);
771 // find first non-whitespace prev char
772 for (; j >= 0; j--) {
773 p = exp.charAt(j);
774 if (p !== ' ') { break }
775 }
776 if (!p || !validDivisionCharRE.test(p)) {
777 inRegex = true;
778 }
779 }
780 }
781 }
782
783 if (expression === undefined) {
784 expression = exp.slice(0, i).trim();
785 } else if (lastFilterIndex !== 0) {
786 pushFilter();
787 }
788
789 function pushFilter () {
790 (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
791 lastFilterIndex = i + 1;
792 }
793
794 if (filters) {
795 for (i = 0; i < filters.length; i++) {
796 expression = wrapFilter(expression, filters[i]);
797 }
798 }
799
800 return expression
801}
802
803function wrapFilter (exp, filter) {
804 var i = filter.indexOf('(');
805 if (i < 0) {
806 // _f: resolveFilter
807 return ("_f(\"" + filter + "\")(" + exp + ")")
808 } else {
809 var name = filter.slice(0, i);
810 var args = filter.slice(i + 1);
811 return ("_f(\"" + name + "\")(" + exp + "," + args)
812 }
813}
814
815/* */
816
817var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
818var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
819
820var buildRegex = cached(function (delimiters) {
821 var open = delimiters[0].replace(regexEscapeRE, '\\$&');
822 var close = delimiters[1].replace(regexEscapeRE, '\\$&');
823 return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
824});
825
826function parseText (
827 text,
828 delimiters
829) {
830 var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
831 if (!tagRE.test(text)) {
832 return
833 }
834 var tokens = [];
835 var lastIndex = tagRE.lastIndex = 0;
836 var match, index;
837 while ((match = tagRE.exec(text))) {
838 index = match.index;
839 // push text token
840 if (index > lastIndex) {
841 tokens.push(JSON.stringify(text.slice(lastIndex, index)));
842 }
843 // tag token
844 var exp = parseFilters(match[1].trim());
845 tokens.push(("_s(" + exp + ")"));
846 lastIndex = index + match[0].length;
847 }
848 if (lastIndex < text.length) {
849 tokens.push(JSON.stringify(text.slice(lastIndex)));
850 }
851 return tokens.join('+')
852}
853
854/* */
855
856function baseWarn (msg) {
857 console.error(("[Vue compiler]: " + msg));
858}
859
860function pluckModuleFunction (
861 modules,
862 key
863) {
864 return modules
865 ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
866 : []
867}
868
869function addProp (el, name, value) {
870 (el.props || (el.props = [])).push({ name: name, value: value });
871}
872
873function addAttr (el, name, value) {
874 (el.attrs || (el.attrs = [])).push({ name: name, value: value });
875}
876
877function addDirective (
878 el,
879 name,
880 rawName,
881 value,
882 arg,
883 modifiers
884) {
885 (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
886}
887
888function addHandler (
889 el,
890 name,
891 value,
892 modifiers,
893 important,
894 warn
895) {
896 // warn prevent and passive modifier
897 /* istanbul ignore if */
898 if (
899 process.env.NODE_ENV !== 'production' && warn &&
900 modifiers && modifiers.prevent && modifiers.passive
901 ) {
902 warn(
903 'passive and prevent can\'t be used together. ' +
904 'Passive handler can\'t prevent default event.'
905 );
906 }
907 // check capture modifier
908 if (modifiers && modifiers.capture) {
909 delete modifiers.capture;
910 name = '!' + name; // mark the event as captured
911 }
912 if (modifiers && modifiers.once) {
913 delete modifiers.once;
914 name = '~' + name; // mark the event as once
915 }
916 /* istanbul ignore if */
917 if (modifiers && modifiers.passive) {
918 delete modifiers.passive;
919 name = '&' + name; // mark the event as passive
920 }
921 var events;
922 if (modifiers && modifiers.native) {
923 delete modifiers.native;
924 events = el.nativeEvents || (el.nativeEvents = {});
925 } else {
926 events = el.events || (el.events = {});
927 }
928 var newHandler = { value: value, modifiers: modifiers };
929 var handlers = events[name];
930 /* istanbul ignore if */
931 if (Array.isArray(handlers)) {
932 important ? handlers.unshift(newHandler) : handlers.push(newHandler);
933 } else if (handlers) {
934 events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
935 } else {
936 events[name] = newHandler;
937 }
938}
939
940function getBindingAttr (
941 el,
942 name,
943 getStatic
944) {
945 var dynamicValue =
946 getAndRemoveAttr(el, ':' + name) ||
947 getAndRemoveAttr(el, 'v-bind:' + name);
948 if (dynamicValue != null) {
949 return parseFilters(dynamicValue)
950 } else if (getStatic !== false) {
951 var staticValue = getAndRemoveAttr(el, name);
952 if (staticValue != null) {
953 return JSON.stringify(staticValue)
954 }
955 }
956}
957
958function getAndRemoveAttr (el, name) {
959 var val;
960 if ((val = el.attrsMap[name]) != null) {
961 var list = el.attrsList;
962 for (var i = 0, l = list.length; i < l; i++) {
963 if (list[i].name === name) {
964 list.splice(i, 1);
965 break
966 }
967 }
968 }
969 return val
970}
971
972/* */
973
974function transformNode (el, options) {
975 var warn = options.warn || baseWarn;
976 var staticClass = getAndRemoveAttr(el, 'class');
977 if (process.env.NODE_ENV !== 'production' && staticClass) {
978 var expression = parseText(staticClass, options.delimiters);
979 if (expression) {
980 warn(
981 "class=\"" + staticClass + "\": " +
982 'Interpolation inside attributes has been removed. ' +
983 'Use v-bind or the colon shorthand instead. For example, ' +
984 'instead of <div class="{{ val }}">, use <div :class="val">.'
985 );
986 }
987 }
988 if (staticClass) {
989 el.staticClass = JSON.stringify(staticClass);
990 }
991 var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
992 if (classBinding) {
993 el.classBinding = classBinding;
994 }
995}
996
997function genData (el) {
998 var data = '';
999 if (el.staticClass) {
1000 data += "staticClass:" + (el.staticClass) + ",";
1001 }
1002 if (el.classBinding) {
1003 data += "class:" + (el.classBinding) + ",";
1004 }
1005 return data
1006}
1007
1008var klass = {
1009 staticKeys: ['staticClass'],
1010 transformNode: transformNode,
1011 genData: genData
1012};
1013
1014/* */
1015
1016var parseStyleText = cached(function (cssText) {
1017 var res = {};
1018 var listDelimiter = /;(?![^(]*\))/g;
1019 var propertyDelimiter = /:(.+)/;
1020 cssText.split(listDelimiter).forEach(function (item) {
1021 if (item) {
1022 var tmp = item.split(propertyDelimiter);
1023 tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
1024 }
1025 });
1026 return res
1027});
1028
1029// normalize possible array / string values into Object
1030
1031
1032/**
1033 * parent component style should be after child's
1034 * so that parent component's style could override it
1035 */
1036
1037/* */
1038
1039function transformNode$1 (el, options) {
1040 var warn = options.warn || baseWarn;
1041 var staticStyle = getAndRemoveAttr(el, 'style');
1042 if (staticStyle) {
1043 /* istanbul ignore if */
1044 if (process.env.NODE_ENV !== 'production') {
1045 var expression = parseText(staticStyle, options.delimiters);
1046 if (expression) {
1047 warn(
1048 "style=\"" + staticStyle + "\": " +
1049 'Interpolation inside attributes has been removed. ' +
1050 'Use v-bind or the colon shorthand instead. For example, ' +
1051 'instead of <div style="{{ val }}">, use <div :style="val">.'
1052 );
1053 }
1054 }
1055 el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
1056 }
1057
1058 var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
1059 if (styleBinding) {
1060 el.styleBinding = styleBinding;
1061 }
1062}
1063
1064function genData$1 (el) {
1065 var data = '';
1066 if (el.staticStyle) {
1067 data += "staticStyle:" + (el.staticStyle) + ",";
1068 }
1069 if (el.styleBinding) {
1070 data += "style:(" + (el.styleBinding) + "),";
1071 }
1072 return data
1073}
1074
1075var style = {
1076 staticKeys: ['staticStyle'],
1077 transformNode: transformNode$1,
1078 genData: genData$1
1079};
1080
1081var modules = [
1082 klass,
1083 style
1084];
1085
1086var ASSET_TYPES = [
1087 'component',
1088 'directive',
1089 'filter'
1090];
1091
1092var LIFECYCLE_HOOKS = [
1093 'beforeCreate',
1094 'created',
1095 'beforeMount',
1096 'mounted',
1097 'beforeUpdate',
1098 'updated',
1099 'beforeDestroy',
1100 'destroyed',
1101 'activated',
1102 'deactivated', 'onLaunch',
1103 'onLoad',
1104 'onShow',
1105 'onReady',
1106 'onHide',
1107 'onUnload',
1108 'onPullDownRefresh',
1109 'onReachBottom',
1110 'onShareAppMessage',
1111 'onPageScroll',
1112 'onTabItemTap',
1113 'attached',
1114 'ready',
1115 'moved',
1116 'detached'
1117];
1118
1119/* */
1120
1121var config = ({
1122 /**
1123 * Option merge strategies (used in core/util/options)
1124 */
1125 optionMergeStrategies: Object.create(null),
1126
1127 /**
1128 * Whether to suppress warnings.
1129 */
1130 silent: false,
1131
1132 /**
1133 * Show production mode tip message on boot?
1134 */
1135 productionTip: process.env.NODE_ENV !== 'production',
1136
1137 /**
1138 * Whether to enable devtools
1139 */
1140 devtools: process.env.NODE_ENV !== 'production',
1141
1142 /**
1143 * Whether to record perf
1144 */
1145 performance: false,
1146
1147 /**
1148 * Error handler for watcher errors
1149 */
1150 errorHandler: null,
1151
1152 /**
1153 * Warn handler for watcher warns
1154 */
1155 warnHandler: null,
1156
1157 /**
1158 * Ignore certain custom elements
1159 */
1160 ignoredElements: [],
1161
1162 /**
1163 * Custom user key aliases for v-on
1164 */
1165 keyCodes: Object.create(null),
1166
1167 /**
1168 * Check if a tag is reserved so that it cannot be registered as a
1169 * component. This is platform-dependent and may be overwritten.
1170 */
1171 isReservedTag: no,
1172
1173 /**
1174 * Check if an attribute is reserved so that it cannot be used as a component
1175 * prop. This is platform-dependent and may be overwritten.
1176 */
1177 isReservedAttr: no,
1178
1179 /**
1180 * Check if a tag is an unknown element.
1181 * Platform-dependent.
1182 */
1183 isUnknownElement: no,
1184
1185 /**
1186 * Get the namespace of an element
1187 */
1188 getTagNamespace: noop,
1189
1190 /**
1191 * Parse the real tag name for the specific platform.
1192 */
1193 parsePlatformTagName: identity,
1194
1195 /**
1196 * Check if an attribute must be bound using property, e.g. value
1197 * Platform-dependent.
1198 */
1199 mustUseProp: no,
1200
1201 /**
1202 * Exposed for legacy reasons
1203 */
1204 _lifecycleHooks: LIFECYCLE_HOOKS
1205});
1206
1207/* */
1208
1209/**
1210 * Cross-platform code generation for component v-model
1211 */
1212function genComponentModel (
1213 el,
1214 value,
1215 modifiers
1216) {
1217 var ref = modifiers || {};
1218 var number = ref.number;
1219 var trim = ref.trim;
1220
1221 var baseValueExpression = '$$v';
1222 var valueExpression = baseValueExpression;
1223 if (trim) {
1224 valueExpression =
1225 "(typeof " + baseValueExpression + " === 'string'" +
1226 "? " + baseValueExpression + ".trim()" +
1227 ": " + baseValueExpression + ")";
1228 }
1229 if (number) {
1230 valueExpression = "_n(" + valueExpression + ")";
1231 }
1232 var assignment = genAssignmentCode(value, valueExpression);
1233
1234 el.model = {
1235 value: ("(" + value + ")"),
1236 expression: ("\"" + value + "\""),
1237 callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
1238 };
1239}
1240
1241/**
1242 * Cross-platform codegen helper for generating v-model value assignment code.
1243 */
1244function genAssignmentCode (
1245 value,
1246 assignment
1247) {
1248 var modelRs = parseModel(value);
1249 if (modelRs.idx === null) {
1250 return (value + "=" + assignment)
1251 } else {
1252 return ("$set(" + (modelRs.exp) + ", " + (modelRs.idx) + ", " + assignment + ")")
1253 }
1254}
1255
1256/**
1257 * parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
1258 *
1259 * for loop possible cases:
1260 *
1261 * - test
1262 * - test[idx]
1263 * - test[test1[idx]]
1264 * - test["a"][idx]
1265 * - xxx.test[a[a].test1[idx]]
1266 * - test.xxx.a["asa"][test1[idx]]
1267 *
1268 */
1269
1270var len;
1271var str;
1272var chr;
1273var index;
1274var expressionPos;
1275var expressionEndPos;
1276
1277function parseModel (val) {
1278 str = val;
1279 len = str.length;
1280 index = expressionPos = expressionEndPos = 0;
1281
1282 if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
1283 return {
1284 exp: val,
1285 idx: null
1286 }
1287 }
1288
1289 while (!eof()) {
1290 chr = next();
1291 /* istanbul ignore if */
1292 if (isStringStart(chr)) {
1293 parseString(chr);
1294 } else if (chr === 0x5B) {
1295 parseBracket(chr);
1296 }
1297 }
1298
1299 return {
1300 exp: val.substring(0, expressionPos),
1301 idx: val.substring(expressionPos + 1, expressionEndPos)
1302 }
1303}
1304
1305function next () {
1306 return str.charCodeAt(++index)
1307}
1308
1309function eof () {
1310 return index >= len
1311}
1312
1313function isStringStart (chr) {
1314 return chr === 0x22 || chr === 0x27
1315}
1316
1317function parseBracket (chr) {
1318 var inBracket = 1;
1319 expressionPos = index;
1320 while (!eof()) {
1321 chr = next();
1322 if (isStringStart(chr)) {
1323 parseString(chr);
1324 continue
1325 }
1326 if (chr === 0x5B) { inBracket++; }
1327 if (chr === 0x5D) { inBracket--; }
1328 if (inBracket === 0) {
1329 expressionEndPos = index;
1330 break
1331 }
1332 }
1333}
1334
1335function parseString (chr) {
1336 var stringQuote = chr;
1337 while (!eof()) {
1338 chr = next();
1339 if (chr === stringQuote) {
1340 break
1341 }
1342 }
1343}
1344
1345/* */
1346
1347var warn;
1348
1349// in some cases, the event used has to be determined at runtime
1350// so we used some reserved tokens during compile.
1351var RANGE_TOKEN = '__r';
1352var CHECKBOX_RADIO_TOKEN = '__c';
1353
1354function model (
1355 el,
1356 dir,
1357 _warn
1358) {
1359 warn = _warn;
1360 var value = dir.value;
1361 var modifiers = dir.modifiers;
1362 var tag = el.tag;
1363 var type = el.attrsMap.type;
1364
1365 if (process.env.NODE_ENV !== 'production') {
1366 var dynamicType = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
1367 if (tag === 'input' && dynamicType) {
1368 warn(
1369 "<input :type=\"" + dynamicType + "\" v-model=\"" + value + "\">:\n" +
1370 "v-model does not support dynamic input types. Use v-if branches instead."
1371 );
1372 }
1373 // inputs with type="file" are read only and setting the input's
1374 // value will throw an error.
1375 if (tag === 'input' && type === 'file') {
1376 warn(
1377 "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
1378 "File inputs are read only. Use a v-on:change listener instead."
1379 );
1380 }
1381 }
1382
1383 if (el.component) {
1384 genComponentModel(el, value, modifiers);
1385 // component v-model doesn't need extra runtime
1386 return false
1387 } else if (tag === 'select') {
1388 genSelect(el, value, modifiers);
1389 } else if (tag === 'input' && type === 'checkbox') {
1390 genCheckboxModel(el, value, modifiers);
1391 } else if (tag === 'input' && type === 'radio') {
1392 genRadioModel(el, value, modifiers);
1393 } else if (tag === 'input' || tag === 'textarea') {
1394 genDefaultModel(el, value, modifiers);
1395 } else if (!config.isReservedTag(tag)) {
1396 genComponentModel(el, value, modifiers);
1397 // component v-model doesn't need extra runtime
1398 return false
1399 } else if (process.env.NODE_ENV !== 'production') {
1400 warn(
1401 "<" + (el.tag) + " v-model=\"" + value + "\">: " +
1402 "v-model is not supported on this element type. " +
1403 'If you are working with contenteditable, it\'s recommended to ' +
1404 'wrap a library dedicated for that purpose inside a custom component.'
1405 );
1406 }
1407
1408 // ensure runtime directive metadata
1409 return true
1410}
1411
1412function genCheckboxModel (
1413 el,
1414 value,
1415 modifiers
1416) {
1417 var number = modifiers && modifiers.number;
1418 var valueBinding = getBindingAttr(el, 'value') || 'null';
1419 var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
1420 var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
1421 addProp(el, 'checked',
1422 "Array.isArray(" + value + ")" +
1423 "?_i(" + value + "," + valueBinding + ")>-1" + (
1424 trueValueBinding === 'true'
1425 ? (":(" + value + ")")
1426 : (":_q(" + value + "," + trueValueBinding + ")")
1427 )
1428 );
1429 addHandler(el, CHECKBOX_RADIO_TOKEN,
1430 "var $$a=" + value + "," +
1431 '$$el=$event.target,' +
1432 "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
1433 'if(Array.isArray($$a)){' +
1434 "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
1435 '$$i=_i($$a,$$v);' +
1436 "if($$c){$$i<0&&(" + value + "=$$a.concat($$v))}" +
1437 "else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
1438 "}else{" + (genAssignmentCode(value, '$$c')) + "}",
1439 null, true
1440 );
1441}
1442
1443function genRadioModel (
1444 el,
1445 value,
1446 modifiers
1447) {
1448 var number = modifiers && modifiers.number;
1449 var valueBinding = getBindingAttr(el, 'value') || 'null';
1450 valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
1451 addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
1452 addHandler(el, CHECKBOX_RADIO_TOKEN, genAssignmentCode(value, valueBinding), null, true);
1453}
1454
1455function genSelect (
1456 el,
1457 value,
1458 modifiers
1459) {
1460 var number = modifiers && modifiers.number;
1461 var selectedVal = "Array.prototype.filter" +
1462 ".call($event.target.options,function(o){return o.selected})" +
1463 ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
1464 "return " + (number ? '_n(val)' : 'val') + "})";
1465
1466 var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
1467 var code = "var $$selectedVal = " + selectedVal + ";";
1468 code = code + " " + (genAssignmentCode(value, assignment));
1469 addHandler(el, 'change', code, null, true);
1470}
1471
1472function genDefaultModel (
1473 el,
1474 value,
1475 modifiers
1476) {
1477 var type = el.attrsMap.type;
1478 var ref = modifiers || {};
1479 var lazy = ref.lazy;
1480 var number = ref.number;
1481 var trim = ref.trim;
1482 var needCompositionGuard = !lazy && type !== 'range';
1483 var event = lazy
1484 ? 'change'
1485 : type === 'range'
1486 ? RANGE_TOKEN
1487 : 'input';
1488
1489 var valueExpression = '$event.target.value';
1490 if (trim) {
1491 valueExpression = "$event.target.value.trim()";
1492 }
1493 if (number) {
1494 valueExpression = "_n(" + valueExpression + ")";
1495 }
1496
1497 var code = genAssignmentCode(value, valueExpression);
1498 if (needCompositionGuard) {
1499 code = "if($event.target.composing)return;" + code;
1500 }
1501
1502 addProp(el, 'value', ("(" + value + ")"));
1503 addHandler(el, event, code, null, true);
1504 if (trim || number) {
1505 addHandler(el, 'blur', '$forceUpdate()');
1506 }
1507}
1508
1509/* */
1510
1511function text (el, dir) {
1512 if (dir.value) {
1513 addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
1514 }
1515}
1516
1517/* */
1518
1519function html (el, dir) {
1520 if (dir.value) {
1521 addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
1522 }
1523}
1524
1525var directives = {
1526 model: model,
1527 text: text,
1528 html: html
1529};
1530
1531/* */
1532
1533var isUnaryTag$2 = makeMap(
1534 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
1535 'link,meta,param,source,track,wbr'
1536);
1537
1538// Elements that you can, intentionally, leave open
1539// (and which close themselves)
1540var canBeLeftOpenTag$2 = makeMap(
1541 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
1542);
1543
1544// HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
1545// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
1546var isNonPhrasingTag$1 = makeMap(
1547 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
1548 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
1549 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
1550 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
1551 'title,tr,track'
1552);
1553
1554/* */
1555
1556var baseOptions = {
1557 expectHTML: true,
1558 modules: modules,
1559 directives: directives,
1560 isPreTag: isPreTag,
1561 isUnaryTag: isUnaryTag$2,
1562 mustUseProp: mustUseProp,
1563 canBeLeftOpenTag: canBeLeftOpenTag$2,
1564 isReservedTag: isReservedTag,
1565 getTagNamespace: getTagNamespace,
1566 staticKeys: genStaticKeys(modules)
1567};
1568
1569/* */
1570
1571var warn$2 = noop;
1572var tip = noop;
1573var formatComponentName = (null); // work around flow check
1574
1575if (process.env.NODE_ENV !== 'production') {
1576 var hasConsole = typeof console !== 'undefined';
1577 var classifyRE = /(?:^|[-_])(\w)/g;
1578 var classify = function (str) { return str
1579 .replace(classifyRE, function (c) { return c.toUpperCase(); })
1580 .replace(/[-_]/g, ''); };
1581
1582 warn$2 = function (msg, vm) {
1583 var trace = vm ? generateComponentTrace(vm) : '';
1584
1585 if (config.warnHandler) {
1586 config.warnHandler.call(null, msg, vm, trace);
1587 } else if (hasConsole && (!config.silent)) {
1588 console.error(("[Vue warn]: " + msg + trace));
1589 }
1590 };
1591
1592 tip = function (msg, vm) {
1593 if (hasConsole && (!config.silent)) {
1594 console.warn("[Vue tip]: " + msg + (
1595 vm ? generateComponentTrace(vm) : ''
1596 ));
1597 }
1598 };
1599
1600 formatComponentName = function (vm, includeFile) {
1601 if (vm.$root === vm) {
1602 return '<Root>'
1603 }
1604 var name = typeof vm === 'string'
1605 ? vm
1606 : typeof vm === 'function' && vm.options
1607 ? vm.options.name
1608 : vm._isVue
1609 ? vm.$options.name || vm.$options._componentTag
1610 : vm.name;
1611
1612 var file = vm._isVue && vm.$options.__file;
1613 if (!name && file) {
1614 var match = file.match(/([^/\\]+)\.vue$/);
1615 name = match && match[1];
1616 }
1617
1618 return (
1619 (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
1620 (file && includeFile !== false ? (" at " + file) : '')
1621 )
1622 };
1623
1624 var repeat = function (str, n) {
1625 var res = '';
1626 while (n) {
1627 if (n % 2 === 1) { res += str; }
1628 if (n > 1) { str += str; }
1629 n >>= 1;
1630 }
1631 return res
1632 };
1633
1634 var generateComponentTrace = function (vm) {
1635 if (vm._isVue && vm.$parent) {
1636 var tree = [];
1637 var currentRecursiveSequence = 0;
1638 while (vm) {
1639 if (tree.length > 0) {
1640 var last = tree[tree.length - 1];
1641 if (last.constructor === vm.constructor) {
1642 currentRecursiveSequence++;
1643 vm = vm.$parent;
1644 continue
1645 } else if (currentRecursiveSequence > 0) {
1646 tree[tree.length - 1] = [last, currentRecursiveSequence];
1647 currentRecursiveSequence = 0;
1648 }
1649 }
1650 tree.push(vm);
1651 vm = vm.$parent;
1652 }
1653 return '\n\nfound in\n\n' + tree
1654 .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
1655 ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
1656 : formatComponentName(vm))); })
1657 .join('\n')
1658 } else {
1659 return ("\n\n(found in " + (formatComponentName(vm)) + ")")
1660 }
1661 };
1662}
1663
1664/* */
1665
1666function handleError (err, vm, info) {
1667 if (config.errorHandler) {
1668 config.errorHandler.call(null, err, vm, info);
1669 } else {
1670 if (process.env.NODE_ENV !== 'production') {
1671 warn$2(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
1672 }
1673 /* istanbul ignore else */
1674 if (inBrowser && typeof console !== 'undefined') {
1675 console.error(err);
1676 } else {
1677 throw err
1678 }
1679 }
1680}
1681
1682/* */
1683
1684// can we use __proto__?
1685var hasProto = '__proto__' in {};
1686
1687// Browser environment sniffing
1688var inBrowser = typeof window !== 'undefined';
1689var UA = ['mpvue-runtime'].join();
1690var isIE = UA && /msie|trident/.test(UA);
1691var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
1692var isEdge = UA && UA.indexOf('edge/') > 0;
1693var isAndroid = UA && UA.indexOf('android') > 0;
1694var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
1695var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
1696
1697// Firefix has a "watch" function on Object.prototype...
1698var nativeWatch = ({}).watch;
1699
1700var supportsPassive = false;
1701if (inBrowser) {
1702 try {
1703 var opts = {};
1704 Object.defineProperty(opts, 'passive', ({
1705 get: function get () {
1706 /* istanbul ignore next */
1707 supportsPassive = true;
1708 }
1709 })); // https://github.com/facebook/flow/issues/285
1710 window.addEventListener('test-passive', null, opts);
1711 } catch (e) {}
1712}
1713
1714// this needs to be lazy-evaled because vue may be required before
1715// vue-server-renderer can set VUE_ENV
1716var _isServer;
1717var isServerRendering = function () {
1718 if (_isServer === undefined) {
1719 /* istanbul ignore if */
1720 if (!inBrowser && typeof global !== 'undefined') {
1721 // detect presence of vue-server-renderer and avoid
1722 // Webpack shimming the process
1723 _isServer = global['process'].env.VUE_ENV === 'server';
1724 } else {
1725 _isServer = false;
1726 }
1727 }
1728 return _isServer
1729};
1730
1731// detect devtools
1732
1733
1734/* istanbul ignore next */
1735function isNative (Ctor) {
1736 return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
1737}
1738
1739var hasSymbol =
1740 typeof Symbol !== 'undefined' && isNative(Symbol) &&
1741 typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
1742
1743/**
1744 * Defer a task to execute it asynchronously.
1745 */
1746var nextTick = (function () {
1747 var callbacks = [];
1748 var pending = false;
1749 var timerFunc;
1750
1751 function nextTickHandler () {
1752 pending = false;
1753 var copies = callbacks.slice(0);
1754 callbacks.length = 0;
1755 for (var i = 0; i < copies.length; i++) {
1756 copies[i]();
1757 }
1758 }
1759
1760 // the nextTick behavior leverages the microtask queue, which can be accessed
1761 // via either native Promise.then or MutationObserver.
1762 // MutationObserver has wider support, however it is seriously bugged in
1763 // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
1764 // completely stops working after triggering a few times... so, if native
1765 // Promise is available, we will use it:
1766 /* istanbul ignore if */
1767 if (typeof Promise !== 'undefined' && isNative(Promise)) {
1768 var p = Promise.resolve();
1769 var logError = function (err) { console.error(err); };
1770 timerFunc = function () {
1771 p.then(nextTickHandler).catch(logError);
1772 // in problematic UIWebViews, Promise.then doesn't completely break, but
1773 // it can get stuck in a weird state where callbacks are pushed into the
1774 // microtask queue but the queue isn't being flushed, until the browser
1775 // needs to do some other work, e.g. handle a timer. Therefore we can
1776 // "force" the microtask queue to be flushed by adding an empty timer.
1777 if (isIOS) { setTimeout(noop); }
1778 };
1779 // } else if (typeof MutationObserver !== 'undefined' && (
1780 // isNative(MutationObserver) ||
1781 // // PhantomJS and iOS 7.x
1782 // MutationObserver.toString() === '[object MutationObserverConstructor]'
1783 // )) {
1784 // // use MutationObserver where native Promise is not available,
1785 // // e.g. PhantomJS IE11, iOS7, Android 4.4
1786 // var counter = 1
1787 // var observer = new MutationObserver(nextTickHandler)
1788 // var textNode = document.createTextNode(String(counter))
1789 // observer.observe(textNode, {
1790 // characterData: true
1791 // })
1792 // timerFunc = () => {
1793 // counter = (counter + 1) % 2
1794 // textNode.data = String(counter)
1795 // }
1796 } else {
1797 // fallback to setTimeout
1798 /* istanbul ignore next */
1799 timerFunc = function () {
1800 setTimeout(nextTickHandler, 0);
1801 };
1802 }
1803
1804 return function queueNextTick (cb, ctx) {
1805 var _resolve;
1806 callbacks.push(function () {
1807 if (cb) {
1808 try {
1809 cb.call(ctx);
1810 } catch (e) {
1811 handleError(e, ctx, 'nextTick');
1812 }
1813 } else if (_resolve) {
1814 _resolve(ctx);
1815 }
1816 });
1817 if (!pending) {
1818 pending = true;
1819 timerFunc();
1820 }
1821 if (!cb && typeof Promise !== 'undefined') {
1822 return new Promise(function (resolve, reject) {
1823 _resolve = resolve;
1824 })
1825 }
1826 }
1827})();
1828
1829var _Set;
1830/* istanbul ignore if */
1831if (typeof Set !== 'undefined' && isNative(Set)) {
1832 // use native Set when available.
1833 _Set = Set;
1834} else {
1835 // a non-standard Set polyfill that only works with primitive keys.
1836 _Set = (function () {
1837 function Set () {
1838 this.set = Object.create(null);
1839 }
1840 Set.prototype.has = function has (key) {
1841 return this.set[key] === true
1842 };
1843 Set.prototype.add = function add (key) {
1844 this.set[key] = true;
1845 };
1846 Set.prototype.clear = function clear () {
1847 this.set = Object.create(null);
1848 };
1849
1850 return Set;
1851 }());
1852}
1853
1854/* */
1855
1856var onRE = /^@|^v-on:/;
1857var dirRE = /^v-|^@|^:/;
1858var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
1859var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/;
1860
1861var argRE = /:(.*)$/;
1862var bindRE = /^:|^v-bind:/;
1863var modifierRE = /\.[^.]+/g;
1864
1865var decodeHTMLCached = cached(he.decode);
1866
1867// configurable state
1868var warn$1;
1869var delimiters;
1870var transforms;
1871var preTransforms;
1872var postTransforms;
1873var platformIsPreTag;
1874var platformMustUseProp;
1875var platformGetTagNamespace;
1876
1877/**
1878 * Convert HTML string to AST.
1879 */
1880function parse (
1881 template$$1,
1882 options
1883) {
1884 warn$1 = options.warn || baseWarn;
1885
1886 platformIsPreTag = options.isPreTag || no;
1887 platformMustUseProp = options.mustUseProp || no;
1888 platformGetTagNamespace = options.getTagNamespace || no;
1889
1890 transforms = pluckModuleFunction(options.modules, 'transformNode');
1891 preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
1892 postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
1893
1894 delimiters = options.delimiters;
1895
1896 var stack = [];
1897 var preserveWhitespace = options.preserveWhitespace !== false;
1898 var root;
1899 var currentParent;
1900 var inVPre = false;
1901 var inPre = false;
1902 var warned = false;
1903
1904 function warnOnce (msg) {
1905 if (!warned) {
1906 warned = true;
1907 warn$1(msg);
1908 }
1909 }
1910
1911 function endPre (element) {
1912 // check pre state
1913 if (element.pre) {
1914 inVPre = false;
1915 }
1916 if (platformIsPreTag(element.tag)) {
1917 inPre = false;
1918 }
1919 }
1920
1921 parseHTML(template$$1, {
1922 warn: warn$1,
1923 expectHTML: options.expectHTML,
1924 isUnaryTag: options.isUnaryTag,
1925 canBeLeftOpenTag: options.canBeLeftOpenTag,
1926 shouldDecodeNewlines: options.shouldDecodeNewlines,
1927 shouldKeepComment: options.comments,
1928 start: function start (tag, attrs, unary) {
1929 // check namespace.
1930 // inherit parent ns if there is one
1931 var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
1932
1933 // handle IE svg bug
1934 /* istanbul ignore if */
1935 if (isIE && ns === 'svg') {
1936 attrs = guardIESVGBug(attrs);
1937 }
1938
1939 var element = {
1940 type: 1,
1941 tag: tag,
1942 attrsList: attrs,
1943 attrsMap: makeAttrsMap(attrs),
1944 parent: currentParent,
1945 children: []
1946 };
1947 if (ns) {
1948 element.ns = ns;
1949 }
1950
1951 if (isForbiddenTag(element) && !isServerRendering()) {
1952 element.forbidden = true;
1953 process.env.NODE_ENV !== 'production' && warn$1(
1954 'Templates should only be responsible for mapping the state to the ' +
1955 'UI. Avoid placing tags with side-effects in your templates, such as ' +
1956 "<" + tag + ">" + ', as they will not be parsed.'
1957 );
1958 }
1959
1960 // apply pre-transforms
1961 for (var i = 0; i < preTransforms.length; i++) {
1962 preTransforms[i](element, options);
1963 }
1964
1965 if (!inVPre) {
1966 processPre(element);
1967 if (element.pre) {
1968 inVPre = true;
1969 }
1970 }
1971 if (platformIsPreTag(element.tag)) {
1972 inPre = true;
1973 }
1974 if (inVPre) {
1975 processRawAttrs(element);
1976 } else {
1977 processFor(element);
1978 processIf(element);
1979 processOnce(element);
1980 processKey(element);
1981
1982 // determine whether this is a plain element after
1983 // removing structural attributes
1984 element.plain = !element.key && !attrs.length;
1985
1986 processRef(element);
1987 processSlot(element);
1988 processComponent(element);
1989 for (var i$1 = 0; i$1 < transforms.length; i$1++) {
1990 transforms[i$1](element, options);
1991 }
1992 processAttrs(element);
1993 }
1994
1995 function checkRootConstraints (el) {
1996 if (process.env.NODE_ENV !== 'production') {
1997 if (el.tag === 'slot' || el.tag === 'template') {
1998 warnOnce(
1999 "Cannot use <" + (el.tag) + "> as component root element because it may " +
2000 'contain multiple nodes.'
2001 );
2002 }
2003 if (el.attrsMap.hasOwnProperty('v-for')) {
2004 warnOnce(
2005 'Cannot use v-for on stateful component root element because ' +
2006 'it renders multiple elements.'
2007 );
2008 }
2009 }
2010 }
2011
2012 // tree management
2013 if (!root) {
2014 root = element;
2015 checkRootConstraints(root);
2016 } else if (!stack.length) {
2017 // allow root elements with v-if, v-else-if and v-else
2018 if (root.if && (element.elseif || element.else)) {
2019 checkRootConstraints(element);
2020 addIfCondition(root, {
2021 exp: element.elseif,
2022 block: element
2023 });
2024 } else if (process.env.NODE_ENV !== 'production') {
2025 warnOnce(
2026 "Component template should contain exactly one root element. " +
2027 "If you are using v-if on multiple elements, " +
2028 "use v-else-if to chain them instead."
2029 );
2030 }
2031 }
2032 if (currentParent && !element.forbidden) {
2033 if (element.elseif || element.else) {
2034 processIfConditions(element, currentParent);
2035 } else if (element.slotScope) { // scoped slot
2036 currentParent.plain = false;
2037 var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
2038 } else {
2039 currentParent.children.push(element);
2040 element.parent = currentParent;
2041 }
2042 }
2043 if (!unary) {
2044 currentParent = element;
2045 stack.push(element);
2046 } else {
2047 endPre(element);
2048 }
2049 // apply post-transforms
2050 for (var i$2 = 0; i$2 < postTransforms.length; i$2++) {
2051 postTransforms[i$2](element, options);
2052 }
2053 },
2054
2055 end: function end () {
2056 // remove trailing whitespace
2057 var element = stack[stack.length - 1];
2058 var lastNode = element.children[element.children.length - 1];
2059 if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
2060 element.children.pop();
2061 }
2062 // pop stack
2063 stack.length -= 1;
2064 currentParent = stack[stack.length - 1];
2065 endPre(element);
2066 },
2067
2068 chars: function chars (text) {
2069 if (!currentParent) {
2070 if (process.env.NODE_ENV !== 'production') {
2071 if (text === template$$1) {
2072 warnOnce(
2073 'Component template requires a root element, rather than just text.'
2074 );
2075 } else if ((text = text.trim())) {
2076 warnOnce(
2077 ("text \"" + text + "\" outside root element will be ignored.")
2078 );
2079 }
2080 }
2081 return
2082 }
2083 // IE textarea placeholder bug
2084 /* istanbul ignore if */
2085 if (isIE &&
2086 currentParent.tag === 'textarea' &&
2087 currentParent.attrsMap.placeholder === text
2088 ) {
2089 return
2090 }
2091 var children = currentParent.children;
2092 text = inPre || text.trim()
2093 ? isTextTag(currentParent) ? text : decodeHTMLCached(text)
2094 // only preserve whitespace if its not right after a starting tag
2095 : preserveWhitespace && children.length ? ' ' : '';
2096 if (text) {
2097 var expression;
2098 if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
2099 children.push({
2100 type: 2,
2101 expression: expression,
2102 text: text
2103 });
2104 } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
2105 children.push({
2106 type: 3,
2107 text: text
2108 });
2109 }
2110 }
2111 },
2112 comment: function comment (text) {
2113 currentParent.children.push({
2114 type: 3,
2115 text: text,
2116 isComment: true
2117 });
2118 }
2119 });
2120 return root
2121}
2122
2123function processPre (el) {
2124 if (getAndRemoveAttr(el, 'v-pre') != null) {
2125 el.pre = true;
2126 }
2127}
2128
2129function processRawAttrs (el) {
2130 var l = el.attrsList.length;
2131 if (l) {
2132 var attrs = el.attrs = new Array(l);
2133 for (var i = 0; i < l; i++) {
2134 attrs[i] = {
2135 name: el.attrsList[i].name,
2136 value: JSON.stringify(el.attrsList[i].value)
2137 };
2138 }
2139 } else if (!el.pre) {
2140 // non root node in pre blocks with no attributes
2141 el.plain = true;
2142 }
2143}
2144
2145function processKey (el) {
2146 var exp = getBindingAttr(el, 'key');
2147 if (exp) {
2148 if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {
2149 warn$1("<template> cannot be keyed. Place the key on real elements instead.");
2150 }
2151 el.key = exp;
2152 }
2153}
2154
2155function processRef (el) {
2156 var ref = getBindingAttr(el, 'ref');
2157 if (ref) {
2158 el.ref = ref;
2159 el.refInFor = checkInFor(el);
2160 }
2161}
2162
2163function processFor (el) {
2164 var exp;
2165 if ((exp = getAndRemoveAttr(el, 'v-for'))) {
2166 var inMatch = exp.match(forAliasRE);
2167 if (!inMatch) {
2168 process.env.NODE_ENV !== 'production' && warn$1(
2169 ("Invalid v-for expression: " + exp)
2170 );
2171 return
2172 }
2173 el.for = inMatch[2].trim();
2174 var alias = inMatch[1].trim();
2175 var iteratorMatch = alias.match(forIteratorRE);
2176 if (iteratorMatch) {
2177 el.alias = iteratorMatch[1].trim();
2178 el.iterator1 = iteratorMatch[2].trim();
2179 if (iteratorMatch[3]) {
2180 el.iterator2 = iteratorMatch[3].trim();
2181 }
2182 } else {
2183 el.alias = alias;
2184 }
2185 }
2186}
2187
2188function processIf (el) {
2189 var exp = getAndRemoveAttr(el, 'v-if');
2190 if (exp) {
2191 el.if = exp;
2192 addIfCondition(el, {
2193 exp: exp,
2194 block: el
2195 });
2196 } else {
2197 if (getAndRemoveAttr(el, 'v-else') != null) {
2198 el.else = true;
2199 }
2200 var elseif = getAndRemoveAttr(el, 'v-else-if');
2201 if (elseif) {
2202 el.elseif = elseif;
2203 }
2204 }
2205}
2206
2207function processIfConditions (el, parent) {
2208 var prev = findPrevElement(parent.children);
2209 if (prev && prev.if) {
2210 addIfCondition(prev, {
2211 exp: el.elseif,
2212 block: el
2213 });
2214 } else if (process.env.NODE_ENV !== 'production') {
2215 warn$1(
2216 "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
2217 "used on element <" + (el.tag) + "> without corresponding v-if."
2218 );
2219 }
2220}
2221
2222function findPrevElement (children) {
2223 var i = children.length;
2224 while (i--) {
2225 if (children[i].type === 1) {
2226 return children[i]
2227 } else {
2228 if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
2229 warn$1(
2230 "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
2231 "will be ignored."
2232 );
2233 }
2234 children.pop();
2235 }
2236 }
2237}
2238
2239function addIfCondition (el, condition) {
2240 if (!el.ifConditions) {
2241 el.ifConditions = [];
2242 }
2243 el.ifConditions.push(condition);
2244}
2245
2246function processOnce (el) {
2247 var once$$1 = getAndRemoveAttr(el, 'v-once');
2248 if (once$$1 != null) {
2249 el.once = true;
2250 }
2251}
2252
2253function processSlot (el) {
2254 if (el.tag === 'slot') {
2255 el.slotName = getBindingAttr(el, 'name');
2256 if (process.env.NODE_ENV !== 'production' && el.key) {
2257 warn$1(
2258 "`key` does not work on <slot> because slots are abstract outlets " +
2259 "and can possibly expand into multiple elements. " +
2260 "Use the key on a wrapping element instead."
2261 );
2262 }
2263 } else {
2264 var slotTarget = getBindingAttr(el, 'slot');
2265 if (slotTarget) {
2266 el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
2267 }
2268 if (el.tag === 'template') {
2269 el.slotScope = getAndRemoveAttr(el, 'scope');
2270 }
2271 }
2272}
2273
2274function processComponent (el) {
2275 var binding;
2276 if ((binding = getBindingAttr(el, 'is'))) {
2277 el.component = binding;
2278 }
2279 if (getAndRemoveAttr(el, 'inline-template') != null) {
2280 el.inlineTemplate = true;
2281 }
2282}
2283
2284function processAttrs (el) {
2285 var list = el.attrsList;
2286 var i, l, name, rawName, value, modifiers, isProp;
2287 for (i = 0, l = list.length; i < l; i++) {
2288 name = rawName = list[i].name;
2289 value = list[i].value;
2290 if (dirRE.test(name)) {
2291 // mark element as dynamic
2292 el.hasBindings = true;
2293 // modifiers
2294 modifiers = parseModifiers(name);
2295 if (modifiers) {
2296 name = name.replace(modifierRE, '');
2297 }
2298 if (bindRE.test(name)) { // v-bind
2299 name = name.replace(bindRE, '');
2300 value = parseFilters(value);
2301 isProp = false;
2302 if (modifiers) {
2303 if (modifiers.prop) {
2304 isProp = true;
2305 name = camelize(name);
2306 if (name === 'innerHtml') { name = 'innerHTML'; }
2307 }
2308 if (modifiers.camel) {
2309 name = camelize(name);
2310 }
2311 if (modifiers.sync) {
2312 addHandler(
2313 el,
2314 ("update:" + (camelize(name))),
2315 genAssignmentCode(value, "$event")
2316 );
2317 }
2318 }
2319 if (!el.component && (
2320 isProp || platformMustUseProp(el.tag, el.attrsMap.type, name)
2321 )) {
2322 addProp(el, name, value);
2323 } else {
2324 addAttr(el, name, value);
2325 }
2326 } else if (onRE.test(name)) { // v-on
2327 name = name.replace(onRE, '');
2328 addHandler(el, name, value, modifiers, false, warn$1);
2329 } else { // normal directives
2330 name = name.replace(dirRE, '');
2331 // parse arg
2332 var argMatch = name.match(argRE);
2333 var arg = argMatch && argMatch[1];
2334 if (arg) {
2335 name = name.slice(0, -(arg.length + 1));
2336 }
2337 addDirective(el, name, rawName, value, arg, modifiers);
2338 if (process.env.NODE_ENV !== 'production' && name === 'model') {
2339 checkForAliasModel(el, value);
2340 }
2341 }
2342 } else {
2343 // literal attribute
2344 if (process.env.NODE_ENV !== 'production') {
2345 var expression = parseText(value, delimiters);
2346 if (expression) {
2347 warn$1(
2348 name + "=\"" + value + "\": " +
2349 'Interpolation inside attributes has been removed. ' +
2350 'Use v-bind or the colon shorthand instead. For example, ' +
2351 'instead of <div id="{{ val }}">, use <div :id="val">.'
2352 );
2353 }
2354 }
2355 addAttr(el, name, JSON.stringify(value));
2356 }
2357 }
2358}
2359
2360function checkInFor (el) {
2361 var parent = el;
2362 while (parent) {
2363 if (parent.for !== undefined) {
2364 return true
2365 }
2366 parent = parent.parent;
2367 }
2368 return false
2369}
2370
2371function parseModifiers (name) {
2372 var match = name.match(modifierRE);
2373 if (match) {
2374 var ret = {};
2375 match.forEach(function (m) { ret[m.slice(1)] = true; });
2376 return ret
2377 }
2378}
2379
2380function makeAttrsMap (attrs) {
2381 var map = {};
2382 for (var i = 0, l = attrs.length; i < l; i++) {
2383 if (
2384 process.env.NODE_ENV !== 'production' &&
2385 map[attrs[i].name] && !isIE && !isEdge
2386 ) {
2387 warn$1('duplicate attribute: ' + attrs[i].name);
2388 }
2389 map[attrs[i].name] = attrs[i].value;
2390 }
2391 return map
2392}
2393
2394// for script (e.g. type="x/template") or style, do not decode content
2395function isTextTag (el) {
2396 return el.tag === 'script' || el.tag === 'style'
2397}
2398
2399function isForbiddenTag (el) {
2400 return (
2401 el.tag === 'style' ||
2402 (el.tag === 'script' && (
2403 !el.attrsMap.type ||
2404 el.attrsMap.type === 'text/javascript'
2405 ))
2406 )
2407}
2408
2409var ieNSBug = /^xmlns:NS\d+/;
2410var ieNSPrefix = /^NS\d+:/;
2411
2412/* istanbul ignore next */
2413function guardIESVGBug (attrs) {
2414 var res = [];
2415 for (var i = 0; i < attrs.length; i++) {
2416 var attr = attrs[i];
2417 if (!ieNSBug.test(attr.name)) {
2418 attr.name = attr.name.replace(ieNSPrefix, '');
2419 res.push(attr);
2420 }
2421 }
2422 return res
2423}
2424
2425function checkForAliasModel (el, value) {
2426 var _el = el;
2427 while (_el) {
2428 if (_el.for && _el.alias === value) {
2429 warn$1(
2430 "<" + (el.tag) + " v-model=\"" + value + "\">: " +
2431 "You are binding v-model directly to a v-for iteration alias. " +
2432 "This will not be able to modify the v-for source array because " +
2433 "writing to the alias is like modifying a function local variable. " +
2434 "Consider using an array of objects and use v-model on an object property instead."
2435 );
2436 }
2437 _el = _el.parent;
2438 }
2439}
2440
2441/* */
2442
2443var isStaticKey;
2444var isPlatformReservedTag;
2445
2446var genStaticKeysCached = cached(genStaticKeys$1);
2447
2448/**
2449 * Goal of the optimizer: walk the generated template AST tree
2450 * and detect sub-trees that are purely static, i.e. parts of
2451 * the DOM that never needs to change.
2452 *
2453 * Once we detect these sub-trees, we can:
2454 *
2455 * 1. Hoist them into constants, so that we no longer need to
2456 * create fresh nodes for them on each re-render;
2457 * 2. Completely skip them in the patching process.
2458 */
2459function optimize (root, options) {
2460 if (!root) { return }
2461 isStaticKey = genStaticKeysCached(options.staticKeys || '');
2462 isPlatformReservedTag = options.isReservedTag || no;
2463 // first pass: mark all non-static nodes.
2464 markStatic(root);
2465 // second pass: mark static roots.
2466 markStaticRoots(root, false);
2467}
2468
2469function genStaticKeys$1 (keys) {
2470 return makeMap(
2471 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
2472 (keys ? ',' + keys : '')
2473 )
2474}
2475
2476function markStatic (node) {
2477 node.static = isStatic(node);
2478 if (node.type === 1) {
2479 // do not make component slot content static. this avoids
2480 // 1. components not able to mutate slot nodes
2481 // 2. static slot content fails for hot-reloading
2482 if (
2483 !isPlatformReservedTag(node.tag) &&
2484 node.tag !== 'slot' &&
2485 node.attrsMap['inline-template'] == null
2486 ) {
2487 return
2488 }
2489 for (var i = 0, l = node.children.length; i < l; i++) {
2490 var child = node.children[i];
2491 markStatic(child);
2492 if (!child.static) {
2493 node.static = false;
2494 }
2495 }
2496 if (node.ifConditions) {
2497 for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
2498 var block = node.ifConditions[i$1].block;
2499 markStatic(block);
2500 if (!block.static) {
2501 node.static = false;
2502 }
2503 }
2504 }
2505 }
2506}
2507
2508function markStaticRoots (node, isInFor) {
2509 if (node.type === 1) {
2510 if (node.static || node.once) {
2511 node.staticInFor = isInFor;
2512 }
2513 // For a node to qualify as a static root, it should have children that
2514 // are not just static text. Otherwise the cost of hoisting out will
2515 // outweigh the benefits and it's better off to just always render it fresh.
2516 if (node.static && node.children.length && !(
2517 node.children.length === 1 &&
2518 node.children[0].type === 3
2519 )) {
2520 node.staticRoot = true;
2521 return
2522 } else {
2523 node.staticRoot = false;
2524 }
2525 if (node.children) {
2526 for (var i = 0, l = node.children.length; i < l; i++) {
2527 markStaticRoots(node.children[i], isInFor || !!node.for);
2528 }
2529 }
2530 if (node.ifConditions) {
2531 for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
2532 markStaticRoots(node.ifConditions[i$1].block, isInFor);
2533 }
2534 }
2535 }
2536}
2537
2538function isStatic (node) {
2539 if (node.type === 2) { // expression
2540 return false
2541 }
2542 if (node.type === 3) { // text
2543 return true
2544 }
2545 return !!(node.pre || (
2546 !node.hasBindings && // no dynamic bindings
2547 !node.if && !node.for && // not v-if or v-for or v-else
2548 !isBuiltInTag(node.tag) && // not a built-in
2549 isPlatformReservedTag(node.tag) && // not a component
2550 !isDirectChildOfTemplateFor(node) &&
2551 Object.keys(node).every(isStaticKey)
2552 ))
2553}
2554
2555function isDirectChildOfTemplateFor (node) {
2556 while (node.parent) {
2557 node = node.parent;
2558 if (node.tag !== 'template') {
2559 return false
2560 }
2561 if (node.for) {
2562 return true
2563 }
2564 }
2565 return false
2566}
2567
2568/* */
2569
2570var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
2571var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/;
2572
2573// keyCode aliases
2574var keyCodes = {
2575 esc: 27,
2576 tab: 9,
2577 enter: 13,
2578 space: 32,
2579 up: 38,
2580 left: 37,
2581 right: 39,
2582 down: 40,
2583 'delete': [8, 46]
2584};
2585
2586// #4868: modifiers that prevent the execution of the listener
2587// need to explicitly return null so that we can determine whether to remove
2588// the listener for .once
2589var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
2590
2591var modifierCode = {
2592 stop: '$event.stopPropagation();',
2593 prevent: '$event.preventDefault();',
2594 self: genGuard("$event.target !== $event.currentTarget"),
2595 ctrl: genGuard("!$event.ctrlKey"),
2596 shift: genGuard("!$event.shiftKey"),
2597 alt: genGuard("!$event.altKey"),
2598 meta: genGuard("!$event.metaKey"),
2599 left: genGuard("'button' in $event && $event.button !== 0"),
2600 middle: genGuard("'button' in $event && $event.button !== 1"),
2601 right: genGuard("'button' in $event && $event.button !== 2")
2602};
2603
2604function genHandlers (
2605 events,
2606 isNative,
2607 warn
2608) {
2609 var res = isNative ? 'nativeOn:{' : 'on:{';
2610 for (var name in events) {
2611 var handler = events[name];
2612 // #5330: warn click.right, since right clicks do not actually fire click events.
2613 if (process.env.NODE_ENV !== 'production' &&
2614 name === 'click' &&
2615 handler && handler.modifiers && handler.modifiers.right
2616 ) {
2617 warn(
2618 "Use \"contextmenu\" instead of \"click.right\" since right clicks " +
2619 "do not actually fire \"click\" events."
2620 );
2621 }
2622 res += "\"" + name + "\":" + (genHandler(name, handler)) + ",";
2623 }
2624 return res.slice(0, -1) + '}'
2625}
2626
2627function genHandler (
2628 name,
2629 handler
2630) {
2631 if (!handler) {
2632 return 'function(){}'
2633 }
2634
2635 if (Array.isArray(handler)) {
2636 return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
2637 }
2638
2639 var isMethodPath = simplePathRE.test(handler.value);
2640 var isFunctionExpression = fnExpRE.test(handler.value);
2641
2642 if (!handler.modifiers) {
2643 return isMethodPath || isFunctionExpression
2644 ? handler.value
2645 : ("function($event){" + (handler.value) + "}") // inline statement
2646 } else {
2647 var code = '';
2648 var genModifierCode = '';
2649 var keys = [];
2650 for (var key in handler.modifiers) {
2651 if (modifierCode[key]) {
2652 genModifierCode += modifierCode[key];
2653 // left/right
2654 if (keyCodes[key]) {
2655 keys.push(key);
2656 }
2657 } else {
2658 keys.push(key);
2659 }
2660 }
2661 if (keys.length) {
2662 code += genKeyFilter(keys);
2663 }
2664 // Make sure modifiers like prevent and stop get executed after key filtering
2665 if (genModifierCode) {
2666 code += genModifierCode;
2667 }
2668 var handlerCode = isMethodPath
2669 ? handler.value + '($event)'
2670 : isFunctionExpression
2671 ? ("(" + (handler.value) + ")($event)")
2672 : handler.value;
2673 return ("function($event){" + code + handlerCode + "}")
2674 }
2675}
2676
2677function genKeyFilter (keys) {
2678 return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
2679}
2680
2681function genFilterCode (key) {
2682 var keyVal = parseInt(key, 10);
2683 if (keyVal) {
2684 return ("$event.keyCode!==" + keyVal)
2685 }
2686 var alias = keyCodes[key];
2687 return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")")
2688}
2689
2690/* */
2691
2692var emptyObject = Object.freeze({});
2693
2694/**
2695 * Check if a string starts with $ or _
2696 */
2697
2698
2699/**
2700 * Define a property.
2701 */
2702function def (obj, key, val, enumerable) {
2703 Object.defineProperty(obj, key, {
2704 value: val,
2705 enumerable: !!enumerable,
2706 writable: true,
2707 configurable: true
2708 });
2709}
2710
2711/* */
2712
2713
2714var uid = 0;
2715
2716/**
2717 * A dep is an observable that can have multiple
2718 * directives subscribing to it.
2719 */
2720var Dep = function Dep () {
2721 this.id = uid++;
2722 this.subs = [];
2723};
2724
2725Dep.prototype.addSub = function addSub (sub) {
2726 this.subs.push(sub);
2727};
2728
2729Dep.prototype.removeSub = function removeSub (sub) {
2730 remove(this.subs, sub);
2731};
2732
2733Dep.prototype.depend = function depend () {
2734 if (Dep.target) {
2735 Dep.target.addDep(this);
2736 }
2737};
2738
2739Dep.prototype.notify = function notify () {
2740 // stabilize the subscriber list first
2741 var subs = this.subs.slice();
2742 for (var i = 0, l = subs.length; i < l; i++) {
2743 subs[i].update();
2744 }
2745};
2746
2747// the current target watcher being evaluated.
2748// this is globally unique because there could be only one
2749// watcher being evaluated at any time.
2750Dep.target = null;
2751
2752/*
2753 * not type checking this file because flow doesn't play well with
2754 * dynamically accessing methods on Array prototype
2755 */
2756
2757var arrayProto = Array.prototype;
2758var arrayMethods = Object.create(arrayProto);[
2759 'push',
2760 'pop',
2761 'shift',
2762 'unshift',
2763 'splice',
2764 'sort',
2765 'reverse'
2766]
2767.forEach(function (method) {
2768 // cache original method
2769 var original = arrayProto[method];
2770 def(arrayMethods, method, function mutator () {
2771 var args = [], len = arguments.length;
2772 while ( len-- ) args[ len ] = arguments[ len ];
2773
2774 var result = original.apply(this, args);
2775 var ob = this.__ob__;
2776 var inserted;
2777 switch (method) {
2778 case 'push':
2779 case 'unshift':
2780 inserted = args;
2781 break
2782 case 'splice':
2783 inserted = args.slice(2);
2784 break
2785 }
2786 if (inserted) { ob.observeArray(inserted); }
2787 // notify change
2788 ob.dep.notify();
2789 return result
2790 });
2791});
2792
2793/* */
2794
2795var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
2796
2797/**
2798 * By default, when a reactive property is set, the new value is
2799 * also converted to become reactive. However when passing down props,
2800 * we don't want to force conversion because the value may be a nested value
2801 * under a frozen data structure. Converting it would defeat the optimization.
2802 */
2803var observerState = {
2804 shouldConvert: true
2805};
2806
2807/**
2808 * Observer class that are attached to each observed
2809 * object. Once attached, the observer converts target
2810 * object's property keys into getter/setters that
2811 * collect dependencies and dispatches updates.
2812 */
2813var Observer = function Observer (value, key) {
2814 this.value = value;
2815 this.dep = new Dep();
2816 this.vmCount = 0;
2817 if (key) {
2818 this.key = key;
2819 }
2820 def(value, '__ob__', this);
2821 if (Array.isArray(value)) {
2822 var augment = hasProto
2823 ? protoAugment
2824 : copyAugment;
2825 augment(value, arrayMethods, arrayKeys);
2826 this.observeArray(value);
2827 } else {
2828 this.walk(value);
2829 }
2830};
2831
2832/**
2833 * Walk through each property and convert them into
2834 * getter/setters. This method should only be called when
2835 * value type is Object.
2836 */
2837Observer.prototype.walk = function walk (obj) {
2838 var keys = Object.keys(obj);
2839 for (var i = 0; i < keys.length; i++) {
2840 defineReactive$$1(obj, keys[i], obj[keys[i]]);
2841 }
2842};
2843
2844/**
2845 * Observe a list of Array items.
2846 */
2847Observer.prototype.observeArray = function observeArray (items) {
2848 for (var i = 0, l = items.length; i < l; i++) {
2849 observe(items[i]);
2850 }
2851};
2852
2853// helpers
2854
2855/**
2856 * Augment an target Object or Array by intercepting
2857 * the prototype chain using __proto__
2858 */
2859function protoAugment (target, src, keys) {
2860 /* eslint-disable no-proto */
2861 target.__proto__ = src;
2862 /* eslint-enable no-proto */
2863}
2864
2865/**
2866 * Augment an target Object or Array by defining
2867 * hidden properties.
2868 */
2869/* istanbul ignore next */
2870function copyAugment (target, src, keys) {
2871 for (var i = 0, l = keys.length; i < l; i++) {
2872 var key = keys[i];
2873 def(target, key, src[key]);
2874 }
2875}
2876
2877/**
2878 * Attempt to create an observer instance for a value,
2879 * returns the new observer if successfully observed,
2880 * or the existing observer if the value already has one.
2881 */
2882function observe (value, asRootData, key) {
2883 if (!isObject(value)) {
2884 return
2885 }
2886 var ob;
2887 if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
2888 ob = value.__ob__;
2889 } else if (
2890 observerState.shouldConvert &&
2891 !isServerRendering() &&
2892 (Array.isArray(value) || isPlainObject(value)) &&
2893 Object.isExtensible(value) &&
2894 !value._isVue
2895 ) {
2896 ob = new Observer(value, key);
2897 }
2898 if (asRootData && ob) {
2899 ob.vmCount++;
2900 }
2901 return ob
2902}
2903
2904/**
2905 * Define a reactive property on an Object.
2906 */
2907function defineReactive$$1 (
2908 obj,
2909 key,
2910 val,
2911 customSetter,
2912 shallow
2913) {
2914 var dep = new Dep();
2915
2916 var property = Object.getOwnPropertyDescriptor(obj, key);
2917 if (property && property.configurable === false) {
2918 return
2919 }
2920
2921 // cater for pre-defined getter/setters
2922 var getter = property && property.get;
2923 var setter = property && property.set;
2924
2925 var childOb = !shallow && observe(val, undefined, key);
2926 Object.defineProperty(obj, key, {
2927 enumerable: true,
2928 configurable: true,
2929 get: function reactiveGetter () {
2930 var value = getter ? getter.call(obj) : val;
2931 if (Dep.target) {
2932 dep.depend();
2933 if (childOb) {
2934 childOb.dep.depend();
2935 }
2936 if (Array.isArray(value)) {
2937 dependArray(value);
2938 }
2939 }
2940 return value
2941 },
2942 set: function reactiveSetter (newVal) {
2943 var value = getter ? getter.call(obj) : val;
2944 /* eslint-disable no-self-compare */
2945 if (newVal === value || (newVal !== newVal && value !== value)) {
2946 return
2947 }
2948
2949 /* eslint-enable no-self-compare */
2950 if (process.env.NODE_ENV !== 'production' && customSetter) {
2951 customSetter();
2952 }
2953 if (setter) {
2954 setter.call(obj, newVal);
2955 } else {
2956 val = newVal;
2957 }
2958 childOb = !shallow && observe(newVal, undefined, key);
2959 dep.notify();
2960
2961 if (!obj.__keyPath) {
2962 def(obj, '__keyPath', {}, false);
2963 }
2964 obj.__keyPath[key] = true;
2965 if (newVal instanceof Object && !(newVal instanceof Array)) {
2966 // 标记是否是通过this.Obj = {} 赋值印发的改动,解决少更新问题#1305
2967 def(newVal, '__newReference', true, false);
2968 }
2969 }
2970 });
2971}
2972
2973/**
2974 * Set a property on an object. Adds the new property and
2975 * triggers change notification if the property doesn't
2976 * already exist.
2977 */
2978function set (target, key, val) {
2979 if (Array.isArray(target) && isValidArrayIndex(key)) {
2980 target.length = Math.max(target.length, key);
2981 target.splice(key, 1, val);
2982 return val
2983 }
2984 if (hasOwn(target, key)) {
2985 target[key] = val;
2986 return val
2987 }
2988 var ob = (target).__ob__;
2989 if (target._isVue || (ob && ob.vmCount)) {
2990 process.env.NODE_ENV !== 'production' && warn$2(
2991 'Avoid adding reactive properties to a Vue instance or its root $data ' +
2992 'at runtime - declare it upfront in the data option.'
2993 );
2994 return val
2995 }
2996 if (!ob) {
2997 target[key] = val;
2998 return val
2999 }
3000 defineReactive$$1(ob.value, key, val);
3001 // Vue.set 添加对象属性,渲染时候把 val 传给小程序渲染
3002 if (!target.__keyPath) {
3003 def(target, '__keyPath', {}, false);
3004 }
3005 target.__keyPath[key] = true;
3006 ob.dep.notify();
3007 return val
3008}
3009
3010/**
3011 * Delete a property and trigger change if necessary.
3012 */
3013
3014
3015/**
3016 * Collect dependencies on array elements when the array is touched, since
3017 * we cannot intercept array element access like property getters.
3018 */
3019function dependArray (value) {
3020 for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
3021 e = value[i];
3022 e && e.__ob__ && e.__ob__.dep.depend();
3023 if (Array.isArray(e)) {
3024 dependArray(e);
3025 }
3026 }
3027}
3028
3029/* */
3030
3031/**
3032 * Option overwriting strategies are functions that handle
3033 * how to merge a parent option value and a child option
3034 * value into the final value.
3035 */
3036var strats = config.optionMergeStrategies;
3037
3038/**
3039 * Options with restrictions
3040 */
3041if (process.env.NODE_ENV !== 'production') {
3042 strats.el = strats.propsData = function (parent, child, vm, key) {
3043 if (!vm) {
3044 warn$2(
3045 "option \"" + key + "\" can only be used during instance " +
3046 'creation with the `new` keyword.'
3047 );
3048 }
3049 return defaultStrat(parent, child)
3050 };
3051}
3052
3053/**
3054 * Helper that recursively merges two data objects together.
3055 */
3056function mergeData (to, from) {
3057 if (!from) { return to }
3058 var key, toVal, fromVal;
3059 var keys = Object.keys(from);
3060 for (var i = 0; i < keys.length; i++) {
3061 key = keys[i];
3062 toVal = to[key];
3063 fromVal = from[key];
3064 if (!hasOwn(to, key)) {
3065 set(to, key, fromVal);
3066 } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
3067 mergeData(toVal, fromVal);
3068 }
3069 }
3070 return to
3071}
3072
3073/**
3074 * Data
3075 */
3076function mergeDataOrFn (
3077 parentVal,
3078 childVal,
3079 vm
3080) {
3081 if (!vm) {
3082 // in a Vue.extend merge, both should be functions
3083 if (!childVal) {
3084 return parentVal
3085 }
3086 if (!parentVal) {
3087 return childVal
3088 }
3089 // when parentVal & childVal are both present,
3090 // we need to return a function that returns the
3091 // merged result of both functions... no need to
3092 // check if parentVal is a function here because
3093 // it has to be a function to pass previous merges.
3094 return function mergedDataFn () {
3095 return mergeData(
3096 typeof childVal === 'function' ? childVal.call(this) : childVal,
3097 parentVal.call(this)
3098 )
3099 }
3100 } else if (parentVal || childVal) {
3101 return function mergedInstanceDataFn () {
3102 // instance merge
3103 var instanceData = typeof childVal === 'function'
3104 ? childVal.call(vm)
3105 : childVal;
3106 var defaultData = typeof parentVal === 'function'
3107 ? parentVal.call(vm)
3108 : undefined;
3109 if (instanceData) {
3110 return mergeData(instanceData, defaultData)
3111 } else {
3112 return defaultData
3113 }
3114 }
3115 }
3116}
3117
3118strats.data = function (
3119 parentVal,
3120 childVal,
3121 vm
3122) {
3123 if (!vm) {
3124 if (childVal && typeof childVal !== 'function') {
3125 process.env.NODE_ENV !== 'production' && warn$2(
3126 'The "data" option should be a function ' +
3127 'that returns a per-instance value in component ' +
3128 'definitions.',
3129 vm
3130 );
3131
3132 return parentVal
3133 }
3134 return mergeDataOrFn.call(this, parentVal, childVal)
3135 }
3136
3137 return mergeDataOrFn(parentVal, childVal, vm)
3138};
3139
3140/**
3141 * Hooks and props are merged as arrays.
3142 */
3143function mergeHook (
3144 parentVal,
3145 childVal
3146) {
3147 return childVal
3148 ? parentVal
3149 ? parentVal.concat(childVal)
3150 : Array.isArray(childVal)
3151 ? childVal
3152 : [childVal]
3153 : parentVal
3154}
3155
3156LIFECYCLE_HOOKS.forEach(function (hook) {
3157 strats[hook] = mergeHook;
3158});
3159
3160/**
3161 * Assets
3162 *
3163 * When a vm is present (instance creation), we need to do
3164 * a three-way merge between constructor options, instance
3165 * options and parent options.
3166 */
3167function mergeAssets (parentVal, childVal) {
3168 var res = Object.create(parentVal || null);
3169 return childVal
3170 ? extend(res, childVal)
3171 : res
3172}
3173
3174ASSET_TYPES.forEach(function (type) {
3175 strats[type + 's'] = mergeAssets;
3176});
3177
3178/**
3179 * Watchers.
3180 *
3181 * Watchers hashes should not overwrite one
3182 * another, so we merge them as arrays.
3183 */
3184strats.watch = function (parentVal, childVal) {
3185 // work around Firefox's Object.prototype.watch...
3186 if (parentVal === nativeWatch) { parentVal = undefined; }
3187 if (childVal === nativeWatch) { childVal = undefined; }
3188 /* istanbul ignore if */
3189 if (!childVal) { return Object.create(parentVal || null) }
3190 if (!parentVal) { return childVal }
3191 var ret = {};
3192 extend(ret, parentVal);
3193 for (var key in childVal) {
3194 var parent = ret[key];
3195 var child = childVal[key];
3196 if (parent && !Array.isArray(parent)) {
3197 parent = [parent];
3198 }
3199 ret[key] = parent
3200 ? parent.concat(child)
3201 : Array.isArray(child) ? child : [child];
3202 }
3203 return ret
3204};
3205
3206/**
3207 * Other object hashes.
3208 */
3209strats.props =
3210strats.methods =
3211strats.inject =
3212strats.computed = function (parentVal, childVal) {
3213 if (!childVal) { return Object.create(parentVal || null) }
3214 if (!parentVal) { return childVal }
3215 var ret = Object.create(null);
3216 extend(ret, parentVal);
3217 extend(ret, childVal);
3218 return ret
3219};
3220strats.provide = mergeDataOrFn;
3221
3222/**
3223 * Default strategy.
3224 */
3225var defaultStrat = function (parentVal, childVal) {
3226 return childVal === undefined
3227 ? parentVal
3228 : childVal
3229};
3230
3231/**
3232 * Merge two option objects into a new one.
3233 * Core utility used in both instantiation and inheritance.
3234 */
3235
3236
3237/**
3238 * Resolve an asset.
3239 * This function is used because child instances need access
3240 * to assets defined in its ancestor chain.
3241 */
3242
3243/* */
3244
3245/* */
3246
3247/* */
3248
3249function on (el, dir) {
3250 if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
3251 warn$2("v-on without argument does not support modifiers.");
3252 }
3253 el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
3254}
3255
3256/* */
3257
3258function bind$1 (el, dir) {
3259 el.wrapData = function (code) {
3260 return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
3261 };
3262}
3263
3264/* */
3265
3266var baseDirectives = {
3267 on: on,
3268 bind: bind$1,
3269 cloak: noop
3270};
3271
3272/* */
3273
3274var CodegenState = function CodegenState (options) {
3275 this.options = options;
3276 this.warn = options.warn || baseWarn;
3277 this.transforms = pluckModuleFunction(options.modules, 'transformCode');
3278 this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
3279 this.directives = extend(extend({}, baseDirectives), options.directives);
3280 var isReservedTag = options.isReservedTag || no;
3281 this.maybeComponent = function (el) { return !isReservedTag(el.tag); };
3282 this.onceId = 0;
3283 this.staticRenderFns = [];
3284};
3285
3286
3287
3288function generate$1 (
3289 ast,
3290 options
3291) {
3292 var state = new CodegenState(options);
3293 var code = ast ? genElement(ast, state) : '_c("div")';
3294 return {
3295 render: ("with(this){return " + code + "}"),
3296 staticRenderFns: state.staticRenderFns
3297 }
3298}
3299
3300function genElement (el, state) {
3301 if (el.staticRoot && !el.staticProcessed) {
3302 return genStatic(el, state)
3303 } else if (el.once && !el.onceProcessed) {
3304 return genOnce(el, state)
3305 } else if (el.for && !el.forProcessed) {
3306 return genFor(el, state)
3307 } else if (el.if && !el.ifProcessed) {
3308 return genIf(el, state)
3309 } else if (el.tag === 'template' && !el.slotTarget) {
3310 return genChildren(el, state) || 'void 0'
3311 } else if (el.tag === 'slot') {
3312 return genSlot(el, state)
3313 } else {
3314 // component or element
3315 var code;
3316 if (el.component) {
3317 code = genComponent(el.component, el, state);
3318 } else {
3319 var data = el.plain ? undefined : genData$2(el, state);
3320
3321 var children = el.inlineTemplate ? null : genChildren(el, state, true);
3322 code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
3323 }
3324 // module transforms
3325 for (var i = 0; i < state.transforms.length; i++) {
3326 code = state.transforms[i](el, code);
3327 }
3328 return code
3329 }
3330}
3331
3332// hoist static sub-trees out
3333function genStatic (el, state) {
3334 el.staticProcessed = true;
3335 state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
3336 return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
3337}
3338
3339// v-once
3340function genOnce (el, state) {
3341 el.onceProcessed = true;
3342 if (el.if && !el.ifProcessed) {
3343 return genIf(el, state)
3344 } else if (el.staticInFor) {
3345 var key = '';
3346 var parent = el.parent;
3347 while (parent) {
3348 if (parent.for) {
3349 key = parent.key;
3350 break
3351 }
3352 parent = parent.parent;
3353 }
3354 if (!key) {
3355 process.env.NODE_ENV !== 'production' && state.warn(
3356 "v-once can only be used inside v-for that is keyed. "
3357 );
3358 return genElement(el, state)
3359 }
3360 return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + (key ? ("," + key) : "") + ")")
3361 } else {
3362 return genStatic(el, state)
3363 }
3364}
3365
3366function genIf (
3367 el,
3368 state,
3369 altGen,
3370 altEmpty
3371) {
3372 el.ifProcessed = true; // avoid recursion
3373 return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
3374}
3375
3376function genIfConditions (
3377 conditions,
3378 state,
3379 altGen,
3380 altEmpty
3381) {
3382 if (!conditions.length) {
3383 return altEmpty || '_e()'
3384 }
3385
3386 var condition = conditions.shift();
3387 if (condition.exp) {
3388 return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
3389 } else {
3390 return ("" + (genTernaryExp(condition.block)))
3391 }
3392
3393 // v-if with v-once should generate code like (a)?_m(0):_m(1)
3394 function genTernaryExp (el) {
3395 return altGen
3396 ? altGen(el, state)
3397 : el.once
3398 ? genOnce(el, state)
3399 : genElement(el, state)
3400 }
3401}
3402
3403function genFor (
3404 el,
3405 state,
3406 altGen,
3407 altHelper
3408) {
3409 var exp = el.for;
3410 var alias = el.alias;
3411 var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
3412 var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
3413
3414 if (process.env.NODE_ENV !== 'production' &&
3415 state.maybeComponent(el) &&
3416 el.tag !== 'slot' &&
3417 el.tag !== 'template' &&
3418 !el.key
3419 ) {
3420 state.warn(
3421 "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
3422 "v-for should have explicit keys. " +
3423 "See https://vuejs.org/guide/list.html#key for more info.",
3424 true /* tip */
3425 );
3426 }
3427
3428 el.forProcessed = true; // avoid recursion
3429 return (altHelper || '_l') + "((" + exp + ")," +
3430 "function(" + alias + iterator1 + iterator2 + "){" +
3431 "return " + ((altGen || genElement)(el, state)) +
3432 '})'
3433}
3434
3435function genData$2 (el, state) {
3436 var data = '{';
3437
3438 // directives first.
3439 // directives may mutate the el's other properties before they are generated.
3440 var dirs = genDirectives(el, state);
3441 if (dirs) { data += dirs + ','; }
3442
3443 // key
3444 if (el.key) {
3445 data += "key:" + (el.key) + ",";
3446 }
3447 // ref
3448 if (el.ref) {
3449 data += "ref:" + (el.ref) + ",";
3450 }
3451 if (el.refInFor) {
3452 data += "refInFor:true,";
3453 }
3454 // pre
3455 if (el.pre) {
3456 data += "pre:true,";
3457 }
3458 // record original tag name for components using "is" attribute
3459 if (el.component) {
3460 data += "tag:\"" + (el.tag) + "\",";
3461 }
3462 // module data generation functions
3463 for (var i = 0; i < state.dataGenFns.length; i++) {
3464 data += state.dataGenFns[i](el);
3465 }
3466 // attributes
3467 if (el.attrs) {
3468 data += "attrs:{" + (genProps(el.attrs)) + "},";
3469 }
3470 // DOM props
3471 if (el.props) {
3472 data += "domProps:{" + (genProps(el.props)) + "},";
3473 }
3474 // event handlers
3475 if (el.events) {
3476 data += (genHandlers(el.events, false, state.warn)) + ",";
3477 }
3478 if (el.nativeEvents) {
3479 data += (genHandlers(el.nativeEvents, true, state.warn)) + ",";
3480 }
3481 // slot target
3482 if (el.slotTarget) {
3483 data += "slot:" + (el.slotTarget) + ",";
3484 }
3485 // scoped slots
3486 if (el.scopedSlots) {
3487 data += (genScopedSlots(el.scopedSlots, state)) + ",";
3488 }
3489 // component v-model
3490 if (el.model) {
3491 data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
3492 }
3493 // inline-template
3494 if (el.inlineTemplate) {
3495 var inlineTemplate = genInlineTemplate(el, state);
3496 if (inlineTemplate) {
3497 data += inlineTemplate + ",";
3498 }
3499 }
3500 data = data.replace(/,$/, '') + '}';
3501 // v-bind data wrap
3502 if (el.wrapData) {
3503 data = el.wrapData(data);
3504 }
3505 // v-on data wrap
3506 if (el.wrapListeners) {
3507 data = el.wrapListeners(data);
3508 }
3509 return data
3510}
3511
3512function genDirectives (el, state) {
3513 var dirs = el.directives;
3514 if (!dirs) { return }
3515 var res = 'directives:[';
3516 var hasRuntime = false;
3517 var i, l, dir, needRuntime;
3518 for (i = 0, l = dirs.length; i < l; i++) {
3519 dir = dirs[i];
3520 needRuntime = true;
3521 var gen = state.directives[dir.name];
3522 if (gen) {
3523 // compile-time directive that manipulates AST.
3524 // returns true if it also needs a runtime counterpart.
3525 needRuntime = !!gen(el, dir, state.warn);
3526 }
3527 if (needRuntime) {
3528 hasRuntime = true;
3529 res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
3530 }
3531 }
3532 if (hasRuntime) {
3533 return res.slice(0, -1) + ']'
3534 }
3535}
3536
3537function genInlineTemplate (el, state) {
3538 var ast = el.children[0];
3539 if (process.env.NODE_ENV !== 'production' && (
3540 el.children.length > 1 || ast.type !== 1
3541 )) {
3542 state.warn('Inline-template components must have exactly one child element.');
3543 }
3544 if (ast.type === 1) {
3545 var inlineRenderFns = generate$1(ast, state.options);
3546 return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
3547 }
3548}
3549
3550function genScopedSlots (
3551 slots,
3552 state
3553) {
3554 return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
3555 return genScopedSlot(key, slots[key], state)
3556 }).join(',')) + "])")
3557}
3558
3559function genScopedSlot (
3560 key,
3561 el,
3562 state
3563) {
3564 if (el.for && !el.forProcessed) {
3565 return genForScopedSlot(key, el, state)
3566 }
3567 return "{key:" + key + ",fn:function(" + (String(el.attrsMap.scope)) + "){" +
3568 "return " + (el.tag === 'template'
3569 ? genChildren(el, state) || 'void 0'
3570 : genElement(el, state)) + "}}"
3571}
3572
3573function genForScopedSlot (
3574 key,
3575 el,
3576 state
3577) {
3578 var exp = el.for;
3579 var alias = el.alias;
3580 var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
3581 var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
3582 el.forProcessed = true; // avoid recursion
3583 return "_l((" + exp + ")," +
3584 "function(" + alias + iterator1 + iterator2 + "){" +
3585 "return " + (genScopedSlot(key, el, state)) +
3586 '})'
3587}
3588
3589function genChildren (
3590 el,
3591 state,
3592 checkSkip,
3593 altGenElement,
3594 altGenNode
3595) {
3596 var children = el.children;
3597 if (children.length) {
3598 var el$1 = children[0];
3599 // optimize single v-for
3600 if (children.length === 1 &&
3601 el$1.for &&
3602 el$1.tag !== 'template' &&
3603 el$1.tag !== 'slot'
3604 ) {
3605 return (altGenElement || genElement)(el$1, state)
3606 }
3607 var normalizationType = checkSkip
3608 ? getNormalizationType(children, state.maybeComponent)
3609 : 0;
3610 var gen = altGenNode || genNode;
3611 return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
3612 }
3613}
3614
3615// determine the normalization needed for the children array.
3616// 0: no normalization needed
3617// 1: simple normalization needed (possible 1-level deep nested array)
3618// 2: full normalization needed
3619function getNormalizationType (
3620 children,
3621 maybeComponent
3622) {
3623 var res = 0;
3624 for (var i = 0; i < children.length; i++) {
3625 var el = children[i];
3626 if (el.type !== 1) {
3627 continue
3628 }
3629 if (needsNormalization(el) ||
3630 (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
3631 res = 2;
3632 break
3633 }
3634 if (maybeComponent(el) ||
3635 (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
3636 res = 1;
3637 }
3638 }
3639 return res
3640}
3641
3642function needsNormalization (el) {
3643 return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
3644}
3645
3646function genNode (node, state) {
3647 if (node.type === 1) {
3648 return genElement(node, state)
3649 } if (node.type === 3 && node.isComment) {
3650 return genComment(node)
3651 } else {
3652 return genText(node)
3653 }
3654}
3655
3656function genText (text) {
3657 return ("_v(" + (text.type === 2
3658 ? text.expression // no need for () because already wrapped in _s()
3659 : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
3660}
3661
3662function genComment (comment) {
3663 return ("_e('" + (comment.text) + "')")
3664}
3665
3666function genSlot (el, state) {
3667 var slotName = el.slotName || '"default"';
3668 var children = genChildren(el, state);
3669 var res = "_t(" + slotName + (children ? ("," + children) : '');
3670 var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
3671 var bind$$1 = el.attrsMap['v-bind'];
3672 if ((attrs || bind$$1) && !children) {
3673 res += ",null";
3674 }
3675 if (attrs) {
3676 res += "," + attrs;
3677 }
3678 if (bind$$1) {
3679 res += (attrs ? '' : ',null') + "," + bind$$1;
3680 }
3681 return res + ')'
3682}
3683
3684// componentName is el.component, take it as argument to shun flow's pessimistic refinement
3685function genComponent (
3686 componentName,
3687 el,
3688 state
3689) {
3690 var children = el.inlineTemplate ? null : genChildren(el, state, true);
3691 return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
3692}
3693
3694function genProps (props) {
3695 var res = '';
3696 for (var i = 0; i < props.length; i++) {
3697 var prop = props[i];
3698 res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
3699 }
3700 return res.slice(0, -1)
3701}
3702
3703// #3895, #4268
3704function transformSpecialNewlines (text) {
3705 return text
3706 .replace(/\u2028/g, '\\u2028')
3707 .replace(/\u2029/g, '\\u2029')
3708}
3709
3710/* */
3711
3712// these keywords should not appear inside expressions, but operators like
3713// typeof, instanceof and in are allowed
3714var prohibitedKeywordRE = new RegExp('\\b' + (
3715 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
3716 'super,throw,while,yield,delete,export,import,return,switch,default,' +
3717 'extends,finally,continue,debugger,function,arguments'
3718).split(',').join('\\b|\\b') + '\\b');
3719
3720// these unary operators should not be used as property/method names
3721var unaryOperatorsRE = new RegExp('\\b' + (
3722 'delete,typeof,void'
3723).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
3724
3725// check valid identifier for v-for
3726var identRE = /[A-Za-z_$][\w$]*/;
3727
3728// strip strings in expressions
3729var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
3730
3731// detect problematic expressions in a template
3732function detectErrors (ast) {
3733 var errors = [];
3734 if (ast) {
3735 checkNode(ast, errors);
3736 }
3737 return errors
3738}
3739
3740function checkNode (node, errors) {
3741 if (node.type === 1) {
3742 for (var name in node.attrsMap) {
3743 if (dirRE.test(name)) {
3744 var value = node.attrsMap[name];
3745 if (value) {
3746 if (name === 'v-for') {
3747 checkFor(node, ("v-for=\"" + value + "\""), errors);
3748 } else if (onRE.test(name)) {
3749 checkEvent(value, (name + "=\"" + value + "\""), errors);
3750 } else {
3751 checkExpression(value, (name + "=\"" + value + "\""), errors);
3752 }
3753 }
3754 }
3755 }
3756 if (node.children) {
3757 for (var i = 0; i < node.children.length; i++) {
3758 checkNode(node.children[i], errors);
3759 }
3760 }
3761 } else if (node.type === 2) {
3762 checkExpression(node.expression, node.text, errors);
3763 }
3764}
3765
3766function checkEvent (exp, text, errors) {
3767 var stipped = exp.replace(stripStringRE, '');
3768 var keywordMatch = stipped.match(unaryOperatorsRE);
3769 if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
3770 errors.push(
3771 "avoid using JavaScript unary operator as property name: " +
3772 "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
3773 );
3774 }
3775 checkExpression(exp, text, errors);
3776}
3777
3778function checkFor (node, text, errors) {
3779 checkExpression(node.for || '', text, errors);
3780 checkIdentifier(node.alias, 'v-for alias', text, errors);
3781 checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
3782 checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
3783}
3784
3785function checkIdentifier (ident, type, text, errors) {
3786 if (typeof ident === 'string' && !identRE.test(ident)) {
3787 errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
3788 }
3789}
3790
3791function checkExpression (exp, text, errors) {
3792 try {
3793 new Function(("return " + exp));
3794 } catch (e) {
3795 var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
3796 if (keywordMatch) {
3797 errors.push(
3798 "avoid using JavaScript keyword as property name: " +
3799 "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
3800 );
3801 } else {
3802 errors.push(("invalid expression: " + (text.trim())));
3803 }
3804 }
3805}
3806
3807/* */
3808
3809function createFunction (code, errors) {
3810 try {
3811 return new Function(code)
3812 } catch (err) {
3813 errors.push({ err: err, code: code });
3814 return noop
3815 }
3816}
3817
3818function createCompileToFunctionFn (compile) {
3819 var cache = Object.create(null);
3820
3821 return function compileToFunctions (
3822 template$$1,
3823 options,
3824 vm
3825 ) {
3826 options = options || {};
3827
3828 /* istanbul ignore if */
3829 if (process.env.NODE_ENV !== 'production') {
3830 // detect possible CSP restriction
3831 try {
3832 new Function('return 1');
3833 } catch (e) {
3834 if (e.toString().match(/unsafe-eval|CSP/)) {
3835 warn$2(
3836 'It seems you are using the standalone build of Vue.js in an ' +
3837 'environment with Content Security Policy that prohibits unsafe-eval. ' +
3838 'The template compiler cannot work in this environment. Consider ' +
3839 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
3840 'templates into render functions.'
3841 );
3842 }
3843 }
3844 }
3845
3846 // check cache
3847 var key = options.delimiters
3848 ? String(options.delimiters) + template$$1
3849 : template$$1;
3850 if (cache[key]) {
3851 return cache[key]
3852 }
3853
3854 // compile
3855 var compiled = compile(template$$1, options);
3856
3857 // check compilation errors/tips
3858 if (process.env.NODE_ENV !== 'production') {
3859 if (compiled.errors && compiled.errors.length) {
3860 warn$2(
3861 "Error compiling template:\n\n" + template$$1 + "\n\n" +
3862 compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
3863 vm
3864 );
3865 }
3866 if (compiled.tips && compiled.tips.length) {
3867 compiled.tips.forEach(function (msg) { return tip(msg, vm); });
3868 }
3869 }
3870
3871 // turn code into functions
3872 var res = {};
3873 var fnGenErrors = [];
3874 res.render = createFunction(compiled.render, fnGenErrors);
3875 res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
3876 return createFunction(code, fnGenErrors)
3877 });
3878
3879 // check function generation errors.
3880 // this should only happen if there is a bug in the compiler itself.
3881 // mostly for codegen development use
3882 /* istanbul ignore if */
3883 if (process.env.NODE_ENV !== 'production') {
3884 if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
3885 warn$2(
3886 "Failed to generate render function:\n\n" +
3887 fnGenErrors.map(function (ref) {
3888 var err = ref.err;
3889 var code = ref.code;
3890
3891 return ((err.toString()) + " in\n\n" + code + "\n");
3892 }).join('\n'),
3893 vm
3894 );
3895 }
3896 }
3897
3898 return (cache[key] = res)
3899 }
3900}
3901
3902/* */
3903
3904function createCompilerCreator (baseCompile) {
3905 return function createCompiler (baseOptions) {
3906 function compile (
3907 template$$1,
3908 options
3909 ) {
3910 var finalOptions = Object.create(baseOptions);
3911 var errors = [];
3912 var tips = [];
3913 finalOptions.warn = function (msg, tip) {
3914 (tip ? tips : errors).push(msg);
3915 };
3916
3917 if (options) {
3918 // merge custom modules
3919 if (options.modules) {
3920 finalOptions.modules =
3921 (baseOptions.modules || []).concat(options.modules);
3922 }
3923 // merge custom directives
3924 if (options.directives) {
3925 finalOptions.directives = extend(
3926 Object.create(baseOptions.directives),
3927 options.directives
3928 );
3929 }
3930 // copy other options
3931 for (var key in options) {
3932 if (key !== 'modules' && key !== 'directives') {
3933 finalOptions[key] = options[key];
3934 }
3935 }
3936 }
3937
3938 var compiled = baseCompile(template$$1, finalOptions);
3939 if (process.env.NODE_ENV !== 'production') {
3940 errors.push.apply(errors, detectErrors(compiled.ast));
3941 }
3942 compiled.errors = errors;
3943 compiled.tips = tips;
3944 return compiled
3945 }
3946
3947 return {
3948 compile: compile,
3949 compileToFunctions: createCompileToFunctionFn(compile)
3950 }
3951 }
3952}
3953
3954var tagMap = {
3955 'br': 'view',
3956 'hr': 'view',
3957
3958 'p': 'view',
3959 'h1': 'view',
3960 'h2': 'view',
3961 'h3': 'view',
3962 'h4': 'view',
3963 'h5': 'view',
3964 'h6': 'view',
3965 'abbr': 'view',
3966 'address': 'view',
3967 'b': 'view',
3968 'bdi': 'view',
3969 'bdo': 'view',
3970 'blockquote': 'view',
3971 'cite': 'view',
3972 'code': 'view',
3973 'del': 'view',
3974 'ins': 'view',
3975 'dfn': 'view',
3976 'em': 'view',
3977 'strong': 'view',
3978 'samp': 'view',
3979 'kbd': 'view',
3980 'var': 'view',
3981 'i': 'view',
3982 'mark': 'view',
3983 'pre': 'view',
3984 'q': 'view',
3985 'ruby': 'view',
3986 'rp': 'view',
3987 'rt': 'view',
3988 's': 'view',
3989 'small': 'view',
3990 'sub': 'view',
3991 'sup': 'view',
3992 'time': 'view',
3993 'u': 'view',
3994 'wbr': 'view',
3995
3996 // 表单元素
3997 'form': 'form',
3998 'input': 'input',
3999 'textarea': 'textarea',
4000 'button': 'button',
4001 'select': 'picker',
4002 'option': 'view',
4003 'optgroup': 'view',
4004 'label': 'label',
4005 'fieldset': 'view',
4006 'datalist': 'picker',
4007 'legend': 'view',
4008 'output': 'view',
4009
4010 // 框架
4011 'iframe': 'view',
4012 // 图像
4013 'img': 'image',
4014 'canvas': 'canvas',
4015 'figure': 'view',
4016 'figcaption': 'view',
4017
4018 // 音视频
4019 'audio': 'audio',
4020 'source': 'audio',
4021 'video': 'video',
4022 'track': 'video',
4023 // 链接
4024 'a': 'navigator',
4025 'nav': 'view',
4026 'link': 'navigator',
4027 // 列表
4028 'ul': 'view',
4029 'ol': 'view',
4030 'li': 'view',
4031 'dl': 'view',
4032 'dt': 'view',
4033 'dd': 'view',
4034 'menu': 'view',
4035 'command': 'view',
4036
4037 // 表格table
4038 'table': 'view',
4039 'caption': 'view',
4040 'th': 'view',
4041 'td': 'view',
4042 'tr': 'view',
4043 'thead': 'view',
4044 'tbody': 'view',
4045 'tfoot': 'view',
4046 'col': 'view',
4047 'colgroup': 'view',
4048
4049 // 样式
4050 'div': 'view',
4051 'main': 'view',
4052 'span': 'label',
4053 'header': 'view',
4054 'footer': 'view',
4055 'section': 'view',
4056 'article': 'view',
4057 'aside': 'view',
4058 'details': 'view',
4059 'dialog': 'view',
4060 'summary': 'view',
4061
4062 'progress': 'progress',
4063 'meter': 'progress',
4064 'head': 'view',
4065 'meta': 'view',
4066 'base': 'text',
4067 'area': 'navigator',
4068
4069 'script': 'view',
4070 'noscript': 'view',
4071 'embed': 'view',
4072 'object': 'view',
4073 'param': 'view',
4074
4075 // https://mp.weixin.qq.com/debug/wxadoc/dev/component/
4076 // [...document.querySelectorAll('.markdown-section tbody td:first-child')].map(v => v.textContent).join(',\n')
4077 'view': 'view',
4078 'scroll-view': 'scroll-view',
4079 'swiper': 'swiper',
4080 'icon': 'icon',
4081 'text': 'text',
4082 'checkbox': 'checkbox',
4083 'radio': 'radio',
4084 'picker': 'picker',
4085 'picker-view': 'picker-view',
4086 'slider': 'slider',
4087 'switch': 'switch',
4088 'navigator': 'navigator',
4089 'image': 'image',
4090 'map': 'map',
4091 'contact-button': 'contact-button',
4092 'block': 'block'
4093};
4094
4095function maybeTag (tagName) {
4096 return tagMap[tagName]
4097}
4098
4099function getWxEleId (index, arr) {
4100 if (!arr || !arr.length) {
4101 return ("'" + index + "'")
4102 }
4103
4104 var str = arr.join("+'-'+");
4105 return ("'" + index + "_'+" + str)
4106}
4107
4108// 检查不允许在 v-for 的时候出现2个及其以上相同 iterator1
4109function checkRepeatIterator (arr, options) {
4110 var len = arr.length;
4111 if (len > 1 && len !== new Set(arr).size) {
4112 options.warn(("同一组件内嵌套的 v-for 不能连续使用相同的索引,目前为: " + arr), false);
4113 }
4114}
4115
4116function fixDefaultIterator (path) {
4117 var forText = path.for;
4118 var iterator1 = path.iterator1;
4119 if (forText && !iterator1) {
4120 path.iterator1 = 'index';
4121 }
4122}
4123
4124function addAttr$1 (path, key, value, inVdom) {
4125 path[key] = value;
4126 path.plain = false;
4127 // path.attrsMap[key] = value
4128 if (!inVdom) {
4129 path.attrsMap[("data-" + key)] = "{{" + value + "}}";
4130 }
4131
4132 // if (!path.attrsList) {
4133 // path.attrsList = []
4134 // }
4135 // path.attrsList.push({ name: `':${key}'`, value })
4136
4137 if (!path.attrs) {
4138 path.attrs = [];
4139 }
4140 path.attrs.push({ name: key, value: value });
4141}
4142
4143function mark (path, options, deps, iteratorArr) {
4144 if ( iteratorArr === void 0 ) iteratorArr = [];
4145
4146 fixDefaultIterator(path);
4147
4148 var tag = path.tag;
4149 var children = path.children;
4150 var iterator1 = path.iterator1;
4151 var events = path.events;
4152 var directives = path.directives;
4153 var ifConditions = path.ifConditions;
4154
4155 var currentArr = Object.assign([], iteratorArr);
4156
4157 if (iterator1) {
4158 currentArr.push(iterator1);
4159 }
4160
4161 checkRepeatIterator(currentArr, options);
4162
4163 // 递归子节点
4164 if (children && children.length) {
4165 children.forEach(function (v, i) {
4166 // const counterIterator = children.slice(0, i).filter(v => v.for).map(v => v.for + '.length').join(`+'-'+`)
4167 mark(v, options, deps, currentArr);
4168 });
4169 }
4170
4171 // fix: v-else events
4172 if (ifConditions && ifConditions.length > 1) {
4173 ifConditions.slice(1).forEach(function (v, i) {
4174 mark(v.block, options, deps, currentArr);
4175 });
4176 }
4177
4178 // for mpvue-template-compiler
4179 // events || v-model
4180 var hasModel = directives && directives.find(function (v) { return v.name === 'model'; });
4181 var needEventsID = events || hasModel;
4182
4183 if (needEventsID) {
4184 var eventId = getWxEleId(deps.eventIndex, currentArr);
4185 // const eventId = getWxEleId(eIndex, currentArr)
4186 addAttr$1(path, 'eventid', eventId);
4187 path.attrsMap['data-comkey'] = '{{$k}}';
4188 deps.eventIndex += 1;
4189 // eIndex += 1
4190 }
4191
4192 // 子组件
4193 if (!tag || maybeTag(tag)) {
4194 return
4195 }
4196
4197 // eg. '1-'+i+'-'+j
4198 var value = getWxEleId(deps.comIndex, currentArr);
4199 addAttr$1(path, 'mpcomid', value, true);
4200 path['mpcomid'] = value;
4201 deps.comIndex += 1;
4202}
4203
4204// 全局的事件触发器 ID
4205// let eIndex = 0
4206function markComponent (ast, options) {
4207 var deps = { comIndex: 0, eventIndex: 0 };
4208 mark(ast, options, deps);
4209
4210 return ast
4211}
4212
4213/* */
4214
4215// for mp
4216// `createCompilerCreator` allows creating compilers that use alternative
4217// parser/optimizer/codegen, e.g the SSR optimizing compiler.
4218// Here we just export a default compiler using the default parts.
4219var createCompiler = createCompilerCreator(function baseCompile (
4220 template$$1,
4221 options
4222) {
4223 var originAst = parse(template$$1.trim(), options);
4224 var ast = markComponent(originAst, options);
4225 optimize(ast, options);
4226 var code = generate$1(ast, options);
4227 return {
4228 ast: ast,
4229 render: code.render,
4230 staticRenderFns: code.staticRenderFns
4231 }
4232});
4233
4234// type:
4235// 0, 默认值, 拼接 ${name}={{ ${content} }}
4236// 1, 拼接 ${name}
4237// 2, 拼接 ${map[key]}={{ '${content}' }}
4238// 3, 拼接 {{ ${content} }}
4239// 4, 拼接为空字符串
4240// 5, 不需要在wxml上表现出来,可直接清除
4241
4242var noSupport = {
4243 type: 4,
4244 check: function check (k, v, errors) {
4245 errors(("不支持此指令: " + k + "=\"" + v + "\""));
4246 return false
4247 }
4248};
4249var directiveMap = {
4250 'v-if': {
4251 name: 'wx:if',
4252 type: 0
4253 },
4254 'v-else-if': {
4255 name: 'wx:elif',
4256 type: 0
4257 },
4258 'v-else': {
4259 name: 'wx:else',
4260 type: 1
4261 },
4262 'v-text': {
4263 name: '',
4264 type: 1
4265 },
4266 'v-html': {
4267 name: '',
4268 type: 1
4269 },
4270 'v-on': {
4271 name: '',
4272 map: {
4273 click: 'tap',
4274 touchstart: 'touchstart',
4275 touchmove: 'touchmove',
4276 touchcancel: 'touchcancel',
4277 touchend: 'touchend',
4278 tap: 'tap',
4279 longtap: 'longtap',
4280 input: 'input',
4281 change: 'change',
4282 submit: 'submit',
4283 blur: 'blur',
4284 focus: 'focus',
4285 reset: 'reset',
4286 confirm: 'confirm',
4287 columnchange: 'columnchange',
4288 linechange: 'linechange',
4289 error: 'error',
4290 scrolltoupper: 'scrolltoupper',
4291 scrolltolower: 'scrolltolower',
4292 scroll: 'scroll',
4293 load: 'load'
4294 },
4295 type: 2
4296 },
4297 'v-bind': {
4298 name: '',
4299 map: {
4300 'href': 'url'
4301 },
4302 type: 3
4303 },
4304 'href': {
4305 name: 'url',
4306 type: 2
4307 },
4308 'v-pre': noSupport,
4309 'v-cloak': noSupport,
4310 'v-once': {
4311 name: '',
4312 type: 5
4313 }
4314};
4315
4316var tagConfig = {
4317 virtualTag: ['slot', 'template', 'block']
4318};
4319
4320// babel-plugin-transform-object-to-ternary-operator.js
4321
4322function getStrByNode (node, onlyStr) {
4323 if ( onlyStr === void 0 ) onlyStr = false;
4324
4325 if (onlyStr) {
4326 return node.value || node.name || ''
4327 }
4328 return node.type === 'StringLiteral' ? node : t.stringLiteral(node.name || '')
4329}
4330
4331// 把 { key: value } 转换成 [ value ? 'key' : '' ]
4332var objectVisitor = {
4333 ObjectExpression: function ObjectExpression (path) {
4334 var elements = path.node.properties.map(function (propertyItem) {
4335 return t.conditionalExpression(propertyItem.value, getStrByNode(propertyItem.key), t.stringLiteral(''))
4336 });
4337 path.replaceWith(t.arrayExpression(elements));
4338 }
4339};
4340
4341function transformObjectToTernaryOperator (babel$$1) {
4342 return { visitor: objectVisitor }
4343}
4344
4345// 把 { key: value } 转换成 'key:' + value + ';'
4346var objectToStringVisitor = {
4347 ObjectExpression: function ObjectExpression (path) {
4348 var expression = path.node.properties.map(function (propertyItem) {
4349 var keyStr = getStrByNode(propertyItem.key, true);
4350 var key = keyStr ? hyphenate(keyStr) : keyStr;
4351 var ref = generate(t.ExpressionStatement(propertyItem.value));
4352 var val = ref.code;
4353 return ("'" + key + ":' + (" + (val.slice(0, -1)) + ") + ';'")
4354 }).join('+');
4355
4356 var p = template(expression)({});
4357 path.replaceWith(p.expression);
4358 }
4359};
4360
4361function transformObjectToString (babel$$1) {
4362 return { visitor: objectToStringVisitor }
4363}
4364
4365function transformDynamicClass (staticClass, clsBinding) {
4366 if ( staticClass === void 0 ) staticClass = '';
4367
4368 var result = babel.transform(("!" + clsBinding), { plugins: [transformObjectToTernaryOperator] });
4369 // 先实现功能,再优化代码
4370 // https://github.com/babel/babel/issues/7138
4371 var cls = prettier.format(result.code, { semi: false, singleQuote: true }).slice(1).slice(0, -1).replace(/\n|\r/g, '');
4372 return (staticClass + " {{" + cls + "}}")
4373}
4374
4375function transformDynamicStyle (staticStyle, styleBinding) {
4376 if ( staticStyle === void 0 ) staticStyle = '';
4377
4378 var result = babel.transform(("!" + styleBinding), { plugins: [transformObjectToString] });
4379 var cls = prettier.format(result.code, { semi: false, singleQuote: true }).slice(1).slice(0, -1).replace(/\n|\r/g, '');
4380 return (staticStyle + " {{" + cls + "}}")
4381}
4382
4383var attrs = {
4384 format: function format (attrs) {
4385 if ( attrs === void 0 ) attrs = {};
4386
4387 var obj = {};
4388
4389 Object.keys(attrs).map(function (key) {
4390 var val = attrs[key];
4391 obj[key.replace('@', 'v-on:').replace(/^:/, 'v-bind:')] = val;
4392 });
4393
4394 return obj
4395 },
4396
4397 convertAttr: function convertAttr (ast, log) {
4398 var this$1 = this;
4399
4400 var attrsMap = ast.attrsMap; if ( attrsMap === void 0 ) attrsMap = {};
4401 var tag = ast.tag;
4402 var staticClass = ast.staticClass;
4403 var attrs = {};
4404 var wxClass = this.classObj(attrsMap['v-bind:class'], staticClass);
4405 wxClass.length ? attrsMap['class'] = wxClass : '';
4406 var wxStyle = this.styleObj(attrsMap['v-bind:style'], attrsMap['style']);
4407 wxStyle.length ? attrsMap['style'] = wxStyle : '';
4408
4409 Object.keys(attrsMap).map(function (key) {
4410 var val = attrsMap[key];
4411 if (key === 'v-bind:class' || key === 'v-bind:style') {
4412 return
4413 }
4414 if (key === 'v-text') {
4415 ast.children.unshift({
4416 text: ("{{" + val + "}}"),
4417 type: 3
4418 });
4419 } else if (key === 'v-html') {
4420 ast.tag = 'rich-text';
4421 attrs['nodes'] = "{{" + val + "}}";
4422 } else if (key === 'v-show') {
4423 attrs['hidden'] = "{{!(" + val + ")}}";
4424 } else if (/^v\-on\:/i.test(key)) {
4425 attrs = this$1.event(key, val, attrs, tag);
4426 } else if (/^v\-bind\:/i.test(key)) {
4427 attrs = this$1.bind(key, val, attrs, tag, attrsMap['wx:key']);
4428 } else if (/^v\-model/.test(key)) {
4429 attrs = this$1.model(key, val, attrs, tag, log);
4430 } else if (directiveMap[key]) {
4431 var ref = directiveMap[key] || {};
4432 var name = ref.name; if ( name === void 0 ) name = '';
4433 var type = ref.type;
4434 var map = ref.map; if ( map === void 0 ) map = {};
4435 var check = ref.check;
4436 if (!(check && !check(key, val, log)) && !(!name || typeof type !== 'number')) {
4437 // 见 ./directiveMap.js 注释
4438 if (type === 0) {
4439 attrs[name] = "{{" + val + "}}";
4440 }
4441
4442 if (type === 1) {
4443 attrs[name] = undefined;
4444 }
4445
4446 if (type === 2) {
4447 attrs[name] = val;
4448 }
4449
4450 if (type === 3) {
4451 attrs[map[name] || name] = "{{" + val + "}}";
4452 return
4453 }
4454 }
4455 } else if (/^v\-/.test(key)) {
4456 log(("不支持此属性-> " + key + "=\"" + val + "\""), 'waring');
4457 } else {
4458 if ((tagConfig.virtualTag.indexOf(tag) > -1) && (key === 'class' || key === 'style' || key === 'data-mpcomid')) {
4459 if (key !== 'data-mpcomid') {
4460 log(("template 不支持此属性-> " + key + "=\"" + val + "\""), 'waring');
4461 }
4462 } else {
4463 attrs[key] = val;
4464 }
4465 }
4466 });
4467 ast.attrsMap = attrs;
4468 return ast
4469 },
4470
4471 event: function event (key, val, attrs, tag) {
4472 // 小程序能力所致,bind 和 catch 事件同时绑定时候,只会触发 bind ,catch 不会被触发。
4473 // .stop 的使用会阻止冒泡,但是同时绑定了一个非冒泡事件,会导致该元素上的 catchEventName 失效!
4474 // .prevent 可以直接干掉,因为小程序里没有什么默认事件,比如submit并不会跳转页面
4475 // .capture 不能做,因为小程序没有捕获类型的事件
4476 // .self 没有可以判断的标识
4477 // .once 也不能做,因为小程序没有 removeEventListener, 虽然可以直接在 handleProxy 中处理,但非常的不优雅,违背了原意,暂不考虑
4478 var name = key.replace(/^v\-on\:/i, '').replace(/\.prevent/i, '');
4479 var ref = name.split('.');
4480 var eventName = ref[0];
4481 var eventNameMap = ref.slice(1);
4482 var eventMap = directiveMap['v-on'];
4483 var check = directiveMap.check;
4484
4485 if (check) {
4486 check(key, val);
4487 }
4488 var wxmlEventName = '';
4489 if (eventName === 'change' && (tag === 'input' || tag === 'textarea')) {
4490 wxmlEventName = 'blur';
4491 } else {
4492 wxmlEventName = eventMap.map[eventName];
4493 }
4494
4495 var eventType = 'bind';
4496 var isStop = eventNameMap.includes('stop');
4497 if (eventNameMap.includes('capture')) {
4498 eventType = isStop ? 'capture-catch:' : 'capture-bind:';
4499 } else if (isStop) {
4500 eventType = 'catch';
4501 }
4502
4503 wxmlEventName = eventType + (wxmlEventName || eventName);
4504 attrs[wxmlEventName] = 'handleProxy';
4505
4506 return attrs
4507 },
4508
4509 bind: function bind (key, val, attrs, tag, isIf) {
4510 var name = key.replace(/^v\-bind\:/i, '');
4511
4512 if (isIf && name === 'key') {
4513 attrs['wx:key'] = val;
4514 }
4515
4516 if (tag === 'template') {
4517 return attrs
4518 }
4519
4520 if (name === 'href') {
4521 attrs['url'] = "{{" + val + "}}";
4522 } else {
4523 attrs[name] = "{{" + val + "}}";
4524 }
4525
4526 return attrs
4527 },
4528
4529 classObj: function classObj (clsBinding, staticCls) {
4530 if ( clsBinding === void 0 ) clsBinding = '';
4531
4532 if (!clsBinding && !staticCls) {
4533 return ''
4534 }
4535 if (!clsBinding && staticCls) {
4536 return staticCls
4537 }
4538
4539 return transformDynamicClass(staticCls, clsBinding)
4540 },
4541
4542 styleObj: function styleObj (styleBinding, staticStyle) {
4543 if ( styleBinding === void 0 ) styleBinding = '';
4544
4545 if (!styleBinding && !staticStyle) {
4546 return ''
4547 }
4548 if (!styleBinding && staticStyle) {
4549 return staticStyle
4550 }
4551
4552 return transformDynamicStyle(staticStyle, styleBinding)
4553 },
4554
4555 model: function model (key, val, attrs, tag) {
4556 var isFormInput = tag === 'input' || tag === 'textarea';
4557 attrs['value'] = "{{" + val + "}}";
4558 if (key === 'v-model.lazy') {
4559 if (isFormInput) {
4560 attrs['bindblur'] = 'handleProxy';
4561 } else {
4562 attrs['bindchange'] = 'handleProxy';
4563 }
4564 } else {
4565 if (isFormInput) {
4566 attrs['bindinput'] = 'handleProxy';
4567 } else {
4568 attrs['bindchange'] = 'handleProxy';
4569 }
4570 }
4571
4572 return attrs
4573 }
4574};
4575
4576function getSlotsName (obj) {
4577 if (!obj) {
4578 return ''
4579 }
4580 // wxml模板中 data="{{ a:{a1:'string2'}, b:'string'}}" 键a不能放在最后,会出错
4581 return tmplateSlotsObj(obj)
4582 .concat(
4583 Object.keys(obj).map(function(k) {
4584 return '$slot' + k + ":'" + obj[k] + "'"
4585 })
4586 )
4587 .join(',')
4588}
4589
4590function tmplateSlotsObj(obj) {
4591 if (!obj) {
4592 return []
4593 }
4594 // wxml模板中 data="{{ a:{a1:'string2'}, b:'string'}}" 键a1不能写成 'a1' 带引号的形式,会出错
4595 var $for = Object.keys(obj)
4596 .map(function(k) {
4597 return (k + ":'" + (obj[k]) + "'")
4598 })
4599 .join(',');
4600 return $for ? [("$for:{" + $for + "}")] : []
4601}
4602
4603var component = {
4604 isComponent: function isComponent (tagName, components) {
4605 if ( components === void 0 ) components = {};
4606
4607 return !!components[tagName]
4608 },
4609 convertComponent: function convertComponent (ast, components, slotName) {
4610 var attrsMap = ast.attrsMap;
4611 var tag = ast.tag;
4612 var mpcomid = ast.mpcomid;
4613 var slots = ast.slots;
4614 if (slotName) {
4615 attrsMap['data'] = "{{...$root[$p], ...$root[$k], $root}}";
4616 // bindedName is available when rendering slot in v-for
4617 var bindedName = attrsMap['v-bind:name'];
4618 if(bindedName) {
4619 attrsMap['is'] = "{{$for[" + bindedName + "]}}";
4620 } else {
4621 attrsMap['is'] = "{{" + slotName + "}}";
4622 }
4623 } else {
4624 var slotsName = getSlotsName(slots);
4625 var restSlotsName = slotsName ? (", " + slotsName) : '';
4626 attrsMap['data'] = "{{...$root[$kk+" + mpcomid + "], $root" + restSlotsName + "}}";
4627 attrsMap['is'] = components[tag].name;
4628 }
4629 return ast
4630 }
4631};
4632
4633var astMap = {
4634 'if': 'wx:if',
4635 'iterator1': 'wx:for-index',
4636 'key': 'wx:key',
4637 'alias': 'wx:for-item',
4638 'v-for': 'wx:for'
4639};
4640
4641var convertFor = function (ast) {
4642 var iterator1 = ast.iterator1;
4643 var forText = ast.for;
4644 var key = ast.key;
4645 var alias = ast.alias;
4646 var attrsMap = ast.attrsMap;
4647
4648 if (forText) {
4649 attrsMap[astMap['v-for']] = "{{" + forText + "}}";
4650 if (iterator1) {
4651 attrsMap[astMap['iterator1']] = iterator1;
4652 }
4653 if (key) {
4654 attrsMap[astMap['key']] = key;
4655 }
4656 if (alias) {
4657 attrsMap[astMap['alias']] = alias;
4658 }
4659
4660 delete attrsMap['v-for'];
4661 }
4662
4663 return ast
4664};
4665
4666// import component from './component'
4667var tag = function (ast, options, component) {
4668 var tag = ast.tag;
4669 var elseif = ast.elseif;
4670 var elseText = ast.else;
4671 var forText = ast.for;
4672 var staticClass = ast.staticClass; if ( staticClass === void 0 ) staticClass = '';
4673 var attrsMap = ast.attrsMap; if ( attrsMap === void 0 ) attrsMap = {};
4674 var components = options.components;
4675 var ifText = attrsMap['v-if'];
4676 var href = attrsMap.href;
4677 var bindHref = attrsMap['v-bind:href'];
4678 var name = attrsMap.name;
4679
4680 if (!tag) {
4681 return ast
4682 }
4683 var isComponent = component.isComponent(tag, components);
4684 if (tag !== 'template' && tag !== 'block' && tag !== 'slot' && !isComponent) {
4685 ast.staticClass = staticClass ? ("_" + tag + " " + staticClass) : ("_" + tag);
4686 }
4687 ast.tag = tagMap[tag] || tag;
4688
4689 var isSlot = tag === 'slot';
4690
4691 if ((ifText || elseif || elseText || forText) && tag === 'template') {
4692 ast.tag = 'block';
4693 } else if (isComponent || isSlot) {
4694 var originSlotName = name || 'default';
4695 var slotName = isSlot ? ("$slot" + originSlotName + " || '" + originSlotName + "'") : undefined;
4696
4697 // 用完必须删除,不然会被编译成 <template name="xxx"> 在小程序中就会表示这是一个模版申明而不是使用,小程序中不能同时申明和使用模版
4698 delete ast.attrsMap.name;
4699 ast = component.convertComponent(ast, components, slotName);
4700 ast.tag = 'template';
4701 } else if (tag === 'a' && !(href || bindHref)) {
4702 ast.tag = 'view';
4703 } else if (ast.events && ast.events.scroll) {
4704 ast.tag = 'scroll-view';
4705 } else if (tag === 'input') {
4706 var type = attrsMap.type;
4707 if (type && ['button', 'checkbox', 'radio'].indexOf(type) > -1) {
4708 delete ast.attrsMap.type;
4709 ast.tag = type;
4710 }
4711 if (type === 'button') {
4712 ast.children.push({
4713 text: attrsMap.value || '',
4714 type: 3
4715 });
4716 delete ast.attrsMap.value;
4717 }
4718 }
4719 return ast
4720};
4721
4722function convertAst (node, options, util, conventRule) {
4723 if ( options === void 0 ) options = {};
4724
4725 var children = node.children;
4726 var ifConditions = node.ifConditions;
4727 var staticClass = node.staticClass; if ( staticClass === void 0 ) staticClass = '';
4728 var mpcomid = node.mpcomid;
4729 var tagName = node.tag;
4730 var log = util.log;
4731 var deps = util.deps;
4732 var slots = util.slots;
4733 var slotTemplates = util.slotTemplates;
4734 var mpmlAst = Object.assign({}, node);
4735 var moduleId = options.moduleId;
4736 var components = options.components;
4737 mpmlAst.tag = tagName = tagName ? hyphenate(tagName) : tagName;
4738 // 引入 import, isSlot 是使用 slot 的编译地方,意即 <slot></slot> 的地方
4739 var isSlot = tagName === 'slot';
4740 if (isSlot) {
4741 deps.slots = 'slots';
4742 // 把当前 slot 节点包裹 template
4743 var defSlot = Object.assign({}, mpmlAst);
4744 defSlot.tag = 'template';
4745 var templateName = "" + (defSlot.attrsMap.name || 'default');
4746 defSlot.attrsMap.name = templateName;
4747 mpmlAst.children = [];
4748 defSlot.parent = node.parent.parent;
4749 slotTemplates[templateName] = defSlot;
4750 }
4751
4752 var currentIsComponent = conventRule.component.isComponent(tagName, components);
4753 if (currentIsComponent) {
4754 deps[tagName] = tagName;
4755 }
4756
4757 if (moduleId && !currentIsComponent && tagConfig.virtualTag.indexOf(tagName) < 0) {
4758 mpmlAst.staticClass = staticClass ? (moduleId + " " + staticClass).replace(/\"/g, '') : moduleId;
4759 } else {
4760 mpmlAst.staticClass = staticClass.replace(/\"/g, '');
4761 }
4762
4763 // 组件内部的node节点全部是 slot
4764 mpmlAst.slots = {};
4765 if (currentIsComponent && children && children.length) {
4766 // 只检查组件下的子节点(不检查孙子节点)是不是具名 slot,不然就是 default slot
4767 children
4768 .reduce(function (res, n) {
4769 var ref = n.attrsMap || {};
4770 var slot = ref.slot;
4771 // 不是具名的,全部放在第一个数组元素中
4772 var arr = slot ? res : res[0];
4773 arr.push(n);
4774 return res
4775 }, [[]])
4776 .forEach(function (n) {
4777 var isDefault = Array.isArray(n);
4778 var slotName = isDefault ? 'default' : n.attrsMap.slot;
4779 var slotId = moduleId + "-" + slotName + "-" + (mpcomid.replace(/\'/g, ''));
4780 var node = isDefault ? { tag: 'slot', attrsMap: {}, children: n } : n;
4781
4782 node.tag = 'template';
4783 node.attrsMap.name = slotId;
4784 delete node.attrsMap.slot;
4785 // 缓存,会集中生成一个 slots 文件
4786 slots[slotId] = { node: convertAst(node, options, util, conventRule), name: slotName, slotId: slotId };
4787 mpmlAst.slots[slotName] = slotId;
4788 });
4789 // 清理当前组件下的节点信息,因为 slot 都被转移了
4790 children.length = 0;
4791 mpmlAst.children.length = 0;
4792 }
4793
4794 mpmlAst.attrsMap = conventRule.attrs.format(mpmlAst.attrsMap);
4795 mpmlAst = tag(mpmlAst, options, conventRule.component);
4796 mpmlAst = conventRule.convertFor(mpmlAst, options);
4797 mpmlAst = conventRule.attrs.convertAttr(mpmlAst, log);
4798 if (children && !isSlot) {
4799 mpmlAst.children = children.map(function (k) { return convertAst(k, options, util, conventRule); });
4800 }
4801
4802 if (ifConditions) {
4803 var length = ifConditions.length;
4804 for (var i = 1; i < length; i++) {
4805 mpmlAst.ifConditions[i].block = convertAst(ifConditions[i].block, options, util, conventRule);
4806 }
4807 }
4808
4809 return mpmlAst
4810}
4811
4812function getAstCommon (compiled, options, log, conventRule) {
4813 if ( options === void 0 ) options = {};
4814
4815 var ast = compiled.ast;
4816 var deps = {
4817 // slots: 'slots'
4818 };
4819 var slots = {
4820 // slotId: nodeAst
4821 };
4822 var slotTemplates = {
4823 };
4824
4825 var wxast = convertAst(ast, options, { log: log, deps: deps, slots: slots, slotTemplates: slotTemplates }, conventRule);
4826 var children = Object.keys(slotTemplates).map(function (k) { return convertAst(slotTemplates[k], options, { log: log, deps: deps, slots: slots, slotTemplates: slotTemplates }, conventRule); });
4827 wxast.children = children.concat(wxast.children);
4828 return {
4829 wxast: wxast,
4830 deps: deps,
4831 slots: slots
4832 }
4833}
4834
4835function mpmlAst (compiled, options, log) {
4836 if ( options === void 0 ) options = {};
4837
4838 var conventRule = { attrs: attrs, component: component, convertFor: convertFor };
4839 return getAstCommon(compiled, options, log, conventRule)
4840}
4841
4842var utils = {
4843 toLowerCase: function toLowerCase (str) {
4844 return str.replace(/([A-Z])/g, '-$1').toLowerCase().trim()
4845 },
4846
4847 getChar: function getChar (index) {
4848 return String.fromCharCode(0x61 + index)
4849 },
4850
4851 log: function log (compiled) {
4852 compiled.mpErrors = [];
4853 compiled.mpTips = [];
4854
4855 return function (str, type) {
4856 if (type === 'waring') {
4857 compiled.mpTips.push(str);
4858 } else {
4859 compiled.mpErrors.push(str);
4860 }
4861 }
4862 }
4863};
4864
4865var autoEndTags = [
4866 'progress',
4867 'checkbox',
4868 'switch',
4869 'input',
4870 'radio',
4871 'slider',
4872 'textarea'
4873];
4874
4875function convertAttr (key, val) {
4876 return (val === '' || typeof val === 'undefined') ? key : (key + "=\"" + val + "\"")
4877}
4878
4879function generateCode (nodeAst, options) {
4880 if ( options === void 0 ) options = {};
4881
4882 var tag = nodeAst.tag;
4883 var attrsMap = nodeAst.attrsMap; if ( attrsMap === void 0 ) attrsMap = {};
4884 var children = nodeAst.children; if ( children === void 0 ) children = [];
4885 var text = nodeAst.text;
4886 var ifConditions = nodeAst.ifConditions; if ( ifConditions === void 0 ) ifConditions = [];
4887 if (!tag) {
4888 return text
4889 }
4890 // v-if 指令
4891 var ifConditionsArr = [];
4892 if (ifConditions) {
4893 var length = ifConditions.length;
4894 for (var i = 1; i < length; i++) {
4895 ifConditionsArr.push(generateCode(ifConditions[i].block, options));
4896 }
4897 }
4898 var childrenContent = children.map(function (childAst) { return generateCode(childAst, options); }).join('');
4899 var attrs = Object.keys(attrsMap).map(function (key) { return convertAttr(key, attrsMap[key]); }).join(' ');
4900 attrs = attrs ? (" " + attrs) : '';
4901
4902 if (autoEndTags.indexOf(tag) > -1 && !childrenContent) {
4903 return ("<" + tag + attrs + " />" + (ifConditionsArr.join('')))
4904 }
4905 return ("<" + tag + attrs + ">" + childrenContent + "</" + tag + ">" + (ifConditionsArr.join('')))
4906
4907 // if (autoEndTags.indexOf(tag) > -1 && !children.length) {
4908 // return `<${tag}${attrs ? ' ' + attrs : ''} />${ifConditionsArr.join('')}`
4909 // }
4910 // return `<${tag}${attrs ? ' ' + attrs : ''}>${childrenContent}</${tag}>${ifConditionsArr.join('')}`
4911}
4912
4913
4914function compileToMPMLCommon (compiled, options, getAst) {
4915 if ( options === void 0 ) options = {};
4916
4917 // TODO, compiled is undefined
4918 var components = options.components; if ( components === void 0 ) components = {};
4919 var log = utils.log(compiled);
4920
4921 var ref = getAst(compiled, options, log);
4922 var wxast = ref.wxast;
4923 var deps = ref.deps; if ( deps === void 0 ) deps = {};
4924 var slots = ref.slots; if ( slots === void 0 ) slots = {};
4925 var code = generateCode(wxast, options);
4926
4927 // 引用子模版
4928 var importCode = Object.keys(deps).map(function (k) { return components[k] ? ("<import src=\"" + (components[k].src) + "\" />") : ''; }).join('');
4929 code = importCode + "<template name=\"" + (options.name) + "\">" + code + "</template>";
4930
4931 // 生成 slots code
4932 Object.keys(slots).forEach(function (k) {
4933 var slot = slots[k];
4934 slot.code = generateCode(slot.node, options);
4935 });
4936
4937 // TODO: 后期优化掉这种暴力全部 import,虽然对性能没啥大影响
4938 return { code: code, compiled: compiled, slots: slots, importCode: importCode }
4939}
4940
4941function compileToMPML$1 (compiled, options) {
4942 if ( options === void 0 ) options = {};
4943
4944 return compileToMPMLCommon(compiled, options, mpmlAst)
4945}
4946
4947// type:
4948// 0, 默认值, 拼接 ${name}={{ ${content} }}
4949// 1, 拼接 ${name}
4950// 2, 拼接 ${map[key]}={{ '${content}' }}
4951// 3, 拼接 {{ ${content} }}
4952// 4, 拼接为空字符串
4953// 5, 不需要在wxml上表现出来,可直接清除
4954
4955var noSupport$1 = {
4956 type: 4,
4957 check: function check (k, v, errors) {
4958 errors(("不支持此指令: " + k + "=\"" + v + "\""));
4959 return false
4960 }
4961};
4962var directiveMap$1 = {
4963 'v-if': {
4964 name: 's-if',
4965 type: 2
4966 },
4967 'v-else-if': {
4968 name: 's-elif',
4969 type: 2
4970 },
4971 'v-else': {
4972 name: 's-else',
4973 type: 1
4974 },
4975 'v-text': {
4976 name: '',
4977 type: 1
4978 },
4979 'v-html': {
4980 name: '',
4981 type: 1
4982 },
4983 'v-on': {
4984 name: '',
4985 map: {
4986 click: 'tap',
4987 touchstart: 'touchstart',
4988 touchmove: 'touchmove',
4989 touchcancel: 'touchcancel',
4990 touchend: 'touchend',
4991 tap: 'tap',
4992 longtap: 'longtap',
4993 input: 'input',
4994 change: 'change',
4995 submit: 'submit',
4996 blur: 'blur',
4997 focus: 'focus',
4998 reset: 'reset',
4999 confirm: 'confirm',
5000 columnchange: 'columnchange',
5001 linechange: 'linechange',
5002 error: 'error',
5003 scrolltoupper: 'scrolltoupper',
5004 scrolltolower: 'scrolltolower',
5005 scroll: 'scroll',
5006 load: 'load'
5007 },
5008 type: 2
5009 },
5010 'v-bind': {
5011 name: '',
5012 map: {
5013 'href': 'url'
5014 },
5015 type: 3
5016 },
5017 'href': {
5018 name: 'url',
5019 type: 2
5020 },
5021 'v-pre': noSupport$1,
5022 'v-cloak': noSupport$1,
5023 'v-once': {
5024 name: '',
5025 type: 5
5026 }
5027};
5028
5029function transformDynamicClass$1 (staticClass, clsBinding) {
5030 if ( staticClass === void 0 ) staticClass = '';
5031
5032 var result = babel.transform(("!" + clsBinding), { plugins: [transformObjectToTernaryOperator] });
5033 // 先实现功能,再优化代码
5034 // https://github.com/babel/babel/issues/7138
5035 var cls = prettier.format(result.code, { semi: false, singleQuote: true }).slice(1).slice(0, -1).replace(/\n|\r/g, '');
5036 return (staticClass + " {{" + cls + "}}")
5037}
5038
5039function transformDynamicStyle$1 (staticStyle, styleBinding) {
5040 if ( staticStyle === void 0 ) staticStyle = '';
5041
5042 var result = babel.transform(("!" + styleBinding), { plugins: [transformObjectToString] });
5043 var cls = prettier.format(result.code, { semi: false, singleQuote: true }).slice(1).slice(0, -1).replace(/\n|\r/g, '');
5044 return (staticStyle + " {{" + cls + "}}")
5045}
5046
5047var attrs$1 = {
5048 format: function format (attrs) {
5049 if ( attrs === void 0 ) attrs = {};
5050
5051 var obj = {};
5052
5053 Object.keys(attrs).map(function (key) {
5054 var val = attrs[key];
5055 obj[key.replace('@', 'v-on:').replace(/^:/, 'v-bind:')] = val;
5056 });
5057
5058 return obj
5059 },
5060
5061 convertAttr: function convertAttr (ast, log) {
5062 var this$1 = this;
5063
5064 var attrsMap = ast.attrsMap; if ( attrsMap === void 0 ) attrsMap = {};
5065 var tag = ast.tag;
5066 var staticClass = ast.staticClass;
5067 var attrs = {};
5068 var wxClass = this.classObj(attrsMap['v-bind:class'], staticClass);
5069 wxClass.length ? attrsMap['class'] = wxClass : '';
5070 var wxStyle = this.styleObj(attrsMap['v-bind:style'], attrsMap['style']);
5071 wxStyle.length ? attrsMap['style'] = wxStyle : '';
5072
5073 Object.keys(attrsMap).map(function (key) {
5074 var val = attrsMap[key];
5075 if (key === 'v-bind:class' || key === 'v-bind:style') {
5076 return
5077 }
5078 if (key === 'v-text') {
5079 ast.children.unshift({
5080 text: ("{{" + val + "}}"),
5081 type: 3
5082 });
5083 } else if (key === 'v-html') {
5084 ast.tag = 'rich-text';
5085 attrs['nodes'] = "{{" + val + "}}";
5086 } else if (key === 'v-show') {
5087 attrs['hidden'] = "{{!(" + val + ")}}";
5088 } else if (/^v\-on\:/i.test(key)) {
5089 attrs = this$1.event(key, val, attrs, tag);
5090 } else if (/^v\-bind\:/i.test(key)) {
5091 attrs = this$1.bind(key, val, attrs, tag, attrsMap['wx:key']);
5092 } else if (/^v\-model/.test(key)) {
5093 attrs = this$1.model(key, val, attrs, tag, log);
5094 } else if (directiveMap$1[key]) {
5095 var ref = directiveMap$1[key] || {};
5096 var name = ref.name; if ( name === void 0 ) name = '';
5097 var type = ref.type;
5098 var map = ref.map; if ( map === void 0 ) map = {};
5099 var check = ref.check;
5100 if (!(check && !check(key, val, log)) && !(!name || typeof type !== 'number')) {
5101 // 见 ./directiveMap.js 注释
5102 if (type === 0) {
5103 attrs[name] = "{{" + val + "}}";
5104 }
5105
5106 if (type === 1) {
5107 attrs[name] = undefined;
5108 }
5109
5110 if (type === 2) {
5111 attrs[name] = val;
5112 }
5113
5114 if (type === 3) {
5115 attrs[map[name] || name] = "{{" + val + "}}";
5116 return
5117 }
5118 }
5119 } else if (/^v\-/.test(key)) {
5120 log(("不支持此属性-> " + key + "=\"" + val + "\""), 'waring');
5121 } else {
5122 if ((tagConfig.virtualTag.indexOf(tag) > -1) && (key === 'class' || key === 'style' || key === 'data-mpcomid')) {
5123 if (key !== 'data-mpcomid') {
5124 log(("template 不支持此属性-> " + key + "=\"" + val + "\""), 'waring');
5125 }
5126 } else {
5127 attrs[key] = val;
5128 }
5129 }
5130 });
5131 ast.attrsMap = attrs;
5132 return ast
5133 },
5134
5135 event: function event (key, val, attrs, tag) {
5136 // 小程序能力所致,bind 和 catch 事件同时绑定时候,只会触发 bind ,catch 不会被触发。
5137 // .stop 的使用会阻止冒泡,但是同时绑定了一个非冒泡事件,会导致该元素上的 catchEventName 失效!
5138 // .prevent 可以直接干掉,因为小程序里没有什么默认事件,比如submit并不会跳转页面
5139 // .capture 不能做,因为小程序没有捕获类型的事件
5140 // .self 没有可以判断的标识
5141 // .once 也不能做,因为小程序没有 removeEventListener, 虽然可以直接在 handleProxy 中处理,但非常的不优雅,违背了原意,暂不考虑
5142 var name = key.replace(/^v\-on\:/i, '').replace(/\.prevent/i, '');
5143 var ref = name.split('.');
5144 var eventName = ref[0];
5145 var eventNameMap = ref.slice(1);
5146 var eventMap = directiveMap$1['v-on'];
5147 var check = directiveMap$1.check;
5148
5149 if (check) {
5150 check(key, val);
5151 }
5152 var wxmlEventName = '';
5153 if (eventName === 'change' && (tag === 'input' || tag === 'textarea')) {
5154 wxmlEventName = 'blur';
5155 } else {
5156 wxmlEventName = eventMap.map[eventName];
5157 }
5158
5159 var eventType = 'bind';
5160 var isStop = eventNameMap.includes('stop');
5161 if (eventNameMap.includes('capture')) {
5162 eventType = isStop ? 'capture-catch:' : 'capture-bind:';
5163 } else if (isStop) {
5164 eventType = 'catch';
5165 }
5166
5167 wxmlEventName = eventType + (wxmlEventName || eventName);
5168 attrs[wxmlEventName] = 'handleProxy';
5169
5170 return attrs
5171 },
5172
5173 bind: function bind (key, val, attrs, tag, isIf) {
5174 var name = key.replace(/^v\-bind\:/i, '');
5175
5176 if (isIf && name === 'key') {
5177 attrs['wx:key'] = val;
5178 }
5179
5180 if (tag === 'template') {
5181 return attrs
5182 }
5183
5184 if (name === 'href') {
5185 attrs['url'] = "{{" + val + "}}";
5186 } else {
5187 attrs[name] = "{{" + val + "}}";
5188 }
5189
5190 if (tag === 'scroll-view') {
5191 if (name === 'scroll-top' || name === 'scroll-left' || name === 'scroll-into-view') {
5192 attrs[name] = "{=" + val + "=}";
5193 }
5194 }
5195
5196 if (tag === 'input' || tag === 'textarea' || tag === 'slider') {
5197 if (name === 'value') {
5198 attrs[name] = "{=" + val + "=}";
5199 }
5200 }
5201
5202 if (tag === 'movable-view' && (name === 'x' || name === 'y')) {
5203 attrs[name] = "{=" + val + "=}";
5204 }
5205
5206 return attrs
5207 },
5208
5209 classObj: function classObj (clsBinding, staticCls) {
5210 if ( clsBinding === void 0 ) clsBinding = '';
5211
5212 if (!clsBinding && !staticCls) {
5213 return ''
5214 }
5215 if (!clsBinding && staticCls) {
5216 return staticCls
5217 }
5218
5219 return transformDynamicClass$1(staticCls, clsBinding)
5220 },
5221
5222 styleObj: function styleObj (styleBinding, staticStyle) {
5223 if ( styleBinding === void 0 ) styleBinding = '';
5224
5225 if (!styleBinding && !staticStyle) {
5226 return ''
5227 }
5228 if (!styleBinding && staticStyle) {
5229 return staticStyle
5230 }
5231
5232 return transformDynamicStyle$1(staticStyle, styleBinding)
5233 },
5234
5235 model: function model (key, val, attrs, tag) {
5236 var isFormInput = tag === 'input' || tag === 'textarea';
5237 attrs['value'] = "{{" + val + "}}";
5238 if (key === 'v-model.lazy') {
5239 if (isFormInput) {
5240 attrs['bindblur'] = 'handleProxy';
5241 } else {
5242 attrs['bindchange'] = 'handleProxy';
5243 }
5244 } else {
5245 if (isFormInput) {
5246 attrs['bindinput'] = 'handleProxy';
5247 } else {
5248 attrs['bindchange'] = 'handleProxy';
5249 }
5250 }
5251
5252 return attrs
5253 }
5254};
5255
5256function getSlotsName$1 (obj) {
5257 if (!obj) {
5258 return ''
5259 }
5260 // wxml模板中 data="{{ a:{a1:'string2'}, b:'string'}}" 键a不能放在最后,会出错
5261 return tmplateSlotsObj$1(obj)
5262 .concat(
5263 Object.keys(obj).map(function (k) { return ("$slot" + k + ":'" + (obj[k]) + "'"); })
5264 )
5265 .join(',')
5266}
5267
5268function tmplateSlotsObj$1 (obj) {
5269 if (!obj) {
5270 return []
5271 }
5272 // wxml模板中 data="{{ a:{a1:'string2'}, b:'string'}}" 键a1不能写成 'a1' 带引号的形式,会出错
5273 var $for = Object.keys(obj)
5274 .map(function (k) { return (k + ":'" + (obj[k]) + "'"); })
5275 .join(',');
5276 return $for ? [("$for:{" + $for + "}")] : []
5277}
5278
5279var component$1 = {
5280 isComponent: function isComponent (tagName, components) {
5281 if ( components === void 0 ) components = {};
5282
5283 return !!components[tagName]
5284 },
5285 convertComponent: function convertComponent (ast, components, slotName) {
5286 var attrsMap = ast.attrsMap;
5287 var tag = ast.tag;
5288 var mpcomid = ast.mpcomid;
5289 var slots = ast.slots;
5290 if (slotName) {
5291 attrsMap['data'] = '{{{...$root[$k], $root}}}';
5292 // bindedName is available when rendering slot in v-for
5293 var bindedName = attrsMap['v-bind:name'];
5294 if (bindedName) {
5295 attrsMap['is'] = '{{$for[' + bindedName + ']}}';
5296 } else {
5297 attrsMap['is'] = '{{' + slotName + '}}';
5298 }
5299 } else {
5300 var slotsName = getSlotsName$1(slots);
5301 var restSlotsName = slotsName ? (", " + slotsName) : '';
5302 attrsMap['data'] = "{{{...$root[$kk+" + mpcomid + "], $root" + restSlotsName + "}}}";
5303 attrsMap['is'] = components[tag].name;
5304 }
5305 return ast
5306 }
5307};
5308
5309var astMap$1 = {
5310 'if': 's-if',
5311 'v-for': 's-for',
5312 'alias': 's-for-item',
5313 'iterator1': 's-for-index',
5314 'key': 's-key'
5315};
5316
5317var convertFor$1 = function (ast) {
5318 var iterator1 = ast.iterator1;
5319 var forText = ast.for;
5320 var key = ast.key;
5321 var alias = ast.alias;
5322 var attrsMap = ast.attrsMap;
5323
5324 // 缩写:<view s-for="p,index in persons">
5325 // 全写:<view s-for="persons" s-for-index="index" s-for-item="p">
5326
5327 if (forText) {
5328 attrsMap[astMap$1['v-for']] = alias + "," + iterator1 + " in " + forText;
5329 // attrsMap[astMap['v-for']] = forText
5330 // if (iterator1) {
5331 // attrsMap[astMap['iterator1']] = iterator1
5332 // }
5333 // if (alias) {
5334 // attrsMap[astMap['alias']] = alias
5335 // }
5336 // if (key) {
5337 // attrsMap[astMap['key']] = key
5338 // }
5339 delete attrsMap['v-for'];
5340 }
5341
5342
5343 return ast
5344};
5345
5346function mpmlAst$1 (compiled, options, log) {
5347 if ( options === void 0 ) options = {};
5348
5349 var conventRule = { attrs: attrs$1, component: component$1, convertFor: convertFor$1 };
5350 return getAstCommon(compiled, options, log, conventRule)
5351}
5352
5353function compileToMPML$2 (compiled, options) {
5354 if ( options === void 0 ) options = {};
5355
5356 return compileToMPMLCommon(compiled, options, mpmlAst$1)
5357}
5358
5359// type:
5360// 0, 默认值, 拼接 ${name}={{ ${content} }}
5361// 1, 拼接 ${name}
5362// 2, 拼接 ${map[key]}={{ '${content}' }}
5363// 3, 拼接 {{ ${content} }}
5364// 4, 拼接为空字符串
5365// 5, 不需要在wxml上表现出来,可直接清除
5366
5367var noSupport$2 = {
5368 type: 4,
5369 check: function check (k, v, errors) {
5370 errors(("不支持此指令: " + k + "=\"" + v + "\""));
5371 return false
5372 }
5373};
5374var directiveMap$2 = {
5375 'v-if': {
5376 name: 'tt:if',
5377 type: 0
5378 },
5379 'v-else-if': {
5380 name: 'tt:elif',
5381 type: 0
5382 },
5383 'v-else': {
5384 name: 'tt:else',
5385 type: 1
5386 },
5387 'v-text': {
5388 name: '',
5389 type: 1
5390 },
5391 'v-html': {
5392 name: '',
5393 type: 1
5394 },
5395 'v-on': {
5396 name: '',
5397 map: {
5398 click: 'tap',
5399 touchstart: 'touchstart',
5400 touchmove: 'touchmove',
5401 touchcancel: 'touchcancel',
5402 touchend: 'touchend',
5403 tap: 'tap',
5404 longtap: 'longtap',
5405 input: 'input',
5406 change: 'change',
5407 submit: 'submit',
5408 blur: 'blur',
5409 focus: 'focus',
5410 reset: 'reset',
5411 confirm: 'confirm',
5412 columnchange: 'columnchange',
5413 linechange: 'linechange',
5414 error: 'error',
5415 scrolltoupper: 'scrolltoupper',
5416 scrolltolower: 'scrolltolower',
5417 scroll: 'scroll',
5418 load: 'load'
5419 },
5420 type: 2
5421 },
5422 'v-bind': {
5423 name: '',
5424 map: {
5425 'href': 'url'
5426 },
5427 type: 3
5428 },
5429 'href': {
5430 name: 'url',
5431 type: 2
5432 },
5433 'v-pre': noSupport$2,
5434 'v-cloak': noSupport$2,
5435 'v-once': {
5436 name: '',
5437 type: 5
5438 }
5439};
5440
5441function transformDynamicClass$2 (staticClass, clsBinding) {
5442 if ( staticClass === void 0 ) staticClass = '';
5443
5444 var result = babel.transform(("!" + clsBinding), { plugins: [transformObjectToTernaryOperator] });
5445 // 先实现功能,再优化代码
5446 // https://github.com/babel/babel/issues/7138
5447 var cls = prettier.format(result.code, { semi: false, singleQuote: true }).slice(1).slice(0, -1).replace(/\n|\r/g, '');
5448 return (staticClass + " {{" + cls + "}}")
5449}
5450
5451function transformDynamicStyle$2 (staticStyle, styleBinding) {
5452 if ( staticStyle === void 0 ) staticStyle = '';
5453
5454 var result = babel.transform(("!" + styleBinding), { plugins: [transformObjectToString] });
5455 var cls = prettier.format(result.code, { semi: false, singleQuote: true }).slice(1).slice(0, -1).replace(/\n|\r/g, '');
5456 return (staticStyle + " {{" + cls + "}}")
5457}
5458
5459var attrs$2 = {
5460 format: function format (attrs) {
5461 if ( attrs === void 0 ) attrs = {};
5462
5463 var obj = {};
5464
5465 Object.keys(attrs).map(function (key) {
5466 var val = attrs[key];
5467 obj[key.replace('@', 'v-on:').replace(/^:/, 'v-bind:')] = val;
5468 });
5469
5470 return obj
5471 },
5472
5473 convertAttr: function convertAttr (ast, log) {
5474 var this$1 = this;
5475
5476 var attrsMap = ast.attrsMap; if ( attrsMap === void 0 ) attrsMap = {};
5477 var tag = ast.tag;
5478 var staticClass = ast.staticClass;
5479 var attrs = {};
5480 var wxClass = this.classObj(attrsMap['v-bind:class'], staticClass);
5481 wxClass.length ? attrsMap['class'] = wxClass : '';
5482 var wxStyle = this.styleObj(attrsMap['v-bind:style'], attrsMap['style']);
5483 wxStyle.length ? attrsMap['style'] = wxStyle : '';
5484
5485 Object.keys(attrsMap).map(function (key) {
5486 var val = attrsMap[key];
5487 if (key === 'v-bind:class' || key === 'v-bind:style') {
5488 return
5489 }
5490 if (key === 'v-text') {
5491 ast.children.unshift({
5492 text: ("{{" + val + "}}"),
5493 type: 3
5494 });
5495 } else if (key === 'v-html') {
5496 ast.tag = 'rich-text';
5497 attrs['nodes'] = "{{" + val + "}}";
5498 } else if (key === 'v-show') {
5499 attrs['hidden'] = "{{!(" + val + ")}}";
5500 } else if (/^v\-on\:/i.test(key)) {
5501 attrs = this$1.event(key, val, attrs, tag);
5502 } else if (/^v\-bind\:/i.test(key)) {
5503 attrs = this$1.bind(key, val, attrs, tag, attrsMap['tt:key']);
5504 } else if (/^v\-model/.test(key)) {
5505 attrs = this$1.model(key, val, attrs, tag, log);
5506 } else if (directiveMap$2[key]) {
5507 var ref = directiveMap$2[key] || {};
5508 var name = ref.name; if ( name === void 0 ) name = '';
5509 var type = ref.type;
5510 var map = ref.map; if ( map === void 0 ) map = {};
5511 var check = ref.check;
5512 if (!(check && !check(key, val, log)) && !(!name || typeof type !== 'number')) {
5513 // 见 ./directiveMap.js 注释
5514 if (type === 0) {
5515 attrs[name] = "{{" + val + "}}";
5516 }
5517
5518 if (type === 1) {
5519 attrs[name] = undefined;
5520 }
5521
5522 if (type === 2) {
5523 attrs[name] = val;
5524 }
5525
5526 if (type === 3) {
5527 attrs[map[name] || name] = "{{" + val + "}}";
5528 return
5529 }
5530 }
5531 } else if (/^v\-/.test(key)) {
5532 log(("不支持此属性-> " + key + "=\"" + val + "\""), 'waring');
5533 } else {
5534 if ((tagConfig.virtualTag.indexOf(tag) > -1) && (key === 'class' || key === 'style' || key === 'data-mpcomid')) {
5535 if (key !== 'data-mpcomid') {
5536 log(("template 不支持此属性-> " + key + "=\"" + val + "\""), 'waring');
5537 }
5538 } else {
5539 attrs[key] = val;
5540 }
5541 }
5542 });
5543 ast.attrsMap = attrs;
5544 return ast
5545 },
5546
5547 event: function event (key, val, attrs, tag) {
5548 // 小程序能力所致,bind 和 catch 事件同时绑定时候,只会触发 bind ,catch 不会被触发。
5549 // .stop 的使用会阻止冒泡,但是同时绑定了一个非冒泡事件,会导致该元素上的 catchEventName 失效!
5550 // .prevent 可以直接干掉,因为小程序里没有什么默认事件,比如submit并不会跳转页面
5551 // .capture 不能做,因为小程序没有捕获类型的事件
5552 // .self 没有可以判断的标识
5553 // .once 也不能做,因为小程序没有 removeEventListener, 虽然可以直接在 handleProxy 中处理,但非常的不优雅,违背了原意,暂不考虑
5554 var name = key.replace(/^v\-on\:/i, '').replace(/\.prevent/i, '');
5555 var ref = name.split('.');
5556 var eventName = ref[0];
5557 var eventNameMap = ref.slice(1);
5558 var eventMap = directiveMap$2['v-on'];
5559 var check = directiveMap$2.check;
5560
5561 if (check) {
5562 check(key, val);
5563 }
5564 var wxmlEventName = '';
5565 if (eventName === 'change' && (tag === 'input' || tag === 'textarea')) {
5566 wxmlEventName = 'blur';
5567 } else {
5568 wxmlEventName = eventMap.map[eventName];
5569 }
5570
5571 var eventType = 'bind';
5572 var isStop = eventNameMap.includes('stop');
5573 if (eventNameMap.includes('capture')) {
5574 eventType = isStop ? 'capture-catch:' : 'capture-bind:';
5575 } else if (isStop) {
5576 eventType = 'catch';
5577 }
5578
5579 wxmlEventName = eventType + (wxmlEventName || eventName);
5580 attrs[wxmlEventName] = 'handleProxy';
5581
5582 return attrs
5583 },
5584
5585 bind: function bind (key, val, attrs, tag, isIf) {
5586 var name = key.replace(/^v\-bind\:/i, '');
5587
5588 if (isIf && name === 'key') {
5589 attrs['tt:key'] = val;
5590 }
5591
5592 if (tag === 'template') {
5593 return attrs
5594 }
5595
5596 if (name === 'href') {
5597 attrs['url'] = "{{" + val + "}}";
5598 } else {
5599 attrs[name] = "{{" + val + "}}";
5600 }
5601
5602 return attrs
5603 },
5604
5605 classObj: function classObj (clsBinding, staticCls) {
5606 if ( clsBinding === void 0 ) clsBinding = '';
5607
5608 if (!clsBinding && !staticCls) {
5609 return ''
5610 }
5611 if (!clsBinding && staticCls) {
5612 return staticCls
5613 }
5614
5615 return transformDynamicClass$2(staticCls, clsBinding)
5616 },
5617
5618 styleObj: function styleObj (styleBinding, staticStyle) {
5619 if ( styleBinding === void 0 ) styleBinding = '';
5620
5621 if (!styleBinding && !staticStyle) {
5622 return ''
5623 }
5624 if (!styleBinding && staticStyle) {
5625 return staticStyle
5626 }
5627
5628 return transformDynamicStyle$2(staticStyle, styleBinding)
5629 },
5630
5631 model: function model (key, val, attrs, tag) {
5632 var isFormInput = tag === 'input' || tag === 'textarea';
5633 attrs['value'] = "{{" + val + "}}";
5634 if (key === 'v-model.lazy') {
5635 if (isFormInput) {
5636 attrs['bindblur'] = 'handleProxy';
5637 } else {
5638 attrs['bindchange'] = 'handleProxy';
5639 }
5640 } else {
5641 if (isFormInput) {
5642 attrs['bindinput'] = 'handleProxy';
5643 } else {
5644 attrs['bindchange'] = 'handleProxy';
5645 }
5646 }
5647
5648 return attrs
5649 }
5650};
5651
5652function getSlotsName$2 (obj) {
5653 if (!obj) {
5654 return ''
5655 }
5656 // wxml模板中 data="{{ a:{a1:'string2'}, b:'string'}}" 键a不能放在最后,会出错
5657 return tmplateSlotsObj$2(obj)
5658 .concat(
5659 Object.keys(obj).map(function(k) {
5660 return '$slot' + k + ":'" + obj[k] + "'"
5661 })
5662 )
5663 .join(',')
5664}
5665
5666function tmplateSlotsObj$2(obj) {
5667 if (!obj) {
5668 return []
5669 }
5670 // wxml模板中 data="{{ a:{a1:'string2'}, b:'string'}}" 键a1不能写成 'a1' 带引号的形式,会出错
5671 var $for = Object.keys(obj)
5672 .map(function(k) {
5673 return (k + ":'" + (obj[k]) + "'")
5674 })
5675 .join(',');
5676 return $for ? [("$for:{" + $for + "}")] : []
5677}
5678
5679var component$2 = {
5680 isComponent: function isComponent (tagName, components) {
5681 if ( components === void 0 ) components = {};
5682
5683 return !!components[tagName]
5684 },
5685 convertComponent: function convertComponent (ast, components, slotName) {
5686 var attrsMap = ast.attrsMap;
5687 var tag = ast.tag;
5688 var mpcomid = ast.mpcomid;
5689 var slots = ast.slots;
5690 if (slotName) {
5691 attrsMap['data'] = "{{...$root[$p], ...$root[$k], $root}}";
5692 // bindedName is available when rendering slot in v-for
5693 var bindedName = attrsMap['v-bind:name'];
5694 if(bindedName) {
5695 attrsMap['is'] = "{{$for[" + bindedName + "]}}";
5696 } else {
5697 attrsMap['is'] = "{{" + slotName + "}}";
5698 }
5699 } else {
5700 var slotsName = getSlotsName$2(slots);
5701 var restSlotsName = slotsName ? (", " + slotsName) : '';
5702 attrsMap['data'] = "{{...$root[$kk+" + mpcomid + "], $root" + restSlotsName + "}}";
5703 attrsMap['is'] = components[tag].name;
5704 }
5705 return ast
5706 }
5707};
5708
5709var astMap$2 = {
5710 'if': 'tt:if',
5711 'iterator1': 'tt:for-index',
5712 'key': 'tt:key',
5713 'alias': 'tt:for-item',
5714 'v-for': 'tt:for'
5715};
5716
5717var convertFor$2 = function (ast) {
5718 var iterator1 = ast.iterator1;
5719 var forText = ast.for;
5720 var key = ast.key;
5721 var alias = ast.alias;
5722 var attrsMap = ast.attrsMap;
5723 if (forText) {
5724 attrsMap[astMap$2['v-for']] = "{{" + forText + "}}";
5725 if (iterator1) {
5726 attrsMap[astMap$2['iterator1']] = iterator1;
5727 }
5728 if (key) {
5729 attrsMap[astMap$2['key']] = key;
5730 }
5731 if (alias) {
5732 attrsMap[astMap$2['alias']] = alias;
5733 }
5734
5735 delete attrsMap['v-for'];
5736 }
5737
5738 return ast
5739};
5740
5741function mpmlAst$2 (compiled, options, log) {
5742 if ( options === void 0 ) options = {};
5743
5744 var conventRule = { attrs: attrs$2, component: component$2, convertFor: convertFor$2 };
5745 return getAstCommon(compiled, options, log, conventRule)
5746}
5747
5748function compileToMPML$3 (compiled, options) {
5749 if ( options === void 0 ) options = {};
5750
5751 return compileToMPMLCommon(compiled, options, mpmlAst$2)
5752}
5753
5754// type:
5755// 0, 默认值, 拼接 ${name}={{ ${content} }}
5756// 1, 拼接 ${name}
5757// 2, 拼接 ${map[key]}={{ '${content}' }}
5758// 3, 拼接 {{ ${content} }}
5759// 4, 拼接为空字符串
5760// 5, 不需要在wxml上表现出来,可直接清除
5761
5762var noSupport$3 = {
5763 type: 4,
5764 check: function (k, v, errors) {
5765 errors(("不支持此指令: " + k + "=\"" + v + "\""));
5766 return false
5767 }
5768};
5769
5770var directiveMap$3 = {
5771 'v-if': {
5772 name: 'a:if',
5773 type: 0
5774 },
5775 'v-else-if': {
5776 name: 'a:elif',
5777 type: 0
5778 },
5779 'v-else': {
5780 name: 'a:else',
5781 type: 1
5782 },
5783 'v-text': {
5784 name: '',
5785 type: 1
5786 },
5787 'v-html': {
5788 name: '',
5789 type: 1
5790 },
5791 'v-on': {
5792 name: '',
5793 map: {
5794 click: 'tap',
5795 touchstart: 'touchStart',
5796 touchmove: 'touchMove',
5797 touchcancel: 'touchCancel',
5798 touchend: 'touchEnd',
5799 tap: 'tap',
5800 longtap: 'longTap',
5801 input: 'input',
5802 change: 'change',
5803 submit: 'submit',
5804 blur: 'blur',
5805 focus: 'focus',
5806 reset: 'reset',
5807 confirm: 'confirm',
5808 columnchange: 'columnChange',
5809 linechange: 'lineChange',
5810 error: 'error',
5811 scrolltoupper: 'scrollToUpper',
5812 scrolltolower: 'scrollToLower',
5813 scroll: 'scroll',
5814 load: 'load'
5815 },
5816 type: 2
5817 },
5818 'v-bind': {
5819 name: '',
5820 map: {
5821 'href': 'url'
5822 },
5823 type: 3
5824 },
5825 'href': {
5826 name: 'url',
5827 type: 2
5828 },
5829 'v-pre': noSupport$3,
5830 'v-cloak': noSupport$3,
5831 'v-once': {
5832 name: '',
5833 type: 5
5834 }
5835};
5836
5837function transformDynamicClass$3 (staticClass, clsBinding) {
5838 if ( staticClass === void 0 ) staticClass = '';
5839
5840 var result = babel.transform(("!" + clsBinding), { plugins: [transformObjectToTernaryOperator] });
5841 // 先实现功能,再优化代码
5842 // https://github.com/babel/babel/issues/7138
5843 var cls = prettier.format(result.code, { semi: false, singleQuote: true }).slice(1).slice(0, -1).replace(/\n|\r/g, '');
5844 return (staticClass + " {{" + cls + "}}")
5845}
5846
5847function transformDynamicStyle$3 (staticStyle, styleBinding) {
5848 if ( staticStyle === void 0 ) staticStyle = '';
5849
5850 var result = babel.transform(("!" + styleBinding), { plugins: [transformObjectToString] });
5851 var cls = prettier.format(result.code, { semi: false, singleQuote: true }).slice(1).slice(0, -1).replace(/\n|\r/g, '');
5852 return (staticStyle + " {{" + cls + "}}")
5853}
5854
5855var attrs$3 = {
5856 format: function format (attrs) {
5857 if ( attrs === void 0 ) attrs = {};
5858
5859 var obj = {};
5860
5861 Object.keys(attrs).map(function (key) {
5862 var val = attrs[key];
5863 obj[key.replace('@', 'v-on:').replace(/^:/, 'v-bind:')] = val;
5864 });
5865 return obj
5866 },
5867
5868 convertAttr: function convertAttr (ast, log) {
5869 var this$1 = this;
5870
5871 var attrsMap = ast.attrsMap; if ( attrsMap === void 0 ) attrsMap = {};
5872 var tag = ast.tag;
5873 var staticClass = ast.staticClass;
5874 var attrs = {};
5875 var wxClass = this.classObj(attrsMap['v-bind:class'], staticClass);
5876 wxClass.length ? attrsMap['class'] = wxClass : '';
5877 var wxStyle = this.styleObj(attrsMap['v-bind:style'], attrsMap['style']);
5878 wxStyle.length ? attrsMap['style'] = wxStyle : '';
5879
5880 Object.keys(attrsMap).map(function (key) {
5881 var val = attrsMap[key];
5882 if (key === 'v-bind:class' || key === 'v-bind:style') {
5883 return
5884 }
5885 if (key === 'v-text') {
5886 ast.children.unshift({
5887 text: ("{{" + val + "}}"),
5888 type: 3
5889 });
5890 } else if (key === 'v-html') {
5891 ast.tag = 'rich-text';
5892 attrs['nodes'] = "{{" + val + "}}";
5893 } else if (key === 'v-show') {
5894 attrs['hidden'] = "{{!(" + val + ")}}";
5895 } else if (/^v\-on\:/i.test(key)) {
5896 attrs = this$1.event(key, val, attrs, tag, log);
5897 } else if (/^v\-bind\:/i.test(key)) {
5898 attrs = this$1.bind(key, val, attrs, tag, attrsMap['a:key']);
5899 } else if (/^v\-model/.test(key)) {
5900 attrs = this$1.model(key, val, attrs, tag, log);
5901 } else if (directiveMap$3[key]) {
5902 var ref = directiveMap$3[key] || {};
5903 var name = ref.name; if ( name === void 0 ) name = '';
5904 var type = ref.type;
5905 var map = ref.map; if ( map === void 0 ) map = {};
5906 var check = ref.check;
5907 if (!(check && !check(key, val, log)) && !(!name || typeof type !== 'number')) {
5908 // 见 ./directiveMap.js 注释
5909 if (type === 0) {
5910 attrs[name] = "{{" + val + "}}";
5911 }
5912
5913 if (type === 1) {
5914 attrs[name] = undefined;
5915 }
5916
5917 if (type === 2) {
5918 attrs[name] = val;
5919 }
5920
5921 if (type === 3) {
5922 attrs[map[name] || name] = "{{" + val + "}}";
5923 return
5924 }
5925 }
5926 } else if (/^v\-/.test(key)) {
5927 log(("不支持此属性-> " + key + "=\"" + val + "\""), 'waring');
5928 } else {
5929 if ((tagConfig.virtualTag.indexOf(tag) > -1) && (key === 'class' || key === 'style' || key === 'data-mpcomid')) {
5930 if (key !== 'data-mpcomid') {
5931 log(("template 不支持此属性-> " + key + "=\"" + val + "\""), 'waring');
5932 }
5933 } else {
5934 attrs[key] = val;
5935 }
5936 }
5937 });
5938 ast.attrsMap = attrs;
5939 return ast
5940 },
5941
5942 event: function event (key, val, attrs, tag, log) {
5943 // 小程序能力所致,bind 和 catch 事件同时绑定时候,只会触发 bind ,catch 不会被触发。
5944 // .stop 的使用会阻止冒泡,但是同时绑定了一个非冒泡事件,会导致该元素上的 catchEventName 失效!
5945 // .prevent 可以直接干掉,因为小程序里没有什么默认事件,比如submit并不会跳转页面
5946 // .capture 不能做,因为小程序没有捕获类型的事件
5947 // .self 没有可以判断的标识
5948 // .once 也不能做,因为小程序没有 removeEventListener, 虽然可以直接在 handleProxy 中处理,但非常的不优雅,违背了原意,暂不考虑
5949 var name = key.replace(/^v\-on\:/i, '').replace(/\.prevent/i, '');
5950 var ref = name.split('.');
5951 var eventName = ref[0];
5952 var eventNameMap = ref.slice(1);
5953 var eventMap = directiveMap$3['v-on'];
5954 var check = directiveMap$3.check;
5955
5956 if (check) {
5957 check(key, val);
5958 }
5959 var wxmlEventName = '';
5960 if (eventName === 'change' && (tag === 'input' || tag === 'textarea')) {
5961 wxmlEventName = 'blur';
5962 } else {
5963 wxmlEventName = eventMap.map[eventName];
5964 }
5965
5966 var eventType = 'on';
5967 var isStop = eventNameMap.includes('stop');
5968 if (eventNameMap.includes('capture')) {
5969 log('支付宝小程序不支持事件捕获');
5970 } else if (isStop) {
5971 eventType = 'catch';
5972 }
5973 var camelCaseEvent = (wxmlEventName || eventName).replace(/^\S/, function (letter) { return letter.toUpperCase(); });
5974 wxmlEventName = eventType + camelCaseEvent;
5975 attrs[wxmlEventName] = 'handleProxy';
5976
5977 return attrs
5978 },
5979
5980 bind: function bind (key, val, attrs, tag, isIf) {
5981 var name = key.replace(/^v\-bind\:/i, '');
5982
5983 if (isIf && name === 'key') {
5984 attrs['a:key'] = val;
5985 }
5986
5987 if (tag === 'template') {
5988 return attrs
5989 }
5990
5991 if (name === 'href') {
5992 attrs['url'] = "{{" + val + "}}";
5993 } else {
5994 attrs[name] = "{{" + val + "}}";
5995 }
5996
5997 return attrs
5998 },
5999
6000 classObj: function classObj (clsBinding, staticCls) {
6001 if ( clsBinding === void 0 ) clsBinding = '';
6002
6003 if (!clsBinding && !staticCls) {
6004 return ''
6005 }
6006 if (!clsBinding && staticCls) {
6007 return staticCls
6008 }
6009
6010 return transformDynamicClass$3(staticCls, clsBinding)
6011 },
6012
6013 styleObj: function styleObj (styleBinding, staticStyle) {
6014 if ( styleBinding === void 0 ) styleBinding = '';
6015
6016 if (!styleBinding && !staticStyle) {
6017 return ''
6018 }
6019 if (!styleBinding && staticStyle) {
6020 return staticStyle
6021 }
6022
6023 return transformDynamicStyle$3(staticStyle, styleBinding)
6024 },
6025
6026 model: function model (key, val, attrs, tag) {
6027 var isFormInput = tag === 'input' || tag === 'textarea';
6028 attrs['value'] = "{{" + val + "}}";
6029 if (key === 'v-model.lazy') {
6030 if (isFormInput) {
6031 attrs['onBlur'] = 'handleProxy';
6032 } else {
6033 attrs['onChange'] = 'handleProxy';
6034 }
6035 } else {
6036 if (isFormInput) {
6037 attrs['onInput'] = 'handleProxy';
6038 } else {
6039 attrs['onChange'] = 'handleProxy';
6040 }
6041 }
6042 return attrs
6043 }
6044};
6045
6046function getSlotsName$3 (obj) {
6047 if (!obj) {
6048 return ''
6049 }
6050 // wxml模板中 data="{{ a:{a1:'string2'}, b:'string'}}" 键a不能放在最后,会出错
6051 return tmplateSlotsObj$3(obj)
6052 .concat(
6053 Object.keys(obj).map(function (k) {
6054 return '$slot' + k + ":'" + obj[k] + "'"
6055 })
6056 )
6057 .join(',')
6058}
6059
6060function tmplateSlotsObj$3 (obj) {
6061 if (!obj) {
6062 return []
6063 }
6064 // wxml模板中 data="{{ a:{a1:'string2'}, b:'string'}}" 键a1不能写成 'a1' 带引号的形式,会出错
6065 var $for = Object.keys(obj)
6066 .map(function (k) {
6067 return (k + ":'" + (obj[k]) + "'")
6068 })
6069 .join(',');
6070 return $for ? [("$for:{" + $for + "}")] : []
6071}
6072
6073var component$3 = {
6074 isComponent: function isComponent (tagName, components) {
6075 if ( components === void 0 ) components = {};
6076
6077 return !!components[tagName]
6078 },
6079 convertComponent: function convertComponent (ast, components, slotName) {
6080 var attrsMap = ast.attrsMap;
6081 var tag = ast.tag;
6082 var mpcomid = ast.mpcomid;
6083 var slots = ast.slots;
6084 if (slotName) {
6085 attrsMap['data'] = "{{...$root[$p], ...$root[$k], $root}}";
6086 // bindedName is available when rendering slot in v-for
6087 var bindedName = attrsMap['v-bind:name'];
6088 if (bindedName) {
6089 attrsMap['is'] = "{{$for[" + bindedName + "]}}";
6090 } else {
6091 attrsMap['is'] = "{{" + slotName + "}}";
6092 }
6093 } else {
6094 var slotsName = getSlotsName$3(slots);
6095 var restSlotsName = slotsName ? (", " + slotsName) : '';
6096 attrsMap['data'] = "{{...$root[$kk+" + mpcomid + "], $root" + restSlotsName + "}}";
6097 attrsMap['is'] = components[tag].name;
6098 }
6099 return ast
6100 }
6101};
6102
6103var astMap$3 = {
6104 'if': 'a:if',
6105 'iterator1': 'a:for-index',
6106 'key': 'a:key',
6107 'alias': 'a:for-item',
6108 'v-for': 'a:for'
6109};
6110
6111var convertFor$3 = function (ast) {
6112 var iterator1 = ast.iterator1;
6113 var forText = ast.for;
6114 var key = ast.key;
6115 var alias = ast.alias;
6116 var attrsMap = ast.attrsMap;
6117
6118 if (forText) {
6119 attrsMap[astMap$3['v-for']] = "{{" + forText + "}}";
6120 if (iterator1) {
6121 attrsMap[astMap$3['iterator1']] = iterator1;
6122 }
6123 if (key) {
6124 attrsMap[astMap$3['key']] = key;
6125 }
6126 if (alias) {
6127 attrsMap[astMap$3['alias']] = alias;
6128 }
6129
6130 delete attrsMap['v-for'];
6131 }
6132
6133 return ast
6134};
6135
6136function mpmlAst$3 (compiled, options, log) {
6137 if ( options === void 0 ) options = {};
6138
6139 var conventRule = { attrs: attrs$3, component: component$3, convertFor: convertFor$3 };
6140 return getAstCommon(compiled, options, log, conventRule)
6141}
6142
6143function compileToMPML$4 (compiled, options) {
6144 if ( options === void 0 ) options = {};
6145
6146 return compileToMPMLCommon(compiled, options, mpmlAst$3)
6147}
6148
6149function compileToMPML (compiled, options, fileExt) {
6150 var code;
6151 switch (fileExt.platform) {
6152 case 'swan':
6153 code = compileToMPML$2(compiled, options);
6154 break
6155 case 'wx':
6156 code = compileToMPML$1(compiled, options);
6157 break
6158 case 'tt':
6159 code = compileToMPML$3(compiled, options);
6160 break
6161 case 'my':
6162 code = compileToMPML$4(compiled, options);
6163 break
6164 default:
6165 code = compileToMPML$1(compiled, options);
6166 }
6167 return code
6168}
6169
6170var ref = createCompiler(baseOptions);
6171var compile = ref.compile;
6172var compileToFunctions = ref.compileToFunctions;
6173
6174/* */
6175
6176exports.parseComponent = parseComponent;
6177exports.compile = compile;
6178exports.compileToFunctions = compileToFunctions;
6179exports.compileToMPML = compileToMPML;