shared.esm-bundler.js 18 KB

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