1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var Vue = (function (exports) {
|
7 | 'use strict';
|
8 |
|
9 | function makeMap(str, expectsLowerCase) {
|
10 | const set = new Set(str.split(","));
|
11 | return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
|
12 | }
|
13 |
|
14 | const EMPTY_OBJ = Object.freeze({}) ;
|
15 | const EMPTY_ARR = Object.freeze([]) ;
|
16 | const NOOP = () => {
|
17 | };
|
18 | const NO = () => false;
|
19 | const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 &&
|
20 | (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
|
21 | const isModelListener = (key) => key.startsWith("onUpdate:");
|
22 | const extend = Object.assign;
|
23 | const remove = (arr, el) => {
|
24 | const i = arr.indexOf(el);
|
25 | if (i > -1) {
|
26 | arr.splice(i, 1);
|
27 | }
|
28 | };
|
29 | const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
30 | const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
31 | const isArray = Array.isArray;
|
32 | const isMap = (val) => toTypeString(val) === "[object Map]";
|
33 | const isSet = (val) => toTypeString(val) === "[object Set]";
|
34 | const isDate = (val) => toTypeString(val) === "[object Date]";
|
35 | const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
|
36 | const isFunction = (val) => typeof val === "function";
|
37 | const isString = (val) => typeof val === "string";
|
38 | const isSymbol = (val) => typeof val === "symbol";
|
39 | const isObject = (val) => val !== null && typeof val === "object";
|
40 | const isPromise = (val) => {
|
41 | return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
|
42 | };
|
43 | const objectToString = Object.prototype.toString;
|
44 | const toTypeString = (value) => objectToString.call(value);
|
45 | const toRawType = (value) => {
|
46 | return toTypeString(value).slice(8, -1);
|
47 | };
|
48 | const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
49 | const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
50 | const isReservedProp = makeMap(
|
51 |
|
52 | ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
|
53 | );
|
54 | const isBuiltInDirective = makeMap(
|
55 | "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
|
56 | );
|
57 | const cacheStringFunction = (fn) => {
|
58 | const cache = Object.create(null);
|
59 | return (str) => {
|
60 | const hit = cache[str];
|
61 | return hit || (cache[str] = fn(str));
|
62 | };
|
63 | };
|
64 | const camelizeRE = /-(\w)/g;
|
65 | const camelize = cacheStringFunction((str) => {
|
66 | return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
67 | });
|
68 | const hyphenateRE = /\B([A-Z])/g;
|
69 | const hyphenate = cacheStringFunction(
|
70 | (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
71 | );
|
72 | const capitalize = cacheStringFunction((str) => {
|
73 | return str.charAt(0).toUpperCase() + str.slice(1);
|
74 | });
|
75 | const toHandlerKey = cacheStringFunction((str) => {
|
76 | const s = str ? `on${capitalize(str)}` : ``;
|
77 | return s;
|
78 | });
|
79 | const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
80 | const invokeArrayFns = (fns, arg) => {
|
81 | for (let i = 0; i < fns.length; i++) {
|
82 | fns[i](arg);
|
83 | }
|
84 | };
|
85 | const def = (obj, key, value) => {
|
86 | Object.defineProperty(obj, key, {
|
87 | configurable: true,
|
88 | enumerable: false,
|
89 | value
|
90 | });
|
91 | };
|
92 | const looseToNumber = (val) => {
|
93 | const n = parseFloat(val);
|
94 | return isNaN(n) ? val : n;
|
95 | };
|
96 | const toNumber = (val) => {
|
97 | const n = isString(val) ? Number(val) : NaN;
|
98 | return isNaN(n) ? val : n;
|
99 | };
|
100 | let _globalThis;
|
101 | const getGlobalThis = () => {
|
102 | return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
|
103 | };
|
104 |
|
105 | const PatchFlagNames = {
|
106 | [1]: `TEXT`,
|
107 | [2]: `CLASS`,
|
108 | [4]: `STYLE`,
|
109 | [8]: `PROPS`,
|
110 | [16]: `FULL_PROPS`,
|
111 | [32]: `NEED_HYDRATION`,
|
112 | [64]: `STABLE_FRAGMENT`,
|
113 | [128]: `KEYED_FRAGMENT`,
|
114 | [256]: `UNKEYED_FRAGMENT`,
|
115 | [512]: `NEED_PATCH`,
|
116 | [1024]: `DYNAMIC_SLOTS`,
|
117 | [2048]: `DEV_ROOT_FRAGMENT`,
|
118 | [-1]: `HOISTED`,
|
119 | [-2]: `BAIL`
|
120 | };
|
121 |
|
122 | const slotFlagsText = {
|
123 | [1]: "STABLE",
|
124 | [2]: "DYNAMIC",
|
125 | [3]: "FORWARDED"
|
126 | };
|
127 |
|
128 | 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";
|
129 | const isGloballyAllowed = makeMap(GLOBALS_ALLOWED);
|
130 |
|
131 | const range = 2;
|
132 | function generateCodeFrame(source, start = 0, end = source.length) {
|
133 | let lines = source.split(/(\r?\n)/);
|
134 | const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
135 | lines = lines.filter((_, idx) => idx % 2 === 0);
|
136 | let count = 0;
|
137 | const res = [];
|
138 | for (let i = 0; i < lines.length; i++) {
|
139 | count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
|
140 | if (count >= start) {
|
141 | for (let j = i - range; j <= i + range || end > count; j++) {
|
142 | if (j < 0 || j >= lines.length)
|
143 | continue;
|
144 | const line = j + 1;
|
145 | res.push(
|
146 | `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
|
147 | );
|
148 | const lineLength = lines[j].length;
|
149 | const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
|
150 | if (j === i) {
|
151 | const pad = start - (count - (lineLength + newLineSeqLength));
|
152 | const length = Math.max(
|
153 | 1,
|
154 | end > count ? lineLength - pad : end - start
|
155 | );
|
156 | res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
|
157 | } else if (j > i) {
|
158 | if (end > count) {
|
159 | const length = Math.max(Math.min(end - count, lineLength), 1);
|
160 | res.push(` | ` + "^".repeat(length));
|
161 | }
|
162 | count += lineLength + newLineSeqLength;
|
163 | }
|
164 | }
|
165 | break;
|
166 | }
|
167 | }
|
168 | return res.join("\n");
|
169 | }
|
170 |
|
171 | function normalizeStyle(value) {
|
172 | if (isArray(value)) {
|
173 | const res = {};
|
174 | for (let i = 0; i < value.length; i++) {
|
175 | const item = value[i];
|
176 | const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
177 | if (normalized) {
|
178 | for (const key in normalized) {
|
179 | res[key] = normalized[key];
|
180 | }
|
181 | }
|
182 | }
|
183 | return res;
|
184 | } else if (isString(value) || isObject(value)) {
|
185 | return value;
|
186 | }
|
187 | }
|
188 | const listDelimiterRE = /;(?![^(]*\))/g;
|
189 | const propertyDelimiterRE = /:([^]+)/;
|
190 | const styleCommentRE = /\/\*[^]*?\*\//g;
|
191 | function parseStringStyle(cssText) {
|
192 | const ret = {};
|
193 | cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
194 | if (item) {
|
195 | const tmp = item.split(propertyDelimiterRE);
|
196 | tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
197 | }
|
198 | });
|
199 | return ret;
|
200 | }
|
201 | function stringifyStyle(styles) {
|
202 | let ret = "";
|
203 | if (!styles || isString(styles)) {
|
204 | return ret;
|
205 | }
|
206 | for (const key in styles) {
|
207 | const value = styles[key];
|
208 | const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
209 | if (isString(value) || typeof value === "number") {
|
210 | ret += `${normalizedKey}:${value};`;
|
211 | }
|
212 | }
|
213 | return ret;
|
214 | }
|
215 | function normalizeClass(value) {
|
216 | let res = "";
|
217 | if (isString(value)) {
|
218 | res = value;
|
219 | } else if (isArray(value)) {
|
220 | for (let i = 0; i < value.length; i++) {
|
221 | const normalized = normalizeClass(value[i]);
|
222 | if (normalized) {
|
223 | res += normalized + " ";
|
224 | }
|
225 | }
|
226 | } else if (isObject(value)) {
|
227 | for (const name in value) {
|
228 | if (value[name]) {
|
229 | res += name + " ";
|
230 | }
|
231 | }
|
232 | }
|
233 | return res.trim();
|
234 | }
|
235 | function normalizeProps(props) {
|
236 | if (!props)
|
237 | return null;
|
238 | let { class: klass, style } = props;
|
239 | if (klass && !isString(klass)) {
|
240 | props.class = normalizeClass(klass);
|
241 | }
|
242 | if (style) {
|
243 | props.style = normalizeStyle(style);
|
244 | }
|
245 | return props;
|
246 | }
|
247 |
|
248 | 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";
|
249 | 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";
|
250 | 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";
|
251 | const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
|
252 | const isHTMLTag = makeMap(HTML_TAGS);
|
253 | const isSVGTag = makeMap(SVG_TAGS);
|
254 | const isMathMLTag = makeMap(MATH_TAGS);
|
255 | const isVoidTag = makeMap(VOID_TAGS);
|
256 |
|
257 | const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
258 | const isSpecialBooleanAttr = makeMap(specialBooleanAttrs);
|
259 | const isBooleanAttr = makeMap(
|
260 | specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
|
261 | );
|
262 | function includeBooleanAttr(value) {
|
263 | return !!value || value === "";
|
264 | }
|
265 | const isKnownHtmlAttr = makeMap(
|
266 | `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`
|
267 | );
|
268 | const isKnownSvgAttr = makeMap(
|
269 | `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`
|
270 | );
|
271 | function isRenderableAttrValue(value) {
|
272 | if (value == null) {
|
273 | return false;
|
274 | }
|
275 | const type = typeof value;
|
276 | return type === "string" || type === "number" || type === "boolean";
|
277 | }
|
278 |
|
279 | function looseCompareArrays(a, b) {
|
280 | if (a.length !== b.length)
|
281 | return false;
|
282 | let equal = true;
|
283 | for (let i = 0; equal && i < a.length; i++) {
|
284 | equal = looseEqual(a[i], b[i]);
|
285 | }
|
286 | return equal;
|
287 | }
|
288 | function looseEqual(a, b) {
|
289 | if (a === b)
|
290 | return true;
|
291 | let aValidType = isDate(a);
|
292 | let bValidType = isDate(b);
|
293 | if (aValidType || bValidType) {
|
294 | return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
295 | }
|
296 | aValidType = isSymbol(a);
|
297 | bValidType = isSymbol(b);
|
298 | if (aValidType || bValidType) {
|
299 | return a === b;
|
300 | }
|
301 | aValidType = isArray(a);
|
302 | bValidType = isArray(b);
|
303 | if (aValidType || bValidType) {
|
304 | return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
305 | }
|
306 | aValidType = isObject(a);
|
307 | bValidType = isObject(b);
|
308 | if (aValidType || bValidType) {
|
309 | if (!aValidType || !bValidType) {
|
310 | return false;
|
311 | }
|
312 | const aKeysCount = Object.keys(a).length;
|
313 | const bKeysCount = Object.keys(b).length;
|
314 | if (aKeysCount !== bKeysCount) {
|
315 | return false;
|
316 | }
|
317 | for (const key in a) {
|
318 | const aHasKey = a.hasOwnProperty(key);
|
319 | const bHasKey = b.hasOwnProperty(key);
|
320 | if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
|
321 | return false;
|
322 | }
|
323 | }
|
324 | }
|
325 | return String(a) === String(b);
|
326 | }
|
327 | function looseIndexOf(arr, val) {
|
328 | return arr.findIndex((item) => looseEqual(item, val));
|
329 | }
|
330 |
|
331 | const toDisplayString = (val) => {
|
332 | return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
|
333 | };
|
334 | const replacer = (_key, val) => {
|
335 | if (val && val.__v_isRef) {
|
336 | return replacer(_key, val.value);
|
337 | } else if (isMap(val)) {
|
338 | return {
|
339 | [`Map(${val.size})`]: [...val.entries()].reduce(
|
340 | (entries, [key, val2], i) => {
|
341 | entries[stringifySymbol(key, i) + " =>"] = val2;
|
342 | return entries;
|
343 | },
|
344 | {}
|
345 | )
|
346 | };
|
347 | } else if (isSet(val)) {
|
348 | return {
|
349 | [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
|
350 | };
|
351 | } else if (isSymbol(val)) {
|
352 | return stringifySymbol(val);
|
353 | } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
|
354 | return String(val);
|
355 | }
|
356 | return val;
|
357 | };
|
358 | const stringifySymbol = (v, i = "") => {
|
359 | var _a;
|
360 | return isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v;
|
361 | };
|
362 |
|
363 | function warn$2(msg, ...args) {
|
364 | console.warn(`[Vue warn] ${msg}`, ...args);
|
365 | }
|
366 |
|
367 | let activeEffectScope;
|
368 | class EffectScope {
|
369 | constructor(detached = false) {
|
370 | this.detached = detached;
|
371 | |
372 |
|
373 |
|
374 | this._active = true;
|
375 | |
376 |
|
377 |
|
378 | this.effects = [];
|
379 | |
380 |
|
381 |
|
382 | this.cleanups = [];
|
383 | this.parent = activeEffectScope;
|
384 | if (!detached && activeEffectScope) {
|
385 | this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
|
386 | this
|
387 | ) - 1;
|
388 | }
|
389 | }
|
390 | get active() {
|
391 | return this._active;
|
392 | }
|
393 | run(fn) {
|
394 | if (this._active) {
|
395 | const currentEffectScope = activeEffectScope;
|
396 | try {
|
397 | activeEffectScope = this;
|
398 | return fn();
|
399 | } finally {
|
400 | activeEffectScope = currentEffectScope;
|
401 | }
|
402 | } else {
|
403 | warn$2(`cannot run an inactive effect scope.`);
|
404 | }
|
405 | }
|
406 | |
407 |
|
408 |
|
409 |
|
410 | on() {
|
411 | activeEffectScope = this;
|
412 | }
|
413 | |
414 |
|
415 |
|
416 |
|
417 | off() {
|
418 | activeEffectScope = this.parent;
|
419 | }
|
420 | stop(fromParent) {
|
421 | if (this._active) {
|
422 | let i, l;
|
423 | for (i = 0, l = this.effects.length; i < l; i++) {
|
424 | this.effects[i].stop();
|
425 | }
|
426 | for (i = 0, l = this.cleanups.length; i < l; i++) {
|
427 | this.cleanups[i]();
|
428 | }
|
429 | if (this.scopes) {
|
430 | for (i = 0, l = this.scopes.length; i < l; i++) {
|
431 | this.scopes[i].stop(true);
|
432 | }
|
433 | }
|
434 | if (!this.detached && this.parent && !fromParent) {
|
435 | const last = this.parent.scopes.pop();
|
436 | if (last && last !== this) {
|
437 | this.parent.scopes[this.index] = last;
|
438 | last.index = this.index;
|
439 | }
|
440 | }
|
441 | this.parent = void 0;
|
442 | this._active = false;
|
443 | }
|
444 | }
|
445 | }
|
446 | function effectScope(detached) {
|
447 | return new EffectScope(detached);
|
448 | }
|
449 | function recordEffectScope(effect, scope = activeEffectScope) {
|
450 | if (scope && scope.active) {
|
451 | scope.effects.push(effect);
|
452 | }
|
453 | }
|
454 | function getCurrentScope() {
|
455 | return activeEffectScope;
|
456 | }
|
457 | function onScopeDispose(fn) {
|
458 | if (activeEffectScope) {
|
459 | activeEffectScope.cleanups.push(fn);
|
460 | } else {
|
461 | warn$2(
|
462 | `onScopeDispose() is called when there is no active effect scope to be associated with.`
|
463 | );
|
464 | }
|
465 | }
|
466 |
|
467 | let activeEffect;
|
468 | class ReactiveEffect {
|
469 | constructor(fn, trigger, scheduler, scope) {
|
470 | this.fn = fn;
|
471 | this.trigger = trigger;
|
472 | this.scheduler = scheduler;
|
473 | this.active = true;
|
474 | this.deps = [];
|
475 | |
476 |
|
477 |
|
478 | this._dirtyLevel = 4;
|
479 | |
480 |
|
481 |
|
482 | this._trackId = 0;
|
483 | |
484 |
|
485 |
|
486 | this._runnings = 0;
|
487 | |
488 |
|
489 |
|
490 | this._shouldSchedule = false;
|
491 | |
492 |
|
493 |
|
494 | this._depsLength = 0;
|
495 | recordEffectScope(this, scope);
|
496 | }
|
497 | get dirty() {
|
498 | if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
|
499 | this._dirtyLevel = 1;
|
500 | pauseTracking();
|
501 | for (let i = 0; i < this._depsLength; i++) {
|
502 | const dep = this.deps[i];
|
503 | if (dep.computed) {
|
504 | triggerComputed(dep.computed);
|
505 | if (this._dirtyLevel >= 4) {
|
506 | break;
|
507 | }
|
508 | }
|
509 | }
|
510 | if (this._dirtyLevel === 1) {
|
511 | this._dirtyLevel = 0;
|
512 | }
|
513 | resetTracking();
|
514 | }
|
515 | return this._dirtyLevel >= 4;
|
516 | }
|
517 | set dirty(v) {
|
518 | this._dirtyLevel = v ? 4 : 0;
|
519 | }
|
520 | run() {
|
521 | this._dirtyLevel = 0;
|
522 | if (!this.active) {
|
523 | return this.fn();
|
524 | }
|
525 | let lastShouldTrack = shouldTrack;
|
526 | let lastEffect = activeEffect;
|
527 | try {
|
528 | shouldTrack = true;
|
529 | activeEffect = this;
|
530 | this._runnings++;
|
531 | preCleanupEffect(this);
|
532 | return this.fn();
|
533 | } finally {
|
534 | postCleanupEffect(this);
|
535 | this._runnings--;
|
536 | activeEffect = lastEffect;
|
537 | shouldTrack = lastShouldTrack;
|
538 | }
|
539 | }
|
540 | stop() {
|
541 | var _a;
|
542 | if (this.active) {
|
543 | preCleanupEffect(this);
|
544 | postCleanupEffect(this);
|
545 | (_a = this.onStop) == null ? void 0 : _a.call(this);
|
546 | this.active = false;
|
547 | }
|
548 | }
|
549 | }
|
550 | function triggerComputed(computed) {
|
551 | return computed.value;
|
552 | }
|
553 | function preCleanupEffect(effect2) {
|
554 | effect2._trackId++;
|
555 | effect2._depsLength = 0;
|
556 | }
|
557 | function postCleanupEffect(effect2) {
|
558 | if (effect2.deps.length > effect2._depsLength) {
|
559 | for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
|
560 | cleanupDepEffect(effect2.deps[i], effect2);
|
561 | }
|
562 | effect2.deps.length = effect2._depsLength;
|
563 | }
|
564 | }
|
565 | function cleanupDepEffect(dep, effect2) {
|
566 | const trackId = dep.get(effect2);
|
567 | if (trackId !== void 0 && effect2._trackId !== trackId) {
|
568 | dep.delete(effect2);
|
569 | if (dep.size === 0) {
|
570 | dep.cleanup();
|
571 | }
|
572 | }
|
573 | }
|
574 | function effect(fn, options) {
|
575 | if (fn.effect instanceof ReactiveEffect) {
|
576 | fn = fn.effect.fn;
|
577 | }
|
578 | const _effect = new ReactiveEffect(fn, NOOP, () => {
|
579 | if (_effect.dirty) {
|
580 | _effect.run();
|
581 | }
|
582 | });
|
583 | if (options) {
|
584 | extend(_effect, options);
|
585 | if (options.scope)
|
586 | recordEffectScope(_effect, options.scope);
|
587 | }
|
588 | if (!options || !options.lazy) {
|
589 | _effect.run();
|
590 | }
|
591 | const runner = _effect.run.bind(_effect);
|
592 | runner.effect = _effect;
|
593 | return runner;
|
594 | }
|
595 | function stop(runner) {
|
596 | runner.effect.stop();
|
597 | }
|
598 | let shouldTrack = true;
|
599 | let pauseScheduleStack = 0;
|
600 | const trackStack = [];
|
601 | function pauseTracking() {
|
602 | trackStack.push(shouldTrack);
|
603 | shouldTrack = false;
|
604 | }
|
605 | function resetTracking() {
|
606 | const last = trackStack.pop();
|
607 | shouldTrack = last === void 0 ? true : last;
|
608 | }
|
609 | function pauseScheduling() {
|
610 | pauseScheduleStack++;
|
611 | }
|
612 | function resetScheduling() {
|
613 | pauseScheduleStack--;
|
614 | while (!pauseScheduleStack && queueEffectSchedulers.length) {
|
615 | queueEffectSchedulers.shift()();
|
616 | }
|
617 | }
|
618 | function trackEffect(effect2, dep, debuggerEventExtraInfo) {
|
619 | var _a;
|
620 | if (dep.get(effect2) !== effect2._trackId) {
|
621 | dep.set(effect2, effect2._trackId);
|
622 | const oldDep = effect2.deps[effect2._depsLength];
|
623 | if (oldDep !== dep) {
|
624 | if (oldDep) {
|
625 | cleanupDepEffect(oldDep, effect2);
|
626 | }
|
627 | effect2.deps[effect2._depsLength++] = dep;
|
628 | } else {
|
629 | effect2._depsLength++;
|
630 | }
|
631 | {
|
632 | (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
633 | }
|
634 | }
|
635 | }
|
636 | const queueEffectSchedulers = [];
|
637 | function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
638 | var _a;
|
639 | pauseScheduling();
|
640 | for (const effect2 of dep.keys()) {
|
641 | let tracking;
|
642 | if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
643 | effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
|
644 | effect2._dirtyLevel = dirtyLevel;
|
645 | }
|
646 | if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
647 | {
|
648 | (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
649 | }
|
650 | effect2.trigger();
|
651 | if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
|
652 | effect2._shouldSchedule = false;
|
653 | if (effect2.scheduler) {
|
654 | queueEffectSchedulers.push(effect2.scheduler);
|
655 | }
|
656 | }
|
657 | }
|
658 | }
|
659 | resetScheduling();
|
660 | }
|
661 |
|
662 | const createDep = (cleanup, computed) => {
|
663 | const dep = new Map();
|
664 | dep.cleanup = cleanup;
|
665 | dep.computed = computed;
|
666 | return dep;
|
667 | };
|
668 |
|
669 | const targetMap = new WeakMap();
|
670 | const ITERATE_KEY = Symbol("iterate" );
|
671 | const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
|
672 | function track(target, type, key) {
|
673 | if (shouldTrack && activeEffect) {
|
674 | let depsMap = targetMap.get(target);
|
675 | if (!depsMap) {
|
676 | targetMap.set(target, depsMap = new Map());
|
677 | }
|
678 | let dep = depsMap.get(key);
|
679 | if (!dep) {
|
680 | depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
|
681 | }
|
682 | trackEffect(
|
683 | activeEffect,
|
684 | dep,
|
685 | {
|
686 | target,
|
687 | type,
|
688 | key
|
689 | }
|
690 | );
|
691 | }
|
692 | }
|
693 | function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
694 | const depsMap = targetMap.get(target);
|
695 | if (!depsMap) {
|
696 | return;
|
697 | }
|
698 | let deps = [];
|
699 | if (type === "clear") {
|
700 | deps = [...depsMap.values()];
|
701 | } else if (key === "length" && isArray(target)) {
|
702 | const newLength = Number(newValue);
|
703 | depsMap.forEach((dep, key2) => {
|
704 | if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
|
705 | deps.push(dep);
|
706 | }
|
707 | });
|
708 | } else {
|
709 | if (key !== void 0) {
|
710 | deps.push(depsMap.get(key));
|
711 | }
|
712 | switch (type) {
|
713 | case "add":
|
714 | if (!isArray(target)) {
|
715 | deps.push(depsMap.get(ITERATE_KEY));
|
716 | if (isMap(target)) {
|
717 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
718 | }
|
719 | } else if (isIntegerKey(key)) {
|
720 | deps.push(depsMap.get("length"));
|
721 | }
|
722 | break;
|
723 | case "delete":
|
724 | if (!isArray(target)) {
|
725 | deps.push(depsMap.get(ITERATE_KEY));
|
726 | if (isMap(target)) {
|
727 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
728 | }
|
729 | }
|
730 | break;
|
731 | case "set":
|
732 | if (isMap(target)) {
|
733 | deps.push(depsMap.get(ITERATE_KEY));
|
734 | }
|
735 | break;
|
736 | }
|
737 | }
|
738 | pauseScheduling();
|
739 | for (const dep of deps) {
|
740 | if (dep) {
|
741 | triggerEffects(
|
742 | dep,
|
743 | 4,
|
744 | {
|
745 | target,
|
746 | type,
|
747 | key,
|
748 | newValue,
|
749 | oldValue,
|
750 | oldTarget
|
751 | }
|
752 | );
|
753 | }
|
754 | }
|
755 | resetScheduling();
|
756 | }
|
757 | function getDepFromReactive(object, key) {
|
758 | var _a;
|
759 | return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
|
760 | }
|
761 |
|
762 | const isNonTrackableKeys = makeMap(`__proto__,__v_isRef,__isVue`);
|
763 | const builtInSymbols = new Set(
|
764 | Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
765 | );
|
766 | const arrayInstrumentations = createArrayInstrumentations();
|
767 | function createArrayInstrumentations() {
|
768 | const instrumentations = {};
|
769 | ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
770 | instrumentations[key] = function(...args) {
|
771 | const arr = toRaw(this);
|
772 | for (let i = 0, l = this.length; i < l; i++) {
|
773 | track(arr, "get", i + "");
|
774 | }
|
775 | const res = arr[key](...args);
|
776 | if (res === -1 || res === false) {
|
777 | return arr[key](...args.map(toRaw));
|
778 | } else {
|
779 | return res;
|
780 | }
|
781 | };
|
782 | });
|
783 | ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
784 | instrumentations[key] = function(...args) {
|
785 | pauseTracking();
|
786 | pauseScheduling();
|
787 | const res = toRaw(this)[key].apply(this, args);
|
788 | resetScheduling();
|
789 | resetTracking();
|
790 | return res;
|
791 | };
|
792 | });
|
793 | return instrumentations;
|
794 | }
|
795 | function hasOwnProperty(key) {
|
796 | const obj = toRaw(this);
|
797 | track(obj, "has", key);
|
798 | return obj.hasOwnProperty(key);
|
799 | }
|
800 | class BaseReactiveHandler {
|
801 | constructor(_isReadonly = false, _shallow = false) {
|
802 | this._isReadonly = _isReadonly;
|
803 | this._shallow = _shallow;
|
804 | }
|
805 | get(target, key, receiver) {
|
806 | const isReadonly2 = this._isReadonly, shallow = this._shallow;
|
807 | if (key === "__v_isReactive") {
|
808 | return !isReadonly2;
|
809 | } else if (key === "__v_isReadonly") {
|
810 | return isReadonly2;
|
811 | } else if (key === "__v_isShallow") {
|
812 | return shallow;
|
813 | } else if (key === "__v_raw") {
|
814 | if (receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target) ||
|
815 |
|
816 | Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
817 | return target;
|
818 | }
|
819 | return;
|
820 | }
|
821 | const targetIsArray = isArray(target);
|
822 | if (!isReadonly2) {
|
823 | if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
824 | return Reflect.get(arrayInstrumentations, key, receiver);
|
825 | }
|
826 | if (key === "hasOwnProperty") {
|
827 | return hasOwnProperty;
|
828 | }
|
829 | }
|
830 | const res = Reflect.get(target, key, receiver);
|
831 | if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
832 | return res;
|
833 | }
|
834 | if (!isReadonly2) {
|
835 | track(target, "get", key);
|
836 | }
|
837 | if (shallow) {
|
838 | return res;
|
839 | }
|
840 | if (isRef(res)) {
|
841 | return targetIsArray && isIntegerKey(key) ? res : res.value;
|
842 | }
|
843 | if (isObject(res)) {
|
844 | return isReadonly2 ? readonly(res) : reactive(res);
|
845 | }
|
846 | return res;
|
847 | }
|
848 | }
|
849 | class MutableReactiveHandler extends BaseReactiveHandler {
|
850 | constructor(shallow = false) {
|
851 | super(false, shallow);
|
852 | }
|
853 | set(target, key, value, receiver) {
|
854 | let oldValue = target[key];
|
855 | if (!this._shallow) {
|
856 | const isOldValueReadonly = isReadonly(oldValue);
|
857 | if (!isShallow(value) && !isReadonly(value)) {
|
858 | oldValue = toRaw(oldValue);
|
859 | value = toRaw(value);
|
860 | }
|
861 | if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
862 | if (isOldValueReadonly) {
|
863 | return false;
|
864 | } else {
|
865 | oldValue.value = value;
|
866 | return true;
|
867 | }
|
868 | }
|
869 | }
|
870 | const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
871 | const result = Reflect.set(target, key, value, receiver);
|
872 | if (target === toRaw(receiver)) {
|
873 | if (!hadKey) {
|
874 | trigger(target, "add", key, value);
|
875 | } else if (hasChanged(value, oldValue)) {
|
876 | trigger(target, "set", key, value, oldValue);
|
877 | }
|
878 | }
|
879 | return result;
|
880 | }
|
881 | deleteProperty(target, key) {
|
882 | const hadKey = hasOwn(target, key);
|
883 | const oldValue = target[key];
|
884 | const result = Reflect.deleteProperty(target, key);
|
885 | if (result && hadKey) {
|
886 | trigger(target, "delete", key, void 0, oldValue);
|
887 | }
|
888 | return result;
|
889 | }
|
890 | has(target, key) {
|
891 | const result = Reflect.has(target, key);
|
892 | if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
893 | track(target, "has", key);
|
894 | }
|
895 | return result;
|
896 | }
|
897 | ownKeys(target) {
|
898 | track(
|
899 | target,
|
900 | "iterate",
|
901 | isArray(target) ? "length" : ITERATE_KEY
|
902 | );
|
903 | return Reflect.ownKeys(target);
|
904 | }
|
905 | }
|
906 | class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
907 | constructor(shallow = false) {
|
908 | super(true, shallow);
|
909 | }
|
910 | set(target, key) {
|
911 | {
|
912 | warn$2(
|
913 | `Set operation on key "${String(key)}" failed: target is readonly.`,
|
914 | target
|
915 | );
|
916 | }
|
917 | return true;
|
918 | }
|
919 | deleteProperty(target, key) {
|
920 | {
|
921 | warn$2(
|
922 | `Delete operation on key "${String(key)}" failed: target is readonly.`,
|
923 | target
|
924 | );
|
925 | }
|
926 | return true;
|
927 | }
|
928 | }
|
929 | const mutableHandlers = new MutableReactiveHandler();
|
930 | const readonlyHandlers = new ReadonlyReactiveHandler();
|
931 | const shallowReactiveHandlers = new MutableReactiveHandler(
|
932 | true
|
933 | );
|
934 | const shallowReadonlyHandlers = new ReadonlyReactiveHandler(true);
|
935 |
|
936 | const toShallow = (value) => value;
|
937 | const getProto = (v) => Reflect.getPrototypeOf(v);
|
938 | function get(target, key, isReadonly = false, isShallow = false) {
|
939 | target = target["__v_raw"];
|
940 | const rawTarget = toRaw(target);
|
941 | const rawKey = toRaw(key);
|
942 | if (!isReadonly) {
|
943 | if (hasChanged(key, rawKey)) {
|
944 | track(rawTarget, "get", key);
|
945 | }
|
946 | track(rawTarget, "get", rawKey);
|
947 | }
|
948 | const { has: has2 } = getProto(rawTarget);
|
949 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
950 | if (has2.call(rawTarget, key)) {
|
951 | return wrap(target.get(key));
|
952 | } else if (has2.call(rawTarget, rawKey)) {
|
953 | return wrap(target.get(rawKey));
|
954 | } else if (target !== rawTarget) {
|
955 | target.get(key);
|
956 | }
|
957 | }
|
958 | function has(key, isReadonly = false) {
|
959 | const target = this["__v_raw"];
|
960 | const rawTarget = toRaw(target);
|
961 | const rawKey = toRaw(key);
|
962 | if (!isReadonly) {
|
963 | if (hasChanged(key, rawKey)) {
|
964 | track(rawTarget, "has", key);
|
965 | }
|
966 | track(rawTarget, "has", rawKey);
|
967 | }
|
968 | return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
969 | }
|
970 | function size(target, isReadonly = false) {
|
971 | target = target["__v_raw"];
|
972 | !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY);
|
973 | return Reflect.get(target, "size", target);
|
974 | }
|
975 | function add(value) {
|
976 | value = toRaw(value);
|
977 | const target = toRaw(this);
|
978 | const proto = getProto(target);
|
979 | const hadKey = proto.has.call(target, value);
|
980 | if (!hadKey) {
|
981 | target.add(value);
|
982 | trigger(target, "add", value, value);
|
983 | }
|
984 | return this;
|
985 | }
|
986 | function set(key, value) {
|
987 | value = toRaw(value);
|
988 | const target = toRaw(this);
|
989 | const { has: has2, get: get2 } = getProto(target);
|
990 | let hadKey = has2.call(target, key);
|
991 | if (!hadKey) {
|
992 | key = toRaw(key);
|
993 | hadKey = has2.call(target, key);
|
994 | } else {
|
995 | checkIdentityKeys(target, has2, key);
|
996 | }
|
997 | const oldValue = get2.call(target, key);
|
998 | target.set(key, value);
|
999 | if (!hadKey) {
|
1000 | trigger(target, "add", key, value);
|
1001 | } else if (hasChanged(value, oldValue)) {
|
1002 | trigger(target, "set", key, value, oldValue);
|
1003 | }
|
1004 | return this;
|
1005 | }
|
1006 | function deleteEntry(key) {
|
1007 | const target = toRaw(this);
|
1008 | const { has: has2, get: get2 } = getProto(target);
|
1009 | let hadKey = has2.call(target, key);
|
1010 | if (!hadKey) {
|
1011 | key = toRaw(key);
|
1012 | hadKey = has2.call(target, key);
|
1013 | } else {
|
1014 | checkIdentityKeys(target, has2, key);
|
1015 | }
|
1016 | const oldValue = get2 ? get2.call(target, key) : void 0;
|
1017 | const result = target.delete(key);
|
1018 | if (hadKey) {
|
1019 | trigger(target, "delete", key, void 0, oldValue);
|
1020 | }
|
1021 | return result;
|
1022 | }
|
1023 | function clear() {
|
1024 | const target = toRaw(this);
|
1025 | const hadItems = target.size !== 0;
|
1026 | const oldTarget = isMap(target) ? new Map(target) : new Set(target) ;
|
1027 | const result = target.clear();
|
1028 | if (hadItems) {
|
1029 | trigger(target, "clear", void 0, void 0, oldTarget);
|
1030 | }
|
1031 | return result;
|
1032 | }
|
1033 | function createForEach(isReadonly, isShallow) {
|
1034 | return function forEach(callback, thisArg) {
|
1035 | const observed = this;
|
1036 | const target = observed["__v_raw"];
|
1037 | const rawTarget = toRaw(target);
|
1038 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
1039 | !isReadonly && track(rawTarget, "iterate", ITERATE_KEY);
|
1040 | return target.forEach((value, key) => {
|
1041 | return callback.call(thisArg, wrap(value), wrap(key), observed);
|
1042 | });
|
1043 | };
|
1044 | }
|
1045 | function createIterableMethod(method, isReadonly, isShallow) {
|
1046 | return function(...args) {
|
1047 | const target = this["__v_raw"];
|
1048 | const rawTarget = toRaw(target);
|
1049 | const targetIsMap = isMap(rawTarget);
|
1050 | const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
1051 | const isKeyOnly = method === "keys" && targetIsMap;
|
1052 | const innerIterator = target[method](...args);
|
1053 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
1054 | !isReadonly && track(
|
1055 | rawTarget,
|
1056 | "iterate",
|
1057 | isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
1058 | );
|
1059 | return {
|
1060 |
|
1061 | next() {
|
1062 | const { value, done } = innerIterator.next();
|
1063 | return done ? { value, done } : {
|
1064 | value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
1065 | done
|
1066 | };
|
1067 | },
|
1068 |
|
1069 | [Symbol.iterator]() {
|
1070 | return this;
|
1071 | }
|
1072 | };
|
1073 | };
|
1074 | }
|
1075 | function createReadonlyMethod(type) {
|
1076 | return function(...args) {
|
1077 | {
|
1078 | const key = args[0] ? `on key "${args[0]}" ` : ``;
|
1079 | console.warn(
|
1080 | `${capitalize(type)} operation ${key}failed: target is readonly.`,
|
1081 | toRaw(this)
|
1082 | );
|
1083 | }
|
1084 | return type === "delete" ? false : type === "clear" ? void 0 : this;
|
1085 | };
|
1086 | }
|
1087 | function createInstrumentations() {
|
1088 | const mutableInstrumentations2 = {
|
1089 | get(key) {
|
1090 | return get(this, key);
|
1091 | },
|
1092 | get size() {
|
1093 | return size(this);
|
1094 | },
|
1095 | has,
|
1096 | add,
|
1097 | set,
|
1098 | delete: deleteEntry,
|
1099 | clear,
|
1100 | forEach: createForEach(false, false)
|
1101 | };
|
1102 | const shallowInstrumentations2 = {
|
1103 | get(key) {
|
1104 | return get(this, key, false, true);
|
1105 | },
|
1106 | get size() {
|
1107 | return size(this);
|
1108 | },
|
1109 | has,
|
1110 | add,
|
1111 | set,
|
1112 | delete: deleteEntry,
|
1113 | clear,
|
1114 | forEach: createForEach(false, true)
|
1115 | };
|
1116 | const readonlyInstrumentations2 = {
|
1117 | get(key) {
|
1118 | return get(this, key, true);
|
1119 | },
|
1120 | get size() {
|
1121 | return size(this, true);
|
1122 | },
|
1123 | has(key) {
|
1124 | return has.call(this, key, true);
|
1125 | },
|
1126 | add: createReadonlyMethod("add"),
|
1127 | set: createReadonlyMethod("set"),
|
1128 | delete: createReadonlyMethod("delete"),
|
1129 | clear: createReadonlyMethod("clear"),
|
1130 | forEach: createForEach(true, false)
|
1131 | };
|
1132 | const shallowReadonlyInstrumentations2 = {
|
1133 | get(key) {
|
1134 | return get(this, key, true, true);
|
1135 | },
|
1136 | get size() {
|
1137 | return size(this, true);
|
1138 | },
|
1139 | has(key) {
|
1140 | return has.call(this, key, true);
|
1141 | },
|
1142 | add: createReadonlyMethod("add"),
|
1143 | set: createReadonlyMethod("set"),
|
1144 | delete: createReadonlyMethod("delete"),
|
1145 | clear: createReadonlyMethod("clear"),
|
1146 | forEach: createForEach(true, true)
|
1147 | };
|
1148 | const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
|
1149 | iteratorMethods.forEach((method) => {
|
1150 | mutableInstrumentations2[method] = createIterableMethod(
|
1151 | method,
|
1152 | false,
|
1153 | false
|
1154 | );
|
1155 | readonlyInstrumentations2[method] = createIterableMethod(
|
1156 | method,
|
1157 | true,
|
1158 | false
|
1159 | );
|
1160 | shallowInstrumentations2[method] = createIterableMethod(
|
1161 | method,
|
1162 | false,
|
1163 | true
|
1164 | );
|
1165 | shallowReadonlyInstrumentations2[method] = createIterableMethod(
|
1166 | method,
|
1167 | true,
|
1168 | true
|
1169 | );
|
1170 | });
|
1171 | return [
|
1172 | mutableInstrumentations2,
|
1173 | readonlyInstrumentations2,
|
1174 | shallowInstrumentations2,
|
1175 | shallowReadonlyInstrumentations2
|
1176 | ];
|
1177 | }
|
1178 | const [
|
1179 | mutableInstrumentations,
|
1180 | readonlyInstrumentations,
|
1181 | shallowInstrumentations,
|
1182 | shallowReadonlyInstrumentations
|
1183 | ] = createInstrumentations();
|
1184 | function createInstrumentationGetter(isReadonly, shallow) {
|
1185 | const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations;
|
1186 | return (target, key, receiver) => {
|
1187 | if (key === "__v_isReactive") {
|
1188 | return !isReadonly;
|
1189 | } else if (key === "__v_isReadonly") {
|
1190 | return isReadonly;
|
1191 | } else if (key === "__v_raw") {
|
1192 | return target;
|
1193 | }
|
1194 | return Reflect.get(
|
1195 | hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
1196 | key,
|
1197 | receiver
|
1198 | );
|
1199 | };
|
1200 | }
|
1201 | const mutableCollectionHandlers = {
|
1202 | get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
1203 | };
|
1204 | const shallowCollectionHandlers = {
|
1205 | get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
1206 | };
|
1207 | const readonlyCollectionHandlers = {
|
1208 | get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
1209 | };
|
1210 | const shallowReadonlyCollectionHandlers = {
|
1211 | get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
1212 | };
|
1213 | function checkIdentityKeys(target, has2, key) {
|
1214 | const rawKey = toRaw(key);
|
1215 | if (rawKey !== key && has2.call(target, rawKey)) {
|
1216 | const type = toRawType(target);
|
1217 | console.warn(
|
1218 | `Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
|
1219 | );
|
1220 | }
|
1221 | }
|
1222 |
|
1223 | const reactiveMap = new WeakMap();
|
1224 | const shallowReactiveMap = new WeakMap();
|
1225 | const readonlyMap = new WeakMap();
|
1226 | const shallowReadonlyMap = new WeakMap();
|
1227 | function targetTypeMap(rawType) {
|
1228 | switch (rawType) {
|
1229 | case "Object":
|
1230 | case "Array":
|
1231 | return 1 ;
|
1232 | case "Map":
|
1233 | case "Set":
|
1234 | case "WeakMap":
|
1235 | case "WeakSet":
|
1236 | return 2 ;
|
1237 | default:
|
1238 | return 0 ;
|
1239 | }
|
1240 | }
|
1241 | function getTargetType(value) {
|
1242 | return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
1243 | }
|
1244 | function reactive(target) {
|
1245 | if (isReadonly(target)) {
|
1246 | return target;
|
1247 | }
|
1248 | return createReactiveObject(
|
1249 | target,
|
1250 | false,
|
1251 | mutableHandlers,
|
1252 | mutableCollectionHandlers,
|
1253 | reactiveMap
|
1254 | );
|
1255 | }
|
1256 | function shallowReactive(target) {
|
1257 | return createReactiveObject(
|
1258 | target,
|
1259 | false,
|
1260 | shallowReactiveHandlers,
|
1261 | shallowCollectionHandlers,
|
1262 | shallowReactiveMap
|
1263 | );
|
1264 | }
|
1265 | function readonly(target) {
|
1266 | return createReactiveObject(
|
1267 | target,
|
1268 | true,
|
1269 | readonlyHandlers,
|
1270 | readonlyCollectionHandlers,
|
1271 | readonlyMap
|
1272 | );
|
1273 | }
|
1274 | function shallowReadonly(target) {
|
1275 | return createReactiveObject(
|
1276 | target,
|
1277 | true,
|
1278 | shallowReadonlyHandlers,
|
1279 | shallowReadonlyCollectionHandlers,
|
1280 | shallowReadonlyMap
|
1281 | );
|
1282 | }
|
1283 | function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
1284 | if (!isObject(target)) {
|
1285 | {
|
1286 | console.warn(`value cannot be made reactive: ${String(target)}`);
|
1287 | }
|
1288 | return target;
|
1289 | }
|
1290 | if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
1291 | return target;
|
1292 | }
|
1293 | const existingProxy = proxyMap.get(target);
|
1294 | if (existingProxy) {
|
1295 | return existingProxy;
|
1296 | }
|
1297 | const targetType = getTargetType(target);
|
1298 | if (targetType === 0 ) {
|
1299 | return target;
|
1300 | }
|
1301 | const proxy = new Proxy(
|
1302 | target,
|
1303 | targetType === 2 ? collectionHandlers : baseHandlers
|
1304 | );
|
1305 | proxyMap.set(target, proxy);
|
1306 | return proxy;
|
1307 | }
|
1308 | function isReactive(value) {
|
1309 | if (isReadonly(value)) {
|
1310 | return isReactive(value["__v_raw"]);
|
1311 | }
|
1312 | return !!(value && value["__v_isReactive"]);
|
1313 | }
|
1314 | function isReadonly(value) {
|
1315 | return !!(value && value["__v_isReadonly"]);
|
1316 | }
|
1317 | function isShallow(value) {
|
1318 | return !!(value && value["__v_isShallow"]);
|
1319 | }
|
1320 | function isProxy(value) {
|
1321 | return isReactive(value) || isReadonly(value);
|
1322 | }
|
1323 | function toRaw(observed) {
|
1324 | const raw = observed && observed["__v_raw"];
|
1325 | return raw ? toRaw(raw) : observed;
|
1326 | }
|
1327 | function markRaw(value) {
|
1328 | if (Object.isExtensible(value)) {
|
1329 | def(value, "__v_skip", true);
|
1330 | }
|
1331 | return value;
|
1332 | }
|
1333 | const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
1334 | const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
1335 |
|
1336 | const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`;
|
1337 | class ComputedRefImpl {
|
1338 | constructor(getter, _setter, isReadonly, isSSR) {
|
1339 | this._setter = _setter;
|
1340 | this.dep = void 0;
|
1341 | this.__v_isRef = true;
|
1342 | this["__v_isReadonly"] = false;
|
1343 | this.effect = new ReactiveEffect(
|
1344 | () => getter(this._value),
|
1345 | () => triggerRefValue(
|
1346 | this,
|
1347 | this.effect._dirtyLevel === 2 ? 2 : 3
|
1348 | )
|
1349 | );
|
1350 | this.effect.computed = this;
|
1351 | this.effect.active = this._cacheable = !isSSR;
|
1352 | this["__v_isReadonly"] = isReadonly;
|
1353 | }
|
1354 | get value() {
|
1355 | const self = toRaw(this);
|
1356 | if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
|
1357 | triggerRefValue(self, 4);
|
1358 | }
|
1359 | trackRefValue(self);
|
1360 | if (self.effect._dirtyLevel >= 2) {
|
1361 | warn$2(COMPUTED_SIDE_EFFECT_WARN);
|
1362 | triggerRefValue(self, 2);
|
1363 | }
|
1364 | return self._value;
|
1365 | }
|
1366 | set value(newValue) {
|
1367 | this._setter(newValue);
|
1368 | }
|
1369 |
|
1370 | get _dirty() {
|
1371 | return this.effect.dirty;
|
1372 | }
|
1373 | set _dirty(v) {
|
1374 | this.effect.dirty = v;
|
1375 | }
|
1376 |
|
1377 | }
|
1378 | function computed$1(getterOrOptions, debugOptions, isSSR = false) {
|
1379 | let getter;
|
1380 | let setter;
|
1381 | const onlyGetter = isFunction(getterOrOptions);
|
1382 | if (onlyGetter) {
|
1383 | getter = getterOrOptions;
|
1384 | setter = () => {
|
1385 | warn$2("Write operation failed: computed value is readonly");
|
1386 | } ;
|
1387 | } else {
|
1388 | getter = getterOrOptions.get;
|
1389 | setter = getterOrOptions.set;
|
1390 | }
|
1391 | const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
1392 | if (debugOptions && !isSSR) {
|
1393 | cRef.effect.onTrack = debugOptions.onTrack;
|
1394 | cRef.effect.onTrigger = debugOptions.onTrigger;
|
1395 | }
|
1396 | return cRef;
|
1397 | }
|
1398 |
|
1399 | function trackRefValue(ref2) {
|
1400 | var _a;
|
1401 | if (shouldTrack && activeEffect) {
|
1402 | ref2 = toRaw(ref2);
|
1403 | trackEffect(
|
1404 | activeEffect,
|
1405 | (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
|
1406 | () => ref2.dep = void 0,
|
1407 | ref2 instanceof ComputedRefImpl ? ref2 : void 0
|
1408 | ),
|
1409 | {
|
1410 | target: ref2,
|
1411 | type: "get",
|
1412 | key: "value"
|
1413 | }
|
1414 | );
|
1415 | }
|
1416 | }
|
1417 | function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
|
1418 | ref2 = toRaw(ref2);
|
1419 | const dep = ref2.dep;
|
1420 | if (dep) {
|
1421 | triggerEffects(
|
1422 | dep,
|
1423 | dirtyLevel,
|
1424 | {
|
1425 | target: ref2,
|
1426 | type: "set",
|
1427 | key: "value",
|
1428 | newValue: newVal
|
1429 | }
|
1430 | );
|
1431 | }
|
1432 | }
|
1433 | function isRef(r) {
|
1434 | return !!(r && r.__v_isRef === true);
|
1435 | }
|
1436 | function ref(value) {
|
1437 | return createRef(value, false);
|
1438 | }
|
1439 | function shallowRef(value) {
|
1440 | return createRef(value, true);
|
1441 | }
|
1442 | function createRef(rawValue, shallow) {
|
1443 | if (isRef(rawValue)) {
|
1444 | return rawValue;
|
1445 | }
|
1446 | return new RefImpl(rawValue, shallow);
|
1447 | }
|
1448 | class RefImpl {
|
1449 | constructor(value, __v_isShallow) {
|
1450 | this.__v_isShallow = __v_isShallow;
|
1451 | this.dep = void 0;
|
1452 | this.__v_isRef = true;
|
1453 | this._rawValue = __v_isShallow ? value : toRaw(value);
|
1454 | this._value = __v_isShallow ? value : toReactive(value);
|
1455 | }
|
1456 | get value() {
|
1457 | trackRefValue(this);
|
1458 | return this._value;
|
1459 | }
|
1460 | set value(newVal) {
|
1461 | const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
|
1462 | newVal = useDirectValue ? newVal : toRaw(newVal);
|
1463 | if (hasChanged(newVal, this._rawValue)) {
|
1464 | this._rawValue = newVal;
|
1465 | this._value = useDirectValue ? newVal : toReactive(newVal);
|
1466 | triggerRefValue(this, 4, newVal);
|
1467 | }
|
1468 | }
|
1469 | }
|
1470 | function triggerRef(ref2) {
|
1471 | triggerRefValue(ref2, 4, ref2.value );
|
1472 | }
|
1473 | function unref(ref2) {
|
1474 | return isRef(ref2) ? ref2.value : ref2;
|
1475 | }
|
1476 | function toValue(source) {
|
1477 | return isFunction(source) ? source() : unref(source);
|
1478 | }
|
1479 | const shallowUnwrapHandlers = {
|
1480 | get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
1481 | set: (target, key, value, receiver) => {
|
1482 | const oldValue = target[key];
|
1483 | if (isRef(oldValue) && !isRef(value)) {
|
1484 | oldValue.value = value;
|
1485 | return true;
|
1486 | } else {
|
1487 | return Reflect.set(target, key, value, receiver);
|
1488 | }
|
1489 | }
|
1490 | };
|
1491 | function proxyRefs(objectWithRefs) {
|
1492 | return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
1493 | }
|
1494 | class CustomRefImpl {
|
1495 | constructor(factory) {
|
1496 | this.dep = void 0;
|
1497 | this.__v_isRef = true;
|
1498 | const { get, set } = factory(
|
1499 | () => trackRefValue(this),
|
1500 | () => triggerRefValue(this)
|
1501 | );
|
1502 | this._get = get;
|
1503 | this._set = set;
|
1504 | }
|
1505 | get value() {
|
1506 | return this._get();
|
1507 | }
|
1508 | set value(newVal) {
|
1509 | this._set(newVal);
|
1510 | }
|
1511 | }
|
1512 | function customRef(factory) {
|
1513 | return new CustomRefImpl(factory);
|
1514 | }
|
1515 | function toRefs(object) {
|
1516 | if (!isProxy(object)) {
|
1517 | console.warn(`toRefs() expects a reactive object but received a plain one.`);
|
1518 | }
|
1519 | const ret = isArray(object) ? new Array(object.length) : {};
|
1520 | for (const key in object) {
|
1521 | ret[key] = propertyToRef(object, key);
|
1522 | }
|
1523 | return ret;
|
1524 | }
|
1525 | class ObjectRefImpl {
|
1526 | constructor(_object, _key, _defaultValue) {
|
1527 | this._object = _object;
|
1528 | this._key = _key;
|
1529 | this._defaultValue = _defaultValue;
|
1530 | this.__v_isRef = true;
|
1531 | }
|
1532 | get value() {
|
1533 | const val = this._object[this._key];
|
1534 | return val === void 0 ? this._defaultValue : val;
|
1535 | }
|
1536 | set value(newVal) {
|
1537 | this._object[this._key] = newVal;
|
1538 | }
|
1539 | get dep() {
|
1540 | return getDepFromReactive(toRaw(this._object), this._key);
|
1541 | }
|
1542 | }
|
1543 | class GetterRefImpl {
|
1544 | constructor(_getter) {
|
1545 | this._getter = _getter;
|
1546 | this.__v_isRef = true;
|
1547 | this.__v_isReadonly = true;
|
1548 | }
|
1549 | get value() {
|
1550 | return this._getter();
|
1551 | }
|
1552 | }
|
1553 | function toRef(source, key, defaultValue) {
|
1554 | if (isRef(source)) {
|
1555 | return source;
|
1556 | } else if (isFunction(source)) {
|
1557 | return new GetterRefImpl(source);
|
1558 | } else if (isObject(source) && arguments.length > 1) {
|
1559 | return propertyToRef(source, key, defaultValue);
|
1560 | } else {
|
1561 | return ref(source);
|
1562 | }
|
1563 | }
|
1564 | function propertyToRef(source, key, defaultValue) {
|
1565 | const val = source[key];
|
1566 | return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
1567 | }
|
1568 |
|
1569 | const TrackOpTypes = {
|
1570 | "GET": "get",
|
1571 | "HAS": "has",
|
1572 | "ITERATE": "iterate"
|
1573 | };
|
1574 | const TriggerOpTypes = {
|
1575 | "SET": "set",
|
1576 | "ADD": "add",
|
1577 | "DELETE": "delete",
|
1578 | "CLEAR": "clear"
|
1579 | };
|
1580 |
|
1581 | const stack$1 = [];
|
1582 | function pushWarningContext(vnode) {
|
1583 | stack$1.push(vnode);
|
1584 | }
|
1585 | function popWarningContext() {
|
1586 | stack$1.pop();
|
1587 | }
|
1588 | function warn$1(msg, ...args) {
|
1589 | pauseTracking();
|
1590 | const instance = stack$1.length ? stack$1[stack$1.length - 1].component : null;
|
1591 | const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
1592 | const trace = getComponentTrace();
|
1593 | if (appWarnHandler) {
|
1594 | callWithErrorHandling(
|
1595 | appWarnHandler,
|
1596 | instance,
|
1597 | 11,
|
1598 | [
|
1599 | msg + args.join(""),
|
1600 | instance && instance.proxy,
|
1601 | trace.map(
|
1602 | ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
|
1603 | ).join("\n"),
|
1604 | trace
|
1605 | ]
|
1606 | );
|
1607 | } else {
|
1608 | const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
1609 | if (trace.length &&
|
1610 | true) {
|
1611 | warnArgs.push(`
|
1612 | `, ...formatTrace(trace));
|
1613 | }
|
1614 | console.warn(...warnArgs);
|
1615 | }
|
1616 | resetTracking();
|
1617 | }
|
1618 | function getComponentTrace() {
|
1619 | let currentVNode = stack$1[stack$1.length - 1];
|
1620 | if (!currentVNode) {
|
1621 | return [];
|
1622 | }
|
1623 | const normalizedStack = [];
|
1624 | while (currentVNode) {
|
1625 | const last = normalizedStack[0];
|
1626 | if (last && last.vnode === currentVNode) {
|
1627 | last.recurseCount++;
|
1628 | } else {
|
1629 | normalizedStack.push({
|
1630 | vnode: currentVNode,
|
1631 | recurseCount: 0
|
1632 | });
|
1633 | }
|
1634 | const parentInstance = currentVNode.component && currentVNode.component.parent;
|
1635 | currentVNode = parentInstance && parentInstance.vnode;
|
1636 | }
|
1637 | return normalizedStack;
|
1638 | }
|
1639 | function formatTrace(trace) {
|
1640 | const logs = [];
|
1641 | trace.forEach((entry, i) => {
|
1642 | logs.push(...i === 0 ? [] : [`
|
1643 | `], ...formatTraceEntry(entry));
|
1644 | });
|
1645 | return logs;
|
1646 | }
|
1647 | function formatTraceEntry({ vnode, recurseCount }) {
|
1648 | const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
1649 | const isRoot = vnode.component ? vnode.component.parent == null : false;
|
1650 | const open = ` at <${formatComponentName(
|
1651 | vnode.component,
|
1652 | vnode.type,
|
1653 | isRoot
|
1654 | )}`;
|
1655 | const close = `>` + postfix;
|
1656 | return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
|
1657 | }
|
1658 | function formatProps(props) {
|
1659 | const res = [];
|
1660 | const keys = Object.keys(props);
|
1661 | keys.slice(0, 3).forEach((key) => {
|
1662 | res.push(...formatProp(key, props[key]));
|
1663 | });
|
1664 | if (keys.length > 3) {
|
1665 | res.push(` ...`);
|
1666 | }
|
1667 | return res;
|
1668 | }
|
1669 | function formatProp(key, value, raw) {
|
1670 | if (isString(value)) {
|
1671 | value = JSON.stringify(value);
|
1672 | return raw ? value : [`${key}=${value}`];
|
1673 | } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
1674 | return raw ? value : [`${key}=${value}`];
|
1675 | } else if (isRef(value)) {
|
1676 | value = formatProp(key, toRaw(value.value), true);
|
1677 | return raw ? value : [`${key}=Ref<`, value, `>`];
|
1678 | } else if (isFunction(value)) {
|
1679 | return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
1680 | } else {
|
1681 | value = toRaw(value);
|
1682 | return raw ? value : [`${key}=`, value];
|
1683 | }
|
1684 | }
|
1685 | function assertNumber(val, type) {
|
1686 | if (val === void 0) {
|
1687 | return;
|
1688 | } else if (typeof val !== "number") {
|
1689 | warn$1(`${type} is not a valid number - got ${JSON.stringify(val)}.`);
|
1690 | } else if (isNaN(val)) {
|
1691 | warn$1(`${type} is NaN - the duration expression might be incorrect.`);
|
1692 | }
|
1693 | }
|
1694 |
|
1695 | const ErrorCodes = {
|
1696 | "SETUP_FUNCTION": 0,
|
1697 | "0": "SETUP_FUNCTION",
|
1698 | "RENDER_FUNCTION": 1,
|
1699 | "1": "RENDER_FUNCTION",
|
1700 | "WATCH_GETTER": 2,
|
1701 | "2": "WATCH_GETTER",
|
1702 | "WATCH_CALLBACK": 3,
|
1703 | "3": "WATCH_CALLBACK",
|
1704 | "WATCH_CLEANUP": 4,
|
1705 | "4": "WATCH_CLEANUP",
|
1706 | "NATIVE_EVENT_HANDLER": 5,
|
1707 | "5": "NATIVE_EVENT_HANDLER",
|
1708 | "COMPONENT_EVENT_HANDLER": 6,
|
1709 | "6": "COMPONENT_EVENT_HANDLER",
|
1710 | "VNODE_HOOK": 7,
|
1711 | "7": "VNODE_HOOK",
|
1712 | "DIRECTIVE_HOOK": 8,
|
1713 | "8": "DIRECTIVE_HOOK",
|
1714 | "TRANSITION_HOOK": 9,
|
1715 | "9": "TRANSITION_HOOK",
|
1716 | "APP_ERROR_HANDLER": 10,
|
1717 | "10": "APP_ERROR_HANDLER",
|
1718 | "APP_WARN_HANDLER": 11,
|
1719 | "11": "APP_WARN_HANDLER",
|
1720 | "FUNCTION_REF": 12,
|
1721 | "12": "FUNCTION_REF",
|
1722 | "ASYNC_COMPONENT_LOADER": 13,
|
1723 | "13": "ASYNC_COMPONENT_LOADER",
|
1724 | "SCHEDULER": 14,
|
1725 | "14": "SCHEDULER"
|
1726 | };
|
1727 | const ErrorTypeStrings$1 = {
|
1728 | ["sp"]: "serverPrefetch hook",
|
1729 | ["bc"]: "beforeCreate hook",
|
1730 | ["c"]: "created hook",
|
1731 | ["bm"]: "beforeMount hook",
|
1732 | ["m"]: "mounted hook",
|
1733 | ["bu"]: "beforeUpdate hook",
|
1734 | ["u"]: "updated",
|
1735 | ["bum"]: "beforeUnmount hook",
|
1736 | ["um"]: "unmounted hook",
|
1737 | ["a"]: "activated hook",
|
1738 | ["da"]: "deactivated hook",
|
1739 | ["ec"]: "errorCaptured hook",
|
1740 | ["rtc"]: "renderTracked hook",
|
1741 | ["rtg"]: "renderTriggered hook",
|
1742 | [0]: "setup function",
|
1743 | [1]: "render function",
|
1744 | [2]: "watcher getter",
|
1745 | [3]: "watcher callback",
|
1746 | [4]: "watcher cleanup function",
|
1747 | [5]: "native event handler",
|
1748 | [6]: "component event handler",
|
1749 | [7]: "vnode hook",
|
1750 | [8]: "directive hook",
|
1751 | [9]: "transition hook",
|
1752 | [10]: "app errorHandler",
|
1753 | [11]: "app warnHandler",
|
1754 | [12]: "ref function",
|
1755 | [13]: "async component loader",
|
1756 | [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
|
1757 | };
|
1758 | function callWithErrorHandling(fn, instance, type, args) {
|
1759 | try {
|
1760 | return args ? fn(...args) : fn();
|
1761 | } catch (err) {
|
1762 | handleError(err, instance, type);
|
1763 | }
|
1764 | }
|
1765 | function callWithAsyncErrorHandling(fn, instance, type, args) {
|
1766 | if (isFunction(fn)) {
|
1767 | const res = callWithErrorHandling(fn, instance, type, args);
|
1768 | if (res && isPromise(res)) {
|
1769 | res.catch((err) => {
|
1770 | handleError(err, instance, type);
|
1771 | });
|
1772 | }
|
1773 | return res;
|
1774 | }
|
1775 | const values = [];
|
1776 | for (let i = 0; i < fn.length; i++) {
|
1777 | values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
1778 | }
|
1779 | return values;
|
1780 | }
|
1781 | function handleError(err, instance, type, throwInDev = true) {
|
1782 | const contextVNode = instance ? instance.vnode : null;
|
1783 | if (instance) {
|
1784 | let cur = instance.parent;
|
1785 | const exposedInstance = instance.proxy;
|
1786 | const errorInfo = ErrorTypeStrings$1[type] ;
|
1787 | while (cur) {
|
1788 | const errorCapturedHooks = cur.ec;
|
1789 | if (errorCapturedHooks) {
|
1790 | for (let i = 0; i < errorCapturedHooks.length; i++) {
|
1791 | if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
1792 | return;
|
1793 | }
|
1794 | }
|
1795 | }
|
1796 | cur = cur.parent;
|
1797 | }
|
1798 | const appErrorHandler = instance.appContext.config.errorHandler;
|
1799 | if (appErrorHandler) {
|
1800 | callWithErrorHandling(
|
1801 | appErrorHandler,
|
1802 | null,
|
1803 | 10,
|
1804 | [err, exposedInstance, errorInfo]
|
1805 | );
|
1806 | return;
|
1807 | }
|
1808 | }
|
1809 | logError(err, type, contextVNode, throwInDev);
|
1810 | }
|
1811 | function logError(err, type, contextVNode, throwInDev = true) {
|
1812 | {
|
1813 | const info = ErrorTypeStrings$1[type];
|
1814 | if (contextVNode) {
|
1815 | pushWarningContext(contextVNode);
|
1816 | }
|
1817 | warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
1818 | if (contextVNode) {
|
1819 | popWarningContext();
|
1820 | }
|
1821 | if (throwInDev) {
|
1822 | throw err;
|
1823 | } else {
|
1824 | console.error(err);
|
1825 | }
|
1826 | }
|
1827 | }
|
1828 |
|
1829 | let isFlushing = false;
|
1830 | let isFlushPending = false;
|
1831 | const queue = [];
|
1832 | let flushIndex = 0;
|
1833 | const pendingPostFlushCbs = [];
|
1834 | let activePostFlushCbs = null;
|
1835 | let postFlushIndex = 0;
|
1836 | const resolvedPromise = Promise.resolve();
|
1837 | let currentFlushPromise = null;
|
1838 | const RECURSION_LIMIT = 100;
|
1839 | function nextTick(fn) {
|
1840 | const p = currentFlushPromise || resolvedPromise;
|
1841 | return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
1842 | }
|
1843 | function findInsertionIndex(id) {
|
1844 | let start = flushIndex + 1;
|
1845 | let end = queue.length;
|
1846 | while (start < end) {
|
1847 | const middle = start + end >>> 1;
|
1848 | const middleJob = queue[middle];
|
1849 | const middleJobId = getId(middleJob);
|
1850 | if (middleJobId < id || middleJobId === id && middleJob.pre) {
|
1851 | start = middle + 1;
|
1852 | } else {
|
1853 | end = middle;
|
1854 | }
|
1855 | }
|
1856 | return start;
|
1857 | }
|
1858 | function queueJob(job) {
|
1859 | if (!queue.length || !queue.includes(
|
1860 | job,
|
1861 | isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
|
1862 | )) {
|
1863 | if (job.id == null) {
|
1864 | queue.push(job);
|
1865 | } else {
|
1866 | queue.splice(findInsertionIndex(job.id), 0, job);
|
1867 | }
|
1868 | queueFlush();
|
1869 | }
|
1870 | }
|
1871 | function queueFlush() {
|
1872 | if (!isFlushing && !isFlushPending) {
|
1873 | isFlushPending = true;
|
1874 | currentFlushPromise = resolvedPromise.then(flushJobs);
|
1875 | }
|
1876 | }
|
1877 | function invalidateJob(job) {
|
1878 | const i = queue.indexOf(job);
|
1879 | if (i > flushIndex) {
|
1880 | queue.splice(i, 1);
|
1881 | }
|
1882 | }
|
1883 | function queuePostFlushCb(cb) {
|
1884 | if (!isArray(cb)) {
|
1885 | if (!activePostFlushCbs || !activePostFlushCbs.includes(
|
1886 | cb,
|
1887 | cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
|
1888 | )) {
|
1889 | pendingPostFlushCbs.push(cb);
|
1890 | }
|
1891 | } else {
|
1892 | pendingPostFlushCbs.push(...cb);
|
1893 | }
|
1894 | queueFlush();
|
1895 | }
|
1896 | function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
|
1897 | {
|
1898 | seen = seen || new Map();
|
1899 | }
|
1900 | for (; i < queue.length; i++) {
|
1901 | const cb = queue[i];
|
1902 | if (cb && cb.pre) {
|
1903 | if (instance && cb.id !== instance.uid) {
|
1904 | continue;
|
1905 | }
|
1906 | if (checkRecursiveUpdates(seen, cb)) {
|
1907 | continue;
|
1908 | }
|
1909 | queue.splice(i, 1);
|
1910 | i--;
|
1911 | cb();
|
1912 | }
|
1913 | }
|
1914 | }
|
1915 | function flushPostFlushCbs(seen) {
|
1916 | if (pendingPostFlushCbs.length) {
|
1917 | const deduped = [...new Set(pendingPostFlushCbs)].sort(
|
1918 | (a, b) => getId(a) - getId(b)
|
1919 | );
|
1920 | pendingPostFlushCbs.length = 0;
|
1921 | if (activePostFlushCbs) {
|
1922 | activePostFlushCbs.push(...deduped);
|
1923 | return;
|
1924 | }
|
1925 | activePostFlushCbs = deduped;
|
1926 | {
|
1927 | seen = seen || new Map();
|
1928 | }
|
1929 | for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
1930 | if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
|
1931 | continue;
|
1932 | }
|
1933 | activePostFlushCbs[postFlushIndex]();
|
1934 | }
|
1935 | activePostFlushCbs = null;
|
1936 | postFlushIndex = 0;
|
1937 | }
|
1938 | }
|
1939 | const getId = (job) => job.id == null ? Infinity : job.id;
|
1940 | const comparator = (a, b) => {
|
1941 | const diff = getId(a) - getId(b);
|
1942 | if (diff === 0) {
|
1943 | if (a.pre && !b.pre)
|
1944 | return -1;
|
1945 | if (b.pre && !a.pre)
|
1946 | return 1;
|
1947 | }
|
1948 | return diff;
|
1949 | };
|
1950 | function flushJobs(seen) {
|
1951 | isFlushPending = false;
|
1952 | isFlushing = true;
|
1953 | {
|
1954 | seen = seen || new Map();
|
1955 | }
|
1956 | queue.sort(comparator);
|
1957 | const check = (job) => checkRecursiveUpdates(seen, job) ;
|
1958 | try {
|
1959 | for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
1960 | const job = queue[flushIndex];
|
1961 | if (job && job.active !== false) {
|
1962 | if (check(job)) {
|
1963 | continue;
|
1964 | }
|
1965 | callWithErrorHandling(job, null, 14);
|
1966 | }
|
1967 | }
|
1968 | } finally {
|
1969 | flushIndex = 0;
|
1970 | queue.length = 0;
|
1971 | flushPostFlushCbs(seen);
|
1972 | isFlushing = false;
|
1973 | currentFlushPromise = null;
|
1974 | if (queue.length || pendingPostFlushCbs.length) {
|
1975 | flushJobs(seen);
|
1976 | }
|
1977 | }
|
1978 | }
|
1979 | function checkRecursiveUpdates(seen, fn) {
|
1980 | if (!seen.has(fn)) {
|
1981 | seen.set(fn, 1);
|
1982 | } else {
|
1983 | const count = seen.get(fn);
|
1984 | if (count > RECURSION_LIMIT) {
|
1985 | const instance = fn.ownerInstance;
|
1986 | const componentName = instance && getComponentName(instance.type);
|
1987 | handleError(
|
1988 | `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
|
1989 | null,
|
1990 | 10
|
1991 | );
|
1992 | return true;
|
1993 | } else {
|
1994 | seen.set(fn, count + 1);
|
1995 | }
|
1996 | }
|
1997 | }
|
1998 |
|
1999 | let isHmrUpdating = false;
|
2000 | const hmrDirtyComponents = new Set();
|
2001 | {
|
2002 | getGlobalThis().__VUE_HMR_RUNTIME__ = {
|
2003 | createRecord: tryWrap(createRecord),
|
2004 | rerender: tryWrap(rerender),
|
2005 | reload: tryWrap(reload)
|
2006 | };
|
2007 | }
|
2008 | const map = new Map();
|
2009 | function registerHMR(instance) {
|
2010 | const id = instance.type.__hmrId;
|
2011 | let record = map.get(id);
|
2012 | if (!record) {
|
2013 | createRecord(id, instance.type);
|
2014 | record = map.get(id);
|
2015 | }
|
2016 | record.instances.add(instance);
|
2017 | }
|
2018 | function unregisterHMR(instance) {
|
2019 | map.get(instance.type.__hmrId).instances.delete(instance);
|
2020 | }
|
2021 | function createRecord(id, initialDef) {
|
2022 | if (map.has(id)) {
|
2023 | return false;
|
2024 | }
|
2025 | map.set(id, {
|
2026 | initialDef: normalizeClassComponent(initialDef),
|
2027 | instances: new Set()
|
2028 | });
|
2029 | return true;
|
2030 | }
|
2031 | function normalizeClassComponent(component) {
|
2032 | return isClassComponent(component) ? component.__vccOpts : component;
|
2033 | }
|
2034 | function rerender(id, newRender) {
|
2035 | const record = map.get(id);
|
2036 | if (!record) {
|
2037 | return;
|
2038 | }
|
2039 | record.initialDef.render = newRender;
|
2040 | [...record.instances].forEach((instance) => {
|
2041 | if (newRender) {
|
2042 | instance.render = newRender;
|
2043 | normalizeClassComponent(instance.type).render = newRender;
|
2044 | }
|
2045 | instance.renderCache = [];
|
2046 | isHmrUpdating = true;
|
2047 | instance.effect.dirty = true;
|
2048 | instance.update();
|
2049 | isHmrUpdating = false;
|
2050 | });
|
2051 | }
|
2052 | function reload(id, newComp) {
|
2053 | const record = map.get(id);
|
2054 | if (!record)
|
2055 | return;
|
2056 | newComp = normalizeClassComponent(newComp);
|
2057 | updateComponentDef(record.initialDef, newComp);
|
2058 | const instances = [...record.instances];
|
2059 | for (const instance of instances) {
|
2060 | const oldComp = normalizeClassComponent(instance.type);
|
2061 | if (!hmrDirtyComponents.has(oldComp)) {
|
2062 | if (oldComp !== record.initialDef) {
|
2063 | updateComponentDef(oldComp, newComp);
|
2064 | }
|
2065 | hmrDirtyComponents.add(oldComp);
|
2066 | }
|
2067 | instance.appContext.propsCache.delete(instance.type);
|
2068 | instance.appContext.emitsCache.delete(instance.type);
|
2069 | instance.appContext.optionsCache.delete(instance.type);
|
2070 | if (instance.ceReload) {
|
2071 | hmrDirtyComponents.add(oldComp);
|
2072 | instance.ceReload(newComp.styles);
|
2073 | hmrDirtyComponents.delete(oldComp);
|
2074 | } else if (instance.parent) {
|
2075 | instance.parent.effect.dirty = true;
|
2076 | queueJob(instance.parent.update);
|
2077 | } else if (instance.appContext.reload) {
|
2078 | instance.appContext.reload();
|
2079 | } else if (typeof window !== "undefined") {
|
2080 | window.location.reload();
|
2081 | } else {
|
2082 | console.warn(
|
2083 | "[HMR] Root or manually mounted instance modified. Full reload required."
|
2084 | );
|
2085 | }
|
2086 | }
|
2087 | queuePostFlushCb(() => {
|
2088 | for (const instance of instances) {
|
2089 | hmrDirtyComponents.delete(
|
2090 | normalizeClassComponent(instance.type)
|
2091 | );
|
2092 | }
|
2093 | });
|
2094 | }
|
2095 | function updateComponentDef(oldComp, newComp) {
|
2096 | extend(oldComp, newComp);
|
2097 | for (const key in oldComp) {
|
2098 | if (key !== "__file" && !(key in newComp)) {
|
2099 | delete oldComp[key];
|
2100 | }
|
2101 | }
|
2102 | }
|
2103 | function tryWrap(fn) {
|
2104 | return (id, arg) => {
|
2105 | try {
|
2106 | return fn(id, arg);
|
2107 | } catch (e) {
|
2108 | console.error(e);
|
2109 | console.warn(
|
2110 | `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
|
2111 | );
|
2112 | }
|
2113 | };
|
2114 | }
|
2115 |
|
2116 | let devtools$1;
|
2117 | let buffer = [];
|
2118 | let devtoolsNotInstalled = false;
|
2119 | function emit$1(event, ...args) {
|
2120 | if (devtools$1) {
|
2121 | devtools$1.emit(event, ...args);
|
2122 | } else if (!devtoolsNotInstalled) {
|
2123 | buffer.push({ event, args });
|
2124 | }
|
2125 | }
|
2126 | function setDevtoolsHook$1(hook, target) {
|
2127 | var _a, _b;
|
2128 | devtools$1 = hook;
|
2129 | if (devtools$1) {
|
2130 | devtools$1.enabled = true;
|
2131 | buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args));
|
2132 | buffer = [];
|
2133 | } else if (
|
2134 |
|
2135 |
|
2136 |
|
2137 | typeof window !== "undefined" &&
|
2138 | window.HTMLElement &&
|
2139 | !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
|
2140 | ) {
|
2141 | const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
|
2142 | replay.push((newHook) => {
|
2143 | setDevtoolsHook$1(newHook, target);
|
2144 | });
|
2145 | setTimeout(() => {
|
2146 | if (!devtools$1) {
|
2147 | target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
|
2148 | devtoolsNotInstalled = true;
|
2149 | buffer = [];
|
2150 | }
|
2151 | }, 3e3);
|
2152 | } else {
|
2153 | devtoolsNotInstalled = true;
|
2154 | buffer = [];
|
2155 | }
|
2156 | }
|
2157 | function devtoolsInitApp(app, version) {
|
2158 | emit$1("app:init" , app, version, {
|
2159 | Fragment,
|
2160 | Text,
|
2161 | Comment,
|
2162 | Static
|
2163 | });
|
2164 | }
|
2165 | function devtoolsUnmountApp(app) {
|
2166 | emit$1("app:unmount" , app);
|
2167 | }
|
2168 | const devtoolsComponentAdded = createDevtoolsComponentHook(
|
2169 | "component:added"
|
2170 | );
|
2171 | const devtoolsComponentUpdated = createDevtoolsComponentHook("component:updated" );
|
2172 | const _devtoolsComponentRemoved = createDevtoolsComponentHook(
|
2173 | "component:removed"
|
2174 | );
|
2175 | const devtoolsComponentRemoved = (component) => {
|
2176 | if (devtools$1 && typeof devtools$1.cleanupBuffer === "function" &&
|
2177 | !devtools$1.cleanupBuffer(component)) {
|
2178 | _devtoolsComponentRemoved(component);
|
2179 | }
|
2180 | };
|
2181 | function createDevtoolsComponentHook(hook) {
|
2182 | return (component) => {
|
2183 | emit$1(
|
2184 | hook,
|
2185 | component.appContext.app,
|
2186 | component.uid,
|
2187 | component.parent ? component.parent.uid : void 0,
|
2188 | component
|
2189 | );
|
2190 | };
|
2191 | }
|
2192 | const devtoolsPerfStart = createDevtoolsPerformanceHook(
|
2193 | "perf:start"
|
2194 | );
|
2195 | const devtoolsPerfEnd = createDevtoolsPerformanceHook(
|
2196 | "perf:end"
|
2197 | );
|
2198 | function createDevtoolsPerformanceHook(hook) {
|
2199 | return (component, type, time) => {
|
2200 | emit$1(hook, component.appContext.app, component.uid, component, type, time);
|
2201 | };
|
2202 | }
|
2203 | function devtoolsComponentEmit(component, event, params) {
|
2204 | emit$1(
|
2205 | "component:emit" ,
|
2206 | component.appContext.app,
|
2207 | component,
|
2208 | event,
|
2209 | params
|
2210 | );
|
2211 | }
|
2212 |
|
2213 | function emit(instance, event, ...rawArgs) {
|
2214 | if (instance.isUnmounted)
|
2215 | return;
|
2216 | const props = instance.vnode.props || EMPTY_OBJ;
|
2217 | {
|
2218 | const {
|
2219 | emitsOptions,
|
2220 | propsOptions: [propsOptions]
|
2221 | } = instance;
|
2222 | if (emitsOptions) {
|
2223 | if (!(event in emitsOptions) && true) {
|
2224 | if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
|
2225 | warn$1(
|
2226 | `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`
|
2227 | );
|
2228 | }
|
2229 | } else {
|
2230 | const validator = emitsOptions[event];
|
2231 | if (isFunction(validator)) {
|
2232 | const isValid = validator(...rawArgs);
|
2233 | if (!isValid) {
|
2234 | warn$1(
|
2235 | `Invalid event arguments: event validation failed for event "${event}".`
|
2236 | );
|
2237 | }
|
2238 | }
|
2239 | }
|
2240 | }
|
2241 | }
|
2242 | let args = rawArgs;
|
2243 | const isModelListener = event.startsWith("update:");
|
2244 | const modelArg = isModelListener && event.slice(7);
|
2245 | if (modelArg && modelArg in props) {
|
2246 | const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;
|
2247 | const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
|
2248 | if (trim) {
|
2249 | args = rawArgs.map((a) => isString(a) ? a.trim() : a);
|
2250 | }
|
2251 | if (number) {
|
2252 | args = rawArgs.map(looseToNumber);
|
2253 | }
|
2254 | }
|
2255 | {
|
2256 | devtoolsComponentEmit(instance, event, args);
|
2257 | }
|
2258 | {
|
2259 | const lowerCaseEvent = event.toLowerCase();
|
2260 | if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
|
2261 | warn$1(
|
2262 | `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
|
2263 | instance,
|
2264 | instance.type
|
2265 | )} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${hyphenate(
|
2266 | event
|
2267 | )}" instead of "${event}".`
|
2268 | );
|
2269 | }
|
2270 | }
|
2271 | let handlerName;
|
2272 | let handler = props[handlerName = toHandlerKey(event)] ||
|
2273 | props[handlerName = toHandlerKey(camelize(event))];
|
2274 | if (!handler && isModelListener) {
|
2275 | handler = props[handlerName = toHandlerKey(hyphenate(event))];
|
2276 | }
|
2277 | if (handler) {
|
2278 | callWithAsyncErrorHandling(
|
2279 | handler,
|
2280 | instance,
|
2281 | 6,
|
2282 | args
|
2283 | );
|
2284 | }
|
2285 | const onceHandler = props[handlerName + `Once`];
|
2286 | if (onceHandler) {
|
2287 | if (!instance.emitted) {
|
2288 | instance.emitted = {};
|
2289 | } else if (instance.emitted[handlerName]) {
|
2290 | return;
|
2291 | }
|
2292 | instance.emitted[handlerName] = true;
|
2293 | callWithAsyncErrorHandling(
|
2294 | onceHandler,
|
2295 | instance,
|
2296 | 6,
|
2297 | args
|
2298 | );
|
2299 | }
|
2300 | }
|
2301 | function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
2302 | const cache = appContext.emitsCache;
|
2303 | const cached = cache.get(comp);
|
2304 | if (cached !== void 0) {
|
2305 | return cached;
|
2306 | }
|
2307 | const raw = comp.emits;
|
2308 | let normalized = {};
|
2309 | let hasExtends = false;
|
2310 | if (!isFunction(comp)) {
|
2311 | const extendEmits = (raw2) => {
|
2312 | const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
|
2313 | if (normalizedFromExtend) {
|
2314 | hasExtends = true;
|
2315 | extend(normalized, normalizedFromExtend);
|
2316 | }
|
2317 | };
|
2318 | if (!asMixin && appContext.mixins.length) {
|
2319 | appContext.mixins.forEach(extendEmits);
|
2320 | }
|
2321 | if (comp.extends) {
|
2322 | extendEmits(comp.extends);
|
2323 | }
|
2324 | if (comp.mixins) {
|
2325 | comp.mixins.forEach(extendEmits);
|
2326 | }
|
2327 | }
|
2328 | if (!raw && !hasExtends) {
|
2329 | if (isObject(comp)) {
|
2330 | cache.set(comp, null);
|
2331 | }
|
2332 | return null;
|
2333 | }
|
2334 | if (isArray(raw)) {
|
2335 | raw.forEach((key) => normalized[key] = null);
|
2336 | } else {
|
2337 | extend(normalized, raw);
|
2338 | }
|
2339 | if (isObject(comp)) {
|
2340 | cache.set(comp, normalized);
|
2341 | }
|
2342 | return normalized;
|
2343 | }
|
2344 | function isEmitListener(options, key) {
|
2345 | if (!options || !isOn(key)) {
|
2346 | return false;
|
2347 | }
|
2348 | key = key.slice(2).replace(/Once$/, "");
|
2349 | return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
|
2350 | }
|
2351 |
|
2352 | let currentRenderingInstance = null;
|
2353 | let currentScopeId = null;
|
2354 | function setCurrentRenderingInstance(instance) {
|
2355 | const prev = currentRenderingInstance;
|
2356 | currentRenderingInstance = instance;
|
2357 | currentScopeId = instance && instance.type.__scopeId || null;
|
2358 | return prev;
|
2359 | }
|
2360 | function pushScopeId(id) {
|
2361 | currentScopeId = id;
|
2362 | }
|
2363 | function popScopeId() {
|
2364 | currentScopeId = null;
|
2365 | }
|
2366 | const withScopeId = (_id) => withCtx;
|
2367 | function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
|
2368 | if (!ctx)
|
2369 | return fn;
|
2370 | if (fn._n) {
|
2371 | return fn;
|
2372 | }
|
2373 | const renderFnWithContext = (...args) => {
|
2374 | if (renderFnWithContext._d) {
|
2375 | setBlockTracking(-1);
|
2376 | }
|
2377 | const prevInstance = setCurrentRenderingInstance(ctx);
|
2378 | let res;
|
2379 | try {
|
2380 | res = fn(...args);
|
2381 | } finally {
|
2382 | setCurrentRenderingInstance(prevInstance);
|
2383 | if (renderFnWithContext._d) {
|
2384 | setBlockTracking(1);
|
2385 | }
|
2386 | }
|
2387 | {
|
2388 | devtoolsComponentUpdated(ctx);
|
2389 | }
|
2390 | return res;
|
2391 | };
|
2392 | renderFnWithContext._n = true;
|
2393 | renderFnWithContext._c = true;
|
2394 | renderFnWithContext._d = true;
|
2395 | return renderFnWithContext;
|
2396 | }
|
2397 |
|
2398 | let accessedAttrs = false;
|
2399 | function markAttrsAccessed() {
|
2400 | accessedAttrs = true;
|
2401 | }
|
2402 | function renderComponentRoot(instance) {
|
2403 | const {
|
2404 | type: Component,
|
2405 | vnode,
|
2406 | proxy,
|
2407 | withProxy,
|
2408 | props,
|
2409 | propsOptions: [propsOptions],
|
2410 | slots,
|
2411 | attrs,
|
2412 | emit,
|
2413 | render,
|
2414 | renderCache,
|
2415 | data,
|
2416 | setupState,
|
2417 | ctx,
|
2418 | inheritAttrs
|
2419 | } = instance;
|
2420 | let result;
|
2421 | let fallthroughAttrs;
|
2422 | const prev = setCurrentRenderingInstance(instance);
|
2423 | {
|
2424 | accessedAttrs = false;
|
2425 | }
|
2426 | try {
|
2427 | if (vnode.shapeFlag & 4) {
|
2428 | const proxyToUse = withProxy || proxy;
|
2429 | const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
|
2430 | get(target, key, receiver) {
|
2431 | warn$1(
|
2432 | `Property '${String(
|
2433 | key
|
2434 | )}' was accessed via 'this'. Avoid using 'this' in templates.`
|
2435 | );
|
2436 | return Reflect.get(target, key, receiver);
|
2437 | }
|
2438 | }) : proxyToUse;
|
2439 | result = normalizeVNode(
|
2440 | render.call(
|
2441 | thisProxy,
|
2442 | proxyToUse,
|
2443 | renderCache,
|
2444 | props,
|
2445 | setupState,
|
2446 | data,
|
2447 | ctx
|
2448 | )
|
2449 | );
|
2450 | fallthroughAttrs = attrs;
|
2451 | } else {
|
2452 | const render2 = Component;
|
2453 | if (attrs === props) {
|
2454 | markAttrsAccessed();
|
2455 | }
|
2456 | result = normalizeVNode(
|
2457 | render2.length > 1 ? render2(
|
2458 | props,
|
2459 | true ? {
|
2460 | get attrs() {
|
2461 | markAttrsAccessed();
|
2462 | return attrs;
|
2463 | },
|
2464 | slots,
|
2465 | emit
|
2466 | } : { attrs, slots, emit }
|
2467 | ) : render2(
|
2468 | props,
|
2469 | null
|
2470 |
|
2471 | )
|
2472 | );
|
2473 | fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
|
2474 | }
|
2475 | } catch (err) {
|
2476 | blockStack.length = 0;
|
2477 | handleError(err, instance, 1);
|
2478 | result = createVNode(Comment);
|
2479 | }
|
2480 | let root = result;
|
2481 | let setRoot = void 0;
|
2482 | if (result.patchFlag > 0 && result.patchFlag & 2048) {
|
2483 | [root, setRoot] = getChildRoot(result);
|
2484 | }
|
2485 | if (fallthroughAttrs && inheritAttrs !== false) {
|
2486 | const keys = Object.keys(fallthroughAttrs);
|
2487 | const { shapeFlag } = root;
|
2488 | if (keys.length) {
|
2489 | if (shapeFlag & (1 | 6)) {
|
2490 | if (propsOptions && keys.some(isModelListener)) {
|
2491 | fallthroughAttrs = filterModelListeners(
|
2492 | fallthroughAttrs,
|
2493 | propsOptions
|
2494 | );
|
2495 | }
|
2496 | root = cloneVNode(root, fallthroughAttrs);
|
2497 | } else if (!accessedAttrs && root.type !== Comment) {
|
2498 | const allAttrs = Object.keys(attrs);
|
2499 | const eventAttrs = [];
|
2500 | const extraAttrs = [];
|
2501 | for (let i = 0, l = allAttrs.length; i < l; i++) {
|
2502 | const key = allAttrs[i];
|
2503 | if (isOn(key)) {
|
2504 | if (!isModelListener(key)) {
|
2505 | eventAttrs.push(key[2].toLowerCase() + key.slice(3));
|
2506 | }
|
2507 | } else {
|
2508 | extraAttrs.push(key);
|
2509 | }
|
2510 | }
|
2511 | if (extraAttrs.length) {
|
2512 | warn$1(
|
2513 | `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`
|
2514 | );
|
2515 | }
|
2516 | if (eventAttrs.length) {
|
2517 | warn$1(
|
2518 | `Extraneous non-emits event listeners (${eventAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`
|
2519 | );
|
2520 | }
|
2521 | }
|
2522 | }
|
2523 | }
|
2524 | if (vnode.dirs) {
|
2525 | if (!isElementRoot(root)) {
|
2526 | warn$1(
|
2527 | `Runtime directive used on component with non-element root node. The directives will not function as intended.`
|
2528 | );
|
2529 | }
|
2530 | root = cloneVNode(root);
|
2531 | root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
|
2532 | }
|
2533 | if (vnode.transition) {
|
2534 | if (!isElementRoot(root)) {
|
2535 | warn$1(
|
2536 | `Component inside <Transition> renders non-element root node that cannot be animated.`
|
2537 | );
|
2538 | }
|
2539 | root.transition = vnode.transition;
|
2540 | }
|
2541 | if (setRoot) {
|
2542 | setRoot(root);
|
2543 | } else {
|
2544 | result = root;
|
2545 | }
|
2546 | setCurrentRenderingInstance(prev);
|
2547 | return result;
|
2548 | }
|
2549 | const getChildRoot = (vnode) => {
|
2550 | const rawChildren = vnode.children;
|
2551 | const dynamicChildren = vnode.dynamicChildren;
|
2552 | const childRoot = filterSingleRoot(rawChildren, false);
|
2553 | if (!childRoot) {
|
2554 | return [vnode, void 0];
|
2555 | } else if (childRoot.patchFlag > 0 && childRoot.patchFlag & 2048) {
|
2556 | return getChildRoot(childRoot);
|
2557 | }
|
2558 | const index = rawChildren.indexOf(childRoot);
|
2559 | const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
|
2560 | const setRoot = (updatedRoot) => {
|
2561 | rawChildren[index] = updatedRoot;
|
2562 | if (dynamicChildren) {
|
2563 | if (dynamicIndex > -1) {
|
2564 | dynamicChildren[dynamicIndex] = updatedRoot;
|
2565 | } else if (updatedRoot.patchFlag > 0) {
|
2566 | vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
|
2567 | }
|
2568 | }
|
2569 | };
|
2570 | return [normalizeVNode(childRoot), setRoot];
|
2571 | };
|
2572 | function filterSingleRoot(children, recurse = true) {
|
2573 | let singleRoot;
|
2574 | for (let i = 0; i < children.length; i++) {
|
2575 | const child = children[i];
|
2576 | if (isVNode(child)) {
|
2577 | if (child.type !== Comment || child.children === "v-if") {
|
2578 | if (singleRoot) {
|
2579 | return;
|
2580 | } else {
|
2581 | singleRoot = child;
|
2582 | if (recurse && singleRoot.patchFlag > 0 && singleRoot.patchFlag & 2048) {
|
2583 | return filterSingleRoot(singleRoot.children);
|
2584 | }
|
2585 | }
|
2586 | }
|
2587 | } else {
|
2588 | return;
|
2589 | }
|
2590 | }
|
2591 | return singleRoot;
|
2592 | }
|
2593 | const getFunctionalFallthrough = (attrs) => {
|
2594 | let res;
|
2595 | for (const key in attrs) {
|
2596 | if (key === "class" || key === "style" || isOn(key)) {
|
2597 | (res || (res = {}))[key] = attrs[key];
|
2598 | }
|
2599 | }
|
2600 | return res;
|
2601 | };
|
2602 | const filterModelListeners = (attrs, props) => {
|
2603 | const res = {};
|
2604 | for (const key in attrs) {
|
2605 | if (!isModelListener(key) || !(key.slice(9) in props)) {
|
2606 | res[key] = attrs[key];
|
2607 | }
|
2608 | }
|
2609 | return res;
|
2610 | };
|
2611 | const isElementRoot = (vnode) => {
|
2612 | return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
|
2613 | };
|
2614 | function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
|
2615 | const { props: prevProps, children: prevChildren, component } = prevVNode;
|
2616 | const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
|
2617 | const emits = component.emitsOptions;
|
2618 | if ((prevChildren || nextChildren) && isHmrUpdating) {
|
2619 | return true;
|
2620 | }
|
2621 | if (nextVNode.dirs || nextVNode.transition) {
|
2622 | return true;
|
2623 | }
|
2624 | if (optimized && patchFlag >= 0) {
|
2625 | if (patchFlag & 1024) {
|
2626 | return true;
|
2627 | }
|
2628 | if (patchFlag & 16) {
|
2629 | if (!prevProps) {
|
2630 | return !!nextProps;
|
2631 | }
|
2632 | return hasPropsChanged(prevProps, nextProps, emits);
|
2633 | } else if (patchFlag & 8) {
|
2634 | const dynamicProps = nextVNode.dynamicProps;
|
2635 | for (let i = 0; i < dynamicProps.length; i++) {
|
2636 | const key = dynamicProps[i];
|
2637 | if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
|
2638 | return true;
|
2639 | }
|
2640 | }
|
2641 | }
|
2642 | } else {
|
2643 | if (prevChildren || nextChildren) {
|
2644 | if (!nextChildren || !nextChildren.$stable) {
|
2645 | return true;
|
2646 | }
|
2647 | }
|
2648 | if (prevProps === nextProps) {
|
2649 | return false;
|
2650 | }
|
2651 | if (!prevProps) {
|
2652 | return !!nextProps;
|
2653 | }
|
2654 | if (!nextProps) {
|
2655 | return true;
|
2656 | }
|
2657 | return hasPropsChanged(prevProps, nextProps, emits);
|
2658 | }
|
2659 | return false;
|
2660 | }
|
2661 | function hasPropsChanged(prevProps, nextProps, emitsOptions) {
|
2662 | const nextKeys = Object.keys(nextProps);
|
2663 | if (nextKeys.length !== Object.keys(prevProps).length) {
|
2664 | return true;
|
2665 | }
|
2666 | for (let i = 0; i < nextKeys.length; i++) {
|
2667 | const key = nextKeys[i];
|
2668 | if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
|
2669 | return true;
|
2670 | }
|
2671 | }
|
2672 | return false;
|
2673 | }
|
2674 | function updateHOCHostEl({ vnode, parent }, el) {
|
2675 | while (parent) {
|
2676 | const root = parent.subTree;
|
2677 | if (root.suspense && root.suspense.activeBranch === vnode) {
|
2678 | root.el = vnode.el;
|
2679 | }
|
2680 | if (root === vnode) {
|
2681 | (vnode = parent.vnode).el = el;
|
2682 | parent = parent.parent;
|
2683 | } else {
|
2684 | break;
|
2685 | }
|
2686 | }
|
2687 | }
|
2688 |
|
2689 | const COMPONENTS = "components";
|
2690 | const DIRECTIVES = "directives";
|
2691 | function resolveComponent(name, maybeSelfReference) {
|
2692 | return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
2693 | }
|
2694 | const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
|
2695 | function resolveDynamicComponent(component) {
|
2696 | if (isString(component)) {
|
2697 | return resolveAsset(COMPONENTS, component, false) || component;
|
2698 | } else {
|
2699 | return component || NULL_DYNAMIC_COMPONENT;
|
2700 | }
|
2701 | }
|
2702 | function resolveDirective(name) {
|
2703 | return resolveAsset(DIRECTIVES, name);
|
2704 | }
|
2705 | function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
2706 | const instance = currentRenderingInstance || currentInstance;
|
2707 | if (instance) {
|
2708 | const Component = instance.type;
|
2709 | if (type === COMPONENTS) {
|
2710 | const selfName = getComponentName(
|
2711 | Component,
|
2712 | false
|
2713 | );
|
2714 | if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
|
2715 | return Component;
|
2716 | }
|
2717 | }
|
2718 | const res = (
|
2719 |
|
2720 |
|
2721 | resolve(instance[type] || Component[type], name) ||
|
2722 | resolve(instance.appContext[type], name)
|
2723 | );
|
2724 | if (!res && maybeSelfReference) {
|
2725 | return Component;
|
2726 | }
|
2727 | if (warnMissing && !res) {
|
2728 | const extra = type === COMPONENTS ? `
|
2729 | If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
|
2730 | warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
|
2731 | }
|
2732 | return res;
|
2733 | } else {
|
2734 | warn$1(
|
2735 | `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
|
2736 | );
|
2737 | }
|
2738 | }
|
2739 | function resolve(registry, name) {
|
2740 | return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
|
2741 | }
|
2742 |
|
2743 | const isSuspense = (type) => type.__isSuspense;
|
2744 | let suspenseId = 0;
|
2745 | const SuspenseImpl = {
|
2746 | name: "Suspense",
|
2747 |
|
2748 |
|
2749 |
|
2750 |
|
2751 | __isSuspense: true,
|
2752 | process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
|
2753 | if (n1 == null) {
|
2754 | mountSuspense(
|
2755 | n2,
|
2756 | container,
|
2757 | anchor,
|
2758 | parentComponent,
|
2759 | parentSuspense,
|
2760 | namespace,
|
2761 | slotScopeIds,
|
2762 | optimized,
|
2763 | rendererInternals
|
2764 | );
|
2765 | } else {
|
2766 | if (parentSuspense && parentSuspense.deps > 0) {
|
2767 | n2.suspense = n1.suspense;
|
2768 | return;
|
2769 | }
|
2770 | patchSuspense(
|
2771 | n1,
|
2772 | n2,
|
2773 | container,
|
2774 | anchor,
|
2775 | parentComponent,
|
2776 | namespace,
|
2777 | slotScopeIds,
|
2778 | optimized,
|
2779 | rendererInternals
|
2780 | );
|
2781 | }
|
2782 | },
|
2783 | hydrate: hydrateSuspense,
|
2784 | create: createSuspenseBoundary,
|
2785 | normalize: normalizeSuspenseChildren
|
2786 | };
|
2787 | const Suspense = SuspenseImpl ;
|
2788 | function triggerEvent(vnode, name) {
|
2789 | const eventListener = vnode.props && vnode.props[name];
|
2790 | if (isFunction(eventListener)) {
|
2791 | eventListener();
|
2792 | }
|
2793 | }
|
2794 | function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
|
2795 | const {
|
2796 | p: patch,
|
2797 | o: { createElement }
|
2798 | } = rendererInternals;
|
2799 | const hiddenContainer = createElement("div");
|
2800 | const suspense = vnode.suspense = createSuspenseBoundary(
|
2801 | vnode,
|
2802 | parentSuspense,
|
2803 | parentComponent,
|
2804 | container,
|
2805 | hiddenContainer,
|
2806 | anchor,
|
2807 | namespace,
|
2808 | slotScopeIds,
|
2809 | optimized,
|
2810 | rendererInternals
|
2811 | );
|
2812 | patch(
|
2813 | null,
|
2814 | suspense.pendingBranch = vnode.ssContent,
|
2815 | hiddenContainer,
|
2816 | null,
|
2817 | parentComponent,
|
2818 | suspense,
|
2819 | namespace,
|
2820 | slotScopeIds
|
2821 | );
|
2822 | if (suspense.deps > 0) {
|
2823 | triggerEvent(vnode, "onPending");
|
2824 | triggerEvent(vnode, "onFallback");
|
2825 | patch(
|
2826 | null,
|
2827 | vnode.ssFallback,
|
2828 | container,
|
2829 | anchor,
|
2830 | parentComponent,
|
2831 | null,
|
2832 |
|
2833 | namespace,
|
2834 | slotScopeIds
|
2835 | );
|
2836 | setActiveBranch(suspense, vnode.ssFallback);
|
2837 | } else {
|
2838 | suspense.resolve(false, true);
|
2839 | }
|
2840 | }
|
2841 | function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
|
2842 | const suspense = n2.suspense = n1.suspense;
|
2843 | suspense.vnode = n2;
|
2844 | n2.el = n1.el;
|
2845 | const newBranch = n2.ssContent;
|
2846 | const newFallback = n2.ssFallback;
|
2847 | const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
|
2848 | if (pendingBranch) {
|
2849 | suspense.pendingBranch = newBranch;
|
2850 | if (isSameVNodeType(newBranch, pendingBranch)) {
|
2851 | patch(
|
2852 | pendingBranch,
|
2853 | newBranch,
|
2854 | suspense.hiddenContainer,
|
2855 | null,
|
2856 | parentComponent,
|
2857 | suspense,
|
2858 | namespace,
|
2859 | slotScopeIds,
|
2860 | optimized
|
2861 | );
|
2862 | if (suspense.deps <= 0) {
|
2863 | suspense.resolve();
|
2864 | } else if (isInFallback) {
|
2865 | if (!isHydrating) {
|
2866 | patch(
|
2867 | activeBranch,
|
2868 | newFallback,
|
2869 | container,
|
2870 | anchor,
|
2871 | parentComponent,
|
2872 | null,
|
2873 |
|
2874 | namespace,
|
2875 | slotScopeIds,
|
2876 | optimized
|
2877 | );
|
2878 | setActiveBranch(suspense, newFallback);
|
2879 | }
|
2880 | }
|
2881 | } else {
|
2882 | suspense.pendingId = suspenseId++;
|
2883 | if (isHydrating) {
|
2884 | suspense.isHydrating = false;
|
2885 | suspense.activeBranch = pendingBranch;
|
2886 | } else {
|
2887 | unmount(pendingBranch, parentComponent, suspense);
|
2888 | }
|
2889 | suspense.deps = 0;
|
2890 | suspense.effects.length = 0;
|
2891 | suspense.hiddenContainer = createElement("div");
|
2892 | if (isInFallback) {
|
2893 | patch(
|
2894 | null,
|
2895 | newBranch,
|
2896 | suspense.hiddenContainer,
|
2897 | null,
|
2898 | parentComponent,
|
2899 | suspense,
|
2900 | namespace,
|
2901 | slotScopeIds,
|
2902 | optimized
|
2903 | );
|
2904 | if (suspense.deps <= 0) {
|
2905 | suspense.resolve();
|
2906 | } else {
|
2907 | patch(
|
2908 | activeBranch,
|
2909 | newFallback,
|
2910 | container,
|
2911 | anchor,
|
2912 | parentComponent,
|
2913 | null,
|
2914 |
|
2915 | namespace,
|
2916 | slotScopeIds,
|
2917 | optimized
|
2918 | );
|
2919 | setActiveBranch(suspense, newFallback);
|
2920 | }
|
2921 | } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2922 | patch(
|
2923 | activeBranch,
|
2924 | newBranch,
|
2925 | container,
|
2926 | anchor,
|
2927 | parentComponent,
|
2928 | suspense,
|
2929 | namespace,
|
2930 | slotScopeIds,
|
2931 | optimized
|
2932 | );
|
2933 | suspense.resolve(true);
|
2934 | } else {
|
2935 | patch(
|
2936 | null,
|
2937 | newBranch,
|
2938 | suspense.hiddenContainer,
|
2939 | null,
|
2940 | parentComponent,
|
2941 | suspense,
|
2942 | namespace,
|
2943 | slotScopeIds,
|
2944 | optimized
|
2945 | );
|
2946 | if (suspense.deps <= 0) {
|
2947 | suspense.resolve();
|
2948 | }
|
2949 | }
|
2950 | }
|
2951 | } else {
|
2952 | if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2953 | patch(
|
2954 | activeBranch,
|
2955 | newBranch,
|
2956 | container,
|
2957 | anchor,
|
2958 | parentComponent,
|
2959 | suspense,
|
2960 | namespace,
|
2961 | slotScopeIds,
|
2962 | optimized
|
2963 | );
|
2964 | setActiveBranch(suspense, newBranch);
|
2965 | } else {
|
2966 | triggerEvent(n2, "onPending");
|
2967 | suspense.pendingBranch = newBranch;
|
2968 | if (newBranch.shapeFlag & 512) {
|
2969 | suspense.pendingId = newBranch.component.suspenseId;
|
2970 | } else {
|
2971 | suspense.pendingId = suspenseId++;
|
2972 | }
|
2973 | patch(
|
2974 | null,
|
2975 | newBranch,
|
2976 | suspense.hiddenContainer,
|
2977 | null,
|
2978 | parentComponent,
|
2979 | suspense,
|
2980 | namespace,
|
2981 | slotScopeIds,
|
2982 | optimized
|
2983 | );
|
2984 | if (suspense.deps <= 0) {
|
2985 | suspense.resolve();
|
2986 | } else {
|
2987 | const { timeout, pendingId } = suspense;
|
2988 | if (timeout > 0) {
|
2989 | setTimeout(() => {
|
2990 | if (suspense.pendingId === pendingId) {
|
2991 | suspense.fallback(newFallback);
|
2992 | }
|
2993 | }, timeout);
|
2994 | } else if (timeout === 0) {
|
2995 | suspense.fallback(newFallback);
|
2996 | }
|
2997 | }
|
2998 | }
|
2999 | }
|
3000 | }
|
3001 | let hasWarned = false;
|
3002 | function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
|
3003 | if (!hasWarned) {
|
3004 | hasWarned = true;
|
3005 | console[console.info ? "info" : "log"](
|
3006 | `<Suspense> is an experimental feature and its API will likely change.`
|
3007 | );
|
3008 | }
|
3009 | const {
|
3010 | p: patch,
|
3011 | m: move,
|
3012 | um: unmount,
|
3013 | n: next,
|
3014 | o: { parentNode, remove }
|
3015 | } = rendererInternals;
|
3016 | let parentSuspenseId;
|
3017 | const isSuspensible = isVNodeSuspensible(vnode);
|
3018 | if (isSuspensible) {
|
3019 | if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
|
3020 | parentSuspenseId = parentSuspense.pendingId;
|
3021 | parentSuspense.deps++;
|
3022 | }
|
3023 | }
|
3024 | const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0;
|
3025 | {
|
3026 | assertNumber(timeout, `Suspense timeout`);
|
3027 | }
|
3028 | const initialAnchor = anchor;
|
3029 | const suspense = {
|
3030 | vnode,
|
3031 | parent: parentSuspense,
|
3032 | parentComponent,
|
3033 | namespace,
|
3034 | container,
|
3035 | hiddenContainer,
|
3036 | deps: 0,
|
3037 | pendingId: suspenseId++,
|
3038 | timeout: typeof timeout === "number" ? timeout : -1,
|
3039 | activeBranch: null,
|
3040 | pendingBranch: null,
|
3041 | isInFallback: !isHydrating,
|
3042 | isHydrating,
|
3043 | isUnmounted: false,
|
3044 | effects: [],
|
3045 | resolve(resume = false, sync = false) {
|
3046 | {
|
3047 | if (!resume && !suspense.pendingBranch) {
|
3048 | throw new Error(
|
3049 | `suspense.resolve() is called without a pending branch.`
|
3050 | );
|
3051 | }
|
3052 | if (suspense.isUnmounted) {
|
3053 | throw new Error(
|
3054 | `suspense.resolve() is called on an already unmounted suspense boundary.`
|
3055 | );
|
3056 | }
|
3057 | }
|
3058 | const {
|
3059 | vnode: vnode2,
|
3060 | activeBranch,
|
3061 | pendingBranch,
|
3062 | pendingId,
|
3063 | effects,
|
3064 | parentComponent: parentComponent2,
|
3065 | container: container2
|
3066 | } = suspense;
|
3067 | let delayEnter = false;
|
3068 | if (suspense.isHydrating) {
|
3069 | suspense.isHydrating = false;
|
3070 | } else if (!resume) {
|
3071 | delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
|
3072 | if (delayEnter) {
|
3073 | activeBranch.transition.afterLeave = () => {
|
3074 | if (pendingId === suspense.pendingId) {
|
3075 | move(
|
3076 | pendingBranch,
|
3077 | container2,
|
3078 | anchor === initialAnchor ? next(activeBranch) : anchor,
|
3079 | 0
|
3080 | );
|
3081 | queuePostFlushCb(effects);
|
3082 | }
|
3083 | };
|
3084 | }
|
3085 | if (activeBranch) {
|
3086 | if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
|
3087 | anchor = next(activeBranch);
|
3088 | }
|
3089 | unmount(activeBranch, parentComponent2, suspense, true);
|
3090 | }
|
3091 | if (!delayEnter) {
|
3092 | move(pendingBranch, container2, anchor, 0);
|
3093 | }
|
3094 | }
|
3095 | setActiveBranch(suspense, pendingBranch);
|
3096 | suspense.pendingBranch = null;
|
3097 | suspense.isInFallback = false;
|
3098 | let parent = suspense.parent;
|
3099 | let hasUnresolvedAncestor = false;
|
3100 | while (parent) {
|
3101 | if (parent.pendingBranch) {
|
3102 | parent.effects.push(...effects);
|
3103 | hasUnresolvedAncestor = true;
|
3104 | break;
|
3105 | }
|
3106 | parent = parent.parent;
|
3107 | }
|
3108 | if (!hasUnresolvedAncestor && !delayEnter) {
|
3109 | queuePostFlushCb(effects);
|
3110 | }
|
3111 | suspense.effects = [];
|
3112 | if (isSuspensible) {
|
3113 | if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
|
3114 | parentSuspense.deps--;
|
3115 | if (parentSuspense.deps === 0 && !sync) {
|
3116 | parentSuspense.resolve();
|
3117 | }
|
3118 | }
|
3119 | }
|
3120 | triggerEvent(vnode2, "onResolve");
|
3121 | },
|
3122 | fallback(fallbackVNode) {
|
3123 | if (!suspense.pendingBranch) {
|
3124 | return;
|
3125 | }
|
3126 | const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense;
|
3127 | triggerEvent(vnode2, "onFallback");
|
3128 | const anchor2 = next(activeBranch);
|
3129 | const mountFallback = () => {
|
3130 | if (!suspense.isInFallback) {
|
3131 | return;
|
3132 | }
|
3133 | patch(
|
3134 | null,
|
3135 | fallbackVNode,
|
3136 | container2,
|
3137 | anchor2,
|
3138 | parentComponent2,
|
3139 | null,
|
3140 |
|
3141 | namespace2,
|
3142 | slotScopeIds,
|
3143 | optimized
|
3144 | );
|
3145 | setActiveBranch(suspense, fallbackVNode);
|
3146 | };
|
3147 | const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
|
3148 | if (delayEnter) {
|
3149 | activeBranch.transition.afterLeave = mountFallback;
|
3150 | }
|
3151 | suspense.isInFallback = true;
|
3152 | unmount(
|
3153 | activeBranch,
|
3154 | parentComponent2,
|
3155 | null,
|
3156 |
|
3157 | true
|
3158 |
|
3159 | );
|
3160 | if (!delayEnter) {
|
3161 | mountFallback();
|
3162 | }
|
3163 | },
|
3164 | move(container2, anchor2, type) {
|
3165 | suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
|
3166 | suspense.container = container2;
|
3167 | },
|
3168 | next() {
|
3169 | return suspense.activeBranch && next(suspense.activeBranch);
|
3170 | },
|
3171 | registerDep(instance, setupRenderEffect) {
|
3172 | const isInPendingSuspense = !!suspense.pendingBranch;
|
3173 | if (isInPendingSuspense) {
|
3174 | suspense.deps++;
|
3175 | }
|
3176 | const hydratedEl = instance.vnode.el;
|
3177 | instance.asyncDep.catch((err) => {
|
3178 | handleError(err, instance, 0);
|
3179 | }).then((asyncSetupResult) => {
|
3180 | if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
|
3181 | return;
|
3182 | }
|
3183 | instance.asyncResolved = true;
|
3184 | const { vnode: vnode2 } = instance;
|
3185 | {
|
3186 | pushWarningContext(vnode2);
|
3187 | }
|
3188 | handleSetupResult(instance, asyncSetupResult, false);
|
3189 | if (hydratedEl) {
|
3190 | vnode2.el = hydratedEl;
|
3191 | }
|
3192 | const placeholder = !hydratedEl && instance.subTree.el;
|
3193 | setupRenderEffect(
|
3194 | instance,
|
3195 | vnode2,
|
3196 |
|
3197 |
|
3198 |
|
3199 | parentNode(hydratedEl || instance.subTree.el),
|
3200 |
|
3201 |
|
3202 | hydratedEl ? null : next(instance.subTree),
|
3203 | suspense,
|
3204 | namespace,
|
3205 | optimized
|
3206 | );
|
3207 | if (placeholder) {
|
3208 | remove(placeholder);
|
3209 | }
|
3210 | updateHOCHostEl(instance, vnode2.el);
|
3211 | {
|
3212 | popWarningContext();
|
3213 | }
|
3214 | if (isInPendingSuspense && --suspense.deps === 0) {
|
3215 | suspense.resolve();
|
3216 | }
|
3217 | });
|
3218 | },
|
3219 | unmount(parentSuspense2, doRemove) {
|
3220 | suspense.isUnmounted = true;
|
3221 | if (suspense.activeBranch) {
|
3222 | unmount(
|
3223 | suspense.activeBranch,
|
3224 | parentComponent,
|
3225 | parentSuspense2,
|
3226 | doRemove
|
3227 | );
|
3228 | }
|
3229 | if (suspense.pendingBranch) {
|
3230 | unmount(
|
3231 | suspense.pendingBranch,
|
3232 | parentComponent,
|
3233 | parentSuspense2,
|
3234 | doRemove
|
3235 | );
|
3236 | }
|
3237 | }
|
3238 | };
|
3239 | return suspense;
|
3240 | }
|
3241 | function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) {
|
3242 | const suspense = vnode.suspense = createSuspenseBoundary(
|
3243 | vnode,
|
3244 | parentSuspense,
|
3245 | parentComponent,
|
3246 | node.parentNode,
|
3247 |
|
3248 | document.createElement("div"),
|
3249 | null,
|
3250 | namespace,
|
3251 | slotScopeIds,
|
3252 | optimized,
|
3253 | rendererInternals,
|
3254 | true
|
3255 | );
|
3256 | const result = hydrateNode(
|
3257 | node,
|
3258 | suspense.pendingBranch = vnode.ssContent,
|
3259 | parentComponent,
|
3260 | suspense,
|
3261 | slotScopeIds,
|
3262 | optimized
|
3263 | );
|
3264 | if (suspense.deps === 0) {
|
3265 | suspense.resolve(false, true);
|
3266 | }
|
3267 | return result;
|
3268 | }
|
3269 | function normalizeSuspenseChildren(vnode) {
|
3270 | const { shapeFlag, children } = vnode;
|
3271 | const isSlotChildren = shapeFlag & 32;
|
3272 | vnode.ssContent = normalizeSuspenseSlot(
|
3273 | isSlotChildren ? children.default : children
|
3274 | );
|
3275 | vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
|
3276 | }
|
3277 | function normalizeSuspenseSlot(s) {
|
3278 | let block;
|
3279 | if (isFunction(s)) {
|
3280 | const trackBlock = isBlockTreeEnabled && s._c;
|
3281 | if (trackBlock) {
|
3282 | s._d = false;
|
3283 | openBlock();
|
3284 | }
|
3285 | s = s();
|
3286 | if (trackBlock) {
|
3287 | s._d = true;
|
3288 | block = currentBlock;
|
3289 | closeBlock();
|
3290 | }
|
3291 | }
|
3292 | if (isArray(s)) {
|
3293 | const singleChild = filterSingleRoot(s);
|
3294 | if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
|
3295 | warn$1(`<Suspense> slots expect a single root node.`);
|
3296 | }
|
3297 | s = singleChild;
|
3298 | }
|
3299 | s = normalizeVNode(s);
|
3300 | if (block && !s.dynamicChildren) {
|
3301 | s.dynamicChildren = block.filter((c) => c !== s);
|
3302 | }
|
3303 | return s;
|
3304 | }
|
3305 | function queueEffectWithSuspense(fn, suspense) {
|
3306 | if (suspense && suspense.pendingBranch) {
|
3307 | if (isArray(fn)) {
|
3308 | suspense.effects.push(...fn);
|
3309 | } else {
|
3310 | suspense.effects.push(fn);
|
3311 | }
|
3312 | } else {
|
3313 | queuePostFlushCb(fn);
|
3314 | }
|
3315 | }
|
3316 | function setActiveBranch(suspense, branch) {
|
3317 | suspense.activeBranch = branch;
|
3318 | const { vnode, parentComponent } = suspense;
|
3319 | let el = branch.el;
|
3320 | while (!el && branch.component) {
|
3321 | branch = branch.component.subTree;
|
3322 | el = branch.el;
|
3323 | }
|
3324 | vnode.el = el;
|
3325 | if (parentComponent && parentComponent.subTree === vnode) {
|
3326 | parentComponent.vnode.el = el;
|
3327 | updateHOCHostEl(parentComponent, el);
|
3328 | }
|
3329 | }
|
3330 | function isVNodeSuspensible(vnode) {
|
3331 | var _a;
|
3332 | return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
|
3333 | }
|
3334 |
|
3335 | const ssrContextKey = Symbol.for("v-scx");
|
3336 | const useSSRContext = () => {
|
3337 | {
|
3338 | warn$1(`useSSRContext() is not supported in the global build.`);
|
3339 | }
|
3340 | };
|
3341 |
|
3342 | function watchEffect(effect, options) {
|
3343 | return doWatch(effect, null, options);
|
3344 | }
|
3345 | function watchPostEffect(effect, options) {
|
3346 | return doWatch(
|
3347 | effect,
|
3348 | null,
|
3349 | extend({}, options, { flush: "post" })
|
3350 | );
|
3351 | }
|
3352 | function watchSyncEffect(effect, options) {
|
3353 | return doWatch(
|
3354 | effect,
|
3355 | null,
|
3356 | extend({}, options, { flush: "sync" })
|
3357 | );
|
3358 | }
|
3359 | const INITIAL_WATCHER_VALUE = {};
|
3360 | function watch(source, cb, options) {
|
3361 | if (!isFunction(cb)) {
|
3362 | warn$1(
|
3363 | `\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`
|
3364 | );
|
3365 | }
|
3366 | return doWatch(source, cb, options);
|
3367 | }
|
3368 | function doWatch(source, cb, {
|
3369 | immediate,
|
3370 | deep,
|
3371 | flush,
|
3372 | once,
|
3373 | onTrack,
|
3374 | onTrigger
|
3375 | } = EMPTY_OBJ) {
|
3376 | if (cb && once) {
|
3377 | const _cb = cb;
|
3378 | cb = (...args) => {
|
3379 | _cb(...args);
|
3380 | unwatch();
|
3381 | };
|
3382 | }
|
3383 | if (deep !== void 0 && typeof deep === "number") {
|
3384 | warn$1(
|
3385 | `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`
|
3386 | );
|
3387 | }
|
3388 | if (!cb) {
|
3389 | if (immediate !== void 0) {
|
3390 | warn$1(
|
3391 | `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
|
3392 | );
|
3393 | }
|
3394 | if (deep !== void 0) {
|
3395 | warn$1(
|
3396 | `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
|
3397 | );
|
3398 | }
|
3399 | if (once !== void 0) {
|
3400 | warn$1(
|
3401 | `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
|
3402 | );
|
3403 | }
|
3404 | }
|
3405 | const warnInvalidSource = (s) => {
|
3406 | warn$1(
|
3407 | `Invalid watch source: `,
|
3408 | s,
|
3409 | `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
|
3410 | );
|
3411 | };
|
3412 | const instance = currentInstance;
|
3413 | const reactiveGetter = (source2) => deep === true ? source2 : (
|
3414 |
|
3415 | traverse(source2, deep === false ? 1 : void 0)
|
3416 | );
|
3417 | let getter;
|
3418 | let forceTrigger = false;
|
3419 | let isMultiSource = false;
|
3420 | if (isRef(source)) {
|
3421 | getter = () => source.value;
|
3422 | forceTrigger = isShallow(source);
|
3423 | } else if (isReactive(source)) {
|
3424 | getter = () => reactiveGetter(source);
|
3425 | forceTrigger = true;
|
3426 | } else if (isArray(source)) {
|
3427 | isMultiSource = true;
|
3428 | forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
3429 | getter = () => source.map((s) => {
|
3430 | if (isRef(s)) {
|
3431 | return s.value;
|
3432 | } else if (isReactive(s)) {
|
3433 | return reactiveGetter(s);
|
3434 | } else if (isFunction(s)) {
|
3435 | return callWithErrorHandling(s, instance, 2);
|
3436 | } else {
|
3437 | warnInvalidSource(s);
|
3438 | }
|
3439 | });
|
3440 | } else if (isFunction(source)) {
|
3441 | if (cb) {
|
3442 | getter = () => callWithErrorHandling(source, instance, 2);
|
3443 | } else {
|
3444 | getter = () => {
|
3445 | if (cleanup) {
|
3446 | cleanup();
|
3447 | }
|
3448 | return callWithAsyncErrorHandling(
|
3449 | source,
|
3450 | instance,
|
3451 | 3,
|
3452 | [onCleanup]
|
3453 | );
|
3454 | };
|
3455 | }
|
3456 | } else {
|
3457 | getter = NOOP;
|
3458 | warnInvalidSource(source);
|
3459 | }
|
3460 | if (cb && deep) {
|
3461 | const baseGetter = getter;
|
3462 | getter = () => traverse(baseGetter());
|
3463 | }
|
3464 | let cleanup;
|
3465 | let onCleanup = (fn) => {
|
3466 | cleanup = effect.onStop = () => {
|
3467 | callWithErrorHandling(fn, instance, 4);
|
3468 | cleanup = effect.onStop = void 0;
|
3469 | };
|
3470 | };
|
3471 | let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
3472 | const job = () => {
|
3473 | if (!effect.active || !effect.dirty) {
|
3474 | return;
|
3475 | }
|
3476 | if (cb) {
|
3477 | const newValue = effect.run();
|
3478 | if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
|
3479 | if (cleanup) {
|
3480 | cleanup();
|
3481 | }
|
3482 | callWithAsyncErrorHandling(cb, instance, 3, [
|
3483 | newValue,
|
3484 |
|
3485 | oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
3486 | onCleanup
|
3487 | ]);
|
3488 | oldValue = newValue;
|
3489 | }
|
3490 | } else {
|
3491 | effect.run();
|
3492 | }
|
3493 | };
|
3494 | job.allowRecurse = !!cb;
|
3495 | let scheduler;
|
3496 | if (flush === "sync") {
|
3497 | scheduler = job;
|
3498 | } else if (flush === "post") {
|
3499 | scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
3500 | } else {
|
3501 | job.pre = true;
|
3502 | if (instance)
|
3503 | job.id = instance.uid;
|
3504 | scheduler = () => queueJob(job);
|
3505 | }
|
3506 | const effect = new ReactiveEffect(getter, NOOP, scheduler);
|
3507 | const scope = getCurrentScope();
|
3508 | const unwatch = () => {
|
3509 | effect.stop();
|
3510 | if (scope) {
|
3511 | remove(scope.effects, effect);
|
3512 | }
|
3513 | };
|
3514 | {
|
3515 | effect.onTrack = onTrack;
|
3516 | effect.onTrigger = onTrigger;
|
3517 | }
|
3518 | if (cb) {
|
3519 | if (immediate) {
|
3520 | job();
|
3521 | } else {
|
3522 | oldValue = effect.run();
|
3523 | }
|
3524 | } else if (flush === "post") {
|
3525 | queuePostRenderEffect(
|
3526 | effect.run.bind(effect),
|
3527 | instance && instance.suspense
|
3528 | );
|
3529 | } else {
|
3530 | effect.run();
|
3531 | }
|
3532 | return unwatch;
|
3533 | }
|
3534 | function instanceWatch(source, value, options) {
|
3535 | const publicThis = this.proxy;
|
3536 | const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
|
3537 | let cb;
|
3538 | if (isFunction(value)) {
|
3539 | cb = value;
|
3540 | } else {
|
3541 | cb = value.handler;
|
3542 | options = value;
|
3543 | }
|
3544 | const reset = setCurrentInstance(this);
|
3545 | const res = doWatch(getter, cb.bind(publicThis), options);
|
3546 | reset();
|
3547 | return res;
|
3548 | }
|
3549 | function createPathGetter(ctx, path) {
|
3550 | const segments = path.split(".");
|
3551 | return () => {
|
3552 | let cur = ctx;
|
3553 | for (let i = 0; i < segments.length && cur; i++) {
|
3554 | cur = cur[segments[i]];
|
3555 | }
|
3556 | return cur;
|
3557 | };
|
3558 | }
|
3559 | function traverse(value, depth, currentDepth = 0, seen) {
|
3560 | if (!isObject(value) || value["__v_skip"]) {
|
3561 | return value;
|
3562 | }
|
3563 | if (depth && depth > 0) {
|
3564 | if (currentDepth >= depth) {
|
3565 | return value;
|
3566 | }
|
3567 | currentDepth++;
|
3568 | }
|
3569 | seen = seen || new Set();
|
3570 | if (seen.has(value)) {
|
3571 | return value;
|
3572 | }
|
3573 | seen.add(value);
|
3574 | if (isRef(value)) {
|
3575 | traverse(value.value, depth, currentDepth, seen);
|
3576 | } else if (isArray(value)) {
|
3577 | for (let i = 0; i < value.length; i++) {
|
3578 | traverse(value[i], depth, currentDepth, seen);
|
3579 | }
|
3580 | } else if (isSet(value) || isMap(value)) {
|
3581 | value.forEach((v) => {
|
3582 | traverse(v, depth, currentDepth, seen);
|
3583 | });
|
3584 | } else if (isPlainObject(value)) {
|
3585 | for (const key in value) {
|
3586 | traverse(value[key], depth, currentDepth, seen);
|
3587 | }
|
3588 | }
|
3589 | return value;
|
3590 | }
|
3591 |
|
3592 | function validateDirectiveName(name) {
|
3593 | if (isBuiltInDirective(name)) {
|
3594 | warn$1("Do not use built-in directive ids as custom directive id: " + name);
|
3595 | }
|
3596 | }
|
3597 | function withDirectives(vnode, directives) {
|
3598 | if (currentRenderingInstance === null) {
|
3599 | warn$1(`withDirectives can only be used inside render functions.`);
|
3600 | return vnode;
|
3601 | }
|
3602 | const instance = getExposeProxy(currentRenderingInstance) || currentRenderingInstance.proxy;
|
3603 | const bindings = vnode.dirs || (vnode.dirs = []);
|
3604 | for (let i = 0; i < directives.length; i++) {
|
3605 | let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
|
3606 | if (dir) {
|
3607 | if (isFunction(dir)) {
|
3608 | dir = {
|
3609 | mounted: dir,
|
3610 | updated: dir
|
3611 | };
|
3612 | }
|
3613 | if (dir.deep) {
|
3614 | traverse(value);
|
3615 | }
|
3616 | bindings.push({
|
3617 | dir,
|
3618 | instance,
|
3619 | value,
|
3620 | oldValue: void 0,
|
3621 | arg,
|
3622 | modifiers
|
3623 | });
|
3624 | }
|
3625 | }
|
3626 | return vnode;
|
3627 | }
|
3628 | function invokeDirectiveHook(vnode, prevVNode, instance, name) {
|
3629 | const bindings = vnode.dirs;
|
3630 | const oldBindings = prevVNode && prevVNode.dirs;
|
3631 | for (let i = 0; i < bindings.length; i++) {
|
3632 | const binding = bindings[i];
|
3633 | if (oldBindings) {
|
3634 | binding.oldValue = oldBindings[i].value;
|
3635 | }
|
3636 | let hook = binding.dir[name];
|
3637 | if (hook) {
|
3638 | pauseTracking();
|
3639 | callWithAsyncErrorHandling(hook, instance, 8, [
|
3640 | vnode.el,
|
3641 | binding,
|
3642 | vnode,
|
3643 | prevVNode
|
3644 | ]);
|
3645 | resetTracking();
|
3646 | }
|
3647 | }
|
3648 | }
|
3649 |
|
3650 | const leaveCbKey = Symbol("_leaveCb");
|
3651 | const enterCbKey$1 = Symbol("_enterCb");
|
3652 | function useTransitionState() {
|
3653 | const state = {
|
3654 | isMounted: false,
|
3655 | isLeaving: false,
|
3656 | isUnmounting: false,
|
3657 | leavingVNodes: new Map()
|
3658 | };
|
3659 | onMounted(() => {
|
3660 | state.isMounted = true;
|
3661 | });
|
3662 | onBeforeUnmount(() => {
|
3663 | state.isUnmounting = true;
|
3664 | });
|
3665 | return state;
|
3666 | }
|
3667 | const TransitionHookValidator = [Function, Array];
|
3668 | const BaseTransitionPropsValidators = {
|
3669 | mode: String,
|
3670 | appear: Boolean,
|
3671 | persisted: Boolean,
|
3672 |
|
3673 | onBeforeEnter: TransitionHookValidator,
|
3674 | onEnter: TransitionHookValidator,
|
3675 | onAfterEnter: TransitionHookValidator,
|
3676 | onEnterCancelled: TransitionHookValidator,
|
3677 |
|
3678 | onBeforeLeave: TransitionHookValidator,
|
3679 | onLeave: TransitionHookValidator,
|
3680 | onAfterLeave: TransitionHookValidator,
|
3681 | onLeaveCancelled: TransitionHookValidator,
|
3682 |
|
3683 | onBeforeAppear: TransitionHookValidator,
|
3684 | onAppear: TransitionHookValidator,
|
3685 | onAfterAppear: TransitionHookValidator,
|
3686 | onAppearCancelled: TransitionHookValidator
|
3687 | };
|
3688 | const BaseTransitionImpl = {
|
3689 | name: `BaseTransition`,
|
3690 | props: BaseTransitionPropsValidators,
|
3691 | setup(props, { slots }) {
|
3692 | const instance = getCurrentInstance();
|
3693 | const state = useTransitionState();
|
3694 | let prevTransitionKey;
|
3695 | return () => {
|
3696 | const children = slots.default && getTransitionRawChildren(slots.default(), true);
|
3697 | if (!children || !children.length) {
|
3698 | return;
|
3699 | }
|
3700 | let child = children[0];
|
3701 | if (children.length > 1) {
|
3702 | let hasFound = false;
|
3703 | for (const c of children) {
|
3704 | if (c.type !== Comment) {
|
3705 | if (hasFound) {
|
3706 | warn$1(
|
3707 | "<transition> can only be used on a single element or component. Use <transition-group> for lists."
|
3708 | );
|
3709 | break;
|
3710 | }
|
3711 | child = c;
|
3712 | hasFound = true;
|
3713 | }
|
3714 | }
|
3715 | }
|
3716 | const rawProps = toRaw(props);
|
3717 | const { mode } = rawProps;
|
3718 | if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
|
3719 | warn$1(`invalid <transition> mode: ${mode}`);
|
3720 | }
|
3721 | if (state.isLeaving) {
|
3722 | return emptyPlaceholder(child);
|
3723 | }
|
3724 | const innerChild = getKeepAliveChild(child);
|
3725 | if (!innerChild) {
|
3726 | return emptyPlaceholder(child);
|
3727 | }
|
3728 | const enterHooks = resolveTransitionHooks(
|
3729 | innerChild,
|
3730 | rawProps,
|
3731 | state,
|
3732 | instance
|
3733 | );
|
3734 | setTransitionHooks(innerChild, enterHooks);
|
3735 | const oldChild = instance.subTree;
|
3736 | const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
|
3737 | let transitionKeyChanged = false;
|
3738 | const { getTransitionKey } = innerChild.type;
|
3739 | if (getTransitionKey) {
|
3740 | const key = getTransitionKey();
|
3741 | if (prevTransitionKey === void 0) {
|
3742 | prevTransitionKey = key;
|
3743 | } else if (key !== prevTransitionKey) {
|
3744 | prevTransitionKey = key;
|
3745 | transitionKeyChanged = true;
|
3746 | }
|
3747 | }
|
3748 | if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
|
3749 | const leavingHooks = resolveTransitionHooks(
|
3750 | oldInnerChild,
|
3751 | rawProps,
|
3752 | state,
|
3753 | instance
|
3754 | );
|
3755 | setTransitionHooks(oldInnerChild, leavingHooks);
|
3756 | if (mode === "out-in") {
|
3757 | state.isLeaving = true;
|
3758 | leavingHooks.afterLeave = () => {
|
3759 | state.isLeaving = false;
|
3760 | if (instance.update.active !== false) {
|
3761 | instance.effect.dirty = true;
|
3762 | instance.update();
|
3763 | }
|
3764 | };
|
3765 | return emptyPlaceholder(child);
|
3766 | } else if (mode === "in-out" && innerChild.type !== Comment) {
|
3767 | leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
|
3768 | const leavingVNodesCache = getLeavingNodesForType(
|
3769 | state,
|
3770 | oldInnerChild
|
3771 | );
|
3772 | leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
|
3773 | el[leaveCbKey] = () => {
|
3774 | earlyRemove();
|
3775 | el[leaveCbKey] = void 0;
|
3776 | delete enterHooks.delayedLeave;
|
3777 | };
|
3778 | enterHooks.delayedLeave = delayedLeave;
|
3779 | };
|
3780 | }
|
3781 | }
|
3782 | return child;
|
3783 | };
|
3784 | }
|
3785 | };
|
3786 | const BaseTransition = BaseTransitionImpl;
|
3787 | function getLeavingNodesForType(state, vnode) {
|
3788 | const { leavingVNodes } = state;
|
3789 | let leavingVNodesCache = leavingVNodes.get(vnode.type);
|
3790 | if (!leavingVNodesCache) {
|
3791 | leavingVNodesCache = Object.create(null);
|
3792 | leavingVNodes.set(vnode.type, leavingVNodesCache);
|
3793 | }
|
3794 | return leavingVNodesCache;
|
3795 | }
|
3796 | function resolveTransitionHooks(vnode, props, state, instance) {
|
3797 | const {
|
3798 | appear,
|
3799 | mode,
|
3800 | persisted = false,
|
3801 | onBeforeEnter,
|
3802 | onEnter,
|
3803 | onAfterEnter,
|
3804 | onEnterCancelled,
|
3805 | onBeforeLeave,
|
3806 | onLeave,
|
3807 | onAfterLeave,
|
3808 | onLeaveCancelled,
|
3809 | onBeforeAppear,
|
3810 | onAppear,
|
3811 | onAfterAppear,
|
3812 | onAppearCancelled
|
3813 | } = props;
|
3814 | const key = String(vnode.key);
|
3815 | const leavingVNodesCache = getLeavingNodesForType(state, vnode);
|
3816 | const callHook = (hook, args) => {
|
3817 | hook && callWithAsyncErrorHandling(
|
3818 | hook,
|
3819 | instance,
|
3820 | 9,
|
3821 | args
|
3822 | );
|
3823 | };
|
3824 | const callAsyncHook = (hook, args) => {
|
3825 | const done = args[1];
|
3826 | callHook(hook, args);
|
3827 | if (isArray(hook)) {
|
3828 | if (hook.every((hook2) => hook2.length <= 1))
|
3829 | done();
|
3830 | } else if (hook.length <= 1) {
|
3831 | done();
|
3832 | }
|
3833 | };
|
3834 | const hooks = {
|
3835 | mode,
|
3836 | persisted,
|
3837 | beforeEnter(el) {
|
3838 | let hook = onBeforeEnter;
|
3839 | if (!state.isMounted) {
|
3840 | if (appear) {
|
3841 | hook = onBeforeAppear || onBeforeEnter;
|
3842 | } else {
|
3843 | return;
|
3844 | }
|
3845 | }
|
3846 | if (el[leaveCbKey]) {
|
3847 | el[leaveCbKey](
|
3848 | true
|
3849 |
|
3850 | );
|
3851 | }
|
3852 | const leavingVNode = leavingVNodesCache[key];
|
3853 | if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
|
3854 | leavingVNode.el[leaveCbKey]();
|
3855 | }
|
3856 | callHook(hook, [el]);
|
3857 | },
|
3858 | enter(el) {
|
3859 | let hook = onEnter;
|
3860 | let afterHook = onAfterEnter;
|
3861 | let cancelHook = onEnterCancelled;
|
3862 | if (!state.isMounted) {
|
3863 | if (appear) {
|
3864 | hook = onAppear || onEnter;
|
3865 | afterHook = onAfterAppear || onAfterEnter;
|
3866 | cancelHook = onAppearCancelled || onEnterCancelled;
|
3867 | } else {
|
3868 | return;
|
3869 | }
|
3870 | }
|
3871 | let called = false;
|
3872 | const done = el[enterCbKey$1] = (cancelled) => {
|
3873 | if (called)
|
3874 | return;
|
3875 | called = true;
|
3876 | if (cancelled) {
|
3877 | callHook(cancelHook, [el]);
|
3878 | } else {
|
3879 | callHook(afterHook, [el]);
|
3880 | }
|
3881 | if (hooks.delayedLeave) {
|
3882 | hooks.delayedLeave();
|
3883 | }
|
3884 | el[enterCbKey$1] = void 0;
|
3885 | };
|
3886 | if (hook) {
|
3887 | callAsyncHook(hook, [el, done]);
|
3888 | } else {
|
3889 | done();
|
3890 | }
|
3891 | },
|
3892 | leave(el, remove) {
|
3893 | const key2 = String(vnode.key);
|
3894 | if (el[enterCbKey$1]) {
|
3895 | el[enterCbKey$1](
|
3896 | true
|
3897 |
|
3898 | );
|
3899 | }
|
3900 | if (state.isUnmounting) {
|
3901 | return remove();
|
3902 | }
|
3903 | callHook(onBeforeLeave, [el]);
|
3904 | let called = false;
|
3905 | const done = el[leaveCbKey] = (cancelled) => {
|
3906 | if (called)
|
3907 | return;
|
3908 | called = true;
|
3909 | remove();
|
3910 | if (cancelled) {
|
3911 | callHook(onLeaveCancelled, [el]);
|
3912 | } else {
|
3913 | callHook(onAfterLeave, [el]);
|
3914 | }
|
3915 | el[leaveCbKey] = void 0;
|
3916 | if (leavingVNodesCache[key2] === vnode) {
|
3917 | delete leavingVNodesCache[key2];
|
3918 | }
|
3919 | };
|
3920 | leavingVNodesCache[key2] = vnode;
|
3921 | if (onLeave) {
|
3922 | callAsyncHook(onLeave, [el, done]);
|
3923 | } else {
|
3924 | done();
|
3925 | }
|
3926 | },
|
3927 | clone(vnode2) {
|
3928 | return resolveTransitionHooks(vnode2, props, state, instance);
|
3929 | }
|
3930 | };
|
3931 | return hooks;
|
3932 | }
|
3933 | function emptyPlaceholder(vnode) {
|
3934 | if (isKeepAlive(vnode)) {
|
3935 | vnode = cloneVNode(vnode);
|
3936 | vnode.children = null;
|
3937 | return vnode;
|
3938 | }
|
3939 | }
|
3940 | function getKeepAliveChild(vnode) {
|
3941 | return isKeepAlive(vnode) ? (
|
3942 |
|
3943 |
|
3944 | vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
|
3945 | ) : vnode;
|
3946 | }
|
3947 | function setTransitionHooks(vnode, hooks) {
|
3948 | if (vnode.shapeFlag & 6 && vnode.component) {
|
3949 | setTransitionHooks(vnode.component.subTree, hooks);
|
3950 | } else if (vnode.shapeFlag & 128) {
|
3951 | vnode.ssContent.transition = hooks.clone(vnode.ssContent);
|
3952 | vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
|
3953 | } else {
|
3954 | vnode.transition = hooks;
|
3955 | }
|
3956 | }
|
3957 | function getTransitionRawChildren(children, keepComment = false, parentKey) {
|
3958 | let ret = [];
|
3959 | let keyedFragmentCount = 0;
|
3960 | for (let i = 0; i < children.length; i++) {
|
3961 | let child = children[i];
|
3962 | const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
|
3963 | if (child.type === Fragment) {
|
3964 | if (child.patchFlag & 128)
|
3965 | keyedFragmentCount++;
|
3966 | ret = ret.concat(
|
3967 | getTransitionRawChildren(child.children, keepComment, key)
|
3968 | );
|
3969 | } else if (keepComment || child.type !== Comment) {
|
3970 | ret.push(key != null ? cloneVNode(child, { key }) : child);
|
3971 | }
|
3972 | }
|
3973 | if (keyedFragmentCount > 1) {
|
3974 | for (let i = 0; i < ret.length; i++) {
|
3975 | ret[i].patchFlag = -2;
|
3976 | }
|
3977 | }
|
3978 | return ret;
|
3979 | }
|
3980 |
|
3981 |
|
3982 |
|
3983 | function defineComponent(options, extraOptions) {
|
3984 | return isFunction(options) ? (
|
3985 |
|
3986 |
|
3987 | (() => extend({ name: options.name }, extraOptions, { setup: options }))()
|
3988 | ) : options;
|
3989 | }
|
3990 |
|
3991 | const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
|
3992 |
|
3993 |
|
3994 | function defineAsyncComponent(source) {
|
3995 | if (isFunction(source)) {
|
3996 | source = { loader: source };
|
3997 | }
|
3998 | const {
|
3999 | loader,
|
4000 | loadingComponent,
|
4001 | errorComponent,
|
4002 | delay = 200,
|
4003 | timeout,
|
4004 |
|
4005 | suspensible = true,
|
4006 | onError: userOnError
|
4007 | } = source;
|
4008 | let pendingRequest = null;
|
4009 | let resolvedComp;
|
4010 | let retries = 0;
|
4011 | const retry = () => {
|
4012 | retries++;
|
4013 | pendingRequest = null;
|
4014 | return load();
|
4015 | };
|
4016 | const load = () => {
|
4017 | let thisRequest;
|
4018 | return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
|
4019 | err = err instanceof Error ? err : new Error(String(err));
|
4020 | if (userOnError) {
|
4021 | return new Promise((resolve, reject) => {
|
4022 | const userRetry = () => resolve(retry());
|
4023 | const userFail = () => reject(err);
|
4024 | userOnError(err, userRetry, userFail, retries + 1);
|
4025 | });
|
4026 | } else {
|
4027 | throw err;
|
4028 | }
|
4029 | }).then((comp) => {
|
4030 | if (thisRequest !== pendingRequest && pendingRequest) {
|
4031 | return pendingRequest;
|
4032 | }
|
4033 | if (!comp) {
|
4034 | warn$1(
|
4035 | `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
|
4036 | );
|
4037 | }
|
4038 | if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
|
4039 | comp = comp.default;
|
4040 | }
|
4041 | if (comp && !isObject(comp) && !isFunction(comp)) {
|
4042 | throw new Error(`Invalid async component load result: ${comp}`);
|
4043 | }
|
4044 | resolvedComp = comp;
|
4045 | return comp;
|
4046 | }));
|
4047 | };
|
4048 | return defineComponent({
|
4049 | name: "AsyncComponentWrapper",
|
4050 | __asyncLoader: load,
|
4051 | get __asyncResolved() {
|
4052 | return resolvedComp;
|
4053 | },
|
4054 | setup() {
|
4055 | const instance = currentInstance;
|
4056 | if (resolvedComp) {
|
4057 | return () => createInnerComp(resolvedComp, instance);
|
4058 | }
|
4059 | const onError = (err) => {
|
4060 | pendingRequest = null;
|
4061 | handleError(
|
4062 | err,
|
4063 | instance,
|
4064 | 13,
|
4065 | !errorComponent
|
4066 | );
|
4067 | };
|
4068 | if (suspensible && instance.suspense || false) {
|
4069 | return load().then((comp) => {
|
4070 | return () => createInnerComp(comp, instance);
|
4071 | }).catch((err) => {
|
4072 | onError(err);
|
4073 | return () => errorComponent ? createVNode(errorComponent, {
|
4074 | error: err
|
4075 | }) : null;
|
4076 | });
|
4077 | }
|
4078 | const loaded = ref(false);
|
4079 | const error = ref();
|
4080 | const delayed = ref(!!delay);
|
4081 | if (delay) {
|
4082 | setTimeout(() => {
|
4083 | delayed.value = false;
|
4084 | }, delay);
|
4085 | }
|
4086 | if (timeout != null) {
|
4087 | setTimeout(() => {
|
4088 | if (!loaded.value && !error.value) {
|
4089 | const err = new Error(
|
4090 | `Async component timed out after ${timeout}ms.`
|
4091 | );
|
4092 | onError(err);
|
4093 | error.value = err;
|
4094 | }
|
4095 | }, timeout);
|
4096 | }
|
4097 | load().then(() => {
|
4098 | loaded.value = true;
|
4099 | if (instance.parent && isKeepAlive(instance.parent.vnode)) {
|
4100 | instance.parent.effect.dirty = true;
|
4101 | queueJob(instance.parent.update);
|
4102 | }
|
4103 | }).catch((err) => {
|
4104 | onError(err);
|
4105 | error.value = err;
|
4106 | });
|
4107 | return () => {
|
4108 | if (loaded.value && resolvedComp) {
|
4109 | return createInnerComp(resolvedComp, instance);
|
4110 | } else if (error.value && errorComponent) {
|
4111 | return createVNode(errorComponent, {
|
4112 | error: error.value
|
4113 | });
|
4114 | } else if (loadingComponent && !delayed.value) {
|
4115 | return createVNode(loadingComponent);
|
4116 | }
|
4117 | };
|
4118 | }
|
4119 | });
|
4120 | }
|
4121 | function createInnerComp(comp, parent) {
|
4122 | const { ref: ref2, props, children, ce } = parent.vnode;
|
4123 | const vnode = createVNode(comp, props, children);
|
4124 | vnode.ref = ref2;
|
4125 | vnode.ce = ce;
|
4126 | delete parent.vnode.ce;
|
4127 | return vnode;
|
4128 | }
|
4129 |
|
4130 | const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
4131 | const KeepAliveImpl = {
|
4132 | name: `KeepAlive`,
|
4133 |
|
4134 |
|
4135 |
|
4136 | __isKeepAlive: true,
|
4137 | props: {
|
4138 | include: [String, RegExp, Array],
|
4139 | exclude: [String, RegExp, Array],
|
4140 | max: [String, Number]
|
4141 | },
|
4142 | setup(props, { slots }) {
|
4143 | const instance = getCurrentInstance();
|
4144 | const sharedContext = instance.ctx;
|
4145 | const cache = new Map();
|
4146 | const keys = new Set();
|
4147 | let current = null;
|
4148 | {
|
4149 | instance.__v_cache = cache;
|
4150 | }
|
4151 | const parentSuspense = instance.suspense;
|
4152 | const {
|
4153 | renderer: {
|
4154 | p: patch,
|
4155 | m: move,
|
4156 | um: _unmount,
|
4157 | o: { createElement }
|
4158 | }
|
4159 | } = sharedContext;
|
4160 | const storageContainer = createElement("div");
|
4161 | sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
|
4162 | const instance2 = vnode.component;
|
4163 | move(vnode, container, anchor, 0, parentSuspense);
|
4164 | patch(
|
4165 | instance2.vnode,
|
4166 | vnode,
|
4167 | container,
|
4168 | anchor,
|
4169 | instance2,
|
4170 | parentSuspense,
|
4171 | namespace,
|
4172 | vnode.slotScopeIds,
|
4173 | optimized
|
4174 | );
|
4175 | queuePostRenderEffect(() => {
|
4176 | instance2.isDeactivated = false;
|
4177 | if (instance2.a) {
|
4178 | invokeArrayFns(instance2.a);
|
4179 | }
|
4180 | const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
|
4181 | if (vnodeHook) {
|
4182 | invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
4183 | }
|
4184 | }, parentSuspense);
|
4185 | {
|
4186 | devtoolsComponentAdded(instance2);
|
4187 | }
|
4188 | };
|
4189 | sharedContext.deactivate = (vnode) => {
|
4190 | const instance2 = vnode.component;
|
4191 | move(vnode, storageContainer, null, 1, parentSuspense);
|
4192 | queuePostRenderEffect(() => {
|
4193 | if (instance2.da) {
|
4194 | invokeArrayFns(instance2.da);
|
4195 | }
|
4196 | const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
|
4197 | if (vnodeHook) {
|
4198 | invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
4199 | }
|
4200 | instance2.isDeactivated = true;
|
4201 | }, parentSuspense);
|
4202 | {
|
4203 | devtoolsComponentAdded(instance2);
|
4204 | }
|
4205 | };
|
4206 | function unmount(vnode) {
|
4207 | resetShapeFlag(vnode);
|
4208 | _unmount(vnode, instance, parentSuspense, true);
|
4209 | }
|
4210 | function pruneCache(filter) {
|
4211 | cache.forEach((vnode, key) => {
|
4212 | const name = getComponentName(vnode.type);
|
4213 | if (name && (!filter || !filter(name))) {
|
4214 | pruneCacheEntry(key);
|
4215 | }
|
4216 | });
|
4217 | }
|
4218 | function pruneCacheEntry(key) {
|
4219 | const cached = cache.get(key);
|
4220 | if (!current || !isSameVNodeType(cached, current)) {
|
4221 | unmount(cached);
|
4222 | } else if (current) {
|
4223 | resetShapeFlag(current);
|
4224 | }
|
4225 | cache.delete(key);
|
4226 | keys.delete(key);
|
4227 | }
|
4228 | watch(
|
4229 | () => [props.include, props.exclude],
|
4230 | ([include, exclude]) => {
|
4231 | include && pruneCache((name) => matches(include, name));
|
4232 | exclude && pruneCache((name) => !matches(exclude, name));
|
4233 | },
|
4234 |
|
4235 | { flush: "post", deep: true }
|
4236 | );
|
4237 | let pendingCacheKey = null;
|
4238 | const cacheSubtree = () => {
|
4239 | if (pendingCacheKey != null) {
|
4240 | cache.set(pendingCacheKey, getInnerChild(instance.subTree));
|
4241 | }
|
4242 | };
|
4243 | onMounted(cacheSubtree);
|
4244 | onUpdated(cacheSubtree);
|
4245 | onBeforeUnmount(() => {
|
4246 | cache.forEach((cached) => {
|
4247 | const { subTree, suspense } = instance;
|
4248 | const vnode = getInnerChild(subTree);
|
4249 | if (cached.type === vnode.type && cached.key === vnode.key) {
|
4250 | resetShapeFlag(vnode);
|
4251 | const da = vnode.component.da;
|
4252 | da && queuePostRenderEffect(da, suspense);
|
4253 | return;
|
4254 | }
|
4255 | unmount(cached);
|
4256 | });
|
4257 | });
|
4258 | return () => {
|
4259 | pendingCacheKey = null;
|
4260 | if (!slots.default) {
|
4261 | return null;
|
4262 | }
|
4263 | const children = slots.default();
|
4264 | const rawVNode = children[0];
|
4265 | if (children.length > 1) {
|
4266 | {
|
4267 | warn$1(`KeepAlive should contain exactly one component child.`);
|
4268 | }
|
4269 | current = null;
|
4270 | return children;
|
4271 | } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
|
4272 | current = null;
|
4273 | return rawVNode;
|
4274 | }
|
4275 | let vnode = getInnerChild(rawVNode);
|
4276 | const comp = vnode.type;
|
4277 | const name = getComponentName(
|
4278 | isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
|
4279 | );
|
4280 | const { include, exclude, max } = props;
|
4281 | if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
|
4282 | current = vnode;
|
4283 | return rawVNode;
|
4284 | }
|
4285 | const key = vnode.key == null ? comp : vnode.key;
|
4286 | const cachedVNode = cache.get(key);
|
4287 | if (vnode.el) {
|
4288 | vnode = cloneVNode(vnode);
|
4289 | if (rawVNode.shapeFlag & 128) {
|
4290 | rawVNode.ssContent = vnode;
|
4291 | }
|
4292 | }
|
4293 | pendingCacheKey = key;
|
4294 | if (cachedVNode) {
|
4295 | vnode.el = cachedVNode.el;
|
4296 | vnode.component = cachedVNode.component;
|
4297 | if (vnode.transition) {
|
4298 | setTransitionHooks(vnode, vnode.transition);
|
4299 | }
|
4300 | vnode.shapeFlag |= 512;
|
4301 | keys.delete(key);
|
4302 | keys.add(key);
|
4303 | } else {
|
4304 | keys.add(key);
|
4305 | if (max && keys.size > parseInt(max, 10)) {
|
4306 | pruneCacheEntry(keys.values().next().value);
|
4307 | }
|
4308 | }
|
4309 | vnode.shapeFlag |= 256;
|
4310 | current = vnode;
|
4311 | return isSuspense(rawVNode.type) ? rawVNode : vnode;
|
4312 | };
|
4313 | }
|
4314 | };
|
4315 | const KeepAlive = KeepAliveImpl;
|
4316 | function matches(pattern, name) {
|
4317 | if (isArray(pattern)) {
|
4318 | return pattern.some((p) => matches(p, name));
|
4319 | } else if (isString(pattern)) {
|
4320 | return pattern.split(",").includes(name);
|
4321 | } else if (isRegExp(pattern)) {
|
4322 | return pattern.test(name);
|
4323 | }
|
4324 | return false;
|
4325 | }
|
4326 | function onActivated(hook, target) {
|
4327 | registerKeepAliveHook(hook, "a", target);
|
4328 | }
|
4329 | function onDeactivated(hook, target) {
|
4330 | registerKeepAliveHook(hook, "da", target);
|
4331 | }
|
4332 | function registerKeepAliveHook(hook, type, target = currentInstance) {
|
4333 | const wrappedHook = hook.__wdc || (hook.__wdc = () => {
|
4334 | let current = target;
|
4335 | while (current) {
|
4336 | if (current.isDeactivated) {
|
4337 | return;
|
4338 | }
|
4339 | current = current.parent;
|
4340 | }
|
4341 | return hook();
|
4342 | });
|
4343 | injectHook(type, wrappedHook, target);
|
4344 | if (target) {
|
4345 | let current = target.parent;
|
4346 | while (current && current.parent) {
|
4347 | if (isKeepAlive(current.parent.vnode)) {
|
4348 | injectToKeepAliveRoot(wrappedHook, type, target, current);
|
4349 | }
|
4350 | current = current.parent;
|
4351 | }
|
4352 | }
|
4353 | }
|
4354 | function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
|
4355 | const injected = injectHook(
|
4356 | type,
|
4357 | hook,
|
4358 | keepAliveRoot,
|
4359 | true
|
4360 |
|
4361 | );
|
4362 | onUnmounted(() => {
|
4363 | remove(keepAliveRoot[type], injected);
|
4364 | }, target);
|
4365 | }
|
4366 | function resetShapeFlag(vnode) {
|
4367 | vnode.shapeFlag &= ~256;
|
4368 | vnode.shapeFlag &= ~512;
|
4369 | }
|
4370 | function getInnerChild(vnode) {
|
4371 | return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
|
4372 | }
|
4373 |
|
4374 | function injectHook(type, hook, target = currentInstance, prepend = false) {
|
4375 | if (target) {
|
4376 | const hooks = target[type] || (target[type] = []);
|
4377 | const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
|
4378 | if (target.isUnmounted) {
|
4379 | return;
|
4380 | }
|
4381 | pauseTracking();
|
4382 | const reset = setCurrentInstance(target);
|
4383 | const res = callWithAsyncErrorHandling(hook, target, type, args);
|
4384 | reset();
|
4385 | resetTracking();
|
4386 | return res;
|
4387 | });
|
4388 | if (prepend) {
|
4389 | hooks.unshift(wrappedHook);
|
4390 | } else {
|
4391 | hooks.push(wrappedHook);
|
4392 | }
|
4393 | return wrappedHook;
|
4394 | } else {
|
4395 | const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
|
4396 | warn$1(
|
4397 | `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
|
4398 | );
|
4399 | }
|
4400 | }
|
4401 | const createHook = (lifecycle) => (hook, target = currentInstance) => (
|
4402 |
|
4403 | (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target)
|
4404 | );
|
4405 | const onBeforeMount = createHook("bm");
|
4406 | const onMounted = createHook("m");
|
4407 | const onBeforeUpdate = createHook("bu");
|
4408 | const onUpdated = createHook("u");
|
4409 | const onBeforeUnmount = createHook("bum");
|
4410 | const onUnmounted = createHook("um");
|
4411 | const onServerPrefetch = createHook("sp");
|
4412 | const onRenderTriggered = createHook(
|
4413 | "rtg"
|
4414 | );
|
4415 | const onRenderTracked = createHook(
|
4416 | "rtc"
|
4417 | );
|
4418 | function onErrorCaptured(hook, target = currentInstance) {
|
4419 | injectHook("ec", hook, target);
|
4420 | }
|
4421 |
|
4422 | function renderList(source, renderItem, cache, index) {
|
4423 | let ret;
|
4424 | const cached = cache && cache[index];
|
4425 | if (isArray(source) || isString(source)) {
|
4426 | ret = new Array(source.length);
|
4427 | for (let i = 0, l = source.length; i < l; i++) {
|
4428 | ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
|
4429 | }
|
4430 | } else if (typeof source === "number") {
|
4431 | if (!Number.isInteger(source)) {
|
4432 | warn$1(`The v-for range expect an integer value but got ${source}.`);
|
4433 | }
|
4434 | ret = new Array(source);
|
4435 | for (let i = 0; i < source; i++) {
|
4436 | ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
|
4437 | }
|
4438 | } else if (isObject(source)) {
|
4439 | if (source[Symbol.iterator]) {
|
4440 | ret = Array.from(
|
4441 | source,
|
4442 | (item, i) => renderItem(item, i, void 0, cached && cached[i])
|
4443 | );
|
4444 | } else {
|
4445 | const keys = Object.keys(source);
|
4446 | ret = new Array(keys.length);
|
4447 | for (let i = 0, l = keys.length; i < l; i++) {
|
4448 | const key = keys[i];
|
4449 | ret[i] = renderItem(source[key], key, i, cached && cached[i]);
|
4450 | }
|
4451 | }
|
4452 | } else {
|
4453 | ret = [];
|
4454 | }
|
4455 | if (cache) {
|
4456 | cache[index] = ret;
|
4457 | }
|
4458 | return ret;
|
4459 | }
|
4460 |
|
4461 | function createSlots(slots, dynamicSlots) {
|
4462 | for (let i = 0; i < dynamicSlots.length; i++) {
|
4463 | const slot = dynamicSlots[i];
|
4464 | if (isArray(slot)) {
|
4465 | for (let j = 0; j < slot.length; j++) {
|
4466 | slots[slot[j].name] = slot[j].fn;
|
4467 | }
|
4468 | } else if (slot) {
|
4469 | slots[slot.name] = slot.key ? (...args) => {
|
4470 | const res = slot.fn(...args);
|
4471 | if (res)
|
4472 | res.key = slot.key;
|
4473 | return res;
|
4474 | } : slot.fn;
|
4475 | }
|
4476 | }
|
4477 | return slots;
|
4478 | }
|
4479 |
|
4480 | function renderSlot(slots, name, props = {}, fallback, noSlotted) {
|
4481 | if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
|
4482 | if (name !== "default")
|
4483 | props.name = name;
|
4484 | return createVNode("slot", props, fallback && fallback());
|
4485 | }
|
4486 | let slot = slots[name];
|
4487 | if (slot && slot.length > 1) {
|
4488 | warn$1(
|
4489 | `SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template.`
|
4490 | );
|
4491 | slot = () => [];
|
4492 | }
|
4493 | if (slot && slot._c) {
|
4494 | slot._d = false;
|
4495 | }
|
4496 | openBlock();
|
4497 | const validSlotContent = slot && ensureValidVNode(slot(props));
|
4498 | const rendered = createBlock(
|
4499 | Fragment,
|
4500 | {
|
4501 | key: props.key ||
|
4502 |
|
4503 | validSlotContent && validSlotContent.key || `_${name}`
|
4504 | },
|
4505 | validSlotContent || (fallback ? fallback() : []),
|
4506 | validSlotContent && slots._ === 1 ? 64 : -2
|
4507 | );
|
4508 | if (!noSlotted && rendered.scopeId) {
|
4509 | rendered.slotScopeIds = [rendered.scopeId + "-s"];
|
4510 | }
|
4511 | if (slot && slot._c) {
|
4512 | slot._d = true;
|
4513 | }
|
4514 | return rendered;
|
4515 | }
|
4516 | function ensureValidVNode(vnodes) {
|
4517 | return vnodes.some((child) => {
|
4518 | if (!isVNode(child))
|
4519 | return true;
|
4520 | if (child.type === Comment)
|
4521 | return false;
|
4522 | if (child.type === Fragment && !ensureValidVNode(child.children))
|
4523 | return false;
|
4524 | return true;
|
4525 | }) ? vnodes : null;
|
4526 | }
|
4527 |
|
4528 | function toHandlers(obj, preserveCaseIfNecessary) {
|
4529 | const ret = {};
|
4530 | if (!isObject(obj)) {
|
4531 | warn$1(`v-on with no argument expects an object value.`);
|
4532 | return ret;
|
4533 | }
|
4534 | for (const key in obj) {
|
4535 | ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : toHandlerKey(key)] = obj[key];
|
4536 | }
|
4537 | return ret;
|
4538 | }
|
4539 |
|
4540 | const getPublicInstance = (i) => {
|
4541 | if (!i)
|
4542 | return null;
|
4543 | if (isStatefulComponent(i))
|
4544 | return getExposeProxy(i) || i.proxy;
|
4545 | return getPublicInstance(i.parent);
|
4546 | };
|
4547 | const publicPropertiesMap = (
|
4548 |
|
4549 |
|
4550 | extend( Object.create(null), {
|
4551 | $: (i) => i,
|
4552 | $el: (i) => i.vnode.el,
|
4553 | $data: (i) => i.data,
|
4554 | $props: (i) => shallowReadonly(i.props) ,
|
4555 | $attrs: (i) => shallowReadonly(i.attrs) ,
|
4556 | $slots: (i) => shallowReadonly(i.slots) ,
|
4557 | $refs: (i) => shallowReadonly(i.refs) ,
|
4558 | $parent: (i) => getPublicInstance(i.parent),
|
4559 | $root: (i) => getPublicInstance(i.root),
|
4560 | $emit: (i) => i.emit,
|
4561 | $options: (i) => resolveMergedOptions(i) ,
|
4562 | $forceUpdate: (i) => i.f || (i.f = () => {
|
4563 | i.effect.dirty = true;
|
4564 | queueJob(i.update);
|
4565 | }),
|
4566 | $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
|
4567 | $watch: (i) => instanceWatch.bind(i)
|
4568 | })
|
4569 | );
|
4570 | const isReservedPrefix = (key) => key === "_" || key === "$";
|
4571 | const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
|
4572 | const PublicInstanceProxyHandlers = {
|
4573 | get({ _: instance }, key) {
|
4574 | const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
4575 | if (key === "__isVue") {
|
4576 | return true;
|
4577 | }
|
4578 | let normalizedProps;
|
4579 | if (key[0] !== "$") {
|
4580 | const n = accessCache[key];
|
4581 | if (n !== void 0) {
|
4582 | switch (n) {
|
4583 | case 1 :
|
4584 | return setupState[key];
|
4585 | case 2 :
|
4586 | return data[key];
|
4587 | case 4 :
|
4588 | return ctx[key];
|
4589 | case 3 :
|
4590 | return props[key];
|
4591 | }
|
4592 | } else if (hasSetupBinding(setupState, key)) {
|
4593 | accessCache[key] = 1 ;
|
4594 | return setupState[key];
|
4595 | } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
4596 | accessCache[key] = 2 ;
|
4597 | return data[key];
|
4598 | } else if (
|
4599 |
|
4600 |
|
4601 | (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
|
4602 | ) {
|
4603 | accessCache[key] = 3 ;
|
4604 | return props[key];
|
4605 | } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
4606 | accessCache[key] = 4 ;
|
4607 | return ctx[key];
|
4608 | } else if (shouldCacheAccess) {
|
4609 | accessCache[key] = 0 ;
|
4610 | }
|
4611 | }
|
4612 | const publicGetter = publicPropertiesMap[key];
|
4613 | let cssModule, globalProperties;
|
4614 | if (publicGetter) {
|
4615 | if (key === "$attrs") {
|
4616 | track(instance, "get", key);
|
4617 | markAttrsAccessed();
|
4618 | } else if (key === "$slots") {
|
4619 | track(instance, "get", key);
|
4620 | }
|
4621 | return publicGetter(instance);
|
4622 | } else if (
|
4623 |
|
4624 | (cssModule = type.__cssModules) && (cssModule = cssModule[key])
|
4625 | ) {
|
4626 | return cssModule;
|
4627 | } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
4628 | accessCache[key] = 4 ;
|
4629 | return ctx[key];
|
4630 | } else if (
|
4631 |
|
4632 | globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
|
4633 | ) {
|
4634 | {
|
4635 | return globalProperties[key];
|
4636 | }
|
4637 | } else if (currentRenderingInstance && (!isString(key) ||
|
4638 |
|
4639 | key.indexOf("__v") !== 0)) {
|
4640 | if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
|
4641 | warn$1(
|
4642 | `Property ${JSON.stringify(
|
4643 | key
|
4644 | )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
|
4645 | );
|
4646 | } else if (instance === currentRenderingInstance) {
|
4647 | warn$1(
|
4648 | `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
|
4649 | );
|
4650 | }
|
4651 | }
|
4652 | },
|
4653 | set({ _: instance }, key, value) {
|
4654 | const { data, setupState, ctx } = instance;
|
4655 | if (hasSetupBinding(setupState, key)) {
|
4656 | setupState[key] = value;
|
4657 | return true;
|
4658 | } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
|
4659 | warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
|
4660 | return false;
|
4661 | } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
4662 | data[key] = value;
|
4663 | return true;
|
4664 | } else if (hasOwn(instance.props, key)) {
|
4665 | warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
|
4666 | return false;
|
4667 | }
|
4668 | if (key[0] === "$" && key.slice(1) in instance) {
|
4669 | warn$1(
|
4670 | `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
|
4671 | );
|
4672 | return false;
|
4673 | } else {
|
4674 | if (key in instance.appContext.config.globalProperties) {
|
4675 | Object.defineProperty(ctx, key, {
|
4676 | enumerable: true,
|
4677 | configurable: true,
|
4678 | value
|
4679 | });
|
4680 | } else {
|
4681 | ctx[key] = value;
|
4682 | }
|
4683 | }
|
4684 | return true;
|
4685 | },
|
4686 | has({
|
4687 | _: { data, setupState, accessCache, ctx, appContext, propsOptions }
|
4688 | }, key) {
|
4689 | let normalizedProps;
|
4690 | return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key);
|
4691 | },
|
4692 | defineProperty(target, key, descriptor) {
|
4693 | if (descriptor.get != null) {
|
4694 | target._.accessCache[key] = 0;
|
4695 | } else if (hasOwn(descriptor, "value")) {
|
4696 | this.set(target, key, descriptor.value, null);
|
4697 | }
|
4698 | return Reflect.defineProperty(target, key, descriptor);
|
4699 | }
|
4700 | };
|
4701 | {
|
4702 | PublicInstanceProxyHandlers.ownKeys = (target) => {
|
4703 | warn$1(
|
4704 | `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
|
4705 | );
|
4706 | return Reflect.ownKeys(target);
|
4707 | };
|
4708 | }
|
4709 | const RuntimeCompiledPublicInstanceProxyHandlers = extend(
|
4710 | {},
|
4711 | PublicInstanceProxyHandlers,
|
4712 | {
|
4713 | get(target, key) {
|
4714 | if (key === Symbol.unscopables) {
|
4715 | return;
|
4716 | }
|
4717 | return PublicInstanceProxyHandlers.get(target, key, target);
|
4718 | },
|
4719 | has(_, key) {
|
4720 | const has = key[0] !== "_" && !isGloballyAllowed(key);
|
4721 | if (!has && PublicInstanceProxyHandlers.has(_, key)) {
|
4722 | warn$1(
|
4723 | `Property ${JSON.stringify(
|
4724 | key
|
4725 | )} should not start with _ which is a reserved prefix for Vue internals.`
|
4726 | );
|
4727 | }
|
4728 | return has;
|
4729 | }
|
4730 | }
|
4731 | );
|
4732 | function createDevRenderContext(instance) {
|
4733 | const target = {};
|
4734 | Object.defineProperty(target, `_`, {
|
4735 | configurable: true,
|
4736 | enumerable: false,
|
4737 | get: () => instance
|
4738 | });
|
4739 | Object.keys(publicPropertiesMap).forEach((key) => {
|
4740 | Object.defineProperty(target, key, {
|
4741 | configurable: true,
|
4742 | enumerable: false,
|
4743 | get: () => publicPropertiesMap[key](instance),
|
4744 | // intercepted by the proxy so no need for implementation,
|
4745 | // but needed to prevent set errors
|
4746 | set: NOOP
|
4747 | });
|
4748 | });
|
4749 | return target;
|
4750 | }
|
4751 | function exposePropsOnRenderContext(instance) {
|
4752 | const {
|
4753 | ctx,
|
4754 | propsOptions: [propsOptions]
|
4755 | } = instance;
|
4756 | if (propsOptions) {
|
4757 | Object.keys(propsOptions).forEach((key) => {
|
4758 | Object.defineProperty(ctx, key, {
|
4759 | enumerable: true,
|
4760 | configurable: true,
|
4761 | get: () => instance.props[key],
|
4762 | set: NOOP
|
4763 | });
|
4764 | });
|
4765 | }
|
4766 | }
|
4767 | function exposeSetupStateOnRenderContext(instance) {
|
4768 | const { ctx, setupState } = instance;
|
4769 | Object.keys(toRaw(setupState)).forEach((key) => {
|
4770 | if (!setupState.__isScriptSetup) {
|
4771 | if (isReservedPrefix(key[0])) {
|
4772 | warn$1(
|
4773 | `setup() return property ${JSON.stringify(
|
4774 | key
|
4775 | )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`
|
4776 | );
|
4777 | return;
|
4778 | }
|
4779 | Object.defineProperty(ctx, key, {
|
4780 | enumerable: true,
|
4781 | configurable: true,
|
4782 | get: () => setupState[key],
|
4783 | set: NOOP
|
4784 | });
|
4785 | }
|
4786 | });
|
4787 | }
|
4788 |
|
4789 | const warnRuntimeUsage = (method) => warn$1(
|
4790 | `${method}() is a compiler-hint helper that is only usable inside <script setup> of a single file component. Its arguments should be compiled away and passing it at runtime has no effect.`
|
4791 | );
|
4792 | function defineProps() {
|
4793 | {
|
4794 | warnRuntimeUsage(`defineProps`);
|
4795 | }
|
4796 | return null;
|
4797 | }
|
4798 | function defineEmits() {
|
4799 | {
|
4800 | warnRuntimeUsage(`defineEmits`);
|
4801 | }
|
4802 | return null;
|
4803 | }
|
4804 | function defineExpose(exposed) {
|
4805 | {
|
4806 | warnRuntimeUsage(`defineExpose`);
|
4807 | }
|
4808 | }
|
4809 | function defineOptions(options) {
|
4810 | {
|
4811 | warnRuntimeUsage(`defineOptions`);
|
4812 | }
|
4813 | }
|
4814 | function defineSlots() {
|
4815 | {
|
4816 | warnRuntimeUsage(`defineSlots`);
|
4817 | }
|
4818 | return null;
|
4819 | }
|
4820 | function defineModel() {
|
4821 | {
|
4822 | warnRuntimeUsage("defineModel");
|
4823 | }
|
4824 | }
|
4825 | function withDefaults(props, defaults) {
|
4826 | {
|
4827 | warnRuntimeUsage(`withDefaults`);
|
4828 | }
|
4829 | return null;
|
4830 | }
|
4831 | function useSlots() {
|
4832 | return getContext().slots;
|
4833 | }
|
4834 | function useAttrs() {
|
4835 | return getContext().attrs;
|
4836 | }
|
4837 | function getContext() {
|
4838 | const i = getCurrentInstance();
|
4839 | if (!i) {
|
4840 | warn$1(`useContext() called without active instance.`);
|
4841 | }
|
4842 | return i.setupContext || (i.setupContext = createSetupContext(i));
|
4843 | }
|
4844 | function normalizePropsOrEmits(props) {
|
4845 | return isArray(props) ? props.reduce(
|
4846 | (normalized, p) => (normalized[p] = null, normalized),
|
4847 | {}
|
4848 | ) : props;
|
4849 | }
|
4850 | function mergeDefaults(raw, defaults) {
|
4851 | const props = normalizePropsOrEmits(raw);
|
4852 | for (const key in defaults) {
|
4853 | if (key.startsWith("__skip"))
|
4854 | continue;
|
4855 | let opt = props[key];
|
4856 | if (opt) {
|
4857 | if (isArray(opt) || isFunction(opt)) {
|
4858 | opt = props[key] = { type: opt, default: defaults[key] };
|
4859 | } else {
|
4860 | opt.default = defaults[key];
|
4861 | }
|
4862 | } else if (opt === null) {
|
4863 | opt = props[key] = { default: defaults[key] };
|
4864 | } else {
|
4865 | warn$1(`props default key "${key}" has no corresponding declaration.`);
|
4866 | }
|
4867 | if (opt && defaults[`__skip_${key}`]) {
|
4868 | opt.skipFactory = true;
|
4869 | }
|
4870 | }
|
4871 | return props;
|
4872 | }
|
4873 | function mergeModels(a, b) {
|
4874 | if (!a || !b)
|
4875 | return a || b;
|
4876 | if (isArray(a) && isArray(b))
|
4877 | return a.concat(b);
|
4878 | return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
|
4879 | }
|
4880 | function createPropsRestProxy(props, excludedKeys) {
|
4881 | const ret = {};
|
4882 | for (const key in props) {
|
4883 | if (!excludedKeys.includes(key)) {
|
4884 | Object.defineProperty(ret, key, {
|
4885 | enumerable: true,
|
4886 | get: () => props[key]
|
4887 | });
|
4888 | }
|
4889 | }
|
4890 | return ret;
|
4891 | }
|
4892 | function withAsyncContext(getAwaitable) {
|
4893 | const ctx = getCurrentInstance();
|
4894 | if (!ctx) {
|
4895 | warn$1(
|
4896 | `withAsyncContext called without active current instance. This is likely a bug.`
|
4897 | );
|
4898 | }
|
4899 | let awaitable = getAwaitable();
|
4900 | unsetCurrentInstance();
|
4901 | if (isPromise(awaitable)) {
|
4902 | awaitable = awaitable.catch((e) => {
|
4903 | setCurrentInstance(ctx);
|
4904 | throw e;
|
4905 | });
|
4906 | }
|
4907 | return [awaitable, () => setCurrentInstance(ctx)];
|
4908 | }
|
4909 |
|
4910 | function createDuplicateChecker() {
|
4911 | const cache = /* @__PURE__ */ Object.create(null);
|
4912 | return (type, key) => {
|
4913 | if (cache[key]) {
|
4914 | warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
|
4915 | } else {
|
4916 | cache[key] = type;
|
4917 | }
|
4918 | };
|
4919 | }
|
4920 | let shouldCacheAccess = true;
|
4921 | function applyOptions(instance) {
|
4922 | const options = resolveMergedOptions(instance);
|
4923 | const publicThis = instance.proxy;
|
4924 | const ctx = instance.ctx;
|
4925 | shouldCacheAccess = false;
|
4926 | if (options.beforeCreate) {
|
4927 | callHook$1(options.beforeCreate, instance, "bc");
|
4928 | }
|
4929 | const {
|
4930 | // state
|
4931 | data: dataOptions,
|
4932 | computed: computedOptions,
|
4933 | methods,
|
4934 | watch: watchOptions,
|
4935 | provide: provideOptions,
|
4936 | inject: injectOptions,
|
4937 | // lifecycle
|
4938 | created,
|
4939 | beforeMount,
|
4940 | mounted,
|
4941 | beforeUpdate,
|
4942 | updated,
|
4943 | activated,
|
4944 | deactivated,
|
4945 | beforeDestroy,
|
4946 | beforeUnmount,
|
4947 | destroyed,
|
4948 | unmounted,
|
4949 | render,
|
4950 | renderTracked,
|
4951 | renderTriggered,
|
4952 | errorCaptured,
|
4953 | serverPrefetch,
|
4954 | // public API
|
4955 | expose,
|
4956 | inheritAttrs,
|
4957 | // assets
|
4958 | components,
|
4959 | directives,
|
4960 | filters
|
4961 | } = options;
|
4962 | const checkDuplicateProperties = createDuplicateChecker() ;
|
4963 | {
|
4964 | const [propsOptions] = instance.propsOptions;
|
4965 | if (propsOptions) {
|
4966 | for (const key in propsOptions) {
|
4967 | checkDuplicateProperties("Props" /* PROPS */, key);
|
4968 | }
|
4969 | }
|
4970 | }
|
4971 | if (injectOptions) {
|
4972 | resolveInjections(injectOptions, ctx, checkDuplicateProperties);
|
4973 | }
|
4974 | if (methods) {
|
4975 | for (const key in methods) {
|
4976 | const methodHandler = methods[key];
|
4977 | if (isFunction(methodHandler)) {
|
4978 | {
|
4979 | Object.defineProperty(ctx, key, {
|
4980 | value: methodHandler.bind(publicThis),
|
4981 | configurable: true,
|
4982 | enumerable: true,
|
4983 | writable: true
|
4984 | });
|
4985 | }
|
4986 | {
|
4987 | checkDuplicateProperties("Methods" /* METHODS */, key);
|
4988 | }
|
4989 | } else {
|
4990 | warn$1(
|
4991 | `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
|
4992 | );
|
4993 | }
|
4994 | }
|
4995 | }
|
4996 | if (dataOptions) {
|
4997 | if (!isFunction(dataOptions)) {
|
4998 | warn$1(
|
4999 | `The data option must be a function. Plain object usage is no longer supported.`
|
5000 | );
|
5001 | }
|
5002 | const data = dataOptions.call(publicThis, publicThis);
|
5003 | if (isPromise(data)) {
|
5004 | warn$1(
|
5005 | `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
|
5006 | );
|
5007 | }
|
5008 | if (!isObject(data)) {
|
5009 | warn$1(`data() should return an object.`);
|
5010 | } else {
|
5011 | instance.data = reactive(data);
|
5012 | {
|
5013 | for (const key in data) {
|
5014 | checkDuplicateProperties("Data" , key);
|
5015 | if (!isReservedPrefix(key[0])) {
|
5016 | Object.defineProperty(ctx, key, {
|
5017 | configurable: true,
|
5018 | enumerable: true,
|
5019 | get: () => data[key],
|
5020 | set: NOOP
|
5021 | });
|
5022 | }
|
5023 | }
|
5024 | }
|
5025 | }
|
5026 | }
|
5027 | shouldCacheAccess = true;
|
5028 | if (computedOptions) {
|
5029 | for (const key in computedOptions) {
|
5030 | const opt = computedOptions[key];
|
5031 | const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
|
5032 | if (get === NOOP) {
|
5033 | warn$1(`Computed property "${key}" has no getter.`);
|
5034 | }
|
5035 | const set = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : () => {
|
5036 | warn$1(
|
5037 | `Write operation failed: computed property "${key}" is readonly.`
|
5038 | );
|
5039 | } ;
|
5040 | const c = computed({
|
5041 | get,
|
5042 | set
|
5043 | });
|
5044 | Object.defineProperty(ctx, key, {
|
5045 | enumerable: true,
|
5046 | configurable: true,
|
5047 | get: () => c.value,
|
5048 | set: (v) => c.value = v
|
5049 | });
|
5050 | {
|
5051 | checkDuplicateProperties("Computed" , key);
|
5052 | }
|
5053 | }
|
5054 | }
|
5055 | if (watchOptions) {
|
5056 | for (const key in watchOptions) {
|
5057 | createWatcher(watchOptions[key], ctx, publicThis, key);
|
5058 | }
|
5059 | }
|
5060 | if (provideOptions) {
|
5061 | const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
|
5062 | Reflect.ownKeys(provides).forEach((key) => {
|
5063 | provide(key, provides[key]);
|
5064 | });
|
5065 | }
|
5066 | if (created) {
|
5067 | callHook$1(created, instance, "c");
|
5068 | }
|
5069 | function registerLifecycleHook(register, hook) {
|
5070 | if (isArray(hook)) {
|
5071 | hook.forEach((_hook) => register(_hook.bind(publicThis)));
|
5072 | } else if (hook) {
|
5073 | register(hook.bind(publicThis));
|
5074 | }
|
5075 | }
|
5076 | registerLifecycleHook(onBeforeMount, beforeMount);
|
5077 | registerLifecycleHook(onMounted, mounted);
|
5078 | registerLifecycleHook(onBeforeUpdate, beforeUpdate);
|
5079 | registerLifecycleHook(onUpdated, updated);
|
5080 | registerLifecycleHook(onActivated, activated);
|
5081 | registerLifecycleHook(onDeactivated, deactivated);
|
5082 | registerLifecycleHook(onErrorCaptured, errorCaptured);
|
5083 | registerLifecycleHook(onRenderTracked, renderTracked);
|
5084 | registerLifecycleHook(onRenderTriggered, renderTriggered);
|
5085 | registerLifecycleHook(onBeforeUnmount, beforeUnmount);
|
5086 | registerLifecycleHook(onUnmounted, unmounted);
|
5087 | registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
5088 | if (isArray(expose)) {
|
5089 | if (expose.length) {
|
5090 | const exposed = instance.exposed || (instance.exposed = {});
|
5091 | expose.forEach((key) => {
|
5092 | Object.defineProperty(exposed, key, {
|
5093 | get: () => publicThis[key],
|
5094 | set: (val) => publicThis[key] = val
|
5095 | });
|
5096 | });
|
5097 | } else if (!instance.exposed) {
|
5098 | instance.exposed = {};
|
5099 | }
|
5100 | }
|
5101 | if (render && instance.render === NOOP) {
|
5102 | instance.render = render;
|
5103 | }
|
5104 | if (inheritAttrs != null) {
|
5105 | instance.inheritAttrs = inheritAttrs;
|
5106 | }
|
5107 | if (components)
|
5108 | instance.components = components;
|
5109 | if (directives)
|
5110 | instance.directives = directives;
|
5111 | }
|
5112 | function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
|
5113 | if (isArray(injectOptions)) {
|
5114 | injectOptions = normalizeInject(injectOptions);
|
5115 | }
|
5116 | for (const key in injectOptions) {
|
5117 | const opt = injectOptions[key];
|
5118 | let injected;
|
5119 | if (isObject(opt)) {
|
5120 | if ("default" in opt) {
|
5121 | injected = inject(
|
5122 | opt.from || key,
|
5123 | opt.default,
|
5124 | true
|
5125 | );
|
5126 | } else {
|
5127 | injected = inject(opt.from || key);
|
5128 | }
|
5129 | } else {
|
5130 | injected = inject(opt);
|
5131 | }
|
5132 | if (isRef(injected)) {
|
5133 | Object.defineProperty(ctx, key, {
|
5134 | enumerable: true,
|
5135 | configurable: true,
|
5136 | get: () => injected.value,
|
5137 | set: (v) => injected.value = v
|
5138 | });
|
5139 | } else {
|
5140 | ctx[key] = injected;
|
5141 | }
|
5142 | {
|
5143 | checkDuplicateProperties("Inject" , key);
|
5144 | }
|
5145 | }
|
5146 | }
|
5147 | function callHook$1(hook, instance, type) {
|
5148 | callWithAsyncErrorHandling(
|
5149 | isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
|
5150 | instance,
|
5151 | type
|
5152 | );
|
5153 | }
|
5154 | function createWatcher(raw, ctx, publicThis, key) {
|
5155 | const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
|
5156 | if (isString(raw)) {
|
5157 | const handler = ctx[raw];
|
5158 | if (isFunction(handler)) {
|
5159 | watch(getter, handler);
|
5160 | } else {
|
5161 | warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
|
5162 | }
|
5163 | } else if (isFunction(raw)) {
|
5164 | watch(getter, raw.bind(publicThis));
|
5165 | } else if (isObject(raw)) {
|
5166 | if (isArray(raw)) {
|
5167 | raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
|
5168 | } else {
|
5169 | const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
|
5170 | if (isFunction(handler)) {
|
5171 | watch(getter, handler, raw);
|
5172 | } else {
|
5173 | warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
|
5174 | }
|
5175 | }
|
5176 | } else {
|
5177 | warn$1(`Invalid watch option: "${key}"`, raw);
|
5178 | }
|
5179 | }
|
5180 | function resolveMergedOptions(instance) {
|
5181 | const base = instance.type;
|
5182 | const { mixins, extends: extendsOptions } = base;
|
5183 | const {
|
5184 | mixins: globalMixins,
|
5185 | optionsCache: cache,
|
5186 | config: { optionMergeStrategies }
|
5187 | } = instance.appContext;
|
5188 | const cached = cache.get(base);
|
5189 | let resolved;
|
5190 | if (cached) {
|
5191 | resolved = cached;
|
5192 | } else if (!globalMixins.length && !mixins && !extendsOptions) {
|
5193 | {
|
5194 | resolved = base;
|
5195 | }
|
5196 | } else {
|
5197 | resolved = {};
|
5198 | if (globalMixins.length) {
|
5199 | globalMixins.forEach(
|
5200 | (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
|
5201 | );
|
5202 | }
|
5203 | mergeOptions(resolved, base, optionMergeStrategies);
|
5204 | }
|
5205 | if (isObject(base)) {
|
5206 | cache.set(base, resolved);
|
5207 | }
|
5208 | return resolved;
|
5209 | }
|
5210 | function mergeOptions(to, from, strats, asMixin = false) {
|
5211 | const { mixins, extends: extendsOptions } = from;
|
5212 | if (extendsOptions) {
|
5213 | mergeOptions(to, extendsOptions, strats, true);
|
5214 | }
|
5215 | if (mixins) {
|
5216 | mixins.forEach(
|
5217 | (m) => mergeOptions(to, m, strats, true)
|
5218 | );
|
5219 | }
|
5220 | for (const key in from) {
|
5221 | if (asMixin && key === "expose") {
|
5222 | warn$1(
|
5223 | `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
|
5224 | );
|
5225 | } else {
|
5226 | const strat = internalOptionMergeStrats[key] || strats && strats[key];
|
5227 | to[key] = strat ? strat(to[key], from[key]) : from[key];
|
5228 | }
|
5229 | }
|
5230 | return to;
|
5231 | }
|
5232 | const internalOptionMergeStrats = {
|
5233 | data: mergeDataFn,
|
5234 | props: mergeEmitsOrPropsOptions,
|
5235 | emits: mergeEmitsOrPropsOptions,
|
5236 |
|
5237 | methods: mergeObjectOptions,
|
5238 | computed: mergeObjectOptions,
|
5239 |
|
5240 | beforeCreate: mergeAsArray$1,
|
5241 | created: mergeAsArray$1,
|
5242 | beforeMount: mergeAsArray$1,
|
5243 | mounted: mergeAsArray$1,
|
5244 | beforeUpdate: mergeAsArray$1,
|
5245 | updated: mergeAsArray$1,
|
5246 | beforeDestroy: mergeAsArray$1,
|
5247 | beforeUnmount: mergeAsArray$1,
|
5248 | destroyed: mergeAsArray$1,
|
5249 | unmounted: mergeAsArray$1,
|
5250 | activated: mergeAsArray$1,
|
5251 | deactivated: mergeAsArray$1,
|
5252 | errorCaptured: mergeAsArray$1,
|
5253 | serverPrefetch: mergeAsArray$1,
|
5254 |
|
5255 | components: mergeObjectOptions,
|
5256 | directives: mergeObjectOptions,
|
5257 |
|
5258 | watch: mergeWatchOptions,
|
5259 |
|
5260 | provide: mergeDataFn,
|
5261 | inject: mergeInject
|
5262 | };
|
5263 | function mergeDataFn(to, from) {
|
5264 | if (!from) {
|
5265 | return to;
|
5266 | }
|
5267 | if (!to) {
|
5268 | return from;
|
5269 | }
|
5270 | return function mergedDataFn() {
|
5271 | return (extend)(
|
5272 | isFunction(to) ? to.call(this, this) : to,
|
5273 | isFunction(from) ? from.call(this, this) : from
|
5274 | );
|
5275 | };
|
5276 | }
|
5277 | function mergeInject(to, from) {
|
5278 | return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
5279 | }
|
5280 | function normalizeInject(raw) {
|
5281 | if (isArray(raw)) {
|
5282 | const res = {};
|
5283 | for (let i = 0; i < raw.length; i++) {
|
5284 | res[raw[i]] = raw[i];
|
5285 | }
|
5286 | return res;
|
5287 | }
|
5288 | return raw;
|
5289 | }
|
5290 | function mergeAsArray$1(to, from) {
|
5291 | return to ? [...new Set([].concat(to, from))] : from;
|
5292 | }
|
5293 | function mergeObjectOptions(to, from) {
|
5294 | return to ? extend( Object.create(null), to, from) : from;
|
5295 | }
|
5296 | function mergeEmitsOrPropsOptions(to, from) {
|
5297 | if (to) {
|
5298 | if (isArray(to) && isArray(from)) {
|
5299 | return [... new Set([...to, ...from])];
|
5300 | }
|
5301 | return extend(
|
5302 | Object.create(null),
|
5303 | normalizePropsOrEmits(to),
|
5304 | normalizePropsOrEmits(from != null ? from : {})
|
5305 | );
|
5306 | } else {
|
5307 | return from;
|
5308 | }
|
5309 | }
|
5310 | function mergeWatchOptions(to, from) {
|
5311 | if (!to)
|
5312 | return from;
|
5313 | if (!from)
|
5314 | return to;
|
5315 | const merged = extend( Object.create(null), to);
|
5316 | for (const key in from) {
|
5317 | merged[key] = mergeAsArray$1(to[key], from[key]);
|
5318 | }
|
5319 | return merged;
|
5320 | }
|
5321 |
|
5322 | function createAppContext() {
|
5323 | return {
|
5324 | app: null,
|
5325 | config: {
|
5326 | isNativeTag: NO,
|
5327 | performance: false,
|
5328 | globalProperties: {},
|
5329 | optionMergeStrategies: {},
|
5330 | errorHandler: void 0,
|
5331 | warnHandler: void 0,
|
5332 | compilerOptions: {}
|
5333 | },
|
5334 | mixins: [],
|
5335 | components: {},
|
5336 | directives: {},
|
5337 | provides: Object.create(null),
|
5338 | optionsCache: new WeakMap(),
|
5339 | propsCache: new WeakMap(),
|
5340 | emitsCache: new WeakMap()
|
5341 | };
|
5342 | }
|
5343 | let uid$1 = 0;
|
5344 | function createAppAPI(render, hydrate) {
|
5345 | return function createApp(rootComponent, rootProps = null) {
|
5346 | if (!isFunction(rootComponent)) {
|
5347 | rootComponent = extend({}, rootComponent);
|
5348 | }
|
5349 | if (rootProps != null && !isObject(rootProps)) {
|
5350 | warn$1(`root props passed to app.mount() must be an object.`);
|
5351 | rootProps = null;
|
5352 | }
|
5353 | const context = createAppContext();
|
5354 | const installedPlugins = new WeakSet();
|
5355 | let isMounted = false;
|
5356 | const app = context.app = {
|
5357 | _uid: uid$1++,
|
5358 | _component: rootComponent,
|
5359 | _props: rootProps,
|
5360 | _container: null,
|
5361 | _context: context,
|
5362 | _instance: null,
|
5363 | version,
|
5364 | get config() {
|
5365 | return context.config;
|
5366 | },
|
5367 | set config(v) {
|
5368 | {
|
5369 | warn$1(
|
5370 | `app.config cannot be replaced. Modify individual options instead.`
|
5371 | );
|
5372 | }
|
5373 | },
|
5374 | use(plugin, ...options) {
|
5375 | if (installedPlugins.has(plugin)) {
|
5376 | warn$1(`Plugin has already been applied to target app.`);
|
5377 | } else if (plugin && isFunction(plugin.install)) {
|
5378 | installedPlugins.add(plugin);
|
5379 | plugin.install(app, ...options);
|
5380 | } else if (isFunction(plugin)) {
|
5381 | installedPlugins.add(plugin);
|
5382 | plugin(app, ...options);
|
5383 | } else {
|
5384 | warn$1(
|
5385 | `A plugin must either be a function or an object with an "install" function.`
|
5386 | );
|
5387 | }
|
5388 | return app;
|
5389 | },
|
5390 | mixin(mixin) {
|
5391 | {
|
5392 | if (!context.mixins.includes(mixin)) {
|
5393 | context.mixins.push(mixin);
|
5394 | } else {
|
5395 | warn$1(
|
5396 | "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
|
5397 | );
|
5398 | }
|
5399 | }
|
5400 | return app;
|
5401 | },
|
5402 | component(name, component) {
|
5403 | {
|
5404 | validateComponentName(name, context.config);
|
5405 | }
|
5406 | if (!component) {
|
5407 | return context.components[name];
|
5408 | }
|
5409 | if (context.components[name]) {
|
5410 | warn$1(`Component "${name}" has already been registered in target app.`);
|
5411 | }
|
5412 | context.components[name] = component;
|
5413 | return app;
|
5414 | },
|
5415 | directive(name, directive) {
|
5416 | {
|
5417 | validateDirectiveName(name);
|
5418 | }
|
5419 | if (!directive) {
|
5420 | return context.directives[name];
|
5421 | }
|
5422 | if (context.directives[name]) {
|
5423 | warn$1(`Directive "${name}" has already been registered in target app.`);
|
5424 | }
|
5425 | context.directives[name] = directive;
|
5426 | return app;
|
5427 | },
|
5428 | mount(rootContainer, isHydrate, namespace) {
|
5429 | if (!isMounted) {
|
5430 | if (rootContainer.__vue_app__) {
|
5431 | warn$1(
|
5432 | `There is already an app instance mounted on the host container.
|
5433 | If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
|
5434 | );
|
5435 | }
|
5436 | const vnode = createVNode(rootComponent, rootProps);
|
5437 | vnode.appContext = context;
|
5438 | if (namespace === true) {
|
5439 | namespace = "svg";
|
5440 | } else if (namespace === false) {
|
5441 | namespace = void 0;
|
5442 | }
|
5443 | {
|
5444 | context.reload = () => {
|
5445 | render(
|
5446 | cloneVNode(vnode),
|
5447 | rootContainer,
|
5448 | namespace
|
5449 | );
|
5450 | };
|
5451 | }
|
5452 | if (isHydrate && hydrate) {
|
5453 | hydrate(vnode, rootContainer);
|
5454 | } else {
|
5455 | render(vnode, rootContainer, namespace);
|
5456 | }
|
5457 | isMounted = true;
|
5458 | app._container = rootContainer;
|
5459 | rootContainer.__vue_app__ = app;
|
5460 | {
|
5461 | app._instance = vnode.component;
|
5462 | devtoolsInitApp(app, version);
|
5463 | }
|
5464 | return getExposeProxy(vnode.component) || vnode.component.proxy;
|
5465 | } else {
|
5466 | warn$1(
|
5467 | `App has already been mounted.
|
5468 | If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``
|
5469 | );
|
5470 | }
|
5471 | },
|
5472 | unmount() {
|
5473 | if (isMounted) {
|
5474 | render(null, app._container);
|
5475 | {
|
5476 | app._instance = null;
|
5477 | devtoolsUnmountApp(app);
|
5478 | }
|
5479 | delete app._container.__vue_app__;
|
5480 | } else {
|
5481 | warn$1(`Cannot unmount an app that is not mounted.`);
|
5482 | }
|
5483 | },
|
5484 | provide(key, value) {
|
5485 | if (key in context.provides) {
|
5486 | warn$1(
|
5487 | `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
|
5488 | );
|
5489 | }
|
5490 | context.provides[key] = value;
|
5491 | return app;
|
5492 | },
|
5493 | runWithContext(fn) {
|
5494 | const lastApp = currentApp;
|
5495 | currentApp = app;
|
5496 | try {
|
5497 | return fn();
|
5498 | } finally {
|
5499 | currentApp = lastApp;
|
5500 | }
|
5501 | }
|
5502 | };
|
5503 | return app;
|
5504 | };
|
5505 | }
|
5506 | let currentApp = null;
|
5507 |
|
5508 | function provide(key, value) {
|
5509 | if (!currentInstance) {
|
5510 | {
|
5511 | warn$1(`provide() can only be used inside setup().`);
|
5512 | }
|
5513 | } else {
|
5514 | let provides = currentInstance.provides;
|
5515 | const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
5516 | if (parentProvides === provides) {
|
5517 | provides = currentInstance.provides = Object.create(parentProvides);
|
5518 | }
|
5519 | provides[key] = value;
|
5520 | }
|
5521 | }
|
5522 | function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
5523 | const instance = currentInstance || currentRenderingInstance;
|
5524 | if (instance || currentApp) {
|
5525 | const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
|
5526 | if (provides && key in provides) {
|
5527 | return provides[key];
|
5528 | } else if (arguments.length > 1) {
|
5529 | return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
|
5530 | } else {
|
5531 | warn$1(`injection "${String(key)}" not found.`);
|
5532 | }
|
5533 | } else {
|
5534 | warn$1(`inject() can only be used inside setup() or functional components.`);
|
5535 | }
|
5536 | }
|
5537 | function hasInjectionContext() {
|
5538 | return !!(currentInstance || currentRenderingInstance || currentApp);
|
5539 | }
|
5540 |
|
5541 | function initProps(instance, rawProps, isStateful, isSSR = false) {
|
5542 | const props = {};
|
5543 | const attrs = {};
|
5544 | def(attrs, InternalObjectKey, 1);
|
5545 | instance.propsDefaults = Object.create(null);
|
5546 | setFullProps(instance, rawProps, props, attrs);
|
5547 | for (const key in instance.propsOptions[0]) {
|
5548 | if (!(key in props)) {
|
5549 | props[key] = void 0;
|
5550 | }
|
5551 | }
|
5552 | {
|
5553 | validateProps(rawProps || {}, props, instance);
|
5554 | }
|
5555 | if (isStateful) {
|
5556 | instance.props = isSSR ? props : shallowReactive(props);
|
5557 | } else {
|
5558 | if (!instance.type.props) {
|
5559 | instance.props = attrs;
|
5560 | } else {
|
5561 | instance.props = props;
|
5562 | }
|
5563 | }
|
5564 | instance.attrs = attrs;
|
5565 | }
|
5566 | function isInHmrContext(instance) {
|
5567 | while (instance) {
|
5568 | if (instance.type.__hmrId)
|
5569 | return true;
|
5570 | instance = instance.parent;
|
5571 | }
|
5572 | }
|
5573 | function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
5574 | const {
|
5575 | props,
|
5576 | attrs,
|
5577 | vnode: { patchFlag }
|
5578 | } = instance;
|
5579 | const rawCurrentProps = toRaw(props);
|
5580 | const [options] = instance.propsOptions;
|
5581 | let hasAttrsChanged = false;
|
5582 | if (
|
5583 |
|
5584 |
|
5585 |
|
5586 | !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
|
5587 | ) {
|
5588 | if (patchFlag & 8) {
|
5589 | const propsToUpdate = instance.vnode.dynamicProps;
|
5590 | for (let i = 0; i < propsToUpdate.length; i++) {
|
5591 | let key = propsToUpdate[i];
|
5592 | if (isEmitListener(instance.emitsOptions, key)) {
|
5593 | continue;
|
5594 | }
|
5595 | const value = rawProps[key];
|
5596 | if (options) {
|
5597 | if (hasOwn(attrs, key)) {
|
5598 | if (value !== attrs[key]) {
|
5599 | attrs[key] = value;
|
5600 | hasAttrsChanged = true;
|
5601 | }
|
5602 | } else {
|
5603 | const camelizedKey = camelize(key);
|
5604 | props[camelizedKey] = resolvePropValue(
|
5605 | options,
|
5606 | rawCurrentProps,
|
5607 | camelizedKey,
|
5608 | value,
|
5609 | instance,
|
5610 | false
|
5611 | );
|
5612 | }
|
5613 | } else {
|
5614 | if (value !== attrs[key]) {
|
5615 | attrs[key] = value;
|
5616 | hasAttrsChanged = true;
|
5617 | }
|
5618 | }
|
5619 | }
|
5620 | }
|
5621 | } else {
|
5622 | if (setFullProps(instance, rawProps, props, attrs)) {
|
5623 | hasAttrsChanged = true;
|
5624 | }
|
5625 | let kebabKey;
|
5626 | for (const key in rawCurrentProps) {
|
5627 | if (!rawProps ||
|
5628 | !hasOwn(rawProps, key) &&
|
5629 |
|
5630 | ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
|
5631 | if (options) {
|
5632 | if (rawPrevProps &&
|
5633 | (rawPrevProps[key] !== void 0 ||
|
5634 | rawPrevProps[kebabKey] !== void 0)) {
|
5635 | props[key] = resolvePropValue(
|
5636 | options,
|
5637 | rawCurrentProps,
|
5638 | key,
|
5639 | void 0,
|
5640 | instance,
|
5641 | true
|
5642 | );
|
5643 | }
|
5644 | } else {
|
5645 | delete props[key];
|
5646 | }
|
5647 | }
|
5648 | }
|
5649 | if (attrs !== rawCurrentProps) {
|
5650 | for (const key in attrs) {
|
5651 | if (!rawProps || !hasOwn(rawProps, key) && true) {
|
5652 | delete attrs[key];
|
5653 | hasAttrsChanged = true;
|
5654 | }
|
5655 | }
|
5656 | }
|
5657 | }
|
5658 | if (hasAttrsChanged) {
|
5659 | trigger(instance, "set", "$attrs");
|
5660 | }
|
5661 | {
|
5662 | validateProps(rawProps || {}, props, instance);
|
5663 | }
|
5664 | }
|
5665 | function setFullProps(instance, rawProps, props, attrs) {
|
5666 | const [options, needCastKeys] = instance.propsOptions;
|
5667 | let hasAttrsChanged = false;
|
5668 | let rawCastValues;
|
5669 | if (rawProps) {
|
5670 | for (let key in rawProps) {
|
5671 | if (isReservedProp(key)) {
|
5672 | continue;
|
5673 | }
|
5674 | const value = rawProps[key];
|
5675 | let camelKey;
|
5676 | if (options && hasOwn(options, camelKey = camelize(key))) {
|
5677 | if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
5678 | props[camelKey] = value;
|
5679 | } else {
|
5680 | (rawCastValues || (rawCastValues = {}))[camelKey] = value;
|
5681 | }
|
5682 | } else if (!isEmitListener(instance.emitsOptions, key)) {
|
5683 | if (!(key in attrs) || value !== attrs[key]) {
|
5684 | attrs[key] = value;
|
5685 | hasAttrsChanged = true;
|
5686 | }
|
5687 | }
|
5688 | }
|
5689 | }
|
5690 | if (needCastKeys) {
|
5691 | const rawCurrentProps = toRaw(props);
|
5692 | const castValues = rawCastValues || EMPTY_OBJ;
|
5693 | for (let i = 0; i < needCastKeys.length; i++) {
|
5694 | const key = needCastKeys[i];
|
5695 | props[key] = resolvePropValue(
|
5696 | options,
|
5697 | rawCurrentProps,
|
5698 | key,
|
5699 | castValues[key],
|
5700 | instance,
|
5701 | !hasOwn(castValues, key)
|
5702 | );
|
5703 | }
|
5704 | }
|
5705 | return hasAttrsChanged;
|
5706 | }
|
5707 | function resolvePropValue(options, props, key, value, instance, isAbsent) {
|
5708 | const opt = options[key];
|
5709 | if (opt != null) {
|
5710 | const hasDefault = hasOwn(opt, "default");
|
5711 | if (hasDefault && value === void 0) {
|
5712 | const defaultValue = opt.default;
|
5713 | if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
|
5714 | const { propsDefaults } = instance;
|
5715 | if (key in propsDefaults) {
|
5716 | value = propsDefaults[key];
|
5717 | } else {
|
5718 | const reset = setCurrentInstance(instance);
|
5719 | value = propsDefaults[key] = defaultValue.call(
|
5720 | null,
|
5721 | props
|
5722 | );
|
5723 | reset();
|
5724 | }
|
5725 | } else {
|
5726 | value = defaultValue;
|
5727 | }
|
5728 | }
|
5729 | if (opt[0 ]) {
|
5730 | if (isAbsent && !hasDefault) {
|
5731 | value = false;
|
5732 | } else if (opt[1 ] && (value === "" || value === hyphenate(key))) {
|
5733 | value = true;
|
5734 | }
|
5735 | }
|
5736 | }
|
5737 | return value;
|
5738 | }
|
5739 | function normalizePropsOptions(comp, appContext, asMixin = false) {
|
5740 | const cache = appContext.propsCache;
|
5741 | const cached = cache.get(comp);
|
5742 | if (cached) {
|
5743 | return cached;
|
5744 | }
|
5745 | const raw = comp.props;
|
5746 | const normalized = {};
|
5747 | const needCastKeys = [];
|
5748 | let hasExtends = false;
|
5749 | if (!isFunction(comp)) {
|
5750 | const extendProps = (raw2) => {
|
5751 | hasExtends = true;
|
5752 | const [props, keys] = normalizePropsOptions(raw2, appContext, true);
|
5753 | extend(normalized, props);
|
5754 | if (keys)
|
5755 | needCastKeys.push(...keys);
|
5756 | };
|
5757 | if (!asMixin && appContext.mixins.length) {
|
5758 | appContext.mixins.forEach(extendProps);
|
5759 | }
|
5760 | if (comp.extends) {
|
5761 | extendProps(comp.extends);
|
5762 | }
|
5763 | if (comp.mixins) {
|
5764 | comp.mixins.forEach(extendProps);
|
5765 | }
|
5766 | }
|
5767 | if (!raw && !hasExtends) {
|
5768 | if (isObject(comp)) {
|
5769 | cache.set(comp, EMPTY_ARR);
|
5770 | }
|
5771 | return EMPTY_ARR;
|
5772 | }
|
5773 | if (isArray(raw)) {
|
5774 | for (let i = 0; i < raw.length; i++) {
|
5775 | if (!isString(raw[i])) {
|
5776 | warn$1(`props must be strings when using array syntax.`, raw[i]);
|
5777 | }
|
5778 | const normalizedKey = camelize(raw[i]);
|
5779 | if (validatePropName(normalizedKey)) {
|
5780 | normalized[normalizedKey] = EMPTY_OBJ;
|
5781 | }
|
5782 | }
|
5783 | } else if (raw) {
|
5784 | if (!isObject(raw)) {
|
5785 | warn$1(`invalid props options`, raw);
|
5786 | }
|
5787 | for (const key in raw) {
|
5788 | const normalizedKey = camelize(key);
|
5789 | if (validatePropName(normalizedKey)) {
|
5790 | const opt = raw[key];
|
5791 | const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
|
5792 | if (prop) {
|
5793 | const booleanIndex = getTypeIndex(Boolean, prop.type);
|
5794 | const stringIndex = getTypeIndex(String, prop.type);
|
5795 | prop[0 ] = booleanIndex > -1;
|
5796 | prop[1 ] = stringIndex < 0 || booleanIndex < stringIndex;
|
5797 | if (booleanIndex > -1 || hasOwn(prop, "default")) {
|
5798 | needCastKeys.push(normalizedKey);
|
5799 | }
|
5800 | }
|
5801 | }
|
5802 | }
|
5803 | }
|
5804 | const res = [normalized, needCastKeys];
|
5805 | if (isObject(comp)) {
|
5806 | cache.set(comp, res);
|
5807 | }
|
5808 | return res;
|
5809 | }
|
5810 | function validatePropName(key) {
|
5811 | if (key[0] !== "$" && !isReservedProp(key)) {
|
5812 | return true;
|
5813 | } else {
|
5814 | warn$1(`Invalid prop name: "${key}" is a reserved property.`);
|
5815 | }
|
5816 | return false;
|
5817 | }
|
5818 | function getType(ctor) {
|
5819 | if (ctor === null) {
|
5820 | return "null";
|
5821 | }
|
5822 | if (typeof ctor === "function") {
|
5823 | return ctor.name || "";
|
5824 | } else if (typeof ctor === "object") {
|
5825 | const name = ctor.constructor && ctor.constructor.name;
|
5826 | return name || "";
|
5827 | }
|
5828 | return "";
|
5829 | }
|
5830 | function isSameType(a, b) {
|
5831 | return getType(a) === getType(b);
|
5832 | }
|
5833 | function getTypeIndex(type, expectedTypes) {
|
5834 | if (isArray(expectedTypes)) {
|
5835 | return expectedTypes.findIndex((t) => isSameType(t, type));
|
5836 | } else if (isFunction(expectedTypes)) {
|
5837 | return isSameType(expectedTypes, type) ? 0 : -1;
|
5838 | }
|
5839 | return -1;
|
5840 | }
|
5841 | function validateProps(rawProps, props, instance) {
|
5842 | const resolvedValues = toRaw(props);
|
5843 | const options = instance.propsOptions[0];
|
5844 | for (const key in options) {
|
5845 | let opt = options[key];
|
5846 | if (opt == null)
|
5847 | continue;
|
5848 | validateProp(
|
5849 | key,
|
5850 | resolvedValues[key],
|
5851 | opt,
|
5852 | shallowReadonly(resolvedValues) ,
|
5853 | !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
|
5854 | );
|
5855 | }
|
5856 | }
|
5857 | function validateProp(name, value, prop, props, isAbsent) {
|
5858 | const { type, required, validator, skipCheck } = prop;
|
5859 | if (required && isAbsent) {
|
5860 | warn$1('Missing required prop: "' + name + '"');
|
5861 | return;
|
5862 | }
|
5863 | if (value == null && !required) {
|
5864 | return;
|
5865 | }
|
5866 | if (type != null && type !== true && !skipCheck) {
|
5867 | let isValid = false;
|
5868 | const types = isArray(type) ? type : [type];
|
5869 | const expectedTypes = [];
|
5870 | for (let i = 0; i < types.length && !isValid; i++) {
|
5871 | const { valid, expectedType } = assertType(value, types[i]);
|
5872 | expectedTypes.push(expectedType || "");
|
5873 | isValid = valid;
|
5874 | }
|
5875 | if (!isValid) {
|
5876 | warn$1(getInvalidTypeMessage(name, value, expectedTypes));
|
5877 | return;
|
5878 | }
|
5879 | }
|
5880 | if (validator && !validator(value, props)) {
|
5881 | warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
|
5882 | }
|
5883 | }
|
5884 | const isSimpleType = makeMap(
|
5885 | "String,Number,Boolean,Function,Symbol,BigInt"
|
5886 | );
|
5887 | function assertType(value, type) {
|
5888 | let valid;
|
5889 | const expectedType = getType(type);
|
5890 | if (isSimpleType(expectedType)) {
|
5891 | const t = typeof value;
|
5892 | valid = t === expectedType.toLowerCase();
|
5893 | if (!valid && t === "object") {
|
5894 | valid = value instanceof type;
|
5895 | }
|
5896 | } else if (expectedType === "Object") {
|
5897 | valid = isObject(value);
|
5898 | } else if (expectedType === "Array") {
|
5899 | valid = isArray(value);
|
5900 | } else if (expectedType === "null") {
|
5901 | valid = value === null;
|
5902 | } else {
|
5903 | valid = value instanceof type;
|
5904 | }
|
5905 | return {
|
5906 | valid,
|
5907 | expectedType
|
5908 | };
|
5909 | }
|
5910 | function getInvalidTypeMessage(name, value, expectedTypes) {
|
5911 | if (expectedTypes.length === 0) {
|
5912 | return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
|
5913 | }
|
5914 | let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
|
5915 | const expectedType = expectedTypes[0];
|
5916 | const receivedType = toRawType(value);
|
5917 | const expectedValue = styleValue(value, expectedType);
|
5918 | const receivedValue = styleValue(value, receivedType);
|
5919 | if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
|
5920 | message += ` with value ${expectedValue}`;
|
5921 | }
|
5922 | message += `, got ${receivedType} `;
|
5923 | if (isExplicable(receivedType)) {
|
5924 | message += `with value ${receivedValue}.`;
|
5925 | }
|
5926 | return message;
|
5927 | }
|
5928 | function styleValue(value, type) {
|
5929 | if (type === "String") {
|
5930 | return `"${value}"`;
|
5931 | } else if (type === "Number") {
|
5932 | return `${Number(value)}`;
|
5933 | } else {
|
5934 | return `${value}`;
|
5935 | }
|
5936 | }
|
5937 | function isExplicable(type) {
|
5938 | const explicitTypes = ["string", "number", "boolean"];
|
5939 | return explicitTypes.some((elem) => type.toLowerCase() === elem);
|
5940 | }
|
5941 | function isBoolean(...args) {
|
5942 | return args.some((elem) => elem.toLowerCase() === "boolean");
|
5943 | }
|
5944 |
|
5945 | const isInternalKey = (key) => key[0] === "_" || key === "$stable";
|
5946 | const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
|
5947 | const normalizeSlot = (key, rawSlot, ctx) => {
|
5948 | if (rawSlot._n) {
|
5949 | return rawSlot;
|
5950 | }
|
5951 | const normalized = withCtx((...args) => {
|
5952 | if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
|
5953 | warn$1(
|
5954 | `Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`
|
5955 | );
|
5956 | }
|
5957 | return normalizeSlotValue(rawSlot(...args));
|
5958 | }, ctx);
|
5959 | normalized._c = false;
|
5960 | return normalized;
|
5961 | };
|
5962 | const normalizeObjectSlots = (rawSlots, slots, instance) => {
|
5963 | const ctx = rawSlots._ctx;
|
5964 | for (const key in rawSlots) {
|
5965 | if (isInternalKey(key))
|
5966 | continue;
|
5967 | const value = rawSlots[key];
|
5968 | if (isFunction(value)) {
|
5969 | slots[key] = normalizeSlot(key, value, ctx);
|
5970 | } else if (value != null) {
|
5971 | {
|
5972 | warn$1(
|
5973 | `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
|
5974 | );
|
5975 | }
|
5976 | const normalized = normalizeSlotValue(value);
|
5977 | slots[key] = () => normalized;
|
5978 | }
|
5979 | }
|
5980 | };
|
5981 | const normalizeVNodeSlots = (instance, children) => {
|
5982 | if (!isKeepAlive(instance.vnode) && true) {
|
5983 | warn$1(
|
5984 | `Non-function value encountered for default slot. Prefer function slots for better performance.`
|
5985 | );
|
5986 | }
|
5987 | const normalized = normalizeSlotValue(children);
|
5988 | instance.slots.default = () => normalized;
|
5989 | };
|
5990 | const initSlots = (instance, children) => {
|
5991 | if (instance.vnode.shapeFlag & 32) {
|
5992 | const type = children._;
|
5993 | if (type) {
|
5994 | instance.slots = toRaw(children);
|
5995 | def(children, "_", type);
|
5996 | } else {
|
5997 | normalizeObjectSlots(
|
5998 | children,
|
5999 | instance.slots = {});
|
6000 | }
|
6001 | } else {
|
6002 | instance.slots = {};
|
6003 | if (children) {
|
6004 | normalizeVNodeSlots(instance, children);
|
6005 | }
|
6006 | }
|
6007 | def(instance.slots, InternalObjectKey, 1);
|
6008 | };
|
6009 | const updateSlots = (instance, children, optimized) => {
|
6010 | const { vnode, slots } = instance;
|
6011 | let needDeletionCheck = true;
|
6012 | let deletionComparisonTarget = EMPTY_OBJ;
|
6013 | if (vnode.shapeFlag & 32) {
|
6014 | const type = children._;
|
6015 | if (type) {
|
6016 | if (isHmrUpdating) {
|
6017 | extend(slots, children);
|
6018 | trigger(instance, "set", "$slots");
|
6019 | } else if (optimized && type === 1) {
|
6020 | needDeletionCheck = false;
|
6021 | } else {
|
6022 | extend(slots, children);
|
6023 | if (!optimized && type === 1) {
|
6024 | delete slots._;
|
6025 | }
|
6026 | }
|
6027 | } else {
|
6028 | needDeletionCheck = !children.$stable;
|
6029 | normalizeObjectSlots(children, slots);
|
6030 | }
|
6031 | deletionComparisonTarget = children;
|
6032 | } else if (children) {
|
6033 | normalizeVNodeSlots(instance, children);
|
6034 | deletionComparisonTarget = { default: 1 };
|
6035 | }
|
6036 | if (needDeletionCheck) {
|
6037 | for (const key in slots) {
|
6038 | if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
|
6039 | delete slots[key];
|
6040 | }
|
6041 | }
|
6042 | }
|
6043 | };
|
6044 |
|
6045 | function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
|
6046 | if (isArray(rawRef)) {
|
6047 | rawRef.forEach(
|
6048 | (r, i) => setRef(
|
6049 | r,
|
6050 | oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
|
6051 | parentSuspense,
|
6052 | vnode,
|
6053 | isUnmount
|
6054 | )
|
6055 | );
|
6056 | return;
|
6057 | }
|
6058 | if (isAsyncWrapper(vnode) && !isUnmount) {
|
6059 | return;
|
6060 | }
|
6061 | const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el;
|
6062 | const value = isUnmount ? null : refValue;
|
6063 | const { i: owner, r: ref } = rawRef;
|
6064 | if (!owner) {
|
6065 | warn$1(
|
6066 | `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
|
6067 | );
|
6068 | return;
|
6069 | }
|
6070 | const oldRef = oldRawRef && oldRawRef.r;
|
6071 | const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
|
6072 | const setupState = owner.setupState;
|
6073 | if (oldRef != null && oldRef !== ref) {
|
6074 | if (isString(oldRef)) {
|
6075 | refs[oldRef] = null;
|
6076 | if (hasOwn(setupState, oldRef)) {
|
6077 | setupState[oldRef] = null;
|
6078 | }
|
6079 | } else if (isRef(oldRef)) {
|
6080 | oldRef.value = null;
|
6081 | }
|
6082 | }
|
6083 | if (isFunction(ref)) {
|
6084 | callWithErrorHandling(ref, owner, 12, [value, refs]);
|
6085 | } else {
|
6086 | const _isString = isString(ref);
|
6087 | const _isRef = isRef(ref);
|
6088 | if (_isString || _isRef) {
|
6089 | const doSet = () => {
|
6090 | if (rawRef.f) {
|
6091 | const existing = _isString ? hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
|
6092 | if (isUnmount) {
|
6093 | isArray(existing) && remove(existing, refValue);
|
6094 | } else {
|
6095 | if (!isArray(existing)) {
|
6096 | if (_isString) {
|
6097 | refs[ref] = [refValue];
|
6098 | if (hasOwn(setupState, ref)) {
|
6099 | setupState[ref] = refs[ref];
|
6100 | }
|
6101 | } else {
|
6102 | ref.value = [refValue];
|
6103 | if (rawRef.k)
|
6104 | refs[rawRef.k] = ref.value;
|
6105 | }
|
6106 | } else if (!existing.includes(refValue)) {
|
6107 | existing.push(refValue);
|
6108 | }
|
6109 | }
|
6110 | } else if (_isString) {
|
6111 | refs[ref] = value;
|
6112 | if (hasOwn(setupState, ref)) {
|
6113 | setupState[ref] = value;
|
6114 | }
|
6115 | } else if (_isRef) {
|
6116 | ref.value = value;
|
6117 | if (rawRef.k)
|
6118 | refs[rawRef.k] = value;
|
6119 | } else {
|
6120 | warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
|
6121 | }
|
6122 | };
|
6123 | if (value) {
|
6124 | doSet.id = -1;
|
6125 | queuePostRenderEffect(doSet, parentSuspense);
|
6126 | } else {
|
6127 | doSet();
|
6128 | }
|
6129 | } else {
|
6130 | warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
|
6131 | }
|
6132 | }
|
6133 | }
|
6134 |
|
6135 | let hasMismatch = false;
|
6136 | const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
|
6137 | const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
|
6138 | const getContainerType = (container) => {
|
6139 | if (isSVGContainer(container))
|
6140 | return "svg";
|
6141 | if (isMathMLContainer(container))
|
6142 | return "mathml";
|
6143 | return void 0;
|
6144 | };
|
6145 | const isComment = (node) => node.nodeType === 8 ;
|
6146 | function createHydrationFunctions(rendererInternals) {
|
6147 | const {
|
6148 | mt: mountComponent,
|
6149 | p: patch,
|
6150 | o: {
|
6151 | patchProp,
|
6152 | createText,
|
6153 | nextSibling,
|
6154 | parentNode,
|
6155 | remove,
|
6156 | insert,
|
6157 | createComment
|
6158 | }
|
6159 | } = rendererInternals;
|
6160 | const hydrate = (vnode, container) => {
|
6161 | if (!container.hasChildNodes()) {
|
6162 | warn$1(
|
6163 | `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`
|
6164 | );
|
6165 | patch(null, vnode, container);
|
6166 | flushPostFlushCbs();
|
6167 | container._vnode = vnode;
|
6168 | return;
|
6169 | }
|
6170 | hasMismatch = false;
|
6171 | hydrateNode(container.firstChild, vnode, null, null, null);
|
6172 | flushPostFlushCbs();
|
6173 | container._vnode = vnode;
|
6174 | if (hasMismatch && true) {
|
6175 | console.error(`Hydration completed but contains mismatches.`);
|
6176 | }
|
6177 | };
|
6178 | const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
|
6179 | const isFragmentStart = isComment(node) && node.data === "[";
|
6180 | const onMismatch = () => handleMismatch(
|
6181 | node,
|
6182 | vnode,
|
6183 | parentComponent,
|
6184 | parentSuspense,
|
6185 | slotScopeIds,
|
6186 | isFragmentStart
|
6187 | );
|
6188 | const { type, ref, shapeFlag, patchFlag } = vnode;
|
6189 | let domType = node.nodeType;
|
6190 | vnode.el = node;
|
6191 | {
|
6192 | if (!("__vnode" in node)) {
|
6193 | Object.defineProperty(node, "__vnode", {
|
6194 | value: vnode,
|
6195 | enumerable: false
|
6196 | });
|
6197 | }
|
6198 | if (!("__vueParentComponent" in node)) {
|
6199 | Object.defineProperty(node, "__vueParentComponent", {
|
6200 | value: parentComponent,
|
6201 | enumerable: false
|
6202 | });
|
6203 | }
|
6204 | }
|
6205 | if (patchFlag === -2) {
|
6206 | optimized = false;
|
6207 | vnode.dynamicChildren = null;
|
6208 | }
|
6209 | let nextNode = null;
|
6210 | switch (type) {
|
6211 | case Text:
|
6212 | if (domType !== 3 ) {
|
6213 | if (vnode.children === "") {
|
6214 | insert(vnode.el = createText(""), parentNode(node), node);
|
6215 | nextNode = node;
|
6216 | } else {
|
6217 | nextNode = onMismatch();
|
6218 | }
|
6219 | } else {
|
6220 | if (node.data !== vnode.children) {
|
6221 | hasMismatch = true;
|
6222 | warn$1(
|
6223 | `Hydration text mismatch in`,
|
6224 | node.parentNode,
|
6225 | `
|
6226 | - rendered on server: ${JSON.stringify(
|
6227 | node.data
|
6228 | )}
|
6229 | - expected on client: ${JSON.stringify(vnode.children)}`
|
6230 | );
|
6231 | node.data = vnode.children;
|
6232 | }
|
6233 | nextNode = nextSibling(node);
|
6234 | }
|
6235 | break;
|
6236 | case Comment:
|
6237 | if (isTemplateNode(node)) {
|
6238 | nextNode = nextSibling(node);
|
6239 | replaceNode(
|
6240 | vnode.el = node.content.firstChild,
|
6241 | node,
|
6242 | parentComponent
|
6243 | );
|
6244 | } else if (domType !== 8 || isFragmentStart) {
|
6245 | nextNode = onMismatch();
|
6246 | } else {
|
6247 | nextNode = nextSibling(node);
|
6248 | }
|
6249 | break;
|
6250 | case Static:
|
6251 | if (isFragmentStart) {
|
6252 | node = nextSibling(node);
|
6253 | domType = node.nodeType;
|
6254 | }
|
6255 | if (domType === 1 || domType === 3 ) {
|
6256 | nextNode = node;
|
6257 | const needToAdoptContent = !vnode.children.length;
|
6258 | for (let i = 0; i < vnode.staticCount; i++) {
|
6259 | if (needToAdoptContent)
|
6260 | vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
|
6261 | if (i === vnode.staticCount - 1) {
|
6262 | vnode.anchor = nextNode;
|
6263 | }
|
6264 | nextNode = nextSibling(nextNode);
|
6265 | }
|
6266 | return isFragmentStart ? nextSibling(nextNode) : nextNode;
|
6267 | } else {
|
6268 | onMismatch();
|
6269 | }
|
6270 | break;
|
6271 | case Fragment:
|
6272 | if (!isFragmentStart) {
|
6273 | nextNode = onMismatch();
|
6274 | } else {
|
6275 | nextNode = hydrateFragment(
|
6276 | node,
|
6277 | vnode,
|
6278 | parentComponent,
|
6279 | parentSuspense,
|
6280 | slotScopeIds,
|
6281 | optimized
|
6282 | );
|
6283 | }
|
6284 | break;
|
6285 | default:
|
6286 | if (shapeFlag & 1) {
|
6287 | if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
|
6288 | nextNode = onMismatch();
|
6289 | } else {
|
6290 | nextNode = hydrateElement(
|
6291 | node,
|
6292 | vnode,
|
6293 | parentComponent,
|
6294 | parentSuspense,
|
6295 | slotScopeIds,
|
6296 | optimized
|
6297 | );
|
6298 | }
|
6299 | } else if (shapeFlag & 6) {
|
6300 | vnode.slotScopeIds = slotScopeIds;
|
6301 | const container = parentNode(node);
|
6302 | if (isFragmentStart) {
|
6303 | nextNode = locateClosingAnchor(node);
|
6304 | } else if (isComment(node) && node.data === "teleport start") {
|
6305 | nextNode = locateClosingAnchor(node, node.data, "teleport end");
|
6306 | } else {
|
6307 | nextNode = nextSibling(node);
|
6308 | }
|
6309 | mountComponent(
|
6310 | vnode,
|
6311 | container,
|
6312 | null,
|
6313 | parentComponent,
|
6314 | parentSuspense,
|
6315 | getContainerType(container),
|
6316 | optimized
|
6317 | );
|
6318 | if (isAsyncWrapper(vnode)) {
|
6319 | let subTree;
|
6320 | if (isFragmentStart) {
|
6321 | subTree = createVNode(Fragment);
|
6322 | subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
|
6323 | } else {
|
6324 | subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
|
6325 | }
|
6326 | subTree.el = node;
|
6327 | vnode.component.subTree = subTree;
|
6328 | }
|
6329 | } else if (shapeFlag & 64) {
|
6330 | if (domType !== 8 ) {
|
6331 | nextNode = onMismatch();
|
6332 | } else {
|
6333 | nextNode = vnode.type.hydrate(
|
6334 | node,
|
6335 | vnode,
|
6336 | parentComponent,
|
6337 | parentSuspense,
|
6338 | slotScopeIds,
|
6339 | optimized,
|
6340 | rendererInternals,
|
6341 | hydrateChildren
|
6342 | );
|
6343 | }
|
6344 | } else if (shapeFlag & 128) {
|
6345 | nextNode = vnode.type.hydrate(
|
6346 | node,
|
6347 | vnode,
|
6348 | parentComponent,
|
6349 | parentSuspense,
|
6350 | getContainerType(parentNode(node)),
|
6351 | slotScopeIds,
|
6352 | optimized,
|
6353 | rendererInternals,
|
6354 | hydrateNode
|
6355 | );
|
6356 | } else {
|
6357 | warn$1("Invalid HostVNode type:", type, `(${typeof type})`);
|
6358 | }
|
6359 | }
|
6360 | if (ref != null) {
|
6361 | setRef(ref, null, parentSuspense, vnode);
|
6362 | }
|
6363 | return nextNode;
|
6364 | };
|
6365 | const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
6366 | optimized = optimized || !!vnode.dynamicChildren;
|
6367 | const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
|
6368 | const forcePatch = type === "input" || type === "option";
|
6369 | {
|
6370 | if (dirs) {
|
6371 | invokeDirectiveHook(vnode, null, parentComponent, "created");
|
6372 | }
|
6373 | let needCallTransitionHooks = false;
|
6374 | if (isTemplateNode(el)) {
|
6375 | needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
|
6376 | const content = el.content.firstChild;
|
6377 | if (needCallTransitionHooks) {
|
6378 | transition.beforeEnter(content);
|
6379 | }
|
6380 | replaceNode(content, el, parentComponent);
|
6381 | vnode.el = el = content;
|
6382 | }
|
6383 | if (shapeFlag & 16 &&
|
6384 | !(props && (props.innerHTML || props.textContent))) {
|
6385 | let next = hydrateChildren(
|
6386 | el.firstChild,
|
6387 | vnode,
|
6388 | el,
|
6389 | parentComponent,
|
6390 | parentSuspense,
|
6391 | slotScopeIds,
|
6392 | optimized
|
6393 | );
|
6394 | let hasWarned = false;
|
6395 | while (next) {
|
6396 | hasMismatch = true;
|
6397 | if (!hasWarned) {
|
6398 | warn$1(
|
6399 | `Hydration children mismatch on`,
|
6400 | el,
|
6401 | `
|
6402 | Server rendered element contains more child nodes than client vdom.`
|
6403 | );
|
6404 | hasWarned = true;
|
6405 | }
|
6406 | const cur = next;
|
6407 | next = next.nextSibling;
|
6408 | remove(cur);
|
6409 | }
|
6410 | } else if (shapeFlag & 8) {
|
6411 | if (el.textContent !== vnode.children) {
|
6412 | hasMismatch = true;
|
6413 | warn$1(
|
6414 | `Hydration text content mismatch on`,
|
6415 | el,
|
6416 | `
|
6417 | - rendered on server: ${el.textContent}
|
6418 | - expected on client: ${vnode.children}`
|
6419 | );
|
6420 | el.textContent = vnode.children;
|
6421 | }
|
6422 | }
|
6423 | if (props) {
|
6424 | {
|
6425 | for (const key in props) {
|
6426 | if (propHasMismatch(el, key, props[key], vnode, parentComponent)) {
|
6427 | hasMismatch = true;
|
6428 | }
|
6429 | if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) ||
|
6430 | key[0] === ".") {
|
6431 | patchProp(
|
6432 | el,
|
6433 | key,
|
6434 | null,
|
6435 | props[key],
|
6436 | void 0,
|
6437 | void 0,
|
6438 | parentComponent
|
6439 | );
|
6440 | }
|
6441 | }
|
6442 | }
|
6443 | }
|
6444 | let vnodeHooks;
|
6445 | if (vnodeHooks = props && props.onVnodeBeforeMount) {
|
6446 | invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
6447 | }
|
6448 | if (dirs) {
|
6449 | invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
6450 | }
|
6451 | if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
|
6452 | queueEffectWithSuspense(() => {
|
6453 | vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
6454 | needCallTransitionHooks && transition.enter(el);
|
6455 | dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
6456 | }, parentSuspense);
|
6457 | }
|
6458 | }
|
6459 | return el.nextSibling;
|
6460 | };
|
6461 | const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
6462 | optimized = optimized || !!parentVNode.dynamicChildren;
|
6463 | const children = parentVNode.children;
|
6464 | const l = children.length;
|
6465 | let hasWarned = false;
|
6466 | for (let i = 0; i < l; i++) {
|
6467 | const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
|
6468 | if (node) {
|
6469 | node = hydrateNode(
|
6470 | node,
|
6471 | vnode,
|
6472 | parentComponent,
|
6473 | parentSuspense,
|
6474 | slotScopeIds,
|
6475 | optimized
|
6476 | );
|
6477 | } else if (vnode.type === Text && !vnode.children) {
|
6478 | continue;
|
6479 | } else {
|
6480 | hasMismatch = true;
|
6481 | if (!hasWarned) {
|
6482 | warn$1(
|
6483 | `Hydration children mismatch on`,
|
6484 | container,
|
6485 | `
|
6486 | Server rendered element contains fewer child nodes than client vdom.`
|
6487 | );
|
6488 | hasWarned = true;
|
6489 | }
|
6490 | patch(
|
6491 | null,
|
6492 | vnode,
|
6493 | container,
|
6494 | null,
|
6495 | parentComponent,
|
6496 | parentSuspense,
|
6497 | getContainerType(container),
|
6498 | slotScopeIds
|
6499 | );
|
6500 | }
|
6501 | }
|
6502 | return node;
|
6503 | };
|
6504 | const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
6505 | const { slotScopeIds: fragmentSlotScopeIds } = vnode;
|
6506 | if (fragmentSlotScopeIds) {
|
6507 | slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
6508 | }
|
6509 | const container = parentNode(node);
|
6510 | const next = hydrateChildren(
|
6511 | nextSibling(node),
|
6512 | vnode,
|
6513 | container,
|
6514 | parentComponent,
|
6515 | parentSuspense,
|
6516 | slotScopeIds,
|
6517 | optimized
|
6518 | );
|
6519 | if (next && isComment(next) && next.data === "]") {
|
6520 | return nextSibling(vnode.anchor = next);
|
6521 | } else {
|
6522 | hasMismatch = true;
|
6523 | insert(vnode.anchor = createComment(`]`), container, next);
|
6524 | return next;
|
6525 | }
|
6526 | };
|
6527 | const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
|
6528 | hasMismatch = true;
|
6529 | warn$1(
|
6530 | `Hydration node mismatch:
|
6531 | - rendered on server:`,
|
6532 | node,
|
6533 | node.nodeType === 3 ? `(text)` : isComment(node) && node.data === "[" ? `(start of fragment)` : ``,
|
6534 | `
|
6535 | - expected on client:`,
|
6536 | vnode.type
|
6537 | );
|
6538 | vnode.el = null;
|
6539 | if (isFragment) {
|
6540 | const end = locateClosingAnchor(node);
|
6541 | while (true) {
|
6542 | const next2 = nextSibling(node);
|
6543 | if (next2 && next2 !== end) {
|
6544 | remove(next2);
|
6545 | } else {
|
6546 | break;
|
6547 | }
|
6548 | }
|
6549 | }
|
6550 | const next = nextSibling(node);
|
6551 | const container = parentNode(node);
|
6552 | remove(node);
|
6553 | patch(
|
6554 | null,
|
6555 | vnode,
|
6556 | container,
|
6557 | next,
|
6558 | parentComponent,
|
6559 | parentSuspense,
|
6560 | getContainerType(container),
|
6561 | slotScopeIds
|
6562 | );
|
6563 | return next;
|
6564 | };
|
6565 | const locateClosingAnchor = (node, open = "[", close = "]") => {
|
6566 | let match = 0;
|
6567 | while (node) {
|
6568 | node = nextSibling(node);
|
6569 | if (node && isComment(node)) {
|
6570 | if (node.data === open)
|
6571 | match++;
|
6572 | if (node.data === close) {
|
6573 | if (match === 0) {
|
6574 | return nextSibling(node);
|
6575 | } else {
|
6576 | match--;
|
6577 | }
|
6578 | }
|
6579 | }
|
6580 | }
|
6581 | return node;
|
6582 | };
|
6583 | const replaceNode = (newNode, oldNode, parentComponent) => {
|
6584 | const parentNode2 = oldNode.parentNode;
|
6585 | if (parentNode2) {
|
6586 | parentNode2.replaceChild(newNode, oldNode);
|
6587 | }
|
6588 | let parent = parentComponent;
|
6589 | while (parent) {
|
6590 | if (parent.vnode.el === oldNode) {
|
6591 | parent.vnode.el = parent.subTree.el = newNode;
|
6592 | }
|
6593 | parent = parent.parent;
|
6594 | }
|
6595 | };
|
6596 | const isTemplateNode = (node) => {
|
6597 | return node.nodeType === 1 && node.tagName.toLowerCase() === "template";
|
6598 | };
|
6599 | return [hydrate, hydrateNode];
|
6600 | }
|
6601 | function propHasMismatch(el, key, clientValue, vnode, instance) {
|
6602 | var _a;
|
6603 | let mismatchType;
|
6604 | let mismatchKey;
|
6605 | let actual;
|
6606 | let expected;
|
6607 | if (key === "class") {
|
6608 | actual = el.getAttribute("class");
|
6609 | expected = normalizeClass(clientValue);
|
6610 | if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) {
|
6611 | mismatchType = mismatchKey = `class`;
|
6612 | }
|
6613 | } else if (key === "style") {
|
6614 | actual = el.getAttribute("style");
|
6615 | expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
|
6616 | const actualMap = toStyleMap(actual);
|
6617 | const expectedMap = toStyleMap(expected);
|
6618 | if (vnode.dirs) {
|
6619 | for (const { dir, value } of vnode.dirs) {
|
6620 | if (dir.name === "show" && !value) {
|
6621 | expectedMap.set("display", "none");
|
6622 | }
|
6623 | }
|
6624 | }
|
6625 | const root = instance == null ? void 0 : instance.subTree;
|
6626 | if (vnode === root || (root == null ? void 0 : root.type) === Fragment && root.children.includes(vnode)) {
|
6627 | const cssVars = (_a = instance == null ? void 0 : instance.getCssVars) == null ? void 0 : _a.call(instance);
|
6628 | for (const key2 in cssVars) {
|
6629 | expectedMap.set(`--${key2}`, String(cssVars[key2]));
|
6630 | }
|
6631 | }
|
6632 | if (!isMapEqual(actualMap, expectedMap)) {
|
6633 | mismatchType = mismatchKey = "style";
|
6634 | }
|
6635 | } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
|
6636 | if (isBooleanAttr(key)) {
|
6637 | actual = el.hasAttribute(key);
|
6638 | expected = includeBooleanAttr(clientValue);
|
6639 | } else if (clientValue == null) {
|
6640 | actual = el.hasAttribute(key);
|
6641 | expected = false;
|
6642 | } else {
|
6643 | if (el.hasAttribute(key)) {
|
6644 | actual = el.getAttribute(key);
|
6645 | } else if (key === "value" && el.tagName === "TEXTAREA") {
|
6646 | actual = el.value;
|
6647 | } else {
|
6648 | actual = false;
|
6649 | }
|
6650 | expected = isRenderableAttrValue(clientValue) ? String(clientValue) : false;
|
6651 | }
|
6652 | if (actual !== expected) {
|
6653 | mismatchType = `attribute`;
|
6654 | mismatchKey = key;
|
6655 | }
|
6656 | }
|
6657 | if (mismatchType) {
|
6658 | const format = (v) => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`;
|
6659 | const preSegment = `Hydration ${mismatchType} mismatch on`;
|
6660 | const postSegment = `
|
6661 | - rendered on server: ${format(actual)}
|
6662 | - expected on client: ${format(expected)}
|
6663 | Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
|
6664 | You should fix the source of the mismatch.`;
|
6665 | {
|
6666 | warn$1(preSegment, el, postSegment);
|
6667 | }
|
6668 | return true;
|
6669 | }
|
6670 | return false;
|
6671 | }
|
6672 | function toClassSet(str) {
|
6673 | return new Set(str.trim().split(/\s+/));
|
6674 | }
|
6675 | function isSetEqual(a, b) {
|
6676 | if (a.size !== b.size) {
|
6677 | return false;
|
6678 | }
|
6679 | for (const s of a) {
|
6680 | if (!b.has(s)) {
|
6681 | return false;
|
6682 | }
|
6683 | }
|
6684 | return true;
|
6685 | }
|
6686 | function toStyleMap(str) {
|
6687 | const styleMap = new Map();
|
6688 | for (const item of str.split(";")) {
|
6689 | let [key, value] = item.split(":");
|
6690 | key = key == null ? void 0 : key.trim();
|
6691 | value = value == null ? void 0 : value.trim();
|
6692 | if (key && value) {
|
6693 | styleMap.set(key, value);
|
6694 | }
|
6695 | }
|
6696 | return styleMap;
|
6697 | }
|
6698 | function isMapEqual(a, b) {
|
6699 | if (a.size !== b.size) {
|
6700 | return false;
|
6701 | }
|
6702 | for (const [key, value] of a) {
|
6703 | if (value !== b.get(key)) {
|
6704 | return false;
|
6705 | }
|
6706 | }
|
6707 | return true;
|
6708 | }
|
6709 |
|
6710 | let supported;
|
6711 | let perf;
|
6712 | function startMeasure(instance, type) {
|
6713 | if (instance.appContext.config.performance && isSupported()) {
|
6714 | perf.mark(`vue-${type}-${instance.uid}`);
|
6715 | }
|
6716 | {
|
6717 | devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
|
6718 | }
|
6719 | }
|
6720 | function endMeasure(instance, type) {
|
6721 | if (instance.appContext.config.performance && isSupported()) {
|
6722 | const startTag = `vue-${type}-${instance.uid}`;
|
6723 | const endTag = startTag + `:end`;
|
6724 | perf.mark(endTag);
|
6725 | perf.measure(
|
6726 | `<${formatComponentName(instance, instance.type)}> ${type}`,
|
6727 | startTag,
|
6728 | endTag
|
6729 | );
|
6730 | perf.clearMarks(startTag);
|
6731 | perf.clearMarks(endTag);
|
6732 | }
|
6733 | {
|
6734 | devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
|
6735 | }
|
6736 | }
|
6737 | function isSupported() {
|
6738 | if (supported !== void 0) {
|
6739 | return supported;
|
6740 | }
|
6741 | if (typeof window !== "undefined" && window.performance) {
|
6742 | supported = true;
|
6743 | perf = window.performance;
|
6744 | } else {
|
6745 | supported = false;
|
6746 | }
|
6747 | return supported;
|
6748 | }
|
6749 |
|
6750 | const queuePostRenderEffect = queueEffectWithSuspense ;
|
6751 | function createRenderer(options) {
|
6752 | return baseCreateRenderer(options);
|
6753 | }
|
6754 | function createHydrationRenderer(options) {
|
6755 | return baseCreateRenderer(options, createHydrationFunctions);
|
6756 | }
|
6757 | function baseCreateRenderer(options, createHydrationFns) {
|
6758 | const target = getGlobalThis();
|
6759 | target.__VUE__ = true;
|
6760 | {
|
6761 | setDevtoolsHook$1(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
|
6762 | }
|
6763 | const {
|
6764 | insert: hostInsert,
|
6765 | remove: hostRemove,
|
6766 | patchProp: hostPatchProp,
|
6767 | createElement: hostCreateElement,
|
6768 | createText: hostCreateText,
|
6769 | createComment: hostCreateComment,
|
6770 | setText: hostSetText,
|
6771 | setElementText: hostSetElementText,
|
6772 | parentNode: hostParentNode,
|
6773 | nextSibling: hostNextSibling,
|
6774 | setScopeId: hostSetScopeId = NOOP,
|
6775 | insertStaticContent: hostInsertStaticContent
|
6776 | } = options;
|
6777 | const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
|
6778 | if (n1 === n2) {
|
6779 | return;
|
6780 | }
|
6781 | if (n1 && !isSameVNodeType(n1, n2)) {
|
6782 | anchor = getNextHostNode(n1);
|
6783 | unmount(n1, parentComponent, parentSuspense, true);
|
6784 | n1 = null;
|
6785 | }
|
6786 | if (n2.patchFlag === -2) {
|
6787 | optimized = false;
|
6788 | n2.dynamicChildren = null;
|
6789 | }
|
6790 | const { type, ref, shapeFlag } = n2;
|
6791 | switch (type) {
|
6792 | case Text:
|
6793 | processText(n1, n2, container, anchor);
|
6794 | break;
|
6795 | case Comment:
|
6796 | processCommentNode(n1, n2, container, anchor);
|
6797 | break;
|
6798 | case Static:
|
6799 | if (n1 == null) {
|
6800 | mountStaticNode(n2, container, anchor, namespace);
|
6801 | } else {
|
6802 | patchStaticNode(n1, n2, container, namespace);
|
6803 | }
|
6804 | break;
|
6805 | case Fragment:
|
6806 | processFragment(
|
6807 | n1,
|
6808 | n2,
|
6809 | container,
|
6810 | anchor,
|
6811 | parentComponent,
|
6812 | parentSuspense,
|
6813 | namespace,
|
6814 | slotScopeIds,
|
6815 | optimized
|
6816 | );
|
6817 | break;
|
6818 | default:
|
6819 | if (shapeFlag & 1) {
|
6820 | processElement(
|
6821 | n1,
|
6822 | n2,
|
6823 | container,
|
6824 | anchor,
|
6825 | parentComponent,
|
6826 | parentSuspense,
|
6827 | namespace,
|
6828 | slotScopeIds,
|
6829 | optimized
|
6830 | );
|
6831 | } else if (shapeFlag & 6) {
|
6832 | processComponent(
|
6833 | n1,
|
6834 | n2,
|
6835 | container,
|
6836 | anchor,
|
6837 | parentComponent,
|
6838 | parentSuspense,
|
6839 | namespace,
|
6840 | slotScopeIds,
|
6841 | optimized
|
6842 | );
|
6843 | } else if (shapeFlag & 64) {
|
6844 | type.process(
|
6845 | n1,
|
6846 | n2,
|
6847 | container,
|
6848 | anchor,
|
6849 | parentComponent,
|
6850 | parentSuspense,
|
6851 | namespace,
|
6852 | slotScopeIds,
|
6853 | optimized,
|
6854 | internals
|
6855 | );
|
6856 | } else if (shapeFlag & 128) {
|
6857 | type.process(
|
6858 | n1,
|
6859 | n2,
|
6860 | container,
|
6861 | anchor,
|
6862 | parentComponent,
|
6863 | parentSuspense,
|
6864 | namespace,
|
6865 | slotScopeIds,
|
6866 | optimized,
|
6867 | internals
|
6868 | );
|
6869 | } else {
|
6870 | warn$1("Invalid VNode type:", type, `(${typeof type})`);
|
6871 | }
|
6872 | }
|
6873 | if (ref != null && parentComponent) {
|
6874 | setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
|
6875 | }
|
6876 | };
|
6877 | const processText = (n1, n2, container, anchor) => {
|
6878 | if (n1 == null) {
|
6879 | hostInsert(
|
6880 | n2.el = hostCreateText(n2.children),
|
6881 | container,
|
6882 | anchor
|
6883 | );
|
6884 | } else {
|
6885 | const el = n2.el = n1.el;
|
6886 | if (n2.children !== n1.children) {
|
6887 | hostSetText(el, n2.children);
|
6888 | }
|
6889 | }
|
6890 | };
|
6891 | const processCommentNode = (n1, n2, container, anchor) => {
|
6892 | if (n1 == null) {
|
6893 | hostInsert(
|
6894 | n2.el = hostCreateComment(n2.children || ""),
|
6895 | container,
|
6896 | anchor
|
6897 | );
|
6898 | } else {
|
6899 | n2.el = n1.el;
|
6900 | }
|
6901 | };
|
6902 | const mountStaticNode = (n2, container, anchor, namespace) => {
|
6903 | [n2.el, n2.anchor] = hostInsertStaticContent(
|
6904 | n2.children,
|
6905 | container,
|
6906 | anchor,
|
6907 | namespace,
|
6908 | n2.el,
|
6909 | n2.anchor
|
6910 | );
|
6911 | };
|
6912 | const patchStaticNode = (n1, n2, container, namespace) => {
|
6913 | if (n2.children !== n1.children) {
|
6914 | const anchor = hostNextSibling(n1.anchor);
|
6915 | removeStaticNode(n1);
|
6916 | [n2.el, n2.anchor] = hostInsertStaticContent(
|
6917 | n2.children,
|
6918 | container,
|
6919 | anchor,
|
6920 | namespace
|
6921 | );
|
6922 | } else {
|
6923 | n2.el = n1.el;
|
6924 | n2.anchor = n1.anchor;
|
6925 | }
|
6926 | };
|
6927 | const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
|
6928 | let next;
|
6929 | while (el && el !== anchor) {
|
6930 | next = hostNextSibling(el);
|
6931 | hostInsert(el, container, nextSibling);
|
6932 | el = next;
|
6933 | }
|
6934 | hostInsert(anchor, container, nextSibling);
|
6935 | };
|
6936 | const removeStaticNode = ({ el, anchor }) => {
|
6937 | let next;
|
6938 | while (el && el !== anchor) {
|
6939 | next = hostNextSibling(el);
|
6940 | hostRemove(el);
|
6941 | el = next;
|
6942 | }
|
6943 | hostRemove(anchor);
|
6944 | };
|
6945 | const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
6946 | if (n2.type === "svg") {
|
6947 | namespace = "svg";
|
6948 | } else if (n2.type === "math") {
|
6949 | namespace = "mathml";
|
6950 | }
|
6951 | if (n1 == null) {
|
6952 | mountElement(
|
6953 | n2,
|
6954 | container,
|
6955 | anchor,
|
6956 | parentComponent,
|
6957 | parentSuspense,
|
6958 | namespace,
|
6959 | slotScopeIds,
|
6960 | optimized
|
6961 | );
|
6962 | } else {
|
6963 | patchElement(
|
6964 | n1,
|
6965 | n2,
|
6966 | parentComponent,
|
6967 | parentSuspense,
|
6968 | namespace,
|
6969 | slotScopeIds,
|
6970 | optimized
|
6971 | );
|
6972 | }
|
6973 | };
|
6974 | const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
6975 | let el;
|
6976 | let vnodeHook;
|
6977 | const { props, shapeFlag, transition, dirs } = vnode;
|
6978 | el = vnode.el = hostCreateElement(
|
6979 | vnode.type,
|
6980 | namespace,
|
6981 | props && props.is,
|
6982 | props
|
6983 | );
|
6984 | if (shapeFlag & 8) {
|
6985 | hostSetElementText(el, vnode.children);
|
6986 | } else if (shapeFlag & 16) {
|
6987 | mountChildren(
|
6988 | vnode.children,
|
6989 | el,
|
6990 | null,
|
6991 | parentComponent,
|
6992 | parentSuspense,
|
6993 | resolveChildrenNamespace(vnode, namespace),
|
6994 | slotScopeIds,
|
6995 | optimized
|
6996 | );
|
6997 | }
|
6998 | if (dirs) {
|
6999 | invokeDirectiveHook(vnode, null, parentComponent, "created");
|
7000 | }
|
7001 | setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
|
7002 | if (props) {
|
7003 | for (const key in props) {
|
7004 | if (key !== "value" && !isReservedProp(key)) {
|
7005 | hostPatchProp(
|
7006 | el,
|
7007 | key,
|
7008 | null,
|
7009 | props[key],
|
7010 | namespace,
|
7011 | vnode.children,
|
7012 | parentComponent,
|
7013 | parentSuspense,
|
7014 | unmountChildren
|
7015 | );
|
7016 | }
|
7017 | }
|
7018 | if ("value" in props) {
|
7019 | hostPatchProp(el, "value", null, props.value, namespace);
|
7020 | }
|
7021 | if (vnodeHook = props.onVnodeBeforeMount) {
|
7022 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
7023 | }
|
7024 | }
|
7025 | {
|
7026 | Object.defineProperty(el, "__vnode", {
|
7027 | value: vnode,
|
7028 | enumerable: false
|
7029 | });
|
7030 | Object.defineProperty(el, "__vueParentComponent", {
|
7031 | value: parentComponent,
|
7032 | enumerable: false
|
7033 | });
|
7034 | }
|
7035 | if (dirs) {
|
7036 | invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
7037 | }
|
7038 | const needCallTransitionHooks = needTransition(parentSuspense, transition);
|
7039 | if (needCallTransitionHooks) {
|
7040 | transition.beforeEnter(el);
|
7041 | }
|
7042 | hostInsert(el, container, anchor);
|
7043 | if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
|
7044 | queuePostRenderEffect(() => {
|
7045 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
7046 | needCallTransitionHooks && transition.enter(el);
|
7047 | dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
7048 | }, parentSuspense);
|
7049 | }
|
7050 | };
|
7051 | const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
|
7052 | if (scopeId) {
|
7053 | hostSetScopeId(el, scopeId);
|
7054 | }
|
7055 | if (slotScopeIds) {
|
7056 | for (let i = 0; i < slotScopeIds.length; i++) {
|
7057 | hostSetScopeId(el, slotScopeIds[i]);
|
7058 | }
|
7059 | }
|
7060 | if (parentComponent) {
|
7061 | let subTree = parentComponent.subTree;
|
7062 | if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
|
7063 | subTree = filterSingleRoot(subTree.children) || subTree;
|
7064 | }
|
7065 | if (vnode === subTree) {
|
7066 | const parentVNode = parentComponent.vnode;
|
7067 | setScopeId(
|
7068 | el,
|
7069 | parentVNode,
|
7070 | parentVNode.scopeId,
|
7071 | parentVNode.slotScopeIds,
|
7072 | parentComponent.parent
|
7073 | );
|
7074 | }
|
7075 | }
|
7076 | };
|
7077 | const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
|
7078 | for (let i = start; i < children.length; i++) {
|
7079 | const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
|
7080 | patch(
|
7081 | null,
|
7082 | child,
|
7083 | container,
|
7084 | anchor,
|
7085 | parentComponent,
|
7086 | parentSuspense,
|
7087 | namespace,
|
7088 | slotScopeIds,
|
7089 | optimized
|
7090 | );
|
7091 | }
|
7092 | };
|
7093 | const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7094 | const el = n2.el = n1.el;
|
7095 | let { patchFlag, dynamicChildren, dirs } = n2;
|
7096 | patchFlag |= n1.patchFlag & 16;
|
7097 | const oldProps = n1.props || EMPTY_OBJ;
|
7098 | const newProps = n2.props || EMPTY_OBJ;
|
7099 | let vnodeHook;
|
7100 | parentComponent && toggleRecurse(parentComponent, false);
|
7101 | if (vnodeHook = newProps.onVnodeBeforeUpdate) {
|
7102 | invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
7103 | }
|
7104 | if (dirs) {
|
7105 | invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
|
7106 | }
|
7107 | parentComponent && toggleRecurse(parentComponent, true);
|
7108 | if (isHmrUpdating) {
|
7109 | patchFlag = 0;
|
7110 | optimized = false;
|
7111 | dynamicChildren = null;
|
7112 | }
|
7113 | if (dynamicChildren) {
|
7114 | patchBlockChildren(
|
7115 | n1.dynamicChildren,
|
7116 | dynamicChildren,
|
7117 | el,
|
7118 | parentComponent,
|
7119 | parentSuspense,
|
7120 | resolveChildrenNamespace(n2, namespace),
|
7121 | slotScopeIds
|
7122 | );
|
7123 | {
|
7124 | traverseStaticChildren(n1, n2);
|
7125 | }
|
7126 | } else if (!optimized) {
|
7127 | patchChildren(
|
7128 | n1,
|
7129 | n2,
|
7130 | el,
|
7131 | null,
|
7132 | parentComponent,
|
7133 | parentSuspense,
|
7134 | resolveChildrenNamespace(n2, namespace),
|
7135 | slotScopeIds,
|
7136 | false
|
7137 | );
|
7138 | }
|
7139 | if (patchFlag > 0) {
|
7140 | if (patchFlag & 16) {
|
7141 | patchProps(
|
7142 | el,
|
7143 | n2,
|
7144 | oldProps,
|
7145 | newProps,
|
7146 | parentComponent,
|
7147 | parentSuspense,
|
7148 | namespace
|
7149 | );
|
7150 | } else {
|
7151 | if (patchFlag & 2) {
|
7152 | if (oldProps.class !== newProps.class) {
|
7153 | hostPatchProp(el, "class", null, newProps.class, namespace);
|
7154 | }
|
7155 | }
|
7156 | if (patchFlag & 4) {
|
7157 | hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
|
7158 | }
|
7159 | if (patchFlag & 8) {
|
7160 | const propsToUpdate = n2.dynamicProps;
|
7161 | for (let i = 0; i < propsToUpdate.length; i++) {
|
7162 | const key = propsToUpdate[i];
|
7163 | const prev = oldProps[key];
|
7164 | const next = newProps[key];
|
7165 | if (next !== prev || key === "value") {
|
7166 | hostPatchProp(
|
7167 | el,
|
7168 | key,
|
7169 | prev,
|
7170 | next,
|
7171 | namespace,
|
7172 | n1.children,
|
7173 | parentComponent,
|
7174 | parentSuspense,
|
7175 | unmountChildren
|
7176 | );
|
7177 | }
|
7178 | }
|
7179 | }
|
7180 | }
|
7181 | if (patchFlag & 1) {
|
7182 | if (n1.children !== n2.children) {
|
7183 | hostSetElementText(el, n2.children);
|
7184 | }
|
7185 | }
|
7186 | } else if (!optimized && dynamicChildren == null) {
|
7187 | patchProps(
|
7188 | el,
|
7189 | n2,
|
7190 | oldProps,
|
7191 | newProps,
|
7192 | parentComponent,
|
7193 | parentSuspense,
|
7194 | namespace
|
7195 | );
|
7196 | }
|
7197 | if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
|
7198 | queuePostRenderEffect(() => {
|
7199 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
7200 | dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
|
7201 | }, parentSuspense);
|
7202 | }
|
7203 | };
|
7204 | const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
|
7205 | for (let i = 0; i < newChildren.length; i++) {
|
7206 | const oldVNode = oldChildren[i];
|
7207 | const newVNode = newChildren[i];
|
7208 | const container = (
|
7209 |
|
7210 |
|
7211 | oldVNode.el &&
|
7212 |
|
7213 | (oldVNode.type === Fragment ||
|
7214 |
|
7215 | !isSameVNodeType(oldVNode, newVNode) ||
|
7216 | oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
|
7217 |
|
7218 |
|
7219 | fallbackContainer
|
7220 | )
|
7221 | );
|
7222 | patch(
|
7223 | oldVNode,
|
7224 | newVNode,
|
7225 | container,
|
7226 | null,
|
7227 | parentComponent,
|
7228 | parentSuspense,
|
7229 | namespace,
|
7230 | slotScopeIds,
|
7231 | true
|
7232 | );
|
7233 | }
|
7234 | };
|
7235 | const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, namespace) => {
|
7236 | if (oldProps !== newProps) {
|
7237 | if (oldProps !== EMPTY_OBJ) {
|
7238 | for (const key in oldProps) {
|
7239 | if (!isReservedProp(key) && !(key in newProps)) {
|
7240 | hostPatchProp(
|
7241 | el,
|
7242 | key,
|
7243 | oldProps[key],
|
7244 | null,
|
7245 | namespace,
|
7246 | vnode.children,
|
7247 | parentComponent,
|
7248 | parentSuspense,
|
7249 | unmountChildren
|
7250 | );
|
7251 | }
|
7252 | }
|
7253 | }
|
7254 | for (const key in newProps) {
|
7255 | if (isReservedProp(key))
|
7256 | continue;
|
7257 | const next = newProps[key];
|
7258 | const prev = oldProps[key];
|
7259 | if (next !== prev && key !== "value") {
|
7260 | hostPatchProp(
|
7261 | el,
|
7262 | key,
|
7263 | prev,
|
7264 | next,
|
7265 | namespace,
|
7266 | vnode.children,
|
7267 | parentComponent,
|
7268 | parentSuspense,
|
7269 | unmountChildren
|
7270 | );
|
7271 | }
|
7272 | }
|
7273 | if ("value" in newProps) {
|
7274 | hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
|
7275 | }
|
7276 | }
|
7277 | };
|
7278 | const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7279 | const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
|
7280 | const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
|
7281 | let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
|
7282 | if (
|
7283 |
|
7284 | isHmrUpdating || patchFlag & 2048
|
7285 | ) {
|
7286 | patchFlag = 0;
|
7287 | optimized = false;
|
7288 | dynamicChildren = null;
|
7289 | }
|
7290 | if (fragmentSlotScopeIds) {
|
7291 | slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
7292 | }
|
7293 | if (n1 == null) {
|
7294 | hostInsert(fragmentStartAnchor, container, anchor);
|
7295 | hostInsert(fragmentEndAnchor, container, anchor);
|
7296 | mountChildren(
|
7297 |
|
7298 |
|
7299 |
|
7300 |
|
7301 | n2.children || [],
|
7302 | container,
|
7303 | fragmentEndAnchor,
|
7304 | parentComponent,
|
7305 | parentSuspense,
|
7306 | namespace,
|
7307 | slotScopeIds,
|
7308 | optimized
|
7309 | );
|
7310 | } else {
|
7311 | if (patchFlag > 0 && patchFlag & 64 && dynamicChildren &&
|
7312 |
|
7313 | n1.dynamicChildren) {
|
7314 | patchBlockChildren(
|
7315 | n1.dynamicChildren,
|
7316 | dynamicChildren,
|
7317 | container,
|
7318 | parentComponent,
|
7319 | parentSuspense,
|
7320 | namespace,
|
7321 | slotScopeIds
|
7322 | );
|
7323 | {
|
7324 | traverseStaticChildren(n1, n2);
|
7325 | }
|
7326 | } else {
|
7327 | patchChildren(
|
7328 | n1,
|
7329 | n2,
|
7330 | container,
|
7331 | fragmentEndAnchor,
|
7332 | parentComponent,
|
7333 | parentSuspense,
|
7334 | namespace,
|
7335 | slotScopeIds,
|
7336 | optimized
|
7337 | );
|
7338 | }
|
7339 | }
|
7340 | };
|
7341 | const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7342 | n2.slotScopeIds = slotScopeIds;
|
7343 | if (n1 == null) {
|
7344 | if (n2.shapeFlag & 512) {
|
7345 | parentComponent.ctx.activate(
|
7346 | n2,
|
7347 | container,
|
7348 | anchor,
|
7349 | namespace,
|
7350 | optimized
|
7351 | );
|
7352 | } else {
|
7353 | mountComponent(
|
7354 | n2,
|
7355 | container,
|
7356 | anchor,
|
7357 | parentComponent,
|
7358 | parentSuspense,
|
7359 | namespace,
|
7360 | optimized
|
7361 | );
|
7362 | }
|
7363 | } else {
|
7364 | updateComponent(n1, n2, optimized);
|
7365 | }
|
7366 | };
|
7367 | const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
|
7368 | const instance = (initialVNode.component = createComponentInstance(
|
7369 | initialVNode,
|
7370 | parentComponent,
|
7371 | parentSuspense
|
7372 | ));
|
7373 | if (instance.type.__hmrId) {
|
7374 | registerHMR(instance);
|
7375 | }
|
7376 | {
|
7377 | pushWarningContext(initialVNode);
|
7378 | startMeasure(instance, `mount`);
|
7379 | }
|
7380 | if (isKeepAlive(initialVNode)) {
|
7381 | instance.ctx.renderer = internals;
|
7382 | }
|
7383 | {
|
7384 | {
|
7385 | startMeasure(instance, `init`);
|
7386 | }
|
7387 | setupComponent(instance);
|
7388 | {
|
7389 | endMeasure(instance, `init`);
|
7390 | }
|
7391 | }
|
7392 | if (instance.asyncDep) {
|
7393 | parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
|
7394 | if (!initialVNode.el) {
|
7395 | const placeholder = instance.subTree = createVNode(Comment);
|
7396 | processCommentNode(null, placeholder, container, anchor);
|
7397 | }
|
7398 | } else {
|
7399 | setupRenderEffect(
|
7400 | instance,
|
7401 | initialVNode,
|
7402 | container,
|
7403 | anchor,
|
7404 | parentSuspense,
|
7405 | namespace,
|
7406 | optimized
|
7407 | );
|
7408 | }
|
7409 | {
|
7410 | popWarningContext();
|
7411 | endMeasure(instance, `mount`);
|
7412 | }
|
7413 | };
|
7414 | const updateComponent = (n1, n2, optimized) => {
|
7415 | const instance = n2.component = n1.component;
|
7416 | if (shouldUpdateComponent(n1, n2, optimized)) {
|
7417 | if (instance.asyncDep && !instance.asyncResolved) {
|
7418 | {
|
7419 | pushWarningContext(n2);
|
7420 | }
|
7421 | updateComponentPreRender(instance, n2, optimized);
|
7422 | {
|
7423 | popWarningContext();
|
7424 | }
|
7425 | return;
|
7426 | } else {
|
7427 | instance.next = n2;
|
7428 | invalidateJob(instance.update);
|
7429 | instance.effect.dirty = true;
|
7430 | instance.update();
|
7431 | }
|
7432 | } else {
|
7433 | n2.el = n1.el;
|
7434 | instance.vnode = n2;
|
7435 | }
|
7436 | };
|
7437 | const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
|
7438 | const componentUpdateFn = () => {
|
7439 | if (!instance.isMounted) {
|
7440 | let vnodeHook;
|
7441 | const { el, props } = initialVNode;
|
7442 | const { bm, m, parent } = instance;
|
7443 | const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
|
7444 | toggleRecurse(instance, false);
|
7445 | if (bm) {
|
7446 | invokeArrayFns(bm);
|
7447 | }
|
7448 | if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
|
7449 | invokeVNodeHook(vnodeHook, parent, initialVNode);
|
7450 | }
|
7451 | toggleRecurse(instance, true);
|
7452 | if (el && hydrateNode) {
|
7453 | const hydrateSubTree = () => {
|
7454 | {
|
7455 | startMeasure(instance, `render`);
|
7456 | }
|
7457 | instance.subTree = renderComponentRoot(instance);
|
7458 | {
|
7459 | endMeasure(instance, `render`);
|
7460 | }
|
7461 | {
|
7462 | startMeasure(instance, `hydrate`);
|
7463 | }
|
7464 | hydrateNode(
|
7465 | el,
|
7466 | instance.subTree,
|
7467 | instance,
|
7468 | parentSuspense,
|
7469 | null
|
7470 | );
|
7471 | {
|
7472 | endMeasure(instance, `hydrate`);
|
7473 | }
|
7474 | };
|
7475 | if (isAsyncWrapperVNode) {
|
7476 | initialVNode.type.__asyncLoader().then(
|
7477 |
|
7478 |
|
7479 |
|
7480 |
|
7481 | () => !instance.isUnmounted && hydrateSubTree()
|
7482 | );
|
7483 | } else {
|
7484 | hydrateSubTree();
|
7485 | }
|
7486 | } else {
|
7487 | {
|
7488 | startMeasure(instance, `render`);
|
7489 | }
|
7490 | const subTree = instance.subTree = renderComponentRoot(instance);
|
7491 | {
|
7492 | endMeasure(instance, `render`);
|
7493 | }
|
7494 | {
|
7495 | startMeasure(instance, `patch`);
|
7496 | }
|
7497 | patch(
|
7498 | null,
|
7499 | subTree,
|
7500 | container,
|
7501 | anchor,
|
7502 | instance,
|
7503 | parentSuspense,
|
7504 | namespace
|
7505 | );
|
7506 | {
|
7507 | endMeasure(instance, `patch`);
|
7508 | }
|
7509 | initialVNode.el = subTree.el;
|
7510 | }
|
7511 | if (m) {
|
7512 | queuePostRenderEffect(m, parentSuspense);
|
7513 | }
|
7514 | if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
|
7515 | const scopedInitialVNode = initialVNode;
|
7516 | queuePostRenderEffect(
|
7517 | () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
|
7518 | parentSuspense
|
7519 | );
|
7520 | }
|
7521 | if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
|
7522 | instance.a && queuePostRenderEffect(instance.a, parentSuspense);
|
7523 | }
|
7524 | instance.isMounted = true;
|
7525 | {
|
7526 | devtoolsComponentAdded(instance);
|
7527 | }
|
7528 | initialVNode = container = anchor = null;
|
7529 | } else {
|
7530 | let { next, bu, u, parent, vnode } = instance;
|
7531 | {
|
7532 | const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
|
7533 | if (nonHydratedAsyncRoot) {
|
7534 | if (next) {
|
7535 | next.el = vnode.el;
|
7536 | updateComponentPreRender(instance, next, optimized);
|
7537 | }
|
7538 | nonHydratedAsyncRoot.asyncDep.then(() => {
|
7539 | if (!instance.isUnmounted) {
|
7540 | componentUpdateFn();
|
7541 | }
|
7542 | });
|
7543 | return;
|
7544 | }
|
7545 | }
|
7546 | let originNext = next;
|
7547 | let vnodeHook;
|
7548 | {
|
7549 | pushWarningContext(next || instance.vnode);
|
7550 | }
|
7551 | toggleRecurse(instance, false);
|
7552 | if (next) {
|
7553 | next.el = vnode.el;
|
7554 | updateComponentPreRender(instance, next, optimized);
|
7555 | } else {
|
7556 | next = vnode;
|
7557 | }
|
7558 | if (bu) {
|
7559 | invokeArrayFns(bu);
|
7560 | }
|
7561 | if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
|
7562 | invokeVNodeHook(vnodeHook, parent, next, vnode);
|
7563 | }
|
7564 | toggleRecurse(instance, true);
|
7565 | {
|
7566 | startMeasure(instance, `render`);
|
7567 | }
|
7568 | const nextTree = renderComponentRoot(instance);
|
7569 | {
|
7570 | endMeasure(instance, `render`);
|
7571 | }
|
7572 | const prevTree = instance.subTree;
|
7573 | instance.subTree = nextTree;
|
7574 | {
|
7575 | startMeasure(instance, `patch`);
|
7576 | }
|
7577 | patch(
|
7578 | prevTree,
|
7579 | nextTree,
|
7580 |
|
7581 | hostParentNode(prevTree.el),
|
7582 |
|
7583 | getNextHostNode(prevTree),
|
7584 | instance,
|
7585 | parentSuspense,
|
7586 | namespace
|
7587 | );
|
7588 | {
|
7589 | endMeasure(instance, `patch`);
|
7590 | }
|
7591 | next.el = nextTree.el;
|
7592 | if (originNext === null) {
|
7593 | updateHOCHostEl(instance, nextTree.el);
|
7594 | }
|
7595 | if (u) {
|
7596 | queuePostRenderEffect(u, parentSuspense);
|
7597 | }
|
7598 | if (vnodeHook = next.props && next.props.onVnodeUpdated) {
|
7599 | queuePostRenderEffect(
|
7600 | () => invokeVNodeHook(vnodeHook, parent, next, vnode),
|
7601 | parentSuspense
|
7602 | );
|
7603 | }
|
7604 | {
|
7605 | devtoolsComponentUpdated(instance);
|
7606 | }
|
7607 | {
|
7608 | popWarningContext();
|
7609 | }
|
7610 | }
|
7611 | };
|
7612 | const effect = instance.effect = new ReactiveEffect(
|
7613 | componentUpdateFn,
|
7614 | NOOP,
|
7615 | () => queueJob(update),
|
7616 | instance.scope
|
7617 |
|
7618 | );
|
7619 | const update = instance.update = () => {
|
7620 | if (effect.dirty) {
|
7621 | effect.run();
|
7622 | }
|
7623 | };
|
7624 | update.id = instance.uid;
|
7625 | toggleRecurse(instance, true);
|
7626 | {
|
7627 | effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
|
7628 | effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
|
7629 | update.ownerInstance = instance;
|
7630 | }
|
7631 | update();
|
7632 | };
|
7633 | const updateComponentPreRender = (instance, nextVNode, optimized) => {
|
7634 | nextVNode.component = instance;
|
7635 | const prevProps = instance.vnode.props;
|
7636 | instance.vnode = nextVNode;
|
7637 | instance.next = null;
|
7638 | updateProps(instance, nextVNode.props, prevProps, optimized);
|
7639 | updateSlots(instance, nextVNode.children, optimized);
|
7640 | pauseTracking();
|
7641 | flushPreFlushCbs(instance);
|
7642 | resetTracking();
|
7643 | };
|
7644 | const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
|
7645 | const c1 = n1 && n1.children;
|
7646 | const prevShapeFlag = n1 ? n1.shapeFlag : 0;
|
7647 | const c2 = n2.children;
|
7648 | const { patchFlag, shapeFlag } = n2;
|
7649 | if (patchFlag > 0) {
|
7650 | if (patchFlag & 128) {
|
7651 | patchKeyedChildren(
|
7652 | c1,
|
7653 | c2,
|
7654 | container,
|
7655 | anchor,
|
7656 | parentComponent,
|
7657 | parentSuspense,
|
7658 | namespace,
|
7659 | slotScopeIds,
|
7660 | optimized
|
7661 | );
|
7662 | return;
|
7663 | } else if (patchFlag & 256) {
|
7664 | patchUnkeyedChildren(
|
7665 | c1,
|
7666 | c2,
|
7667 | container,
|
7668 | anchor,
|
7669 | parentComponent,
|
7670 | parentSuspense,
|
7671 | namespace,
|
7672 | slotScopeIds,
|
7673 | optimized
|
7674 | );
|
7675 | return;
|
7676 | }
|
7677 | }
|
7678 | if (shapeFlag & 8) {
|
7679 | if (prevShapeFlag & 16) {
|
7680 | unmountChildren(c1, parentComponent, parentSuspense);
|
7681 | }
|
7682 | if (c2 !== c1) {
|
7683 | hostSetElementText(container, c2);
|
7684 | }
|
7685 | } else {
|
7686 | if (prevShapeFlag & 16) {
|
7687 | if (shapeFlag & 16) {
|
7688 | patchKeyedChildren(
|
7689 | c1,
|
7690 | c2,
|
7691 | container,
|
7692 | anchor,
|
7693 | parentComponent,
|
7694 | parentSuspense,
|
7695 | namespace,
|
7696 | slotScopeIds,
|
7697 | optimized
|
7698 | );
|
7699 | } else {
|
7700 | unmountChildren(c1, parentComponent, parentSuspense, true);
|
7701 | }
|
7702 | } else {
|
7703 | if (prevShapeFlag & 8) {
|
7704 | hostSetElementText(container, "");
|
7705 | }
|
7706 | if (shapeFlag & 16) {
|
7707 | mountChildren(
|
7708 | c2,
|
7709 | container,
|
7710 | anchor,
|
7711 | parentComponent,
|
7712 | parentSuspense,
|
7713 | namespace,
|
7714 | slotScopeIds,
|
7715 | optimized
|
7716 | );
|
7717 | }
|
7718 | }
|
7719 | }
|
7720 | };
|
7721 | const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7722 | c1 = c1 || EMPTY_ARR;
|
7723 | c2 = c2 || EMPTY_ARR;
|
7724 | const oldLength = c1.length;
|
7725 | const newLength = c2.length;
|
7726 | const commonLength = Math.min(oldLength, newLength);
|
7727 | let i;
|
7728 | for (i = 0; i < commonLength; i++) {
|
7729 | const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
7730 | patch(
|
7731 | c1[i],
|
7732 | nextChild,
|
7733 | container,
|
7734 | null,
|
7735 | parentComponent,
|
7736 | parentSuspense,
|
7737 | namespace,
|
7738 | slotScopeIds,
|
7739 | optimized
|
7740 | );
|
7741 | }
|
7742 | if (oldLength > newLength) {
|
7743 | unmountChildren(
|
7744 | c1,
|
7745 | parentComponent,
|
7746 | parentSuspense,
|
7747 | true,
|
7748 | false,
|
7749 | commonLength
|
7750 | );
|
7751 | } else {
|
7752 | mountChildren(
|
7753 | c2,
|
7754 | container,
|
7755 | anchor,
|
7756 | parentComponent,
|
7757 | parentSuspense,
|
7758 | namespace,
|
7759 | slotScopeIds,
|
7760 | optimized,
|
7761 | commonLength
|
7762 | );
|
7763 | }
|
7764 | };
|
7765 | const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7766 | let i = 0;
|
7767 | const l2 = c2.length;
|
7768 | let e1 = c1.length - 1;
|
7769 | let e2 = l2 - 1;
|
7770 | while (i <= e1 && i <= e2) {
|
7771 | const n1 = c1[i];
|
7772 | const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
7773 | if (isSameVNodeType(n1, n2)) {
|
7774 | patch(
|
7775 | n1,
|
7776 | n2,
|
7777 | container,
|
7778 | null,
|
7779 | parentComponent,
|
7780 | parentSuspense,
|
7781 | namespace,
|
7782 | slotScopeIds,
|
7783 | optimized
|
7784 | );
|
7785 | } else {
|
7786 | break;
|
7787 | }
|
7788 | i++;
|
7789 | }
|
7790 | while (i <= e1 && i <= e2) {
|
7791 | const n1 = c1[e1];
|
7792 | const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
|
7793 | if (isSameVNodeType(n1, n2)) {
|
7794 | patch(
|
7795 | n1,
|
7796 | n2,
|
7797 | container,
|
7798 | null,
|
7799 | parentComponent,
|
7800 | parentSuspense,
|
7801 | namespace,
|
7802 | slotScopeIds,
|
7803 | optimized
|
7804 | );
|
7805 | } else {
|
7806 | break;
|
7807 | }
|
7808 | e1--;
|
7809 | e2--;
|
7810 | }
|
7811 | if (i > e1) {
|
7812 | if (i <= e2) {
|
7813 | const nextPos = e2 + 1;
|
7814 | const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
|
7815 | while (i <= e2) {
|
7816 | patch(
|
7817 | null,
|
7818 | c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
|
7819 | container,
|
7820 | anchor,
|
7821 | parentComponent,
|
7822 | parentSuspense,
|
7823 | namespace,
|
7824 | slotScopeIds,
|
7825 | optimized
|
7826 | );
|
7827 | i++;
|
7828 | }
|
7829 | }
|
7830 | } else if (i > e2) {
|
7831 | while (i <= e1) {
|
7832 | unmount(c1[i], parentComponent, parentSuspense, true);
|
7833 | i++;
|
7834 | }
|
7835 | } else {
|
7836 | const s1 = i;
|
7837 | const s2 = i;
|
7838 | const keyToNewIndexMap = new Map();
|
7839 | for (i = s2; i <= e2; i++) {
|
7840 | const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
7841 | if (nextChild.key != null) {
|
7842 | if (keyToNewIndexMap.has(nextChild.key)) {
|
7843 | warn$1(
|
7844 | `Duplicate keys found during update:`,
|
7845 | JSON.stringify(nextChild.key),
|
7846 | `Make sure keys are unique.`
|
7847 | );
|
7848 | }
|
7849 | keyToNewIndexMap.set(nextChild.key, i);
|
7850 | }
|
7851 | }
|
7852 | let j;
|
7853 | let patched = 0;
|
7854 | const toBePatched = e2 - s2 + 1;
|
7855 | let moved = false;
|
7856 | let maxNewIndexSoFar = 0;
|
7857 | const newIndexToOldIndexMap = new Array(toBePatched);
|
7858 | for (i = 0; i < toBePatched; i++)
|
7859 | newIndexToOldIndexMap[i] = 0;
|
7860 | for (i = s1; i <= e1; i++) {
|
7861 | const prevChild = c1[i];
|
7862 | if (patched >= toBePatched) {
|
7863 | unmount(prevChild, parentComponent, parentSuspense, true);
|
7864 | continue;
|
7865 | }
|
7866 | let newIndex;
|
7867 | if (prevChild.key != null) {
|
7868 | newIndex = keyToNewIndexMap.get(prevChild.key);
|
7869 | } else {
|
7870 | for (j = s2; j <= e2; j++) {
|
7871 | if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
|
7872 | newIndex = j;
|
7873 | break;
|
7874 | }
|
7875 | }
|
7876 | }
|
7877 | if (newIndex === void 0) {
|
7878 | unmount(prevChild, parentComponent, parentSuspense, true);
|
7879 | } else {
|
7880 | newIndexToOldIndexMap[newIndex - s2] = i + 1;
|
7881 | if (newIndex >= maxNewIndexSoFar) {
|
7882 | maxNewIndexSoFar = newIndex;
|
7883 | } else {
|
7884 | moved = true;
|
7885 | }
|
7886 | patch(
|
7887 | prevChild,
|
7888 | c2[newIndex],
|
7889 | container,
|
7890 | null,
|
7891 | parentComponent,
|
7892 | parentSuspense,
|
7893 | namespace,
|
7894 | slotScopeIds,
|
7895 | optimized
|
7896 | );
|
7897 | patched++;
|
7898 | }
|
7899 | }
|
7900 | const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
|
7901 | j = increasingNewIndexSequence.length - 1;
|
7902 | for (i = toBePatched - 1; i >= 0; i--) {
|
7903 | const nextIndex = s2 + i;
|
7904 | const nextChild = c2[nextIndex];
|
7905 | const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
|
7906 | if (newIndexToOldIndexMap[i] === 0) {
|
7907 | patch(
|
7908 | null,
|
7909 | nextChild,
|
7910 | container,
|
7911 | anchor,
|
7912 | parentComponent,
|
7913 | parentSuspense,
|
7914 | namespace,
|
7915 | slotScopeIds,
|
7916 | optimized
|
7917 | );
|
7918 | } else if (moved) {
|
7919 | if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
7920 | move(nextChild, container, anchor, 2);
|
7921 | } else {
|
7922 | j--;
|
7923 | }
|
7924 | }
|
7925 | }
|
7926 | }
|
7927 | };
|
7928 | const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
|
7929 | const { el, type, transition, children, shapeFlag } = vnode;
|
7930 | if (shapeFlag & 6) {
|
7931 | move(vnode.component.subTree, container, anchor, moveType);
|
7932 | return;
|
7933 | }
|
7934 | if (shapeFlag & 128) {
|
7935 | vnode.suspense.move(container, anchor, moveType);
|
7936 | return;
|
7937 | }
|
7938 | if (shapeFlag & 64) {
|
7939 | type.move(vnode, container, anchor, internals);
|
7940 | return;
|
7941 | }
|
7942 | if (type === Fragment) {
|
7943 | hostInsert(el, container, anchor);
|
7944 | for (let i = 0; i < children.length; i++) {
|
7945 | move(children[i], container, anchor, moveType);
|
7946 | }
|
7947 | hostInsert(vnode.anchor, container, anchor);
|
7948 | return;
|
7949 | }
|
7950 | if (type === Static) {
|
7951 | moveStaticNode(vnode, container, anchor);
|
7952 | return;
|
7953 | }
|
7954 | const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
|
7955 | if (needTransition2) {
|
7956 | if (moveType === 0) {
|
7957 | transition.beforeEnter(el);
|
7958 | hostInsert(el, container, anchor);
|
7959 | queuePostRenderEffect(() => transition.enter(el), parentSuspense);
|
7960 | } else {
|
7961 | const { leave, delayLeave, afterLeave } = transition;
|
7962 | const remove2 = () => hostInsert(el, container, anchor);
|
7963 | const performLeave = () => {
|
7964 | leave(el, () => {
|
7965 | remove2();
|
7966 | afterLeave && afterLeave();
|
7967 | });
|
7968 | };
|
7969 | if (delayLeave) {
|
7970 | delayLeave(el, remove2, performLeave);
|
7971 | } else {
|
7972 | performLeave();
|
7973 | }
|
7974 | }
|
7975 | } else {
|
7976 | hostInsert(el, container, anchor);
|
7977 | }
|
7978 | };
|
7979 | const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
|
7980 | const {
|
7981 | type,
|
7982 | props,
|
7983 | ref,
|
7984 | children,
|
7985 | dynamicChildren,
|
7986 | shapeFlag,
|
7987 | patchFlag,
|
7988 | dirs
|
7989 | } = vnode;
|
7990 | if (ref != null) {
|
7991 | setRef(ref, null, parentSuspense, vnode, true);
|
7992 | }
|
7993 | if (shapeFlag & 256) {
|
7994 | parentComponent.ctx.deactivate(vnode);
|
7995 | return;
|
7996 | }
|
7997 | const shouldInvokeDirs = shapeFlag & 1 && dirs;
|
7998 | const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
|
7999 | let vnodeHook;
|
8000 | if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
|
8001 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
8002 | }
|
8003 | if (shapeFlag & 6) {
|
8004 | unmountComponent(vnode.component, parentSuspense, doRemove);
|
8005 | } else {
|
8006 | if (shapeFlag & 128) {
|
8007 | vnode.suspense.unmount(parentSuspense, doRemove);
|
8008 | return;
|
8009 | }
|
8010 | if (shouldInvokeDirs) {
|
8011 | invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
|
8012 | }
|
8013 | if (shapeFlag & 64) {
|
8014 | vnode.type.remove(
|
8015 | vnode,
|
8016 | parentComponent,
|
8017 | parentSuspense,
|
8018 | optimized,
|
8019 | internals,
|
8020 | doRemove
|
8021 | );
|
8022 | } else if (dynamicChildren &&
|
8023 | (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
|
8024 | unmountChildren(
|
8025 | dynamicChildren,
|
8026 | parentComponent,
|
8027 | parentSuspense,
|
8028 | false,
|
8029 | true
|
8030 | );
|
8031 | } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
|
8032 | unmountChildren(children, parentComponent, parentSuspense);
|
8033 | }
|
8034 | if (doRemove) {
|
8035 | remove(vnode);
|
8036 | }
|
8037 | }
|
8038 | if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
|
8039 | queuePostRenderEffect(() => {
|
8040 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
8041 | shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
|
8042 | }, parentSuspense);
|
8043 | }
|
8044 | };
|
8045 | const remove = (vnode) => {
|
8046 | const { type, el, anchor, transition } = vnode;
|
8047 | if (type === Fragment) {
|
8048 | if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
|
8049 | vnode.children.forEach((child) => {
|
8050 | if (child.type === Comment) {
|
8051 | hostRemove(child.el);
|
8052 | } else {
|
8053 | remove(child);
|
8054 | }
|
8055 | });
|
8056 | } else {
|
8057 | removeFragment(el, anchor);
|
8058 | }
|
8059 | return;
|
8060 | }
|
8061 | if (type === Static) {
|
8062 | removeStaticNode(vnode);
|
8063 | return;
|
8064 | }
|
8065 | const performRemove = () => {
|
8066 | hostRemove(el);
|
8067 | if (transition && !transition.persisted && transition.afterLeave) {
|
8068 | transition.afterLeave();
|
8069 | }
|
8070 | };
|
8071 | if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
|
8072 | const { leave, delayLeave } = transition;
|
8073 | const performLeave = () => leave(el, performRemove);
|
8074 | if (delayLeave) {
|
8075 | delayLeave(vnode.el, performRemove, performLeave);
|
8076 | } else {
|
8077 | performLeave();
|
8078 | }
|
8079 | } else {
|
8080 | performRemove();
|
8081 | }
|
8082 | };
|
8083 | const removeFragment = (cur, end) => {
|
8084 | let next;
|
8085 | while (cur !== end) {
|
8086 | next = hostNextSibling(cur);
|
8087 | hostRemove(cur);
|
8088 | cur = next;
|
8089 | }
|
8090 | hostRemove(end);
|
8091 | };
|
8092 | const unmountComponent = (instance, parentSuspense, doRemove) => {
|
8093 | if (instance.type.__hmrId) {
|
8094 | unregisterHMR(instance);
|
8095 | }
|
8096 | const { bum, scope, update, subTree, um } = instance;
|
8097 | if (bum) {
|
8098 | invokeArrayFns(bum);
|
8099 | }
|
8100 | scope.stop();
|
8101 | if (update) {
|
8102 | update.active = false;
|
8103 | unmount(subTree, instance, parentSuspense, doRemove);
|
8104 | }
|
8105 | if (um) {
|
8106 | queuePostRenderEffect(um, parentSuspense);
|
8107 | }
|
8108 | queuePostRenderEffect(() => {
|
8109 | instance.isUnmounted = true;
|
8110 | }, parentSuspense);
|
8111 | if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
|
8112 | parentSuspense.deps--;
|
8113 | if (parentSuspense.deps === 0) {
|
8114 | parentSuspense.resolve();
|
8115 | }
|
8116 | }
|
8117 | {
|
8118 | devtoolsComponentRemoved(instance);
|
8119 | }
|
8120 | };
|
8121 | const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
|
8122 | for (let i = start; i < children.length; i++) {
|
8123 | unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
|
8124 | }
|
8125 | };
|
8126 | const getNextHostNode = (vnode) => {
|
8127 | if (vnode.shapeFlag & 6) {
|
8128 | return getNextHostNode(vnode.component.subTree);
|
8129 | }
|
8130 | if (vnode.shapeFlag & 128) {
|
8131 | return vnode.suspense.next();
|
8132 | }
|
8133 | return hostNextSibling(vnode.anchor || vnode.el);
|
8134 | };
|
8135 | let isFlushing = false;
|
8136 | const render = (vnode, container, namespace) => {
|
8137 | if (vnode == null) {
|
8138 | if (container._vnode) {
|
8139 | unmount(container._vnode, null, null, true);
|
8140 | }
|
8141 | } else {
|
8142 | patch(
|
8143 | container._vnode || null,
|
8144 | vnode,
|
8145 | container,
|
8146 | null,
|
8147 | null,
|
8148 | null,
|
8149 | namespace
|
8150 | );
|
8151 | }
|
8152 | if (!isFlushing) {
|
8153 | isFlushing = true;
|
8154 | flushPreFlushCbs();
|
8155 | flushPostFlushCbs();
|
8156 | isFlushing = false;
|
8157 | }
|
8158 | container._vnode = vnode;
|
8159 | };
|
8160 | const internals = {
|
8161 | p: patch,
|
8162 | um: unmount,
|
8163 | m: move,
|
8164 | r: remove,
|
8165 | mt: mountComponent,
|
8166 | mc: mountChildren,
|
8167 | pc: patchChildren,
|
8168 | pbc: patchBlockChildren,
|
8169 | n: getNextHostNode,
|
8170 | o: options
|
8171 | };
|
8172 | let hydrate;
|
8173 | let hydrateNode;
|
8174 | if (createHydrationFns) {
|
8175 | [hydrate, hydrateNode] = createHydrationFns(
|
8176 | internals
|
8177 | );
|
8178 | }
|
8179 | return {
|
8180 | render,
|
8181 | hydrate,
|
8182 | createApp: createAppAPI(render, hydrate)
|
8183 | };
|
8184 | }
|
8185 | function resolveChildrenNamespace({ type, props }, currentNamespace) {
|
8186 | return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
|
8187 | }
|
8188 | function toggleRecurse({ effect, update }, allowed) {
|
8189 | effect.allowRecurse = update.allowRecurse = allowed;
|
8190 | }
|
8191 | function needTransition(parentSuspense, transition) {
|
8192 | return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
|
8193 | }
|
8194 | function traverseStaticChildren(n1, n2, shallow = false) {
|
8195 | const ch1 = n1.children;
|
8196 | const ch2 = n2.children;
|
8197 | if (isArray(ch1) && isArray(ch2)) {
|
8198 | for (let i = 0; i < ch1.length; i++) {
|
8199 | const c1 = ch1[i];
|
8200 | let c2 = ch2[i];
|
8201 | if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
|
8202 | if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
|
8203 | c2 = ch2[i] = cloneIfMounted(ch2[i]);
|
8204 | c2.el = c1.el;
|
8205 | }
|
8206 | if (!shallow)
|
8207 | traverseStaticChildren(c1, c2);
|
8208 | }
|
8209 | if (c2.type === Text) {
|
8210 | c2.el = c1.el;
|
8211 | }
|
8212 | if (c2.type === Comment && !c2.el) {
|
8213 | c2.el = c1.el;
|
8214 | }
|
8215 | }
|
8216 | }
|
8217 | }
|
8218 | function getSequence(arr) {
|
8219 | const p = arr.slice();
|
8220 | const result = [0];
|
8221 | let i, j, u, v, c;
|
8222 | const len = arr.length;
|
8223 | for (i = 0; i < len; i++) {
|
8224 | const arrI = arr[i];
|
8225 | if (arrI !== 0) {
|
8226 | j = result[result.length - 1];
|
8227 | if (arr[j] < arrI) {
|
8228 | p[i] = j;
|
8229 | result.push(i);
|
8230 | continue;
|
8231 | }
|
8232 | u = 0;
|
8233 | v = result.length - 1;
|
8234 | while (u < v) {
|
8235 | c = u + v >> 1;
|
8236 | if (arr[result[c]] < arrI) {
|
8237 | u = c + 1;
|
8238 | } else {
|
8239 | v = c;
|
8240 | }
|
8241 | }
|
8242 | if (arrI < arr[result[u]]) {
|
8243 | if (u > 0) {
|
8244 | p[i] = result[u - 1];
|
8245 | }
|
8246 | result[u] = i;
|
8247 | }
|
8248 | }
|
8249 | }
|
8250 | u = result.length;
|
8251 | v = result[u - 1];
|
8252 | while (u-- > 0) {
|
8253 | result[u] = v;
|
8254 | v = p[v];
|
8255 | }
|
8256 | return result;
|
8257 | }
|
8258 | function locateNonHydratedAsyncRoot(instance) {
|
8259 | const subComponent = instance.subTree.component;
|
8260 | if (subComponent) {
|
8261 | if (subComponent.asyncDep && !subComponent.asyncResolved) {
|
8262 | return subComponent;
|
8263 | } else {
|
8264 | return locateNonHydratedAsyncRoot(subComponent);
|
8265 | }
|
8266 | }
|
8267 | }
|
8268 |
|
8269 | const isTeleport = (type) => type.__isTeleport;
|
8270 | const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
|
8271 | const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
|
8272 | const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
|
8273 | const resolveTarget = (props, select) => {
|
8274 | const targetSelector = props && props.to;
|
8275 | if (isString(targetSelector)) {
|
8276 | if (!select) {
|
8277 | warn$1(
|
8278 | `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`
|
8279 | );
|
8280 | return null;
|
8281 | } else {
|
8282 | const target = select(targetSelector);
|
8283 | if (!target) {
|
8284 | warn$1(
|
8285 | `Failed to locate Teleport target with selector "${targetSelector}". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.`
|
8286 | );
|
8287 | }
|
8288 | return target;
|
8289 | }
|
8290 | } else {
|
8291 | if (!targetSelector && !isTeleportDisabled(props)) {
|
8292 | warn$1(`Invalid Teleport target: ${targetSelector}`);
|
8293 | }
|
8294 | return targetSelector;
|
8295 | }
|
8296 | };
|
8297 | const TeleportImpl = {
|
8298 | name: "Teleport",
|
8299 | __isTeleport: true,
|
8300 | process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
|
8301 | const {
|
8302 | mc: mountChildren,
|
8303 | pc: patchChildren,
|
8304 | pbc: patchBlockChildren,
|
8305 | o: { insert, querySelector, createText, createComment }
|
8306 | } = internals;
|
8307 | const disabled = isTeleportDisabled(n2.props);
|
8308 | let { shapeFlag, children, dynamicChildren } = n2;
|
8309 | if (isHmrUpdating) {
|
8310 | optimized = false;
|
8311 | dynamicChildren = null;
|
8312 | }
|
8313 | if (n1 == null) {
|
8314 | const placeholder = n2.el = createComment("teleport start") ;
|
8315 | const mainAnchor = n2.anchor = createComment("teleport end") ;
|
8316 | insert(placeholder, container, anchor);
|
8317 | insert(mainAnchor, container, anchor);
|
8318 | const target = n2.target = resolveTarget(n2.props, querySelector);
|
8319 | const targetAnchor = n2.targetAnchor = createText("");
|
8320 | if (target) {
|
8321 | insert(targetAnchor, target);
|
8322 | if (namespace === "svg" || isTargetSVG(target)) {
|
8323 | namespace = "svg";
|
8324 | } else if (namespace === "mathml" || isTargetMathML(target)) {
|
8325 | namespace = "mathml";
|
8326 | }
|
8327 | } else if (!disabled) {
|
8328 | warn$1("Invalid Teleport target on mount:", target, `(${typeof target})`);
|
8329 | }
|
8330 | const mount = (container2, anchor2) => {
|
8331 | if (shapeFlag & 16) {
|
8332 | mountChildren(
|
8333 | children,
|
8334 | container2,
|
8335 | anchor2,
|
8336 | parentComponent,
|
8337 | parentSuspense,
|
8338 | namespace,
|
8339 | slotScopeIds,
|
8340 | optimized
|
8341 | );
|
8342 | }
|
8343 | };
|
8344 | if (disabled) {
|
8345 | mount(container, mainAnchor);
|
8346 | } else if (target) {
|
8347 | mount(target, targetAnchor);
|
8348 | }
|
8349 | } else {
|
8350 | n2.el = n1.el;
|
8351 | const mainAnchor = n2.anchor = n1.anchor;
|
8352 | const target = n2.target = n1.target;
|
8353 | const targetAnchor = n2.targetAnchor = n1.targetAnchor;
|
8354 | const wasDisabled = isTeleportDisabled(n1.props);
|
8355 | const currentContainer = wasDisabled ? container : target;
|
8356 | const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
|
8357 | if (namespace === "svg" || isTargetSVG(target)) {
|
8358 | namespace = "svg";
|
8359 | } else if (namespace === "mathml" || isTargetMathML(target)) {
|
8360 | namespace = "mathml";
|
8361 | }
|
8362 | if (dynamicChildren) {
|
8363 | patchBlockChildren(
|
8364 | n1.dynamicChildren,
|
8365 | dynamicChildren,
|
8366 | currentContainer,
|
8367 | parentComponent,
|
8368 | parentSuspense,
|
8369 | namespace,
|
8370 | slotScopeIds
|
8371 | );
|
8372 | traverseStaticChildren(n1, n2, true);
|
8373 | } else if (!optimized) {
|
8374 | patchChildren(
|
8375 | n1,
|
8376 | n2,
|
8377 | currentContainer,
|
8378 | currentAnchor,
|
8379 | parentComponent,
|
8380 | parentSuspense,
|
8381 | namespace,
|
8382 | slotScopeIds,
|
8383 | false
|
8384 | );
|
8385 | }
|
8386 | if (disabled) {
|
8387 | if (!wasDisabled) {
|
8388 | moveTeleport(
|
8389 | n2,
|
8390 | container,
|
8391 | mainAnchor,
|
8392 | internals,
|
8393 | 1
|
8394 | );
|
8395 | } else {
|
8396 | if (n2.props && n1.props && n2.props.to !== n1.props.to) {
|
8397 | n2.props.to = n1.props.to;
|
8398 | }
|
8399 | }
|
8400 | } else {
|
8401 | if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
|
8402 | const nextTarget = n2.target = resolveTarget(
|
8403 | n2.props,
|
8404 | querySelector
|
8405 | );
|
8406 | if (nextTarget) {
|
8407 | moveTeleport(
|
8408 | n2,
|
8409 | nextTarget,
|
8410 | null,
|
8411 | internals,
|
8412 | 0
|
8413 | );
|
8414 | } else {
|
8415 | warn$1(
|
8416 | "Invalid Teleport target on update:",
|
8417 | target,
|
8418 | `(${typeof target})`
|
8419 | );
|
8420 | }
|
8421 | } else if (wasDisabled) {
|
8422 | moveTeleport(
|
8423 | n2,
|
8424 | target,
|
8425 | targetAnchor,
|
8426 | internals,
|
8427 | 1
|
8428 | );
|
8429 | }
|
8430 | }
|
8431 | }
|
8432 | updateCssVars(n2);
|
8433 | },
|
8434 | remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
|
8435 | const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
|
8436 | if (target) {
|
8437 | hostRemove(targetAnchor);
|
8438 | }
|
8439 | doRemove && hostRemove(anchor);
|
8440 | if (shapeFlag & 16) {
|
8441 | const shouldRemove = doRemove || !isTeleportDisabled(props);
|
8442 | for (let i = 0; i < children.length; i++) {
|
8443 | const child = children[i];
|
8444 | unmount(
|
8445 | child,
|
8446 | parentComponent,
|
8447 | parentSuspense,
|
8448 | shouldRemove,
|
8449 | !!child.dynamicChildren
|
8450 | );
|
8451 | }
|
8452 | }
|
8453 | },
|
8454 | move: moveTeleport,
|
8455 | hydrate: hydrateTeleport
|
8456 | };
|
8457 | function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
|
8458 | if (moveType === 0) {
|
8459 | insert(vnode.targetAnchor, container, parentAnchor);
|
8460 | }
|
8461 | const { el, anchor, shapeFlag, children, props } = vnode;
|
8462 | const isReorder = moveType === 2;
|
8463 | if (isReorder) {
|
8464 | insert(el, container, parentAnchor);
|
8465 | }
|
8466 | if (!isReorder || isTeleportDisabled(props)) {
|
8467 | if (shapeFlag & 16) {
|
8468 | for (let i = 0; i < children.length; i++) {
|
8469 | move(
|
8470 | children[i],
|
8471 | container,
|
8472 | parentAnchor,
|
8473 | 2
|
8474 | );
|
8475 | }
|
8476 | }
|
8477 | }
|
8478 | if (isReorder) {
|
8479 | insert(anchor, container, parentAnchor);
|
8480 | }
|
8481 | }
|
8482 | function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
|
8483 | o: { nextSibling, parentNode, querySelector }
|
8484 | }, hydrateChildren) {
|
8485 | const target = vnode.target = resolveTarget(
|
8486 | vnode.props,
|
8487 | querySelector
|
8488 | );
|
8489 | if (target) {
|
8490 | const targetNode = target._lpa || target.firstChild;
|
8491 | if (vnode.shapeFlag & 16) {
|
8492 | if (isTeleportDisabled(vnode.props)) {
|
8493 | vnode.anchor = hydrateChildren(
|
8494 | nextSibling(node),
|
8495 | vnode,
|
8496 | parentNode(node),
|
8497 | parentComponent,
|
8498 | parentSuspense,
|
8499 | slotScopeIds,
|
8500 | optimized
|
8501 | );
|
8502 | vnode.targetAnchor = targetNode;
|
8503 | } else {
|
8504 | vnode.anchor = nextSibling(node);
|
8505 | let targetAnchor = targetNode;
|
8506 | while (targetAnchor) {
|
8507 | targetAnchor = nextSibling(targetAnchor);
|
8508 | if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
|
8509 | vnode.targetAnchor = targetAnchor;
|
8510 | target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
|
8511 | break;
|
8512 | }
|
8513 | }
|
8514 | hydrateChildren(
|
8515 | targetNode,
|
8516 | vnode,
|
8517 | target,
|
8518 | parentComponent,
|
8519 | parentSuspense,
|
8520 | slotScopeIds,
|
8521 | optimized
|
8522 | );
|
8523 | }
|
8524 | }
|
8525 | updateCssVars(vnode);
|
8526 | }
|
8527 | return vnode.anchor && nextSibling(vnode.anchor);
|
8528 | }
|
8529 | const Teleport = TeleportImpl;
|
8530 | function updateCssVars(vnode) {
|
8531 | const ctx = vnode.ctx;
|
8532 | if (ctx && ctx.ut) {
|
8533 | let node = vnode.children[0].el;
|
8534 | while (node && node !== vnode.targetAnchor) {
|
8535 | if (node.nodeType === 1)
|
8536 | node.setAttribute("data-v-owner", ctx.uid);
|
8537 | node = node.nextSibling;
|
8538 | }
|
8539 | ctx.ut();
|
8540 | }
|
8541 | }
|
8542 |
|
8543 | const Fragment = Symbol.for("v-fgt");
|
8544 | const Text = Symbol.for("v-txt");
|
8545 | const Comment = Symbol.for("v-cmt");
|
8546 | const Static = Symbol.for("v-stc");
|
8547 | const blockStack = [];
|
8548 | let currentBlock = null;
|
8549 | function openBlock(disableTracking = false) {
|
8550 | blockStack.push(currentBlock = disableTracking ? null : []);
|
8551 | }
|
8552 | function closeBlock() {
|
8553 | blockStack.pop();
|
8554 | currentBlock = blockStack[blockStack.length - 1] || null;
|
8555 | }
|
8556 | let isBlockTreeEnabled = 1;
|
8557 | function setBlockTracking(value) {
|
8558 | isBlockTreeEnabled += value;
|
8559 | }
|
8560 | function setupBlock(vnode) {
|
8561 | vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
|
8562 | closeBlock();
|
8563 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
8564 | currentBlock.push(vnode);
|
8565 | }
|
8566 | return vnode;
|
8567 | }
|
8568 | function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
|
8569 | return setupBlock(
|
8570 | createBaseVNode(
|
8571 | type,
|
8572 | props,
|
8573 | children,
|
8574 | patchFlag,
|
8575 | dynamicProps,
|
8576 | shapeFlag,
|
8577 | true
|
8578 | )
|
8579 | );
|
8580 | }
|
8581 | function createBlock(type, props, children, patchFlag, dynamicProps) {
|
8582 | return setupBlock(
|
8583 | createVNode(
|
8584 | type,
|
8585 | props,
|
8586 | children,
|
8587 | patchFlag,
|
8588 | dynamicProps,
|
8589 | true
|
8590 | )
|
8591 | );
|
8592 | }
|
8593 | function isVNode(value) {
|
8594 | return value ? value.__v_isVNode === true : false;
|
8595 | }
|
8596 | function isSameVNodeType(n1, n2) {
|
8597 | if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
|
8598 | n1.shapeFlag &= ~256;
|
8599 | n2.shapeFlag &= ~512;
|
8600 | return false;
|
8601 | }
|
8602 | return n1.type === n2.type && n1.key === n2.key;
|
8603 | }
|
8604 | let vnodeArgsTransformer;
|
8605 | function transformVNodeArgs(transformer) {
|
8606 | vnodeArgsTransformer = transformer;
|
8607 | }
|
8608 | const createVNodeWithArgsTransform = (...args) => {
|
8609 | return _createVNode(
|
8610 | ...vnodeArgsTransformer ? vnodeArgsTransformer(args, currentRenderingInstance) : args
|
8611 | );
|
8612 | };
|
8613 | const InternalObjectKey = `__vInternal`;
|
8614 | const normalizeKey = ({ key }) => key != null ? key : null;
|
8615 | const normalizeRef = ({
|
8616 | ref,
|
8617 | ref_key,
|
8618 | ref_for
|
8619 | }) => {
|
8620 | if (typeof ref === "number") {
|
8621 | ref = "" + ref;
|
8622 | }
|
8623 | return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null;
|
8624 | };
|
8625 | function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
|
8626 | const vnode = {
|
8627 | __v_isVNode: true,
|
8628 | __v_skip: true,
|
8629 | type,
|
8630 | props,
|
8631 | key: props && normalizeKey(props),
|
8632 | ref: props && normalizeRef(props),
|
8633 | scopeId: currentScopeId,
|
8634 | slotScopeIds: null,
|
8635 | children,
|
8636 | component: null,
|
8637 | suspense: null,
|
8638 | ssContent: null,
|
8639 | ssFallback: null,
|
8640 | dirs: null,
|
8641 | transition: null,
|
8642 | el: null,
|
8643 | anchor: null,
|
8644 | target: null,
|
8645 | targetAnchor: null,
|
8646 | staticCount: 0,
|
8647 | shapeFlag,
|
8648 | patchFlag,
|
8649 | dynamicProps,
|
8650 | dynamicChildren: null,
|
8651 | appContext: null,
|
8652 | ctx: currentRenderingInstance
|
8653 | };
|
8654 | if (needFullChildrenNormalization) {
|
8655 | normalizeChildren(vnode, children);
|
8656 | if (shapeFlag & 128) {
|
8657 | type.normalize(vnode);
|
8658 | }
|
8659 | } else if (children) {
|
8660 | vnode.shapeFlag |= isString(children) ? 8 : 16;
|
8661 | }
|
8662 | if (vnode.key !== vnode.key) {
|
8663 | warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
8664 | }
|
8665 | if (isBlockTreeEnabled > 0 &&
|
8666 | !isBlockNode &&
|
8667 | currentBlock &&
|
8668 |
|
8669 |
|
8670 |
|
8671 | (vnode.patchFlag > 0 || shapeFlag & 6) &&
|
8672 |
|
8673 | vnode.patchFlag !== 32) {
|
8674 | currentBlock.push(vnode);
|
8675 | }
|
8676 | return vnode;
|
8677 | }
|
8678 | const createVNode = createVNodeWithArgsTransform ;
|
8679 | function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
8680 | if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
8681 | if (!type) {
|
8682 | warn$1(`Invalid vnode type when creating vnode: ${type}.`);
|
8683 | }
|
8684 | type = Comment;
|
8685 | }
|
8686 | if (isVNode(type)) {
|
8687 | const cloned = cloneVNode(
|
8688 | type,
|
8689 | props,
|
8690 | true
|
8691 |
|
8692 | );
|
8693 | if (children) {
|
8694 | normalizeChildren(cloned, children);
|
8695 | }
|
8696 | if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
|
8697 | if (cloned.shapeFlag & 6) {
|
8698 | currentBlock[currentBlock.indexOf(type)] = cloned;
|
8699 | } else {
|
8700 | currentBlock.push(cloned);
|
8701 | }
|
8702 | }
|
8703 | cloned.patchFlag |= -2;
|
8704 | return cloned;
|
8705 | }
|
8706 | if (isClassComponent(type)) {
|
8707 | type = type.__vccOpts;
|
8708 | }
|
8709 | if (props) {
|
8710 | props = guardReactiveProps(props);
|
8711 | let { class: klass, style } = props;
|
8712 | if (klass && !isString(klass)) {
|
8713 | props.class = normalizeClass(klass);
|
8714 | }
|
8715 | if (isObject(style)) {
|
8716 | if (isProxy(style) && !isArray(style)) {
|
8717 | style = extend({}, style);
|
8718 | }
|
8719 | props.style = normalizeStyle(style);
|
8720 | }
|
8721 | }
|
8722 | const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
|
8723 | if (shapeFlag & 4 && isProxy(type)) {
|
8724 | type = toRaw(type);
|
8725 | warn$1(
|
8726 | `Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
|
8727 | `
|
8728 | Component that was made reactive: `,
|
8729 | type
|
8730 | );
|
8731 | }
|
8732 | return createBaseVNode(
|
8733 | type,
|
8734 | props,
|
8735 | children,
|
8736 | patchFlag,
|
8737 | dynamicProps,
|
8738 | shapeFlag,
|
8739 | isBlockNode,
|
8740 | true
|
8741 | );
|
8742 | }
|
8743 | function guardReactiveProps(props) {
|
8744 | if (!props)
|
8745 | return null;
|
8746 | return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props;
|
8747 | }
|
8748 | function cloneVNode(vnode, extraProps, mergeRef = false) {
|
8749 | const { props, ref, patchFlag, children } = vnode;
|
8750 | const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
|
8751 | const cloned = {
|
8752 | __v_isVNode: true,
|
8753 | __v_skip: true,
|
8754 | type: vnode.type,
|
8755 | props: mergedProps,
|
8756 | key: mergedProps && normalizeKey(mergedProps),
|
8757 | ref: extraProps && extraProps.ref ? (
|
8758 |
|
8759 |
|
8760 |
|
8761 | mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
|
8762 | ) : ref,
|
8763 | scopeId: vnode.scopeId,
|
8764 | slotScopeIds: vnode.slotScopeIds,
|
8765 | children: patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
|
8766 | target: vnode.target,
|
8767 | targetAnchor: vnode.targetAnchor,
|
8768 | staticCount: vnode.staticCount,
|
8769 | shapeFlag: vnode.shapeFlag,
|
8770 |
|
8771 |
|
8772 |
|
8773 |
|
8774 | patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
|
8775 | dynamicProps: vnode.dynamicProps,
|
8776 | dynamicChildren: vnode.dynamicChildren,
|
8777 | appContext: vnode.appContext,
|
8778 | dirs: vnode.dirs,
|
8779 | transition: vnode.transition,
|
8780 |
|
8781 |
|
8782 |
|
8783 |
|
8784 | component: vnode.component,
|
8785 | suspense: vnode.suspense,
|
8786 | ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
8787 | ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
8788 | el: vnode.el,
|
8789 | anchor: vnode.anchor,
|
8790 | ctx: vnode.ctx,
|
8791 | ce: vnode.ce
|
8792 | };
|
8793 | return cloned;
|
8794 | }
|
8795 | function deepCloneVNode(vnode) {
|
8796 | const cloned = cloneVNode(vnode);
|
8797 | if (isArray(vnode.children)) {
|
8798 | cloned.children = vnode.children.map(deepCloneVNode);
|
8799 | }
|
8800 | return cloned;
|
8801 | }
|
8802 | function createTextVNode(text = " ", flag = 0) {
|
8803 | return createVNode(Text, null, text, flag);
|
8804 | }
|
8805 | function createStaticVNode(content, numberOfNodes) {
|
8806 | const vnode = createVNode(Static, null, content);
|
8807 | vnode.staticCount = numberOfNodes;
|
8808 | return vnode;
|
8809 | }
|
8810 | function createCommentVNode(text = "", asBlock = false) {
|
8811 | return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
|
8812 | }
|
8813 | function normalizeVNode(child) {
|
8814 | if (child == null || typeof child === "boolean") {
|
8815 | return createVNode(Comment);
|
8816 | } else if (isArray(child)) {
|
8817 | return createVNode(
|
8818 | Fragment,
|
8819 | null,
|
8820 |
|
8821 | child.slice()
|
8822 | );
|
8823 | } else if (typeof child === "object") {
|
8824 | return cloneIfMounted(child);
|
8825 | } else {
|
8826 | return createVNode(Text, null, String(child));
|
8827 | }
|
8828 | }
|
8829 | function cloneIfMounted(child) {
|
8830 | return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
|
8831 | }
|
8832 | function normalizeChildren(vnode, children) {
|
8833 | let type = 0;
|
8834 | const { shapeFlag } = vnode;
|
8835 | if (children == null) {
|
8836 | children = null;
|
8837 | } else if (isArray(children)) {
|
8838 | type = 16;
|
8839 | } else if (typeof children === "object") {
|
8840 | if (shapeFlag & (1 | 64)) {
|
8841 | const slot = children.default;
|
8842 | if (slot) {
|
8843 | slot._c && (slot._d = false);
|
8844 | normalizeChildren(vnode, slot());
|
8845 | slot._c && (slot._d = true);
|
8846 | }
|
8847 | return;
|
8848 | } else {
|
8849 | type = 32;
|
8850 | const slotFlag = children._;
|
8851 | if (!slotFlag && !(InternalObjectKey in children)) {
|
8852 | children._ctx = currentRenderingInstance;
|
8853 | } else if (slotFlag === 3 && currentRenderingInstance) {
|
8854 | if (currentRenderingInstance.slots._ === 1) {
|
8855 | children._ = 1;
|
8856 | } else {
|
8857 | children._ = 2;
|
8858 | vnode.patchFlag |= 1024;
|
8859 | }
|
8860 | }
|
8861 | }
|
8862 | } else if (isFunction(children)) {
|
8863 | children = { default: children, _ctx: currentRenderingInstance };
|
8864 | type = 32;
|
8865 | } else {
|
8866 | children = String(children);
|
8867 | if (shapeFlag & 64) {
|
8868 | type = 16;
|
8869 | children = [createTextVNode(children)];
|
8870 | } else {
|
8871 | type = 8;
|
8872 | }
|
8873 | }
|
8874 | vnode.children = children;
|
8875 | vnode.shapeFlag |= type;
|
8876 | }
|
8877 | function mergeProps(...args) {
|
8878 | const ret = {};
|
8879 | for (let i = 0; i < args.length; i++) {
|
8880 | const toMerge = args[i];
|
8881 | for (const key in toMerge) {
|
8882 | if (key === "class") {
|
8883 | if (ret.class !== toMerge.class) {
|
8884 | ret.class = normalizeClass([ret.class, toMerge.class]);
|
8885 | }
|
8886 | } else if (key === "style") {
|
8887 | ret.style = normalizeStyle([ret.style, toMerge.style]);
|
8888 | } else if (isOn(key)) {
|
8889 | const existing = ret[key];
|
8890 | const incoming = toMerge[key];
|
8891 | if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
|
8892 | ret[key] = existing ? [].concat(existing, incoming) : incoming;
|
8893 | }
|
8894 | } else if (key !== "") {
|
8895 | ret[key] = toMerge[key];
|
8896 | }
|
8897 | }
|
8898 | }
|
8899 | return ret;
|
8900 | }
|
8901 | function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
8902 | callWithAsyncErrorHandling(hook, instance, 7, [
|
8903 | vnode,
|
8904 | prevVNode
|
8905 | ]);
|
8906 | }
|
8907 |
|
8908 | const emptyAppContext = createAppContext();
|
8909 | let uid = 0;
|
8910 | function createComponentInstance(vnode, parent, suspense) {
|
8911 | const type = vnode.type;
|
8912 | const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
8913 | const instance = {
|
8914 | uid: uid++,
|
8915 | vnode,
|
8916 | type,
|
8917 | parent,
|
8918 | appContext,
|
8919 | root: null,
|
8920 |
|
8921 | next: null,
|
8922 | subTree: null,
|
8923 |
|
8924 | effect: null,
|
8925 | update: null,
|
8926 |
|
8927 | scope: new EffectScope(
|
8928 | true
|
8929 |
|
8930 | ),
|
8931 | render: null,
|
8932 | proxy: null,
|
8933 | exposed: null,
|
8934 | exposeProxy: null,
|
8935 | withProxy: null,
|
8936 | provides: parent ? parent.provides : Object.create(appContext.provides),
|
8937 | accessCache: null,
|
8938 | renderCache: [],
|
8939 |
|
8940 | components: null,
|
8941 | directives: null,
|
8942 |
|
8943 | propsOptions: normalizePropsOptions(type, appContext),
|
8944 | emitsOptions: normalizeEmitsOptions(type, appContext),
|
8945 |
|
8946 | emit: null,
|
8947 |
|
8948 | emitted: null,
|
8949 |
|
8950 | propsDefaults: EMPTY_OBJ,
|
8951 |
|
8952 | inheritAttrs: type.inheritAttrs,
|
8953 |
|
8954 | ctx: EMPTY_OBJ,
|
8955 | data: EMPTY_OBJ,
|
8956 | props: EMPTY_OBJ,
|
8957 | attrs: EMPTY_OBJ,
|
8958 | slots: EMPTY_OBJ,
|
8959 | refs: EMPTY_OBJ,
|
8960 | setupState: EMPTY_OBJ,
|
8961 | setupContext: null,
|
8962 | attrsProxy: null,
|
8963 | slotsProxy: null,
|
8964 |
|
8965 | suspense,
|
8966 | suspenseId: suspense ? suspense.pendingId : 0,
|
8967 | asyncDep: null,
|
8968 | asyncResolved: false,
|
8969 |
|
8970 |
|
8971 | isMounted: false,
|
8972 | isUnmounted: false,
|
8973 | isDeactivated: false,
|
8974 | bc: null,
|
8975 | c: null,
|
8976 | bm: null,
|
8977 | m: null,
|
8978 | bu: null,
|
8979 | u: null,
|
8980 | um: null,
|
8981 | bum: null,
|
8982 | da: null,
|
8983 | a: null,
|
8984 | rtg: null,
|
8985 | rtc: null,
|
8986 | ec: null,
|
8987 | sp: null
|
8988 | };
|
8989 | {
|
8990 | instance.ctx = createDevRenderContext(instance);
|
8991 | }
|
8992 | instance.root = parent ? parent.root : instance;
|
8993 | instance.emit = emit.bind(null, instance);
|
8994 | if (vnode.ce) {
|
8995 | vnode.ce(instance);
|
8996 | }
|
8997 | return instance;
|
8998 | }
|
8999 | let currentInstance = null;
|
9000 | const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
9001 | let internalSetCurrentInstance;
|
9002 | let setInSSRSetupState;
|
9003 | {
|
9004 | internalSetCurrentInstance = (i) => {
|
9005 | currentInstance = i;
|
9006 | };
|
9007 | setInSSRSetupState = (v) => {
|
9008 | isInSSRComponentSetup = v;
|
9009 | };
|
9010 | }
|
9011 | const setCurrentInstance = (instance) => {
|
9012 | const prev = currentInstance;
|
9013 | internalSetCurrentInstance(instance);
|
9014 | instance.scope.on();
|
9015 | return () => {
|
9016 | instance.scope.off();
|
9017 | internalSetCurrentInstance(prev);
|
9018 | };
|
9019 | };
|
9020 | const unsetCurrentInstance = () => {
|
9021 | currentInstance && currentInstance.scope.off();
|
9022 | internalSetCurrentInstance(null);
|
9023 | };
|
9024 | const isBuiltInTag = makeMap("slot,component");
|
9025 | function validateComponentName(name, config) {
|
9026 | const appIsNativeTag = config.isNativeTag || NO;
|
9027 | if (isBuiltInTag(name) || appIsNativeTag(name)) {
|
9028 | warn$1(
|
9029 | "Do not use built-in or reserved HTML elements as component id: " + name
|
9030 | );
|
9031 | }
|
9032 | }
|
9033 | function isStatefulComponent(instance) {
|
9034 | return instance.vnode.shapeFlag & 4;
|
9035 | }
|
9036 | let isInSSRComponentSetup = false;
|
9037 | function setupComponent(instance, isSSR = false) {
|
9038 | isSSR && setInSSRSetupState(isSSR);
|
9039 | const { props, children } = instance.vnode;
|
9040 | const isStateful = isStatefulComponent(instance);
|
9041 | initProps(instance, props, isStateful, isSSR);
|
9042 | initSlots(instance, children);
|
9043 | const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
|
9044 | isSSR && setInSSRSetupState(false);
|
9045 | return setupResult;
|
9046 | }
|
9047 | function setupStatefulComponent(instance, isSSR) {
|
9048 | var _a;
|
9049 | const Component = instance.type;
|
9050 | {
|
9051 | if (Component.name) {
|
9052 | validateComponentName(Component.name, instance.appContext.config);
|
9053 | }
|
9054 | if (Component.components) {
|
9055 | const names = Object.keys(Component.components);
|
9056 | for (let i = 0; i < names.length; i++) {
|
9057 | validateComponentName(names[i], instance.appContext.config);
|
9058 | }
|
9059 | }
|
9060 | if (Component.directives) {
|
9061 | const names = Object.keys(Component.directives);
|
9062 | for (let i = 0; i < names.length; i++) {
|
9063 | validateDirectiveName(names[i]);
|
9064 | }
|
9065 | }
|
9066 | if (Component.compilerOptions && isRuntimeOnly()) {
|
9067 | warn$1(
|
9068 | `"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`
|
9069 | );
|
9070 | }
|
9071 | }
|
9072 | instance.accessCache = Object.create(null);
|
9073 | instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
|
9074 | {
|
9075 | exposePropsOnRenderContext(instance);
|
9076 | }
|
9077 | const { setup } = Component;
|
9078 | if (setup) {
|
9079 | const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
|
9080 | const reset = setCurrentInstance(instance);
|
9081 | pauseTracking();
|
9082 | const setupResult = callWithErrorHandling(
|
9083 | setup,
|
9084 | instance,
|
9085 | 0,
|
9086 | [
|
9087 | shallowReadonly(instance.props) ,
|
9088 | setupContext
|
9089 | ]
|
9090 | );
|
9091 | resetTracking();
|
9092 | reset();
|
9093 | if (isPromise(setupResult)) {
|
9094 | setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
|
9095 | if (isSSR) {
|
9096 | return setupResult.then((resolvedResult) => {
|
9097 | handleSetupResult(instance, resolvedResult, isSSR);
|
9098 | }).catch((e) => {
|
9099 | handleError(e, instance, 0);
|
9100 | });
|
9101 | } else {
|
9102 | instance.asyncDep = setupResult;
|
9103 | if (!instance.suspense) {
|
9104 | const name = (_a = Component.name) != null ? _a : "Anonymous";
|
9105 | warn$1(
|
9106 | `Component <${name}>: setup function returned a promise, but no <Suspense> boundary was found in the parent component tree. A component with async setup() must be nested in a <Suspense> in order to be rendered.`
|
9107 | );
|
9108 | }
|
9109 | }
|
9110 | } else {
|
9111 | handleSetupResult(instance, setupResult, isSSR);
|
9112 | }
|
9113 | } else {
|
9114 | finishComponentSetup(instance, isSSR);
|
9115 | }
|
9116 | }
|
9117 | function handleSetupResult(instance, setupResult, isSSR) {
|
9118 | if (isFunction(setupResult)) {
|
9119 | {
|
9120 | instance.render = setupResult;
|
9121 | }
|
9122 | } else if (isObject(setupResult)) {
|
9123 | if (isVNode(setupResult)) {
|
9124 | warn$1(
|
9125 | `setup() should not return VNodes directly - return a render function instead.`
|
9126 | );
|
9127 | }
|
9128 | {
|
9129 | instance.devtoolsRawSetupState = setupResult;
|
9130 | }
|
9131 | instance.setupState = proxyRefs(setupResult);
|
9132 | {
|
9133 | exposeSetupStateOnRenderContext(instance);
|
9134 | }
|
9135 | } else if (setupResult !== void 0) {
|
9136 | warn$1(
|
9137 | `setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`
|
9138 | );
|
9139 | }
|
9140 | finishComponentSetup(instance, isSSR);
|
9141 | }
|
9142 | let compile$1;
|
9143 | let installWithProxy;
|
9144 | function registerRuntimeCompiler(_compile) {
|
9145 | compile$1 = _compile;
|
9146 | installWithProxy = (i) => {
|
9147 | if (i.render._rc) {
|
9148 | i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
|
9149 | }
|
9150 | };
|
9151 | }
|
9152 | const isRuntimeOnly = () => !compile$1;
|
9153 | function finishComponentSetup(instance, isSSR, skipOptions) {
|
9154 | const Component = instance.type;
|
9155 | if (!instance.render) {
|
9156 | if (!isSSR && compile$1 && !Component.render) {
|
9157 | const template = Component.template || resolveMergedOptions(instance).template;
|
9158 | if (template) {
|
9159 | {
|
9160 | startMeasure(instance, `compile`);
|
9161 | }
|
9162 | const { isCustomElement, compilerOptions } = instance.appContext.config;
|
9163 | const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
9164 | const finalCompilerOptions = extend(
|
9165 | extend(
|
9166 | {
|
9167 | isCustomElement,
|
9168 | delimiters
|
9169 | },
|
9170 | compilerOptions
|
9171 | ),
|
9172 | componentCompilerOptions
|
9173 | );
|
9174 | Component.render = compile$1(template, finalCompilerOptions);
|
9175 | {
|
9176 | endMeasure(instance, `compile`);
|
9177 | }
|
9178 | }
|
9179 | }
|
9180 | instance.render = Component.render || NOOP;
|
9181 | if (installWithProxy) {
|
9182 | installWithProxy(instance);
|
9183 | }
|
9184 | }
|
9185 | {
|
9186 | const reset = setCurrentInstance(instance);
|
9187 | pauseTracking();
|
9188 | try {
|
9189 | applyOptions(instance);
|
9190 | } finally {
|
9191 | resetTracking();
|
9192 | reset();
|
9193 | }
|
9194 | }
|
9195 | if (!Component.render && instance.render === NOOP && !isSSR) {
|
9196 | if (!compile$1 && Component.template) {
|
9197 | warn$1(
|
9198 | `Component provided template option but runtime compilation is not supported in this build of Vue.` + (` Use "vue.global.js" instead.` )
|
9199 | );
|
9200 | } else {
|
9201 | warn$1(`Component is missing template or render function.`);
|
9202 | }
|
9203 | }
|
9204 | }
|
9205 | function getAttrsProxy(instance) {
|
9206 | return instance.attrsProxy || (instance.attrsProxy = new Proxy(
|
9207 | instance.attrs,
|
9208 | {
|
9209 | get(target, key) {
|
9210 | markAttrsAccessed();
|
9211 | track(instance, "get", "$attrs");
|
9212 | return target[key];
|
9213 | },
|
9214 | set() {
|
9215 | warn$1(`setupContext.attrs is readonly.`);
|
9216 | return false;
|
9217 | },
|
9218 | deleteProperty() {
|
9219 | warn$1(`setupContext.attrs is readonly.`);
|
9220 | return false;
|
9221 | }
|
9222 | }
|
9223 | ));
|
9224 | }
|
9225 | function getSlotsProxy(instance) {
|
9226 | return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
|
9227 | get(target, key) {
|
9228 | track(instance, "get", "$slots");
|
9229 | return target[key];
|
9230 | }
|
9231 | }));
|
9232 | }
|
9233 | function createSetupContext(instance) {
|
9234 | const expose = (exposed) => {
|
9235 | {
|
9236 | if (instance.exposed) {
|
9237 | warn$1(`expose() should be called only once per setup().`);
|
9238 | }
|
9239 | if (exposed != null) {
|
9240 | let exposedType = typeof exposed;
|
9241 | if (exposedType === "object") {
|
9242 | if (isArray(exposed)) {
|
9243 | exposedType = "array";
|
9244 | } else if (isRef(exposed)) {
|
9245 | exposedType = "ref";
|
9246 | }
|
9247 | }
|
9248 | if (exposedType !== "object") {
|
9249 | warn$1(
|
9250 | `expose() should be passed a plain object, received ${exposedType}.`
|
9251 | );
|
9252 | }
|
9253 | }
|
9254 | }
|
9255 | instance.exposed = exposed || {};
|
9256 | };
|
9257 | {
|
9258 | return Object.freeze({
|
9259 | get attrs() {
|
9260 | return getAttrsProxy(instance);
|
9261 | },
|
9262 | get slots() {
|
9263 | return getSlotsProxy(instance);
|
9264 | },
|
9265 | get emit() {
|
9266 | return (event, ...args) => instance.emit(event, ...args);
|
9267 | },
|
9268 | expose
|
9269 | });
|
9270 | }
|
9271 | }
|
9272 | function getExposeProxy(instance) {
|
9273 | if (instance.exposed) {
|
9274 | return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
9275 | get(target, key) {
|
9276 | if (key in target) {
|
9277 | return target[key];
|
9278 | } else if (key in publicPropertiesMap) {
|
9279 | return publicPropertiesMap[key](instance);
|
9280 | }
|
9281 | },
|
9282 | has(target, key) {
|
9283 | return key in target || key in publicPropertiesMap;
|
9284 | }
|
9285 | }));
|
9286 | }
|
9287 | }
|
9288 | const classifyRE = /(?:^|[-_])(\w)/g;
|
9289 | const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
9290 | function getComponentName(Component, includeInferred = true) {
|
9291 | return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
9292 | }
|
9293 | function formatComponentName(instance, Component, isRoot = false) {
|
9294 | let name = getComponentName(Component);
|
9295 | if (!name && Component.__file) {
|
9296 | const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
9297 | if (match) {
|
9298 | name = match[1];
|
9299 | }
|
9300 | }
|
9301 | if (!name && instance && instance.parent) {
|
9302 | const inferFromRegistry = (registry) => {
|
9303 | for (const key in registry) {
|
9304 | if (registry[key] === Component) {
|
9305 | return key;
|
9306 | }
|
9307 | }
|
9308 | };
|
9309 | name = inferFromRegistry(
|
9310 | instance.components || instance.parent.type.components
|
9311 | ) || inferFromRegistry(instance.appContext.components);
|
9312 | }
|
9313 | return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
9314 | }
|
9315 | function isClassComponent(value) {
|
9316 | return isFunction(value) && "__vccOpts" in value;
|
9317 | }
|
9318 |
|
9319 | const computed = (getterOrOptions, debugOptions) => {
|
9320 | return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
|
9321 | };
|
9322 |
|
9323 | function useModel(props, name, options = EMPTY_OBJ) {
|
9324 | const i = getCurrentInstance();
|
9325 | if (!i) {
|
9326 | warn$1(`useModel() called without active instance.`);
|
9327 | return ref();
|
9328 | }
|
9329 | if (!i.propsOptions[0][name]) {
|
9330 | warn$1(`useModel() called with prop "${name}" which is not declared.`);
|
9331 | return ref();
|
9332 | }
|
9333 | const camelizedName = camelize(name);
|
9334 | const hyphenatedName = hyphenate(name);
|
9335 | const res = customRef((track, trigger) => {
|
9336 | let localValue;
|
9337 | watchSyncEffect(() => {
|
9338 | const propValue = props[name];
|
9339 | if (hasChanged(localValue, propValue)) {
|
9340 | localValue = propValue;
|
9341 | trigger();
|
9342 | }
|
9343 | });
|
9344 | return {
|
9345 | get() {
|
9346 | track();
|
9347 | return options.get ? options.get(localValue) : localValue;
|
9348 | },
|
9349 | set(value) {
|
9350 | const rawProps = i.vnode.props;
|
9351 | if (!(rawProps &&
|
9352 | (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
|
9353 | localValue = value;
|
9354 | trigger();
|
9355 | }
|
9356 | i.emit(`update:${name}`, options.set ? options.set(value) : value);
|
9357 | }
|
9358 | };
|
9359 | });
|
9360 | const modifierKey = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
|
9361 | res[Symbol.iterator] = () => {
|
9362 | let i2 = 0;
|
9363 | return {
|
9364 | next() {
|
9365 | if (i2 < 2) {
|
9366 | return { value: i2++ ? props[modifierKey] || {} : res, done: false };
|
9367 | } else {
|
9368 | return { done: true };
|
9369 | }
|
9370 | }
|
9371 | };
|
9372 | };
|
9373 | return res;
|
9374 | }
|
9375 |
|
9376 | function h(type, propsOrChildren, children) {
|
9377 | const l = arguments.length;
|
9378 | if (l === 2) {
|
9379 | if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
|
9380 | if (isVNode(propsOrChildren)) {
|
9381 | return createVNode(type, null, [propsOrChildren]);
|
9382 | }
|
9383 | return createVNode(type, propsOrChildren);
|
9384 | } else {
|
9385 | return createVNode(type, null, propsOrChildren);
|
9386 | }
|
9387 | } else {
|
9388 | if (l > 3) {
|
9389 | children = Array.prototype.slice.call(arguments, 2);
|
9390 | } else if (l === 3 && isVNode(children)) {
|
9391 | children = [children];
|
9392 | }
|
9393 | return createVNode(type, propsOrChildren, children);
|
9394 | }
|
9395 | }
|
9396 |
|
9397 | function initCustomFormatter() {
|
9398 | if (typeof window === "undefined") {
|
9399 | return;
|
9400 | }
|
9401 | const vueStyle = { style: "color:#3ba776" };
|
9402 | const numberStyle = { style: "color:#1677ff" };
|
9403 | const stringStyle = { style: "color:#f5222d" };
|
9404 | const keywordStyle = { style: "color:#eb2f96" };
|
9405 | const formatter = {
|
9406 | header(obj) {
|
9407 | if (!isObject(obj)) {
|
9408 | return null;
|
9409 | }
|
9410 | if (obj.__isVue) {
|
9411 | return ["div", vueStyle, `VueInstance`];
|
9412 | } else if (isRef(obj)) {
|
9413 | return [
|
9414 | "div",
|
9415 | {},
|
9416 | ["span", vueStyle, genRefFlag(obj)],
|
9417 | "<",
|
9418 | formatValue(obj.value),
|
9419 | `>`
|
9420 | ];
|
9421 | } else if (isReactive(obj)) {
|
9422 | return [
|
9423 | "div",
|
9424 | {},
|
9425 | ["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
|
9426 | "<",
|
9427 | formatValue(obj),
|
9428 | `>${isReadonly(obj) ? ` (readonly)` : ``}`
|
9429 | ];
|
9430 | } else if (isReadonly(obj)) {
|
9431 | return [
|
9432 | "div",
|
9433 | {},
|
9434 | ["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
|
9435 | "<",
|
9436 | formatValue(obj),
|
9437 | ">"
|
9438 | ];
|
9439 | }
|
9440 | return null;
|
9441 | },
|
9442 | hasBody(obj) {
|
9443 | return obj && obj.__isVue;
|
9444 | },
|
9445 | body(obj) {
|
9446 | if (obj && obj.__isVue) {
|
9447 | return [
|
9448 | "div",
|
9449 | {},
|
9450 | ...formatInstance(obj.$)
|
9451 | ];
|
9452 | }
|
9453 | }
|
9454 | };
|
9455 | function formatInstance(instance) {
|
9456 | const blocks = [];
|
9457 | if (instance.type.props && instance.props) {
|
9458 | blocks.push(createInstanceBlock("props", toRaw(instance.props)));
|
9459 | }
|
9460 | if (instance.setupState !== EMPTY_OBJ) {
|
9461 | blocks.push(createInstanceBlock("setup", instance.setupState));
|
9462 | }
|
9463 | if (instance.data !== EMPTY_OBJ) {
|
9464 | blocks.push(createInstanceBlock("data", toRaw(instance.data)));
|
9465 | }
|
9466 | const computed = extractKeys(instance, "computed");
|
9467 | if (computed) {
|
9468 | blocks.push(createInstanceBlock("computed", computed));
|
9469 | }
|
9470 | const injected = extractKeys(instance, "inject");
|
9471 | if (injected) {
|
9472 | blocks.push(createInstanceBlock("injected", injected));
|
9473 | }
|
9474 | blocks.push([
|
9475 | "div",
|
9476 | {},
|
9477 | [
|
9478 | "span",
|
9479 | {
|
9480 | style: keywordStyle.style + ";opacity:0.66"
|
9481 | },
|
9482 | "$ (internal): "
|
9483 | ],
|
9484 | ["object", { object: instance }]
|
9485 | ]);
|
9486 | return blocks;
|
9487 | }
|
9488 | function createInstanceBlock(type, target) {
|
9489 | target = extend({}, target);
|
9490 | if (!Object.keys(target).length) {
|
9491 | return ["span", {}];
|
9492 | }
|
9493 | return [
|
9494 | "div",
|
9495 | { style: "line-height:1.25em;margin-bottom:0.6em" },
|
9496 | [
|
9497 | "div",
|
9498 | {
|
9499 | style: "color:#476582"
|
9500 | },
|
9501 | type
|
9502 | ],
|
9503 | [
|
9504 | "div",
|
9505 | {
|
9506 | style: "padding-left:1.25em"
|
9507 | },
|
9508 | ...Object.keys(target).map((key) => {
|
9509 | return [
|
9510 | "div",
|
9511 | {},
|
9512 | ["span", keywordStyle, key + ": "],
|
9513 | formatValue(target[key], false)
|
9514 | ];
|
9515 | })
|
9516 | ]
|
9517 | ];
|
9518 | }
|
9519 | function formatValue(v, asRaw = true) {
|
9520 | if (typeof v === "number") {
|
9521 | return ["span", numberStyle, v];
|
9522 | } else if (typeof v === "string") {
|
9523 | return ["span", stringStyle, JSON.stringify(v)];
|
9524 | } else if (typeof v === "boolean") {
|
9525 | return ["span", keywordStyle, v];
|
9526 | } else if (isObject(v)) {
|
9527 | return ["object", { object: asRaw ? toRaw(v) : v }];
|
9528 | } else {
|
9529 | return ["span", stringStyle, String(v)];
|
9530 | }
|
9531 | }
|
9532 | function extractKeys(instance, type) {
|
9533 | const Comp = instance.type;
|
9534 | if (isFunction(Comp)) {
|
9535 | return;
|
9536 | }
|
9537 | const extracted = {};
|
9538 | for (const key in instance.ctx) {
|
9539 | if (isKeyOfType(Comp, key, type)) {
|
9540 | extracted[key] = instance.ctx[key];
|
9541 | }
|
9542 | }
|
9543 | return extracted;
|
9544 | }
|
9545 | function isKeyOfType(Comp, key, type) {
|
9546 | const opts = Comp[type];
|
9547 | if (isArray(opts) && opts.includes(key) || isObject(opts) && key in opts) {
|
9548 | return true;
|
9549 | }
|
9550 | if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
|
9551 | return true;
|
9552 | }
|
9553 | if (Comp.mixins && Comp.mixins.some((m) => isKeyOfType(m, key, type))) {
|
9554 | return true;
|
9555 | }
|
9556 | }
|
9557 | function genRefFlag(v) {
|
9558 | if (isShallow(v)) {
|
9559 | return `ShallowRef`;
|
9560 | }
|
9561 | if (v.effect) {
|
9562 | return `ComputedRef`;
|
9563 | }
|
9564 | return `Ref`;
|
9565 | }
|
9566 | if (window.devtoolsFormatters) {
|
9567 | window.devtoolsFormatters.push(formatter);
|
9568 | } else {
|
9569 | window.devtoolsFormatters = [formatter];
|
9570 | }
|
9571 | }
|
9572 |
|
9573 | function withMemo(memo, render, cache, index) {
|
9574 | const cached = cache[index];
|
9575 | if (cached && isMemoSame(cached, memo)) {
|
9576 | return cached;
|
9577 | }
|
9578 | const ret = render();
|
9579 | ret.memo = memo.slice();
|
9580 | return cache[index] = ret;
|
9581 | }
|
9582 | function isMemoSame(cached, memo) {
|
9583 | const prev = cached.memo;
|
9584 | if (prev.length != memo.length) {
|
9585 | return false;
|
9586 | }
|
9587 | for (let i = 0; i < prev.length; i++) {
|
9588 | if (hasChanged(prev[i], memo[i])) {
|
9589 | return false;
|
9590 | }
|
9591 | }
|
9592 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
9593 | currentBlock.push(cached);
|
9594 | }
|
9595 | return true;
|
9596 | }
|
9597 |
|
9598 | const version = "3.4.19";
|
9599 | const warn = warn$1 ;
|
9600 | const ErrorTypeStrings = ErrorTypeStrings$1 ;
|
9601 | const devtools = devtools$1 ;
|
9602 | const setDevtoolsHook = setDevtoolsHook$1 ;
|
9603 | const ssrUtils = null;
|
9604 | const resolveFilter = null;
|
9605 | const compatUtils = null;
|
9606 | const DeprecationTypes = null;
|
9607 |
|
9608 | const svgNS = "http://www.w3.org/2000/svg";
|
9609 | const mathmlNS = "http://www.w3.org/1998/Math/MathML";
|
9610 | const doc = typeof document !== "undefined" ? document : null;
|
9611 | const templateContainer = doc && doc.createElement("template");
|
9612 | const nodeOps = {
|
9613 | insert: (child, parent, anchor) => {
|
9614 | parent.insertBefore(child, anchor || null);
|
9615 | },
|
9616 | remove: (child) => {
|
9617 | const parent = child.parentNode;
|
9618 | if (parent) {
|
9619 | parent.removeChild(child);
|
9620 | }
|
9621 | },
|
9622 | createElement: (tag, namespace, is, props) => {
|
9623 | const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0);
|
9624 | if (tag === "select" && props && props.multiple != null) {
|
9625 | el.setAttribute("multiple", props.multiple);
|
9626 | }
|
9627 | return el;
|
9628 | },
|
9629 | createText: (text) => doc.createTextNode(text),
|
9630 | createComment: (text) => doc.createComment(text),
|
9631 | setText: (node, text) => {
|
9632 | node.nodeValue = text;
|
9633 | },
|
9634 | setElementText: (el, text) => {
|
9635 | el.textContent = text;
|
9636 | },
|
9637 | parentNode: (node) => node.parentNode,
|
9638 | nextSibling: (node) => node.nextSibling,
|
9639 | querySelector: (selector) => doc.querySelector(selector),
|
9640 | setScopeId(el, id) {
|
9641 | el.setAttribute(id, "");
|
9642 | },
|
9643 |
|
9644 |
|
9645 |
|
9646 |
|
9647 | insertStaticContent(content, parent, anchor, namespace, start, end) {
|
9648 | const before = anchor ? anchor.previousSibling : parent.lastChild;
|
9649 | if (start && (start === end || start.nextSibling)) {
|
9650 | while (true) {
|
9651 | parent.insertBefore(start.cloneNode(true), anchor);
|
9652 | if (start === end || !(start = start.nextSibling))
|
9653 | break;
|
9654 | }
|
9655 | } else {
|
9656 | templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content;
|
9657 | const template = templateContainer.content;
|
9658 | if (namespace === "svg" || namespace === "mathml") {
|
9659 | const wrapper = template.firstChild;
|
9660 | while (wrapper.firstChild) {
|
9661 | template.appendChild(wrapper.firstChild);
|
9662 | }
|
9663 | template.removeChild(wrapper);
|
9664 | }
|
9665 | parent.insertBefore(template, anchor);
|
9666 | }
|
9667 | return [
|
9668 |
|
9669 | before ? before.nextSibling : parent.firstChild,
|
9670 |
|
9671 | anchor ? anchor.previousSibling : parent.lastChild
|
9672 | ];
|
9673 | }
|
9674 | };
|
9675 |
|
9676 | const TRANSITION$1 = "transition";
|
9677 | const ANIMATION = "animation";
|
9678 | const vtcKey = Symbol("_vtc");
|
9679 | const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
|
9680 | Transition.displayName = "Transition";
|
9681 | const DOMTransitionPropsValidators = {
|
9682 | name: String,
|
9683 | type: String,
|
9684 | css: {
|
9685 | type: Boolean,
|
9686 | default: true
|
9687 | },
|
9688 | duration: [String, Number, Object],
|
9689 | enterFromClass: String,
|
9690 | enterActiveClass: String,
|
9691 | enterToClass: String,
|
9692 | appearFromClass: String,
|
9693 | appearActiveClass: String,
|
9694 | appearToClass: String,
|
9695 | leaveFromClass: String,
|
9696 | leaveActiveClass: String,
|
9697 | leaveToClass: String
|
9698 | };
|
9699 | const TransitionPropsValidators = Transition.props = extend(
|
9700 | {},
|
9701 | BaseTransitionPropsValidators,
|
9702 | DOMTransitionPropsValidators
|
9703 | );
|
9704 | const callHook = (hook, args = []) => {
|
9705 | if (isArray(hook)) {
|
9706 | hook.forEach((h2) => h2(...args));
|
9707 | } else if (hook) {
|
9708 | hook(...args);
|
9709 | }
|
9710 | };
|
9711 | const hasExplicitCallback = (hook) => {
|
9712 | return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
|
9713 | };
|
9714 | function resolveTransitionProps(rawProps) {
|
9715 | const baseProps = {};
|
9716 | for (const key in rawProps) {
|
9717 | if (!(key in DOMTransitionPropsValidators)) {
|
9718 | baseProps[key] = rawProps[key];
|
9719 | }
|
9720 | }
|
9721 | if (rawProps.css === false) {
|
9722 | return baseProps;
|
9723 | }
|
9724 | const {
|
9725 | name = "v",
|
9726 | type,
|
9727 | duration,
|
9728 | enterFromClass = `${name}-enter-from`,
|
9729 | enterActiveClass = `${name}-enter-active`,
|
9730 | enterToClass = `${name}-enter-to`,
|
9731 | appearFromClass = enterFromClass,
|
9732 | appearActiveClass = enterActiveClass,
|
9733 | appearToClass = enterToClass,
|
9734 | leaveFromClass = `${name}-leave-from`,
|
9735 | leaveActiveClass = `${name}-leave-active`,
|
9736 | leaveToClass = `${name}-leave-to`
|
9737 | } = rawProps;
|
9738 | const durations = normalizeDuration(duration);
|
9739 | const enterDuration = durations && durations[0];
|
9740 | const leaveDuration = durations && durations[1];
|
9741 | const {
|
9742 | onBeforeEnter,
|
9743 | onEnter,
|
9744 | onEnterCancelled,
|
9745 | onLeave,
|
9746 | onLeaveCancelled,
|
9747 | onBeforeAppear = onBeforeEnter,
|
9748 | onAppear = onEnter,
|
9749 | onAppearCancelled = onEnterCancelled
|
9750 | } = baseProps;
|
9751 | const finishEnter = (el, isAppear, done) => {
|
9752 | removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
9753 | removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
|
9754 | done && done();
|
9755 | };
|
9756 | const finishLeave = (el, done) => {
|
9757 | el._isLeaving = false;
|
9758 | removeTransitionClass(el, leaveFromClass);
|
9759 | removeTransitionClass(el, leaveToClass);
|
9760 | removeTransitionClass(el, leaveActiveClass);
|
9761 | done && done();
|
9762 | };
|
9763 | const makeEnterHook = (isAppear) => {
|
9764 | return (el, done) => {
|
9765 | const hook = isAppear ? onAppear : onEnter;
|
9766 | const resolve = () => finishEnter(el, isAppear, done);
|
9767 | callHook(hook, [el, resolve]);
|
9768 | nextFrame(() => {
|
9769 | removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
|
9770 | addTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
9771 | if (!hasExplicitCallback(hook)) {
|
9772 | whenTransitionEnds(el, type, enterDuration, resolve);
|
9773 | }
|
9774 | });
|
9775 | };
|
9776 | };
|
9777 | return extend(baseProps, {
|
9778 | onBeforeEnter(el) {
|
9779 | callHook(onBeforeEnter, [el]);
|
9780 | addTransitionClass(el, enterFromClass);
|
9781 | addTransitionClass(el, enterActiveClass);
|
9782 | },
|
9783 | onBeforeAppear(el) {
|
9784 | callHook(onBeforeAppear, [el]);
|
9785 | addTransitionClass(el, appearFromClass);
|
9786 | addTransitionClass(el, appearActiveClass);
|
9787 | },
|
9788 | onEnter: makeEnterHook(false),
|
9789 | onAppear: makeEnterHook(true),
|
9790 | onLeave(el, done) {
|
9791 | el._isLeaving = true;
|
9792 | const resolve = () => finishLeave(el, done);
|
9793 | addTransitionClass(el, leaveFromClass);
|
9794 | forceReflow();
|
9795 | addTransitionClass(el, leaveActiveClass);
|
9796 | nextFrame(() => {
|
9797 | if (!el._isLeaving) {
|
9798 | return;
|
9799 | }
|
9800 | removeTransitionClass(el, leaveFromClass);
|
9801 | addTransitionClass(el, leaveToClass);
|
9802 | if (!hasExplicitCallback(onLeave)) {
|
9803 | whenTransitionEnds(el, type, leaveDuration, resolve);
|
9804 | }
|
9805 | });
|
9806 | callHook(onLeave, [el, resolve]);
|
9807 | },
|
9808 | onEnterCancelled(el) {
|
9809 | finishEnter(el, false);
|
9810 | callHook(onEnterCancelled, [el]);
|
9811 | },
|
9812 | onAppearCancelled(el) {
|
9813 | finishEnter(el, true);
|
9814 | callHook(onAppearCancelled, [el]);
|
9815 | },
|
9816 | onLeaveCancelled(el) {
|
9817 | finishLeave(el);
|
9818 | callHook(onLeaveCancelled, [el]);
|
9819 | }
|
9820 | });
|
9821 | }
|
9822 | function normalizeDuration(duration) {
|
9823 | if (duration == null) {
|
9824 | return null;
|
9825 | } else if (isObject(duration)) {
|
9826 | return [NumberOf(duration.enter), NumberOf(duration.leave)];
|
9827 | } else {
|
9828 | const n = NumberOf(duration);
|
9829 | return [n, n];
|
9830 | }
|
9831 | }
|
9832 | function NumberOf(val) {
|
9833 | const res = toNumber(val);
|
9834 | {
|
9835 | assertNumber(res, "<transition> explicit duration");
|
9836 | }
|
9837 | return res;
|
9838 | }
|
9839 | function addTransitionClass(el, cls) {
|
9840 | cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
|
9841 | (el[vtcKey] || (el[vtcKey] = new Set())).add(cls);
|
9842 | }
|
9843 | function removeTransitionClass(el, cls) {
|
9844 | cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
|
9845 | const _vtc = el[vtcKey];
|
9846 | if (_vtc) {
|
9847 | _vtc.delete(cls);
|
9848 | if (!_vtc.size) {
|
9849 | el[vtcKey] = void 0;
|
9850 | }
|
9851 | }
|
9852 | }
|
9853 | function nextFrame(cb) {
|
9854 | requestAnimationFrame(() => {
|
9855 | requestAnimationFrame(cb);
|
9856 | });
|
9857 | }
|
9858 | let endId = 0;
|
9859 | function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
|
9860 | const id = el._endId = ++endId;
|
9861 | const resolveIfNotStale = () => {
|
9862 | if (id === el._endId) {
|
9863 | resolve();
|
9864 | }
|
9865 | };
|
9866 | if (explicitTimeout) {
|
9867 | return setTimeout(resolveIfNotStale, explicitTimeout);
|
9868 | }
|
9869 | const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
|
9870 | if (!type) {
|
9871 | return resolve();
|
9872 | }
|
9873 | const endEvent = type + "end";
|
9874 | let ended = 0;
|
9875 | const end = () => {
|
9876 | el.removeEventListener(endEvent, onEnd);
|
9877 | resolveIfNotStale();
|
9878 | };
|
9879 | const onEnd = (e) => {
|
9880 | if (e.target === el && ++ended >= propCount) {
|
9881 | end();
|
9882 | }
|
9883 | };
|
9884 | setTimeout(() => {
|
9885 | if (ended < propCount) {
|
9886 | end();
|
9887 | }
|
9888 | }, timeout + 1);
|
9889 | el.addEventListener(endEvent, onEnd);
|
9890 | }
|
9891 | function getTransitionInfo(el, expectedType) {
|
9892 | const styles = window.getComputedStyle(el);
|
9893 | const getStyleProperties = (key) => (styles[key] || "").split(", ");
|
9894 | const transitionDelays = getStyleProperties(`${TRANSITION$1}Delay`);
|
9895 | const transitionDurations = getStyleProperties(`${TRANSITION$1}Duration`);
|
9896 | const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
|
9897 | const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
|
9898 | const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
|
9899 | const animationTimeout = getTimeout(animationDelays, animationDurations);
|
9900 | let type = null;
|
9901 | let timeout = 0;
|
9902 | let propCount = 0;
|
9903 | if (expectedType === TRANSITION$1) {
|
9904 | if (transitionTimeout > 0) {
|
9905 | type = TRANSITION$1;
|
9906 | timeout = transitionTimeout;
|
9907 | propCount = transitionDurations.length;
|
9908 | }
|
9909 | } else if (expectedType === ANIMATION) {
|
9910 | if (animationTimeout > 0) {
|
9911 | type = ANIMATION;
|
9912 | timeout = animationTimeout;
|
9913 | propCount = animationDurations.length;
|
9914 | }
|
9915 | } else {
|
9916 | timeout = Math.max(transitionTimeout, animationTimeout);
|
9917 | type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION$1 : ANIMATION : null;
|
9918 | propCount = type ? type === TRANSITION$1 ? transitionDurations.length : animationDurations.length : 0;
|
9919 | }
|
9920 | const hasTransform = type === TRANSITION$1 && /\b(transform|all)(,|$)/.test(
|
9921 | getStyleProperties(`${TRANSITION$1}Property`).toString()
|
9922 | );
|
9923 | return {
|
9924 | type,
|
9925 | timeout,
|
9926 | propCount,
|
9927 | hasTransform
|
9928 | };
|
9929 | }
|
9930 | function getTimeout(delays, durations) {
|
9931 | while (delays.length < durations.length) {
|
9932 | delays = delays.concat(delays);
|
9933 | }
|
9934 | return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
|
9935 | }
|
9936 | function toMs(s) {
|
9937 | if (s === "auto")
|
9938 | return 0;
|
9939 | return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
|
9940 | }
|
9941 | function forceReflow() {
|
9942 | return document.body.offsetHeight;
|
9943 | }
|
9944 |
|
9945 | function patchClass(el, value, isSVG) {
|
9946 | const transitionClasses = el[vtcKey];
|
9947 | if (transitionClasses) {
|
9948 | value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
|
9949 | }
|
9950 | if (value == null) {
|
9951 | el.removeAttribute("class");
|
9952 | } else if (isSVG) {
|
9953 | el.setAttribute("class", value);
|
9954 | } else {
|
9955 | el.className = value;
|
9956 | }
|
9957 | }
|
9958 |
|
9959 | const vShowOldKey = Symbol("_vod");
|
9960 | const vShow = {
|
9961 | beforeMount(el, { value }, { transition }) {
|
9962 | el[vShowOldKey] = el.style.display === "none" ? "" : el.style.display;
|
9963 | if (transition && value) {
|
9964 | transition.beforeEnter(el);
|
9965 | } else {
|
9966 | setDisplay(el, value);
|
9967 | }
|
9968 | },
|
9969 | mounted(el, { value }, { transition }) {
|
9970 | if (transition && value) {
|
9971 | transition.enter(el);
|
9972 | }
|
9973 | },
|
9974 | updated(el, { value, oldValue }, { transition }) {
|
9975 | if (!value === !oldValue && (el.style.display === el[vShowOldKey] || !value))
|
9976 | return;
|
9977 | if (transition) {
|
9978 | if (value) {
|
9979 | transition.beforeEnter(el);
|
9980 | setDisplay(el, true);
|
9981 | transition.enter(el);
|
9982 | } else {
|
9983 | transition.leave(el, () => {
|
9984 | setDisplay(el, false);
|
9985 | });
|
9986 | }
|
9987 | } else {
|
9988 | setDisplay(el, value);
|
9989 | }
|
9990 | },
|
9991 | beforeUnmount(el, { value }) {
|
9992 | setDisplay(el, value);
|
9993 | }
|
9994 | };
|
9995 | {
|
9996 | vShow.name = "show";
|
9997 | }
|
9998 | function setDisplay(el, value) {
|
9999 | el.style.display = value ? el[vShowOldKey] : "none";
|
10000 | }
|
10001 |
|
10002 | const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT" );
|
10003 | function useCssVars(getter) {
|
10004 | const instance = getCurrentInstance();
|
10005 | if (!instance) {
|
10006 | warn(`useCssVars is called without current active component instance.`);
|
10007 | return;
|
10008 | }
|
10009 | const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
|
10010 | Array.from(
|
10011 | document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
|
10012 | ).forEach((node) => setVarsOnNode(node, vars));
|
10013 | };
|
10014 | {
|
10015 | instance.getCssVars = () => getter(instance.proxy);
|
10016 | }
|
10017 | const setVars = () => {
|
10018 | const vars = getter(instance.proxy);
|
10019 | setVarsOnVNode(instance.subTree, vars);
|
10020 | updateTeleports(vars);
|
10021 | };
|
10022 | watchPostEffect(setVars);
|
10023 | onMounted(() => {
|
10024 | const ob = new MutationObserver(setVars);
|
10025 | ob.observe(instance.subTree.el.parentNode, { childList: true });
|
10026 | onUnmounted(() => ob.disconnect());
|
10027 | });
|
10028 | }
|
10029 | function setVarsOnVNode(vnode, vars) {
|
10030 | if (vnode.shapeFlag & 128) {
|
10031 | const suspense = vnode.suspense;
|
10032 | vnode = suspense.activeBranch;
|
10033 | if (suspense.pendingBranch && !suspense.isHydrating) {
|
10034 | suspense.effects.push(() => {
|
10035 | setVarsOnVNode(suspense.activeBranch, vars);
|
10036 | });
|
10037 | }
|
10038 | }
|
10039 | while (vnode.component) {
|
10040 | vnode = vnode.component.subTree;
|
10041 | }
|
10042 | if (vnode.shapeFlag & 1 && vnode.el) {
|
10043 | setVarsOnNode(vnode.el, vars);
|
10044 | } else if (vnode.type === Fragment) {
|
10045 | vnode.children.forEach((c) => setVarsOnVNode(c, vars));
|
10046 | } else if (vnode.type === Static) {
|
10047 | let { el, anchor } = vnode;
|
10048 | while (el) {
|
10049 | setVarsOnNode(el, vars);
|
10050 | if (el === anchor)
|
10051 | break;
|
10052 | el = el.nextSibling;
|
10053 | }
|
10054 | }
|
10055 | }
|
10056 | function setVarsOnNode(el, vars) {
|
10057 | if (el.nodeType === 1) {
|
10058 | const style = el.style;
|
10059 | let cssText = "";
|
10060 | for (const key in vars) {
|
10061 | style.setProperty(`--${key}`, vars[key]);
|
10062 | cssText += `--${key}: ${vars[key]};`;
|
10063 | }
|
10064 | style[CSS_VAR_TEXT] = cssText;
|
10065 | }
|
10066 | }
|
10067 |
|
10068 | const displayRE = /(^|;)\s*display\s*:/;
|
10069 | function patchStyle(el, prev, next) {
|
10070 | const style = el.style;
|
10071 | const isCssString = isString(next);
|
10072 | const currentDisplay = style.display;
|
10073 | let hasControlledDisplay = false;
|
10074 | if (next && !isCssString) {
|
10075 | if (prev && !isString(prev)) {
|
10076 | for (const key in prev) {
|
10077 | if (next[key] == null) {
|
10078 | setStyle(style, key, "");
|
10079 | }
|
10080 | }
|
10081 | }
|
10082 | for (const key in next) {
|
10083 | if (key === "display") {
|
10084 | hasControlledDisplay = true;
|
10085 | }
|
10086 | setStyle(style, key, next[key]);
|
10087 | }
|
10088 | } else {
|
10089 | if (isCssString) {
|
10090 | if (prev !== next) {
|
10091 | const cssVarText = style[CSS_VAR_TEXT];
|
10092 | if (cssVarText) {
|
10093 | next += ";" + cssVarText;
|
10094 | }
|
10095 | style.cssText = next;
|
10096 | hasControlledDisplay = displayRE.test(next);
|
10097 | }
|
10098 | } else if (prev) {
|
10099 | el.removeAttribute("style");
|
10100 | }
|
10101 | }
|
10102 | if (vShowOldKey in el) {
|
10103 | el[vShowOldKey] = hasControlledDisplay ? style.display : "";
|
10104 | style.display = currentDisplay;
|
10105 | }
|
10106 | }
|
10107 | const semicolonRE = /[^\\];\s*$/;
|
10108 | const importantRE = /\s*!important$/;
|
10109 | function setStyle(style, name, val) {
|
10110 | if (isArray(val)) {
|
10111 | val.forEach((v) => setStyle(style, name, v));
|
10112 | } else {
|
10113 | if (val == null)
|
10114 | val = "";
|
10115 | {
|
10116 | if (semicolonRE.test(val)) {
|
10117 | warn(
|
10118 | `Unexpected semicolon at the end of '${name}' style value: '${val}'`
|
10119 | );
|
10120 | }
|
10121 | }
|
10122 | if (name.startsWith("--")) {
|
10123 | style.setProperty(name, val);
|
10124 | } else {
|
10125 | const prefixed = autoPrefix(style, name);
|
10126 | if (importantRE.test(val)) {
|
10127 | style.setProperty(
|
10128 | hyphenate(prefixed),
|
10129 | val.replace(importantRE, ""),
|
10130 | "important"
|
10131 | );
|
10132 | } else {
|
10133 | style[prefixed] = val;
|
10134 | }
|
10135 | }
|
10136 | }
|
10137 | }
|
10138 | const prefixes = ["Webkit", "Moz", "ms"];
|
10139 | const prefixCache = {};
|
10140 | function autoPrefix(style, rawName) {
|
10141 | const cached = prefixCache[rawName];
|
10142 | if (cached) {
|
10143 | return cached;
|
10144 | }
|
10145 | let name = camelize(rawName);
|
10146 | if (name !== "filter" && name in style) {
|
10147 | return prefixCache[rawName] = name;
|
10148 | }
|
10149 | name = capitalize(name);
|
10150 | for (let i = 0; i < prefixes.length; i++) {
|
10151 | const prefixed = prefixes[i] + name;
|
10152 | if (prefixed in style) {
|
10153 | return prefixCache[rawName] = prefixed;
|
10154 | }
|
10155 | }
|
10156 | return rawName;
|
10157 | }
|
10158 |
|
10159 | const xlinkNS = "http://www.w3.org/1999/xlink";
|
10160 | function patchAttr(el, key, value, isSVG, instance) {
|
10161 | if (isSVG && key.startsWith("xlink:")) {
|
10162 | if (value == null) {
|
10163 | el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
10164 | } else {
|
10165 | el.setAttributeNS(xlinkNS, key, value);
|
10166 | }
|
10167 | } else {
|
10168 | const isBoolean = isSpecialBooleanAttr(key);
|
10169 | if (value == null || isBoolean && !includeBooleanAttr(value)) {
|
10170 | el.removeAttribute(key);
|
10171 | } else {
|
10172 | el.setAttribute(key, isBoolean ? "" : value);
|
10173 | }
|
10174 | }
|
10175 | }
|
10176 |
|
10177 | function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
|
10178 | if (key === "innerHTML" || key === "textContent") {
|
10179 | if (prevChildren) {
|
10180 | unmountChildren(prevChildren, parentComponent, parentSuspense);
|
10181 | }
|
10182 | el[key] = value == null ? "" : value;
|
10183 | return;
|
10184 | }
|
10185 | const tag = el.tagName;
|
10186 | if (key === "value" && tag !== "PROGRESS" &&
|
10187 | !tag.includes("-")) {
|
10188 | el._value = value;
|
10189 | const oldValue = tag === "OPTION" ? el.getAttribute("value") : el.value;
|
10190 | const newValue = value == null ? "" : value;
|
10191 | if (oldValue !== newValue) {
|
10192 | el.value = newValue;
|
10193 | }
|
10194 | if (value == null) {
|
10195 | el.removeAttribute(key);
|
10196 | }
|
10197 | return;
|
10198 | }
|
10199 | let needRemove = false;
|
10200 | if (value === "" || value == null) {
|
10201 | const type = typeof el[key];
|
10202 | if (type === "boolean") {
|
10203 | value = includeBooleanAttr(value);
|
10204 | } else if (value == null && type === "string") {
|
10205 | value = "";
|
10206 | needRemove = true;
|
10207 | } else if (type === "number") {
|
10208 | value = 0;
|
10209 | needRemove = true;
|
10210 | }
|
10211 | }
|
10212 | try {
|
10213 | el[key] = value;
|
10214 | } catch (e) {
|
10215 | if (!needRemove) {
|
10216 | warn(
|
10217 | `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
|
10218 | e
|
10219 | );
|
10220 | }
|
10221 | }
|
10222 | needRemove && el.removeAttribute(key);
|
10223 | }
|
10224 |
|
10225 | function addEventListener(el, event, handler, options) {
|
10226 | el.addEventListener(event, handler, options);
|
10227 | }
|
10228 | function removeEventListener(el, event, handler, options) {
|
10229 | el.removeEventListener(event, handler, options);
|
10230 | }
|
10231 | const veiKey = Symbol("_vei");
|
10232 | function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
10233 | const invokers = el[veiKey] || (el[veiKey] = {});
|
10234 | const existingInvoker = invokers[rawName];
|
10235 | if (nextValue && existingInvoker) {
|
10236 | existingInvoker.value = nextValue;
|
10237 | } else {
|
10238 | const [name, options] = parseName(rawName);
|
10239 | if (nextValue) {
|
10240 | const invoker = invokers[rawName] = createInvoker(nextValue, instance);
|
10241 | addEventListener(el, name, invoker, options);
|
10242 | } else if (existingInvoker) {
|
10243 | removeEventListener(el, name, existingInvoker, options);
|
10244 | invokers[rawName] = void 0;
|
10245 | }
|
10246 | }
|
10247 | }
|
10248 | const optionsModifierRE = /(?:Once|Passive|Capture)$/;
|
10249 | function parseName(name) {
|
10250 | let options;
|
10251 | if (optionsModifierRE.test(name)) {
|
10252 | options = {};
|
10253 | let m;
|
10254 | while (m = name.match(optionsModifierRE)) {
|
10255 | name = name.slice(0, name.length - m[0].length);
|
10256 | options[m[0].toLowerCase()] = true;
|
10257 | }
|
10258 | }
|
10259 | const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
|
10260 | return [event, options];
|
10261 | }
|
10262 | let cachedNow = 0;
|
10263 | const p = Promise.resolve();
|
10264 | const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
|
10265 | function createInvoker(initialValue, instance) {
|
10266 | const invoker = (e) => {
|
10267 | if (!e._vts) {
|
10268 | e._vts = Date.now();
|
10269 | } else if (e._vts <= invoker.attached) {
|
10270 | return;
|
10271 | }
|
10272 | callWithAsyncErrorHandling(
|
10273 | patchStopImmediatePropagation(e, invoker.value),
|
10274 | instance,
|
10275 | 5,
|
10276 | [e]
|
10277 | );
|
10278 | };
|
10279 | invoker.value = initialValue;
|
10280 | invoker.attached = getNow();
|
10281 | return invoker;
|
10282 | }
|
10283 | function patchStopImmediatePropagation(e, value) {
|
10284 | if (isArray(value)) {
|
10285 | const originalStop = e.stopImmediatePropagation;
|
10286 | e.stopImmediatePropagation = () => {
|
10287 | originalStop.call(e);
|
10288 | e._stopped = true;
|
10289 | };
|
10290 | return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2));
|
10291 | } else {
|
10292 | return value;
|
10293 | }
|
10294 | }
|
10295 |
|
10296 | const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 &&
|
10297 | key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
|
10298 | const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
|
10299 | const isSVG = namespace === "svg";
|
10300 | if (key === "class") {
|
10301 | patchClass(el, nextValue, isSVG);
|
10302 | } else if (key === "style") {
|
10303 | patchStyle(el, prevValue, nextValue);
|
10304 | } else if (isOn(key)) {
|
10305 | if (!isModelListener(key)) {
|
10306 | patchEvent(el, key, prevValue, nextValue, parentComponent);
|
10307 | }
|
10308 | } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
|
10309 | patchDOMProp(
|
10310 | el,
|
10311 | key,
|
10312 | nextValue,
|
10313 | prevChildren,
|
10314 | parentComponent,
|
10315 | parentSuspense,
|
10316 | unmountChildren
|
10317 | );
|
10318 | } else {
|
10319 | if (key === "true-value") {
|
10320 | el._trueValue = nextValue;
|
10321 | } else if (key === "false-value") {
|
10322 | el._falseValue = nextValue;
|
10323 | }
|
10324 | patchAttr(el, key, nextValue, isSVG);
|
10325 | }
|
10326 | };
|
10327 | function shouldSetAsProp(el, key, value, isSVG) {
|
10328 | if (isSVG) {
|
10329 | if (key === "innerHTML" || key === "textContent") {
|
10330 | return true;
|
10331 | }
|
10332 | if (key in el && isNativeOn(key) && isFunction(value)) {
|
10333 | return true;
|
10334 | }
|
10335 | return false;
|
10336 | }
|
10337 | if (key === "spellcheck" || key === "draggable" || key === "translate") {
|
10338 | return false;
|
10339 | }
|
10340 | if (key === "form") {
|
10341 | return false;
|
10342 | }
|
10343 | if (key === "list" && el.tagName === "INPUT") {
|
10344 | return false;
|
10345 | }
|
10346 | if (key === "type" && el.tagName === "TEXTAREA") {
|
10347 | return false;
|
10348 | }
|
10349 | if (key === "width" || key === "height") {
|
10350 | const tag = el.tagName;
|
10351 | if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
|
10352 | return false;
|
10353 | }
|
10354 | }
|
10355 | if (isNativeOn(key) && isString(value)) {
|
10356 | return false;
|
10357 | }
|
10358 | return key in el;
|
10359 | }
|
10360 |
|
10361 |
|
10362 |
|
10363 | function defineCustomElement(options, hydrate2) {
|
10364 | const Comp = defineComponent(options);
|
10365 | class VueCustomElement extends VueElement {
|
10366 | constructor(initialProps) {
|
10367 | super(Comp, initialProps, hydrate2);
|
10368 | }
|
10369 | }
|
10370 | VueCustomElement.def = Comp;
|
10371 | return VueCustomElement;
|
10372 | }
|
10373 |
|
10374 | const defineSSRCustomElement = (options) => {
|
10375 | return defineCustomElement(options, hydrate);
|
10376 | };
|
10377 | const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
|
10378 | };
|
10379 | class VueElement extends BaseClass {
|
10380 | constructor(_def, _props = {}, hydrate2) {
|
10381 | super();
|
10382 | this._def = _def;
|
10383 | this._props = _props;
|
10384 | |
10385 |
|
10386 |
|
10387 | this._instance = null;
|
10388 | this._connected = false;
|
10389 | this._resolved = false;
|
10390 | this._numberProps = null;
|
10391 | this._ob = null;
|
10392 | if (this.shadowRoot && hydrate2) {
|
10393 | hydrate2(this._createVNode(), this.shadowRoot);
|
10394 | } else {
|
10395 | if (this.shadowRoot) {
|
10396 | warn(
|
10397 | `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
|
10398 | );
|
10399 | }
|
10400 | this.attachShadow({ mode: "open" });
|
10401 | if (!this._def.__asyncLoader) {
|
10402 | this._resolveProps(this._def);
|
10403 | }
|
10404 | }
|
10405 | }
|
10406 | connectedCallback() {
|
10407 | this._connected = true;
|
10408 | if (!this._instance) {
|
10409 | if (this._resolved) {
|
10410 | this._update();
|
10411 | } else {
|
10412 | this._resolveDef();
|
10413 | }
|
10414 | }
|
10415 | }
|
10416 | disconnectedCallback() {
|
10417 | this._connected = false;
|
10418 | if (this._ob) {
|
10419 | this._ob.disconnect();
|
10420 | this._ob = null;
|
10421 | }
|
10422 | nextTick(() => {
|
10423 | if (!this._connected) {
|
10424 | render(null, this.shadowRoot);
|
10425 | this._instance = null;
|
10426 | }
|
10427 | });
|
10428 | }
|
10429 | |
10430 |
|
10431 |
|
10432 | _resolveDef() {
|
10433 | this._resolved = true;
|
10434 | for (let i = 0; i < this.attributes.length; i++) {
|
10435 | this._setAttr(this.attributes[i].name);
|
10436 | }
|
10437 | this._ob = new MutationObserver((mutations) => {
|
10438 | for (const m of mutations) {
|
10439 | this._setAttr(m.attributeName);
|
10440 | }
|
10441 | });
|
10442 | this._ob.observe(this, { attributes: true });
|
10443 | const resolve = (def, isAsync = false) => {
|
10444 | const { props, styles } = def;
|
10445 | let numberProps;
|
10446 | if (props && !isArray(props)) {
|
10447 | for (const key in props) {
|
10448 | const opt = props[key];
|
10449 | if (opt === Number || opt && opt.type === Number) {
|
10450 | if (key in this._props) {
|
10451 | this._props[key] = toNumber(this._props[key]);
|
10452 | }
|
10453 | (numberProps || (numberProps = Object.create(null)))[camelize(key)] = true;
|
10454 | }
|
10455 | }
|
10456 | }
|
10457 | this._numberProps = numberProps;
|
10458 | if (isAsync) {
|
10459 | this._resolveProps(def);
|
10460 | }
|
10461 | this._applyStyles(styles);
|
10462 | this._update();
|
10463 | };
|
10464 | const asyncDef = this._def.__asyncLoader;
|
10465 | if (asyncDef) {
|
10466 | asyncDef().then((def) => resolve(def, true));
|
10467 | } else {
|
10468 | resolve(this._def);
|
10469 | }
|
10470 | }
|
10471 | _resolveProps(def) {
|
10472 | const { props } = def;
|
10473 | const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
|
10474 | for (const key of Object.keys(this)) {
|
10475 | if (key[0] !== "_" && declaredPropKeys.includes(key)) {
|
10476 | this._setProp(key, this[key], true, false);
|
10477 | }
|
10478 | }
|
10479 | for (const key of declaredPropKeys.map(camelize)) {
|
10480 | Object.defineProperty(this, key, {
|
10481 | get() {
|
10482 | return this._getProp(key);
|
10483 | },
|
10484 | set(val) {
|
10485 | this._setProp(key, val);
|
10486 | }
|
10487 | });
|
10488 | }
|
10489 | }
|
10490 | _setAttr(key) {
|
10491 | let value = this.getAttribute(key);
|
10492 | const camelKey = camelize(key);
|
10493 | if (this._numberProps && this._numberProps[camelKey]) {
|
10494 | value = toNumber(value);
|
10495 | }
|
10496 | this._setProp(camelKey, value, false);
|
10497 | }
|
10498 | |
10499 |
|
10500 |
|
10501 | _getProp(key) {
|
10502 | return this._props[key];
|
10503 | }
|
10504 | |
10505 |
|
10506 |
|
10507 | _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
|
10508 | if (val !== this._props[key]) {
|
10509 | this._props[key] = val;
|
10510 | if (shouldUpdate && this._instance) {
|
10511 | this._update();
|
10512 | }
|
10513 | if (shouldReflect) {
|
10514 | if (val === true) {
|
10515 | this.setAttribute(hyphenate(key), "");
|
10516 | } else if (typeof val === "string" || typeof val === "number") {
|
10517 | this.setAttribute(hyphenate(key), val + "");
|
10518 | } else if (!val) {
|
10519 | this.removeAttribute(hyphenate(key));
|
10520 | }
|
10521 | }
|
10522 | }
|
10523 | }
|
10524 | _update() {
|
10525 | render(this._createVNode(), this.shadowRoot);
|
10526 | }
|
10527 | _createVNode() {
|
10528 | const vnode = createVNode(this._def, extend({}, this._props));
|
10529 | if (!this._instance) {
|
10530 | vnode.ce = (instance) => {
|
10531 | this._instance = instance;
|
10532 | instance.isCE = true;
|
10533 | {
|
10534 | instance.ceReload = (newStyles) => {
|
10535 | if (this._styles) {
|
10536 | this._styles.forEach((s) => this.shadowRoot.removeChild(s));
|
10537 | this._styles.length = 0;
|
10538 | }
|
10539 | this._applyStyles(newStyles);
|
10540 | this._instance = null;
|
10541 | this._update();
|
10542 | };
|
10543 | }
|
10544 | const dispatch = (event, args) => {
|
10545 | this.dispatchEvent(
|
10546 | new CustomEvent(event, {
|
10547 | detail: args
|
10548 | })
|
10549 | );
|
10550 | };
|
10551 | instance.emit = (event, ...args) => {
|
10552 | dispatch(event, args);
|
10553 | if (hyphenate(event) !== event) {
|
10554 | dispatch(hyphenate(event), args);
|
10555 | }
|
10556 | };
|
10557 | let parent = this;
|
10558 | while (parent = parent && (parent.parentNode || parent.host)) {
|
10559 | if (parent instanceof VueElement) {
|
10560 | instance.parent = parent._instance;
|
10561 | instance.provides = parent._instance.provides;
|
10562 | break;
|
10563 | }
|
10564 | }
|
10565 | };
|
10566 | }
|
10567 | return vnode;
|
10568 | }
|
10569 | _applyStyles(styles) {
|
10570 | if (styles) {
|
10571 | styles.forEach((css) => {
|
10572 | const s = document.createElement("style");
|
10573 | s.textContent = css;
|
10574 | this.shadowRoot.appendChild(s);
|
10575 | {
|
10576 | (this._styles || (this._styles = [])).push(s);
|
10577 | }
|
10578 | });
|
10579 | }
|
10580 | }
|
10581 | }
|
10582 |
|
10583 | function useCssModule(name = "$style") {
|
10584 | {
|
10585 | {
|
10586 | warn(`useCssModule() is not supported in the global build.`);
|
10587 | }
|
10588 | return EMPTY_OBJ;
|
10589 | }
|
10590 | }
|
10591 |
|
10592 | const positionMap = new WeakMap();
|
10593 | const newPositionMap = new WeakMap();
|
10594 | const moveCbKey = Symbol("_moveCb");
|
10595 | const enterCbKey = Symbol("_enterCb");
|
10596 | const TransitionGroupImpl = {
|
10597 | name: "TransitionGroup",
|
10598 | props: extend({}, TransitionPropsValidators, {
|
10599 | tag: String,
|
10600 | moveClass: String
|
10601 | }),
|
10602 | setup(props, { slots }) {
|
10603 | const instance = getCurrentInstance();
|
10604 | const state = useTransitionState();
|
10605 | let prevChildren;
|
10606 | let children;
|
10607 | onUpdated(() => {
|
10608 | if (!prevChildren.length) {
|
10609 | return;
|
10610 | }
|
10611 | const moveClass = props.moveClass || `${props.name || "v"}-move`;
|
10612 | if (!hasCSSTransform(
|
10613 | prevChildren[0].el,
|
10614 | instance.vnode.el,
|
10615 | moveClass
|
10616 | )) {
|
10617 | return;
|
10618 | }
|
10619 | prevChildren.forEach(callPendingCbs);
|
10620 | prevChildren.forEach(recordPosition);
|
10621 | const movedChildren = prevChildren.filter(applyTranslation);
|
10622 | forceReflow();
|
10623 | movedChildren.forEach((c) => {
|
10624 | const el = c.el;
|
10625 | const style = el.style;
|
10626 | addTransitionClass(el, moveClass);
|
10627 | style.transform = style.webkitTransform = style.transitionDuration = "";
|
10628 | const cb = el[moveCbKey] = (e) => {
|
10629 | if (e && e.target !== el) {
|
10630 | return;
|
10631 | }
|
10632 | if (!e || /transform$/.test(e.propertyName)) {
|
10633 | el.removeEventListener("transitionend", cb);
|
10634 | el[moveCbKey] = null;
|
10635 | removeTransitionClass(el, moveClass);
|
10636 | }
|
10637 | };
|
10638 | el.addEventListener("transitionend", cb);
|
10639 | });
|
10640 | });
|
10641 | return () => {
|
10642 | const rawProps = toRaw(props);
|
10643 | const cssTransitionProps = resolveTransitionProps(rawProps);
|
10644 | let tag = rawProps.tag || Fragment;
|
10645 | prevChildren = children;
|
10646 | children = slots.default ? getTransitionRawChildren(slots.default()) : [];
|
10647 | for (let i = 0; i < children.length; i++) {
|
10648 | const child = children[i];
|
10649 | if (child.key != null) {
|
10650 | setTransitionHooks(
|
10651 | child,
|
10652 | resolveTransitionHooks(child, cssTransitionProps, state, instance)
|
10653 | );
|
10654 | } else {
|
10655 | warn(`<TransitionGroup> children must be keyed.`);
|
10656 | }
|
10657 | }
|
10658 | if (prevChildren) {
|
10659 | for (let i = 0; i < prevChildren.length; i++) {
|
10660 | const child = prevChildren[i];
|
10661 | setTransitionHooks(
|
10662 | child,
|
10663 | resolveTransitionHooks(child, cssTransitionProps, state, instance)
|
10664 | );
|
10665 | positionMap.set(child, child.el.getBoundingClientRect());
|
10666 | }
|
10667 | }
|
10668 | return createVNode(tag, null, children);
|
10669 | };
|
10670 | }
|
10671 | };
|
10672 | const removeMode = (props) => delete props.mode;
|
10673 | removeMode(TransitionGroupImpl.props);
|
10674 | const TransitionGroup = TransitionGroupImpl;
|
10675 | function callPendingCbs(c) {
|
10676 | const el = c.el;
|
10677 | if (el[moveCbKey]) {
|
10678 | el[moveCbKey]();
|
10679 | }
|
10680 | if (el[enterCbKey]) {
|
10681 | el[enterCbKey]();
|
10682 | }
|
10683 | }
|
10684 | function recordPosition(c) {
|
10685 | newPositionMap.set(c, c.el.getBoundingClientRect());
|
10686 | }
|
10687 | function applyTranslation(c) {
|
10688 | const oldPos = positionMap.get(c);
|
10689 | const newPos = newPositionMap.get(c);
|
10690 | const dx = oldPos.left - newPos.left;
|
10691 | const dy = oldPos.top - newPos.top;
|
10692 | if (dx || dy) {
|
10693 | const s = c.el.style;
|
10694 | s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
|
10695 | s.transitionDuration = "0s";
|
10696 | return c;
|
10697 | }
|
10698 | }
|
10699 | function hasCSSTransform(el, root, moveClass) {
|
10700 | const clone = el.cloneNode();
|
10701 | const _vtc = el[vtcKey];
|
10702 | if (_vtc) {
|
10703 | _vtc.forEach((cls) => {
|
10704 | cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
|
10705 | });
|
10706 | }
|
10707 | moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
|
10708 | clone.style.display = "none";
|
10709 | const container = root.nodeType === 1 ? root : root.parentNode;
|
10710 | container.appendChild(clone);
|
10711 | const { hasTransform } = getTransitionInfo(clone);
|
10712 | container.removeChild(clone);
|
10713 | return hasTransform;
|
10714 | }
|
10715 |
|
10716 | const getModelAssigner = (vnode) => {
|
10717 | const fn = vnode.props["onUpdate:modelValue"] || false;
|
10718 | return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
|
10719 | };
|
10720 | function onCompositionStart(e) {
|
10721 | e.target.composing = true;
|
10722 | }
|
10723 | function onCompositionEnd(e) {
|
10724 | const target = e.target;
|
10725 | if (target.composing) {
|
10726 | target.composing = false;
|
10727 | target.dispatchEvent(new Event("input"));
|
10728 | }
|
10729 | }
|
10730 | const assignKey = Symbol("_assign");
|
10731 | const vModelText = {
|
10732 | created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
10733 | el[assignKey] = getModelAssigner(vnode);
|
10734 | const castToNumber = number || vnode.props && vnode.props.type === "number";
|
10735 | addEventListener(el, lazy ? "change" : "input", (e) => {
|
10736 | if (e.target.composing)
|
10737 | return;
|
10738 | let domValue = el.value;
|
10739 | if (trim) {
|
10740 | domValue = domValue.trim();
|
10741 | }
|
10742 | if (castToNumber) {
|
10743 | domValue = looseToNumber(domValue);
|
10744 | }
|
10745 | el[assignKey](domValue);
|
10746 | });
|
10747 | if (trim) {
|
10748 | addEventListener(el, "change", () => {
|
10749 | el.value = el.value.trim();
|
10750 | });
|
10751 | }
|
10752 | if (!lazy) {
|
10753 | addEventListener(el, "compositionstart", onCompositionStart);
|
10754 | addEventListener(el, "compositionend", onCompositionEnd);
|
10755 | addEventListener(el, "change", onCompositionEnd);
|
10756 | }
|
10757 | },
|
10758 |
|
10759 | mounted(el, { value }) {
|
10760 | el.value = value == null ? "" : value;
|
10761 | },
|
10762 | beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
|
10763 | el[assignKey] = getModelAssigner(vnode);
|
10764 | if (el.composing)
|
10765 | return;
|
10766 | const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
|
10767 | const newValue = value == null ? "" : value;
|
10768 | if (elValue === newValue) {
|
10769 | return;
|
10770 | }
|
10771 | if (document.activeElement === el && el.type !== "range") {
|
10772 | if (lazy) {
|
10773 | return;
|
10774 | }
|
10775 | if (trim && el.value.trim() === newValue) {
|
10776 | return;
|
10777 | }
|
10778 | }
|
10779 | el.value = newValue;
|
10780 | }
|
10781 | };
|
10782 | const vModelCheckbox = {
|
10783 |
|
10784 | deep: true,
|
10785 | created(el, _, vnode) {
|
10786 | el[assignKey] = getModelAssigner(vnode);
|
10787 | addEventListener(el, "change", () => {
|
10788 | const modelValue = el._modelValue;
|
10789 | const elementValue = getValue(el);
|
10790 | const checked = el.checked;
|
10791 | const assign = el[assignKey];
|
10792 | if (isArray(modelValue)) {
|
10793 | const index = looseIndexOf(modelValue, elementValue);
|
10794 | const found = index !== -1;
|
10795 | if (checked && !found) {
|
10796 | assign(modelValue.concat(elementValue));
|
10797 | } else if (!checked && found) {
|
10798 | const filtered = [...modelValue];
|
10799 | filtered.splice(index, 1);
|
10800 | assign(filtered);
|
10801 | }
|
10802 | } else if (isSet(modelValue)) {
|
10803 | const cloned = new Set(modelValue);
|
10804 | if (checked) {
|
10805 | cloned.add(elementValue);
|
10806 | } else {
|
10807 | cloned.delete(elementValue);
|
10808 | }
|
10809 | assign(cloned);
|
10810 | } else {
|
10811 | assign(getCheckboxValue(el, checked));
|
10812 | }
|
10813 | });
|
10814 | },
|
10815 |
|
10816 | mounted: setChecked,
|
10817 | beforeUpdate(el, binding, vnode) {
|
10818 | el[assignKey] = getModelAssigner(vnode);
|
10819 | setChecked(el, binding, vnode);
|
10820 | }
|
10821 | };
|
10822 | function setChecked(el, { value, oldValue }, vnode) {
|
10823 | el._modelValue = value;
|
10824 | if (isArray(value)) {
|
10825 | el.checked = looseIndexOf(value, vnode.props.value) > -1;
|
10826 | } else if (isSet(value)) {
|
10827 | el.checked = value.has(vnode.props.value);
|
10828 | } else if (value !== oldValue) {
|
10829 | el.checked = looseEqual(value, getCheckboxValue(el, true));
|
10830 | }
|
10831 | }
|
10832 | const vModelRadio = {
|
10833 | created(el, { value }, vnode) {
|
10834 | el.checked = looseEqual(value, vnode.props.value);
|
10835 | el[assignKey] = getModelAssigner(vnode);
|
10836 | addEventListener(el, "change", () => {
|
10837 | el[assignKey](getValue(el));
|
10838 | });
|
10839 | },
|
10840 | beforeUpdate(el, { value, oldValue }, vnode) {
|
10841 | el[assignKey] = getModelAssigner(vnode);
|
10842 | if (value !== oldValue) {
|
10843 | el.checked = looseEqual(value, vnode.props.value);
|
10844 | }
|
10845 | }
|
10846 | };
|
10847 | const vModelSelect = {
|
10848 |
|
10849 | deep: true,
|
10850 | created(el, { value, modifiers: { number } }, vnode) {
|
10851 | const isSetModel = isSet(value);
|
10852 | addEventListener(el, "change", () => {
|
10853 | const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
10854 | (o) => number ? looseToNumber(getValue(o)) : getValue(o)
|
10855 | );
|
10856 | el[assignKey](
|
10857 | el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
10858 | );
|
10859 | el._assigning = true;
|
10860 | nextTick(() => {
|
10861 | el._assigning = false;
|
10862 | });
|
10863 | });
|
10864 | el[assignKey] = getModelAssigner(vnode);
|
10865 | },
|
10866 |
|
10867 |
|
10868 | mounted(el, { value, oldValue, modifiers: { number } }) {
|
10869 | setSelected(el, value, oldValue, number);
|
10870 | },
|
10871 | beforeUpdate(el, _binding, vnode) {
|
10872 | el[assignKey] = getModelAssigner(vnode);
|
10873 | },
|
10874 | updated(el, { value, oldValue, modifiers: { number } }) {
|
10875 | if (!el._assigning) {
|
10876 | setSelected(el, value, oldValue, number);
|
10877 | }
|
10878 | }
|
10879 | };
|
10880 | function setSelected(el, value, oldValue, number) {
|
10881 | const isMultiple = el.multiple;
|
10882 | const isArrayValue = isArray(value);
|
10883 | if (isMultiple && !isArrayValue && !isSet(value)) {
|
10884 | warn(
|
10885 | `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
|
10886 | );
|
10887 | return;
|
10888 | }
|
10889 | for (let i = 0, l = el.options.length; i < l; i++) {
|
10890 | const option = el.options[i];
|
10891 | const optionValue = getValue(option);
|
10892 | if (isMultiple) {
|
10893 | if (isArrayValue) {
|
10894 | const optionType = typeof optionValue;
|
10895 | if (optionType === "string" || optionType === "number") {
|
10896 | option.selected = value.includes(
|
10897 | number ? looseToNumber(optionValue) : optionValue
|
10898 | );
|
10899 | } else {
|
10900 | option.selected = looseIndexOf(value, optionValue) > -1;
|
10901 | }
|
10902 | } else {
|
10903 | option.selected = value.has(optionValue);
|
10904 | }
|
10905 | } else {
|
10906 | if (looseEqual(getValue(option), value)) {
|
10907 | if (el.selectedIndex !== i)
|
10908 | el.selectedIndex = i;
|
10909 | return;
|
10910 | }
|
10911 | }
|
10912 | }
|
10913 | if (!isMultiple && el.selectedIndex !== -1) {
|
10914 | el.selectedIndex = -1;
|
10915 | }
|
10916 | }
|
10917 | function getValue(el) {
|
10918 | return "_value" in el ? el._value : el.value;
|
10919 | }
|
10920 | function getCheckboxValue(el, checked) {
|
10921 | const key = checked ? "_trueValue" : "_falseValue";
|
10922 | return key in el ? el[key] : checked;
|
10923 | }
|
10924 | const vModelDynamic = {
|
10925 | created(el, binding, vnode) {
|
10926 | callModelHook(el, binding, vnode, null, "created");
|
10927 | },
|
10928 | mounted(el, binding, vnode) {
|
10929 | callModelHook(el, binding, vnode, null, "mounted");
|
10930 | },
|
10931 | beforeUpdate(el, binding, vnode, prevVNode) {
|
10932 | callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
|
10933 | },
|
10934 | updated(el, binding, vnode, prevVNode) {
|
10935 | callModelHook(el, binding, vnode, prevVNode, "updated");
|
10936 | }
|
10937 | };
|
10938 | function resolveDynamicModel(tagName, type) {
|
10939 | switch (tagName) {
|
10940 | case "SELECT":
|
10941 | return vModelSelect;
|
10942 | case "TEXTAREA":
|
10943 | return vModelText;
|
10944 | default:
|
10945 | switch (type) {
|
10946 | case "checkbox":
|
10947 | return vModelCheckbox;
|
10948 | case "radio":
|
10949 | return vModelRadio;
|
10950 | default:
|
10951 | return vModelText;
|
10952 | }
|
10953 | }
|
10954 | }
|
10955 | function callModelHook(el, binding, vnode, prevVNode, hook) {
|
10956 | const modelToUse = resolveDynamicModel(
|
10957 | el.tagName,
|
10958 | vnode.props && vnode.props.type
|
10959 | );
|
10960 | const fn = modelToUse[hook];
|
10961 | fn && fn(el, binding, vnode, prevVNode);
|
10962 | }
|
10963 |
|
10964 | const systemModifiers = ["ctrl", "shift", "alt", "meta"];
|
10965 | const modifierGuards = {
|
10966 | stop: (e) => e.stopPropagation(),
|
10967 | prevent: (e) => e.preventDefault(),
|
10968 | self: (e) => e.target !== e.currentTarget,
|
10969 | ctrl: (e) => !e.ctrlKey,
|
10970 | shift: (e) => !e.shiftKey,
|
10971 | alt: (e) => !e.altKey,
|
10972 | meta: (e) => !e.metaKey,
|
10973 | left: (e) => "button" in e && e.button !== 0,
|
10974 | middle: (e) => "button" in e && e.button !== 1,
|
10975 | right: (e) => "button" in e && e.button !== 2,
|
10976 | exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
|
10977 | };
|
10978 | const withModifiers = (fn, modifiers) => {
|
10979 | const cache = fn._withMods || (fn._withMods = {});
|
10980 | const cacheKey = modifiers.join(".");
|
10981 | return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
|
10982 | for (let i = 0; i < modifiers.length; i++) {
|
10983 | const guard = modifierGuards[modifiers[i]];
|
10984 | if (guard && guard(event, modifiers))
|
10985 | return;
|
10986 | }
|
10987 | return fn(event, ...args);
|
10988 | });
|
10989 | };
|
10990 | const keyNames = {
|
10991 | esc: "escape",
|
10992 | space: " ",
|
10993 | up: "arrow-up",
|
10994 | left: "arrow-left",
|
10995 | right: "arrow-right",
|
10996 | down: "arrow-down",
|
10997 | delete: "backspace"
|
10998 | };
|
10999 | const withKeys = (fn, modifiers) => {
|
11000 | const cache = fn._withKeys || (fn._withKeys = {});
|
11001 | const cacheKey = modifiers.join(".");
|
11002 | return cache[cacheKey] || (cache[cacheKey] = (event) => {
|
11003 | if (!("key" in event)) {
|
11004 | return;
|
11005 | }
|
11006 | const eventKey = hyphenate(event.key);
|
11007 | if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
|
11008 | return fn(event);
|
11009 | }
|
11010 | });
|
11011 | };
|
11012 |
|
11013 | const rendererOptions = extend({ patchProp }, nodeOps);
|
11014 | let renderer;
|
11015 | let enabledHydration = false;
|
11016 | function ensureRenderer() {
|
11017 | return renderer || (renderer = createRenderer(rendererOptions));
|
11018 | }
|
11019 | function ensureHydrationRenderer() {
|
11020 | renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
|
11021 | enabledHydration = true;
|
11022 | return renderer;
|
11023 | }
|
11024 | const render = (...args) => {
|
11025 | ensureRenderer().render(...args);
|
11026 | };
|
11027 | const hydrate = (...args) => {
|
11028 | ensureHydrationRenderer().hydrate(...args);
|
11029 | };
|
11030 | const createApp = (...args) => {
|
11031 | const app = ensureRenderer().createApp(...args);
|
11032 | {
|
11033 | injectNativeTagCheck(app);
|
11034 | injectCompilerOptionsCheck(app);
|
11035 | }
|
11036 | const { mount } = app;
|
11037 | app.mount = (containerOrSelector) => {
|
11038 | const container = normalizeContainer(containerOrSelector);
|
11039 | if (!container)
|
11040 | return;
|
11041 | const component = app._component;
|
11042 | if (!isFunction(component) && !component.render && !component.template) {
|
11043 | component.template = container.innerHTML;
|
11044 | }
|
11045 | container.innerHTML = "";
|
11046 | const proxy = mount(container, false, resolveRootNamespace(container));
|
11047 | if (container instanceof Element) {
|
11048 | container.removeAttribute("v-cloak");
|
11049 | container.setAttribute("data-v-app", "");
|
11050 | }
|
11051 | return proxy;
|
11052 | };
|
11053 | return app;
|
11054 | };
|
11055 | const createSSRApp = (...args) => {
|
11056 | const app = ensureHydrationRenderer().createApp(...args);
|
11057 | {
|
11058 | injectNativeTagCheck(app);
|
11059 | injectCompilerOptionsCheck(app);
|
11060 | }
|
11061 | const { mount } = app;
|
11062 | app.mount = (containerOrSelector) => {
|
11063 | const container = normalizeContainer(containerOrSelector);
|
11064 | if (container) {
|
11065 | return mount(container, true, resolveRootNamespace(container));
|
11066 | }
|
11067 | };
|
11068 | return app;
|
11069 | };
|
11070 | function resolveRootNamespace(container) {
|
11071 | if (container instanceof SVGElement) {
|
11072 | return "svg";
|
11073 | }
|
11074 | if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
|
11075 | return "mathml";
|
11076 | }
|
11077 | }
|
11078 | function injectNativeTagCheck(app) {
|
11079 | Object.defineProperty(app.config, "isNativeTag", {
|
11080 | value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
11081 | writable: false
|
11082 | });
|
11083 | }
|
11084 | function injectCompilerOptionsCheck(app) {
|
11085 | if (isRuntimeOnly()) {
|
11086 | const isCustomElement = app.config.isCustomElement;
|
11087 | Object.defineProperty(app.config, "isCustomElement", {
|
11088 | get() {
|
11089 | return isCustomElement;
|
11090 | },
|
11091 | set() {
|
11092 | warn(
|
11093 | `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
|
11094 | );
|
11095 | }
|
11096 | });
|
11097 | const compilerOptions = app.config.compilerOptions;
|
11098 | const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
|
11099 | - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
|
11100 | - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
|
11101 | - For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc`;
|
11102 | Object.defineProperty(app.config, "compilerOptions", {
|
11103 | get() {
|
11104 | warn(msg);
|
11105 | return compilerOptions;
|
11106 | },
|
11107 | set() {
|
11108 | warn(msg);
|
11109 | }
|
11110 | });
|
11111 | }
|
11112 | }
|
11113 | function normalizeContainer(container) {
|
11114 | if (isString(container)) {
|
11115 | const res = document.querySelector(container);
|
11116 | if (!res) {
|
11117 | warn(
|
11118 | `Failed to mount app: mount target selector "${container}" returned null.`
|
11119 | );
|
11120 | }
|
11121 | return res;
|
11122 | }
|
11123 | if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
|
11124 | warn(
|
11125 | `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
|
11126 | );
|
11127 | }
|
11128 | return container;
|
11129 | }
|
11130 | const initDirectivesForSSR = NOOP;
|
11131 |
|
11132 | function initDev() {
|
11133 | {
|
11134 | {
|
11135 | console.info(
|
11136 | `You are running a development build of Vue.
|
11137 | Make sure to use the production build (*.prod.js) when deploying for production.`
|
11138 | );
|
11139 | }
|
11140 | initCustomFormatter();
|
11141 | }
|
11142 | }
|
11143 |
|
11144 | const FRAGMENT = Symbol(`Fragment` );
|
11145 | const TELEPORT = Symbol(`Teleport` );
|
11146 | const SUSPENSE = Symbol(`Suspense` );
|
11147 | const KEEP_ALIVE = Symbol(`KeepAlive` );
|
11148 | const BASE_TRANSITION = Symbol(`BaseTransition` );
|
11149 | const OPEN_BLOCK = Symbol(`openBlock` );
|
11150 | const CREATE_BLOCK = Symbol(`createBlock` );
|
11151 | const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
|
11152 | const CREATE_VNODE = Symbol(`createVNode` );
|
11153 | const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
|
11154 | const CREATE_COMMENT = Symbol(`createCommentVNode` );
|
11155 | const CREATE_TEXT = Symbol(`createTextVNode` );
|
11156 | const CREATE_STATIC = Symbol(`createStaticVNode` );
|
11157 | const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
|
11158 | const RESOLVE_DYNAMIC_COMPONENT = Symbol(
|
11159 | `resolveDynamicComponent`
|
11160 | );
|
11161 | const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
|
11162 | const RESOLVE_FILTER = Symbol(`resolveFilter` );
|
11163 | const WITH_DIRECTIVES = Symbol(`withDirectives` );
|
11164 | const RENDER_LIST = Symbol(`renderList` );
|
11165 | const RENDER_SLOT = Symbol(`renderSlot` );
|
11166 | const CREATE_SLOTS = Symbol(`createSlots` );
|
11167 | const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
|
11168 | const MERGE_PROPS = Symbol(`mergeProps` );
|
11169 | const NORMALIZE_CLASS = Symbol(`normalizeClass` );
|
11170 | const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
|
11171 | const NORMALIZE_PROPS = Symbol(`normalizeProps` );
|
11172 | const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
|
11173 | const TO_HANDLERS = Symbol(`toHandlers` );
|
11174 | const CAMELIZE = Symbol(`camelize` );
|
11175 | const CAPITALIZE = Symbol(`capitalize` );
|
11176 | const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
|
11177 | const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
|
11178 | const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
|
11179 | const POP_SCOPE_ID = Symbol(`popScopeId` );
|
11180 | const WITH_CTX = Symbol(`withCtx` );
|
11181 | const UNREF = Symbol(`unref` );
|
11182 | const IS_REF = Symbol(`isRef` );
|
11183 | const WITH_MEMO = Symbol(`withMemo` );
|
11184 | const IS_MEMO_SAME = Symbol(`isMemoSame` );
|
11185 | const helperNameMap = {
|
11186 | [FRAGMENT]: `Fragment`,
|
11187 | [TELEPORT]: `Teleport`,
|
11188 | [SUSPENSE]: `Suspense`,
|
11189 | [KEEP_ALIVE]: `KeepAlive`,
|
11190 | [BASE_TRANSITION]: `BaseTransition`,
|
11191 | [OPEN_BLOCK]: `openBlock`,
|
11192 | [CREATE_BLOCK]: `createBlock`,
|
11193 | [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
|
11194 | [CREATE_VNODE]: `createVNode`,
|
11195 | [CREATE_ELEMENT_VNODE]: `createElementVNode`,
|
11196 | [CREATE_COMMENT]: `createCommentVNode`,
|
11197 | [CREATE_TEXT]: `createTextVNode`,
|
11198 | [CREATE_STATIC]: `createStaticVNode`,
|
11199 | [RESOLVE_COMPONENT]: `resolveComponent`,
|
11200 | [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
|
11201 | [RESOLVE_DIRECTIVE]: `resolveDirective`,
|
11202 | [RESOLVE_FILTER]: `resolveFilter`,
|
11203 | [WITH_DIRECTIVES]: `withDirectives`,
|
11204 | [RENDER_LIST]: `renderList`,
|
11205 | [RENDER_SLOT]: `renderSlot`,
|
11206 | [CREATE_SLOTS]: `createSlots`,
|
11207 | [TO_DISPLAY_STRING]: `toDisplayString`,
|
11208 | [MERGE_PROPS]: `mergeProps`,
|
11209 | [NORMALIZE_CLASS]: `normalizeClass`,
|
11210 | [NORMALIZE_STYLE]: `normalizeStyle`,
|
11211 | [NORMALIZE_PROPS]: `normalizeProps`,
|
11212 | [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
|
11213 | [TO_HANDLERS]: `toHandlers`,
|
11214 | [CAMELIZE]: `camelize`,
|
11215 | [CAPITALIZE]: `capitalize`,
|
11216 | [TO_HANDLER_KEY]: `toHandlerKey`,
|
11217 | [SET_BLOCK_TRACKING]: `setBlockTracking`,
|
11218 | [PUSH_SCOPE_ID]: `pushScopeId`,
|
11219 | [POP_SCOPE_ID]: `popScopeId`,
|
11220 | [WITH_CTX]: `withCtx`,
|
11221 | [UNREF]: `unref`,
|
11222 | [IS_REF]: `isRef`,
|
11223 | [WITH_MEMO]: `withMemo`,
|
11224 | [IS_MEMO_SAME]: `isMemoSame`
|
11225 | };
|
11226 | function registerRuntimeHelpers(helpers) {
|
11227 | Object.getOwnPropertySymbols(helpers).forEach((s) => {
|
11228 | helperNameMap[s] = helpers[s];
|
11229 | });
|
11230 | }
|
11231 |
|
11232 | const locStub = {
|
11233 | start: { line: 1, column: 1, offset: 0 },
|
11234 | end: { line: 1, column: 1, offset: 0 },
|
11235 | source: ""
|
11236 | };
|
11237 | function createRoot(children, source = "") {
|
11238 | return {
|
11239 | type: 0,
|
11240 | source,
|
11241 | children,
|
11242 | helpers: new Set(),
|
11243 | components: [],
|
11244 | directives: [],
|
11245 | hoists: [],
|
11246 | imports: [],
|
11247 | cached: 0,
|
11248 | temps: 0,
|
11249 | codegenNode: void 0,
|
11250 | loc: locStub
|
11251 | };
|
11252 | }
|
11253 | function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
|
11254 | if (context) {
|
11255 | if (isBlock) {
|
11256 | context.helper(OPEN_BLOCK);
|
11257 | context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
|
11258 | } else {
|
11259 | context.helper(getVNodeHelper(context.inSSR, isComponent));
|
11260 | }
|
11261 | if (directives) {
|
11262 | context.helper(WITH_DIRECTIVES);
|
11263 | }
|
11264 | }
|
11265 | return {
|
11266 | type: 13,
|
11267 | tag,
|
11268 | props,
|
11269 | children,
|
11270 | patchFlag,
|
11271 | dynamicProps,
|
11272 | directives,
|
11273 | isBlock,
|
11274 | disableTracking,
|
11275 | isComponent,
|
11276 | loc
|
11277 | };
|
11278 | }
|
11279 | function createArrayExpression(elements, loc = locStub) {
|
11280 | return {
|
11281 | type: 17,
|
11282 | loc,
|
11283 | elements
|
11284 | };
|
11285 | }
|
11286 | function createObjectExpression(properties, loc = locStub) {
|
11287 | return {
|
11288 | type: 15,
|
11289 | loc,
|
11290 | properties
|
11291 | };
|
11292 | }
|
11293 | function createObjectProperty(key, value) {
|
11294 | return {
|
11295 | type: 16,
|
11296 | loc: locStub,
|
11297 | key: isString(key) ? createSimpleExpression(key, true) : key,
|
11298 | value
|
11299 | };
|
11300 | }
|
11301 | function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
|
11302 | return {
|
11303 | type: 4,
|
11304 | loc,
|
11305 | content,
|
11306 | isStatic,
|
11307 | constType: isStatic ? 3 : constType
|
11308 | };
|
11309 | }
|
11310 | function createCompoundExpression(children, loc = locStub) {
|
11311 | return {
|
11312 | type: 8,
|
11313 | loc,
|
11314 | children
|
11315 | };
|
11316 | }
|
11317 | function createCallExpression(callee, args = [], loc = locStub) {
|
11318 | return {
|
11319 | type: 14,
|
11320 | loc,
|
11321 | callee,
|
11322 | arguments: args
|
11323 | };
|
11324 | }
|
11325 | function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
|
11326 | return {
|
11327 | type: 18,
|
11328 | params,
|
11329 | returns,
|
11330 | newline,
|
11331 | isSlot,
|
11332 | loc
|
11333 | };
|
11334 | }
|
11335 | function createConditionalExpression(test, consequent, alternate, newline = true) {
|
11336 | return {
|
11337 | type: 19,
|
11338 | test,
|
11339 | consequent,
|
11340 | alternate,
|
11341 | newline,
|
11342 | loc: locStub
|
11343 | };
|
11344 | }
|
11345 | function createCacheExpression(index, value, isVNode = false) {
|
11346 | return {
|
11347 | type: 20,
|
11348 | index,
|
11349 | value,
|
11350 | isVNode,
|
11351 | loc: locStub
|
11352 | };
|
11353 | }
|
11354 | function createBlockStatement(body) {
|
11355 | return {
|
11356 | type: 21,
|
11357 | body,
|
11358 | loc: locStub
|
11359 | };
|
11360 | }
|
11361 | function getVNodeHelper(ssr, isComponent) {
|
11362 | return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
11363 | }
|
11364 | function getVNodeBlockHelper(ssr, isComponent) {
|
11365 | return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
|
11366 | }
|
11367 | function convertToBlock(node, { helper, removeHelper, inSSR }) {
|
11368 | if (!node.isBlock) {
|
11369 | node.isBlock = true;
|
11370 | removeHelper(getVNodeHelper(inSSR, node.isComponent));
|
11371 | helper(OPEN_BLOCK);
|
11372 | helper(getVNodeBlockHelper(inSSR, node.isComponent));
|
11373 | }
|
11374 | }
|
11375 |
|
11376 | const defaultDelimitersOpen = new Uint8Array([123, 123]);
|
11377 | const defaultDelimitersClose = new Uint8Array([125, 125]);
|
11378 | function isTagStartChar(c) {
|
11379 | return c >= 97 && c <= 122 || c >= 65 && c <= 90;
|
11380 | }
|
11381 | function isWhitespace(c) {
|
11382 | return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
|
11383 | }
|
11384 | function isEndOfTagSection(c) {
|
11385 | return c === 47 || c === 62 || isWhitespace(c);
|
11386 | }
|
11387 | function toCharCodes(str) {
|
11388 | const ret = new Uint8Array(str.length);
|
11389 | for (let i = 0; i < str.length; i++) {
|
11390 | ret[i] = str.charCodeAt(i);
|
11391 | }
|
11392 | return ret;
|
11393 | }
|
11394 | const Sequences = {
|
11395 | Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
|
11396 |
|
11397 | CdataEnd: new Uint8Array([93, 93, 62]),
|
11398 |
|
11399 | CommentEnd: new Uint8Array([45, 45, 62]),
|
11400 |
|
11401 | ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
|
11402 |
|
11403 | StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
|
11404 |
|
11405 | TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
|
11406 |
|
11407 | TextareaEnd: new Uint8Array([
|
11408 | 60,
|
11409 | 47,
|
11410 | 116,
|
11411 | 101,
|
11412 | 120,
|
11413 | 116,
|
11414 | 97,
|
11415 | 114,
|
11416 | 101,
|
11417 | 97
|
11418 | ])
|
11419 |
|
11420 | };
|
11421 | class Tokenizer {
|
11422 | constructor(stack, cbs) {
|
11423 | this.stack = stack;
|
11424 | this.cbs = cbs;
|
11425 |
|
11426 | this.state = 1;
|
11427 |
|
11428 | this.buffer = "";
|
11429 |
|
11430 | this.sectionStart = 0;
|
11431 |
|
11432 | this.index = 0;
|
11433 |
|
11434 | this.entityStart = 0;
|
11435 |
|
11436 | this.baseState = 1;
|
11437 |
|
11438 | this.inRCDATA = false;
|
11439 |
|
11440 | this.inXML = false;
|
11441 |
|
11442 | this.inVPre = false;
|
11443 |
|
11444 | this.newlines = [];
|
11445 | this.mode = 0;
|
11446 | this.delimiterOpen = defaultDelimitersOpen;
|
11447 | this.delimiterClose = defaultDelimitersClose;
|
11448 | this.delimiterIndex = -1;
|
11449 | this.currentSequence = void 0;
|
11450 | this.sequenceIndex = 0;
|
11451 | }
|
11452 | get inSFCRoot() {
|
11453 | return this.mode === 2 && this.stack.length === 0;
|
11454 | }
|
11455 | reset() {
|
11456 | this.state = 1;
|
11457 | this.mode = 0;
|
11458 | this.buffer = "";
|
11459 | this.sectionStart = 0;
|
11460 | this.index = 0;
|
11461 | this.baseState = 1;
|
11462 | this.inRCDATA = false;
|
11463 | this.currentSequence = void 0;
|
11464 | this.newlines.length = 0;
|
11465 | this.delimiterOpen = defaultDelimitersOpen;
|
11466 | this.delimiterClose = defaultDelimitersClose;
|
11467 | }
|
11468 | |
11469 |
|
11470 |
|
11471 |
|
11472 |
|
11473 |
|
11474 | getPos(index) {
|
11475 | let line = 1;
|
11476 | let column = index + 1;
|
11477 | for (let i = this.newlines.length - 1; i >= 0; i--) {
|
11478 | const newlineIndex = this.newlines[i];
|
11479 | if (index > newlineIndex) {
|
11480 | line = i + 2;
|
11481 | column = index - newlineIndex;
|
11482 | break;
|
11483 | }
|
11484 | }
|
11485 | return {
|
11486 | column,
|
11487 | line,
|
11488 | offset: index
|
11489 | };
|
11490 | }
|
11491 | peek() {
|
11492 | return this.buffer.charCodeAt(this.index + 1);
|
11493 | }
|
11494 | stateText(c) {
|
11495 | if (c === 60) {
|
11496 | if (this.index > this.sectionStart) {
|
11497 | this.cbs.ontext(this.sectionStart, this.index);
|
11498 | }
|
11499 | this.state = 5;
|
11500 | this.sectionStart = this.index;
|
11501 | } else if (!this.inVPre && c === this.delimiterOpen[0]) {
|
11502 | this.state = 2;
|
11503 | this.delimiterIndex = 0;
|
11504 | this.stateInterpolationOpen(c);
|
11505 | }
|
11506 | }
|
11507 | stateInterpolationOpen(c) {
|
11508 | if (c === this.delimiterOpen[this.delimiterIndex]) {
|
11509 | if (this.delimiterIndex === this.delimiterOpen.length - 1) {
|
11510 | const start = this.index + 1 - this.delimiterOpen.length;
|
11511 | if (start > this.sectionStart) {
|
11512 | this.cbs.ontext(this.sectionStart, start);
|
11513 | }
|
11514 | this.state = 3;
|
11515 | this.sectionStart = start;
|
11516 | } else {
|
11517 | this.delimiterIndex++;
|
11518 | }
|
11519 | } else if (this.inRCDATA) {
|
11520 | this.state = 32;
|
11521 | this.stateInRCDATA(c);
|
11522 | } else {
|
11523 | this.state = 1;
|
11524 | this.stateText(c);
|
11525 | }
|
11526 | }
|
11527 | stateInterpolation(c) {
|
11528 | if (c === this.delimiterClose[0]) {
|
11529 | this.state = 4;
|
11530 | this.delimiterIndex = 0;
|
11531 | this.stateInterpolationClose(c);
|
11532 | }
|
11533 | }
|
11534 | stateInterpolationClose(c) {
|
11535 | if (c === this.delimiterClose[this.delimiterIndex]) {
|
11536 | if (this.delimiterIndex === this.delimiterClose.length - 1) {
|
11537 | this.cbs.oninterpolation(this.sectionStart, this.index + 1);
|
11538 | if (this.inRCDATA) {
|
11539 | this.state = 32;
|
11540 | } else {
|
11541 | this.state = 1;
|
11542 | }
|
11543 | this.sectionStart = this.index + 1;
|
11544 | } else {
|
11545 | this.delimiterIndex++;
|
11546 | }
|
11547 | } else {
|
11548 | this.state = 3;
|
11549 | this.stateInterpolation(c);
|
11550 | }
|
11551 | }
|
11552 | stateSpecialStartSequence(c) {
|
11553 | const isEnd = this.sequenceIndex === this.currentSequence.length;
|
11554 | const isMatch = isEnd ? (
|
11555 |
|
11556 | isEndOfTagSection(c)
|
11557 | ) : (
|
11558 |
|
11559 | (c | 32) === this.currentSequence[this.sequenceIndex]
|
11560 | );
|
11561 | if (!isMatch) {
|
11562 | this.inRCDATA = false;
|
11563 | } else if (!isEnd) {
|
11564 | this.sequenceIndex++;
|
11565 | return;
|
11566 | }
|
11567 | this.sequenceIndex = 0;
|
11568 | this.state = 6;
|
11569 | this.stateInTagName(c);
|
11570 | }
|
11571 |
|
11572 | stateInRCDATA(c) {
|
11573 | if (this.sequenceIndex === this.currentSequence.length) {
|
11574 | if (c === 62 || isWhitespace(c)) {
|
11575 | const endOfText = this.index - this.currentSequence.length;
|
11576 | if (this.sectionStart < endOfText) {
|
11577 | const actualIndex = this.index;
|
11578 | this.index = endOfText;
|
11579 | this.cbs.ontext(this.sectionStart, endOfText);
|
11580 | this.index = actualIndex;
|
11581 | }
|
11582 | this.sectionStart = endOfText + 2;
|
11583 | this.stateInClosingTagName(c);
|
11584 | this.inRCDATA = false;
|
11585 | return;
|
11586 | }
|
11587 | this.sequenceIndex = 0;
|
11588 | }
|
11589 | if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
|
11590 | this.sequenceIndex += 1;
|
11591 | } else if (this.sequenceIndex === 0) {
|
11592 | if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
|
11593 | if (c === this.delimiterOpen[0]) {
|
11594 | this.state = 2;
|
11595 | this.delimiterIndex = 0;
|
11596 | this.stateInterpolationOpen(c);
|
11597 | }
|
11598 | } else if (this.fastForwardTo(60)) {
|
11599 | this.sequenceIndex = 1;
|
11600 | }
|
11601 | } else {
|
11602 | this.sequenceIndex = Number(c === 60);
|
11603 | }
|
11604 | }
|
11605 | stateCDATASequence(c) {
|
11606 | if (c === Sequences.Cdata[this.sequenceIndex]) {
|
11607 | if (++this.sequenceIndex === Sequences.Cdata.length) {
|
11608 | this.state = 28;
|
11609 | this.currentSequence = Sequences.CdataEnd;
|
11610 | this.sequenceIndex = 0;
|
11611 | this.sectionStart = this.index + 1;
|
11612 | }
|
11613 | } else {
|
11614 | this.sequenceIndex = 0;
|
11615 | this.state = 23;
|
11616 | this.stateInDeclaration(c);
|
11617 | }
|
11618 | }
|
11619 | |
11620 |
|
11621 |
|
11622 |
|
11623 |
|
11624 |
|
11625 | fastForwardTo(c) {
|
11626 | while (++this.index < this.buffer.length) {
|
11627 | const cc = this.buffer.charCodeAt(this.index);
|
11628 | if (cc === 10) {
|
11629 | this.newlines.push(this.index);
|
11630 | }
|
11631 | if (cc === c) {
|
11632 | return true;
|
11633 | }
|
11634 | }
|
11635 | this.index = this.buffer.length - 1;
|
11636 | return false;
|
11637 | }
|
11638 | |
11639 |
|
11640 |
|
11641 |
|
11642 |
|
11643 |
|
11644 |
|
11645 |
|
11646 | stateInCommentLike(c) {
|
11647 | if (c === this.currentSequence[this.sequenceIndex]) {
|
11648 | if (++this.sequenceIndex === this.currentSequence.length) {
|
11649 | if (this.currentSequence === Sequences.CdataEnd) {
|
11650 | this.cbs.oncdata(this.sectionStart, this.index - 2);
|
11651 | } else {
|
11652 | this.cbs.oncomment(this.sectionStart, this.index - 2);
|
11653 | }
|
11654 | this.sequenceIndex = 0;
|
11655 | this.sectionStart = this.index + 1;
|
11656 | this.state = 1;
|
11657 | }
|
11658 | } else if (this.sequenceIndex === 0) {
|
11659 | if (this.fastForwardTo(this.currentSequence[0])) {
|
11660 | this.sequenceIndex = 1;
|
11661 | }
|
11662 | } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
|
11663 | this.sequenceIndex = 0;
|
11664 | }
|
11665 | }
|
11666 | startSpecial(sequence, offset) {
|
11667 | this.enterRCDATA(sequence, offset);
|
11668 | this.state = 31;
|
11669 | }
|
11670 | enterRCDATA(sequence, offset) {
|
11671 | this.inRCDATA = true;
|
11672 | this.currentSequence = sequence;
|
11673 | this.sequenceIndex = offset;
|
11674 | }
|
11675 | stateBeforeTagName(c) {
|
11676 | if (c === 33) {
|
11677 | this.state = 22;
|
11678 | this.sectionStart = this.index + 1;
|
11679 | } else if (c === 63) {
|
11680 | this.state = 24;
|
11681 | this.sectionStart = this.index + 1;
|
11682 | } else if (isTagStartChar(c)) {
|
11683 | this.sectionStart = this.index;
|
11684 | if (this.mode === 0) {
|
11685 | this.state = 6;
|
11686 | } else if (this.inSFCRoot) {
|
11687 | this.state = 34;
|
11688 | } else if (!this.inXML) {
|
11689 | const lower = c | 32;
|
11690 | if (lower === 116) {
|
11691 | this.state = 30;
|
11692 | } else {
|
11693 | this.state = lower === 115 ? 29 : 6;
|
11694 | }
|
11695 | } else {
|
11696 | this.state = 6;
|
11697 | }
|
11698 | } else if (c === 47) {
|
11699 | this.state = 8;
|
11700 | } else {
|
11701 | this.state = 1;
|
11702 | this.stateText(c);
|
11703 | }
|
11704 | }
|
11705 | stateInTagName(c) {
|
11706 | if (isEndOfTagSection(c)) {
|
11707 | this.handleTagName(c);
|
11708 | }
|
11709 | }
|
11710 | stateInSFCRootTagName(c) {
|
11711 | if (isEndOfTagSection(c)) {
|
11712 | const tag = this.buffer.slice(this.sectionStart, this.index);
|
11713 | if (tag !== "template") {
|
11714 | this.enterRCDATA(toCharCodes(`</` + tag), 0);
|
11715 | }
|
11716 | this.handleTagName(c);
|
11717 | }
|
11718 | }
|
11719 | handleTagName(c) {
|
11720 | this.cbs.onopentagname(this.sectionStart, this.index);
|
11721 | this.sectionStart = -1;
|
11722 | this.state = 11;
|
11723 | this.stateBeforeAttrName(c);
|
11724 | }
|
11725 | stateBeforeClosingTagName(c) {
|
11726 | if (isWhitespace(c)) ; else if (c === 62) {
|
11727 | {
|
11728 | this.cbs.onerr(14, this.index);
|
11729 | }
|
11730 | this.state = 1;
|
11731 | this.sectionStart = this.index + 1;
|
11732 | } else {
|
11733 | this.state = isTagStartChar(c) ? 9 : 27;
|
11734 | this.sectionStart = this.index;
|
11735 | }
|
11736 | }
|
11737 | stateInClosingTagName(c) {
|
11738 | if (c === 62 || isWhitespace(c)) {
|
11739 | this.cbs.onclosetag(this.sectionStart, this.index);
|
11740 | this.sectionStart = -1;
|
11741 | this.state = 10;
|
11742 | this.stateAfterClosingTagName(c);
|
11743 | }
|
11744 | }
|
11745 | stateAfterClosingTagName(c) {
|
11746 | if (c === 62) {
|
11747 | this.state = 1;
|
11748 | this.sectionStart = this.index + 1;
|
11749 | }
|
11750 | }
|
11751 | stateBeforeAttrName(c) {
|
11752 | if (c === 62) {
|
11753 | this.cbs.onopentagend(this.index);
|
11754 | if (this.inRCDATA) {
|
11755 | this.state = 32;
|
11756 | } else {
|
11757 | this.state = 1;
|
11758 | }
|
11759 | this.sectionStart = this.index + 1;
|
11760 | } else if (c === 47) {
|
11761 | this.state = 7;
|
11762 | if (this.peek() !== 62) {
|
11763 | this.cbs.onerr(22, this.index);
|
11764 | }
|
11765 | } else if (c === 60 && this.peek() === 47) {
|
11766 | this.cbs.onopentagend(this.index);
|
11767 | this.state = 5;
|
11768 | this.sectionStart = this.index;
|
11769 | } else if (!isWhitespace(c)) {
|
11770 | if (c === 61) {
|
11771 | this.cbs.onerr(
|
11772 | 19,
|
11773 | this.index
|
11774 | );
|
11775 | }
|
11776 | this.handleAttrStart(c);
|
11777 | }
|
11778 | }
|
11779 | handleAttrStart(c) {
|
11780 | if (c === 118 && this.peek() === 45) {
|
11781 | this.state = 13;
|
11782 | this.sectionStart = this.index;
|
11783 | } else if (c === 46 || c === 58 || c === 64 || c === 35) {
|
11784 | this.cbs.ondirname(this.index, this.index + 1);
|
11785 | this.state = 14;
|
11786 | this.sectionStart = this.index + 1;
|
11787 | } else {
|
11788 | this.state = 12;
|
11789 | this.sectionStart = this.index;
|
11790 | }
|
11791 | }
|
11792 | stateInSelfClosingTag(c) {
|
11793 | if (c === 62) {
|
11794 | this.cbs.onselfclosingtag(this.index);
|
11795 | this.state = 1;
|
11796 | this.sectionStart = this.index + 1;
|
11797 | this.inRCDATA = false;
|
11798 | } else if (!isWhitespace(c)) {
|
11799 | this.state = 11;
|
11800 | this.stateBeforeAttrName(c);
|
11801 | }
|
11802 | }
|
11803 | stateInAttrName(c) {
|
11804 | if (c === 61 || isEndOfTagSection(c)) {
|
11805 | this.cbs.onattribname(this.sectionStart, this.index);
|
11806 | this.handleAttrNameEnd(c);
|
11807 | } else if (c === 34 || c === 39 || c === 60) {
|
11808 | this.cbs.onerr(
|
11809 | 17,
|
11810 | this.index
|
11811 | );
|
11812 | }
|
11813 | }
|
11814 | stateInDirName(c) {
|
11815 | if (c === 61 || isEndOfTagSection(c)) {
|
11816 | this.cbs.ondirname(this.sectionStart, this.index);
|
11817 | this.handleAttrNameEnd(c);
|
11818 | } else if (c === 58) {
|
11819 | this.cbs.ondirname(this.sectionStart, this.index);
|
11820 | this.state = 14;
|
11821 | this.sectionStart = this.index + 1;
|
11822 | } else if (c === 46) {
|
11823 | this.cbs.ondirname(this.sectionStart, this.index);
|
11824 | this.state = 16;
|
11825 | this.sectionStart = this.index + 1;
|
11826 | }
|
11827 | }
|
11828 | stateInDirArg(c) {
|
11829 | if (c === 61 || isEndOfTagSection(c)) {
|
11830 | this.cbs.ondirarg(this.sectionStart, this.index);
|
11831 | this.handleAttrNameEnd(c);
|
11832 | } else if (c === 91) {
|
11833 | this.state = 15;
|
11834 | } else if (c === 46) {
|
11835 | this.cbs.ondirarg(this.sectionStart, this.index);
|
11836 | this.state = 16;
|
11837 | this.sectionStart = this.index + 1;
|
11838 | }
|
11839 | }
|
11840 | stateInDynamicDirArg(c) {
|
11841 | if (c === 93) {
|
11842 | this.state = 14;
|
11843 | } else if (c === 61 || isEndOfTagSection(c)) {
|
11844 | this.cbs.ondirarg(this.sectionStart, this.index + 1);
|
11845 | this.handleAttrNameEnd(c);
|
11846 | {
|
11847 | this.cbs.onerr(
|
11848 | 27,
|
11849 | this.index
|
11850 | );
|
11851 | }
|
11852 | }
|
11853 | }
|
11854 | stateInDirModifier(c) {
|
11855 | if (c === 61 || isEndOfTagSection(c)) {
|
11856 | this.cbs.ondirmodifier(this.sectionStart, this.index);
|
11857 | this.handleAttrNameEnd(c);
|
11858 | } else if (c === 46) {
|
11859 | this.cbs.ondirmodifier(this.sectionStart, this.index);
|
11860 | this.sectionStart = this.index + 1;
|
11861 | }
|
11862 | }
|
11863 | handleAttrNameEnd(c) {
|
11864 | this.sectionStart = this.index;
|
11865 | this.state = 17;
|
11866 | this.cbs.onattribnameend(this.index);
|
11867 | this.stateAfterAttrName(c);
|
11868 | }
|
11869 | stateAfterAttrName(c) {
|
11870 | if (c === 61) {
|
11871 | this.state = 18;
|
11872 | } else if (c === 47 || c === 62) {
|
11873 | this.cbs.onattribend(0, this.sectionStart);
|
11874 | this.sectionStart = -1;
|
11875 | this.state = 11;
|
11876 | this.stateBeforeAttrName(c);
|
11877 | } else if (!isWhitespace(c)) {
|
11878 | this.cbs.onattribend(0, this.sectionStart);
|
11879 | this.handleAttrStart(c);
|
11880 | }
|
11881 | }
|
11882 | stateBeforeAttrValue(c) {
|
11883 | if (c === 34) {
|
11884 | this.state = 19;
|
11885 | this.sectionStart = this.index + 1;
|
11886 | } else if (c === 39) {
|
11887 | this.state = 20;
|
11888 | this.sectionStart = this.index + 1;
|
11889 | } else if (!isWhitespace(c)) {
|
11890 | this.sectionStart = this.index;
|
11891 | this.state = 21;
|
11892 | this.stateInAttrValueNoQuotes(c);
|
11893 | }
|
11894 | }
|
11895 | handleInAttrValue(c, quote) {
|
11896 | if (c === quote || this.fastForwardTo(quote)) {
|
11897 | this.cbs.onattribdata(this.sectionStart, this.index);
|
11898 | this.sectionStart = -1;
|
11899 | this.cbs.onattribend(
|
11900 | quote === 34 ? 3 : 2,
|
11901 | this.index + 1
|
11902 | );
|
11903 | this.state = 11;
|
11904 | }
|
11905 | }
|
11906 | stateInAttrValueDoubleQuotes(c) {
|
11907 | this.handleInAttrValue(c, 34);
|
11908 | }
|
11909 | stateInAttrValueSingleQuotes(c) {
|
11910 | this.handleInAttrValue(c, 39);
|
11911 | }
|
11912 | stateInAttrValueNoQuotes(c) {
|
11913 | if (isWhitespace(c) || c === 62) {
|
11914 | this.cbs.onattribdata(this.sectionStart, this.index);
|
11915 | this.sectionStart = -1;
|
11916 | this.cbs.onattribend(1, this.index);
|
11917 | this.state = 11;
|
11918 | this.stateBeforeAttrName(c);
|
11919 | } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
|
11920 | this.cbs.onerr(
|
11921 | 18,
|
11922 | this.index
|
11923 | );
|
11924 | } else ;
|
11925 | }
|
11926 | stateBeforeDeclaration(c) {
|
11927 | if (c === 91) {
|
11928 | this.state = 26;
|
11929 | this.sequenceIndex = 0;
|
11930 | } else {
|
11931 | this.state = c === 45 ? 25 : 23;
|
11932 | }
|
11933 | }
|
11934 | stateInDeclaration(c) {
|
11935 | if (c === 62 || this.fastForwardTo(62)) {
|
11936 | this.state = 1;
|
11937 | this.sectionStart = this.index + 1;
|
11938 | }
|
11939 | }
|
11940 | stateInProcessingInstruction(c) {
|
11941 | if (c === 62 || this.fastForwardTo(62)) {
|
11942 | this.cbs.onprocessinginstruction(this.sectionStart, this.index);
|
11943 | this.state = 1;
|
11944 | this.sectionStart = this.index + 1;
|
11945 | }
|
11946 | }
|
11947 | stateBeforeComment(c) {
|
11948 | if (c === 45) {
|
11949 | this.state = 28;
|
11950 | this.currentSequence = Sequences.CommentEnd;
|
11951 | this.sequenceIndex = 2;
|
11952 | this.sectionStart = this.index + 1;
|
11953 | } else {
|
11954 | this.state = 23;
|
11955 | }
|
11956 | }
|
11957 | stateInSpecialComment(c) {
|
11958 | if (c === 62 || this.fastForwardTo(62)) {
|
11959 | this.cbs.oncomment(this.sectionStart, this.index);
|
11960 | this.state = 1;
|
11961 | this.sectionStart = this.index + 1;
|
11962 | }
|
11963 | }
|
11964 | stateBeforeSpecialS(c) {
|
11965 | const lower = c | 32;
|
11966 | if (lower === Sequences.ScriptEnd[3]) {
|
11967 | this.startSpecial(Sequences.ScriptEnd, 4);
|
11968 | } else if (lower === Sequences.StyleEnd[3]) {
|
11969 | this.startSpecial(Sequences.StyleEnd, 4);
|
11970 | } else {
|
11971 | this.state = 6;
|
11972 | this.stateInTagName(c);
|
11973 | }
|
11974 | }
|
11975 | stateBeforeSpecialT(c) {
|
11976 | const lower = c | 32;
|
11977 | if (lower === Sequences.TitleEnd[3]) {
|
11978 | this.startSpecial(Sequences.TitleEnd, 4);
|
11979 | } else if (lower === Sequences.TextareaEnd[3]) {
|
11980 | this.startSpecial(Sequences.TextareaEnd, 4);
|
11981 | } else {
|
11982 | this.state = 6;
|
11983 | this.stateInTagName(c);
|
11984 | }
|
11985 | }
|
11986 | startEntity() {
|
11987 | }
|
11988 | stateInEntity() {
|
11989 | }
|
11990 | |
11991 |
|
11992 |
|
11993 |
|
11994 |
|
11995 | parse(input) {
|
11996 | this.buffer = input;
|
11997 | while (this.index < this.buffer.length) {
|
11998 | const c = this.buffer.charCodeAt(this.index);
|
11999 | if (c === 10) {
|
12000 | this.newlines.push(this.index);
|
12001 | }
|
12002 | switch (this.state) {
|
12003 | case 1: {
|
12004 | this.stateText(c);
|
12005 | break;
|
12006 | }
|
12007 | case 2: {
|
12008 | this.stateInterpolationOpen(c);
|
12009 | break;
|
12010 | }
|
12011 | case 3: {
|
12012 | this.stateInterpolation(c);
|
12013 | break;
|
12014 | }
|
12015 | case 4: {
|
12016 | this.stateInterpolationClose(c);
|
12017 | break;
|
12018 | }
|
12019 | case 31: {
|
12020 | this.stateSpecialStartSequence(c);
|
12021 | break;
|
12022 | }
|
12023 | case 32: {
|
12024 | this.stateInRCDATA(c);
|
12025 | break;
|
12026 | }
|
12027 | case 26: {
|
12028 | this.stateCDATASequence(c);
|
12029 | break;
|
12030 | }
|
12031 | case 19: {
|
12032 | this.stateInAttrValueDoubleQuotes(c);
|
12033 | break;
|
12034 | }
|
12035 | case 12: {
|
12036 | this.stateInAttrName(c);
|
12037 | break;
|
12038 | }
|
12039 | case 13: {
|
12040 | this.stateInDirName(c);
|
12041 | break;
|
12042 | }
|
12043 | case 14: {
|
12044 | this.stateInDirArg(c);
|
12045 | break;
|
12046 | }
|
12047 | case 15: {
|
12048 | this.stateInDynamicDirArg(c);
|
12049 | break;
|
12050 | }
|
12051 | case 16: {
|
12052 | this.stateInDirModifier(c);
|
12053 | break;
|
12054 | }
|
12055 | case 28: {
|
12056 | this.stateInCommentLike(c);
|
12057 | break;
|
12058 | }
|
12059 | case 27: {
|
12060 | this.stateInSpecialComment(c);
|
12061 | break;
|
12062 | }
|
12063 | case 11: {
|
12064 | this.stateBeforeAttrName(c);
|
12065 | break;
|
12066 | }
|
12067 | case 6: {
|
12068 | this.stateInTagName(c);
|
12069 | break;
|
12070 | }
|
12071 | case 34: {
|
12072 | this.stateInSFCRootTagName(c);
|
12073 | break;
|
12074 | }
|
12075 | case 9: {
|
12076 | this.stateInClosingTagName(c);
|
12077 | break;
|
12078 | }
|
12079 | case 5: {
|
12080 | this.stateBeforeTagName(c);
|
12081 | break;
|
12082 | }
|
12083 | case 17: {
|
12084 | this.stateAfterAttrName(c);
|
12085 | break;
|
12086 | }
|
12087 | case 20: {
|
12088 | this.stateInAttrValueSingleQuotes(c);
|
12089 | break;
|
12090 | }
|
12091 | case 18: {
|
12092 | this.stateBeforeAttrValue(c);
|
12093 | break;
|
12094 | }
|
12095 | case 8: {
|
12096 | this.stateBeforeClosingTagName(c);
|
12097 | break;
|
12098 | }
|
12099 | case 10: {
|
12100 | this.stateAfterClosingTagName(c);
|
12101 | break;
|
12102 | }
|
12103 | case 29: {
|
12104 | this.stateBeforeSpecialS(c);
|
12105 | break;
|
12106 | }
|
12107 | case 30: {
|
12108 | this.stateBeforeSpecialT(c);
|
12109 | break;
|
12110 | }
|
12111 | case 21: {
|
12112 | this.stateInAttrValueNoQuotes(c);
|
12113 | break;
|
12114 | }
|
12115 | case 7: {
|
12116 | this.stateInSelfClosingTag(c);
|
12117 | break;
|
12118 | }
|
12119 | case 23: {
|
12120 | this.stateInDeclaration(c);
|
12121 | break;
|
12122 | }
|
12123 | case 22: {
|
12124 | this.stateBeforeDeclaration(c);
|
12125 | break;
|
12126 | }
|
12127 | case 25: {
|
12128 | this.stateBeforeComment(c);
|
12129 | break;
|
12130 | }
|
12131 | case 24: {
|
12132 | this.stateInProcessingInstruction(c);
|
12133 | break;
|
12134 | }
|
12135 | case 33: {
|
12136 | this.stateInEntity();
|
12137 | break;
|
12138 | }
|
12139 | }
|
12140 | this.index++;
|
12141 | }
|
12142 | this.cleanup();
|
12143 | this.finish();
|
12144 | }
|
12145 | |
12146 |
|
12147 |
|
12148 | cleanup() {
|
12149 | if (this.sectionStart !== this.index) {
|
12150 | if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
|
12151 | this.cbs.ontext(this.sectionStart, this.index);
|
12152 | this.sectionStart = this.index;
|
12153 | } else if (this.state === 19 || this.state === 20 || this.state === 21) {
|
12154 | this.cbs.onattribdata(this.sectionStart, this.index);
|
12155 | this.sectionStart = this.index;
|
12156 | }
|
12157 | }
|
12158 | }
|
12159 | finish() {
|
12160 | this.handleTrailingData();
|
12161 | this.cbs.onend();
|
12162 | }
|
12163 |
|
12164 | handleTrailingData() {
|
12165 | const endIndex = this.buffer.length;
|
12166 | if (this.sectionStart >= endIndex) {
|
12167 | return;
|
12168 | }
|
12169 | if (this.state === 28) {
|
12170 | if (this.currentSequence === Sequences.CdataEnd) {
|
12171 | this.cbs.oncdata(this.sectionStart, endIndex);
|
12172 | } else {
|
12173 | this.cbs.oncomment(this.sectionStart, endIndex);
|
12174 | }
|
12175 | } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) ; else {
|
12176 | this.cbs.ontext(this.sectionStart, endIndex);
|
12177 | }
|
12178 | }
|
12179 | emitCodePoint(cp, consumed) {
|
12180 | }
|
12181 | }
|
12182 |
|
12183 | function defaultOnError(error) {
|
12184 | throw error;
|
12185 | }
|
12186 | function defaultOnWarn(msg) {
|
12187 | console.warn(`[Vue warn] ${msg.message}`);
|
12188 | }
|
12189 | function createCompilerError(code, loc, messages, additionalMessage) {
|
12190 | const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
|
12191 | const error = new SyntaxError(String(msg));
|
12192 | error.code = code;
|
12193 | error.loc = loc;
|
12194 | return error;
|
12195 | }
|
12196 | const errorMessages = {
|
12197 |
|
12198 | [0]: "Illegal comment.",
|
12199 | [1]: "CDATA section is allowed only in XML context.",
|
12200 | [2]: "Duplicate attribute.",
|
12201 | [3]: "End tag cannot have attributes.",
|
12202 | [4]: "Illegal '/' in tags.",
|
12203 | [5]: "Unexpected EOF in tag.",
|
12204 | [6]: "Unexpected EOF in CDATA section.",
|
12205 | [7]: "Unexpected EOF in comment.",
|
12206 | [8]: "Unexpected EOF in script.",
|
12207 | [9]: "Unexpected EOF in tag.",
|
12208 | [10]: "Incorrectly closed comment.",
|
12209 | [11]: "Incorrectly opened comment.",
|
12210 | [12]: "Illegal tag name. Use '<' to print '<'.",
|
12211 | [13]: "Attribute value was expected.",
|
12212 | [14]: "End tag name was expected.",
|
12213 | [15]: "Whitespace was expected.",
|
12214 | [16]: "Unexpected '<!--' in comment.",
|
12215 | [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
12216 | [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
12217 | [19]: "Attribute name cannot start with '='.",
|
12218 | [21]: "'<?' is allowed only in XML context.",
|
12219 | [20]: `Unexpected null character.`,
|
12220 | [22]: "Illegal '/' in tags.",
|
12221 |
|
12222 | [23]: "Invalid end tag.",
|
12223 | [24]: "Element is missing end tag.",
|
12224 | [25]: "Interpolation end sign was not found.",
|
12225 | [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
12226 | [26]: "Legal directive name was expected.",
|
12227 |
|
12228 | [28]: `v-if/v-else-if is missing expression.`,
|
12229 | [29]: `v-if/else branches must use unique keys.`,
|
12230 | [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
12231 | [31]: `v-for is missing expression.`,
|
12232 | [32]: `v-for has invalid expression.`,
|
12233 | [33]: `<template v-for> key should be placed on the <template> tag.`,
|
12234 | [34]: `v-bind is missing expression.`,
|
12235 | [52]: `v-bind with same-name shorthand only allows static argument.`,
|
12236 | [35]: `v-on is missing expression.`,
|
12237 | [36]: `Unexpected custom directive on <slot> outlet.`,
|
12238 | [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
|
12239 | [38]: `Duplicate slot names found. `,
|
12240 | [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
12241 | [40]: `v-slot can only be used on components or <template> tags.`,
|
12242 | [41]: `v-model is missing expression.`,
|
12243 | [42]: `v-model value must be a valid JavaScript member expression.`,
|
12244 | [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
12245 | [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
12246 | Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
12247 | [45]: `Error parsing JavaScript expression: `,
|
12248 | [46]: `<KeepAlive> expects exactly one child component.`,
|
12249 | [51]: `@vnode-* hooks in templates are no longer supported. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support has been removed in 3.4.`,
|
12250 |
|
12251 | [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
12252 | [48]: `ES module mode is not supported in this build of compiler.`,
|
12253 | [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
12254 | [50]: `"scopeId" option is only supported in module mode.`,
|
12255 |
|
12256 | [53]: ``
|
12257 | };
|
12258 |
|
12259 | const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
12260 | function isCoreComponent(tag) {
|
12261 | switch (tag) {
|
12262 | case "Teleport":
|
12263 | case "teleport":
|
12264 | return TELEPORT;
|
12265 | case "Suspense":
|
12266 | case "suspense":
|
12267 | return SUSPENSE;
|
12268 | case "KeepAlive":
|
12269 | case "keep-alive":
|
12270 | return KEEP_ALIVE;
|
12271 | case "BaseTransition":
|
12272 | case "base-transition":
|
12273 | return BASE_TRANSITION;
|
12274 | }
|
12275 | }
|
12276 | const nonIdentifierRE = /^\d|[^\$\w]/;
|
12277 | const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
12278 | const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
12279 | const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
12280 | const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
|
12281 | const isMemberExpressionBrowser = (path) => {
|
12282 | path = path.trim().replace(whitespaceRE, (s) => s.trim());
|
12283 | let state = 0 ;
|
12284 | let stateStack = [];
|
12285 | let currentOpenBracketCount = 0;
|
12286 | let currentOpenParensCount = 0;
|
12287 | let currentStringType = null;
|
12288 | for (let i = 0; i < path.length; i++) {
|
12289 | const char = path.charAt(i);
|
12290 | switch (state) {
|
12291 | case 0 :
|
12292 | if (char === "[") {
|
12293 | stateStack.push(state);
|
12294 | state = 1 ;
|
12295 | currentOpenBracketCount++;
|
12296 | } else if (char === "(") {
|
12297 | stateStack.push(state);
|
12298 | state = 2 ;
|
12299 | currentOpenParensCount++;
|
12300 | } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
|
12301 | return false;
|
12302 | }
|
12303 | break;
|
12304 | case 1 :
|
12305 | if (char === `'` || char === `"` || char === "`") {
|
12306 | stateStack.push(state);
|
12307 | state = 3 ;
|
12308 | currentStringType = char;
|
12309 | } else if (char === `[`) {
|
12310 | currentOpenBracketCount++;
|
12311 | } else if (char === `]`) {
|
12312 | if (!--currentOpenBracketCount) {
|
12313 | state = stateStack.pop();
|
12314 | }
|
12315 | }
|
12316 | break;
|
12317 | case 2 :
|
12318 | if (char === `'` || char === `"` || char === "`") {
|
12319 | stateStack.push(state);
|
12320 | state = 3 ;
|
12321 | currentStringType = char;
|
12322 | } else if (char === `(`) {
|
12323 | currentOpenParensCount++;
|
12324 | } else if (char === `)`) {
|
12325 | if (i === path.length - 1) {
|
12326 | return false;
|
12327 | }
|
12328 | if (!--currentOpenParensCount) {
|
12329 | state = stateStack.pop();
|
12330 | }
|
12331 | }
|
12332 | break;
|
12333 | case 3 :
|
12334 | if (char === currentStringType) {
|
12335 | state = stateStack.pop();
|
12336 | currentStringType = null;
|
12337 | }
|
12338 | break;
|
12339 | }
|
12340 | }
|
12341 | return !currentOpenBracketCount && !currentOpenParensCount;
|
12342 | };
|
12343 | const isMemberExpression = isMemberExpressionBrowser ;
|
12344 | function assert(condition, msg) {
|
12345 | if (!condition) {
|
12346 | throw new Error(msg || `unexpected compiler condition`);
|
12347 | }
|
12348 | }
|
12349 | function findDir(node, name, allowEmpty = false) {
|
12350 | for (let i = 0; i < node.props.length; i++) {
|
12351 | const p = node.props[i];
|
12352 | if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
|
12353 | return p;
|
12354 | }
|
12355 | }
|
12356 | }
|
12357 | function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
12358 | for (let i = 0; i < node.props.length; i++) {
|
12359 | const p = node.props[i];
|
12360 | if (p.type === 6) {
|
12361 | if (dynamicOnly)
|
12362 | continue;
|
12363 | if (p.name === name && (p.value || allowEmpty)) {
|
12364 | return p;
|
12365 | }
|
12366 | } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
|
12367 | return p;
|
12368 | }
|
12369 | }
|
12370 | }
|
12371 | function isStaticArgOf(arg, name) {
|
12372 | return !!(arg && isStaticExp(arg) && arg.content === name);
|
12373 | }
|
12374 | function hasDynamicKeyVBind(node) {
|
12375 | return node.props.some(
|
12376 | (p) => p.type === 7 && p.name === "bind" && (!p.arg ||
|
12377 | p.arg.type !== 4 ||
|
12378 | !p.arg.isStatic)
|
12379 |
|
12380 | );
|
12381 | }
|
12382 | function isText$1(node) {
|
12383 | return node.type === 5 || node.type === 2;
|
12384 | }
|
12385 | function isVSlot(p) {
|
12386 | return p.type === 7 && p.name === "slot";
|
12387 | }
|
12388 | function isTemplateNode(node) {
|
12389 | return node.type === 1 && node.tagType === 3;
|
12390 | }
|
12391 | function isSlotOutlet(node) {
|
12392 | return node.type === 1 && node.tagType === 2;
|
12393 | }
|
12394 | const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
12395 | function getUnnormalizedProps(props, callPath = []) {
|
12396 | if (props && !isString(props) && props.type === 14) {
|
12397 | const callee = props.callee;
|
12398 | if (!isString(callee) && propsHelperSet.has(callee)) {
|
12399 | return getUnnormalizedProps(
|
12400 | props.arguments[0],
|
12401 | callPath.concat(props)
|
12402 | );
|
12403 | }
|
12404 | }
|
12405 | return [props, callPath];
|
12406 | }
|
12407 | function injectProp(node, prop, context) {
|
12408 | let propsWithInjection;
|
12409 | let props = node.type === 13 ? node.props : node.arguments[2];
|
12410 | let callPath = [];
|
12411 | let parentCall;
|
12412 | if (props && !isString(props) && props.type === 14) {
|
12413 | const ret = getUnnormalizedProps(props);
|
12414 | props = ret[0];
|
12415 | callPath = ret[1];
|
12416 | parentCall = callPath[callPath.length - 1];
|
12417 | }
|
12418 | if (props == null || isString(props)) {
|
12419 | propsWithInjection = createObjectExpression([prop]);
|
12420 | } else if (props.type === 14) {
|
12421 | const first = props.arguments[0];
|
12422 | if (!isString(first) && first.type === 15) {
|
12423 | if (!hasProp(prop, first)) {
|
12424 | first.properties.unshift(prop);
|
12425 | }
|
12426 | } else {
|
12427 | if (props.callee === TO_HANDLERS) {
|
12428 | propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
|
12429 | createObjectExpression([prop]),
|
12430 | props
|
12431 | ]);
|
12432 | } else {
|
12433 | props.arguments.unshift(createObjectExpression([prop]));
|
12434 | }
|
12435 | }
|
12436 | !propsWithInjection && (propsWithInjection = props);
|
12437 | } else if (props.type === 15) {
|
12438 | if (!hasProp(prop, props)) {
|
12439 | props.properties.unshift(prop);
|
12440 | }
|
12441 | propsWithInjection = props;
|
12442 | } else {
|
12443 | propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
|
12444 | createObjectExpression([prop]),
|
12445 | props
|
12446 | ]);
|
12447 | if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
|
12448 | parentCall = callPath[callPath.length - 2];
|
12449 | }
|
12450 | }
|
12451 | if (node.type === 13) {
|
12452 | if (parentCall) {
|
12453 | parentCall.arguments[0] = propsWithInjection;
|
12454 | } else {
|
12455 | node.props = propsWithInjection;
|
12456 | }
|
12457 | } else {
|
12458 | if (parentCall) {
|
12459 | parentCall.arguments[0] = propsWithInjection;
|
12460 | } else {
|
12461 | node.arguments[2] = propsWithInjection;
|
12462 | }
|
12463 | }
|
12464 | }
|
12465 | function hasProp(prop, props) {
|
12466 | let result = false;
|
12467 | if (prop.key.type === 4) {
|
12468 | const propKeyName = prop.key.content;
|
12469 | result = props.properties.some(
|
12470 | (p) => p.key.type === 4 && p.key.content === propKeyName
|
12471 | );
|
12472 | }
|
12473 | return result;
|
12474 | }
|
12475 | function toValidAssetId(name, type) {
|
12476 | return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
|
12477 | return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
|
12478 | })}`;
|
12479 | }
|
12480 | function getMemoedVNodeCall(node) {
|
12481 | if (node.type === 14 && node.callee === WITH_MEMO) {
|
12482 | return node.arguments[1].returns;
|
12483 | } else {
|
12484 | return node;
|
12485 | }
|
12486 | }
|
12487 | const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
12488 |
|
12489 | const defaultParserOptions = {
|
12490 | parseMode: "base",
|
12491 | ns: 0,
|
12492 | delimiters: [`{{`, `}}`],
|
12493 | getNamespace: () => 0,
|
12494 | isVoidTag: NO,
|
12495 | isPreTag: NO,
|
12496 | isCustomElement: NO,
|
12497 | onError: defaultOnError,
|
12498 | onWarn: defaultOnWarn,
|
12499 | comments: true,
|
12500 | prefixIdentifiers: false
|
12501 | };
|
12502 | let currentOptions = defaultParserOptions;
|
12503 | let currentRoot = null;
|
12504 | let currentInput = "";
|
12505 | let currentOpenTag = null;
|
12506 | let currentProp = null;
|
12507 | let currentAttrValue = "";
|
12508 | let currentAttrStartIndex = -1;
|
12509 | let currentAttrEndIndex = -1;
|
12510 | let inPre = 0;
|
12511 | let inVPre = false;
|
12512 | let currentVPreBoundary = null;
|
12513 | const stack = [];
|
12514 | const tokenizer = new Tokenizer(stack, {
|
12515 | onerr: emitError,
|
12516 | ontext(start, end) {
|
12517 | onText(getSlice(start, end), start, end);
|
12518 | },
|
12519 | ontextentity(char, start, end) {
|
12520 | onText(char, start, end);
|
12521 | },
|
12522 | oninterpolation(start, end) {
|
12523 | if (inVPre) {
|
12524 | return onText(getSlice(start, end), start, end);
|
12525 | }
|
12526 | let innerStart = start + tokenizer.delimiterOpen.length;
|
12527 | let innerEnd = end - tokenizer.delimiterClose.length;
|
12528 | while (isWhitespace(currentInput.charCodeAt(innerStart))) {
|
12529 | innerStart++;
|
12530 | }
|
12531 | while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
|
12532 | innerEnd--;
|
12533 | }
|
12534 | let exp = getSlice(innerStart, innerEnd);
|
12535 | if (exp.includes("&")) {
|
12536 | {
|
12537 | exp = currentOptions.decodeEntities(exp, false);
|
12538 | }
|
12539 | }
|
12540 | addNode({
|
12541 | type: 5,
|
12542 | content: createExp(exp, false, getLoc(innerStart, innerEnd)),
|
12543 | loc: getLoc(start, end)
|
12544 | });
|
12545 | },
|
12546 | onopentagname(start, end) {
|
12547 | const name = getSlice(start, end);
|
12548 | currentOpenTag = {
|
12549 | type: 1,
|
12550 | tag: name,
|
12551 | ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
|
12552 | tagType: 0,
|
12553 |
|
12554 | props: [],
|
12555 | children: [],
|
12556 | loc: getLoc(start - 1, end),
|
12557 | codegenNode: void 0
|
12558 | };
|
12559 | },
|
12560 | onopentagend(end) {
|
12561 | endOpenTag(end);
|
12562 | },
|
12563 | onclosetag(start, end) {
|
12564 | const name = getSlice(start, end);
|
12565 | if (!currentOptions.isVoidTag(name)) {
|
12566 | let found = false;
|
12567 | for (let i = 0; i < stack.length; i++) {
|
12568 | const e = stack[i];
|
12569 | if (e.tag.toLowerCase() === name.toLowerCase()) {
|
12570 | found = true;
|
12571 | if (i > 0) {
|
12572 | emitError(24, stack[0].loc.start.offset);
|
12573 | }
|
12574 | for (let j = 0; j <= i; j++) {
|
12575 | const el = stack.shift();
|
12576 | onCloseTag(el, end, j < i);
|
12577 | }
|
12578 | break;
|
12579 | }
|
12580 | }
|
12581 | if (!found) {
|
12582 | emitError(23, backTrack(start, 60));
|
12583 | }
|
12584 | }
|
12585 | },
|
12586 | onselfclosingtag(end) {
|
12587 | var _a;
|
12588 | const name = currentOpenTag.tag;
|
12589 | currentOpenTag.isSelfClosing = true;
|
12590 | endOpenTag(end);
|
12591 | if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
|
12592 | onCloseTag(stack.shift(), end);
|
12593 | }
|
12594 | },
|
12595 | onattribname(start, end) {
|
12596 | currentProp = {
|
12597 | type: 6,
|
12598 | name: getSlice(start, end),
|
12599 | nameLoc: getLoc(start, end),
|
12600 | value: void 0,
|
12601 | loc: getLoc(start)
|
12602 | };
|
12603 | },
|
12604 | ondirname(start, end) {
|
12605 | const raw = getSlice(start, end);
|
12606 | const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
|
12607 | if (!inVPre && name === "") {
|
12608 | emitError(26, start);
|
12609 | }
|
12610 | if (inVPre || name === "") {
|
12611 | currentProp = {
|
12612 | type: 6,
|
12613 | name: raw,
|
12614 | nameLoc: getLoc(start, end),
|
12615 | value: void 0,
|
12616 | loc: getLoc(start)
|
12617 | };
|
12618 | } else {
|
12619 | currentProp = {
|
12620 | type: 7,
|
12621 | name,
|
12622 | rawName: raw,
|
12623 | exp: void 0,
|
12624 | arg: void 0,
|
12625 | modifiers: raw === "." ? ["prop"] : [],
|
12626 | loc: getLoc(start)
|
12627 | };
|
12628 | if (name === "pre") {
|
12629 | inVPre = tokenizer.inVPre = true;
|
12630 | currentVPreBoundary = currentOpenTag;
|
12631 | const props = currentOpenTag.props;
|
12632 | for (let i = 0; i < props.length; i++) {
|
12633 | if (props[i].type === 7) {
|
12634 | props[i] = dirToAttr(props[i]);
|
12635 | }
|
12636 | }
|
12637 | }
|
12638 | }
|
12639 | },
|
12640 | ondirarg(start, end) {
|
12641 | if (start === end)
|
12642 | return;
|
12643 | const arg = getSlice(start, end);
|
12644 | if (inVPre) {
|
12645 | currentProp.name += arg;
|
12646 | setLocEnd(currentProp.nameLoc, end);
|
12647 | } else {
|
12648 | const isStatic = arg[0] !== `[`;
|
12649 | currentProp.arg = createExp(
|
12650 | isStatic ? arg : arg.slice(1, -1),
|
12651 | isStatic,
|
12652 | getLoc(start, end),
|
12653 | isStatic ? 3 : 0
|
12654 | );
|
12655 | }
|
12656 | },
|
12657 | ondirmodifier(start, end) {
|
12658 | const mod = getSlice(start, end);
|
12659 | if (inVPre) {
|
12660 | currentProp.name += "." + mod;
|
12661 | setLocEnd(currentProp.nameLoc, end);
|
12662 | } else if (currentProp.name === "slot") {
|
12663 | const arg = currentProp.arg;
|
12664 | if (arg) {
|
12665 | arg.content += "." + mod;
|
12666 | setLocEnd(arg.loc, end);
|
12667 | }
|
12668 | } else {
|
12669 | currentProp.modifiers.push(mod);
|
12670 | }
|
12671 | },
|
12672 | onattribdata(start, end) {
|
12673 | currentAttrValue += getSlice(start, end);
|
12674 | if (currentAttrStartIndex < 0)
|
12675 | currentAttrStartIndex = start;
|
12676 | currentAttrEndIndex = end;
|
12677 | },
|
12678 | onattribentity(char, start, end) {
|
12679 | currentAttrValue += char;
|
12680 | if (currentAttrStartIndex < 0)
|
12681 | currentAttrStartIndex = start;
|
12682 | currentAttrEndIndex = end;
|
12683 | },
|
12684 | onattribnameend(end) {
|
12685 | const start = currentProp.loc.start.offset;
|
12686 | const name = getSlice(start, end);
|
12687 | if (currentProp.type === 7) {
|
12688 | currentProp.rawName = name;
|
12689 | }
|
12690 | if (currentOpenTag.props.some(
|
12691 | (p) => (p.type === 7 ? p.rawName : p.name) === name
|
12692 | )) {
|
12693 | emitError(2, start);
|
12694 | }
|
12695 | },
|
12696 | onattribend(quote, end) {
|
12697 | if (currentOpenTag && currentProp) {
|
12698 | setLocEnd(currentProp.loc, end);
|
12699 | if (quote !== 0) {
|
12700 | if (currentAttrValue.includes("&")) {
|
12701 | currentAttrValue = currentOptions.decodeEntities(
|
12702 | currentAttrValue,
|
12703 | true
|
12704 | );
|
12705 | }
|
12706 | if (currentProp.type === 6) {
|
12707 | if (currentProp.name === "class") {
|
12708 | currentAttrValue = condense(currentAttrValue).trim();
|
12709 | }
|
12710 | if (quote === 1 && !currentAttrValue) {
|
12711 | emitError(13, end);
|
12712 | }
|
12713 | currentProp.value = {
|
12714 | type: 2,
|
12715 | content: currentAttrValue,
|
12716 | loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
|
12717 | };
|
12718 | if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
|
12719 | tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
|
12720 | }
|
12721 | } else {
|
12722 | let expParseMode = 0 ;
|
12723 | currentProp.exp = createExp(
|
12724 | currentAttrValue,
|
12725 | false,
|
12726 | getLoc(currentAttrStartIndex, currentAttrEndIndex),
|
12727 | 0,
|
12728 | expParseMode
|
12729 | );
|
12730 | if (currentProp.name === "for") {
|
12731 | currentProp.forParseResult = parseForExpression(currentProp.exp);
|
12732 | }
|
12733 | }
|
12734 | }
|
12735 | if (currentProp.type !== 7 || currentProp.name !== "pre") {
|
12736 | currentOpenTag.props.push(currentProp);
|
12737 | }
|
12738 | }
|
12739 | currentAttrValue = "";
|
12740 | currentAttrStartIndex = currentAttrEndIndex = -1;
|
12741 | },
|
12742 | oncomment(start, end) {
|
12743 | if (currentOptions.comments) {
|
12744 | addNode({
|
12745 | type: 3,
|
12746 | content: getSlice(start, end),
|
12747 | loc: getLoc(start - 4, end + 3)
|
12748 | });
|
12749 | }
|
12750 | },
|
12751 | onend() {
|
12752 | const end = currentInput.length;
|
12753 | if (tokenizer.state !== 1) {
|
12754 | switch (tokenizer.state) {
|
12755 | case 5:
|
12756 | case 8:
|
12757 | emitError(5, end);
|
12758 | break;
|
12759 | case 3:
|
12760 | case 4:
|
12761 | emitError(
|
12762 | 25,
|
12763 | tokenizer.sectionStart
|
12764 | );
|
12765 | break;
|
12766 | case 28:
|
12767 | if (tokenizer.currentSequence === Sequences.CdataEnd) {
|
12768 | emitError(6, end);
|
12769 | } else {
|
12770 | emitError(7, end);
|
12771 | }
|
12772 | break;
|
12773 | case 6:
|
12774 | case 7:
|
12775 | case 9:
|
12776 | case 11:
|
12777 | case 12:
|
12778 | case 13:
|
12779 | case 14:
|
12780 | case 15:
|
12781 | case 16:
|
12782 | case 17:
|
12783 | case 18:
|
12784 | case 19:
|
12785 | case 20:
|
12786 | case 21:
|
12787 | emitError(9, end);
|
12788 | break;
|
12789 | }
|
12790 | }
|
12791 | for (let index = 0; index < stack.length; index++) {
|
12792 | onCloseTag(stack[index], end - 1);
|
12793 | emitError(24, stack[index].loc.start.offset);
|
12794 | }
|
12795 | },
|
12796 | oncdata(start, end) {
|
12797 | if (stack[0].ns !== 0) {
|
12798 | onText(getSlice(start, end), start, end);
|
12799 | } else {
|
12800 | emitError(1, start - 9);
|
12801 | }
|
12802 | },
|
12803 | onprocessinginstruction(start) {
|
12804 | if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
12805 | emitError(
|
12806 | 21,
|
12807 | start - 1
|
12808 | );
|
12809 | }
|
12810 | }
|
12811 | });
|
12812 | const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
12813 | const stripParensRE = /^\(|\)$/g;
|
12814 | function parseForExpression(input) {
|
12815 | const loc = input.loc;
|
12816 | const exp = input.content;
|
12817 | const inMatch = exp.match(forAliasRE);
|
12818 | if (!inMatch)
|
12819 | return;
|
12820 | const [, LHS, RHS] = inMatch;
|
12821 | const createAliasExpression = (content, offset, asParam = false) => {
|
12822 | const start = loc.start.offset + offset;
|
12823 | const end = start + content.length;
|
12824 | return createExp(
|
12825 | content,
|
12826 | false,
|
12827 | getLoc(start, end),
|
12828 | 0,
|
12829 | asParam ? 1 : 0
|
12830 | );
|
12831 | };
|
12832 | const result = {
|
12833 | source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
12834 | value: void 0,
|
12835 | key: void 0,
|
12836 | index: void 0,
|
12837 | finalized: false
|
12838 | };
|
12839 | let valueContent = LHS.trim().replace(stripParensRE, "").trim();
|
12840 | const trimmedOffset = LHS.indexOf(valueContent);
|
12841 | const iteratorMatch = valueContent.match(forIteratorRE);
|
12842 | if (iteratorMatch) {
|
12843 | valueContent = valueContent.replace(forIteratorRE, "").trim();
|
12844 | const keyContent = iteratorMatch[1].trim();
|
12845 | let keyOffset;
|
12846 | if (keyContent) {
|
12847 | keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
12848 | result.key = createAliasExpression(keyContent, keyOffset, true);
|
12849 | }
|
12850 | if (iteratorMatch[2]) {
|
12851 | const indexContent = iteratorMatch[2].trim();
|
12852 | if (indexContent) {
|
12853 | result.index = createAliasExpression(
|
12854 | indexContent,
|
12855 | exp.indexOf(
|
12856 | indexContent,
|
12857 | result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
12858 | ),
|
12859 | true
|
12860 | );
|
12861 | }
|
12862 | }
|
12863 | }
|
12864 | if (valueContent) {
|
12865 | result.value = createAliasExpression(valueContent, trimmedOffset, true);
|
12866 | }
|
12867 | return result;
|
12868 | }
|
12869 | function getSlice(start, end) {
|
12870 | return currentInput.slice(start, end);
|
12871 | }
|
12872 | function endOpenTag(end) {
|
12873 | if (tokenizer.inSFCRoot) {
|
12874 | currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
|
12875 | }
|
12876 | addNode(currentOpenTag);
|
12877 | const { tag, ns } = currentOpenTag;
|
12878 | if (ns === 0 && currentOptions.isPreTag(tag)) {
|
12879 | inPre++;
|
12880 | }
|
12881 | if (currentOptions.isVoidTag(tag)) {
|
12882 | onCloseTag(currentOpenTag, end);
|
12883 | } else {
|
12884 | stack.unshift(currentOpenTag);
|
12885 | if (ns === 1 || ns === 2) {
|
12886 | tokenizer.inXML = true;
|
12887 | }
|
12888 | }
|
12889 | currentOpenTag = null;
|
12890 | }
|
12891 | function onText(content, start, end) {
|
12892 | var _a;
|
12893 | {
|
12894 | const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
|
12895 | if (tag !== "script" && tag !== "style" && content.includes("&")) {
|
12896 | content = currentOptions.decodeEntities(content, false);
|
12897 | }
|
12898 | }
|
12899 | const parent = stack[0] || currentRoot;
|
12900 | const lastNode = parent.children[parent.children.length - 1];
|
12901 | if ((lastNode == null ? void 0 : lastNode.type) === 2) {
|
12902 | lastNode.content += content;
|
12903 | setLocEnd(lastNode.loc, end);
|
12904 | } else {
|
12905 | parent.children.push({
|
12906 | type: 2,
|
12907 | content,
|
12908 | loc: getLoc(start, end)
|
12909 | });
|
12910 | }
|
12911 | }
|
12912 | function onCloseTag(el, end, isImplied = false) {
|
12913 | if (isImplied) {
|
12914 | setLocEnd(el.loc, backTrack(end, 60));
|
12915 | } else {
|
12916 | setLocEnd(el.loc, end + 1);
|
12917 | }
|
12918 | if (tokenizer.inSFCRoot) {
|
12919 | if (el.children.length) {
|
12920 | el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
|
12921 | } else {
|
12922 | el.innerLoc.end = extend({}, el.innerLoc.start);
|
12923 | }
|
12924 | el.innerLoc.source = getSlice(
|
12925 | el.innerLoc.start.offset,
|
12926 | el.innerLoc.end.offset
|
12927 | );
|
12928 | }
|
12929 | const { tag, ns } = el;
|
12930 | if (!inVPre) {
|
12931 | if (tag === "slot") {
|
12932 | el.tagType = 2;
|
12933 | } else if (isFragmentTemplate(el)) {
|
12934 | el.tagType = 3;
|
12935 | } else if (isComponent(el)) {
|
12936 | el.tagType = 1;
|
12937 | }
|
12938 | }
|
12939 | if (!tokenizer.inRCDATA) {
|
12940 | el.children = condenseWhitespace(el.children, el.tag);
|
12941 | }
|
12942 | if (ns === 0 && currentOptions.isPreTag(tag)) {
|
12943 | inPre--;
|
12944 | }
|
12945 | if (currentVPreBoundary === el) {
|
12946 | inVPre = tokenizer.inVPre = false;
|
12947 | currentVPreBoundary = null;
|
12948 | }
|
12949 | if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
12950 | tokenizer.inXML = false;
|
12951 | }
|
12952 | }
|
12953 | function backTrack(index, c) {
|
12954 | let i = index;
|
12955 | while (currentInput.charCodeAt(i) !== c && i >= 0)
|
12956 | i--;
|
12957 | return i;
|
12958 | }
|
12959 | const specialTemplateDir = new Set(["if", "else", "else-if", "for", "slot"]);
|
12960 | function isFragmentTemplate({ tag, props }) {
|
12961 | if (tag === "template") {
|
12962 | for (let i = 0; i < props.length; i++) {
|
12963 | if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
|
12964 | return true;
|
12965 | }
|
12966 | }
|
12967 | }
|
12968 | return false;
|
12969 | }
|
12970 | function isComponent({ tag, props }) {
|
12971 | var _a;
|
12972 | if (currentOptions.isCustomElement(tag)) {
|
12973 | return false;
|
12974 | }
|
12975 | if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
|
12976 | return true;
|
12977 | }
|
12978 | for (let i = 0; i < props.length; i++) {
|
12979 | const p = props[i];
|
12980 | if (p.type === 6) {
|
12981 | if (p.name === "is" && p.value) {
|
12982 | if (p.value.content.startsWith("vue:")) {
|
12983 | return true;
|
12984 | }
|
12985 | }
|
12986 | }
|
12987 | }
|
12988 | return false;
|
12989 | }
|
12990 | function isUpperCase(c) {
|
12991 | return c > 64 && c < 91;
|
12992 | }
|
12993 | const windowsNewlineRE = /\r\n/g;
|
12994 | function condenseWhitespace(nodes, tag) {
|
12995 | var _a, _b;
|
12996 | const shouldCondense = currentOptions.whitespace !== "preserve";
|
12997 | let removedWhitespace = false;
|
12998 | for (let i = 0; i < nodes.length; i++) {
|
12999 | const node = nodes[i];
|
13000 | if (node.type === 2) {
|
13001 | if (!inPre) {
|
13002 | if (isAllWhitespace(node.content)) {
|
13003 | const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
|
13004 | const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
|
13005 | if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
|
13006 | removedWhitespace = true;
|
13007 | nodes[i] = null;
|
13008 | } else {
|
13009 | node.content = " ";
|
13010 | }
|
13011 | } else if (shouldCondense) {
|
13012 | node.content = condense(node.content);
|
13013 | }
|
13014 | } else {
|
13015 | node.content = node.content.replace(windowsNewlineRE, "\n");
|
13016 | }
|
13017 | }
|
13018 | }
|
13019 | if (inPre && tag && currentOptions.isPreTag(tag)) {
|
13020 | const first = nodes[0];
|
13021 | if (first && first.type === 2) {
|
13022 | first.content = first.content.replace(/^\r?\n/, "");
|
13023 | }
|
13024 | }
|
13025 | return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
13026 | }
|
13027 | function isAllWhitespace(str) {
|
13028 | for (let i = 0; i < str.length; i++) {
|
13029 | if (!isWhitespace(str.charCodeAt(i))) {
|
13030 | return false;
|
13031 | }
|
13032 | }
|
13033 | return true;
|
13034 | }
|
13035 | function hasNewlineChar(str) {
|
13036 | for (let i = 0; i < str.length; i++) {
|
13037 | const c = str.charCodeAt(i);
|
13038 | if (c === 10 || c === 13) {
|
13039 | return true;
|
13040 | }
|
13041 | }
|
13042 | return false;
|
13043 | }
|
13044 | function condense(str) {
|
13045 | let ret = "";
|
13046 | let prevCharIsWhitespace = false;
|
13047 | for (let i = 0; i < str.length; i++) {
|
13048 | if (isWhitespace(str.charCodeAt(i))) {
|
13049 | if (!prevCharIsWhitespace) {
|
13050 | ret += " ";
|
13051 | prevCharIsWhitespace = true;
|
13052 | }
|
13053 | } else {
|
13054 | ret += str[i];
|
13055 | prevCharIsWhitespace = false;
|
13056 | }
|
13057 | }
|
13058 | return ret;
|
13059 | }
|
13060 | function addNode(node) {
|
13061 | (stack[0] || currentRoot).children.push(node);
|
13062 | }
|
13063 | function getLoc(start, end) {
|
13064 | return {
|
13065 | start: tokenizer.getPos(start),
|
13066 |
|
13067 | end: end == null ? end : tokenizer.getPos(end),
|
13068 |
|
13069 | source: end == null ? end : getSlice(start, end)
|
13070 | };
|
13071 | }
|
13072 | function setLocEnd(loc, end) {
|
13073 | loc.end = tokenizer.getPos(end);
|
13074 | loc.source = getSlice(loc.start.offset, end);
|
13075 | }
|
13076 | function dirToAttr(dir) {
|
13077 | const attr = {
|
13078 | type: 6,
|
13079 | name: dir.rawName,
|
13080 | nameLoc: getLoc(
|
13081 | dir.loc.start.offset,
|
13082 | dir.loc.start.offset + dir.rawName.length
|
13083 | ),
|
13084 | value: void 0,
|
13085 | loc: dir.loc
|
13086 | };
|
13087 | if (dir.exp) {
|
13088 | const loc = dir.exp.loc;
|
13089 | if (loc.end.offset < dir.loc.end.offset) {
|
13090 | loc.start.offset--;
|
13091 | loc.start.column--;
|
13092 | loc.end.offset++;
|
13093 | loc.end.column++;
|
13094 | }
|
13095 | attr.value = {
|
13096 | type: 2,
|
13097 | content: dir.exp.content,
|
13098 | loc
|
13099 | };
|
13100 | }
|
13101 | return attr;
|
13102 | }
|
13103 | function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
|
13104 | const exp = createSimpleExpression(content, isStatic, loc, constType);
|
13105 | return exp;
|
13106 | }
|
13107 | function emitError(code, index, message) {
|
13108 | currentOptions.onError(
|
13109 | createCompilerError(code, getLoc(index, index), void 0, message)
|
13110 | );
|
13111 | }
|
13112 | function reset() {
|
13113 | tokenizer.reset();
|
13114 | currentOpenTag = null;
|
13115 | currentProp = null;
|
13116 | currentAttrValue = "";
|
13117 | currentAttrStartIndex = -1;
|
13118 | currentAttrEndIndex = -1;
|
13119 | stack.length = 0;
|
13120 | }
|
13121 | function baseParse(input, options) {
|
13122 | reset();
|
13123 | currentInput = input;
|
13124 | currentOptions = extend({}, defaultParserOptions);
|
13125 | if (options) {
|
13126 | let key;
|
13127 | for (key in options) {
|
13128 | if (options[key] != null) {
|
13129 | currentOptions[key] = options[key];
|
13130 | }
|
13131 | }
|
13132 | }
|
13133 | {
|
13134 | if (!currentOptions.decodeEntities) {
|
13135 | throw new Error(
|
13136 | `[@vue/compiler-core] decodeEntities option is required in browser builds.`
|
13137 | );
|
13138 | }
|
13139 | }
|
13140 | tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
13141 | tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
|
13142 | const delimiters = options == null ? void 0 : options.delimiters;
|
13143 | if (delimiters) {
|
13144 | tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
|
13145 | tokenizer.delimiterClose = toCharCodes(delimiters[1]);
|
13146 | }
|
13147 | const root = currentRoot = createRoot([], input);
|
13148 | tokenizer.parse(currentInput);
|
13149 | root.loc = getLoc(0, input.length);
|
13150 | root.children = condenseWhitespace(root.children);
|
13151 | currentRoot = null;
|
13152 | return root;
|
13153 | }
|
13154 |
|
13155 | function hoistStatic(root, context) {
|
13156 | walk(
|
13157 | root,
|
13158 | context,
|
13159 |
|
13160 |
|
13161 | isSingleElementRoot(root, root.children[0])
|
13162 | );
|
13163 | }
|
13164 | function isSingleElementRoot(root, child) {
|
13165 | const { children } = root;
|
13166 | return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
|
13167 | }
|
13168 | function walk(node, context, doNotHoistNode = false) {
|
13169 | const { children } = node;
|
13170 | const originalCount = children.length;
|
13171 | let hoistedCount = 0;
|
13172 | for (let i = 0; i < children.length; i++) {
|
13173 | const child = children[i];
|
13174 | if (child.type === 1 && child.tagType === 0) {
|
13175 | const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
13176 | if (constantType > 0) {
|
13177 | if (constantType >= 2) {
|
13178 | child.codegenNode.patchFlag = -1 + (` /* HOISTED */` );
|
13179 | child.codegenNode = context.hoist(child.codegenNode);
|
13180 | hoistedCount++;
|
13181 | continue;
|
13182 | }
|
13183 | } else {
|
13184 | const codegenNode = child.codegenNode;
|
13185 | if (codegenNode.type === 13) {
|
13186 | const flag = getPatchFlag(codegenNode);
|
13187 | if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
|
13188 | const props = getNodeProps(child);
|
13189 | if (props) {
|
13190 | codegenNode.props = context.hoist(props);
|
13191 | }
|
13192 | }
|
13193 | if (codegenNode.dynamicProps) {
|
13194 | codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
|
13195 | }
|
13196 | }
|
13197 | }
|
13198 | }
|
13199 | if (child.type === 1) {
|
13200 | const isComponent = child.tagType === 1;
|
13201 | if (isComponent) {
|
13202 | context.scopes.vSlot++;
|
13203 | }
|
13204 | walk(child, context);
|
13205 | if (isComponent) {
|
13206 | context.scopes.vSlot--;
|
13207 | }
|
13208 | } else if (child.type === 11) {
|
13209 | walk(child, context, child.children.length === 1);
|
13210 | } else if (child.type === 9) {
|
13211 | for (let i2 = 0; i2 < child.branches.length; i2++) {
|
13212 | walk(
|
13213 | child.branches[i2],
|
13214 | context,
|
13215 | child.branches[i2].children.length === 1
|
13216 | );
|
13217 | }
|
13218 | }
|
13219 | }
|
13220 | if (hoistedCount && context.transformHoist) {
|
13221 | context.transformHoist(children, context, node);
|
13222 | }
|
13223 | if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
|
13224 | const hoisted = context.hoist(
|
13225 | createArrayExpression(node.codegenNode.children)
|
13226 | );
|
13227 | if (context.hmr) {
|
13228 | hoisted.content = `[...${hoisted.content}]`;
|
13229 | }
|
13230 | node.codegenNode.children = hoisted;
|
13231 | }
|
13232 | }
|
13233 | function getConstantType(node, context) {
|
13234 | const { constantCache } = context;
|
13235 | switch (node.type) {
|
13236 | case 1:
|
13237 | if (node.tagType !== 0) {
|
13238 | return 0;
|
13239 | }
|
13240 | const cached = constantCache.get(node);
|
13241 | if (cached !== void 0) {
|
13242 | return cached;
|
13243 | }
|
13244 | const codegenNode = node.codegenNode;
|
13245 | if (codegenNode.type !== 13) {
|
13246 | return 0;
|
13247 | }
|
13248 | if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
|
13249 | return 0;
|
13250 | }
|
13251 | const flag = getPatchFlag(codegenNode);
|
13252 | if (!flag) {
|
13253 | let returnType2 = 3;
|
13254 | const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
13255 | if (generatedPropsType === 0) {
|
13256 | constantCache.set(node, 0);
|
13257 | return 0;
|
13258 | }
|
13259 | if (generatedPropsType < returnType2) {
|
13260 | returnType2 = generatedPropsType;
|
13261 | }
|
13262 | for (let i = 0; i < node.children.length; i++) {
|
13263 | const childType = getConstantType(node.children[i], context);
|
13264 | if (childType === 0) {
|
13265 | constantCache.set(node, 0);
|
13266 | return 0;
|
13267 | }
|
13268 | if (childType < returnType2) {
|
13269 | returnType2 = childType;
|
13270 | }
|
13271 | }
|
13272 | if (returnType2 > 1) {
|
13273 | for (let i = 0; i < node.props.length; i++) {
|
13274 | const p = node.props[i];
|
13275 | if (p.type === 7 && p.name === "bind" && p.exp) {
|
13276 | const expType = getConstantType(p.exp, context);
|
13277 | if (expType === 0) {
|
13278 | constantCache.set(node, 0);
|
13279 | return 0;
|
13280 | }
|
13281 | if (expType < returnType2) {
|
13282 | returnType2 = expType;
|
13283 | }
|
13284 | }
|
13285 | }
|
13286 | }
|
13287 | if (codegenNode.isBlock) {
|
13288 | for (let i = 0; i < node.props.length; i++) {
|
13289 | const p = node.props[i];
|
13290 | if (p.type === 7) {
|
13291 | constantCache.set(node, 0);
|
13292 | return 0;
|
13293 | }
|
13294 | }
|
13295 | context.removeHelper(OPEN_BLOCK);
|
13296 | context.removeHelper(
|
13297 | getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
|
13298 | );
|
13299 | codegenNode.isBlock = false;
|
13300 | context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
|
13301 | }
|
13302 | constantCache.set(node, returnType2);
|
13303 | return returnType2;
|
13304 | } else {
|
13305 | constantCache.set(node, 0);
|
13306 | return 0;
|
13307 | }
|
13308 | case 2:
|
13309 | case 3:
|
13310 | return 3;
|
13311 | case 9:
|
13312 | case 11:
|
13313 | case 10:
|
13314 | return 0;
|
13315 | case 5:
|
13316 | case 12:
|
13317 | return getConstantType(node.content, context);
|
13318 | case 4:
|
13319 | return node.constType;
|
13320 | case 8:
|
13321 | let returnType = 3;
|
13322 | for (let i = 0; i < node.children.length; i++) {
|
13323 | const child = node.children[i];
|
13324 | if (isString(child) || isSymbol(child)) {
|
13325 | continue;
|
13326 | }
|
13327 | const childType = getConstantType(child, context);
|
13328 | if (childType === 0) {
|
13329 | return 0;
|
13330 | } else if (childType < returnType) {
|
13331 | returnType = childType;
|
13332 | }
|
13333 | }
|
13334 | return returnType;
|
13335 | default:
|
13336 | return 0;
|
13337 | }
|
13338 | }
|
13339 | const allowHoistedHelperSet = new Set([
|
13340 | NORMALIZE_CLASS,
|
13341 | NORMALIZE_STYLE,
|
13342 | NORMALIZE_PROPS,
|
13343 | GUARD_REACTIVE_PROPS
|
13344 | ]);
|
13345 | function getConstantTypeOfHelperCall(value, context) {
|
13346 | if (value.type === 14 && !isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
|
13347 | const arg = value.arguments[0];
|
13348 | if (arg.type === 4) {
|
13349 | return getConstantType(arg, context);
|
13350 | } else if (arg.type === 14) {
|
13351 | return getConstantTypeOfHelperCall(arg, context);
|
13352 | }
|
13353 | }
|
13354 | return 0;
|
13355 | }
|
13356 | function getGeneratedPropsConstantType(node, context) {
|
13357 | let returnType = 3;
|
13358 | const props = getNodeProps(node);
|
13359 | if (props && props.type === 15) {
|
13360 | const { properties } = props;
|
13361 | for (let i = 0; i < properties.length; i++) {
|
13362 | const { key, value } = properties[i];
|
13363 | const keyType = getConstantType(key, context);
|
13364 | if (keyType === 0) {
|
13365 | return keyType;
|
13366 | }
|
13367 | if (keyType < returnType) {
|
13368 | returnType = keyType;
|
13369 | }
|
13370 | let valueType;
|
13371 | if (value.type === 4) {
|
13372 | valueType = getConstantType(value, context);
|
13373 | } else if (value.type === 14) {
|
13374 | valueType = getConstantTypeOfHelperCall(value, context);
|
13375 | } else {
|
13376 | valueType = 0;
|
13377 | }
|
13378 | if (valueType === 0) {
|
13379 | return valueType;
|
13380 | }
|
13381 | if (valueType < returnType) {
|
13382 | returnType = valueType;
|
13383 | }
|
13384 | }
|
13385 | }
|
13386 | return returnType;
|
13387 | }
|
13388 | function getNodeProps(node) {
|
13389 | const codegenNode = node.codegenNode;
|
13390 | if (codegenNode.type === 13) {
|
13391 | return codegenNode.props;
|
13392 | }
|
13393 | }
|
13394 | function getPatchFlag(node) {
|
13395 | const flag = node.patchFlag;
|
13396 | return flag ? parseInt(flag, 10) : void 0;
|
13397 | }
|
13398 |
|
13399 | function createTransformContext(root, {
|
13400 | filename = "",
|
13401 | prefixIdentifiers = false,
|
13402 | hoistStatic: hoistStatic2 = false,
|
13403 | hmr = false,
|
13404 | cacheHandlers = false,
|
13405 | nodeTransforms = [],
|
13406 | directiveTransforms = {},
|
13407 | transformHoist = null,
|
13408 | isBuiltInComponent = NOOP,
|
13409 | isCustomElement = NOOP,
|
13410 | expressionPlugins = [],
|
13411 | scopeId = null,
|
13412 | slotted = true,
|
13413 | ssr = false,
|
13414 | inSSR = false,
|
13415 | ssrCssVars = ``,
|
13416 | bindingMetadata = EMPTY_OBJ,
|
13417 | inline = false,
|
13418 | isTS = false,
|
13419 | onError = defaultOnError,
|
13420 | onWarn = defaultOnWarn,
|
13421 | compatConfig
|
13422 | }) {
|
13423 | const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
13424 | const context = {
|
13425 |
|
13426 | filename,
|
13427 | selfName: nameMatch && capitalize(camelize(nameMatch[1])),
|
13428 | prefixIdentifiers,
|
13429 | hoistStatic: hoistStatic2,
|
13430 | hmr,
|
13431 | cacheHandlers,
|
13432 | nodeTransforms,
|
13433 | directiveTransforms,
|
13434 | transformHoist,
|
13435 | isBuiltInComponent,
|
13436 | isCustomElement,
|
13437 | expressionPlugins,
|
13438 | scopeId,
|
13439 | slotted,
|
13440 | ssr,
|
13441 | inSSR,
|
13442 | ssrCssVars,
|
13443 | bindingMetadata,
|
13444 | inline,
|
13445 | isTS,
|
13446 | onError,
|
13447 | onWarn,
|
13448 | compatConfig,
|
13449 |
|
13450 | root,
|
13451 | helpers: new Map(),
|
13452 | components: new Set(),
|
13453 | directives: new Set(),
|
13454 | hoists: [],
|
13455 | imports: [],
|
13456 | constantCache: new WeakMap(),
|
13457 | temps: 0,
|
13458 | cached: 0,
|
13459 | identifiers: Object.create(null),
|
13460 | scopes: {
|
13461 | vFor: 0,
|
13462 | vSlot: 0,
|
13463 | vPre: 0,
|
13464 | vOnce: 0
|
13465 | },
|
13466 | parent: null,
|
13467 | currentNode: root,
|
13468 | childIndex: 0,
|
13469 | inVOnce: false,
|
13470 |
|
13471 | helper(name) {
|
13472 | const count = context.helpers.get(name) || 0;
|
13473 | context.helpers.set(name, count + 1);
|
13474 | return name;
|
13475 | },
|
13476 | removeHelper(name) {
|
13477 | const count = context.helpers.get(name);
|
13478 | if (count) {
|
13479 | const currentCount = count - 1;
|
13480 | if (!currentCount) {
|
13481 | context.helpers.delete(name);
|
13482 | } else {
|
13483 | context.helpers.set(name, currentCount);
|
13484 | }
|
13485 | }
|
13486 | },
|
13487 | helperString(name) {
|
13488 | return `_${helperNameMap[context.helper(name)]}`;
|
13489 | },
|
13490 | replaceNode(node) {
|
13491 | {
|
13492 | if (!context.currentNode) {
|
13493 | throw new Error(`Node being replaced is already removed.`);
|
13494 | }
|
13495 | if (!context.parent) {
|
13496 | throw new Error(`Cannot replace root node.`);
|
13497 | }
|
13498 | }
|
13499 | context.parent.children[context.childIndex] = context.currentNode = node;
|
13500 | },
|
13501 | removeNode(node) {
|
13502 | if (!context.parent) {
|
13503 | throw new Error(`Cannot remove root node.`);
|
13504 | }
|
13505 | const list = context.parent.children;
|
13506 | const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
|
13507 | if (removalIndex < 0) {
|
13508 | throw new Error(`node being removed is not a child of current parent`);
|
13509 | }
|
13510 | if (!node || node === context.currentNode) {
|
13511 | context.currentNode = null;
|
13512 | context.onNodeRemoved();
|
13513 | } else {
|
13514 | if (context.childIndex > removalIndex) {
|
13515 | context.childIndex--;
|
13516 | context.onNodeRemoved();
|
13517 | }
|
13518 | }
|
13519 | context.parent.children.splice(removalIndex, 1);
|
13520 | },
|
13521 | onNodeRemoved: NOOP,
|
13522 | addIdentifiers(exp) {
|
13523 | },
|
13524 | removeIdentifiers(exp) {
|
13525 | },
|
13526 | hoist(exp) {
|
13527 | if (isString(exp))
|
13528 | exp = createSimpleExpression(exp);
|
13529 | context.hoists.push(exp);
|
13530 | const identifier = createSimpleExpression(
|
13531 | `_hoisted_${context.hoists.length}`,
|
13532 | false,
|
13533 | exp.loc,
|
13534 | 2
|
13535 | );
|
13536 | identifier.hoisted = exp;
|
13537 | return identifier;
|
13538 | },
|
13539 | cache(exp, isVNode = false) {
|
13540 | return createCacheExpression(context.cached++, exp, isVNode);
|
13541 | }
|
13542 | };
|
13543 | return context;
|
13544 | }
|
13545 | function transform(root, options) {
|
13546 | const context = createTransformContext(root, options);
|
13547 | traverseNode(root, context);
|
13548 | if (options.hoistStatic) {
|
13549 | hoistStatic(root, context);
|
13550 | }
|
13551 | if (!options.ssr) {
|
13552 | createRootCodegen(root, context);
|
13553 | }
|
13554 | root.helpers = new Set([...context.helpers.keys()]);
|
13555 | root.components = [...context.components];
|
13556 | root.directives = [...context.directives];
|
13557 | root.imports = context.imports;
|
13558 | root.hoists = context.hoists;
|
13559 | root.temps = context.temps;
|
13560 | root.cached = context.cached;
|
13561 | root.transformed = true;
|
13562 | }
|
13563 | function createRootCodegen(root, context) {
|
13564 | const { helper } = context;
|
13565 | const { children } = root;
|
13566 | if (children.length === 1) {
|
13567 | const child = children[0];
|
13568 | if (isSingleElementRoot(root, child) && child.codegenNode) {
|
13569 | const codegenNode = child.codegenNode;
|
13570 | if (codegenNode.type === 13) {
|
13571 | convertToBlock(codegenNode, context);
|
13572 | }
|
13573 | root.codegenNode = codegenNode;
|
13574 | } else {
|
13575 | root.codegenNode = child;
|
13576 | }
|
13577 | } else if (children.length > 1) {
|
13578 | let patchFlag = 64;
|
13579 | let patchFlagText = PatchFlagNames[64];
|
13580 | if (children.filter((c) => c.type !== 3).length === 1) {
|
13581 | patchFlag |= 2048;
|
13582 | patchFlagText += `, ${PatchFlagNames[2048]}`;
|
13583 | }
|
13584 | root.codegenNode = createVNodeCall(
|
13585 | context,
|
13586 | helper(FRAGMENT),
|
13587 | void 0,
|
13588 | root.children,
|
13589 | patchFlag + (` /* ${patchFlagText} */` ),
|
13590 | void 0,
|
13591 | void 0,
|
13592 | true,
|
13593 | void 0,
|
13594 | false
|
13595 | );
|
13596 | } else ;
|
13597 | }
|
13598 | function traverseChildren(parent, context) {
|
13599 | let i = 0;
|
13600 | const nodeRemoved = () => {
|
13601 | i--;
|
13602 | };
|
13603 | for (; i < parent.children.length; i++) {
|
13604 | const child = parent.children[i];
|
13605 | if (isString(child))
|
13606 | continue;
|
13607 | context.parent = parent;
|
13608 | context.childIndex = i;
|
13609 | context.onNodeRemoved = nodeRemoved;
|
13610 | traverseNode(child, context);
|
13611 | }
|
13612 | }
|
13613 | function traverseNode(node, context) {
|
13614 | context.currentNode = node;
|
13615 | const { nodeTransforms } = context;
|
13616 | const exitFns = [];
|
13617 | for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
|
13618 | const onExit = nodeTransforms[i2](node, context);
|
13619 | if (onExit) {
|
13620 | if (isArray(onExit)) {
|
13621 | exitFns.push(...onExit);
|
13622 | } else {
|
13623 | exitFns.push(onExit);
|
13624 | }
|
13625 | }
|
13626 | if (!context.currentNode) {
|
13627 | return;
|
13628 | } else {
|
13629 | node = context.currentNode;
|
13630 | }
|
13631 | }
|
13632 | switch (node.type) {
|
13633 | case 3:
|
13634 | if (!context.ssr) {
|
13635 | context.helper(CREATE_COMMENT);
|
13636 | }
|
13637 | break;
|
13638 | case 5:
|
13639 | if (!context.ssr) {
|
13640 | context.helper(TO_DISPLAY_STRING);
|
13641 | }
|
13642 | break;
|
13643 | case 9:
|
13644 | for (let i2 = 0; i2 < node.branches.length; i2++) {
|
13645 | traverseNode(node.branches[i2], context);
|
13646 | }
|
13647 | break;
|
13648 | case 10:
|
13649 | case 11:
|
13650 | case 1:
|
13651 | case 0:
|
13652 | traverseChildren(node, context);
|
13653 | break;
|
13654 | }
|
13655 | context.currentNode = node;
|
13656 | let i = exitFns.length;
|
13657 | while (i--) {
|
13658 | exitFns[i]();
|
13659 | }
|
13660 | }
|
13661 | function createStructuralDirectiveTransform(name, fn) {
|
13662 | const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
|
13663 | return (node, context) => {
|
13664 | if (node.type === 1) {
|
13665 | const { props } = node;
|
13666 | if (node.tagType === 3 && props.some(isVSlot)) {
|
13667 | return;
|
13668 | }
|
13669 | const exitFns = [];
|
13670 | for (let i = 0; i < props.length; i++) {
|
13671 | const prop = props[i];
|
13672 | if (prop.type === 7 && matches(prop.name)) {
|
13673 | props.splice(i, 1);
|
13674 | i--;
|
13675 | const onExit = fn(node, prop, context);
|
13676 | if (onExit)
|
13677 | exitFns.push(onExit);
|
13678 | }
|
13679 | }
|
13680 | return exitFns;
|
13681 | }
|
13682 | };
|
13683 | }
|
13684 |
|
13685 | const PURE_ANNOTATION = `/*#__PURE__*/`;
|
13686 | const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
13687 | function createCodegenContext(ast, {
|
13688 | mode = "function",
|
13689 | prefixIdentifiers = mode === "module",
|
13690 | sourceMap = false,
|
13691 | filename = `template.vue.html`,
|
13692 | scopeId = null,
|
13693 | optimizeImports = false,
|
13694 | runtimeGlobalName = `Vue`,
|
13695 | runtimeModuleName = `vue`,
|
13696 | ssrRuntimeModuleName = "vue/server-renderer",
|
13697 | ssr = false,
|
13698 | isTS = false,
|
13699 | inSSR = false
|
13700 | }) {
|
13701 | const context = {
|
13702 | mode,
|
13703 | prefixIdentifiers,
|
13704 | sourceMap,
|
13705 | filename,
|
13706 | scopeId,
|
13707 | optimizeImports,
|
13708 | runtimeGlobalName,
|
13709 | runtimeModuleName,
|
13710 | ssrRuntimeModuleName,
|
13711 | ssr,
|
13712 | isTS,
|
13713 | inSSR,
|
13714 | source: ast.source,
|
13715 | code: ``,
|
13716 | column: 1,
|
13717 | line: 1,
|
13718 | offset: 0,
|
13719 | indentLevel: 0,
|
13720 | pure: false,
|
13721 | map: void 0,
|
13722 | helper(key) {
|
13723 | return `_${helperNameMap[key]}`;
|
13724 | },
|
13725 | push(code, newlineIndex = -2 , node) {
|
13726 | context.code += code;
|
13727 | },
|
13728 | indent() {
|
13729 | newline(++context.indentLevel);
|
13730 | },
|
13731 | deindent(withoutNewLine = false) {
|
13732 | if (withoutNewLine) {
|
13733 | --context.indentLevel;
|
13734 | } else {
|
13735 | newline(--context.indentLevel);
|
13736 | }
|
13737 | },
|
13738 | newline() {
|
13739 | newline(context.indentLevel);
|
13740 | }
|
13741 | };
|
13742 | function newline(n) {
|
13743 | context.push("\n" + ` `.repeat(n), 0 );
|
13744 | }
|
13745 | return context;
|
13746 | }
|
13747 | function generate(ast, options = {}) {
|
13748 | const context = createCodegenContext(ast, options);
|
13749 | if (options.onContextCreated)
|
13750 | options.onContextCreated(context);
|
13751 | const {
|
13752 | mode,
|
13753 | push,
|
13754 | prefixIdentifiers,
|
13755 | indent,
|
13756 | deindent,
|
13757 | newline,
|
13758 | scopeId,
|
13759 | ssr
|
13760 | } = context;
|
13761 | const helpers = Array.from(ast.helpers);
|
13762 | const hasHelpers = helpers.length > 0;
|
13763 | const useWithBlock = !prefixIdentifiers && mode !== "module";
|
13764 | const preambleContext = context;
|
13765 | {
|
13766 | genFunctionPreamble(ast, preambleContext);
|
13767 | }
|
13768 | const functionName = ssr ? `ssrRender` : `render`;
|
13769 | const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
|
13770 | const signature = args.join(", ");
|
13771 | {
|
13772 | push(`function ${functionName}(${signature}) {`);
|
13773 | }
|
13774 | indent();
|
13775 | if (useWithBlock) {
|
13776 | push(`with (_ctx) {`);
|
13777 | indent();
|
13778 | if (hasHelpers) {
|
13779 | push(
|
13780 | `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
13781 | `,
|
13782 | -1
|
13783 | );
|
13784 | newline();
|
13785 | }
|
13786 | }
|
13787 | if (ast.components.length) {
|
13788 | genAssets(ast.components, "component", context);
|
13789 | if (ast.directives.length || ast.temps > 0) {
|
13790 | newline();
|
13791 | }
|
13792 | }
|
13793 | if (ast.directives.length) {
|
13794 | genAssets(ast.directives, "directive", context);
|
13795 | if (ast.temps > 0) {
|
13796 | newline();
|
13797 | }
|
13798 | }
|
13799 | if (ast.temps > 0) {
|
13800 | push(`let `);
|
13801 | for (let i = 0; i < ast.temps; i++) {
|
13802 | push(`${i > 0 ? `, ` : ``}_temp${i}`);
|
13803 | }
|
13804 | }
|
13805 | if (ast.components.length || ast.directives.length || ast.temps) {
|
13806 | push(`
|
13807 | `, 0 );
|
13808 | newline();
|
13809 | }
|
13810 | if (!ssr) {
|
13811 | push(`return `);
|
13812 | }
|
13813 | if (ast.codegenNode) {
|
13814 | genNode(ast.codegenNode, context);
|
13815 | } else {
|
13816 | push(`null`);
|
13817 | }
|
13818 | if (useWithBlock) {
|
13819 | deindent();
|
13820 | push(`}`);
|
13821 | }
|
13822 | deindent();
|
13823 | push(`}`);
|
13824 | return {
|
13825 | ast,
|
13826 | code: context.code,
|
13827 | preamble: ``,
|
13828 | map: context.map ? context.map.toJSON() : void 0
|
13829 | };
|
13830 | }
|
13831 | function genFunctionPreamble(ast, context) {
|
13832 | const {
|
13833 | ssr,
|
13834 | prefixIdentifiers,
|
13835 | push,
|
13836 | newline,
|
13837 | runtimeModuleName,
|
13838 | runtimeGlobalName,
|
13839 | ssrRuntimeModuleName
|
13840 | } = context;
|
13841 | const VueBinding = runtimeGlobalName;
|
13842 | const helpers = Array.from(ast.helpers);
|
13843 | if (helpers.length > 0) {
|
13844 | {
|
13845 | push(`const _Vue = ${VueBinding}
|
13846 | `, -1 );
|
13847 | if (ast.hoists.length) {
|
13848 | const staticHelpers = [
|
13849 | CREATE_VNODE,
|
13850 | CREATE_ELEMENT_VNODE,
|
13851 | CREATE_COMMENT,
|
13852 | CREATE_TEXT,
|
13853 | CREATE_STATIC
|
13854 | ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
13855 | push(`const { ${staticHelpers} } = _Vue
|
13856 | `, -1 );
|
13857 | }
|
13858 | }
|
13859 | }
|
13860 | genHoists(ast.hoists, context);
|
13861 | newline();
|
13862 | push(`return `);
|
13863 | }
|
13864 | function genAssets(assets, type, { helper, push, newline, isTS }) {
|
13865 | const resolver = helper(
|
13866 | type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
|
13867 | );
|
13868 | for (let i = 0; i < assets.length; i++) {
|
13869 | let id = assets[i];
|
13870 | const maybeSelfReference = id.endsWith("__self");
|
13871 | if (maybeSelfReference) {
|
13872 | id = id.slice(0, -6);
|
13873 | }
|
13874 | push(
|
13875 | `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
|
13876 | );
|
13877 | if (i < assets.length - 1) {
|
13878 | newline();
|
13879 | }
|
13880 | }
|
13881 | }
|
13882 | function genHoists(hoists, context) {
|
13883 | if (!hoists.length) {
|
13884 | return;
|
13885 | }
|
13886 | context.pure = true;
|
13887 | const { push, newline, helper, scopeId, mode } = context;
|
13888 | newline();
|
13889 | for (let i = 0; i < hoists.length; i++) {
|
13890 | const exp = hoists[i];
|
13891 | if (exp) {
|
13892 | push(
|
13893 | `const _hoisted_${i + 1} = ${``}`
|
13894 | );
|
13895 | genNode(exp, context);
|
13896 | newline();
|
13897 | }
|
13898 | }
|
13899 | context.pure = false;
|
13900 | }
|
13901 | function isText(n) {
|
13902 | return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
|
13903 | }
|
13904 | function genNodeListAsArray(nodes, context) {
|
13905 | const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText(n));
|
13906 | context.push(`[`);
|
13907 | multilines && context.indent();
|
13908 | genNodeList(nodes, context, multilines);
|
13909 | multilines && context.deindent();
|
13910 | context.push(`]`);
|
13911 | }
|
13912 | function genNodeList(nodes, context, multilines = false, comma = true) {
|
13913 | const { push, newline } = context;
|
13914 | for (let i = 0; i < nodes.length; i++) {
|
13915 | const node = nodes[i];
|
13916 | if (isString(node)) {
|
13917 | push(node, -3 );
|
13918 | } else if (isArray(node)) {
|
13919 | genNodeListAsArray(node, context);
|
13920 | } else {
|
13921 | genNode(node, context);
|
13922 | }
|
13923 | if (i < nodes.length - 1) {
|
13924 | if (multilines) {
|
13925 | comma && push(",");
|
13926 | newline();
|
13927 | } else {
|
13928 | comma && push(", ");
|
13929 | }
|
13930 | }
|
13931 | }
|
13932 | }
|
13933 | function genNode(node, context) {
|
13934 | if (isString(node)) {
|
13935 | context.push(node, -3 );
|
13936 | return;
|
13937 | }
|
13938 | if (isSymbol(node)) {
|
13939 | context.push(context.helper(node));
|
13940 | return;
|
13941 | }
|
13942 | switch (node.type) {
|
13943 | case 1:
|
13944 | case 9:
|
13945 | case 11:
|
13946 | assert(
|
13947 | node.codegenNode != null,
|
13948 | `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
|
13949 | );
|
13950 | genNode(node.codegenNode, context);
|
13951 | break;
|
13952 | case 2:
|
13953 | genText(node, context);
|
13954 | break;
|
13955 | case 4:
|
13956 | genExpression(node, context);
|
13957 | break;
|
13958 | case 5:
|
13959 | genInterpolation(node, context);
|
13960 | break;
|
13961 | case 12:
|
13962 | genNode(node.codegenNode, context);
|
13963 | break;
|
13964 | case 8:
|
13965 | genCompoundExpression(node, context);
|
13966 | break;
|
13967 | case 3:
|
13968 | genComment(node, context);
|
13969 | break;
|
13970 | case 13:
|
13971 | genVNodeCall(node, context);
|
13972 | break;
|
13973 | case 14:
|
13974 | genCallExpression(node, context);
|
13975 | break;
|
13976 | case 15:
|
13977 | genObjectExpression(node, context);
|
13978 | break;
|
13979 | case 17:
|
13980 | genArrayExpression(node, context);
|
13981 | break;
|
13982 | case 18:
|
13983 | genFunctionExpression(node, context);
|
13984 | break;
|
13985 | case 19:
|
13986 | genConditionalExpression(node, context);
|
13987 | break;
|
13988 | case 20:
|
13989 | genCacheExpression(node, context);
|
13990 | break;
|
13991 | case 21:
|
13992 | genNodeList(node.body, context, true, false);
|
13993 | break;
|
13994 | case 22:
|
13995 | break;
|
13996 | case 23:
|
13997 | break;
|
13998 | case 24:
|
13999 | break;
|
14000 | case 25:
|
14001 | break;
|
14002 | case 26:
|
14003 | break;
|
14004 | case 10:
|
14005 | break;
|
14006 | default:
|
14007 | {
|
14008 | assert(false, `unhandled codegen node type: ${node.type}`);
|
14009 | const exhaustiveCheck = node;
|
14010 | return exhaustiveCheck;
|
14011 | }
|
14012 | }
|
14013 | }
|
14014 | function genText(node, context) {
|
14015 | context.push(JSON.stringify(node.content), -3 , node);
|
14016 | }
|
14017 | function genExpression(node, context) {
|
14018 | const { content, isStatic } = node;
|
14019 | context.push(
|
14020 | isStatic ? JSON.stringify(content) : content,
|
14021 | -3 ,
|
14022 | node
|
14023 | );
|
14024 | }
|
14025 | function genInterpolation(node, context) {
|
14026 | const { push, helper, pure } = context;
|
14027 | if (pure)
|
14028 | push(PURE_ANNOTATION);
|
14029 | push(`${helper(TO_DISPLAY_STRING)}(`);
|
14030 | genNode(node.content, context);
|
14031 | push(`)`);
|
14032 | }
|
14033 | function genCompoundExpression(node, context) {
|
14034 | for (let i = 0; i < node.children.length; i++) {
|
14035 | const child = node.children[i];
|
14036 | if (isString(child)) {
|
14037 | context.push(child, -3 );
|
14038 | } else {
|
14039 | genNode(child, context);
|
14040 | }
|
14041 | }
|
14042 | }
|
14043 | function genExpressionAsPropertyKey(node, context) {
|
14044 | const { push } = context;
|
14045 | if (node.type === 8) {
|
14046 | push(`[`);
|
14047 | genCompoundExpression(node, context);
|
14048 | push(`]`);
|
14049 | } else if (node.isStatic) {
|
14050 | const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
14051 | push(text, -2 , node);
|
14052 | } else {
|
14053 | push(`[${node.content}]`, -3 , node);
|
14054 | }
|
14055 | }
|
14056 | function genComment(node, context) {
|
14057 | const { push, helper, pure } = context;
|
14058 | if (pure) {
|
14059 | push(PURE_ANNOTATION);
|
14060 | }
|
14061 | push(
|
14062 | `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
14063 | -3 ,
|
14064 | node
|
14065 | );
|
14066 | }
|
14067 | function genVNodeCall(node, context) {
|
14068 | const { push, helper, pure } = context;
|
14069 | const {
|
14070 | tag,
|
14071 | props,
|
14072 | children,
|
14073 | patchFlag,
|
14074 | dynamicProps,
|
14075 | directives,
|
14076 | isBlock,
|
14077 | disableTracking,
|
14078 | isComponent
|
14079 | } = node;
|
14080 | if (directives) {
|
14081 | push(helper(WITH_DIRECTIVES) + `(`);
|
14082 | }
|
14083 | if (isBlock) {
|
14084 | push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
|
14085 | }
|
14086 | if (pure) {
|
14087 | push(PURE_ANNOTATION);
|
14088 | }
|
14089 | const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
14090 | push(helper(callHelper) + `(`, -2 , node);
|
14091 | genNodeList(
|
14092 | genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
|
14093 | context
|
14094 | );
|
14095 | push(`)`);
|
14096 | if (isBlock) {
|
14097 | push(`)`);
|
14098 | }
|
14099 | if (directives) {
|
14100 | push(`, `);
|
14101 | genNode(directives, context);
|
14102 | push(`)`);
|
14103 | }
|
14104 | }
|
14105 | function genNullableArgs(args) {
|
14106 | let i = args.length;
|
14107 | while (i--) {
|
14108 | if (args[i] != null)
|
14109 | break;
|
14110 | }
|
14111 | return args.slice(0, i + 1).map((arg) => arg || `null`);
|
14112 | }
|
14113 | function genCallExpression(node, context) {
|
14114 | const { push, helper, pure } = context;
|
14115 | const callee = isString(node.callee) ? node.callee : helper(node.callee);
|
14116 | if (pure) {
|
14117 | push(PURE_ANNOTATION);
|
14118 | }
|
14119 | push(callee + `(`, -2 , node);
|
14120 | genNodeList(node.arguments, context);
|
14121 | push(`)`);
|
14122 | }
|
14123 | function genObjectExpression(node, context) {
|
14124 | const { push, indent, deindent, newline } = context;
|
14125 | const { properties } = node;
|
14126 | if (!properties.length) {
|
14127 | push(`{}`, -2 , node);
|
14128 | return;
|
14129 | }
|
14130 | const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
14131 | push(multilines ? `{` : `{ `);
|
14132 | multilines && indent();
|
14133 | for (let i = 0; i < properties.length; i++) {
|
14134 | const { key, value } = properties[i];
|
14135 | genExpressionAsPropertyKey(key, context);
|
14136 | push(`: `);
|
14137 | genNode(value, context);
|
14138 | if (i < properties.length - 1) {
|
14139 | push(`,`);
|
14140 | newline();
|
14141 | }
|
14142 | }
|
14143 | multilines && deindent();
|
14144 | push(multilines ? `}` : ` }`);
|
14145 | }
|
14146 | function genArrayExpression(node, context) {
|
14147 | genNodeListAsArray(node.elements, context);
|
14148 | }
|
14149 | function genFunctionExpression(node, context) {
|
14150 | const { push, indent, deindent } = context;
|
14151 | const { params, returns, body, newline, isSlot } = node;
|
14152 | if (isSlot) {
|
14153 | push(`_${helperNameMap[WITH_CTX]}(`);
|
14154 | }
|
14155 | push(`(`, -2 , node);
|
14156 | if (isArray(params)) {
|
14157 | genNodeList(params, context);
|
14158 | } else if (params) {
|
14159 | genNode(params, context);
|
14160 | }
|
14161 | push(`) => `);
|
14162 | if (newline || body) {
|
14163 | push(`{`);
|
14164 | indent();
|
14165 | }
|
14166 | if (returns) {
|
14167 | if (newline) {
|
14168 | push(`return `);
|
14169 | }
|
14170 | if (isArray(returns)) {
|
14171 | genNodeListAsArray(returns, context);
|
14172 | } else {
|
14173 | genNode(returns, context);
|
14174 | }
|
14175 | } else if (body) {
|
14176 | genNode(body, context);
|
14177 | }
|
14178 | if (newline || body) {
|
14179 | deindent();
|
14180 | push(`}`);
|
14181 | }
|
14182 | if (isSlot) {
|
14183 | push(`)`);
|
14184 | }
|
14185 | }
|
14186 | function genConditionalExpression(node, context) {
|
14187 | const { test, consequent, alternate, newline: needNewline } = node;
|
14188 | const { push, indent, deindent, newline } = context;
|
14189 | if (test.type === 4) {
|
14190 | const needsParens = !isSimpleIdentifier(test.content);
|
14191 | needsParens && push(`(`);
|
14192 | genExpression(test, context);
|
14193 | needsParens && push(`)`);
|
14194 | } else {
|
14195 | push(`(`);
|
14196 | genNode(test, context);
|
14197 | push(`)`);
|
14198 | }
|
14199 | needNewline && indent();
|
14200 | context.indentLevel++;
|
14201 | needNewline || push(` `);
|
14202 | push(`? `);
|
14203 | genNode(consequent, context);
|
14204 | context.indentLevel--;
|
14205 | needNewline && newline();
|
14206 | needNewline || push(` `);
|
14207 | push(`: `);
|
14208 | const isNested = alternate.type === 19;
|
14209 | if (!isNested) {
|
14210 | context.indentLevel++;
|
14211 | }
|
14212 | genNode(alternate, context);
|
14213 | if (!isNested) {
|
14214 | context.indentLevel--;
|
14215 | }
|
14216 | needNewline && deindent(
|
14217 | true
|
14218 |
|
14219 | );
|
14220 | }
|
14221 | function genCacheExpression(node, context) {
|
14222 | const { push, helper, indent, deindent, newline } = context;
|
14223 | push(`_cache[${node.index}] || (`);
|
14224 | if (node.isVNode) {
|
14225 | indent();
|
14226 | push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
|
14227 | newline();
|
14228 | }
|
14229 | push(`_cache[${node.index}] = `);
|
14230 | genNode(node.value, context);
|
14231 | if (node.isVNode) {
|
14232 | push(`,`);
|
14233 | newline();
|
14234 | push(`${helper(SET_BLOCK_TRACKING)}(1),`);
|
14235 | newline();
|
14236 | push(`_cache[${node.index}]`);
|
14237 | deindent();
|
14238 | }
|
14239 | push(`)`);
|
14240 | }
|
14241 |
|
14242 | const prohibitedKeywordRE = new RegExp(
|
14243 | "\\b" + "arguments,await,break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,let,new,return,super,switch,throw,try,var,void,while,with,yield".split(",").join("\\b|\\b") + "\\b"
|
14244 | );
|
14245 | const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
|
14246 | function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
|
14247 | const exp = node.content;
|
14248 | if (!exp.trim()) {
|
14249 | return;
|
14250 | }
|
14251 | try {
|
14252 | new Function(
|
14253 | asRawStatements ? ` ${exp} ` : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`
|
14254 | );
|
14255 | } catch (e) {
|
14256 | let message = e.message;
|
14257 | const keywordMatch = exp.replace(stripStringRE, "").match(prohibitedKeywordRE);
|
14258 | if (keywordMatch) {
|
14259 | message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
|
14260 | }
|
14261 | context.onError(
|
14262 | createCompilerError(
|
14263 | 45,
|
14264 | node.loc,
|
14265 | void 0,
|
14266 | message
|
14267 | )
|
14268 | );
|
14269 | }
|
14270 | }
|
14271 |
|
14272 | const transformExpression = (node, context) => {
|
14273 | if (node.type === 5) {
|
14274 | node.content = processExpression(
|
14275 | node.content,
|
14276 | context
|
14277 | );
|
14278 | } else if (node.type === 1) {
|
14279 | for (let i = 0; i < node.props.length; i++) {
|
14280 | const dir = node.props[i];
|
14281 | if (dir.type === 7 && dir.name !== "for") {
|
14282 | const exp = dir.exp;
|
14283 | const arg = dir.arg;
|
14284 | if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
|
14285 | dir.exp = processExpression(
|
14286 | exp,
|
14287 | context,
|
14288 |
|
14289 | dir.name === "slot"
|
14290 | );
|
14291 | }
|
14292 | if (arg && arg.type === 4 && !arg.isStatic) {
|
14293 | dir.arg = processExpression(arg, context);
|
14294 | }
|
14295 | }
|
14296 | }
|
14297 | }
|
14298 | };
|
14299 | function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
14300 | {
|
14301 | {
|
14302 | validateBrowserExpression(node, context, asParams, asRawStatements);
|
14303 | }
|
14304 | return node;
|
14305 | }
|
14306 | }
|
14307 |
|
14308 | const transformIf = createStructuralDirectiveTransform(
|
14309 | /^(if|else|else-if)$/,
|
14310 | (node, dir, context) => {
|
14311 | return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
14312 | const siblings = context.parent.children;
|
14313 | let i = siblings.indexOf(ifNode);
|
14314 | let key = 0;
|
14315 | while (i-- >= 0) {
|
14316 | const sibling = siblings[i];
|
14317 | if (sibling && sibling.type === 9) {
|
14318 | key += sibling.branches.length;
|
14319 | }
|
14320 | }
|
14321 | return () => {
|
14322 | if (isRoot) {
|
14323 | ifNode.codegenNode = createCodegenNodeForBranch(
|
14324 | branch,
|
14325 | key,
|
14326 | context
|
14327 | );
|
14328 | } else {
|
14329 | const parentCondition = getParentCondition(ifNode.codegenNode);
|
14330 | parentCondition.alternate = createCodegenNodeForBranch(
|
14331 | branch,
|
14332 | key + ifNode.branches.length - 1,
|
14333 | context
|
14334 | );
|
14335 | }
|
14336 | };
|
14337 | });
|
14338 | }
|
14339 | );
|
14340 | function processIf(node, dir, context, processCodegen) {
|
14341 | if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
|
14342 | const loc = dir.exp ? dir.exp.loc : node.loc;
|
14343 | context.onError(
|
14344 | createCompilerError(28, dir.loc)
|
14345 | );
|
14346 | dir.exp = createSimpleExpression(`true`, false, loc);
|
14347 | }
|
14348 | if (dir.exp) {
|
14349 | validateBrowserExpression(dir.exp, context);
|
14350 | }
|
14351 | if (dir.name === "if") {
|
14352 | const branch = createIfBranch(node, dir);
|
14353 | const ifNode = {
|
14354 | type: 9,
|
14355 | loc: node.loc,
|
14356 | branches: [branch]
|
14357 | };
|
14358 | context.replaceNode(ifNode);
|
14359 | if (processCodegen) {
|
14360 | return processCodegen(ifNode, branch, true);
|
14361 | }
|
14362 | } else {
|
14363 | const siblings = context.parent.children;
|
14364 | const comments = [];
|
14365 | let i = siblings.indexOf(node);
|
14366 | while (i-- >= -1) {
|
14367 | const sibling = siblings[i];
|
14368 | if (sibling && sibling.type === 3) {
|
14369 | context.removeNode(sibling);
|
14370 | comments.unshift(sibling);
|
14371 | continue;
|
14372 | }
|
14373 | if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
|
14374 | context.removeNode(sibling);
|
14375 | continue;
|
14376 | }
|
14377 | if (sibling && sibling.type === 9) {
|
14378 | if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
14379 | context.onError(
|
14380 | createCompilerError(30, node.loc)
|
14381 | );
|
14382 | }
|
14383 | context.removeNode();
|
14384 | const branch = createIfBranch(node, dir);
|
14385 | if (comments.length &&
|
14386 | !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
|
14387 | branch.children = [...comments, ...branch.children];
|
14388 | }
|
14389 | {
|
14390 | const key = branch.userKey;
|
14391 | if (key) {
|
14392 | sibling.branches.forEach(({ userKey }) => {
|
14393 | if (isSameKey(userKey, key)) {
|
14394 | context.onError(
|
14395 | createCompilerError(
|
14396 | 29,
|
14397 | branch.userKey.loc
|
14398 | )
|
14399 | );
|
14400 | }
|
14401 | });
|
14402 | }
|
14403 | }
|
14404 | sibling.branches.push(branch);
|
14405 | const onExit = processCodegen && processCodegen(sibling, branch, false);
|
14406 | traverseNode(branch, context);
|
14407 | if (onExit)
|
14408 | onExit();
|
14409 | context.currentNode = null;
|
14410 | } else {
|
14411 | context.onError(
|
14412 | createCompilerError(30, node.loc)
|
14413 | );
|
14414 | }
|
14415 | break;
|
14416 | }
|
14417 | }
|
14418 | }
|
14419 | function createIfBranch(node, dir) {
|
14420 | const isTemplateIf = node.tagType === 3;
|
14421 | return {
|
14422 | type: 10,
|
14423 | loc: node.loc,
|
14424 | condition: dir.name === "else" ? void 0 : dir.exp,
|
14425 | children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
|
14426 | userKey: findProp(node, `key`),
|
14427 | isTemplateIf
|
14428 | };
|
14429 | }
|
14430 | function createCodegenNodeForBranch(branch, keyIndex, context) {
|
14431 | if (branch.condition) {
|
14432 | return createConditionalExpression(
|
14433 | branch.condition,
|
14434 | createChildrenCodegenNode(branch, keyIndex, context),
|
14435 |
|
14436 |
|
14437 | createCallExpression(context.helper(CREATE_COMMENT), [
|
14438 | '"v-if"' ,
|
14439 | "true"
|
14440 | ])
|
14441 | );
|
14442 | } else {
|
14443 | return createChildrenCodegenNode(branch, keyIndex, context);
|
14444 | }
|
14445 | }
|
14446 | function createChildrenCodegenNode(branch, keyIndex, context) {
|
14447 | const { helper } = context;
|
14448 | const keyProperty = createObjectProperty(
|
14449 | `key`,
|
14450 | createSimpleExpression(
|
14451 | `${keyIndex}`,
|
14452 | false,
|
14453 | locStub,
|
14454 | 2
|
14455 | )
|
14456 | );
|
14457 | const { children } = branch;
|
14458 | const firstChild = children[0];
|
14459 | const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
|
14460 | if (needFragmentWrapper) {
|
14461 | if (children.length === 1 && firstChild.type === 11) {
|
14462 | const vnodeCall = firstChild.codegenNode;
|
14463 | injectProp(vnodeCall, keyProperty, context);
|
14464 | return vnodeCall;
|
14465 | } else {
|
14466 | let patchFlag = 64;
|
14467 | let patchFlagText = PatchFlagNames[64];
|
14468 | if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
|
14469 | patchFlag |= 2048;
|
14470 | patchFlagText += `, ${PatchFlagNames[2048]}`;
|
14471 | }
|
14472 | return createVNodeCall(
|
14473 | context,
|
14474 | helper(FRAGMENT),
|
14475 | createObjectExpression([keyProperty]),
|
14476 | children,
|
14477 | patchFlag + (` /* ${patchFlagText} */` ),
|
14478 | void 0,
|
14479 | void 0,
|
14480 | true,
|
14481 | false,
|
14482 | false,
|
14483 | branch.loc
|
14484 | );
|
14485 | }
|
14486 | } else {
|
14487 | const ret = firstChild.codegenNode;
|
14488 | const vnodeCall = getMemoedVNodeCall(ret);
|
14489 | if (vnodeCall.type === 13) {
|
14490 | convertToBlock(vnodeCall, context);
|
14491 | }
|
14492 | injectProp(vnodeCall, keyProperty, context);
|
14493 | return ret;
|
14494 | }
|
14495 | }
|
14496 | function isSameKey(a, b) {
|
14497 | if (!a || a.type !== b.type) {
|
14498 | return false;
|
14499 | }
|
14500 | if (a.type === 6) {
|
14501 | if (a.value.content !== b.value.content) {
|
14502 | return false;
|
14503 | }
|
14504 | } else {
|
14505 | const exp = a.exp;
|
14506 | const branchExp = b.exp;
|
14507 | if (exp.type !== branchExp.type) {
|
14508 | return false;
|
14509 | }
|
14510 | if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
|
14511 | return false;
|
14512 | }
|
14513 | }
|
14514 | return true;
|
14515 | }
|
14516 | function getParentCondition(node) {
|
14517 | while (true) {
|
14518 | if (node.type === 19) {
|
14519 | if (node.alternate.type === 19) {
|
14520 | node = node.alternate;
|
14521 | } else {
|
14522 | return node;
|
14523 | }
|
14524 | } else if (node.type === 20) {
|
14525 | node = node.value;
|
14526 | }
|
14527 | }
|
14528 | }
|
14529 |
|
14530 | const transformFor = createStructuralDirectiveTransform(
|
14531 | "for",
|
14532 | (node, dir, context) => {
|
14533 | const { helper, removeHelper } = context;
|
14534 | return processFor(node, dir, context, (forNode) => {
|
14535 | const renderExp = createCallExpression(helper(RENDER_LIST), [
|
14536 | forNode.source
|
14537 | ]);
|
14538 | const isTemplate = isTemplateNode(node);
|
14539 | const memo = findDir(node, "memo");
|
14540 | const keyProp = findProp(node, `key`);
|
14541 | const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
|
14542 | const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
14543 | const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
14544 | const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
14545 | forNode.codegenNode = createVNodeCall(
|
14546 | context,
|
14547 | helper(FRAGMENT),
|
14548 | void 0,
|
14549 | renderExp,
|
14550 | fragmentFlag + (` /* ${PatchFlagNames[fragmentFlag]} */` ),
|
14551 | void 0,
|
14552 | void 0,
|
14553 | true,
|
14554 | !isStableFragment,
|
14555 | false,
|
14556 | node.loc
|
14557 | );
|
14558 | return () => {
|
14559 | let childBlock;
|
14560 | const { children } = forNode;
|
14561 | if (isTemplate) {
|
14562 | node.children.some((c) => {
|
14563 | if (c.type === 1) {
|
14564 | const key = findProp(c, "key");
|
14565 | if (key) {
|
14566 | context.onError(
|
14567 | createCompilerError(
|
14568 | 33,
|
14569 | key.loc
|
14570 | )
|
14571 | );
|
14572 | return true;
|
14573 | }
|
14574 | }
|
14575 | });
|
14576 | }
|
14577 | const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
|
14578 | const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
|
14579 | if (slotOutlet) {
|
14580 | childBlock = slotOutlet.codegenNode;
|
14581 | if (isTemplate && keyProperty) {
|
14582 | injectProp(childBlock, keyProperty, context);
|
14583 | }
|
14584 | } else if (needFragmentWrapper) {
|
14585 | childBlock = createVNodeCall(
|
14586 | context,
|
14587 | helper(FRAGMENT),
|
14588 | keyProperty ? createObjectExpression([keyProperty]) : void 0,
|
14589 | node.children,
|
14590 | 64 + (` /* ${PatchFlagNames[64]} */` ),
|
14591 | void 0,
|
14592 | void 0,
|
14593 | true,
|
14594 | void 0,
|
14595 | false
|
14596 | );
|
14597 | } else {
|
14598 | childBlock = children[0].codegenNode;
|
14599 | if (isTemplate && keyProperty) {
|
14600 | injectProp(childBlock, keyProperty, context);
|
14601 | }
|
14602 | if (childBlock.isBlock !== !isStableFragment) {
|
14603 | if (childBlock.isBlock) {
|
14604 | removeHelper(OPEN_BLOCK);
|
14605 | removeHelper(
|
14606 | getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
|
14607 | );
|
14608 | } else {
|
14609 | removeHelper(
|
14610 | getVNodeHelper(context.inSSR, childBlock.isComponent)
|
14611 | );
|
14612 | }
|
14613 | }
|
14614 | childBlock.isBlock = !isStableFragment;
|
14615 | if (childBlock.isBlock) {
|
14616 | helper(OPEN_BLOCK);
|
14617 | helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
14618 | } else {
|
14619 | helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
14620 | }
|
14621 | }
|
14622 | if (memo) {
|
14623 | const loop = createFunctionExpression(
|
14624 | createForLoopParams(forNode.parseResult, [
|
14625 | createSimpleExpression(`_cached`)
|
14626 | ])
|
14627 | );
|
14628 | loop.body = createBlockStatement([
|
14629 | createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
|
14630 | createCompoundExpression([
|
14631 | `if (_cached`,
|
14632 | ...keyExp ? [` && _cached.key === `, keyExp] : [],
|
14633 | ` && ${context.helperString(
|
14634 | IS_MEMO_SAME
|
14635 | )}(_cached, _memo)) return _cached`
|
14636 | ]),
|
14637 | createCompoundExpression([`const _item = `, childBlock]),
|
14638 | createSimpleExpression(`_item.memo = _memo`),
|
14639 | createSimpleExpression(`return _item`)
|
14640 | ]);
|
14641 | renderExp.arguments.push(
|
14642 | loop,
|
14643 | createSimpleExpression(`_cache`),
|
14644 | createSimpleExpression(String(context.cached++))
|
14645 | );
|
14646 | } else {
|
14647 | renderExp.arguments.push(
|
14648 | createFunctionExpression(
|
14649 | createForLoopParams(forNode.parseResult),
|
14650 | childBlock,
|
14651 | true
|
14652 | )
|
14653 | );
|
14654 | }
|
14655 | };
|
14656 | });
|
14657 | }
|
14658 | );
|
14659 | function processFor(node, dir, context, processCodegen) {
|
14660 | if (!dir.exp) {
|
14661 | context.onError(
|
14662 | createCompilerError(31, dir.loc)
|
14663 | );
|
14664 | return;
|
14665 | }
|
14666 | const parseResult = dir.forParseResult;
|
14667 | if (!parseResult) {
|
14668 | context.onError(
|
14669 | createCompilerError(32, dir.loc)
|
14670 | );
|
14671 | return;
|
14672 | }
|
14673 | finalizeForParseResult(parseResult, context);
|
14674 | const { addIdentifiers, removeIdentifiers, scopes } = context;
|
14675 | const { source, value, key, index } = parseResult;
|
14676 | const forNode = {
|
14677 | type: 11,
|
14678 | loc: dir.loc,
|
14679 | source,
|
14680 | valueAlias: value,
|
14681 | keyAlias: key,
|
14682 | objectIndexAlias: index,
|
14683 | parseResult,
|
14684 | children: isTemplateNode(node) ? node.children : [node]
|
14685 | };
|
14686 | context.replaceNode(forNode);
|
14687 | scopes.vFor++;
|
14688 | const onExit = processCodegen && processCodegen(forNode);
|
14689 | return () => {
|
14690 | scopes.vFor--;
|
14691 | if (onExit)
|
14692 | onExit();
|
14693 | };
|
14694 | }
|
14695 | function finalizeForParseResult(result, context) {
|
14696 | if (result.finalized)
|
14697 | return;
|
14698 | {
|
14699 | validateBrowserExpression(result.source, context);
|
14700 | if (result.key) {
|
14701 | validateBrowserExpression(
|
14702 | result.key,
|
14703 | context,
|
14704 | true
|
14705 | );
|
14706 | }
|
14707 | if (result.index) {
|
14708 | validateBrowserExpression(
|
14709 | result.index,
|
14710 | context,
|
14711 | true
|
14712 | );
|
14713 | }
|
14714 | if (result.value) {
|
14715 | validateBrowserExpression(
|
14716 | result.value,
|
14717 | context,
|
14718 | true
|
14719 | );
|
14720 | }
|
14721 | }
|
14722 | result.finalized = true;
|
14723 | }
|
14724 | function createForLoopParams({ value, key, index }, memoArgs = []) {
|
14725 | return createParamsList([value, key, index, ...memoArgs]);
|
14726 | }
|
14727 | function createParamsList(args) {
|
14728 | let i = args.length;
|
14729 | while (i--) {
|
14730 | if (args[i])
|
14731 | break;
|
14732 | }
|
14733 | return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
|
14734 | }
|
14735 |
|
14736 | const defaultFallback = createSimpleExpression(`undefined`, false);
|
14737 | const trackSlotScopes = (node, context) => {
|
14738 | if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
|
14739 | const vSlot = findDir(node, "slot");
|
14740 | if (vSlot) {
|
14741 | vSlot.exp;
|
14742 | context.scopes.vSlot++;
|
14743 | return () => {
|
14744 | context.scopes.vSlot--;
|
14745 | };
|
14746 | }
|
14747 | }
|
14748 | };
|
14749 | const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
|
14750 | props,
|
14751 | children,
|
14752 | false,
|
14753 | true,
|
14754 | children.length ? children[0].loc : loc
|
14755 | );
|
14756 | function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
14757 | context.helper(WITH_CTX);
|
14758 | const { children, loc } = node;
|
14759 | const slotsProperties = [];
|
14760 | const dynamicSlots = [];
|
14761 | let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
|
14762 | const onComponentSlot = findDir(node, "slot", true);
|
14763 | if (onComponentSlot) {
|
14764 | const { arg, exp } = onComponentSlot;
|
14765 | if (arg && !isStaticExp(arg)) {
|
14766 | hasDynamicSlots = true;
|
14767 | }
|
14768 | slotsProperties.push(
|
14769 | createObjectProperty(
|
14770 | arg || createSimpleExpression("default", true),
|
14771 | buildSlotFn(exp, void 0, children, loc)
|
14772 | )
|
14773 | );
|
14774 | }
|
14775 | let hasTemplateSlots = false;
|
14776 | let hasNamedDefaultSlot = false;
|
14777 | const implicitDefaultChildren = [];
|
14778 | const seenSlotNames = new Set();
|
14779 | let conditionalBranchIndex = 0;
|
14780 | for (let i = 0; i < children.length; i++) {
|
14781 | const slotElement = children[i];
|
14782 | let slotDir;
|
14783 | if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
|
14784 | if (slotElement.type !== 3) {
|
14785 | implicitDefaultChildren.push(slotElement);
|
14786 | }
|
14787 | continue;
|
14788 | }
|
14789 | if (onComponentSlot) {
|
14790 | context.onError(
|
14791 | createCompilerError(37, slotDir.loc)
|
14792 | );
|
14793 | break;
|
14794 | }
|
14795 | hasTemplateSlots = true;
|
14796 | const { children: slotChildren, loc: slotLoc } = slotElement;
|
14797 | const {
|
14798 | arg: slotName = createSimpleExpression(`default`, true),
|
14799 | exp: slotProps,
|
14800 | loc: dirLoc
|
14801 | } = slotDir;
|
14802 | let staticSlotName;
|
14803 | if (isStaticExp(slotName)) {
|
14804 | staticSlotName = slotName ? slotName.content : `default`;
|
14805 | } else {
|
14806 | hasDynamicSlots = true;
|
14807 | }
|
14808 | const vFor = findDir(slotElement, "for");
|
14809 | const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
|
14810 | let vIf;
|
14811 | let vElse;
|
14812 | if (vIf = findDir(slotElement, "if")) {
|
14813 | hasDynamicSlots = true;
|
14814 | dynamicSlots.push(
|
14815 | createConditionalExpression(
|
14816 | vIf.exp,
|
14817 | buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
|
14818 | defaultFallback
|
14819 | )
|
14820 | );
|
14821 | } else if (vElse = findDir(
|
14822 | slotElement,
|
14823 | /^else(-if)?$/,
|
14824 | true
|
14825 |
|
14826 | )) {
|
14827 | let j = i;
|
14828 | let prev;
|
14829 | while (j--) {
|
14830 | prev = children[j];
|
14831 | if (prev.type !== 3) {
|
14832 | break;
|
14833 | }
|
14834 | }
|
14835 | if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
|
14836 | children.splice(i, 1);
|
14837 | i--;
|
14838 | let conditional = dynamicSlots[dynamicSlots.length - 1];
|
14839 | while (conditional.alternate.type === 19) {
|
14840 | conditional = conditional.alternate;
|
14841 | }
|
14842 | conditional.alternate = vElse.exp ? createConditionalExpression(
|
14843 | vElse.exp,
|
14844 | buildDynamicSlot(
|
14845 | slotName,
|
14846 | slotFunction,
|
14847 | conditionalBranchIndex++
|
14848 | ),
|
14849 | defaultFallback
|
14850 | ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
|
14851 | } else {
|
14852 | context.onError(
|
14853 | createCompilerError(30, vElse.loc)
|
14854 | );
|
14855 | }
|
14856 | } else if (vFor) {
|
14857 | hasDynamicSlots = true;
|
14858 | const parseResult = vFor.forParseResult;
|
14859 | if (parseResult) {
|
14860 | finalizeForParseResult(parseResult, context);
|
14861 | dynamicSlots.push(
|
14862 | createCallExpression(context.helper(RENDER_LIST), [
|
14863 | parseResult.source,
|
14864 | createFunctionExpression(
|
14865 | createForLoopParams(parseResult),
|
14866 | buildDynamicSlot(slotName, slotFunction),
|
14867 | true
|
14868 | )
|
14869 | ])
|
14870 | );
|
14871 | } else {
|
14872 | context.onError(
|
14873 | createCompilerError(
|
14874 | 32,
|
14875 | vFor.loc
|
14876 | )
|
14877 | );
|
14878 | }
|
14879 | } else {
|
14880 | if (staticSlotName) {
|
14881 | if (seenSlotNames.has(staticSlotName)) {
|
14882 | context.onError(
|
14883 | createCompilerError(
|
14884 | 38,
|
14885 | dirLoc
|
14886 | )
|
14887 | );
|
14888 | continue;
|
14889 | }
|
14890 | seenSlotNames.add(staticSlotName);
|
14891 | if (staticSlotName === "default") {
|
14892 | hasNamedDefaultSlot = true;
|
14893 | }
|
14894 | }
|
14895 | slotsProperties.push(createObjectProperty(slotName, slotFunction));
|
14896 | }
|
14897 | }
|
14898 | if (!onComponentSlot) {
|
14899 | const buildDefaultSlotProperty = (props, children2) => {
|
14900 | const fn = buildSlotFn(props, void 0, children2, loc);
|
14901 | return createObjectProperty(`default`, fn);
|
14902 | };
|
14903 | if (!hasTemplateSlots) {
|
14904 | slotsProperties.push(buildDefaultSlotProperty(void 0, children));
|
14905 | } else if (implicitDefaultChildren.length &&
|
14906 |
|
14907 |
|
14908 | implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
|
14909 | if (hasNamedDefaultSlot) {
|
14910 | context.onError(
|
14911 | createCompilerError(
|
14912 | 39,
|
14913 | implicitDefaultChildren[0].loc
|
14914 | )
|
14915 | );
|
14916 | } else {
|
14917 | slotsProperties.push(
|
14918 | buildDefaultSlotProperty(void 0, implicitDefaultChildren)
|
14919 | );
|
14920 | }
|
14921 | }
|
14922 | }
|
14923 | const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
|
14924 | let slots = createObjectExpression(
|
14925 | slotsProperties.concat(
|
14926 | createObjectProperty(
|
14927 | `_`,
|
14928 |
|
14929 |
|
14930 | createSimpleExpression(
|
14931 | slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
|
14932 | false
|
14933 | )
|
14934 | )
|
14935 | ),
|
14936 | loc
|
14937 | );
|
14938 | if (dynamicSlots.length) {
|
14939 | slots = createCallExpression(context.helper(CREATE_SLOTS), [
|
14940 | slots,
|
14941 | createArrayExpression(dynamicSlots)
|
14942 | ]);
|
14943 | }
|
14944 | return {
|
14945 | slots,
|
14946 | hasDynamicSlots
|
14947 | };
|
14948 | }
|
14949 | function buildDynamicSlot(name, fn, index) {
|
14950 | const props = [
|
14951 | createObjectProperty(`name`, name),
|
14952 | createObjectProperty(`fn`, fn)
|
14953 | ];
|
14954 | if (index != null) {
|
14955 | props.push(
|
14956 | createObjectProperty(`key`, createSimpleExpression(String(index), true))
|
14957 | );
|
14958 | }
|
14959 | return createObjectExpression(props);
|
14960 | }
|
14961 | function hasForwardedSlots(children) {
|
14962 | for (let i = 0; i < children.length; i++) {
|
14963 | const child = children[i];
|
14964 | switch (child.type) {
|
14965 | case 1:
|
14966 | if (child.tagType === 2 || hasForwardedSlots(child.children)) {
|
14967 | return true;
|
14968 | }
|
14969 | break;
|
14970 | case 9:
|
14971 | if (hasForwardedSlots(child.branches))
|
14972 | return true;
|
14973 | break;
|
14974 | case 10:
|
14975 | case 11:
|
14976 | if (hasForwardedSlots(child.children))
|
14977 | return true;
|
14978 | break;
|
14979 | }
|
14980 | }
|
14981 | return false;
|
14982 | }
|
14983 | function isNonWhitespaceContent(node) {
|
14984 | if (node.type !== 2 && node.type !== 12)
|
14985 | return true;
|
14986 | return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
|
14987 | }
|
14988 |
|
14989 | const directiveImportMap = new WeakMap();
|
14990 | const transformElement = (node, context) => {
|
14991 | return function postTransformElement() {
|
14992 | node = context.currentNode;
|
14993 | if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
|
14994 | return;
|
14995 | }
|
14996 | const { tag, props } = node;
|
14997 | const isComponent = node.tagType === 1;
|
14998 | let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
|
14999 | const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
|
15000 | let vnodeProps;
|
15001 | let vnodeChildren;
|
15002 | let vnodePatchFlag;
|
15003 | let patchFlag = 0;
|
15004 | let vnodeDynamicProps;
|
15005 | let dynamicPropNames;
|
15006 | let vnodeDirectives;
|
15007 | let shouldUseBlock = (
|
15008 |
|
15009 | isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent &&
|
15010 |
|
15011 |
|
15012 |
|
15013 | (tag === "svg" || tag === "foreignObject")
|
15014 | );
|
15015 | if (props.length > 0) {
|
15016 | const propsBuildResult = buildProps(
|
15017 | node,
|
15018 | context,
|
15019 | void 0,
|
15020 | isComponent,
|
15021 | isDynamicComponent
|
15022 | );
|
15023 | vnodeProps = propsBuildResult.props;
|
15024 | patchFlag = propsBuildResult.patchFlag;
|
15025 | dynamicPropNames = propsBuildResult.dynamicPropNames;
|
15026 | const directives = propsBuildResult.directives;
|
15027 | vnodeDirectives = directives && directives.length ? createArrayExpression(
|
15028 | directives.map((dir) => buildDirectiveArgs(dir, context))
|
15029 | ) : void 0;
|
15030 | if (propsBuildResult.shouldUseBlock) {
|
15031 | shouldUseBlock = true;
|
15032 | }
|
15033 | }
|
15034 | if (node.children.length > 0) {
|
15035 | if (vnodeTag === KEEP_ALIVE) {
|
15036 | shouldUseBlock = true;
|
15037 | patchFlag |= 1024;
|
15038 | if (node.children.length > 1) {
|
15039 | context.onError(
|
15040 | createCompilerError(46, {
|
15041 | start: node.children[0].loc.start,
|
15042 | end: node.children[node.children.length - 1].loc.end,
|
15043 | source: ""
|
15044 | })
|
15045 | );
|
15046 | }
|
15047 | }
|
15048 | const shouldBuildAsSlots = isComponent &&
|
15049 | vnodeTag !== TELEPORT &&
|
15050 | vnodeTag !== KEEP_ALIVE;
|
15051 | if (shouldBuildAsSlots) {
|
15052 | const { slots, hasDynamicSlots } = buildSlots(node, context);
|
15053 | vnodeChildren = slots;
|
15054 | if (hasDynamicSlots) {
|
15055 | patchFlag |= 1024;
|
15056 | }
|
15057 | } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
|
15058 | const child = node.children[0];
|
15059 | const type = child.type;
|
15060 | const hasDynamicTextChild = type === 5 || type === 8;
|
15061 | if (hasDynamicTextChild && getConstantType(child, context) === 0) {
|
15062 | patchFlag |= 1;
|
15063 | }
|
15064 | if (hasDynamicTextChild || type === 2) {
|
15065 | vnodeChildren = child;
|
15066 | } else {
|
15067 | vnodeChildren = node.children;
|
15068 | }
|
15069 | } else {
|
15070 | vnodeChildren = node.children;
|
15071 | }
|
15072 | }
|
15073 | if (patchFlag !== 0) {
|
15074 | {
|
15075 | if (patchFlag < 0) {
|
15076 | vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
|
15077 | } else {
|
15078 | const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
|
15079 | vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
|
15080 | }
|
15081 | }
|
15082 | if (dynamicPropNames && dynamicPropNames.length) {
|
15083 | vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
|
15084 | }
|
15085 | }
|
15086 | node.codegenNode = createVNodeCall(
|
15087 | context,
|
15088 | vnodeTag,
|
15089 | vnodeProps,
|
15090 | vnodeChildren,
|
15091 | vnodePatchFlag,
|
15092 | vnodeDynamicProps,
|
15093 | vnodeDirectives,
|
15094 | !!shouldUseBlock,
|
15095 | false,
|
15096 | isComponent,
|
15097 | node.loc
|
15098 | );
|
15099 | };
|
15100 | };
|
15101 | function resolveComponentType(node, context, ssr = false) {
|
15102 | let { tag } = node;
|
15103 | const isExplicitDynamic = isComponentTag(tag);
|
15104 | const isProp = findProp(node, "is");
|
15105 | if (isProp) {
|
15106 | if (isExplicitDynamic || false) {
|
15107 | const exp = isProp.type === 6 ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
|
15108 | if (exp) {
|
15109 | return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
15110 | exp
|
15111 | ]);
|
15112 | }
|
15113 | } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
|
15114 | tag = isProp.value.content.slice(4);
|
15115 | }
|
15116 | }
|
15117 | const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
15118 | if (builtIn) {
|
15119 | if (!ssr)
|
15120 | context.helper(builtIn);
|
15121 | return builtIn;
|
15122 | }
|
15123 | context.helper(RESOLVE_COMPONENT);
|
15124 | context.components.add(tag);
|
15125 | return toValidAssetId(tag, `component`);
|
15126 | }
|
15127 | function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
15128 | const { tag, loc: elementLoc, children } = node;
|
15129 | let properties = [];
|
15130 | const mergeArgs = [];
|
15131 | const runtimeDirectives = [];
|
15132 | const hasChildren = children.length > 0;
|
15133 | let shouldUseBlock = false;
|
15134 | let patchFlag = 0;
|
15135 | let hasRef = false;
|
15136 | let hasClassBinding = false;
|
15137 | let hasStyleBinding = false;
|
15138 | let hasHydrationEventBinding = false;
|
15139 | let hasDynamicKeys = false;
|
15140 | let hasVnodeHook = false;
|
15141 | const dynamicPropNames = [];
|
15142 | const pushMergeArg = (arg) => {
|
15143 | if (properties.length) {
|
15144 | mergeArgs.push(
|
15145 | createObjectExpression(dedupeProperties(properties), elementLoc)
|
15146 | );
|
15147 | properties = [];
|
15148 | }
|
15149 | if (arg)
|
15150 | mergeArgs.push(arg);
|
15151 | };
|
15152 | const analyzePatchFlag = ({ key, value }) => {
|
15153 | if (isStaticExp(key)) {
|
15154 | const name = key.content;
|
15155 | const isEventHandler = isOn(name);
|
15156 | if (isEventHandler && (!isComponent || isDynamicComponent) &&
|
15157 |
|
15158 | name.toLowerCase() !== "onclick" &&
|
15159 | name !== "onUpdate:modelValue" &&
|
15160 | !isReservedProp(name)) {
|
15161 | hasHydrationEventBinding = true;
|
15162 | }
|
15163 | if (isEventHandler && isReservedProp(name)) {
|
15164 | hasVnodeHook = true;
|
15165 | }
|
15166 | if (isEventHandler && value.type === 14) {
|
15167 | value = value.arguments[0];
|
15168 | }
|
15169 | if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
|
15170 | return;
|
15171 | }
|
15172 | if (name === "ref") {
|
15173 | hasRef = true;
|
15174 | } else if (name === "class") {
|
15175 | hasClassBinding = true;
|
15176 | } else if (name === "style") {
|
15177 | hasStyleBinding = true;
|
15178 | } else if (name !== "key" && !dynamicPropNames.includes(name)) {
|
15179 | dynamicPropNames.push(name);
|
15180 | }
|
15181 | if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
|
15182 | dynamicPropNames.push(name);
|
15183 | }
|
15184 | } else {
|
15185 | hasDynamicKeys = true;
|
15186 | }
|
15187 | };
|
15188 | for (let i = 0; i < props.length; i++) {
|
15189 | const prop = props[i];
|
15190 | if (prop.type === 6) {
|
15191 | const { loc, name, nameLoc, value } = prop;
|
15192 | let isStatic = true;
|
15193 | if (name === "ref") {
|
15194 | hasRef = true;
|
15195 | if (context.scopes.vFor > 0) {
|
15196 | properties.push(
|
15197 | createObjectProperty(
|
15198 | createSimpleExpression("ref_for", true),
|
15199 | createSimpleExpression("true")
|
15200 | )
|
15201 | );
|
15202 | }
|
15203 | }
|
15204 | if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
|
15205 | continue;
|
15206 | }
|
15207 | properties.push(
|
15208 | createObjectProperty(
|
15209 | createSimpleExpression(name, true, nameLoc),
|
15210 | createSimpleExpression(
|
15211 | value ? value.content : "",
|
15212 | isStatic,
|
15213 | value ? value.loc : loc
|
15214 | )
|
15215 | )
|
15216 | );
|
15217 | } else {
|
15218 | const { name, arg, exp, loc, modifiers } = prop;
|
15219 | const isVBind = name === "bind";
|
15220 | const isVOn = name === "on";
|
15221 | if (name === "slot") {
|
15222 | if (!isComponent) {
|
15223 | context.onError(
|
15224 | createCompilerError(40, loc)
|
15225 | );
|
15226 | }
|
15227 | continue;
|
15228 | }
|
15229 | if (name === "once" || name === "memo") {
|
15230 | continue;
|
15231 | }
|
15232 | if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
|
15233 | continue;
|
15234 | }
|
15235 | if (isVOn && ssr) {
|
15236 | continue;
|
15237 | }
|
15238 | if (
|
15239 |
|
15240 | isVBind && isStaticArgOf(arg, "key") ||
|
15241 |
|
15242 | isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
|
15243 | ) {
|
15244 | shouldUseBlock = true;
|
15245 | }
|
15246 | if (isVBind && isStaticArgOf(arg, "ref") && context.scopes.vFor > 0) {
|
15247 | properties.push(
|
15248 | createObjectProperty(
|
15249 | createSimpleExpression("ref_for", true),
|
15250 | createSimpleExpression("true")
|
15251 | )
|
15252 | );
|
15253 | }
|
15254 | if (!arg && (isVBind || isVOn)) {
|
15255 | hasDynamicKeys = true;
|
15256 | if (exp) {
|
15257 | if (isVBind) {
|
15258 | pushMergeArg();
|
15259 | mergeArgs.push(exp);
|
15260 | } else {
|
15261 | pushMergeArg({
|
15262 | type: 14,
|
15263 | loc,
|
15264 | callee: context.helper(TO_HANDLERS),
|
15265 | arguments: isComponent ? [exp] : [exp, `true`]
|
15266 | });
|
15267 | }
|
15268 | } else {
|
15269 | context.onError(
|
15270 | createCompilerError(
|
15271 | isVBind ? 34 : 35,
|
15272 | loc
|
15273 | )
|
15274 | );
|
15275 | }
|
15276 | continue;
|
15277 | }
|
15278 | if (isVBind && modifiers.includes("prop")) {
|
15279 | patchFlag |= 32;
|
15280 | }
|
15281 | const directiveTransform = context.directiveTransforms[name];
|
15282 | if (directiveTransform) {
|
15283 | const { props: props2, needRuntime } = directiveTransform(prop, node, context);
|
15284 | !ssr && props2.forEach(analyzePatchFlag);
|
15285 | if (isVOn && arg && !isStaticExp(arg)) {
|
15286 | pushMergeArg(createObjectExpression(props2, elementLoc));
|
15287 | } else {
|
15288 | properties.push(...props2);
|
15289 | }
|
15290 | if (needRuntime) {
|
15291 | runtimeDirectives.push(prop);
|
15292 | if (isSymbol(needRuntime)) {
|
15293 | directiveImportMap.set(prop, needRuntime);
|
15294 | }
|
15295 | }
|
15296 | } else if (!isBuiltInDirective(name)) {
|
15297 | runtimeDirectives.push(prop);
|
15298 | if (hasChildren) {
|
15299 | shouldUseBlock = true;
|
15300 | }
|
15301 | }
|
15302 | }
|
15303 | }
|
15304 | let propsExpression = void 0;
|
15305 | if (mergeArgs.length) {
|
15306 | pushMergeArg();
|
15307 | if (mergeArgs.length > 1) {
|
15308 | propsExpression = createCallExpression(
|
15309 | context.helper(MERGE_PROPS),
|
15310 | mergeArgs,
|
15311 | elementLoc
|
15312 | );
|
15313 | } else {
|
15314 | propsExpression = mergeArgs[0];
|
15315 | }
|
15316 | } else if (properties.length) {
|
15317 | propsExpression = createObjectExpression(
|
15318 | dedupeProperties(properties),
|
15319 | elementLoc
|
15320 | );
|
15321 | }
|
15322 | if (hasDynamicKeys) {
|
15323 | patchFlag |= 16;
|
15324 | } else {
|
15325 | if (hasClassBinding && !isComponent) {
|
15326 | patchFlag |= 2;
|
15327 | }
|
15328 | if (hasStyleBinding && !isComponent) {
|
15329 | patchFlag |= 4;
|
15330 | }
|
15331 | if (dynamicPropNames.length) {
|
15332 | patchFlag |= 8;
|
15333 | }
|
15334 | if (hasHydrationEventBinding) {
|
15335 | patchFlag |= 32;
|
15336 | }
|
15337 | }
|
15338 | if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
|
15339 | patchFlag |= 512;
|
15340 | }
|
15341 | if (!context.inSSR && propsExpression) {
|
15342 | switch (propsExpression.type) {
|
15343 | case 15:
|
15344 | let classKeyIndex = -1;
|
15345 | let styleKeyIndex = -1;
|
15346 | let hasDynamicKey = false;
|
15347 | for (let i = 0; i < propsExpression.properties.length; i++) {
|
15348 | const key = propsExpression.properties[i].key;
|
15349 | if (isStaticExp(key)) {
|
15350 | if (key.content === "class") {
|
15351 | classKeyIndex = i;
|
15352 | } else if (key.content === "style") {
|
15353 | styleKeyIndex = i;
|
15354 | }
|
15355 | } else if (!key.isHandlerKey) {
|
15356 | hasDynamicKey = true;
|
15357 | }
|
15358 | }
|
15359 | const classProp = propsExpression.properties[classKeyIndex];
|
15360 | const styleProp = propsExpression.properties[styleKeyIndex];
|
15361 | if (!hasDynamicKey) {
|
15362 | if (classProp && !isStaticExp(classProp.value)) {
|
15363 | classProp.value = createCallExpression(
|
15364 | context.helper(NORMALIZE_CLASS),
|
15365 | [classProp.value]
|
15366 | );
|
15367 | }
|
15368 | if (styleProp &&
|
15369 |
|
15370 | (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` ||
|
15371 |
|
15372 | styleProp.value.type === 17)) {
|
15373 | styleProp.value = createCallExpression(
|
15374 | context.helper(NORMALIZE_STYLE),
|
15375 | [styleProp.value]
|
15376 | );
|
15377 | }
|
15378 | } else {
|
15379 | propsExpression = createCallExpression(
|
15380 | context.helper(NORMALIZE_PROPS),
|
15381 | [propsExpression]
|
15382 | );
|
15383 | }
|
15384 | break;
|
15385 | case 14:
|
15386 | break;
|
15387 | default:
|
15388 | propsExpression = createCallExpression(
|
15389 | context.helper(NORMALIZE_PROPS),
|
15390 | [
|
15391 | createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
|
15392 | propsExpression
|
15393 | ])
|
15394 | ]
|
15395 | );
|
15396 | break;
|
15397 | }
|
15398 | }
|
15399 | return {
|
15400 | props: propsExpression,
|
15401 | directives: runtimeDirectives,
|
15402 | patchFlag,
|
15403 | dynamicPropNames,
|
15404 | shouldUseBlock
|
15405 | };
|
15406 | }
|
15407 | function dedupeProperties(properties) {
|
15408 | const knownProps = new Map();
|
15409 | const deduped = [];
|
15410 | for (let i = 0; i < properties.length; i++) {
|
15411 | const prop = properties[i];
|
15412 | if (prop.key.type === 8 || !prop.key.isStatic) {
|
15413 | deduped.push(prop);
|
15414 | continue;
|
15415 | }
|
15416 | const name = prop.key.content;
|
15417 | const existing = knownProps.get(name);
|
15418 | if (existing) {
|
15419 | if (name === "style" || name === "class" || isOn(name)) {
|
15420 | mergeAsArray(existing, prop);
|
15421 | }
|
15422 | } else {
|
15423 | knownProps.set(name, prop);
|
15424 | deduped.push(prop);
|
15425 | }
|
15426 | }
|
15427 | return deduped;
|
15428 | }
|
15429 | function mergeAsArray(existing, incoming) {
|
15430 | if (existing.value.type === 17) {
|
15431 | existing.value.elements.push(incoming.value);
|
15432 | } else {
|
15433 | existing.value = createArrayExpression(
|
15434 | [existing.value, incoming.value],
|
15435 | existing.loc
|
15436 | );
|
15437 | }
|
15438 | }
|
15439 | function buildDirectiveArgs(dir, context) {
|
15440 | const dirArgs = [];
|
15441 | const runtime = directiveImportMap.get(dir);
|
15442 | if (runtime) {
|
15443 | dirArgs.push(context.helperString(runtime));
|
15444 | } else {
|
15445 | {
|
15446 | context.helper(RESOLVE_DIRECTIVE);
|
15447 | context.directives.add(dir.name);
|
15448 | dirArgs.push(toValidAssetId(dir.name, `directive`));
|
15449 | }
|
15450 | }
|
15451 | const { loc } = dir;
|
15452 | if (dir.exp)
|
15453 | dirArgs.push(dir.exp);
|
15454 | if (dir.arg) {
|
15455 | if (!dir.exp) {
|
15456 | dirArgs.push(`void 0`);
|
15457 | }
|
15458 | dirArgs.push(dir.arg);
|
15459 | }
|
15460 | if (Object.keys(dir.modifiers).length) {
|
15461 | if (!dir.arg) {
|
15462 | if (!dir.exp) {
|
15463 | dirArgs.push(`void 0`);
|
15464 | }
|
15465 | dirArgs.push(`void 0`);
|
15466 | }
|
15467 | const trueExpression = createSimpleExpression(`true`, false, loc);
|
15468 | dirArgs.push(
|
15469 | createObjectExpression(
|
15470 | dir.modifiers.map(
|
15471 | (modifier) => createObjectProperty(modifier, trueExpression)
|
15472 | ),
|
15473 | loc
|
15474 | )
|
15475 | );
|
15476 | }
|
15477 | return createArrayExpression(dirArgs, dir.loc);
|
15478 | }
|
15479 | function stringifyDynamicPropNames(props) {
|
15480 | let propsNamesString = `[`;
|
15481 | for (let i = 0, l = props.length; i < l; i++) {
|
15482 | propsNamesString += JSON.stringify(props[i]);
|
15483 | if (i < l - 1)
|
15484 | propsNamesString += ", ";
|
15485 | }
|
15486 | return propsNamesString + `]`;
|
15487 | }
|
15488 | function isComponentTag(tag) {
|
15489 | return tag === "component" || tag === "Component";
|
15490 | }
|
15491 |
|
15492 | const transformSlotOutlet = (node, context) => {
|
15493 | if (isSlotOutlet(node)) {
|
15494 | const { children, loc } = node;
|
15495 | const { slotName, slotProps } = processSlotOutlet(node, context);
|
15496 | const slotArgs = [
|
15497 | context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
|
15498 | slotName,
|
15499 | "{}",
|
15500 | "undefined",
|
15501 | "true"
|
15502 | ];
|
15503 | let expectedLen = 2;
|
15504 | if (slotProps) {
|
15505 | slotArgs[2] = slotProps;
|
15506 | expectedLen = 3;
|
15507 | }
|
15508 | if (children.length) {
|
15509 | slotArgs[3] = createFunctionExpression([], children, false, false, loc);
|
15510 | expectedLen = 4;
|
15511 | }
|
15512 | if (context.scopeId && !context.slotted) {
|
15513 | expectedLen = 5;
|
15514 | }
|
15515 | slotArgs.splice(expectedLen);
|
15516 | node.codegenNode = createCallExpression(
|
15517 | context.helper(RENDER_SLOT),
|
15518 | slotArgs,
|
15519 | loc
|
15520 | );
|
15521 | }
|
15522 | };
|
15523 | function processSlotOutlet(node, context) {
|
15524 | let slotName = `"default"`;
|
15525 | let slotProps = void 0;
|
15526 | const nonNameProps = [];
|
15527 | for (let i = 0; i < node.props.length; i++) {
|
15528 | const p = node.props[i];
|
15529 | if (p.type === 6) {
|
15530 | if (p.value) {
|
15531 | if (p.name === "name") {
|
15532 | slotName = JSON.stringify(p.value.content);
|
15533 | } else {
|
15534 | p.name = camelize(p.name);
|
15535 | nonNameProps.push(p);
|
15536 | }
|
15537 | }
|
15538 | } else {
|
15539 | if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
|
15540 | if (p.exp) {
|
15541 | slotName = p.exp;
|
15542 | } else if (p.arg && p.arg.type === 4) {
|
15543 | const name = camelize(p.arg.content);
|
15544 | slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
|
15545 | }
|
15546 | } else {
|
15547 | if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
|
15548 | p.arg.content = camelize(p.arg.content);
|
15549 | }
|
15550 | nonNameProps.push(p);
|
15551 | }
|
15552 | }
|
15553 | }
|
15554 | if (nonNameProps.length > 0) {
|
15555 | const { props, directives } = buildProps(
|
15556 | node,
|
15557 | context,
|
15558 | nonNameProps,
|
15559 | false,
|
15560 | false
|
15561 | );
|
15562 | slotProps = props;
|
15563 | if (directives.length) {
|
15564 | context.onError(
|
15565 | createCompilerError(
|
15566 | 36,
|
15567 | directives[0].loc
|
15568 | )
|
15569 | );
|
15570 | }
|
15571 | }
|
15572 | return {
|
15573 | slotName,
|
15574 | slotProps
|
15575 | };
|
15576 | }
|
15577 |
|
15578 | const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
15579 | const transformOn$1 = (dir, node, context, augmentor) => {
|
15580 | const { loc, modifiers, arg } = dir;
|
15581 | if (!dir.exp && !modifiers.length) {
|
15582 | context.onError(createCompilerError(35, loc));
|
15583 | }
|
15584 | let eventName;
|
15585 | if (arg.type === 4) {
|
15586 | if (arg.isStatic) {
|
15587 | let rawName = arg.content;
|
15588 | if (rawName.startsWith("vnode")) {
|
15589 | context.onError(createCompilerError(51, arg.loc));
|
15590 | }
|
15591 | if (rawName.startsWith("vue:")) {
|
15592 | rawName = `vnode-${rawName.slice(4)}`;
|
15593 | }
|
15594 | const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
|
15595 |
|
15596 |
|
15597 | toHandlerKey(camelize(rawName))
|
15598 | ) : (
|
15599 |
|
15600 |
|
15601 | `on:${rawName}`
|
15602 | );
|
15603 | eventName = createSimpleExpression(eventString, true, arg.loc);
|
15604 | } else {
|
15605 | eventName = createCompoundExpression([
|
15606 | `${context.helperString(TO_HANDLER_KEY)}(`,
|
15607 | arg,
|
15608 | `)`
|
15609 | ]);
|
15610 | }
|
15611 | } else {
|
15612 | eventName = arg;
|
15613 | eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
|
15614 | eventName.children.push(`)`);
|
15615 | }
|
15616 | let exp = dir.exp;
|
15617 | if (exp && !exp.content.trim()) {
|
15618 | exp = void 0;
|
15619 | }
|
15620 | let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
|
15621 | if (exp) {
|
15622 | const isMemberExp = isMemberExpression(exp.content);
|
15623 | const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
|
15624 | const hasMultipleStatements = exp.content.includes(`;`);
|
15625 | {
|
15626 | validateBrowserExpression(
|
15627 | exp,
|
15628 | context,
|
15629 | false,
|
15630 | hasMultipleStatements
|
15631 | );
|
15632 | }
|
15633 | if (isInlineStatement || shouldCache && isMemberExp) {
|
15634 | exp = createCompoundExpression([
|
15635 | `${isInlineStatement ? `$event` : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
|
15636 | exp,
|
15637 | hasMultipleStatements ? `}` : `)`
|
15638 | ]);
|
15639 | }
|
15640 | }
|
15641 | let ret = {
|
15642 | props: [
|
15643 | createObjectProperty(
|
15644 | eventName,
|
15645 | exp || createSimpleExpression(`() => {}`, false, loc)
|
15646 | )
|
15647 | ]
|
15648 | };
|
15649 | if (augmentor) {
|
15650 | ret = augmentor(ret);
|
15651 | }
|
15652 | if (shouldCache) {
|
15653 | ret.props[0].value = context.cache(ret.props[0].value);
|
15654 | }
|
15655 | ret.props.forEach((p) => p.key.isHandlerKey = true);
|
15656 | return ret;
|
15657 | };
|
15658 |
|
15659 | const transformBind = (dir, _node, context) => {
|
15660 | const { modifiers, loc } = dir;
|
15661 | const arg = dir.arg;
|
15662 | let { exp } = dir;
|
15663 | if (exp && exp.type === 4 && !exp.content.trim()) {
|
15664 | {
|
15665 | exp = void 0;
|
15666 | }
|
15667 | }
|
15668 | if (!exp) {
|
15669 | if (arg.type !== 4 || !arg.isStatic) {
|
15670 | context.onError(
|
15671 | createCompilerError(
|
15672 | 52,
|
15673 | arg.loc
|
15674 | )
|
15675 | );
|
15676 | return {
|
15677 | props: [
|
15678 | createObjectProperty(arg, createSimpleExpression("", true, loc))
|
15679 | ]
|
15680 | };
|
15681 | }
|
15682 | const propName = camelize(arg.content);
|
15683 | exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
|
15684 | }
|
15685 | if (arg.type !== 4) {
|
15686 | arg.children.unshift(`(`);
|
15687 | arg.children.push(`) || ""`);
|
15688 | } else if (!arg.isStatic) {
|
15689 | arg.content = `${arg.content} || ""`;
|
15690 | }
|
15691 | if (modifiers.includes("camel")) {
|
15692 | if (arg.type === 4) {
|
15693 | if (arg.isStatic) {
|
15694 | arg.content = camelize(arg.content);
|
15695 | } else {
|
15696 | arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
15697 | }
|
15698 | } else {
|
15699 | arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
15700 | arg.children.push(`)`);
|
15701 | }
|
15702 | }
|
15703 | if (!context.inSSR) {
|
15704 | if (modifiers.includes("prop")) {
|
15705 | injectPrefix(arg, ".");
|
15706 | }
|
15707 | if (modifiers.includes("attr")) {
|
15708 | injectPrefix(arg, "^");
|
15709 | }
|
15710 | }
|
15711 | return {
|
15712 | props: [createObjectProperty(arg, exp)]
|
15713 | };
|
15714 | };
|
15715 | const injectPrefix = (arg, prefix) => {
|
15716 | if (arg.type === 4) {
|
15717 | if (arg.isStatic) {
|
15718 | arg.content = prefix + arg.content;
|
15719 | } else {
|
15720 | arg.content = `\`${prefix}\${${arg.content}}\``;
|
15721 | }
|
15722 | } else {
|
15723 | arg.children.unshift(`'${prefix}' + (`);
|
15724 | arg.children.push(`)`);
|
15725 | }
|
15726 | };
|
15727 |
|
15728 | const transformText = (node, context) => {
|
15729 | if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
15730 | return () => {
|
15731 | const children = node.children;
|
15732 | let currentContainer = void 0;
|
15733 | let hasText = false;
|
15734 | for (let i = 0; i < children.length; i++) {
|
15735 | const child = children[i];
|
15736 | if (isText$1(child)) {
|
15737 | hasText = true;
|
15738 | for (let j = i + 1; j < children.length; j++) {
|
15739 | const next = children[j];
|
15740 | if (isText$1(next)) {
|
15741 | if (!currentContainer) {
|
15742 | currentContainer = children[i] = createCompoundExpression(
|
15743 | [child],
|
15744 | child.loc
|
15745 | );
|
15746 | }
|
15747 | currentContainer.children.push(` + `, next);
|
15748 | children.splice(j, 1);
|
15749 | j--;
|
15750 | } else {
|
15751 | currentContainer = void 0;
|
15752 | break;
|
15753 | }
|
15754 | }
|
15755 | }
|
15756 | }
|
15757 | if (!hasText ||
|
15758 |
|
15759 |
|
15760 |
|
15761 | children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 &&
|
15762 |
|
15763 |
|
15764 |
|
15765 |
|
15766 | !node.props.find(
|
15767 | (p) => p.type === 7 && !context.directiveTransforms[p.name]
|
15768 | ) &&
|
15769 |
|
15770 |
|
15771 | true)) {
|
15772 | return;
|
15773 | }
|
15774 | for (let i = 0; i < children.length; i++) {
|
15775 | const child = children[i];
|
15776 | if (isText$1(child) || child.type === 8) {
|
15777 | const callArgs = [];
|
15778 | if (child.type !== 2 || child.content !== " ") {
|
15779 | callArgs.push(child);
|
15780 | }
|
15781 | if (!context.ssr && getConstantType(child, context) === 0) {
|
15782 | callArgs.push(
|
15783 | 1 + (` /* ${PatchFlagNames[1]} */` )
|
15784 | );
|
15785 | }
|
15786 | children[i] = {
|
15787 | type: 12,
|
15788 | content: child,
|
15789 | loc: child.loc,
|
15790 | codegenNode: createCallExpression(
|
15791 | context.helper(CREATE_TEXT),
|
15792 | callArgs
|
15793 | )
|
15794 | };
|
15795 | }
|
15796 | }
|
15797 | };
|
15798 | }
|
15799 | };
|
15800 |
|
15801 | const seen$1 = new WeakSet();
|
15802 | const transformOnce = (node, context) => {
|
15803 | if (node.type === 1 && findDir(node, "once", true)) {
|
15804 | if (seen$1.has(node) || context.inVOnce || context.inSSR) {
|
15805 | return;
|
15806 | }
|
15807 | seen$1.add(node);
|
15808 | context.inVOnce = true;
|
15809 | context.helper(SET_BLOCK_TRACKING);
|
15810 | return () => {
|
15811 | context.inVOnce = false;
|
15812 | const cur = context.currentNode;
|
15813 | if (cur.codegenNode) {
|
15814 | cur.codegenNode = context.cache(
|
15815 | cur.codegenNode,
|
15816 | true
|
15817 |
|
15818 | );
|
15819 | }
|
15820 | };
|
15821 | }
|
15822 | };
|
15823 |
|
15824 | const transformModel$1 = (dir, node, context) => {
|
15825 | const { exp, arg } = dir;
|
15826 | if (!exp) {
|
15827 | context.onError(
|
15828 | createCompilerError(41, dir.loc)
|
15829 | );
|
15830 | return createTransformProps();
|
15831 | }
|
15832 | const rawExp = exp.loc.source;
|
15833 | const expString = exp.type === 4 ? exp.content : rawExp;
|
15834 | const bindingType = context.bindingMetadata[rawExp];
|
15835 | if (bindingType === "props" || bindingType === "props-aliased") {
|
15836 | context.onError(createCompilerError(44, exp.loc));
|
15837 | return createTransformProps();
|
15838 | }
|
15839 | const maybeRef = false;
|
15840 | if (!expString.trim() || !isMemberExpression(expString) && !maybeRef) {
|
15841 | context.onError(
|
15842 | createCompilerError(42, exp.loc)
|
15843 | );
|
15844 | return createTransformProps();
|
15845 | }
|
15846 | const propName = arg ? arg : createSimpleExpression("modelValue", true);
|
15847 | const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
|
15848 | let assignmentExp;
|
15849 | const eventArg = context.isTS ? `($event: any)` : `$event`;
|
15850 | {
|
15851 | assignmentExp = createCompoundExpression([
|
15852 | `${eventArg} => ((`,
|
15853 | exp,
|
15854 | `) = $event)`
|
15855 | ]);
|
15856 | }
|
15857 | const props = [
|
15858 |
|
15859 | createObjectProperty(propName, dir.exp),
|
15860 |
|
15861 | createObjectProperty(eventName, assignmentExp)
|
15862 | ];
|
15863 | if (dir.modifiers.length && node.tagType === 1) {
|
15864 | const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
|
15865 | const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
|
15866 | props.push(
|
15867 | createObjectProperty(
|
15868 | modifiersKey,
|
15869 | createSimpleExpression(
|
15870 | `{ ${modifiers} }`,
|
15871 | false,
|
15872 | dir.loc,
|
15873 | 2
|
15874 | )
|
15875 | )
|
15876 | );
|
15877 | }
|
15878 | return createTransformProps(props);
|
15879 | };
|
15880 | function createTransformProps(props = []) {
|
15881 | return { props };
|
15882 | }
|
15883 |
|
15884 | const seen = new WeakSet();
|
15885 | const transformMemo = (node, context) => {
|
15886 | if (node.type === 1) {
|
15887 | const dir = findDir(node, "memo");
|
15888 | if (!dir || seen.has(node)) {
|
15889 | return;
|
15890 | }
|
15891 | seen.add(node);
|
15892 | return () => {
|
15893 | const codegenNode = node.codegenNode || context.currentNode.codegenNode;
|
15894 | if (codegenNode && codegenNode.type === 13) {
|
15895 | if (node.tagType !== 1) {
|
15896 | convertToBlock(codegenNode, context);
|
15897 | }
|
15898 | node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
15899 | dir.exp,
|
15900 | createFunctionExpression(void 0, codegenNode),
|
15901 | `_cache`,
|
15902 | String(context.cached++)
|
15903 | ]);
|
15904 | }
|
15905 | };
|
15906 | }
|
15907 | };
|
15908 |
|
15909 | function getBaseTransformPreset(prefixIdentifiers) {
|
15910 | return [
|
15911 | [
|
15912 | transformOnce,
|
15913 | transformIf,
|
15914 | transformMemo,
|
15915 | transformFor,
|
15916 | ...[],
|
15917 | ...[transformExpression] ,
|
15918 | transformSlotOutlet,
|
15919 | transformElement,
|
15920 | trackSlotScopes,
|
15921 | transformText
|
15922 | ],
|
15923 | {
|
15924 | on: transformOn$1,
|
15925 | bind: transformBind,
|
15926 | model: transformModel$1
|
15927 | }
|
15928 | ];
|
15929 | }
|
15930 | function baseCompile(source, options = {}) {
|
15931 | const onError = options.onError || defaultOnError;
|
15932 | const isModuleMode = options.mode === "module";
|
15933 | {
|
15934 | if (options.prefixIdentifiers === true) {
|
15935 | onError(createCompilerError(47));
|
15936 | } else if (isModuleMode) {
|
15937 | onError(createCompilerError(48));
|
15938 | }
|
15939 | }
|
15940 | const prefixIdentifiers = false;
|
15941 | if (options.cacheHandlers) {
|
15942 | onError(createCompilerError(49));
|
15943 | }
|
15944 | if (options.scopeId && !isModuleMode) {
|
15945 | onError(createCompilerError(50));
|
15946 | }
|
15947 | const resolvedOptions = extend({}, options, {
|
15948 | prefixIdentifiers
|
15949 | });
|
15950 | const ast = isString(source) ? baseParse(source, resolvedOptions) : source;
|
15951 | const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
15952 | transform(
|
15953 | ast,
|
15954 | extend({}, resolvedOptions, {
|
15955 | nodeTransforms: [
|
15956 | ...nodeTransforms,
|
15957 | ...options.nodeTransforms || []
|
15958 |
|
15959 | ],
|
15960 | directiveTransforms: extend(
|
15961 | {},
|
15962 | directiveTransforms,
|
15963 | options.directiveTransforms || {}
|
15964 |
|
15965 | )
|
15966 | })
|
15967 | );
|
15968 | return generate(ast, resolvedOptions);
|
15969 | }
|
15970 |
|
15971 | const noopDirectiveTransform = () => ({ props: [] });
|
15972 |
|
15973 | const V_MODEL_RADIO = Symbol(`vModelRadio` );
|
15974 | const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
|
15975 | const V_MODEL_TEXT = Symbol(`vModelText` );
|
15976 | const V_MODEL_SELECT = Symbol(`vModelSelect` );
|
15977 | const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
|
15978 | const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
|
15979 | const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
|
15980 | const V_SHOW = Symbol(`vShow` );
|
15981 | const TRANSITION = Symbol(`Transition` );
|
15982 | const TRANSITION_GROUP = Symbol(`TransitionGroup` );
|
15983 | registerRuntimeHelpers({
|
15984 | [V_MODEL_RADIO]: `vModelRadio`,
|
15985 | [V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
15986 | [V_MODEL_TEXT]: `vModelText`,
|
15987 | [V_MODEL_SELECT]: `vModelSelect`,
|
15988 | [V_MODEL_DYNAMIC]: `vModelDynamic`,
|
15989 | [V_ON_WITH_MODIFIERS]: `withModifiers`,
|
15990 | [V_ON_WITH_KEYS]: `withKeys`,
|
15991 | [V_SHOW]: `vShow`,
|
15992 | [TRANSITION]: `Transition`,
|
15993 | [TRANSITION_GROUP]: `TransitionGroup`
|
15994 | });
|
15995 |
|
15996 | let decoder;
|
15997 | function decodeHtmlBrowser(raw, asAttr = false) {
|
15998 | if (!decoder) {
|
15999 | decoder = document.createElement("div");
|
16000 | }
|
16001 | if (asAttr) {
|
16002 | decoder.innerHTML = `<div foo="${raw.replace(/"/g, """)}">`;
|
16003 | return decoder.children[0].getAttribute("foo");
|
16004 | } else {
|
16005 | decoder.innerHTML = raw;
|
16006 | return decoder.textContent;
|
16007 | }
|
16008 | }
|
16009 |
|
16010 | const parserOptions = {
|
16011 | parseMode: "html",
|
16012 | isVoidTag,
|
16013 | isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
16014 | isPreTag: (tag) => tag === "pre",
|
16015 | decodeEntities: decodeHtmlBrowser ,
|
16016 | isBuiltInComponent: (tag) => {
|
16017 | if (tag === "Transition" || tag === "transition") {
|
16018 | return TRANSITION;
|
16019 | } else if (tag === "TransitionGroup" || tag === "transition-group") {
|
16020 | return TRANSITION_GROUP;
|
16021 | }
|
16022 | },
|
16023 |
|
16024 | getNamespace(tag, parent, rootNamespace) {
|
16025 | let ns = parent ? parent.ns : rootNamespace;
|
16026 | if (parent && ns === 2) {
|
16027 | if (parent.tag === "annotation-xml") {
|
16028 | if (tag === "svg") {
|
16029 | return 1;
|
16030 | }
|
16031 | if (parent.props.some(
|
16032 | (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
|
16033 | )) {
|
16034 | ns = 0;
|
16035 | }
|
16036 | } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
|
16037 | ns = 0;
|
16038 | }
|
16039 | } else if (parent && ns === 1) {
|
16040 | if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
|
16041 | ns = 0;
|
16042 | }
|
16043 | }
|
16044 | if (ns === 0) {
|
16045 | if (tag === "svg") {
|
16046 | return 1;
|
16047 | }
|
16048 | if (tag === "math") {
|
16049 | return 2;
|
16050 | }
|
16051 | }
|
16052 | return ns;
|
16053 | }
|
16054 | };
|
16055 |
|
16056 | const transformStyle = (node) => {
|
16057 | if (node.type === 1) {
|
16058 | node.props.forEach((p, i) => {
|
16059 | if (p.type === 6 && p.name === "style" && p.value) {
|
16060 | node.props[i] = {
|
16061 | type: 7,
|
16062 | name: `bind`,
|
16063 | arg: createSimpleExpression(`style`, true, p.loc),
|
16064 | exp: parseInlineCSS(p.value.content, p.loc),
|
16065 | modifiers: [],
|
16066 | loc: p.loc
|
16067 | };
|
16068 | }
|
16069 | });
|
16070 | }
|
16071 | };
|
16072 | const parseInlineCSS = (cssText, loc) => {
|
16073 | const normalized = parseStringStyle(cssText);
|
16074 | return createSimpleExpression(
|
16075 | JSON.stringify(normalized),
|
16076 | false,
|
16077 | loc,
|
16078 | 3
|
16079 | );
|
16080 | };
|
16081 |
|
16082 | function createDOMCompilerError(code, loc) {
|
16083 | return createCompilerError(
|
16084 | code,
|
16085 | loc,
|
16086 | DOMErrorMessages
|
16087 | );
|
16088 | }
|
16089 | const DOMErrorMessages = {
|
16090 | [53]: `v-html is missing expression.`,
|
16091 | [54]: `v-html will override element children.`,
|
16092 | [55]: `v-text is missing expression.`,
|
16093 | [56]: `v-text will override element children.`,
|
16094 | [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
16095 | [58]: `v-model argument is not supported on plain elements.`,
|
16096 | [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
16097 | [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
16098 | [61]: `v-show is missing expression.`,
|
16099 | [62]: `<Transition> expects exactly one child element or component.`,
|
16100 | [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
16101 | };
|
16102 |
|
16103 | const transformVHtml = (dir, node, context) => {
|
16104 | const { exp, loc } = dir;
|
16105 | if (!exp) {
|
16106 | context.onError(
|
16107 | createDOMCompilerError(53, loc)
|
16108 | );
|
16109 | }
|
16110 | if (node.children.length) {
|
16111 | context.onError(
|
16112 | createDOMCompilerError(54, loc)
|
16113 | );
|
16114 | node.children.length = 0;
|
16115 | }
|
16116 | return {
|
16117 | props: [
|
16118 | createObjectProperty(
|
16119 | createSimpleExpression(`innerHTML`, true, loc),
|
16120 | exp || createSimpleExpression("", true)
|
16121 | )
|
16122 | ]
|
16123 | };
|
16124 | };
|
16125 |
|
16126 | const transformVText = (dir, node, context) => {
|
16127 | const { exp, loc } = dir;
|
16128 | if (!exp) {
|
16129 | context.onError(
|
16130 | createDOMCompilerError(55, loc)
|
16131 | );
|
16132 | }
|
16133 | if (node.children.length) {
|
16134 | context.onError(
|
16135 | createDOMCompilerError(56, loc)
|
16136 | );
|
16137 | node.children.length = 0;
|
16138 | }
|
16139 | return {
|
16140 | props: [
|
16141 | createObjectProperty(
|
16142 | createSimpleExpression(`textContent`, true),
|
16143 | exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
|
16144 | context.helperString(TO_DISPLAY_STRING),
|
16145 | [exp],
|
16146 | loc
|
16147 | ) : createSimpleExpression("", true)
|
16148 | )
|
16149 | ]
|
16150 | };
|
16151 | };
|
16152 |
|
16153 | const transformModel = (dir, node, context) => {
|
16154 | const baseResult = transformModel$1(dir, node, context);
|
16155 | if (!baseResult.props.length || node.tagType === 1) {
|
16156 | return baseResult;
|
16157 | }
|
16158 | if (dir.arg) {
|
16159 | context.onError(
|
16160 | createDOMCompilerError(
|
16161 | 58,
|
16162 | dir.arg.loc
|
16163 | )
|
16164 | );
|
16165 | }
|
16166 | function checkDuplicatedValue() {
|
16167 | const value = findDir(node, "bind");
|
16168 | if (value && isStaticArgOf(value.arg, "value")) {
|
16169 | context.onError(
|
16170 | createDOMCompilerError(
|
16171 | 60,
|
16172 | value.loc
|
16173 | )
|
16174 | );
|
16175 | }
|
16176 | }
|
16177 | const { tag } = node;
|
16178 | const isCustomElement = context.isCustomElement(tag);
|
16179 | if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
|
16180 | let directiveToUse = V_MODEL_TEXT;
|
16181 | let isInvalidType = false;
|
16182 | if (tag === "input" || isCustomElement) {
|
16183 | const type = findProp(node, `type`);
|
16184 | if (type) {
|
16185 | if (type.type === 7) {
|
16186 | directiveToUse = V_MODEL_DYNAMIC;
|
16187 | } else if (type.value) {
|
16188 | switch (type.value.content) {
|
16189 | case "radio":
|
16190 | directiveToUse = V_MODEL_RADIO;
|
16191 | break;
|
16192 | case "checkbox":
|
16193 | directiveToUse = V_MODEL_CHECKBOX;
|
16194 | break;
|
16195 | case "file":
|
16196 | isInvalidType = true;
|
16197 | context.onError(
|
16198 | createDOMCompilerError(
|
16199 | 59,
|
16200 | dir.loc
|
16201 | )
|
16202 | );
|
16203 | break;
|
16204 | default:
|
16205 | checkDuplicatedValue();
|
16206 | break;
|
16207 | }
|
16208 | }
|
16209 | } else if (hasDynamicKeyVBind(node)) {
|
16210 | directiveToUse = V_MODEL_DYNAMIC;
|
16211 | } else {
|
16212 | checkDuplicatedValue();
|
16213 | }
|
16214 | } else if (tag === "select") {
|
16215 | directiveToUse = V_MODEL_SELECT;
|
16216 | } else {
|
16217 | checkDuplicatedValue();
|
16218 | }
|
16219 | if (!isInvalidType) {
|
16220 | baseResult.needRuntime = context.helper(directiveToUse);
|
16221 | }
|
16222 | } else {
|
16223 | context.onError(
|
16224 | createDOMCompilerError(
|
16225 | 57,
|
16226 | dir.loc
|
16227 | )
|
16228 | );
|
16229 | }
|
16230 | baseResult.props = baseResult.props.filter(
|
16231 | (p) => !(p.key.type === 4 && p.key.content === "modelValue")
|
16232 | );
|
16233 | return baseResult;
|
16234 | };
|
16235 |
|
16236 | const isEventOptionModifier = makeMap(`passive,once,capture`);
|
16237 | const isNonKeyModifier = makeMap(
|
16238 |
|
16239 | `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
|
16240 | );
|
16241 | const maybeKeyModifier = makeMap("left,right");
|
16242 | const isKeyboardEvent = makeMap(
|
16243 | `onkeyup,onkeydown,onkeypress`,
|
16244 | true
|
16245 | );
|
16246 | const resolveModifiers = (key, modifiers, context, loc) => {
|
16247 | const keyModifiers = [];
|
16248 | const nonKeyModifiers = [];
|
16249 | const eventOptionModifiers = [];
|
16250 | for (let i = 0; i < modifiers.length; i++) {
|
16251 | const modifier = modifiers[i];
|
16252 | if (isEventOptionModifier(modifier)) {
|
16253 | eventOptionModifiers.push(modifier);
|
16254 | } else {
|
16255 | if (maybeKeyModifier(modifier)) {
|
16256 | if (isStaticExp(key)) {
|
16257 | if (isKeyboardEvent(key.content)) {
|
16258 | keyModifiers.push(modifier);
|
16259 | } else {
|
16260 | nonKeyModifiers.push(modifier);
|
16261 | }
|
16262 | } else {
|
16263 | keyModifiers.push(modifier);
|
16264 | nonKeyModifiers.push(modifier);
|
16265 | }
|
16266 | } else {
|
16267 | if (isNonKeyModifier(modifier)) {
|
16268 | nonKeyModifiers.push(modifier);
|
16269 | } else {
|
16270 | keyModifiers.push(modifier);
|
16271 | }
|
16272 | }
|
16273 | }
|
16274 | }
|
16275 | return {
|
16276 | keyModifiers,
|
16277 | nonKeyModifiers,
|
16278 | eventOptionModifiers
|
16279 | };
|
16280 | };
|
16281 | const transformClick = (key, event) => {
|
16282 | const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
|
16283 | return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
|
16284 | `(`,
|
16285 | key,
|
16286 | `) === "onClick" ? "${event}" : (`,
|
16287 | key,
|
16288 | `)`
|
16289 | ]) : key;
|
16290 | };
|
16291 | const transformOn = (dir, node, context) => {
|
16292 | return transformOn$1(dir, node, context, (baseResult) => {
|
16293 | const { modifiers } = dir;
|
16294 | if (!modifiers.length)
|
16295 | return baseResult;
|
16296 | let { key, value: handlerExp } = baseResult.props[0];
|
16297 | const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
16298 | if (nonKeyModifiers.includes("right")) {
|
16299 | key = transformClick(key, `onContextmenu`);
|
16300 | }
|
16301 | if (nonKeyModifiers.includes("middle")) {
|
16302 | key = transformClick(key, `onMouseup`);
|
16303 | }
|
16304 | if (nonKeyModifiers.length) {
|
16305 | handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
|
16306 | handlerExp,
|
16307 | JSON.stringify(nonKeyModifiers)
|
16308 | ]);
|
16309 | }
|
16310 | if (keyModifiers.length &&
|
16311 | (!isStaticExp(key) || isKeyboardEvent(key.content))) {
|
16312 | handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
16313 | handlerExp,
|
16314 | JSON.stringify(keyModifiers)
|
16315 | ]);
|
16316 | }
|
16317 | if (eventOptionModifiers.length) {
|
16318 | const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
|
16319 | key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
16320 | }
|
16321 | return {
|
16322 | props: [createObjectProperty(key, handlerExp)]
|
16323 | };
|
16324 | });
|
16325 | };
|
16326 |
|
16327 | const transformShow = (dir, node, context) => {
|
16328 | const { exp, loc } = dir;
|
16329 | if (!exp) {
|
16330 | context.onError(
|
16331 | createDOMCompilerError(61, loc)
|
16332 | );
|
16333 | }
|
16334 | return {
|
16335 | props: [],
|
16336 | needRuntime: context.helper(V_SHOW)
|
16337 | };
|
16338 | };
|
16339 |
|
16340 | const transformTransition = (node, context) => {
|
16341 | if (node.type === 1 && node.tagType === 1) {
|
16342 | const component = context.isBuiltInComponent(node.tag);
|
16343 | if (component === TRANSITION) {
|
16344 | return () => {
|
16345 | if (!node.children.length) {
|
16346 | return;
|
16347 | }
|
16348 | if (hasMultipleChildren(node)) {
|
16349 | context.onError(
|
16350 | createDOMCompilerError(
|
16351 | 62,
|
16352 | {
|
16353 | start: node.children[0].loc.start,
|
16354 | end: node.children[node.children.length - 1].loc.end,
|
16355 | source: ""
|
16356 | }
|
16357 | )
|
16358 | );
|
16359 | }
|
16360 | const child = node.children[0];
|
16361 | if (child.type === 1) {
|
16362 | for (const p of child.props) {
|
16363 | if (p.type === 7 && p.name === "show") {
|
16364 | node.props.push({
|
16365 | type: 6,
|
16366 | name: "persisted",
|
16367 | nameLoc: node.loc,
|
16368 | value: void 0,
|
16369 | loc: node.loc
|
16370 | });
|
16371 | }
|
16372 | }
|
16373 | }
|
16374 | };
|
16375 | }
|
16376 | }
|
16377 | };
|
16378 | function hasMultipleChildren(node) {
|
16379 | const children = node.children = node.children.filter(
|
16380 | (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
|
16381 | );
|
16382 | const child = children[0];
|
16383 | return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
|
16384 | }
|
16385 |
|
16386 | const ignoreSideEffectTags = (node, context) => {
|
16387 | if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
16388 | context.onError(
|
16389 | createDOMCompilerError(
|
16390 | 63,
|
16391 | node.loc
|
16392 | )
|
16393 | );
|
16394 | context.removeNode();
|
16395 | }
|
16396 | };
|
16397 |
|
16398 | const DOMNodeTransforms = [
|
16399 | transformStyle,
|
16400 | ...[transformTransition]
|
16401 | ];
|
16402 | const DOMDirectiveTransforms = {
|
16403 | cloak: noopDirectiveTransform,
|
16404 | html: transformVHtml,
|
16405 | text: transformVText,
|
16406 | model: transformModel,
|
16407 |
|
16408 | on: transformOn,
|
16409 |
|
16410 | show: transformShow
|
16411 | };
|
16412 | function compile(src, options = {}) {
|
16413 | return baseCompile(
|
16414 | src,
|
16415 | extend({}, parserOptions, options, {
|
16416 | nodeTransforms: [
|
16417 |
|
16418 |
|
16419 |
|
16420 | ignoreSideEffectTags,
|
16421 | ...DOMNodeTransforms,
|
16422 | ...options.nodeTransforms || []
|
16423 | ],
|
16424 | directiveTransforms: extend(
|
16425 | {},
|
16426 | DOMDirectiveTransforms,
|
16427 | options.directiveTransforms || {}
|
16428 | ),
|
16429 | transformHoist: null
|
16430 | })
|
16431 | );
|
16432 | }
|
16433 |
|
16434 | {
|
16435 | initDev();
|
16436 | }
|
16437 | const compileCache = new WeakMap();
|
16438 | function getCache(options) {
|
16439 | let c = compileCache.get(options != null ? options : EMPTY_OBJ);
|
16440 | if (!c) {
|
16441 | c = Object.create(null);
|
16442 | compileCache.set(options != null ? options : EMPTY_OBJ, c);
|
16443 | }
|
16444 | return c;
|
16445 | }
|
16446 | function compileToFunction(template, options) {
|
16447 | if (!isString(template)) {
|
16448 | if (template.nodeType) {
|
16449 | template = template.innerHTML;
|
16450 | } else {
|
16451 | warn(`invalid template option: `, template);
|
16452 | return NOOP;
|
16453 | }
|
16454 | }
|
16455 | const key = template;
|
16456 | const cache = getCache(options);
|
16457 | const cached = cache[key];
|
16458 | if (cached) {
|
16459 | return cached;
|
16460 | }
|
16461 | if (template[0] === "#") {
|
16462 | const el = document.querySelector(template);
|
16463 | if (!el) {
|
16464 | warn(`Template element not found or is empty: ${template}`);
|
16465 | }
|
16466 | template = el ? el.innerHTML : ``;
|
16467 | }
|
16468 | const opts = extend(
|
16469 | {
|
16470 | hoistStatic: true,
|
16471 | onError: onError ,
|
16472 | onWarn: (e) => onError(e, true)
|
16473 | },
|
16474 | options
|
16475 | );
|
16476 | if (!opts.isCustomElement && typeof customElements !== "undefined") {
|
16477 | opts.isCustomElement = (tag) => !!customElements.get(tag);
|
16478 | }
|
16479 | const { code } = compile(template, opts);
|
16480 | function onError(err, asWarning = false) {
|
16481 | const message = asWarning ? err.message : `Template compilation error: ${err.message}`;
|
16482 | const codeFrame = err.loc && generateCodeFrame(
|
16483 | template,
|
16484 | err.loc.start.offset,
|
16485 | err.loc.end.offset
|
16486 | );
|
16487 | warn(codeFrame ? `${message}
|
16488 | ${codeFrame}` : message);
|
16489 | }
|
16490 | const render = new Function(code)() ;
|
16491 | render._rc = true;
|
16492 | return cache[key] = render;
|
16493 | }
|
16494 | registerRuntimeCompiler(compileToFunction);
|
16495 |
|
16496 | exports.BaseTransition = BaseTransition;
|
16497 | exports.BaseTransitionPropsValidators = BaseTransitionPropsValidators;
|
16498 | exports.Comment = Comment;
|
16499 | exports.DeprecationTypes = DeprecationTypes;
|
16500 | exports.EffectScope = EffectScope;
|
16501 | exports.ErrorCodes = ErrorCodes;
|
16502 | exports.ErrorTypeStrings = ErrorTypeStrings;
|
16503 | exports.Fragment = Fragment;
|
16504 | exports.KeepAlive = KeepAlive;
|
16505 | exports.ReactiveEffect = ReactiveEffect;
|
16506 | exports.Static = Static;
|
16507 | exports.Suspense = Suspense;
|
16508 | exports.Teleport = Teleport;
|
16509 | exports.Text = Text;
|
16510 | exports.TrackOpTypes = TrackOpTypes;
|
16511 | exports.Transition = Transition;
|
16512 | exports.TransitionGroup = TransitionGroup;
|
16513 | exports.TriggerOpTypes = TriggerOpTypes;
|
16514 | exports.VueElement = VueElement;
|
16515 | exports.assertNumber = assertNumber;
|
16516 | exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
|
16517 | exports.callWithErrorHandling = callWithErrorHandling;
|
16518 | exports.camelize = camelize;
|
16519 | exports.capitalize = capitalize;
|
16520 | exports.cloneVNode = cloneVNode;
|
16521 | exports.compatUtils = compatUtils;
|
16522 | exports.compile = compileToFunction;
|
16523 | exports.computed = computed;
|
16524 | exports.createApp = createApp;
|
16525 | exports.createBlock = createBlock;
|
16526 | exports.createCommentVNode = createCommentVNode;
|
16527 | exports.createElementBlock = createElementBlock;
|
16528 | exports.createElementVNode = createBaseVNode;
|
16529 | exports.createHydrationRenderer = createHydrationRenderer;
|
16530 | exports.createPropsRestProxy = createPropsRestProxy;
|
16531 | exports.createRenderer = createRenderer;
|
16532 | exports.createSSRApp = createSSRApp;
|
16533 | exports.createSlots = createSlots;
|
16534 | exports.createStaticVNode = createStaticVNode;
|
16535 | exports.createTextVNode = createTextVNode;
|
16536 | exports.createVNode = createVNode;
|
16537 | exports.customRef = customRef;
|
16538 | exports.defineAsyncComponent = defineAsyncComponent;
|
16539 | exports.defineComponent = defineComponent;
|
16540 | exports.defineCustomElement = defineCustomElement;
|
16541 | exports.defineEmits = defineEmits;
|
16542 | exports.defineExpose = defineExpose;
|
16543 | exports.defineModel = defineModel;
|
16544 | exports.defineOptions = defineOptions;
|
16545 | exports.defineProps = defineProps;
|
16546 | exports.defineSSRCustomElement = defineSSRCustomElement;
|
16547 | exports.defineSlots = defineSlots;
|
16548 | exports.devtools = devtools;
|
16549 | exports.effect = effect;
|
16550 | exports.effectScope = effectScope;
|
16551 | exports.getCurrentInstance = getCurrentInstance;
|
16552 | exports.getCurrentScope = getCurrentScope;
|
16553 | exports.getTransitionRawChildren = getTransitionRawChildren;
|
16554 | exports.guardReactiveProps = guardReactiveProps;
|
16555 | exports.h = h;
|
16556 | exports.handleError = handleError;
|
16557 | exports.hasInjectionContext = hasInjectionContext;
|
16558 | exports.hydrate = hydrate;
|
16559 | exports.initCustomFormatter = initCustomFormatter;
|
16560 | exports.initDirectivesForSSR = initDirectivesForSSR;
|
16561 | exports.inject = inject;
|
16562 | exports.isMemoSame = isMemoSame;
|
16563 | exports.isProxy = isProxy;
|
16564 | exports.isReactive = isReactive;
|
16565 | exports.isReadonly = isReadonly;
|
16566 | exports.isRef = isRef;
|
16567 | exports.isRuntimeOnly = isRuntimeOnly;
|
16568 | exports.isShallow = isShallow;
|
16569 | exports.isVNode = isVNode;
|
16570 | exports.markRaw = markRaw;
|
16571 | exports.mergeDefaults = mergeDefaults;
|
16572 | exports.mergeModels = mergeModels;
|
16573 | exports.mergeProps = mergeProps;
|
16574 | exports.nextTick = nextTick;
|
16575 | exports.normalizeClass = normalizeClass;
|
16576 | exports.normalizeProps = normalizeProps;
|
16577 | exports.normalizeStyle = normalizeStyle;
|
16578 | exports.onActivated = onActivated;
|
16579 | exports.onBeforeMount = onBeforeMount;
|
16580 | exports.onBeforeUnmount = onBeforeUnmount;
|
16581 | exports.onBeforeUpdate = onBeforeUpdate;
|
16582 | exports.onDeactivated = onDeactivated;
|
16583 | exports.onErrorCaptured = onErrorCaptured;
|
16584 | exports.onMounted = onMounted;
|
16585 | exports.onRenderTracked = onRenderTracked;
|
16586 | exports.onRenderTriggered = onRenderTriggered;
|
16587 | exports.onScopeDispose = onScopeDispose;
|
16588 | exports.onServerPrefetch = onServerPrefetch;
|
16589 | exports.onUnmounted = onUnmounted;
|
16590 | exports.onUpdated = onUpdated;
|
16591 | exports.openBlock = openBlock;
|
16592 | exports.popScopeId = popScopeId;
|
16593 | exports.provide = provide;
|
16594 | exports.proxyRefs = proxyRefs;
|
16595 | exports.pushScopeId = pushScopeId;
|
16596 | exports.queuePostFlushCb = queuePostFlushCb;
|
16597 | exports.reactive = reactive;
|
16598 | exports.readonly = readonly;
|
16599 | exports.ref = ref;
|
16600 | exports.registerRuntimeCompiler = registerRuntimeCompiler;
|
16601 | exports.render = render;
|
16602 | exports.renderList = renderList;
|
16603 | exports.renderSlot = renderSlot;
|
16604 | exports.resolveComponent = resolveComponent;
|
16605 | exports.resolveDirective = resolveDirective;
|
16606 | exports.resolveDynamicComponent = resolveDynamicComponent;
|
16607 | exports.resolveFilter = resolveFilter;
|
16608 | exports.resolveTransitionHooks = resolveTransitionHooks;
|
16609 | exports.setBlockTracking = setBlockTracking;
|
16610 | exports.setDevtoolsHook = setDevtoolsHook;
|
16611 | exports.setTransitionHooks = setTransitionHooks;
|
16612 | exports.shallowReactive = shallowReactive;
|
16613 | exports.shallowReadonly = shallowReadonly;
|
16614 | exports.shallowRef = shallowRef;
|
16615 | exports.ssrContextKey = ssrContextKey;
|
16616 | exports.ssrUtils = ssrUtils;
|
16617 | exports.stop = stop;
|
16618 | exports.toDisplayString = toDisplayString;
|
16619 | exports.toHandlerKey = toHandlerKey;
|
16620 | exports.toHandlers = toHandlers;
|
16621 | exports.toRaw = toRaw;
|
16622 | exports.toRef = toRef;
|
16623 | exports.toRefs = toRefs;
|
16624 | exports.toValue = toValue;
|
16625 | exports.transformVNodeArgs = transformVNodeArgs;
|
16626 | exports.triggerRef = triggerRef;
|
16627 | exports.unref = unref;
|
16628 | exports.useAttrs = useAttrs;
|
16629 | exports.useCssModule = useCssModule;
|
16630 | exports.useCssVars = useCssVars;
|
16631 | exports.useModel = useModel;
|
16632 | exports.useSSRContext = useSSRContext;
|
16633 | exports.useSlots = useSlots;
|
16634 | exports.useTransitionState = useTransitionState;
|
16635 | exports.vModelCheckbox = vModelCheckbox;
|
16636 | exports.vModelDynamic = vModelDynamic;
|
16637 | exports.vModelRadio = vModelRadio;
|
16638 | exports.vModelSelect = vModelSelect;
|
16639 | exports.vModelText = vModelText;
|
16640 | exports.vShow = vShow;
|
16641 | exports.version = version;
|
16642 | exports.warn = warn;
|
16643 | exports.watch = watch;
|
16644 | exports.watchEffect = watchEffect;
|
16645 | exports.watchPostEffect = watchPostEffect;
|
16646 | exports.watchSyncEffect = watchSyncEffect;
|
16647 | exports.withAsyncContext = withAsyncContext;
|
16648 | exports.withCtx = withCtx;
|
16649 | exports.withDefaults = withDefaults;
|
16650 | exports.withDirectives = withDirectives;
|
16651 | exports.withKeys = withKeys;
|
16652 | exports.withMemo = withMemo;
|
16653 | exports.withModifiers = withModifiers;
|
16654 | exports.withScopeId = withScopeId;
|
16655 |
|
16656 | return exports;
|
16657 |
|
16658 | })({});
|