@vue-email/compiler
Version:
Compile vue-email templates
1,134 lines (1,115 loc) • 1.8 MB
JavaScript
import { resolve as resolve$3, join as join$3, extname as extname$1 } from 'node:path';
import { readFileSync as readFileSync$1, readdirSync, statSync } from 'node:fs';
import { deepmerge, VueEmailPlugin, htmlToText, cleanup, EBody, EHead, EHeading, EButton, ECodeBlock, ECodeInline, EColumn, EContainer, EFont, EHr, EHtml, EImg, ELink, EMarkdown, EPreview, ERow, ESection, ETailwind, EText } from 'vue-email';
import { initDirectivesForSSR, createApp, createVNode, ssrContextKey, warn as warn$3, Fragment, Static, Comment as Comment$5, Text, mergeProps, ssrUtils, defineComponent, h, getCurrentInstance, effectScope, inject, onMounted, onUnmounted, shallowRef, ref, computed, onBeforeMount, watch, isRef } from 'vue';
import { lightGreen, bold, blue } from 'kolorist';
import { pascalCase } from 'scule';
import { importModule } from 'import-string';
function createInitConfig(options) {
const config = deepmerge(
{
verbose: true,
options: options.options,
vueCompilerOptions: options.vueCompilerOptions
},
options
);
return config;
}
function makeMap$1(str, expectsLowerCase) {
const map = /* @__PURE__ */ Object.create(null);
const list = str.split(",");
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
}
const EMPTY_OBJ = Object.freeze({}) ;
const NOOP$1 = () => {
};
const NO = () => false;
const onRE$1 = /^on[^a-z]/;
const isOn$1 = (key) => onRE$1.test(key);
const extend = Object.assign;
const hasOwnProperty$3 = Object.prototype.hasOwnProperty;
const hasOwn$1 = (val, key) => hasOwnProperty$3.call(val, key);
const isArray$3 = Array.isArray;
const isMap = (val) => toTypeString$1(val) === "[object Map]";
const isSet = (val) => toTypeString$1(val) === "[object Set]";
const isFunction$1$1 = (val) => typeof val === "function";
const isString$2 = (val) => typeof val === "string";
const isSymbol$1 = (val) => typeof val === "symbol";
const isObject$2 = (val) => val !== null && typeof val === "object";
const objectToString$1 = Object.prototype.toString;
const toTypeString$1 = (value) => objectToString$1.call(value);
const isPlainObject$1 = (val) => toTypeString$1(val) === "[object Object]";
const isReservedProp = /* @__PURE__ */ makeMap$1(
// 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$1(
"bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
);
const cacheStringFunction$1 = (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$1((str) => {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
});
const hyphenateRE$1 = /\B([A-Z])/g;
const hyphenate$1 = cacheStringFunction$1(
(str) => str.replace(hyphenateRE$1, "-$1").toLowerCase()
);
const capitalize$1 = cacheStringFunction$1((str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
});
const toHandlerKey = cacheStringFunction$1((str) => {
const s = str ? `on${capitalize$1(str)}` : ``;
return s;
});
const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
function genPropsAccessExp(name) {
return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
}
const PatchFlagNames = {
[1]: `TEXT`,
[2]: `CLASS`,
[4]: `STYLE`,
[8]: `PROPS`,
[16]: `FULL_PROPS`,
[32]: `HYDRATE_EVENTS`,
[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 GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console";
const isGloballyAllowed = /* @__PURE__ */ makeMap$1(GLOBALS_ALLOWED);
const range = 2;
function generateCodeFrame$1(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");
}
function normalizeStyle$1(value) {
if (isArray$3(value)) {
const res = {};
for (let i = 0; i < value.length; i++) {
const item = value[i];
const normalized = isString$2(item) ? parseStringStyle$1(item) : normalizeStyle$1(item);
if (normalized) {
for (const key in normalized) {
res[key] = normalized[key];
}
}
}
return res;
} else if (isString$2(value) || isObject$2(value)) {
return value;
}
}
const listDelimiterRE$1 = /;(?![^(]*\))/g;
const propertyDelimiterRE$1 = /:([^]+)/;
const styleCommentRE$1 = /\/\*[^]*?\*\//g;
function parseStringStyle$1(cssText) {
const ret = {};
cssText.replace(styleCommentRE$1, "").split(listDelimiterRE$1).forEach((item) => {
if (item) {
const tmp = item.split(propertyDelimiterRE$1);
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
}
});
return ret;
}
function stringifyStyle$1(styles) {
let ret = "";
if (!styles || isString$2(styles)) {
return ret;
}
for (const key in styles) {
const value = styles[key];
const normalizedKey = key.startsWith(`--`) ? key : hyphenate$1(key);
if (isString$2(value) || typeof value === "number") {
ret += `${normalizedKey}:${value};`;
}
}
return ret;
}
function normalizeClass$1(value) {
let res = "";
if (isString$2(value)) {
res = value;
} else if (isArray$3(value)) {
for (let i = 0; i < value.length; i++) {
const normalized = normalizeClass$1(value[i]);
if (normalized) {
res += normalized + " ";
}
}
} else if (isObject$2(value)) {
for (const name in value) {
if (value[name]) {
res += name + " ";
}
}
}
return res.trim();
}
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$1 = "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 VOID_TAGS$1 = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
const isHTMLTag = /* @__PURE__ */ makeMap$1(HTML_TAGS);
const isSVGTag$1 = /* @__PURE__ */ makeMap$1(SVG_TAGS$1);
const isVoidTag$1 = /* @__PURE__ */ makeMap$1(VOID_TAGS$1);
const specialBooleanAttrs$1 = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
const isBooleanAttr$1 = /* @__PURE__ */ makeMap$1(
specialBooleanAttrs$1 + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
);
const unsafeAttrCharRE$1 = /[>/="'\u0009\u000a\u000c\u0020]/;
const attrValidationCache$1 = {};
function isSSRSafeAttrName$1(name) {
if (attrValidationCache$1.hasOwnProperty(name)) {
return attrValidationCache$1[name];
}
const isUnsafe = unsafeAttrCharRE$1.test(name);
if (isUnsafe) {
console.error(`unsafe attribute name: ${name}`);
}
return attrValidationCache$1[name] = !isUnsafe;
}
const propsToAttrMap$1 = {
acceptCharset: "accept-charset",
className: "class",
htmlFor: "for",
httpEquiv: "http-equiv"
};
const isKnownHtmlAttr = /* @__PURE__ */ makeMap$1(
`accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap`
);
const isKnownSvgAttr = /* @__PURE__ */ makeMap$1(
`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
);
const escapeRE$1 = /["'&<>]/;
function escapeHtml$2(string) {
const str = "" + string;
const match = escapeRE$1.exec(str);
if (!match) {
return str;
}
let html = "";
let escaped;
let index;
let lastIndex = 0;
for (index = match.index; index < str.length; index++) {
switch (str.charCodeAt(index)) {
case 34:
escaped = """;
break;
case 38:
escaped = "&";
break;
case 39:
escaped = "'";
break;
case 60:
escaped = "<";
break;
case 62:
escaped = ">";
break;
default:
continue;
}
if (lastIndex !== index) {
html += str.slice(lastIndex, index);
}
lastIndex = index + 1;
html += escaped;
}
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
}
const toDisplayString$1 = (val) => {
return isString$2(val) ? val : val == null ? "" : isArray$3(val) || isObject$2(val) && (val.toString === objectToString$1 || !isFunction$1$1(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
};
const replacer = (_key, val) => {
if (val && val.__v_isRef) {
return replacer(_key, val.value);
} else if (isMap(val)) {
return {
[`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val2]) => {
entries[`${key} =>`] = val2;
return entries;
}, {})
};
} else if (isSet(val)) {
return {
[`Set(${val.size})`]: [...val.values()]
};
} else if (isObject$2(val) && !isArray$3(val) && !isPlainObject$1(val)) {
return String(val);
}
return val;
};
function defaultOnError$1(error) {
throw error;
}
function defaultOnWarn(msg) {
console.warn(`[Vue warn] ${msg.message}`);
}
function createCompilerError(code, loc, messages, additionalMessage) {
const msg = (messages || errorMessages$3)[code] + (additionalMessage || ``) ;
const error = new SyntaxError(String(msg));
error.code = code;
error.loc = loc;
return error;
}
const errorMessages$3 = {
// 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.",
// Vue-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]: `v-if/v-else-if is missing expression.`,
[29]: `v-if/else branches must use unique keys.`,
[30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
[31]: `v-for is missing expression.`,
[32]: `v-for has invalid expression.`,
[33]: `<template v-for> key should be placed on the <template> tag.`,
[34]: `v-bind is missing expression.`,
[35]: `v-on is missing expression.`,
[36]: `Unexpected custom directive on <slot> outlet.`,
[37]: `Mixed v-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]: `v-slot can only be used on components or <template> tags.`,
[41]: `v-model is missing expression.`,
[42]: `v-model value must be a valid JavaScript member expression.`,
[43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
[44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
[45]: `Error parsing JavaScript expression: `,
[46]: `<KeepAlive> expects exactly one child component.`,
// 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.`,
// deprecations
[51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
[52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
// just to fulfill types
[53]: ``
};
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 locStub = {
source: "",
start: { line: 1, column: 1, offset: 0 },
end: { line: 1, column: 1, offset: 0 }
};
function createRoot(children, loc = locStub) {
return {
type: 0,
children,
helpers: /* @__PURE__ */ new Set(),
components: [],
directives: [],
hoists: [],
imports: [],
cached: 0,
temps: 0,
codegenNode: void 0,
loc
};
}
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$2(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$2(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, isVNode = false) {
return {
type: 20,
index,
value,
isVNode,
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));
}
}
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
function getAugmentedNamespace(n) {
if (n.__esModule) return n;
var f = n.default;
if (typeof f == "function") {
var a = function a () {
if (this instanceof a) {
return Reflect.construct(f, arguments, this.constructor);
}
return f.apply(this, arguments);
};
a.prototype = f.prototype;
} else a = {};
Object.defineProperty(a, '__esModule', {value: true});
Object.keys(n).forEach(function (k) {
var d = Object.getOwnPropertyDescriptor(n, k);
Object.defineProperty(a, k, d.get ? d : {
enumerable: true,
get: function () {
return n[k];
}
});
});
return a;
}
var lib = {};
Object.defineProperty(lib, '__esModule', {
value: true
});
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
class Position {
constructor(line, col, index) {
this.line = void 0;
this.column = void 0;
this.index = void 0;
this.line = line;
this.column = col;
this.index = index;
}
}
class SourceLocation {
constructor(start, end) {
this.start = void 0;
this.end = void 0;
this.filename = void 0;
this.identifierName = void 0;
this.start = start;
this.end = end;
}
}
function createPositionWithColumnOffset(position, columnOffset) {
const {
line,
column,
index
} = position;
return new Position(line, column + columnOffset, index + columnOffset);
}
const code$3 = "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
var ModuleErrors = {
ImportMetaOutsideModule: {
message: `import.meta may appear only with 'sourceType: "module"'`,
code: code$3
},
ImportOutsideModule: {
message: `'import' and 'export' may appear only with 'sourceType: "module"'`,
code: code$3
}
};
const NodeDescriptions = {
ArrayPattern: "array destructuring pattern",
AssignmentExpression: "assignment expression",
AssignmentPattern: "assignment expression",
ArrowFunctionExpression: "arrow function expression",
ConditionalExpression: "conditional expression",
CatchClause: "catch clause",
ForOfStatement: "for-of statement",
ForInStatement: "for-in statement",
ForStatement: "for-loop",
FormalParameters: "function parameter list",
Identifier: "identifier",
ImportSpecifier: "import specifier",
ImportDefaultSpecifier: "import default specifier",
ImportNamespaceSpecifier: "import namespace specifier",
ObjectPattern: "object destructuring pattern",
ParenthesizedExpression: "parenthesized expression",
RestElement: "rest element",
UpdateExpression: {
true: "prefix operation",
false: "postfix operation"
},
VariableDeclarator: "variable declaration",
YieldExpression: "yield expression"
};
const toNodeDescription = ({
type,
prefix
}) => type === "UpdateExpression" ? NodeDescriptions.UpdateExpression[String(prefix)] : NodeDescriptions[type];
var StandardErrors = {
AccessorIsGenerator: ({
kind
}) => `A ${kind}ter cannot be a generator.`,
ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.",
AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
BadGetterArity: "A 'get' accessor must not have any formal parameters.",
BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
ConstructorClassField: "Classes may not have a field named 'constructor'.",
ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
ConstructorIsAccessor: "Class constructor may not be an accessor.",
ConstructorIsAsync: "Constructor can't be an async function.",
ConstructorIsGenerator: "Constructor can't be a generator.",
DeclarationMissingInitializer: ({
kind
}) => `Missing initializer in ${kind} declaration.`,
DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",
DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",
DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",
DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",
DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
DecoratorStaticBlock: "Decorators can't be used with a static block.",
DeferImportRequiresNamespace: 'Only `import defer * as x from "./module"` is valid.',
DeletePrivateField: "Deleting a private field is not allowed.",
DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
DuplicateConstructor: "Duplicate constructor in the same class.",
DuplicateDefaultExport: "Only one default export allowed per module.",
DuplicateExport: ({
exportName
}) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`,
DuplicateProto: "Redefinition of __proto__ property.",
DuplicateRegExpFlags: "Duplicate regular expression flag.",
DynamicImportPhaseRequiresImportExpressions: ({
phase
}) => `'import.${phase}(...)' can only be parsed when using the 'createImportExpressions' option.`,
ElementAfterRest: "Rest element must be last element.",
EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
ExportBindingIsString: ({
localName,
exportName
}) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
ForInOfLoopInitializer: ({
type
}) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
ForInUsing: "For-in loop may not start with 'using' declaration.",
ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
IllegalBreakContinue: ({
type
}) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`,
IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
IllegalReturn: "'return' outside of function.",
ImportAttributesUseAssert: "The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedAssertSyntax: true` option in the import attributes plugin to suppress this error.",
ImportBindingIsString: ({
importName
}) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments.",
ImportCallArity: ({
maxArgumentCount
}) => `\`import()\` requires exactly ${maxArgumentCount === 1 ? "one argument" : "one or two arguments"}.`,
ImportCallNotNewExpression: "Cannot use new with import(...).",
ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.",
ImportReflectionHasAssertion: "`import module x` cannot have assertions.",
ImportReflectionNotBinding: 'Only `import module x from "./module"` is valid.',
IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
InvalidBigIntLiteral: "Invalid BigIntLiteral.",
InvalidCodePoint: "Code point out of bounds.",
InvalidCoverInitializedName: "Invalid shorthand property initializer.",
InvalidDecimal: "Invalid decimal.",
InvalidDigit: ({
radix
}) => `Expected number in radix ${radix}.`,
InvalidEscapeSequence: "Bad character escape sequence.",
InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
InvalidEscapedReservedWord: ({
reservedWord
}) => `Escape sequence in keyword ${reservedWord}.`,
InvalidIdentifier: ({
identifierName
}) => `Invalid identifier ${identifierName}.`,
InvalidLhs: ({
ancestor
}) => `Invalid left-hand side in ${toNodeDescription(ancestor)}.`,
InvalidLhsBinding: ({
ancestor
}) => `Binding invalid left-hand side in ${toNodeDescription(ancestor)}.`,
InvalidLhsOptionalChaining: ({
ancestor
}) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`,
InvalidNumber: "Invalid number.",
InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
InvalidOrUnexpectedToken: ({
unexpected
}) => `Unexpected character '${unexpected}'.`,
InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
InvalidPrivateFieldResolution: ({
identifierName
}) => `Private name #${identifierName} is not defined.`,
InvalidPropertyBindingPattern: "Binding member expression.",
InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.",
InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
LabelRedeclaration: ({
labelName
}) => `Label '${labelName}' is already declared.`,
LetInLexicalBinding: "'let' is disallowed as a lexically bound name.",
LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
MalformedRegExpFlags: "Invalid regular expression flag.",
MissingClassName: "A class name is required.",
MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
MissingSemicolon: "Missing semicolon.",
MissingPlugin: ({
missingPlugin
}) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
MissingOneOfPlugins: ({
missingPlugin
}) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.",
ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
ModuleAttributesWithDuplicateKeys: ({
key
}) => `Duplicate key "${key}" is not allowed in module attributes.`,
ModuleExportNameHasLoneSurrogate: ({
surrogateCharCode
}) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`,
ModuleExportUndefined: ({
localName
}) => `Export '${localName}' is not defined.`,
MultipleDefaultsInSwitch: "Multiple default clauses.",
NewlineAfterThrow: "Illegal newline after throw.",
NoCatchOrFinally: "Missing catch or finally clause.",
NumberIdentifier: "Identifier directly after number.",
NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
ParamDupe: "Argument name clash.",
PatternHasAccessor: "Object pattern can't contain getter or setter.",
PatternHasMethod: "Object pattern can't contain methods.",
PrivateInExpectedIn: ({
identifierName
}) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`,
PrivateNameRedeclaration: ({
identifierName
}) => `Duplicate private name #${identifierName}.`,
RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
RecordNoProto: "'__proto__' is not allowed in Record expressions.",
RestTrailingComma: "Unexpected trailing comma after rest element.",
SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.",
SloppyFunctionAnnexB: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",
SourcePhaseImportRequiresDefault: 'Only `import source x from "./module"` is valid.',
StaticPrototype: "Classes may not have static property named prototype.",
SuperNotAllowed: "`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",
SuperPrivateField: "Private fields can't be accessed on super.",
TrailingDecorator: "Decorators must be attached to a class element.",
TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',
UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
UnexpectedKeyword: ({
keyword
}) => `Unexpected keyword '${keyword}'.`,
UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
UnexpectedPrivateField: "Unexpected private name.",
UnexpectedReservedWord: ({
reservedWord
}) => `Unexpected reserved word '${reservedWord}'.`,
UnexpectedSuper: "'super' is only allowed in object methods and classes.",
UnexpectedToken: ({
expected,
unexpected
}) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script`.",
UnsupportedBind: "Binding should be performed on object property.",
UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
UnsupportedMetaProperty: ({
target,
onlyValidPropertyName
}) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`,
UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
UnterminatedComment: "Unterminated comment.",
UnterminatedRegExp: "Unterminated regular expression.",
UnterminatedString: "Unterminated string constant.",
UnterminatedTemplate: "Unterminated template.",
UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.",
VarRedeclaration: ({
identifierName
}) => `Identifier '${identifierName}' has already been declared.`,
YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
YieldInParameter: "Yield expression is not allowed in formal parameters.",
ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
};
var StrictModeErrors = {
StrictDelete: "Deleting local variable in strict mode.",
StrictEvalArguments: ({
referenceName
}) => `Assigning to '${referenceName}' in strict mode.`,
StrictEvalArgumentsBinding: ({
bindingName
}) => `Binding '${bindingName}' in strict mode.`,
StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.",
StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.",
StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.",
StrictWith: "'with' in strict mode."
};
const UnparenthesizedPipeBodyDescriptions = new Set(["ArrowFunctionExpression", "AssignmentExpression", "ConditionalExpression", "YieldExpression"]);
var PipelineOperatorErrors = {
PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",
PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',
PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
PipeTopicUnconfiguredToken: ({
token
}) => `Invalid topic token ${token}. In order to use ${token} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${token}" }.`,
PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",
PipeUnparenthesizedBody: ({
type
}) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({
type
})}; please wrap it in parentheses.`,
PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',
PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.",
PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.",
PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.",
PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
};
const _excluded$1 = ["toMessage"],
_excluded2$1 = ["message"];
function defineHidden(obj, key, value) {
Object.defineProperty(obj, key, {
enumerable: false,
configurable: true,
value
});
}
function toParseErrorConstructor(_ref) {
let {
toMessage
} = _ref,
properties = _objectWithoutPropertiesLoose(_ref, _excluded$1);
return function constructor({
loc,
details
}) {
const error = new SyntaxError();
Object.assign(error, properties, {
loc,
pos: loc.index
});
if ("missingPlugin" in details) {
Object.assign(error, {
missingPlugin: details.missingPlugin
});
}
defineHidden(error, "clone", function clone(overrides = {}) {
var _overrides$loc;
const {
line,
column,
index
} = (_overrides$loc = overrides.loc) != null ? _overrides$loc : loc;
return constructor({
loc: new Position(line, column, index),
details: Object.assign({}, details, overrides.details)
});
});
defineHidden(error, "details", details);
Object.defineProperty(error, "message", {
configurable: true,
get() {
const message = `${toMessage(details)} (${loc.line}:${loc.column})`;
this.message = message;
return message;
},
set(value) {
Object.defineProperty(this, "message", {
value,
writable: true
});
}
});
return error;
};
}
function ParseErrorEnum(argument, syntaxPlugin) {
if (Array.isArray(argument)) {
return parseErrorTemplates => ParseErrorEnum(parseErrorTemplates, argument[0]);
}
const ParseErrorConstructors = {};
for (const reasonCode of Object.keys(argument)) {
const template = argument[reasonCode];
const _ref2 = typeof template === "string" ? {
message: () => template
} : typeof template === "function" ? {
message: template
} : template,
{
message
} = _ref2,
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
const toMessage = typeof message === "string" ? () => message : message;
ParseErrorConstructors[reasonCode] = toParseErrorConstructor(Object.assign({
code: "BABEL_PARSER_SYNTAX_ERROR",
reasonCode,
toMessage
}, syntaxPlugin ? {
syntaxPlugin
} : {}, rest));
}
return ParseErrorConstructors;
}
const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors));
const {
defineProperty
} = Object;
const toUnenumerable = (object, key) => defineProperty(object, key, {
enumerable: false,
value: object[key]
});
function toESTreeLocation(node) {
node.loc.start && toUnenumerable(node.loc.start, "index");
node.loc.end && toUnenumerable(node.loc.end, "index");
return node;
}
var estree = superClass => class ESTreeParserMixin extends superClass {
parse() {
const file = toESTreeLocation(super.parse());
if (this.options.tokens) {
file.tokens = file.token