package.dist.compiler-dom.esm-browser.js Maven / Gradle / Ivy
The newest version!
/**
* @vue/compiler-dom v3.5.10
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function makeMap(str) {
const map = /* @__PURE__ */ Object.create(null);
for (const key of str.split(",")) map[key] = 1;
return (val) => val in map;
}
const EMPTY_OBJ = Object.freeze({}) ;
const NOOP = () => {
};
const NO = () => false;
const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
(key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
const extend = Object.assign;
const isArray = Array.isArray;
const isString = (val) => typeof val === "string";
const isSymbol = (val) => typeof val === "symbol";
const isObject = (val) => val !== null && typeof val === "object";
const isReservedProp = /* @__PURE__ */ makeMap(
// the leading comma is intentional so empty string "" is also included
",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
);
const isBuiltInDirective = /* @__PURE__ */ makeMap(
"bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
);
const cacheStringFunction = (fn) => {
const cache = /* @__PURE__ */ Object.create(null);
return (str) => {
const hit = cache[str];
return hit || (cache[str] = fn(str));
};
};
const camelizeRE = /-(\w)/g;
const camelize = cacheStringFunction(
(str) => {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
}
);
const capitalize = cacheStringFunction((str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
});
const toHandlerKey = cacheStringFunction(
(str) => {
const s = str ? `on${capitalize(str)}` : ``;
return s;
}
);
const PatchFlagNames = {
[1]: `TEXT`,
[2]: `CLASS`,
[4]: `STYLE`,
[8]: `PROPS`,
[16]: `FULL_PROPS`,
[32]: `NEED_HYDRATION`,
[64]: `STABLE_FRAGMENT`,
[128]: `KEYED_FRAGMENT`,
[256]: `UNKEYED_FRAGMENT`,
[512]: `NEED_PATCH`,
[1024]: `DYNAMIC_SLOTS`,
[2048]: `DEV_ROOT_FRAGMENT`,
[-1]: `HOISTED`,
[-2]: `BAIL`
};
const slotFlagsText = {
[1]: "STABLE",
[2]: "DYNAMIC",
[3]: "FORWARDED"
};
const range = 2;
function generateCodeFrame(source, start = 0, end = source.length) {
start = Math.max(0, Math.min(start, source.length));
end = Math.max(0, Math.min(end, source.length));
if (start > end) return "";
let lines = source.split(/(\r?\n)/);
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
lines = lines.filter((_, idx) => idx % 2 === 0);
let count = 0;
const res = [];
for (let i = 0; i < lines.length; i++) {
count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
if (count >= start) {
for (let j = i - range; j <= i + range || end > count; j++) {
if (j < 0 || j >= lines.length) continue;
const line = j + 1;
res.push(
`${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
);
const lineLength = lines[j].length;
const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
if (j === i) {
const pad = start - (count - (lineLength + newLineSeqLength));
const length = Math.max(
1,
end > count ? lineLength - pad : end - start
);
res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
} else if (j > i) {
if (end > count) {
const length = Math.max(Math.min(end - count, lineLength), 1);
res.push(` | ` + "^".repeat(length));
}
count += lineLength + newLineSeqLength;
}
}
break;
}
}
return res.join("\n");
}
const listDelimiterRE = /;(?![^(]*\))/g;
const propertyDelimiterRE = /:([^]+)/;
const styleCommentRE = /\/\*[^]*?\*\//g;
function parseStringStyle(cssText) {
const ret = {};
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
if (item) {
const tmp = item.split(propertyDelimiterRE);
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
}
});
return ret;
}
const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
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: 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: 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]),
// `= 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 (!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 and