/** * @vue/compiler-core v3.5.12 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var shared = require('@vue/shared'); var decode_js = require('entities/lib/decode.js'); var parser = require('@babel/parser'); var estreeWalker = require('estree-walker'); var sourceMapJs = require('source-map-js'); const FRAGMENT = Symbol(`Fragment` ); const TELEPORT = Symbol(`Teleport` ); const SUSPENSE = Symbol(`Suspense` ); const KEEP_ALIVE = Symbol(`KeepAlive` ); const BASE_TRANSITION = Symbol( `BaseTransition` ); const OPEN_BLOCK = Symbol(`openBlock` ); const CREATE_BLOCK = Symbol(`createBlock` ); const CREATE_ELEMENT_BLOCK = Symbol( `createElementBlock` ); const CREATE_VNODE = Symbol(`createVNode` ); const CREATE_ELEMENT_VNODE = Symbol( `createElementVNode` ); const CREATE_COMMENT = Symbol( `createCommentVNode` ); const CREATE_TEXT = Symbol( `createTextVNode` ); const CREATE_STATIC = Symbol( `createStaticVNode` ); const RESOLVE_COMPONENT = Symbol( `resolveComponent` ); const RESOLVE_DYNAMIC_COMPONENT = Symbol( `resolveDynamicComponent` ); const RESOLVE_DIRECTIVE = Symbol( `resolveDirective` ); const RESOLVE_FILTER = Symbol( `resolveFilter` ); const WITH_DIRECTIVES = Symbol( `withDirectives` ); const RENDER_LIST = Symbol(`renderList` ); const RENDER_SLOT = Symbol(`renderSlot` ); const CREATE_SLOTS = Symbol(`createSlots` ); const TO_DISPLAY_STRING = Symbol( `toDisplayString` ); const MERGE_PROPS = Symbol(`mergeProps` ); const NORMALIZE_CLASS = Symbol( `normalizeClass` ); const NORMALIZE_STYLE = Symbol( `normalizeStyle` ); const NORMALIZE_PROPS = Symbol( `normalizeProps` ); const GUARD_REACTIVE_PROPS = Symbol( `guardReactiveProps` ); const TO_HANDLERS = Symbol(`toHandlers` ); const CAMELIZE = Symbol(`camelize` ); const CAPITALIZE = Symbol(`capitalize` ); const TO_HANDLER_KEY = Symbol( `toHandlerKey` ); const SET_BLOCK_TRACKING = Symbol( `setBlockTracking` ); const PUSH_SCOPE_ID = Symbol(`pushScopeId` ); const POP_SCOPE_ID = Symbol(`popScopeId` ); const WITH_CTX = Symbol(`withCtx` ); const UNREF = Symbol(`unref` ); const IS_REF = Symbol(`isRef` ); const WITH_MEMO = Symbol(`withMemo` ); const IS_MEMO_SAME = Symbol(`isMemoSame` ); const helperNameMap = { [FRAGMENT]: `Fragment`, [TELEPORT]: `Teleport`, [SUSPENSE]: `Suspense`, [KEEP_ALIVE]: `KeepAlive`, [BASE_TRANSITION]: `BaseTransition`, [OPEN_BLOCK]: `openBlock`, [CREATE_BLOCK]: `createBlock`, [CREATE_ELEMENT_BLOCK]: `createElementBlock`, [CREATE_VNODE]: `createVNode`, [CREATE_ELEMENT_VNODE]: `createElementVNode`, [CREATE_COMMENT]: `createCommentVNode`, [CREATE_TEXT]: `createTextVNode`, [CREATE_STATIC]: `createStaticVNode`, [RESOLVE_COMPONENT]: `resolveComponent`, [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`, [RESOLVE_DIRECTIVE]: `resolveDirective`, [RESOLVE_FILTER]: `resolveFilter`, [WITH_DIRECTIVES]: `withDirectives`, [RENDER_LIST]: `renderList`, [RENDER_SLOT]: `renderSlot`, [CREATE_SLOTS]: `createSlots`, [TO_DISPLAY_STRING]: `toDisplayString`, [MERGE_PROPS]: `mergeProps`, [NORMALIZE_CLASS]: `normalizeClass`, [NORMALIZE_STYLE]: `normalizeStyle`, [NORMALIZE_PROPS]: `normalizeProps`, [GUARD_REACTIVE_PROPS]: `guardReactiveProps`, [TO_HANDLERS]: `toHandlers`, [CAMELIZE]: `camelize`, [CAPITALIZE]: `capitalize`, [TO_HANDLER_KEY]: `toHandlerKey`, [SET_BLOCK_TRACKING]: `setBlockTracking`, [PUSH_SCOPE_ID]: `pushScopeId`, [POP_SCOPE_ID]: `popScopeId`, [WITH_CTX]: `withCtx`, [UNREF]: `unref`, [IS_REF]: `isRef`, [WITH_MEMO]: `withMemo`, [IS_MEMO_SAME]: `isMemoSame` }; function registerRuntimeHelpers(helpers) { Object.getOwnPropertySymbols(helpers).forEach((s) => { helperNameMap[s] = helpers[s]; }); } const Namespaces = { "HTML": 0, "0": "HTML", "SVG": 1, "1": "SVG", "MATH_ML": 2, "2": "MATH_ML" }; const NodeTypes = { "ROOT": 0, "0": "ROOT", "ELEMENT": 1, "1": "ELEMENT", "TEXT": 2, "2": "TEXT", "COMMENT": 3, "3": "COMMENT", "SIMPLE_EXPRESSION": 4, "4": "SIMPLE_EXPRESSION", "INTERPOLATION": 5, "5": "INTERPOLATION", "ATTRIBUTE": 6, "6": "ATTRIBUTE", "DIRECTIVE": 7, "7": "DIRECTIVE", "COMPOUND_EXPRESSION": 8, "8": "COMPOUND_EXPRESSION", "IF": 9, "9": "IF", "IF_BRANCH": 10, "10": "IF_BRANCH", "FOR": 11, "11": "FOR", "TEXT_CALL": 12, "12": "TEXT_CALL", "VNODE_CALL": 13, "13": "VNODE_CALL", "JS_CALL_EXPRESSION": 14, "14": "JS_CALL_EXPRESSION", "JS_OBJECT_EXPRESSION": 15, "15": "JS_OBJECT_EXPRESSION", "JS_PROPERTY": 16, "16": "JS_PROPERTY", "JS_ARRAY_EXPRESSION": 17, "17": "JS_ARRAY_EXPRESSION", "JS_FUNCTION_EXPRESSION": 18, "18": "JS_FUNCTION_EXPRESSION", "JS_CONDITIONAL_EXPRESSION": 19, "19": "JS_CONDITIONAL_EXPRESSION", "JS_CACHE_EXPRESSION": 20, "20": "JS_CACHE_EXPRESSION", "JS_BLOCK_STATEMENT": 21, "21": "JS_BLOCK_STATEMENT", "JS_TEMPLATE_LITERAL": 22, "22": "JS_TEMPLATE_LITERAL", "JS_IF_STATEMENT": 23, "23": "JS_IF_STATEMENT", "JS_ASSIGNMENT_EXPRESSION": 24, "24": "JS_ASSIGNMENT_EXPRESSION", "JS_SEQUENCE_EXPRESSION": 25, "25": "JS_SEQUENCE_EXPRESSION", "JS_RETURN_STATEMENT": 26, "26": "JS_RETURN_STATEMENT" }; const ElementTypes = { "ELEMENT": 0, "0": "ELEMENT", "COMPONENT": 1, "1": "COMPONENT", "SLOT": 2, "2": "SLOT", "TEMPLATE": 3, "3": "TEMPLATE" }; const ConstantTypes = { "NOT_CONSTANT": 0, "0": "NOT_CONSTANT", "CAN_SKIP_PATCH": 1, "1": "CAN_SKIP_PATCH", "CAN_CACHE": 2, "2": "CAN_CACHE", "CAN_STRINGIFY": 3, "3": "CAN_STRINGIFY" }; const locStub = { start: { line: 1, column: 1, offset: 0 }, end: { line: 1, column: 1, offset: 0 }, source: "" }; function createRoot(children, source = "") { return { type: 0, source, children, helpers: /* @__PURE__ */ new Set(), components: [], directives: [], hoists: [], imports: [], cached: [], temps: 0, codegenNode: void 0, loc: locStub }; } function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) { if (context) { if (isBlock) { context.helper(OPEN_BLOCK); context.helper(getVNodeBlockHelper(context.inSSR, isComponent)); } else { context.helper(getVNodeHelper(context.inSSR, isComponent)); } if (directives) { context.helper(WITH_DIRECTIVES); } } return { type: 13, tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent, loc }; } function createArrayExpression(elements, loc = locStub) { return { type: 17, loc, elements }; } function createObjectExpression(properties, loc = locStub) { return { type: 15, loc, properties }; } function createObjectProperty(key, value) { return { type: 16, loc: locStub, key: shared.isString(key) ? createSimpleExpression(key, true) : key, value }; } function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) { return { type: 4, loc, content, isStatic, constType: isStatic ? 3 : constType }; } function createInterpolation(content, loc) { return { type: 5, loc, content: shared.isString(content) ? createSimpleExpression(content, false, loc) : content }; } function createCompoundExpression(children, loc = locStub) { return { type: 8, loc, children }; } function createCallExpression(callee, args = [], loc = locStub) { return { type: 14, loc, callee, arguments: args }; } function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) { return { type: 18, params, returns, newline, isSlot, loc }; } function createConditionalExpression(test, consequent, alternate, newline = true) { return { type: 19, test, consequent, alternate, newline, loc: locStub }; } function createCacheExpression(index, value, needPauseTracking = false) { return { type: 20, index, value, needPauseTracking, needArraySpread: false, loc: locStub }; } function createBlockStatement(body) { return { type: 21, body, loc: locStub }; } function createTemplateLiteral(elements) { return { type: 22, elements, loc: locStub }; } function createIfStatement(test, consequent, alternate) { return { type: 23, test, consequent, alternate, loc: locStub }; } function createAssignmentExpression(left, right) { return { type: 24, left, right, loc: locStub }; } function createSequenceExpression(expressions) { return { type: 25, expressions, loc: locStub }; } function createReturnStatement(returns) { return { type: 26, returns, loc: locStub }; } function getVNodeHelper(ssr, isComponent) { return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE; } function getVNodeBlockHelper(ssr, isComponent) { return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK; } function convertToBlock(node, { helper, removeHelper, inSSR }) { if (!node.isBlock) { node.isBlock = true; removeHelper(getVNodeHelper(inSSR, node.isComponent)); helper(OPEN_BLOCK); helper(getVNodeBlockHelper(inSSR, node.isComponent)); } } const defaultDelimitersOpen = new Uint8Array([123, 123]); const defaultDelimitersClose = new Uint8Array([125, 125]); function isTagStartChar(c) { return c >= 97 && c <= 122 || c >= 65 && c <= 90; } function isWhitespace(c) { return c === 32 || c === 10 || c === 9 || c === 12 || c === 13; } function isEndOfTagSection(c) { return c === 47 || c === 62 || isWhitespace(c); } function toCharCodes(str) { const ret = new Uint8Array(str.length); for (let i = 0; i < str.length; i++) { ret[i] = str.charCodeAt(i); } return ret; } const Sequences = { Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]), // CDATA[ CdataEnd: new Uint8Array([93, 93, 62]), // ]]> CommentEnd: new Uint8Array([45, 45, 62]), // `-->` ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]), // `<\/script` StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]), // ` this.emitCodePoint(cp, consumed) ); } } get inSFCRoot() { return this.mode === 2 && this.stack.length === 0; } reset() { this.state = 1; this.mode = 0; this.buffer = ""; this.sectionStart = 0; this.index = 0; this.baseState = 1; this.inRCDATA = false; this.currentSequence = void 0; this.newlines.length = 0; this.delimiterOpen = defaultDelimitersOpen; this.delimiterClose = defaultDelimitersClose; } /** * Generate Position object with line / column information using recorded * newline positions. We know the index is always going to be an already * processed index, so all the newlines up to this index should have been * recorded. */ getPos(index) { let line = 1; let column = index + 1; for (let i = this.newlines.length - 1; i >= 0; i--) { const newlineIndex = this.newlines[i]; if (index > newlineIndex) { line = i + 2; column = index - newlineIndex; break; } } return { column, line, offset: index }; } peek() { return this.buffer.charCodeAt(this.index + 1); } stateText(c) { if (c === 60) { if (this.index > this.sectionStart) { this.cbs.ontext(this.sectionStart, this.index); } this.state = 5; this.sectionStart = this.index; } else if (c === 38) { this.startEntity(); } else if (!this.inVPre && c === this.delimiterOpen[0]) { this.state = 2; this.delimiterIndex = 0; this.stateInterpolationOpen(c); } } stateInterpolationOpen(c) { if (c === this.delimiterOpen[this.delimiterIndex]) { if (this.delimiterIndex === this.delimiterOpen.length - 1) { const start = this.index + 1 - this.delimiterOpen.length; if (start > this.sectionStart) { this.cbs.ontext(this.sectionStart, start); } this.state = 3; this.sectionStart = start; } else { this.delimiterIndex++; } } else if (this.inRCDATA) { this.state = 32; this.stateInRCDATA(c); } else { this.state = 1; this.stateText(c); } } stateInterpolation(c) { if (c === this.delimiterClose[0]) { this.state = 4; this.delimiterIndex = 0; this.stateInterpolationClose(c); } } stateInterpolationClose(c) { if (c === this.delimiterClose[this.delimiterIndex]) { if (this.delimiterIndex === this.delimiterClose.length - 1) { this.cbs.oninterpolation(this.sectionStart, this.index + 1); if (this.inRCDATA) { this.state = 32; } else { this.state = 1; } this.sectionStart = this.index + 1; } else { this.delimiterIndex++; } } else { this.state = 3; this.stateInterpolation(c); } } stateSpecialStartSequence(c) { const isEnd = this.sequenceIndex === this.currentSequence.length; const isMatch = isEnd ? ( // If we are at the end of the sequence, make sure the tag name has ended isEndOfTagSection(c) ) : ( // Otherwise, do a case-insensitive comparison (c | 32) === this.currentSequence[this.sequenceIndex] ); if (!isMatch) { this.inRCDATA = false; } else if (!isEnd) { this.sequenceIndex++; return; } this.sequenceIndex = 0; this.state = 6; this.stateInTagName(c); } /** Look for an end tag. For