@kdujs/compiler-dom
Version:
@kdujs/compiler-dom
1,591 lines (1,578 loc) • 186 kB
JavaScript
/**
* @kdujs/compiler-dom v3.4.27
* (c) 2021-present NKDuy
* @license MIT
**/
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function makeMap(str, expectsLowerCase) {
const set = new Set(str.split(","));
return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
}
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,onKnodeBeforeMount,onKnodeMounted,onKnodeBeforeUpdate,onKnodeUpdated,onKnodeBeforeUnmount,onKnodeUnmounted"
);
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) {
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_KNODE = Symbol(`createKNode` );
const CREATE_ELEMENT_KNODE = Symbol(`createElementKNode` );
const CREATE_COMMENT = Symbol(`createCommentKNode` );
const CREATE_TEXT = Symbol(`createTextKNode` );
const CREATE_STATIC = Symbol(`createStaticKNode` );
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_KNODE]: `createKNode`,
[CREATE_ELEMENT_KNODE]: `createElementKNode`,
[CREATE_COMMENT]: `createCommentKNode`,
[CREATE_TEXT]: `createTextKNode`,
[CREATE_STATIC]: `createStaticKNode`,
[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",
"KNODE_CALL": 13,
"13": "KNODE_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_HOIST": 2,
"2": "CAN_HOIST",
"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: 0,
temps: 0,
codegenNode: void 0,
loc: locStub
};
}
function createKNodeCall(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(getKNodeBlockHelper(context.inSSR, isComponent));
} else {
context.helper(getKNodeHelper(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, isKNode = false) {
return {
type: 20,
index,
value,
isKNode,
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 getKNodeHelper(ssr, isComponent) {
return ssr || isComponent ? CREATE_KNODE : CREATE_ELEMENT_KNODE;
}
function getKNodeBlockHelper(ssr, isComponent) {
return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
}
function convertToBlock(node, { helper, removeHelper, inSSR }) {
if (!node.isBlock) {
node.isBlock = true;
removeHelper(getKNodeHelper(inSSR, node.isComponent));
helper(OPEN_BLOCK);
helper(getKNodeBlockHelper(inSSR, node.isComponent));
}
}
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
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]),
// `</style`
TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
// `</title`
TextareaEnd: new Uint8Array([
60,
47,
116,
101,
120,
116,
97,
114,
101,
97
])
// `</textarea
};
class Tokenizer {
constructor(stack, cbs) {
this.stack = stack;
this.cbs = cbs;
/** The current state the tokenizer is in. */
__publicField(this, "state", 1);
/** The read buffer. */
__publicField(this, "buffer", "");
/** The beginning of the section that is currently being read. */
__publicField(this, "sectionStart", 0);
/** The index within the buffer that we are currently looking at. */
__publicField(this, "index", 0);
/** The start of the last entity. */
__publicField(this, "entityStart", 0);
/** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
__publicField(this, "baseState", 1);
/** For special parsing behavior inside of script and style tags. */
__publicField(this, "inRCDATA", false);
/** For disabling RCDATA tags handling */
__publicField(this, "inXML", false);
/** For disabling interpolation parsing in k-pre */
__publicField(this, "inKPre", false);
/** Record newline positions for fast line / column calculation */
__publicField(this, "newlines", []);
__publicField(this, "entityDecoder");
__publicField(this, "mode", 0);
__publicField(this, "delimiterOpen", defaultDelimitersOpen);
__publicField(this, "delimiterClose", defaultDelimitersClose);
__publicField(this, "delimiterIndex", -1);
__publicField(this, "currentSequence");
__publicField(this, "sequenceIndex", 0);
}
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 (!this.inKPre && 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 <title> and <textarea>, also decode entities. */
stateInRCDATA(c) {
if (this.sequenceIndex === this.currentSequence.length) {
if (c === 62 || isWhitespace(c)) {
const endOfText = this.index - this.currentSequence.length;
if (this.sectionStart < endOfText) {
const actualIndex = this.index;
this.index = endOfText;
this.cbs.ontext(this.sectionStart, endOfText);
this.index = actualIndex;
}
this.sectionStart = endOfText + 2;
this.stateInClosingTagName(c);
this.inRCDATA = false;
return;
}
this.sequenceIndex = 0;
}
if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
this.sequenceIndex += 1;
} else if (this.sequenceIndex === 0) {
if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
if (c === this.delimiterOpen[0]) {
this.state = 2;
this.delimiterIndex = 0;
this.stateInterpolationOpen(c);
}
} else if (this.fastForwardTo(60)) {
this.sequenceIndex = 1;
}
} else {
this.sequenceIndex = Number(c === 60);
}
}
stateCDATASequence(c) {
if (c === Sequences.Cdata[this.sequenceIndex]) {
if (++this.sequenceIndex === Sequences.Cdata.length) {
this.state = 28;
this.currentSequence = Sequences.CdataEnd;
this.sequenceIndex = 0;
this.sectionStart = this.index + 1;
}
} else {
this.sequenceIndex = 0;
this.state = 23;
this.stateInDeclaration(c);
}
}
/**
* When we wait for one specific character, we can speed things up
* by skipping through the buffer until we find it.
*
* @returns Whether the character was found.
*/
fastForwardTo(c) {
while (++this.index < this.buffer.length) {
const cc = this.buffer.charCodeAt(this.index);
if (cc === 10) {
this.newlines.push(this.index);
}
if (cc === c) {
return true;
}
}
this.index = this.buffer.length - 1;
return false;
}
/**
* Comments and CDATA end with `-->` and `]]>`.
*
* Their common qualities are:
* - Their end sequences have a distinct character they start with.
* - That character is then repeated, so we have to check multiple repeats.
* - All characters but the start character of the sequence can be skipped.
*/
stateInCommentLike(c) {
if (c === this.currentSequence[this.sequenceIndex]) {
if (++this.sequenceIndex === this.currentSequence.length) {
if (this.currentSequence === Sequences.CdataEnd) {
this.cbs.oncdata(this.sectionStart, this.index - 2);
} else {
this.cbs.oncomment(this.sectionStart, this.index - 2);
}
this.sequenceIndex = 0;
this.sectionStart = this.index + 1;
this.state = 1;
}
} else if (this.sequenceIndex === 0) {
if (this.fastForwardTo(this.currentSequence[0])) {
this.sequenceIndex = 1;
}
} else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
this.sequenceIndex = 0;
}
}
startSpecial(sequence, offset) {
this.enterRCDATA(sequence, offset);
this.state = 31;
}
enterRCDATA(sequence, offset) {
this.inRCDATA = true;
this.currentSequence = sequence;
this.sequenceIndex = offset;
}
stateBeforeTagName(c) {
if (c === 33) {
this.state = 22;
this.sectionStart = this.index + 1;
} else if (c === 63) {
this.state = 24;
this.sectionStart = this.index + 1;
} else if (isTagStartChar(c)) {
this.sectionStart = this.index;
if (this.mode === 0) {
this.state = 6;
} else if (this.inSFCRoot) {
this.state = 34;
} else if (!this.inXML) {
if (c === 116) {
this.state = 30;
} else {
this.state = c === 115 ? 29 : 6;
}
} else {
this.state = 6;
}
} else if (c === 47) {
this.state = 8;
} else {
this.state = 1;
this.stateText(c);
}
}
stateInTagName(c) {
if (isEndOfTagSection(c)) {
this.handleTagName(c);
}
}
stateInSFCRootTagName(c) {
if (isEndOfTagSection(c)) {
const tag = this.buffer.slice(this.sectionStart, this.index);
if (tag !== "template") {
this.enterRCDATA(toCharCodes(`</` + tag), 0);
}
this.handleTagName(c);
}
}
handleTagName(c) {
this.cbs.onopentagname(this.sectionStart, this.index);
this.sectionStart = -1;
this.state = 11;
this.stateBeforeAttrName(c);
}
stateBeforeClosingTagName(c) {
if (isWhitespace(c)) ; else if (c === 62) {
{
this.cbs.onerr(14, this.index);
}
this.state = 1;
this.sectionStart = this.index + 1;
} else {
this.state = isTagStartChar(c) ? 9 : 27;
this.sectionStart = this.index;
}
}
stateInClosingTagName(c) {
if (c === 62 || isWhitespace(c)) {
this.cbs.onclosetag(this.sectionStart, this.index);
this.sectionStart = -1;
this.state = 10;
this.stateAfterClosingTagName(c);
}
}
stateAfterClosingTagName(c) {
if (c === 62) {
this.state = 1;
this.sectionStart = this.index + 1;
}
}
stateBeforeAttrName(c) {
if (c === 62) {
this.cbs.onopentagend(this.index);
if (this.inRCDATA) {
this.state = 32;
} else {
this.state = 1;
}
this.sectionStart = this.index + 1;
} else if (c === 47) {
this.state = 7;
if (this.peek() !== 62) {
this.cbs.onerr(22, this.index);
}
} else if (c === 60 && this.peek() === 47) {
this.cbs.onopentagend(this.index);
this.state = 5;
this.sectionStart = this.index;
} else if (!isWhitespace(c)) {
if (c === 61) {
this.cbs.onerr(
19,
this.index
);
}
this.handleAttrStart(c);
}
}
handleAttrStart(c) {
if (c === 118 && this.peek() === 45) {
this.state = 13;
this.sectionStart = this.index;
} else if (c === 46 || c === 58 || c === 64 || c === 35) {
this.cbs.ondirname(this.index, this.index + 1);
this.state = 14;
this.sectionStart = this.index + 1;
} else {
this.state = 12;
this.sectionStart = this.index;
}
}
stateInSelfClosingTag(c) {
if (c === 62) {
this.cbs.onselfclosingtag(this.index);
this.state = 1;
this.sectionStart = this.index + 1;
this.inRCDATA = false;
} else if (!isWhitespace(c)) {
this.state = 11;
this.stateBeforeAttrName(c);
}
}
stateInAttrName(c) {
if (c === 61 || isEndOfTagSection(c)) {
this.cbs.onattribname(this.sectionStart, this.index);
this.handleAttrNameEnd(c);
} else if (c === 34 || c === 39 || c === 60) {
this.cbs.onerr(
17,
this.index
);
}
}
stateInDirName(c) {
if (c === 61 || isEndOfTagSection(c)) {
this.cbs.ondirname(this.sectionStart, this.index);
this.handleAttrNameEnd(c);
} else if (c === 58) {
this.cbs.ondirname(this.sectionStart, this.index);
this.state = 14;
this.sectionStart = this.index + 1;
} else if (c === 46) {
this.cbs.ondirname(this.sectionStart, this.index);
this.state = 16;
this.sectionStart = this.index + 1;
}
}
stateInDirArg(c) {
if (c === 61 || isEndOfTagSection(c)) {
this.cbs.ondirarg(this.sectionStart, this.index);
this.handleAttrNameEnd(c);
} else if (c === 91) {
this.state = 15;
} else if (c === 46) {
this.cbs.ondirarg(this.sectionStart, this.index);
this.state = 16;
this.sectionStart = this.index + 1;
}
}
stateInDynamicDirArg(c) {
if (c === 93) {
this.state = 14;
} else if (c === 61 || isEndOfTagSection(c)) {
this.cbs.ondirarg(this.sectionStart, this.index + 1);
this.handleAttrNameEnd(c);
{
this.cbs.onerr(
27,
this.index
);
}
}
}
stateInDirModifier(c) {
if (c === 61 || isEndOfTagSection(c)) {
this.cbs.ondirmodifier(this.sectionStart, this.index);
this.handleAttrNameEnd(c);
} else if (c === 46) {
this.cbs.ondirmodifier(this.sectionStart, this.index);
this.sectionStart = this.index + 1;
}
}
handleAttrNameEnd(c) {
this.sectionStart = this.index;
this.state = 17;
this.cbs.onattribnameend(this.index);
this.stateAfterAttrName(c);
}
stateAfterAttrName(c) {
if (c === 61) {
this.state = 18;
} else if (c === 47 || c === 62) {
this.cbs.onattribend(0, this.sectionStart);
this.sectionStart = -1;
this.state = 11;
this.stateBeforeAttrName(c);
} else if (!isWhitespace(c)) {
this.cbs.onattribend(0, this.sectionStart);
this.handleAttrStart(c);
}
}
stateBeforeAttrValue(c) {
if (c === 34) {
this.state = 19;
this.sectionStart = this.index + 1;
} else if (c === 39) {
this.state = 20;
this.sectionStart = this.index + 1;
} else if (!isWhitespace(c)) {
this.sectionStart = this.index;
this.state = 21;
this.stateInAttrValueNoQuotes(c);
}
}
handleInAttrValue(c, quote) {
if (c === quote || this.fastForwardTo(quote)) {
this.cbs.onattribdata(this.sectionStart, this.index);
this.sectionStart = -1;
this.cbs.onattribend(
quote === 34 ? 3 : 2,
this.index + 1
);
this.state = 11;
}
}
stateInAttrValueDoubleQuotes(c) {
this.handleInAttrValue(c, 34);
}
stateInAttrValueSingleQuotes(c) {
this.handleInAttrValue(c, 39);
}
stateInAttrValueNoQuotes(c) {
if (isWhitespace(c) || c === 62) {
this.cbs.onattribdata(this.sectionStart, this.index);
this.sectionStart = -1;
this.cbs.onattribend(1, this.index);
this.state = 11;
this.stateBeforeAttrName(c);
} else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
this.cbs.onerr(
18,
this.index
);
} else ;
}
stateBeforeDeclaration(c) {
if (c === 91) {
this.state = 26;
this.sequenceIndex = 0;
} else {
this.state = c === 45 ? 25 : 23;
}
}
stateInDeclaration(c) {
if (c === 62 || this.fastForwardTo(62)) {
this.state = 1;
this.sectionStart = this.index + 1;
}
}
stateInProcessingInstruction(c) {
if (c === 62 || this.fastForwardTo(62)) {
this.cbs.onprocessinginstruction(this.sectionStart, this.index);
this.state = 1;
this.sectionStart = this.index + 1;
}
}
stateBeforeComment(c) {
if (c === 45) {
this.state = 28;
this.currentSequence = Sequences.CommentEnd;
this.sequenceIndex = 2;
this.sectionStart = this.index + 1;
} else {
this.state = 23;
}
}
stateInSpecialComment(c) {
if (c === 62 || this.fastForwardTo(62)) {
this.cbs.oncomment(this.sectionStart, this.index);
this.state = 1;
this.sectionStart = this.index + 1;
}
}
stateBeforeSpecialS(c) {
if (c === Sequences.ScriptEnd[3]) {
this.startSpecial(Sequences.ScriptEnd, 4);
} else if (c === Sequences.StyleEnd[3]) {
this.startSpecial(Sequences.StyleEnd, 4);
} else {
this.state = 6;
this.stateInTagName(c);
}
}
stateBeforeSpecialT(c) {
if (c === Sequences.TitleEnd[3]) {
this.startSpecial(Sequences.TitleEnd, 4);
} else if (c === Sequences.TextareaEnd[3]) {
this.startSpecial(Sequences.TextareaEnd, 4);
} else {
this.state = 6;
this.stateInTagName(c);
}
}
startEntity() {
}
stateInEntity() {
}
/**
* Iterates through the buffer, calling the function corresponding to the current state.
*
* States that are more likely to be hit are higher up, as a performance improvement.
*/
parse(input) {
this.buffer = input;
while (this.index < this.buffer.length) {
const c = this.buffer.charCodeAt(this.index);
if (c === 10) {
this.newlines.push(this.index);
}
switch (this.state) {
case 1: {
this.stateText(c);
break;
}
case 2: {
this.stateInterpolationOpen(c);
break;
}
case 3: {
this.stateInterpolation(c);
break;
}
case 4: {
this.stateInterpolationClose(c);
break;
}
case 31: {
this.stateSpecialStartSequence(c);
break;
}
case 32: {
this.stateInRCDATA(c);
break;
}
case 26: {
this.stateCDATASequence(c);
break;
}
case 19: {
this.stateInAttrValueDoubleQuotes(c);
break;
}
case 12: {
this.stateInAttrName(c);
break;
}
case 13: {
this.stateInDirName(c);
break;
}
case 14: {
this.stateInDirArg(c);
break;
}
case 15: {
this.stateInDynamicDirArg(c);
break;
}
case 16: {
this.stateInDirModifier(c);
break;
}
case 28: {
this.stateInCommentLike(c);
break;
}
case 27: {
this.stateInSpecialComment(c);
break;
}
case 11: {
this.stateBeforeAttrName(c);
break;
}
case 6: {
this.stateInTagName(c);
break;
}
case 34: {
this.stateInSFCRootTagName(c);
break;
}
case 9: {
this.stateInClosingTagName(c);
break;
}
case 5: {
this.stateBeforeTagName(c);
break;
}
case 17: {
this.stateAfterAttrName(c);
break;
}
case 20: {
this.stateInAttrValueSingleQuotes(c);
break;
}
case 18: {
this.stateBeforeAttrValue(c);
break;
}
case 8: {
this.stateBeforeClosingTagName(c);
break;
}
case 10: {
this.stateAfterClosingTagName(c);
break;
}
case 29: {
this.stateBeforeSpecialS(c);
break;
}
case 30: {
this.stateBeforeSpecialT(c);
break;
}
case 21: {
this.stateInAttrValueNoQuotes(c);
break;
}
case 7: {
this.stateInSelfClosingTag(c);
break;
}
case 23: {
this.stateInDeclaration(c);
break;
}
case 22: {
this.stateBeforeDeclaration(c);
break;
}
case 25: {
this.stateBeforeComment(c);
break;
}
case 24: {
this.stateInProcessingInstruction(c);
break;
}
case 33: {
this.stateInEntity();
break;
}
}
this.index++;
}
this.cleanup();
this.finish();
}
/**
* Remove data that has already been consumed from the buffer.
*/
cleanup() {
if (this.sectionStart !== this.index) {
if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
this.cbs.ontext(this.sectionStart, this.index);
this.sectionStart = this.index;
} else if (this.state === 19 || this.state === 20 || this.state === 21) {
this.cbs.onattribdata(this.sectionStart, this.index);
this.sectionStart = this.index;
}
}
}
finish() {
this.handleTrailingData();
this.cbs.onend();
}
/** Handle any trailing data. */
handleTrailingData() {
const endIndex = this.buffer.length;
if (this.sectionStart >= endIndex) {
return;
}
if (this.state === 28) {
if (this.currentSequence === Sequences.CdataEnd) {
this.cbs.oncdata(this.sectionStart, endIndex);
} else {
this.cbs.oncomment(this.sectionStart, endIndex);
}
} else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) ; else {
this.cbs.ontext(this.sectionStart, endIndex);
}
}
emitCodePoint(cp, consumed) {
}
}
const CompilerDeprecationTypes = {
"COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
"COMPILER_K_BIND_SYNC": "COMPILER_K_BIND_SYNC",
"COMPILER_K_BIND_OBJECT_ORDER": "COMPILER_K_BIND_OBJECT_ORDER",
"COMPILER_K_ON_NATIVE": "COMPILER_K_ON_NATIVE",
"COMPILER_K_IF_K_FOR_PRECEDENCE": "COMPILER_K_IF_K_FOR_PRECEDENCE",
"COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
"COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
"COMPILER_FILTERS": "COMPILER_FILTERS"
};
const deprecationData = {
["COMPILER_IS_ON_ELEMENT"]: {
message: `Platform-native elements with "is" prop will no longer be treated as components in Kdu 3 unless the "is" value is explicitly prefixed with "kdu:".`,
link: `https://kdujs-v3-migration.web.app/breaking-changes/custom-elements-interop.html`
},
["COMPILER_K_BIND_SYNC"]: {
message: (key) => `.sync modifier for k-bind has been removed. Use k-model with argument instead. \`k-bind:${key}.sync\` should be changed to \`k-model:${key}\`.`,
link: `https://kdujs-v3-migration.web.app/breaking-changes/k-model.html`
},
["COMPILER_K_BIND_OBJECT_ORDER"]: {
message: `k-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before k-bind in the case of conflict. To retain 2.x behavior, move k-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
link: `https://kdujs-v3-migration.web.app/breaking-changes/k-bind.html`
},
["COMPILER_K_ON_NATIVE"]: {
message: `.native modifier for k-on has been removed as is no longer necessary.`,
link: `https://kdujs-v3-migration.web.app/breaking-changes/k-on-native-modifier-removed.html`
},
["COMPILER_K_IF_K_FOR_PRECEDENCE"]: {
message: `k-if / k-for precedence when used on the same element has changed in Kdu 3: k-if now takes higher precedence and will no longer have access to k-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters k-for data source.`,
link: `https://kdujs-v3-migration.web.app/breaking-changes/k-if-k-for.html`
},
["COMPILER_NATIVE_TEMPLATE"]: {
message: `<template> with no special directives will render as a native template element instead of its inner content in Kdu 3.`
},
["COMPILER_INLINE_TEMPLATE"]: {
message: `"inline-template" has been removed in Kdu 3.`,
link: `https://kdujs-v3-migration.web.app/breaking-changes/inline-template-attribute.html`
},
["COMPILER_FILTERS"]: {
message: `filters have been removed in Kdu 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
link: `https://kdujs-v3-migration.web.app/breaking-changes/filters.html`
}
};
function getCompatValue(key, { compatConfig }) {
const value = compatConfig && compatConfig[key];
if (key === "MODE") {
return value || 3;
} else {
return value;
}
}
function isCompatEnabled(key, context) {
const mode = getCompatValue("MODE", context);
const value = getCompatValue(key, context);
return mode === 3 ? value === true : value !== false;
}
function checkCompatEnabled(key, context, loc, ...args) {
const enabled = isCompatEnabled(key, context);
if (enabled) {
warnDeprecation(key, context, loc, ...args);
}
return enabled;
}
function warnDeprecation(key, context, loc, ...args) {
const val = getCompatValue(key, context);
if (val === "suppress-warning") {
return;
}
const { message, link } = deprecationData[key];
const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
Details: ${link}` : ``}`;
const err = new SyntaxError(msg);
err.code = key;
if (loc)
err.loc = loc;
context.onWarn(err);
}
function defaultOnError(error) {
throw error;
}
function defaultOnWarn(msg) {
console.warn(`[Kdu warn] ${msg.message}`);
}
function createCompilerError(code, loc, messages, additionalMessage) {
const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
const error = new SyntaxError(String(msg));
error.code = code;
error.loc = loc;
return error;
}
const ErrorCodes = {
"ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
"0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
"CDATA_IN_HTML_CONTENT": 1,
"1": "CDATA_IN_HTML_CONTENT",
"DUPLICATE_ATTRIBUTE": 2,
"2": "DUPLICATE_ATTRIBUTE",
"END_TAG_WITH_ATTRIBUTES": 3,
"3": "END_TAG_WITH_ATTRIBUTES",
"END_TAG_WITH_TRAILING_SOLIDUS": 4,
"4": "END_TAG_WITH_TRAILING_SOLIDUS",
"EOF_BEFORE_TAG_NAME": 5,
"5": "EOF_BEFORE_TAG_NAME",
"EOF_IN_CDATA": 6,
"6": "EOF_IN_CDATA",
"EOF_IN_COMMENT": 7,
"7": "EOF_IN_COMMENT",
"EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
"8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
"EOF_IN_TAG": 9,
"9": "EOF_IN_TAG",
"INCORRECTLY_CLOSED_COMMENT": 10,
"10": "INCORRECTLY_CLOSED_COMMENT",
"INCORRECTLY_OPENED_COMMENT": 11,
"11": "INCORRECTLY_OPENED_COMMENT",
"INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
"12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
"MISSING_ATTRIBUTE_VALUE": 13,
"13": "MISSING_ATTRIBUTE_VALUE",
"MISSING_END_TAG_NAME": 14,
"14": "MISSING_END_TAG_NAME",
"MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
"15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
"NESTED_COMMENT": 16,
"16": "NESTED_COMMENT",
"UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
"17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
"UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
"18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
"UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
"19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
"UNEXPECTED_NULL_CHARACTER": 20,
"20": "UNEXPECTED_NULL_CHARACTER",
"UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
"21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
"UNEXPECTED_SOLIDUS_IN_TAG": 22,
"22": "UNEXPECTED_SOLIDUS_IN_TAG",
"X_INVALID_END_TAG": 23,
"23": "X_INVALID_END_TAG",
"X_MISSING_END_TAG": 24,
"24": "X_MISSING_END_TAG",
"X_MISSING_INTERPOLATION_END": 25,
"25": "X_MISSING_INTERPOLATION_END",
"X_MISSING_DIRECTIVE_NAME": 26,
"26": "X_MISSING_DIRECTIVE_NAME",
"X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
"27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
"X_K_IF_NO_EXPRESSION": 28,
"28": "X_K_IF_NO_EXPRESSION",
"X_K_IF_SAME_KEY": 29,
"29": "X_K_IF_SAME_KEY",
"X_K_ELSE_NO_ADJACENT_IF": 30,
"30": "X_K_ELSE_NO_ADJACENT_IF",
"X_K_FOR_NO_EXPRESSION": 31,
"31": "X_K_FOR_NO_EXPRESSION",
"X_K_FOR_MALFORMED_EXPRESSION": 32,
"32": "X_K_FOR_MALFORMED_EXPRESSION",
"X_K_FOR_TEMPLATE_KEY_PLACEMENT": 33,
"33": "X_K_FOR_TEMPLATE_KEY_PLACEMENT",
"X_K_BIND_NO_EXPRESSION": 34,
"34": "X_K_BIND_NO_EXPRESSION",
"X_K_ON_NO_EXPRESSION": 35,
"35": "X_K_ON_NO_EXPRESSION",
"X_K_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
"36": "X_K_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
"X_K_SLOT_MIXED_SLOT_USAGE": 37,
"37": "X_K_SLOT_MIXED_SLOT_USAGE",
"X_K_SLOT_DUPLICATE_SLOT_NAMES": 38,
"38": "X_K_SLOT_DUPLICATE_SLOT_NAMES",
"X_K_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
"39": "X_K_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
"X_K_SLOT_MISPLACED": 40,
"40": "X_K_SLOT_MISPLACED",
"X_K_MODEL_NO_EXPRESSION": 41,
"41": "X_K_MODEL_NO_EXPRESSION",
"X_K_MODEL_MALFORMED_EXPRESSION": 42,
"42": "X_K_MODEL_MALFORMED_EXPRESSION",
"X_K_MODEL_ON_SCOPE_VARIABLE": 43,
"43": "X_K_MODEL_ON_SCOPE_VARIABLE",
"X_K_MODEL_ON_PROPS": 44,
"44": "X_K_MODEL_ON_PROPS",
"X_INVALID_EXPRESSION": 45,
"45": "X_INVALID_EXPRESSION",
"X_KEEP_ALIVE_INVALID_CHILDREN": 46,
"46": "X_KEEP_ALIVE_INVALID_CHILDREN",
"X_PREFIX_ID_NOT_SUPPORTED": 47,
"47": "X_PREFIX_ID_NOT_SUPPORTED",
"X_MODULE_MODE_NOT_SUPPORTED": 48,
"48": "X_MODULE_MODE_NOT_SUPPORTED",
"X_CACHE_HANDLER_NOT_SUPPORTED": 49,
"49": "X_CACHE_HANDLER_NOT_SUPPORTED",
"X_SCOPE_ID_NOT_SUPPORTED": 50,
"50": "X_SCOPE_ID_NOT_SUPPORTED",
"X_KNODE_HOOKS": 51,
"51": "X_KNODE_HOOKS",
"X_K_BIND_INVALID_SAME_NAME_ARGUMENT": 52,
"52": "X_K_BIND_INVALID_SAME_NAME_ARGUMENT",
"__EXTEND_POINT__": 53,
"53": "__EXTEND_POINT__"
};
const errorMessages = {
// parse errors
[0]: "Illegal comment.",
[1]: "CDATA section is allowed only in XML context.",
[2]: "Duplicate attribute.",
[3]: "End tag cannot have attributes.",
[4]: "Illegal '/' in tags.",
[5]: "Unexpected EOF in tag.",
[6]: "Unexpected EOF in CDATA section.",
[7]: "Unexpected EOF in comment.",
[8]: "Unexpected EOF in script.",
[9]: "Unexpected EOF in tag.",
[10]: "Incorrectly closed comment.",
[11]: "Incorrectly opened comment.",
[12]: "Illegal tag name. Use '<' to print '<'.",
[13]: "Attribute value was expected.",
[14]: "End tag name was expected.",
[15]: "Whitespace was expected.",
[16]: "Unexpected '<!--' in comment.",
[17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
[18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
[19]: "Attribute name cannot start with '='.",
[21]: "'<?' is allowed only in XML context.",
[20]: `Unexpected null character.`,
[22]: "Illegal '/' in tags.",
// Kdu-specific parse errors
[23]: "Invalid end tag.",
[24]: "Element is missing end tag.",
[25]: "Interpolation end sign was not found.",
[27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
[26]: "Legal directive name was expected.",
// transform errors
[28]: `k-if/k-else-if is missing expression.`,
[29]: `k-if/else branches must use unique keys.`,
[30]: `k-else/k-else-if has no adjacent k-if or k-else-if.`,
[31]: `k-for is missing expression.`,
[32]: `k-for has invalid expression.`,
[33]: `<template k-for> key should be placed on the <template> tag.`,
[34]: `k-bind is missing expression.`,
[52]: `k-bind with same-name shorthand only allows static argument.`,
[35]: `k-on is missing expression.`,
[36]: `Unexpected custom directive on <slot> outlet.`,
[37]: `Mixed k-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
[38]: `Duplicate slot names found. `,
[39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
[40]: `k-slot can only be used on components or <template> tags.`,
[41]: `k-model is missing expression.`,
[42]: `k-model value must be a valid JavaScript member expression.`,
[43]: `k-model cannot be used on k-for or k-slot scope variables because they are not writable.`,
[44]: `k-model cannot be used on a prop, because local prop bindings are not writable.
Use a k-bind binding combined with a k-on listener that emits update:x event instead.`,
[45]: `Error parsing JavaScript expression: `,
[46]: `<KeepAlive> expects exactly one child component.`,
[51]: `@knode-* hooks in templates are no longer supported. Use the kdu: prefix instead. For example, @knode-mounted should be changed to @kdu:mounted. @knode-* hooks support has been removed in 3.4.`,
// generic errors
[47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
[48]: `ES module mode is not supported in this build of compiler.`,
[49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
[50]: `"scopeId" option is only supported in module mode.`,
// just to fulfill types
[53]: ``
};
function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
{
return;
}
}
function isReferencedIdentifier(id, parent, parentStack) {
{
return false;
}
}
function isInDestructureAssignment(parent, parentStack) {
if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
let i = parentStack.length;
while (i--) {
const p = parentStack[i];
if (p.type === "AssignmentExpression") {
return true;
} else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
break;