1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | function makeMap(str, expectsLowerCase) {
|
7 | const set = new Set(str.split(","));
|
8 | return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
|
9 | }
|
10 |
|
11 | const EMPTY_OBJ = Object.freeze({}) ;
|
12 | const EMPTY_ARR = Object.freeze([]) ;
|
13 | const NOOP = () => {
|
14 | };
|
15 | const NO = () => false;
|
16 | const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 &&
|
17 | (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
|
18 | const isModelListener = (key) => key.startsWith("onUpdate:");
|
19 | const extend = Object.assign;
|
20 | const remove = (arr, el) => {
|
21 | const i = arr.indexOf(el);
|
22 | if (i > -1) {
|
23 | arr.splice(i, 1);
|
24 | }
|
25 | };
|
26 | const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
27 | const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
28 | const isArray = Array.isArray;
|
29 | const isMap = (val) => toTypeString(val) === "[object Map]";
|
30 | const isSet = (val) => toTypeString(val) === "[object Set]";
|
31 | const isDate = (val) => toTypeString(val) === "[object Date]";
|
32 | const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
|
33 | const isFunction = (val) => typeof val === "function";
|
34 | const isString = (val) => typeof val === "string";
|
35 | const isSymbol = (val) => typeof val === "symbol";
|
36 | const isObject = (val) => val !== null && typeof val === "object";
|
37 | const isPromise = (val) => {
|
38 | return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
|
39 | };
|
40 | const objectToString = Object.prototype.toString;
|
41 | const toTypeString = (value) => objectToString.call(value);
|
42 | const toRawType = (value) => {
|
43 | return toTypeString(value).slice(8, -1);
|
44 | };
|
45 | const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
46 | const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
47 | const isReservedProp = makeMap(
|
48 |
|
49 | ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
|
50 | );
|
51 | const isBuiltInDirective = makeMap(
|
52 | "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
|
53 | );
|
54 | const cacheStringFunction = (fn) => {
|
55 | const cache = Object.create(null);
|
56 | return (str) => {
|
57 | const hit = cache[str];
|
58 | return hit || (cache[str] = fn(str));
|
59 | };
|
60 | };
|
61 | const camelizeRE = /-(\w)/g;
|
62 | const camelize = cacheStringFunction((str) => {
|
63 | return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
64 | });
|
65 | const hyphenateRE = /\B([A-Z])/g;
|
66 | const hyphenate = cacheStringFunction(
|
67 | (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
68 | );
|
69 | const capitalize = cacheStringFunction((str) => {
|
70 | return str.charAt(0).toUpperCase() + str.slice(1);
|
71 | });
|
72 | const toHandlerKey = cacheStringFunction((str) => {
|
73 | const s = str ? `on${capitalize(str)}` : ``;
|
74 | return s;
|
75 | });
|
76 | const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
77 | const invokeArrayFns = (fns, arg) => {
|
78 | for (let i = 0; i < fns.length; i++) {
|
79 | fns[i](arg);
|
80 | }
|
81 | };
|
82 | const def = (obj, key, value) => {
|
83 | Object.defineProperty(obj, key, {
|
84 | configurable: true,
|
85 | enumerable: false,
|
86 | value
|
87 | });
|
88 | };
|
89 | const looseToNumber = (val) => {
|
90 | const n = parseFloat(val);
|
91 | return isNaN(n) ? val : n;
|
92 | };
|
93 | const toNumber = (val) => {
|
94 | const n = isString(val) ? Number(val) : NaN;
|
95 | return isNaN(n) ? val : n;
|
96 | };
|
97 | let _globalThis;
|
98 | const getGlobalThis = () => {
|
99 | return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
|
100 | };
|
101 |
|
102 | const PatchFlagNames = {
|
103 | [1]: `TEXT`,
|
104 | [2]: `CLASS`,
|
105 | [4]: `STYLE`,
|
106 | [8]: `PROPS`,
|
107 | [16]: `FULL_PROPS`,
|
108 | [32]: `NEED_HYDRATION`,
|
109 | [64]: `STABLE_FRAGMENT`,
|
110 | [128]: `KEYED_FRAGMENT`,
|
111 | [256]: `UNKEYED_FRAGMENT`,
|
112 | [512]: `NEED_PATCH`,
|
113 | [1024]: `DYNAMIC_SLOTS`,
|
114 | [2048]: `DEV_ROOT_FRAGMENT`,
|
115 | [-1]: `HOISTED`,
|
116 | [-2]: `BAIL`
|
117 | };
|
118 |
|
119 | const slotFlagsText = {
|
120 | [1]: "STABLE",
|
121 | [2]: "DYNAMIC",
|
122 | [3]: "FORWARDED"
|
123 | };
|
124 |
|
125 | 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";
|
126 | const isGloballyAllowed = makeMap(GLOBALS_ALLOWED);
|
127 |
|
128 | const range = 2;
|
129 | function generateCodeFrame(source, start = 0, end = source.length) {
|
130 | let lines = source.split(/(\r?\n)/);
|
131 | const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
132 | lines = lines.filter((_, idx) => idx % 2 === 0);
|
133 | let count = 0;
|
134 | const res = [];
|
135 | for (let i = 0; i < lines.length; i++) {
|
136 | count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
|
137 | if (count >= start) {
|
138 | for (let j = i - range; j <= i + range || end > count; j++) {
|
139 | if (j < 0 || j >= lines.length)
|
140 | continue;
|
141 | const line = j + 1;
|
142 | res.push(
|
143 | `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
|
144 | );
|
145 | const lineLength = lines[j].length;
|
146 | const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
|
147 | if (j === i) {
|
148 | const pad = start - (count - (lineLength + newLineSeqLength));
|
149 | const length = Math.max(
|
150 | 1,
|
151 | end > count ? lineLength - pad : end - start
|
152 | );
|
153 | res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
|
154 | } else if (j > i) {
|
155 | if (end > count) {
|
156 | const length = Math.max(Math.min(end - count, lineLength), 1);
|
157 | res.push(` | ` + "^".repeat(length));
|
158 | }
|
159 | count += lineLength + newLineSeqLength;
|
160 | }
|
161 | }
|
162 | break;
|
163 | }
|
164 | }
|
165 | return res.join("\n");
|
166 | }
|
167 |
|
168 | function normalizeStyle(value) {
|
169 | if (isArray(value)) {
|
170 | const res = {};
|
171 | for (let i = 0; i < value.length; i++) {
|
172 | const item = value[i];
|
173 | const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
174 | if (normalized) {
|
175 | for (const key in normalized) {
|
176 | res[key] = normalized[key];
|
177 | }
|
178 | }
|
179 | }
|
180 | return res;
|
181 | } else if (isString(value) || isObject(value)) {
|
182 | return value;
|
183 | }
|
184 | }
|
185 | const listDelimiterRE = /;(?![^(]*\))/g;
|
186 | const propertyDelimiterRE = /:([^]+)/;
|
187 | const styleCommentRE = /\/\*[^]*?\*\//g;
|
188 | function parseStringStyle(cssText) {
|
189 | const ret = {};
|
190 | cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
191 | if (item) {
|
192 | const tmp = item.split(propertyDelimiterRE);
|
193 | tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
194 | }
|
195 | });
|
196 | return ret;
|
197 | }
|
198 | function stringifyStyle(styles) {
|
199 | let ret = "";
|
200 | if (!styles || isString(styles)) {
|
201 | return ret;
|
202 | }
|
203 | for (const key in styles) {
|
204 | const value = styles[key];
|
205 | const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
206 | if (isString(value) || typeof value === "number") {
|
207 | ret += `${normalizedKey}:${value};`;
|
208 | }
|
209 | }
|
210 | return ret;
|
211 | }
|
212 | function normalizeClass(value) {
|
213 | let res = "";
|
214 | if (isString(value)) {
|
215 | res = value;
|
216 | } else if (isArray(value)) {
|
217 | for (let i = 0; i < value.length; i++) {
|
218 | const normalized = normalizeClass(value[i]);
|
219 | if (normalized) {
|
220 | res += normalized + " ";
|
221 | }
|
222 | }
|
223 | } else if (isObject(value)) {
|
224 | for (const name in value) {
|
225 | if (value[name]) {
|
226 | res += name + " ";
|
227 | }
|
228 | }
|
229 | }
|
230 | return res.trim();
|
231 | }
|
232 | function normalizeProps(props) {
|
233 | if (!props)
|
234 | return null;
|
235 | let { class: klass, style } = props;
|
236 | if (klass && !isString(klass)) {
|
237 | props.class = normalizeClass(klass);
|
238 | }
|
239 | if (style) {
|
240 | props.style = normalizeStyle(style);
|
241 | }
|
242 | return props;
|
243 | }
|
244 |
|
245 | 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";
|
246 | 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";
|
247 | 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";
|
248 | const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
|
249 | const isHTMLTag = makeMap(HTML_TAGS);
|
250 | const isSVGTag = makeMap(SVG_TAGS);
|
251 | const isMathMLTag = makeMap(MATH_TAGS);
|
252 | const isVoidTag = makeMap(VOID_TAGS);
|
253 |
|
254 | const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
255 | const isSpecialBooleanAttr = makeMap(specialBooleanAttrs);
|
256 | const isBooleanAttr = makeMap(
|
257 | specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
|
258 | );
|
259 | function includeBooleanAttr(value) {
|
260 | return !!value || value === "";
|
261 | }
|
262 | const isKnownHtmlAttr = makeMap(
|
263 | `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`
|
264 | );
|
265 | const isKnownSvgAttr = makeMap(
|
266 | `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`
|
267 | );
|
268 | function isRenderableAttrValue(value) {
|
269 | if (value == null) {
|
270 | return false;
|
271 | }
|
272 | const type = typeof value;
|
273 | return type === "string" || type === "number" || type === "boolean";
|
274 | }
|
275 |
|
276 | function looseCompareArrays(a, b) {
|
277 | if (a.length !== b.length)
|
278 | return false;
|
279 | let equal = true;
|
280 | for (let i = 0; equal && i < a.length; i++) {
|
281 | equal = looseEqual(a[i], b[i]);
|
282 | }
|
283 | return equal;
|
284 | }
|
285 | function looseEqual(a, b) {
|
286 | if (a === b)
|
287 | return true;
|
288 | let aValidType = isDate(a);
|
289 | let bValidType = isDate(b);
|
290 | if (aValidType || bValidType) {
|
291 | return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
292 | }
|
293 | aValidType = isSymbol(a);
|
294 | bValidType = isSymbol(b);
|
295 | if (aValidType || bValidType) {
|
296 | return a === b;
|
297 | }
|
298 | aValidType = isArray(a);
|
299 | bValidType = isArray(b);
|
300 | if (aValidType || bValidType) {
|
301 | return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
302 | }
|
303 | aValidType = isObject(a);
|
304 | bValidType = isObject(b);
|
305 | if (aValidType || bValidType) {
|
306 | if (!aValidType || !bValidType) {
|
307 | return false;
|
308 | }
|
309 | const aKeysCount = Object.keys(a).length;
|
310 | const bKeysCount = Object.keys(b).length;
|
311 | if (aKeysCount !== bKeysCount) {
|
312 | return false;
|
313 | }
|
314 | for (const key in a) {
|
315 | const aHasKey = a.hasOwnProperty(key);
|
316 | const bHasKey = b.hasOwnProperty(key);
|
317 | if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
|
318 | return false;
|
319 | }
|
320 | }
|
321 | }
|
322 | return String(a) === String(b);
|
323 | }
|
324 | function looseIndexOf(arr, val) {
|
325 | return arr.findIndex((item) => looseEqual(item, val));
|
326 | }
|
327 |
|
328 | const toDisplayString = (val) => {
|
329 | return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
|
330 | };
|
331 | const replacer = (_key, val) => {
|
332 | if (val && val.__v_isRef) {
|
333 | return replacer(_key, val.value);
|
334 | } else if (isMap(val)) {
|
335 | return {
|
336 | [`Map(${val.size})`]: [...val.entries()].reduce(
|
337 | (entries, [key, val2], i) => {
|
338 | entries[stringifySymbol(key, i) + " =>"] = val2;
|
339 | return entries;
|
340 | },
|
341 | {}
|
342 | )
|
343 | };
|
344 | } else if (isSet(val)) {
|
345 | return {
|
346 | [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
|
347 | };
|
348 | } else if (isSymbol(val)) {
|
349 | return stringifySymbol(val);
|
350 | } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
|
351 | return String(val);
|
352 | }
|
353 | return val;
|
354 | };
|
355 | const stringifySymbol = (v, i = "") => {
|
356 | var _a;
|
357 | return isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v;
|
358 | };
|
359 |
|
360 | function warn$2(msg, ...args) {
|
361 | console.warn(`[Vue warn] ${msg}`, ...args);
|
362 | }
|
363 |
|
364 | let activeEffectScope;
|
365 | class EffectScope {
|
366 | constructor(detached = false) {
|
367 | this.detached = detached;
|
368 | |
369 |
|
370 |
|
371 | this._active = true;
|
372 | |
373 |
|
374 |
|
375 | this.effects = [];
|
376 | |
377 |
|
378 |
|
379 | this.cleanups = [];
|
380 | this.parent = activeEffectScope;
|
381 | if (!detached && activeEffectScope) {
|
382 | this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
|
383 | this
|
384 | ) - 1;
|
385 | }
|
386 | }
|
387 | get active() {
|
388 | return this._active;
|
389 | }
|
390 | run(fn) {
|
391 | if (this._active) {
|
392 | const currentEffectScope = activeEffectScope;
|
393 | try {
|
394 | activeEffectScope = this;
|
395 | return fn();
|
396 | } finally {
|
397 | activeEffectScope = currentEffectScope;
|
398 | }
|
399 | } else {
|
400 | warn$2(`cannot run an inactive effect scope.`);
|
401 | }
|
402 | }
|
403 | |
404 |
|
405 |
|
406 |
|
407 | on() {
|
408 | activeEffectScope = this;
|
409 | }
|
410 | |
411 |
|
412 |
|
413 |
|
414 | off() {
|
415 | activeEffectScope = this.parent;
|
416 | }
|
417 | stop(fromParent) {
|
418 | if (this._active) {
|
419 | let i, l;
|
420 | for (i = 0, l = this.effects.length; i < l; i++) {
|
421 | this.effects[i].stop();
|
422 | }
|
423 | for (i = 0, l = this.cleanups.length; i < l; i++) {
|
424 | this.cleanups[i]();
|
425 | }
|
426 | if (this.scopes) {
|
427 | for (i = 0, l = this.scopes.length; i < l; i++) {
|
428 | this.scopes[i].stop(true);
|
429 | }
|
430 | }
|
431 | if (!this.detached && this.parent && !fromParent) {
|
432 | const last = this.parent.scopes.pop();
|
433 | if (last && last !== this) {
|
434 | this.parent.scopes[this.index] = last;
|
435 | last.index = this.index;
|
436 | }
|
437 | }
|
438 | this.parent = void 0;
|
439 | this._active = false;
|
440 | }
|
441 | }
|
442 | }
|
443 | function effectScope(detached) {
|
444 | return new EffectScope(detached);
|
445 | }
|
446 | function recordEffectScope(effect, scope = activeEffectScope) {
|
447 | if (scope && scope.active) {
|
448 | scope.effects.push(effect);
|
449 | }
|
450 | }
|
451 | function getCurrentScope() {
|
452 | return activeEffectScope;
|
453 | }
|
454 | function onScopeDispose(fn) {
|
455 | if (activeEffectScope) {
|
456 | activeEffectScope.cleanups.push(fn);
|
457 | } else {
|
458 | warn$2(
|
459 | `onScopeDispose() is called when there is no active effect scope to be associated with.`
|
460 | );
|
461 | }
|
462 | }
|
463 |
|
464 | let activeEffect;
|
465 | class ReactiveEffect {
|
466 | constructor(fn, trigger, scheduler, scope) {
|
467 | this.fn = fn;
|
468 | this.trigger = trigger;
|
469 | this.scheduler = scheduler;
|
470 | this.active = true;
|
471 | this.deps = [];
|
472 | |
473 |
|
474 |
|
475 | this._dirtyLevel = 4;
|
476 | |
477 |
|
478 |
|
479 | this._trackId = 0;
|
480 | |
481 |
|
482 |
|
483 | this._runnings = 0;
|
484 | |
485 |
|
486 |
|
487 | this._shouldSchedule = false;
|
488 | |
489 |
|
490 |
|
491 | this._depsLength = 0;
|
492 | recordEffectScope(this, scope);
|
493 | }
|
494 | get dirty() {
|
495 | if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
|
496 | this._dirtyLevel = 1;
|
497 | pauseTracking();
|
498 | for (let i = 0; i < this._depsLength; i++) {
|
499 | const dep = this.deps[i];
|
500 | if (dep.computed) {
|
501 | triggerComputed(dep.computed);
|
502 | if (this._dirtyLevel >= 4) {
|
503 | break;
|
504 | }
|
505 | }
|
506 | }
|
507 | if (this._dirtyLevel === 1) {
|
508 | this._dirtyLevel = 0;
|
509 | }
|
510 | resetTracking();
|
511 | }
|
512 | return this._dirtyLevel >= 4;
|
513 | }
|
514 | set dirty(v) {
|
515 | this._dirtyLevel = v ? 4 : 0;
|
516 | }
|
517 | run() {
|
518 | this._dirtyLevel = 0;
|
519 | if (!this.active) {
|
520 | return this.fn();
|
521 | }
|
522 | let lastShouldTrack = shouldTrack;
|
523 | let lastEffect = activeEffect;
|
524 | try {
|
525 | shouldTrack = true;
|
526 | activeEffect = this;
|
527 | this._runnings++;
|
528 | preCleanupEffect(this);
|
529 | return this.fn();
|
530 | } finally {
|
531 | postCleanupEffect(this);
|
532 | this._runnings--;
|
533 | activeEffect = lastEffect;
|
534 | shouldTrack = lastShouldTrack;
|
535 | }
|
536 | }
|
537 | stop() {
|
538 | var _a;
|
539 | if (this.active) {
|
540 | preCleanupEffect(this);
|
541 | postCleanupEffect(this);
|
542 | (_a = this.onStop) == null ? void 0 : _a.call(this);
|
543 | this.active = false;
|
544 | }
|
545 | }
|
546 | }
|
547 | function triggerComputed(computed) {
|
548 | return computed.value;
|
549 | }
|
550 | function preCleanupEffect(effect2) {
|
551 | effect2._trackId++;
|
552 | effect2._depsLength = 0;
|
553 | }
|
554 | function postCleanupEffect(effect2) {
|
555 | if (effect2.deps.length > effect2._depsLength) {
|
556 | for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
|
557 | cleanupDepEffect(effect2.deps[i], effect2);
|
558 | }
|
559 | effect2.deps.length = effect2._depsLength;
|
560 | }
|
561 | }
|
562 | function cleanupDepEffect(dep, effect2) {
|
563 | const trackId = dep.get(effect2);
|
564 | if (trackId !== void 0 && effect2._trackId !== trackId) {
|
565 | dep.delete(effect2);
|
566 | if (dep.size === 0) {
|
567 | dep.cleanup();
|
568 | }
|
569 | }
|
570 | }
|
571 | function effect(fn, options) {
|
572 | if (fn.effect instanceof ReactiveEffect) {
|
573 | fn = fn.effect.fn;
|
574 | }
|
575 | const _effect = new ReactiveEffect(fn, NOOP, () => {
|
576 | if (_effect.dirty) {
|
577 | _effect.run();
|
578 | }
|
579 | });
|
580 | if (options) {
|
581 | extend(_effect, options);
|
582 | if (options.scope)
|
583 | recordEffectScope(_effect, options.scope);
|
584 | }
|
585 | if (!options || !options.lazy) {
|
586 | _effect.run();
|
587 | }
|
588 | const runner = _effect.run.bind(_effect);
|
589 | runner.effect = _effect;
|
590 | return runner;
|
591 | }
|
592 | function stop(runner) {
|
593 | runner.effect.stop();
|
594 | }
|
595 | let shouldTrack = true;
|
596 | let pauseScheduleStack = 0;
|
597 | const trackStack = [];
|
598 | function pauseTracking() {
|
599 | trackStack.push(shouldTrack);
|
600 | shouldTrack = false;
|
601 | }
|
602 | function resetTracking() {
|
603 | const last = trackStack.pop();
|
604 | shouldTrack = last === void 0 ? true : last;
|
605 | }
|
606 | function pauseScheduling() {
|
607 | pauseScheduleStack++;
|
608 | }
|
609 | function resetScheduling() {
|
610 | pauseScheduleStack--;
|
611 | while (!pauseScheduleStack && queueEffectSchedulers.length) {
|
612 | queueEffectSchedulers.shift()();
|
613 | }
|
614 | }
|
615 | function trackEffect(effect2, dep, debuggerEventExtraInfo) {
|
616 | var _a;
|
617 | if (dep.get(effect2) !== effect2._trackId) {
|
618 | dep.set(effect2, effect2._trackId);
|
619 | const oldDep = effect2.deps[effect2._depsLength];
|
620 | if (oldDep !== dep) {
|
621 | if (oldDep) {
|
622 | cleanupDepEffect(oldDep, effect2);
|
623 | }
|
624 | effect2.deps[effect2._depsLength++] = dep;
|
625 | } else {
|
626 | effect2._depsLength++;
|
627 | }
|
628 | {
|
629 | (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
630 | }
|
631 | }
|
632 | }
|
633 | const queueEffectSchedulers = [];
|
634 | function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
635 | var _a;
|
636 | pauseScheduling();
|
637 | for (const effect2 of dep.keys()) {
|
638 | let tracking;
|
639 | if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
640 | effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
|
641 | effect2._dirtyLevel = dirtyLevel;
|
642 | }
|
643 | if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
644 | {
|
645 | (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
646 | }
|
647 | effect2.trigger();
|
648 | if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
|
649 | effect2._shouldSchedule = false;
|
650 | if (effect2.scheduler) {
|
651 | queueEffectSchedulers.push(effect2.scheduler);
|
652 | }
|
653 | }
|
654 | }
|
655 | }
|
656 | resetScheduling();
|
657 | }
|
658 |
|
659 | const createDep = (cleanup, computed) => {
|
660 | const dep = new Map();
|
661 | dep.cleanup = cleanup;
|
662 | dep.computed = computed;
|
663 | return dep;
|
664 | };
|
665 |
|
666 | const targetMap = new WeakMap();
|
667 | const ITERATE_KEY = Symbol("iterate" );
|
668 | const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
|
669 | function track(target, type, key) {
|
670 | if (shouldTrack && activeEffect) {
|
671 | let depsMap = targetMap.get(target);
|
672 | if (!depsMap) {
|
673 | targetMap.set(target, depsMap = new Map());
|
674 | }
|
675 | let dep = depsMap.get(key);
|
676 | if (!dep) {
|
677 | depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
|
678 | }
|
679 | trackEffect(
|
680 | activeEffect,
|
681 | dep,
|
682 | {
|
683 | target,
|
684 | type,
|
685 | key
|
686 | }
|
687 | );
|
688 | }
|
689 | }
|
690 | function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
691 | const depsMap = targetMap.get(target);
|
692 | if (!depsMap) {
|
693 | return;
|
694 | }
|
695 | let deps = [];
|
696 | if (type === "clear") {
|
697 | deps = [...depsMap.values()];
|
698 | } else if (key === "length" && isArray(target)) {
|
699 | const newLength = Number(newValue);
|
700 | depsMap.forEach((dep, key2) => {
|
701 | if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
|
702 | deps.push(dep);
|
703 | }
|
704 | });
|
705 | } else {
|
706 | if (key !== void 0) {
|
707 | deps.push(depsMap.get(key));
|
708 | }
|
709 | switch (type) {
|
710 | case "add":
|
711 | if (!isArray(target)) {
|
712 | deps.push(depsMap.get(ITERATE_KEY));
|
713 | if (isMap(target)) {
|
714 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
715 | }
|
716 | } else if (isIntegerKey(key)) {
|
717 | deps.push(depsMap.get("length"));
|
718 | }
|
719 | break;
|
720 | case "delete":
|
721 | if (!isArray(target)) {
|
722 | deps.push(depsMap.get(ITERATE_KEY));
|
723 | if (isMap(target)) {
|
724 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
725 | }
|
726 | }
|
727 | break;
|
728 | case "set":
|
729 | if (isMap(target)) {
|
730 | deps.push(depsMap.get(ITERATE_KEY));
|
731 | }
|
732 | break;
|
733 | }
|
734 | }
|
735 | pauseScheduling();
|
736 | for (const dep of deps) {
|
737 | if (dep) {
|
738 | triggerEffects(
|
739 | dep,
|
740 | 4,
|
741 | {
|
742 | target,
|
743 | type,
|
744 | key,
|
745 | newValue,
|
746 | oldValue,
|
747 | oldTarget
|
748 | }
|
749 | );
|
750 | }
|
751 | }
|
752 | resetScheduling();
|
753 | }
|
754 | function getDepFromReactive(object, key) {
|
755 | var _a;
|
756 | return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
|
757 | }
|
758 |
|
759 | const isNonTrackableKeys = makeMap(`__proto__,__v_isRef,__isVue`);
|
760 | const builtInSymbols = new Set(
|
761 | Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
762 | );
|
763 | const arrayInstrumentations = createArrayInstrumentations();
|
764 | function createArrayInstrumentations() {
|
765 | const instrumentations = {};
|
766 | ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
767 | instrumentations[key] = function(...args) {
|
768 | const arr = toRaw(this);
|
769 | for (let i = 0, l = this.length; i < l; i++) {
|
770 | track(arr, "get", i + "");
|
771 | }
|
772 | const res = arr[key](...args);
|
773 | if (res === -1 || res === false) {
|
774 | return arr[key](...args.map(toRaw));
|
775 | } else {
|
776 | return res;
|
777 | }
|
778 | };
|
779 | });
|
780 | ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
781 | instrumentations[key] = function(...args) {
|
782 | pauseTracking();
|
783 | pauseScheduling();
|
784 | const res = toRaw(this)[key].apply(this, args);
|
785 | resetScheduling();
|
786 | resetTracking();
|
787 | return res;
|
788 | };
|
789 | });
|
790 | return instrumentations;
|
791 | }
|
792 | function hasOwnProperty(key) {
|
793 | const obj = toRaw(this);
|
794 | track(obj, "has", key);
|
795 | return obj.hasOwnProperty(key);
|
796 | }
|
797 | class BaseReactiveHandler {
|
798 | constructor(_isReadonly = false, _shallow = false) {
|
799 | this._isReadonly = _isReadonly;
|
800 | this._shallow = _shallow;
|
801 | }
|
802 | get(target, key, receiver) {
|
803 | const isReadonly2 = this._isReadonly, shallow = this._shallow;
|
804 | if (key === "__v_isReactive") {
|
805 | return !isReadonly2;
|
806 | } else if (key === "__v_isReadonly") {
|
807 | return isReadonly2;
|
808 | } else if (key === "__v_isShallow") {
|
809 | return shallow;
|
810 | } else if (key === "__v_raw") {
|
811 | if (receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target) ||
|
812 |
|
813 | Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
814 | return target;
|
815 | }
|
816 | return;
|
817 | }
|
818 | const targetIsArray = isArray(target);
|
819 | if (!isReadonly2) {
|
820 | if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
821 | return Reflect.get(arrayInstrumentations, key, receiver);
|
822 | }
|
823 | if (key === "hasOwnProperty") {
|
824 | return hasOwnProperty;
|
825 | }
|
826 | }
|
827 | const res = Reflect.get(target, key, receiver);
|
828 | if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
829 | return res;
|
830 | }
|
831 | if (!isReadonly2) {
|
832 | track(target, "get", key);
|
833 | }
|
834 | if (shallow) {
|
835 | return res;
|
836 | }
|
837 | if (isRef(res)) {
|
838 | return targetIsArray && isIntegerKey(key) ? res : res.value;
|
839 | }
|
840 | if (isObject(res)) {
|
841 | return isReadonly2 ? readonly(res) : reactive(res);
|
842 | }
|
843 | return res;
|
844 | }
|
845 | }
|
846 | class MutableReactiveHandler extends BaseReactiveHandler {
|
847 | constructor(shallow = false) {
|
848 | super(false, shallow);
|
849 | }
|
850 | set(target, key, value, receiver) {
|
851 | let oldValue = target[key];
|
852 | if (!this._shallow) {
|
853 | const isOldValueReadonly = isReadonly(oldValue);
|
854 | if (!isShallow(value) && !isReadonly(value)) {
|
855 | oldValue = toRaw(oldValue);
|
856 | value = toRaw(value);
|
857 | }
|
858 | if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
859 | if (isOldValueReadonly) {
|
860 | return false;
|
861 | } else {
|
862 | oldValue.value = value;
|
863 | return true;
|
864 | }
|
865 | }
|
866 | }
|
867 | const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
868 | const result = Reflect.set(target, key, value, receiver);
|
869 | if (target === toRaw(receiver)) {
|
870 | if (!hadKey) {
|
871 | trigger(target, "add", key, value);
|
872 | } else if (hasChanged(value, oldValue)) {
|
873 | trigger(target, "set", key, value, oldValue);
|
874 | }
|
875 | }
|
876 | return result;
|
877 | }
|
878 | deleteProperty(target, key) {
|
879 | const hadKey = hasOwn(target, key);
|
880 | const oldValue = target[key];
|
881 | const result = Reflect.deleteProperty(target, key);
|
882 | if (result && hadKey) {
|
883 | trigger(target, "delete", key, void 0, oldValue);
|
884 | }
|
885 | return result;
|
886 | }
|
887 | has(target, key) {
|
888 | const result = Reflect.has(target, key);
|
889 | if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
890 | track(target, "has", key);
|
891 | }
|
892 | return result;
|
893 | }
|
894 | ownKeys(target) {
|
895 | track(
|
896 | target,
|
897 | "iterate",
|
898 | isArray(target) ? "length" : ITERATE_KEY
|
899 | );
|
900 | return Reflect.ownKeys(target);
|
901 | }
|
902 | }
|
903 | class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
904 | constructor(shallow = false) {
|
905 | super(true, shallow);
|
906 | }
|
907 | set(target, key) {
|
908 | {
|
909 | warn$2(
|
910 | `Set operation on key "${String(key)}" failed: target is readonly.`,
|
911 | target
|
912 | );
|
913 | }
|
914 | return true;
|
915 | }
|
916 | deleteProperty(target, key) {
|
917 | {
|
918 | warn$2(
|
919 | `Delete operation on key "${String(key)}" failed: target is readonly.`,
|
920 | target
|
921 | );
|
922 | }
|
923 | return true;
|
924 | }
|
925 | }
|
926 | const mutableHandlers = new MutableReactiveHandler();
|
927 | const readonlyHandlers = new ReadonlyReactiveHandler();
|
928 | const shallowReactiveHandlers = new MutableReactiveHandler(
|
929 | true
|
930 | );
|
931 | const shallowReadonlyHandlers = new ReadonlyReactiveHandler(true);
|
932 |
|
933 | const toShallow = (value) => value;
|
934 | const getProto = (v) => Reflect.getPrototypeOf(v);
|
935 | function get(target, key, isReadonly = false, isShallow = false) {
|
936 | target = target["__v_raw"];
|
937 | const rawTarget = toRaw(target);
|
938 | const rawKey = toRaw(key);
|
939 | if (!isReadonly) {
|
940 | if (hasChanged(key, rawKey)) {
|
941 | track(rawTarget, "get", key);
|
942 | }
|
943 | track(rawTarget, "get", rawKey);
|
944 | }
|
945 | const { has: has2 } = getProto(rawTarget);
|
946 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
947 | if (has2.call(rawTarget, key)) {
|
948 | return wrap(target.get(key));
|
949 | } else if (has2.call(rawTarget, rawKey)) {
|
950 | return wrap(target.get(rawKey));
|
951 | } else if (target !== rawTarget) {
|
952 | target.get(key);
|
953 | }
|
954 | }
|
955 | function has(key, isReadonly = false) {
|
956 | const target = this["__v_raw"];
|
957 | const rawTarget = toRaw(target);
|
958 | const rawKey = toRaw(key);
|
959 | if (!isReadonly) {
|
960 | if (hasChanged(key, rawKey)) {
|
961 | track(rawTarget, "has", key);
|
962 | }
|
963 | track(rawTarget, "has", rawKey);
|
964 | }
|
965 | return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
966 | }
|
967 | function size(target, isReadonly = false) {
|
968 | target = target["__v_raw"];
|
969 | !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY);
|
970 | return Reflect.get(target, "size", target);
|
971 | }
|
972 | function add(value) {
|
973 | value = toRaw(value);
|
974 | const target = toRaw(this);
|
975 | const proto = getProto(target);
|
976 | const hadKey = proto.has.call(target, value);
|
977 | if (!hadKey) {
|
978 | target.add(value);
|
979 | trigger(target, "add", value, value);
|
980 | }
|
981 | return this;
|
982 | }
|
983 | function set(key, value) {
|
984 | value = toRaw(value);
|
985 | const target = toRaw(this);
|
986 | const { has: has2, get: get2 } = getProto(target);
|
987 | let hadKey = has2.call(target, key);
|
988 | if (!hadKey) {
|
989 | key = toRaw(key);
|
990 | hadKey = has2.call(target, key);
|
991 | } else {
|
992 | checkIdentityKeys(target, has2, key);
|
993 | }
|
994 | const oldValue = get2.call(target, key);
|
995 | target.set(key, value);
|
996 | if (!hadKey) {
|
997 | trigger(target, "add", key, value);
|
998 | } else if (hasChanged(value, oldValue)) {
|
999 | trigger(target, "set", key, value, oldValue);
|
1000 | }
|
1001 | return this;
|
1002 | }
|
1003 | function deleteEntry(key) {
|
1004 | const target = toRaw(this);
|
1005 | const { has: has2, get: get2 } = getProto(target);
|
1006 | let hadKey = has2.call(target, key);
|
1007 | if (!hadKey) {
|
1008 | key = toRaw(key);
|
1009 | hadKey = has2.call(target, key);
|
1010 | } else {
|
1011 | checkIdentityKeys(target, has2, key);
|
1012 | }
|
1013 | const oldValue = get2 ? get2.call(target, key) : void 0;
|
1014 | const result = target.delete(key);
|
1015 | if (hadKey) {
|
1016 | trigger(target, "delete", key, void 0, oldValue);
|
1017 | }
|
1018 | return result;
|
1019 | }
|
1020 | function clear() {
|
1021 | const target = toRaw(this);
|
1022 | const hadItems = target.size !== 0;
|
1023 | const oldTarget = isMap(target) ? new Map(target) : new Set(target) ;
|
1024 | const result = target.clear();
|
1025 | if (hadItems) {
|
1026 | trigger(target, "clear", void 0, void 0, oldTarget);
|
1027 | }
|
1028 | return result;
|
1029 | }
|
1030 | function createForEach(isReadonly, isShallow) {
|
1031 | return function forEach(callback, thisArg) {
|
1032 | const observed = this;
|
1033 | const target = observed["__v_raw"];
|
1034 | const rawTarget = toRaw(target);
|
1035 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
1036 | !isReadonly && track(rawTarget, "iterate", ITERATE_KEY);
|
1037 | return target.forEach((value, key) => {
|
1038 | return callback.call(thisArg, wrap(value), wrap(key), observed);
|
1039 | });
|
1040 | };
|
1041 | }
|
1042 | function createIterableMethod(method, isReadonly, isShallow) {
|
1043 | return function(...args) {
|
1044 | const target = this["__v_raw"];
|
1045 | const rawTarget = toRaw(target);
|
1046 | const targetIsMap = isMap(rawTarget);
|
1047 | const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
1048 | const isKeyOnly = method === "keys" && targetIsMap;
|
1049 | const innerIterator = target[method](...args);
|
1050 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
1051 | !isReadonly && track(
|
1052 | rawTarget,
|
1053 | "iterate",
|
1054 | isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
1055 | );
|
1056 | return {
|
1057 |
|
1058 | next() {
|
1059 | const { value, done } = innerIterator.next();
|
1060 | return done ? { value, done } : {
|
1061 | value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
1062 | done
|
1063 | };
|
1064 | },
|
1065 |
|
1066 | [Symbol.iterator]() {
|
1067 | return this;
|
1068 | }
|
1069 | };
|
1070 | };
|
1071 | }
|
1072 | function createReadonlyMethod(type) {
|
1073 | return function(...args) {
|
1074 | {
|
1075 | const key = args[0] ? `on key "${args[0]}" ` : ``;
|
1076 | console.warn(
|
1077 | `${capitalize(type)} operation ${key}failed: target is readonly.`,
|
1078 | toRaw(this)
|
1079 | );
|
1080 | }
|
1081 | return type === "delete" ? false : type === "clear" ? void 0 : this;
|
1082 | };
|
1083 | }
|
1084 | function createInstrumentations() {
|
1085 | const mutableInstrumentations2 = {
|
1086 | get(key) {
|
1087 | return get(this, key);
|
1088 | },
|
1089 | get size() {
|
1090 | return size(this);
|
1091 | },
|
1092 | has,
|
1093 | add,
|
1094 | set,
|
1095 | delete: deleteEntry,
|
1096 | clear,
|
1097 | forEach: createForEach(false, false)
|
1098 | };
|
1099 | const shallowInstrumentations2 = {
|
1100 | get(key) {
|
1101 | return get(this, key, false, true);
|
1102 | },
|
1103 | get size() {
|
1104 | return size(this);
|
1105 | },
|
1106 | has,
|
1107 | add,
|
1108 | set,
|
1109 | delete: deleteEntry,
|
1110 | clear,
|
1111 | forEach: createForEach(false, true)
|
1112 | };
|
1113 | const readonlyInstrumentations2 = {
|
1114 | get(key) {
|
1115 | return get(this, key, true);
|
1116 | },
|
1117 | get size() {
|
1118 | return size(this, true);
|
1119 | },
|
1120 | has(key) {
|
1121 | return has.call(this, key, true);
|
1122 | },
|
1123 | add: createReadonlyMethod("add"),
|
1124 | set: createReadonlyMethod("set"),
|
1125 | delete: createReadonlyMethod("delete"),
|
1126 | clear: createReadonlyMethod("clear"),
|
1127 | forEach: createForEach(true, false)
|
1128 | };
|
1129 | const shallowReadonlyInstrumentations2 = {
|
1130 | get(key) {
|
1131 | return get(this, key, true, true);
|
1132 | },
|
1133 | get size() {
|
1134 | return size(this, true);
|
1135 | },
|
1136 | has(key) {
|
1137 | return has.call(this, key, true);
|
1138 | },
|
1139 | add: createReadonlyMethod("add"),
|
1140 | set: createReadonlyMethod("set"),
|
1141 | delete: createReadonlyMethod("delete"),
|
1142 | clear: createReadonlyMethod("clear"),
|
1143 | forEach: createForEach(true, true)
|
1144 | };
|
1145 | const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
|
1146 | iteratorMethods.forEach((method) => {
|
1147 | mutableInstrumentations2[method] = createIterableMethod(
|
1148 | method,
|
1149 | false,
|
1150 | false
|
1151 | );
|
1152 | readonlyInstrumentations2[method] = createIterableMethod(
|
1153 | method,
|
1154 | true,
|
1155 | false
|
1156 | );
|
1157 | shallowInstrumentations2[method] = createIterableMethod(
|
1158 | method,
|
1159 | false,
|
1160 | true
|
1161 | );
|
1162 | shallowReadonlyInstrumentations2[method] = createIterableMethod(
|
1163 | method,
|
1164 | true,
|
1165 | true
|
1166 | );
|
1167 | });
|
1168 | return [
|
1169 | mutableInstrumentations2,
|
1170 | readonlyInstrumentations2,
|
1171 | shallowInstrumentations2,
|
1172 | shallowReadonlyInstrumentations2
|
1173 | ];
|
1174 | }
|
1175 | const [
|
1176 | mutableInstrumentations,
|
1177 | readonlyInstrumentations,
|
1178 | shallowInstrumentations,
|
1179 | shallowReadonlyInstrumentations
|
1180 | ] = createInstrumentations();
|
1181 | function createInstrumentationGetter(isReadonly, shallow) {
|
1182 | const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations;
|
1183 | return (target, key, receiver) => {
|
1184 | if (key === "__v_isReactive") {
|
1185 | return !isReadonly;
|
1186 | } else if (key === "__v_isReadonly") {
|
1187 | return isReadonly;
|
1188 | } else if (key === "__v_raw") {
|
1189 | return target;
|
1190 | }
|
1191 | return Reflect.get(
|
1192 | hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
1193 | key,
|
1194 | receiver
|
1195 | );
|
1196 | };
|
1197 | }
|
1198 | const mutableCollectionHandlers = {
|
1199 | get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
1200 | };
|
1201 | const shallowCollectionHandlers = {
|
1202 | get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
1203 | };
|
1204 | const readonlyCollectionHandlers = {
|
1205 | get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
1206 | };
|
1207 | const shallowReadonlyCollectionHandlers = {
|
1208 | get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
1209 | };
|
1210 | function checkIdentityKeys(target, has2, key) {
|
1211 | const rawKey = toRaw(key);
|
1212 | if (rawKey !== key && has2.call(target, rawKey)) {
|
1213 | const type = toRawType(target);
|
1214 | console.warn(
|
1215 | `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.`
|
1216 | );
|
1217 | }
|
1218 | }
|
1219 |
|
1220 | const reactiveMap = new WeakMap();
|
1221 | const shallowReactiveMap = new WeakMap();
|
1222 | const readonlyMap = new WeakMap();
|
1223 | const shallowReadonlyMap = new WeakMap();
|
1224 | function targetTypeMap(rawType) {
|
1225 | switch (rawType) {
|
1226 | case "Object":
|
1227 | case "Array":
|
1228 | return 1 ;
|
1229 | case "Map":
|
1230 | case "Set":
|
1231 | case "WeakMap":
|
1232 | case "WeakSet":
|
1233 | return 2 ;
|
1234 | default:
|
1235 | return 0 ;
|
1236 | }
|
1237 | }
|
1238 | function getTargetType(value) {
|
1239 | return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
1240 | }
|
1241 | function reactive(target) {
|
1242 | if (isReadonly(target)) {
|
1243 | return target;
|
1244 | }
|
1245 | return createReactiveObject(
|
1246 | target,
|
1247 | false,
|
1248 | mutableHandlers,
|
1249 | mutableCollectionHandlers,
|
1250 | reactiveMap
|
1251 | );
|
1252 | }
|
1253 | function shallowReactive(target) {
|
1254 | return createReactiveObject(
|
1255 | target,
|
1256 | false,
|
1257 | shallowReactiveHandlers,
|
1258 | shallowCollectionHandlers,
|
1259 | shallowReactiveMap
|
1260 | );
|
1261 | }
|
1262 | function readonly(target) {
|
1263 | return createReactiveObject(
|
1264 | target,
|
1265 | true,
|
1266 | readonlyHandlers,
|
1267 | readonlyCollectionHandlers,
|
1268 | readonlyMap
|
1269 | );
|
1270 | }
|
1271 | function shallowReadonly(target) {
|
1272 | return createReactiveObject(
|
1273 | target,
|
1274 | true,
|
1275 | shallowReadonlyHandlers,
|
1276 | shallowReadonlyCollectionHandlers,
|
1277 | shallowReadonlyMap
|
1278 | );
|
1279 | }
|
1280 | function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
1281 | if (!isObject(target)) {
|
1282 | {
|
1283 | console.warn(`value cannot be made reactive: ${String(target)}`);
|
1284 | }
|
1285 | return target;
|
1286 | }
|
1287 | if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
1288 | return target;
|
1289 | }
|
1290 | const existingProxy = proxyMap.get(target);
|
1291 | if (existingProxy) {
|
1292 | return existingProxy;
|
1293 | }
|
1294 | const targetType = getTargetType(target);
|
1295 | if (targetType === 0 ) {
|
1296 | return target;
|
1297 | }
|
1298 | const proxy = new Proxy(
|
1299 | target,
|
1300 | targetType === 2 ? collectionHandlers : baseHandlers
|
1301 | );
|
1302 | proxyMap.set(target, proxy);
|
1303 | return proxy;
|
1304 | }
|
1305 | function isReactive(value) {
|
1306 | if (isReadonly(value)) {
|
1307 | return isReactive(value["__v_raw"]);
|
1308 | }
|
1309 | return !!(value && value["__v_isReactive"]);
|
1310 | }
|
1311 | function isReadonly(value) {
|
1312 | return !!(value && value["__v_isReadonly"]);
|
1313 | }
|
1314 | function isShallow(value) {
|
1315 | return !!(value && value["__v_isShallow"]);
|
1316 | }
|
1317 | function isProxy(value) {
|
1318 | return isReactive(value) || isReadonly(value);
|
1319 | }
|
1320 | function toRaw(observed) {
|
1321 | const raw = observed && observed["__v_raw"];
|
1322 | return raw ? toRaw(raw) : observed;
|
1323 | }
|
1324 | function markRaw(value) {
|
1325 | if (Object.isExtensible(value)) {
|
1326 | def(value, "__v_skip", true);
|
1327 | }
|
1328 | return value;
|
1329 | }
|
1330 | const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
1331 | const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
1332 |
|
1333 | 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`;
|
1334 | class ComputedRefImpl {
|
1335 | constructor(getter, _setter, isReadonly, isSSR) {
|
1336 | this._setter = _setter;
|
1337 | this.dep = void 0;
|
1338 | this.__v_isRef = true;
|
1339 | this["__v_isReadonly"] = false;
|
1340 | this.effect = new ReactiveEffect(
|
1341 | () => getter(this._value),
|
1342 | () => triggerRefValue(
|
1343 | this,
|
1344 | this.effect._dirtyLevel === 2 ? 2 : 3
|
1345 | )
|
1346 | );
|
1347 | this.effect.computed = this;
|
1348 | this.effect.active = this._cacheable = !isSSR;
|
1349 | this["__v_isReadonly"] = isReadonly;
|
1350 | }
|
1351 | get value() {
|
1352 | const self = toRaw(this);
|
1353 | if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
|
1354 | triggerRefValue(self, 4);
|
1355 | }
|
1356 | trackRefValue(self);
|
1357 | if (self.effect._dirtyLevel >= 2) {
|
1358 | warn$2(COMPUTED_SIDE_EFFECT_WARN);
|
1359 | triggerRefValue(self, 2);
|
1360 | }
|
1361 | return self._value;
|
1362 | }
|
1363 | set value(newValue) {
|
1364 | this._setter(newValue);
|
1365 | }
|
1366 |
|
1367 | get _dirty() {
|
1368 | return this.effect.dirty;
|
1369 | }
|
1370 | set _dirty(v) {
|
1371 | this.effect.dirty = v;
|
1372 | }
|
1373 |
|
1374 | }
|
1375 | function computed$1(getterOrOptions, debugOptions, isSSR = false) {
|
1376 | let getter;
|
1377 | let setter;
|
1378 | const onlyGetter = isFunction(getterOrOptions);
|
1379 | if (onlyGetter) {
|
1380 | getter = getterOrOptions;
|
1381 | setter = () => {
|
1382 | warn$2("Write operation failed: computed value is readonly");
|
1383 | } ;
|
1384 | } else {
|
1385 | getter = getterOrOptions.get;
|
1386 | setter = getterOrOptions.set;
|
1387 | }
|
1388 | const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
1389 | if (debugOptions && !isSSR) {
|
1390 | cRef.effect.onTrack = debugOptions.onTrack;
|
1391 | cRef.effect.onTrigger = debugOptions.onTrigger;
|
1392 | }
|
1393 | return cRef;
|
1394 | }
|
1395 |
|
1396 | function trackRefValue(ref2) {
|
1397 | var _a;
|
1398 | if (shouldTrack && activeEffect) {
|
1399 | ref2 = toRaw(ref2);
|
1400 | trackEffect(
|
1401 | activeEffect,
|
1402 | (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
|
1403 | () => ref2.dep = void 0,
|
1404 | ref2 instanceof ComputedRefImpl ? ref2 : void 0
|
1405 | ),
|
1406 | {
|
1407 | target: ref2,
|
1408 | type: "get",
|
1409 | key: "value"
|
1410 | }
|
1411 | );
|
1412 | }
|
1413 | }
|
1414 | function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
|
1415 | ref2 = toRaw(ref2);
|
1416 | const dep = ref2.dep;
|
1417 | if (dep) {
|
1418 | triggerEffects(
|
1419 | dep,
|
1420 | dirtyLevel,
|
1421 | {
|
1422 | target: ref2,
|
1423 | type: "set",
|
1424 | key: "value",
|
1425 | newValue: newVal
|
1426 | }
|
1427 | );
|
1428 | }
|
1429 | }
|
1430 | function isRef(r) {
|
1431 | return !!(r && r.__v_isRef === true);
|
1432 | }
|
1433 | function ref(value) {
|
1434 | return createRef(value, false);
|
1435 | }
|
1436 | function shallowRef(value) {
|
1437 | return createRef(value, true);
|
1438 | }
|
1439 | function createRef(rawValue, shallow) {
|
1440 | if (isRef(rawValue)) {
|
1441 | return rawValue;
|
1442 | }
|
1443 | return new RefImpl(rawValue, shallow);
|
1444 | }
|
1445 | class RefImpl {
|
1446 | constructor(value, __v_isShallow) {
|
1447 | this.__v_isShallow = __v_isShallow;
|
1448 | this.dep = void 0;
|
1449 | this.__v_isRef = true;
|
1450 | this._rawValue = __v_isShallow ? value : toRaw(value);
|
1451 | this._value = __v_isShallow ? value : toReactive(value);
|
1452 | }
|
1453 | get value() {
|
1454 | trackRefValue(this);
|
1455 | return this._value;
|
1456 | }
|
1457 | set value(newVal) {
|
1458 | const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
|
1459 | newVal = useDirectValue ? newVal : toRaw(newVal);
|
1460 | if (hasChanged(newVal, this._rawValue)) {
|
1461 | this._rawValue = newVal;
|
1462 | this._value = useDirectValue ? newVal : toReactive(newVal);
|
1463 | triggerRefValue(this, 4, newVal);
|
1464 | }
|
1465 | }
|
1466 | }
|
1467 | function triggerRef(ref2) {
|
1468 | triggerRefValue(ref2, 4, ref2.value );
|
1469 | }
|
1470 | function unref(ref2) {
|
1471 | return isRef(ref2) ? ref2.value : ref2;
|
1472 | }
|
1473 | function toValue(source) {
|
1474 | return isFunction(source) ? source() : unref(source);
|
1475 | }
|
1476 | const shallowUnwrapHandlers = {
|
1477 | get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
1478 | set: (target, key, value, receiver) => {
|
1479 | const oldValue = target[key];
|
1480 | if (isRef(oldValue) && !isRef(value)) {
|
1481 | oldValue.value = value;
|
1482 | return true;
|
1483 | } else {
|
1484 | return Reflect.set(target, key, value, receiver);
|
1485 | }
|
1486 | }
|
1487 | };
|
1488 | function proxyRefs(objectWithRefs) {
|
1489 | return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
1490 | }
|
1491 | class CustomRefImpl {
|
1492 | constructor(factory) {
|
1493 | this.dep = void 0;
|
1494 | this.__v_isRef = true;
|
1495 | const { get, set } = factory(
|
1496 | () => trackRefValue(this),
|
1497 | () => triggerRefValue(this)
|
1498 | );
|
1499 | this._get = get;
|
1500 | this._set = set;
|
1501 | }
|
1502 | get value() {
|
1503 | return this._get();
|
1504 | }
|
1505 | set value(newVal) {
|
1506 | this._set(newVal);
|
1507 | }
|
1508 | }
|
1509 | function customRef(factory) {
|
1510 | return new CustomRefImpl(factory);
|
1511 | }
|
1512 | function toRefs(object) {
|
1513 | if (!isProxy(object)) {
|
1514 | console.warn(`toRefs() expects a reactive object but received a plain one.`);
|
1515 | }
|
1516 | const ret = isArray(object) ? new Array(object.length) : {};
|
1517 | for (const key in object) {
|
1518 | ret[key] = propertyToRef(object, key);
|
1519 | }
|
1520 | return ret;
|
1521 | }
|
1522 | class ObjectRefImpl {
|
1523 | constructor(_object, _key, _defaultValue) {
|
1524 | this._object = _object;
|
1525 | this._key = _key;
|
1526 | this._defaultValue = _defaultValue;
|
1527 | this.__v_isRef = true;
|
1528 | }
|
1529 | get value() {
|
1530 | const val = this._object[this._key];
|
1531 | return val === void 0 ? this._defaultValue : val;
|
1532 | }
|
1533 | set value(newVal) {
|
1534 | this._object[this._key] = newVal;
|
1535 | }
|
1536 | get dep() {
|
1537 | return getDepFromReactive(toRaw(this._object), this._key);
|
1538 | }
|
1539 | }
|
1540 | class GetterRefImpl {
|
1541 | constructor(_getter) {
|
1542 | this._getter = _getter;
|
1543 | this.__v_isRef = true;
|
1544 | this.__v_isReadonly = true;
|
1545 | }
|
1546 | get value() {
|
1547 | return this._getter();
|
1548 | }
|
1549 | }
|
1550 | function toRef(source, key, defaultValue) {
|
1551 | if (isRef(source)) {
|
1552 | return source;
|
1553 | } else if (isFunction(source)) {
|
1554 | return new GetterRefImpl(source);
|
1555 | } else if (isObject(source) && arguments.length > 1) {
|
1556 | return propertyToRef(source, key, defaultValue);
|
1557 | } else {
|
1558 | return ref(source);
|
1559 | }
|
1560 | }
|
1561 | function propertyToRef(source, key, defaultValue) {
|
1562 | const val = source[key];
|
1563 | return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
1564 | }
|
1565 |
|
1566 | const TrackOpTypes = {
|
1567 | "GET": "get",
|
1568 | "HAS": "has",
|
1569 | "ITERATE": "iterate"
|
1570 | };
|
1571 | const TriggerOpTypes = {
|
1572 | "SET": "set",
|
1573 | "ADD": "add",
|
1574 | "DELETE": "delete",
|
1575 | "CLEAR": "clear"
|
1576 | };
|
1577 |
|
1578 | const stack$1 = [];
|
1579 | function pushWarningContext(vnode) {
|
1580 | stack$1.push(vnode);
|
1581 | }
|
1582 | function popWarningContext() {
|
1583 | stack$1.pop();
|
1584 | }
|
1585 | function warn$1(msg, ...args) {
|
1586 | pauseTracking();
|
1587 | const instance = stack$1.length ? stack$1[stack$1.length - 1].component : null;
|
1588 | const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
1589 | const trace = getComponentTrace();
|
1590 | if (appWarnHandler) {
|
1591 | callWithErrorHandling(
|
1592 | appWarnHandler,
|
1593 | instance,
|
1594 | 11,
|
1595 | [
|
1596 | msg + args.join(""),
|
1597 | instance && instance.proxy,
|
1598 | trace.map(
|
1599 | ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
|
1600 | ).join("\n"),
|
1601 | trace
|
1602 | ]
|
1603 | );
|
1604 | } else {
|
1605 | const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
1606 | if (trace.length &&
|
1607 | true) {
|
1608 | warnArgs.push(`
|
1609 | `, ...formatTrace(trace));
|
1610 | }
|
1611 | console.warn(...warnArgs);
|
1612 | }
|
1613 | resetTracking();
|
1614 | }
|
1615 | function getComponentTrace() {
|
1616 | let currentVNode = stack$1[stack$1.length - 1];
|
1617 | if (!currentVNode) {
|
1618 | return [];
|
1619 | }
|
1620 | const normalizedStack = [];
|
1621 | while (currentVNode) {
|
1622 | const last = normalizedStack[0];
|
1623 | if (last && last.vnode === currentVNode) {
|
1624 | last.recurseCount++;
|
1625 | } else {
|
1626 | normalizedStack.push({
|
1627 | vnode: currentVNode,
|
1628 | recurseCount: 0
|
1629 | });
|
1630 | }
|
1631 | const parentInstance = currentVNode.component && currentVNode.component.parent;
|
1632 | currentVNode = parentInstance && parentInstance.vnode;
|
1633 | }
|
1634 | return normalizedStack;
|
1635 | }
|
1636 | function formatTrace(trace) {
|
1637 | const logs = [];
|
1638 | trace.forEach((entry, i) => {
|
1639 | logs.push(...i === 0 ? [] : [`
|
1640 | `], ...formatTraceEntry(entry));
|
1641 | });
|
1642 | return logs;
|
1643 | }
|
1644 | function formatTraceEntry({ vnode, recurseCount }) {
|
1645 | const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
1646 | const isRoot = vnode.component ? vnode.component.parent == null : false;
|
1647 | const open = ` at <${formatComponentName(
|
1648 | vnode.component,
|
1649 | vnode.type,
|
1650 | isRoot
|
1651 | )}`;
|
1652 | const close = `>` + postfix;
|
1653 | return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
|
1654 | }
|
1655 | function formatProps(props) {
|
1656 | const res = [];
|
1657 | const keys = Object.keys(props);
|
1658 | keys.slice(0, 3).forEach((key) => {
|
1659 | res.push(...formatProp(key, props[key]));
|
1660 | });
|
1661 | if (keys.length > 3) {
|
1662 | res.push(` ...`);
|
1663 | }
|
1664 | return res;
|
1665 | }
|
1666 | function formatProp(key, value, raw) {
|
1667 | if (isString(value)) {
|
1668 | value = JSON.stringify(value);
|
1669 | return raw ? value : [`${key}=${value}`];
|
1670 | } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
1671 | return raw ? value : [`${key}=${value}`];
|
1672 | } else if (isRef(value)) {
|
1673 | value = formatProp(key, toRaw(value.value), true);
|
1674 | return raw ? value : [`${key}=Ref<`, value, `>`];
|
1675 | } else if (isFunction(value)) {
|
1676 | return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
1677 | } else {
|
1678 | value = toRaw(value);
|
1679 | return raw ? value : [`${key}=`, value];
|
1680 | }
|
1681 | }
|
1682 | function assertNumber(val, type) {
|
1683 | if (val === void 0) {
|
1684 | return;
|
1685 | } else if (typeof val !== "number") {
|
1686 | warn$1(`${type} is not a valid number - got ${JSON.stringify(val)}.`);
|
1687 | } else if (isNaN(val)) {
|
1688 | warn$1(`${type} is NaN - the duration expression might be incorrect.`);
|
1689 | }
|
1690 | }
|
1691 |
|
1692 | const ErrorCodes = {
|
1693 | "SETUP_FUNCTION": 0,
|
1694 | "0": "SETUP_FUNCTION",
|
1695 | "RENDER_FUNCTION": 1,
|
1696 | "1": "RENDER_FUNCTION",
|
1697 | "WATCH_GETTER": 2,
|
1698 | "2": "WATCH_GETTER",
|
1699 | "WATCH_CALLBACK": 3,
|
1700 | "3": "WATCH_CALLBACK",
|
1701 | "WATCH_CLEANUP": 4,
|
1702 | "4": "WATCH_CLEANUP",
|
1703 | "NATIVE_EVENT_HANDLER": 5,
|
1704 | "5": "NATIVE_EVENT_HANDLER",
|
1705 | "COMPONENT_EVENT_HANDLER": 6,
|
1706 | "6": "COMPONENT_EVENT_HANDLER",
|
1707 | "VNODE_HOOK": 7,
|
1708 | "7": "VNODE_HOOK",
|
1709 | "DIRECTIVE_HOOK": 8,
|
1710 | "8": "DIRECTIVE_HOOK",
|
1711 | "TRANSITION_HOOK": 9,
|
1712 | "9": "TRANSITION_HOOK",
|
1713 | "APP_ERROR_HANDLER": 10,
|
1714 | "10": "APP_ERROR_HANDLER",
|
1715 | "APP_WARN_HANDLER": 11,
|
1716 | "11": "APP_WARN_HANDLER",
|
1717 | "FUNCTION_REF": 12,
|
1718 | "12": "FUNCTION_REF",
|
1719 | "ASYNC_COMPONENT_LOADER": 13,
|
1720 | "13": "ASYNC_COMPONENT_LOADER",
|
1721 | "SCHEDULER": 14,
|
1722 | "14": "SCHEDULER"
|
1723 | };
|
1724 | const ErrorTypeStrings$1 = {
|
1725 | ["sp"]: "serverPrefetch hook",
|
1726 | ["bc"]: "beforeCreate hook",
|
1727 | ["c"]: "created hook",
|
1728 | ["bm"]: "beforeMount hook",
|
1729 | ["m"]: "mounted hook",
|
1730 | ["bu"]: "beforeUpdate hook",
|
1731 | ["u"]: "updated",
|
1732 | ["bum"]: "beforeUnmount hook",
|
1733 | ["um"]: "unmounted hook",
|
1734 | ["a"]: "activated hook",
|
1735 | ["da"]: "deactivated hook",
|
1736 | ["ec"]: "errorCaptured hook",
|
1737 | ["rtc"]: "renderTracked hook",
|
1738 | ["rtg"]: "renderTriggered hook",
|
1739 | [0]: "setup function",
|
1740 | [1]: "render function",
|
1741 | [2]: "watcher getter",
|
1742 | [3]: "watcher callback",
|
1743 | [4]: "watcher cleanup function",
|
1744 | [5]: "native event handler",
|
1745 | [6]: "component event handler",
|
1746 | [7]: "vnode hook",
|
1747 | [8]: "directive hook",
|
1748 | [9]: "transition hook",
|
1749 | [10]: "app errorHandler",
|
1750 | [11]: "app warnHandler",
|
1751 | [12]: "ref function",
|
1752 | [13]: "async component loader",
|
1753 | [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
|
1754 | };
|
1755 | function callWithErrorHandling(fn, instance, type, args) {
|
1756 | try {
|
1757 | return args ? fn(...args) : fn();
|
1758 | } catch (err) {
|
1759 | handleError(err, instance, type);
|
1760 | }
|
1761 | }
|
1762 | function callWithAsyncErrorHandling(fn, instance, type, args) {
|
1763 | if (isFunction(fn)) {
|
1764 | const res = callWithErrorHandling(fn, instance, type, args);
|
1765 | if (res && isPromise(res)) {
|
1766 | res.catch((err) => {
|
1767 | handleError(err, instance, type);
|
1768 | });
|
1769 | }
|
1770 | return res;
|
1771 | }
|
1772 | const values = [];
|
1773 | for (let i = 0; i < fn.length; i++) {
|
1774 | values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
1775 | }
|
1776 | return values;
|
1777 | }
|
1778 | function handleError(err, instance, type, throwInDev = true) {
|
1779 | const contextVNode = instance ? instance.vnode : null;
|
1780 | if (instance) {
|
1781 | let cur = instance.parent;
|
1782 | const exposedInstance = instance.proxy;
|
1783 | const errorInfo = ErrorTypeStrings$1[type] ;
|
1784 | while (cur) {
|
1785 | const errorCapturedHooks = cur.ec;
|
1786 | if (errorCapturedHooks) {
|
1787 | for (let i = 0; i < errorCapturedHooks.length; i++) {
|
1788 | if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
1789 | return;
|
1790 | }
|
1791 | }
|
1792 | }
|
1793 | cur = cur.parent;
|
1794 | }
|
1795 | const appErrorHandler = instance.appContext.config.errorHandler;
|
1796 | if (appErrorHandler) {
|
1797 | callWithErrorHandling(
|
1798 | appErrorHandler,
|
1799 | null,
|
1800 | 10,
|
1801 | [err, exposedInstance, errorInfo]
|
1802 | );
|
1803 | return;
|
1804 | }
|
1805 | }
|
1806 | logError(err, type, contextVNode, throwInDev);
|
1807 | }
|
1808 | function logError(err, type, contextVNode, throwInDev = true) {
|
1809 | {
|
1810 | const info = ErrorTypeStrings$1[type];
|
1811 | if (contextVNode) {
|
1812 | pushWarningContext(contextVNode);
|
1813 | }
|
1814 | warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
1815 | if (contextVNode) {
|
1816 | popWarningContext();
|
1817 | }
|
1818 | if (throwInDev) {
|
1819 | throw err;
|
1820 | } else {
|
1821 | console.error(err);
|
1822 | }
|
1823 | }
|
1824 | }
|
1825 |
|
1826 | let isFlushing = false;
|
1827 | let isFlushPending = false;
|
1828 | const queue = [];
|
1829 | let flushIndex = 0;
|
1830 | const pendingPostFlushCbs = [];
|
1831 | let activePostFlushCbs = null;
|
1832 | let postFlushIndex = 0;
|
1833 | const resolvedPromise = Promise.resolve();
|
1834 | let currentFlushPromise = null;
|
1835 | const RECURSION_LIMIT = 100;
|
1836 | function nextTick(fn) {
|
1837 | const p = currentFlushPromise || resolvedPromise;
|
1838 | return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
1839 | }
|
1840 | function findInsertionIndex(id) {
|
1841 | let start = flushIndex + 1;
|
1842 | let end = queue.length;
|
1843 | while (start < end) {
|
1844 | const middle = start + end >>> 1;
|
1845 | const middleJob = queue[middle];
|
1846 | const middleJobId = getId(middleJob);
|
1847 | if (middleJobId < id || middleJobId === id && middleJob.pre) {
|
1848 | start = middle + 1;
|
1849 | } else {
|
1850 | end = middle;
|
1851 | }
|
1852 | }
|
1853 | return start;
|
1854 | }
|
1855 | function queueJob(job) {
|
1856 | if (!queue.length || !queue.includes(
|
1857 | job,
|
1858 | isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
|
1859 | )) {
|
1860 | if (job.id == null) {
|
1861 | queue.push(job);
|
1862 | } else {
|
1863 | queue.splice(findInsertionIndex(job.id), 0, job);
|
1864 | }
|
1865 | queueFlush();
|
1866 | }
|
1867 | }
|
1868 | function queueFlush() {
|
1869 | if (!isFlushing && !isFlushPending) {
|
1870 | isFlushPending = true;
|
1871 | currentFlushPromise = resolvedPromise.then(flushJobs);
|
1872 | }
|
1873 | }
|
1874 | function invalidateJob(job) {
|
1875 | const i = queue.indexOf(job);
|
1876 | if (i > flushIndex) {
|
1877 | queue.splice(i, 1);
|
1878 | }
|
1879 | }
|
1880 | function queuePostFlushCb(cb) {
|
1881 | if (!isArray(cb)) {
|
1882 | if (!activePostFlushCbs || !activePostFlushCbs.includes(
|
1883 | cb,
|
1884 | cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
|
1885 | )) {
|
1886 | pendingPostFlushCbs.push(cb);
|
1887 | }
|
1888 | } else {
|
1889 | pendingPostFlushCbs.push(...cb);
|
1890 | }
|
1891 | queueFlush();
|
1892 | }
|
1893 | function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
|
1894 | {
|
1895 | seen = seen || new Map();
|
1896 | }
|
1897 | for (; i < queue.length; i++) {
|
1898 | const cb = queue[i];
|
1899 | if (cb && cb.pre) {
|
1900 | if (instance && cb.id !== instance.uid) {
|
1901 | continue;
|
1902 | }
|
1903 | if (checkRecursiveUpdates(seen, cb)) {
|
1904 | continue;
|
1905 | }
|
1906 | queue.splice(i, 1);
|
1907 | i--;
|
1908 | cb();
|
1909 | }
|
1910 | }
|
1911 | }
|
1912 | function flushPostFlushCbs(seen) {
|
1913 | if (pendingPostFlushCbs.length) {
|
1914 | const deduped = [...new Set(pendingPostFlushCbs)].sort(
|
1915 | (a, b) => getId(a) - getId(b)
|
1916 | );
|
1917 | pendingPostFlushCbs.length = 0;
|
1918 | if (activePostFlushCbs) {
|
1919 | activePostFlushCbs.push(...deduped);
|
1920 | return;
|
1921 | }
|
1922 | activePostFlushCbs = deduped;
|
1923 | {
|
1924 | seen = seen || new Map();
|
1925 | }
|
1926 | for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
1927 | if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
|
1928 | continue;
|
1929 | }
|
1930 | activePostFlushCbs[postFlushIndex]();
|
1931 | }
|
1932 | activePostFlushCbs = null;
|
1933 | postFlushIndex = 0;
|
1934 | }
|
1935 | }
|
1936 | const getId = (job) => job.id == null ? Infinity : job.id;
|
1937 | const comparator = (a, b) => {
|
1938 | const diff = getId(a) - getId(b);
|
1939 | if (diff === 0) {
|
1940 | if (a.pre && !b.pre)
|
1941 | return -1;
|
1942 | if (b.pre && !a.pre)
|
1943 | return 1;
|
1944 | }
|
1945 | return diff;
|
1946 | };
|
1947 | function flushJobs(seen) {
|
1948 | isFlushPending = false;
|
1949 | isFlushing = true;
|
1950 | {
|
1951 | seen = seen || new Map();
|
1952 | }
|
1953 | queue.sort(comparator);
|
1954 | const check = (job) => checkRecursiveUpdates(seen, job) ;
|
1955 | try {
|
1956 | for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
1957 | const job = queue[flushIndex];
|
1958 | if (job && job.active !== false) {
|
1959 | if (check(job)) {
|
1960 | continue;
|
1961 | }
|
1962 | callWithErrorHandling(job, null, 14);
|
1963 | }
|
1964 | }
|
1965 | } finally {
|
1966 | flushIndex = 0;
|
1967 | queue.length = 0;
|
1968 | flushPostFlushCbs(seen);
|
1969 | isFlushing = false;
|
1970 | currentFlushPromise = null;
|
1971 | if (queue.length || pendingPostFlushCbs.length) {
|
1972 | flushJobs(seen);
|
1973 | }
|
1974 | }
|
1975 | }
|
1976 | function checkRecursiveUpdates(seen, fn) {
|
1977 | if (!seen.has(fn)) {
|
1978 | seen.set(fn, 1);
|
1979 | } else {
|
1980 | const count = seen.get(fn);
|
1981 | if (count > RECURSION_LIMIT) {
|
1982 | const instance = fn.ownerInstance;
|
1983 | const componentName = instance && getComponentName(instance.type);
|
1984 | handleError(
|
1985 | `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.`,
|
1986 | null,
|
1987 | 10
|
1988 | );
|
1989 | return true;
|
1990 | } else {
|
1991 | seen.set(fn, count + 1);
|
1992 | }
|
1993 | }
|
1994 | }
|
1995 |
|
1996 | let isHmrUpdating = false;
|
1997 | const hmrDirtyComponents = new Set();
|
1998 | {
|
1999 | getGlobalThis().__VUE_HMR_RUNTIME__ = {
|
2000 | createRecord: tryWrap(createRecord),
|
2001 | rerender: tryWrap(rerender),
|
2002 | reload: tryWrap(reload)
|
2003 | };
|
2004 | }
|
2005 | const map = new Map();
|
2006 | function registerHMR(instance) {
|
2007 | const id = instance.type.__hmrId;
|
2008 | let record = map.get(id);
|
2009 | if (!record) {
|
2010 | createRecord(id, instance.type);
|
2011 | record = map.get(id);
|
2012 | }
|
2013 | record.instances.add(instance);
|
2014 | }
|
2015 | function unregisterHMR(instance) {
|
2016 | map.get(instance.type.__hmrId).instances.delete(instance);
|
2017 | }
|
2018 | function createRecord(id, initialDef) {
|
2019 | if (map.has(id)) {
|
2020 | return false;
|
2021 | }
|
2022 | map.set(id, {
|
2023 | initialDef: normalizeClassComponent(initialDef),
|
2024 | instances: new Set()
|
2025 | });
|
2026 | return true;
|
2027 | }
|
2028 | function normalizeClassComponent(component) {
|
2029 | return isClassComponent(component) ? component.__vccOpts : component;
|
2030 | }
|
2031 | function rerender(id, newRender) {
|
2032 | const record = map.get(id);
|
2033 | if (!record) {
|
2034 | return;
|
2035 | }
|
2036 | record.initialDef.render = newRender;
|
2037 | [...record.instances].forEach((instance) => {
|
2038 | if (newRender) {
|
2039 | instance.render = newRender;
|
2040 | normalizeClassComponent(instance.type).render = newRender;
|
2041 | }
|
2042 | instance.renderCache = [];
|
2043 | isHmrUpdating = true;
|
2044 | instance.effect.dirty = true;
|
2045 | instance.update();
|
2046 | isHmrUpdating = false;
|
2047 | });
|
2048 | }
|
2049 | function reload(id, newComp) {
|
2050 | const record = map.get(id);
|
2051 | if (!record)
|
2052 | return;
|
2053 | newComp = normalizeClassComponent(newComp);
|
2054 | updateComponentDef(record.initialDef, newComp);
|
2055 | const instances = [...record.instances];
|
2056 | for (const instance of instances) {
|
2057 | const oldComp = normalizeClassComponent(instance.type);
|
2058 | if (!hmrDirtyComponents.has(oldComp)) {
|
2059 | if (oldComp !== record.initialDef) {
|
2060 | updateComponentDef(oldComp, newComp);
|
2061 | }
|
2062 | hmrDirtyComponents.add(oldComp);
|
2063 | }
|
2064 | instance.appContext.propsCache.delete(instance.type);
|
2065 | instance.appContext.emitsCache.delete(instance.type);
|
2066 | instance.appContext.optionsCache.delete(instance.type);
|
2067 | if (instance.ceReload) {
|
2068 | hmrDirtyComponents.add(oldComp);
|
2069 | instance.ceReload(newComp.styles);
|
2070 | hmrDirtyComponents.delete(oldComp);
|
2071 | } else if (instance.parent) {
|
2072 | instance.parent.effect.dirty = true;
|
2073 | queueJob(instance.parent.update);
|
2074 | } else if (instance.appContext.reload) {
|
2075 | instance.appContext.reload();
|
2076 | } else if (typeof window !== "undefined") {
|
2077 | window.location.reload();
|
2078 | } else {
|
2079 | console.warn(
|
2080 | "[HMR] Root or manually mounted instance modified. Full reload required."
|
2081 | );
|
2082 | }
|
2083 | }
|
2084 | queuePostFlushCb(() => {
|
2085 | for (const instance of instances) {
|
2086 | hmrDirtyComponents.delete(
|
2087 | normalizeClassComponent(instance.type)
|
2088 | );
|
2089 | }
|
2090 | });
|
2091 | }
|
2092 | function updateComponentDef(oldComp, newComp) {
|
2093 | extend(oldComp, newComp);
|
2094 | for (const key in oldComp) {
|
2095 | if (key !== "__file" && !(key in newComp)) {
|
2096 | delete oldComp[key];
|
2097 | }
|
2098 | }
|
2099 | }
|
2100 | function tryWrap(fn) {
|
2101 | return (id, arg) => {
|
2102 | try {
|
2103 | return fn(id, arg);
|
2104 | } catch (e) {
|
2105 | console.error(e);
|
2106 | console.warn(
|
2107 | `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
|
2108 | );
|
2109 | }
|
2110 | };
|
2111 | }
|
2112 |
|
2113 | let devtools$1;
|
2114 | let buffer = [];
|
2115 | let devtoolsNotInstalled = false;
|
2116 | function emit$1(event, ...args) {
|
2117 | if (devtools$1) {
|
2118 | devtools$1.emit(event, ...args);
|
2119 | } else if (!devtoolsNotInstalled) {
|
2120 | buffer.push({ event, args });
|
2121 | }
|
2122 | }
|
2123 | function setDevtoolsHook$1(hook, target) {
|
2124 | var _a, _b;
|
2125 | devtools$1 = hook;
|
2126 | if (devtools$1) {
|
2127 | devtools$1.enabled = true;
|
2128 | buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args));
|
2129 | buffer = [];
|
2130 | } else if (
|
2131 |
|
2132 |
|
2133 |
|
2134 | typeof window !== "undefined" &&
|
2135 | window.HTMLElement &&
|
2136 | !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
|
2137 | ) {
|
2138 | const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
|
2139 | replay.push((newHook) => {
|
2140 | setDevtoolsHook$1(newHook, target);
|
2141 | });
|
2142 | setTimeout(() => {
|
2143 | if (!devtools$1) {
|
2144 | target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
|
2145 | devtoolsNotInstalled = true;
|
2146 | buffer = [];
|
2147 | }
|
2148 | }, 3e3);
|
2149 | } else {
|
2150 | devtoolsNotInstalled = true;
|
2151 | buffer = [];
|
2152 | }
|
2153 | }
|
2154 | function devtoolsInitApp(app, version) {
|
2155 | emit$1("app:init" , app, version, {
|
2156 | Fragment,
|
2157 | Text,
|
2158 | Comment,
|
2159 | Static
|
2160 | });
|
2161 | }
|
2162 | function devtoolsUnmountApp(app) {
|
2163 | emit$1("app:unmount" , app);
|
2164 | }
|
2165 | const devtoolsComponentAdded = createDevtoolsComponentHook(
|
2166 | "component:added"
|
2167 | );
|
2168 | const devtoolsComponentUpdated = createDevtoolsComponentHook("component:updated" );
|
2169 | const _devtoolsComponentRemoved = createDevtoolsComponentHook(
|
2170 | "component:removed"
|
2171 | );
|
2172 | const devtoolsComponentRemoved = (component) => {
|
2173 | if (devtools$1 && typeof devtools$1.cleanupBuffer === "function" &&
|
2174 | !devtools$1.cleanupBuffer(component)) {
|
2175 | _devtoolsComponentRemoved(component);
|
2176 | }
|
2177 | };
|
2178 | function createDevtoolsComponentHook(hook) {
|
2179 | return (component) => {
|
2180 | emit$1(
|
2181 | hook,
|
2182 | component.appContext.app,
|
2183 | component.uid,
|
2184 | component.parent ? component.parent.uid : void 0,
|
2185 | component
|
2186 | );
|
2187 | };
|
2188 | }
|
2189 | const devtoolsPerfStart = createDevtoolsPerformanceHook(
|
2190 | "perf:start"
|
2191 | );
|
2192 | const devtoolsPerfEnd = createDevtoolsPerformanceHook(
|
2193 | "perf:end"
|
2194 | );
|
2195 | function createDevtoolsPerformanceHook(hook) {
|
2196 | return (component, type, time) => {
|
2197 | emit$1(hook, component.appContext.app, component.uid, component, type, time);
|
2198 | };
|
2199 | }
|
2200 | function devtoolsComponentEmit(component, event, params) {
|
2201 | emit$1(
|
2202 | "component:emit" ,
|
2203 | component.appContext.app,
|
2204 | component,
|
2205 | event,
|
2206 | params
|
2207 | );
|
2208 | }
|
2209 |
|
2210 | function emit(instance, event, ...rawArgs) {
|
2211 | if (instance.isUnmounted)
|
2212 | return;
|
2213 | const props = instance.vnode.props || EMPTY_OBJ;
|
2214 | {
|
2215 | const {
|
2216 | emitsOptions,
|
2217 | propsOptions: [propsOptions]
|
2218 | } = instance;
|
2219 | if (emitsOptions) {
|
2220 | if (!(event in emitsOptions) && true) {
|
2221 | if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
|
2222 | warn$1(
|
2223 | `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`
|
2224 | );
|
2225 | }
|
2226 | } else {
|
2227 | const validator = emitsOptions[event];
|
2228 | if (isFunction(validator)) {
|
2229 | const isValid = validator(...rawArgs);
|
2230 | if (!isValid) {
|
2231 | warn$1(
|
2232 | `Invalid event arguments: event validation failed for event "${event}".`
|
2233 | );
|
2234 | }
|
2235 | }
|
2236 | }
|
2237 | }
|
2238 | }
|
2239 | let args = rawArgs;
|
2240 | const isModelListener = event.startsWith("update:");
|
2241 | const modelArg = isModelListener && event.slice(7);
|
2242 | if (modelArg && modelArg in props) {
|
2243 | const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;
|
2244 | const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
|
2245 | if (trim) {
|
2246 | args = rawArgs.map((a) => isString(a) ? a.trim() : a);
|
2247 | }
|
2248 | if (number) {
|
2249 | args = rawArgs.map(looseToNumber);
|
2250 | }
|
2251 | }
|
2252 | {
|
2253 | devtoolsComponentEmit(instance, event, args);
|
2254 | }
|
2255 | {
|
2256 | const lowerCaseEvent = event.toLowerCase();
|
2257 | if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
|
2258 | warn$1(
|
2259 | `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
|
2260 | instance,
|
2261 | instance.type
|
2262 | )} 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(
|
2263 | event
|
2264 | )}" instead of "${event}".`
|
2265 | );
|
2266 | }
|
2267 | }
|
2268 | let handlerName;
|
2269 | let handler = props[handlerName = toHandlerKey(event)] ||
|
2270 | props[handlerName = toHandlerKey(camelize(event))];
|
2271 | if (!handler && isModelListener) {
|
2272 | handler = props[handlerName = toHandlerKey(hyphenate(event))];
|
2273 | }
|
2274 | if (handler) {
|
2275 | callWithAsyncErrorHandling(
|
2276 | handler,
|
2277 | instance,
|
2278 | 6,
|
2279 | args
|
2280 | );
|
2281 | }
|
2282 | const onceHandler = props[handlerName + `Once`];
|
2283 | if (onceHandler) {
|
2284 | if (!instance.emitted) {
|
2285 | instance.emitted = {};
|
2286 | } else if (instance.emitted[handlerName]) {
|
2287 | return;
|
2288 | }
|
2289 | instance.emitted[handlerName] = true;
|
2290 | callWithAsyncErrorHandling(
|
2291 | onceHandler,
|
2292 | instance,
|
2293 | 6,
|
2294 | args
|
2295 | );
|
2296 | }
|
2297 | }
|
2298 | function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
2299 | const cache = appContext.emitsCache;
|
2300 | const cached = cache.get(comp);
|
2301 | if (cached !== void 0) {
|
2302 | return cached;
|
2303 | }
|
2304 | const raw = comp.emits;
|
2305 | let normalized = {};
|
2306 | let hasExtends = false;
|
2307 | if (!isFunction(comp)) {
|
2308 | const extendEmits = (raw2) => {
|
2309 | const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
|
2310 | if (normalizedFromExtend) {
|
2311 | hasExtends = true;
|
2312 | extend(normalized, normalizedFromExtend);
|
2313 | }
|
2314 | };
|
2315 | if (!asMixin && appContext.mixins.length) {
|
2316 | appContext.mixins.forEach(extendEmits);
|
2317 | }
|
2318 | if (comp.extends) {
|
2319 | extendEmits(comp.extends);
|
2320 | }
|
2321 | if (comp.mixins) {
|
2322 | comp.mixins.forEach(extendEmits);
|
2323 | }
|
2324 | }
|
2325 | if (!raw && !hasExtends) {
|
2326 | if (isObject(comp)) {
|
2327 | cache.set(comp, null);
|
2328 | }
|
2329 | return null;
|
2330 | }
|
2331 | if (isArray(raw)) {
|
2332 | raw.forEach((key) => normalized[key] = null);
|
2333 | } else {
|
2334 | extend(normalized, raw);
|
2335 | }
|
2336 | if (isObject(comp)) {
|
2337 | cache.set(comp, normalized);
|
2338 | }
|
2339 | return normalized;
|
2340 | }
|
2341 | function isEmitListener(options, key) {
|
2342 | if (!options || !isOn(key)) {
|
2343 | return false;
|
2344 | }
|
2345 | key = key.slice(2).replace(/Once$/, "");
|
2346 | return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
|
2347 | }
|
2348 |
|
2349 | let currentRenderingInstance = null;
|
2350 | let currentScopeId = null;
|
2351 | function setCurrentRenderingInstance(instance) {
|
2352 | const prev = currentRenderingInstance;
|
2353 | currentRenderingInstance = instance;
|
2354 | currentScopeId = instance && instance.type.__scopeId || null;
|
2355 | return prev;
|
2356 | }
|
2357 | function pushScopeId(id) {
|
2358 | currentScopeId = id;
|
2359 | }
|
2360 | function popScopeId() {
|
2361 | currentScopeId = null;
|
2362 | }
|
2363 | const withScopeId = (_id) => withCtx;
|
2364 | function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
|
2365 | if (!ctx)
|
2366 | return fn;
|
2367 | if (fn._n) {
|
2368 | return fn;
|
2369 | }
|
2370 | const renderFnWithContext = (...args) => {
|
2371 | if (renderFnWithContext._d) {
|
2372 | setBlockTracking(-1);
|
2373 | }
|
2374 | const prevInstance = setCurrentRenderingInstance(ctx);
|
2375 | let res;
|
2376 | try {
|
2377 | res = fn(...args);
|
2378 | } finally {
|
2379 | setCurrentRenderingInstance(prevInstance);
|
2380 | if (renderFnWithContext._d) {
|
2381 | setBlockTracking(1);
|
2382 | }
|
2383 | }
|
2384 | {
|
2385 | devtoolsComponentUpdated(ctx);
|
2386 | }
|
2387 | return res;
|
2388 | };
|
2389 | renderFnWithContext._n = true;
|
2390 | renderFnWithContext._c = true;
|
2391 | renderFnWithContext._d = true;
|
2392 | return renderFnWithContext;
|
2393 | }
|
2394 |
|
2395 | let accessedAttrs = false;
|
2396 | function markAttrsAccessed() {
|
2397 | accessedAttrs = true;
|
2398 | }
|
2399 | function renderComponentRoot(instance) {
|
2400 | const {
|
2401 | type: Component,
|
2402 | vnode,
|
2403 | proxy,
|
2404 | withProxy,
|
2405 | props,
|
2406 | propsOptions: [propsOptions],
|
2407 | slots,
|
2408 | attrs,
|
2409 | emit,
|
2410 | render,
|
2411 | renderCache,
|
2412 | data,
|
2413 | setupState,
|
2414 | ctx,
|
2415 | inheritAttrs
|
2416 | } = instance;
|
2417 | let result;
|
2418 | let fallthroughAttrs;
|
2419 | const prev = setCurrentRenderingInstance(instance);
|
2420 | {
|
2421 | accessedAttrs = false;
|
2422 | }
|
2423 | try {
|
2424 | if (vnode.shapeFlag & 4) {
|
2425 | const proxyToUse = withProxy || proxy;
|
2426 | const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
|
2427 | get(target, key, receiver) {
|
2428 | warn$1(
|
2429 | `Property '${String(
|
2430 | key
|
2431 | )}' was accessed via 'this'. Avoid using 'this' in templates.`
|
2432 | );
|
2433 | return Reflect.get(target, key, receiver);
|
2434 | }
|
2435 | }) : proxyToUse;
|
2436 | result = normalizeVNode(
|
2437 | render.call(
|
2438 | thisProxy,
|
2439 | proxyToUse,
|
2440 | renderCache,
|
2441 | props,
|
2442 | setupState,
|
2443 | data,
|
2444 | ctx
|
2445 | )
|
2446 | );
|
2447 | fallthroughAttrs = attrs;
|
2448 | } else {
|
2449 | const render2 = Component;
|
2450 | if (attrs === props) {
|
2451 | markAttrsAccessed();
|
2452 | }
|
2453 | result = normalizeVNode(
|
2454 | render2.length > 1 ? render2(
|
2455 | props,
|
2456 | true ? {
|
2457 | get attrs() {
|
2458 | markAttrsAccessed();
|
2459 | return attrs;
|
2460 | },
|
2461 | slots,
|
2462 | emit
|
2463 | } : { attrs, slots, emit }
|
2464 | ) : render2(
|
2465 | props,
|
2466 | null
|
2467 |
|
2468 | )
|
2469 | );
|
2470 | fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
|
2471 | }
|
2472 | } catch (err) {
|
2473 | blockStack.length = 0;
|
2474 | handleError(err, instance, 1);
|
2475 | result = createVNode(Comment);
|
2476 | }
|
2477 | let root = result;
|
2478 | let setRoot = void 0;
|
2479 | if (result.patchFlag > 0 && result.patchFlag & 2048) {
|
2480 | [root, setRoot] = getChildRoot(result);
|
2481 | }
|
2482 | if (fallthroughAttrs && inheritAttrs !== false) {
|
2483 | const keys = Object.keys(fallthroughAttrs);
|
2484 | const { shapeFlag } = root;
|
2485 | if (keys.length) {
|
2486 | if (shapeFlag & (1 | 6)) {
|
2487 | if (propsOptions && keys.some(isModelListener)) {
|
2488 | fallthroughAttrs = filterModelListeners(
|
2489 | fallthroughAttrs,
|
2490 | propsOptions
|
2491 | );
|
2492 | }
|
2493 | root = cloneVNode(root, fallthroughAttrs);
|
2494 | } else if (!accessedAttrs && root.type !== Comment) {
|
2495 | const allAttrs = Object.keys(attrs);
|
2496 | const eventAttrs = [];
|
2497 | const extraAttrs = [];
|
2498 | for (let i = 0, l = allAttrs.length; i < l; i++) {
|
2499 | const key = allAttrs[i];
|
2500 | if (isOn(key)) {
|
2501 | if (!isModelListener(key)) {
|
2502 | eventAttrs.push(key[2].toLowerCase() + key.slice(3));
|
2503 | }
|
2504 | } else {
|
2505 | extraAttrs.push(key);
|
2506 | }
|
2507 | }
|
2508 | if (extraAttrs.length) {
|
2509 | warn$1(
|
2510 | `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`
|
2511 | );
|
2512 | }
|
2513 | if (eventAttrs.length) {
|
2514 | warn$1(
|
2515 | `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.`
|
2516 | );
|
2517 | }
|
2518 | }
|
2519 | }
|
2520 | }
|
2521 | if (vnode.dirs) {
|
2522 | if (!isElementRoot(root)) {
|
2523 | warn$1(
|
2524 | `Runtime directive used on component with non-element root node. The directives will not function as intended.`
|
2525 | );
|
2526 | }
|
2527 | root = cloneVNode(root);
|
2528 | root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
|
2529 | }
|
2530 | if (vnode.transition) {
|
2531 | if (!isElementRoot(root)) {
|
2532 | warn$1(
|
2533 | `Component inside <Transition> renders non-element root node that cannot be animated.`
|
2534 | );
|
2535 | }
|
2536 | root.transition = vnode.transition;
|
2537 | }
|
2538 | if (setRoot) {
|
2539 | setRoot(root);
|
2540 | } else {
|
2541 | result = root;
|
2542 | }
|
2543 | setCurrentRenderingInstance(prev);
|
2544 | return result;
|
2545 | }
|
2546 | const getChildRoot = (vnode) => {
|
2547 | const rawChildren = vnode.children;
|
2548 | const dynamicChildren = vnode.dynamicChildren;
|
2549 | const childRoot = filterSingleRoot(rawChildren, false);
|
2550 | if (!childRoot) {
|
2551 | return [vnode, void 0];
|
2552 | } else if (childRoot.patchFlag > 0 && childRoot.patchFlag & 2048) {
|
2553 | return getChildRoot(childRoot);
|
2554 | }
|
2555 | const index = rawChildren.indexOf(childRoot);
|
2556 | const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
|
2557 | const setRoot = (updatedRoot) => {
|
2558 | rawChildren[index] = updatedRoot;
|
2559 | if (dynamicChildren) {
|
2560 | if (dynamicIndex > -1) {
|
2561 | dynamicChildren[dynamicIndex] = updatedRoot;
|
2562 | } else if (updatedRoot.patchFlag > 0) {
|
2563 | vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
|
2564 | }
|
2565 | }
|
2566 | };
|
2567 | return [normalizeVNode(childRoot), setRoot];
|
2568 | };
|
2569 | function filterSingleRoot(children, recurse = true) {
|
2570 | let singleRoot;
|
2571 | for (let i = 0; i < children.length; i++) {
|
2572 | const child = children[i];
|
2573 | if (isVNode(child)) {
|
2574 | if (child.type !== Comment || child.children === "v-if") {
|
2575 | if (singleRoot) {
|
2576 | return;
|
2577 | } else {
|
2578 | singleRoot = child;
|
2579 | if (recurse && singleRoot.patchFlag > 0 && singleRoot.patchFlag & 2048) {
|
2580 | return filterSingleRoot(singleRoot.children);
|
2581 | }
|
2582 | }
|
2583 | }
|
2584 | } else {
|
2585 | return;
|
2586 | }
|
2587 | }
|
2588 | return singleRoot;
|
2589 | }
|
2590 | const getFunctionalFallthrough = (attrs) => {
|
2591 | let res;
|
2592 | for (const key in attrs) {
|
2593 | if (key === "class" || key === "style" || isOn(key)) {
|
2594 | (res || (res = {}))[key] = attrs[key];
|
2595 | }
|
2596 | }
|
2597 | return res;
|
2598 | };
|
2599 | const filterModelListeners = (attrs, props) => {
|
2600 | const res = {};
|
2601 | for (const key in attrs) {
|
2602 | if (!isModelListener(key) || !(key.slice(9) in props)) {
|
2603 | res[key] = attrs[key];
|
2604 | }
|
2605 | }
|
2606 | return res;
|
2607 | };
|
2608 | const isElementRoot = (vnode) => {
|
2609 | return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
|
2610 | };
|
2611 | function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
|
2612 | const { props: prevProps, children: prevChildren, component } = prevVNode;
|
2613 | const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
|
2614 | const emits = component.emitsOptions;
|
2615 | if ((prevChildren || nextChildren) && isHmrUpdating) {
|
2616 | return true;
|
2617 | }
|
2618 | if (nextVNode.dirs || nextVNode.transition) {
|
2619 | return true;
|
2620 | }
|
2621 | if (optimized && patchFlag >= 0) {
|
2622 | if (patchFlag & 1024) {
|
2623 | return true;
|
2624 | }
|
2625 | if (patchFlag & 16) {
|
2626 | if (!prevProps) {
|
2627 | return !!nextProps;
|
2628 | }
|
2629 | return hasPropsChanged(prevProps, nextProps, emits);
|
2630 | } else if (patchFlag & 8) {
|
2631 | const dynamicProps = nextVNode.dynamicProps;
|
2632 | for (let i = 0; i < dynamicProps.length; i++) {
|
2633 | const key = dynamicProps[i];
|
2634 | if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
|
2635 | return true;
|
2636 | }
|
2637 | }
|
2638 | }
|
2639 | } else {
|
2640 | if (prevChildren || nextChildren) {
|
2641 | if (!nextChildren || !nextChildren.$stable) {
|
2642 | return true;
|
2643 | }
|
2644 | }
|
2645 | if (prevProps === nextProps) {
|
2646 | return false;
|
2647 | }
|
2648 | if (!prevProps) {
|
2649 | return !!nextProps;
|
2650 | }
|
2651 | if (!nextProps) {
|
2652 | return true;
|
2653 | }
|
2654 | return hasPropsChanged(prevProps, nextProps, emits);
|
2655 | }
|
2656 | return false;
|
2657 | }
|
2658 | function hasPropsChanged(prevProps, nextProps, emitsOptions) {
|
2659 | const nextKeys = Object.keys(nextProps);
|
2660 | if (nextKeys.length !== Object.keys(prevProps).length) {
|
2661 | return true;
|
2662 | }
|
2663 | for (let i = 0; i < nextKeys.length; i++) {
|
2664 | const key = nextKeys[i];
|
2665 | if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
|
2666 | return true;
|
2667 | }
|
2668 | }
|
2669 | return false;
|
2670 | }
|
2671 | function updateHOCHostEl({ vnode, parent }, el) {
|
2672 | while (parent) {
|
2673 | const root = parent.subTree;
|
2674 | if (root.suspense && root.suspense.activeBranch === vnode) {
|
2675 | root.el = vnode.el;
|
2676 | }
|
2677 | if (root === vnode) {
|
2678 | (vnode = parent.vnode).el = el;
|
2679 | parent = parent.parent;
|
2680 | } else {
|
2681 | break;
|
2682 | }
|
2683 | }
|
2684 | }
|
2685 |
|
2686 | const COMPONENTS = "components";
|
2687 | const DIRECTIVES = "directives";
|
2688 | function resolveComponent(name, maybeSelfReference) {
|
2689 | return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
2690 | }
|
2691 | const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
|
2692 | function resolveDynamicComponent(component) {
|
2693 | if (isString(component)) {
|
2694 | return resolveAsset(COMPONENTS, component, false) || component;
|
2695 | } else {
|
2696 | return component || NULL_DYNAMIC_COMPONENT;
|
2697 | }
|
2698 | }
|
2699 | function resolveDirective(name) {
|
2700 | return resolveAsset(DIRECTIVES, name);
|
2701 | }
|
2702 | function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
2703 | const instance = currentRenderingInstance || currentInstance;
|
2704 | if (instance) {
|
2705 | const Component = instance.type;
|
2706 | if (type === COMPONENTS) {
|
2707 | const selfName = getComponentName(
|
2708 | Component,
|
2709 | false
|
2710 | );
|
2711 | if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
|
2712 | return Component;
|
2713 | }
|
2714 | }
|
2715 | const res = (
|
2716 |
|
2717 |
|
2718 | resolve(instance[type] || Component[type], name) ||
|
2719 | resolve(instance.appContext[type], name)
|
2720 | );
|
2721 | if (!res && maybeSelfReference) {
|
2722 | return Component;
|
2723 | }
|
2724 | if (warnMissing && !res) {
|
2725 | const extra = type === COMPONENTS ? `
|
2726 | If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
|
2727 | warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
|
2728 | }
|
2729 | return res;
|
2730 | } else {
|
2731 | warn$1(
|
2732 | `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
|
2733 | );
|
2734 | }
|
2735 | }
|
2736 | function resolve(registry, name) {
|
2737 | return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
|
2738 | }
|
2739 |
|
2740 | const isSuspense = (type) => type.__isSuspense;
|
2741 | let suspenseId = 0;
|
2742 | const SuspenseImpl = {
|
2743 | name: "Suspense",
|
2744 |
|
2745 |
|
2746 |
|
2747 |
|
2748 | __isSuspense: true,
|
2749 | process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
|
2750 | if (n1 == null) {
|
2751 | mountSuspense(
|
2752 | n2,
|
2753 | container,
|
2754 | anchor,
|
2755 | parentComponent,
|
2756 | parentSuspense,
|
2757 | namespace,
|
2758 | slotScopeIds,
|
2759 | optimized,
|
2760 | rendererInternals
|
2761 | );
|
2762 | } else {
|
2763 | if (parentSuspense && parentSuspense.deps > 0) {
|
2764 | n2.suspense = n1.suspense;
|
2765 | return;
|
2766 | }
|
2767 | patchSuspense(
|
2768 | n1,
|
2769 | n2,
|
2770 | container,
|
2771 | anchor,
|
2772 | parentComponent,
|
2773 | namespace,
|
2774 | slotScopeIds,
|
2775 | optimized,
|
2776 | rendererInternals
|
2777 | );
|
2778 | }
|
2779 | },
|
2780 | hydrate: hydrateSuspense,
|
2781 | create: createSuspenseBoundary,
|
2782 | normalize: normalizeSuspenseChildren
|
2783 | };
|
2784 | const Suspense = SuspenseImpl ;
|
2785 | function triggerEvent(vnode, name) {
|
2786 | const eventListener = vnode.props && vnode.props[name];
|
2787 | if (isFunction(eventListener)) {
|
2788 | eventListener();
|
2789 | }
|
2790 | }
|
2791 | function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
|
2792 | const {
|
2793 | p: patch,
|
2794 | o: { createElement }
|
2795 | } = rendererInternals;
|
2796 | const hiddenContainer = createElement("div");
|
2797 | const suspense = vnode.suspense = createSuspenseBoundary(
|
2798 | vnode,
|
2799 | parentSuspense,
|
2800 | parentComponent,
|
2801 | container,
|
2802 | hiddenContainer,
|
2803 | anchor,
|
2804 | namespace,
|
2805 | slotScopeIds,
|
2806 | optimized,
|
2807 | rendererInternals
|
2808 | );
|
2809 | patch(
|
2810 | null,
|
2811 | suspense.pendingBranch = vnode.ssContent,
|
2812 | hiddenContainer,
|
2813 | null,
|
2814 | parentComponent,
|
2815 | suspense,
|
2816 | namespace,
|
2817 | slotScopeIds
|
2818 | );
|
2819 | if (suspense.deps > 0) {
|
2820 | triggerEvent(vnode, "onPending");
|
2821 | triggerEvent(vnode, "onFallback");
|
2822 | patch(
|
2823 | null,
|
2824 | vnode.ssFallback,
|
2825 | container,
|
2826 | anchor,
|
2827 | parentComponent,
|
2828 | null,
|
2829 |
|
2830 | namespace,
|
2831 | slotScopeIds
|
2832 | );
|
2833 | setActiveBranch(suspense, vnode.ssFallback);
|
2834 | } else {
|
2835 | suspense.resolve(false, true);
|
2836 | }
|
2837 | }
|
2838 | function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
|
2839 | const suspense = n2.suspense = n1.suspense;
|
2840 | suspense.vnode = n2;
|
2841 | n2.el = n1.el;
|
2842 | const newBranch = n2.ssContent;
|
2843 | const newFallback = n2.ssFallback;
|
2844 | const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
|
2845 | if (pendingBranch) {
|
2846 | suspense.pendingBranch = newBranch;
|
2847 | if (isSameVNodeType(newBranch, pendingBranch)) {
|
2848 | patch(
|
2849 | pendingBranch,
|
2850 | newBranch,
|
2851 | suspense.hiddenContainer,
|
2852 | null,
|
2853 | parentComponent,
|
2854 | suspense,
|
2855 | namespace,
|
2856 | slotScopeIds,
|
2857 | optimized
|
2858 | );
|
2859 | if (suspense.deps <= 0) {
|
2860 | suspense.resolve();
|
2861 | } else if (isInFallback) {
|
2862 | if (!isHydrating) {
|
2863 | patch(
|
2864 | activeBranch,
|
2865 | newFallback,
|
2866 | container,
|
2867 | anchor,
|
2868 | parentComponent,
|
2869 | null,
|
2870 |
|
2871 | namespace,
|
2872 | slotScopeIds,
|
2873 | optimized
|
2874 | );
|
2875 | setActiveBranch(suspense, newFallback);
|
2876 | }
|
2877 | }
|
2878 | } else {
|
2879 | suspense.pendingId = suspenseId++;
|
2880 | if (isHydrating) {
|
2881 | suspense.isHydrating = false;
|
2882 | suspense.activeBranch = pendingBranch;
|
2883 | } else {
|
2884 | unmount(pendingBranch, parentComponent, suspense);
|
2885 | }
|
2886 | suspense.deps = 0;
|
2887 | suspense.effects.length = 0;
|
2888 | suspense.hiddenContainer = createElement("div");
|
2889 | if (isInFallback) {
|
2890 | patch(
|
2891 | null,
|
2892 | newBranch,
|
2893 | suspense.hiddenContainer,
|
2894 | null,
|
2895 | parentComponent,
|
2896 | suspense,
|
2897 | namespace,
|
2898 | slotScopeIds,
|
2899 | optimized
|
2900 | );
|
2901 | if (suspense.deps <= 0) {
|
2902 | suspense.resolve();
|
2903 | } else {
|
2904 | patch(
|
2905 | activeBranch,
|
2906 | newFallback,
|
2907 | container,
|
2908 | anchor,
|
2909 | parentComponent,
|
2910 | null,
|
2911 |
|
2912 | namespace,
|
2913 | slotScopeIds,
|
2914 | optimized
|
2915 | );
|
2916 | setActiveBranch(suspense, newFallback);
|
2917 | }
|
2918 | } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2919 | patch(
|
2920 | activeBranch,
|
2921 | newBranch,
|
2922 | container,
|
2923 | anchor,
|
2924 | parentComponent,
|
2925 | suspense,
|
2926 | namespace,
|
2927 | slotScopeIds,
|
2928 | optimized
|
2929 | );
|
2930 | suspense.resolve(true);
|
2931 | } else {
|
2932 | patch(
|
2933 | null,
|
2934 | newBranch,
|
2935 | suspense.hiddenContainer,
|
2936 | null,
|
2937 | parentComponent,
|
2938 | suspense,
|
2939 | namespace,
|
2940 | slotScopeIds,
|
2941 | optimized
|
2942 | );
|
2943 | if (suspense.deps <= 0) {
|
2944 | suspense.resolve();
|
2945 | }
|
2946 | }
|
2947 | }
|
2948 | } else {
|
2949 | if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2950 | patch(
|
2951 | activeBranch,
|
2952 | newBranch,
|
2953 | container,
|
2954 | anchor,
|
2955 | parentComponent,
|
2956 | suspense,
|
2957 | namespace,
|
2958 | slotScopeIds,
|
2959 | optimized
|
2960 | );
|
2961 | setActiveBranch(suspense, newBranch);
|
2962 | } else {
|
2963 | triggerEvent(n2, "onPending");
|
2964 | suspense.pendingBranch = newBranch;
|
2965 | if (newBranch.shapeFlag & 512) {
|
2966 | suspense.pendingId = newBranch.component.suspenseId;
|
2967 | } else {
|
2968 | suspense.pendingId = suspenseId++;
|
2969 | }
|
2970 | patch(
|
2971 | null,
|
2972 | newBranch,
|
2973 | suspense.hiddenContainer,
|
2974 | null,
|
2975 | parentComponent,
|
2976 | suspense,
|
2977 | namespace,
|
2978 | slotScopeIds,
|
2979 | optimized
|
2980 | );
|
2981 | if (suspense.deps <= 0) {
|
2982 | suspense.resolve();
|
2983 | } else {
|
2984 | const { timeout, pendingId } = suspense;
|
2985 | if (timeout > 0) {
|
2986 | setTimeout(() => {
|
2987 | if (suspense.pendingId === pendingId) {
|
2988 | suspense.fallback(newFallback);
|
2989 | }
|
2990 | }, timeout);
|
2991 | } else if (timeout === 0) {
|
2992 | suspense.fallback(newFallback);
|
2993 | }
|
2994 | }
|
2995 | }
|
2996 | }
|
2997 | }
|
2998 | let hasWarned = false;
|
2999 | function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
|
3000 | if (!hasWarned) {
|
3001 | hasWarned = true;
|
3002 | console[console.info ? "info" : "log"](
|
3003 | `<Suspense> is an experimental feature and its API will likely change.`
|
3004 | );
|
3005 | }
|
3006 | const {
|
3007 | p: patch,
|
3008 | m: move,
|
3009 | um: unmount,
|
3010 | n: next,
|
3011 | o: { parentNode, remove }
|
3012 | } = rendererInternals;
|
3013 | let parentSuspenseId;
|
3014 | const isSuspensible = isVNodeSuspensible(vnode);
|
3015 | if (isSuspensible) {
|
3016 | if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
|
3017 | parentSuspenseId = parentSuspense.pendingId;
|
3018 | parentSuspense.deps++;
|
3019 | }
|
3020 | }
|
3021 | const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0;
|
3022 | {
|
3023 | assertNumber(timeout, `Suspense timeout`);
|
3024 | }
|
3025 | const initialAnchor = anchor;
|
3026 | const suspense = {
|
3027 | vnode,
|
3028 | parent: parentSuspense,
|
3029 | parentComponent,
|
3030 | namespace,
|
3031 | container,
|
3032 | hiddenContainer,
|
3033 | deps: 0,
|
3034 | pendingId: suspenseId++,
|
3035 | timeout: typeof timeout === "number" ? timeout : -1,
|
3036 | activeBranch: null,
|
3037 | pendingBranch: null,
|
3038 | isInFallback: !isHydrating,
|
3039 | isHydrating,
|
3040 | isUnmounted: false,
|
3041 | effects: [],
|
3042 | resolve(resume = false, sync = false) {
|
3043 | {
|
3044 | if (!resume && !suspense.pendingBranch) {
|
3045 | throw new Error(
|
3046 | `suspense.resolve() is called without a pending branch.`
|
3047 | );
|
3048 | }
|
3049 | if (suspense.isUnmounted) {
|
3050 | throw new Error(
|
3051 | `suspense.resolve() is called on an already unmounted suspense boundary.`
|
3052 | );
|
3053 | }
|
3054 | }
|
3055 | const {
|
3056 | vnode: vnode2,
|
3057 | activeBranch,
|
3058 | pendingBranch,
|
3059 | pendingId,
|
3060 | effects,
|
3061 | parentComponent: parentComponent2,
|
3062 | container: container2
|
3063 | } = suspense;
|
3064 | let delayEnter = false;
|
3065 | if (suspense.isHydrating) {
|
3066 | suspense.isHydrating = false;
|
3067 | } else if (!resume) {
|
3068 | delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
|
3069 | if (delayEnter) {
|
3070 | activeBranch.transition.afterLeave = () => {
|
3071 | if (pendingId === suspense.pendingId) {
|
3072 | move(
|
3073 | pendingBranch,
|
3074 | container2,
|
3075 | anchor === initialAnchor ? next(activeBranch) : anchor,
|
3076 | 0
|
3077 | );
|
3078 | queuePostFlushCb(effects);
|
3079 | }
|
3080 | };
|
3081 | }
|
3082 | if (activeBranch) {
|
3083 | if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
|
3084 | anchor = next(activeBranch);
|
3085 | }
|
3086 | unmount(activeBranch, parentComponent2, suspense, true);
|
3087 | }
|
3088 | if (!delayEnter) {
|
3089 | move(pendingBranch, container2, anchor, 0);
|
3090 | }
|
3091 | }
|
3092 | setActiveBranch(suspense, pendingBranch);
|
3093 | suspense.pendingBranch = null;
|
3094 | suspense.isInFallback = false;
|
3095 | let parent = suspense.parent;
|
3096 | let hasUnresolvedAncestor = false;
|
3097 | while (parent) {
|
3098 | if (parent.pendingBranch) {
|
3099 | parent.effects.push(...effects);
|
3100 | hasUnresolvedAncestor = true;
|
3101 | break;
|
3102 | }
|
3103 | parent = parent.parent;
|
3104 | }
|
3105 | if (!hasUnresolvedAncestor && !delayEnter) {
|
3106 | queuePostFlushCb(effects);
|
3107 | }
|
3108 | suspense.effects = [];
|
3109 | if (isSuspensible) {
|
3110 | if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
|
3111 | parentSuspense.deps--;
|
3112 | if (parentSuspense.deps === 0 && !sync) {
|
3113 | parentSuspense.resolve();
|
3114 | }
|
3115 | }
|
3116 | }
|
3117 | triggerEvent(vnode2, "onResolve");
|
3118 | },
|
3119 | fallback(fallbackVNode) {
|
3120 | if (!suspense.pendingBranch) {
|
3121 | return;
|
3122 | }
|
3123 | const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense;
|
3124 | triggerEvent(vnode2, "onFallback");
|
3125 | const anchor2 = next(activeBranch);
|
3126 | const mountFallback = () => {
|
3127 | if (!suspense.isInFallback) {
|
3128 | return;
|
3129 | }
|
3130 | patch(
|
3131 | null,
|
3132 | fallbackVNode,
|
3133 | container2,
|
3134 | anchor2,
|
3135 | parentComponent2,
|
3136 | null,
|
3137 |
|
3138 | namespace2,
|
3139 | slotScopeIds,
|
3140 | optimized
|
3141 | );
|
3142 | setActiveBranch(suspense, fallbackVNode);
|
3143 | };
|
3144 | const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
|
3145 | if (delayEnter) {
|
3146 | activeBranch.transition.afterLeave = mountFallback;
|
3147 | }
|
3148 | suspense.isInFallback = true;
|
3149 | unmount(
|
3150 | activeBranch,
|
3151 | parentComponent2,
|
3152 | null,
|
3153 |
|
3154 | true
|
3155 |
|
3156 | );
|
3157 | if (!delayEnter) {
|
3158 | mountFallback();
|
3159 | }
|
3160 | },
|
3161 | move(container2, anchor2, type) {
|
3162 | suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
|
3163 | suspense.container = container2;
|
3164 | },
|
3165 | next() {
|
3166 | return suspense.activeBranch && next(suspense.activeBranch);
|
3167 | },
|
3168 | registerDep(instance, setupRenderEffect) {
|
3169 | const isInPendingSuspense = !!suspense.pendingBranch;
|
3170 | if (isInPendingSuspense) {
|
3171 | suspense.deps++;
|
3172 | }
|
3173 | const hydratedEl = instance.vnode.el;
|
3174 | instance.asyncDep.catch((err) => {
|
3175 | handleError(err, instance, 0);
|
3176 | }).then((asyncSetupResult) => {
|
3177 | if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
|
3178 | return;
|
3179 | }
|
3180 | instance.asyncResolved = true;
|
3181 | const { vnode: vnode2 } = instance;
|
3182 | {
|
3183 | pushWarningContext(vnode2);
|
3184 | }
|
3185 | handleSetupResult(instance, asyncSetupResult, false);
|
3186 | if (hydratedEl) {
|
3187 | vnode2.el = hydratedEl;
|
3188 | }
|
3189 | const placeholder = !hydratedEl && instance.subTree.el;
|
3190 | setupRenderEffect(
|
3191 | instance,
|
3192 | vnode2,
|
3193 |
|
3194 |
|
3195 |
|
3196 | parentNode(hydratedEl || instance.subTree.el),
|
3197 |
|
3198 |
|
3199 | hydratedEl ? null : next(instance.subTree),
|
3200 | suspense,
|
3201 | namespace,
|
3202 | optimized
|
3203 | );
|
3204 | if (placeholder) {
|
3205 | remove(placeholder);
|
3206 | }
|
3207 | updateHOCHostEl(instance, vnode2.el);
|
3208 | {
|
3209 | popWarningContext();
|
3210 | }
|
3211 | if (isInPendingSuspense && --suspense.deps === 0) {
|
3212 | suspense.resolve();
|
3213 | }
|
3214 | });
|
3215 | },
|
3216 | unmount(parentSuspense2, doRemove) {
|
3217 | suspense.isUnmounted = true;
|
3218 | if (suspense.activeBranch) {
|
3219 | unmount(
|
3220 | suspense.activeBranch,
|
3221 | parentComponent,
|
3222 | parentSuspense2,
|
3223 | doRemove
|
3224 | );
|
3225 | }
|
3226 | if (suspense.pendingBranch) {
|
3227 | unmount(
|
3228 | suspense.pendingBranch,
|
3229 | parentComponent,
|
3230 | parentSuspense2,
|
3231 | doRemove
|
3232 | );
|
3233 | }
|
3234 | }
|
3235 | };
|
3236 | return suspense;
|
3237 | }
|
3238 | function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) {
|
3239 | const suspense = vnode.suspense = createSuspenseBoundary(
|
3240 | vnode,
|
3241 | parentSuspense,
|
3242 | parentComponent,
|
3243 | node.parentNode,
|
3244 |
|
3245 | document.createElement("div"),
|
3246 | null,
|
3247 | namespace,
|
3248 | slotScopeIds,
|
3249 | optimized,
|
3250 | rendererInternals,
|
3251 | true
|
3252 | );
|
3253 | const result = hydrateNode(
|
3254 | node,
|
3255 | suspense.pendingBranch = vnode.ssContent,
|
3256 | parentComponent,
|
3257 | suspense,
|
3258 | slotScopeIds,
|
3259 | optimized
|
3260 | );
|
3261 | if (suspense.deps === 0) {
|
3262 | suspense.resolve(false, true);
|
3263 | }
|
3264 | return result;
|
3265 | }
|
3266 | function normalizeSuspenseChildren(vnode) {
|
3267 | const { shapeFlag, children } = vnode;
|
3268 | const isSlotChildren = shapeFlag & 32;
|
3269 | vnode.ssContent = normalizeSuspenseSlot(
|
3270 | isSlotChildren ? children.default : children
|
3271 | );
|
3272 | vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
|
3273 | }
|
3274 | function normalizeSuspenseSlot(s) {
|
3275 | let block;
|
3276 | if (isFunction(s)) {
|
3277 | const trackBlock = isBlockTreeEnabled && s._c;
|
3278 | if (trackBlock) {
|
3279 | s._d = false;
|
3280 | openBlock();
|
3281 | }
|
3282 | s = s();
|
3283 | if (trackBlock) {
|
3284 | s._d = true;
|
3285 | block = currentBlock;
|
3286 | closeBlock();
|
3287 | }
|
3288 | }
|
3289 | if (isArray(s)) {
|
3290 | const singleChild = filterSingleRoot(s);
|
3291 | if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
|
3292 | warn$1(`<Suspense> slots expect a single root node.`);
|
3293 | }
|
3294 | s = singleChild;
|
3295 | }
|
3296 | s = normalizeVNode(s);
|
3297 | if (block && !s.dynamicChildren) {
|
3298 | s.dynamicChildren = block.filter((c) => c !== s);
|
3299 | }
|
3300 | return s;
|
3301 | }
|
3302 | function queueEffectWithSuspense(fn, suspense) {
|
3303 | if (suspense && suspense.pendingBranch) {
|
3304 | if (isArray(fn)) {
|
3305 | suspense.effects.push(...fn);
|
3306 | } else {
|
3307 | suspense.effects.push(fn);
|
3308 | }
|
3309 | } else {
|
3310 | queuePostFlushCb(fn);
|
3311 | }
|
3312 | }
|
3313 | function setActiveBranch(suspense, branch) {
|
3314 | suspense.activeBranch = branch;
|
3315 | const { vnode, parentComponent } = suspense;
|
3316 | let el = branch.el;
|
3317 | while (!el && branch.component) {
|
3318 | branch = branch.component.subTree;
|
3319 | el = branch.el;
|
3320 | }
|
3321 | vnode.el = el;
|
3322 | if (parentComponent && parentComponent.subTree === vnode) {
|
3323 | parentComponent.vnode.el = el;
|
3324 | updateHOCHostEl(parentComponent, el);
|
3325 | }
|
3326 | }
|
3327 | function isVNodeSuspensible(vnode) {
|
3328 | var _a;
|
3329 | return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
|
3330 | }
|
3331 |
|
3332 | const ssrContextKey = Symbol.for("v-scx");
|
3333 | const useSSRContext = () => {
|
3334 | {
|
3335 | const ctx = inject(ssrContextKey);
|
3336 | if (!ctx) {
|
3337 | warn$1(
|
3338 | `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
|
3339 | );
|
3340 | }
|
3341 | return ctx;
|
3342 | }
|
3343 | };
|
3344 |
|
3345 | function watchEffect(effect, options) {
|
3346 | return doWatch(effect, null, options);
|
3347 | }
|
3348 | function watchPostEffect(effect, options) {
|
3349 | return doWatch(
|
3350 | effect,
|
3351 | null,
|
3352 | extend({}, options, { flush: "post" })
|
3353 | );
|
3354 | }
|
3355 | function watchSyncEffect(effect, options) {
|
3356 | return doWatch(
|
3357 | effect,
|
3358 | null,
|
3359 | extend({}, options, { flush: "sync" })
|
3360 | );
|
3361 | }
|
3362 | const INITIAL_WATCHER_VALUE = {};
|
3363 | function watch(source, cb, options) {
|
3364 | if (!isFunction(cb)) {
|
3365 | warn$1(
|
3366 | `\`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.`
|
3367 | );
|
3368 | }
|
3369 | return doWatch(source, cb, options);
|
3370 | }
|
3371 | function doWatch(source, cb, {
|
3372 | immediate,
|
3373 | deep,
|
3374 | flush,
|
3375 | once,
|
3376 | onTrack,
|
3377 | onTrigger
|
3378 | } = EMPTY_OBJ) {
|
3379 | if (cb && once) {
|
3380 | const _cb = cb;
|
3381 | cb = (...args) => {
|
3382 | _cb(...args);
|
3383 | unwatch();
|
3384 | };
|
3385 | }
|
3386 | if (deep !== void 0 && typeof deep === "number") {
|
3387 | warn$1(
|
3388 | `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`
|
3389 | );
|
3390 | }
|
3391 | if (!cb) {
|
3392 | if (immediate !== void 0) {
|
3393 | warn$1(
|
3394 | `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
|
3395 | );
|
3396 | }
|
3397 | if (deep !== void 0) {
|
3398 | warn$1(
|
3399 | `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
|
3400 | );
|
3401 | }
|
3402 | if (once !== void 0) {
|
3403 | warn$1(
|
3404 | `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
|
3405 | );
|
3406 | }
|
3407 | }
|
3408 | const warnInvalidSource = (s) => {
|
3409 | warn$1(
|
3410 | `Invalid watch source: `,
|
3411 | s,
|
3412 | `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
|
3413 | );
|
3414 | };
|
3415 | const instance = currentInstance;
|
3416 | const reactiveGetter = (source2) => deep === true ? source2 : (
|
3417 |
|
3418 | traverse(source2, deep === false ? 1 : void 0)
|
3419 | );
|
3420 | let getter;
|
3421 | let forceTrigger = false;
|
3422 | let isMultiSource = false;
|
3423 | if (isRef(source)) {
|
3424 | getter = () => source.value;
|
3425 | forceTrigger = isShallow(source);
|
3426 | } else if (isReactive(source)) {
|
3427 | getter = () => reactiveGetter(source);
|
3428 | forceTrigger = true;
|
3429 | } else if (isArray(source)) {
|
3430 | isMultiSource = true;
|
3431 | forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
3432 | getter = () => source.map((s) => {
|
3433 | if (isRef(s)) {
|
3434 | return s.value;
|
3435 | } else if (isReactive(s)) {
|
3436 | return reactiveGetter(s);
|
3437 | } else if (isFunction(s)) {
|
3438 | return callWithErrorHandling(s, instance, 2);
|
3439 | } else {
|
3440 | warnInvalidSource(s);
|
3441 | }
|
3442 | });
|
3443 | } else if (isFunction(source)) {
|
3444 | if (cb) {
|
3445 | getter = () => callWithErrorHandling(source, instance, 2);
|
3446 | } else {
|
3447 | getter = () => {
|
3448 | if (cleanup) {
|
3449 | cleanup();
|
3450 | }
|
3451 | return callWithAsyncErrorHandling(
|
3452 | source,
|
3453 | instance,
|
3454 | 3,
|
3455 | [onCleanup]
|
3456 | );
|
3457 | };
|
3458 | }
|
3459 | } else {
|
3460 | getter = NOOP;
|
3461 | warnInvalidSource(source);
|
3462 | }
|
3463 | if (cb && deep) {
|
3464 | const baseGetter = getter;
|
3465 | getter = () => traverse(baseGetter());
|
3466 | }
|
3467 | let cleanup;
|
3468 | let onCleanup = (fn) => {
|
3469 | cleanup = effect.onStop = () => {
|
3470 | callWithErrorHandling(fn, instance, 4);
|
3471 | cleanup = effect.onStop = void 0;
|
3472 | };
|
3473 | };
|
3474 | let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
3475 | const job = () => {
|
3476 | if (!effect.active || !effect.dirty) {
|
3477 | return;
|
3478 | }
|
3479 | if (cb) {
|
3480 | const newValue = effect.run();
|
3481 | if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
|
3482 | if (cleanup) {
|
3483 | cleanup();
|
3484 | }
|
3485 | callWithAsyncErrorHandling(cb, instance, 3, [
|
3486 | newValue,
|
3487 |
|
3488 | oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
3489 | onCleanup
|
3490 | ]);
|
3491 | oldValue = newValue;
|
3492 | }
|
3493 | } else {
|
3494 | effect.run();
|
3495 | }
|
3496 | };
|
3497 | job.allowRecurse = !!cb;
|
3498 | let scheduler;
|
3499 | if (flush === "sync") {
|
3500 | scheduler = job;
|
3501 | } else if (flush === "post") {
|
3502 | scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
3503 | } else {
|
3504 | job.pre = true;
|
3505 | if (instance)
|
3506 | job.id = instance.uid;
|
3507 | scheduler = () => queueJob(job);
|
3508 | }
|
3509 | const effect = new ReactiveEffect(getter, NOOP, scheduler);
|
3510 | const scope = getCurrentScope();
|
3511 | const unwatch = () => {
|
3512 | effect.stop();
|
3513 | if (scope) {
|
3514 | remove(scope.effects, effect);
|
3515 | }
|
3516 | };
|
3517 | {
|
3518 | effect.onTrack = onTrack;
|
3519 | effect.onTrigger = onTrigger;
|
3520 | }
|
3521 | if (cb) {
|
3522 | if (immediate) {
|
3523 | job();
|
3524 | } else {
|
3525 | oldValue = effect.run();
|
3526 | }
|
3527 | } else if (flush === "post") {
|
3528 | queuePostRenderEffect(
|
3529 | effect.run.bind(effect),
|
3530 | instance && instance.suspense
|
3531 | );
|
3532 | } else {
|
3533 | effect.run();
|
3534 | }
|
3535 | return unwatch;
|
3536 | }
|
3537 | function instanceWatch(source, value, options) {
|
3538 | const publicThis = this.proxy;
|
3539 | const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
|
3540 | let cb;
|
3541 | if (isFunction(value)) {
|
3542 | cb = value;
|
3543 | } else {
|
3544 | cb = value.handler;
|
3545 | options = value;
|
3546 | }
|
3547 | const reset = setCurrentInstance(this);
|
3548 | const res = doWatch(getter, cb.bind(publicThis), options);
|
3549 | reset();
|
3550 | return res;
|
3551 | }
|
3552 | function createPathGetter(ctx, path) {
|
3553 | const segments = path.split(".");
|
3554 | return () => {
|
3555 | let cur = ctx;
|
3556 | for (let i = 0; i < segments.length && cur; i++) {
|
3557 | cur = cur[segments[i]];
|
3558 | }
|
3559 | return cur;
|
3560 | };
|
3561 | }
|
3562 | function traverse(value, depth, currentDepth = 0, seen) {
|
3563 | if (!isObject(value) || value["__v_skip"]) {
|
3564 | return value;
|
3565 | }
|
3566 | if (depth && depth > 0) {
|
3567 | if (currentDepth >= depth) {
|
3568 | return value;
|
3569 | }
|
3570 | currentDepth++;
|
3571 | }
|
3572 | seen = seen || new Set();
|
3573 | if (seen.has(value)) {
|
3574 | return value;
|
3575 | }
|
3576 | seen.add(value);
|
3577 | if (isRef(value)) {
|
3578 | traverse(value.value, depth, currentDepth, seen);
|
3579 | } else if (isArray(value)) {
|
3580 | for (let i = 0; i < value.length; i++) {
|
3581 | traverse(value[i], depth, currentDepth, seen);
|
3582 | }
|
3583 | } else if (isSet(value) || isMap(value)) {
|
3584 | value.forEach((v) => {
|
3585 | traverse(v, depth, currentDepth, seen);
|
3586 | });
|
3587 | } else if (isPlainObject(value)) {
|
3588 | for (const key in value) {
|
3589 | traverse(value[key], depth, currentDepth, seen);
|
3590 | }
|
3591 | }
|
3592 | return value;
|
3593 | }
|
3594 |
|
3595 | function validateDirectiveName(name) {
|
3596 | if (isBuiltInDirective(name)) {
|
3597 | warn$1("Do not use built-in directive ids as custom directive id: " + name);
|
3598 | }
|
3599 | }
|
3600 | function withDirectives(vnode, directives) {
|
3601 | if (currentRenderingInstance === null) {
|
3602 | warn$1(`withDirectives can only be used inside render functions.`);
|
3603 | return vnode;
|
3604 | }
|
3605 | const instance = getExposeProxy(currentRenderingInstance) || currentRenderingInstance.proxy;
|
3606 | const bindings = vnode.dirs || (vnode.dirs = []);
|
3607 | for (let i = 0; i < directives.length; i++) {
|
3608 | let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
|
3609 | if (dir) {
|
3610 | if (isFunction(dir)) {
|
3611 | dir = {
|
3612 | mounted: dir,
|
3613 | updated: dir
|
3614 | };
|
3615 | }
|
3616 | if (dir.deep) {
|
3617 | traverse(value);
|
3618 | }
|
3619 | bindings.push({
|
3620 | dir,
|
3621 | instance,
|
3622 | value,
|
3623 | oldValue: void 0,
|
3624 | arg,
|
3625 | modifiers
|
3626 | });
|
3627 | }
|
3628 | }
|
3629 | return vnode;
|
3630 | }
|
3631 | function invokeDirectiveHook(vnode, prevVNode, instance, name) {
|
3632 | const bindings = vnode.dirs;
|
3633 | const oldBindings = prevVNode && prevVNode.dirs;
|
3634 | for (let i = 0; i < bindings.length; i++) {
|
3635 | const binding = bindings[i];
|
3636 | if (oldBindings) {
|
3637 | binding.oldValue = oldBindings[i].value;
|
3638 | }
|
3639 | let hook = binding.dir[name];
|
3640 | if (hook) {
|
3641 | pauseTracking();
|
3642 | callWithAsyncErrorHandling(hook, instance, 8, [
|
3643 | vnode.el,
|
3644 | binding,
|
3645 | vnode,
|
3646 | prevVNode
|
3647 | ]);
|
3648 | resetTracking();
|
3649 | }
|
3650 | }
|
3651 | }
|
3652 |
|
3653 | const leaveCbKey = Symbol("_leaveCb");
|
3654 | const enterCbKey$1 = Symbol("_enterCb");
|
3655 | function useTransitionState() {
|
3656 | const state = {
|
3657 | isMounted: false,
|
3658 | isLeaving: false,
|
3659 | isUnmounting: false,
|
3660 | leavingVNodes: new Map()
|
3661 | };
|
3662 | onMounted(() => {
|
3663 | state.isMounted = true;
|
3664 | });
|
3665 | onBeforeUnmount(() => {
|
3666 | state.isUnmounting = true;
|
3667 | });
|
3668 | return state;
|
3669 | }
|
3670 | const TransitionHookValidator = [Function, Array];
|
3671 | const BaseTransitionPropsValidators = {
|
3672 | mode: String,
|
3673 | appear: Boolean,
|
3674 | persisted: Boolean,
|
3675 |
|
3676 | onBeforeEnter: TransitionHookValidator,
|
3677 | onEnter: TransitionHookValidator,
|
3678 | onAfterEnter: TransitionHookValidator,
|
3679 | onEnterCancelled: TransitionHookValidator,
|
3680 |
|
3681 | onBeforeLeave: TransitionHookValidator,
|
3682 | onLeave: TransitionHookValidator,
|
3683 | onAfterLeave: TransitionHookValidator,
|
3684 | onLeaveCancelled: TransitionHookValidator,
|
3685 |
|
3686 | onBeforeAppear: TransitionHookValidator,
|
3687 | onAppear: TransitionHookValidator,
|
3688 | onAfterAppear: TransitionHookValidator,
|
3689 | onAppearCancelled: TransitionHookValidator
|
3690 | };
|
3691 | const BaseTransitionImpl = {
|
3692 | name: `BaseTransition`,
|
3693 | props: BaseTransitionPropsValidators,
|
3694 | setup(props, { slots }) {
|
3695 | const instance = getCurrentInstance();
|
3696 | const state = useTransitionState();
|
3697 | let prevTransitionKey;
|
3698 | return () => {
|
3699 | const children = slots.default && getTransitionRawChildren(slots.default(), true);
|
3700 | if (!children || !children.length) {
|
3701 | return;
|
3702 | }
|
3703 | let child = children[0];
|
3704 | if (children.length > 1) {
|
3705 | let hasFound = false;
|
3706 | for (const c of children) {
|
3707 | if (c.type !== Comment) {
|
3708 | if (hasFound) {
|
3709 | warn$1(
|
3710 | "<transition> can only be used on a single element or component. Use <transition-group> for lists."
|
3711 | );
|
3712 | break;
|
3713 | }
|
3714 | child = c;
|
3715 | hasFound = true;
|
3716 | }
|
3717 | }
|
3718 | }
|
3719 | const rawProps = toRaw(props);
|
3720 | const { mode } = rawProps;
|
3721 | if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
|
3722 | warn$1(`invalid <transition> mode: ${mode}`);
|
3723 | }
|
3724 | if (state.isLeaving) {
|
3725 | return emptyPlaceholder(child);
|
3726 | }
|
3727 | const innerChild = getKeepAliveChild(child);
|
3728 | if (!innerChild) {
|
3729 | return emptyPlaceholder(child);
|
3730 | }
|
3731 | const enterHooks = resolveTransitionHooks(
|
3732 | innerChild,
|
3733 | rawProps,
|
3734 | state,
|
3735 | instance
|
3736 | );
|
3737 | setTransitionHooks(innerChild, enterHooks);
|
3738 | const oldChild = instance.subTree;
|
3739 | const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
|
3740 | let transitionKeyChanged = false;
|
3741 | const { getTransitionKey } = innerChild.type;
|
3742 | if (getTransitionKey) {
|
3743 | const key = getTransitionKey();
|
3744 | if (prevTransitionKey === void 0) {
|
3745 | prevTransitionKey = key;
|
3746 | } else if (key !== prevTransitionKey) {
|
3747 | prevTransitionKey = key;
|
3748 | transitionKeyChanged = true;
|
3749 | }
|
3750 | }
|
3751 | if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
|
3752 | const leavingHooks = resolveTransitionHooks(
|
3753 | oldInnerChild,
|
3754 | rawProps,
|
3755 | state,
|
3756 | instance
|
3757 | );
|
3758 | setTransitionHooks(oldInnerChild, leavingHooks);
|
3759 | if (mode === "out-in") {
|
3760 | state.isLeaving = true;
|
3761 | leavingHooks.afterLeave = () => {
|
3762 | state.isLeaving = false;
|
3763 | if (instance.update.active !== false) {
|
3764 | instance.effect.dirty = true;
|
3765 | instance.update();
|
3766 | }
|
3767 | };
|
3768 | return emptyPlaceholder(child);
|
3769 | } else if (mode === "in-out" && innerChild.type !== Comment) {
|
3770 | leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
|
3771 | const leavingVNodesCache = getLeavingNodesForType(
|
3772 | state,
|
3773 | oldInnerChild
|
3774 | );
|
3775 | leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
|
3776 | el[leaveCbKey] = () => {
|
3777 | earlyRemove();
|
3778 | el[leaveCbKey] = void 0;
|
3779 | delete enterHooks.delayedLeave;
|
3780 | };
|
3781 | enterHooks.delayedLeave = delayedLeave;
|
3782 | };
|
3783 | }
|
3784 | }
|
3785 | return child;
|
3786 | };
|
3787 | }
|
3788 | };
|
3789 | const BaseTransition = BaseTransitionImpl;
|
3790 | function getLeavingNodesForType(state, vnode) {
|
3791 | const { leavingVNodes } = state;
|
3792 | let leavingVNodesCache = leavingVNodes.get(vnode.type);
|
3793 | if (!leavingVNodesCache) {
|
3794 | leavingVNodesCache = Object.create(null);
|
3795 | leavingVNodes.set(vnode.type, leavingVNodesCache);
|
3796 | }
|
3797 | return leavingVNodesCache;
|
3798 | }
|
3799 | function resolveTransitionHooks(vnode, props, state, instance) {
|
3800 | const {
|
3801 | appear,
|
3802 | mode,
|
3803 | persisted = false,
|
3804 | onBeforeEnter,
|
3805 | onEnter,
|
3806 | onAfterEnter,
|
3807 | onEnterCancelled,
|
3808 | onBeforeLeave,
|
3809 | onLeave,
|
3810 | onAfterLeave,
|
3811 | onLeaveCancelled,
|
3812 | onBeforeAppear,
|
3813 | onAppear,
|
3814 | onAfterAppear,
|
3815 | onAppearCancelled
|
3816 | } = props;
|
3817 | const key = String(vnode.key);
|
3818 | const leavingVNodesCache = getLeavingNodesForType(state, vnode);
|
3819 | const callHook = (hook, args) => {
|
3820 | hook && callWithAsyncErrorHandling(
|
3821 | hook,
|
3822 | instance,
|
3823 | 9,
|
3824 | args
|
3825 | );
|
3826 | };
|
3827 | const callAsyncHook = (hook, args) => {
|
3828 | const done = args[1];
|
3829 | callHook(hook, args);
|
3830 | if (isArray(hook)) {
|
3831 | if (hook.every((hook2) => hook2.length <= 1))
|
3832 | done();
|
3833 | } else if (hook.length <= 1) {
|
3834 | done();
|
3835 | }
|
3836 | };
|
3837 | const hooks = {
|
3838 | mode,
|
3839 | persisted,
|
3840 | beforeEnter(el) {
|
3841 | let hook = onBeforeEnter;
|
3842 | if (!state.isMounted) {
|
3843 | if (appear) {
|
3844 | hook = onBeforeAppear || onBeforeEnter;
|
3845 | } else {
|
3846 | return;
|
3847 | }
|
3848 | }
|
3849 | if (el[leaveCbKey]) {
|
3850 | el[leaveCbKey](
|
3851 | true
|
3852 |
|
3853 | );
|
3854 | }
|
3855 | const leavingVNode = leavingVNodesCache[key];
|
3856 | if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
|
3857 | leavingVNode.el[leaveCbKey]();
|
3858 | }
|
3859 | callHook(hook, [el]);
|
3860 | },
|
3861 | enter(el) {
|
3862 | let hook = onEnter;
|
3863 | let afterHook = onAfterEnter;
|
3864 | let cancelHook = onEnterCancelled;
|
3865 | if (!state.isMounted) {
|
3866 | if (appear) {
|
3867 | hook = onAppear || onEnter;
|
3868 | afterHook = onAfterAppear || onAfterEnter;
|
3869 | cancelHook = onAppearCancelled || onEnterCancelled;
|
3870 | } else {
|
3871 | return;
|
3872 | }
|
3873 | }
|
3874 | let called = false;
|
3875 | const done = el[enterCbKey$1] = (cancelled) => {
|
3876 | if (called)
|
3877 | return;
|
3878 | called = true;
|
3879 | if (cancelled) {
|
3880 | callHook(cancelHook, [el]);
|
3881 | } else {
|
3882 | callHook(afterHook, [el]);
|
3883 | }
|
3884 | if (hooks.delayedLeave) {
|
3885 | hooks.delayedLeave();
|
3886 | }
|
3887 | el[enterCbKey$1] = void 0;
|
3888 | };
|
3889 | if (hook) {
|
3890 | callAsyncHook(hook, [el, done]);
|
3891 | } else {
|
3892 | done();
|
3893 | }
|
3894 | },
|
3895 | leave(el, remove) {
|
3896 | const key2 = String(vnode.key);
|
3897 | if (el[enterCbKey$1]) {
|
3898 | el[enterCbKey$1](
|
3899 | true
|
3900 |
|
3901 | );
|
3902 | }
|
3903 | if (state.isUnmounting) {
|
3904 | return remove();
|
3905 | }
|
3906 | callHook(onBeforeLeave, [el]);
|
3907 | let called = false;
|
3908 | const done = el[leaveCbKey] = (cancelled) => {
|
3909 | if (called)
|
3910 | return;
|
3911 | called = true;
|
3912 | remove();
|
3913 | if (cancelled) {
|
3914 | callHook(onLeaveCancelled, [el]);
|
3915 | } else {
|
3916 | callHook(onAfterLeave, [el]);
|
3917 | }
|
3918 | el[leaveCbKey] = void 0;
|
3919 | if (leavingVNodesCache[key2] === vnode) {
|
3920 | delete leavingVNodesCache[key2];
|
3921 | }
|
3922 | };
|
3923 | leavingVNodesCache[key2] = vnode;
|
3924 | if (onLeave) {
|
3925 | callAsyncHook(onLeave, [el, done]);
|
3926 | } else {
|
3927 | done();
|
3928 | }
|
3929 | },
|
3930 | clone(vnode2) {
|
3931 | return resolveTransitionHooks(vnode2, props, state, instance);
|
3932 | }
|
3933 | };
|
3934 | return hooks;
|
3935 | }
|
3936 | function emptyPlaceholder(vnode) {
|
3937 | if (isKeepAlive(vnode)) {
|
3938 | vnode = cloneVNode(vnode);
|
3939 | vnode.children = null;
|
3940 | return vnode;
|
3941 | }
|
3942 | }
|
3943 | function getKeepAliveChild(vnode) {
|
3944 | return isKeepAlive(vnode) ? (
|
3945 |
|
3946 |
|
3947 | vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
|
3948 | ) : vnode;
|
3949 | }
|
3950 | function setTransitionHooks(vnode, hooks) {
|
3951 | if (vnode.shapeFlag & 6 && vnode.component) {
|
3952 | setTransitionHooks(vnode.component.subTree, hooks);
|
3953 | } else if (vnode.shapeFlag & 128) {
|
3954 | vnode.ssContent.transition = hooks.clone(vnode.ssContent);
|
3955 | vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
|
3956 | } else {
|
3957 | vnode.transition = hooks;
|
3958 | }
|
3959 | }
|
3960 | function getTransitionRawChildren(children, keepComment = false, parentKey) {
|
3961 | let ret = [];
|
3962 | let keyedFragmentCount = 0;
|
3963 | for (let i = 0; i < children.length; i++) {
|
3964 | let child = children[i];
|
3965 | const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
|
3966 | if (child.type === Fragment) {
|
3967 | if (child.patchFlag & 128)
|
3968 | keyedFragmentCount++;
|
3969 | ret = ret.concat(
|
3970 | getTransitionRawChildren(child.children, keepComment, key)
|
3971 | );
|
3972 | } else if (keepComment || child.type !== Comment) {
|
3973 | ret.push(key != null ? cloneVNode(child, { key }) : child);
|
3974 | }
|
3975 | }
|
3976 | if (keyedFragmentCount > 1) {
|
3977 | for (let i = 0; i < ret.length; i++) {
|
3978 | ret[i].patchFlag = -2;
|
3979 | }
|
3980 | }
|
3981 | return ret;
|
3982 | }
|
3983 |
|
3984 |
|
3985 |
|
3986 | function defineComponent(options, extraOptions) {
|
3987 | return isFunction(options) ? (
|
3988 |
|
3989 |
|
3990 | (() => extend({ name: options.name }, extraOptions, { setup: options }))()
|
3991 | ) : options;
|
3992 | }
|
3993 |
|
3994 | const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
|
3995 |
|
3996 |
|
3997 | function defineAsyncComponent(source) {
|
3998 | if (isFunction(source)) {
|
3999 | source = { loader: source };
|
4000 | }
|
4001 | const {
|
4002 | loader,
|
4003 | loadingComponent,
|
4004 | errorComponent,
|
4005 | delay = 200,
|
4006 | timeout,
|
4007 |
|
4008 | suspensible = true,
|
4009 | onError: userOnError
|
4010 | } = source;
|
4011 | let pendingRequest = null;
|
4012 | let resolvedComp;
|
4013 | let retries = 0;
|
4014 | const retry = () => {
|
4015 | retries++;
|
4016 | pendingRequest = null;
|
4017 | return load();
|
4018 | };
|
4019 | const load = () => {
|
4020 | let thisRequest;
|
4021 | return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
|
4022 | err = err instanceof Error ? err : new Error(String(err));
|
4023 | if (userOnError) {
|
4024 | return new Promise((resolve, reject) => {
|
4025 | const userRetry = () => resolve(retry());
|
4026 | const userFail = () => reject(err);
|
4027 | userOnError(err, userRetry, userFail, retries + 1);
|
4028 | });
|
4029 | } else {
|
4030 | throw err;
|
4031 | }
|
4032 | }).then((comp) => {
|
4033 | if (thisRequest !== pendingRequest && pendingRequest) {
|
4034 | return pendingRequest;
|
4035 | }
|
4036 | if (!comp) {
|
4037 | warn$1(
|
4038 | `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
|
4039 | );
|
4040 | }
|
4041 | if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
|
4042 | comp = comp.default;
|
4043 | }
|
4044 | if (comp && !isObject(comp) && !isFunction(comp)) {
|
4045 | throw new Error(`Invalid async component load result: ${comp}`);
|
4046 | }
|
4047 | resolvedComp = comp;
|
4048 | return comp;
|
4049 | }));
|
4050 | };
|
4051 | return defineComponent({
|
4052 | name: "AsyncComponentWrapper",
|
4053 | __asyncLoader: load,
|
4054 | get __asyncResolved() {
|
4055 | return resolvedComp;
|
4056 | },
|
4057 | setup() {
|
4058 | const instance = currentInstance;
|
4059 | if (resolvedComp) {
|
4060 | return () => createInnerComp(resolvedComp, instance);
|
4061 | }
|
4062 | const onError = (err) => {
|
4063 | pendingRequest = null;
|
4064 | handleError(
|
4065 | err,
|
4066 | instance,
|
4067 | 13,
|
4068 | !errorComponent
|
4069 | );
|
4070 | };
|
4071 | if (suspensible && instance.suspense || false) {
|
4072 | return load().then((comp) => {
|
4073 | return () => createInnerComp(comp, instance);
|
4074 | }).catch((err) => {
|
4075 | onError(err);
|
4076 | return () => errorComponent ? createVNode(errorComponent, {
|
4077 | error: err
|
4078 | }) : null;
|
4079 | });
|
4080 | }
|
4081 | const loaded = ref(false);
|
4082 | const error = ref();
|
4083 | const delayed = ref(!!delay);
|
4084 | if (delay) {
|
4085 | setTimeout(() => {
|
4086 | delayed.value = false;
|
4087 | }, delay);
|
4088 | }
|
4089 | if (timeout != null) {
|
4090 | setTimeout(() => {
|
4091 | if (!loaded.value && !error.value) {
|
4092 | const err = new Error(
|
4093 | `Async component timed out after ${timeout}ms.`
|
4094 | );
|
4095 | onError(err);
|
4096 | error.value = err;
|
4097 | }
|
4098 | }, timeout);
|
4099 | }
|
4100 | load().then(() => {
|
4101 | loaded.value = true;
|
4102 | if (instance.parent && isKeepAlive(instance.parent.vnode)) {
|
4103 | instance.parent.effect.dirty = true;
|
4104 | queueJob(instance.parent.update);
|
4105 | }
|
4106 | }).catch((err) => {
|
4107 | onError(err);
|
4108 | error.value = err;
|
4109 | });
|
4110 | return () => {
|
4111 | if (loaded.value && resolvedComp) {
|
4112 | return createInnerComp(resolvedComp, instance);
|
4113 | } else if (error.value && errorComponent) {
|
4114 | return createVNode(errorComponent, {
|
4115 | error: error.value
|
4116 | });
|
4117 | } else if (loadingComponent && !delayed.value) {
|
4118 | return createVNode(loadingComponent);
|
4119 | }
|
4120 | };
|
4121 | }
|
4122 | });
|
4123 | }
|
4124 | function createInnerComp(comp, parent) {
|
4125 | const { ref: ref2, props, children, ce } = parent.vnode;
|
4126 | const vnode = createVNode(comp, props, children);
|
4127 | vnode.ref = ref2;
|
4128 | vnode.ce = ce;
|
4129 | delete parent.vnode.ce;
|
4130 | return vnode;
|
4131 | }
|
4132 |
|
4133 | const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
4134 | const KeepAliveImpl = {
|
4135 | name: `KeepAlive`,
|
4136 |
|
4137 |
|
4138 |
|
4139 | __isKeepAlive: true,
|
4140 | props: {
|
4141 | include: [String, RegExp, Array],
|
4142 | exclude: [String, RegExp, Array],
|
4143 | max: [String, Number]
|
4144 | },
|
4145 | setup(props, { slots }) {
|
4146 | const instance = getCurrentInstance();
|
4147 | const sharedContext = instance.ctx;
|
4148 | const cache = new Map();
|
4149 | const keys = new Set();
|
4150 | let current = null;
|
4151 | {
|
4152 | instance.__v_cache = cache;
|
4153 | }
|
4154 | const parentSuspense = instance.suspense;
|
4155 | const {
|
4156 | renderer: {
|
4157 | p: patch,
|
4158 | m: move,
|
4159 | um: _unmount,
|
4160 | o: { createElement }
|
4161 | }
|
4162 | } = sharedContext;
|
4163 | const storageContainer = createElement("div");
|
4164 | sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
|
4165 | const instance2 = vnode.component;
|
4166 | move(vnode, container, anchor, 0, parentSuspense);
|
4167 | patch(
|
4168 | instance2.vnode,
|
4169 | vnode,
|
4170 | container,
|
4171 | anchor,
|
4172 | instance2,
|
4173 | parentSuspense,
|
4174 | namespace,
|
4175 | vnode.slotScopeIds,
|
4176 | optimized
|
4177 | );
|
4178 | queuePostRenderEffect(() => {
|
4179 | instance2.isDeactivated = false;
|
4180 | if (instance2.a) {
|
4181 | invokeArrayFns(instance2.a);
|
4182 | }
|
4183 | const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
|
4184 | if (vnodeHook) {
|
4185 | invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
4186 | }
|
4187 | }, parentSuspense);
|
4188 | {
|
4189 | devtoolsComponentAdded(instance2);
|
4190 | }
|
4191 | };
|
4192 | sharedContext.deactivate = (vnode) => {
|
4193 | const instance2 = vnode.component;
|
4194 | move(vnode, storageContainer, null, 1, parentSuspense);
|
4195 | queuePostRenderEffect(() => {
|
4196 | if (instance2.da) {
|
4197 | invokeArrayFns(instance2.da);
|
4198 | }
|
4199 | const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
|
4200 | if (vnodeHook) {
|
4201 | invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
4202 | }
|
4203 | instance2.isDeactivated = true;
|
4204 | }, parentSuspense);
|
4205 | {
|
4206 | devtoolsComponentAdded(instance2);
|
4207 | }
|
4208 | };
|
4209 | function unmount(vnode) {
|
4210 | resetShapeFlag(vnode);
|
4211 | _unmount(vnode, instance, parentSuspense, true);
|
4212 | }
|
4213 | function pruneCache(filter) {
|
4214 | cache.forEach((vnode, key) => {
|
4215 | const name = getComponentName(vnode.type);
|
4216 | if (name && (!filter || !filter(name))) {
|
4217 | pruneCacheEntry(key);
|
4218 | }
|
4219 | });
|
4220 | }
|
4221 | function pruneCacheEntry(key) {
|
4222 | const cached = cache.get(key);
|
4223 | if (!current || !isSameVNodeType(cached, current)) {
|
4224 | unmount(cached);
|
4225 | } else if (current) {
|
4226 | resetShapeFlag(current);
|
4227 | }
|
4228 | cache.delete(key);
|
4229 | keys.delete(key);
|
4230 | }
|
4231 | watch(
|
4232 | () => [props.include, props.exclude],
|
4233 | ([include, exclude]) => {
|
4234 | include && pruneCache((name) => matches(include, name));
|
4235 | exclude && pruneCache((name) => !matches(exclude, name));
|
4236 | },
|
4237 |
|
4238 | { flush: "post", deep: true }
|
4239 | );
|
4240 | let pendingCacheKey = null;
|
4241 | const cacheSubtree = () => {
|
4242 | if (pendingCacheKey != null) {
|
4243 | cache.set(pendingCacheKey, getInnerChild(instance.subTree));
|
4244 | }
|
4245 | };
|
4246 | onMounted(cacheSubtree);
|
4247 | onUpdated(cacheSubtree);
|
4248 | onBeforeUnmount(() => {
|
4249 | cache.forEach((cached) => {
|
4250 | const { subTree, suspense } = instance;
|
4251 | const vnode = getInnerChild(subTree);
|
4252 | if (cached.type === vnode.type && cached.key === vnode.key) {
|
4253 | resetShapeFlag(vnode);
|
4254 | const da = vnode.component.da;
|
4255 | da && queuePostRenderEffect(da, suspense);
|
4256 | return;
|
4257 | }
|
4258 | unmount(cached);
|
4259 | });
|
4260 | });
|
4261 | return () => {
|
4262 | pendingCacheKey = null;
|
4263 | if (!slots.default) {
|
4264 | return null;
|
4265 | }
|
4266 | const children = slots.default();
|
4267 | const rawVNode = children[0];
|
4268 | if (children.length > 1) {
|
4269 | {
|
4270 | warn$1(`KeepAlive should contain exactly one component child.`);
|
4271 | }
|
4272 | current = null;
|
4273 | return children;
|
4274 | } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
|
4275 | current = null;
|
4276 | return rawVNode;
|
4277 | }
|
4278 | let vnode = getInnerChild(rawVNode);
|
4279 | const comp = vnode.type;
|
4280 | const name = getComponentName(
|
4281 | isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
|
4282 | );
|
4283 | const { include, exclude, max } = props;
|
4284 | if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
|
4285 | current = vnode;
|
4286 | return rawVNode;
|
4287 | }
|
4288 | const key = vnode.key == null ? comp : vnode.key;
|
4289 | const cachedVNode = cache.get(key);
|
4290 | if (vnode.el) {
|
4291 | vnode = cloneVNode(vnode);
|
4292 | if (rawVNode.shapeFlag & 128) {
|
4293 | rawVNode.ssContent = vnode;
|
4294 | }
|
4295 | }
|
4296 | pendingCacheKey = key;
|
4297 | if (cachedVNode) {
|
4298 | vnode.el = cachedVNode.el;
|
4299 | vnode.component = cachedVNode.component;
|
4300 | if (vnode.transition) {
|
4301 | setTransitionHooks(vnode, vnode.transition);
|
4302 | }
|
4303 | vnode.shapeFlag |= 512;
|
4304 | keys.delete(key);
|
4305 | keys.add(key);
|
4306 | } else {
|
4307 | keys.add(key);
|
4308 | if (max && keys.size > parseInt(max, 10)) {
|
4309 | pruneCacheEntry(keys.values().next().value);
|
4310 | }
|
4311 | }
|
4312 | vnode.shapeFlag |= 256;
|
4313 | current = vnode;
|
4314 | return isSuspense(rawVNode.type) ? rawVNode : vnode;
|
4315 | };
|
4316 | }
|
4317 | };
|
4318 | const KeepAlive = KeepAliveImpl;
|
4319 | function matches(pattern, name) {
|
4320 | if (isArray(pattern)) {
|
4321 | return pattern.some((p) => matches(p, name));
|
4322 | } else if (isString(pattern)) {
|
4323 | return pattern.split(",").includes(name);
|
4324 | } else if (isRegExp(pattern)) {
|
4325 | return pattern.test(name);
|
4326 | }
|
4327 | return false;
|
4328 | }
|
4329 | function onActivated(hook, target) {
|
4330 | registerKeepAliveHook(hook, "a", target);
|
4331 | }
|
4332 | function onDeactivated(hook, target) {
|
4333 | registerKeepAliveHook(hook, "da", target);
|
4334 | }
|
4335 | function registerKeepAliveHook(hook, type, target = currentInstance) {
|
4336 | const wrappedHook = hook.__wdc || (hook.__wdc = () => {
|
4337 | let current = target;
|
4338 | while (current) {
|
4339 | if (current.isDeactivated) {
|
4340 | return;
|
4341 | }
|
4342 | current = current.parent;
|
4343 | }
|
4344 | return hook();
|
4345 | });
|
4346 | injectHook(type, wrappedHook, target);
|
4347 | if (target) {
|
4348 | let current = target.parent;
|
4349 | while (current && current.parent) {
|
4350 | if (isKeepAlive(current.parent.vnode)) {
|
4351 | injectToKeepAliveRoot(wrappedHook, type, target, current);
|
4352 | }
|
4353 | current = current.parent;
|
4354 | }
|
4355 | }
|
4356 | }
|
4357 | function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
|
4358 | const injected = injectHook(
|
4359 | type,
|
4360 | hook,
|
4361 | keepAliveRoot,
|
4362 | true
|
4363 |
|
4364 | );
|
4365 | onUnmounted(() => {
|
4366 | remove(keepAliveRoot[type], injected);
|
4367 | }, target);
|
4368 | }
|
4369 | function resetShapeFlag(vnode) {
|
4370 | vnode.shapeFlag &= ~256;
|
4371 | vnode.shapeFlag &= ~512;
|
4372 | }
|
4373 | function getInnerChild(vnode) {
|
4374 | return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
|
4375 | }
|
4376 |
|
4377 | function injectHook(type, hook, target = currentInstance, prepend = false) {
|
4378 | if (target) {
|
4379 | const hooks = target[type] || (target[type] = []);
|
4380 | const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
|
4381 | if (target.isUnmounted) {
|
4382 | return;
|
4383 | }
|
4384 | pauseTracking();
|
4385 | const reset = setCurrentInstance(target);
|
4386 | const res = callWithAsyncErrorHandling(hook, target, type, args);
|
4387 | reset();
|
4388 | resetTracking();
|
4389 | return res;
|
4390 | });
|
4391 | if (prepend) {
|
4392 | hooks.unshift(wrappedHook);
|
4393 | } else {
|
4394 | hooks.push(wrappedHook);
|
4395 | }
|
4396 | return wrappedHook;
|
4397 | } else {
|
4398 | const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
|
4399 | warn$1(
|
4400 | `${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.` )
|
4401 | );
|
4402 | }
|
4403 | }
|
4404 | const createHook = (lifecycle) => (hook, target = currentInstance) => (
|
4405 |
|
4406 | (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target)
|
4407 | );
|
4408 | const onBeforeMount = createHook("bm");
|
4409 | const onMounted = createHook("m");
|
4410 | const onBeforeUpdate = createHook("bu");
|
4411 | const onUpdated = createHook("u");
|
4412 | const onBeforeUnmount = createHook("bum");
|
4413 | const onUnmounted = createHook("um");
|
4414 | const onServerPrefetch = createHook("sp");
|
4415 | const onRenderTriggered = createHook(
|
4416 | "rtg"
|
4417 | );
|
4418 | const onRenderTracked = createHook(
|
4419 | "rtc"
|
4420 | );
|
4421 | function onErrorCaptured(hook, target = currentInstance) {
|
4422 | injectHook("ec", hook, target);
|
4423 | }
|
4424 |
|
4425 | function renderList(source, renderItem, cache, index) {
|
4426 | let ret;
|
4427 | const cached = cache && cache[index];
|
4428 | if (isArray(source) || isString(source)) {
|
4429 | ret = new Array(source.length);
|
4430 | for (let i = 0, l = source.length; i < l; i++) {
|
4431 | ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
|
4432 | }
|
4433 | } else if (typeof source === "number") {
|
4434 | if (!Number.isInteger(source)) {
|
4435 | warn$1(`The v-for range expect an integer value but got ${source}.`);
|
4436 | }
|
4437 | ret = new Array(source);
|
4438 | for (let i = 0; i < source; i++) {
|
4439 | ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
|
4440 | }
|
4441 | } else if (isObject(source)) {
|
4442 | if (source[Symbol.iterator]) {
|
4443 | ret = Array.from(
|
4444 | source,
|
4445 | (item, i) => renderItem(item, i, void 0, cached && cached[i])
|
4446 | );
|
4447 | } else {
|
4448 | const keys = Object.keys(source);
|
4449 | ret = new Array(keys.length);
|
4450 | for (let i = 0, l = keys.length; i < l; i++) {
|
4451 | const key = keys[i];
|
4452 | ret[i] = renderItem(source[key], key, i, cached && cached[i]);
|
4453 | }
|
4454 | }
|
4455 | } else {
|
4456 | ret = [];
|
4457 | }
|
4458 | if (cache) {
|
4459 | cache[index] = ret;
|
4460 | }
|
4461 | return ret;
|
4462 | }
|
4463 |
|
4464 | function createSlots(slots, dynamicSlots) {
|
4465 | for (let i = 0; i < dynamicSlots.length; i++) {
|
4466 | const slot = dynamicSlots[i];
|
4467 | if (isArray(slot)) {
|
4468 | for (let j = 0; j < slot.length; j++) {
|
4469 | slots[slot[j].name] = slot[j].fn;
|
4470 | }
|
4471 | } else if (slot) {
|
4472 | slots[slot.name] = slot.key ? (...args) => {
|
4473 | const res = slot.fn(...args);
|
4474 | if (res)
|
4475 | res.key = slot.key;
|
4476 | return res;
|
4477 | } : slot.fn;
|
4478 | }
|
4479 | }
|
4480 | return slots;
|
4481 | }
|
4482 |
|
4483 | function renderSlot(slots, name, props = {}, fallback, noSlotted) {
|
4484 | if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
|
4485 | if (name !== "default")
|
4486 | props.name = name;
|
4487 | return createVNode("slot", props, fallback && fallback());
|
4488 | }
|
4489 | let slot = slots[name];
|
4490 | if (slot && slot.length > 1) {
|
4491 | warn$1(
|
4492 | `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.`
|
4493 | );
|
4494 | slot = () => [];
|
4495 | }
|
4496 | if (slot && slot._c) {
|
4497 | slot._d = false;
|
4498 | }
|
4499 | openBlock();
|
4500 | const validSlotContent = slot && ensureValidVNode(slot(props));
|
4501 | const rendered = createBlock(
|
4502 | Fragment,
|
4503 | {
|
4504 | key: props.key ||
|
4505 |
|
4506 | validSlotContent && validSlotContent.key || `_${name}`
|
4507 | },
|
4508 | validSlotContent || (fallback ? fallback() : []),
|
4509 | validSlotContent && slots._ === 1 ? 64 : -2
|
4510 | );
|
4511 | if (!noSlotted && rendered.scopeId) {
|
4512 | rendered.slotScopeIds = [rendered.scopeId + "-s"];
|
4513 | }
|
4514 | if (slot && slot._c) {
|
4515 | slot._d = true;
|
4516 | }
|
4517 | return rendered;
|
4518 | }
|
4519 | function ensureValidVNode(vnodes) {
|
4520 | return vnodes.some((child) => {
|
4521 | if (!isVNode(child))
|
4522 | return true;
|
4523 | if (child.type === Comment)
|
4524 | return false;
|
4525 | if (child.type === Fragment && !ensureValidVNode(child.children))
|
4526 | return false;
|
4527 | return true;
|
4528 | }) ? vnodes : null;
|
4529 | }
|
4530 |
|
4531 | function toHandlers(obj, preserveCaseIfNecessary) {
|
4532 | const ret = {};
|
4533 | if (!isObject(obj)) {
|
4534 | warn$1(`v-on with no argument expects an object value.`);
|
4535 | return ret;
|
4536 | }
|
4537 | for (const key in obj) {
|
4538 | ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : toHandlerKey(key)] = obj[key];
|
4539 | }
|
4540 | return ret;
|
4541 | }
|
4542 |
|
4543 | const getPublicInstance = (i) => {
|
4544 | if (!i)
|
4545 | return null;
|
4546 | if (isStatefulComponent(i))
|
4547 | return getExposeProxy(i) || i.proxy;
|
4548 | return getPublicInstance(i.parent);
|
4549 | };
|
4550 | const publicPropertiesMap = (
|
4551 |
|
4552 |
|
4553 | extend( Object.create(null), {
|
4554 | $: (i) => i,
|
4555 | $el: (i) => i.vnode.el,
|
4556 | $data: (i) => i.data,
|
4557 | $props: (i) => shallowReadonly(i.props) ,
|
4558 | $attrs: (i) => shallowReadonly(i.attrs) ,
|
4559 | $slots: (i) => shallowReadonly(i.slots) ,
|
4560 | $refs: (i) => shallowReadonly(i.refs) ,
|
4561 | $parent: (i) => getPublicInstance(i.parent),
|
4562 | $root: (i) => getPublicInstance(i.root),
|
4563 | $emit: (i) => i.emit,
|
4564 | $options: (i) => resolveMergedOptions(i) ,
|
4565 | $forceUpdate: (i) => i.f || (i.f = () => {
|
4566 | i.effect.dirty = true;
|
4567 | queueJob(i.update);
|
4568 | }),
|
4569 | $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
|
4570 | $watch: (i) => instanceWatch.bind(i)
|
4571 | })
|
4572 | );
|
4573 | const isReservedPrefix = (key) => key === "_" || key === "$";
|
4574 | const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
|
4575 | const PublicInstanceProxyHandlers = {
|
4576 | get({ _: instance }, key) {
|
4577 | const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
4578 | if (key === "__isVue") {
|
4579 | return true;
|
4580 | }
|
4581 | let normalizedProps;
|
4582 | if (key[0] !== "$") {
|
4583 | const n = accessCache[key];
|
4584 | if (n !== void 0) {
|
4585 | switch (n) {
|
4586 | case 1 :
|
4587 | return setupState[key];
|
4588 | case 2 :
|
4589 | return data[key];
|
4590 | case 4 :
|
4591 | return ctx[key];
|
4592 | case 3 :
|
4593 | return props[key];
|
4594 | }
|
4595 | } else if (hasSetupBinding(setupState, key)) {
|
4596 | accessCache[key] = 1 ;
|
4597 | return setupState[key];
|
4598 | } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
4599 | accessCache[key] = 2 ;
|
4600 | return data[key];
|
4601 | } else if (
|
4602 |
|
4603 |
|
4604 | (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
|
4605 | ) {
|
4606 | accessCache[key] = 3 ;
|
4607 | return props[key];
|
4608 | } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
4609 | accessCache[key] = 4 ;
|
4610 | return ctx[key];
|
4611 | } else if (shouldCacheAccess) {
|
4612 | accessCache[key] = 0 ;
|
4613 | }
|
4614 | }
|
4615 | const publicGetter = publicPropertiesMap[key];
|
4616 | let cssModule, globalProperties;
|
4617 | if (publicGetter) {
|
4618 | if (key === "$attrs") {
|
4619 | track(instance, "get", key);
|
4620 | markAttrsAccessed();
|
4621 | } else if (key === "$slots") {
|
4622 | track(instance, "get", key);
|
4623 | }
|
4624 | return publicGetter(instance);
|
4625 | } else if (
|
4626 |
|
4627 | (cssModule = type.__cssModules) && (cssModule = cssModule[key])
|
4628 | ) {
|
4629 | return cssModule;
|
4630 | } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
4631 | accessCache[key] = 4 ;
|
4632 | return ctx[key];
|
4633 | } else if (
|
4634 |
|
4635 | globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
|
4636 | ) {
|
4637 | {
|
4638 | return globalProperties[key];
|
4639 | }
|
4640 | } else if (currentRenderingInstance && (!isString(key) ||
|
4641 |
|
4642 | key.indexOf("__v") !== 0)) {
|
4643 | if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
|
4644 | warn$1(
|
4645 | `Property ${JSON.stringify(
|
4646 | key
|
4647 | )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
|
4648 | );
|
4649 | } else if (instance === currentRenderingInstance) {
|
4650 | warn$1(
|
4651 | `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
|
4652 | );
|
4653 | }
|
4654 | }
|
4655 | },
|
4656 | set({ _: instance }, key, value) {
|
4657 | const { data, setupState, ctx } = instance;
|
4658 | if (hasSetupBinding(setupState, key)) {
|
4659 | setupState[key] = value;
|
4660 | return true;
|
4661 | } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
|
4662 | warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
|
4663 | return false;
|
4664 | } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
4665 | data[key] = value;
|
4666 | return true;
|
4667 | } else if (hasOwn(instance.props, key)) {
|
4668 | warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
|
4669 | return false;
|
4670 | }
|
4671 | if (key[0] === "$" && key.slice(1) in instance) {
|
4672 | warn$1(
|
4673 | `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
|
4674 | );
|
4675 | return false;
|
4676 | } else {
|
4677 | if (key in instance.appContext.config.globalProperties) {
|
4678 | Object.defineProperty(ctx, key, {
|
4679 | enumerable: true,
|
4680 | configurable: true,
|
4681 | value
|
4682 | });
|
4683 | } else {
|
4684 | ctx[key] = value;
|
4685 | }
|
4686 | }
|
4687 | return true;
|
4688 | },
|
4689 | has({
|
4690 | _: { data, setupState, accessCache, ctx, appContext, propsOptions }
|
4691 | }, key) {
|
4692 | let normalizedProps;
|
4693 | 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);
|
4694 | },
|
4695 | defineProperty(target, key, descriptor) {
|
4696 | if (descriptor.get != null) {
|
4697 | target._.accessCache[key] = 0;
|
4698 | } else if (hasOwn(descriptor, "value")) {
|
4699 | this.set(target, key, descriptor.value, null);
|
4700 | }
|
4701 | return Reflect.defineProperty(target, key, descriptor);
|
4702 | }
|
4703 | };
|
4704 | {
|
4705 | PublicInstanceProxyHandlers.ownKeys = (target) => {
|
4706 | warn$1(
|
4707 | `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
|
4708 | );
|
4709 | return Reflect.ownKeys(target);
|
4710 | };
|
4711 | }
|
4712 | const RuntimeCompiledPublicInstanceProxyHandlers = extend(
|
4713 | {},
|
4714 | PublicInstanceProxyHandlers,
|
4715 | {
|
4716 | get(target, key) {
|
4717 | if (key === Symbol.unscopables) {
|
4718 | return;
|
4719 | }
|
4720 | return PublicInstanceProxyHandlers.get(target, key, target);
|
4721 | },
|
4722 | has(_, key) {
|
4723 | const has = key[0] !== "_" && !isGloballyAllowed(key);
|
4724 | if (!has && PublicInstanceProxyHandlers.has(_, key)) {
|
4725 | warn$1(
|
4726 | `Property ${JSON.stringify(
|
4727 | key
|
4728 | )} should not start with _ which is a reserved prefix for Vue internals.`
|
4729 | );
|
4730 | }
|
4731 | return has;
|
4732 | }
|
4733 | }
|
4734 | );
|
4735 | function createDevRenderContext(instance) {
|
4736 | const target = {};
|
4737 | Object.defineProperty(target, `_`, {
|
4738 | configurable: true,
|
4739 | enumerable: false,
|
4740 | get: () => instance
|
4741 | });
|
4742 | Object.keys(publicPropertiesMap).forEach((key) => {
|
4743 | Object.defineProperty(target, key, {
|
4744 | configurable: true,
|
4745 | enumerable: false,
|
4746 | get: () => publicPropertiesMap[key](instance),
|
4747 | // intercepted by the proxy so no need for implementation,
|
4748 | // but needed to prevent set errors
|
4749 | set: NOOP
|
4750 | });
|
4751 | });
|
4752 | return target;
|
4753 | }
|
4754 | function exposePropsOnRenderContext(instance) {
|
4755 | const {
|
4756 | ctx,
|
4757 | propsOptions: [propsOptions]
|
4758 | } = instance;
|
4759 | if (propsOptions) {
|
4760 | Object.keys(propsOptions).forEach((key) => {
|
4761 | Object.defineProperty(ctx, key, {
|
4762 | enumerable: true,
|
4763 | configurable: true,
|
4764 | get: () => instance.props[key],
|
4765 | set: NOOP
|
4766 | });
|
4767 | });
|
4768 | }
|
4769 | }
|
4770 | function exposeSetupStateOnRenderContext(instance) {
|
4771 | const { ctx, setupState } = instance;
|
4772 | Object.keys(toRaw(setupState)).forEach((key) => {
|
4773 | if (!setupState.__isScriptSetup) {
|
4774 | if (isReservedPrefix(key[0])) {
|
4775 | warn$1(
|
4776 | `setup() return property ${JSON.stringify(
|
4777 | key
|
4778 | )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`
|
4779 | );
|
4780 | return;
|
4781 | }
|
4782 | Object.defineProperty(ctx, key, {
|
4783 | enumerable: true,
|
4784 | configurable: true,
|
4785 | get: () => setupState[key],
|
4786 | set: NOOP
|
4787 | });
|
4788 | }
|
4789 | });
|
4790 | }
|
4791 |
|
4792 | const warnRuntimeUsage = (method) => warn$1(
|
4793 | `${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.`
|
4794 | );
|
4795 | function defineProps() {
|
4796 | {
|
4797 | warnRuntimeUsage(`defineProps`);
|
4798 | }
|
4799 | return null;
|
4800 | }
|
4801 | function defineEmits() {
|
4802 | {
|
4803 | warnRuntimeUsage(`defineEmits`);
|
4804 | }
|
4805 | return null;
|
4806 | }
|
4807 | function defineExpose(exposed) {
|
4808 | {
|
4809 | warnRuntimeUsage(`defineExpose`);
|
4810 | }
|
4811 | }
|
4812 | function defineOptions(options) {
|
4813 | {
|
4814 | warnRuntimeUsage(`defineOptions`);
|
4815 | }
|
4816 | }
|
4817 | function defineSlots() {
|
4818 | {
|
4819 | warnRuntimeUsage(`defineSlots`);
|
4820 | }
|
4821 | return null;
|
4822 | }
|
4823 | function defineModel() {
|
4824 | {
|
4825 | warnRuntimeUsage("defineModel");
|
4826 | }
|
4827 | }
|
4828 | function withDefaults(props, defaults) {
|
4829 | {
|
4830 | warnRuntimeUsage(`withDefaults`);
|
4831 | }
|
4832 | return null;
|
4833 | }
|
4834 | function useSlots() {
|
4835 | return getContext().slots;
|
4836 | }
|
4837 | function useAttrs() {
|
4838 | return getContext().attrs;
|
4839 | }
|
4840 | function getContext() {
|
4841 | const i = getCurrentInstance();
|
4842 | if (!i) {
|
4843 | warn$1(`useContext() called without active instance.`);
|
4844 | }
|
4845 | return i.setupContext || (i.setupContext = createSetupContext(i));
|
4846 | }
|
4847 | function normalizePropsOrEmits(props) {
|
4848 | return isArray(props) ? props.reduce(
|
4849 | (normalized, p) => (normalized[p] = null, normalized),
|
4850 | {}
|
4851 | ) : props;
|
4852 | }
|
4853 | function mergeDefaults(raw, defaults) {
|
4854 | const props = normalizePropsOrEmits(raw);
|
4855 | for (const key in defaults) {
|
4856 | if (key.startsWith("__skip"))
|
4857 | continue;
|
4858 | let opt = props[key];
|
4859 | if (opt) {
|
4860 | if (isArray(opt) || isFunction(opt)) {
|
4861 | opt = props[key] = { type: opt, default: defaults[key] };
|
4862 | } else {
|
4863 | opt.default = defaults[key];
|
4864 | }
|
4865 | } else if (opt === null) {
|
4866 | opt = props[key] = { default: defaults[key] };
|
4867 | } else {
|
4868 | warn$1(`props default key "${key}" has no corresponding declaration.`);
|
4869 | }
|
4870 | if (opt && defaults[`__skip_${key}`]) {
|
4871 | opt.skipFactory = true;
|
4872 | }
|
4873 | }
|
4874 | return props;
|
4875 | }
|
4876 | function mergeModels(a, b) {
|
4877 | if (!a || !b)
|
4878 | return a || b;
|
4879 | if (isArray(a) && isArray(b))
|
4880 | return a.concat(b);
|
4881 | return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
|
4882 | }
|
4883 | function createPropsRestProxy(props, excludedKeys) {
|
4884 | const ret = {};
|
4885 | for (const key in props) {
|
4886 | if (!excludedKeys.includes(key)) {
|
4887 | Object.defineProperty(ret, key, {
|
4888 | enumerable: true,
|
4889 | get: () => props[key]
|
4890 | });
|
4891 | }
|
4892 | }
|
4893 | return ret;
|
4894 | }
|
4895 | function withAsyncContext(getAwaitable) {
|
4896 | const ctx = getCurrentInstance();
|
4897 | if (!ctx) {
|
4898 | warn$1(
|
4899 | `withAsyncContext called without active current instance. This is likely a bug.`
|
4900 | );
|
4901 | }
|
4902 | let awaitable = getAwaitable();
|
4903 | unsetCurrentInstance();
|
4904 | if (isPromise(awaitable)) {
|
4905 | awaitable = awaitable.catch((e) => {
|
4906 | setCurrentInstance(ctx);
|
4907 | throw e;
|
4908 | });
|
4909 | }
|
4910 | return [awaitable, () => setCurrentInstance(ctx)];
|
4911 | }
|
4912 |
|
4913 | function createDuplicateChecker() {
|
4914 | const cache = /* @__PURE__ */ Object.create(null);
|
4915 | return (type, key) => {
|
4916 | if (cache[key]) {
|
4917 | warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
|
4918 | } else {
|
4919 | cache[key] = type;
|
4920 | }
|
4921 | };
|
4922 | }
|
4923 | let shouldCacheAccess = true;
|
4924 | function applyOptions(instance) {
|
4925 | const options = resolveMergedOptions(instance);
|
4926 | const publicThis = instance.proxy;
|
4927 | const ctx = instance.ctx;
|
4928 | shouldCacheAccess = false;
|
4929 | if (options.beforeCreate) {
|
4930 | callHook$1(options.beforeCreate, instance, "bc");
|
4931 | }
|
4932 | const {
|
4933 | // state
|
4934 | data: dataOptions,
|
4935 | computed: computedOptions,
|
4936 | methods,
|
4937 | watch: watchOptions,
|
4938 | provide: provideOptions,
|
4939 | inject: injectOptions,
|
4940 | // lifecycle
|
4941 | created,
|
4942 | beforeMount,
|
4943 | mounted,
|
4944 | beforeUpdate,
|
4945 | updated,
|
4946 | activated,
|
4947 | deactivated,
|
4948 | beforeDestroy,
|
4949 | beforeUnmount,
|
4950 | destroyed,
|
4951 | unmounted,
|
4952 | render,
|
4953 | renderTracked,
|
4954 | renderTriggered,
|
4955 | errorCaptured,
|
4956 | serverPrefetch,
|
4957 | // public API
|
4958 | expose,
|
4959 | inheritAttrs,
|
4960 | // assets
|
4961 | components,
|
4962 | directives,
|
4963 | filters
|
4964 | } = options;
|
4965 | const checkDuplicateProperties = createDuplicateChecker() ;
|
4966 | {
|
4967 | const [propsOptions] = instance.propsOptions;
|
4968 | if (propsOptions) {
|
4969 | for (const key in propsOptions) {
|
4970 | checkDuplicateProperties("Props" /* PROPS */, key);
|
4971 | }
|
4972 | }
|
4973 | }
|
4974 | if (injectOptions) {
|
4975 | resolveInjections(injectOptions, ctx, checkDuplicateProperties);
|
4976 | }
|
4977 | if (methods) {
|
4978 | for (const key in methods) {
|
4979 | const methodHandler = methods[key];
|
4980 | if (isFunction(methodHandler)) {
|
4981 | {
|
4982 | Object.defineProperty(ctx, key, {
|
4983 | value: methodHandler.bind(publicThis),
|
4984 | configurable: true,
|
4985 | enumerable: true,
|
4986 | writable: true
|
4987 | });
|
4988 | }
|
4989 | {
|
4990 | checkDuplicateProperties("Methods" /* METHODS */, key);
|
4991 | }
|
4992 | } else {
|
4993 | warn$1(
|
4994 | `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
|
4995 | );
|
4996 | }
|
4997 | }
|
4998 | }
|
4999 | if (dataOptions) {
|
5000 | if (!isFunction(dataOptions)) {
|
5001 | warn$1(
|
5002 | `The data option must be a function. Plain object usage is no longer supported.`
|
5003 | );
|
5004 | }
|
5005 | const data = dataOptions.call(publicThis, publicThis);
|
5006 | if (isPromise(data)) {
|
5007 | warn$1(
|
5008 | `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
|
5009 | );
|
5010 | }
|
5011 | if (!isObject(data)) {
|
5012 | warn$1(`data() should return an object.`);
|
5013 | } else {
|
5014 | instance.data = reactive(data);
|
5015 | {
|
5016 | for (const key in data) {
|
5017 | checkDuplicateProperties("Data" , key);
|
5018 | if (!isReservedPrefix(key[0])) {
|
5019 | Object.defineProperty(ctx, key, {
|
5020 | configurable: true,
|
5021 | enumerable: true,
|
5022 | get: () => data[key],
|
5023 | set: NOOP
|
5024 | });
|
5025 | }
|
5026 | }
|
5027 | }
|
5028 | }
|
5029 | }
|
5030 | shouldCacheAccess = true;
|
5031 | if (computedOptions) {
|
5032 | for (const key in computedOptions) {
|
5033 | const opt = computedOptions[key];
|
5034 | const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
|
5035 | if (get === NOOP) {
|
5036 | warn$1(`Computed property "${key}" has no getter.`);
|
5037 | }
|
5038 | const set = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : () => {
|
5039 | warn$1(
|
5040 | `Write operation failed: computed property "${key}" is readonly.`
|
5041 | );
|
5042 | } ;
|
5043 | const c = computed({
|
5044 | get,
|
5045 | set
|
5046 | });
|
5047 | Object.defineProperty(ctx, key, {
|
5048 | enumerable: true,
|
5049 | configurable: true,
|
5050 | get: () => c.value,
|
5051 | set: (v) => c.value = v
|
5052 | });
|
5053 | {
|
5054 | checkDuplicateProperties("Computed" , key);
|
5055 | }
|
5056 | }
|
5057 | }
|
5058 | if (watchOptions) {
|
5059 | for (const key in watchOptions) {
|
5060 | createWatcher(watchOptions[key], ctx, publicThis, key);
|
5061 | }
|
5062 | }
|
5063 | if (provideOptions) {
|
5064 | const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
|
5065 | Reflect.ownKeys(provides).forEach((key) => {
|
5066 | provide(key, provides[key]);
|
5067 | });
|
5068 | }
|
5069 | if (created) {
|
5070 | callHook$1(created, instance, "c");
|
5071 | }
|
5072 | function registerLifecycleHook(register, hook) {
|
5073 | if (isArray(hook)) {
|
5074 | hook.forEach((_hook) => register(_hook.bind(publicThis)));
|
5075 | } else if (hook) {
|
5076 | register(hook.bind(publicThis));
|
5077 | }
|
5078 | }
|
5079 | registerLifecycleHook(onBeforeMount, beforeMount);
|
5080 | registerLifecycleHook(onMounted, mounted);
|
5081 | registerLifecycleHook(onBeforeUpdate, beforeUpdate);
|
5082 | registerLifecycleHook(onUpdated, updated);
|
5083 | registerLifecycleHook(onActivated, activated);
|
5084 | registerLifecycleHook(onDeactivated, deactivated);
|
5085 | registerLifecycleHook(onErrorCaptured, errorCaptured);
|
5086 | registerLifecycleHook(onRenderTracked, renderTracked);
|
5087 | registerLifecycleHook(onRenderTriggered, renderTriggered);
|
5088 | registerLifecycleHook(onBeforeUnmount, beforeUnmount);
|
5089 | registerLifecycleHook(onUnmounted, unmounted);
|
5090 | registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
5091 | if (isArray(expose)) {
|
5092 | if (expose.length) {
|
5093 | const exposed = instance.exposed || (instance.exposed = {});
|
5094 | expose.forEach((key) => {
|
5095 | Object.defineProperty(exposed, key, {
|
5096 | get: () => publicThis[key],
|
5097 | set: (val) => publicThis[key] = val
|
5098 | });
|
5099 | });
|
5100 | } else if (!instance.exposed) {
|
5101 | instance.exposed = {};
|
5102 | }
|
5103 | }
|
5104 | if (render && instance.render === NOOP) {
|
5105 | instance.render = render;
|
5106 | }
|
5107 | if (inheritAttrs != null) {
|
5108 | instance.inheritAttrs = inheritAttrs;
|
5109 | }
|
5110 | if (components)
|
5111 | instance.components = components;
|
5112 | if (directives)
|
5113 | instance.directives = directives;
|
5114 | }
|
5115 | function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
|
5116 | if (isArray(injectOptions)) {
|
5117 | injectOptions = normalizeInject(injectOptions);
|
5118 | }
|
5119 | for (const key in injectOptions) {
|
5120 | const opt = injectOptions[key];
|
5121 | let injected;
|
5122 | if (isObject(opt)) {
|
5123 | if ("default" in opt) {
|
5124 | injected = inject(
|
5125 | opt.from || key,
|
5126 | opt.default,
|
5127 | true
|
5128 | );
|
5129 | } else {
|
5130 | injected = inject(opt.from || key);
|
5131 | }
|
5132 | } else {
|
5133 | injected = inject(opt);
|
5134 | }
|
5135 | if (isRef(injected)) {
|
5136 | Object.defineProperty(ctx, key, {
|
5137 | enumerable: true,
|
5138 | configurable: true,
|
5139 | get: () => injected.value,
|
5140 | set: (v) => injected.value = v
|
5141 | });
|
5142 | } else {
|
5143 | ctx[key] = injected;
|
5144 | }
|
5145 | {
|
5146 | checkDuplicateProperties("Inject" , key);
|
5147 | }
|
5148 | }
|
5149 | }
|
5150 | function callHook$1(hook, instance, type) {
|
5151 | callWithAsyncErrorHandling(
|
5152 | isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
|
5153 | instance,
|
5154 | type
|
5155 | );
|
5156 | }
|
5157 | function createWatcher(raw, ctx, publicThis, key) {
|
5158 | const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
|
5159 | if (isString(raw)) {
|
5160 | const handler = ctx[raw];
|
5161 | if (isFunction(handler)) {
|
5162 | watch(getter, handler);
|
5163 | } else {
|
5164 | warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
|
5165 | }
|
5166 | } else if (isFunction(raw)) {
|
5167 | watch(getter, raw.bind(publicThis));
|
5168 | } else if (isObject(raw)) {
|
5169 | if (isArray(raw)) {
|
5170 | raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
|
5171 | } else {
|
5172 | const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
|
5173 | if (isFunction(handler)) {
|
5174 | watch(getter, handler, raw);
|
5175 | } else {
|
5176 | warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
|
5177 | }
|
5178 | }
|
5179 | } else {
|
5180 | warn$1(`Invalid watch option: "${key}"`, raw);
|
5181 | }
|
5182 | }
|
5183 | function resolveMergedOptions(instance) {
|
5184 | const base = instance.type;
|
5185 | const { mixins, extends: extendsOptions } = base;
|
5186 | const {
|
5187 | mixins: globalMixins,
|
5188 | optionsCache: cache,
|
5189 | config: { optionMergeStrategies }
|
5190 | } = instance.appContext;
|
5191 | const cached = cache.get(base);
|
5192 | let resolved;
|
5193 | if (cached) {
|
5194 | resolved = cached;
|
5195 | } else if (!globalMixins.length && !mixins && !extendsOptions) {
|
5196 | {
|
5197 | resolved = base;
|
5198 | }
|
5199 | } else {
|
5200 | resolved = {};
|
5201 | if (globalMixins.length) {
|
5202 | globalMixins.forEach(
|
5203 | (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
|
5204 | );
|
5205 | }
|
5206 | mergeOptions(resolved, base, optionMergeStrategies);
|
5207 | }
|
5208 | if (isObject(base)) {
|
5209 | cache.set(base, resolved);
|
5210 | }
|
5211 | return resolved;
|
5212 | }
|
5213 | function mergeOptions(to, from, strats, asMixin = false) {
|
5214 | const { mixins, extends: extendsOptions } = from;
|
5215 | if (extendsOptions) {
|
5216 | mergeOptions(to, extendsOptions, strats, true);
|
5217 | }
|
5218 | if (mixins) {
|
5219 | mixins.forEach(
|
5220 | (m) => mergeOptions(to, m, strats, true)
|
5221 | );
|
5222 | }
|
5223 | for (const key in from) {
|
5224 | if (asMixin && key === "expose") {
|
5225 | warn$1(
|
5226 | `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
|
5227 | );
|
5228 | } else {
|
5229 | const strat = internalOptionMergeStrats[key] || strats && strats[key];
|
5230 | to[key] = strat ? strat(to[key], from[key]) : from[key];
|
5231 | }
|
5232 | }
|
5233 | return to;
|
5234 | }
|
5235 | const internalOptionMergeStrats = {
|
5236 | data: mergeDataFn,
|
5237 | props: mergeEmitsOrPropsOptions,
|
5238 | emits: mergeEmitsOrPropsOptions,
|
5239 |
|
5240 | methods: mergeObjectOptions,
|
5241 | computed: mergeObjectOptions,
|
5242 |
|
5243 | beforeCreate: mergeAsArray$1,
|
5244 | created: mergeAsArray$1,
|
5245 | beforeMount: mergeAsArray$1,
|
5246 | mounted: mergeAsArray$1,
|
5247 | beforeUpdate: mergeAsArray$1,
|
5248 | updated: mergeAsArray$1,
|
5249 | beforeDestroy: mergeAsArray$1,
|
5250 | beforeUnmount: mergeAsArray$1,
|
5251 | destroyed: mergeAsArray$1,
|
5252 | unmounted: mergeAsArray$1,
|
5253 | activated: mergeAsArray$1,
|
5254 | deactivated: mergeAsArray$1,
|
5255 | errorCaptured: mergeAsArray$1,
|
5256 | serverPrefetch: mergeAsArray$1,
|
5257 |
|
5258 | components: mergeObjectOptions,
|
5259 | directives: mergeObjectOptions,
|
5260 |
|
5261 | watch: mergeWatchOptions,
|
5262 |
|
5263 | provide: mergeDataFn,
|
5264 | inject: mergeInject
|
5265 | };
|
5266 | function mergeDataFn(to, from) {
|
5267 | if (!from) {
|
5268 | return to;
|
5269 | }
|
5270 | if (!to) {
|
5271 | return from;
|
5272 | }
|
5273 | return function mergedDataFn() {
|
5274 | return (extend)(
|
5275 | isFunction(to) ? to.call(this, this) : to,
|
5276 | isFunction(from) ? from.call(this, this) : from
|
5277 | );
|
5278 | };
|
5279 | }
|
5280 | function mergeInject(to, from) {
|
5281 | return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
5282 | }
|
5283 | function normalizeInject(raw) {
|
5284 | if (isArray(raw)) {
|
5285 | const res = {};
|
5286 | for (let i = 0; i < raw.length; i++) {
|
5287 | res[raw[i]] = raw[i];
|
5288 | }
|
5289 | return res;
|
5290 | }
|
5291 | return raw;
|
5292 | }
|
5293 | function mergeAsArray$1(to, from) {
|
5294 | return to ? [...new Set([].concat(to, from))] : from;
|
5295 | }
|
5296 | function mergeObjectOptions(to, from) {
|
5297 | return to ? extend( Object.create(null), to, from) : from;
|
5298 | }
|
5299 | function mergeEmitsOrPropsOptions(to, from) {
|
5300 | if (to) {
|
5301 | if (isArray(to) && isArray(from)) {
|
5302 | return [... new Set([...to, ...from])];
|
5303 | }
|
5304 | return extend(
|
5305 | Object.create(null),
|
5306 | normalizePropsOrEmits(to),
|
5307 | normalizePropsOrEmits(from != null ? from : {})
|
5308 | );
|
5309 | } else {
|
5310 | return from;
|
5311 | }
|
5312 | }
|
5313 | function mergeWatchOptions(to, from) {
|
5314 | if (!to)
|
5315 | return from;
|
5316 | if (!from)
|
5317 | return to;
|
5318 | const merged = extend( Object.create(null), to);
|
5319 | for (const key in from) {
|
5320 | merged[key] = mergeAsArray$1(to[key], from[key]);
|
5321 | }
|
5322 | return merged;
|
5323 | }
|
5324 |
|
5325 | function createAppContext() {
|
5326 | return {
|
5327 | app: null,
|
5328 | config: {
|
5329 | isNativeTag: NO,
|
5330 | performance: false,
|
5331 | globalProperties: {},
|
5332 | optionMergeStrategies: {},
|
5333 | errorHandler: void 0,
|
5334 | warnHandler: void 0,
|
5335 | compilerOptions: {}
|
5336 | },
|
5337 | mixins: [],
|
5338 | components: {},
|
5339 | directives: {},
|
5340 | provides: Object.create(null),
|
5341 | optionsCache: new WeakMap(),
|
5342 | propsCache: new WeakMap(),
|
5343 | emitsCache: new WeakMap()
|
5344 | };
|
5345 | }
|
5346 | let uid$1 = 0;
|
5347 | function createAppAPI(render, hydrate) {
|
5348 | return function createApp(rootComponent, rootProps = null) {
|
5349 | if (!isFunction(rootComponent)) {
|
5350 | rootComponent = extend({}, rootComponent);
|
5351 | }
|
5352 | if (rootProps != null && !isObject(rootProps)) {
|
5353 | warn$1(`root props passed to app.mount() must be an object.`);
|
5354 | rootProps = null;
|
5355 | }
|
5356 | const context = createAppContext();
|
5357 | const installedPlugins = new WeakSet();
|
5358 | let isMounted = false;
|
5359 | const app = context.app = {
|
5360 | _uid: uid$1++,
|
5361 | _component: rootComponent,
|
5362 | _props: rootProps,
|
5363 | _container: null,
|
5364 | _context: context,
|
5365 | _instance: null,
|
5366 | version,
|
5367 | get config() {
|
5368 | return context.config;
|
5369 | },
|
5370 | set config(v) {
|
5371 | {
|
5372 | warn$1(
|
5373 | `app.config cannot be replaced. Modify individual options instead.`
|
5374 | );
|
5375 | }
|
5376 | },
|
5377 | use(plugin, ...options) {
|
5378 | if (installedPlugins.has(plugin)) {
|
5379 | warn$1(`Plugin has already been applied to target app.`);
|
5380 | } else if (plugin && isFunction(plugin.install)) {
|
5381 | installedPlugins.add(plugin);
|
5382 | plugin.install(app, ...options);
|
5383 | } else if (isFunction(plugin)) {
|
5384 | installedPlugins.add(plugin);
|
5385 | plugin(app, ...options);
|
5386 | } else {
|
5387 | warn$1(
|
5388 | `A plugin must either be a function or an object with an "install" function.`
|
5389 | );
|
5390 | }
|
5391 | return app;
|
5392 | },
|
5393 | mixin(mixin) {
|
5394 | {
|
5395 | if (!context.mixins.includes(mixin)) {
|
5396 | context.mixins.push(mixin);
|
5397 | } else {
|
5398 | warn$1(
|
5399 | "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
|
5400 | );
|
5401 | }
|
5402 | }
|
5403 | return app;
|
5404 | },
|
5405 | component(name, component) {
|
5406 | {
|
5407 | validateComponentName(name, context.config);
|
5408 | }
|
5409 | if (!component) {
|
5410 | return context.components[name];
|
5411 | }
|
5412 | if (context.components[name]) {
|
5413 | warn$1(`Component "${name}" has already been registered in target app.`);
|
5414 | }
|
5415 | context.components[name] = component;
|
5416 | return app;
|
5417 | },
|
5418 | directive(name, directive) {
|
5419 | {
|
5420 | validateDirectiveName(name);
|
5421 | }
|
5422 | if (!directive) {
|
5423 | return context.directives[name];
|
5424 | }
|
5425 | if (context.directives[name]) {
|
5426 | warn$1(`Directive "${name}" has already been registered in target app.`);
|
5427 | }
|
5428 | context.directives[name] = directive;
|
5429 | return app;
|
5430 | },
|
5431 | mount(rootContainer, isHydrate, namespace) {
|
5432 | if (!isMounted) {
|
5433 | if (rootContainer.__vue_app__) {
|
5434 | warn$1(
|
5435 | `There is already an app instance mounted on the host container.
|
5436 | If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
|
5437 | );
|
5438 | }
|
5439 | const vnode = createVNode(rootComponent, rootProps);
|
5440 | vnode.appContext = context;
|
5441 | if (namespace === true) {
|
5442 | namespace = "svg";
|
5443 | } else if (namespace === false) {
|
5444 | namespace = void 0;
|
5445 | }
|
5446 | {
|
5447 | context.reload = () => {
|
5448 | render(
|
5449 | cloneVNode(vnode),
|
5450 | rootContainer,
|
5451 | namespace
|
5452 | );
|
5453 | };
|
5454 | }
|
5455 | if (isHydrate && hydrate) {
|
5456 | hydrate(vnode, rootContainer);
|
5457 | } else {
|
5458 | render(vnode, rootContainer, namespace);
|
5459 | }
|
5460 | isMounted = true;
|
5461 | app._container = rootContainer;
|
5462 | rootContainer.__vue_app__ = app;
|
5463 | {
|
5464 | app._instance = vnode.component;
|
5465 | devtoolsInitApp(app, version);
|
5466 | }
|
5467 | return getExposeProxy(vnode.component) || vnode.component.proxy;
|
5468 | } else {
|
5469 | warn$1(
|
5470 | `App has already been mounted.
|
5471 | 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)\``
|
5472 | );
|
5473 | }
|
5474 | },
|
5475 | unmount() {
|
5476 | if (isMounted) {
|
5477 | render(null, app._container);
|
5478 | {
|
5479 | app._instance = null;
|
5480 | devtoolsUnmountApp(app);
|
5481 | }
|
5482 | delete app._container.__vue_app__;
|
5483 | } else {
|
5484 | warn$1(`Cannot unmount an app that is not mounted.`);
|
5485 | }
|
5486 | },
|
5487 | provide(key, value) {
|
5488 | if (key in context.provides) {
|
5489 | warn$1(
|
5490 | `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
|
5491 | );
|
5492 | }
|
5493 | context.provides[key] = value;
|
5494 | return app;
|
5495 | },
|
5496 | runWithContext(fn) {
|
5497 | const lastApp = currentApp;
|
5498 | currentApp = app;
|
5499 | try {
|
5500 | return fn();
|
5501 | } finally {
|
5502 | currentApp = lastApp;
|
5503 | }
|
5504 | }
|
5505 | };
|
5506 | return app;
|
5507 | };
|
5508 | }
|
5509 | let currentApp = null;
|
5510 |
|
5511 | function provide(key, value) {
|
5512 | if (!currentInstance) {
|
5513 | {
|
5514 | warn$1(`provide() can only be used inside setup().`);
|
5515 | }
|
5516 | } else {
|
5517 | let provides = currentInstance.provides;
|
5518 | const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
5519 | if (parentProvides === provides) {
|
5520 | provides = currentInstance.provides = Object.create(parentProvides);
|
5521 | }
|
5522 | provides[key] = value;
|
5523 | }
|
5524 | }
|
5525 | function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
5526 | const instance = currentInstance || currentRenderingInstance;
|
5527 | if (instance || currentApp) {
|
5528 | const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
|
5529 | if (provides && key in provides) {
|
5530 | return provides[key];
|
5531 | } else if (arguments.length > 1) {
|
5532 | return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
|
5533 | } else {
|
5534 | warn$1(`injection "${String(key)}" not found.`);
|
5535 | }
|
5536 | } else {
|
5537 | warn$1(`inject() can only be used inside setup() or functional components.`);
|
5538 | }
|
5539 | }
|
5540 | function hasInjectionContext() {
|
5541 | return !!(currentInstance || currentRenderingInstance || currentApp);
|
5542 | }
|
5543 |
|
5544 | function initProps(instance, rawProps, isStateful, isSSR = false) {
|
5545 | const props = {};
|
5546 | const attrs = {};
|
5547 | def(attrs, InternalObjectKey, 1);
|
5548 | instance.propsDefaults = Object.create(null);
|
5549 | setFullProps(instance, rawProps, props, attrs);
|
5550 | for (const key in instance.propsOptions[0]) {
|
5551 | if (!(key in props)) {
|
5552 | props[key] = void 0;
|
5553 | }
|
5554 | }
|
5555 | {
|
5556 | validateProps(rawProps || {}, props, instance);
|
5557 | }
|
5558 | if (isStateful) {
|
5559 | instance.props = isSSR ? props : shallowReactive(props);
|
5560 | } else {
|
5561 | if (!instance.type.props) {
|
5562 | instance.props = attrs;
|
5563 | } else {
|
5564 | instance.props = props;
|
5565 | }
|
5566 | }
|
5567 | instance.attrs = attrs;
|
5568 | }
|
5569 | function isInHmrContext(instance) {
|
5570 | while (instance) {
|
5571 | if (instance.type.__hmrId)
|
5572 | return true;
|
5573 | instance = instance.parent;
|
5574 | }
|
5575 | }
|
5576 | function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
5577 | const {
|
5578 | props,
|
5579 | attrs,
|
5580 | vnode: { patchFlag }
|
5581 | } = instance;
|
5582 | const rawCurrentProps = toRaw(props);
|
5583 | const [options] = instance.propsOptions;
|
5584 | let hasAttrsChanged = false;
|
5585 | if (
|
5586 |
|
5587 |
|
5588 |
|
5589 | !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
|
5590 | ) {
|
5591 | if (patchFlag & 8) {
|
5592 | const propsToUpdate = instance.vnode.dynamicProps;
|
5593 | for (let i = 0; i < propsToUpdate.length; i++) {
|
5594 | let key = propsToUpdate[i];
|
5595 | if (isEmitListener(instance.emitsOptions, key)) {
|
5596 | continue;
|
5597 | }
|
5598 | const value = rawProps[key];
|
5599 | if (options) {
|
5600 | if (hasOwn(attrs, key)) {
|
5601 | if (value !== attrs[key]) {
|
5602 | attrs[key] = value;
|
5603 | hasAttrsChanged = true;
|
5604 | }
|
5605 | } else {
|
5606 | const camelizedKey = camelize(key);
|
5607 | props[camelizedKey] = resolvePropValue(
|
5608 | options,
|
5609 | rawCurrentProps,
|
5610 | camelizedKey,
|
5611 | value,
|
5612 | instance,
|
5613 | false
|
5614 | );
|
5615 | }
|
5616 | } else {
|
5617 | if (value !== attrs[key]) {
|
5618 | attrs[key] = value;
|
5619 | hasAttrsChanged = true;
|
5620 | }
|
5621 | }
|
5622 | }
|
5623 | }
|
5624 | } else {
|
5625 | if (setFullProps(instance, rawProps, props, attrs)) {
|
5626 | hasAttrsChanged = true;
|
5627 | }
|
5628 | let kebabKey;
|
5629 | for (const key in rawCurrentProps) {
|
5630 | if (!rawProps ||
|
5631 | !hasOwn(rawProps, key) &&
|
5632 |
|
5633 | ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
|
5634 | if (options) {
|
5635 | if (rawPrevProps &&
|
5636 | (rawPrevProps[key] !== void 0 ||
|
5637 | rawPrevProps[kebabKey] !== void 0)) {
|
5638 | props[key] = resolvePropValue(
|
5639 | options,
|
5640 | rawCurrentProps,
|
5641 | key,
|
5642 | void 0,
|
5643 | instance,
|
5644 | true
|
5645 | );
|
5646 | }
|
5647 | } else {
|
5648 | delete props[key];
|
5649 | }
|
5650 | }
|
5651 | }
|
5652 | if (attrs !== rawCurrentProps) {
|
5653 | for (const key in attrs) {
|
5654 | if (!rawProps || !hasOwn(rawProps, key) && true) {
|
5655 | delete attrs[key];
|
5656 | hasAttrsChanged = true;
|
5657 | }
|
5658 | }
|
5659 | }
|
5660 | }
|
5661 | if (hasAttrsChanged) {
|
5662 | trigger(instance, "set", "$attrs");
|
5663 | }
|
5664 | {
|
5665 | validateProps(rawProps || {}, props, instance);
|
5666 | }
|
5667 | }
|
5668 | function setFullProps(instance, rawProps, props, attrs) {
|
5669 | const [options, needCastKeys] = instance.propsOptions;
|
5670 | let hasAttrsChanged = false;
|
5671 | let rawCastValues;
|
5672 | if (rawProps) {
|
5673 | for (let key in rawProps) {
|
5674 | if (isReservedProp(key)) {
|
5675 | continue;
|
5676 | }
|
5677 | const value = rawProps[key];
|
5678 | let camelKey;
|
5679 | if (options && hasOwn(options, camelKey = camelize(key))) {
|
5680 | if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
5681 | props[camelKey] = value;
|
5682 | } else {
|
5683 | (rawCastValues || (rawCastValues = {}))[camelKey] = value;
|
5684 | }
|
5685 | } else if (!isEmitListener(instance.emitsOptions, key)) {
|
5686 | if (!(key in attrs) || value !== attrs[key]) {
|
5687 | attrs[key] = value;
|
5688 | hasAttrsChanged = true;
|
5689 | }
|
5690 | }
|
5691 | }
|
5692 | }
|
5693 | if (needCastKeys) {
|
5694 | const rawCurrentProps = toRaw(props);
|
5695 | const castValues = rawCastValues || EMPTY_OBJ;
|
5696 | for (let i = 0; i < needCastKeys.length; i++) {
|
5697 | const key = needCastKeys[i];
|
5698 | props[key] = resolvePropValue(
|
5699 | options,
|
5700 | rawCurrentProps,
|
5701 | key,
|
5702 | castValues[key],
|
5703 | instance,
|
5704 | !hasOwn(castValues, key)
|
5705 | );
|
5706 | }
|
5707 | }
|
5708 | return hasAttrsChanged;
|
5709 | }
|
5710 | function resolvePropValue(options, props, key, value, instance, isAbsent) {
|
5711 | const opt = options[key];
|
5712 | if (opt != null) {
|
5713 | const hasDefault = hasOwn(opt, "default");
|
5714 | if (hasDefault && value === void 0) {
|
5715 | const defaultValue = opt.default;
|
5716 | if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
|
5717 | const { propsDefaults } = instance;
|
5718 | if (key in propsDefaults) {
|
5719 | value = propsDefaults[key];
|
5720 | } else {
|
5721 | const reset = setCurrentInstance(instance);
|
5722 | value = propsDefaults[key] = defaultValue.call(
|
5723 | null,
|
5724 | props
|
5725 | );
|
5726 | reset();
|
5727 | }
|
5728 | } else {
|
5729 | value = defaultValue;
|
5730 | }
|
5731 | }
|
5732 | if (opt[0 ]) {
|
5733 | if (isAbsent && !hasDefault) {
|
5734 | value = false;
|
5735 | } else if (opt[1 ] && (value === "" || value === hyphenate(key))) {
|
5736 | value = true;
|
5737 | }
|
5738 | }
|
5739 | }
|
5740 | return value;
|
5741 | }
|
5742 | function normalizePropsOptions(comp, appContext, asMixin = false) {
|
5743 | const cache = appContext.propsCache;
|
5744 | const cached = cache.get(comp);
|
5745 | if (cached) {
|
5746 | return cached;
|
5747 | }
|
5748 | const raw = comp.props;
|
5749 | const normalized = {};
|
5750 | const needCastKeys = [];
|
5751 | let hasExtends = false;
|
5752 | if (!isFunction(comp)) {
|
5753 | const extendProps = (raw2) => {
|
5754 | hasExtends = true;
|
5755 | const [props, keys] = normalizePropsOptions(raw2, appContext, true);
|
5756 | extend(normalized, props);
|
5757 | if (keys)
|
5758 | needCastKeys.push(...keys);
|
5759 | };
|
5760 | if (!asMixin && appContext.mixins.length) {
|
5761 | appContext.mixins.forEach(extendProps);
|
5762 | }
|
5763 | if (comp.extends) {
|
5764 | extendProps(comp.extends);
|
5765 | }
|
5766 | if (comp.mixins) {
|
5767 | comp.mixins.forEach(extendProps);
|
5768 | }
|
5769 | }
|
5770 | if (!raw && !hasExtends) {
|
5771 | if (isObject(comp)) {
|
5772 | cache.set(comp, EMPTY_ARR);
|
5773 | }
|
5774 | return EMPTY_ARR;
|
5775 | }
|
5776 | if (isArray(raw)) {
|
5777 | for (let i = 0; i < raw.length; i++) {
|
5778 | if (!isString(raw[i])) {
|
5779 | warn$1(`props must be strings when using array syntax.`, raw[i]);
|
5780 | }
|
5781 | const normalizedKey = camelize(raw[i]);
|
5782 | if (validatePropName(normalizedKey)) {
|
5783 | normalized[normalizedKey] = EMPTY_OBJ;
|
5784 | }
|
5785 | }
|
5786 | } else if (raw) {
|
5787 | if (!isObject(raw)) {
|
5788 | warn$1(`invalid props options`, raw);
|
5789 | }
|
5790 | for (const key in raw) {
|
5791 | const normalizedKey = camelize(key);
|
5792 | if (validatePropName(normalizedKey)) {
|
5793 | const opt = raw[key];
|
5794 | const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
|
5795 | if (prop) {
|
5796 | const booleanIndex = getTypeIndex(Boolean, prop.type);
|
5797 | const stringIndex = getTypeIndex(String, prop.type);
|
5798 | prop[0 ] = booleanIndex > -1;
|
5799 | prop[1 ] = stringIndex < 0 || booleanIndex < stringIndex;
|
5800 | if (booleanIndex > -1 || hasOwn(prop, "default")) {
|
5801 | needCastKeys.push(normalizedKey);
|
5802 | }
|
5803 | }
|
5804 | }
|
5805 | }
|
5806 | }
|
5807 | const res = [normalized, needCastKeys];
|
5808 | if (isObject(comp)) {
|
5809 | cache.set(comp, res);
|
5810 | }
|
5811 | return res;
|
5812 | }
|
5813 | function validatePropName(key) {
|
5814 | if (key[0] !== "$" && !isReservedProp(key)) {
|
5815 | return true;
|
5816 | } else {
|
5817 | warn$1(`Invalid prop name: "${key}" is a reserved property.`);
|
5818 | }
|
5819 | return false;
|
5820 | }
|
5821 | function getType(ctor) {
|
5822 | if (ctor === null) {
|
5823 | return "null";
|
5824 | }
|
5825 | if (typeof ctor === "function") {
|
5826 | return ctor.name || "";
|
5827 | } else if (typeof ctor === "object") {
|
5828 | const name = ctor.constructor && ctor.constructor.name;
|
5829 | return name || "";
|
5830 | }
|
5831 | return "";
|
5832 | }
|
5833 | function isSameType(a, b) {
|
5834 | return getType(a) === getType(b);
|
5835 | }
|
5836 | function getTypeIndex(type, expectedTypes) {
|
5837 | if (isArray(expectedTypes)) {
|
5838 | return expectedTypes.findIndex((t) => isSameType(t, type));
|
5839 | } else if (isFunction(expectedTypes)) {
|
5840 | return isSameType(expectedTypes, type) ? 0 : -1;
|
5841 | }
|
5842 | return -1;
|
5843 | }
|
5844 | function validateProps(rawProps, props, instance) {
|
5845 | const resolvedValues = toRaw(props);
|
5846 | const options = instance.propsOptions[0];
|
5847 | for (const key in options) {
|
5848 | let opt = options[key];
|
5849 | if (opt == null)
|
5850 | continue;
|
5851 | validateProp(
|
5852 | key,
|
5853 | resolvedValues[key],
|
5854 | opt,
|
5855 | shallowReadonly(resolvedValues) ,
|
5856 | !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
|
5857 | );
|
5858 | }
|
5859 | }
|
5860 | function validateProp(name, value, prop, props, isAbsent) {
|
5861 | const { type, required, validator, skipCheck } = prop;
|
5862 | if (required && isAbsent) {
|
5863 | warn$1('Missing required prop: "' + name + '"');
|
5864 | return;
|
5865 | }
|
5866 | if (value == null && !required) {
|
5867 | return;
|
5868 | }
|
5869 | if (type != null && type !== true && !skipCheck) {
|
5870 | let isValid = false;
|
5871 | const types = isArray(type) ? type : [type];
|
5872 | const expectedTypes = [];
|
5873 | for (let i = 0; i < types.length && !isValid; i++) {
|
5874 | const { valid, expectedType } = assertType(value, types[i]);
|
5875 | expectedTypes.push(expectedType || "");
|
5876 | isValid = valid;
|
5877 | }
|
5878 | if (!isValid) {
|
5879 | warn$1(getInvalidTypeMessage(name, value, expectedTypes));
|
5880 | return;
|
5881 | }
|
5882 | }
|
5883 | if (validator && !validator(value, props)) {
|
5884 | warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
|
5885 | }
|
5886 | }
|
5887 | const isSimpleType = makeMap(
|
5888 | "String,Number,Boolean,Function,Symbol,BigInt"
|
5889 | );
|
5890 | function assertType(value, type) {
|
5891 | let valid;
|
5892 | const expectedType = getType(type);
|
5893 | if (isSimpleType(expectedType)) {
|
5894 | const t = typeof value;
|
5895 | valid = t === expectedType.toLowerCase();
|
5896 | if (!valid && t === "object") {
|
5897 | valid = value instanceof type;
|
5898 | }
|
5899 | } else if (expectedType === "Object") {
|
5900 | valid = isObject(value);
|
5901 | } else if (expectedType === "Array") {
|
5902 | valid = isArray(value);
|
5903 | } else if (expectedType === "null") {
|
5904 | valid = value === null;
|
5905 | } else {
|
5906 | valid = value instanceof type;
|
5907 | }
|
5908 | return {
|
5909 | valid,
|
5910 | expectedType
|
5911 | };
|
5912 | }
|
5913 | function getInvalidTypeMessage(name, value, expectedTypes) {
|
5914 | if (expectedTypes.length === 0) {
|
5915 | return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
|
5916 | }
|
5917 | let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
|
5918 | const expectedType = expectedTypes[0];
|
5919 | const receivedType = toRawType(value);
|
5920 | const expectedValue = styleValue(value, expectedType);
|
5921 | const receivedValue = styleValue(value, receivedType);
|
5922 | if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
|
5923 | message += ` with value ${expectedValue}`;
|
5924 | }
|
5925 | message += `, got ${receivedType} `;
|
5926 | if (isExplicable(receivedType)) {
|
5927 | message += `with value ${receivedValue}.`;
|
5928 | }
|
5929 | return message;
|
5930 | }
|
5931 | function styleValue(value, type) {
|
5932 | if (type === "String") {
|
5933 | return `"${value}"`;
|
5934 | } else if (type === "Number") {
|
5935 | return `${Number(value)}`;
|
5936 | } else {
|
5937 | return `${value}`;
|
5938 | }
|
5939 | }
|
5940 | function isExplicable(type) {
|
5941 | const explicitTypes = ["string", "number", "boolean"];
|
5942 | return explicitTypes.some((elem) => type.toLowerCase() === elem);
|
5943 | }
|
5944 | function isBoolean(...args) {
|
5945 | return args.some((elem) => elem.toLowerCase() === "boolean");
|
5946 | }
|
5947 |
|
5948 | const isInternalKey = (key) => key[0] === "_" || key === "$stable";
|
5949 | const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
|
5950 | const normalizeSlot = (key, rawSlot, ctx) => {
|
5951 | if (rawSlot._n) {
|
5952 | return rawSlot;
|
5953 | }
|
5954 | const normalized = withCtx((...args) => {
|
5955 | if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
|
5956 | warn$1(
|
5957 | `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.`
|
5958 | );
|
5959 | }
|
5960 | return normalizeSlotValue(rawSlot(...args));
|
5961 | }, ctx);
|
5962 | normalized._c = false;
|
5963 | return normalized;
|
5964 | };
|
5965 | const normalizeObjectSlots = (rawSlots, slots, instance) => {
|
5966 | const ctx = rawSlots._ctx;
|
5967 | for (const key in rawSlots) {
|
5968 | if (isInternalKey(key))
|
5969 | continue;
|
5970 | const value = rawSlots[key];
|
5971 | if (isFunction(value)) {
|
5972 | slots[key] = normalizeSlot(key, value, ctx);
|
5973 | } else if (value != null) {
|
5974 | {
|
5975 | warn$1(
|
5976 | `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
|
5977 | );
|
5978 | }
|
5979 | const normalized = normalizeSlotValue(value);
|
5980 | slots[key] = () => normalized;
|
5981 | }
|
5982 | }
|
5983 | };
|
5984 | const normalizeVNodeSlots = (instance, children) => {
|
5985 | if (!isKeepAlive(instance.vnode) && true) {
|
5986 | warn$1(
|
5987 | `Non-function value encountered for default slot. Prefer function slots for better performance.`
|
5988 | );
|
5989 | }
|
5990 | const normalized = normalizeSlotValue(children);
|
5991 | instance.slots.default = () => normalized;
|
5992 | };
|
5993 | const initSlots = (instance, children) => {
|
5994 | if (instance.vnode.shapeFlag & 32) {
|
5995 | const type = children._;
|
5996 | if (type) {
|
5997 | instance.slots = toRaw(children);
|
5998 | def(children, "_", type);
|
5999 | } else {
|
6000 | normalizeObjectSlots(
|
6001 | children,
|
6002 | instance.slots = {});
|
6003 | }
|
6004 | } else {
|
6005 | instance.slots = {};
|
6006 | if (children) {
|
6007 | normalizeVNodeSlots(instance, children);
|
6008 | }
|
6009 | }
|
6010 | def(instance.slots, InternalObjectKey, 1);
|
6011 | };
|
6012 | const updateSlots = (instance, children, optimized) => {
|
6013 | const { vnode, slots } = instance;
|
6014 | let needDeletionCheck = true;
|
6015 | let deletionComparisonTarget = EMPTY_OBJ;
|
6016 | if (vnode.shapeFlag & 32) {
|
6017 | const type = children._;
|
6018 | if (type) {
|
6019 | if (isHmrUpdating) {
|
6020 | extend(slots, children);
|
6021 | trigger(instance, "set", "$slots");
|
6022 | } else if (optimized && type === 1) {
|
6023 | needDeletionCheck = false;
|
6024 | } else {
|
6025 | extend(slots, children);
|
6026 | if (!optimized && type === 1) {
|
6027 | delete slots._;
|
6028 | }
|
6029 | }
|
6030 | } else {
|
6031 | needDeletionCheck = !children.$stable;
|
6032 | normalizeObjectSlots(children, slots);
|
6033 | }
|
6034 | deletionComparisonTarget = children;
|
6035 | } else if (children) {
|
6036 | normalizeVNodeSlots(instance, children);
|
6037 | deletionComparisonTarget = { default: 1 };
|
6038 | }
|
6039 | if (needDeletionCheck) {
|
6040 | for (const key in slots) {
|
6041 | if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
|
6042 | delete slots[key];
|
6043 | }
|
6044 | }
|
6045 | }
|
6046 | };
|
6047 |
|
6048 | function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
|
6049 | if (isArray(rawRef)) {
|
6050 | rawRef.forEach(
|
6051 | (r, i) => setRef(
|
6052 | r,
|
6053 | oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
|
6054 | parentSuspense,
|
6055 | vnode,
|
6056 | isUnmount
|
6057 | )
|
6058 | );
|
6059 | return;
|
6060 | }
|
6061 | if (isAsyncWrapper(vnode) && !isUnmount) {
|
6062 | return;
|
6063 | }
|
6064 | const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el;
|
6065 | const value = isUnmount ? null : refValue;
|
6066 | const { i: owner, r: ref } = rawRef;
|
6067 | if (!owner) {
|
6068 | warn$1(
|
6069 | `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
|
6070 | );
|
6071 | return;
|
6072 | }
|
6073 | const oldRef = oldRawRef && oldRawRef.r;
|
6074 | const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
|
6075 | const setupState = owner.setupState;
|
6076 | if (oldRef != null && oldRef !== ref) {
|
6077 | if (isString(oldRef)) {
|
6078 | refs[oldRef] = null;
|
6079 | if (hasOwn(setupState, oldRef)) {
|
6080 | setupState[oldRef] = null;
|
6081 | }
|
6082 | } else if (isRef(oldRef)) {
|
6083 | oldRef.value = null;
|
6084 | }
|
6085 | }
|
6086 | if (isFunction(ref)) {
|
6087 | callWithErrorHandling(ref, owner, 12, [value, refs]);
|
6088 | } else {
|
6089 | const _isString = isString(ref);
|
6090 | const _isRef = isRef(ref);
|
6091 | if (_isString || _isRef) {
|
6092 | const doSet = () => {
|
6093 | if (rawRef.f) {
|
6094 | const existing = _isString ? hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
|
6095 | if (isUnmount) {
|
6096 | isArray(existing) && remove(existing, refValue);
|
6097 | } else {
|
6098 | if (!isArray(existing)) {
|
6099 | if (_isString) {
|
6100 | refs[ref] = [refValue];
|
6101 | if (hasOwn(setupState, ref)) {
|
6102 | setupState[ref] = refs[ref];
|
6103 | }
|
6104 | } else {
|
6105 | ref.value = [refValue];
|
6106 | if (rawRef.k)
|
6107 | refs[rawRef.k] = ref.value;
|
6108 | }
|
6109 | } else if (!existing.includes(refValue)) {
|
6110 | existing.push(refValue);
|
6111 | }
|
6112 | }
|
6113 | } else if (_isString) {
|
6114 | refs[ref] = value;
|
6115 | if (hasOwn(setupState, ref)) {
|
6116 | setupState[ref] = value;
|
6117 | }
|
6118 | } else if (_isRef) {
|
6119 | ref.value = value;
|
6120 | if (rawRef.k)
|
6121 | refs[rawRef.k] = value;
|
6122 | } else {
|
6123 | warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
|
6124 | }
|
6125 | };
|
6126 | if (value) {
|
6127 | doSet.id = -1;
|
6128 | queuePostRenderEffect(doSet, parentSuspense);
|
6129 | } else {
|
6130 | doSet();
|
6131 | }
|
6132 | } else {
|
6133 | warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
|
6134 | }
|
6135 | }
|
6136 | }
|
6137 |
|
6138 | let hasMismatch = false;
|
6139 | const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
|
6140 | const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
|
6141 | const getContainerType = (container) => {
|
6142 | if (isSVGContainer(container))
|
6143 | return "svg";
|
6144 | if (isMathMLContainer(container))
|
6145 | return "mathml";
|
6146 | return void 0;
|
6147 | };
|
6148 | const isComment = (node) => node.nodeType === 8 ;
|
6149 | function createHydrationFunctions(rendererInternals) {
|
6150 | const {
|
6151 | mt: mountComponent,
|
6152 | p: patch,
|
6153 | o: {
|
6154 | patchProp,
|
6155 | createText,
|
6156 | nextSibling,
|
6157 | parentNode,
|
6158 | remove,
|
6159 | insert,
|
6160 | createComment
|
6161 | }
|
6162 | } = rendererInternals;
|
6163 | const hydrate = (vnode, container) => {
|
6164 | if (!container.hasChildNodes()) {
|
6165 | warn$1(
|
6166 | `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`
|
6167 | );
|
6168 | patch(null, vnode, container);
|
6169 | flushPostFlushCbs();
|
6170 | container._vnode = vnode;
|
6171 | return;
|
6172 | }
|
6173 | hasMismatch = false;
|
6174 | hydrateNode(container.firstChild, vnode, null, null, null);
|
6175 | flushPostFlushCbs();
|
6176 | container._vnode = vnode;
|
6177 | if (hasMismatch && true) {
|
6178 | console.error(`Hydration completed but contains mismatches.`);
|
6179 | }
|
6180 | };
|
6181 | const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
|
6182 | const isFragmentStart = isComment(node) && node.data === "[";
|
6183 | const onMismatch = () => handleMismatch(
|
6184 | node,
|
6185 | vnode,
|
6186 | parentComponent,
|
6187 | parentSuspense,
|
6188 | slotScopeIds,
|
6189 | isFragmentStart
|
6190 | );
|
6191 | const { type, ref, shapeFlag, patchFlag } = vnode;
|
6192 | let domType = node.nodeType;
|
6193 | vnode.el = node;
|
6194 | {
|
6195 | if (!("__vnode" in node)) {
|
6196 | Object.defineProperty(node, "__vnode", {
|
6197 | value: vnode,
|
6198 | enumerable: false
|
6199 | });
|
6200 | }
|
6201 | if (!("__vueParentComponent" in node)) {
|
6202 | Object.defineProperty(node, "__vueParentComponent", {
|
6203 | value: parentComponent,
|
6204 | enumerable: false
|
6205 | });
|
6206 | }
|
6207 | }
|
6208 | if (patchFlag === -2) {
|
6209 | optimized = false;
|
6210 | vnode.dynamicChildren = null;
|
6211 | }
|
6212 | let nextNode = null;
|
6213 | switch (type) {
|
6214 | case Text:
|
6215 | if (domType !== 3 ) {
|
6216 | if (vnode.children === "") {
|
6217 | insert(vnode.el = createText(""), parentNode(node), node);
|
6218 | nextNode = node;
|
6219 | } else {
|
6220 | nextNode = onMismatch();
|
6221 | }
|
6222 | } else {
|
6223 | if (node.data !== vnode.children) {
|
6224 | hasMismatch = true;
|
6225 | warn$1(
|
6226 | `Hydration text mismatch in`,
|
6227 | node.parentNode,
|
6228 | `
|
6229 | - rendered on server: ${JSON.stringify(
|
6230 | node.data
|
6231 | )}
|
6232 | - expected on client: ${JSON.stringify(vnode.children)}`
|
6233 | );
|
6234 | node.data = vnode.children;
|
6235 | }
|
6236 | nextNode = nextSibling(node);
|
6237 | }
|
6238 | break;
|
6239 | case Comment:
|
6240 | if (isTemplateNode(node)) {
|
6241 | nextNode = nextSibling(node);
|
6242 | replaceNode(
|
6243 | vnode.el = node.content.firstChild,
|
6244 | node,
|
6245 | parentComponent
|
6246 | );
|
6247 | } else if (domType !== 8 || isFragmentStart) {
|
6248 | nextNode = onMismatch();
|
6249 | } else {
|
6250 | nextNode = nextSibling(node);
|
6251 | }
|
6252 | break;
|
6253 | case Static:
|
6254 | if (isFragmentStart) {
|
6255 | node = nextSibling(node);
|
6256 | domType = node.nodeType;
|
6257 | }
|
6258 | if (domType === 1 || domType === 3 ) {
|
6259 | nextNode = node;
|
6260 | const needToAdoptContent = !vnode.children.length;
|
6261 | for (let i = 0; i < vnode.staticCount; i++) {
|
6262 | if (needToAdoptContent)
|
6263 | vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
|
6264 | if (i === vnode.staticCount - 1) {
|
6265 | vnode.anchor = nextNode;
|
6266 | }
|
6267 | nextNode = nextSibling(nextNode);
|
6268 | }
|
6269 | return isFragmentStart ? nextSibling(nextNode) : nextNode;
|
6270 | } else {
|
6271 | onMismatch();
|
6272 | }
|
6273 | break;
|
6274 | case Fragment:
|
6275 | if (!isFragmentStart) {
|
6276 | nextNode = onMismatch();
|
6277 | } else {
|
6278 | nextNode = hydrateFragment(
|
6279 | node,
|
6280 | vnode,
|
6281 | parentComponent,
|
6282 | parentSuspense,
|
6283 | slotScopeIds,
|
6284 | optimized
|
6285 | );
|
6286 | }
|
6287 | break;
|
6288 | default:
|
6289 | if (shapeFlag & 1) {
|
6290 | if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
|
6291 | nextNode = onMismatch();
|
6292 | } else {
|
6293 | nextNode = hydrateElement(
|
6294 | node,
|
6295 | vnode,
|
6296 | parentComponent,
|
6297 | parentSuspense,
|
6298 | slotScopeIds,
|
6299 | optimized
|
6300 | );
|
6301 | }
|
6302 | } else if (shapeFlag & 6) {
|
6303 | vnode.slotScopeIds = slotScopeIds;
|
6304 | const container = parentNode(node);
|
6305 | if (isFragmentStart) {
|
6306 | nextNode = locateClosingAnchor(node);
|
6307 | } else if (isComment(node) && node.data === "teleport start") {
|
6308 | nextNode = locateClosingAnchor(node, node.data, "teleport end");
|
6309 | } else {
|
6310 | nextNode = nextSibling(node);
|
6311 | }
|
6312 | mountComponent(
|
6313 | vnode,
|
6314 | container,
|
6315 | null,
|
6316 | parentComponent,
|
6317 | parentSuspense,
|
6318 | getContainerType(container),
|
6319 | optimized
|
6320 | );
|
6321 | if (isAsyncWrapper(vnode)) {
|
6322 | let subTree;
|
6323 | if (isFragmentStart) {
|
6324 | subTree = createVNode(Fragment);
|
6325 | subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
|
6326 | } else {
|
6327 | subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
|
6328 | }
|
6329 | subTree.el = node;
|
6330 | vnode.component.subTree = subTree;
|
6331 | }
|
6332 | } else if (shapeFlag & 64) {
|
6333 | if (domType !== 8 ) {
|
6334 | nextNode = onMismatch();
|
6335 | } else {
|
6336 | nextNode = vnode.type.hydrate(
|
6337 | node,
|
6338 | vnode,
|
6339 | parentComponent,
|
6340 | parentSuspense,
|
6341 | slotScopeIds,
|
6342 | optimized,
|
6343 | rendererInternals,
|
6344 | hydrateChildren
|
6345 | );
|
6346 | }
|
6347 | } else if (shapeFlag & 128) {
|
6348 | nextNode = vnode.type.hydrate(
|
6349 | node,
|
6350 | vnode,
|
6351 | parentComponent,
|
6352 | parentSuspense,
|
6353 | getContainerType(parentNode(node)),
|
6354 | slotScopeIds,
|
6355 | optimized,
|
6356 | rendererInternals,
|
6357 | hydrateNode
|
6358 | );
|
6359 | } else {
|
6360 | warn$1("Invalid HostVNode type:", type, `(${typeof type})`);
|
6361 | }
|
6362 | }
|
6363 | if (ref != null) {
|
6364 | setRef(ref, null, parentSuspense, vnode);
|
6365 | }
|
6366 | return nextNode;
|
6367 | };
|
6368 | const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
6369 | optimized = optimized || !!vnode.dynamicChildren;
|
6370 | const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
|
6371 | const forcePatch = type === "input" || type === "option";
|
6372 | {
|
6373 | if (dirs) {
|
6374 | invokeDirectiveHook(vnode, null, parentComponent, "created");
|
6375 | }
|
6376 | let needCallTransitionHooks = false;
|
6377 | if (isTemplateNode(el)) {
|
6378 | needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
|
6379 | const content = el.content.firstChild;
|
6380 | if (needCallTransitionHooks) {
|
6381 | transition.beforeEnter(content);
|
6382 | }
|
6383 | replaceNode(content, el, parentComponent);
|
6384 | vnode.el = el = content;
|
6385 | }
|
6386 | if (shapeFlag & 16 &&
|
6387 | !(props && (props.innerHTML || props.textContent))) {
|
6388 | let next = hydrateChildren(
|
6389 | el.firstChild,
|
6390 | vnode,
|
6391 | el,
|
6392 | parentComponent,
|
6393 | parentSuspense,
|
6394 | slotScopeIds,
|
6395 | optimized
|
6396 | );
|
6397 | let hasWarned = false;
|
6398 | while (next) {
|
6399 | hasMismatch = true;
|
6400 | if (!hasWarned) {
|
6401 | warn$1(
|
6402 | `Hydration children mismatch on`,
|
6403 | el,
|
6404 | `
|
6405 | Server rendered element contains more child nodes than client vdom.`
|
6406 | );
|
6407 | hasWarned = true;
|
6408 | }
|
6409 | const cur = next;
|
6410 | next = next.nextSibling;
|
6411 | remove(cur);
|
6412 | }
|
6413 | } else if (shapeFlag & 8) {
|
6414 | if (el.textContent !== vnode.children) {
|
6415 | hasMismatch = true;
|
6416 | warn$1(
|
6417 | `Hydration text content mismatch on`,
|
6418 | el,
|
6419 | `
|
6420 | - rendered on server: ${el.textContent}
|
6421 | - expected on client: ${vnode.children}`
|
6422 | );
|
6423 | el.textContent = vnode.children;
|
6424 | }
|
6425 | }
|
6426 | if (props) {
|
6427 | {
|
6428 | for (const key in props) {
|
6429 | if (propHasMismatch(el, key, props[key], vnode, parentComponent)) {
|
6430 | hasMismatch = true;
|
6431 | }
|
6432 | if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) ||
|
6433 | key[0] === ".") {
|
6434 | patchProp(
|
6435 | el,
|
6436 | key,
|
6437 | null,
|
6438 | props[key],
|
6439 | void 0,
|
6440 | void 0,
|
6441 | parentComponent
|
6442 | );
|
6443 | }
|
6444 | }
|
6445 | }
|
6446 | }
|
6447 | let vnodeHooks;
|
6448 | if (vnodeHooks = props && props.onVnodeBeforeMount) {
|
6449 | invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
6450 | }
|
6451 | if (dirs) {
|
6452 | invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
6453 | }
|
6454 | if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
|
6455 | queueEffectWithSuspense(() => {
|
6456 | vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
6457 | needCallTransitionHooks && transition.enter(el);
|
6458 | dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
6459 | }, parentSuspense);
|
6460 | }
|
6461 | }
|
6462 | return el.nextSibling;
|
6463 | };
|
6464 | const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
6465 | optimized = optimized || !!parentVNode.dynamicChildren;
|
6466 | const children = parentVNode.children;
|
6467 | const l = children.length;
|
6468 | let hasWarned = false;
|
6469 | for (let i = 0; i < l; i++) {
|
6470 | const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
|
6471 | if (node) {
|
6472 | node = hydrateNode(
|
6473 | node,
|
6474 | vnode,
|
6475 | parentComponent,
|
6476 | parentSuspense,
|
6477 | slotScopeIds,
|
6478 | optimized
|
6479 | );
|
6480 | } else if (vnode.type === Text && !vnode.children) {
|
6481 | continue;
|
6482 | } else {
|
6483 | hasMismatch = true;
|
6484 | if (!hasWarned) {
|
6485 | warn$1(
|
6486 | `Hydration children mismatch on`,
|
6487 | container,
|
6488 | `
|
6489 | Server rendered element contains fewer child nodes than client vdom.`
|
6490 | );
|
6491 | hasWarned = true;
|
6492 | }
|
6493 | patch(
|
6494 | null,
|
6495 | vnode,
|
6496 | container,
|
6497 | null,
|
6498 | parentComponent,
|
6499 | parentSuspense,
|
6500 | getContainerType(container),
|
6501 | slotScopeIds
|
6502 | );
|
6503 | }
|
6504 | }
|
6505 | return node;
|
6506 | };
|
6507 | const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
6508 | const { slotScopeIds: fragmentSlotScopeIds } = vnode;
|
6509 | if (fragmentSlotScopeIds) {
|
6510 | slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
6511 | }
|
6512 | const container = parentNode(node);
|
6513 | const next = hydrateChildren(
|
6514 | nextSibling(node),
|
6515 | vnode,
|
6516 | container,
|
6517 | parentComponent,
|
6518 | parentSuspense,
|
6519 | slotScopeIds,
|
6520 | optimized
|
6521 | );
|
6522 | if (next && isComment(next) && next.data === "]") {
|
6523 | return nextSibling(vnode.anchor = next);
|
6524 | } else {
|
6525 | hasMismatch = true;
|
6526 | insert(vnode.anchor = createComment(`]`), container, next);
|
6527 | return next;
|
6528 | }
|
6529 | };
|
6530 | const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
|
6531 | hasMismatch = true;
|
6532 | warn$1(
|
6533 | `Hydration node mismatch:
|
6534 | - rendered on server:`,
|
6535 | node,
|
6536 | node.nodeType === 3 ? `(text)` : isComment(node) && node.data === "[" ? `(start of fragment)` : ``,
|
6537 | `
|
6538 | - expected on client:`,
|
6539 | vnode.type
|
6540 | );
|
6541 | vnode.el = null;
|
6542 | if (isFragment) {
|
6543 | const end = locateClosingAnchor(node);
|
6544 | while (true) {
|
6545 | const next2 = nextSibling(node);
|
6546 | if (next2 && next2 !== end) {
|
6547 | remove(next2);
|
6548 | } else {
|
6549 | break;
|
6550 | }
|
6551 | }
|
6552 | }
|
6553 | const next = nextSibling(node);
|
6554 | const container = parentNode(node);
|
6555 | remove(node);
|
6556 | patch(
|
6557 | null,
|
6558 | vnode,
|
6559 | container,
|
6560 | next,
|
6561 | parentComponent,
|
6562 | parentSuspense,
|
6563 | getContainerType(container),
|
6564 | slotScopeIds
|
6565 | );
|
6566 | return next;
|
6567 | };
|
6568 | const locateClosingAnchor = (node, open = "[", close = "]") => {
|
6569 | let match = 0;
|
6570 | while (node) {
|
6571 | node = nextSibling(node);
|
6572 | if (node && isComment(node)) {
|
6573 | if (node.data === open)
|
6574 | match++;
|
6575 | if (node.data === close) {
|
6576 | if (match === 0) {
|
6577 | return nextSibling(node);
|
6578 | } else {
|
6579 | match--;
|
6580 | }
|
6581 | }
|
6582 | }
|
6583 | }
|
6584 | return node;
|
6585 | };
|
6586 | const replaceNode = (newNode, oldNode, parentComponent) => {
|
6587 | const parentNode2 = oldNode.parentNode;
|
6588 | if (parentNode2) {
|
6589 | parentNode2.replaceChild(newNode, oldNode);
|
6590 | }
|
6591 | let parent = parentComponent;
|
6592 | while (parent) {
|
6593 | if (parent.vnode.el === oldNode) {
|
6594 | parent.vnode.el = parent.subTree.el = newNode;
|
6595 | }
|
6596 | parent = parent.parent;
|
6597 | }
|
6598 | };
|
6599 | const isTemplateNode = (node) => {
|
6600 | return node.nodeType === 1 && node.tagName.toLowerCase() === "template";
|
6601 | };
|
6602 | return [hydrate, hydrateNode];
|
6603 | }
|
6604 | function propHasMismatch(el, key, clientValue, vnode, instance) {
|
6605 | var _a;
|
6606 | let mismatchType;
|
6607 | let mismatchKey;
|
6608 | let actual;
|
6609 | let expected;
|
6610 | if (key === "class") {
|
6611 | actual = el.getAttribute("class");
|
6612 | expected = normalizeClass(clientValue);
|
6613 | if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) {
|
6614 | mismatchType = mismatchKey = `class`;
|
6615 | }
|
6616 | } else if (key === "style") {
|
6617 | actual = el.getAttribute("style");
|
6618 | expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
|
6619 | const actualMap = toStyleMap(actual);
|
6620 | const expectedMap = toStyleMap(expected);
|
6621 | if (vnode.dirs) {
|
6622 | for (const { dir, value } of vnode.dirs) {
|
6623 | if (dir.name === "show" && !value) {
|
6624 | expectedMap.set("display", "none");
|
6625 | }
|
6626 | }
|
6627 | }
|
6628 | const root = instance == null ? void 0 : instance.subTree;
|
6629 | if (vnode === root || (root == null ? void 0 : root.type) === Fragment && root.children.includes(vnode)) {
|
6630 | const cssVars = (_a = instance == null ? void 0 : instance.getCssVars) == null ? void 0 : _a.call(instance);
|
6631 | for (const key2 in cssVars) {
|
6632 | expectedMap.set(`--${key2}`, String(cssVars[key2]));
|
6633 | }
|
6634 | }
|
6635 | if (!isMapEqual(actualMap, expectedMap)) {
|
6636 | mismatchType = mismatchKey = "style";
|
6637 | }
|
6638 | } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
|
6639 | if (isBooleanAttr(key)) {
|
6640 | actual = el.hasAttribute(key);
|
6641 | expected = includeBooleanAttr(clientValue);
|
6642 | } else if (clientValue == null) {
|
6643 | actual = el.hasAttribute(key);
|
6644 | expected = false;
|
6645 | } else {
|
6646 | if (el.hasAttribute(key)) {
|
6647 | actual = el.getAttribute(key);
|
6648 | } else if (key === "value" && el.tagName === "TEXTAREA") {
|
6649 | actual = el.value;
|
6650 | } else {
|
6651 | actual = false;
|
6652 | }
|
6653 | expected = isRenderableAttrValue(clientValue) ? String(clientValue) : false;
|
6654 | }
|
6655 | if (actual !== expected) {
|
6656 | mismatchType = `attribute`;
|
6657 | mismatchKey = key;
|
6658 | }
|
6659 | }
|
6660 | if (mismatchType) {
|
6661 | const format = (v) => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`;
|
6662 | const preSegment = `Hydration ${mismatchType} mismatch on`;
|
6663 | const postSegment = `
|
6664 | - rendered on server: ${format(actual)}
|
6665 | - expected on client: ${format(expected)}
|
6666 | Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
|
6667 | You should fix the source of the mismatch.`;
|
6668 | {
|
6669 | warn$1(preSegment, el, postSegment);
|
6670 | }
|
6671 | return true;
|
6672 | }
|
6673 | return false;
|
6674 | }
|
6675 | function toClassSet(str) {
|
6676 | return new Set(str.trim().split(/\s+/));
|
6677 | }
|
6678 | function isSetEqual(a, b) {
|
6679 | if (a.size !== b.size) {
|
6680 | return false;
|
6681 | }
|
6682 | for (const s of a) {
|
6683 | if (!b.has(s)) {
|
6684 | return false;
|
6685 | }
|
6686 | }
|
6687 | return true;
|
6688 | }
|
6689 | function toStyleMap(str) {
|
6690 | const styleMap = new Map();
|
6691 | for (const item of str.split(";")) {
|
6692 | let [key, value] = item.split(":");
|
6693 | key = key == null ? void 0 : key.trim();
|
6694 | value = value == null ? void 0 : value.trim();
|
6695 | if (key && value) {
|
6696 | styleMap.set(key, value);
|
6697 | }
|
6698 | }
|
6699 | return styleMap;
|
6700 | }
|
6701 | function isMapEqual(a, b) {
|
6702 | if (a.size !== b.size) {
|
6703 | return false;
|
6704 | }
|
6705 | for (const [key, value] of a) {
|
6706 | if (value !== b.get(key)) {
|
6707 | return false;
|
6708 | }
|
6709 | }
|
6710 | return true;
|
6711 | }
|
6712 |
|
6713 | let supported;
|
6714 | let perf;
|
6715 | function startMeasure(instance, type) {
|
6716 | if (instance.appContext.config.performance && isSupported()) {
|
6717 | perf.mark(`vue-${type}-${instance.uid}`);
|
6718 | }
|
6719 | {
|
6720 | devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
|
6721 | }
|
6722 | }
|
6723 | function endMeasure(instance, type) {
|
6724 | if (instance.appContext.config.performance && isSupported()) {
|
6725 | const startTag = `vue-${type}-${instance.uid}`;
|
6726 | const endTag = startTag + `:end`;
|
6727 | perf.mark(endTag);
|
6728 | perf.measure(
|
6729 | `<${formatComponentName(instance, instance.type)}> ${type}`,
|
6730 | startTag,
|
6731 | endTag
|
6732 | );
|
6733 | perf.clearMarks(startTag);
|
6734 | perf.clearMarks(endTag);
|
6735 | }
|
6736 | {
|
6737 | devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
|
6738 | }
|
6739 | }
|
6740 | function isSupported() {
|
6741 | if (supported !== void 0) {
|
6742 | return supported;
|
6743 | }
|
6744 | if (typeof window !== "undefined" && window.performance) {
|
6745 | supported = true;
|
6746 | perf = window.performance;
|
6747 | } else {
|
6748 | supported = false;
|
6749 | }
|
6750 | return supported;
|
6751 | }
|
6752 |
|
6753 | const queuePostRenderEffect = queueEffectWithSuspense ;
|
6754 | function createRenderer(options) {
|
6755 | return baseCreateRenderer(options);
|
6756 | }
|
6757 | function createHydrationRenderer(options) {
|
6758 | return baseCreateRenderer(options, createHydrationFunctions);
|
6759 | }
|
6760 | function baseCreateRenderer(options, createHydrationFns) {
|
6761 | const target = getGlobalThis();
|
6762 | target.__VUE__ = true;
|
6763 | {
|
6764 | setDevtoolsHook$1(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
|
6765 | }
|
6766 | const {
|
6767 | insert: hostInsert,
|
6768 | remove: hostRemove,
|
6769 | patchProp: hostPatchProp,
|
6770 | createElement: hostCreateElement,
|
6771 | createText: hostCreateText,
|
6772 | createComment: hostCreateComment,
|
6773 | setText: hostSetText,
|
6774 | setElementText: hostSetElementText,
|
6775 | parentNode: hostParentNode,
|
6776 | nextSibling: hostNextSibling,
|
6777 | setScopeId: hostSetScopeId = NOOP,
|
6778 | insertStaticContent: hostInsertStaticContent
|
6779 | } = options;
|
6780 | const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
|
6781 | if (n1 === n2) {
|
6782 | return;
|
6783 | }
|
6784 | if (n1 && !isSameVNodeType(n1, n2)) {
|
6785 | anchor = getNextHostNode(n1);
|
6786 | unmount(n1, parentComponent, parentSuspense, true);
|
6787 | n1 = null;
|
6788 | }
|
6789 | if (n2.patchFlag === -2) {
|
6790 | optimized = false;
|
6791 | n2.dynamicChildren = null;
|
6792 | }
|
6793 | const { type, ref, shapeFlag } = n2;
|
6794 | switch (type) {
|
6795 | case Text:
|
6796 | processText(n1, n2, container, anchor);
|
6797 | break;
|
6798 | case Comment:
|
6799 | processCommentNode(n1, n2, container, anchor);
|
6800 | break;
|
6801 | case Static:
|
6802 | if (n1 == null) {
|
6803 | mountStaticNode(n2, container, anchor, namespace);
|
6804 | } else {
|
6805 | patchStaticNode(n1, n2, container, namespace);
|
6806 | }
|
6807 | break;
|
6808 | case Fragment:
|
6809 | processFragment(
|
6810 | n1,
|
6811 | n2,
|
6812 | container,
|
6813 | anchor,
|
6814 | parentComponent,
|
6815 | parentSuspense,
|
6816 | namespace,
|
6817 | slotScopeIds,
|
6818 | optimized
|
6819 | );
|
6820 | break;
|
6821 | default:
|
6822 | if (shapeFlag & 1) {
|
6823 | processElement(
|
6824 | n1,
|
6825 | n2,
|
6826 | container,
|
6827 | anchor,
|
6828 | parentComponent,
|
6829 | parentSuspense,
|
6830 | namespace,
|
6831 | slotScopeIds,
|
6832 | optimized
|
6833 | );
|
6834 | } else if (shapeFlag & 6) {
|
6835 | processComponent(
|
6836 | n1,
|
6837 | n2,
|
6838 | container,
|
6839 | anchor,
|
6840 | parentComponent,
|
6841 | parentSuspense,
|
6842 | namespace,
|
6843 | slotScopeIds,
|
6844 | optimized
|
6845 | );
|
6846 | } else if (shapeFlag & 64) {
|
6847 | type.process(
|
6848 | n1,
|
6849 | n2,
|
6850 | container,
|
6851 | anchor,
|
6852 | parentComponent,
|
6853 | parentSuspense,
|
6854 | namespace,
|
6855 | slotScopeIds,
|
6856 | optimized,
|
6857 | internals
|
6858 | );
|
6859 | } else if (shapeFlag & 128) {
|
6860 | type.process(
|
6861 | n1,
|
6862 | n2,
|
6863 | container,
|
6864 | anchor,
|
6865 | parentComponent,
|
6866 | parentSuspense,
|
6867 | namespace,
|
6868 | slotScopeIds,
|
6869 | optimized,
|
6870 | internals
|
6871 | );
|
6872 | } else {
|
6873 | warn$1("Invalid VNode type:", type, `(${typeof type})`);
|
6874 | }
|
6875 | }
|
6876 | if (ref != null && parentComponent) {
|
6877 | setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
|
6878 | }
|
6879 | };
|
6880 | const processText = (n1, n2, container, anchor) => {
|
6881 | if (n1 == null) {
|
6882 | hostInsert(
|
6883 | n2.el = hostCreateText(n2.children),
|
6884 | container,
|
6885 | anchor
|
6886 | );
|
6887 | } else {
|
6888 | const el = n2.el = n1.el;
|
6889 | if (n2.children !== n1.children) {
|
6890 | hostSetText(el, n2.children);
|
6891 | }
|
6892 | }
|
6893 | };
|
6894 | const processCommentNode = (n1, n2, container, anchor) => {
|
6895 | if (n1 == null) {
|
6896 | hostInsert(
|
6897 | n2.el = hostCreateComment(n2.children || ""),
|
6898 | container,
|
6899 | anchor
|
6900 | );
|
6901 | } else {
|
6902 | n2.el = n1.el;
|
6903 | }
|
6904 | };
|
6905 | const mountStaticNode = (n2, container, anchor, namespace) => {
|
6906 | [n2.el, n2.anchor] = hostInsertStaticContent(
|
6907 | n2.children,
|
6908 | container,
|
6909 | anchor,
|
6910 | namespace,
|
6911 | n2.el,
|
6912 | n2.anchor
|
6913 | );
|
6914 | };
|
6915 | const patchStaticNode = (n1, n2, container, namespace) => {
|
6916 | if (n2.children !== n1.children) {
|
6917 | const anchor = hostNextSibling(n1.anchor);
|
6918 | removeStaticNode(n1);
|
6919 | [n2.el, n2.anchor] = hostInsertStaticContent(
|
6920 | n2.children,
|
6921 | container,
|
6922 | anchor,
|
6923 | namespace
|
6924 | );
|
6925 | } else {
|
6926 | n2.el = n1.el;
|
6927 | n2.anchor = n1.anchor;
|
6928 | }
|
6929 | };
|
6930 | const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
|
6931 | let next;
|
6932 | while (el && el !== anchor) {
|
6933 | next = hostNextSibling(el);
|
6934 | hostInsert(el, container, nextSibling);
|
6935 | el = next;
|
6936 | }
|
6937 | hostInsert(anchor, container, nextSibling);
|
6938 | };
|
6939 | const removeStaticNode = ({ el, anchor }) => {
|
6940 | let next;
|
6941 | while (el && el !== anchor) {
|
6942 | next = hostNextSibling(el);
|
6943 | hostRemove(el);
|
6944 | el = next;
|
6945 | }
|
6946 | hostRemove(anchor);
|
6947 | };
|
6948 | const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
6949 | if (n2.type === "svg") {
|
6950 | namespace = "svg";
|
6951 | } else if (n2.type === "math") {
|
6952 | namespace = "mathml";
|
6953 | }
|
6954 | if (n1 == null) {
|
6955 | mountElement(
|
6956 | n2,
|
6957 | container,
|
6958 | anchor,
|
6959 | parentComponent,
|
6960 | parentSuspense,
|
6961 | namespace,
|
6962 | slotScopeIds,
|
6963 | optimized
|
6964 | );
|
6965 | } else {
|
6966 | patchElement(
|
6967 | n1,
|
6968 | n2,
|
6969 | parentComponent,
|
6970 | parentSuspense,
|
6971 | namespace,
|
6972 | slotScopeIds,
|
6973 | optimized
|
6974 | );
|
6975 | }
|
6976 | };
|
6977 | const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
6978 | let el;
|
6979 | let vnodeHook;
|
6980 | const { props, shapeFlag, transition, dirs } = vnode;
|
6981 | el = vnode.el = hostCreateElement(
|
6982 | vnode.type,
|
6983 | namespace,
|
6984 | props && props.is,
|
6985 | props
|
6986 | );
|
6987 | if (shapeFlag & 8) {
|
6988 | hostSetElementText(el, vnode.children);
|
6989 | } else if (shapeFlag & 16) {
|
6990 | mountChildren(
|
6991 | vnode.children,
|
6992 | el,
|
6993 | null,
|
6994 | parentComponent,
|
6995 | parentSuspense,
|
6996 | resolveChildrenNamespace(vnode, namespace),
|
6997 | slotScopeIds,
|
6998 | optimized
|
6999 | );
|
7000 | }
|
7001 | if (dirs) {
|
7002 | invokeDirectiveHook(vnode, null, parentComponent, "created");
|
7003 | }
|
7004 | setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
|
7005 | if (props) {
|
7006 | for (const key in props) {
|
7007 | if (key !== "value" && !isReservedProp(key)) {
|
7008 | hostPatchProp(
|
7009 | el,
|
7010 | key,
|
7011 | null,
|
7012 | props[key],
|
7013 | namespace,
|
7014 | vnode.children,
|
7015 | parentComponent,
|
7016 | parentSuspense,
|
7017 | unmountChildren
|
7018 | );
|
7019 | }
|
7020 | }
|
7021 | if ("value" in props) {
|
7022 | hostPatchProp(el, "value", null, props.value, namespace);
|
7023 | }
|
7024 | if (vnodeHook = props.onVnodeBeforeMount) {
|
7025 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
7026 | }
|
7027 | }
|
7028 | {
|
7029 | Object.defineProperty(el, "__vnode", {
|
7030 | value: vnode,
|
7031 | enumerable: false
|
7032 | });
|
7033 | Object.defineProperty(el, "__vueParentComponent", {
|
7034 | value: parentComponent,
|
7035 | enumerable: false
|
7036 | });
|
7037 | }
|
7038 | if (dirs) {
|
7039 | invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
7040 | }
|
7041 | const needCallTransitionHooks = needTransition(parentSuspense, transition);
|
7042 | if (needCallTransitionHooks) {
|
7043 | transition.beforeEnter(el);
|
7044 | }
|
7045 | hostInsert(el, container, anchor);
|
7046 | if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
|
7047 | queuePostRenderEffect(() => {
|
7048 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
7049 | needCallTransitionHooks && transition.enter(el);
|
7050 | dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
7051 | }, parentSuspense);
|
7052 | }
|
7053 | };
|
7054 | const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
|
7055 | if (scopeId) {
|
7056 | hostSetScopeId(el, scopeId);
|
7057 | }
|
7058 | if (slotScopeIds) {
|
7059 | for (let i = 0; i < slotScopeIds.length; i++) {
|
7060 | hostSetScopeId(el, slotScopeIds[i]);
|
7061 | }
|
7062 | }
|
7063 | if (parentComponent) {
|
7064 | let subTree = parentComponent.subTree;
|
7065 | if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
|
7066 | subTree = filterSingleRoot(subTree.children) || subTree;
|
7067 | }
|
7068 | if (vnode === subTree) {
|
7069 | const parentVNode = parentComponent.vnode;
|
7070 | setScopeId(
|
7071 | el,
|
7072 | parentVNode,
|
7073 | parentVNode.scopeId,
|
7074 | parentVNode.slotScopeIds,
|
7075 | parentComponent.parent
|
7076 | );
|
7077 | }
|
7078 | }
|
7079 | };
|
7080 | const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
|
7081 | for (let i = start; i < children.length; i++) {
|
7082 | const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
|
7083 | patch(
|
7084 | null,
|
7085 | child,
|
7086 | container,
|
7087 | anchor,
|
7088 | parentComponent,
|
7089 | parentSuspense,
|
7090 | namespace,
|
7091 | slotScopeIds,
|
7092 | optimized
|
7093 | );
|
7094 | }
|
7095 | };
|
7096 | const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7097 | const el = n2.el = n1.el;
|
7098 | let { patchFlag, dynamicChildren, dirs } = n2;
|
7099 | patchFlag |= n1.patchFlag & 16;
|
7100 | const oldProps = n1.props || EMPTY_OBJ;
|
7101 | const newProps = n2.props || EMPTY_OBJ;
|
7102 | let vnodeHook;
|
7103 | parentComponent && toggleRecurse(parentComponent, false);
|
7104 | if (vnodeHook = newProps.onVnodeBeforeUpdate) {
|
7105 | invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
7106 | }
|
7107 | if (dirs) {
|
7108 | invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
|
7109 | }
|
7110 | parentComponent && toggleRecurse(parentComponent, true);
|
7111 | if (isHmrUpdating) {
|
7112 | patchFlag = 0;
|
7113 | optimized = false;
|
7114 | dynamicChildren = null;
|
7115 | }
|
7116 | if (dynamicChildren) {
|
7117 | patchBlockChildren(
|
7118 | n1.dynamicChildren,
|
7119 | dynamicChildren,
|
7120 | el,
|
7121 | parentComponent,
|
7122 | parentSuspense,
|
7123 | resolveChildrenNamespace(n2, namespace),
|
7124 | slotScopeIds
|
7125 | );
|
7126 | {
|
7127 | traverseStaticChildren(n1, n2);
|
7128 | }
|
7129 | } else if (!optimized) {
|
7130 | patchChildren(
|
7131 | n1,
|
7132 | n2,
|
7133 | el,
|
7134 | null,
|
7135 | parentComponent,
|
7136 | parentSuspense,
|
7137 | resolveChildrenNamespace(n2, namespace),
|
7138 | slotScopeIds,
|
7139 | false
|
7140 | );
|
7141 | }
|
7142 | if (patchFlag > 0) {
|
7143 | if (patchFlag & 16) {
|
7144 | patchProps(
|
7145 | el,
|
7146 | n2,
|
7147 | oldProps,
|
7148 | newProps,
|
7149 | parentComponent,
|
7150 | parentSuspense,
|
7151 | namespace
|
7152 | );
|
7153 | } else {
|
7154 | if (patchFlag & 2) {
|
7155 | if (oldProps.class !== newProps.class) {
|
7156 | hostPatchProp(el, "class", null, newProps.class, namespace);
|
7157 | }
|
7158 | }
|
7159 | if (patchFlag & 4) {
|
7160 | hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
|
7161 | }
|
7162 | if (patchFlag & 8) {
|
7163 | const propsToUpdate = n2.dynamicProps;
|
7164 | for (let i = 0; i < propsToUpdate.length; i++) {
|
7165 | const key = propsToUpdate[i];
|
7166 | const prev = oldProps[key];
|
7167 | const next = newProps[key];
|
7168 | if (next !== prev || key === "value") {
|
7169 | hostPatchProp(
|
7170 | el,
|
7171 | key,
|
7172 | prev,
|
7173 | next,
|
7174 | namespace,
|
7175 | n1.children,
|
7176 | parentComponent,
|
7177 | parentSuspense,
|
7178 | unmountChildren
|
7179 | );
|
7180 | }
|
7181 | }
|
7182 | }
|
7183 | }
|
7184 | if (patchFlag & 1) {
|
7185 | if (n1.children !== n2.children) {
|
7186 | hostSetElementText(el, n2.children);
|
7187 | }
|
7188 | }
|
7189 | } else if (!optimized && dynamicChildren == null) {
|
7190 | patchProps(
|
7191 | el,
|
7192 | n2,
|
7193 | oldProps,
|
7194 | newProps,
|
7195 | parentComponent,
|
7196 | parentSuspense,
|
7197 | namespace
|
7198 | );
|
7199 | }
|
7200 | if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
|
7201 | queuePostRenderEffect(() => {
|
7202 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
7203 | dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
|
7204 | }, parentSuspense);
|
7205 | }
|
7206 | };
|
7207 | const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
|
7208 | for (let i = 0; i < newChildren.length; i++) {
|
7209 | const oldVNode = oldChildren[i];
|
7210 | const newVNode = newChildren[i];
|
7211 | const container = (
|
7212 |
|
7213 |
|
7214 | oldVNode.el &&
|
7215 |
|
7216 | (oldVNode.type === Fragment ||
|
7217 |
|
7218 | !isSameVNodeType(oldVNode, newVNode) ||
|
7219 | oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
|
7220 |
|
7221 |
|
7222 | fallbackContainer
|
7223 | )
|
7224 | );
|
7225 | patch(
|
7226 | oldVNode,
|
7227 | newVNode,
|
7228 | container,
|
7229 | null,
|
7230 | parentComponent,
|
7231 | parentSuspense,
|
7232 | namespace,
|
7233 | slotScopeIds,
|
7234 | true
|
7235 | );
|
7236 | }
|
7237 | };
|
7238 | const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, namespace) => {
|
7239 | if (oldProps !== newProps) {
|
7240 | if (oldProps !== EMPTY_OBJ) {
|
7241 | for (const key in oldProps) {
|
7242 | if (!isReservedProp(key) && !(key in newProps)) {
|
7243 | hostPatchProp(
|
7244 | el,
|
7245 | key,
|
7246 | oldProps[key],
|
7247 | null,
|
7248 | namespace,
|
7249 | vnode.children,
|
7250 | parentComponent,
|
7251 | parentSuspense,
|
7252 | unmountChildren
|
7253 | );
|
7254 | }
|
7255 | }
|
7256 | }
|
7257 | for (const key in newProps) {
|
7258 | if (isReservedProp(key))
|
7259 | continue;
|
7260 | const next = newProps[key];
|
7261 | const prev = oldProps[key];
|
7262 | if (next !== prev && key !== "value") {
|
7263 | hostPatchProp(
|
7264 | el,
|
7265 | key,
|
7266 | prev,
|
7267 | next,
|
7268 | namespace,
|
7269 | vnode.children,
|
7270 | parentComponent,
|
7271 | parentSuspense,
|
7272 | unmountChildren
|
7273 | );
|
7274 | }
|
7275 | }
|
7276 | if ("value" in newProps) {
|
7277 | hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
|
7278 | }
|
7279 | }
|
7280 | };
|
7281 | const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7282 | const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
|
7283 | const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
|
7284 | let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
|
7285 | if (
|
7286 |
|
7287 | isHmrUpdating || patchFlag & 2048
|
7288 | ) {
|
7289 | patchFlag = 0;
|
7290 | optimized = false;
|
7291 | dynamicChildren = null;
|
7292 | }
|
7293 | if (fragmentSlotScopeIds) {
|
7294 | slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
7295 | }
|
7296 | if (n1 == null) {
|
7297 | hostInsert(fragmentStartAnchor, container, anchor);
|
7298 | hostInsert(fragmentEndAnchor, container, anchor);
|
7299 | mountChildren(
|
7300 |
|
7301 |
|
7302 |
|
7303 |
|
7304 | n2.children || [],
|
7305 | container,
|
7306 | fragmentEndAnchor,
|
7307 | parentComponent,
|
7308 | parentSuspense,
|
7309 | namespace,
|
7310 | slotScopeIds,
|
7311 | optimized
|
7312 | );
|
7313 | } else {
|
7314 | if (patchFlag > 0 && patchFlag & 64 && dynamicChildren &&
|
7315 |
|
7316 | n1.dynamicChildren) {
|
7317 | patchBlockChildren(
|
7318 | n1.dynamicChildren,
|
7319 | dynamicChildren,
|
7320 | container,
|
7321 | parentComponent,
|
7322 | parentSuspense,
|
7323 | namespace,
|
7324 | slotScopeIds
|
7325 | );
|
7326 | {
|
7327 | traverseStaticChildren(n1, n2);
|
7328 | }
|
7329 | } else {
|
7330 | patchChildren(
|
7331 | n1,
|
7332 | n2,
|
7333 | container,
|
7334 | fragmentEndAnchor,
|
7335 | parentComponent,
|
7336 | parentSuspense,
|
7337 | namespace,
|
7338 | slotScopeIds,
|
7339 | optimized
|
7340 | );
|
7341 | }
|
7342 | }
|
7343 | };
|
7344 | const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7345 | n2.slotScopeIds = slotScopeIds;
|
7346 | if (n1 == null) {
|
7347 | if (n2.shapeFlag & 512) {
|
7348 | parentComponent.ctx.activate(
|
7349 | n2,
|
7350 | container,
|
7351 | anchor,
|
7352 | namespace,
|
7353 | optimized
|
7354 | );
|
7355 | } else {
|
7356 | mountComponent(
|
7357 | n2,
|
7358 | container,
|
7359 | anchor,
|
7360 | parentComponent,
|
7361 | parentSuspense,
|
7362 | namespace,
|
7363 | optimized
|
7364 | );
|
7365 | }
|
7366 | } else {
|
7367 | updateComponent(n1, n2, optimized);
|
7368 | }
|
7369 | };
|
7370 | const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
|
7371 | const instance = (initialVNode.component = createComponentInstance(
|
7372 | initialVNode,
|
7373 | parentComponent,
|
7374 | parentSuspense
|
7375 | ));
|
7376 | if (instance.type.__hmrId) {
|
7377 | registerHMR(instance);
|
7378 | }
|
7379 | {
|
7380 | pushWarningContext(initialVNode);
|
7381 | startMeasure(instance, `mount`);
|
7382 | }
|
7383 | if (isKeepAlive(initialVNode)) {
|
7384 | instance.ctx.renderer = internals;
|
7385 | }
|
7386 | {
|
7387 | {
|
7388 | startMeasure(instance, `init`);
|
7389 | }
|
7390 | setupComponent(instance);
|
7391 | {
|
7392 | endMeasure(instance, `init`);
|
7393 | }
|
7394 | }
|
7395 | if (instance.asyncDep) {
|
7396 | parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
|
7397 | if (!initialVNode.el) {
|
7398 | const placeholder = instance.subTree = createVNode(Comment);
|
7399 | processCommentNode(null, placeholder, container, anchor);
|
7400 | }
|
7401 | } else {
|
7402 | setupRenderEffect(
|
7403 | instance,
|
7404 | initialVNode,
|
7405 | container,
|
7406 | anchor,
|
7407 | parentSuspense,
|
7408 | namespace,
|
7409 | optimized
|
7410 | );
|
7411 | }
|
7412 | {
|
7413 | popWarningContext();
|
7414 | endMeasure(instance, `mount`);
|
7415 | }
|
7416 | };
|
7417 | const updateComponent = (n1, n2, optimized) => {
|
7418 | const instance = n2.component = n1.component;
|
7419 | if (shouldUpdateComponent(n1, n2, optimized)) {
|
7420 | if (instance.asyncDep && !instance.asyncResolved) {
|
7421 | {
|
7422 | pushWarningContext(n2);
|
7423 | }
|
7424 | updateComponentPreRender(instance, n2, optimized);
|
7425 | {
|
7426 | popWarningContext();
|
7427 | }
|
7428 | return;
|
7429 | } else {
|
7430 | instance.next = n2;
|
7431 | invalidateJob(instance.update);
|
7432 | instance.effect.dirty = true;
|
7433 | instance.update();
|
7434 | }
|
7435 | } else {
|
7436 | n2.el = n1.el;
|
7437 | instance.vnode = n2;
|
7438 | }
|
7439 | };
|
7440 | const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
|
7441 | const componentUpdateFn = () => {
|
7442 | if (!instance.isMounted) {
|
7443 | let vnodeHook;
|
7444 | const { el, props } = initialVNode;
|
7445 | const { bm, m, parent } = instance;
|
7446 | const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
|
7447 | toggleRecurse(instance, false);
|
7448 | if (bm) {
|
7449 | invokeArrayFns(bm);
|
7450 | }
|
7451 | if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
|
7452 | invokeVNodeHook(vnodeHook, parent, initialVNode);
|
7453 | }
|
7454 | toggleRecurse(instance, true);
|
7455 | if (el && hydrateNode) {
|
7456 | const hydrateSubTree = () => {
|
7457 | {
|
7458 | startMeasure(instance, `render`);
|
7459 | }
|
7460 | instance.subTree = renderComponentRoot(instance);
|
7461 | {
|
7462 | endMeasure(instance, `render`);
|
7463 | }
|
7464 | {
|
7465 | startMeasure(instance, `hydrate`);
|
7466 | }
|
7467 | hydrateNode(
|
7468 | el,
|
7469 | instance.subTree,
|
7470 | instance,
|
7471 | parentSuspense,
|
7472 | null
|
7473 | );
|
7474 | {
|
7475 | endMeasure(instance, `hydrate`);
|
7476 | }
|
7477 | };
|
7478 | if (isAsyncWrapperVNode) {
|
7479 | initialVNode.type.__asyncLoader().then(
|
7480 |
|
7481 |
|
7482 |
|
7483 |
|
7484 | () => !instance.isUnmounted && hydrateSubTree()
|
7485 | );
|
7486 | } else {
|
7487 | hydrateSubTree();
|
7488 | }
|
7489 | } else {
|
7490 | {
|
7491 | startMeasure(instance, `render`);
|
7492 | }
|
7493 | const subTree = instance.subTree = renderComponentRoot(instance);
|
7494 | {
|
7495 | endMeasure(instance, `render`);
|
7496 | }
|
7497 | {
|
7498 | startMeasure(instance, `patch`);
|
7499 | }
|
7500 | patch(
|
7501 | null,
|
7502 | subTree,
|
7503 | container,
|
7504 | anchor,
|
7505 | instance,
|
7506 | parentSuspense,
|
7507 | namespace
|
7508 | );
|
7509 | {
|
7510 | endMeasure(instance, `patch`);
|
7511 | }
|
7512 | initialVNode.el = subTree.el;
|
7513 | }
|
7514 | if (m) {
|
7515 | queuePostRenderEffect(m, parentSuspense);
|
7516 | }
|
7517 | if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
|
7518 | const scopedInitialVNode = initialVNode;
|
7519 | queuePostRenderEffect(
|
7520 | () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
|
7521 | parentSuspense
|
7522 | );
|
7523 | }
|
7524 | if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
|
7525 | instance.a && queuePostRenderEffect(instance.a, parentSuspense);
|
7526 | }
|
7527 | instance.isMounted = true;
|
7528 | {
|
7529 | devtoolsComponentAdded(instance);
|
7530 | }
|
7531 | initialVNode = container = anchor = null;
|
7532 | } else {
|
7533 | let { next, bu, u, parent, vnode } = instance;
|
7534 | {
|
7535 | const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
|
7536 | if (nonHydratedAsyncRoot) {
|
7537 | if (next) {
|
7538 | next.el = vnode.el;
|
7539 | updateComponentPreRender(instance, next, optimized);
|
7540 | }
|
7541 | nonHydratedAsyncRoot.asyncDep.then(() => {
|
7542 | if (!instance.isUnmounted) {
|
7543 | componentUpdateFn();
|
7544 | }
|
7545 | });
|
7546 | return;
|
7547 | }
|
7548 | }
|
7549 | let originNext = next;
|
7550 | let vnodeHook;
|
7551 | {
|
7552 | pushWarningContext(next || instance.vnode);
|
7553 | }
|
7554 | toggleRecurse(instance, false);
|
7555 | if (next) {
|
7556 | next.el = vnode.el;
|
7557 | updateComponentPreRender(instance, next, optimized);
|
7558 | } else {
|
7559 | next = vnode;
|
7560 | }
|
7561 | if (bu) {
|
7562 | invokeArrayFns(bu);
|
7563 | }
|
7564 | if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
|
7565 | invokeVNodeHook(vnodeHook, parent, next, vnode);
|
7566 | }
|
7567 | toggleRecurse(instance, true);
|
7568 | {
|
7569 | startMeasure(instance, `render`);
|
7570 | }
|
7571 | const nextTree = renderComponentRoot(instance);
|
7572 | {
|
7573 | endMeasure(instance, `render`);
|
7574 | }
|
7575 | const prevTree = instance.subTree;
|
7576 | instance.subTree = nextTree;
|
7577 | {
|
7578 | startMeasure(instance, `patch`);
|
7579 | }
|
7580 | patch(
|
7581 | prevTree,
|
7582 | nextTree,
|
7583 |
|
7584 | hostParentNode(prevTree.el),
|
7585 |
|
7586 | getNextHostNode(prevTree),
|
7587 | instance,
|
7588 | parentSuspense,
|
7589 | namespace
|
7590 | );
|
7591 | {
|
7592 | endMeasure(instance, `patch`);
|
7593 | }
|
7594 | next.el = nextTree.el;
|
7595 | if (originNext === null) {
|
7596 | updateHOCHostEl(instance, nextTree.el);
|
7597 | }
|
7598 | if (u) {
|
7599 | queuePostRenderEffect(u, parentSuspense);
|
7600 | }
|
7601 | if (vnodeHook = next.props && next.props.onVnodeUpdated) {
|
7602 | queuePostRenderEffect(
|
7603 | () => invokeVNodeHook(vnodeHook, parent, next, vnode),
|
7604 | parentSuspense
|
7605 | );
|
7606 | }
|
7607 | {
|
7608 | devtoolsComponentUpdated(instance);
|
7609 | }
|
7610 | {
|
7611 | popWarningContext();
|
7612 | }
|
7613 | }
|
7614 | };
|
7615 | const effect = instance.effect = new ReactiveEffect(
|
7616 | componentUpdateFn,
|
7617 | NOOP,
|
7618 | () => queueJob(update),
|
7619 | instance.scope
|
7620 |
|
7621 | );
|
7622 | const update = instance.update = () => {
|
7623 | if (effect.dirty) {
|
7624 | effect.run();
|
7625 | }
|
7626 | };
|
7627 | update.id = instance.uid;
|
7628 | toggleRecurse(instance, true);
|
7629 | {
|
7630 | effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
|
7631 | effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
|
7632 | update.ownerInstance = instance;
|
7633 | }
|
7634 | update();
|
7635 | };
|
7636 | const updateComponentPreRender = (instance, nextVNode, optimized) => {
|
7637 | nextVNode.component = instance;
|
7638 | const prevProps = instance.vnode.props;
|
7639 | instance.vnode = nextVNode;
|
7640 | instance.next = null;
|
7641 | updateProps(instance, nextVNode.props, prevProps, optimized);
|
7642 | updateSlots(instance, nextVNode.children, optimized);
|
7643 | pauseTracking();
|
7644 | flushPreFlushCbs(instance);
|
7645 | resetTracking();
|
7646 | };
|
7647 | const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
|
7648 | const c1 = n1 && n1.children;
|
7649 | const prevShapeFlag = n1 ? n1.shapeFlag : 0;
|
7650 | const c2 = n2.children;
|
7651 | const { patchFlag, shapeFlag } = n2;
|
7652 | if (patchFlag > 0) {
|
7653 | if (patchFlag & 128) {
|
7654 | patchKeyedChildren(
|
7655 | c1,
|
7656 | c2,
|
7657 | container,
|
7658 | anchor,
|
7659 | parentComponent,
|
7660 | parentSuspense,
|
7661 | namespace,
|
7662 | slotScopeIds,
|
7663 | optimized
|
7664 | );
|
7665 | return;
|
7666 | } else if (patchFlag & 256) {
|
7667 | patchUnkeyedChildren(
|
7668 | c1,
|
7669 | c2,
|
7670 | container,
|
7671 | anchor,
|
7672 | parentComponent,
|
7673 | parentSuspense,
|
7674 | namespace,
|
7675 | slotScopeIds,
|
7676 | optimized
|
7677 | );
|
7678 | return;
|
7679 | }
|
7680 | }
|
7681 | if (shapeFlag & 8) {
|
7682 | if (prevShapeFlag & 16) {
|
7683 | unmountChildren(c1, parentComponent, parentSuspense);
|
7684 | }
|
7685 | if (c2 !== c1) {
|
7686 | hostSetElementText(container, c2);
|
7687 | }
|
7688 | } else {
|
7689 | if (prevShapeFlag & 16) {
|
7690 | if (shapeFlag & 16) {
|
7691 | patchKeyedChildren(
|
7692 | c1,
|
7693 | c2,
|
7694 | container,
|
7695 | anchor,
|
7696 | parentComponent,
|
7697 | parentSuspense,
|
7698 | namespace,
|
7699 | slotScopeIds,
|
7700 | optimized
|
7701 | );
|
7702 | } else {
|
7703 | unmountChildren(c1, parentComponent, parentSuspense, true);
|
7704 | }
|
7705 | } else {
|
7706 | if (prevShapeFlag & 8) {
|
7707 | hostSetElementText(container, "");
|
7708 | }
|
7709 | if (shapeFlag & 16) {
|
7710 | mountChildren(
|
7711 | c2,
|
7712 | container,
|
7713 | anchor,
|
7714 | parentComponent,
|
7715 | parentSuspense,
|
7716 | namespace,
|
7717 | slotScopeIds,
|
7718 | optimized
|
7719 | );
|
7720 | }
|
7721 | }
|
7722 | }
|
7723 | };
|
7724 | const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7725 | c1 = c1 || EMPTY_ARR;
|
7726 | c2 = c2 || EMPTY_ARR;
|
7727 | const oldLength = c1.length;
|
7728 | const newLength = c2.length;
|
7729 | const commonLength = Math.min(oldLength, newLength);
|
7730 | let i;
|
7731 | for (i = 0; i < commonLength; i++) {
|
7732 | const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
7733 | patch(
|
7734 | c1[i],
|
7735 | nextChild,
|
7736 | container,
|
7737 | null,
|
7738 | parentComponent,
|
7739 | parentSuspense,
|
7740 | namespace,
|
7741 | slotScopeIds,
|
7742 | optimized
|
7743 | );
|
7744 | }
|
7745 | if (oldLength > newLength) {
|
7746 | unmountChildren(
|
7747 | c1,
|
7748 | parentComponent,
|
7749 | parentSuspense,
|
7750 | true,
|
7751 | false,
|
7752 | commonLength
|
7753 | );
|
7754 | } else {
|
7755 | mountChildren(
|
7756 | c2,
|
7757 | container,
|
7758 | anchor,
|
7759 | parentComponent,
|
7760 | parentSuspense,
|
7761 | namespace,
|
7762 | slotScopeIds,
|
7763 | optimized,
|
7764 | commonLength
|
7765 | );
|
7766 | }
|
7767 | };
|
7768 | const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7769 | let i = 0;
|
7770 | const l2 = c2.length;
|
7771 | let e1 = c1.length - 1;
|
7772 | let e2 = l2 - 1;
|
7773 | while (i <= e1 && i <= e2) {
|
7774 | const n1 = c1[i];
|
7775 | const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
7776 | if (isSameVNodeType(n1, n2)) {
|
7777 | patch(
|
7778 | n1,
|
7779 | n2,
|
7780 | container,
|
7781 | null,
|
7782 | parentComponent,
|
7783 | parentSuspense,
|
7784 | namespace,
|
7785 | slotScopeIds,
|
7786 | optimized
|
7787 | );
|
7788 | } else {
|
7789 | break;
|
7790 | }
|
7791 | i++;
|
7792 | }
|
7793 | while (i <= e1 && i <= e2) {
|
7794 | const n1 = c1[e1];
|
7795 | const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
|
7796 | if (isSameVNodeType(n1, n2)) {
|
7797 | patch(
|
7798 | n1,
|
7799 | n2,
|
7800 | container,
|
7801 | null,
|
7802 | parentComponent,
|
7803 | parentSuspense,
|
7804 | namespace,
|
7805 | slotScopeIds,
|
7806 | optimized
|
7807 | );
|
7808 | } else {
|
7809 | break;
|
7810 | }
|
7811 | e1--;
|
7812 | e2--;
|
7813 | }
|
7814 | if (i > e1) {
|
7815 | if (i <= e2) {
|
7816 | const nextPos = e2 + 1;
|
7817 | const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
|
7818 | while (i <= e2) {
|
7819 | patch(
|
7820 | null,
|
7821 | c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
|
7822 | container,
|
7823 | anchor,
|
7824 | parentComponent,
|
7825 | parentSuspense,
|
7826 | namespace,
|
7827 | slotScopeIds,
|
7828 | optimized
|
7829 | );
|
7830 | i++;
|
7831 | }
|
7832 | }
|
7833 | } else if (i > e2) {
|
7834 | while (i <= e1) {
|
7835 | unmount(c1[i], parentComponent, parentSuspense, true);
|
7836 | i++;
|
7837 | }
|
7838 | } else {
|
7839 | const s1 = i;
|
7840 | const s2 = i;
|
7841 | const keyToNewIndexMap = new Map();
|
7842 | for (i = s2; i <= e2; i++) {
|
7843 | const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
7844 | if (nextChild.key != null) {
|
7845 | if (keyToNewIndexMap.has(nextChild.key)) {
|
7846 | warn$1(
|
7847 | `Duplicate keys found during update:`,
|
7848 | JSON.stringify(nextChild.key),
|
7849 | `Make sure keys are unique.`
|
7850 | );
|
7851 | }
|
7852 | keyToNewIndexMap.set(nextChild.key, i);
|
7853 | }
|
7854 | }
|
7855 | let j;
|
7856 | let patched = 0;
|
7857 | const toBePatched = e2 - s2 + 1;
|
7858 | let moved = false;
|
7859 | let maxNewIndexSoFar = 0;
|
7860 | const newIndexToOldIndexMap = new Array(toBePatched);
|
7861 | for (i = 0; i < toBePatched; i++)
|
7862 | newIndexToOldIndexMap[i] = 0;
|
7863 | for (i = s1; i <= e1; i++) {
|
7864 | const prevChild = c1[i];
|
7865 | if (patched >= toBePatched) {
|
7866 | unmount(prevChild, parentComponent, parentSuspense, true);
|
7867 | continue;
|
7868 | }
|
7869 | let newIndex;
|
7870 | if (prevChild.key != null) {
|
7871 | newIndex = keyToNewIndexMap.get(prevChild.key);
|
7872 | } else {
|
7873 | for (j = s2; j <= e2; j++) {
|
7874 | if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
|
7875 | newIndex = j;
|
7876 | break;
|
7877 | }
|
7878 | }
|
7879 | }
|
7880 | if (newIndex === void 0) {
|
7881 | unmount(prevChild, parentComponent, parentSuspense, true);
|
7882 | } else {
|
7883 | newIndexToOldIndexMap[newIndex - s2] = i + 1;
|
7884 | if (newIndex >= maxNewIndexSoFar) {
|
7885 | maxNewIndexSoFar = newIndex;
|
7886 | } else {
|
7887 | moved = true;
|
7888 | }
|
7889 | patch(
|
7890 | prevChild,
|
7891 | c2[newIndex],
|
7892 | container,
|
7893 | null,
|
7894 | parentComponent,
|
7895 | parentSuspense,
|
7896 | namespace,
|
7897 | slotScopeIds,
|
7898 | optimized
|
7899 | );
|
7900 | patched++;
|
7901 | }
|
7902 | }
|
7903 | const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
|
7904 | j = increasingNewIndexSequence.length - 1;
|
7905 | for (i = toBePatched - 1; i >= 0; i--) {
|
7906 | const nextIndex = s2 + i;
|
7907 | const nextChild = c2[nextIndex];
|
7908 | const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
|
7909 | if (newIndexToOldIndexMap[i] === 0) {
|
7910 | patch(
|
7911 | null,
|
7912 | nextChild,
|
7913 | container,
|
7914 | anchor,
|
7915 | parentComponent,
|
7916 | parentSuspense,
|
7917 | namespace,
|
7918 | slotScopeIds,
|
7919 | optimized
|
7920 | );
|
7921 | } else if (moved) {
|
7922 | if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
7923 | move(nextChild, container, anchor, 2);
|
7924 | } else {
|
7925 | j--;
|
7926 | }
|
7927 | }
|
7928 | }
|
7929 | }
|
7930 | };
|
7931 | const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
|
7932 | const { el, type, transition, children, shapeFlag } = vnode;
|
7933 | if (shapeFlag & 6) {
|
7934 | move(vnode.component.subTree, container, anchor, moveType);
|
7935 | return;
|
7936 | }
|
7937 | if (shapeFlag & 128) {
|
7938 | vnode.suspense.move(container, anchor, moveType);
|
7939 | return;
|
7940 | }
|
7941 | if (shapeFlag & 64) {
|
7942 | type.move(vnode, container, anchor, internals);
|
7943 | return;
|
7944 | }
|
7945 | if (type === Fragment) {
|
7946 | hostInsert(el, container, anchor);
|
7947 | for (let i = 0; i < children.length; i++) {
|
7948 | move(children[i], container, anchor, moveType);
|
7949 | }
|
7950 | hostInsert(vnode.anchor, container, anchor);
|
7951 | return;
|
7952 | }
|
7953 | if (type === Static) {
|
7954 | moveStaticNode(vnode, container, anchor);
|
7955 | return;
|
7956 | }
|
7957 | const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
|
7958 | if (needTransition2) {
|
7959 | if (moveType === 0) {
|
7960 | transition.beforeEnter(el);
|
7961 | hostInsert(el, container, anchor);
|
7962 | queuePostRenderEffect(() => transition.enter(el), parentSuspense);
|
7963 | } else {
|
7964 | const { leave, delayLeave, afterLeave } = transition;
|
7965 | const remove2 = () => hostInsert(el, container, anchor);
|
7966 | const performLeave = () => {
|
7967 | leave(el, () => {
|
7968 | remove2();
|
7969 | afterLeave && afterLeave();
|
7970 | });
|
7971 | };
|
7972 | if (delayLeave) {
|
7973 | delayLeave(el, remove2, performLeave);
|
7974 | } else {
|
7975 | performLeave();
|
7976 | }
|
7977 | }
|
7978 | } else {
|
7979 | hostInsert(el, container, anchor);
|
7980 | }
|
7981 | };
|
7982 | const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
|
7983 | const {
|
7984 | type,
|
7985 | props,
|
7986 | ref,
|
7987 | children,
|
7988 | dynamicChildren,
|
7989 | shapeFlag,
|
7990 | patchFlag,
|
7991 | dirs
|
7992 | } = vnode;
|
7993 | if (ref != null) {
|
7994 | setRef(ref, null, parentSuspense, vnode, true);
|
7995 | }
|
7996 | if (shapeFlag & 256) {
|
7997 | parentComponent.ctx.deactivate(vnode);
|
7998 | return;
|
7999 | }
|
8000 | const shouldInvokeDirs = shapeFlag & 1 && dirs;
|
8001 | const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
|
8002 | let vnodeHook;
|
8003 | if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
|
8004 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
8005 | }
|
8006 | if (shapeFlag & 6) {
|
8007 | unmountComponent(vnode.component, parentSuspense, doRemove);
|
8008 | } else {
|
8009 | if (shapeFlag & 128) {
|
8010 | vnode.suspense.unmount(parentSuspense, doRemove);
|
8011 | return;
|
8012 | }
|
8013 | if (shouldInvokeDirs) {
|
8014 | invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
|
8015 | }
|
8016 | if (shapeFlag & 64) {
|
8017 | vnode.type.remove(
|
8018 | vnode,
|
8019 | parentComponent,
|
8020 | parentSuspense,
|
8021 | optimized,
|
8022 | internals,
|
8023 | doRemove
|
8024 | );
|
8025 | } else if (dynamicChildren &&
|
8026 | (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
|
8027 | unmountChildren(
|
8028 | dynamicChildren,
|
8029 | parentComponent,
|
8030 | parentSuspense,
|
8031 | false,
|
8032 | true
|
8033 | );
|
8034 | } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
|
8035 | unmountChildren(children, parentComponent, parentSuspense);
|
8036 | }
|
8037 | if (doRemove) {
|
8038 | remove(vnode);
|
8039 | }
|
8040 | }
|
8041 | if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
|
8042 | queuePostRenderEffect(() => {
|
8043 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
8044 | shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
|
8045 | }, parentSuspense);
|
8046 | }
|
8047 | };
|
8048 | const remove = (vnode) => {
|
8049 | const { type, el, anchor, transition } = vnode;
|
8050 | if (type === Fragment) {
|
8051 | if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
|
8052 | vnode.children.forEach((child) => {
|
8053 | if (child.type === Comment) {
|
8054 | hostRemove(child.el);
|
8055 | } else {
|
8056 | remove(child);
|
8057 | }
|
8058 | });
|
8059 | } else {
|
8060 | removeFragment(el, anchor);
|
8061 | }
|
8062 | return;
|
8063 | }
|
8064 | if (type === Static) {
|
8065 | removeStaticNode(vnode);
|
8066 | return;
|
8067 | }
|
8068 | const performRemove = () => {
|
8069 | hostRemove(el);
|
8070 | if (transition && !transition.persisted && transition.afterLeave) {
|
8071 | transition.afterLeave();
|
8072 | }
|
8073 | };
|
8074 | if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
|
8075 | const { leave, delayLeave } = transition;
|
8076 | const performLeave = () => leave(el, performRemove);
|
8077 | if (delayLeave) {
|
8078 | delayLeave(vnode.el, performRemove, performLeave);
|
8079 | } else {
|
8080 | performLeave();
|
8081 | }
|
8082 | } else {
|
8083 | performRemove();
|
8084 | }
|
8085 | };
|
8086 | const removeFragment = (cur, end) => {
|
8087 | let next;
|
8088 | while (cur !== end) {
|
8089 | next = hostNextSibling(cur);
|
8090 | hostRemove(cur);
|
8091 | cur = next;
|
8092 | }
|
8093 | hostRemove(end);
|
8094 | };
|
8095 | const unmountComponent = (instance, parentSuspense, doRemove) => {
|
8096 | if (instance.type.__hmrId) {
|
8097 | unregisterHMR(instance);
|
8098 | }
|
8099 | const { bum, scope, update, subTree, um } = instance;
|
8100 | if (bum) {
|
8101 | invokeArrayFns(bum);
|
8102 | }
|
8103 | scope.stop();
|
8104 | if (update) {
|
8105 | update.active = false;
|
8106 | unmount(subTree, instance, parentSuspense, doRemove);
|
8107 | }
|
8108 | if (um) {
|
8109 | queuePostRenderEffect(um, parentSuspense);
|
8110 | }
|
8111 | queuePostRenderEffect(() => {
|
8112 | instance.isUnmounted = true;
|
8113 | }, parentSuspense);
|
8114 | if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
|
8115 | parentSuspense.deps--;
|
8116 | if (parentSuspense.deps === 0) {
|
8117 | parentSuspense.resolve();
|
8118 | }
|
8119 | }
|
8120 | {
|
8121 | devtoolsComponentRemoved(instance);
|
8122 | }
|
8123 | };
|
8124 | const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
|
8125 | for (let i = start; i < children.length; i++) {
|
8126 | unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
|
8127 | }
|
8128 | };
|
8129 | const getNextHostNode = (vnode) => {
|
8130 | if (vnode.shapeFlag & 6) {
|
8131 | return getNextHostNode(vnode.component.subTree);
|
8132 | }
|
8133 | if (vnode.shapeFlag & 128) {
|
8134 | return vnode.suspense.next();
|
8135 | }
|
8136 | return hostNextSibling(vnode.anchor || vnode.el);
|
8137 | };
|
8138 | let isFlushing = false;
|
8139 | const render = (vnode, container, namespace) => {
|
8140 | if (vnode == null) {
|
8141 | if (container._vnode) {
|
8142 | unmount(container._vnode, null, null, true);
|
8143 | }
|
8144 | } else {
|
8145 | patch(
|
8146 | container._vnode || null,
|
8147 | vnode,
|
8148 | container,
|
8149 | null,
|
8150 | null,
|
8151 | null,
|
8152 | namespace
|
8153 | );
|
8154 | }
|
8155 | if (!isFlushing) {
|
8156 | isFlushing = true;
|
8157 | flushPreFlushCbs();
|
8158 | flushPostFlushCbs();
|
8159 | isFlushing = false;
|
8160 | }
|
8161 | container._vnode = vnode;
|
8162 | };
|
8163 | const internals = {
|
8164 | p: patch,
|
8165 | um: unmount,
|
8166 | m: move,
|
8167 | r: remove,
|
8168 | mt: mountComponent,
|
8169 | mc: mountChildren,
|
8170 | pc: patchChildren,
|
8171 | pbc: patchBlockChildren,
|
8172 | n: getNextHostNode,
|
8173 | o: options
|
8174 | };
|
8175 | let hydrate;
|
8176 | let hydrateNode;
|
8177 | if (createHydrationFns) {
|
8178 | [hydrate, hydrateNode] = createHydrationFns(
|
8179 | internals
|
8180 | );
|
8181 | }
|
8182 | return {
|
8183 | render,
|
8184 | hydrate,
|
8185 | createApp: createAppAPI(render, hydrate)
|
8186 | };
|
8187 | }
|
8188 | function resolveChildrenNamespace({ type, props }, currentNamespace) {
|
8189 | return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
|
8190 | }
|
8191 | function toggleRecurse({ effect, update }, allowed) {
|
8192 | effect.allowRecurse = update.allowRecurse = allowed;
|
8193 | }
|
8194 | function needTransition(parentSuspense, transition) {
|
8195 | return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
|
8196 | }
|
8197 | function traverseStaticChildren(n1, n2, shallow = false) {
|
8198 | const ch1 = n1.children;
|
8199 | const ch2 = n2.children;
|
8200 | if (isArray(ch1) && isArray(ch2)) {
|
8201 | for (let i = 0; i < ch1.length; i++) {
|
8202 | const c1 = ch1[i];
|
8203 | let c2 = ch2[i];
|
8204 | if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
|
8205 | if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
|
8206 | c2 = ch2[i] = cloneIfMounted(ch2[i]);
|
8207 | c2.el = c1.el;
|
8208 | }
|
8209 | if (!shallow)
|
8210 | traverseStaticChildren(c1, c2);
|
8211 | }
|
8212 | if (c2.type === Text) {
|
8213 | c2.el = c1.el;
|
8214 | }
|
8215 | if (c2.type === Comment && !c2.el) {
|
8216 | c2.el = c1.el;
|
8217 | }
|
8218 | }
|
8219 | }
|
8220 | }
|
8221 | function getSequence(arr) {
|
8222 | const p = arr.slice();
|
8223 | const result = [0];
|
8224 | let i, j, u, v, c;
|
8225 | const len = arr.length;
|
8226 | for (i = 0; i < len; i++) {
|
8227 | const arrI = arr[i];
|
8228 | if (arrI !== 0) {
|
8229 | j = result[result.length - 1];
|
8230 | if (arr[j] < arrI) {
|
8231 | p[i] = j;
|
8232 | result.push(i);
|
8233 | continue;
|
8234 | }
|
8235 | u = 0;
|
8236 | v = result.length - 1;
|
8237 | while (u < v) {
|
8238 | c = u + v >> 1;
|
8239 | if (arr[result[c]] < arrI) {
|
8240 | u = c + 1;
|
8241 | } else {
|
8242 | v = c;
|
8243 | }
|
8244 | }
|
8245 | if (arrI < arr[result[u]]) {
|
8246 | if (u > 0) {
|
8247 | p[i] = result[u - 1];
|
8248 | }
|
8249 | result[u] = i;
|
8250 | }
|
8251 | }
|
8252 | }
|
8253 | u = result.length;
|
8254 | v = result[u - 1];
|
8255 | while (u-- > 0) {
|
8256 | result[u] = v;
|
8257 | v = p[v];
|
8258 | }
|
8259 | return result;
|
8260 | }
|
8261 | function locateNonHydratedAsyncRoot(instance) {
|
8262 | const subComponent = instance.subTree.component;
|
8263 | if (subComponent) {
|
8264 | if (subComponent.asyncDep && !subComponent.asyncResolved) {
|
8265 | return subComponent;
|
8266 | } else {
|
8267 | return locateNonHydratedAsyncRoot(subComponent);
|
8268 | }
|
8269 | }
|
8270 | }
|
8271 |
|
8272 | const isTeleport = (type) => type.__isTeleport;
|
8273 | const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
|
8274 | const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
|
8275 | const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
|
8276 | const resolveTarget = (props, select) => {
|
8277 | const targetSelector = props && props.to;
|
8278 | if (isString(targetSelector)) {
|
8279 | if (!select) {
|
8280 | warn$1(
|
8281 | `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`
|
8282 | );
|
8283 | return null;
|
8284 | } else {
|
8285 | const target = select(targetSelector);
|
8286 | if (!target) {
|
8287 | warn$1(
|
8288 | `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.`
|
8289 | );
|
8290 | }
|
8291 | return target;
|
8292 | }
|
8293 | } else {
|
8294 | if (!targetSelector && !isTeleportDisabled(props)) {
|
8295 | warn$1(`Invalid Teleport target: ${targetSelector}`);
|
8296 | }
|
8297 | return targetSelector;
|
8298 | }
|
8299 | };
|
8300 | const TeleportImpl = {
|
8301 | name: "Teleport",
|
8302 | __isTeleport: true,
|
8303 | process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
|
8304 | const {
|
8305 | mc: mountChildren,
|
8306 | pc: patchChildren,
|
8307 | pbc: patchBlockChildren,
|
8308 | o: { insert, querySelector, createText, createComment }
|
8309 | } = internals;
|
8310 | const disabled = isTeleportDisabled(n2.props);
|
8311 | let { shapeFlag, children, dynamicChildren } = n2;
|
8312 | if (isHmrUpdating) {
|
8313 | optimized = false;
|
8314 | dynamicChildren = null;
|
8315 | }
|
8316 | if (n1 == null) {
|
8317 | const placeholder = n2.el = createComment("teleport start") ;
|
8318 | const mainAnchor = n2.anchor = createComment("teleport end") ;
|
8319 | insert(placeholder, container, anchor);
|
8320 | insert(mainAnchor, container, anchor);
|
8321 | const target = n2.target = resolveTarget(n2.props, querySelector);
|
8322 | const targetAnchor = n2.targetAnchor = createText("");
|
8323 | if (target) {
|
8324 | insert(targetAnchor, target);
|
8325 | if (namespace === "svg" || isTargetSVG(target)) {
|
8326 | namespace = "svg";
|
8327 | } else if (namespace === "mathml" || isTargetMathML(target)) {
|
8328 | namespace = "mathml";
|
8329 | }
|
8330 | } else if (!disabled) {
|
8331 | warn$1("Invalid Teleport target on mount:", target, `(${typeof target})`);
|
8332 | }
|
8333 | const mount = (container2, anchor2) => {
|
8334 | if (shapeFlag & 16) {
|
8335 | mountChildren(
|
8336 | children,
|
8337 | container2,
|
8338 | anchor2,
|
8339 | parentComponent,
|
8340 | parentSuspense,
|
8341 | namespace,
|
8342 | slotScopeIds,
|
8343 | optimized
|
8344 | );
|
8345 | }
|
8346 | };
|
8347 | if (disabled) {
|
8348 | mount(container, mainAnchor);
|
8349 | } else if (target) {
|
8350 | mount(target, targetAnchor);
|
8351 | }
|
8352 | } else {
|
8353 | n2.el = n1.el;
|
8354 | const mainAnchor = n2.anchor = n1.anchor;
|
8355 | const target = n2.target = n1.target;
|
8356 | const targetAnchor = n2.targetAnchor = n1.targetAnchor;
|
8357 | const wasDisabled = isTeleportDisabled(n1.props);
|
8358 | const currentContainer = wasDisabled ? container : target;
|
8359 | const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
|
8360 | if (namespace === "svg" || isTargetSVG(target)) {
|
8361 | namespace = "svg";
|
8362 | } else if (namespace === "mathml" || isTargetMathML(target)) {
|
8363 | namespace = "mathml";
|
8364 | }
|
8365 | if (dynamicChildren) {
|
8366 | patchBlockChildren(
|
8367 | n1.dynamicChildren,
|
8368 | dynamicChildren,
|
8369 | currentContainer,
|
8370 | parentComponent,
|
8371 | parentSuspense,
|
8372 | namespace,
|
8373 | slotScopeIds
|
8374 | );
|
8375 | traverseStaticChildren(n1, n2, true);
|
8376 | } else if (!optimized) {
|
8377 | patchChildren(
|
8378 | n1,
|
8379 | n2,
|
8380 | currentContainer,
|
8381 | currentAnchor,
|
8382 | parentComponent,
|
8383 | parentSuspense,
|
8384 | namespace,
|
8385 | slotScopeIds,
|
8386 | false
|
8387 | );
|
8388 | }
|
8389 | if (disabled) {
|
8390 | if (!wasDisabled) {
|
8391 | moveTeleport(
|
8392 | n2,
|
8393 | container,
|
8394 | mainAnchor,
|
8395 | internals,
|
8396 | 1
|
8397 | );
|
8398 | } else {
|
8399 | if (n2.props && n1.props && n2.props.to !== n1.props.to) {
|
8400 | n2.props.to = n1.props.to;
|
8401 | }
|
8402 | }
|
8403 | } else {
|
8404 | if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
|
8405 | const nextTarget = n2.target = resolveTarget(
|
8406 | n2.props,
|
8407 | querySelector
|
8408 | );
|
8409 | if (nextTarget) {
|
8410 | moveTeleport(
|
8411 | n2,
|
8412 | nextTarget,
|
8413 | null,
|
8414 | internals,
|
8415 | 0
|
8416 | );
|
8417 | } else {
|
8418 | warn$1(
|
8419 | "Invalid Teleport target on update:",
|
8420 | target,
|
8421 | `(${typeof target})`
|
8422 | );
|
8423 | }
|
8424 | } else if (wasDisabled) {
|
8425 | moveTeleport(
|
8426 | n2,
|
8427 | target,
|
8428 | targetAnchor,
|
8429 | internals,
|
8430 | 1
|
8431 | );
|
8432 | }
|
8433 | }
|
8434 | }
|
8435 | updateCssVars(n2);
|
8436 | },
|
8437 | remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
|
8438 | const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
|
8439 | if (target) {
|
8440 | hostRemove(targetAnchor);
|
8441 | }
|
8442 | doRemove && hostRemove(anchor);
|
8443 | if (shapeFlag & 16) {
|
8444 | const shouldRemove = doRemove || !isTeleportDisabled(props);
|
8445 | for (let i = 0; i < children.length; i++) {
|
8446 | const child = children[i];
|
8447 | unmount(
|
8448 | child,
|
8449 | parentComponent,
|
8450 | parentSuspense,
|
8451 | shouldRemove,
|
8452 | !!child.dynamicChildren
|
8453 | );
|
8454 | }
|
8455 | }
|
8456 | },
|
8457 | move: moveTeleport,
|
8458 | hydrate: hydrateTeleport
|
8459 | };
|
8460 | function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
|
8461 | if (moveType === 0) {
|
8462 | insert(vnode.targetAnchor, container, parentAnchor);
|
8463 | }
|
8464 | const { el, anchor, shapeFlag, children, props } = vnode;
|
8465 | const isReorder = moveType === 2;
|
8466 | if (isReorder) {
|
8467 | insert(el, container, parentAnchor);
|
8468 | }
|
8469 | if (!isReorder || isTeleportDisabled(props)) {
|
8470 | if (shapeFlag & 16) {
|
8471 | for (let i = 0; i < children.length; i++) {
|
8472 | move(
|
8473 | children[i],
|
8474 | container,
|
8475 | parentAnchor,
|
8476 | 2
|
8477 | );
|
8478 | }
|
8479 | }
|
8480 | }
|
8481 | if (isReorder) {
|
8482 | insert(anchor, container, parentAnchor);
|
8483 | }
|
8484 | }
|
8485 | function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
|
8486 | o: { nextSibling, parentNode, querySelector }
|
8487 | }, hydrateChildren) {
|
8488 | const target = vnode.target = resolveTarget(
|
8489 | vnode.props,
|
8490 | querySelector
|
8491 | );
|
8492 | if (target) {
|
8493 | const targetNode = target._lpa || target.firstChild;
|
8494 | if (vnode.shapeFlag & 16) {
|
8495 | if (isTeleportDisabled(vnode.props)) {
|
8496 | vnode.anchor = hydrateChildren(
|
8497 | nextSibling(node),
|
8498 | vnode,
|
8499 | parentNode(node),
|
8500 | parentComponent,
|
8501 | parentSuspense,
|
8502 | slotScopeIds,
|
8503 | optimized
|
8504 | );
|
8505 | vnode.targetAnchor = targetNode;
|
8506 | } else {
|
8507 | vnode.anchor = nextSibling(node);
|
8508 | let targetAnchor = targetNode;
|
8509 | while (targetAnchor) {
|
8510 | targetAnchor = nextSibling(targetAnchor);
|
8511 | if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
|
8512 | vnode.targetAnchor = targetAnchor;
|
8513 | target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
|
8514 | break;
|
8515 | }
|
8516 | }
|
8517 | hydrateChildren(
|
8518 | targetNode,
|
8519 | vnode,
|
8520 | target,
|
8521 | parentComponent,
|
8522 | parentSuspense,
|
8523 | slotScopeIds,
|
8524 | optimized
|
8525 | );
|
8526 | }
|
8527 | }
|
8528 | updateCssVars(vnode);
|
8529 | }
|
8530 | return vnode.anchor && nextSibling(vnode.anchor);
|
8531 | }
|
8532 | const Teleport = TeleportImpl;
|
8533 | function updateCssVars(vnode) {
|
8534 | const ctx = vnode.ctx;
|
8535 | if (ctx && ctx.ut) {
|
8536 | let node = vnode.children[0].el;
|
8537 | while (node && node !== vnode.targetAnchor) {
|
8538 | if (node.nodeType === 1)
|
8539 | node.setAttribute("data-v-owner", ctx.uid);
|
8540 | node = node.nextSibling;
|
8541 | }
|
8542 | ctx.ut();
|
8543 | }
|
8544 | }
|
8545 |
|
8546 | const Fragment = Symbol.for("v-fgt");
|
8547 | const Text = Symbol.for("v-txt");
|
8548 | const Comment = Symbol.for("v-cmt");
|
8549 | const Static = Symbol.for("v-stc");
|
8550 | const blockStack = [];
|
8551 | let currentBlock = null;
|
8552 | function openBlock(disableTracking = false) {
|
8553 | blockStack.push(currentBlock = disableTracking ? null : []);
|
8554 | }
|
8555 | function closeBlock() {
|
8556 | blockStack.pop();
|
8557 | currentBlock = blockStack[blockStack.length - 1] || null;
|
8558 | }
|
8559 | let isBlockTreeEnabled = 1;
|
8560 | function setBlockTracking(value) {
|
8561 | isBlockTreeEnabled += value;
|
8562 | }
|
8563 | function setupBlock(vnode) {
|
8564 | vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
|
8565 | closeBlock();
|
8566 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
8567 | currentBlock.push(vnode);
|
8568 | }
|
8569 | return vnode;
|
8570 | }
|
8571 | function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
|
8572 | return setupBlock(
|
8573 | createBaseVNode(
|
8574 | type,
|
8575 | props,
|
8576 | children,
|
8577 | patchFlag,
|
8578 | dynamicProps,
|
8579 | shapeFlag,
|
8580 | true
|
8581 | )
|
8582 | );
|
8583 | }
|
8584 | function createBlock(type, props, children, patchFlag, dynamicProps) {
|
8585 | return setupBlock(
|
8586 | createVNode(
|
8587 | type,
|
8588 | props,
|
8589 | children,
|
8590 | patchFlag,
|
8591 | dynamicProps,
|
8592 | true
|
8593 | )
|
8594 | );
|
8595 | }
|
8596 | function isVNode(value) {
|
8597 | return value ? value.__v_isVNode === true : false;
|
8598 | }
|
8599 | function isSameVNodeType(n1, n2) {
|
8600 | if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
|
8601 | n1.shapeFlag &= ~256;
|
8602 | n2.shapeFlag &= ~512;
|
8603 | return false;
|
8604 | }
|
8605 | return n1.type === n2.type && n1.key === n2.key;
|
8606 | }
|
8607 | let vnodeArgsTransformer;
|
8608 | function transformVNodeArgs(transformer) {
|
8609 | vnodeArgsTransformer = transformer;
|
8610 | }
|
8611 | const createVNodeWithArgsTransform = (...args) => {
|
8612 | return _createVNode(
|
8613 | ...vnodeArgsTransformer ? vnodeArgsTransformer(args, currentRenderingInstance) : args
|
8614 | );
|
8615 | };
|
8616 | const InternalObjectKey = `__vInternal`;
|
8617 | const normalizeKey = ({ key }) => key != null ? key : null;
|
8618 | const normalizeRef = ({
|
8619 | ref,
|
8620 | ref_key,
|
8621 | ref_for
|
8622 | }) => {
|
8623 | if (typeof ref === "number") {
|
8624 | ref = "" + ref;
|
8625 | }
|
8626 | return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null;
|
8627 | };
|
8628 | function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
|
8629 | const vnode = {
|
8630 | __v_isVNode: true,
|
8631 | __v_skip: true,
|
8632 | type,
|
8633 | props,
|
8634 | key: props && normalizeKey(props),
|
8635 | ref: props && normalizeRef(props),
|
8636 | scopeId: currentScopeId,
|
8637 | slotScopeIds: null,
|
8638 | children,
|
8639 | component: null,
|
8640 | suspense: null,
|
8641 | ssContent: null,
|
8642 | ssFallback: null,
|
8643 | dirs: null,
|
8644 | transition: null,
|
8645 | el: null,
|
8646 | anchor: null,
|
8647 | target: null,
|
8648 | targetAnchor: null,
|
8649 | staticCount: 0,
|
8650 | shapeFlag,
|
8651 | patchFlag,
|
8652 | dynamicProps,
|
8653 | dynamicChildren: null,
|
8654 | appContext: null,
|
8655 | ctx: currentRenderingInstance
|
8656 | };
|
8657 | if (needFullChildrenNormalization) {
|
8658 | normalizeChildren(vnode, children);
|
8659 | if (shapeFlag & 128) {
|
8660 | type.normalize(vnode);
|
8661 | }
|
8662 | } else if (children) {
|
8663 | vnode.shapeFlag |= isString(children) ? 8 : 16;
|
8664 | }
|
8665 | if (vnode.key !== vnode.key) {
|
8666 | warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
8667 | }
|
8668 | if (isBlockTreeEnabled > 0 &&
|
8669 | !isBlockNode &&
|
8670 | currentBlock &&
|
8671 |
|
8672 |
|
8673 |
|
8674 | (vnode.patchFlag > 0 || shapeFlag & 6) &&
|
8675 |
|
8676 | vnode.patchFlag !== 32) {
|
8677 | currentBlock.push(vnode);
|
8678 | }
|
8679 | return vnode;
|
8680 | }
|
8681 | const createVNode = createVNodeWithArgsTransform ;
|
8682 | function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
8683 | if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
8684 | if (!type) {
|
8685 | warn$1(`Invalid vnode type when creating vnode: ${type}.`);
|
8686 | }
|
8687 | type = Comment;
|
8688 | }
|
8689 | if (isVNode(type)) {
|
8690 | const cloned = cloneVNode(
|
8691 | type,
|
8692 | props,
|
8693 | true
|
8694 |
|
8695 | );
|
8696 | if (children) {
|
8697 | normalizeChildren(cloned, children);
|
8698 | }
|
8699 | if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
|
8700 | if (cloned.shapeFlag & 6) {
|
8701 | currentBlock[currentBlock.indexOf(type)] = cloned;
|
8702 | } else {
|
8703 | currentBlock.push(cloned);
|
8704 | }
|
8705 | }
|
8706 | cloned.patchFlag |= -2;
|
8707 | return cloned;
|
8708 | }
|
8709 | if (isClassComponent(type)) {
|
8710 | type = type.__vccOpts;
|
8711 | }
|
8712 | if (props) {
|
8713 | props = guardReactiveProps(props);
|
8714 | let { class: klass, style } = props;
|
8715 | if (klass && !isString(klass)) {
|
8716 | props.class = normalizeClass(klass);
|
8717 | }
|
8718 | if (isObject(style)) {
|
8719 | if (isProxy(style) && !isArray(style)) {
|
8720 | style = extend({}, style);
|
8721 | }
|
8722 | props.style = normalizeStyle(style);
|
8723 | }
|
8724 | }
|
8725 | const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
|
8726 | if (shapeFlag & 4 && isProxy(type)) {
|
8727 | type = toRaw(type);
|
8728 | warn$1(
|
8729 | `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\`.`,
|
8730 | `
|
8731 | Component that was made reactive: `,
|
8732 | type
|
8733 | );
|
8734 | }
|
8735 | return createBaseVNode(
|
8736 | type,
|
8737 | props,
|
8738 | children,
|
8739 | patchFlag,
|
8740 | dynamicProps,
|
8741 | shapeFlag,
|
8742 | isBlockNode,
|
8743 | true
|
8744 | );
|
8745 | }
|
8746 | function guardReactiveProps(props) {
|
8747 | if (!props)
|
8748 | return null;
|
8749 | return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props;
|
8750 | }
|
8751 | function cloneVNode(vnode, extraProps, mergeRef = false) {
|
8752 | const { props, ref, patchFlag, children } = vnode;
|
8753 | const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
|
8754 | const cloned = {
|
8755 | __v_isVNode: true,
|
8756 | __v_skip: true,
|
8757 | type: vnode.type,
|
8758 | props: mergedProps,
|
8759 | key: mergedProps && normalizeKey(mergedProps),
|
8760 | ref: extraProps && extraProps.ref ? (
|
8761 |
|
8762 |
|
8763 |
|
8764 | mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
|
8765 | ) : ref,
|
8766 | scopeId: vnode.scopeId,
|
8767 | slotScopeIds: vnode.slotScopeIds,
|
8768 | children: patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
|
8769 | target: vnode.target,
|
8770 | targetAnchor: vnode.targetAnchor,
|
8771 | staticCount: vnode.staticCount,
|
8772 | shapeFlag: vnode.shapeFlag,
|
8773 |
|
8774 |
|
8775 |
|
8776 |
|
8777 | patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
|
8778 | dynamicProps: vnode.dynamicProps,
|
8779 | dynamicChildren: vnode.dynamicChildren,
|
8780 | appContext: vnode.appContext,
|
8781 | dirs: vnode.dirs,
|
8782 | transition: vnode.transition,
|
8783 |
|
8784 |
|
8785 |
|
8786 |
|
8787 | component: vnode.component,
|
8788 | suspense: vnode.suspense,
|
8789 | ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
8790 | ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
8791 | el: vnode.el,
|
8792 | anchor: vnode.anchor,
|
8793 | ctx: vnode.ctx,
|
8794 | ce: vnode.ce
|
8795 | };
|
8796 | return cloned;
|
8797 | }
|
8798 | function deepCloneVNode(vnode) {
|
8799 | const cloned = cloneVNode(vnode);
|
8800 | if (isArray(vnode.children)) {
|
8801 | cloned.children = vnode.children.map(deepCloneVNode);
|
8802 | }
|
8803 | return cloned;
|
8804 | }
|
8805 | function createTextVNode(text = " ", flag = 0) {
|
8806 | return createVNode(Text, null, text, flag);
|
8807 | }
|
8808 | function createStaticVNode(content, numberOfNodes) {
|
8809 | const vnode = createVNode(Static, null, content);
|
8810 | vnode.staticCount = numberOfNodes;
|
8811 | return vnode;
|
8812 | }
|
8813 | function createCommentVNode(text = "", asBlock = false) {
|
8814 | return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
|
8815 | }
|
8816 | function normalizeVNode(child) {
|
8817 | if (child == null || typeof child === "boolean") {
|
8818 | return createVNode(Comment);
|
8819 | } else if (isArray(child)) {
|
8820 | return createVNode(
|
8821 | Fragment,
|
8822 | null,
|
8823 |
|
8824 | child.slice()
|
8825 | );
|
8826 | } else if (typeof child === "object") {
|
8827 | return cloneIfMounted(child);
|
8828 | } else {
|
8829 | return createVNode(Text, null, String(child));
|
8830 | }
|
8831 | }
|
8832 | function cloneIfMounted(child) {
|
8833 | return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
|
8834 | }
|
8835 | function normalizeChildren(vnode, children) {
|
8836 | let type = 0;
|
8837 | const { shapeFlag } = vnode;
|
8838 | if (children == null) {
|
8839 | children = null;
|
8840 | } else if (isArray(children)) {
|
8841 | type = 16;
|
8842 | } else if (typeof children === "object") {
|
8843 | if (shapeFlag & (1 | 64)) {
|
8844 | const slot = children.default;
|
8845 | if (slot) {
|
8846 | slot._c && (slot._d = false);
|
8847 | normalizeChildren(vnode, slot());
|
8848 | slot._c && (slot._d = true);
|
8849 | }
|
8850 | return;
|
8851 | } else {
|
8852 | type = 32;
|
8853 | const slotFlag = children._;
|
8854 | if (!slotFlag && !(InternalObjectKey in children)) {
|
8855 | children._ctx = currentRenderingInstance;
|
8856 | } else if (slotFlag === 3 && currentRenderingInstance) {
|
8857 | if (currentRenderingInstance.slots._ === 1) {
|
8858 | children._ = 1;
|
8859 | } else {
|
8860 | children._ = 2;
|
8861 | vnode.patchFlag |= 1024;
|
8862 | }
|
8863 | }
|
8864 | }
|
8865 | } else if (isFunction(children)) {
|
8866 | children = { default: children, _ctx: currentRenderingInstance };
|
8867 | type = 32;
|
8868 | } else {
|
8869 | children = String(children);
|
8870 | if (shapeFlag & 64) {
|
8871 | type = 16;
|
8872 | children = [createTextVNode(children)];
|
8873 | } else {
|
8874 | type = 8;
|
8875 | }
|
8876 | }
|
8877 | vnode.children = children;
|
8878 | vnode.shapeFlag |= type;
|
8879 | }
|
8880 | function mergeProps(...args) {
|
8881 | const ret = {};
|
8882 | for (let i = 0; i < args.length; i++) {
|
8883 | const toMerge = args[i];
|
8884 | for (const key in toMerge) {
|
8885 | if (key === "class") {
|
8886 | if (ret.class !== toMerge.class) {
|
8887 | ret.class = normalizeClass([ret.class, toMerge.class]);
|
8888 | }
|
8889 | } else if (key === "style") {
|
8890 | ret.style = normalizeStyle([ret.style, toMerge.style]);
|
8891 | } else if (isOn(key)) {
|
8892 | const existing = ret[key];
|
8893 | const incoming = toMerge[key];
|
8894 | if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
|
8895 | ret[key] = existing ? [].concat(existing, incoming) : incoming;
|
8896 | }
|
8897 | } else if (key !== "") {
|
8898 | ret[key] = toMerge[key];
|
8899 | }
|
8900 | }
|
8901 | }
|
8902 | return ret;
|
8903 | }
|
8904 | function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
8905 | callWithAsyncErrorHandling(hook, instance, 7, [
|
8906 | vnode,
|
8907 | prevVNode
|
8908 | ]);
|
8909 | }
|
8910 |
|
8911 | const emptyAppContext = createAppContext();
|
8912 | let uid = 0;
|
8913 | function createComponentInstance(vnode, parent, suspense) {
|
8914 | const type = vnode.type;
|
8915 | const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
8916 | const instance = {
|
8917 | uid: uid++,
|
8918 | vnode,
|
8919 | type,
|
8920 | parent,
|
8921 | appContext,
|
8922 | root: null,
|
8923 |
|
8924 | next: null,
|
8925 | subTree: null,
|
8926 |
|
8927 | effect: null,
|
8928 | update: null,
|
8929 |
|
8930 | scope: new EffectScope(
|
8931 | true
|
8932 |
|
8933 | ),
|
8934 | render: null,
|
8935 | proxy: null,
|
8936 | exposed: null,
|
8937 | exposeProxy: null,
|
8938 | withProxy: null,
|
8939 | provides: parent ? parent.provides : Object.create(appContext.provides),
|
8940 | accessCache: null,
|
8941 | renderCache: [],
|
8942 |
|
8943 | components: null,
|
8944 | directives: null,
|
8945 |
|
8946 | propsOptions: normalizePropsOptions(type, appContext),
|
8947 | emitsOptions: normalizeEmitsOptions(type, appContext),
|
8948 |
|
8949 | emit: null,
|
8950 |
|
8951 | emitted: null,
|
8952 |
|
8953 | propsDefaults: EMPTY_OBJ,
|
8954 |
|
8955 | inheritAttrs: type.inheritAttrs,
|
8956 |
|
8957 | ctx: EMPTY_OBJ,
|
8958 | data: EMPTY_OBJ,
|
8959 | props: EMPTY_OBJ,
|
8960 | attrs: EMPTY_OBJ,
|
8961 | slots: EMPTY_OBJ,
|
8962 | refs: EMPTY_OBJ,
|
8963 | setupState: EMPTY_OBJ,
|
8964 | setupContext: null,
|
8965 | attrsProxy: null,
|
8966 | slotsProxy: null,
|
8967 |
|
8968 | suspense,
|
8969 | suspenseId: suspense ? suspense.pendingId : 0,
|
8970 | asyncDep: null,
|
8971 | asyncResolved: false,
|
8972 |
|
8973 |
|
8974 | isMounted: false,
|
8975 | isUnmounted: false,
|
8976 | isDeactivated: false,
|
8977 | bc: null,
|
8978 | c: null,
|
8979 | bm: null,
|
8980 | m: null,
|
8981 | bu: null,
|
8982 | u: null,
|
8983 | um: null,
|
8984 | bum: null,
|
8985 | da: null,
|
8986 | a: null,
|
8987 | rtg: null,
|
8988 | rtc: null,
|
8989 | ec: null,
|
8990 | sp: null
|
8991 | };
|
8992 | {
|
8993 | instance.ctx = createDevRenderContext(instance);
|
8994 | }
|
8995 | instance.root = parent ? parent.root : instance;
|
8996 | instance.emit = emit.bind(null, instance);
|
8997 | if (vnode.ce) {
|
8998 | vnode.ce(instance);
|
8999 | }
|
9000 | return instance;
|
9001 | }
|
9002 | let currentInstance = null;
|
9003 | const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
9004 | let internalSetCurrentInstance;
|
9005 | let setInSSRSetupState;
|
9006 | {
|
9007 | internalSetCurrentInstance = (i) => {
|
9008 | currentInstance = i;
|
9009 | };
|
9010 | setInSSRSetupState = (v) => {
|
9011 | isInSSRComponentSetup = v;
|
9012 | };
|
9013 | }
|
9014 | const setCurrentInstance = (instance) => {
|
9015 | const prev = currentInstance;
|
9016 | internalSetCurrentInstance(instance);
|
9017 | instance.scope.on();
|
9018 | return () => {
|
9019 | instance.scope.off();
|
9020 | internalSetCurrentInstance(prev);
|
9021 | };
|
9022 | };
|
9023 | const unsetCurrentInstance = () => {
|
9024 | currentInstance && currentInstance.scope.off();
|
9025 | internalSetCurrentInstance(null);
|
9026 | };
|
9027 | const isBuiltInTag = makeMap("slot,component");
|
9028 | function validateComponentName(name, config) {
|
9029 | const appIsNativeTag = config.isNativeTag || NO;
|
9030 | if (isBuiltInTag(name) || appIsNativeTag(name)) {
|
9031 | warn$1(
|
9032 | "Do not use built-in or reserved HTML elements as component id: " + name
|
9033 | );
|
9034 | }
|
9035 | }
|
9036 | function isStatefulComponent(instance) {
|
9037 | return instance.vnode.shapeFlag & 4;
|
9038 | }
|
9039 | let isInSSRComponentSetup = false;
|
9040 | function setupComponent(instance, isSSR = false) {
|
9041 | isSSR && setInSSRSetupState(isSSR);
|
9042 | const { props, children } = instance.vnode;
|
9043 | const isStateful = isStatefulComponent(instance);
|
9044 | initProps(instance, props, isStateful, isSSR);
|
9045 | initSlots(instance, children);
|
9046 | const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
|
9047 | isSSR && setInSSRSetupState(false);
|
9048 | return setupResult;
|
9049 | }
|
9050 | function setupStatefulComponent(instance, isSSR) {
|
9051 | var _a;
|
9052 | const Component = instance.type;
|
9053 | {
|
9054 | if (Component.name) {
|
9055 | validateComponentName(Component.name, instance.appContext.config);
|
9056 | }
|
9057 | if (Component.components) {
|
9058 | const names = Object.keys(Component.components);
|
9059 | for (let i = 0; i < names.length; i++) {
|
9060 | validateComponentName(names[i], instance.appContext.config);
|
9061 | }
|
9062 | }
|
9063 | if (Component.directives) {
|
9064 | const names = Object.keys(Component.directives);
|
9065 | for (let i = 0; i < names.length; i++) {
|
9066 | validateDirectiveName(names[i]);
|
9067 | }
|
9068 | }
|
9069 | if (Component.compilerOptions && isRuntimeOnly()) {
|
9070 | warn$1(
|
9071 | `"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.`
|
9072 | );
|
9073 | }
|
9074 | }
|
9075 | instance.accessCache = Object.create(null);
|
9076 | instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
|
9077 | {
|
9078 | exposePropsOnRenderContext(instance);
|
9079 | }
|
9080 | const { setup } = Component;
|
9081 | if (setup) {
|
9082 | const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
|
9083 | const reset = setCurrentInstance(instance);
|
9084 | pauseTracking();
|
9085 | const setupResult = callWithErrorHandling(
|
9086 | setup,
|
9087 | instance,
|
9088 | 0,
|
9089 | [
|
9090 | shallowReadonly(instance.props) ,
|
9091 | setupContext
|
9092 | ]
|
9093 | );
|
9094 | resetTracking();
|
9095 | reset();
|
9096 | if (isPromise(setupResult)) {
|
9097 | setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
|
9098 | if (isSSR) {
|
9099 | return setupResult.then((resolvedResult) => {
|
9100 | handleSetupResult(instance, resolvedResult, isSSR);
|
9101 | }).catch((e) => {
|
9102 | handleError(e, instance, 0);
|
9103 | });
|
9104 | } else {
|
9105 | instance.asyncDep = setupResult;
|
9106 | if (!instance.suspense) {
|
9107 | const name = (_a = Component.name) != null ? _a : "Anonymous";
|
9108 | warn$1(
|
9109 | `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.`
|
9110 | );
|
9111 | }
|
9112 | }
|
9113 | } else {
|
9114 | handleSetupResult(instance, setupResult, isSSR);
|
9115 | }
|
9116 | } else {
|
9117 | finishComponentSetup(instance, isSSR);
|
9118 | }
|
9119 | }
|
9120 | function handleSetupResult(instance, setupResult, isSSR) {
|
9121 | if (isFunction(setupResult)) {
|
9122 | {
|
9123 | instance.render = setupResult;
|
9124 | }
|
9125 | } else if (isObject(setupResult)) {
|
9126 | if (isVNode(setupResult)) {
|
9127 | warn$1(
|
9128 | `setup() should not return VNodes directly - return a render function instead.`
|
9129 | );
|
9130 | }
|
9131 | {
|
9132 | instance.devtoolsRawSetupState = setupResult;
|
9133 | }
|
9134 | instance.setupState = proxyRefs(setupResult);
|
9135 | {
|
9136 | exposeSetupStateOnRenderContext(instance);
|
9137 | }
|
9138 | } else if (setupResult !== void 0) {
|
9139 | warn$1(
|
9140 | `setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`
|
9141 | );
|
9142 | }
|
9143 | finishComponentSetup(instance, isSSR);
|
9144 | }
|
9145 | let compile$1;
|
9146 | let installWithProxy;
|
9147 | function registerRuntimeCompiler(_compile) {
|
9148 | compile$1 = _compile;
|
9149 | installWithProxy = (i) => {
|
9150 | if (i.render._rc) {
|
9151 | i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
|
9152 | }
|
9153 | };
|
9154 | }
|
9155 | const isRuntimeOnly = () => !compile$1;
|
9156 | function finishComponentSetup(instance, isSSR, skipOptions) {
|
9157 | const Component = instance.type;
|
9158 | if (!instance.render) {
|
9159 | if (!isSSR && compile$1 && !Component.render) {
|
9160 | const template = Component.template || resolveMergedOptions(instance).template;
|
9161 | if (template) {
|
9162 | {
|
9163 | startMeasure(instance, `compile`);
|
9164 | }
|
9165 | const { isCustomElement, compilerOptions } = instance.appContext.config;
|
9166 | const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
9167 | const finalCompilerOptions = extend(
|
9168 | extend(
|
9169 | {
|
9170 | isCustomElement,
|
9171 | delimiters
|
9172 | },
|
9173 | compilerOptions
|
9174 | ),
|
9175 | componentCompilerOptions
|
9176 | );
|
9177 | Component.render = compile$1(template, finalCompilerOptions);
|
9178 | {
|
9179 | endMeasure(instance, `compile`);
|
9180 | }
|
9181 | }
|
9182 | }
|
9183 | instance.render = Component.render || NOOP;
|
9184 | if (installWithProxy) {
|
9185 | installWithProxy(instance);
|
9186 | }
|
9187 | }
|
9188 | {
|
9189 | const reset = setCurrentInstance(instance);
|
9190 | pauseTracking();
|
9191 | try {
|
9192 | applyOptions(instance);
|
9193 | } finally {
|
9194 | resetTracking();
|
9195 | reset();
|
9196 | }
|
9197 | }
|
9198 | if (!Component.render && instance.render === NOOP && !isSSR) {
|
9199 | if (!compile$1 && Component.template) {
|
9200 | warn$1(
|
9201 | `Component provided template option but runtime compilation is not supported in this build of Vue.` + (` Use "vue.esm-browser.js" instead.` )
|
9202 | );
|
9203 | } else {
|
9204 | warn$1(`Component is missing template or render function.`);
|
9205 | }
|
9206 | }
|
9207 | }
|
9208 | function getAttrsProxy(instance) {
|
9209 | return instance.attrsProxy || (instance.attrsProxy = new Proxy(
|
9210 | instance.attrs,
|
9211 | {
|
9212 | get(target, key) {
|
9213 | markAttrsAccessed();
|
9214 | track(instance, "get", "$attrs");
|
9215 | return target[key];
|
9216 | },
|
9217 | set() {
|
9218 | warn$1(`setupContext.attrs is readonly.`);
|
9219 | return false;
|
9220 | },
|
9221 | deleteProperty() {
|
9222 | warn$1(`setupContext.attrs is readonly.`);
|
9223 | return false;
|
9224 | }
|
9225 | }
|
9226 | ));
|
9227 | }
|
9228 | function getSlotsProxy(instance) {
|
9229 | return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
|
9230 | get(target, key) {
|
9231 | track(instance, "get", "$slots");
|
9232 | return target[key];
|
9233 | }
|
9234 | }));
|
9235 | }
|
9236 | function createSetupContext(instance) {
|
9237 | const expose = (exposed) => {
|
9238 | {
|
9239 | if (instance.exposed) {
|
9240 | warn$1(`expose() should be called only once per setup().`);
|
9241 | }
|
9242 | if (exposed != null) {
|
9243 | let exposedType = typeof exposed;
|
9244 | if (exposedType === "object") {
|
9245 | if (isArray(exposed)) {
|
9246 | exposedType = "array";
|
9247 | } else if (isRef(exposed)) {
|
9248 | exposedType = "ref";
|
9249 | }
|
9250 | }
|
9251 | if (exposedType !== "object") {
|
9252 | warn$1(
|
9253 | `expose() should be passed a plain object, received ${exposedType}.`
|
9254 | );
|
9255 | }
|
9256 | }
|
9257 | }
|
9258 | instance.exposed = exposed || {};
|
9259 | };
|
9260 | {
|
9261 | return Object.freeze({
|
9262 | get attrs() {
|
9263 | return getAttrsProxy(instance);
|
9264 | },
|
9265 | get slots() {
|
9266 | return getSlotsProxy(instance);
|
9267 | },
|
9268 | get emit() {
|
9269 | return (event, ...args) => instance.emit(event, ...args);
|
9270 | },
|
9271 | expose
|
9272 | });
|
9273 | }
|
9274 | }
|
9275 | function getExposeProxy(instance) {
|
9276 | if (instance.exposed) {
|
9277 | return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
9278 | get(target, key) {
|
9279 | if (key in target) {
|
9280 | return target[key];
|
9281 | } else if (key in publicPropertiesMap) {
|
9282 | return publicPropertiesMap[key](instance);
|
9283 | }
|
9284 | },
|
9285 | has(target, key) {
|
9286 | return key in target || key in publicPropertiesMap;
|
9287 | }
|
9288 | }));
|
9289 | }
|
9290 | }
|
9291 | const classifyRE = /(?:^|[-_])(\w)/g;
|
9292 | const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
9293 | function getComponentName(Component, includeInferred = true) {
|
9294 | return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
9295 | }
|
9296 | function formatComponentName(instance, Component, isRoot = false) {
|
9297 | let name = getComponentName(Component);
|
9298 | if (!name && Component.__file) {
|
9299 | const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
9300 | if (match) {
|
9301 | name = match[1];
|
9302 | }
|
9303 | }
|
9304 | if (!name && instance && instance.parent) {
|
9305 | const inferFromRegistry = (registry) => {
|
9306 | for (const key in registry) {
|
9307 | if (registry[key] === Component) {
|
9308 | return key;
|
9309 | }
|
9310 | }
|
9311 | };
|
9312 | name = inferFromRegistry(
|
9313 | instance.components || instance.parent.type.components
|
9314 | ) || inferFromRegistry(instance.appContext.components);
|
9315 | }
|
9316 | return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
9317 | }
|
9318 | function isClassComponent(value) {
|
9319 | return isFunction(value) && "__vccOpts" in value;
|
9320 | }
|
9321 |
|
9322 | const computed = (getterOrOptions, debugOptions) => {
|
9323 | return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
|
9324 | };
|
9325 |
|
9326 | function useModel(props, name, options = EMPTY_OBJ) {
|
9327 | const i = getCurrentInstance();
|
9328 | if (!i) {
|
9329 | warn$1(`useModel() called without active instance.`);
|
9330 | return ref();
|
9331 | }
|
9332 | if (!i.propsOptions[0][name]) {
|
9333 | warn$1(`useModel() called with prop "${name}" which is not declared.`);
|
9334 | return ref();
|
9335 | }
|
9336 | const camelizedName = camelize(name);
|
9337 | const hyphenatedName = hyphenate(name);
|
9338 | const res = customRef((track, trigger) => {
|
9339 | let localValue;
|
9340 | watchSyncEffect(() => {
|
9341 | const propValue = props[name];
|
9342 | if (hasChanged(localValue, propValue)) {
|
9343 | localValue = propValue;
|
9344 | trigger();
|
9345 | }
|
9346 | });
|
9347 | return {
|
9348 | get() {
|
9349 | track();
|
9350 | return options.get ? options.get(localValue) : localValue;
|
9351 | },
|
9352 | set(value) {
|
9353 | const rawProps = i.vnode.props;
|
9354 | if (!(rawProps &&
|
9355 | (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
|
9356 | localValue = value;
|
9357 | trigger();
|
9358 | }
|
9359 | i.emit(`update:${name}`, options.set ? options.set(value) : value);
|
9360 | }
|
9361 | };
|
9362 | });
|
9363 | const modifierKey = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
|
9364 | res[Symbol.iterator] = () => {
|
9365 | let i2 = 0;
|
9366 | return {
|
9367 | next() {
|
9368 | if (i2 < 2) {
|
9369 | return { value: i2++ ? props[modifierKey] || {} : res, done: false };
|
9370 | } else {
|
9371 | return { done: true };
|
9372 | }
|
9373 | }
|
9374 | };
|
9375 | };
|
9376 | return res;
|
9377 | }
|
9378 |
|
9379 | function h(type, propsOrChildren, children) {
|
9380 | const l = arguments.length;
|
9381 | if (l === 2) {
|
9382 | if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
|
9383 | if (isVNode(propsOrChildren)) {
|
9384 | return createVNode(type, null, [propsOrChildren]);
|
9385 | }
|
9386 | return createVNode(type, propsOrChildren);
|
9387 | } else {
|
9388 | return createVNode(type, null, propsOrChildren);
|
9389 | }
|
9390 | } else {
|
9391 | if (l > 3) {
|
9392 | children = Array.prototype.slice.call(arguments, 2);
|
9393 | } else if (l === 3 && isVNode(children)) {
|
9394 | children = [children];
|
9395 | }
|
9396 | return createVNode(type, propsOrChildren, children);
|
9397 | }
|
9398 | }
|
9399 |
|
9400 | function initCustomFormatter() {
|
9401 | if (typeof window === "undefined") {
|
9402 | return;
|
9403 | }
|
9404 | const vueStyle = { style: "color:#3ba776" };
|
9405 | const numberStyle = { style: "color:#1677ff" };
|
9406 | const stringStyle = { style: "color:#f5222d" };
|
9407 | const keywordStyle = { style: "color:#eb2f96" };
|
9408 | const formatter = {
|
9409 | header(obj) {
|
9410 | if (!isObject(obj)) {
|
9411 | return null;
|
9412 | }
|
9413 | if (obj.__isVue) {
|
9414 | return ["div", vueStyle, `VueInstance`];
|
9415 | } else if (isRef(obj)) {
|
9416 | return [
|
9417 | "div",
|
9418 | {},
|
9419 | ["span", vueStyle, genRefFlag(obj)],
|
9420 | "<",
|
9421 | formatValue(obj.value),
|
9422 | `>`
|
9423 | ];
|
9424 | } else if (isReactive(obj)) {
|
9425 | return [
|
9426 | "div",
|
9427 | {},
|
9428 | ["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
|
9429 | "<",
|
9430 | formatValue(obj),
|
9431 | `>${isReadonly(obj) ? ` (readonly)` : ``}`
|
9432 | ];
|
9433 | } else if (isReadonly(obj)) {
|
9434 | return [
|
9435 | "div",
|
9436 | {},
|
9437 | ["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
|
9438 | "<",
|
9439 | formatValue(obj),
|
9440 | ">"
|
9441 | ];
|
9442 | }
|
9443 | return null;
|
9444 | },
|
9445 | hasBody(obj) {
|
9446 | return obj && obj.__isVue;
|
9447 | },
|
9448 | body(obj) {
|
9449 | if (obj && obj.__isVue) {
|
9450 | return [
|
9451 | "div",
|
9452 | {},
|
9453 | ...formatInstance(obj.$)
|
9454 | ];
|
9455 | }
|
9456 | }
|
9457 | };
|
9458 | function formatInstance(instance) {
|
9459 | const blocks = [];
|
9460 | if (instance.type.props && instance.props) {
|
9461 | blocks.push(createInstanceBlock("props", toRaw(instance.props)));
|
9462 | }
|
9463 | if (instance.setupState !== EMPTY_OBJ) {
|
9464 | blocks.push(createInstanceBlock("setup", instance.setupState));
|
9465 | }
|
9466 | if (instance.data !== EMPTY_OBJ) {
|
9467 | blocks.push(createInstanceBlock("data", toRaw(instance.data)));
|
9468 | }
|
9469 | const computed = extractKeys(instance, "computed");
|
9470 | if (computed) {
|
9471 | blocks.push(createInstanceBlock("computed", computed));
|
9472 | }
|
9473 | const injected = extractKeys(instance, "inject");
|
9474 | if (injected) {
|
9475 | blocks.push(createInstanceBlock("injected", injected));
|
9476 | }
|
9477 | blocks.push([
|
9478 | "div",
|
9479 | {},
|
9480 | [
|
9481 | "span",
|
9482 | {
|
9483 | style: keywordStyle.style + ";opacity:0.66"
|
9484 | },
|
9485 | "$ (internal): "
|
9486 | ],
|
9487 | ["object", { object: instance }]
|
9488 | ]);
|
9489 | return blocks;
|
9490 | }
|
9491 | function createInstanceBlock(type, target) {
|
9492 | target = extend({}, target);
|
9493 | if (!Object.keys(target).length) {
|
9494 | return ["span", {}];
|
9495 | }
|
9496 | return [
|
9497 | "div",
|
9498 | { style: "line-height:1.25em;margin-bottom:0.6em" },
|
9499 | [
|
9500 | "div",
|
9501 | {
|
9502 | style: "color:#476582"
|
9503 | },
|
9504 | type
|
9505 | ],
|
9506 | [
|
9507 | "div",
|
9508 | {
|
9509 | style: "padding-left:1.25em"
|
9510 | },
|
9511 | ...Object.keys(target).map((key) => {
|
9512 | return [
|
9513 | "div",
|
9514 | {},
|
9515 | ["span", keywordStyle, key + ": "],
|
9516 | formatValue(target[key], false)
|
9517 | ];
|
9518 | })
|
9519 | ]
|
9520 | ];
|
9521 | }
|
9522 | function formatValue(v, asRaw = true) {
|
9523 | if (typeof v === "number") {
|
9524 | return ["span", numberStyle, v];
|
9525 | } else if (typeof v === "string") {
|
9526 | return ["span", stringStyle, JSON.stringify(v)];
|
9527 | } else if (typeof v === "boolean") {
|
9528 | return ["span", keywordStyle, v];
|
9529 | } else if (isObject(v)) {
|
9530 | return ["object", { object: asRaw ? toRaw(v) : v }];
|
9531 | } else {
|
9532 | return ["span", stringStyle, String(v)];
|
9533 | }
|
9534 | }
|
9535 | function extractKeys(instance, type) {
|
9536 | const Comp = instance.type;
|
9537 | if (isFunction(Comp)) {
|
9538 | return;
|
9539 | }
|
9540 | const extracted = {};
|
9541 | for (const key in instance.ctx) {
|
9542 | if (isKeyOfType(Comp, key, type)) {
|
9543 | extracted[key] = instance.ctx[key];
|
9544 | }
|
9545 | }
|
9546 | return extracted;
|
9547 | }
|
9548 | function isKeyOfType(Comp, key, type) {
|
9549 | const opts = Comp[type];
|
9550 | if (isArray(opts) && opts.includes(key) || isObject(opts) && key in opts) {
|
9551 | return true;
|
9552 | }
|
9553 | if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
|
9554 | return true;
|
9555 | }
|
9556 | if (Comp.mixins && Comp.mixins.some((m) => isKeyOfType(m, key, type))) {
|
9557 | return true;
|
9558 | }
|
9559 | }
|
9560 | function genRefFlag(v) {
|
9561 | if (isShallow(v)) {
|
9562 | return `ShallowRef`;
|
9563 | }
|
9564 | if (v.effect) {
|
9565 | return `ComputedRef`;
|
9566 | }
|
9567 | return `Ref`;
|
9568 | }
|
9569 | if (window.devtoolsFormatters) {
|
9570 | window.devtoolsFormatters.push(formatter);
|
9571 | } else {
|
9572 | window.devtoolsFormatters = [formatter];
|
9573 | }
|
9574 | }
|
9575 |
|
9576 | function withMemo(memo, render, cache, index) {
|
9577 | const cached = cache[index];
|
9578 | if (cached && isMemoSame(cached, memo)) {
|
9579 | return cached;
|
9580 | }
|
9581 | const ret = render();
|
9582 | ret.memo = memo.slice();
|
9583 | return cache[index] = ret;
|
9584 | }
|
9585 | function isMemoSame(cached, memo) {
|
9586 | const prev = cached.memo;
|
9587 | if (prev.length != memo.length) {
|
9588 | return false;
|
9589 | }
|
9590 | for (let i = 0; i < prev.length; i++) {
|
9591 | if (hasChanged(prev[i], memo[i])) {
|
9592 | return false;
|
9593 | }
|
9594 | }
|
9595 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
9596 | currentBlock.push(cached);
|
9597 | }
|
9598 | return true;
|
9599 | }
|
9600 |
|
9601 | const version = "3.4.19";
|
9602 | const warn = warn$1 ;
|
9603 | const ErrorTypeStrings = ErrorTypeStrings$1 ;
|
9604 | const devtools = devtools$1 ;
|
9605 | const setDevtoolsHook = setDevtoolsHook$1 ;
|
9606 | const ssrUtils = null;
|
9607 | const resolveFilter = null;
|
9608 | const compatUtils = null;
|
9609 | const DeprecationTypes = null;
|
9610 |
|
9611 | const svgNS = "http://www.w3.org/2000/svg";
|
9612 | const mathmlNS = "http://www.w3.org/1998/Math/MathML";
|
9613 | const doc = typeof document !== "undefined" ? document : null;
|
9614 | const templateContainer = doc && doc.createElement("template");
|
9615 | const nodeOps = {
|
9616 | insert: (child, parent, anchor) => {
|
9617 | parent.insertBefore(child, anchor || null);
|
9618 | },
|
9619 | remove: (child) => {
|
9620 | const parent = child.parentNode;
|
9621 | if (parent) {
|
9622 | parent.removeChild(child);
|
9623 | }
|
9624 | },
|
9625 | createElement: (tag, namespace, is, props) => {
|
9626 | const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0);
|
9627 | if (tag === "select" && props && props.multiple != null) {
|
9628 | el.setAttribute("multiple", props.multiple);
|
9629 | }
|
9630 | return el;
|
9631 | },
|
9632 | createText: (text) => doc.createTextNode(text),
|
9633 | createComment: (text) => doc.createComment(text),
|
9634 | setText: (node, text) => {
|
9635 | node.nodeValue = text;
|
9636 | },
|
9637 | setElementText: (el, text) => {
|
9638 | el.textContent = text;
|
9639 | },
|
9640 | parentNode: (node) => node.parentNode,
|
9641 | nextSibling: (node) => node.nextSibling,
|
9642 | querySelector: (selector) => doc.querySelector(selector),
|
9643 | setScopeId(el, id) {
|
9644 | el.setAttribute(id, "");
|
9645 | },
|
9646 |
|
9647 |
|
9648 |
|
9649 |
|
9650 | insertStaticContent(content, parent, anchor, namespace, start, end) {
|
9651 | const before = anchor ? anchor.previousSibling : parent.lastChild;
|
9652 | if (start && (start === end || start.nextSibling)) {
|
9653 | while (true) {
|
9654 | parent.insertBefore(start.cloneNode(true), anchor);
|
9655 | if (start === end || !(start = start.nextSibling))
|
9656 | break;
|
9657 | }
|
9658 | } else {
|
9659 | templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content;
|
9660 | const template = templateContainer.content;
|
9661 | if (namespace === "svg" || namespace === "mathml") {
|
9662 | const wrapper = template.firstChild;
|
9663 | while (wrapper.firstChild) {
|
9664 | template.appendChild(wrapper.firstChild);
|
9665 | }
|
9666 | template.removeChild(wrapper);
|
9667 | }
|
9668 | parent.insertBefore(template, anchor);
|
9669 | }
|
9670 | return [
|
9671 |
|
9672 | before ? before.nextSibling : parent.firstChild,
|
9673 |
|
9674 | anchor ? anchor.previousSibling : parent.lastChild
|
9675 | ];
|
9676 | }
|
9677 | };
|
9678 |
|
9679 | const TRANSITION$1 = "transition";
|
9680 | const ANIMATION = "animation";
|
9681 | const vtcKey = Symbol("_vtc");
|
9682 | const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
|
9683 | Transition.displayName = "Transition";
|
9684 | const DOMTransitionPropsValidators = {
|
9685 | name: String,
|
9686 | type: String,
|
9687 | css: {
|
9688 | type: Boolean,
|
9689 | default: true
|
9690 | },
|
9691 | duration: [String, Number, Object],
|
9692 | enterFromClass: String,
|
9693 | enterActiveClass: String,
|
9694 | enterToClass: String,
|
9695 | appearFromClass: String,
|
9696 | appearActiveClass: String,
|
9697 | appearToClass: String,
|
9698 | leaveFromClass: String,
|
9699 | leaveActiveClass: String,
|
9700 | leaveToClass: String
|
9701 | };
|
9702 | const TransitionPropsValidators = Transition.props = extend(
|
9703 | {},
|
9704 | BaseTransitionPropsValidators,
|
9705 | DOMTransitionPropsValidators
|
9706 | );
|
9707 | const callHook = (hook, args = []) => {
|
9708 | if (isArray(hook)) {
|
9709 | hook.forEach((h2) => h2(...args));
|
9710 | } else if (hook) {
|
9711 | hook(...args);
|
9712 | }
|
9713 | };
|
9714 | const hasExplicitCallback = (hook) => {
|
9715 | return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
|
9716 | };
|
9717 | function resolveTransitionProps(rawProps) {
|
9718 | const baseProps = {};
|
9719 | for (const key in rawProps) {
|
9720 | if (!(key in DOMTransitionPropsValidators)) {
|
9721 | baseProps[key] = rawProps[key];
|
9722 | }
|
9723 | }
|
9724 | if (rawProps.css === false) {
|
9725 | return baseProps;
|
9726 | }
|
9727 | const {
|
9728 | name = "v",
|
9729 | type,
|
9730 | duration,
|
9731 | enterFromClass = `${name}-enter-from`,
|
9732 | enterActiveClass = `${name}-enter-active`,
|
9733 | enterToClass = `${name}-enter-to`,
|
9734 | appearFromClass = enterFromClass,
|
9735 | appearActiveClass = enterActiveClass,
|
9736 | appearToClass = enterToClass,
|
9737 | leaveFromClass = `${name}-leave-from`,
|
9738 | leaveActiveClass = `${name}-leave-active`,
|
9739 | leaveToClass = `${name}-leave-to`
|
9740 | } = rawProps;
|
9741 | const durations = normalizeDuration(duration);
|
9742 | const enterDuration = durations && durations[0];
|
9743 | const leaveDuration = durations && durations[1];
|
9744 | const {
|
9745 | onBeforeEnter,
|
9746 | onEnter,
|
9747 | onEnterCancelled,
|
9748 | onLeave,
|
9749 | onLeaveCancelled,
|
9750 | onBeforeAppear = onBeforeEnter,
|
9751 | onAppear = onEnter,
|
9752 | onAppearCancelled = onEnterCancelled
|
9753 | } = baseProps;
|
9754 | const finishEnter = (el, isAppear, done) => {
|
9755 | removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
9756 | removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
|
9757 | done && done();
|
9758 | };
|
9759 | const finishLeave = (el, done) => {
|
9760 | el._isLeaving = false;
|
9761 | removeTransitionClass(el, leaveFromClass);
|
9762 | removeTransitionClass(el, leaveToClass);
|
9763 | removeTransitionClass(el, leaveActiveClass);
|
9764 | done && done();
|
9765 | };
|
9766 | const makeEnterHook = (isAppear) => {
|
9767 | return (el, done) => {
|
9768 | const hook = isAppear ? onAppear : onEnter;
|
9769 | const resolve = () => finishEnter(el, isAppear, done);
|
9770 | callHook(hook, [el, resolve]);
|
9771 | nextFrame(() => {
|
9772 | removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
|
9773 | addTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
9774 | if (!hasExplicitCallback(hook)) {
|
9775 | whenTransitionEnds(el, type, enterDuration, resolve);
|
9776 | }
|
9777 | });
|
9778 | };
|
9779 | };
|
9780 | return extend(baseProps, {
|
9781 | onBeforeEnter(el) {
|
9782 | callHook(onBeforeEnter, [el]);
|
9783 | addTransitionClass(el, enterFromClass);
|
9784 | addTransitionClass(el, enterActiveClass);
|
9785 | },
|
9786 | onBeforeAppear(el) {
|
9787 | callHook(onBeforeAppear, [el]);
|
9788 | addTransitionClass(el, appearFromClass);
|
9789 | addTransitionClass(el, appearActiveClass);
|
9790 | },
|
9791 | onEnter: makeEnterHook(false),
|
9792 | onAppear: makeEnterHook(true),
|
9793 | onLeave(el, done) {
|
9794 | el._isLeaving = true;
|
9795 | const resolve = () => finishLeave(el, done);
|
9796 | addTransitionClass(el, leaveFromClass);
|
9797 | forceReflow();
|
9798 | addTransitionClass(el, leaveActiveClass);
|
9799 | nextFrame(() => {
|
9800 | if (!el._isLeaving) {
|
9801 | return;
|
9802 | }
|
9803 | removeTransitionClass(el, leaveFromClass);
|
9804 | addTransitionClass(el, leaveToClass);
|
9805 | if (!hasExplicitCallback(onLeave)) {
|
9806 | whenTransitionEnds(el, type, leaveDuration, resolve);
|
9807 | }
|
9808 | });
|
9809 | callHook(onLeave, [el, resolve]);
|
9810 | },
|
9811 | onEnterCancelled(el) {
|
9812 | finishEnter(el, false);
|
9813 | callHook(onEnterCancelled, [el]);
|
9814 | },
|
9815 | onAppearCancelled(el) {
|
9816 | finishEnter(el, true);
|
9817 | callHook(onAppearCancelled, [el]);
|
9818 | },
|
9819 | onLeaveCancelled(el) {
|
9820 | finishLeave(el);
|
9821 | callHook(onLeaveCancelled, [el]);
|
9822 | }
|
9823 | });
|
9824 | }
|
9825 | function normalizeDuration(duration) {
|
9826 | if (duration == null) {
|
9827 | return null;
|
9828 | } else if (isObject(duration)) {
|
9829 | return [NumberOf(duration.enter), NumberOf(duration.leave)];
|
9830 | } else {
|
9831 | const n = NumberOf(duration);
|
9832 | return [n, n];
|
9833 | }
|
9834 | }
|
9835 | function NumberOf(val) {
|
9836 | const res = toNumber(val);
|
9837 | {
|
9838 | assertNumber(res, "<transition> explicit duration");
|
9839 | }
|
9840 | return res;
|
9841 | }
|
9842 | function addTransitionClass(el, cls) {
|
9843 | cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
|
9844 | (el[vtcKey] || (el[vtcKey] = new Set())).add(cls);
|
9845 | }
|
9846 | function removeTransitionClass(el, cls) {
|
9847 | cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
|
9848 | const _vtc = el[vtcKey];
|
9849 | if (_vtc) {
|
9850 | _vtc.delete(cls);
|
9851 | if (!_vtc.size) {
|
9852 | el[vtcKey] = void 0;
|
9853 | }
|
9854 | }
|
9855 | }
|
9856 | function nextFrame(cb) {
|
9857 | requestAnimationFrame(() => {
|
9858 | requestAnimationFrame(cb);
|
9859 | });
|
9860 | }
|
9861 | let endId = 0;
|
9862 | function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
|
9863 | const id = el._endId = ++endId;
|
9864 | const resolveIfNotStale = () => {
|
9865 | if (id === el._endId) {
|
9866 | resolve();
|
9867 | }
|
9868 | };
|
9869 | if (explicitTimeout) {
|
9870 | return setTimeout(resolveIfNotStale, explicitTimeout);
|
9871 | }
|
9872 | const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
|
9873 | if (!type) {
|
9874 | return resolve();
|
9875 | }
|
9876 | const endEvent = type + "end";
|
9877 | let ended = 0;
|
9878 | const end = () => {
|
9879 | el.removeEventListener(endEvent, onEnd);
|
9880 | resolveIfNotStale();
|
9881 | };
|
9882 | const onEnd = (e) => {
|
9883 | if (e.target === el && ++ended >= propCount) {
|
9884 | end();
|
9885 | }
|
9886 | };
|
9887 | setTimeout(() => {
|
9888 | if (ended < propCount) {
|
9889 | end();
|
9890 | }
|
9891 | }, timeout + 1);
|
9892 | el.addEventListener(endEvent, onEnd);
|
9893 | }
|
9894 | function getTransitionInfo(el, expectedType) {
|
9895 | const styles = window.getComputedStyle(el);
|
9896 | const getStyleProperties = (key) => (styles[key] || "").split(", ");
|
9897 | const transitionDelays = getStyleProperties(`${TRANSITION$1}Delay`);
|
9898 | const transitionDurations = getStyleProperties(`${TRANSITION$1}Duration`);
|
9899 | const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
|
9900 | const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
|
9901 | const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
|
9902 | const animationTimeout = getTimeout(animationDelays, animationDurations);
|
9903 | let type = null;
|
9904 | let timeout = 0;
|
9905 | let propCount = 0;
|
9906 | if (expectedType === TRANSITION$1) {
|
9907 | if (transitionTimeout > 0) {
|
9908 | type = TRANSITION$1;
|
9909 | timeout = transitionTimeout;
|
9910 | propCount = transitionDurations.length;
|
9911 | }
|
9912 | } else if (expectedType === ANIMATION) {
|
9913 | if (animationTimeout > 0) {
|
9914 | type = ANIMATION;
|
9915 | timeout = animationTimeout;
|
9916 | propCount = animationDurations.length;
|
9917 | }
|
9918 | } else {
|
9919 | timeout = Math.max(transitionTimeout, animationTimeout);
|
9920 | type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION$1 : ANIMATION : null;
|
9921 | propCount = type ? type === TRANSITION$1 ? transitionDurations.length : animationDurations.length : 0;
|
9922 | }
|
9923 | const hasTransform = type === TRANSITION$1 && /\b(transform|all)(,|$)/.test(
|
9924 | getStyleProperties(`${TRANSITION$1}Property`).toString()
|
9925 | );
|
9926 | return {
|
9927 | type,
|
9928 | timeout,
|
9929 | propCount,
|
9930 | hasTransform
|
9931 | };
|
9932 | }
|
9933 | function getTimeout(delays, durations) {
|
9934 | while (delays.length < durations.length) {
|
9935 | delays = delays.concat(delays);
|
9936 | }
|
9937 | return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
|
9938 | }
|
9939 | function toMs(s) {
|
9940 | if (s === "auto")
|
9941 | return 0;
|
9942 | return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
|
9943 | }
|
9944 | function forceReflow() {
|
9945 | return document.body.offsetHeight;
|
9946 | }
|
9947 |
|
9948 | function patchClass(el, value, isSVG) {
|
9949 | const transitionClasses = el[vtcKey];
|
9950 | if (transitionClasses) {
|
9951 | value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
|
9952 | }
|
9953 | if (value == null) {
|
9954 | el.removeAttribute("class");
|
9955 | } else if (isSVG) {
|
9956 | el.setAttribute("class", value);
|
9957 | } else {
|
9958 | el.className = value;
|
9959 | }
|
9960 | }
|
9961 |
|
9962 | const vShowOldKey = Symbol("_vod");
|
9963 | const vShow = {
|
9964 | beforeMount(el, { value }, { transition }) {
|
9965 | el[vShowOldKey] = el.style.display === "none" ? "" : el.style.display;
|
9966 | if (transition && value) {
|
9967 | transition.beforeEnter(el);
|
9968 | } else {
|
9969 | setDisplay(el, value);
|
9970 | }
|
9971 | },
|
9972 | mounted(el, { value }, { transition }) {
|
9973 | if (transition && value) {
|
9974 | transition.enter(el);
|
9975 | }
|
9976 | },
|
9977 | updated(el, { value, oldValue }, { transition }) {
|
9978 | if (!value === !oldValue && (el.style.display === el[vShowOldKey] || !value))
|
9979 | return;
|
9980 | if (transition) {
|
9981 | if (value) {
|
9982 | transition.beforeEnter(el);
|
9983 | setDisplay(el, true);
|
9984 | transition.enter(el);
|
9985 | } else {
|
9986 | transition.leave(el, () => {
|
9987 | setDisplay(el, false);
|
9988 | });
|
9989 | }
|
9990 | } else {
|
9991 | setDisplay(el, value);
|
9992 | }
|
9993 | },
|
9994 | beforeUnmount(el, { value }) {
|
9995 | setDisplay(el, value);
|
9996 | }
|
9997 | };
|
9998 | {
|
9999 | vShow.name = "show";
|
10000 | }
|
10001 | function setDisplay(el, value) {
|
10002 | el.style.display = value ? el[vShowOldKey] : "none";
|
10003 | }
|
10004 |
|
10005 | const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT" );
|
10006 | function useCssVars(getter) {
|
10007 | const instance = getCurrentInstance();
|
10008 | if (!instance) {
|
10009 | warn(`useCssVars is called without current active component instance.`);
|
10010 | return;
|
10011 | }
|
10012 | const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
|
10013 | Array.from(
|
10014 | document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
|
10015 | ).forEach((node) => setVarsOnNode(node, vars));
|
10016 | };
|
10017 | {
|
10018 | instance.getCssVars = () => getter(instance.proxy);
|
10019 | }
|
10020 | const setVars = () => {
|
10021 | const vars = getter(instance.proxy);
|
10022 | setVarsOnVNode(instance.subTree, vars);
|
10023 | updateTeleports(vars);
|
10024 | };
|
10025 | watchPostEffect(setVars);
|
10026 | onMounted(() => {
|
10027 | const ob = new MutationObserver(setVars);
|
10028 | ob.observe(instance.subTree.el.parentNode, { childList: true });
|
10029 | onUnmounted(() => ob.disconnect());
|
10030 | });
|
10031 | }
|
10032 | function setVarsOnVNode(vnode, vars) {
|
10033 | if (vnode.shapeFlag & 128) {
|
10034 | const suspense = vnode.suspense;
|
10035 | vnode = suspense.activeBranch;
|
10036 | if (suspense.pendingBranch && !suspense.isHydrating) {
|
10037 | suspense.effects.push(() => {
|
10038 | setVarsOnVNode(suspense.activeBranch, vars);
|
10039 | });
|
10040 | }
|
10041 | }
|
10042 | while (vnode.component) {
|
10043 | vnode = vnode.component.subTree;
|
10044 | }
|
10045 | if (vnode.shapeFlag & 1 && vnode.el) {
|
10046 | setVarsOnNode(vnode.el, vars);
|
10047 | } else if (vnode.type === Fragment) {
|
10048 | vnode.children.forEach((c) => setVarsOnVNode(c, vars));
|
10049 | } else if (vnode.type === Static) {
|
10050 | let { el, anchor } = vnode;
|
10051 | while (el) {
|
10052 | setVarsOnNode(el, vars);
|
10053 | if (el === anchor)
|
10054 | break;
|
10055 | el = el.nextSibling;
|
10056 | }
|
10057 | }
|
10058 | }
|
10059 | function setVarsOnNode(el, vars) {
|
10060 | if (el.nodeType === 1) {
|
10061 | const style = el.style;
|
10062 | let cssText = "";
|
10063 | for (const key in vars) {
|
10064 | style.setProperty(`--${key}`, vars[key]);
|
10065 | cssText += `--${key}: ${vars[key]};`;
|
10066 | }
|
10067 | style[CSS_VAR_TEXT] = cssText;
|
10068 | }
|
10069 | }
|
10070 |
|
10071 | const displayRE = /(^|;)\s*display\s*:/;
|
10072 | function patchStyle(el, prev, next) {
|
10073 | const style = el.style;
|
10074 | const isCssString = isString(next);
|
10075 | const currentDisplay = style.display;
|
10076 | let hasControlledDisplay = false;
|
10077 | if (next && !isCssString) {
|
10078 | if (prev && !isString(prev)) {
|
10079 | for (const key in prev) {
|
10080 | if (next[key] == null) {
|
10081 | setStyle(style, key, "");
|
10082 | }
|
10083 | }
|
10084 | }
|
10085 | for (const key in next) {
|
10086 | if (key === "display") {
|
10087 | hasControlledDisplay = true;
|
10088 | }
|
10089 | setStyle(style, key, next[key]);
|
10090 | }
|
10091 | } else {
|
10092 | if (isCssString) {
|
10093 | if (prev !== next) {
|
10094 | const cssVarText = style[CSS_VAR_TEXT];
|
10095 | if (cssVarText) {
|
10096 | next += ";" + cssVarText;
|
10097 | }
|
10098 | style.cssText = next;
|
10099 | hasControlledDisplay = displayRE.test(next);
|
10100 | }
|
10101 | } else if (prev) {
|
10102 | el.removeAttribute("style");
|
10103 | }
|
10104 | }
|
10105 | if (vShowOldKey in el) {
|
10106 | el[vShowOldKey] = hasControlledDisplay ? style.display : "";
|
10107 | style.display = currentDisplay;
|
10108 | }
|
10109 | }
|
10110 | const semicolonRE = /[^\\];\s*$/;
|
10111 | const importantRE = /\s*!important$/;
|
10112 | function setStyle(style, name, val) {
|
10113 | if (isArray(val)) {
|
10114 | val.forEach((v) => setStyle(style, name, v));
|
10115 | } else {
|
10116 | if (val == null)
|
10117 | val = "";
|
10118 | {
|
10119 | if (semicolonRE.test(val)) {
|
10120 | warn(
|
10121 | `Unexpected semicolon at the end of '${name}' style value: '${val}'`
|
10122 | );
|
10123 | }
|
10124 | }
|
10125 | if (name.startsWith("--")) {
|
10126 | style.setProperty(name, val);
|
10127 | } else {
|
10128 | const prefixed = autoPrefix(style, name);
|
10129 | if (importantRE.test(val)) {
|
10130 | style.setProperty(
|
10131 | hyphenate(prefixed),
|
10132 | val.replace(importantRE, ""),
|
10133 | "important"
|
10134 | );
|
10135 | } else {
|
10136 | style[prefixed] = val;
|
10137 | }
|
10138 | }
|
10139 | }
|
10140 | }
|
10141 | const prefixes = ["Webkit", "Moz", "ms"];
|
10142 | const prefixCache = {};
|
10143 | function autoPrefix(style, rawName) {
|
10144 | const cached = prefixCache[rawName];
|
10145 | if (cached) {
|
10146 | return cached;
|
10147 | }
|
10148 | let name = camelize(rawName);
|
10149 | if (name !== "filter" && name in style) {
|
10150 | return prefixCache[rawName] = name;
|
10151 | }
|
10152 | name = capitalize(name);
|
10153 | for (let i = 0; i < prefixes.length; i++) {
|
10154 | const prefixed = prefixes[i] + name;
|
10155 | if (prefixed in style) {
|
10156 | return prefixCache[rawName] = prefixed;
|
10157 | }
|
10158 | }
|
10159 | return rawName;
|
10160 | }
|
10161 |
|
10162 | const xlinkNS = "http://www.w3.org/1999/xlink";
|
10163 | function patchAttr(el, key, value, isSVG, instance) {
|
10164 | if (isSVG && key.startsWith("xlink:")) {
|
10165 | if (value == null) {
|
10166 | el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
10167 | } else {
|
10168 | el.setAttributeNS(xlinkNS, key, value);
|
10169 | }
|
10170 | } else {
|
10171 | const isBoolean = isSpecialBooleanAttr(key);
|
10172 | if (value == null || isBoolean && !includeBooleanAttr(value)) {
|
10173 | el.removeAttribute(key);
|
10174 | } else {
|
10175 | el.setAttribute(key, isBoolean ? "" : value);
|
10176 | }
|
10177 | }
|
10178 | }
|
10179 |
|
10180 | function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
|
10181 | if (key === "innerHTML" || key === "textContent") {
|
10182 | if (prevChildren) {
|
10183 | unmountChildren(prevChildren, parentComponent, parentSuspense);
|
10184 | }
|
10185 | el[key] = value == null ? "" : value;
|
10186 | return;
|
10187 | }
|
10188 | const tag = el.tagName;
|
10189 | if (key === "value" && tag !== "PROGRESS" &&
|
10190 | !tag.includes("-")) {
|
10191 | el._value = value;
|
10192 | const oldValue = tag === "OPTION" ? el.getAttribute("value") : el.value;
|
10193 | const newValue = value == null ? "" : value;
|
10194 | if (oldValue !== newValue) {
|
10195 | el.value = newValue;
|
10196 | }
|
10197 | if (value == null) {
|
10198 | el.removeAttribute(key);
|
10199 | }
|
10200 | return;
|
10201 | }
|
10202 | let needRemove = false;
|
10203 | if (value === "" || value == null) {
|
10204 | const type = typeof el[key];
|
10205 | if (type === "boolean") {
|
10206 | value = includeBooleanAttr(value);
|
10207 | } else if (value == null && type === "string") {
|
10208 | value = "";
|
10209 | needRemove = true;
|
10210 | } else if (type === "number") {
|
10211 | value = 0;
|
10212 | needRemove = true;
|
10213 | }
|
10214 | }
|
10215 | try {
|
10216 | el[key] = value;
|
10217 | } catch (e) {
|
10218 | if (!needRemove) {
|
10219 | warn(
|
10220 | `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
|
10221 | e
|
10222 | );
|
10223 | }
|
10224 | }
|
10225 | needRemove && el.removeAttribute(key);
|
10226 | }
|
10227 |
|
10228 | function addEventListener(el, event, handler, options) {
|
10229 | el.addEventListener(event, handler, options);
|
10230 | }
|
10231 | function removeEventListener(el, event, handler, options) {
|
10232 | el.removeEventListener(event, handler, options);
|
10233 | }
|
10234 | const veiKey = Symbol("_vei");
|
10235 | function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
10236 | const invokers = el[veiKey] || (el[veiKey] = {});
|
10237 | const existingInvoker = invokers[rawName];
|
10238 | if (nextValue && existingInvoker) {
|
10239 | existingInvoker.value = nextValue;
|
10240 | } else {
|
10241 | const [name, options] = parseName(rawName);
|
10242 | if (nextValue) {
|
10243 | const invoker = invokers[rawName] = createInvoker(nextValue, instance);
|
10244 | addEventListener(el, name, invoker, options);
|
10245 | } else if (existingInvoker) {
|
10246 | removeEventListener(el, name, existingInvoker, options);
|
10247 | invokers[rawName] = void 0;
|
10248 | }
|
10249 | }
|
10250 | }
|
10251 | const optionsModifierRE = /(?:Once|Passive|Capture)$/;
|
10252 | function parseName(name) {
|
10253 | let options;
|
10254 | if (optionsModifierRE.test(name)) {
|
10255 | options = {};
|
10256 | let m;
|
10257 | while (m = name.match(optionsModifierRE)) {
|
10258 | name = name.slice(0, name.length - m[0].length);
|
10259 | options[m[0].toLowerCase()] = true;
|
10260 | }
|
10261 | }
|
10262 | const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
|
10263 | return [event, options];
|
10264 | }
|
10265 | let cachedNow = 0;
|
10266 | const p = Promise.resolve();
|
10267 | const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
|
10268 | function createInvoker(initialValue, instance) {
|
10269 | const invoker = (e) => {
|
10270 | if (!e._vts) {
|
10271 | e._vts = Date.now();
|
10272 | } else if (e._vts <= invoker.attached) {
|
10273 | return;
|
10274 | }
|
10275 | callWithAsyncErrorHandling(
|
10276 | patchStopImmediatePropagation(e, invoker.value),
|
10277 | instance,
|
10278 | 5,
|
10279 | [e]
|
10280 | );
|
10281 | };
|
10282 | invoker.value = initialValue;
|
10283 | invoker.attached = getNow();
|
10284 | return invoker;
|
10285 | }
|
10286 | function patchStopImmediatePropagation(e, value) {
|
10287 | if (isArray(value)) {
|
10288 | const originalStop = e.stopImmediatePropagation;
|
10289 | e.stopImmediatePropagation = () => {
|
10290 | originalStop.call(e);
|
10291 | e._stopped = true;
|
10292 | };
|
10293 | return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2));
|
10294 | } else {
|
10295 | return value;
|
10296 | }
|
10297 | }
|
10298 |
|
10299 | const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 &&
|
10300 | key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
|
10301 | const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
|
10302 | const isSVG = namespace === "svg";
|
10303 | if (key === "class") {
|
10304 | patchClass(el, nextValue, isSVG);
|
10305 | } else if (key === "style") {
|
10306 | patchStyle(el, prevValue, nextValue);
|
10307 | } else if (isOn(key)) {
|
10308 | if (!isModelListener(key)) {
|
10309 | patchEvent(el, key, prevValue, nextValue, parentComponent);
|
10310 | }
|
10311 | } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
|
10312 | patchDOMProp(
|
10313 | el,
|
10314 | key,
|
10315 | nextValue,
|
10316 | prevChildren,
|
10317 | parentComponent,
|
10318 | parentSuspense,
|
10319 | unmountChildren
|
10320 | );
|
10321 | } else {
|
10322 | if (key === "true-value") {
|
10323 | el._trueValue = nextValue;
|
10324 | } else if (key === "false-value") {
|
10325 | el._falseValue = nextValue;
|
10326 | }
|
10327 | patchAttr(el, key, nextValue, isSVG);
|
10328 | }
|
10329 | };
|
10330 | function shouldSetAsProp(el, key, value, isSVG) {
|
10331 | if (isSVG) {
|
10332 | if (key === "innerHTML" || key === "textContent") {
|
10333 | return true;
|
10334 | }
|
10335 | if (key in el && isNativeOn(key) && isFunction(value)) {
|
10336 | return true;
|
10337 | }
|
10338 | return false;
|
10339 | }
|
10340 | if (key === "spellcheck" || key === "draggable" || key === "translate") {
|
10341 | return false;
|
10342 | }
|
10343 | if (key === "form") {
|
10344 | return false;
|
10345 | }
|
10346 | if (key === "list" && el.tagName === "INPUT") {
|
10347 | return false;
|
10348 | }
|
10349 | if (key === "type" && el.tagName === "TEXTAREA") {
|
10350 | return false;
|
10351 | }
|
10352 | if (key === "width" || key === "height") {
|
10353 | const tag = el.tagName;
|
10354 | if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
|
10355 | return false;
|
10356 | }
|
10357 | }
|
10358 | if (isNativeOn(key) && isString(value)) {
|
10359 | return false;
|
10360 | }
|
10361 | return key in el;
|
10362 | }
|
10363 |
|
10364 |
|
10365 |
|
10366 | function defineCustomElement(options, hydrate2) {
|
10367 | const Comp = defineComponent(options);
|
10368 | class VueCustomElement extends VueElement {
|
10369 | constructor(initialProps) {
|
10370 | super(Comp, initialProps, hydrate2);
|
10371 | }
|
10372 | }
|
10373 | VueCustomElement.def = Comp;
|
10374 | return VueCustomElement;
|
10375 | }
|
10376 |
|
10377 | const defineSSRCustomElement = (options) => {
|
10378 | return defineCustomElement(options, hydrate);
|
10379 | };
|
10380 | const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
|
10381 | };
|
10382 | class VueElement extends BaseClass {
|
10383 | constructor(_def, _props = {}, hydrate2) {
|
10384 | super();
|
10385 | this._def = _def;
|
10386 | this._props = _props;
|
10387 | |
10388 |
|
10389 |
|
10390 | this._instance = null;
|
10391 | this._connected = false;
|
10392 | this._resolved = false;
|
10393 | this._numberProps = null;
|
10394 | this._ob = null;
|
10395 | if (this.shadowRoot && hydrate2) {
|
10396 | hydrate2(this._createVNode(), this.shadowRoot);
|
10397 | } else {
|
10398 | if (this.shadowRoot) {
|
10399 | warn(
|
10400 | `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
|
10401 | );
|
10402 | }
|
10403 | this.attachShadow({ mode: "open" });
|
10404 | if (!this._def.__asyncLoader) {
|
10405 | this._resolveProps(this._def);
|
10406 | }
|
10407 | }
|
10408 | }
|
10409 | connectedCallback() {
|
10410 | this._connected = true;
|
10411 | if (!this._instance) {
|
10412 | if (this._resolved) {
|
10413 | this._update();
|
10414 | } else {
|
10415 | this._resolveDef();
|
10416 | }
|
10417 | }
|
10418 | }
|
10419 | disconnectedCallback() {
|
10420 | this._connected = false;
|
10421 | if (this._ob) {
|
10422 | this._ob.disconnect();
|
10423 | this._ob = null;
|
10424 | }
|
10425 | nextTick(() => {
|
10426 | if (!this._connected) {
|
10427 | render(null, this.shadowRoot);
|
10428 | this._instance = null;
|
10429 | }
|
10430 | });
|
10431 | }
|
10432 | |
10433 |
|
10434 |
|
10435 | _resolveDef() {
|
10436 | this._resolved = true;
|
10437 | for (let i = 0; i < this.attributes.length; i++) {
|
10438 | this._setAttr(this.attributes[i].name);
|
10439 | }
|
10440 | this._ob = new MutationObserver((mutations) => {
|
10441 | for (const m of mutations) {
|
10442 | this._setAttr(m.attributeName);
|
10443 | }
|
10444 | });
|
10445 | this._ob.observe(this, { attributes: true });
|
10446 | const resolve = (def, isAsync = false) => {
|
10447 | const { props, styles } = def;
|
10448 | let numberProps;
|
10449 | if (props && !isArray(props)) {
|
10450 | for (const key in props) {
|
10451 | const opt = props[key];
|
10452 | if (opt === Number || opt && opt.type === Number) {
|
10453 | if (key in this._props) {
|
10454 | this._props[key] = toNumber(this._props[key]);
|
10455 | }
|
10456 | (numberProps || (numberProps = Object.create(null)))[camelize(key)] = true;
|
10457 | }
|
10458 | }
|
10459 | }
|
10460 | this._numberProps = numberProps;
|
10461 | if (isAsync) {
|
10462 | this._resolveProps(def);
|
10463 | }
|
10464 | this._applyStyles(styles);
|
10465 | this._update();
|
10466 | };
|
10467 | const asyncDef = this._def.__asyncLoader;
|
10468 | if (asyncDef) {
|
10469 | asyncDef().then((def) => resolve(def, true));
|
10470 | } else {
|
10471 | resolve(this._def);
|
10472 | }
|
10473 | }
|
10474 | _resolveProps(def) {
|
10475 | const { props } = def;
|
10476 | const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
|
10477 | for (const key of Object.keys(this)) {
|
10478 | if (key[0] !== "_" && declaredPropKeys.includes(key)) {
|
10479 | this._setProp(key, this[key], true, false);
|
10480 | }
|
10481 | }
|
10482 | for (const key of declaredPropKeys.map(camelize)) {
|
10483 | Object.defineProperty(this, key, {
|
10484 | get() {
|
10485 | return this._getProp(key);
|
10486 | },
|
10487 | set(val) {
|
10488 | this._setProp(key, val);
|
10489 | }
|
10490 | });
|
10491 | }
|
10492 | }
|
10493 | _setAttr(key) {
|
10494 | let value = this.getAttribute(key);
|
10495 | const camelKey = camelize(key);
|
10496 | if (this._numberProps && this._numberProps[camelKey]) {
|
10497 | value = toNumber(value);
|
10498 | }
|
10499 | this._setProp(camelKey, value, false);
|
10500 | }
|
10501 | |
10502 |
|
10503 |
|
10504 | _getProp(key) {
|
10505 | return this._props[key];
|
10506 | }
|
10507 | |
10508 |
|
10509 |
|
10510 | _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
|
10511 | if (val !== this._props[key]) {
|
10512 | this._props[key] = val;
|
10513 | if (shouldUpdate && this._instance) {
|
10514 | this._update();
|
10515 | }
|
10516 | if (shouldReflect) {
|
10517 | if (val === true) {
|
10518 | this.setAttribute(hyphenate(key), "");
|
10519 | } else if (typeof val === "string" || typeof val === "number") {
|
10520 | this.setAttribute(hyphenate(key), val + "");
|
10521 | } else if (!val) {
|
10522 | this.removeAttribute(hyphenate(key));
|
10523 | }
|
10524 | }
|
10525 | }
|
10526 | }
|
10527 | _update() {
|
10528 | render(this._createVNode(), this.shadowRoot);
|
10529 | }
|
10530 | _createVNode() {
|
10531 | const vnode = createVNode(this._def, extend({}, this._props));
|
10532 | if (!this._instance) {
|
10533 | vnode.ce = (instance) => {
|
10534 | this._instance = instance;
|
10535 | instance.isCE = true;
|
10536 | {
|
10537 | instance.ceReload = (newStyles) => {
|
10538 | if (this._styles) {
|
10539 | this._styles.forEach((s) => this.shadowRoot.removeChild(s));
|
10540 | this._styles.length = 0;
|
10541 | }
|
10542 | this._applyStyles(newStyles);
|
10543 | this._instance = null;
|
10544 | this._update();
|
10545 | };
|
10546 | }
|
10547 | const dispatch = (event, args) => {
|
10548 | this.dispatchEvent(
|
10549 | new CustomEvent(event, {
|
10550 | detail: args
|
10551 | })
|
10552 | );
|
10553 | };
|
10554 | instance.emit = (event, ...args) => {
|
10555 | dispatch(event, args);
|
10556 | if (hyphenate(event) !== event) {
|
10557 | dispatch(hyphenate(event), args);
|
10558 | }
|
10559 | };
|
10560 | let parent = this;
|
10561 | while (parent = parent && (parent.parentNode || parent.host)) {
|
10562 | if (parent instanceof VueElement) {
|
10563 | instance.parent = parent._instance;
|
10564 | instance.provides = parent._instance.provides;
|
10565 | break;
|
10566 | }
|
10567 | }
|
10568 | };
|
10569 | }
|
10570 | return vnode;
|
10571 | }
|
10572 | _applyStyles(styles) {
|
10573 | if (styles) {
|
10574 | styles.forEach((css) => {
|
10575 | const s = document.createElement("style");
|
10576 | s.textContent = css;
|
10577 | this.shadowRoot.appendChild(s);
|
10578 | {
|
10579 | (this._styles || (this._styles = [])).push(s);
|
10580 | }
|
10581 | });
|
10582 | }
|
10583 | }
|
10584 | }
|
10585 |
|
10586 | function useCssModule(name = "$style") {
|
10587 | {
|
10588 | const instance = getCurrentInstance();
|
10589 | if (!instance) {
|
10590 | warn(`useCssModule must be called inside setup()`);
|
10591 | return EMPTY_OBJ;
|
10592 | }
|
10593 | const modules = instance.type.__cssModules;
|
10594 | if (!modules) {
|
10595 | warn(`Current instance does not have CSS modules injected.`);
|
10596 | return EMPTY_OBJ;
|
10597 | }
|
10598 | const mod = modules[name];
|
10599 | if (!mod) {
|
10600 | warn(`Current instance does not have CSS module named "${name}".`);
|
10601 | return EMPTY_OBJ;
|
10602 | }
|
10603 | return mod;
|
10604 | }
|
10605 | }
|
10606 |
|
10607 | const positionMap = new WeakMap();
|
10608 | const newPositionMap = new WeakMap();
|
10609 | const moveCbKey = Symbol("_moveCb");
|
10610 | const enterCbKey = Symbol("_enterCb");
|
10611 | const TransitionGroupImpl = {
|
10612 | name: "TransitionGroup",
|
10613 | props: extend({}, TransitionPropsValidators, {
|
10614 | tag: String,
|
10615 | moveClass: String
|
10616 | }),
|
10617 | setup(props, { slots }) {
|
10618 | const instance = getCurrentInstance();
|
10619 | const state = useTransitionState();
|
10620 | let prevChildren;
|
10621 | let children;
|
10622 | onUpdated(() => {
|
10623 | if (!prevChildren.length) {
|
10624 | return;
|
10625 | }
|
10626 | const moveClass = props.moveClass || `${props.name || "v"}-move`;
|
10627 | if (!hasCSSTransform(
|
10628 | prevChildren[0].el,
|
10629 | instance.vnode.el,
|
10630 | moveClass
|
10631 | )) {
|
10632 | return;
|
10633 | }
|
10634 | prevChildren.forEach(callPendingCbs);
|
10635 | prevChildren.forEach(recordPosition);
|
10636 | const movedChildren = prevChildren.filter(applyTranslation);
|
10637 | forceReflow();
|
10638 | movedChildren.forEach((c) => {
|
10639 | const el = c.el;
|
10640 | const style = el.style;
|
10641 | addTransitionClass(el, moveClass);
|
10642 | style.transform = style.webkitTransform = style.transitionDuration = "";
|
10643 | const cb = el[moveCbKey] = (e) => {
|
10644 | if (e && e.target !== el) {
|
10645 | return;
|
10646 | }
|
10647 | if (!e || /transform$/.test(e.propertyName)) {
|
10648 | el.removeEventListener("transitionend", cb);
|
10649 | el[moveCbKey] = null;
|
10650 | removeTransitionClass(el, moveClass);
|
10651 | }
|
10652 | };
|
10653 | el.addEventListener("transitionend", cb);
|
10654 | });
|
10655 | });
|
10656 | return () => {
|
10657 | const rawProps = toRaw(props);
|
10658 | const cssTransitionProps = resolveTransitionProps(rawProps);
|
10659 | let tag = rawProps.tag || Fragment;
|
10660 | prevChildren = children;
|
10661 | children = slots.default ? getTransitionRawChildren(slots.default()) : [];
|
10662 | for (let i = 0; i < children.length; i++) {
|
10663 | const child = children[i];
|
10664 | if (child.key != null) {
|
10665 | setTransitionHooks(
|
10666 | child,
|
10667 | resolveTransitionHooks(child, cssTransitionProps, state, instance)
|
10668 | );
|
10669 | } else {
|
10670 | warn(`<TransitionGroup> children must be keyed.`);
|
10671 | }
|
10672 | }
|
10673 | if (prevChildren) {
|
10674 | for (let i = 0; i < prevChildren.length; i++) {
|
10675 | const child = prevChildren[i];
|
10676 | setTransitionHooks(
|
10677 | child,
|
10678 | resolveTransitionHooks(child, cssTransitionProps, state, instance)
|
10679 | );
|
10680 | positionMap.set(child, child.el.getBoundingClientRect());
|
10681 | }
|
10682 | }
|
10683 | return createVNode(tag, null, children);
|
10684 | };
|
10685 | }
|
10686 | };
|
10687 | const removeMode = (props) => delete props.mode;
|
10688 | removeMode(TransitionGroupImpl.props);
|
10689 | const TransitionGroup = TransitionGroupImpl;
|
10690 | function callPendingCbs(c) {
|
10691 | const el = c.el;
|
10692 | if (el[moveCbKey]) {
|
10693 | el[moveCbKey]();
|
10694 | }
|
10695 | if (el[enterCbKey]) {
|
10696 | el[enterCbKey]();
|
10697 | }
|
10698 | }
|
10699 | function recordPosition(c) {
|
10700 | newPositionMap.set(c, c.el.getBoundingClientRect());
|
10701 | }
|
10702 | function applyTranslation(c) {
|
10703 | const oldPos = positionMap.get(c);
|
10704 | const newPos = newPositionMap.get(c);
|
10705 | const dx = oldPos.left - newPos.left;
|
10706 | const dy = oldPos.top - newPos.top;
|
10707 | if (dx || dy) {
|
10708 | const s = c.el.style;
|
10709 | s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
|
10710 | s.transitionDuration = "0s";
|
10711 | return c;
|
10712 | }
|
10713 | }
|
10714 | function hasCSSTransform(el, root, moveClass) {
|
10715 | const clone = el.cloneNode();
|
10716 | const _vtc = el[vtcKey];
|
10717 | if (_vtc) {
|
10718 | _vtc.forEach((cls) => {
|
10719 | cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
|
10720 | });
|
10721 | }
|
10722 | moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
|
10723 | clone.style.display = "none";
|
10724 | const container = root.nodeType === 1 ? root : root.parentNode;
|
10725 | container.appendChild(clone);
|
10726 | const { hasTransform } = getTransitionInfo(clone);
|
10727 | container.removeChild(clone);
|
10728 | return hasTransform;
|
10729 | }
|
10730 |
|
10731 | const getModelAssigner = (vnode) => {
|
10732 | const fn = vnode.props["onUpdate:modelValue"] || false;
|
10733 | return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
|
10734 | };
|
10735 | function onCompositionStart(e) {
|
10736 | e.target.composing = true;
|
10737 | }
|
10738 | function onCompositionEnd(e) {
|
10739 | const target = e.target;
|
10740 | if (target.composing) {
|
10741 | target.composing = false;
|
10742 | target.dispatchEvent(new Event("input"));
|
10743 | }
|
10744 | }
|
10745 | const assignKey = Symbol("_assign");
|
10746 | const vModelText = {
|
10747 | created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
10748 | el[assignKey] = getModelAssigner(vnode);
|
10749 | const castToNumber = number || vnode.props && vnode.props.type === "number";
|
10750 | addEventListener(el, lazy ? "change" : "input", (e) => {
|
10751 | if (e.target.composing)
|
10752 | return;
|
10753 | let domValue = el.value;
|
10754 | if (trim) {
|
10755 | domValue = domValue.trim();
|
10756 | }
|
10757 | if (castToNumber) {
|
10758 | domValue = looseToNumber(domValue);
|
10759 | }
|
10760 | el[assignKey](domValue);
|
10761 | });
|
10762 | if (trim) {
|
10763 | addEventListener(el, "change", () => {
|
10764 | el.value = el.value.trim();
|
10765 | });
|
10766 | }
|
10767 | if (!lazy) {
|
10768 | addEventListener(el, "compositionstart", onCompositionStart);
|
10769 | addEventListener(el, "compositionend", onCompositionEnd);
|
10770 | addEventListener(el, "change", onCompositionEnd);
|
10771 | }
|
10772 | },
|
10773 |
|
10774 | mounted(el, { value }) {
|
10775 | el.value = value == null ? "" : value;
|
10776 | },
|
10777 | beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
|
10778 | el[assignKey] = getModelAssigner(vnode);
|
10779 | if (el.composing)
|
10780 | return;
|
10781 | const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
|
10782 | const newValue = value == null ? "" : value;
|
10783 | if (elValue === newValue) {
|
10784 | return;
|
10785 | }
|
10786 | if (document.activeElement === el && el.type !== "range") {
|
10787 | if (lazy) {
|
10788 | return;
|
10789 | }
|
10790 | if (trim && el.value.trim() === newValue) {
|
10791 | return;
|
10792 | }
|
10793 | }
|
10794 | el.value = newValue;
|
10795 | }
|
10796 | };
|
10797 | const vModelCheckbox = {
|
10798 |
|
10799 | deep: true,
|
10800 | created(el, _, vnode) {
|
10801 | el[assignKey] = getModelAssigner(vnode);
|
10802 | addEventListener(el, "change", () => {
|
10803 | const modelValue = el._modelValue;
|
10804 | const elementValue = getValue(el);
|
10805 | const checked = el.checked;
|
10806 | const assign = el[assignKey];
|
10807 | if (isArray(modelValue)) {
|
10808 | const index = looseIndexOf(modelValue, elementValue);
|
10809 | const found = index !== -1;
|
10810 | if (checked && !found) {
|
10811 | assign(modelValue.concat(elementValue));
|
10812 | } else if (!checked && found) {
|
10813 | const filtered = [...modelValue];
|
10814 | filtered.splice(index, 1);
|
10815 | assign(filtered);
|
10816 | }
|
10817 | } else if (isSet(modelValue)) {
|
10818 | const cloned = new Set(modelValue);
|
10819 | if (checked) {
|
10820 | cloned.add(elementValue);
|
10821 | } else {
|
10822 | cloned.delete(elementValue);
|
10823 | }
|
10824 | assign(cloned);
|
10825 | } else {
|
10826 | assign(getCheckboxValue(el, checked));
|
10827 | }
|
10828 | });
|
10829 | },
|
10830 |
|
10831 | mounted: setChecked,
|
10832 | beforeUpdate(el, binding, vnode) {
|
10833 | el[assignKey] = getModelAssigner(vnode);
|
10834 | setChecked(el, binding, vnode);
|
10835 | }
|
10836 | };
|
10837 | function setChecked(el, { value, oldValue }, vnode) {
|
10838 | el._modelValue = value;
|
10839 | if (isArray(value)) {
|
10840 | el.checked = looseIndexOf(value, vnode.props.value) > -1;
|
10841 | } else if (isSet(value)) {
|
10842 | el.checked = value.has(vnode.props.value);
|
10843 | } else if (value !== oldValue) {
|
10844 | el.checked = looseEqual(value, getCheckboxValue(el, true));
|
10845 | }
|
10846 | }
|
10847 | const vModelRadio = {
|
10848 | created(el, { value }, vnode) {
|
10849 | el.checked = looseEqual(value, vnode.props.value);
|
10850 | el[assignKey] = getModelAssigner(vnode);
|
10851 | addEventListener(el, "change", () => {
|
10852 | el[assignKey](getValue(el));
|
10853 | });
|
10854 | },
|
10855 | beforeUpdate(el, { value, oldValue }, vnode) {
|
10856 | el[assignKey] = getModelAssigner(vnode);
|
10857 | if (value !== oldValue) {
|
10858 | el.checked = looseEqual(value, vnode.props.value);
|
10859 | }
|
10860 | }
|
10861 | };
|
10862 | const vModelSelect = {
|
10863 |
|
10864 | deep: true,
|
10865 | created(el, { value, modifiers: { number } }, vnode) {
|
10866 | const isSetModel = isSet(value);
|
10867 | addEventListener(el, "change", () => {
|
10868 | const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
10869 | (o) => number ? looseToNumber(getValue(o)) : getValue(o)
|
10870 | );
|
10871 | el[assignKey](
|
10872 | el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
10873 | );
|
10874 | el._assigning = true;
|
10875 | nextTick(() => {
|
10876 | el._assigning = false;
|
10877 | });
|
10878 | });
|
10879 | el[assignKey] = getModelAssigner(vnode);
|
10880 | },
|
10881 |
|
10882 |
|
10883 | mounted(el, { value, oldValue, modifiers: { number } }) {
|
10884 | setSelected(el, value, oldValue, number);
|
10885 | },
|
10886 | beforeUpdate(el, _binding, vnode) {
|
10887 | el[assignKey] = getModelAssigner(vnode);
|
10888 | },
|
10889 | updated(el, { value, oldValue, modifiers: { number } }) {
|
10890 | if (!el._assigning) {
|
10891 | setSelected(el, value, oldValue, number);
|
10892 | }
|
10893 | }
|
10894 | };
|
10895 | function setSelected(el, value, oldValue, number) {
|
10896 | const isMultiple = el.multiple;
|
10897 | const isArrayValue = isArray(value);
|
10898 | if (isMultiple && !isArrayValue && !isSet(value)) {
|
10899 | warn(
|
10900 | `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
|
10901 | );
|
10902 | return;
|
10903 | }
|
10904 | for (let i = 0, l = el.options.length; i < l; i++) {
|
10905 | const option = el.options[i];
|
10906 | const optionValue = getValue(option);
|
10907 | if (isMultiple) {
|
10908 | if (isArrayValue) {
|
10909 | const optionType = typeof optionValue;
|
10910 | if (optionType === "string" || optionType === "number") {
|
10911 | option.selected = value.includes(
|
10912 | number ? looseToNumber(optionValue) : optionValue
|
10913 | );
|
10914 | } else {
|
10915 | option.selected = looseIndexOf(value, optionValue) > -1;
|
10916 | }
|
10917 | } else {
|
10918 | option.selected = value.has(optionValue);
|
10919 | }
|
10920 | } else {
|
10921 | if (looseEqual(getValue(option), value)) {
|
10922 | if (el.selectedIndex !== i)
|
10923 | el.selectedIndex = i;
|
10924 | return;
|
10925 | }
|
10926 | }
|
10927 | }
|
10928 | if (!isMultiple && el.selectedIndex !== -1) {
|
10929 | el.selectedIndex = -1;
|
10930 | }
|
10931 | }
|
10932 | function getValue(el) {
|
10933 | return "_value" in el ? el._value : el.value;
|
10934 | }
|
10935 | function getCheckboxValue(el, checked) {
|
10936 | const key = checked ? "_trueValue" : "_falseValue";
|
10937 | return key in el ? el[key] : checked;
|
10938 | }
|
10939 | const vModelDynamic = {
|
10940 | created(el, binding, vnode) {
|
10941 | callModelHook(el, binding, vnode, null, "created");
|
10942 | },
|
10943 | mounted(el, binding, vnode) {
|
10944 | callModelHook(el, binding, vnode, null, "mounted");
|
10945 | },
|
10946 | beforeUpdate(el, binding, vnode, prevVNode) {
|
10947 | callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
|
10948 | },
|
10949 | updated(el, binding, vnode, prevVNode) {
|
10950 | callModelHook(el, binding, vnode, prevVNode, "updated");
|
10951 | }
|
10952 | };
|
10953 | function resolveDynamicModel(tagName, type) {
|
10954 | switch (tagName) {
|
10955 | case "SELECT":
|
10956 | return vModelSelect;
|
10957 | case "TEXTAREA":
|
10958 | return vModelText;
|
10959 | default:
|
10960 | switch (type) {
|
10961 | case "checkbox":
|
10962 | return vModelCheckbox;
|
10963 | case "radio":
|
10964 | return vModelRadio;
|
10965 | default:
|
10966 | return vModelText;
|
10967 | }
|
10968 | }
|
10969 | }
|
10970 | function callModelHook(el, binding, vnode, prevVNode, hook) {
|
10971 | const modelToUse = resolveDynamicModel(
|
10972 | el.tagName,
|
10973 | vnode.props && vnode.props.type
|
10974 | );
|
10975 | const fn = modelToUse[hook];
|
10976 | fn && fn(el, binding, vnode, prevVNode);
|
10977 | }
|
10978 |
|
10979 | const systemModifiers = ["ctrl", "shift", "alt", "meta"];
|
10980 | const modifierGuards = {
|
10981 | stop: (e) => e.stopPropagation(),
|
10982 | prevent: (e) => e.preventDefault(),
|
10983 | self: (e) => e.target !== e.currentTarget,
|
10984 | ctrl: (e) => !e.ctrlKey,
|
10985 | shift: (e) => !e.shiftKey,
|
10986 | alt: (e) => !e.altKey,
|
10987 | meta: (e) => !e.metaKey,
|
10988 | left: (e) => "button" in e && e.button !== 0,
|
10989 | middle: (e) => "button" in e && e.button !== 1,
|
10990 | right: (e) => "button" in e && e.button !== 2,
|
10991 | exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
|
10992 | };
|
10993 | const withModifiers = (fn, modifiers) => {
|
10994 | const cache = fn._withMods || (fn._withMods = {});
|
10995 | const cacheKey = modifiers.join(".");
|
10996 | return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
|
10997 | for (let i = 0; i < modifiers.length; i++) {
|
10998 | const guard = modifierGuards[modifiers[i]];
|
10999 | if (guard && guard(event, modifiers))
|
11000 | return;
|
11001 | }
|
11002 | return fn(event, ...args);
|
11003 | });
|
11004 | };
|
11005 | const keyNames = {
|
11006 | esc: "escape",
|
11007 | space: " ",
|
11008 | up: "arrow-up",
|
11009 | left: "arrow-left",
|
11010 | right: "arrow-right",
|
11011 | down: "arrow-down",
|
11012 | delete: "backspace"
|
11013 | };
|
11014 | const withKeys = (fn, modifiers) => {
|
11015 | const cache = fn._withKeys || (fn._withKeys = {});
|
11016 | const cacheKey = modifiers.join(".");
|
11017 | return cache[cacheKey] || (cache[cacheKey] = (event) => {
|
11018 | if (!("key" in event)) {
|
11019 | return;
|
11020 | }
|
11021 | const eventKey = hyphenate(event.key);
|
11022 | if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
|
11023 | return fn(event);
|
11024 | }
|
11025 | });
|
11026 | };
|
11027 |
|
11028 | const rendererOptions = extend({ patchProp }, nodeOps);
|
11029 | let renderer;
|
11030 | let enabledHydration = false;
|
11031 | function ensureRenderer() {
|
11032 | return renderer || (renderer = createRenderer(rendererOptions));
|
11033 | }
|
11034 | function ensureHydrationRenderer() {
|
11035 | renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
|
11036 | enabledHydration = true;
|
11037 | return renderer;
|
11038 | }
|
11039 | const render = (...args) => {
|
11040 | ensureRenderer().render(...args);
|
11041 | };
|
11042 | const hydrate = (...args) => {
|
11043 | ensureHydrationRenderer().hydrate(...args);
|
11044 | };
|
11045 | const createApp = (...args) => {
|
11046 | const app = ensureRenderer().createApp(...args);
|
11047 | {
|
11048 | injectNativeTagCheck(app);
|
11049 | injectCompilerOptionsCheck(app);
|
11050 | }
|
11051 | const { mount } = app;
|
11052 | app.mount = (containerOrSelector) => {
|
11053 | const container = normalizeContainer(containerOrSelector);
|
11054 | if (!container)
|
11055 | return;
|
11056 | const component = app._component;
|
11057 | if (!isFunction(component) && !component.render && !component.template) {
|
11058 | component.template = container.innerHTML;
|
11059 | }
|
11060 | container.innerHTML = "";
|
11061 | const proxy = mount(container, false, resolveRootNamespace(container));
|
11062 | if (container instanceof Element) {
|
11063 | container.removeAttribute("v-cloak");
|
11064 | container.setAttribute("data-v-app", "");
|
11065 | }
|
11066 | return proxy;
|
11067 | };
|
11068 | return app;
|
11069 | };
|
11070 | const createSSRApp = (...args) => {
|
11071 | const app = ensureHydrationRenderer().createApp(...args);
|
11072 | {
|
11073 | injectNativeTagCheck(app);
|
11074 | injectCompilerOptionsCheck(app);
|
11075 | }
|
11076 | const { mount } = app;
|
11077 | app.mount = (containerOrSelector) => {
|
11078 | const container = normalizeContainer(containerOrSelector);
|
11079 | if (container) {
|
11080 | return mount(container, true, resolveRootNamespace(container));
|
11081 | }
|
11082 | };
|
11083 | return app;
|
11084 | };
|
11085 | function resolveRootNamespace(container) {
|
11086 | if (container instanceof SVGElement) {
|
11087 | return "svg";
|
11088 | }
|
11089 | if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
|
11090 | return "mathml";
|
11091 | }
|
11092 | }
|
11093 | function injectNativeTagCheck(app) {
|
11094 | Object.defineProperty(app.config, "isNativeTag", {
|
11095 | value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
11096 | writable: false
|
11097 | });
|
11098 | }
|
11099 | function injectCompilerOptionsCheck(app) {
|
11100 | if (isRuntimeOnly()) {
|
11101 | const isCustomElement = app.config.isCustomElement;
|
11102 | Object.defineProperty(app.config, "isCustomElement", {
|
11103 | get() {
|
11104 | return isCustomElement;
|
11105 | },
|
11106 | set() {
|
11107 | warn(
|
11108 | `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
|
11109 | );
|
11110 | }
|
11111 | });
|
11112 | const compilerOptions = app.config.compilerOptions;
|
11113 | 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.
|
11114 | - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
|
11115 | - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
|
11116 | - 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`;
|
11117 | Object.defineProperty(app.config, "compilerOptions", {
|
11118 | get() {
|
11119 | warn(msg);
|
11120 | return compilerOptions;
|
11121 | },
|
11122 | set() {
|
11123 | warn(msg);
|
11124 | }
|
11125 | });
|
11126 | }
|
11127 | }
|
11128 | function normalizeContainer(container) {
|
11129 | if (isString(container)) {
|
11130 | const res = document.querySelector(container);
|
11131 | if (!res) {
|
11132 | warn(
|
11133 | `Failed to mount app: mount target selector "${container}" returned null.`
|
11134 | );
|
11135 | }
|
11136 | return res;
|
11137 | }
|
11138 | if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
|
11139 | warn(
|
11140 | `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
|
11141 | );
|
11142 | }
|
11143 | return container;
|
11144 | }
|
11145 | const initDirectivesForSSR = NOOP;
|
11146 |
|
11147 | var runtimeDom = Object.freeze({
|
11148 | __proto__: null,
|
11149 | BaseTransition: BaseTransition,
|
11150 | BaseTransitionPropsValidators: BaseTransitionPropsValidators,
|
11151 | Comment: Comment,
|
11152 | DeprecationTypes: DeprecationTypes,
|
11153 | EffectScope: EffectScope,
|
11154 | ErrorCodes: ErrorCodes,
|
11155 | ErrorTypeStrings: ErrorTypeStrings,
|
11156 | Fragment: Fragment,
|
11157 | KeepAlive: KeepAlive,
|
11158 | ReactiveEffect: ReactiveEffect,
|
11159 | Static: Static,
|
11160 | Suspense: Suspense,
|
11161 | Teleport: Teleport,
|
11162 | Text: Text,
|
11163 | TrackOpTypes: TrackOpTypes,
|
11164 | Transition: Transition,
|
11165 | TransitionGroup: TransitionGroup,
|
11166 | TriggerOpTypes: TriggerOpTypes,
|
11167 | VueElement: VueElement,
|
11168 | assertNumber: assertNumber,
|
11169 | callWithAsyncErrorHandling: callWithAsyncErrorHandling,
|
11170 | callWithErrorHandling: callWithErrorHandling,
|
11171 | camelize: camelize,
|
11172 | capitalize: capitalize,
|
11173 | cloneVNode: cloneVNode,
|
11174 | compatUtils: compatUtils,
|
11175 | computed: computed,
|
11176 | createApp: createApp,
|
11177 | createBlock: createBlock,
|
11178 | createCommentVNode: createCommentVNode,
|
11179 | createElementBlock: createElementBlock,
|
11180 | createElementVNode: createBaseVNode,
|
11181 | createHydrationRenderer: createHydrationRenderer,
|
11182 | createPropsRestProxy: createPropsRestProxy,
|
11183 | createRenderer: createRenderer,
|
11184 | createSSRApp: createSSRApp,
|
11185 | createSlots: createSlots,
|
11186 | createStaticVNode: createStaticVNode,
|
11187 | createTextVNode: createTextVNode,
|
11188 | createVNode: createVNode,
|
11189 | customRef: customRef,
|
11190 | defineAsyncComponent: defineAsyncComponent,
|
11191 | defineComponent: defineComponent,
|
11192 | defineCustomElement: defineCustomElement,
|
11193 | defineEmits: defineEmits,
|
11194 | defineExpose: defineExpose,
|
11195 | defineModel: defineModel,
|
11196 | defineOptions: defineOptions,
|
11197 | defineProps: defineProps,
|
11198 | defineSSRCustomElement: defineSSRCustomElement,
|
11199 | defineSlots: defineSlots,
|
11200 | devtools: devtools,
|
11201 | effect: effect,
|
11202 | effectScope: effectScope,
|
11203 | getCurrentInstance: getCurrentInstance,
|
11204 | getCurrentScope: getCurrentScope,
|
11205 | getTransitionRawChildren: getTransitionRawChildren,
|
11206 | guardReactiveProps: guardReactiveProps,
|
11207 | h: h,
|
11208 | handleError: handleError,
|
11209 | hasInjectionContext: hasInjectionContext,
|
11210 | hydrate: hydrate,
|
11211 | initCustomFormatter: initCustomFormatter,
|
11212 | initDirectivesForSSR: initDirectivesForSSR,
|
11213 | inject: inject,
|
11214 | isMemoSame: isMemoSame,
|
11215 | isProxy: isProxy,
|
11216 | isReactive: isReactive,
|
11217 | isReadonly: isReadonly,
|
11218 | isRef: isRef,
|
11219 | isRuntimeOnly: isRuntimeOnly,
|
11220 | isShallow: isShallow,
|
11221 | isVNode: isVNode,
|
11222 | markRaw: markRaw,
|
11223 | mergeDefaults: mergeDefaults,
|
11224 | mergeModels: mergeModels,
|
11225 | mergeProps: mergeProps,
|
11226 | nextTick: nextTick,
|
11227 | normalizeClass: normalizeClass,
|
11228 | normalizeProps: normalizeProps,
|
11229 | normalizeStyle: normalizeStyle,
|
11230 | onActivated: onActivated,
|
11231 | onBeforeMount: onBeforeMount,
|
11232 | onBeforeUnmount: onBeforeUnmount,
|
11233 | onBeforeUpdate: onBeforeUpdate,
|
11234 | onDeactivated: onDeactivated,
|
11235 | onErrorCaptured: onErrorCaptured,
|
11236 | onMounted: onMounted,
|
11237 | onRenderTracked: onRenderTracked,
|
11238 | onRenderTriggered: onRenderTriggered,
|
11239 | onScopeDispose: onScopeDispose,
|
11240 | onServerPrefetch: onServerPrefetch,
|
11241 | onUnmounted: onUnmounted,
|
11242 | onUpdated: onUpdated,
|
11243 | openBlock: openBlock,
|
11244 | popScopeId: popScopeId,
|
11245 | provide: provide,
|
11246 | proxyRefs: proxyRefs,
|
11247 | pushScopeId: pushScopeId,
|
11248 | queuePostFlushCb: queuePostFlushCb,
|
11249 | reactive: reactive,
|
11250 | readonly: readonly,
|
11251 | ref: ref,
|
11252 | registerRuntimeCompiler: registerRuntimeCompiler,
|
11253 | render: render,
|
11254 | renderList: renderList,
|
11255 | renderSlot: renderSlot,
|
11256 | resolveComponent: resolveComponent,
|
11257 | resolveDirective: resolveDirective,
|
11258 | resolveDynamicComponent: resolveDynamicComponent,
|
11259 | resolveFilter: resolveFilter,
|
11260 | resolveTransitionHooks: resolveTransitionHooks,
|
11261 | setBlockTracking: setBlockTracking,
|
11262 | setDevtoolsHook: setDevtoolsHook,
|
11263 | setTransitionHooks: setTransitionHooks,
|
11264 | shallowReactive: shallowReactive,
|
11265 | shallowReadonly: shallowReadonly,
|
11266 | shallowRef: shallowRef,
|
11267 | ssrContextKey: ssrContextKey,
|
11268 | ssrUtils: ssrUtils,
|
11269 | stop: stop,
|
11270 | toDisplayString: toDisplayString,
|
11271 | toHandlerKey: toHandlerKey,
|
11272 | toHandlers: toHandlers,
|
11273 | toRaw: toRaw,
|
11274 | toRef: toRef,
|
11275 | toRefs: toRefs,
|
11276 | toValue: toValue,
|
11277 | transformVNodeArgs: transformVNodeArgs,
|
11278 | triggerRef: triggerRef,
|
11279 | unref: unref,
|
11280 | useAttrs: useAttrs,
|
11281 | useCssModule: useCssModule,
|
11282 | useCssVars: useCssVars,
|
11283 | useModel: useModel,
|
11284 | useSSRContext: useSSRContext,
|
11285 | useSlots: useSlots,
|
11286 | useTransitionState: useTransitionState,
|
11287 | vModelCheckbox: vModelCheckbox,
|
11288 | vModelDynamic: vModelDynamic,
|
11289 | vModelRadio: vModelRadio,
|
11290 | vModelSelect: vModelSelect,
|
11291 | vModelText: vModelText,
|
11292 | vShow: vShow,
|
11293 | version: version,
|
11294 | warn: warn,
|
11295 | watch: watch,
|
11296 | watchEffect: watchEffect,
|
11297 | watchPostEffect: watchPostEffect,
|
11298 | watchSyncEffect: watchSyncEffect,
|
11299 | withAsyncContext: withAsyncContext,
|
11300 | withCtx: withCtx,
|
11301 | withDefaults: withDefaults,
|
11302 | withDirectives: withDirectives,
|
11303 | withKeys: withKeys,
|
11304 | withMemo: withMemo,
|
11305 | withModifiers: withModifiers,
|
11306 | withScopeId: withScopeId
|
11307 | });
|
11308 |
|
11309 | function initDev() {
|
11310 | {
|
11311 | {
|
11312 | console.info(
|
11313 | `You are running a development build of Vue.
|
11314 | Make sure to use the production build (*.prod.js) when deploying for production.`
|
11315 | );
|
11316 | }
|
11317 | initCustomFormatter();
|
11318 | }
|
11319 | }
|
11320 |
|
11321 | const FRAGMENT = Symbol(`Fragment` );
|
11322 | const TELEPORT = Symbol(`Teleport` );
|
11323 | const SUSPENSE = Symbol(`Suspense` );
|
11324 | const KEEP_ALIVE = Symbol(`KeepAlive` );
|
11325 | const BASE_TRANSITION = Symbol(`BaseTransition` );
|
11326 | const OPEN_BLOCK = Symbol(`openBlock` );
|
11327 | const CREATE_BLOCK = Symbol(`createBlock` );
|
11328 | const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
|
11329 | const CREATE_VNODE = Symbol(`createVNode` );
|
11330 | const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
|
11331 | const CREATE_COMMENT = Symbol(`createCommentVNode` );
|
11332 | const CREATE_TEXT = Symbol(`createTextVNode` );
|
11333 | const CREATE_STATIC = Symbol(`createStaticVNode` );
|
11334 | const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
|
11335 | const RESOLVE_DYNAMIC_COMPONENT = Symbol(
|
11336 | `resolveDynamicComponent`
|
11337 | );
|
11338 | const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
|
11339 | const RESOLVE_FILTER = Symbol(`resolveFilter` );
|
11340 | const WITH_DIRECTIVES = Symbol(`withDirectives` );
|
11341 | const RENDER_LIST = Symbol(`renderList` );
|
11342 | const RENDER_SLOT = Symbol(`renderSlot` );
|
11343 | const CREATE_SLOTS = Symbol(`createSlots` );
|
11344 | const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
|
11345 | const MERGE_PROPS = Symbol(`mergeProps` );
|
11346 | const NORMALIZE_CLASS = Symbol(`normalizeClass` );
|
11347 | const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
|
11348 | const NORMALIZE_PROPS = Symbol(`normalizeProps` );
|
11349 | const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
|
11350 | const TO_HANDLERS = Symbol(`toHandlers` );
|
11351 | const CAMELIZE = Symbol(`camelize` );
|
11352 | const CAPITALIZE = Symbol(`capitalize` );
|
11353 | const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
|
11354 | const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
|
11355 | const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
|
11356 | const POP_SCOPE_ID = Symbol(`popScopeId` );
|
11357 | const WITH_CTX = Symbol(`withCtx` );
|
11358 | const UNREF = Symbol(`unref` );
|
11359 | const IS_REF = Symbol(`isRef` );
|
11360 | const WITH_MEMO = Symbol(`withMemo` );
|
11361 | const IS_MEMO_SAME = Symbol(`isMemoSame` );
|
11362 | const helperNameMap = {
|
11363 | [FRAGMENT]: `Fragment`,
|
11364 | [TELEPORT]: `Teleport`,
|
11365 | [SUSPENSE]: `Suspense`,
|
11366 | [KEEP_ALIVE]: `KeepAlive`,
|
11367 | [BASE_TRANSITION]: `BaseTransition`,
|
11368 | [OPEN_BLOCK]: `openBlock`,
|
11369 | [CREATE_BLOCK]: `createBlock`,
|
11370 | [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
|
11371 | [CREATE_VNODE]: `createVNode`,
|
11372 | [CREATE_ELEMENT_VNODE]: `createElementVNode`,
|
11373 | [CREATE_COMMENT]: `createCommentVNode`,
|
11374 | [CREATE_TEXT]: `createTextVNode`,
|
11375 | [CREATE_STATIC]: `createStaticVNode`,
|
11376 | [RESOLVE_COMPONENT]: `resolveComponent`,
|
11377 | [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
|
11378 | [RESOLVE_DIRECTIVE]: `resolveDirective`,
|
11379 | [RESOLVE_FILTER]: `resolveFilter`,
|
11380 | [WITH_DIRECTIVES]: `withDirectives`,
|
11381 | [RENDER_LIST]: `renderList`,
|
11382 | [RENDER_SLOT]: `renderSlot`,
|
11383 | [CREATE_SLOTS]: `createSlots`,
|
11384 | [TO_DISPLAY_STRING]: `toDisplayString`,
|
11385 | [MERGE_PROPS]: `mergeProps`,
|
11386 | [NORMALIZE_CLASS]: `normalizeClass`,
|
11387 | [NORMALIZE_STYLE]: `normalizeStyle`,
|
11388 | [NORMALIZE_PROPS]: `normalizeProps`,
|
11389 | [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
|
11390 | [TO_HANDLERS]: `toHandlers`,
|
11391 | [CAMELIZE]: `camelize`,
|
11392 | [CAPITALIZE]: `capitalize`,
|
11393 | [TO_HANDLER_KEY]: `toHandlerKey`,
|
11394 | [SET_BLOCK_TRACKING]: `setBlockTracking`,
|
11395 | [PUSH_SCOPE_ID]: `pushScopeId`,
|
11396 | [POP_SCOPE_ID]: `popScopeId`,
|
11397 | [WITH_CTX]: `withCtx`,
|
11398 | [UNREF]: `unref`,
|
11399 | [IS_REF]: `isRef`,
|
11400 | [WITH_MEMO]: `withMemo`,
|
11401 | [IS_MEMO_SAME]: `isMemoSame`
|
11402 | };
|
11403 | function registerRuntimeHelpers(helpers) {
|
11404 | Object.getOwnPropertySymbols(helpers).forEach((s) => {
|
11405 | helperNameMap[s] = helpers[s];
|
11406 | });
|
11407 | }
|
11408 |
|
11409 | const locStub = {
|
11410 | start: { line: 1, column: 1, offset: 0 },
|
11411 | end: { line: 1, column: 1, offset: 0 },
|
11412 | source: ""
|
11413 | };
|
11414 | function createRoot(children, source = "") {
|
11415 | return {
|
11416 | type: 0,
|
11417 | source,
|
11418 | children,
|
11419 | helpers: new Set(),
|
11420 | components: [],
|
11421 | directives: [],
|
11422 | hoists: [],
|
11423 | imports: [],
|
11424 | cached: 0,
|
11425 | temps: 0,
|
11426 | codegenNode: void 0,
|
11427 | loc: locStub
|
11428 | };
|
11429 | }
|
11430 | function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
|
11431 | if (context) {
|
11432 | if (isBlock) {
|
11433 | context.helper(OPEN_BLOCK);
|
11434 | context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
|
11435 | } else {
|
11436 | context.helper(getVNodeHelper(context.inSSR, isComponent));
|
11437 | }
|
11438 | if (directives) {
|
11439 | context.helper(WITH_DIRECTIVES);
|
11440 | }
|
11441 | }
|
11442 | return {
|
11443 | type: 13,
|
11444 | tag,
|
11445 | props,
|
11446 | children,
|
11447 | patchFlag,
|
11448 | dynamicProps,
|
11449 | directives,
|
11450 | isBlock,
|
11451 | disableTracking,
|
11452 | isComponent,
|
11453 | loc
|
11454 | };
|
11455 | }
|
11456 | function createArrayExpression(elements, loc = locStub) {
|
11457 | return {
|
11458 | type: 17,
|
11459 | loc,
|
11460 | elements
|
11461 | };
|
11462 | }
|
11463 | function createObjectExpression(properties, loc = locStub) {
|
11464 | return {
|
11465 | type: 15,
|
11466 | loc,
|
11467 | properties
|
11468 | };
|
11469 | }
|
11470 | function createObjectProperty(key, value) {
|
11471 | return {
|
11472 | type: 16,
|
11473 | loc: locStub,
|
11474 | key: isString(key) ? createSimpleExpression(key, true) : key,
|
11475 | value
|
11476 | };
|
11477 | }
|
11478 | function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
|
11479 | return {
|
11480 | type: 4,
|
11481 | loc,
|
11482 | content,
|
11483 | isStatic,
|
11484 | constType: isStatic ? 3 : constType
|
11485 | };
|
11486 | }
|
11487 | function createCompoundExpression(children, loc = locStub) {
|
11488 | return {
|
11489 | type: 8,
|
11490 | loc,
|
11491 | children
|
11492 | };
|
11493 | }
|
11494 | function createCallExpression(callee, args = [], loc = locStub) {
|
11495 | return {
|
11496 | type: 14,
|
11497 | loc,
|
11498 | callee,
|
11499 | arguments: args
|
11500 | };
|
11501 | }
|
11502 | function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
|
11503 | return {
|
11504 | type: 18,
|
11505 | params,
|
11506 | returns,
|
11507 | newline,
|
11508 | isSlot,
|
11509 | loc
|
11510 | };
|
11511 | }
|
11512 | function createConditionalExpression(test, consequent, alternate, newline = true) {
|
11513 | return {
|
11514 | type: 19,
|
11515 | test,
|
11516 | consequent,
|
11517 | alternate,
|
11518 | newline,
|
11519 | loc: locStub
|
11520 | };
|
11521 | }
|
11522 | function createCacheExpression(index, value, isVNode = false) {
|
11523 | return {
|
11524 | type: 20,
|
11525 | index,
|
11526 | value,
|
11527 | isVNode,
|
11528 | loc: locStub
|
11529 | };
|
11530 | }
|
11531 | function createBlockStatement(body) {
|
11532 | return {
|
11533 | type: 21,
|
11534 | body,
|
11535 | loc: locStub
|
11536 | };
|
11537 | }
|
11538 | function getVNodeHelper(ssr, isComponent) {
|
11539 | return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
11540 | }
|
11541 | function getVNodeBlockHelper(ssr, isComponent) {
|
11542 | return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
|
11543 | }
|
11544 | function convertToBlock(node, { helper, removeHelper, inSSR }) {
|
11545 | if (!node.isBlock) {
|
11546 | node.isBlock = true;
|
11547 | removeHelper(getVNodeHelper(inSSR, node.isComponent));
|
11548 | helper(OPEN_BLOCK);
|
11549 | helper(getVNodeBlockHelper(inSSR, node.isComponent));
|
11550 | }
|
11551 | }
|
11552 |
|
11553 | const defaultDelimitersOpen = new Uint8Array([123, 123]);
|
11554 | const defaultDelimitersClose = new Uint8Array([125, 125]);
|
11555 | function isTagStartChar(c) {
|
11556 | return c >= 97 && c <= 122 || c >= 65 && c <= 90;
|
11557 | }
|
11558 | function isWhitespace(c) {
|
11559 | return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
|
11560 | }
|
11561 | function isEndOfTagSection(c) {
|
11562 | return c === 47 || c === 62 || isWhitespace(c);
|
11563 | }
|
11564 | function toCharCodes(str) {
|
11565 | const ret = new Uint8Array(str.length);
|
11566 | for (let i = 0; i < str.length; i++) {
|
11567 | ret[i] = str.charCodeAt(i);
|
11568 | }
|
11569 | return ret;
|
11570 | }
|
11571 | const Sequences = {
|
11572 | Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
|
11573 |
|
11574 | CdataEnd: new Uint8Array([93, 93, 62]),
|
11575 |
|
11576 | CommentEnd: new Uint8Array([45, 45, 62]),
|
11577 |
|
11578 | ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
|
11579 |
|
11580 | StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
|
11581 |
|
11582 | TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
|
11583 |
|
11584 | TextareaEnd: new Uint8Array([
|
11585 | 60,
|
11586 | 47,
|
11587 | 116,
|
11588 | 101,
|
11589 | 120,
|
11590 | 116,
|
11591 | 97,
|
11592 | 114,
|
11593 | 101,
|
11594 | 97
|
11595 | ])
|
11596 |
|
11597 | };
|
11598 | class Tokenizer {
|
11599 | constructor(stack, cbs) {
|
11600 | this.stack = stack;
|
11601 | this.cbs = cbs;
|
11602 |
|
11603 | this.state = 1;
|
11604 |
|
11605 | this.buffer = "";
|
11606 |
|
11607 | this.sectionStart = 0;
|
11608 |
|
11609 | this.index = 0;
|
11610 |
|
11611 | this.entityStart = 0;
|
11612 |
|
11613 | this.baseState = 1;
|
11614 |
|
11615 | this.inRCDATA = false;
|
11616 |
|
11617 | this.inXML = false;
|
11618 |
|
11619 | this.inVPre = false;
|
11620 |
|
11621 | this.newlines = [];
|
11622 | this.mode = 0;
|
11623 | this.delimiterOpen = defaultDelimitersOpen;
|
11624 | this.delimiterClose = defaultDelimitersClose;
|
11625 | this.delimiterIndex = -1;
|
11626 | this.currentSequence = void 0;
|
11627 | this.sequenceIndex = 0;
|
11628 | }
|
11629 | get inSFCRoot() {
|
11630 | return this.mode === 2 && this.stack.length === 0;
|
11631 | }
|
11632 | reset() {
|
11633 | this.state = 1;
|
11634 | this.mode = 0;
|
11635 | this.buffer = "";
|
11636 | this.sectionStart = 0;
|
11637 | this.index = 0;
|
11638 | this.baseState = 1;
|
11639 | this.inRCDATA = false;
|
11640 | this.currentSequence = void 0;
|
11641 | this.newlines.length = 0;
|
11642 | this.delimiterOpen = defaultDelimitersOpen;
|
11643 | this.delimiterClose = defaultDelimitersClose;
|
11644 | }
|
11645 | |
11646 |
|
11647 |
|
11648 |
|
11649 |
|
11650 |
|
11651 | getPos(index) {
|
11652 | let line = 1;
|
11653 | let column = index + 1;
|
11654 | for (let i = this.newlines.length - 1; i >= 0; i--) {
|
11655 | const newlineIndex = this.newlines[i];
|
11656 | if (index > newlineIndex) {
|
11657 | line = i + 2;
|
11658 | column = index - newlineIndex;
|
11659 | break;
|
11660 | }
|
11661 | }
|
11662 | return {
|
11663 | column,
|
11664 | line,
|
11665 | offset: index
|
11666 | };
|
11667 | }
|
11668 | peek() {
|
11669 | return this.buffer.charCodeAt(this.index + 1);
|
11670 | }
|
11671 | stateText(c) {
|
11672 | if (c === 60) {
|
11673 | if (this.index > this.sectionStart) {
|
11674 | this.cbs.ontext(this.sectionStart, this.index);
|
11675 | }
|
11676 | this.state = 5;
|
11677 | this.sectionStart = this.index;
|
11678 | } else if (!this.inVPre && c === this.delimiterOpen[0]) {
|
11679 | this.state = 2;
|
11680 | this.delimiterIndex = 0;
|
11681 | this.stateInterpolationOpen(c);
|
11682 | }
|
11683 | }
|
11684 | stateInterpolationOpen(c) {
|
11685 | if (c === this.delimiterOpen[this.delimiterIndex]) {
|
11686 | if (this.delimiterIndex === this.delimiterOpen.length - 1) {
|
11687 | const start = this.index + 1 - this.delimiterOpen.length;
|
11688 | if (start > this.sectionStart) {
|
11689 | this.cbs.ontext(this.sectionStart, start);
|
11690 | }
|
11691 | this.state = 3;
|
11692 | this.sectionStart = start;
|
11693 | } else {
|
11694 | this.delimiterIndex++;
|
11695 | }
|
11696 | } else if (this.inRCDATA) {
|
11697 | this.state = 32;
|
11698 | this.stateInRCDATA(c);
|
11699 | } else {
|
11700 | this.state = 1;
|
11701 | this.stateText(c);
|
11702 | }
|
11703 | }
|
11704 | stateInterpolation(c) {
|
11705 | if (c === this.delimiterClose[0]) {
|
11706 | this.state = 4;
|
11707 | this.delimiterIndex = 0;
|
11708 | this.stateInterpolationClose(c);
|
11709 | }
|
11710 | }
|
11711 | stateInterpolationClose(c) {
|
11712 | if (c === this.delimiterClose[this.delimiterIndex]) {
|
11713 | if (this.delimiterIndex === this.delimiterClose.length - 1) {
|
11714 | this.cbs.oninterpolation(this.sectionStart, this.index + 1);
|
11715 | if (this.inRCDATA) {
|
11716 | this.state = 32;
|
11717 | } else {
|
11718 | this.state = 1;
|
11719 | }
|
11720 | this.sectionStart = this.index + 1;
|
11721 | } else {
|
11722 | this.delimiterIndex++;
|
11723 | }
|
11724 | } else {
|
11725 | this.state = 3;
|
11726 | this.stateInterpolation(c);
|
11727 | }
|
11728 | }
|
11729 | stateSpecialStartSequence(c) {
|
11730 | const isEnd = this.sequenceIndex === this.currentSequence.length;
|
11731 | const isMatch = isEnd ? (
|
11732 |
|
11733 | isEndOfTagSection(c)
|
11734 | ) : (
|
11735 |
|
11736 | (c | 32) === this.currentSequence[this.sequenceIndex]
|
11737 | );
|
11738 | if (!isMatch) {
|
11739 | this.inRCDATA = false;
|
11740 | } else if (!isEnd) {
|
11741 | this.sequenceIndex++;
|
11742 | return;
|
11743 | }
|
11744 | this.sequenceIndex = 0;
|
11745 | this.state = 6;
|
11746 | this.stateInTagName(c);
|
11747 | }
|
11748 |
|
11749 | stateInRCDATA(c) {
|
11750 | if (this.sequenceIndex === this.currentSequence.length) {
|
11751 | if (c === 62 || isWhitespace(c)) {
|
11752 | const endOfText = this.index - this.currentSequence.length;
|
11753 | if (this.sectionStart < endOfText) {
|
11754 | const actualIndex = this.index;
|
11755 | this.index = endOfText;
|
11756 | this.cbs.ontext(this.sectionStart, endOfText);
|
11757 | this.index = actualIndex;
|
11758 | }
|
11759 | this.sectionStart = endOfText + 2;
|
11760 | this.stateInClosingTagName(c);
|
11761 | this.inRCDATA = false;
|
11762 | return;
|
11763 | }
|
11764 | this.sequenceIndex = 0;
|
11765 | }
|
11766 | if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
|
11767 | this.sequenceIndex += 1;
|
11768 | } else if (this.sequenceIndex === 0) {
|
11769 | if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
|
11770 | if (c === this.delimiterOpen[0]) {
|
11771 | this.state = 2;
|
11772 | this.delimiterIndex = 0;
|
11773 | this.stateInterpolationOpen(c);
|
11774 | }
|
11775 | } else if (this.fastForwardTo(60)) {
|
11776 | this.sequenceIndex = 1;
|
11777 | }
|
11778 | } else {
|
11779 | this.sequenceIndex = Number(c === 60);
|
11780 | }
|
11781 | }
|
11782 | stateCDATASequence(c) {
|
11783 | if (c === Sequences.Cdata[this.sequenceIndex]) {
|
11784 | if (++this.sequenceIndex === Sequences.Cdata.length) {
|
11785 | this.state = 28;
|
11786 | this.currentSequence = Sequences.CdataEnd;
|
11787 | this.sequenceIndex = 0;
|
11788 | this.sectionStart = this.index + 1;
|
11789 | }
|
11790 | } else {
|
11791 | this.sequenceIndex = 0;
|
11792 | this.state = 23;
|
11793 | this.stateInDeclaration(c);
|
11794 | }
|
11795 | }
|
11796 | |
11797 |
|
11798 |
|
11799 |
|
11800 |
|
11801 |
|
11802 | fastForwardTo(c) {
|
11803 | while (++this.index < this.buffer.length) {
|
11804 | const cc = this.buffer.charCodeAt(this.index);
|
11805 | if (cc === 10) {
|
11806 | this.newlines.push(this.index);
|
11807 | }
|
11808 | if (cc === c) {
|
11809 | return true;
|
11810 | }
|
11811 | }
|
11812 | this.index = this.buffer.length - 1;
|
11813 | return false;
|
11814 | }
|
11815 | |
11816 |
|
11817 |
|
11818 |
|
11819 |
|
11820 |
|
11821 |
|
11822 |
|
11823 | stateInCommentLike(c) {
|
11824 | if (c === this.currentSequence[this.sequenceIndex]) {
|
11825 | if (++this.sequenceIndex === this.currentSequence.length) {
|
11826 | if (this.currentSequence === Sequences.CdataEnd) {
|
11827 | this.cbs.oncdata(this.sectionStart, this.index - 2);
|
11828 | } else {
|
11829 | this.cbs.oncomment(this.sectionStart, this.index - 2);
|
11830 | }
|
11831 | this.sequenceIndex = 0;
|
11832 | this.sectionStart = this.index + 1;
|
11833 | this.state = 1;
|
11834 | }
|
11835 | } else if (this.sequenceIndex === 0) {
|
11836 | if (this.fastForwardTo(this.currentSequence[0])) {
|
11837 | this.sequenceIndex = 1;
|
11838 | }
|
11839 | } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
|
11840 | this.sequenceIndex = 0;
|
11841 | }
|
11842 | }
|
11843 | startSpecial(sequence, offset) {
|
11844 | this.enterRCDATA(sequence, offset);
|
11845 | this.state = 31;
|
11846 | }
|
11847 | enterRCDATA(sequence, offset) {
|
11848 | this.inRCDATA = true;
|
11849 | this.currentSequence = sequence;
|
11850 | this.sequenceIndex = offset;
|
11851 | }
|
11852 | stateBeforeTagName(c) {
|
11853 | if (c === 33) {
|
11854 | this.state = 22;
|
11855 | this.sectionStart = this.index + 1;
|
11856 | } else if (c === 63) {
|
11857 | this.state = 24;
|
11858 | this.sectionStart = this.index + 1;
|
11859 | } else if (isTagStartChar(c)) {
|
11860 | this.sectionStart = this.index;
|
11861 | if (this.mode === 0) {
|
11862 | this.state = 6;
|
11863 | } else if (this.inSFCRoot) {
|
11864 | this.state = 34;
|
11865 | } else if (!this.inXML) {
|
11866 | const lower = c | 32;
|
11867 | if (lower === 116) {
|
11868 | this.state = 30;
|
11869 | } else {
|
11870 | this.state = lower === 115 ? 29 : 6;
|
11871 | }
|
11872 | } else {
|
11873 | this.state = 6;
|
11874 | }
|
11875 | } else if (c === 47) {
|
11876 | this.state = 8;
|
11877 | } else {
|
11878 | this.state = 1;
|
11879 | this.stateText(c);
|
11880 | }
|
11881 | }
|
11882 | stateInTagName(c) {
|
11883 | if (isEndOfTagSection(c)) {
|
11884 | this.handleTagName(c);
|
11885 | }
|
11886 | }
|
11887 | stateInSFCRootTagName(c) {
|
11888 | if (isEndOfTagSection(c)) {
|
11889 | const tag = this.buffer.slice(this.sectionStart, this.index);
|
11890 | if (tag !== "template") {
|
11891 | this.enterRCDATA(toCharCodes(`</` + tag), 0);
|
11892 | }
|
11893 | this.handleTagName(c);
|
11894 | }
|
11895 | }
|
11896 | handleTagName(c) {
|
11897 | this.cbs.onopentagname(this.sectionStart, this.index);
|
11898 | this.sectionStart = -1;
|
11899 | this.state = 11;
|
11900 | this.stateBeforeAttrName(c);
|
11901 | }
|
11902 | stateBeforeClosingTagName(c) {
|
11903 | if (isWhitespace(c)) ; else if (c === 62) {
|
11904 | {
|
11905 | this.cbs.onerr(14, this.index);
|
11906 | }
|
11907 | this.state = 1;
|
11908 | this.sectionStart = this.index + 1;
|
11909 | } else {
|
11910 | this.state = isTagStartChar(c) ? 9 : 27;
|
11911 | this.sectionStart = this.index;
|
11912 | }
|
11913 | }
|
11914 | stateInClosingTagName(c) {
|
11915 | if (c === 62 || isWhitespace(c)) {
|
11916 | this.cbs.onclosetag(this.sectionStart, this.index);
|
11917 | this.sectionStart = -1;
|
11918 | this.state = 10;
|
11919 | this.stateAfterClosingTagName(c);
|
11920 | }
|
11921 | }
|
11922 | stateAfterClosingTagName(c) {
|
11923 | if (c === 62) {
|
11924 | this.state = 1;
|
11925 | this.sectionStart = this.index + 1;
|
11926 | }
|
11927 | }
|
11928 | stateBeforeAttrName(c) {
|
11929 | if (c === 62) {
|
11930 | this.cbs.onopentagend(this.index);
|
11931 | if (this.inRCDATA) {
|
11932 | this.state = 32;
|
11933 | } else {
|
11934 | this.state = 1;
|
11935 | }
|
11936 | this.sectionStart = this.index + 1;
|
11937 | } else if (c === 47) {
|
11938 | this.state = 7;
|
11939 | if (this.peek() !== 62) {
|
11940 | this.cbs.onerr(22, this.index);
|
11941 | }
|
11942 | } else if (c === 60 && this.peek() === 47) {
|
11943 | this.cbs.onopentagend(this.index);
|
11944 | this.state = 5;
|
11945 | this.sectionStart = this.index;
|
11946 | } else if (!isWhitespace(c)) {
|
11947 | if (c === 61) {
|
11948 | this.cbs.onerr(
|
11949 | 19,
|
11950 | this.index
|
11951 | );
|
11952 | }
|
11953 | this.handleAttrStart(c);
|
11954 | }
|
11955 | }
|
11956 | handleAttrStart(c) {
|
11957 | if (c === 118 && this.peek() === 45) {
|
11958 | this.state = 13;
|
11959 | this.sectionStart = this.index;
|
11960 | } else if (c === 46 || c === 58 || c === 64 || c === 35) {
|
11961 | this.cbs.ondirname(this.index, this.index + 1);
|
11962 | this.state = 14;
|
11963 | this.sectionStart = this.index + 1;
|
11964 | } else {
|
11965 | this.state = 12;
|
11966 | this.sectionStart = this.index;
|
11967 | }
|
11968 | }
|
11969 | stateInSelfClosingTag(c) {
|
11970 | if (c === 62) {
|
11971 | this.cbs.onselfclosingtag(this.index);
|
11972 | this.state = 1;
|
11973 | this.sectionStart = this.index + 1;
|
11974 | this.inRCDATA = false;
|
11975 | } else if (!isWhitespace(c)) {
|
11976 | this.state = 11;
|
11977 | this.stateBeforeAttrName(c);
|
11978 | }
|
11979 | }
|
11980 | stateInAttrName(c) {
|
11981 | if (c === 61 || isEndOfTagSection(c)) {
|
11982 | this.cbs.onattribname(this.sectionStart, this.index);
|
11983 | this.handleAttrNameEnd(c);
|
11984 | } else if (c === 34 || c === 39 || c === 60) {
|
11985 | this.cbs.onerr(
|
11986 | 17,
|
11987 | this.index
|
11988 | );
|
11989 | }
|
11990 | }
|
11991 | stateInDirName(c) {
|
11992 | if (c === 61 || isEndOfTagSection(c)) {
|
11993 | this.cbs.ondirname(this.sectionStart, this.index);
|
11994 | this.handleAttrNameEnd(c);
|
11995 | } else if (c === 58) {
|
11996 | this.cbs.ondirname(this.sectionStart, this.index);
|
11997 | this.state = 14;
|
11998 | this.sectionStart = this.index + 1;
|
11999 | } else if (c === 46) {
|
12000 | this.cbs.ondirname(this.sectionStart, this.index);
|
12001 | this.state = 16;
|
12002 | this.sectionStart = this.index + 1;
|
12003 | }
|
12004 | }
|
12005 | stateInDirArg(c) {
|
12006 | if (c === 61 || isEndOfTagSection(c)) {
|
12007 | this.cbs.ondirarg(this.sectionStart, this.index);
|
12008 | this.handleAttrNameEnd(c);
|
12009 | } else if (c === 91) {
|
12010 | this.state = 15;
|
12011 | } else if (c === 46) {
|
12012 | this.cbs.ondirarg(this.sectionStart, this.index);
|
12013 | this.state = 16;
|
12014 | this.sectionStart = this.index + 1;
|
12015 | }
|
12016 | }
|
12017 | stateInDynamicDirArg(c) {
|
12018 | if (c === 93) {
|
12019 | this.state = 14;
|
12020 | } else if (c === 61 || isEndOfTagSection(c)) {
|
12021 | this.cbs.ondirarg(this.sectionStart, this.index + 1);
|
12022 | this.handleAttrNameEnd(c);
|
12023 | {
|
12024 | this.cbs.onerr(
|
12025 | 27,
|
12026 | this.index
|
12027 | );
|
12028 | }
|
12029 | }
|
12030 | }
|
12031 | stateInDirModifier(c) {
|
12032 | if (c === 61 || isEndOfTagSection(c)) {
|
12033 | this.cbs.ondirmodifier(this.sectionStart, this.index);
|
12034 | this.handleAttrNameEnd(c);
|
12035 | } else if (c === 46) {
|
12036 | this.cbs.ondirmodifier(this.sectionStart, this.index);
|
12037 | this.sectionStart = this.index + 1;
|
12038 | }
|
12039 | }
|
12040 | handleAttrNameEnd(c) {
|
12041 | this.sectionStart = this.index;
|
12042 | this.state = 17;
|
12043 | this.cbs.onattribnameend(this.index);
|
12044 | this.stateAfterAttrName(c);
|
12045 | }
|
12046 | stateAfterAttrName(c) {
|
12047 | if (c === 61) {
|
12048 | this.state = 18;
|
12049 | } else if (c === 47 || c === 62) {
|
12050 | this.cbs.onattribend(0, this.sectionStart);
|
12051 | this.sectionStart = -1;
|
12052 | this.state = 11;
|
12053 | this.stateBeforeAttrName(c);
|
12054 | } else if (!isWhitespace(c)) {
|
12055 | this.cbs.onattribend(0, this.sectionStart);
|
12056 | this.handleAttrStart(c);
|
12057 | }
|
12058 | }
|
12059 | stateBeforeAttrValue(c) {
|
12060 | if (c === 34) {
|
12061 | this.state = 19;
|
12062 | this.sectionStart = this.index + 1;
|
12063 | } else if (c === 39) {
|
12064 | this.state = 20;
|
12065 | this.sectionStart = this.index + 1;
|
12066 | } else if (!isWhitespace(c)) {
|
12067 | this.sectionStart = this.index;
|
12068 | this.state = 21;
|
12069 | this.stateInAttrValueNoQuotes(c);
|
12070 | }
|
12071 | }
|
12072 | handleInAttrValue(c, quote) {
|
12073 | if (c === quote || this.fastForwardTo(quote)) {
|
12074 | this.cbs.onattribdata(this.sectionStart, this.index);
|
12075 | this.sectionStart = -1;
|
12076 | this.cbs.onattribend(
|
12077 | quote === 34 ? 3 : 2,
|
12078 | this.index + 1
|
12079 | );
|
12080 | this.state = 11;
|
12081 | }
|
12082 | }
|
12083 | stateInAttrValueDoubleQuotes(c) {
|
12084 | this.handleInAttrValue(c, 34);
|
12085 | }
|
12086 | stateInAttrValueSingleQuotes(c) {
|
12087 | this.handleInAttrValue(c, 39);
|
12088 | }
|
12089 | stateInAttrValueNoQuotes(c) {
|
12090 | if (isWhitespace(c) || c === 62) {
|
12091 | this.cbs.onattribdata(this.sectionStart, this.index);
|
12092 | this.sectionStart = -1;
|
12093 | this.cbs.onattribend(1, this.index);
|
12094 | this.state = 11;
|
12095 | this.stateBeforeAttrName(c);
|
12096 | } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
|
12097 | this.cbs.onerr(
|
12098 | 18,
|
12099 | this.index
|
12100 | );
|
12101 | } else ;
|
12102 | }
|
12103 | stateBeforeDeclaration(c) {
|
12104 | if (c === 91) {
|
12105 | this.state = 26;
|
12106 | this.sequenceIndex = 0;
|
12107 | } else {
|
12108 | this.state = c === 45 ? 25 : 23;
|
12109 | }
|
12110 | }
|
12111 | stateInDeclaration(c) {
|
12112 | if (c === 62 || this.fastForwardTo(62)) {
|
12113 | this.state = 1;
|
12114 | this.sectionStart = this.index + 1;
|
12115 | }
|
12116 | }
|
12117 | stateInProcessingInstruction(c) {
|
12118 | if (c === 62 || this.fastForwardTo(62)) {
|
12119 | this.cbs.onprocessinginstruction(this.sectionStart, this.index);
|
12120 | this.state = 1;
|
12121 | this.sectionStart = this.index + 1;
|
12122 | }
|
12123 | }
|
12124 | stateBeforeComment(c) {
|
12125 | if (c === 45) {
|
12126 | this.state = 28;
|
12127 | this.currentSequence = Sequences.CommentEnd;
|
12128 | this.sequenceIndex = 2;
|
12129 | this.sectionStart = this.index + 1;
|
12130 | } else {
|
12131 | this.state = 23;
|
12132 | }
|
12133 | }
|
12134 | stateInSpecialComment(c) {
|
12135 | if (c === 62 || this.fastForwardTo(62)) {
|
12136 | this.cbs.oncomment(this.sectionStart, this.index);
|
12137 | this.state = 1;
|
12138 | this.sectionStart = this.index + 1;
|
12139 | }
|
12140 | }
|
12141 | stateBeforeSpecialS(c) {
|
12142 | const lower = c | 32;
|
12143 | if (lower === Sequences.ScriptEnd[3]) {
|
12144 | this.startSpecial(Sequences.ScriptEnd, 4);
|
12145 | } else if (lower === Sequences.StyleEnd[3]) {
|
12146 | this.startSpecial(Sequences.StyleEnd, 4);
|
12147 | } else {
|
12148 | this.state = 6;
|
12149 | this.stateInTagName(c);
|
12150 | }
|
12151 | }
|
12152 | stateBeforeSpecialT(c) {
|
12153 | const lower = c | 32;
|
12154 | if (lower === Sequences.TitleEnd[3]) {
|
12155 | this.startSpecial(Sequences.TitleEnd, 4);
|
12156 | } else if (lower === Sequences.TextareaEnd[3]) {
|
12157 | this.startSpecial(Sequences.TextareaEnd, 4);
|
12158 | } else {
|
12159 | this.state = 6;
|
12160 | this.stateInTagName(c);
|
12161 | }
|
12162 | }
|
12163 | startEntity() {
|
12164 | }
|
12165 | stateInEntity() {
|
12166 | }
|
12167 | |
12168 |
|
12169 |
|
12170 |
|
12171 |
|
12172 | parse(input) {
|
12173 | this.buffer = input;
|
12174 | while (this.index < this.buffer.length) {
|
12175 | const c = this.buffer.charCodeAt(this.index);
|
12176 | if (c === 10) {
|
12177 | this.newlines.push(this.index);
|
12178 | }
|
12179 | switch (this.state) {
|
12180 | case 1: {
|
12181 | this.stateText(c);
|
12182 | break;
|
12183 | }
|
12184 | case 2: {
|
12185 | this.stateInterpolationOpen(c);
|
12186 | break;
|
12187 | }
|
12188 | case 3: {
|
12189 | this.stateInterpolation(c);
|
12190 | break;
|
12191 | }
|
12192 | case 4: {
|
12193 | this.stateInterpolationClose(c);
|
12194 | break;
|
12195 | }
|
12196 | case 31: {
|
12197 | this.stateSpecialStartSequence(c);
|
12198 | break;
|
12199 | }
|
12200 | case 32: {
|
12201 | this.stateInRCDATA(c);
|
12202 | break;
|
12203 | }
|
12204 | case 26: {
|
12205 | this.stateCDATASequence(c);
|
12206 | break;
|
12207 | }
|
12208 | case 19: {
|
12209 | this.stateInAttrValueDoubleQuotes(c);
|
12210 | break;
|
12211 | }
|
12212 | case 12: {
|
12213 | this.stateInAttrName(c);
|
12214 | break;
|
12215 | }
|
12216 | case 13: {
|
12217 | this.stateInDirName(c);
|
12218 | break;
|
12219 | }
|
12220 | case 14: {
|
12221 | this.stateInDirArg(c);
|
12222 | break;
|
12223 | }
|
12224 | case 15: {
|
12225 | this.stateInDynamicDirArg(c);
|
12226 | break;
|
12227 | }
|
12228 | case 16: {
|
12229 | this.stateInDirModifier(c);
|
12230 | break;
|
12231 | }
|
12232 | case 28: {
|
12233 | this.stateInCommentLike(c);
|
12234 | break;
|
12235 | }
|
12236 | case 27: {
|
12237 | this.stateInSpecialComment(c);
|
12238 | break;
|
12239 | }
|
12240 | case 11: {
|
12241 | this.stateBeforeAttrName(c);
|
12242 | break;
|
12243 | }
|
12244 | case 6: {
|
12245 | this.stateInTagName(c);
|
12246 | break;
|
12247 | }
|
12248 | case 34: {
|
12249 | this.stateInSFCRootTagName(c);
|
12250 | break;
|
12251 | }
|
12252 | case 9: {
|
12253 | this.stateInClosingTagName(c);
|
12254 | break;
|
12255 | }
|
12256 | case 5: {
|
12257 | this.stateBeforeTagName(c);
|
12258 | break;
|
12259 | }
|
12260 | case 17: {
|
12261 | this.stateAfterAttrName(c);
|
12262 | break;
|
12263 | }
|
12264 | case 20: {
|
12265 | this.stateInAttrValueSingleQuotes(c);
|
12266 | break;
|
12267 | }
|
12268 | case 18: {
|
12269 | this.stateBeforeAttrValue(c);
|
12270 | break;
|
12271 | }
|
12272 | case 8: {
|
12273 | this.stateBeforeClosingTagName(c);
|
12274 | break;
|
12275 | }
|
12276 | case 10: {
|
12277 | this.stateAfterClosingTagName(c);
|
12278 | break;
|
12279 | }
|
12280 | case 29: {
|
12281 | this.stateBeforeSpecialS(c);
|
12282 | break;
|
12283 | }
|
12284 | case 30: {
|
12285 | this.stateBeforeSpecialT(c);
|
12286 | break;
|
12287 | }
|
12288 | case 21: {
|
12289 | this.stateInAttrValueNoQuotes(c);
|
12290 | break;
|
12291 | }
|
12292 | case 7: {
|
12293 | this.stateInSelfClosingTag(c);
|
12294 | break;
|
12295 | }
|
12296 | case 23: {
|
12297 | this.stateInDeclaration(c);
|
12298 | break;
|
12299 | }
|
12300 | case 22: {
|
12301 | this.stateBeforeDeclaration(c);
|
12302 | break;
|
12303 | }
|
12304 | case 25: {
|
12305 | this.stateBeforeComment(c);
|
12306 | break;
|
12307 | }
|
12308 | case 24: {
|
12309 | this.stateInProcessingInstruction(c);
|
12310 | break;
|
12311 | }
|
12312 | case 33: {
|
12313 | this.stateInEntity();
|
12314 | break;
|
12315 | }
|
12316 | }
|
12317 | this.index++;
|
12318 | }
|
12319 | this.cleanup();
|
12320 | this.finish();
|
12321 | }
|
12322 | |
12323 |
|
12324 |
|
12325 | cleanup() {
|
12326 | if (this.sectionStart !== this.index) {
|
12327 | if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
|
12328 | this.cbs.ontext(this.sectionStart, this.index);
|
12329 | this.sectionStart = this.index;
|
12330 | } else if (this.state === 19 || this.state === 20 || this.state === 21) {
|
12331 | this.cbs.onattribdata(this.sectionStart, this.index);
|
12332 | this.sectionStart = this.index;
|
12333 | }
|
12334 | }
|
12335 | }
|
12336 | finish() {
|
12337 | this.handleTrailingData();
|
12338 | this.cbs.onend();
|
12339 | }
|
12340 |
|
12341 | handleTrailingData() {
|
12342 | const endIndex = this.buffer.length;
|
12343 | if (this.sectionStart >= endIndex) {
|
12344 | return;
|
12345 | }
|
12346 | if (this.state === 28) {
|
12347 | if (this.currentSequence === Sequences.CdataEnd) {
|
12348 | this.cbs.oncdata(this.sectionStart, endIndex);
|
12349 | } else {
|
12350 | this.cbs.oncomment(this.sectionStart, endIndex);
|
12351 | }
|
12352 | } 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 {
|
12353 | this.cbs.ontext(this.sectionStart, endIndex);
|
12354 | }
|
12355 | }
|
12356 | emitCodePoint(cp, consumed) {
|
12357 | }
|
12358 | }
|
12359 |
|
12360 | function defaultOnError(error) {
|
12361 | throw error;
|
12362 | }
|
12363 | function defaultOnWarn(msg) {
|
12364 | console.warn(`[Vue warn] ${msg.message}`);
|
12365 | }
|
12366 | function createCompilerError(code, loc, messages, additionalMessage) {
|
12367 | const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
|
12368 | const error = new SyntaxError(String(msg));
|
12369 | error.code = code;
|
12370 | error.loc = loc;
|
12371 | return error;
|
12372 | }
|
12373 | const errorMessages = {
|
12374 |
|
12375 | [0]: "Illegal comment.",
|
12376 | [1]: "CDATA section is allowed only in XML context.",
|
12377 | [2]: "Duplicate attribute.",
|
12378 | [3]: "End tag cannot have attributes.",
|
12379 | [4]: "Illegal '/' in tags.",
|
12380 | [5]: "Unexpected EOF in tag.",
|
12381 | [6]: "Unexpected EOF in CDATA section.",
|
12382 | [7]: "Unexpected EOF in comment.",
|
12383 | [8]: "Unexpected EOF in script.",
|
12384 | [9]: "Unexpected EOF in tag.",
|
12385 | [10]: "Incorrectly closed comment.",
|
12386 | [11]: "Incorrectly opened comment.",
|
12387 | [12]: "Illegal tag name. Use '<' to print '<'.",
|
12388 | [13]: "Attribute value was expected.",
|
12389 | [14]: "End tag name was expected.",
|
12390 | [15]: "Whitespace was expected.",
|
12391 | [16]: "Unexpected '<!--' in comment.",
|
12392 | [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
12393 | [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
12394 | [19]: "Attribute name cannot start with '='.",
|
12395 | [21]: "'<?' is allowed only in XML context.",
|
12396 | [20]: `Unexpected null character.`,
|
12397 | [22]: "Illegal '/' in tags.",
|
12398 |
|
12399 | [23]: "Invalid end tag.",
|
12400 | [24]: "Element is missing end tag.",
|
12401 | [25]: "Interpolation end sign was not found.",
|
12402 | [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
12403 | [26]: "Legal directive name was expected.",
|
12404 |
|
12405 | [28]: `v-if/v-else-if is missing expression.`,
|
12406 | [29]: `v-if/else branches must use unique keys.`,
|
12407 | [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
12408 | [31]: `v-for is missing expression.`,
|
12409 | [32]: `v-for has invalid expression.`,
|
12410 | [33]: `<template v-for> key should be placed on the <template> tag.`,
|
12411 | [34]: `v-bind is missing expression.`,
|
12412 | [52]: `v-bind with same-name shorthand only allows static argument.`,
|
12413 | [35]: `v-on is missing expression.`,
|
12414 | [36]: `Unexpected custom directive on <slot> outlet.`,
|
12415 | [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.`,
|
12416 | [38]: `Duplicate slot names found. `,
|
12417 | [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
12418 | [40]: `v-slot can only be used on components or <template> tags.`,
|
12419 | [41]: `v-model is missing expression.`,
|
12420 | [42]: `v-model value must be a valid JavaScript member expression.`,
|
12421 | [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
12422 | [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
12423 | Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
12424 | [45]: `Error parsing JavaScript expression: `,
|
12425 | [46]: `<KeepAlive> expects exactly one child component.`,
|
12426 | [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.`,
|
12427 |
|
12428 | [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
12429 | [48]: `ES module mode is not supported in this build of compiler.`,
|
12430 | [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
12431 | [50]: `"scopeId" option is only supported in module mode.`,
|
12432 |
|
12433 | [53]: ``
|
12434 | };
|
12435 |
|
12436 | const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
12437 | function isCoreComponent(tag) {
|
12438 | switch (tag) {
|
12439 | case "Teleport":
|
12440 | case "teleport":
|
12441 | return TELEPORT;
|
12442 | case "Suspense":
|
12443 | case "suspense":
|
12444 | return SUSPENSE;
|
12445 | case "KeepAlive":
|
12446 | case "keep-alive":
|
12447 | return KEEP_ALIVE;
|
12448 | case "BaseTransition":
|
12449 | case "base-transition":
|
12450 | return BASE_TRANSITION;
|
12451 | }
|
12452 | }
|
12453 | const nonIdentifierRE = /^\d|[^\$\w]/;
|
12454 | const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
12455 | const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
12456 | const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
12457 | const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
|
12458 | const isMemberExpressionBrowser = (path) => {
|
12459 | path = path.trim().replace(whitespaceRE, (s) => s.trim());
|
12460 | let state = 0 ;
|
12461 | let stateStack = [];
|
12462 | let currentOpenBracketCount = 0;
|
12463 | let currentOpenParensCount = 0;
|
12464 | let currentStringType = null;
|
12465 | for (let i = 0; i < path.length; i++) {
|
12466 | const char = path.charAt(i);
|
12467 | switch (state) {
|
12468 | case 0 :
|
12469 | if (char === "[") {
|
12470 | stateStack.push(state);
|
12471 | state = 1 ;
|
12472 | currentOpenBracketCount++;
|
12473 | } else if (char === "(") {
|
12474 | stateStack.push(state);
|
12475 | state = 2 ;
|
12476 | currentOpenParensCount++;
|
12477 | } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
|
12478 | return false;
|
12479 | }
|
12480 | break;
|
12481 | case 1 :
|
12482 | if (char === `'` || char === `"` || char === "`") {
|
12483 | stateStack.push(state);
|
12484 | state = 3 ;
|
12485 | currentStringType = char;
|
12486 | } else if (char === `[`) {
|
12487 | currentOpenBracketCount++;
|
12488 | } else if (char === `]`) {
|
12489 | if (!--currentOpenBracketCount) {
|
12490 | state = stateStack.pop();
|
12491 | }
|
12492 | }
|
12493 | break;
|
12494 | case 2 :
|
12495 | if (char === `'` || char === `"` || char === "`") {
|
12496 | stateStack.push(state);
|
12497 | state = 3 ;
|
12498 | currentStringType = char;
|
12499 | } else if (char === `(`) {
|
12500 | currentOpenParensCount++;
|
12501 | } else if (char === `)`) {
|
12502 | if (i === path.length - 1) {
|
12503 | return false;
|
12504 | }
|
12505 | if (!--currentOpenParensCount) {
|
12506 | state = stateStack.pop();
|
12507 | }
|
12508 | }
|
12509 | break;
|
12510 | case 3 :
|
12511 | if (char === currentStringType) {
|
12512 | state = stateStack.pop();
|
12513 | currentStringType = null;
|
12514 | }
|
12515 | break;
|
12516 | }
|
12517 | }
|
12518 | return !currentOpenBracketCount && !currentOpenParensCount;
|
12519 | };
|
12520 | const isMemberExpression = isMemberExpressionBrowser ;
|
12521 | function assert(condition, msg) {
|
12522 | if (!condition) {
|
12523 | throw new Error(msg || `unexpected compiler condition`);
|
12524 | }
|
12525 | }
|
12526 | function findDir(node, name, allowEmpty = false) {
|
12527 | for (let i = 0; i < node.props.length; i++) {
|
12528 | const p = node.props[i];
|
12529 | if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
|
12530 | return p;
|
12531 | }
|
12532 | }
|
12533 | }
|
12534 | function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
12535 | for (let i = 0; i < node.props.length; i++) {
|
12536 | const p = node.props[i];
|
12537 | if (p.type === 6) {
|
12538 | if (dynamicOnly)
|
12539 | continue;
|
12540 | if (p.name === name && (p.value || allowEmpty)) {
|
12541 | return p;
|
12542 | }
|
12543 | } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
|
12544 | return p;
|
12545 | }
|
12546 | }
|
12547 | }
|
12548 | function isStaticArgOf(arg, name) {
|
12549 | return !!(arg && isStaticExp(arg) && arg.content === name);
|
12550 | }
|
12551 | function hasDynamicKeyVBind(node) {
|
12552 | return node.props.some(
|
12553 | (p) => p.type === 7 && p.name === "bind" && (!p.arg ||
|
12554 | p.arg.type !== 4 ||
|
12555 | !p.arg.isStatic)
|
12556 |
|
12557 | );
|
12558 | }
|
12559 | function isText$1(node) {
|
12560 | return node.type === 5 || node.type === 2;
|
12561 | }
|
12562 | function isVSlot(p) {
|
12563 | return p.type === 7 && p.name === "slot";
|
12564 | }
|
12565 | function isTemplateNode(node) {
|
12566 | return node.type === 1 && node.tagType === 3;
|
12567 | }
|
12568 | function isSlotOutlet(node) {
|
12569 | return node.type === 1 && node.tagType === 2;
|
12570 | }
|
12571 | const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
12572 | function getUnnormalizedProps(props, callPath = []) {
|
12573 | if (props && !isString(props) && props.type === 14) {
|
12574 | const callee = props.callee;
|
12575 | if (!isString(callee) && propsHelperSet.has(callee)) {
|
12576 | return getUnnormalizedProps(
|
12577 | props.arguments[0],
|
12578 | callPath.concat(props)
|
12579 | );
|
12580 | }
|
12581 | }
|
12582 | return [props, callPath];
|
12583 | }
|
12584 | function injectProp(node, prop, context) {
|
12585 | let propsWithInjection;
|
12586 | let props = node.type === 13 ? node.props : node.arguments[2];
|
12587 | let callPath = [];
|
12588 | let parentCall;
|
12589 | if (props && !isString(props) && props.type === 14) {
|
12590 | const ret = getUnnormalizedProps(props);
|
12591 | props = ret[0];
|
12592 | callPath = ret[1];
|
12593 | parentCall = callPath[callPath.length - 1];
|
12594 | }
|
12595 | if (props == null || isString(props)) {
|
12596 | propsWithInjection = createObjectExpression([prop]);
|
12597 | } else if (props.type === 14) {
|
12598 | const first = props.arguments[0];
|
12599 | if (!isString(first) && first.type === 15) {
|
12600 | if (!hasProp(prop, first)) {
|
12601 | first.properties.unshift(prop);
|
12602 | }
|
12603 | } else {
|
12604 | if (props.callee === TO_HANDLERS) {
|
12605 | propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
|
12606 | createObjectExpression([prop]),
|
12607 | props
|
12608 | ]);
|
12609 | } else {
|
12610 | props.arguments.unshift(createObjectExpression([prop]));
|
12611 | }
|
12612 | }
|
12613 | !propsWithInjection && (propsWithInjection = props);
|
12614 | } else if (props.type === 15) {
|
12615 | if (!hasProp(prop, props)) {
|
12616 | props.properties.unshift(prop);
|
12617 | }
|
12618 | propsWithInjection = props;
|
12619 | } else {
|
12620 | propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
|
12621 | createObjectExpression([prop]),
|
12622 | props
|
12623 | ]);
|
12624 | if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
|
12625 | parentCall = callPath[callPath.length - 2];
|
12626 | }
|
12627 | }
|
12628 | if (node.type === 13) {
|
12629 | if (parentCall) {
|
12630 | parentCall.arguments[0] = propsWithInjection;
|
12631 | } else {
|
12632 | node.props = propsWithInjection;
|
12633 | }
|
12634 | } else {
|
12635 | if (parentCall) {
|
12636 | parentCall.arguments[0] = propsWithInjection;
|
12637 | } else {
|
12638 | node.arguments[2] = propsWithInjection;
|
12639 | }
|
12640 | }
|
12641 | }
|
12642 | function hasProp(prop, props) {
|
12643 | let result = false;
|
12644 | if (prop.key.type === 4) {
|
12645 | const propKeyName = prop.key.content;
|
12646 | result = props.properties.some(
|
12647 | (p) => p.key.type === 4 && p.key.content === propKeyName
|
12648 | );
|
12649 | }
|
12650 | return result;
|
12651 | }
|
12652 | function toValidAssetId(name, type) {
|
12653 | return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
|
12654 | return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
|
12655 | })}`;
|
12656 | }
|
12657 | function getMemoedVNodeCall(node) {
|
12658 | if (node.type === 14 && node.callee === WITH_MEMO) {
|
12659 | return node.arguments[1].returns;
|
12660 | } else {
|
12661 | return node;
|
12662 | }
|
12663 | }
|
12664 | const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
12665 |
|
12666 | const defaultParserOptions = {
|
12667 | parseMode: "base",
|
12668 | ns: 0,
|
12669 | delimiters: [`{{`, `}}`],
|
12670 | getNamespace: () => 0,
|
12671 | isVoidTag: NO,
|
12672 | isPreTag: NO,
|
12673 | isCustomElement: NO,
|
12674 | onError: defaultOnError,
|
12675 | onWarn: defaultOnWarn,
|
12676 | comments: true,
|
12677 | prefixIdentifiers: false
|
12678 | };
|
12679 | let currentOptions = defaultParserOptions;
|
12680 | let currentRoot = null;
|
12681 | let currentInput = "";
|
12682 | let currentOpenTag = null;
|
12683 | let currentProp = null;
|
12684 | let currentAttrValue = "";
|
12685 | let currentAttrStartIndex = -1;
|
12686 | let currentAttrEndIndex = -1;
|
12687 | let inPre = 0;
|
12688 | let inVPre = false;
|
12689 | let currentVPreBoundary = null;
|
12690 | const stack = [];
|
12691 | const tokenizer = new Tokenizer(stack, {
|
12692 | onerr: emitError,
|
12693 | ontext(start, end) {
|
12694 | onText(getSlice(start, end), start, end);
|
12695 | },
|
12696 | ontextentity(char, start, end) {
|
12697 | onText(char, start, end);
|
12698 | },
|
12699 | oninterpolation(start, end) {
|
12700 | if (inVPre) {
|
12701 | return onText(getSlice(start, end), start, end);
|
12702 | }
|
12703 | let innerStart = start + tokenizer.delimiterOpen.length;
|
12704 | let innerEnd = end - tokenizer.delimiterClose.length;
|
12705 | while (isWhitespace(currentInput.charCodeAt(innerStart))) {
|
12706 | innerStart++;
|
12707 | }
|
12708 | while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
|
12709 | innerEnd--;
|
12710 | }
|
12711 | let exp = getSlice(innerStart, innerEnd);
|
12712 | if (exp.includes("&")) {
|
12713 | {
|
12714 | exp = currentOptions.decodeEntities(exp, false);
|
12715 | }
|
12716 | }
|
12717 | addNode({
|
12718 | type: 5,
|
12719 | content: createExp(exp, false, getLoc(innerStart, innerEnd)),
|
12720 | loc: getLoc(start, end)
|
12721 | });
|
12722 | },
|
12723 | onopentagname(start, end) {
|
12724 | const name = getSlice(start, end);
|
12725 | currentOpenTag = {
|
12726 | type: 1,
|
12727 | tag: name,
|
12728 | ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
|
12729 | tagType: 0,
|
12730 |
|
12731 | props: [],
|
12732 | children: [],
|
12733 | loc: getLoc(start - 1, end),
|
12734 | codegenNode: void 0
|
12735 | };
|
12736 | },
|
12737 | onopentagend(end) {
|
12738 | endOpenTag(end);
|
12739 | },
|
12740 | onclosetag(start, end) {
|
12741 | const name = getSlice(start, end);
|
12742 | if (!currentOptions.isVoidTag(name)) {
|
12743 | let found = false;
|
12744 | for (let i = 0; i < stack.length; i++) {
|
12745 | const e = stack[i];
|
12746 | if (e.tag.toLowerCase() === name.toLowerCase()) {
|
12747 | found = true;
|
12748 | if (i > 0) {
|
12749 | emitError(24, stack[0].loc.start.offset);
|
12750 | }
|
12751 | for (let j = 0; j <= i; j++) {
|
12752 | const el = stack.shift();
|
12753 | onCloseTag(el, end, j < i);
|
12754 | }
|
12755 | break;
|
12756 | }
|
12757 | }
|
12758 | if (!found) {
|
12759 | emitError(23, backTrack(start, 60));
|
12760 | }
|
12761 | }
|
12762 | },
|
12763 | onselfclosingtag(end) {
|
12764 | var _a;
|
12765 | const name = currentOpenTag.tag;
|
12766 | currentOpenTag.isSelfClosing = true;
|
12767 | endOpenTag(end);
|
12768 | if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
|
12769 | onCloseTag(stack.shift(), end);
|
12770 | }
|
12771 | },
|
12772 | onattribname(start, end) {
|
12773 | currentProp = {
|
12774 | type: 6,
|
12775 | name: getSlice(start, end),
|
12776 | nameLoc: getLoc(start, end),
|
12777 | value: void 0,
|
12778 | loc: getLoc(start)
|
12779 | };
|
12780 | },
|
12781 | ondirname(start, end) {
|
12782 | const raw = getSlice(start, end);
|
12783 | const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
|
12784 | if (!inVPre && name === "") {
|
12785 | emitError(26, start);
|
12786 | }
|
12787 | if (inVPre || name === "") {
|
12788 | currentProp = {
|
12789 | type: 6,
|
12790 | name: raw,
|
12791 | nameLoc: getLoc(start, end),
|
12792 | value: void 0,
|
12793 | loc: getLoc(start)
|
12794 | };
|
12795 | } else {
|
12796 | currentProp = {
|
12797 | type: 7,
|
12798 | name,
|
12799 | rawName: raw,
|
12800 | exp: void 0,
|
12801 | arg: void 0,
|
12802 | modifiers: raw === "." ? ["prop"] : [],
|
12803 | loc: getLoc(start)
|
12804 | };
|
12805 | if (name === "pre") {
|
12806 | inVPre = tokenizer.inVPre = true;
|
12807 | currentVPreBoundary = currentOpenTag;
|
12808 | const props = currentOpenTag.props;
|
12809 | for (let i = 0; i < props.length; i++) {
|
12810 | if (props[i].type === 7) {
|
12811 | props[i] = dirToAttr(props[i]);
|
12812 | }
|
12813 | }
|
12814 | }
|
12815 | }
|
12816 | },
|
12817 | ondirarg(start, end) {
|
12818 | if (start === end)
|
12819 | return;
|
12820 | const arg = getSlice(start, end);
|
12821 | if (inVPre) {
|
12822 | currentProp.name += arg;
|
12823 | setLocEnd(currentProp.nameLoc, end);
|
12824 | } else {
|
12825 | const isStatic = arg[0] !== `[`;
|
12826 | currentProp.arg = createExp(
|
12827 | isStatic ? arg : arg.slice(1, -1),
|
12828 | isStatic,
|
12829 | getLoc(start, end),
|
12830 | isStatic ? 3 : 0
|
12831 | );
|
12832 | }
|
12833 | },
|
12834 | ondirmodifier(start, end) {
|
12835 | const mod = getSlice(start, end);
|
12836 | if (inVPre) {
|
12837 | currentProp.name += "." + mod;
|
12838 | setLocEnd(currentProp.nameLoc, end);
|
12839 | } else if (currentProp.name === "slot") {
|
12840 | const arg = currentProp.arg;
|
12841 | if (arg) {
|
12842 | arg.content += "." + mod;
|
12843 | setLocEnd(arg.loc, end);
|
12844 | }
|
12845 | } else {
|
12846 | currentProp.modifiers.push(mod);
|
12847 | }
|
12848 | },
|
12849 | onattribdata(start, end) {
|
12850 | currentAttrValue += getSlice(start, end);
|
12851 | if (currentAttrStartIndex < 0)
|
12852 | currentAttrStartIndex = start;
|
12853 | currentAttrEndIndex = end;
|
12854 | },
|
12855 | onattribentity(char, start, end) {
|
12856 | currentAttrValue += char;
|
12857 | if (currentAttrStartIndex < 0)
|
12858 | currentAttrStartIndex = start;
|
12859 | currentAttrEndIndex = end;
|
12860 | },
|
12861 | onattribnameend(end) {
|
12862 | const start = currentProp.loc.start.offset;
|
12863 | const name = getSlice(start, end);
|
12864 | if (currentProp.type === 7) {
|
12865 | currentProp.rawName = name;
|
12866 | }
|
12867 | if (currentOpenTag.props.some(
|
12868 | (p) => (p.type === 7 ? p.rawName : p.name) === name
|
12869 | )) {
|
12870 | emitError(2, start);
|
12871 | }
|
12872 | },
|
12873 | onattribend(quote, end) {
|
12874 | if (currentOpenTag && currentProp) {
|
12875 | setLocEnd(currentProp.loc, end);
|
12876 | if (quote !== 0) {
|
12877 | if (currentAttrValue.includes("&")) {
|
12878 | currentAttrValue = currentOptions.decodeEntities(
|
12879 | currentAttrValue,
|
12880 | true
|
12881 | );
|
12882 | }
|
12883 | if (currentProp.type === 6) {
|
12884 | if (currentProp.name === "class") {
|
12885 | currentAttrValue = condense(currentAttrValue).trim();
|
12886 | }
|
12887 | if (quote === 1 && !currentAttrValue) {
|
12888 | emitError(13, end);
|
12889 | }
|
12890 | currentProp.value = {
|
12891 | type: 2,
|
12892 | content: currentAttrValue,
|
12893 | loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
|
12894 | };
|
12895 | if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
|
12896 | tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
|
12897 | }
|
12898 | } else {
|
12899 | let expParseMode = 0 ;
|
12900 | currentProp.exp = createExp(
|
12901 | currentAttrValue,
|
12902 | false,
|
12903 | getLoc(currentAttrStartIndex, currentAttrEndIndex),
|
12904 | 0,
|
12905 | expParseMode
|
12906 | );
|
12907 | if (currentProp.name === "for") {
|
12908 | currentProp.forParseResult = parseForExpression(currentProp.exp);
|
12909 | }
|
12910 | }
|
12911 | }
|
12912 | if (currentProp.type !== 7 || currentProp.name !== "pre") {
|
12913 | currentOpenTag.props.push(currentProp);
|
12914 | }
|
12915 | }
|
12916 | currentAttrValue = "";
|
12917 | currentAttrStartIndex = currentAttrEndIndex = -1;
|
12918 | },
|
12919 | oncomment(start, end) {
|
12920 | if (currentOptions.comments) {
|
12921 | addNode({
|
12922 | type: 3,
|
12923 | content: getSlice(start, end),
|
12924 | loc: getLoc(start - 4, end + 3)
|
12925 | });
|
12926 | }
|
12927 | },
|
12928 | onend() {
|
12929 | const end = currentInput.length;
|
12930 | if (tokenizer.state !== 1) {
|
12931 | switch (tokenizer.state) {
|
12932 | case 5:
|
12933 | case 8:
|
12934 | emitError(5, end);
|
12935 | break;
|
12936 | case 3:
|
12937 | case 4:
|
12938 | emitError(
|
12939 | 25,
|
12940 | tokenizer.sectionStart
|
12941 | );
|
12942 | break;
|
12943 | case 28:
|
12944 | if (tokenizer.currentSequence === Sequences.CdataEnd) {
|
12945 | emitError(6, end);
|
12946 | } else {
|
12947 | emitError(7, end);
|
12948 | }
|
12949 | break;
|
12950 | case 6:
|
12951 | case 7:
|
12952 | case 9:
|
12953 | case 11:
|
12954 | case 12:
|
12955 | case 13:
|
12956 | case 14:
|
12957 | case 15:
|
12958 | case 16:
|
12959 | case 17:
|
12960 | case 18:
|
12961 | case 19:
|
12962 | case 20:
|
12963 | case 21:
|
12964 | emitError(9, end);
|
12965 | break;
|
12966 | }
|
12967 | }
|
12968 | for (let index = 0; index < stack.length; index++) {
|
12969 | onCloseTag(stack[index], end - 1);
|
12970 | emitError(24, stack[index].loc.start.offset);
|
12971 | }
|
12972 | },
|
12973 | oncdata(start, end) {
|
12974 | if (stack[0].ns !== 0) {
|
12975 | onText(getSlice(start, end), start, end);
|
12976 | } else {
|
12977 | emitError(1, start - 9);
|
12978 | }
|
12979 | },
|
12980 | onprocessinginstruction(start) {
|
12981 | if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
12982 | emitError(
|
12983 | 21,
|
12984 | start - 1
|
12985 | );
|
12986 | }
|
12987 | }
|
12988 | });
|
12989 | const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
12990 | const stripParensRE = /^\(|\)$/g;
|
12991 | function parseForExpression(input) {
|
12992 | const loc = input.loc;
|
12993 | const exp = input.content;
|
12994 | const inMatch = exp.match(forAliasRE);
|
12995 | if (!inMatch)
|
12996 | return;
|
12997 | const [, LHS, RHS] = inMatch;
|
12998 | const createAliasExpression = (content, offset, asParam = false) => {
|
12999 | const start = loc.start.offset + offset;
|
13000 | const end = start + content.length;
|
13001 | return createExp(
|
13002 | content,
|
13003 | false,
|
13004 | getLoc(start, end),
|
13005 | 0,
|
13006 | asParam ? 1 : 0
|
13007 | );
|
13008 | };
|
13009 | const result = {
|
13010 | source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
13011 | value: void 0,
|
13012 | key: void 0,
|
13013 | index: void 0,
|
13014 | finalized: false
|
13015 | };
|
13016 | let valueContent = LHS.trim().replace(stripParensRE, "").trim();
|
13017 | const trimmedOffset = LHS.indexOf(valueContent);
|
13018 | const iteratorMatch = valueContent.match(forIteratorRE);
|
13019 | if (iteratorMatch) {
|
13020 | valueContent = valueContent.replace(forIteratorRE, "").trim();
|
13021 | const keyContent = iteratorMatch[1].trim();
|
13022 | let keyOffset;
|
13023 | if (keyContent) {
|
13024 | keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
13025 | result.key = createAliasExpression(keyContent, keyOffset, true);
|
13026 | }
|
13027 | if (iteratorMatch[2]) {
|
13028 | const indexContent = iteratorMatch[2].trim();
|
13029 | if (indexContent) {
|
13030 | result.index = createAliasExpression(
|
13031 | indexContent,
|
13032 | exp.indexOf(
|
13033 | indexContent,
|
13034 | result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
13035 | ),
|
13036 | true
|
13037 | );
|
13038 | }
|
13039 | }
|
13040 | }
|
13041 | if (valueContent) {
|
13042 | result.value = createAliasExpression(valueContent, trimmedOffset, true);
|
13043 | }
|
13044 | return result;
|
13045 | }
|
13046 | function getSlice(start, end) {
|
13047 | return currentInput.slice(start, end);
|
13048 | }
|
13049 | function endOpenTag(end) {
|
13050 | if (tokenizer.inSFCRoot) {
|
13051 | currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
|
13052 | }
|
13053 | addNode(currentOpenTag);
|
13054 | const { tag, ns } = currentOpenTag;
|
13055 | if (ns === 0 && currentOptions.isPreTag(tag)) {
|
13056 | inPre++;
|
13057 | }
|
13058 | if (currentOptions.isVoidTag(tag)) {
|
13059 | onCloseTag(currentOpenTag, end);
|
13060 | } else {
|
13061 | stack.unshift(currentOpenTag);
|
13062 | if (ns === 1 || ns === 2) {
|
13063 | tokenizer.inXML = true;
|
13064 | }
|
13065 | }
|
13066 | currentOpenTag = null;
|
13067 | }
|
13068 | function onText(content, start, end) {
|
13069 | var _a;
|
13070 | {
|
13071 | const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
|
13072 | if (tag !== "script" && tag !== "style" && content.includes("&")) {
|
13073 | content = currentOptions.decodeEntities(content, false);
|
13074 | }
|
13075 | }
|
13076 | const parent = stack[0] || currentRoot;
|
13077 | const lastNode = parent.children[parent.children.length - 1];
|
13078 | if ((lastNode == null ? void 0 : lastNode.type) === 2) {
|
13079 | lastNode.content += content;
|
13080 | setLocEnd(lastNode.loc, end);
|
13081 | } else {
|
13082 | parent.children.push({
|
13083 | type: 2,
|
13084 | content,
|
13085 | loc: getLoc(start, end)
|
13086 | });
|
13087 | }
|
13088 | }
|
13089 | function onCloseTag(el, end, isImplied = false) {
|
13090 | if (isImplied) {
|
13091 | setLocEnd(el.loc, backTrack(end, 60));
|
13092 | } else {
|
13093 | setLocEnd(el.loc, end + 1);
|
13094 | }
|
13095 | if (tokenizer.inSFCRoot) {
|
13096 | if (el.children.length) {
|
13097 | el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
|
13098 | } else {
|
13099 | el.innerLoc.end = extend({}, el.innerLoc.start);
|
13100 | }
|
13101 | el.innerLoc.source = getSlice(
|
13102 | el.innerLoc.start.offset,
|
13103 | el.innerLoc.end.offset
|
13104 | );
|
13105 | }
|
13106 | const { tag, ns } = el;
|
13107 | if (!inVPre) {
|
13108 | if (tag === "slot") {
|
13109 | el.tagType = 2;
|
13110 | } else if (isFragmentTemplate(el)) {
|
13111 | el.tagType = 3;
|
13112 | } else if (isComponent(el)) {
|
13113 | el.tagType = 1;
|
13114 | }
|
13115 | }
|
13116 | if (!tokenizer.inRCDATA) {
|
13117 | el.children = condenseWhitespace(el.children, el.tag);
|
13118 | }
|
13119 | if (ns === 0 && currentOptions.isPreTag(tag)) {
|
13120 | inPre--;
|
13121 | }
|
13122 | if (currentVPreBoundary === el) {
|
13123 | inVPre = tokenizer.inVPre = false;
|
13124 | currentVPreBoundary = null;
|
13125 | }
|
13126 | if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
13127 | tokenizer.inXML = false;
|
13128 | }
|
13129 | }
|
13130 | function backTrack(index, c) {
|
13131 | let i = index;
|
13132 | while (currentInput.charCodeAt(i) !== c && i >= 0)
|
13133 | i--;
|
13134 | return i;
|
13135 | }
|
13136 | const specialTemplateDir = new Set(["if", "else", "else-if", "for", "slot"]);
|
13137 | function isFragmentTemplate({ tag, props }) {
|
13138 | if (tag === "template") {
|
13139 | for (let i = 0; i < props.length; i++) {
|
13140 | if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
|
13141 | return true;
|
13142 | }
|
13143 | }
|
13144 | }
|
13145 | return false;
|
13146 | }
|
13147 | function isComponent({ tag, props }) {
|
13148 | var _a;
|
13149 | if (currentOptions.isCustomElement(tag)) {
|
13150 | return false;
|
13151 | }
|
13152 | if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
|
13153 | return true;
|
13154 | }
|
13155 | for (let i = 0; i < props.length; i++) {
|
13156 | const p = props[i];
|
13157 | if (p.type === 6) {
|
13158 | if (p.name === "is" && p.value) {
|
13159 | if (p.value.content.startsWith("vue:")) {
|
13160 | return true;
|
13161 | }
|
13162 | }
|
13163 | }
|
13164 | }
|
13165 | return false;
|
13166 | }
|
13167 | function isUpperCase(c) {
|
13168 | return c > 64 && c < 91;
|
13169 | }
|
13170 | const windowsNewlineRE = /\r\n/g;
|
13171 | function condenseWhitespace(nodes, tag) {
|
13172 | var _a, _b;
|
13173 | const shouldCondense = currentOptions.whitespace !== "preserve";
|
13174 | let removedWhitespace = false;
|
13175 | for (let i = 0; i < nodes.length; i++) {
|
13176 | const node = nodes[i];
|
13177 | if (node.type === 2) {
|
13178 | if (!inPre) {
|
13179 | if (isAllWhitespace(node.content)) {
|
13180 | const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
|
13181 | const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
|
13182 | if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
|
13183 | removedWhitespace = true;
|
13184 | nodes[i] = null;
|
13185 | } else {
|
13186 | node.content = " ";
|
13187 | }
|
13188 | } else if (shouldCondense) {
|
13189 | node.content = condense(node.content);
|
13190 | }
|
13191 | } else {
|
13192 | node.content = node.content.replace(windowsNewlineRE, "\n");
|
13193 | }
|
13194 | }
|
13195 | }
|
13196 | if (inPre && tag && currentOptions.isPreTag(tag)) {
|
13197 | const first = nodes[0];
|
13198 | if (first && first.type === 2) {
|
13199 | first.content = first.content.replace(/^\r?\n/, "");
|
13200 | }
|
13201 | }
|
13202 | return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
13203 | }
|
13204 | function isAllWhitespace(str) {
|
13205 | for (let i = 0; i < str.length; i++) {
|
13206 | if (!isWhitespace(str.charCodeAt(i))) {
|
13207 | return false;
|
13208 | }
|
13209 | }
|
13210 | return true;
|
13211 | }
|
13212 | function hasNewlineChar(str) {
|
13213 | for (let i = 0; i < str.length; i++) {
|
13214 | const c = str.charCodeAt(i);
|
13215 | if (c === 10 || c === 13) {
|
13216 | return true;
|
13217 | }
|
13218 | }
|
13219 | return false;
|
13220 | }
|
13221 | function condense(str) {
|
13222 | let ret = "";
|
13223 | let prevCharIsWhitespace = false;
|
13224 | for (let i = 0; i < str.length; i++) {
|
13225 | if (isWhitespace(str.charCodeAt(i))) {
|
13226 | if (!prevCharIsWhitespace) {
|
13227 | ret += " ";
|
13228 | prevCharIsWhitespace = true;
|
13229 | }
|
13230 | } else {
|
13231 | ret += str[i];
|
13232 | prevCharIsWhitespace = false;
|
13233 | }
|
13234 | }
|
13235 | return ret;
|
13236 | }
|
13237 | function addNode(node) {
|
13238 | (stack[0] || currentRoot).children.push(node);
|
13239 | }
|
13240 | function getLoc(start, end) {
|
13241 | return {
|
13242 | start: tokenizer.getPos(start),
|
13243 |
|
13244 | end: end == null ? end : tokenizer.getPos(end),
|
13245 |
|
13246 | source: end == null ? end : getSlice(start, end)
|
13247 | };
|
13248 | }
|
13249 | function setLocEnd(loc, end) {
|
13250 | loc.end = tokenizer.getPos(end);
|
13251 | loc.source = getSlice(loc.start.offset, end);
|
13252 | }
|
13253 | function dirToAttr(dir) {
|
13254 | const attr = {
|
13255 | type: 6,
|
13256 | name: dir.rawName,
|
13257 | nameLoc: getLoc(
|
13258 | dir.loc.start.offset,
|
13259 | dir.loc.start.offset + dir.rawName.length
|
13260 | ),
|
13261 | value: void 0,
|
13262 | loc: dir.loc
|
13263 | };
|
13264 | if (dir.exp) {
|
13265 | const loc = dir.exp.loc;
|
13266 | if (loc.end.offset < dir.loc.end.offset) {
|
13267 | loc.start.offset--;
|
13268 | loc.start.column--;
|
13269 | loc.end.offset++;
|
13270 | loc.end.column++;
|
13271 | }
|
13272 | attr.value = {
|
13273 | type: 2,
|
13274 | content: dir.exp.content,
|
13275 | loc
|
13276 | };
|
13277 | }
|
13278 | return attr;
|
13279 | }
|
13280 | function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
|
13281 | const exp = createSimpleExpression(content, isStatic, loc, constType);
|
13282 | return exp;
|
13283 | }
|
13284 | function emitError(code, index, message) {
|
13285 | currentOptions.onError(
|
13286 | createCompilerError(code, getLoc(index, index), void 0, message)
|
13287 | );
|
13288 | }
|
13289 | function reset() {
|
13290 | tokenizer.reset();
|
13291 | currentOpenTag = null;
|
13292 | currentProp = null;
|
13293 | currentAttrValue = "";
|
13294 | currentAttrStartIndex = -1;
|
13295 | currentAttrEndIndex = -1;
|
13296 | stack.length = 0;
|
13297 | }
|
13298 | function baseParse(input, options) {
|
13299 | reset();
|
13300 | currentInput = input;
|
13301 | currentOptions = extend({}, defaultParserOptions);
|
13302 | if (options) {
|
13303 | let key;
|
13304 | for (key in options) {
|
13305 | if (options[key] != null) {
|
13306 | currentOptions[key] = options[key];
|
13307 | }
|
13308 | }
|
13309 | }
|
13310 | {
|
13311 | if (!currentOptions.decodeEntities) {
|
13312 | throw new Error(
|
13313 | `[@vue/compiler-core] decodeEntities option is required in browser builds.`
|
13314 | );
|
13315 | }
|
13316 | }
|
13317 | tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
13318 | tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
|
13319 | const delimiters = options == null ? void 0 : options.delimiters;
|
13320 | if (delimiters) {
|
13321 | tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
|
13322 | tokenizer.delimiterClose = toCharCodes(delimiters[1]);
|
13323 | }
|
13324 | const root = currentRoot = createRoot([], input);
|
13325 | tokenizer.parse(currentInput);
|
13326 | root.loc = getLoc(0, input.length);
|
13327 | root.children = condenseWhitespace(root.children);
|
13328 | currentRoot = null;
|
13329 | return root;
|
13330 | }
|
13331 |
|
13332 | function hoistStatic(root, context) {
|
13333 | walk(
|
13334 | root,
|
13335 | context,
|
13336 |
|
13337 |
|
13338 | isSingleElementRoot(root, root.children[0])
|
13339 | );
|
13340 | }
|
13341 | function isSingleElementRoot(root, child) {
|
13342 | const { children } = root;
|
13343 | return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
|
13344 | }
|
13345 | function walk(node, context, doNotHoistNode = false) {
|
13346 | const { children } = node;
|
13347 | const originalCount = children.length;
|
13348 | let hoistedCount = 0;
|
13349 | for (let i = 0; i < children.length; i++) {
|
13350 | const child = children[i];
|
13351 | if (child.type === 1 && child.tagType === 0) {
|
13352 | const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
13353 | if (constantType > 0) {
|
13354 | if (constantType >= 2) {
|
13355 | child.codegenNode.patchFlag = -1 + (` /* HOISTED */` );
|
13356 | child.codegenNode = context.hoist(child.codegenNode);
|
13357 | hoistedCount++;
|
13358 | continue;
|
13359 | }
|
13360 | } else {
|
13361 | const codegenNode = child.codegenNode;
|
13362 | if (codegenNode.type === 13) {
|
13363 | const flag = getPatchFlag(codegenNode);
|
13364 | if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
|
13365 | const props = getNodeProps(child);
|
13366 | if (props) {
|
13367 | codegenNode.props = context.hoist(props);
|
13368 | }
|
13369 | }
|
13370 | if (codegenNode.dynamicProps) {
|
13371 | codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
|
13372 | }
|
13373 | }
|
13374 | }
|
13375 | }
|
13376 | if (child.type === 1) {
|
13377 | const isComponent = child.tagType === 1;
|
13378 | if (isComponent) {
|
13379 | context.scopes.vSlot++;
|
13380 | }
|
13381 | walk(child, context);
|
13382 | if (isComponent) {
|
13383 | context.scopes.vSlot--;
|
13384 | }
|
13385 | } else if (child.type === 11) {
|
13386 | walk(child, context, child.children.length === 1);
|
13387 | } else if (child.type === 9) {
|
13388 | for (let i2 = 0; i2 < child.branches.length; i2++) {
|
13389 | walk(
|
13390 | child.branches[i2],
|
13391 | context,
|
13392 | child.branches[i2].children.length === 1
|
13393 | );
|
13394 | }
|
13395 | }
|
13396 | }
|
13397 | if (hoistedCount && context.transformHoist) {
|
13398 | context.transformHoist(children, context, node);
|
13399 | }
|
13400 | if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
|
13401 | const hoisted = context.hoist(
|
13402 | createArrayExpression(node.codegenNode.children)
|
13403 | );
|
13404 | if (context.hmr) {
|
13405 | hoisted.content = `[...${hoisted.content}]`;
|
13406 | }
|
13407 | node.codegenNode.children = hoisted;
|
13408 | }
|
13409 | }
|
13410 | function getConstantType(node, context) {
|
13411 | const { constantCache } = context;
|
13412 | switch (node.type) {
|
13413 | case 1:
|
13414 | if (node.tagType !== 0) {
|
13415 | return 0;
|
13416 | }
|
13417 | const cached = constantCache.get(node);
|
13418 | if (cached !== void 0) {
|
13419 | return cached;
|
13420 | }
|
13421 | const codegenNode = node.codegenNode;
|
13422 | if (codegenNode.type !== 13) {
|
13423 | return 0;
|
13424 | }
|
13425 | if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
|
13426 | return 0;
|
13427 | }
|
13428 | const flag = getPatchFlag(codegenNode);
|
13429 | if (!flag) {
|
13430 | let returnType2 = 3;
|
13431 | const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
13432 | if (generatedPropsType === 0) {
|
13433 | constantCache.set(node, 0);
|
13434 | return 0;
|
13435 | }
|
13436 | if (generatedPropsType < returnType2) {
|
13437 | returnType2 = generatedPropsType;
|
13438 | }
|
13439 | for (let i = 0; i < node.children.length; i++) {
|
13440 | const childType = getConstantType(node.children[i], context);
|
13441 | if (childType === 0) {
|
13442 | constantCache.set(node, 0);
|
13443 | return 0;
|
13444 | }
|
13445 | if (childType < returnType2) {
|
13446 | returnType2 = childType;
|
13447 | }
|
13448 | }
|
13449 | if (returnType2 > 1) {
|
13450 | for (let i = 0; i < node.props.length; i++) {
|
13451 | const p = node.props[i];
|
13452 | if (p.type === 7 && p.name === "bind" && p.exp) {
|
13453 | const expType = getConstantType(p.exp, context);
|
13454 | if (expType === 0) {
|
13455 | constantCache.set(node, 0);
|
13456 | return 0;
|
13457 | }
|
13458 | if (expType < returnType2) {
|
13459 | returnType2 = expType;
|
13460 | }
|
13461 | }
|
13462 | }
|
13463 | }
|
13464 | if (codegenNode.isBlock) {
|
13465 | for (let i = 0; i < node.props.length; i++) {
|
13466 | const p = node.props[i];
|
13467 | if (p.type === 7) {
|
13468 | constantCache.set(node, 0);
|
13469 | return 0;
|
13470 | }
|
13471 | }
|
13472 | context.removeHelper(OPEN_BLOCK);
|
13473 | context.removeHelper(
|
13474 | getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
|
13475 | );
|
13476 | codegenNode.isBlock = false;
|
13477 | context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
|
13478 | }
|
13479 | constantCache.set(node, returnType2);
|
13480 | return returnType2;
|
13481 | } else {
|
13482 | constantCache.set(node, 0);
|
13483 | return 0;
|
13484 | }
|
13485 | case 2:
|
13486 | case 3:
|
13487 | return 3;
|
13488 | case 9:
|
13489 | case 11:
|
13490 | case 10:
|
13491 | return 0;
|
13492 | case 5:
|
13493 | case 12:
|
13494 | return getConstantType(node.content, context);
|
13495 | case 4:
|
13496 | return node.constType;
|
13497 | case 8:
|
13498 | let returnType = 3;
|
13499 | for (let i = 0; i < node.children.length; i++) {
|
13500 | const child = node.children[i];
|
13501 | if (isString(child) || isSymbol(child)) {
|
13502 | continue;
|
13503 | }
|
13504 | const childType = getConstantType(child, context);
|
13505 | if (childType === 0) {
|
13506 | return 0;
|
13507 | } else if (childType < returnType) {
|
13508 | returnType = childType;
|
13509 | }
|
13510 | }
|
13511 | return returnType;
|
13512 | default:
|
13513 | return 0;
|
13514 | }
|
13515 | }
|
13516 | const allowHoistedHelperSet = new Set([
|
13517 | NORMALIZE_CLASS,
|
13518 | NORMALIZE_STYLE,
|
13519 | NORMALIZE_PROPS,
|
13520 | GUARD_REACTIVE_PROPS
|
13521 | ]);
|
13522 | function getConstantTypeOfHelperCall(value, context) {
|
13523 | if (value.type === 14 && !isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
|
13524 | const arg = value.arguments[0];
|
13525 | if (arg.type === 4) {
|
13526 | return getConstantType(arg, context);
|
13527 | } else if (arg.type === 14) {
|
13528 | return getConstantTypeOfHelperCall(arg, context);
|
13529 | }
|
13530 | }
|
13531 | return 0;
|
13532 | }
|
13533 | function getGeneratedPropsConstantType(node, context) {
|
13534 | let returnType = 3;
|
13535 | const props = getNodeProps(node);
|
13536 | if (props && props.type === 15) {
|
13537 | const { properties } = props;
|
13538 | for (let i = 0; i < properties.length; i++) {
|
13539 | const { key, value } = properties[i];
|
13540 | const keyType = getConstantType(key, context);
|
13541 | if (keyType === 0) {
|
13542 | return keyType;
|
13543 | }
|
13544 | if (keyType < returnType) {
|
13545 | returnType = keyType;
|
13546 | }
|
13547 | let valueType;
|
13548 | if (value.type === 4) {
|
13549 | valueType = getConstantType(value, context);
|
13550 | } else if (value.type === 14) {
|
13551 | valueType = getConstantTypeOfHelperCall(value, context);
|
13552 | } else {
|
13553 | valueType = 0;
|
13554 | }
|
13555 | if (valueType === 0) {
|
13556 | return valueType;
|
13557 | }
|
13558 | if (valueType < returnType) {
|
13559 | returnType = valueType;
|
13560 | }
|
13561 | }
|
13562 | }
|
13563 | return returnType;
|
13564 | }
|
13565 | function getNodeProps(node) {
|
13566 | const codegenNode = node.codegenNode;
|
13567 | if (codegenNode.type === 13) {
|
13568 | return codegenNode.props;
|
13569 | }
|
13570 | }
|
13571 | function getPatchFlag(node) {
|
13572 | const flag = node.patchFlag;
|
13573 | return flag ? parseInt(flag, 10) : void 0;
|
13574 | }
|
13575 |
|
13576 | function createTransformContext(root, {
|
13577 | filename = "",
|
13578 | prefixIdentifiers = false,
|
13579 | hoistStatic: hoistStatic2 = false,
|
13580 | hmr = false,
|
13581 | cacheHandlers = false,
|
13582 | nodeTransforms = [],
|
13583 | directiveTransforms = {},
|
13584 | transformHoist = null,
|
13585 | isBuiltInComponent = NOOP,
|
13586 | isCustomElement = NOOP,
|
13587 | expressionPlugins = [],
|
13588 | scopeId = null,
|
13589 | slotted = true,
|
13590 | ssr = false,
|
13591 | inSSR = false,
|
13592 | ssrCssVars = ``,
|
13593 | bindingMetadata = EMPTY_OBJ,
|
13594 | inline = false,
|
13595 | isTS = false,
|
13596 | onError = defaultOnError,
|
13597 | onWarn = defaultOnWarn,
|
13598 | compatConfig
|
13599 | }) {
|
13600 | const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
13601 | const context = {
|
13602 |
|
13603 | filename,
|
13604 | selfName: nameMatch && capitalize(camelize(nameMatch[1])),
|
13605 | prefixIdentifiers,
|
13606 | hoistStatic: hoistStatic2,
|
13607 | hmr,
|
13608 | cacheHandlers,
|
13609 | nodeTransforms,
|
13610 | directiveTransforms,
|
13611 | transformHoist,
|
13612 | isBuiltInComponent,
|
13613 | isCustomElement,
|
13614 | expressionPlugins,
|
13615 | scopeId,
|
13616 | slotted,
|
13617 | ssr,
|
13618 | inSSR,
|
13619 | ssrCssVars,
|
13620 | bindingMetadata,
|
13621 | inline,
|
13622 | isTS,
|
13623 | onError,
|
13624 | onWarn,
|
13625 | compatConfig,
|
13626 |
|
13627 | root,
|
13628 | helpers: new Map(),
|
13629 | components: new Set(),
|
13630 | directives: new Set(),
|
13631 | hoists: [],
|
13632 | imports: [],
|
13633 | constantCache: new WeakMap(),
|
13634 | temps: 0,
|
13635 | cached: 0,
|
13636 | identifiers: Object.create(null),
|
13637 | scopes: {
|
13638 | vFor: 0,
|
13639 | vSlot: 0,
|
13640 | vPre: 0,
|
13641 | vOnce: 0
|
13642 | },
|
13643 | parent: null,
|
13644 | currentNode: root,
|
13645 | childIndex: 0,
|
13646 | inVOnce: false,
|
13647 |
|
13648 | helper(name) {
|
13649 | const count = context.helpers.get(name) || 0;
|
13650 | context.helpers.set(name, count + 1);
|
13651 | return name;
|
13652 | },
|
13653 | removeHelper(name) {
|
13654 | const count = context.helpers.get(name);
|
13655 | if (count) {
|
13656 | const currentCount = count - 1;
|
13657 | if (!currentCount) {
|
13658 | context.helpers.delete(name);
|
13659 | } else {
|
13660 | context.helpers.set(name, currentCount);
|
13661 | }
|
13662 | }
|
13663 | },
|
13664 | helperString(name) {
|
13665 | return `_${helperNameMap[context.helper(name)]}`;
|
13666 | },
|
13667 | replaceNode(node) {
|
13668 | {
|
13669 | if (!context.currentNode) {
|
13670 | throw new Error(`Node being replaced is already removed.`);
|
13671 | }
|
13672 | if (!context.parent) {
|
13673 | throw new Error(`Cannot replace root node.`);
|
13674 | }
|
13675 | }
|
13676 | context.parent.children[context.childIndex] = context.currentNode = node;
|
13677 | },
|
13678 | removeNode(node) {
|
13679 | if (!context.parent) {
|
13680 | throw new Error(`Cannot remove root node.`);
|
13681 | }
|
13682 | const list = context.parent.children;
|
13683 | const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
|
13684 | if (removalIndex < 0) {
|
13685 | throw new Error(`node being removed is not a child of current parent`);
|
13686 | }
|
13687 | if (!node || node === context.currentNode) {
|
13688 | context.currentNode = null;
|
13689 | context.onNodeRemoved();
|
13690 | } else {
|
13691 | if (context.childIndex > removalIndex) {
|
13692 | context.childIndex--;
|
13693 | context.onNodeRemoved();
|
13694 | }
|
13695 | }
|
13696 | context.parent.children.splice(removalIndex, 1);
|
13697 | },
|
13698 | onNodeRemoved: NOOP,
|
13699 | addIdentifiers(exp) {
|
13700 | },
|
13701 | removeIdentifiers(exp) {
|
13702 | },
|
13703 | hoist(exp) {
|
13704 | if (isString(exp))
|
13705 | exp = createSimpleExpression(exp);
|
13706 | context.hoists.push(exp);
|
13707 | const identifier = createSimpleExpression(
|
13708 | `_hoisted_${context.hoists.length}`,
|
13709 | false,
|
13710 | exp.loc,
|
13711 | 2
|
13712 | );
|
13713 | identifier.hoisted = exp;
|
13714 | return identifier;
|
13715 | },
|
13716 | cache(exp, isVNode = false) {
|
13717 | return createCacheExpression(context.cached++, exp, isVNode);
|
13718 | }
|
13719 | };
|
13720 | return context;
|
13721 | }
|
13722 | function transform(root, options) {
|
13723 | const context = createTransformContext(root, options);
|
13724 | traverseNode(root, context);
|
13725 | if (options.hoistStatic) {
|
13726 | hoistStatic(root, context);
|
13727 | }
|
13728 | if (!options.ssr) {
|
13729 | createRootCodegen(root, context);
|
13730 | }
|
13731 | root.helpers = new Set([...context.helpers.keys()]);
|
13732 | root.components = [...context.components];
|
13733 | root.directives = [...context.directives];
|
13734 | root.imports = context.imports;
|
13735 | root.hoists = context.hoists;
|
13736 | root.temps = context.temps;
|
13737 | root.cached = context.cached;
|
13738 | root.transformed = true;
|
13739 | }
|
13740 | function createRootCodegen(root, context) {
|
13741 | const { helper } = context;
|
13742 | const { children } = root;
|
13743 | if (children.length === 1) {
|
13744 | const child = children[0];
|
13745 | if (isSingleElementRoot(root, child) && child.codegenNode) {
|
13746 | const codegenNode = child.codegenNode;
|
13747 | if (codegenNode.type === 13) {
|
13748 | convertToBlock(codegenNode, context);
|
13749 | }
|
13750 | root.codegenNode = codegenNode;
|
13751 | } else {
|
13752 | root.codegenNode = child;
|
13753 | }
|
13754 | } else if (children.length > 1) {
|
13755 | let patchFlag = 64;
|
13756 | let patchFlagText = PatchFlagNames[64];
|
13757 | if (children.filter((c) => c.type !== 3).length === 1) {
|
13758 | patchFlag |= 2048;
|
13759 | patchFlagText += `, ${PatchFlagNames[2048]}`;
|
13760 | }
|
13761 | root.codegenNode = createVNodeCall(
|
13762 | context,
|
13763 | helper(FRAGMENT),
|
13764 | void 0,
|
13765 | root.children,
|
13766 | patchFlag + (` /* ${patchFlagText} */` ),
|
13767 | void 0,
|
13768 | void 0,
|
13769 | true,
|
13770 | void 0,
|
13771 | false
|
13772 | );
|
13773 | } else ;
|
13774 | }
|
13775 | function traverseChildren(parent, context) {
|
13776 | let i = 0;
|
13777 | const nodeRemoved = () => {
|
13778 | i--;
|
13779 | };
|
13780 | for (; i < parent.children.length; i++) {
|
13781 | const child = parent.children[i];
|
13782 | if (isString(child))
|
13783 | continue;
|
13784 | context.parent = parent;
|
13785 | context.childIndex = i;
|
13786 | context.onNodeRemoved = nodeRemoved;
|
13787 | traverseNode(child, context);
|
13788 | }
|
13789 | }
|
13790 | function traverseNode(node, context) {
|
13791 | context.currentNode = node;
|
13792 | const { nodeTransforms } = context;
|
13793 | const exitFns = [];
|
13794 | for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
|
13795 | const onExit = nodeTransforms[i2](node, context);
|
13796 | if (onExit) {
|
13797 | if (isArray(onExit)) {
|
13798 | exitFns.push(...onExit);
|
13799 | } else {
|
13800 | exitFns.push(onExit);
|
13801 | }
|
13802 | }
|
13803 | if (!context.currentNode) {
|
13804 | return;
|
13805 | } else {
|
13806 | node = context.currentNode;
|
13807 | }
|
13808 | }
|
13809 | switch (node.type) {
|
13810 | case 3:
|
13811 | if (!context.ssr) {
|
13812 | context.helper(CREATE_COMMENT);
|
13813 | }
|
13814 | break;
|
13815 | case 5:
|
13816 | if (!context.ssr) {
|
13817 | context.helper(TO_DISPLAY_STRING);
|
13818 | }
|
13819 | break;
|
13820 | case 9:
|
13821 | for (let i2 = 0; i2 < node.branches.length; i2++) {
|
13822 | traverseNode(node.branches[i2], context);
|
13823 | }
|
13824 | break;
|
13825 | case 10:
|
13826 | case 11:
|
13827 | case 1:
|
13828 | case 0:
|
13829 | traverseChildren(node, context);
|
13830 | break;
|
13831 | }
|
13832 | context.currentNode = node;
|
13833 | let i = exitFns.length;
|
13834 | while (i--) {
|
13835 | exitFns[i]();
|
13836 | }
|
13837 | }
|
13838 | function createStructuralDirectiveTransform(name, fn) {
|
13839 | const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
|
13840 | return (node, context) => {
|
13841 | if (node.type === 1) {
|
13842 | const { props } = node;
|
13843 | if (node.tagType === 3 && props.some(isVSlot)) {
|
13844 | return;
|
13845 | }
|
13846 | const exitFns = [];
|
13847 | for (let i = 0; i < props.length; i++) {
|
13848 | const prop = props[i];
|
13849 | if (prop.type === 7 && matches(prop.name)) {
|
13850 | props.splice(i, 1);
|
13851 | i--;
|
13852 | const onExit = fn(node, prop, context);
|
13853 | if (onExit)
|
13854 | exitFns.push(onExit);
|
13855 | }
|
13856 | }
|
13857 | return exitFns;
|
13858 | }
|
13859 | };
|
13860 | }
|
13861 |
|
13862 | const PURE_ANNOTATION = `/*#__PURE__*/`;
|
13863 | const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
13864 | function createCodegenContext(ast, {
|
13865 | mode = "function",
|
13866 | prefixIdentifiers = mode === "module",
|
13867 | sourceMap = false,
|
13868 | filename = `template.vue.html`,
|
13869 | scopeId = null,
|
13870 | optimizeImports = false,
|
13871 | runtimeGlobalName = `Vue`,
|
13872 | runtimeModuleName = `vue`,
|
13873 | ssrRuntimeModuleName = "vue/server-renderer",
|
13874 | ssr = false,
|
13875 | isTS = false,
|
13876 | inSSR = false
|
13877 | }) {
|
13878 | const context = {
|
13879 | mode,
|
13880 | prefixIdentifiers,
|
13881 | sourceMap,
|
13882 | filename,
|
13883 | scopeId,
|
13884 | optimizeImports,
|
13885 | runtimeGlobalName,
|
13886 | runtimeModuleName,
|
13887 | ssrRuntimeModuleName,
|
13888 | ssr,
|
13889 | isTS,
|
13890 | inSSR,
|
13891 | source: ast.source,
|
13892 | code: ``,
|
13893 | column: 1,
|
13894 | line: 1,
|
13895 | offset: 0,
|
13896 | indentLevel: 0,
|
13897 | pure: false,
|
13898 | map: void 0,
|
13899 | helper(key) {
|
13900 | return `_${helperNameMap[key]}`;
|
13901 | },
|
13902 | push(code, newlineIndex = -2 , node) {
|
13903 | context.code += code;
|
13904 | },
|
13905 | indent() {
|
13906 | newline(++context.indentLevel);
|
13907 | },
|
13908 | deindent(withoutNewLine = false) {
|
13909 | if (withoutNewLine) {
|
13910 | --context.indentLevel;
|
13911 | } else {
|
13912 | newline(--context.indentLevel);
|
13913 | }
|
13914 | },
|
13915 | newline() {
|
13916 | newline(context.indentLevel);
|
13917 | }
|
13918 | };
|
13919 | function newline(n) {
|
13920 | context.push("\n" + ` `.repeat(n), 0 );
|
13921 | }
|
13922 | return context;
|
13923 | }
|
13924 | function generate(ast, options = {}) {
|
13925 | const context = createCodegenContext(ast, options);
|
13926 | if (options.onContextCreated)
|
13927 | options.onContextCreated(context);
|
13928 | const {
|
13929 | mode,
|
13930 | push,
|
13931 | prefixIdentifiers,
|
13932 | indent,
|
13933 | deindent,
|
13934 | newline,
|
13935 | scopeId,
|
13936 | ssr
|
13937 | } = context;
|
13938 | const helpers = Array.from(ast.helpers);
|
13939 | const hasHelpers = helpers.length > 0;
|
13940 | const useWithBlock = !prefixIdentifiers && mode !== "module";
|
13941 | const preambleContext = context;
|
13942 | {
|
13943 | genFunctionPreamble(ast, preambleContext);
|
13944 | }
|
13945 | const functionName = ssr ? `ssrRender` : `render`;
|
13946 | const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
|
13947 | const signature = args.join(", ");
|
13948 | {
|
13949 | push(`function ${functionName}(${signature}) {`);
|
13950 | }
|
13951 | indent();
|
13952 | if (useWithBlock) {
|
13953 | push(`with (_ctx) {`);
|
13954 | indent();
|
13955 | if (hasHelpers) {
|
13956 | push(
|
13957 | `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
13958 | `,
|
13959 | -1
|
13960 | );
|
13961 | newline();
|
13962 | }
|
13963 | }
|
13964 | if (ast.components.length) {
|
13965 | genAssets(ast.components, "component", context);
|
13966 | if (ast.directives.length || ast.temps > 0) {
|
13967 | newline();
|
13968 | }
|
13969 | }
|
13970 | if (ast.directives.length) {
|
13971 | genAssets(ast.directives, "directive", context);
|
13972 | if (ast.temps > 0) {
|
13973 | newline();
|
13974 | }
|
13975 | }
|
13976 | if (ast.temps > 0) {
|
13977 | push(`let `);
|
13978 | for (let i = 0; i < ast.temps; i++) {
|
13979 | push(`${i > 0 ? `, ` : ``}_temp${i}`);
|
13980 | }
|
13981 | }
|
13982 | if (ast.components.length || ast.directives.length || ast.temps) {
|
13983 | push(`
|
13984 | `, 0 );
|
13985 | newline();
|
13986 | }
|
13987 | if (!ssr) {
|
13988 | push(`return `);
|
13989 | }
|
13990 | if (ast.codegenNode) {
|
13991 | genNode(ast.codegenNode, context);
|
13992 | } else {
|
13993 | push(`null`);
|
13994 | }
|
13995 | if (useWithBlock) {
|
13996 | deindent();
|
13997 | push(`}`);
|
13998 | }
|
13999 | deindent();
|
14000 | push(`}`);
|
14001 | return {
|
14002 | ast,
|
14003 | code: context.code,
|
14004 | preamble: ``,
|
14005 | map: context.map ? context.map.toJSON() : void 0
|
14006 | };
|
14007 | }
|
14008 | function genFunctionPreamble(ast, context) {
|
14009 | const {
|
14010 | ssr,
|
14011 | prefixIdentifiers,
|
14012 | push,
|
14013 | newline,
|
14014 | runtimeModuleName,
|
14015 | runtimeGlobalName,
|
14016 | ssrRuntimeModuleName
|
14017 | } = context;
|
14018 | const VueBinding = runtimeGlobalName;
|
14019 | const helpers = Array.from(ast.helpers);
|
14020 | if (helpers.length > 0) {
|
14021 | {
|
14022 | push(`const _Vue = ${VueBinding}
|
14023 | `, -1 );
|
14024 | if (ast.hoists.length) {
|
14025 | const staticHelpers = [
|
14026 | CREATE_VNODE,
|
14027 | CREATE_ELEMENT_VNODE,
|
14028 | CREATE_COMMENT,
|
14029 | CREATE_TEXT,
|
14030 | CREATE_STATIC
|
14031 | ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
14032 | push(`const { ${staticHelpers} } = _Vue
|
14033 | `, -1 );
|
14034 | }
|
14035 | }
|
14036 | }
|
14037 | genHoists(ast.hoists, context);
|
14038 | newline();
|
14039 | push(`return `);
|
14040 | }
|
14041 | function genAssets(assets, type, { helper, push, newline, isTS }) {
|
14042 | const resolver = helper(
|
14043 | type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
|
14044 | );
|
14045 | for (let i = 0; i < assets.length; i++) {
|
14046 | let id = assets[i];
|
14047 | const maybeSelfReference = id.endsWith("__self");
|
14048 | if (maybeSelfReference) {
|
14049 | id = id.slice(0, -6);
|
14050 | }
|
14051 | push(
|
14052 | `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
|
14053 | );
|
14054 | if (i < assets.length - 1) {
|
14055 | newline();
|
14056 | }
|
14057 | }
|
14058 | }
|
14059 | function genHoists(hoists, context) {
|
14060 | if (!hoists.length) {
|
14061 | return;
|
14062 | }
|
14063 | context.pure = true;
|
14064 | const { push, newline, helper, scopeId, mode } = context;
|
14065 | newline();
|
14066 | for (let i = 0; i < hoists.length; i++) {
|
14067 | const exp = hoists[i];
|
14068 | if (exp) {
|
14069 | push(
|
14070 | `const _hoisted_${i + 1} = ${``}`
|
14071 | );
|
14072 | genNode(exp, context);
|
14073 | newline();
|
14074 | }
|
14075 | }
|
14076 | context.pure = false;
|
14077 | }
|
14078 | function isText(n) {
|
14079 | return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
|
14080 | }
|
14081 | function genNodeListAsArray(nodes, context) {
|
14082 | const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText(n));
|
14083 | context.push(`[`);
|
14084 | multilines && context.indent();
|
14085 | genNodeList(nodes, context, multilines);
|
14086 | multilines && context.deindent();
|
14087 | context.push(`]`);
|
14088 | }
|
14089 | function genNodeList(nodes, context, multilines = false, comma = true) {
|
14090 | const { push, newline } = context;
|
14091 | for (let i = 0; i < nodes.length; i++) {
|
14092 | const node = nodes[i];
|
14093 | if (isString(node)) {
|
14094 | push(node, -3 );
|
14095 | } else if (isArray(node)) {
|
14096 | genNodeListAsArray(node, context);
|
14097 | } else {
|
14098 | genNode(node, context);
|
14099 | }
|
14100 | if (i < nodes.length - 1) {
|
14101 | if (multilines) {
|
14102 | comma && push(",");
|
14103 | newline();
|
14104 | } else {
|
14105 | comma && push(", ");
|
14106 | }
|
14107 | }
|
14108 | }
|
14109 | }
|
14110 | function genNode(node, context) {
|
14111 | if (isString(node)) {
|
14112 | context.push(node, -3 );
|
14113 | return;
|
14114 | }
|
14115 | if (isSymbol(node)) {
|
14116 | context.push(context.helper(node));
|
14117 | return;
|
14118 | }
|
14119 | switch (node.type) {
|
14120 | case 1:
|
14121 | case 9:
|
14122 | case 11:
|
14123 | assert(
|
14124 | node.codegenNode != null,
|
14125 | `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
|
14126 | );
|
14127 | genNode(node.codegenNode, context);
|
14128 | break;
|
14129 | case 2:
|
14130 | genText(node, context);
|
14131 | break;
|
14132 | case 4:
|
14133 | genExpression(node, context);
|
14134 | break;
|
14135 | case 5:
|
14136 | genInterpolation(node, context);
|
14137 | break;
|
14138 | case 12:
|
14139 | genNode(node.codegenNode, context);
|
14140 | break;
|
14141 | case 8:
|
14142 | genCompoundExpression(node, context);
|
14143 | break;
|
14144 | case 3:
|
14145 | genComment(node, context);
|
14146 | break;
|
14147 | case 13:
|
14148 | genVNodeCall(node, context);
|
14149 | break;
|
14150 | case 14:
|
14151 | genCallExpression(node, context);
|
14152 | break;
|
14153 | case 15:
|
14154 | genObjectExpression(node, context);
|
14155 | break;
|
14156 | case 17:
|
14157 | genArrayExpression(node, context);
|
14158 | break;
|
14159 | case 18:
|
14160 | genFunctionExpression(node, context);
|
14161 | break;
|
14162 | case 19:
|
14163 | genConditionalExpression(node, context);
|
14164 | break;
|
14165 | case 20:
|
14166 | genCacheExpression(node, context);
|
14167 | break;
|
14168 | case 21:
|
14169 | genNodeList(node.body, context, true, false);
|
14170 | break;
|
14171 | case 22:
|
14172 | break;
|
14173 | case 23:
|
14174 | break;
|
14175 | case 24:
|
14176 | break;
|
14177 | case 25:
|
14178 | break;
|
14179 | case 26:
|
14180 | break;
|
14181 | case 10:
|
14182 | break;
|
14183 | default:
|
14184 | {
|
14185 | assert(false, `unhandled codegen node type: ${node.type}`);
|
14186 | const exhaustiveCheck = node;
|
14187 | return exhaustiveCheck;
|
14188 | }
|
14189 | }
|
14190 | }
|
14191 | function genText(node, context) {
|
14192 | context.push(JSON.stringify(node.content), -3 , node);
|
14193 | }
|
14194 | function genExpression(node, context) {
|
14195 | const { content, isStatic } = node;
|
14196 | context.push(
|
14197 | isStatic ? JSON.stringify(content) : content,
|
14198 | -3 ,
|
14199 | node
|
14200 | );
|
14201 | }
|
14202 | function genInterpolation(node, context) {
|
14203 | const { push, helper, pure } = context;
|
14204 | if (pure)
|
14205 | push(PURE_ANNOTATION);
|
14206 | push(`${helper(TO_DISPLAY_STRING)}(`);
|
14207 | genNode(node.content, context);
|
14208 | push(`)`);
|
14209 | }
|
14210 | function genCompoundExpression(node, context) {
|
14211 | for (let i = 0; i < node.children.length; i++) {
|
14212 | const child = node.children[i];
|
14213 | if (isString(child)) {
|
14214 | context.push(child, -3 );
|
14215 | } else {
|
14216 | genNode(child, context);
|
14217 | }
|
14218 | }
|
14219 | }
|
14220 | function genExpressionAsPropertyKey(node, context) {
|
14221 | const { push } = context;
|
14222 | if (node.type === 8) {
|
14223 | push(`[`);
|
14224 | genCompoundExpression(node, context);
|
14225 | push(`]`);
|
14226 | } else if (node.isStatic) {
|
14227 | const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
14228 | push(text, -2 , node);
|
14229 | } else {
|
14230 | push(`[${node.content}]`, -3 , node);
|
14231 | }
|
14232 | }
|
14233 | function genComment(node, context) {
|
14234 | const { push, helper, pure } = context;
|
14235 | if (pure) {
|
14236 | push(PURE_ANNOTATION);
|
14237 | }
|
14238 | push(
|
14239 | `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
14240 | -3 ,
|
14241 | node
|
14242 | );
|
14243 | }
|
14244 | function genVNodeCall(node, context) {
|
14245 | const { push, helper, pure } = context;
|
14246 | const {
|
14247 | tag,
|
14248 | props,
|
14249 | children,
|
14250 | patchFlag,
|
14251 | dynamicProps,
|
14252 | directives,
|
14253 | isBlock,
|
14254 | disableTracking,
|
14255 | isComponent
|
14256 | } = node;
|
14257 | if (directives) {
|
14258 | push(helper(WITH_DIRECTIVES) + `(`);
|
14259 | }
|
14260 | if (isBlock) {
|
14261 | push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
|
14262 | }
|
14263 | if (pure) {
|
14264 | push(PURE_ANNOTATION);
|
14265 | }
|
14266 | const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
14267 | push(helper(callHelper) + `(`, -2 , node);
|
14268 | genNodeList(
|
14269 | genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
|
14270 | context
|
14271 | );
|
14272 | push(`)`);
|
14273 | if (isBlock) {
|
14274 | push(`)`);
|
14275 | }
|
14276 | if (directives) {
|
14277 | push(`, `);
|
14278 | genNode(directives, context);
|
14279 | push(`)`);
|
14280 | }
|
14281 | }
|
14282 | function genNullableArgs(args) {
|
14283 | let i = args.length;
|
14284 | while (i--) {
|
14285 | if (args[i] != null)
|
14286 | break;
|
14287 | }
|
14288 | return args.slice(0, i + 1).map((arg) => arg || `null`);
|
14289 | }
|
14290 | function genCallExpression(node, context) {
|
14291 | const { push, helper, pure } = context;
|
14292 | const callee = isString(node.callee) ? node.callee : helper(node.callee);
|
14293 | if (pure) {
|
14294 | push(PURE_ANNOTATION);
|
14295 | }
|
14296 | push(callee + `(`, -2 , node);
|
14297 | genNodeList(node.arguments, context);
|
14298 | push(`)`);
|
14299 | }
|
14300 | function genObjectExpression(node, context) {
|
14301 | const { push, indent, deindent, newline } = context;
|
14302 | const { properties } = node;
|
14303 | if (!properties.length) {
|
14304 | push(`{}`, -2 , node);
|
14305 | return;
|
14306 | }
|
14307 | const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
14308 | push(multilines ? `{` : `{ `);
|
14309 | multilines && indent();
|
14310 | for (let i = 0; i < properties.length; i++) {
|
14311 | const { key, value } = properties[i];
|
14312 | genExpressionAsPropertyKey(key, context);
|
14313 | push(`: `);
|
14314 | genNode(value, context);
|
14315 | if (i < properties.length - 1) {
|
14316 | push(`,`);
|
14317 | newline();
|
14318 | }
|
14319 | }
|
14320 | multilines && deindent();
|
14321 | push(multilines ? `}` : ` }`);
|
14322 | }
|
14323 | function genArrayExpression(node, context) {
|
14324 | genNodeListAsArray(node.elements, context);
|
14325 | }
|
14326 | function genFunctionExpression(node, context) {
|
14327 | const { push, indent, deindent } = context;
|
14328 | const { params, returns, body, newline, isSlot } = node;
|
14329 | if (isSlot) {
|
14330 | push(`_${helperNameMap[WITH_CTX]}(`);
|
14331 | }
|
14332 | push(`(`, -2 , node);
|
14333 | if (isArray(params)) {
|
14334 | genNodeList(params, context);
|
14335 | } else if (params) {
|
14336 | genNode(params, context);
|
14337 | }
|
14338 | push(`) => `);
|
14339 | if (newline || body) {
|
14340 | push(`{`);
|
14341 | indent();
|
14342 | }
|
14343 | if (returns) {
|
14344 | if (newline) {
|
14345 | push(`return `);
|
14346 | }
|
14347 | if (isArray(returns)) {
|
14348 | genNodeListAsArray(returns, context);
|
14349 | } else {
|
14350 | genNode(returns, context);
|
14351 | }
|
14352 | } else if (body) {
|
14353 | genNode(body, context);
|
14354 | }
|
14355 | if (newline || body) {
|
14356 | deindent();
|
14357 | push(`}`);
|
14358 | }
|
14359 | if (isSlot) {
|
14360 | push(`)`);
|
14361 | }
|
14362 | }
|
14363 | function genConditionalExpression(node, context) {
|
14364 | const { test, consequent, alternate, newline: needNewline } = node;
|
14365 | const { push, indent, deindent, newline } = context;
|
14366 | if (test.type === 4) {
|
14367 | const needsParens = !isSimpleIdentifier(test.content);
|
14368 | needsParens && push(`(`);
|
14369 | genExpression(test, context);
|
14370 | needsParens && push(`)`);
|
14371 | } else {
|
14372 | push(`(`);
|
14373 | genNode(test, context);
|
14374 | push(`)`);
|
14375 | }
|
14376 | needNewline && indent();
|
14377 | context.indentLevel++;
|
14378 | needNewline || push(` `);
|
14379 | push(`? `);
|
14380 | genNode(consequent, context);
|
14381 | context.indentLevel--;
|
14382 | needNewline && newline();
|
14383 | needNewline || push(` `);
|
14384 | push(`: `);
|
14385 | const isNested = alternate.type === 19;
|
14386 | if (!isNested) {
|
14387 | context.indentLevel++;
|
14388 | }
|
14389 | genNode(alternate, context);
|
14390 | if (!isNested) {
|
14391 | context.indentLevel--;
|
14392 | }
|
14393 | needNewline && deindent(
|
14394 | true
|
14395 |
|
14396 | );
|
14397 | }
|
14398 | function genCacheExpression(node, context) {
|
14399 | const { push, helper, indent, deindent, newline } = context;
|
14400 | push(`_cache[${node.index}] || (`);
|
14401 | if (node.isVNode) {
|
14402 | indent();
|
14403 | push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
|
14404 | newline();
|
14405 | }
|
14406 | push(`_cache[${node.index}] = `);
|
14407 | genNode(node.value, context);
|
14408 | if (node.isVNode) {
|
14409 | push(`,`);
|
14410 | newline();
|
14411 | push(`${helper(SET_BLOCK_TRACKING)}(1),`);
|
14412 | newline();
|
14413 | push(`_cache[${node.index}]`);
|
14414 | deindent();
|
14415 | }
|
14416 | push(`)`);
|
14417 | }
|
14418 |
|
14419 | const prohibitedKeywordRE = new RegExp(
|
14420 | "\\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"
|
14421 | );
|
14422 | const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
|
14423 | function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
|
14424 | const exp = node.content;
|
14425 | if (!exp.trim()) {
|
14426 | return;
|
14427 | }
|
14428 | try {
|
14429 | new Function(
|
14430 | asRawStatements ? ` ${exp} ` : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`
|
14431 | );
|
14432 | } catch (e) {
|
14433 | let message = e.message;
|
14434 | const keywordMatch = exp.replace(stripStringRE, "").match(prohibitedKeywordRE);
|
14435 | if (keywordMatch) {
|
14436 | message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
|
14437 | }
|
14438 | context.onError(
|
14439 | createCompilerError(
|
14440 | 45,
|
14441 | node.loc,
|
14442 | void 0,
|
14443 | message
|
14444 | )
|
14445 | );
|
14446 | }
|
14447 | }
|
14448 |
|
14449 | const transformExpression = (node, context) => {
|
14450 | if (node.type === 5) {
|
14451 | node.content = processExpression(
|
14452 | node.content,
|
14453 | context
|
14454 | );
|
14455 | } else if (node.type === 1) {
|
14456 | for (let i = 0; i < node.props.length; i++) {
|
14457 | const dir = node.props[i];
|
14458 | if (dir.type === 7 && dir.name !== "for") {
|
14459 | const exp = dir.exp;
|
14460 | const arg = dir.arg;
|
14461 | if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
|
14462 | dir.exp = processExpression(
|
14463 | exp,
|
14464 | context,
|
14465 |
|
14466 | dir.name === "slot"
|
14467 | );
|
14468 | }
|
14469 | if (arg && arg.type === 4 && !arg.isStatic) {
|
14470 | dir.arg = processExpression(arg, context);
|
14471 | }
|
14472 | }
|
14473 | }
|
14474 | }
|
14475 | };
|
14476 | function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
14477 | {
|
14478 | {
|
14479 | validateBrowserExpression(node, context, asParams, asRawStatements);
|
14480 | }
|
14481 | return node;
|
14482 | }
|
14483 | }
|
14484 |
|
14485 | const transformIf = createStructuralDirectiveTransform(
|
14486 | /^(if|else|else-if)$/,
|
14487 | (node, dir, context) => {
|
14488 | return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
14489 | const siblings = context.parent.children;
|
14490 | let i = siblings.indexOf(ifNode);
|
14491 | let key = 0;
|
14492 | while (i-- >= 0) {
|
14493 | const sibling = siblings[i];
|
14494 | if (sibling && sibling.type === 9) {
|
14495 | key += sibling.branches.length;
|
14496 | }
|
14497 | }
|
14498 | return () => {
|
14499 | if (isRoot) {
|
14500 | ifNode.codegenNode = createCodegenNodeForBranch(
|
14501 | branch,
|
14502 | key,
|
14503 | context
|
14504 | );
|
14505 | } else {
|
14506 | const parentCondition = getParentCondition(ifNode.codegenNode);
|
14507 | parentCondition.alternate = createCodegenNodeForBranch(
|
14508 | branch,
|
14509 | key + ifNode.branches.length - 1,
|
14510 | context
|
14511 | );
|
14512 | }
|
14513 | };
|
14514 | });
|
14515 | }
|
14516 | );
|
14517 | function processIf(node, dir, context, processCodegen) {
|
14518 | if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
|
14519 | const loc = dir.exp ? dir.exp.loc : node.loc;
|
14520 | context.onError(
|
14521 | createCompilerError(28, dir.loc)
|
14522 | );
|
14523 | dir.exp = createSimpleExpression(`true`, false, loc);
|
14524 | }
|
14525 | if (dir.exp) {
|
14526 | validateBrowserExpression(dir.exp, context);
|
14527 | }
|
14528 | if (dir.name === "if") {
|
14529 | const branch = createIfBranch(node, dir);
|
14530 | const ifNode = {
|
14531 | type: 9,
|
14532 | loc: node.loc,
|
14533 | branches: [branch]
|
14534 | };
|
14535 | context.replaceNode(ifNode);
|
14536 | if (processCodegen) {
|
14537 | return processCodegen(ifNode, branch, true);
|
14538 | }
|
14539 | } else {
|
14540 | const siblings = context.parent.children;
|
14541 | const comments = [];
|
14542 | let i = siblings.indexOf(node);
|
14543 | while (i-- >= -1) {
|
14544 | const sibling = siblings[i];
|
14545 | if (sibling && sibling.type === 3) {
|
14546 | context.removeNode(sibling);
|
14547 | comments.unshift(sibling);
|
14548 | continue;
|
14549 | }
|
14550 | if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
|
14551 | context.removeNode(sibling);
|
14552 | continue;
|
14553 | }
|
14554 | if (sibling && sibling.type === 9) {
|
14555 | if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
14556 | context.onError(
|
14557 | createCompilerError(30, node.loc)
|
14558 | );
|
14559 | }
|
14560 | context.removeNode();
|
14561 | const branch = createIfBranch(node, dir);
|
14562 | if (comments.length &&
|
14563 | !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
|
14564 | branch.children = [...comments, ...branch.children];
|
14565 | }
|
14566 | {
|
14567 | const key = branch.userKey;
|
14568 | if (key) {
|
14569 | sibling.branches.forEach(({ userKey }) => {
|
14570 | if (isSameKey(userKey, key)) {
|
14571 | context.onError(
|
14572 | createCompilerError(
|
14573 | 29,
|
14574 | branch.userKey.loc
|
14575 | )
|
14576 | );
|
14577 | }
|
14578 | });
|
14579 | }
|
14580 | }
|
14581 | sibling.branches.push(branch);
|
14582 | const onExit = processCodegen && processCodegen(sibling, branch, false);
|
14583 | traverseNode(branch, context);
|
14584 | if (onExit)
|
14585 | onExit();
|
14586 | context.currentNode = null;
|
14587 | } else {
|
14588 | context.onError(
|
14589 | createCompilerError(30, node.loc)
|
14590 | );
|
14591 | }
|
14592 | break;
|
14593 | }
|
14594 | }
|
14595 | }
|
14596 | function createIfBranch(node, dir) {
|
14597 | const isTemplateIf = node.tagType === 3;
|
14598 | return {
|
14599 | type: 10,
|
14600 | loc: node.loc,
|
14601 | condition: dir.name === "else" ? void 0 : dir.exp,
|
14602 | children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
|
14603 | userKey: findProp(node, `key`),
|
14604 | isTemplateIf
|
14605 | };
|
14606 | }
|
14607 | function createCodegenNodeForBranch(branch, keyIndex, context) {
|
14608 | if (branch.condition) {
|
14609 | return createConditionalExpression(
|
14610 | branch.condition,
|
14611 | createChildrenCodegenNode(branch, keyIndex, context),
|
14612 |
|
14613 |
|
14614 | createCallExpression(context.helper(CREATE_COMMENT), [
|
14615 | '"v-if"' ,
|
14616 | "true"
|
14617 | ])
|
14618 | );
|
14619 | } else {
|
14620 | return createChildrenCodegenNode(branch, keyIndex, context);
|
14621 | }
|
14622 | }
|
14623 | function createChildrenCodegenNode(branch, keyIndex, context) {
|
14624 | const { helper } = context;
|
14625 | const keyProperty = createObjectProperty(
|
14626 | `key`,
|
14627 | createSimpleExpression(
|
14628 | `${keyIndex}`,
|
14629 | false,
|
14630 | locStub,
|
14631 | 2
|
14632 | )
|
14633 | );
|
14634 | const { children } = branch;
|
14635 | const firstChild = children[0];
|
14636 | const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
|
14637 | if (needFragmentWrapper) {
|
14638 | if (children.length === 1 && firstChild.type === 11) {
|
14639 | const vnodeCall = firstChild.codegenNode;
|
14640 | injectProp(vnodeCall, keyProperty, context);
|
14641 | return vnodeCall;
|
14642 | } else {
|
14643 | let patchFlag = 64;
|
14644 | let patchFlagText = PatchFlagNames[64];
|
14645 | if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
|
14646 | patchFlag |= 2048;
|
14647 | patchFlagText += `, ${PatchFlagNames[2048]}`;
|
14648 | }
|
14649 | return createVNodeCall(
|
14650 | context,
|
14651 | helper(FRAGMENT),
|
14652 | createObjectExpression([keyProperty]),
|
14653 | children,
|
14654 | patchFlag + (` /* ${patchFlagText} */` ),
|
14655 | void 0,
|
14656 | void 0,
|
14657 | true,
|
14658 | false,
|
14659 | false,
|
14660 | branch.loc
|
14661 | );
|
14662 | }
|
14663 | } else {
|
14664 | const ret = firstChild.codegenNode;
|
14665 | const vnodeCall = getMemoedVNodeCall(ret);
|
14666 | if (vnodeCall.type === 13) {
|
14667 | convertToBlock(vnodeCall, context);
|
14668 | }
|
14669 | injectProp(vnodeCall, keyProperty, context);
|
14670 | return ret;
|
14671 | }
|
14672 | }
|
14673 | function isSameKey(a, b) {
|
14674 | if (!a || a.type !== b.type) {
|
14675 | return false;
|
14676 | }
|
14677 | if (a.type === 6) {
|
14678 | if (a.value.content !== b.value.content) {
|
14679 | return false;
|
14680 | }
|
14681 | } else {
|
14682 | const exp = a.exp;
|
14683 | const branchExp = b.exp;
|
14684 | if (exp.type !== branchExp.type) {
|
14685 | return false;
|
14686 | }
|
14687 | if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
|
14688 | return false;
|
14689 | }
|
14690 | }
|
14691 | return true;
|
14692 | }
|
14693 | function getParentCondition(node) {
|
14694 | while (true) {
|
14695 | if (node.type === 19) {
|
14696 | if (node.alternate.type === 19) {
|
14697 | node = node.alternate;
|
14698 | } else {
|
14699 | return node;
|
14700 | }
|
14701 | } else if (node.type === 20) {
|
14702 | node = node.value;
|
14703 | }
|
14704 | }
|
14705 | }
|
14706 |
|
14707 | const transformFor = createStructuralDirectiveTransform(
|
14708 | "for",
|
14709 | (node, dir, context) => {
|
14710 | const { helper, removeHelper } = context;
|
14711 | return processFor(node, dir, context, (forNode) => {
|
14712 | const renderExp = createCallExpression(helper(RENDER_LIST), [
|
14713 | forNode.source
|
14714 | ]);
|
14715 | const isTemplate = isTemplateNode(node);
|
14716 | const memo = findDir(node, "memo");
|
14717 | const keyProp = findProp(node, `key`);
|
14718 | const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
|
14719 | const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
14720 | const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
14721 | const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
14722 | forNode.codegenNode = createVNodeCall(
|
14723 | context,
|
14724 | helper(FRAGMENT),
|
14725 | void 0,
|
14726 | renderExp,
|
14727 | fragmentFlag + (` /* ${PatchFlagNames[fragmentFlag]} */` ),
|
14728 | void 0,
|
14729 | void 0,
|
14730 | true,
|
14731 | !isStableFragment,
|
14732 | false,
|
14733 | node.loc
|
14734 | );
|
14735 | return () => {
|
14736 | let childBlock;
|
14737 | const { children } = forNode;
|
14738 | if (isTemplate) {
|
14739 | node.children.some((c) => {
|
14740 | if (c.type === 1) {
|
14741 | const key = findProp(c, "key");
|
14742 | if (key) {
|
14743 | context.onError(
|
14744 | createCompilerError(
|
14745 | 33,
|
14746 | key.loc
|
14747 | )
|
14748 | );
|
14749 | return true;
|
14750 | }
|
14751 | }
|
14752 | });
|
14753 | }
|
14754 | const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
|
14755 | const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
|
14756 | if (slotOutlet) {
|
14757 | childBlock = slotOutlet.codegenNode;
|
14758 | if (isTemplate && keyProperty) {
|
14759 | injectProp(childBlock, keyProperty, context);
|
14760 | }
|
14761 | } else if (needFragmentWrapper) {
|
14762 | childBlock = createVNodeCall(
|
14763 | context,
|
14764 | helper(FRAGMENT),
|
14765 | keyProperty ? createObjectExpression([keyProperty]) : void 0,
|
14766 | node.children,
|
14767 | 64 + (` /* ${PatchFlagNames[64]} */` ),
|
14768 | void 0,
|
14769 | void 0,
|
14770 | true,
|
14771 | void 0,
|
14772 | false
|
14773 | );
|
14774 | } else {
|
14775 | childBlock = children[0].codegenNode;
|
14776 | if (isTemplate && keyProperty) {
|
14777 | injectProp(childBlock, keyProperty, context);
|
14778 | }
|
14779 | if (childBlock.isBlock !== !isStableFragment) {
|
14780 | if (childBlock.isBlock) {
|
14781 | removeHelper(OPEN_BLOCK);
|
14782 | removeHelper(
|
14783 | getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
|
14784 | );
|
14785 | } else {
|
14786 | removeHelper(
|
14787 | getVNodeHelper(context.inSSR, childBlock.isComponent)
|
14788 | );
|
14789 | }
|
14790 | }
|
14791 | childBlock.isBlock = !isStableFragment;
|
14792 | if (childBlock.isBlock) {
|
14793 | helper(OPEN_BLOCK);
|
14794 | helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
14795 | } else {
|
14796 | helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
14797 | }
|
14798 | }
|
14799 | if (memo) {
|
14800 | const loop = createFunctionExpression(
|
14801 | createForLoopParams(forNode.parseResult, [
|
14802 | createSimpleExpression(`_cached`)
|
14803 | ])
|
14804 | );
|
14805 | loop.body = createBlockStatement([
|
14806 | createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
|
14807 | createCompoundExpression([
|
14808 | `if (_cached`,
|
14809 | ...keyExp ? [` && _cached.key === `, keyExp] : [],
|
14810 | ` && ${context.helperString(
|
14811 | IS_MEMO_SAME
|
14812 | )}(_cached, _memo)) return _cached`
|
14813 | ]),
|
14814 | createCompoundExpression([`const _item = `, childBlock]),
|
14815 | createSimpleExpression(`_item.memo = _memo`),
|
14816 | createSimpleExpression(`return _item`)
|
14817 | ]);
|
14818 | renderExp.arguments.push(
|
14819 | loop,
|
14820 | createSimpleExpression(`_cache`),
|
14821 | createSimpleExpression(String(context.cached++))
|
14822 | );
|
14823 | } else {
|
14824 | renderExp.arguments.push(
|
14825 | createFunctionExpression(
|
14826 | createForLoopParams(forNode.parseResult),
|
14827 | childBlock,
|
14828 | true
|
14829 | )
|
14830 | );
|
14831 | }
|
14832 | };
|
14833 | });
|
14834 | }
|
14835 | );
|
14836 | function processFor(node, dir, context, processCodegen) {
|
14837 | if (!dir.exp) {
|
14838 | context.onError(
|
14839 | createCompilerError(31, dir.loc)
|
14840 | );
|
14841 | return;
|
14842 | }
|
14843 | const parseResult = dir.forParseResult;
|
14844 | if (!parseResult) {
|
14845 | context.onError(
|
14846 | createCompilerError(32, dir.loc)
|
14847 | );
|
14848 | return;
|
14849 | }
|
14850 | finalizeForParseResult(parseResult, context);
|
14851 | const { addIdentifiers, removeIdentifiers, scopes } = context;
|
14852 | const { source, value, key, index } = parseResult;
|
14853 | const forNode = {
|
14854 | type: 11,
|
14855 | loc: dir.loc,
|
14856 | source,
|
14857 | valueAlias: value,
|
14858 | keyAlias: key,
|
14859 | objectIndexAlias: index,
|
14860 | parseResult,
|
14861 | children: isTemplateNode(node) ? node.children : [node]
|
14862 | };
|
14863 | context.replaceNode(forNode);
|
14864 | scopes.vFor++;
|
14865 | const onExit = processCodegen && processCodegen(forNode);
|
14866 | return () => {
|
14867 | scopes.vFor--;
|
14868 | if (onExit)
|
14869 | onExit();
|
14870 | };
|
14871 | }
|
14872 | function finalizeForParseResult(result, context) {
|
14873 | if (result.finalized)
|
14874 | return;
|
14875 | {
|
14876 | validateBrowserExpression(result.source, context);
|
14877 | if (result.key) {
|
14878 | validateBrowserExpression(
|
14879 | result.key,
|
14880 | context,
|
14881 | true
|
14882 | );
|
14883 | }
|
14884 | if (result.index) {
|
14885 | validateBrowserExpression(
|
14886 | result.index,
|
14887 | context,
|
14888 | true
|
14889 | );
|
14890 | }
|
14891 | if (result.value) {
|
14892 | validateBrowserExpression(
|
14893 | result.value,
|
14894 | context,
|
14895 | true
|
14896 | );
|
14897 | }
|
14898 | }
|
14899 | result.finalized = true;
|
14900 | }
|
14901 | function createForLoopParams({ value, key, index }, memoArgs = []) {
|
14902 | return createParamsList([value, key, index, ...memoArgs]);
|
14903 | }
|
14904 | function createParamsList(args) {
|
14905 | let i = args.length;
|
14906 | while (i--) {
|
14907 | if (args[i])
|
14908 | break;
|
14909 | }
|
14910 | return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
|
14911 | }
|
14912 |
|
14913 | const defaultFallback = createSimpleExpression(`undefined`, false);
|
14914 | const trackSlotScopes = (node, context) => {
|
14915 | if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
|
14916 | const vSlot = findDir(node, "slot");
|
14917 | if (vSlot) {
|
14918 | vSlot.exp;
|
14919 | context.scopes.vSlot++;
|
14920 | return () => {
|
14921 | context.scopes.vSlot--;
|
14922 | };
|
14923 | }
|
14924 | }
|
14925 | };
|
14926 | const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
|
14927 | props,
|
14928 | children,
|
14929 | false,
|
14930 | true,
|
14931 | children.length ? children[0].loc : loc
|
14932 | );
|
14933 | function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
14934 | context.helper(WITH_CTX);
|
14935 | const { children, loc } = node;
|
14936 | const slotsProperties = [];
|
14937 | const dynamicSlots = [];
|
14938 | let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
|
14939 | const onComponentSlot = findDir(node, "slot", true);
|
14940 | if (onComponentSlot) {
|
14941 | const { arg, exp } = onComponentSlot;
|
14942 | if (arg && !isStaticExp(arg)) {
|
14943 | hasDynamicSlots = true;
|
14944 | }
|
14945 | slotsProperties.push(
|
14946 | createObjectProperty(
|
14947 | arg || createSimpleExpression("default", true),
|
14948 | buildSlotFn(exp, void 0, children, loc)
|
14949 | )
|
14950 | );
|
14951 | }
|
14952 | let hasTemplateSlots = false;
|
14953 | let hasNamedDefaultSlot = false;
|
14954 | const implicitDefaultChildren = [];
|
14955 | const seenSlotNames = new Set();
|
14956 | let conditionalBranchIndex = 0;
|
14957 | for (let i = 0; i < children.length; i++) {
|
14958 | const slotElement = children[i];
|
14959 | let slotDir;
|
14960 | if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
|
14961 | if (slotElement.type !== 3) {
|
14962 | implicitDefaultChildren.push(slotElement);
|
14963 | }
|
14964 | continue;
|
14965 | }
|
14966 | if (onComponentSlot) {
|
14967 | context.onError(
|
14968 | createCompilerError(37, slotDir.loc)
|
14969 | );
|
14970 | break;
|
14971 | }
|
14972 | hasTemplateSlots = true;
|
14973 | const { children: slotChildren, loc: slotLoc } = slotElement;
|
14974 | const {
|
14975 | arg: slotName = createSimpleExpression(`default`, true),
|
14976 | exp: slotProps,
|
14977 | loc: dirLoc
|
14978 | } = slotDir;
|
14979 | let staticSlotName;
|
14980 | if (isStaticExp(slotName)) {
|
14981 | staticSlotName = slotName ? slotName.content : `default`;
|
14982 | } else {
|
14983 | hasDynamicSlots = true;
|
14984 | }
|
14985 | const vFor = findDir(slotElement, "for");
|
14986 | const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
|
14987 | let vIf;
|
14988 | let vElse;
|
14989 | if (vIf = findDir(slotElement, "if")) {
|
14990 | hasDynamicSlots = true;
|
14991 | dynamicSlots.push(
|
14992 | createConditionalExpression(
|
14993 | vIf.exp,
|
14994 | buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
|
14995 | defaultFallback
|
14996 | )
|
14997 | );
|
14998 | } else if (vElse = findDir(
|
14999 | slotElement,
|
15000 | /^else(-if)?$/,
|
15001 | true
|
15002 |
|
15003 | )) {
|
15004 | let j = i;
|
15005 | let prev;
|
15006 | while (j--) {
|
15007 | prev = children[j];
|
15008 | if (prev.type !== 3) {
|
15009 | break;
|
15010 | }
|
15011 | }
|
15012 | if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
|
15013 | children.splice(i, 1);
|
15014 | i--;
|
15015 | let conditional = dynamicSlots[dynamicSlots.length - 1];
|
15016 | while (conditional.alternate.type === 19) {
|
15017 | conditional = conditional.alternate;
|
15018 | }
|
15019 | conditional.alternate = vElse.exp ? createConditionalExpression(
|
15020 | vElse.exp,
|
15021 | buildDynamicSlot(
|
15022 | slotName,
|
15023 | slotFunction,
|
15024 | conditionalBranchIndex++
|
15025 | ),
|
15026 | defaultFallback
|
15027 | ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
|
15028 | } else {
|
15029 | context.onError(
|
15030 | createCompilerError(30, vElse.loc)
|
15031 | );
|
15032 | }
|
15033 | } else if (vFor) {
|
15034 | hasDynamicSlots = true;
|
15035 | const parseResult = vFor.forParseResult;
|
15036 | if (parseResult) {
|
15037 | finalizeForParseResult(parseResult, context);
|
15038 | dynamicSlots.push(
|
15039 | createCallExpression(context.helper(RENDER_LIST), [
|
15040 | parseResult.source,
|
15041 | createFunctionExpression(
|
15042 | createForLoopParams(parseResult),
|
15043 | buildDynamicSlot(slotName, slotFunction),
|
15044 | true
|
15045 | )
|
15046 | ])
|
15047 | );
|
15048 | } else {
|
15049 | context.onError(
|
15050 | createCompilerError(
|
15051 | 32,
|
15052 | vFor.loc
|
15053 | )
|
15054 | );
|
15055 | }
|
15056 | } else {
|
15057 | if (staticSlotName) {
|
15058 | if (seenSlotNames.has(staticSlotName)) {
|
15059 | context.onError(
|
15060 | createCompilerError(
|
15061 | 38,
|
15062 | dirLoc
|
15063 | )
|
15064 | );
|
15065 | continue;
|
15066 | }
|
15067 | seenSlotNames.add(staticSlotName);
|
15068 | if (staticSlotName === "default") {
|
15069 | hasNamedDefaultSlot = true;
|
15070 | }
|
15071 | }
|
15072 | slotsProperties.push(createObjectProperty(slotName, slotFunction));
|
15073 | }
|
15074 | }
|
15075 | if (!onComponentSlot) {
|
15076 | const buildDefaultSlotProperty = (props, children2) => {
|
15077 | const fn = buildSlotFn(props, void 0, children2, loc);
|
15078 | return createObjectProperty(`default`, fn);
|
15079 | };
|
15080 | if (!hasTemplateSlots) {
|
15081 | slotsProperties.push(buildDefaultSlotProperty(void 0, children));
|
15082 | } else if (implicitDefaultChildren.length &&
|
15083 |
|
15084 |
|
15085 | implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
|
15086 | if (hasNamedDefaultSlot) {
|
15087 | context.onError(
|
15088 | createCompilerError(
|
15089 | 39,
|
15090 | implicitDefaultChildren[0].loc
|
15091 | )
|
15092 | );
|
15093 | } else {
|
15094 | slotsProperties.push(
|
15095 | buildDefaultSlotProperty(void 0, implicitDefaultChildren)
|
15096 | );
|
15097 | }
|
15098 | }
|
15099 | }
|
15100 | const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
|
15101 | let slots = createObjectExpression(
|
15102 | slotsProperties.concat(
|
15103 | createObjectProperty(
|
15104 | `_`,
|
15105 |
|
15106 |
|
15107 | createSimpleExpression(
|
15108 | slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
|
15109 | false
|
15110 | )
|
15111 | )
|
15112 | ),
|
15113 | loc
|
15114 | );
|
15115 | if (dynamicSlots.length) {
|
15116 | slots = createCallExpression(context.helper(CREATE_SLOTS), [
|
15117 | slots,
|
15118 | createArrayExpression(dynamicSlots)
|
15119 | ]);
|
15120 | }
|
15121 | return {
|
15122 | slots,
|
15123 | hasDynamicSlots
|
15124 | };
|
15125 | }
|
15126 | function buildDynamicSlot(name, fn, index) {
|
15127 | const props = [
|
15128 | createObjectProperty(`name`, name),
|
15129 | createObjectProperty(`fn`, fn)
|
15130 | ];
|
15131 | if (index != null) {
|
15132 | props.push(
|
15133 | createObjectProperty(`key`, createSimpleExpression(String(index), true))
|
15134 | );
|
15135 | }
|
15136 | return createObjectExpression(props);
|
15137 | }
|
15138 | function hasForwardedSlots(children) {
|
15139 | for (let i = 0; i < children.length; i++) {
|
15140 | const child = children[i];
|
15141 | switch (child.type) {
|
15142 | case 1:
|
15143 | if (child.tagType === 2 || hasForwardedSlots(child.children)) {
|
15144 | return true;
|
15145 | }
|
15146 | break;
|
15147 | case 9:
|
15148 | if (hasForwardedSlots(child.branches))
|
15149 | return true;
|
15150 | break;
|
15151 | case 10:
|
15152 | case 11:
|
15153 | if (hasForwardedSlots(child.children))
|
15154 | return true;
|
15155 | break;
|
15156 | }
|
15157 | }
|
15158 | return false;
|
15159 | }
|
15160 | function isNonWhitespaceContent(node) {
|
15161 | if (node.type !== 2 && node.type !== 12)
|
15162 | return true;
|
15163 | return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
|
15164 | }
|
15165 |
|
15166 | const directiveImportMap = new WeakMap();
|
15167 | const transformElement = (node, context) => {
|
15168 | return function postTransformElement() {
|
15169 | node = context.currentNode;
|
15170 | if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
|
15171 | return;
|
15172 | }
|
15173 | const { tag, props } = node;
|
15174 | const isComponent = node.tagType === 1;
|
15175 | let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
|
15176 | const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
|
15177 | let vnodeProps;
|
15178 | let vnodeChildren;
|
15179 | let vnodePatchFlag;
|
15180 | let patchFlag = 0;
|
15181 | let vnodeDynamicProps;
|
15182 | let dynamicPropNames;
|
15183 | let vnodeDirectives;
|
15184 | let shouldUseBlock = (
|
15185 |
|
15186 | isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent &&
|
15187 |
|
15188 |
|
15189 |
|
15190 | (tag === "svg" || tag === "foreignObject")
|
15191 | );
|
15192 | if (props.length > 0) {
|
15193 | const propsBuildResult = buildProps(
|
15194 | node,
|
15195 | context,
|
15196 | void 0,
|
15197 | isComponent,
|
15198 | isDynamicComponent
|
15199 | );
|
15200 | vnodeProps = propsBuildResult.props;
|
15201 | patchFlag = propsBuildResult.patchFlag;
|
15202 | dynamicPropNames = propsBuildResult.dynamicPropNames;
|
15203 | const directives = propsBuildResult.directives;
|
15204 | vnodeDirectives = directives && directives.length ? createArrayExpression(
|
15205 | directives.map((dir) => buildDirectiveArgs(dir, context))
|
15206 | ) : void 0;
|
15207 | if (propsBuildResult.shouldUseBlock) {
|
15208 | shouldUseBlock = true;
|
15209 | }
|
15210 | }
|
15211 | if (node.children.length > 0) {
|
15212 | if (vnodeTag === KEEP_ALIVE) {
|
15213 | shouldUseBlock = true;
|
15214 | patchFlag |= 1024;
|
15215 | if (node.children.length > 1) {
|
15216 | context.onError(
|
15217 | createCompilerError(46, {
|
15218 | start: node.children[0].loc.start,
|
15219 | end: node.children[node.children.length - 1].loc.end,
|
15220 | source: ""
|
15221 | })
|
15222 | );
|
15223 | }
|
15224 | }
|
15225 | const shouldBuildAsSlots = isComponent &&
|
15226 | vnodeTag !== TELEPORT &&
|
15227 | vnodeTag !== KEEP_ALIVE;
|
15228 | if (shouldBuildAsSlots) {
|
15229 | const { slots, hasDynamicSlots } = buildSlots(node, context);
|
15230 | vnodeChildren = slots;
|
15231 | if (hasDynamicSlots) {
|
15232 | patchFlag |= 1024;
|
15233 | }
|
15234 | } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
|
15235 | const child = node.children[0];
|
15236 | const type = child.type;
|
15237 | const hasDynamicTextChild = type === 5 || type === 8;
|
15238 | if (hasDynamicTextChild && getConstantType(child, context) === 0) {
|
15239 | patchFlag |= 1;
|
15240 | }
|
15241 | if (hasDynamicTextChild || type === 2) {
|
15242 | vnodeChildren = child;
|
15243 | } else {
|
15244 | vnodeChildren = node.children;
|
15245 | }
|
15246 | } else {
|
15247 | vnodeChildren = node.children;
|
15248 | }
|
15249 | }
|
15250 | if (patchFlag !== 0) {
|
15251 | {
|
15252 | if (patchFlag < 0) {
|
15253 | vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
|
15254 | } else {
|
15255 | const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
|
15256 | vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
|
15257 | }
|
15258 | }
|
15259 | if (dynamicPropNames && dynamicPropNames.length) {
|
15260 | vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
|
15261 | }
|
15262 | }
|
15263 | node.codegenNode = createVNodeCall(
|
15264 | context,
|
15265 | vnodeTag,
|
15266 | vnodeProps,
|
15267 | vnodeChildren,
|
15268 | vnodePatchFlag,
|
15269 | vnodeDynamicProps,
|
15270 | vnodeDirectives,
|
15271 | !!shouldUseBlock,
|
15272 | false,
|
15273 | isComponent,
|
15274 | node.loc
|
15275 | );
|
15276 | };
|
15277 | };
|
15278 | function resolveComponentType(node, context, ssr = false) {
|
15279 | let { tag } = node;
|
15280 | const isExplicitDynamic = isComponentTag(tag);
|
15281 | const isProp = findProp(node, "is");
|
15282 | if (isProp) {
|
15283 | if (isExplicitDynamic || false) {
|
15284 | const exp = isProp.type === 6 ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
|
15285 | if (exp) {
|
15286 | return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
15287 | exp
|
15288 | ]);
|
15289 | }
|
15290 | } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
|
15291 | tag = isProp.value.content.slice(4);
|
15292 | }
|
15293 | }
|
15294 | const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
15295 | if (builtIn) {
|
15296 | if (!ssr)
|
15297 | context.helper(builtIn);
|
15298 | return builtIn;
|
15299 | }
|
15300 | context.helper(RESOLVE_COMPONENT);
|
15301 | context.components.add(tag);
|
15302 | return toValidAssetId(tag, `component`);
|
15303 | }
|
15304 | function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
15305 | const { tag, loc: elementLoc, children } = node;
|
15306 | let properties = [];
|
15307 | const mergeArgs = [];
|
15308 | const runtimeDirectives = [];
|
15309 | const hasChildren = children.length > 0;
|
15310 | let shouldUseBlock = false;
|
15311 | let patchFlag = 0;
|
15312 | let hasRef = false;
|
15313 | let hasClassBinding = false;
|
15314 | let hasStyleBinding = false;
|
15315 | let hasHydrationEventBinding = false;
|
15316 | let hasDynamicKeys = false;
|
15317 | let hasVnodeHook = false;
|
15318 | const dynamicPropNames = [];
|
15319 | const pushMergeArg = (arg) => {
|
15320 | if (properties.length) {
|
15321 | mergeArgs.push(
|
15322 | createObjectExpression(dedupeProperties(properties), elementLoc)
|
15323 | );
|
15324 | properties = [];
|
15325 | }
|
15326 | if (arg)
|
15327 | mergeArgs.push(arg);
|
15328 | };
|
15329 | const analyzePatchFlag = ({ key, value }) => {
|
15330 | if (isStaticExp(key)) {
|
15331 | const name = key.content;
|
15332 | const isEventHandler = isOn(name);
|
15333 | if (isEventHandler && (!isComponent || isDynamicComponent) &&
|
15334 |
|
15335 | name.toLowerCase() !== "onclick" &&
|
15336 | name !== "onUpdate:modelValue" &&
|
15337 | !isReservedProp(name)) {
|
15338 | hasHydrationEventBinding = true;
|
15339 | }
|
15340 | if (isEventHandler && isReservedProp(name)) {
|
15341 | hasVnodeHook = true;
|
15342 | }
|
15343 | if (isEventHandler && value.type === 14) {
|
15344 | value = value.arguments[0];
|
15345 | }
|
15346 | if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
|
15347 | return;
|
15348 | }
|
15349 | if (name === "ref") {
|
15350 | hasRef = true;
|
15351 | } else if (name === "class") {
|
15352 | hasClassBinding = true;
|
15353 | } else if (name === "style") {
|
15354 | hasStyleBinding = true;
|
15355 | } else if (name !== "key" && !dynamicPropNames.includes(name)) {
|
15356 | dynamicPropNames.push(name);
|
15357 | }
|
15358 | if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
|
15359 | dynamicPropNames.push(name);
|
15360 | }
|
15361 | } else {
|
15362 | hasDynamicKeys = true;
|
15363 | }
|
15364 | };
|
15365 | for (let i = 0; i < props.length; i++) {
|
15366 | const prop = props[i];
|
15367 | if (prop.type === 6) {
|
15368 | const { loc, name, nameLoc, value } = prop;
|
15369 | let isStatic = true;
|
15370 | if (name === "ref") {
|
15371 | hasRef = true;
|
15372 | if (context.scopes.vFor > 0) {
|
15373 | properties.push(
|
15374 | createObjectProperty(
|
15375 | createSimpleExpression("ref_for", true),
|
15376 | createSimpleExpression("true")
|
15377 | )
|
15378 | );
|
15379 | }
|
15380 | }
|
15381 | if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
|
15382 | continue;
|
15383 | }
|
15384 | properties.push(
|
15385 | createObjectProperty(
|
15386 | createSimpleExpression(name, true, nameLoc),
|
15387 | createSimpleExpression(
|
15388 | value ? value.content : "",
|
15389 | isStatic,
|
15390 | value ? value.loc : loc
|
15391 | )
|
15392 | )
|
15393 | );
|
15394 | } else {
|
15395 | const { name, arg, exp, loc, modifiers } = prop;
|
15396 | const isVBind = name === "bind";
|
15397 | const isVOn = name === "on";
|
15398 | if (name === "slot") {
|
15399 | if (!isComponent) {
|
15400 | context.onError(
|
15401 | createCompilerError(40, loc)
|
15402 | );
|
15403 | }
|
15404 | continue;
|
15405 | }
|
15406 | if (name === "once" || name === "memo") {
|
15407 | continue;
|
15408 | }
|
15409 | if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
|
15410 | continue;
|
15411 | }
|
15412 | if (isVOn && ssr) {
|
15413 | continue;
|
15414 | }
|
15415 | if (
|
15416 |
|
15417 | isVBind && isStaticArgOf(arg, "key") ||
|
15418 |
|
15419 | isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
|
15420 | ) {
|
15421 | shouldUseBlock = true;
|
15422 | }
|
15423 | if (isVBind && isStaticArgOf(arg, "ref") && context.scopes.vFor > 0) {
|
15424 | properties.push(
|
15425 | createObjectProperty(
|
15426 | createSimpleExpression("ref_for", true),
|
15427 | createSimpleExpression("true")
|
15428 | )
|
15429 | );
|
15430 | }
|
15431 | if (!arg && (isVBind || isVOn)) {
|
15432 | hasDynamicKeys = true;
|
15433 | if (exp) {
|
15434 | if (isVBind) {
|
15435 | pushMergeArg();
|
15436 | mergeArgs.push(exp);
|
15437 | } else {
|
15438 | pushMergeArg({
|
15439 | type: 14,
|
15440 | loc,
|
15441 | callee: context.helper(TO_HANDLERS),
|
15442 | arguments: isComponent ? [exp] : [exp, `true`]
|
15443 | });
|
15444 | }
|
15445 | } else {
|
15446 | context.onError(
|
15447 | createCompilerError(
|
15448 | isVBind ? 34 : 35,
|
15449 | loc
|
15450 | )
|
15451 | );
|
15452 | }
|
15453 | continue;
|
15454 | }
|
15455 | if (isVBind && modifiers.includes("prop")) {
|
15456 | patchFlag |= 32;
|
15457 | }
|
15458 | const directiveTransform = context.directiveTransforms[name];
|
15459 | if (directiveTransform) {
|
15460 | const { props: props2, needRuntime } = directiveTransform(prop, node, context);
|
15461 | !ssr && props2.forEach(analyzePatchFlag);
|
15462 | if (isVOn && arg && !isStaticExp(arg)) {
|
15463 | pushMergeArg(createObjectExpression(props2, elementLoc));
|
15464 | } else {
|
15465 | properties.push(...props2);
|
15466 | }
|
15467 | if (needRuntime) {
|
15468 | runtimeDirectives.push(prop);
|
15469 | if (isSymbol(needRuntime)) {
|
15470 | directiveImportMap.set(prop, needRuntime);
|
15471 | }
|
15472 | }
|
15473 | } else if (!isBuiltInDirective(name)) {
|
15474 | runtimeDirectives.push(prop);
|
15475 | if (hasChildren) {
|
15476 | shouldUseBlock = true;
|
15477 | }
|
15478 | }
|
15479 | }
|
15480 | }
|
15481 | let propsExpression = void 0;
|
15482 | if (mergeArgs.length) {
|
15483 | pushMergeArg();
|
15484 | if (mergeArgs.length > 1) {
|
15485 | propsExpression = createCallExpression(
|
15486 | context.helper(MERGE_PROPS),
|
15487 | mergeArgs,
|
15488 | elementLoc
|
15489 | );
|
15490 | } else {
|
15491 | propsExpression = mergeArgs[0];
|
15492 | }
|
15493 | } else if (properties.length) {
|
15494 | propsExpression = createObjectExpression(
|
15495 | dedupeProperties(properties),
|
15496 | elementLoc
|
15497 | );
|
15498 | }
|
15499 | if (hasDynamicKeys) {
|
15500 | patchFlag |= 16;
|
15501 | } else {
|
15502 | if (hasClassBinding && !isComponent) {
|
15503 | patchFlag |= 2;
|
15504 | }
|
15505 | if (hasStyleBinding && !isComponent) {
|
15506 | patchFlag |= 4;
|
15507 | }
|
15508 | if (dynamicPropNames.length) {
|
15509 | patchFlag |= 8;
|
15510 | }
|
15511 | if (hasHydrationEventBinding) {
|
15512 | patchFlag |= 32;
|
15513 | }
|
15514 | }
|
15515 | if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
|
15516 | patchFlag |= 512;
|
15517 | }
|
15518 | if (!context.inSSR && propsExpression) {
|
15519 | switch (propsExpression.type) {
|
15520 | case 15:
|
15521 | let classKeyIndex = -1;
|
15522 | let styleKeyIndex = -1;
|
15523 | let hasDynamicKey = false;
|
15524 | for (let i = 0; i < propsExpression.properties.length; i++) {
|
15525 | const key = propsExpression.properties[i].key;
|
15526 | if (isStaticExp(key)) {
|
15527 | if (key.content === "class") {
|
15528 | classKeyIndex = i;
|
15529 | } else if (key.content === "style") {
|
15530 | styleKeyIndex = i;
|
15531 | }
|
15532 | } else if (!key.isHandlerKey) {
|
15533 | hasDynamicKey = true;
|
15534 | }
|
15535 | }
|
15536 | const classProp = propsExpression.properties[classKeyIndex];
|
15537 | const styleProp = propsExpression.properties[styleKeyIndex];
|
15538 | if (!hasDynamicKey) {
|
15539 | if (classProp && !isStaticExp(classProp.value)) {
|
15540 | classProp.value = createCallExpression(
|
15541 | context.helper(NORMALIZE_CLASS),
|
15542 | [classProp.value]
|
15543 | );
|
15544 | }
|
15545 | if (styleProp &&
|
15546 |
|
15547 | (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` ||
|
15548 |
|
15549 | styleProp.value.type === 17)) {
|
15550 | styleProp.value = createCallExpression(
|
15551 | context.helper(NORMALIZE_STYLE),
|
15552 | [styleProp.value]
|
15553 | );
|
15554 | }
|
15555 | } else {
|
15556 | propsExpression = createCallExpression(
|
15557 | context.helper(NORMALIZE_PROPS),
|
15558 | [propsExpression]
|
15559 | );
|
15560 | }
|
15561 | break;
|
15562 | case 14:
|
15563 | break;
|
15564 | default:
|
15565 | propsExpression = createCallExpression(
|
15566 | context.helper(NORMALIZE_PROPS),
|
15567 | [
|
15568 | createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
|
15569 | propsExpression
|
15570 | ])
|
15571 | ]
|
15572 | );
|
15573 | break;
|
15574 | }
|
15575 | }
|
15576 | return {
|
15577 | props: propsExpression,
|
15578 | directives: runtimeDirectives,
|
15579 | patchFlag,
|
15580 | dynamicPropNames,
|
15581 | shouldUseBlock
|
15582 | };
|
15583 | }
|
15584 | function dedupeProperties(properties) {
|
15585 | const knownProps = new Map();
|
15586 | const deduped = [];
|
15587 | for (let i = 0; i < properties.length; i++) {
|
15588 | const prop = properties[i];
|
15589 | if (prop.key.type === 8 || !prop.key.isStatic) {
|
15590 | deduped.push(prop);
|
15591 | continue;
|
15592 | }
|
15593 | const name = prop.key.content;
|
15594 | const existing = knownProps.get(name);
|
15595 | if (existing) {
|
15596 | if (name === "style" || name === "class" || isOn(name)) {
|
15597 | mergeAsArray(existing, prop);
|
15598 | }
|
15599 | } else {
|
15600 | knownProps.set(name, prop);
|
15601 | deduped.push(prop);
|
15602 | }
|
15603 | }
|
15604 | return deduped;
|
15605 | }
|
15606 | function mergeAsArray(existing, incoming) {
|
15607 | if (existing.value.type === 17) {
|
15608 | existing.value.elements.push(incoming.value);
|
15609 | } else {
|
15610 | existing.value = createArrayExpression(
|
15611 | [existing.value, incoming.value],
|
15612 | existing.loc
|
15613 | );
|
15614 | }
|
15615 | }
|
15616 | function buildDirectiveArgs(dir, context) {
|
15617 | const dirArgs = [];
|
15618 | const runtime = directiveImportMap.get(dir);
|
15619 | if (runtime) {
|
15620 | dirArgs.push(context.helperString(runtime));
|
15621 | } else {
|
15622 | {
|
15623 | context.helper(RESOLVE_DIRECTIVE);
|
15624 | context.directives.add(dir.name);
|
15625 | dirArgs.push(toValidAssetId(dir.name, `directive`));
|
15626 | }
|
15627 | }
|
15628 | const { loc } = dir;
|
15629 | if (dir.exp)
|
15630 | dirArgs.push(dir.exp);
|
15631 | if (dir.arg) {
|
15632 | if (!dir.exp) {
|
15633 | dirArgs.push(`void 0`);
|
15634 | }
|
15635 | dirArgs.push(dir.arg);
|
15636 | }
|
15637 | if (Object.keys(dir.modifiers).length) {
|
15638 | if (!dir.arg) {
|
15639 | if (!dir.exp) {
|
15640 | dirArgs.push(`void 0`);
|
15641 | }
|
15642 | dirArgs.push(`void 0`);
|
15643 | }
|
15644 | const trueExpression = createSimpleExpression(`true`, false, loc);
|
15645 | dirArgs.push(
|
15646 | createObjectExpression(
|
15647 | dir.modifiers.map(
|
15648 | (modifier) => createObjectProperty(modifier, trueExpression)
|
15649 | ),
|
15650 | loc
|
15651 | )
|
15652 | );
|
15653 | }
|
15654 | return createArrayExpression(dirArgs, dir.loc);
|
15655 | }
|
15656 | function stringifyDynamicPropNames(props) {
|
15657 | let propsNamesString = `[`;
|
15658 | for (let i = 0, l = props.length; i < l; i++) {
|
15659 | propsNamesString += JSON.stringify(props[i]);
|
15660 | if (i < l - 1)
|
15661 | propsNamesString += ", ";
|
15662 | }
|
15663 | return propsNamesString + `]`;
|
15664 | }
|
15665 | function isComponentTag(tag) {
|
15666 | return tag === "component" || tag === "Component";
|
15667 | }
|
15668 |
|
15669 | const transformSlotOutlet = (node, context) => {
|
15670 | if (isSlotOutlet(node)) {
|
15671 | const { children, loc } = node;
|
15672 | const { slotName, slotProps } = processSlotOutlet(node, context);
|
15673 | const slotArgs = [
|
15674 | context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
|
15675 | slotName,
|
15676 | "{}",
|
15677 | "undefined",
|
15678 | "true"
|
15679 | ];
|
15680 | let expectedLen = 2;
|
15681 | if (slotProps) {
|
15682 | slotArgs[2] = slotProps;
|
15683 | expectedLen = 3;
|
15684 | }
|
15685 | if (children.length) {
|
15686 | slotArgs[3] = createFunctionExpression([], children, false, false, loc);
|
15687 | expectedLen = 4;
|
15688 | }
|
15689 | if (context.scopeId && !context.slotted) {
|
15690 | expectedLen = 5;
|
15691 | }
|
15692 | slotArgs.splice(expectedLen);
|
15693 | node.codegenNode = createCallExpression(
|
15694 | context.helper(RENDER_SLOT),
|
15695 | slotArgs,
|
15696 | loc
|
15697 | );
|
15698 | }
|
15699 | };
|
15700 | function processSlotOutlet(node, context) {
|
15701 | let slotName = `"default"`;
|
15702 | let slotProps = void 0;
|
15703 | const nonNameProps = [];
|
15704 | for (let i = 0; i < node.props.length; i++) {
|
15705 | const p = node.props[i];
|
15706 | if (p.type === 6) {
|
15707 | if (p.value) {
|
15708 | if (p.name === "name") {
|
15709 | slotName = JSON.stringify(p.value.content);
|
15710 | } else {
|
15711 | p.name = camelize(p.name);
|
15712 | nonNameProps.push(p);
|
15713 | }
|
15714 | }
|
15715 | } else {
|
15716 | if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
|
15717 | if (p.exp) {
|
15718 | slotName = p.exp;
|
15719 | } else if (p.arg && p.arg.type === 4) {
|
15720 | const name = camelize(p.arg.content);
|
15721 | slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
|
15722 | }
|
15723 | } else {
|
15724 | if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
|
15725 | p.arg.content = camelize(p.arg.content);
|
15726 | }
|
15727 | nonNameProps.push(p);
|
15728 | }
|
15729 | }
|
15730 | }
|
15731 | if (nonNameProps.length > 0) {
|
15732 | const { props, directives } = buildProps(
|
15733 | node,
|
15734 | context,
|
15735 | nonNameProps,
|
15736 | false,
|
15737 | false
|
15738 | );
|
15739 | slotProps = props;
|
15740 | if (directives.length) {
|
15741 | context.onError(
|
15742 | createCompilerError(
|
15743 | 36,
|
15744 | directives[0].loc
|
15745 | )
|
15746 | );
|
15747 | }
|
15748 | }
|
15749 | return {
|
15750 | slotName,
|
15751 | slotProps
|
15752 | };
|
15753 | }
|
15754 |
|
15755 | const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
15756 | const transformOn$1 = (dir, node, context, augmentor) => {
|
15757 | const { loc, modifiers, arg } = dir;
|
15758 | if (!dir.exp && !modifiers.length) {
|
15759 | context.onError(createCompilerError(35, loc));
|
15760 | }
|
15761 | let eventName;
|
15762 | if (arg.type === 4) {
|
15763 | if (arg.isStatic) {
|
15764 | let rawName = arg.content;
|
15765 | if (rawName.startsWith("vnode")) {
|
15766 | context.onError(createCompilerError(51, arg.loc));
|
15767 | }
|
15768 | if (rawName.startsWith("vue:")) {
|
15769 | rawName = `vnode-${rawName.slice(4)}`;
|
15770 | }
|
15771 | const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
|
15772 |
|
15773 |
|
15774 | toHandlerKey(camelize(rawName))
|
15775 | ) : (
|
15776 |
|
15777 |
|
15778 | `on:${rawName}`
|
15779 | );
|
15780 | eventName = createSimpleExpression(eventString, true, arg.loc);
|
15781 | } else {
|
15782 | eventName = createCompoundExpression([
|
15783 | `${context.helperString(TO_HANDLER_KEY)}(`,
|
15784 | arg,
|
15785 | `)`
|
15786 | ]);
|
15787 | }
|
15788 | } else {
|
15789 | eventName = arg;
|
15790 | eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
|
15791 | eventName.children.push(`)`);
|
15792 | }
|
15793 | let exp = dir.exp;
|
15794 | if (exp && !exp.content.trim()) {
|
15795 | exp = void 0;
|
15796 | }
|
15797 | let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
|
15798 | if (exp) {
|
15799 | const isMemberExp = isMemberExpression(exp.content);
|
15800 | const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
|
15801 | const hasMultipleStatements = exp.content.includes(`;`);
|
15802 | {
|
15803 | validateBrowserExpression(
|
15804 | exp,
|
15805 | context,
|
15806 | false,
|
15807 | hasMultipleStatements
|
15808 | );
|
15809 | }
|
15810 | if (isInlineStatement || shouldCache && isMemberExp) {
|
15811 | exp = createCompoundExpression([
|
15812 | `${isInlineStatement ? `$event` : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
|
15813 | exp,
|
15814 | hasMultipleStatements ? `}` : `)`
|
15815 | ]);
|
15816 | }
|
15817 | }
|
15818 | let ret = {
|
15819 | props: [
|
15820 | createObjectProperty(
|
15821 | eventName,
|
15822 | exp || createSimpleExpression(`() => {}`, false, loc)
|
15823 | )
|
15824 | ]
|
15825 | };
|
15826 | if (augmentor) {
|
15827 | ret = augmentor(ret);
|
15828 | }
|
15829 | if (shouldCache) {
|
15830 | ret.props[0].value = context.cache(ret.props[0].value);
|
15831 | }
|
15832 | ret.props.forEach((p) => p.key.isHandlerKey = true);
|
15833 | return ret;
|
15834 | };
|
15835 |
|
15836 | const transformBind = (dir, _node, context) => {
|
15837 | const { modifiers, loc } = dir;
|
15838 | const arg = dir.arg;
|
15839 | let { exp } = dir;
|
15840 | if (exp && exp.type === 4 && !exp.content.trim()) {
|
15841 | {
|
15842 | exp = void 0;
|
15843 | }
|
15844 | }
|
15845 | if (!exp) {
|
15846 | if (arg.type !== 4 || !arg.isStatic) {
|
15847 | context.onError(
|
15848 | createCompilerError(
|
15849 | 52,
|
15850 | arg.loc
|
15851 | )
|
15852 | );
|
15853 | return {
|
15854 | props: [
|
15855 | createObjectProperty(arg, createSimpleExpression("", true, loc))
|
15856 | ]
|
15857 | };
|
15858 | }
|
15859 | const propName = camelize(arg.content);
|
15860 | exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
|
15861 | }
|
15862 | if (arg.type !== 4) {
|
15863 | arg.children.unshift(`(`);
|
15864 | arg.children.push(`) || ""`);
|
15865 | } else if (!arg.isStatic) {
|
15866 | arg.content = `${arg.content} || ""`;
|
15867 | }
|
15868 | if (modifiers.includes("camel")) {
|
15869 | if (arg.type === 4) {
|
15870 | if (arg.isStatic) {
|
15871 | arg.content = camelize(arg.content);
|
15872 | } else {
|
15873 | arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
15874 | }
|
15875 | } else {
|
15876 | arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
15877 | arg.children.push(`)`);
|
15878 | }
|
15879 | }
|
15880 | if (!context.inSSR) {
|
15881 | if (modifiers.includes("prop")) {
|
15882 | injectPrefix(arg, ".");
|
15883 | }
|
15884 | if (modifiers.includes("attr")) {
|
15885 | injectPrefix(arg, "^");
|
15886 | }
|
15887 | }
|
15888 | return {
|
15889 | props: [createObjectProperty(arg, exp)]
|
15890 | };
|
15891 | };
|
15892 | const injectPrefix = (arg, prefix) => {
|
15893 | if (arg.type === 4) {
|
15894 | if (arg.isStatic) {
|
15895 | arg.content = prefix + arg.content;
|
15896 | } else {
|
15897 | arg.content = `\`${prefix}\${${arg.content}}\``;
|
15898 | }
|
15899 | } else {
|
15900 | arg.children.unshift(`'${prefix}' + (`);
|
15901 | arg.children.push(`)`);
|
15902 | }
|
15903 | };
|
15904 |
|
15905 | const transformText = (node, context) => {
|
15906 | if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
15907 | return () => {
|
15908 | const children = node.children;
|
15909 | let currentContainer = void 0;
|
15910 | let hasText = false;
|
15911 | for (let i = 0; i < children.length; i++) {
|
15912 | const child = children[i];
|
15913 | if (isText$1(child)) {
|
15914 | hasText = true;
|
15915 | for (let j = i + 1; j < children.length; j++) {
|
15916 | const next = children[j];
|
15917 | if (isText$1(next)) {
|
15918 | if (!currentContainer) {
|
15919 | currentContainer = children[i] = createCompoundExpression(
|
15920 | [child],
|
15921 | child.loc
|
15922 | );
|
15923 | }
|
15924 | currentContainer.children.push(` + `, next);
|
15925 | children.splice(j, 1);
|
15926 | j--;
|
15927 | } else {
|
15928 | currentContainer = void 0;
|
15929 | break;
|
15930 | }
|
15931 | }
|
15932 | }
|
15933 | }
|
15934 | if (!hasText ||
|
15935 |
|
15936 |
|
15937 |
|
15938 | children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 &&
|
15939 |
|
15940 |
|
15941 |
|
15942 |
|
15943 | !node.props.find(
|
15944 | (p) => p.type === 7 && !context.directiveTransforms[p.name]
|
15945 | ) &&
|
15946 |
|
15947 |
|
15948 | true)) {
|
15949 | return;
|
15950 | }
|
15951 | for (let i = 0; i < children.length; i++) {
|
15952 | const child = children[i];
|
15953 | if (isText$1(child) || child.type === 8) {
|
15954 | const callArgs = [];
|
15955 | if (child.type !== 2 || child.content !== " ") {
|
15956 | callArgs.push(child);
|
15957 | }
|
15958 | if (!context.ssr && getConstantType(child, context) === 0) {
|
15959 | callArgs.push(
|
15960 | 1 + (` /* ${PatchFlagNames[1]} */` )
|
15961 | );
|
15962 | }
|
15963 | children[i] = {
|
15964 | type: 12,
|
15965 | content: child,
|
15966 | loc: child.loc,
|
15967 | codegenNode: createCallExpression(
|
15968 | context.helper(CREATE_TEXT),
|
15969 | callArgs
|
15970 | )
|
15971 | };
|
15972 | }
|
15973 | }
|
15974 | };
|
15975 | }
|
15976 | };
|
15977 |
|
15978 | const seen$1 = new WeakSet();
|
15979 | const transformOnce = (node, context) => {
|
15980 | if (node.type === 1 && findDir(node, "once", true)) {
|
15981 | if (seen$1.has(node) || context.inVOnce || context.inSSR) {
|
15982 | return;
|
15983 | }
|
15984 | seen$1.add(node);
|
15985 | context.inVOnce = true;
|
15986 | context.helper(SET_BLOCK_TRACKING);
|
15987 | return () => {
|
15988 | context.inVOnce = false;
|
15989 | const cur = context.currentNode;
|
15990 | if (cur.codegenNode) {
|
15991 | cur.codegenNode = context.cache(
|
15992 | cur.codegenNode,
|
15993 | true
|
15994 |
|
15995 | );
|
15996 | }
|
15997 | };
|
15998 | }
|
15999 | };
|
16000 |
|
16001 | const transformModel$1 = (dir, node, context) => {
|
16002 | const { exp, arg } = dir;
|
16003 | if (!exp) {
|
16004 | context.onError(
|
16005 | createCompilerError(41, dir.loc)
|
16006 | );
|
16007 | return createTransformProps();
|
16008 | }
|
16009 | const rawExp = exp.loc.source;
|
16010 | const expString = exp.type === 4 ? exp.content : rawExp;
|
16011 | const bindingType = context.bindingMetadata[rawExp];
|
16012 | if (bindingType === "props" || bindingType === "props-aliased") {
|
16013 | context.onError(createCompilerError(44, exp.loc));
|
16014 | return createTransformProps();
|
16015 | }
|
16016 | const maybeRef = false;
|
16017 | if (!expString.trim() || !isMemberExpression(expString) && !maybeRef) {
|
16018 | context.onError(
|
16019 | createCompilerError(42, exp.loc)
|
16020 | );
|
16021 | return createTransformProps();
|
16022 | }
|
16023 | const propName = arg ? arg : createSimpleExpression("modelValue", true);
|
16024 | const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
|
16025 | let assignmentExp;
|
16026 | const eventArg = context.isTS ? `($event: any)` : `$event`;
|
16027 | {
|
16028 | assignmentExp = createCompoundExpression([
|
16029 | `${eventArg} => ((`,
|
16030 | exp,
|
16031 | `) = $event)`
|
16032 | ]);
|
16033 | }
|
16034 | const props = [
|
16035 |
|
16036 | createObjectProperty(propName, dir.exp),
|
16037 |
|
16038 | createObjectProperty(eventName, assignmentExp)
|
16039 | ];
|
16040 | if (dir.modifiers.length && node.tagType === 1) {
|
16041 | const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
|
16042 | const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
|
16043 | props.push(
|
16044 | createObjectProperty(
|
16045 | modifiersKey,
|
16046 | createSimpleExpression(
|
16047 | `{ ${modifiers} }`,
|
16048 | false,
|
16049 | dir.loc,
|
16050 | 2
|
16051 | )
|
16052 | )
|
16053 | );
|
16054 | }
|
16055 | return createTransformProps(props);
|
16056 | };
|
16057 | function createTransformProps(props = []) {
|
16058 | return { props };
|
16059 | }
|
16060 |
|
16061 | const seen = new WeakSet();
|
16062 | const transformMemo = (node, context) => {
|
16063 | if (node.type === 1) {
|
16064 | const dir = findDir(node, "memo");
|
16065 | if (!dir || seen.has(node)) {
|
16066 | return;
|
16067 | }
|
16068 | seen.add(node);
|
16069 | return () => {
|
16070 | const codegenNode = node.codegenNode || context.currentNode.codegenNode;
|
16071 | if (codegenNode && codegenNode.type === 13) {
|
16072 | if (node.tagType !== 1) {
|
16073 | convertToBlock(codegenNode, context);
|
16074 | }
|
16075 | node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
16076 | dir.exp,
|
16077 | createFunctionExpression(void 0, codegenNode),
|
16078 | `_cache`,
|
16079 | String(context.cached++)
|
16080 | ]);
|
16081 | }
|
16082 | };
|
16083 | }
|
16084 | };
|
16085 |
|
16086 | function getBaseTransformPreset(prefixIdentifiers) {
|
16087 | return [
|
16088 | [
|
16089 | transformOnce,
|
16090 | transformIf,
|
16091 | transformMemo,
|
16092 | transformFor,
|
16093 | ...[],
|
16094 | ...[transformExpression] ,
|
16095 | transformSlotOutlet,
|
16096 | transformElement,
|
16097 | trackSlotScopes,
|
16098 | transformText
|
16099 | ],
|
16100 | {
|
16101 | on: transformOn$1,
|
16102 | bind: transformBind,
|
16103 | model: transformModel$1
|
16104 | }
|
16105 | ];
|
16106 | }
|
16107 | function baseCompile(source, options = {}) {
|
16108 | const onError = options.onError || defaultOnError;
|
16109 | const isModuleMode = options.mode === "module";
|
16110 | {
|
16111 | if (options.prefixIdentifiers === true) {
|
16112 | onError(createCompilerError(47));
|
16113 | } else if (isModuleMode) {
|
16114 | onError(createCompilerError(48));
|
16115 | }
|
16116 | }
|
16117 | const prefixIdentifiers = false;
|
16118 | if (options.cacheHandlers) {
|
16119 | onError(createCompilerError(49));
|
16120 | }
|
16121 | if (options.scopeId && !isModuleMode) {
|
16122 | onError(createCompilerError(50));
|
16123 | }
|
16124 | const resolvedOptions = extend({}, options, {
|
16125 | prefixIdentifiers
|
16126 | });
|
16127 | const ast = isString(source) ? baseParse(source, resolvedOptions) : source;
|
16128 | const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
16129 | transform(
|
16130 | ast,
|
16131 | extend({}, resolvedOptions, {
|
16132 | nodeTransforms: [
|
16133 | ...nodeTransforms,
|
16134 | ...options.nodeTransforms || []
|
16135 |
|
16136 | ],
|
16137 | directiveTransforms: extend(
|
16138 | {},
|
16139 | directiveTransforms,
|
16140 | options.directiveTransforms || {}
|
16141 |
|
16142 | )
|
16143 | })
|
16144 | );
|
16145 | return generate(ast, resolvedOptions);
|
16146 | }
|
16147 |
|
16148 | const noopDirectiveTransform = () => ({ props: [] });
|
16149 |
|
16150 | const V_MODEL_RADIO = Symbol(`vModelRadio` );
|
16151 | const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
|
16152 | const V_MODEL_TEXT = Symbol(`vModelText` );
|
16153 | const V_MODEL_SELECT = Symbol(`vModelSelect` );
|
16154 | const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
|
16155 | const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
|
16156 | const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
|
16157 | const V_SHOW = Symbol(`vShow` );
|
16158 | const TRANSITION = Symbol(`Transition` );
|
16159 | const TRANSITION_GROUP = Symbol(`TransitionGroup` );
|
16160 | registerRuntimeHelpers({
|
16161 | [V_MODEL_RADIO]: `vModelRadio`,
|
16162 | [V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
16163 | [V_MODEL_TEXT]: `vModelText`,
|
16164 | [V_MODEL_SELECT]: `vModelSelect`,
|
16165 | [V_MODEL_DYNAMIC]: `vModelDynamic`,
|
16166 | [V_ON_WITH_MODIFIERS]: `withModifiers`,
|
16167 | [V_ON_WITH_KEYS]: `withKeys`,
|
16168 | [V_SHOW]: `vShow`,
|
16169 | [TRANSITION]: `Transition`,
|
16170 | [TRANSITION_GROUP]: `TransitionGroup`
|
16171 | });
|
16172 |
|
16173 | let decoder;
|
16174 | function decodeHtmlBrowser(raw, asAttr = false) {
|
16175 | if (!decoder) {
|
16176 | decoder = document.createElement("div");
|
16177 | }
|
16178 | if (asAttr) {
|
16179 | decoder.innerHTML = `<div foo="${raw.replace(/"/g, """)}">`;
|
16180 | return decoder.children[0].getAttribute("foo");
|
16181 | } else {
|
16182 | decoder.innerHTML = raw;
|
16183 | return decoder.textContent;
|
16184 | }
|
16185 | }
|
16186 |
|
16187 | const parserOptions = {
|
16188 | parseMode: "html",
|
16189 | isVoidTag,
|
16190 | isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
16191 | isPreTag: (tag) => tag === "pre",
|
16192 | decodeEntities: decodeHtmlBrowser ,
|
16193 | isBuiltInComponent: (tag) => {
|
16194 | if (tag === "Transition" || tag === "transition") {
|
16195 | return TRANSITION;
|
16196 | } else if (tag === "TransitionGroup" || tag === "transition-group") {
|
16197 | return TRANSITION_GROUP;
|
16198 | }
|
16199 | },
|
16200 |
|
16201 | getNamespace(tag, parent, rootNamespace) {
|
16202 | let ns = parent ? parent.ns : rootNamespace;
|
16203 | if (parent && ns === 2) {
|
16204 | if (parent.tag === "annotation-xml") {
|
16205 | if (tag === "svg") {
|
16206 | return 1;
|
16207 | }
|
16208 | if (parent.props.some(
|
16209 | (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
|
16210 | )) {
|
16211 | ns = 0;
|
16212 | }
|
16213 | } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
|
16214 | ns = 0;
|
16215 | }
|
16216 | } else if (parent && ns === 1) {
|
16217 | if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
|
16218 | ns = 0;
|
16219 | }
|
16220 | }
|
16221 | if (ns === 0) {
|
16222 | if (tag === "svg") {
|
16223 | return 1;
|
16224 | }
|
16225 | if (tag === "math") {
|
16226 | return 2;
|
16227 | }
|
16228 | }
|
16229 | return ns;
|
16230 | }
|
16231 | };
|
16232 |
|
16233 | const transformStyle = (node) => {
|
16234 | if (node.type === 1) {
|
16235 | node.props.forEach((p, i) => {
|
16236 | if (p.type === 6 && p.name === "style" && p.value) {
|
16237 | node.props[i] = {
|
16238 | type: 7,
|
16239 | name: `bind`,
|
16240 | arg: createSimpleExpression(`style`, true, p.loc),
|
16241 | exp: parseInlineCSS(p.value.content, p.loc),
|
16242 | modifiers: [],
|
16243 | loc: p.loc
|
16244 | };
|
16245 | }
|
16246 | });
|
16247 | }
|
16248 | };
|
16249 | const parseInlineCSS = (cssText, loc) => {
|
16250 | const normalized = parseStringStyle(cssText);
|
16251 | return createSimpleExpression(
|
16252 | JSON.stringify(normalized),
|
16253 | false,
|
16254 | loc,
|
16255 | 3
|
16256 | );
|
16257 | };
|
16258 |
|
16259 | function createDOMCompilerError(code, loc) {
|
16260 | return createCompilerError(
|
16261 | code,
|
16262 | loc,
|
16263 | DOMErrorMessages
|
16264 | );
|
16265 | }
|
16266 | const DOMErrorMessages = {
|
16267 | [53]: `v-html is missing expression.`,
|
16268 | [54]: `v-html will override element children.`,
|
16269 | [55]: `v-text is missing expression.`,
|
16270 | [56]: `v-text will override element children.`,
|
16271 | [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
16272 | [58]: `v-model argument is not supported on plain elements.`,
|
16273 | [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
16274 | [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
16275 | [61]: `v-show is missing expression.`,
|
16276 | [62]: `<Transition> expects exactly one child element or component.`,
|
16277 | [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
16278 | };
|
16279 |
|
16280 | const transformVHtml = (dir, node, context) => {
|
16281 | const { exp, loc } = dir;
|
16282 | if (!exp) {
|
16283 | context.onError(
|
16284 | createDOMCompilerError(53, loc)
|
16285 | );
|
16286 | }
|
16287 | if (node.children.length) {
|
16288 | context.onError(
|
16289 | createDOMCompilerError(54, loc)
|
16290 | );
|
16291 | node.children.length = 0;
|
16292 | }
|
16293 | return {
|
16294 | props: [
|
16295 | createObjectProperty(
|
16296 | createSimpleExpression(`innerHTML`, true, loc),
|
16297 | exp || createSimpleExpression("", true)
|
16298 | )
|
16299 | ]
|
16300 | };
|
16301 | };
|
16302 |
|
16303 | const transformVText = (dir, node, context) => {
|
16304 | const { exp, loc } = dir;
|
16305 | if (!exp) {
|
16306 | context.onError(
|
16307 | createDOMCompilerError(55, loc)
|
16308 | );
|
16309 | }
|
16310 | if (node.children.length) {
|
16311 | context.onError(
|
16312 | createDOMCompilerError(56, loc)
|
16313 | );
|
16314 | node.children.length = 0;
|
16315 | }
|
16316 | return {
|
16317 | props: [
|
16318 | createObjectProperty(
|
16319 | createSimpleExpression(`textContent`, true),
|
16320 | exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
|
16321 | context.helperString(TO_DISPLAY_STRING),
|
16322 | [exp],
|
16323 | loc
|
16324 | ) : createSimpleExpression("", true)
|
16325 | )
|
16326 | ]
|
16327 | };
|
16328 | };
|
16329 |
|
16330 | const transformModel = (dir, node, context) => {
|
16331 | const baseResult = transformModel$1(dir, node, context);
|
16332 | if (!baseResult.props.length || node.tagType === 1) {
|
16333 | return baseResult;
|
16334 | }
|
16335 | if (dir.arg) {
|
16336 | context.onError(
|
16337 | createDOMCompilerError(
|
16338 | 58,
|
16339 | dir.arg.loc
|
16340 | )
|
16341 | );
|
16342 | }
|
16343 | function checkDuplicatedValue() {
|
16344 | const value = findDir(node, "bind");
|
16345 | if (value && isStaticArgOf(value.arg, "value")) {
|
16346 | context.onError(
|
16347 | createDOMCompilerError(
|
16348 | 60,
|
16349 | value.loc
|
16350 | )
|
16351 | );
|
16352 | }
|
16353 | }
|
16354 | const { tag } = node;
|
16355 | const isCustomElement = context.isCustomElement(tag);
|
16356 | if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
|
16357 | let directiveToUse = V_MODEL_TEXT;
|
16358 | let isInvalidType = false;
|
16359 | if (tag === "input" || isCustomElement) {
|
16360 | const type = findProp(node, `type`);
|
16361 | if (type) {
|
16362 | if (type.type === 7) {
|
16363 | directiveToUse = V_MODEL_DYNAMIC;
|
16364 | } else if (type.value) {
|
16365 | switch (type.value.content) {
|
16366 | case "radio":
|
16367 | directiveToUse = V_MODEL_RADIO;
|
16368 | break;
|
16369 | case "checkbox":
|
16370 | directiveToUse = V_MODEL_CHECKBOX;
|
16371 | break;
|
16372 | case "file":
|
16373 | isInvalidType = true;
|
16374 | context.onError(
|
16375 | createDOMCompilerError(
|
16376 | 59,
|
16377 | dir.loc
|
16378 | )
|
16379 | );
|
16380 | break;
|
16381 | default:
|
16382 | checkDuplicatedValue();
|
16383 | break;
|
16384 | }
|
16385 | }
|
16386 | } else if (hasDynamicKeyVBind(node)) {
|
16387 | directiveToUse = V_MODEL_DYNAMIC;
|
16388 | } else {
|
16389 | checkDuplicatedValue();
|
16390 | }
|
16391 | } else if (tag === "select") {
|
16392 | directiveToUse = V_MODEL_SELECT;
|
16393 | } else {
|
16394 | checkDuplicatedValue();
|
16395 | }
|
16396 | if (!isInvalidType) {
|
16397 | baseResult.needRuntime = context.helper(directiveToUse);
|
16398 | }
|
16399 | } else {
|
16400 | context.onError(
|
16401 | createDOMCompilerError(
|
16402 | 57,
|
16403 | dir.loc
|
16404 | )
|
16405 | );
|
16406 | }
|
16407 | baseResult.props = baseResult.props.filter(
|
16408 | (p) => !(p.key.type === 4 && p.key.content === "modelValue")
|
16409 | );
|
16410 | return baseResult;
|
16411 | };
|
16412 |
|
16413 | const isEventOptionModifier = makeMap(`passive,once,capture`);
|
16414 | const isNonKeyModifier = makeMap(
|
16415 |
|
16416 | `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
|
16417 | );
|
16418 | const maybeKeyModifier = makeMap("left,right");
|
16419 | const isKeyboardEvent = makeMap(
|
16420 | `onkeyup,onkeydown,onkeypress`,
|
16421 | true
|
16422 | );
|
16423 | const resolveModifiers = (key, modifiers, context, loc) => {
|
16424 | const keyModifiers = [];
|
16425 | const nonKeyModifiers = [];
|
16426 | const eventOptionModifiers = [];
|
16427 | for (let i = 0; i < modifiers.length; i++) {
|
16428 | const modifier = modifiers[i];
|
16429 | if (isEventOptionModifier(modifier)) {
|
16430 | eventOptionModifiers.push(modifier);
|
16431 | } else {
|
16432 | if (maybeKeyModifier(modifier)) {
|
16433 | if (isStaticExp(key)) {
|
16434 | if (isKeyboardEvent(key.content)) {
|
16435 | keyModifiers.push(modifier);
|
16436 | } else {
|
16437 | nonKeyModifiers.push(modifier);
|
16438 | }
|
16439 | } else {
|
16440 | keyModifiers.push(modifier);
|
16441 | nonKeyModifiers.push(modifier);
|
16442 | }
|
16443 | } else {
|
16444 | if (isNonKeyModifier(modifier)) {
|
16445 | nonKeyModifiers.push(modifier);
|
16446 | } else {
|
16447 | keyModifiers.push(modifier);
|
16448 | }
|
16449 | }
|
16450 | }
|
16451 | }
|
16452 | return {
|
16453 | keyModifiers,
|
16454 | nonKeyModifiers,
|
16455 | eventOptionModifiers
|
16456 | };
|
16457 | };
|
16458 | const transformClick = (key, event) => {
|
16459 | const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
|
16460 | return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
|
16461 | `(`,
|
16462 | key,
|
16463 | `) === "onClick" ? "${event}" : (`,
|
16464 | key,
|
16465 | `)`
|
16466 | ]) : key;
|
16467 | };
|
16468 | const transformOn = (dir, node, context) => {
|
16469 | return transformOn$1(dir, node, context, (baseResult) => {
|
16470 | const { modifiers } = dir;
|
16471 | if (!modifiers.length)
|
16472 | return baseResult;
|
16473 | let { key, value: handlerExp } = baseResult.props[0];
|
16474 | const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
16475 | if (nonKeyModifiers.includes("right")) {
|
16476 | key = transformClick(key, `onContextmenu`);
|
16477 | }
|
16478 | if (nonKeyModifiers.includes("middle")) {
|
16479 | key = transformClick(key, `onMouseup`);
|
16480 | }
|
16481 | if (nonKeyModifiers.length) {
|
16482 | handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
|
16483 | handlerExp,
|
16484 | JSON.stringify(nonKeyModifiers)
|
16485 | ]);
|
16486 | }
|
16487 | if (keyModifiers.length &&
|
16488 | (!isStaticExp(key) || isKeyboardEvent(key.content))) {
|
16489 | handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
16490 | handlerExp,
|
16491 | JSON.stringify(keyModifiers)
|
16492 | ]);
|
16493 | }
|
16494 | if (eventOptionModifiers.length) {
|
16495 | const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
|
16496 | key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
16497 | }
|
16498 | return {
|
16499 | props: [createObjectProperty(key, handlerExp)]
|
16500 | };
|
16501 | });
|
16502 | };
|
16503 |
|
16504 | const transformShow = (dir, node, context) => {
|
16505 | const { exp, loc } = dir;
|
16506 | if (!exp) {
|
16507 | context.onError(
|
16508 | createDOMCompilerError(61, loc)
|
16509 | );
|
16510 | }
|
16511 | return {
|
16512 | props: [],
|
16513 | needRuntime: context.helper(V_SHOW)
|
16514 | };
|
16515 | };
|
16516 |
|
16517 | const transformTransition = (node, context) => {
|
16518 | if (node.type === 1 && node.tagType === 1) {
|
16519 | const component = context.isBuiltInComponent(node.tag);
|
16520 | if (component === TRANSITION) {
|
16521 | return () => {
|
16522 | if (!node.children.length) {
|
16523 | return;
|
16524 | }
|
16525 | if (hasMultipleChildren(node)) {
|
16526 | context.onError(
|
16527 | createDOMCompilerError(
|
16528 | 62,
|
16529 | {
|
16530 | start: node.children[0].loc.start,
|
16531 | end: node.children[node.children.length - 1].loc.end,
|
16532 | source: ""
|
16533 | }
|
16534 | )
|
16535 | );
|
16536 | }
|
16537 | const child = node.children[0];
|
16538 | if (child.type === 1) {
|
16539 | for (const p of child.props) {
|
16540 | if (p.type === 7 && p.name === "show") {
|
16541 | node.props.push({
|
16542 | type: 6,
|
16543 | name: "persisted",
|
16544 | nameLoc: node.loc,
|
16545 | value: void 0,
|
16546 | loc: node.loc
|
16547 | });
|
16548 | }
|
16549 | }
|
16550 | }
|
16551 | };
|
16552 | }
|
16553 | }
|
16554 | };
|
16555 | function hasMultipleChildren(node) {
|
16556 | const children = node.children = node.children.filter(
|
16557 | (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
|
16558 | );
|
16559 | const child = children[0];
|
16560 | return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
|
16561 | }
|
16562 |
|
16563 | const ignoreSideEffectTags = (node, context) => {
|
16564 | if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
16565 | context.onError(
|
16566 | createDOMCompilerError(
|
16567 | 63,
|
16568 | node.loc
|
16569 | )
|
16570 | );
|
16571 | context.removeNode();
|
16572 | }
|
16573 | };
|
16574 |
|
16575 | const DOMNodeTransforms = [
|
16576 | transformStyle,
|
16577 | ...[transformTransition]
|
16578 | ];
|
16579 | const DOMDirectiveTransforms = {
|
16580 | cloak: noopDirectiveTransform,
|
16581 | html: transformVHtml,
|
16582 | text: transformVText,
|
16583 | model: transformModel,
|
16584 |
|
16585 | on: transformOn,
|
16586 |
|
16587 | show: transformShow
|
16588 | };
|
16589 | function compile(src, options = {}) {
|
16590 | return baseCompile(
|
16591 | src,
|
16592 | extend({}, parserOptions, options, {
|
16593 | nodeTransforms: [
|
16594 |
|
16595 |
|
16596 |
|
16597 | ignoreSideEffectTags,
|
16598 | ...DOMNodeTransforms,
|
16599 | ...options.nodeTransforms || []
|
16600 | ],
|
16601 | directiveTransforms: extend(
|
16602 | {},
|
16603 | DOMDirectiveTransforms,
|
16604 | options.directiveTransforms || {}
|
16605 | ),
|
16606 | transformHoist: null
|
16607 | })
|
16608 | );
|
16609 | }
|
16610 |
|
16611 | {
|
16612 | initDev();
|
16613 | }
|
16614 | const compileCache = new WeakMap();
|
16615 | function getCache(options) {
|
16616 | let c = compileCache.get(options != null ? options : EMPTY_OBJ);
|
16617 | if (!c) {
|
16618 | c = Object.create(null);
|
16619 | compileCache.set(options != null ? options : EMPTY_OBJ, c);
|
16620 | }
|
16621 | return c;
|
16622 | }
|
16623 | function compileToFunction(template, options) {
|
16624 | if (!isString(template)) {
|
16625 | if (template.nodeType) {
|
16626 | template = template.innerHTML;
|
16627 | } else {
|
16628 | warn(`invalid template option: `, template);
|
16629 | return NOOP;
|
16630 | }
|
16631 | }
|
16632 | const key = template;
|
16633 | const cache = getCache(options);
|
16634 | const cached = cache[key];
|
16635 | if (cached) {
|
16636 | return cached;
|
16637 | }
|
16638 | if (template[0] === "#") {
|
16639 | const el = document.querySelector(template);
|
16640 | if (!el) {
|
16641 | warn(`Template element not found or is empty: ${template}`);
|
16642 | }
|
16643 | template = el ? el.innerHTML : ``;
|
16644 | }
|
16645 | const opts = extend(
|
16646 | {
|
16647 | hoistStatic: true,
|
16648 | onError: onError ,
|
16649 | onWarn: (e) => onError(e, true)
|
16650 | },
|
16651 | options
|
16652 | );
|
16653 | if (!opts.isCustomElement && typeof customElements !== "undefined") {
|
16654 | opts.isCustomElement = (tag) => !!customElements.get(tag);
|
16655 | }
|
16656 | const { code } = compile(template, opts);
|
16657 | function onError(err, asWarning = false) {
|
16658 | const message = asWarning ? err.message : `Template compilation error: ${err.message}`;
|
16659 | const codeFrame = err.loc && generateCodeFrame(
|
16660 | template,
|
16661 | err.loc.start.offset,
|
16662 | err.loc.end.offset
|
16663 | );
|
16664 | warn(codeFrame ? `${message}
|
16665 | ${codeFrame}` : message);
|
16666 | }
|
16667 | const render = new Function("Vue", code)(runtimeDom);
|
16668 | render._rc = true;
|
16669 | return cache[key] = render;
|
16670 | }
|
16671 | registerRuntimeCompiler(compileToFunction);
|
16672 |
|
16673 | export { BaseTransition, BaseTransitionPropsValidators, Comment, DeprecationTypes, EffectScope, ErrorCodes, ErrorTypeStrings, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, TrackOpTypes, Transition, TransitionGroup, TriggerOpTypes, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compileToFunction as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useModel, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };
|