1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var Vue = (function (exports) {
|
7 | 'use strict';
|
8 |
|
9 |
|
10 |
|
11 | function makeMap(str, expectsLowerCase) {
|
12 | const set = new Set(str.split(","));
|
13 | return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
|
14 | }
|
15 |
|
16 | const EMPTY_OBJ = Object.freeze({}) ;
|
17 | const EMPTY_ARR = Object.freeze([]) ;
|
18 | const NOOP = () => {
|
19 | };
|
20 | const NO = () => false;
|
21 | const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 &&
|
22 | (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
|
23 | const isModelListener = (key) => key.startsWith("onUpdate:");
|
24 | const extend = Object.assign;
|
25 | const remove = (arr, el) => {
|
26 | const i = arr.indexOf(el);
|
27 | if (i > -1) {
|
28 | arr.splice(i, 1);
|
29 | }
|
30 | };
|
31 | const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
32 | const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
33 | const isArray = Array.isArray;
|
34 | const isMap = (val) => toTypeString(val) === "[object Map]";
|
35 | const isSet = (val) => toTypeString(val) === "[object Set]";
|
36 | const isDate = (val) => toTypeString(val) === "[object Date]";
|
37 | const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
|
38 | const isFunction = (val) => typeof val === "function";
|
39 | const isString = (val) => typeof val === "string";
|
40 | const isSymbol = (val) => typeof val === "symbol";
|
41 | const isObject = (val) => val !== null && typeof val === "object";
|
42 | const isPromise = (val) => {
|
43 | return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
|
44 | };
|
45 | const objectToString = Object.prototype.toString;
|
46 | const toTypeString = (value) => objectToString.call(value);
|
47 | const toRawType = (value) => {
|
48 | return toTypeString(value).slice(8, -1);
|
49 | };
|
50 | const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
51 | const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
52 | const isReservedProp = makeMap(
|
53 |
|
54 | ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
|
55 | );
|
56 | const isBuiltInDirective = makeMap(
|
57 | "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
|
58 | );
|
59 | const cacheStringFunction = (fn) => {
|
60 | const cache = Object.create(null);
|
61 | return (str) => {
|
62 | const hit = cache[str];
|
63 | return hit || (cache[str] = fn(str));
|
64 | };
|
65 | };
|
66 | const camelizeRE = /-(\w)/g;
|
67 | const camelize = cacheStringFunction((str) => {
|
68 | return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
69 | });
|
70 | const hyphenateRE = /\B([A-Z])/g;
|
71 | const hyphenate = cacheStringFunction(
|
72 | (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
73 | );
|
74 | const capitalize = cacheStringFunction((str) => {
|
75 | return str.charAt(0).toUpperCase() + str.slice(1);
|
76 | });
|
77 | const toHandlerKey = cacheStringFunction((str) => {
|
78 | const s = str ? `on${capitalize(str)}` : ``;
|
79 | return s;
|
80 | });
|
81 | const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
82 | const invokeArrayFns = (fns, arg) => {
|
83 | for (let i = 0; i < fns.length; i++) {
|
84 | fns[i](arg);
|
85 | }
|
86 | };
|
87 | const def = (obj, key, value) => {
|
88 | Object.defineProperty(obj, key, {
|
89 | configurable: true,
|
90 | enumerable: false,
|
91 | value
|
92 | });
|
93 | };
|
94 | const looseToNumber = (val) => {
|
95 | const n = parseFloat(val);
|
96 | return isNaN(n) ? val : n;
|
97 | };
|
98 | const toNumber = (val) => {
|
99 | const n = isString(val) ? Number(val) : NaN;
|
100 | return isNaN(n) ? val : n;
|
101 | };
|
102 | let _globalThis;
|
103 | const getGlobalThis = () => {
|
104 | return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
|
105 | };
|
106 |
|
107 | const PatchFlagNames = {
|
108 | [1]: `TEXT`,
|
109 | [2]: `CLASS`,
|
110 | [4]: `STYLE`,
|
111 | [8]: `PROPS`,
|
112 | [16]: `FULL_PROPS`,
|
113 | [32]: `NEED_HYDRATION`,
|
114 | [64]: `STABLE_FRAGMENT`,
|
115 | [128]: `KEYED_FRAGMENT`,
|
116 | [256]: `UNKEYED_FRAGMENT`,
|
117 | [512]: `NEED_PATCH`,
|
118 | [1024]: `DYNAMIC_SLOTS`,
|
119 | [2048]: `DEV_ROOT_FRAGMENT`,
|
120 | [-1]: `HOISTED`,
|
121 | [-2]: `BAIL`
|
122 | };
|
123 |
|
124 | const slotFlagsText = {
|
125 | [1]: "STABLE",
|
126 | [2]: "DYNAMIC",
|
127 | [3]: "FORWARDED"
|
128 | };
|
129 |
|
130 | 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";
|
131 | const isGloballyAllowed = makeMap(GLOBALS_ALLOWED);
|
132 |
|
133 | const range = 2;
|
134 | function generateCodeFrame(source, start = 0, end = source.length) {
|
135 | let lines = source.split(/(\r?\n)/);
|
136 | const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
137 | lines = lines.filter((_, idx) => idx % 2 === 0);
|
138 | let count = 0;
|
139 | const res = [];
|
140 | for (let i = 0; i < lines.length; i++) {
|
141 | count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
|
142 | if (count >= start) {
|
143 | for (let j = i - range; j <= i + range || end > count; j++) {
|
144 | if (j < 0 || j >= lines.length)
|
145 | continue;
|
146 | const line = j + 1;
|
147 | res.push(
|
148 | `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
|
149 | );
|
150 | const lineLength = lines[j].length;
|
151 | const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
|
152 | if (j === i) {
|
153 | const pad = start - (count - (lineLength + newLineSeqLength));
|
154 | const length = Math.max(
|
155 | 1,
|
156 | end > count ? lineLength - pad : end - start
|
157 | );
|
158 | res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
|
159 | } else if (j > i) {
|
160 | if (end > count) {
|
161 | const length = Math.max(Math.min(end - count, lineLength), 1);
|
162 | res.push(` | ` + "^".repeat(length));
|
163 | }
|
164 | count += lineLength + newLineSeqLength;
|
165 | }
|
166 | }
|
167 | break;
|
168 | }
|
169 | }
|
170 | return res.join("\n");
|
171 | }
|
172 |
|
173 | function normalizeStyle(value) {
|
174 | if (isArray(value)) {
|
175 | const res = {};
|
176 | for (let i = 0; i < value.length; i++) {
|
177 | const item = value[i];
|
178 | const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
179 | if (normalized) {
|
180 | for (const key in normalized) {
|
181 | res[key] = normalized[key];
|
182 | }
|
183 | }
|
184 | }
|
185 | return res;
|
186 | } else if (isString(value) || isObject(value)) {
|
187 | return value;
|
188 | }
|
189 | }
|
190 | const listDelimiterRE = /;(?![^(]*\))/g;
|
191 | const propertyDelimiterRE = /:([^]+)/;
|
192 | const styleCommentRE = /\/\*[^]*?\*\//g;
|
193 | function parseStringStyle(cssText) {
|
194 | const ret = {};
|
195 | cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
196 | if (item) {
|
197 | const tmp = item.split(propertyDelimiterRE);
|
198 | tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
199 | }
|
200 | });
|
201 | return ret;
|
202 | }
|
203 | function stringifyStyle(styles) {
|
204 | let ret = "";
|
205 | if (!styles || isString(styles)) {
|
206 | return ret;
|
207 | }
|
208 | for (const key in styles) {
|
209 | const value = styles[key];
|
210 | const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
211 | if (isString(value) || typeof value === "number") {
|
212 | ret += `${normalizedKey}:${value};`;
|
213 | }
|
214 | }
|
215 | return ret;
|
216 | }
|
217 | function normalizeClass(value) {
|
218 | let res = "";
|
219 | if (isString(value)) {
|
220 | res = value;
|
221 | } else if (isArray(value)) {
|
222 | for (let i = 0; i < value.length; i++) {
|
223 | const normalized = normalizeClass(value[i]);
|
224 | if (normalized) {
|
225 | res += normalized + " ";
|
226 | }
|
227 | }
|
228 | } else if (isObject(value)) {
|
229 | for (const name in value) {
|
230 | if (value[name]) {
|
231 | res += name + " ";
|
232 | }
|
233 | }
|
234 | }
|
235 | return res.trim();
|
236 | }
|
237 | function normalizeProps(props) {
|
238 | if (!props)
|
239 | return null;
|
240 | let { class: klass, style } = props;
|
241 | if (klass && !isString(klass)) {
|
242 | props.class = normalizeClass(klass);
|
243 | }
|
244 | if (style) {
|
245 | props.style = normalizeStyle(style);
|
246 | }
|
247 | return props;
|
248 | }
|
249 |
|
250 | 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";
|
251 | 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";
|
252 | 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";
|
253 | const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
|
254 | const isHTMLTag = makeMap(HTML_TAGS);
|
255 | const isSVGTag = makeMap(SVG_TAGS);
|
256 | const isMathMLTag = makeMap(MATH_TAGS);
|
257 | const isVoidTag = makeMap(VOID_TAGS);
|
258 |
|
259 | const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
260 | const isSpecialBooleanAttr = makeMap(specialBooleanAttrs);
|
261 | const isBooleanAttr = makeMap(
|
262 | specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
|
263 | );
|
264 | function includeBooleanAttr(value) {
|
265 | return !!value || value === "";
|
266 | }
|
267 | const isKnownHtmlAttr = makeMap(
|
268 | `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`
|
269 | );
|
270 | const isKnownSvgAttr = makeMap(
|
271 | `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`
|
272 | );
|
273 | function isRenderableAttrValue(value) {
|
274 | if (value == null) {
|
275 | return false;
|
276 | }
|
277 | const type = typeof value;
|
278 | return type === "string" || type === "number" || type === "boolean";
|
279 | }
|
280 |
|
281 | function looseCompareArrays(a, b) {
|
282 | if (a.length !== b.length)
|
283 | return false;
|
284 | let equal = true;
|
285 | for (let i = 0; equal && i < a.length; i++) {
|
286 | equal = looseEqual(a[i], b[i]);
|
287 | }
|
288 | return equal;
|
289 | }
|
290 | function looseEqual(a, b) {
|
291 | if (a === b)
|
292 | return true;
|
293 | let aValidType = isDate(a);
|
294 | let bValidType = isDate(b);
|
295 | if (aValidType || bValidType) {
|
296 | return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
297 | }
|
298 | aValidType = isSymbol(a);
|
299 | bValidType = isSymbol(b);
|
300 | if (aValidType || bValidType) {
|
301 | return a === b;
|
302 | }
|
303 | aValidType = isArray(a);
|
304 | bValidType = isArray(b);
|
305 | if (aValidType || bValidType) {
|
306 | return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
307 | }
|
308 | aValidType = isObject(a);
|
309 | bValidType = isObject(b);
|
310 | if (aValidType || bValidType) {
|
311 | if (!aValidType || !bValidType) {
|
312 | return false;
|
313 | }
|
314 | const aKeysCount = Object.keys(a).length;
|
315 | const bKeysCount = Object.keys(b).length;
|
316 | if (aKeysCount !== bKeysCount) {
|
317 | return false;
|
318 | }
|
319 | for (const key in a) {
|
320 | const aHasKey = a.hasOwnProperty(key);
|
321 | const bHasKey = b.hasOwnProperty(key);
|
322 | if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
|
323 | return false;
|
324 | }
|
325 | }
|
326 | }
|
327 | return String(a) === String(b);
|
328 | }
|
329 | function looseIndexOf(arr, val) {
|
330 | return arr.findIndex((item) => looseEqual(item, val));
|
331 | }
|
332 |
|
333 | const toDisplayString = (val) => {
|
334 | return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
|
335 | };
|
336 | const replacer = (_key, val) => {
|
337 | if (val && val.__v_isRef) {
|
338 | return replacer(_key, val.value);
|
339 | } else if (isMap(val)) {
|
340 | return {
|
341 | [`Map(${val.size})`]: [...val.entries()].reduce(
|
342 | (entries, [key, val2], i) => {
|
343 | entries[stringifySymbol(key, i) + " =>"] = val2;
|
344 | return entries;
|
345 | },
|
346 | {}
|
347 | )
|
348 | };
|
349 | } else if (isSet(val)) {
|
350 | return {
|
351 | [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
|
352 | };
|
353 | } else if (isSymbol(val)) {
|
354 | return stringifySymbol(val);
|
355 | } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
|
356 | return String(val);
|
357 | }
|
358 | return val;
|
359 | };
|
360 | const stringifySymbol = (v, i = "") => {
|
361 | var _a;
|
362 | return (
|
363 |
|
364 |
|
365 | isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
|
366 | );
|
367 | };
|
368 |
|
369 | function warn$2(msg, ...args) {
|
370 | console.warn(`[Vue warn] ${msg}`, ...args);
|
371 | }
|
372 |
|
373 | let activeEffectScope;
|
374 | class EffectScope {
|
375 | constructor(detached = false) {
|
376 | this.detached = detached;
|
377 | |
378 |
|
379 |
|
380 | this._active = true;
|
381 | |
382 |
|
383 |
|
384 | this.effects = [];
|
385 | |
386 |
|
387 |
|
388 | this.cleanups = [];
|
389 | this.parent = activeEffectScope;
|
390 | if (!detached && activeEffectScope) {
|
391 | this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
|
392 | this
|
393 | ) - 1;
|
394 | }
|
395 | }
|
396 | get active() {
|
397 | return this._active;
|
398 | }
|
399 | run(fn) {
|
400 | if (this._active) {
|
401 | const currentEffectScope = activeEffectScope;
|
402 | try {
|
403 | activeEffectScope = this;
|
404 | return fn();
|
405 | } finally {
|
406 | activeEffectScope = currentEffectScope;
|
407 | }
|
408 | } else {
|
409 | warn$2(`cannot run an inactive effect scope.`);
|
410 | }
|
411 | }
|
412 | |
413 |
|
414 |
|
415 |
|
416 | on() {
|
417 | activeEffectScope = this;
|
418 | }
|
419 | |
420 |
|
421 |
|
422 |
|
423 | off() {
|
424 | activeEffectScope = this.parent;
|
425 | }
|
426 | stop(fromParent) {
|
427 | if (this._active) {
|
428 | let i, l;
|
429 | for (i = 0, l = this.effects.length; i < l; i++) {
|
430 | this.effects[i].stop();
|
431 | }
|
432 | for (i = 0, l = this.cleanups.length; i < l; i++) {
|
433 | this.cleanups[i]();
|
434 | }
|
435 | if (this.scopes) {
|
436 | for (i = 0, l = this.scopes.length; i < l; i++) {
|
437 | this.scopes[i].stop(true);
|
438 | }
|
439 | }
|
440 | if (!this.detached && this.parent && !fromParent) {
|
441 | const last = this.parent.scopes.pop();
|
442 | if (last && last !== this) {
|
443 | this.parent.scopes[this.index] = last;
|
444 | last.index = this.index;
|
445 | }
|
446 | }
|
447 | this.parent = void 0;
|
448 | this._active = false;
|
449 | }
|
450 | }
|
451 | }
|
452 | function effectScope(detached) {
|
453 | return new EffectScope(detached);
|
454 | }
|
455 | function recordEffectScope(effect, scope = activeEffectScope) {
|
456 | if (scope && scope.active) {
|
457 | scope.effects.push(effect);
|
458 | }
|
459 | }
|
460 | function getCurrentScope() {
|
461 | return activeEffectScope;
|
462 | }
|
463 | function onScopeDispose(fn) {
|
464 | if (activeEffectScope) {
|
465 | activeEffectScope.cleanups.push(fn);
|
466 | } else {
|
467 | warn$2(
|
468 | `onScopeDispose() is called when there is no active effect scope to be associated with.`
|
469 | );
|
470 | }
|
471 | }
|
472 |
|
473 | let activeEffect;
|
474 | class ReactiveEffect {
|
475 | constructor(fn, trigger, scheduler, scope) {
|
476 | this.fn = fn;
|
477 | this.trigger = trigger;
|
478 | this.scheduler = scheduler;
|
479 | this.active = true;
|
480 | this.deps = [];
|
481 | |
482 |
|
483 |
|
484 | this._dirtyLevel = 4;
|
485 | |
486 |
|
487 |
|
488 | this._trackId = 0;
|
489 | |
490 |
|
491 |
|
492 | this._runnings = 0;
|
493 | |
494 |
|
495 |
|
496 | this._shouldSchedule = false;
|
497 | |
498 |
|
499 |
|
500 | this._depsLength = 0;
|
501 | recordEffectScope(this, scope);
|
502 | }
|
503 | get dirty() {
|
504 | if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
|
505 | this._dirtyLevel = 1;
|
506 | pauseTracking();
|
507 | for (let i = 0; i < this._depsLength; i++) {
|
508 | const dep = this.deps[i];
|
509 | if (dep.computed) {
|
510 | triggerComputed(dep.computed);
|
511 | if (this._dirtyLevel >= 4) {
|
512 | break;
|
513 | }
|
514 | }
|
515 | }
|
516 | if (this._dirtyLevel === 1) {
|
517 | this._dirtyLevel = 0;
|
518 | }
|
519 | resetTracking();
|
520 | }
|
521 | return this._dirtyLevel >= 4;
|
522 | }
|
523 | set dirty(v) {
|
524 | this._dirtyLevel = v ? 4 : 0;
|
525 | }
|
526 | run() {
|
527 | this._dirtyLevel = 0;
|
528 | if (!this.active) {
|
529 | return this.fn();
|
530 | }
|
531 | let lastShouldTrack = shouldTrack;
|
532 | let lastEffect = activeEffect;
|
533 | try {
|
534 | shouldTrack = true;
|
535 | activeEffect = this;
|
536 | this._runnings++;
|
537 | preCleanupEffect(this);
|
538 | return this.fn();
|
539 | } finally {
|
540 | postCleanupEffect(this);
|
541 | this._runnings--;
|
542 | activeEffect = lastEffect;
|
543 | shouldTrack = lastShouldTrack;
|
544 | }
|
545 | }
|
546 | stop() {
|
547 | var _a;
|
548 | if (this.active) {
|
549 | preCleanupEffect(this);
|
550 | postCleanupEffect(this);
|
551 | (_a = this.onStop) == null ? void 0 : _a.call(this);
|
552 | this.active = false;
|
553 | }
|
554 | }
|
555 | }
|
556 | function triggerComputed(computed) {
|
557 | return computed.value;
|
558 | }
|
559 | function preCleanupEffect(effect2) {
|
560 | effect2._trackId++;
|
561 | effect2._depsLength = 0;
|
562 | }
|
563 | function postCleanupEffect(effect2) {
|
564 | if (effect2.deps.length > effect2._depsLength) {
|
565 | for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
|
566 | cleanupDepEffect(effect2.deps[i], effect2);
|
567 | }
|
568 | effect2.deps.length = effect2._depsLength;
|
569 | }
|
570 | }
|
571 | function cleanupDepEffect(dep, effect2) {
|
572 | const trackId = dep.get(effect2);
|
573 | if (trackId !== void 0 && effect2._trackId !== trackId) {
|
574 | dep.delete(effect2);
|
575 | if (dep.size === 0) {
|
576 | dep.cleanup();
|
577 | }
|
578 | }
|
579 | }
|
580 | function effect(fn, options) {
|
581 | if (fn.effect instanceof ReactiveEffect) {
|
582 | fn = fn.effect.fn;
|
583 | }
|
584 | const _effect = new ReactiveEffect(fn, NOOP, () => {
|
585 | if (_effect.dirty) {
|
586 | _effect.run();
|
587 | }
|
588 | });
|
589 | if (options) {
|
590 | extend(_effect, options);
|
591 | if (options.scope)
|
592 | recordEffectScope(_effect, options.scope);
|
593 | }
|
594 | if (!options || !options.lazy) {
|
595 | _effect.run();
|
596 | }
|
597 | const runner = _effect.run.bind(_effect);
|
598 | runner.effect = _effect;
|
599 | return runner;
|
600 | }
|
601 | function stop(runner) {
|
602 | runner.effect.stop();
|
603 | }
|
604 | let shouldTrack = true;
|
605 | let pauseScheduleStack = 0;
|
606 | const trackStack = [];
|
607 | function pauseTracking() {
|
608 | trackStack.push(shouldTrack);
|
609 | shouldTrack = false;
|
610 | }
|
611 | function resetTracking() {
|
612 | const last = trackStack.pop();
|
613 | shouldTrack = last === void 0 ? true : last;
|
614 | }
|
615 | function pauseScheduling() {
|
616 | pauseScheduleStack++;
|
617 | }
|
618 | function resetScheduling() {
|
619 | pauseScheduleStack--;
|
620 | while (!pauseScheduleStack && queueEffectSchedulers.length) {
|
621 | queueEffectSchedulers.shift()();
|
622 | }
|
623 | }
|
624 | function trackEffect(effect2, dep, debuggerEventExtraInfo) {
|
625 | var _a;
|
626 | if (dep.get(effect2) !== effect2._trackId) {
|
627 | dep.set(effect2, effect2._trackId);
|
628 | const oldDep = effect2.deps[effect2._depsLength];
|
629 | if (oldDep !== dep) {
|
630 | if (oldDep) {
|
631 | cleanupDepEffect(oldDep, effect2);
|
632 | }
|
633 | effect2.deps[effect2._depsLength++] = dep;
|
634 | } else {
|
635 | effect2._depsLength++;
|
636 | }
|
637 | {
|
638 | (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
639 | }
|
640 | }
|
641 | }
|
642 | const queueEffectSchedulers = [];
|
643 | function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
644 | var _a;
|
645 | pauseScheduling();
|
646 | for (const effect2 of dep.keys()) {
|
647 | let tracking;
|
648 | if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
649 | effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
|
650 | effect2._dirtyLevel = dirtyLevel;
|
651 | }
|
652 | if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
653 | {
|
654 | (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
655 | }
|
656 | effect2.trigger();
|
657 | if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
|
658 | effect2._shouldSchedule = false;
|
659 | if (effect2.scheduler) {
|
660 | queueEffectSchedulers.push(effect2.scheduler);
|
661 | }
|
662 | }
|
663 | }
|
664 | }
|
665 | resetScheduling();
|
666 | }
|
667 |
|
668 | const createDep = (cleanup, computed) => {
|
669 | const dep = new Map();
|
670 | dep.cleanup = cleanup;
|
671 | dep.computed = computed;
|
672 | return dep;
|
673 | };
|
674 |
|
675 | const targetMap = new WeakMap();
|
676 | const ITERATE_KEY = Symbol("iterate" );
|
677 | const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
|
678 | function track(target, type, key) {
|
679 | if (shouldTrack && activeEffect) {
|
680 | let depsMap = targetMap.get(target);
|
681 | if (!depsMap) {
|
682 | targetMap.set(target, depsMap = new Map());
|
683 | }
|
684 | let dep = depsMap.get(key);
|
685 | if (!dep) {
|
686 | depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
|
687 | }
|
688 | trackEffect(
|
689 | activeEffect,
|
690 | dep,
|
691 | {
|
692 | target,
|
693 | type,
|
694 | key
|
695 | }
|
696 | );
|
697 | }
|
698 | }
|
699 | function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
700 | const depsMap = targetMap.get(target);
|
701 | if (!depsMap) {
|
702 | return;
|
703 | }
|
704 | let deps = [];
|
705 | if (type === "clear") {
|
706 | deps = [...depsMap.values()];
|
707 | } else if (key === "length" && isArray(target)) {
|
708 | const newLength = Number(newValue);
|
709 | depsMap.forEach((dep, key2) => {
|
710 | if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
|
711 | deps.push(dep);
|
712 | }
|
713 | });
|
714 | } else {
|
715 | if (key !== void 0) {
|
716 | deps.push(depsMap.get(key));
|
717 | }
|
718 | switch (type) {
|
719 | case "add":
|
720 | if (!isArray(target)) {
|
721 | deps.push(depsMap.get(ITERATE_KEY));
|
722 | if (isMap(target)) {
|
723 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
724 | }
|
725 | } else if (isIntegerKey(key)) {
|
726 | deps.push(depsMap.get("length"));
|
727 | }
|
728 | break;
|
729 | case "delete":
|
730 | if (!isArray(target)) {
|
731 | deps.push(depsMap.get(ITERATE_KEY));
|
732 | if (isMap(target)) {
|
733 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
734 | }
|
735 | }
|
736 | break;
|
737 | case "set":
|
738 | if (isMap(target)) {
|
739 | deps.push(depsMap.get(ITERATE_KEY));
|
740 | }
|
741 | break;
|
742 | }
|
743 | }
|
744 | pauseScheduling();
|
745 | for (const dep of deps) {
|
746 | if (dep) {
|
747 | triggerEffects(
|
748 | dep,
|
749 | 4,
|
750 | {
|
751 | target,
|
752 | type,
|
753 | key,
|
754 | newValue,
|
755 | oldValue,
|
756 | oldTarget
|
757 | }
|
758 | );
|
759 | }
|
760 | }
|
761 | resetScheduling();
|
762 | }
|
763 | function getDepFromReactive(object, key) {
|
764 | var _a;
|
765 | return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
|
766 | }
|
767 |
|
768 | const isNonTrackableKeys = makeMap(`__proto__,__v_isRef,__isVue`);
|
769 | const builtInSymbols = new Set(
|
770 | Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
771 | );
|
772 | const arrayInstrumentations = createArrayInstrumentations();
|
773 | function createArrayInstrumentations() {
|
774 | const instrumentations = {};
|
775 | ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
776 | instrumentations[key] = function(...args) {
|
777 | const arr = toRaw(this);
|
778 | for (let i = 0, l = this.length; i < l; i++) {
|
779 | track(arr, "get", i + "");
|
780 | }
|
781 | const res = arr[key](...args);
|
782 | if (res === -1 || res === false) {
|
783 | return arr[key](...args.map(toRaw));
|
784 | } else {
|
785 | return res;
|
786 | }
|
787 | };
|
788 | });
|
789 | ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
790 | instrumentations[key] = function(...args) {
|
791 | pauseTracking();
|
792 | pauseScheduling();
|
793 | const res = toRaw(this)[key].apply(this, args);
|
794 | resetScheduling();
|
795 | resetTracking();
|
796 | return res;
|
797 | };
|
798 | });
|
799 | return instrumentations;
|
800 | }
|
801 | function hasOwnProperty(key) {
|
802 | if (!isSymbol(key))
|
803 | key = String(key);
|
804 | const obj = toRaw(this);
|
805 | track(obj, "has", key);
|
806 | return obj.hasOwnProperty(key);
|
807 | }
|
808 | class BaseReactiveHandler {
|
809 | constructor(_isReadonly = false, _isShallow = false) {
|
810 | this._isReadonly = _isReadonly;
|
811 | this._isShallow = _isShallow;
|
812 | }
|
813 | get(target, key, receiver) {
|
814 | const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
|
815 | if (key === "__v_isReactive") {
|
816 | return !isReadonly2;
|
817 | } else if (key === "__v_isReadonly") {
|
818 | return isReadonly2;
|
819 | } else if (key === "__v_isShallow") {
|
820 | return isShallow2;
|
821 | } else if (key === "__v_raw") {
|
822 | if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) ||
|
823 |
|
824 | Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
825 | return target;
|
826 | }
|
827 | return;
|
828 | }
|
829 | const targetIsArray = isArray(target);
|
830 | if (!isReadonly2) {
|
831 | if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
832 | return Reflect.get(arrayInstrumentations, key, receiver);
|
833 | }
|
834 | if (key === "hasOwnProperty") {
|
835 | return hasOwnProperty;
|
836 | }
|
837 | }
|
838 | const res = Reflect.get(target, key, receiver);
|
839 | if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
840 | return res;
|
841 | }
|
842 | if (!isReadonly2) {
|
843 | track(target, "get", key);
|
844 | }
|
845 | if (isShallow2) {
|
846 | return res;
|
847 | }
|
848 | if (isRef(res)) {
|
849 | return targetIsArray && isIntegerKey(key) ? res : res.value;
|
850 | }
|
851 | if (isObject(res)) {
|
852 | return isReadonly2 ? readonly(res) : reactive(res);
|
853 | }
|
854 | return res;
|
855 | }
|
856 | }
|
857 | class MutableReactiveHandler extends BaseReactiveHandler {
|
858 | constructor(isShallow2 = false) {
|
859 | super(false, isShallow2);
|
860 | }
|
861 | set(target, key, value, receiver) {
|
862 | let oldValue = target[key];
|
863 | if (!this._isShallow) {
|
864 | const isOldValueReadonly = isReadonly(oldValue);
|
865 | if (!isShallow(value) && !isReadonly(value)) {
|
866 | oldValue = toRaw(oldValue);
|
867 | value = toRaw(value);
|
868 | }
|
869 | if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
870 | if (isOldValueReadonly) {
|
871 | return false;
|
872 | } else {
|
873 | oldValue.value = value;
|
874 | return true;
|
875 | }
|
876 | }
|
877 | }
|
878 | const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
879 | const result = Reflect.set(target, key, value, receiver);
|
880 | if (target === toRaw(receiver)) {
|
881 | if (!hadKey) {
|
882 | trigger(target, "add", key, value);
|
883 | } else if (hasChanged(value, oldValue)) {
|
884 | trigger(target, "set", key, value, oldValue);
|
885 | }
|
886 | }
|
887 | return result;
|
888 | }
|
889 | deleteProperty(target, key) {
|
890 | const hadKey = hasOwn(target, key);
|
891 | const oldValue = target[key];
|
892 | const result = Reflect.deleteProperty(target, key);
|
893 | if (result && hadKey) {
|
894 | trigger(target, "delete", key, void 0, oldValue);
|
895 | }
|
896 | return result;
|
897 | }
|
898 | has(target, key) {
|
899 | const result = Reflect.has(target, key);
|
900 | if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
901 | track(target, "has", key);
|
902 | }
|
903 | return result;
|
904 | }
|
905 | ownKeys(target) {
|
906 | track(
|
907 | target,
|
908 | "iterate",
|
909 | isArray(target) ? "length" : ITERATE_KEY
|
910 | );
|
911 | return Reflect.ownKeys(target);
|
912 | }
|
913 | }
|
914 | class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
915 | constructor(isShallow2 = false) {
|
916 | super(true, isShallow2);
|
917 | }
|
918 | set(target, key) {
|
919 | {
|
920 | warn$2(
|
921 | `Set operation on key "${String(key)}" failed: target is readonly.`,
|
922 | target
|
923 | );
|
924 | }
|
925 | return true;
|
926 | }
|
927 | deleteProperty(target, key) {
|
928 | {
|
929 | warn$2(
|
930 | `Delete operation on key "${String(key)}" failed: target is readonly.`,
|
931 | target
|
932 | );
|
933 | }
|
934 | return true;
|
935 | }
|
936 | }
|
937 | const mutableHandlers = new MutableReactiveHandler();
|
938 | const readonlyHandlers = new ReadonlyReactiveHandler();
|
939 | const shallowReactiveHandlers = new MutableReactiveHandler(
|
940 | true
|
941 | );
|
942 | const shallowReadonlyHandlers = new ReadonlyReactiveHandler(true);
|
943 |
|
944 | const toShallow = (value) => value;
|
945 | const getProto = (v) => Reflect.getPrototypeOf(v);
|
946 | function get(target, key, isReadonly = false, isShallow = false) {
|
947 | target = target["__v_raw"];
|
948 | const rawTarget = toRaw(target);
|
949 | const rawKey = toRaw(key);
|
950 | if (!isReadonly) {
|
951 | if (hasChanged(key, rawKey)) {
|
952 | track(rawTarget, "get", key);
|
953 | }
|
954 | track(rawTarget, "get", rawKey);
|
955 | }
|
956 | const { has: has2 } = getProto(rawTarget);
|
957 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
958 | if (has2.call(rawTarget, key)) {
|
959 | return wrap(target.get(key));
|
960 | } else if (has2.call(rawTarget, rawKey)) {
|
961 | return wrap(target.get(rawKey));
|
962 | } else if (target !== rawTarget) {
|
963 | target.get(key);
|
964 | }
|
965 | }
|
966 | function has(key, isReadonly = false) {
|
967 | const target = this["__v_raw"];
|
968 | const rawTarget = toRaw(target);
|
969 | const rawKey = toRaw(key);
|
970 | if (!isReadonly) {
|
971 | if (hasChanged(key, rawKey)) {
|
972 | track(rawTarget, "has", key);
|
973 | }
|
974 | track(rawTarget, "has", rawKey);
|
975 | }
|
976 | return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
977 | }
|
978 | function size(target, isReadonly = false) {
|
979 | target = target["__v_raw"];
|
980 | !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY);
|
981 | return Reflect.get(target, "size", target);
|
982 | }
|
983 | function add(value) {
|
984 | value = toRaw(value);
|
985 | const target = toRaw(this);
|
986 | const proto = getProto(target);
|
987 | const hadKey = proto.has.call(target, value);
|
988 | if (!hadKey) {
|
989 | target.add(value);
|
990 | trigger(target, "add", value, value);
|
991 | }
|
992 | return this;
|
993 | }
|
994 | function set(key, value) {
|
995 | value = toRaw(value);
|
996 | const target = toRaw(this);
|
997 | const { has: has2, get: get2 } = getProto(target);
|
998 | let hadKey = has2.call(target, key);
|
999 | if (!hadKey) {
|
1000 | key = toRaw(key);
|
1001 | hadKey = has2.call(target, key);
|
1002 | } else {
|
1003 | checkIdentityKeys(target, has2, key);
|
1004 | }
|
1005 | const oldValue = get2.call(target, key);
|
1006 | target.set(key, value);
|
1007 | if (!hadKey) {
|
1008 | trigger(target, "add", key, value);
|
1009 | } else if (hasChanged(value, oldValue)) {
|
1010 | trigger(target, "set", key, value, oldValue);
|
1011 | }
|
1012 | return this;
|
1013 | }
|
1014 | function deleteEntry(key) {
|
1015 | const target = toRaw(this);
|
1016 | const { has: has2, get: get2 } = getProto(target);
|
1017 | let hadKey = has2.call(target, key);
|
1018 | if (!hadKey) {
|
1019 | key = toRaw(key);
|
1020 | hadKey = has2.call(target, key);
|
1021 | } else {
|
1022 | checkIdentityKeys(target, has2, key);
|
1023 | }
|
1024 | const oldValue = get2 ? get2.call(target, key) : void 0;
|
1025 | const result = target.delete(key);
|
1026 | if (hadKey) {
|
1027 | trigger(target, "delete", key, void 0, oldValue);
|
1028 | }
|
1029 | return result;
|
1030 | }
|
1031 | function clear() {
|
1032 | const target = toRaw(this);
|
1033 | const hadItems = target.size !== 0;
|
1034 | const oldTarget = isMap(target) ? new Map(target) : new Set(target) ;
|
1035 | const result = target.clear();
|
1036 | if (hadItems) {
|
1037 | trigger(target, "clear", void 0, void 0, oldTarget);
|
1038 | }
|
1039 | return result;
|
1040 | }
|
1041 | function createForEach(isReadonly, isShallow) {
|
1042 | return function forEach(callback, thisArg) {
|
1043 | const observed = this;
|
1044 | const target = observed["__v_raw"];
|
1045 | const rawTarget = toRaw(target);
|
1046 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
1047 | !isReadonly && track(rawTarget, "iterate", ITERATE_KEY);
|
1048 | return target.forEach((value, key) => {
|
1049 | return callback.call(thisArg, wrap(value), wrap(key), observed);
|
1050 | });
|
1051 | };
|
1052 | }
|
1053 | function createIterableMethod(method, isReadonly, isShallow) {
|
1054 | return function(...args) {
|
1055 | const target = this["__v_raw"];
|
1056 | const rawTarget = toRaw(target);
|
1057 | const targetIsMap = isMap(rawTarget);
|
1058 | const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
1059 | const isKeyOnly = method === "keys" && targetIsMap;
|
1060 | const innerIterator = target[method](...args);
|
1061 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
1062 | !isReadonly && track(
|
1063 | rawTarget,
|
1064 | "iterate",
|
1065 | isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
1066 | );
|
1067 | return {
|
1068 |
|
1069 | next() {
|
1070 | const { value, done } = innerIterator.next();
|
1071 | return done ? { value, done } : {
|
1072 | value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
1073 | done
|
1074 | };
|
1075 | },
|
1076 |
|
1077 | [Symbol.iterator]() {
|
1078 | return this;
|
1079 | }
|
1080 | };
|
1081 | };
|
1082 | }
|
1083 | function createReadonlyMethod(type) {
|
1084 | return function(...args) {
|
1085 | {
|
1086 | const key = args[0] ? `on key "${args[0]}" ` : ``;
|
1087 | warn$2(
|
1088 | `${capitalize(type)} operation ${key}failed: target is readonly.`,
|
1089 | toRaw(this)
|
1090 | );
|
1091 | }
|
1092 | return type === "delete" ? false : type === "clear" ? void 0 : this;
|
1093 | };
|
1094 | }
|
1095 | function createInstrumentations() {
|
1096 | const mutableInstrumentations2 = {
|
1097 | get(key) {
|
1098 | return get(this, key);
|
1099 | },
|
1100 | get size() {
|
1101 | return size(this);
|
1102 | },
|
1103 | has,
|
1104 | add,
|
1105 | set,
|
1106 | delete: deleteEntry,
|
1107 | clear,
|
1108 | forEach: createForEach(false, false)
|
1109 | };
|
1110 | const shallowInstrumentations2 = {
|
1111 | get(key) {
|
1112 | return get(this, key, false, true);
|
1113 | },
|
1114 | get size() {
|
1115 | return size(this);
|
1116 | },
|
1117 | has,
|
1118 | add,
|
1119 | set,
|
1120 | delete: deleteEntry,
|
1121 | clear,
|
1122 | forEach: createForEach(false, true)
|
1123 | };
|
1124 | const readonlyInstrumentations2 = {
|
1125 | get(key) {
|
1126 | return get(this, key, true);
|
1127 | },
|
1128 | get size() {
|
1129 | return size(this, true);
|
1130 | },
|
1131 | has(key) {
|
1132 | return has.call(this, key, true);
|
1133 | },
|
1134 | add: createReadonlyMethod("add"),
|
1135 | set: createReadonlyMethod("set"),
|
1136 | delete: createReadonlyMethod("delete"),
|
1137 | clear: createReadonlyMethod("clear"),
|
1138 | forEach: createForEach(true, false)
|
1139 | };
|
1140 | const shallowReadonlyInstrumentations2 = {
|
1141 | get(key) {
|
1142 | return get(this, key, true, true);
|
1143 | },
|
1144 | get size() {
|
1145 | return size(this, true);
|
1146 | },
|
1147 | has(key) {
|
1148 | return has.call(this, key, true);
|
1149 | },
|
1150 | add: createReadonlyMethod("add"),
|
1151 | set: createReadonlyMethod("set"),
|
1152 | delete: createReadonlyMethod("delete"),
|
1153 | clear: createReadonlyMethod("clear"),
|
1154 | forEach: createForEach(true, true)
|
1155 | };
|
1156 | const iteratorMethods = [
|
1157 | "keys",
|
1158 | "values",
|
1159 | "entries",
|
1160 | Symbol.iterator
|
1161 | ];
|
1162 | iteratorMethods.forEach((method) => {
|
1163 | mutableInstrumentations2[method] = createIterableMethod(method, false, false);
|
1164 | readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
|
1165 | shallowInstrumentations2[method] = createIterableMethod(method, false, true);
|
1166 | shallowReadonlyInstrumentations2[method] = createIterableMethod(
|
1167 | method,
|
1168 | true,
|
1169 | true
|
1170 | );
|
1171 | });
|
1172 | return [
|
1173 | mutableInstrumentations2,
|
1174 | readonlyInstrumentations2,
|
1175 | shallowInstrumentations2,
|
1176 | shallowReadonlyInstrumentations2
|
1177 | ];
|
1178 | }
|
1179 | const [
|
1180 | mutableInstrumentations,
|
1181 | readonlyInstrumentations,
|
1182 | shallowInstrumentations,
|
1183 | shallowReadonlyInstrumentations
|
1184 | ] = createInstrumentations();
|
1185 | function createInstrumentationGetter(isReadonly, shallow) {
|
1186 | const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations;
|
1187 | return (target, key, receiver) => {
|
1188 | if (key === "__v_isReactive") {
|
1189 | return !isReadonly;
|
1190 | } else if (key === "__v_isReadonly") {
|
1191 | return isReadonly;
|
1192 | } else if (key === "__v_raw") {
|
1193 | return target;
|
1194 | }
|
1195 | return Reflect.get(
|
1196 | hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
1197 | key,
|
1198 | receiver
|
1199 | );
|
1200 | };
|
1201 | }
|
1202 | const mutableCollectionHandlers = {
|
1203 | get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
1204 | };
|
1205 | const shallowCollectionHandlers = {
|
1206 | get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
1207 | };
|
1208 | const readonlyCollectionHandlers = {
|
1209 | get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
1210 | };
|
1211 | const shallowReadonlyCollectionHandlers = {
|
1212 | get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
1213 | };
|
1214 | function checkIdentityKeys(target, has2, key) {
|
1215 | const rawKey = toRaw(key);
|
1216 | if (rawKey !== key && has2.call(target, rawKey)) {
|
1217 | const type = toRawType(target);
|
1218 | warn$2(
|
1219 | `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.`
|
1220 | );
|
1221 | }
|
1222 | }
|
1223 |
|
1224 | const reactiveMap = new WeakMap();
|
1225 | const shallowReactiveMap = new WeakMap();
|
1226 | const readonlyMap = new WeakMap();
|
1227 | const shallowReadonlyMap = new WeakMap();
|
1228 | function targetTypeMap(rawType) {
|
1229 | switch (rawType) {
|
1230 | case "Object":
|
1231 | case "Array":
|
1232 | return 1 ;
|
1233 | case "Map":
|
1234 | case "Set":
|
1235 | case "WeakMap":
|
1236 | case "WeakSet":
|
1237 | return 2 ;
|
1238 | default:
|
1239 | return 0 ;
|
1240 | }
|
1241 | }
|
1242 | function getTargetType(value) {
|
1243 | return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
1244 | }
|
1245 | function reactive(target) {
|
1246 | if (isReadonly(target)) {
|
1247 | return target;
|
1248 | }
|
1249 | return createReactiveObject(
|
1250 | target,
|
1251 | false,
|
1252 | mutableHandlers,
|
1253 | mutableCollectionHandlers,
|
1254 | reactiveMap
|
1255 | );
|
1256 | }
|
1257 | function shallowReactive(target) {
|
1258 | return createReactiveObject(
|
1259 | target,
|
1260 | false,
|
1261 | shallowReactiveHandlers,
|
1262 | shallowCollectionHandlers,
|
1263 | shallowReactiveMap
|
1264 | );
|
1265 | }
|
1266 | function readonly(target) {
|
1267 | return createReactiveObject(
|
1268 | target,
|
1269 | true,
|
1270 | readonlyHandlers,
|
1271 | readonlyCollectionHandlers,
|
1272 | readonlyMap
|
1273 | );
|
1274 | }
|
1275 | function shallowReadonly(target) {
|
1276 | return createReactiveObject(
|
1277 | target,
|
1278 | true,
|
1279 | shallowReadonlyHandlers,
|
1280 | shallowReadonlyCollectionHandlers,
|
1281 | shallowReadonlyMap
|
1282 | );
|
1283 | }
|
1284 | function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
1285 | if (!isObject(target)) {
|
1286 | {
|
1287 | warn$2(`value cannot be made reactive: ${String(target)}`);
|
1288 | }
|
1289 | return target;
|
1290 | }
|
1291 | if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
1292 | return target;
|
1293 | }
|
1294 | const existingProxy = proxyMap.get(target);
|
1295 | if (existingProxy) {
|
1296 | return existingProxy;
|
1297 | }
|
1298 | const targetType = getTargetType(target);
|
1299 | if (targetType === 0 ) {
|
1300 | return target;
|
1301 | }
|
1302 | const proxy = new Proxy(
|
1303 | target,
|
1304 | targetType === 2 ? collectionHandlers : baseHandlers
|
1305 | );
|
1306 | proxyMap.set(target, proxy);
|
1307 | return proxy;
|
1308 | }
|
1309 | function isReactive(value) {
|
1310 | if (isReadonly(value)) {
|
1311 | return isReactive(value["__v_raw"]);
|
1312 | }
|
1313 | return !!(value && value["__v_isReactive"]);
|
1314 | }
|
1315 | function isReadonly(value) {
|
1316 | return !!(value && value["__v_isReadonly"]);
|
1317 | }
|
1318 | function isShallow(value) {
|
1319 | return !!(value && value["__v_isShallow"]);
|
1320 | }
|
1321 | function isProxy(value) {
|
1322 | return value ? !!value["__v_raw"] : false;
|
1323 | }
|
1324 | function toRaw(observed) {
|
1325 | const raw = observed && observed["__v_raw"];
|
1326 | return raw ? toRaw(raw) : observed;
|
1327 | }
|
1328 | function markRaw(value) {
|
1329 | if (Object.isExtensible(value)) {
|
1330 | def(value, "__v_skip", true);
|
1331 | }
|
1332 | return value;
|
1333 | }
|
1334 | const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
1335 | const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
1336 |
|
1337 | 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`;
|
1338 | class ComputedRefImpl {
|
1339 | constructor(getter, _setter, isReadonly, isSSR) {
|
1340 | this.getter = getter;
|
1341 | this._setter = _setter;
|
1342 | this.dep = void 0;
|
1343 | this.__v_isRef = true;
|
1344 | this["__v_isReadonly"] = false;
|
1345 | this.effect = new ReactiveEffect(
|
1346 | () => getter(this._value),
|
1347 | () => triggerRefValue(
|
1348 | this,
|
1349 | this.effect._dirtyLevel === 2 ? 2 : 3
|
1350 | )
|
1351 | );
|
1352 | this.effect.computed = this;
|
1353 | this.effect.active = this._cacheable = !isSSR;
|
1354 | this["__v_isReadonly"] = isReadonly;
|
1355 | }
|
1356 | get value() {
|
1357 | const self = toRaw(this);
|
1358 | if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
|
1359 | triggerRefValue(self, 4);
|
1360 | }
|
1361 | trackRefValue(self);
|
1362 | if (self.effect._dirtyLevel >= 2) {
|
1363 | if (this._warnRecursive) {
|
1364 | warn$2(COMPUTED_SIDE_EFFECT_WARN, `
|
1365 |
|
1366 | getter: `, this.getter);
|
1367 | }
|
1368 | triggerRefValue(self, 2);
|
1369 | }
|
1370 | return self._value;
|
1371 | }
|
1372 | set value(newValue) {
|
1373 | this._setter(newValue);
|
1374 | }
|
1375 |
|
1376 | get _dirty() {
|
1377 | return this.effect.dirty;
|
1378 | }
|
1379 | set _dirty(v) {
|
1380 | this.effect.dirty = v;
|
1381 | }
|
1382 |
|
1383 | }
|
1384 | function computed$1(getterOrOptions, debugOptions, isSSR = false) {
|
1385 | let getter;
|
1386 | let setter;
|
1387 | const onlyGetter = isFunction(getterOrOptions);
|
1388 | if (onlyGetter) {
|
1389 | getter = getterOrOptions;
|
1390 | setter = () => {
|
1391 | warn$2("Write operation failed: computed value is readonly");
|
1392 | } ;
|
1393 | } else {
|
1394 | getter = getterOrOptions.get;
|
1395 | setter = getterOrOptions.set;
|
1396 | }
|
1397 | const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
1398 | if (debugOptions && !isSSR) {
|
1399 | cRef.effect.onTrack = debugOptions.onTrack;
|
1400 | cRef.effect.onTrigger = debugOptions.onTrigger;
|
1401 | }
|
1402 | return cRef;
|
1403 | }
|
1404 |
|
1405 | function trackRefValue(ref2) {
|
1406 | var _a;
|
1407 | if (shouldTrack && activeEffect) {
|
1408 | ref2 = toRaw(ref2);
|
1409 | trackEffect(
|
1410 | activeEffect,
|
1411 | (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
|
1412 | () => ref2.dep = void 0,
|
1413 | ref2 instanceof ComputedRefImpl ? ref2 : void 0
|
1414 | ),
|
1415 | {
|
1416 | target: ref2,
|
1417 | type: "get",
|
1418 | key: "value"
|
1419 | }
|
1420 | );
|
1421 | }
|
1422 | }
|
1423 | function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
|
1424 | ref2 = toRaw(ref2);
|
1425 | const dep = ref2.dep;
|
1426 | if (dep) {
|
1427 | triggerEffects(
|
1428 | dep,
|
1429 | dirtyLevel,
|
1430 | {
|
1431 | target: ref2,
|
1432 | type: "set",
|
1433 | key: "value",
|
1434 | newValue: newVal
|
1435 | }
|
1436 | );
|
1437 | }
|
1438 | }
|
1439 | function isRef(r) {
|
1440 | return !!(r && r.__v_isRef === true);
|
1441 | }
|
1442 | function ref(value) {
|
1443 | return createRef(value, false);
|
1444 | }
|
1445 | function shallowRef(value) {
|
1446 | return createRef(value, true);
|
1447 | }
|
1448 | function createRef(rawValue, shallow) {
|
1449 | if (isRef(rawValue)) {
|
1450 | return rawValue;
|
1451 | }
|
1452 | return new RefImpl(rawValue, shallow);
|
1453 | }
|
1454 | class RefImpl {
|
1455 | constructor(value, __v_isShallow) {
|
1456 | this.__v_isShallow = __v_isShallow;
|
1457 | this.dep = void 0;
|
1458 | this.__v_isRef = true;
|
1459 | this._rawValue = __v_isShallow ? value : toRaw(value);
|
1460 | this._value = __v_isShallow ? value : toReactive(value);
|
1461 | }
|
1462 | get value() {
|
1463 | trackRefValue(this);
|
1464 | return this._value;
|
1465 | }
|
1466 | set value(newVal) {
|
1467 | const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
|
1468 | newVal = useDirectValue ? newVal : toRaw(newVal);
|
1469 | if (hasChanged(newVal, this._rawValue)) {
|
1470 | this._rawValue = newVal;
|
1471 | this._value = useDirectValue ? newVal : toReactive(newVal);
|
1472 | triggerRefValue(this, 4, newVal);
|
1473 | }
|
1474 | }
|
1475 | }
|
1476 | function triggerRef(ref2) {
|
1477 | triggerRefValue(ref2, 4, ref2.value );
|
1478 | }
|
1479 | function unref(ref2) {
|
1480 | return isRef(ref2) ? ref2.value : ref2;
|
1481 | }
|
1482 | function toValue(source) {
|
1483 | return isFunction(source) ? source() : unref(source);
|
1484 | }
|
1485 | const shallowUnwrapHandlers = {
|
1486 | get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
1487 | set: (target, key, value, receiver) => {
|
1488 | const oldValue = target[key];
|
1489 | if (isRef(oldValue) && !isRef(value)) {
|
1490 | oldValue.value = value;
|
1491 | return true;
|
1492 | } else {
|
1493 | return Reflect.set(target, key, value, receiver);
|
1494 | }
|
1495 | }
|
1496 | };
|
1497 | function proxyRefs(objectWithRefs) {
|
1498 | return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
1499 | }
|
1500 | class CustomRefImpl {
|
1501 | constructor(factory) {
|
1502 | this.dep = void 0;
|
1503 | this.__v_isRef = true;
|
1504 | const { get, set } = factory(
|
1505 | () => trackRefValue(this),
|
1506 | () => triggerRefValue(this)
|
1507 | );
|
1508 | this._get = get;
|
1509 | this._set = set;
|
1510 | }
|
1511 | get value() {
|
1512 | return this._get();
|
1513 | }
|
1514 | set value(newVal) {
|
1515 | this._set(newVal);
|
1516 | }
|
1517 | }
|
1518 | function customRef(factory) {
|
1519 | return new CustomRefImpl(factory);
|
1520 | }
|
1521 | function toRefs(object) {
|
1522 | if (!isProxy(object)) {
|
1523 | warn$2(`toRefs() expects a reactive object but received a plain one.`);
|
1524 | }
|
1525 | const ret = isArray(object) ? new Array(object.length) : {};
|
1526 | for (const key in object) {
|
1527 | ret[key] = propertyToRef(object, key);
|
1528 | }
|
1529 | return ret;
|
1530 | }
|
1531 | class ObjectRefImpl {
|
1532 | constructor(_object, _key, _defaultValue) {
|
1533 | this._object = _object;
|
1534 | this._key = _key;
|
1535 | this._defaultValue = _defaultValue;
|
1536 | this.__v_isRef = true;
|
1537 | }
|
1538 | get value() {
|
1539 | const val = this._object[this._key];
|
1540 | return val === void 0 ? this._defaultValue : val;
|
1541 | }
|
1542 | set value(newVal) {
|
1543 | this._object[this._key] = newVal;
|
1544 | }
|
1545 | get dep() {
|
1546 | return getDepFromReactive(toRaw(this._object), this._key);
|
1547 | }
|
1548 | }
|
1549 | class GetterRefImpl {
|
1550 | constructor(_getter) {
|
1551 | this._getter = _getter;
|
1552 | this.__v_isRef = true;
|
1553 | this.__v_isReadonly = true;
|
1554 | }
|
1555 | get value() {
|
1556 | return this._getter();
|
1557 | }
|
1558 | }
|
1559 | function toRef(source, key, defaultValue) {
|
1560 | if (isRef(source)) {
|
1561 | return source;
|
1562 | } else if (isFunction(source)) {
|
1563 | return new GetterRefImpl(source);
|
1564 | } else if (isObject(source) && arguments.length > 1) {
|
1565 | return propertyToRef(source, key, defaultValue);
|
1566 | } else {
|
1567 | return ref(source);
|
1568 | }
|
1569 | }
|
1570 | function propertyToRef(source, key, defaultValue) {
|
1571 | const val = source[key];
|
1572 | return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
1573 | }
|
1574 |
|
1575 | const TrackOpTypes = {
|
1576 | "GET": "get",
|
1577 | "HAS": "has",
|
1578 | "ITERATE": "iterate"
|
1579 | };
|
1580 | const TriggerOpTypes = {
|
1581 | "SET": "set",
|
1582 | "ADD": "add",
|
1583 | "DELETE": "delete",
|
1584 | "CLEAR": "clear"
|
1585 | };
|
1586 |
|
1587 | const stack$1 = [];
|
1588 | function pushWarningContext(vnode) {
|
1589 | stack$1.push(vnode);
|
1590 | }
|
1591 | function popWarningContext() {
|
1592 | stack$1.pop();
|
1593 | }
|
1594 | function warn$1(msg, ...args) {
|
1595 | pauseTracking();
|
1596 | const instance = stack$1.length ? stack$1[stack$1.length - 1].component : null;
|
1597 | const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
1598 | const trace = getComponentTrace();
|
1599 | if (appWarnHandler) {
|
1600 | callWithErrorHandling(
|
1601 | appWarnHandler,
|
1602 | instance,
|
1603 | 11,
|
1604 | [
|
1605 | msg + args.map((a) => {
|
1606 | var _a, _b;
|
1607 | return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
|
1608 | }).join(""),
|
1609 | instance && instance.proxy,
|
1610 | trace.map(
|
1611 | ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
|
1612 | ).join("\n"),
|
1613 | trace
|
1614 | ]
|
1615 | );
|
1616 | } else {
|
1617 | const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
1618 | if (trace.length &&
|
1619 | true) {
|
1620 | warnArgs.push(`
|
1621 | `, ...formatTrace(trace));
|
1622 | }
|
1623 | console.warn(...warnArgs);
|
1624 | }
|
1625 | resetTracking();
|
1626 | }
|
1627 | function getComponentTrace() {
|
1628 | let currentVNode = stack$1[stack$1.length - 1];
|
1629 | if (!currentVNode) {
|
1630 | return [];
|
1631 | }
|
1632 | const normalizedStack = [];
|
1633 | while (currentVNode) {
|
1634 | const last = normalizedStack[0];
|
1635 | if (last && last.vnode === currentVNode) {
|
1636 | last.recurseCount++;
|
1637 | } else {
|
1638 | normalizedStack.push({
|
1639 | vnode: currentVNode,
|
1640 | recurseCount: 0
|
1641 | });
|
1642 | }
|
1643 | const parentInstance = currentVNode.component && currentVNode.component.parent;
|
1644 | currentVNode = parentInstance && parentInstance.vnode;
|
1645 | }
|
1646 | return normalizedStack;
|
1647 | }
|
1648 | function formatTrace(trace) {
|
1649 | const logs = [];
|
1650 | trace.forEach((entry, i) => {
|
1651 | logs.push(...i === 0 ? [] : [`
|
1652 | `], ...formatTraceEntry(entry));
|
1653 | });
|
1654 | return logs;
|
1655 | }
|
1656 | function formatTraceEntry({ vnode, recurseCount }) {
|
1657 | const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
1658 | const isRoot = vnode.component ? vnode.component.parent == null : false;
|
1659 | const open = ` at <${formatComponentName(
|
1660 | vnode.component,
|
1661 | vnode.type,
|
1662 | isRoot
|
1663 | )}`;
|
1664 | const close = `>` + postfix;
|
1665 | return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
|
1666 | }
|
1667 | function formatProps(props) {
|
1668 | const res = [];
|
1669 | const keys = Object.keys(props);
|
1670 | keys.slice(0, 3).forEach((key) => {
|
1671 | res.push(...formatProp(key, props[key]));
|
1672 | });
|
1673 | if (keys.length > 3) {
|
1674 | res.push(` ...`);
|
1675 | }
|
1676 | return res;
|
1677 | }
|
1678 | function formatProp(key, value, raw) {
|
1679 | if (isString(value)) {
|
1680 | value = JSON.stringify(value);
|
1681 | return raw ? value : [`${key}=${value}`];
|
1682 | } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
1683 | return raw ? value : [`${key}=${value}`];
|
1684 | } else if (isRef(value)) {
|
1685 | value = formatProp(key, toRaw(value.value), true);
|
1686 | return raw ? value : [`${key}=Ref<`, value, `>`];
|
1687 | } else if (isFunction(value)) {
|
1688 | return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
1689 | } else {
|
1690 | value = toRaw(value);
|
1691 | return raw ? value : [`${key}=`, value];
|
1692 | }
|
1693 | }
|
1694 | function assertNumber(val, type) {
|
1695 | if (val === void 0) {
|
1696 | return;
|
1697 | } else if (typeof val !== "number") {
|
1698 | warn$1(`${type} is not a valid number - got ${JSON.stringify(val)}.`);
|
1699 | } else if (isNaN(val)) {
|
1700 | warn$1(`${type} is NaN - the duration expression might be incorrect.`);
|
1701 | }
|
1702 | }
|
1703 |
|
1704 | const ErrorCodes = {
|
1705 | "SETUP_FUNCTION": 0,
|
1706 | "0": "SETUP_FUNCTION",
|
1707 | "RENDER_FUNCTION": 1,
|
1708 | "1": "RENDER_FUNCTION",
|
1709 | "WATCH_GETTER": 2,
|
1710 | "2": "WATCH_GETTER",
|
1711 | "WATCH_CALLBACK": 3,
|
1712 | "3": "WATCH_CALLBACK",
|
1713 | "WATCH_CLEANUP": 4,
|
1714 | "4": "WATCH_CLEANUP",
|
1715 | "NATIVE_EVENT_HANDLER": 5,
|
1716 | "5": "NATIVE_EVENT_HANDLER",
|
1717 | "COMPONENT_EVENT_HANDLER": 6,
|
1718 | "6": "COMPONENT_EVENT_HANDLER",
|
1719 | "VNODE_HOOK": 7,
|
1720 | "7": "VNODE_HOOK",
|
1721 | "DIRECTIVE_HOOK": 8,
|
1722 | "8": "DIRECTIVE_HOOK",
|
1723 | "TRANSITION_HOOK": 9,
|
1724 | "9": "TRANSITION_HOOK",
|
1725 | "APP_ERROR_HANDLER": 10,
|
1726 | "10": "APP_ERROR_HANDLER",
|
1727 | "APP_WARN_HANDLER": 11,
|
1728 | "11": "APP_WARN_HANDLER",
|
1729 | "FUNCTION_REF": 12,
|
1730 | "12": "FUNCTION_REF",
|
1731 | "ASYNC_COMPONENT_LOADER": 13,
|
1732 | "13": "ASYNC_COMPONENT_LOADER",
|
1733 | "SCHEDULER": 14,
|
1734 | "14": "SCHEDULER"
|
1735 | };
|
1736 | const ErrorTypeStrings$1 = {
|
1737 | ["sp"]: "serverPrefetch hook",
|
1738 | ["bc"]: "beforeCreate hook",
|
1739 | ["c"]: "created hook",
|
1740 | ["bm"]: "beforeMount hook",
|
1741 | ["m"]: "mounted hook",
|
1742 | ["bu"]: "beforeUpdate hook",
|
1743 | ["u"]: "updated",
|
1744 | ["bum"]: "beforeUnmount hook",
|
1745 | ["um"]: "unmounted hook",
|
1746 | ["a"]: "activated hook",
|
1747 | ["da"]: "deactivated hook",
|
1748 | ["ec"]: "errorCaptured hook",
|
1749 | ["rtc"]: "renderTracked hook",
|
1750 | ["rtg"]: "renderTriggered hook",
|
1751 | [0]: "setup function",
|
1752 | [1]: "render function",
|
1753 | [2]: "watcher getter",
|
1754 | [3]: "watcher callback",
|
1755 | [4]: "watcher cleanup function",
|
1756 | [5]: "native event handler",
|
1757 | [6]: "component event handler",
|
1758 | [7]: "vnode hook",
|
1759 | [8]: "directive hook",
|
1760 | [9]: "transition hook",
|
1761 | [10]: "app errorHandler",
|
1762 | [11]: "app warnHandler",
|
1763 | [12]: "ref function",
|
1764 | [13]: "async component loader",
|
1765 | [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
|
1766 | };
|
1767 | function callWithErrorHandling(fn, instance, type, args) {
|
1768 | try {
|
1769 | return args ? fn(...args) : fn();
|
1770 | } catch (err) {
|
1771 | handleError(err, instance, type);
|
1772 | }
|
1773 | }
|
1774 | function callWithAsyncErrorHandling(fn, instance, type, args) {
|
1775 | if (isFunction(fn)) {
|
1776 | const res = callWithErrorHandling(fn, instance, type, args);
|
1777 | if (res && isPromise(res)) {
|
1778 | res.catch((err) => {
|
1779 | handleError(err, instance, type);
|
1780 | });
|
1781 | }
|
1782 | return res;
|
1783 | }
|
1784 | if (isArray(fn)) {
|
1785 | const values = [];
|
1786 | for (let i = 0; i < fn.length; i++) {
|
1787 | values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
1788 | }
|
1789 | return values;
|
1790 | } else {
|
1791 | warn$1(
|
1792 | `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`
|
1793 | );
|
1794 | }
|
1795 | }
|
1796 | function handleError(err, instance, type, throwInDev = true) {
|
1797 | const contextVNode = instance ? instance.vnode : null;
|
1798 | if (instance) {
|
1799 | let cur = instance.parent;
|
1800 | const exposedInstance = instance.proxy;
|
1801 | const errorInfo = ErrorTypeStrings$1[type] ;
|
1802 | while (cur) {
|
1803 | const errorCapturedHooks = cur.ec;
|
1804 | if (errorCapturedHooks) {
|
1805 | for (let i = 0; i < errorCapturedHooks.length; i++) {
|
1806 | if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
1807 | return;
|
1808 | }
|
1809 | }
|
1810 | }
|
1811 | cur = cur.parent;
|
1812 | }
|
1813 | const appErrorHandler = instance.appContext.config.errorHandler;
|
1814 | if (appErrorHandler) {
|
1815 | pauseTracking();
|
1816 | callWithErrorHandling(
|
1817 | appErrorHandler,
|
1818 | null,
|
1819 | 10,
|
1820 | [err, exposedInstance, errorInfo]
|
1821 | );
|
1822 | resetTracking();
|
1823 | return;
|
1824 | }
|
1825 | }
|
1826 | logError(err, type, contextVNode, throwInDev);
|
1827 | }
|
1828 | function logError(err, type, contextVNode, throwInDev = true) {
|
1829 | {
|
1830 | const info = ErrorTypeStrings$1[type];
|
1831 | if (contextVNode) {
|
1832 | pushWarningContext(contextVNode);
|
1833 | }
|
1834 | warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
1835 | if (contextVNode) {
|
1836 | popWarningContext();
|
1837 | }
|
1838 | if (throwInDev) {
|
1839 | throw err;
|
1840 | } else {
|
1841 | console.error(err);
|
1842 | }
|
1843 | }
|
1844 | }
|
1845 |
|
1846 | let isFlushing = false;
|
1847 | let isFlushPending = false;
|
1848 | const queue = [];
|
1849 | let flushIndex = 0;
|
1850 | const pendingPostFlushCbs = [];
|
1851 | let activePostFlushCbs = null;
|
1852 | let postFlushIndex = 0;
|
1853 | const resolvedPromise = Promise.resolve();
|
1854 | let currentFlushPromise = null;
|
1855 | const RECURSION_LIMIT = 100;
|
1856 | function nextTick(fn) {
|
1857 | const p = currentFlushPromise || resolvedPromise;
|
1858 | return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
1859 | }
|
1860 | function findInsertionIndex(id) {
|
1861 | let start = flushIndex + 1;
|
1862 | let end = queue.length;
|
1863 | while (start < end) {
|
1864 | const middle = start + end >>> 1;
|
1865 | const middleJob = queue[middle];
|
1866 | const middleJobId = getId(middleJob);
|
1867 | if (middleJobId < id || middleJobId === id && middleJob.pre) {
|
1868 | start = middle + 1;
|
1869 | } else {
|
1870 | end = middle;
|
1871 | }
|
1872 | }
|
1873 | return start;
|
1874 | }
|
1875 | function queueJob(job) {
|
1876 | if (!queue.length || !queue.includes(
|
1877 | job,
|
1878 | isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
|
1879 | )) {
|
1880 | if (job.id == null) {
|
1881 | queue.push(job);
|
1882 | } else {
|
1883 | queue.splice(findInsertionIndex(job.id), 0, job);
|
1884 | }
|
1885 | queueFlush();
|
1886 | }
|
1887 | }
|
1888 | function queueFlush() {
|
1889 | if (!isFlushing && !isFlushPending) {
|
1890 | isFlushPending = true;
|
1891 | currentFlushPromise = resolvedPromise.then(flushJobs);
|
1892 | }
|
1893 | }
|
1894 | function invalidateJob(job) {
|
1895 | const i = queue.indexOf(job);
|
1896 | if (i > flushIndex) {
|
1897 | queue.splice(i, 1);
|
1898 | }
|
1899 | }
|
1900 | function queuePostFlushCb(cb) {
|
1901 | if (!isArray(cb)) {
|
1902 | if (!activePostFlushCbs || !activePostFlushCbs.includes(
|
1903 | cb,
|
1904 | cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
|
1905 | )) {
|
1906 | pendingPostFlushCbs.push(cb);
|
1907 | }
|
1908 | } else {
|
1909 | pendingPostFlushCbs.push(...cb);
|
1910 | }
|
1911 | queueFlush();
|
1912 | }
|
1913 | function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
|
1914 | {
|
1915 | seen = seen || new Map();
|
1916 | }
|
1917 | for (; i < queue.length; i++) {
|
1918 | const cb = queue[i];
|
1919 | if (cb && cb.pre) {
|
1920 | if (instance && cb.id !== instance.uid) {
|
1921 | continue;
|
1922 | }
|
1923 | if (checkRecursiveUpdates(seen, cb)) {
|
1924 | continue;
|
1925 | }
|
1926 | queue.splice(i, 1);
|
1927 | i--;
|
1928 | cb();
|
1929 | }
|
1930 | }
|
1931 | }
|
1932 | function flushPostFlushCbs(seen) {
|
1933 | if (pendingPostFlushCbs.length) {
|
1934 | const deduped = [...new Set(pendingPostFlushCbs)].sort(
|
1935 | (a, b) => getId(a) - getId(b)
|
1936 | );
|
1937 | pendingPostFlushCbs.length = 0;
|
1938 | if (activePostFlushCbs) {
|
1939 | activePostFlushCbs.push(...deduped);
|
1940 | return;
|
1941 | }
|
1942 | activePostFlushCbs = deduped;
|
1943 | {
|
1944 | seen = seen || new Map();
|
1945 | }
|
1946 | for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
1947 | if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
|
1948 | continue;
|
1949 | }
|
1950 | activePostFlushCbs[postFlushIndex]();
|
1951 | }
|
1952 | activePostFlushCbs = null;
|
1953 | postFlushIndex = 0;
|
1954 | }
|
1955 | }
|
1956 | const getId = (job) => job.id == null ? Infinity : job.id;
|
1957 | const comparator = (a, b) => {
|
1958 | const diff = getId(a) - getId(b);
|
1959 | if (diff === 0) {
|
1960 | if (a.pre && !b.pre)
|
1961 | return -1;
|
1962 | if (b.pre && !a.pre)
|
1963 | return 1;
|
1964 | }
|
1965 | return diff;
|
1966 | };
|
1967 | function flushJobs(seen) {
|
1968 | isFlushPending = false;
|
1969 | isFlushing = true;
|
1970 | {
|
1971 | seen = seen || new Map();
|
1972 | }
|
1973 | queue.sort(comparator);
|
1974 | const check = (job) => checkRecursiveUpdates(seen, job) ;
|
1975 | try {
|
1976 | for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
1977 | const job = queue[flushIndex];
|
1978 | if (job && job.active !== false) {
|
1979 | if (check(job)) {
|
1980 | continue;
|
1981 | }
|
1982 | callWithErrorHandling(job, null, 14);
|
1983 | }
|
1984 | }
|
1985 | } finally {
|
1986 | flushIndex = 0;
|
1987 | queue.length = 0;
|
1988 | flushPostFlushCbs(seen);
|
1989 | isFlushing = false;
|
1990 | currentFlushPromise = null;
|
1991 | if (queue.length || pendingPostFlushCbs.length) {
|
1992 | flushJobs(seen);
|
1993 | }
|
1994 | }
|
1995 | }
|
1996 | function checkRecursiveUpdates(seen, fn) {
|
1997 | if (!seen.has(fn)) {
|
1998 | seen.set(fn, 1);
|
1999 | } else {
|
2000 | const count = seen.get(fn);
|
2001 | if (count > RECURSION_LIMIT) {
|
2002 | const instance = fn.ownerInstance;
|
2003 | const componentName = instance && getComponentName(instance.type);
|
2004 | handleError(
|
2005 | `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.`,
|
2006 | null,
|
2007 | 10
|
2008 | );
|
2009 | return true;
|
2010 | } else {
|
2011 | seen.set(fn, count + 1);
|
2012 | }
|
2013 | }
|
2014 | }
|
2015 |
|
2016 | let isHmrUpdating = false;
|
2017 | const hmrDirtyComponents = new Set();
|
2018 | {
|
2019 | getGlobalThis().__VUE_HMR_RUNTIME__ = {
|
2020 | createRecord: tryWrap(createRecord),
|
2021 | rerender: tryWrap(rerender),
|
2022 | reload: tryWrap(reload)
|
2023 | };
|
2024 | }
|
2025 | const map = new Map();
|
2026 | function registerHMR(instance) {
|
2027 | const id = instance.type.__hmrId;
|
2028 | let record = map.get(id);
|
2029 | if (!record) {
|
2030 | createRecord(id, instance.type);
|
2031 | record = map.get(id);
|
2032 | }
|
2033 | record.instances.add(instance);
|
2034 | }
|
2035 | function unregisterHMR(instance) {
|
2036 | map.get(instance.type.__hmrId).instances.delete(instance);
|
2037 | }
|
2038 | function createRecord(id, initialDef) {
|
2039 | if (map.has(id)) {
|
2040 | return false;
|
2041 | }
|
2042 | map.set(id, {
|
2043 | initialDef: normalizeClassComponent(initialDef),
|
2044 | instances: new Set()
|
2045 | });
|
2046 | return true;
|
2047 | }
|
2048 | function normalizeClassComponent(component) {
|
2049 | return isClassComponent(component) ? component.__vccOpts : component;
|
2050 | }
|
2051 | function rerender(id, newRender) {
|
2052 | const record = map.get(id);
|
2053 | if (!record) {
|
2054 | return;
|
2055 | }
|
2056 | record.initialDef.render = newRender;
|
2057 | [...record.instances].forEach((instance) => {
|
2058 | if (newRender) {
|
2059 | instance.render = newRender;
|
2060 | normalizeClassComponent(instance.type).render = newRender;
|
2061 | }
|
2062 | instance.renderCache = [];
|
2063 | isHmrUpdating = true;
|
2064 | instance.effect.dirty = true;
|
2065 | instance.update();
|
2066 | isHmrUpdating = false;
|
2067 | });
|
2068 | }
|
2069 | function reload(id, newComp) {
|
2070 | const record = map.get(id);
|
2071 | if (!record)
|
2072 | return;
|
2073 | newComp = normalizeClassComponent(newComp);
|
2074 | updateComponentDef(record.initialDef, newComp);
|
2075 | const instances = [...record.instances];
|
2076 | for (const instance of instances) {
|
2077 | const oldComp = normalizeClassComponent(instance.type);
|
2078 | if (!hmrDirtyComponents.has(oldComp)) {
|
2079 | if (oldComp !== record.initialDef) {
|
2080 | updateComponentDef(oldComp, newComp);
|
2081 | }
|
2082 | hmrDirtyComponents.add(oldComp);
|
2083 | }
|
2084 | instance.appContext.propsCache.delete(instance.type);
|
2085 | instance.appContext.emitsCache.delete(instance.type);
|
2086 | instance.appContext.optionsCache.delete(instance.type);
|
2087 | if (instance.ceReload) {
|
2088 | hmrDirtyComponents.add(oldComp);
|
2089 | instance.ceReload(newComp.styles);
|
2090 | hmrDirtyComponents.delete(oldComp);
|
2091 | } else if (instance.parent) {
|
2092 | instance.parent.effect.dirty = true;
|
2093 | queueJob(instance.parent.update);
|
2094 | } else if (instance.appContext.reload) {
|
2095 | instance.appContext.reload();
|
2096 | } else if (typeof window !== "undefined") {
|
2097 | window.location.reload();
|
2098 | } else {
|
2099 | console.warn(
|
2100 | "[HMR] Root or manually mounted instance modified. Full reload required."
|
2101 | );
|
2102 | }
|
2103 | }
|
2104 | queuePostFlushCb(() => {
|
2105 | for (const instance of instances) {
|
2106 | hmrDirtyComponents.delete(
|
2107 | normalizeClassComponent(instance.type)
|
2108 | );
|
2109 | }
|
2110 | });
|
2111 | }
|
2112 | function updateComponentDef(oldComp, newComp) {
|
2113 | extend(oldComp, newComp);
|
2114 | for (const key in oldComp) {
|
2115 | if (key !== "__file" && !(key in newComp)) {
|
2116 | delete oldComp[key];
|
2117 | }
|
2118 | }
|
2119 | }
|
2120 | function tryWrap(fn) {
|
2121 | return (id, arg) => {
|
2122 | try {
|
2123 | return fn(id, arg);
|
2124 | } catch (e) {
|
2125 | console.error(e);
|
2126 | console.warn(
|
2127 | `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
|
2128 | );
|
2129 | }
|
2130 | };
|
2131 | }
|
2132 |
|
2133 | let devtools$1;
|
2134 | let buffer = [];
|
2135 | let devtoolsNotInstalled = false;
|
2136 | function emit$1(event, ...args) {
|
2137 | if (devtools$1) {
|
2138 | devtools$1.emit(event, ...args);
|
2139 | } else if (!devtoolsNotInstalled) {
|
2140 | buffer.push({ event, args });
|
2141 | }
|
2142 | }
|
2143 | function setDevtoolsHook$1(hook, target) {
|
2144 | var _a, _b;
|
2145 | devtools$1 = hook;
|
2146 | if (devtools$1) {
|
2147 | devtools$1.enabled = true;
|
2148 | buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args));
|
2149 | buffer = [];
|
2150 | } else if (
|
2151 |
|
2152 |
|
2153 |
|
2154 | typeof window !== "undefined" &&
|
2155 | window.HTMLElement &&
|
2156 | !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
|
2157 | ) {
|
2158 | const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
|
2159 | replay.push((newHook) => {
|
2160 | setDevtoolsHook$1(newHook, target);
|
2161 | });
|
2162 | setTimeout(() => {
|
2163 | if (!devtools$1) {
|
2164 | target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
|
2165 | devtoolsNotInstalled = true;
|
2166 | buffer = [];
|
2167 | }
|
2168 | }, 3e3);
|
2169 | } else {
|
2170 | devtoolsNotInstalled = true;
|
2171 | buffer = [];
|
2172 | }
|
2173 | }
|
2174 | function devtoolsInitApp(app, version) {
|
2175 | emit$1("app:init" , app, version, {
|
2176 | Fragment,
|
2177 | Text,
|
2178 | Comment,
|
2179 | Static
|
2180 | });
|
2181 | }
|
2182 | function devtoolsUnmountApp(app) {
|
2183 | emit$1("app:unmount" , app);
|
2184 | }
|
2185 | const devtoolsComponentAdded = createDevtoolsComponentHook(
|
2186 | "component:added"
|
2187 | );
|
2188 | const devtoolsComponentUpdated = createDevtoolsComponentHook("component:updated" );
|
2189 | const _devtoolsComponentRemoved = createDevtoolsComponentHook(
|
2190 | "component:removed"
|
2191 | );
|
2192 | const devtoolsComponentRemoved = (component) => {
|
2193 | if (devtools$1 && typeof devtools$1.cleanupBuffer === "function" &&
|
2194 | !devtools$1.cleanupBuffer(component)) {
|
2195 | _devtoolsComponentRemoved(component);
|
2196 | }
|
2197 | };
|
2198 |
|
2199 |
|
2200 | function createDevtoolsComponentHook(hook) {
|
2201 | return (component) => {
|
2202 | emit$1(
|
2203 | hook,
|
2204 | component.appContext.app,
|
2205 | component.uid,
|
2206 | component.parent ? component.parent.uid : void 0,
|
2207 | component
|
2208 | );
|
2209 | };
|
2210 | }
|
2211 | const devtoolsPerfStart = createDevtoolsPerformanceHook(
|
2212 | "perf:start"
|
2213 | );
|
2214 | const devtoolsPerfEnd = createDevtoolsPerformanceHook(
|
2215 | "perf:end"
|
2216 | );
|
2217 | function createDevtoolsPerformanceHook(hook) {
|
2218 | return (component, type, time) => {
|
2219 | emit$1(hook, component.appContext.app, component.uid, component, type, time);
|
2220 | };
|
2221 | }
|
2222 | function devtoolsComponentEmit(component, event, params) {
|
2223 | emit$1(
|
2224 | "component:emit" ,
|
2225 | component.appContext.app,
|
2226 | component,
|
2227 | event,
|
2228 | params
|
2229 | );
|
2230 | }
|
2231 |
|
2232 | function emit(instance, event, ...rawArgs) {
|
2233 | if (instance.isUnmounted)
|
2234 | return;
|
2235 | const props = instance.vnode.props || EMPTY_OBJ;
|
2236 | {
|
2237 | const {
|
2238 | emitsOptions,
|
2239 | propsOptions: [propsOptions]
|
2240 | } = instance;
|
2241 | if (emitsOptions) {
|
2242 | if (!(event in emitsOptions) && true) {
|
2243 | if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
|
2244 | warn$1(
|
2245 | `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`
|
2246 | );
|
2247 | }
|
2248 | } else {
|
2249 | const validator = emitsOptions[event];
|
2250 | if (isFunction(validator)) {
|
2251 | const isValid = validator(...rawArgs);
|
2252 | if (!isValid) {
|
2253 | warn$1(
|
2254 | `Invalid event arguments: event validation failed for event "${event}".`
|
2255 | );
|
2256 | }
|
2257 | }
|
2258 | }
|
2259 | }
|
2260 | }
|
2261 | let args = rawArgs;
|
2262 | const isModelListener = event.startsWith("update:");
|
2263 | const modelArg = isModelListener && event.slice(7);
|
2264 | if (modelArg && modelArg in props) {
|
2265 | const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;
|
2266 | const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
|
2267 | if (trim) {
|
2268 | args = rawArgs.map((a) => isString(a) ? a.trim() : a);
|
2269 | }
|
2270 | if (number) {
|
2271 | args = rawArgs.map(looseToNumber);
|
2272 | }
|
2273 | }
|
2274 | {
|
2275 | devtoolsComponentEmit(instance, event, args);
|
2276 | }
|
2277 | {
|
2278 | const lowerCaseEvent = event.toLowerCase();
|
2279 | if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
|
2280 | warn$1(
|
2281 | `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
|
2282 | instance,
|
2283 | instance.type
|
2284 | )} 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(
|
2285 | event
|
2286 | )}" instead of "${event}".`
|
2287 | );
|
2288 | }
|
2289 | }
|
2290 | let handlerName;
|
2291 | let handler = props[handlerName = toHandlerKey(event)] ||
|
2292 | props[handlerName = toHandlerKey(camelize(event))];
|
2293 | if (!handler && isModelListener) {
|
2294 | handler = props[handlerName = toHandlerKey(hyphenate(event))];
|
2295 | }
|
2296 | if (handler) {
|
2297 | callWithAsyncErrorHandling(
|
2298 | handler,
|
2299 | instance,
|
2300 | 6,
|
2301 | args
|
2302 | );
|
2303 | }
|
2304 | const onceHandler = props[handlerName + `Once`];
|
2305 | if (onceHandler) {
|
2306 | if (!instance.emitted) {
|
2307 | instance.emitted = {};
|
2308 | } else if (instance.emitted[handlerName]) {
|
2309 | return;
|
2310 | }
|
2311 | instance.emitted[handlerName] = true;
|
2312 | callWithAsyncErrorHandling(
|
2313 | onceHandler,
|
2314 | instance,
|
2315 | 6,
|
2316 | args
|
2317 | );
|
2318 | }
|
2319 | }
|
2320 | function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
2321 | const cache = appContext.emitsCache;
|
2322 | const cached = cache.get(comp);
|
2323 | if (cached !== void 0) {
|
2324 | return cached;
|
2325 | }
|
2326 | const raw = comp.emits;
|
2327 | let normalized = {};
|
2328 | let hasExtends = false;
|
2329 | if (!isFunction(comp)) {
|
2330 | const extendEmits = (raw2) => {
|
2331 | const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
|
2332 | if (normalizedFromExtend) {
|
2333 | hasExtends = true;
|
2334 | extend(normalized, normalizedFromExtend);
|
2335 | }
|
2336 | };
|
2337 | if (!asMixin && appContext.mixins.length) {
|
2338 | appContext.mixins.forEach(extendEmits);
|
2339 | }
|
2340 | if (comp.extends) {
|
2341 | extendEmits(comp.extends);
|
2342 | }
|
2343 | if (comp.mixins) {
|
2344 | comp.mixins.forEach(extendEmits);
|
2345 | }
|
2346 | }
|
2347 | if (!raw && !hasExtends) {
|
2348 | if (isObject(comp)) {
|
2349 | cache.set(comp, null);
|
2350 | }
|
2351 | return null;
|
2352 | }
|
2353 | if (isArray(raw)) {
|
2354 | raw.forEach((key) => normalized[key] = null);
|
2355 | } else {
|
2356 | extend(normalized, raw);
|
2357 | }
|
2358 | if (isObject(comp)) {
|
2359 | cache.set(comp, normalized);
|
2360 | }
|
2361 | return normalized;
|
2362 | }
|
2363 | function isEmitListener(options, key) {
|
2364 | if (!options || !isOn(key)) {
|
2365 | return false;
|
2366 | }
|
2367 | key = key.slice(2).replace(/Once$/, "");
|
2368 | return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
|
2369 | }
|
2370 |
|
2371 | let currentRenderingInstance = null;
|
2372 | let currentScopeId = null;
|
2373 | function setCurrentRenderingInstance(instance) {
|
2374 | const prev = currentRenderingInstance;
|
2375 | currentRenderingInstance = instance;
|
2376 | currentScopeId = instance && instance.type.__scopeId || null;
|
2377 | return prev;
|
2378 | }
|
2379 | function pushScopeId(id) {
|
2380 | currentScopeId = id;
|
2381 | }
|
2382 | function popScopeId() {
|
2383 | currentScopeId = null;
|
2384 | }
|
2385 | const withScopeId = (_id) => withCtx;
|
2386 | function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
|
2387 | if (!ctx)
|
2388 | return fn;
|
2389 | if (fn._n) {
|
2390 | return fn;
|
2391 | }
|
2392 | const renderFnWithContext = (...args) => {
|
2393 | if (renderFnWithContext._d) {
|
2394 | setBlockTracking(-1);
|
2395 | }
|
2396 | const prevInstance = setCurrentRenderingInstance(ctx);
|
2397 | let res;
|
2398 | try {
|
2399 | res = fn(...args);
|
2400 | } finally {
|
2401 | setCurrentRenderingInstance(prevInstance);
|
2402 | if (renderFnWithContext._d) {
|
2403 | setBlockTracking(1);
|
2404 | }
|
2405 | }
|
2406 | {
|
2407 | devtoolsComponentUpdated(ctx);
|
2408 | }
|
2409 | return res;
|
2410 | };
|
2411 | renderFnWithContext._n = true;
|
2412 | renderFnWithContext._c = true;
|
2413 | renderFnWithContext._d = true;
|
2414 | return renderFnWithContext;
|
2415 | }
|
2416 |
|
2417 | let accessedAttrs = false;
|
2418 | function markAttrsAccessed() {
|
2419 | accessedAttrs = true;
|
2420 | }
|
2421 | function renderComponentRoot(instance) {
|
2422 | const {
|
2423 | type: Component,
|
2424 | vnode,
|
2425 | proxy,
|
2426 | withProxy,
|
2427 | propsOptions: [propsOptions],
|
2428 | slots,
|
2429 | attrs,
|
2430 | emit,
|
2431 | render,
|
2432 | renderCache,
|
2433 | props,
|
2434 | data,
|
2435 | setupState,
|
2436 | ctx,
|
2437 | inheritAttrs
|
2438 | } = instance;
|
2439 | const prev = setCurrentRenderingInstance(instance);
|
2440 | let result;
|
2441 | let fallthroughAttrs;
|
2442 | {
|
2443 | accessedAttrs = false;
|
2444 | }
|
2445 | try {
|
2446 | if (vnode.shapeFlag & 4) {
|
2447 | const proxyToUse = withProxy || proxy;
|
2448 | const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
|
2449 | get(target, key, receiver) {
|
2450 | warn$1(
|
2451 | `Property '${String(
|
2452 | key
|
2453 | )}' was accessed via 'this'. Avoid using 'this' in templates.`
|
2454 | );
|
2455 | return Reflect.get(target, key, receiver);
|
2456 | }
|
2457 | }) : proxyToUse;
|
2458 | result = normalizeVNode(
|
2459 | render.call(
|
2460 | thisProxy,
|
2461 | proxyToUse,
|
2462 | renderCache,
|
2463 | true ? shallowReadonly(props) : props,
|
2464 | setupState,
|
2465 | data,
|
2466 | ctx
|
2467 | )
|
2468 | );
|
2469 | fallthroughAttrs = attrs;
|
2470 | } else {
|
2471 | const render2 = Component;
|
2472 | if (attrs === props) {
|
2473 | markAttrsAccessed();
|
2474 | }
|
2475 | result = normalizeVNode(
|
2476 | render2.length > 1 ? render2(
|
2477 | true ? shallowReadonly(props) : props,
|
2478 | true ? {
|
2479 | get attrs() {
|
2480 | markAttrsAccessed();
|
2481 | return attrs;
|
2482 | },
|
2483 | slots,
|
2484 | emit
|
2485 | } : { attrs, slots, emit }
|
2486 | ) : render2(
|
2487 | true ? shallowReadonly(props) : props,
|
2488 | null
|
2489 | )
|
2490 | );
|
2491 | fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
|
2492 | }
|
2493 | } catch (err) {
|
2494 | blockStack.length = 0;
|
2495 | handleError(err, instance, 1);
|
2496 | result = createVNode(Comment);
|
2497 | }
|
2498 | let root = result;
|
2499 | let setRoot = void 0;
|
2500 | if (result.patchFlag > 0 && result.patchFlag & 2048) {
|
2501 | [root, setRoot] = getChildRoot(result);
|
2502 | }
|
2503 | if (fallthroughAttrs && inheritAttrs !== false) {
|
2504 | const keys = Object.keys(fallthroughAttrs);
|
2505 | const { shapeFlag } = root;
|
2506 | if (keys.length) {
|
2507 | if (shapeFlag & (1 | 6)) {
|
2508 | if (propsOptions && keys.some(isModelListener)) {
|
2509 | fallthroughAttrs = filterModelListeners(
|
2510 | fallthroughAttrs,
|
2511 | propsOptions
|
2512 | );
|
2513 | }
|
2514 | root = cloneVNode(root, fallthroughAttrs);
|
2515 | } else if (!accessedAttrs && root.type !== Comment) {
|
2516 | const allAttrs = Object.keys(attrs);
|
2517 | const eventAttrs = [];
|
2518 | const extraAttrs = [];
|
2519 | for (let i = 0, l = allAttrs.length; i < l; i++) {
|
2520 | const key = allAttrs[i];
|
2521 | if (isOn(key)) {
|
2522 | if (!isModelListener(key)) {
|
2523 | eventAttrs.push(key[2].toLowerCase() + key.slice(3));
|
2524 | }
|
2525 | } else {
|
2526 | extraAttrs.push(key);
|
2527 | }
|
2528 | }
|
2529 | if (extraAttrs.length) {
|
2530 | warn$1(
|
2531 | `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`
|
2532 | );
|
2533 | }
|
2534 | if (eventAttrs.length) {
|
2535 | warn$1(
|
2536 | `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.`
|
2537 | );
|
2538 | }
|
2539 | }
|
2540 | }
|
2541 | }
|
2542 | if (vnode.dirs) {
|
2543 | if (!isElementRoot(root)) {
|
2544 | warn$1(
|
2545 | `Runtime directive used on component with non-element root node. The directives will not function as intended.`
|
2546 | );
|
2547 | }
|
2548 | root = cloneVNode(root);
|
2549 | root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
|
2550 | }
|
2551 | if (vnode.transition) {
|
2552 | if (!isElementRoot(root)) {
|
2553 | warn$1(
|
2554 | `Component inside <Transition> renders non-element root node that cannot be animated.`
|
2555 | );
|
2556 | }
|
2557 | root.transition = vnode.transition;
|
2558 | }
|
2559 | if (setRoot) {
|
2560 | setRoot(root);
|
2561 | } else {
|
2562 | result = root;
|
2563 | }
|
2564 | setCurrentRenderingInstance(prev);
|
2565 | return result;
|
2566 | }
|
2567 | const getChildRoot = (vnode) => {
|
2568 | const rawChildren = vnode.children;
|
2569 | const dynamicChildren = vnode.dynamicChildren;
|
2570 | const childRoot = filterSingleRoot(rawChildren, false);
|
2571 | if (!childRoot) {
|
2572 | return [vnode, void 0];
|
2573 | } else if (childRoot.patchFlag > 0 && childRoot.patchFlag & 2048) {
|
2574 | return getChildRoot(childRoot);
|
2575 | }
|
2576 | const index = rawChildren.indexOf(childRoot);
|
2577 | const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
|
2578 | const setRoot = (updatedRoot) => {
|
2579 | rawChildren[index] = updatedRoot;
|
2580 | if (dynamicChildren) {
|
2581 | if (dynamicIndex > -1) {
|
2582 | dynamicChildren[dynamicIndex] = updatedRoot;
|
2583 | } else if (updatedRoot.patchFlag > 0) {
|
2584 | vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
|
2585 | }
|
2586 | }
|
2587 | };
|
2588 | return [normalizeVNode(childRoot), setRoot];
|
2589 | };
|
2590 | function filterSingleRoot(children, recurse = true) {
|
2591 | let singleRoot;
|
2592 | for (let i = 0; i < children.length; i++) {
|
2593 | const child = children[i];
|
2594 | if (isVNode(child)) {
|
2595 | if (child.type !== Comment || child.children === "v-if") {
|
2596 | if (singleRoot) {
|
2597 | return;
|
2598 | } else {
|
2599 | singleRoot = child;
|
2600 | if (recurse && singleRoot.patchFlag > 0 && singleRoot.patchFlag & 2048) {
|
2601 | return filterSingleRoot(singleRoot.children);
|
2602 | }
|
2603 | }
|
2604 | }
|
2605 | } else {
|
2606 | return;
|
2607 | }
|
2608 | }
|
2609 | return singleRoot;
|
2610 | }
|
2611 | const getFunctionalFallthrough = (attrs) => {
|
2612 | let res;
|
2613 | for (const key in attrs) {
|
2614 | if (key === "class" || key === "style" || isOn(key)) {
|
2615 | (res || (res = {}))[key] = attrs[key];
|
2616 | }
|
2617 | }
|
2618 | return res;
|
2619 | };
|
2620 | const filterModelListeners = (attrs, props) => {
|
2621 | const res = {};
|
2622 | for (const key in attrs) {
|
2623 | if (!isModelListener(key) || !(key.slice(9) in props)) {
|
2624 | res[key] = attrs[key];
|
2625 | }
|
2626 | }
|
2627 | return res;
|
2628 | };
|
2629 | const isElementRoot = (vnode) => {
|
2630 | return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
|
2631 | };
|
2632 | function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
|
2633 | const { props: prevProps, children: prevChildren, component } = prevVNode;
|
2634 | const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
|
2635 | const emits = component.emitsOptions;
|
2636 | if ((prevChildren || nextChildren) && isHmrUpdating) {
|
2637 | return true;
|
2638 | }
|
2639 | if (nextVNode.dirs || nextVNode.transition) {
|
2640 | return true;
|
2641 | }
|
2642 | if (optimized && patchFlag >= 0) {
|
2643 | if (patchFlag & 1024) {
|
2644 | return true;
|
2645 | }
|
2646 | if (patchFlag & 16) {
|
2647 | if (!prevProps) {
|
2648 | return !!nextProps;
|
2649 | }
|
2650 | return hasPropsChanged(prevProps, nextProps, emits);
|
2651 | } else if (patchFlag & 8) {
|
2652 | const dynamicProps = nextVNode.dynamicProps;
|
2653 | for (let i = 0; i < dynamicProps.length; i++) {
|
2654 | const key = dynamicProps[i];
|
2655 | if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
|
2656 | return true;
|
2657 | }
|
2658 | }
|
2659 | }
|
2660 | } else {
|
2661 | if (prevChildren || nextChildren) {
|
2662 | if (!nextChildren || !nextChildren.$stable) {
|
2663 | return true;
|
2664 | }
|
2665 | }
|
2666 | if (prevProps === nextProps) {
|
2667 | return false;
|
2668 | }
|
2669 | if (!prevProps) {
|
2670 | return !!nextProps;
|
2671 | }
|
2672 | if (!nextProps) {
|
2673 | return true;
|
2674 | }
|
2675 | return hasPropsChanged(prevProps, nextProps, emits);
|
2676 | }
|
2677 | return false;
|
2678 | }
|
2679 | function hasPropsChanged(prevProps, nextProps, emitsOptions) {
|
2680 | const nextKeys = Object.keys(nextProps);
|
2681 | if (nextKeys.length !== Object.keys(prevProps).length) {
|
2682 | return true;
|
2683 | }
|
2684 | for (let i = 0; i < nextKeys.length; i++) {
|
2685 | const key = nextKeys[i];
|
2686 | if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
|
2687 | return true;
|
2688 | }
|
2689 | }
|
2690 | return false;
|
2691 | }
|
2692 | function updateHOCHostEl({ vnode, parent }, el) {
|
2693 | while (parent) {
|
2694 | const root = parent.subTree;
|
2695 | if (root.suspense && root.suspense.activeBranch === vnode) {
|
2696 | root.el = vnode.el;
|
2697 | }
|
2698 | if (root === vnode) {
|
2699 | (vnode = parent.vnode).el = el;
|
2700 | parent = parent.parent;
|
2701 | } else {
|
2702 | break;
|
2703 | }
|
2704 | }
|
2705 | }
|
2706 |
|
2707 | const COMPONENTS = "components";
|
2708 | const DIRECTIVES = "directives";
|
2709 | function resolveComponent(name, maybeSelfReference) {
|
2710 | return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
2711 | }
|
2712 | const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
|
2713 | function resolveDynamicComponent(component) {
|
2714 | if (isString(component)) {
|
2715 | return resolveAsset(COMPONENTS, component, false) || component;
|
2716 | } else {
|
2717 | return component || NULL_DYNAMIC_COMPONENT;
|
2718 | }
|
2719 | }
|
2720 | function resolveDirective(name) {
|
2721 | return resolveAsset(DIRECTIVES, name);
|
2722 | }
|
2723 | function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
2724 | const instance = currentRenderingInstance || currentInstance;
|
2725 | if (instance) {
|
2726 | const Component = instance.type;
|
2727 | if (type === COMPONENTS) {
|
2728 | const selfName = getComponentName(
|
2729 | Component,
|
2730 | false
|
2731 | );
|
2732 | if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
|
2733 | return Component;
|
2734 | }
|
2735 | }
|
2736 | const res = (
|
2737 |
|
2738 |
|
2739 | resolve(instance[type] || Component[type], name) ||
|
2740 | resolve(instance.appContext[type], name)
|
2741 | );
|
2742 | if (!res && maybeSelfReference) {
|
2743 | return Component;
|
2744 | }
|
2745 | if (warnMissing && !res) {
|
2746 | const extra = type === COMPONENTS ? `
|
2747 | If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
|
2748 | warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
|
2749 | }
|
2750 | return res;
|
2751 | } else {
|
2752 | warn$1(
|
2753 | `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
|
2754 | );
|
2755 | }
|
2756 | }
|
2757 | function resolve(registry, name) {
|
2758 | return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
|
2759 | }
|
2760 |
|
2761 | const isSuspense = (type) => type.__isSuspense;
|
2762 | let suspenseId = 0;
|
2763 | const SuspenseImpl = {
|
2764 | name: "Suspense",
|
2765 |
|
2766 |
|
2767 |
|
2768 |
|
2769 | __isSuspense: true,
|
2770 | process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
|
2771 | if (n1 == null) {
|
2772 | mountSuspense(
|
2773 | n2,
|
2774 | container,
|
2775 | anchor,
|
2776 | parentComponent,
|
2777 | parentSuspense,
|
2778 | namespace,
|
2779 | slotScopeIds,
|
2780 | optimized,
|
2781 | rendererInternals
|
2782 | );
|
2783 | } else {
|
2784 | if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
|
2785 | n2.suspense = n1.suspense;
|
2786 | n2.suspense.vnode = n2;
|
2787 | n2.el = n1.el;
|
2788 | return;
|
2789 | }
|
2790 | patchSuspense(
|
2791 | n1,
|
2792 | n2,
|
2793 | container,
|
2794 | anchor,
|
2795 | parentComponent,
|
2796 | namespace,
|
2797 | slotScopeIds,
|
2798 | optimized,
|
2799 | rendererInternals
|
2800 | );
|
2801 | }
|
2802 | },
|
2803 | hydrate: hydrateSuspense,
|
2804 | create: createSuspenseBoundary,
|
2805 | normalize: normalizeSuspenseChildren
|
2806 | };
|
2807 | const Suspense = SuspenseImpl ;
|
2808 | function triggerEvent(vnode, name) {
|
2809 | const eventListener = vnode.props && vnode.props[name];
|
2810 | if (isFunction(eventListener)) {
|
2811 | eventListener();
|
2812 | }
|
2813 | }
|
2814 | function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
|
2815 | const {
|
2816 | p: patch,
|
2817 | o: { createElement }
|
2818 | } = rendererInternals;
|
2819 | const hiddenContainer = createElement("div");
|
2820 | const suspense = vnode.suspense = createSuspenseBoundary(
|
2821 | vnode,
|
2822 | parentSuspense,
|
2823 | parentComponent,
|
2824 | container,
|
2825 | hiddenContainer,
|
2826 | anchor,
|
2827 | namespace,
|
2828 | slotScopeIds,
|
2829 | optimized,
|
2830 | rendererInternals
|
2831 | );
|
2832 | patch(
|
2833 | null,
|
2834 | suspense.pendingBranch = vnode.ssContent,
|
2835 | hiddenContainer,
|
2836 | null,
|
2837 | parentComponent,
|
2838 | suspense,
|
2839 | namespace,
|
2840 | slotScopeIds
|
2841 | );
|
2842 | if (suspense.deps > 0) {
|
2843 | triggerEvent(vnode, "onPending");
|
2844 | triggerEvent(vnode, "onFallback");
|
2845 | patch(
|
2846 | null,
|
2847 | vnode.ssFallback,
|
2848 | container,
|
2849 | anchor,
|
2850 | parentComponent,
|
2851 | null,
|
2852 |
|
2853 | namespace,
|
2854 | slotScopeIds
|
2855 | );
|
2856 | setActiveBranch(suspense, vnode.ssFallback);
|
2857 | } else {
|
2858 | suspense.resolve(false, true);
|
2859 | }
|
2860 | }
|
2861 | function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
|
2862 | const suspense = n2.suspense = n1.suspense;
|
2863 | suspense.vnode = n2;
|
2864 | n2.el = n1.el;
|
2865 | const newBranch = n2.ssContent;
|
2866 | const newFallback = n2.ssFallback;
|
2867 | const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
|
2868 | if (pendingBranch) {
|
2869 | suspense.pendingBranch = newBranch;
|
2870 | if (isSameVNodeType(newBranch, pendingBranch)) {
|
2871 | patch(
|
2872 | pendingBranch,
|
2873 | newBranch,
|
2874 | suspense.hiddenContainer,
|
2875 | null,
|
2876 | parentComponent,
|
2877 | suspense,
|
2878 | namespace,
|
2879 | slotScopeIds,
|
2880 | optimized
|
2881 | );
|
2882 | if (suspense.deps <= 0) {
|
2883 | suspense.resolve();
|
2884 | } else if (isInFallback) {
|
2885 | if (!isHydrating) {
|
2886 | patch(
|
2887 | activeBranch,
|
2888 | newFallback,
|
2889 | container,
|
2890 | anchor,
|
2891 | parentComponent,
|
2892 | null,
|
2893 |
|
2894 | namespace,
|
2895 | slotScopeIds,
|
2896 | optimized
|
2897 | );
|
2898 | setActiveBranch(suspense, newFallback);
|
2899 | }
|
2900 | }
|
2901 | } else {
|
2902 | suspense.pendingId = suspenseId++;
|
2903 | if (isHydrating) {
|
2904 | suspense.isHydrating = false;
|
2905 | suspense.activeBranch = pendingBranch;
|
2906 | } else {
|
2907 | unmount(pendingBranch, parentComponent, suspense);
|
2908 | }
|
2909 | suspense.deps = 0;
|
2910 | suspense.effects.length = 0;
|
2911 | suspense.hiddenContainer = createElement("div");
|
2912 | if (isInFallback) {
|
2913 | patch(
|
2914 | null,
|
2915 | newBranch,
|
2916 | suspense.hiddenContainer,
|
2917 | null,
|
2918 | parentComponent,
|
2919 | suspense,
|
2920 | namespace,
|
2921 | slotScopeIds,
|
2922 | optimized
|
2923 | );
|
2924 | if (suspense.deps <= 0) {
|
2925 | suspense.resolve();
|
2926 | } else {
|
2927 | patch(
|
2928 | activeBranch,
|
2929 | newFallback,
|
2930 | container,
|
2931 | anchor,
|
2932 | parentComponent,
|
2933 | null,
|
2934 |
|
2935 | namespace,
|
2936 | slotScopeIds,
|
2937 | optimized
|
2938 | );
|
2939 | setActiveBranch(suspense, newFallback);
|
2940 | }
|
2941 | } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2942 | patch(
|
2943 | activeBranch,
|
2944 | newBranch,
|
2945 | container,
|
2946 | anchor,
|
2947 | parentComponent,
|
2948 | suspense,
|
2949 | namespace,
|
2950 | slotScopeIds,
|
2951 | optimized
|
2952 | );
|
2953 | suspense.resolve(true);
|
2954 | } else {
|
2955 | patch(
|
2956 | null,
|
2957 | newBranch,
|
2958 | suspense.hiddenContainer,
|
2959 | null,
|
2960 | parentComponent,
|
2961 | suspense,
|
2962 | namespace,
|
2963 | slotScopeIds,
|
2964 | optimized
|
2965 | );
|
2966 | if (suspense.deps <= 0) {
|
2967 | suspense.resolve();
|
2968 | }
|
2969 | }
|
2970 | }
|
2971 | } else {
|
2972 | if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2973 | patch(
|
2974 | activeBranch,
|
2975 | newBranch,
|
2976 | container,
|
2977 | anchor,
|
2978 | parentComponent,
|
2979 | suspense,
|
2980 | namespace,
|
2981 | slotScopeIds,
|
2982 | optimized
|
2983 | );
|
2984 | setActiveBranch(suspense, newBranch);
|
2985 | } else {
|
2986 | triggerEvent(n2, "onPending");
|
2987 | suspense.pendingBranch = newBranch;
|
2988 | if (newBranch.shapeFlag & 512) {
|
2989 | suspense.pendingId = newBranch.component.suspenseId;
|
2990 | } else {
|
2991 | suspense.pendingId = suspenseId++;
|
2992 | }
|
2993 | patch(
|
2994 | null,
|
2995 | newBranch,
|
2996 | suspense.hiddenContainer,
|
2997 | null,
|
2998 | parentComponent,
|
2999 | suspense,
|
3000 | namespace,
|
3001 | slotScopeIds,
|
3002 | optimized
|
3003 | );
|
3004 | if (suspense.deps <= 0) {
|
3005 | suspense.resolve();
|
3006 | } else {
|
3007 | const { timeout, pendingId } = suspense;
|
3008 | if (timeout > 0) {
|
3009 | setTimeout(() => {
|
3010 | if (suspense.pendingId === pendingId) {
|
3011 | suspense.fallback(newFallback);
|
3012 | }
|
3013 | }, timeout);
|
3014 | } else if (timeout === 0) {
|
3015 | suspense.fallback(newFallback);
|
3016 | }
|
3017 | }
|
3018 | }
|
3019 | }
|
3020 | }
|
3021 | let hasWarned = false;
|
3022 | function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
|
3023 | if (!hasWarned) {
|
3024 | hasWarned = true;
|
3025 | console[console.info ? "info" : "log"](
|
3026 | `<Suspense> is an experimental feature and its API will likely change.`
|
3027 | );
|
3028 | }
|
3029 | const {
|
3030 | p: patch,
|
3031 | m: move,
|
3032 | um: unmount,
|
3033 | n: next,
|
3034 | o: { parentNode, remove }
|
3035 | } = rendererInternals;
|
3036 | let parentSuspenseId;
|
3037 | const isSuspensible = isVNodeSuspensible(vnode);
|
3038 | if (isSuspensible) {
|
3039 | if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
|
3040 | parentSuspenseId = parentSuspense.pendingId;
|
3041 | parentSuspense.deps++;
|
3042 | }
|
3043 | }
|
3044 | const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0;
|
3045 | {
|
3046 | assertNumber(timeout, `Suspense timeout`);
|
3047 | }
|
3048 | const initialAnchor = anchor;
|
3049 | const suspense = {
|
3050 | vnode,
|
3051 | parent: parentSuspense,
|
3052 | parentComponent,
|
3053 | namespace,
|
3054 | container,
|
3055 | hiddenContainer,
|
3056 | deps: 0,
|
3057 | pendingId: suspenseId++,
|
3058 | timeout: typeof timeout === "number" ? timeout : -1,
|
3059 | activeBranch: null,
|
3060 | pendingBranch: null,
|
3061 | isInFallback: !isHydrating,
|
3062 | isHydrating,
|
3063 | isUnmounted: false,
|
3064 | effects: [],
|
3065 | resolve(resume = false, sync = false) {
|
3066 | {
|
3067 | if (!resume && !suspense.pendingBranch) {
|
3068 | throw new Error(
|
3069 | `suspense.resolve() is called without a pending branch.`
|
3070 | );
|
3071 | }
|
3072 | if (suspense.isUnmounted) {
|
3073 | throw new Error(
|
3074 | `suspense.resolve() is called on an already unmounted suspense boundary.`
|
3075 | );
|
3076 | }
|
3077 | }
|
3078 | const {
|
3079 | vnode: vnode2,
|
3080 | activeBranch,
|
3081 | pendingBranch,
|
3082 | pendingId,
|
3083 | effects,
|
3084 | parentComponent: parentComponent2,
|
3085 | container: container2
|
3086 | } = suspense;
|
3087 | let delayEnter = false;
|
3088 | if (suspense.isHydrating) {
|
3089 | suspense.isHydrating = false;
|
3090 | } else if (!resume) {
|
3091 | delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
|
3092 | if (delayEnter) {
|
3093 | activeBranch.transition.afterLeave = () => {
|
3094 | if (pendingId === suspense.pendingId) {
|
3095 | move(
|
3096 | pendingBranch,
|
3097 | container2,
|
3098 | anchor === initialAnchor ? next(activeBranch) : anchor,
|
3099 | 0
|
3100 | );
|
3101 | queuePostFlushCb(effects);
|
3102 | }
|
3103 | };
|
3104 | }
|
3105 | if (activeBranch) {
|
3106 | if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
|
3107 | anchor = next(activeBranch);
|
3108 | }
|
3109 | unmount(activeBranch, parentComponent2, suspense, true);
|
3110 | }
|
3111 | if (!delayEnter) {
|
3112 | move(pendingBranch, container2, anchor, 0);
|
3113 | }
|
3114 | }
|
3115 | setActiveBranch(suspense, pendingBranch);
|
3116 | suspense.pendingBranch = null;
|
3117 | suspense.isInFallback = false;
|
3118 | let parent = suspense.parent;
|
3119 | let hasUnresolvedAncestor = false;
|
3120 | while (parent) {
|
3121 | if (parent.pendingBranch) {
|
3122 | parent.effects.push(...effects);
|
3123 | hasUnresolvedAncestor = true;
|
3124 | break;
|
3125 | }
|
3126 | parent = parent.parent;
|
3127 | }
|
3128 | if (!hasUnresolvedAncestor && !delayEnter) {
|
3129 | queuePostFlushCb(effects);
|
3130 | }
|
3131 | suspense.effects = [];
|
3132 | if (isSuspensible) {
|
3133 | if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
|
3134 | parentSuspense.deps--;
|
3135 | if (parentSuspense.deps === 0 && !sync) {
|
3136 | parentSuspense.resolve();
|
3137 | }
|
3138 | }
|
3139 | }
|
3140 | triggerEvent(vnode2, "onResolve");
|
3141 | },
|
3142 | fallback(fallbackVNode) {
|
3143 | if (!suspense.pendingBranch) {
|
3144 | return;
|
3145 | }
|
3146 | const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense;
|
3147 | triggerEvent(vnode2, "onFallback");
|
3148 | const anchor2 = next(activeBranch);
|
3149 | const mountFallback = () => {
|
3150 | if (!suspense.isInFallback) {
|
3151 | return;
|
3152 | }
|
3153 | patch(
|
3154 | null,
|
3155 | fallbackVNode,
|
3156 | container2,
|
3157 | anchor2,
|
3158 | parentComponent2,
|
3159 | null,
|
3160 |
|
3161 | namespace2,
|
3162 | slotScopeIds,
|
3163 | optimized
|
3164 | );
|
3165 | setActiveBranch(suspense, fallbackVNode);
|
3166 | };
|
3167 | const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
|
3168 | if (delayEnter) {
|
3169 | activeBranch.transition.afterLeave = mountFallback;
|
3170 | }
|
3171 | suspense.isInFallback = true;
|
3172 | unmount(
|
3173 | activeBranch,
|
3174 | parentComponent2,
|
3175 | null,
|
3176 |
|
3177 | true
|
3178 |
|
3179 | );
|
3180 | if (!delayEnter) {
|
3181 | mountFallback();
|
3182 | }
|
3183 | },
|
3184 | move(container2, anchor2, type) {
|
3185 | suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
|
3186 | suspense.container = container2;
|
3187 | },
|
3188 | next() {
|
3189 | return suspense.activeBranch && next(suspense.activeBranch);
|
3190 | },
|
3191 | registerDep(instance, setupRenderEffect) {
|
3192 | const isInPendingSuspense = !!suspense.pendingBranch;
|
3193 | if (isInPendingSuspense) {
|
3194 | suspense.deps++;
|
3195 | }
|
3196 | const hydratedEl = instance.vnode.el;
|
3197 | instance.asyncDep.catch((err) => {
|
3198 | handleError(err, instance, 0);
|
3199 | }).then((asyncSetupResult) => {
|
3200 | if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
|
3201 | return;
|
3202 | }
|
3203 | instance.asyncResolved = true;
|
3204 | const { vnode: vnode2 } = instance;
|
3205 | {
|
3206 | pushWarningContext(vnode2);
|
3207 | }
|
3208 | handleSetupResult(instance, asyncSetupResult, false);
|
3209 | if (hydratedEl) {
|
3210 | vnode2.el = hydratedEl;
|
3211 | }
|
3212 | const placeholder = !hydratedEl && instance.subTree.el;
|
3213 | setupRenderEffect(
|
3214 | instance,
|
3215 | vnode2,
|
3216 |
|
3217 |
|
3218 |
|
3219 | parentNode(hydratedEl || instance.subTree.el),
|
3220 |
|
3221 |
|
3222 | hydratedEl ? null : next(instance.subTree),
|
3223 | suspense,
|
3224 | namespace,
|
3225 | optimized
|
3226 | );
|
3227 | if (placeholder) {
|
3228 | remove(placeholder);
|
3229 | }
|
3230 | updateHOCHostEl(instance, vnode2.el);
|
3231 | {
|
3232 | popWarningContext();
|
3233 | }
|
3234 | if (isInPendingSuspense && --suspense.deps === 0) {
|
3235 | suspense.resolve();
|
3236 | }
|
3237 | });
|
3238 | },
|
3239 | unmount(parentSuspense2, doRemove) {
|
3240 | suspense.isUnmounted = true;
|
3241 | if (suspense.activeBranch) {
|
3242 | unmount(
|
3243 | suspense.activeBranch,
|
3244 | parentComponent,
|
3245 | parentSuspense2,
|
3246 | doRemove
|
3247 | );
|
3248 | }
|
3249 | if (suspense.pendingBranch) {
|
3250 | unmount(
|
3251 | suspense.pendingBranch,
|
3252 | parentComponent,
|
3253 | parentSuspense2,
|
3254 | doRemove
|
3255 | );
|
3256 | }
|
3257 | }
|
3258 | };
|
3259 | return suspense;
|
3260 | }
|
3261 | function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) {
|
3262 | const suspense = vnode.suspense = createSuspenseBoundary(
|
3263 | vnode,
|
3264 | parentSuspense,
|
3265 | parentComponent,
|
3266 | node.parentNode,
|
3267 |
|
3268 | document.createElement("div"),
|
3269 | null,
|
3270 | namespace,
|
3271 | slotScopeIds,
|
3272 | optimized,
|
3273 | rendererInternals,
|
3274 | true
|
3275 | );
|
3276 | const result = hydrateNode(
|
3277 | node,
|
3278 | suspense.pendingBranch = vnode.ssContent,
|
3279 | parentComponent,
|
3280 | suspense,
|
3281 | slotScopeIds,
|
3282 | optimized
|
3283 | );
|
3284 | if (suspense.deps === 0) {
|
3285 | suspense.resolve(false, true);
|
3286 | }
|
3287 | return result;
|
3288 | }
|
3289 | function normalizeSuspenseChildren(vnode) {
|
3290 | const { shapeFlag, children } = vnode;
|
3291 | const isSlotChildren = shapeFlag & 32;
|
3292 | vnode.ssContent = normalizeSuspenseSlot(
|
3293 | isSlotChildren ? children.default : children
|
3294 | );
|
3295 | vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
|
3296 | }
|
3297 | function normalizeSuspenseSlot(s) {
|
3298 | let block;
|
3299 | if (isFunction(s)) {
|
3300 | const trackBlock = isBlockTreeEnabled && s._c;
|
3301 | if (trackBlock) {
|
3302 | s._d = false;
|
3303 | openBlock();
|
3304 | }
|
3305 | s = s();
|
3306 | if (trackBlock) {
|
3307 | s._d = true;
|
3308 | block = currentBlock;
|
3309 | closeBlock();
|
3310 | }
|
3311 | }
|
3312 | if (isArray(s)) {
|
3313 | const singleChild = filterSingleRoot(s);
|
3314 | if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
|
3315 | warn$1(`<Suspense> slots expect a single root node.`);
|
3316 | }
|
3317 | s = singleChild;
|
3318 | }
|
3319 | s = normalizeVNode(s);
|
3320 | if (block && !s.dynamicChildren) {
|
3321 | s.dynamicChildren = block.filter((c) => c !== s);
|
3322 | }
|
3323 | return s;
|
3324 | }
|
3325 | function queueEffectWithSuspense(fn, suspense) {
|
3326 | if (suspense && suspense.pendingBranch) {
|
3327 | if (isArray(fn)) {
|
3328 | suspense.effects.push(...fn);
|
3329 | } else {
|
3330 | suspense.effects.push(fn);
|
3331 | }
|
3332 | } else {
|
3333 | queuePostFlushCb(fn);
|
3334 | }
|
3335 | }
|
3336 | function setActiveBranch(suspense, branch) {
|
3337 | suspense.activeBranch = branch;
|
3338 | const { vnode, parentComponent } = suspense;
|
3339 | let el = branch.el;
|
3340 | while (!el && branch.component) {
|
3341 | branch = branch.component.subTree;
|
3342 | el = branch.el;
|
3343 | }
|
3344 | vnode.el = el;
|
3345 | if (parentComponent && parentComponent.subTree === vnode) {
|
3346 | parentComponent.vnode.el = el;
|
3347 | updateHOCHostEl(parentComponent, el);
|
3348 | }
|
3349 | }
|
3350 | function isVNodeSuspensible(vnode) {
|
3351 | var _a;
|
3352 | return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
|
3353 | }
|
3354 |
|
3355 | const ssrContextKey = Symbol.for("v-scx");
|
3356 | const useSSRContext = () => {
|
3357 | {
|
3358 | warn$1(`useSSRContext() is not supported in the global build.`);
|
3359 | }
|
3360 | };
|
3361 |
|
3362 | function watchEffect(effect, options) {
|
3363 | return doWatch(effect, null, options);
|
3364 | }
|
3365 | function watchPostEffect(effect, options) {
|
3366 | return doWatch(
|
3367 | effect,
|
3368 | null,
|
3369 | extend({}, options, { flush: "post" })
|
3370 | );
|
3371 | }
|
3372 | function watchSyncEffect(effect, options) {
|
3373 | return doWatch(
|
3374 | effect,
|
3375 | null,
|
3376 | extend({}, options, { flush: "sync" })
|
3377 | );
|
3378 | }
|
3379 | const INITIAL_WATCHER_VALUE = {};
|
3380 | function watch(source, cb, options) {
|
3381 | if (!isFunction(cb)) {
|
3382 | warn$1(
|
3383 | `\`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.`
|
3384 | );
|
3385 | }
|
3386 | return doWatch(source, cb, options);
|
3387 | }
|
3388 | function doWatch(source, cb, {
|
3389 | immediate,
|
3390 | deep,
|
3391 | flush,
|
3392 | once,
|
3393 | onTrack,
|
3394 | onTrigger
|
3395 | } = EMPTY_OBJ) {
|
3396 | if (cb && once) {
|
3397 | const _cb = cb;
|
3398 | cb = (...args) => {
|
3399 | _cb(...args);
|
3400 | unwatch();
|
3401 | };
|
3402 | }
|
3403 | if (deep !== void 0 && typeof deep === "number") {
|
3404 | warn$1(
|
3405 | `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`
|
3406 | );
|
3407 | }
|
3408 | if (!cb) {
|
3409 | if (immediate !== void 0) {
|
3410 | warn$1(
|
3411 | `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
|
3412 | );
|
3413 | }
|
3414 | if (deep !== void 0) {
|
3415 | warn$1(
|
3416 | `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
|
3417 | );
|
3418 | }
|
3419 | if (once !== void 0) {
|
3420 | warn$1(
|
3421 | `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
|
3422 | );
|
3423 | }
|
3424 | }
|
3425 | const warnInvalidSource = (s) => {
|
3426 | warn$1(
|
3427 | `Invalid watch source: `,
|
3428 | s,
|
3429 | `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
|
3430 | );
|
3431 | };
|
3432 | const instance = currentInstance;
|
3433 | const reactiveGetter = (source2) => deep === true ? source2 : (
|
3434 |
|
3435 | traverse(source2, deep === false ? 1 : void 0)
|
3436 | );
|
3437 | let getter;
|
3438 | let forceTrigger = false;
|
3439 | let isMultiSource = false;
|
3440 | if (isRef(source)) {
|
3441 | getter = () => source.value;
|
3442 | forceTrigger = isShallow(source);
|
3443 | } else if (isReactive(source)) {
|
3444 | getter = () => reactiveGetter(source);
|
3445 | forceTrigger = true;
|
3446 | } else if (isArray(source)) {
|
3447 | isMultiSource = true;
|
3448 | forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
3449 | getter = () => source.map((s) => {
|
3450 | if (isRef(s)) {
|
3451 | return s.value;
|
3452 | } else if (isReactive(s)) {
|
3453 | return reactiveGetter(s);
|
3454 | } else if (isFunction(s)) {
|
3455 | return callWithErrorHandling(s, instance, 2);
|
3456 | } else {
|
3457 | warnInvalidSource(s);
|
3458 | }
|
3459 | });
|
3460 | } else if (isFunction(source)) {
|
3461 | if (cb) {
|
3462 | getter = () => callWithErrorHandling(source, instance, 2);
|
3463 | } else {
|
3464 | getter = () => {
|
3465 | if (cleanup) {
|
3466 | cleanup();
|
3467 | }
|
3468 | return callWithAsyncErrorHandling(
|
3469 | source,
|
3470 | instance,
|
3471 | 3,
|
3472 | [onCleanup]
|
3473 | );
|
3474 | };
|
3475 | }
|
3476 | } else {
|
3477 | getter = NOOP;
|
3478 | warnInvalidSource(source);
|
3479 | }
|
3480 | if (cb && deep) {
|
3481 | const baseGetter = getter;
|
3482 | getter = () => traverse(baseGetter());
|
3483 | }
|
3484 | let cleanup;
|
3485 | let onCleanup = (fn) => {
|
3486 | cleanup = effect.onStop = () => {
|
3487 | callWithErrorHandling(fn, instance, 4);
|
3488 | cleanup = effect.onStop = void 0;
|
3489 | };
|
3490 | };
|
3491 | let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
3492 | const job = () => {
|
3493 | if (!effect.active || !effect.dirty) {
|
3494 | return;
|
3495 | }
|
3496 | if (cb) {
|
3497 | const newValue = effect.run();
|
3498 | if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
|
3499 | if (cleanup) {
|
3500 | cleanup();
|
3501 | }
|
3502 | callWithAsyncErrorHandling(cb, instance, 3, [
|
3503 | newValue,
|
3504 |
|
3505 | oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
3506 | onCleanup
|
3507 | ]);
|
3508 | oldValue = newValue;
|
3509 | }
|
3510 | } else {
|
3511 | effect.run();
|
3512 | }
|
3513 | };
|
3514 | job.allowRecurse = !!cb;
|
3515 | let scheduler;
|
3516 | if (flush === "sync") {
|
3517 | scheduler = job;
|
3518 | } else if (flush === "post") {
|
3519 | scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
3520 | } else {
|
3521 | job.pre = true;
|
3522 | if (instance)
|
3523 | job.id = instance.uid;
|
3524 | scheduler = () => queueJob(job);
|
3525 | }
|
3526 | const effect = new ReactiveEffect(getter, NOOP, scheduler);
|
3527 | const scope = getCurrentScope();
|
3528 | const unwatch = () => {
|
3529 | effect.stop();
|
3530 | if (scope) {
|
3531 | remove(scope.effects, effect);
|
3532 | }
|
3533 | };
|
3534 | {
|
3535 | effect.onTrack = onTrack;
|
3536 | effect.onTrigger = onTrigger;
|
3537 | }
|
3538 | if (cb) {
|
3539 | if (immediate) {
|
3540 | job();
|
3541 | } else {
|
3542 | oldValue = effect.run();
|
3543 | }
|
3544 | } else if (flush === "post") {
|
3545 | queuePostRenderEffect(
|
3546 | effect.run.bind(effect),
|
3547 | instance && instance.suspense
|
3548 | );
|
3549 | } else {
|
3550 | effect.run();
|
3551 | }
|
3552 | return unwatch;
|
3553 | }
|
3554 | function instanceWatch(source, value, options) {
|
3555 | const publicThis = this.proxy;
|
3556 | const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
|
3557 | let cb;
|
3558 | if (isFunction(value)) {
|
3559 | cb = value;
|
3560 | } else {
|
3561 | cb = value.handler;
|
3562 | options = value;
|
3563 | }
|
3564 | const reset = setCurrentInstance(this);
|
3565 | const res = doWatch(getter, cb.bind(publicThis), options);
|
3566 | reset();
|
3567 | return res;
|
3568 | }
|
3569 | function createPathGetter(ctx, path) {
|
3570 | const segments = path.split(".");
|
3571 | return () => {
|
3572 | let cur = ctx;
|
3573 | for (let i = 0; i < segments.length && cur; i++) {
|
3574 | cur = cur[segments[i]];
|
3575 | }
|
3576 | return cur;
|
3577 | };
|
3578 | }
|
3579 | function traverse(value, depth, currentDepth = 0, seen) {
|
3580 | if (!isObject(value) || value["__v_skip"]) {
|
3581 | return value;
|
3582 | }
|
3583 | if (depth && depth > 0) {
|
3584 | if (currentDepth >= depth) {
|
3585 | return value;
|
3586 | }
|
3587 | currentDepth++;
|
3588 | }
|
3589 | seen = seen || new Set();
|
3590 | if (seen.has(value)) {
|
3591 | return value;
|
3592 | }
|
3593 | seen.add(value);
|
3594 | if (isRef(value)) {
|
3595 | traverse(value.value, depth, currentDepth, seen);
|
3596 | } else if (isArray(value)) {
|
3597 | for (let i = 0; i < value.length; i++) {
|
3598 | traverse(value[i], depth, currentDepth, seen);
|
3599 | }
|
3600 | } else if (isSet(value) || isMap(value)) {
|
3601 | value.forEach((v) => {
|
3602 | traverse(v, depth, currentDepth, seen);
|
3603 | });
|
3604 | } else if (isPlainObject(value)) {
|
3605 | for (const key in value) {
|
3606 | traverse(value[key], depth, currentDepth, seen);
|
3607 | }
|
3608 | }
|
3609 | return value;
|
3610 | }
|
3611 |
|
3612 | function validateDirectiveName(name) {
|
3613 | if (isBuiltInDirective(name)) {
|
3614 | warn$1("Do not use built-in directive ids as custom directive id: " + name);
|
3615 | }
|
3616 | }
|
3617 | function withDirectives(vnode, directives) {
|
3618 | if (currentRenderingInstance === null) {
|
3619 | warn$1(`withDirectives can only be used inside render functions.`);
|
3620 | return vnode;
|
3621 | }
|
3622 | const instance = getExposeProxy(currentRenderingInstance) || currentRenderingInstance.proxy;
|
3623 | const bindings = vnode.dirs || (vnode.dirs = []);
|
3624 | for (let i = 0; i < directives.length; i++) {
|
3625 | let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
|
3626 | if (dir) {
|
3627 | if (isFunction(dir)) {
|
3628 | dir = {
|
3629 | mounted: dir,
|
3630 | updated: dir
|
3631 | };
|
3632 | }
|
3633 | if (dir.deep) {
|
3634 | traverse(value);
|
3635 | }
|
3636 | bindings.push({
|
3637 | dir,
|
3638 | instance,
|
3639 | value,
|
3640 | oldValue: void 0,
|
3641 | arg,
|
3642 | modifiers
|
3643 | });
|
3644 | }
|
3645 | }
|
3646 | return vnode;
|
3647 | }
|
3648 | function invokeDirectiveHook(vnode, prevVNode, instance, name) {
|
3649 | const bindings = vnode.dirs;
|
3650 | const oldBindings = prevVNode && prevVNode.dirs;
|
3651 | for (let i = 0; i < bindings.length; i++) {
|
3652 | const binding = bindings[i];
|
3653 | if (oldBindings) {
|
3654 | binding.oldValue = oldBindings[i].value;
|
3655 | }
|
3656 | let hook = binding.dir[name];
|
3657 | if (hook) {
|
3658 | pauseTracking();
|
3659 | callWithAsyncErrorHandling(hook, instance, 8, [
|
3660 | vnode.el,
|
3661 | binding,
|
3662 | vnode,
|
3663 | prevVNode
|
3664 | ]);
|
3665 | resetTracking();
|
3666 | }
|
3667 | }
|
3668 | }
|
3669 |
|
3670 | const leaveCbKey = Symbol("_leaveCb");
|
3671 | const enterCbKey$1 = Symbol("_enterCb");
|
3672 | function useTransitionState() {
|
3673 | const state = {
|
3674 | isMounted: false,
|
3675 | isLeaving: false,
|
3676 | isUnmounting: false,
|
3677 | leavingVNodes: new Map()
|
3678 | };
|
3679 | onMounted(() => {
|
3680 | state.isMounted = true;
|
3681 | });
|
3682 | onBeforeUnmount(() => {
|
3683 | state.isUnmounting = true;
|
3684 | });
|
3685 | return state;
|
3686 | }
|
3687 | const TransitionHookValidator = [Function, Array];
|
3688 | const BaseTransitionPropsValidators = {
|
3689 | mode: String,
|
3690 | appear: Boolean,
|
3691 | persisted: Boolean,
|
3692 |
|
3693 | onBeforeEnter: TransitionHookValidator,
|
3694 | onEnter: TransitionHookValidator,
|
3695 | onAfterEnter: TransitionHookValidator,
|
3696 | onEnterCancelled: TransitionHookValidator,
|
3697 |
|
3698 | onBeforeLeave: TransitionHookValidator,
|
3699 | onLeave: TransitionHookValidator,
|
3700 | onAfterLeave: TransitionHookValidator,
|
3701 | onLeaveCancelled: TransitionHookValidator,
|
3702 |
|
3703 | onBeforeAppear: TransitionHookValidator,
|
3704 | onAppear: TransitionHookValidator,
|
3705 | onAfterAppear: TransitionHookValidator,
|
3706 | onAppearCancelled: TransitionHookValidator
|
3707 | };
|
3708 | const BaseTransitionImpl = {
|
3709 | name: `BaseTransition`,
|
3710 | props: BaseTransitionPropsValidators,
|
3711 | setup(props, { slots }) {
|
3712 | const instance = getCurrentInstance();
|
3713 | const state = useTransitionState();
|
3714 | return () => {
|
3715 | const children = slots.default && getTransitionRawChildren(slots.default(), true);
|
3716 | if (!children || !children.length) {
|
3717 | return;
|
3718 | }
|
3719 | let child = children[0];
|
3720 | if (children.length > 1) {
|
3721 | let hasFound = false;
|
3722 | for (const c of children) {
|
3723 | if (c.type !== Comment) {
|
3724 | if (hasFound) {
|
3725 | warn$1(
|
3726 | "<transition> can only be used on a single element or component. Use <transition-group> for lists."
|
3727 | );
|
3728 | break;
|
3729 | }
|
3730 | child = c;
|
3731 | hasFound = true;
|
3732 | }
|
3733 | }
|
3734 | }
|
3735 | const rawProps = toRaw(props);
|
3736 | const { mode } = rawProps;
|
3737 | if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
|
3738 | warn$1(`invalid <transition> mode: ${mode}`);
|
3739 | }
|
3740 | if (state.isLeaving) {
|
3741 | return emptyPlaceholder(child);
|
3742 | }
|
3743 | const innerChild = getKeepAliveChild(child);
|
3744 | if (!innerChild) {
|
3745 | return emptyPlaceholder(child);
|
3746 | }
|
3747 | const enterHooks = resolveTransitionHooks(
|
3748 | innerChild,
|
3749 | rawProps,
|
3750 | state,
|
3751 | instance
|
3752 | );
|
3753 | setTransitionHooks(innerChild, enterHooks);
|
3754 | const oldChild = instance.subTree;
|
3755 | const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
|
3756 | if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
|
3757 | const leavingHooks = resolveTransitionHooks(
|
3758 | oldInnerChild,
|
3759 | rawProps,
|
3760 | state,
|
3761 | instance
|
3762 | );
|
3763 | setTransitionHooks(oldInnerChild, leavingHooks);
|
3764 | if (mode === "out-in") {
|
3765 | state.isLeaving = true;
|
3766 | leavingHooks.afterLeave = () => {
|
3767 | state.isLeaving = false;
|
3768 | if (instance.update.active !== false) {
|
3769 | instance.effect.dirty = true;
|
3770 | instance.update();
|
3771 | }
|
3772 | };
|
3773 | return emptyPlaceholder(child);
|
3774 | } else if (mode === "in-out" && innerChild.type !== Comment) {
|
3775 | leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
|
3776 | const leavingVNodesCache = getLeavingNodesForType(
|
3777 | state,
|
3778 | oldInnerChild
|
3779 | );
|
3780 | leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
|
3781 | el[leaveCbKey] = () => {
|
3782 | earlyRemove();
|
3783 | el[leaveCbKey] = void 0;
|
3784 | delete enterHooks.delayedLeave;
|
3785 | };
|
3786 | enterHooks.delayedLeave = delayedLeave;
|
3787 | };
|
3788 | }
|
3789 | }
|
3790 | return child;
|
3791 | };
|
3792 | }
|
3793 | };
|
3794 | const BaseTransition = BaseTransitionImpl;
|
3795 | function getLeavingNodesForType(state, vnode) {
|
3796 | const { leavingVNodes } = state;
|
3797 | let leavingVNodesCache = leavingVNodes.get(vnode.type);
|
3798 | if (!leavingVNodesCache) {
|
3799 | leavingVNodesCache = Object.create(null);
|
3800 | leavingVNodes.set(vnode.type, leavingVNodesCache);
|
3801 | }
|
3802 | return leavingVNodesCache;
|
3803 | }
|
3804 | function resolveTransitionHooks(vnode, props, state, instance) {
|
3805 | const {
|
3806 | appear,
|
3807 | mode,
|
3808 | persisted = false,
|
3809 | onBeforeEnter,
|
3810 | onEnter,
|
3811 | onAfterEnter,
|
3812 | onEnterCancelled,
|
3813 | onBeforeLeave,
|
3814 | onLeave,
|
3815 | onAfterLeave,
|
3816 | onLeaveCancelled,
|
3817 | onBeforeAppear,
|
3818 | onAppear,
|
3819 | onAfterAppear,
|
3820 | onAppearCancelled
|
3821 | } = props;
|
3822 | const key = String(vnode.key);
|
3823 | const leavingVNodesCache = getLeavingNodesForType(state, vnode);
|
3824 | const callHook = (hook, args) => {
|
3825 | hook && callWithAsyncErrorHandling(
|
3826 | hook,
|
3827 | instance,
|
3828 | 9,
|
3829 | args
|
3830 | );
|
3831 | };
|
3832 | const callAsyncHook = (hook, args) => {
|
3833 | const done = args[1];
|
3834 | callHook(hook, args);
|
3835 | if (isArray(hook)) {
|
3836 | if (hook.every((hook2) => hook2.length <= 1))
|
3837 | done();
|
3838 | } else if (hook.length <= 1) {
|
3839 | done();
|
3840 | }
|
3841 | };
|
3842 | const hooks = {
|
3843 | mode,
|
3844 | persisted,
|
3845 | beforeEnter(el) {
|
3846 | let hook = onBeforeEnter;
|
3847 | if (!state.isMounted) {
|
3848 | if (appear) {
|
3849 | hook = onBeforeAppear || onBeforeEnter;
|
3850 | } else {
|
3851 | return;
|
3852 | }
|
3853 | }
|
3854 | if (el[leaveCbKey]) {
|
3855 | el[leaveCbKey](
|
3856 | true
|
3857 |
|
3858 | );
|
3859 | }
|
3860 | const leavingVNode = leavingVNodesCache[key];
|
3861 | if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
|
3862 | leavingVNode.el[leaveCbKey]();
|
3863 | }
|
3864 | callHook(hook, [el]);
|
3865 | },
|
3866 | enter(el) {
|
3867 | let hook = onEnter;
|
3868 | let afterHook = onAfterEnter;
|
3869 | let cancelHook = onEnterCancelled;
|
3870 | if (!state.isMounted) {
|
3871 | if (appear) {
|
3872 | hook = onAppear || onEnter;
|
3873 | afterHook = onAfterAppear || onAfterEnter;
|
3874 | cancelHook = onAppearCancelled || onEnterCancelled;
|
3875 | } else {
|
3876 | return;
|
3877 | }
|
3878 | }
|
3879 | let called = false;
|
3880 | const done = el[enterCbKey$1] = (cancelled) => {
|
3881 | if (called)
|
3882 | return;
|
3883 | called = true;
|
3884 | if (cancelled) {
|
3885 | callHook(cancelHook, [el]);
|
3886 | } else {
|
3887 | callHook(afterHook, [el]);
|
3888 | }
|
3889 | if (hooks.delayedLeave) {
|
3890 | hooks.delayedLeave();
|
3891 | }
|
3892 | el[enterCbKey$1] = void 0;
|
3893 | };
|
3894 | if (hook) {
|
3895 | callAsyncHook(hook, [el, done]);
|
3896 | } else {
|
3897 | done();
|
3898 | }
|
3899 | },
|
3900 | leave(el, remove) {
|
3901 | const key2 = String(vnode.key);
|
3902 | if (el[enterCbKey$1]) {
|
3903 | el[enterCbKey$1](
|
3904 | true
|
3905 |
|
3906 | );
|
3907 | }
|
3908 | if (state.isUnmounting) {
|
3909 | return remove();
|
3910 | }
|
3911 | callHook(onBeforeLeave, [el]);
|
3912 | let called = false;
|
3913 | const done = el[leaveCbKey] = (cancelled) => {
|
3914 | if (called)
|
3915 | return;
|
3916 | called = true;
|
3917 | remove();
|
3918 | if (cancelled) {
|
3919 | callHook(onLeaveCancelled, [el]);
|
3920 | } else {
|
3921 | callHook(onAfterLeave, [el]);
|
3922 | }
|
3923 | el[leaveCbKey] = void 0;
|
3924 | if (leavingVNodesCache[key2] === vnode) {
|
3925 | delete leavingVNodesCache[key2];
|
3926 | }
|
3927 | };
|
3928 | leavingVNodesCache[key2] = vnode;
|
3929 | if (onLeave) {
|
3930 | callAsyncHook(onLeave, [el, done]);
|
3931 | } else {
|
3932 | done();
|
3933 | }
|
3934 | },
|
3935 | clone(vnode2) {
|
3936 | return resolveTransitionHooks(vnode2, props, state, instance);
|
3937 | }
|
3938 | };
|
3939 | return hooks;
|
3940 | }
|
3941 | function emptyPlaceholder(vnode) {
|
3942 | if (isKeepAlive(vnode)) {
|
3943 | vnode = cloneVNode(vnode);
|
3944 | vnode.children = null;
|
3945 | return vnode;
|
3946 | }
|
3947 | }
|
3948 | function getKeepAliveChild(vnode) {
|
3949 | if (!isKeepAlive(vnode)) {
|
3950 | return vnode;
|
3951 | }
|
3952 | if (vnode.component) {
|
3953 | return vnode.component.subTree;
|
3954 | }
|
3955 | const { shapeFlag, children } = vnode;
|
3956 | if (children) {
|
3957 | if (shapeFlag & 16) {
|
3958 | return children[0];
|
3959 | }
|
3960 | if (shapeFlag & 32 && isFunction(children.default)) {
|
3961 | return children.default();
|
3962 | }
|
3963 | }
|
3964 | }
|
3965 | function setTransitionHooks(vnode, hooks) {
|
3966 | if (vnode.shapeFlag & 6 && vnode.component) {
|
3967 | setTransitionHooks(vnode.component.subTree, hooks);
|
3968 | } else if (vnode.shapeFlag & 128) {
|
3969 | vnode.ssContent.transition = hooks.clone(vnode.ssContent);
|
3970 | vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
|
3971 | } else {
|
3972 | vnode.transition = hooks;
|
3973 | }
|
3974 | }
|
3975 | function getTransitionRawChildren(children, keepComment = false, parentKey) {
|
3976 | let ret = [];
|
3977 | let keyedFragmentCount = 0;
|
3978 | for (let i = 0; i < children.length; i++) {
|
3979 | let child = children[i];
|
3980 | const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
|
3981 | if (child.type === Fragment) {
|
3982 | if (child.patchFlag & 128)
|
3983 | keyedFragmentCount++;
|
3984 | ret = ret.concat(
|
3985 | getTransitionRawChildren(child.children, keepComment, key)
|
3986 | );
|
3987 | } else if (keepComment || child.type !== Comment) {
|
3988 | ret.push(key != null ? cloneVNode(child, { key }) : child);
|
3989 | }
|
3990 | }
|
3991 | if (keyedFragmentCount > 1) {
|
3992 | for (let i = 0; i < ret.length; i++) {
|
3993 | ret[i].patchFlag = -2;
|
3994 | }
|
3995 | }
|
3996 | return ret;
|
3997 | }
|
3998 |
|
3999 |
|
4000 |
|
4001 | function defineComponent(options, extraOptions) {
|
4002 | return isFunction(options) ? (
|
4003 |
|
4004 |
|
4005 | (() => extend({ name: options.name }, extraOptions, { setup: options }))()
|
4006 | ) : options;
|
4007 | }
|
4008 |
|
4009 | const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
|
4010 |
|
4011 |
|
4012 | function defineAsyncComponent(source) {
|
4013 | if (isFunction(source)) {
|
4014 | source = { loader: source };
|
4015 | }
|
4016 | const {
|
4017 | loader,
|
4018 | loadingComponent,
|
4019 | errorComponent,
|
4020 | delay = 200,
|
4021 | timeout,
|
4022 |
|
4023 | suspensible = true,
|
4024 | onError: userOnError
|
4025 | } = source;
|
4026 | let pendingRequest = null;
|
4027 | let resolvedComp;
|
4028 | let retries = 0;
|
4029 | const retry = () => {
|
4030 | retries++;
|
4031 | pendingRequest = null;
|
4032 | return load();
|
4033 | };
|
4034 | const load = () => {
|
4035 | let thisRequest;
|
4036 | return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
|
4037 | err = err instanceof Error ? err : new Error(String(err));
|
4038 | if (userOnError) {
|
4039 | return new Promise((resolve, reject) => {
|
4040 | const userRetry = () => resolve(retry());
|
4041 | const userFail = () => reject(err);
|
4042 | userOnError(err, userRetry, userFail, retries + 1);
|
4043 | });
|
4044 | } else {
|
4045 | throw err;
|
4046 | }
|
4047 | }).then((comp) => {
|
4048 | if (thisRequest !== pendingRequest && pendingRequest) {
|
4049 | return pendingRequest;
|
4050 | }
|
4051 | if (!comp) {
|
4052 | warn$1(
|
4053 | `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
|
4054 | );
|
4055 | }
|
4056 | if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
|
4057 | comp = comp.default;
|
4058 | }
|
4059 | if (comp && !isObject(comp) && !isFunction(comp)) {
|
4060 | throw new Error(`Invalid async component load result: ${comp}`);
|
4061 | }
|
4062 | resolvedComp = comp;
|
4063 | return comp;
|
4064 | }));
|
4065 | };
|
4066 | return defineComponent({
|
4067 | name: "AsyncComponentWrapper",
|
4068 | __asyncLoader: load,
|
4069 | get __asyncResolved() {
|
4070 | return resolvedComp;
|
4071 | },
|
4072 | setup() {
|
4073 | const instance = currentInstance;
|
4074 | if (resolvedComp) {
|
4075 | return () => createInnerComp(resolvedComp, instance);
|
4076 | }
|
4077 | const onError = (err) => {
|
4078 | pendingRequest = null;
|
4079 | handleError(
|
4080 | err,
|
4081 | instance,
|
4082 | 13,
|
4083 | !errorComponent
|
4084 | );
|
4085 | };
|
4086 | if (suspensible && instance.suspense || false) {
|
4087 | return load().then((comp) => {
|
4088 | return () => createInnerComp(comp, instance);
|
4089 | }).catch((err) => {
|
4090 | onError(err);
|
4091 | return () => errorComponent ? createVNode(errorComponent, {
|
4092 | error: err
|
4093 | }) : null;
|
4094 | });
|
4095 | }
|
4096 | const loaded = ref(false);
|
4097 | const error = ref();
|
4098 | const delayed = ref(!!delay);
|
4099 | if (delay) {
|
4100 | setTimeout(() => {
|
4101 | delayed.value = false;
|
4102 | }, delay);
|
4103 | }
|
4104 | if (timeout != null) {
|
4105 | setTimeout(() => {
|
4106 | if (!loaded.value && !error.value) {
|
4107 | const err = new Error(
|
4108 | `Async component timed out after ${timeout}ms.`
|
4109 | );
|
4110 | onError(err);
|
4111 | error.value = err;
|
4112 | }
|
4113 | }, timeout);
|
4114 | }
|
4115 | load().then(() => {
|
4116 | loaded.value = true;
|
4117 | if (instance.parent && isKeepAlive(instance.parent.vnode)) {
|
4118 | instance.parent.effect.dirty = true;
|
4119 | queueJob(instance.parent.update);
|
4120 | }
|
4121 | }).catch((err) => {
|
4122 | onError(err);
|
4123 | error.value = err;
|
4124 | });
|
4125 | return () => {
|
4126 | if (loaded.value && resolvedComp) {
|
4127 | return createInnerComp(resolvedComp, instance);
|
4128 | } else if (error.value && errorComponent) {
|
4129 | return createVNode(errorComponent, {
|
4130 | error: error.value
|
4131 | });
|
4132 | } else if (loadingComponent && !delayed.value) {
|
4133 | return createVNode(loadingComponent);
|
4134 | }
|
4135 | };
|
4136 | }
|
4137 | });
|
4138 | }
|
4139 | function createInnerComp(comp, parent) {
|
4140 | const { ref: ref2, props, children, ce } = parent.vnode;
|
4141 | const vnode = createVNode(comp, props, children);
|
4142 | vnode.ref = ref2;
|
4143 | vnode.ce = ce;
|
4144 | delete parent.vnode.ce;
|
4145 | return vnode;
|
4146 | }
|
4147 |
|
4148 | const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
4149 | const KeepAliveImpl = {
|
4150 | name: `KeepAlive`,
|
4151 |
|
4152 |
|
4153 |
|
4154 | __isKeepAlive: true,
|
4155 | props: {
|
4156 | include: [String, RegExp, Array],
|
4157 | exclude: [String, RegExp, Array],
|
4158 | max: [String, Number]
|
4159 | },
|
4160 | setup(props, { slots }) {
|
4161 | const instance = getCurrentInstance();
|
4162 | const sharedContext = instance.ctx;
|
4163 | const cache = new Map();
|
4164 | const keys = new Set();
|
4165 | let current = null;
|
4166 | {
|
4167 | instance.__v_cache = cache;
|
4168 | }
|
4169 | const parentSuspense = instance.suspense;
|
4170 | const {
|
4171 | renderer: {
|
4172 | p: patch,
|
4173 | m: move,
|
4174 | um: _unmount,
|
4175 | o: { createElement }
|
4176 | }
|
4177 | } = sharedContext;
|
4178 | const storageContainer = createElement("div");
|
4179 | sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
|
4180 | const instance2 = vnode.component;
|
4181 | move(vnode, container, anchor, 0, parentSuspense);
|
4182 | patch(
|
4183 | instance2.vnode,
|
4184 | vnode,
|
4185 | container,
|
4186 | anchor,
|
4187 | instance2,
|
4188 | parentSuspense,
|
4189 | namespace,
|
4190 | vnode.slotScopeIds,
|
4191 | optimized
|
4192 | );
|
4193 | queuePostRenderEffect(() => {
|
4194 | instance2.isDeactivated = false;
|
4195 | if (instance2.a) {
|
4196 | invokeArrayFns(instance2.a);
|
4197 | }
|
4198 | const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
|
4199 | if (vnodeHook) {
|
4200 | invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
4201 | }
|
4202 | }, parentSuspense);
|
4203 | {
|
4204 | devtoolsComponentAdded(instance2);
|
4205 | }
|
4206 | };
|
4207 | sharedContext.deactivate = (vnode) => {
|
4208 | const instance2 = vnode.component;
|
4209 | move(vnode, storageContainer, null, 1, parentSuspense);
|
4210 | queuePostRenderEffect(() => {
|
4211 | if (instance2.da) {
|
4212 | invokeArrayFns(instance2.da);
|
4213 | }
|
4214 | const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
|
4215 | if (vnodeHook) {
|
4216 | invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
4217 | }
|
4218 | instance2.isDeactivated = true;
|
4219 | }, parentSuspense);
|
4220 | {
|
4221 | devtoolsComponentAdded(instance2);
|
4222 | }
|
4223 | };
|
4224 | function unmount(vnode) {
|
4225 | resetShapeFlag(vnode);
|
4226 | _unmount(vnode, instance, parentSuspense, true);
|
4227 | }
|
4228 | function pruneCache(filter) {
|
4229 | cache.forEach((vnode, key) => {
|
4230 | const name = getComponentName(vnode.type);
|
4231 | if (name && (!filter || !filter(name))) {
|
4232 | pruneCacheEntry(key);
|
4233 | }
|
4234 | });
|
4235 | }
|
4236 | function pruneCacheEntry(key) {
|
4237 | const cached = cache.get(key);
|
4238 | if (!current || !isSameVNodeType(cached, current)) {
|
4239 | unmount(cached);
|
4240 | } else if (current) {
|
4241 | resetShapeFlag(current);
|
4242 | }
|
4243 | cache.delete(key);
|
4244 | keys.delete(key);
|
4245 | }
|
4246 | watch(
|
4247 | () => [props.include, props.exclude],
|
4248 | ([include, exclude]) => {
|
4249 | include && pruneCache((name) => matches(include, name));
|
4250 | exclude && pruneCache((name) => !matches(exclude, name));
|
4251 | },
|
4252 |
|
4253 | { flush: "post", deep: true }
|
4254 | );
|
4255 | let pendingCacheKey = null;
|
4256 | const cacheSubtree = () => {
|
4257 | if (pendingCacheKey != null) {
|
4258 | cache.set(pendingCacheKey, getInnerChild(instance.subTree));
|
4259 | }
|
4260 | };
|
4261 | onMounted(cacheSubtree);
|
4262 | onUpdated(cacheSubtree);
|
4263 | onBeforeUnmount(() => {
|
4264 | cache.forEach((cached) => {
|
4265 | const { subTree, suspense } = instance;
|
4266 | const vnode = getInnerChild(subTree);
|
4267 | if (cached.type === vnode.type && cached.key === vnode.key) {
|
4268 | resetShapeFlag(vnode);
|
4269 | const da = vnode.component.da;
|
4270 | da && queuePostRenderEffect(da, suspense);
|
4271 | return;
|
4272 | }
|
4273 | unmount(cached);
|
4274 | });
|
4275 | });
|
4276 | return () => {
|
4277 | pendingCacheKey = null;
|
4278 | if (!slots.default) {
|
4279 | return current = null;
|
4280 | }
|
4281 | const children = slots.default();
|
4282 | const rawVNode = children[0];
|
4283 | if (children.length > 1) {
|
4284 | {
|
4285 | warn$1(`KeepAlive should contain exactly one component child.`);
|
4286 | }
|
4287 | current = null;
|
4288 | return children;
|
4289 | } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
|
4290 | current = null;
|
4291 | return rawVNode;
|
4292 | }
|
4293 | let vnode = getInnerChild(rawVNode);
|
4294 | const comp = vnode.type;
|
4295 | const name = getComponentName(
|
4296 | isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
|
4297 | );
|
4298 | const { include, exclude, max } = props;
|
4299 | if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
|
4300 | current = vnode;
|
4301 | return rawVNode;
|
4302 | }
|
4303 | const key = vnode.key == null ? comp : vnode.key;
|
4304 | const cachedVNode = cache.get(key);
|
4305 | if (vnode.el) {
|
4306 | vnode = cloneVNode(vnode);
|
4307 | if (rawVNode.shapeFlag & 128) {
|
4308 | rawVNode.ssContent = vnode;
|
4309 | }
|
4310 | }
|
4311 | pendingCacheKey = key;
|
4312 | if (cachedVNode) {
|
4313 | vnode.el = cachedVNode.el;
|
4314 | vnode.component = cachedVNode.component;
|
4315 | if (vnode.transition) {
|
4316 | setTransitionHooks(vnode, vnode.transition);
|
4317 | }
|
4318 | vnode.shapeFlag |= 512;
|
4319 | keys.delete(key);
|
4320 | keys.add(key);
|
4321 | } else {
|
4322 | keys.add(key);
|
4323 | if (max && keys.size > parseInt(max, 10)) {
|
4324 | pruneCacheEntry(keys.values().next().value);
|
4325 | }
|
4326 | }
|
4327 | vnode.shapeFlag |= 256;
|
4328 | current = vnode;
|
4329 | return isSuspense(rawVNode.type) ? rawVNode : vnode;
|
4330 | };
|
4331 | }
|
4332 | };
|
4333 | const KeepAlive = KeepAliveImpl;
|
4334 | function matches(pattern, name) {
|
4335 | if (isArray(pattern)) {
|
4336 | return pattern.some((p) => matches(p, name));
|
4337 | } else if (isString(pattern)) {
|
4338 | return pattern.split(",").includes(name);
|
4339 | } else if (isRegExp(pattern)) {
|
4340 | return pattern.test(name);
|
4341 | }
|
4342 | return false;
|
4343 | }
|
4344 | function onActivated(hook, target) {
|
4345 | registerKeepAliveHook(hook, "a", target);
|
4346 | }
|
4347 | function onDeactivated(hook, target) {
|
4348 | registerKeepAliveHook(hook, "da", target);
|
4349 | }
|
4350 | function registerKeepAliveHook(hook, type, target = currentInstance) {
|
4351 | const wrappedHook = hook.__wdc || (hook.__wdc = () => {
|
4352 | let current = target;
|
4353 | while (current) {
|
4354 | if (current.isDeactivated) {
|
4355 | return;
|
4356 | }
|
4357 | current = current.parent;
|
4358 | }
|
4359 | return hook();
|
4360 | });
|
4361 | injectHook(type, wrappedHook, target);
|
4362 | if (target) {
|
4363 | let current = target.parent;
|
4364 | while (current && current.parent) {
|
4365 | if (isKeepAlive(current.parent.vnode)) {
|
4366 | injectToKeepAliveRoot(wrappedHook, type, target, current);
|
4367 | }
|
4368 | current = current.parent;
|
4369 | }
|
4370 | }
|
4371 | }
|
4372 | function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
|
4373 | const injected = injectHook(
|
4374 | type,
|
4375 | hook,
|
4376 | keepAliveRoot,
|
4377 | true
|
4378 |
|
4379 | );
|
4380 | onUnmounted(() => {
|
4381 | remove(keepAliveRoot[type], injected);
|
4382 | }, target);
|
4383 | }
|
4384 | function resetShapeFlag(vnode) {
|
4385 | vnode.shapeFlag &= ~256;
|
4386 | vnode.shapeFlag &= ~512;
|
4387 | }
|
4388 | function getInnerChild(vnode) {
|
4389 | return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
|
4390 | }
|
4391 |
|
4392 | function injectHook(type, hook, target = currentInstance, prepend = false) {
|
4393 | if (target) {
|
4394 | const hooks = target[type] || (target[type] = []);
|
4395 | const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
|
4396 | if (target.isUnmounted) {
|
4397 | return;
|
4398 | }
|
4399 | pauseTracking();
|
4400 | const reset = setCurrentInstance(target);
|
4401 | const res = callWithAsyncErrorHandling(hook, target, type, args);
|
4402 | reset();
|
4403 | resetTracking();
|
4404 | return res;
|
4405 | });
|
4406 | if (prepend) {
|
4407 | hooks.unshift(wrappedHook);
|
4408 | } else {
|
4409 | hooks.push(wrappedHook);
|
4410 | }
|
4411 | return wrappedHook;
|
4412 | } else {
|
4413 | const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
|
4414 | warn$1(
|
4415 | `${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.` )
|
4416 | );
|
4417 | }
|
4418 | }
|
4419 | const createHook = (lifecycle) => (hook, target = currentInstance) => (
|
4420 |
|
4421 | (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target)
|
4422 | );
|
4423 | const onBeforeMount = createHook("bm");
|
4424 | const onMounted = createHook("m");
|
4425 | const onBeforeUpdate = createHook("bu");
|
4426 | const onUpdated = createHook("u");
|
4427 | const onBeforeUnmount = createHook("bum");
|
4428 | const onUnmounted = createHook("um");
|
4429 | const onServerPrefetch = createHook("sp");
|
4430 | const onRenderTriggered = createHook(
|
4431 | "rtg"
|
4432 | );
|
4433 | const onRenderTracked = createHook(
|
4434 | "rtc"
|
4435 | );
|
4436 | function onErrorCaptured(hook, target = currentInstance) {
|
4437 | injectHook("ec", hook, target);
|
4438 | }
|
4439 |
|
4440 | function renderList(source, renderItem, cache, index) {
|
4441 | let ret;
|
4442 | const cached = cache && cache[index];
|
4443 | if (isArray(source) || isString(source)) {
|
4444 | ret = new Array(source.length);
|
4445 | for (let i = 0, l = source.length; i < l; i++) {
|
4446 | ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
|
4447 | }
|
4448 | } else if (typeof source === "number") {
|
4449 | if (!Number.isInteger(source)) {
|
4450 | warn$1(`The v-for range expect an integer value but got ${source}.`);
|
4451 | }
|
4452 | ret = new Array(source);
|
4453 | for (let i = 0; i < source; i++) {
|
4454 | ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
|
4455 | }
|
4456 | } else if (isObject(source)) {
|
4457 | if (source[Symbol.iterator]) {
|
4458 | ret = Array.from(
|
4459 | source,
|
4460 | (item, i) => renderItem(item, i, void 0, cached && cached[i])
|
4461 | );
|
4462 | } else {
|
4463 | const keys = Object.keys(source);
|
4464 | ret = new Array(keys.length);
|
4465 | for (let i = 0, l = keys.length; i < l; i++) {
|
4466 | const key = keys[i];
|
4467 | ret[i] = renderItem(source[key], key, i, cached && cached[i]);
|
4468 | }
|
4469 | }
|
4470 | } else {
|
4471 | ret = [];
|
4472 | }
|
4473 | if (cache) {
|
4474 | cache[index] = ret;
|
4475 | }
|
4476 | return ret;
|
4477 | }
|
4478 |
|
4479 | function createSlots(slots, dynamicSlots) {
|
4480 | for (let i = 0; i < dynamicSlots.length; i++) {
|
4481 | const slot = dynamicSlots[i];
|
4482 | if (isArray(slot)) {
|
4483 | for (let j = 0; j < slot.length; j++) {
|
4484 | slots[slot[j].name] = slot[j].fn;
|
4485 | }
|
4486 | } else if (slot) {
|
4487 | slots[slot.name] = slot.key ? (...args) => {
|
4488 | const res = slot.fn(...args);
|
4489 | if (res)
|
4490 | res.key = slot.key;
|
4491 | return res;
|
4492 | } : slot.fn;
|
4493 | }
|
4494 | }
|
4495 | return slots;
|
4496 | }
|
4497 |
|
4498 | function renderSlot(slots, name, props = {}, fallback, noSlotted) {
|
4499 | if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
|
4500 | if (name !== "default")
|
4501 | props.name = name;
|
4502 | return createVNode("slot", props, fallback && fallback());
|
4503 | }
|
4504 | let slot = slots[name];
|
4505 | if (slot && slot.length > 1) {
|
4506 | warn$1(
|
4507 | `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.`
|
4508 | );
|
4509 | slot = () => [];
|
4510 | }
|
4511 | if (slot && slot._c) {
|
4512 | slot._d = false;
|
4513 | }
|
4514 | openBlock();
|
4515 | const validSlotContent = slot && ensureValidVNode(slot(props));
|
4516 | const rendered = createBlock(
|
4517 | Fragment,
|
4518 | {
|
4519 | key: props.key ||
|
4520 |
|
4521 | validSlotContent && validSlotContent.key || `_${name}`
|
4522 | },
|
4523 | validSlotContent || (fallback ? fallback() : []),
|
4524 | validSlotContent && slots._ === 1 ? 64 : -2
|
4525 | );
|
4526 | if (!noSlotted && rendered.scopeId) {
|
4527 | rendered.slotScopeIds = [rendered.scopeId + "-s"];
|
4528 | }
|
4529 | if (slot && slot._c) {
|
4530 | slot._d = true;
|
4531 | }
|
4532 | return rendered;
|
4533 | }
|
4534 | function ensureValidVNode(vnodes) {
|
4535 | return vnodes.some((child) => {
|
4536 | if (!isVNode(child))
|
4537 | return true;
|
4538 | if (child.type === Comment)
|
4539 | return false;
|
4540 | if (child.type === Fragment && !ensureValidVNode(child.children))
|
4541 | return false;
|
4542 | return true;
|
4543 | }) ? vnodes : null;
|
4544 | }
|
4545 |
|
4546 | function toHandlers(obj, preserveCaseIfNecessary) {
|
4547 | const ret = {};
|
4548 | if (!isObject(obj)) {
|
4549 | warn$1(`v-on with no argument expects an object value.`);
|
4550 | return ret;
|
4551 | }
|
4552 | for (const key in obj) {
|
4553 | ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : toHandlerKey(key)] = obj[key];
|
4554 | }
|
4555 | return ret;
|
4556 | }
|
4557 |
|
4558 | const getPublicInstance = (i) => {
|
4559 | if (!i)
|
4560 | return null;
|
4561 | if (isStatefulComponent(i))
|
4562 | return getExposeProxy(i) || i.proxy;
|
4563 | return getPublicInstance(i.parent);
|
4564 | };
|
4565 | const publicPropertiesMap = (
|
4566 |
|
4567 |
|
4568 | extend( Object.create(null), {
|
4569 | $: (i) => i,
|
4570 | $el: (i) => i.vnode.el,
|
4571 | $data: (i) => i.data,
|
4572 | $props: (i) => shallowReadonly(i.props) ,
|
4573 | $attrs: (i) => shallowReadonly(i.attrs) ,
|
4574 | $slots: (i) => shallowReadonly(i.slots) ,
|
4575 | $refs: (i) => shallowReadonly(i.refs) ,
|
4576 | $parent: (i) => getPublicInstance(i.parent),
|
4577 | $root: (i) => getPublicInstance(i.root),
|
4578 | $emit: (i) => i.emit,
|
4579 | $options: (i) => resolveMergedOptions(i) ,
|
4580 | $forceUpdate: (i) => i.f || (i.f = () => {
|
4581 | i.effect.dirty = true;
|
4582 | queueJob(i.update);
|
4583 | }),
|
4584 | $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
|
4585 | $watch: (i) => instanceWatch.bind(i)
|
4586 | })
|
4587 | );
|
4588 | const isReservedPrefix = (key) => key === "_" || key === "$";
|
4589 | const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
|
4590 | const PublicInstanceProxyHandlers = {
|
4591 | get({ _: instance }, key) {
|
4592 | if (key === "__v_skip") {
|
4593 | return true;
|
4594 | }
|
4595 | const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
4596 | if (key === "__isVue") {
|
4597 | return true;
|
4598 | }
|
4599 | let normalizedProps;
|
4600 | if (key[0] !== "$") {
|
4601 | const n = accessCache[key];
|
4602 | if (n !== void 0) {
|
4603 | switch (n) {
|
4604 | case 1 :
|
4605 | return setupState[key];
|
4606 | case 2 :
|
4607 | return data[key];
|
4608 | case 4 :
|
4609 | return ctx[key];
|
4610 | case 3 :
|
4611 | return props[key];
|
4612 | }
|
4613 | } else if (hasSetupBinding(setupState, key)) {
|
4614 | accessCache[key] = 1 ;
|
4615 | return setupState[key];
|
4616 | } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
4617 | accessCache[key] = 2 ;
|
4618 | return data[key];
|
4619 | } else if (
|
4620 |
|
4621 |
|
4622 | (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
|
4623 | ) {
|
4624 | accessCache[key] = 3 ;
|
4625 | return props[key];
|
4626 | } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
4627 | accessCache[key] = 4 ;
|
4628 | return ctx[key];
|
4629 | } else if (shouldCacheAccess) {
|
4630 | accessCache[key] = 0 ;
|
4631 | }
|
4632 | }
|
4633 | const publicGetter = publicPropertiesMap[key];
|
4634 | let cssModule, globalProperties;
|
4635 | if (publicGetter) {
|
4636 | if (key === "$attrs") {
|
4637 | track(instance.attrs, "get", "");
|
4638 | markAttrsAccessed();
|
4639 | } else if (key === "$slots") {
|
4640 | track(instance, "get", key);
|
4641 | }
|
4642 | return publicGetter(instance);
|
4643 | } else if (
|
4644 |
|
4645 | (cssModule = type.__cssModules) && (cssModule = cssModule[key])
|
4646 | ) {
|
4647 | return cssModule;
|
4648 | } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
4649 | accessCache[key] = 4 ;
|
4650 | return ctx[key];
|
4651 | } else if (
|
4652 |
|
4653 | globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
|
4654 | ) {
|
4655 | {
|
4656 | return globalProperties[key];
|
4657 | }
|
4658 | } else if (currentRenderingInstance && (!isString(key) ||
|
4659 |
|
4660 | key.indexOf("__v") !== 0)) {
|
4661 | if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
|
4662 | warn$1(
|
4663 | `Property ${JSON.stringify(
|
4664 | key
|
4665 | )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
|
4666 | );
|
4667 | } else if (instance === currentRenderingInstance) {
|
4668 | warn$1(
|
4669 | `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
|
4670 | );
|
4671 | }
|
4672 | }
|
4673 | },
|
4674 | set({ _: instance }, key, value) {
|
4675 | const { data, setupState, ctx } = instance;
|
4676 | if (hasSetupBinding(setupState, key)) {
|
4677 | setupState[key] = value;
|
4678 | return true;
|
4679 | } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
|
4680 | warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
|
4681 | return false;
|
4682 | } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
4683 | data[key] = value;
|
4684 | return true;
|
4685 | } else if (hasOwn(instance.props, key)) {
|
4686 | warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
|
4687 | return false;
|
4688 | }
|
4689 | if (key[0] === "$" && key.slice(1) in instance) {
|
4690 | warn$1(
|
4691 | `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
|
4692 | );
|
4693 | return false;
|
4694 | } else {
|
4695 | if (key in instance.appContext.config.globalProperties) {
|
4696 | Object.defineProperty(ctx, key, {
|
4697 | enumerable: true,
|
4698 | configurable: true,
|
4699 | value
|
4700 | });
|
4701 | } else {
|
4702 | ctx[key] = value;
|
4703 | }
|
4704 | }
|
4705 | return true;
|
4706 | },
|
4707 | has({
|
4708 | _: { data, setupState, accessCache, ctx, appContext, propsOptions }
|
4709 | }, key) {
|
4710 | let normalizedProps;
|
4711 | 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);
|
4712 | },
|
4713 | defineProperty(target, key, descriptor) {
|
4714 | if (descriptor.get != null) {
|
4715 | target._.accessCache[key] = 0;
|
4716 | } else if (hasOwn(descriptor, "value")) {
|
4717 | this.set(target, key, descriptor.value, null);
|
4718 | }
|
4719 | return Reflect.defineProperty(target, key, descriptor);
|
4720 | }
|
4721 | };
|
4722 | {
|
4723 | PublicInstanceProxyHandlers.ownKeys = (target) => {
|
4724 | warn$1(
|
4725 | `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
|
4726 | );
|
4727 | return Reflect.ownKeys(target);
|
4728 | };
|
4729 | }
|
4730 | const RuntimeCompiledPublicInstanceProxyHandlers = extend(
|
4731 | {},
|
4732 | PublicInstanceProxyHandlers,
|
4733 | {
|
4734 | get(target, key) {
|
4735 | if (key === Symbol.unscopables) {
|
4736 | return;
|
4737 | }
|
4738 | return PublicInstanceProxyHandlers.get(target, key, target);
|
4739 | },
|
4740 | has(_, key) {
|
4741 | const has = key[0] !== "_" && !isGloballyAllowed(key);
|
4742 | if (!has && PublicInstanceProxyHandlers.has(_, key)) {
|
4743 | warn$1(
|
4744 | `Property ${JSON.stringify(
|
4745 | key
|
4746 | )} should not start with _ which is a reserved prefix for Vue internals.`
|
4747 | );
|
4748 | }
|
4749 | return has;
|
4750 | }
|
4751 | }
|
4752 | );
|
4753 | function createDevRenderContext(instance) {
|
4754 | const target = {};
|
4755 | Object.defineProperty(target, `_`, {
|
4756 | configurable: true,
|
4757 | enumerable: false,
|
4758 | get: () => instance
|
4759 | });
|
4760 | Object.keys(publicPropertiesMap).forEach((key) => {
|
4761 | Object.defineProperty(target, key, {
|
4762 | configurable: true,
|
4763 | enumerable: false,
|
4764 | get: () => publicPropertiesMap[key](instance),
|
4765 | // intercepted by the proxy so no need for implementation,
|
4766 | // but needed to prevent set errors
|
4767 | set: NOOP
|
4768 | });
|
4769 | });
|
4770 | return target;
|
4771 | }
|
4772 | function exposePropsOnRenderContext(instance) {
|
4773 | const {
|
4774 | ctx,
|
4775 | propsOptions: [propsOptions]
|
4776 | } = instance;
|
4777 | if (propsOptions) {
|
4778 | Object.keys(propsOptions).forEach((key) => {
|
4779 | Object.defineProperty(ctx, key, {
|
4780 | enumerable: true,
|
4781 | configurable: true,
|
4782 | get: () => instance.props[key],
|
4783 | set: NOOP
|
4784 | });
|
4785 | });
|
4786 | }
|
4787 | }
|
4788 | function exposeSetupStateOnRenderContext(instance) {
|
4789 | const { ctx, setupState } = instance;
|
4790 | Object.keys(toRaw(setupState)).forEach((key) => {
|
4791 | if (!setupState.__isScriptSetup) {
|
4792 | if (isReservedPrefix(key[0])) {
|
4793 | warn$1(
|
4794 | `setup() return property ${JSON.stringify(
|
4795 | key
|
4796 | )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`
|
4797 | );
|
4798 | return;
|
4799 | }
|
4800 | Object.defineProperty(ctx, key, {
|
4801 | enumerable: true,
|
4802 | configurable: true,
|
4803 | get: () => setupState[key],
|
4804 | set: NOOP
|
4805 | });
|
4806 | }
|
4807 | });
|
4808 | }
|
4809 |
|
4810 | const warnRuntimeUsage = (method) => warn$1(
|
4811 | `${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.`
|
4812 | );
|
4813 | function defineProps() {
|
4814 | {
|
4815 | warnRuntimeUsage(`defineProps`);
|
4816 | }
|
4817 | return null;
|
4818 | }
|
4819 | function defineEmits() {
|
4820 | {
|
4821 | warnRuntimeUsage(`defineEmits`);
|
4822 | }
|
4823 | return null;
|
4824 | }
|
4825 | function defineExpose(exposed) {
|
4826 | {
|
4827 | warnRuntimeUsage(`defineExpose`);
|
4828 | }
|
4829 | }
|
4830 | function defineOptions(options) {
|
4831 | {
|
4832 | warnRuntimeUsage(`defineOptions`);
|
4833 | }
|
4834 | }
|
4835 | function defineSlots() {
|
4836 | {
|
4837 | warnRuntimeUsage(`defineSlots`);
|
4838 | }
|
4839 | return null;
|
4840 | }
|
4841 | function defineModel() {
|
4842 | {
|
4843 | warnRuntimeUsage("defineModel");
|
4844 | }
|
4845 | }
|
4846 | function withDefaults(props, defaults) {
|
4847 | {
|
4848 | warnRuntimeUsage(`withDefaults`);
|
4849 | }
|
4850 | return null;
|
4851 | }
|
4852 | function useSlots() {
|
4853 | return getContext().slots;
|
4854 | }
|
4855 | function useAttrs() {
|
4856 | return getContext().attrs;
|
4857 | }
|
4858 | function getContext() {
|
4859 | const i = getCurrentInstance();
|
4860 | if (!i) {
|
4861 | warn$1(`useContext() called without active instance.`);
|
4862 | }
|
4863 | return i.setupContext || (i.setupContext = createSetupContext(i));
|
4864 | }
|
4865 | function normalizePropsOrEmits(props) {
|
4866 | return isArray(props) ? props.reduce(
|
4867 | (normalized, p) => (normalized[p] = null, normalized),
|
4868 | {}
|
4869 | ) : props;
|
4870 | }
|
4871 | function mergeDefaults(raw, defaults) {
|
4872 | const props = normalizePropsOrEmits(raw);
|
4873 | for (const key in defaults) {
|
4874 | if (key.startsWith("__skip"))
|
4875 | continue;
|
4876 | let opt = props[key];
|
4877 | if (opt) {
|
4878 | if (isArray(opt) || isFunction(opt)) {
|
4879 | opt = props[key] = { type: opt, default: defaults[key] };
|
4880 | } else {
|
4881 | opt.default = defaults[key];
|
4882 | }
|
4883 | } else if (opt === null) {
|
4884 | opt = props[key] = { default: defaults[key] };
|
4885 | } else {
|
4886 | warn$1(`props default key "${key}" has no corresponding declaration.`);
|
4887 | }
|
4888 | if (opt && defaults[`__skip_${key}`]) {
|
4889 | opt.skipFactory = true;
|
4890 | }
|
4891 | }
|
4892 | return props;
|
4893 | }
|
4894 | function mergeModels(a, b) {
|
4895 | if (!a || !b)
|
4896 | return a || b;
|
4897 | if (isArray(a) && isArray(b))
|
4898 | return a.concat(b);
|
4899 | return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
|
4900 | }
|
4901 | function createPropsRestProxy(props, excludedKeys) {
|
4902 | const ret = {};
|
4903 | for (const key in props) {
|
4904 | if (!excludedKeys.includes(key)) {
|
4905 | Object.defineProperty(ret, key, {
|
4906 | enumerable: true,
|
4907 | get: () => props[key]
|
4908 | });
|
4909 | }
|
4910 | }
|
4911 | return ret;
|
4912 | }
|
4913 | function withAsyncContext(getAwaitable) {
|
4914 | const ctx = getCurrentInstance();
|
4915 | if (!ctx) {
|
4916 | warn$1(
|
4917 | `withAsyncContext called without active current instance. This is likely a bug.`
|
4918 | );
|
4919 | }
|
4920 | let awaitable = getAwaitable();
|
4921 | unsetCurrentInstance();
|
4922 | if (isPromise(awaitable)) {
|
4923 | awaitable = awaitable.catch((e) => {
|
4924 | setCurrentInstance(ctx);
|
4925 | throw e;
|
4926 | });
|
4927 | }
|
4928 | return [awaitable, () => setCurrentInstance(ctx)];
|
4929 | }
|
4930 |
|
4931 | function createDuplicateChecker() {
|
4932 | const cache = /* @__PURE__ */ Object.create(null);
|
4933 | return (type, key) => {
|
4934 | if (cache[key]) {
|
4935 | warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
|
4936 | } else {
|
4937 | cache[key] = type;
|
4938 | }
|
4939 | };
|
4940 | }
|
4941 | let shouldCacheAccess = true;
|
4942 | function applyOptions(instance) {
|
4943 | const options = resolveMergedOptions(instance);
|
4944 | const publicThis = instance.proxy;
|
4945 | const ctx = instance.ctx;
|
4946 | shouldCacheAccess = false;
|
4947 | if (options.beforeCreate) {
|
4948 | callHook$1(options.beforeCreate, instance, "bc");
|
4949 | }
|
4950 | const {
|
4951 | // state
|
4952 | data: dataOptions,
|
4953 | computed: computedOptions,
|
4954 | methods,
|
4955 | watch: watchOptions,
|
4956 | provide: provideOptions,
|
4957 | inject: injectOptions,
|
4958 | // lifecycle
|
4959 | created,
|
4960 | beforeMount,
|
4961 | mounted,
|
4962 | beforeUpdate,
|
4963 | updated,
|
4964 | activated,
|
4965 | deactivated,
|
4966 | beforeDestroy,
|
4967 | beforeUnmount,
|
4968 | destroyed,
|
4969 | unmounted,
|
4970 | render,
|
4971 | renderTracked,
|
4972 | renderTriggered,
|
4973 | errorCaptured,
|
4974 | serverPrefetch,
|
4975 | // public API
|
4976 | expose,
|
4977 | inheritAttrs,
|
4978 | // assets
|
4979 | components,
|
4980 | directives,
|
4981 | filters
|
4982 | } = options;
|
4983 | const checkDuplicateProperties = createDuplicateChecker() ;
|
4984 | {
|
4985 | const [propsOptions] = instance.propsOptions;
|
4986 | if (propsOptions) {
|
4987 | for (const key in propsOptions) {
|
4988 | checkDuplicateProperties("Props" /* PROPS */, key);
|
4989 | }
|
4990 | }
|
4991 | }
|
4992 | if (injectOptions) {
|
4993 | resolveInjections(injectOptions, ctx, checkDuplicateProperties);
|
4994 | }
|
4995 | if (methods) {
|
4996 | for (const key in methods) {
|
4997 | const methodHandler = methods[key];
|
4998 | if (isFunction(methodHandler)) {
|
4999 | {
|
5000 | Object.defineProperty(ctx, key, {
|
5001 | value: methodHandler.bind(publicThis),
|
5002 | configurable: true,
|
5003 | enumerable: true,
|
5004 | writable: true
|
5005 | });
|
5006 | }
|
5007 | {
|
5008 | checkDuplicateProperties("Methods" /* METHODS */, key);
|
5009 | }
|
5010 | } else {
|
5011 | warn$1(
|
5012 | `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
|
5013 | );
|
5014 | }
|
5015 | }
|
5016 | }
|
5017 | if (dataOptions) {
|
5018 | if (!isFunction(dataOptions)) {
|
5019 | warn$1(
|
5020 | `The data option must be a function. Plain object usage is no longer supported.`
|
5021 | );
|
5022 | }
|
5023 | const data = dataOptions.call(publicThis, publicThis);
|
5024 | if (isPromise(data)) {
|
5025 | warn$1(
|
5026 | `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
|
5027 | );
|
5028 | }
|
5029 | if (!isObject(data)) {
|
5030 | warn$1(`data() should return an object.`);
|
5031 | } else {
|
5032 | instance.data = reactive(data);
|
5033 | {
|
5034 | for (const key in data) {
|
5035 | checkDuplicateProperties("Data" , key);
|
5036 | if (!isReservedPrefix(key[0])) {
|
5037 | Object.defineProperty(ctx, key, {
|
5038 | configurable: true,
|
5039 | enumerable: true,
|
5040 | get: () => data[key],
|
5041 | set: NOOP
|
5042 | });
|
5043 | }
|
5044 | }
|
5045 | }
|
5046 | }
|
5047 | }
|
5048 | shouldCacheAccess = true;
|
5049 | if (computedOptions) {
|
5050 | for (const key in computedOptions) {
|
5051 | const opt = computedOptions[key];
|
5052 | const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
|
5053 | if (get === NOOP) {
|
5054 | warn$1(`Computed property "${key}" has no getter.`);
|
5055 | }
|
5056 | const set = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : () => {
|
5057 | warn$1(
|
5058 | `Write operation failed: computed property "${key}" is readonly.`
|
5059 | );
|
5060 | } ;
|
5061 | const c = computed({
|
5062 | get,
|
5063 | set
|
5064 | });
|
5065 | Object.defineProperty(ctx, key, {
|
5066 | enumerable: true,
|
5067 | configurable: true,
|
5068 | get: () => c.value,
|
5069 | set: (v) => c.value = v
|
5070 | });
|
5071 | {
|
5072 | checkDuplicateProperties("Computed" , key);
|
5073 | }
|
5074 | }
|
5075 | }
|
5076 | if (watchOptions) {
|
5077 | for (const key in watchOptions) {
|
5078 | createWatcher(watchOptions[key], ctx, publicThis, key);
|
5079 | }
|
5080 | }
|
5081 | if (provideOptions) {
|
5082 | const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
|
5083 | Reflect.ownKeys(provides).forEach((key) => {
|
5084 | provide(key, provides[key]);
|
5085 | });
|
5086 | }
|
5087 | if (created) {
|
5088 | callHook$1(created, instance, "c");
|
5089 | }
|
5090 | function registerLifecycleHook(register, hook) {
|
5091 | if (isArray(hook)) {
|
5092 | hook.forEach((_hook) => register(_hook.bind(publicThis)));
|
5093 | } else if (hook) {
|
5094 | register(hook.bind(publicThis));
|
5095 | }
|
5096 | }
|
5097 | registerLifecycleHook(onBeforeMount, beforeMount);
|
5098 | registerLifecycleHook(onMounted, mounted);
|
5099 | registerLifecycleHook(onBeforeUpdate, beforeUpdate);
|
5100 | registerLifecycleHook(onUpdated, updated);
|
5101 | registerLifecycleHook(onActivated, activated);
|
5102 | registerLifecycleHook(onDeactivated, deactivated);
|
5103 | registerLifecycleHook(onErrorCaptured, errorCaptured);
|
5104 | registerLifecycleHook(onRenderTracked, renderTracked);
|
5105 | registerLifecycleHook(onRenderTriggered, renderTriggered);
|
5106 | registerLifecycleHook(onBeforeUnmount, beforeUnmount);
|
5107 | registerLifecycleHook(onUnmounted, unmounted);
|
5108 | registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
5109 | if (isArray(expose)) {
|
5110 | if (expose.length) {
|
5111 | const exposed = instance.exposed || (instance.exposed = {});
|
5112 | expose.forEach((key) => {
|
5113 | Object.defineProperty(exposed, key, {
|
5114 | get: () => publicThis[key],
|
5115 | set: (val) => publicThis[key] = val
|
5116 | });
|
5117 | });
|
5118 | } else if (!instance.exposed) {
|
5119 | instance.exposed = {};
|
5120 | }
|
5121 | }
|
5122 | if (render && instance.render === NOOP) {
|
5123 | instance.render = render;
|
5124 | }
|
5125 | if (inheritAttrs != null) {
|
5126 | instance.inheritAttrs = inheritAttrs;
|
5127 | }
|
5128 | if (components)
|
5129 | instance.components = components;
|
5130 | if (directives)
|
5131 | instance.directives = directives;
|
5132 | }
|
5133 | function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
|
5134 | if (isArray(injectOptions)) {
|
5135 | injectOptions = normalizeInject(injectOptions);
|
5136 | }
|
5137 | for (const key in injectOptions) {
|
5138 | const opt = injectOptions[key];
|
5139 | let injected;
|
5140 | if (isObject(opt)) {
|
5141 | if ("default" in opt) {
|
5142 | injected = inject(
|
5143 | opt.from || key,
|
5144 | opt.default,
|
5145 | true
|
5146 | );
|
5147 | } else {
|
5148 | injected = inject(opt.from || key);
|
5149 | }
|
5150 | } else {
|
5151 | injected = inject(opt);
|
5152 | }
|
5153 | if (isRef(injected)) {
|
5154 | Object.defineProperty(ctx, key, {
|
5155 | enumerable: true,
|
5156 | configurable: true,
|
5157 | get: () => injected.value,
|
5158 | set: (v) => injected.value = v
|
5159 | });
|
5160 | } else {
|
5161 | ctx[key] = injected;
|
5162 | }
|
5163 | {
|
5164 | checkDuplicateProperties("Inject" , key);
|
5165 | }
|
5166 | }
|
5167 | }
|
5168 | function callHook$1(hook, instance, type) {
|
5169 | callWithAsyncErrorHandling(
|
5170 | isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
|
5171 | instance,
|
5172 | type
|
5173 | );
|
5174 | }
|
5175 | function createWatcher(raw, ctx, publicThis, key) {
|
5176 | const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
|
5177 | if (isString(raw)) {
|
5178 | const handler = ctx[raw];
|
5179 | if (isFunction(handler)) {
|
5180 | watch(getter, handler);
|
5181 | } else {
|
5182 | warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
|
5183 | }
|
5184 | } else if (isFunction(raw)) {
|
5185 | watch(getter, raw.bind(publicThis));
|
5186 | } else if (isObject(raw)) {
|
5187 | if (isArray(raw)) {
|
5188 | raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
|
5189 | } else {
|
5190 | const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
|
5191 | if (isFunction(handler)) {
|
5192 | watch(getter, handler, raw);
|
5193 | } else {
|
5194 | warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
|
5195 | }
|
5196 | }
|
5197 | } else {
|
5198 | warn$1(`Invalid watch option: "${key}"`, raw);
|
5199 | }
|
5200 | }
|
5201 | function resolveMergedOptions(instance) {
|
5202 | const base = instance.type;
|
5203 | const { mixins, extends: extendsOptions } = base;
|
5204 | const {
|
5205 | mixins: globalMixins,
|
5206 | optionsCache: cache,
|
5207 | config: { optionMergeStrategies }
|
5208 | } = instance.appContext;
|
5209 | const cached = cache.get(base);
|
5210 | let resolved;
|
5211 | if (cached) {
|
5212 | resolved = cached;
|
5213 | } else if (!globalMixins.length && !mixins && !extendsOptions) {
|
5214 | {
|
5215 | resolved = base;
|
5216 | }
|
5217 | } else {
|
5218 | resolved = {};
|
5219 | if (globalMixins.length) {
|
5220 | globalMixins.forEach(
|
5221 | (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
|
5222 | );
|
5223 | }
|
5224 | mergeOptions(resolved, base, optionMergeStrategies);
|
5225 | }
|
5226 | if (isObject(base)) {
|
5227 | cache.set(base, resolved);
|
5228 | }
|
5229 | return resolved;
|
5230 | }
|
5231 | function mergeOptions(to, from, strats, asMixin = false) {
|
5232 | const { mixins, extends: extendsOptions } = from;
|
5233 | if (extendsOptions) {
|
5234 | mergeOptions(to, extendsOptions, strats, true);
|
5235 | }
|
5236 | if (mixins) {
|
5237 | mixins.forEach(
|
5238 | (m) => mergeOptions(to, m, strats, true)
|
5239 | );
|
5240 | }
|
5241 | for (const key in from) {
|
5242 | if (asMixin && key === "expose") {
|
5243 | warn$1(
|
5244 | `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
|
5245 | );
|
5246 | } else {
|
5247 | const strat = internalOptionMergeStrats[key] || strats && strats[key];
|
5248 | to[key] = strat ? strat(to[key], from[key]) : from[key];
|
5249 | }
|
5250 | }
|
5251 | return to;
|
5252 | }
|
5253 | const internalOptionMergeStrats = {
|
5254 | data: mergeDataFn,
|
5255 | props: mergeEmitsOrPropsOptions,
|
5256 | emits: mergeEmitsOrPropsOptions,
|
5257 |
|
5258 | methods: mergeObjectOptions,
|
5259 | computed: mergeObjectOptions,
|
5260 |
|
5261 | beforeCreate: mergeAsArray$1,
|
5262 | created: mergeAsArray$1,
|
5263 | beforeMount: mergeAsArray$1,
|
5264 | mounted: mergeAsArray$1,
|
5265 | beforeUpdate: mergeAsArray$1,
|
5266 | updated: mergeAsArray$1,
|
5267 | beforeDestroy: mergeAsArray$1,
|
5268 | beforeUnmount: mergeAsArray$1,
|
5269 | destroyed: mergeAsArray$1,
|
5270 | unmounted: mergeAsArray$1,
|
5271 | activated: mergeAsArray$1,
|
5272 | deactivated: mergeAsArray$1,
|
5273 | errorCaptured: mergeAsArray$1,
|
5274 | serverPrefetch: mergeAsArray$1,
|
5275 |
|
5276 | components: mergeObjectOptions,
|
5277 | directives: mergeObjectOptions,
|
5278 |
|
5279 | watch: mergeWatchOptions,
|
5280 |
|
5281 | provide: mergeDataFn,
|
5282 | inject: mergeInject
|
5283 | };
|
5284 | function mergeDataFn(to, from) {
|
5285 | if (!from) {
|
5286 | return to;
|
5287 | }
|
5288 | if (!to) {
|
5289 | return from;
|
5290 | }
|
5291 | return function mergedDataFn() {
|
5292 | return (extend)(
|
5293 | isFunction(to) ? to.call(this, this) : to,
|
5294 | isFunction(from) ? from.call(this, this) : from
|
5295 | );
|
5296 | };
|
5297 | }
|
5298 | function mergeInject(to, from) {
|
5299 | return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
5300 | }
|
5301 | function normalizeInject(raw) {
|
5302 | if (isArray(raw)) {
|
5303 | const res = {};
|
5304 | for (let i = 0; i < raw.length; i++) {
|
5305 | res[raw[i]] = raw[i];
|
5306 | }
|
5307 | return res;
|
5308 | }
|
5309 | return raw;
|
5310 | }
|
5311 | function mergeAsArray$1(to, from) {
|
5312 | return to ? [...new Set([].concat(to, from))] : from;
|
5313 | }
|
5314 | function mergeObjectOptions(to, from) {
|
5315 | return to ? extend( Object.create(null), to, from) : from;
|
5316 | }
|
5317 | function mergeEmitsOrPropsOptions(to, from) {
|
5318 | if (to) {
|
5319 | if (isArray(to) && isArray(from)) {
|
5320 | return [... new Set([...to, ...from])];
|
5321 | }
|
5322 | return extend(
|
5323 | Object.create(null),
|
5324 | normalizePropsOrEmits(to),
|
5325 | normalizePropsOrEmits(from != null ? from : {})
|
5326 | );
|
5327 | } else {
|
5328 | return from;
|
5329 | }
|
5330 | }
|
5331 | function mergeWatchOptions(to, from) {
|
5332 | if (!to)
|
5333 | return from;
|
5334 | if (!from)
|
5335 | return to;
|
5336 | const merged = extend( Object.create(null), to);
|
5337 | for (const key in from) {
|
5338 | merged[key] = mergeAsArray$1(to[key], from[key]);
|
5339 | }
|
5340 | return merged;
|
5341 | }
|
5342 |
|
5343 | function createAppContext() {
|
5344 | return {
|
5345 | app: null,
|
5346 | config: {
|
5347 | isNativeTag: NO,
|
5348 | performance: false,
|
5349 | globalProperties: {},
|
5350 | optionMergeStrategies: {},
|
5351 | errorHandler: void 0,
|
5352 | warnHandler: void 0,
|
5353 | compilerOptions: {}
|
5354 | },
|
5355 | mixins: [],
|
5356 | components: {},
|
5357 | directives: {},
|
5358 | provides: Object.create(null),
|
5359 | optionsCache: new WeakMap(),
|
5360 | propsCache: new WeakMap(),
|
5361 | emitsCache: new WeakMap()
|
5362 | };
|
5363 | }
|
5364 | let uid$1 = 0;
|
5365 | function createAppAPI(render, hydrate) {
|
5366 | return function createApp(rootComponent, rootProps = null) {
|
5367 | if (!isFunction(rootComponent)) {
|
5368 | rootComponent = extend({}, rootComponent);
|
5369 | }
|
5370 | if (rootProps != null && !isObject(rootProps)) {
|
5371 | warn$1(`root props passed to app.mount() must be an object.`);
|
5372 | rootProps = null;
|
5373 | }
|
5374 | const context = createAppContext();
|
5375 | const installedPlugins = new WeakSet();
|
5376 | let isMounted = false;
|
5377 | const app = context.app = {
|
5378 | _uid: uid$1++,
|
5379 | _component: rootComponent,
|
5380 | _props: rootProps,
|
5381 | _container: null,
|
5382 | _context: context,
|
5383 | _instance: null,
|
5384 | version,
|
5385 | get config() {
|
5386 | return context.config;
|
5387 | },
|
5388 | set config(v) {
|
5389 | {
|
5390 | warn$1(
|
5391 | `app.config cannot be replaced. Modify individual options instead.`
|
5392 | );
|
5393 | }
|
5394 | },
|
5395 | use(plugin, ...options) {
|
5396 | if (installedPlugins.has(plugin)) {
|
5397 | warn$1(`Plugin has already been applied to target app.`);
|
5398 | } else if (plugin && isFunction(plugin.install)) {
|
5399 | installedPlugins.add(plugin);
|
5400 | plugin.install(app, ...options);
|
5401 | } else if (isFunction(plugin)) {
|
5402 | installedPlugins.add(plugin);
|
5403 | plugin(app, ...options);
|
5404 | } else {
|
5405 | warn$1(
|
5406 | `A plugin must either be a function or an object with an "install" function.`
|
5407 | );
|
5408 | }
|
5409 | return app;
|
5410 | },
|
5411 | mixin(mixin) {
|
5412 | {
|
5413 | if (!context.mixins.includes(mixin)) {
|
5414 | context.mixins.push(mixin);
|
5415 | } else {
|
5416 | warn$1(
|
5417 | "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
|
5418 | );
|
5419 | }
|
5420 | }
|
5421 | return app;
|
5422 | },
|
5423 | component(name, component) {
|
5424 | {
|
5425 | validateComponentName(name, context.config);
|
5426 | }
|
5427 | if (!component) {
|
5428 | return context.components[name];
|
5429 | }
|
5430 | if (context.components[name]) {
|
5431 | warn$1(`Component "${name}" has already been registered in target app.`);
|
5432 | }
|
5433 | context.components[name] = component;
|
5434 | return app;
|
5435 | },
|
5436 | directive(name, directive) {
|
5437 | {
|
5438 | validateDirectiveName(name);
|
5439 | }
|
5440 | if (!directive) {
|
5441 | return context.directives[name];
|
5442 | }
|
5443 | if (context.directives[name]) {
|
5444 | warn$1(`Directive "${name}" has already been registered in target app.`);
|
5445 | }
|
5446 | context.directives[name] = directive;
|
5447 | return app;
|
5448 | },
|
5449 | mount(rootContainer, isHydrate, namespace) {
|
5450 | if (!isMounted) {
|
5451 | if (rootContainer.__vue_app__) {
|
5452 | warn$1(
|
5453 | `There is already an app instance mounted on the host container.
|
5454 | If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
|
5455 | );
|
5456 | }
|
5457 | const vnode = createVNode(rootComponent, rootProps);
|
5458 | vnode.appContext = context;
|
5459 | if (namespace === true) {
|
5460 | namespace = "svg";
|
5461 | } else if (namespace === false) {
|
5462 | namespace = void 0;
|
5463 | }
|
5464 | {
|
5465 | context.reload = () => {
|
5466 | render(
|
5467 | cloneVNode(vnode),
|
5468 | rootContainer,
|
5469 | namespace
|
5470 | );
|
5471 | };
|
5472 | }
|
5473 | if (isHydrate && hydrate) {
|
5474 | hydrate(vnode, rootContainer);
|
5475 | } else {
|
5476 | render(vnode, rootContainer, namespace);
|
5477 | }
|
5478 | isMounted = true;
|
5479 | app._container = rootContainer;
|
5480 | rootContainer.__vue_app__ = app;
|
5481 | {
|
5482 | app._instance = vnode.component;
|
5483 | devtoolsInitApp(app, version);
|
5484 | }
|
5485 | return getExposeProxy(vnode.component) || vnode.component.proxy;
|
5486 | } else {
|
5487 | warn$1(
|
5488 | `App has already been mounted.
|
5489 | 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)\``
|
5490 | );
|
5491 | }
|
5492 | },
|
5493 | unmount() {
|
5494 | if (isMounted) {
|
5495 | render(null, app._container);
|
5496 | {
|
5497 | app._instance = null;
|
5498 | devtoolsUnmountApp(app);
|
5499 | }
|
5500 | delete app._container.__vue_app__;
|
5501 | } else {
|
5502 | warn$1(`Cannot unmount an app that is not mounted.`);
|
5503 | }
|
5504 | },
|
5505 | provide(key, value) {
|
5506 | if (key in context.provides) {
|
5507 | warn$1(
|
5508 | `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
|
5509 | );
|
5510 | }
|
5511 | context.provides[key] = value;
|
5512 | return app;
|
5513 | },
|
5514 | runWithContext(fn) {
|
5515 | const lastApp = currentApp;
|
5516 | currentApp = app;
|
5517 | try {
|
5518 | return fn();
|
5519 | } finally {
|
5520 | currentApp = lastApp;
|
5521 | }
|
5522 | }
|
5523 | };
|
5524 | return app;
|
5525 | };
|
5526 | }
|
5527 | let currentApp = null;
|
5528 |
|
5529 | function provide(key, value) {
|
5530 | if (!currentInstance) {
|
5531 | {
|
5532 | warn$1(`provide() can only be used inside setup().`);
|
5533 | }
|
5534 | } else {
|
5535 | let provides = currentInstance.provides;
|
5536 | const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
5537 | if (parentProvides === provides) {
|
5538 | provides = currentInstance.provides = Object.create(parentProvides);
|
5539 | }
|
5540 | provides[key] = value;
|
5541 | }
|
5542 | }
|
5543 | function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
5544 | const instance = currentInstance || currentRenderingInstance;
|
5545 | if (instance || currentApp) {
|
5546 | const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
|
5547 | if (provides && key in provides) {
|
5548 | return provides[key];
|
5549 | } else if (arguments.length > 1) {
|
5550 | return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
|
5551 | } else {
|
5552 | warn$1(`injection "${String(key)}" not found.`);
|
5553 | }
|
5554 | } else {
|
5555 | warn$1(`inject() can only be used inside setup() or functional components.`);
|
5556 | }
|
5557 | }
|
5558 | function hasInjectionContext() {
|
5559 | return !!(currentInstance || currentRenderingInstance || currentApp);
|
5560 | }
|
5561 |
|
5562 | const internalObjectProto = {};
|
5563 | const createInternalObject = () => Object.create(internalObjectProto);
|
5564 | const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
|
5565 |
|
5566 | function initProps(instance, rawProps, isStateful, isSSR = false) {
|
5567 | const props = {};
|
5568 | const attrs = createInternalObject();
|
5569 | instance.propsDefaults = Object.create(null);
|
5570 | setFullProps(instance, rawProps, props, attrs);
|
5571 | for (const key in instance.propsOptions[0]) {
|
5572 | if (!(key in props)) {
|
5573 | props[key] = void 0;
|
5574 | }
|
5575 | }
|
5576 | {
|
5577 | validateProps(rawProps || {}, props, instance);
|
5578 | }
|
5579 | if (isStateful) {
|
5580 | instance.props = isSSR ? props : shallowReactive(props);
|
5581 | } else {
|
5582 | if (!instance.type.props) {
|
5583 | instance.props = attrs;
|
5584 | } else {
|
5585 | instance.props = props;
|
5586 | }
|
5587 | }
|
5588 | instance.attrs = attrs;
|
5589 | }
|
5590 | function isInHmrContext(instance) {
|
5591 | while (instance) {
|
5592 | if (instance.type.__hmrId)
|
5593 | return true;
|
5594 | instance = instance.parent;
|
5595 | }
|
5596 | }
|
5597 | function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
5598 | const {
|
5599 | props,
|
5600 | attrs,
|
5601 | vnode: { patchFlag }
|
5602 | } = instance;
|
5603 | const rawCurrentProps = toRaw(props);
|
5604 | const [options] = instance.propsOptions;
|
5605 | let hasAttrsChanged = false;
|
5606 | if (
|
5607 |
|
5608 |
|
5609 |
|
5610 | !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
|
5611 | ) {
|
5612 | if (patchFlag & 8) {
|
5613 | const propsToUpdate = instance.vnode.dynamicProps;
|
5614 | for (let i = 0; i < propsToUpdate.length; i++) {
|
5615 | let key = propsToUpdate[i];
|
5616 | if (isEmitListener(instance.emitsOptions, key)) {
|
5617 | continue;
|
5618 | }
|
5619 | const value = rawProps[key];
|
5620 | if (options) {
|
5621 | if (hasOwn(attrs, key)) {
|
5622 | if (value !== attrs[key]) {
|
5623 | attrs[key] = value;
|
5624 | hasAttrsChanged = true;
|
5625 | }
|
5626 | } else {
|
5627 | const camelizedKey = camelize(key);
|
5628 | props[camelizedKey] = resolvePropValue(
|
5629 | options,
|
5630 | rawCurrentProps,
|
5631 | camelizedKey,
|
5632 | value,
|
5633 | instance,
|
5634 | false
|
5635 | );
|
5636 | }
|
5637 | } else {
|
5638 | if (value !== attrs[key]) {
|
5639 | attrs[key] = value;
|
5640 | hasAttrsChanged = true;
|
5641 | }
|
5642 | }
|
5643 | }
|
5644 | }
|
5645 | } else {
|
5646 | if (setFullProps(instance, rawProps, props, attrs)) {
|
5647 | hasAttrsChanged = true;
|
5648 | }
|
5649 | let kebabKey;
|
5650 | for (const key in rawCurrentProps) {
|
5651 | if (!rawProps ||
|
5652 | !hasOwn(rawProps, key) &&
|
5653 |
|
5654 | ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
|
5655 | if (options) {
|
5656 | if (rawPrevProps &&
|
5657 | (rawPrevProps[key] !== void 0 ||
|
5658 | rawPrevProps[kebabKey] !== void 0)) {
|
5659 | props[key] = resolvePropValue(
|
5660 | options,
|
5661 | rawCurrentProps,
|
5662 | key,
|
5663 | void 0,
|
5664 | instance,
|
5665 | true
|
5666 | );
|
5667 | }
|
5668 | } else {
|
5669 | delete props[key];
|
5670 | }
|
5671 | }
|
5672 | }
|
5673 | if (attrs !== rawCurrentProps) {
|
5674 | for (const key in attrs) {
|
5675 | if (!rawProps || !hasOwn(rawProps, key) && true) {
|
5676 | delete attrs[key];
|
5677 | hasAttrsChanged = true;
|
5678 | }
|
5679 | }
|
5680 | }
|
5681 | }
|
5682 | if (hasAttrsChanged) {
|
5683 | trigger(instance.attrs, "set", "");
|
5684 | }
|
5685 | {
|
5686 | validateProps(rawProps || {}, props, instance);
|
5687 | }
|
5688 | }
|
5689 | function setFullProps(instance, rawProps, props, attrs) {
|
5690 | const [options, needCastKeys] = instance.propsOptions;
|
5691 | let hasAttrsChanged = false;
|
5692 | let rawCastValues;
|
5693 | if (rawProps) {
|
5694 | for (let key in rawProps) {
|
5695 | if (isReservedProp(key)) {
|
5696 | continue;
|
5697 | }
|
5698 | const value = rawProps[key];
|
5699 | let camelKey;
|
5700 | if (options && hasOwn(options, camelKey = camelize(key))) {
|
5701 | if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
5702 | props[camelKey] = value;
|
5703 | } else {
|
5704 | (rawCastValues || (rawCastValues = {}))[camelKey] = value;
|
5705 | }
|
5706 | } else if (!isEmitListener(instance.emitsOptions, key)) {
|
5707 | if (!(key in attrs) || value !== attrs[key]) {
|
5708 | attrs[key] = value;
|
5709 | hasAttrsChanged = true;
|
5710 | }
|
5711 | }
|
5712 | }
|
5713 | }
|
5714 | if (needCastKeys) {
|
5715 | const rawCurrentProps = toRaw(props);
|
5716 | const castValues = rawCastValues || EMPTY_OBJ;
|
5717 | for (let i = 0; i < needCastKeys.length; i++) {
|
5718 | const key = needCastKeys[i];
|
5719 | props[key] = resolvePropValue(
|
5720 | options,
|
5721 | rawCurrentProps,
|
5722 | key,
|
5723 | castValues[key],
|
5724 | instance,
|
5725 | !hasOwn(castValues, key)
|
5726 | );
|
5727 | }
|
5728 | }
|
5729 | return hasAttrsChanged;
|
5730 | }
|
5731 | function resolvePropValue(options, props, key, value, instance, isAbsent) {
|
5732 | const opt = options[key];
|
5733 | if (opt != null) {
|
5734 | const hasDefault = hasOwn(opt, "default");
|
5735 | if (hasDefault && value === void 0) {
|
5736 | const defaultValue = opt.default;
|
5737 | if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
|
5738 | const { propsDefaults } = instance;
|
5739 | if (key in propsDefaults) {
|
5740 | value = propsDefaults[key];
|
5741 | } else {
|
5742 | const reset = setCurrentInstance(instance);
|
5743 | value = propsDefaults[key] = defaultValue.call(
|
5744 | null,
|
5745 | props
|
5746 | );
|
5747 | reset();
|
5748 | }
|
5749 | } else {
|
5750 | value = defaultValue;
|
5751 | }
|
5752 | }
|
5753 | if (opt[0 ]) {
|
5754 | if (isAbsent && !hasDefault) {
|
5755 | value = false;
|
5756 | } else if (opt[1 ] && (value === "" || value === hyphenate(key))) {
|
5757 | value = true;
|
5758 | }
|
5759 | }
|
5760 | }
|
5761 | return value;
|
5762 | }
|
5763 | function normalizePropsOptions(comp, appContext, asMixin = false) {
|
5764 | const cache = appContext.propsCache;
|
5765 | const cached = cache.get(comp);
|
5766 | if (cached) {
|
5767 | return cached;
|
5768 | }
|
5769 | const raw = comp.props;
|
5770 | const normalized = {};
|
5771 | const needCastKeys = [];
|
5772 | let hasExtends = false;
|
5773 | if (!isFunction(comp)) {
|
5774 | const extendProps = (raw2) => {
|
5775 | hasExtends = true;
|
5776 | const [props, keys] = normalizePropsOptions(raw2, appContext, true);
|
5777 | extend(normalized, props);
|
5778 | if (keys)
|
5779 | needCastKeys.push(...keys);
|
5780 | };
|
5781 | if (!asMixin && appContext.mixins.length) {
|
5782 | appContext.mixins.forEach(extendProps);
|
5783 | }
|
5784 | if (comp.extends) {
|
5785 | extendProps(comp.extends);
|
5786 | }
|
5787 | if (comp.mixins) {
|
5788 | comp.mixins.forEach(extendProps);
|
5789 | }
|
5790 | }
|
5791 | if (!raw && !hasExtends) {
|
5792 | if (isObject(comp)) {
|
5793 | cache.set(comp, EMPTY_ARR);
|
5794 | }
|
5795 | return EMPTY_ARR;
|
5796 | }
|
5797 | if (isArray(raw)) {
|
5798 | for (let i = 0; i < raw.length; i++) {
|
5799 | if (!isString(raw[i])) {
|
5800 | warn$1(`props must be strings when using array syntax.`, raw[i]);
|
5801 | }
|
5802 | const normalizedKey = camelize(raw[i]);
|
5803 | if (validatePropName(normalizedKey)) {
|
5804 | normalized[normalizedKey] = EMPTY_OBJ;
|
5805 | }
|
5806 | }
|
5807 | } else if (raw) {
|
5808 | if (!isObject(raw)) {
|
5809 | warn$1(`invalid props options`, raw);
|
5810 | }
|
5811 | for (const key in raw) {
|
5812 | const normalizedKey = camelize(key);
|
5813 | if (validatePropName(normalizedKey)) {
|
5814 | const opt = raw[key];
|
5815 | const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
|
5816 | if (prop) {
|
5817 | const booleanIndex = getTypeIndex(Boolean, prop.type);
|
5818 | const stringIndex = getTypeIndex(String, prop.type);
|
5819 | prop[0 ] = booleanIndex > -1;
|
5820 | prop[1 ] = stringIndex < 0 || booleanIndex < stringIndex;
|
5821 | if (booleanIndex > -1 || hasOwn(prop, "default")) {
|
5822 | needCastKeys.push(normalizedKey);
|
5823 | }
|
5824 | }
|
5825 | }
|
5826 | }
|
5827 | }
|
5828 | const res = [normalized, needCastKeys];
|
5829 | if (isObject(comp)) {
|
5830 | cache.set(comp, res);
|
5831 | }
|
5832 | return res;
|
5833 | }
|
5834 | function validatePropName(key) {
|
5835 | if (key[0] !== "$" && !isReservedProp(key)) {
|
5836 | return true;
|
5837 | } else {
|
5838 | warn$1(`Invalid prop name: "${key}" is a reserved property.`);
|
5839 | }
|
5840 | return false;
|
5841 | }
|
5842 | function getType(ctor) {
|
5843 | if (ctor === null) {
|
5844 | return "null";
|
5845 | }
|
5846 | if (typeof ctor === "function") {
|
5847 | return ctor.name || "";
|
5848 | } else if (typeof ctor === "object") {
|
5849 | const name = ctor.constructor && ctor.constructor.name;
|
5850 | return name || "";
|
5851 | }
|
5852 | return "";
|
5853 | }
|
5854 | function isSameType(a, b) {
|
5855 | return getType(a) === getType(b);
|
5856 | }
|
5857 | function getTypeIndex(type, expectedTypes) {
|
5858 | if (isArray(expectedTypes)) {
|
5859 | return expectedTypes.findIndex((t) => isSameType(t, type));
|
5860 | } else if (isFunction(expectedTypes)) {
|
5861 | return isSameType(expectedTypes, type) ? 0 : -1;
|
5862 | }
|
5863 | return -1;
|
5864 | }
|
5865 | function validateProps(rawProps, props, instance) {
|
5866 | const resolvedValues = toRaw(props);
|
5867 | const options = instance.propsOptions[0];
|
5868 | for (const key in options) {
|
5869 | let opt = options[key];
|
5870 | if (opt == null)
|
5871 | continue;
|
5872 | validateProp(
|
5873 | key,
|
5874 | resolvedValues[key],
|
5875 | opt,
|
5876 | shallowReadonly(resolvedValues) ,
|
5877 | !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
|
5878 | );
|
5879 | }
|
5880 | }
|
5881 | function validateProp(name, value, prop, props, isAbsent) {
|
5882 | const { type, required, validator, skipCheck } = prop;
|
5883 | if (required && isAbsent) {
|
5884 | warn$1('Missing required prop: "' + name + '"');
|
5885 | return;
|
5886 | }
|
5887 | if (value == null && !required) {
|
5888 | return;
|
5889 | }
|
5890 | if (type != null && type !== true && !skipCheck) {
|
5891 | let isValid = false;
|
5892 | const types = isArray(type) ? type : [type];
|
5893 | const expectedTypes = [];
|
5894 | for (let i = 0; i < types.length && !isValid; i++) {
|
5895 | const { valid, expectedType } = assertType(value, types[i]);
|
5896 | expectedTypes.push(expectedType || "");
|
5897 | isValid = valid;
|
5898 | }
|
5899 | if (!isValid) {
|
5900 | warn$1(getInvalidTypeMessage(name, value, expectedTypes));
|
5901 | return;
|
5902 | }
|
5903 | }
|
5904 | if (validator && !validator(value, props)) {
|
5905 | warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
|
5906 | }
|
5907 | }
|
5908 | const isSimpleType = makeMap(
|
5909 | "String,Number,Boolean,Function,Symbol,BigInt"
|
5910 | );
|
5911 | function assertType(value, type) {
|
5912 | let valid;
|
5913 | const expectedType = getType(type);
|
5914 | if (isSimpleType(expectedType)) {
|
5915 | const t = typeof value;
|
5916 | valid = t === expectedType.toLowerCase();
|
5917 | if (!valid && t === "object") {
|
5918 | valid = value instanceof type;
|
5919 | }
|
5920 | } else if (expectedType === "Object") {
|
5921 | valid = isObject(value);
|
5922 | } else if (expectedType === "Array") {
|
5923 | valid = isArray(value);
|
5924 | } else if (expectedType === "null") {
|
5925 | valid = value === null;
|
5926 | } else {
|
5927 | valid = value instanceof type;
|
5928 | }
|
5929 | return {
|
5930 | valid,
|
5931 | expectedType
|
5932 | };
|
5933 | }
|
5934 | function getInvalidTypeMessage(name, value, expectedTypes) {
|
5935 | if (expectedTypes.length === 0) {
|
5936 | return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
|
5937 | }
|
5938 | let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
|
5939 | const expectedType = expectedTypes[0];
|
5940 | const receivedType = toRawType(value);
|
5941 | const expectedValue = styleValue(value, expectedType);
|
5942 | const receivedValue = styleValue(value, receivedType);
|
5943 | if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
|
5944 | message += ` with value ${expectedValue}`;
|
5945 | }
|
5946 | message += `, got ${receivedType} `;
|
5947 | if (isExplicable(receivedType)) {
|
5948 | message += `with value ${receivedValue}.`;
|
5949 | }
|
5950 | return message;
|
5951 | }
|
5952 | function styleValue(value, type) {
|
5953 | if (type === "String") {
|
5954 | return `"${value}"`;
|
5955 | } else if (type === "Number") {
|
5956 | return `${Number(value)}`;
|
5957 | } else {
|
5958 | return `${value}`;
|
5959 | }
|
5960 | }
|
5961 | function isExplicable(type) {
|
5962 | const explicitTypes = ["string", "number", "boolean"];
|
5963 | return explicitTypes.some((elem) => type.toLowerCase() === elem);
|
5964 | }
|
5965 | function isBoolean(...args) {
|
5966 | return args.some((elem) => elem.toLowerCase() === "boolean");
|
5967 | }
|
5968 |
|
5969 | const isInternalKey = (key) => key[0] === "_" || key === "$stable";
|
5970 | const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
|
5971 | const normalizeSlot = (key, rawSlot, ctx) => {
|
5972 | if (rawSlot._n) {
|
5973 | return rawSlot;
|
5974 | }
|
5975 | const normalized = withCtx((...args) => {
|
5976 | if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
|
5977 | warn$1(
|
5978 | `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.`
|
5979 | );
|
5980 | }
|
5981 | return normalizeSlotValue(rawSlot(...args));
|
5982 | }, ctx);
|
5983 | normalized._c = false;
|
5984 | return normalized;
|
5985 | };
|
5986 | const normalizeObjectSlots = (rawSlots, slots, instance) => {
|
5987 | const ctx = rawSlots._ctx;
|
5988 | for (const key in rawSlots) {
|
5989 | if (isInternalKey(key))
|
5990 | continue;
|
5991 | const value = rawSlots[key];
|
5992 | if (isFunction(value)) {
|
5993 | slots[key] = normalizeSlot(key, value, ctx);
|
5994 | } else if (value != null) {
|
5995 | {
|
5996 | warn$1(
|
5997 | `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
|
5998 | );
|
5999 | }
|
6000 | const normalized = normalizeSlotValue(value);
|
6001 | slots[key] = () => normalized;
|
6002 | }
|
6003 | }
|
6004 | };
|
6005 | const normalizeVNodeSlots = (instance, children) => {
|
6006 | if (!isKeepAlive(instance.vnode) && true) {
|
6007 | warn$1(
|
6008 | `Non-function value encountered for default slot. Prefer function slots for better performance.`
|
6009 | );
|
6010 | }
|
6011 | const normalized = normalizeSlotValue(children);
|
6012 | instance.slots.default = () => normalized;
|
6013 | };
|
6014 | const initSlots = (instance, children) => {
|
6015 | const slots = instance.slots = createInternalObject();
|
6016 | if (instance.vnode.shapeFlag & 32) {
|
6017 | const type = children._;
|
6018 | if (type) {
|
6019 | extend(slots, children);
|
6020 | def(slots, "_", type);
|
6021 | } else {
|
6022 | normalizeObjectSlots(children, slots);
|
6023 | }
|
6024 | } else if (children) {
|
6025 | normalizeVNodeSlots(instance, children);
|
6026 | }
|
6027 | };
|
6028 | const updateSlots = (instance, children, optimized) => {
|
6029 | const { vnode, slots } = instance;
|
6030 | let needDeletionCheck = true;
|
6031 | let deletionComparisonTarget = EMPTY_OBJ;
|
6032 | if (vnode.shapeFlag & 32) {
|
6033 | const type = children._;
|
6034 | if (type) {
|
6035 | if (isHmrUpdating) {
|
6036 | extend(slots, children);
|
6037 | trigger(instance, "set", "$slots");
|
6038 | } else if (optimized && type === 1) {
|
6039 | needDeletionCheck = false;
|
6040 | } else {
|
6041 | extend(slots, children);
|
6042 | if (!optimized && type === 1) {
|
6043 | delete slots._;
|
6044 | }
|
6045 | }
|
6046 | } else {
|
6047 | needDeletionCheck = !children.$stable;
|
6048 | normalizeObjectSlots(children, slots);
|
6049 | }
|
6050 | deletionComparisonTarget = children;
|
6051 | } else if (children) {
|
6052 | normalizeVNodeSlots(instance, children);
|
6053 | deletionComparisonTarget = { default: 1 };
|
6054 | }
|
6055 | if (needDeletionCheck) {
|
6056 | for (const key in slots) {
|
6057 | if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
|
6058 | delete slots[key];
|
6059 | }
|
6060 | }
|
6061 | }
|
6062 | };
|
6063 |
|
6064 | function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
|
6065 | if (isArray(rawRef)) {
|
6066 | rawRef.forEach(
|
6067 | (r, i) => setRef(
|
6068 | r,
|
6069 | oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
|
6070 | parentSuspense,
|
6071 | vnode,
|
6072 | isUnmount
|
6073 | )
|
6074 | );
|
6075 | return;
|
6076 | }
|
6077 | if (isAsyncWrapper(vnode) && !isUnmount) {
|
6078 | return;
|
6079 | }
|
6080 | const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el;
|
6081 | const value = isUnmount ? null : refValue;
|
6082 | const { i: owner, r: ref } = rawRef;
|
6083 | if (!owner) {
|
6084 | warn$1(
|
6085 | `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
|
6086 | );
|
6087 | return;
|
6088 | }
|
6089 | const oldRef = oldRawRef && oldRawRef.r;
|
6090 | const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
|
6091 | const setupState = owner.setupState;
|
6092 | if (oldRef != null && oldRef !== ref) {
|
6093 | if (isString(oldRef)) {
|
6094 | refs[oldRef] = null;
|
6095 | if (hasOwn(setupState, oldRef)) {
|
6096 | setupState[oldRef] = null;
|
6097 | }
|
6098 | } else if (isRef(oldRef)) {
|
6099 | oldRef.value = null;
|
6100 | }
|
6101 | }
|
6102 | if (isFunction(ref)) {
|
6103 | callWithErrorHandling(ref, owner, 12, [value, refs]);
|
6104 | } else {
|
6105 | const _isString = isString(ref);
|
6106 | const _isRef = isRef(ref);
|
6107 | if (_isString || _isRef) {
|
6108 | const doSet = () => {
|
6109 | if (rawRef.f) {
|
6110 | const existing = _isString ? hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
|
6111 | if (isUnmount) {
|
6112 | isArray(existing) && remove(existing, refValue);
|
6113 | } else {
|
6114 | if (!isArray(existing)) {
|
6115 | if (_isString) {
|
6116 | refs[ref] = [refValue];
|
6117 | if (hasOwn(setupState, ref)) {
|
6118 | setupState[ref] = refs[ref];
|
6119 | }
|
6120 | } else {
|
6121 | ref.value = [refValue];
|
6122 | if (rawRef.k)
|
6123 | refs[rawRef.k] = ref.value;
|
6124 | }
|
6125 | } else if (!existing.includes(refValue)) {
|
6126 | existing.push(refValue);
|
6127 | }
|
6128 | }
|
6129 | } else if (_isString) {
|
6130 | refs[ref] = value;
|
6131 | if (hasOwn(setupState, ref)) {
|
6132 | setupState[ref] = value;
|
6133 | }
|
6134 | } else if (_isRef) {
|
6135 | ref.value = value;
|
6136 | if (rawRef.k)
|
6137 | refs[rawRef.k] = value;
|
6138 | } else {
|
6139 | warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
|
6140 | }
|
6141 | };
|
6142 | if (value) {
|
6143 | doSet.id = -1;
|
6144 | queuePostRenderEffect(doSet, parentSuspense);
|
6145 | } else {
|
6146 | doSet();
|
6147 | }
|
6148 | } else {
|
6149 | warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
|
6150 | }
|
6151 | }
|
6152 | }
|
6153 |
|
6154 | let hasMismatch = false;
|
6155 | const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
|
6156 | const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
|
6157 | const getContainerType = (container) => {
|
6158 | if (isSVGContainer(container))
|
6159 | return "svg";
|
6160 | if (isMathMLContainer(container))
|
6161 | return "mathml";
|
6162 | return void 0;
|
6163 | };
|
6164 | const isComment = (node) => node.nodeType === 8 ;
|
6165 | function createHydrationFunctions(rendererInternals) {
|
6166 | const {
|
6167 | mt: mountComponent,
|
6168 | p: patch,
|
6169 | o: {
|
6170 | patchProp,
|
6171 | createText,
|
6172 | nextSibling,
|
6173 | parentNode,
|
6174 | remove,
|
6175 | insert,
|
6176 | createComment
|
6177 | }
|
6178 | } = rendererInternals;
|
6179 | const hydrate = (vnode, container) => {
|
6180 | if (!container.hasChildNodes()) {
|
6181 | warn$1(
|
6182 | `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`
|
6183 | );
|
6184 | patch(null, vnode, container);
|
6185 | flushPostFlushCbs();
|
6186 | container._vnode = vnode;
|
6187 | return;
|
6188 | }
|
6189 | hasMismatch = false;
|
6190 | hydrateNode(container.firstChild, vnode, null, null, null);
|
6191 | flushPostFlushCbs();
|
6192 | container._vnode = vnode;
|
6193 | if (hasMismatch && true) {
|
6194 | console.error(`Hydration completed but contains mismatches.`);
|
6195 | }
|
6196 | };
|
6197 | const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
|
6198 | optimized = optimized || !!vnode.dynamicChildren;
|
6199 | const isFragmentStart = isComment(node) && node.data === "[";
|
6200 | const onMismatch = () => handleMismatch(
|
6201 | node,
|
6202 | vnode,
|
6203 | parentComponent,
|
6204 | parentSuspense,
|
6205 | slotScopeIds,
|
6206 | isFragmentStart
|
6207 | );
|
6208 | const { type, ref, shapeFlag, patchFlag } = vnode;
|
6209 | let domType = node.nodeType;
|
6210 | vnode.el = node;
|
6211 | {
|
6212 | if (!("__vnode" in node)) {
|
6213 | Object.defineProperty(node, "__vnode", {
|
6214 | value: vnode,
|
6215 | enumerable: false
|
6216 | });
|
6217 | }
|
6218 | if (!("__vueParentComponent" in node)) {
|
6219 | Object.defineProperty(node, "__vueParentComponent", {
|
6220 | value: parentComponent,
|
6221 | enumerable: false
|
6222 | });
|
6223 | }
|
6224 | }
|
6225 | if (patchFlag === -2) {
|
6226 | optimized = false;
|
6227 | vnode.dynamicChildren = null;
|
6228 | }
|
6229 | let nextNode = null;
|
6230 | switch (type) {
|
6231 | case Text:
|
6232 | if (domType !== 3 ) {
|
6233 | if (vnode.children === "") {
|
6234 | insert(vnode.el = createText(""), parentNode(node), node);
|
6235 | nextNode = node;
|
6236 | } else {
|
6237 | nextNode = onMismatch();
|
6238 | }
|
6239 | } else {
|
6240 | if (node.data !== vnode.children) {
|
6241 | hasMismatch = true;
|
6242 | warn$1(
|
6243 | `Hydration text mismatch in`,
|
6244 | node.parentNode,
|
6245 | `
|
6246 | - rendered on server: ${JSON.stringify(
|
6247 | node.data
|
6248 | )}
|
6249 | - expected on client: ${JSON.stringify(vnode.children)}`
|
6250 | );
|
6251 | node.data = vnode.children;
|
6252 | }
|
6253 | nextNode = nextSibling(node);
|
6254 | }
|
6255 | break;
|
6256 | case Comment:
|
6257 | if (isTemplateNode(node)) {
|
6258 | nextNode = nextSibling(node);
|
6259 | replaceNode(
|
6260 | vnode.el = node.content.firstChild,
|
6261 | node,
|
6262 | parentComponent
|
6263 | );
|
6264 | } else if (domType !== 8 || isFragmentStart) {
|
6265 | nextNode = onMismatch();
|
6266 | } else {
|
6267 | nextNode = nextSibling(node);
|
6268 | }
|
6269 | break;
|
6270 | case Static:
|
6271 | if (isFragmentStart) {
|
6272 | node = nextSibling(node);
|
6273 | domType = node.nodeType;
|
6274 | }
|
6275 | if (domType === 1 || domType === 3 ) {
|
6276 | nextNode = node;
|
6277 | const needToAdoptContent = !vnode.children.length;
|
6278 | for (let i = 0; i < vnode.staticCount; i++) {
|
6279 | if (needToAdoptContent)
|
6280 | vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
|
6281 | if (i === vnode.staticCount - 1) {
|
6282 | vnode.anchor = nextNode;
|
6283 | }
|
6284 | nextNode = nextSibling(nextNode);
|
6285 | }
|
6286 | return isFragmentStart ? nextSibling(nextNode) : nextNode;
|
6287 | } else {
|
6288 | onMismatch();
|
6289 | }
|
6290 | break;
|
6291 | case Fragment:
|
6292 | if (!isFragmentStart) {
|
6293 | nextNode = onMismatch();
|
6294 | } else {
|
6295 | nextNode = hydrateFragment(
|
6296 | node,
|
6297 | vnode,
|
6298 | parentComponent,
|
6299 | parentSuspense,
|
6300 | slotScopeIds,
|
6301 | optimized
|
6302 | );
|
6303 | }
|
6304 | break;
|
6305 | default:
|
6306 | if (shapeFlag & 1) {
|
6307 | if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
|
6308 | nextNode = onMismatch();
|
6309 | } else {
|
6310 | nextNode = hydrateElement(
|
6311 | node,
|
6312 | vnode,
|
6313 | parentComponent,
|
6314 | parentSuspense,
|
6315 | slotScopeIds,
|
6316 | optimized
|
6317 | );
|
6318 | }
|
6319 | } else if (shapeFlag & 6) {
|
6320 | vnode.slotScopeIds = slotScopeIds;
|
6321 | const container = parentNode(node);
|
6322 | if (isFragmentStart) {
|
6323 | nextNode = locateClosingAnchor(node);
|
6324 | } else if (isComment(node) && node.data === "teleport start") {
|
6325 | nextNode = locateClosingAnchor(node, node.data, "teleport end");
|
6326 | } else {
|
6327 | nextNode = nextSibling(node);
|
6328 | }
|
6329 | mountComponent(
|
6330 | vnode,
|
6331 | container,
|
6332 | null,
|
6333 | parentComponent,
|
6334 | parentSuspense,
|
6335 | getContainerType(container),
|
6336 | optimized
|
6337 | );
|
6338 | if (isAsyncWrapper(vnode)) {
|
6339 | let subTree;
|
6340 | if (isFragmentStart) {
|
6341 | subTree = createVNode(Fragment);
|
6342 | subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
|
6343 | } else {
|
6344 | subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
|
6345 | }
|
6346 | subTree.el = node;
|
6347 | vnode.component.subTree = subTree;
|
6348 | }
|
6349 | } else if (shapeFlag & 64) {
|
6350 | if (domType !== 8 ) {
|
6351 | nextNode = onMismatch();
|
6352 | } else {
|
6353 | nextNode = vnode.type.hydrate(
|
6354 | node,
|
6355 | vnode,
|
6356 | parentComponent,
|
6357 | parentSuspense,
|
6358 | slotScopeIds,
|
6359 | optimized,
|
6360 | rendererInternals,
|
6361 | hydrateChildren
|
6362 | );
|
6363 | }
|
6364 | } else if (shapeFlag & 128) {
|
6365 | nextNode = vnode.type.hydrate(
|
6366 | node,
|
6367 | vnode,
|
6368 | parentComponent,
|
6369 | parentSuspense,
|
6370 | getContainerType(parentNode(node)),
|
6371 | slotScopeIds,
|
6372 | optimized,
|
6373 | rendererInternals,
|
6374 | hydrateNode
|
6375 | );
|
6376 | } else {
|
6377 | warn$1("Invalid HostVNode type:", type, `(${typeof type})`);
|
6378 | }
|
6379 | }
|
6380 | if (ref != null) {
|
6381 | setRef(ref, null, parentSuspense, vnode);
|
6382 | }
|
6383 | return nextNode;
|
6384 | };
|
6385 | const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
6386 | optimized = optimized || !!vnode.dynamicChildren;
|
6387 | const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
|
6388 | const forcePatch = type === "input" || type === "option";
|
6389 | {
|
6390 | if (dirs) {
|
6391 | invokeDirectiveHook(vnode, null, parentComponent, "created");
|
6392 | }
|
6393 | let needCallTransitionHooks = false;
|
6394 | if (isTemplateNode(el)) {
|
6395 | needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
|
6396 | const content = el.content.firstChild;
|
6397 | if (needCallTransitionHooks) {
|
6398 | transition.beforeEnter(content);
|
6399 | }
|
6400 | replaceNode(content, el, parentComponent);
|
6401 | vnode.el = el = content;
|
6402 | }
|
6403 | if (shapeFlag & 16 &&
|
6404 | !(props && (props.innerHTML || props.textContent))) {
|
6405 | let next = hydrateChildren(
|
6406 | el.firstChild,
|
6407 | vnode,
|
6408 | el,
|
6409 | parentComponent,
|
6410 | parentSuspense,
|
6411 | slotScopeIds,
|
6412 | optimized
|
6413 | );
|
6414 | let hasWarned = false;
|
6415 | while (next) {
|
6416 | hasMismatch = true;
|
6417 | if (!hasWarned) {
|
6418 | warn$1(
|
6419 | `Hydration children mismatch on`,
|
6420 | el,
|
6421 | `
|
6422 | Server rendered element contains more child nodes than client vdom.`
|
6423 | );
|
6424 | hasWarned = true;
|
6425 | }
|
6426 | const cur = next;
|
6427 | next = next.nextSibling;
|
6428 | remove(cur);
|
6429 | }
|
6430 | } else if (shapeFlag & 8) {
|
6431 | if (el.textContent !== vnode.children) {
|
6432 | hasMismatch = true;
|
6433 | warn$1(
|
6434 | `Hydration text content mismatch on`,
|
6435 | el,
|
6436 | `
|
6437 | - rendered on server: ${el.textContent}
|
6438 | - expected on client: ${vnode.children}`
|
6439 | );
|
6440 | el.textContent = vnode.children;
|
6441 | }
|
6442 | }
|
6443 | if (props) {
|
6444 | {
|
6445 | for (const key in props) {
|
6446 | if (propHasMismatch(el, key, props[key], vnode, parentComponent)) {
|
6447 | hasMismatch = true;
|
6448 | }
|
6449 | if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) ||
|
6450 | key[0] === ".") {
|
6451 | patchProp(
|
6452 | el,
|
6453 | key,
|
6454 | null,
|
6455 | props[key],
|
6456 | void 0,
|
6457 | void 0,
|
6458 | parentComponent
|
6459 | );
|
6460 | }
|
6461 | }
|
6462 | }
|
6463 | }
|
6464 | let vnodeHooks;
|
6465 | if (vnodeHooks = props && props.onVnodeBeforeMount) {
|
6466 | invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
6467 | }
|
6468 | if (dirs) {
|
6469 | invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
6470 | }
|
6471 | if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
|
6472 | queueEffectWithSuspense(() => {
|
6473 | vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
6474 | needCallTransitionHooks && transition.enter(el);
|
6475 | dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
6476 | }, parentSuspense);
|
6477 | }
|
6478 | }
|
6479 | return el.nextSibling;
|
6480 | };
|
6481 | const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
6482 | optimized = optimized || !!parentVNode.dynamicChildren;
|
6483 | const children = parentVNode.children;
|
6484 | const l = children.length;
|
6485 | let hasWarned = false;
|
6486 | for (let i = 0; i < l; i++) {
|
6487 | const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
|
6488 | if (node) {
|
6489 | node = hydrateNode(
|
6490 | node,
|
6491 | vnode,
|
6492 | parentComponent,
|
6493 | parentSuspense,
|
6494 | slotScopeIds,
|
6495 | optimized
|
6496 | );
|
6497 | } else if (vnode.type === Text && !vnode.children) {
|
6498 | continue;
|
6499 | } else {
|
6500 | hasMismatch = true;
|
6501 | if (!hasWarned) {
|
6502 | warn$1(
|
6503 | `Hydration children mismatch on`,
|
6504 | container,
|
6505 | `
|
6506 | Server rendered element contains fewer child nodes than client vdom.`
|
6507 | );
|
6508 | hasWarned = true;
|
6509 | }
|
6510 | patch(
|
6511 | null,
|
6512 | vnode,
|
6513 | container,
|
6514 | null,
|
6515 | parentComponent,
|
6516 | parentSuspense,
|
6517 | getContainerType(container),
|
6518 | slotScopeIds
|
6519 | );
|
6520 | }
|
6521 | }
|
6522 | return node;
|
6523 | };
|
6524 | const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
6525 | const { slotScopeIds: fragmentSlotScopeIds } = vnode;
|
6526 | if (fragmentSlotScopeIds) {
|
6527 | slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
6528 | }
|
6529 | const container = parentNode(node);
|
6530 | const next = hydrateChildren(
|
6531 | nextSibling(node),
|
6532 | vnode,
|
6533 | container,
|
6534 | parentComponent,
|
6535 | parentSuspense,
|
6536 | slotScopeIds,
|
6537 | optimized
|
6538 | );
|
6539 | if (next && isComment(next) && next.data === "]") {
|
6540 | return nextSibling(vnode.anchor = next);
|
6541 | } else {
|
6542 | hasMismatch = true;
|
6543 | insert(vnode.anchor = createComment(`]`), container, next);
|
6544 | return next;
|
6545 | }
|
6546 | };
|
6547 | const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
|
6548 | hasMismatch = true;
|
6549 | warn$1(
|
6550 | `Hydration node mismatch:
|
6551 | - rendered on server:`,
|
6552 | node,
|
6553 | node.nodeType === 3 ? `(text)` : isComment(node) && node.data === "[" ? `(start of fragment)` : ``,
|
6554 | `
|
6555 | - expected on client:`,
|
6556 | vnode.type
|
6557 | );
|
6558 | vnode.el = null;
|
6559 | if (isFragment) {
|
6560 | const end = locateClosingAnchor(node);
|
6561 | while (true) {
|
6562 | const next2 = nextSibling(node);
|
6563 | if (next2 && next2 !== end) {
|
6564 | remove(next2);
|
6565 | } else {
|
6566 | break;
|
6567 | }
|
6568 | }
|
6569 | }
|
6570 | const next = nextSibling(node);
|
6571 | const container = parentNode(node);
|
6572 | remove(node);
|
6573 | patch(
|
6574 | null,
|
6575 | vnode,
|
6576 | container,
|
6577 | next,
|
6578 | parentComponent,
|
6579 | parentSuspense,
|
6580 | getContainerType(container),
|
6581 | slotScopeIds
|
6582 | );
|
6583 | return next;
|
6584 | };
|
6585 | const locateClosingAnchor = (node, open = "[", close = "]") => {
|
6586 | let match = 0;
|
6587 | while (node) {
|
6588 | node = nextSibling(node);
|
6589 | if (node && isComment(node)) {
|
6590 | if (node.data === open)
|
6591 | match++;
|
6592 | if (node.data === close) {
|
6593 | if (match === 0) {
|
6594 | return nextSibling(node);
|
6595 | } else {
|
6596 | match--;
|
6597 | }
|
6598 | }
|
6599 | }
|
6600 | }
|
6601 | return node;
|
6602 | };
|
6603 | const replaceNode = (newNode, oldNode, parentComponent) => {
|
6604 | const parentNode2 = oldNode.parentNode;
|
6605 | if (parentNode2) {
|
6606 | parentNode2.replaceChild(newNode, oldNode);
|
6607 | }
|
6608 | let parent = parentComponent;
|
6609 | while (parent) {
|
6610 | if (parent.vnode.el === oldNode) {
|
6611 | parent.vnode.el = parent.subTree.el = newNode;
|
6612 | }
|
6613 | parent = parent.parent;
|
6614 | }
|
6615 | };
|
6616 | const isTemplateNode = (node) => {
|
6617 | return node.nodeType === 1 && node.tagName.toLowerCase() === "template";
|
6618 | };
|
6619 | return [hydrate, hydrateNode];
|
6620 | }
|
6621 | function propHasMismatch(el, key, clientValue, vnode, instance) {
|
6622 | var _a;
|
6623 | let mismatchType;
|
6624 | let mismatchKey;
|
6625 | let actual;
|
6626 | let expected;
|
6627 | if (key === "class") {
|
6628 | actual = el.getAttribute("class");
|
6629 | expected = normalizeClass(clientValue);
|
6630 | if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) {
|
6631 | mismatchType = mismatchKey = `class`;
|
6632 | }
|
6633 | } else if (key === "style") {
|
6634 | actual = el.getAttribute("style");
|
6635 | expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
|
6636 | const actualMap = toStyleMap(actual);
|
6637 | const expectedMap = toStyleMap(expected);
|
6638 | if (vnode.dirs) {
|
6639 | for (const { dir, value } of vnode.dirs) {
|
6640 | if (dir.name === "show" && !value) {
|
6641 | expectedMap.set("display", "none");
|
6642 | }
|
6643 | }
|
6644 | }
|
6645 | const root = instance == null ? void 0 : instance.subTree;
|
6646 | if (vnode === root || (root == null ? void 0 : root.type) === Fragment && root.children.includes(vnode)) {
|
6647 | const cssVars = (_a = instance == null ? void 0 : instance.getCssVars) == null ? void 0 : _a.call(instance);
|
6648 | for (const key2 in cssVars) {
|
6649 | expectedMap.set(`--${key2}`, String(cssVars[key2]));
|
6650 | }
|
6651 | }
|
6652 | if (!isMapEqual(actualMap, expectedMap)) {
|
6653 | mismatchType = mismatchKey = "style";
|
6654 | }
|
6655 | } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
|
6656 | if (isBooleanAttr(key)) {
|
6657 | actual = el.hasAttribute(key);
|
6658 | expected = includeBooleanAttr(clientValue);
|
6659 | } else if (clientValue == null) {
|
6660 | actual = el.hasAttribute(key);
|
6661 | expected = false;
|
6662 | } else {
|
6663 | if (el.hasAttribute(key)) {
|
6664 | actual = el.getAttribute(key);
|
6665 | } else if (key === "value" && el.tagName === "TEXTAREA") {
|
6666 | actual = el.value;
|
6667 | } else {
|
6668 | actual = false;
|
6669 | }
|
6670 | expected = isRenderableAttrValue(clientValue) ? String(clientValue) : false;
|
6671 | }
|
6672 | if (actual !== expected) {
|
6673 | mismatchType = `attribute`;
|
6674 | mismatchKey = key;
|
6675 | }
|
6676 | }
|
6677 | if (mismatchType) {
|
6678 | const format = (v) => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`;
|
6679 | const preSegment = `Hydration ${mismatchType} mismatch on`;
|
6680 | const postSegment = `
|
6681 | - rendered on server: ${format(actual)}
|
6682 | - expected on client: ${format(expected)}
|
6683 | Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
|
6684 | You should fix the source of the mismatch.`;
|
6685 | {
|
6686 | warn$1(preSegment, el, postSegment);
|
6687 | }
|
6688 | return true;
|
6689 | }
|
6690 | return false;
|
6691 | }
|
6692 | function toClassSet(str) {
|
6693 | return new Set(str.trim().split(/\s+/));
|
6694 | }
|
6695 | function isSetEqual(a, b) {
|
6696 | if (a.size !== b.size) {
|
6697 | return false;
|
6698 | }
|
6699 | for (const s of a) {
|
6700 | if (!b.has(s)) {
|
6701 | return false;
|
6702 | }
|
6703 | }
|
6704 | return true;
|
6705 | }
|
6706 | function toStyleMap(str) {
|
6707 | const styleMap = new Map();
|
6708 | for (const item of str.split(";")) {
|
6709 | let [key, value] = item.split(":");
|
6710 | key = key == null ? void 0 : key.trim();
|
6711 | value = value == null ? void 0 : value.trim();
|
6712 | if (key && value) {
|
6713 | styleMap.set(key, value);
|
6714 | }
|
6715 | }
|
6716 | return styleMap;
|
6717 | }
|
6718 | function isMapEqual(a, b) {
|
6719 | if (a.size !== b.size) {
|
6720 | return false;
|
6721 | }
|
6722 | for (const [key, value] of a) {
|
6723 | if (value !== b.get(key)) {
|
6724 | return false;
|
6725 | }
|
6726 | }
|
6727 | return true;
|
6728 | }
|
6729 |
|
6730 | let supported;
|
6731 | let perf;
|
6732 | function startMeasure(instance, type) {
|
6733 | if (instance.appContext.config.performance && isSupported()) {
|
6734 | perf.mark(`vue-${type}-${instance.uid}`);
|
6735 | }
|
6736 | {
|
6737 | devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
|
6738 | }
|
6739 | }
|
6740 | function endMeasure(instance, type) {
|
6741 | if (instance.appContext.config.performance && isSupported()) {
|
6742 | const startTag = `vue-${type}-${instance.uid}`;
|
6743 | const endTag = startTag + `:end`;
|
6744 | perf.mark(endTag);
|
6745 | perf.measure(
|
6746 | `<${formatComponentName(instance, instance.type)}> ${type}`,
|
6747 | startTag,
|
6748 | endTag
|
6749 | );
|
6750 | perf.clearMarks(startTag);
|
6751 | perf.clearMarks(endTag);
|
6752 | }
|
6753 | {
|
6754 | devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
|
6755 | }
|
6756 | }
|
6757 | function isSupported() {
|
6758 | if (supported !== void 0) {
|
6759 | return supported;
|
6760 | }
|
6761 | if (typeof window !== "undefined" && window.performance) {
|
6762 | supported = true;
|
6763 | perf = window.performance;
|
6764 | } else {
|
6765 | supported = false;
|
6766 | }
|
6767 | return supported;
|
6768 | }
|
6769 |
|
6770 | const queuePostRenderEffect = queueEffectWithSuspense ;
|
6771 | function createRenderer(options) {
|
6772 | return baseCreateRenderer(options);
|
6773 | }
|
6774 | function createHydrationRenderer(options) {
|
6775 | return baseCreateRenderer(options, createHydrationFunctions);
|
6776 | }
|
6777 | function baseCreateRenderer(options, createHydrationFns) {
|
6778 | const target = getGlobalThis();
|
6779 | target.__VUE__ = true;
|
6780 | {
|
6781 | setDevtoolsHook$1(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
|
6782 | }
|
6783 | const {
|
6784 | insert: hostInsert,
|
6785 | remove: hostRemove,
|
6786 | patchProp: hostPatchProp,
|
6787 | createElement: hostCreateElement,
|
6788 | createText: hostCreateText,
|
6789 | createComment: hostCreateComment,
|
6790 | setText: hostSetText,
|
6791 | setElementText: hostSetElementText,
|
6792 | parentNode: hostParentNode,
|
6793 | nextSibling: hostNextSibling,
|
6794 | setScopeId: hostSetScopeId = NOOP,
|
6795 | insertStaticContent: hostInsertStaticContent
|
6796 | } = options;
|
6797 | const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
|
6798 | if (n1 === n2) {
|
6799 | return;
|
6800 | }
|
6801 | if (n1 && !isSameVNodeType(n1, n2)) {
|
6802 | anchor = getNextHostNode(n1);
|
6803 | unmount(n1, parentComponent, parentSuspense, true);
|
6804 | n1 = null;
|
6805 | }
|
6806 | if (n2.patchFlag === -2) {
|
6807 | optimized = false;
|
6808 | n2.dynamicChildren = null;
|
6809 | }
|
6810 | const { type, ref, shapeFlag } = n2;
|
6811 | switch (type) {
|
6812 | case Text:
|
6813 | processText(n1, n2, container, anchor);
|
6814 | break;
|
6815 | case Comment:
|
6816 | processCommentNode(n1, n2, container, anchor);
|
6817 | break;
|
6818 | case Static:
|
6819 | if (n1 == null) {
|
6820 | mountStaticNode(n2, container, anchor, namespace);
|
6821 | } else {
|
6822 | patchStaticNode(n1, n2, container, namespace);
|
6823 | }
|
6824 | break;
|
6825 | case Fragment:
|
6826 | processFragment(
|
6827 | n1,
|
6828 | n2,
|
6829 | container,
|
6830 | anchor,
|
6831 | parentComponent,
|
6832 | parentSuspense,
|
6833 | namespace,
|
6834 | slotScopeIds,
|
6835 | optimized
|
6836 | );
|
6837 | break;
|
6838 | default:
|
6839 | if (shapeFlag & 1) {
|
6840 | processElement(
|
6841 | n1,
|
6842 | n2,
|
6843 | container,
|
6844 | anchor,
|
6845 | parentComponent,
|
6846 | parentSuspense,
|
6847 | namespace,
|
6848 | slotScopeIds,
|
6849 | optimized
|
6850 | );
|
6851 | } else if (shapeFlag & 6) {
|
6852 | processComponent(
|
6853 | n1,
|
6854 | n2,
|
6855 | container,
|
6856 | anchor,
|
6857 | parentComponent,
|
6858 | parentSuspense,
|
6859 | namespace,
|
6860 | slotScopeIds,
|
6861 | optimized
|
6862 | );
|
6863 | } else if (shapeFlag & 64) {
|
6864 | type.process(
|
6865 | n1,
|
6866 | n2,
|
6867 | container,
|
6868 | anchor,
|
6869 | parentComponent,
|
6870 | parentSuspense,
|
6871 | namespace,
|
6872 | slotScopeIds,
|
6873 | optimized,
|
6874 | internals
|
6875 | );
|
6876 | } else if (shapeFlag & 128) {
|
6877 | type.process(
|
6878 | n1,
|
6879 | n2,
|
6880 | container,
|
6881 | anchor,
|
6882 | parentComponent,
|
6883 | parentSuspense,
|
6884 | namespace,
|
6885 | slotScopeIds,
|
6886 | optimized,
|
6887 | internals
|
6888 | );
|
6889 | } else {
|
6890 | warn$1("Invalid VNode type:", type, `(${typeof type})`);
|
6891 | }
|
6892 | }
|
6893 | if (ref != null && parentComponent) {
|
6894 | setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
|
6895 | }
|
6896 | };
|
6897 | const processText = (n1, n2, container, anchor) => {
|
6898 | if (n1 == null) {
|
6899 | hostInsert(
|
6900 | n2.el = hostCreateText(n2.children),
|
6901 | container,
|
6902 | anchor
|
6903 | );
|
6904 | } else {
|
6905 | const el = n2.el = n1.el;
|
6906 | if (n2.children !== n1.children) {
|
6907 | hostSetText(el, n2.children);
|
6908 | }
|
6909 | }
|
6910 | };
|
6911 | const processCommentNode = (n1, n2, container, anchor) => {
|
6912 | if (n1 == null) {
|
6913 | hostInsert(
|
6914 | n2.el = hostCreateComment(n2.children || ""),
|
6915 | container,
|
6916 | anchor
|
6917 | );
|
6918 | } else {
|
6919 | n2.el = n1.el;
|
6920 | }
|
6921 | };
|
6922 | const mountStaticNode = (n2, container, anchor, namespace) => {
|
6923 | [n2.el, n2.anchor] = hostInsertStaticContent(
|
6924 | n2.children,
|
6925 | container,
|
6926 | anchor,
|
6927 | namespace,
|
6928 | n2.el,
|
6929 | n2.anchor
|
6930 | );
|
6931 | };
|
6932 | const patchStaticNode = (n1, n2, container, namespace) => {
|
6933 | if (n2.children !== n1.children) {
|
6934 | const anchor = hostNextSibling(n1.anchor);
|
6935 | removeStaticNode(n1);
|
6936 | [n2.el, n2.anchor] = hostInsertStaticContent(
|
6937 | n2.children,
|
6938 | container,
|
6939 | anchor,
|
6940 | namespace
|
6941 | );
|
6942 | } else {
|
6943 | n2.el = n1.el;
|
6944 | n2.anchor = n1.anchor;
|
6945 | }
|
6946 | };
|
6947 | const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
|
6948 | let next;
|
6949 | while (el && el !== anchor) {
|
6950 | next = hostNextSibling(el);
|
6951 | hostInsert(el, container, nextSibling);
|
6952 | el = next;
|
6953 | }
|
6954 | hostInsert(anchor, container, nextSibling);
|
6955 | };
|
6956 | const removeStaticNode = ({ el, anchor }) => {
|
6957 | let next;
|
6958 | while (el && el !== anchor) {
|
6959 | next = hostNextSibling(el);
|
6960 | hostRemove(el);
|
6961 | el = next;
|
6962 | }
|
6963 | hostRemove(anchor);
|
6964 | };
|
6965 | const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
6966 | if (n2.type === "svg") {
|
6967 | namespace = "svg";
|
6968 | } else if (n2.type === "math") {
|
6969 | namespace = "mathml";
|
6970 | }
|
6971 | if (n1 == null) {
|
6972 | mountElement(
|
6973 | n2,
|
6974 | container,
|
6975 | anchor,
|
6976 | parentComponent,
|
6977 | parentSuspense,
|
6978 | namespace,
|
6979 | slotScopeIds,
|
6980 | optimized
|
6981 | );
|
6982 | } else {
|
6983 | patchElement(
|
6984 | n1,
|
6985 | n2,
|
6986 | parentComponent,
|
6987 | parentSuspense,
|
6988 | namespace,
|
6989 | slotScopeIds,
|
6990 | optimized
|
6991 | );
|
6992 | }
|
6993 | };
|
6994 | const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
6995 | let el;
|
6996 | let vnodeHook;
|
6997 | const { props, shapeFlag, transition, dirs } = vnode;
|
6998 | el = vnode.el = hostCreateElement(
|
6999 | vnode.type,
|
7000 | namespace,
|
7001 | props && props.is,
|
7002 | props
|
7003 | );
|
7004 | if (shapeFlag & 8) {
|
7005 | hostSetElementText(el, vnode.children);
|
7006 | } else if (shapeFlag & 16) {
|
7007 | mountChildren(
|
7008 | vnode.children,
|
7009 | el,
|
7010 | null,
|
7011 | parentComponent,
|
7012 | parentSuspense,
|
7013 | resolveChildrenNamespace(vnode, namespace),
|
7014 | slotScopeIds,
|
7015 | optimized
|
7016 | );
|
7017 | }
|
7018 | if (dirs) {
|
7019 | invokeDirectiveHook(vnode, null, parentComponent, "created");
|
7020 | }
|
7021 | setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
|
7022 | if (props) {
|
7023 | for (const key in props) {
|
7024 | if (key !== "value" && !isReservedProp(key)) {
|
7025 | hostPatchProp(
|
7026 | el,
|
7027 | key,
|
7028 | null,
|
7029 | props[key],
|
7030 | namespace,
|
7031 | vnode.children,
|
7032 | parentComponent,
|
7033 | parentSuspense,
|
7034 | unmountChildren
|
7035 | );
|
7036 | }
|
7037 | }
|
7038 | if ("value" in props) {
|
7039 | hostPatchProp(el, "value", null, props.value, namespace);
|
7040 | }
|
7041 | if (vnodeHook = props.onVnodeBeforeMount) {
|
7042 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
7043 | }
|
7044 | }
|
7045 | {
|
7046 | Object.defineProperty(el, "__vnode", {
|
7047 | value: vnode,
|
7048 | enumerable: false
|
7049 | });
|
7050 | Object.defineProperty(el, "__vueParentComponent", {
|
7051 | value: parentComponent,
|
7052 | enumerable: false
|
7053 | });
|
7054 | }
|
7055 | if (dirs) {
|
7056 | invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
7057 | }
|
7058 | const needCallTransitionHooks = needTransition(parentSuspense, transition);
|
7059 | if (needCallTransitionHooks) {
|
7060 | transition.beforeEnter(el);
|
7061 | }
|
7062 | hostInsert(el, container, anchor);
|
7063 | if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
|
7064 | queuePostRenderEffect(() => {
|
7065 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
7066 | needCallTransitionHooks && transition.enter(el);
|
7067 | dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
7068 | }, parentSuspense);
|
7069 | }
|
7070 | };
|
7071 | const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
|
7072 | if (scopeId) {
|
7073 | hostSetScopeId(el, scopeId);
|
7074 | }
|
7075 | if (slotScopeIds) {
|
7076 | for (let i = 0; i < slotScopeIds.length; i++) {
|
7077 | hostSetScopeId(el, slotScopeIds[i]);
|
7078 | }
|
7079 | }
|
7080 | if (parentComponent) {
|
7081 | let subTree = parentComponent.subTree;
|
7082 | if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
|
7083 | subTree = filterSingleRoot(subTree.children) || subTree;
|
7084 | }
|
7085 | if (vnode === subTree) {
|
7086 | const parentVNode = parentComponent.vnode;
|
7087 | setScopeId(
|
7088 | el,
|
7089 | parentVNode,
|
7090 | parentVNode.scopeId,
|
7091 | parentVNode.slotScopeIds,
|
7092 | parentComponent.parent
|
7093 | );
|
7094 | }
|
7095 | }
|
7096 | };
|
7097 | const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
|
7098 | for (let i = start; i < children.length; i++) {
|
7099 | const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
|
7100 | patch(
|
7101 | null,
|
7102 | child,
|
7103 | container,
|
7104 | anchor,
|
7105 | parentComponent,
|
7106 | parentSuspense,
|
7107 | namespace,
|
7108 | slotScopeIds,
|
7109 | optimized
|
7110 | );
|
7111 | }
|
7112 | };
|
7113 | const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7114 | const el = n2.el = n1.el;
|
7115 | let { patchFlag, dynamicChildren, dirs } = n2;
|
7116 | patchFlag |= n1.patchFlag & 16;
|
7117 | const oldProps = n1.props || EMPTY_OBJ;
|
7118 | const newProps = n2.props || EMPTY_OBJ;
|
7119 | let vnodeHook;
|
7120 | parentComponent && toggleRecurse(parentComponent, false);
|
7121 | if (vnodeHook = newProps.onVnodeBeforeUpdate) {
|
7122 | invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
7123 | }
|
7124 | if (dirs) {
|
7125 | invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
|
7126 | }
|
7127 | parentComponent && toggleRecurse(parentComponent, true);
|
7128 | if (isHmrUpdating) {
|
7129 | patchFlag = 0;
|
7130 | optimized = false;
|
7131 | dynamicChildren = null;
|
7132 | }
|
7133 | if (dynamicChildren) {
|
7134 | patchBlockChildren(
|
7135 | n1.dynamicChildren,
|
7136 | dynamicChildren,
|
7137 | el,
|
7138 | parentComponent,
|
7139 | parentSuspense,
|
7140 | resolveChildrenNamespace(n2, namespace),
|
7141 | slotScopeIds
|
7142 | );
|
7143 | {
|
7144 | traverseStaticChildren(n1, n2);
|
7145 | }
|
7146 | } else if (!optimized) {
|
7147 | patchChildren(
|
7148 | n1,
|
7149 | n2,
|
7150 | el,
|
7151 | null,
|
7152 | parentComponent,
|
7153 | parentSuspense,
|
7154 | resolveChildrenNamespace(n2, namespace),
|
7155 | slotScopeIds,
|
7156 | false
|
7157 | );
|
7158 | }
|
7159 | if (patchFlag > 0) {
|
7160 | if (patchFlag & 16) {
|
7161 | patchProps(
|
7162 | el,
|
7163 | n2,
|
7164 | oldProps,
|
7165 | newProps,
|
7166 | parentComponent,
|
7167 | parentSuspense,
|
7168 | namespace
|
7169 | );
|
7170 | } else {
|
7171 | if (patchFlag & 2) {
|
7172 | if (oldProps.class !== newProps.class) {
|
7173 | hostPatchProp(el, "class", null, newProps.class, namespace);
|
7174 | }
|
7175 | }
|
7176 | if (patchFlag & 4) {
|
7177 | hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
|
7178 | }
|
7179 | if (patchFlag & 8) {
|
7180 | const propsToUpdate = n2.dynamicProps;
|
7181 | for (let i = 0; i < propsToUpdate.length; i++) {
|
7182 | const key = propsToUpdate[i];
|
7183 | const prev = oldProps[key];
|
7184 | const next = newProps[key];
|
7185 | if (next !== prev || key === "value") {
|
7186 | hostPatchProp(
|
7187 | el,
|
7188 | key,
|
7189 | prev,
|
7190 | next,
|
7191 | namespace,
|
7192 | n1.children,
|
7193 | parentComponent,
|
7194 | parentSuspense,
|
7195 | unmountChildren
|
7196 | );
|
7197 | }
|
7198 | }
|
7199 | }
|
7200 | }
|
7201 | if (patchFlag & 1) {
|
7202 | if (n1.children !== n2.children) {
|
7203 | hostSetElementText(el, n2.children);
|
7204 | }
|
7205 | }
|
7206 | } else if (!optimized && dynamicChildren == null) {
|
7207 | patchProps(
|
7208 | el,
|
7209 | n2,
|
7210 | oldProps,
|
7211 | newProps,
|
7212 | parentComponent,
|
7213 | parentSuspense,
|
7214 | namespace
|
7215 | );
|
7216 | }
|
7217 | if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
|
7218 | queuePostRenderEffect(() => {
|
7219 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
7220 | dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
|
7221 | }, parentSuspense);
|
7222 | }
|
7223 | };
|
7224 | const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
|
7225 | for (let i = 0; i < newChildren.length; i++) {
|
7226 | const oldVNode = oldChildren[i];
|
7227 | const newVNode = newChildren[i];
|
7228 | const container = (
|
7229 |
|
7230 |
|
7231 | oldVNode.el &&
|
7232 |
|
7233 | (oldVNode.type === Fragment ||
|
7234 |
|
7235 | !isSameVNodeType(oldVNode, newVNode) ||
|
7236 | oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
|
7237 |
|
7238 |
|
7239 | fallbackContainer
|
7240 | )
|
7241 | );
|
7242 | patch(
|
7243 | oldVNode,
|
7244 | newVNode,
|
7245 | container,
|
7246 | null,
|
7247 | parentComponent,
|
7248 | parentSuspense,
|
7249 | namespace,
|
7250 | slotScopeIds,
|
7251 | true
|
7252 | );
|
7253 | }
|
7254 | };
|
7255 | const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, namespace) => {
|
7256 | if (oldProps !== newProps) {
|
7257 | if (oldProps !== EMPTY_OBJ) {
|
7258 | for (const key in oldProps) {
|
7259 | if (!isReservedProp(key) && !(key in newProps)) {
|
7260 | hostPatchProp(
|
7261 | el,
|
7262 | key,
|
7263 | oldProps[key],
|
7264 | null,
|
7265 | namespace,
|
7266 | vnode.children,
|
7267 | parentComponent,
|
7268 | parentSuspense,
|
7269 | unmountChildren
|
7270 | );
|
7271 | }
|
7272 | }
|
7273 | }
|
7274 | for (const key in newProps) {
|
7275 | if (isReservedProp(key))
|
7276 | continue;
|
7277 | const next = newProps[key];
|
7278 | const prev = oldProps[key];
|
7279 | if (next !== prev && key !== "value") {
|
7280 | hostPatchProp(
|
7281 | el,
|
7282 | key,
|
7283 | prev,
|
7284 | next,
|
7285 | namespace,
|
7286 | vnode.children,
|
7287 | parentComponent,
|
7288 | parentSuspense,
|
7289 | unmountChildren
|
7290 | );
|
7291 | }
|
7292 | }
|
7293 | if ("value" in newProps) {
|
7294 | hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
|
7295 | }
|
7296 | }
|
7297 | };
|
7298 | const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7299 | const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
|
7300 | const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
|
7301 | let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
|
7302 | if (
|
7303 |
|
7304 | isHmrUpdating || patchFlag & 2048
|
7305 | ) {
|
7306 | patchFlag = 0;
|
7307 | optimized = false;
|
7308 | dynamicChildren = null;
|
7309 | }
|
7310 | if (fragmentSlotScopeIds) {
|
7311 | slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
7312 | }
|
7313 | if (n1 == null) {
|
7314 | hostInsert(fragmentStartAnchor, container, anchor);
|
7315 | hostInsert(fragmentEndAnchor, container, anchor);
|
7316 | mountChildren(
|
7317 |
|
7318 |
|
7319 |
|
7320 |
|
7321 | n2.children || [],
|
7322 | container,
|
7323 | fragmentEndAnchor,
|
7324 | parentComponent,
|
7325 | parentSuspense,
|
7326 | namespace,
|
7327 | slotScopeIds,
|
7328 | optimized
|
7329 | );
|
7330 | } else {
|
7331 | if (patchFlag > 0 && patchFlag & 64 && dynamicChildren &&
|
7332 |
|
7333 | n1.dynamicChildren) {
|
7334 | patchBlockChildren(
|
7335 | n1.dynamicChildren,
|
7336 | dynamicChildren,
|
7337 | container,
|
7338 | parentComponent,
|
7339 | parentSuspense,
|
7340 | namespace,
|
7341 | slotScopeIds
|
7342 | );
|
7343 | {
|
7344 | traverseStaticChildren(n1, n2);
|
7345 | }
|
7346 | } else {
|
7347 | patchChildren(
|
7348 | n1,
|
7349 | n2,
|
7350 | container,
|
7351 | fragmentEndAnchor,
|
7352 | parentComponent,
|
7353 | parentSuspense,
|
7354 | namespace,
|
7355 | slotScopeIds,
|
7356 | optimized
|
7357 | );
|
7358 | }
|
7359 | }
|
7360 | };
|
7361 | const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7362 | n2.slotScopeIds = slotScopeIds;
|
7363 | if (n1 == null) {
|
7364 | if (n2.shapeFlag & 512) {
|
7365 | parentComponent.ctx.activate(
|
7366 | n2,
|
7367 | container,
|
7368 | anchor,
|
7369 | namespace,
|
7370 | optimized
|
7371 | );
|
7372 | } else {
|
7373 | mountComponent(
|
7374 | n2,
|
7375 | container,
|
7376 | anchor,
|
7377 | parentComponent,
|
7378 | parentSuspense,
|
7379 | namespace,
|
7380 | optimized
|
7381 | );
|
7382 | }
|
7383 | } else {
|
7384 | updateComponent(n1, n2, optimized);
|
7385 | }
|
7386 | };
|
7387 | const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
|
7388 | const instance = (initialVNode.component = createComponentInstance(
|
7389 | initialVNode,
|
7390 | parentComponent,
|
7391 | parentSuspense
|
7392 | ));
|
7393 | if (instance.type.__hmrId) {
|
7394 | registerHMR(instance);
|
7395 | }
|
7396 | {
|
7397 | pushWarningContext(initialVNode);
|
7398 | startMeasure(instance, `mount`);
|
7399 | }
|
7400 | if (isKeepAlive(initialVNode)) {
|
7401 | instance.ctx.renderer = internals;
|
7402 | }
|
7403 | {
|
7404 | {
|
7405 | startMeasure(instance, `init`);
|
7406 | }
|
7407 | setupComponent(instance);
|
7408 | {
|
7409 | endMeasure(instance, `init`);
|
7410 | }
|
7411 | }
|
7412 | if (instance.asyncDep) {
|
7413 | parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
|
7414 | if (!initialVNode.el) {
|
7415 | const placeholder = instance.subTree = createVNode(Comment);
|
7416 | processCommentNode(null, placeholder, container, anchor);
|
7417 | }
|
7418 | } else {
|
7419 | setupRenderEffect(
|
7420 | instance,
|
7421 | initialVNode,
|
7422 | container,
|
7423 | anchor,
|
7424 | parentSuspense,
|
7425 | namespace,
|
7426 | optimized
|
7427 | );
|
7428 | }
|
7429 | {
|
7430 | popWarningContext();
|
7431 | endMeasure(instance, `mount`);
|
7432 | }
|
7433 | };
|
7434 | const updateComponent = (n1, n2, optimized) => {
|
7435 | const instance = n2.component = n1.component;
|
7436 | if (shouldUpdateComponent(n1, n2, optimized)) {
|
7437 | if (instance.asyncDep && !instance.asyncResolved) {
|
7438 | {
|
7439 | pushWarningContext(n2);
|
7440 | }
|
7441 | updateComponentPreRender(instance, n2, optimized);
|
7442 | {
|
7443 | popWarningContext();
|
7444 | }
|
7445 | return;
|
7446 | } else {
|
7447 | instance.next = n2;
|
7448 | invalidateJob(instance.update);
|
7449 | instance.effect.dirty = true;
|
7450 | instance.update();
|
7451 | }
|
7452 | } else {
|
7453 | n2.el = n1.el;
|
7454 | instance.vnode = n2;
|
7455 | }
|
7456 | };
|
7457 | const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
|
7458 | const componentUpdateFn = () => {
|
7459 | if (!instance.isMounted) {
|
7460 | let vnodeHook;
|
7461 | const { el, props } = initialVNode;
|
7462 | const { bm, m, parent } = instance;
|
7463 | const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
|
7464 | toggleRecurse(instance, false);
|
7465 | if (bm) {
|
7466 | invokeArrayFns(bm);
|
7467 | }
|
7468 | if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
|
7469 | invokeVNodeHook(vnodeHook, parent, initialVNode);
|
7470 | }
|
7471 | toggleRecurse(instance, true);
|
7472 | if (el && hydrateNode) {
|
7473 | const hydrateSubTree = () => {
|
7474 | {
|
7475 | startMeasure(instance, `render`);
|
7476 | }
|
7477 | instance.subTree = renderComponentRoot(instance);
|
7478 | {
|
7479 | endMeasure(instance, `render`);
|
7480 | }
|
7481 | {
|
7482 | startMeasure(instance, `hydrate`);
|
7483 | }
|
7484 | hydrateNode(
|
7485 | el,
|
7486 | instance.subTree,
|
7487 | instance,
|
7488 | parentSuspense,
|
7489 | null
|
7490 | );
|
7491 | {
|
7492 | endMeasure(instance, `hydrate`);
|
7493 | }
|
7494 | };
|
7495 | if (isAsyncWrapperVNode) {
|
7496 | initialVNode.type.__asyncLoader().then(
|
7497 |
|
7498 |
|
7499 |
|
7500 |
|
7501 | () => !instance.isUnmounted && hydrateSubTree()
|
7502 | );
|
7503 | } else {
|
7504 | hydrateSubTree();
|
7505 | }
|
7506 | } else {
|
7507 | {
|
7508 | startMeasure(instance, `render`);
|
7509 | }
|
7510 | const subTree = instance.subTree = renderComponentRoot(instance);
|
7511 | {
|
7512 | endMeasure(instance, `render`);
|
7513 | }
|
7514 | {
|
7515 | startMeasure(instance, `patch`);
|
7516 | }
|
7517 | patch(
|
7518 | null,
|
7519 | subTree,
|
7520 | container,
|
7521 | anchor,
|
7522 | instance,
|
7523 | parentSuspense,
|
7524 | namespace
|
7525 | );
|
7526 | {
|
7527 | endMeasure(instance, `patch`);
|
7528 | }
|
7529 | initialVNode.el = subTree.el;
|
7530 | }
|
7531 | if (m) {
|
7532 | queuePostRenderEffect(m, parentSuspense);
|
7533 | }
|
7534 | if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
|
7535 | const scopedInitialVNode = initialVNode;
|
7536 | queuePostRenderEffect(
|
7537 | () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
|
7538 | parentSuspense
|
7539 | );
|
7540 | }
|
7541 | if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
|
7542 | instance.a && queuePostRenderEffect(instance.a, parentSuspense);
|
7543 | }
|
7544 | instance.isMounted = true;
|
7545 | {
|
7546 | devtoolsComponentAdded(instance);
|
7547 | }
|
7548 | initialVNode = container = anchor = null;
|
7549 | } else {
|
7550 | let { next, bu, u, parent, vnode } = instance;
|
7551 | {
|
7552 | const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
|
7553 | if (nonHydratedAsyncRoot) {
|
7554 | if (next) {
|
7555 | next.el = vnode.el;
|
7556 | updateComponentPreRender(instance, next, optimized);
|
7557 | }
|
7558 | nonHydratedAsyncRoot.asyncDep.then(() => {
|
7559 | if (!instance.isUnmounted) {
|
7560 | componentUpdateFn();
|
7561 | }
|
7562 | });
|
7563 | return;
|
7564 | }
|
7565 | }
|
7566 | let originNext = next;
|
7567 | let vnodeHook;
|
7568 | {
|
7569 | pushWarningContext(next || instance.vnode);
|
7570 | }
|
7571 | toggleRecurse(instance, false);
|
7572 | if (next) {
|
7573 | next.el = vnode.el;
|
7574 | updateComponentPreRender(instance, next, optimized);
|
7575 | } else {
|
7576 | next = vnode;
|
7577 | }
|
7578 | if (bu) {
|
7579 | invokeArrayFns(bu);
|
7580 | }
|
7581 | if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
|
7582 | invokeVNodeHook(vnodeHook, parent, next, vnode);
|
7583 | }
|
7584 | toggleRecurse(instance, true);
|
7585 | {
|
7586 | startMeasure(instance, `render`);
|
7587 | }
|
7588 | const nextTree = renderComponentRoot(instance);
|
7589 | {
|
7590 | endMeasure(instance, `render`);
|
7591 | }
|
7592 | const prevTree = instance.subTree;
|
7593 | instance.subTree = nextTree;
|
7594 | {
|
7595 | startMeasure(instance, `patch`);
|
7596 | }
|
7597 | patch(
|
7598 | prevTree,
|
7599 | nextTree,
|
7600 |
|
7601 | hostParentNode(prevTree.el),
|
7602 |
|
7603 | getNextHostNode(prevTree),
|
7604 | instance,
|
7605 | parentSuspense,
|
7606 | namespace
|
7607 | );
|
7608 | {
|
7609 | endMeasure(instance, `patch`);
|
7610 | }
|
7611 | next.el = nextTree.el;
|
7612 | if (originNext === null) {
|
7613 | updateHOCHostEl(instance, nextTree.el);
|
7614 | }
|
7615 | if (u) {
|
7616 | queuePostRenderEffect(u, parentSuspense);
|
7617 | }
|
7618 | if (vnodeHook = next.props && next.props.onVnodeUpdated) {
|
7619 | queuePostRenderEffect(
|
7620 | () => invokeVNodeHook(vnodeHook, parent, next, vnode),
|
7621 | parentSuspense
|
7622 | );
|
7623 | }
|
7624 | {
|
7625 | devtoolsComponentUpdated(instance);
|
7626 | }
|
7627 | {
|
7628 | popWarningContext();
|
7629 | }
|
7630 | }
|
7631 | };
|
7632 | const effect = instance.effect = new ReactiveEffect(
|
7633 | componentUpdateFn,
|
7634 | NOOP,
|
7635 | () => queueJob(update),
|
7636 | instance.scope
|
7637 |
|
7638 | );
|
7639 | const update = instance.update = () => {
|
7640 | if (effect.dirty) {
|
7641 | effect.run();
|
7642 | }
|
7643 | };
|
7644 | update.id = instance.uid;
|
7645 | toggleRecurse(instance, true);
|
7646 | {
|
7647 | effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
|
7648 | effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
|
7649 | update.ownerInstance = instance;
|
7650 | }
|
7651 | update();
|
7652 | };
|
7653 | const updateComponentPreRender = (instance, nextVNode, optimized) => {
|
7654 | nextVNode.component = instance;
|
7655 | const prevProps = instance.vnode.props;
|
7656 | instance.vnode = nextVNode;
|
7657 | instance.next = null;
|
7658 | updateProps(instance, nextVNode.props, prevProps, optimized);
|
7659 | updateSlots(instance, nextVNode.children, optimized);
|
7660 | pauseTracking();
|
7661 | flushPreFlushCbs(instance);
|
7662 | resetTracking();
|
7663 | };
|
7664 | const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
|
7665 | const c1 = n1 && n1.children;
|
7666 | const prevShapeFlag = n1 ? n1.shapeFlag : 0;
|
7667 | const c2 = n2.children;
|
7668 | const { patchFlag, shapeFlag } = n2;
|
7669 | if (patchFlag > 0) {
|
7670 | if (patchFlag & 128) {
|
7671 | patchKeyedChildren(
|
7672 | c1,
|
7673 | c2,
|
7674 | container,
|
7675 | anchor,
|
7676 | parentComponent,
|
7677 | parentSuspense,
|
7678 | namespace,
|
7679 | slotScopeIds,
|
7680 | optimized
|
7681 | );
|
7682 | return;
|
7683 | } else if (patchFlag & 256) {
|
7684 | patchUnkeyedChildren(
|
7685 | c1,
|
7686 | c2,
|
7687 | container,
|
7688 | anchor,
|
7689 | parentComponent,
|
7690 | parentSuspense,
|
7691 | namespace,
|
7692 | slotScopeIds,
|
7693 | optimized
|
7694 | );
|
7695 | return;
|
7696 | }
|
7697 | }
|
7698 | if (shapeFlag & 8) {
|
7699 | if (prevShapeFlag & 16) {
|
7700 | unmountChildren(c1, parentComponent, parentSuspense);
|
7701 | }
|
7702 | if (c2 !== c1) {
|
7703 | hostSetElementText(container, c2);
|
7704 | }
|
7705 | } else {
|
7706 | if (prevShapeFlag & 16) {
|
7707 | if (shapeFlag & 16) {
|
7708 | patchKeyedChildren(
|
7709 | c1,
|
7710 | c2,
|
7711 | container,
|
7712 | anchor,
|
7713 | parentComponent,
|
7714 | parentSuspense,
|
7715 | namespace,
|
7716 | slotScopeIds,
|
7717 | optimized
|
7718 | );
|
7719 | } else {
|
7720 | unmountChildren(c1, parentComponent, parentSuspense, true);
|
7721 | }
|
7722 | } else {
|
7723 | if (prevShapeFlag & 8) {
|
7724 | hostSetElementText(container, "");
|
7725 | }
|
7726 | if (shapeFlag & 16) {
|
7727 | mountChildren(
|
7728 | c2,
|
7729 | container,
|
7730 | anchor,
|
7731 | parentComponent,
|
7732 | parentSuspense,
|
7733 | namespace,
|
7734 | slotScopeIds,
|
7735 | optimized
|
7736 | );
|
7737 | }
|
7738 | }
|
7739 | }
|
7740 | };
|
7741 | const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7742 | c1 = c1 || EMPTY_ARR;
|
7743 | c2 = c2 || EMPTY_ARR;
|
7744 | const oldLength = c1.length;
|
7745 | const newLength = c2.length;
|
7746 | const commonLength = Math.min(oldLength, newLength);
|
7747 | let i;
|
7748 | for (i = 0; i < commonLength; i++) {
|
7749 | const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
7750 | patch(
|
7751 | c1[i],
|
7752 | nextChild,
|
7753 | container,
|
7754 | null,
|
7755 | parentComponent,
|
7756 | parentSuspense,
|
7757 | namespace,
|
7758 | slotScopeIds,
|
7759 | optimized
|
7760 | );
|
7761 | }
|
7762 | if (oldLength > newLength) {
|
7763 | unmountChildren(
|
7764 | c1,
|
7765 | parentComponent,
|
7766 | parentSuspense,
|
7767 | true,
|
7768 | false,
|
7769 | commonLength
|
7770 | );
|
7771 | } else {
|
7772 | mountChildren(
|
7773 | c2,
|
7774 | container,
|
7775 | anchor,
|
7776 | parentComponent,
|
7777 | parentSuspense,
|
7778 | namespace,
|
7779 | slotScopeIds,
|
7780 | optimized,
|
7781 | commonLength
|
7782 | );
|
7783 | }
|
7784 | };
|
7785 | const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
7786 | let i = 0;
|
7787 | const l2 = c2.length;
|
7788 | let e1 = c1.length - 1;
|
7789 | let e2 = l2 - 1;
|
7790 | while (i <= e1 && i <= e2) {
|
7791 | const n1 = c1[i];
|
7792 | const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
7793 | if (isSameVNodeType(n1, n2)) {
|
7794 | patch(
|
7795 | n1,
|
7796 | n2,
|
7797 | container,
|
7798 | null,
|
7799 | parentComponent,
|
7800 | parentSuspense,
|
7801 | namespace,
|
7802 | slotScopeIds,
|
7803 | optimized
|
7804 | );
|
7805 | } else {
|
7806 | break;
|
7807 | }
|
7808 | i++;
|
7809 | }
|
7810 | while (i <= e1 && i <= e2) {
|
7811 | const n1 = c1[e1];
|
7812 | const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
|
7813 | if (isSameVNodeType(n1, n2)) {
|
7814 | patch(
|
7815 | n1,
|
7816 | n2,
|
7817 | container,
|
7818 | null,
|
7819 | parentComponent,
|
7820 | parentSuspense,
|
7821 | namespace,
|
7822 | slotScopeIds,
|
7823 | optimized
|
7824 | );
|
7825 | } else {
|
7826 | break;
|
7827 | }
|
7828 | e1--;
|
7829 | e2--;
|
7830 | }
|
7831 | if (i > e1) {
|
7832 | if (i <= e2) {
|
7833 | const nextPos = e2 + 1;
|
7834 | const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
|
7835 | while (i <= e2) {
|
7836 | patch(
|
7837 | null,
|
7838 | c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
|
7839 | container,
|
7840 | anchor,
|
7841 | parentComponent,
|
7842 | parentSuspense,
|
7843 | namespace,
|
7844 | slotScopeIds,
|
7845 | optimized
|
7846 | );
|
7847 | i++;
|
7848 | }
|
7849 | }
|
7850 | } else if (i > e2) {
|
7851 | while (i <= e1) {
|
7852 | unmount(c1[i], parentComponent, parentSuspense, true);
|
7853 | i++;
|
7854 | }
|
7855 | } else {
|
7856 | const s1 = i;
|
7857 | const s2 = i;
|
7858 | const keyToNewIndexMap = new Map();
|
7859 | for (i = s2; i <= e2; i++) {
|
7860 | const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
7861 | if (nextChild.key != null) {
|
7862 | if (keyToNewIndexMap.has(nextChild.key)) {
|
7863 | warn$1(
|
7864 | `Duplicate keys found during update:`,
|
7865 | JSON.stringify(nextChild.key),
|
7866 | `Make sure keys are unique.`
|
7867 | );
|
7868 | }
|
7869 | keyToNewIndexMap.set(nextChild.key, i);
|
7870 | }
|
7871 | }
|
7872 | let j;
|
7873 | let patched = 0;
|
7874 | const toBePatched = e2 - s2 + 1;
|
7875 | let moved = false;
|
7876 | let maxNewIndexSoFar = 0;
|
7877 | const newIndexToOldIndexMap = new Array(toBePatched);
|
7878 | for (i = 0; i < toBePatched; i++)
|
7879 | newIndexToOldIndexMap[i] = 0;
|
7880 | for (i = s1; i <= e1; i++) {
|
7881 | const prevChild = c1[i];
|
7882 | if (patched >= toBePatched) {
|
7883 | unmount(prevChild, parentComponent, parentSuspense, true);
|
7884 | continue;
|
7885 | }
|
7886 | let newIndex;
|
7887 | if (prevChild.key != null) {
|
7888 | newIndex = keyToNewIndexMap.get(prevChild.key);
|
7889 | } else {
|
7890 | for (j = s2; j <= e2; j++) {
|
7891 | if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
|
7892 | newIndex = j;
|
7893 | break;
|
7894 | }
|
7895 | }
|
7896 | }
|
7897 | if (newIndex === void 0) {
|
7898 | unmount(prevChild, parentComponent, parentSuspense, true);
|
7899 | } else {
|
7900 | newIndexToOldIndexMap[newIndex - s2] = i + 1;
|
7901 | if (newIndex >= maxNewIndexSoFar) {
|
7902 | maxNewIndexSoFar = newIndex;
|
7903 | } else {
|
7904 | moved = true;
|
7905 | }
|
7906 | patch(
|
7907 | prevChild,
|
7908 | c2[newIndex],
|
7909 | container,
|
7910 | null,
|
7911 | parentComponent,
|
7912 | parentSuspense,
|
7913 | namespace,
|
7914 | slotScopeIds,
|
7915 | optimized
|
7916 | );
|
7917 | patched++;
|
7918 | }
|
7919 | }
|
7920 | const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
|
7921 | j = increasingNewIndexSequence.length - 1;
|
7922 | for (i = toBePatched - 1; i >= 0; i--) {
|
7923 | const nextIndex = s2 + i;
|
7924 | const nextChild = c2[nextIndex];
|
7925 | const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
|
7926 | if (newIndexToOldIndexMap[i] === 0) {
|
7927 | patch(
|
7928 | null,
|
7929 | nextChild,
|
7930 | container,
|
7931 | anchor,
|
7932 | parentComponent,
|
7933 | parentSuspense,
|
7934 | namespace,
|
7935 | slotScopeIds,
|
7936 | optimized
|
7937 | );
|
7938 | } else if (moved) {
|
7939 | if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
7940 | move(nextChild, container, anchor, 2);
|
7941 | } else {
|
7942 | j--;
|
7943 | }
|
7944 | }
|
7945 | }
|
7946 | }
|
7947 | };
|
7948 | const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
|
7949 | const { el, type, transition, children, shapeFlag } = vnode;
|
7950 | if (shapeFlag & 6) {
|
7951 | move(vnode.component.subTree, container, anchor, moveType);
|
7952 | return;
|
7953 | }
|
7954 | if (shapeFlag & 128) {
|
7955 | vnode.suspense.move(container, anchor, moveType);
|
7956 | return;
|
7957 | }
|
7958 | if (shapeFlag & 64) {
|
7959 | type.move(vnode, container, anchor, internals);
|
7960 | return;
|
7961 | }
|
7962 | if (type === Fragment) {
|
7963 | hostInsert(el, container, anchor);
|
7964 | for (let i = 0; i < children.length; i++) {
|
7965 | move(children[i], container, anchor, moveType);
|
7966 | }
|
7967 | hostInsert(vnode.anchor, container, anchor);
|
7968 | return;
|
7969 | }
|
7970 | if (type === Static) {
|
7971 | moveStaticNode(vnode, container, anchor);
|
7972 | return;
|
7973 | }
|
7974 | const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
|
7975 | if (needTransition2) {
|
7976 | if (moveType === 0) {
|
7977 | transition.beforeEnter(el);
|
7978 | hostInsert(el, container, anchor);
|
7979 | queuePostRenderEffect(() => transition.enter(el), parentSuspense);
|
7980 | } else {
|
7981 | const { leave, delayLeave, afterLeave } = transition;
|
7982 | const remove2 = () => hostInsert(el, container, anchor);
|
7983 | const performLeave = () => {
|
7984 | leave(el, () => {
|
7985 | remove2();
|
7986 | afterLeave && afterLeave();
|
7987 | });
|
7988 | };
|
7989 | if (delayLeave) {
|
7990 | delayLeave(el, remove2, performLeave);
|
7991 | } else {
|
7992 | performLeave();
|
7993 | }
|
7994 | }
|
7995 | } else {
|
7996 | hostInsert(el, container, anchor);
|
7997 | }
|
7998 | };
|
7999 | const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
|
8000 | const {
|
8001 | type,
|
8002 | props,
|
8003 | ref,
|
8004 | children,
|
8005 | dynamicChildren,
|
8006 | shapeFlag,
|
8007 | patchFlag,
|
8008 | dirs
|
8009 | } = vnode;
|
8010 | if (ref != null) {
|
8011 | setRef(ref, null, parentSuspense, vnode, true);
|
8012 | }
|
8013 | if (shapeFlag & 256) {
|
8014 | parentComponent.ctx.deactivate(vnode);
|
8015 | return;
|
8016 | }
|
8017 | const shouldInvokeDirs = shapeFlag & 1 && dirs;
|
8018 | const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
|
8019 | let vnodeHook;
|
8020 | if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
|
8021 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
8022 | }
|
8023 | if (shapeFlag & 6) {
|
8024 | unmountComponent(vnode.component, parentSuspense, doRemove);
|
8025 | } else {
|
8026 | if (shapeFlag & 128) {
|
8027 | vnode.suspense.unmount(parentSuspense, doRemove);
|
8028 | return;
|
8029 | }
|
8030 | if (shouldInvokeDirs) {
|
8031 | invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
|
8032 | }
|
8033 | if (shapeFlag & 64) {
|
8034 | vnode.type.remove(
|
8035 | vnode,
|
8036 | parentComponent,
|
8037 | parentSuspense,
|
8038 | optimized,
|
8039 | internals,
|
8040 | doRemove
|
8041 | );
|
8042 | } else if (dynamicChildren &&
|
8043 | (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
|
8044 | unmountChildren(
|
8045 | dynamicChildren,
|
8046 | parentComponent,
|
8047 | parentSuspense,
|
8048 | false,
|
8049 | true
|
8050 | );
|
8051 | } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
|
8052 | unmountChildren(children, parentComponent, parentSuspense);
|
8053 | }
|
8054 | if (doRemove) {
|
8055 | remove(vnode);
|
8056 | }
|
8057 | }
|
8058 | if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
|
8059 | queuePostRenderEffect(() => {
|
8060 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
8061 | shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
|
8062 | }, parentSuspense);
|
8063 | }
|
8064 | };
|
8065 | const remove = (vnode) => {
|
8066 | const { type, el, anchor, transition } = vnode;
|
8067 | if (type === Fragment) {
|
8068 | if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
|
8069 | vnode.children.forEach((child) => {
|
8070 | if (child.type === Comment) {
|
8071 | hostRemove(child.el);
|
8072 | } else {
|
8073 | remove(child);
|
8074 | }
|
8075 | });
|
8076 | } else {
|
8077 | removeFragment(el, anchor);
|
8078 | }
|
8079 | return;
|
8080 | }
|
8081 | if (type === Static) {
|
8082 | removeStaticNode(vnode);
|
8083 | return;
|
8084 | }
|
8085 | const performRemove = () => {
|
8086 | hostRemove(el);
|
8087 | if (transition && !transition.persisted && transition.afterLeave) {
|
8088 | transition.afterLeave();
|
8089 | }
|
8090 | };
|
8091 | if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
|
8092 | const { leave, delayLeave } = transition;
|
8093 | const performLeave = () => leave(el, performRemove);
|
8094 | if (delayLeave) {
|
8095 | delayLeave(vnode.el, performRemove, performLeave);
|
8096 | } else {
|
8097 | performLeave();
|
8098 | }
|
8099 | } else {
|
8100 | performRemove();
|
8101 | }
|
8102 | };
|
8103 | const removeFragment = (cur, end) => {
|
8104 | let next;
|
8105 | while (cur !== end) {
|
8106 | next = hostNextSibling(cur);
|
8107 | hostRemove(cur);
|
8108 | cur = next;
|
8109 | }
|
8110 | hostRemove(end);
|
8111 | };
|
8112 | const unmountComponent = (instance, parentSuspense, doRemove) => {
|
8113 | if (instance.type.__hmrId) {
|
8114 | unregisterHMR(instance);
|
8115 | }
|
8116 | const { bum, scope, update, subTree, um } = instance;
|
8117 | if (bum) {
|
8118 | invokeArrayFns(bum);
|
8119 | }
|
8120 | scope.stop();
|
8121 | if (update) {
|
8122 | update.active = false;
|
8123 | unmount(subTree, instance, parentSuspense, doRemove);
|
8124 | }
|
8125 | if (um) {
|
8126 | queuePostRenderEffect(um, parentSuspense);
|
8127 | }
|
8128 | queuePostRenderEffect(() => {
|
8129 | instance.isUnmounted = true;
|
8130 | }, parentSuspense);
|
8131 | if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
|
8132 | parentSuspense.deps--;
|
8133 | if (parentSuspense.deps === 0) {
|
8134 | parentSuspense.resolve();
|
8135 | }
|
8136 | }
|
8137 | {
|
8138 | devtoolsComponentRemoved(instance);
|
8139 | }
|
8140 | };
|
8141 | const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
|
8142 | for (let i = start; i < children.length; i++) {
|
8143 | unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
|
8144 | }
|
8145 | };
|
8146 | const getNextHostNode = (vnode) => {
|
8147 | if (vnode.shapeFlag & 6) {
|
8148 | return getNextHostNode(vnode.component.subTree);
|
8149 | }
|
8150 | if (vnode.shapeFlag & 128) {
|
8151 | return vnode.suspense.next();
|
8152 | }
|
8153 | return hostNextSibling(vnode.anchor || vnode.el);
|
8154 | };
|
8155 | let isFlushing = false;
|
8156 | const render = (vnode, container, namespace) => {
|
8157 | if (vnode == null) {
|
8158 | if (container._vnode) {
|
8159 | unmount(container._vnode, null, null, true);
|
8160 | }
|
8161 | } else {
|
8162 | patch(
|
8163 | container._vnode || null,
|
8164 | vnode,
|
8165 | container,
|
8166 | null,
|
8167 | null,
|
8168 | null,
|
8169 | namespace
|
8170 | );
|
8171 | }
|
8172 | if (!isFlushing) {
|
8173 | isFlushing = true;
|
8174 | flushPreFlushCbs();
|
8175 | flushPostFlushCbs();
|
8176 | isFlushing = false;
|
8177 | }
|
8178 | container._vnode = vnode;
|
8179 | };
|
8180 | const internals = {
|
8181 | p: patch,
|
8182 | um: unmount,
|
8183 | m: move,
|
8184 | r: remove,
|
8185 | mt: mountComponent,
|
8186 | mc: mountChildren,
|
8187 | pc: patchChildren,
|
8188 | pbc: patchBlockChildren,
|
8189 | n: getNextHostNode,
|
8190 | o: options
|
8191 | };
|
8192 | let hydrate;
|
8193 | let hydrateNode;
|
8194 | if (createHydrationFns) {
|
8195 | [hydrate, hydrateNode] = createHydrationFns(
|
8196 | internals
|
8197 | );
|
8198 | }
|
8199 | return {
|
8200 | render,
|
8201 | hydrate,
|
8202 | createApp: createAppAPI(render, hydrate)
|
8203 | };
|
8204 | }
|
8205 | function resolveChildrenNamespace({ type, props }, currentNamespace) {
|
8206 | return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
|
8207 | }
|
8208 | function toggleRecurse({ effect, update }, allowed) {
|
8209 | effect.allowRecurse = update.allowRecurse = allowed;
|
8210 | }
|
8211 | function needTransition(parentSuspense, transition) {
|
8212 | return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
|
8213 | }
|
8214 | function traverseStaticChildren(n1, n2, shallow = false) {
|
8215 | const ch1 = n1.children;
|
8216 | const ch2 = n2.children;
|
8217 | if (isArray(ch1) && isArray(ch2)) {
|
8218 | for (let i = 0; i < ch1.length; i++) {
|
8219 | const c1 = ch1[i];
|
8220 | let c2 = ch2[i];
|
8221 | if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
|
8222 | if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
|
8223 | c2 = ch2[i] = cloneIfMounted(ch2[i]);
|
8224 | c2.el = c1.el;
|
8225 | }
|
8226 | if (!shallow)
|
8227 | traverseStaticChildren(c1, c2);
|
8228 | }
|
8229 | if (c2.type === Text) {
|
8230 | c2.el = c1.el;
|
8231 | }
|
8232 | if (c2.type === Comment && !c2.el) {
|
8233 | c2.el = c1.el;
|
8234 | }
|
8235 | }
|
8236 | }
|
8237 | }
|
8238 | function getSequence(arr) {
|
8239 | const p = arr.slice();
|
8240 | const result = [0];
|
8241 | let i, j, u, v, c;
|
8242 | const len = arr.length;
|
8243 | for (i = 0; i < len; i++) {
|
8244 | const arrI = arr[i];
|
8245 | if (arrI !== 0) {
|
8246 | j = result[result.length - 1];
|
8247 | if (arr[j] < arrI) {
|
8248 | p[i] = j;
|
8249 | result.push(i);
|
8250 | continue;
|
8251 | }
|
8252 | u = 0;
|
8253 | v = result.length - 1;
|
8254 | while (u < v) {
|
8255 | c = u + v >> 1;
|
8256 | if (arr[result[c]] < arrI) {
|
8257 | u = c + 1;
|
8258 | } else {
|
8259 | v = c;
|
8260 | }
|
8261 | }
|
8262 | if (arrI < arr[result[u]]) {
|
8263 | if (u > 0) {
|
8264 | p[i] = result[u - 1];
|
8265 | }
|
8266 | result[u] = i;
|
8267 | }
|
8268 | }
|
8269 | }
|
8270 | u = result.length;
|
8271 | v = result[u - 1];
|
8272 | while (u-- > 0) {
|
8273 | result[u] = v;
|
8274 | v = p[v];
|
8275 | }
|
8276 | return result;
|
8277 | }
|
8278 | function locateNonHydratedAsyncRoot(instance) {
|
8279 | const subComponent = instance.subTree.component;
|
8280 | if (subComponent) {
|
8281 | if (subComponent.asyncDep && !subComponent.asyncResolved) {
|
8282 | return subComponent;
|
8283 | } else {
|
8284 | return locateNonHydratedAsyncRoot(subComponent);
|
8285 | }
|
8286 | }
|
8287 | }
|
8288 |
|
8289 | const isTeleport = (type) => type.__isTeleport;
|
8290 | const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
|
8291 | const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
|
8292 | const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
|
8293 | const resolveTarget = (props, select) => {
|
8294 | const targetSelector = props && props.to;
|
8295 | if (isString(targetSelector)) {
|
8296 | if (!select) {
|
8297 | warn$1(
|
8298 | `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`
|
8299 | );
|
8300 | return null;
|
8301 | } else {
|
8302 | const target = select(targetSelector);
|
8303 | if (!target) {
|
8304 | warn$1(
|
8305 | `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.`
|
8306 | );
|
8307 | }
|
8308 | return target;
|
8309 | }
|
8310 | } else {
|
8311 | if (!targetSelector && !isTeleportDisabled(props)) {
|
8312 | warn$1(`Invalid Teleport target: ${targetSelector}`);
|
8313 | }
|
8314 | return targetSelector;
|
8315 | }
|
8316 | };
|
8317 | const TeleportImpl = {
|
8318 | name: "Teleport",
|
8319 | __isTeleport: true,
|
8320 | process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
|
8321 | const {
|
8322 | mc: mountChildren,
|
8323 | pc: patchChildren,
|
8324 | pbc: patchBlockChildren,
|
8325 | o: { insert, querySelector, createText, createComment }
|
8326 | } = internals;
|
8327 | const disabled = isTeleportDisabled(n2.props);
|
8328 | let { shapeFlag, children, dynamicChildren } = n2;
|
8329 | if (isHmrUpdating) {
|
8330 | optimized = false;
|
8331 | dynamicChildren = null;
|
8332 | }
|
8333 | if (n1 == null) {
|
8334 | const placeholder = n2.el = createComment("teleport start") ;
|
8335 | const mainAnchor = n2.anchor = createComment("teleport end") ;
|
8336 | insert(placeholder, container, anchor);
|
8337 | insert(mainAnchor, container, anchor);
|
8338 | const target = n2.target = resolveTarget(n2.props, querySelector);
|
8339 | const targetAnchor = n2.targetAnchor = createText("");
|
8340 | if (target) {
|
8341 | insert(targetAnchor, target);
|
8342 | if (namespace === "svg" || isTargetSVG(target)) {
|
8343 | namespace = "svg";
|
8344 | } else if (namespace === "mathml" || isTargetMathML(target)) {
|
8345 | namespace = "mathml";
|
8346 | }
|
8347 | } else if (!disabled) {
|
8348 | warn$1("Invalid Teleport target on mount:", target, `(${typeof target})`);
|
8349 | }
|
8350 | const mount = (container2, anchor2) => {
|
8351 | if (shapeFlag & 16) {
|
8352 | mountChildren(
|
8353 | children,
|
8354 | container2,
|
8355 | anchor2,
|
8356 | parentComponent,
|
8357 | parentSuspense,
|
8358 | namespace,
|
8359 | slotScopeIds,
|
8360 | optimized
|
8361 | );
|
8362 | }
|
8363 | };
|
8364 | if (disabled) {
|
8365 | mount(container, mainAnchor);
|
8366 | } else if (target) {
|
8367 | mount(target, targetAnchor);
|
8368 | }
|
8369 | } else {
|
8370 | n2.el = n1.el;
|
8371 | const mainAnchor = n2.anchor = n1.anchor;
|
8372 | const target = n2.target = n1.target;
|
8373 | const targetAnchor = n2.targetAnchor = n1.targetAnchor;
|
8374 | const wasDisabled = isTeleportDisabled(n1.props);
|
8375 | const currentContainer = wasDisabled ? container : target;
|
8376 | const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
|
8377 | if (namespace === "svg" || isTargetSVG(target)) {
|
8378 | namespace = "svg";
|
8379 | } else if (namespace === "mathml" || isTargetMathML(target)) {
|
8380 | namespace = "mathml";
|
8381 | }
|
8382 | if (dynamicChildren) {
|
8383 | patchBlockChildren(
|
8384 | n1.dynamicChildren,
|
8385 | dynamicChildren,
|
8386 | currentContainer,
|
8387 | parentComponent,
|
8388 | parentSuspense,
|
8389 | namespace,
|
8390 | slotScopeIds
|
8391 | );
|
8392 | traverseStaticChildren(n1, n2, true);
|
8393 | } else if (!optimized) {
|
8394 | patchChildren(
|
8395 | n1,
|
8396 | n2,
|
8397 | currentContainer,
|
8398 | currentAnchor,
|
8399 | parentComponent,
|
8400 | parentSuspense,
|
8401 | namespace,
|
8402 | slotScopeIds,
|
8403 | false
|
8404 | );
|
8405 | }
|
8406 | if (disabled) {
|
8407 | if (!wasDisabled) {
|
8408 | moveTeleport(
|
8409 | n2,
|
8410 | container,
|
8411 | mainAnchor,
|
8412 | internals,
|
8413 | 1
|
8414 | );
|
8415 | } else {
|
8416 | if (n2.props && n1.props && n2.props.to !== n1.props.to) {
|
8417 | n2.props.to = n1.props.to;
|
8418 | }
|
8419 | }
|
8420 | } else {
|
8421 | if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
|
8422 | const nextTarget = n2.target = resolveTarget(
|
8423 | n2.props,
|
8424 | querySelector
|
8425 | );
|
8426 | if (nextTarget) {
|
8427 | moveTeleport(
|
8428 | n2,
|
8429 | nextTarget,
|
8430 | null,
|
8431 | internals,
|
8432 | 0
|
8433 | );
|
8434 | } else {
|
8435 | warn$1(
|
8436 | "Invalid Teleport target on update:",
|
8437 | target,
|
8438 | `(${typeof target})`
|
8439 | );
|
8440 | }
|
8441 | } else if (wasDisabled) {
|
8442 | moveTeleport(
|
8443 | n2,
|
8444 | target,
|
8445 | targetAnchor,
|
8446 | internals,
|
8447 | 1
|
8448 | );
|
8449 | }
|
8450 | }
|
8451 | }
|
8452 | updateCssVars(n2);
|
8453 | },
|
8454 | remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
|
8455 | const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
|
8456 | if (target) {
|
8457 | hostRemove(targetAnchor);
|
8458 | }
|
8459 | doRemove && hostRemove(anchor);
|
8460 | if (shapeFlag & 16) {
|
8461 | const shouldRemove = doRemove || !isTeleportDisabled(props);
|
8462 | for (let i = 0; i < children.length; i++) {
|
8463 | const child = children[i];
|
8464 | unmount(
|
8465 | child,
|
8466 | parentComponent,
|
8467 | parentSuspense,
|
8468 | shouldRemove,
|
8469 | !!child.dynamicChildren
|
8470 | );
|
8471 | }
|
8472 | }
|
8473 | },
|
8474 | move: moveTeleport,
|
8475 | hydrate: hydrateTeleport
|
8476 | };
|
8477 | function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
|
8478 | if (moveType === 0) {
|
8479 | insert(vnode.targetAnchor, container, parentAnchor);
|
8480 | }
|
8481 | const { el, anchor, shapeFlag, children, props } = vnode;
|
8482 | const isReorder = moveType === 2;
|
8483 | if (isReorder) {
|
8484 | insert(el, container, parentAnchor);
|
8485 | }
|
8486 | if (!isReorder || isTeleportDisabled(props)) {
|
8487 | if (shapeFlag & 16) {
|
8488 | for (let i = 0; i < children.length; i++) {
|
8489 | move(
|
8490 | children[i],
|
8491 | container,
|
8492 | parentAnchor,
|
8493 | 2
|
8494 | );
|
8495 | }
|
8496 | }
|
8497 | }
|
8498 | if (isReorder) {
|
8499 | insert(anchor, container, parentAnchor);
|
8500 | }
|
8501 | }
|
8502 | function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
|
8503 | o: { nextSibling, parentNode, querySelector }
|
8504 | }, hydrateChildren) {
|
8505 | const target = vnode.target = resolveTarget(
|
8506 | vnode.props,
|
8507 | querySelector
|
8508 | );
|
8509 | if (target) {
|
8510 | const targetNode = target._lpa || target.firstChild;
|
8511 | if (vnode.shapeFlag & 16) {
|
8512 | if (isTeleportDisabled(vnode.props)) {
|
8513 | vnode.anchor = hydrateChildren(
|
8514 | nextSibling(node),
|
8515 | vnode,
|
8516 | parentNode(node),
|
8517 | parentComponent,
|
8518 | parentSuspense,
|
8519 | slotScopeIds,
|
8520 | optimized
|
8521 | );
|
8522 | vnode.targetAnchor = targetNode;
|
8523 | } else {
|
8524 | vnode.anchor = nextSibling(node);
|
8525 | let targetAnchor = targetNode;
|
8526 | while (targetAnchor) {
|
8527 | targetAnchor = nextSibling(targetAnchor);
|
8528 | if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
|
8529 | vnode.targetAnchor = targetAnchor;
|
8530 | target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
|
8531 | break;
|
8532 | }
|
8533 | }
|
8534 | hydrateChildren(
|
8535 | targetNode,
|
8536 | vnode,
|
8537 | target,
|
8538 | parentComponent,
|
8539 | parentSuspense,
|
8540 | slotScopeIds,
|
8541 | optimized
|
8542 | );
|
8543 | }
|
8544 | }
|
8545 | updateCssVars(vnode);
|
8546 | }
|
8547 | return vnode.anchor && nextSibling(vnode.anchor);
|
8548 | }
|
8549 | const Teleport = TeleportImpl;
|
8550 | function updateCssVars(vnode) {
|
8551 | const ctx = vnode.ctx;
|
8552 | if (ctx && ctx.ut) {
|
8553 | let node = vnode.children[0].el;
|
8554 | while (node && node !== vnode.targetAnchor) {
|
8555 | if (node.nodeType === 1)
|
8556 | node.setAttribute("data-v-owner", ctx.uid);
|
8557 | node = node.nextSibling;
|
8558 | }
|
8559 | ctx.ut();
|
8560 | }
|
8561 | }
|
8562 |
|
8563 | const Fragment = Symbol.for("v-fgt");
|
8564 | const Text = Symbol.for("v-txt");
|
8565 | const Comment = Symbol.for("v-cmt");
|
8566 | const Static = Symbol.for("v-stc");
|
8567 | const blockStack = [];
|
8568 | let currentBlock = null;
|
8569 | function openBlock(disableTracking = false) {
|
8570 | blockStack.push(currentBlock = disableTracking ? null : []);
|
8571 | }
|
8572 | function closeBlock() {
|
8573 | blockStack.pop();
|
8574 | currentBlock = blockStack[blockStack.length - 1] || null;
|
8575 | }
|
8576 | let isBlockTreeEnabled = 1;
|
8577 | function setBlockTracking(value) {
|
8578 | isBlockTreeEnabled += value;
|
8579 | }
|
8580 | function setupBlock(vnode) {
|
8581 | vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
|
8582 | closeBlock();
|
8583 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
8584 | currentBlock.push(vnode);
|
8585 | }
|
8586 | return vnode;
|
8587 | }
|
8588 | function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
|
8589 | return setupBlock(
|
8590 | createBaseVNode(
|
8591 | type,
|
8592 | props,
|
8593 | children,
|
8594 | patchFlag,
|
8595 | dynamicProps,
|
8596 | shapeFlag,
|
8597 | true
|
8598 | )
|
8599 | );
|
8600 | }
|
8601 | function createBlock(type, props, children, patchFlag, dynamicProps) {
|
8602 | return setupBlock(
|
8603 | createVNode(
|
8604 | type,
|
8605 | props,
|
8606 | children,
|
8607 | patchFlag,
|
8608 | dynamicProps,
|
8609 | true
|
8610 | )
|
8611 | );
|
8612 | }
|
8613 | function isVNode(value) {
|
8614 | return value ? value.__v_isVNode === true : false;
|
8615 | }
|
8616 | function isSameVNodeType(n1, n2) {
|
8617 | if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
|
8618 | n1.shapeFlag &= ~256;
|
8619 | n2.shapeFlag &= ~512;
|
8620 | return false;
|
8621 | }
|
8622 | return n1.type === n2.type && n1.key === n2.key;
|
8623 | }
|
8624 | let vnodeArgsTransformer;
|
8625 | function transformVNodeArgs(transformer) {
|
8626 | vnodeArgsTransformer = transformer;
|
8627 | }
|
8628 | const createVNodeWithArgsTransform = (...args) => {
|
8629 | return _createVNode(
|
8630 | ...vnodeArgsTransformer ? vnodeArgsTransformer(args, currentRenderingInstance) : args
|
8631 | );
|
8632 | };
|
8633 | const normalizeKey = ({ key }) => key != null ? key : null;
|
8634 | const normalizeRef = ({
|
8635 | ref,
|
8636 | ref_key,
|
8637 | ref_for
|
8638 | }) => {
|
8639 | if (typeof ref === "number") {
|
8640 | ref = "" + ref;
|
8641 | }
|
8642 | return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null;
|
8643 | };
|
8644 | function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
|
8645 | const vnode = {
|
8646 | __v_isVNode: true,
|
8647 | __v_skip: true,
|
8648 | type,
|
8649 | props,
|
8650 | key: props && normalizeKey(props),
|
8651 | ref: props && normalizeRef(props),
|
8652 | scopeId: currentScopeId,
|
8653 | slotScopeIds: null,
|
8654 | children,
|
8655 | component: null,
|
8656 | suspense: null,
|
8657 | ssContent: null,
|
8658 | ssFallback: null,
|
8659 | dirs: null,
|
8660 | transition: null,
|
8661 | el: null,
|
8662 | anchor: null,
|
8663 | target: null,
|
8664 | targetAnchor: null,
|
8665 | staticCount: 0,
|
8666 | shapeFlag,
|
8667 | patchFlag,
|
8668 | dynamicProps,
|
8669 | dynamicChildren: null,
|
8670 | appContext: null,
|
8671 | ctx: currentRenderingInstance
|
8672 | };
|
8673 | if (needFullChildrenNormalization) {
|
8674 | normalizeChildren(vnode, children);
|
8675 | if (shapeFlag & 128) {
|
8676 | type.normalize(vnode);
|
8677 | }
|
8678 | } else if (children) {
|
8679 | vnode.shapeFlag |= isString(children) ? 8 : 16;
|
8680 | }
|
8681 | if (vnode.key !== vnode.key) {
|
8682 | warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
8683 | }
|
8684 | if (isBlockTreeEnabled > 0 &&
|
8685 | !isBlockNode &&
|
8686 | currentBlock &&
|
8687 |
|
8688 |
|
8689 |
|
8690 | (vnode.patchFlag > 0 || shapeFlag & 6) &&
|
8691 |
|
8692 | vnode.patchFlag !== 32) {
|
8693 | currentBlock.push(vnode);
|
8694 | }
|
8695 | return vnode;
|
8696 | }
|
8697 | const createVNode = createVNodeWithArgsTransform ;
|
8698 | function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
8699 | if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
8700 | if (!type) {
|
8701 | warn$1(`Invalid vnode type when creating vnode: ${type}.`);
|
8702 | }
|
8703 | type = Comment;
|
8704 | }
|
8705 | if (isVNode(type)) {
|
8706 | const cloned = cloneVNode(
|
8707 | type,
|
8708 | props,
|
8709 | true
|
8710 |
|
8711 | );
|
8712 | if (children) {
|
8713 | normalizeChildren(cloned, children);
|
8714 | }
|
8715 | if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
|
8716 | if (cloned.shapeFlag & 6) {
|
8717 | currentBlock[currentBlock.indexOf(type)] = cloned;
|
8718 | } else {
|
8719 | currentBlock.push(cloned);
|
8720 | }
|
8721 | }
|
8722 | cloned.patchFlag |= -2;
|
8723 | return cloned;
|
8724 | }
|
8725 | if (isClassComponent(type)) {
|
8726 | type = type.__vccOpts;
|
8727 | }
|
8728 | if (props) {
|
8729 | props = guardReactiveProps(props);
|
8730 | let { class: klass, style } = props;
|
8731 | if (klass && !isString(klass)) {
|
8732 | props.class = normalizeClass(klass);
|
8733 | }
|
8734 | if (isObject(style)) {
|
8735 | if (isProxy(style) && !isArray(style)) {
|
8736 | style = extend({}, style);
|
8737 | }
|
8738 | props.style = normalizeStyle(style);
|
8739 | }
|
8740 | }
|
8741 | const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
|
8742 | if (shapeFlag & 4 && isProxy(type)) {
|
8743 | type = toRaw(type);
|
8744 | warn$1(
|
8745 | `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\`.`,
|
8746 | `
|
8747 | Component that was made reactive: `,
|
8748 | type
|
8749 | );
|
8750 | }
|
8751 | return createBaseVNode(
|
8752 | type,
|
8753 | props,
|
8754 | children,
|
8755 | patchFlag,
|
8756 | dynamicProps,
|
8757 | shapeFlag,
|
8758 | isBlockNode,
|
8759 | true
|
8760 | );
|
8761 | }
|
8762 | function guardReactiveProps(props) {
|
8763 | if (!props)
|
8764 | return null;
|
8765 | return isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
|
8766 | }
|
8767 | function cloneVNode(vnode, extraProps, mergeRef = false) {
|
8768 | const { props, ref, patchFlag, children } = vnode;
|
8769 | const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
|
8770 | const cloned = {
|
8771 | __v_isVNode: true,
|
8772 | __v_skip: true,
|
8773 | type: vnode.type,
|
8774 | props: mergedProps,
|
8775 | key: mergedProps && normalizeKey(mergedProps),
|
8776 | ref: extraProps && extraProps.ref ? (
|
8777 |
|
8778 |
|
8779 |
|
8780 | mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
|
8781 | ) : ref,
|
8782 | scopeId: vnode.scopeId,
|
8783 | slotScopeIds: vnode.slotScopeIds,
|
8784 | children: patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
|
8785 | target: vnode.target,
|
8786 | targetAnchor: vnode.targetAnchor,
|
8787 | staticCount: vnode.staticCount,
|
8788 | shapeFlag: vnode.shapeFlag,
|
8789 |
|
8790 |
|
8791 |
|
8792 |
|
8793 | patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
|
8794 | dynamicProps: vnode.dynamicProps,
|
8795 | dynamicChildren: vnode.dynamicChildren,
|
8796 | appContext: vnode.appContext,
|
8797 | dirs: vnode.dirs,
|
8798 | transition: vnode.transition,
|
8799 |
|
8800 |
|
8801 |
|
8802 |
|
8803 | component: vnode.component,
|
8804 | suspense: vnode.suspense,
|
8805 | ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
8806 | ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
8807 | el: vnode.el,
|
8808 | anchor: vnode.anchor,
|
8809 | ctx: vnode.ctx,
|
8810 | ce: vnode.ce
|
8811 | };
|
8812 | return cloned;
|
8813 | }
|
8814 | function deepCloneVNode(vnode) {
|
8815 | const cloned = cloneVNode(vnode);
|
8816 | if (isArray(vnode.children)) {
|
8817 | cloned.children = vnode.children.map(deepCloneVNode);
|
8818 | }
|
8819 | return cloned;
|
8820 | }
|
8821 | function createTextVNode(text = " ", flag = 0) {
|
8822 | return createVNode(Text, null, text, flag);
|
8823 | }
|
8824 | function createStaticVNode(content, numberOfNodes) {
|
8825 | const vnode = createVNode(Static, null, content);
|
8826 | vnode.staticCount = numberOfNodes;
|
8827 | return vnode;
|
8828 | }
|
8829 | function createCommentVNode(text = "", asBlock = false) {
|
8830 | return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
|
8831 | }
|
8832 | function normalizeVNode(child) {
|
8833 | if (child == null || typeof child === "boolean") {
|
8834 | return createVNode(Comment);
|
8835 | } else if (isArray(child)) {
|
8836 | return createVNode(
|
8837 | Fragment,
|
8838 | null,
|
8839 |
|
8840 | child.slice()
|
8841 | );
|
8842 | } else if (typeof child === "object") {
|
8843 | return cloneIfMounted(child);
|
8844 | } else {
|
8845 | return createVNode(Text, null, String(child));
|
8846 | }
|
8847 | }
|
8848 | function cloneIfMounted(child) {
|
8849 | return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
|
8850 | }
|
8851 | function normalizeChildren(vnode, children) {
|
8852 | let type = 0;
|
8853 | const { shapeFlag } = vnode;
|
8854 | if (children == null) {
|
8855 | children = null;
|
8856 | } else if (isArray(children)) {
|
8857 | type = 16;
|
8858 | } else if (typeof children === "object") {
|
8859 | if (shapeFlag & (1 | 64)) {
|
8860 | const slot = children.default;
|
8861 | if (slot) {
|
8862 | slot._c && (slot._d = false);
|
8863 | normalizeChildren(vnode, slot());
|
8864 | slot._c && (slot._d = true);
|
8865 | }
|
8866 | return;
|
8867 | } else {
|
8868 | type = 32;
|
8869 | const slotFlag = children._;
|
8870 | if (!slotFlag && !isInternalObject(children)) {
|
8871 | children._ctx = currentRenderingInstance;
|
8872 | } else if (slotFlag === 3 && currentRenderingInstance) {
|
8873 | if (currentRenderingInstance.slots._ === 1) {
|
8874 | children._ = 1;
|
8875 | } else {
|
8876 | children._ = 2;
|
8877 | vnode.patchFlag |= 1024;
|
8878 | }
|
8879 | }
|
8880 | }
|
8881 | } else if (isFunction(children)) {
|
8882 | children = { default: children, _ctx: currentRenderingInstance };
|
8883 | type = 32;
|
8884 | } else {
|
8885 | children = String(children);
|
8886 | if (shapeFlag & 64) {
|
8887 | type = 16;
|
8888 | children = [createTextVNode(children)];
|
8889 | } else {
|
8890 | type = 8;
|
8891 | }
|
8892 | }
|
8893 | vnode.children = children;
|
8894 | vnode.shapeFlag |= type;
|
8895 | }
|
8896 | function mergeProps(...args) {
|
8897 | const ret = {};
|
8898 | for (let i = 0; i < args.length; i++) {
|
8899 | const toMerge = args[i];
|
8900 | for (const key in toMerge) {
|
8901 | if (key === "class") {
|
8902 | if (ret.class !== toMerge.class) {
|
8903 | ret.class = normalizeClass([ret.class, toMerge.class]);
|
8904 | }
|
8905 | } else if (key === "style") {
|
8906 | ret.style = normalizeStyle([ret.style, toMerge.style]);
|
8907 | } else if (isOn(key)) {
|
8908 | const existing = ret[key];
|
8909 | const incoming = toMerge[key];
|
8910 | if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
|
8911 | ret[key] = existing ? [].concat(existing, incoming) : incoming;
|
8912 | }
|
8913 | } else if (key !== "") {
|
8914 | ret[key] = toMerge[key];
|
8915 | }
|
8916 | }
|
8917 | }
|
8918 | return ret;
|
8919 | }
|
8920 | function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
8921 | callWithAsyncErrorHandling(hook, instance, 7, [
|
8922 | vnode,
|
8923 | prevVNode
|
8924 | ]);
|
8925 | }
|
8926 |
|
8927 | const emptyAppContext = createAppContext();
|
8928 | let uid = 0;
|
8929 | function createComponentInstance(vnode, parent, suspense) {
|
8930 | const type = vnode.type;
|
8931 | const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
8932 | const instance = {
|
8933 | uid: uid++,
|
8934 | vnode,
|
8935 | type,
|
8936 | parent,
|
8937 | appContext,
|
8938 | root: null,
|
8939 |
|
8940 | next: null,
|
8941 | subTree: null,
|
8942 |
|
8943 | effect: null,
|
8944 | update: null,
|
8945 |
|
8946 | scope: new EffectScope(
|
8947 | true
|
8948 |
|
8949 | ),
|
8950 | render: null,
|
8951 | proxy: null,
|
8952 | exposed: null,
|
8953 | exposeProxy: null,
|
8954 | withProxy: null,
|
8955 | provides: parent ? parent.provides : Object.create(appContext.provides),
|
8956 | accessCache: null,
|
8957 | renderCache: [],
|
8958 |
|
8959 | components: null,
|
8960 | directives: null,
|
8961 |
|
8962 | propsOptions: normalizePropsOptions(type, appContext),
|
8963 | emitsOptions: normalizeEmitsOptions(type, appContext),
|
8964 |
|
8965 | emit: null,
|
8966 |
|
8967 | emitted: null,
|
8968 |
|
8969 | propsDefaults: EMPTY_OBJ,
|
8970 |
|
8971 | inheritAttrs: type.inheritAttrs,
|
8972 |
|
8973 | ctx: EMPTY_OBJ,
|
8974 | data: EMPTY_OBJ,
|
8975 | props: EMPTY_OBJ,
|
8976 | attrs: EMPTY_OBJ,
|
8977 | slots: EMPTY_OBJ,
|
8978 | refs: EMPTY_OBJ,
|
8979 | setupState: EMPTY_OBJ,
|
8980 | setupContext: null,
|
8981 | attrsProxy: null,
|
8982 | slotsProxy: null,
|
8983 |
|
8984 | suspense,
|
8985 | suspenseId: suspense ? suspense.pendingId : 0,
|
8986 | asyncDep: null,
|
8987 | asyncResolved: false,
|
8988 |
|
8989 |
|
8990 | isMounted: false,
|
8991 | isUnmounted: false,
|
8992 | isDeactivated: false,
|
8993 | bc: null,
|
8994 | c: null,
|
8995 | bm: null,
|
8996 | m: null,
|
8997 | bu: null,
|
8998 | u: null,
|
8999 | um: null,
|
9000 | bum: null,
|
9001 | da: null,
|
9002 | a: null,
|
9003 | rtg: null,
|
9004 | rtc: null,
|
9005 | ec: null,
|
9006 | sp: null
|
9007 | };
|
9008 | {
|
9009 | instance.ctx = createDevRenderContext(instance);
|
9010 | }
|
9011 | instance.root = parent ? parent.root : instance;
|
9012 | instance.emit = emit.bind(null, instance);
|
9013 | if (vnode.ce) {
|
9014 | vnode.ce(instance);
|
9015 | }
|
9016 | return instance;
|
9017 | }
|
9018 | let currentInstance = null;
|
9019 | const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
9020 | let internalSetCurrentInstance;
|
9021 | let setInSSRSetupState;
|
9022 | {
|
9023 | internalSetCurrentInstance = (i) => {
|
9024 | currentInstance = i;
|
9025 | };
|
9026 | setInSSRSetupState = (v) => {
|
9027 | isInSSRComponentSetup = v;
|
9028 | };
|
9029 | }
|
9030 | const setCurrentInstance = (instance) => {
|
9031 | const prev = currentInstance;
|
9032 | internalSetCurrentInstance(instance);
|
9033 | instance.scope.on();
|
9034 | return () => {
|
9035 | instance.scope.off();
|
9036 | internalSetCurrentInstance(prev);
|
9037 | };
|
9038 | };
|
9039 | const unsetCurrentInstance = () => {
|
9040 | currentInstance && currentInstance.scope.off();
|
9041 | internalSetCurrentInstance(null);
|
9042 | };
|
9043 | const isBuiltInTag = makeMap("slot,component");
|
9044 | function validateComponentName(name, { isNativeTag }) {
|
9045 | if (isBuiltInTag(name) || isNativeTag(name)) {
|
9046 | warn$1(
|
9047 | "Do not use built-in or reserved HTML elements as component id: " + name
|
9048 | );
|
9049 | }
|
9050 | }
|
9051 | function isStatefulComponent(instance) {
|
9052 | return instance.vnode.shapeFlag & 4;
|
9053 | }
|
9054 | let isInSSRComponentSetup = false;
|
9055 | function setupComponent(instance, isSSR = false) {
|
9056 | isSSR && setInSSRSetupState(isSSR);
|
9057 | const { props, children } = instance.vnode;
|
9058 | const isStateful = isStatefulComponent(instance);
|
9059 | initProps(instance, props, isStateful, isSSR);
|
9060 | initSlots(instance, children);
|
9061 | const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
|
9062 | isSSR && setInSSRSetupState(false);
|
9063 | return setupResult;
|
9064 | }
|
9065 | function setupStatefulComponent(instance, isSSR) {
|
9066 | var _a;
|
9067 | const Component = instance.type;
|
9068 | {
|
9069 | if (Component.name) {
|
9070 | validateComponentName(Component.name, instance.appContext.config);
|
9071 | }
|
9072 | if (Component.components) {
|
9073 | const names = Object.keys(Component.components);
|
9074 | for (let i = 0; i < names.length; i++) {
|
9075 | validateComponentName(names[i], instance.appContext.config);
|
9076 | }
|
9077 | }
|
9078 | if (Component.directives) {
|
9079 | const names = Object.keys(Component.directives);
|
9080 | for (let i = 0; i < names.length; i++) {
|
9081 | validateDirectiveName(names[i]);
|
9082 | }
|
9083 | }
|
9084 | if (Component.compilerOptions && isRuntimeOnly()) {
|
9085 | warn$1(
|
9086 | `"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.`
|
9087 | );
|
9088 | }
|
9089 | }
|
9090 | instance.accessCache = Object.create(null);
|
9091 | instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
|
9092 | {
|
9093 | exposePropsOnRenderContext(instance);
|
9094 | }
|
9095 | const { setup } = Component;
|
9096 | if (setup) {
|
9097 | const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
|
9098 | const reset = setCurrentInstance(instance);
|
9099 | pauseTracking();
|
9100 | const setupResult = callWithErrorHandling(
|
9101 | setup,
|
9102 | instance,
|
9103 | 0,
|
9104 | [
|
9105 | shallowReadonly(instance.props) ,
|
9106 | setupContext
|
9107 | ]
|
9108 | );
|
9109 | resetTracking();
|
9110 | reset();
|
9111 | if (isPromise(setupResult)) {
|
9112 | setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
|
9113 | if (isSSR) {
|
9114 | return setupResult.then((resolvedResult) => {
|
9115 | handleSetupResult(instance, resolvedResult, isSSR);
|
9116 | }).catch((e) => {
|
9117 | handleError(e, instance, 0);
|
9118 | });
|
9119 | } else {
|
9120 | instance.asyncDep = setupResult;
|
9121 | if (!instance.suspense) {
|
9122 | const name = (_a = Component.name) != null ? _a : "Anonymous";
|
9123 | warn$1(
|
9124 | `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.`
|
9125 | );
|
9126 | }
|
9127 | }
|
9128 | } else {
|
9129 | handleSetupResult(instance, setupResult, isSSR);
|
9130 | }
|
9131 | } else {
|
9132 | finishComponentSetup(instance, isSSR);
|
9133 | }
|
9134 | }
|
9135 | function handleSetupResult(instance, setupResult, isSSR) {
|
9136 | if (isFunction(setupResult)) {
|
9137 | {
|
9138 | instance.render = setupResult;
|
9139 | }
|
9140 | } else if (isObject(setupResult)) {
|
9141 | if (isVNode(setupResult)) {
|
9142 | warn$1(
|
9143 | `setup() should not return VNodes directly - return a render function instead.`
|
9144 | );
|
9145 | }
|
9146 | {
|
9147 | instance.devtoolsRawSetupState = setupResult;
|
9148 | }
|
9149 | instance.setupState = proxyRefs(setupResult);
|
9150 | {
|
9151 | exposeSetupStateOnRenderContext(instance);
|
9152 | }
|
9153 | } else if (setupResult !== void 0) {
|
9154 | warn$1(
|
9155 | `setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`
|
9156 | );
|
9157 | }
|
9158 | finishComponentSetup(instance, isSSR);
|
9159 | }
|
9160 | let compile$1;
|
9161 | let installWithProxy;
|
9162 | function registerRuntimeCompiler(_compile) {
|
9163 | compile$1 = _compile;
|
9164 | installWithProxy = (i) => {
|
9165 | if (i.render._rc) {
|
9166 | i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
|
9167 | }
|
9168 | };
|
9169 | }
|
9170 | const isRuntimeOnly = () => !compile$1;
|
9171 | function finishComponentSetup(instance, isSSR, skipOptions) {
|
9172 | const Component = instance.type;
|
9173 | if (!instance.render) {
|
9174 | if (!isSSR && compile$1 && !Component.render) {
|
9175 | const template = Component.template || resolveMergedOptions(instance).template;
|
9176 | if (template) {
|
9177 | {
|
9178 | startMeasure(instance, `compile`);
|
9179 | }
|
9180 | const { isCustomElement, compilerOptions } = instance.appContext.config;
|
9181 | const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
9182 | const finalCompilerOptions = extend(
|
9183 | extend(
|
9184 | {
|
9185 | isCustomElement,
|
9186 | delimiters
|
9187 | },
|
9188 | compilerOptions
|
9189 | ),
|
9190 | componentCompilerOptions
|
9191 | );
|
9192 | Component.render = compile$1(template, finalCompilerOptions);
|
9193 | {
|
9194 | endMeasure(instance, `compile`);
|
9195 | }
|
9196 | }
|
9197 | }
|
9198 | instance.render = Component.render || NOOP;
|
9199 | if (installWithProxy) {
|
9200 | installWithProxy(instance);
|
9201 | }
|
9202 | }
|
9203 | {
|
9204 | const reset = setCurrentInstance(instance);
|
9205 | pauseTracking();
|
9206 | try {
|
9207 | applyOptions(instance);
|
9208 | } finally {
|
9209 | resetTracking();
|
9210 | reset();
|
9211 | }
|
9212 | }
|
9213 | if (!Component.render && instance.render === NOOP && !isSSR) {
|
9214 | if (!compile$1 && Component.template) {
|
9215 | warn$1(
|
9216 | `Component provided template option but runtime compilation is not supported in this build of Vue.` + (` Use "vue.global.js" instead.` )
|
9217 | );
|
9218 | } else {
|
9219 | warn$1(`Component is missing template or render function.`);
|
9220 | }
|
9221 | }
|
9222 | }
|
9223 | const attrsProxyHandlers = {
|
9224 | get(target, key) {
|
9225 | markAttrsAccessed();
|
9226 | track(target, "get", "");
|
9227 | return target[key];
|
9228 | },
|
9229 | set() {
|
9230 | warn$1(`setupContext.attrs is readonly.`);
|
9231 | return false;
|
9232 | },
|
9233 | deleteProperty() {
|
9234 | warn$1(`setupContext.attrs is readonly.`);
|
9235 | return false;
|
9236 | }
|
9237 | } ;
|
9238 | function getSlotsProxy(instance) {
|
9239 | return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
|
9240 | get(target, key) {
|
9241 | track(instance, "get", "$slots");
|
9242 | return target[key];
|
9243 | }
|
9244 | }));
|
9245 | }
|
9246 | function createSetupContext(instance) {
|
9247 | const expose = (exposed) => {
|
9248 | {
|
9249 | if (instance.exposed) {
|
9250 | warn$1(`expose() should be called only once per setup().`);
|
9251 | }
|
9252 | if (exposed != null) {
|
9253 | let exposedType = typeof exposed;
|
9254 | if (exposedType === "object") {
|
9255 | if (isArray(exposed)) {
|
9256 | exposedType = "array";
|
9257 | } else if (isRef(exposed)) {
|
9258 | exposedType = "ref";
|
9259 | }
|
9260 | }
|
9261 | if (exposedType !== "object") {
|
9262 | warn$1(
|
9263 | `expose() should be passed a plain object, received ${exposedType}.`
|
9264 | );
|
9265 | }
|
9266 | }
|
9267 | }
|
9268 | instance.exposed = exposed || {};
|
9269 | };
|
9270 | {
|
9271 | let attrsProxy;
|
9272 | return Object.freeze({
|
9273 | get attrs() {
|
9274 | return attrsProxy || (attrsProxy = new Proxy(instance.attrs, attrsProxyHandlers));
|
9275 | },
|
9276 | get slots() {
|
9277 | return getSlotsProxy(instance);
|
9278 | },
|
9279 | get emit() {
|
9280 | return (event, ...args) => instance.emit(event, ...args);
|
9281 | },
|
9282 | expose
|
9283 | });
|
9284 | }
|
9285 | }
|
9286 | function getExposeProxy(instance) {
|
9287 | if (instance.exposed) {
|
9288 | return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
9289 | get(target, key) {
|
9290 | if (key in target) {
|
9291 | return target[key];
|
9292 | } else if (key in publicPropertiesMap) {
|
9293 | return publicPropertiesMap[key](instance);
|
9294 | }
|
9295 | },
|
9296 | has(target, key) {
|
9297 | return key in target || key in publicPropertiesMap;
|
9298 | }
|
9299 | }));
|
9300 | }
|
9301 | }
|
9302 | const classifyRE = /(?:^|[-_])(\w)/g;
|
9303 | const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
9304 | function getComponentName(Component, includeInferred = true) {
|
9305 | return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
9306 | }
|
9307 | function formatComponentName(instance, Component, isRoot = false) {
|
9308 | let name = getComponentName(Component);
|
9309 | if (!name && Component.__file) {
|
9310 | const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
9311 | if (match) {
|
9312 | name = match[1];
|
9313 | }
|
9314 | }
|
9315 | if (!name && instance && instance.parent) {
|
9316 | const inferFromRegistry = (registry) => {
|
9317 | for (const key in registry) {
|
9318 | if (registry[key] === Component) {
|
9319 | return key;
|
9320 | }
|
9321 | }
|
9322 | };
|
9323 | name = inferFromRegistry(
|
9324 | instance.components || instance.parent.type.components
|
9325 | ) || inferFromRegistry(instance.appContext.components);
|
9326 | }
|
9327 | return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
9328 | }
|
9329 | function isClassComponent(value) {
|
9330 | return isFunction(value) && "__vccOpts" in value;
|
9331 | }
|
9332 |
|
9333 | const computed = (getterOrOptions, debugOptions) => {
|
9334 | const c = computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
|
9335 | {
|
9336 | const i = getCurrentInstance();
|
9337 | if (i && i.appContext.config.warnRecursiveComputed) {
|
9338 | c._warnRecursive = true;
|
9339 | }
|
9340 | }
|
9341 | return c;
|
9342 | };
|
9343 |
|
9344 | function useModel(props, name, options = EMPTY_OBJ) {
|
9345 | const i = getCurrentInstance();
|
9346 | if (!i) {
|
9347 | warn$1(`useModel() called without active instance.`);
|
9348 | return ref();
|
9349 | }
|
9350 | if (!i.propsOptions[0][name]) {
|
9351 | warn$1(`useModel() called with prop "${name}" which is not declared.`);
|
9352 | return ref();
|
9353 | }
|
9354 | const camelizedName = camelize(name);
|
9355 | const hyphenatedName = hyphenate(name);
|
9356 | const res = customRef((track, trigger) => {
|
9357 | let localValue;
|
9358 | watchSyncEffect(() => {
|
9359 | const propValue = props[name];
|
9360 | if (hasChanged(localValue, propValue)) {
|
9361 | localValue = propValue;
|
9362 | trigger();
|
9363 | }
|
9364 | });
|
9365 | return {
|
9366 | get() {
|
9367 | track();
|
9368 | return options.get ? options.get(localValue) : localValue;
|
9369 | },
|
9370 | set(value) {
|
9371 | const rawProps = i.vnode.props;
|
9372 | if (!(rawProps &&
|
9373 | (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
|
9374 | localValue = value;
|
9375 | trigger();
|
9376 | }
|
9377 | i.emit(`update:${name}`, options.set ? options.set(value) : value);
|
9378 | }
|
9379 | };
|
9380 | });
|
9381 | const modifierKey = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
|
9382 | res[Symbol.iterator] = () => {
|
9383 | let i2 = 0;
|
9384 | return {
|
9385 | next() {
|
9386 | if (i2 < 2) {
|
9387 | return { value: i2++ ? props[modifierKey] || {} : res, done: false };
|
9388 | } else {
|
9389 | return { done: true };
|
9390 | }
|
9391 | }
|
9392 | };
|
9393 | };
|
9394 | return res;
|
9395 | }
|
9396 |
|
9397 | function h(type, propsOrChildren, children) {
|
9398 | const l = arguments.length;
|
9399 | if (l === 2) {
|
9400 | if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
|
9401 | if (isVNode(propsOrChildren)) {
|
9402 | return createVNode(type, null, [propsOrChildren]);
|
9403 | }
|
9404 | return createVNode(type, propsOrChildren);
|
9405 | } else {
|
9406 | return createVNode(type, null, propsOrChildren);
|
9407 | }
|
9408 | } else {
|
9409 | if (l > 3) {
|
9410 | children = Array.prototype.slice.call(arguments, 2);
|
9411 | } else if (l === 3 && isVNode(children)) {
|
9412 | children = [children];
|
9413 | }
|
9414 | return createVNode(type, propsOrChildren, children);
|
9415 | }
|
9416 | }
|
9417 |
|
9418 | function initCustomFormatter() {
|
9419 | if (typeof window === "undefined") {
|
9420 | return;
|
9421 | }
|
9422 | const vueStyle = { style: "color:#3ba776" };
|
9423 | const numberStyle = { style: "color:#1677ff" };
|
9424 | const stringStyle = { style: "color:#f5222d" };
|
9425 | const keywordStyle = { style: "color:#eb2f96" };
|
9426 | const formatter = {
|
9427 | header(obj) {
|
9428 | if (!isObject(obj)) {
|
9429 | return null;
|
9430 | }
|
9431 | if (obj.__isVue) {
|
9432 | return ["div", vueStyle, `VueInstance`];
|
9433 | } else if (isRef(obj)) {
|
9434 | return [
|
9435 | "div",
|
9436 | {},
|
9437 | ["span", vueStyle, genRefFlag(obj)],
|
9438 | "<",
|
9439 | formatValue(obj.value),
|
9440 | `>`
|
9441 | ];
|
9442 | } else if (isReactive(obj)) {
|
9443 | return [
|
9444 | "div",
|
9445 | {},
|
9446 | ["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
|
9447 | "<",
|
9448 | formatValue(obj),
|
9449 | `>${isReadonly(obj) ? ` (readonly)` : ``}`
|
9450 | ];
|
9451 | } else if (isReadonly(obj)) {
|
9452 | return [
|
9453 | "div",
|
9454 | {},
|
9455 | ["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
|
9456 | "<",
|
9457 | formatValue(obj),
|
9458 | ">"
|
9459 | ];
|
9460 | }
|
9461 | return null;
|
9462 | },
|
9463 | hasBody(obj) {
|
9464 | return obj && obj.__isVue;
|
9465 | },
|
9466 | body(obj) {
|
9467 | if (obj && obj.__isVue) {
|
9468 | return [
|
9469 | "div",
|
9470 | {},
|
9471 | ...formatInstance(obj.$)
|
9472 | ];
|
9473 | }
|
9474 | }
|
9475 | };
|
9476 | function formatInstance(instance) {
|
9477 | const blocks = [];
|
9478 | if (instance.type.props && instance.props) {
|
9479 | blocks.push(createInstanceBlock("props", toRaw(instance.props)));
|
9480 | }
|
9481 | if (instance.setupState !== EMPTY_OBJ) {
|
9482 | blocks.push(createInstanceBlock("setup", instance.setupState));
|
9483 | }
|
9484 | if (instance.data !== EMPTY_OBJ) {
|
9485 | blocks.push(createInstanceBlock("data", toRaw(instance.data)));
|
9486 | }
|
9487 | const computed = extractKeys(instance, "computed");
|
9488 | if (computed) {
|
9489 | blocks.push(createInstanceBlock("computed", computed));
|
9490 | }
|
9491 | const injected = extractKeys(instance, "inject");
|
9492 | if (injected) {
|
9493 | blocks.push(createInstanceBlock("injected", injected));
|
9494 | }
|
9495 | blocks.push([
|
9496 | "div",
|
9497 | {},
|
9498 | [
|
9499 | "span",
|
9500 | {
|
9501 | style: keywordStyle.style + ";opacity:0.66"
|
9502 | },
|
9503 | "$ (internal): "
|
9504 | ],
|
9505 | ["object", { object: instance }]
|
9506 | ]);
|
9507 | return blocks;
|
9508 | }
|
9509 | function createInstanceBlock(type, target) {
|
9510 | target = extend({}, target);
|
9511 | if (!Object.keys(target).length) {
|
9512 | return ["span", {}];
|
9513 | }
|
9514 | return [
|
9515 | "div",
|
9516 | { style: "line-height:1.25em;margin-bottom:0.6em" },
|
9517 | [
|
9518 | "div",
|
9519 | {
|
9520 | style: "color:#476582"
|
9521 | },
|
9522 | type
|
9523 | ],
|
9524 | [
|
9525 | "div",
|
9526 | {
|
9527 | style: "padding-left:1.25em"
|
9528 | },
|
9529 | ...Object.keys(target).map((key) => {
|
9530 | return [
|
9531 | "div",
|
9532 | {},
|
9533 | ["span", keywordStyle, key + ": "],
|
9534 | formatValue(target[key], false)
|
9535 | ];
|
9536 | })
|
9537 | ]
|
9538 | ];
|
9539 | }
|
9540 | function formatValue(v, asRaw = true) {
|
9541 | if (typeof v === "number") {
|
9542 | return ["span", numberStyle, v];
|
9543 | } else if (typeof v === "string") {
|
9544 | return ["span", stringStyle, JSON.stringify(v)];
|
9545 | } else if (typeof v === "boolean") {
|
9546 | return ["span", keywordStyle, v];
|
9547 | } else if (isObject(v)) {
|
9548 | return ["object", { object: asRaw ? toRaw(v) : v }];
|
9549 | } else {
|
9550 | return ["span", stringStyle, String(v)];
|
9551 | }
|
9552 | }
|
9553 | function extractKeys(instance, type) {
|
9554 | const Comp = instance.type;
|
9555 | if (isFunction(Comp)) {
|
9556 | return;
|
9557 | }
|
9558 | const extracted = {};
|
9559 | for (const key in instance.ctx) {
|
9560 | if (isKeyOfType(Comp, key, type)) {
|
9561 | extracted[key] = instance.ctx[key];
|
9562 | }
|
9563 | }
|
9564 | return extracted;
|
9565 | }
|
9566 | function isKeyOfType(Comp, key, type) {
|
9567 | const opts = Comp[type];
|
9568 | if (isArray(opts) && opts.includes(key) || isObject(opts) && key in opts) {
|
9569 | return true;
|
9570 | }
|
9571 | if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
|
9572 | return true;
|
9573 | }
|
9574 | if (Comp.mixins && Comp.mixins.some((m) => isKeyOfType(m, key, type))) {
|
9575 | return true;
|
9576 | }
|
9577 | }
|
9578 | function genRefFlag(v) {
|
9579 | if (isShallow(v)) {
|
9580 | return `ShallowRef`;
|
9581 | }
|
9582 | if (v.effect) {
|
9583 | return `ComputedRef`;
|
9584 | }
|
9585 | return `Ref`;
|
9586 | }
|
9587 | if (window.devtoolsFormatters) {
|
9588 | window.devtoolsFormatters.push(formatter);
|
9589 | } else {
|
9590 | window.devtoolsFormatters = [formatter];
|
9591 | }
|
9592 | }
|
9593 |
|
9594 | function withMemo(memo, render, cache, index) {
|
9595 | const cached = cache[index];
|
9596 | if (cached && isMemoSame(cached, memo)) {
|
9597 | return cached;
|
9598 | }
|
9599 | const ret = render();
|
9600 | ret.memo = memo.slice();
|
9601 | return cache[index] = ret;
|
9602 | }
|
9603 | function isMemoSame(cached, memo) {
|
9604 | const prev = cached.memo;
|
9605 | if (prev.length != memo.length) {
|
9606 | return false;
|
9607 | }
|
9608 | for (let i = 0; i < prev.length; i++) {
|
9609 | if (hasChanged(prev[i], memo[i])) {
|
9610 | return false;
|
9611 | }
|
9612 | }
|
9613 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
9614 | currentBlock.push(cached);
|
9615 | }
|
9616 | return true;
|
9617 | }
|
9618 |
|
9619 | const version = "3.4.25";
|
9620 | const warn = warn$1 ;
|
9621 | const ErrorTypeStrings = ErrorTypeStrings$1 ;
|
9622 | const devtools = devtools$1 ;
|
9623 | const setDevtoolsHook = setDevtoolsHook$1 ;
|
9624 | const ssrUtils = null;
|
9625 | const resolveFilter = null;
|
9626 | const compatUtils = null;
|
9627 | const DeprecationTypes = null;
|
9628 |
|
9629 | const svgNS = "http://www.w3.org/2000/svg";
|
9630 | const mathmlNS = "http://www.w3.org/1998/Math/MathML";
|
9631 | const doc = typeof document !== "undefined" ? document : null;
|
9632 | const templateContainer = doc && doc.createElement("template");
|
9633 | const nodeOps = {
|
9634 | insert: (child, parent, anchor) => {
|
9635 | parent.insertBefore(child, anchor || null);
|
9636 | },
|
9637 | remove: (child) => {
|
9638 | const parent = child.parentNode;
|
9639 | if (parent) {
|
9640 | parent.removeChild(child);
|
9641 | }
|
9642 | },
|
9643 | createElement: (tag, namespace, is, props) => {
|
9644 | const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0);
|
9645 | if (tag === "select" && props && props.multiple != null) {
|
9646 | el.setAttribute("multiple", props.multiple);
|
9647 | }
|
9648 | return el;
|
9649 | },
|
9650 | createText: (text) => doc.createTextNode(text),
|
9651 | createComment: (text) => doc.createComment(text),
|
9652 | setText: (node, text) => {
|
9653 | node.nodeValue = text;
|
9654 | },
|
9655 | setElementText: (el, text) => {
|
9656 | el.textContent = text;
|
9657 | },
|
9658 | parentNode: (node) => node.parentNode,
|
9659 | nextSibling: (node) => node.nextSibling,
|
9660 | querySelector: (selector) => doc.querySelector(selector),
|
9661 | setScopeId(el, id) {
|
9662 | el.setAttribute(id, "");
|
9663 | },
|
9664 |
|
9665 |
|
9666 |
|
9667 |
|
9668 | insertStaticContent(content, parent, anchor, namespace, start, end) {
|
9669 | const before = anchor ? anchor.previousSibling : parent.lastChild;
|
9670 | if (start && (start === end || start.nextSibling)) {
|
9671 | while (true) {
|
9672 | parent.insertBefore(start.cloneNode(true), anchor);
|
9673 | if (start === end || !(start = start.nextSibling))
|
9674 | break;
|
9675 | }
|
9676 | } else {
|
9677 | templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content;
|
9678 | const template = templateContainer.content;
|
9679 | if (namespace === "svg" || namespace === "mathml") {
|
9680 | const wrapper = template.firstChild;
|
9681 | while (wrapper.firstChild) {
|
9682 | template.appendChild(wrapper.firstChild);
|
9683 | }
|
9684 | template.removeChild(wrapper);
|
9685 | }
|
9686 | parent.insertBefore(template, anchor);
|
9687 | }
|
9688 | return [
|
9689 |
|
9690 | before ? before.nextSibling : parent.firstChild,
|
9691 |
|
9692 | anchor ? anchor.previousSibling : parent.lastChild
|
9693 | ];
|
9694 | }
|
9695 | };
|
9696 |
|
9697 | const TRANSITION$1 = "transition";
|
9698 | const ANIMATION = "animation";
|
9699 | const vtcKey = Symbol("_vtc");
|
9700 | const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
|
9701 | Transition.displayName = "Transition";
|
9702 | const DOMTransitionPropsValidators = {
|
9703 | name: String,
|
9704 | type: String,
|
9705 | css: {
|
9706 | type: Boolean,
|
9707 | default: true
|
9708 | },
|
9709 | duration: [String, Number, Object],
|
9710 | enterFromClass: String,
|
9711 | enterActiveClass: String,
|
9712 | enterToClass: String,
|
9713 | appearFromClass: String,
|
9714 | appearActiveClass: String,
|
9715 | appearToClass: String,
|
9716 | leaveFromClass: String,
|
9717 | leaveActiveClass: String,
|
9718 | leaveToClass: String
|
9719 | };
|
9720 | const TransitionPropsValidators = Transition.props = extend(
|
9721 | {},
|
9722 | BaseTransitionPropsValidators,
|
9723 | DOMTransitionPropsValidators
|
9724 | );
|
9725 | const callHook = (hook, args = []) => {
|
9726 | if (isArray(hook)) {
|
9727 | hook.forEach((h2) => h2(...args));
|
9728 | } else if (hook) {
|
9729 | hook(...args);
|
9730 | }
|
9731 | };
|
9732 | const hasExplicitCallback = (hook) => {
|
9733 | return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
|
9734 | };
|
9735 | function resolveTransitionProps(rawProps) {
|
9736 | const baseProps = {};
|
9737 | for (const key in rawProps) {
|
9738 | if (!(key in DOMTransitionPropsValidators)) {
|
9739 | baseProps[key] = rawProps[key];
|
9740 | }
|
9741 | }
|
9742 | if (rawProps.css === false) {
|
9743 | return baseProps;
|
9744 | }
|
9745 | const {
|
9746 | name = "v",
|
9747 | type,
|
9748 | duration,
|
9749 | enterFromClass = `${name}-enter-from`,
|
9750 | enterActiveClass = `${name}-enter-active`,
|
9751 | enterToClass = `${name}-enter-to`,
|
9752 | appearFromClass = enterFromClass,
|
9753 | appearActiveClass = enterActiveClass,
|
9754 | appearToClass = enterToClass,
|
9755 | leaveFromClass = `${name}-leave-from`,
|
9756 | leaveActiveClass = `${name}-leave-active`,
|
9757 | leaveToClass = `${name}-leave-to`
|
9758 | } = rawProps;
|
9759 | const durations = normalizeDuration(duration);
|
9760 | const enterDuration = durations && durations[0];
|
9761 | const leaveDuration = durations && durations[1];
|
9762 | const {
|
9763 | onBeforeEnter,
|
9764 | onEnter,
|
9765 | onEnterCancelled,
|
9766 | onLeave,
|
9767 | onLeaveCancelled,
|
9768 | onBeforeAppear = onBeforeEnter,
|
9769 | onAppear = onEnter,
|
9770 | onAppearCancelled = onEnterCancelled
|
9771 | } = baseProps;
|
9772 | const finishEnter = (el, isAppear, done) => {
|
9773 | removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
9774 | removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
|
9775 | done && done();
|
9776 | };
|
9777 | const finishLeave = (el, done) => {
|
9778 | el._isLeaving = false;
|
9779 | removeTransitionClass(el, leaveFromClass);
|
9780 | removeTransitionClass(el, leaveToClass);
|
9781 | removeTransitionClass(el, leaveActiveClass);
|
9782 | done && done();
|
9783 | };
|
9784 | const makeEnterHook = (isAppear) => {
|
9785 | return (el, done) => {
|
9786 | const hook = isAppear ? onAppear : onEnter;
|
9787 | const resolve = () => finishEnter(el, isAppear, done);
|
9788 | callHook(hook, [el, resolve]);
|
9789 | nextFrame(() => {
|
9790 | removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
|
9791 | addTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
9792 | if (!hasExplicitCallback(hook)) {
|
9793 | whenTransitionEnds(el, type, enterDuration, resolve);
|
9794 | }
|
9795 | });
|
9796 | };
|
9797 | };
|
9798 | return extend(baseProps, {
|
9799 | onBeforeEnter(el) {
|
9800 | callHook(onBeforeEnter, [el]);
|
9801 | addTransitionClass(el, enterFromClass);
|
9802 | addTransitionClass(el, enterActiveClass);
|
9803 | },
|
9804 | onBeforeAppear(el) {
|
9805 | callHook(onBeforeAppear, [el]);
|
9806 | addTransitionClass(el, appearFromClass);
|
9807 | addTransitionClass(el, appearActiveClass);
|
9808 | },
|
9809 | onEnter: makeEnterHook(false),
|
9810 | onAppear: makeEnterHook(true),
|
9811 | onLeave(el, done) {
|
9812 | el._isLeaving = true;
|
9813 | const resolve = () => finishLeave(el, done);
|
9814 | addTransitionClass(el, leaveFromClass);
|
9815 | addTransitionClass(el, leaveActiveClass);
|
9816 | forceReflow();
|
9817 | nextFrame(() => {
|
9818 | if (!el._isLeaving) {
|
9819 | return;
|
9820 | }
|
9821 | removeTransitionClass(el, leaveFromClass);
|
9822 | addTransitionClass(el, leaveToClass);
|
9823 | if (!hasExplicitCallback(onLeave)) {
|
9824 | whenTransitionEnds(el, type, leaveDuration, resolve);
|
9825 | }
|
9826 | });
|
9827 | callHook(onLeave, [el, resolve]);
|
9828 | },
|
9829 | onEnterCancelled(el) {
|
9830 | finishEnter(el, false);
|
9831 | callHook(onEnterCancelled, [el]);
|
9832 | },
|
9833 | onAppearCancelled(el) {
|
9834 | finishEnter(el, true);
|
9835 | callHook(onAppearCancelled, [el]);
|
9836 | },
|
9837 | onLeaveCancelled(el) {
|
9838 | finishLeave(el);
|
9839 | callHook(onLeaveCancelled, [el]);
|
9840 | }
|
9841 | });
|
9842 | }
|
9843 | function normalizeDuration(duration) {
|
9844 | if (duration == null) {
|
9845 | return null;
|
9846 | } else if (isObject(duration)) {
|
9847 | return [NumberOf(duration.enter), NumberOf(duration.leave)];
|
9848 | } else {
|
9849 | const n = NumberOf(duration);
|
9850 | return [n, n];
|
9851 | }
|
9852 | }
|
9853 | function NumberOf(val) {
|
9854 | const res = toNumber(val);
|
9855 | {
|
9856 | assertNumber(res, "<transition> explicit duration");
|
9857 | }
|
9858 | return res;
|
9859 | }
|
9860 | function addTransitionClass(el, cls) {
|
9861 | cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
|
9862 | (el[vtcKey] || (el[vtcKey] = new Set())).add(cls);
|
9863 | }
|
9864 | function removeTransitionClass(el, cls) {
|
9865 | cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
|
9866 | const _vtc = el[vtcKey];
|
9867 | if (_vtc) {
|
9868 | _vtc.delete(cls);
|
9869 | if (!_vtc.size) {
|
9870 | el[vtcKey] = void 0;
|
9871 | }
|
9872 | }
|
9873 | }
|
9874 | function nextFrame(cb) {
|
9875 | requestAnimationFrame(() => {
|
9876 | requestAnimationFrame(cb);
|
9877 | });
|
9878 | }
|
9879 | let endId = 0;
|
9880 | function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
|
9881 | const id = el._endId = ++endId;
|
9882 | const resolveIfNotStale = () => {
|
9883 | if (id === el._endId) {
|
9884 | resolve();
|
9885 | }
|
9886 | };
|
9887 | if (explicitTimeout) {
|
9888 | return setTimeout(resolveIfNotStale, explicitTimeout);
|
9889 | }
|
9890 | const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
|
9891 | if (!type) {
|
9892 | return resolve();
|
9893 | }
|
9894 | const endEvent = type + "end";
|
9895 | let ended = 0;
|
9896 | const end = () => {
|
9897 | el.removeEventListener(endEvent, onEnd);
|
9898 | resolveIfNotStale();
|
9899 | };
|
9900 | const onEnd = (e) => {
|
9901 | if (e.target === el && ++ended >= propCount) {
|
9902 | end();
|
9903 | }
|
9904 | };
|
9905 | setTimeout(() => {
|
9906 | if (ended < propCount) {
|
9907 | end();
|
9908 | }
|
9909 | }, timeout + 1);
|
9910 | el.addEventListener(endEvent, onEnd);
|
9911 | }
|
9912 | function getTransitionInfo(el, expectedType) {
|
9913 | const styles = window.getComputedStyle(el);
|
9914 | const getStyleProperties = (key) => (styles[key] || "").split(", ");
|
9915 | const transitionDelays = getStyleProperties(`${TRANSITION$1}Delay`);
|
9916 | const transitionDurations = getStyleProperties(`${TRANSITION$1}Duration`);
|
9917 | const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
|
9918 | const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
|
9919 | const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
|
9920 | const animationTimeout = getTimeout(animationDelays, animationDurations);
|
9921 | let type = null;
|
9922 | let timeout = 0;
|
9923 | let propCount = 0;
|
9924 | if (expectedType === TRANSITION$1) {
|
9925 | if (transitionTimeout > 0) {
|
9926 | type = TRANSITION$1;
|
9927 | timeout = transitionTimeout;
|
9928 | propCount = transitionDurations.length;
|
9929 | }
|
9930 | } else if (expectedType === ANIMATION) {
|
9931 | if (animationTimeout > 0) {
|
9932 | type = ANIMATION;
|
9933 | timeout = animationTimeout;
|
9934 | propCount = animationDurations.length;
|
9935 | }
|
9936 | } else {
|
9937 | timeout = Math.max(transitionTimeout, animationTimeout);
|
9938 | type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION$1 : ANIMATION : null;
|
9939 | propCount = type ? type === TRANSITION$1 ? transitionDurations.length : animationDurations.length : 0;
|
9940 | }
|
9941 | const hasTransform = type === TRANSITION$1 && /\b(transform|all)(,|$)/.test(
|
9942 | getStyleProperties(`${TRANSITION$1}Property`).toString()
|
9943 | );
|
9944 | return {
|
9945 | type,
|
9946 | timeout,
|
9947 | propCount,
|
9948 | hasTransform
|
9949 | };
|
9950 | }
|
9951 | function getTimeout(delays, durations) {
|
9952 | while (delays.length < durations.length) {
|
9953 | delays = delays.concat(delays);
|
9954 | }
|
9955 | return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
|
9956 | }
|
9957 | function toMs(s) {
|
9958 | if (s === "auto")
|
9959 | return 0;
|
9960 | return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
|
9961 | }
|
9962 | function forceReflow() {
|
9963 | return document.body.offsetHeight;
|
9964 | }
|
9965 |
|
9966 | function patchClass(el, value, isSVG) {
|
9967 | const transitionClasses = el[vtcKey];
|
9968 | if (transitionClasses) {
|
9969 | value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
|
9970 | }
|
9971 | if (value == null) {
|
9972 | el.removeAttribute("class");
|
9973 | } else if (isSVG) {
|
9974 | el.setAttribute("class", value);
|
9975 | } else {
|
9976 | el.className = value;
|
9977 | }
|
9978 | }
|
9979 |
|
9980 | const vShowOriginalDisplay = Symbol("_vod");
|
9981 | const vShowHidden = Symbol("_vsh");
|
9982 | const vShow = {
|
9983 | beforeMount(el, { value }, { transition }) {
|
9984 | el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
|
9985 | if (transition && value) {
|
9986 | transition.beforeEnter(el);
|
9987 | } else {
|
9988 | setDisplay(el, value);
|
9989 | }
|
9990 | },
|
9991 | mounted(el, { value }, { transition }) {
|
9992 | if (transition && value) {
|
9993 | transition.enter(el);
|
9994 | }
|
9995 | },
|
9996 | updated(el, { value, oldValue }, { transition }) {
|
9997 | if (!value === !oldValue)
|
9998 | return;
|
9999 | if (transition) {
|
10000 | if (value) {
|
10001 | transition.beforeEnter(el);
|
10002 | setDisplay(el, true);
|
10003 | transition.enter(el);
|
10004 | } else {
|
10005 | transition.leave(el, () => {
|
10006 | setDisplay(el, false);
|
10007 | });
|
10008 | }
|
10009 | } else {
|
10010 | setDisplay(el, value);
|
10011 | }
|
10012 | },
|
10013 | beforeUnmount(el, { value }) {
|
10014 | setDisplay(el, value);
|
10015 | }
|
10016 | };
|
10017 | {
|
10018 | vShow.name = "show";
|
10019 | }
|
10020 | function setDisplay(el, value) {
|
10021 | el.style.display = value ? el[vShowOriginalDisplay] : "none";
|
10022 | el[vShowHidden] = !value;
|
10023 | }
|
10024 |
|
10025 | const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT" );
|
10026 | function useCssVars(getter) {
|
10027 | const instance = getCurrentInstance();
|
10028 | if (!instance) {
|
10029 | warn(`useCssVars is called without current active component instance.`);
|
10030 | return;
|
10031 | }
|
10032 | const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
|
10033 | Array.from(
|
10034 | document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
|
10035 | ).forEach((node) => setVarsOnNode(node, vars));
|
10036 | };
|
10037 | {
|
10038 | instance.getCssVars = () => getter(instance.proxy);
|
10039 | }
|
10040 | const setVars = () => {
|
10041 | const vars = getter(instance.proxy);
|
10042 | setVarsOnVNode(instance.subTree, vars);
|
10043 | updateTeleports(vars);
|
10044 | };
|
10045 | onMounted(() => {
|
10046 | watchPostEffect(setVars);
|
10047 | const ob = new MutationObserver(setVars);
|
10048 | ob.observe(instance.subTree.el.parentNode, { childList: true });
|
10049 | onUnmounted(() => ob.disconnect());
|
10050 | });
|
10051 | }
|
10052 | function setVarsOnVNode(vnode, vars) {
|
10053 | if (vnode.shapeFlag & 128) {
|
10054 | const suspense = vnode.suspense;
|
10055 | vnode = suspense.activeBranch;
|
10056 | if (suspense.pendingBranch && !suspense.isHydrating) {
|
10057 | suspense.effects.push(() => {
|
10058 | setVarsOnVNode(suspense.activeBranch, vars);
|
10059 | });
|
10060 | }
|
10061 | }
|
10062 | while (vnode.component) {
|
10063 | vnode = vnode.component.subTree;
|
10064 | }
|
10065 | if (vnode.shapeFlag & 1 && vnode.el) {
|
10066 | setVarsOnNode(vnode.el, vars);
|
10067 | } else if (vnode.type === Fragment) {
|
10068 | vnode.children.forEach((c) => setVarsOnVNode(c, vars));
|
10069 | } else if (vnode.type === Static) {
|
10070 | let { el, anchor } = vnode;
|
10071 | while (el) {
|
10072 | setVarsOnNode(el, vars);
|
10073 | if (el === anchor)
|
10074 | break;
|
10075 | el = el.nextSibling;
|
10076 | }
|
10077 | }
|
10078 | }
|
10079 | function setVarsOnNode(el, vars) {
|
10080 | if (el.nodeType === 1) {
|
10081 | const style = el.style;
|
10082 | let cssText = "";
|
10083 | for (const key in vars) {
|
10084 | style.setProperty(`--${key}`, vars[key]);
|
10085 | cssText += `--${key}: ${vars[key]};`;
|
10086 | }
|
10087 | style[CSS_VAR_TEXT] = cssText;
|
10088 | }
|
10089 | }
|
10090 |
|
10091 | const displayRE = /(^|;)\s*display\s*:/;
|
10092 | function patchStyle(el, prev, next) {
|
10093 | const style = el.style;
|
10094 | const isCssString = isString(next);
|
10095 | let hasControlledDisplay = false;
|
10096 | if (next && !isCssString) {
|
10097 | if (prev) {
|
10098 | if (!isString(prev)) {
|
10099 | for (const key in prev) {
|
10100 | if (next[key] == null) {
|
10101 | setStyle(style, key, "");
|
10102 | }
|
10103 | }
|
10104 | } else {
|
10105 | for (const prevStyle of prev.split(";")) {
|
10106 | const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
|
10107 | if (next[key] == null) {
|
10108 | setStyle(style, key, "");
|
10109 | }
|
10110 | }
|
10111 | }
|
10112 | }
|
10113 | for (const key in next) {
|
10114 | if (key === "display") {
|
10115 | hasControlledDisplay = true;
|
10116 | }
|
10117 | setStyle(style, key, next[key]);
|
10118 | }
|
10119 | } else {
|
10120 | if (isCssString) {
|
10121 | if (prev !== next) {
|
10122 | const cssVarText = style[CSS_VAR_TEXT];
|
10123 | if (cssVarText) {
|
10124 | next += ";" + cssVarText;
|
10125 | }
|
10126 | style.cssText = next;
|
10127 | hasControlledDisplay = displayRE.test(next);
|
10128 | }
|
10129 | } else if (prev) {
|
10130 | el.removeAttribute("style");
|
10131 | }
|
10132 | }
|
10133 | if (vShowOriginalDisplay in el) {
|
10134 | el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
|
10135 | if (el[vShowHidden]) {
|
10136 | style.display = "none";
|
10137 | }
|
10138 | }
|
10139 | }
|
10140 | const semicolonRE = /[^\\];\s*$/;
|
10141 | const importantRE = /\s*!important$/;
|
10142 | function setStyle(style, name, val) {
|
10143 | if (isArray(val)) {
|
10144 | val.forEach((v) => setStyle(style, name, v));
|
10145 | } else {
|
10146 | if (val == null)
|
10147 | val = "";
|
10148 | {
|
10149 | if (semicolonRE.test(val)) {
|
10150 | warn(
|
10151 | `Unexpected semicolon at the end of '${name}' style value: '${val}'`
|
10152 | );
|
10153 | }
|
10154 | }
|
10155 | if (name.startsWith("--")) {
|
10156 | style.setProperty(name, val);
|
10157 | } else {
|
10158 | const prefixed = autoPrefix(style, name);
|
10159 | if (importantRE.test(val)) {
|
10160 | style.setProperty(
|
10161 | hyphenate(prefixed),
|
10162 | val.replace(importantRE, ""),
|
10163 | "important"
|
10164 | );
|
10165 | } else {
|
10166 | style[prefixed] = val;
|
10167 | }
|
10168 | }
|
10169 | }
|
10170 | }
|
10171 | const prefixes = ["Webkit", "Moz", "ms"];
|
10172 | const prefixCache = {};
|
10173 | function autoPrefix(style, rawName) {
|
10174 | const cached = prefixCache[rawName];
|
10175 | if (cached) {
|
10176 | return cached;
|
10177 | }
|
10178 | let name = camelize(rawName);
|
10179 | if (name !== "filter" && name in style) {
|
10180 | return prefixCache[rawName] = name;
|
10181 | }
|
10182 | name = capitalize(name);
|
10183 | for (let i = 0; i < prefixes.length; i++) {
|
10184 | const prefixed = prefixes[i] + name;
|
10185 | if (prefixed in style) {
|
10186 | return prefixCache[rawName] = prefixed;
|
10187 | }
|
10188 | }
|
10189 | return rawName;
|
10190 | }
|
10191 |
|
10192 | const xlinkNS = "http://www.w3.org/1999/xlink";
|
10193 | function patchAttr(el, key, value, isSVG, instance) {
|
10194 | if (isSVG && key.startsWith("xlink:")) {
|
10195 | if (value == null) {
|
10196 | el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
10197 | } else {
|
10198 | el.setAttributeNS(xlinkNS, key, value);
|
10199 | }
|
10200 | } else {
|
10201 | const isBoolean = isSpecialBooleanAttr(key);
|
10202 | if (value == null || isBoolean && !includeBooleanAttr(value)) {
|
10203 | el.removeAttribute(key);
|
10204 | } else {
|
10205 | el.setAttribute(key, isBoolean ? "" : value);
|
10206 | }
|
10207 | }
|
10208 | }
|
10209 |
|
10210 | function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
|
10211 | if (key === "innerHTML" || key === "textContent") {
|
10212 | if (prevChildren) {
|
10213 | unmountChildren(prevChildren, parentComponent, parentSuspense);
|
10214 | }
|
10215 | el[key] = value == null ? "" : value;
|
10216 | return;
|
10217 | }
|
10218 | const tag = el.tagName;
|
10219 | if (key === "value" && tag !== "PROGRESS" &&
|
10220 | !tag.includes("-")) {
|
10221 | const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
|
10222 | const newValue = value == null ? "" : value;
|
10223 | if (oldValue !== newValue || !("_value" in el)) {
|
10224 | el.value = newValue;
|
10225 | }
|
10226 | if (value == null) {
|
10227 | el.removeAttribute(key);
|
10228 | }
|
10229 | el._value = value;
|
10230 | return;
|
10231 | }
|
10232 | let needRemove = false;
|
10233 | if (value === "" || value == null) {
|
10234 | const type = typeof el[key];
|
10235 | if (type === "boolean") {
|
10236 | value = includeBooleanAttr(value);
|
10237 | } else if (value == null && type === "string") {
|
10238 | value = "";
|
10239 | needRemove = true;
|
10240 | } else if (type === "number") {
|
10241 | value = 0;
|
10242 | needRemove = true;
|
10243 | }
|
10244 | }
|
10245 | try {
|
10246 | el[key] = value;
|
10247 | } catch (e) {
|
10248 | if (!needRemove) {
|
10249 | warn(
|
10250 | `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
|
10251 | e
|
10252 | );
|
10253 | }
|
10254 | }
|
10255 | needRemove && el.removeAttribute(key);
|
10256 | }
|
10257 |
|
10258 | function addEventListener(el, event, handler, options) {
|
10259 | el.addEventListener(event, handler, options);
|
10260 | }
|
10261 | function removeEventListener(el, event, handler, options) {
|
10262 | el.removeEventListener(event, handler, options);
|
10263 | }
|
10264 | const veiKey = Symbol("_vei");
|
10265 | function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
10266 | const invokers = el[veiKey] || (el[veiKey] = {});
|
10267 | const existingInvoker = invokers[rawName];
|
10268 | if (nextValue && existingInvoker) {
|
10269 | existingInvoker.value = sanitizeEventValue(nextValue, rawName) ;
|
10270 | } else {
|
10271 | const [name, options] = parseName(rawName);
|
10272 | if (nextValue) {
|
10273 | const invoker = invokers[rawName] = createInvoker(
|
10274 | sanitizeEventValue(nextValue, rawName) ,
|
10275 | instance
|
10276 | );
|
10277 | addEventListener(el, name, invoker, options);
|
10278 | } else if (existingInvoker) {
|
10279 | removeEventListener(el, name, existingInvoker, options);
|
10280 | invokers[rawName] = void 0;
|
10281 | }
|
10282 | }
|
10283 | }
|
10284 | const optionsModifierRE = /(?:Once|Passive|Capture)$/;
|
10285 | function parseName(name) {
|
10286 | let options;
|
10287 | if (optionsModifierRE.test(name)) {
|
10288 | options = {};
|
10289 | let m;
|
10290 | while (m = name.match(optionsModifierRE)) {
|
10291 | name = name.slice(0, name.length - m[0].length);
|
10292 | options[m[0].toLowerCase()] = true;
|
10293 | }
|
10294 | }
|
10295 | const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
|
10296 | return [event, options];
|
10297 | }
|
10298 | let cachedNow = 0;
|
10299 | const p = Promise.resolve();
|
10300 | const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
|
10301 | function createInvoker(initialValue, instance) {
|
10302 | const invoker = (e) => {
|
10303 | if (!e._vts) {
|
10304 | e._vts = Date.now();
|
10305 | } else if (e._vts <= invoker.attached) {
|
10306 | return;
|
10307 | }
|
10308 | callWithAsyncErrorHandling(
|
10309 | patchStopImmediatePropagation(e, invoker.value),
|
10310 | instance,
|
10311 | 5,
|
10312 | [e]
|
10313 | );
|
10314 | };
|
10315 | invoker.value = initialValue;
|
10316 | invoker.attached = getNow();
|
10317 | return invoker;
|
10318 | }
|
10319 | function sanitizeEventValue(value, propName) {
|
10320 | if (isFunction(value) || isArray(value)) {
|
10321 | return value;
|
10322 | }
|
10323 | warn(
|
10324 | `Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?
|
10325 | Expected function or array of functions, received type ${typeof value}.`
|
10326 | );
|
10327 | return NOOP;
|
10328 | }
|
10329 | function patchStopImmediatePropagation(e, value) {
|
10330 | if (isArray(value)) {
|
10331 | const originalStop = e.stopImmediatePropagation;
|
10332 | e.stopImmediatePropagation = () => {
|
10333 | originalStop.call(e);
|
10334 | e._stopped = true;
|
10335 | };
|
10336 | return value.map(
|
10337 | (fn) => (e2) => !e2._stopped && fn && fn(e2)
|
10338 | );
|
10339 | } else {
|
10340 | return value;
|
10341 | }
|
10342 | }
|
10343 |
|
10344 | const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 &&
|
10345 | key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
|
10346 | const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
|
10347 | const isSVG = namespace === "svg";
|
10348 | if (key === "class") {
|
10349 | patchClass(el, nextValue, isSVG);
|
10350 | } else if (key === "style") {
|
10351 | patchStyle(el, prevValue, nextValue);
|
10352 | } else if (isOn(key)) {
|
10353 | if (!isModelListener(key)) {
|
10354 | patchEvent(el, key, prevValue, nextValue, parentComponent);
|
10355 | }
|
10356 | } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
|
10357 | patchDOMProp(
|
10358 | el,
|
10359 | key,
|
10360 | nextValue,
|
10361 | prevChildren,
|
10362 | parentComponent,
|
10363 | parentSuspense,
|
10364 | unmountChildren
|
10365 | );
|
10366 | } else {
|
10367 | if (key === "true-value") {
|
10368 | el._trueValue = nextValue;
|
10369 | } else if (key === "false-value") {
|
10370 | el._falseValue = nextValue;
|
10371 | }
|
10372 | patchAttr(el, key, nextValue, isSVG);
|
10373 | }
|
10374 | };
|
10375 | function shouldSetAsProp(el, key, value, isSVG) {
|
10376 | if (isSVG) {
|
10377 | if (key === "innerHTML" || key === "textContent") {
|
10378 | return true;
|
10379 | }
|
10380 | if (key in el && isNativeOn(key) && isFunction(value)) {
|
10381 | return true;
|
10382 | }
|
10383 | return false;
|
10384 | }
|
10385 | if (key === "spellcheck" || key === "draggable" || key === "translate") {
|
10386 | return false;
|
10387 | }
|
10388 | if (key === "form") {
|
10389 | return false;
|
10390 | }
|
10391 | if (key === "list" && el.tagName === "INPUT") {
|
10392 | return false;
|
10393 | }
|
10394 | if (key === "type" && el.tagName === "TEXTAREA") {
|
10395 | return false;
|
10396 | }
|
10397 | if (key === "width" || key === "height") {
|
10398 | const tag = el.tagName;
|
10399 | if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
|
10400 | return false;
|
10401 | }
|
10402 | }
|
10403 | if (isNativeOn(key) && isString(value)) {
|
10404 | return false;
|
10405 | }
|
10406 | return key in el;
|
10407 | }
|
10408 |
|
10409 |
|
10410 |
|
10411 | function defineCustomElement(options, hydrate2) {
|
10412 | const Comp = defineComponent(options);
|
10413 | class VueCustomElement extends VueElement {
|
10414 | constructor(initialProps) {
|
10415 | super(Comp, initialProps, hydrate2);
|
10416 | }
|
10417 | }
|
10418 | VueCustomElement.def = Comp;
|
10419 | return VueCustomElement;
|
10420 | }
|
10421 |
|
10422 | const defineSSRCustomElement = (options) => {
|
10423 | return defineCustomElement(options, hydrate);
|
10424 | };
|
10425 | const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
|
10426 | };
|
10427 | class VueElement extends BaseClass {
|
10428 | constructor(_def, _props = {}, hydrate2) {
|
10429 | super();
|
10430 | this._def = _def;
|
10431 | this._props = _props;
|
10432 | |
10433 |
|
10434 |
|
10435 | this._instance = null;
|
10436 | this._connected = false;
|
10437 | this._resolved = false;
|
10438 | this._numberProps = null;
|
10439 | this._ob = null;
|
10440 | if (this.shadowRoot && hydrate2) {
|
10441 | hydrate2(this._createVNode(), this.shadowRoot);
|
10442 | } else {
|
10443 | if (this.shadowRoot) {
|
10444 | warn(
|
10445 | `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
|
10446 | );
|
10447 | }
|
10448 | this.attachShadow({ mode: "open" });
|
10449 | if (!this._def.__asyncLoader) {
|
10450 | this._resolveProps(this._def);
|
10451 | }
|
10452 | }
|
10453 | }
|
10454 | connectedCallback() {
|
10455 | this._connected = true;
|
10456 | if (!this._instance) {
|
10457 | if (this._resolved) {
|
10458 | this._update();
|
10459 | } else {
|
10460 | this._resolveDef();
|
10461 | }
|
10462 | }
|
10463 | }
|
10464 | disconnectedCallback() {
|
10465 | this._connected = false;
|
10466 | if (this._ob) {
|
10467 | this._ob.disconnect();
|
10468 | this._ob = null;
|
10469 | }
|
10470 | nextTick(() => {
|
10471 | if (!this._connected) {
|
10472 | render(null, this.shadowRoot);
|
10473 | this._instance = null;
|
10474 | }
|
10475 | });
|
10476 | }
|
10477 | |
10478 |
|
10479 |
|
10480 | _resolveDef() {
|
10481 | this._resolved = true;
|
10482 | for (let i = 0; i < this.attributes.length; i++) {
|
10483 | this._setAttr(this.attributes[i].name);
|
10484 | }
|
10485 | this._ob = new MutationObserver((mutations) => {
|
10486 | for (const m of mutations) {
|
10487 | this._setAttr(m.attributeName);
|
10488 | }
|
10489 | });
|
10490 | this._ob.observe(this, { attributes: true });
|
10491 | const resolve = (def, isAsync = false) => {
|
10492 | const { props, styles } = def;
|
10493 | let numberProps;
|
10494 | if (props && !isArray(props)) {
|
10495 | for (const key in props) {
|
10496 | const opt = props[key];
|
10497 | if (opt === Number || opt && opt.type === Number) {
|
10498 | if (key in this._props) {
|
10499 | this._props[key] = toNumber(this._props[key]);
|
10500 | }
|
10501 | (numberProps || (numberProps = Object.create(null)))[camelize(key)] = true;
|
10502 | }
|
10503 | }
|
10504 | }
|
10505 | this._numberProps = numberProps;
|
10506 | if (isAsync) {
|
10507 | this._resolveProps(def);
|
10508 | }
|
10509 | this._applyStyles(styles);
|
10510 | this._update();
|
10511 | };
|
10512 | const asyncDef = this._def.__asyncLoader;
|
10513 | if (asyncDef) {
|
10514 | asyncDef().then((def) => resolve(def, true));
|
10515 | } else {
|
10516 | resolve(this._def);
|
10517 | }
|
10518 | }
|
10519 | _resolveProps(def) {
|
10520 | const { props } = def;
|
10521 | const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
|
10522 | for (const key of Object.keys(this)) {
|
10523 | if (key[0] !== "_" && declaredPropKeys.includes(key)) {
|
10524 | this._setProp(key, this[key], true, false);
|
10525 | }
|
10526 | }
|
10527 | for (const key of declaredPropKeys.map(camelize)) {
|
10528 | Object.defineProperty(this, key, {
|
10529 | get() {
|
10530 | return this._getProp(key);
|
10531 | },
|
10532 | set(val) {
|
10533 | this._setProp(key, val);
|
10534 | }
|
10535 | });
|
10536 | }
|
10537 | }
|
10538 | _setAttr(key) {
|
10539 | let value = this.hasAttribute(key) ? this.getAttribute(key) : void 0;
|
10540 | const camelKey = camelize(key);
|
10541 | if (this._numberProps && this._numberProps[camelKey]) {
|
10542 | value = toNumber(value);
|
10543 | }
|
10544 | this._setProp(camelKey, value, false);
|
10545 | }
|
10546 | |
10547 |
|
10548 |
|
10549 | _getProp(key) {
|
10550 | return this._props[key];
|
10551 | }
|
10552 | |
10553 |
|
10554 |
|
10555 | _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
|
10556 | if (val !== this._props[key]) {
|
10557 | this._props[key] = val;
|
10558 | if (shouldUpdate && this._instance) {
|
10559 | this._update();
|
10560 | }
|
10561 | if (shouldReflect) {
|
10562 | if (val === true) {
|
10563 | this.setAttribute(hyphenate(key), "");
|
10564 | } else if (typeof val === "string" || typeof val === "number") {
|
10565 | this.setAttribute(hyphenate(key), val + "");
|
10566 | } else if (!val) {
|
10567 | this.removeAttribute(hyphenate(key));
|
10568 | }
|
10569 | }
|
10570 | }
|
10571 | }
|
10572 | _update() {
|
10573 | render(this._createVNode(), this.shadowRoot);
|
10574 | }
|
10575 | _createVNode() {
|
10576 | const vnode = createVNode(this._def, extend({}, this._props));
|
10577 | if (!this._instance) {
|
10578 | vnode.ce = (instance) => {
|
10579 | this._instance = instance;
|
10580 | instance.isCE = true;
|
10581 | {
|
10582 | instance.ceReload = (newStyles) => {
|
10583 | if (this._styles) {
|
10584 | this._styles.forEach((s) => this.shadowRoot.removeChild(s));
|
10585 | this._styles.length = 0;
|
10586 | }
|
10587 | this._applyStyles(newStyles);
|
10588 | this._instance = null;
|
10589 | this._update();
|
10590 | };
|
10591 | }
|
10592 | const dispatch = (event, args) => {
|
10593 | this.dispatchEvent(
|
10594 | new CustomEvent(event, {
|
10595 | detail: args
|
10596 | })
|
10597 | );
|
10598 | };
|
10599 | instance.emit = (event, ...args) => {
|
10600 | dispatch(event, args);
|
10601 | if (hyphenate(event) !== event) {
|
10602 | dispatch(hyphenate(event), args);
|
10603 | }
|
10604 | };
|
10605 | let parent = this;
|
10606 | while (parent = parent && (parent.parentNode || parent.host)) {
|
10607 | if (parent instanceof VueElement) {
|
10608 | instance.parent = parent._instance;
|
10609 | instance.provides = parent._instance.provides;
|
10610 | break;
|
10611 | }
|
10612 | }
|
10613 | };
|
10614 | }
|
10615 | return vnode;
|
10616 | }
|
10617 | _applyStyles(styles) {
|
10618 | if (styles) {
|
10619 | styles.forEach((css) => {
|
10620 | const s = document.createElement("style");
|
10621 | s.textContent = css;
|
10622 | this.shadowRoot.appendChild(s);
|
10623 | {
|
10624 | (this._styles || (this._styles = [])).push(s);
|
10625 | }
|
10626 | });
|
10627 | }
|
10628 | }
|
10629 | }
|
10630 |
|
10631 | function useCssModule(name = "$style") {
|
10632 | {
|
10633 | {
|
10634 | warn(`useCssModule() is not supported in the global build.`);
|
10635 | }
|
10636 | return EMPTY_OBJ;
|
10637 | }
|
10638 | }
|
10639 |
|
10640 | const positionMap = new WeakMap();
|
10641 | const newPositionMap = new WeakMap();
|
10642 | const moveCbKey = Symbol("_moveCb");
|
10643 | const enterCbKey = Symbol("_enterCb");
|
10644 | const TransitionGroupImpl = {
|
10645 | name: "TransitionGroup",
|
10646 | props: extend({}, TransitionPropsValidators, {
|
10647 | tag: String,
|
10648 | moveClass: String
|
10649 | }),
|
10650 | setup(props, { slots }) {
|
10651 | const instance = getCurrentInstance();
|
10652 | const state = useTransitionState();
|
10653 | let prevChildren;
|
10654 | let children;
|
10655 | onUpdated(() => {
|
10656 | if (!prevChildren.length) {
|
10657 | return;
|
10658 | }
|
10659 | const moveClass = props.moveClass || `${props.name || "v"}-move`;
|
10660 | if (!hasCSSTransform(
|
10661 | prevChildren[0].el,
|
10662 | instance.vnode.el,
|
10663 | moveClass
|
10664 | )) {
|
10665 | return;
|
10666 | }
|
10667 | prevChildren.forEach(callPendingCbs);
|
10668 | prevChildren.forEach(recordPosition);
|
10669 | const movedChildren = prevChildren.filter(applyTranslation);
|
10670 | forceReflow();
|
10671 | movedChildren.forEach((c) => {
|
10672 | const el = c.el;
|
10673 | const style = el.style;
|
10674 | addTransitionClass(el, moveClass);
|
10675 | style.transform = style.webkitTransform = style.transitionDuration = "";
|
10676 | const cb = el[moveCbKey] = (e) => {
|
10677 | if (e && e.target !== el) {
|
10678 | return;
|
10679 | }
|
10680 | if (!e || /transform$/.test(e.propertyName)) {
|
10681 | el.removeEventListener("transitionend", cb);
|
10682 | el[moveCbKey] = null;
|
10683 | removeTransitionClass(el, moveClass);
|
10684 | }
|
10685 | };
|
10686 | el.addEventListener("transitionend", cb);
|
10687 | });
|
10688 | });
|
10689 | return () => {
|
10690 | const rawProps = toRaw(props);
|
10691 | const cssTransitionProps = resolveTransitionProps(rawProps);
|
10692 | let tag = rawProps.tag || Fragment;
|
10693 | prevChildren = [];
|
10694 | if (children) {
|
10695 | for (let i = 0; i < children.length; i++) {
|
10696 | const child = children[i];
|
10697 | if (child.el && child.el instanceof Element) {
|
10698 | prevChildren.push(child);
|
10699 | setTransitionHooks(
|
10700 | child,
|
10701 | resolveTransitionHooks(
|
10702 | child,
|
10703 | cssTransitionProps,
|
10704 | state,
|
10705 | instance
|
10706 | )
|
10707 | );
|
10708 | positionMap.set(
|
10709 | child,
|
10710 | child.el.getBoundingClientRect()
|
10711 | );
|
10712 | }
|
10713 | }
|
10714 | }
|
10715 | children = slots.default ? getTransitionRawChildren(slots.default()) : [];
|
10716 | for (let i = 0; i < children.length; i++) {
|
10717 | const child = children[i];
|
10718 | if (child.key != null) {
|
10719 | setTransitionHooks(
|
10720 | child,
|
10721 | resolveTransitionHooks(child, cssTransitionProps, state, instance)
|
10722 | );
|
10723 | } else {
|
10724 | warn(`<TransitionGroup> children must be keyed.`);
|
10725 | }
|
10726 | }
|
10727 | return createVNode(tag, null, children);
|
10728 | };
|
10729 | }
|
10730 | };
|
10731 | const removeMode = (props) => delete props.mode;
|
10732 | removeMode(TransitionGroupImpl.props);
|
10733 | const TransitionGroup = TransitionGroupImpl;
|
10734 | function callPendingCbs(c) {
|
10735 | const el = c.el;
|
10736 | if (el[moveCbKey]) {
|
10737 | el[moveCbKey]();
|
10738 | }
|
10739 | if (el[enterCbKey]) {
|
10740 | el[enterCbKey]();
|
10741 | }
|
10742 | }
|
10743 | function recordPosition(c) {
|
10744 | newPositionMap.set(c, c.el.getBoundingClientRect());
|
10745 | }
|
10746 | function applyTranslation(c) {
|
10747 | const oldPos = positionMap.get(c);
|
10748 | const newPos = newPositionMap.get(c);
|
10749 | const dx = oldPos.left - newPos.left;
|
10750 | const dy = oldPos.top - newPos.top;
|
10751 | if (dx || dy) {
|
10752 | const s = c.el.style;
|
10753 | s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
|
10754 | s.transitionDuration = "0s";
|
10755 | return c;
|
10756 | }
|
10757 | }
|
10758 | function hasCSSTransform(el, root, moveClass) {
|
10759 | const clone = el.cloneNode();
|
10760 | const _vtc = el[vtcKey];
|
10761 | if (_vtc) {
|
10762 | _vtc.forEach((cls) => {
|
10763 | cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
|
10764 | });
|
10765 | }
|
10766 | moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
|
10767 | clone.style.display = "none";
|
10768 | const container = root.nodeType === 1 ? root : root.parentNode;
|
10769 | container.appendChild(clone);
|
10770 | const { hasTransform } = getTransitionInfo(clone);
|
10771 | container.removeChild(clone);
|
10772 | return hasTransform;
|
10773 | }
|
10774 |
|
10775 | const getModelAssigner = (vnode) => {
|
10776 | const fn = vnode.props["onUpdate:modelValue"] || false;
|
10777 | return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
|
10778 | };
|
10779 | function onCompositionStart(e) {
|
10780 | e.target.composing = true;
|
10781 | }
|
10782 | function onCompositionEnd(e) {
|
10783 | const target = e.target;
|
10784 | if (target.composing) {
|
10785 | target.composing = false;
|
10786 | target.dispatchEvent(new Event("input"));
|
10787 | }
|
10788 | }
|
10789 | const assignKey = Symbol("_assign");
|
10790 | const vModelText = {
|
10791 | created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
10792 | el[assignKey] = getModelAssigner(vnode);
|
10793 | const castToNumber = number || vnode.props && vnode.props.type === "number";
|
10794 | addEventListener(el, lazy ? "change" : "input", (e) => {
|
10795 | if (e.target.composing)
|
10796 | return;
|
10797 | let domValue = el.value;
|
10798 | if (trim) {
|
10799 | domValue = domValue.trim();
|
10800 | }
|
10801 | if (castToNumber) {
|
10802 | domValue = looseToNumber(domValue);
|
10803 | }
|
10804 | el[assignKey](domValue);
|
10805 | });
|
10806 | if (trim) {
|
10807 | addEventListener(el, "change", () => {
|
10808 | el.value = el.value.trim();
|
10809 | });
|
10810 | }
|
10811 | if (!lazy) {
|
10812 | addEventListener(el, "compositionstart", onCompositionStart);
|
10813 | addEventListener(el, "compositionend", onCompositionEnd);
|
10814 | addEventListener(el, "change", onCompositionEnd);
|
10815 | }
|
10816 | },
|
10817 |
|
10818 | mounted(el, { value }) {
|
10819 | el.value = value == null ? "" : value;
|
10820 | },
|
10821 | beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
|
10822 | el[assignKey] = getModelAssigner(vnode);
|
10823 | if (el.composing)
|
10824 | return;
|
10825 | const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
|
10826 | const newValue = value == null ? "" : value;
|
10827 | if (elValue === newValue) {
|
10828 | return;
|
10829 | }
|
10830 | if (document.activeElement === el && el.type !== "range") {
|
10831 | if (lazy) {
|
10832 | return;
|
10833 | }
|
10834 | if (trim && el.value.trim() === newValue) {
|
10835 | return;
|
10836 | }
|
10837 | }
|
10838 | el.value = newValue;
|
10839 | }
|
10840 | };
|
10841 | const vModelCheckbox = {
|
10842 |
|
10843 | deep: true,
|
10844 | created(el, _, vnode) {
|
10845 | el[assignKey] = getModelAssigner(vnode);
|
10846 | addEventListener(el, "change", () => {
|
10847 | const modelValue = el._modelValue;
|
10848 | const elementValue = getValue(el);
|
10849 | const checked = el.checked;
|
10850 | const assign = el[assignKey];
|
10851 | if (isArray(modelValue)) {
|
10852 | const index = looseIndexOf(modelValue, elementValue);
|
10853 | const found = index !== -1;
|
10854 | if (checked && !found) {
|
10855 | assign(modelValue.concat(elementValue));
|
10856 | } else if (!checked && found) {
|
10857 | const filtered = [...modelValue];
|
10858 | filtered.splice(index, 1);
|
10859 | assign(filtered);
|
10860 | }
|
10861 | } else if (isSet(modelValue)) {
|
10862 | const cloned = new Set(modelValue);
|
10863 | if (checked) {
|
10864 | cloned.add(elementValue);
|
10865 | } else {
|
10866 | cloned.delete(elementValue);
|
10867 | }
|
10868 | assign(cloned);
|
10869 | } else {
|
10870 | assign(getCheckboxValue(el, checked));
|
10871 | }
|
10872 | });
|
10873 | },
|
10874 |
|
10875 | mounted: setChecked,
|
10876 | beforeUpdate(el, binding, vnode) {
|
10877 | el[assignKey] = getModelAssigner(vnode);
|
10878 | setChecked(el, binding, vnode);
|
10879 | }
|
10880 | };
|
10881 | function setChecked(el, { value, oldValue }, vnode) {
|
10882 | el._modelValue = value;
|
10883 | if (isArray(value)) {
|
10884 | el.checked = looseIndexOf(value, vnode.props.value) > -1;
|
10885 | } else if (isSet(value)) {
|
10886 | el.checked = value.has(vnode.props.value);
|
10887 | } else if (value !== oldValue) {
|
10888 | el.checked = looseEqual(value, getCheckboxValue(el, true));
|
10889 | }
|
10890 | }
|
10891 | const vModelRadio = {
|
10892 | created(el, { value }, vnode) {
|
10893 | el.checked = looseEqual(value, vnode.props.value);
|
10894 | el[assignKey] = getModelAssigner(vnode);
|
10895 | addEventListener(el, "change", () => {
|
10896 | el[assignKey](getValue(el));
|
10897 | });
|
10898 | },
|
10899 | beforeUpdate(el, { value, oldValue }, vnode) {
|
10900 | el[assignKey] = getModelAssigner(vnode);
|
10901 | if (value !== oldValue) {
|
10902 | el.checked = looseEqual(value, vnode.props.value);
|
10903 | }
|
10904 | }
|
10905 | };
|
10906 | const vModelSelect = {
|
10907 |
|
10908 | deep: true,
|
10909 | created(el, { value, modifiers: { number } }, vnode) {
|
10910 | const isSetModel = isSet(value);
|
10911 | addEventListener(el, "change", () => {
|
10912 | const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
10913 | (o) => number ? looseToNumber(getValue(o)) : getValue(o)
|
10914 | );
|
10915 | el[assignKey](
|
10916 | el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
10917 | );
|
10918 | el._assigning = true;
|
10919 | nextTick(() => {
|
10920 | el._assigning = false;
|
10921 | });
|
10922 | });
|
10923 | el[assignKey] = getModelAssigner(vnode);
|
10924 | },
|
10925 |
|
10926 |
|
10927 | mounted(el, { value, modifiers: { number } }) {
|
10928 | setSelected(el, value);
|
10929 | },
|
10930 | beforeUpdate(el, _binding, vnode) {
|
10931 | el[assignKey] = getModelAssigner(vnode);
|
10932 | },
|
10933 | updated(el, { value, modifiers: { number } }) {
|
10934 | if (!el._assigning) {
|
10935 | setSelected(el, value);
|
10936 | }
|
10937 | }
|
10938 | };
|
10939 | function setSelected(el, value, number) {
|
10940 | const isMultiple = el.multiple;
|
10941 | const isArrayValue = isArray(value);
|
10942 | if (isMultiple && !isArrayValue && !isSet(value)) {
|
10943 | warn(
|
10944 | `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
|
10945 | );
|
10946 | return;
|
10947 | }
|
10948 | for (let i = 0, l = el.options.length; i < l; i++) {
|
10949 | const option = el.options[i];
|
10950 | const optionValue = getValue(option);
|
10951 | if (isMultiple) {
|
10952 | if (isArrayValue) {
|
10953 | const optionType = typeof optionValue;
|
10954 | if (optionType === "string" || optionType === "number") {
|
10955 | option.selected = value.some((v) => String(v) === String(optionValue));
|
10956 | } else {
|
10957 | option.selected = looseIndexOf(value, optionValue) > -1;
|
10958 | }
|
10959 | } else {
|
10960 | option.selected = value.has(optionValue);
|
10961 | }
|
10962 | } else if (looseEqual(getValue(option), value)) {
|
10963 | if (el.selectedIndex !== i)
|
10964 | el.selectedIndex = i;
|
10965 | return;
|
10966 | }
|
10967 | }
|
10968 | if (!isMultiple && el.selectedIndex !== -1) {
|
10969 | el.selectedIndex = -1;
|
10970 | }
|
10971 | }
|
10972 | function getValue(el) {
|
10973 | return "_value" in el ? el._value : el.value;
|
10974 | }
|
10975 | function getCheckboxValue(el, checked) {
|
10976 | const key = checked ? "_trueValue" : "_falseValue";
|
10977 | return key in el ? el[key] : checked;
|
10978 | }
|
10979 | const vModelDynamic = {
|
10980 | created(el, binding, vnode) {
|
10981 | callModelHook(el, binding, vnode, null, "created");
|
10982 | },
|
10983 | mounted(el, binding, vnode) {
|
10984 | callModelHook(el, binding, vnode, null, "mounted");
|
10985 | },
|
10986 | beforeUpdate(el, binding, vnode, prevVNode) {
|
10987 | callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
|
10988 | },
|
10989 | updated(el, binding, vnode, prevVNode) {
|
10990 | callModelHook(el, binding, vnode, prevVNode, "updated");
|
10991 | }
|
10992 | };
|
10993 | function resolveDynamicModel(tagName, type) {
|
10994 | switch (tagName) {
|
10995 | case "SELECT":
|
10996 | return vModelSelect;
|
10997 | case "TEXTAREA":
|
10998 | return vModelText;
|
10999 | default:
|
11000 | switch (type) {
|
11001 | case "checkbox":
|
11002 | return vModelCheckbox;
|
11003 | case "radio":
|
11004 | return vModelRadio;
|
11005 | default:
|
11006 | return vModelText;
|
11007 | }
|
11008 | }
|
11009 | }
|
11010 | function callModelHook(el, binding, vnode, prevVNode, hook) {
|
11011 | const modelToUse = resolveDynamicModel(
|
11012 | el.tagName,
|
11013 | vnode.props && vnode.props.type
|
11014 | );
|
11015 | const fn = modelToUse[hook];
|
11016 | fn && fn(el, binding, vnode, prevVNode);
|
11017 | }
|
11018 |
|
11019 | const systemModifiers = ["ctrl", "shift", "alt", "meta"];
|
11020 | const modifierGuards = {
|
11021 | stop: (e) => e.stopPropagation(),
|
11022 | prevent: (e) => e.preventDefault(),
|
11023 | self: (e) => e.target !== e.currentTarget,
|
11024 | ctrl: (e) => !e.ctrlKey,
|
11025 | shift: (e) => !e.shiftKey,
|
11026 | alt: (e) => !e.altKey,
|
11027 | meta: (e) => !e.metaKey,
|
11028 | left: (e) => "button" in e && e.button !== 0,
|
11029 | middle: (e) => "button" in e && e.button !== 1,
|
11030 | right: (e) => "button" in e && e.button !== 2,
|
11031 | exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
|
11032 | };
|
11033 | const withModifiers = (fn, modifiers) => {
|
11034 | const cache = fn._withMods || (fn._withMods = {});
|
11035 | const cacheKey = modifiers.join(".");
|
11036 | return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
|
11037 | for (let i = 0; i < modifiers.length; i++) {
|
11038 | const guard = modifierGuards[modifiers[i]];
|
11039 | if (guard && guard(event, modifiers))
|
11040 | return;
|
11041 | }
|
11042 | return fn(event, ...args);
|
11043 | });
|
11044 | };
|
11045 | const keyNames = {
|
11046 | esc: "escape",
|
11047 | space: " ",
|
11048 | up: "arrow-up",
|
11049 | left: "arrow-left",
|
11050 | right: "arrow-right",
|
11051 | down: "arrow-down",
|
11052 | delete: "backspace"
|
11053 | };
|
11054 | const withKeys = (fn, modifiers) => {
|
11055 | const cache = fn._withKeys || (fn._withKeys = {});
|
11056 | const cacheKey = modifiers.join(".");
|
11057 | return cache[cacheKey] || (cache[cacheKey] = (event) => {
|
11058 | if (!("key" in event)) {
|
11059 | return;
|
11060 | }
|
11061 | const eventKey = hyphenate(event.key);
|
11062 | if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
|
11063 | return fn(event);
|
11064 | }
|
11065 | });
|
11066 | };
|
11067 |
|
11068 | const rendererOptions = extend({ patchProp }, nodeOps);
|
11069 | let renderer;
|
11070 | let enabledHydration = false;
|
11071 | function ensureRenderer() {
|
11072 | return renderer || (renderer = createRenderer(rendererOptions));
|
11073 | }
|
11074 | function ensureHydrationRenderer() {
|
11075 | renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
|
11076 | enabledHydration = true;
|
11077 | return renderer;
|
11078 | }
|
11079 | const render = (...args) => {
|
11080 | ensureRenderer().render(...args);
|
11081 | };
|
11082 | const hydrate = (...args) => {
|
11083 | ensureHydrationRenderer().hydrate(...args);
|
11084 | };
|
11085 | const createApp = (...args) => {
|
11086 | const app = ensureRenderer().createApp(...args);
|
11087 | {
|
11088 | injectNativeTagCheck(app);
|
11089 | injectCompilerOptionsCheck(app);
|
11090 | }
|
11091 | const { mount } = app;
|
11092 | app.mount = (containerOrSelector) => {
|
11093 | const container = normalizeContainer(containerOrSelector);
|
11094 | if (!container)
|
11095 | return;
|
11096 | const component = app._component;
|
11097 | if (!isFunction(component) && !component.render && !component.template) {
|
11098 | component.template = container.innerHTML;
|
11099 | }
|
11100 | container.innerHTML = "";
|
11101 | const proxy = mount(container, false, resolveRootNamespace(container));
|
11102 | if (container instanceof Element) {
|
11103 | container.removeAttribute("v-cloak");
|
11104 | container.setAttribute("data-v-app", "");
|
11105 | }
|
11106 | return proxy;
|
11107 | };
|
11108 | return app;
|
11109 | };
|
11110 | const createSSRApp = (...args) => {
|
11111 | const app = ensureHydrationRenderer().createApp(...args);
|
11112 | {
|
11113 | injectNativeTagCheck(app);
|
11114 | injectCompilerOptionsCheck(app);
|
11115 | }
|
11116 | const { mount } = app;
|
11117 | app.mount = (containerOrSelector) => {
|
11118 | const container = normalizeContainer(containerOrSelector);
|
11119 | if (container) {
|
11120 | return mount(container, true, resolveRootNamespace(container));
|
11121 | }
|
11122 | };
|
11123 | return app;
|
11124 | };
|
11125 | function resolveRootNamespace(container) {
|
11126 | if (container instanceof SVGElement) {
|
11127 | return "svg";
|
11128 | }
|
11129 | if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
|
11130 | return "mathml";
|
11131 | }
|
11132 | }
|
11133 | function injectNativeTagCheck(app) {
|
11134 | Object.defineProperty(app.config, "isNativeTag", {
|
11135 | value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
11136 | writable: false
|
11137 | });
|
11138 | }
|
11139 | function injectCompilerOptionsCheck(app) {
|
11140 | if (isRuntimeOnly()) {
|
11141 | const isCustomElement = app.config.isCustomElement;
|
11142 | Object.defineProperty(app.config, "isCustomElement", {
|
11143 | get() {
|
11144 | return isCustomElement;
|
11145 | },
|
11146 | set() {
|
11147 | warn(
|
11148 | `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
|
11149 | );
|
11150 | }
|
11151 | });
|
11152 | const compilerOptions = app.config.compilerOptions;
|
11153 | 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.
|
11154 | - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
|
11155 | - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
|
11156 | - 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`;
|
11157 | Object.defineProperty(app.config, "compilerOptions", {
|
11158 | get() {
|
11159 | warn(msg);
|
11160 | return compilerOptions;
|
11161 | },
|
11162 | set() {
|
11163 | warn(msg);
|
11164 | }
|
11165 | });
|
11166 | }
|
11167 | }
|
11168 | function normalizeContainer(container) {
|
11169 | if (isString(container)) {
|
11170 | const res = document.querySelector(container);
|
11171 | if (!res) {
|
11172 | warn(
|
11173 | `Failed to mount app: mount target selector "${container}" returned null.`
|
11174 | );
|
11175 | }
|
11176 | return res;
|
11177 | }
|
11178 | if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
|
11179 | warn(
|
11180 | `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
|
11181 | );
|
11182 | }
|
11183 | return container;
|
11184 | }
|
11185 | const initDirectivesForSSR = NOOP;
|
11186 |
|
11187 | function initDev() {
|
11188 | {
|
11189 | {
|
11190 | console.info(
|
11191 | `You are running a development build of Vue.
|
11192 | Make sure to use the production build (*.prod.js) when deploying for production.`
|
11193 | );
|
11194 | }
|
11195 | initCustomFormatter();
|
11196 | }
|
11197 | }
|
11198 |
|
11199 | const FRAGMENT = Symbol(`Fragment` );
|
11200 | const TELEPORT = Symbol(`Teleport` );
|
11201 | const SUSPENSE = Symbol(`Suspense` );
|
11202 | const KEEP_ALIVE = Symbol(`KeepAlive` );
|
11203 | const BASE_TRANSITION = Symbol(`BaseTransition` );
|
11204 | const OPEN_BLOCK = Symbol(`openBlock` );
|
11205 | const CREATE_BLOCK = Symbol(`createBlock` );
|
11206 | const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
|
11207 | const CREATE_VNODE = Symbol(`createVNode` );
|
11208 | const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
|
11209 | const CREATE_COMMENT = Symbol(`createCommentVNode` );
|
11210 | const CREATE_TEXT = Symbol(`createTextVNode` );
|
11211 | const CREATE_STATIC = Symbol(`createStaticVNode` );
|
11212 | const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
|
11213 | const RESOLVE_DYNAMIC_COMPONENT = Symbol(
|
11214 | `resolveDynamicComponent`
|
11215 | );
|
11216 | const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
|
11217 | const RESOLVE_FILTER = Symbol(`resolveFilter` );
|
11218 | const WITH_DIRECTIVES = Symbol(`withDirectives` );
|
11219 | const RENDER_LIST = Symbol(`renderList` );
|
11220 | const RENDER_SLOT = Symbol(`renderSlot` );
|
11221 | const CREATE_SLOTS = Symbol(`createSlots` );
|
11222 | const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
|
11223 | const MERGE_PROPS = Symbol(`mergeProps` );
|
11224 | const NORMALIZE_CLASS = Symbol(`normalizeClass` );
|
11225 | const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
|
11226 | const NORMALIZE_PROPS = Symbol(`normalizeProps` );
|
11227 | const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
|
11228 | const TO_HANDLERS = Symbol(`toHandlers` );
|
11229 | const CAMELIZE = Symbol(`camelize` );
|
11230 | const CAPITALIZE = Symbol(`capitalize` );
|
11231 | const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
|
11232 | const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
|
11233 | const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
|
11234 | const POP_SCOPE_ID = Symbol(`popScopeId` );
|
11235 | const WITH_CTX = Symbol(`withCtx` );
|
11236 | const UNREF = Symbol(`unref` );
|
11237 | const IS_REF = Symbol(`isRef` );
|
11238 | const WITH_MEMO = Symbol(`withMemo` );
|
11239 | const IS_MEMO_SAME = Symbol(`isMemoSame` );
|
11240 | const helperNameMap = {
|
11241 | [FRAGMENT]: `Fragment`,
|
11242 | [TELEPORT]: `Teleport`,
|
11243 | [SUSPENSE]: `Suspense`,
|
11244 | [KEEP_ALIVE]: `KeepAlive`,
|
11245 | [BASE_TRANSITION]: `BaseTransition`,
|
11246 | [OPEN_BLOCK]: `openBlock`,
|
11247 | [CREATE_BLOCK]: `createBlock`,
|
11248 | [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
|
11249 | [CREATE_VNODE]: `createVNode`,
|
11250 | [CREATE_ELEMENT_VNODE]: `createElementVNode`,
|
11251 | [CREATE_COMMENT]: `createCommentVNode`,
|
11252 | [CREATE_TEXT]: `createTextVNode`,
|
11253 | [CREATE_STATIC]: `createStaticVNode`,
|
11254 | [RESOLVE_COMPONENT]: `resolveComponent`,
|
11255 | [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
|
11256 | [RESOLVE_DIRECTIVE]: `resolveDirective`,
|
11257 | [RESOLVE_FILTER]: `resolveFilter`,
|
11258 | [WITH_DIRECTIVES]: `withDirectives`,
|
11259 | [RENDER_LIST]: `renderList`,
|
11260 | [RENDER_SLOT]: `renderSlot`,
|
11261 | [CREATE_SLOTS]: `createSlots`,
|
11262 | [TO_DISPLAY_STRING]: `toDisplayString`,
|
11263 | [MERGE_PROPS]: `mergeProps`,
|
11264 | [NORMALIZE_CLASS]: `normalizeClass`,
|
11265 | [NORMALIZE_STYLE]: `normalizeStyle`,
|
11266 | [NORMALIZE_PROPS]: `normalizeProps`,
|
11267 | [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
|
11268 | [TO_HANDLERS]: `toHandlers`,
|
11269 | [CAMELIZE]: `camelize`,
|
11270 | [CAPITALIZE]: `capitalize`,
|
11271 | [TO_HANDLER_KEY]: `toHandlerKey`,
|
11272 | [SET_BLOCK_TRACKING]: `setBlockTracking`,
|
11273 | [PUSH_SCOPE_ID]: `pushScopeId`,
|
11274 | [POP_SCOPE_ID]: `popScopeId`,
|
11275 | [WITH_CTX]: `withCtx`,
|
11276 | [UNREF]: `unref`,
|
11277 | [IS_REF]: `isRef`,
|
11278 | [WITH_MEMO]: `withMemo`,
|
11279 | [IS_MEMO_SAME]: `isMemoSame`
|
11280 | };
|
11281 | function registerRuntimeHelpers(helpers) {
|
11282 | Object.getOwnPropertySymbols(helpers).forEach((s) => {
|
11283 | helperNameMap[s] = helpers[s];
|
11284 | });
|
11285 | }
|
11286 |
|
11287 | const locStub = {
|
11288 | start: { line: 1, column: 1, offset: 0 },
|
11289 | end: { line: 1, column: 1, offset: 0 },
|
11290 | source: ""
|
11291 | };
|
11292 | function createRoot(children, source = "") {
|
11293 | return {
|
11294 | type: 0,
|
11295 | source,
|
11296 | children,
|
11297 | helpers: new Set(),
|
11298 | components: [],
|
11299 | directives: [],
|
11300 | hoists: [],
|
11301 | imports: [],
|
11302 | cached: 0,
|
11303 | temps: 0,
|
11304 | codegenNode: void 0,
|
11305 | loc: locStub
|
11306 | };
|
11307 | }
|
11308 | function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
|
11309 | if (context) {
|
11310 | if (isBlock) {
|
11311 | context.helper(OPEN_BLOCK);
|
11312 | context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
|
11313 | } else {
|
11314 | context.helper(getVNodeHelper(context.inSSR, isComponent));
|
11315 | }
|
11316 | if (directives) {
|
11317 | context.helper(WITH_DIRECTIVES);
|
11318 | }
|
11319 | }
|
11320 | return {
|
11321 | type: 13,
|
11322 | tag,
|
11323 | props,
|
11324 | children,
|
11325 | patchFlag,
|
11326 | dynamicProps,
|
11327 | directives,
|
11328 | isBlock,
|
11329 | disableTracking,
|
11330 | isComponent,
|
11331 | loc
|
11332 | };
|
11333 | }
|
11334 | function createArrayExpression(elements, loc = locStub) {
|
11335 | return {
|
11336 | type: 17,
|
11337 | loc,
|
11338 | elements
|
11339 | };
|
11340 | }
|
11341 | function createObjectExpression(properties, loc = locStub) {
|
11342 | return {
|
11343 | type: 15,
|
11344 | loc,
|
11345 | properties
|
11346 | };
|
11347 | }
|
11348 | function createObjectProperty(key, value) {
|
11349 | return {
|
11350 | type: 16,
|
11351 | loc: locStub,
|
11352 | key: isString(key) ? createSimpleExpression(key, true) : key,
|
11353 | value
|
11354 | };
|
11355 | }
|
11356 | function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
|
11357 | return {
|
11358 | type: 4,
|
11359 | loc,
|
11360 | content,
|
11361 | isStatic,
|
11362 | constType: isStatic ? 3 : constType
|
11363 | };
|
11364 | }
|
11365 | function createCompoundExpression(children, loc = locStub) {
|
11366 | return {
|
11367 | type: 8,
|
11368 | loc,
|
11369 | children
|
11370 | };
|
11371 | }
|
11372 | function createCallExpression(callee, args = [], loc = locStub) {
|
11373 | return {
|
11374 | type: 14,
|
11375 | loc,
|
11376 | callee,
|
11377 | arguments: args
|
11378 | };
|
11379 | }
|
11380 | function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
|
11381 | return {
|
11382 | type: 18,
|
11383 | params,
|
11384 | returns,
|
11385 | newline,
|
11386 | isSlot,
|
11387 | loc
|
11388 | };
|
11389 | }
|
11390 | function createConditionalExpression(test, consequent, alternate, newline = true) {
|
11391 | return {
|
11392 | type: 19,
|
11393 | test,
|
11394 | consequent,
|
11395 | alternate,
|
11396 | newline,
|
11397 | loc: locStub
|
11398 | };
|
11399 | }
|
11400 | function createCacheExpression(index, value, isVNode = false) {
|
11401 | return {
|
11402 | type: 20,
|
11403 | index,
|
11404 | value,
|
11405 | isVNode,
|
11406 | loc: locStub
|
11407 | };
|
11408 | }
|
11409 | function createBlockStatement(body) {
|
11410 | return {
|
11411 | type: 21,
|
11412 | body,
|
11413 | loc: locStub
|
11414 | };
|
11415 | }
|
11416 | function getVNodeHelper(ssr, isComponent) {
|
11417 | return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
11418 | }
|
11419 | function getVNodeBlockHelper(ssr, isComponent) {
|
11420 | return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
|
11421 | }
|
11422 | function convertToBlock(node, { helper, removeHelper, inSSR }) {
|
11423 | if (!node.isBlock) {
|
11424 | node.isBlock = true;
|
11425 | removeHelper(getVNodeHelper(inSSR, node.isComponent));
|
11426 | helper(OPEN_BLOCK);
|
11427 | helper(getVNodeBlockHelper(inSSR, node.isComponent));
|
11428 | }
|
11429 | }
|
11430 |
|
11431 | const defaultDelimitersOpen = new Uint8Array([123, 123]);
|
11432 | const defaultDelimitersClose = new Uint8Array([125, 125]);
|
11433 | function isTagStartChar(c) {
|
11434 | return c >= 97 && c <= 122 || c >= 65 && c <= 90;
|
11435 | }
|
11436 | function isWhitespace(c) {
|
11437 | return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
|
11438 | }
|
11439 | function isEndOfTagSection(c) {
|
11440 | return c === 47 || c === 62 || isWhitespace(c);
|
11441 | }
|
11442 | function toCharCodes(str) {
|
11443 | const ret = new Uint8Array(str.length);
|
11444 | for (let i = 0; i < str.length; i++) {
|
11445 | ret[i] = str.charCodeAt(i);
|
11446 | }
|
11447 | return ret;
|
11448 | }
|
11449 | const Sequences = {
|
11450 | Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
|
11451 |
|
11452 | CdataEnd: new Uint8Array([93, 93, 62]),
|
11453 |
|
11454 | CommentEnd: new Uint8Array([45, 45, 62]),
|
11455 |
|
11456 | ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
|
11457 |
|
11458 | StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
|
11459 |
|
11460 | TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
|
11461 |
|
11462 | TextareaEnd: new Uint8Array([
|
11463 | 60,
|
11464 | 47,
|
11465 | 116,
|
11466 | 101,
|
11467 | 120,
|
11468 | 116,
|
11469 | 97,
|
11470 | 114,
|
11471 | 101,
|
11472 | 97
|
11473 | ])
|
11474 |
|
11475 | };
|
11476 | class Tokenizer {
|
11477 | constructor(stack, cbs) {
|
11478 | this.stack = stack;
|
11479 | this.cbs = cbs;
|
11480 |
|
11481 | this.state = 1;
|
11482 |
|
11483 | this.buffer = "";
|
11484 |
|
11485 | this.sectionStart = 0;
|
11486 |
|
11487 | this.index = 0;
|
11488 |
|
11489 | this.entityStart = 0;
|
11490 |
|
11491 | this.baseState = 1;
|
11492 |
|
11493 | this.inRCDATA = false;
|
11494 |
|
11495 | this.inXML = false;
|
11496 |
|
11497 | this.inVPre = false;
|
11498 |
|
11499 | this.newlines = [];
|
11500 | this.mode = 0;
|
11501 | this.delimiterOpen = defaultDelimitersOpen;
|
11502 | this.delimiterClose = defaultDelimitersClose;
|
11503 | this.delimiterIndex = -1;
|
11504 | this.currentSequence = void 0;
|
11505 | this.sequenceIndex = 0;
|
11506 | }
|
11507 | get inSFCRoot() {
|
11508 | return this.mode === 2 && this.stack.length === 0;
|
11509 | }
|
11510 | reset() {
|
11511 | this.state = 1;
|
11512 | this.mode = 0;
|
11513 | this.buffer = "";
|
11514 | this.sectionStart = 0;
|
11515 | this.index = 0;
|
11516 | this.baseState = 1;
|
11517 | this.inRCDATA = false;
|
11518 | this.currentSequence = void 0;
|
11519 | this.newlines.length = 0;
|
11520 | this.delimiterOpen = defaultDelimitersOpen;
|
11521 | this.delimiterClose = defaultDelimitersClose;
|
11522 | }
|
11523 | |
11524 |
|
11525 |
|
11526 |
|
11527 |
|
11528 |
|
11529 | getPos(index) {
|
11530 | let line = 1;
|
11531 | let column = index + 1;
|
11532 | for (let i = this.newlines.length - 1; i >= 0; i--) {
|
11533 | const newlineIndex = this.newlines[i];
|
11534 | if (index > newlineIndex) {
|
11535 | line = i + 2;
|
11536 | column = index - newlineIndex;
|
11537 | break;
|
11538 | }
|
11539 | }
|
11540 | return {
|
11541 | column,
|
11542 | line,
|
11543 | offset: index
|
11544 | };
|
11545 | }
|
11546 | peek() {
|
11547 | return this.buffer.charCodeAt(this.index + 1);
|
11548 | }
|
11549 | stateText(c) {
|
11550 | if (c === 60) {
|
11551 | if (this.index > this.sectionStart) {
|
11552 | this.cbs.ontext(this.sectionStart, this.index);
|
11553 | }
|
11554 | this.state = 5;
|
11555 | this.sectionStart = this.index;
|
11556 | } else if (!this.inVPre && c === this.delimiterOpen[0]) {
|
11557 | this.state = 2;
|
11558 | this.delimiterIndex = 0;
|
11559 | this.stateInterpolationOpen(c);
|
11560 | }
|
11561 | }
|
11562 | stateInterpolationOpen(c) {
|
11563 | if (c === this.delimiterOpen[this.delimiterIndex]) {
|
11564 | if (this.delimiterIndex === this.delimiterOpen.length - 1) {
|
11565 | const start = this.index + 1 - this.delimiterOpen.length;
|
11566 | if (start > this.sectionStart) {
|
11567 | this.cbs.ontext(this.sectionStart, start);
|
11568 | }
|
11569 | this.state = 3;
|
11570 | this.sectionStart = start;
|
11571 | } else {
|
11572 | this.delimiterIndex++;
|
11573 | }
|
11574 | } else if (this.inRCDATA) {
|
11575 | this.state = 32;
|
11576 | this.stateInRCDATA(c);
|
11577 | } else {
|
11578 | this.state = 1;
|
11579 | this.stateText(c);
|
11580 | }
|
11581 | }
|
11582 | stateInterpolation(c) {
|
11583 | if (c === this.delimiterClose[0]) {
|
11584 | this.state = 4;
|
11585 | this.delimiterIndex = 0;
|
11586 | this.stateInterpolationClose(c);
|
11587 | }
|
11588 | }
|
11589 | stateInterpolationClose(c) {
|
11590 | if (c === this.delimiterClose[this.delimiterIndex]) {
|
11591 | if (this.delimiterIndex === this.delimiterClose.length - 1) {
|
11592 | this.cbs.oninterpolation(this.sectionStart, this.index + 1);
|
11593 | if (this.inRCDATA) {
|
11594 | this.state = 32;
|
11595 | } else {
|
11596 | this.state = 1;
|
11597 | }
|
11598 | this.sectionStart = this.index + 1;
|
11599 | } else {
|
11600 | this.delimiterIndex++;
|
11601 | }
|
11602 | } else {
|
11603 | this.state = 3;
|
11604 | this.stateInterpolation(c);
|
11605 | }
|
11606 | }
|
11607 | stateSpecialStartSequence(c) {
|
11608 | const isEnd = this.sequenceIndex === this.currentSequence.length;
|
11609 | const isMatch = isEnd ? (
|
11610 |
|
11611 | isEndOfTagSection(c)
|
11612 | ) : (
|
11613 |
|
11614 | (c | 32) === this.currentSequence[this.sequenceIndex]
|
11615 | );
|
11616 | if (!isMatch) {
|
11617 | this.inRCDATA = false;
|
11618 | } else if (!isEnd) {
|
11619 | this.sequenceIndex++;
|
11620 | return;
|
11621 | }
|
11622 | this.sequenceIndex = 0;
|
11623 | this.state = 6;
|
11624 | this.stateInTagName(c);
|
11625 | }
|
11626 |
|
11627 | stateInRCDATA(c) {
|
11628 | if (this.sequenceIndex === this.currentSequence.length) {
|
11629 | if (c === 62 || isWhitespace(c)) {
|
11630 | const endOfText = this.index - this.currentSequence.length;
|
11631 | if (this.sectionStart < endOfText) {
|
11632 | const actualIndex = this.index;
|
11633 | this.index = endOfText;
|
11634 | this.cbs.ontext(this.sectionStart, endOfText);
|
11635 | this.index = actualIndex;
|
11636 | }
|
11637 | this.sectionStart = endOfText + 2;
|
11638 | this.stateInClosingTagName(c);
|
11639 | this.inRCDATA = false;
|
11640 | return;
|
11641 | }
|
11642 | this.sequenceIndex = 0;
|
11643 | }
|
11644 | if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
|
11645 | this.sequenceIndex += 1;
|
11646 | } else if (this.sequenceIndex === 0) {
|
11647 | if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
|
11648 | if (c === this.delimiterOpen[0]) {
|
11649 | this.state = 2;
|
11650 | this.delimiterIndex = 0;
|
11651 | this.stateInterpolationOpen(c);
|
11652 | }
|
11653 | } else if (this.fastForwardTo(60)) {
|
11654 | this.sequenceIndex = 1;
|
11655 | }
|
11656 | } else {
|
11657 | this.sequenceIndex = Number(c === 60);
|
11658 | }
|
11659 | }
|
11660 | stateCDATASequence(c) {
|
11661 | if (c === Sequences.Cdata[this.sequenceIndex]) {
|
11662 | if (++this.sequenceIndex === Sequences.Cdata.length) {
|
11663 | this.state = 28;
|
11664 | this.currentSequence = Sequences.CdataEnd;
|
11665 | this.sequenceIndex = 0;
|
11666 | this.sectionStart = this.index + 1;
|
11667 | }
|
11668 | } else {
|
11669 | this.sequenceIndex = 0;
|
11670 | this.state = 23;
|
11671 | this.stateInDeclaration(c);
|
11672 | }
|
11673 | }
|
11674 | |
11675 |
|
11676 |
|
11677 |
|
11678 |
|
11679 |
|
11680 | fastForwardTo(c) {
|
11681 | while (++this.index < this.buffer.length) {
|
11682 | const cc = this.buffer.charCodeAt(this.index);
|
11683 | if (cc === 10) {
|
11684 | this.newlines.push(this.index);
|
11685 | }
|
11686 | if (cc === c) {
|
11687 | return true;
|
11688 | }
|
11689 | }
|
11690 | this.index = this.buffer.length - 1;
|
11691 | return false;
|
11692 | }
|
11693 | |
11694 |
|
11695 |
|
11696 |
|
11697 |
|
11698 |
|
11699 |
|
11700 |
|
11701 | stateInCommentLike(c) {
|
11702 | if (c === this.currentSequence[this.sequenceIndex]) {
|
11703 | if (++this.sequenceIndex === this.currentSequence.length) {
|
11704 | if (this.currentSequence === Sequences.CdataEnd) {
|
11705 | this.cbs.oncdata(this.sectionStart, this.index - 2);
|
11706 | } else {
|
11707 | this.cbs.oncomment(this.sectionStart, this.index - 2);
|
11708 | }
|
11709 | this.sequenceIndex = 0;
|
11710 | this.sectionStart = this.index + 1;
|
11711 | this.state = 1;
|
11712 | }
|
11713 | } else if (this.sequenceIndex === 0) {
|
11714 | if (this.fastForwardTo(this.currentSequence[0])) {
|
11715 | this.sequenceIndex = 1;
|
11716 | }
|
11717 | } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
|
11718 | this.sequenceIndex = 0;
|
11719 | }
|
11720 | }
|
11721 | startSpecial(sequence, offset) {
|
11722 | this.enterRCDATA(sequence, offset);
|
11723 | this.state = 31;
|
11724 | }
|
11725 | enterRCDATA(sequence, offset) {
|
11726 | this.inRCDATA = true;
|
11727 | this.currentSequence = sequence;
|
11728 | this.sequenceIndex = offset;
|
11729 | }
|
11730 | stateBeforeTagName(c) {
|
11731 | if (c === 33) {
|
11732 | this.state = 22;
|
11733 | this.sectionStart = this.index + 1;
|
11734 | } else if (c === 63) {
|
11735 | this.state = 24;
|
11736 | this.sectionStart = this.index + 1;
|
11737 | } else if (isTagStartChar(c)) {
|
11738 | this.sectionStart = this.index;
|
11739 | if (this.mode === 0) {
|
11740 | this.state = 6;
|
11741 | } else if (this.inSFCRoot) {
|
11742 | this.state = 34;
|
11743 | } else if (!this.inXML) {
|
11744 | if (c === 116) {
|
11745 | this.state = 30;
|
11746 | } else {
|
11747 | this.state = c === 115 ? 29 : 6;
|
11748 | }
|
11749 | } else {
|
11750 | this.state = 6;
|
11751 | }
|
11752 | } else if (c === 47) {
|
11753 | this.state = 8;
|
11754 | } else {
|
11755 | this.state = 1;
|
11756 | this.stateText(c);
|
11757 | }
|
11758 | }
|
11759 | stateInTagName(c) {
|
11760 | if (isEndOfTagSection(c)) {
|
11761 | this.handleTagName(c);
|
11762 | }
|
11763 | }
|
11764 | stateInSFCRootTagName(c) {
|
11765 | if (isEndOfTagSection(c)) {
|
11766 | const tag = this.buffer.slice(this.sectionStart, this.index);
|
11767 | if (tag !== "template") {
|
11768 | this.enterRCDATA(toCharCodes(`</` + tag), 0);
|
11769 | }
|
11770 | this.handleTagName(c);
|
11771 | }
|
11772 | }
|
11773 | handleTagName(c) {
|
11774 | this.cbs.onopentagname(this.sectionStart, this.index);
|
11775 | this.sectionStart = -1;
|
11776 | this.state = 11;
|
11777 | this.stateBeforeAttrName(c);
|
11778 | }
|
11779 | stateBeforeClosingTagName(c) {
|
11780 | if (isWhitespace(c)) ; else if (c === 62) {
|
11781 | {
|
11782 | this.cbs.onerr(14, this.index);
|
11783 | }
|
11784 | this.state = 1;
|
11785 | this.sectionStart = this.index + 1;
|
11786 | } else {
|
11787 | this.state = isTagStartChar(c) ? 9 : 27;
|
11788 | this.sectionStart = this.index;
|
11789 | }
|
11790 | }
|
11791 | stateInClosingTagName(c) {
|
11792 | if (c === 62 || isWhitespace(c)) {
|
11793 | this.cbs.onclosetag(this.sectionStart, this.index);
|
11794 | this.sectionStart = -1;
|
11795 | this.state = 10;
|
11796 | this.stateAfterClosingTagName(c);
|
11797 | }
|
11798 | }
|
11799 | stateAfterClosingTagName(c) {
|
11800 | if (c === 62) {
|
11801 | this.state = 1;
|
11802 | this.sectionStart = this.index + 1;
|
11803 | }
|
11804 | }
|
11805 | stateBeforeAttrName(c) {
|
11806 | if (c === 62) {
|
11807 | this.cbs.onopentagend(this.index);
|
11808 | if (this.inRCDATA) {
|
11809 | this.state = 32;
|
11810 | } else {
|
11811 | this.state = 1;
|
11812 | }
|
11813 | this.sectionStart = this.index + 1;
|
11814 | } else if (c === 47) {
|
11815 | this.state = 7;
|
11816 | if (this.peek() !== 62) {
|
11817 | this.cbs.onerr(22, this.index);
|
11818 | }
|
11819 | } else if (c === 60 && this.peek() === 47) {
|
11820 | this.cbs.onopentagend(this.index);
|
11821 | this.state = 5;
|
11822 | this.sectionStart = this.index;
|
11823 | } else if (!isWhitespace(c)) {
|
11824 | if (c === 61) {
|
11825 | this.cbs.onerr(
|
11826 | 19,
|
11827 | this.index
|
11828 | );
|
11829 | }
|
11830 | this.handleAttrStart(c);
|
11831 | }
|
11832 | }
|
11833 | handleAttrStart(c) {
|
11834 | if (c === 118 && this.peek() === 45) {
|
11835 | this.state = 13;
|
11836 | this.sectionStart = this.index;
|
11837 | } else if (c === 46 || c === 58 || c === 64 || c === 35) {
|
11838 | this.cbs.ondirname(this.index, this.index + 1);
|
11839 | this.state = 14;
|
11840 | this.sectionStart = this.index + 1;
|
11841 | } else {
|
11842 | this.state = 12;
|
11843 | this.sectionStart = this.index;
|
11844 | }
|
11845 | }
|
11846 | stateInSelfClosingTag(c) {
|
11847 | if (c === 62) {
|
11848 | this.cbs.onselfclosingtag(this.index);
|
11849 | this.state = 1;
|
11850 | this.sectionStart = this.index + 1;
|
11851 | this.inRCDATA = false;
|
11852 | } else if (!isWhitespace(c)) {
|
11853 | this.state = 11;
|
11854 | this.stateBeforeAttrName(c);
|
11855 | }
|
11856 | }
|
11857 | stateInAttrName(c) {
|
11858 | if (c === 61 || isEndOfTagSection(c)) {
|
11859 | this.cbs.onattribname(this.sectionStart, this.index);
|
11860 | this.handleAttrNameEnd(c);
|
11861 | } else if (c === 34 || c === 39 || c === 60) {
|
11862 | this.cbs.onerr(
|
11863 | 17,
|
11864 | this.index
|
11865 | );
|
11866 | }
|
11867 | }
|
11868 | stateInDirName(c) {
|
11869 | if (c === 61 || isEndOfTagSection(c)) {
|
11870 | this.cbs.ondirname(this.sectionStart, this.index);
|
11871 | this.handleAttrNameEnd(c);
|
11872 | } else if (c === 58) {
|
11873 | this.cbs.ondirname(this.sectionStart, this.index);
|
11874 | this.state = 14;
|
11875 | this.sectionStart = this.index + 1;
|
11876 | } else if (c === 46) {
|
11877 | this.cbs.ondirname(this.sectionStart, this.index);
|
11878 | this.state = 16;
|
11879 | this.sectionStart = this.index + 1;
|
11880 | }
|
11881 | }
|
11882 | stateInDirArg(c) {
|
11883 | if (c === 61 || isEndOfTagSection(c)) {
|
11884 | this.cbs.ondirarg(this.sectionStart, this.index);
|
11885 | this.handleAttrNameEnd(c);
|
11886 | } else if (c === 91) {
|
11887 | this.state = 15;
|
11888 | } else if (c === 46) {
|
11889 | this.cbs.ondirarg(this.sectionStart, this.index);
|
11890 | this.state = 16;
|
11891 | this.sectionStart = this.index + 1;
|
11892 | }
|
11893 | }
|
11894 | stateInDynamicDirArg(c) {
|
11895 | if (c === 93) {
|
11896 | this.state = 14;
|
11897 | } else if (c === 61 || isEndOfTagSection(c)) {
|
11898 | this.cbs.ondirarg(this.sectionStart, this.index + 1);
|
11899 | this.handleAttrNameEnd(c);
|
11900 | {
|
11901 | this.cbs.onerr(
|
11902 | 27,
|
11903 | this.index
|
11904 | );
|
11905 | }
|
11906 | }
|
11907 | }
|
11908 | stateInDirModifier(c) {
|
11909 | if (c === 61 || isEndOfTagSection(c)) {
|
11910 | this.cbs.ondirmodifier(this.sectionStart, this.index);
|
11911 | this.handleAttrNameEnd(c);
|
11912 | } else if (c === 46) {
|
11913 | this.cbs.ondirmodifier(this.sectionStart, this.index);
|
11914 | this.sectionStart = this.index + 1;
|
11915 | }
|
11916 | }
|
11917 | handleAttrNameEnd(c) {
|
11918 | this.sectionStart = this.index;
|
11919 | this.state = 17;
|
11920 | this.cbs.onattribnameend(this.index);
|
11921 | this.stateAfterAttrName(c);
|
11922 | }
|
11923 | stateAfterAttrName(c) {
|
11924 | if (c === 61) {
|
11925 | this.state = 18;
|
11926 | } else if (c === 47 || c === 62) {
|
11927 | this.cbs.onattribend(0, this.sectionStart);
|
11928 | this.sectionStart = -1;
|
11929 | this.state = 11;
|
11930 | this.stateBeforeAttrName(c);
|
11931 | } else if (!isWhitespace(c)) {
|
11932 | this.cbs.onattribend(0, this.sectionStart);
|
11933 | this.handleAttrStart(c);
|
11934 | }
|
11935 | }
|
11936 | stateBeforeAttrValue(c) {
|
11937 | if (c === 34) {
|
11938 | this.state = 19;
|
11939 | this.sectionStart = this.index + 1;
|
11940 | } else if (c === 39) {
|
11941 | this.state = 20;
|
11942 | this.sectionStart = this.index + 1;
|
11943 | } else if (!isWhitespace(c)) {
|
11944 | this.sectionStart = this.index;
|
11945 | this.state = 21;
|
11946 | this.stateInAttrValueNoQuotes(c);
|
11947 | }
|
11948 | }
|
11949 | handleInAttrValue(c, quote) {
|
11950 | if (c === quote || this.fastForwardTo(quote)) {
|
11951 | this.cbs.onattribdata(this.sectionStart, this.index);
|
11952 | this.sectionStart = -1;
|
11953 | this.cbs.onattribend(
|
11954 | quote === 34 ? 3 : 2,
|
11955 | this.index + 1
|
11956 | );
|
11957 | this.state = 11;
|
11958 | }
|
11959 | }
|
11960 | stateInAttrValueDoubleQuotes(c) {
|
11961 | this.handleInAttrValue(c, 34);
|
11962 | }
|
11963 | stateInAttrValueSingleQuotes(c) {
|
11964 | this.handleInAttrValue(c, 39);
|
11965 | }
|
11966 | stateInAttrValueNoQuotes(c) {
|
11967 | if (isWhitespace(c) || c === 62) {
|
11968 | this.cbs.onattribdata(this.sectionStart, this.index);
|
11969 | this.sectionStart = -1;
|
11970 | this.cbs.onattribend(1, this.index);
|
11971 | this.state = 11;
|
11972 | this.stateBeforeAttrName(c);
|
11973 | } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
|
11974 | this.cbs.onerr(
|
11975 | 18,
|
11976 | this.index
|
11977 | );
|
11978 | } else ;
|
11979 | }
|
11980 | stateBeforeDeclaration(c) {
|
11981 | if (c === 91) {
|
11982 | this.state = 26;
|
11983 | this.sequenceIndex = 0;
|
11984 | } else {
|
11985 | this.state = c === 45 ? 25 : 23;
|
11986 | }
|
11987 | }
|
11988 | stateInDeclaration(c) {
|
11989 | if (c === 62 || this.fastForwardTo(62)) {
|
11990 | this.state = 1;
|
11991 | this.sectionStart = this.index + 1;
|
11992 | }
|
11993 | }
|
11994 | stateInProcessingInstruction(c) {
|
11995 | if (c === 62 || this.fastForwardTo(62)) {
|
11996 | this.cbs.onprocessinginstruction(this.sectionStart, this.index);
|
11997 | this.state = 1;
|
11998 | this.sectionStart = this.index + 1;
|
11999 | }
|
12000 | }
|
12001 | stateBeforeComment(c) {
|
12002 | if (c === 45) {
|
12003 | this.state = 28;
|
12004 | this.currentSequence = Sequences.CommentEnd;
|
12005 | this.sequenceIndex = 2;
|
12006 | this.sectionStart = this.index + 1;
|
12007 | } else {
|
12008 | this.state = 23;
|
12009 | }
|
12010 | }
|
12011 | stateInSpecialComment(c) {
|
12012 | if (c === 62 || this.fastForwardTo(62)) {
|
12013 | this.cbs.oncomment(this.sectionStart, this.index);
|
12014 | this.state = 1;
|
12015 | this.sectionStart = this.index + 1;
|
12016 | }
|
12017 | }
|
12018 | stateBeforeSpecialS(c) {
|
12019 | if (c === Sequences.ScriptEnd[3]) {
|
12020 | this.startSpecial(Sequences.ScriptEnd, 4);
|
12021 | } else if (c === Sequences.StyleEnd[3]) {
|
12022 | this.startSpecial(Sequences.StyleEnd, 4);
|
12023 | } else {
|
12024 | this.state = 6;
|
12025 | this.stateInTagName(c);
|
12026 | }
|
12027 | }
|
12028 | stateBeforeSpecialT(c) {
|
12029 | if (c === Sequences.TitleEnd[3]) {
|
12030 | this.startSpecial(Sequences.TitleEnd, 4);
|
12031 | } else if (c === Sequences.TextareaEnd[3]) {
|
12032 | this.startSpecial(Sequences.TextareaEnd, 4);
|
12033 | } else {
|
12034 | this.state = 6;
|
12035 | this.stateInTagName(c);
|
12036 | }
|
12037 | }
|
12038 | startEntity() {
|
12039 | }
|
12040 | stateInEntity() {
|
12041 | }
|
12042 | |
12043 |
|
12044 |
|
12045 |
|
12046 |
|
12047 | parse(input) {
|
12048 | this.buffer = input;
|
12049 | while (this.index < this.buffer.length) {
|
12050 | const c = this.buffer.charCodeAt(this.index);
|
12051 | if (c === 10) {
|
12052 | this.newlines.push(this.index);
|
12053 | }
|
12054 | switch (this.state) {
|
12055 | case 1: {
|
12056 | this.stateText(c);
|
12057 | break;
|
12058 | }
|
12059 | case 2: {
|
12060 | this.stateInterpolationOpen(c);
|
12061 | break;
|
12062 | }
|
12063 | case 3: {
|
12064 | this.stateInterpolation(c);
|
12065 | break;
|
12066 | }
|
12067 | case 4: {
|
12068 | this.stateInterpolationClose(c);
|
12069 | break;
|
12070 | }
|
12071 | case 31: {
|
12072 | this.stateSpecialStartSequence(c);
|
12073 | break;
|
12074 | }
|
12075 | case 32: {
|
12076 | this.stateInRCDATA(c);
|
12077 | break;
|
12078 | }
|
12079 | case 26: {
|
12080 | this.stateCDATASequence(c);
|
12081 | break;
|
12082 | }
|
12083 | case 19: {
|
12084 | this.stateInAttrValueDoubleQuotes(c);
|
12085 | break;
|
12086 | }
|
12087 | case 12: {
|
12088 | this.stateInAttrName(c);
|
12089 | break;
|
12090 | }
|
12091 | case 13: {
|
12092 | this.stateInDirName(c);
|
12093 | break;
|
12094 | }
|
12095 | case 14: {
|
12096 | this.stateInDirArg(c);
|
12097 | break;
|
12098 | }
|
12099 | case 15: {
|
12100 | this.stateInDynamicDirArg(c);
|
12101 | break;
|
12102 | }
|
12103 | case 16: {
|
12104 | this.stateInDirModifier(c);
|
12105 | break;
|
12106 | }
|
12107 | case 28: {
|
12108 | this.stateInCommentLike(c);
|
12109 | break;
|
12110 | }
|
12111 | case 27: {
|
12112 | this.stateInSpecialComment(c);
|
12113 | break;
|
12114 | }
|
12115 | case 11: {
|
12116 | this.stateBeforeAttrName(c);
|
12117 | break;
|
12118 | }
|
12119 | case 6: {
|
12120 | this.stateInTagName(c);
|
12121 | break;
|
12122 | }
|
12123 | case 34: {
|
12124 | this.stateInSFCRootTagName(c);
|
12125 | break;
|
12126 | }
|
12127 | case 9: {
|
12128 | this.stateInClosingTagName(c);
|
12129 | break;
|
12130 | }
|
12131 | case 5: {
|
12132 | this.stateBeforeTagName(c);
|
12133 | break;
|
12134 | }
|
12135 | case 17: {
|
12136 | this.stateAfterAttrName(c);
|
12137 | break;
|
12138 | }
|
12139 | case 20: {
|
12140 | this.stateInAttrValueSingleQuotes(c);
|
12141 | break;
|
12142 | }
|
12143 | case 18: {
|
12144 | this.stateBeforeAttrValue(c);
|
12145 | break;
|
12146 | }
|
12147 | case 8: {
|
12148 | this.stateBeforeClosingTagName(c);
|
12149 | break;
|
12150 | }
|
12151 | case 10: {
|
12152 | this.stateAfterClosingTagName(c);
|
12153 | break;
|
12154 | }
|
12155 | case 29: {
|
12156 | this.stateBeforeSpecialS(c);
|
12157 | break;
|
12158 | }
|
12159 | case 30: {
|
12160 | this.stateBeforeSpecialT(c);
|
12161 | break;
|
12162 | }
|
12163 | case 21: {
|
12164 | this.stateInAttrValueNoQuotes(c);
|
12165 | break;
|
12166 | }
|
12167 | case 7: {
|
12168 | this.stateInSelfClosingTag(c);
|
12169 | break;
|
12170 | }
|
12171 | case 23: {
|
12172 | this.stateInDeclaration(c);
|
12173 | break;
|
12174 | }
|
12175 | case 22: {
|
12176 | this.stateBeforeDeclaration(c);
|
12177 | break;
|
12178 | }
|
12179 | case 25: {
|
12180 | this.stateBeforeComment(c);
|
12181 | break;
|
12182 | }
|
12183 | case 24: {
|
12184 | this.stateInProcessingInstruction(c);
|
12185 | break;
|
12186 | }
|
12187 | case 33: {
|
12188 | this.stateInEntity();
|
12189 | break;
|
12190 | }
|
12191 | }
|
12192 | this.index++;
|
12193 | }
|
12194 | this.cleanup();
|
12195 | this.finish();
|
12196 | }
|
12197 | |
12198 |
|
12199 |
|
12200 | cleanup() {
|
12201 | if (this.sectionStart !== this.index) {
|
12202 | if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
|
12203 | this.cbs.ontext(this.sectionStart, this.index);
|
12204 | this.sectionStart = this.index;
|
12205 | } else if (this.state === 19 || this.state === 20 || this.state === 21) {
|
12206 | this.cbs.onattribdata(this.sectionStart, this.index);
|
12207 | this.sectionStart = this.index;
|
12208 | }
|
12209 | }
|
12210 | }
|
12211 | finish() {
|
12212 | this.handleTrailingData();
|
12213 | this.cbs.onend();
|
12214 | }
|
12215 |
|
12216 | handleTrailingData() {
|
12217 | const endIndex = this.buffer.length;
|
12218 | if (this.sectionStart >= endIndex) {
|
12219 | return;
|
12220 | }
|
12221 | if (this.state === 28) {
|
12222 | if (this.currentSequence === Sequences.CdataEnd) {
|
12223 | this.cbs.oncdata(this.sectionStart, endIndex);
|
12224 | } else {
|
12225 | this.cbs.oncomment(this.sectionStart, endIndex);
|
12226 | }
|
12227 | } 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 {
|
12228 | this.cbs.ontext(this.sectionStart, endIndex);
|
12229 | }
|
12230 | }
|
12231 | emitCodePoint(cp, consumed) {
|
12232 | }
|
12233 | }
|
12234 |
|
12235 | function defaultOnError(error) {
|
12236 | throw error;
|
12237 | }
|
12238 | function defaultOnWarn(msg) {
|
12239 | console.warn(`[Vue warn] ${msg.message}`);
|
12240 | }
|
12241 | function createCompilerError(code, loc, messages, additionalMessage) {
|
12242 | const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
|
12243 | const error = new SyntaxError(String(msg));
|
12244 | error.code = code;
|
12245 | error.loc = loc;
|
12246 | return error;
|
12247 | }
|
12248 | const errorMessages = {
|
12249 |
|
12250 | [0]: "Illegal comment.",
|
12251 | [1]: "CDATA section is allowed only in XML context.",
|
12252 | [2]: "Duplicate attribute.",
|
12253 | [3]: "End tag cannot have attributes.",
|
12254 | [4]: "Illegal '/' in tags.",
|
12255 | [5]: "Unexpected EOF in tag.",
|
12256 | [6]: "Unexpected EOF in CDATA section.",
|
12257 | [7]: "Unexpected EOF in comment.",
|
12258 | [8]: "Unexpected EOF in script.",
|
12259 | [9]: "Unexpected EOF in tag.",
|
12260 | [10]: "Incorrectly closed comment.",
|
12261 | [11]: "Incorrectly opened comment.",
|
12262 | [12]: "Illegal tag name. Use '<' to print '<'.",
|
12263 | [13]: "Attribute value was expected.",
|
12264 | [14]: "End tag name was expected.",
|
12265 | [15]: "Whitespace was expected.",
|
12266 | [16]: "Unexpected '<!--' in comment.",
|
12267 | [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
12268 | [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
12269 | [19]: "Attribute name cannot start with '='.",
|
12270 | [21]: "'<?' is allowed only in XML context.",
|
12271 | [20]: `Unexpected null character.`,
|
12272 | [22]: "Illegal '/' in tags.",
|
12273 |
|
12274 | [23]: "Invalid end tag.",
|
12275 | [24]: "Element is missing end tag.",
|
12276 | [25]: "Interpolation end sign was not found.",
|
12277 | [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
12278 | [26]: "Legal directive name was expected.",
|
12279 |
|
12280 | [28]: `v-if/v-else-if is missing expression.`,
|
12281 | [29]: `v-if/else branches must use unique keys.`,
|
12282 | [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
12283 | [31]: `v-for is missing expression.`,
|
12284 | [32]: `v-for has invalid expression.`,
|
12285 | [33]: `<template v-for> key should be placed on the <template> tag.`,
|
12286 | [34]: `v-bind is missing expression.`,
|
12287 | [52]: `v-bind with same-name shorthand only allows static argument.`,
|
12288 | [35]: `v-on is missing expression.`,
|
12289 | [36]: `Unexpected custom directive on <slot> outlet.`,
|
12290 | [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.`,
|
12291 | [38]: `Duplicate slot names found. `,
|
12292 | [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
12293 | [40]: `v-slot can only be used on components or <template> tags.`,
|
12294 | [41]: `v-model is missing expression.`,
|
12295 | [42]: `v-model value must be a valid JavaScript member expression.`,
|
12296 | [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
12297 | [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
12298 | Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
12299 | [45]: `Error parsing JavaScript expression: `,
|
12300 | [46]: `<KeepAlive> expects exactly one child component.`,
|
12301 | [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.`,
|
12302 |
|
12303 | [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
12304 | [48]: `ES module mode is not supported in this build of compiler.`,
|
12305 | [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
12306 | [50]: `"scopeId" option is only supported in module mode.`,
|
12307 |
|
12308 | [53]: ``
|
12309 | };
|
12310 |
|
12311 | const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
12312 | function isCoreComponent(tag) {
|
12313 | switch (tag) {
|
12314 | case "Teleport":
|
12315 | case "teleport":
|
12316 | return TELEPORT;
|
12317 | case "Suspense":
|
12318 | case "suspense":
|
12319 | return SUSPENSE;
|
12320 | case "KeepAlive":
|
12321 | case "keep-alive":
|
12322 | return KEEP_ALIVE;
|
12323 | case "BaseTransition":
|
12324 | case "base-transition":
|
12325 | return BASE_TRANSITION;
|
12326 | }
|
12327 | }
|
12328 | const nonIdentifierRE = /^\d|[^\$\w]/;
|
12329 | const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
12330 | const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
12331 | const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
12332 | const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
|
12333 | const isMemberExpressionBrowser = (path) => {
|
12334 | path = path.trim().replace(whitespaceRE, (s) => s.trim());
|
12335 | let state = 0 ;
|
12336 | let stateStack = [];
|
12337 | let currentOpenBracketCount = 0;
|
12338 | let currentOpenParensCount = 0;
|
12339 | let currentStringType = null;
|
12340 | for (let i = 0; i < path.length; i++) {
|
12341 | const char = path.charAt(i);
|
12342 | switch (state) {
|
12343 | case 0 :
|
12344 | if (char === "[") {
|
12345 | stateStack.push(state);
|
12346 | state = 1 ;
|
12347 | currentOpenBracketCount++;
|
12348 | } else if (char === "(") {
|
12349 | stateStack.push(state);
|
12350 | state = 2 ;
|
12351 | currentOpenParensCount++;
|
12352 | } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
|
12353 | return false;
|
12354 | }
|
12355 | break;
|
12356 | case 1 :
|
12357 | if (char === `'` || char === `"` || char === "`") {
|
12358 | stateStack.push(state);
|
12359 | state = 3 ;
|
12360 | currentStringType = char;
|
12361 | } else if (char === `[`) {
|
12362 | currentOpenBracketCount++;
|
12363 | } else if (char === `]`) {
|
12364 | if (!--currentOpenBracketCount) {
|
12365 | state = stateStack.pop();
|
12366 | }
|
12367 | }
|
12368 | break;
|
12369 | case 2 :
|
12370 | if (char === `'` || char === `"` || char === "`") {
|
12371 | stateStack.push(state);
|
12372 | state = 3 ;
|
12373 | currentStringType = char;
|
12374 | } else if (char === `(`) {
|
12375 | currentOpenParensCount++;
|
12376 | } else if (char === `)`) {
|
12377 | if (i === path.length - 1) {
|
12378 | return false;
|
12379 | }
|
12380 | if (!--currentOpenParensCount) {
|
12381 | state = stateStack.pop();
|
12382 | }
|
12383 | }
|
12384 | break;
|
12385 | case 3 :
|
12386 | if (char === currentStringType) {
|
12387 | state = stateStack.pop();
|
12388 | currentStringType = null;
|
12389 | }
|
12390 | break;
|
12391 | }
|
12392 | }
|
12393 | return !currentOpenBracketCount && !currentOpenParensCount;
|
12394 | };
|
12395 | const isMemberExpression = isMemberExpressionBrowser ;
|
12396 | function assert(condition, msg) {
|
12397 | if (!condition) {
|
12398 | throw new Error(msg || `unexpected compiler condition`);
|
12399 | }
|
12400 | }
|
12401 | function findDir(node, name, allowEmpty = false) {
|
12402 | for (let i = 0; i < node.props.length; i++) {
|
12403 | const p = node.props[i];
|
12404 | if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
|
12405 | return p;
|
12406 | }
|
12407 | }
|
12408 | }
|
12409 | function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
12410 | for (let i = 0; i < node.props.length; i++) {
|
12411 | const p = node.props[i];
|
12412 | if (p.type === 6) {
|
12413 | if (dynamicOnly)
|
12414 | continue;
|
12415 | if (p.name === name && (p.value || allowEmpty)) {
|
12416 | return p;
|
12417 | }
|
12418 | } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
|
12419 | return p;
|
12420 | }
|
12421 | }
|
12422 | }
|
12423 | function isStaticArgOf(arg, name) {
|
12424 | return !!(arg && isStaticExp(arg) && arg.content === name);
|
12425 | }
|
12426 | function hasDynamicKeyVBind(node) {
|
12427 | return node.props.some(
|
12428 | (p) => p.type === 7 && p.name === "bind" && (!p.arg ||
|
12429 | p.arg.type !== 4 ||
|
12430 | !p.arg.isStatic)
|
12431 |
|
12432 | );
|
12433 | }
|
12434 | function isText$1(node) {
|
12435 | return node.type === 5 || node.type === 2;
|
12436 | }
|
12437 | function isVSlot(p) {
|
12438 | return p.type === 7 && p.name === "slot";
|
12439 | }
|
12440 | function isTemplateNode(node) {
|
12441 | return node.type === 1 && node.tagType === 3;
|
12442 | }
|
12443 | function isSlotOutlet(node) {
|
12444 | return node.type === 1 && node.tagType === 2;
|
12445 | }
|
12446 | const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
12447 | function getUnnormalizedProps(props, callPath = []) {
|
12448 | if (props && !isString(props) && props.type === 14) {
|
12449 | const callee = props.callee;
|
12450 | if (!isString(callee) && propsHelperSet.has(callee)) {
|
12451 | return getUnnormalizedProps(
|
12452 | props.arguments[0],
|
12453 | callPath.concat(props)
|
12454 | );
|
12455 | }
|
12456 | }
|
12457 | return [props, callPath];
|
12458 | }
|
12459 | function injectProp(node, prop, context) {
|
12460 | let propsWithInjection;
|
12461 | let props = node.type === 13 ? node.props : node.arguments[2];
|
12462 | let callPath = [];
|
12463 | let parentCall;
|
12464 | if (props && !isString(props) && props.type === 14) {
|
12465 | const ret = getUnnormalizedProps(props);
|
12466 | props = ret[0];
|
12467 | callPath = ret[1];
|
12468 | parentCall = callPath[callPath.length - 1];
|
12469 | }
|
12470 | if (props == null || isString(props)) {
|
12471 | propsWithInjection = createObjectExpression([prop]);
|
12472 | } else if (props.type === 14) {
|
12473 | const first = props.arguments[0];
|
12474 | if (!isString(first) && first.type === 15) {
|
12475 | if (!hasProp(prop, first)) {
|
12476 | first.properties.unshift(prop);
|
12477 | }
|
12478 | } else {
|
12479 | if (props.callee === TO_HANDLERS) {
|
12480 | propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
|
12481 | createObjectExpression([prop]),
|
12482 | props
|
12483 | ]);
|
12484 | } else {
|
12485 | props.arguments.unshift(createObjectExpression([prop]));
|
12486 | }
|
12487 | }
|
12488 | !propsWithInjection && (propsWithInjection = props);
|
12489 | } else if (props.type === 15) {
|
12490 | if (!hasProp(prop, props)) {
|
12491 | props.properties.unshift(prop);
|
12492 | }
|
12493 | propsWithInjection = props;
|
12494 | } else {
|
12495 | propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
|
12496 | createObjectExpression([prop]),
|
12497 | props
|
12498 | ]);
|
12499 | if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
|
12500 | parentCall = callPath[callPath.length - 2];
|
12501 | }
|
12502 | }
|
12503 | if (node.type === 13) {
|
12504 | if (parentCall) {
|
12505 | parentCall.arguments[0] = propsWithInjection;
|
12506 | } else {
|
12507 | node.props = propsWithInjection;
|
12508 | }
|
12509 | } else {
|
12510 | if (parentCall) {
|
12511 | parentCall.arguments[0] = propsWithInjection;
|
12512 | } else {
|
12513 | node.arguments[2] = propsWithInjection;
|
12514 | }
|
12515 | }
|
12516 | }
|
12517 | function hasProp(prop, props) {
|
12518 | let result = false;
|
12519 | if (prop.key.type === 4) {
|
12520 | const propKeyName = prop.key.content;
|
12521 | result = props.properties.some(
|
12522 | (p) => p.key.type === 4 && p.key.content === propKeyName
|
12523 | );
|
12524 | }
|
12525 | return result;
|
12526 | }
|
12527 | function toValidAssetId(name, type) {
|
12528 | return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
|
12529 | return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
|
12530 | })}`;
|
12531 | }
|
12532 | function getMemoedVNodeCall(node) {
|
12533 | if (node.type === 14 && node.callee === WITH_MEMO) {
|
12534 | return node.arguments[1].returns;
|
12535 | } else {
|
12536 | return node;
|
12537 | }
|
12538 | }
|
12539 | const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
12540 |
|
12541 | const defaultParserOptions = {
|
12542 | parseMode: "base",
|
12543 | ns: 0,
|
12544 | delimiters: [`{{`, `}}`],
|
12545 | getNamespace: () => 0,
|
12546 | isVoidTag: NO,
|
12547 | isPreTag: NO,
|
12548 | isCustomElement: NO,
|
12549 | onError: defaultOnError,
|
12550 | onWarn: defaultOnWarn,
|
12551 | comments: true,
|
12552 | prefixIdentifiers: false
|
12553 | };
|
12554 | let currentOptions = defaultParserOptions;
|
12555 | let currentRoot = null;
|
12556 | let currentInput = "";
|
12557 | let currentOpenTag = null;
|
12558 | let currentProp = null;
|
12559 | let currentAttrValue = "";
|
12560 | let currentAttrStartIndex = -1;
|
12561 | let currentAttrEndIndex = -1;
|
12562 | let inPre = 0;
|
12563 | let inVPre = false;
|
12564 | let currentVPreBoundary = null;
|
12565 | const stack = [];
|
12566 | const tokenizer = new Tokenizer(stack, {
|
12567 | onerr: emitError,
|
12568 | ontext(start, end) {
|
12569 | onText(getSlice(start, end), start, end);
|
12570 | },
|
12571 | ontextentity(char, start, end) {
|
12572 | onText(char, start, end);
|
12573 | },
|
12574 | oninterpolation(start, end) {
|
12575 | if (inVPre) {
|
12576 | return onText(getSlice(start, end), start, end);
|
12577 | }
|
12578 | let innerStart = start + tokenizer.delimiterOpen.length;
|
12579 | let innerEnd = end - tokenizer.delimiterClose.length;
|
12580 | while (isWhitespace(currentInput.charCodeAt(innerStart))) {
|
12581 | innerStart++;
|
12582 | }
|
12583 | while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
|
12584 | innerEnd--;
|
12585 | }
|
12586 | let exp = getSlice(innerStart, innerEnd);
|
12587 | if (exp.includes("&")) {
|
12588 | {
|
12589 | exp = currentOptions.decodeEntities(exp, false);
|
12590 | }
|
12591 | }
|
12592 | addNode({
|
12593 | type: 5,
|
12594 | content: createExp(exp, false, getLoc(innerStart, innerEnd)),
|
12595 | loc: getLoc(start, end)
|
12596 | });
|
12597 | },
|
12598 | onopentagname(start, end) {
|
12599 | const name = getSlice(start, end);
|
12600 | currentOpenTag = {
|
12601 | type: 1,
|
12602 | tag: name,
|
12603 | ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
|
12604 | tagType: 0,
|
12605 |
|
12606 | props: [],
|
12607 | children: [],
|
12608 | loc: getLoc(start - 1, end),
|
12609 | codegenNode: void 0
|
12610 | };
|
12611 | },
|
12612 | onopentagend(end) {
|
12613 | endOpenTag(end);
|
12614 | },
|
12615 | onclosetag(start, end) {
|
12616 | const name = getSlice(start, end);
|
12617 | if (!currentOptions.isVoidTag(name)) {
|
12618 | let found = false;
|
12619 | for (let i = 0; i < stack.length; i++) {
|
12620 | const e = stack[i];
|
12621 | if (e.tag.toLowerCase() === name.toLowerCase()) {
|
12622 | found = true;
|
12623 | if (i > 0) {
|
12624 | emitError(24, stack[0].loc.start.offset);
|
12625 | }
|
12626 | for (let j = 0; j <= i; j++) {
|
12627 | const el = stack.shift();
|
12628 | onCloseTag(el, end, j < i);
|
12629 | }
|
12630 | break;
|
12631 | }
|
12632 | }
|
12633 | if (!found) {
|
12634 | emitError(23, backTrack(start, 60));
|
12635 | }
|
12636 | }
|
12637 | },
|
12638 | onselfclosingtag(end) {
|
12639 | var _a;
|
12640 | const name = currentOpenTag.tag;
|
12641 | currentOpenTag.isSelfClosing = true;
|
12642 | endOpenTag(end);
|
12643 | if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
|
12644 | onCloseTag(stack.shift(), end);
|
12645 | }
|
12646 | },
|
12647 | onattribname(start, end) {
|
12648 | currentProp = {
|
12649 | type: 6,
|
12650 | name: getSlice(start, end),
|
12651 | nameLoc: getLoc(start, end),
|
12652 | value: void 0,
|
12653 | loc: getLoc(start)
|
12654 | };
|
12655 | },
|
12656 | ondirname(start, end) {
|
12657 | const raw = getSlice(start, end);
|
12658 | const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
|
12659 | if (!inVPre && name === "") {
|
12660 | emitError(26, start);
|
12661 | }
|
12662 | if (inVPre || name === "") {
|
12663 | currentProp = {
|
12664 | type: 6,
|
12665 | name: raw,
|
12666 | nameLoc: getLoc(start, end),
|
12667 | value: void 0,
|
12668 | loc: getLoc(start)
|
12669 | };
|
12670 | } else {
|
12671 | currentProp = {
|
12672 | type: 7,
|
12673 | name,
|
12674 | rawName: raw,
|
12675 | exp: void 0,
|
12676 | arg: void 0,
|
12677 | modifiers: raw === "." ? ["prop"] : [],
|
12678 | loc: getLoc(start)
|
12679 | };
|
12680 | if (name === "pre") {
|
12681 | inVPre = tokenizer.inVPre = true;
|
12682 | currentVPreBoundary = currentOpenTag;
|
12683 | const props = currentOpenTag.props;
|
12684 | for (let i = 0; i < props.length; i++) {
|
12685 | if (props[i].type === 7) {
|
12686 | props[i] = dirToAttr(props[i]);
|
12687 | }
|
12688 | }
|
12689 | }
|
12690 | }
|
12691 | },
|
12692 | ondirarg(start, end) {
|
12693 | if (start === end)
|
12694 | return;
|
12695 | const arg = getSlice(start, end);
|
12696 | if (inVPre) {
|
12697 | currentProp.name += arg;
|
12698 | setLocEnd(currentProp.nameLoc, end);
|
12699 | } else {
|
12700 | const isStatic = arg[0] !== `[`;
|
12701 | currentProp.arg = createExp(
|
12702 | isStatic ? arg : arg.slice(1, -1),
|
12703 | isStatic,
|
12704 | getLoc(start, end),
|
12705 | isStatic ? 3 : 0
|
12706 | );
|
12707 | }
|
12708 | },
|
12709 | ondirmodifier(start, end) {
|
12710 | const mod = getSlice(start, end);
|
12711 | if (inVPre) {
|
12712 | currentProp.name += "." + mod;
|
12713 | setLocEnd(currentProp.nameLoc, end);
|
12714 | } else if (currentProp.name === "slot") {
|
12715 | const arg = currentProp.arg;
|
12716 | if (arg) {
|
12717 | arg.content += "." + mod;
|
12718 | setLocEnd(arg.loc, end);
|
12719 | }
|
12720 | } else {
|
12721 | currentProp.modifiers.push(mod);
|
12722 | }
|
12723 | },
|
12724 | onattribdata(start, end) {
|
12725 | currentAttrValue += getSlice(start, end);
|
12726 | if (currentAttrStartIndex < 0)
|
12727 | currentAttrStartIndex = start;
|
12728 | currentAttrEndIndex = end;
|
12729 | },
|
12730 | onattribentity(char, start, end) {
|
12731 | currentAttrValue += char;
|
12732 | if (currentAttrStartIndex < 0)
|
12733 | currentAttrStartIndex = start;
|
12734 | currentAttrEndIndex = end;
|
12735 | },
|
12736 | onattribnameend(end) {
|
12737 | const start = currentProp.loc.start.offset;
|
12738 | const name = getSlice(start, end);
|
12739 | if (currentProp.type === 7) {
|
12740 | currentProp.rawName = name;
|
12741 | }
|
12742 | if (currentOpenTag.props.some(
|
12743 | (p) => (p.type === 7 ? p.rawName : p.name) === name
|
12744 | )) {
|
12745 | emitError(2, start);
|
12746 | }
|
12747 | },
|
12748 | onattribend(quote, end) {
|
12749 | if (currentOpenTag && currentProp) {
|
12750 | setLocEnd(currentProp.loc, end);
|
12751 | if (quote !== 0) {
|
12752 | if (currentAttrValue.includes("&")) {
|
12753 | currentAttrValue = currentOptions.decodeEntities(
|
12754 | currentAttrValue,
|
12755 | true
|
12756 | );
|
12757 | }
|
12758 | if (currentProp.type === 6) {
|
12759 | if (currentProp.name === "class") {
|
12760 | currentAttrValue = condense(currentAttrValue).trim();
|
12761 | }
|
12762 | if (quote === 1 && !currentAttrValue) {
|
12763 | emitError(13, end);
|
12764 | }
|
12765 | currentProp.value = {
|
12766 | type: 2,
|
12767 | content: currentAttrValue,
|
12768 | loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
|
12769 | };
|
12770 | if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
|
12771 | tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
|
12772 | }
|
12773 | } else {
|
12774 | let expParseMode = 0 ;
|
12775 | currentProp.exp = createExp(
|
12776 | currentAttrValue,
|
12777 | false,
|
12778 | getLoc(currentAttrStartIndex, currentAttrEndIndex),
|
12779 | 0,
|
12780 | expParseMode
|
12781 | );
|
12782 | if (currentProp.name === "for") {
|
12783 | currentProp.forParseResult = parseForExpression(currentProp.exp);
|
12784 | }
|
12785 | }
|
12786 | }
|
12787 | if (currentProp.type !== 7 || currentProp.name !== "pre") {
|
12788 | currentOpenTag.props.push(currentProp);
|
12789 | }
|
12790 | }
|
12791 | currentAttrValue = "";
|
12792 | currentAttrStartIndex = currentAttrEndIndex = -1;
|
12793 | },
|
12794 | oncomment(start, end) {
|
12795 | if (currentOptions.comments) {
|
12796 | addNode({
|
12797 | type: 3,
|
12798 | content: getSlice(start, end),
|
12799 | loc: getLoc(start - 4, end + 3)
|
12800 | });
|
12801 | }
|
12802 | },
|
12803 | onend() {
|
12804 | const end = currentInput.length;
|
12805 | if (tokenizer.state !== 1) {
|
12806 | switch (tokenizer.state) {
|
12807 | case 5:
|
12808 | case 8:
|
12809 | emitError(5, end);
|
12810 | break;
|
12811 | case 3:
|
12812 | case 4:
|
12813 | emitError(
|
12814 | 25,
|
12815 | tokenizer.sectionStart
|
12816 | );
|
12817 | break;
|
12818 | case 28:
|
12819 | if (tokenizer.currentSequence === Sequences.CdataEnd) {
|
12820 | emitError(6, end);
|
12821 | } else {
|
12822 | emitError(7, end);
|
12823 | }
|
12824 | break;
|
12825 | case 6:
|
12826 | case 7:
|
12827 | case 9:
|
12828 | case 11:
|
12829 | case 12:
|
12830 | case 13:
|
12831 | case 14:
|
12832 | case 15:
|
12833 | case 16:
|
12834 | case 17:
|
12835 | case 18:
|
12836 | case 19:
|
12837 | case 20:
|
12838 | case 21:
|
12839 | emitError(9, end);
|
12840 | break;
|
12841 | }
|
12842 | }
|
12843 | for (let index = 0; index < stack.length; index++) {
|
12844 | onCloseTag(stack[index], end - 1);
|
12845 | emitError(24, stack[index].loc.start.offset);
|
12846 | }
|
12847 | },
|
12848 | oncdata(start, end) {
|
12849 | if (stack[0].ns !== 0) {
|
12850 | onText(getSlice(start, end), start, end);
|
12851 | } else {
|
12852 | emitError(1, start - 9);
|
12853 | }
|
12854 | },
|
12855 | onprocessinginstruction(start) {
|
12856 | if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
12857 | emitError(
|
12858 | 21,
|
12859 | start - 1
|
12860 | );
|
12861 | }
|
12862 | }
|
12863 | });
|
12864 | const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
12865 | const stripParensRE = /^\(|\)$/g;
|
12866 | function parseForExpression(input) {
|
12867 | const loc = input.loc;
|
12868 | const exp = input.content;
|
12869 | const inMatch = exp.match(forAliasRE);
|
12870 | if (!inMatch)
|
12871 | return;
|
12872 | const [, LHS, RHS] = inMatch;
|
12873 | const createAliasExpression = (content, offset, asParam = false) => {
|
12874 | const start = loc.start.offset + offset;
|
12875 | const end = start + content.length;
|
12876 | return createExp(
|
12877 | content,
|
12878 | false,
|
12879 | getLoc(start, end),
|
12880 | 0,
|
12881 | asParam ? 1 : 0
|
12882 | );
|
12883 | };
|
12884 | const result = {
|
12885 | source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
12886 | value: void 0,
|
12887 | key: void 0,
|
12888 | index: void 0,
|
12889 | finalized: false
|
12890 | };
|
12891 | let valueContent = LHS.trim().replace(stripParensRE, "").trim();
|
12892 | const trimmedOffset = LHS.indexOf(valueContent);
|
12893 | const iteratorMatch = valueContent.match(forIteratorRE);
|
12894 | if (iteratorMatch) {
|
12895 | valueContent = valueContent.replace(forIteratorRE, "").trim();
|
12896 | const keyContent = iteratorMatch[1].trim();
|
12897 | let keyOffset;
|
12898 | if (keyContent) {
|
12899 | keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
12900 | result.key = createAliasExpression(keyContent, keyOffset, true);
|
12901 | }
|
12902 | if (iteratorMatch[2]) {
|
12903 | const indexContent = iteratorMatch[2].trim();
|
12904 | if (indexContent) {
|
12905 | result.index = createAliasExpression(
|
12906 | indexContent,
|
12907 | exp.indexOf(
|
12908 | indexContent,
|
12909 | result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
12910 | ),
|
12911 | true
|
12912 | );
|
12913 | }
|
12914 | }
|
12915 | }
|
12916 | if (valueContent) {
|
12917 | result.value = createAliasExpression(valueContent, trimmedOffset, true);
|
12918 | }
|
12919 | return result;
|
12920 | }
|
12921 | function getSlice(start, end) {
|
12922 | return currentInput.slice(start, end);
|
12923 | }
|
12924 | function endOpenTag(end) {
|
12925 | if (tokenizer.inSFCRoot) {
|
12926 | currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
|
12927 | }
|
12928 | addNode(currentOpenTag);
|
12929 | const { tag, ns } = currentOpenTag;
|
12930 | if (ns === 0 && currentOptions.isPreTag(tag)) {
|
12931 | inPre++;
|
12932 | }
|
12933 | if (currentOptions.isVoidTag(tag)) {
|
12934 | onCloseTag(currentOpenTag, end);
|
12935 | } else {
|
12936 | stack.unshift(currentOpenTag);
|
12937 | if (ns === 1 || ns === 2) {
|
12938 | tokenizer.inXML = true;
|
12939 | }
|
12940 | }
|
12941 | currentOpenTag = null;
|
12942 | }
|
12943 | function onText(content, start, end) {
|
12944 | var _a;
|
12945 | {
|
12946 | const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
|
12947 | if (tag !== "script" && tag !== "style" && content.includes("&")) {
|
12948 | content = currentOptions.decodeEntities(content, false);
|
12949 | }
|
12950 | }
|
12951 | const parent = stack[0] || currentRoot;
|
12952 | const lastNode = parent.children[parent.children.length - 1];
|
12953 | if ((lastNode == null ? void 0 : lastNode.type) === 2) {
|
12954 | lastNode.content += content;
|
12955 | setLocEnd(lastNode.loc, end);
|
12956 | } else {
|
12957 | parent.children.push({
|
12958 | type: 2,
|
12959 | content,
|
12960 | loc: getLoc(start, end)
|
12961 | });
|
12962 | }
|
12963 | }
|
12964 | function onCloseTag(el, end, isImplied = false) {
|
12965 | if (isImplied) {
|
12966 | setLocEnd(el.loc, backTrack(end, 60));
|
12967 | } else {
|
12968 | setLocEnd(el.loc, lookAhead(end, 62) + 1);
|
12969 | }
|
12970 | if (tokenizer.inSFCRoot) {
|
12971 | if (el.children.length) {
|
12972 | el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
|
12973 | } else {
|
12974 | el.innerLoc.end = extend({}, el.innerLoc.start);
|
12975 | }
|
12976 | el.innerLoc.source = getSlice(
|
12977 | el.innerLoc.start.offset,
|
12978 | el.innerLoc.end.offset
|
12979 | );
|
12980 | }
|
12981 | const { tag, ns } = el;
|
12982 | if (!inVPre) {
|
12983 | if (tag === "slot") {
|
12984 | el.tagType = 2;
|
12985 | } else if (isFragmentTemplate(el)) {
|
12986 | el.tagType = 3;
|
12987 | } else if (isComponent(el)) {
|
12988 | el.tagType = 1;
|
12989 | }
|
12990 | }
|
12991 | if (!tokenizer.inRCDATA) {
|
12992 | el.children = condenseWhitespace(el.children, el.tag);
|
12993 | }
|
12994 | if (ns === 0 && currentOptions.isPreTag(tag)) {
|
12995 | inPre--;
|
12996 | }
|
12997 | if (currentVPreBoundary === el) {
|
12998 | inVPre = tokenizer.inVPre = false;
|
12999 | currentVPreBoundary = null;
|
13000 | }
|
13001 | if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
13002 | tokenizer.inXML = false;
|
13003 | }
|
13004 | }
|
13005 | function lookAhead(index, c) {
|
13006 | let i = index;
|
13007 | while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1)
|
13008 | i++;
|
13009 | return i;
|
13010 | }
|
13011 | function backTrack(index, c) {
|
13012 | let i = index;
|
13013 | while (currentInput.charCodeAt(i) !== c && i >= 0)
|
13014 | i--;
|
13015 | return i;
|
13016 | }
|
13017 | const specialTemplateDir = new Set(["if", "else", "else-if", "for", "slot"]);
|
13018 | function isFragmentTemplate({ tag, props }) {
|
13019 | if (tag === "template") {
|
13020 | for (let i = 0; i < props.length; i++) {
|
13021 | if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
|
13022 | return true;
|
13023 | }
|
13024 | }
|
13025 | }
|
13026 | return false;
|
13027 | }
|
13028 | function isComponent({ tag, props }) {
|
13029 | var _a;
|
13030 | if (currentOptions.isCustomElement(tag)) {
|
13031 | return false;
|
13032 | }
|
13033 | if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
|
13034 | return true;
|
13035 | }
|
13036 | for (let i = 0; i < props.length; i++) {
|
13037 | const p = props[i];
|
13038 | if (p.type === 6) {
|
13039 | if (p.name === "is" && p.value) {
|
13040 | if (p.value.content.startsWith("vue:")) {
|
13041 | return true;
|
13042 | }
|
13043 | }
|
13044 | }
|
13045 | }
|
13046 | return false;
|
13047 | }
|
13048 | function isUpperCase(c) {
|
13049 | return c > 64 && c < 91;
|
13050 | }
|
13051 | const windowsNewlineRE = /\r\n/g;
|
13052 | function condenseWhitespace(nodes, tag) {
|
13053 | var _a, _b;
|
13054 | const shouldCondense = currentOptions.whitespace !== "preserve";
|
13055 | let removedWhitespace = false;
|
13056 | for (let i = 0; i < nodes.length; i++) {
|
13057 | const node = nodes[i];
|
13058 | if (node.type === 2) {
|
13059 | if (!inPre) {
|
13060 | if (isAllWhitespace(node.content)) {
|
13061 | const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
|
13062 | const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
|
13063 | if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
|
13064 | removedWhitespace = true;
|
13065 | nodes[i] = null;
|
13066 | } else {
|
13067 | node.content = " ";
|
13068 | }
|
13069 | } else if (shouldCondense) {
|
13070 | node.content = condense(node.content);
|
13071 | }
|
13072 | } else {
|
13073 | node.content = node.content.replace(windowsNewlineRE, "\n");
|
13074 | }
|
13075 | }
|
13076 | }
|
13077 | if (inPre && tag && currentOptions.isPreTag(tag)) {
|
13078 | const first = nodes[0];
|
13079 | if (first && first.type === 2) {
|
13080 | first.content = first.content.replace(/^\r?\n/, "");
|
13081 | }
|
13082 | }
|
13083 | return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
13084 | }
|
13085 | function isAllWhitespace(str) {
|
13086 | for (let i = 0; i < str.length; i++) {
|
13087 | if (!isWhitespace(str.charCodeAt(i))) {
|
13088 | return false;
|
13089 | }
|
13090 | }
|
13091 | return true;
|
13092 | }
|
13093 | function hasNewlineChar(str) {
|
13094 | for (let i = 0; i < str.length; i++) {
|
13095 | const c = str.charCodeAt(i);
|
13096 | if (c === 10 || c === 13) {
|
13097 | return true;
|
13098 | }
|
13099 | }
|
13100 | return false;
|
13101 | }
|
13102 | function condense(str) {
|
13103 | let ret = "";
|
13104 | let prevCharIsWhitespace = false;
|
13105 | for (let i = 0; i < str.length; i++) {
|
13106 | if (isWhitespace(str.charCodeAt(i))) {
|
13107 | if (!prevCharIsWhitespace) {
|
13108 | ret += " ";
|
13109 | prevCharIsWhitespace = true;
|
13110 | }
|
13111 | } else {
|
13112 | ret += str[i];
|
13113 | prevCharIsWhitespace = false;
|
13114 | }
|
13115 | }
|
13116 | return ret;
|
13117 | }
|
13118 | function addNode(node) {
|
13119 | (stack[0] || currentRoot).children.push(node);
|
13120 | }
|
13121 | function getLoc(start, end) {
|
13122 | return {
|
13123 | start: tokenizer.getPos(start),
|
13124 |
|
13125 | end: end == null ? end : tokenizer.getPos(end),
|
13126 |
|
13127 | source: end == null ? end : getSlice(start, end)
|
13128 | };
|
13129 | }
|
13130 | function setLocEnd(loc, end) {
|
13131 | loc.end = tokenizer.getPos(end);
|
13132 | loc.source = getSlice(loc.start.offset, end);
|
13133 | }
|
13134 | function dirToAttr(dir) {
|
13135 | const attr = {
|
13136 | type: 6,
|
13137 | name: dir.rawName,
|
13138 | nameLoc: getLoc(
|
13139 | dir.loc.start.offset,
|
13140 | dir.loc.start.offset + dir.rawName.length
|
13141 | ),
|
13142 | value: void 0,
|
13143 | loc: dir.loc
|
13144 | };
|
13145 | if (dir.exp) {
|
13146 | const loc = dir.exp.loc;
|
13147 | if (loc.end.offset < dir.loc.end.offset) {
|
13148 | loc.start.offset--;
|
13149 | loc.start.column--;
|
13150 | loc.end.offset++;
|
13151 | loc.end.column++;
|
13152 | }
|
13153 | attr.value = {
|
13154 | type: 2,
|
13155 | content: dir.exp.content,
|
13156 | loc
|
13157 | };
|
13158 | }
|
13159 | return attr;
|
13160 | }
|
13161 | function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
|
13162 | const exp = createSimpleExpression(content, isStatic, loc, constType);
|
13163 | return exp;
|
13164 | }
|
13165 | function emitError(code, index, message) {
|
13166 | currentOptions.onError(
|
13167 | createCompilerError(code, getLoc(index, index), void 0, message)
|
13168 | );
|
13169 | }
|
13170 | function reset() {
|
13171 | tokenizer.reset();
|
13172 | currentOpenTag = null;
|
13173 | currentProp = null;
|
13174 | currentAttrValue = "";
|
13175 | currentAttrStartIndex = -1;
|
13176 | currentAttrEndIndex = -1;
|
13177 | stack.length = 0;
|
13178 | }
|
13179 | function baseParse(input, options) {
|
13180 | reset();
|
13181 | currentInput = input;
|
13182 | currentOptions = extend({}, defaultParserOptions);
|
13183 | if (options) {
|
13184 | let key;
|
13185 | for (key in options) {
|
13186 | if (options[key] != null) {
|
13187 | currentOptions[key] = options[key];
|
13188 | }
|
13189 | }
|
13190 | }
|
13191 | {
|
13192 | if (!currentOptions.decodeEntities) {
|
13193 | throw new Error(
|
13194 | `[@vue/compiler-core] decodeEntities option is required in browser builds.`
|
13195 | );
|
13196 | }
|
13197 | }
|
13198 | tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
13199 | tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
|
13200 | const delimiters = options == null ? void 0 : options.delimiters;
|
13201 | if (delimiters) {
|
13202 | tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
|
13203 | tokenizer.delimiterClose = toCharCodes(delimiters[1]);
|
13204 | }
|
13205 | const root = currentRoot = createRoot([], input);
|
13206 | tokenizer.parse(currentInput);
|
13207 | root.loc = getLoc(0, input.length);
|
13208 | root.children = condenseWhitespace(root.children);
|
13209 | currentRoot = null;
|
13210 | return root;
|
13211 | }
|
13212 |
|
13213 | function hoistStatic(root, context) {
|
13214 | walk(
|
13215 | root,
|
13216 | context,
|
13217 |
|
13218 |
|
13219 | isSingleElementRoot(root, root.children[0])
|
13220 | );
|
13221 | }
|
13222 | function isSingleElementRoot(root, child) {
|
13223 | const { children } = root;
|
13224 | return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
|
13225 | }
|
13226 | function walk(node, context, doNotHoistNode = false) {
|
13227 | const { children } = node;
|
13228 | const originalCount = children.length;
|
13229 | let hoistedCount = 0;
|
13230 | for (let i = 0; i < children.length; i++) {
|
13231 | const child = children[i];
|
13232 | if (child.type === 1 && child.tagType === 0) {
|
13233 | const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
13234 | if (constantType > 0) {
|
13235 | if (constantType >= 2) {
|
13236 | child.codegenNode.patchFlag = -1 + (` /* HOISTED */` );
|
13237 | child.codegenNode = context.hoist(child.codegenNode);
|
13238 | hoistedCount++;
|
13239 | continue;
|
13240 | }
|
13241 | } else {
|
13242 | const codegenNode = child.codegenNode;
|
13243 | if (codegenNode.type === 13) {
|
13244 | const flag = getPatchFlag(codegenNode);
|
13245 | if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
|
13246 | const props = getNodeProps(child);
|
13247 | if (props) {
|
13248 | codegenNode.props = context.hoist(props);
|
13249 | }
|
13250 | }
|
13251 | if (codegenNode.dynamicProps) {
|
13252 | codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
|
13253 | }
|
13254 | }
|
13255 | }
|
13256 | }
|
13257 | if (child.type === 1) {
|
13258 | const isComponent = child.tagType === 1;
|
13259 | if (isComponent) {
|
13260 | context.scopes.vSlot++;
|
13261 | }
|
13262 | walk(child, context);
|
13263 | if (isComponent) {
|
13264 | context.scopes.vSlot--;
|
13265 | }
|
13266 | } else if (child.type === 11) {
|
13267 | walk(child, context, child.children.length === 1);
|
13268 | } else if (child.type === 9) {
|
13269 | for (let i2 = 0; i2 < child.branches.length; i2++) {
|
13270 | walk(
|
13271 | child.branches[i2],
|
13272 | context,
|
13273 | child.branches[i2].children.length === 1
|
13274 | );
|
13275 | }
|
13276 | }
|
13277 | }
|
13278 | if (hoistedCount && context.transformHoist) {
|
13279 | context.transformHoist(children, context, node);
|
13280 | }
|
13281 | if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
|
13282 | const hoisted = context.hoist(
|
13283 | createArrayExpression(node.codegenNode.children)
|
13284 | );
|
13285 | if (context.hmr) {
|
13286 | hoisted.content = `[...${hoisted.content}]`;
|
13287 | }
|
13288 | node.codegenNode.children = hoisted;
|
13289 | }
|
13290 | }
|
13291 | function getConstantType(node, context) {
|
13292 | const { constantCache } = context;
|
13293 | switch (node.type) {
|
13294 | case 1:
|
13295 | if (node.tagType !== 0) {
|
13296 | return 0;
|
13297 | }
|
13298 | const cached = constantCache.get(node);
|
13299 | if (cached !== void 0) {
|
13300 | return cached;
|
13301 | }
|
13302 | const codegenNode = node.codegenNode;
|
13303 | if (codegenNode.type !== 13) {
|
13304 | return 0;
|
13305 | }
|
13306 | if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
|
13307 | return 0;
|
13308 | }
|
13309 | const flag = getPatchFlag(codegenNode);
|
13310 | if (!flag) {
|
13311 | let returnType2 = 3;
|
13312 | const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
13313 | if (generatedPropsType === 0) {
|
13314 | constantCache.set(node, 0);
|
13315 | return 0;
|
13316 | }
|
13317 | if (generatedPropsType < returnType2) {
|
13318 | returnType2 = generatedPropsType;
|
13319 | }
|
13320 | for (let i = 0; i < node.children.length; i++) {
|
13321 | const childType = getConstantType(node.children[i], context);
|
13322 | if (childType === 0) {
|
13323 | constantCache.set(node, 0);
|
13324 | return 0;
|
13325 | }
|
13326 | if (childType < returnType2) {
|
13327 | returnType2 = childType;
|
13328 | }
|
13329 | }
|
13330 | if (returnType2 > 1) {
|
13331 | for (let i = 0; i < node.props.length; i++) {
|
13332 | const p = node.props[i];
|
13333 | if (p.type === 7 && p.name === "bind" && p.exp) {
|
13334 | const expType = getConstantType(p.exp, context);
|
13335 | if (expType === 0) {
|
13336 | constantCache.set(node, 0);
|
13337 | return 0;
|
13338 | }
|
13339 | if (expType < returnType2) {
|
13340 | returnType2 = expType;
|
13341 | }
|
13342 | }
|
13343 | }
|
13344 | }
|
13345 | if (codegenNode.isBlock) {
|
13346 | for (let i = 0; i < node.props.length; i++) {
|
13347 | const p = node.props[i];
|
13348 | if (p.type === 7) {
|
13349 | constantCache.set(node, 0);
|
13350 | return 0;
|
13351 | }
|
13352 | }
|
13353 | context.removeHelper(OPEN_BLOCK);
|
13354 | context.removeHelper(
|
13355 | getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
|
13356 | );
|
13357 | codegenNode.isBlock = false;
|
13358 | context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
|
13359 | }
|
13360 | constantCache.set(node, returnType2);
|
13361 | return returnType2;
|
13362 | } else {
|
13363 | constantCache.set(node, 0);
|
13364 | return 0;
|
13365 | }
|
13366 | case 2:
|
13367 | case 3:
|
13368 | return 3;
|
13369 | case 9:
|
13370 | case 11:
|
13371 | case 10:
|
13372 | return 0;
|
13373 | case 5:
|
13374 | case 12:
|
13375 | return getConstantType(node.content, context);
|
13376 | case 4:
|
13377 | return node.constType;
|
13378 | case 8:
|
13379 | let returnType = 3;
|
13380 | for (let i = 0; i < node.children.length; i++) {
|
13381 | const child = node.children[i];
|
13382 | if (isString(child) || isSymbol(child)) {
|
13383 | continue;
|
13384 | }
|
13385 | const childType = getConstantType(child, context);
|
13386 | if (childType === 0) {
|
13387 | return 0;
|
13388 | } else if (childType < returnType) {
|
13389 | returnType = childType;
|
13390 | }
|
13391 | }
|
13392 | return returnType;
|
13393 | default:
|
13394 | return 0;
|
13395 | }
|
13396 | }
|
13397 | const allowHoistedHelperSet = new Set([
|
13398 | NORMALIZE_CLASS,
|
13399 | NORMALIZE_STYLE,
|
13400 | NORMALIZE_PROPS,
|
13401 | GUARD_REACTIVE_PROPS
|
13402 | ]);
|
13403 | function getConstantTypeOfHelperCall(value, context) {
|
13404 | if (value.type === 14 && !isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
|
13405 | const arg = value.arguments[0];
|
13406 | if (arg.type === 4) {
|
13407 | return getConstantType(arg, context);
|
13408 | } else if (arg.type === 14) {
|
13409 | return getConstantTypeOfHelperCall(arg, context);
|
13410 | }
|
13411 | }
|
13412 | return 0;
|
13413 | }
|
13414 | function getGeneratedPropsConstantType(node, context) {
|
13415 | let returnType = 3;
|
13416 | const props = getNodeProps(node);
|
13417 | if (props && props.type === 15) {
|
13418 | const { properties } = props;
|
13419 | for (let i = 0; i < properties.length; i++) {
|
13420 | const { key, value } = properties[i];
|
13421 | const keyType = getConstantType(key, context);
|
13422 | if (keyType === 0) {
|
13423 | return keyType;
|
13424 | }
|
13425 | if (keyType < returnType) {
|
13426 | returnType = keyType;
|
13427 | }
|
13428 | let valueType;
|
13429 | if (value.type === 4) {
|
13430 | valueType = getConstantType(value, context);
|
13431 | } else if (value.type === 14) {
|
13432 | valueType = getConstantTypeOfHelperCall(value, context);
|
13433 | } else {
|
13434 | valueType = 0;
|
13435 | }
|
13436 | if (valueType === 0) {
|
13437 | return valueType;
|
13438 | }
|
13439 | if (valueType < returnType) {
|
13440 | returnType = valueType;
|
13441 | }
|
13442 | }
|
13443 | }
|
13444 | return returnType;
|
13445 | }
|
13446 | function getNodeProps(node) {
|
13447 | const codegenNode = node.codegenNode;
|
13448 | if (codegenNode.type === 13) {
|
13449 | return codegenNode.props;
|
13450 | }
|
13451 | }
|
13452 | function getPatchFlag(node) {
|
13453 | const flag = node.patchFlag;
|
13454 | return flag ? parseInt(flag, 10) : void 0;
|
13455 | }
|
13456 |
|
13457 | function createTransformContext(root, {
|
13458 | filename = "",
|
13459 | prefixIdentifiers = false,
|
13460 | hoistStatic: hoistStatic2 = false,
|
13461 | hmr = false,
|
13462 | cacheHandlers = false,
|
13463 | nodeTransforms = [],
|
13464 | directiveTransforms = {},
|
13465 | transformHoist = null,
|
13466 | isBuiltInComponent = NOOP,
|
13467 | isCustomElement = NOOP,
|
13468 | expressionPlugins = [],
|
13469 | scopeId = null,
|
13470 | slotted = true,
|
13471 | ssr = false,
|
13472 | inSSR = false,
|
13473 | ssrCssVars = ``,
|
13474 | bindingMetadata = EMPTY_OBJ,
|
13475 | inline = false,
|
13476 | isTS = false,
|
13477 | onError = defaultOnError,
|
13478 | onWarn = defaultOnWarn,
|
13479 | compatConfig
|
13480 | }) {
|
13481 | const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
13482 | const context = {
|
13483 |
|
13484 | filename,
|
13485 | selfName: nameMatch && capitalize(camelize(nameMatch[1])),
|
13486 | prefixIdentifiers,
|
13487 | hoistStatic: hoistStatic2,
|
13488 | hmr,
|
13489 | cacheHandlers,
|
13490 | nodeTransforms,
|
13491 | directiveTransforms,
|
13492 | transformHoist,
|
13493 | isBuiltInComponent,
|
13494 | isCustomElement,
|
13495 | expressionPlugins,
|
13496 | scopeId,
|
13497 | slotted,
|
13498 | ssr,
|
13499 | inSSR,
|
13500 | ssrCssVars,
|
13501 | bindingMetadata,
|
13502 | inline,
|
13503 | isTS,
|
13504 | onError,
|
13505 | onWarn,
|
13506 | compatConfig,
|
13507 |
|
13508 | root,
|
13509 | helpers: new Map(),
|
13510 | components: new Set(),
|
13511 | directives: new Set(),
|
13512 | hoists: [],
|
13513 | imports: [],
|
13514 | constantCache: new WeakMap(),
|
13515 | temps: 0,
|
13516 | cached: 0,
|
13517 | identifiers: Object.create(null),
|
13518 | scopes: {
|
13519 | vFor: 0,
|
13520 | vSlot: 0,
|
13521 | vPre: 0,
|
13522 | vOnce: 0
|
13523 | },
|
13524 | parent: null,
|
13525 | grandParent: null,
|
13526 | currentNode: root,
|
13527 | childIndex: 0,
|
13528 | inVOnce: false,
|
13529 |
|
13530 | helper(name) {
|
13531 | const count = context.helpers.get(name) || 0;
|
13532 | context.helpers.set(name, count + 1);
|
13533 | return name;
|
13534 | },
|
13535 | removeHelper(name) {
|
13536 | const count = context.helpers.get(name);
|
13537 | if (count) {
|
13538 | const currentCount = count - 1;
|
13539 | if (!currentCount) {
|
13540 | context.helpers.delete(name);
|
13541 | } else {
|
13542 | context.helpers.set(name, currentCount);
|
13543 | }
|
13544 | }
|
13545 | },
|
13546 | helperString(name) {
|
13547 | return `_${helperNameMap[context.helper(name)]}`;
|
13548 | },
|
13549 | replaceNode(node) {
|
13550 | {
|
13551 | if (!context.currentNode) {
|
13552 | throw new Error(`Node being replaced is already removed.`);
|
13553 | }
|
13554 | if (!context.parent) {
|
13555 | throw new Error(`Cannot replace root node.`);
|
13556 | }
|
13557 | }
|
13558 | context.parent.children[context.childIndex] = context.currentNode = node;
|
13559 | },
|
13560 | removeNode(node) {
|
13561 | if (!context.parent) {
|
13562 | throw new Error(`Cannot remove root node.`);
|
13563 | }
|
13564 | const list = context.parent.children;
|
13565 | const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
|
13566 | if (removalIndex < 0) {
|
13567 | throw new Error(`node being removed is not a child of current parent`);
|
13568 | }
|
13569 | if (!node || node === context.currentNode) {
|
13570 | context.currentNode = null;
|
13571 | context.onNodeRemoved();
|
13572 | } else {
|
13573 | if (context.childIndex > removalIndex) {
|
13574 | context.childIndex--;
|
13575 | context.onNodeRemoved();
|
13576 | }
|
13577 | }
|
13578 | context.parent.children.splice(removalIndex, 1);
|
13579 | },
|
13580 | onNodeRemoved: NOOP,
|
13581 | addIdentifiers(exp) {
|
13582 | },
|
13583 | removeIdentifiers(exp) {
|
13584 | },
|
13585 | hoist(exp) {
|
13586 | if (isString(exp))
|
13587 | exp = createSimpleExpression(exp);
|
13588 | context.hoists.push(exp);
|
13589 | const identifier = createSimpleExpression(
|
13590 | `_hoisted_${context.hoists.length}`,
|
13591 | false,
|
13592 | exp.loc,
|
13593 | 2
|
13594 | );
|
13595 | identifier.hoisted = exp;
|
13596 | return identifier;
|
13597 | },
|
13598 | cache(exp, isVNode = false) {
|
13599 | return createCacheExpression(context.cached++, exp, isVNode);
|
13600 | }
|
13601 | };
|
13602 | return context;
|
13603 | }
|
13604 | function transform(root, options) {
|
13605 | const context = createTransformContext(root, options);
|
13606 | traverseNode(root, context);
|
13607 | if (options.hoistStatic) {
|
13608 | hoistStatic(root, context);
|
13609 | }
|
13610 | if (!options.ssr) {
|
13611 | createRootCodegen(root, context);
|
13612 | }
|
13613 | root.helpers = new Set([...context.helpers.keys()]);
|
13614 | root.components = [...context.components];
|
13615 | root.directives = [...context.directives];
|
13616 | root.imports = context.imports;
|
13617 | root.hoists = context.hoists;
|
13618 | root.temps = context.temps;
|
13619 | root.cached = context.cached;
|
13620 | root.transformed = true;
|
13621 | }
|
13622 | function createRootCodegen(root, context) {
|
13623 | const { helper } = context;
|
13624 | const { children } = root;
|
13625 | if (children.length === 1) {
|
13626 | const child = children[0];
|
13627 | if (isSingleElementRoot(root, child) && child.codegenNode) {
|
13628 | const codegenNode = child.codegenNode;
|
13629 | if (codegenNode.type === 13) {
|
13630 | convertToBlock(codegenNode, context);
|
13631 | }
|
13632 | root.codegenNode = codegenNode;
|
13633 | } else {
|
13634 | root.codegenNode = child;
|
13635 | }
|
13636 | } else if (children.length > 1) {
|
13637 | let patchFlag = 64;
|
13638 | let patchFlagText = PatchFlagNames[64];
|
13639 | if (children.filter((c) => c.type !== 3).length === 1) {
|
13640 | patchFlag |= 2048;
|
13641 | patchFlagText += `, ${PatchFlagNames[2048]}`;
|
13642 | }
|
13643 | root.codegenNode = createVNodeCall(
|
13644 | context,
|
13645 | helper(FRAGMENT),
|
13646 | void 0,
|
13647 | root.children,
|
13648 | patchFlag + (` /* ${patchFlagText} */` ),
|
13649 | void 0,
|
13650 | void 0,
|
13651 | true,
|
13652 | void 0,
|
13653 | false
|
13654 | );
|
13655 | } else ;
|
13656 | }
|
13657 | function traverseChildren(parent, context) {
|
13658 | let i = 0;
|
13659 | const nodeRemoved = () => {
|
13660 | i--;
|
13661 | };
|
13662 | for (; i < parent.children.length; i++) {
|
13663 | const child = parent.children[i];
|
13664 | if (isString(child))
|
13665 | continue;
|
13666 | context.grandParent = context.parent;
|
13667 | context.parent = parent;
|
13668 | context.childIndex = i;
|
13669 | context.onNodeRemoved = nodeRemoved;
|
13670 | traverseNode(child, context);
|
13671 | }
|
13672 | }
|
13673 | function traverseNode(node, context) {
|
13674 | context.currentNode = node;
|
13675 | const { nodeTransforms } = context;
|
13676 | const exitFns = [];
|
13677 | for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
|
13678 | const onExit = nodeTransforms[i2](node, context);
|
13679 | if (onExit) {
|
13680 | if (isArray(onExit)) {
|
13681 | exitFns.push(...onExit);
|
13682 | } else {
|
13683 | exitFns.push(onExit);
|
13684 | }
|
13685 | }
|
13686 | if (!context.currentNode) {
|
13687 | return;
|
13688 | } else {
|
13689 | node = context.currentNode;
|
13690 | }
|
13691 | }
|
13692 | switch (node.type) {
|
13693 | case 3:
|
13694 | if (!context.ssr) {
|
13695 | context.helper(CREATE_COMMENT);
|
13696 | }
|
13697 | break;
|
13698 | case 5:
|
13699 | if (!context.ssr) {
|
13700 | context.helper(TO_DISPLAY_STRING);
|
13701 | }
|
13702 | break;
|
13703 | case 9:
|
13704 | for (let i2 = 0; i2 < node.branches.length; i2++) {
|
13705 | traverseNode(node.branches[i2], context);
|
13706 | }
|
13707 | break;
|
13708 | case 10:
|
13709 | case 11:
|
13710 | case 1:
|
13711 | case 0:
|
13712 | traverseChildren(node, context);
|
13713 | break;
|
13714 | }
|
13715 | context.currentNode = node;
|
13716 | let i = exitFns.length;
|
13717 | while (i--) {
|
13718 | exitFns[i]();
|
13719 | }
|
13720 | }
|
13721 | function createStructuralDirectiveTransform(name, fn) {
|
13722 | const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
|
13723 | return (node, context) => {
|
13724 | if (node.type === 1) {
|
13725 | const { props } = node;
|
13726 | if (node.tagType === 3 && props.some(isVSlot)) {
|
13727 | return;
|
13728 | }
|
13729 | const exitFns = [];
|
13730 | for (let i = 0; i < props.length; i++) {
|
13731 | const prop = props[i];
|
13732 | if (prop.type === 7 && matches(prop.name)) {
|
13733 | props.splice(i, 1);
|
13734 | i--;
|
13735 | const onExit = fn(node, prop, context);
|
13736 | if (onExit)
|
13737 | exitFns.push(onExit);
|
13738 | }
|
13739 | }
|
13740 | return exitFns;
|
13741 | }
|
13742 | };
|
13743 | }
|
13744 |
|
13745 | const PURE_ANNOTATION = `/*#__PURE__*/`;
|
13746 | const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
13747 | function createCodegenContext(ast, {
|
13748 | mode = "function",
|
13749 | prefixIdentifiers = mode === "module",
|
13750 | sourceMap = false,
|
13751 | filename = `template.vue.html`,
|
13752 | scopeId = null,
|
13753 | optimizeImports = false,
|
13754 | runtimeGlobalName = `Vue`,
|
13755 | runtimeModuleName = `vue`,
|
13756 | ssrRuntimeModuleName = "vue/server-renderer",
|
13757 | ssr = false,
|
13758 | isTS = false,
|
13759 | inSSR = false
|
13760 | }) {
|
13761 | const context = {
|
13762 | mode,
|
13763 | prefixIdentifiers,
|
13764 | sourceMap,
|
13765 | filename,
|
13766 | scopeId,
|
13767 | optimizeImports,
|
13768 | runtimeGlobalName,
|
13769 | runtimeModuleName,
|
13770 | ssrRuntimeModuleName,
|
13771 | ssr,
|
13772 | isTS,
|
13773 | inSSR,
|
13774 | source: ast.source,
|
13775 | code: ``,
|
13776 | column: 1,
|
13777 | line: 1,
|
13778 | offset: 0,
|
13779 | indentLevel: 0,
|
13780 | pure: false,
|
13781 | map: void 0,
|
13782 | helper(key) {
|
13783 | return `_${helperNameMap[key]}`;
|
13784 | },
|
13785 | push(code, newlineIndex = -2 , node) {
|
13786 | context.code += code;
|
13787 | },
|
13788 | indent() {
|
13789 | newline(++context.indentLevel);
|
13790 | },
|
13791 | deindent(withoutNewLine = false) {
|
13792 | if (withoutNewLine) {
|
13793 | --context.indentLevel;
|
13794 | } else {
|
13795 | newline(--context.indentLevel);
|
13796 | }
|
13797 | },
|
13798 | newline() {
|
13799 | newline(context.indentLevel);
|
13800 | }
|
13801 | };
|
13802 | function newline(n) {
|
13803 | context.push("\n" + ` `.repeat(n), 0 );
|
13804 | }
|
13805 | return context;
|
13806 | }
|
13807 | function generate(ast, options = {}) {
|
13808 | const context = createCodegenContext(ast, options);
|
13809 | if (options.onContextCreated)
|
13810 | options.onContextCreated(context);
|
13811 | const {
|
13812 | mode,
|
13813 | push,
|
13814 | prefixIdentifiers,
|
13815 | indent,
|
13816 | deindent,
|
13817 | newline,
|
13818 | scopeId,
|
13819 | ssr
|
13820 | } = context;
|
13821 | const helpers = Array.from(ast.helpers);
|
13822 | const hasHelpers = helpers.length > 0;
|
13823 | const useWithBlock = !prefixIdentifiers && mode !== "module";
|
13824 | const preambleContext = context;
|
13825 | {
|
13826 | genFunctionPreamble(ast, preambleContext);
|
13827 | }
|
13828 | const functionName = ssr ? `ssrRender` : `render`;
|
13829 | const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
|
13830 | const signature = args.join(", ");
|
13831 | {
|
13832 | push(`function ${functionName}(${signature}) {`);
|
13833 | }
|
13834 | indent();
|
13835 | if (useWithBlock) {
|
13836 | push(`with (_ctx) {`);
|
13837 | indent();
|
13838 | if (hasHelpers) {
|
13839 | push(
|
13840 | `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
13841 | `,
|
13842 | -1
|
13843 | );
|
13844 | newline();
|
13845 | }
|
13846 | }
|
13847 | if (ast.components.length) {
|
13848 | genAssets(ast.components, "component", context);
|
13849 | if (ast.directives.length || ast.temps > 0) {
|
13850 | newline();
|
13851 | }
|
13852 | }
|
13853 | if (ast.directives.length) {
|
13854 | genAssets(ast.directives, "directive", context);
|
13855 | if (ast.temps > 0) {
|
13856 | newline();
|
13857 | }
|
13858 | }
|
13859 | if (ast.temps > 0) {
|
13860 | push(`let `);
|
13861 | for (let i = 0; i < ast.temps; i++) {
|
13862 | push(`${i > 0 ? `, ` : ``}_temp${i}`);
|
13863 | }
|
13864 | }
|
13865 | if (ast.components.length || ast.directives.length || ast.temps) {
|
13866 | push(`
|
13867 | `, 0 );
|
13868 | newline();
|
13869 | }
|
13870 | if (!ssr) {
|
13871 | push(`return `);
|
13872 | }
|
13873 | if (ast.codegenNode) {
|
13874 | genNode(ast.codegenNode, context);
|
13875 | } else {
|
13876 | push(`null`);
|
13877 | }
|
13878 | if (useWithBlock) {
|
13879 | deindent();
|
13880 | push(`}`);
|
13881 | }
|
13882 | deindent();
|
13883 | push(`}`);
|
13884 | return {
|
13885 | ast,
|
13886 | code: context.code,
|
13887 | preamble: ``,
|
13888 | map: context.map ? context.map.toJSON() : void 0
|
13889 | };
|
13890 | }
|
13891 | function genFunctionPreamble(ast, context) {
|
13892 | const {
|
13893 | ssr,
|
13894 | prefixIdentifiers,
|
13895 | push,
|
13896 | newline,
|
13897 | runtimeModuleName,
|
13898 | runtimeGlobalName,
|
13899 | ssrRuntimeModuleName
|
13900 | } = context;
|
13901 | const VueBinding = runtimeGlobalName;
|
13902 | const helpers = Array.from(ast.helpers);
|
13903 | if (helpers.length > 0) {
|
13904 | {
|
13905 | push(`const _Vue = ${VueBinding}
|
13906 | `, -1 );
|
13907 | if (ast.hoists.length) {
|
13908 | const staticHelpers = [
|
13909 | CREATE_VNODE,
|
13910 | CREATE_ELEMENT_VNODE,
|
13911 | CREATE_COMMENT,
|
13912 | CREATE_TEXT,
|
13913 | CREATE_STATIC
|
13914 | ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
13915 | push(`const { ${staticHelpers} } = _Vue
|
13916 | `, -1 );
|
13917 | }
|
13918 | }
|
13919 | }
|
13920 | genHoists(ast.hoists, context);
|
13921 | newline();
|
13922 | push(`return `);
|
13923 | }
|
13924 | function genAssets(assets, type, { helper, push, newline, isTS }) {
|
13925 | const resolver = helper(
|
13926 | type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
|
13927 | );
|
13928 | for (let i = 0; i < assets.length; i++) {
|
13929 | let id = assets[i];
|
13930 | const maybeSelfReference = id.endsWith("__self");
|
13931 | if (maybeSelfReference) {
|
13932 | id = id.slice(0, -6);
|
13933 | }
|
13934 | push(
|
13935 | `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
|
13936 | );
|
13937 | if (i < assets.length - 1) {
|
13938 | newline();
|
13939 | }
|
13940 | }
|
13941 | }
|
13942 | function genHoists(hoists, context) {
|
13943 | if (!hoists.length) {
|
13944 | return;
|
13945 | }
|
13946 | context.pure = true;
|
13947 | const { push, newline, helper, scopeId, mode } = context;
|
13948 | newline();
|
13949 | for (let i = 0; i < hoists.length; i++) {
|
13950 | const exp = hoists[i];
|
13951 | if (exp) {
|
13952 | push(
|
13953 | `const _hoisted_${i + 1} = ${``}`
|
13954 | );
|
13955 | genNode(exp, context);
|
13956 | newline();
|
13957 | }
|
13958 | }
|
13959 | context.pure = false;
|
13960 | }
|
13961 | function isText(n) {
|
13962 | return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
|
13963 | }
|
13964 | function genNodeListAsArray(nodes, context) {
|
13965 | const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText(n));
|
13966 | context.push(`[`);
|
13967 | multilines && context.indent();
|
13968 | genNodeList(nodes, context, multilines);
|
13969 | multilines && context.deindent();
|
13970 | context.push(`]`);
|
13971 | }
|
13972 | function genNodeList(nodes, context, multilines = false, comma = true) {
|
13973 | const { push, newline } = context;
|
13974 | for (let i = 0; i < nodes.length; i++) {
|
13975 | const node = nodes[i];
|
13976 | if (isString(node)) {
|
13977 | push(node, -3 );
|
13978 | } else if (isArray(node)) {
|
13979 | genNodeListAsArray(node, context);
|
13980 | } else {
|
13981 | genNode(node, context);
|
13982 | }
|
13983 | if (i < nodes.length - 1) {
|
13984 | if (multilines) {
|
13985 | comma && push(",");
|
13986 | newline();
|
13987 | } else {
|
13988 | comma && push(", ");
|
13989 | }
|
13990 | }
|
13991 | }
|
13992 | }
|
13993 | function genNode(node, context) {
|
13994 | if (isString(node)) {
|
13995 | context.push(node, -3 );
|
13996 | return;
|
13997 | }
|
13998 | if (isSymbol(node)) {
|
13999 | context.push(context.helper(node));
|
14000 | return;
|
14001 | }
|
14002 | switch (node.type) {
|
14003 | case 1:
|
14004 | case 9:
|
14005 | case 11:
|
14006 | assert(
|
14007 | node.codegenNode != null,
|
14008 | `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
|
14009 | );
|
14010 | genNode(node.codegenNode, context);
|
14011 | break;
|
14012 | case 2:
|
14013 | genText(node, context);
|
14014 | break;
|
14015 | case 4:
|
14016 | genExpression(node, context);
|
14017 | break;
|
14018 | case 5:
|
14019 | genInterpolation(node, context);
|
14020 | break;
|
14021 | case 12:
|
14022 | genNode(node.codegenNode, context);
|
14023 | break;
|
14024 | case 8:
|
14025 | genCompoundExpression(node, context);
|
14026 | break;
|
14027 | case 3:
|
14028 | genComment(node, context);
|
14029 | break;
|
14030 | case 13:
|
14031 | genVNodeCall(node, context);
|
14032 | break;
|
14033 | case 14:
|
14034 | genCallExpression(node, context);
|
14035 | break;
|
14036 | case 15:
|
14037 | genObjectExpression(node, context);
|
14038 | break;
|
14039 | case 17:
|
14040 | genArrayExpression(node, context);
|
14041 | break;
|
14042 | case 18:
|
14043 | genFunctionExpression(node, context);
|
14044 | break;
|
14045 | case 19:
|
14046 | genConditionalExpression(node, context);
|
14047 | break;
|
14048 | case 20:
|
14049 | genCacheExpression(node, context);
|
14050 | break;
|
14051 | case 21:
|
14052 | genNodeList(node.body, context, true, false);
|
14053 | break;
|
14054 | case 22:
|
14055 | break;
|
14056 | case 23:
|
14057 | break;
|
14058 | case 24:
|
14059 | break;
|
14060 | case 25:
|
14061 | break;
|
14062 | case 26:
|
14063 | break;
|
14064 | case 10:
|
14065 | break;
|
14066 | default:
|
14067 | {
|
14068 | assert(false, `unhandled codegen node type: ${node.type}`);
|
14069 | const exhaustiveCheck = node;
|
14070 | return exhaustiveCheck;
|
14071 | }
|
14072 | }
|
14073 | }
|
14074 | function genText(node, context) {
|
14075 | context.push(JSON.stringify(node.content), -3 , node);
|
14076 | }
|
14077 | function genExpression(node, context) {
|
14078 | const { content, isStatic } = node;
|
14079 | context.push(
|
14080 | isStatic ? JSON.stringify(content) : content,
|
14081 | -3 ,
|
14082 | node
|
14083 | );
|
14084 | }
|
14085 | function genInterpolation(node, context) {
|
14086 | const { push, helper, pure } = context;
|
14087 | if (pure)
|
14088 | push(PURE_ANNOTATION);
|
14089 | push(`${helper(TO_DISPLAY_STRING)}(`);
|
14090 | genNode(node.content, context);
|
14091 | push(`)`);
|
14092 | }
|
14093 | function genCompoundExpression(node, context) {
|
14094 | for (let i = 0; i < node.children.length; i++) {
|
14095 | const child = node.children[i];
|
14096 | if (isString(child)) {
|
14097 | context.push(child, -3 );
|
14098 | } else {
|
14099 | genNode(child, context);
|
14100 | }
|
14101 | }
|
14102 | }
|
14103 | function genExpressionAsPropertyKey(node, context) {
|
14104 | const { push } = context;
|
14105 | if (node.type === 8) {
|
14106 | push(`[`);
|
14107 | genCompoundExpression(node, context);
|
14108 | push(`]`);
|
14109 | } else if (node.isStatic) {
|
14110 | const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
14111 | push(text, -2 , node);
|
14112 | } else {
|
14113 | push(`[${node.content}]`, -3 , node);
|
14114 | }
|
14115 | }
|
14116 | function genComment(node, context) {
|
14117 | const { push, helper, pure } = context;
|
14118 | if (pure) {
|
14119 | push(PURE_ANNOTATION);
|
14120 | }
|
14121 | push(
|
14122 | `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
14123 | -3 ,
|
14124 | node
|
14125 | );
|
14126 | }
|
14127 | function genVNodeCall(node, context) {
|
14128 | const { push, helper, pure } = context;
|
14129 | const {
|
14130 | tag,
|
14131 | props,
|
14132 | children,
|
14133 | patchFlag,
|
14134 | dynamicProps,
|
14135 | directives,
|
14136 | isBlock,
|
14137 | disableTracking,
|
14138 | isComponent
|
14139 | } = node;
|
14140 | if (directives) {
|
14141 | push(helper(WITH_DIRECTIVES) + `(`);
|
14142 | }
|
14143 | if (isBlock) {
|
14144 | push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
|
14145 | }
|
14146 | if (pure) {
|
14147 | push(PURE_ANNOTATION);
|
14148 | }
|
14149 | const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
14150 | push(helper(callHelper) + `(`, -2 , node);
|
14151 | genNodeList(
|
14152 | genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
|
14153 | context
|
14154 | );
|
14155 | push(`)`);
|
14156 | if (isBlock) {
|
14157 | push(`)`);
|
14158 | }
|
14159 | if (directives) {
|
14160 | push(`, `);
|
14161 | genNode(directives, context);
|
14162 | push(`)`);
|
14163 | }
|
14164 | }
|
14165 | function genNullableArgs(args) {
|
14166 | let i = args.length;
|
14167 | while (i--) {
|
14168 | if (args[i] != null)
|
14169 | break;
|
14170 | }
|
14171 | return args.slice(0, i + 1).map((arg) => arg || `null`);
|
14172 | }
|
14173 | function genCallExpression(node, context) {
|
14174 | const { push, helper, pure } = context;
|
14175 | const callee = isString(node.callee) ? node.callee : helper(node.callee);
|
14176 | if (pure) {
|
14177 | push(PURE_ANNOTATION);
|
14178 | }
|
14179 | push(callee + `(`, -2 , node);
|
14180 | genNodeList(node.arguments, context);
|
14181 | push(`)`);
|
14182 | }
|
14183 | function genObjectExpression(node, context) {
|
14184 | const { push, indent, deindent, newline } = context;
|
14185 | const { properties } = node;
|
14186 | if (!properties.length) {
|
14187 | push(`{}`, -2 , node);
|
14188 | return;
|
14189 | }
|
14190 | const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
14191 | push(multilines ? `{` : `{ `);
|
14192 | multilines && indent();
|
14193 | for (let i = 0; i < properties.length; i++) {
|
14194 | const { key, value } = properties[i];
|
14195 | genExpressionAsPropertyKey(key, context);
|
14196 | push(`: `);
|
14197 | genNode(value, context);
|
14198 | if (i < properties.length - 1) {
|
14199 | push(`,`);
|
14200 | newline();
|
14201 | }
|
14202 | }
|
14203 | multilines && deindent();
|
14204 | push(multilines ? `}` : ` }`);
|
14205 | }
|
14206 | function genArrayExpression(node, context) {
|
14207 | genNodeListAsArray(node.elements, context);
|
14208 | }
|
14209 | function genFunctionExpression(node, context) {
|
14210 | const { push, indent, deindent } = context;
|
14211 | const { params, returns, body, newline, isSlot } = node;
|
14212 | if (isSlot) {
|
14213 | push(`_${helperNameMap[WITH_CTX]}(`);
|
14214 | }
|
14215 | push(`(`, -2 , node);
|
14216 | if (isArray(params)) {
|
14217 | genNodeList(params, context);
|
14218 | } else if (params) {
|
14219 | genNode(params, context);
|
14220 | }
|
14221 | push(`) => `);
|
14222 | if (newline || body) {
|
14223 | push(`{`);
|
14224 | indent();
|
14225 | }
|
14226 | if (returns) {
|
14227 | if (newline) {
|
14228 | push(`return `);
|
14229 | }
|
14230 | if (isArray(returns)) {
|
14231 | genNodeListAsArray(returns, context);
|
14232 | } else {
|
14233 | genNode(returns, context);
|
14234 | }
|
14235 | } else if (body) {
|
14236 | genNode(body, context);
|
14237 | }
|
14238 | if (newline || body) {
|
14239 | deindent();
|
14240 | push(`}`);
|
14241 | }
|
14242 | if (isSlot) {
|
14243 | push(`)`);
|
14244 | }
|
14245 | }
|
14246 | function genConditionalExpression(node, context) {
|
14247 | const { test, consequent, alternate, newline: needNewline } = node;
|
14248 | const { push, indent, deindent, newline } = context;
|
14249 | if (test.type === 4) {
|
14250 | const needsParens = !isSimpleIdentifier(test.content);
|
14251 | needsParens && push(`(`);
|
14252 | genExpression(test, context);
|
14253 | needsParens && push(`)`);
|
14254 | } else {
|
14255 | push(`(`);
|
14256 | genNode(test, context);
|
14257 | push(`)`);
|
14258 | }
|
14259 | needNewline && indent();
|
14260 | context.indentLevel++;
|
14261 | needNewline || push(` `);
|
14262 | push(`? `);
|
14263 | genNode(consequent, context);
|
14264 | context.indentLevel--;
|
14265 | needNewline && newline();
|
14266 | needNewline || push(` `);
|
14267 | push(`: `);
|
14268 | const isNested = alternate.type === 19;
|
14269 | if (!isNested) {
|
14270 | context.indentLevel++;
|
14271 | }
|
14272 | genNode(alternate, context);
|
14273 | if (!isNested) {
|
14274 | context.indentLevel--;
|
14275 | }
|
14276 | needNewline && deindent(
|
14277 | true
|
14278 |
|
14279 | );
|
14280 | }
|
14281 | function genCacheExpression(node, context) {
|
14282 | const { push, helper, indent, deindent, newline } = context;
|
14283 | push(`_cache[${node.index}] || (`);
|
14284 | if (node.isVNode) {
|
14285 | indent();
|
14286 | push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
|
14287 | newline();
|
14288 | }
|
14289 | push(`_cache[${node.index}] = `);
|
14290 | genNode(node.value, context);
|
14291 | if (node.isVNode) {
|
14292 | push(`,`);
|
14293 | newline();
|
14294 | push(`${helper(SET_BLOCK_TRACKING)}(1),`);
|
14295 | newline();
|
14296 | push(`_cache[${node.index}]`);
|
14297 | deindent();
|
14298 | }
|
14299 | push(`)`);
|
14300 | }
|
14301 |
|
14302 | const prohibitedKeywordRE = new RegExp(
|
14303 | "\\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"
|
14304 | );
|
14305 | const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
|
14306 | function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
|
14307 | const exp = node.content;
|
14308 | if (!exp.trim()) {
|
14309 | return;
|
14310 | }
|
14311 | try {
|
14312 | new Function(
|
14313 | asRawStatements ? ` ${exp} ` : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`
|
14314 | );
|
14315 | } catch (e) {
|
14316 | let message = e.message;
|
14317 | const keywordMatch = exp.replace(stripStringRE, "").match(prohibitedKeywordRE);
|
14318 | if (keywordMatch) {
|
14319 | message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
|
14320 | }
|
14321 | context.onError(
|
14322 | createCompilerError(
|
14323 | 45,
|
14324 | node.loc,
|
14325 | void 0,
|
14326 | message
|
14327 | )
|
14328 | );
|
14329 | }
|
14330 | }
|
14331 |
|
14332 | const transformExpression = (node, context) => {
|
14333 | if (node.type === 5) {
|
14334 | node.content = processExpression(
|
14335 | node.content,
|
14336 | context
|
14337 | );
|
14338 | } else if (node.type === 1) {
|
14339 | for (let i = 0; i < node.props.length; i++) {
|
14340 | const dir = node.props[i];
|
14341 | if (dir.type === 7 && dir.name !== "for") {
|
14342 | const exp = dir.exp;
|
14343 | const arg = dir.arg;
|
14344 | if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
|
14345 | dir.exp = processExpression(
|
14346 | exp,
|
14347 | context,
|
14348 |
|
14349 | dir.name === "slot"
|
14350 | );
|
14351 | }
|
14352 | if (arg && arg.type === 4 && !arg.isStatic) {
|
14353 | dir.arg = processExpression(arg, context);
|
14354 | }
|
14355 | }
|
14356 | }
|
14357 | }
|
14358 | };
|
14359 | function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
14360 | {
|
14361 | {
|
14362 | validateBrowserExpression(node, context, asParams, asRawStatements);
|
14363 | }
|
14364 | return node;
|
14365 | }
|
14366 | }
|
14367 |
|
14368 | const transformIf = createStructuralDirectiveTransform(
|
14369 | /^(if|else|else-if)$/,
|
14370 | (node, dir, context) => {
|
14371 | return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
14372 | const siblings = context.parent.children;
|
14373 | let i = siblings.indexOf(ifNode);
|
14374 | let key = 0;
|
14375 | while (i-- >= 0) {
|
14376 | const sibling = siblings[i];
|
14377 | if (sibling && sibling.type === 9) {
|
14378 | key += sibling.branches.length;
|
14379 | }
|
14380 | }
|
14381 | return () => {
|
14382 | if (isRoot) {
|
14383 | ifNode.codegenNode = createCodegenNodeForBranch(
|
14384 | branch,
|
14385 | key,
|
14386 | context
|
14387 | );
|
14388 | } else {
|
14389 | const parentCondition = getParentCondition(ifNode.codegenNode);
|
14390 | parentCondition.alternate = createCodegenNodeForBranch(
|
14391 | branch,
|
14392 | key + ifNode.branches.length - 1,
|
14393 | context
|
14394 | );
|
14395 | }
|
14396 | };
|
14397 | });
|
14398 | }
|
14399 | );
|
14400 | function processIf(node, dir, context, processCodegen) {
|
14401 | if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
|
14402 | const loc = dir.exp ? dir.exp.loc : node.loc;
|
14403 | context.onError(
|
14404 | createCompilerError(28, dir.loc)
|
14405 | );
|
14406 | dir.exp = createSimpleExpression(`true`, false, loc);
|
14407 | }
|
14408 | if (dir.exp) {
|
14409 | validateBrowserExpression(dir.exp, context);
|
14410 | }
|
14411 | if (dir.name === "if") {
|
14412 | const branch = createIfBranch(node, dir);
|
14413 | const ifNode = {
|
14414 | type: 9,
|
14415 | loc: node.loc,
|
14416 | branches: [branch]
|
14417 | };
|
14418 | context.replaceNode(ifNode);
|
14419 | if (processCodegen) {
|
14420 | return processCodegen(ifNode, branch, true);
|
14421 | }
|
14422 | } else {
|
14423 | const siblings = context.parent.children;
|
14424 | const comments = [];
|
14425 | let i = siblings.indexOf(node);
|
14426 | while (i-- >= -1) {
|
14427 | const sibling = siblings[i];
|
14428 | if (sibling && sibling.type === 3) {
|
14429 | context.removeNode(sibling);
|
14430 | comments.unshift(sibling);
|
14431 | continue;
|
14432 | }
|
14433 | if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
|
14434 | context.removeNode(sibling);
|
14435 | continue;
|
14436 | }
|
14437 | if (sibling && sibling.type === 9) {
|
14438 | if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
14439 | context.onError(
|
14440 | createCompilerError(30, node.loc)
|
14441 | );
|
14442 | }
|
14443 | context.removeNode();
|
14444 | const branch = createIfBranch(node, dir);
|
14445 | if (comments.length &&
|
14446 | !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
|
14447 | branch.children = [...comments, ...branch.children];
|
14448 | }
|
14449 | {
|
14450 | const key = branch.userKey;
|
14451 | if (key) {
|
14452 | sibling.branches.forEach(({ userKey }) => {
|
14453 | if (isSameKey(userKey, key)) {
|
14454 | context.onError(
|
14455 | createCompilerError(
|
14456 | 29,
|
14457 | branch.userKey.loc
|
14458 | )
|
14459 | );
|
14460 | }
|
14461 | });
|
14462 | }
|
14463 | }
|
14464 | sibling.branches.push(branch);
|
14465 | const onExit = processCodegen && processCodegen(sibling, branch, false);
|
14466 | traverseNode(branch, context);
|
14467 | if (onExit)
|
14468 | onExit();
|
14469 | context.currentNode = null;
|
14470 | } else {
|
14471 | context.onError(
|
14472 | createCompilerError(30, node.loc)
|
14473 | );
|
14474 | }
|
14475 | break;
|
14476 | }
|
14477 | }
|
14478 | }
|
14479 | function createIfBranch(node, dir) {
|
14480 | const isTemplateIf = node.tagType === 3;
|
14481 | return {
|
14482 | type: 10,
|
14483 | loc: node.loc,
|
14484 | condition: dir.name === "else" ? void 0 : dir.exp,
|
14485 | children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
|
14486 | userKey: findProp(node, `key`),
|
14487 | isTemplateIf
|
14488 | };
|
14489 | }
|
14490 | function createCodegenNodeForBranch(branch, keyIndex, context) {
|
14491 | if (branch.condition) {
|
14492 | return createConditionalExpression(
|
14493 | branch.condition,
|
14494 | createChildrenCodegenNode(branch, keyIndex, context),
|
14495 |
|
14496 |
|
14497 | createCallExpression(context.helper(CREATE_COMMENT), [
|
14498 | '"v-if"' ,
|
14499 | "true"
|
14500 | ])
|
14501 | );
|
14502 | } else {
|
14503 | return createChildrenCodegenNode(branch, keyIndex, context);
|
14504 | }
|
14505 | }
|
14506 | function createChildrenCodegenNode(branch, keyIndex, context) {
|
14507 | const { helper } = context;
|
14508 | const keyProperty = createObjectProperty(
|
14509 | `key`,
|
14510 | createSimpleExpression(
|
14511 | `${keyIndex}`,
|
14512 | false,
|
14513 | locStub,
|
14514 | 2
|
14515 | )
|
14516 | );
|
14517 | const { children } = branch;
|
14518 | const firstChild = children[0];
|
14519 | const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
|
14520 | if (needFragmentWrapper) {
|
14521 | if (children.length === 1 && firstChild.type === 11) {
|
14522 | const vnodeCall = firstChild.codegenNode;
|
14523 | injectProp(vnodeCall, keyProperty, context);
|
14524 | return vnodeCall;
|
14525 | } else {
|
14526 | let patchFlag = 64;
|
14527 | let patchFlagText = PatchFlagNames[64];
|
14528 | if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
|
14529 | patchFlag |= 2048;
|
14530 | patchFlagText += `, ${PatchFlagNames[2048]}`;
|
14531 | }
|
14532 | return createVNodeCall(
|
14533 | context,
|
14534 | helper(FRAGMENT),
|
14535 | createObjectExpression([keyProperty]),
|
14536 | children,
|
14537 | patchFlag + (` /* ${patchFlagText} */` ),
|
14538 | void 0,
|
14539 | void 0,
|
14540 | true,
|
14541 | false,
|
14542 | false,
|
14543 | branch.loc
|
14544 | );
|
14545 | }
|
14546 | } else {
|
14547 | const ret = firstChild.codegenNode;
|
14548 | const vnodeCall = getMemoedVNodeCall(ret);
|
14549 | if (vnodeCall.type === 13) {
|
14550 | convertToBlock(vnodeCall, context);
|
14551 | }
|
14552 | injectProp(vnodeCall, keyProperty, context);
|
14553 | return ret;
|
14554 | }
|
14555 | }
|
14556 | function isSameKey(a, b) {
|
14557 | if (!a || a.type !== b.type) {
|
14558 | return false;
|
14559 | }
|
14560 | if (a.type === 6) {
|
14561 | if (a.value.content !== b.value.content) {
|
14562 | return false;
|
14563 | }
|
14564 | } else {
|
14565 | const exp = a.exp;
|
14566 | const branchExp = b.exp;
|
14567 | if (exp.type !== branchExp.type) {
|
14568 | return false;
|
14569 | }
|
14570 | if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
|
14571 | return false;
|
14572 | }
|
14573 | }
|
14574 | return true;
|
14575 | }
|
14576 | function getParentCondition(node) {
|
14577 | while (true) {
|
14578 | if (node.type === 19) {
|
14579 | if (node.alternate.type === 19) {
|
14580 | node = node.alternate;
|
14581 | } else {
|
14582 | return node;
|
14583 | }
|
14584 | } else if (node.type === 20) {
|
14585 | node = node.value;
|
14586 | }
|
14587 | }
|
14588 | }
|
14589 |
|
14590 | const transformFor = createStructuralDirectiveTransform(
|
14591 | "for",
|
14592 | (node, dir, context) => {
|
14593 | const { helper, removeHelper } = context;
|
14594 | return processFor(node, dir, context, (forNode) => {
|
14595 | const renderExp = createCallExpression(helper(RENDER_LIST), [
|
14596 | forNode.source
|
14597 | ]);
|
14598 | const isTemplate = isTemplateNode(node);
|
14599 | const memo = findDir(node, "memo");
|
14600 | const keyProp = findProp(node, `key`);
|
14601 | const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
|
14602 | const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
14603 | const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
14604 | const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
14605 | forNode.codegenNode = createVNodeCall(
|
14606 | context,
|
14607 | helper(FRAGMENT),
|
14608 | void 0,
|
14609 | renderExp,
|
14610 | fragmentFlag + (` /* ${PatchFlagNames[fragmentFlag]} */` ),
|
14611 | void 0,
|
14612 | void 0,
|
14613 | true,
|
14614 | !isStableFragment,
|
14615 | false,
|
14616 | node.loc
|
14617 | );
|
14618 | return () => {
|
14619 | let childBlock;
|
14620 | const { children } = forNode;
|
14621 | if (isTemplate) {
|
14622 | node.children.some((c) => {
|
14623 | if (c.type === 1) {
|
14624 | const key = findProp(c, "key");
|
14625 | if (key) {
|
14626 | context.onError(
|
14627 | createCompilerError(
|
14628 | 33,
|
14629 | key.loc
|
14630 | )
|
14631 | );
|
14632 | return true;
|
14633 | }
|
14634 | }
|
14635 | });
|
14636 | }
|
14637 | const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
|
14638 | const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
|
14639 | if (slotOutlet) {
|
14640 | childBlock = slotOutlet.codegenNode;
|
14641 | if (isTemplate && keyProperty) {
|
14642 | injectProp(childBlock, keyProperty, context);
|
14643 | }
|
14644 | } else if (needFragmentWrapper) {
|
14645 | childBlock = createVNodeCall(
|
14646 | context,
|
14647 | helper(FRAGMENT),
|
14648 | keyProperty ? createObjectExpression([keyProperty]) : void 0,
|
14649 | node.children,
|
14650 | 64 + (` /* ${PatchFlagNames[64]} */` ),
|
14651 | void 0,
|
14652 | void 0,
|
14653 | true,
|
14654 | void 0,
|
14655 | false
|
14656 | );
|
14657 | } else {
|
14658 | childBlock = children[0].codegenNode;
|
14659 | if (isTemplate && keyProperty) {
|
14660 | injectProp(childBlock, keyProperty, context);
|
14661 | }
|
14662 | if (childBlock.isBlock !== !isStableFragment) {
|
14663 | if (childBlock.isBlock) {
|
14664 | removeHelper(OPEN_BLOCK);
|
14665 | removeHelper(
|
14666 | getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
|
14667 | );
|
14668 | } else {
|
14669 | removeHelper(
|
14670 | getVNodeHelper(context.inSSR, childBlock.isComponent)
|
14671 | );
|
14672 | }
|
14673 | }
|
14674 | childBlock.isBlock = !isStableFragment;
|
14675 | if (childBlock.isBlock) {
|
14676 | helper(OPEN_BLOCK);
|
14677 | helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
14678 | } else {
|
14679 | helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
14680 | }
|
14681 | }
|
14682 | if (memo) {
|
14683 | const loop = createFunctionExpression(
|
14684 | createForLoopParams(forNode.parseResult, [
|
14685 | createSimpleExpression(`_cached`)
|
14686 | ])
|
14687 | );
|
14688 | loop.body = createBlockStatement([
|
14689 | createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
|
14690 | createCompoundExpression([
|
14691 | `if (_cached`,
|
14692 | ...keyExp ? [` && _cached.key === `, keyExp] : [],
|
14693 | ` && ${context.helperString(
|
14694 | IS_MEMO_SAME
|
14695 | )}(_cached, _memo)) return _cached`
|
14696 | ]),
|
14697 | createCompoundExpression([`const _item = `, childBlock]),
|
14698 | createSimpleExpression(`_item.memo = _memo`),
|
14699 | createSimpleExpression(`return _item`)
|
14700 | ]);
|
14701 | renderExp.arguments.push(
|
14702 | loop,
|
14703 | createSimpleExpression(`_cache`),
|
14704 | createSimpleExpression(String(context.cached++))
|
14705 | );
|
14706 | } else {
|
14707 | renderExp.arguments.push(
|
14708 | createFunctionExpression(
|
14709 | createForLoopParams(forNode.parseResult),
|
14710 | childBlock,
|
14711 | true
|
14712 | )
|
14713 | );
|
14714 | }
|
14715 | };
|
14716 | });
|
14717 | }
|
14718 | );
|
14719 | function processFor(node, dir, context, processCodegen) {
|
14720 | if (!dir.exp) {
|
14721 | context.onError(
|
14722 | createCompilerError(31, dir.loc)
|
14723 | );
|
14724 | return;
|
14725 | }
|
14726 | const parseResult = dir.forParseResult;
|
14727 | if (!parseResult) {
|
14728 | context.onError(
|
14729 | createCompilerError(32, dir.loc)
|
14730 | );
|
14731 | return;
|
14732 | }
|
14733 | finalizeForParseResult(parseResult, context);
|
14734 | const { addIdentifiers, removeIdentifiers, scopes } = context;
|
14735 | const { source, value, key, index } = parseResult;
|
14736 | const forNode = {
|
14737 | type: 11,
|
14738 | loc: dir.loc,
|
14739 | source,
|
14740 | valueAlias: value,
|
14741 | keyAlias: key,
|
14742 | objectIndexAlias: index,
|
14743 | parseResult,
|
14744 | children: isTemplateNode(node) ? node.children : [node]
|
14745 | };
|
14746 | context.replaceNode(forNode);
|
14747 | scopes.vFor++;
|
14748 | const onExit = processCodegen && processCodegen(forNode);
|
14749 | return () => {
|
14750 | scopes.vFor--;
|
14751 | if (onExit)
|
14752 | onExit();
|
14753 | };
|
14754 | }
|
14755 | function finalizeForParseResult(result, context) {
|
14756 | if (result.finalized)
|
14757 | return;
|
14758 | {
|
14759 | validateBrowserExpression(result.source, context);
|
14760 | if (result.key) {
|
14761 | validateBrowserExpression(
|
14762 | result.key,
|
14763 | context,
|
14764 | true
|
14765 | );
|
14766 | }
|
14767 | if (result.index) {
|
14768 | validateBrowserExpression(
|
14769 | result.index,
|
14770 | context,
|
14771 | true
|
14772 | );
|
14773 | }
|
14774 | if (result.value) {
|
14775 | validateBrowserExpression(
|
14776 | result.value,
|
14777 | context,
|
14778 | true
|
14779 | );
|
14780 | }
|
14781 | }
|
14782 | result.finalized = true;
|
14783 | }
|
14784 | function createForLoopParams({ value, key, index }, memoArgs = []) {
|
14785 | return createParamsList([value, key, index, ...memoArgs]);
|
14786 | }
|
14787 | function createParamsList(args) {
|
14788 | let i = args.length;
|
14789 | while (i--) {
|
14790 | if (args[i])
|
14791 | break;
|
14792 | }
|
14793 | return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
|
14794 | }
|
14795 |
|
14796 | const defaultFallback = createSimpleExpression(`undefined`, false);
|
14797 | const trackSlotScopes = (node, context) => {
|
14798 | if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
|
14799 | const vSlot = findDir(node, "slot");
|
14800 | if (vSlot) {
|
14801 | vSlot.exp;
|
14802 | context.scopes.vSlot++;
|
14803 | return () => {
|
14804 | context.scopes.vSlot--;
|
14805 | };
|
14806 | }
|
14807 | }
|
14808 | };
|
14809 | const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
|
14810 | props,
|
14811 | children,
|
14812 | false,
|
14813 | true,
|
14814 | children.length ? children[0].loc : loc
|
14815 | );
|
14816 | function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
14817 | context.helper(WITH_CTX);
|
14818 | const { children, loc } = node;
|
14819 | const slotsProperties = [];
|
14820 | const dynamicSlots = [];
|
14821 | let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
|
14822 | const onComponentSlot = findDir(node, "slot", true);
|
14823 | if (onComponentSlot) {
|
14824 | const { arg, exp } = onComponentSlot;
|
14825 | if (arg && !isStaticExp(arg)) {
|
14826 | hasDynamicSlots = true;
|
14827 | }
|
14828 | slotsProperties.push(
|
14829 | createObjectProperty(
|
14830 | arg || createSimpleExpression("default", true),
|
14831 | buildSlotFn(exp, void 0, children, loc)
|
14832 | )
|
14833 | );
|
14834 | }
|
14835 | let hasTemplateSlots = false;
|
14836 | let hasNamedDefaultSlot = false;
|
14837 | const implicitDefaultChildren = [];
|
14838 | const seenSlotNames = new Set();
|
14839 | let conditionalBranchIndex = 0;
|
14840 | for (let i = 0; i < children.length; i++) {
|
14841 | const slotElement = children[i];
|
14842 | let slotDir;
|
14843 | if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
|
14844 | if (slotElement.type !== 3) {
|
14845 | implicitDefaultChildren.push(slotElement);
|
14846 | }
|
14847 | continue;
|
14848 | }
|
14849 | if (onComponentSlot) {
|
14850 | context.onError(
|
14851 | createCompilerError(37, slotDir.loc)
|
14852 | );
|
14853 | break;
|
14854 | }
|
14855 | hasTemplateSlots = true;
|
14856 | const { children: slotChildren, loc: slotLoc } = slotElement;
|
14857 | const {
|
14858 | arg: slotName = createSimpleExpression(`default`, true),
|
14859 | exp: slotProps,
|
14860 | loc: dirLoc
|
14861 | } = slotDir;
|
14862 | let staticSlotName;
|
14863 | if (isStaticExp(slotName)) {
|
14864 | staticSlotName = slotName ? slotName.content : `default`;
|
14865 | } else {
|
14866 | hasDynamicSlots = true;
|
14867 | }
|
14868 | const vFor = findDir(slotElement, "for");
|
14869 | const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
|
14870 | let vIf;
|
14871 | let vElse;
|
14872 | if (vIf = findDir(slotElement, "if")) {
|
14873 | hasDynamicSlots = true;
|
14874 | dynamicSlots.push(
|
14875 | createConditionalExpression(
|
14876 | vIf.exp,
|
14877 | buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
|
14878 | defaultFallback
|
14879 | )
|
14880 | );
|
14881 | } else if (vElse = findDir(
|
14882 | slotElement,
|
14883 | /^else(-if)?$/,
|
14884 | true
|
14885 |
|
14886 | )) {
|
14887 | let j = i;
|
14888 | let prev;
|
14889 | while (j--) {
|
14890 | prev = children[j];
|
14891 | if (prev.type !== 3) {
|
14892 | break;
|
14893 | }
|
14894 | }
|
14895 | if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
|
14896 | children.splice(i, 1);
|
14897 | i--;
|
14898 | let conditional = dynamicSlots[dynamicSlots.length - 1];
|
14899 | while (conditional.alternate.type === 19) {
|
14900 | conditional = conditional.alternate;
|
14901 | }
|
14902 | conditional.alternate = vElse.exp ? createConditionalExpression(
|
14903 | vElse.exp,
|
14904 | buildDynamicSlot(
|
14905 | slotName,
|
14906 | slotFunction,
|
14907 | conditionalBranchIndex++
|
14908 | ),
|
14909 | defaultFallback
|
14910 | ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
|
14911 | } else {
|
14912 | context.onError(
|
14913 | createCompilerError(30, vElse.loc)
|
14914 | );
|
14915 | }
|
14916 | } else if (vFor) {
|
14917 | hasDynamicSlots = true;
|
14918 | const parseResult = vFor.forParseResult;
|
14919 | if (parseResult) {
|
14920 | finalizeForParseResult(parseResult, context);
|
14921 | dynamicSlots.push(
|
14922 | createCallExpression(context.helper(RENDER_LIST), [
|
14923 | parseResult.source,
|
14924 | createFunctionExpression(
|
14925 | createForLoopParams(parseResult),
|
14926 | buildDynamicSlot(slotName, slotFunction),
|
14927 | true
|
14928 | )
|
14929 | ])
|
14930 | );
|
14931 | } else {
|
14932 | context.onError(
|
14933 | createCompilerError(
|
14934 | 32,
|
14935 | vFor.loc
|
14936 | )
|
14937 | );
|
14938 | }
|
14939 | } else {
|
14940 | if (staticSlotName) {
|
14941 | if (seenSlotNames.has(staticSlotName)) {
|
14942 | context.onError(
|
14943 | createCompilerError(
|
14944 | 38,
|
14945 | dirLoc
|
14946 | )
|
14947 | );
|
14948 | continue;
|
14949 | }
|
14950 | seenSlotNames.add(staticSlotName);
|
14951 | if (staticSlotName === "default") {
|
14952 | hasNamedDefaultSlot = true;
|
14953 | }
|
14954 | }
|
14955 | slotsProperties.push(createObjectProperty(slotName, slotFunction));
|
14956 | }
|
14957 | }
|
14958 | if (!onComponentSlot) {
|
14959 | const buildDefaultSlotProperty = (props, children2) => {
|
14960 | const fn = buildSlotFn(props, void 0, children2, loc);
|
14961 | return createObjectProperty(`default`, fn);
|
14962 | };
|
14963 | if (!hasTemplateSlots) {
|
14964 | slotsProperties.push(buildDefaultSlotProperty(void 0, children));
|
14965 | } else if (implicitDefaultChildren.length &&
|
14966 |
|
14967 |
|
14968 | implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
|
14969 | if (hasNamedDefaultSlot) {
|
14970 | context.onError(
|
14971 | createCompilerError(
|
14972 | 39,
|
14973 | implicitDefaultChildren[0].loc
|
14974 | )
|
14975 | );
|
14976 | } else {
|
14977 | slotsProperties.push(
|
14978 | buildDefaultSlotProperty(void 0, implicitDefaultChildren)
|
14979 | );
|
14980 | }
|
14981 | }
|
14982 | }
|
14983 | const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
|
14984 | let slots = createObjectExpression(
|
14985 | slotsProperties.concat(
|
14986 | createObjectProperty(
|
14987 | `_`,
|
14988 |
|
14989 |
|
14990 | createSimpleExpression(
|
14991 | slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
|
14992 | false
|
14993 | )
|
14994 | )
|
14995 | ),
|
14996 | loc
|
14997 | );
|
14998 | if (dynamicSlots.length) {
|
14999 | slots = createCallExpression(context.helper(CREATE_SLOTS), [
|
15000 | slots,
|
15001 | createArrayExpression(dynamicSlots)
|
15002 | ]);
|
15003 | }
|
15004 | return {
|
15005 | slots,
|
15006 | hasDynamicSlots
|
15007 | };
|
15008 | }
|
15009 | function buildDynamicSlot(name, fn, index) {
|
15010 | const props = [
|
15011 | createObjectProperty(`name`, name),
|
15012 | createObjectProperty(`fn`, fn)
|
15013 | ];
|
15014 | if (index != null) {
|
15015 | props.push(
|
15016 | createObjectProperty(`key`, createSimpleExpression(String(index), true))
|
15017 | );
|
15018 | }
|
15019 | return createObjectExpression(props);
|
15020 | }
|
15021 | function hasForwardedSlots(children) {
|
15022 | for (let i = 0; i < children.length; i++) {
|
15023 | const child = children[i];
|
15024 | switch (child.type) {
|
15025 | case 1:
|
15026 | if (child.tagType === 2 || hasForwardedSlots(child.children)) {
|
15027 | return true;
|
15028 | }
|
15029 | break;
|
15030 | case 9:
|
15031 | if (hasForwardedSlots(child.branches))
|
15032 | return true;
|
15033 | break;
|
15034 | case 10:
|
15035 | case 11:
|
15036 | if (hasForwardedSlots(child.children))
|
15037 | return true;
|
15038 | break;
|
15039 | }
|
15040 | }
|
15041 | return false;
|
15042 | }
|
15043 | function isNonWhitespaceContent(node) {
|
15044 | if (node.type !== 2 && node.type !== 12)
|
15045 | return true;
|
15046 | return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
|
15047 | }
|
15048 |
|
15049 | const directiveImportMap = new WeakMap();
|
15050 | const transformElement = (node, context) => {
|
15051 | return function postTransformElement() {
|
15052 | node = context.currentNode;
|
15053 | if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
|
15054 | return;
|
15055 | }
|
15056 | const { tag, props } = node;
|
15057 | const isComponent = node.tagType === 1;
|
15058 | let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
|
15059 | const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
|
15060 | let vnodeProps;
|
15061 | let vnodeChildren;
|
15062 | let vnodePatchFlag;
|
15063 | let patchFlag = 0;
|
15064 | let vnodeDynamicProps;
|
15065 | let dynamicPropNames;
|
15066 | let vnodeDirectives;
|
15067 | let shouldUseBlock = (
|
15068 |
|
15069 | isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent &&
|
15070 |
|
15071 |
|
15072 |
|
15073 | (tag === "svg" || tag === "foreignObject")
|
15074 | );
|
15075 | if (props.length > 0) {
|
15076 | const propsBuildResult = buildProps(
|
15077 | node,
|
15078 | context,
|
15079 | void 0,
|
15080 | isComponent,
|
15081 | isDynamicComponent
|
15082 | );
|
15083 | vnodeProps = propsBuildResult.props;
|
15084 | patchFlag = propsBuildResult.patchFlag;
|
15085 | dynamicPropNames = propsBuildResult.dynamicPropNames;
|
15086 | const directives = propsBuildResult.directives;
|
15087 | vnodeDirectives = directives && directives.length ? createArrayExpression(
|
15088 | directives.map((dir) => buildDirectiveArgs(dir, context))
|
15089 | ) : void 0;
|
15090 | if (propsBuildResult.shouldUseBlock) {
|
15091 | shouldUseBlock = true;
|
15092 | }
|
15093 | }
|
15094 | if (node.children.length > 0) {
|
15095 | if (vnodeTag === KEEP_ALIVE) {
|
15096 | shouldUseBlock = true;
|
15097 | patchFlag |= 1024;
|
15098 | if (node.children.length > 1) {
|
15099 | context.onError(
|
15100 | createCompilerError(46, {
|
15101 | start: node.children[0].loc.start,
|
15102 | end: node.children[node.children.length - 1].loc.end,
|
15103 | source: ""
|
15104 | })
|
15105 | );
|
15106 | }
|
15107 | }
|
15108 | const shouldBuildAsSlots = isComponent &&
|
15109 | vnodeTag !== TELEPORT &&
|
15110 | vnodeTag !== KEEP_ALIVE;
|
15111 | if (shouldBuildAsSlots) {
|
15112 | const { slots, hasDynamicSlots } = buildSlots(node, context);
|
15113 | vnodeChildren = slots;
|
15114 | if (hasDynamicSlots) {
|
15115 | patchFlag |= 1024;
|
15116 | }
|
15117 | } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
|
15118 | const child = node.children[0];
|
15119 | const type = child.type;
|
15120 | const hasDynamicTextChild = type === 5 || type === 8;
|
15121 | if (hasDynamicTextChild && getConstantType(child, context) === 0) {
|
15122 | patchFlag |= 1;
|
15123 | }
|
15124 | if (hasDynamicTextChild || type === 2) {
|
15125 | vnodeChildren = child;
|
15126 | } else {
|
15127 | vnodeChildren = node.children;
|
15128 | }
|
15129 | } else {
|
15130 | vnodeChildren = node.children;
|
15131 | }
|
15132 | }
|
15133 | if (patchFlag !== 0) {
|
15134 | {
|
15135 | if (patchFlag < 0) {
|
15136 | vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
|
15137 | } else {
|
15138 | const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
|
15139 | vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
|
15140 | }
|
15141 | }
|
15142 | if (dynamicPropNames && dynamicPropNames.length) {
|
15143 | vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
|
15144 | }
|
15145 | }
|
15146 | node.codegenNode = createVNodeCall(
|
15147 | context,
|
15148 | vnodeTag,
|
15149 | vnodeProps,
|
15150 | vnodeChildren,
|
15151 | vnodePatchFlag,
|
15152 | vnodeDynamicProps,
|
15153 | vnodeDirectives,
|
15154 | !!shouldUseBlock,
|
15155 | false,
|
15156 | isComponent,
|
15157 | node.loc
|
15158 | );
|
15159 | };
|
15160 | };
|
15161 | function resolveComponentType(node, context, ssr = false) {
|
15162 | let { tag } = node;
|
15163 | const isExplicitDynamic = isComponentTag(tag);
|
15164 | const isProp = findProp(
|
15165 | node,
|
15166 | "is",
|
15167 | false,
|
15168 | true
|
15169 |
|
15170 | );
|
15171 | if (isProp) {
|
15172 | if (isExplicitDynamic || false) {
|
15173 | let exp;
|
15174 | if (isProp.type === 6) {
|
15175 | exp = isProp.value && createSimpleExpression(isProp.value.content, true);
|
15176 | } else {
|
15177 | exp = isProp.exp;
|
15178 | if (!exp) {
|
15179 | exp = createSimpleExpression(`is`, false, isProp.loc);
|
15180 | }
|
15181 | }
|
15182 | if (exp) {
|
15183 | return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
15184 | exp
|
15185 | ]);
|
15186 | }
|
15187 | } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
|
15188 | tag = isProp.value.content.slice(4);
|
15189 | }
|
15190 | }
|
15191 | const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
15192 | if (builtIn) {
|
15193 | if (!ssr)
|
15194 | context.helper(builtIn);
|
15195 | return builtIn;
|
15196 | }
|
15197 | context.helper(RESOLVE_COMPONENT);
|
15198 | context.components.add(tag);
|
15199 | return toValidAssetId(tag, `component`);
|
15200 | }
|
15201 | function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
15202 | const { tag, loc: elementLoc, children } = node;
|
15203 | let properties = [];
|
15204 | const mergeArgs = [];
|
15205 | const runtimeDirectives = [];
|
15206 | const hasChildren = children.length > 0;
|
15207 | let shouldUseBlock = false;
|
15208 | let patchFlag = 0;
|
15209 | let hasRef = false;
|
15210 | let hasClassBinding = false;
|
15211 | let hasStyleBinding = false;
|
15212 | let hasHydrationEventBinding = false;
|
15213 | let hasDynamicKeys = false;
|
15214 | let hasVnodeHook = false;
|
15215 | const dynamicPropNames = [];
|
15216 | const pushMergeArg = (arg) => {
|
15217 | if (properties.length) {
|
15218 | mergeArgs.push(
|
15219 | createObjectExpression(dedupeProperties(properties), elementLoc)
|
15220 | );
|
15221 | properties = [];
|
15222 | }
|
15223 | if (arg)
|
15224 | mergeArgs.push(arg);
|
15225 | };
|
15226 | const pushRefVForMarker = () => {
|
15227 | if (context.scopes.vFor > 0) {
|
15228 | properties.push(
|
15229 | createObjectProperty(
|
15230 | createSimpleExpression("ref_for", true),
|
15231 | createSimpleExpression("true")
|
15232 | )
|
15233 | );
|
15234 | }
|
15235 | };
|
15236 | const analyzePatchFlag = ({ key, value }) => {
|
15237 | if (isStaticExp(key)) {
|
15238 | const name = key.content;
|
15239 | const isEventHandler = isOn(name);
|
15240 | if (isEventHandler && (!isComponent || isDynamicComponent) &&
|
15241 |
|
15242 | name.toLowerCase() !== "onclick" &&
|
15243 | name !== "onUpdate:modelValue" &&
|
15244 | !isReservedProp(name)) {
|
15245 | hasHydrationEventBinding = true;
|
15246 | }
|
15247 | if (isEventHandler && isReservedProp(name)) {
|
15248 | hasVnodeHook = true;
|
15249 | }
|
15250 | if (isEventHandler && value.type === 14) {
|
15251 | value = value.arguments[0];
|
15252 | }
|
15253 | if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
|
15254 | return;
|
15255 | }
|
15256 | if (name === "ref") {
|
15257 | hasRef = true;
|
15258 | } else if (name === "class") {
|
15259 | hasClassBinding = true;
|
15260 | } else if (name === "style") {
|
15261 | hasStyleBinding = true;
|
15262 | } else if (name !== "key" && !dynamicPropNames.includes(name)) {
|
15263 | dynamicPropNames.push(name);
|
15264 | }
|
15265 | if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
|
15266 | dynamicPropNames.push(name);
|
15267 | }
|
15268 | } else {
|
15269 | hasDynamicKeys = true;
|
15270 | }
|
15271 | };
|
15272 | for (let i = 0; i < props.length; i++) {
|
15273 | const prop = props[i];
|
15274 | if (prop.type === 6) {
|
15275 | const { loc, name, nameLoc, value } = prop;
|
15276 | let isStatic = true;
|
15277 | if (name === "ref") {
|
15278 | hasRef = true;
|
15279 | pushRefVForMarker();
|
15280 | }
|
15281 | if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
|
15282 | continue;
|
15283 | }
|
15284 | properties.push(
|
15285 | createObjectProperty(
|
15286 | createSimpleExpression(name, true, nameLoc),
|
15287 | createSimpleExpression(
|
15288 | value ? value.content : "",
|
15289 | isStatic,
|
15290 | value ? value.loc : loc
|
15291 | )
|
15292 | )
|
15293 | );
|
15294 | } else {
|
15295 | const { name, arg, exp, loc, modifiers } = prop;
|
15296 | const isVBind = name === "bind";
|
15297 | const isVOn = name === "on";
|
15298 | if (name === "slot") {
|
15299 | if (!isComponent) {
|
15300 | context.onError(
|
15301 | createCompilerError(40, loc)
|
15302 | );
|
15303 | }
|
15304 | continue;
|
15305 | }
|
15306 | if (name === "once" || name === "memo") {
|
15307 | continue;
|
15308 | }
|
15309 | if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
|
15310 | continue;
|
15311 | }
|
15312 | if (isVOn && ssr) {
|
15313 | continue;
|
15314 | }
|
15315 | if (
|
15316 |
|
15317 | isVBind && isStaticArgOf(arg, "key") ||
|
15318 |
|
15319 | isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
|
15320 | ) {
|
15321 | shouldUseBlock = true;
|
15322 | }
|
15323 | if (isVBind && isStaticArgOf(arg, "ref")) {
|
15324 | pushRefVForMarker();
|
15325 | }
|
15326 | if (!arg && (isVBind || isVOn)) {
|
15327 | hasDynamicKeys = true;
|
15328 | if (exp) {
|
15329 | if (isVBind) {
|
15330 | pushRefVForMarker();
|
15331 | pushMergeArg();
|
15332 | mergeArgs.push(exp);
|
15333 | } else {
|
15334 | pushMergeArg({
|
15335 | type: 14,
|
15336 | loc,
|
15337 | callee: context.helper(TO_HANDLERS),
|
15338 | arguments: isComponent ? [exp] : [exp, `true`]
|
15339 | });
|
15340 | }
|
15341 | } else {
|
15342 | context.onError(
|
15343 | createCompilerError(
|
15344 | isVBind ? 34 : 35,
|
15345 | loc
|
15346 | )
|
15347 | );
|
15348 | }
|
15349 | continue;
|
15350 | }
|
15351 | if (isVBind && modifiers.includes("prop")) {
|
15352 | patchFlag |= 32;
|
15353 | }
|
15354 | const directiveTransform = context.directiveTransforms[name];
|
15355 | if (directiveTransform) {
|
15356 | const { props: props2, needRuntime } = directiveTransform(prop, node, context);
|
15357 | !ssr && props2.forEach(analyzePatchFlag);
|
15358 | if (isVOn && arg && !isStaticExp(arg)) {
|
15359 | pushMergeArg(createObjectExpression(props2, elementLoc));
|
15360 | } else {
|
15361 | properties.push(...props2);
|
15362 | }
|
15363 | if (needRuntime) {
|
15364 | runtimeDirectives.push(prop);
|
15365 | if (isSymbol(needRuntime)) {
|
15366 | directiveImportMap.set(prop, needRuntime);
|
15367 | }
|
15368 | }
|
15369 | } else if (!isBuiltInDirective(name)) {
|
15370 | runtimeDirectives.push(prop);
|
15371 | if (hasChildren) {
|
15372 | shouldUseBlock = true;
|
15373 | }
|
15374 | }
|
15375 | }
|
15376 | }
|
15377 | let propsExpression = void 0;
|
15378 | if (mergeArgs.length) {
|
15379 | pushMergeArg();
|
15380 | if (mergeArgs.length > 1) {
|
15381 | propsExpression = createCallExpression(
|
15382 | context.helper(MERGE_PROPS),
|
15383 | mergeArgs,
|
15384 | elementLoc
|
15385 | );
|
15386 | } else {
|
15387 | propsExpression = mergeArgs[0];
|
15388 | }
|
15389 | } else if (properties.length) {
|
15390 | propsExpression = createObjectExpression(
|
15391 | dedupeProperties(properties),
|
15392 | elementLoc
|
15393 | );
|
15394 | }
|
15395 | if (hasDynamicKeys) {
|
15396 | patchFlag |= 16;
|
15397 | } else {
|
15398 | if (hasClassBinding && !isComponent) {
|
15399 | patchFlag |= 2;
|
15400 | }
|
15401 | if (hasStyleBinding && !isComponent) {
|
15402 | patchFlag |= 4;
|
15403 | }
|
15404 | if (dynamicPropNames.length) {
|
15405 | patchFlag |= 8;
|
15406 | }
|
15407 | if (hasHydrationEventBinding) {
|
15408 | patchFlag |= 32;
|
15409 | }
|
15410 | }
|
15411 | if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
|
15412 | patchFlag |= 512;
|
15413 | }
|
15414 | if (!context.inSSR && propsExpression) {
|
15415 | switch (propsExpression.type) {
|
15416 | case 15:
|
15417 | let classKeyIndex = -1;
|
15418 | let styleKeyIndex = -1;
|
15419 | let hasDynamicKey = false;
|
15420 | for (let i = 0; i < propsExpression.properties.length; i++) {
|
15421 | const key = propsExpression.properties[i].key;
|
15422 | if (isStaticExp(key)) {
|
15423 | if (key.content === "class") {
|
15424 | classKeyIndex = i;
|
15425 | } else if (key.content === "style") {
|
15426 | styleKeyIndex = i;
|
15427 | }
|
15428 | } else if (!key.isHandlerKey) {
|
15429 | hasDynamicKey = true;
|
15430 | }
|
15431 | }
|
15432 | const classProp = propsExpression.properties[classKeyIndex];
|
15433 | const styleProp = propsExpression.properties[styleKeyIndex];
|
15434 | if (!hasDynamicKey) {
|
15435 | if (classProp && !isStaticExp(classProp.value)) {
|
15436 | classProp.value = createCallExpression(
|
15437 | context.helper(NORMALIZE_CLASS),
|
15438 | [classProp.value]
|
15439 | );
|
15440 | }
|
15441 | if (styleProp &&
|
15442 |
|
15443 | (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` ||
|
15444 |
|
15445 | styleProp.value.type === 17)) {
|
15446 | styleProp.value = createCallExpression(
|
15447 | context.helper(NORMALIZE_STYLE),
|
15448 | [styleProp.value]
|
15449 | );
|
15450 | }
|
15451 | } else {
|
15452 | propsExpression = createCallExpression(
|
15453 | context.helper(NORMALIZE_PROPS),
|
15454 | [propsExpression]
|
15455 | );
|
15456 | }
|
15457 | break;
|
15458 | case 14:
|
15459 | break;
|
15460 | default:
|
15461 | propsExpression = createCallExpression(
|
15462 | context.helper(NORMALIZE_PROPS),
|
15463 | [
|
15464 | createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
|
15465 | propsExpression
|
15466 | ])
|
15467 | ]
|
15468 | );
|
15469 | break;
|
15470 | }
|
15471 | }
|
15472 | return {
|
15473 | props: propsExpression,
|
15474 | directives: runtimeDirectives,
|
15475 | patchFlag,
|
15476 | dynamicPropNames,
|
15477 | shouldUseBlock
|
15478 | };
|
15479 | }
|
15480 | function dedupeProperties(properties) {
|
15481 | const knownProps = new Map();
|
15482 | const deduped = [];
|
15483 | for (let i = 0; i < properties.length; i++) {
|
15484 | const prop = properties[i];
|
15485 | if (prop.key.type === 8 || !prop.key.isStatic) {
|
15486 | deduped.push(prop);
|
15487 | continue;
|
15488 | }
|
15489 | const name = prop.key.content;
|
15490 | const existing = knownProps.get(name);
|
15491 | if (existing) {
|
15492 | if (name === "style" || name === "class" || isOn(name)) {
|
15493 | mergeAsArray(existing, prop);
|
15494 | }
|
15495 | } else {
|
15496 | knownProps.set(name, prop);
|
15497 | deduped.push(prop);
|
15498 | }
|
15499 | }
|
15500 | return deduped;
|
15501 | }
|
15502 | function mergeAsArray(existing, incoming) {
|
15503 | if (existing.value.type === 17) {
|
15504 | existing.value.elements.push(incoming.value);
|
15505 | } else {
|
15506 | existing.value = createArrayExpression(
|
15507 | [existing.value, incoming.value],
|
15508 | existing.loc
|
15509 | );
|
15510 | }
|
15511 | }
|
15512 | function buildDirectiveArgs(dir, context) {
|
15513 | const dirArgs = [];
|
15514 | const runtime = directiveImportMap.get(dir);
|
15515 | if (runtime) {
|
15516 | dirArgs.push(context.helperString(runtime));
|
15517 | } else {
|
15518 | {
|
15519 | context.helper(RESOLVE_DIRECTIVE);
|
15520 | context.directives.add(dir.name);
|
15521 | dirArgs.push(toValidAssetId(dir.name, `directive`));
|
15522 | }
|
15523 | }
|
15524 | const { loc } = dir;
|
15525 | if (dir.exp)
|
15526 | dirArgs.push(dir.exp);
|
15527 | if (dir.arg) {
|
15528 | if (!dir.exp) {
|
15529 | dirArgs.push(`void 0`);
|
15530 | }
|
15531 | dirArgs.push(dir.arg);
|
15532 | }
|
15533 | if (Object.keys(dir.modifiers).length) {
|
15534 | if (!dir.arg) {
|
15535 | if (!dir.exp) {
|
15536 | dirArgs.push(`void 0`);
|
15537 | }
|
15538 | dirArgs.push(`void 0`);
|
15539 | }
|
15540 | const trueExpression = createSimpleExpression(`true`, false, loc);
|
15541 | dirArgs.push(
|
15542 | createObjectExpression(
|
15543 | dir.modifiers.map(
|
15544 | (modifier) => createObjectProperty(modifier, trueExpression)
|
15545 | ),
|
15546 | loc
|
15547 | )
|
15548 | );
|
15549 | }
|
15550 | return createArrayExpression(dirArgs, dir.loc);
|
15551 | }
|
15552 | function stringifyDynamicPropNames(props) {
|
15553 | let propsNamesString = `[`;
|
15554 | for (let i = 0, l = props.length; i < l; i++) {
|
15555 | propsNamesString += JSON.stringify(props[i]);
|
15556 | if (i < l - 1)
|
15557 | propsNamesString += ", ";
|
15558 | }
|
15559 | return propsNamesString + `]`;
|
15560 | }
|
15561 | function isComponentTag(tag) {
|
15562 | return tag === "component" || tag === "Component";
|
15563 | }
|
15564 |
|
15565 | const transformSlotOutlet = (node, context) => {
|
15566 | if (isSlotOutlet(node)) {
|
15567 | const { children, loc } = node;
|
15568 | const { slotName, slotProps } = processSlotOutlet(node, context);
|
15569 | const slotArgs = [
|
15570 | context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
|
15571 | slotName,
|
15572 | "{}",
|
15573 | "undefined",
|
15574 | "true"
|
15575 | ];
|
15576 | let expectedLen = 2;
|
15577 | if (slotProps) {
|
15578 | slotArgs[2] = slotProps;
|
15579 | expectedLen = 3;
|
15580 | }
|
15581 | if (children.length) {
|
15582 | slotArgs[3] = createFunctionExpression([], children, false, false, loc);
|
15583 | expectedLen = 4;
|
15584 | }
|
15585 | if (context.scopeId && !context.slotted) {
|
15586 | expectedLen = 5;
|
15587 | }
|
15588 | slotArgs.splice(expectedLen);
|
15589 | node.codegenNode = createCallExpression(
|
15590 | context.helper(RENDER_SLOT),
|
15591 | slotArgs,
|
15592 | loc
|
15593 | );
|
15594 | }
|
15595 | };
|
15596 | function processSlotOutlet(node, context) {
|
15597 | let slotName = `"default"`;
|
15598 | let slotProps = void 0;
|
15599 | const nonNameProps = [];
|
15600 | for (let i = 0; i < node.props.length; i++) {
|
15601 | const p = node.props[i];
|
15602 | if (p.type === 6) {
|
15603 | if (p.value) {
|
15604 | if (p.name === "name") {
|
15605 | slotName = JSON.stringify(p.value.content);
|
15606 | } else {
|
15607 | p.name = camelize(p.name);
|
15608 | nonNameProps.push(p);
|
15609 | }
|
15610 | }
|
15611 | } else {
|
15612 | if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
|
15613 | if (p.exp) {
|
15614 | slotName = p.exp;
|
15615 | } else if (p.arg && p.arg.type === 4) {
|
15616 | const name = camelize(p.arg.content);
|
15617 | slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
|
15618 | }
|
15619 | } else {
|
15620 | if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
|
15621 | p.arg.content = camelize(p.arg.content);
|
15622 | }
|
15623 | nonNameProps.push(p);
|
15624 | }
|
15625 | }
|
15626 | }
|
15627 | if (nonNameProps.length > 0) {
|
15628 | const { props, directives } = buildProps(
|
15629 | node,
|
15630 | context,
|
15631 | nonNameProps,
|
15632 | false,
|
15633 | false
|
15634 | );
|
15635 | slotProps = props;
|
15636 | if (directives.length) {
|
15637 | context.onError(
|
15638 | createCompilerError(
|
15639 | 36,
|
15640 | directives[0].loc
|
15641 | )
|
15642 | );
|
15643 | }
|
15644 | }
|
15645 | return {
|
15646 | slotName,
|
15647 | slotProps
|
15648 | };
|
15649 | }
|
15650 |
|
15651 | const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
15652 | const transformOn$1 = (dir, node, context, augmentor) => {
|
15653 | const { loc, modifiers, arg } = dir;
|
15654 | if (!dir.exp && !modifiers.length) {
|
15655 | context.onError(createCompilerError(35, loc));
|
15656 | }
|
15657 | let eventName;
|
15658 | if (arg.type === 4) {
|
15659 | if (arg.isStatic) {
|
15660 | let rawName = arg.content;
|
15661 | if (rawName.startsWith("vnode")) {
|
15662 | context.onError(createCompilerError(51, arg.loc));
|
15663 | }
|
15664 | if (rawName.startsWith("vue:")) {
|
15665 | rawName = `vnode-${rawName.slice(4)}`;
|
15666 | }
|
15667 | const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
|
15668 |
|
15669 |
|
15670 | toHandlerKey(camelize(rawName))
|
15671 | ) : (
|
15672 |
|
15673 |
|
15674 | `on:${rawName}`
|
15675 | );
|
15676 | eventName = createSimpleExpression(eventString, true, arg.loc);
|
15677 | } else {
|
15678 | eventName = createCompoundExpression([
|
15679 | `${context.helperString(TO_HANDLER_KEY)}(`,
|
15680 | arg,
|
15681 | `)`
|
15682 | ]);
|
15683 | }
|
15684 | } else {
|
15685 | eventName = arg;
|
15686 | eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
|
15687 | eventName.children.push(`)`);
|
15688 | }
|
15689 | let exp = dir.exp;
|
15690 | if (exp && !exp.content.trim()) {
|
15691 | exp = void 0;
|
15692 | }
|
15693 | let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
|
15694 | if (exp) {
|
15695 | const isMemberExp = isMemberExpression(exp.content);
|
15696 | const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
|
15697 | const hasMultipleStatements = exp.content.includes(`;`);
|
15698 | {
|
15699 | validateBrowserExpression(
|
15700 | exp,
|
15701 | context,
|
15702 | false,
|
15703 | hasMultipleStatements
|
15704 | );
|
15705 | }
|
15706 | if (isInlineStatement || shouldCache && isMemberExp) {
|
15707 | exp = createCompoundExpression([
|
15708 | `${isInlineStatement ? `$event` : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
|
15709 | exp,
|
15710 | hasMultipleStatements ? `}` : `)`
|
15711 | ]);
|
15712 | }
|
15713 | }
|
15714 | let ret = {
|
15715 | props: [
|
15716 | createObjectProperty(
|
15717 | eventName,
|
15718 | exp || createSimpleExpression(`() => {}`, false, loc)
|
15719 | )
|
15720 | ]
|
15721 | };
|
15722 | if (augmentor) {
|
15723 | ret = augmentor(ret);
|
15724 | }
|
15725 | if (shouldCache) {
|
15726 | ret.props[0].value = context.cache(ret.props[0].value);
|
15727 | }
|
15728 | ret.props.forEach((p) => p.key.isHandlerKey = true);
|
15729 | return ret;
|
15730 | };
|
15731 |
|
15732 | const transformBind = (dir, _node, context) => {
|
15733 | const { modifiers, loc } = dir;
|
15734 | const arg = dir.arg;
|
15735 | let { exp } = dir;
|
15736 | if (exp && exp.type === 4 && !exp.content.trim()) {
|
15737 | {
|
15738 | exp = void 0;
|
15739 | }
|
15740 | }
|
15741 | if (!exp) {
|
15742 | if (arg.type !== 4 || !arg.isStatic) {
|
15743 | context.onError(
|
15744 | createCompilerError(
|
15745 | 52,
|
15746 | arg.loc
|
15747 | )
|
15748 | );
|
15749 | return {
|
15750 | props: [
|
15751 | createObjectProperty(arg, createSimpleExpression("", true, loc))
|
15752 | ]
|
15753 | };
|
15754 | }
|
15755 | const propName = camelize(arg.content);
|
15756 | exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
|
15757 | }
|
15758 | if (arg.type !== 4) {
|
15759 | arg.children.unshift(`(`);
|
15760 | arg.children.push(`) || ""`);
|
15761 | } else if (!arg.isStatic) {
|
15762 | arg.content = `${arg.content} || ""`;
|
15763 | }
|
15764 | if (modifiers.includes("camel")) {
|
15765 | if (arg.type === 4) {
|
15766 | if (arg.isStatic) {
|
15767 | arg.content = camelize(arg.content);
|
15768 | } else {
|
15769 | arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
15770 | }
|
15771 | } else {
|
15772 | arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
15773 | arg.children.push(`)`);
|
15774 | }
|
15775 | }
|
15776 | if (!context.inSSR) {
|
15777 | if (modifiers.includes("prop")) {
|
15778 | injectPrefix(arg, ".");
|
15779 | }
|
15780 | if (modifiers.includes("attr")) {
|
15781 | injectPrefix(arg, "^");
|
15782 | }
|
15783 | }
|
15784 | return {
|
15785 | props: [createObjectProperty(arg, exp)]
|
15786 | };
|
15787 | };
|
15788 | const injectPrefix = (arg, prefix) => {
|
15789 | if (arg.type === 4) {
|
15790 | if (arg.isStatic) {
|
15791 | arg.content = prefix + arg.content;
|
15792 | } else {
|
15793 | arg.content = `\`${prefix}\${${arg.content}}\``;
|
15794 | }
|
15795 | } else {
|
15796 | arg.children.unshift(`'${prefix}' + (`);
|
15797 | arg.children.push(`)`);
|
15798 | }
|
15799 | };
|
15800 |
|
15801 | const transformText = (node, context) => {
|
15802 | if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
15803 | return () => {
|
15804 | const children = node.children;
|
15805 | let currentContainer = void 0;
|
15806 | let hasText = false;
|
15807 | for (let i = 0; i < children.length; i++) {
|
15808 | const child = children[i];
|
15809 | if (isText$1(child)) {
|
15810 | hasText = true;
|
15811 | for (let j = i + 1; j < children.length; j++) {
|
15812 | const next = children[j];
|
15813 | if (isText$1(next)) {
|
15814 | if (!currentContainer) {
|
15815 | currentContainer = children[i] = createCompoundExpression(
|
15816 | [child],
|
15817 | child.loc
|
15818 | );
|
15819 | }
|
15820 | currentContainer.children.push(` + `, next);
|
15821 | children.splice(j, 1);
|
15822 | j--;
|
15823 | } else {
|
15824 | currentContainer = void 0;
|
15825 | break;
|
15826 | }
|
15827 | }
|
15828 | }
|
15829 | }
|
15830 | if (!hasText ||
|
15831 |
|
15832 |
|
15833 |
|
15834 | children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 &&
|
15835 |
|
15836 |
|
15837 |
|
15838 |
|
15839 | !node.props.find(
|
15840 | (p) => p.type === 7 && !context.directiveTransforms[p.name]
|
15841 | ) &&
|
15842 |
|
15843 |
|
15844 | true)) {
|
15845 | return;
|
15846 | }
|
15847 | for (let i = 0; i < children.length; i++) {
|
15848 | const child = children[i];
|
15849 | if (isText$1(child) || child.type === 8) {
|
15850 | const callArgs = [];
|
15851 | if (child.type !== 2 || child.content !== " ") {
|
15852 | callArgs.push(child);
|
15853 | }
|
15854 | if (!context.ssr && getConstantType(child, context) === 0) {
|
15855 | callArgs.push(
|
15856 | 1 + (` /* ${PatchFlagNames[1]} */` )
|
15857 | );
|
15858 | }
|
15859 | children[i] = {
|
15860 | type: 12,
|
15861 | content: child,
|
15862 | loc: child.loc,
|
15863 | codegenNode: createCallExpression(
|
15864 | context.helper(CREATE_TEXT),
|
15865 | callArgs
|
15866 | )
|
15867 | };
|
15868 | }
|
15869 | }
|
15870 | };
|
15871 | }
|
15872 | };
|
15873 |
|
15874 | const seen$1 = new WeakSet();
|
15875 | const transformOnce = (node, context) => {
|
15876 | if (node.type === 1 && findDir(node, "once", true)) {
|
15877 | if (seen$1.has(node) || context.inVOnce || context.inSSR) {
|
15878 | return;
|
15879 | }
|
15880 | seen$1.add(node);
|
15881 | context.inVOnce = true;
|
15882 | context.helper(SET_BLOCK_TRACKING);
|
15883 | return () => {
|
15884 | context.inVOnce = false;
|
15885 | const cur = context.currentNode;
|
15886 | if (cur.codegenNode) {
|
15887 | cur.codegenNode = context.cache(
|
15888 | cur.codegenNode,
|
15889 | true
|
15890 |
|
15891 | );
|
15892 | }
|
15893 | };
|
15894 | }
|
15895 | };
|
15896 |
|
15897 | const transformModel$1 = (dir, node, context) => {
|
15898 | const { exp, arg } = dir;
|
15899 | if (!exp) {
|
15900 | context.onError(
|
15901 | createCompilerError(41, dir.loc)
|
15902 | );
|
15903 | return createTransformProps();
|
15904 | }
|
15905 | const rawExp = exp.loc.source;
|
15906 | const expString = exp.type === 4 ? exp.content : rawExp;
|
15907 | const bindingType = context.bindingMetadata[rawExp];
|
15908 | if (bindingType === "props" || bindingType === "props-aliased") {
|
15909 | context.onError(createCompilerError(44, exp.loc));
|
15910 | return createTransformProps();
|
15911 | }
|
15912 | const maybeRef = false;
|
15913 | if (!expString.trim() || !isMemberExpression(expString) && !maybeRef) {
|
15914 | context.onError(
|
15915 | createCompilerError(42, exp.loc)
|
15916 | );
|
15917 | return createTransformProps();
|
15918 | }
|
15919 | const propName = arg ? arg : createSimpleExpression("modelValue", true);
|
15920 | const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
|
15921 | let assignmentExp;
|
15922 | const eventArg = context.isTS ? `($event: any)` : `$event`;
|
15923 | {
|
15924 | assignmentExp = createCompoundExpression([
|
15925 | `${eventArg} => ((`,
|
15926 | exp,
|
15927 | `) = $event)`
|
15928 | ]);
|
15929 | }
|
15930 | const props = [
|
15931 |
|
15932 | createObjectProperty(propName, dir.exp),
|
15933 |
|
15934 | createObjectProperty(eventName, assignmentExp)
|
15935 | ];
|
15936 | if (dir.modifiers.length && node.tagType === 1) {
|
15937 | const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
|
15938 | const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
|
15939 | props.push(
|
15940 | createObjectProperty(
|
15941 | modifiersKey,
|
15942 | createSimpleExpression(
|
15943 | `{ ${modifiers} }`,
|
15944 | false,
|
15945 | dir.loc,
|
15946 | 2
|
15947 | )
|
15948 | )
|
15949 | );
|
15950 | }
|
15951 | return createTransformProps(props);
|
15952 | };
|
15953 | function createTransformProps(props = []) {
|
15954 | return { props };
|
15955 | }
|
15956 |
|
15957 | const seen = new WeakSet();
|
15958 | const transformMemo = (node, context) => {
|
15959 | if (node.type === 1) {
|
15960 | const dir = findDir(node, "memo");
|
15961 | if (!dir || seen.has(node)) {
|
15962 | return;
|
15963 | }
|
15964 | seen.add(node);
|
15965 | return () => {
|
15966 | const codegenNode = node.codegenNode || context.currentNode.codegenNode;
|
15967 | if (codegenNode && codegenNode.type === 13) {
|
15968 | if (node.tagType !== 1) {
|
15969 | convertToBlock(codegenNode, context);
|
15970 | }
|
15971 | node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
15972 | dir.exp,
|
15973 | createFunctionExpression(void 0, codegenNode),
|
15974 | `_cache`,
|
15975 | String(context.cached++)
|
15976 | ]);
|
15977 | }
|
15978 | };
|
15979 | }
|
15980 | };
|
15981 |
|
15982 | function getBaseTransformPreset(prefixIdentifiers) {
|
15983 | return [
|
15984 | [
|
15985 | transformOnce,
|
15986 | transformIf,
|
15987 | transformMemo,
|
15988 | transformFor,
|
15989 | ...[],
|
15990 | ...[transformExpression] ,
|
15991 | transformSlotOutlet,
|
15992 | transformElement,
|
15993 | trackSlotScopes,
|
15994 | transformText
|
15995 | ],
|
15996 | {
|
15997 | on: transformOn$1,
|
15998 | bind: transformBind,
|
15999 | model: transformModel$1
|
16000 | }
|
16001 | ];
|
16002 | }
|
16003 | function baseCompile(source, options = {}) {
|
16004 | const onError = options.onError || defaultOnError;
|
16005 | const isModuleMode = options.mode === "module";
|
16006 | {
|
16007 | if (options.prefixIdentifiers === true) {
|
16008 | onError(createCompilerError(47));
|
16009 | } else if (isModuleMode) {
|
16010 | onError(createCompilerError(48));
|
16011 | }
|
16012 | }
|
16013 | const prefixIdentifiers = false;
|
16014 | if (options.cacheHandlers) {
|
16015 | onError(createCompilerError(49));
|
16016 | }
|
16017 | if (options.scopeId && !isModuleMode) {
|
16018 | onError(createCompilerError(50));
|
16019 | }
|
16020 | const resolvedOptions = extend({}, options, {
|
16021 | prefixIdentifiers
|
16022 | });
|
16023 | const ast = isString(source) ? baseParse(source, resolvedOptions) : source;
|
16024 | const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
16025 | transform(
|
16026 | ast,
|
16027 | extend({}, resolvedOptions, {
|
16028 | nodeTransforms: [
|
16029 | ...nodeTransforms,
|
16030 | ...options.nodeTransforms || []
|
16031 |
|
16032 | ],
|
16033 | directiveTransforms: extend(
|
16034 | {},
|
16035 | directiveTransforms,
|
16036 | options.directiveTransforms || {}
|
16037 |
|
16038 | )
|
16039 | })
|
16040 | );
|
16041 | return generate(ast, resolvedOptions);
|
16042 | }
|
16043 |
|
16044 | const noopDirectiveTransform = () => ({ props: [] });
|
16045 |
|
16046 | const V_MODEL_RADIO = Symbol(`vModelRadio` );
|
16047 | const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
|
16048 | const V_MODEL_TEXT = Symbol(`vModelText` );
|
16049 | const V_MODEL_SELECT = Symbol(`vModelSelect` );
|
16050 | const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
|
16051 | const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
|
16052 | const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
|
16053 | const V_SHOW = Symbol(`vShow` );
|
16054 | const TRANSITION = Symbol(`Transition` );
|
16055 | const TRANSITION_GROUP = Symbol(`TransitionGroup` );
|
16056 | registerRuntimeHelpers({
|
16057 | [V_MODEL_RADIO]: `vModelRadio`,
|
16058 | [V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
16059 | [V_MODEL_TEXT]: `vModelText`,
|
16060 | [V_MODEL_SELECT]: `vModelSelect`,
|
16061 | [V_MODEL_DYNAMIC]: `vModelDynamic`,
|
16062 | [V_ON_WITH_MODIFIERS]: `withModifiers`,
|
16063 | [V_ON_WITH_KEYS]: `withKeys`,
|
16064 | [V_SHOW]: `vShow`,
|
16065 | [TRANSITION]: `Transition`,
|
16066 | [TRANSITION_GROUP]: `TransitionGroup`
|
16067 | });
|
16068 |
|
16069 | let decoder;
|
16070 | function decodeHtmlBrowser(raw, asAttr = false) {
|
16071 | if (!decoder) {
|
16072 | decoder = document.createElement("div");
|
16073 | }
|
16074 | if (asAttr) {
|
16075 | decoder.innerHTML = `<div foo="${raw.replace(/"/g, """)}">`;
|
16076 | return decoder.children[0].getAttribute("foo");
|
16077 | } else {
|
16078 | decoder.innerHTML = raw;
|
16079 | return decoder.textContent;
|
16080 | }
|
16081 | }
|
16082 |
|
16083 | const parserOptions = {
|
16084 | parseMode: "html",
|
16085 | isVoidTag,
|
16086 | isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
16087 | isPreTag: (tag) => tag === "pre",
|
16088 | decodeEntities: decodeHtmlBrowser ,
|
16089 | isBuiltInComponent: (tag) => {
|
16090 | if (tag === "Transition" || tag === "transition") {
|
16091 | return TRANSITION;
|
16092 | } else if (tag === "TransitionGroup" || tag === "transition-group") {
|
16093 | return TRANSITION_GROUP;
|
16094 | }
|
16095 | },
|
16096 |
|
16097 | getNamespace(tag, parent, rootNamespace) {
|
16098 | let ns = parent ? parent.ns : rootNamespace;
|
16099 | if (parent && ns === 2) {
|
16100 | if (parent.tag === "annotation-xml") {
|
16101 | if (tag === "svg") {
|
16102 | return 1;
|
16103 | }
|
16104 | if (parent.props.some(
|
16105 | (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
|
16106 | )) {
|
16107 | ns = 0;
|
16108 | }
|
16109 | } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
|
16110 | ns = 0;
|
16111 | }
|
16112 | } else if (parent && ns === 1) {
|
16113 | if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
|
16114 | ns = 0;
|
16115 | }
|
16116 | }
|
16117 | if (ns === 0) {
|
16118 | if (tag === "svg") {
|
16119 | return 1;
|
16120 | }
|
16121 | if (tag === "math") {
|
16122 | return 2;
|
16123 | }
|
16124 | }
|
16125 | return ns;
|
16126 | }
|
16127 | };
|
16128 |
|
16129 | const transformStyle = (node) => {
|
16130 | if (node.type === 1) {
|
16131 | node.props.forEach((p, i) => {
|
16132 | if (p.type === 6 && p.name === "style" && p.value) {
|
16133 | node.props[i] = {
|
16134 | type: 7,
|
16135 | name: `bind`,
|
16136 | arg: createSimpleExpression(`style`, true, p.loc),
|
16137 | exp: parseInlineCSS(p.value.content, p.loc),
|
16138 | modifiers: [],
|
16139 | loc: p.loc
|
16140 | };
|
16141 | }
|
16142 | });
|
16143 | }
|
16144 | };
|
16145 | const parseInlineCSS = (cssText, loc) => {
|
16146 | const normalized = parseStringStyle(cssText);
|
16147 | return createSimpleExpression(
|
16148 | JSON.stringify(normalized),
|
16149 | false,
|
16150 | loc,
|
16151 | 3
|
16152 | );
|
16153 | };
|
16154 |
|
16155 | function createDOMCompilerError(code, loc) {
|
16156 | return createCompilerError(
|
16157 | code,
|
16158 | loc,
|
16159 | DOMErrorMessages
|
16160 | );
|
16161 | }
|
16162 | const DOMErrorMessages = {
|
16163 | [53]: `v-html is missing expression.`,
|
16164 | [54]: `v-html will override element children.`,
|
16165 | [55]: `v-text is missing expression.`,
|
16166 | [56]: `v-text will override element children.`,
|
16167 | [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
16168 | [58]: `v-model argument is not supported on plain elements.`,
|
16169 | [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
16170 | [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
16171 | [61]: `v-show is missing expression.`,
|
16172 | [62]: `<Transition> expects exactly one child element or component.`,
|
16173 | [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
16174 | };
|
16175 |
|
16176 | const transformVHtml = (dir, node, context) => {
|
16177 | const { exp, loc } = dir;
|
16178 | if (!exp) {
|
16179 | context.onError(
|
16180 | createDOMCompilerError(53, loc)
|
16181 | );
|
16182 | }
|
16183 | if (node.children.length) {
|
16184 | context.onError(
|
16185 | createDOMCompilerError(54, loc)
|
16186 | );
|
16187 | node.children.length = 0;
|
16188 | }
|
16189 | return {
|
16190 | props: [
|
16191 | createObjectProperty(
|
16192 | createSimpleExpression(`innerHTML`, true, loc),
|
16193 | exp || createSimpleExpression("", true)
|
16194 | )
|
16195 | ]
|
16196 | };
|
16197 | };
|
16198 |
|
16199 | const transformVText = (dir, node, context) => {
|
16200 | const { exp, loc } = dir;
|
16201 | if (!exp) {
|
16202 | context.onError(
|
16203 | createDOMCompilerError(55, loc)
|
16204 | );
|
16205 | }
|
16206 | if (node.children.length) {
|
16207 | context.onError(
|
16208 | createDOMCompilerError(56, loc)
|
16209 | );
|
16210 | node.children.length = 0;
|
16211 | }
|
16212 | return {
|
16213 | props: [
|
16214 | createObjectProperty(
|
16215 | createSimpleExpression(`textContent`, true),
|
16216 | exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
|
16217 | context.helperString(TO_DISPLAY_STRING),
|
16218 | [exp],
|
16219 | loc
|
16220 | ) : createSimpleExpression("", true)
|
16221 | )
|
16222 | ]
|
16223 | };
|
16224 | };
|
16225 |
|
16226 | const transformModel = (dir, node, context) => {
|
16227 | const baseResult = transformModel$1(dir, node, context);
|
16228 | if (!baseResult.props.length || node.tagType === 1) {
|
16229 | return baseResult;
|
16230 | }
|
16231 | if (dir.arg) {
|
16232 | context.onError(
|
16233 | createDOMCompilerError(
|
16234 | 58,
|
16235 | dir.arg.loc
|
16236 | )
|
16237 | );
|
16238 | }
|
16239 | function checkDuplicatedValue() {
|
16240 | const value = findDir(node, "bind");
|
16241 | if (value && isStaticArgOf(value.arg, "value")) {
|
16242 | context.onError(
|
16243 | createDOMCompilerError(
|
16244 | 60,
|
16245 | value.loc
|
16246 | )
|
16247 | );
|
16248 | }
|
16249 | }
|
16250 | const { tag } = node;
|
16251 | const isCustomElement = context.isCustomElement(tag);
|
16252 | if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
|
16253 | let directiveToUse = V_MODEL_TEXT;
|
16254 | let isInvalidType = false;
|
16255 | if (tag === "input" || isCustomElement) {
|
16256 | const type = findProp(node, `type`);
|
16257 | if (type) {
|
16258 | if (type.type === 7) {
|
16259 | directiveToUse = V_MODEL_DYNAMIC;
|
16260 | } else if (type.value) {
|
16261 | switch (type.value.content) {
|
16262 | case "radio":
|
16263 | directiveToUse = V_MODEL_RADIO;
|
16264 | break;
|
16265 | case "checkbox":
|
16266 | directiveToUse = V_MODEL_CHECKBOX;
|
16267 | break;
|
16268 | case "file":
|
16269 | isInvalidType = true;
|
16270 | context.onError(
|
16271 | createDOMCompilerError(
|
16272 | 59,
|
16273 | dir.loc
|
16274 | )
|
16275 | );
|
16276 | break;
|
16277 | default:
|
16278 | checkDuplicatedValue();
|
16279 | break;
|
16280 | }
|
16281 | }
|
16282 | } else if (hasDynamicKeyVBind(node)) {
|
16283 | directiveToUse = V_MODEL_DYNAMIC;
|
16284 | } else {
|
16285 | checkDuplicatedValue();
|
16286 | }
|
16287 | } else if (tag === "select") {
|
16288 | directiveToUse = V_MODEL_SELECT;
|
16289 | } else {
|
16290 | checkDuplicatedValue();
|
16291 | }
|
16292 | if (!isInvalidType) {
|
16293 | baseResult.needRuntime = context.helper(directiveToUse);
|
16294 | }
|
16295 | } else {
|
16296 | context.onError(
|
16297 | createDOMCompilerError(
|
16298 | 57,
|
16299 | dir.loc
|
16300 | )
|
16301 | );
|
16302 | }
|
16303 | baseResult.props = baseResult.props.filter(
|
16304 | (p) => !(p.key.type === 4 && p.key.content === "modelValue")
|
16305 | );
|
16306 | return baseResult;
|
16307 | };
|
16308 |
|
16309 | const isEventOptionModifier = makeMap(`passive,once,capture`);
|
16310 | const isNonKeyModifier = makeMap(
|
16311 |
|
16312 | `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
|
16313 | );
|
16314 | const maybeKeyModifier = makeMap("left,right");
|
16315 | const isKeyboardEvent = makeMap(
|
16316 | `onkeyup,onkeydown,onkeypress`,
|
16317 | true
|
16318 | );
|
16319 | const resolveModifiers = (key, modifiers, context, loc) => {
|
16320 | const keyModifiers = [];
|
16321 | const nonKeyModifiers = [];
|
16322 | const eventOptionModifiers = [];
|
16323 | for (let i = 0; i < modifiers.length; i++) {
|
16324 | const modifier = modifiers[i];
|
16325 | if (isEventOptionModifier(modifier)) {
|
16326 | eventOptionModifiers.push(modifier);
|
16327 | } else {
|
16328 | if (maybeKeyModifier(modifier)) {
|
16329 | if (isStaticExp(key)) {
|
16330 | if (isKeyboardEvent(key.content)) {
|
16331 | keyModifiers.push(modifier);
|
16332 | } else {
|
16333 | nonKeyModifiers.push(modifier);
|
16334 | }
|
16335 | } else {
|
16336 | keyModifiers.push(modifier);
|
16337 | nonKeyModifiers.push(modifier);
|
16338 | }
|
16339 | } else {
|
16340 | if (isNonKeyModifier(modifier)) {
|
16341 | nonKeyModifiers.push(modifier);
|
16342 | } else {
|
16343 | keyModifiers.push(modifier);
|
16344 | }
|
16345 | }
|
16346 | }
|
16347 | }
|
16348 | return {
|
16349 | keyModifiers,
|
16350 | nonKeyModifiers,
|
16351 | eventOptionModifiers
|
16352 | };
|
16353 | };
|
16354 | const transformClick = (key, event) => {
|
16355 | const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
|
16356 | return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
|
16357 | `(`,
|
16358 | key,
|
16359 | `) === "onClick" ? "${event}" : (`,
|
16360 | key,
|
16361 | `)`
|
16362 | ]) : key;
|
16363 | };
|
16364 | const transformOn = (dir, node, context) => {
|
16365 | return transformOn$1(dir, node, context, (baseResult) => {
|
16366 | const { modifiers } = dir;
|
16367 | if (!modifiers.length)
|
16368 | return baseResult;
|
16369 | let { key, value: handlerExp } = baseResult.props[0];
|
16370 | const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
16371 | if (nonKeyModifiers.includes("right")) {
|
16372 | key = transformClick(key, `onContextmenu`);
|
16373 | }
|
16374 | if (nonKeyModifiers.includes("middle")) {
|
16375 | key = transformClick(key, `onMouseup`);
|
16376 | }
|
16377 | if (nonKeyModifiers.length) {
|
16378 | handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
|
16379 | handlerExp,
|
16380 | JSON.stringify(nonKeyModifiers)
|
16381 | ]);
|
16382 | }
|
16383 | if (keyModifiers.length &&
|
16384 | (!isStaticExp(key) || isKeyboardEvent(key.content))) {
|
16385 | handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
16386 | handlerExp,
|
16387 | JSON.stringify(keyModifiers)
|
16388 | ]);
|
16389 | }
|
16390 | if (eventOptionModifiers.length) {
|
16391 | const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
|
16392 | key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
16393 | }
|
16394 | return {
|
16395 | props: [createObjectProperty(key, handlerExp)]
|
16396 | };
|
16397 | });
|
16398 | };
|
16399 |
|
16400 | const transformShow = (dir, node, context) => {
|
16401 | const { exp, loc } = dir;
|
16402 | if (!exp) {
|
16403 | context.onError(
|
16404 | createDOMCompilerError(61, loc)
|
16405 | );
|
16406 | }
|
16407 | return {
|
16408 | props: [],
|
16409 | needRuntime: context.helper(V_SHOW)
|
16410 | };
|
16411 | };
|
16412 |
|
16413 | const transformTransition = (node, context) => {
|
16414 | if (node.type === 1 && node.tagType === 1) {
|
16415 | const component = context.isBuiltInComponent(node.tag);
|
16416 | if (component === TRANSITION) {
|
16417 | return () => {
|
16418 | if (!node.children.length) {
|
16419 | return;
|
16420 | }
|
16421 | if (hasMultipleChildren(node)) {
|
16422 | context.onError(
|
16423 | createDOMCompilerError(
|
16424 | 62,
|
16425 | {
|
16426 | start: node.children[0].loc.start,
|
16427 | end: node.children[node.children.length - 1].loc.end,
|
16428 | source: ""
|
16429 | }
|
16430 | )
|
16431 | );
|
16432 | }
|
16433 | const child = node.children[0];
|
16434 | if (child.type === 1) {
|
16435 | for (const p of child.props) {
|
16436 | if (p.type === 7 && p.name === "show") {
|
16437 | node.props.push({
|
16438 | type: 6,
|
16439 | name: "persisted",
|
16440 | nameLoc: node.loc,
|
16441 | value: void 0,
|
16442 | loc: node.loc
|
16443 | });
|
16444 | }
|
16445 | }
|
16446 | }
|
16447 | };
|
16448 | }
|
16449 | }
|
16450 | };
|
16451 | function hasMultipleChildren(node) {
|
16452 | const children = node.children = node.children.filter(
|
16453 | (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
|
16454 | );
|
16455 | const child = children[0];
|
16456 | return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
|
16457 | }
|
16458 |
|
16459 | const ignoreSideEffectTags = (node, context) => {
|
16460 | if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
16461 | context.onError(
|
16462 | createDOMCompilerError(
|
16463 | 63,
|
16464 | node.loc
|
16465 | )
|
16466 | );
|
16467 | context.removeNode();
|
16468 | }
|
16469 | };
|
16470 |
|
16471 | const DOMNodeTransforms = [
|
16472 | transformStyle,
|
16473 | ...[transformTransition]
|
16474 | ];
|
16475 | const DOMDirectiveTransforms = {
|
16476 | cloak: noopDirectiveTransform,
|
16477 | html: transformVHtml,
|
16478 | text: transformVText,
|
16479 | model: transformModel,
|
16480 |
|
16481 | on: transformOn,
|
16482 |
|
16483 | show: transformShow
|
16484 | };
|
16485 | function compile(src, options = {}) {
|
16486 | return baseCompile(
|
16487 | src,
|
16488 | extend({}, parserOptions, options, {
|
16489 | nodeTransforms: [
|
16490 |
|
16491 |
|
16492 |
|
16493 | ignoreSideEffectTags,
|
16494 | ...DOMNodeTransforms,
|
16495 | ...options.nodeTransforms || []
|
16496 | ],
|
16497 | directiveTransforms: extend(
|
16498 | {},
|
16499 | DOMDirectiveTransforms,
|
16500 | options.directiveTransforms || {}
|
16501 | ),
|
16502 | transformHoist: null
|
16503 | })
|
16504 | );
|
16505 | }
|
16506 |
|
16507 | {
|
16508 | initDev();
|
16509 | }
|
16510 | const compileCache = new WeakMap();
|
16511 | function getCache(options) {
|
16512 | let c = compileCache.get(options != null ? options : EMPTY_OBJ);
|
16513 | if (!c) {
|
16514 | c = Object.create(null);
|
16515 | compileCache.set(options != null ? options : EMPTY_OBJ, c);
|
16516 | }
|
16517 | return c;
|
16518 | }
|
16519 | function compileToFunction(template, options) {
|
16520 | if (!isString(template)) {
|
16521 | if (template.nodeType) {
|
16522 | template = template.innerHTML;
|
16523 | } else {
|
16524 | warn(`invalid template option: `, template);
|
16525 | return NOOP;
|
16526 | }
|
16527 | }
|
16528 | const key = template;
|
16529 | const cache = getCache(options);
|
16530 | const cached = cache[key];
|
16531 | if (cached) {
|
16532 | return cached;
|
16533 | }
|
16534 | if (template[0] === "#") {
|
16535 | const el = document.querySelector(template);
|
16536 | if (!el) {
|
16537 | warn(`Template element not found or is empty: ${template}`);
|
16538 | }
|
16539 | template = el ? el.innerHTML : ``;
|
16540 | }
|
16541 | const opts = extend(
|
16542 | {
|
16543 | hoistStatic: true,
|
16544 | onError: onError ,
|
16545 | onWarn: (e) => onError(e, true)
|
16546 | },
|
16547 | options
|
16548 | );
|
16549 | if (!opts.isCustomElement && typeof customElements !== "undefined") {
|
16550 | opts.isCustomElement = (tag) => !!customElements.get(tag);
|
16551 | }
|
16552 | const { code } = compile(template, opts);
|
16553 | function onError(err, asWarning = false) {
|
16554 | const message = asWarning ? err.message : `Template compilation error: ${err.message}`;
|
16555 | const codeFrame = err.loc && generateCodeFrame(
|
16556 | template,
|
16557 | err.loc.start.offset,
|
16558 | err.loc.end.offset
|
16559 | );
|
16560 | warn(codeFrame ? `${message}
|
16561 | ${codeFrame}` : message);
|
16562 | }
|
16563 | const render = new Function(code)() ;
|
16564 | render._rc = true;
|
16565 | return cache[key] = render;
|
16566 | }
|
16567 | registerRuntimeCompiler(compileToFunction);
|
16568 |
|
16569 | exports.BaseTransition = BaseTransition;
|
16570 | exports.BaseTransitionPropsValidators = BaseTransitionPropsValidators;
|
16571 | exports.Comment = Comment;
|
16572 | exports.DeprecationTypes = DeprecationTypes;
|
16573 | exports.EffectScope = EffectScope;
|
16574 | exports.ErrorCodes = ErrorCodes;
|
16575 | exports.ErrorTypeStrings = ErrorTypeStrings;
|
16576 | exports.Fragment = Fragment;
|
16577 | exports.KeepAlive = KeepAlive;
|
16578 | exports.ReactiveEffect = ReactiveEffect;
|
16579 | exports.Static = Static;
|
16580 | exports.Suspense = Suspense;
|
16581 | exports.Teleport = Teleport;
|
16582 | exports.Text = Text;
|
16583 | exports.TrackOpTypes = TrackOpTypes;
|
16584 | exports.Transition = Transition;
|
16585 | exports.TransitionGroup = TransitionGroup;
|
16586 | exports.TriggerOpTypes = TriggerOpTypes;
|
16587 | exports.VueElement = VueElement;
|
16588 | exports.assertNumber = assertNumber;
|
16589 | exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
|
16590 | exports.callWithErrorHandling = callWithErrorHandling;
|
16591 | exports.camelize = camelize;
|
16592 | exports.capitalize = capitalize;
|
16593 | exports.cloneVNode = cloneVNode;
|
16594 | exports.compatUtils = compatUtils;
|
16595 | exports.compile = compileToFunction;
|
16596 | exports.computed = computed;
|
16597 | exports.createApp = createApp;
|
16598 | exports.createBlock = createBlock;
|
16599 | exports.createCommentVNode = createCommentVNode;
|
16600 | exports.createElementBlock = createElementBlock;
|
16601 | exports.createElementVNode = createBaseVNode;
|
16602 | exports.createHydrationRenderer = createHydrationRenderer;
|
16603 | exports.createPropsRestProxy = createPropsRestProxy;
|
16604 | exports.createRenderer = createRenderer;
|
16605 | exports.createSSRApp = createSSRApp;
|
16606 | exports.createSlots = createSlots;
|
16607 | exports.createStaticVNode = createStaticVNode;
|
16608 | exports.createTextVNode = createTextVNode;
|
16609 | exports.createVNode = createVNode;
|
16610 | exports.customRef = customRef;
|
16611 | exports.defineAsyncComponent = defineAsyncComponent;
|
16612 | exports.defineComponent = defineComponent;
|
16613 | exports.defineCustomElement = defineCustomElement;
|
16614 | exports.defineEmits = defineEmits;
|
16615 | exports.defineExpose = defineExpose;
|
16616 | exports.defineModel = defineModel;
|
16617 | exports.defineOptions = defineOptions;
|
16618 | exports.defineProps = defineProps;
|
16619 | exports.defineSSRCustomElement = defineSSRCustomElement;
|
16620 | exports.defineSlots = defineSlots;
|
16621 | exports.devtools = devtools;
|
16622 | exports.effect = effect;
|
16623 | exports.effectScope = effectScope;
|
16624 | exports.getCurrentInstance = getCurrentInstance;
|
16625 | exports.getCurrentScope = getCurrentScope;
|
16626 | exports.getTransitionRawChildren = getTransitionRawChildren;
|
16627 | exports.guardReactiveProps = guardReactiveProps;
|
16628 | exports.h = h;
|
16629 | exports.handleError = handleError;
|
16630 | exports.hasInjectionContext = hasInjectionContext;
|
16631 | exports.hydrate = hydrate;
|
16632 | exports.initCustomFormatter = initCustomFormatter;
|
16633 | exports.initDirectivesForSSR = initDirectivesForSSR;
|
16634 | exports.inject = inject;
|
16635 | exports.isMemoSame = isMemoSame;
|
16636 | exports.isProxy = isProxy;
|
16637 | exports.isReactive = isReactive;
|
16638 | exports.isReadonly = isReadonly;
|
16639 | exports.isRef = isRef;
|
16640 | exports.isRuntimeOnly = isRuntimeOnly;
|
16641 | exports.isShallow = isShallow;
|
16642 | exports.isVNode = isVNode;
|
16643 | exports.markRaw = markRaw;
|
16644 | exports.mergeDefaults = mergeDefaults;
|
16645 | exports.mergeModels = mergeModels;
|
16646 | exports.mergeProps = mergeProps;
|
16647 | exports.nextTick = nextTick;
|
16648 | exports.normalizeClass = normalizeClass;
|
16649 | exports.normalizeProps = normalizeProps;
|
16650 | exports.normalizeStyle = normalizeStyle;
|
16651 | exports.onActivated = onActivated;
|
16652 | exports.onBeforeMount = onBeforeMount;
|
16653 | exports.onBeforeUnmount = onBeforeUnmount;
|
16654 | exports.onBeforeUpdate = onBeforeUpdate;
|
16655 | exports.onDeactivated = onDeactivated;
|
16656 | exports.onErrorCaptured = onErrorCaptured;
|
16657 | exports.onMounted = onMounted;
|
16658 | exports.onRenderTracked = onRenderTracked;
|
16659 | exports.onRenderTriggered = onRenderTriggered;
|
16660 | exports.onScopeDispose = onScopeDispose;
|
16661 | exports.onServerPrefetch = onServerPrefetch;
|
16662 | exports.onUnmounted = onUnmounted;
|
16663 | exports.onUpdated = onUpdated;
|
16664 | exports.openBlock = openBlock;
|
16665 | exports.popScopeId = popScopeId;
|
16666 | exports.provide = provide;
|
16667 | exports.proxyRefs = proxyRefs;
|
16668 | exports.pushScopeId = pushScopeId;
|
16669 | exports.queuePostFlushCb = queuePostFlushCb;
|
16670 | exports.reactive = reactive;
|
16671 | exports.readonly = readonly;
|
16672 | exports.ref = ref;
|
16673 | exports.registerRuntimeCompiler = registerRuntimeCompiler;
|
16674 | exports.render = render;
|
16675 | exports.renderList = renderList;
|
16676 | exports.renderSlot = renderSlot;
|
16677 | exports.resolveComponent = resolveComponent;
|
16678 | exports.resolveDirective = resolveDirective;
|
16679 | exports.resolveDynamicComponent = resolveDynamicComponent;
|
16680 | exports.resolveFilter = resolveFilter;
|
16681 | exports.resolveTransitionHooks = resolveTransitionHooks;
|
16682 | exports.setBlockTracking = setBlockTracking;
|
16683 | exports.setDevtoolsHook = setDevtoolsHook;
|
16684 | exports.setTransitionHooks = setTransitionHooks;
|
16685 | exports.shallowReactive = shallowReactive;
|
16686 | exports.shallowReadonly = shallowReadonly;
|
16687 | exports.shallowRef = shallowRef;
|
16688 | exports.ssrContextKey = ssrContextKey;
|
16689 | exports.ssrUtils = ssrUtils;
|
16690 | exports.stop = stop;
|
16691 | exports.toDisplayString = toDisplayString;
|
16692 | exports.toHandlerKey = toHandlerKey;
|
16693 | exports.toHandlers = toHandlers;
|
16694 | exports.toRaw = toRaw;
|
16695 | exports.toRef = toRef;
|
16696 | exports.toRefs = toRefs;
|
16697 | exports.toValue = toValue;
|
16698 | exports.transformVNodeArgs = transformVNodeArgs;
|
16699 | exports.triggerRef = triggerRef;
|
16700 | exports.unref = unref;
|
16701 | exports.useAttrs = useAttrs;
|
16702 | exports.useCssModule = useCssModule;
|
16703 | exports.useCssVars = useCssVars;
|
16704 | exports.useModel = useModel;
|
16705 | exports.useSSRContext = useSSRContext;
|
16706 | exports.useSlots = useSlots;
|
16707 | exports.useTransitionState = useTransitionState;
|
16708 | exports.vModelCheckbox = vModelCheckbox;
|
16709 | exports.vModelDynamic = vModelDynamic;
|
16710 | exports.vModelRadio = vModelRadio;
|
16711 | exports.vModelSelect = vModelSelect;
|
16712 | exports.vModelText = vModelText;
|
16713 | exports.vShow = vShow;
|
16714 | exports.version = version;
|
16715 | exports.warn = warn;
|
16716 | exports.watch = watch;
|
16717 | exports.watchEffect = watchEffect;
|
16718 | exports.watchPostEffect = watchPostEffect;
|
16719 | exports.watchSyncEffect = watchSyncEffect;
|
16720 | exports.withAsyncContext = withAsyncContext;
|
16721 | exports.withCtx = withCtx;
|
16722 | exports.withDefaults = withDefaults;
|
16723 | exports.withDirectives = withDirectives;
|
16724 | exports.withKeys = withKeys;
|
16725 | exports.withMemo = withMemo;
|
16726 | exports.withModifiers = withModifiers;
|
16727 | exports.withScopeId = withScopeId;
|
16728 |
|
16729 | return exports;
|
16730 |
|
16731 | })({});
|