'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var CompilerDOM = require('@vue/compiler-dom'); var sourceMapJs = require('source-map-js'); var path$3 = require('path'); var parser$2 = require('@babel/parser'); var shared = require('@vue/shared'); var compilerCore = require('@vue/compiler-core'); var url = require('url'); var CompilerSSR = require('@vue/compiler-ssr'); var require$$2 = require('util'); var require$$0 = require('fs'); var require$$0$1 = require('postcss'); var estreeWalker = require('estree-walker'); var reactivityTransform = require('@vue/reactivity-transform'); var MagicString = require('magic-string'); function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { for (var k in e) { n[k] = e[k]; } } n.default = e; return Object.freeze(n); } var CompilerDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(CompilerDOM); var CompilerSSR__namespace = /*#__PURE__*/_interopNamespaceDefault(CompilerSSR); const UNKNOWN_TYPE = "Unknown"; function resolveObjectKey(node, computed) { switch (node.type) { case "StringLiteral": case "NumericLiteral": return String(node.value); case "Identifier": if (!computed) return node.name; } return void 0; } function concatStrings(strs) { return strs.filter((s) => !!s).join(", "); } function isLiteralNode(node) { return node.type.endsWith("Literal"); } function unwrapTSNode(node) { if (CompilerDOM.TS_NODE_TYPES.includes(node.type)) { return unwrapTSNode(node.expression); } else { return node; } } function isCallOf(node, test) { return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name))); } function toRuntimeTypeString(types) { return types.length > 1 ? `[${types.join(", ")}]` : types[0]; } function getImportedName(specifier) { if (specifier.type === "ImportSpecifier") return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value; else if (specifier.type === "ImportNamespaceSpecifier") return "*"; return "default"; } function getId(node) { return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null; } const identity = (str) => str; const fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g; const toLowerCase = (str) => str.toLowerCase(); function toFileNameLowerCase(x) { return fileNameLowerCaseRegExp.test(x) ? x.replace(fileNameLowerCaseRegExp, toLowerCase) : x; } function createGetCanonicalFileName(useCaseSensitiveFileNames) { return useCaseSensitiveFileNames ? identity : toFileNameLowerCase; } const normalize = (path$3.posix || path$3).normalize; const windowsSlashRE = /\\/g; function normalizePath(p) { return normalize(p.replace(windowsSlashRE, "/")); } const joinPaths = (path$3.posix || path$3).join; const escapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g; function getEscapedKey(key) { return escapeSymbolsRE.test(key) ? JSON.stringify(key) : key; } var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function pad (hash, len) { while (hash.length < len) { hash = '0' + hash; } return hash; } function fold (hash, text) { var i; var chr; var len; if (text.length === 0) { return hash; } for (i = 0, len = text.length; i < len; i++) { chr = text.charCodeAt(i); hash = ((hash << 5) - hash) + chr; hash |= 0; } return hash < 0 ? hash * -2 : hash; } function foldObject (hash, o, seen) { return Object.keys(o).sort().reduce(foldKey, hash); function foldKey (hash, key) { return foldValue(hash, o[key], key, seen); } } function foldValue (input, value, key, seen) { var hash = fold(fold(fold(input, key), toString$1(value)), typeof value); if (value === null) { return fold(hash, 'null'); } if (value === undefined) { return fold(hash, 'undefined'); } if (typeof value === 'object' || typeof value === 'function') { if (seen.indexOf(value) !== -1) { return fold(hash, '[Circular]' + key); } seen.push(value); var objHash = foldObject(hash, value, seen); if (!('valueOf' in value) || typeof value.valueOf !== 'function') { return objHash; } try { return fold(objHash, String(value.valueOf())) } catch (err) { return fold(objHash, '[valueOf exception]' + (err.stack || err.message)) } } return fold(hash, value.toString()); } function toString$1 (o) { return Object.prototype.toString.call(o); } function sum (o) { return pad(foldValue(0, o, '', []).toString(16), 8); } var hashSum = sum; var hash$1 = hashSum; const CSS_VARS_HELPER = `useCssVars`; function genCssVarsFromList(vars, id, isProd, isSSR = false) { return `{ ${vars.map( (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})` ).join(",\n ")} }`; } function genVarName(id, raw, isProd) { if (isProd) { return hash$1(id + raw); } else { return `${id}-${raw.replace(escapeSymbolsRE, (s) => `\\${s}`)}`; } } function normalizeExpression(exp) { exp = exp.trim(); if (exp[0] === `'` && exp[exp.length - 1] === `'` || exp[0] === `"` && exp[exp.length - 1] === `"`) { return exp.slice(1, -1); } return exp; } const vBindRE = /v-bind\s*\(/g; function parseCssVars(sfc) { const vars = []; sfc.styles.forEach((style) => { let match; const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, ""); while (match = vBindRE.exec(content)) { const start = match.index + match[0].length; const end = lexBinding(content, start); if (end !== null) { const variable = normalizeExpression(content.slice(start, end)); if (!vars.includes(variable)) { vars.push(variable); } } } }); return vars; } function lexBinding(content, start) { let state = 0 /* inParens */; let parenDepth = 0; for (let i = start; i < content.length; i++) { const char = content.charAt(i); switch (state) { case 0 /* inParens */: if (char === `'`) { state = 1 /* inSingleQuoteString */; } else if (char === `"`) { state = 2 /* inDoubleQuoteString */; } else if (char === `(`) { parenDepth++; } else if (char === `)`) { if (parenDepth > 0) { parenDepth--; } else { return i; } } break; case 1 /* inSingleQuoteString */: if (char === `'`) { state = 0 /* inParens */; } break; case 2 /* inDoubleQuoteString */: if (char === `"`) { state = 0 /* inParens */; } break; } } return null; } const cssVarsPlugin = (opts) => { const { id, isProd } = opts; return { postcssPlugin: "vue-sfc-vars", Declaration(decl) { const value = decl.value; if (vBindRE.test(value)) { vBindRE.lastIndex = 0; let transformed = ""; let lastIndex = 0; let match; while (match = vBindRE.exec(value)) { const start = match.index + match[0].length; const end = lexBinding(value, start); if (end !== null) { const variable = normalizeExpression(value.slice(start, end)); transformed += value.slice(lastIndex, match.index) + `var(--${genVarName(id, variable, isProd)})`; lastIndex = end + 1; } } decl.value = transformed + value.slice(lastIndex); } } }; }; cssVarsPlugin.postcss = true; function genCssVarsCode(vars, bindings, id, isProd) { const varsExp = genCssVarsFromList(vars, id, isProd); const exp = CompilerDOM.createSimpleExpression(varsExp, false); const context = CompilerDOM.createTransformContext(CompilerDOM.createRoot([]), { prefixIdentifiers: true, inline: true, bindingMetadata: bindings.__isScriptSetup === false ? void 0 : bindings }); const transformed = CompilerDOM.processExpression(exp, context); const transformedString = transformed.type === 4 ? transformed.content : transformed.children.map((c) => { return typeof c === "string" ? c : c.content; }).join(""); return `_${CSS_VARS_HELPER}(_ctx => (${transformedString}))`; } function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) { return ` import { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue' const __injectCSSVars__ = () => { ${genCssVarsCode( cssVars, bindings, id, isProd )}} const __setup__ = ${defaultVar}.setup ${defaultVar}.setup = __setup__ ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) } : __injectCSSVars__ `; } var iterator; var hasRequiredIterator; function requireIterator () { if (hasRequiredIterator) return iterator; hasRequiredIterator = 1; iterator = function (Yallist) { Yallist.prototype[Symbol.iterator] = function* () { for (let walker = this.head; walker; walker = walker.next) { yield walker.value; } }; }; return iterator; } var yallist = Yallist$1; Yallist$1.Node = Node; Yallist$1.create = Yallist$1; function Yallist$1 (list) { var self = this; if (!(self instanceof Yallist$1)) { self = new Yallist$1(); } self.tail = null; self.head = null; self.length = 0; if (list && typeof list.forEach === 'function') { list.forEach(function (item) { self.push(item); }); } else if (arguments.length > 0) { for (var i = 0, l = arguments.length; i < l; i++) { self.push(arguments[i]); } } return self } Yallist$1.prototype.removeNode = function (node) { if (node.list !== this) { throw new Error('removing node which does not belong to this list') } var next = node.next; var prev = node.prev; if (next) { next.prev = prev; } if (prev) { prev.next = next; } if (node === this.head) { this.head = next; } if (node === this.tail) { this.tail = prev; } node.list.length--; node.next = null; node.prev = null; node.list = null; return next }; Yallist$1.prototype.unshiftNode = function (node) { if (node === this.head) { return } if (node.list) { node.list.removeNode(node); } var head = this.head; node.list = this; node.next = head; if (head) { head.prev = node; } this.head = node; if (!this.tail) { this.tail = node; } this.length++; }; Yallist$1.prototype.pushNode = function (node) { if (node === this.tail) { return } if (node.list) { node.list.removeNode(node); } var tail = this.tail; node.list = this; node.prev = tail; if (tail) { tail.next = node; } this.tail = node; if (!this.head) { this.head = node; } this.length++; }; Yallist$1.prototype.push = function () { for (var i = 0, l = arguments.length; i < l; i++) { push(this, arguments[i]); } return this.length }; Yallist$1.prototype.unshift = function () { for (var i = 0, l = arguments.length; i < l; i++) { unshift(this, arguments[i]); } return this.length }; Yallist$1.prototype.pop = function () { if (!this.tail) { return undefined } var res = this.tail.value; this.tail = this.tail.prev; if (this.tail) { this.tail.next = null; } else { this.head = null; } this.length--; return res }; Yallist$1.prototype.shift = function () { if (!this.head) { return undefined } var res = this.head.value; this.head = this.head.next; if (this.head) { this.head.prev = null; } else { this.tail = null; } this.length--; return res }; Yallist$1.prototype.forEach = function (fn, thisp) { thisp = thisp || this; for (var walker = this.head, i = 0; walker !== null; i++) { fn.call(thisp, walker.value, i, this); walker = walker.next; } }; Yallist$1.prototype.forEachReverse = function (fn, thisp) { thisp = thisp || this; for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { fn.call(thisp, walker.value, i, this); walker = walker.prev; } }; Yallist$1.prototype.get = function (n) { for (var i = 0, walker = this.head; walker !== null && i < n; i++) { // abort out of the list early if we hit a cycle walker = walker.next; } if (i === n && walker !== null) { return walker.value } }; Yallist$1.prototype.getReverse = function (n) { for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { // abort out of the list early if we hit a cycle walker = walker.prev; } if (i === n && walker !== null) { return walker.value } }; Yallist$1.prototype.map = function (fn, thisp) { thisp = thisp || this; var res = new Yallist$1(); for (var walker = this.head; walker !== null;) { res.push(fn.call(thisp, walker.value, this)); walker = walker.next; } return res }; Yallist$1.prototype.mapReverse = function (fn, thisp) { thisp = thisp || this; var res = new Yallist$1(); for (var walker = this.tail; walker !== null;) { res.push(fn.call(thisp, walker.value, this)); walker = walker.prev; } return res }; Yallist$1.prototype.reduce = function (fn, initial) { var acc; var walker = this.head; if (arguments.length > 1) { acc = initial; } else if (this.head) { walker = this.head.next; acc = this.head.value; } else { throw new TypeError('Reduce of empty list with no initial value') } for (var i = 0; walker !== null; i++) { acc = fn(acc, walker.value, i); walker = walker.next; } return acc }; Yallist$1.prototype.reduceReverse = function (fn, initial) { var acc; var walker = this.tail; if (arguments.length > 1) { acc = initial; } else if (this.tail) { walker = this.tail.prev; acc = this.tail.value; } else { throw new TypeError('Reduce of empty list with no initial value') } for (var i = this.length - 1; walker !== null; i--) { acc = fn(acc, walker.value, i); walker = walker.prev; } return acc }; Yallist$1.prototype.toArray = function () { var arr = new Array(this.length); for (var i = 0, walker = this.head; walker !== null; i++) { arr[i] = walker.value; walker = walker.next; } return arr }; Yallist$1.prototype.toArrayReverse = function () { var arr = new Array(this.length); for (var i = 0, walker = this.tail; walker !== null; i++) { arr[i] = walker.value; walker = walker.prev; } return arr }; Yallist$1.prototype.slice = function (from, to) { to = to || this.length; if (to < 0) { to += this.length; } from = from || 0; if (from < 0) { from += this.length; } var ret = new Yallist$1(); if (to < from || to < 0) { return ret } if (from < 0) { from = 0; } if (to > this.length) { to = this.length; } for (var i = 0, walker = this.head; walker !== null && i < from; i++) { walker = walker.next; } for (; walker !== null && i < to; i++, walker = walker.next) { ret.push(walker.value); } return ret }; Yallist$1.prototype.sliceReverse = function (from, to) { to = to || this.length; if (to < 0) { to += this.length; } from = from || 0; if (from < 0) { from += this.length; } var ret = new Yallist$1(); if (to < from || to < 0) { return ret } if (from < 0) { from = 0; } if (to > this.length) { to = this.length; } for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { walker = walker.prev; } for (; walker !== null && i > from; i--, walker = walker.prev) { ret.push(walker.value); } return ret }; Yallist$1.prototype.splice = function (start, deleteCount /*, ...nodes */) { if (start > this.length) { start = this.length - 1; } if (start < 0) { start = this.length + start; } for (var i = 0, walker = this.head; walker !== null && i < start; i++) { walker = walker.next; } var ret = []; for (var i = 0; walker && i < deleteCount; i++) { ret.push(walker.value); walker = this.removeNode(walker); } if (walker === null) { walker = this.tail; } if (walker !== this.head && walker !== this.tail) { walker = walker.prev; } for (var i = 2; i < arguments.length; i++) { walker = insert(this, walker, arguments[i]); } return ret; }; Yallist$1.prototype.reverse = function () { var head = this.head; var tail = this.tail; for (var walker = head; walker !== null; walker = walker.prev) { var p = walker.prev; walker.prev = walker.next; walker.next = p; } this.head = tail; this.tail = head; return this }; function insert (self, node, value) { var inserted = node === self.head ? new Node(value, null, node, self) : new Node(value, node, node.next, self); if (inserted.next === null) { self.tail = inserted; } if (inserted.prev === null) { self.head = inserted; } self.length++; return inserted } function push (self, item) { self.tail = new Node(item, self.tail, null, self); if (!self.head) { self.head = self.tail; } self.length++; } function unshift (self, item) { self.head = new Node(item, null, self.head, self); if (!self.tail) { self.tail = self.head; } self.length++; } function Node (value, prev, next, list) { if (!(this instanceof Node)) { return new Node(value, prev, next, list) } this.list = list; this.value = value; if (prev) { prev.next = this; this.prev = prev; } else { this.prev = null; } if (next) { next.prev = this; this.next = next; } else { this.next = null; } } try { // add if support for Symbol.iterator is present requireIterator()(Yallist$1); } catch (er) {} // A linked list to keep track of recently-used-ness const Yallist = yallist; const MAX = Symbol('max'); const LENGTH = Symbol('length'); const LENGTH_CALCULATOR = Symbol('lengthCalculator'); const ALLOW_STALE = Symbol('allowStale'); const MAX_AGE = Symbol('maxAge'); const DISPOSE = Symbol('dispose'); const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet'); const LRU_LIST = Symbol('lruList'); const CACHE = Symbol('cache'); const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet'); const naiveLength = () => 1; // lruList is a yallist where the head is the youngest // item, and the tail is the oldest. the list contains the Hit // objects as the entries. // Each Hit object has a reference to its Yallist.Node. This // never changes. // // cache is a Map (or PseudoMap) that matches the keys to // the Yallist.Node object. class LRUCache { constructor (options) { if (typeof options === 'number') options = { max: options }; if (!options) options = {}; if (options.max && (typeof options.max !== 'number' || options.max < 0)) throw new TypeError('max must be a non-negative number') // Kind of weird to have a default max of Infinity, but oh well. this[MAX] = options.max || Infinity; const lc = options.length || naiveLength; this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc; this[ALLOW_STALE] = options.stale || false; if (options.maxAge && typeof options.maxAge !== 'number') throw new TypeError('maxAge must be a number') this[MAX_AGE] = options.maxAge || 0; this[DISPOSE] = options.dispose; this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false; this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false; this.reset(); } // resize the cache when the max changes. set max (mL) { if (typeof mL !== 'number' || mL < 0) throw new TypeError('max must be a non-negative number') this[MAX] = mL || Infinity; trim(this); } get max () { return this[MAX] } set allowStale (allowStale) { this[ALLOW_STALE] = !!allowStale; } get allowStale () { return this[ALLOW_STALE] } set maxAge (mA) { if (typeof mA !== 'number') throw new TypeError('maxAge must be a non-negative number') this[MAX_AGE] = mA; trim(this); } get maxAge () { return this[MAX_AGE] } // resize the cache when the lengthCalculator changes. set lengthCalculator (lC) { if (typeof lC !== 'function') lC = naiveLength; if (lC !== this[LENGTH_CALCULATOR]) { this[LENGTH_CALCULATOR] = lC; this[LENGTH] = 0; this[LRU_LIST].forEach(hit => { hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key); this[LENGTH] += hit.length; }); } trim(this); } get lengthCalculator () { return this[LENGTH_CALCULATOR] } get length () { return this[LENGTH] } get itemCount () { return this[LRU_LIST].length } rforEach (fn, thisp) { thisp = thisp || this; for (let walker = this[LRU_LIST].tail; walker !== null;) { const prev = walker.prev; forEachStep(this, fn, walker, thisp); walker = prev; } } forEach (fn, thisp) { thisp = thisp || this; for (let walker = this[LRU_LIST].head; walker !== null;) { const next = walker.next; forEachStep(this, fn, walker, thisp); walker = next; } } keys () { return this[LRU_LIST].toArray().map(k => k.key) } values () { return this[LRU_LIST].toArray().map(k => k.value) } reset () { if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) { this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)); } this[CACHE] = new Map(); // hash of items by key this[LRU_LIST] = new Yallist(); // list of items in order of use recency this[LENGTH] = 0; // length of items in the list } dump () { return this[LRU_LIST].map(hit => isStale(this, hit) ? false : { k: hit.key, v: hit.value, e: hit.now + (hit.maxAge || 0) }).toArray().filter(h => h) } dumpLru () { return this[LRU_LIST] } set (key, value, maxAge) { maxAge = maxAge || this[MAX_AGE]; if (maxAge && typeof maxAge !== 'number') throw new TypeError('maxAge must be a number') const now = maxAge ? Date.now() : 0; const len = this[LENGTH_CALCULATOR](value, key); if (this[CACHE].has(key)) { if (len > this[MAX]) { del(this, this[CACHE].get(key)); return false } const node = this[CACHE].get(key); const item = node.value; // dispose of the old one before overwriting // split out into 2 ifs for better coverage tracking if (this[DISPOSE]) { if (!this[NO_DISPOSE_ON_SET]) this[DISPOSE](key, item.value); } item.now = now; item.maxAge = maxAge; item.value = value; this[LENGTH] += len - item.length; item.length = len; this.get(key); trim(this); return true } const hit = new Entry(key, value, len, now, maxAge); // oversized objects fall out of cache automatically. if (hit.length > this[MAX]) { if (this[DISPOSE]) this[DISPOSE](key, value); return false } this[LENGTH] += hit.length; this[LRU_LIST].unshift(hit); this[CACHE].set(key, this[LRU_LIST].head); trim(this); return true } has (key) { if (!this[CACHE].has(key)) return false const hit = this[CACHE].get(key).value; return !isStale(this, hit) } get (key) { return get(this, key, true) } peek (key) { return get(this, key, false) } pop () { const node = this[LRU_LIST].tail; if (!node) return null del(this, node); return node.value } del (key) { del(this, this[CACHE].get(key)); } load (arr) { // reset the cache this.reset(); const now = Date.now(); // A previous serialized cache has the most recent items first for (let l = arr.length - 1; l >= 0; l--) { const hit = arr[l]; const expiresAt = hit.e || 0; if (expiresAt === 0) // the item was created without expiration in a non aged cache this.set(hit.k, hit.v); else { const maxAge = expiresAt - now; // dont add already expired items if (maxAge > 0) { this.set(hit.k, hit.v, maxAge); } } } } prune () { this[CACHE].forEach((value, key) => get(this, key, false)); } } const get = (self, key, doUse) => { const node = self[CACHE].get(key); if (node) { const hit = node.value; if (isStale(self, hit)) { del(self, node); if (!self[ALLOW_STALE]) return undefined } else { if (doUse) { if (self[UPDATE_AGE_ON_GET]) node.value.now = Date.now(); self[LRU_LIST].unshiftNode(node); } } return hit.value } }; const isStale = (self, hit) => { if (!hit || (!hit.maxAge && !self[MAX_AGE])) return false const diff = Date.now() - hit.now; return hit.maxAge ? diff > hit.maxAge : self[MAX_AGE] && (diff > self[MAX_AGE]) }; const trim = self => { if (self[LENGTH] > self[MAX]) { for (let walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) { // We know that we're about to delete this one, and also // what the next least recently used key will be, so just // go ahead and set it now. const prev = walker.prev; del(self, walker); walker = prev; } } }; const del = (self, node) => { if (node) { const hit = node.value; if (self[DISPOSE]) self[DISPOSE](hit.key, hit.value); self[LENGTH] -= hit.length; self[CACHE].delete(hit.key); self[LRU_LIST].removeNode(node); } }; class Entry { constructor (key, value, length, now, maxAge) { this.key = key; this.value = value; this.length = length; this.now = now; this.maxAge = maxAge || 0; } } const forEachStep = (self, fn, node, thisp) => { let hit = node.value; if (isStale(self, hit)) { del(self, node); if (!self[ALLOW_STALE]) hit = undefined; } if (hit) fn.call(thisp, hit.value, hit.key, self); }; var lruCache = LRUCache; var LRU = lruCache; function createCache(size = 500) { const cache = new LRU(size); cache.delete = cache.del.bind(cache); return cache; } function isImportUsed(local, sfc) { return new RegExp( // #4274 escape $ since it's a special char in regex // (and is the only regex special char that is valid in identifiers) `[^\\w$_]${local.replace(/\$/g, "\\$")}[^\\w$_]` ).test(resolveTemplateUsageCheckString(sfc)); } const templateUsageCheckCache = createCache(); function resolveTemplateUsageCheckString(sfc) { const { content, ast } = sfc.template; const cached = templateUsageCheckCache.get(content); if (cached) { return cached; } let code = ""; CompilerDOM.transform(CompilerDOM.createRoot([ast]), { nodeTransforms: [ (node) => { if (node.type === 1) { if (!CompilerDOM.parserOptions.isNativeTag(node.tag) && !CompilerDOM.parserOptions.isBuiltInComponent(node.tag)) { code += `,${shared.camelize(node.tag)},${shared.capitalize(shared.camelize(node.tag))}`; } for (let i = 0; i < node.props.length; i++) { const prop = node.props[i]; if (prop.type === 7) { if (!shared.isBuiltInDirective(prop.name)) { code += `,v${shared.capitalize(shared.camelize(prop.name))}`; } if (prop.exp) { code += `,${processExp( prop.exp.content, prop.name )}`; } } } } else if (node.type === 5) { code += `,${processExp( node.content.content )}`; } } ] }); code += ";"; templateUsageCheckCache.set(content, code); return code; } const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/; function processExp(exp, dir) { if (/ as\s+\w|<.*>|:/.test(exp)) { if (dir === "slot") { exp = `(${exp})=>{}`; } else if (dir === "on") { exp = `()=>{return ${exp}}`; } else if (dir === "for") { const inMatch = exp.match(forAliasRE); if (inMatch) { let [, LHS, RHS] = inMatch; LHS = LHS.trim().replace(/^\(|\)$/g, ""); return processExp(`(${LHS})=>{}`) + processExp(RHS); } } let ret = ""; const ast = parser$2.parseExpression(exp, { plugins: ["typescript"] }); CompilerDOM.walkIdentifiers(ast, (node) => { ret += `,` + node.name; }); return ret; } return stripStrings(exp); } function stripStrings(exp) { return exp.replace(/'[^']*'|"[^"]*"/g, "").replace(/`[^`]+`/g, stripTemplateString); } function stripTemplateString(str) { const interpMatch = str.match(/\${[^}]+}/g); if (interpMatch) { return interpMatch.map((m) => m.slice(2, -1)).join(","); } return ""; } const DEFAULT_FILENAME = "anonymous.vue"; const parseCache = createCache(); function parse$2(source, { sourceMap = true, filename = DEFAULT_FILENAME, sourceRoot = "", pad = false, ignoreEmpty = true, compiler = CompilerDOM__namespace } = {}) { const sourceKey = source + sourceMap + filename + sourceRoot + pad + compiler.parse; const cache = parseCache.get(sourceKey); if (cache) { return cache; } const descriptor = { filename, source, template: null, script: null, scriptSetup: null, styles: [], customBlocks: [], cssVars: [], slotted: false, shouldForceReload: (prevImports) => hmrShouldReload(prevImports, descriptor) }; const errors = []; const ast = compiler.parse(source, { // there are no components at SFC parsing level isNativeTag: () => true, // preserve all whitespaces isPreTag: () => true, getTextMode: ({ tag, props }, parent) => { if (!parent && tag !== "template" || //