1 | /**
|
---|
2 | * @vue/server-renderer v3.5.13
|
---|
3 | * (c) 2018-present Yuxi (Evan) You and Vue contributors
|
---|
4 | * @license MIT
|
---|
5 | **/
|
---|
6 | /*! #__NO_SIDE_EFFECTS__ */
|
---|
7 | // @__NO_SIDE_EFFECTS__
|
---|
8 | function makeMap(str) {
|
---|
9 | const map = /* @__PURE__ */ Object.create(null);
|
---|
10 | for (const key of str.split(",")) map[key] = 1;
|
---|
11 | return (val) => val in map;
|
---|
12 | }
|
---|
13 |
|
---|
14 | const EMPTY_OBJ = Object.freeze({}) ;
|
---|
15 | const EMPTY_ARR = Object.freeze([]) ;
|
---|
16 | const NOOP = () => {
|
---|
17 | };
|
---|
18 | const NO = () => false;
|
---|
19 | const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
|
---|
20 | (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
|
---|
21 | const isModelListener = (key) => key.startsWith("onUpdate:");
|
---|
22 | const extend = Object.assign;
|
---|
23 | const remove = (arr, el) => {
|
---|
24 | const i = arr.indexOf(el);
|
---|
25 | if (i > -1) {
|
---|
26 | arr.splice(i, 1);
|
---|
27 | }
|
---|
28 | };
|
---|
29 | const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
---|
30 | const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
---|
31 | const isArray = Array.isArray;
|
---|
32 | const isMap = (val) => toTypeString(val) === "[object Map]";
|
---|
33 | const isSet = (val) => toTypeString(val) === "[object Set]";
|
---|
34 | const isDate = (val) => toTypeString(val) === "[object Date]";
|
---|
35 | const isFunction = (val) => typeof val === "function";
|
---|
36 | const isString = (val) => typeof val === "string";
|
---|
37 | const isSymbol = (val) => typeof val === "symbol";
|
---|
38 | const isObject = (val) => val !== null && typeof val === "object";
|
---|
39 | const isPromise = (val) => {
|
---|
40 | return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
|
---|
41 | };
|
---|
42 | const objectToString = Object.prototype.toString;
|
---|
43 | const toTypeString = (value) => objectToString.call(value);
|
---|
44 | const toRawType = (value) => {
|
---|
45 | return toTypeString(value).slice(8, -1);
|
---|
46 | };
|
---|
47 | const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
---|
48 | const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
---|
49 | const isReservedProp = /* @__PURE__ */ makeMap(
|
---|
50 | // the leading comma is intentional so empty string "" is also included
|
---|
51 | ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
|
---|
52 | );
|
---|
53 | const isBuiltInDirective = /* @__PURE__ */ makeMap(
|
---|
54 | "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
|
---|
55 | );
|
---|
56 | const cacheStringFunction = (fn) => {
|
---|
57 | const cache = /* @__PURE__ */ Object.create(null);
|
---|
58 | return (str) => {
|
---|
59 | const hit = cache[str];
|
---|
60 | return hit || (cache[str] = fn(str));
|
---|
61 | };
|
---|
62 | };
|
---|
63 | const camelizeRE = /-(\w)/g;
|
---|
64 | const camelize = cacheStringFunction(
|
---|
65 | (str) => {
|
---|
66 | return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
---|
67 | }
|
---|
68 | );
|
---|
69 | const hyphenateRE = /\B([A-Z])/g;
|
---|
70 | const hyphenate = cacheStringFunction(
|
---|
71 | (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
---|
72 | );
|
---|
73 | const capitalize = cacheStringFunction((str) => {
|
---|
74 | return str.charAt(0).toUpperCase() + str.slice(1);
|
---|
75 | });
|
---|
76 | const toHandlerKey = cacheStringFunction(
|
---|
77 | (str) => {
|
---|
78 | const s = str ? `on${capitalize(str)}` : ``;
|
---|
79 | return s;
|
---|
80 | }
|
---|
81 | );
|
---|
82 | const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
---|
83 | const invokeArrayFns = (fns, ...arg) => {
|
---|
84 | for (let i = 0; i < fns.length; i++) {
|
---|
85 | fns[i](...arg);
|
---|
86 | }
|
---|
87 | };
|
---|
88 | const def = (obj, key, value, writable = false) => {
|
---|
89 | Object.defineProperty(obj, key, {
|
---|
90 | configurable: true,
|
---|
91 | enumerable: false,
|
---|
92 | writable,
|
---|
93 | value
|
---|
94 | });
|
---|
95 | };
|
---|
96 | const looseToNumber = (val) => {
|
---|
97 | const n = parseFloat(val);
|
---|
98 | return isNaN(n) ? val : n;
|
---|
99 | };
|
---|
100 | let _globalThis;
|
---|
101 | const getGlobalThis = () => {
|
---|
102 | return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
|
---|
103 | };
|
---|
104 |
|
---|
105 | function normalizeStyle(value) {
|
---|
106 | if (isArray(value)) {
|
---|
107 | const res = {};
|
---|
108 | for (let i = 0; i < value.length; i++) {
|
---|
109 | const item = value[i];
|
---|
110 | const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
---|
111 | if (normalized) {
|
---|
112 | for (const key in normalized) {
|
---|
113 | res[key] = normalized[key];
|
---|
114 | }
|
---|
115 | }
|
---|
116 | }
|
---|
117 | return res;
|
---|
118 | } else if (isString(value) || isObject(value)) {
|
---|
119 | return value;
|
---|
120 | }
|
---|
121 | }
|
---|
122 | const listDelimiterRE = /;(?![^(]*\))/g;
|
---|
123 | const propertyDelimiterRE = /:([^]+)/;
|
---|
124 | const styleCommentRE = /\/\*[^]*?\*\//g;
|
---|
125 | function parseStringStyle(cssText) {
|
---|
126 | const ret = {};
|
---|
127 | cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
---|
128 | if (item) {
|
---|
129 | const tmp = item.split(propertyDelimiterRE);
|
---|
130 | tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
---|
131 | }
|
---|
132 | });
|
---|
133 | return ret;
|
---|
134 | }
|
---|
135 | function stringifyStyle(styles) {
|
---|
136 | if (!styles) return "";
|
---|
137 | if (isString(styles)) return styles;
|
---|
138 | let ret = "";
|
---|
139 | for (const key in styles) {
|
---|
140 | const value = styles[key];
|
---|
141 | if (isString(value) || typeof value === "number") {
|
---|
142 | const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
---|
143 | ret += `${normalizedKey}:${value};`;
|
---|
144 | }
|
---|
145 | }
|
---|
146 | return ret;
|
---|
147 | }
|
---|
148 | function normalizeClass(value) {
|
---|
149 | let res = "";
|
---|
150 | if (isString(value)) {
|
---|
151 | res = value;
|
---|
152 | } else if (isArray(value)) {
|
---|
153 | for (let i = 0; i < value.length; i++) {
|
---|
154 | const normalized = normalizeClass(value[i]);
|
---|
155 | if (normalized) {
|
---|
156 | res += normalized + " ";
|
---|
157 | }
|
---|
158 | }
|
---|
159 | } else if (isObject(value)) {
|
---|
160 | for (const name in value) {
|
---|
161 | if (value[name]) {
|
---|
162 | res += name + " ";
|
---|
163 | }
|
---|
164 | }
|
---|
165 | }
|
---|
166 | return res.trim();
|
---|
167 | }
|
---|
168 |
|
---|
169 | 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";
|
---|
170 | 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";
|
---|
171 | 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";
|
---|
172 | const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
|
---|
173 | const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
|
---|
174 | const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
|
---|
175 | const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
|
---|
176 | const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
|
---|
177 |
|
---|
178 | const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
---|
179 | const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
|
---|
180 | const isBooleanAttr = /* @__PURE__ */ makeMap(
|
---|
181 | specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
|
---|
182 | );
|
---|
183 | function includeBooleanAttr(value) {
|
---|
184 | return !!value || value === "";
|
---|
185 | }
|
---|
186 | const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
---|
187 | const attrValidationCache = {};
|
---|
188 | function isSSRSafeAttrName(name) {
|
---|
189 | if (attrValidationCache.hasOwnProperty(name)) {
|
---|
190 | return attrValidationCache[name];
|
---|
191 | }
|
---|
192 | const isUnsafe = unsafeAttrCharRE.test(name);
|
---|
193 | if (isUnsafe) {
|
---|
194 | console.error(`unsafe attribute name: ${name}`);
|
---|
195 | }
|
---|
196 | return attrValidationCache[name] = !isUnsafe;
|
---|
197 | }
|
---|
198 | const propsToAttrMap = {
|
---|
199 | acceptCharset: "accept-charset",
|
---|
200 | className: "class",
|
---|
201 | htmlFor: "for",
|
---|
202 | httpEquiv: "http-equiv"
|
---|
203 | };
|
---|
204 | function isRenderableAttrValue(value) {
|
---|
205 | if (value == null) {
|
---|
206 | return false;
|
---|
207 | }
|
---|
208 | const type = typeof value;
|
---|
209 | return type === "string" || type === "number" || type === "boolean";
|
---|
210 | }
|
---|
211 |
|
---|
212 | const escapeRE = /["'&<>]/;
|
---|
213 | function escapeHtml(string) {
|
---|
214 | const str = "" + string;
|
---|
215 | const match = escapeRE.exec(str);
|
---|
216 | if (!match) {
|
---|
217 | return str;
|
---|
218 | }
|
---|
219 | let html = "";
|
---|
220 | let escaped;
|
---|
221 | let index;
|
---|
222 | let lastIndex = 0;
|
---|
223 | for (index = match.index; index < str.length; index++) {
|
---|
224 | switch (str.charCodeAt(index)) {
|
---|
225 | case 34:
|
---|
226 | escaped = """;
|
---|
227 | break;
|
---|
228 | case 38:
|
---|
229 | escaped = "&";
|
---|
230 | break;
|
---|
231 | case 39:
|
---|
232 | escaped = "'";
|
---|
233 | break;
|
---|
234 | case 60:
|
---|
235 | escaped = "<";
|
---|
236 | break;
|
---|
237 | case 62:
|
---|
238 | escaped = ">";
|
---|
239 | break;
|
---|
240 | default:
|
---|
241 | continue;
|
---|
242 | }
|
---|
243 | if (lastIndex !== index) {
|
---|
244 | html += str.slice(lastIndex, index);
|
---|
245 | }
|
---|
246 | lastIndex = index + 1;
|
---|
247 | html += escaped;
|
---|
248 | }
|
---|
249 | return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
|
---|
250 | }
|
---|
251 | const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
|
---|
252 | function escapeHtmlComment(src) {
|
---|
253 | return src.replace(commentStripRE, "");
|
---|
254 | }
|
---|
255 |
|
---|
256 | function looseCompareArrays(a, b) {
|
---|
257 | if (a.length !== b.length) return false;
|
---|
258 | let equal = true;
|
---|
259 | for (let i = 0; equal && i < a.length; i++) {
|
---|
260 | equal = looseEqual(a[i], b[i]);
|
---|
261 | }
|
---|
262 | return equal;
|
---|
263 | }
|
---|
264 | function looseEqual(a, b) {
|
---|
265 | if (a === b) return true;
|
---|
266 | let aValidType = isDate(a);
|
---|
267 | let bValidType = isDate(b);
|
---|
268 | if (aValidType || bValidType) {
|
---|
269 | return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
---|
270 | }
|
---|
271 | aValidType = isSymbol(a);
|
---|
272 | bValidType = isSymbol(b);
|
---|
273 | if (aValidType || bValidType) {
|
---|
274 | return a === b;
|
---|
275 | }
|
---|
276 | aValidType = isArray(a);
|
---|
277 | bValidType = isArray(b);
|
---|
278 | if (aValidType || bValidType) {
|
---|
279 | return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
---|
280 | }
|
---|
281 | aValidType = isObject(a);
|
---|
282 | bValidType = isObject(b);
|
---|
283 | if (aValidType || bValidType) {
|
---|
284 | if (!aValidType || !bValidType) {
|
---|
285 | return false;
|
---|
286 | }
|
---|
287 | const aKeysCount = Object.keys(a).length;
|
---|
288 | const bKeysCount = Object.keys(b).length;
|
---|
289 | if (aKeysCount !== bKeysCount) {
|
---|
290 | return false;
|
---|
291 | }
|
---|
292 | for (const key in a) {
|
---|
293 | const aHasKey = a.hasOwnProperty(key);
|
---|
294 | const bHasKey = b.hasOwnProperty(key);
|
---|
295 | if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
|
---|
296 | return false;
|
---|
297 | }
|
---|
298 | }
|
---|
299 | }
|
---|
300 | return String(a) === String(b);
|
---|
301 | }
|
---|
302 | function looseIndexOf(arr, val) {
|
---|
303 | return arr.findIndex((item) => looseEqual(item, val));
|
---|
304 | }
|
---|
305 |
|
---|
306 | const isRef$1 = (val) => {
|
---|
307 | return !!(val && val["__v_isRef"] === true);
|
---|
308 | };
|
---|
309 | const toDisplayString = (val) => {
|
---|
310 | return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? isRef$1(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
|
---|
311 | };
|
---|
312 | const replacer = (_key, val) => {
|
---|
313 | if (isRef$1(val)) {
|
---|
314 | return replacer(_key, val.value);
|
---|
315 | } else if (isMap(val)) {
|
---|
316 | return {
|
---|
317 | [`Map(${val.size})`]: [...val.entries()].reduce(
|
---|
318 | (entries, [key, val2], i) => {
|
---|
319 | entries[stringifySymbol(key, i) + " =>"] = val2;
|
---|
320 | return entries;
|
---|
321 | },
|
---|
322 | {}
|
---|
323 | )
|
---|
324 | };
|
---|
325 | } else if (isSet(val)) {
|
---|
326 | return {
|
---|
327 | [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
|
---|
328 | };
|
---|
329 | } else if (isSymbol(val)) {
|
---|
330 | return stringifySymbol(val);
|
---|
331 | } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
|
---|
332 | return String(val);
|
---|
333 | }
|
---|
334 | return val;
|
---|
335 | };
|
---|
336 | const stringifySymbol = (v, i = "") => {
|
---|
337 | var _a;
|
---|
338 | return (
|
---|
339 | // Symbol.description in es2019+ so we need to cast here to pass
|
---|
340 | // the lib: es2016 check
|
---|
341 | isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
|
---|
342 | );
|
---|
343 | };
|
---|
344 |
|
---|
345 | function warn$2(msg, ...args) {
|
---|
346 | console.warn(`[Vue warn] ${msg}`, ...args);
|
---|
347 | }
|
---|
348 |
|
---|
349 | let activeEffectScope;
|
---|
350 | class EffectScope {
|
---|
351 | constructor(detached = false) {
|
---|
352 | this.detached = detached;
|
---|
353 | /**
|
---|
354 | * @internal
|
---|
355 | */
|
---|
356 | this._active = true;
|
---|
357 | /**
|
---|
358 | * @internal
|
---|
359 | */
|
---|
360 | this.effects = [];
|
---|
361 | /**
|
---|
362 | * @internal
|
---|
363 | */
|
---|
364 | this.cleanups = [];
|
---|
365 | this._isPaused = false;
|
---|
366 | this.parent = activeEffectScope;
|
---|
367 | if (!detached && activeEffectScope) {
|
---|
368 | this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
|
---|
369 | this
|
---|
370 | ) - 1;
|
---|
371 | }
|
---|
372 | }
|
---|
373 | get active() {
|
---|
374 | return this._active;
|
---|
375 | }
|
---|
376 | pause() {
|
---|
377 | if (this._active) {
|
---|
378 | this._isPaused = true;
|
---|
379 | let i, l;
|
---|
380 | if (this.scopes) {
|
---|
381 | for (i = 0, l = this.scopes.length; i < l; i++) {
|
---|
382 | this.scopes[i].pause();
|
---|
383 | }
|
---|
384 | }
|
---|
385 | for (i = 0, l = this.effects.length; i < l; i++) {
|
---|
386 | this.effects[i].pause();
|
---|
387 | }
|
---|
388 | }
|
---|
389 | }
|
---|
390 | /**
|
---|
391 | * Resumes the effect scope, including all child scopes and effects.
|
---|
392 | */
|
---|
393 | resume() {
|
---|
394 | if (this._active) {
|
---|
395 | if (this._isPaused) {
|
---|
396 | this._isPaused = false;
|
---|
397 | let i, l;
|
---|
398 | if (this.scopes) {
|
---|
399 | for (i = 0, l = this.scopes.length; i < l; i++) {
|
---|
400 | this.scopes[i].resume();
|
---|
401 | }
|
---|
402 | }
|
---|
403 | for (i = 0, l = this.effects.length; i < l; i++) {
|
---|
404 | this.effects[i].resume();
|
---|
405 | }
|
---|
406 | }
|
---|
407 | }
|
---|
408 | }
|
---|
409 | run(fn) {
|
---|
410 | if (this._active) {
|
---|
411 | const currentEffectScope = activeEffectScope;
|
---|
412 | try {
|
---|
413 | activeEffectScope = this;
|
---|
414 | return fn();
|
---|
415 | } finally {
|
---|
416 | activeEffectScope = currentEffectScope;
|
---|
417 | }
|
---|
418 | } else {
|
---|
419 | warn$2(`cannot run an inactive effect scope.`);
|
---|
420 | }
|
---|
421 | }
|
---|
422 | /**
|
---|
423 | * This should only be called on non-detached scopes
|
---|
424 | * @internal
|
---|
425 | */
|
---|
426 | on() {
|
---|
427 | activeEffectScope = this;
|
---|
428 | }
|
---|
429 | /**
|
---|
430 | * This should only be called on non-detached scopes
|
---|
431 | * @internal
|
---|
432 | */
|
---|
433 | off() {
|
---|
434 | activeEffectScope = this.parent;
|
---|
435 | }
|
---|
436 | stop(fromParent) {
|
---|
437 | if (this._active) {
|
---|
438 | this._active = false;
|
---|
439 | let i, l;
|
---|
440 | for (i = 0, l = this.effects.length; i < l; i++) {
|
---|
441 | this.effects[i].stop();
|
---|
442 | }
|
---|
443 | this.effects.length = 0;
|
---|
444 | for (i = 0, l = this.cleanups.length; i < l; i++) {
|
---|
445 | this.cleanups[i]();
|
---|
446 | }
|
---|
447 | this.cleanups.length = 0;
|
---|
448 | if (this.scopes) {
|
---|
449 | for (i = 0, l = this.scopes.length; i < l; i++) {
|
---|
450 | this.scopes[i].stop(true);
|
---|
451 | }
|
---|
452 | this.scopes.length = 0;
|
---|
453 | }
|
---|
454 | if (!this.detached && this.parent && !fromParent) {
|
---|
455 | const last = this.parent.scopes.pop();
|
---|
456 | if (last && last !== this) {
|
---|
457 | this.parent.scopes[this.index] = last;
|
---|
458 | last.index = this.index;
|
---|
459 | }
|
---|
460 | }
|
---|
461 | this.parent = void 0;
|
---|
462 | }
|
---|
463 | }
|
---|
464 | }
|
---|
465 | function getCurrentScope() {
|
---|
466 | return activeEffectScope;
|
---|
467 | }
|
---|
468 |
|
---|
469 | let activeSub;
|
---|
470 | const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
|
---|
471 | class ReactiveEffect {
|
---|
472 | constructor(fn) {
|
---|
473 | this.fn = fn;
|
---|
474 | /**
|
---|
475 | * @internal
|
---|
476 | */
|
---|
477 | this.deps = void 0;
|
---|
478 | /**
|
---|
479 | * @internal
|
---|
480 | */
|
---|
481 | this.depsTail = void 0;
|
---|
482 | /**
|
---|
483 | * @internal
|
---|
484 | */
|
---|
485 | this.flags = 1 | 4;
|
---|
486 | /**
|
---|
487 | * @internal
|
---|
488 | */
|
---|
489 | this.next = void 0;
|
---|
490 | /**
|
---|
491 | * @internal
|
---|
492 | */
|
---|
493 | this.cleanup = void 0;
|
---|
494 | this.scheduler = void 0;
|
---|
495 | if (activeEffectScope && activeEffectScope.active) {
|
---|
496 | activeEffectScope.effects.push(this);
|
---|
497 | }
|
---|
498 | }
|
---|
499 | pause() {
|
---|
500 | this.flags |= 64;
|
---|
501 | }
|
---|
502 | resume() {
|
---|
503 | if (this.flags & 64) {
|
---|
504 | this.flags &= ~64;
|
---|
505 | if (pausedQueueEffects.has(this)) {
|
---|
506 | pausedQueueEffects.delete(this);
|
---|
507 | this.trigger();
|
---|
508 | }
|
---|
509 | }
|
---|
510 | }
|
---|
511 | /**
|
---|
512 | * @internal
|
---|
513 | */
|
---|
514 | notify() {
|
---|
515 | if (this.flags & 2 && !(this.flags & 32)) {
|
---|
516 | return;
|
---|
517 | }
|
---|
518 | if (!(this.flags & 8)) {
|
---|
519 | batch(this);
|
---|
520 | }
|
---|
521 | }
|
---|
522 | run() {
|
---|
523 | if (!(this.flags & 1)) {
|
---|
524 | return this.fn();
|
---|
525 | }
|
---|
526 | this.flags |= 2;
|
---|
527 | cleanupEffect(this);
|
---|
528 | prepareDeps(this);
|
---|
529 | const prevEffect = activeSub;
|
---|
530 | const prevShouldTrack = shouldTrack;
|
---|
531 | activeSub = this;
|
---|
532 | shouldTrack = true;
|
---|
533 | try {
|
---|
534 | return this.fn();
|
---|
535 | } finally {
|
---|
536 | if (activeSub !== this) {
|
---|
537 | warn$2(
|
---|
538 | "Active effect was not restored correctly - this is likely a Vue internal bug."
|
---|
539 | );
|
---|
540 | }
|
---|
541 | cleanupDeps(this);
|
---|
542 | activeSub = prevEffect;
|
---|
543 | shouldTrack = prevShouldTrack;
|
---|
544 | this.flags &= ~2;
|
---|
545 | }
|
---|
546 | }
|
---|
547 | stop() {
|
---|
548 | if (this.flags & 1) {
|
---|
549 | for (let link = this.deps; link; link = link.nextDep) {
|
---|
550 | removeSub(link);
|
---|
551 | }
|
---|
552 | this.deps = this.depsTail = void 0;
|
---|
553 | cleanupEffect(this);
|
---|
554 | this.onStop && this.onStop();
|
---|
555 | this.flags &= ~1;
|
---|
556 | }
|
---|
557 | }
|
---|
558 | trigger() {
|
---|
559 | if (this.flags & 64) {
|
---|
560 | pausedQueueEffects.add(this);
|
---|
561 | } else if (this.scheduler) {
|
---|
562 | this.scheduler();
|
---|
563 | } else {
|
---|
564 | this.runIfDirty();
|
---|
565 | }
|
---|
566 | }
|
---|
567 | /**
|
---|
568 | * @internal
|
---|
569 | */
|
---|
570 | runIfDirty() {
|
---|
571 | if (isDirty(this)) {
|
---|
572 | this.run();
|
---|
573 | }
|
---|
574 | }
|
---|
575 | get dirty() {
|
---|
576 | return isDirty(this);
|
---|
577 | }
|
---|
578 | }
|
---|
579 | let batchDepth = 0;
|
---|
580 | let batchedSub;
|
---|
581 | let batchedComputed;
|
---|
582 | function batch(sub, isComputed = false) {
|
---|
583 | sub.flags |= 8;
|
---|
584 | if (isComputed) {
|
---|
585 | sub.next = batchedComputed;
|
---|
586 | batchedComputed = sub;
|
---|
587 | return;
|
---|
588 | }
|
---|
589 | sub.next = batchedSub;
|
---|
590 | batchedSub = sub;
|
---|
591 | }
|
---|
592 | function startBatch() {
|
---|
593 | batchDepth++;
|
---|
594 | }
|
---|
595 | function endBatch() {
|
---|
596 | if (--batchDepth > 0) {
|
---|
597 | return;
|
---|
598 | }
|
---|
599 | if (batchedComputed) {
|
---|
600 | let e = batchedComputed;
|
---|
601 | batchedComputed = void 0;
|
---|
602 | while (e) {
|
---|
603 | const next = e.next;
|
---|
604 | e.next = void 0;
|
---|
605 | e.flags &= ~8;
|
---|
606 | e = next;
|
---|
607 | }
|
---|
608 | }
|
---|
609 | let error;
|
---|
610 | while (batchedSub) {
|
---|
611 | let e = batchedSub;
|
---|
612 | batchedSub = void 0;
|
---|
613 | while (e) {
|
---|
614 | const next = e.next;
|
---|
615 | e.next = void 0;
|
---|
616 | e.flags &= ~8;
|
---|
617 | if (e.flags & 1) {
|
---|
618 | try {
|
---|
619 | ;
|
---|
620 | e.trigger();
|
---|
621 | } catch (err) {
|
---|
622 | if (!error) error = err;
|
---|
623 | }
|
---|
624 | }
|
---|
625 | e = next;
|
---|
626 | }
|
---|
627 | }
|
---|
628 | if (error) throw error;
|
---|
629 | }
|
---|
630 | function prepareDeps(sub) {
|
---|
631 | for (let link = sub.deps; link; link = link.nextDep) {
|
---|
632 | link.version = -1;
|
---|
633 | link.prevActiveLink = link.dep.activeLink;
|
---|
634 | link.dep.activeLink = link;
|
---|
635 | }
|
---|
636 | }
|
---|
637 | function cleanupDeps(sub) {
|
---|
638 | let head;
|
---|
639 | let tail = sub.depsTail;
|
---|
640 | let link = tail;
|
---|
641 | while (link) {
|
---|
642 | const prev = link.prevDep;
|
---|
643 | if (link.version === -1) {
|
---|
644 | if (link === tail) tail = prev;
|
---|
645 | removeSub(link);
|
---|
646 | removeDep(link);
|
---|
647 | } else {
|
---|
648 | head = link;
|
---|
649 | }
|
---|
650 | link.dep.activeLink = link.prevActiveLink;
|
---|
651 | link.prevActiveLink = void 0;
|
---|
652 | link = prev;
|
---|
653 | }
|
---|
654 | sub.deps = head;
|
---|
655 | sub.depsTail = tail;
|
---|
656 | }
|
---|
657 | function isDirty(sub) {
|
---|
658 | for (let link = sub.deps; link; link = link.nextDep) {
|
---|
659 | if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
|
---|
660 | return true;
|
---|
661 | }
|
---|
662 | }
|
---|
663 | if (sub._dirty) {
|
---|
664 | return true;
|
---|
665 | }
|
---|
666 | return false;
|
---|
667 | }
|
---|
668 | function refreshComputed(computed) {
|
---|
669 | if (computed.flags & 4 && !(computed.flags & 16)) {
|
---|
670 | return;
|
---|
671 | }
|
---|
672 | computed.flags &= ~16;
|
---|
673 | if (computed.globalVersion === globalVersion) {
|
---|
674 | return;
|
---|
675 | }
|
---|
676 | computed.globalVersion = globalVersion;
|
---|
677 | const dep = computed.dep;
|
---|
678 | computed.flags |= 2;
|
---|
679 | if (dep.version > 0 && !computed.isSSR && computed.deps && !isDirty(computed)) {
|
---|
680 | computed.flags &= ~2;
|
---|
681 | return;
|
---|
682 | }
|
---|
683 | const prevSub = activeSub;
|
---|
684 | const prevShouldTrack = shouldTrack;
|
---|
685 | activeSub = computed;
|
---|
686 | shouldTrack = true;
|
---|
687 | try {
|
---|
688 | prepareDeps(computed);
|
---|
689 | const value = computed.fn(computed._value);
|
---|
690 | if (dep.version === 0 || hasChanged(value, computed._value)) {
|
---|
691 | computed._value = value;
|
---|
692 | dep.version++;
|
---|
693 | }
|
---|
694 | } catch (err) {
|
---|
695 | dep.version++;
|
---|
696 | throw err;
|
---|
697 | } finally {
|
---|
698 | activeSub = prevSub;
|
---|
699 | shouldTrack = prevShouldTrack;
|
---|
700 | cleanupDeps(computed);
|
---|
701 | computed.flags &= ~2;
|
---|
702 | }
|
---|
703 | }
|
---|
704 | function removeSub(link, soft = false) {
|
---|
705 | const { dep, prevSub, nextSub } = link;
|
---|
706 | if (prevSub) {
|
---|
707 | prevSub.nextSub = nextSub;
|
---|
708 | link.prevSub = void 0;
|
---|
709 | }
|
---|
710 | if (nextSub) {
|
---|
711 | nextSub.prevSub = prevSub;
|
---|
712 | link.nextSub = void 0;
|
---|
713 | }
|
---|
714 | if (dep.subsHead === link) {
|
---|
715 | dep.subsHead = nextSub;
|
---|
716 | }
|
---|
717 | if (dep.subs === link) {
|
---|
718 | dep.subs = prevSub;
|
---|
719 | if (!prevSub && dep.computed) {
|
---|
720 | dep.computed.flags &= ~4;
|
---|
721 | for (let l = dep.computed.deps; l; l = l.nextDep) {
|
---|
722 | removeSub(l, true);
|
---|
723 | }
|
---|
724 | }
|
---|
725 | }
|
---|
726 | if (!soft && !--dep.sc && dep.map) {
|
---|
727 | dep.map.delete(dep.key);
|
---|
728 | }
|
---|
729 | }
|
---|
730 | function removeDep(link) {
|
---|
731 | const { prevDep, nextDep } = link;
|
---|
732 | if (prevDep) {
|
---|
733 | prevDep.nextDep = nextDep;
|
---|
734 | link.prevDep = void 0;
|
---|
735 | }
|
---|
736 | if (nextDep) {
|
---|
737 | nextDep.prevDep = prevDep;
|
---|
738 | link.nextDep = void 0;
|
---|
739 | }
|
---|
740 | }
|
---|
741 | let shouldTrack = true;
|
---|
742 | const trackStack = [];
|
---|
743 | function pauseTracking() {
|
---|
744 | trackStack.push(shouldTrack);
|
---|
745 | shouldTrack = false;
|
---|
746 | }
|
---|
747 | function resetTracking() {
|
---|
748 | const last = trackStack.pop();
|
---|
749 | shouldTrack = last === void 0 ? true : last;
|
---|
750 | }
|
---|
751 | function cleanupEffect(e) {
|
---|
752 | const { cleanup } = e;
|
---|
753 | e.cleanup = void 0;
|
---|
754 | if (cleanup) {
|
---|
755 | const prevSub = activeSub;
|
---|
756 | activeSub = void 0;
|
---|
757 | try {
|
---|
758 | cleanup();
|
---|
759 | } finally {
|
---|
760 | activeSub = prevSub;
|
---|
761 | }
|
---|
762 | }
|
---|
763 | }
|
---|
764 |
|
---|
765 | let globalVersion = 0;
|
---|
766 | class Link {
|
---|
767 | constructor(sub, dep) {
|
---|
768 | this.sub = sub;
|
---|
769 | this.dep = dep;
|
---|
770 | this.version = dep.version;
|
---|
771 | this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
|
---|
772 | }
|
---|
773 | }
|
---|
774 | class Dep {
|
---|
775 | constructor(computed) {
|
---|
776 | this.computed = computed;
|
---|
777 | this.version = 0;
|
---|
778 | /**
|
---|
779 | * Link between this dep and the current active effect
|
---|
780 | */
|
---|
781 | this.activeLink = void 0;
|
---|
782 | /**
|
---|
783 | * Doubly linked list representing the subscribing effects (tail)
|
---|
784 | */
|
---|
785 | this.subs = void 0;
|
---|
786 | /**
|
---|
787 | * For object property deps cleanup
|
---|
788 | */
|
---|
789 | this.map = void 0;
|
---|
790 | this.key = void 0;
|
---|
791 | /**
|
---|
792 | * Subscriber counter
|
---|
793 | */
|
---|
794 | this.sc = 0;
|
---|
795 | {
|
---|
796 | this.subsHead = void 0;
|
---|
797 | }
|
---|
798 | }
|
---|
799 | track(debugInfo) {
|
---|
800 | if (!activeSub || !shouldTrack || activeSub === this.computed) {
|
---|
801 | return;
|
---|
802 | }
|
---|
803 | let link = this.activeLink;
|
---|
804 | if (link === void 0 || link.sub !== activeSub) {
|
---|
805 | link = this.activeLink = new Link(activeSub, this);
|
---|
806 | if (!activeSub.deps) {
|
---|
807 | activeSub.deps = activeSub.depsTail = link;
|
---|
808 | } else {
|
---|
809 | link.prevDep = activeSub.depsTail;
|
---|
810 | activeSub.depsTail.nextDep = link;
|
---|
811 | activeSub.depsTail = link;
|
---|
812 | }
|
---|
813 | addSub(link);
|
---|
814 | } else if (link.version === -1) {
|
---|
815 | link.version = this.version;
|
---|
816 | if (link.nextDep) {
|
---|
817 | const next = link.nextDep;
|
---|
818 | next.prevDep = link.prevDep;
|
---|
819 | if (link.prevDep) {
|
---|
820 | link.prevDep.nextDep = next;
|
---|
821 | }
|
---|
822 | link.prevDep = activeSub.depsTail;
|
---|
823 | link.nextDep = void 0;
|
---|
824 | activeSub.depsTail.nextDep = link;
|
---|
825 | activeSub.depsTail = link;
|
---|
826 | if (activeSub.deps === link) {
|
---|
827 | activeSub.deps = next;
|
---|
828 | }
|
---|
829 | }
|
---|
830 | }
|
---|
831 | if (activeSub.onTrack) {
|
---|
832 | activeSub.onTrack(
|
---|
833 | extend(
|
---|
834 | {
|
---|
835 | effect: activeSub
|
---|
836 | },
|
---|
837 | debugInfo
|
---|
838 | )
|
---|
839 | );
|
---|
840 | }
|
---|
841 | return link;
|
---|
842 | }
|
---|
843 | trigger(debugInfo) {
|
---|
844 | this.version++;
|
---|
845 | globalVersion++;
|
---|
846 | this.notify(debugInfo);
|
---|
847 | }
|
---|
848 | notify(debugInfo) {
|
---|
849 | startBatch();
|
---|
850 | try {
|
---|
851 | if (true) {
|
---|
852 | for (let head = this.subsHead; head; head = head.nextSub) {
|
---|
853 | if (head.sub.onTrigger && !(head.sub.flags & 8)) {
|
---|
854 | head.sub.onTrigger(
|
---|
855 | extend(
|
---|
856 | {
|
---|
857 | effect: head.sub
|
---|
858 | },
|
---|
859 | debugInfo
|
---|
860 | )
|
---|
861 | );
|
---|
862 | }
|
---|
863 | }
|
---|
864 | }
|
---|
865 | for (let link = this.subs; link; link = link.prevSub) {
|
---|
866 | if (link.sub.notify()) {
|
---|
867 | ;
|
---|
868 | link.sub.dep.notify();
|
---|
869 | }
|
---|
870 | }
|
---|
871 | } finally {
|
---|
872 | endBatch();
|
---|
873 | }
|
---|
874 | }
|
---|
875 | }
|
---|
876 | function addSub(link) {
|
---|
877 | link.dep.sc++;
|
---|
878 | if (link.sub.flags & 4) {
|
---|
879 | const computed = link.dep.computed;
|
---|
880 | if (computed && !link.dep.subs) {
|
---|
881 | computed.flags |= 4 | 16;
|
---|
882 | for (let l = computed.deps; l; l = l.nextDep) {
|
---|
883 | addSub(l);
|
---|
884 | }
|
---|
885 | }
|
---|
886 | const currentTail = link.dep.subs;
|
---|
887 | if (currentTail !== link) {
|
---|
888 | link.prevSub = currentTail;
|
---|
889 | if (currentTail) currentTail.nextSub = link;
|
---|
890 | }
|
---|
891 | if (link.dep.subsHead === void 0) {
|
---|
892 | link.dep.subsHead = link;
|
---|
893 | }
|
---|
894 | link.dep.subs = link;
|
---|
895 | }
|
---|
896 | }
|
---|
897 | const targetMap = /* @__PURE__ */ new WeakMap();
|
---|
898 | const ITERATE_KEY = Symbol(
|
---|
899 | "Object iterate"
|
---|
900 | );
|
---|
901 | const MAP_KEY_ITERATE_KEY = Symbol(
|
---|
902 | "Map keys iterate"
|
---|
903 | );
|
---|
904 | const ARRAY_ITERATE_KEY = Symbol(
|
---|
905 | "Array iterate"
|
---|
906 | );
|
---|
907 | function track(target, type, key) {
|
---|
908 | if (shouldTrack && activeSub) {
|
---|
909 | let depsMap = targetMap.get(target);
|
---|
910 | if (!depsMap) {
|
---|
911 | targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
---|
912 | }
|
---|
913 | let dep = depsMap.get(key);
|
---|
914 | if (!dep) {
|
---|
915 | depsMap.set(key, dep = new Dep());
|
---|
916 | dep.map = depsMap;
|
---|
917 | dep.key = key;
|
---|
918 | }
|
---|
919 | {
|
---|
920 | dep.track({
|
---|
921 | target,
|
---|
922 | type,
|
---|
923 | key
|
---|
924 | });
|
---|
925 | }
|
---|
926 | }
|
---|
927 | }
|
---|
928 | function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
---|
929 | const depsMap = targetMap.get(target);
|
---|
930 | if (!depsMap) {
|
---|
931 | globalVersion++;
|
---|
932 | return;
|
---|
933 | }
|
---|
934 | const run = (dep) => {
|
---|
935 | if (dep) {
|
---|
936 | {
|
---|
937 | dep.trigger({
|
---|
938 | target,
|
---|
939 | type,
|
---|
940 | key,
|
---|
941 | newValue,
|
---|
942 | oldValue,
|
---|
943 | oldTarget
|
---|
944 | });
|
---|
945 | }
|
---|
946 | }
|
---|
947 | };
|
---|
948 | startBatch();
|
---|
949 | if (type === "clear") {
|
---|
950 | depsMap.forEach(run);
|
---|
951 | } else {
|
---|
952 | const targetIsArray = isArray(target);
|
---|
953 | const isArrayIndex = targetIsArray && isIntegerKey(key);
|
---|
954 | if (targetIsArray && key === "length") {
|
---|
955 | const newLength = Number(newValue);
|
---|
956 | depsMap.forEach((dep, key2) => {
|
---|
957 | if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
|
---|
958 | run(dep);
|
---|
959 | }
|
---|
960 | });
|
---|
961 | } else {
|
---|
962 | if (key !== void 0 || depsMap.has(void 0)) {
|
---|
963 | run(depsMap.get(key));
|
---|
964 | }
|
---|
965 | if (isArrayIndex) {
|
---|
966 | run(depsMap.get(ARRAY_ITERATE_KEY));
|
---|
967 | }
|
---|
968 | switch (type) {
|
---|
969 | case "add":
|
---|
970 | if (!targetIsArray) {
|
---|
971 | run(depsMap.get(ITERATE_KEY));
|
---|
972 | if (isMap(target)) {
|
---|
973 | run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
---|
974 | }
|
---|
975 | } else if (isArrayIndex) {
|
---|
976 | run(depsMap.get("length"));
|
---|
977 | }
|
---|
978 | break;
|
---|
979 | case "delete":
|
---|
980 | if (!targetIsArray) {
|
---|
981 | run(depsMap.get(ITERATE_KEY));
|
---|
982 | if (isMap(target)) {
|
---|
983 | run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
---|
984 | }
|
---|
985 | }
|
---|
986 | break;
|
---|
987 | case "set":
|
---|
988 | if (isMap(target)) {
|
---|
989 | run(depsMap.get(ITERATE_KEY));
|
---|
990 | }
|
---|
991 | break;
|
---|
992 | }
|
---|
993 | }
|
---|
994 | }
|
---|
995 | endBatch();
|
---|
996 | }
|
---|
997 |
|
---|
998 | function reactiveReadArray(array) {
|
---|
999 | const raw = toRaw(array);
|
---|
1000 | if (raw === array) return raw;
|
---|
1001 | track(raw, "iterate", ARRAY_ITERATE_KEY);
|
---|
1002 | return isShallow(array) ? raw : raw.map(toReactive);
|
---|
1003 | }
|
---|
1004 | function shallowReadArray(arr) {
|
---|
1005 | track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
|
---|
1006 | return arr;
|
---|
1007 | }
|
---|
1008 | const arrayInstrumentations = {
|
---|
1009 | __proto__: null,
|
---|
1010 | [Symbol.iterator]() {
|
---|
1011 | return iterator(this, Symbol.iterator, toReactive);
|
---|
1012 | },
|
---|
1013 | concat(...args) {
|
---|
1014 | return reactiveReadArray(this).concat(
|
---|
1015 | ...args.map((x) => isArray(x) ? reactiveReadArray(x) : x)
|
---|
1016 | );
|
---|
1017 | },
|
---|
1018 | entries() {
|
---|
1019 | return iterator(this, "entries", (value) => {
|
---|
1020 | value[1] = toReactive(value[1]);
|
---|
1021 | return value;
|
---|
1022 | });
|
---|
1023 | },
|
---|
1024 | every(fn, thisArg) {
|
---|
1025 | return apply(this, "every", fn, thisArg, void 0, arguments);
|
---|
1026 | },
|
---|
1027 | filter(fn, thisArg) {
|
---|
1028 | return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
|
---|
1029 | },
|
---|
1030 | find(fn, thisArg) {
|
---|
1031 | return apply(this, "find", fn, thisArg, toReactive, arguments);
|
---|
1032 | },
|
---|
1033 | findIndex(fn, thisArg) {
|
---|
1034 | return apply(this, "findIndex", fn, thisArg, void 0, arguments);
|
---|
1035 | },
|
---|
1036 | findLast(fn, thisArg) {
|
---|
1037 | return apply(this, "findLast", fn, thisArg, toReactive, arguments);
|
---|
1038 | },
|
---|
1039 | findLastIndex(fn, thisArg) {
|
---|
1040 | return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
|
---|
1041 | },
|
---|
1042 | // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
|
---|
1043 | forEach(fn, thisArg) {
|
---|
1044 | return apply(this, "forEach", fn, thisArg, void 0, arguments);
|
---|
1045 | },
|
---|
1046 | includes(...args) {
|
---|
1047 | return searchProxy(this, "includes", args);
|
---|
1048 | },
|
---|
1049 | indexOf(...args) {
|
---|
1050 | return searchProxy(this, "indexOf", args);
|
---|
1051 | },
|
---|
1052 | join(separator) {
|
---|
1053 | return reactiveReadArray(this).join(separator);
|
---|
1054 | },
|
---|
1055 | // keys() iterator only reads `length`, no optimisation required
|
---|
1056 | lastIndexOf(...args) {
|
---|
1057 | return searchProxy(this, "lastIndexOf", args);
|
---|
1058 | },
|
---|
1059 | map(fn, thisArg) {
|
---|
1060 | return apply(this, "map", fn, thisArg, void 0, arguments);
|
---|
1061 | },
|
---|
1062 | pop() {
|
---|
1063 | return noTracking(this, "pop");
|
---|
1064 | },
|
---|
1065 | push(...args) {
|
---|
1066 | return noTracking(this, "push", args);
|
---|
1067 | },
|
---|
1068 | reduce(fn, ...args) {
|
---|
1069 | return reduce(this, "reduce", fn, args);
|
---|
1070 | },
|
---|
1071 | reduceRight(fn, ...args) {
|
---|
1072 | return reduce(this, "reduceRight", fn, args);
|
---|
1073 | },
|
---|
1074 | shift() {
|
---|
1075 | return noTracking(this, "shift");
|
---|
1076 | },
|
---|
1077 | // slice could use ARRAY_ITERATE but also seems to beg for range tracking
|
---|
1078 | some(fn, thisArg) {
|
---|
1079 | return apply(this, "some", fn, thisArg, void 0, arguments);
|
---|
1080 | },
|
---|
1081 | splice(...args) {
|
---|
1082 | return noTracking(this, "splice", args);
|
---|
1083 | },
|
---|
1084 | toReversed() {
|
---|
1085 | return reactiveReadArray(this).toReversed();
|
---|
1086 | },
|
---|
1087 | toSorted(comparer) {
|
---|
1088 | return reactiveReadArray(this).toSorted(comparer);
|
---|
1089 | },
|
---|
1090 | toSpliced(...args) {
|
---|
1091 | return reactiveReadArray(this).toSpliced(...args);
|
---|
1092 | },
|
---|
1093 | unshift(...args) {
|
---|
1094 | return noTracking(this, "unshift", args);
|
---|
1095 | },
|
---|
1096 | values() {
|
---|
1097 | return iterator(this, "values", toReactive);
|
---|
1098 | }
|
---|
1099 | };
|
---|
1100 | function iterator(self, method, wrapValue) {
|
---|
1101 | const arr = shallowReadArray(self);
|
---|
1102 | const iter = arr[method]();
|
---|
1103 | if (arr !== self && !isShallow(self)) {
|
---|
1104 | iter._next = iter.next;
|
---|
1105 | iter.next = () => {
|
---|
1106 | const result = iter._next();
|
---|
1107 | if (result.value) {
|
---|
1108 | result.value = wrapValue(result.value);
|
---|
1109 | }
|
---|
1110 | return result;
|
---|
1111 | };
|
---|
1112 | }
|
---|
1113 | return iter;
|
---|
1114 | }
|
---|
1115 | const arrayProto = Array.prototype;
|
---|
1116 | function apply(self, method, fn, thisArg, wrappedRetFn, args) {
|
---|
1117 | const arr = shallowReadArray(self);
|
---|
1118 | const needsWrap = arr !== self && !isShallow(self);
|
---|
1119 | const methodFn = arr[method];
|
---|
1120 | if (methodFn !== arrayProto[method]) {
|
---|
1121 | const result2 = methodFn.apply(self, args);
|
---|
1122 | return needsWrap ? toReactive(result2) : result2;
|
---|
1123 | }
|
---|
1124 | let wrappedFn = fn;
|
---|
1125 | if (arr !== self) {
|
---|
1126 | if (needsWrap) {
|
---|
1127 | wrappedFn = function(item, index) {
|
---|
1128 | return fn.call(this, toReactive(item), index, self);
|
---|
1129 | };
|
---|
1130 | } else if (fn.length > 2) {
|
---|
1131 | wrappedFn = function(item, index) {
|
---|
1132 | return fn.call(this, item, index, self);
|
---|
1133 | };
|
---|
1134 | }
|
---|
1135 | }
|
---|
1136 | const result = methodFn.call(arr, wrappedFn, thisArg);
|
---|
1137 | return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
|
---|
1138 | }
|
---|
1139 | function reduce(self, method, fn, args) {
|
---|
1140 | const arr = shallowReadArray(self);
|
---|
1141 | let wrappedFn = fn;
|
---|
1142 | if (arr !== self) {
|
---|
1143 | if (!isShallow(self)) {
|
---|
1144 | wrappedFn = function(acc, item, index) {
|
---|
1145 | return fn.call(this, acc, toReactive(item), index, self);
|
---|
1146 | };
|
---|
1147 | } else if (fn.length > 3) {
|
---|
1148 | wrappedFn = function(acc, item, index) {
|
---|
1149 | return fn.call(this, acc, item, index, self);
|
---|
1150 | };
|
---|
1151 | }
|
---|
1152 | }
|
---|
1153 | return arr[method](wrappedFn, ...args);
|
---|
1154 | }
|
---|
1155 | function searchProxy(self, method, args) {
|
---|
1156 | const arr = toRaw(self);
|
---|
1157 | track(arr, "iterate", ARRAY_ITERATE_KEY);
|
---|
1158 | const res = arr[method](...args);
|
---|
1159 | if ((res === -1 || res === false) && isProxy(args[0])) {
|
---|
1160 | args[0] = toRaw(args[0]);
|
---|
1161 | return arr[method](...args);
|
---|
1162 | }
|
---|
1163 | return res;
|
---|
1164 | }
|
---|
1165 | function noTracking(self, method, args = []) {
|
---|
1166 | pauseTracking();
|
---|
1167 | startBatch();
|
---|
1168 | const res = toRaw(self)[method].apply(self, args);
|
---|
1169 | endBatch();
|
---|
1170 | resetTracking();
|
---|
1171 | return res;
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
---|
1175 | const builtInSymbols = new Set(
|
---|
1176 | /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
---|
1177 | );
|
---|
1178 | function hasOwnProperty(key) {
|
---|
1179 | if (!isSymbol(key)) key = String(key);
|
---|
1180 | const obj = toRaw(this);
|
---|
1181 | track(obj, "has", key);
|
---|
1182 | return obj.hasOwnProperty(key);
|
---|
1183 | }
|
---|
1184 | class BaseReactiveHandler {
|
---|
1185 | constructor(_isReadonly = false, _isShallow = false) {
|
---|
1186 | this._isReadonly = _isReadonly;
|
---|
1187 | this._isShallow = _isShallow;
|
---|
1188 | }
|
---|
1189 | get(target, key, receiver) {
|
---|
1190 | if (key === "__v_skip") return target["__v_skip"];
|
---|
1191 | const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
|
---|
1192 | if (key === "__v_isReactive") {
|
---|
1193 | return !isReadonly2;
|
---|
1194 | } else if (key === "__v_isReadonly") {
|
---|
1195 | return isReadonly2;
|
---|
1196 | } else if (key === "__v_isShallow") {
|
---|
1197 | return isShallow2;
|
---|
1198 | } else if (key === "__v_raw") {
|
---|
1199 | if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
|
---|
1200 | // this means the receiver is a user proxy of the reactive proxy
|
---|
1201 | Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
---|
1202 | return target;
|
---|
1203 | }
|
---|
1204 | return;
|
---|
1205 | }
|
---|
1206 | const targetIsArray = isArray(target);
|
---|
1207 | if (!isReadonly2) {
|
---|
1208 | let fn;
|
---|
1209 | if (targetIsArray && (fn = arrayInstrumentations[key])) {
|
---|
1210 | return fn;
|
---|
1211 | }
|
---|
1212 | if (key === "hasOwnProperty") {
|
---|
1213 | return hasOwnProperty;
|
---|
1214 | }
|
---|
1215 | }
|
---|
1216 | const res = Reflect.get(
|
---|
1217 | target,
|
---|
1218 | key,
|
---|
1219 | // if this is a proxy wrapping a ref, return methods using the raw ref
|
---|
1220 | // as receiver so that we don't have to call `toRaw` on the ref in all
|
---|
1221 | // its class methods
|
---|
1222 | isRef(target) ? target : receiver
|
---|
1223 | );
|
---|
1224 | if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
---|
1225 | return res;
|
---|
1226 | }
|
---|
1227 | if (!isReadonly2) {
|
---|
1228 | track(target, "get", key);
|
---|
1229 | }
|
---|
1230 | if (isShallow2) {
|
---|
1231 | return res;
|
---|
1232 | }
|
---|
1233 | if (isRef(res)) {
|
---|
1234 | return targetIsArray && isIntegerKey(key) ? res : res.value;
|
---|
1235 | }
|
---|
1236 | if (isObject(res)) {
|
---|
1237 | return isReadonly2 ? readonly(res) : reactive(res);
|
---|
1238 | }
|
---|
1239 | return res;
|
---|
1240 | }
|
---|
1241 | }
|
---|
1242 | class MutableReactiveHandler extends BaseReactiveHandler {
|
---|
1243 | constructor(isShallow2 = false) {
|
---|
1244 | super(false, isShallow2);
|
---|
1245 | }
|
---|
1246 | set(target, key, value, receiver) {
|
---|
1247 | let oldValue = target[key];
|
---|
1248 | if (!this._isShallow) {
|
---|
1249 | const isOldValueReadonly = isReadonly(oldValue);
|
---|
1250 | if (!isShallow(value) && !isReadonly(value)) {
|
---|
1251 | oldValue = toRaw(oldValue);
|
---|
1252 | value = toRaw(value);
|
---|
1253 | }
|
---|
1254 | if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
---|
1255 | if (isOldValueReadonly) {
|
---|
1256 | return false;
|
---|
1257 | } else {
|
---|
1258 | oldValue.value = value;
|
---|
1259 | return true;
|
---|
1260 | }
|
---|
1261 | }
|
---|
1262 | }
|
---|
1263 | const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
---|
1264 | const result = Reflect.set(
|
---|
1265 | target,
|
---|
1266 | key,
|
---|
1267 | value,
|
---|
1268 | isRef(target) ? target : receiver
|
---|
1269 | );
|
---|
1270 | if (target === toRaw(receiver)) {
|
---|
1271 | if (!hadKey) {
|
---|
1272 | trigger(target, "add", key, value);
|
---|
1273 | } else if (hasChanged(value, oldValue)) {
|
---|
1274 | trigger(target, "set", key, value, oldValue);
|
---|
1275 | }
|
---|
1276 | }
|
---|
1277 | return result;
|
---|
1278 | }
|
---|
1279 | deleteProperty(target, key) {
|
---|
1280 | const hadKey = hasOwn(target, key);
|
---|
1281 | const oldValue = target[key];
|
---|
1282 | const result = Reflect.deleteProperty(target, key);
|
---|
1283 | if (result && hadKey) {
|
---|
1284 | trigger(target, "delete", key, void 0, oldValue);
|
---|
1285 | }
|
---|
1286 | return result;
|
---|
1287 | }
|
---|
1288 | has(target, key) {
|
---|
1289 | const result = Reflect.has(target, key);
|
---|
1290 | if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
---|
1291 | track(target, "has", key);
|
---|
1292 | }
|
---|
1293 | return result;
|
---|
1294 | }
|
---|
1295 | ownKeys(target) {
|
---|
1296 | track(
|
---|
1297 | target,
|
---|
1298 | "iterate",
|
---|
1299 | isArray(target) ? "length" : ITERATE_KEY
|
---|
1300 | );
|
---|
1301 | return Reflect.ownKeys(target);
|
---|
1302 | }
|
---|
1303 | }
|
---|
1304 | class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
---|
1305 | constructor(isShallow2 = false) {
|
---|
1306 | super(true, isShallow2);
|
---|
1307 | }
|
---|
1308 | set(target, key) {
|
---|
1309 | {
|
---|
1310 | warn$2(
|
---|
1311 | `Set operation on key "${String(key)}" failed: target is readonly.`,
|
---|
1312 | target
|
---|
1313 | );
|
---|
1314 | }
|
---|
1315 | return true;
|
---|
1316 | }
|
---|
1317 | deleteProperty(target, key) {
|
---|
1318 | {
|
---|
1319 | warn$2(
|
---|
1320 | `Delete operation on key "${String(key)}" failed: target is readonly.`,
|
---|
1321 | target
|
---|
1322 | );
|
---|
1323 | }
|
---|
1324 | return true;
|
---|
1325 | }
|
---|
1326 | }
|
---|
1327 | const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
---|
1328 | const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
---|
1329 | const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
|
---|
1330 | const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
---|
1331 |
|
---|
1332 | const toShallow = (value) => value;
|
---|
1333 | const getProto = (v) => Reflect.getPrototypeOf(v);
|
---|
1334 | function createIterableMethod(method, isReadonly2, isShallow2) {
|
---|
1335 | return function(...args) {
|
---|
1336 | const target = this["__v_raw"];
|
---|
1337 | const rawTarget = toRaw(target);
|
---|
1338 | const targetIsMap = isMap(rawTarget);
|
---|
1339 | const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
---|
1340 | const isKeyOnly = method === "keys" && targetIsMap;
|
---|
1341 | const innerIterator = target[method](...args);
|
---|
1342 | const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
---|
1343 | !isReadonly2 && track(
|
---|
1344 | rawTarget,
|
---|
1345 | "iterate",
|
---|
1346 | isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
---|
1347 | );
|
---|
1348 | return {
|
---|
1349 | // iterator protocol
|
---|
1350 | next() {
|
---|
1351 | const { value, done } = innerIterator.next();
|
---|
1352 | return done ? { value, done } : {
|
---|
1353 | value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
---|
1354 | done
|
---|
1355 | };
|
---|
1356 | },
|
---|
1357 | // iterable protocol
|
---|
1358 | [Symbol.iterator]() {
|
---|
1359 | return this;
|
---|
1360 | }
|
---|
1361 | };
|
---|
1362 | };
|
---|
1363 | }
|
---|
1364 | function createReadonlyMethod(type) {
|
---|
1365 | return function(...args) {
|
---|
1366 | {
|
---|
1367 | const key = args[0] ? `on key "${args[0]}" ` : ``;
|
---|
1368 | warn$2(
|
---|
1369 | `${capitalize(type)} operation ${key}failed: target is readonly.`,
|
---|
1370 | toRaw(this)
|
---|
1371 | );
|
---|
1372 | }
|
---|
1373 | return type === "delete" ? false : type === "clear" ? void 0 : this;
|
---|
1374 | };
|
---|
1375 | }
|
---|
1376 | function createInstrumentations(readonly, shallow) {
|
---|
1377 | const instrumentations = {
|
---|
1378 | get(key) {
|
---|
1379 | const target = this["__v_raw"];
|
---|
1380 | const rawTarget = toRaw(target);
|
---|
1381 | const rawKey = toRaw(key);
|
---|
1382 | if (!readonly) {
|
---|
1383 | if (hasChanged(key, rawKey)) {
|
---|
1384 | track(rawTarget, "get", key);
|
---|
1385 | }
|
---|
1386 | track(rawTarget, "get", rawKey);
|
---|
1387 | }
|
---|
1388 | const { has } = getProto(rawTarget);
|
---|
1389 | const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
---|
1390 | if (has.call(rawTarget, key)) {
|
---|
1391 | return wrap(target.get(key));
|
---|
1392 | } else if (has.call(rawTarget, rawKey)) {
|
---|
1393 | return wrap(target.get(rawKey));
|
---|
1394 | } else if (target !== rawTarget) {
|
---|
1395 | target.get(key);
|
---|
1396 | }
|
---|
1397 | },
|
---|
1398 | get size() {
|
---|
1399 | const target = this["__v_raw"];
|
---|
1400 | !readonly && track(toRaw(target), "iterate", ITERATE_KEY);
|
---|
1401 | return Reflect.get(target, "size", target);
|
---|
1402 | },
|
---|
1403 | has(key) {
|
---|
1404 | const target = this["__v_raw"];
|
---|
1405 | const rawTarget = toRaw(target);
|
---|
1406 | const rawKey = toRaw(key);
|
---|
1407 | if (!readonly) {
|
---|
1408 | if (hasChanged(key, rawKey)) {
|
---|
1409 | track(rawTarget, "has", key);
|
---|
1410 | }
|
---|
1411 | track(rawTarget, "has", rawKey);
|
---|
1412 | }
|
---|
1413 | return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
---|
1414 | },
|
---|
1415 | forEach(callback, thisArg) {
|
---|
1416 | const observed = this;
|
---|
1417 | const target = observed["__v_raw"];
|
---|
1418 | const rawTarget = toRaw(target);
|
---|
1419 | const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
---|
1420 | !readonly && track(rawTarget, "iterate", ITERATE_KEY);
|
---|
1421 | return target.forEach((value, key) => {
|
---|
1422 | return callback.call(thisArg, wrap(value), wrap(key), observed);
|
---|
1423 | });
|
---|
1424 | }
|
---|
1425 | };
|
---|
1426 | extend(
|
---|
1427 | instrumentations,
|
---|
1428 | readonly ? {
|
---|
1429 | add: createReadonlyMethod("add"),
|
---|
1430 | set: createReadonlyMethod("set"),
|
---|
1431 | delete: createReadonlyMethod("delete"),
|
---|
1432 | clear: createReadonlyMethod("clear")
|
---|
1433 | } : {
|
---|
1434 | add(value) {
|
---|
1435 | if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
---|
1436 | value = toRaw(value);
|
---|
1437 | }
|
---|
1438 | const target = toRaw(this);
|
---|
1439 | const proto = getProto(target);
|
---|
1440 | const hadKey = proto.has.call(target, value);
|
---|
1441 | if (!hadKey) {
|
---|
1442 | target.add(value);
|
---|
1443 | trigger(target, "add", value, value);
|
---|
1444 | }
|
---|
1445 | return this;
|
---|
1446 | },
|
---|
1447 | set(key, value) {
|
---|
1448 | if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
---|
1449 | value = toRaw(value);
|
---|
1450 | }
|
---|
1451 | const target = toRaw(this);
|
---|
1452 | const { has, get } = getProto(target);
|
---|
1453 | let hadKey = has.call(target, key);
|
---|
1454 | if (!hadKey) {
|
---|
1455 | key = toRaw(key);
|
---|
1456 | hadKey = has.call(target, key);
|
---|
1457 | } else {
|
---|
1458 | checkIdentityKeys(target, has, key);
|
---|
1459 | }
|
---|
1460 | const oldValue = get.call(target, key);
|
---|
1461 | target.set(key, value);
|
---|
1462 | if (!hadKey) {
|
---|
1463 | trigger(target, "add", key, value);
|
---|
1464 | } else if (hasChanged(value, oldValue)) {
|
---|
1465 | trigger(target, "set", key, value, oldValue);
|
---|
1466 | }
|
---|
1467 | return this;
|
---|
1468 | },
|
---|
1469 | delete(key) {
|
---|
1470 | const target = toRaw(this);
|
---|
1471 | const { has, get } = getProto(target);
|
---|
1472 | let hadKey = has.call(target, key);
|
---|
1473 | if (!hadKey) {
|
---|
1474 | key = toRaw(key);
|
---|
1475 | hadKey = has.call(target, key);
|
---|
1476 | } else {
|
---|
1477 | checkIdentityKeys(target, has, key);
|
---|
1478 | }
|
---|
1479 | const oldValue = get ? get.call(target, key) : void 0;
|
---|
1480 | const result = target.delete(key);
|
---|
1481 | if (hadKey) {
|
---|
1482 | trigger(target, "delete", key, void 0, oldValue);
|
---|
1483 | }
|
---|
1484 | return result;
|
---|
1485 | },
|
---|
1486 | clear() {
|
---|
1487 | const target = toRaw(this);
|
---|
1488 | const hadItems = target.size !== 0;
|
---|
1489 | const oldTarget = isMap(target) ? new Map(target) : new Set(target) ;
|
---|
1490 | const result = target.clear();
|
---|
1491 | if (hadItems) {
|
---|
1492 | trigger(
|
---|
1493 | target,
|
---|
1494 | "clear",
|
---|
1495 | void 0,
|
---|
1496 | void 0,
|
---|
1497 | oldTarget
|
---|
1498 | );
|
---|
1499 | }
|
---|
1500 | return result;
|
---|
1501 | }
|
---|
1502 | }
|
---|
1503 | );
|
---|
1504 | const iteratorMethods = [
|
---|
1505 | "keys",
|
---|
1506 | "values",
|
---|
1507 | "entries",
|
---|
1508 | Symbol.iterator
|
---|
1509 | ];
|
---|
1510 | iteratorMethods.forEach((method) => {
|
---|
1511 | instrumentations[method] = createIterableMethod(method, readonly, shallow);
|
---|
1512 | });
|
---|
1513 | return instrumentations;
|
---|
1514 | }
|
---|
1515 | function createInstrumentationGetter(isReadonly2, shallow) {
|
---|
1516 | const instrumentations = createInstrumentations(isReadonly2, shallow);
|
---|
1517 | return (target, key, receiver) => {
|
---|
1518 | if (key === "__v_isReactive") {
|
---|
1519 | return !isReadonly2;
|
---|
1520 | } else if (key === "__v_isReadonly") {
|
---|
1521 | return isReadonly2;
|
---|
1522 | } else if (key === "__v_raw") {
|
---|
1523 | return target;
|
---|
1524 | }
|
---|
1525 | return Reflect.get(
|
---|
1526 | hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
---|
1527 | key,
|
---|
1528 | receiver
|
---|
1529 | );
|
---|
1530 | };
|
---|
1531 | }
|
---|
1532 | const mutableCollectionHandlers = {
|
---|
1533 | get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
---|
1534 | };
|
---|
1535 | const shallowCollectionHandlers = {
|
---|
1536 | get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
---|
1537 | };
|
---|
1538 | const readonlyCollectionHandlers = {
|
---|
1539 | get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
---|
1540 | };
|
---|
1541 | const shallowReadonlyCollectionHandlers = {
|
---|
1542 | get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
---|
1543 | };
|
---|
1544 | function checkIdentityKeys(target, has, key) {
|
---|
1545 | const rawKey = toRaw(key);
|
---|
1546 | if (rawKey !== key && has.call(target, rawKey)) {
|
---|
1547 | const type = toRawType(target);
|
---|
1548 | warn$2(
|
---|
1549 | `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.`
|
---|
1550 | );
|
---|
1551 | }
|
---|
1552 | }
|
---|
1553 |
|
---|
1554 | const reactiveMap = /* @__PURE__ */ new WeakMap();
|
---|
1555 | const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
---|
1556 | const readonlyMap = /* @__PURE__ */ new WeakMap();
|
---|
1557 | const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
---|
1558 | function targetTypeMap(rawType) {
|
---|
1559 | switch (rawType) {
|
---|
1560 | case "Object":
|
---|
1561 | case "Array":
|
---|
1562 | return 1 /* COMMON */;
|
---|
1563 | case "Map":
|
---|
1564 | case "Set":
|
---|
1565 | case "WeakMap":
|
---|
1566 | case "WeakSet":
|
---|
1567 | return 2 /* COLLECTION */;
|
---|
1568 | default:
|
---|
1569 | return 0 /* INVALID */;
|
---|
1570 | }
|
---|
1571 | }
|
---|
1572 | function getTargetType(value) {
|
---|
1573 | return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value));
|
---|
1574 | }
|
---|
1575 | function reactive(target) {
|
---|
1576 | if (isReadonly(target)) {
|
---|
1577 | return target;
|
---|
1578 | }
|
---|
1579 | return createReactiveObject(
|
---|
1580 | target,
|
---|
1581 | false,
|
---|
1582 | mutableHandlers,
|
---|
1583 | mutableCollectionHandlers,
|
---|
1584 | reactiveMap
|
---|
1585 | );
|
---|
1586 | }
|
---|
1587 | function shallowReactive(target) {
|
---|
1588 | return createReactiveObject(
|
---|
1589 | target,
|
---|
1590 | false,
|
---|
1591 | shallowReactiveHandlers,
|
---|
1592 | shallowCollectionHandlers,
|
---|
1593 | shallowReactiveMap
|
---|
1594 | );
|
---|
1595 | }
|
---|
1596 | function readonly(target) {
|
---|
1597 | return createReactiveObject(
|
---|
1598 | target,
|
---|
1599 | true,
|
---|
1600 | readonlyHandlers,
|
---|
1601 | readonlyCollectionHandlers,
|
---|
1602 | readonlyMap
|
---|
1603 | );
|
---|
1604 | }
|
---|
1605 | function shallowReadonly(target) {
|
---|
1606 | return createReactiveObject(
|
---|
1607 | target,
|
---|
1608 | true,
|
---|
1609 | shallowReadonlyHandlers,
|
---|
1610 | shallowReadonlyCollectionHandlers,
|
---|
1611 | shallowReadonlyMap
|
---|
1612 | );
|
---|
1613 | }
|
---|
1614 | function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
---|
1615 | if (!isObject(target)) {
|
---|
1616 | {
|
---|
1617 | warn$2(
|
---|
1618 | `value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
|
---|
1619 | target
|
---|
1620 | )}`
|
---|
1621 | );
|
---|
1622 | }
|
---|
1623 | return target;
|
---|
1624 | }
|
---|
1625 | if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
---|
1626 | return target;
|
---|
1627 | }
|
---|
1628 | const existingProxy = proxyMap.get(target);
|
---|
1629 | if (existingProxy) {
|
---|
1630 | return existingProxy;
|
---|
1631 | }
|
---|
1632 | const targetType = getTargetType(target);
|
---|
1633 | if (targetType === 0 /* INVALID */) {
|
---|
1634 | return target;
|
---|
1635 | }
|
---|
1636 | const proxy = new Proxy(
|
---|
1637 | target,
|
---|
1638 | targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
|
---|
1639 | );
|
---|
1640 | proxyMap.set(target, proxy);
|
---|
1641 | return proxy;
|
---|
1642 | }
|
---|
1643 | function isReactive(value) {
|
---|
1644 | if (isReadonly(value)) {
|
---|
1645 | return isReactive(value["__v_raw"]);
|
---|
1646 | }
|
---|
1647 | return !!(value && value["__v_isReactive"]);
|
---|
1648 | }
|
---|
1649 | function isReadonly(value) {
|
---|
1650 | return !!(value && value["__v_isReadonly"]);
|
---|
1651 | }
|
---|
1652 | function isShallow(value) {
|
---|
1653 | return !!(value && value["__v_isShallow"]);
|
---|
1654 | }
|
---|
1655 | function isProxy(value) {
|
---|
1656 | return value ? !!value["__v_raw"] : false;
|
---|
1657 | }
|
---|
1658 | function toRaw(observed) {
|
---|
1659 | const raw = observed && observed["__v_raw"];
|
---|
1660 | return raw ? toRaw(raw) : observed;
|
---|
1661 | }
|
---|
1662 | function markRaw(value) {
|
---|
1663 | if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
|
---|
1664 | def(value, "__v_skip", true);
|
---|
1665 | }
|
---|
1666 | return value;
|
---|
1667 | }
|
---|
1668 | const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
---|
1669 | const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
---|
1670 |
|
---|
1671 | function isRef(r) {
|
---|
1672 | return r ? r["__v_isRef"] === true : false;
|
---|
1673 | }
|
---|
1674 | function unref(ref2) {
|
---|
1675 | return isRef(ref2) ? ref2.value : ref2;
|
---|
1676 | }
|
---|
1677 | const shallowUnwrapHandlers = {
|
---|
1678 | get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
|
---|
1679 | set: (target, key, value, receiver) => {
|
---|
1680 | const oldValue = target[key];
|
---|
1681 | if (isRef(oldValue) && !isRef(value)) {
|
---|
1682 | oldValue.value = value;
|
---|
1683 | return true;
|
---|
1684 | } else {
|
---|
1685 | return Reflect.set(target, key, value, receiver);
|
---|
1686 | }
|
---|
1687 | }
|
---|
1688 | };
|
---|
1689 | function proxyRefs(objectWithRefs) {
|
---|
1690 | return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
---|
1691 | }
|
---|
1692 |
|
---|
1693 | class ComputedRefImpl {
|
---|
1694 | constructor(fn, setter, isSSR) {
|
---|
1695 | this.fn = fn;
|
---|
1696 | this.setter = setter;
|
---|
1697 | /**
|
---|
1698 | * @internal
|
---|
1699 | */
|
---|
1700 | this._value = void 0;
|
---|
1701 | /**
|
---|
1702 | * @internal
|
---|
1703 | */
|
---|
1704 | this.dep = new Dep(this);
|
---|
1705 | /**
|
---|
1706 | * @internal
|
---|
1707 | */
|
---|
1708 | this.__v_isRef = true;
|
---|
1709 | // TODO isolatedDeclarations "__v_isReadonly"
|
---|
1710 | // A computed is also a subscriber that tracks other deps
|
---|
1711 | /**
|
---|
1712 | * @internal
|
---|
1713 | */
|
---|
1714 | this.deps = void 0;
|
---|
1715 | /**
|
---|
1716 | * @internal
|
---|
1717 | */
|
---|
1718 | this.depsTail = void 0;
|
---|
1719 | /**
|
---|
1720 | * @internal
|
---|
1721 | */
|
---|
1722 | this.flags = 16;
|
---|
1723 | /**
|
---|
1724 | * @internal
|
---|
1725 | */
|
---|
1726 | this.globalVersion = globalVersion - 1;
|
---|
1727 | /**
|
---|
1728 | * @internal
|
---|
1729 | */
|
---|
1730 | this.next = void 0;
|
---|
1731 | // for backwards compat
|
---|
1732 | this.effect = this;
|
---|
1733 | this["__v_isReadonly"] = !setter;
|
---|
1734 | this.isSSR = isSSR;
|
---|
1735 | }
|
---|
1736 | /**
|
---|
1737 | * @internal
|
---|
1738 | */
|
---|
1739 | notify() {
|
---|
1740 | this.flags |= 16;
|
---|
1741 | if (!(this.flags & 8) && // avoid infinite self recursion
|
---|
1742 | activeSub !== this) {
|
---|
1743 | batch(this, true);
|
---|
1744 | return true;
|
---|
1745 | }
|
---|
1746 | }
|
---|
1747 | get value() {
|
---|
1748 | const link = this.dep.track({
|
---|
1749 | target: this,
|
---|
1750 | type: "get",
|
---|
1751 | key: "value"
|
---|
1752 | }) ;
|
---|
1753 | refreshComputed(this);
|
---|
1754 | if (link) {
|
---|
1755 | link.version = this.dep.version;
|
---|
1756 | }
|
---|
1757 | return this._value;
|
---|
1758 | }
|
---|
1759 | set value(newValue) {
|
---|
1760 | if (this.setter) {
|
---|
1761 | this.setter(newValue);
|
---|
1762 | } else {
|
---|
1763 | warn$2("Write operation failed: computed value is readonly");
|
---|
1764 | }
|
---|
1765 | }
|
---|
1766 | }
|
---|
1767 | function computed$1(getterOrOptions, debugOptions, isSSR = false) {
|
---|
1768 | let getter;
|
---|
1769 | let setter;
|
---|
1770 | if (isFunction(getterOrOptions)) {
|
---|
1771 | getter = getterOrOptions;
|
---|
1772 | } else {
|
---|
1773 | getter = getterOrOptions.get;
|
---|
1774 | setter = getterOrOptions.set;
|
---|
1775 | }
|
---|
1776 | const cRef = new ComputedRefImpl(getter, setter, isSSR);
|
---|
1777 | return cRef;
|
---|
1778 | }
|
---|
1779 |
|
---|
1780 | const INITIAL_WATCHER_VALUE = {};
|
---|
1781 | const cleanupMap = /* @__PURE__ */ new WeakMap();
|
---|
1782 | let activeWatcher = void 0;
|
---|
1783 | function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
|
---|
1784 | if (owner) {
|
---|
1785 | let cleanups = cleanupMap.get(owner);
|
---|
1786 | if (!cleanups) cleanupMap.set(owner, cleanups = []);
|
---|
1787 | cleanups.push(cleanupFn);
|
---|
1788 | } else if (!failSilently) {
|
---|
1789 | warn$2(
|
---|
1790 | `onWatcherCleanup() was called when there was no active watcher to associate with.`
|
---|
1791 | );
|
---|
1792 | }
|
---|
1793 | }
|
---|
1794 | function watch$1(source, cb, options = EMPTY_OBJ) {
|
---|
1795 | const { immediate, deep, once, scheduler, augmentJob, call } = options;
|
---|
1796 | const warnInvalidSource = (s) => {
|
---|
1797 | (options.onWarn || warn$2)(
|
---|
1798 | `Invalid watch source: `,
|
---|
1799 | s,
|
---|
1800 | `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
|
---|
1801 | );
|
---|
1802 | };
|
---|
1803 | const reactiveGetter = (source2) => {
|
---|
1804 | if (deep) return source2;
|
---|
1805 | if (isShallow(source2) || deep === false || deep === 0)
|
---|
1806 | return traverse(source2, 1);
|
---|
1807 | return traverse(source2);
|
---|
1808 | };
|
---|
1809 | let effect;
|
---|
1810 | let getter;
|
---|
1811 | let cleanup;
|
---|
1812 | let boundCleanup;
|
---|
1813 | let forceTrigger = false;
|
---|
1814 | let isMultiSource = false;
|
---|
1815 | if (isRef(source)) {
|
---|
1816 | getter = () => source.value;
|
---|
1817 | forceTrigger = isShallow(source);
|
---|
1818 | } else if (isReactive(source)) {
|
---|
1819 | getter = () => reactiveGetter(source);
|
---|
1820 | forceTrigger = true;
|
---|
1821 | } else if (isArray(source)) {
|
---|
1822 | isMultiSource = true;
|
---|
1823 | forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
---|
1824 | getter = () => source.map((s) => {
|
---|
1825 | if (isRef(s)) {
|
---|
1826 | return s.value;
|
---|
1827 | } else if (isReactive(s)) {
|
---|
1828 | return reactiveGetter(s);
|
---|
1829 | } else if (isFunction(s)) {
|
---|
1830 | return call ? call(s, 2) : s();
|
---|
1831 | } else {
|
---|
1832 | warnInvalidSource(s);
|
---|
1833 | }
|
---|
1834 | });
|
---|
1835 | } else if (isFunction(source)) {
|
---|
1836 | if (cb) {
|
---|
1837 | getter = call ? () => call(source, 2) : source;
|
---|
1838 | } else {
|
---|
1839 | getter = () => {
|
---|
1840 | if (cleanup) {
|
---|
1841 | pauseTracking();
|
---|
1842 | try {
|
---|
1843 | cleanup();
|
---|
1844 | } finally {
|
---|
1845 | resetTracking();
|
---|
1846 | }
|
---|
1847 | }
|
---|
1848 | const currentEffect = activeWatcher;
|
---|
1849 | activeWatcher = effect;
|
---|
1850 | try {
|
---|
1851 | return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
|
---|
1852 | } finally {
|
---|
1853 | activeWatcher = currentEffect;
|
---|
1854 | }
|
---|
1855 | };
|
---|
1856 | }
|
---|
1857 | } else {
|
---|
1858 | getter = NOOP;
|
---|
1859 | warnInvalidSource(source);
|
---|
1860 | }
|
---|
1861 | if (cb && deep) {
|
---|
1862 | const baseGetter = getter;
|
---|
1863 | const depth = deep === true ? Infinity : deep;
|
---|
1864 | getter = () => traverse(baseGetter(), depth);
|
---|
1865 | }
|
---|
1866 | const scope = getCurrentScope();
|
---|
1867 | const watchHandle = () => {
|
---|
1868 | effect.stop();
|
---|
1869 | if (scope && scope.active) {
|
---|
1870 | remove(scope.effects, effect);
|
---|
1871 | }
|
---|
1872 | };
|
---|
1873 | if (once && cb) {
|
---|
1874 | const _cb = cb;
|
---|
1875 | cb = (...args) => {
|
---|
1876 | _cb(...args);
|
---|
1877 | watchHandle();
|
---|
1878 | };
|
---|
1879 | }
|
---|
1880 | let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
---|
1881 | const job = (immediateFirstRun) => {
|
---|
1882 | if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
|
---|
1883 | return;
|
---|
1884 | }
|
---|
1885 | if (cb) {
|
---|
1886 | const newValue = effect.run();
|
---|
1887 | if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
|
---|
1888 | if (cleanup) {
|
---|
1889 | cleanup();
|
---|
1890 | }
|
---|
1891 | const currentWatcher = activeWatcher;
|
---|
1892 | activeWatcher = effect;
|
---|
1893 | try {
|
---|
1894 | const args = [
|
---|
1895 | newValue,
|
---|
1896 | // pass undefined as the old value when it's changed for the first time
|
---|
1897 | oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
---|
1898 | boundCleanup
|
---|
1899 | ];
|
---|
1900 | call ? call(cb, 3, args) : (
|
---|
1901 | // @ts-expect-error
|
---|
1902 | cb(...args)
|
---|
1903 | );
|
---|
1904 | oldValue = newValue;
|
---|
1905 | } finally {
|
---|
1906 | activeWatcher = currentWatcher;
|
---|
1907 | }
|
---|
1908 | }
|
---|
1909 | } else {
|
---|
1910 | effect.run();
|
---|
1911 | }
|
---|
1912 | };
|
---|
1913 | if (augmentJob) {
|
---|
1914 | augmentJob(job);
|
---|
1915 | }
|
---|
1916 | effect = new ReactiveEffect(getter);
|
---|
1917 | effect.scheduler = scheduler ? () => scheduler(job, false) : job;
|
---|
1918 | boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
|
---|
1919 | cleanup = effect.onStop = () => {
|
---|
1920 | const cleanups = cleanupMap.get(effect);
|
---|
1921 | if (cleanups) {
|
---|
1922 | if (call) {
|
---|
1923 | call(cleanups, 4);
|
---|
1924 | } else {
|
---|
1925 | for (const cleanup2 of cleanups) cleanup2();
|
---|
1926 | }
|
---|
1927 | cleanupMap.delete(effect);
|
---|
1928 | }
|
---|
1929 | };
|
---|
1930 | {
|
---|
1931 | effect.onTrack = options.onTrack;
|
---|
1932 | effect.onTrigger = options.onTrigger;
|
---|
1933 | }
|
---|
1934 | if (cb) {
|
---|
1935 | if (immediate) {
|
---|
1936 | job(true);
|
---|
1937 | } else {
|
---|
1938 | oldValue = effect.run();
|
---|
1939 | }
|
---|
1940 | } else if (scheduler) {
|
---|
1941 | scheduler(job.bind(null, true), true);
|
---|
1942 | } else {
|
---|
1943 | effect.run();
|
---|
1944 | }
|
---|
1945 | watchHandle.pause = effect.pause.bind(effect);
|
---|
1946 | watchHandle.resume = effect.resume.bind(effect);
|
---|
1947 | watchHandle.stop = watchHandle;
|
---|
1948 | return watchHandle;
|
---|
1949 | }
|
---|
1950 | function traverse(value, depth = Infinity, seen) {
|
---|
1951 | if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
|
---|
1952 | return value;
|
---|
1953 | }
|
---|
1954 | seen = seen || /* @__PURE__ */ new Set();
|
---|
1955 | if (seen.has(value)) {
|
---|
1956 | return value;
|
---|
1957 | }
|
---|
1958 | seen.add(value);
|
---|
1959 | depth--;
|
---|
1960 | if (isRef(value)) {
|
---|
1961 | traverse(value.value, depth, seen);
|
---|
1962 | } else if (isArray(value)) {
|
---|
1963 | for (let i = 0; i < value.length; i++) {
|
---|
1964 | traverse(value[i], depth, seen);
|
---|
1965 | }
|
---|
1966 | } else if (isSet(value) || isMap(value)) {
|
---|
1967 | value.forEach((v) => {
|
---|
1968 | traverse(v, depth, seen);
|
---|
1969 | });
|
---|
1970 | } else if (isPlainObject(value)) {
|
---|
1971 | for (const key in value) {
|
---|
1972 | traverse(value[key], depth, seen);
|
---|
1973 | }
|
---|
1974 | for (const key of Object.getOwnPropertySymbols(value)) {
|
---|
1975 | if (Object.prototype.propertyIsEnumerable.call(value, key)) {
|
---|
1976 | traverse(value[key], depth, seen);
|
---|
1977 | }
|
---|
1978 | }
|
---|
1979 | }
|
---|
1980 | return value;
|
---|
1981 | }
|
---|
1982 |
|
---|
1983 | const stack = [];
|
---|
1984 | function pushWarningContext$1(vnode) {
|
---|
1985 | stack.push(vnode);
|
---|
1986 | }
|
---|
1987 | function popWarningContext$1() {
|
---|
1988 | stack.pop();
|
---|
1989 | }
|
---|
1990 | let isWarning = false;
|
---|
1991 | function warn$1(msg, ...args) {
|
---|
1992 | if (isWarning) return;
|
---|
1993 | isWarning = true;
|
---|
1994 | pauseTracking();
|
---|
1995 | const instance = stack.length ? stack[stack.length - 1].component : null;
|
---|
1996 | const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
---|
1997 | const trace = getComponentTrace();
|
---|
1998 | if (appWarnHandler) {
|
---|
1999 | callWithErrorHandling(
|
---|
2000 | appWarnHandler,
|
---|
2001 | instance,
|
---|
2002 | 11,
|
---|
2003 | [
|
---|
2004 | // eslint-disable-next-line no-restricted-syntax
|
---|
2005 | msg + args.map((a) => {
|
---|
2006 | var _a, _b;
|
---|
2007 | return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
|
---|
2008 | }).join(""),
|
---|
2009 | instance && instance.proxy,
|
---|
2010 | trace.map(
|
---|
2011 | ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
|
---|
2012 | ).join("\n"),
|
---|
2013 | trace
|
---|
2014 | ]
|
---|
2015 | );
|
---|
2016 | } else {
|
---|
2017 | const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
---|
2018 | if (trace.length && // avoid spamming console during tests
|
---|
2019 | true) {
|
---|
2020 | warnArgs.push(`
|
---|
2021 | `, ...formatTrace(trace));
|
---|
2022 | }
|
---|
2023 | console.warn(...warnArgs);
|
---|
2024 | }
|
---|
2025 | resetTracking();
|
---|
2026 | isWarning = false;
|
---|
2027 | }
|
---|
2028 | function getComponentTrace() {
|
---|
2029 | let currentVNode = stack[stack.length - 1];
|
---|
2030 | if (!currentVNode) {
|
---|
2031 | return [];
|
---|
2032 | }
|
---|
2033 | const normalizedStack = [];
|
---|
2034 | while (currentVNode) {
|
---|
2035 | const last = normalizedStack[0];
|
---|
2036 | if (last && last.vnode === currentVNode) {
|
---|
2037 | last.recurseCount++;
|
---|
2038 | } else {
|
---|
2039 | normalizedStack.push({
|
---|
2040 | vnode: currentVNode,
|
---|
2041 | recurseCount: 0
|
---|
2042 | });
|
---|
2043 | }
|
---|
2044 | const parentInstance = currentVNode.component && currentVNode.component.parent;
|
---|
2045 | currentVNode = parentInstance && parentInstance.vnode;
|
---|
2046 | }
|
---|
2047 | return normalizedStack;
|
---|
2048 | }
|
---|
2049 | function formatTrace(trace) {
|
---|
2050 | const logs = [];
|
---|
2051 | trace.forEach((entry, i) => {
|
---|
2052 | logs.push(...i === 0 ? [] : [`
|
---|
2053 | `], ...formatTraceEntry(entry));
|
---|
2054 | });
|
---|
2055 | return logs;
|
---|
2056 | }
|
---|
2057 | function formatTraceEntry({ vnode, recurseCount }) {
|
---|
2058 | const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
---|
2059 | const isRoot = vnode.component ? vnode.component.parent == null : false;
|
---|
2060 | const open = ` at <${formatComponentName(
|
---|
2061 | vnode.component,
|
---|
2062 | vnode.type,
|
---|
2063 | isRoot
|
---|
2064 | )}`;
|
---|
2065 | const close = `>` + postfix;
|
---|
2066 | return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
|
---|
2067 | }
|
---|
2068 | function formatProps(props) {
|
---|
2069 | const res = [];
|
---|
2070 | const keys = Object.keys(props);
|
---|
2071 | keys.slice(0, 3).forEach((key) => {
|
---|
2072 | res.push(...formatProp(key, props[key]));
|
---|
2073 | });
|
---|
2074 | if (keys.length > 3) {
|
---|
2075 | res.push(` ...`);
|
---|
2076 | }
|
---|
2077 | return res;
|
---|
2078 | }
|
---|
2079 | function formatProp(key, value, raw) {
|
---|
2080 | if (isString(value)) {
|
---|
2081 | value = JSON.stringify(value);
|
---|
2082 | return raw ? value : [`${key}=${value}`];
|
---|
2083 | } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
---|
2084 | return raw ? value : [`${key}=${value}`];
|
---|
2085 | } else if (isRef(value)) {
|
---|
2086 | value = formatProp(key, toRaw(value.value), true);
|
---|
2087 | return raw ? value : [`${key}=Ref<`, value, `>`];
|
---|
2088 | } else if (isFunction(value)) {
|
---|
2089 | return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
---|
2090 | } else {
|
---|
2091 | value = toRaw(value);
|
---|
2092 | return raw ? value : [`${key}=`, value];
|
---|
2093 | }
|
---|
2094 | }
|
---|
2095 |
|
---|
2096 | const ErrorTypeStrings = {
|
---|
2097 | ["sp"]: "serverPrefetch hook",
|
---|
2098 | ["bc"]: "beforeCreate hook",
|
---|
2099 | ["c"]: "created hook",
|
---|
2100 | ["bm"]: "beforeMount hook",
|
---|
2101 | ["m"]: "mounted hook",
|
---|
2102 | ["bu"]: "beforeUpdate hook",
|
---|
2103 | ["u"]: "updated",
|
---|
2104 | ["bum"]: "beforeUnmount hook",
|
---|
2105 | ["um"]: "unmounted hook",
|
---|
2106 | ["a"]: "activated hook",
|
---|
2107 | ["da"]: "deactivated hook",
|
---|
2108 | ["ec"]: "errorCaptured hook",
|
---|
2109 | ["rtc"]: "renderTracked hook",
|
---|
2110 | ["rtg"]: "renderTriggered hook",
|
---|
2111 | [0]: "setup function",
|
---|
2112 | [1]: "render function",
|
---|
2113 | [2]: "watcher getter",
|
---|
2114 | [3]: "watcher callback",
|
---|
2115 | [4]: "watcher cleanup function",
|
---|
2116 | [5]: "native event handler",
|
---|
2117 | [6]: "component event handler",
|
---|
2118 | [7]: "vnode hook",
|
---|
2119 | [8]: "directive hook",
|
---|
2120 | [9]: "transition hook",
|
---|
2121 | [10]: "app errorHandler",
|
---|
2122 | [11]: "app warnHandler",
|
---|
2123 | [12]: "ref function",
|
---|
2124 | [13]: "async component loader",
|
---|
2125 | [14]: "scheduler flush",
|
---|
2126 | [15]: "component update",
|
---|
2127 | [16]: "app unmount cleanup function"
|
---|
2128 | };
|
---|
2129 | function callWithErrorHandling(fn, instance, type, args) {
|
---|
2130 | try {
|
---|
2131 | return args ? fn(...args) : fn();
|
---|
2132 | } catch (err) {
|
---|
2133 | handleError(err, instance, type);
|
---|
2134 | }
|
---|
2135 | }
|
---|
2136 | function callWithAsyncErrorHandling(fn, instance, type, args) {
|
---|
2137 | if (isFunction(fn)) {
|
---|
2138 | const res = callWithErrorHandling(fn, instance, type, args);
|
---|
2139 | if (res && isPromise(res)) {
|
---|
2140 | res.catch((err) => {
|
---|
2141 | handleError(err, instance, type);
|
---|
2142 | });
|
---|
2143 | }
|
---|
2144 | return res;
|
---|
2145 | }
|
---|
2146 | if (isArray(fn)) {
|
---|
2147 | const values = [];
|
---|
2148 | for (let i = 0; i < fn.length; i++) {
|
---|
2149 | values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
---|
2150 | }
|
---|
2151 | return values;
|
---|
2152 | } else {
|
---|
2153 | warn$1(
|
---|
2154 | `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`
|
---|
2155 | );
|
---|
2156 | }
|
---|
2157 | }
|
---|
2158 | function handleError(err, instance, type, throwInDev = true) {
|
---|
2159 | const contextVNode = instance ? instance.vnode : null;
|
---|
2160 | const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || EMPTY_OBJ;
|
---|
2161 | if (instance) {
|
---|
2162 | let cur = instance.parent;
|
---|
2163 | const exposedInstance = instance.proxy;
|
---|
2164 | const errorInfo = ErrorTypeStrings[type] ;
|
---|
2165 | while (cur) {
|
---|
2166 | const errorCapturedHooks = cur.ec;
|
---|
2167 | if (errorCapturedHooks) {
|
---|
2168 | for (let i = 0; i < errorCapturedHooks.length; i++) {
|
---|
2169 | if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
---|
2170 | return;
|
---|
2171 | }
|
---|
2172 | }
|
---|
2173 | }
|
---|
2174 | cur = cur.parent;
|
---|
2175 | }
|
---|
2176 | if (errorHandler) {
|
---|
2177 | pauseTracking();
|
---|
2178 | callWithErrorHandling(errorHandler, null, 10, [
|
---|
2179 | err,
|
---|
2180 | exposedInstance,
|
---|
2181 | errorInfo
|
---|
2182 | ]);
|
---|
2183 | resetTracking();
|
---|
2184 | return;
|
---|
2185 | }
|
---|
2186 | }
|
---|
2187 | logError(err, type, contextVNode, throwInDev, throwUnhandledErrorInProduction);
|
---|
2188 | }
|
---|
2189 | function logError(err, type, contextVNode, throwInDev = true, throwInProd = false) {
|
---|
2190 | {
|
---|
2191 | const info = ErrorTypeStrings[type];
|
---|
2192 | if (contextVNode) {
|
---|
2193 | pushWarningContext$1(contextVNode);
|
---|
2194 | }
|
---|
2195 | warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
---|
2196 | if (contextVNode) {
|
---|
2197 | popWarningContext$1();
|
---|
2198 | }
|
---|
2199 | if (throwInDev) {
|
---|
2200 | throw err;
|
---|
2201 | } else {
|
---|
2202 | console.error(err);
|
---|
2203 | }
|
---|
2204 | }
|
---|
2205 | }
|
---|
2206 |
|
---|
2207 | const queue = [];
|
---|
2208 | let flushIndex = -1;
|
---|
2209 | const pendingPostFlushCbs = [];
|
---|
2210 | let activePostFlushCbs = null;
|
---|
2211 | let postFlushIndex = 0;
|
---|
2212 | const resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
---|
2213 | let currentFlushPromise = null;
|
---|
2214 | const RECURSION_LIMIT = 100;
|
---|
2215 | function nextTick(fn) {
|
---|
2216 | const p = currentFlushPromise || resolvedPromise;
|
---|
2217 | return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
---|
2218 | }
|
---|
2219 | function findInsertionIndex(id) {
|
---|
2220 | let start = flushIndex + 1;
|
---|
2221 | let end = queue.length;
|
---|
2222 | while (start < end) {
|
---|
2223 | const middle = start + end >>> 1;
|
---|
2224 | const middleJob = queue[middle];
|
---|
2225 | const middleJobId = getId(middleJob);
|
---|
2226 | if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
|
---|
2227 | start = middle + 1;
|
---|
2228 | } else {
|
---|
2229 | end = middle;
|
---|
2230 | }
|
---|
2231 | }
|
---|
2232 | return start;
|
---|
2233 | }
|
---|
2234 | function queueJob(job) {
|
---|
2235 | if (!(job.flags & 1)) {
|
---|
2236 | const jobId = getId(job);
|
---|
2237 | const lastJob = queue[queue.length - 1];
|
---|
2238 | if (!lastJob || // fast path when the job id is larger than the tail
|
---|
2239 | !(job.flags & 2) && jobId >= getId(lastJob)) {
|
---|
2240 | queue.push(job);
|
---|
2241 | } else {
|
---|
2242 | queue.splice(findInsertionIndex(jobId), 0, job);
|
---|
2243 | }
|
---|
2244 | job.flags |= 1;
|
---|
2245 | queueFlush();
|
---|
2246 | }
|
---|
2247 | }
|
---|
2248 | function queueFlush() {
|
---|
2249 | if (!currentFlushPromise) {
|
---|
2250 | currentFlushPromise = resolvedPromise.then(flushJobs);
|
---|
2251 | }
|
---|
2252 | }
|
---|
2253 | function queuePostFlushCb(cb) {
|
---|
2254 | if (!isArray(cb)) {
|
---|
2255 | if (activePostFlushCbs && cb.id === -1) {
|
---|
2256 | activePostFlushCbs.splice(postFlushIndex + 1, 0, cb);
|
---|
2257 | } else if (!(cb.flags & 1)) {
|
---|
2258 | pendingPostFlushCbs.push(cb);
|
---|
2259 | cb.flags |= 1;
|
---|
2260 | }
|
---|
2261 | } else {
|
---|
2262 | pendingPostFlushCbs.push(...cb);
|
---|
2263 | }
|
---|
2264 | queueFlush();
|
---|
2265 | }
|
---|
2266 | function flushPreFlushCbs(instance, seen, i = flushIndex + 1) {
|
---|
2267 | {
|
---|
2268 | seen = seen || /* @__PURE__ */ new Map();
|
---|
2269 | }
|
---|
2270 | for (; i < queue.length; i++) {
|
---|
2271 | const cb = queue[i];
|
---|
2272 | if (cb && cb.flags & 2) {
|
---|
2273 | if (instance && cb.id !== instance.uid) {
|
---|
2274 | continue;
|
---|
2275 | }
|
---|
2276 | if (checkRecursiveUpdates(seen, cb)) {
|
---|
2277 | continue;
|
---|
2278 | }
|
---|
2279 | queue.splice(i, 1);
|
---|
2280 | i--;
|
---|
2281 | if (cb.flags & 4) {
|
---|
2282 | cb.flags &= ~1;
|
---|
2283 | }
|
---|
2284 | cb();
|
---|
2285 | if (!(cb.flags & 4)) {
|
---|
2286 | cb.flags &= ~1;
|
---|
2287 | }
|
---|
2288 | }
|
---|
2289 | }
|
---|
2290 | }
|
---|
2291 | function flushPostFlushCbs(seen) {
|
---|
2292 | if (pendingPostFlushCbs.length) {
|
---|
2293 | const deduped = [...new Set(pendingPostFlushCbs)].sort(
|
---|
2294 | (a, b) => getId(a) - getId(b)
|
---|
2295 | );
|
---|
2296 | pendingPostFlushCbs.length = 0;
|
---|
2297 | if (activePostFlushCbs) {
|
---|
2298 | activePostFlushCbs.push(...deduped);
|
---|
2299 | return;
|
---|
2300 | }
|
---|
2301 | activePostFlushCbs = deduped;
|
---|
2302 | {
|
---|
2303 | seen = seen || /* @__PURE__ */ new Map();
|
---|
2304 | }
|
---|
2305 | for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
---|
2306 | const cb = activePostFlushCbs[postFlushIndex];
|
---|
2307 | if (checkRecursiveUpdates(seen, cb)) {
|
---|
2308 | continue;
|
---|
2309 | }
|
---|
2310 | if (cb.flags & 4) {
|
---|
2311 | cb.flags &= ~1;
|
---|
2312 | }
|
---|
2313 | if (!(cb.flags & 8)) cb();
|
---|
2314 | cb.flags &= ~1;
|
---|
2315 | }
|
---|
2316 | activePostFlushCbs = null;
|
---|
2317 | postFlushIndex = 0;
|
---|
2318 | }
|
---|
2319 | }
|
---|
2320 | const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
|
---|
2321 | function flushJobs(seen) {
|
---|
2322 | {
|
---|
2323 | seen = seen || /* @__PURE__ */ new Map();
|
---|
2324 | }
|
---|
2325 | const check = (job) => checkRecursiveUpdates(seen, job) ;
|
---|
2326 | try {
|
---|
2327 | for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
---|
2328 | const job = queue[flushIndex];
|
---|
2329 | if (job && !(job.flags & 8)) {
|
---|
2330 | if (check(job)) {
|
---|
2331 | continue;
|
---|
2332 | }
|
---|
2333 | if (job.flags & 4) {
|
---|
2334 | job.flags &= ~1;
|
---|
2335 | }
|
---|
2336 | callWithErrorHandling(
|
---|
2337 | job,
|
---|
2338 | job.i,
|
---|
2339 | job.i ? 15 : 14
|
---|
2340 | );
|
---|
2341 | if (!(job.flags & 4)) {
|
---|
2342 | job.flags &= ~1;
|
---|
2343 | }
|
---|
2344 | }
|
---|
2345 | }
|
---|
2346 | } finally {
|
---|
2347 | for (; flushIndex < queue.length; flushIndex++) {
|
---|
2348 | const job = queue[flushIndex];
|
---|
2349 | if (job) {
|
---|
2350 | job.flags &= ~1;
|
---|
2351 | }
|
---|
2352 | }
|
---|
2353 | flushIndex = -1;
|
---|
2354 | queue.length = 0;
|
---|
2355 | flushPostFlushCbs(seen);
|
---|
2356 | currentFlushPromise = null;
|
---|
2357 | if (queue.length || pendingPostFlushCbs.length) {
|
---|
2358 | flushJobs(seen);
|
---|
2359 | }
|
---|
2360 | }
|
---|
2361 | }
|
---|
2362 | function checkRecursiveUpdates(seen, fn) {
|
---|
2363 | const count = seen.get(fn) || 0;
|
---|
2364 | if (count > RECURSION_LIMIT) {
|
---|
2365 | const instance = fn.i;
|
---|
2366 | const componentName = instance && getComponentName(instance.type);
|
---|
2367 | handleError(
|
---|
2368 | `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.`,
|
---|
2369 | null,
|
---|
2370 | 10
|
---|
2371 | );
|
---|
2372 | return true;
|
---|
2373 | }
|
---|
2374 | seen.set(fn, count + 1);
|
---|
2375 | return false;
|
---|
2376 | }
|
---|
2377 |
|
---|
2378 | let isHmrUpdating = false;
|
---|
2379 | const hmrDirtyComponents = /* @__PURE__ */ new Map();
|
---|
2380 | {
|
---|
2381 | getGlobalThis().__VUE_HMR_RUNTIME__ = {
|
---|
2382 | createRecord: tryWrap(createRecord),
|
---|
2383 | rerender: tryWrap(rerender),
|
---|
2384 | reload: tryWrap(reload)
|
---|
2385 | };
|
---|
2386 | }
|
---|
2387 | const map = /* @__PURE__ */ new Map();
|
---|
2388 | function registerHMR(instance) {
|
---|
2389 | const id = instance.type.__hmrId;
|
---|
2390 | let record = map.get(id);
|
---|
2391 | if (!record) {
|
---|
2392 | createRecord(id, instance.type);
|
---|
2393 | record = map.get(id);
|
---|
2394 | }
|
---|
2395 | record.instances.add(instance);
|
---|
2396 | }
|
---|
2397 | function unregisterHMR(instance) {
|
---|
2398 | map.get(instance.type.__hmrId).instances.delete(instance);
|
---|
2399 | }
|
---|
2400 | function createRecord(id, initialDef) {
|
---|
2401 | if (map.has(id)) {
|
---|
2402 | return false;
|
---|
2403 | }
|
---|
2404 | map.set(id, {
|
---|
2405 | initialDef: normalizeClassComponent(initialDef),
|
---|
2406 | instances: /* @__PURE__ */ new Set()
|
---|
2407 | });
|
---|
2408 | return true;
|
---|
2409 | }
|
---|
2410 | function normalizeClassComponent(component) {
|
---|
2411 | return isClassComponent(component) ? component.__vccOpts : component;
|
---|
2412 | }
|
---|
2413 | function rerender(id, newRender) {
|
---|
2414 | const record = map.get(id);
|
---|
2415 | if (!record) {
|
---|
2416 | return;
|
---|
2417 | }
|
---|
2418 | record.initialDef.render = newRender;
|
---|
2419 | [...record.instances].forEach((instance) => {
|
---|
2420 | if (newRender) {
|
---|
2421 | instance.render = newRender;
|
---|
2422 | normalizeClassComponent(instance.type).render = newRender;
|
---|
2423 | }
|
---|
2424 | instance.renderCache = [];
|
---|
2425 | isHmrUpdating = true;
|
---|
2426 | instance.update();
|
---|
2427 | isHmrUpdating = false;
|
---|
2428 | });
|
---|
2429 | }
|
---|
2430 | function reload(id, newComp) {
|
---|
2431 | const record = map.get(id);
|
---|
2432 | if (!record) return;
|
---|
2433 | newComp = normalizeClassComponent(newComp);
|
---|
2434 | updateComponentDef(record.initialDef, newComp);
|
---|
2435 | const instances = [...record.instances];
|
---|
2436 | for (let i = 0; i < instances.length; i++) {
|
---|
2437 | const instance = instances[i];
|
---|
2438 | const oldComp = normalizeClassComponent(instance.type);
|
---|
2439 | let dirtyInstances = hmrDirtyComponents.get(oldComp);
|
---|
2440 | if (!dirtyInstances) {
|
---|
2441 | if (oldComp !== record.initialDef) {
|
---|
2442 | updateComponentDef(oldComp, newComp);
|
---|
2443 | }
|
---|
2444 | hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
|
---|
2445 | }
|
---|
2446 | dirtyInstances.add(instance);
|
---|
2447 | instance.appContext.propsCache.delete(instance.type);
|
---|
2448 | instance.appContext.emitsCache.delete(instance.type);
|
---|
2449 | instance.appContext.optionsCache.delete(instance.type);
|
---|
2450 | if (instance.ceReload) {
|
---|
2451 | dirtyInstances.add(instance);
|
---|
2452 | instance.ceReload(newComp.styles);
|
---|
2453 | dirtyInstances.delete(instance);
|
---|
2454 | } else if (instance.parent) {
|
---|
2455 | queueJob(() => {
|
---|
2456 | isHmrUpdating = true;
|
---|
2457 | instance.parent.update();
|
---|
2458 | isHmrUpdating = false;
|
---|
2459 | dirtyInstances.delete(instance);
|
---|
2460 | });
|
---|
2461 | } else if (instance.appContext.reload) {
|
---|
2462 | instance.appContext.reload();
|
---|
2463 | } else if (typeof window !== "undefined") {
|
---|
2464 | window.location.reload();
|
---|
2465 | } else {
|
---|
2466 | console.warn(
|
---|
2467 | "[HMR] Root or manually mounted instance modified. Full reload required."
|
---|
2468 | );
|
---|
2469 | }
|
---|
2470 | if (instance.root.ce && instance !== instance.root) {
|
---|
2471 | instance.root.ce._removeChildStyle(oldComp);
|
---|
2472 | }
|
---|
2473 | }
|
---|
2474 | queuePostFlushCb(() => {
|
---|
2475 | hmrDirtyComponents.clear();
|
---|
2476 | });
|
---|
2477 | }
|
---|
2478 | function updateComponentDef(oldComp, newComp) {
|
---|
2479 | extend(oldComp, newComp);
|
---|
2480 | for (const key in oldComp) {
|
---|
2481 | if (key !== "__file" && !(key in newComp)) {
|
---|
2482 | delete oldComp[key];
|
---|
2483 | }
|
---|
2484 | }
|
---|
2485 | }
|
---|
2486 | function tryWrap(fn) {
|
---|
2487 | return (id, arg) => {
|
---|
2488 | try {
|
---|
2489 | return fn(id, arg);
|
---|
2490 | } catch (e) {
|
---|
2491 | console.error(e);
|
---|
2492 | console.warn(
|
---|
2493 | `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
|
---|
2494 | );
|
---|
2495 | }
|
---|
2496 | };
|
---|
2497 | }
|
---|
2498 |
|
---|
2499 | let devtools;
|
---|
2500 | let buffer = [];
|
---|
2501 | let devtoolsNotInstalled = false;
|
---|
2502 | function emit$1(event, ...args) {
|
---|
2503 | if (devtools) {
|
---|
2504 | devtools.emit(event, ...args);
|
---|
2505 | } else if (!devtoolsNotInstalled) {
|
---|
2506 | buffer.push({ event, args });
|
---|
2507 | }
|
---|
2508 | }
|
---|
2509 | function setDevtoolsHook(hook, target) {
|
---|
2510 | var _a, _b;
|
---|
2511 | devtools = hook;
|
---|
2512 | if (devtools) {
|
---|
2513 | devtools.enabled = true;
|
---|
2514 | buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
|
---|
2515 | buffer = [];
|
---|
2516 | } else if (
|
---|
2517 | // handle late devtools injection - only do this if we are in an actual
|
---|
2518 | // browser environment to avoid the timer handle stalling test runner exit
|
---|
2519 | // (#4815)
|
---|
2520 | typeof window !== "undefined" && // some envs mock window but not fully
|
---|
2521 | window.HTMLElement && // also exclude jsdom
|
---|
2522 | // eslint-disable-next-line no-restricted-syntax
|
---|
2523 | !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
|
---|
2524 | ) {
|
---|
2525 | const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
|
---|
2526 | replay.push((newHook) => {
|
---|
2527 | setDevtoolsHook(newHook, target);
|
---|
2528 | });
|
---|
2529 | setTimeout(() => {
|
---|
2530 | if (!devtools) {
|
---|
2531 | target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
|
---|
2532 | devtoolsNotInstalled = true;
|
---|
2533 | buffer = [];
|
---|
2534 | }
|
---|
2535 | }, 3e3);
|
---|
2536 | } else {
|
---|
2537 | devtoolsNotInstalled = true;
|
---|
2538 | buffer = [];
|
---|
2539 | }
|
---|
2540 | }
|
---|
2541 | function devtoolsInitApp(app, version) {
|
---|
2542 | emit$1("app:init" /* APP_INIT */, app, version, {
|
---|
2543 | Fragment,
|
---|
2544 | Text,
|
---|
2545 | Comment,
|
---|
2546 | Static
|
---|
2547 | });
|
---|
2548 | }
|
---|
2549 | function devtoolsUnmountApp(app) {
|
---|
2550 | emit$1("app:unmount" /* APP_UNMOUNT */, app);
|
---|
2551 | }
|
---|
2552 | const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
|
---|
2553 | const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
|
---|
2554 | const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
|
---|
2555 | "component:removed" /* COMPONENT_REMOVED */
|
---|
2556 | );
|
---|
2557 | const devtoolsComponentRemoved = (component) => {
|
---|
2558 | if (devtools && typeof devtools.cleanupBuffer === "function" && // remove the component if it wasn't buffered
|
---|
2559 | !devtools.cleanupBuffer(component)) {
|
---|
2560 | _devtoolsComponentRemoved(component);
|
---|
2561 | }
|
---|
2562 | };
|
---|
2563 | /*! #__NO_SIDE_EFFECTS__ */
|
---|
2564 | // @__NO_SIDE_EFFECTS__
|
---|
2565 | function createDevtoolsComponentHook(hook) {
|
---|
2566 | return (component) => {
|
---|
2567 | emit$1(
|
---|
2568 | hook,
|
---|
2569 | component.appContext.app,
|
---|
2570 | component.uid,
|
---|
2571 | component.parent ? component.parent.uid : void 0,
|
---|
2572 | component
|
---|
2573 | );
|
---|
2574 | };
|
---|
2575 | }
|
---|
2576 | const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
|
---|
2577 | const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
|
---|
2578 | function createDevtoolsPerformanceHook(hook) {
|
---|
2579 | return (component, type, time) => {
|
---|
2580 | emit$1(hook, component.appContext.app, component.uid, component, type, time);
|
---|
2581 | };
|
---|
2582 | }
|
---|
2583 | function devtoolsComponentEmit(component, event, params) {
|
---|
2584 | emit$1(
|
---|
2585 | "component:emit" /* COMPONENT_EMIT */,
|
---|
2586 | component.appContext.app,
|
---|
2587 | component,
|
---|
2588 | event,
|
---|
2589 | params
|
---|
2590 | );
|
---|
2591 | }
|
---|
2592 |
|
---|
2593 | let currentRenderingInstance = null;
|
---|
2594 | let currentScopeId = null;
|
---|
2595 | function setCurrentRenderingInstance$1(instance) {
|
---|
2596 | const prev = currentRenderingInstance;
|
---|
2597 | currentRenderingInstance = instance;
|
---|
2598 | currentScopeId = instance && instance.type.__scopeId || null;
|
---|
2599 | return prev;
|
---|
2600 | }
|
---|
2601 | function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
|
---|
2602 | if (!ctx) return fn;
|
---|
2603 | if (fn._n) {
|
---|
2604 | return fn;
|
---|
2605 | }
|
---|
2606 | const renderFnWithContext = (...args) => {
|
---|
2607 | if (renderFnWithContext._d) {
|
---|
2608 | setBlockTracking(-1);
|
---|
2609 | }
|
---|
2610 | const prevInstance = setCurrentRenderingInstance$1(ctx);
|
---|
2611 | let res;
|
---|
2612 | try {
|
---|
2613 | res = fn(...args);
|
---|
2614 | } finally {
|
---|
2615 | setCurrentRenderingInstance$1(prevInstance);
|
---|
2616 | if (renderFnWithContext._d) {
|
---|
2617 | setBlockTracking(1);
|
---|
2618 | }
|
---|
2619 | }
|
---|
2620 | {
|
---|
2621 | devtoolsComponentUpdated(ctx);
|
---|
2622 | }
|
---|
2623 | return res;
|
---|
2624 | };
|
---|
2625 | renderFnWithContext._n = true;
|
---|
2626 | renderFnWithContext._c = true;
|
---|
2627 | renderFnWithContext._d = true;
|
---|
2628 | return renderFnWithContext;
|
---|
2629 | }
|
---|
2630 |
|
---|
2631 | function validateDirectiveName(name) {
|
---|
2632 | if (isBuiltInDirective(name)) {
|
---|
2633 | warn$1("Do not use built-in directive ids as custom directive id: " + name);
|
---|
2634 | }
|
---|
2635 | }
|
---|
2636 | function invokeDirectiveHook(vnode, prevVNode, instance, name) {
|
---|
2637 | const bindings = vnode.dirs;
|
---|
2638 | const oldBindings = prevVNode && prevVNode.dirs;
|
---|
2639 | for (let i = 0; i < bindings.length; i++) {
|
---|
2640 | const binding = bindings[i];
|
---|
2641 | if (oldBindings) {
|
---|
2642 | binding.oldValue = oldBindings[i].value;
|
---|
2643 | }
|
---|
2644 | let hook = binding.dir[name];
|
---|
2645 | if (hook) {
|
---|
2646 | pauseTracking();
|
---|
2647 | callWithAsyncErrorHandling(hook, instance, 8, [
|
---|
2648 | vnode.el,
|
---|
2649 | binding,
|
---|
2650 | vnode,
|
---|
2651 | prevVNode
|
---|
2652 | ]);
|
---|
2653 | resetTracking();
|
---|
2654 | }
|
---|
2655 | }
|
---|
2656 | }
|
---|
2657 |
|
---|
2658 | const TeleportEndKey = Symbol("_vte");
|
---|
2659 | const isTeleport = (type) => type.__isTeleport;
|
---|
2660 |
|
---|
2661 | function setTransitionHooks(vnode, hooks) {
|
---|
2662 | if (vnode.shapeFlag & 6 && vnode.component) {
|
---|
2663 | vnode.transition = hooks;
|
---|
2664 | setTransitionHooks(vnode.component.subTree, hooks);
|
---|
2665 | } else if (vnode.shapeFlag & 128) {
|
---|
2666 | vnode.ssContent.transition = hooks.clone(vnode.ssContent);
|
---|
2667 | vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
|
---|
2668 | } else {
|
---|
2669 | vnode.transition = hooks;
|
---|
2670 | }
|
---|
2671 | }
|
---|
2672 |
|
---|
2673 | function markAsyncBoundary(instance) {
|
---|
2674 | instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
|
---|
2675 | }
|
---|
2676 |
|
---|
2677 | const knownTemplateRefs = /* @__PURE__ */ new WeakSet();
|
---|
2678 |
|
---|
2679 | function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
|
---|
2680 | if (isArray(rawRef)) {
|
---|
2681 | rawRef.forEach(
|
---|
2682 | (r, i) => setRef(
|
---|
2683 | r,
|
---|
2684 | oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
|
---|
2685 | parentSuspense,
|
---|
2686 | vnode,
|
---|
2687 | isUnmount
|
---|
2688 | )
|
---|
2689 | );
|
---|
2690 | return;
|
---|
2691 | }
|
---|
2692 | if (isAsyncWrapper(vnode) && !isUnmount) {
|
---|
2693 | if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) {
|
---|
2694 | setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree);
|
---|
2695 | }
|
---|
2696 | return;
|
---|
2697 | }
|
---|
2698 | const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
|
---|
2699 | const value = isUnmount ? null : refValue;
|
---|
2700 | const { i: owner, r: ref } = rawRef;
|
---|
2701 | if (!owner) {
|
---|
2702 | warn$1(
|
---|
2703 | `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
|
---|
2704 | );
|
---|
2705 | return;
|
---|
2706 | }
|
---|
2707 | const oldRef = oldRawRef && oldRawRef.r;
|
---|
2708 | const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
|
---|
2709 | const setupState = owner.setupState;
|
---|
2710 | const rawSetupState = toRaw(setupState);
|
---|
2711 | const canSetSetupRef = setupState === EMPTY_OBJ ? () => false : (key) => {
|
---|
2712 | {
|
---|
2713 | if (hasOwn(rawSetupState, key) && !isRef(rawSetupState[key])) {
|
---|
2714 | warn$1(
|
---|
2715 | `Template ref "${key}" used on a non-ref value. It will not work in the production build.`
|
---|
2716 | );
|
---|
2717 | }
|
---|
2718 | if (knownTemplateRefs.has(rawSetupState[key])) {
|
---|
2719 | return false;
|
---|
2720 | }
|
---|
2721 | }
|
---|
2722 | return hasOwn(rawSetupState, key);
|
---|
2723 | };
|
---|
2724 | if (oldRef != null && oldRef !== ref) {
|
---|
2725 | if (isString(oldRef)) {
|
---|
2726 | refs[oldRef] = null;
|
---|
2727 | if (canSetSetupRef(oldRef)) {
|
---|
2728 | setupState[oldRef] = null;
|
---|
2729 | }
|
---|
2730 | } else if (isRef(oldRef)) {
|
---|
2731 | oldRef.value = null;
|
---|
2732 | }
|
---|
2733 | }
|
---|
2734 | if (isFunction(ref)) {
|
---|
2735 | callWithErrorHandling(ref, owner, 12, [value, refs]);
|
---|
2736 | } else {
|
---|
2737 | const _isString = isString(ref);
|
---|
2738 | const _isRef = isRef(ref);
|
---|
2739 | if (_isString || _isRef) {
|
---|
2740 | const doSet = () => {
|
---|
2741 | if (rawRef.f) {
|
---|
2742 | const existing = _isString ? canSetSetupRef(ref) ? setupState[ref] : refs[ref] : ref.value;
|
---|
2743 | if (isUnmount) {
|
---|
2744 | isArray(existing) && remove(existing, refValue);
|
---|
2745 | } else {
|
---|
2746 | if (!isArray(existing)) {
|
---|
2747 | if (_isString) {
|
---|
2748 | refs[ref] = [refValue];
|
---|
2749 | if (canSetSetupRef(ref)) {
|
---|
2750 | setupState[ref] = refs[ref];
|
---|
2751 | }
|
---|
2752 | } else {
|
---|
2753 | ref.value = [refValue];
|
---|
2754 | if (rawRef.k) refs[rawRef.k] = ref.value;
|
---|
2755 | }
|
---|
2756 | } else if (!existing.includes(refValue)) {
|
---|
2757 | existing.push(refValue);
|
---|
2758 | }
|
---|
2759 | }
|
---|
2760 | } else if (_isString) {
|
---|
2761 | refs[ref] = value;
|
---|
2762 | if (canSetSetupRef(ref)) {
|
---|
2763 | setupState[ref] = value;
|
---|
2764 | }
|
---|
2765 | } else if (_isRef) {
|
---|
2766 | ref.value = value;
|
---|
2767 | if (rawRef.k) refs[rawRef.k] = value;
|
---|
2768 | } else {
|
---|
2769 | warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
|
---|
2770 | }
|
---|
2771 | };
|
---|
2772 | if (value) {
|
---|
2773 | doSet.id = -1;
|
---|
2774 | queuePostRenderEffect(doSet, parentSuspense);
|
---|
2775 | } else {
|
---|
2776 | doSet();
|
---|
2777 | }
|
---|
2778 | } else {
|
---|
2779 | warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
|
---|
2780 | }
|
---|
2781 | }
|
---|
2782 | }
|
---|
2783 |
|
---|
2784 | const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
|
---|
2785 |
|
---|
2786 | const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
---|
2787 | function onActivated(hook, target) {
|
---|
2788 | registerKeepAliveHook(hook, "a", target);
|
---|
2789 | }
|
---|
2790 | function onDeactivated(hook, target) {
|
---|
2791 | registerKeepAliveHook(hook, "da", target);
|
---|
2792 | }
|
---|
2793 | function registerKeepAliveHook(hook, type, target = currentInstance) {
|
---|
2794 | const wrappedHook = hook.__wdc || (hook.__wdc = () => {
|
---|
2795 | let current = target;
|
---|
2796 | while (current) {
|
---|
2797 | if (current.isDeactivated) {
|
---|
2798 | return;
|
---|
2799 | }
|
---|
2800 | current = current.parent;
|
---|
2801 | }
|
---|
2802 | return hook();
|
---|
2803 | });
|
---|
2804 | injectHook(type, wrappedHook, target);
|
---|
2805 | if (target) {
|
---|
2806 | let current = target.parent;
|
---|
2807 | while (current && current.parent) {
|
---|
2808 | if (isKeepAlive(current.parent.vnode)) {
|
---|
2809 | injectToKeepAliveRoot(wrappedHook, type, target, current);
|
---|
2810 | }
|
---|
2811 | current = current.parent;
|
---|
2812 | }
|
---|
2813 | }
|
---|
2814 | }
|
---|
2815 | function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
|
---|
2816 | const injected = injectHook(
|
---|
2817 | type,
|
---|
2818 | hook,
|
---|
2819 | keepAliveRoot,
|
---|
2820 | true
|
---|
2821 | /* prepend */
|
---|
2822 | );
|
---|
2823 | onUnmounted(() => {
|
---|
2824 | remove(keepAliveRoot[type], injected);
|
---|
2825 | }, target);
|
---|
2826 | }
|
---|
2827 |
|
---|
2828 | function injectHook(type, hook, target = currentInstance, prepend = false) {
|
---|
2829 | if (target) {
|
---|
2830 | const hooks = target[type] || (target[type] = []);
|
---|
2831 | const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
|
---|
2832 | pauseTracking();
|
---|
2833 | const reset = setCurrentInstance(target);
|
---|
2834 | const res = callWithAsyncErrorHandling(hook, target, type, args);
|
---|
2835 | reset();
|
---|
2836 | resetTracking();
|
---|
2837 | return res;
|
---|
2838 | });
|
---|
2839 | if (prepend) {
|
---|
2840 | hooks.unshift(wrappedHook);
|
---|
2841 | } else {
|
---|
2842 | hooks.push(wrappedHook);
|
---|
2843 | }
|
---|
2844 | return wrappedHook;
|
---|
2845 | } else {
|
---|
2846 | const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
|
---|
2847 | warn$1(
|
---|
2848 | `${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.` )
|
---|
2849 | );
|
---|
2850 | }
|
---|
2851 | }
|
---|
2852 | const createHook = (lifecycle) => (hook, target = currentInstance) => {
|
---|
2853 | if (!isInSSRComponentSetup || lifecycle === "sp") {
|
---|
2854 | injectHook(lifecycle, (...args) => hook(...args), target);
|
---|
2855 | }
|
---|
2856 | };
|
---|
2857 | const onBeforeMount = createHook("bm");
|
---|
2858 | const onMounted = createHook("m");
|
---|
2859 | const onBeforeUpdate = createHook(
|
---|
2860 | "bu"
|
---|
2861 | );
|
---|
2862 | const onUpdated = createHook("u");
|
---|
2863 | const onBeforeUnmount = createHook(
|
---|
2864 | "bum"
|
---|
2865 | );
|
---|
2866 | const onUnmounted = createHook("um");
|
---|
2867 | const onServerPrefetch = createHook(
|
---|
2868 | "sp"
|
---|
2869 | );
|
---|
2870 | const onRenderTriggered = createHook("rtg");
|
---|
2871 | const onRenderTracked = createHook("rtc");
|
---|
2872 | function onErrorCaptured(hook, target = currentInstance) {
|
---|
2873 | injectHook("ec", hook, target);
|
---|
2874 | }
|
---|
2875 |
|
---|
2876 | const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
|
---|
2877 |
|
---|
2878 | function ensureValidVNode$1(vnodes) {
|
---|
2879 | return vnodes.some((child) => {
|
---|
2880 | if (!isVNode$2(child)) return true;
|
---|
2881 | if (child.type === Comment) return false;
|
---|
2882 | if (child.type === Fragment && !ensureValidVNode$1(child.children))
|
---|
2883 | return false;
|
---|
2884 | return true;
|
---|
2885 | }) ? vnodes : null;
|
---|
2886 | }
|
---|
2887 |
|
---|
2888 | const getPublicInstance = (i) => {
|
---|
2889 | if (!i) return null;
|
---|
2890 | if (isStatefulComponent(i)) return getComponentPublicInstance(i);
|
---|
2891 | return getPublicInstance(i.parent);
|
---|
2892 | };
|
---|
2893 | const publicPropertiesMap = (
|
---|
2894 | // Move PURE marker to new line to workaround compiler discarding it
|
---|
2895 | // due to type annotation
|
---|
2896 | /* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
|
---|
2897 | $: (i) => i,
|
---|
2898 | $el: (i) => i.vnode.el,
|
---|
2899 | $data: (i) => i.data,
|
---|
2900 | $props: (i) => shallowReadonly(i.props) ,
|
---|
2901 | $attrs: (i) => shallowReadonly(i.attrs) ,
|
---|
2902 | $slots: (i) => shallowReadonly(i.slots) ,
|
---|
2903 | $refs: (i) => shallowReadonly(i.refs) ,
|
---|
2904 | $parent: (i) => getPublicInstance(i.parent),
|
---|
2905 | $root: (i) => getPublicInstance(i.root),
|
---|
2906 | $host: (i) => i.ce,
|
---|
2907 | $emit: (i) => i.emit,
|
---|
2908 | $options: (i) => resolveMergedOptions(i) ,
|
---|
2909 | $forceUpdate: (i) => i.f || (i.f = () => {
|
---|
2910 | queueJob(i.update);
|
---|
2911 | }),
|
---|
2912 | $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
|
---|
2913 | $watch: (i) => instanceWatch.bind(i)
|
---|
2914 | })
|
---|
2915 | );
|
---|
2916 | const isReservedPrefix = (key) => key === "_" || key === "$";
|
---|
2917 | const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
|
---|
2918 | const PublicInstanceProxyHandlers = {
|
---|
2919 | get({ _: instance }, key) {
|
---|
2920 | if (key === "__v_skip") {
|
---|
2921 | return true;
|
---|
2922 | }
|
---|
2923 | const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
---|
2924 | if (key === "__isVue") {
|
---|
2925 | return true;
|
---|
2926 | }
|
---|
2927 | let normalizedProps;
|
---|
2928 | if (key[0] !== "$") {
|
---|
2929 | const n = accessCache[key];
|
---|
2930 | if (n !== void 0) {
|
---|
2931 | switch (n) {
|
---|
2932 | case 1 /* SETUP */:
|
---|
2933 | return setupState[key];
|
---|
2934 | case 2 /* DATA */:
|
---|
2935 | return data[key];
|
---|
2936 | case 4 /* CONTEXT */:
|
---|
2937 | return ctx[key];
|
---|
2938 | case 3 /* PROPS */:
|
---|
2939 | return props[key];
|
---|
2940 | }
|
---|
2941 | } else if (hasSetupBinding(setupState, key)) {
|
---|
2942 | accessCache[key] = 1 /* SETUP */;
|
---|
2943 | return setupState[key];
|
---|
2944 | } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
---|
2945 | accessCache[key] = 2 /* DATA */;
|
---|
2946 | return data[key];
|
---|
2947 | } else if (
|
---|
2948 | // only cache other properties when instance has declared (thus stable)
|
---|
2949 | // props
|
---|
2950 | (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
|
---|
2951 | ) {
|
---|
2952 | accessCache[key] = 3 /* PROPS */;
|
---|
2953 | return props[key];
|
---|
2954 | } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
---|
2955 | accessCache[key] = 4 /* CONTEXT */;
|
---|
2956 | return ctx[key];
|
---|
2957 | } else if (shouldCacheAccess) {
|
---|
2958 | accessCache[key] = 0 /* OTHER */;
|
---|
2959 | }
|
---|
2960 | }
|
---|
2961 | const publicGetter = publicPropertiesMap[key];
|
---|
2962 | let cssModule, globalProperties;
|
---|
2963 | if (publicGetter) {
|
---|
2964 | if (key === "$attrs") {
|
---|
2965 | track(instance.attrs, "get", "");
|
---|
2966 | markAttrsAccessed();
|
---|
2967 | } else if (key === "$slots") {
|
---|
2968 | track(instance, "get", key);
|
---|
2969 | }
|
---|
2970 | return publicGetter(instance);
|
---|
2971 | } else if (
|
---|
2972 | // css module (injected by vue-loader)
|
---|
2973 | (cssModule = type.__cssModules) && (cssModule = cssModule[key])
|
---|
2974 | ) {
|
---|
2975 | return cssModule;
|
---|
2976 | } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
---|
2977 | accessCache[key] = 4 /* CONTEXT */;
|
---|
2978 | return ctx[key];
|
---|
2979 | } else if (
|
---|
2980 | // global properties
|
---|
2981 | globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
|
---|
2982 | ) {
|
---|
2983 | {
|
---|
2984 | return globalProperties[key];
|
---|
2985 | }
|
---|
2986 | } else if (currentRenderingInstance && (!isString(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
|
---|
2987 | // to infinite warning loop
|
---|
2988 | key.indexOf("__v") !== 0)) {
|
---|
2989 | if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
|
---|
2990 | warn$1(
|
---|
2991 | `Property ${JSON.stringify(
|
---|
2992 | key
|
---|
2993 | )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
|
---|
2994 | );
|
---|
2995 | } else if (instance === currentRenderingInstance) {
|
---|
2996 | warn$1(
|
---|
2997 | `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
|
---|
2998 | );
|
---|
2999 | }
|
---|
3000 | }
|
---|
3001 | },
|
---|
3002 | set({ _: instance }, key, value) {
|
---|
3003 | const { data, setupState, ctx } = instance;
|
---|
3004 | if (hasSetupBinding(setupState, key)) {
|
---|
3005 | setupState[key] = value;
|
---|
3006 | return true;
|
---|
3007 | } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
|
---|
3008 | warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
|
---|
3009 | return false;
|
---|
3010 | } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
---|
3011 | data[key] = value;
|
---|
3012 | return true;
|
---|
3013 | } else if (hasOwn(instance.props, key)) {
|
---|
3014 | warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
|
---|
3015 | return false;
|
---|
3016 | }
|
---|
3017 | if (key[0] === "$" && key.slice(1) in instance) {
|
---|
3018 | warn$1(
|
---|
3019 | `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
|
---|
3020 | );
|
---|
3021 | return false;
|
---|
3022 | } else {
|
---|
3023 | if (key in instance.appContext.config.globalProperties) {
|
---|
3024 | Object.defineProperty(ctx, key, {
|
---|
3025 | enumerable: true,
|
---|
3026 | configurable: true,
|
---|
3027 | value
|
---|
3028 | });
|
---|
3029 | } else {
|
---|
3030 | ctx[key] = value;
|
---|
3031 | }
|
---|
3032 | }
|
---|
3033 | return true;
|
---|
3034 | },
|
---|
3035 | has({
|
---|
3036 | _: { data, setupState, accessCache, ctx, appContext, propsOptions }
|
---|
3037 | }, key) {
|
---|
3038 | let normalizedProps;
|
---|
3039 | 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);
|
---|
3040 | },
|
---|
3041 | defineProperty(target, key, descriptor) {
|
---|
3042 | if (descriptor.get != null) {
|
---|
3043 | target._.accessCache[key] = 0;
|
---|
3044 | } else if (hasOwn(descriptor, "value")) {
|
---|
3045 | this.set(target, key, descriptor.value, null);
|
---|
3046 | }
|
---|
3047 | return Reflect.defineProperty(target, key, descriptor);
|
---|
3048 | }
|
---|
3049 | };
|
---|
3050 | {
|
---|
3051 | PublicInstanceProxyHandlers.ownKeys = (target) => {
|
---|
3052 | warn$1(
|
---|
3053 | `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
|
---|
3054 | );
|
---|
3055 | return Reflect.ownKeys(target);
|
---|
3056 | };
|
---|
3057 | }
|
---|
3058 | function createDevRenderContext(instance) {
|
---|
3059 | const target = {};
|
---|
3060 | Object.defineProperty(target, `_`, {
|
---|
3061 | configurable: true,
|
---|
3062 | enumerable: false,
|
---|
3063 | get: () => instance
|
---|
3064 | });
|
---|
3065 | Object.keys(publicPropertiesMap).forEach((key) => {
|
---|
3066 | Object.defineProperty(target, key, {
|
---|
3067 | configurable: true,
|
---|
3068 | enumerable: false,
|
---|
3069 | get: () => publicPropertiesMap[key](instance),
|
---|
3070 | // intercepted by the proxy so no need for implementation,
|
---|
3071 | // but needed to prevent set errors
|
---|
3072 | set: NOOP
|
---|
3073 | });
|
---|
3074 | });
|
---|
3075 | return target;
|
---|
3076 | }
|
---|
3077 | function exposePropsOnRenderContext(instance) {
|
---|
3078 | const {
|
---|
3079 | ctx,
|
---|
3080 | propsOptions: [propsOptions]
|
---|
3081 | } = instance;
|
---|
3082 | if (propsOptions) {
|
---|
3083 | Object.keys(propsOptions).forEach((key) => {
|
---|
3084 | Object.defineProperty(ctx, key, {
|
---|
3085 | enumerable: true,
|
---|
3086 | configurable: true,
|
---|
3087 | get: () => instance.props[key],
|
---|
3088 | set: NOOP
|
---|
3089 | });
|
---|
3090 | });
|
---|
3091 | }
|
---|
3092 | }
|
---|
3093 | function exposeSetupStateOnRenderContext(instance) {
|
---|
3094 | const { ctx, setupState } = instance;
|
---|
3095 | Object.keys(toRaw(setupState)).forEach((key) => {
|
---|
3096 | if (!setupState.__isScriptSetup) {
|
---|
3097 | if (isReservedPrefix(key[0])) {
|
---|
3098 | warn$1(
|
---|
3099 | `setup() return property ${JSON.stringify(
|
---|
3100 | key
|
---|
3101 | )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`
|
---|
3102 | );
|
---|
3103 | return;
|
---|
3104 | }
|
---|
3105 | Object.defineProperty(ctx, key, {
|
---|
3106 | enumerable: true,
|
---|
3107 | configurable: true,
|
---|
3108 | get: () => setupState[key],
|
---|
3109 | set: NOOP
|
---|
3110 | });
|
---|
3111 | }
|
---|
3112 | });
|
---|
3113 | }
|
---|
3114 |
|
---|
3115 | function normalizePropsOrEmits(props) {
|
---|
3116 | return isArray(props) ? props.reduce(
|
---|
3117 | (normalized, p) => (normalized[p] = null, normalized),
|
---|
3118 | {}
|
---|
3119 | ) : props;
|
---|
3120 | }
|
---|
3121 |
|
---|
3122 | function createDuplicateChecker() {
|
---|
3123 | const cache = /* @__PURE__ */ Object.create(null);
|
---|
3124 | return (type, key) => {
|
---|
3125 | if (cache[key]) {
|
---|
3126 | warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
|
---|
3127 | } else {
|
---|
3128 | cache[key] = type;
|
---|
3129 | }
|
---|
3130 | };
|
---|
3131 | }
|
---|
3132 | let shouldCacheAccess = true;
|
---|
3133 | function applyOptions(instance) {
|
---|
3134 | const options = resolveMergedOptions(instance);
|
---|
3135 | const publicThis = instance.proxy;
|
---|
3136 | const ctx = instance.ctx;
|
---|
3137 | shouldCacheAccess = false;
|
---|
3138 | if (options.beforeCreate) {
|
---|
3139 | callHook(options.beforeCreate, instance, "bc");
|
---|
3140 | }
|
---|
3141 | const {
|
---|
3142 | // state
|
---|
3143 | data: dataOptions,
|
---|
3144 | computed: computedOptions,
|
---|
3145 | methods,
|
---|
3146 | watch: watchOptions,
|
---|
3147 | provide: provideOptions,
|
---|
3148 | inject: injectOptions,
|
---|
3149 | // lifecycle
|
---|
3150 | created,
|
---|
3151 | beforeMount,
|
---|
3152 | mounted,
|
---|
3153 | beforeUpdate,
|
---|
3154 | updated,
|
---|
3155 | activated,
|
---|
3156 | deactivated,
|
---|
3157 | beforeDestroy,
|
---|
3158 | beforeUnmount,
|
---|
3159 | destroyed,
|
---|
3160 | unmounted,
|
---|
3161 | render,
|
---|
3162 | renderTracked,
|
---|
3163 | renderTriggered,
|
---|
3164 | errorCaptured,
|
---|
3165 | serverPrefetch,
|
---|
3166 | // public API
|
---|
3167 | expose,
|
---|
3168 | inheritAttrs,
|
---|
3169 | // assets
|
---|
3170 | components,
|
---|
3171 | directives,
|
---|
3172 | filters
|
---|
3173 | } = options;
|
---|
3174 | const checkDuplicateProperties = createDuplicateChecker() ;
|
---|
3175 | {
|
---|
3176 | const [propsOptions] = instance.propsOptions;
|
---|
3177 | if (propsOptions) {
|
---|
3178 | for (const key in propsOptions) {
|
---|
3179 | checkDuplicateProperties("Props" /* PROPS */, key);
|
---|
3180 | }
|
---|
3181 | }
|
---|
3182 | }
|
---|
3183 | if (injectOptions) {
|
---|
3184 | resolveInjections(injectOptions, ctx, checkDuplicateProperties);
|
---|
3185 | }
|
---|
3186 | if (methods) {
|
---|
3187 | for (const key in methods) {
|
---|
3188 | const methodHandler = methods[key];
|
---|
3189 | if (isFunction(methodHandler)) {
|
---|
3190 | {
|
---|
3191 | Object.defineProperty(ctx, key, {
|
---|
3192 | value: methodHandler.bind(publicThis),
|
---|
3193 | configurable: true,
|
---|
3194 | enumerable: true,
|
---|
3195 | writable: true
|
---|
3196 | });
|
---|
3197 | }
|
---|
3198 | {
|
---|
3199 | checkDuplicateProperties("Methods" /* METHODS */, key);
|
---|
3200 | }
|
---|
3201 | } else {
|
---|
3202 | warn$1(
|
---|
3203 | `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
|
---|
3204 | );
|
---|
3205 | }
|
---|
3206 | }
|
---|
3207 | }
|
---|
3208 | if (dataOptions) {
|
---|
3209 | if (!isFunction(dataOptions)) {
|
---|
3210 | warn$1(
|
---|
3211 | `The data option must be a function. Plain object usage is no longer supported.`
|
---|
3212 | );
|
---|
3213 | }
|
---|
3214 | const data = dataOptions.call(publicThis, publicThis);
|
---|
3215 | if (isPromise(data)) {
|
---|
3216 | warn$1(
|
---|
3217 | `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
|
---|
3218 | );
|
---|
3219 | }
|
---|
3220 | if (!isObject(data)) {
|
---|
3221 | warn$1(`data() should return an object.`);
|
---|
3222 | } else {
|
---|
3223 | instance.data = reactive(data);
|
---|
3224 | {
|
---|
3225 | for (const key in data) {
|
---|
3226 | checkDuplicateProperties("Data" /* DATA */, key);
|
---|
3227 | if (!isReservedPrefix(key[0])) {
|
---|
3228 | Object.defineProperty(ctx, key, {
|
---|
3229 | configurable: true,
|
---|
3230 | enumerable: true,
|
---|
3231 | get: () => data[key],
|
---|
3232 | set: NOOP
|
---|
3233 | });
|
---|
3234 | }
|
---|
3235 | }
|
---|
3236 | }
|
---|
3237 | }
|
---|
3238 | }
|
---|
3239 | shouldCacheAccess = true;
|
---|
3240 | if (computedOptions) {
|
---|
3241 | for (const key in computedOptions) {
|
---|
3242 | const opt = computedOptions[key];
|
---|
3243 | const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
|
---|
3244 | if (get === NOOP) {
|
---|
3245 | warn$1(`Computed property "${key}" has no getter.`);
|
---|
3246 | }
|
---|
3247 | const set = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : () => {
|
---|
3248 | warn$1(
|
---|
3249 | `Write operation failed: computed property "${key}" is readonly.`
|
---|
3250 | );
|
---|
3251 | } ;
|
---|
3252 | const c = computed({
|
---|
3253 | get,
|
---|
3254 | set
|
---|
3255 | });
|
---|
3256 | Object.defineProperty(ctx, key, {
|
---|
3257 | enumerable: true,
|
---|
3258 | configurable: true,
|
---|
3259 | get: () => c.value,
|
---|
3260 | set: (v) => c.value = v
|
---|
3261 | });
|
---|
3262 | {
|
---|
3263 | checkDuplicateProperties("Computed" /* COMPUTED */, key);
|
---|
3264 | }
|
---|
3265 | }
|
---|
3266 | }
|
---|
3267 | if (watchOptions) {
|
---|
3268 | for (const key in watchOptions) {
|
---|
3269 | createWatcher(watchOptions[key], ctx, publicThis, key);
|
---|
3270 | }
|
---|
3271 | }
|
---|
3272 | if (provideOptions) {
|
---|
3273 | const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
|
---|
3274 | Reflect.ownKeys(provides).forEach((key) => {
|
---|
3275 | provide(key, provides[key]);
|
---|
3276 | });
|
---|
3277 | }
|
---|
3278 | if (created) {
|
---|
3279 | callHook(created, instance, "c");
|
---|
3280 | }
|
---|
3281 | function registerLifecycleHook(register, hook) {
|
---|
3282 | if (isArray(hook)) {
|
---|
3283 | hook.forEach((_hook) => register(_hook.bind(publicThis)));
|
---|
3284 | } else if (hook) {
|
---|
3285 | register(hook.bind(publicThis));
|
---|
3286 | }
|
---|
3287 | }
|
---|
3288 | registerLifecycleHook(onBeforeMount, beforeMount);
|
---|
3289 | registerLifecycleHook(onMounted, mounted);
|
---|
3290 | registerLifecycleHook(onBeforeUpdate, beforeUpdate);
|
---|
3291 | registerLifecycleHook(onUpdated, updated);
|
---|
3292 | registerLifecycleHook(onActivated, activated);
|
---|
3293 | registerLifecycleHook(onDeactivated, deactivated);
|
---|
3294 | registerLifecycleHook(onErrorCaptured, errorCaptured);
|
---|
3295 | registerLifecycleHook(onRenderTracked, renderTracked);
|
---|
3296 | registerLifecycleHook(onRenderTriggered, renderTriggered);
|
---|
3297 | registerLifecycleHook(onBeforeUnmount, beforeUnmount);
|
---|
3298 | registerLifecycleHook(onUnmounted, unmounted);
|
---|
3299 | registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
---|
3300 | if (isArray(expose)) {
|
---|
3301 | if (expose.length) {
|
---|
3302 | const exposed = instance.exposed || (instance.exposed = {});
|
---|
3303 | expose.forEach((key) => {
|
---|
3304 | Object.defineProperty(exposed, key, {
|
---|
3305 | get: () => publicThis[key],
|
---|
3306 | set: (val) => publicThis[key] = val
|
---|
3307 | });
|
---|
3308 | });
|
---|
3309 | } else if (!instance.exposed) {
|
---|
3310 | instance.exposed = {};
|
---|
3311 | }
|
---|
3312 | }
|
---|
3313 | if (render && instance.render === NOOP) {
|
---|
3314 | instance.render = render;
|
---|
3315 | }
|
---|
3316 | if (inheritAttrs != null) {
|
---|
3317 | instance.inheritAttrs = inheritAttrs;
|
---|
3318 | }
|
---|
3319 | if (components) instance.components = components;
|
---|
3320 | if (directives) instance.directives = directives;
|
---|
3321 | if (serverPrefetch) {
|
---|
3322 | markAsyncBoundary(instance);
|
---|
3323 | }
|
---|
3324 | }
|
---|
3325 | function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
|
---|
3326 | if (isArray(injectOptions)) {
|
---|
3327 | injectOptions = normalizeInject(injectOptions);
|
---|
3328 | }
|
---|
3329 | for (const key in injectOptions) {
|
---|
3330 | const opt = injectOptions[key];
|
---|
3331 | let injected;
|
---|
3332 | if (isObject(opt)) {
|
---|
3333 | if ("default" in opt) {
|
---|
3334 | injected = inject(
|
---|
3335 | opt.from || key,
|
---|
3336 | opt.default,
|
---|
3337 | true
|
---|
3338 | );
|
---|
3339 | } else {
|
---|
3340 | injected = inject(opt.from || key);
|
---|
3341 | }
|
---|
3342 | } else {
|
---|
3343 | injected = inject(opt);
|
---|
3344 | }
|
---|
3345 | if (isRef(injected)) {
|
---|
3346 | Object.defineProperty(ctx, key, {
|
---|
3347 | enumerable: true,
|
---|
3348 | configurable: true,
|
---|
3349 | get: () => injected.value,
|
---|
3350 | set: (v) => injected.value = v
|
---|
3351 | });
|
---|
3352 | } else {
|
---|
3353 | ctx[key] = injected;
|
---|
3354 | }
|
---|
3355 | {
|
---|
3356 | checkDuplicateProperties("Inject" /* INJECT */, key);
|
---|
3357 | }
|
---|
3358 | }
|
---|
3359 | }
|
---|
3360 | function callHook(hook, instance, type) {
|
---|
3361 | callWithAsyncErrorHandling(
|
---|
3362 | isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
|
---|
3363 | instance,
|
---|
3364 | type
|
---|
3365 | );
|
---|
3366 | }
|
---|
3367 | function createWatcher(raw, ctx, publicThis, key) {
|
---|
3368 | let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
|
---|
3369 | if (isString(raw)) {
|
---|
3370 | const handler = ctx[raw];
|
---|
3371 | if (isFunction(handler)) {
|
---|
3372 | {
|
---|
3373 | watch(getter, handler);
|
---|
3374 | }
|
---|
3375 | } else {
|
---|
3376 | warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
|
---|
3377 | }
|
---|
3378 | } else if (isFunction(raw)) {
|
---|
3379 | {
|
---|
3380 | watch(getter, raw.bind(publicThis));
|
---|
3381 | }
|
---|
3382 | } else if (isObject(raw)) {
|
---|
3383 | if (isArray(raw)) {
|
---|
3384 | raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
|
---|
3385 | } else {
|
---|
3386 | const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
|
---|
3387 | if (isFunction(handler)) {
|
---|
3388 | watch(getter, handler, raw);
|
---|
3389 | } else {
|
---|
3390 | warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
|
---|
3391 | }
|
---|
3392 | }
|
---|
3393 | } else {
|
---|
3394 | warn$1(`Invalid watch option: "${key}"`, raw);
|
---|
3395 | }
|
---|
3396 | }
|
---|
3397 | function resolveMergedOptions(instance) {
|
---|
3398 | const base = instance.type;
|
---|
3399 | const { mixins, extends: extendsOptions } = base;
|
---|
3400 | const {
|
---|
3401 | mixins: globalMixins,
|
---|
3402 | optionsCache: cache,
|
---|
3403 | config: { optionMergeStrategies }
|
---|
3404 | } = instance.appContext;
|
---|
3405 | const cached = cache.get(base);
|
---|
3406 | let resolved;
|
---|
3407 | if (cached) {
|
---|
3408 | resolved = cached;
|
---|
3409 | } else if (!globalMixins.length && !mixins && !extendsOptions) {
|
---|
3410 | {
|
---|
3411 | resolved = base;
|
---|
3412 | }
|
---|
3413 | } else {
|
---|
3414 | resolved = {};
|
---|
3415 | if (globalMixins.length) {
|
---|
3416 | globalMixins.forEach(
|
---|
3417 | (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
|
---|
3418 | );
|
---|
3419 | }
|
---|
3420 | mergeOptions(resolved, base, optionMergeStrategies);
|
---|
3421 | }
|
---|
3422 | if (isObject(base)) {
|
---|
3423 | cache.set(base, resolved);
|
---|
3424 | }
|
---|
3425 | return resolved;
|
---|
3426 | }
|
---|
3427 | function mergeOptions(to, from, strats, asMixin = false) {
|
---|
3428 | const { mixins, extends: extendsOptions } = from;
|
---|
3429 | if (extendsOptions) {
|
---|
3430 | mergeOptions(to, extendsOptions, strats, true);
|
---|
3431 | }
|
---|
3432 | if (mixins) {
|
---|
3433 | mixins.forEach(
|
---|
3434 | (m) => mergeOptions(to, m, strats, true)
|
---|
3435 | );
|
---|
3436 | }
|
---|
3437 | for (const key in from) {
|
---|
3438 | if (asMixin && key === "expose") {
|
---|
3439 | warn$1(
|
---|
3440 | `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
|
---|
3441 | );
|
---|
3442 | } else {
|
---|
3443 | const strat = internalOptionMergeStrats[key] || strats && strats[key];
|
---|
3444 | to[key] = strat ? strat(to[key], from[key]) : from[key];
|
---|
3445 | }
|
---|
3446 | }
|
---|
3447 | return to;
|
---|
3448 | }
|
---|
3449 | const internalOptionMergeStrats = {
|
---|
3450 | data: mergeDataFn,
|
---|
3451 | props: mergeEmitsOrPropsOptions,
|
---|
3452 | emits: mergeEmitsOrPropsOptions,
|
---|
3453 | // objects
|
---|
3454 | methods: mergeObjectOptions,
|
---|
3455 | computed: mergeObjectOptions,
|
---|
3456 | // lifecycle
|
---|
3457 | beforeCreate: mergeAsArray,
|
---|
3458 | created: mergeAsArray,
|
---|
3459 | beforeMount: mergeAsArray,
|
---|
3460 | mounted: mergeAsArray,
|
---|
3461 | beforeUpdate: mergeAsArray,
|
---|
3462 | updated: mergeAsArray,
|
---|
3463 | beforeDestroy: mergeAsArray,
|
---|
3464 | beforeUnmount: mergeAsArray,
|
---|
3465 | destroyed: mergeAsArray,
|
---|
3466 | unmounted: mergeAsArray,
|
---|
3467 | activated: mergeAsArray,
|
---|
3468 | deactivated: mergeAsArray,
|
---|
3469 | errorCaptured: mergeAsArray,
|
---|
3470 | serverPrefetch: mergeAsArray,
|
---|
3471 | // assets
|
---|
3472 | components: mergeObjectOptions,
|
---|
3473 | directives: mergeObjectOptions,
|
---|
3474 | // watch
|
---|
3475 | watch: mergeWatchOptions,
|
---|
3476 | // provide / inject
|
---|
3477 | provide: mergeDataFn,
|
---|
3478 | inject: mergeInject
|
---|
3479 | };
|
---|
3480 | function mergeDataFn(to, from) {
|
---|
3481 | if (!from) {
|
---|
3482 | return to;
|
---|
3483 | }
|
---|
3484 | if (!to) {
|
---|
3485 | return from;
|
---|
3486 | }
|
---|
3487 | return function mergedDataFn() {
|
---|
3488 | return (extend)(
|
---|
3489 | isFunction(to) ? to.call(this, this) : to,
|
---|
3490 | isFunction(from) ? from.call(this, this) : from
|
---|
3491 | );
|
---|
3492 | };
|
---|
3493 | }
|
---|
3494 | function mergeInject(to, from) {
|
---|
3495 | return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
---|
3496 | }
|
---|
3497 | function normalizeInject(raw) {
|
---|
3498 | if (isArray(raw)) {
|
---|
3499 | const res = {};
|
---|
3500 | for (let i = 0; i < raw.length; i++) {
|
---|
3501 | res[raw[i]] = raw[i];
|
---|
3502 | }
|
---|
3503 | return res;
|
---|
3504 | }
|
---|
3505 | return raw;
|
---|
3506 | }
|
---|
3507 | function mergeAsArray(to, from) {
|
---|
3508 | return to ? [...new Set([].concat(to, from))] : from;
|
---|
3509 | }
|
---|
3510 | function mergeObjectOptions(to, from) {
|
---|
3511 | return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from;
|
---|
3512 | }
|
---|
3513 | function mergeEmitsOrPropsOptions(to, from) {
|
---|
3514 | if (to) {
|
---|
3515 | if (isArray(to) && isArray(from)) {
|
---|
3516 | return [.../* @__PURE__ */ new Set([...to, ...from])];
|
---|
3517 | }
|
---|
3518 | return extend(
|
---|
3519 | /* @__PURE__ */ Object.create(null),
|
---|
3520 | normalizePropsOrEmits(to),
|
---|
3521 | normalizePropsOrEmits(from != null ? from : {})
|
---|
3522 | );
|
---|
3523 | } else {
|
---|
3524 | return from;
|
---|
3525 | }
|
---|
3526 | }
|
---|
3527 | function mergeWatchOptions(to, from) {
|
---|
3528 | if (!to) return from;
|
---|
3529 | if (!from) return to;
|
---|
3530 | const merged = extend(/* @__PURE__ */ Object.create(null), to);
|
---|
3531 | for (const key in from) {
|
---|
3532 | merged[key] = mergeAsArray(to[key], from[key]);
|
---|
3533 | }
|
---|
3534 | return merged;
|
---|
3535 | }
|
---|
3536 |
|
---|
3537 | function createAppContext() {
|
---|
3538 | return {
|
---|
3539 | app: null,
|
---|
3540 | config: {
|
---|
3541 | isNativeTag: NO,
|
---|
3542 | performance: false,
|
---|
3543 | globalProperties: {},
|
---|
3544 | optionMergeStrategies: {},
|
---|
3545 | errorHandler: void 0,
|
---|
3546 | warnHandler: void 0,
|
---|
3547 | compilerOptions: {}
|
---|
3548 | },
|
---|
3549 | mixins: [],
|
---|
3550 | components: {},
|
---|
3551 | directives: {},
|
---|
3552 | provides: /* @__PURE__ */ Object.create(null),
|
---|
3553 | optionsCache: /* @__PURE__ */ new WeakMap(),
|
---|
3554 | propsCache: /* @__PURE__ */ new WeakMap(),
|
---|
3555 | emitsCache: /* @__PURE__ */ new WeakMap()
|
---|
3556 | };
|
---|
3557 | }
|
---|
3558 | let uid$1 = 0;
|
---|
3559 | function createAppAPI(render, hydrate) {
|
---|
3560 | return function createApp(rootComponent, rootProps = null) {
|
---|
3561 | if (!isFunction(rootComponent)) {
|
---|
3562 | rootComponent = extend({}, rootComponent);
|
---|
3563 | }
|
---|
3564 | if (rootProps != null && !isObject(rootProps)) {
|
---|
3565 | warn$1(`root props passed to app.mount() must be an object.`);
|
---|
3566 | rootProps = null;
|
---|
3567 | }
|
---|
3568 | const context = createAppContext();
|
---|
3569 | const installedPlugins = /* @__PURE__ */ new WeakSet();
|
---|
3570 | const pluginCleanupFns = [];
|
---|
3571 | let isMounted = false;
|
---|
3572 | const app = context.app = {
|
---|
3573 | _uid: uid$1++,
|
---|
3574 | _component: rootComponent,
|
---|
3575 | _props: rootProps,
|
---|
3576 | _container: null,
|
---|
3577 | _context: context,
|
---|
3578 | _instance: null,
|
---|
3579 | version,
|
---|
3580 | get config() {
|
---|
3581 | return context.config;
|
---|
3582 | },
|
---|
3583 | set config(v) {
|
---|
3584 | {
|
---|
3585 | warn$1(
|
---|
3586 | `app.config cannot be replaced. Modify individual options instead.`
|
---|
3587 | );
|
---|
3588 | }
|
---|
3589 | },
|
---|
3590 | use(plugin, ...options) {
|
---|
3591 | if (installedPlugins.has(plugin)) {
|
---|
3592 | warn$1(`Plugin has already been applied to target app.`);
|
---|
3593 | } else if (plugin && isFunction(plugin.install)) {
|
---|
3594 | installedPlugins.add(plugin);
|
---|
3595 | plugin.install(app, ...options);
|
---|
3596 | } else if (isFunction(plugin)) {
|
---|
3597 | installedPlugins.add(plugin);
|
---|
3598 | plugin(app, ...options);
|
---|
3599 | } else {
|
---|
3600 | warn$1(
|
---|
3601 | `A plugin must either be a function or an object with an "install" function.`
|
---|
3602 | );
|
---|
3603 | }
|
---|
3604 | return app;
|
---|
3605 | },
|
---|
3606 | mixin(mixin) {
|
---|
3607 | {
|
---|
3608 | if (!context.mixins.includes(mixin)) {
|
---|
3609 | context.mixins.push(mixin);
|
---|
3610 | } else {
|
---|
3611 | warn$1(
|
---|
3612 | "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
|
---|
3613 | );
|
---|
3614 | }
|
---|
3615 | }
|
---|
3616 | return app;
|
---|
3617 | },
|
---|
3618 | component(name, component) {
|
---|
3619 | {
|
---|
3620 | validateComponentName(name, context.config);
|
---|
3621 | }
|
---|
3622 | if (!component) {
|
---|
3623 | return context.components[name];
|
---|
3624 | }
|
---|
3625 | if (context.components[name]) {
|
---|
3626 | warn$1(`Component "${name}" has already been registered in target app.`);
|
---|
3627 | }
|
---|
3628 | context.components[name] = component;
|
---|
3629 | return app;
|
---|
3630 | },
|
---|
3631 | directive(name, directive) {
|
---|
3632 | {
|
---|
3633 | validateDirectiveName(name);
|
---|
3634 | }
|
---|
3635 | if (!directive) {
|
---|
3636 | return context.directives[name];
|
---|
3637 | }
|
---|
3638 | if (context.directives[name]) {
|
---|
3639 | warn$1(`Directive "${name}" has already been registered in target app.`);
|
---|
3640 | }
|
---|
3641 | context.directives[name] = directive;
|
---|
3642 | return app;
|
---|
3643 | },
|
---|
3644 | mount(rootContainer, isHydrate, namespace) {
|
---|
3645 | if (!isMounted) {
|
---|
3646 | if (rootContainer.__vue_app__) {
|
---|
3647 | warn$1(
|
---|
3648 | `There is already an app instance mounted on the host container.
|
---|
3649 | If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
|
---|
3650 | );
|
---|
3651 | }
|
---|
3652 | const vnode = app._ceVNode || createVNode(rootComponent, rootProps);
|
---|
3653 | vnode.appContext = context;
|
---|
3654 | if (namespace === true) {
|
---|
3655 | namespace = "svg";
|
---|
3656 | } else if (namespace === false) {
|
---|
3657 | namespace = void 0;
|
---|
3658 | }
|
---|
3659 | {
|
---|
3660 | context.reload = () => {
|
---|
3661 | render(
|
---|
3662 | cloneVNode(vnode),
|
---|
3663 | rootContainer,
|
---|
3664 | namespace
|
---|
3665 | );
|
---|
3666 | };
|
---|
3667 | }
|
---|
3668 | if (isHydrate && hydrate) {
|
---|
3669 | hydrate(vnode, rootContainer);
|
---|
3670 | } else {
|
---|
3671 | render(vnode, rootContainer, namespace);
|
---|
3672 | }
|
---|
3673 | isMounted = true;
|
---|
3674 | app._container = rootContainer;
|
---|
3675 | rootContainer.__vue_app__ = app;
|
---|
3676 | {
|
---|
3677 | app._instance = vnode.component;
|
---|
3678 | devtoolsInitApp(app, version);
|
---|
3679 | }
|
---|
3680 | return getComponentPublicInstance(vnode.component);
|
---|
3681 | } else {
|
---|
3682 | warn$1(
|
---|
3683 | `App has already been mounted.
|
---|
3684 | 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)\``
|
---|
3685 | );
|
---|
3686 | }
|
---|
3687 | },
|
---|
3688 | onUnmount(cleanupFn) {
|
---|
3689 | if (typeof cleanupFn !== "function") {
|
---|
3690 | warn$1(
|
---|
3691 | `Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
|
---|
3692 | );
|
---|
3693 | }
|
---|
3694 | pluginCleanupFns.push(cleanupFn);
|
---|
3695 | },
|
---|
3696 | unmount() {
|
---|
3697 | if (isMounted) {
|
---|
3698 | callWithAsyncErrorHandling(
|
---|
3699 | pluginCleanupFns,
|
---|
3700 | app._instance,
|
---|
3701 | 16
|
---|
3702 | );
|
---|
3703 | render(null, app._container);
|
---|
3704 | {
|
---|
3705 | app._instance = null;
|
---|
3706 | devtoolsUnmountApp(app);
|
---|
3707 | }
|
---|
3708 | delete app._container.__vue_app__;
|
---|
3709 | } else {
|
---|
3710 | warn$1(`Cannot unmount an app that is not mounted.`);
|
---|
3711 | }
|
---|
3712 | },
|
---|
3713 | provide(key, value) {
|
---|
3714 | if (key in context.provides) {
|
---|
3715 | warn$1(
|
---|
3716 | `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
|
---|
3717 | );
|
---|
3718 | }
|
---|
3719 | context.provides[key] = value;
|
---|
3720 | return app;
|
---|
3721 | },
|
---|
3722 | runWithContext(fn) {
|
---|
3723 | const lastApp = currentApp;
|
---|
3724 | currentApp = app;
|
---|
3725 | try {
|
---|
3726 | return fn();
|
---|
3727 | } finally {
|
---|
3728 | currentApp = lastApp;
|
---|
3729 | }
|
---|
3730 | }
|
---|
3731 | };
|
---|
3732 | return app;
|
---|
3733 | };
|
---|
3734 | }
|
---|
3735 | let currentApp = null;
|
---|
3736 |
|
---|
3737 | function provide(key, value) {
|
---|
3738 | if (!currentInstance) {
|
---|
3739 | {
|
---|
3740 | warn$1(`provide() can only be used inside setup().`);
|
---|
3741 | }
|
---|
3742 | } else {
|
---|
3743 | let provides = currentInstance.provides;
|
---|
3744 | const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
---|
3745 | if (parentProvides === provides) {
|
---|
3746 | provides = currentInstance.provides = Object.create(parentProvides);
|
---|
3747 | }
|
---|
3748 | provides[key] = value;
|
---|
3749 | }
|
---|
3750 | }
|
---|
3751 | function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
---|
3752 | const instance = currentInstance || currentRenderingInstance;
|
---|
3753 | if (instance || currentApp) {
|
---|
3754 | const provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
|
---|
3755 | if (provides && key in provides) {
|
---|
3756 | return provides[key];
|
---|
3757 | } else if (arguments.length > 1) {
|
---|
3758 | return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
|
---|
3759 | } else {
|
---|
3760 | warn$1(`injection "${String(key)}" not found.`);
|
---|
3761 | }
|
---|
3762 | } else {
|
---|
3763 | warn$1(`inject() can only be used inside setup() or functional components.`);
|
---|
3764 | }
|
---|
3765 | }
|
---|
3766 |
|
---|
3767 | const internalObjectProto = {};
|
---|
3768 | const createInternalObject = () => Object.create(internalObjectProto);
|
---|
3769 | const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
|
---|
3770 |
|
---|
3771 | function initProps(instance, rawProps, isStateful, isSSR = false) {
|
---|
3772 | const props = {};
|
---|
3773 | const attrs = createInternalObject();
|
---|
3774 | instance.propsDefaults = /* @__PURE__ */ Object.create(null);
|
---|
3775 | setFullProps(instance, rawProps, props, attrs);
|
---|
3776 | for (const key in instance.propsOptions[0]) {
|
---|
3777 | if (!(key in props)) {
|
---|
3778 | props[key] = void 0;
|
---|
3779 | }
|
---|
3780 | }
|
---|
3781 | {
|
---|
3782 | validateProps(rawProps || {}, props, instance);
|
---|
3783 | }
|
---|
3784 | if (isStateful) {
|
---|
3785 | instance.props = isSSR ? props : shallowReactive(props);
|
---|
3786 | } else {
|
---|
3787 | if (!instance.type.props) {
|
---|
3788 | instance.props = attrs;
|
---|
3789 | } else {
|
---|
3790 | instance.props = props;
|
---|
3791 | }
|
---|
3792 | }
|
---|
3793 | instance.attrs = attrs;
|
---|
3794 | }
|
---|
3795 | function isInHmrContext(instance) {
|
---|
3796 | while (instance) {
|
---|
3797 | if (instance.type.__hmrId) return true;
|
---|
3798 | instance = instance.parent;
|
---|
3799 | }
|
---|
3800 | }
|
---|
3801 | function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
---|
3802 | const {
|
---|
3803 | props,
|
---|
3804 | attrs,
|
---|
3805 | vnode: { patchFlag }
|
---|
3806 | } = instance;
|
---|
3807 | const rawCurrentProps = toRaw(props);
|
---|
3808 | const [options] = instance.propsOptions;
|
---|
3809 | let hasAttrsChanged = false;
|
---|
3810 | if (
|
---|
3811 | // always force full diff in dev
|
---|
3812 | // - #1942 if hmr is enabled with sfc component
|
---|
3813 | // - vite#872 non-sfc component used by sfc component
|
---|
3814 | !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
|
---|
3815 | ) {
|
---|
3816 | if (patchFlag & 8) {
|
---|
3817 | const propsToUpdate = instance.vnode.dynamicProps;
|
---|
3818 | for (let i = 0; i < propsToUpdate.length; i++) {
|
---|
3819 | let key = propsToUpdate[i];
|
---|
3820 | if (isEmitListener(instance.emitsOptions, key)) {
|
---|
3821 | continue;
|
---|
3822 | }
|
---|
3823 | const value = rawProps[key];
|
---|
3824 | if (options) {
|
---|
3825 | if (hasOwn(attrs, key)) {
|
---|
3826 | if (value !== attrs[key]) {
|
---|
3827 | attrs[key] = value;
|
---|
3828 | hasAttrsChanged = true;
|
---|
3829 | }
|
---|
3830 | } else {
|
---|
3831 | const camelizedKey = camelize(key);
|
---|
3832 | props[camelizedKey] = resolvePropValue(
|
---|
3833 | options,
|
---|
3834 | rawCurrentProps,
|
---|
3835 | camelizedKey,
|
---|
3836 | value,
|
---|
3837 | instance,
|
---|
3838 | false
|
---|
3839 | );
|
---|
3840 | }
|
---|
3841 | } else {
|
---|
3842 | if (value !== attrs[key]) {
|
---|
3843 | attrs[key] = value;
|
---|
3844 | hasAttrsChanged = true;
|
---|
3845 | }
|
---|
3846 | }
|
---|
3847 | }
|
---|
3848 | }
|
---|
3849 | } else {
|
---|
3850 | if (setFullProps(instance, rawProps, props, attrs)) {
|
---|
3851 | hasAttrsChanged = true;
|
---|
3852 | }
|
---|
3853 | let kebabKey;
|
---|
3854 | for (const key in rawCurrentProps) {
|
---|
3855 | if (!rawProps || // for camelCase
|
---|
3856 | !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
|
---|
3857 | // and converted to camelCase (#955)
|
---|
3858 | ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
|
---|
3859 | if (options) {
|
---|
3860 | if (rawPrevProps && // for camelCase
|
---|
3861 | (rawPrevProps[key] !== void 0 || // for kebab-case
|
---|
3862 | rawPrevProps[kebabKey] !== void 0)) {
|
---|
3863 | props[key] = resolvePropValue(
|
---|
3864 | options,
|
---|
3865 | rawCurrentProps,
|
---|
3866 | key,
|
---|
3867 | void 0,
|
---|
3868 | instance,
|
---|
3869 | true
|
---|
3870 | );
|
---|
3871 | }
|
---|
3872 | } else {
|
---|
3873 | delete props[key];
|
---|
3874 | }
|
---|
3875 | }
|
---|
3876 | }
|
---|
3877 | if (attrs !== rawCurrentProps) {
|
---|
3878 | for (const key in attrs) {
|
---|
3879 | if (!rawProps || !hasOwn(rawProps, key) && true) {
|
---|
3880 | delete attrs[key];
|
---|
3881 | hasAttrsChanged = true;
|
---|
3882 | }
|
---|
3883 | }
|
---|
3884 | }
|
---|
3885 | }
|
---|
3886 | if (hasAttrsChanged) {
|
---|
3887 | trigger(instance.attrs, "set", "");
|
---|
3888 | }
|
---|
3889 | {
|
---|
3890 | validateProps(rawProps || {}, props, instance);
|
---|
3891 | }
|
---|
3892 | }
|
---|
3893 | function setFullProps(instance, rawProps, props, attrs) {
|
---|
3894 | const [options, needCastKeys] = instance.propsOptions;
|
---|
3895 | let hasAttrsChanged = false;
|
---|
3896 | let rawCastValues;
|
---|
3897 | if (rawProps) {
|
---|
3898 | for (let key in rawProps) {
|
---|
3899 | if (isReservedProp(key)) {
|
---|
3900 | continue;
|
---|
3901 | }
|
---|
3902 | const value = rawProps[key];
|
---|
3903 | let camelKey;
|
---|
3904 | if (options && hasOwn(options, camelKey = camelize(key))) {
|
---|
3905 | if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
---|
3906 | props[camelKey] = value;
|
---|
3907 | } else {
|
---|
3908 | (rawCastValues || (rawCastValues = {}))[camelKey] = value;
|
---|
3909 | }
|
---|
3910 | } else if (!isEmitListener(instance.emitsOptions, key)) {
|
---|
3911 | if (!(key in attrs) || value !== attrs[key]) {
|
---|
3912 | attrs[key] = value;
|
---|
3913 | hasAttrsChanged = true;
|
---|
3914 | }
|
---|
3915 | }
|
---|
3916 | }
|
---|
3917 | }
|
---|
3918 | if (needCastKeys) {
|
---|
3919 | const rawCurrentProps = toRaw(props);
|
---|
3920 | const castValues = rawCastValues || EMPTY_OBJ;
|
---|
3921 | for (let i = 0; i < needCastKeys.length; i++) {
|
---|
3922 | const key = needCastKeys[i];
|
---|
3923 | props[key] = resolvePropValue(
|
---|
3924 | options,
|
---|
3925 | rawCurrentProps,
|
---|
3926 | key,
|
---|
3927 | castValues[key],
|
---|
3928 | instance,
|
---|
3929 | !hasOwn(castValues, key)
|
---|
3930 | );
|
---|
3931 | }
|
---|
3932 | }
|
---|
3933 | return hasAttrsChanged;
|
---|
3934 | }
|
---|
3935 | function resolvePropValue(options, props, key, value, instance, isAbsent) {
|
---|
3936 | const opt = options[key];
|
---|
3937 | if (opt != null) {
|
---|
3938 | const hasDefault = hasOwn(opt, "default");
|
---|
3939 | if (hasDefault && value === void 0) {
|
---|
3940 | const defaultValue = opt.default;
|
---|
3941 | if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
|
---|
3942 | const { propsDefaults } = instance;
|
---|
3943 | if (key in propsDefaults) {
|
---|
3944 | value = propsDefaults[key];
|
---|
3945 | } else {
|
---|
3946 | const reset = setCurrentInstance(instance);
|
---|
3947 | value = propsDefaults[key] = defaultValue.call(
|
---|
3948 | null,
|
---|
3949 | props
|
---|
3950 | );
|
---|
3951 | reset();
|
---|
3952 | }
|
---|
3953 | } else {
|
---|
3954 | value = defaultValue;
|
---|
3955 | }
|
---|
3956 | if (instance.ce) {
|
---|
3957 | instance.ce._setProp(key, value);
|
---|
3958 | }
|
---|
3959 | }
|
---|
3960 | if (opt[0 /* shouldCast */]) {
|
---|
3961 | if (isAbsent && !hasDefault) {
|
---|
3962 | value = false;
|
---|
3963 | } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
|
---|
3964 | value = true;
|
---|
3965 | }
|
---|
3966 | }
|
---|
3967 | }
|
---|
3968 | return value;
|
---|
3969 | }
|
---|
3970 | const mixinPropsCache = /* @__PURE__ */ new WeakMap();
|
---|
3971 | function normalizePropsOptions(comp, appContext, asMixin = false) {
|
---|
3972 | const cache = asMixin ? mixinPropsCache : appContext.propsCache;
|
---|
3973 | const cached = cache.get(comp);
|
---|
3974 | if (cached) {
|
---|
3975 | return cached;
|
---|
3976 | }
|
---|
3977 | const raw = comp.props;
|
---|
3978 | const normalized = {};
|
---|
3979 | const needCastKeys = [];
|
---|
3980 | let hasExtends = false;
|
---|
3981 | if (!isFunction(comp)) {
|
---|
3982 | const extendProps = (raw2) => {
|
---|
3983 | hasExtends = true;
|
---|
3984 | const [props, keys] = normalizePropsOptions(raw2, appContext, true);
|
---|
3985 | extend(normalized, props);
|
---|
3986 | if (keys) needCastKeys.push(...keys);
|
---|
3987 | };
|
---|
3988 | if (!asMixin && appContext.mixins.length) {
|
---|
3989 | appContext.mixins.forEach(extendProps);
|
---|
3990 | }
|
---|
3991 | if (comp.extends) {
|
---|
3992 | extendProps(comp.extends);
|
---|
3993 | }
|
---|
3994 | if (comp.mixins) {
|
---|
3995 | comp.mixins.forEach(extendProps);
|
---|
3996 | }
|
---|
3997 | }
|
---|
3998 | if (!raw && !hasExtends) {
|
---|
3999 | if (isObject(comp)) {
|
---|
4000 | cache.set(comp, EMPTY_ARR);
|
---|
4001 | }
|
---|
4002 | return EMPTY_ARR;
|
---|
4003 | }
|
---|
4004 | if (isArray(raw)) {
|
---|
4005 | for (let i = 0; i < raw.length; i++) {
|
---|
4006 | if (!isString(raw[i])) {
|
---|
4007 | warn$1(`props must be strings when using array syntax.`, raw[i]);
|
---|
4008 | }
|
---|
4009 | const normalizedKey = camelize(raw[i]);
|
---|
4010 | if (validatePropName(normalizedKey)) {
|
---|
4011 | normalized[normalizedKey] = EMPTY_OBJ;
|
---|
4012 | }
|
---|
4013 | }
|
---|
4014 | } else if (raw) {
|
---|
4015 | if (!isObject(raw)) {
|
---|
4016 | warn$1(`invalid props options`, raw);
|
---|
4017 | }
|
---|
4018 | for (const key in raw) {
|
---|
4019 | const normalizedKey = camelize(key);
|
---|
4020 | if (validatePropName(normalizedKey)) {
|
---|
4021 | const opt = raw[key];
|
---|
4022 | const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
|
---|
4023 | const propType = prop.type;
|
---|
4024 | let shouldCast = false;
|
---|
4025 | let shouldCastTrue = true;
|
---|
4026 | if (isArray(propType)) {
|
---|
4027 | for (let index = 0; index < propType.length; ++index) {
|
---|
4028 | const type = propType[index];
|
---|
4029 | const typeName = isFunction(type) && type.name;
|
---|
4030 | if (typeName === "Boolean") {
|
---|
4031 | shouldCast = true;
|
---|
4032 | break;
|
---|
4033 | } else if (typeName === "String") {
|
---|
4034 | shouldCastTrue = false;
|
---|
4035 | }
|
---|
4036 | }
|
---|
4037 | } else {
|
---|
4038 | shouldCast = isFunction(propType) && propType.name === "Boolean";
|
---|
4039 | }
|
---|
4040 | prop[0 /* shouldCast */] = shouldCast;
|
---|
4041 | prop[1 /* shouldCastTrue */] = shouldCastTrue;
|
---|
4042 | if (shouldCast || hasOwn(prop, "default")) {
|
---|
4043 | needCastKeys.push(normalizedKey);
|
---|
4044 | }
|
---|
4045 | }
|
---|
4046 | }
|
---|
4047 | }
|
---|
4048 | const res = [normalized, needCastKeys];
|
---|
4049 | if (isObject(comp)) {
|
---|
4050 | cache.set(comp, res);
|
---|
4051 | }
|
---|
4052 | return res;
|
---|
4053 | }
|
---|
4054 | function validatePropName(key) {
|
---|
4055 | if (key[0] !== "$" && !isReservedProp(key)) {
|
---|
4056 | return true;
|
---|
4057 | } else {
|
---|
4058 | warn$1(`Invalid prop name: "${key}" is a reserved property.`);
|
---|
4059 | }
|
---|
4060 | return false;
|
---|
4061 | }
|
---|
4062 | function getType(ctor) {
|
---|
4063 | if (ctor === null) {
|
---|
4064 | return "null";
|
---|
4065 | }
|
---|
4066 | if (typeof ctor === "function") {
|
---|
4067 | return ctor.name || "";
|
---|
4068 | } else if (typeof ctor === "object") {
|
---|
4069 | const name = ctor.constructor && ctor.constructor.name;
|
---|
4070 | return name || "";
|
---|
4071 | }
|
---|
4072 | return "";
|
---|
4073 | }
|
---|
4074 | function validateProps(rawProps, props, instance) {
|
---|
4075 | const resolvedValues = toRaw(props);
|
---|
4076 | const options = instance.propsOptions[0];
|
---|
4077 | const camelizePropsKey = Object.keys(rawProps).map((key) => camelize(key));
|
---|
4078 | for (const key in options) {
|
---|
4079 | let opt = options[key];
|
---|
4080 | if (opt == null) continue;
|
---|
4081 | validateProp(
|
---|
4082 | key,
|
---|
4083 | resolvedValues[key],
|
---|
4084 | opt,
|
---|
4085 | shallowReadonly(resolvedValues) ,
|
---|
4086 | !camelizePropsKey.includes(key)
|
---|
4087 | );
|
---|
4088 | }
|
---|
4089 | }
|
---|
4090 | function validateProp(name, value, prop, props, isAbsent) {
|
---|
4091 | const { type, required, validator, skipCheck } = prop;
|
---|
4092 | if (required && isAbsent) {
|
---|
4093 | warn$1('Missing required prop: "' + name + '"');
|
---|
4094 | return;
|
---|
4095 | }
|
---|
4096 | if (value == null && !required) {
|
---|
4097 | return;
|
---|
4098 | }
|
---|
4099 | if (type != null && type !== true && !skipCheck) {
|
---|
4100 | let isValid = false;
|
---|
4101 | const types = isArray(type) ? type : [type];
|
---|
4102 | const expectedTypes = [];
|
---|
4103 | for (let i = 0; i < types.length && !isValid; i++) {
|
---|
4104 | const { valid, expectedType } = assertType(value, types[i]);
|
---|
4105 | expectedTypes.push(expectedType || "");
|
---|
4106 | isValid = valid;
|
---|
4107 | }
|
---|
4108 | if (!isValid) {
|
---|
4109 | warn$1(getInvalidTypeMessage(name, value, expectedTypes));
|
---|
4110 | return;
|
---|
4111 | }
|
---|
4112 | }
|
---|
4113 | if (validator && !validator(value, props)) {
|
---|
4114 | warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
|
---|
4115 | }
|
---|
4116 | }
|
---|
4117 | const isSimpleType = /* @__PURE__ */ makeMap(
|
---|
4118 | "String,Number,Boolean,Function,Symbol,BigInt"
|
---|
4119 | );
|
---|
4120 | function assertType(value, type) {
|
---|
4121 | let valid;
|
---|
4122 | const expectedType = getType(type);
|
---|
4123 | if (expectedType === "null") {
|
---|
4124 | valid = value === null;
|
---|
4125 | } else if (isSimpleType(expectedType)) {
|
---|
4126 | const t = typeof value;
|
---|
4127 | valid = t === expectedType.toLowerCase();
|
---|
4128 | if (!valid && t === "object") {
|
---|
4129 | valid = value instanceof type;
|
---|
4130 | }
|
---|
4131 | } else if (expectedType === "Object") {
|
---|
4132 | valid = isObject(value);
|
---|
4133 | } else if (expectedType === "Array") {
|
---|
4134 | valid = isArray(value);
|
---|
4135 | } else {
|
---|
4136 | valid = value instanceof type;
|
---|
4137 | }
|
---|
4138 | return {
|
---|
4139 | valid,
|
---|
4140 | expectedType
|
---|
4141 | };
|
---|
4142 | }
|
---|
4143 | function getInvalidTypeMessage(name, value, expectedTypes) {
|
---|
4144 | if (expectedTypes.length === 0) {
|
---|
4145 | return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
|
---|
4146 | }
|
---|
4147 | let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
|
---|
4148 | const expectedType = expectedTypes[0];
|
---|
4149 | const receivedType = toRawType(value);
|
---|
4150 | const expectedValue = styleValue(value, expectedType);
|
---|
4151 | const receivedValue = styleValue(value, receivedType);
|
---|
4152 | if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
|
---|
4153 | message += ` with value ${expectedValue}`;
|
---|
4154 | }
|
---|
4155 | message += `, got ${receivedType} `;
|
---|
4156 | if (isExplicable(receivedType)) {
|
---|
4157 | message += `with value ${receivedValue}.`;
|
---|
4158 | }
|
---|
4159 | return message;
|
---|
4160 | }
|
---|
4161 | function styleValue(value, type) {
|
---|
4162 | if (type === "String") {
|
---|
4163 | return `"${value}"`;
|
---|
4164 | } else if (type === "Number") {
|
---|
4165 | return `${Number(value)}`;
|
---|
4166 | } else {
|
---|
4167 | return `${value}`;
|
---|
4168 | }
|
---|
4169 | }
|
---|
4170 | function isExplicable(type) {
|
---|
4171 | const explicitTypes = ["string", "number", "boolean"];
|
---|
4172 | return explicitTypes.some((elem) => type.toLowerCase() === elem);
|
---|
4173 | }
|
---|
4174 | function isBoolean(...args) {
|
---|
4175 | return args.some((elem) => elem.toLowerCase() === "boolean");
|
---|
4176 | }
|
---|
4177 |
|
---|
4178 | const isInternalKey = (key) => key[0] === "_" || key === "$stable";
|
---|
4179 | const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode$1) : [normalizeVNode$1(value)];
|
---|
4180 | const normalizeSlot = (key, rawSlot, ctx) => {
|
---|
4181 | if (rawSlot._n) {
|
---|
4182 | return rawSlot;
|
---|
4183 | }
|
---|
4184 | const normalized = withCtx((...args) => {
|
---|
4185 | if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
|
---|
4186 | warn$1(
|
---|
4187 | `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.`
|
---|
4188 | );
|
---|
4189 | }
|
---|
4190 | return normalizeSlotValue(rawSlot(...args));
|
---|
4191 | }, ctx);
|
---|
4192 | normalized._c = false;
|
---|
4193 | return normalized;
|
---|
4194 | };
|
---|
4195 | const normalizeObjectSlots = (rawSlots, slots, instance) => {
|
---|
4196 | const ctx = rawSlots._ctx;
|
---|
4197 | for (const key in rawSlots) {
|
---|
4198 | if (isInternalKey(key)) continue;
|
---|
4199 | const value = rawSlots[key];
|
---|
4200 | if (isFunction(value)) {
|
---|
4201 | slots[key] = normalizeSlot(key, value, ctx);
|
---|
4202 | } else if (value != null) {
|
---|
4203 | {
|
---|
4204 | warn$1(
|
---|
4205 | `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
|
---|
4206 | );
|
---|
4207 | }
|
---|
4208 | const normalized = normalizeSlotValue(value);
|
---|
4209 | slots[key] = () => normalized;
|
---|
4210 | }
|
---|
4211 | }
|
---|
4212 | };
|
---|
4213 | const normalizeVNodeSlots = (instance, children) => {
|
---|
4214 | if (!isKeepAlive(instance.vnode) && true) {
|
---|
4215 | warn$1(
|
---|
4216 | `Non-function value encountered for default slot. Prefer function slots for better performance.`
|
---|
4217 | );
|
---|
4218 | }
|
---|
4219 | const normalized = normalizeSlotValue(children);
|
---|
4220 | instance.slots.default = () => normalized;
|
---|
4221 | };
|
---|
4222 | const assignSlots = (slots, children, optimized) => {
|
---|
4223 | for (const key in children) {
|
---|
4224 | if (optimized || key !== "_") {
|
---|
4225 | slots[key] = children[key];
|
---|
4226 | }
|
---|
4227 | }
|
---|
4228 | };
|
---|
4229 | const initSlots = (instance, children, optimized) => {
|
---|
4230 | const slots = instance.slots = createInternalObject();
|
---|
4231 | if (instance.vnode.shapeFlag & 32) {
|
---|
4232 | const type = children._;
|
---|
4233 | if (type) {
|
---|
4234 | assignSlots(slots, children, optimized);
|
---|
4235 | if (optimized) {
|
---|
4236 | def(slots, "_", type, true);
|
---|
4237 | }
|
---|
4238 | } else {
|
---|
4239 | normalizeObjectSlots(children, slots);
|
---|
4240 | }
|
---|
4241 | } else if (children) {
|
---|
4242 | normalizeVNodeSlots(instance, children);
|
---|
4243 | }
|
---|
4244 | };
|
---|
4245 | const updateSlots = (instance, children, optimized) => {
|
---|
4246 | const { vnode, slots } = instance;
|
---|
4247 | let needDeletionCheck = true;
|
---|
4248 | let deletionComparisonTarget = EMPTY_OBJ;
|
---|
4249 | if (vnode.shapeFlag & 32) {
|
---|
4250 | const type = children._;
|
---|
4251 | if (type) {
|
---|
4252 | if (isHmrUpdating) {
|
---|
4253 | assignSlots(slots, children, optimized);
|
---|
4254 | trigger(instance, "set", "$slots");
|
---|
4255 | } else if (optimized && type === 1) {
|
---|
4256 | needDeletionCheck = false;
|
---|
4257 | } else {
|
---|
4258 | assignSlots(slots, children, optimized);
|
---|
4259 | }
|
---|
4260 | } else {
|
---|
4261 | needDeletionCheck = !children.$stable;
|
---|
4262 | normalizeObjectSlots(children, slots);
|
---|
4263 | }
|
---|
4264 | deletionComparisonTarget = children;
|
---|
4265 | } else if (children) {
|
---|
4266 | normalizeVNodeSlots(instance, children);
|
---|
4267 | deletionComparisonTarget = { default: 1 };
|
---|
4268 | }
|
---|
4269 | if (needDeletionCheck) {
|
---|
4270 | for (const key in slots) {
|
---|
4271 | if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
|
---|
4272 | delete slots[key];
|
---|
4273 | }
|
---|
4274 | }
|
---|
4275 | }
|
---|
4276 | };
|
---|
4277 |
|
---|
4278 | let supported;
|
---|
4279 | let perf;
|
---|
4280 | function startMeasure(instance, type) {
|
---|
4281 | if (instance.appContext.config.performance && isSupported()) {
|
---|
4282 | perf.mark(`vue-${type}-${instance.uid}`);
|
---|
4283 | }
|
---|
4284 | {
|
---|
4285 | devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
|
---|
4286 | }
|
---|
4287 | }
|
---|
4288 | function endMeasure(instance, type) {
|
---|
4289 | if (instance.appContext.config.performance && isSupported()) {
|
---|
4290 | const startTag = `vue-${type}-${instance.uid}`;
|
---|
4291 | const endTag = startTag + `:end`;
|
---|
4292 | perf.mark(endTag);
|
---|
4293 | perf.measure(
|
---|
4294 | `<${formatComponentName(instance, instance.type)}> ${type}`,
|
---|
4295 | startTag,
|
---|
4296 | endTag
|
---|
4297 | );
|
---|
4298 | perf.clearMarks(startTag);
|
---|
4299 | perf.clearMarks(endTag);
|
---|
4300 | }
|
---|
4301 | {
|
---|
4302 | devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
|
---|
4303 | }
|
---|
4304 | }
|
---|
4305 | function isSupported() {
|
---|
4306 | if (supported !== void 0) {
|
---|
4307 | return supported;
|
---|
4308 | }
|
---|
4309 | if (typeof window !== "undefined" && window.performance) {
|
---|
4310 | supported = true;
|
---|
4311 | perf = window.performance;
|
---|
4312 | } else {
|
---|
4313 | supported = false;
|
---|
4314 | }
|
---|
4315 | return supported;
|
---|
4316 | }
|
---|
4317 |
|
---|
4318 | const queuePostRenderEffect = queueEffectWithSuspense ;
|
---|
4319 | function createRenderer(options) {
|
---|
4320 | return baseCreateRenderer(options);
|
---|
4321 | }
|
---|
4322 | function baseCreateRenderer(options, createHydrationFns) {
|
---|
4323 | const target = getGlobalThis();
|
---|
4324 | target.__VUE__ = true;
|
---|
4325 | {
|
---|
4326 | setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
|
---|
4327 | }
|
---|
4328 | const {
|
---|
4329 | insert: hostInsert,
|
---|
4330 | remove: hostRemove,
|
---|
4331 | patchProp: hostPatchProp,
|
---|
4332 | createElement: hostCreateElement,
|
---|
4333 | createText: hostCreateText,
|
---|
4334 | createComment: hostCreateComment,
|
---|
4335 | setText: hostSetText,
|
---|
4336 | setElementText: hostSetElementText,
|
---|
4337 | parentNode: hostParentNode,
|
---|
4338 | nextSibling: hostNextSibling,
|
---|
4339 | setScopeId: hostSetScopeId = NOOP,
|
---|
4340 | insertStaticContent: hostInsertStaticContent
|
---|
4341 | } = options;
|
---|
4342 | const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
|
---|
4343 | if (n1 === n2) {
|
---|
4344 | return;
|
---|
4345 | }
|
---|
4346 | if (n1 && !isSameVNodeType(n1, n2)) {
|
---|
4347 | anchor = getNextHostNode(n1);
|
---|
4348 | unmount(n1, parentComponent, parentSuspense, true);
|
---|
4349 | n1 = null;
|
---|
4350 | }
|
---|
4351 | if (n2.patchFlag === -2) {
|
---|
4352 | optimized = false;
|
---|
4353 | n2.dynamicChildren = null;
|
---|
4354 | }
|
---|
4355 | const { type, ref, shapeFlag } = n2;
|
---|
4356 | switch (type) {
|
---|
4357 | case Text:
|
---|
4358 | processText(n1, n2, container, anchor);
|
---|
4359 | break;
|
---|
4360 | case Comment:
|
---|
4361 | processCommentNode(n1, n2, container, anchor);
|
---|
4362 | break;
|
---|
4363 | case Static:
|
---|
4364 | if (n1 == null) {
|
---|
4365 | mountStaticNode(n2, container, anchor, namespace);
|
---|
4366 | } else {
|
---|
4367 | patchStaticNode(n1, n2, container, namespace);
|
---|
4368 | }
|
---|
4369 | break;
|
---|
4370 | case Fragment:
|
---|
4371 | processFragment(
|
---|
4372 | n1,
|
---|
4373 | n2,
|
---|
4374 | container,
|
---|
4375 | anchor,
|
---|
4376 | parentComponent,
|
---|
4377 | parentSuspense,
|
---|
4378 | namespace,
|
---|
4379 | slotScopeIds,
|
---|
4380 | optimized
|
---|
4381 | );
|
---|
4382 | break;
|
---|
4383 | default:
|
---|
4384 | if (shapeFlag & 1) {
|
---|
4385 | processElement(
|
---|
4386 | n1,
|
---|
4387 | n2,
|
---|
4388 | container,
|
---|
4389 | anchor,
|
---|
4390 | parentComponent,
|
---|
4391 | parentSuspense,
|
---|
4392 | namespace,
|
---|
4393 | slotScopeIds,
|
---|
4394 | optimized
|
---|
4395 | );
|
---|
4396 | } else if (shapeFlag & 6) {
|
---|
4397 | processComponent(
|
---|
4398 | n1,
|
---|
4399 | n2,
|
---|
4400 | container,
|
---|
4401 | anchor,
|
---|
4402 | parentComponent,
|
---|
4403 | parentSuspense,
|
---|
4404 | namespace,
|
---|
4405 | slotScopeIds,
|
---|
4406 | optimized
|
---|
4407 | );
|
---|
4408 | } else if (shapeFlag & 64) {
|
---|
4409 | type.process(
|
---|
4410 | n1,
|
---|
4411 | n2,
|
---|
4412 | container,
|
---|
4413 | anchor,
|
---|
4414 | parentComponent,
|
---|
4415 | parentSuspense,
|
---|
4416 | namespace,
|
---|
4417 | slotScopeIds,
|
---|
4418 | optimized,
|
---|
4419 | internals
|
---|
4420 | );
|
---|
4421 | } else if (shapeFlag & 128) {
|
---|
4422 | type.process(
|
---|
4423 | n1,
|
---|
4424 | n2,
|
---|
4425 | container,
|
---|
4426 | anchor,
|
---|
4427 | parentComponent,
|
---|
4428 | parentSuspense,
|
---|
4429 | namespace,
|
---|
4430 | slotScopeIds,
|
---|
4431 | optimized,
|
---|
4432 | internals
|
---|
4433 | );
|
---|
4434 | } else {
|
---|
4435 | warn$1("Invalid VNode type:", type, `(${typeof type})`);
|
---|
4436 | }
|
---|
4437 | }
|
---|
4438 | if (ref != null && parentComponent) {
|
---|
4439 | setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
|
---|
4440 | }
|
---|
4441 | };
|
---|
4442 | const processText = (n1, n2, container, anchor) => {
|
---|
4443 | if (n1 == null) {
|
---|
4444 | hostInsert(
|
---|
4445 | n2.el = hostCreateText(n2.children),
|
---|
4446 | container,
|
---|
4447 | anchor
|
---|
4448 | );
|
---|
4449 | } else {
|
---|
4450 | const el = n2.el = n1.el;
|
---|
4451 | if (n2.children !== n1.children) {
|
---|
4452 | hostSetText(el, n2.children);
|
---|
4453 | }
|
---|
4454 | }
|
---|
4455 | };
|
---|
4456 | const processCommentNode = (n1, n2, container, anchor) => {
|
---|
4457 | if (n1 == null) {
|
---|
4458 | hostInsert(
|
---|
4459 | n2.el = hostCreateComment(n2.children || ""),
|
---|
4460 | container,
|
---|
4461 | anchor
|
---|
4462 | );
|
---|
4463 | } else {
|
---|
4464 | n2.el = n1.el;
|
---|
4465 | }
|
---|
4466 | };
|
---|
4467 | const mountStaticNode = (n2, container, anchor, namespace) => {
|
---|
4468 | [n2.el, n2.anchor] = hostInsertStaticContent(
|
---|
4469 | n2.children,
|
---|
4470 | container,
|
---|
4471 | anchor,
|
---|
4472 | namespace,
|
---|
4473 | n2.el,
|
---|
4474 | n2.anchor
|
---|
4475 | );
|
---|
4476 | };
|
---|
4477 | const patchStaticNode = (n1, n2, container, namespace) => {
|
---|
4478 | if (n2.children !== n1.children) {
|
---|
4479 | const anchor = hostNextSibling(n1.anchor);
|
---|
4480 | removeStaticNode(n1);
|
---|
4481 | [n2.el, n2.anchor] = hostInsertStaticContent(
|
---|
4482 | n2.children,
|
---|
4483 | container,
|
---|
4484 | anchor,
|
---|
4485 | namespace
|
---|
4486 | );
|
---|
4487 | } else {
|
---|
4488 | n2.el = n1.el;
|
---|
4489 | n2.anchor = n1.anchor;
|
---|
4490 | }
|
---|
4491 | };
|
---|
4492 | const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
|
---|
4493 | let next;
|
---|
4494 | while (el && el !== anchor) {
|
---|
4495 | next = hostNextSibling(el);
|
---|
4496 | hostInsert(el, container, nextSibling);
|
---|
4497 | el = next;
|
---|
4498 | }
|
---|
4499 | hostInsert(anchor, container, nextSibling);
|
---|
4500 | };
|
---|
4501 | const removeStaticNode = ({ el, anchor }) => {
|
---|
4502 | let next;
|
---|
4503 | while (el && el !== anchor) {
|
---|
4504 | next = hostNextSibling(el);
|
---|
4505 | hostRemove(el);
|
---|
4506 | el = next;
|
---|
4507 | }
|
---|
4508 | hostRemove(anchor);
|
---|
4509 | };
|
---|
4510 | const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
4511 | if (n2.type === "svg") {
|
---|
4512 | namespace = "svg";
|
---|
4513 | } else if (n2.type === "math") {
|
---|
4514 | namespace = "mathml";
|
---|
4515 | }
|
---|
4516 | if (n1 == null) {
|
---|
4517 | mountElement(
|
---|
4518 | n2,
|
---|
4519 | container,
|
---|
4520 | anchor,
|
---|
4521 | parentComponent,
|
---|
4522 | parentSuspense,
|
---|
4523 | namespace,
|
---|
4524 | slotScopeIds,
|
---|
4525 | optimized
|
---|
4526 | );
|
---|
4527 | } else {
|
---|
4528 | patchElement(
|
---|
4529 | n1,
|
---|
4530 | n2,
|
---|
4531 | parentComponent,
|
---|
4532 | parentSuspense,
|
---|
4533 | namespace,
|
---|
4534 | slotScopeIds,
|
---|
4535 | optimized
|
---|
4536 | );
|
---|
4537 | }
|
---|
4538 | };
|
---|
4539 | const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
4540 | let el;
|
---|
4541 | let vnodeHook;
|
---|
4542 | const { props, shapeFlag, transition, dirs } = vnode;
|
---|
4543 | el = vnode.el = hostCreateElement(
|
---|
4544 | vnode.type,
|
---|
4545 | namespace,
|
---|
4546 | props && props.is,
|
---|
4547 | props
|
---|
4548 | );
|
---|
4549 | if (shapeFlag & 8) {
|
---|
4550 | hostSetElementText(el, vnode.children);
|
---|
4551 | } else if (shapeFlag & 16) {
|
---|
4552 | mountChildren(
|
---|
4553 | vnode.children,
|
---|
4554 | el,
|
---|
4555 | null,
|
---|
4556 | parentComponent,
|
---|
4557 | parentSuspense,
|
---|
4558 | resolveChildrenNamespace(vnode, namespace),
|
---|
4559 | slotScopeIds,
|
---|
4560 | optimized
|
---|
4561 | );
|
---|
4562 | }
|
---|
4563 | if (dirs) {
|
---|
4564 | invokeDirectiveHook(vnode, null, parentComponent, "created");
|
---|
4565 | }
|
---|
4566 | setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
|
---|
4567 | if (props) {
|
---|
4568 | for (const key in props) {
|
---|
4569 | if (key !== "value" && !isReservedProp(key)) {
|
---|
4570 | hostPatchProp(el, key, null, props[key], namespace, parentComponent);
|
---|
4571 | }
|
---|
4572 | }
|
---|
4573 | if ("value" in props) {
|
---|
4574 | hostPatchProp(el, "value", null, props.value, namespace);
|
---|
4575 | }
|
---|
4576 | if (vnodeHook = props.onVnodeBeforeMount) {
|
---|
4577 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
---|
4578 | }
|
---|
4579 | }
|
---|
4580 | {
|
---|
4581 | def(el, "__vnode", vnode, true);
|
---|
4582 | def(el, "__vueParentComponent", parentComponent, true);
|
---|
4583 | }
|
---|
4584 | if (dirs) {
|
---|
4585 | invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
---|
4586 | }
|
---|
4587 | const needCallTransitionHooks = needTransition(parentSuspense, transition);
|
---|
4588 | if (needCallTransitionHooks) {
|
---|
4589 | transition.beforeEnter(el);
|
---|
4590 | }
|
---|
4591 | hostInsert(el, container, anchor);
|
---|
4592 | if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
|
---|
4593 | queuePostRenderEffect(() => {
|
---|
4594 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
---|
4595 | needCallTransitionHooks && transition.enter(el);
|
---|
4596 | dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
---|
4597 | }, parentSuspense);
|
---|
4598 | }
|
---|
4599 | };
|
---|
4600 | const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
|
---|
4601 | if (scopeId) {
|
---|
4602 | hostSetScopeId(el, scopeId);
|
---|
4603 | }
|
---|
4604 | if (slotScopeIds) {
|
---|
4605 | for (let i = 0; i < slotScopeIds.length; i++) {
|
---|
4606 | hostSetScopeId(el, slotScopeIds[i]);
|
---|
4607 | }
|
---|
4608 | }
|
---|
4609 | if (parentComponent) {
|
---|
4610 | let subTree = parentComponent.subTree;
|
---|
4611 | if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
|
---|
4612 | subTree = filterSingleRoot(subTree.children) || subTree;
|
---|
4613 | }
|
---|
4614 | if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
|
---|
4615 | const parentVNode = parentComponent.vnode;
|
---|
4616 | setScopeId(
|
---|
4617 | el,
|
---|
4618 | parentVNode,
|
---|
4619 | parentVNode.scopeId,
|
---|
4620 | parentVNode.slotScopeIds,
|
---|
4621 | parentComponent.parent
|
---|
4622 | );
|
---|
4623 | }
|
---|
4624 | }
|
---|
4625 | };
|
---|
4626 | const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
|
---|
4627 | for (let i = start; i < children.length; i++) {
|
---|
4628 | const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode$1(children[i]);
|
---|
4629 | patch(
|
---|
4630 | null,
|
---|
4631 | child,
|
---|
4632 | container,
|
---|
4633 | anchor,
|
---|
4634 | parentComponent,
|
---|
4635 | parentSuspense,
|
---|
4636 | namespace,
|
---|
4637 | slotScopeIds,
|
---|
4638 | optimized
|
---|
4639 | );
|
---|
4640 | }
|
---|
4641 | };
|
---|
4642 | const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
4643 | const el = n2.el = n1.el;
|
---|
4644 | {
|
---|
4645 | el.__vnode = n2;
|
---|
4646 | }
|
---|
4647 | let { patchFlag, dynamicChildren, dirs } = n2;
|
---|
4648 | patchFlag |= n1.patchFlag & 16;
|
---|
4649 | const oldProps = n1.props || EMPTY_OBJ;
|
---|
4650 | const newProps = n2.props || EMPTY_OBJ;
|
---|
4651 | let vnodeHook;
|
---|
4652 | parentComponent && toggleRecurse(parentComponent, false);
|
---|
4653 | if (vnodeHook = newProps.onVnodeBeforeUpdate) {
|
---|
4654 | invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
---|
4655 | }
|
---|
4656 | if (dirs) {
|
---|
4657 | invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
|
---|
4658 | }
|
---|
4659 | parentComponent && toggleRecurse(parentComponent, true);
|
---|
4660 | if (isHmrUpdating) {
|
---|
4661 | patchFlag = 0;
|
---|
4662 | optimized = false;
|
---|
4663 | dynamicChildren = null;
|
---|
4664 | }
|
---|
4665 | if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
|
---|
4666 | hostSetElementText(el, "");
|
---|
4667 | }
|
---|
4668 | if (dynamicChildren) {
|
---|
4669 | patchBlockChildren(
|
---|
4670 | n1.dynamicChildren,
|
---|
4671 | dynamicChildren,
|
---|
4672 | el,
|
---|
4673 | parentComponent,
|
---|
4674 | parentSuspense,
|
---|
4675 | resolveChildrenNamespace(n2, namespace),
|
---|
4676 | slotScopeIds
|
---|
4677 | );
|
---|
4678 | {
|
---|
4679 | traverseStaticChildren(n1, n2);
|
---|
4680 | }
|
---|
4681 | } else if (!optimized) {
|
---|
4682 | patchChildren(
|
---|
4683 | n1,
|
---|
4684 | n2,
|
---|
4685 | el,
|
---|
4686 | null,
|
---|
4687 | parentComponent,
|
---|
4688 | parentSuspense,
|
---|
4689 | resolveChildrenNamespace(n2, namespace),
|
---|
4690 | slotScopeIds,
|
---|
4691 | false
|
---|
4692 | );
|
---|
4693 | }
|
---|
4694 | if (patchFlag > 0) {
|
---|
4695 | if (patchFlag & 16) {
|
---|
4696 | patchProps(el, oldProps, newProps, parentComponent, namespace);
|
---|
4697 | } else {
|
---|
4698 | if (patchFlag & 2) {
|
---|
4699 | if (oldProps.class !== newProps.class) {
|
---|
4700 | hostPatchProp(el, "class", null, newProps.class, namespace);
|
---|
4701 | }
|
---|
4702 | }
|
---|
4703 | if (patchFlag & 4) {
|
---|
4704 | hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
|
---|
4705 | }
|
---|
4706 | if (patchFlag & 8) {
|
---|
4707 | const propsToUpdate = n2.dynamicProps;
|
---|
4708 | for (let i = 0; i < propsToUpdate.length; i++) {
|
---|
4709 | const key = propsToUpdate[i];
|
---|
4710 | const prev = oldProps[key];
|
---|
4711 | const next = newProps[key];
|
---|
4712 | if (next !== prev || key === "value") {
|
---|
4713 | hostPatchProp(el, key, prev, next, namespace, parentComponent);
|
---|
4714 | }
|
---|
4715 | }
|
---|
4716 | }
|
---|
4717 | }
|
---|
4718 | if (patchFlag & 1) {
|
---|
4719 | if (n1.children !== n2.children) {
|
---|
4720 | hostSetElementText(el, n2.children);
|
---|
4721 | }
|
---|
4722 | }
|
---|
4723 | } else if (!optimized && dynamicChildren == null) {
|
---|
4724 | patchProps(el, oldProps, newProps, parentComponent, namespace);
|
---|
4725 | }
|
---|
4726 | if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
|
---|
4727 | queuePostRenderEffect(() => {
|
---|
4728 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
---|
4729 | dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
|
---|
4730 | }, parentSuspense);
|
---|
4731 | }
|
---|
4732 | };
|
---|
4733 | const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
|
---|
4734 | for (let i = 0; i < newChildren.length; i++) {
|
---|
4735 | const oldVNode = oldChildren[i];
|
---|
4736 | const newVNode = newChildren[i];
|
---|
4737 | const container = (
|
---|
4738 | // oldVNode may be an errored async setup() component inside Suspense
|
---|
4739 | // which will not have a mounted element
|
---|
4740 | oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
|
---|
4741 | // of the Fragment itself so it can move its children.
|
---|
4742 | (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
|
---|
4743 | // which also requires the correct parent container
|
---|
4744 | !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
|
---|
4745 | oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
|
---|
4746 | // In other cases, the parent container is not actually used so we
|
---|
4747 | // just pass the block element here to avoid a DOM parentNode call.
|
---|
4748 | fallbackContainer
|
---|
4749 | )
|
---|
4750 | );
|
---|
4751 | patch(
|
---|
4752 | oldVNode,
|
---|
4753 | newVNode,
|
---|
4754 | container,
|
---|
4755 | null,
|
---|
4756 | parentComponent,
|
---|
4757 | parentSuspense,
|
---|
4758 | namespace,
|
---|
4759 | slotScopeIds,
|
---|
4760 | true
|
---|
4761 | );
|
---|
4762 | }
|
---|
4763 | };
|
---|
4764 | const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
|
---|
4765 | if (oldProps !== newProps) {
|
---|
4766 | if (oldProps !== EMPTY_OBJ) {
|
---|
4767 | for (const key in oldProps) {
|
---|
4768 | if (!isReservedProp(key) && !(key in newProps)) {
|
---|
4769 | hostPatchProp(
|
---|
4770 | el,
|
---|
4771 | key,
|
---|
4772 | oldProps[key],
|
---|
4773 | null,
|
---|
4774 | namespace,
|
---|
4775 | parentComponent
|
---|
4776 | );
|
---|
4777 | }
|
---|
4778 | }
|
---|
4779 | }
|
---|
4780 | for (const key in newProps) {
|
---|
4781 | if (isReservedProp(key)) continue;
|
---|
4782 | const next = newProps[key];
|
---|
4783 | const prev = oldProps[key];
|
---|
4784 | if (next !== prev && key !== "value") {
|
---|
4785 | hostPatchProp(el, key, prev, next, namespace, parentComponent);
|
---|
4786 | }
|
---|
4787 | }
|
---|
4788 | if ("value" in newProps) {
|
---|
4789 | hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
|
---|
4790 | }
|
---|
4791 | }
|
---|
4792 | };
|
---|
4793 | const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
4794 | const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
|
---|
4795 | const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
|
---|
4796 | let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
|
---|
4797 | if (
|
---|
4798 | // #5523 dev root fragment may inherit directives
|
---|
4799 | isHmrUpdating || patchFlag & 2048
|
---|
4800 | ) {
|
---|
4801 | patchFlag = 0;
|
---|
4802 | optimized = false;
|
---|
4803 | dynamicChildren = null;
|
---|
4804 | }
|
---|
4805 | if (fragmentSlotScopeIds) {
|
---|
4806 | slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
---|
4807 | }
|
---|
4808 | if (n1 == null) {
|
---|
4809 | hostInsert(fragmentStartAnchor, container, anchor);
|
---|
4810 | hostInsert(fragmentEndAnchor, container, anchor);
|
---|
4811 | mountChildren(
|
---|
4812 | // #10007
|
---|
4813 | // such fragment like `<></>` will be compiled into
|
---|
4814 | // a fragment which doesn't have a children.
|
---|
4815 | // In this case fallback to an empty array
|
---|
4816 | n2.children || [],
|
---|
4817 | container,
|
---|
4818 | fragmentEndAnchor,
|
---|
4819 | parentComponent,
|
---|
4820 | parentSuspense,
|
---|
4821 | namespace,
|
---|
4822 | slotScopeIds,
|
---|
4823 | optimized
|
---|
4824 | );
|
---|
4825 | } else {
|
---|
4826 | if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
|
---|
4827 | // of renderSlot() with no valid children
|
---|
4828 | n1.dynamicChildren) {
|
---|
4829 | patchBlockChildren(
|
---|
4830 | n1.dynamicChildren,
|
---|
4831 | dynamicChildren,
|
---|
4832 | container,
|
---|
4833 | parentComponent,
|
---|
4834 | parentSuspense,
|
---|
4835 | namespace,
|
---|
4836 | slotScopeIds
|
---|
4837 | );
|
---|
4838 | {
|
---|
4839 | traverseStaticChildren(n1, n2);
|
---|
4840 | }
|
---|
4841 | } else {
|
---|
4842 | patchChildren(
|
---|
4843 | n1,
|
---|
4844 | n2,
|
---|
4845 | container,
|
---|
4846 | fragmentEndAnchor,
|
---|
4847 | parentComponent,
|
---|
4848 | parentSuspense,
|
---|
4849 | namespace,
|
---|
4850 | slotScopeIds,
|
---|
4851 | optimized
|
---|
4852 | );
|
---|
4853 | }
|
---|
4854 | }
|
---|
4855 | };
|
---|
4856 | const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
4857 | n2.slotScopeIds = slotScopeIds;
|
---|
4858 | if (n1 == null) {
|
---|
4859 | if (n2.shapeFlag & 512) {
|
---|
4860 | parentComponent.ctx.activate(
|
---|
4861 | n2,
|
---|
4862 | container,
|
---|
4863 | anchor,
|
---|
4864 | namespace,
|
---|
4865 | optimized
|
---|
4866 | );
|
---|
4867 | } else {
|
---|
4868 | mountComponent(
|
---|
4869 | n2,
|
---|
4870 | container,
|
---|
4871 | anchor,
|
---|
4872 | parentComponent,
|
---|
4873 | parentSuspense,
|
---|
4874 | namespace,
|
---|
4875 | optimized
|
---|
4876 | );
|
---|
4877 | }
|
---|
4878 | } else {
|
---|
4879 | updateComponent(n1, n2, optimized);
|
---|
4880 | }
|
---|
4881 | };
|
---|
4882 | const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
|
---|
4883 | const instance = (initialVNode.component = createComponentInstance$1(
|
---|
4884 | initialVNode,
|
---|
4885 | parentComponent,
|
---|
4886 | parentSuspense
|
---|
4887 | ));
|
---|
4888 | if (instance.type.__hmrId) {
|
---|
4889 | registerHMR(instance);
|
---|
4890 | }
|
---|
4891 | {
|
---|
4892 | pushWarningContext$1(initialVNode);
|
---|
4893 | startMeasure(instance, `mount`);
|
---|
4894 | }
|
---|
4895 | if (isKeepAlive(initialVNode)) {
|
---|
4896 | instance.ctx.renderer = internals;
|
---|
4897 | }
|
---|
4898 | {
|
---|
4899 | {
|
---|
4900 | startMeasure(instance, `init`);
|
---|
4901 | }
|
---|
4902 | setupComponent$1(instance, false, optimized);
|
---|
4903 | {
|
---|
4904 | endMeasure(instance, `init`);
|
---|
4905 | }
|
---|
4906 | }
|
---|
4907 | if (instance.asyncDep) {
|
---|
4908 | if (isHmrUpdating) initialVNode.el = null;
|
---|
4909 | parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
|
---|
4910 | if (!initialVNode.el) {
|
---|
4911 | const placeholder = instance.subTree = createVNode(Comment);
|
---|
4912 | processCommentNode(null, placeholder, container, anchor);
|
---|
4913 | }
|
---|
4914 | } else {
|
---|
4915 | setupRenderEffect(
|
---|
4916 | instance,
|
---|
4917 | initialVNode,
|
---|
4918 | container,
|
---|
4919 | anchor,
|
---|
4920 | parentSuspense,
|
---|
4921 | namespace,
|
---|
4922 | optimized
|
---|
4923 | );
|
---|
4924 | }
|
---|
4925 | {
|
---|
4926 | popWarningContext$1();
|
---|
4927 | endMeasure(instance, `mount`);
|
---|
4928 | }
|
---|
4929 | };
|
---|
4930 | const updateComponent = (n1, n2, optimized) => {
|
---|
4931 | const instance = n2.component = n1.component;
|
---|
4932 | if (shouldUpdateComponent(n1, n2, optimized)) {
|
---|
4933 | if (instance.asyncDep && !instance.asyncResolved) {
|
---|
4934 | {
|
---|
4935 | pushWarningContext$1(n2);
|
---|
4936 | }
|
---|
4937 | updateComponentPreRender(instance, n2, optimized);
|
---|
4938 | {
|
---|
4939 | popWarningContext$1();
|
---|
4940 | }
|
---|
4941 | return;
|
---|
4942 | } else {
|
---|
4943 | instance.next = n2;
|
---|
4944 | instance.update();
|
---|
4945 | }
|
---|
4946 | } else {
|
---|
4947 | n2.el = n1.el;
|
---|
4948 | instance.vnode = n2;
|
---|
4949 | }
|
---|
4950 | };
|
---|
4951 | const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
|
---|
4952 | const componentUpdateFn = () => {
|
---|
4953 | if (!instance.isMounted) {
|
---|
4954 | let vnodeHook;
|
---|
4955 | const { el, props } = initialVNode;
|
---|
4956 | const { bm, m, parent, root, type } = instance;
|
---|
4957 | const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
|
---|
4958 | toggleRecurse(instance, false);
|
---|
4959 | if (bm) {
|
---|
4960 | invokeArrayFns(bm);
|
---|
4961 | }
|
---|
4962 | if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
|
---|
4963 | invokeVNodeHook(vnodeHook, parent, initialVNode);
|
---|
4964 | }
|
---|
4965 | toggleRecurse(instance, true);
|
---|
4966 | if (el && hydrateNode) {
|
---|
4967 | const hydrateSubTree = () => {
|
---|
4968 | {
|
---|
4969 | startMeasure(instance, `render`);
|
---|
4970 | }
|
---|
4971 | instance.subTree = renderComponentRoot$1(instance);
|
---|
4972 | {
|
---|
4973 | endMeasure(instance, `render`);
|
---|
4974 | }
|
---|
4975 | {
|
---|
4976 | startMeasure(instance, `hydrate`);
|
---|
4977 | }
|
---|
4978 | hydrateNode(
|
---|
4979 | el,
|
---|
4980 | instance.subTree,
|
---|
4981 | instance,
|
---|
4982 | parentSuspense,
|
---|
4983 | null
|
---|
4984 | );
|
---|
4985 | {
|
---|
4986 | endMeasure(instance, `hydrate`);
|
---|
4987 | }
|
---|
4988 | };
|
---|
4989 | if (isAsyncWrapperVNode && type.__asyncHydrate) {
|
---|
4990 | type.__asyncHydrate(
|
---|
4991 | el,
|
---|
4992 | instance,
|
---|
4993 | hydrateSubTree
|
---|
4994 | );
|
---|
4995 | } else {
|
---|
4996 | hydrateSubTree();
|
---|
4997 | }
|
---|
4998 | } else {
|
---|
4999 | if (root.ce) {
|
---|
5000 | root.ce._injectChildStyle(type);
|
---|
5001 | }
|
---|
5002 | {
|
---|
5003 | startMeasure(instance, `render`);
|
---|
5004 | }
|
---|
5005 | const subTree = instance.subTree = renderComponentRoot$1(instance);
|
---|
5006 | {
|
---|
5007 | endMeasure(instance, `render`);
|
---|
5008 | }
|
---|
5009 | {
|
---|
5010 | startMeasure(instance, `patch`);
|
---|
5011 | }
|
---|
5012 | patch(
|
---|
5013 | null,
|
---|
5014 | subTree,
|
---|
5015 | container,
|
---|
5016 | anchor,
|
---|
5017 | instance,
|
---|
5018 | parentSuspense,
|
---|
5019 | namespace
|
---|
5020 | );
|
---|
5021 | {
|
---|
5022 | endMeasure(instance, `patch`);
|
---|
5023 | }
|
---|
5024 | initialVNode.el = subTree.el;
|
---|
5025 | }
|
---|
5026 | if (m) {
|
---|
5027 | queuePostRenderEffect(m, parentSuspense);
|
---|
5028 | }
|
---|
5029 | if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
|
---|
5030 | const scopedInitialVNode = initialVNode;
|
---|
5031 | queuePostRenderEffect(
|
---|
5032 | () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
|
---|
5033 | parentSuspense
|
---|
5034 | );
|
---|
5035 | }
|
---|
5036 | if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
|
---|
5037 | instance.a && queuePostRenderEffect(instance.a, parentSuspense);
|
---|
5038 | }
|
---|
5039 | instance.isMounted = true;
|
---|
5040 | {
|
---|
5041 | devtoolsComponentAdded(instance);
|
---|
5042 | }
|
---|
5043 | initialVNode = container = anchor = null;
|
---|
5044 | } else {
|
---|
5045 | let { next, bu, u, parent, vnode } = instance;
|
---|
5046 | {
|
---|
5047 | const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
|
---|
5048 | if (nonHydratedAsyncRoot) {
|
---|
5049 | if (next) {
|
---|
5050 | next.el = vnode.el;
|
---|
5051 | updateComponentPreRender(instance, next, optimized);
|
---|
5052 | }
|
---|
5053 | nonHydratedAsyncRoot.asyncDep.then(() => {
|
---|
5054 | if (!instance.isUnmounted) {
|
---|
5055 | componentUpdateFn();
|
---|
5056 | }
|
---|
5057 | });
|
---|
5058 | return;
|
---|
5059 | }
|
---|
5060 | }
|
---|
5061 | let originNext = next;
|
---|
5062 | let vnodeHook;
|
---|
5063 | {
|
---|
5064 | pushWarningContext$1(next || instance.vnode);
|
---|
5065 | }
|
---|
5066 | toggleRecurse(instance, false);
|
---|
5067 | if (next) {
|
---|
5068 | next.el = vnode.el;
|
---|
5069 | updateComponentPreRender(instance, next, optimized);
|
---|
5070 | } else {
|
---|
5071 | next = vnode;
|
---|
5072 | }
|
---|
5073 | if (bu) {
|
---|
5074 | invokeArrayFns(bu);
|
---|
5075 | }
|
---|
5076 | if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
|
---|
5077 | invokeVNodeHook(vnodeHook, parent, next, vnode);
|
---|
5078 | }
|
---|
5079 | toggleRecurse(instance, true);
|
---|
5080 | {
|
---|
5081 | startMeasure(instance, `render`);
|
---|
5082 | }
|
---|
5083 | const nextTree = renderComponentRoot$1(instance);
|
---|
5084 | {
|
---|
5085 | endMeasure(instance, `render`);
|
---|
5086 | }
|
---|
5087 | const prevTree = instance.subTree;
|
---|
5088 | instance.subTree = nextTree;
|
---|
5089 | {
|
---|
5090 | startMeasure(instance, `patch`);
|
---|
5091 | }
|
---|
5092 | patch(
|
---|
5093 | prevTree,
|
---|
5094 | nextTree,
|
---|
5095 | // parent may have changed if it's in a teleport
|
---|
5096 | hostParentNode(prevTree.el),
|
---|
5097 | // anchor may have changed if it's in a fragment
|
---|
5098 | getNextHostNode(prevTree),
|
---|
5099 | instance,
|
---|
5100 | parentSuspense,
|
---|
5101 | namespace
|
---|
5102 | );
|
---|
5103 | {
|
---|
5104 | endMeasure(instance, `patch`);
|
---|
5105 | }
|
---|
5106 | next.el = nextTree.el;
|
---|
5107 | if (originNext === null) {
|
---|
5108 | updateHOCHostEl(instance, nextTree.el);
|
---|
5109 | }
|
---|
5110 | if (u) {
|
---|
5111 | queuePostRenderEffect(u, parentSuspense);
|
---|
5112 | }
|
---|
5113 | if (vnodeHook = next.props && next.props.onVnodeUpdated) {
|
---|
5114 | queuePostRenderEffect(
|
---|
5115 | () => invokeVNodeHook(vnodeHook, parent, next, vnode),
|
---|
5116 | parentSuspense
|
---|
5117 | );
|
---|
5118 | }
|
---|
5119 | {
|
---|
5120 | devtoolsComponentUpdated(instance);
|
---|
5121 | }
|
---|
5122 | {
|
---|
5123 | popWarningContext$1();
|
---|
5124 | }
|
---|
5125 | }
|
---|
5126 | };
|
---|
5127 | instance.scope.on();
|
---|
5128 | const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
|
---|
5129 | instance.scope.off();
|
---|
5130 | const update = instance.update = effect.run.bind(effect);
|
---|
5131 | const job = instance.job = effect.runIfDirty.bind(effect);
|
---|
5132 | job.i = instance;
|
---|
5133 | job.id = instance.uid;
|
---|
5134 | effect.scheduler = () => queueJob(job);
|
---|
5135 | toggleRecurse(instance, true);
|
---|
5136 | {
|
---|
5137 | effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
|
---|
5138 | effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
|
---|
5139 | }
|
---|
5140 | update();
|
---|
5141 | };
|
---|
5142 | const updateComponentPreRender = (instance, nextVNode, optimized) => {
|
---|
5143 | nextVNode.component = instance;
|
---|
5144 | const prevProps = instance.vnode.props;
|
---|
5145 | instance.vnode = nextVNode;
|
---|
5146 | instance.next = null;
|
---|
5147 | updateProps(instance, nextVNode.props, prevProps, optimized);
|
---|
5148 | updateSlots(instance, nextVNode.children, optimized);
|
---|
5149 | pauseTracking();
|
---|
5150 | flushPreFlushCbs(instance);
|
---|
5151 | resetTracking();
|
---|
5152 | };
|
---|
5153 | const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
|
---|
5154 | const c1 = n1 && n1.children;
|
---|
5155 | const prevShapeFlag = n1 ? n1.shapeFlag : 0;
|
---|
5156 | const c2 = n2.children;
|
---|
5157 | const { patchFlag, shapeFlag } = n2;
|
---|
5158 | if (patchFlag > 0) {
|
---|
5159 | if (patchFlag & 128) {
|
---|
5160 | patchKeyedChildren(
|
---|
5161 | c1,
|
---|
5162 | c2,
|
---|
5163 | container,
|
---|
5164 | anchor,
|
---|
5165 | parentComponent,
|
---|
5166 | parentSuspense,
|
---|
5167 | namespace,
|
---|
5168 | slotScopeIds,
|
---|
5169 | optimized
|
---|
5170 | );
|
---|
5171 | return;
|
---|
5172 | } else if (patchFlag & 256) {
|
---|
5173 | patchUnkeyedChildren(
|
---|
5174 | c1,
|
---|
5175 | c2,
|
---|
5176 | container,
|
---|
5177 | anchor,
|
---|
5178 | parentComponent,
|
---|
5179 | parentSuspense,
|
---|
5180 | namespace,
|
---|
5181 | slotScopeIds,
|
---|
5182 | optimized
|
---|
5183 | );
|
---|
5184 | return;
|
---|
5185 | }
|
---|
5186 | }
|
---|
5187 | if (shapeFlag & 8) {
|
---|
5188 | if (prevShapeFlag & 16) {
|
---|
5189 | unmountChildren(c1, parentComponent, parentSuspense);
|
---|
5190 | }
|
---|
5191 | if (c2 !== c1) {
|
---|
5192 | hostSetElementText(container, c2);
|
---|
5193 | }
|
---|
5194 | } else {
|
---|
5195 | if (prevShapeFlag & 16) {
|
---|
5196 | if (shapeFlag & 16) {
|
---|
5197 | patchKeyedChildren(
|
---|
5198 | c1,
|
---|
5199 | c2,
|
---|
5200 | container,
|
---|
5201 | anchor,
|
---|
5202 | parentComponent,
|
---|
5203 | parentSuspense,
|
---|
5204 | namespace,
|
---|
5205 | slotScopeIds,
|
---|
5206 | optimized
|
---|
5207 | );
|
---|
5208 | } else {
|
---|
5209 | unmountChildren(c1, parentComponent, parentSuspense, true);
|
---|
5210 | }
|
---|
5211 | } else {
|
---|
5212 | if (prevShapeFlag & 8) {
|
---|
5213 | hostSetElementText(container, "");
|
---|
5214 | }
|
---|
5215 | if (shapeFlag & 16) {
|
---|
5216 | mountChildren(
|
---|
5217 | c2,
|
---|
5218 | container,
|
---|
5219 | anchor,
|
---|
5220 | parentComponent,
|
---|
5221 | parentSuspense,
|
---|
5222 | namespace,
|
---|
5223 | slotScopeIds,
|
---|
5224 | optimized
|
---|
5225 | );
|
---|
5226 | }
|
---|
5227 | }
|
---|
5228 | }
|
---|
5229 | };
|
---|
5230 | const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
5231 | c1 = c1 || EMPTY_ARR;
|
---|
5232 | c2 = c2 || EMPTY_ARR;
|
---|
5233 | const oldLength = c1.length;
|
---|
5234 | const newLength = c2.length;
|
---|
5235 | const commonLength = Math.min(oldLength, newLength);
|
---|
5236 | let i;
|
---|
5237 | for (i = 0; i < commonLength; i++) {
|
---|
5238 | const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode$1(c2[i]);
|
---|
5239 | patch(
|
---|
5240 | c1[i],
|
---|
5241 | nextChild,
|
---|
5242 | container,
|
---|
5243 | null,
|
---|
5244 | parentComponent,
|
---|
5245 | parentSuspense,
|
---|
5246 | namespace,
|
---|
5247 | slotScopeIds,
|
---|
5248 | optimized
|
---|
5249 | );
|
---|
5250 | }
|
---|
5251 | if (oldLength > newLength) {
|
---|
5252 | unmountChildren(
|
---|
5253 | c1,
|
---|
5254 | parentComponent,
|
---|
5255 | parentSuspense,
|
---|
5256 | true,
|
---|
5257 | false,
|
---|
5258 | commonLength
|
---|
5259 | );
|
---|
5260 | } else {
|
---|
5261 | mountChildren(
|
---|
5262 | c2,
|
---|
5263 | container,
|
---|
5264 | anchor,
|
---|
5265 | parentComponent,
|
---|
5266 | parentSuspense,
|
---|
5267 | namespace,
|
---|
5268 | slotScopeIds,
|
---|
5269 | optimized,
|
---|
5270 | commonLength
|
---|
5271 | );
|
---|
5272 | }
|
---|
5273 | };
|
---|
5274 | const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
5275 | let i = 0;
|
---|
5276 | const l2 = c2.length;
|
---|
5277 | let e1 = c1.length - 1;
|
---|
5278 | let e2 = l2 - 1;
|
---|
5279 | while (i <= e1 && i <= e2) {
|
---|
5280 | const n1 = c1[i];
|
---|
5281 | const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode$1(c2[i]);
|
---|
5282 | if (isSameVNodeType(n1, n2)) {
|
---|
5283 | patch(
|
---|
5284 | n1,
|
---|
5285 | n2,
|
---|
5286 | container,
|
---|
5287 | null,
|
---|
5288 | parentComponent,
|
---|
5289 | parentSuspense,
|
---|
5290 | namespace,
|
---|
5291 | slotScopeIds,
|
---|
5292 | optimized
|
---|
5293 | );
|
---|
5294 | } else {
|
---|
5295 | break;
|
---|
5296 | }
|
---|
5297 | i++;
|
---|
5298 | }
|
---|
5299 | while (i <= e1 && i <= e2) {
|
---|
5300 | const n1 = c1[e1];
|
---|
5301 | const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode$1(c2[e2]);
|
---|
5302 | if (isSameVNodeType(n1, n2)) {
|
---|
5303 | patch(
|
---|
5304 | n1,
|
---|
5305 | n2,
|
---|
5306 | container,
|
---|
5307 | null,
|
---|
5308 | parentComponent,
|
---|
5309 | parentSuspense,
|
---|
5310 | namespace,
|
---|
5311 | slotScopeIds,
|
---|
5312 | optimized
|
---|
5313 | );
|
---|
5314 | } else {
|
---|
5315 | break;
|
---|
5316 | }
|
---|
5317 | e1--;
|
---|
5318 | e2--;
|
---|
5319 | }
|
---|
5320 | if (i > e1) {
|
---|
5321 | if (i <= e2) {
|
---|
5322 | const nextPos = e2 + 1;
|
---|
5323 | const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
|
---|
5324 | while (i <= e2) {
|
---|
5325 | patch(
|
---|
5326 | null,
|
---|
5327 | c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode$1(c2[i]),
|
---|
5328 | container,
|
---|
5329 | anchor,
|
---|
5330 | parentComponent,
|
---|
5331 | parentSuspense,
|
---|
5332 | namespace,
|
---|
5333 | slotScopeIds,
|
---|
5334 | optimized
|
---|
5335 | );
|
---|
5336 | i++;
|
---|
5337 | }
|
---|
5338 | }
|
---|
5339 | } else if (i > e2) {
|
---|
5340 | while (i <= e1) {
|
---|
5341 | unmount(c1[i], parentComponent, parentSuspense, true);
|
---|
5342 | i++;
|
---|
5343 | }
|
---|
5344 | } else {
|
---|
5345 | const s1 = i;
|
---|
5346 | const s2 = i;
|
---|
5347 | const keyToNewIndexMap = /* @__PURE__ */ new Map();
|
---|
5348 | for (i = s2; i <= e2; i++) {
|
---|
5349 | const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode$1(c2[i]);
|
---|
5350 | if (nextChild.key != null) {
|
---|
5351 | if (keyToNewIndexMap.has(nextChild.key)) {
|
---|
5352 | warn$1(
|
---|
5353 | `Duplicate keys found during update:`,
|
---|
5354 | JSON.stringify(nextChild.key),
|
---|
5355 | `Make sure keys are unique.`
|
---|
5356 | );
|
---|
5357 | }
|
---|
5358 | keyToNewIndexMap.set(nextChild.key, i);
|
---|
5359 | }
|
---|
5360 | }
|
---|
5361 | let j;
|
---|
5362 | let patched = 0;
|
---|
5363 | const toBePatched = e2 - s2 + 1;
|
---|
5364 | let moved = false;
|
---|
5365 | let maxNewIndexSoFar = 0;
|
---|
5366 | const newIndexToOldIndexMap = new Array(toBePatched);
|
---|
5367 | for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0;
|
---|
5368 | for (i = s1; i <= e1; i++) {
|
---|
5369 | const prevChild = c1[i];
|
---|
5370 | if (patched >= toBePatched) {
|
---|
5371 | unmount(prevChild, parentComponent, parentSuspense, true);
|
---|
5372 | continue;
|
---|
5373 | }
|
---|
5374 | let newIndex;
|
---|
5375 | if (prevChild.key != null) {
|
---|
5376 | newIndex = keyToNewIndexMap.get(prevChild.key);
|
---|
5377 | } else {
|
---|
5378 | for (j = s2; j <= e2; j++) {
|
---|
5379 | if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
|
---|
5380 | newIndex = j;
|
---|
5381 | break;
|
---|
5382 | }
|
---|
5383 | }
|
---|
5384 | }
|
---|
5385 | if (newIndex === void 0) {
|
---|
5386 | unmount(prevChild, parentComponent, parentSuspense, true);
|
---|
5387 | } else {
|
---|
5388 | newIndexToOldIndexMap[newIndex - s2] = i + 1;
|
---|
5389 | if (newIndex >= maxNewIndexSoFar) {
|
---|
5390 | maxNewIndexSoFar = newIndex;
|
---|
5391 | } else {
|
---|
5392 | moved = true;
|
---|
5393 | }
|
---|
5394 | patch(
|
---|
5395 | prevChild,
|
---|
5396 | c2[newIndex],
|
---|
5397 | container,
|
---|
5398 | null,
|
---|
5399 | parentComponent,
|
---|
5400 | parentSuspense,
|
---|
5401 | namespace,
|
---|
5402 | slotScopeIds,
|
---|
5403 | optimized
|
---|
5404 | );
|
---|
5405 | patched++;
|
---|
5406 | }
|
---|
5407 | }
|
---|
5408 | const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
|
---|
5409 | j = increasingNewIndexSequence.length - 1;
|
---|
5410 | for (i = toBePatched - 1; i >= 0; i--) {
|
---|
5411 | const nextIndex = s2 + i;
|
---|
5412 | const nextChild = c2[nextIndex];
|
---|
5413 | const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
|
---|
5414 | if (newIndexToOldIndexMap[i] === 0) {
|
---|
5415 | patch(
|
---|
5416 | null,
|
---|
5417 | nextChild,
|
---|
5418 | container,
|
---|
5419 | anchor,
|
---|
5420 | parentComponent,
|
---|
5421 | parentSuspense,
|
---|
5422 | namespace,
|
---|
5423 | slotScopeIds,
|
---|
5424 | optimized
|
---|
5425 | );
|
---|
5426 | } else if (moved) {
|
---|
5427 | if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
---|
5428 | move(nextChild, container, anchor, 2);
|
---|
5429 | } else {
|
---|
5430 | j--;
|
---|
5431 | }
|
---|
5432 | }
|
---|
5433 | }
|
---|
5434 | }
|
---|
5435 | };
|
---|
5436 | const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
|
---|
5437 | const { el, type, transition, children, shapeFlag } = vnode;
|
---|
5438 | if (shapeFlag & 6) {
|
---|
5439 | move(vnode.component.subTree, container, anchor, moveType);
|
---|
5440 | return;
|
---|
5441 | }
|
---|
5442 | if (shapeFlag & 128) {
|
---|
5443 | vnode.suspense.move(container, anchor, moveType);
|
---|
5444 | return;
|
---|
5445 | }
|
---|
5446 | if (shapeFlag & 64) {
|
---|
5447 | type.move(vnode, container, anchor, internals);
|
---|
5448 | return;
|
---|
5449 | }
|
---|
5450 | if (type === Fragment) {
|
---|
5451 | hostInsert(el, container, anchor);
|
---|
5452 | for (let i = 0; i < children.length; i++) {
|
---|
5453 | move(children[i], container, anchor, moveType);
|
---|
5454 | }
|
---|
5455 | hostInsert(vnode.anchor, container, anchor);
|
---|
5456 | return;
|
---|
5457 | }
|
---|
5458 | if (type === Static) {
|
---|
5459 | moveStaticNode(vnode, container, anchor);
|
---|
5460 | return;
|
---|
5461 | }
|
---|
5462 | const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
|
---|
5463 | if (needTransition2) {
|
---|
5464 | if (moveType === 0) {
|
---|
5465 | transition.beforeEnter(el);
|
---|
5466 | hostInsert(el, container, anchor);
|
---|
5467 | queuePostRenderEffect(() => transition.enter(el), parentSuspense);
|
---|
5468 | } else {
|
---|
5469 | const { leave, delayLeave, afterLeave } = transition;
|
---|
5470 | const remove2 = () => hostInsert(el, container, anchor);
|
---|
5471 | const performLeave = () => {
|
---|
5472 | leave(el, () => {
|
---|
5473 | remove2();
|
---|
5474 | afterLeave && afterLeave();
|
---|
5475 | });
|
---|
5476 | };
|
---|
5477 | if (delayLeave) {
|
---|
5478 | delayLeave(el, remove2, performLeave);
|
---|
5479 | } else {
|
---|
5480 | performLeave();
|
---|
5481 | }
|
---|
5482 | }
|
---|
5483 | } else {
|
---|
5484 | hostInsert(el, container, anchor);
|
---|
5485 | }
|
---|
5486 | };
|
---|
5487 | const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
|
---|
5488 | const {
|
---|
5489 | type,
|
---|
5490 | props,
|
---|
5491 | ref,
|
---|
5492 | children,
|
---|
5493 | dynamicChildren,
|
---|
5494 | shapeFlag,
|
---|
5495 | patchFlag,
|
---|
5496 | dirs,
|
---|
5497 | cacheIndex
|
---|
5498 | } = vnode;
|
---|
5499 | if (patchFlag === -2) {
|
---|
5500 | optimized = false;
|
---|
5501 | }
|
---|
5502 | if (ref != null) {
|
---|
5503 | setRef(ref, null, parentSuspense, vnode, true);
|
---|
5504 | }
|
---|
5505 | if (cacheIndex != null) {
|
---|
5506 | parentComponent.renderCache[cacheIndex] = void 0;
|
---|
5507 | }
|
---|
5508 | if (shapeFlag & 256) {
|
---|
5509 | parentComponent.ctx.deactivate(vnode);
|
---|
5510 | return;
|
---|
5511 | }
|
---|
5512 | const shouldInvokeDirs = shapeFlag & 1 && dirs;
|
---|
5513 | const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
|
---|
5514 | let vnodeHook;
|
---|
5515 | if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
|
---|
5516 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
---|
5517 | }
|
---|
5518 | if (shapeFlag & 6) {
|
---|
5519 | unmountComponent(vnode.component, parentSuspense, doRemove);
|
---|
5520 | } else {
|
---|
5521 | if (shapeFlag & 128) {
|
---|
5522 | vnode.suspense.unmount(parentSuspense, doRemove);
|
---|
5523 | return;
|
---|
5524 | }
|
---|
5525 | if (shouldInvokeDirs) {
|
---|
5526 | invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
|
---|
5527 | }
|
---|
5528 | if (shapeFlag & 64) {
|
---|
5529 | vnode.type.remove(
|
---|
5530 | vnode,
|
---|
5531 | parentComponent,
|
---|
5532 | parentSuspense,
|
---|
5533 | internals,
|
---|
5534 | doRemove
|
---|
5535 | );
|
---|
5536 | } else if (dynamicChildren && // #5154
|
---|
5537 | // when v-once is used inside a block, setBlockTracking(-1) marks the
|
---|
5538 | // parent block with hasOnce: true
|
---|
5539 | // so that it doesn't take the fast path during unmount - otherwise
|
---|
5540 | // components nested in v-once are never unmounted.
|
---|
5541 | !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
|
---|
5542 | (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
|
---|
5543 | unmountChildren(
|
---|
5544 | dynamicChildren,
|
---|
5545 | parentComponent,
|
---|
5546 | parentSuspense,
|
---|
5547 | false,
|
---|
5548 | true
|
---|
5549 | );
|
---|
5550 | } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
|
---|
5551 | unmountChildren(children, parentComponent, parentSuspense);
|
---|
5552 | }
|
---|
5553 | if (doRemove) {
|
---|
5554 | remove(vnode);
|
---|
5555 | }
|
---|
5556 | }
|
---|
5557 | if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
|
---|
5558 | queuePostRenderEffect(() => {
|
---|
5559 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
---|
5560 | shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
|
---|
5561 | }, parentSuspense);
|
---|
5562 | }
|
---|
5563 | };
|
---|
5564 | const remove = (vnode) => {
|
---|
5565 | const { type, el, anchor, transition } = vnode;
|
---|
5566 | if (type === Fragment) {
|
---|
5567 | if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
|
---|
5568 | vnode.children.forEach((child) => {
|
---|
5569 | if (child.type === Comment) {
|
---|
5570 | hostRemove(child.el);
|
---|
5571 | } else {
|
---|
5572 | remove(child);
|
---|
5573 | }
|
---|
5574 | });
|
---|
5575 | } else {
|
---|
5576 | removeFragment(el, anchor);
|
---|
5577 | }
|
---|
5578 | return;
|
---|
5579 | }
|
---|
5580 | if (type === Static) {
|
---|
5581 | removeStaticNode(vnode);
|
---|
5582 | return;
|
---|
5583 | }
|
---|
5584 | const performRemove = () => {
|
---|
5585 | hostRemove(el);
|
---|
5586 | if (transition && !transition.persisted && transition.afterLeave) {
|
---|
5587 | transition.afterLeave();
|
---|
5588 | }
|
---|
5589 | };
|
---|
5590 | if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
|
---|
5591 | const { leave, delayLeave } = transition;
|
---|
5592 | const performLeave = () => leave(el, performRemove);
|
---|
5593 | if (delayLeave) {
|
---|
5594 | delayLeave(vnode.el, performRemove, performLeave);
|
---|
5595 | } else {
|
---|
5596 | performLeave();
|
---|
5597 | }
|
---|
5598 | } else {
|
---|
5599 | performRemove();
|
---|
5600 | }
|
---|
5601 | };
|
---|
5602 | const removeFragment = (cur, end) => {
|
---|
5603 | let next;
|
---|
5604 | while (cur !== end) {
|
---|
5605 | next = hostNextSibling(cur);
|
---|
5606 | hostRemove(cur);
|
---|
5607 | cur = next;
|
---|
5608 | }
|
---|
5609 | hostRemove(end);
|
---|
5610 | };
|
---|
5611 | const unmountComponent = (instance, parentSuspense, doRemove) => {
|
---|
5612 | if (instance.type.__hmrId) {
|
---|
5613 | unregisterHMR(instance);
|
---|
5614 | }
|
---|
5615 | const { bum, scope, job, subTree, um, m, a } = instance;
|
---|
5616 | invalidateMount(m);
|
---|
5617 | invalidateMount(a);
|
---|
5618 | if (bum) {
|
---|
5619 | invokeArrayFns(bum);
|
---|
5620 | }
|
---|
5621 | scope.stop();
|
---|
5622 | if (job) {
|
---|
5623 | job.flags |= 8;
|
---|
5624 | unmount(subTree, instance, parentSuspense, doRemove);
|
---|
5625 | }
|
---|
5626 | if (um) {
|
---|
5627 | queuePostRenderEffect(um, parentSuspense);
|
---|
5628 | }
|
---|
5629 | queuePostRenderEffect(() => {
|
---|
5630 | instance.isUnmounted = true;
|
---|
5631 | }, parentSuspense);
|
---|
5632 | if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
|
---|
5633 | parentSuspense.deps--;
|
---|
5634 | if (parentSuspense.deps === 0) {
|
---|
5635 | parentSuspense.resolve();
|
---|
5636 | }
|
---|
5637 | }
|
---|
5638 | {
|
---|
5639 | devtoolsComponentRemoved(instance);
|
---|
5640 | }
|
---|
5641 | };
|
---|
5642 | const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
|
---|
5643 | for (let i = start; i < children.length; i++) {
|
---|
5644 | unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
|
---|
5645 | }
|
---|
5646 | };
|
---|
5647 | const getNextHostNode = (vnode) => {
|
---|
5648 | if (vnode.shapeFlag & 6) {
|
---|
5649 | return getNextHostNode(vnode.component.subTree);
|
---|
5650 | }
|
---|
5651 | if (vnode.shapeFlag & 128) {
|
---|
5652 | return vnode.suspense.next();
|
---|
5653 | }
|
---|
5654 | const el = hostNextSibling(vnode.anchor || vnode.el);
|
---|
5655 | const teleportEnd = el && el[TeleportEndKey];
|
---|
5656 | return teleportEnd ? hostNextSibling(teleportEnd) : el;
|
---|
5657 | };
|
---|
5658 | let isFlushing = false;
|
---|
5659 | const render = (vnode, container, namespace) => {
|
---|
5660 | if (vnode == null) {
|
---|
5661 | if (container._vnode) {
|
---|
5662 | unmount(container._vnode, null, null, true);
|
---|
5663 | }
|
---|
5664 | } else {
|
---|
5665 | patch(
|
---|
5666 | container._vnode || null,
|
---|
5667 | vnode,
|
---|
5668 | container,
|
---|
5669 | null,
|
---|
5670 | null,
|
---|
5671 | null,
|
---|
5672 | namespace
|
---|
5673 | );
|
---|
5674 | }
|
---|
5675 | container._vnode = vnode;
|
---|
5676 | if (!isFlushing) {
|
---|
5677 | isFlushing = true;
|
---|
5678 | flushPreFlushCbs();
|
---|
5679 | flushPostFlushCbs();
|
---|
5680 | isFlushing = false;
|
---|
5681 | }
|
---|
5682 | };
|
---|
5683 | const internals = {
|
---|
5684 | p: patch,
|
---|
5685 | um: unmount,
|
---|
5686 | m: move,
|
---|
5687 | r: remove,
|
---|
5688 | mt: mountComponent,
|
---|
5689 | mc: mountChildren,
|
---|
5690 | pc: patchChildren,
|
---|
5691 | pbc: patchBlockChildren,
|
---|
5692 | n: getNextHostNode,
|
---|
5693 | o: options
|
---|
5694 | };
|
---|
5695 | let hydrate;
|
---|
5696 | let hydrateNode;
|
---|
5697 | return {
|
---|
5698 | render,
|
---|
5699 | hydrate,
|
---|
5700 | createApp: createAppAPI(render, hydrate)
|
---|
5701 | };
|
---|
5702 | }
|
---|
5703 | function resolveChildrenNamespace({ type, props }, currentNamespace) {
|
---|
5704 | return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
|
---|
5705 | }
|
---|
5706 | function toggleRecurse({ effect, job }, allowed) {
|
---|
5707 | if (allowed) {
|
---|
5708 | effect.flags |= 32;
|
---|
5709 | job.flags |= 4;
|
---|
5710 | } else {
|
---|
5711 | effect.flags &= ~32;
|
---|
5712 | job.flags &= ~4;
|
---|
5713 | }
|
---|
5714 | }
|
---|
5715 | function needTransition(parentSuspense, transition) {
|
---|
5716 | return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
|
---|
5717 | }
|
---|
5718 | function traverseStaticChildren(n1, n2, shallow = false) {
|
---|
5719 | const ch1 = n1.children;
|
---|
5720 | const ch2 = n2.children;
|
---|
5721 | if (isArray(ch1) && isArray(ch2)) {
|
---|
5722 | for (let i = 0; i < ch1.length; i++) {
|
---|
5723 | const c1 = ch1[i];
|
---|
5724 | let c2 = ch2[i];
|
---|
5725 | if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
|
---|
5726 | if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
|
---|
5727 | c2 = ch2[i] = cloneIfMounted(ch2[i]);
|
---|
5728 | c2.el = c1.el;
|
---|
5729 | }
|
---|
5730 | if (!shallow && c2.patchFlag !== -2)
|
---|
5731 | traverseStaticChildren(c1, c2);
|
---|
5732 | }
|
---|
5733 | if (c2.type === Text) {
|
---|
5734 | c2.el = c1.el;
|
---|
5735 | }
|
---|
5736 | if (c2.type === Comment && !c2.el) {
|
---|
5737 | c2.el = c1.el;
|
---|
5738 | }
|
---|
5739 | }
|
---|
5740 | }
|
---|
5741 | }
|
---|
5742 | function getSequence(arr) {
|
---|
5743 | const p = arr.slice();
|
---|
5744 | const result = [0];
|
---|
5745 | let i, j, u, v, c;
|
---|
5746 | const len = arr.length;
|
---|
5747 | for (i = 0; i < len; i++) {
|
---|
5748 | const arrI = arr[i];
|
---|
5749 | if (arrI !== 0) {
|
---|
5750 | j = result[result.length - 1];
|
---|
5751 | if (arr[j] < arrI) {
|
---|
5752 | p[i] = j;
|
---|
5753 | result.push(i);
|
---|
5754 | continue;
|
---|
5755 | }
|
---|
5756 | u = 0;
|
---|
5757 | v = result.length - 1;
|
---|
5758 | while (u < v) {
|
---|
5759 | c = u + v >> 1;
|
---|
5760 | if (arr[result[c]] < arrI) {
|
---|
5761 | u = c + 1;
|
---|
5762 | } else {
|
---|
5763 | v = c;
|
---|
5764 | }
|
---|
5765 | }
|
---|
5766 | if (arrI < arr[result[u]]) {
|
---|
5767 | if (u > 0) {
|
---|
5768 | p[i] = result[u - 1];
|
---|
5769 | }
|
---|
5770 | result[u] = i;
|
---|
5771 | }
|
---|
5772 | }
|
---|
5773 | }
|
---|
5774 | u = result.length;
|
---|
5775 | v = result[u - 1];
|
---|
5776 | while (u-- > 0) {
|
---|
5777 | result[u] = v;
|
---|
5778 | v = p[v];
|
---|
5779 | }
|
---|
5780 | return result;
|
---|
5781 | }
|
---|
5782 | function locateNonHydratedAsyncRoot(instance) {
|
---|
5783 | const subComponent = instance.subTree.component;
|
---|
5784 | if (subComponent) {
|
---|
5785 | if (subComponent.asyncDep && !subComponent.asyncResolved) {
|
---|
5786 | return subComponent;
|
---|
5787 | } else {
|
---|
5788 | return locateNonHydratedAsyncRoot(subComponent);
|
---|
5789 | }
|
---|
5790 | }
|
---|
5791 | }
|
---|
5792 | function invalidateMount(hooks) {
|
---|
5793 | if (hooks) {
|
---|
5794 | for (let i = 0; i < hooks.length; i++)
|
---|
5795 | hooks[i].flags |= 8;
|
---|
5796 | }
|
---|
5797 | }
|
---|
5798 |
|
---|
5799 | const ssrContextKey = Symbol.for("v-scx");
|
---|
5800 | const useSSRContext = () => {
|
---|
5801 | {
|
---|
5802 | const ctx = inject(ssrContextKey);
|
---|
5803 | if (!ctx) {
|
---|
5804 | warn$1(
|
---|
5805 | `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
|
---|
5806 | );
|
---|
5807 | }
|
---|
5808 | return ctx;
|
---|
5809 | }
|
---|
5810 | };
|
---|
5811 |
|
---|
5812 | function watch(source, cb, options) {
|
---|
5813 | if (!isFunction(cb)) {
|
---|
5814 | warn$1(
|
---|
5815 | `\`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.`
|
---|
5816 | );
|
---|
5817 | }
|
---|
5818 | return doWatch(source, cb, options);
|
---|
5819 | }
|
---|
5820 | function doWatch(source, cb, options = EMPTY_OBJ) {
|
---|
5821 | const { immediate, deep, flush, once } = options;
|
---|
5822 | if (!cb) {
|
---|
5823 | if (immediate !== void 0) {
|
---|
5824 | warn$1(
|
---|
5825 | `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
|
---|
5826 | );
|
---|
5827 | }
|
---|
5828 | if (deep !== void 0) {
|
---|
5829 | warn$1(
|
---|
5830 | `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
|
---|
5831 | );
|
---|
5832 | }
|
---|
5833 | if (once !== void 0) {
|
---|
5834 | warn$1(
|
---|
5835 | `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
|
---|
5836 | );
|
---|
5837 | }
|
---|
5838 | }
|
---|
5839 | const baseWatchOptions = extend({}, options);
|
---|
5840 | baseWatchOptions.onWarn = warn$1;
|
---|
5841 | const runsImmediately = cb && immediate || !cb && flush !== "post";
|
---|
5842 | let ssrCleanup;
|
---|
5843 | if (isInSSRComponentSetup) {
|
---|
5844 | if (flush === "sync") {
|
---|
5845 | const ctx = useSSRContext();
|
---|
5846 | ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
|
---|
5847 | } else if (!runsImmediately) {
|
---|
5848 | const watchStopHandle = () => {
|
---|
5849 | };
|
---|
5850 | watchStopHandle.stop = NOOP;
|
---|
5851 | watchStopHandle.resume = NOOP;
|
---|
5852 | watchStopHandle.pause = NOOP;
|
---|
5853 | return watchStopHandle;
|
---|
5854 | }
|
---|
5855 | }
|
---|
5856 | const instance = currentInstance;
|
---|
5857 | baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
|
---|
5858 | let isPre = false;
|
---|
5859 | if (flush === "post") {
|
---|
5860 | baseWatchOptions.scheduler = (job) => {
|
---|
5861 | queuePostRenderEffect(job, instance && instance.suspense);
|
---|
5862 | };
|
---|
5863 | } else if (flush !== "sync") {
|
---|
5864 | isPre = true;
|
---|
5865 | baseWatchOptions.scheduler = (job, isFirstRun) => {
|
---|
5866 | if (isFirstRun) {
|
---|
5867 | job();
|
---|
5868 | } else {
|
---|
5869 | queueJob(job);
|
---|
5870 | }
|
---|
5871 | };
|
---|
5872 | }
|
---|
5873 | baseWatchOptions.augmentJob = (job) => {
|
---|
5874 | if (cb) {
|
---|
5875 | job.flags |= 4;
|
---|
5876 | }
|
---|
5877 | if (isPre) {
|
---|
5878 | job.flags |= 2;
|
---|
5879 | if (instance) {
|
---|
5880 | job.id = instance.uid;
|
---|
5881 | job.i = instance;
|
---|
5882 | }
|
---|
5883 | }
|
---|
5884 | };
|
---|
5885 | const watchHandle = watch$1(source, cb, baseWatchOptions);
|
---|
5886 | if (isInSSRComponentSetup) {
|
---|
5887 | if (ssrCleanup) {
|
---|
5888 | ssrCleanup.push(watchHandle);
|
---|
5889 | } else if (runsImmediately) {
|
---|
5890 | watchHandle();
|
---|
5891 | }
|
---|
5892 | }
|
---|
5893 | return watchHandle;
|
---|
5894 | }
|
---|
5895 | function instanceWatch(source, value, options) {
|
---|
5896 | const publicThis = this.proxy;
|
---|
5897 | const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
|
---|
5898 | let cb;
|
---|
5899 | if (isFunction(value)) {
|
---|
5900 | cb = value;
|
---|
5901 | } else {
|
---|
5902 | cb = value.handler;
|
---|
5903 | options = value;
|
---|
5904 | }
|
---|
5905 | const reset = setCurrentInstance(this);
|
---|
5906 | const res = doWatch(getter, cb.bind(publicThis), options);
|
---|
5907 | reset();
|
---|
5908 | return res;
|
---|
5909 | }
|
---|
5910 | function createPathGetter(ctx, path) {
|
---|
5911 | const segments = path.split(".");
|
---|
5912 | return () => {
|
---|
5913 | let cur = ctx;
|
---|
5914 | for (let i = 0; i < segments.length && cur; i++) {
|
---|
5915 | cur = cur[segments[i]];
|
---|
5916 | }
|
---|
5917 | return cur;
|
---|
5918 | };
|
---|
5919 | }
|
---|
5920 |
|
---|
5921 | const getModelModifiers = (props, modelName) => {
|
---|
5922 | return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${camelize(modelName)}Modifiers`] || props[`${hyphenate(modelName)}Modifiers`];
|
---|
5923 | };
|
---|
5924 |
|
---|
5925 | function emit(instance, event, ...rawArgs) {
|
---|
5926 | if (instance.isUnmounted) return;
|
---|
5927 | const props = instance.vnode.props || EMPTY_OBJ;
|
---|
5928 | {
|
---|
5929 | const {
|
---|
5930 | emitsOptions,
|
---|
5931 | propsOptions: [propsOptions]
|
---|
5932 | } = instance;
|
---|
5933 | if (emitsOptions) {
|
---|
5934 | if (!(event in emitsOptions) && true) {
|
---|
5935 | if (!propsOptions || !(toHandlerKey(camelize(event)) in propsOptions)) {
|
---|
5936 | warn$1(
|
---|
5937 | `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(camelize(event))}" prop.`
|
---|
5938 | );
|
---|
5939 | }
|
---|
5940 | } else {
|
---|
5941 | const validator = emitsOptions[event];
|
---|
5942 | if (isFunction(validator)) {
|
---|
5943 | const isValid = validator(...rawArgs);
|
---|
5944 | if (!isValid) {
|
---|
5945 | warn$1(
|
---|
5946 | `Invalid event arguments: event validation failed for event "${event}".`
|
---|
5947 | );
|
---|
5948 | }
|
---|
5949 | }
|
---|
5950 | }
|
---|
5951 | }
|
---|
5952 | }
|
---|
5953 | let args = rawArgs;
|
---|
5954 | const isModelListener = event.startsWith("update:");
|
---|
5955 | const modifiers = isModelListener && getModelModifiers(props, event.slice(7));
|
---|
5956 | if (modifiers) {
|
---|
5957 | if (modifiers.trim) {
|
---|
5958 | args = rawArgs.map((a) => isString(a) ? a.trim() : a);
|
---|
5959 | }
|
---|
5960 | if (modifiers.number) {
|
---|
5961 | args = rawArgs.map(looseToNumber);
|
---|
5962 | }
|
---|
5963 | }
|
---|
5964 | {
|
---|
5965 | devtoolsComponentEmit(instance, event, args);
|
---|
5966 | }
|
---|
5967 | {
|
---|
5968 | const lowerCaseEvent = event.toLowerCase();
|
---|
5969 | if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
|
---|
5970 | warn$1(
|
---|
5971 | `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
|
---|
5972 | instance,
|
---|
5973 | instance.type
|
---|
5974 | )} 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(
|
---|
5975 | event
|
---|
5976 | )}" instead of "${event}".`
|
---|
5977 | );
|
---|
5978 | }
|
---|
5979 | }
|
---|
5980 | let handlerName;
|
---|
5981 | let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249)
|
---|
5982 | props[handlerName = toHandlerKey(camelize(event))];
|
---|
5983 | if (!handler && isModelListener) {
|
---|
5984 | handler = props[handlerName = toHandlerKey(hyphenate(event))];
|
---|
5985 | }
|
---|
5986 | if (handler) {
|
---|
5987 | callWithAsyncErrorHandling(
|
---|
5988 | handler,
|
---|
5989 | instance,
|
---|
5990 | 6,
|
---|
5991 | args
|
---|
5992 | );
|
---|
5993 | }
|
---|
5994 | const onceHandler = props[handlerName + `Once`];
|
---|
5995 | if (onceHandler) {
|
---|
5996 | if (!instance.emitted) {
|
---|
5997 | instance.emitted = {};
|
---|
5998 | } else if (instance.emitted[handlerName]) {
|
---|
5999 | return;
|
---|
6000 | }
|
---|
6001 | instance.emitted[handlerName] = true;
|
---|
6002 | callWithAsyncErrorHandling(
|
---|
6003 | onceHandler,
|
---|
6004 | instance,
|
---|
6005 | 6,
|
---|
6006 | args
|
---|
6007 | );
|
---|
6008 | }
|
---|
6009 | }
|
---|
6010 | function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
---|
6011 | const cache = appContext.emitsCache;
|
---|
6012 | const cached = cache.get(comp);
|
---|
6013 | if (cached !== void 0) {
|
---|
6014 | return cached;
|
---|
6015 | }
|
---|
6016 | const raw = comp.emits;
|
---|
6017 | let normalized = {};
|
---|
6018 | let hasExtends = false;
|
---|
6019 | if (!isFunction(comp)) {
|
---|
6020 | const extendEmits = (raw2) => {
|
---|
6021 | const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
|
---|
6022 | if (normalizedFromExtend) {
|
---|
6023 | hasExtends = true;
|
---|
6024 | extend(normalized, normalizedFromExtend);
|
---|
6025 | }
|
---|
6026 | };
|
---|
6027 | if (!asMixin && appContext.mixins.length) {
|
---|
6028 | appContext.mixins.forEach(extendEmits);
|
---|
6029 | }
|
---|
6030 | if (comp.extends) {
|
---|
6031 | extendEmits(comp.extends);
|
---|
6032 | }
|
---|
6033 | if (comp.mixins) {
|
---|
6034 | comp.mixins.forEach(extendEmits);
|
---|
6035 | }
|
---|
6036 | }
|
---|
6037 | if (!raw && !hasExtends) {
|
---|
6038 | if (isObject(comp)) {
|
---|
6039 | cache.set(comp, null);
|
---|
6040 | }
|
---|
6041 | return null;
|
---|
6042 | }
|
---|
6043 | if (isArray(raw)) {
|
---|
6044 | raw.forEach((key) => normalized[key] = null);
|
---|
6045 | } else {
|
---|
6046 | extend(normalized, raw);
|
---|
6047 | }
|
---|
6048 | if (isObject(comp)) {
|
---|
6049 | cache.set(comp, normalized);
|
---|
6050 | }
|
---|
6051 | return normalized;
|
---|
6052 | }
|
---|
6053 | function isEmitListener(options, key) {
|
---|
6054 | if (!options || !isOn(key)) {
|
---|
6055 | return false;
|
---|
6056 | }
|
---|
6057 | key = key.slice(2).replace(/Once$/, "");
|
---|
6058 | return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
|
---|
6059 | }
|
---|
6060 |
|
---|
6061 | let accessedAttrs = false;
|
---|
6062 | function markAttrsAccessed() {
|
---|
6063 | accessedAttrs = true;
|
---|
6064 | }
|
---|
6065 | function renderComponentRoot$1(instance) {
|
---|
6066 | const {
|
---|
6067 | type: Component,
|
---|
6068 | vnode,
|
---|
6069 | proxy,
|
---|
6070 | withProxy,
|
---|
6071 | propsOptions: [propsOptions],
|
---|
6072 | slots,
|
---|
6073 | attrs,
|
---|
6074 | emit,
|
---|
6075 | render,
|
---|
6076 | renderCache,
|
---|
6077 | props,
|
---|
6078 | data,
|
---|
6079 | setupState,
|
---|
6080 | ctx,
|
---|
6081 | inheritAttrs
|
---|
6082 | } = instance;
|
---|
6083 | const prev = setCurrentRenderingInstance$1(instance);
|
---|
6084 | let result;
|
---|
6085 | let fallthroughAttrs;
|
---|
6086 | {
|
---|
6087 | accessedAttrs = false;
|
---|
6088 | }
|
---|
6089 | try {
|
---|
6090 | if (vnode.shapeFlag & 4) {
|
---|
6091 | const proxyToUse = withProxy || proxy;
|
---|
6092 | const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
|
---|
6093 | get(target, key, receiver) {
|
---|
6094 | warn$1(
|
---|
6095 | `Property '${String(
|
---|
6096 | key
|
---|
6097 | )}' was accessed via 'this'. Avoid using 'this' in templates.`
|
---|
6098 | );
|
---|
6099 | return Reflect.get(target, key, receiver);
|
---|
6100 | }
|
---|
6101 | }) : proxyToUse;
|
---|
6102 | result = normalizeVNode$1(
|
---|
6103 | render.call(
|
---|
6104 | thisProxy,
|
---|
6105 | proxyToUse,
|
---|
6106 | renderCache,
|
---|
6107 | true ? shallowReadonly(props) : props,
|
---|
6108 | setupState,
|
---|
6109 | data,
|
---|
6110 | ctx
|
---|
6111 | )
|
---|
6112 | );
|
---|
6113 | fallthroughAttrs = attrs;
|
---|
6114 | } else {
|
---|
6115 | const render2 = Component;
|
---|
6116 | if (attrs === props) {
|
---|
6117 | markAttrsAccessed();
|
---|
6118 | }
|
---|
6119 | result = normalizeVNode$1(
|
---|
6120 | render2.length > 1 ? render2(
|
---|
6121 | true ? shallowReadonly(props) : props,
|
---|
6122 | true ? {
|
---|
6123 | get attrs() {
|
---|
6124 | markAttrsAccessed();
|
---|
6125 | return shallowReadonly(attrs);
|
---|
6126 | },
|
---|
6127 | slots,
|
---|
6128 | emit
|
---|
6129 | } : { attrs, slots, emit }
|
---|
6130 | ) : render2(
|
---|
6131 | true ? shallowReadonly(props) : props,
|
---|
6132 | null
|
---|
6133 | )
|
---|
6134 | );
|
---|
6135 | fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
|
---|
6136 | }
|
---|
6137 | } catch (err) {
|
---|
6138 | handleError(err, instance, 1);
|
---|
6139 | result = createVNode(Comment);
|
---|
6140 | }
|
---|
6141 | let root = result;
|
---|
6142 | let setRoot = void 0;
|
---|
6143 | if (result.patchFlag > 0 && result.patchFlag & 2048) {
|
---|
6144 | [root, setRoot] = getChildRoot(result);
|
---|
6145 | }
|
---|
6146 | if (fallthroughAttrs && inheritAttrs !== false) {
|
---|
6147 | const keys = Object.keys(fallthroughAttrs);
|
---|
6148 | const { shapeFlag } = root;
|
---|
6149 | if (keys.length) {
|
---|
6150 | if (shapeFlag & (1 | 6)) {
|
---|
6151 | if (propsOptions && keys.some(isModelListener)) {
|
---|
6152 | fallthroughAttrs = filterModelListeners(
|
---|
6153 | fallthroughAttrs,
|
---|
6154 | propsOptions
|
---|
6155 | );
|
---|
6156 | }
|
---|
6157 | root = cloneVNode(root, fallthroughAttrs, false, true);
|
---|
6158 | } else if (!accessedAttrs && root.type !== Comment) {
|
---|
6159 | const allAttrs = Object.keys(attrs);
|
---|
6160 | const eventAttrs = [];
|
---|
6161 | const extraAttrs = [];
|
---|
6162 | for (let i = 0, l = allAttrs.length; i < l; i++) {
|
---|
6163 | const key = allAttrs[i];
|
---|
6164 | if (isOn(key)) {
|
---|
6165 | if (!isModelListener(key)) {
|
---|
6166 | eventAttrs.push(key[2].toLowerCase() + key.slice(3));
|
---|
6167 | }
|
---|
6168 | } else {
|
---|
6169 | extraAttrs.push(key);
|
---|
6170 | }
|
---|
6171 | }
|
---|
6172 | if (extraAttrs.length) {
|
---|
6173 | warn$1(
|
---|
6174 | `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text or teleport root nodes.`
|
---|
6175 | );
|
---|
6176 | }
|
---|
6177 | if (eventAttrs.length) {
|
---|
6178 | warn$1(
|
---|
6179 | `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.`
|
---|
6180 | );
|
---|
6181 | }
|
---|
6182 | }
|
---|
6183 | }
|
---|
6184 | }
|
---|
6185 | if (vnode.dirs) {
|
---|
6186 | if (!isElementRoot(root)) {
|
---|
6187 | warn$1(
|
---|
6188 | `Runtime directive used on component with non-element root node. The directives will not function as intended.`
|
---|
6189 | );
|
---|
6190 | }
|
---|
6191 | root = cloneVNode(root, null, false, true);
|
---|
6192 | root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
|
---|
6193 | }
|
---|
6194 | if (vnode.transition) {
|
---|
6195 | if (!isElementRoot(root)) {
|
---|
6196 | warn$1(
|
---|
6197 | `Component inside <Transition> renders non-element root node that cannot be animated.`
|
---|
6198 | );
|
---|
6199 | }
|
---|
6200 | setTransitionHooks(root, vnode.transition);
|
---|
6201 | }
|
---|
6202 | if (setRoot) {
|
---|
6203 | setRoot(root);
|
---|
6204 | } else {
|
---|
6205 | result = root;
|
---|
6206 | }
|
---|
6207 | setCurrentRenderingInstance$1(prev);
|
---|
6208 | return result;
|
---|
6209 | }
|
---|
6210 | const getChildRoot = (vnode) => {
|
---|
6211 | const rawChildren = vnode.children;
|
---|
6212 | const dynamicChildren = vnode.dynamicChildren;
|
---|
6213 | const childRoot = filterSingleRoot(rawChildren, false);
|
---|
6214 | if (!childRoot) {
|
---|
6215 | return [vnode, void 0];
|
---|
6216 | } else if (childRoot.patchFlag > 0 && childRoot.patchFlag & 2048) {
|
---|
6217 | return getChildRoot(childRoot);
|
---|
6218 | }
|
---|
6219 | const index = rawChildren.indexOf(childRoot);
|
---|
6220 | const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
|
---|
6221 | const setRoot = (updatedRoot) => {
|
---|
6222 | rawChildren[index] = updatedRoot;
|
---|
6223 | if (dynamicChildren) {
|
---|
6224 | if (dynamicIndex > -1) {
|
---|
6225 | dynamicChildren[dynamicIndex] = updatedRoot;
|
---|
6226 | } else if (updatedRoot.patchFlag > 0) {
|
---|
6227 | vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
|
---|
6228 | }
|
---|
6229 | }
|
---|
6230 | };
|
---|
6231 | return [normalizeVNode$1(childRoot), setRoot];
|
---|
6232 | };
|
---|
6233 | function filterSingleRoot(children, recurse = true) {
|
---|
6234 | let singleRoot;
|
---|
6235 | for (let i = 0; i < children.length; i++) {
|
---|
6236 | const child = children[i];
|
---|
6237 | if (isVNode$2(child)) {
|
---|
6238 | if (child.type !== Comment || child.children === "v-if") {
|
---|
6239 | if (singleRoot) {
|
---|
6240 | return;
|
---|
6241 | } else {
|
---|
6242 | singleRoot = child;
|
---|
6243 | if (recurse && singleRoot.patchFlag > 0 && singleRoot.patchFlag & 2048) {
|
---|
6244 | return filterSingleRoot(singleRoot.children);
|
---|
6245 | }
|
---|
6246 | }
|
---|
6247 | }
|
---|
6248 | } else {
|
---|
6249 | return;
|
---|
6250 | }
|
---|
6251 | }
|
---|
6252 | return singleRoot;
|
---|
6253 | }
|
---|
6254 | const getFunctionalFallthrough = (attrs) => {
|
---|
6255 | let res;
|
---|
6256 | for (const key in attrs) {
|
---|
6257 | if (key === "class" || key === "style" || isOn(key)) {
|
---|
6258 | (res || (res = {}))[key] = attrs[key];
|
---|
6259 | }
|
---|
6260 | }
|
---|
6261 | return res;
|
---|
6262 | };
|
---|
6263 | const filterModelListeners = (attrs, props) => {
|
---|
6264 | const res = {};
|
---|
6265 | for (const key in attrs) {
|
---|
6266 | if (!isModelListener(key) || !(key.slice(9) in props)) {
|
---|
6267 | res[key] = attrs[key];
|
---|
6268 | }
|
---|
6269 | }
|
---|
6270 | return res;
|
---|
6271 | };
|
---|
6272 | const isElementRoot = (vnode) => {
|
---|
6273 | return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
|
---|
6274 | };
|
---|
6275 | function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
|
---|
6276 | const { props: prevProps, children: prevChildren, component } = prevVNode;
|
---|
6277 | const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
|
---|
6278 | const emits = component.emitsOptions;
|
---|
6279 | if ((prevChildren || nextChildren) && isHmrUpdating) {
|
---|
6280 | return true;
|
---|
6281 | }
|
---|
6282 | if (nextVNode.dirs || nextVNode.transition) {
|
---|
6283 | return true;
|
---|
6284 | }
|
---|
6285 | if (optimized && patchFlag >= 0) {
|
---|
6286 | if (patchFlag & 1024) {
|
---|
6287 | return true;
|
---|
6288 | }
|
---|
6289 | if (patchFlag & 16) {
|
---|
6290 | if (!prevProps) {
|
---|
6291 | return !!nextProps;
|
---|
6292 | }
|
---|
6293 | return hasPropsChanged(prevProps, nextProps, emits);
|
---|
6294 | } else if (patchFlag & 8) {
|
---|
6295 | const dynamicProps = nextVNode.dynamicProps;
|
---|
6296 | for (let i = 0; i < dynamicProps.length; i++) {
|
---|
6297 | const key = dynamicProps[i];
|
---|
6298 | if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
|
---|
6299 | return true;
|
---|
6300 | }
|
---|
6301 | }
|
---|
6302 | }
|
---|
6303 | } else {
|
---|
6304 | if (prevChildren || nextChildren) {
|
---|
6305 | if (!nextChildren || !nextChildren.$stable) {
|
---|
6306 | return true;
|
---|
6307 | }
|
---|
6308 | }
|
---|
6309 | if (prevProps === nextProps) {
|
---|
6310 | return false;
|
---|
6311 | }
|
---|
6312 | if (!prevProps) {
|
---|
6313 | return !!nextProps;
|
---|
6314 | }
|
---|
6315 | if (!nextProps) {
|
---|
6316 | return true;
|
---|
6317 | }
|
---|
6318 | return hasPropsChanged(prevProps, nextProps, emits);
|
---|
6319 | }
|
---|
6320 | return false;
|
---|
6321 | }
|
---|
6322 | function hasPropsChanged(prevProps, nextProps, emitsOptions) {
|
---|
6323 | const nextKeys = Object.keys(nextProps);
|
---|
6324 | if (nextKeys.length !== Object.keys(prevProps).length) {
|
---|
6325 | return true;
|
---|
6326 | }
|
---|
6327 | for (let i = 0; i < nextKeys.length; i++) {
|
---|
6328 | const key = nextKeys[i];
|
---|
6329 | if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
|
---|
6330 | return true;
|
---|
6331 | }
|
---|
6332 | }
|
---|
6333 | return false;
|
---|
6334 | }
|
---|
6335 | function updateHOCHostEl({ vnode, parent }, el) {
|
---|
6336 | while (parent) {
|
---|
6337 | const root = parent.subTree;
|
---|
6338 | if (root.suspense && root.suspense.activeBranch === vnode) {
|
---|
6339 | root.el = vnode.el;
|
---|
6340 | }
|
---|
6341 | if (root === vnode) {
|
---|
6342 | (vnode = parent.vnode).el = el;
|
---|
6343 | parent = parent.parent;
|
---|
6344 | } else {
|
---|
6345 | break;
|
---|
6346 | }
|
---|
6347 | }
|
---|
6348 | }
|
---|
6349 |
|
---|
6350 | const isSuspense = (type) => type.__isSuspense;
|
---|
6351 | function queueEffectWithSuspense(fn, suspense) {
|
---|
6352 | if (suspense && suspense.pendingBranch) {
|
---|
6353 | if (isArray(fn)) {
|
---|
6354 | suspense.effects.push(...fn);
|
---|
6355 | } else {
|
---|
6356 | suspense.effects.push(fn);
|
---|
6357 | }
|
---|
6358 | } else {
|
---|
6359 | queuePostFlushCb(fn);
|
---|
6360 | }
|
---|
6361 | }
|
---|
6362 |
|
---|
6363 | const Fragment = Symbol.for("v-fgt");
|
---|
6364 | const Text = Symbol.for("v-txt");
|
---|
6365 | const Comment = Symbol.for("v-cmt");
|
---|
6366 | const Static = Symbol.for("v-stc");
|
---|
6367 | let currentBlock = null;
|
---|
6368 | let isBlockTreeEnabled = 1;
|
---|
6369 | function setBlockTracking(value, inVOnce = false) {
|
---|
6370 | isBlockTreeEnabled += value;
|
---|
6371 | if (value < 0 && currentBlock && inVOnce) {
|
---|
6372 | currentBlock.hasOnce = true;
|
---|
6373 | }
|
---|
6374 | }
|
---|
6375 | function isVNode$2(value) {
|
---|
6376 | return value ? value.__v_isVNode === true : false;
|
---|
6377 | }
|
---|
6378 | function isSameVNodeType(n1, n2) {
|
---|
6379 | if (n2.shapeFlag & 6 && n1.component) {
|
---|
6380 | const dirtyInstances = hmrDirtyComponents.get(n2.type);
|
---|
6381 | if (dirtyInstances && dirtyInstances.has(n1.component)) {
|
---|
6382 | n1.shapeFlag &= ~256;
|
---|
6383 | n2.shapeFlag &= ~512;
|
---|
6384 | return false;
|
---|
6385 | }
|
---|
6386 | }
|
---|
6387 | return n1.type === n2.type && n1.key === n2.key;
|
---|
6388 | }
|
---|
6389 | const createVNodeWithArgsTransform = (...args) => {
|
---|
6390 | return _createVNode(
|
---|
6391 | ...args
|
---|
6392 | );
|
---|
6393 | };
|
---|
6394 | const normalizeKey = ({ key }) => key != null ? key : null;
|
---|
6395 | const normalizeRef = ({
|
---|
6396 | ref,
|
---|
6397 | ref_key,
|
---|
6398 | ref_for
|
---|
6399 | }) => {
|
---|
6400 | if (typeof ref === "number") {
|
---|
6401 | ref = "" + ref;
|
---|
6402 | }
|
---|
6403 | return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null;
|
---|
6404 | };
|
---|
6405 | function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
|
---|
6406 | const vnode = {
|
---|
6407 | __v_isVNode: true,
|
---|
6408 | __v_skip: true,
|
---|
6409 | type,
|
---|
6410 | props,
|
---|
6411 | key: props && normalizeKey(props),
|
---|
6412 | ref: props && normalizeRef(props),
|
---|
6413 | scopeId: currentScopeId,
|
---|
6414 | slotScopeIds: null,
|
---|
6415 | children,
|
---|
6416 | component: null,
|
---|
6417 | suspense: null,
|
---|
6418 | ssContent: null,
|
---|
6419 | ssFallback: null,
|
---|
6420 | dirs: null,
|
---|
6421 | transition: null,
|
---|
6422 | el: null,
|
---|
6423 | anchor: null,
|
---|
6424 | target: null,
|
---|
6425 | targetStart: null,
|
---|
6426 | targetAnchor: null,
|
---|
6427 | staticCount: 0,
|
---|
6428 | shapeFlag,
|
---|
6429 | patchFlag,
|
---|
6430 | dynamicProps,
|
---|
6431 | dynamicChildren: null,
|
---|
6432 | appContext: null,
|
---|
6433 | ctx: currentRenderingInstance
|
---|
6434 | };
|
---|
6435 | if (needFullChildrenNormalization) {
|
---|
6436 | normalizeChildren(vnode, children);
|
---|
6437 | if (shapeFlag & 128) {
|
---|
6438 | type.normalize(vnode);
|
---|
6439 | }
|
---|
6440 | } else if (children) {
|
---|
6441 | vnode.shapeFlag |= isString(children) ? 8 : 16;
|
---|
6442 | }
|
---|
6443 | if (vnode.key !== vnode.key) {
|
---|
6444 | warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
---|
6445 | }
|
---|
6446 | if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
|
---|
6447 | !isBlockNode && // has current parent block
|
---|
6448 | currentBlock && // presence of a patch flag indicates this node needs patching on updates.
|
---|
6449 | // component nodes also should always be patched, because even if the
|
---|
6450 | // component doesn't need to update, it needs to persist the instance on to
|
---|
6451 | // the next vnode so that it can be properly unmounted later.
|
---|
6452 | (vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
|
---|
6453 | // vnode should not be considered dynamic due to handler caching.
|
---|
6454 | vnode.patchFlag !== 32) {
|
---|
6455 | currentBlock.push(vnode);
|
---|
6456 | }
|
---|
6457 | return vnode;
|
---|
6458 | }
|
---|
6459 | const createVNode = createVNodeWithArgsTransform ;
|
---|
6460 | function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
---|
6461 | if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
---|
6462 | if (!type) {
|
---|
6463 | warn$1(`Invalid vnode type when creating vnode: ${type}.`);
|
---|
6464 | }
|
---|
6465 | type = Comment;
|
---|
6466 | }
|
---|
6467 | if (isVNode$2(type)) {
|
---|
6468 | const cloned = cloneVNode(
|
---|
6469 | type,
|
---|
6470 | props,
|
---|
6471 | true
|
---|
6472 | /* mergeRef: true */
|
---|
6473 | );
|
---|
6474 | if (children) {
|
---|
6475 | normalizeChildren(cloned, children);
|
---|
6476 | }
|
---|
6477 | if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
|
---|
6478 | if (cloned.shapeFlag & 6) {
|
---|
6479 | currentBlock[currentBlock.indexOf(type)] = cloned;
|
---|
6480 | } else {
|
---|
6481 | currentBlock.push(cloned);
|
---|
6482 | }
|
---|
6483 | }
|
---|
6484 | cloned.patchFlag = -2;
|
---|
6485 | return cloned;
|
---|
6486 | }
|
---|
6487 | if (isClassComponent(type)) {
|
---|
6488 | type = type.__vccOpts;
|
---|
6489 | }
|
---|
6490 | if (props) {
|
---|
6491 | props = guardReactiveProps(props);
|
---|
6492 | let { class: klass, style } = props;
|
---|
6493 | if (klass && !isString(klass)) {
|
---|
6494 | props.class = normalizeClass(klass);
|
---|
6495 | }
|
---|
6496 | if (isObject(style)) {
|
---|
6497 | if (isProxy(style) && !isArray(style)) {
|
---|
6498 | style = extend({}, style);
|
---|
6499 | }
|
---|
6500 | props.style = normalizeStyle(style);
|
---|
6501 | }
|
---|
6502 | }
|
---|
6503 | const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
|
---|
6504 | if (shapeFlag & 4 && isProxy(type)) {
|
---|
6505 | type = toRaw(type);
|
---|
6506 | warn$1(
|
---|
6507 | `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\`.`,
|
---|
6508 | `
|
---|
6509 | Component that was made reactive: `,
|
---|
6510 | type
|
---|
6511 | );
|
---|
6512 | }
|
---|
6513 | return createBaseVNode(
|
---|
6514 | type,
|
---|
6515 | props,
|
---|
6516 | children,
|
---|
6517 | patchFlag,
|
---|
6518 | dynamicProps,
|
---|
6519 | shapeFlag,
|
---|
6520 | isBlockNode,
|
---|
6521 | true
|
---|
6522 | );
|
---|
6523 | }
|
---|
6524 | function guardReactiveProps(props) {
|
---|
6525 | if (!props) return null;
|
---|
6526 | return isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
|
---|
6527 | }
|
---|
6528 | function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
|
---|
6529 | const { props, ref, patchFlag, children, transition } = vnode;
|
---|
6530 | const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
|
---|
6531 | const cloned = {
|
---|
6532 | __v_isVNode: true,
|
---|
6533 | __v_skip: true,
|
---|
6534 | type: vnode.type,
|
---|
6535 | props: mergedProps,
|
---|
6536 | key: mergedProps && normalizeKey(mergedProps),
|
---|
6537 | ref: extraProps && extraProps.ref ? (
|
---|
6538 | // #2078 in the case of <component :is="vnode" ref="extra"/>
|
---|
6539 | // if the vnode itself already has a ref, cloneVNode will need to merge
|
---|
6540 | // the refs so the single vnode can be set on multiple refs
|
---|
6541 | mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
|
---|
6542 | ) : ref,
|
---|
6543 | scopeId: vnode.scopeId,
|
---|
6544 | slotScopeIds: vnode.slotScopeIds,
|
---|
6545 | children: patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
|
---|
6546 | target: vnode.target,
|
---|
6547 | targetStart: vnode.targetStart,
|
---|
6548 | targetAnchor: vnode.targetAnchor,
|
---|
6549 | staticCount: vnode.staticCount,
|
---|
6550 | shapeFlag: vnode.shapeFlag,
|
---|
6551 | // if the vnode is cloned with extra props, we can no longer assume its
|
---|
6552 | // existing patch flag to be reliable and need to add the FULL_PROPS flag.
|
---|
6553 | // note: preserve flag for fragments since they use the flag for children
|
---|
6554 | // fast paths only.
|
---|
6555 | patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
|
---|
6556 | dynamicProps: vnode.dynamicProps,
|
---|
6557 | dynamicChildren: vnode.dynamicChildren,
|
---|
6558 | appContext: vnode.appContext,
|
---|
6559 | dirs: vnode.dirs,
|
---|
6560 | transition,
|
---|
6561 | // These should technically only be non-null on mounted VNodes. However,
|
---|
6562 | // they *should* be copied for kept-alive vnodes. So we just always copy
|
---|
6563 | // them since them being non-null during a mount doesn't affect the logic as
|
---|
6564 | // they will simply be overwritten.
|
---|
6565 | component: vnode.component,
|
---|
6566 | suspense: vnode.suspense,
|
---|
6567 | ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
---|
6568 | ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
---|
6569 | el: vnode.el,
|
---|
6570 | anchor: vnode.anchor,
|
---|
6571 | ctx: vnode.ctx,
|
---|
6572 | ce: vnode.ce
|
---|
6573 | };
|
---|
6574 | if (transition && cloneTransition) {
|
---|
6575 | setTransitionHooks(
|
---|
6576 | cloned,
|
---|
6577 | transition.clone(cloned)
|
---|
6578 | );
|
---|
6579 | }
|
---|
6580 | return cloned;
|
---|
6581 | }
|
---|
6582 | function deepCloneVNode(vnode) {
|
---|
6583 | const cloned = cloneVNode(vnode);
|
---|
6584 | if (isArray(vnode.children)) {
|
---|
6585 | cloned.children = vnode.children.map(deepCloneVNode);
|
---|
6586 | }
|
---|
6587 | return cloned;
|
---|
6588 | }
|
---|
6589 | function createTextVNode(text = " ", flag = 0) {
|
---|
6590 | return createVNode(Text, null, text, flag);
|
---|
6591 | }
|
---|
6592 | function normalizeVNode$1(child) {
|
---|
6593 | if (child == null || typeof child === "boolean") {
|
---|
6594 | return createVNode(Comment);
|
---|
6595 | } else if (isArray(child)) {
|
---|
6596 | return createVNode(
|
---|
6597 | Fragment,
|
---|
6598 | null,
|
---|
6599 | // #3666, avoid reference pollution when reusing vnode
|
---|
6600 | child.slice()
|
---|
6601 | );
|
---|
6602 | } else if (isVNode$2(child)) {
|
---|
6603 | return cloneIfMounted(child);
|
---|
6604 | } else {
|
---|
6605 | return createVNode(Text, null, String(child));
|
---|
6606 | }
|
---|
6607 | }
|
---|
6608 | function cloneIfMounted(child) {
|
---|
6609 | return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
|
---|
6610 | }
|
---|
6611 | function normalizeChildren(vnode, children) {
|
---|
6612 | let type = 0;
|
---|
6613 | const { shapeFlag } = vnode;
|
---|
6614 | if (children == null) {
|
---|
6615 | children = null;
|
---|
6616 | } else if (isArray(children)) {
|
---|
6617 | type = 16;
|
---|
6618 | } else if (typeof children === "object") {
|
---|
6619 | if (shapeFlag & (1 | 64)) {
|
---|
6620 | const slot = children.default;
|
---|
6621 | if (slot) {
|
---|
6622 | slot._c && (slot._d = false);
|
---|
6623 | normalizeChildren(vnode, slot());
|
---|
6624 | slot._c && (slot._d = true);
|
---|
6625 | }
|
---|
6626 | return;
|
---|
6627 | } else {
|
---|
6628 | type = 32;
|
---|
6629 | const slotFlag = children._;
|
---|
6630 | if (!slotFlag && !isInternalObject(children)) {
|
---|
6631 | children._ctx = currentRenderingInstance;
|
---|
6632 | } else if (slotFlag === 3 && currentRenderingInstance) {
|
---|
6633 | if (currentRenderingInstance.slots._ === 1) {
|
---|
6634 | children._ = 1;
|
---|
6635 | } else {
|
---|
6636 | children._ = 2;
|
---|
6637 | vnode.patchFlag |= 1024;
|
---|
6638 | }
|
---|
6639 | }
|
---|
6640 | }
|
---|
6641 | } else if (isFunction(children)) {
|
---|
6642 | children = { default: children, _ctx: currentRenderingInstance };
|
---|
6643 | type = 32;
|
---|
6644 | } else {
|
---|
6645 | children = String(children);
|
---|
6646 | if (shapeFlag & 64) {
|
---|
6647 | type = 16;
|
---|
6648 | children = [createTextVNode(children)];
|
---|
6649 | } else {
|
---|
6650 | type = 8;
|
---|
6651 | }
|
---|
6652 | }
|
---|
6653 | vnode.children = children;
|
---|
6654 | vnode.shapeFlag |= type;
|
---|
6655 | }
|
---|
6656 | function mergeProps(...args) {
|
---|
6657 | const ret = {};
|
---|
6658 | for (let i = 0; i < args.length; i++) {
|
---|
6659 | const toMerge = args[i];
|
---|
6660 | for (const key in toMerge) {
|
---|
6661 | if (key === "class") {
|
---|
6662 | if (ret.class !== toMerge.class) {
|
---|
6663 | ret.class = normalizeClass([ret.class, toMerge.class]);
|
---|
6664 | }
|
---|
6665 | } else if (key === "style") {
|
---|
6666 | ret.style = normalizeStyle([ret.style, toMerge.style]);
|
---|
6667 | } else if (isOn(key)) {
|
---|
6668 | const existing = ret[key];
|
---|
6669 | const incoming = toMerge[key];
|
---|
6670 | if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
|
---|
6671 | ret[key] = existing ? [].concat(existing, incoming) : incoming;
|
---|
6672 | }
|
---|
6673 | } else if (key !== "") {
|
---|
6674 | ret[key] = toMerge[key];
|
---|
6675 | }
|
---|
6676 | }
|
---|
6677 | }
|
---|
6678 | return ret;
|
---|
6679 | }
|
---|
6680 | function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
---|
6681 | callWithAsyncErrorHandling(hook, instance, 7, [
|
---|
6682 | vnode,
|
---|
6683 | prevVNode
|
---|
6684 | ]);
|
---|
6685 | }
|
---|
6686 |
|
---|
6687 | const emptyAppContext = createAppContext();
|
---|
6688 | let uid = 0;
|
---|
6689 | function createComponentInstance$1(vnode, parent, suspense) {
|
---|
6690 | const type = vnode.type;
|
---|
6691 | const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
---|
6692 | const instance = {
|
---|
6693 | uid: uid++,
|
---|
6694 | vnode,
|
---|
6695 | type,
|
---|
6696 | parent,
|
---|
6697 | appContext,
|
---|
6698 | root: null,
|
---|
6699 | // to be immediately set
|
---|
6700 | next: null,
|
---|
6701 | subTree: null,
|
---|
6702 | // will be set synchronously right after creation
|
---|
6703 | effect: null,
|
---|
6704 | update: null,
|
---|
6705 | // will be set synchronously right after creation
|
---|
6706 | job: null,
|
---|
6707 | scope: new EffectScope(
|
---|
6708 | true
|
---|
6709 | /* detached */
|
---|
6710 | ),
|
---|
6711 | render: null,
|
---|
6712 | proxy: null,
|
---|
6713 | exposed: null,
|
---|
6714 | exposeProxy: null,
|
---|
6715 | withProxy: null,
|
---|
6716 | provides: parent ? parent.provides : Object.create(appContext.provides),
|
---|
6717 | ids: parent ? parent.ids : ["", 0, 0],
|
---|
6718 | accessCache: null,
|
---|
6719 | renderCache: [],
|
---|
6720 | // local resolved assets
|
---|
6721 | components: null,
|
---|
6722 | directives: null,
|
---|
6723 | // resolved props and emits options
|
---|
6724 | propsOptions: normalizePropsOptions(type, appContext),
|
---|
6725 | emitsOptions: normalizeEmitsOptions(type, appContext),
|
---|
6726 | // emit
|
---|
6727 | emit: null,
|
---|
6728 | // to be set immediately
|
---|
6729 | emitted: null,
|
---|
6730 | // props default value
|
---|
6731 | propsDefaults: EMPTY_OBJ,
|
---|
6732 | // inheritAttrs
|
---|
6733 | inheritAttrs: type.inheritAttrs,
|
---|
6734 | // state
|
---|
6735 | ctx: EMPTY_OBJ,
|
---|
6736 | data: EMPTY_OBJ,
|
---|
6737 | props: EMPTY_OBJ,
|
---|
6738 | attrs: EMPTY_OBJ,
|
---|
6739 | slots: EMPTY_OBJ,
|
---|
6740 | refs: EMPTY_OBJ,
|
---|
6741 | setupState: EMPTY_OBJ,
|
---|
6742 | setupContext: null,
|
---|
6743 | // suspense related
|
---|
6744 | suspense,
|
---|
6745 | suspenseId: suspense ? suspense.pendingId : 0,
|
---|
6746 | asyncDep: null,
|
---|
6747 | asyncResolved: false,
|
---|
6748 | // lifecycle hooks
|
---|
6749 | // not using enums here because it results in computed properties
|
---|
6750 | isMounted: false,
|
---|
6751 | isUnmounted: false,
|
---|
6752 | isDeactivated: false,
|
---|
6753 | bc: null,
|
---|
6754 | c: null,
|
---|
6755 | bm: null,
|
---|
6756 | m: null,
|
---|
6757 | bu: null,
|
---|
6758 | u: null,
|
---|
6759 | um: null,
|
---|
6760 | bum: null,
|
---|
6761 | da: null,
|
---|
6762 | a: null,
|
---|
6763 | rtg: null,
|
---|
6764 | rtc: null,
|
---|
6765 | ec: null,
|
---|
6766 | sp: null
|
---|
6767 | };
|
---|
6768 | {
|
---|
6769 | instance.ctx = createDevRenderContext(instance);
|
---|
6770 | }
|
---|
6771 | instance.root = parent ? parent.root : instance;
|
---|
6772 | instance.emit = emit.bind(null, instance);
|
---|
6773 | if (vnode.ce) {
|
---|
6774 | vnode.ce(instance);
|
---|
6775 | }
|
---|
6776 | return instance;
|
---|
6777 | }
|
---|
6778 | let currentInstance = null;
|
---|
6779 | const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
---|
6780 | let internalSetCurrentInstance;
|
---|
6781 | let setInSSRSetupState;
|
---|
6782 | {
|
---|
6783 | const g = getGlobalThis();
|
---|
6784 | const registerGlobalSetter = (key, setter) => {
|
---|
6785 | let setters;
|
---|
6786 | if (!(setters = g[key])) setters = g[key] = [];
|
---|
6787 | setters.push(setter);
|
---|
6788 | return (v) => {
|
---|
6789 | if (setters.length > 1) setters.forEach((set) => set(v));
|
---|
6790 | else setters[0](v);
|
---|
6791 | };
|
---|
6792 | };
|
---|
6793 | internalSetCurrentInstance = registerGlobalSetter(
|
---|
6794 | `__VUE_INSTANCE_SETTERS__`,
|
---|
6795 | (v) => currentInstance = v
|
---|
6796 | );
|
---|
6797 | setInSSRSetupState = registerGlobalSetter(
|
---|
6798 | `__VUE_SSR_SETTERS__`,
|
---|
6799 | (v) => isInSSRComponentSetup = v
|
---|
6800 | );
|
---|
6801 | }
|
---|
6802 | const setCurrentInstance = (instance) => {
|
---|
6803 | const prev = currentInstance;
|
---|
6804 | internalSetCurrentInstance(instance);
|
---|
6805 | instance.scope.on();
|
---|
6806 | return () => {
|
---|
6807 | instance.scope.off();
|
---|
6808 | internalSetCurrentInstance(prev);
|
---|
6809 | };
|
---|
6810 | };
|
---|
6811 | const unsetCurrentInstance = () => {
|
---|
6812 | currentInstance && currentInstance.scope.off();
|
---|
6813 | internalSetCurrentInstance(null);
|
---|
6814 | };
|
---|
6815 | const isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");
|
---|
6816 | function validateComponentName(name, { isNativeTag }) {
|
---|
6817 | if (isBuiltInTag(name) || isNativeTag(name)) {
|
---|
6818 | warn$1(
|
---|
6819 | "Do not use built-in or reserved HTML elements as component id: " + name
|
---|
6820 | );
|
---|
6821 | }
|
---|
6822 | }
|
---|
6823 | function isStatefulComponent(instance) {
|
---|
6824 | return instance.vnode.shapeFlag & 4;
|
---|
6825 | }
|
---|
6826 | let isInSSRComponentSetup = false;
|
---|
6827 | function setupComponent$1(instance, isSSR = false, optimized = false) {
|
---|
6828 | isSSR && setInSSRSetupState(isSSR);
|
---|
6829 | const { props, children } = instance.vnode;
|
---|
6830 | const isStateful = isStatefulComponent(instance);
|
---|
6831 | initProps(instance, props, isStateful, isSSR);
|
---|
6832 | initSlots(instance, children, optimized);
|
---|
6833 | const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
|
---|
6834 | isSSR && setInSSRSetupState(false);
|
---|
6835 | return setupResult;
|
---|
6836 | }
|
---|
6837 | function setupStatefulComponent(instance, isSSR) {
|
---|
6838 | var _a;
|
---|
6839 | const Component = instance.type;
|
---|
6840 | {
|
---|
6841 | if (Component.name) {
|
---|
6842 | validateComponentName(Component.name, instance.appContext.config);
|
---|
6843 | }
|
---|
6844 | if (Component.components) {
|
---|
6845 | const names = Object.keys(Component.components);
|
---|
6846 | for (let i = 0; i < names.length; i++) {
|
---|
6847 | validateComponentName(names[i], instance.appContext.config);
|
---|
6848 | }
|
---|
6849 | }
|
---|
6850 | if (Component.directives) {
|
---|
6851 | const names = Object.keys(Component.directives);
|
---|
6852 | for (let i = 0; i < names.length; i++) {
|
---|
6853 | validateDirectiveName(names[i]);
|
---|
6854 | }
|
---|
6855 | }
|
---|
6856 | if (Component.compilerOptions && isRuntimeOnly()) {
|
---|
6857 | warn$1(
|
---|
6858 | `"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.`
|
---|
6859 | );
|
---|
6860 | }
|
---|
6861 | }
|
---|
6862 | instance.accessCache = /* @__PURE__ */ Object.create(null);
|
---|
6863 | instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
|
---|
6864 | {
|
---|
6865 | exposePropsOnRenderContext(instance);
|
---|
6866 | }
|
---|
6867 | const { setup } = Component;
|
---|
6868 | if (setup) {
|
---|
6869 | pauseTracking();
|
---|
6870 | const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
|
---|
6871 | const reset = setCurrentInstance(instance);
|
---|
6872 | const setupResult = callWithErrorHandling(
|
---|
6873 | setup,
|
---|
6874 | instance,
|
---|
6875 | 0,
|
---|
6876 | [
|
---|
6877 | shallowReadonly(instance.props) ,
|
---|
6878 | setupContext
|
---|
6879 | ]
|
---|
6880 | );
|
---|
6881 | const isAsyncSetup = isPromise(setupResult);
|
---|
6882 | resetTracking();
|
---|
6883 | reset();
|
---|
6884 | if ((isAsyncSetup || instance.sp) && !isAsyncWrapper(instance)) {
|
---|
6885 | markAsyncBoundary(instance);
|
---|
6886 | }
|
---|
6887 | if (isAsyncSetup) {
|
---|
6888 | setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
|
---|
6889 | if (isSSR) {
|
---|
6890 | return setupResult.then((resolvedResult) => {
|
---|
6891 | handleSetupResult(instance, resolvedResult, isSSR);
|
---|
6892 | }).catch((e) => {
|
---|
6893 | handleError(e, instance, 0);
|
---|
6894 | });
|
---|
6895 | } else {
|
---|
6896 | instance.asyncDep = setupResult;
|
---|
6897 | if (!instance.suspense) {
|
---|
6898 | const name = (_a = Component.name) != null ? _a : "Anonymous";
|
---|
6899 | warn$1(
|
---|
6900 | `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.`
|
---|
6901 | );
|
---|
6902 | }
|
---|
6903 | }
|
---|
6904 | } else {
|
---|
6905 | handleSetupResult(instance, setupResult, isSSR);
|
---|
6906 | }
|
---|
6907 | } else {
|
---|
6908 | finishComponentSetup(instance, isSSR);
|
---|
6909 | }
|
---|
6910 | }
|
---|
6911 | function handleSetupResult(instance, setupResult, isSSR) {
|
---|
6912 | if (isFunction(setupResult)) {
|
---|
6913 | if (instance.type.__ssrInlineRender) {
|
---|
6914 | instance.ssrRender = setupResult;
|
---|
6915 | } else {
|
---|
6916 | instance.render = setupResult;
|
---|
6917 | }
|
---|
6918 | } else if (isObject(setupResult)) {
|
---|
6919 | if (isVNode$2(setupResult)) {
|
---|
6920 | warn$1(
|
---|
6921 | `setup() should not return VNodes directly - return a render function instead.`
|
---|
6922 | );
|
---|
6923 | }
|
---|
6924 | {
|
---|
6925 | instance.devtoolsRawSetupState = setupResult;
|
---|
6926 | }
|
---|
6927 | instance.setupState = proxyRefs(setupResult);
|
---|
6928 | {
|
---|
6929 | exposeSetupStateOnRenderContext(instance);
|
---|
6930 | }
|
---|
6931 | } else if (setupResult !== void 0) {
|
---|
6932 | warn$1(
|
---|
6933 | `setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`
|
---|
6934 | );
|
---|
6935 | }
|
---|
6936 | finishComponentSetup(instance, isSSR);
|
---|
6937 | }
|
---|
6938 | let compile;
|
---|
6939 | const isRuntimeOnly = () => !compile;
|
---|
6940 | function finishComponentSetup(instance, isSSR, skipOptions) {
|
---|
6941 | const Component = instance.type;
|
---|
6942 | if (!instance.render) {
|
---|
6943 | if (!isSSR && compile && !Component.render) {
|
---|
6944 | const template = Component.template || resolveMergedOptions(instance).template;
|
---|
6945 | if (template) {
|
---|
6946 | {
|
---|
6947 | startMeasure(instance, `compile`);
|
---|
6948 | }
|
---|
6949 | const { isCustomElement, compilerOptions } = instance.appContext.config;
|
---|
6950 | const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
---|
6951 | const finalCompilerOptions = extend(
|
---|
6952 | extend(
|
---|
6953 | {
|
---|
6954 | isCustomElement,
|
---|
6955 | delimiters
|
---|
6956 | },
|
---|
6957 | compilerOptions
|
---|
6958 | ),
|
---|
6959 | componentCompilerOptions
|
---|
6960 | );
|
---|
6961 | Component.render = compile(template, finalCompilerOptions);
|
---|
6962 | {
|
---|
6963 | endMeasure(instance, `compile`);
|
---|
6964 | }
|
---|
6965 | }
|
---|
6966 | }
|
---|
6967 | instance.render = Component.render || NOOP;
|
---|
6968 | }
|
---|
6969 | {
|
---|
6970 | const reset = setCurrentInstance(instance);
|
---|
6971 | pauseTracking();
|
---|
6972 | try {
|
---|
6973 | applyOptions(instance);
|
---|
6974 | } finally {
|
---|
6975 | resetTracking();
|
---|
6976 | reset();
|
---|
6977 | }
|
---|
6978 | }
|
---|
6979 | if (!Component.render && instance.render === NOOP && !isSSR) {
|
---|
6980 | if (Component.template) {
|
---|
6981 | warn$1(
|
---|
6982 | `Component provided template option but runtime compilation is not supported in this build of Vue.` + (` Use "vue.esm-browser.js" instead.` )
|
---|
6983 | );
|
---|
6984 | } else {
|
---|
6985 | warn$1(`Component is missing template or render function: `, Component);
|
---|
6986 | }
|
---|
6987 | }
|
---|
6988 | }
|
---|
6989 | const attrsProxyHandlers = {
|
---|
6990 | get(target, key) {
|
---|
6991 | markAttrsAccessed();
|
---|
6992 | track(target, "get", "");
|
---|
6993 | return target[key];
|
---|
6994 | },
|
---|
6995 | set() {
|
---|
6996 | warn$1(`setupContext.attrs is readonly.`);
|
---|
6997 | return false;
|
---|
6998 | },
|
---|
6999 | deleteProperty() {
|
---|
7000 | warn$1(`setupContext.attrs is readonly.`);
|
---|
7001 | return false;
|
---|
7002 | }
|
---|
7003 | } ;
|
---|
7004 | function getSlotsProxy(instance) {
|
---|
7005 | return new Proxy(instance.slots, {
|
---|
7006 | get(target, key) {
|
---|
7007 | track(instance, "get", "$slots");
|
---|
7008 | return target[key];
|
---|
7009 | }
|
---|
7010 | });
|
---|
7011 | }
|
---|
7012 | function createSetupContext(instance) {
|
---|
7013 | const expose = (exposed) => {
|
---|
7014 | {
|
---|
7015 | if (instance.exposed) {
|
---|
7016 | warn$1(`expose() should be called only once per setup().`);
|
---|
7017 | }
|
---|
7018 | if (exposed != null) {
|
---|
7019 | let exposedType = typeof exposed;
|
---|
7020 | if (exposedType === "object") {
|
---|
7021 | if (isArray(exposed)) {
|
---|
7022 | exposedType = "array";
|
---|
7023 | } else if (isRef(exposed)) {
|
---|
7024 | exposedType = "ref";
|
---|
7025 | }
|
---|
7026 | }
|
---|
7027 | if (exposedType !== "object") {
|
---|
7028 | warn$1(
|
---|
7029 | `expose() should be passed a plain object, received ${exposedType}.`
|
---|
7030 | );
|
---|
7031 | }
|
---|
7032 | }
|
---|
7033 | }
|
---|
7034 | instance.exposed = exposed || {};
|
---|
7035 | };
|
---|
7036 | {
|
---|
7037 | let attrsProxy;
|
---|
7038 | let slotsProxy;
|
---|
7039 | return Object.freeze({
|
---|
7040 | get attrs() {
|
---|
7041 | return attrsProxy || (attrsProxy = new Proxy(instance.attrs, attrsProxyHandlers));
|
---|
7042 | },
|
---|
7043 | get slots() {
|
---|
7044 | return slotsProxy || (slotsProxy = getSlotsProxy(instance));
|
---|
7045 | },
|
---|
7046 | get emit() {
|
---|
7047 | return (event, ...args) => instance.emit(event, ...args);
|
---|
7048 | },
|
---|
7049 | expose
|
---|
7050 | });
|
---|
7051 | }
|
---|
7052 | }
|
---|
7053 | function getComponentPublicInstance(instance) {
|
---|
7054 | if (instance.exposed) {
|
---|
7055 | return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
---|
7056 | get(target, key) {
|
---|
7057 | if (key in target) {
|
---|
7058 | return target[key];
|
---|
7059 | } else if (key in publicPropertiesMap) {
|
---|
7060 | return publicPropertiesMap[key](instance);
|
---|
7061 | }
|
---|
7062 | },
|
---|
7063 | has(target, key) {
|
---|
7064 | return key in target || key in publicPropertiesMap;
|
---|
7065 | }
|
---|
7066 | }));
|
---|
7067 | } else {
|
---|
7068 | return instance.proxy;
|
---|
7069 | }
|
---|
7070 | }
|
---|
7071 | const classifyRE = /(?:^|[-_])(\w)/g;
|
---|
7072 | const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
---|
7073 | function getComponentName(Component, includeInferred = true) {
|
---|
7074 | return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
---|
7075 | }
|
---|
7076 | function formatComponentName(instance, Component, isRoot = false) {
|
---|
7077 | let name = getComponentName(Component);
|
---|
7078 | if (!name && Component.__file) {
|
---|
7079 | const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
---|
7080 | if (match) {
|
---|
7081 | name = match[1];
|
---|
7082 | }
|
---|
7083 | }
|
---|
7084 | if (!name && instance && instance.parent) {
|
---|
7085 | const inferFromRegistry = (registry) => {
|
---|
7086 | for (const key in registry) {
|
---|
7087 | if (registry[key] === Component) {
|
---|
7088 | return key;
|
---|
7089 | }
|
---|
7090 | }
|
---|
7091 | };
|
---|
7092 | name = inferFromRegistry(
|
---|
7093 | instance.components || instance.parent.type.components
|
---|
7094 | ) || inferFromRegistry(instance.appContext.components);
|
---|
7095 | }
|
---|
7096 | return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
---|
7097 | }
|
---|
7098 | function isClassComponent(value) {
|
---|
7099 | return isFunction(value) && "__vccOpts" in value;
|
---|
7100 | }
|
---|
7101 |
|
---|
7102 | const computed = (getterOrOptions, debugOptions) => {
|
---|
7103 | const c = computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
|
---|
7104 | {
|
---|
7105 | const i = getCurrentInstance();
|
---|
7106 | if (i && i.appContext.config.warnRecursiveComputed) {
|
---|
7107 | c._warnRecursive = true;
|
---|
7108 | }
|
---|
7109 | }
|
---|
7110 | return c;
|
---|
7111 | };
|
---|
7112 |
|
---|
7113 | const version = "3.5.13";
|
---|
7114 | const warn = warn$1 ;
|
---|
7115 | const _ssrUtils = {
|
---|
7116 | createComponentInstance: createComponentInstance$1,
|
---|
7117 | setupComponent: setupComponent$1,
|
---|
7118 | renderComponentRoot: renderComponentRoot$1,
|
---|
7119 | setCurrentRenderingInstance: setCurrentRenderingInstance$1,
|
---|
7120 | isVNode: isVNode$2,
|
---|
7121 | normalizeVNode: normalizeVNode$1,
|
---|
7122 | getComponentPublicInstance,
|
---|
7123 | ensureValidVNode: ensureValidVNode$1,
|
---|
7124 | pushWarningContext: pushWarningContext$1,
|
---|
7125 | popWarningContext: popWarningContext$1
|
---|
7126 | };
|
---|
7127 | const ssrUtils = _ssrUtils ;
|
---|
7128 |
|
---|
7129 | let policy = void 0;
|
---|
7130 | const tt = typeof window !== "undefined" && window.trustedTypes;
|
---|
7131 | if (tt) {
|
---|
7132 | try {
|
---|
7133 | policy = /* @__PURE__ */ tt.createPolicy("vue", {
|
---|
7134 | createHTML: (val) => val
|
---|
7135 | });
|
---|
7136 | } catch (e) {
|
---|
7137 | warn(`Error creating trusted types policy: ${e}`);
|
---|
7138 | }
|
---|
7139 | }
|
---|
7140 | const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val;
|
---|
7141 | const svgNS = "http://www.w3.org/2000/svg";
|
---|
7142 | const mathmlNS = "http://www.w3.org/1998/Math/MathML";
|
---|
7143 | const doc = typeof document !== "undefined" ? document : null;
|
---|
7144 | const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
|
---|
7145 | const nodeOps = {
|
---|
7146 | insert: (child, parent, anchor) => {
|
---|
7147 | parent.insertBefore(child, anchor || null);
|
---|
7148 | },
|
---|
7149 | remove: (child) => {
|
---|
7150 | const parent = child.parentNode;
|
---|
7151 | if (parent) {
|
---|
7152 | parent.removeChild(child);
|
---|
7153 | }
|
---|
7154 | },
|
---|
7155 | createElement: (tag, namespace, is, props) => {
|
---|
7156 | const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : is ? doc.createElement(tag, { is }) : doc.createElement(tag);
|
---|
7157 | if (tag === "select" && props && props.multiple != null) {
|
---|
7158 | el.setAttribute("multiple", props.multiple);
|
---|
7159 | }
|
---|
7160 | return el;
|
---|
7161 | },
|
---|
7162 | createText: (text) => doc.createTextNode(text),
|
---|
7163 | createComment: (text) => doc.createComment(text),
|
---|
7164 | setText: (node, text) => {
|
---|
7165 | node.nodeValue = text;
|
---|
7166 | },
|
---|
7167 | setElementText: (el, text) => {
|
---|
7168 | el.textContent = text;
|
---|
7169 | },
|
---|
7170 | parentNode: (node) => node.parentNode,
|
---|
7171 | nextSibling: (node) => node.nextSibling,
|
---|
7172 | querySelector: (selector) => doc.querySelector(selector),
|
---|
7173 | setScopeId(el, id) {
|
---|
7174 | el.setAttribute(id, "");
|
---|
7175 | },
|
---|
7176 | // __UNSAFE__
|
---|
7177 | // Reason: innerHTML.
|
---|
7178 | // Static content here can only come from compiled templates.
|
---|
7179 | // As long as the user only uses trusted templates, this is safe.
|
---|
7180 | insertStaticContent(content, parent, anchor, namespace, start, end) {
|
---|
7181 | const before = anchor ? anchor.previousSibling : parent.lastChild;
|
---|
7182 | if (start && (start === end || start.nextSibling)) {
|
---|
7183 | while (true) {
|
---|
7184 | parent.insertBefore(start.cloneNode(true), anchor);
|
---|
7185 | if (start === end || !(start = start.nextSibling)) break;
|
---|
7186 | }
|
---|
7187 | } else {
|
---|
7188 | templateContainer.innerHTML = unsafeToTrustedHTML(
|
---|
7189 | namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content
|
---|
7190 | );
|
---|
7191 | const template = templateContainer.content;
|
---|
7192 | if (namespace === "svg" || namespace === "mathml") {
|
---|
7193 | const wrapper = template.firstChild;
|
---|
7194 | while (wrapper.firstChild) {
|
---|
7195 | template.appendChild(wrapper.firstChild);
|
---|
7196 | }
|
---|
7197 | template.removeChild(wrapper);
|
---|
7198 | }
|
---|
7199 | parent.insertBefore(template, anchor);
|
---|
7200 | }
|
---|
7201 | return [
|
---|
7202 | // first
|
---|
7203 | before ? before.nextSibling : parent.firstChild,
|
---|
7204 | // last
|
---|
7205 | anchor ? anchor.previousSibling : parent.lastChild
|
---|
7206 | ];
|
---|
7207 | }
|
---|
7208 | };
|
---|
7209 |
|
---|
7210 | const vtcKey = Symbol("_vtc");
|
---|
7211 |
|
---|
7212 | function patchClass(el, value, isSVG) {
|
---|
7213 | const transitionClasses = el[vtcKey];
|
---|
7214 | if (transitionClasses) {
|
---|
7215 | value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
|
---|
7216 | }
|
---|
7217 | if (value == null) {
|
---|
7218 | el.removeAttribute("class");
|
---|
7219 | } else if (isSVG) {
|
---|
7220 | el.setAttribute("class", value);
|
---|
7221 | } else {
|
---|
7222 | el.className = value;
|
---|
7223 | }
|
---|
7224 | }
|
---|
7225 |
|
---|
7226 | const vShowOriginalDisplay = Symbol("_vod");
|
---|
7227 | const vShowHidden = Symbol("_vsh");
|
---|
7228 |
|
---|
7229 | const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT" );
|
---|
7230 |
|
---|
7231 | const displayRE = /(^|;)\s*display\s*:/;
|
---|
7232 | function patchStyle(el, prev, next) {
|
---|
7233 | const style = el.style;
|
---|
7234 | const isCssString = isString(next);
|
---|
7235 | let hasControlledDisplay = false;
|
---|
7236 | if (next && !isCssString) {
|
---|
7237 | if (prev) {
|
---|
7238 | if (!isString(prev)) {
|
---|
7239 | for (const key in prev) {
|
---|
7240 | if (next[key] == null) {
|
---|
7241 | setStyle(style, key, "");
|
---|
7242 | }
|
---|
7243 | }
|
---|
7244 | } else {
|
---|
7245 | for (const prevStyle of prev.split(";")) {
|
---|
7246 | const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
|
---|
7247 | if (next[key] == null) {
|
---|
7248 | setStyle(style, key, "");
|
---|
7249 | }
|
---|
7250 | }
|
---|
7251 | }
|
---|
7252 | }
|
---|
7253 | for (const key in next) {
|
---|
7254 | if (key === "display") {
|
---|
7255 | hasControlledDisplay = true;
|
---|
7256 | }
|
---|
7257 | setStyle(style, key, next[key]);
|
---|
7258 | }
|
---|
7259 | } else {
|
---|
7260 | if (isCssString) {
|
---|
7261 | if (prev !== next) {
|
---|
7262 | const cssVarText = style[CSS_VAR_TEXT];
|
---|
7263 | if (cssVarText) {
|
---|
7264 | next += ";" + cssVarText;
|
---|
7265 | }
|
---|
7266 | style.cssText = next;
|
---|
7267 | hasControlledDisplay = displayRE.test(next);
|
---|
7268 | }
|
---|
7269 | } else if (prev) {
|
---|
7270 | el.removeAttribute("style");
|
---|
7271 | }
|
---|
7272 | }
|
---|
7273 | if (vShowOriginalDisplay in el) {
|
---|
7274 | el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
|
---|
7275 | if (el[vShowHidden]) {
|
---|
7276 | style.display = "none";
|
---|
7277 | }
|
---|
7278 | }
|
---|
7279 | }
|
---|
7280 | const semicolonRE = /[^\\];\s*$/;
|
---|
7281 | const importantRE = /\s*!important$/;
|
---|
7282 | function setStyle(style, name, val) {
|
---|
7283 | if (isArray(val)) {
|
---|
7284 | val.forEach((v) => setStyle(style, name, v));
|
---|
7285 | } else {
|
---|
7286 | if (val == null) val = "";
|
---|
7287 | {
|
---|
7288 | if (semicolonRE.test(val)) {
|
---|
7289 | warn(
|
---|
7290 | `Unexpected semicolon at the end of '${name}' style value: '${val}'`
|
---|
7291 | );
|
---|
7292 | }
|
---|
7293 | }
|
---|
7294 | if (name.startsWith("--")) {
|
---|
7295 | style.setProperty(name, val);
|
---|
7296 | } else {
|
---|
7297 | const prefixed = autoPrefix(style, name);
|
---|
7298 | if (importantRE.test(val)) {
|
---|
7299 | style.setProperty(
|
---|
7300 | hyphenate(prefixed),
|
---|
7301 | val.replace(importantRE, ""),
|
---|
7302 | "important"
|
---|
7303 | );
|
---|
7304 | } else {
|
---|
7305 | style[prefixed] = val;
|
---|
7306 | }
|
---|
7307 | }
|
---|
7308 | }
|
---|
7309 | }
|
---|
7310 | const prefixes = ["Webkit", "Moz", "ms"];
|
---|
7311 | const prefixCache = {};
|
---|
7312 | function autoPrefix(style, rawName) {
|
---|
7313 | const cached = prefixCache[rawName];
|
---|
7314 | if (cached) {
|
---|
7315 | return cached;
|
---|
7316 | }
|
---|
7317 | let name = camelize(rawName);
|
---|
7318 | if (name !== "filter" && name in style) {
|
---|
7319 | return prefixCache[rawName] = name;
|
---|
7320 | }
|
---|
7321 | name = capitalize(name);
|
---|
7322 | for (let i = 0; i < prefixes.length; i++) {
|
---|
7323 | const prefixed = prefixes[i] + name;
|
---|
7324 | if (prefixed in style) {
|
---|
7325 | return prefixCache[rawName] = prefixed;
|
---|
7326 | }
|
---|
7327 | }
|
---|
7328 | return rawName;
|
---|
7329 | }
|
---|
7330 |
|
---|
7331 | const xlinkNS = "http://www.w3.org/1999/xlink";
|
---|
7332 | function patchAttr(el, key, value, isSVG, instance, isBoolean = isSpecialBooleanAttr(key)) {
|
---|
7333 | if (isSVG && key.startsWith("xlink:")) {
|
---|
7334 | if (value == null) {
|
---|
7335 | el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
---|
7336 | } else {
|
---|
7337 | el.setAttributeNS(xlinkNS, key, value);
|
---|
7338 | }
|
---|
7339 | } else {
|
---|
7340 | if (value == null || isBoolean && !includeBooleanAttr(value)) {
|
---|
7341 | el.removeAttribute(key);
|
---|
7342 | } else {
|
---|
7343 | el.setAttribute(
|
---|
7344 | key,
|
---|
7345 | isBoolean ? "" : isSymbol(value) ? String(value) : value
|
---|
7346 | );
|
---|
7347 | }
|
---|
7348 | }
|
---|
7349 | }
|
---|
7350 |
|
---|
7351 | function patchDOMProp(el, key, value, parentComponent, attrName) {
|
---|
7352 | if (key === "innerHTML" || key === "textContent") {
|
---|
7353 | if (value != null) {
|
---|
7354 | el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
|
---|
7355 | }
|
---|
7356 | return;
|
---|
7357 | }
|
---|
7358 | const tag = el.tagName;
|
---|
7359 | if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
|
---|
7360 | !tag.includes("-")) {
|
---|
7361 | const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
|
---|
7362 | const newValue = value == null ? (
|
---|
7363 | // #11647: value should be set as empty string for null and undefined,
|
---|
7364 | // but <input type="checkbox"> should be set as 'on'.
|
---|
7365 | el.type === "checkbox" ? "on" : ""
|
---|
7366 | ) : String(value);
|
---|
7367 | if (oldValue !== newValue || !("_value" in el)) {
|
---|
7368 | el.value = newValue;
|
---|
7369 | }
|
---|
7370 | if (value == null) {
|
---|
7371 | el.removeAttribute(key);
|
---|
7372 | }
|
---|
7373 | el._value = value;
|
---|
7374 | return;
|
---|
7375 | }
|
---|
7376 | let needRemove = false;
|
---|
7377 | if (value === "" || value == null) {
|
---|
7378 | const type = typeof el[key];
|
---|
7379 | if (type === "boolean") {
|
---|
7380 | value = includeBooleanAttr(value);
|
---|
7381 | } else if (value == null && type === "string") {
|
---|
7382 | value = "";
|
---|
7383 | needRemove = true;
|
---|
7384 | } else if (type === "number") {
|
---|
7385 | value = 0;
|
---|
7386 | needRemove = true;
|
---|
7387 | }
|
---|
7388 | }
|
---|
7389 | try {
|
---|
7390 | el[key] = value;
|
---|
7391 | } catch (e) {
|
---|
7392 | if (!needRemove) {
|
---|
7393 | warn(
|
---|
7394 | `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
|
---|
7395 | e
|
---|
7396 | );
|
---|
7397 | }
|
---|
7398 | }
|
---|
7399 | needRemove && el.removeAttribute(attrName || key);
|
---|
7400 | }
|
---|
7401 |
|
---|
7402 | function addEventListener(el, event, handler, options) {
|
---|
7403 | el.addEventListener(event, handler, options);
|
---|
7404 | }
|
---|
7405 | function removeEventListener(el, event, handler, options) {
|
---|
7406 | el.removeEventListener(event, handler, options);
|
---|
7407 | }
|
---|
7408 | const veiKey = Symbol("_vei");
|
---|
7409 | function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
---|
7410 | const invokers = el[veiKey] || (el[veiKey] = {});
|
---|
7411 | const existingInvoker = invokers[rawName];
|
---|
7412 | if (nextValue && existingInvoker) {
|
---|
7413 | existingInvoker.value = sanitizeEventValue(nextValue, rawName) ;
|
---|
7414 | } else {
|
---|
7415 | const [name, options] = parseName(rawName);
|
---|
7416 | if (nextValue) {
|
---|
7417 | const invoker = invokers[rawName] = createInvoker(
|
---|
7418 | sanitizeEventValue(nextValue, rawName) ,
|
---|
7419 | instance
|
---|
7420 | );
|
---|
7421 | addEventListener(el, name, invoker, options);
|
---|
7422 | } else if (existingInvoker) {
|
---|
7423 | removeEventListener(el, name, existingInvoker, options);
|
---|
7424 | invokers[rawName] = void 0;
|
---|
7425 | }
|
---|
7426 | }
|
---|
7427 | }
|
---|
7428 | const optionsModifierRE = /(?:Once|Passive|Capture)$/;
|
---|
7429 | function parseName(name) {
|
---|
7430 | let options;
|
---|
7431 | if (optionsModifierRE.test(name)) {
|
---|
7432 | options = {};
|
---|
7433 | let m;
|
---|
7434 | while (m = name.match(optionsModifierRE)) {
|
---|
7435 | name = name.slice(0, name.length - m[0].length);
|
---|
7436 | options[m[0].toLowerCase()] = true;
|
---|
7437 | }
|
---|
7438 | }
|
---|
7439 | const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
|
---|
7440 | return [event, options];
|
---|
7441 | }
|
---|
7442 | let cachedNow = 0;
|
---|
7443 | const p = /* @__PURE__ */ Promise.resolve();
|
---|
7444 | const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
|
---|
7445 | function createInvoker(initialValue, instance) {
|
---|
7446 | const invoker = (e) => {
|
---|
7447 | if (!e._vts) {
|
---|
7448 | e._vts = Date.now();
|
---|
7449 | } else if (e._vts <= invoker.attached) {
|
---|
7450 | return;
|
---|
7451 | }
|
---|
7452 | callWithAsyncErrorHandling(
|
---|
7453 | patchStopImmediatePropagation(e, invoker.value),
|
---|
7454 | instance,
|
---|
7455 | 5,
|
---|
7456 | [e]
|
---|
7457 | );
|
---|
7458 | };
|
---|
7459 | invoker.value = initialValue;
|
---|
7460 | invoker.attached = getNow();
|
---|
7461 | return invoker;
|
---|
7462 | }
|
---|
7463 | function sanitizeEventValue(value, propName) {
|
---|
7464 | if (isFunction(value) || isArray(value)) {
|
---|
7465 | return value;
|
---|
7466 | }
|
---|
7467 | warn(
|
---|
7468 | `Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?
|
---|
7469 | Expected function or array of functions, received type ${typeof value}.`
|
---|
7470 | );
|
---|
7471 | return NOOP;
|
---|
7472 | }
|
---|
7473 | function patchStopImmediatePropagation(e, value) {
|
---|
7474 | if (isArray(value)) {
|
---|
7475 | const originalStop = e.stopImmediatePropagation;
|
---|
7476 | e.stopImmediatePropagation = () => {
|
---|
7477 | originalStop.call(e);
|
---|
7478 | e._stopped = true;
|
---|
7479 | };
|
---|
7480 | return value.map(
|
---|
7481 | (fn) => (e2) => !e2._stopped && fn && fn(e2)
|
---|
7482 | );
|
---|
7483 | } else {
|
---|
7484 | return value;
|
---|
7485 | }
|
---|
7486 | }
|
---|
7487 |
|
---|
7488 | const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
|
---|
7489 | key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
|
---|
7490 | const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
|
---|
7491 | const isSVG = namespace === "svg";
|
---|
7492 | if (key === "class") {
|
---|
7493 | patchClass(el, nextValue, isSVG);
|
---|
7494 | } else if (key === "style") {
|
---|
7495 | patchStyle(el, prevValue, nextValue);
|
---|
7496 | } else if (isOn(key)) {
|
---|
7497 | if (!isModelListener(key)) {
|
---|
7498 | patchEvent(el, key, prevValue, nextValue, parentComponent);
|
---|
7499 | }
|
---|
7500 | } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
|
---|
7501 | patchDOMProp(el, key, nextValue);
|
---|
7502 | if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) {
|
---|
7503 | patchAttr(el, key, nextValue, isSVG, parentComponent, key !== "value");
|
---|
7504 | }
|
---|
7505 | } else if (
|
---|
7506 | // #11081 force set props for possible async custom element
|
---|
7507 | el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
|
---|
7508 | ) {
|
---|
7509 | patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
|
---|
7510 | } else {
|
---|
7511 | if (key === "true-value") {
|
---|
7512 | el._trueValue = nextValue;
|
---|
7513 | } else if (key === "false-value") {
|
---|
7514 | el._falseValue = nextValue;
|
---|
7515 | }
|
---|
7516 | patchAttr(el, key, nextValue, isSVG);
|
---|
7517 | }
|
---|
7518 | };
|
---|
7519 | function shouldSetAsProp(el, key, value, isSVG) {
|
---|
7520 | if (isSVG) {
|
---|
7521 | if (key === "innerHTML" || key === "textContent") {
|
---|
7522 | return true;
|
---|
7523 | }
|
---|
7524 | if (key in el && isNativeOn(key) && isFunction(value)) {
|
---|
7525 | return true;
|
---|
7526 | }
|
---|
7527 | return false;
|
---|
7528 | }
|
---|
7529 | if (key === "spellcheck" || key === "draggable" || key === "translate") {
|
---|
7530 | return false;
|
---|
7531 | }
|
---|
7532 | if (key === "form") {
|
---|
7533 | return false;
|
---|
7534 | }
|
---|
7535 | if (key === "list" && el.tagName === "INPUT") {
|
---|
7536 | return false;
|
---|
7537 | }
|
---|
7538 | if (key === "type" && el.tagName === "TEXTAREA") {
|
---|
7539 | return false;
|
---|
7540 | }
|
---|
7541 | if (key === "width" || key === "height") {
|
---|
7542 | const tag = el.tagName;
|
---|
7543 | if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
|
---|
7544 | return false;
|
---|
7545 | }
|
---|
7546 | }
|
---|
7547 | if (isNativeOn(key) && isString(value)) {
|
---|
7548 | return false;
|
---|
7549 | }
|
---|
7550 | return key in el;
|
---|
7551 | }
|
---|
7552 |
|
---|
7553 | const getModelAssigner = (vnode) => {
|
---|
7554 | const fn = vnode.props["onUpdate:modelValue"] || false;
|
---|
7555 | return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
|
---|
7556 | };
|
---|
7557 | function onCompositionStart(e) {
|
---|
7558 | e.target.composing = true;
|
---|
7559 | }
|
---|
7560 | function onCompositionEnd(e) {
|
---|
7561 | const target = e.target;
|
---|
7562 | if (target.composing) {
|
---|
7563 | target.composing = false;
|
---|
7564 | target.dispatchEvent(new Event("input"));
|
---|
7565 | }
|
---|
7566 | }
|
---|
7567 | const assignKey = Symbol("_assign");
|
---|
7568 | const vModelText = {
|
---|
7569 | created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
---|
7570 | el[assignKey] = getModelAssigner(vnode);
|
---|
7571 | const castToNumber = number || vnode.props && vnode.props.type === "number";
|
---|
7572 | addEventListener(el, lazy ? "change" : "input", (e) => {
|
---|
7573 | if (e.target.composing) return;
|
---|
7574 | let domValue = el.value;
|
---|
7575 | if (trim) {
|
---|
7576 | domValue = domValue.trim();
|
---|
7577 | }
|
---|
7578 | if (castToNumber) {
|
---|
7579 | domValue = looseToNumber(domValue);
|
---|
7580 | }
|
---|
7581 | el[assignKey](domValue);
|
---|
7582 | });
|
---|
7583 | if (trim) {
|
---|
7584 | addEventListener(el, "change", () => {
|
---|
7585 | el.value = el.value.trim();
|
---|
7586 | });
|
---|
7587 | }
|
---|
7588 | if (!lazy) {
|
---|
7589 | addEventListener(el, "compositionstart", onCompositionStart);
|
---|
7590 | addEventListener(el, "compositionend", onCompositionEnd);
|
---|
7591 | addEventListener(el, "change", onCompositionEnd);
|
---|
7592 | }
|
---|
7593 | },
|
---|
7594 | // set value on mounted so it's after min/max for type="range"
|
---|
7595 | mounted(el, { value }) {
|
---|
7596 | el.value = value == null ? "" : value;
|
---|
7597 | },
|
---|
7598 | beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
|
---|
7599 | el[assignKey] = getModelAssigner(vnode);
|
---|
7600 | if (el.composing) return;
|
---|
7601 | const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
|
---|
7602 | const newValue = value == null ? "" : value;
|
---|
7603 | if (elValue === newValue) {
|
---|
7604 | return;
|
---|
7605 | }
|
---|
7606 | if (document.activeElement === el && el.type !== "range") {
|
---|
7607 | if (lazy && value === oldValue) {
|
---|
7608 | return;
|
---|
7609 | }
|
---|
7610 | if (trim && el.value.trim() === newValue) {
|
---|
7611 | return;
|
---|
7612 | }
|
---|
7613 | }
|
---|
7614 | el.value = newValue;
|
---|
7615 | }
|
---|
7616 | };
|
---|
7617 | const vModelCheckbox = {
|
---|
7618 | // #4096 array checkboxes need to be deep traversed
|
---|
7619 | deep: true,
|
---|
7620 | created(el, _, vnode) {
|
---|
7621 | el[assignKey] = getModelAssigner(vnode);
|
---|
7622 | addEventListener(el, "change", () => {
|
---|
7623 | const modelValue = el._modelValue;
|
---|
7624 | const elementValue = getValue(el);
|
---|
7625 | const checked = el.checked;
|
---|
7626 | const assign = el[assignKey];
|
---|
7627 | if (isArray(modelValue)) {
|
---|
7628 | const index = looseIndexOf(modelValue, elementValue);
|
---|
7629 | const found = index !== -1;
|
---|
7630 | if (checked && !found) {
|
---|
7631 | assign(modelValue.concat(elementValue));
|
---|
7632 | } else if (!checked && found) {
|
---|
7633 | const filtered = [...modelValue];
|
---|
7634 | filtered.splice(index, 1);
|
---|
7635 | assign(filtered);
|
---|
7636 | }
|
---|
7637 | } else if (isSet(modelValue)) {
|
---|
7638 | const cloned = new Set(modelValue);
|
---|
7639 | if (checked) {
|
---|
7640 | cloned.add(elementValue);
|
---|
7641 | } else {
|
---|
7642 | cloned.delete(elementValue);
|
---|
7643 | }
|
---|
7644 | assign(cloned);
|
---|
7645 | } else {
|
---|
7646 | assign(getCheckboxValue(el, checked));
|
---|
7647 | }
|
---|
7648 | });
|
---|
7649 | },
|
---|
7650 | // set initial checked on mount to wait for true-value/false-value
|
---|
7651 | mounted: setChecked,
|
---|
7652 | beforeUpdate(el, binding, vnode) {
|
---|
7653 | el[assignKey] = getModelAssigner(vnode);
|
---|
7654 | setChecked(el, binding, vnode);
|
---|
7655 | }
|
---|
7656 | };
|
---|
7657 | function setChecked(el, { value, oldValue }, vnode) {
|
---|
7658 | el._modelValue = value;
|
---|
7659 | let checked;
|
---|
7660 | if (isArray(value)) {
|
---|
7661 | checked = looseIndexOf(value, vnode.props.value) > -1;
|
---|
7662 | } else if (isSet(value)) {
|
---|
7663 | checked = value.has(vnode.props.value);
|
---|
7664 | } else {
|
---|
7665 | if (value === oldValue) return;
|
---|
7666 | checked = looseEqual(value, getCheckboxValue(el, true));
|
---|
7667 | }
|
---|
7668 | if (el.checked !== checked) {
|
---|
7669 | el.checked = checked;
|
---|
7670 | }
|
---|
7671 | }
|
---|
7672 | const vModelRadio = {
|
---|
7673 | created(el, { value }, vnode) {
|
---|
7674 | el.checked = looseEqual(value, vnode.props.value);
|
---|
7675 | el[assignKey] = getModelAssigner(vnode);
|
---|
7676 | addEventListener(el, "change", () => {
|
---|
7677 | el[assignKey](getValue(el));
|
---|
7678 | });
|
---|
7679 | },
|
---|
7680 | beforeUpdate(el, { value, oldValue }, vnode) {
|
---|
7681 | el[assignKey] = getModelAssigner(vnode);
|
---|
7682 | if (value !== oldValue) {
|
---|
7683 | el.checked = looseEqual(value, vnode.props.value);
|
---|
7684 | }
|
---|
7685 | }
|
---|
7686 | };
|
---|
7687 | function getValue(el) {
|
---|
7688 | return "_value" in el ? el._value : el.value;
|
---|
7689 | }
|
---|
7690 | function getCheckboxValue(el, checked) {
|
---|
7691 | const key = checked ? "_trueValue" : "_falseValue";
|
---|
7692 | return key in el ? el[key] : checked;
|
---|
7693 | }
|
---|
7694 | function initVModelForSSR() {
|
---|
7695 | vModelText.getSSRProps = ({ value }) => ({ value });
|
---|
7696 | vModelRadio.getSSRProps = ({ value }, vnode) => {
|
---|
7697 | if (vnode.props && looseEqual(vnode.props.value, value)) {
|
---|
7698 | return { checked: true };
|
---|
7699 | }
|
---|
7700 | };
|
---|
7701 | vModelCheckbox.getSSRProps = ({ value }, vnode) => {
|
---|
7702 | if (isArray(value)) {
|
---|
7703 | if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) {
|
---|
7704 | return { checked: true };
|
---|
7705 | }
|
---|
7706 | } else if (isSet(value)) {
|
---|
7707 | if (vnode.props && value.has(vnode.props.value)) {
|
---|
7708 | return { checked: true };
|
---|
7709 | }
|
---|
7710 | } else if (value) {
|
---|
7711 | return { checked: true };
|
---|
7712 | }
|
---|
7713 | };
|
---|
7714 | }
|
---|
7715 |
|
---|
7716 | const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
|
---|
7717 | let renderer;
|
---|
7718 | function ensureRenderer() {
|
---|
7719 | return renderer || (renderer = createRenderer(rendererOptions));
|
---|
7720 | }
|
---|
7721 | const createApp = (...args) => {
|
---|
7722 | const app = ensureRenderer().createApp(...args);
|
---|
7723 | {
|
---|
7724 | injectNativeTagCheck(app);
|
---|
7725 | injectCompilerOptionsCheck(app);
|
---|
7726 | }
|
---|
7727 | const { mount } = app;
|
---|
7728 | app.mount = (containerOrSelector) => {
|
---|
7729 | const container = normalizeContainer(containerOrSelector);
|
---|
7730 | if (!container) return;
|
---|
7731 | const component = app._component;
|
---|
7732 | if (!isFunction(component) && !component.render && !component.template) {
|
---|
7733 | component.template = container.innerHTML;
|
---|
7734 | }
|
---|
7735 | if (container.nodeType === 1) {
|
---|
7736 | container.textContent = "";
|
---|
7737 | }
|
---|
7738 | const proxy = mount(container, false, resolveRootNamespace(container));
|
---|
7739 | if (container instanceof Element) {
|
---|
7740 | container.removeAttribute("v-cloak");
|
---|
7741 | container.setAttribute("data-v-app", "");
|
---|
7742 | }
|
---|
7743 | return proxy;
|
---|
7744 | };
|
---|
7745 | return app;
|
---|
7746 | };
|
---|
7747 | function resolveRootNamespace(container) {
|
---|
7748 | if (container instanceof SVGElement) {
|
---|
7749 | return "svg";
|
---|
7750 | }
|
---|
7751 | if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
|
---|
7752 | return "mathml";
|
---|
7753 | }
|
---|
7754 | }
|
---|
7755 | function injectNativeTagCheck(app) {
|
---|
7756 | Object.defineProperty(app.config, "isNativeTag", {
|
---|
7757 | value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
---|
7758 | writable: false
|
---|
7759 | });
|
---|
7760 | }
|
---|
7761 | function injectCompilerOptionsCheck(app) {
|
---|
7762 | {
|
---|
7763 | const isCustomElement = app.config.isCustomElement;
|
---|
7764 | Object.defineProperty(app.config, "isCustomElement", {
|
---|
7765 | get() {
|
---|
7766 | return isCustomElement;
|
---|
7767 | },
|
---|
7768 | set() {
|
---|
7769 | warn(
|
---|
7770 | `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
|
---|
7771 | );
|
---|
7772 | }
|
---|
7773 | });
|
---|
7774 | const compilerOptions = app.config.compilerOptions;
|
---|
7775 | 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.
|
---|
7776 | - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
|
---|
7777 | - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
|
---|
7778 | - 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`;
|
---|
7779 | Object.defineProperty(app.config, "compilerOptions", {
|
---|
7780 | get() {
|
---|
7781 | warn(msg);
|
---|
7782 | return compilerOptions;
|
---|
7783 | },
|
---|
7784 | set() {
|
---|
7785 | warn(msg);
|
---|
7786 | }
|
---|
7787 | });
|
---|
7788 | }
|
---|
7789 | }
|
---|
7790 | function normalizeContainer(container) {
|
---|
7791 | if (isString(container)) {
|
---|
7792 | const res = document.querySelector(container);
|
---|
7793 | if (!res) {
|
---|
7794 | warn(
|
---|
7795 | `Failed to mount app: mount target selector "${container}" returned null.`
|
---|
7796 | );
|
---|
7797 | }
|
---|
7798 | return res;
|
---|
7799 | }
|
---|
7800 | if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
|
---|
7801 | warn(
|
---|
7802 | `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
|
---|
7803 | );
|
---|
7804 | }
|
---|
7805 | return container;
|
---|
7806 | }
|
---|
7807 | let ssrDirectiveInitialized = false;
|
---|
7808 | const initDirectivesForSSR = () => {
|
---|
7809 | if (!ssrDirectiveInitialized) {
|
---|
7810 | ssrDirectiveInitialized = true;
|
---|
7811 | initVModelForSSR();
|
---|
7812 | }
|
---|
7813 | } ;
|
---|
7814 |
|
---|
7815 | const shouldIgnoreProp = /* @__PURE__ */ makeMap(
|
---|
7816 | `,key,ref,innerHTML,textContent,ref_key,ref_for`
|
---|
7817 | );
|
---|
7818 | function ssrRenderAttrs(props, tag) {
|
---|
7819 | let ret = "";
|
---|
7820 | for (const key in props) {
|
---|
7821 | if (shouldIgnoreProp(key) || isOn(key) || tag === "textarea" && key === "value") {
|
---|
7822 | continue;
|
---|
7823 | }
|
---|
7824 | const value = props[key];
|
---|
7825 | if (key === "class") {
|
---|
7826 | ret += ` class="${ssrRenderClass(value)}"`;
|
---|
7827 | } else if (key === "style") {
|
---|
7828 | ret += ` style="${ssrRenderStyle(value)}"`;
|
---|
7829 | } else if (key === "className") {
|
---|
7830 | ret += ` class="${String(value)}"`;
|
---|
7831 | } else {
|
---|
7832 | ret += ssrRenderDynamicAttr(key, value, tag);
|
---|
7833 | }
|
---|
7834 | }
|
---|
7835 | return ret;
|
---|
7836 | }
|
---|
7837 | function ssrRenderDynamicAttr(key, value, tag) {
|
---|
7838 | if (!isRenderableAttrValue(value)) {
|
---|
7839 | return ``;
|
---|
7840 | }
|
---|
7841 | const attrKey = tag && (tag.indexOf("-") > 0 || isSVGTag(tag)) ? key : propsToAttrMap[key] || key.toLowerCase();
|
---|
7842 | if (isBooleanAttr(attrKey)) {
|
---|
7843 | return includeBooleanAttr(value) ? ` ${attrKey}` : ``;
|
---|
7844 | } else if (isSSRSafeAttrName(attrKey)) {
|
---|
7845 | return value === "" ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`;
|
---|
7846 | } else {
|
---|
7847 | console.warn(
|
---|
7848 | `[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`
|
---|
7849 | );
|
---|
7850 | return ``;
|
---|
7851 | }
|
---|
7852 | }
|
---|
7853 | function ssrRenderAttr(key, value) {
|
---|
7854 | if (!isRenderableAttrValue(value)) {
|
---|
7855 | return ``;
|
---|
7856 | }
|
---|
7857 | return ` ${key}="${escapeHtml(value)}"`;
|
---|
7858 | }
|
---|
7859 | function ssrRenderClass(raw) {
|
---|
7860 | return escapeHtml(normalizeClass(raw));
|
---|
7861 | }
|
---|
7862 | function ssrRenderStyle(raw) {
|
---|
7863 | if (!raw) {
|
---|
7864 | return "";
|
---|
7865 | }
|
---|
7866 | if (isString(raw)) {
|
---|
7867 | return escapeHtml(raw);
|
---|
7868 | }
|
---|
7869 | const styles = normalizeStyle(raw);
|
---|
7870 | return escapeHtml(stringifyStyle(styles));
|
---|
7871 | }
|
---|
7872 |
|
---|
7873 | function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
---|
7874 | return renderComponentVNode(
|
---|
7875 | createVNode(comp, props, children),
|
---|
7876 | parentComponent,
|
---|
7877 | slotScopeId
|
---|
7878 | );
|
---|
7879 | }
|
---|
7880 |
|
---|
7881 | const { ensureValidVNode } = ssrUtils;
|
---|
7882 | function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
---|
7883 | push(`<!--[-->`);
|
---|
7884 | ssrRenderSlotInner(
|
---|
7885 | slots,
|
---|
7886 | slotName,
|
---|
7887 | slotProps,
|
---|
7888 | fallbackRenderFn,
|
---|
7889 | push,
|
---|
7890 | parentComponent,
|
---|
7891 | slotScopeId
|
---|
7892 | );
|
---|
7893 | push(`<!--]-->`);
|
---|
7894 | }
|
---|
7895 | function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
|
---|
7896 | const slotFn = slots[slotName];
|
---|
7897 | if (slotFn) {
|
---|
7898 | const slotBuffer = [];
|
---|
7899 | const bufferedPush = (item) => {
|
---|
7900 | slotBuffer.push(item);
|
---|
7901 | };
|
---|
7902 | const ret = slotFn(
|
---|
7903 | slotProps,
|
---|
7904 | bufferedPush,
|
---|
7905 | parentComponent,
|
---|
7906 | slotScopeId ? " " + slotScopeId : ""
|
---|
7907 | );
|
---|
7908 | if (isArray(ret)) {
|
---|
7909 | const validSlotContent = ensureValidVNode(ret);
|
---|
7910 | if (validSlotContent) {
|
---|
7911 | renderVNodeChildren(
|
---|
7912 | push,
|
---|
7913 | validSlotContent,
|
---|
7914 | parentComponent,
|
---|
7915 | slotScopeId
|
---|
7916 | );
|
---|
7917 | } else if (fallbackRenderFn) {
|
---|
7918 | fallbackRenderFn();
|
---|
7919 | }
|
---|
7920 | } else {
|
---|
7921 | let isEmptySlot = true;
|
---|
7922 | if (transition) {
|
---|
7923 | isEmptySlot = false;
|
---|
7924 | } else {
|
---|
7925 | for (let i = 0; i < slotBuffer.length; i++) {
|
---|
7926 | if (!isComment(slotBuffer[i])) {
|
---|
7927 | isEmptySlot = false;
|
---|
7928 | break;
|
---|
7929 | }
|
---|
7930 | }
|
---|
7931 | }
|
---|
7932 | if (isEmptySlot) {
|
---|
7933 | if (fallbackRenderFn) {
|
---|
7934 | fallbackRenderFn();
|
---|
7935 | }
|
---|
7936 | } else {
|
---|
7937 | let start = 0;
|
---|
7938 | let end = slotBuffer.length;
|
---|
7939 | if (transition && slotBuffer[0] === "<!--[-->" && slotBuffer[end - 1] === "<!--]-->") {
|
---|
7940 | start++;
|
---|
7941 | end--;
|
---|
7942 | }
|
---|
7943 | for (let i = start; i < end; i++) {
|
---|
7944 | push(slotBuffer[i]);
|
---|
7945 | }
|
---|
7946 | }
|
---|
7947 | }
|
---|
7948 | } else if (fallbackRenderFn) {
|
---|
7949 | fallbackRenderFn();
|
---|
7950 | }
|
---|
7951 | }
|
---|
7952 | const commentTestRE = /^<!--[\s\S]*-->$/;
|
---|
7953 | const commentRE = /<!--[^]*?-->/gm;
|
---|
7954 | function isComment(item) {
|
---|
7955 | if (typeof item !== "string" || !commentTestRE.test(item)) return false;
|
---|
7956 | if (item.length <= 8) return true;
|
---|
7957 | return !item.replace(commentRE, "").trim();
|
---|
7958 | }
|
---|
7959 |
|
---|
7960 | function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
---|
7961 | parentPush("<!--teleport start-->");
|
---|
7962 | const context = parentComponent.appContext.provides[ssrContextKey];
|
---|
7963 | const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
---|
7964 | const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
|
---|
7965 | const bufferIndex = targetBuffer.length;
|
---|
7966 | let teleportContent;
|
---|
7967 | if (disabled) {
|
---|
7968 | contentRenderFn(parentPush);
|
---|
7969 | teleportContent = `<!--teleport start anchor--><!--teleport anchor-->`;
|
---|
7970 | } else {
|
---|
7971 | const { getBuffer, push } = createBuffer();
|
---|
7972 | push(`<!--teleport start anchor-->`);
|
---|
7973 | contentRenderFn(push);
|
---|
7974 | push(`<!--teleport anchor-->`);
|
---|
7975 | teleportContent = getBuffer();
|
---|
7976 | }
|
---|
7977 | targetBuffer.splice(bufferIndex, 0, teleportContent);
|
---|
7978 | parentPush("<!--teleport end-->");
|
---|
7979 | }
|
---|
7980 |
|
---|
7981 | function ssrInterpolate(value) {
|
---|
7982 | return escapeHtml(toDisplayString(value));
|
---|
7983 | }
|
---|
7984 |
|
---|
7985 | function ssrRenderList(source, renderItem) {
|
---|
7986 | if (isArray(source) || isString(source)) {
|
---|
7987 | for (let i = 0, l = source.length; i < l; i++) {
|
---|
7988 | renderItem(source[i], i);
|
---|
7989 | }
|
---|
7990 | } else if (typeof source === "number") {
|
---|
7991 | if (!Number.isInteger(source)) {
|
---|
7992 | warn(`The v-for range expect an integer value but got ${source}.`);
|
---|
7993 | return;
|
---|
7994 | }
|
---|
7995 | for (let i = 0; i < source; i++) {
|
---|
7996 | renderItem(i + 1, i);
|
---|
7997 | }
|
---|
7998 | } else if (isObject(source)) {
|
---|
7999 | if (source[Symbol.iterator]) {
|
---|
8000 | const arr = Array.from(source);
|
---|
8001 | for (let i = 0, l = arr.length; i < l; i++) {
|
---|
8002 | renderItem(arr[i], i);
|
---|
8003 | }
|
---|
8004 | } else {
|
---|
8005 | const keys = Object.keys(source);
|
---|
8006 | for (let i = 0, l = keys.length; i < l; i++) {
|
---|
8007 | const key = keys[i];
|
---|
8008 | renderItem(source[key], key, i);
|
---|
8009 | }
|
---|
8010 | }
|
---|
8011 | }
|
---|
8012 | }
|
---|
8013 |
|
---|
8014 | async function ssrRenderSuspense(push, { default: renderContent }) {
|
---|
8015 | if (renderContent) {
|
---|
8016 | renderContent();
|
---|
8017 | } else {
|
---|
8018 | push(`<!---->`);
|
---|
8019 | }
|
---|
8020 | }
|
---|
8021 |
|
---|
8022 | function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
---|
8023 | if (typeof dir !== "function" && dir.getSSRProps) {
|
---|
8024 | return dir.getSSRProps(
|
---|
8025 | {
|
---|
8026 | dir,
|
---|
8027 | instance: ssrUtils.getComponentPublicInstance(instance.$),
|
---|
8028 | value,
|
---|
8029 | oldValue: void 0,
|
---|
8030 | arg,
|
---|
8031 | modifiers
|
---|
8032 | },
|
---|
8033 | null
|
---|
8034 | ) || {};
|
---|
8035 | }
|
---|
8036 | return {};
|
---|
8037 | }
|
---|
8038 |
|
---|
8039 | const ssrLooseEqual = looseEqual;
|
---|
8040 | function ssrLooseContain(arr, value) {
|
---|
8041 | return looseIndexOf(arr, value) > -1;
|
---|
8042 | }
|
---|
8043 | function ssrRenderDynamicModel(type, model, value) {
|
---|
8044 | switch (type) {
|
---|
8045 | case "radio":
|
---|
8046 | return looseEqual(model, value) ? " checked" : "";
|
---|
8047 | case "checkbox":
|
---|
8048 | return (isArray(model) ? ssrLooseContain(model, value) : model) ? " checked" : "";
|
---|
8049 | default:
|
---|
8050 | return ssrRenderAttr("value", model);
|
---|
8051 | }
|
---|
8052 | }
|
---|
8053 | function ssrGetDynamicModelProps(existingProps = {}, model) {
|
---|
8054 | const { type, value } = existingProps;
|
---|
8055 | switch (type) {
|
---|
8056 | case "radio":
|
---|
8057 | return looseEqual(model, value) ? { checked: true } : null;
|
---|
8058 | case "checkbox":
|
---|
8059 | return (isArray(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null;
|
---|
8060 | default:
|
---|
8061 | return { value: model };
|
---|
8062 | }
|
---|
8063 | }
|
---|
8064 |
|
---|
8065 | function ssrCompile(template, instance) {
|
---|
8066 | {
|
---|
8067 | throw new Error(
|
---|
8068 | `On-the-fly template compilation is not supported in the ESM build of @vue/server-renderer. All templates must be pre-compiled into render functions.`
|
---|
8069 | );
|
---|
8070 | }
|
---|
8071 | }
|
---|
8072 |
|
---|
8073 | const {
|
---|
8074 | createComponentInstance,
|
---|
8075 | setCurrentRenderingInstance,
|
---|
8076 | setupComponent,
|
---|
8077 | renderComponentRoot,
|
---|
8078 | normalizeVNode,
|
---|
8079 | pushWarningContext,
|
---|
8080 | popWarningContext
|
---|
8081 | } = ssrUtils;
|
---|
8082 | function createBuffer() {
|
---|
8083 | let appendable = false;
|
---|
8084 | const buffer = [];
|
---|
8085 | return {
|
---|
8086 | getBuffer() {
|
---|
8087 | return buffer;
|
---|
8088 | },
|
---|
8089 | push(item) {
|
---|
8090 | const isStringItem = isString(item);
|
---|
8091 | if (appendable && isStringItem) {
|
---|
8092 | buffer[buffer.length - 1] += item;
|
---|
8093 | return;
|
---|
8094 | }
|
---|
8095 | buffer.push(item);
|
---|
8096 | appendable = isStringItem;
|
---|
8097 | if (isPromise(item) || isArray(item) && item.hasAsync) {
|
---|
8098 | buffer.hasAsync = true;
|
---|
8099 | }
|
---|
8100 | }
|
---|
8101 | };
|
---|
8102 | }
|
---|
8103 | function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
---|
8104 | const instance = vnode.component = createComponentInstance(
|
---|
8105 | vnode,
|
---|
8106 | parentComponent,
|
---|
8107 | null
|
---|
8108 | );
|
---|
8109 | pushWarningContext(vnode);
|
---|
8110 | const res = setupComponent(
|
---|
8111 | instance,
|
---|
8112 | true
|
---|
8113 | /* isSSR */
|
---|
8114 | );
|
---|
8115 | popWarningContext();
|
---|
8116 | const hasAsyncSetup = isPromise(res);
|
---|
8117 | let prefetches = instance.sp;
|
---|
8118 | if (hasAsyncSetup || prefetches) {
|
---|
8119 | const p = Promise.resolve(res).then(() => {
|
---|
8120 | if (hasAsyncSetup) prefetches = instance.sp;
|
---|
8121 | if (prefetches) {
|
---|
8122 | return Promise.all(
|
---|
8123 | prefetches.map((prefetch) => prefetch.call(instance.proxy))
|
---|
8124 | );
|
---|
8125 | }
|
---|
8126 | }).catch(NOOP);
|
---|
8127 | return p.then(() => renderComponentSubTree(instance, slotScopeId));
|
---|
8128 | } else {
|
---|
8129 | return renderComponentSubTree(instance, slotScopeId);
|
---|
8130 | }
|
---|
8131 | }
|
---|
8132 | function renderComponentSubTree(instance, slotScopeId) {
|
---|
8133 | pushWarningContext(instance.vnode);
|
---|
8134 | const comp = instance.type;
|
---|
8135 | const { getBuffer, push } = createBuffer();
|
---|
8136 | if (isFunction(comp)) {
|
---|
8137 | let root = renderComponentRoot(instance);
|
---|
8138 | if (!comp.props) {
|
---|
8139 | for (const key in instance.attrs) {
|
---|
8140 | if (key.startsWith(`data-v-`)) {
|
---|
8141 | (root.props || (root.props = {}))[key] = ``;
|
---|
8142 | }
|
---|
8143 | }
|
---|
8144 | }
|
---|
8145 | renderVNode(push, instance.subTree = root, instance, slotScopeId);
|
---|
8146 | } else {
|
---|
8147 | if ((!instance.render || instance.render === NOOP) && !instance.ssrRender && !comp.ssrRender && isString(comp.template)) {
|
---|
8148 | comp.ssrRender = ssrCompile(comp.template);
|
---|
8149 | }
|
---|
8150 | const ssrRender = instance.ssrRender || comp.ssrRender;
|
---|
8151 | if (ssrRender) {
|
---|
8152 | let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
|
---|
8153 | let hasCloned = false;
|
---|
8154 | let cur = instance;
|
---|
8155 | while (true) {
|
---|
8156 | const scopeId = cur.vnode.scopeId;
|
---|
8157 | if (scopeId) {
|
---|
8158 | if (!hasCloned) {
|
---|
8159 | attrs = { ...attrs };
|
---|
8160 | hasCloned = true;
|
---|
8161 | }
|
---|
8162 | attrs[scopeId] = "";
|
---|
8163 | }
|
---|
8164 | const parent = cur.parent;
|
---|
8165 | if (parent && parent.subTree && parent.subTree === cur.vnode) {
|
---|
8166 | cur = parent;
|
---|
8167 | } else {
|
---|
8168 | break;
|
---|
8169 | }
|
---|
8170 | }
|
---|
8171 | if (slotScopeId) {
|
---|
8172 | if (!hasCloned) attrs = { ...attrs };
|
---|
8173 | const slotScopeIdList = slotScopeId.trim().split(" ");
|
---|
8174 | for (let i = 0; i < slotScopeIdList.length; i++) {
|
---|
8175 | attrs[slotScopeIdList[i]] = "";
|
---|
8176 | }
|
---|
8177 | }
|
---|
8178 | const prev = setCurrentRenderingInstance(instance);
|
---|
8179 | try {
|
---|
8180 | ssrRender(
|
---|
8181 | instance.proxy,
|
---|
8182 | push,
|
---|
8183 | instance,
|
---|
8184 | attrs,
|
---|
8185 | // compiler-optimized bindings
|
---|
8186 | instance.props,
|
---|
8187 | instance.setupState,
|
---|
8188 | instance.data,
|
---|
8189 | instance.ctx
|
---|
8190 | );
|
---|
8191 | } finally {
|
---|
8192 | setCurrentRenderingInstance(prev);
|
---|
8193 | }
|
---|
8194 | } else if (instance.render && instance.render !== NOOP) {
|
---|
8195 | renderVNode(
|
---|
8196 | push,
|
---|
8197 | instance.subTree = renderComponentRoot(instance),
|
---|
8198 | instance,
|
---|
8199 | slotScopeId
|
---|
8200 | );
|
---|
8201 | } else {
|
---|
8202 | const componentName = comp.name || comp.__file || `<Anonymous>`;
|
---|
8203 | warn(`Component ${componentName} is missing template or render function.`);
|
---|
8204 | push(`<!---->`);
|
---|
8205 | }
|
---|
8206 | }
|
---|
8207 | popWarningContext();
|
---|
8208 | return getBuffer();
|
---|
8209 | }
|
---|
8210 | function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
---|
8211 | const { type, shapeFlag, children, dirs, props } = vnode;
|
---|
8212 | if (dirs) {
|
---|
8213 | vnode.props = applySSRDirectives(vnode, props, dirs);
|
---|
8214 | }
|
---|
8215 | switch (type) {
|
---|
8216 | case Text:
|
---|
8217 | push(escapeHtml(children));
|
---|
8218 | break;
|
---|
8219 | case Comment:
|
---|
8220 | push(
|
---|
8221 | children ? `<!--${escapeHtmlComment(children)}-->` : `<!---->`
|
---|
8222 | );
|
---|
8223 | break;
|
---|
8224 | case Static:
|
---|
8225 | push(children);
|
---|
8226 | break;
|
---|
8227 | case Fragment:
|
---|
8228 | if (vnode.slotScopeIds) {
|
---|
8229 | slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
---|
8230 | }
|
---|
8231 | push(`<!--[-->`);
|
---|
8232 | renderVNodeChildren(
|
---|
8233 | push,
|
---|
8234 | children,
|
---|
8235 | parentComponent,
|
---|
8236 | slotScopeId
|
---|
8237 | );
|
---|
8238 | push(`<!--]-->`);
|
---|
8239 | break;
|
---|
8240 | default:
|
---|
8241 | if (shapeFlag & 1) {
|
---|
8242 | renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
---|
8243 | } else if (shapeFlag & 6) {
|
---|
8244 | push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
---|
8245 | } else if (shapeFlag & 64) {
|
---|
8246 | renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
---|
8247 | } else if (shapeFlag & 128) {
|
---|
8248 | renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
---|
8249 | } else {
|
---|
8250 | warn(
|
---|
8251 | "[@vue/server-renderer] Invalid VNode type:",
|
---|
8252 | type,
|
---|
8253 | `(${typeof type})`
|
---|
8254 | );
|
---|
8255 | }
|
---|
8256 | }
|
---|
8257 | }
|
---|
8258 | function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
---|
8259 | for (let i = 0; i < children.length; i++) {
|
---|
8260 | renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
---|
8261 | }
|
---|
8262 | }
|
---|
8263 | function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
|
---|
8264 | const tag = vnode.type;
|
---|
8265 | let { props, children, shapeFlag, scopeId } = vnode;
|
---|
8266 | let openTag = `<${tag}`;
|
---|
8267 | if (props) {
|
---|
8268 | openTag += ssrRenderAttrs(props, tag);
|
---|
8269 | }
|
---|
8270 | if (scopeId) {
|
---|
8271 | openTag += ` ${scopeId}`;
|
---|
8272 | }
|
---|
8273 | let curParent = parentComponent;
|
---|
8274 | let curVnode = vnode;
|
---|
8275 | while (curParent && curVnode === curParent.subTree) {
|
---|
8276 | curVnode = curParent.vnode;
|
---|
8277 | if (curVnode.scopeId) {
|
---|
8278 | openTag += ` ${curVnode.scopeId}`;
|
---|
8279 | }
|
---|
8280 | curParent = curParent.parent;
|
---|
8281 | }
|
---|
8282 | if (slotScopeId) {
|
---|
8283 | openTag += ` ${slotScopeId}`;
|
---|
8284 | }
|
---|
8285 | push(openTag + `>`);
|
---|
8286 | if (!isVoidTag(tag)) {
|
---|
8287 | let hasChildrenOverride = false;
|
---|
8288 | if (props) {
|
---|
8289 | if (props.innerHTML) {
|
---|
8290 | hasChildrenOverride = true;
|
---|
8291 | push(props.innerHTML);
|
---|
8292 | } else if (props.textContent) {
|
---|
8293 | hasChildrenOverride = true;
|
---|
8294 | push(escapeHtml(props.textContent));
|
---|
8295 | } else if (tag === "textarea" && props.value) {
|
---|
8296 | hasChildrenOverride = true;
|
---|
8297 | push(escapeHtml(props.value));
|
---|
8298 | }
|
---|
8299 | }
|
---|
8300 | if (!hasChildrenOverride) {
|
---|
8301 | if (shapeFlag & 8) {
|
---|
8302 | push(escapeHtml(children));
|
---|
8303 | } else if (shapeFlag & 16) {
|
---|
8304 | renderVNodeChildren(
|
---|
8305 | push,
|
---|
8306 | children,
|
---|
8307 | parentComponent,
|
---|
8308 | slotScopeId
|
---|
8309 | );
|
---|
8310 | }
|
---|
8311 | }
|
---|
8312 | push(`</${tag}>`);
|
---|
8313 | }
|
---|
8314 | }
|
---|
8315 | function applySSRDirectives(vnode, rawProps, dirs) {
|
---|
8316 | const toMerge = [];
|
---|
8317 | for (let i = 0; i < dirs.length; i++) {
|
---|
8318 | const binding = dirs[i];
|
---|
8319 | const {
|
---|
8320 | dir: { getSSRProps }
|
---|
8321 | } = binding;
|
---|
8322 | if (getSSRProps) {
|
---|
8323 | const props = getSSRProps(binding, vnode);
|
---|
8324 | if (props) toMerge.push(props);
|
---|
8325 | }
|
---|
8326 | }
|
---|
8327 | return mergeProps(rawProps || {}, ...toMerge);
|
---|
8328 | }
|
---|
8329 | function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
---|
8330 | const target = vnode.props && vnode.props.to;
|
---|
8331 | const disabled = vnode.props && vnode.props.disabled;
|
---|
8332 | if (!target) {
|
---|
8333 | if (!disabled) {
|
---|
8334 | warn(`[@vue/server-renderer] Teleport is missing target prop.`);
|
---|
8335 | }
|
---|
8336 | return [];
|
---|
8337 | }
|
---|
8338 | if (!isString(target)) {
|
---|
8339 | warn(
|
---|
8340 | `[@vue/server-renderer] Teleport target must be a query selector string.`
|
---|
8341 | );
|
---|
8342 | return [];
|
---|
8343 | }
|
---|
8344 | ssrRenderTeleport(
|
---|
8345 | push,
|
---|
8346 | (push2) => {
|
---|
8347 | renderVNodeChildren(
|
---|
8348 | push2,
|
---|
8349 | vnode.children,
|
---|
8350 | parentComponent,
|
---|
8351 | slotScopeId
|
---|
8352 | );
|
---|
8353 | },
|
---|
8354 | target,
|
---|
8355 | disabled || disabled === "",
|
---|
8356 | parentComponent
|
---|
8357 | );
|
---|
8358 | }
|
---|
8359 |
|
---|
8360 | const { isVNode: isVNode$1 } = ssrUtils;
|
---|
8361 | function nestedUnrollBuffer(buffer, parentRet, startIndex) {
|
---|
8362 | if (!buffer.hasAsync) {
|
---|
8363 | return parentRet + unrollBufferSync$1(buffer);
|
---|
8364 | }
|
---|
8365 | let ret = parentRet;
|
---|
8366 | for (let i = startIndex; i < buffer.length; i += 1) {
|
---|
8367 | const item = buffer[i];
|
---|
8368 | if (isString(item)) {
|
---|
8369 | ret += item;
|
---|
8370 | continue;
|
---|
8371 | }
|
---|
8372 | if (isPromise(item)) {
|
---|
8373 | return item.then((nestedItem) => {
|
---|
8374 | buffer[i] = nestedItem;
|
---|
8375 | return nestedUnrollBuffer(buffer, ret, i);
|
---|
8376 | });
|
---|
8377 | }
|
---|
8378 | const result = nestedUnrollBuffer(item, ret, 0);
|
---|
8379 | if (isPromise(result)) {
|
---|
8380 | return result.then((nestedItem) => {
|
---|
8381 | buffer[i] = nestedItem;
|
---|
8382 | return nestedUnrollBuffer(buffer, "", i);
|
---|
8383 | });
|
---|
8384 | }
|
---|
8385 | ret = result;
|
---|
8386 | }
|
---|
8387 | return ret;
|
---|
8388 | }
|
---|
8389 | function unrollBuffer$1(buffer) {
|
---|
8390 | return nestedUnrollBuffer(buffer, "", 0);
|
---|
8391 | }
|
---|
8392 | function unrollBufferSync$1(buffer) {
|
---|
8393 | let ret = "";
|
---|
8394 | for (let i = 0; i < buffer.length; i++) {
|
---|
8395 | let item = buffer[i];
|
---|
8396 | if (isString(item)) {
|
---|
8397 | ret += item;
|
---|
8398 | } else {
|
---|
8399 | ret += unrollBufferSync$1(item);
|
---|
8400 | }
|
---|
8401 | }
|
---|
8402 | return ret;
|
---|
8403 | }
|
---|
8404 | async function renderToString(input, context = {}) {
|
---|
8405 | if (isVNode$1(input)) {
|
---|
8406 | return renderToString(createApp({ render: () => input }), context);
|
---|
8407 | }
|
---|
8408 | const vnode = createVNode(input._component, input._props);
|
---|
8409 | vnode.appContext = input._context;
|
---|
8410 | input.provide(ssrContextKey, context);
|
---|
8411 | const buffer = await renderComponentVNode(vnode);
|
---|
8412 | const result = await unrollBuffer$1(buffer);
|
---|
8413 | await resolveTeleports(context);
|
---|
8414 | if (context.__watcherHandles) {
|
---|
8415 | for (const unwatch of context.__watcherHandles) {
|
---|
8416 | unwatch();
|
---|
8417 | }
|
---|
8418 | }
|
---|
8419 | return result;
|
---|
8420 | }
|
---|
8421 | async function resolveTeleports(context) {
|
---|
8422 | if (context.__teleportBuffers) {
|
---|
8423 | context.teleports = context.teleports || {};
|
---|
8424 | for (const key in context.__teleportBuffers) {
|
---|
8425 | context.teleports[key] = await unrollBuffer$1(
|
---|
8426 | await Promise.all([context.__teleportBuffers[key]])
|
---|
8427 | );
|
---|
8428 | }
|
---|
8429 | }
|
---|
8430 | }
|
---|
8431 |
|
---|
8432 | const { isVNode } = ssrUtils;
|
---|
8433 | async function unrollBuffer(buffer, stream) {
|
---|
8434 | if (buffer.hasAsync) {
|
---|
8435 | for (let i = 0; i < buffer.length; i++) {
|
---|
8436 | let item = buffer[i];
|
---|
8437 | if (isPromise(item)) {
|
---|
8438 | item = await item;
|
---|
8439 | }
|
---|
8440 | if (isString(item)) {
|
---|
8441 | stream.push(item);
|
---|
8442 | } else {
|
---|
8443 | await unrollBuffer(item, stream);
|
---|
8444 | }
|
---|
8445 | }
|
---|
8446 | } else {
|
---|
8447 | unrollBufferSync(buffer, stream);
|
---|
8448 | }
|
---|
8449 | }
|
---|
8450 | function unrollBufferSync(buffer, stream) {
|
---|
8451 | for (let i = 0; i < buffer.length; i++) {
|
---|
8452 | let item = buffer[i];
|
---|
8453 | if (isString(item)) {
|
---|
8454 | stream.push(item);
|
---|
8455 | } else {
|
---|
8456 | unrollBufferSync(item, stream);
|
---|
8457 | }
|
---|
8458 | }
|
---|
8459 | }
|
---|
8460 | function renderToSimpleStream(input, context, stream) {
|
---|
8461 | if (isVNode(input)) {
|
---|
8462 | return renderToSimpleStream(
|
---|
8463 | createApp({ render: () => input }),
|
---|
8464 | context,
|
---|
8465 | stream
|
---|
8466 | );
|
---|
8467 | }
|
---|
8468 | const vnode = createVNode(input._component, input._props);
|
---|
8469 | vnode.appContext = input._context;
|
---|
8470 | input.provide(ssrContextKey, context);
|
---|
8471 | Promise.resolve(renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
|
---|
8472 | if (context.__watcherHandles) {
|
---|
8473 | for (const unwatch of context.__watcherHandles) {
|
---|
8474 | unwatch();
|
---|
8475 | }
|
---|
8476 | }
|
---|
8477 | }).then(() => stream.push(null)).catch((error) => {
|
---|
8478 | stream.destroy(error);
|
---|
8479 | });
|
---|
8480 | return stream;
|
---|
8481 | }
|
---|
8482 | function renderToStream(input, context = {}) {
|
---|
8483 | console.warn(
|
---|
8484 | `[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`
|
---|
8485 | );
|
---|
8486 | return renderToNodeStream(input, context);
|
---|
8487 | }
|
---|
8488 | function renderToNodeStream(input, context = {}) {
|
---|
8489 | {
|
---|
8490 | throw new Error(
|
---|
8491 | `ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.`
|
---|
8492 | );
|
---|
8493 | }
|
---|
8494 | }
|
---|
8495 | function pipeToNodeWritable(input, context = {}, writable) {
|
---|
8496 | renderToSimpleStream(input, context, {
|
---|
8497 | push(content) {
|
---|
8498 | if (content != null) {
|
---|
8499 | writable.write(content);
|
---|
8500 | } else {
|
---|
8501 | writable.end();
|
---|
8502 | }
|
---|
8503 | },
|
---|
8504 | destroy(err) {
|
---|
8505 | writable.destroy(err);
|
---|
8506 | }
|
---|
8507 | });
|
---|
8508 | }
|
---|
8509 | function renderToWebStream(input, context = {}) {
|
---|
8510 | if (typeof ReadableStream !== "function") {
|
---|
8511 | throw new Error(
|
---|
8512 | `ReadableStream constructor is not available in the global scope. If the target environment does support web streams, consider using pipeToWebWritable() with an existing WritableStream instance instead.`
|
---|
8513 | );
|
---|
8514 | }
|
---|
8515 | const encoder = new TextEncoder();
|
---|
8516 | let cancelled = false;
|
---|
8517 | return new ReadableStream({
|
---|
8518 | start(controller) {
|
---|
8519 | renderToSimpleStream(input, context, {
|
---|
8520 | push(content) {
|
---|
8521 | if (cancelled) return;
|
---|
8522 | if (content != null) {
|
---|
8523 | controller.enqueue(encoder.encode(content));
|
---|
8524 | } else {
|
---|
8525 | controller.close();
|
---|
8526 | }
|
---|
8527 | },
|
---|
8528 | destroy(err) {
|
---|
8529 | controller.error(err);
|
---|
8530 | }
|
---|
8531 | });
|
---|
8532 | },
|
---|
8533 | cancel() {
|
---|
8534 | cancelled = true;
|
---|
8535 | }
|
---|
8536 | });
|
---|
8537 | }
|
---|
8538 | function pipeToWebWritable(input, context = {}, writable) {
|
---|
8539 | const writer = writable.getWriter();
|
---|
8540 | const encoder = new TextEncoder();
|
---|
8541 | let hasReady = false;
|
---|
8542 | try {
|
---|
8543 | hasReady = isPromise(writer.ready);
|
---|
8544 | } catch (e) {
|
---|
8545 | }
|
---|
8546 | renderToSimpleStream(input, context, {
|
---|
8547 | async push(content) {
|
---|
8548 | if (hasReady) {
|
---|
8549 | await writer.ready;
|
---|
8550 | }
|
---|
8551 | if (content != null) {
|
---|
8552 | return writer.write(encoder.encode(content));
|
---|
8553 | } else {
|
---|
8554 | return writer.close();
|
---|
8555 | }
|
---|
8556 | },
|
---|
8557 | destroy(err) {
|
---|
8558 | console.log(err);
|
---|
8559 | writer.close();
|
---|
8560 | }
|
---|
8561 | });
|
---|
8562 | }
|
---|
8563 |
|
---|
8564 | initDirectivesForSSR();
|
---|
8565 |
|
---|
8566 | export { pipeToNodeWritable, pipeToWebWritable, renderToNodeStream, renderToSimpleStream, renderToStream, renderToString, renderToWebStream, ssrGetDirectiveProps, ssrGetDynamicModelProps, includeBooleanAttr as ssrIncludeBooleanAttr, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderDynamicAttr, ssrRenderDynamicModel, ssrRenderList, ssrRenderSlot, ssrRenderSlotInner, ssrRenderStyle, ssrRenderSuspense, ssrRenderTeleport, renderVNode as ssrRenderVNode };
|
---|