shared.esm-bundler.js 22 KB

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