@harlem/plugin-ssr
Version:
The official server-side rendering plugin for Harlem
1,370 lines (1,367 loc) • 560 kB
JavaScript
"use strict";
(() => {
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// ../../node_modules/@vue/shared/dist/shared.esm-bundler.js
var shared_esm_bundler_exports = {};
__export(shared_esm_bundler_exports, {
EMPTY_ARR: () => EMPTY_ARR,
EMPTY_OBJ: () => EMPTY_OBJ,
NO: () => NO,
NOOP: () => NOOP,
PatchFlagNames: () => PatchFlagNames,
camelize: () => camelize,
capitalize: () => capitalize,
def: () => def,
escapeHtml: () => escapeHtml,
escapeHtmlComment: () => escapeHtmlComment,
extend: () => extend,
genPropsAccessExp: () => genPropsAccessExp,
generateCodeFrame: () => generateCodeFrame,
getGlobalThis: () => getGlobalThis,
hasChanged: () => hasChanged,
hasOwn: () => hasOwn,
hyphenate: () => hyphenate,
includeBooleanAttr: () => includeBooleanAttr,
invokeArrayFns: () => invokeArrayFns,
isArray: () => isArray,
isBooleanAttr: () => isBooleanAttr,
isBuiltInDirective: () => isBuiltInDirective,
isDate: () => isDate,
isFunction: () => isFunction,
isGloballyWhitelisted: () => isGloballyWhitelisted,
isHTMLTag: () => isHTMLTag,
isIntegerKey: () => isIntegerKey,
isKnownHtmlAttr: () => isKnownHtmlAttr,
isKnownSvgAttr: () => isKnownSvgAttr,
isMap: () => isMap,
isModelListener: () => isModelListener,
isObject: () => isObject,
isOn: () => isOn,
isPlainObject: () => isPlainObject,
isPromise: () => isPromise,
isRegExp: () => isRegExp,
isReservedProp: () => isReservedProp,
isSSRSafeAttrName: () => isSSRSafeAttrName,
isSVGTag: () => isSVGTag,
isSet: () => isSet,
isSpecialBooleanAttr: () => isSpecialBooleanAttr,
isString: () => isString,
isSymbol: () => isSymbol,
isVoidTag: () => isVoidTag,
looseEqual: () => looseEqual,
looseIndexOf: () => looseIndexOf,
looseToNumber: () => looseToNumber,
makeMap: () => makeMap,
normalizeClass: () => normalizeClass,
normalizeProps: () => normalizeProps,
normalizeStyle: () => normalizeStyle,
objectToString: () => objectToString,
parseStringStyle: () => parseStringStyle,
propsToAttrMap: () => propsToAttrMap,
remove: () => remove,
slotFlagsText: () => slotFlagsText,
stringifyStyle: () => stringifyStyle,
toDisplayString: () => toDisplayString,
toHandlerKey: () => toHandlerKey,
toNumber: () => toNumber,
toRawType: () => toRawType,
toTypeString: () => toTypeString
});
function makeMap(str, expectsLowerCase) {
const map2 = /* @__PURE__ */ Object.create(null);
const list = str.split(",");
for (let i = 0; i < list.length; i++) {
map2[list[i]] = true;
}
return expectsLowerCase ? (val) => !!map2[val.toLowerCase()] : (val) => !!map2[val];
}
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");
}
function normalizeStyle(value) {
if (isArray(value)) {
const res = {};
for (let i = 0; i < value.length; i++) {
const item = value[i];
const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
if (normalized) {
for (const key in normalized) {
res[key] = normalized[key];
}
}
}
return res;
} else if (isString(value)) {
return value;
} else if (isObject(value)) {
return value;
}
}
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;
}
function stringifyStyle(styles) {
let ret = "";
if (!styles || isString(styles)) {
return ret;
}
for (const key in styles) {
const value = styles[key];
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
if (isString(value) || typeof value === "number") {
ret += `${normalizedKey}:${value};`;
}
}
return ret;
}
function normalizeClass(value) {
let res = "";
if (isString(value)) {
res = value;
} else if (isArray(value)) {
for (let i = 0; i < value.length; i++) {
const normalized = normalizeClass(value[i]);
if (normalized) {
res += normalized + " ";
}
}
} else if (isObject(value)) {
for (const name in value) {
if (value[name]) {
res += name + " ";
}
}
}
return res.trim();
}
function normalizeProps(props) {
if (!props)
return null;
let { class: klass, style } = props;
if (klass && !isString(klass)) {
props.class = normalizeClass(klass);
}
if (style) {
props.style = normalizeStyle(style);
}
return props;
}
function includeBooleanAttr(value) {
return !!value || value === "";
}
function isSSRSafeAttrName(name) {
if (attrValidationCache.hasOwnProperty(name)) {
return attrValidationCache[name];
}
const isUnsafe = unsafeAttrCharRE.test(name);
if (isUnsafe) {
console.error(`unsafe attribute name: ${name}`);
}
return attrValidationCache[name] = !isUnsafe;
}
function escapeHtml(string) {
const str = "" + string;
const match = escapeRE.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;
}
function escapeHtmlComment(src) {
return src.replace(commentStripRE, "");
}
function looseCompareArrays(a, b) {
if (a.length !== b.length)
return false;
let equal = true;
for (let i = 0; equal && i < a.length; i++) {
equal = looseEqual(a[i], b[i]);
}
return equal;
}
function looseEqual(a, b) {
if (a === b)
return true;
let aValidType = isDate(a);
let bValidType = isDate(b);
if (aValidType || bValidType) {
return aValidType && bValidType ? a.getTime() === b.getTime() : false;
}
aValidType = isSymbol(a);
bValidType = isSymbol(b);
if (aValidType || bValidType) {
return a === b;
}
aValidType = isArray(a);
bValidType = isArray(b);
if (aValidType || bValidType) {
return aValidType && bValidType ? looseCompareArrays(a, b) : false;
}
aValidType = isObject(a);
bValidType = isObject(b);
if (aValidType || bValidType) {
if (!aValidType || !bValidType) {
return false;
}
const aKeysCount = Object.keys(a).length;
const bKeysCount = Object.keys(b).length;
if (aKeysCount !== bKeysCount) {
return false;
}
for (const key in a) {
const aHasKey = a.hasOwnProperty(key);
const bHasKey = b.hasOwnProperty(key);
if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
return false;
}
}
}
return String(a) === String(b);
}
function looseIndexOf(arr, val) {
return arr.findIndex((item) => looseEqual(item, val));
}
function genPropsAccessExp(name) {
return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
}
var PatchFlagNames, slotFlagsText, GLOBALS_WHITE_LISTED, isGloballyWhitelisted, range, listDelimiterRE, propertyDelimiterRE, styleCommentRE, HTML_TAGS, SVG_TAGS, VOID_TAGS, isHTMLTag, isSVGTag, isVoidTag, specialBooleanAttrs, isSpecialBooleanAttr, isBooleanAttr, unsafeAttrCharRE, attrValidationCache, propsToAttrMap, isKnownHtmlAttr, isKnownSvgAttr, escapeRE, commentStripRE, toDisplayString, replacer, EMPTY_OBJ, EMPTY_ARR, NOOP, NO, onRE, isOn, isModelListener, extend, remove, hasOwnProperty, hasOwn, isArray, isMap, isSet, isDate, isRegExp, isFunction, isString, isSymbol, isObject, isPromise, objectToString, toTypeString, toRawType, isPlainObject, isIntegerKey, isReservedProp, isBuiltInDirective, cacheStringFunction, camelizeRE, camelize, hyphenateRE, hyphenate, capitalize, toHandlerKey, hasChanged, invokeArrayFns, def, looseToNumber, toNumber, _globalThis, getGlobalThis, identRE;
var init_shared_esm_bundler = __esm({
"../../node_modules/@vue/shared/dist/shared.esm-bundler.js"() {
PatchFlagNames = {
[
1
/* PatchFlags.TEXT */
]: `TEXT`,
[
2
/* PatchFlags.CLASS */
]: `CLASS`,
[
4
/* PatchFlags.STYLE */
]: `STYLE`,
[
8
/* PatchFlags.PROPS */
]: `PROPS`,
[
16
/* PatchFlags.FULL_PROPS */
]: `FULL_PROPS`,
[
32
/* PatchFlags.HYDRATE_EVENTS */
]: `HYDRATE_EVENTS`,
[
64
/* PatchFlags.STABLE_FRAGMENT */
]: `STABLE_FRAGMENT`,
[
128
/* PatchFlags.KEYED_FRAGMENT */
]: `KEYED_FRAGMENT`,
[
256
/* PatchFlags.UNKEYED_FRAGMENT */
]: `UNKEYED_FRAGMENT`,
[
512
/* PatchFlags.NEED_PATCH */
]: `NEED_PATCH`,
[
1024
/* PatchFlags.DYNAMIC_SLOTS */
]: `DYNAMIC_SLOTS`,
[
2048
/* PatchFlags.DEV_ROOT_FRAGMENT */
]: `DEV_ROOT_FRAGMENT`,
[
-1
/* PatchFlags.HOISTED */
]: `HOISTED`,
[
-2
/* PatchFlags.BAIL */
]: `BAIL`
};
slotFlagsText = {
[
1
/* SlotFlags.STABLE */
]: "STABLE",
[
2
/* SlotFlags.DYNAMIC */
]: "DYNAMIC",
[
3
/* SlotFlags.FORWARDED */
]: "FORWARDED"
};
GLOBALS_WHITE_LISTED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt";
isGloballyWhitelisted = /* @__PURE__ */ makeMap(GLOBALS_WHITE_LISTED);
range = 2;
listDelimiterRE = /;(?![^(]*\))/g;
propertyDelimiterRE = /:([^]+)/;
styleCommentRE = /\/\*.*?\*\//gs;
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";
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";
VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
attrValidationCache = {};
propsToAttrMap = {
acceptCharset: "accept-charset",
className: "class",
htmlFor: "for",
httpEquiv: "http-equiv"
};
isKnownHtmlAttr = /* @__PURE__ */ makeMap(`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,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`);
isKnownSvgAttr = /* @__PURE__ */ makeMap(`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`);
escapeRE = /["'&<>]/;
commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
toDisplayString = (val) => {
return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
};
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(val) && !isArray(val) && !isPlainObject(val)) {
return String(val);
}
return val;
};
EMPTY_OBJ = process.env.NODE_ENV !== "production" ? Object.freeze({}) : {};
EMPTY_ARR = process.env.NODE_ENV !== "production" ? Object.freeze([]) : [];
NOOP = () => {
};
NO = () => false;
onRE = /^on[^a-z]/;
isOn = (key) => onRE.test(key);
isModelListener = (key) => key.startsWith("onUpdate:");
extend = Object.assign;
remove = (arr, el) => {
const i = arr.indexOf(el);
if (i > -1) {
arr.splice(i, 1);
}
};
hasOwnProperty = Object.prototype.hasOwnProperty;
hasOwn = (val, key) => hasOwnProperty.call(val, key);
isArray = Array.isArray;
isMap = (val) => toTypeString(val) === "[object Map]";
isSet = (val) => toTypeString(val) === "[object Set]";
isDate = (val) => toTypeString(val) === "[object Date]";
isRegExp = (val) => toTypeString(val) === "[object RegExp]";
isFunction = (val) => typeof val === "function";
isString = (val) => typeof val === "string";
isSymbol = (val) => typeof val === "symbol";
isObject = (val) => val !== null && typeof val === "object";
isPromise = (val) => {
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
};
objectToString = Object.prototype.toString;
toTypeString = (value) => objectToString.call(value);
toRawType = (value) => {
return toTypeString(value).slice(8, -1);
};
isPlainObject = (val) => toTypeString(val) === "[object Object]";
isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
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"
);
isBuiltInDirective = /* @__PURE__ */ makeMap("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo");
cacheStringFunction = (fn) => {
const cache = /* @__PURE__ */ Object.create(null);
return (str) => {
const hit = cache[str];
return hit || (cache[str] = fn(str));
};
};
camelizeRE = /-(\w)/g;
camelize = cacheStringFunction((str) => {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
});
hyphenateRE = /\B([A-Z])/g;
hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
hasChanged = (value, oldValue) => !Object.is(value, oldValue);
invokeArrayFns = (fns, arg) => {
for (let i = 0; i < fns.length; i++) {
fns[i](arg);
}
};
def = (obj, key, value) => {
Object.defineProperty(obj, key, {
configurable: true,
enumerable: false,
value
});
};
looseToNumber = (val) => {
const n = parseFloat(val);
return isNaN(n) ? val : n;
};
toNumber = (val) => {
const n = isString(val) ? Number(val) : NaN;
return isNaN(n) ? val : n;
};
getGlobalThis = () => {
return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
};
identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
}
});
// ../../node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js
function defaultOnError(error) {
throw error;
}
function defaultOnWarn(msg) {
process.env.NODE_ENV !== "production" && console.warn(`[Vue warn] ${msg.message}`);
}
function createCompilerError(code, loc, messages, additionalMessage) {
const msg = process.env.NODE_ENV !== "production" || false ? (messages || errorMessages)[code] + (additionalMessage || ``) : code;
const error = new SyntaxError(String(msg));
error.code = code;
error.loc = loc;
return error;
}
function registerRuntimeHelpers(helpers) {
Object.getOwnPropertySymbols(helpers).forEach((s) => {
helperNameMap[s] = helpers[s];
});
}
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, isComponent2 = false, loc = locStub) {
if (context) {
if (isBlock) {
context.helper(OPEN_BLOCK);
context.helper(getVNodeBlockHelper(context.inSSR, isComponent2));
} else {
context.helper(getVNodeHelper(context.inSSR, isComponent2));
}
if (directives) {
context.helper(WITH_DIRECTIVES);
}
}
return {
type: 13,
tag,
props,
children,
patchFlag,
dynamicProps,
directives,
isBlock,
disableTracking,
isComponent: isComponent2,
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, isVNode2 = false) {
return {
type: 20,
index,
value,
isVNode: isVNode2,
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 isCoreComponent(tag) {
if (isBuiltInType(tag, "Teleport")) {
return TELEPORT;
} else if (isBuiltInType(tag, "Suspense")) {
return SUSPENSE;
} else if (isBuiltInType(tag, "KeepAlive")) {
return KEEP_ALIVE;
} else if (isBuiltInType(tag, "BaseTransition")) {
return BASE_TRANSITION;
}
}
function getInnerRange(loc, offset, length) {
const source = loc.source.slice(offset, offset + length);
const newLoc = {
source,
start: advancePositionWithClone(loc.start, loc.source, offset),
end: loc.end
};
if (length != null) {
newLoc.end = advancePositionWithClone(loc.start, loc.source, offset + length);
}
return newLoc;
}
function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
return advancePositionWithMutation(extend({}, pos), source, numberOfCharacters);
}
function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
let linesCount = 0;
let lastNewLinePos = -1;
for (let i = 0; i < numberOfCharacters; i++) {
if (source.charCodeAt(i) === 10) {
linesCount++;
lastNewLinePos = i;
}
}
pos.offset += numberOfCharacters;
pos.line += linesCount;
pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
return pos;
}
function assert(condition, msg) {
if (!condition) {
throw new Error(msg || `unexpected compiler condition`);
}
}
function findDir(node, name, allowEmpty = false) {
for (let i = 0; i < node.props.length; i++) {
const p2 = node.props[i];
if (p2.type === 7 && (allowEmpty || p2.exp) && (isString(name) ? p2.name === name : name.test(p2.name))) {
return p2;
}
}
}
function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
for (let i = 0; i < node.props.length; i++) {
const p2 = node.props[i];
if (p2.type === 6) {
if (dynamicOnly)
continue;
if (p2.name === name && (p2.value || allowEmpty)) {
return p2;
}
} else if (p2.name === "bind" && (p2.exp || allowEmpty) && isStaticArgOf(p2.arg, name)) {
return p2;
}
}
}
function isStaticArgOf(arg, name) {
return !!(arg && isStaticExp(arg) && arg.content === name);
}
function hasDynamicKeyVBind(node) {
return node.props.some(
(p2) => p2.type === 7 && p2.name === "bind" && (!p2.arg || // v-bind="obj"
p2.arg.type !== 4 || // v-bind:[_ctx.foo]
!p2.arg.isStatic)
// v-bind:[foo]
);
}
function isText$1(node) {
return node.type === 5 || node.type === 2;
}
function isVSlot(p2) {
return p2.type === 7 && p2.name === "slot";
}
function isTemplateNode(node) {
return node.type === 1 && node.tagType === 3;
}
function isSlotOutlet(node) {
return node.type === 1 && node.tagType === 2;
}
function getVNodeHelper(ssr, isComponent2) {
return ssr || isComponent2 ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
}
function getVNodeBlockHelper(ssr, isComponent2) {
return ssr || isComponent2 ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
}
function getUnnormalizedProps(props, callPath = []) {
if (props && !isString(props) && props.type === 14) {
const callee = props.callee;
if (!isString(callee) && propsHelperSet.has(callee)) {
return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
}
}
return [props, callPath];
}
function injectProp(node, prop, context) {
let propsWithInjection;
let props = node.type === 13 ? node.props : node.arguments[2];
let callPath = [];
let parentCall;
if (props && !isString(props) && props.type === 14) {
const ret = getUnnormalizedProps(props);
props = ret[0];
callPath = ret[1];
parentCall = callPath[callPath.length - 1];
}
if (props == null || isString(props)) {
propsWithInjection = createObjectExpression([prop]);
} else if (props.type === 14) {
const first = props.arguments[0];
if (!isString(first) && first.type === 15) {
if (!hasProp(prop, first)) {
first.properties.unshift(prop);
}
} else {
if (props.callee === TO_HANDLERS) {
propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
createObjectExpression([prop]),
props
]);
} else {
props.arguments.unshift(createObjectExpression([prop]));
}
}
!propsWithInjection && (propsWithInjection = props);
} else if (props.type === 15) {
if (!hasProp(prop, props)) {
props.properties.unshift(prop);
}
propsWithInjection = props;
} else {
propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
createObjectExpression([prop]),
props
]);
if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
parentCall = callPath[callPath.length - 2];
}
}
if (node.type === 13) {
if (parentCall) {
parentCall.arguments[0] = propsWithInjection;
} else {
node.props = propsWithInjection;
}
} else {
if (parentCall) {
parentCall.arguments[0] = propsWithInjection;
} else {
node.arguments[2] = propsWithInjection;
}
}
}
function hasProp(prop, props) {
let result = false;
if (prop.key.type === 4) {
const propKeyName = prop.key.content;
result = props.properties.some((p2) => p2.key.type === 4 && p2.key.content === propKeyName);
}
return result;
}
function toValidAssetId(name, type) {
return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
})}`;
}
function hasScopeRef(node, ids) {
if (!node || Object.keys(ids).length === 0) {
return false;
}
switch (node.type) {
case 1:
for (let i = 0; i < node.props.length; i++) {
const p2 = node.props[i];
if (p2.type === 7 && (hasScopeRef(p2.arg, ids) || hasScopeRef(p2.exp, ids))) {
return true;
}
}
return node.children.some((c) => hasScopeRef(c, ids));
case 11:
if (hasScopeRef(node.source, ids)) {
return true;
}
return node.children.some((c) => hasScopeRef(c, ids));
case 9:
return node.branches.some((b) => hasScopeRef(b, ids));
case 10:
if (hasScopeRef(node.condition, ids)) {
return true;
}
return node.children.some((c) => hasScopeRef(c, ids));
case 4:
return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
case 8:
return node.children.some((c) => isObject(c) && hasScopeRef(c, ids));
case 5:
case 12:
return hasScopeRef(node.content, ids);
case 2:
case 3:
return false;
default:
if (process.env.NODE_ENV !== "production")
;
return false;
}
}
function getMemoedVNodeCall(node) {
if (node.type === 14 && node.callee === WITH_MEMO) {
return node.arguments[1].returns;
} else {
return node;
}
}
function makeBlock(node, { helper, removeHelper, inSSR }) {
if (!node.isBlock) {
node.isBlock = true;
removeHelper(getVNodeHelper(inSSR, node.isComponent));
helper(OPEN_BLOCK);
helper(getVNodeBlockHelper(inSSR, node.isComponent));
}
}
function getCompatValue(key, context) {
const config = context.options ? context.options.compatConfig : context.compatConfig;
const value = config && config[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 (process.env.NODE_ENV !== "production" && 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 baseParse(content, options = {}) {
const context = createParserContext(content, options);
const start = getCursor(context);
return createRoot(parseChildren(context, 0, []), getSelection(context, start));
}
function createParserContext(content, rawOptions) {
const options = extend({}, defaultParserOptions);
let key;
for (key in rawOptions) {
options[key] = rawOptions[key] === void 0 ? defaultParserOptions[key] : rawOptions[key];
}
return {
options,
column: 1,
line: 1,
offset: 0,
originalSource: content,
source: content,
inPre: false,
inVPre: false,
onWarn: options.onWarn
};
}
function parseChildren(context, mode, ancestors) {
const parent = last(ancestors);
const ns = parent ? parent.ns : 0;
const nodes = [];
while (!isEnd(context, mode, ancestors)) {
const s = context.source;
let node = void 0;
if (mode === 0 || mode === 1) {
if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
node = parseInterpolation(context, mode);
} else if (mode === 0 && s[0] === "<") {
if (s.length === 1) {
emitError(context, 5, 1);
} else if (s[1] === "!") {
if (startsWith(s, "<!--")) {
node = parseComment(context);
} else if (startsWith(s, "<!DOCTYPE")) {
node = parseBogusComment(context);
} else if (startsWith(s, "<![CDATA[")) {
if (ns !== 0) {
node = parseCDATA(context, ancestors);
} else {
emitError(
context,
1
/* ErrorCodes.CDATA_IN_HTML_CONTENT */
);
node = parseBogusComment(context);
}
} else {
emitError(
context,
11
/* ErrorCodes.INCORRECTLY_OPENED_COMMENT */
);
node = parseBogusComment(context);
}
} else if (s[1] === "/") {
if (s.length === 2) {
emitError(context, 5, 2);
} else if (s[2] === ">") {
emitError(context, 14, 2);
advanceBy(context, 3);
continue;
} else if (/[a-z]/i.test(s[2])) {
emitError(
context,
23
/* ErrorCodes.X_INVALID_END_TAG */
);
parseTag(context, 1, parent);
continue;
} else {
emitError(context, 12, 2);
node = parseBogusComment(context);
}
} else if (/[a-z]/i.test(s[1])) {
node = parseElement(context, ancestors);
if (isCompatEnabled("COMPILER_NATIVE_TEMPLATE", context) && node && node.tag === "template" && !node.props.some((p2) => p2.type === 7 && isSpecialTemplateDirective(p2.name))) {
process.env.NODE_ENV !== "production" && warnDeprecation("COMPILER_NATIVE_TEMPLATE", context, node.loc);
node = node.children;
}
} else if (s[1] === "?") {
emitError(context, 21, 1);
node = parseBogusComment(context);
} else {
emitError(context, 12, 1);
}
}
}
if (!node) {
node = parseText(context, mode);
}
if (isArray(node)) {
for (let i = 0; i < node.length; i++) {
pushNode(nodes, node[i]);
}
} else {
pushNode(nodes, node);
}
}
let removedWhitespace = false;
if (mode !== 2 && mode !== 1) {
const shouldCondense = context.options.whitespace !== "preserve";
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
if (node.type === 2) {
if (!context.inPre) {
if (!/[^\t\r\n\f ]/.test(node.content)) {
const prev = nodes[i - 1];
const next = nodes[i + 1];
if (!prev || !next || shouldCondense && (prev.type === 3 && next.type === 3 || prev.type === 3 && next.type === 1 || prev.type === 1 && next.type === 3 || prev.type === 1 && next.type === 1 && /[\r\n]/.test(node.content))) {
removedWhitespace = true;
nodes[i] = null;
} else {
node.content = " ";
}
} else if (shouldCondense) {
node.content = node.content.replace(/[\t\r\n\f ]+/g, " ");
}
} else {
node.content = node.content.replace(/\r\n/g, "\n");
}
} else if (node.type === 3 && !context.options.comments) {
removedWhitespace = true;
nodes[i] = null;
}
}
if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
const first = nodes[0];
if (first && first.type === 2) {
first.content = first.content.replace(/^\r?\n/, "");
}
}
}
return removedWhitespace ? nodes.filter(Boolean) : nodes;
}
function pushNode(nodes, node) {
if (node.type === 2) {
const prev = last(nodes);
if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
prev.content += node.content;
prev.loc.end = node.loc.end;
prev.loc.source += node.loc.source;
return;
}
}
nodes.push(node);
}
function parseCDATA(context, ancestors) {
advanceBy(context, 9);
const nodes = parseChildren(context, 3, ancestors);
if (context.source.length === 0) {
emitError(
context,
6
/* ErrorCodes.EOF_IN_CDATA */
);
} else {
advanceBy(context, 3);
}
return nodes;
}
function parseComment(context) {
const start = getCursor(context);
let content;
const match = /--(\!)?>/.exec(context.source);
if (!match) {
content = context.source.slice(4);
advanceBy(context, context.source.length);
emitError(
context,
7
/* ErrorCodes.EOF_IN_COMMENT */
);
} else {
if (match.index <= 3) {
emitError(
context,
0
/* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */
);
}
if (match[1]) {
emitError(
context,
10
/* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */
);
}
content = context.source.slice(4, match.index);
const s = context.source.slice(0, match.index);
let prevIndex = 1, nestedIndex = 0;
while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
advanceBy(context, nestedIndex - prevIndex + 1);
if (nestedIndex + 4 < s.length) {
emitError(
context,
16
/* ErrorCodes.NESTED_COMMENT */
);
}
prevIndex = nestedIndex + 1;
}
advanceBy(context, match.index + match[0].length - prevIndex + 1);
}
return {
type: 3,
content,
loc: getSelection(context, start)
};
}
function parseBogusComment(context) {
const start = getCursor(context);
const contentStart = context.source[1] === "?" ? 1 : 2;
let content;
const closeIndex = context.source.indexOf(">");
if (closeIndex === -1) {
content = context.source.slice(contentStart);
advanceBy(context, context.source.length);
} else {
content = context.source.slice(contentStart, closeIndex);
advanceBy(context, closeIndex + 1);
}
return {
type: 3,
content,
loc: getSelection(context, start)
};
}
function parseElement(context, ancestors) {
const wasInPre = context.inPre;
const wasInVPre = context.inVPre;
const parent = last(ancestors);
const element = parseTag(context, 0, parent);
const isPreBoundary = context.inPre && !wasInPre;
const isVPreBoundary = context.inVPre && !wasInVPre;
if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
if (isPreBoundary) {
context.inPre = false;
}
if (isVPreBoundary) {
context.inVPre = false;
}
return element;
}
ancestors.push(element);
const mode = context.options.getTextMode(element, parent);
const children = parseChildren(context, mode, ancestors);
ancestors.pop();
{
const inlineTemplateProp = element.props.find((p2) => p2.type === 6 && p2.name === "inline-template");
if (inlineTemplateProp && checkCompatEnabled("COMPILER_INLINE_TEMPLATE", context, inlineTemplateProp.loc)) {
const loc = getSelection(context, element.loc.end);
inlineTemplateProp.value = {
type: 2,
content: loc.source,
loc
};
}
}
element.children = children;
if (startsWithEndTagOpen(context.source, element.tag)) {
parseTag(context, 1, parent);
} else {
emitError(context, 24, 0, element.loc.start);
if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
const first = children[0];
if (first && startsWith(first.loc.source, "<!--")) {
emitError(
context,
8
/* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */
);
}
}
}
element.loc = getSelection(context, element.loc.start);
if (isPreBoundary) {
context.inPre = false;
}
if (isVPreBoundary) {
context.inVPre = false;
}
return element;
}
function parseTag(context, type, parent) {
const start = getCursor(context);
const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
const tag = match[1];
const ns = context.options.getNamespace(tag, parent);
advanceBy(context, match[0].length);
advanceSpaces(context);
const cursor = getCursor(context);
const currentSource = context.source;
if (context.options.isPreTag(tag)) {
context.inPre = true;
}
let props = parseAttributes(context, type);
if (type === 0 && !context.inVPre && props.some((p2) => p2.type === 7 && p2.name === "pre")) {
context.inVPre = true;
extend(context, cursor);
context.source = currentSource;
props = parseAttributes(context, type).filter((p2) => p2.name !== "v-pre");
}
let isSelfClosing = false;
if (context.source.length === 0) {
emitError(
context,
9
/* ErrorCodes.EOF_IN_TAG */
);
} else {
isSelfClosing = startsWith(context.source, "/>");
if (type === 1 && isSelfClosing) {
emitError(
context,
4
/* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */
);
}
advanceBy(context, isSelfClosing ? 2 : 1);
}
if (type === 1) {
return;
}
if (process.env.NODE_ENV !== "production" && isCompatEnabled("COMPILER_V_IF_V_FOR_PRECEDENCE", context)) {
let hasIf = false;
let hasFor = false;
for (let i = 0; i < props.length; i++) {
const p2 = props[i];
if (p2.type === 7) {
if (p2.name === "if") {
hasIf = true;
} else if (p2.name === "for") {
hasFor = true;
}
}
if (hasIf && hasFor) {
warnDeprecation("COMPILER_V_IF_V_FOR_PRECEDENCE", context, getSelection(context, start));
break;
}
}
}
let tagType = 0;
if (!context.inVPre) {
if (tag === "slot") {
tagType = 2;
} else if (tag === "template") {
if (props.some((p2) => p2.type === 7 && isSpecialTemplateDirective(p2.name))) {
tagType = 3;
}
} else if (isComponent(tag, props, context)) {
tagType = 1;
}
}
return {
type: 1,
ns,
tag,
tagType,
props,
isSelfClosing,
children: [],
loc: getSelection(context, start),
codegenNode: void 0
// to be created during transform phase
};
}
function isComponent(tag, props, context) {
const options = context.options;
if (options.isCustomElement(tag)) {
return false;
}
if (tag === "component" || /^[A-Z]/.test(tag) || isCoreComponent(tag) || options.isBuiltInComponent && options.isBuiltInComponent(tag) || options.isNativeTag && !options.isNativeTag(tag)) {
return true;
}