shared.cjs.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. /**
  4. * Make a map and return a function for checking if a key
  5. * is in that map.
  6. * IMPORTANT: all calls of this function must be prefixed with
  7. * \/\*#\_\_PURE\_\_\*\/
  8. * So that rollup can tree-shake them if necessary.
  9. */
  10. function makeMap(str, expectsLowerCase) {
  11. const map = Object.create(null);
  12. const list = str.split(',');
  13. for (let i = 0; i < list.length; i++) {
  14. map[list[i]] = true;
  15. }
  16. return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
  17. }
  18. /**
  19. * dev only flag -> name mapping
  20. */
  21. const PatchFlagNames = {
  22. [1 /* TEXT */]: `TEXT`,
  23. [2 /* CLASS */]: `CLASS`,
  24. [4 /* STYLE */]: `STYLE`,
  25. [8 /* PROPS */]: `PROPS`,
  26. [16 /* FULL_PROPS */]: `FULL_PROPS`,
  27. [32 /* HYDRATE_EVENTS */]: `HYDRATE_EVENTS`,
  28. [64 /* STABLE_FRAGMENT */]: `STABLE_FRAGMENT`,
  29. [128 /* KEYED_FRAGMENT */]: `KEYED_FRAGMENT`,
  30. [256 /* UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`,
  31. [512 /* NEED_PATCH */]: `NEED_PATCH`,
  32. [1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
  33. [2048 /* DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`,
  34. [-1 /* HOISTED */]: `HOISTED`,
  35. [-2 /* BAIL */]: `BAIL`
  36. };
  37. /**
  38. * Dev only
  39. */
  40. const slotFlagsText = {
  41. [1 /* STABLE */]: 'STABLE',
  42. [2 /* DYNAMIC */]: 'DYNAMIC',
  43. [3 /* FORWARDED */]: 'FORWARDED'
  44. };
  45. const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
  46. 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
  47. 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
  48. const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
  49. const range = 2;
  50. function generateCodeFrame(source, start = 0, end = source.length) {
  51. // Split the content into individual lines but capture the newline sequence
  52. // that separated each line. This is important because the actual sequence is
  53. // needed to properly take into account the full line length for offset
  54. // comparison
  55. let lines = source.split(/(\r?\n)/);
  56. // Separate the lines and newline sequences into separate arrays for easier referencing
  57. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  58. lines = lines.filter((_, idx) => idx % 2 === 0);
  59. let count = 0;
  60. const res = [];
  61. for (let i = 0; i < lines.length; i++) {
  62. count +=
  63. lines[i].length +
  64. ((newlineSequences[i] && newlineSequences[i].length) || 0);
  65. if (count >= start) {
  66. for (let j = i - range; j <= i + range || end > count; j++) {
  67. if (j < 0 || j >= lines.length)
  68. continue;
  69. const line = j + 1;
  70. res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
  71. const lineLength = lines[j].length;
  72. const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0;
  73. if (j === i) {
  74. // push underline
  75. const pad = start - (count - (lineLength + newLineSeqLength));
  76. const length = Math.max(1, end > count ? lineLength - pad : end - start);
  77. res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
  78. }
  79. else if (j > i) {
  80. if (end > count) {
  81. const length = Math.max(Math.min(end - count, lineLength), 1);
  82. res.push(` | ` + '^'.repeat(length));
  83. }
  84. count += lineLength + newLineSeqLength;
  85. }
  86. }
  87. break;
  88. }
  89. }
  90. return res.join('\n');
  91. }
  92. /**
  93. * On the client we only need to offer special cases for boolean attributes that
  94. * have different names from their corresponding dom properties:
  95. * - itemscope -> N/A
  96. * - allowfullscreen -> allowFullscreen
  97. * - formnovalidate -> formNoValidate
  98. * - ismap -> isMap
  99. * - nomodule -> noModule
  100. * - novalidate -> noValidate
  101. * - readonly -> readOnly
  102. */
  103. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  104. const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
  105. /**
  106. * The full list is needed during SSR to produce the correct initial markup.
  107. */
  108. const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
  109. `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
  110. `loop,open,required,reversed,scoped,seamless,` +
  111. `checked,muted,multiple,selected`);
  112. /**
  113. * Boolean attributes should be included if the value is truthy or ''.
  114. * e.g. <select multiple> compiles to { multiple: '' }
  115. */
  116. function includeBooleanAttr(value) {
  117. return !!value || value === '';
  118. }
  119. const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
  120. const attrValidationCache = {};
  121. function isSSRSafeAttrName(name) {
  122. if (attrValidationCache.hasOwnProperty(name)) {
  123. return attrValidationCache[name];
  124. }
  125. const isUnsafe = unsafeAttrCharRE.test(name);
  126. if (isUnsafe) {
  127. console.error(`unsafe attribute name: ${name}`);
  128. }
  129. return (attrValidationCache[name] = !isUnsafe);
  130. }
  131. const propsToAttrMap = {
  132. acceptCharset: 'accept-charset',
  133. className: 'class',
  134. htmlFor: 'for',
  135. httpEquiv: 'http-equiv'
  136. };
  137. /**
  138. * CSS properties that accept plain numbers
  139. */
  140. const isNoUnitNumericStyleProp = /*#__PURE__*/ makeMap(`animation-iteration-count,border-image-outset,border-image-slice,` +
  141. `border-image-width,box-flex,box-flex-group,box-ordinal-group,column-count,` +
  142. `columns,flex,flex-grow,flex-positive,flex-shrink,flex-negative,flex-order,` +
  143. `grid-row,grid-row-end,grid-row-span,grid-row-start,grid-column,` +
  144. `grid-column-end,grid-column-span,grid-column-start,font-weight,line-clamp,` +
  145. `line-height,opacity,order,orphans,tab-size,widows,z-index,zoom,` +
  146. // SVG
  147. `fill-opacity,flood-opacity,stop-opacity,stroke-dasharray,stroke-dashoffset,` +
  148. `stroke-miterlimit,stroke-opacity,stroke-width`);
  149. /**
  150. * Known attributes, this is used for stringification of runtime static nodes
  151. * so that we don't stringify bindings that cannot be set from HTML.
  152. * Don't also forget to allow `data-*` and `aria-*`!
  153. * Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
  154. */
  155. const isKnownHtmlAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
  156. `autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
  157. `border,buffered,capture,challenge,charset,checked,cite,class,code,` +
  158. `codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` +
  159. `coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` +
  160. `disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` +
  161. `formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` +
  162. `height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` +
  163. `ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` +
  164. `manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` +
  165. `open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` +
  166. `referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
  167. `selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
  168. `start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
  169. `value,width,wrap`);
  170. /**
  171. * Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
  172. */
  173. const isKnownSvgAttr = /*#__PURE__*/ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
  174. `arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
  175. `baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +
  176. `clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,` +
  177. `color-interpolation-filters,color-profile,color-rendering,` +
  178. `contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,` +
  179. `descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,` +
  180. `dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,` +
  181. `fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,` +
  182. `font-family,font-size,font-size-adjust,font-stretch,font-style,` +
  183. `font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,` +
  184. `glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,` +
  185. `gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,` +
  186. `horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,` +
  187. `k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,` +
  188. `lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,` +
  189. `marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,` +
  190. `mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,` +
  191. `name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,` +
  192. `overflow,overline-position,overline-thickness,panose-1,paint-order,path,` +
  193. `pathLength,patternContentUnits,patternTransform,patternUnits,ping,` +
  194. `pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,` +
  195. `preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,` +
  196. `rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,` +
  197. `restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,` +
  198. `specularConstant,specularExponent,speed,spreadMethod,startOffset,` +
  199. `stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,` +
  200. `strikethrough-position,strikethrough-thickness,string,stroke,` +
  201. `stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,` +
  202. `stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,` +
  203. `systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,` +
  204. `text-decoration,text-rendering,textLength,to,transform,transform-origin,` +
  205. `type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,` +
  206. `unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,` +
  207. `v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,` +
  208. `vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
  209. `writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
  210. `xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,` +
  211. `xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
  212. function normalizeStyle(value) {
  213. if (isArray(value)) {
  214. const res = {};
  215. for (let i = 0; i < value.length; i++) {
  216. const item = value[i];
  217. const normalized = isString(item)
  218. ? parseStringStyle(item)
  219. : normalizeStyle(item);
  220. if (normalized) {
  221. for (const key in normalized) {
  222. res[key] = normalized[key];
  223. }
  224. }
  225. }
  226. return res;
  227. }
  228. else if (isString(value)) {
  229. return value;
  230. }
  231. else if (isObject(value)) {
  232. return value;
  233. }
  234. }
  235. const listDelimiterRE = /;(?![^(]*\))/g;
  236. const propertyDelimiterRE = /:(.+)/;
  237. function parseStringStyle(cssText) {
  238. const ret = {};
  239. cssText.split(listDelimiterRE).forEach(item => {
  240. if (item) {
  241. const tmp = item.split(propertyDelimiterRE);
  242. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  243. }
  244. });
  245. return ret;
  246. }
  247. function stringifyStyle(styles) {
  248. let ret = '';
  249. if (!styles || isString(styles)) {
  250. return ret;
  251. }
  252. for (const key in styles) {
  253. const value = styles[key];
  254. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
  255. if (isString(value) ||
  256. (typeof value === 'number' && isNoUnitNumericStyleProp(normalizedKey))) {
  257. // only render valid values
  258. ret += `${normalizedKey}:${value};`;
  259. }
  260. }
  261. return ret;
  262. }
  263. function normalizeClass(value) {
  264. let res = '';
  265. if (isString(value)) {
  266. res = value;
  267. }
  268. else if (isArray(value)) {
  269. for (let i = 0; i < value.length; i++) {
  270. const normalized = normalizeClass(value[i]);
  271. if (normalized) {
  272. res += normalized + ' ';
  273. }
  274. }
  275. }
  276. else if (isObject(value)) {
  277. for (const name in value) {
  278. if (value[name]) {
  279. res += name + ' ';
  280. }
  281. }
  282. }
  283. return res.trim();
  284. }
  285. function normalizeProps(props) {
  286. if (!props)
  287. return null;
  288. let { class: klass, style } = props;
  289. if (klass && !isString(klass)) {
  290. props.class = normalizeClass(klass);
  291. }
  292. if (style) {
  293. props.style = normalizeStyle(style);
  294. }
  295. return props;
  296. }
  297. // These tag configs are shared between compiler-dom and runtime-dom, so they
  298. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
  299. const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
  300. 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
  301. 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
  302. 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
  303. 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
  304. 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
  305. 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
  306. 'option,output,progress,select,textarea,details,dialog,menu,' +
  307. 'summary,template,blockquote,iframe,tfoot';
  308. // https://developer.mozilla.org/en-US/docs/Web/SVG/Element
  309. const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
  310. 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
  311. 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
  312. 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
  313. 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
  314. 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
  315. 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
  316. 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
  317. 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
  318. 'text,textPath,title,tspan,unknown,use,view';
  319. const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';
  320. const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
  321. const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
  322. const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
  323. const escapeRE = /["'&<>]/;
  324. function escapeHtml(string) {
  325. const str = '' + string;
  326. const match = escapeRE.exec(str);
  327. if (!match) {
  328. return str;
  329. }
  330. let html = '';
  331. let escaped;
  332. let index;
  333. let lastIndex = 0;
  334. for (index = match.index; index < str.length; index++) {
  335. switch (str.charCodeAt(index)) {
  336. case 34: // "
  337. escaped = '&quot;';
  338. break;
  339. case 38: // &
  340. escaped = '&amp;';
  341. break;
  342. case 39: // '
  343. escaped = '&#39;';
  344. break;
  345. case 60: // <
  346. escaped = '&lt;';
  347. break;
  348. case 62: // >
  349. escaped = '&gt;';
  350. break;
  351. default:
  352. continue;
  353. }
  354. if (lastIndex !== index) {
  355. html += str.substring(lastIndex, index);
  356. }
  357. lastIndex = index + 1;
  358. html += escaped;
  359. }
  360. return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
  361. }
  362. // https://www.w3.org/TR/html52/syntax.html#comments
  363. const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
  364. function escapeHtmlComment(src) {
  365. return src.replace(commentStripRE, '');
  366. }
  367. function looseCompareArrays(a, b) {
  368. if (a.length !== b.length)
  369. return false;
  370. let equal = true;
  371. for (let i = 0; equal && i < a.length; i++) {
  372. equal = looseEqual(a[i], b[i]);
  373. }
  374. return equal;
  375. }
  376. function looseEqual(a, b) {
  377. if (a === b)
  378. return true;
  379. let aValidType = isDate(a);
  380. let bValidType = isDate(b);
  381. if (aValidType || bValidType) {
  382. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  383. }
  384. aValidType = isArray(a);
  385. bValidType = isArray(b);
  386. if (aValidType || bValidType) {
  387. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  388. }
  389. aValidType = isObject(a);
  390. bValidType = isObject(b);
  391. if (aValidType || bValidType) {
  392. /* istanbul ignore if: this if will probably never be called */
  393. if (!aValidType || !bValidType) {
  394. return false;
  395. }
  396. const aKeysCount = Object.keys(a).length;
  397. const bKeysCount = Object.keys(b).length;
  398. if (aKeysCount !== bKeysCount) {
  399. return false;
  400. }
  401. for (const key in a) {
  402. const aHasKey = a.hasOwnProperty(key);
  403. const bHasKey = b.hasOwnProperty(key);
  404. if ((aHasKey && !bHasKey) ||
  405. (!aHasKey && bHasKey) ||
  406. !looseEqual(a[key], b[key])) {
  407. return false;
  408. }
  409. }
  410. }
  411. return String(a) === String(b);
  412. }
  413. function looseIndexOf(arr, val) {
  414. return arr.findIndex(item => looseEqual(item, val));
  415. }
  416. /**
  417. * For converting {{ interpolation }} values to displayed strings.
  418. * @private
  419. */
  420. const toDisplayString = (val) => {
  421. return val == null
  422. ? ''
  423. : isArray(val) ||
  424. (isObject(val) &&
  425. (val.toString === objectToString || !isFunction(val.toString)))
  426. ? JSON.stringify(val, replacer, 2)
  427. : String(val);
  428. };
  429. const replacer = (_key, val) => {
  430. // can't use isRef here since @vue/shared has no deps
  431. if (val && val.__v_isRef) {
  432. return replacer(_key, val.value);
  433. }
  434. else if (isMap(val)) {
  435. return {
  436. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
  437. entries[`${key} =>`] = val;
  438. return entries;
  439. }, {})
  440. };
  441. }
  442. else if (isSet(val)) {
  443. return {
  444. [`Set(${val.size})`]: [...val.values()]
  445. };
  446. }
  447. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  448. return String(val);
  449. }
  450. return val;
  451. };
  452. /**
  453. * List of @babel/parser plugins that are used for template expression
  454. * transforms and SFC script transforms. By default we enable proposals slated
  455. * for ES2020. This will need to be updated as the spec moves forward.
  456. * Full list at https://babeljs.io/docs/en/next/babel-parser#plugins
  457. */
  458. const babelParserDefaultPlugins = [
  459. 'bigInt',
  460. 'optionalChaining',
  461. 'nullishCoalescingOperator'
  462. ];
  463. const EMPTY_OBJ = Object.freeze({})
  464. ;
  465. const EMPTY_ARR = Object.freeze([]) ;
  466. const NOOP = () => { };
  467. /**
  468. * Always return false.
  469. */
  470. const NO = () => false;
  471. const onRE = /^on[^a-z]/;
  472. const isOn = (key) => onRE.test(key);
  473. const isModelListener = (key) => key.startsWith('onUpdate:');
  474. const extend = Object.assign;
  475. const remove = (arr, el) => {
  476. const i = arr.indexOf(el);
  477. if (i > -1) {
  478. arr.splice(i, 1);
  479. }
  480. };
  481. const hasOwnProperty = Object.prototype.hasOwnProperty;
  482. const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  483. const isArray = Array.isArray;
  484. const isMap = (val) => toTypeString(val) === '[object Map]';
  485. const isSet = (val) => toTypeString(val) === '[object Set]';
  486. const isDate = (val) => val instanceof Date;
  487. const isFunction = (val) => typeof val === 'function';
  488. const isString = (val) => typeof val === 'string';
  489. const isSymbol = (val) => typeof val === 'symbol';
  490. const isObject = (val) => val !== null && typeof val === 'object';
  491. const isPromise = (val) => {
  492. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  493. };
  494. const objectToString = Object.prototype.toString;
  495. const toTypeString = (value) => objectToString.call(value);
  496. const toRawType = (value) => {
  497. // extract "RawType" from strings like "[object RawType]"
  498. return toTypeString(value).slice(8, -1);
  499. };
  500. const isPlainObject = (val) => toTypeString(val) === '[object Object]';
  501. const isIntegerKey = (key) => isString(key) &&
  502. key !== 'NaN' &&
  503. key[0] !== '-' &&
  504. '' + parseInt(key, 10) === key;
  505. const isReservedProp = /*#__PURE__*/ makeMap(
  506. // the leading comma is intentional so empty string "" is also included
  507. ',key,ref,' +
  508. 'onVnodeBeforeMount,onVnodeMounted,' +
  509. 'onVnodeBeforeUpdate,onVnodeUpdated,' +
  510. 'onVnodeBeforeUnmount,onVnodeUnmounted');
  511. const cacheStringFunction = (fn) => {
  512. const cache = Object.create(null);
  513. return ((str) => {
  514. const hit = cache[str];
  515. return hit || (cache[str] = fn(str));
  516. });
  517. };
  518. const camelizeRE = /-(\w)/g;
  519. /**
  520. * @private
  521. */
  522. const camelize = cacheStringFunction((str) => {
  523. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  524. });
  525. const hyphenateRE = /\B([A-Z])/g;
  526. /**
  527. * @private
  528. */
  529. const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
  530. /**
  531. * @private
  532. */
  533. const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  534. /**
  535. * @private
  536. */
  537. const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  538. // compare whether a value has changed, accounting for NaN.
  539. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  540. const invokeArrayFns = (fns, arg) => {
  541. for (let i = 0; i < fns.length; i++) {
  542. fns[i](arg);
  543. }
  544. };
  545. const def = (obj, key, value) => {
  546. Object.defineProperty(obj, key, {
  547. configurable: true,
  548. enumerable: false,
  549. value
  550. });
  551. };
  552. const toNumber = (val) => {
  553. const n = parseFloat(val);
  554. return isNaN(n) ? val : n;
  555. };
  556. let _globalThis;
  557. const getGlobalThis = () => {
  558. return (_globalThis ||
  559. (_globalThis =
  560. typeof globalThis !== 'undefined'
  561. ? globalThis
  562. : typeof self !== 'undefined'
  563. ? self
  564. : typeof window !== 'undefined'
  565. ? window
  566. : typeof global !== 'undefined'
  567. ? global
  568. : {}));
  569. };
  570. exports.EMPTY_ARR = EMPTY_ARR;
  571. exports.EMPTY_OBJ = EMPTY_OBJ;
  572. exports.NO = NO;
  573. exports.NOOP = NOOP;
  574. exports.PatchFlagNames = PatchFlagNames;
  575. exports.babelParserDefaultPlugins = babelParserDefaultPlugins;
  576. exports.camelize = camelize;
  577. exports.capitalize = capitalize;
  578. exports.def = def;
  579. exports.escapeHtml = escapeHtml;
  580. exports.escapeHtmlComment = escapeHtmlComment;
  581. exports.extend = extend;
  582. exports.generateCodeFrame = generateCodeFrame;
  583. exports.getGlobalThis = getGlobalThis;
  584. exports.hasChanged = hasChanged;
  585. exports.hasOwn = hasOwn;
  586. exports.hyphenate = hyphenate;
  587. exports.includeBooleanAttr = includeBooleanAttr;
  588. exports.invokeArrayFns = invokeArrayFns;
  589. exports.isArray = isArray;
  590. exports.isBooleanAttr = isBooleanAttr;
  591. exports.isDate = isDate;
  592. exports.isFunction = isFunction;
  593. exports.isGloballyWhitelisted = isGloballyWhitelisted;
  594. exports.isHTMLTag = isHTMLTag;
  595. exports.isIntegerKey = isIntegerKey;
  596. exports.isKnownHtmlAttr = isKnownHtmlAttr;
  597. exports.isKnownSvgAttr = isKnownSvgAttr;
  598. exports.isMap = isMap;
  599. exports.isModelListener = isModelListener;
  600. exports.isNoUnitNumericStyleProp = isNoUnitNumericStyleProp;
  601. exports.isObject = isObject;
  602. exports.isOn = isOn;
  603. exports.isPlainObject = isPlainObject;
  604. exports.isPromise = isPromise;
  605. exports.isReservedProp = isReservedProp;
  606. exports.isSSRSafeAttrName = isSSRSafeAttrName;
  607. exports.isSVGTag = isSVGTag;
  608. exports.isSet = isSet;
  609. exports.isSpecialBooleanAttr = isSpecialBooleanAttr;
  610. exports.isString = isString;
  611. exports.isSymbol = isSymbol;
  612. exports.isVoidTag = isVoidTag;
  613. exports.looseEqual = looseEqual;
  614. exports.looseIndexOf = looseIndexOf;
  615. exports.makeMap = makeMap;
  616. exports.normalizeClass = normalizeClass;
  617. exports.normalizeProps = normalizeProps;
  618. exports.normalizeStyle = normalizeStyle;
  619. exports.objectToString = objectToString;
  620. exports.parseStringStyle = parseStringStyle;
  621. exports.propsToAttrMap = propsToAttrMap;
  622. exports.remove = remove;
  623. exports.slotFlagsText = slotFlagsText;
  624. exports.stringifyStyle = stringifyStyle;
  625. exports.toDisplayString = toDisplayString;
  626. exports.toHandlerKey = toHandlerKey;
  627. exports.toNumber = toNumber;
  628. exports.toRawType = toRawType;
  629. exports.toTypeString = toTypeString;