shared.cjs.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. /**
  2. * @vue/shared v3.5.12
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. 'use strict';
  7. Object.defineProperty(exports, '__esModule', { value: true });
  8. /*! #__NO_SIDE_EFFECTS__ */
  9. // @__NO_SIDE_EFFECTS__
  10. function makeMap(str) {
  11. const map = /* @__PURE__ */ Object.create(null);
  12. for (const key of str.split(",")) map[key] = 1;
  13. return (val) => val in map;
  14. }
  15. const EMPTY_OBJ = Object.freeze({}) ;
  16. const EMPTY_ARR = Object.freeze([]) ;
  17. const NOOP = () => {
  18. };
  19. const NO = () => false;
  20. const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
  21. (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
  22. const isModelListener = (key) => key.startsWith("onUpdate:");
  23. const extend = Object.assign;
  24. const remove = (arr, el) => {
  25. const i = arr.indexOf(el);
  26. if (i > -1) {
  27. arr.splice(i, 1);
  28. }
  29. };
  30. const hasOwnProperty = Object.prototype.hasOwnProperty;
  31. const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  32. const isArray = Array.isArray;
  33. const isMap = (val) => toTypeString(val) === "[object Map]";
  34. const isSet = (val) => toTypeString(val) === "[object Set]";
  35. const isDate = (val) => toTypeString(val) === "[object Date]";
  36. const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
  37. const isFunction = (val) => typeof val === "function";
  38. const isString = (val) => typeof val === "string";
  39. const isSymbol = (val) => typeof val === "symbol";
  40. const isObject = (val) => val !== null && typeof val === "object";
  41. const isPromise = (val) => {
  42. return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
  43. };
  44. const objectToString = Object.prototype.toString;
  45. const toTypeString = (value) => objectToString.call(value);
  46. const toRawType = (value) => {
  47. return toTypeString(value).slice(8, -1);
  48. };
  49. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  50. const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
  51. const isReservedProp = /* @__PURE__ */ makeMap(
  52. // the leading comma is intentional so empty string "" is also included
  53. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  54. );
  55. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  56. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  57. );
  58. const cacheStringFunction = (fn) => {
  59. const cache = /* @__PURE__ */ Object.create(null);
  60. return (str) => {
  61. const hit = cache[str];
  62. return hit || (cache[str] = fn(str));
  63. };
  64. };
  65. const camelizeRE = /-(\w)/g;
  66. const camelize = cacheStringFunction(
  67. (str) => {
  68. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  69. }
  70. );
  71. const hyphenateRE = /\B([A-Z])/g;
  72. const hyphenate = cacheStringFunction(
  73. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  74. );
  75. const capitalize = cacheStringFunction((str) => {
  76. return str.charAt(0).toUpperCase() + str.slice(1);
  77. });
  78. const toHandlerKey = cacheStringFunction(
  79. (str) => {
  80. const s = str ? `on${capitalize(str)}` : ``;
  81. return s;
  82. }
  83. );
  84. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  85. const invokeArrayFns = (fns, ...arg) => {
  86. for (let i = 0; i < fns.length; i++) {
  87. fns[i](...arg);
  88. }
  89. };
  90. const def = (obj, key, value, writable = false) => {
  91. Object.defineProperty(obj, key, {
  92. configurable: true,
  93. enumerable: false,
  94. writable,
  95. value
  96. });
  97. };
  98. const looseToNumber = (val) => {
  99. const n = parseFloat(val);
  100. return isNaN(n) ? val : n;
  101. };
  102. const toNumber = (val) => {
  103. const n = isString(val) ? Number(val) : NaN;
  104. return isNaN(n) ? val : n;
  105. };
  106. let _globalThis;
  107. const getGlobalThis = () => {
  108. return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
  109. };
  110. const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
  111. function genPropsAccessExp(name) {
  112. return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
  113. }
  114. function genCacheKey(source, options) {
  115. return source + JSON.stringify(
  116. options,
  117. (_, val) => typeof val === "function" ? val.toString() : val
  118. );
  119. }
  120. const PatchFlags = {
  121. "TEXT": 1,
  122. "1": "TEXT",
  123. "CLASS": 2,
  124. "2": "CLASS",
  125. "STYLE": 4,
  126. "4": "STYLE",
  127. "PROPS": 8,
  128. "8": "PROPS",
  129. "FULL_PROPS": 16,
  130. "16": "FULL_PROPS",
  131. "NEED_HYDRATION": 32,
  132. "32": "NEED_HYDRATION",
  133. "STABLE_FRAGMENT": 64,
  134. "64": "STABLE_FRAGMENT",
  135. "KEYED_FRAGMENT": 128,
  136. "128": "KEYED_FRAGMENT",
  137. "UNKEYED_FRAGMENT": 256,
  138. "256": "UNKEYED_FRAGMENT",
  139. "NEED_PATCH": 512,
  140. "512": "NEED_PATCH",
  141. "DYNAMIC_SLOTS": 1024,
  142. "1024": "DYNAMIC_SLOTS",
  143. "DEV_ROOT_FRAGMENT": 2048,
  144. "2048": "DEV_ROOT_FRAGMENT",
  145. "CACHED": -1,
  146. "-1": "CACHED",
  147. "BAIL": -2,
  148. "-2": "BAIL"
  149. };
  150. const PatchFlagNames = {
  151. [1]: `TEXT`,
  152. [2]: `CLASS`,
  153. [4]: `STYLE`,
  154. [8]: `PROPS`,
  155. [16]: `FULL_PROPS`,
  156. [32]: `NEED_HYDRATION`,
  157. [64]: `STABLE_FRAGMENT`,
  158. [128]: `KEYED_FRAGMENT`,
  159. [256]: `UNKEYED_FRAGMENT`,
  160. [512]: `NEED_PATCH`,
  161. [1024]: `DYNAMIC_SLOTS`,
  162. [2048]: `DEV_ROOT_FRAGMENT`,
  163. [-1]: `HOISTED`,
  164. [-2]: `BAIL`
  165. };
  166. const ShapeFlags = {
  167. "ELEMENT": 1,
  168. "1": "ELEMENT",
  169. "FUNCTIONAL_COMPONENT": 2,
  170. "2": "FUNCTIONAL_COMPONENT",
  171. "STATEFUL_COMPONENT": 4,
  172. "4": "STATEFUL_COMPONENT",
  173. "TEXT_CHILDREN": 8,
  174. "8": "TEXT_CHILDREN",
  175. "ARRAY_CHILDREN": 16,
  176. "16": "ARRAY_CHILDREN",
  177. "SLOTS_CHILDREN": 32,
  178. "32": "SLOTS_CHILDREN",
  179. "TELEPORT": 64,
  180. "64": "TELEPORT",
  181. "SUSPENSE": 128,
  182. "128": "SUSPENSE",
  183. "COMPONENT_SHOULD_KEEP_ALIVE": 256,
  184. "256": "COMPONENT_SHOULD_KEEP_ALIVE",
  185. "COMPONENT_KEPT_ALIVE": 512,
  186. "512": "COMPONENT_KEPT_ALIVE",
  187. "COMPONENT": 6,
  188. "6": "COMPONENT"
  189. };
  190. const SlotFlags = {
  191. "STABLE": 1,
  192. "1": "STABLE",
  193. "DYNAMIC": 2,
  194. "2": "DYNAMIC",
  195. "FORWARDED": 3,
  196. "3": "FORWARDED"
  197. };
  198. const slotFlagsText = {
  199. [1]: "STABLE",
  200. [2]: "DYNAMIC",
  201. [3]: "FORWARDED"
  202. };
  203. 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,Error,Symbol";
  204. const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
  205. const isGloballyWhitelisted = isGloballyAllowed;
  206. const range = 2;
  207. function generateCodeFrame(source, start = 0, end = source.length) {
  208. start = Math.max(0, Math.min(start, source.length));
  209. end = Math.max(0, Math.min(end, source.length));
  210. if (start > end) return "";
  211. let lines = source.split(/(\r?\n)/);
  212. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  213. lines = lines.filter((_, idx) => idx % 2 === 0);
  214. let count = 0;
  215. const res = [];
  216. for (let i = 0; i < lines.length; i++) {
  217. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  218. if (count >= start) {
  219. for (let j = i - range; j <= i + range || end > count; j++) {
  220. if (j < 0 || j >= lines.length) continue;
  221. const line = j + 1;
  222. res.push(
  223. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  224. );
  225. const lineLength = lines[j].length;
  226. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  227. if (j === i) {
  228. const pad = start - (count - (lineLength + newLineSeqLength));
  229. const length = Math.max(
  230. 1,
  231. end > count ? lineLength - pad : end - start
  232. );
  233. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  234. } else if (j > i) {
  235. if (end > count) {
  236. const length = Math.max(Math.min(end - count, lineLength), 1);
  237. res.push(` | ` + "^".repeat(length));
  238. }
  239. count += lineLength + newLineSeqLength;
  240. }
  241. }
  242. break;
  243. }
  244. }
  245. return res.join("\n");
  246. }
  247. function normalizeStyle(value) {
  248. if (isArray(value)) {
  249. const res = {};
  250. for (let i = 0; i < value.length; i++) {
  251. const item = value[i];
  252. const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
  253. if (normalized) {
  254. for (const key in normalized) {
  255. res[key] = normalized[key];
  256. }
  257. }
  258. }
  259. return res;
  260. } else if (isString(value) || isObject(value)) {
  261. return value;
  262. }
  263. }
  264. const listDelimiterRE = /;(?![^(]*\))/g;
  265. const propertyDelimiterRE = /:([^]+)/;
  266. const styleCommentRE = /\/\*[^]*?\*\//g;
  267. function parseStringStyle(cssText) {
  268. const ret = {};
  269. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  270. if (item) {
  271. const tmp = item.split(propertyDelimiterRE);
  272. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  273. }
  274. });
  275. return ret;
  276. }
  277. function stringifyStyle(styles) {
  278. let ret = "";
  279. if (!styles || isString(styles)) {
  280. return ret;
  281. }
  282. for (const key in styles) {
  283. const value = styles[key];
  284. if (isString(value) || typeof value === "number") {
  285. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
  286. ret += `${normalizedKey}:${value};`;
  287. }
  288. }
  289. return ret;
  290. }
  291. function normalizeClass(value) {
  292. let res = "";
  293. if (isString(value)) {
  294. res = value;
  295. } else if (isArray(value)) {
  296. for (let i = 0; i < value.length; i++) {
  297. const normalized = normalizeClass(value[i]);
  298. if (normalized) {
  299. res += normalized + " ";
  300. }
  301. }
  302. } else if (isObject(value)) {
  303. for (const name in value) {
  304. if (value[name]) {
  305. res += name + " ";
  306. }
  307. }
  308. }
  309. return res.trim();
  310. }
  311. function normalizeProps(props) {
  312. if (!props) return null;
  313. let { class: klass, style } = props;
  314. if (klass && !isString(klass)) {
  315. props.class = normalizeClass(klass);
  316. }
  317. if (style) {
  318. props.style = normalizeStyle(style);
  319. }
  320. return props;
  321. }
  322. 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";
  323. 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";
  324. 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";
  325. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  326. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  327. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  328. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
  329. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  330. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  331. const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
  332. const isBooleanAttr = /* @__PURE__ */ makeMap(
  333. specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
  334. );
  335. function includeBooleanAttr(value) {
  336. return !!value || value === "";
  337. }
  338. const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
  339. const attrValidationCache = {};
  340. function isSSRSafeAttrName(name) {
  341. if (attrValidationCache.hasOwnProperty(name)) {
  342. return attrValidationCache[name];
  343. }
  344. const isUnsafe = unsafeAttrCharRE.test(name);
  345. if (isUnsafe) {
  346. console.error(`unsafe attribute name: ${name}`);
  347. }
  348. return attrValidationCache[name] = !isUnsafe;
  349. }
  350. const propsToAttrMap = {
  351. acceptCharset: "accept-charset",
  352. className: "class",
  353. htmlFor: "for",
  354. httpEquiv: "http-equiv"
  355. };
  356. const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
  357. `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`
  358. );
  359. const isKnownSvgAttr = /* @__PURE__ */ makeMap(
  360. `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,xmlns:xlink,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
  361. );
  362. const isKnownMathMLAttr = /* @__PURE__ */ makeMap(
  363. `accent,accentunder,actiontype,align,alignmentscope,altimg,altimg-height,altimg-valign,altimg-width,alttext,bevelled,close,columnsalign,columnlines,columnspan,denomalign,depth,dir,display,displaystyle,encoding,equalcolumns,equalrows,fence,fontstyle,fontweight,form,frame,framespacing,groupalign,height,href,id,indentalign,indentalignfirst,indentalignlast,indentshift,indentshiftfirst,indentshiftlast,indextype,justify,largetop,largeop,lquote,lspace,mathbackground,mathcolor,mathsize,mathvariant,maxsize,minlabelspacing,mode,other,overflow,position,rowalign,rowlines,rowspan,rquote,rspace,scriptlevel,scriptminsize,scriptsizemultiplier,selection,separator,separators,shift,side,src,stackalign,stretchy,subscriptshift,superscriptshift,symmetric,voffset,width,widths,xlink:href,xlink:show,xlink:type,xmlns`
  364. );
  365. function isRenderableAttrValue(value) {
  366. if (value == null) {
  367. return false;
  368. }
  369. const type = typeof value;
  370. return type === "string" || type === "number" || type === "boolean";
  371. }
  372. const escapeRE = /["'&<>]/;
  373. function escapeHtml(string) {
  374. const str = "" + string;
  375. const match = escapeRE.exec(str);
  376. if (!match) {
  377. return str;
  378. }
  379. let html = "";
  380. let escaped;
  381. let index;
  382. let lastIndex = 0;
  383. for (index = match.index; index < str.length; index++) {
  384. switch (str.charCodeAt(index)) {
  385. case 34:
  386. escaped = "&quot;";
  387. break;
  388. case 38:
  389. escaped = "&amp;";
  390. break;
  391. case 39:
  392. escaped = "&#39;";
  393. break;
  394. case 60:
  395. escaped = "&lt;";
  396. break;
  397. case 62:
  398. escaped = "&gt;";
  399. break;
  400. default:
  401. continue;
  402. }
  403. if (lastIndex !== index) {
  404. html += str.slice(lastIndex, index);
  405. }
  406. lastIndex = index + 1;
  407. html += escaped;
  408. }
  409. return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
  410. }
  411. const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
  412. function escapeHtmlComment(src) {
  413. return src.replace(commentStripRE, "");
  414. }
  415. const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
  416. function getEscapedCssVarName(key, doubleEscape) {
  417. return key.replace(
  418. cssVarNameEscapeSymbolsRE,
  419. (s) => doubleEscape ? s === '"' ? '\\\\\\"' : `\\\\${s}` : `\\${s}`
  420. );
  421. }
  422. function looseCompareArrays(a, b) {
  423. if (a.length !== b.length) return false;
  424. let equal = true;
  425. for (let i = 0; equal && i < a.length; i++) {
  426. equal = looseEqual(a[i], b[i]);
  427. }
  428. return equal;
  429. }
  430. function looseEqual(a, b) {
  431. if (a === b) return true;
  432. let aValidType = isDate(a);
  433. let bValidType = isDate(b);
  434. if (aValidType || bValidType) {
  435. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  436. }
  437. aValidType = isSymbol(a);
  438. bValidType = isSymbol(b);
  439. if (aValidType || bValidType) {
  440. return a === b;
  441. }
  442. aValidType = isArray(a);
  443. bValidType = isArray(b);
  444. if (aValidType || bValidType) {
  445. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  446. }
  447. aValidType = isObject(a);
  448. bValidType = isObject(b);
  449. if (aValidType || bValidType) {
  450. if (!aValidType || !bValidType) {
  451. return false;
  452. }
  453. const aKeysCount = Object.keys(a).length;
  454. const bKeysCount = Object.keys(b).length;
  455. if (aKeysCount !== bKeysCount) {
  456. return false;
  457. }
  458. for (const key in a) {
  459. const aHasKey = a.hasOwnProperty(key);
  460. const bHasKey = b.hasOwnProperty(key);
  461. if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
  462. return false;
  463. }
  464. }
  465. }
  466. return String(a) === String(b);
  467. }
  468. function looseIndexOf(arr, val) {
  469. return arr.findIndex((item) => looseEqual(item, val));
  470. }
  471. const isRef = (val) => {
  472. return !!(val && val["__v_isRef"] === true);
  473. };
  474. const toDisplayString = (val) => {
  475. return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? isRef(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
  476. };
  477. const replacer = (_key, val) => {
  478. if (isRef(val)) {
  479. return replacer(_key, val.value);
  480. } else if (isMap(val)) {
  481. return {
  482. [`Map(${val.size})`]: [...val.entries()].reduce(
  483. (entries, [key, val2], i) => {
  484. entries[stringifySymbol(key, i) + " =>"] = val2;
  485. return entries;
  486. },
  487. {}
  488. )
  489. };
  490. } else if (isSet(val)) {
  491. return {
  492. [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
  493. };
  494. } else if (isSymbol(val)) {
  495. return stringifySymbol(val);
  496. } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  497. return String(val);
  498. }
  499. return val;
  500. };
  501. const stringifySymbol = (v, i = "") => {
  502. var _a;
  503. return (
  504. // Symbol.description in es2019+ so we need to cast here to pass
  505. // the lib: es2016 check
  506. isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
  507. );
  508. };
  509. exports.EMPTY_ARR = EMPTY_ARR;
  510. exports.EMPTY_OBJ = EMPTY_OBJ;
  511. exports.NO = NO;
  512. exports.NOOP = NOOP;
  513. exports.PatchFlagNames = PatchFlagNames;
  514. exports.PatchFlags = PatchFlags;
  515. exports.ShapeFlags = ShapeFlags;
  516. exports.SlotFlags = SlotFlags;
  517. exports.camelize = camelize;
  518. exports.capitalize = capitalize;
  519. exports.cssVarNameEscapeSymbolsRE = cssVarNameEscapeSymbolsRE;
  520. exports.def = def;
  521. exports.escapeHtml = escapeHtml;
  522. exports.escapeHtmlComment = escapeHtmlComment;
  523. exports.extend = extend;
  524. exports.genCacheKey = genCacheKey;
  525. exports.genPropsAccessExp = genPropsAccessExp;
  526. exports.generateCodeFrame = generateCodeFrame;
  527. exports.getEscapedCssVarName = getEscapedCssVarName;
  528. exports.getGlobalThis = getGlobalThis;
  529. exports.hasChanged = hasChanged;
  530. exports.hasOwn = hasOwn;
  531. exports.hyphenate = hyphenate;
  532. exports.includeBooleanAttr = includeBooleanAttr;
  533. exports.invokeArrayFns = invokeArrayFns;
  534. exports.isArray = isArray;
  535. exports.isBooleanAttr = isBooleanAttr;
  536. exports.isBuiltInDirective = isBuiltInDirective;
  537. exports.isDate = isDate;
  538. exports.isFunction = isFunction;
  539. exports.isGloballyAllowed = isGloballyAllowed;
  540. exports.isGloballyWhitelisted = isGloballyWhitelisted;
  541. exports.isHTMLTag = isHTMLTag;
  542. exports.isIntegerKey = isIntegerKey;
  543. exports.isKnownHtmlAttr = isKnownHtmlAttr;
  544. exports.isKnownMathMLAttr = isKnownMathMLAttr;
  545. exports.isKnownSvgAttr = isKnownSvgAttr;
  546. exports.isMap = isMap;
  547. exports.isMathMLTag = isMathMLTag;
  548. exports.isModelListener = isModelListener;
  549. exports.isObject = isObject;
  550. exports.isOn = isOn;
  551. exports.isPlainObject = isPlainObject;
  552. exports.isPromise = isPromise;
  553. exports.isRegExp = isRegExp;
  554. exports.isRenderableAttrValue = isRenderableAttrValue;
  555. exports.isReservedProp = isReservedProp;
  556. exports.isSSRSafeAttrName = isSSRSafeAttrName;
  557. exports.isSVGTag = isSVGTag;
  558. exports.isSet = isSet;
  559. exports.isSpecialBooleanAttr = isSpecialBooleanAttr;
  560. exports.isString = isString;
  561. exports.isSymbol = isSymbol;
  562. exports.isVoidTag = isVoidTag;
  563. exports.looseEqual = looseEqual;
  564. exports.looseIndexOf = looseIndexOf;
  565. exports.looseToNumber = looseToNumber;
  566. exports.makeMap = makeMap;
  567. exports.normalizeClass = normalizeClass;
  568. exports.normalizeProps = normalizeProps;
  569. exports.normalizeStyle = normalizeStyle;
  570. exports.objectToString = objectToString;
  571. exports.parseStringStyle = parseStringStyle;
  572. exports.propsToAttrMap = propsToAttrMap;
  573. exports.remove = remove;
  574. exports.slotFlagsText = slotFlagsText;
  575. exports.stringifyStyle = stringifyStyle;
  576. exports.toDisplayString = toDisplayString;
  577. exports.toHandlerKey = toHandlerKey;
  578. exports.toNumber = toNumber;
  579. exports.toRawType = toRawType;
  580. exports.toTypeString = toTypeString;