1 | var Vue = (function (exports) {
|
2 | 'use strict';
|
3 |
|
4 | |
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | function makeMap(str, expectsLowerCase) {
|
12 | const map = Object.create(null);
|
13 | const list = str.split(',');
|
14 | for (let i = 0; i < list.length; i++) {
|
15 | map[list[i]] = true;
|
16 | }
|
17 | return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
|
18 | }
|
19 |
|
20 | const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
|
21 | 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
|
22 | 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
|
23 | const isGloballyWhitelisted = makeMap(GLOBALS_WHITE_LISTED);
|
24 |
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
37 | const isSpecialBooleanAttr = makeMap(specialBooleanAttrs);
|
38 | |
39 |
|
40 |
|
41 |
|
42 | function includeBooleanAttr(value) {
|
43 | return !!value || value === '';
|
44 | }
|
45 |
|
46 | function normalizeStyle(value) {
|
47 | if (isArray(value)) {
|
48 | const res = {};
|
49 | for (let i = 0; i < value.length; i++) {
|
50 | const item = value[i];
|
51 | const normalized = isString(item)
|
52 | ? parseStringStyle(item)
|
53 | : normalizeStyle(item);
|
54 | if (normalized) {
|
55 | for (const key in normalized) {
|
56 | res[key] = normalized[key];
|
57 | }
|
58 | }
|
59 | }
|
60 | return res;
|
61 | }
|
62 | else if (isString(value)) {
|
63 | return value;
|
64 | }
|
65 | else if (isObject(value)) {
|
66 | return value;
|
67 | }
|
68 | }
|
69 | const listDelimiterRE = /;(?![^(]*\))/g;
|
70 | const propertyDelimiterRE = /:(.+)/;
|
71 | function parseStringStyle(cssText) {
|
72 | const ret = {};
|
73 | cssText.split(listDelimiterRE).forEach(item => {
|
74 | if (item) {
|
75 | const tmp = item.split(propertyDelimiterRE);
|
76 | tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
77 | }
|
78 | });
|
79 | return ret;
|
80 | }
|
81 | function normalizeClass(value) {
|
82 | let res = '';
|
83 | if (isString(value)) {
|
84 | res = value;
|
85 | }
|
86 | else if (isArray(value)) {
|
87 | for (let i = 0; i < value.length; i++) {
|
88 | const normalized = normalizeClass(value[i]);
|
89 | if (normalized) {
|
90 | res += normalized + ' ';
|
91 | }
|
92 | }
|
93 | }
|
94 | else if (isObject(value)) {
|
95 | for (const name in value) {
|
96 | if (value[name]) {
|
97 | res += name + ' ';
|
98 | }
|
99 | }
|
100 | }
|
101 | return res.trim();
|
102 | }
|
103 | function normalizeProps(props) {
|
104 | if (!props)
|
105 | return null;
|
106 | let { class: klass, style } = props;
|
107 | if (klass && !isString(klass)) {
|
108 | props.class = normalizeClass(klass);
|
109 | }
|
110 | if (style) {
|
111 | props.style = normalizeStyle(style);
|
112 | }
|
113 | return props;
|
114 | }
|
115 |
|
116 |
|
117 |
|
118 | const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
|
119 | 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
|
120 | 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
|
121 | 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
|
122 | 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
|
123 | 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
|
124 | 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
|
125 | 'option,output,progress,select,textarea,details,dialog,menu,' +
|
126 | 'summary,template,blockquote,iframe,tfoot';
|
127 |
|
128 | const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
|
129 | 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
|
130 | 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
|
131 | 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
|
132 | 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
|
133 | 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
|
134 | 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
|
135 | 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
|
136 | 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
|
137 | 'text,textPath,title,tspan,unknown,use,view';
|
138 | const isHTMLTag = makeMap(HTML_TAGS);
|
139 | const isSVGTag = makeMap(SVG_TAGS);
|
140 |
|
141 | function looseCompareArrays(a, b) {
|
142 | if (a.length !== b.length)
|
143 | return false;
|
144 | let equal = true;
|
145 | for (let i = 0; equal && i < a.length; i++) {
|
146 | equal = looseEqual(a[i], b[i]);
|
147 | }
|
148 | return equal;
|
149 | }
|
150 | function looseEqual(a, b) {
|
151 | if (a === b)
|
152 | return true;
|
153 | let aValidType = isDate(a);
|
154 | let bValidType = isDate(b);
|
155 | if (aValidType || bValidType) {
|
156 | return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
157 | }
|
158 | aValidType = isArray(a);
|
159 | bValidType = isArray(b);
|
160 | if (aValidType || bValidType) {
|
161 | return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
162 | }
|
163 | aValidType = isObject(a);
|
164 | bValidType = isObject(b);
|
165 | if (aValidType || bValidType) {
|
166 |
|
167 | if (!aValidType || !bValidType) {
|
168 | return false;
|
169 | }
|
170 | const aKeysCount = Object.keys(a).length;
|
171 | const bKeysCount = Object.keys(b).length;
|
172 | if (aKeysCount !== bKeysCount) {
|
173 | return false;
|
174 | }
|
175 | for (const key in a) {
|
176 | const aHasKey = a.hasOwnProperty(key);
|
177 | const bHasKey = b.hasOwnProperty(key);
|
178 | if ((aHasKey && !bHasKey) ||
|
179 | (!aHasKey && bHasKey) ||
|
180 | !looseEqual(a[key], b[key])) {
|
181 | return false;
|
182 | }
|
183 | }
|
184 | }
|
185 | return String(a) === String(b);
|
186 | }
|
187 | function looseIndexOf(arr, val) {
|
188 | return arr.findIndex(item => looseEqual(item, val));
|
189 | }
|
190 |
|
191 | |
192 |
|
193 |
|
194 |
|
195 | const toDisplayString = (val) => {
|
196 | return val == null
|
197 | ? ''
|
198 | : isArray(val) ||
|
199 | (isObject(val) &&
|
200 | (val.toString === objectToString || !isFunction(val.toString)))
|
201 | ? JSON.stringify(val, replacer, 2)
|
202 | : String(val);
|
203 | };
|
204 | const replacer = (_key, val) => {
|
205 |
|
206 | if (val && val.__v_isRef) {
|
207 | return replacer(_key, val.value);
|
208 | }
|
209 | else if (isMap(val)) {
|
210 | return {
|
211 | [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
|
212 | entries[`${key} =>`] = val;
|
213 | return entries;
|
214 | }, {})
|
215 | };
|
216 | }
|
217 | else if (isSet(val)) {
|
218 | return {
|
219 | [`Set(${val.size})`]: [...val.values()]
|
220 | };
|
221 | }
|
222 | else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
|
223 | return String(val);
|
224 | }
|
225 | return val;
|
226 | };
|
227 |
|
228 | const EMPTY_OBJ = Object.freeze({})
|
229 | ;
|
230 | const EMPTY_ARR = Object.freeze([]) ;
|
231 | const NOOP = () => { };
|
232 | |
233 |
|
234 |
|
235 | const NO = () => false;
|
236 | const onRE = /^on[^a-z]/;
|
237 | const isOn = (key) => onRE.test(key);
|
238 | const isModelListener = (key) => key.startsWith('onUpdate:');
|
239 | const extend = Object.assign;
|
240 | const remove = (arr, el) => {
|
241 | const i = arr.indexOf(el);
|
242 | if (i > -1) {
|
243 | arr.splice(i, 1);
|
244 | }
|
245 | };
|
246 | const hasOwnProperty = Object.prototype.hasOwnProperty;
|
247 | const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
248 | const isArray = Array.isArray;
|
249 | const isMap = (val) => toTypeString(val) === '[object Map]';
|
250 | const isSet = (val) => toTypeString(val) === '[object Set]';
|
251 | const isDate = (val) => val instanceof Date;
|
252 | const isFunction = (val) => typeof val === 'function';
|
253 | const isString = (val) => typeof val === 'string';
|
254 | const isSymbol = (val) => typeof val === 'symbol';
|
255 | const isObject = (val) => val !== null && typeof val === 'object';
|
256 | const isPromise = (val) => {
|
257 | return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
258 | };
|
259 | const objectToString = Object.prototype.toString;
|
260 | const toTypeString = (value) => objectToString.call(value);
|
261 | const toRawType = (value) => {
|
262 |
|
263 | return toTypeString(value).slice(8, -1);
|
264 | };
|
265 | const isPlainObject = (val) => toTypeString(val) === '[object Object]';
|
266 | const isIntegerKey = (key) => isString(key) &&
|
267 | key !== 'NaN' &&
|
268 | key[0] !== '-' &&
|
269 | '' + parseInt(key, 10) === key;
|
270 | const isReservedProp = makeMap(
|
271 |
|
272 | ',key,ref,' +
|
273 | 'onVnodeBeforeMount,onVnodeMounted,' +
|
274 | 'onVnodeBeforeUpdate,onVnodeUpdated,' +
|
275 | 'onVnodeBeforeUnmount,onVnodeUnmounted');
|
276 | const cacheStringFunction = (fn) => {
|
277 | const cache = Object.create(null);
|
278 | return ((str) => {
|
279 | const hit = cache[str];
|
280 | return hit || (cache[str] = fn(str));
|
281 | });
|
282 | };
|
283 | const camelizeRE = /-(\w)/g;
|
284 | |
285 |
|
286 |
|
287 | const camelize = cacheStringFunction((str) => {
|
288 | return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
|
289 | });
|
290 | const hyphenateRE = /\B([A-Z])/g;
|
291 | |
292 |
|
293 |
|
294 | const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
|
295 | |
296 |
|
297 |
|
298 | const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
|
299 | |
300 |
|
301 |
|
302 | const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
|
303 |
|
304 | const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
305 | const invokeArrayFns = (fns, arg) => {
|
306 | for (let i = 0; i < fns.length; i++) {
|
307 | fns[i](arg);
|
308 | }
|
309 | };
|
310 | const def = (obj, key, value) => {
|
311 | Object.defineProperty(obj, key, {
|
312 | configurable: true,
|
313 | enumerable: false,
|
314 | value
|
315 | });
|
316 | };
|
317 | const toNumber = (val) => {
|
318 | const n = parseFloat(val);
|
319 | return isNaN(n) ? val : n;
|
320 | };
|
321 | let _globalThis;
|
322 | const getGlobalThis = () => {
|
323 | return (_globalThis ||
|
324 | (_globalThis =
|
325 | typeof globalThis !== 'undefined'
|
326 | ? globalThis
|
327 | : typeof self !== 'undefined'
|
328 | ? self
|
329 | : typeof window !== 'undefined'
|
330 | ? window
|
331 | : typeof global !== 'undefined'
|
332 | ? global
|
333 | : {}));
|
334 | };
|
335 |
|
336 | function warn(msg, ...args) {
|
337 | console.warn(`[Vue warn] ${msg}`, ...args);
|
338 | }
|
339 |
|
340 | let activeEffectScope;
|
341 | const effectScopeStack = [];
|
342 | class EffectScope {
|
343 | constructor(detached = false) {
|
344 | this.active = true;
|
345 | this.effects = [];
|
346 | this.cleanups = [];
|
347 | if (!detached && activeEffectScope) {
|
348 | this.parent = activeEffectScope;
|
349 | this.index =
|
350 | (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
351 | }
|
352 | }
|
353 | run(fn) {
|
354 | if (this.active) {
|
355 | try {
|
356 | this.on();
|
357 | return fn();
|
358 | }
|
359 | finally {
|
360 | this.off();
|
361 | }
|
362 | }
|
363 | else {
|
364 | warn(`cannot run an inactive effect scope.`);
|
365 | }
|
366 | }
|
367 | on() {
|
368 | if (this.active) {
|
369 | effectScopeStack.push(this);
|
370 | activeEffectScope = this;
|
371 | }
|
372 | }
|
373 | off() {
|
374 | if (this.active) {
|
375 | effectScopeStack.pop();
|
376 | activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
|
377 | }
|
378 | }
|
379 | stop(fromParent) {
|
380 | if (this.active) {
|
381 | this.effects.forEach(e => e.stop());
|
382 | this.cleanups.forEach(cleanup => cleanup());
|
383 | if (this.scopes) {
|
384 | this.scopes.forEach(e => e.stop(true));
|
385 | }
|
386 |
|
387 | if (this.parent && !fromParent) {
|
388 |
|
389 | const last = this.parent.scopes.pop();
|
390 | if (last && last !== this) {
|
391 | this.parent.scopes[this.index] = last;
|
392 | last.index = this.index;
|
393 | }
|
394 | }
|
395 | this.active = false;
|
396 | }
|
397 | }
|
398 | }
|
399 | function effectScope(detached) {
|
400 | return new EffectScope(detached);
|
401 | }
|
402 | function recordEffectScope(effect, scope) {
|
403 | scope = scope || activeEffectScope;
|
404 | if (scope && scope.active) {
|
405 | scope.effects.push(effect);
|
406 | }
|
407 | }
|
408 | function getCurrentScope() {
|
409 | return activeEffectScope;
|
410 | }
|
411 | function onScopeDispose(fn) {
|
412 | if (activeEffectScope) {
|
413 | activeEffectScope.cleanups.push(fn);
|
414 | }
|
415 | else {
|
416 | warn(`onScopeDispose() is called when there is no active effect scope` +
|
417 | ` to be associated with.`);
|
418 | }
|
419 | }
|
420 |
|
421 | const createDep = (effects) => {
|
422 | const dep = new Set(effects);
|
423 | dep.w = 0;
|
424 | dep.n = 0;
|
425 | return dep;
|
426 | };
|
427 | const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
|
428 | const newTracked = (dep) => (dep.n & trackOpBit) > 0;
|
429 | const initDepMarkers = ({ deps }) => {
|
430 | if (deps.length) {
|
431 | for (let i = 0; i < deps.length; i++) {
|
432 | deps[i].w |= trackOpBit;
|
433 | }
|
434 | }
|
435 | };
|
436 | const finalizeDepMarkers = (effect) => {
|
437 | const { deps } = effect;
|
438 | if (deps.length) {
|
439 | let ptr = 0;
|
440 | for (let i = 0; i < deps.length; i++) {
|
441 | const dep = deps[i];
|
442 | if (wasTracked(dep) && !newTracked(dep)) {
|
443 | dep.delete(effect);
|
444 | }
|
445 | else {
|
446 | deps[ptr++] = dep;
|
447 | }
|
448 |
|
449 | dep.w &= ~trackOpBit;
|
450 | dep.n &= ~trackOpBit;
|
451 | }
|
452 | deps.length = ptr;
|
453 | }
|
454 | };
|
455 |
|
456 | const targetMap = new WeakMap();
|
457 |
|
458 | let effectTrackDepth = 0;
|
459 | let trackOpBit = 1;
|
460 | |
461 |
|
462 |
|
463 |
|
464 |
|
465 | const maxMarkerBits = 30;
|
466 | const effectStack = [];
|
467 | let activeEffect;
|
468 | const ITERATE_KEY = Symbol('iterate' );
|
469 | const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
|
470 | class ReactiveEffect {
|
471 | constructor(fn, scheduler = null, scope) {
|
472 | this.fn = fn;
|
473 | this.scheduler = scheduler;
|
474 | this.active = true;
|
475 | this.deps = [];
|
476 | recordEffectScope(this, scope);
|
477 | }
|
478 | run() {
|
479 | if (!this.active) {
|
480 | return this.fn();
|
481 | }
|
482 | if (!effectStack.includes(this)) {
|
483 | try {
|
484 | effectStack.push((activeEffect = this));
|
485 | enableTracking();
|
486 | trackOpBit = 1 << ++effectTrackDepth;
|
487 | if (effectTrackDepth <= maxMarkerBits) {
|
488 | initDepMarkers(this);
|
489 | }
|
490 | else {
|
491 | cleanupEffect(this);
|
492 | }
|
493 | return this.fn();
|
494 | }
|
495 | finally {
|
496 | if (effectTrackDepth <= maxMarkerBits) {
|
497 | finalizeDepMarkers(this);
|
498 | }
|
499 | trackOpBit = 1 << --effectTrackDepth;
|
500 | resetTracking();
|
501 | effectStack.pop();
|
502 | const n = effectStack.length;
|
503 | activeEffect = n > 0 ? effectStack[n - 1] : undefined;
|
504 | }
|
505 | }
|
506 | }
|
507 | stop() {
|
508 | if (this.active) {
|
509 | cleanupEffect(this);
|
510 | if (this.onStop) {
|
511 | this.onStop();
|
512 | }
|
513 | this.active = false;
|
514 | }
|
515 | }
|
516 | }
|
517 | function cleanupEffect(effect) {
|
518 | const { deps } = effect;
|
519 | if (deps.length) {
|
520 | for (let i = 0; i < deps.length; i++) {
|
521 | deps[i].delete(effect);
|
522 | }
|
523 | deps.length = 0;
|
524 | }
|
525 | }
|
526 | function effect(fn, options) {
|
527 | if (fn.effect) {
|
528 | fn = fn.effect.fn;
|
529 | }
|
530 | const _effect = new ReactiveEffect(fn);
|
531 | if (options) {
|
532 | extend(_effect, options);
|
533 | if (options.scope)
|
534 | recordEffectScope(_effect, options.scope);
|
535 | }
|
536 | if (!options || !options.lazy) {
|
537 | _effect.run();
|
538 | }
|
539 | const runner = _effect.run.bind(_effect);
|
540 | runner.effect = _effect;
|
541 | return runner;
|
542 | }
|
543 | function stop(runner) {
|
544 | runner.effect.stop();
|
545 | }
|
546 | let shouldTrack = true;
|
547 | const trackStack = [];
|
548 | function pauseTracking() {
|
549 | trackStack.push(shouldTrack);
|
550 | shouldTrack = false;
|
551 | }
|
552 | function enableTracking() {
|
553 | trackStack.push(shouldTrack);
|
554 | shouldTrack = true;
|
555 | }
|
556 | function resetTracking() {
|
557 | const last = trackStack.pop();
|
558 | shouldTrack = last === undefined ? true : last;
|
559 | }
|
560 | function track(target, type, key) {
|
561 | if (!isTracking()) {
|
562 | return;
|
563 | }
|
564 | let depsMap = targetMap.get(target);
|
565 | if (!depsMap) {
|
566 | targetMap.set(target, (depsMap = new Map()));
|
567 | }
|
568 | let dep = depsMap.get(key);
|
569 | if (!dep) {
|
570 | depsMap.set(key, (dep = createDep()));
|
571 | }
|
572 | const eventInfo = { effect: activeEffect, target, type, key }
|
573 | ;
|
574 | trackEffects(dep, eventInfo);
|
575 | }
|
576 | function isTracking() {
|
577 | return shouldTrack && activeEffect !== undefined;
|
578 | }
|
579 | function trackEffects(dep, debuggerEventExtraInfo) {
|
580 | let shouldTrack = false;
|
581 | if (effectTrackDepth <= maxMarkerBits) {
|
582 | if (!newTracked(dep)) {
|
583 | dep.n |= trackOpBit;
|
584 | shouldTrack = !wasTracked(dep);
|
585 | }
|
586 | }
|
587 | else {
|
588 |
|
589 | shouldTrack = !dep.has(activeEffect);
|
590 | }
|
591 | if (shouldTrack) {
|
592 | dep.add(activeEffect);
|
593 | activeEffect.deps.push(dep);
|
594 | if (activeEffect.onTrack) {
|
595 | activeEffect.onTrack(Object.assign({
|
596 | effect: activeEffect
|
597 | }, debuggerEventExtraInfo));
|
598 | }
|
599 | }
|
600 | }
|
601 | function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
602 | const depsMap = targetMap.get(target);
|
603 | if (!depsMap) {
|
604 |
|
605 | return;
|
606 | }
|
607 | let deps = [];
|
608 | if (type === "clear" ) {
|
609 |
|
610 |
|
611 | deps = [...depsMap.values()];
|
612 | }
|
613 | else if (key === 'length' && isArray(target)) {
|
614 | depsMap.forEach((dep, key) => {
|
615 | if (key === 'length' || key >= newValue) {
|
616 | deps.push(dep);
|
617 | }
|
618 | });
|
619 | }
|
620 | else {
|
621 |
|
622 | if (key !== void 0) {
|
623 | deps.push(depsMap.get(key));
|
624 | }
|
625 |
|
626 | switch (type) {
|
627 | case "add" :
|
628 | if (!isArray(target)) {
|
629 | deps.push(depsMap.get(ITERATE_KEY));
|
630 | if (isMap(target)) {
|
631 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
632 | }
|
633 | }
|
634 | else if (isIntegerKey(key)) {
|
635 |
|
636 | deps.push(depsMap.get('length'));
|
637 | }
|
638 | break;
|
639 | case "delete" :
|
640 | if (!isArray(target)) {
|
641 | deps.push(depsMap.get(ITERATE_KEY));
|
642 | if (isMap(target)) {
|
643 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
644 | }
|
645 | }
|
646 | break;
|
647 | case "set" :
|
648 | if (isMap(target)) {
|
649 | deps.push(depsMap.get(ITERATE_KEY));
|
650 | }
|
651 | break;
|
652 | }
|
653 | }
|
654 | const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
|
655 | ;
|
656 | if (deps.length === 1) {
|
657 | if (deps[0]) {
|
658 | {
|
659 | triggerEffects(deps[0], eventInfo);
|
660 | }
|
661 | }
|
662 | }
|
663 | else {
|
664 | const effects = [];
|
665 | for (const dep of deps) {
|
666 | if (dep) {
|
667 | effects.push(...dep);
|
668 | }
|
669 | }
|
670 | {
|
671 | triggerEffects(createDep(effects), eventInfo);
|
672 | }
|
673 | }
|
674 | }
|
675 | function triggerEffects(dep, debuggerEventExtraInfo) {
|
676 |
|
677 | for (const effect of isArray(dep) ? dep : [...dep]) {
|
678 | if (effect !== activeEffect || effect.allowRecurse) {
|
679 | if (effect.onTrigger) {
|
680 | effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
|
681 | }
|
682 | if (effect.scheduler) {
|
683 | effect.scheduler();
|
684 | }
|
685 | else {
|
686 | effect.run();
|
687 | }
|
688 | }
|
689 | }
|
690 | }
|
691 |
|
692 | const isNonTrackableKeys = makeMap(`__proto__,__v_isRef,__isVue`);
|
693 | const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
|
694 | .map(key => Symbol[key])
|
695 | .filter(isSymbol));
|
696 | const get = /*#__PURE__*/ createGetter();
|
697 | const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
698 | const readonlyGet = /*#__PURE__*/ createGetter(true);
|
699 | const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
700 | const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
|
701 | function createArrayInstrumentations() {
|
702 | const instrumentations = {};
|
703 | ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
|
704 | instrumentations[key] = function (...args) {
|
705 | const arr = toRaw(this);
|
706 | for (let i = 0, l = this.length; i < l; i++) {
|
707 | track(arr, "get" , i + '');
|
708 | }
|
709 |
|
710 | const res = arr[key](...args);
|
711 | if (res === -1 || res === false) {
|
712 |
|
713 | return arr[key](...args.map(toRaw));
|
714 | }
|
715 | else {
|
716 | return res;
|
717 | }
|
718 | };
|
719 | });
|
720 | ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
|
721 | instrumentations[key] = function (...args) {
|
722 | pauseTracking();
|
723 | const res = toRaw(this)[key].apply(this, args);
|
724 | resetTracking();
|
725 | return res;
|
726 | };
|
727 | });
|
728 | return instrumentations;
|
729 | }
|
730 | function createGetter(isReadonly = false, shallow = false) {
|
731 | return function get(target, key, receiver) {
|
732 | if (key === "__v_isReactive" ) {
|
733 | return !isReadonly;
|
734 | }
|
735 | else if (key === "__v_isReadonly" ) {
|
736 | return isReadonly;
|
737 | }
|
738 | else if (key === "__v_raw" &&
|
739 | receiver ===
|
740 | (isReadonly
|
741 | ? shallow
|
742 | ? shallowReadonlyMap
|
743 | : readonlyMap
|
744 | : shallow
|
745 | ? shallowReactiveMap
|
746 | : reactiveMap).get(target)) {
|
747 | return target;
|
748 | }
|
749 | const targetIsArray = isArray(target);
|
750 | if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
751 | return Reflect.get(arrayInstrumentations, key, receiver);
|
752 | }
|
753 | const res = Reflect.get(target, key, receiver);
|
754 | if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
755 | return res;
|
756 | }
|
757 | if (!isReadonly) {
|
758 | track(target, "get" , key);
|
759 | }
|
760 | if (shallow) {
|
761 | return res;
|
762 | }
|
763 | if (isRef(res)) {
|
764 |
|
765 | const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
|
766 | return shouldUnwrap ? res.value : res;
|
767 | }
|
768 | if (isObject(res)) {
|
769 |
|
770 |
|
771 |
|
772 | return isReadonly ? readonly(res) : reactive(res);
|
773 | }
|
774 | return res;
|
775 | };
|
776 | }
|
777 | const set = /*#__PURE__*/ createSetter();
|
778 | const shallowSet = /*#__PURE__*/ createSetter(true);
|
779 | function createSetter(shallow = false) {
|
780 | return function set(target, key, value, receiver) {
|
781 | let oldValue = target[key];
|
782 | if (!shallow) {
|
783 | value = toRaw(value);
|
784 | oldValue = toRaw(oldValue);
|
785 | if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
786 | oldValue.value = value;
|
787 | return true;
|
788 | }
|
789 | }
|
790 | const hadKey = isArray(target) && isIntegerKey(key)
|
791 | ? Number(key) < target.length
|
792 | : hasOwn(target, key);
|
793 | const result = Reflect.set(target, key, value, receiver);
|
794 |
|
795 | if (target === toRaw(receiver)) {
|
796 | if (!hadKey) {
|
797 | trigger(target, "add" , key, value);
|
798 | }
|
799 | else if (hasChanged(value, oldValue)) {
|
800 | trigger(target, "set" , key, value, oldValue);
|
801 | }
|
802 | }
|
803 | return result;
|
804 | };
|
805 | }
|
806 | function deleteProperty(target, key) {
|
807 | const hadKey = hasOwn(target, key);
|
808 | const oldValue = target[key];
|
809 | const result = Reflect.deleteProperty(target, key);
|
810 | if (result && hadKey) {
|
811 | trigger(target, "delete" , key, undefined, oldValue);
|
812 | }
|
813 | return result;
|
814 | }
|
815 | function has(target, key) {
|
816 | const result = Reflect.has(target, key);
|
817 | if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
818 | track(target, "has" , key);
|
819 | }
|
820 | return result;
|
821 | }
|
822 | function ownKeys(target) {
|
823 | track(target, "iterate" , isArray(target) ? 'length' : ITERATE_KEY);
|
824 | return Reflect.ownKeys(target);
|
825 | }
|
826 | const mutableHandlers = {
|
827 | get,
|
828 | set,
|
829 | deleteProperty,
|
830 | has,
|
831 | ownKeys
|
832 | };
|
833 | const readonlyHandlers = {
|
834 | get: readonlyGet,
|
835 | set(target, key) {
|
836 | {
|
837 | console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
|
838 | }
|
839 | return true;
|
840 | },
|
841 | deleteProperty(target, key) {
|
842 | {
|
843 | console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
|
844 | }
|
845 | return true;
|
846 | }
|
847 | };
|
848 | const shallowReactiveHandlers = extend({}, mutableHandlers, {
|
849 | get: shallowGet,
|
850 | set: shallowSet
|
851 | });
|
852 | // Props handlers are special in the sense that it should not unwrap top-level
|
853 | // refs (in order to allow refs to be explicitly passed down), but should
|
854 | // retain the reactivity of the normal readonly object.
|
855 | const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
|
856 | get: shallowReadonlyGet
|
857 | });
|
858 |
|
859 | const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
860 | const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
861 | const toShallow = (value) => value;
|
862 | const getProto = (v) => Reflect.getPrototypeOf(v);
|
863 | function get$1(target, key, isReadonly = false, isShallow = false) {
|
864 |
|
865 |
|
866 | target = target["__v_raw" ];
|
867 | const rawTarget = toRaw(target);
|
868 | const rawKey = toRaw(key);
|
869 | if (key !== rawKey) {
|
870 | !isReadonly && track(rawTarget, "get" , key);
|
871 | }
|
872 | !isReadonly && track(rawTarget, "get" , rawKey);
|
873 | const { has } = getProto(rawTarget);
|
874 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
875 | if (has.call(rawTarget, key)) {
|
876 | return wrap(target.get(key));
|
877 | }
|
878 | else if (has.call(rawTarget, rawKey)) {
|
879 | return wrap(target.get(rawKey));
|
880 | }
|
881 | else if (target !== rawTarget) {
|
882 |
|
883 |
|
884 | target.get(key);
|
885 | }
|
886 | }
|
887 | function has$1(key, isReadonly = false) {
|
888 | const target = this["__v_raw" ];
|
889 | const rawTarget = toRaw(target);
|
890 | const rawKey = toRaw(key);
|
891 | if (key !== rawKey) {
|
892 | !isReadonly && track(rawTarget, "has" , key);
|
893 | }
|
894 | !isReadonly && track(rawTarget, "has" , rawKey);
|
895 | return key === rawKey
|
896 | ? target.has(key)
|
897 | : target.has(key) || target.has(rawKey);
|
898 | }
|
899 | function size(target, isReadonly = false) {
|
900 | target = target["__v_raw" ];
|
901 | !isReadonly && track(toRaw(target), "iterate" , ITERATE_KEY);
|
902 | return Reflect.get(target, 'size', target);
|
903 | }
|
904 | function add(value) {
|
905 | value = toRaw(value);
|
906 | const target = toRaw(this);
|
907 | const proto = getProto(target);
|
908 | const hadKey = proto.has.call(target, value);
|
909 | if (!hadKey) {
|
910 | target.add(value);
|
911 | trigger(target, "add" , value, value);
|
912 | }
|
913 | return this;
|
914 | }
|
915 | function set$1(key, value) {
|
916 | value = toRaw(value);
|
917 | const target = toRaw(this);
|
918 | const { has, get } = getProto(target);
|
919 | let hadKey = has.call(target, key);
|
920 | if (!hadKey) {
|
921 | key = toRaw(key);
|
922 | hadKey = has.call(target, key);
|
923 | }
|
924 | else {
|
925 | checkIdentityKeys(target, has, key);
|
926 | }
|
927 | const oldValue = get.call(target, key);
|
928 | target.set(key, value);
|
929 | if (!hadKey) {
|
930 | trigger(target, "add" , key, value);
|
931 | }
|
932 | else if (hasChanged(value, oldValue)) {
|
933 | trigger(target, "set" , key, value, oldValue);
|
934 | }
|
935 | return this;
|
936 | }
|
937 | function deleteEntry(key) {
|
938 | const target = toRaw(this);
|
939 | const { has, get } = getProto(target);
|
940 | let hadKey = has.call(target, key);
|
941 | if (!hadKey) {
|
942 | key = toRaw(key);
|
943 | hadKey = has.call(target, key);
|
944 | }
|
945 | else {
|
946 | checkIdentityKeys(target, has, key);
|
947 | }
|
948 | const oldValue = get ? get.call(target, key) : undefined;
|
949 | // forward the operation before queueing reactions
|
950 | const result = target.delete(key);
|
951 | if (hadKey) {
|
952 | trigger(target, "delete" , key, undefined, oldValue);
|
953 | }
|
954 | return result;
|
955 | }
|
956 | function clear() {
|
957 | const target = toRaw(this);
|
958 | const hadItems = target.size !== 0;
|
959 | const oldTarget = isMap(target)
|
960 | ? new Map(target)
|
961 | : new Set(target)
|
962 | ;
|
963 |
|
964 | const result = target.clear();
|
965 | if (hadItems) {
|
966 | trigger(target, "clear" , undefined, undefined, oldTarget);
|
967 | }
|
968 | return result;
|
969 | }
|
970 | function createForEach(isReadonly, isShallow) {
|
971 | return function forEach(callback, thisArg) {
|
972 | const observed = this;
|
973 | const target = observed["__v_raw" ];
|
974 | const rawTarget = toRaw(target);
|
975 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
976 | !isReadonly && track(rawTarget, "iterate" , ITERATE_KEY);
|
977 | return target.forEach((value, key) => {
|
978 |
|
979 |
|
980 |
|
981 | return callback.call(thisArg, wrap(value), wrap(key), observed);
|
982 | });
|
983 | };
|
984 | }
|
985 | function createIterableMethod(method, isReadonly, isShallow) {
|
986 | return function (...args) {
|
987 | const target = this["__v_raw" ];
|
988 | const rawTarget = toRaw(target);
|
989 | const targetIsMap = isMap(rawTarget);
|
990 | const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
|
991 | const isKeyOnly = method === 'keys' && targetIsMap;
|
992 | const innerIterator = target[method](...args);
|
993 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
994 | !isReadonly &&
|
995 | track(rawTarget, "iterate" , isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
|
996 |
|
997 |
|
998 | return {
|
999 |
|
1000 | next() {
|
1001 | const { value, done } = innerIterator.next();
|
1002 | return done
|
1003 | ? { value, done }
|
1004 | : {
|
1005 | value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
1006 | done
|
1007 | };
|
1008 | },
|
1009 |
|
1010 | [Symbol.iterator]() {
|
1011 | return this;
|
1012 | }
|
1013 | };
|
1014 | };
|
1015 | }
|
1016 | function createReadonlyMethod(type) {
|
1017 | return function (...args) {
|
1018 | {
|
1019 | const key = args[0] ? `on key "${args[0]}" ` : ``;
|
1020 | console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
|
1021 | }
|
1022 | return type === "delete" ? false : this;
|
1023 | };
|
1024 | }
|
1025 | function createInstrumentations() {
|
1026 | const mutableInstrumentations = {
|
1027 | get(key) {
|
1028 | return get$1(this, key);
|
1029 | },
|
1030 | get size() {
|
1031 | return size(this);
|
1032 | },
|
1033 | has: has$1,
|
1034 | add,
|
1035 | set: set$1,
|
1036 | delete: deleteEntry,
|
1037 | clear,
|
1038 | forEach: createForEach(false, false)
|
1039 | };
|
1040 | const shallowInstrumentations = {
|
1041 | get(key) {
|
1042 | return get$1(this, key, false, true);
|
1043 | },
|
1044 | get size() {
|
1045 | return size(this);
|
1046 | },
|
1047 | has: has$1,
|
1048 | add,
|
1049 | set: set$1,
|
1050 | delete: deleteEntry,
|
1051 | clear,
|
1052 | forEach: createForEach(false, true)
|
1053 | };
|
1054 | const readonlyInstrumentations = {
|
1055 | get(key) {
|
1056 | return get$1(this, key, true);
|
1057 | },
|
1058 | get size() {
|
1059 | return size(this, true);
|
1060 | },
|
1061 | has(key) {
|
1062 | return has$1.call(this, key, true);
|
1063 | },
|
1064 | add: createReadonlyMethod("add" ),
|
1065 | set: createReadonlyMethod("set" /* SET */),
|
1066 | delete: createReadonlyMethod("delete" /* DELETE */),
|
1067 | clear: createReadonlyMethod("clear" /* CLEAR */),
|
1068 | forEach: createForEach(true, false)
|
1069 | };
|
1070 | const shallowReadonlyInstrumentations = {
|
1071 | get(key) {
|
1072 | return get$1(this, key, true, true);
|
1073 | },
|
1074 | get size() {
|
1075 | return size(this, true);
|
1076 | },
|
1077 | has(key) {
|
1078 | return has$1.call(this, key, true);
|
1079 | },
|
1080 | add: createReadonlyMethod("add" ),
|
1081 | set: createReadonlyMethod("set" /* SET */),
|
1082 | delete: createReadonlyMethod("delete" /* DELETE */),
|
1083 | clear: createReadonlyMethod("clear" /* CLEAR */),
|
1084 | forEach: createForEach(true, true)
|
1085 | };
|
1086 | const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
|
1087 | iteratorMethods.forEach(method => {
|
1088 | mutableInstrumentations[method] = createIterableMethod(method, false, false);
|
1089 | readonlyInstrumentations[method] = createIterableMethod(method, true, false);
|
1090 | shallowInstrumentations[method] = createIterableMethod(method, false, true);
|
1091 | shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
|
1092 | });
|
1093 | return [
|
1094 | mutableInstrumentations,
|
1095 | readonlyInstrumentations,
|
1096 | shallowInstrumentations,
|
1097 | shallowReadonlyInstrumentations
|
1098 | ];
|
1099 | }
|
1100 | const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = createInstrumentations();
|
1101 | function createInstrumentationGetter(isReadonly, shallow) {
|
1102 | const instrumentations = shallow
|
1103 | ? isReadonly
|
1104 | ? shallowReadonlyInstrumentations
|
1105 | : shallowInstrumentations
|
1106 | : isReadonly
|
1107 | ? readonlyInstrumentations
|
1108 | : mutableInstrumentations;
|
1109 | return (target, key, receiver) => {
|
1110 | if (key === "__v_isReactive" ) {
|
1111 | return !isReadonly;
|
1112 | }
|
1113 | else if (key === "__v_isReadonly" ) {
|
1114 | return isReadonly;
|
1115 | }
|
1116 | else if (key === "__v_raw" ) {
|
1117 | return target;
|
1118 | }
|
1119 | return Reflect.get(hasOwn(instrumentations, key) && key in target
|
1120 | ? instrumentations
|
1121 | : target, key, receiver);
|
1122 | };
|
1123 | }
|
1124 | const mutableCollectionHandlers = {
|
1125 | get: /*#__PURE__*/ createInstrumentationGetter(false, false)
|
1126 | };
|
1127 | const shallowCollectionHandlers = {
|
1128 | get: /*#__PURE__*/ createInstrumentationGetter(false, true)
|
1129 | };
|
1130 | const readonlyCollectionHandlers = {
|
1131 | get: /*#__PURE__*/ createInstrumentationGetter(true, false)
|
1132 | };
|
1133 | const shallowReadonlyCollectionHandlers = {
|
1134 | get: /*#__PURE__*/ createInstrumentationGetter(true, true)
|
1135 | };
|
1136 | function checkIdentityKeys(target, has, key) {
|
1137 | const rawKey = toRaw(key);
|
1138 | if (rawKey !== key && has.call(target, rawKey)) {
|
1139 | const type = toRawType(target);
|
1140 | console.warn(`Reactive ${type} contains both the raw and reactive ` +
|
1141 | `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
|
1142 | `which can lead to inconsistencies. ` +
|
1143 | `Avoid differentiating between the raw and reactive versions ` +
|
1144 | `of an object and only use the reactive version if possible.`);
|
1145 | }
|
1146 | }
|
1147 |
|
1148 | const reactiveMap = new WeakMap();
|
1149 | const shallowReactiveMap = new WeakMap();
|
1150 | const readonlyMap = new WeakMap();
|
1151 | const shallowReadonlyMap = new WeakMap();
|
1152 | function targetTypeMap(rawType) {
|
1153 | switch (rawType) {
|
1154 | case 'Object':
|
1155 | case 'Array':
|
1156 | return 1 ;
|
1157 | case 'Map':
|
1158 | case 'Set':
|
1159 | case 'WeakMap':
|
1160 | case 'WeakSet':
|
1161 | return 2 ;
|
1162 | default:
|
1163 | return 0 ;
|
1164 | }
|
1165 | }
|
1166 | function getTargetType(value) {
|
1167 | return value["__v_skip" ] || !Object.isExtensible(value)
|
1168 | ? 0
|
1169 | : targetTypeMap(toRawType(value));
|
1170 | }
|
1171 | function reactive(target) {
|
1172 |
|
1173 | if (target && target["__v_isReadonly" ]) {
|
1174 | return target;
|
1175 | }
|
1176 | return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
1177 | }
|
1178 | |
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 | function shallowReactive(target) {
|
1184 | return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
|
1185 | }
|
1186 | |
1187 |
|
1188 |
|
1189 |
|
1190 | function readonly(target) {
|
1191 | return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
1192 | }
|
1193 | |
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 | function shallowReadonly(target) {
|
1200 | return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
1201 | }
|
1202 | function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
|
1203 | if (!isObject(target)) {
|
1204 | {
|
1205 | console.warn(`value cannot be made reactive: ${String(target)}`);
|
1206 | }
|
1207 | return target;
|
1208 | }
|
1209 |
|
1210 |
|
1211 | if (target["__v_raw" ] &&
|
1212 | !(isReadonly && target["__v_isReactive" ])) {
|
1213 | return target;
|
1214 | }
|
1215 |
|
1216 | const existingProxy = proxyMap.get(target);
|
1217 | if (existingProxy) {
|
1218 | return existingProxy;
|
1219 | }
|
1220 |
|
1221 | const targetType = getTargetType(target);
|
1222 | if (targetType === 0 ) {
|
1223 | return target;
|
1224 | }
|
1225 | const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
1226 | proxyMap.set(target, proxy);
|
1227 | return proxy;
|
1228 | }
|
1229 | function isReactive(value) {
|
1230 | if (isReadonly(value)) {
|
1231 | return isReactive(value["__v_raw" ]);
|
1232 | }
|
1233 | return !!(value && value["__v_isReactive" ]);
|
1234 | }
|
1235 | function isReadonly(value) {
|
1236 | return !!(value && value["__v_isReadonly" ]);
|
1237 | }
|
1238 | function isProxy(value) {
|
1239 | return isReactive(value) || isReadonly(value);
|
1240 | }
|
1241 | function toRaw(observed) {
|
1242 | const raw = observed && observed["__v_raw" ];
|
1243 | return raw ? toRaw(raw) : observed;
|
1244 | }
|
1245 | function markRaw(value) {
|
1246 | def(value, "__v_skip" , true);
|
1247 | return value;
|
1248 | }
|
1249 |
|
1250 | function trackRefValue(ref) {
|
1251 | if (isTracking()) {
|
1252 | ref = toRaw(ref);
|
1253 | if (!ref.dep) {
|
1254 | ref.dep = createDep();
|
1255 | }
|
1256 | {
|
1257 | trackEffects(ref.dep, {
|
1258 | target: ref,
|
1259 | type: "get" ,
|
1260 | key: 'value'
|
1261 | });
|
1262 | }
|
1263 | }
|
1264 | }
|
1265 | function triggerRefValue(ref, newVal) {
|
1266 | ref = toRaw(ref);
|
1267 | if (ref.dep) {
|
1268 | {
|
1269 | triggerEffects(ref.dep, {
|
1270 | target: ref,
|
1271 | type: "set" ,
|
1272 | key: 'value',
|
1273 | newValue: newVal
|
1274 | });
|
1275 | }
|
1276 | }
|
1277 | }
|
1278 | const convert = (val) => isObject(val) ? reactive(val) : val;
|
1279 | function isRef(r) {
|
1280 | return Boolean(r && r.__v_isRef === true);
|
1281 | }
|
1282 | function ref(value) {
|
1283 | return createRef(value, false);
|
1284 | }
|
1285 | function shallowRef(value) {
|
1286 | return createRef(value, true);
|
1287 | }
|
1288 | class RefImpl {
|
1289 | constructor(value, _shallow) {
|
1290 | this._shallow = _shallow;
|
1291 | this.dep = undefined;
|
1292 | this.__v_isRef = true;
|
1293 | this._rawValue = _shallow ? value : toRaw(value);
|
1294 | this._value = _shallow ? value : convert(value);
|
1295 | }
|
1296 | get value() {
|
1297 | trackRefValue(this);
|
1298 | return this._value;
|
1299 | }
|
1300 | set value(newVal) {
|
1301 | newVal = this._shallow ? newVal : toRaw(newVal);
|
1302 | if (hasChanged(newVal, this._rawValue)) {
|
1303 | this._rawValue = newVal;
|
1304 | this._value = this._shallow ? newVal : convert(newVal);
|
1305 | triggerRefValue(this, newVal);
|
1306 | }
|
1307 | }
|
1308 | }
|
1309 | function createRef(rawValue, shallow) {
|
1310 | if (isRef(rawValue)) {
|
1311 | return rawValue;
|
1312 | }
|
1313 | return new RefImpl(rawValue, shallow);
|
1314 | }
|
1315 | function triggerRef(ref) {
|
1316 | triggerRefValue(ref, ref.value );
|
1317 | }
|
1318 | function unref(ref) {
|
1319 | return isRef(ref) ? ref.value : ref;
|
1320 | }
|
1321 | const shallowUnwrapHandlers = {
|
1322 | get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
1323 | set: (target, key, value, receiver) => {
|
1324 | const oldValue = target[key];
|
1325 | if (isRef(oldValue) && !isRef(value)) {
|
1326 | oldValue.value = value;
|
1327 | return true;
|
1328 | }
|
1329 | else {
|
1330 | return Reflect.set(target, key, value, receiver);
|
1331 | }
|
1332 | }
|
1333 | };
|
1334 | function proxyRefs(objectWithRefs) {
|
1335 | return isReactive(objectWithRefs)
|
1336 | ? objectWithRefs
|
1337 | : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
1338 | }
|
1339 | class CustomRefImpl {
|
1340 | constructor(factory) {
|
1341 | this.dep = undefined;
|
1342 | this.__v_isRef = true;
|
1343 | const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
|
1344 | this._get = get;
|
1345 | this._set = set;
|
1346 | }
|
1347 | get value() {
|
1348 | return this._get();
|
1349 | }
|
1350 | set value(newVal) {
|
1351 | this._set(newVal);
|
1352 | }
|
1353 | }
|
1354 | function customRef(factory) {
|
1355 | return new CustomRefImpl(factory);
|
1356 | }
|
1357 | function toRefs(object) {
|
1358 | if (!isProxy(object)) {
|
1359 | console.warn(`toRefs() expects a reactive object but received a plain one.`);
|
1360 | }
|
1361 | const ret = isArray(object) ? new Array(object.length) : {};
|
1362 | for (const key in object) {
|
1363 | ret[key] = toRef(object, key);
|
1364 | }
|
1365 | return ret;
|
1366 | }
|
1367 | class ObjectRefImpl {
|
1368 | constructor(_object, _key) {
|
1369 | this._object = _object;
|
1370 | this._key = _key;
|
1371 | this.__v_isRef = true;
|
1372 | }
|
1373 | get value() {
|
1374 | return this._object[this._key];
|
1375 | }
|
1376 | set value(newVal) {
|
1377 | this._object[this._key] = newVal;
|
1378 | }
|
1379 | }
|
1380 | function toRef(object, key) {
|
1381 | const val = object[key];
|
1382 | return isRef(val) ? val : new ObjectRefImpl(object, key);
|
1383 | }
|
1384 |
|
1385 | class ComputedRefImpl {
|
1386 | constructor(getter, _setter, isReadonly) {
|
1387 | this._setter = _setter;
|
1388 | this.dep = undefined;
|
1389 | this._dirty = true;
|
1390 | this.__v_isRef = true;
|
1391 | this.effect = new ReactiveEffect(getter, () => {
|
1392 | if (!this._dirty) {
|
1393 | this._dirty = true;
|
1394 | triggerRefValue(this);
|
1395 | }
|
1396 | });
|
1397 | this["__v_isReadonly" ] = isReadonly;
|
1398 | }
|
1399 | get value() {
|
1400 |
|
1401 | const self = toRaw(this);
|
1402 | trackRefValue(self);
|
1403 | if (self._dirty) {
|
1404 | self._dirty = false;
|
1405 | self._value = self.effect.run();
|
1406 | }
|
1407 | return self._value;
|
1408 | }
|
1409 | set value(newValue) {
|
1410 | this._setter(newValue);
|
1411 | }
|
1412 | }
|
1413 | function computed(getterOrOptions, debugOptions) {
|
1414 | let getter;
|
1415 | let setter;
|
1416 | if (isFunction(getterOrOptions)) {
|
1417 | getter = getterOrOptions;
|
1418 | setter = () => {
|
1419 | console.warn('Write operation failed: computed value is readonly');
|
1420 | }
|
1421 | ;
|
1422 | }
|
1423 | else {
|
1424 | getter = getterOrOptions.get;
|
1425 | setter = getterOrOptions.set;
|
1426 | }
|
1427 | const cRef = new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
|
1428 | if (debugOptions) {
|
1429 | cRef.effect.onTrack = debugOptions.onTrack;
|
1430 | cRef.effect.onTrigger = debugOptions.onTrigger;
|
1431 | }
|
1432 | return cRef;
|
1433 | }
|
1434 |
|
1435 |
|
1436 | let isHmrUpdating = false;
|
1437 | const hmrDirtyComponents = new Set();
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 | {
|
1444 | const globalObject = typeof global !== 'undefined'
|
1445 | ? global
|
1446 | : typeof self !== 'undefined'
|
1447 | ? self
|
1448 | : typeof window !== 'undefined'
|
1449 | ? window
|
1450 | : {};
|
1451 | globalObject.__VUE_HMR_RUNTIME__ = {
|
1452 | createRecord: tryWrap(createRecord),
|
1453 | rerender: tryWrap(rerender),
|
1454 | reload: tryWrap(reload)
|
1455 | };
|
1456 | }
|
1457 | const map = new Map();
|
1458 | function registerHMR(instance) {
|
1459 | const id = instance.type.__hmrId;
|
1460 | let record = map.get(id);
|
1461 | if (!record) {
|
1462 | createRecord(id, instance.type);
|
1463 | record = map.get(id);
|
1464 | }
|
1465 | record.instances.add(instance);
|
1466 | }
|
1467 | function unregisterHMR(instance) {
|
1468 | map.get(instance.type.__hmrId).instances.delete(instance);
|
1469 | }
|
1470 | function createRecord(id, component) {
|
1471 | if (!component) {
|
1472 | warn$1(`HMR API usage is out of date.\n` +
|
1473 | `Please upgrade vue-loader/vite/rollup-plugin-vue or other relevant ` +
|
1474 | `dependency that handles Vue SFC compilation.`);
|
1475 | component = {};
|
1476 | }
|
1477 | if (map.has(id)) {
|
1478 | return false;
|
1479 | }
|
1480 | map.set(id, {
|
1481 | component: isClassComponent(component) ? component.__vccOpts : component,
|
1482 | instances: new Set()
|
1483 | });
|
1484 | return true;
|
1485 | }
|
1486 | function rerender(id, newRender) {
|
1487 | const record = map.get(id);
|
1488 | if (!record)
|
1489 | return;
|
1490 | if (newRender)
|
1491 | record.component.render = newRender;
|
1492 |
|
1493 |
|
1494 | Array.from(record.instances).forEach(instance => {
|
1495 | if (newRender) {
|
1496 | instance.render = newRender;
|
1497 | }
|
1498 | instance.renderCache = [];
|
1499 |
|
1500 | isHmrUpdating = true;
|
1501 | instance.update();
|
1502 | isHmrUpdating = false;
|
1503 | });
|
1504 | }
|
1505 | function reload(id, newComp) {
|
1506 | const record = map.get(id);
|
1507 | if (!record)
|
1508 | return;
|
1509 |
|
1510 |
|
1511 | const { component, instances } = record;
|
1512 | if (!hmrDirtyComponents.has(component)) {
|
1513 |
|
1514 | newComp = isClassComponent(newComp) ? newComp.__vccOpts : newComp;
|
1515 | extend(component, newComp);
|
1516 | for (const key in component) {
|
1517 | if (key !== '__file' && !(key in newComp)) {
|
1518 | delete component[key];
|
1519 | }
|
1520 | }
|
1521 |
|
1522 |
|
1523 | hmrDirtyComponents.add(component);
|
1524 |
|
1525 | queuePostFlushCb(() => {
|
1526 | hmrDirtyComponents.delete(component);
|
1527 | });
|
1528 | }
|
1529 | Array.from(instances).forEach(instance => {
|
1530 |
|
1531 | instance.appContext.optionsCache.delete(instance.type);
|
1532 | if (instance.ceReload) {
|
1533 |
|
1534 | hmrDirtyComponents.add(component);
|
1535 | instance.ceReload(newComp.styles);
|
1536 | hmrDirtyComponents.delete(component);
|
1537 | }
|
1538 | else if (instance.parent) {
|
1539 |
|
1540 |
|
1541 |
|
1542 | queueJob(instance.parent.update);
|
1543 |
|
1544 |
|
1545 | if (instance.parent.type.__asyncLoader &&
|
1546 | instance.parent.ceReload) {
|
1547 | instance.parent.ceReload(newComp.styles);
|
1548 | }
|
1549 | }
|
1550 | else if (instance.appContext.reload) {
|
1551 |
|
1552 | instance.appContext.reload();
|
1553 | }
|
1554 | else if (typeof window !== 'undefined') {
|
1555 |
|
1556 | window.location.reload();
|
1557 | }
|
1558 | else {
|
1559 | console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
|
1560 | }
|
1561 | });
|
1562 | }
|
1563 | function tryWrap(fn) {
|
1564 | return (id, arg) => {
|
1565 | try {
|
1566 | return fn(id, arg);
|
1567 | }
|
1568 | catch (e) {
|
1569 | console.error(e);
|
1570 | console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
|
1571 | `Full reload required.`);
|
1572 | }
|
1573 | };
|
1574 | }
|
1575 |
|
1576 | function setDevtoolsHook(hook) {
|
1577 | exports.devtools = hook;
|
1578 | }
|
1579 | function devtoolsInitApp(app, version) {
|
1580 |
|
1581 | if (!exports.devtools)
|
1582 | return;
|
1583 | exports.devtools.emit("app:init" , app, version, {
|
1584 | Fragment,
|
1585 | Text,
|
1586 | Comment,
|
1587 | Static
|
1588 | });
|
1589 | }
|
1590 | function devtoolsUnmountApp(app) {
|
1591 | if (!exports.devtools)
|
1592 | return;
|
1593 | exports.devtools.emit("app:unmount" , app);
|
1594 | }
|
1595 | const devtoolsComponentAdded = createDevtoolsComponentHook("component:added" );
|
1596 | const devtoolsComponentUpdated =
|
1597 | createDevtoolsComponentHook("component:updated" );
|
1598 | const devtoolsComponentRemoved =
|
1599 | createDevtoolsComponentHook("component:removed" );
|
1600 | function createDevtoolsComponentHook(hook) {
|
1601 | return (component) => {
|
1602 | if (!exports.devtools)
|
1603 | return;
|
1604 | exports.devtools.emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
|
1605 | };
|
1606 | }
|
1607 | const devtoolsPerfStart = createDevtoolsPerformanceHook("perf:start" );
|
1608 | const devtoolsPerfEnd = createDevtoolsPerformanceHook("perf:end" );
|
1609 | function createDevtoolsPerformanceHook(hook) {
|
1610 | return (component, type, time) => {
|
1611 | if (!exports.devtools)
|
1612 | return;
|
1613 | exports.devtools.emit(hook, component.appContext.app, component.uid, component, type, time);
|
1614 | };
|
1615 | }
|
1616 | function devtoolsComponentEmit(component, event, params) {
|
1617 | if (!exports.devtools)
|
1618 | return;
|
1619 | exports.devtools.emit("component:emit" , component.appContext.app, component, event, params);
|
1620 | }
|
1621 |
|
1622 | const deprecationData = {
|
1623 | ["GLOBAL_MOUNT" ]: {
|
1624 | message: `The global app bootstrapping API has changed: vm.$mount() and the "el" ` +
|
1625 | `option have been removed. Use createApp(RootComponent).mount() instead.`,
|
1626 | link: `https://v3.vuejs.org/guide/migration/global-api.html#mounting-app-instance`
|
1627 | },
|
1628 | ["GLOBAL_MOUNT_CONTAINER" ]: {
|
1629 | message: `Vue detected directives on the mount container. ` +
|
1630 | `In Vue 3, the container is no longer considered part of the template ` +
|
1631 | `and will not be processed/replaced.`,
|
1632 | link: `https://v3.vuejs.org/guide/migration/mount-changes.html`
|
1633 | },
|
1634 | ["GLOBAL_EXTEND" ]: {
|
1635 | message: `Vue.extend() has been removed in Vue 3. ` +
|
1636 | `Use defineComponent() instead.`,
|
1637 | link: `https://v3.vuejs.org/api/global-api.html#definecomponent`
|
1638 | },
|
1639 | ["GLOBAL_PROTOTYPE" ]: {
|
1640 | message: `Vue.prototype is no longer available in Vue 3. ` +
|
1641 | `Use app.config.globalProperties instead.`,
|
1642 | link: `https://v3.vuejs.org/guide/migration/global-api.html#vue-prototype-replaced-by-config-globalproperties`
|
1643 | },
|
1644 | ["GLOBAL_SET" ]: {
|
1645 | message: `Vue.set() has been removed as it is no longer needed in Vue 3. ` +
|
1646 | `Simply use native JavaScript mutations.`
|
1647 | },
|
1648 | ["GLOBAL_DELETE" ]: {
|
1649 | message: `Vue.delete() has been removed as it is no longer needed in Vue 3. ` +
|
1650 | `Simply use native JavaScript mutations.`
|
1651 | },
|
1652 | ["GLOBAL_OBSERVABLE" ]: {
|
1653 | message: `Vue.observable() has been removed. ` +
|
1654 | `Use \`import { reactive } from "vue"\` from Composition API instead.`,
|
1655 | link: `https://v3.vuejs.org/api/basic-reactivity.html`
|
1656 | },
|
1657 | ["GLOBAL_PRIVATE_UTIL" ]: {
|
1658 | message: `Vue.util has been removed. Please refactor to avoid its usage ` +
|
1659 | `since it was an internal API even in Vue 2.`
|
1660 | },
|
1661 | ["CONFIG_SILENT" ]: {
|
1662 | message: `config.silent has been removed because it is not good practice to ` +
|
1663 | `intentionally suppress warnings. You can use your browser console's ` +
|
1664 | `filter features to focus on relevant messages.`
|
1665 | },
|
1666 | ["CONFIG_DEVTOOLS" ]: {
|
1667 | message: `config.devtools has been removed. To enable devtools for ` +
|
1668 | `production, configure the __VUE_PROD_DEVTOOLS__ compile-time flag.`,
|
1669 | link: `https://github.com/vuejs/vue-next/tree/master/packages/vue#bundler-build-feature-flags`
|
1670 | },
|
1671 | ["CONFIG_KEY_CODES" ]: {
|
1672 | message: `config.keyCodes has been removed. ` +
|
1673 | `In Vue 3, you can directly use the kebab-case key names as v-on modifiers.`,
|
1674 | link: `https://v3.vuejs.org/guide/migration/keycode-modifiers.html`
|
1675 | },
|
1676 | ["CONFIG_PRODUCTION_TIP" ]: {
|
1677 | message: `config.productionTip has been removed.`,
|
1678 | link: `https://v3.vuejs.org/guide/migration/global-api.html#config-productiontip-removed`
|
1679 | },
|
1680 | ["CONFIG_IGNORED_ELEMENTS" ]: {
|
1681 | message: () => {
|
1682 | let msg = `config.ignoredElements has been removed.`;
|
1683 | if (isRuntimeOnly()) {
|
1684 | msg += ` Pass the "isCustomElement" option to @vue/compiler-dom instead.`;
|
1685 | }
|
1686 | else {
|
1687 | msg += ` Use config.isCustomElement instead.`;
|
1688 | }
|
1689 | return msg;
|
1690 | },
|
1691 | link: `https://v3.vuejs.org/guide/migration/global-api.html#config-ignoredelements-is-now-config-iscustomelement`
|
1692 | },
|
1693 | ["CONFIG_WHITESPACE" ]: {
|
1694 |
|
1695 |
|
1696 | message: `Vue 3 compiler's whitespace option will default to "condense" instead of ` +
|
1697 | `"preserve". To suppress this warning, provide an explicit value for ` +
|
1698 | `\`config.compilerOptions.whitespace\`.`
|
1699 | },
|
1700 | ["CONFIG_OPTION_MERGE_STRATS" ]: {
|
1701 | message: `config.optionMergeStrategies no longer exposes internal strategies. ` +
|
1702 | `Use custom merge functions instead.`
|
1703 | },
|
1704 | ["INSTANCE_SET" ]: {
|
1705 | message: `vm.$set() has been removed as it is no longer needed in Vue 3. ` +
|
1706 | `Simply use native JavaScript mutations.`
|
1707 | },
|
1708 | ["INSTANCE_DELETE" ]: {
|
1709 | message: `vm.$delete() has been removed as it is no longer needed in Vue 3. ` +
|
1710 | `Simply use native JavaScript mutations.`
|
1711 | },
|
1712 | ["INSTANCE_DESTROY" ]: {
|
1713 | message: `vm.$destroy() has been removed. Use app.unmount() instead.`,
|
1714 | link: `https://v3.vuejs.org/api/application-api.html#unmount`
|
1715 | },
|
1716 | ["INSTANCE_EVENT_EMITTER" ]: {
|
1717 | message: `vm.$on/$once/$off() have been removed. ` +
|
1718 | `Use an external event emitter library instead.`,
|
1719 | link: `https://v3.vuejs.org/guide/migration/events-api.html`
|
1720 | },
|
1721 | ["INSTANCE_EVENT_HOOKS" ]: {
|
1722 | message: event => `"${event}" lifecycle events are no longer supported. From templates, ` +
|
1723 | `use the "vnode" prefix instead of "hook:". For example, @${event} ` +
|
1724 | `should be changed to @vnode-${event.slice(5)}. ` +
|
1725 | `From JavaScript, use Composition API to dynamically register lifecycle ` +
|
1726 | `hooks.`,
|
1727 | link: `https://v3.vuejs.org/guide/migration/vnode-lifecycle-events.html`
|
1728 | },
|
1729 | ["INSTANCE_CHILDREN" ]: {
|
1730 | message: `vm.$children has been removed. Consider refactoring your logic ` +
|
1731 | `to avoid relying on direct access to child components.`,
|
1732 | link: `https://v3.vuejs.org/guide/migration/children.html`
|
1733 | },
|
1734 | ["INSTANCE_LISTENERS" ]: {
|
1735 | message: `vm.$listeners has been removed. In Vue 3, parent v-on listeners are ` +
|
1736 | `included in vm.$attrs and it is no longer necessary to separately use ` +
|
1737 | `v-on="$listeners" if you are already using v-bind="$attrs". ` +
|
1738 | `(Note: the Vue 3 behavior only applies if this compat config is disabled)`,
|
1739 | link: `https://v3.vuejs.org/guide/migration/listeners-removed.html`
|
1740 | },
|
1741 | ["INSTANCE_SCOPED_SLOTS" ]: {
|
1742 | message: `vm.$scopedSlots has been removed. Use vm.$slots instead.`,
|
1743 | link: `https://v3.vuejs.org/guide/migration/slots-unification.html`
|
1744 | },
|
1745 | ["INSTANCE_ATTRS_CLASS_STYLE" ]: {
|
1746 | message: componentName => `Component <${componentName || 'Anonymous'}> has \`inheritAttrs: false\` but is ` +
|
1747 | `relying on class/style fallthrough from parent. In Vue 3, class/style ` +
|
1748 | `are now included in $attrs and will no longer fallthrough when ` +
|
1749 | `inheritAttrs is false. If you are already using v-bind="$attrs" on ` +
|
1750 | `component root it should render the same end result. ` +
|
1751 | `If you are binding $attrs to a non-root element and expecting ` +
|
1752 | `class/style to fallthrough on root, you will need to now manually bind ` +
|
1753 | `them on root via :class="$attrs.class".`,
|
1754 | link: `https://v3.vuejs.org/guide/migration/attrs-includes-class-style.html`
|
1755 | },
|
1756 | ["OPTIONS_DATA_FN" ]: {
|
1757 | message: `The "data" option can no longer be a plain object. ` +
|
1758 | `Always use a function.`,
|
1759 | link: `https://v3.vuejs.org/guide/migration/data-option.html`
|
1760 | },
|
1761 | ["OPTIONS_DATA_MERGE" ]: {
|
1762 | message: (key) => `Detected conflicting key "${key}" when merging data option values. ` +
|
1763 | `In Vue 3, data keys are merged shallowly and will override one another.`,
|
1764 | link: `https://v3.vuejs.org/guide/migration/data-option.html#mixin-merge-behavior-change`
|
1765 | },
|
1766 | ["OPTIONS_BEFORE_DESTROY" ]: {
|
1767 | message: `\`beforeDestroy\` has been renamed to \`beforeUnmount\`.`
|
1768 | },
|
1769 | ["OPTIONS_DESTROYED" ]: {
|
1770 | message: `\`destroyed\` has been renamed to \`unmounted\`.`
|
1771 | },
|
1772 | ["WATCH_ARRAY" ]: {
|
1773 | message: `"watch" option or vm.$watch on an array value will no longer ` +
|
1774 | `trigger on array mutation unless the "deep" option is specified. ` +
|
1775 | `If current usage is intended, you can disable the compat behavior and ` +
|
1776 | `suppress this warning with:` +
|
1777 | `\n\n configureCompat({ ${"WATCH_ARRAY" /* WATCH_ARRAY */}: false })\n`,
|
1778 | link: `https://v3.vuejs.org/guide/migration/watch.html`
|
1779 | },
|
1780 | ["PROPS_DEFAULT_THIS" ]: {
|
1781 | message: (key) => `props default value function no longer has access to "this". The compat ` +
|
1782 | `build only offers access to this.$options.` +
|
1783 | `(found in prop "${key}")`,
|
1784 | link: `https://v3.vuejs.org/guide/migration/props-default-this.html`
|
1785 | },
|
1786 | ["CUSTOM_DIR" ]: {
|
1787 | message: (legacyHook, newHook) => `Custom directive hook "${legacyHook}" has been removed. ` +
|
1788 | `Use "${newHook}" instead.`,
|
1789 | link: `https://v3.vuejs.org/guide/migration/custom-directives.html`
|
1790 | },
|
1791 | ["V_FOR_REF" ]: {
|
1792 | message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
|
1793 | `Consider using function refs or refactor to avoid ref usage altogether.`,
|
1794 | link: `https://v3.vuejs.org/guide/migration/array-refs.html`
|
1795 | },
|
1796 | ["V_ON_KEYCODE_MODIFIER" ]: {
|
1797 | message: `Using keyCode as v-on modifier is no longer supported. ` +
|
1798 | `Use kebab-case key name modifiers instead.`,
|
1799 | link: `https://v3.vuejs.org/guide/migration/keycode-modifiers.html`
|
1800 | },
|
1801 | ["ATTR_FALSE_VALUE" ]: {
|
1802 | message: (name) => `Attribute "${name}" with v-bind value \`false\` will render ` +
|
1803 | `${name}="false" instead of removing it in Vue 3. To remove the attribute, ` +
|
1804 | `use \`null\` or \`undefined\` instead. If the usage is intended, ` +
|
1805 | `you can disable the compat behavior and suppress this warning with:` +
|
1806 | `\n\n configureCompat({ ${"ATTR_FALSE_VALUE" /* ATTR_FALSE_VALUE */}: false })\n`,
|
1807 | link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html`
|
1808 | },
|
1809 | ["ATTR_ENUMERATED_COERCION" ]: {
|
1810 | message: (name, value, coerced) => `Enumerated attribute "${name}" with v-bind value \`${value}\` will ` +
|
1811 | `${value === null ? `be removed` : `render the value as-is`} instead of coercing the value to "${coerced}" in Vue 3. ` +
|
1812 | `Always use explicit "true" or "false" values for enumerated attributes. ` +
|
1813 | `If the usage is intended, ` +
|
1814 | `you can disable the compat behavior and suppress this warning with:` +
|
1815 | `\n\n configureCompat({ ${"ATTR_ENUMERATED_COERCION" /* ATTR_ENUMERATED_COERCION */}: false })\n`,
|
1816 | link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html`
|
1817 | },
|
1818 | ["TRANSITION_CLASSES" ]: {
|
1819 | message: ``
|
1820 | },
|
1821 | ["TRANSITION_GROUP_ROOT" ]: {
|
1822 | message: `<TransitionGroup> no longer renders a root <span> element by ` +
|
1823 | `default if no "tag" prop is specified. If you do not rely on the span ` +
|
1824 | `for styling, you can disable the compat behavior and suppress this ` +
|
1825 | `warning with:` +
|
1826 | `\n\n configureCompat({ ${"TRANSITION_GROUP_ROOT" /* TRANSITION_GROUP_ROOT */}: false })\n`,
|
1827 | link: `https://v3.vuejs.org/guide/migration/transition-group.html`
|
1828 | },
|
1829 | ["COMPONENT_ASYNC" ]: {
|
1830 | message: (comp) => {
|
1831 | const name = getComponentName(comp);
|
1832 | return (`Async component${name ? ` <${name}>` : `s`} should be explicitly created via \`defineAsyncComponent()\` ` +
|
1833 | `in Vue 3. Plain functions will be treated as functional components in ` +
|
1834 | `non-compat build. If you have already migrated all async component ` +
|
1835 | `usage and intend to use plain functions for functional components, ` +
|
1836 | `you can disable the compat behavior and suppress this ` +
|
1837 | `warning with:` +
|
1838 | `\n\n configureCompat({ ${"COMPONENT_ASYNC" /* COMPONENT_ASYNC */}: false })\n`);
|
1839 | },
|
1840 | link: `https://v3.vuejs.org/guide/migration/async-components.html`
|
1841 | },
|
1842 | ["COMPONENT_FUNCTIONAL" ]: {
|
1843 | message: (comp) => {
|
1844 | const name = getComponentName(comp);
|
1845 | return (`Functional component${name ? ` <${name}>` : `s`} should be defined as a plain function in Vue 3. The "functional" ` +
|
1846 | `option has been removed. NOTE: Before migrating to use plain ` +
|
1847 | `functions for functional components, first make sure that all async ` +
|
1848 | `components usage have been migrated and its compat behavior has ` +
|
1849 | `been disabled.`);
|
1850 | },
|
1851 | link: `https://v3.vuejs.org/guide/migration/functional-components.html`
|
1852 | },
|
1853 | ["COMPONENT_V_MODEL" ]: {
|
1854 | message: (comp) => {
|
1855 | const configMsg = `opt-in to ` +
|
1856 | `Vue 3 behavior on a per-component basis with \`compatConfig: { ${"COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */}: false }\`.`;
|
1857 | if (comp.props &&
|
1858 | (isArray(comp.props)
|
1859 | ? comp.props.includes('modelValue')
|
1860 | : hasOwn(comp.props, 'modelValue'))) {
|
1861 | return (`Component delcares "modelValue" prop, which is Vue 3 usage, but ` +
|
1862 | `is running under Vue 2 compat v-model behavior. You can ${configMsg}`);
|
1863 | }
|
1864 | return (`v-model usage on component has changed in Vue 3. Component that expects ` +
|
1865 | `to work with v-model should now use the "modelValue" prop and emit the ` +
|
1866 | `"update:modelValue" event. You can update the usage and then ${configMsg}`);
|
1867 | },
|
1868 | link: `https://v3.vuejs.org/guide/migration/v-model.html`
|
1869 | },
|
1870 | ["RENDER_FUNCTION" ]: {
|
1871 | message: `Vue 3's render function API has changed. ` +
|
1872 | `You can opt-in to the new API with:` +
|
1873 | `\n\n configureCompat({ ${"RENDER_FUNCTION" /* RENDER_FUNCTION */}: false })\n` +
|
1874 | `\n (This can also be done per-component via the "compatConfig" option.)`,
|
1875 | link: `https://v3.vuejs.org/guide/migration/render-function-api.html`
|
1876 | },
|
1877 | ["FILTERS" ]: {
|
1878 | message: `filters have been removed in Vue 3. ` +
|
1879 | `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
|
1880 | `Use method calls or computed properties instead.`,
|
1881 | link: `https://v3.vuejs.org/guide/migration/filters.html`
|
1882 | },
|
1883 | ["PRIVATE_APIS" ]: {
|
1884 | message: name => `"${name}" is a Vue 2 private API that no longer exists in Vue 3. ` +
|
1885 | `If you are seeing this warning only due to a dependency, you can ` +
|
1886 | `suppress this warning via { PRIVATE_APIS: 'supress-warning' }.`
|
1887 | }
|
1888 | };
|
1889 | const instanceWarned = Object.create(null);
|
1890 | const warnCount = Object.create(null);
|
1891 | function warnDeprecation(key, instance, ...args) {
|
1892 | instance = instance || getCurrentInstance();
|
1893 |
|
1894 | const config = getCompatConfigForKey(key, instance);
|
1895 | if (config === 'suppress-warning') {
|
1896 | return;
|
1897 | }
|
1898 | const dupKey = key + args.join('');
|
1899 | let compId = instance && formatComponentName(instance, instance.type);
|
1900 | if (compId === 'Anonymous' && instance) {
|
1901 | compId = instance.uid;
|
1902 | }
|
1903 |
|
1904 | const componentDupKey = dupKey + compId;
|
1905 | if (componentDupKey in instanceWarned) {
|
1906 | return;
|
1907 | }
|
1908 | instanceWarned[componentDupKey] = true;
|
1909 |
|
1910 |
|
1911 | if (dupKey in warnCount) {
|
1912 | warn$1(`(deprecation ${key}) (${++warnCount[dupKey] + 1})`);
|
1913 | return;
|
1914 | }
|
1915 | warnCount[dupKey] = 0;
|
1916 | const { message, link } = deprecationData[key];
|
1917 | warn$1(`(deprecation ${key}) ${typeof message === 'function' ? message(...args) : message}${link ? `\n Details: ${link}` : ``}`);
|
1918 | if (!isCompatEnabled(key, instance, true)) {
|
1919 | console.error(`^ The above deprecation's compat behavior is disabled and will likely ` +
|
1920 | `lead to runtime errors.`);
|
1921 | }
|
1922 | }
|
1923 | const globalCompatConfig = {
|
1924 | MODE: 2
|
1925 | };
|
1926 | function getCompatConfigForKey(key, instance) {
|
1927 | const instanceConfig = instance && instance.type.compatConfig;
|
1928 | if (instanceConfig && key in instanceConfig) {
|
1929 | return instanceConfig[key];
|
1930 | }
|
1931 | return globalCompatConfig[key];
|
1932 | }
|
1933 | function isCompatEnabled(key, instance, enableForBuiltIn = false) {
|
1934 |
|
1935 | if (!enableForBuiltIn && instance && instance.type.__isBuiltIn) {
|
1936 | return false;
|
1937 | }
|
1938 | const rawMode = getCompatConfigForKey('MODE', instance) || 2;
|
1939 | const val = getCompatConfigForKey(key, instance);
|
1940 | const mode = isFunction(rawMode)
|
1941 | ? rawMode(instance && instance.type)
|
1942 | : rawMode;
|
1943 | if (mode === 2) {
|
1944 | return val !== false;
|
1945 | }
|
1946 | else {
|
1947 | return val === true || val === 'suppress-warning';
|
1948 | }
|
1949 | }
|
1950 |
|
1951 | function emit(instance, event, ...rawArgs) {
|
1952 | const props = instance.vnode.props || EMPTY_OBJ;
|
1953 | {
|
1954 | const { emitsOptions, propsOptions: [propsOptions] } = instance;
|
1955 | if (emitsOptions) {
|
1956 | if (!(event in emitsOptions) &&
|
1957 | !(false )) {
|
1958 | if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
|
1959 | warn$1(`Component emitted event "${event}" but it is neither declared in ` +
|
1960 | `the emits option nor as an "${toHandlerKey(event)}" prop.`);
|
1961 | }
|
1962 | }
|
1963 | else {
|
1964 | const validator = emitsOptions[event];
|
1965 | if (isFunction(validator)) {
|
1966 | const isValid = validator(...rawArgs);
|
1967 | if (!isValid) {
|
1968 | warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
|
1969 | }
|
1970 | }
|
1971 | }
|
1972 | }
|
1973 | }
|
1974 | let args = rawArgs;
|
1975 | const isModelListener = event.startsWith('update:');
|
1976 |
|
1977 | const modelArg = isModelListener && event.slice(7);
|
1978 | if (modelArg && modelArg in props) {
|
1979 | const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
|
1980 | const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
|
1981 | if (trim) {
|
1982 | args = rawArgs.map(a => a.trim());
|
1983 | }
|
1984 | else if (number) {
|
1985 | args = rawArgs.map(toNumber);
|
1986 | }
|
1987 | }
|
1988 | {
|
1989 | devtoolsComponentEmit(instance, event, args);
|
1990 | }
|
1991 | {
|
1992 | const lowerCaseEvent = event.toLowerCase();
|
1993 | if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
|
1994 | warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
|
1995 | `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
|
1996 | `Note that HTML attributes are case-insensitive and you cannot use ` +
|
1997 | `v-on to listen to camelCase events when using in-DOM templates. ` +
|
1998 | `You should probably use "${hyphenate(event)}" instead of "${event}".`);
|
1999 | }
|
2000 | }
|
2001 | let handlerName;
|
2002 | let handler = props[(handlerName = toHandlerKey(event))] ||
|
2003 |
|
2004 | props[(handlerName = toHandlerKey(camelize(event)))];
|
2005 |
|
2006 |
|
2007 | if (!handler && isModelListener) {
|
2008 | handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
|
2009 | }
|
2010 | if (handler) {
|
2011 | callWithAsyncErrorHandling(handler, instance, 6 , args);
|
2012 | }
|
2013 | const onceHandler = props[handlerName + `Once`];
|
2014 | if (onceHandler) {
|
2015 | if (!instance.emitted) {
|
2016 | instance.emitted = {};
|
2017 | }
|
2018 | else if (instance.emitted[handlerName]) {
|
2019 | return;
|
2020 | }
|
2021 | instance.emitted[handlerName] = true;
|
2022 | callWithAsyncErrorHandling(onceHandler, instance, 6 , args);
|
2023 | }
|
2024 | }
|
2025 | function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
2026 | const cache = appContext.emitsCache;
|
2027 | const cached = cache.get(comp);
|
2028 | if (cached !== undefined) {
|
2029 | return cached;
|
2030 | }
|
2031 | const raw = comp.emits;
|
2032 | let normalized = {};
|
2033 |
|
2034 | let hasExtends = false;
|
2035 | if (!isFunction(comp)) {
|
2036 | const extendEmits = (raw) => {
|
2037 | const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
|
2038 | if (normalizedFromExtend) {
|
2039 | hasExtends = true;
|
2040 | extend(normalized, normalizedFromExtend);
|
2041 | }
|
2042 | };
|
2043 | if (!asMixin && appContext.mixins.length) {
|
2044 | appContext.mixins.forEach(extendEmits);
|
2045 | }
|
2046 | if (comp.extends) {
|
2047 | extendEmits(comp.extends);
|
2048 | }
|
2049 | if (comp.mixins) {
|
2050 | comp.mixins.forEach(extendEmits);
|
2051 | }
|
2052 | }
|
2053 | if (!raw && !hasExtends) {
|
2054 | cache.set(comp, null);
|
2055 | return null;
|
2056 | }
|
2057 | if (isArray(raw)) {
|
2058 | raw.forEach(key => (normalized[key] = null));
|
2059 | }
|
2060 | else {
|
2061 | extend(normalized, raw);
|
2062 | }
|
2063 | cache.set(comp, normalized);
|
2064 | return normalized;
|
2065 | }
|
2066 |
|
2067 |
|
2068 |
|
2069 | function isEmitListener(options, key) {
|
2070 | if (!options || !isOn(key)) {
|
2071 | return false;
|
2072 | }
|
2073 | key = key.slice(2).replace(/Once$/, '');
|
2074 | return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
|
2075 | hasOwn(options, hyphenate(key)) ||
|
2076 | hasOwn(options, key));
|
2077 | }
|
2078 |
|
2079 | |
2080 |
|
2081 |
|
2082 |
|
2083 | let currentRenderingInstance = null;
|
2084 | let currentScopeId = null;
|
2085 | |
2086 |
|
2087 |
|
2088 |
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 |
|
2094 |
|
2095 | function setCurrentRenderingInstance(instance) {
|
2096 | const prev = currentRenderingInstance;
|
2097 | currentRenderingInstance = instance;
|
2098 | currentScopeId = (instance && instance.type.__scopeId) || null;
|
2099 | return prev;
|
2100 | }
|
2101 | |
2102 |
|
2103 |
|
2104 |
|
2105 | function pushScopeId(id) {
|
2106 | currentScopeId = id;
|
2107 | }
|
2108 | |
2109 |
|
2110 |
|
2111 |
|
2112 |
|
2113 | function popScopeId() {
|
2114 | currentScopeId = null;
|
2115 | }
|
2116 | |
2117 |
|
2118 |
|
2119 |
|
2120 | const withScopeId = (_id) => withCtx;
|
2121 | |
2122 |
|
2123 |
|
2124 |
|
2125 | function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
|
2126 | ) {
|
2127 | if (!ctx)
|
2128 | return fn;
|
2129 |
|
2130 | if (fn._n) {
|
2131 | return fn;
|
2132 | }
|
2133 | const renderFnWithContext = (...args) => {
|
2134 |
|
2135 |
|
2136 |
|
2137 |
|
2138 |
|
2139 | if (renderFnWithContext._d) {
|
2140 | setBlockTracking(-1);
|
2141 | }
|
2142 | const prevInstance = setCurrentRenderingInstance(ctx);
|
2143 | const res = fn(...args);
|
2144 | setCurrentRenderingInstance(prevInstance);
|
2145 | if (renderFnWithContext._d) {
|
2146 | setBlockTracking(1);
|
2147 | }
|
2148 | {
|
2149 | devtoolsComponentUpdated(ctx);
|
2150 | }
|
2151 | return res;
|
2152 | };
|
2153 |
|
2154 | renderFnWithContext._n = true;
|
2155 |
|
2156 |
|
2157 |
|
2158 | renderFnWithContext._c = true;
|
2159 |
|
2160 | renderFnWithContext._d = true;
|
2161 | return renderFnWithContext;
|
2162 | }
|
2163 |
|
2164 | |
2165 |
|
2166 |
|
2167 |
|
2168 |
|
2169 | let accessedAttrs = false;
|
2170 | function markAttrsAccessed() {
|
2171 | accessedAttrs = true;
|
2172 | }
|
2173 | function renderComponentRoot(instance) {
|
2174 | const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
|
2175 | let result;
|
2176 | const prev = setCurrentRenderingInstance(instance);
|
2177 | {
|
2178 | accessedAttrs = false;
|
2179 | }
|
2180 | try {
|
2181 | let fallthroughAttrs;
|
2182 | if (vnode.shapeFlag & 4 ) {
|
2183 |
|
2184 |
|
2185 | const proxyToUse = withProxy || proxy;
|
2186 | result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
|
2187 | fallthroughAttrs = attrs;
|
2188 | }
|
2189 | else {
|
2190 |
|
2191 | const render = Component;
|
2192 |
|
2193 | if (true && attrs === props) {
|
2194 | markAttrsAccessed();
|
2195 | }
|
2196 | result = normalizeVNode(render.length > 1
|
2197 | ? render(props, true
|
2198 | ? {
|
2199 | get attrs() {
|
2200 | markAttrsAccessed();
|
2201 | return attrs;
|
2202 | },
|
2203 | slots,
|
2204 | emit
|
2205 | }
|
2206 | : { attrs, slots, emit })
|
2207 | : render(props, null ));
|
2208 | fallthroughAttrs = Component.props
|
2209 | ? attrs
|
2210 | : getFunctionalFallthrough(attrs);
|
2211 | }
|
2212 |
|
2213 |
|
2214 |
|
2215 | let root = result;
|
2216 | let setRoot = undefined;
|
2217 | if (true &&
|
2218 | result.patchFlag > 0 &&
|
2219 | result.patchFlag & 2048 ) {
|
2220 | ;
|
2221 | [root, setRoot] = getChildRoot(result);
|
2222 | }
|
2223 | if (fallthroughAttrs && inheritAttrs !== false) {
|
2224 | const keys = Object.keys(fallthroughAttrs);
|
2225 | const { shapeFlag } = root;
|
2226 | if (keys.length) {
|
2227 | if (shapeFlag & (1 | 6 )) {
|
2228 | if (propsOptions && keys.some(isModelListener)) {
|
2229 |
|
2230 |
|
2231 |
|
2232 |
|
2233 | fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
|
2234 | }
|
2235 | root = cloneVNode(root, fallthroughAttrs);
|
2236 | }
|
2237 | else if (true && !accessedAttrs && root.type !== Comment) {
|
2238 | const allAttrs = Object.keys(attrs);
|
2239 | const eventAttrs = [];
|
2240 | const extraAttrs = [];
|
2241 | for (let i = 0, l = allAttrs.length; i < l; i++) {
|
2242 | const key = allAttrs[i];
|
2243 | if (isOn(key)) {
|
2244 |
|
2245 | if (!isModelListener(key)) {
|
2246 |
|
2247 |
|
2248 | eventAttrs.push(key[2].toLowerCase() + key.slice(3));
|
2249 | }
|
2250 | }
|
2251 | else {
|
2252 | extraAttrs.push(key);
|
2253 | }
|
2254 | }
|
2255 | if (extraAttrs.length) {
|
2256 | warn$1(`Extraneous non-props attributes (` +
|
2257 | `${extraAttrs.join(', ')}) ` +
|
2258 | `were passed to component but could not be automatically inherited ` +
|
2259 | `because component renders fragment or text root nodes.`);
|
2260 | }
|
2261 | if (eventAttrs.length) {
|
2262 | warn$1(`Extraneous non-emits event listeners (` +
|
2263 | `${eventAttrs.join(', ')}) ` +
|
2264 | `were passed to component but could not be automatically inherited ` +
|
2265 | `because component renders fragment or text root nodes. ` +
|
2266 | `If the listener is intended to be a component custom event listener only, ` +
|
2267 | `declare it using the "emits" option.`);
|
2268 | }
|
2269 | }
|
2270 | }
|
2271 | }
|
2272 | if (false &&
|
2273 | isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" , instance) &&
|
2274 | vnode.shapeFlag & 4 &&
|
2275 | root.shapeFlag & (1 | 6 )) ;
|
2276 |
|
2277 | if (vnode.dirs) {
|
2278 | if (true && !isElementRoot(root)) {
|
2279 | warn$1(`Runtime directive used on component with non-element root node. ` +
|
2280 | `The directives will not function as intended.`);
|
2281 | }
|
2282 | root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
|
2283 | }
|
2284 |
|
2285 | if (vnode.transition) {
|
2286 | if (true && !isElementRoot(root)) {
|
2287 | warn$1(`Component inside <Transition> renders non-element root node ` +
|
2288 | `that cannot be animated.`);
|
2289 | }
|
2290 | root.transition = vnode.transition;
|
2291 | }
|
2292 | if (true && setRoot) {
|
2293 | setRoot(root);
|
2294 | }
|
2295 | else {
|
2296 | result = root;
|
2297 | }
|
2298 | }
|
2299 | catch (err) {
|
2300 | blockStack.length = 0;
|
2301 | handleError(err, instance, 1 );
|
2302 | result = createVNode(Comment);
|
2303 | }
|
2304 | setCurrentRenderingInstance(prev);
|
2305 | return result;
|
2306 | }
|
2307 | |
2308 |
|
2309 |
|
2310 |
|
2311 |
|
2312 |
|
2313 | const getChildRoot = (vnode) => {
|
2314 | const rawChildren = vnode.children;
|
2315 | const dynamicChildren = vnode.dynamicChildren;
|
2316 | const childRoot = filterSingleRoot(rawChildren);
|
2317 | if (!childRoot) {
|
2318 | return [vnode, undefined];
|
2319 | }
|
2320 | const index = rawChildren.indexOf(childRoot);
|
2321 | const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
|
2322 | const setRoot = (updatedRoot) => {
|
2323 | rawChildren[index] = updatedRoot;
|
2324 | if (dynamicChildren) {
|
2325 | if (dynamicIndex > -1) {
|
2326 | dynamicChildren[dynamicIndex] = updatedRoot;
|
2327 | }
|
2328 | else if (updatedRoot.patchFlag > 0) {
|
2329 | vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
|
2330 | }
|
2331 | }
|
2332 | };
|
2333 | return [normalizeVNode(childRoot), setRoot];
|
2334 | };
|
2335 | function filterSingleRoot(children) {
|
2336 | let singleRoot;
|
2337 | for (let i = 0; i < children.length; i++) {
|
2338 | const child = children[i];
|
2339 | if (isVNode(child)) {
|
2340 |
|
2341 | if (child.type !== Comment || child.children === 'v-if') {
|
2342 | if (singleRoot) {
|
2343 |
|
2344 | return;
|
2345 | }
|
2346 | else {
|
2347 | singleRoot = child;
|
2348 | }
|
2349 | }
|
2350 | }
|
2351 | else {
|
2352 | return;
|
2353 | }
|
2354 | }
|
2355 | return singleRoot;
|
2356 | }
|
2357 | const getFunctionalFallthrough = (attrs) => {
|
2358 | let res;
|
2359 | for (const key in attrs) {
|
2360 | if (key === 'class' || key === 'style' || isOn(key)) {
|
2361 | (res || (res = {}))[key] = attrs[key];
|
2362 | }
|
2363 | }
|
2364 | return res;
|
2365 | };
|
2366 | const filterModelListeners = (attrs, props) => {
|
2367 | const res = {};
|
2368 | for (const key in attrs) {
|
2369 | if (!isModelListener(key) || !(key.slice(9) in props)) {
|
2370 | res[key] = attrs[key];
|
2371 | }
|
2372 | }
|
2373 | return res;
|
2374 | };
|
2375 | const isElementRoot = (vnode) => {
|
2376 | return (vnode.shapeFlag & (6 | 1 ) ||
|
2377 | vnode.type === Comment
|
2378 | );
|
2379 | };
|
2380 | function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
|
2381 | const { props: prevProps, children: prevChildren, component } = prevVNode;
|
2382 | const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
|
2383 | const emits = component.emitsOptions;
|
2384 |
|
2385 |
|
2386 |
|
2387 | if ((prevChildren || nextChildren) && isHmrUpdating) {
|
2388 | return true;
|
2389 | }
|
2390 |
|
2391 | if (nextVNode.dirs || nextVNode.transition) {
|
2392 | return true;
|
2393 | }
|
2394 | if (optimized && patchFlag >= 0) {
|
2395 | if (patchFlag & 1024 ) {
|
2396 |
|
2397 |
|
2398 | return true;
|
2399 | }
|
2400 | if (patchFlag & 16 ) {
|
2401 | if (!prevProps) {
|
2402 | return !!nextProps;
|
2403 | }
|
2404 |
|
2405 | return hasPropsChanged(prevProps, nextProps, emits);
|
2406 | }
|
2407 | else if (patchFlag & 8 ) {
|
2408 | const dynamicProps = nextVNode.dynamicProps;
|
2409 | for (let i = 0; i < dynamicProps.length; i++) {
|
2410 | const key = dynamicProps[i];
|
2411 | if (nextProps[key] !== prevProps[key] &&
|
2412 | !isEmitListener(emits, key)) {
|
2413 | return true;
|
2414 | }
|
2415 | }
|
2416 | }
|
2417 | }
|
2418 | else {
|
2419 |
|
2420 |
|
2421 | if (prevChildren || nextChildren) {
|
2422 | if (!nextChildren || !nextChildren.$stable) {
|
2423 | return true;
|
2424 | }
|
2425 | }
|
2426 | if (prevProps === nextProps) {
|
2427 | return false;
|
2428 | }
|
2429 | if (!prevProps) {
|
2430 | return !!nextProps;
|
2431 | }
|
2432 | if (!nextProps) {
|
2433 | return true;
|
2434 | }
|
2435 | return hasPropsChanged(prevProps, nextProps, emits);
|
2436 | }
|
2437 | return false;
|
2438 | }
|
2439 | function hasPropsChanged(prevProps, nextProps, emitsOptions) {
|
2440 | const nextKeys = Object.keys(nextProps);
|
2441 | if (nextKeys.length !== Object.keys(prevProps).length) {
|
2442 | return true;
|
2443 | }
|
2444 | for (let i = 0; i < nextKeys.length; i++) {
|
2445 | const key = nextKeys[i];
|
2446 | if (nextProps[key] !== prevProps[key] &&
|
2447 | !isEmitListener(emitsOptions, key)) {
|
2448 | return true;
|
2449 | }
|
2450 | }
|
2451 | return false;
|
2452 | }
|
2453 | function updateHOCHostEl({ vnode, parent }, el // HostNode
|
2454 | ) {
|
2455 | while (parent && parent.subTree === vnode) {
|
2456 | (vnode = parent.vnode).el = el;
|
2457 | parent = parent.parent;
|
2458 | }
|
2459 | }
|
2460 |
|
2461 | const isSuspense = (type) => type.__isSuspense;
|
2462 |
|
2463 |
|
2464 |
|
2465 | const SuspenseImpl = {
|
2466 | name: 'Suspense',
|
2467 |
|
2468 |
|
2469 |
|
2470 |
|
2471 | __isSuspense: true,
|
2472 | process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
|
2473 |
|
2474 | rendererInternals) {
|
2475 | if (n1 == null) {
|
2476 | mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
|
2477 | }
|
2478 | else {
|
2479 | patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
|
2480 | }
|
2481 | },
|
2482 | hydrate: hydrateSuspense,
|
2483 | create: createSuspenseBoundary,
|
2484 | normalize: normalizeSuspenseChildren
|
2485 | };
|
2486 |
|
2487 | const Suspense = (SuspenseImpl );
|
2488 | function triggerEvent(vnode, name) {
|
2489 | const eventListener = vnode.props && vnode.props[name];
|
2490 | if (isFunction(eventListener)) {
|
2491 | eventListener();
|
2492 | }
|
2493 | }
|
2494 | function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
|
2495 | const { p: patch, o: { createElement } } = rendererInternals;
|
2496 | const hiddenContainer = createElement('div');
|
2497 | const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
|
2498 |
|
2499 | patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
|
2500 |
|
2501 | if (suspense.deps > 0) {
|
2502 |
|
2503 |
|
2504 | triggerEvent(vnode, 'onPending');
|
2505 | triggerEvent(vnode, 'onFallback');
|
2506 |
|
2507 | patch(null, vnode.ssFallback, container, anchor, parentComponent, null,
|
2508 | isSVG, slotScopeIds);
|
2509 | setActiveBranch(suspense, vnode.ssFallback);
|
2510 | }
|
2511 | else {
|
2512 |
|
2513 | suspense.resolve();
|
2514 | }
|
2515 | }
|
2516 | function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
|
2517 | const suspense = (n2.suspense = n1.suspense);
|
2518 | suspense.vnode = n2;
|
2519 | n2.el = n1.el;
|
2520 | const newBranch = n2.ssContent;
|
2521 | const newFallback = n2.ssFallback;
|
2522 | const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
|
2523 | if (pendingBranch) {
|
2524 | suspense.pendingBranch = newBranch;
|
2525 | if (isSameVNodeType(newBranch, pendingBranch)) {
|
2526 |
|
2527 | patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2528 | if (suspense.deps <= 0) {
|
2529 | suspense.resolve();
|
2530 | }
|
2531 | else if (isInFallback) {
|
2532 | patch(activeBranch, newFallback, container, anchor, parentComponent, null,
|
2533 | isSVG, slotScopeIds, optimized);
|
2534 | setActiveBranch(suspense, newFallback);
|
2535 | }
|
2536 | }
|
2537 | else {
|
2538 |
|
2539 | suspense.pendingId++;
|
2540 | if (isHydrating) {
|
2541 |
|
2542 |
|
2543 |
|
2544 | suspense.isHydrating = false;
|
2545 | suspense.activeBranch = pendingBranch;
|
2546 | }
|
2547 | else {
|
2548 | unmount(pendingBranch, parentComponent, suspense);
|
2549 | }
|
2550 |
|
2551 |
|
2552 | suspense.deps = 0;
|
2553 |
|
2554 | suspense.effects.length = 0;
|
2555 |
|
2556 | suspense.hiddenContainer = createElement('div');
|
2557 | if (isInFallback) {
|
2558 |
|
2559 | patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2560 | if (suspense.deps <= 0) {
|
2561 | suspense.resolve();
|
2562 | }
|
2563 | else {
|
2564 | patch(activeBranch, newFallback, container, anchor, parentComponent, null,
|
2565 | isSVG, slotScopeIds, optimized);
|
2566 | setActiveBranch(suspense, newFallback);
|
2567 | }
|
2568 | }
|
2569 | else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2570 |
|
2571 | patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2572 |
|
2573 | suspense.resolve(true);
|
2574 | }
|
2575 | else {
|
2576 |
|
2577 | patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2578 | if (suspense.deps <= 0) {
|
2579 | suspense.resolve();
|
2580 | }
|
2581 | }
|
2582 | }
|
2583 | }
|
2584 | else {
|
2585 | if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2586 |
|
2587 | patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2588 | setActiveBranch(suspense, newBranch);
|
2589 | }
|
2590 | else {
|
2591 |
|
2592 |
|
2593 | triggerEvent(n2, 'onPending');
|
2594 |
|
2595 | suspense.pendingBranch = newBranch;
|
2596 | suspense.pendingId++;
|
2597 | patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2598 | if (suspense.deps <= 0) {
|
2599 |
|
2600 | suspense.resolve();
|
2601 | }
|
2602 | else {
|
2603 | const { timeout, pendingId } = suspense;
|
2604 | if (timeout > 0) {
|
2605 | setTimeout(() => {
|
2606 | if (suspense.pendingId === pendingId) {
|
2607 | suspense.fallback(newFallback);
|
2608 | }
|
2609 | }, timeout);
|
2610 | }
|
2611 | else if (timeout === 0) {
|
2612 | suspense.fallback(newFallback);
|
2613 | }
|
2614 | }
|
2615 | }
|
2616 | }
|
2617 | }
|
2618 | let hasWarned = false;
|
2619 | function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
|
2620 |
|
2621 | if (!hasWarned) {
|
2622 | hasWarned = true;
|
2623 |
|
2624 | console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
|
2625 | }
|
2626 | const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
|
2627 | const timeout = toNumber(vnode.props && vnode.props.timeout);
|
2628 | const suspense = {
|
2629 | vnode,
|
2630 | parent,
|
2631 | parentComponent,
|
2632 | isSVG,
|
2633 | container,
|
2634 | hiddenContainer,
|
2635 | anchor,
|
2636 | deps: 0,
|
2637 | pendingId: 0,
|
2638 | timeout: typeof timeout === 'number' ? timeout : -1,
|
2639 | activeBranch: null,
|
2640 | pendingBranch: null,
|
2641 | isInFallback: true,
|
2642 | isHydrating,
|
2643 | isUnmounted: false,
|
2644 | effects: [],
|
2645 | resolve(resume = false) {
|
2646 | {
|
2647 | if (!resume && !suspense.pendingBranch) {
|
2648 | throw new Error(`suspense.resolve() is called without a pending branch.`);
|
2649 | }
|
2650 | if (suspense.isUnmounted) {
|
2651 | throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
|
2652 | }
|
2653 | }
|
2654 | const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
|
2655 | if (suspense.isHydrating) {
|
2656 | suspense.isHydrating = false;
|
2657 | }
|
2658 | else if (!resume) {
|
2659 | const delayEnter = activeBranch &&
|
2660 | pendingBranch.transition &&
|
2661 | pendingBranch.transition.mode === 'out-in';
|
2662 | if (delayEnter) {
|
2663 | activeBranch.transition.afterLeave = () => {
|
2664 | if (pendingId === suspense.pendingId) {
|
2665 | move(pendingBranch, container, anchor, 0 );
|
2666 | }
|
2667 | };
|
2668 | }
|
2669 |
|
2670 | let { anchor } = suspense;
|
2671 |
|
2672 | if (activeBranch) {
|
2673 |
|
2674 |
|
2675 | anchor = next(activeBranch);
|
2676 | unmount(activeBranch, parentComponent, suspense, true);
|
2677 | }
|
2678 | if (!delayEnter) {
|
2679 |
|
2680 | move(pendingBranch, container, anchor, 0 );
|
2681 | }
|
2682 | }
|
2683 | setActiveBranch(suspense, pendingBranch);
|
2684 | suspense.pendingBranch = null;
|
2685 | suspense.isInFallback = false;
|
2686 |
|
2687 |
|
2688 | let parent = suspense.parent;
|
2689 | let hasUnresolvedAncestor = false;
|
2690 | while (parent) {
|
2691 | if (parent.pendingBranch) {
|
2692 |
|
2693 |
|
2694 | parent.effects.push(...effects);
|
2695 | hasUnresolvedAncestor = true;
|
2696 | break;
|
2697 | }
|
2698 | parent = parent.parent;
|
2699 | }
|
2700 |
|
2701 | if (!hasUnresolvedAncestor) {
|
2702 | queuePostFlushCb(effects);
|
2703 | }
|
2704 | suspense.effects = [];
|
2705 |
|
2706 | triggerEvent(vnode, 'onResolve');
|
2707 | },
|
2708 | fallback(fallbackVNode) {
|
2709 | if (!suspense.pendingBranch) {
|
2710 | return;
|
2711 | }
|
2712 | const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
|
2713 |
|
2714 | triggerEvent(vnode, 'onFallback');
|
2715 | const anchor = next(activeBranch);
|
2716 | const mountFallback = () => {
|
2717 | if (!suspense.isInFallback) {
|
2718 | return;
|
2719 | }
|
2720 |
|
2721 | patch(null, fallbackVNode, container, anchor, parentComponent, null,
|
2722 | isSVG, slotScopeIds, optimized);
|
2723 | setActiveBranch(suspense, fallbackVNode);
|
2724 | };
|
2725 | const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
|
2726 | if (delayEnter) {
|
2727 | activeBranch.transition.afterLeave = mountFallback;
|
2728 | }
|
2729 | suspense.isInFallback = true;
|
2730 |
|
2731 | unmount(activeBranch, parentComponent, null,
|
2732 | true
|
2733 | );
|
2734 | if (!delayEnter) {
|
2735 | mountFallback();
|
2736 | }
|
2737 | },
|
2738 | move(container, anchor, type) {
|
2739 | suspense.activeBranch &&
|
2740 | move(suspense.activeBranch, container, anchor, type);
|
2741 | suspense.container = container;
|
2742 | },
|
2743 | next() {
|
2744 | return suspense.activeBranch && next(suspense.activeBranch);
|
2745 | },
|
2746 | registerDep(instance, setupRenderEffect) {
|
2747 | const isInPendingSuspense = !!suspense.pendingBranch;
|
2748 | if (isInPendingSuspense) {
|
2749 | suspense.deps++;
|
2750 | }
|
2751 | const hydratedEl = instance.vnode.el;
|
2752 | instance
|
2753 | .asyncDep.catch(err => {
|
2754 | handleError(err, instance, 0 );
|
2755 | })
|
2756 | .then(asyncSetupResult => {
|
2757 |
|
2758 |
|
2759 | if (instance.isUnmounted ||
|
2760 | suspense.isUnmounted ||
|
2761 | suspense.pendingId !== instance.suspenseId) {
|
2762 | return;
|
2763 | }
|
2764 |
|
2765 | instance.asyncResolved = true;
|
2766 | const { vnode } = instance;
|
2767 | {
|
2768 | pushWarningContext(vnode);
|
2769 | }
|
2770 | handleSetupResult(instance, asyncSetupResult, false);
|
2771 | if (hydratedEl) {
|
2772 |
|
2773 |
|
2774 | vnode.el = hydratedEl;
|
2775 | }
|
2776 | const placeholder = !hydratedEl && instance.subTree.el;
|
2777 | setupRenderEffect(instance, vnode,
|
2778 |
|
2779 |
|
2780 |
|
2781 | parentNode(hydratedEl || instance.subTree.el),
|
2782 |
|
2783 |
|
2784 | hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
|
2785 | if (placeholder) {
|
2786 | remove(placeholder);
|
2787 | }
|
2788 | updateHOCHostEl(instance, vnode.el);
|
2789 | {
|
2790 | popWarningContext();
|
2791 | }
|
2792 |
|
2793 | if (isInPendingSuspense && --suspense.deps === 0) {
|
2794 | suspense.resolve();
|
2795 | }
|
2796 | });
|
2797 | },
|
2798 | unmount(parentSuspense, doRemove) {
|
2799 | suspense.isUnmounted = true;
|
2800 | if (suspense.activeBranch) {
|
2801 | unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
|
2802 | }
|
2803 | if (suspense.pendingBranch) {
|
2804 | unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
|
2805 | }
|
2806 | }
|
2807 | };
|
2808 | return suspense;
|
2809 | }
|
2810 | function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
|
2811 |
|
2812 | const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true ));
|
2813 |
|
2814 |
|
2815 |
|
2816 |
|
2817 |
|
2818 |
|
2819 | const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
|
2820 | if (suspense.deps === 0) {
|
2821 | suspense.resolve();
|
2822 | }
|
2823 | return result;
|
2824 |
|
2825 | }
|
2826 | function normalizeSuspenseChildren(vnode) {
|
2827 | const { shapeFlag, children } = vnode;
|
2828 | const isSlotChildren = shapeFlag & 32 ;
|
2829 | vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
|
2830 | vnode.ssFallback = isSlotChildren
|
2831 | ? normalizeSuspenseSlot(children.fallback)
|
2832 | : createVNode(Comment);
|
2833 | }
|
2834 | function normalizeSuspenseSlot(s) {
|
2835 | let block;
|
2836 | if (isFunction(s)) {
|
2837 | const isCompiledSlot = s._c;
|
2838 | if (isCompiledSlot) {
|
2839 |
|
2840 |
|
2841 |
|
2842 | s._d = false;
|
2843 | openBlock();
|
2844 | }
|
2845 | s = s();
|
2846 | if (isCompiledSlot) {
|
2847 | s._d = true;
|
2848 | block = currentBlock;
|
2849 | closeBlock();
|
2850 | }
|
2851 | }
|
2852 | if (isArray(s)) {
|
2853 | const singleChild = filterSingleRoot(s);
|
2854 | if (!singleChild) {
|
2855 | warn$1(`<Suspense> slots expect a single root node.`);
|
2856 | }
|
2857 | s = singleChild;
|
2858 | }
|
2859 | s = normalizeVNode(s);
|
2860 | if (block && !s.dynamicChildren) {
|
2861 | s.dynamicChildren = block.filter(c => c !== s);
|
2862 | }
|
2863 | return s;
|
2864 | }
|
2865 | function queueEffectWithSuspense(fn, suspense) {
|
2866 | if (suspense && suspense.pendingBranch) {
|
2867 | if (isArray(fn)) {
|
2868 | suspense.effects.push(...fn);
|
2869 | }
|
2870 | else {
|
2871 | suspense.effects.push(fn);
|
2872 | }
|
2873 | }
|
2874 | else {
|
2875 | queuePostFlushCb(fn);
|
2876 | }
|
2877 | }
|
2878 | function setActiveBranch(suspense, branch) {
|
2879 | suspense.activeBranch = branch;
|
2880 | const { vnode, parentComponent } = suspense;
|
2881 | const el = (vnode.el = branch.el);
|
2882 |
|
2883 |
|
2884 | if (parentComponent && parentComponent.subTree === vnode) {
|
2885 | parentComponent.vnode.el = el;
|
2886 | updateHOCHostEl(parentComponent, el);
|
2887 | }
|
2888 | }
|
2889 |
|
2890 | function provide(key, value) {
|
2891 | if (!currentInstance) {
|
2892 | {
|
2893 | warn$1(`provide() can only be used inside setup().`);
|
2894 | }
|
2895 | }
|
2896 | else {
|
2897 | let provides = currentInstance.provides;
|
2898 |
|
2899 |
|
2900 |
|
2901 |
|
2902 |
|
2903 | const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
2904 | if (parentProvides === provides) {
|
2905 | provides = currentInstance.provides = Object.create(parentProvides);
|
2906 | }
|
2907 |
|
2908 | provides[key] = value;
|
2909 | }
|
2910 | }
|
2911 | function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
2912 |
|
2913 |
|
2914 | const instance = currentInstance || currentRenderingInstance;
|
2915 | if (instance) {
|
2916 |
|
2917 |
|
2918 |
|
2919 | const provides = instance.parent == null
|
2920 | ? instance.vnode.appContext && instance.vnode.appContext.provides
|
2921 | : instance.parent.provides;
|
2922 | if (provides && key in provides) {
|
2923 |
|
2924 | return provides[key];
|
2925 | }
|
2926 | else if (arguments.length > 1) {
|
2927 | return treatDefaultAsFactory && isFunction(defaultValue)
|
2928 | ? defaultValue.call(instance.proxy)
|
2929 | : defaultValue;
|
2930 | }
|
2931 | else {
|
2932 | warn$1(`injection "${String(key)}" not found.`);
|
2933 | }
|
2934 | }
|
2935 | else {
|
2936 | warn$1(`inject() can only be used inside setup() or functional components.`);
|
2937 | }
|
2938 | }
|
2939 |
|
2940 | function useTransitionState() {
|
2941 | const state = {
|
2942 | isMounted: false,
|
2943 | isLeaving: false,
|
2944 | isUnmounting: false,
|
2945 | leavingVNodes: new Map()
|
2946 | };
|
2947 | onMounted(() => {
|
2948 | state.isMounted = true;
|
2949 | });
|
2950 | onBeforeUnmount(() => {
|
2951 | state.isUnmounting = true;
|
2952 | });
|
2953 | return state;
|
2954 | }
|
2955 | const TransitionHookValidator = [Function, Array];
|
2956 | const BaseTransitionImpl = {
|
2957 | name: `BaseTransition`,
|
2958 | props: {
|
2959 | mode: String,
|
2960 | appear: Boolean,
|
2961 | persisted: Boolean,
|
2962 |
|
2963 | onBeforeEnter: TransitionHookValidator,
|
2964 | onEnter: TransitionHookValidator,
|
2965 | onAfterEnter: TransitionHookValidator,
|
2966 | onEnterCancelled: TransitionHookValidator,
|
2967 |
|
2968 | onBeforeLeave: TransitionHookValidator,
|
2969 | onLeave: TransitionHookValidator,
|
2970 | onAfterLeave: TransitionHookValidator,
|
2971 | onLeaveCancelled: TransitionHookValidator,
|
2972 |
|
2973 | onBeforeAppear: TransitionHookValidator,
|
2974 | onAppear: TransitionHookValidator,
|
2975 | onAfterAppear: TransitionHookValidator,
|
2976 | onAppearCancelled: TransitionHookValidator
|
2977 | },
|
2978 | setup(props, { slots }) {
|
2979 | const instance = getCurrentInstance();
|
2980 | const state = useTransitionState();
|
2981 | let prevTransitionKey;
|
2982 | return () => {
|
2983 | const children = slots.default && getTransitionRawChildren(slots.default(), true);
|
2984 | if (!children || !children.length) {
|
2985 | return;
|
2986 | }
|
2987 |
|
2988 | if (children.length > 1) {
|
2989 | warn$1('<transition> can only be used on a single element or component. Use ' +
|
2990 | '<transition-group> for lists.');
|
2991 | }
|
2992 |
|
2993 |
|
2994 | const rawProps = toRaw(props);
|
2995 | const { mode } = rawProps;
|
2996 |
|
2997 | if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
|
2998 | warn$1(`invalid <transition> mode: ${mode}`);
|
2999 | }
|
3000 |
|
3001 | const child = children[0];
|
3002 | if (state.isLeaving) {
|
3003 | return emptyPlaceholder(child);
|
3004 | }
|
3005 |
|
3006 |
|
3007 | const innerChild = getKeepAliveChild(child);
|
3008 | if (!innerChild) {
|
3009 | return emptyPlaceholder(child);
|
3010 | }
|
3011 | const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
|
3012 | setTransitionHooks(innerChild, enterHooks);
|
3013 | const oldChild = instance.subTree;
|
3014 | const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
|
3015 | let transitionKeyChanged = false;
|
3016 | const { getTransitionKey } = innerChild.type;
|
3017 | if (getTransitionKey) {
|
3018 | const key = getTransitionKey();
|
3019 | if (prevTransitionKey === undefined) {
|
3020 | prevTransitionKey = key;
|
3021 | }
|
3022 | else if (key !== prevTransitionKey) {
|
3023 | prevTransitionKey = key;
|
3024 | transitionKeyChanged = true;
|
3025 | }
|
3026 | }
|
3027 |
|
3028 | if (oldInnerChild &&
|
3029 | oldInnerChild.type !== Comment &&
|
3030 | (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
|
3031 | const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
|
3032 |
|
3033 | setTransitionHooks(oldInnerChild, leavingHooks);
|
3034 |
|
3035 | if (mode === 'out-in') {
|
3036 | state.isLeaving = true;
|
3037 |
|
3038 | leavingHooks.afterLeave = () => {
|
3039 | state.isLeaving = false;
|
3040 | instance.update();
|
3041 | };
|
3042 | return emptyPlaceholder(child);
|
3043 | }
|
3044 | else if (mode === 'in-out' && innerChild.type !== Comment) {
|
3045 | leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
|
3046 | const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
|
3047 | leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
|
3048 |
|
3049 | el._leaveCb = () => {
|
3050 | earlyRemove();
|
3051 | el._leaveCb = undefined;
|
3052 | delete enterHooks.delayedLeave;
|
3053 | };
|
3054 | enterHooks.delayedLeave = delayedLeave;
|
3055 | };
|
3056 | }
|
3057 | }
|
3058 | return child;
|
3059 | };
|
3060 | }
|
3061 | };
|
3062 |
|
3063 |
|
3064 | const BaseTransition = BaseTransitionImpl;
|
3065 | function getLeavingNodesForType(state, vnode) {
|
3066 | const { leavingVNodes } = state;
|
3067 | let leavingVNodesCache = leavingVNodes.get(vnode.type);
|
3068 | if (!leavingVNodesCache) {
|
3069 | leavingVNodesCache = Object.create(null);
|
3070 | leavingVNodes.set(vnode.type, leavingVNodesCache);
|
3071 | }
|
3072 | return leavingVNodesCache;
|
3073 | }
|
3074 |
|
3075 |
|
3076 | function resolveTransitionHooks(vnode, props, state, instance) {
|
3077 | const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
|
3078 | const key = String(vnode.key);
|
3079 | const leavingVNodesCache = getLeavingNodesForType(state, vnode);
|
3080 | const callHook = (hook, args) => {
|
3081 | hook &&
|
3082 | callWithAsyncErrorHandling(hook, instance, 9 , args);
|
3083 | };
|
3084 | const hooks = {
|
3085 | mode,
|
3086 | persisted,
|
3087 | beforeEnter(el) {
|
3088 | let hook = onBeforeEnter;
|
3089 | if (!state.isMounted) {
|
3090 | if (appear) {
|
3091 | hook = onBeforeAppear || onBeforeEnter;
|
3092 | }
|
3093 | else {
|
3094 | return;
|
3095 | }
|
3096 | }
|
3097 |
|
3098 | if (el._leaveCb) {
|
3099 | el._leaveCb(true );
|
3100 | }
|
3101 |
|
3102 | const leavingVNode = leavingVNodesCache[key];
|
3103 | if (leavingVNode &&
|
3104 | isSameVNodeType(vnode, leavingVNode) &&
|
3105 | leavingVNode.el._leaveCb) {
|
3106 |
|
3107 | leavingVNode.el._leaveCb();
|
3108 | }
|
3109 | callHook(hook, [el]);
|
3110 | },
|
3111 | enter(el) {
|
3112 | let hook = onEnter;
|
3113 | let afterHook = onAfterEnter;
|
3114 | let cancelHook = onEnterCancelled;
|
3115 | if (!state.isMounted) {
|
3116 | if (appear) {
|
3117 | hook = onAppear || onEnter;
|
3118 | afterHook = onAfterAppear || onAfterEnter;
|
3119 | cancelHook = onAppearCancelled || onEnterCancelled;
|
3120 | }
|
3121 | else {
|
3122 | return;
|
3123 | }
|
3124 | }
|
3125 | let called = false;
|
3126 | const done = (el._enterCb = (cancelled) => {
|
3127 | if (called)
|
3128 | return;
|
3129 | called = true;
|
3130 | if (cancelled) {
|
3131 | callHook(cancelHook, [el]);
|
3132 | }
|
3133 | else {
|
3134 | callHook(afterHook, [el]);
|
3135 | }
|
3136 | if (hooks.delayedLeave) {
|
3137 | hooks.delayedLeave();
|
3138 | }
|
3139 | el._enterCb = undefined;
|
3140 | });
|
3141 | if (hook) {
|
3142 | hook(el, done);
|
3143 | if (hook.length <= 1) {
|
3144 | done();
|
3145 | }
|
3146 | }
|
3147 | else {
|
3148 | done();
|
3149 | }
|
3150 | },
|
3151 | leave(el, remove) {
|
3152 | const key = String(vnode.key);
|
3153 | if (el._enterCb) {
|
3154 | el._enterCb(true );
|
3155 | }
|
3156 | if (state.isUnmounting) {
|
3157 | return remove();
|
3158 | }
|
3159 | callHook(onBeforeLeave, [el]);
|
3160 | let called = false;
|
3161 | const done = (el._leaveCb = (cancelled) => {
|
3162 | if (called)
|
3163 | return;
|
3164 | called = true;
|
3165 | remove();
|
3166 | if (cancelled) {
|
3167 | callHook(onLeaveCancelled, [el]);
|
3168 | }
|
3169 | else {
|
3170 | callHook(onAfterLeave, [el]);
|
3171 | }
|
3172 | el._leaveCb = undefined;
|
3173 | if (leavingVNodesCache[key] === vnode) {
|
3174 | delete leavingVNodesCache[key];
|
3175 | }
|
3176 | });
|
3177 | leavingVNodesCache[key] = vnode;
|
3178 | if (onLeave) {
|
3179 | onLeave(el, done);
|
3180 | if (onLeave.length <= 1) {
|
3181 | done();
|
3182 | }
|
3183 | }
|
3184 | else {
|
3185 | done();
|
3186 | }
|
3187 | },
|
3188 | clone(vnode) {
|
3189 | return resolveTransitionHooks(vnode, props, state, instance);
|
3190 | }
|
3191 | };
|
3192 | return hooks;
|
3193 | }
|
3194 |
|
3195 |
|
3196 |
|
3197 |
|
3198 | function emptyPlaceholder(vnode) {
|
3199 | if (isKeepAlive(vnode)) {
|
3200 | vnode = cloneVNode(vnode);
|
3201 | vnode.children = null;
|
3202 | return vnode;
|
3203 | }
|
3204 | }
|
3205 | function getKeepAliveChild(vnode) {
|
3206 | return isKeepAlive(vnode)
|
3207 | ? vnode.children
|
3208 | ? vnode.children[0]
|
3209 | : undefined
|
3210 | : vnode;
|
3211 | }
|
3212 | function setTransitionHooks(vnode, hooks) {
|
3213 | if (vnode.shapeFlag & 6 && vnode.component) {
|
3214 | setTransitionHooks(vnode.component.subTree, hooks);
|
3215 | }
|
3216 | else if (vnode.shapeFlag & 128 ) {
|
3217 | vnode.ssContent.transition = hooks.clone(vnode.ssContent);
|
3218 | vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
|
3219 | }
|
3220 | else {
|
3221 | vnode.transition = hooks;
|
3222 | }
|
3223 | }
|
3224 | function getTransitionRawChildren(children, keepComment = false) {
|
3225 | let ret = [];
|
3226 | let keyedFragmentCount = 0;
|
3227 | for (let i = 0; i < children.length; i++) {
|
3228 | const child = children[i];
|
3229 |
|
3230 | if (child.type === Fragment) {
|
3231 | if (child.patchFlag & 128 )
|
3232 | keyedFragmentCount++;
|
3233 | ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
|
3234 | }
|
3235 |
|
3236 | else if (keepComment || child.type !== Comment) {
|
3237 | ret.push(child);
|
3238 | }
|
3239 | }
|
3240 |
|
3241 |
|
3242 |
|
3243 |
|
3244 | if (keyedFragmentCount > 1) {
|
3245 | for (let i = 0; i < ret.length; i++) {
|
3246 | ret[i].patchFlag = -2 ;
|
3247 | }
|
3248 | }
|
3249 | return ret;
|
3250 | }
|
3251 |
|
3252 |
|
3253 | function defineComponent(options) {
|
3254 | return isFunction(options) ? { setup: options, name: options.name } : options;
|
3255 | }
|
3256 |
|
3257 | const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
|
3258 | function defineAsyncComponent(source) {
|
3259 | if (isFunction(source)) {
|
3260 | source = { loader: source };
|
3261 | }
|
3262 | const { loader, loadingComponent, errorComponent, delay = 200, timeout,
|
3263 | suspensible = true, onError: userOnError } = source;
|
3264 | let pendingRequest = null;
|
3265 | let resolvedComp;
|
3266 | let retries = 0;
|
3267 | const retry = () => {
|
3268 | retries++;
|
3269 | pendingRequest = null;
|
3270 | return load();
|
3271 | };
|
3272 | const load = () => {
|
3273 | let thisRequest;
|
3274 | return (pendingRequest ||
|
3275 | (thisRequest = pendingRequest =
|
3276 | loader()
|
3277 | .catch(err => {
|
3278 | err = err instanceof Error ? err : new Error(String(err));
|
3279 | if (userOnError) {
|
3280 | return new Promise((resolve, reject) => {
|
3281 | const userRetry = () => resolve(retry());
|
3282 | const userFail = () => reject(err);
|
3283 | userOnError(err, userRetry, userFail, retries + 1);
|
3284 | });
|
3285 | }
|
3286 | else {
|
3287 | throw err;
|
3288 | }
|
3289 | })
|
3290 | .then((comp) => {
|
3291 | if (thisRequest !== pendingRequest && pendingRequest) {
|
3292 | return pendingRequest;
|
3293 | }
|
3294 | if (!comp) {
|
3295 | warn$1(`Async component loader resolved to undefined. ` +
|
3296 | `If you are using retry(), make sure to return its return value.`);
|
3297 | }
|
3298 |
|
3299 | if (comp &&
|
3300 | (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
|
3301 | comp = comp.default;
|
3302 | }
|
3303 | if (comp && !isObject(comp) && !isFunction(comp)) {
|
3304 | throw new Error(`Invalid async component load result: ${comp}`);
|
3305 | }
|
3306 | resolvedComp = comp;
|
3307 | return comp;
|
3308 | })));
|
3309 | };
|
3310 | return defineComponent({
|
3311 | name: 'AsyncComponentWrapper',
|
3312 | __asyncLoader: load,
|
3313 | get __asyncResolved() {
|
3314 | return resolvedComp;
|
3315 | },
|
3316 | setup() {
|
3317 | const instance = currentInstance;
|
3318 |
|
3319 | if (resolvedComp) {
|
3320 | return () => createInnerComp(resolvedComp, instance);
|
3321 | }
|
3322 | const onError = (err) => {
|
3323 | pendingRequest = null;
|
3324 | handleError(err, instance, 13 , !errorComponent );
|
3325 | };
|
3326 |
|
3327 | if ((suspensible && instance.suspense) ||
|
3328 | (false )) {
|
3329 | return load()
|
3330 | .then(comp => {
|
3331 | return () => createInnerComp(comp, instance);
|
3332 | })
|
3333 | .catch(err => {
|
3334 | onError(err);
|
3335 | return () => errorComponent
|
3336 | ? createVNode(errorComponent, {
|
3337 | error: err
|
3338 | })
|
3339 | : null;
|
3340 | });
|
3341 | }
|
3342 | const loaded = ref(false);
|
3343 | const error = ref();
|
3344 | const delayed = ref(!!delay);
|
3345 | if (delay) {
|
3346 | setTimeout(() => {
|
3347 | delayed.value = false;
|
3348 | }, delay);
|
3349 | }
|
3350 | if (timeout != null) {
|
3351 | setTimeout(() => {
|
3352 | if (!loaded.value && !error.value) {
|
3353 | const err = new Error(`Async component timed out after ${timeout}ms.`);
|
3354 | onError(err);
|
3355 | error.value = err;
|
3356 | }
|
3357 | }, timeout);
|
3358 | }
|
3359 | load()
|
3360 | .then(() => {
|
3361 | loaded.value = true;
|
3362 | if (instance.parent && isKeepAlive(instance.parent.vnode)) {
|
3363 |
|
3364 |
|
3365 | queueJob(instance.parent.update);
|
3366 | }
|
3367 | })
|
3368 | .catch(err => {
|
3369 | onError(err);
|
3370 | error.value = err;
|
3371 | });
|
3372 | return () => {
|
3373 | if (loaded.value && resolvedComp) {
|
3374 | return createInnerComp(resolvedComp, instance);
|
3375 | }
|
3376 | else if (error.value && errorComponent) {
|
3377 | return createVNode(errorComponent, {
|
3378 | error: error.value
|
3379 | });
|
3380 | }
|
3381 | else if (loadingComponent && !delayed.value) {
|
3382 | return createVNode(loadingComponent);
|
3383 | }
|
3384 | };
|
3385 | }
|
3386 | });
|
3387 | }
|
3388 | function createInnerComp(comp, { vnode: { ref, props, children } }) {
|
3389 | const vnode = createVNode(comp, props, children);
|
3390 |
|
3391 | vnode.ref = ref;
|
3392 | return vnode;
|
3393 | }
|
3394 |
|
3395 | const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
3396 | const KeepAliveImpl = {
|
3397 | name: `KeepAlive`,
|
3398 |
|
3399 |
|
3400 |
|
3401 | __isKeepAlive: true,
|
3402 | props: {
|
3403 | include: [String, RegExp, Array],
|
3404 | exclude: [String, RegExp, Array],
|
3405 | max: [String, Number]
|
3406 | },
|
3407 | setup(props, { slots }) {
|
3408 | const instance = getCurrentInstance();
|
3409 |
|
3410 |
|
3411 |
|
3412 |
|
3413 |
|
3414 | const sharedContext = instance.ctx;
|
3415 |
|
3416 |
|
3417 | if (!sharedContext.renderer) {
|
3418 | return slots.default;
|
3419 | }
|
3420 | const cache = new Map();
|
3421 | const keys = new Set();
|
3422 | let current = null;
|
3423 | {
|
3424 | instance.__v_cache = cache;
|
3425 | }
|
3426 | const parentSuspense = instance.suspense;
|
3427 | const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
|
3428 | const storageContainer = createElement('div');
|
3429 | sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
|
3430 | const instance = vnode.component;
|
3431 | move(vnode, container, anchor, 0 , parentSuspense);
|
3432 |
|
3433 | patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
|
3434 | queuePostRenderEffect(() => {
|
3435 | instance.isDeactivated = false;
|
3436 | if (instance.a) {
|
3437 | invokeArrayFns(instance.a);
|
3438 | }
|
3439 | const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
|
3440 | if (vnodeHook) {
|
3441 | invokeVNodeHook(vnodeHook, instance.parent, vnode);
|
3442 | }
|
3443 | }, parentSuspense);
|
3444 | {
|
3445 |
|
3446 | devtoolsComponentAdded(instance);
|
3447 | }
|
3448 | };
|
3449 | sharedContext.deactivate = (vnode) => {
|
3450 | const instance = vnode.component;
|
3451 | move(vnode, storageContainer, null, 1 , parentSuspense);
|
3452 | queuePostRenderEffect(() => {
|
3453 | if (instance.da) {
|
3454 | invokeArrayFns(instance.da);
|
3455 | }
|
3456 | const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
|
3457 | if (vnodeHook) {
|
3458 | invokeVNodeHook(vnodeHook, instance.parent, vnode);
|
3459 | }
|
3460 | instance.isDeactivated = true;
|
3461 | }, parentSuspense);
|
3462 | {
|
3463 |
|
3464 | devtoolsComponentAdded(instance);
|
3465 | }
|
3466 | };
|
3467 | function unmount(vnode) {
|
3468 |
|
3469 | resetShapeFlag(vnode);
|
3470 | _unmount(vnode, instance, parentSuspense);
|
3471 | }
|
3472 | function pruneCache(filter) {
|
3473 | cache.forEach((vnode, key) => {
|
3474 | const name = getComponentName(vnode.type);
|
3475 | if (name && (!filter || !filter(name))) {
|
3476 | pruneCacheEntry(key);
|
3477 | }
|
3478 | });
|
3479 | }
|
3480 | function pruneCacheEntry(key) {
|
3481 | const cached = cache.get(key);
|
3482 | if (!current || cached.type !== current.type) {
|
3483 | unmount(cached);
|
3484 | }
|
3485 | else if (current) {
|
3486 |
|
3487 |
|
3488 | resetShapeFlag(current);
|
3489 | }
|
3490 | cache.delete(key);
|
3491 | keys.delete(key);
|
3492 | }
|
3493 |
|
3494 | watch(() => [props.include, props.exclude], ([include, exclude]) => {
|
3495 | include && pruneCache(name => matches(include, name));
|
3496 | exclude && pruneCache(name => !matches(exclude, name));
|
3497 | },
|
3498 |
|
3499 | { flush: 'post', deep: true });
|
3500 |
|
3501 | let pendingCacheKey = null;
|
3502 | const cacheSubtree = () => {
|
3503 |
|
3504 | if (pendingCacheKey != null) {
|
3505 | cache.set(pendingCacheKey, getInnerChild(instance.subTree));
|
3506 | }
|
3507 | };
|
3508 | onMounted(cacheSubtree);
|
3509 | onUpdated(cacheSubtree);
|
3510 | onBeforeUnmount(() => {
|
3511 | cache.forEach(cached => {
|
3512 | const { subTree, suspense } = instance;
|
3513 | const vnode = getInnerChild(subTree);
|
3514 | if (cached.type === vnode.type) {
|
3515 |
|
3516 | resetShapeFlag(vnode);
|
3517 |
|
3518 | const da = vnode.component.da;
|
3519 | da && queuePostRenderEffect(da, suspense);
|
3520 | return;
|
3521 | }
|
3522 | unmount(cached);
|
3523 | });
|
3524 | });
|
3525 | return () => {
|
3526 | pendingCacheKey = null;
|
3527 | if (!slots.default) {
|
3528 | return null;
|
3529 | }
|
3530 | const children = slots.default();
|
3531 | const rawVNode = children[0];
|
3532 | if (children.length > 1) {
|
3533 | {
|
3534 | warn$1(`KeepAlive should contain exactly one component child.`);
|
3535 | }
|
3536 | current = null;
|
3537 | return children;
|
3538 | }
|
3539 | else if (!isVNode(rawVNode) ||
|
3540 | (!(rawVNode.shapeFlag & 4 ) &&
|
3541 | !(rawVNode.shapeFlag & 128 ))) {
|
3542 | current = null;
|
3543 | return rawVNode;
|
3544 | }
|
3545 | let vnode = getInnerChild(rawVNode);
|
3546 | const comp = vnode.type;
|
3547 |
|
3548 |
|
3549 | const name = getComponentName(isAsyncWrapper(vnode)
|
3550 | ? vnode.type.__asyncResolved || {}
|
3551 | : comp);
|
3552 | const { include, exclude, max } = props;
|
3553 | if ((include && (!name || !matches(include, name))) ||
|
3554 | (exclude && name && matches(exclude, name))) {
|
3555 | current = vnode;
|
3556 | return rawVNode;
|
3557 | }
|
3558 | const key = vnode.key == null ? comp : vnode.key;
|
3559 | const cachedVNode = cache.get(key);
|
3560 |
|
3561 | if (vnode.el) {
|
3562 | vnode = cloneVNode(vnode);
|
3563 | if (rawVNode.shapeFlag & 128 ) {
|
3564 | rawVNode.ssContent = vnode;
|
3565 | }
|
3566 | }
|
3567 |
|
3568 |
|
3569 |
|
3570 |
|
3571 |
|
3572 | pendingCacheKey = key;
|
3573 | if (cachedVNode) {
|
3574 |
|
3575 | vnode.el = cachedVNode.el;
|
3576 | vnode.component = cachedVNode.component;
|
3577 | if (vnode.transition) {
|
3578 |
|
3579 | setTransitionHooks(vnode, vnode.transition);
|
3580 | }
|
3581 |
|
3582 | vnode.shapeFlag |= 512 ;
|
3583 |
|
3584 | keys.delete(key);
|
3585 | keys.add(key);
|
3586 | }
|
3587 | else {
|
3588 | keys.add(key);
|
3589 |
|
3590 | if (max && keys.size > parseInt(max, 10)) {
|
3591 | pruneCacheEntry(keys.values().next().value);
|
3592 | }
|
3593 | }
|
3594 |
|
3595 | vnode.shapeFlag |= 256 ;
|
3596 | current = vnode;
|
3597 | return rawVNode;
|
3598 | };
|
3599 | }
|
3600 | };
|
3601 |
|
3602 |
|
3603 | const KeepAlive = KeepAliveImpl;
|
3604 | function matches(pattern, name) {
|
3605 | if (isArray(pattern)) {
|
3606 | return pattern.some((p) => matches(p, name));
|
3607 | }
|
3608 | else if (isString(pattern)) {
|
3609 | return pattern.split(',').indexOf(name) > -1;
|
3610 | }
|
3611 | else if (pattern.test) {
|
3612 | return pattern.test(name);
|
3613 | }
|
3614 |
|
3615 | return false;
|
3616 | }
|
3617 | function onActivated(hook, target) {
|
3618 | registerKeepAliveHook(hook, "a" , target);
|
3619 | }
|
3620 | function onDeactivated(hook, target) {
|
3621 | registerKeepAliveHook(hook, "da" , target);
|
3622 | }
|
3623 | function registerKeepAliveHook(hook, type, target = currentInstance) {
|
3624 |
|
3625 |
|
3626 |
|
3627 | const wrappedHook = hook.__wdc ||
|
3628 | (hook.__wdc = () => {
|
3629 |
|
3630 | let current = target;
|
3631 | while (current) {
|
3632 | if (current.isDeactivated) {
|
3633 | return;
|
3634 | }
|
3635 | current = current.parent;
|
3636 | }
|
3637 | hook();
|
3638 | });
|
3639 | injectHook(type, wrappedHook, target);
|
3640 |
|
3641 |
|
3642 |
|
3643 |
|
3644 |
|
3645 | if (target) {
|
3646 | let current = target.parent;
|
3647 | while (current && current.parent) {
|
3648 | if (isKeepAlive(current.parent.vnode)) {
|
3649 | injectToKeepAliveRoot(wrappedHook, type, target, current);
|
3650 | }
|
3651 | current = current.parent;
|
3652 | }
|
3653 | }
|
3654 | }
|
3655 | function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
|
3656 |
|
3657 |
|
3658 | const injected = injectHook(type, hook, keepAliveRoot, true );
|
3659 | onUnmounted(() => {
|
3660 | remove(keepAliveRoot[type], injected);
|
3661 | }, target);
|
3662 | }
|
3663 | function resetShapeFlag(vnode) {
|
3664 | let shapeFlag = vnode.shapeFlag;
|
3665 | if (shapeFlag & 256 ) {
|
3666 | shapeFlag -= 256 ;
|
3667 | }
|
3668 | if (shapeFlag & 512 ) {
|
3669 | shapeFlag -= 512 ;
|
3670 | }
|
3671 | vnode.shapeFlag = shapeFlag;
|
3672 | }
|
3673 | function getInnerChild(vnode) {
|
3674 | return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
|
3675 | }
|
3676 |
|
3677 | function injectHook(type, hook, target = currentInstance, prepend = false) {
|
3678 | if (target) {
|
3679 | const hooks = target[type] || (target[type] = []);
|
3680 |
|
3681 |
|
3682 |
|
3683 | const wrappedHook = hook.__weh ||
|
3684 | (hook.__weh = (...args) => {
|
3685 | if (target.isUnmounted) {
|
3686 | return;
|
3687 | }
|
3688 |
|
3689 |
|
3690 | pauseTracking();
|
3691 |
|
3692 |
|
3693 |
|
3694 | setCurrentInstance(target);
|
3695 | const res = callWithAsyncErrorHandling(hook, target, type, args);
|
3696 | unsetCurrentInstance();
|
3697 | resetTracking();
|
3698 | return res;
|
3699 | });
|
3700 | if (prepend) {
|
3701 | hooks.unshift(wrappedHook);
|
3702 | }
|
3703 | else {
|
3704 | hooks.push(wrappedHook);
|
3705 | }
|
3706 | return wrappedHook;
|
3707 | }
|
3708 | else {
|
3709 | const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
|
3710 | warn$1(`${apiName} is called when there is no active component instance to be ` +
|
3711 | `associated with. ` +
|
3712 | `Lifecycle injection APIs can only be used during execution of setup().` +
|
3713 | (` If you are using async setup(), make sure to register lifecycle ` +
|
3714 | `hooks before the first await statement.`
|
3715 | ));
|
3716 | }
|
3717 | }
|
3718 | const createHook = (lifecycle) => (hook, target = currentInstance) =>
|
3719 |
|
3720 | (!isInSSRComponentSetup || lifecycle === "sp" ) &&
|
3721 | injectHook(lifecycle, hook, target);
|
3722 | const onBeforeMount = createHook("bm" );
|
3723 | const onMounted = createHook("m" );
|
3724 | const onBeforeUpdate = createHook("bu" );
|
3725 | const onUpdated = createHook("u" );
|
3726 | const onBeforeUnmount = createHook("bum" );
|
3727 | const onUnmounted = createHook("um" );
|
3728 | const onServerPrefetch = createHook("sp" );
|
3729 | const onRenderTriggered = createHook("rtg" );
|
3730 | const onRenderTracked = createHook("rtc" );
|
3731 | function onErrorCaptured(hook, target = currentInstance) {
|
3732 | injectHook("ec" , hook, target);
|
3733 | }
|
3734 |
|
3735 | function createDuplicateChecker() {
|
3736 | const cache = Object.create(null);
|
3737 | return (type, key) => {
|
3738 | if (cache[key]) {
|
3739 | warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
|
3740 | }
|
3741 | else {
|
3742 | cache[key] = type;
|
3743 | }
|
3744 | };
|
3745 | }
|
3746 | let shouldCacheAccess = true;
|
3747 | function applyOptions(instance) {
|
3748 | const options = resolveMergedOptions(instance);
|
3749 | const publicThis = instance.proxy;
|
3750 | const ctx = instance.ctx;
|
3751 |
|
3752 | shouldCacheAccess = false;
|
3753 |
|
3754 |
|
3755 | if (options.beforeCreate) {
|
3756 | callHook(options.beforeCreate, instance, "bc" );
|
3757 | }
|
3758 | const {
|
3759 |
|
3760 | data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
|
3761 |
|
3762 | created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
|
3763 |
|
3764 | expose, inheritAttrs,
|
3765 |
|
3766 | components, directives, filters } = options;
|
3767 | const checkDuplicateProperties = createDuplicateChecker() ;
|
3768 | {
|
3769 | const [propsOptions] = instance.propsOptions;
|
3770 | if (propsOptions) {
|
3771 | for (const key in propsOptions) {
|
3772 | checkDuplicateProperties("Props" , key);
|
3773 | }
|
3774 | }
|
3775 | }
|
3776 |
|
3777 |
|
3778 |
|
3779 |
|
3780 |
|
3781 |
|
3782 |
|
3783 | if (injectOptions) {
|
3784 | resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
|
3785 | }
|
3786 | if (methods) {
|
3787 | for (const key in methods) {
|
3788 | const methodHandler = methods[key];
|
3789 | if (isFunction(methodHandler)) {
|
3790 |
|
3791 |
|
3792 |
|
3793 | {
|
3794 | Object.defineProperty(ctx, key, {
|
3795 | value: methodHandler.bind(publicThis),
|
3796 | configurable: true,
|
3797 | enumerable: true,
|
3798 | writable: true
|
3799 | });
|
3800 | }
|
3801 | {
|
3802 | checkDuplicateProperties("Methods" , key);
|
3803 | }
|
3804 | }
|
3805 | else {
|
3806 | warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
|
3807 | `Did you reference the function correctly?`);
|
3808 | }
|
3809 | }
|
3810 | }
|
3811 | if (dataOptions) {
|
3812 | if (!isFunction(dataOptions)) {
|
3813 | warn$1(`The data option must be a function. ` +
|
3814 | `Plain object usage is no longer supported.`);
|
3815 | }
|
3816 | const data = dataOptions.call(publicThis, publicThis);
|
3817 | if (isPromise(data)) {
|
3818 | warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
|
3819 | `intend to perform data fetching before component renders, use ` +
|
3820 | `async setup() + <Suspense>.`);
|
3821 | }
|
3822 | if (!isObject(data)) {
|
3823 | warn$1(`data() should return an object.`);
|
3824 | }
|
3825 | else {
|
3826 | instance.data = reactive(data);
|
3827 | {
|
3828 | for (const key in data) {
|
3829 | checkDuplicateProperties("Data" , key);
|
3830 |
|
3831 | if (key[0] !== '$' && key[0] !== '_') {
|
3832 | Object.defineProperty(ctx, key, {
|
3833 | configurable: true,
|
3834 | enumerable: true,
|
3835 | get: () => data[key],
|
3836 | set: NOOP
|
3837 | });
|
3838 | }
|
3839 | }
|
3840 | }
|
3841 | }
|
3842 | }
|
3843 | // state initialization complete at this point - start caching access
|
3844 | shouldCacheAccess = true;
|
3845 | if (computedOptions) {
|
3846 | for (const key in computedOptions) {
|
3847 | const opt = computedOptions[key];
|
3848 | const get = isFunction(opt)
|
3849 | ? opt.bind(publicThis, publicThis)
|
3850 | : isFunction(opt.get)
|
3851 | ? opt.get.bind(publicThis, publicThis)
|
3852 | : NOOP;
|
3853 | if (get === NOOP) {
|
3854 | warn$1(`Computed property "${key}" has no getter.`);
|
3855 | }
|
3856 | const set = !isFunction(opt) && isFunction(opt.set)
|
3857 | ? opt.set.bind(publicThis)
|
3858 | : () => {
|
3859 | warn$1(`Write operation failed: computed property "${key}" is readonly.`);
|
3860 | }
|
3861 | ;
|
3862 | const c = computed({
|
3863 | get,
|
3864 | set
|
3865 | });
|
3866 | Object.defineProperty(ctx, key, {
|
3867 | enumerable: true,
|
3868 | configurable: true,
|
3869 | get: () => c.value,
|
3870 | set: v => (c.value = v)
|
3871 | });
|
3872 | {
|
3873 | checkDuplicateProperties("Computed" , key);
|
3874 | }
|
3875 | }
|
3876 | }
|
3877 | if (watchOptions) {
|
3878 | for (const key in watchOptions) {
|
3879 | createWatcher(watchOptions[key], ctx, publicThis, key);
|
3880 | }
|
3881 | }
|
3882 | if (provideOptions) {
|
3883 | const provides = isFunction(provideOptions)
|
3884 | ? provideOptions.call(publicThis)
|
3885 | : provideOptions;
|
3886 | Reflect.ownKeys(provides).forEach(key => {
|
3887 | provide(key, provides[key]);
|
3888 | });
|
3889 | }
|
3890 | if (created) {
|
3891 | callHook(created, instance, "c" );
|
3892 | }
|
3893 | function registerLifecycleHook(register, hook) {
|
3894 | if (isArray(hook)) {
|
3895 | hook.forEach(_hook => register(_hook.bind(publicThis)));
|
3896 | }
|
3897 | else if (hook) {
|
3898 | register(hook.bind(publicThis));
|
3899 | }
|
3900 | }
|
3901 | registerLifecycleHook(onBeforeMount, beforeMount);
|
3902 | registerLifecycleHook(onMounted, mounted);
|
3903 | registerLifecycleHook(onBeforeUpdate, beforeUpdate);
|
3904 | registerLifecycleHook(onUpdated, updated);
|
3905 | registerLifecycleHook(onActivated, activated);
|
3906 | registerLifecycleHook(onDeactivated, deactivated);
|
3907 | registerLifecycleHook(onErrorCaptured, errorCaptured);
|
3908 | registerLifecycleHook(onRenderTracked, renderTracked);
|
3909 | registerLifecycleHook(onRenderTriggered, renderTriggered);
|
3910 | registerLifecycleHook(onBeforeUnmount, beforeUnmount);
|
3911 | registerLifecycleHook(onUnmounted, unmounted);
|
3912 | registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
3913 | if (isArray(expose)) {
|
3914 | if (expose.length) {
|
3915 | const exposed = instance.exposed || (instance.exposed = {});
|
3916 | expose.forEach(key => {
|
3917 | Object.defineProperty(exposed, key, {
|
3918 | get: () => publicThis[key],
|
3919 | set: val => (publicThis[key] = val)
|
3920 | });
|
3921 | });
|
3922 | }
|
3923 | else if (!instance.exposed) {
|
3924 | instance.exposed = {};
|
3925 | }
|
3926 | }
|
3927 |
|
3928 |
|
3929 | if (render && instance.render === NOOP) {
|
3930 | instance.render = render;
|
3931 | }
|
3932 | if (inheritAttrs != null) {
|
3933 | instance.inheritAttrs = inheritAttrs;
|
3934 | }
|
3935 |
|
3936 | if (components)
|
3937 | instance.components = components;
|
3938 | if (directives)
|
3939 | instance.directives = directives;
|
3940 | }
|
3941 | function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
|
3942 | if (isArray(injectOptions)) {
|
3943 | injectOptions = normalizeInject(injectOptions);
|
3944 | }
|
3945 | for (const key in injectOptions) {
|
3946 | const opt = injectOptions[key];
|
3947 | let injected;
|
3948 | if (isObject(opt)) {
|
3949 | if ('default' in opt) {
|
3950 | injected = inject(opt.from || key, opt.default, true );
|
3951 | }
|
3952 | else {
|
3953 | injected = inject(opt.from || key);
|
3954 | }
|
3955 | }
|
3956 | else {
|
3957 | injected = inject(opt);
|
3958 | }
|
3959 | if (isRef(injected)) {
|
3960 |
|
3961 | if (unwrapRef) {
|
3962 | Object.defineProperty(ctx, key, {
|
3963 | enumerable: true,
|
3964 | configurable: true,
|
3965 | get: () => injected.value,
|
3966 | set: v => (injected.value = v)
|
3967 | });
|
3968 | }
|
3969 | else {
|
3970 | {
|
3971 | warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
|
3972 | `and no longer needs \`.value\` in the next minor release. ` +
|
3973 | `To opt-in to the new behavior now, ` +
|
3974 | `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
|
3975 | `temporary and will not be needed in the future.)`);
|
3976 | }
|
3977 | ctx[key] = injected;
|
3978 | }
|
3979 | }
|
3980 | else {
|
3981 | ctx[key] = injected;
|
3982 | }
|
3983 | {
|
3984 | checkDuplicateProperties("Inject" , key);
|
3985 | }
|
3986 | }
|
3987 | }
|
3988 | function callHook(hook, instance, type) {
|
3989 | callWithAsyncErrorHandling(isArray(hook)
|
3990 | ? hook.map(h => h.bind(instance.proxy))
|
3991 | : hook.bind(instance.proxy), instance, type);
|
3992 | }
|
3993 | function createWatcher(raw, ctx, publicThis, key) {
|
3994 | const getter = key.includes('.')
|
3995 | ? createPathGetter(publicThis, key)
|
3996 | : () => publicThis[key];
|
3997 | if (isString(raw)) {
|
3998 | const handler = ctx[raw];
|
3999 | if (isFunction(handler)) {
|
4000 | watch(getter, handler);
|
4001 | }
|
4002 | else {
|
4003 | warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
|
4004 | }
|
4005 | }
|
4006 | else if (isFunction(raw)) {
|
4007 | watch(getter, raw.bind(publicThis));
|
4008 | }
|
4009 | else if (isObject(raw)) {
|
4010 | if (isArray(raw)) {
|
4011 | raw.forEach(r => createWatcher(r, ctx, publicThis, key));
|
4012 | }
|
4013 | else {
|
4014 | const handler = isFunction(raw.handler)
|
4015 | ? raw.handler.bind(publicThis)
|
4016 | : ctx[raw.handler];
|
4017 | if (isFunction(handler)) {
|
4018 | watch(getter, handler, raw);
|
4019 | }
|
4020 | else {
|
4021 | warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
|
4022 | }
|
4023 | }
|
4024 | }
|
4025 | else {
|
4026 | warn$1(`Invalid watch option: "${key}"`, raw);
|
4027 | }
|
4028 | }
|
4029 | |
4030 |
|
4031 |
|
4032 |
|
4033 |
|
4034 | function resolveMergedOptions(instance) {
|
4035 | const base = instance.type;
|
4036 | const { mixins, extends: extendsOptions } = base;
|
4037 | const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
|
4038 | const cached = cache.get(base);
|
4039 | let resolved;
|
4040 | if (cached) {
|
4041 | resolved = cached;
|
4042 | }
|
4043 | else if (!globalMixins.length && !mixins && !extendsOptions) {
|
4044 | {
|
4045 | resolved = base;
|
4046 | }
|
4047 | }
|
4048 | else {
|
4049 | resolved = {};
|
4050 | if (globalMixins.length) {
|
4051 | globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
|
4052 | }
|
4053 | mergeOptions(resolved, base, optionMergeStrategies);
|
4054 | }
|
4055 | cache.set(base, resolved);
|
4056 | return resolved;
|
4057 | }
|
4058 | function mergeOptions(to, from, strats, asMixin = false) {
|
4059 | const { mixins, extends: extendsOptions } = from;
|
4060 | if (extendsOptions) {
|
4061 | mergeOptions(to, extendsOptions, strats, true);
|
4062 | }
|
4063 | if (mixins) {
|
4064 | mixins.forEach((m) => mergeOptions(to, m, strats, true));
|
4065 | }
|
4066 | for (const key in from) {
|
4067 | if (asMixin && key === 'expose') {
|
4068 | warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
|
4069 | `It should only be declared in the base component itself.`);
|
4070 | }
|
4071 | else {
|
4072 | const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
|
4073 | to[key] = strat ? strat(to[key], from[key]) : from[key];
|
4074 | }
|
4075 | }
|
4076 | return to;
|
4077 | }
|
4078 | const internalOptionMergeStrats = {
|
4079 | data: mergeDataFn,
|
4080 | props: mergeObjectOptions,
|
4081 | emits: mergeObjectOptions,
|
4082 |
|
4083 | methods: mergeObjectOptions,
|
4084 | computed: mergeObjectOptions,
|
4085 |
|
4086 | beforeCreate: mergeAsArray,
|
4087 | created: mergeAsArray,
|
4088 | beforeMount: mergeAsArray,
|
4089 | mounted: mergeAsArray,
|
4090 | beforeUpdate: mergeAsArray,
|
4091 | updated: mergeAsArray,
|
4092 | beforeDestroy: mergeAsArray,
|
4093 | beforeUnmount: mergeAsArray,
|
4094 | destroyed: mergeAsArray,
|
4095 | unmounted: mergeAsArray,
|
4096 | activated: mergeAsArray,
|
4097 | deactivated: mergeAsArray,
|
4098 | errorCaptured: mergeAsArray,
|
4099 | serverPrefetch: mergeAsArray,
|
4100 |
|
4101 | components: mergeObjectOptions,
|
4102 | directives: mergeObjectOptions,
|
4103 |
|
4104 | watch: mergeWatchOptions,
|
4105 |
|
4106 | provide: mergeDataFn,
|
4107 | inject: mergeInject
|
4108 | };
|
4109 | function mergeDataFn(to, from) {
|
4110 | if (!from) {
|
4111 | return to;
|
4112 | }
|
4113 | if (!to) {
|
4114 | return from;
|
4115 | }
|
4116 | return function mergedDataFn() {
|
4117 | return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
|
4118 | };
|
4119 | }
|
4120 | function mergeInject(to, from) {
|
4121 | return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
4122 | }
|
4123 | function normalizeInject(raw) {
|
4124 | if (isArray(raw)) {
|
4125 | const res = {};
|
4126 | for (let i = 0; i < raw.length; i++) {
|
4127 | res[raw[i]] = raw[i];
|
4128 | }
|
4129 | return res;
|
4130 | }
|
4131 | return raw;
|
4132 | }
|
4133 | function mergeAsArray(to, from) {
|
4134 | return to ? [...new Set([].concat(to, from))] : from;
|
4135 | }
|
4136 | function mergeObjectOptions(to, from) {
|
4137 | return to ? extend(extend(Object.create(null), to), from) : from;
|
4138 | }
|
4139 | function mergeWatchOptions(to, from) {
|
4140 | if (!to)
|
4141 | return from;
|
4142 | if (!from)
|
4143 | return to;
|
4144 | const merged = extend(Object.create(null), to);
|
4145 | for (const key in from) {
|
4146 | merged[key] = mergeAsArray(to[key], from[key]);
|
4147 | }
|
4148 | return merged;
|
4149 | }
|
4150 |
|
4151 | function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
|
4152 | isSSR = false) {
|
4153 | const props = {};
|
4154 | const attrs = {};
|
4155 | def(attrs, InternalObjectKey, 1);
|
4156 | instance.propsDefaults = Object.create(null);
|
4157 | setFullProps(instance, rawProps, props, attrs);
|
4158 |
|
4159 | for (const key in instance.propsOptions[0]) {
|
4160 | if (!(key in props)) {
|
4161 | props[key] = undefined;
|
4162 | }
|
4163 | }
|
4164 |
|
4165 | {
|
4166 | validateProps(rawProps || {}, props, instance);
|
4167 | }
|
4168 | if (isStateful) {
|
4169 |
|
4170 | instance.props = isSSR ? props : shallowReactive(props);
|
4171 | }
|
4172 | else {
|
4173 | if (!instance.type.props) {
|
4174 |
|
4175 | instance.props = attrs;
|
4176 | }
|
4177 | else {
|
4178 |
|
4179 | instance.props = props;
|
4180 | }
|
4181 | }
|
4182 | instance.attrs = attrs;
|
4183 | }
|
4184 | function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
4185 | const { props, attrs, vnode: { patchFlag } } = instance;
|
4186 | const rawCurrentProps = toRaw(props);
|
4187 | const [options] = instance.propsOptions;
|
4188 | let hasAttrsChanged = false;
|
4189 | if (
|
4190 |
|
4191 |
|
4192 |
|
4193 | !((instance.type.__hmrId ||
|
4194 | (instance.parent && instance.parent.type.__hmrId))) &&
|
4195 | (optimized || patchFlag > 0) &&
|
4196 | !(patchFlag & 16 )) {
|
4197 | if (patchFlag & 8 ) {
|
4198 |
|
4199 |
|
4200 | const propsToUpdate = instance.vnode.dynamicProps;
|
4201 | for (let i = 0; i < propsToUpdate.length; i++) {
|
4202 | let key = propsToUpdate[i];
|
4203 |
|
4204 | const value = rawProps[key];
|
4205 | if (options) {
|
4206 |
|
4207 |
|
4208 | if (hasOwn(attrs, key)) {
|
4209 | if (value !== attrs[key]) {
|
4210 | attrs[key] = value;
|
4211 | hasAttrsChanged = true;
|
4212 | }
|
4213 | }
|
4214 | else {
|
4215 | const camelizedKey = camelize(key);
|
4216 | props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false );
|
4217 | }
|
4218 | }
|
4219 | else {
|
4220 | if (value !== attrs[key]) {
|
4221 | attrs[key] = value;
|
4222 | hasAttrsChanged = true;
|
4223 | }
|
4224 | }
|
4225 | }
|
4226 | }
|
4227 | }
|
4228 | else {
|
4229 |
|
4230 | if (setFullProps(instance, rawProps, props, attrs)) {
|
4231 | hasAttrsChanged = true;
|
4232 | }
|
4233 |
|
4234 |
|
4235 | let kebabKey;
|
4236 | for (const key in rawCurrentProps) {
|
4237 | if (!rawProps ||
|
4238 |
|
4239 | (!hasOwn(rawProps, key) &&
|
4240 |
|
4241 |
|
4242 | ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
|
4243 | if (options) {
|
4244 | if (rawPrevProps &&
|
4245 |
|
4246 | (rawPrevProps[key] !== undefined ||
|
4247 |
|
4248 | rawPrevProps[kebabKey] !== undefined)) {
|
4249 | props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true );
|
4250 | }
|
4251 | }
|
4252 | else {
|
4253 | delete props[key];
|
4254 | }
|
4255 | }
|
4256 | }
|
4257 |
|
4258 |
|
4259 | if (attrs !== rawCurrentProps) {
|
4260 | for (const key in attrs) {
|
4261 | if (!rawProps || !hasOwn(rawProps, key)) {
|
4262 | delete attrs[key];
|
4263 | hasAttrsChanged = true;
|
4264 | }
|
4265 | }
|
4266 | }
|
4267 | }
|
4268 |
|
4269 | if (hasAttrsChanged) {
|
4270 | trigger(instance, "set" , '$attrs');
|
4271 | }
|
4272 | {
|
4273 | validateProps(rawProps || {}, props, instance);
|
4274 | }
|
4275 | }
|
4276 | function setFullProps(instance, rawProps, props, attrs) {
|
4277 | const [options, needCastKeys] = instance.propsOptions;
|
4278 | let hasAttrsChanged = false;
|
4279 | let rawCastValues;
|
4280 | if (rawProps) {
|
4281 | for (let key in rawProps) {
|
4282 |
|
4283 | if (isReservedProp(key)) {
|
4284 | continue;
|
4285 | }
|
4286 | const value = rawProps[key];
|
4287 |
|
4288 |
|
4289 | let camelKey;
|
4290 | if (options && hasOwn(options, (camelKey = camelize(key)))) {
|
4291 | if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
4292 | props[camelKey] = value;
|
4293 | }
|
4294 | else {
|
4295 | (rawCastValues || (rawCastValues = {}))[camelKey] = value;
|
4296 | }
|
4297 | }
|
4298 | else if (!isEmitListener(instance.emitsOptions, key)) {
|
4299 | if (value !== attrs[key]) {
|
4300 | attrs[key] = value;
|
4301 | hasAttrsChanged = true;
|
4302 | }
|
4303 | }
|
4304 | }
|
4305 | }
|
4306 | if (needCastKeys) {
|
4307 | const rawCurrentProps = toRaw(props);
|
4308 | const castValues = rawCastValues || EMPTY_OBJ;
|
4309 | for (let i = 0; i < needCastKeys.length; i++) {
|
4310 | const key = needCastKeys[i];
|
4311 | props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
|
4312 | }
|
4313 | }
|
4314 | return hasAttrsChanged;
|
4315 | }
|
4316 | function resolvePropValue(options, props, key, value, instance, isAbsent) {
|
4317 | const opt = options[key];
|
4318 | if (opt != null) {
|
4319 | const hasDefault = hasOwn(opt, 'default');
|
4320 |
|
4321 | if (hasDefault && value === undefined) {
|
4322 | const defaultValue = opt.default;
|
4323 | if (opt.type !== Function && isFunction(defaultValue)) {
|
4324 | const { propsDefaults } = instance;
|
4325 | if (key in propsDefaults) {
|
4326 | value = propsDefaults[key];
|
4327 | }
|
4328 | else {
|
4329 | setCurrentInstance(instance);
|
4330 | value = propsDefaults[key] = defaultValue.call(null, props);
|
4331 | unsetCurrentInstance();
|
4332 | }
|
4333 | }
|
4334 | else {
|
4335 | value = defaultValue;
|
4336 | }
|
4337 | }
|
4338 |
|
4339 | if (opt[0 ]) {
|
4340 | if (isAbsent && !hasDefault) {
|
4341 | value = false;
|
4342 | }
|
4343 | else if (opt[1 ] &&
|
4344 | (value === '' || value === hyphenate(key))) {
|
4345 | value = true;
|
4346 | }
|
4347 | }
|
4348 | }
|
4349 | return value;
|
4350 | }
|
4351 | function normalizePropsOptions(comp, appContext, asMixin = false) {
|
4352 | const cache = appContext.propsCache;
|
4353 | const cached = cache.get(comp);
|
4354 | if (cached) {
|
4355 | return cached;
|
4356 | }
|
4357 | const raw = comp.props;
|
4358 | const normalized = {};
|
4359 | const needCastKeys = [];
|
4360 |
|
4361 | let hasExtends = false;
|
4362 | if (!isFunction(comp)) {
|
4363 | const extendProps = (raw) => {
|
4364 | hasExtends = true;
|
4365 | const [props, keys] = normalizePropsOptions(raw, appContext, true);
|
4366 | extend(normalized, props);
|
4367 | if (keys)
|
4368 | needCastKeys.push(...keys);
|
4369 | };
|
4370 | if (!asMixin && appContext.mixins.length) {
|
4371 | appContext.mixins.forEach(extendProps);
|
4372 | }
|
4373 | if (comp.extends) {
|
4374 | extendProps(comp.extends);
|
4375 | }
|
4376 | if (comp.mixins) {
|
4377 | comp.mixins.forEach(extendProps);
|
4378 | }
|
4379 | }
|
4380 | if (!raw && !hasExtends) {
|
4381 | cache.set(comp, EMPTY_ARR);
|
4382 | return EMPTY_ARR;
|
4383 | }
|
4384 | if (isArray(raw)) {
|
4385 | for (let i = 0; i < raw.length; i++) {
|
4386 | if (!isString(raw[i])) {
|
4387 | warn$1(`props must be strings when using array syntax.`, raw[i]);
|
4388 | }
|
4389 | const normalizedKey = camelize(raw[i]);
|
4390 | if (validatePropName(normalizedKey)) {
|
4391 | normalized[normalizedKey] = EMPTY_OBJ;
|
4392 | }
|
4393 | }
|
4394 | }
|
4395 | else if (raw) {
|
4396 | if (!isObject(raw)) {
|
4397 | warn$1(`invalid props options`, raw);
|
4398 | }
|
4399 | for (const key in raw) {
|
4400 | const normalizedKey = camelize(key);
|
4401 | if (validatePropName(normalizedKey)) {
|
4402 | const opt = raw[key];
|
4403 | const prop = (normalized[normalizedKey] =
|
4404 | isArray(opt) || isFunction(opt) ? { type: opt } : opt);
|
4405 | if (prop) {
|
4406 | const booleanIndex = getTypeIndex(Boolean, prop.type);
|
4407 | const stringIndex = getTypeIndex(String, prop.type);
|
4408 | prop[0 ] = booleanIndex > -1;
|
4409 | prop[1 ] =
|
4410 | stringIndex < 0 || booleanIndex < stringIndex;
|
4411 |
|
4412 | if (booleanIndex > -1 || hasOwn(prop, 'default')) {
|
4413 | needCastKeys.push(normalizedKey);
|
4414 | }
|
4415 | }
|
4416 | }
|
4417 | }
|
4418 | }
|
4419 | const res = [normalized, needCastKeys];
|
4420 | cache.set(comp, res);
|
4421 | return res;
|
4422 | }
|
4423 | function validatePropName(key) {
|
4424 | if (key[0] !== '$') {
|
4425 | return true;
|
4426 | }
|
4427 | else {
|
4428 | warn$1(`Invalid prop name: "${key}" is a reserved property.`);
|
4429 | }
|
4430 | return false;
|
4431 | }
|
4432 |
|
4433 |
|
4434 | function getType(ctor) {
|
4435 | const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
|
4436 | return match ? match[1] : ctor === null ? 'null' : '';
|
4437 | }
|
4438 | function isSameType(a, b) {
|
4439 | return getType(a) === getType(b);
|
4440 | }
|
4441 | function getTypeIndex(type, expectedTypes) {
|
4442 | if (isArray(expectedTypes)) {
|
4443 | return expectedTypes.findIndex(t => isSameType(t, type));
|
4444 | }
|
4445 | else if (isFunction(expectedTypes)) {
|
4446 | return isSameType(expectedTypes, type) ? 0 : -1;
|
4447 | }
|
4448 | return -1;
|
4449 | }
|
4450 | |
4451 |
|
4452 |
|
4453 | function validateProps(rawProps, props, instance) {
|
4454 | const resolvedValues = toRaw(props);
|
4455 | const options = instance.propsOptions[0];
|
4456 | for (const key in options) {
|
4457 | let opt = options[key];
|
4458 | if (opt == null)
|
4459 | continue;
|
4460 | validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
|
4461 | }
|
4462 | }
|
4463 | |
4464 |
|
4465 |
|
4466 | function validateProp(name, value, prop, isAbsent) {
|
4467 | const { type, required, validator } = prop;
|
4468 |
|
4469 | if (required && isAbsent) {
|
4470 | warn$1('Missing required prop: "' + name + '"');
|
4471 | return;
|
4472 | }
|
4473 |
|
4474 | if (value == null && !prop.required) {
|
4475 | return;
|
4476 | }
|
4477 |
|
4478 | if (type != null && type !== true) {
|
4479 | let isValid = false;
|
4480 | const types = isArray(type) ? type : [type];
|
4481 | const expectedTypes = [];
|
4482 |
|
4483 | for (let i = 0; i < types.length && !isValid; i++) {
|
4484 | const { valid, expectedType } = assertType(value, types[i]);
|
4485 | expectedTypes.push(expectedType || '');
|
4486 | isValid = valid;
|
4487 | }
|
4488 | if (!isValid) {
|
4489 | warn$1(getInvalidTypeMessage(name, value, expectedTypes));
|
4490 | return;
|
4491 | }
|
4492 | }
|
4493 |
|
4494 | if (validator && !validator(value)) {
|
4495 | warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
|
4496 | }
|
4497 | }
|
4498 | const isSimpleType = makeMap('String,Number,Boolean,Function,Symbol,BigInt');
|
4499 | |
4500 |
|
4501 |
|
4502 | function assertType(value, type) {
|
4503 | let valid;
|
4504 | const expectedType = getType(type);
|
4505 | if (isSimpleType(expectedType)) {
|
4506 | const t = typeof value;
|
4507 | valid = t === expectedType.toLowerCase();
|
4508 |
|
4509 | if (!valid && t === 'object') {
|
4510 | valid = value instanceof type;
|
4511 | }
|
4512 | }
|
4513 | else if (expectedType === 'Object') {
|
4514 | valid = isObject(value);
|
4515 | }
|
4516 | else if (expectedType === 'Array') {
|
4517 | valid = isArray(value);
|
4518 | }
|
4519 | else if (expectedType === 'null') {
|
4520 | valid = value === null;
|
4521 | }
|
4522 | else {
|
4523 | valid = value instanceof type;
|
4524 | }
|
4525 | return {
|
4526 | valid,
|
4527 | expectedType
|
4528 | };
|
4529 | }
|
4530 | |
4531 |
|
4532 |
|
4533 | function getInvalidTypeMessage(name, value, expectedTypes) {
|
4534 | let message = `Invalid prop: type check failed for prop "${name}".` +
|
4535 | ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
|
4536 | const expectedType = expectedTypes[0];
|
4537 | const receivedType = toRawType(value);
|
4538 | const expectedValue = styleValue(value, expectedType);
|
4539 | const receivedValue = styleValue(value, receivedType);
|
4540 |
|
4541 | if (expectedTypes.length === 1 &&
|
4542 | isExplicable(expectedType) &&
|
4543 | !isBoolean(expectedType, receivedType)) {
|
4544 | message += ` with value ${expectedValue}`;
|
4545 | }
|
4546 | message += `, got ${receivedType} `;
|
4547 |
|
4548 | if (isExplicable(receivedType)) {
|
4549 | message += `with value ${receivedValue}.`;
|
4550 | }
|
4551 | return message;
|
4552 | }
|
4553 | |
4554 |
|
4555 |
|
4556 | function styleValue(value, type) {
|
4557 | if (type === 'String') {
|
4558 | return `"${value}"`;
|
4559 | }
|
4560 | else if (type === 'Number') {
|
4561 | return `${Number(value)}`;
|
4562 | }
|
4563 | else {
|
4564 | return `${value}`;
|
4565 | }
|
4566 | }
|
4567 | |
4568 |
|
4569 |
|
4570 | function isExplicable(type) {
|
4571 | const explicitTypes = ['string', 'number', 'boolean'];
|
4572 | return explicitTypes.some(elem => type.toLowerCase() === elem);
|
4573 | }
|
4574 | |
4575 |
|
4576 |
|
4577 | function isBoolean(...args) {
|
4578 | return args.some(elem => elem.toLowerCase() === 'boolean');
|
4579 | }
|
4580 |
|
4581 | const isInternalKey = (key) => key[0] === '_' || key === '$stable';
|
4582 | const normalizeSlotValue = (value) => isArray(value)
|
4583 | ? value.map(normalizeVNode)
|
4584 | : [normalizeVNode(value)];
|
4585 | const normalizeSlot = (key, rawSlot, ctx) => {
|
4586 | const normalized = withCtx((...args) => {
|
4587 | if (currentInstance) {
|
4588 | warn$1(`Slot "${key}" invoked outside of the render function: ` +
|
4589 | `this will not track dependencies used in the slot. ` +
|
4590 | `Invoke the slot function inside the render function instead.`);
|
4591 | }
|
4592 | return normalizeSlotValue(rawSlot(...args));
|
4593 | }, ctx);
|
4594 | normalized._c = false;
|
4595 | return normalized;
|
4596 | };
|
4597 | const normalizeObjectSlots = (rawSlots, slots, instance) => {
|
4598 | const ctx = rawSlots._ctx;
|
4599 | for (const key in rawSlots) {
|
4600 | if (isInternalKey(key))
|
4601 | continue;
|
4602 | const value = rawSlots[key];
|
4603 | if (isFunction(value)) {
|
4604 | slots[key] = normalizeSlot(key, value, ctx);
|
4605 | }
|
4606 | else if (value != null) {
|
4607 | {
|
4608 | warn$1(`Non-function value encountered for slot "${key}". ` +
|
4609 | `Prefer function slots for better performance.`);
|
4610 | }
|
4611 | const normalized = normalizeSlotValue(value);
|
4612 | slots[key] = () => normalized;
|
4613 | }
|
4614 | }
|
4615 | };
|
4616 | const normalizeVNodeSlots = (instance, children) => {
|
4617 | if (!isKeepAlive(instance.vnode) &&
|
4618 | !(false )) {
|
4619 | warn$1(`Non-function value encountered for default slot. ` +
|
4620 | `Prefer function slots for better performance.`);
|
4621 | }
|
4622 | const normalized = normalizeSlotValue(children);
|
4623 | instance.slots.default = () => normalized;
|
4624 | };
|
4625 | const initSlots = (instance, children) => {
|
4626 | if (instance.vnode.shapeFlag & 32 ) {
|
4627 | const type = children._;
|
4628 | if (type) {
|
4629 |
|
4630 |
|
4631 | instance.slots = toRaw(children);
|
4632 |
|
4633 | def(children, '_', type);
|
4634 | }
|
4635 | else {
|
4636 | normalizeObjectSlots(children, (instance.slots = {}));
|
4637 | }
|
4638 | }
|
4639 | else {
|
4640 | instance.slots = {};
|
4641 | if (children) {
|
4642 | normalizeVNodeSlots(instance, children);
|
4643 | }
|
4644 | }
|
4645 | def(instance.slots, InternalObjectKey, 1);
|
4646 | };
|
4647 | const updateSlots = (instance, children, optimized) => {
|
4648 | const { vnode, slots } = instance;
|
4649 | let needDeletionCheck = true;
|
4650 | let deletionComparisonTarget = EMPTY_OBJ;
|
4651 | if (vnode.shapeFlag & 32 ) {
|
4652 | const type = children._;
|
4653 | if (type) {
|
4654 |
|
4655 | if (isHmrUpdating) {
|
4656 |
|
4657 |
|
4658 | extend(slots, children);
|
4659 | }
|
4660 | else if (optimized && type === 1 ) {
|
4661 |
|
4662 |
|
4663 | needDeletionCheck = false;
|
4664 | }
|
4665 | else {
|
4666 |
|
4667 |
|
4668 | extend(slots, children);
|
4669 |
|
4670 |
|
4671 |
|
4672 |
|
4673 | if (!optimized && type === 1 ) {
|
4674 | delete slots._;
|
4675 | }
|
4676 | }
|
4677 | }
|
4678 | else {
|
4679 | needDeletionCheck = !children.$stable;
|
4680 | normalizeObjectSlots(children, slots);
|
4681 | }
|
4682 | deletionComparisonTarget = children;
|
4683 | }
|
4684 | else if (children) {
|
4685 |
|
4686 | normalizeVNodeSlots(instance, children);
|
4687 | deletionComparisonTarget = { default: 1 };
|
4688 | }
|
4689 |
|
4690 | if (needDeletionCheck) {
|
4691 | for (const key in slots) {
|
4692 | if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
|
4693 | delete slots[key];
|
4694 | }
|
4695 | }
|
4696 | }
|
4697 | };
|
4698 |
|
4699 | |
4700 |
|
4701 |
|
4702 |
|
4703 |
|
4704 |
|
4705 |
|
4706 |
|
4707 |
|
4708 |
|
4709 |
|
4710 |
|
4711 | const isBuiltInDirective = makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
|
4712 | function validateDirectiveName(name) {
|
4713 | if (isBuiltInDirective(name)) {
|
4714 | warn$1('Do not use built-in directive ids as custom directive id: ' + name);
|
4715 | }
|
4716 | }
|
4717 | |
4718 |
|
4719 |
|
4720 | function withDirectives(vnode, directives) {
|
4721 | const internalInstance = currentRenderingInstance;
|
4722 | if (internalInstance === null) {
|
4723 | warn$1(`withDirectives can only be used inside render functions.`);
|
4724 | return vnode;
|
4725 | }
|
4726 | const instance = internalInstance.proxy;
|
4727 | const bindings = vnode.dirs || (vnode.dirs = []);
|
4728 | for (let i = 0; i < directives.length; i++) {
|
4729 | let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
|
4730 | if (isFunction(dir)) {
|
4731 | dir = {
|
4732 | mounted: dir,
|
4733 | updated: dir
|
4734 | };
|
4735 | }
|
4736 | if (dir.deep) {
|
4737 | traverse(value);
|
4738 | }
|
4739 | bindings.push({
|
4740 | dir,
|
4741 | instance,
|
4742 | value,
|
4743 | oldValue: void 0,
|
4744 | arg,
|
4745 | modifiers
|
4746 | });
|
4747 | }
|
4748 | return vnode;
|
4749 | }
|
4750 | function invokeDirectiveHook(vnode, prevVNode, instance, name) {
|
4751 | const bindings = vnode.dirs;
|
4752 | const oldBindings = prevVNode && prevVNode.dirs;
|
4753 | for (let i = 0; i < bindings.length; i++) {
|
4754 | const binding = bindings[i];
|
4755 | if (oldBindings) {
|
4756 | binding.oldValue = oldBindings[i].value;
|
4757 | }
|
4758 | let hook = binding.dir[name];
|
4759 | if (hook) {
|
4760 |
|
4761 |
|
4762 | pauseTracking();
|
4763 | callWithAsyncErrorHandling(hook, instance, 8 , [
|
4764 | vnode.el,
|
4765 | binding,
|
4766 | vnode,
|
4767 | prevVNode
|
4768 | ]);
|
4769 | resetTracking();
|
4770 | }
|
4771 | }
|
4772 | }
|
4773 |
|
4774 | function createAppContext() {
|
4775 | return {
|
4776 | app: null,
|
4777 | config: {
|
4778 | isNativeTag: NO,
|
4779 | performance: false,
|
4780 | globalProperties: {},
|
4781 | optionMergeStrategies: {},
|
4782 | errorHandler: undefined,
|
4783 | warnHandler: undefined,
|
4784 | compilerOptions: {}
|
4785 | },
|
4786 | mixins: [],
|
4787 | components: {},
|
4788 | directives: {},
|
4789 | provides: Object.create(null),
|
4790 | optionsCache: new WeakMap(),
|
4791 | propsCache: new WeakMap(),
|
4792 | emitsCache: new WeakMap()
|
4793 | };
|
4794 | }
|
4795 | let uid = 0;
|
4796 | function createAppAPI(render, hydrate) {
|
4797 | return function createApp(rootComponent, rootProps = null) {
|
4798 | if (rootProps != null && !isObject(rootProps)) {
|
4799 | warn$1(`root props passed to app.mount() must be an object.`);
|
4800 | rootProps = null;
|
4801 | }
|
4802 | const context = createAppContext();
|
4803 | const installedPlugins = new Set();
|
4804 | let isMounted = false;
|
4805 | const app = (context.app = {
|
4806 | _uid: uid++,
|
4807 | _component: rootComponent,
|
4808 | _props: rootProps,
|
4809 | _container: null,
|
4810 | _context: context,
|
4811 | _instance: null,
|
4812 | version,
|
4813 | get config() {
|
4814 | return context.config;
|
4815 | },
|
4816 | set config(v) {
|
4817 | {
|
4818 | warn$1(`app.config cannot be replaced. Modify individual options instead.`);
|
4819 | }
|
4820 | },
|
4821 | use(plugin, ...options) {
|
4822 | if (installedPlugins.has(plugin)) {
|
4823 | warn$1(`Plugin has already been applied to target app.`);
|
4824 | }
|
4825 | else if (plugin && isFunction(plugin.install)) {
|
4826 | installedPlugins.add(plugin);
|
4827 | plugin.install(app, ...options);
|
4828 | }
|
4829 | else if (isFunction(plugin)) {
|
4830 | installedPlugins.add(plugin);
|
4831 | plugin(app, ...options);
|
4832 | }
|
4833 | else {
|
4834 | warn$1(`A plugin must either be a function or an object with an "install" ` +
|
4835 | `function.`);
|
4836 | }
|
4837 | return app;
|
4838 | },
|
4839 | mixin(mixin) {
|
4840 | {
|
4841 | if (!context.mixins.includes(mixin)) {
|
4842 | context.mixins.push(mixin);
|
4843 | }
|
4844 | else {
|
4845 | warn$1('Mixin has already been applied to target app' +
|
4846 | (mixin.name ? `: ${mixin.name}` : ''));
|
4847 | }
|
4848 | }
|
4849 | return app;
|
4850 | },
|
4851 | component(name, component) {
|
4852 | {
|
4853 | validateComponentName(name, context.config);
|
4854 | }
|
4855 | if (!component) {
|
4856 | return context.components[name];
|
4857 | }
|
4858 | if (context.components[name]) {
|
4859 | warn$1(`Component "${name}" has already been registered in target app.`);
|
4860 | }
|
4861 | context.components[name] = component;
|
4862 | return app;
|
4863 | },
|
4864 | directive(name, directive) {
|
4865 | {
|
4866 | validateDirectiveName(name);
|
4867 | }
|
4868 | if (!directive) {
|
4869 | return context.directives[name];
|
4870 | }
|
4871 | if (context.directives[name]) {
|
4872 | warn$1(`Directive "${name}" has already been registered in target app.`);
|
4873 | }
|
4874 | context.directives[name] = directive;
|
4875 | return app;
|
4876 | },
|
4877 | mount(rootContainer, isHydrate, isSVG) {
|
4878 | if (!isMounted) {
|
4879 | const vnode = createVNode(rootComponent, rootProps);
|
4880 |
|
4881 |
|
4882 | vnode.appContext = context;
|
4883 |
|
4884 | {
|
4885 | context.reload = () => {
|
4886 | render(cloneVNode(vnode), rootContainer, isSVG);
|
4887 | };
|
4888 | }
|
4889 | if (isHydrate && hydrate) {
|
4890 | hydrate(vnode, rootContainer);
|
4891 | }
|
4892 | else {
|
4893 | render(vnode, rootContainer, isSVG);
|
4894 | }
|
4895 | isMounted = true;
|
4896 | app._container = rootContainer;
|
4897 | rootContainer.__vue_app__ = app;
|
4898 | {
|
4899 | app._instance = vnode.component;
|
4900 | devtoolsInitApp(app, version);
|
4901 | }
|
4902 | return vnode.component.proxy;
|
4903 | }
|
4904 | else {
|
4905 | warn$1(`App has already been mounted.\n` +
|
4906 | `If you want to remount the same app, move your app creation logic ` +
|
4907 | `into a factory function and create fresh app instances for each ` +
|
4908 | `mount - e.g. \`const createMyApp = () => createApp(App)\``);
|
4909 | }
|
4910 | },
|
4911 | unmount() {
|
4912 | if (isMounted) {
|
4913 | render(null, app._container);
|
4914 | {
|
4915 | app._instance = null;
|
4916 | devtoolsUnmountApp(app);
|
4917 | }
|
4918 | delete app._container.__vue_app__;
|
4919 | }
|
4920 | else {
|
4921 | warn$1(`Cannot unmount an app that is not mounted.`);
|
4922 | }
|
4923 | },
|
4924 | provide(key, value) {
|
4925 | if (key in context.provides) {
|
4926 | warn$1(`App already provides property with key "${String(key)}". ` +
|
4927 | `It will be overwritten with the new value.`);
|
4928 | }
|
4929 |
|
4930 |
|
4931 | context.provides[key] = value;
|
4932 | return app;
|
4933 | }
|
4934 | });
|
4935 | return app;
|
4936 | };
|
4937 | }
|
4938 |
|
4939 | let hasMismatch = false;
|
4940 | const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
|
4941 | const isComment = (node) => node.nodeType === 8 ;
|
4942 |
|
4943 |
|
4944 |
|
4945 |
|
4946 |
|
4947 | function createHydrationFunctions(rendererInternals) {
|
4948 | const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
|
4949 | const hydrate = (vnode, container) => {
|
4950 | if (!container.hasChildNodes()) {
|
4951 | warn$1(`Attempting to hydrate existing markup but container is empty. ` +
|
4952 | `Performing full mount instead.`);
|
4953 | patch(null, vnode, container);
|
4954 | flushPostFlushCbs();
|
4955 | return;
|
4956 | }
|
4957 | hasMismatch = false;
|
4958 | hydrateNode(container.firstChild, vnode, null, null, null);
|
4959 | flushPostFlushCbs();
|
4960 | if (hasMismatch && !false) {
|
4961 |
|
4962 | console.error(`Hydration completed but contains mismatches.`);
|
4963 | }
|
4964 | };
|
4965 | const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
|
4966 | const isFragmentStart = isComment(node) && node.data === '[';
|
4967 | const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
|
4968 | const { type, ref, shapeFlag } = vnode;
|
4969 | const domType = node.nodeType;
|
4970 | vnode.el = node;
|
4971 | let nextNode = null;
|
4972 | switch (type) {
|
4973 | case Text:
|
4974 | if (domType !== 3 ) {
|
4975 | nextNode = onMismatch();
|
4976 | }
|
4977 | else {
|
4978 | if (node.data !== vnode.children) {
|
4979 | hasMismatch = true;
|
4980 | warn$1(`Hydration text mismatch:` +
|
4981 | `\n- Client: ${JSON.stringify(node.data)}` +
|
4982 | `\n- Server: ${JSON.stringify(vnode.children)}`);
|
4983 | node.data = vnode.children;
|
4984 | }
|
4985 | nextNode = nextSibling(node);
|
4986 | }
|
4987 | break;
|
4988 | case Comment:
|
4989 | if (domType !== 8 || isFragmentStart) {
|
4990 | nextNode = onMismatch();
|
4991 | }
|
4992 | else {
|
4993 | nextNode = nextSibling(node);
|
4994 | }
|
4995 | break;
|
4996 | case Static:
|
4997 | if (domType !== 1 ) {
|
4998 | nextNode = onMismatch();
|
4999 | }
|
5000 | else {
|
5001 |
|
5002 | nextNode = node;
|
5003 |
|
5004 |
|
5005 | const needToAdoptContent = !vnode.children.length;
|
5006 | for (let i = 0; i < vnode.staticCount; i++) {
|
5007 | if (needToAdoptContent)
|
5008 | vnode.children += nextNode.outerHTML;
|
5009 | if (i === vnode.staticCount - 1) {
|
5010 | vnode.anchor = nextNode;
|
5011 | }
|
5012 | nextNode = nextSibling(nextNode);
|
5013 | }
|
5014 | return nextNode;
|
5015 | }
|
5016 | break;
|
5017 | case Fragment:
|
5018 | if (!isFragmentStart) {
|
5019 | nextNode = onMismatch();
|
5020 | }
|
5021 | else {
|
5022 | nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
|
5023 | }
|
5024 | break;
|
5025 | default:
|
5026 | if (shapeFlag & 1 ) {
|
5027 | if (domType !== 1 ||
|
5028 | vnode.type.toLowerCase() !==
|
5029 | node.tagName.toLowerCase()) {
|
5030 | nextNode = onMismatch();
|
5031 | }
|
5032 | else {
|
5033 | nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
|
5034 | }
|
5035 | }
|
5036 | else if (shapeFlag & 6 ) {
|
5037 |
|
5038 |
|
5039 |
|
5040 | vnode.slotScopeIds = slotScopeIds;
|
5041 | const container = parentNode(node);
|
5042 | mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
|
5043 |
|
5044 |
|
5045 |
|
5046 | nextNode = isFragmentStart
|
5047 | ? locateClosingAsyncAnchor(node)
|
5048 | : nextSibling(node);
|
5049 |
|
5050 |
|
5051 |
|
5052 |
|
5053 | if (isAsyncWrapper(vnode)) {
|
5054 | let subTree;
|
5055 | if (isFragmentStart) {
|
5056 | subTree = createVNode(Fragment);
|
5057 | subTree.anchor = nextNode
|
5058 | ? nextNode.previousSibling
|
5059 | : container.lastChild;
|
5060 | }
|
5061 | else {
|
5062 | subTree =
|
5063 | node.nodeType === 3 ? createTextVNode('') : createVNode('div');
|
5064 | }
|
5065 | subTree.el = node;
|
5066 | vnode.component.subTree = subTree;
|
5067 | }
|
5068 | }
|
5069 | else if (shapeFlag & 64 ) {
|
5070 | if (domType !== 8 ) {
|
5071 | nextNode = onMismatch();
|
5072 | }
|
5073 | else {
|
5074 | nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
|
5075 | }
|
5076 | }
|
5077 | else if (shapeFlag & 128 ) {
|
5078 | nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
|
5079 | }
|
5080 | else {
|
5081 | warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
|
5082 | }
|
5083 | }
|
5084 | if (ref != null) {
|
5085 | setRef(ref, null, parentSuspense, vnode);
|
5086 | }
|
5087 | return nextNode;
|
5088 | };
|
5089 | const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
5090 | optimized = optimized || !!vnode.dynamicChildren;
|
5091 | const { type, props, patchFlag, shapeFlag, dirs } = vnode;
|
5092 |
|
5093 |
|
5094 | const forcePatchValue = (type === 'input' && dirs) || type === 'option';
|
5095 |
|
5096 | if (forcePatchValue || patchFlag !== -1 ) {
|
5097 | if (dirs) {
|
5098 | invokeDirectiveHook(vnode, null, parentComponent, 'created');
|
5099 | }
|
5100 |
|
5101 | if (props) {
|
5102 | if (forcePatchValue ||
|
5103 | !optimized ||
|
5104 | patchFlag & (16 | 32 )) {
|
5105 | for (const key in props) {
|
5106 | if ((forcePatchValue && key.endsWith('value')) ||
|
5107 | (isOn(key) && !isReservedProp(key))) {
|
5108 | patchProp(el, key, null, props[key]);
|
5109 | }
|
5110 | }
|
5111 | }
|
5112 | else if (props.onClick) {
|
5113 |
|
5114 |
|
5115 | patchProp(el, 'onClick', null, props.onClick);
|
5116 | }
|
5117 | }
|
5118 |
|
5119 | let vnodeHooks;
|
5120 | if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
|
5121 | invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
5122 | }
|
5123 | if (dirs) {
|
5124 | invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
|
5125 | }
|
5126 | if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
|
5127 | queueEffectWithSuspense(() => {
|
5128 | vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
5129 | dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
|
5130 | }, parentSuspense);
|
5131 | }
|
5132 |
|
5133 | if (shapeFlag & 16 &&
|
5134 |
|
5135 | !(props && (props.innerHTML || props.textContent))) {
|
5136 | let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
|
5137 | let hasWarned = false;
|
5138 | while (next) {
|
5139 | hasMismatch = true;
|
5140 | if (!hasWarned) {
|
5141 | warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
|
5142 | `server rendered element contains more child nodes than client vdom.`);
|
5143 | hasWarned = true;
|
5144 | }
|
5145 |
|
5146 | const cur = next;
|
5147 | next = next.nextSibling;
|
5148 | remove(cur);
|
5149 | }
|
5150 | }
|
5151 | else if (shapeFlag & 8 ) {
|
5152 | if (el.textContent !== vnode.children) {
|
5153 | hasMismatch = true;
|
5154 | warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
|
5155 | `- Client: ${el.textContent}\n` +
|
5156 | `- Server: ${vnode.children}`);
|
5157 | el.textContent = vnode.children;
|
5158 | }
|
5159 | }
|
5160 | }
|
5161 | return el.nextSibling;
|
5162 | };
|
5163 | const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
5164 | optimized = optimized || !!parentVNode.dynamicChildren;
|
5165 | const children = parentVNode.children;
|
5166 | const l = children.length;
|
5167 | let hasWarned = false;
|
5168 | for (let i = 0; i < l; i++) {
|
5169 | const vnode = optimized
|
5170 | ? children[i]
|
5171 | : (children[i] = normalizeVNode(children[i]));
|
5172 | if (node) {
|
5173 | node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
|
5174 | }
|
5175 | else if (vnode.type === Text && !vnode.children) {
|
5176 | continue;
|
5177 | }
|
5178 | else {
|
5179 | hasMismatch = true;
|
5180 | if (!hasWarned) {
|
5181 | warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
|
5182 | `server rendered element contains fewer child nodes than client vdom.`);
|
5183 | hasWarned = true;
|
5184 | }
|
5185 |
|
5186 | patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
|
5187 | }
|
5188 | }
|
5189 | return node;
|
5190 | };
|
5191 | const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
5192 | const { slotScopeIds: fragmentSlotScopeIds } = vnode;
|
5193 | if (fragmentSlotScopeIds) {
|
5194 | slotScopeIds = slotScopeIds
|
5195 | ? slotScopeIds.concat(fragmentSlotScopeIds)
|
5196 | : fragmentSlotScopeIds;
|
5197 | }
|
5198 | const container = parentNode(node);
|
5199 | const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
|
5200 | if (next && isComment(next) && next.data === ']') {
|
5201 | return nextSibling((vnode.anchor = next));
|
5202 | }
|
5203 | else {
|
5204 |
|
5205 |
|
5206 | hasMismatch = true;
|
5207 |
|
5208 | insert((vnode.anchor = createComment(`]`)), container, next);
|
5209 | return next;
|
5210 | }
|
5211 | };
|
5212 | const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
|
5213 | hasMismatch = true;
|
5214 | warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3
|
5215 | ? `(text)`
|
5216 | : isComment(node) && node.data === '['
|
5217 | ? `(start of fragment)`
|
5218 | : ``);
|
5219 | vnode.el = null;
|
5220 | if (isFragment) {
|
5221 |
|
5222 | const end = locateClosingAsyncAnchor(node);
|
5223 | while (true) {
|
5224 | const next = nextSibling(node);
|
5225 | if (next && next !== end) {
|
5226 | remove(next);
|
5227 | }
|
5228 | else {
|
5229 | break;
|
5230 | }
|
5231 | }
|
5232 | }
|
5233 | const next = nextSibling(node);
|
5234 | const container = parentNode(node);
|
5235 | remove(node);
|
5236 | patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
|
5237 | return next;
|
5238 | };
|
5239 | const locateClosingAsyncAnchor = (node) => {
|
5240 | let match = 0;
|
5241 | while (node) {
|
5242 | node = nextSibling(node);
|
5243 | if (node && isComment(node)) {
|
5244 | if (node.data === '[')
|
5245 | match++;
|
5246 | if (node.data === ']') {
|
5247 | if (match === 0) {
|
5248 | return nextSibling(node);
|
5249 | }
|
5250 | else {
|
5251 | match--;
|
5252 | }
|
5253 | }
|
5254 | }
|
5255 | }
|
5256 | return node;
|
5257 | };
|
5258 | return [hydrate, hydrateNode];
|
5259 | }
|
5260 |
|
5261 | let supported;
|
5262 | let perf;
|
5263 | function startMeasure(instance, type) {
|
5264 | if (instance.appContext.config.performance && isSupported()) {
|
5265 | perf.mark(`vue-${type}-${instance.uid}`);
|
5266 | }
|
5267 | {
|
5268 | devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
|
5269 | }
|
5270 | }
|
5271 | function endMeasure(instance, type) {
|
5272 | if (instance.appContext.config.performance && isSupported()) {
|
5273 | const startTag = `vue-${type}-${instance.uid}`;
|
5274 | const endTag = startTag + `:end`;
|
5275 | perf.mark(endTag);
|
5276 | perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
|
5277 | perf.clearMarks(startTag);
|
5278 | perf.clearMarks(endTag);
|
5279 | }
|
5280 | {
|
5281 | devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
|
5282 | }
|
5283 | }
|
5284 | function isSupported() {
|
5285 | if (supported !== undefined) {
|
5286 | return supported;
|
5287 | }
|
5288 |
|
5289 | if (typeof window !== 'undefined' && window.performance) {
|
5290 | supported = true;
|
5291 | perf = window.performance;
|
5292 | }
|
5293 | else {
|
5294 | supported = false;
|
5295 | }
|
5296 |
|
5297 | return supported;
|
5298 | }
|
5299 |
|
5300 | const queuePostRenderEffect = queueEffectWithSuspense
|
5301 | ;
|
5302 | |
5303 |
|
5304 |
|
5305 |
|
5306 |
|
5307 |
|
5308 |
|
5309 |
|
5310 |
|
5311 |
|
5312 |
|
5313 |
|
5314 |
|
5315 |
|
5316 |
|
5317 | function createRenderer(options) {
|
5318 | return baseCreateRenderer(options);
|
5319 | }
|
5320 |
|
5321 |
|
5322 |
|
5323 | function createHydrationRenderer(options) {
|
5324 | return baseCreateRenderer(options, createHydrationFunctions);
|
5325 | }
|
5326 |
|
5327 | function baseCreateRenderer(options, createHydrationFns) {
|
5328 | {
|
5329 | const target = getGlobalThis();
|
5330 | target.__VUE__ = true;
|
5331 | setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__);
|
5332 | }
|
5333 | const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
|
5334 |
|
5335 |
|
5336 | const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
|
5337 | if (n1 === n2) {
|
5338 | return;
|
5339 | }
|
5340 |
|
5341 | if (n1 && !isSameVNodeType(n1, n2)) {
|
5342 | anchor = getNextHostNode(n1);
|
5343 | unmount(n1, parentComponent, parentSuspense, true);
|
5344 | n1 = null;
|
5345 | }
|
5346 | if (n2.patchFlag === -2 ) {
|
5347 | optimized = false;
|
5348 | n2.dynamicChildren = null;
|
5349 | }
|
5350 | const { type, ref, shapeFlag } = n2;
|
5351 | switch (type) {
|
5352 | case Text:
|
5353 | processText(n1, n2, container, anchor);
|
5354 | break;
|
5355 | case Comment:
|
5356 | processCommentNode(n1, n2, container, anchor);
|
5357 | break;
|
5358 | case Static:
|
5359 | if (n1 == null) {
|
5360 | mountStaticNode(n2, container, anchor, isSVG);
|
5361 | }
|
5362 | else {
|
5363 | patchStaticNode(n1, n2, container, isSVG);
|
5364 | }
|
5365 | break;
|
5366 | case Fragment:
|
5367 | processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5368 | break;
|
5369 | default:
|
5370 | if (shapeFlag & 1 ) {
|
5371 | processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5372 | }
|
5373 | else if (shapeFlag & 6 ) {
|
5374 | processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5375 | }
|
5376 | else if (shapeFlag & 64 ) {
|
5377 | type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
|
5378 | }
|
5379 | else if (shapeFlag & 128 ) {
|
5380 | type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
|
5381 | }
|
5382 | else {
|
5383 | warn$1('Invalid VNode type:', type, `(${typeof type})`);
|
5384 | }
|
5385 | }
|
5386 |
|
5387 | if (ref != null && parentComponent) {
|
5388 | setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
|
5389 | }
|
5390 | };
|
5391 | const processText = (n1, n2, container, anchor) => {
|
5392 | if (n1 == null) {
|
5393 | hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
|
5394 | }
|
5395 | else {
|
5396 | const el = (n2.el = n1.el);
|
5397 | if (n2.children !== n1.children) {
|
5398 | hostSetText(el, n2.children);
|
5399 | }
|
5400 | }
|
5401 | };
|
5402 | const processCommentNode = (n1, n2, container, anchor) => {
|
5403 | if (n1 == null) {
|
5404 | hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
|
5405 | }
|
5406 | else {
|
5407 |
|
5408 | n2.el = n1.el;
|
5409 | }
|
5410 | };
|
5411 | const mountStaticNode = (n2, container, anchor, isSVG) => {
|
5412 | [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
|
5413 | };
|
5414 | |
5415 |
|
5416 |
|
5417 | const patchStaticNode = (n1, n2, container, isSVG) => {
|
5418 |
|
5419 | if (n2.children !== n1.children) {
|
5420 | const anchor = hostNextSibling(n1.anchor);
|
5421 |
|
5422 | removeStaticNode(n1);
|
5423 | [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
|
5424 | }
|
5425 | else {
|
5426 | n2.el = n1.el;
|
5427 | n2.anchor = n1.anchor;
|
5428 | }
|
5429 | };
|
5430 | const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
|
5431 | let next;
|
5432 | while (el && el !== anchor) {
|
5433 | next = hostNextSibling(el);
|
5434 | hostInsert(el, container, nextSibling);
|
5435 | el = next;
|
5436 | }
|
5437 | hostInsert(anchor, container, nextSibling);
|
5438 | };
|
5439 | const removeStaticNode = ({ el, anchor }) => {
|
5440 | let next;
|
5441 | while (el && el !== anchor) {
|
5442 | next = hostNextSibling(el);
|
5443 | hostRemove(el);
|
5444 | el = next;
|
5445 | }
|
5446 | hostRemove(anchor);
|
5447 | };
|
5448 | const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5449 | isSVG = isSVG || n2.type === 'svg';
|
5450 | if (n1 == null) {
|
5451 | mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5452 | }
|
5453 | else {
|
5454 | patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5455 | }
|
5456 | };
|
5457 | const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5458 | let el;
|
5459 | let vnodeHook;
|
5460 | const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
|
5461 | {
|
5462 | el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
|
5463 |
|
5464 |
|
5465 | if (shapeFlag & 8 ) {
|
5466 | hostSetElementText(el, vnode.children);
|
5467 | }
|
5468 | else if (shapeFlag & 16 ) {
|
5469 | mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
|
5470 | }
|
5471 | if (dirs) {
|
5472 | invokeDirectiveHook(vnode, null, parentComponent, 'created');
|
5473 | }
|
5474 |
|
5475 | if (props) {
|
5476 | for (const key in props) {
|
5477 | if (key !== 'value' && !isReservedProp(key)) {
|
5478 | hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
|
5479 | }
|
5480 | }
|
5481 | |
5482 |
|
5483 |
|
5484 |
|
5485 |
|
5486 |
|
5487 |
|
5488 |
|
5489 |
|
5490 | if ('value' in props) {
|
5491 | hostPatchProp(el, 'value', null, props.value);
|
5492 | }
|
5493 | if ((vnodeHook = props.onVnodeBeforeMount)) {
|
5494 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
5495 | }
|
5496 | }
|
5497 |
|
5498 | setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
|
5499 | }
|
5500 | {
|
5501 | Object.defineProperty(el, '__vnode', {
|
5502 | value: vnode,
|
5503 | enumerable: false
|
5504 | });
|
5505 | Object.defineProperty(el, '__vueParentComponent', {
|
5506 | value: parentComponent,
|
5507 | enumerable: false
|
5508 | });
|
5509 | }
|
5510 | if (dirs) {
|
5511 | invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
|
5512 | }
|
5513 |
|
5514 |
|
5515 | const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
|
5516 | transition &&
|
5517 | !transition.persisted;
|
5518 | if (needCallTransitionHooks) {
|
5519 | transition.beforeEnter(el);
|
5520 | }
|
5521 | hostInsert(el, container, anchor);
|
5522 | if ((vnodeHook = props && props.onVnodeMounted) ||
|
5523 | needCallTransitionHooks ||
|
5524 | dirs) {
|
5525 | queuePostRenderEffect(() => {
|
5526 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
5527 | needCallTransitionHooks && transition.enter(el);
|
5528 | dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
|
5529 | }, parentSuspense);
|
5530 | }
|
5531 | };
|
5532 | const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
|
5533 | if (scopeId) {
|
5534 | hostSetScopeId(el, scopeId);
|
5535 | }
|
5536 | if (slotScopeIds) {
|
5537 | for (let i = 0; i < slotScopeIds.length; i++) {
|
5538 | hostSetScopeId(el, slotScopeIds[i]);
|
5539 | }
|
5540 | }
|
5541 | if (parentComponent) {
|
5542 | let subTree = parentComponent.subTree;
|
5543 | if (subTree.patchFlag > 0 &&
|
5544 | subTree.patchFlag & 2048 ) {
|
5545 | subTree =
|
5546 | filterSingleRoot(subTree.children) || subTree;
|
5547 | }
|
5548 | if (vnode === subTree) {
|
5549 | const parentVNode = parentComponent.vnode;
|
5550 | setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
|
5551 | }
|
5552 | }
|
5553 | };
|
5554 | const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
|
5555 | for (let i = start; i < children.length; i++) {
|
5556 | const child = (children[i] = optimized
|
5557 | ? cloneIfMounted(children[i])
|
5558 | : normalizeVNode(children[i]));
|
5559 | patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5560 | }
|
5561 | };
|
5562 | const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5563 | const el = (n2.el = n1.el);
|
5564 | let { patchFlag, dynamicChildren, dirs } = n2;
|
5565 |
|
5566 |
|
5567 | patchFlag |= n1.patchFlag & 16 ;
|
5568 | const oldProps = n1.props || EMPTY_OBJ;
|
5569 | const newProps = n2.props || EMPTY_OBJ;
|
5570 | let vnodeHook;
|
5571 | if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
|
5572 | invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
5573 | }
|
5574 | if (dirs) {
|
5575 | invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
|
5576 | }
|
5577 | if (isHmrUpdating) {
|
5578 |
|
5579 | patchFlag = 0;
|
5580 | optimized = false;
|
5581 | dynamicChildren = null;
|
5582 | }
|
5583 | const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
|
5584 | if (dynamicChildren) {
|
5585 | patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
|
5586 | if (parentComponent && parentComponent.type.__hmrId) {
|
5587 | traverseStaticChildren(n1, n2);
|
5588 | }
|
5589 | }
|
5590 | else if (!optimized) {
|
5591 |
|
5592 | patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
|
5593 | }
|
5594 | if (patchFlag > 0) {
|
5595 |
|
5596 |
|
5597 |
|
5598 |
|
5599 | if (patchFlag & 16 ) {
|
5600 |
|
5601 | patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
|
5602 | }
|
5603 | else {
|
5604 |
|
5605 |
|
5606 | if (patchFlag & 2 ) {
|
5607 | if (oldProps.class !== newProps.class) {
|
5608 | hostPatchProp(el, 'class', null, newProps.class, isSVG);
|
5609 | }
|
5610 | }
|
5611 |
|
5612 |
|
5613 | if (patchFlag & 4 ) {
|
5614 | hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
|
5615 | }
|
5616 |
|
5617 |
|
5618 |
|
5619 |
|
5620 |
|
5621 |
|
5622 | if (patchFlag & 8 ) {
|
5623 |
|
5624 | const propsToUpdate = n2.dynamicProps;
|
5625 | for (let i = 0; i < propsToUpdate.length; i++) {
|
5626 | const key = propsToUpdate[i];
|
5627 | const prev = oldProps[key];
|
5628 | const next = newProps[key];
|
5629 |
|
5630 | if (next !== prev || key === 'value') {
|
5631 | hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
|
5632 | }
|
5633 | }
|
5634 | }
|
5635 | }
|
5636 |
|
5637 |
|
5638 | if (patchFlag & 1 ) {
|
5639 | if (n1.children !== n2.children) {
|
5640 | hostSetElementText(el, n2.children);
|
5641 | }
|
5642 | }
|
5643 | }
|
5644 | else if (!optimized && dynamicChildren == null) {
|
5645 |
|
5646 | patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
|
5647 | }
|
5648 | if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
|
5649 | queuePostRenderEffect(() => {
|
5650 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
5651 | dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
|
5652 | }, parentSuspense);
|
5653 | }
|
5654 | };
|
5655 |
|
5656 | const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
|
5657 | for (let i = 0; i < newChildren.length; i++) {
|
5658 | const oldVNode = oldChildren[i];
|
5659 | const newVNode = newChildren[i];
|
5660 |
|
5661 | const container =
|
5662 |
|
5663 |
|
5664 | oldVNode.el &&
|
5665 |
|
5666 |
|
5667 | (oldVNode.type === Fragment ||
|
5668 |
|
5669 |
|
5670 | !isSameVNodeType(oldVNode, newVNode) ||
|
5671 |
|
5672 | oldVNode.shapeFlag & (6 | 64 ))
|
5673 | ? hostParentNode(oldVNode.el)
|
5674 | :
|
5675 |
|
5676 | fallbackContainer;
|
5677 | patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
|
5678 | }
|
5679 | };
|
5680 | const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
|
5681 | if (oldProps !== newProps) {
|
5682 | for (const key in newProps) {
|
5683 |
|
5684 | if (isReservedProp(key))
|
5685 | continue;
|
5686 | const next = newProps[key];
|
5687 | const prev = oldProps[key];
|
5688 |
|
5689 | if (next !== prev && key !== 'value') {
|
5690 | hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
|
5691 | }
|
5692 | }
|
5693 | if (oldProps !== EMPTY_OBJ) {
|
5694 | for (const key in oldProps) {
|
5695 | if (!isReservedProp(key) && !(key in newProps)) {
|
5696 | hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
|
5697 | }
|
5698 | }
|
5699 | }
|
5700 | if ('value' in newProps) {
|
5701 | hostPatchProp(el, 'value', oldProps.value, newProps.value);
|
5702 | }
|
5703 | }
|
5704 | };
|
5705 | const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5706 | const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
|
5707 | const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
|
5708 | let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
|
5709 | if (isHmrUpdating) {
|
5710 |
|
5711 | patchFlag = 0;
|
5712 | optimized = false;
|
5713 | dynamicChildren = null;
|
5714 | }
|
5715 |
|
5716 | if (fragmentSlotScopeIds) {
|
5717 | slotScopeIds = slotScopeIds
|
5718 | ? slotScopeIds.concat(fragmentSlotScopeIds)
|
5719 | : fragmentSlotScopeIds;
|
5720 | }
|
5721 | if (n1 == null) {
|
5722 | hostInsert(fragmentStartAnchor, container, anchor);
|
5723 | hostInsert(fragmentEndAnchor, container, anchor);
|
5724 |
|
5725 |
|
5726 |
|
5727 | mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5728 | }
|
5729 | else {
|
5730 | if (patchFlag > 0 &&
|
5731 | patchFlag & 64 &&
|
5732 | dynamicChildren &&
|
5733 |
|
5734 |
|
5735 | n1.dynamicChildren) {
|
5736 |
|
5737 |
|
5738 | patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
|
5739 | if (parentComponent && parentComponent.type.__hmrId) {
|
5740 | traverseStaticChildren(n1, n2);
|
5741 | }
|
5742 | else if (
|
5743 |
|
5744 |
|
5745 |
|
5746 |
|
5747 | n2.key != null ||
|
5748 | (parentComponent && n2 === parentComponent.subTree)) {
|
5749 | traverseStaticChildren(n1, n2, true );
|
5750 | }
|
5751 | }
|
5752 | else {
|
5753 |
|
5754 |
|
5755 |
|
5756 |
|
5757 | patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5758 | }
|
5759 | }
|
5760 | };
|
5761 | const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5762 | n2.slotScopeIds = slotScopeIds;
|
5763 | if (n1 == null) {
|
5764 | if (n2.shapeFlag & 512 ) {
|
5765 | parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
|
5766 | }
|
5767 | else {
|
5768 | mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
|
5769 | }
|
5770 | }
|
5771 | else {
|
5772 | updateComponent(n1, n2, optimized);
|
5773 | }
|
5774 | };
|
5775 | const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
|
5776 | const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
|
5777 | if (instance.type.__hmrId) {
|
5778 | registerHMR(instance);
|
5779 | }
|
5780 | {
|
5781 | pushWarningContext(initialVNode);
|
5782 | startMeasure(instance, `mount`);
|
5783 | }
|
5784 |
|
5785 | if (isKeepAlive(initialVNode)) {
|
5786 | instance.ctx.renderer = internals;
|
5787 | }
|
5788 |
|
5789 | {
|
5790 | {
|
5791 | startMeasure(instance, `init`);
|
5792 | }
|
5793 | setupComponent(instance);
|
5794 | {
|
5795 | endMeasure(instance, `init`);
|
5796 | }
|
5797 | }
|
5798 |
|
5799 |
|
5800 | if (instance.asyncDep) {
|
5801 | parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
|
5802 |
|
5803 |
|
5804 | if (!initialVNode.el) {
|
5805 | const placeholder = (instance.subTree = createVNode(Comment));
|
5806 | processCommentNode(null, placeholder, container, anchor);
|
5807 | }
|
5808 | return;
|
5809 | }
|
5810 | setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
|
5811 | {
|
5812 | popWarningContext();
|
5813 | endMeasure(instance, `mount`);
|
5814 | }
|
5815 | };
|
5816 | const updateComponent = (n1, n2, optimized) => {
|
5817 | const instance = (n2.component = n1.component);
|
5818 | if (shouldUpdateComponent(n1, n2, optimized)) {
|
5819 | if (instance.asyncDep &&
|
5820 | !instance.asyncResolved) {
|
5821 |
|
5822 |
|
5823 | {
|
5824 | pushWarningContext(n2);
|
5825 | }
|
5826 | updateComponentPreRender(instance, n2, optimized);
|
5827 | {
|
5828 | popWarningContext();
|
5829 | }
|
5830 | return;
|
5831 | }
|
5832 | else {
|
5833 |
|
5834 | instance.next = n2;
|
5835 |
|
5836 |
|
5837 | invalidateJob(instance.update);
|
5838 |
|
5839 | instance.update();
|
5840 | }
|
5841 | }
|
5842 | else {
|
5843 |
|
5844 | n2.component = n1.component;
|
5845 | n2.el = n1.el;
|
5846 | instance.vnode = n2;
|
5847 | }
|
5848 | };
|
5849 | const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
|
5850 | const componentUpdateFn = () => {
|
5851 | if (!instance.isMounted) {
|
5852 | let vnodeHook;
|
5853 | const { el, props } = initialVNode;
|
5854 | const { bm, m, parent } = instance;
|
5855 | const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
|
5856 | effect.allowRecurse = false;
|
5857 |
|
5858 | if (bm) {
|
5859 | invokeArrayFns(bm);
|
5860 | }
|
5861 |
|
5862 | if (!isAsyncWrapperVNode &&
|
5863 | (vnodeHook = props && props.onVnodeBeforeMount)) {
|
5864 | invokeVNodeHook(vnodeHook, parent, initialVNode);
|
5865 | }
|
5866 | effect.allowRecurse = true;
|
5867 | if (el && hydrateNode) {
|
5868 |
|
5869 | const hydrateSubTree = () => {
|
5870 | {
|
5871 | startMeasure(instance, `render`);
|
5872 | }
|
5873 | instance.subTree = renderComponentRoot(instance);
|
5874 | {
|
5875 | endMeasure(instance, `render`);
|
5876 | }
|
5877 | {
|
5878 | startMeasure(instance, `hydrate`);
|
5879 | }
|
5880 | hydrateNode(el, instance.subTree, instance, parentSuspense, null);
|
5881 | {
|
5882 | endMeasure(instance, `hydrate`);
|
5883 | }
|
5884 | };
|
5885 | if (isAsyncWrapperVNode) {
|
5886 | initialVNode.type.__asyncLoader().then(
|
5887 |
|
5888 |
|
5889 |
|
5890 |
|
5891 | () => !instance.isUnmounted && hydrateSubTree());
|
5892 | }
|
5893 | else {
|
5894 | hydrateSubTree();
|
5895 | }
|
5896 | }
|
5897 | else {
|
5898 | {
|
5899 | startMeasure(instance, `render`);
|
5900 | }
|
5901 | const subTree = (instance.subTree = renderComponentRoot(instance));
|
5902 | {
|
5903 | endMeasure(instance, `render`);
|
5904 | }
|
5905 | {
|
5906 | startMeasure(instance, `patch`);
|
5907 | }
|
5908 | patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
|
5909 | {
|
5910 | endMeasure(instance, `patch`);
|
5911 | }
|
5912 | initialVNode.el = subTree.el;
|
5913 | }
|
5914 |
|
5915 | if (m) {
|
5916 | queuePostRenderEffect(m, parentSuspense);
|
5917 | }
|
5918 |
|
5919 | if (!isAsyncWrapperVNode &&
|
5920 | (vnodeHook = props && props.onVnodeMounted)) {
|
5921 | const scopedInitialVNode = initialVNode;
|
5922 | queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
|
5923 | }
|
5924 |
|
5925 |
|
5926 |
|
5927 | if (initialVNode.shapeFlag & 256 ) {
|
5928 | instance.a && queuePostRenderEffect(instance.a, parentSuspense);
|
5929 | }
|
5930 | instance.isMounted = true;
|
5931 | {
|
5932 | devtoolsComponentAdded(instance);
|
5933 | }
|
5934 |
|
5935 | initialVNode = container = anchor = null;
|
5936 | }
|
5937 | else {
|
5938 |
|
5939 |
|
5940 |
|
5941 | let { next, bu, u, parent, vnode } = instance;
|
5942 | let originNext = next;
|
5943 | let vnodeHook;
|
5944 | {
|
5945 | pushWarningContext(next || instance.vnode);
|
5946 | }
|
5947 |
|
5948 | effect.allowRecurse = false;
|
5949 | if (next) {
|
5950 | next.el = vnode.el;
|
5951 | updateComponentPreRender(instance, next, optimized);
|
5952 | }
|
5953 | else {
|
5954 | next = vnode;
|
5955 | }
|
5956 |
|
5957 | if (bu) {
|
5958 | invokeArrayFns(bu);
|
5959 | }
|
5960 |
|
5961 | if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
|
5962 | invokeVNodeHook(vnodeHook, parent, next, vnode);
|
5963 | }
|
5964 | effect.allowRecurse = true;
|
5965 |
|
5966 | {
|
5967 | startMeasure(instance, `render`);
|
5968 | }
|
5969 | const nextTree = renderComponentRoot(instance);
|
5970 | {
|
5971 | endMeasure(instance, `render`);
|
5972 | }
|
5973 | const prevTree = instance.subTree;
|
5974 | instance.subTree = nextTree;
|
5975 | {
|
5976 | startMeasure(instance, `patch`);
|
5977 | }
|
5978 | patch(prevTree, nextTree,
|
5979 |
|
5980 | hostParentNode(prevTree.el),
|
5981 |
|
5982 | getNextHostNode(prevTree), instance, parentSuspense, isSVG);
|
5983 | {
|
5984 | endMeasure(instance, `patch`);
|
5985 | }
|
5986 | next.el = nextTree.el;
|
5987 | if (originNext === null) {
|
5988 |
|
5989 |
|
5990 |
|
5991 | updateHOCHostEl(instance, nextTree.el);
|
5992 | }
|
5993 |
|
5994 | if (u) {
|
5995 | queuePostRenderEffect(u, parentSuspense);
|
5996 | }
|
5997 |
|
5998 | if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
|
5999 | queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
|
6000 | }
|
6001 | {
|
6002 | devtoolsComponentUpdated(instance);
|
6003 | }
|
6004 | {
|
6005 | popWarningContext();
|
6006 | }
|
6007 | }
|
6008 | };
|
6009 |
|
6010 | const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope
|
6011 | );
|
6012 | const update = (instance.update = effect.run.bind(effect));
|
6013 | update.id = instance.uid;
|
6014 |
|
6015 |
|
6016 | effect.allowRecurse = update.allowRecurse = true;
|
6017 | {
|
6018 | effect.onTrack = instance.rtc
|
6019 | ? e => invokeArrayFns(instance.rtc, e)
|
6020 | : void 0;
|
6021 | effect.onTrigger = instance.rtg
|
6022 | ? e => invokeArrayFns(instance.rtg, e)
|
6023 | : void 0;
|
6024 |
|
6025 | update.ownerInstance = instance;
|
6026 | }
|
6027 | update();
|
6028 | };
|
6029 | const updateComponentPreRender = (instance, nextVNode, optimized) => {
|
6030 | nextVNode.component = instance;
|
6031 | const prevProps = instance.vnode.props;
|
6032 | instance.vnode = nextVNode;
|
6033 | instance.next = null;
|
6034 | updateProps(instance, nextVNode.props, prevProps, optimized);
|
6035 | updateSlots(instance, nextVNode.children, optimized);
|
6036 | pauseTracking();
|
6037 |
|
6038 |
|
6039 | flushPreFlushCbs(undefined, instance.update);
|
6040 | resetTracking();
|
6041 | };
|
6042 | const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
|
6043 | const c1 = n1 && n1.children;
|
6044 | const prevShapeFlag = n1 ? n1.shapeFlag : 0;
|
6045 | const c2 = n2.children;
|
6046 | const { patchFlag, shapeFlag } = n2;
|
6047 |
|
6048 | if (patchFlag > 0) {
|
6049 | if (patchFlag & 128 ) {
|
6050 |
|
6051 |
|
6052 | patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6053 | return;
|
6054 | }
|
6055 | else if (patchFlag & 256 ) {
|
6056 |
|
6057 | patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6058 | return;
|
6059 | }
|
6060 | }
|
6061 |
|
6062 | if (shapeFlag & 8 ) {
|
6063 |
|
6064 | if (prevShapeFlag & 16 ) {
|
6065 | unmountChildren(c1, parentComponent, parentSuspense);
|
6066 | }
|
6067 | if (c2 !== c1) {
|
6068 | hostSetElementText(container, c2);
|
6069 | }
|
6070 | }
|
6071 | else {
|
6072 | if (prevShapeFlag & 16 ) {
|
6073 |
|
6074 | if (shapeFlag & 16 ) {
|
6075 |
|
6076 | patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6077 | }
|
6078 | else {
|
6079 |
|
6080 | unmountChildren(c1, parentComponent, parentSuspense, true);
|
6081 | }
|
6082 | }
|
6083 | else {
|
6084 |
|
6085 |
|
6086 | if (prevShapeFlag & 8 ) {
|
6087 | hostSetElementText(container, '');
|
6088 | }
|
6089 |
|
6090 | if (shapeFlag & 16 ) {
|
6091 | mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6092 | }
|
6093 | }
|
6094 | }
|
6095 | };
|
6096 | const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
6097 | c1 = c1 || EMPTY_ARR;
|
6098 | c2 = c2 || EMPTY_ARR;
|
6099 | const oldLength = c1.length;
|
6100 | const newLength = c2.length;
|
6101 | const commonLength = Math.min(oldLength, newLength);
|
6102 | let i;
|
6103 | for (i = 0; i < commonLength; i++) {
|
6104 | const nextChild = (c2[i] = optimized
|
6105 | ? cloneIfMounted(c2[i])
|
6106 | : normalizeVNode(c2[i]));
|
6107 | patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6108 | }
|
6109 | if (oldLength > newLength) {
|
6110 |
|
6111 | unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
|
6112 | }
|
6113 | else {
|
6114 |
|
6115 | mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
|
6116 | }
|
6117 | };
|
6118 |
|
6119 | const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
6120 | let i = 0;
|
6121 | const l2 = c2.length;
|
6122 | let e1 = c1.length - 1;
|
6123 | let e2 = l2 - 1;
|
6124 |
|
6125 |
|
6126 |
|
6127 | while (i <= e1 && i <= e2) {
|
6128 | const n1 = c1[i];
|
6129 | const n2 = (c2[i] = optimized
|
6130 | ? cloneIfMounted(c2[i])
|
6131 | : normalizeVNode(c2[i]));
|
6132 | if (isSameVNodeType(n1, n2)) {
|
6133 | patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6134 | }
|
6135 | else {
|
6136 | break;
|
6137 | }
|
6138 | i++;
|
6139 | }
|
6140 |
|
6141 |
|
6142 |
|
6143 | while (i <= e1 && i <= e2) {
|
6144 | const n1 = c1[e1];
|
6145 | const n2 = (c2[e2] = optimized
|
6146 | ? cloneIfMounted(c2[e2])
|
6147 | : normalizeVNode(c2[e2]));
|
6148 | if (isSameVNodeType(n1, n2)) {
|
6149 | patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6150 | }
|
6151 | else {
|
6152 | break;
|
6153 | }
|
6154 | e1--;
|
6155 | e2--;
|
6156 | }
|
6157 |
|
6158 |
|
6159 |
|
6160 |
|
6161 |
|
6162 |
|
6163 |
|
6164 | if (i > e1) {
|
6165 | if (i <= e2) {
|
6166 | const nextPos = e2 + 1;
|
6167 | const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
|
6168 | while (i <= e2) {
|
6169 | patch(null, (c2[i] = optimized
|
6170 | ? cloneIfMounted(c2[i])
|
6171 | : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6172 | i++;
|
6173 | }
|
6174 | }
|
6175 | }
|
6176 |
|
6177 |
|
6178 |
|
6179 |
|
6180 |
|
6181 |
|
6182 |
|
6183 | else if (i > e2) {
|
6184 | while (i <= e1) {
|
6185 | unmount(c1[i], parentComponent, parentSuspense, true);
|
6186 | i++;
|
6187 | }
|
6188 | }
|
6189 |
|
6190 |
|
6191 |
|
6192 |
|
6193 | else {
|
6194 | const s1 = i;
|
6195 | const s2 = i;
|
6196 |
|
6197 | const keyToNewIndexMap = new Map();
|
6198 | for (i = s2; i <= e2; i++) {
|
6199 | const nextChild = (c2[i] = optimized
|
6200 | ? cloneIfMounted(c2[i])
|
6201 | : normalizeVNode(c2[i]));
|
6202 | if (nextChild.key != null) {
|
6203 | if (keyToNewIndexMap.has(nextChild.key)) {
|
6204 | warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
|
6205 | }
|
6206 | keyToNewIndexMap.set(nextChild.key, i);
|
6207 | }
|
6208 | }
|
6209 |
|
6210 |
|
6211 | let j;
|
6212 | let patched = 0;
|
6213 | const toBePatched = e2 - s2 + 1;
|
6214 | let moved = false;
|
6215 |
|
6216 | let maxNewIndexSoFar = 0;
|
6217 |
|
6218 |
|
6219 |
|
6220 |
|
6221 |
|
6222 | const newIndexToOldIndexMap = new Array(toBePatched);
|
6223 | for (i = 0; i < toBePatched; i++)
|
6224 | newIndexToOldIndexMap[i] = 0;
|
6225 | for (i = s1; i <= e1; i++) {
|
6226 | const prevChild = c1[i];
|
6227 | if (patched >= toBePatched) {
|
6228 |
|
6229 | unmount(prevChild, parentComponent, parentSuspense, true);
|
6230 | continue;
|
6231 | }
|
6232 | let newIndex;
|
6233 | if (prevChild.key != null) {
|
6234 | newIndex = keyToNewIndexMap.get(prevChild.key);
|
6235 | }
|
6236 | else {
|
6237 |
|
6238 | for (j = s2; j <= e2; j++) {
|
6239 | if (newIndexToOldIndexMap[j - s2] === 0 &&
|
6240 | isSameVNodeType(prevChild, c2[j])) {
|
6241 | newIndex = j;
|
6242 | break;
|
6243 | }
|
6244 | }
|
6245 | }
|
6246 | if (newIndex === undefined) {
|
6247 | unmount(prevChild, parentComponent, parentSuspense, true);
|
6248 | }
|
6249 | else {
|
6250 | newIndexToOldIndexMap[newIndex - s2] = i + 1;
|
6251 | if (newIndex >= maxNewIndexSoFar) {
|
6252 | maxNewIndexSoFar = newIndex;
|
6253 | }
|
6254 | else {
|
6255 | moved = true;
|
6256 | }
|
6257 | patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6258 | patched++;
|
6259 | }
|
6260 | }
|
6261 |
|
6262 |
|
6263 | const increasingNewIndexSequence = moved
|
6264 | ? getSequence(newIndexToOldIndexMap)
|
6265 | : EMPTY_ARR;
|
6266 | j = increasingNewIndexSequence.length - 1;
|
6267 |
|
6268 | for (i = toBePatched - 1; i >= 0; i--) {
|
6269 | const nextIndex = s2 + i;
|
6270 | const nextChild = c2[nextIndex];
|
6271 | const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
|
6272 | if (newIndexToOldIndexMap[i] === 0) {
|
6273 |
|
6274 | patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6275 | }
|
6276 | else if (moved) {
|
6277 |
|
6278 |
|
6279 |
|
6280 | if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
6281 | move(nextChild, container, anchor, 2 );
|
6282 | }
|
6283 | else {
|
6284 | j--;
|
6285 | }
|
6286 | }
|
6287 | }
|
6288 | }
|
6289 | };
|
6290 | const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
|
6291 | const { el, type, transition, children, shapeFlag } = vnode;
|
6292 | if (shapeFlag & 6 ) {
|
6293 | move(vnode.component.subTree, container, anchor, moveType);
|
6294 | return;
|
6295 | }
|
6296 | if (shapeFlag & 128 ) {
|
6297 | vnode.suspense.move(container, anchor, moveType);
|
6298 | return;
|
6299 | }
|
6300 | if (shapeFlag & 64 ) {
|
6301 | type.move(vnode, container, anchor, internals);
|
6302 | return;
|
6303 | }
|
6304 | if (type === Fragment) {
|
6305 | hostInsert(el, container, anchor);
|
6306 | for (let i = 0; i < children.length; i++) {
|
6307 | move(children[i], container, anchor, moveType);
|
6308 | }
|
6309 | hostInsert(vnode.anchor, container, anchor);
|
6310 | return;
|
6311 | }
|
6312 | if (type === Static) {
|
6313 | moveStaticNode(vnode, container, anchor);
|
6314 | return;
|
6315 | }
|
6316 |
|
6317 | const needTransition = moveType !== 2 &&
|
6318 | shapeFlag & 1 &&
|
6319 | transition;
|
6320 | if (needTransition) {
|
6321 | if (moveType === 0 ) {
|
6322 | transition.beforeEnter(el);
|
6323 | hostInsert(el, container, anchor);
|
6324 | queuePostRenderEffect(() => transition.enter(el), parentSuspense);
|
6325 | }
|
6326 | else {
|
6327 | const { leave, delayLeave, afterLeave } = transition;
|
6328 | const remove = () => hostInsert(el, container, anchor);
|
6329 | const performLeave = () => {
|
6330 | leave(el, () => {
|
6331 | remove();
|
6332 | afterLeave && afterLeave();
|
6333 | });
|
6334 | };
|
6335 | if (delayLeave) {
|
6336 | delayLeave(el, remove, performLeave);
|
6337 | }
|
6338 | else {
|
6339 | performLeave();
|
6340 | }
|
6341 | }
|
6342 | }
|
6343 | else {
|
6344 | hostInsert(el, container, anchor);
|
6345 | }
|
6346 | };
|
6347 | const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
|
6348 | const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
|
6349 |
|
6350 | if (ref != null) {
|
6351 | setRef(ref, null, parentSuspense, vnode, true);
|
6352 | }
|
6353 | if (shapeFlag & 256 ) {
|
6354 | parentComponent.ctx.deactivate(vnode);
|
6355 | return;
|
6356 | }
|
6357 | const shouldInvokeDirs = shapeFlag & 1 && dirs;
|
6358 | const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
|
6359 | let vnodeHook;
|
6360 | if (shouldInvokeVnodeHook &&
|
6361 | (vnodeHook = props && props.onVnodeBeforeUnmount)) {
|
6362 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
6363 | }
|
6364 | if (shapeFlag & 6 ) {
|
6365 | unmountComponent(vnode.component, parentSuspense, doRemove);
|
6366 | }
|
6367 | else {
|
6368 | if (shapeFlag & 128 ) {
|
6369 | vnode.suspense.unmount(parentSuspense, doRemove);
|
6370 | return;
|
6371 | }
|
6372 | if (shouldInvokeDirs) {
|
6373 | invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
|
6374 | }
|
6375 | if (shapeFlag & 64 ) {
|
6376 | vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
|
6377 | }
|
6378 | else if (dynamicChildren &&
|
6379 |
|
6380 | (type !== Fragment ||
|
6381 | (patchFlag > 0 && patchFlag & 64 ))) {
|
6382 |
|
6383 | unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
|
6384 | }
|
6385 | else if ((type === Fragment &&
|
6386 | patchFlag &
|
6387 | (128 | 256 )) ||
|
6388 | (!optimized && shapeFlag & 16 )) {
|
6389 | unmountChildren(children, parentComponent, parentSuspense);
|
6390 | }
|
6391 | if (doRemove) {
|
6392 | remove(vnode);
|
6393 | }
|
6394 | }
|
6395 | if ((shouldInvokeVnodeHook &&
|
6396 | (vnodeHook = props && props.onVnodeUnmounted)) ||
|
6397 | shouldInvokeDirs) {
|
6398 | queuePostRenderEffect(() => {
|
6399 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
6400 | shouldInvokeDirs &&
|
6401 | invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
|
6402 | }, parentSuspense);
|
6403 | }
|
6404 | };
|
6405 | const remove = vnode => {
|
6406 | const { type, el, anchor, transition } = vnode;
|
6407 | if (type === Fragment) {
|
6408 | removeFragment(el, anchor);
|
6409 | return;
|
6410 | }
|
6411 | if (type === Static) {
|
6412 | removeStaticNode(vnode);
|
6413 | return;
|
6414 | }
|
6415 | const performRemove = () => {
|
6416 | hostRemove(el);
|
6417 | if (transition && !transition.persisted && transition.afterLeave) {
|
6418 | transition.afterLeave();
|
6419 | }
|
6420 | };
|
6421 | if (vnode.shapeFlag & 1 &&
|
6422 | transition &&
|
6423 | !transition.persisted) {
|
6424 | const { leave, delayLeave } = transition;
|
6425 | const performLeave = () => leave(el, performRemove);
|
6426 | if (delayLeave) {
|
6427 | delayLeave(vnode.el, performRemove, performLeave);
|
6428 | }
|
6429 | else {
|
6430 | performLeave();
|
6431 | }
|
6432 | }
|
6433 | else {
|
6434 | performRemove();
|
6435 | }
|
6436 | };
|
6437 | const removeFragment = (cur, end) => {
|
6438 |
|
6439 |
|
6440 | let next;
|
6441 | while (cur !== end) {
|
6442 | next = hostNextSibling(cur);
|
6443 | hostRemove(cur);
|
6444 | cur = next;
|
6445 | }
|
6446 | hostRemove(end);
|
6447 | };
|
6448 | const unmountComponent = (instance, parentSuspense, doRemove) => {
|
6449 | if (instance.type.__hmrId) {
|
6450 | unregisterHMR(instance);
|
6451 | }
|
6452 | const { bum, scope, update, subTree, um } = instance;
|
6453 |
|
6454 | if (bum) {
|
6455 | invokeArrayFns(bum);
|
6456 | }
|
6457 |
|
6458 | scope.stop();
|
6459 |
|
6460 |
|
6461 | if (update) {
|
6462 |
|
6463 | update.active = false;
|
6464 | unmount(subTree, instance, parentSuspense, doRemove);
|
6465 | }
|
6466 |
|
6467 | if (um) {
|
6468 | queuePostRenderEffect(um, parentSuspense);
|
6469 | }
|
6470 | queuePostRenderEffect(() => {
|
6471 | instance.isUnmounted = true;
|
6472 | }, parentSuspense);
|
6473 |
|
6474 |
|
6475 |
|
6476 | if (parentSuspense &&
|
6477 | parentSuspense.pendingBranch &&
|
6478 | !parentSuspense.isUnmounted &&
|
6479 | instance.asyncDep &&
|
6480 | !instance.asyncResolved &&
|
6481 | instance.suspenseId === parentSuspense.pendingId) {
|
6482 | parentSuspense.deps--;
|
6483 | if (parentSuspense.deps === 0) {
|
6484 | parentSuspense.resolve();
|
6485 | }
|
6486 | }
|
6487 | {
|
6488 | devtoolsComponentRemoved(instance);
|
6489 | }
|
6490 | };
|
6491 | const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
|
6492 | for (let i = start; i < children.length; i++) {
|
6493 | unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
|
6494 | }
|
6495 | };
|
6496 | const getNextHostNode = vnode => {
|
6497 | if (vnode.shapeFlag & 6 ) {
|
6498 | return getNextHostNode(vnode.component.subTree);
|
6499 | }
|
6500 | if (vnode.shapeFlag & 128 ) {
|
6501 | return vnode.suspense.next();
|
6502 | }
|
6503 | return hostNextSibling((vnode.anchor || vnode.el));
|
6504 | };
|
6505 | const render = (vnode, container, isSVG) => {
|
6506 | if (vnode == null) {
|
6507 | if (container._vnode) {
|
6508 | unmount(container._vnode, null, null, true);
|
6509 | }
|
6510 | }
|
6511 | else {
|
6512 | patch(container._vnode || null, vnode, container, null, null, null, isSVG);
|
6513 | }
|
6514 | flushPostFlushCbs();
|
6515 | container._vnode = vnode;
|
6516 | };
|
6517 | const internals = {
|
6518 | p: patch,
|
6519 | um: unmount,
|
6520 | m: move,
|
6521 | r: remove,
|
6522 | mt: mountComponent,
|
6523 | mc: mountChildren,
|
6524 | pc: patchChildren,
|
6525 | pbc: patchBlockChildren,
|
6526 | n: getNextHostNode,
|
6527 | o: options
|
6528 | };
|
6529 | let hydrate;
|
6530 | let hydrateNode;
|
6531 | if (createHydrationFns) {
|
6532 | [hydrate, hydrateNode] = createHydrationFns(internals);
|
6533 | }
|
6534 | return {
|
6535 | render,
|
6536 | hydrate,
|
6537 | createApp: createAppAPI(render, hydrate)
|
6538 | };
|
6539 | }
|
6540 | function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
|
6541 | if (isArray(rawRef)) {
|
6542 | rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
|
6543 | return;
|
6544 | }
|
6545 | if (isAsyncWrapper(vnode) && !isUnmount) {
|
6546 |
|
6547 |
|
6548 | return;
|
6549 | }
|
6550 | const refValue = vnode.shapeFlag & 4
|
6551 | ? getExposeProxy(vnode.component) || vnode.component.proxy
|
6552 | : vnode.el;
|
6553 | const value = isUnmount ? null : refValue;
|
6554 | const { i: owner, r: ref } = rawRef;
|
6555 | if (!owner) {
|
6556 | warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
|
6557 | `A vnode with ref must be created inside the render function.`);
|
6558 | return;
|
6559 | }
|
6560 | const oldRef = oldRawRef && oldRawRef.r;
|
6561 | const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
|
6562 | const setupState = owner.setupState;
|
6563 |
|
6564 | if (oldRef != null && oldRef !== ref) {
|
6565 | if (isString(oldRef)) {
|
6566 | refs[oldRef] = null;
|
6567 | if (hasOwn(setupState, oldRef)) {
|
6568 | setupState[oldRef] = null;
|
6569 | }
|
6570 | }
|
6571 | else if (isRef(oldRef)) {
|
6572 | oldRef.value = null;
|
6573 | }
|
6574 | }
|
6575 | if (isString(ref)) {
|
6576 | const doSet = () => {
|
6577 | {
|
6578 | refs[ref] = value;
|
6579 | }
|
6580 | if (hasOwn(setupState, ref)) {
|
6581 | setupState[ref] = value;
|
6582 | }
|
6583 | };
|
6584 |
|
6585 |
|
6586 |
|
6587 | if (value) {
|
6588 | doSet.id = -1;
|
6589 | queuePostRenderEffect(doSet, parentSuspense);
|
6590 | }
|
6591 | else {
|
6592 | doSet();
|
6593 | }
|
6594 | }
|
6595 | else if (isRef(ref)) {
|
6596 | const doSet = () => {
|
6597 | ref.value = value;
|
6598 | };
|
6599 | if (value) {
|
6600 | doSet.id = -1;
|
6601 | queuePostRenderEffect(doSet, parentSuspense);
|
6602 | }
|
6603 | else {
|
6604 | doSet();
|
6605 | }
|
6606 | }
|
6607 | else if (isFunction(ref)) {
|
6608 | callWithErrorHandling(ref, owner, 12 , [value, refs]);
|
6609 | }
|
6610 | else {
|
6611 | warn$1('Invalid template ref type:', value, `(${typeof value})`);
|
6612 | }
|
6613 | }
|
6614 | function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
6615 | callWithAsyncErrorHandling(hook, instance, 7 , [
|
6616 | vnode,
|
6617 | prevVNode
|
6618 | ]);
|
6619 | }
|
6620 | |
6621 |
|
6622 |
|
6623 |
|
6624 |
|
6625 |
|
6626 |
|
6627 |
|
6628 |
|
6629 |
|
6630 |
|
6631 | function traverseStaticChildren(n1, n2, shallow = false) {
|
6632 | const ch1 = n1.children;
|
6633 | const ch2 = n2.children;
|
6634 | if (isArray(ch1) && isArray(ch2)) {
|
6635 | for (let i = 0; i < ch1.length; i++) {
|
6636 |
|
6637 |
|
6638 | const c1 = ch1[i];
|
6639 | let c2 = ch2[i];
|
6640 | if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
|
6641 | if (c2.patchFlag <= 0 || c2.patchFlag === 32 ) {
|
6642 | c2 = ch2[i] = cloneIfMounted(ch2[i]);
|
6643 | c2.el = c1.el;
|
6644 | }
|
6645 | if (!shallow)
|
6646 | traverseStaticChildren(c1, c2);
|
6647 | }
|
6648 |
|
6649 |
|
6650 | if (c2.type === Comment && !c2.el) {
|
6651 | c2.el = c1.el;
|
6652 | }
|
6653 | }
|
6654 | }
|
6655 | }
|
6656 |
|
6657 | function getSequence(arr) {
|
6658 | const p = arr.slice();
|
6659 | const result = [0];
|
6660 | let i, j, u, v, c;
|
6661 | const len = arr.length;
|
6662 | for (i = 0; i < len; i++) {
|
6663 | const arrI = arr[i];
|
6664 | if (arrI !== 0) {
|
6665 | j = result[result.length - 1];
|
6666 | if (arr[j] < arrI) {
|
6667 | p[i] = j;
|
6668 | result.push(i);
|
6669 | continue;
|
6670 | }
|
6671 | u = 0;
|
6672 | v = result.length - 1;
|
6673 | while (u < v) {
|
6674 | c = (u + v) >> 1;
|
6675 | if (arr[result[c]] < arrI) {
|
6676 | u = c + 1;
|
6677 | }
|
6678 | else {
|
6679 | v = c;
|
6680 | }
|
6681 | }
|
6682 | if (arrI < arr[result[u]]) {
|
6683 | if (u > 0) {
|
6684 | p[i] = result[u - 1];
|
6685 | }
|
6686 | result[u] = i;
|
6687 | }
|
6688 | }
|
6689 | }
|
6690 | u = result.length;
|
6691 | v = result[u - 1];
|
6692 | while (u-- > 0) {
|
6693 | result[u] = v;
|
6694 | v = p[v];
|
6695 | }
|
6696 | return result;
|
6697 | }
|
6698 |
|
6699 | const isTeleport = (type) => type.__isTeleport;
|
6700 | const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
|
6701 | const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
|
6702 | const resolveTarget = (props, select) => {
|
6703 | const targetSelector = props && props.to;
|
6704 | if (isString(targetSelector)) {
|
6705 | if (!select) {
|
6706 | warn$1(`Current renderer does not support string target for Teleports. ` +
|
6707 | `(missing querySelector renderer option)`);
|
6708 | return null;
|
6709 | }
|
6710 | else {
|
6711 | const target = select(targetSelector);
|
6712 | if (!target) {
|
6713 | warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
|
6714 | `Note the target element must exist before the component is mounted - ` +
|
6715 | `i.e. the target cannot be rendered by the component itself, and ` +
|
6716 | `ideally should be outside of the entire Vue component tree.`);
|
6717 | }
|
6718 | return target;
|
6719 | }
|
6720 | }
|
6721 | else {
|
6722 | if (!targetSelector && !isTeleportDisabled(props)) {
|
6723 | warn$1(`Invalid Teleport target: ${targetSelector}`);
|
6724 | }
|
6725 | return targetSelector;
|
6726 | }
|
6727 | };
|
6728 | const TeleportImpl = {
|
6729 | __isTeleport: true,
|
6730 | process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
|
6731 | const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
|
6732 | const disabled = isTeleportDisabled(n2.props);
|
6733 | let { shapeFlag, children, dynamicChildren } = n2;
|
6734 |
|
6735 |
|
6736 | if (isHmrUpdating) {
|
6737 | optimized = false;
|
6738 | dynamicChildren = null;
|
6739 | }
|
6740 | if (n1 == null) {
|
6741 |
|
6742 | const placeholder = (n2.el = createComment('teleport start')
|
6743 | );
|
6744 | const mainAnchor = (n2.anchor = createComment('teleport end')
|
6745 | );
|
6746 | insert(placeholder, container, anchor);
|
6747 | insert(mainAnchor, container, anchor);
|
6748 | const target = (n2.target = resolveTarget(n2.props, querySelector));
|
6749 | const targetAnchor = (n2.targetAnchor = createText(''));
|
6750 | if (target) {
|
6751 | insert(targetAnchor, target);
|
6752 |
|
6753 | isSVG = isSVG || isTargetSVG(target);
|
6754 | }
|
6755 | else if (!disabled) {
|
6756 | warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
|
6757 | }
|
6758 | const mount = (container, anchor) => {
|
6759 |
|
6760 |
|
6761 | if (shapeFlag & 16 ) {
|
6762 | mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6763 | }
|
6764 | };
|
6765 | if (disabled) {
|
6766 | mount(container, mainAnchor);
|
6767 | }
|
6768 | else if (target) {
|
6769 | mount(target, targetAnchor);
|
6770 | }
|
6771 | }
|
6772 | else {
|
6773 |
|
6774 | n2.el = n1.el;
|
6775 | const mainAnchor = (n2.anchor = n1.anchor);
|
6776 | const target = (n2.target = n1.target);
|
6777 | const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
|
6778 | const wasDisabled = isTeleportDisabled(n1.props);
|
6779 | const currentContainer = wasDisabled ? container : target;
|
6780 | const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
|
6781 | isSVG = isSVG || isTargetSVG(target);
|
6782 | if (dynamicChildren) {
|
6783 |
|
6784 | patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
|
6785 |
|
6786 |
|
6787 |
|
6788 | traverseStaticChildren(n1, n2, true);
|
6789 | }
|
6790 | else if (!optimized) {
|
6791 | patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
|
6792 | }
|
6793 | if (disabled) {
|
6794 | if (!wasDisabled) {
|
6795 |
|
6796 |
|
6797 | moveTeleport(n2, container, mainAnchor, internals, 1 );
|
6798 | }
|
6799 | }
|
6800 | else {
|
6801 |
|
6802 | if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
|
6803 | const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
|
6804 | if (nextTarget) {
|
6805 | moveTeleport(n2, nextTarget, null, internals, 0 );
|
6806 | }
|
6807 | else {
|
6808 | warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
|
6809 | }
|
6810 | }
|
6811 | else if (wasDisabled) {
|
6812 |
|
6813 |
|
6814 | moveTeleport(n2, target, targetAnchor, internals, 1 );
|
6815 | }
|
6816 | }
|
6817 | }
|
6818 | },
|
6819 | remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
|
6820 | const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
|
6821 | if (target) {
|
6822 | hostRemove(targetAnchor);
|
6823 | }
|
6824 |
|
6825 | if (doRemove || !isTeleportDisabled(props)) {
|
6826 | hostRemove(anchor);
|
6827 | if (shapeFlag & 16 ) {
|
6828 | for (let i = 0; i < children.length; i++) {
|
6829 | const child = children[i];
|
6830 | unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
|
6831 | }
|
6832 | }
|
6833 | }
|
6834 | },
|
6835 | move: moveTeleport,
|
6836 | hydrate: hydrateTeleport
|
6837 | };
|
6838 | function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
|
6839 |
|
6840 | if (moveType === 0 ) {
|
6841 | insert(vnode.targetAnchor, container, parentAnchor);
|
6842 | }
|
6843 | const { el, anchor, shapeFlag, children, props } = vnode;
|
6844 | const isReorder = moveType === 2 ;
|
6845 |
|
6846 | if (isReorder) {
|
6847 | insert(el, container, parentAnchor);
|
6848 | }
|
6849 |
|
6850 |
|
6851 |
|
6852 | if (!isReorder || isTeleportDisabled(props)) {
|
6853 |
|
6854 | if (shapeFlag & 16 ) {
|
6855 | for (let i = 0; i < children.length; i++) {
|
6856 | move(children[i], container, parentAnchor, 2 );
|
6857 | }
|
6858 | }
|
6859 | }
|
6860 |
|
6861 | if (isReorder) {
|
6862 | insert(anchor, container, parentAnchor);
|
6863 | }
|
6864 | }
|
6865 | function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
|
6866 | const target = (vnode.target = resolveTarget(vnode.props, querySelector));
|
6867 | if (target) {
|
6868 |
|
6869 |
|
6870 | const targetNode = target._lpa || target.firstChild;
|
6871 | if (vnode.shapeFlag & 16 ) {
|
6872 | if (isTeleportDisabled(vnode.props)) {
|
6873 | vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
|
6874 | vnode.targetAnchor = targetNode;
|
6875 | }
|
6876 | else {
|
6877 | vnode.anchor = nextSibling(node);
|
6878 | vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
|
6879 | }
|
6880 | target._lpa =
|
6881 | vnode.targetAnchor && nextSibling(vnode.targetAnchor);
|
6882 | }
|
6883 | }
|
6884 | return vnode.anchor && nextSibling(vnode.anchor);
|
6885 | }
|
6886 |
|
6887 | const Teleport = TeleportImpl;
|
6888 |
|
6889 | const COMPONENTS = 'components';
|
6890 | const DIRECTIVES = 'directives';
|
6891 | |
6892 |
|
6893 |
|
6894 | function resolveComponent(name, maybeSelfReference) {
|
6895 | return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
6896 | }
|
6897 | const NULL_DYNAMIC_COMPONENT = Symbol();
|
6898 | |
6899 |
|
6900 |
|
6901 | function resolveDynamicComponent(component) {
|
6902 | if (isString(component)) {
|
6903 | return resolveAsset(COMPONENTS, component, false) || component;
|
6904 | }
|
6905 | else {
|
6906 |
|
6907 | return (component || NULL_DYNAMIC_COMPONENT);
|
6908 | }
|
6909 | }
|
6910 | |
6911 |
|
6912 |
|
6913 | function resolveDirective(name) {
|
6914 | return resolveAsset(DIRECTIVES, name);
|
6915 | }
|
6916 |
|
6917 | function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
6918 | const instance = currentRenderingInstance || currentInstance;
|
6919 | if (instance) {
|
6920 | const Component = instance.type;
|
6921 |
|
6922 | if (type === COMPONENTS) {
|
6923 | const selfName = getComponentName(Component);
|
6924 | if (selfName &&
|
6925 | (selfName === name ||
|
6926 | selfName === camelize(name) ||
|
6927 | selfName === capitalize(camelize(name)))) {
|
6928 | return Component;
|
6929 | }
|
6930 | }
|
6931 | const res =
|
6932 |
|
6933 |
|
6934 | resolve(instance[type] || Component[type], name) ||
|
6935 |
|
6936 | resolve(instance.appContext[type], name);
|
6937 | if (!res && maybeSelfReference) {
|
6938 |
|
6939 | return Component;
|
6940 | }
|
6941 | if (warnMissing && !res) {
|
6942 | warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
|
6943 | }
|
6944 | return res;
|
6945 | }
|
6946 | else {
|
6947 | warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
|
6948 | `can only be used in render() or setup().`);
|
6949 | }
|
6950 | }
|
6951 | function resolve(registry, name) {
|
6952 | return (registry &&
|
6953 | (registry[name] ||
|
6954 | registry[camelize(name)] ||
|
6955 | registry[capitalize(camelize(name))]));
|
6956 | }
|
6957 |
|
6958 | const Fragment = Symbol('Fragment' );
|
6959 | const Text = Symbol('Text' );
|
6960 | const Comment = Symbol('Comment' );
|
6961 | const Static = Symbol('Static' );
|
6962 |
|
6963 |
|
6964 |
|
6965 |
|
6966 |
|
6967 | const blockStack = [];
|
6968 | let currentBlock = null;
|
6969 | |
6970 |
|
6971 |
|
6972 |
|
6973 |
|
6974 |
|
6975 |
|
6976 |
|
6977 |
|
6978 |
|
6979 |
|
6980 |
|
6981 |
|
6982 |
|
6983 |
|
6984 |
|
6985 | function openBlock(disableTracking = false) {
|
6986 | blockStack.push((currentBlock = disableTracking ? null : []));
|
6987 | }
|
6988 | function closeBlock() {
|
6989 | blockStack.pop();
|
6990 | currentBlock = blockStack[blockStack.length - 1] || null;
|
6991 | }
|
6992 |
|
6993 |
|
6994 |
|
6995 |
|
6996 | let isBlockTreeEnabled = 1;
|
6997 | |
6998 |
|
6999 |
|
7000 |
|
7001 |
|
7002 |
|
7003 |
|
7004 |
|
7005 |
|
7006 |
|
7007 |
|
7008 |
|
7009 |
|
7010 |
|
7011 |
|
7012 |
|
7013 | function setBlockTracking(value) {
|
7014 | isBlockTreeEnabled += value;
|
7015 | }
|
7016 | function setupBlock(vnode) {
|
7017 |
|
7018 | vnode.dynamicChildren =
|
7019 | isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
|
7020 |
|
7021 | closeBlock();
|
7022 |
|
7023 |
|
7024 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
7025 | currentBlock.push(vnode);
|
7026 | }
|
7027 | return vnode;
|
7028 | }
|
7029 | |
7030 |
|
7031 |
|
7032 | function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
|
7033 | return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true ));
|
7034 | }
|
7035 | |
7036 |
|
7037 |
|
7038 |
|
7039 |
|
7040 |
|
7041 |
|
7042 | function createBlock(type, props, children, patchFlag, dynamicProps) {
|
7043 | return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true ));
|
7044 | }
|
7045 | function isVNode(value) {
|
7046 | return value ? value.__v_isVNode === true : false;
|
7047 | }
|
7048 | function isSameVNodeType(n1, n2) {
|
7049 | if (n2.shapeFlag & 6 &&
|
7050 | hmrDirtyComponents.has(n2.type)) {
|
7051 |
|
7052 | return false;
|
7053 | }
|
7054 | return n1.type === n2.type && n1.key === n2.key;
|
7055 | }
|
7056 | let vnodeArgsTransformer;
|
7057 | |
7058 |
|
7059 |
|
7060 |
|
7061 |
|
7062 |
|
7063 | function transformVNodeArgs(transformer) {
|
7064 | vnodeArgsTransformer = transformer;
|
7065 | }
|
7066 | const createVNodeWithArgsTransform = (...args) => {
|
7067 | return _createVNode(...(vnodeArgsTransformer
|
7068 | ? vnodeArgsTransformer(args, currentRenderingInstance)
|
7069 | : args));
|
7070 | };
|
7071 | const InternalObjectKey = `__vInternal`;
|
7072 | const normalizeKey = ({ key }) => key != null ? key : null;
|
7073 | const normalizeRef = ({ ref }) => {
|
7074 | return (ref != null
|
7075 | ? isString(ref) || isRef(ref) || isFunction(ref)
|
7076 | ? { i: currentRenderingInstance, r: ref }
|
7077 | : ref
|
7078 | : null);
|
7079 | };
|
7080 | function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
|
7081 | const vnode = {
|
7082 | __v_isVNode: true,
|
7083 | __v_skip: true,
|
7084 | type,
|
7085 | props,
|
7086 | key: props && normalizeKey(props),
|
7087 | ref: props && normalizeRef(props),
|
7088 | scopeId: currentScopeId,
|
7089 | slotScopeIds: null,
|
7090 | children,
|
7091 | component: null,
|
7092 | suspense: null,
|
7093 | ssContent: null,
|
7094 | ssFallback: null,
|
7095 | dirs: null,
|
7096 | transition: null,
|
7097 | el: null,
|
7098 | anchor: null,
|
7099 | target: null,
|
7100 | targetAnchor: null,
|
7101 | staticCount: 0,
|
7102 | shapeFlag,
|
7103 | patchFlag,
|
7104 | dynamicProps,
|
7105 | dynamicChildren: null,
|
7106 | appContext: null
|
7107 | };
|
7108 | if (needFullChildrenNormalization) {
|
7109 | normalizeChildren(vnode, children);
|
7110 |
|
7111 | if (shapeFlag & 128 ) {
|
7112 | type.normalize(vnode);
|
7113 | }
|
7114 | }
|
7115 | else if (children) {
|
7116 |
|
7117 |
|
7118 | vnode.shapeFlag |= isString(children)
|
7119 | ? 8
|
7120 | : 16 ;
|
7121 | }
|
7122 |
|
7123 | if (vnode.key !== vnode.key) {
|
7124 | warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
7125 | }
|
7126 |
|
7127 | if (isBlockTreeEnabled > 0 &&
|
7128 |
|
7129 | !isBlockNode &&
|
7130 |
|
7131 | currentBlock &&
|
7132 |
|
7133 |
|
7134 |
|
7135 |
|
7136 | (vnode.patchFlag > 0 || shapeFlag & 6 ) &&
|
7137 |
|
7138 |
|
7139 | vnode.patchFlag !== 32 ) {
|
7140 | currentBlock.push(vnode);
|
7141 | }
|
7142 | return vnode;
|
7143 | }
|
7144 | const createVNode = (createVNodeWithArgsTransform );
|
7145 | function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
7146 | if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
7147 | if (!type) {
|
7148 | warn$1(`Invalid vnode type when creating vnode: ${type}.`);
|
7149 | }
|
7150 | type = Comment;
|
7151 | }
|
7152 | if (isVNode(type)) {
|
7153 |
|
7154 |
|
7155 |
|
7156 | const cloned = cloneVNode(type, props, true );
|
7157 | if (children) {
|
7158 | normalizeChildren(cloned, children);
|
7159 | }
|
7160 | return cloned;
|
7161 | }
|
7162 |
|
7163 | if (isClassComponent(type)) {
|
7164 | type = type.__vccOpts;
|
7165 | }
|
7166 |
|
7167 | if (props) {
|
7168 |
|
7169 | props = guardReactiveProps(props);
|
7170 | let { class: klass, style } = props;
|
7171 | if (klass && !isString(klass)) {
|
7172 | props.class = normalizeClass(klass);
|
7173 | }
|
7174 | if (isObject(style)) {
|
7175 |
|
7176 |
|
7177 | if (isProxy(style) && !isArray(style)) {
|
7178 | style = extend({}, style);
|
7179 | }
|
7180 | props.style = normalizeStyle(style);
|
7181 | }
|
7182 | }
|
7183 |
|
7184 | const shapeFlag = isString(type)
|
7185 | ? 1
|
7186 | : isSuspense(type)
|
7187 | ? 128
|
7188 | : isTeleport(type)
|
7189 | ? 64
|
7190 | : isObject(type)
|
7191 | ? 4
|
7192 | : isFunction(type)
|
7193 | ? 2
|
7194 | : 0;
|
7195 | if (shapeFlag & 4 && isProxy(type)) {
|
7196 | type = toRaw(type);
|
7197 | warn$1(`Vue received a Component which was made a reactive object. This can ` +
|
7198 | `lead to unnecessary performance overhead, and should be avoided by ` +
|
7199 | `marking the component with \`markRaw\` or using \`shallowRef\` ` +
|
7200 | `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
|
7201 | }
|
7202 | return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
|
7203 | }
|
7204 | function guardReactiveProps(props) {
|
7205 | if (!props)
|
7206 | return null;
|
7207 | return isProxy(props) || InternalObjectKey in props
|
7208 | ? extend({}, props)
|
7209 | : props;
|
7210 | }
|
7211 | function cloneVNode(vnode, extraProps, mergeRef = false) {
|
7212 |
|
7213 |
|
7214 | const { props, ref, patchFlag, children } = vnode;
|
7215 | const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
|
7216 | const cloned = {
|
7217 | __v_isVNode: true,
|
7218 | __v_skip: true,
|
7219 | type: vnode.type,
|
7220 | props: mergedProps,
|
7221 | key: mergedProps && normalizeKey(mergedProps),
|
7222 | ref: extraProps && extraProps.ref
|
7223 | ?
|
7224 |
|
7225 |
|
7226 | mergeRef && ref
|
7227 | ? isArray(ref)
|
7228 | ? ref.concat(normalizeRef(extraProps))
|
7229 | : [ref, normalizeRef(extraProps)]
|
7230 | : normalizeRef(extraProps)
|
7231 | : ref,
|
7232 | scopeId: vnode.scopeId,
|
7233 | slotScopeIds: vnode.slotScopeIds,
|
7234 | children: patchFlag === -1 && isArray(children)
|
7235 | ? children.map(deepCloneVNode)
|
7236 | : children,
|
7237 | target: vnode.target,
|
7238 | targetAnchor: vnode.targetAnchor,
|
7239 | staticCount: vnode.staticCount,
|
7240 | shapeFlag: vnode.shapeFlag,
|
7241 |
|
7242 |
|
7243 |
|
7244 |
|
7245 | patchFlag: extraProps && vnode.type !== Fragment
|
7246 | ? patchFlag === -1
|
7247 | ? 16
|
7248 | : patchFlag | 16
|
7249 | : patchFlag,
|
7250 | dynamicProps: vnode.dynamicProps,
|
7251 | dynamicChildren: vnode.dynamicChildren,
|
7252 | appContext: vnode.appContext,
|
7253 | dirs: vnode.dirs,
|
7254 | transition: vnode.transition,
|
7255 |
|
7256 |
|
7257 |
|
7258 |
|
7259 | component: vnode.component,
|
7260 | suspense: vnode.suspense,
|
7261 | ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
7262 | ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
7263 | el: vnode.el,
|
7264 | anchor: vnode.anchor
|
7265 | };
|
7266 | return cloned;
|
7267 | }
|
7268 | |
7269 |
|
7270 |
|
7271 |
|
7272 | function deepCloneVNode(vnode) {
|
7273 | const cloned = cloneVNode(vnode);
|
7274 | if (isArray(vnode.children)) {
|
7275 | cloned.children = vnode.children.map(deepCloneVNode);
|
7276 | }
|
7277 | return cloned;
|
7278 | }
|
7279 | |
7280 |
|
7281 |
|
7282 | function createTextVNode(text = ' ', flag = 0) {
|
7283 | return createVNode(Text, null, text, flag);
|
7284 | }
|
7285 | |
7286 |
|
7287 |
|
7288 | function createStaticVNode(content, numberOfNodes) {
|
7289 |
|
7290 |
|
7291 | const vnode = createVNode(Static, null, content);
|
7292 | vnode.staticCount = numberOfNodes;
|
7293 | return vnode;
|
7294 | }
|
7295 | |
7296 |
|
7297 |
|
7298 | function createCommentVNode(text = '',
|
7299 | // when used as the v-else branch, the comment node must be created as a
|
7300 | // block to ensure correct updates.
|
7301 | asBlock = false) {
|
7302 | return asBlock
|
7303 | ? (openBlock(), createBlock(Comment, null, text))
|
7304 | : createVNode(Comment, null, text);
|
7305 | }
|
7306 | function normalizeVNode(child) {
|
7307 | if (child == null || typeof child === 'boolean') {
|
7308 |
|
7309 | return createVNode(Comment);
|
7310 | }
|
7311 | else if (isArray(child)) {
|
7312 |
|
7313 | return createVNode(Fragment, null,
|
7314 |
|
7315 | child.slice());
|
7316 | }
|
7317 | else if (typeof child === 'object') {
|
7318 |
|
7319 |
|
7320 | return cloneIfMounted(child);
|
7321 | }
|
7322 | else {
|
7323 |
|
7324 | return createVNode(Text, null, String(child));
|
7325 | }
|
7326 | }
|
7327 |
|
7328 | function cloneIfMounted(child) {
|
7329 | return child.el === null || child.memo ? child : cloneVNode(child);
|
7330 | }
|
7331 | function normalizeChildren(vnode, children) {
|
7332 | let type = 0;
|
7333 | const { shapeFlag } = vnode;
|
7334 | if (children == null) {
|
7335 | children = null;
|
7336 | }
|
7337 | else if (isArray(children)) {
|
7338 | type = 16 ;
|
7339 | }
|
7340 | else if (typeof children === 'object') {
|
7341 | if (shapeFlag & (1 | 64 )) {
|
7342 |
|
7343 | const slot = children.default;
|
7344 | if (slot) {
|
7345 |
|
7346 | slot._c && (slot._d = false);
|
7347 | normalizeChildren(vnode, slot());
|
7348 | slot._c && (slot._d = true);
|
7349 | }
|
7350 | return;
|
7351 | }
|
7352 | else {
|
7353 | type = 32 ;
|
7354 | const slotFlag = children._;
|
7355 | if (!slotFlag && !(InternalObjectKey in children)) {
|
7356 | children._ctx = currentRenderingInstance;
|
7357 | }
|
7358 | else if (slotFlag === 3 && currentRenderingInstance) {
|
7359 |
|
7360 |
|
7361 | if (currentRenderingInstance.slots._ === 1 ) {
|
7362 | children._ = 1 ;
|
7363 | }
|
7364 | else {
|
7365 | children._ = 2 ;
|
7366 | vnode.patchFlag |= 1024 ;
|
7367 | }
|
7368 | }
|
7369 | }
|
7370 | }
|
7371 | else if (isFunction(children)) {
|
7372 | children = { default: children, _ctx: currentRenderingInstance };
|
7373 | type = 32 ;
|
7374 | }
|
7375 | else {
|
7376 | children = String(children);
|
7377 |
|
7378 | if (shapeFlag & 64 ) {
|
7379 | type = 16 ;
|
7380 | children = [createTextVNode(children)];
|
7381 | }
|
7382 | else {
|
7383 | type = 8 ;
|
7384 | }
|
7385 | }
|
7386 | vnode.children = children;
|
7387 | vnode.shapeFlag |= type;
|
7388 | }
|
7389 | function mergeProps(...args) {
|
7390 | const ret = {};
|
7391 | for (let i = 0; i < args.length; i++) {
|
7392 | const toMerge = args[i];
|
7393 | for (const key in toMerge) {
|
7394 | if (key === 'class') {
|
7395 | if (ret.class !== toMerge.class) {
|
7396 | ret.class = normalizeClass([ret.class, toMerge.class]);
|
7397 | }
|
7398 | }
|
7399 | else if (key === 'style') {
|
7400 | ret.style = normalizeStyle([ret.style, toMerge.style]);
|
7401 | }
|
7402 | else if (isOn(key)) {
|
7403 | const existing = ret[key];
|
7404 | const incoming = toMerge[key];
|
7405 | if (existing !== incoming) {
|
7406 | ret[key] = existing
|
7407 | ? [].concat(existing, incoming)
|
7408 | : incoming;
|
7409 | }
|
7410 | }
|
7411 | else if (key !== '') {
|
7412 | ret[key] = toMerge[key];
|
7413 | }
|
7414 | }
|
7415 | }
|
7416 | return ret;
|
7417 | }
|
7418 |
|
7419 | |
7420 |
|
7421 |
|
7422 | function renderList(source, renderItem, cache, index) {
|
7423 | let ret;
|
7424 | const cached = (cache && cache[index]);
|
7425 | if (isArray(source) || isString(source)) {
|
7426 | ret = new Array(source.length);
|
7427 | for (let i = 0, l = source.length; i < l; i++) {
|
7428 | ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
|
7429 | }
|
7430 | }
|
7431 | else if (typeof source === 'number') {
|
7432 | if (!Number.isInteger(source)) {
|
7433 | warn$1(`The v-for range expect an integer value but got ${source}.`);
|
7434 | return [];
|
7435 | }
|
7436 | ret = new Array(source);
|
7437 | for (let i = 0; i < source; i++) {
|
7438 | ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
|
7439 | }
|
7440 | }
|
7441 | else if (isObject(source)) {
|
7442 | if (source[Symbol.iterator]) {
|
7443 | ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
|
7444 | }
|
7445 | else {
|
7446 | const keys = Object.keys(source);
|
7447 | ret = new Array(keys.length);
|
7448 | for (let i = 0, l = keys.length; i < l; i++) {
|
7449 | const key = keys[i];
|
7450 | ret[i] = renderItem(source[key], key, i, cached && cached[i]);
|
7451 | }
|
7452 | }
|
7453 | }
|
7454 | else {
|
7455 | ret = [];
|
7456 | }
|
7457 | if (cache) {
|
7458 | cache[index] = ret;
|
7459 | }
|
7460 | return ret;
|
7461 | }
|
7462 |
|
7463 | |
7464 |
|
7465 |
|
7466 |
|
7467 | function createSlots(slots, dynamicSlots) {
|
7468 | for (let i = 0; i < dynamicSlots.length; i++) {
|
7469 | const slot = dynamicSlots[i];
|
7470 |
|
7471 | if (isArray(slot)) {
|
7472 | for (let j = 0; j < slot.length; j++) {
|
7473 | slots[slot[j].name] = slot[j].fn;
|
7474 | }
|
7475 | }
|
7476 | else if (slot) {
|
7477 |
|
7478 | slots[slot.name] = slot.fn;
|
7479 | }
|
7480 | }
|
7481 | return slots;
|
7482 | }
|
7483 |
|
7484 | |
7485 |
|
7486 |
|
7487 |
|
7488 | function renderSlot(slots, name, props = {},
|
7489 | // this is not a user-facing function, so the fallback is always generated by
|
7490 | // the compiler and guaranteed to be a function returning an array
|
7491 | fallback, noSlotted) {
|
7492 | if (currentRenderingInstance.isCE) {
|
7493 | return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
|
7494 | }
|
7495 | let slot = slots[name];
|
7496 | if (slot && slot.length > 1) {
|
7497 | warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
|
7498 | `function. You need to mark this component with $dynamic-slots in the ` +
|
7499 | `parent template.`);
|
7500 | slot = () => [];
|
7501 | }
|
7502 |
|
7503 |
|
7504 |
|
7505 |
|
7506 | if (slot && slot._c) {
|
7507 | slot._d = false;
|
7508 | }
|
7509 | openBlock();
|
7510 | const validSlotContent = slot && ensureValidVNode(slot(props));
|
7511 | const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1
|
7512 | ? 64
|
7513 | : -2 );
|
7514 | if (!noSlotted && rendered.scopeId) {
|
7515 | rendered.slotScopeIds = [rendered.scopeId + '-s'];
|
7516 | }
|
7517 | if (slot && slot._c) {
|
7518 | slot._d = true;
|
7519 | }
|
7520 | return rendered;
|
7521 | }
|
7522 | function ensureValidVNode(vnodes) {
|
7523 | return vnodes.some(child => {
|
7524 | if (!isVNode(child))
|
7525 | return true;
|
7526 | if (child.type === Comment)
|
7527 | return false;
|
7528 | if (child.type === Fragment &&
|
7529 | !ensureValidVNode(child.children))
|
7530 | return false;
|
7531 | return true;
|
7532 | })
|
7533 | ? vnodes
|
7534 | : null;
|
7535 | }
|
7536 |
|
7537 | |
7538 |
|
7539 |
|
7540 |
|
7541 | function toHandlers(obj) {
|
7542 | const ret = {};
|
7543 | if (!isObject(obj)) {
|
7544 | warn$1(`v-on with no argument expects an object value.`);
|
7545 | return ret;
|
7546 | }
|
7547 | for (const key in obj) {
|
7548 | ret[toHandlerKey(key)] = obj[key];
|
7549 | }
|
7550 | return ret;
|
7551 | }
|
7552 |
|
7553 | |
7554 |
|
7555 |
|
7556 |
|
7557 |
|
7558 | const getPublicInstance = (i) => {
|
7559 | if (!i)
|
7560 | return null;
|
7561 | if (isStatefulComponent(i))
|
7562 | return getExposeProxy(i) || i.proxy;
|
7563 | return getPublicInstance(i.parent);
|
7564 | };
|
7565 | const publicPropertiesMap = extend(Object.create(null), {
|
7566 | $: i => i,
|
7567 | $el: i => i.vnode.el,
|
7568 | $data: i => i.data,
|
7569 | $props: i => (shallowReadonly(i.props) ),
|
7570 | $attrs: i => (shallowReadonly(i.attrs) ),
|
7571 | $slots: i => (shallowReadonly(i.slots) ),
|
7572 | $refs: i => (shallowReadonly(i.refs) ),
|
7573 | $parent: i => getPublicInstance(i.parent),
|
7574 | $root: i => getPublicInstance(i.root),
|
7575 | $emit: i => i.emit,
|
7576 | $options: i => (resolveMergedOptions(i) ),
|
7577 | $forceUpdate: i => () => queueJob(i.update),
|
7578 | $nextTick: i => nextTick.bind(i.proxy),
|
7579 | $watch: i => (instanceWatch.bind(i) )
|
7580 | });
|
7581 | const PublicInstanceProxyHandlers = {
|
7582 | get({ _: instance }, key) {
|
7583 | const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
7584 |
|
7585 | if (key === '__isVue') {
|
7586 | return true;
|
7587 | }
|
7588 |
|
7589 |
|
7590 |
|
7591 |
|
7592 | if (setupState !== EMPTY_OBJ &&
|
7593 | setupState.__isScriptSetup &&
|
7594 | hasOwn(setupState, key)) {
|
7595 | return setupState[key];
|
7596 | }
|
7597 |
|
7598 |
|
7599 |
|
7600 |
|
7601 |
|
7602 |
|
7603 | let normalizedProps;
|
7604 | if (key[0] !== '$') {
|
7605 | const n = accessCache[key];
|
7606 | if (n !== undefined) {
|
7607 | switch (n) {
|
7608 | case 0 :
|
7609 | return setupState[key];
|
7610 | case 1 :
|
7611 | return data[key];
|
7612 | case 3 :
|
7613 | return ctx[key];
|
7614 | case 2 :
|
7615 | return props[key];
|
7616 |
|
7617 | }
|
7618 | }
|
7619 | else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
|
7620 | accessCache[key] = 0 ;
|
7621 | return setupState[key];
|
7622 | }
|
7623 | else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
7624 | accessCache[key] = 1 ;
|
7625 | return data[key];
|
7626 | }
|
7627 | else if (
|
7628 |
|
7629 |
|
7630 | (normalizedProps = instance.propsOptions[0]) &&
|
7631 | hasOwn(normalizedProps, key)) {
|
7632 | accessCache[key] = 2 ;
|
7633 | return props[key];
|
7634 | }
|
7635 | else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
7636 | accessCache[key] = 3 ;
|
7637 | return ctx[key];
|
7638 | }
|
7639 | else if (shouldCacheAccess) {
|
7640 | accessCache[key] = 4 ;
|
7641 | }
|
7642 | }
|
7643 | const publicGetter = publicPropertiesMap[key];
|
7644 | let cssModule, globalProperties;
|
7645 |
|
7646 | if (publicGetter) {
|
7647 | if (key === '$attrs') {
|
7648 | track(instance, "get" , key);
|
7649 | markAttrsAccessed();
|
7650 | }
|
7651 | return publicGetter(instance);
|
7652 | }
|
7653 | else if (
|
7654 |
|
7655 | (cssModule = type.__cssModules) &&
|
7656 | (cssModule = cssModule[key])) {
|
7657 | return cssModule;
|
7658 | }
|
7659 | else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
7660 |
|
7661 | accessCache[key] = 3 ;
|
7662 | return ctx[key];
|
7663 | }
|
7664 | else if (
|
7665 |
|
7666 | ((globalProperties = appContext.config.globalProperties),
|
7667 | hasOwn(globalProperties, key))) {
|
7668 | {
|
7669 | return globalProperties[key];
|
7670 | }
|
7671 | }
|
7672 | else if (currentRenderingInstance &&
|
7673 | (!isString(key) ||
|
7674 |
|
7675 |
|
7676 | key.indexOf('__v') !== 0)) {
|
7677 | if (data !== EMPTY_OBJ &&
|
7678 | (key[0] === '$' || key[0] === '_') &&
|
7679 | hasOwn(data, key)) {
|
7680 | warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
|
7681 | `character ("$" or "_") and is not proxied on the render context.`);
|
7682 | }
|
7683 | else if (instance === currentRenderingInstance) {
|
7684 | warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
|
7685 | `but is not defined on instance.`);
|
7686 | }
|
7687 | }
|
7688 | },
|
7689 | set({ _: instance }, key, value) {
|
7690 | const { data, setupState, ctx } = instance;
|
7691 | if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
|
7692 | setupState[key] = value;
|
7693 | }
|
7694 | else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
7695 | data[key] = value;
|
7696 | }
|
7697 | else if (hasOwn(instance.props, key)) {
|
7698 | warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
|
7699 | return false;
|
7700 | }
|
7701 | if (key[0] === '$' && key.slice(1) in instance) {
|
7702 | warn$1(`Attempting to mutate public property "${key}". ` +
|
7703 | `Properties starting with $ are reserved and readonly.`, instance);
|
7704 | return false;
|
7705 | }
|
7706 | else {
|
7707 | if (key in instance.appContext.config.globalProperties) {
|
7708 | Object.defineProperty(ctx, key, {
|
7709 | enumerable: true,
|
7710 | configurable: true,
|
7711 | value
|
7712 | });
|
7713 | }
|
7714 | else {
|
7715 | ctx[key] = value;
|
7716 | }
|
7717 | }
|
7718 | return true;
|
7719 | },
|
7720 | has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
|
7721 | let normalizedProps;
|
7722 | return (accessCache[key] !== undefined ||
|
7723 | (data !== EMPTY_OBJ && hasOwn(data, key)) ||
|
7724 | (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
|
7725 | ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
|
7726 | hasOwn(ctx, key) ||
|
7727 | hasOwn(publicPropertiesMap, key) ||
|
7728 | hasOwn(appContext.config.globalProperties, key));
|
7729 | }
|
7730 | };
|
7731 | {
|
7732 | PublicInstanceProxyHandlers.ownKeys = (target) => {
|
7733 | warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
|
7734 | `The keys will be empty in production mode to avoid performance overhead.`);
|
7735 | return Reflect.ownKeys(target);
|
7736 | };
|
7737 | }
|
7738 | const RuntimeCompiledPublicInstanceProxyHandlers = extend({}, PublicInstanceProxyHandlers, {
|
7739 | get(target, key) {
|
7740 |
|
7741 | if (key === Symbol.unscopables) {
|
7742 | return;
|
7743 | }
|
7744 | return PublicInstanceProxyHandlers.get(target, key, target);
|
7745 | },
|
7746 | has(_, key) {
|
7747 | const has = key[0] !== '_' && !isGloballyWhitelisted(key);
|
7748 | if (!has && PublicInstanceProxyHandlers.has(_, key)) {
|
7749 | warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
|
7750 | }
|
7751 | return has;
|
7752 | }
|
7753 | });
|
7754 |
|
7755 |
|
7756 |
|
7757 |
|
7758 | function createDevRenderContext(instance) {
|
7759 | const target = {};
|
7760 |
|
7761 | Object.defineProperty(target, `_`, {
|
7762 | configurable: true,
|
7763 | enumerable: false,
|
7764 | get: () => instance
|
7765 | });
|
7766 | // expose public properties
|
7767 | Object.keys(publicPropertiesMap).forEach(key => {
|
7768 | Object.defineProperty(target, key, {
|
7769 | configurable: true,
|
7770 | enumerable: false,
|
7771 | get: () => publicPropertiesMap[key](instance),
|
7772 | // intercepted by the proxy so no need for implementation,
|
7773 | // but needed to prevent set errors
|
7774 | set: NOOP
|
7775 | });
|
7776 | });
|
7777 | return target;
|
7778 | }
|
7779 | // dev only
|
7780 | function exposePropsOnRenderContext(instance) {
|
7781 | const { ctx, propsOptions: [propsOptions] } = instance;
|
7782 | if (propsOptions) {
|
7783 | Object.keys(propsOptions).forEach(key => {
|
7784 | Object.defineProperty(ctx, key, {
|
7785 | enumerable: true,
|
7786 | configurable: true,
|
7787 | get: () => instance.props[key],
|
7788 | set: NOOP
|
7789 | });
|
7790 | });
|
7791 | }
|
7792 | }
|
7793 | // dev only
|
7794 | function exposeSetupStateOnRenderContext(instance) {
|
7795 | const { ctx, setupState } = instance;
|
7796 | Object.keys(toRaw(setupState)).forEach(key => {
|
7797 | if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
|
7798 | warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
|
7799 | `which are reserved prefixes for Vue internals.`);
|
7800 | return;
|
7801 | }
|
7802 | Object.defineProperty(ctx, key, {
|
7803 | enumerable: true,
|
7804 | configurable: true,
|
7805 | get: () => setupState[key],
|
7806 | set: NOOP
|
7807 | });
|
7808 | });
|
7809 | }
|
7810 |
|
7811 | const emptyAppContext = createAppContext();
|
7812 | let uid$1 = 0;
|
7813 | function createComponentInstance(vnode, parent, suspense) {
|
7814 | const type = vnode.type;
|
7815 |
|
7816 | const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
7817 | const instance = {
|
7818 | uid: uid$1++,
|
7819 | vnode,
|
7820 | type,
|
7821 | parent,
|
7822 | appContext,
|
7823 | root: null,
|
7824 | next: null,
|
7825 | subTree: null,
|
7826 | update: null,
|
7827 | scope: new EffectScope(true ),
|
7828 | render: null,
|
7829 | proxy: null,
|
7830 | exposed: null,
|
7831 | exposeProxy: null,
|
7832 | withProxy: null,
|
7833 | provides: parent ? parent.provides : Object.create(appContext.provides),
|
7834 | accessCache: null,
|
7835 | renderCache: [],
|
7836 |
|
7837 | components: null,
|
7838 | directives: null,
|
7839 |
|
7840 | propsOptions: normalizePropsOptions(type, appContext),
|
7841 | emitsOptions: normalizeEmitsOptions(type, appContext),
|
7842 |
|
7843 | emit: null,
|
7844 | emitted: null,
|
7845 |
|
7846 | propsDefaults: EMPTY_OBJ,
|
7847 |
|
7848 | inheritAttrs: type.inheritAttrs,
|
7849 |
|
7850 | ctx: EMPTY_OBJ,
|
7851 | data: EMPTY_OBJ,
|
7852 | props: EMPTY_OBJ,
|
7853 | attrs: EMPTY_OBJ,
|
7854 | slots: EMPTY_OBJ,
|
7855 | refs: EMPTY_OBJ,
|
7856 | setupState: EMPTY_OBJ,
|
7857 | setupContext: null,
|
7858 |
|
7859 | suspense,
|
7860 | suspenseId: suspense ? suspense.pendingId : 0,
|
7861 | asyncDep: null,
|
7862 | asyncResolved: false,
|
7863 |
|
7864 |
|
7865 | isMounted: false,
|
7866 | isUnmounted: false,
|
7867 | isDeactivated: false,
|
7868 | bc: null,
|
7869 | c: null,
|
7870 | bm: null,
|
7871 | m: null,
|
7872 | bu: null,
|
7873 | u: null,
|
7874 | um: null,
|
7875 | bum: null,
|
7876 | da: null,
|
7877 | a: null,
|
7878 | rtg: null,
|
7879 | rtc: null,
|
7880 | ec: null,
|
7881 | sp: null
|
7882 | };
|
7883 | {
|
7884 | instance.ctx = createDevRenderContext(instance);
|
7885 | }
|
7886 | instance.root = parent ? parent.root : instance;
|
7887 | instance.emit = emit.bind(null, instance);
|
7888 |
|
7889 | if (vnode.ce) {
|
7890 | vnode.ce(instance);
|
7891 | }
|
7892 | return instance;
|
7893 | }
|
7894 | let currentInstance = null;
|
7895 | const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
7896 | const setCurrentInstance = (instance) => {
|
7897 | currentInstance = instance;
|
7898 | instance.scope.on();
|
7899 | };
|
7900 | const unsetCurrentInstance = () => {
|
7901 | currentInstance && currentInstance.scope.off();
|
7902 | currentInstance = null;
|
7903 | };
|
7904 | const isBuiltInTag = makeMap('slot,component');
|
7905 | function validateComponentName(name, config) {
|
7906 | const appIsNativeTag = config.isNativeTag || NO;
|
7907 | if (isBuiltInTag(name) || appIsNativeTag(name)) {
|
7908 | warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
|
7909 | }
|
7910 | }
|
7911 | function isStatefulComponent(instance) {
|
7912 | return instance.vnode.shapeFlag & 4 ;
|
7913 | }
|
7914 | let isInSSRComponentSetup = false;
|
7915 | function setupComponent(instance, isSSR = false) {
|
7916 | isInSSRComponentSetup = isSSR;
|
7917 | const { props, children } = instance.vnode;
|
7918 | const isStateful = isStatefulComponent(instance);
|
7919 | initProps(instance, props, isStateful, isSSR);
|
7920 | initSlots(instance, children);
|
7921 | const setupResult = isStateful
|
7922 | ? setupStatefulComponent(instance, isSSR)
|
7923 | : undefined;
|
7924 | isInSSRComponentSetup = false;
|
7925 | return setupResult;
|
7926 | }
|
7927 | function setupStatefulComponent(instance, isSSR) {
|
7928 | const Component = instance.type;
|
7929 | {
|
7930 | if (Component.name) {
|
7931 | validateComponentName(Component.name, instance.appContext.config);
|
7932 | }
|
7933 | if (Component.components) {
|
7934 | const names = Object.keys(Component.components);
|
7935 | for (let i = 0; i < names.length; i++) {
|
7936 | validateComponentName(names[i], instance.appContext.config);
|
7937 | }
|
7938 | }
|
7939 | if (Component.directives) {
|
7940 | const names = Object.keys(Component.directives);
|
7941 | for (let i = 0; i < names.length; i++) {
|
7942 | validateDirectiveName(names[i]);
|
7943 | }
|
7944 | }
|
7945 | if (Component.compilerOptions && isRuntimeOnly()) {
|
7946 | warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
|
7947 | `includes the runtime compiler. Since you are using a runtime-only ` +
|
7948 | `build, the options should be passed via your build tool config instead.`);
|
7949 | }
|
7950 | }
|
7951 |
|
7952 | instance.accessCache = Object.create(null);
|
7953 |
|
7954 |
|
7955 | instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
|
7956 | {
|
7957 | exposePropsOnRenderContext(instance);
|
7958 | }
|
7959 |
|
7960 | const { setup } = Component;
|
7961 | if (setup) {
|
7962 | const setupContext = (instance.setupContext =
|
7963 | setup.length > 1 ? createSetupContext(instance) : null);
|
7964 | setCurrentInstance(instance);
|
7965 | pauseTracking();
|
7966 | const setupResult = callWithErrorHandling(setup, instance, 0 , [shallowReadonly(instance.props) , setupContext]);
|
7967 | resetTracking();
|
7968 | unsetCurrentInstance();
|
7969 | if (isPromise(setupResult)) {
|
7970 | setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
|
7971 | if (isSSR) {
|
7972 |
|
7973 | return setupResult
|
7974 | .then((resolvedResult) => {
|
7975 | handleSetupResult(instance, resolvedResult, isSSR);
|
7976 | })
|
7977 | .catch(e => {
|
7978 | handleError(e, instance, 0 );
|
7979 | });
|
7980 | }
|
7981 | else {
|
7982 |
|
7983 |
|
7984 | instance.asyncDep = setupResult;
|
7985 | }
|
7986 | }
|
7987 | else {
|
7988 | handleSetupResult(instance, setupResult, isSSR);
|
7989 | }
|
7990 | }
|
7991 | else {
|
7992 | finishComponentSetup(instance, isSSR);
|
7993 | }
|
7994 | }
|
7995 | function handleSetupResult(instance, setupResult, isSSR) {
|
7996 | if (isFunction(setupResult)) {
|
7997 |
|
7998 | {
|
7999 | instance.render = setupResult;
|
8000 | }
|
8001 | }
|
8002 | else if (isObject(setupResult)) {
|
8003 | if (isVNode(setupResult)) {
|
8004 | warn$1(`setup() should not return VNodes directly - ` +
|
8005 | `return a render function instead.`);
|
8006 | }
|
8007 |
|
8008 |
|
8009 | {
|
8010 | instance.devtoolsRawSetupState = setupResult;
|
8011 | }
|
8012 | instance.setupState = proxyRefs(setupResult);
|
8013 | {
|
8014 | exposeSetupStateOnRenderContext(instance);
|
8015 | }
|
8016 | }
|
8017 | else if (setupResult !== undefined) {
|
8018 | warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
|
8019 | }
|
8020 | finishComponentSetup(instance, isSSR);
|
8021 | }
|
8022 | let compile;
|
8023 | let installWithProxy;
|
8024 | |
8025 |
|
8026 |
|
8027 |
|
8028 | function registerRuntimeCompiler(_compile) {
|
8029 | compile = _compile;
|
8030 | installWithProxy = i => {
|
8031 | if (i.render._rc) {
|
8032 | i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
|
8033 | }
|
8034 | };
|
8035 | }
|
8036 |
|
8037 | const isRuntimeOnly = () => !compile;
|
8038 | function finishComponentSetup(instance, isSSR, skipOptions) {
|
8039 | const Component = instance.type;
|
8040 |
|
8041 | if (!instance.render) {
|
8042 |
|
8043 | if (compile && !Component.render) {
|
8044 | const template = Component.template;
|
8045 | if (template) {
|
8046 | {
|
8047 | startMeasure(instance, `compile`);
|
8048 | }
|
8049 | const { isCustomElement, compilerOptions } = instance.appContext.config;
|
8050 | const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
8051 | const finalCompilerOptions = extend(extend({
|
8052 | isCustomElement,
|
8053 | delimiters
|
8054 | }, compilerOptions), componentCompilerOptions);
|
8055 | Component.render = compile(template, finalCompilerOptions);
|
8056 | {
|
8057 | endMeasure(instance, `compile`);
|
8058 | }
|
8059 | }
|
8060 | }
|
8061 | instance.render = (Component.render || NOOP);
|
8062 |
|
8063 |
|
8064 |
|
8065 | if (installWithProxy) {
|
8066 | installWithProxy(instance);
|
8067 | }
|
8068 | }
|
8069 |
|
8070 | {
|
8071 | setCurrentInstance(instance);
|
8072 | pauseTracking();
|
8073 | applyOptions(instance);
|
8074 | resetTracking();
|
8075 | unsetCurrentInstance();
|
8076 | }
|
8077 |
|
8078 |
|
8079 | if (!Component.render && instance.render === NOOP && !isSSR) {
|
8080 |
|
8081 | if (!compile && Component.template) {
|
8082 | warn$1(`Component provided template option but ` +
|
8083 | `runtime compilation is not supported in this build of Vue.` +
|
8084 | (` Use "vue.global.js" instead.`
|
8085 | ) );
|
8086 | }
|
8087 | else {
|
8088 | warn$1(`Component is missing template or render function.`);
|
8089 | }
|
8090 | }
|
8091 | }
|
8092 | function createAttrsProxy(instance) {
|
8093 | return new Proxy(instance.attrs, {
|
8094 | get(target, key) {
|
8095 | markAttrsAccessed();
|
8096 | track(instance, "get" , '$attrs');
|
8097 | return target[key];
|
8098 | },
|
8099 | set() {
|
8100 | warn$1(`setupContext.attrs is readonly.`);
|
8101 | return false;
|
8102 | },
|
8103 | deleteProperty() {
|
8104 | warn$1(`setupContext.attrs is readonly.`);
|
8105 | return false;
|
8106 | }
|
8107 | }
|
8108 | );
|
8109 | }
|
8110 | function createSetupContext(instance) {
|
8111 | const expose = exposed => {
|
8112 | if (instance.exposed) {
|
8113 | warn$1(`expose() should be called only once per setup().`);
|
8114 | }
|
8115 | instance.exposed = exposed || {};
|
8116 | };
|
8117 | let attrs;
|
8118 | {
|
8119 |
|
8120 |
|
8121 | return Object.freeze({
|
8122 | get attrs() {
|
8123 | return attrs || (attrs = createAttrsProxy(instance));
|
8124 | },
|
8125 | get slots() {
|
8126 | return shallowReadonly(instance.slots);
|
8127 | },
|
8128 | get emit() {
|
8129 | return (event, ...args) => instance.emit(event, ...args);
|
8130 | },
|
8131 | expose
|
8132 | });
|
8133 | }
|
8134 | }
|
8135 | function getExposeProxy(instance) {
|
8136 | if (instance.exposed) {
|
8137 | return (instance.exposeProxy ||
|
8138 | (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
8139 | get(target, key) {
|
8140 | if (key in target) {
|
8141 | return target[key];
|
8142 | }
|
8143 | else if (key in publicPropertiesMap) {
|
8144 | return publicPropertiesMap[key](instance);
|
8145 | }
|
8146 | }
|
8147 | })));
|
8148 | }
|
8149 | }
|
8150 | const classifyRE = /(?:^|[-_])(\w)/g;
|
8151 | const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
|
8152 | function getComponentName(Component) {
|
8153 | return isFunction(Component)
|
8154 | ? Component.displayName || Component.name
|
8155 | : Component.name;
|
8156 | }
|
8157 |
|
8158 | function formatComponentName(instance, Component, isRoot = false) {
|
8159 | let name = getComponentName(Component);
|
8160 | if (!name && Component.__file) {
|
8161 | const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
8162 | if (match) {
|
8163 | name = match[1];
|
8164 | }
|
8165 | }
|
8166 | if (!name && instance && instance.parent) {
|
8167 |
|
8168 | const inferFromRegistry = (registry) => {
|
8169 | for (const key in registry) {
|
8170 | if (registry[key] === Component) {
|
8171 | return key;
|
8172 | }
|
8173 | }
|
8174 | };
|
8175 | name =
|
8176 | inferFromRegistry(instance.components ||
|
8177 | instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
|
8178 | }
|
8179 | return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
8180 | }
|
8181 | function isClassComponent(value) {
|
8182 | return isFunction(value) && '__vccOpts' in value;
|
8183 | }
|
8184 |
|
8185 | const stack = [];
|
8186 | function pushWarningContext(vnode) {
|
8187 | stack.push(vnode);
|
8188 | }
|
8189 | function popWarningContext() {
|
8190 | stack.pop();
|
8191 | }
|
8192 | function warn$1(msg, ...args) {
|
8193 |
|
8194 |
|
8195 | pauseTracking();
|
8196 | const instance = stack.length ? stack[stack.length - 1].component : null;
|
8197 | const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
8198 | const trace = getComponentTrace();
|
8199 | if (appWarnHandler) {
|
8200 | callWithErrorHandling(appWarnHandler, instance, 11 , [
|
8201 | msg + args.join(''),
|
8202 | instance && instance.proxy,
|
8203 | trace
|
8204 | .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
|
8205 | .join('\n'),
|
8206 | trace
|
8207 | ]);
|
8208 | }
|
8209 | else {
|
8210 | const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
8211 |
|
8212 | if (trace.length &&
|
8213 |
|
8214 | !false) {
|
8215 | warnArgs.push(`\n`, ...formatTrace(trace));
|
8216 | }
|
8217 | console.warn(...warnArgs);
|
8218 | }
|
8219 | resetTracking();
|
8220 | }
|
8221 | function getComponentTrace() {
|
8222 | let currentVNode = stack[stack.length - 1];
|
8223 | if (!currentVNode) {
|
8224 | return [];
|
8225 | }
|
8226 |
|
8227 |
|
8228 |
|
8229 | const normalizedStack = [];
|
8230 | while (currentVNode) {
|
8231 | const last = normalizedStack[0];
|
8232 | if (last && last.vnode === currentVNode) {
|
8233 | last.recurseCount++;
|
8234 | }
|
8235 | else {
|
8236 | normalizedStack.push({
|
8237 | vnode: currentVNode,
|
8238 | recurseCount: 0
|
8239 | });
|
8240 | }
|
8241 | const parentInstance = currentVNode.component && currentVNode.component.parent;
|
8242 | currentVNode = parentInstance && parentInstance.vnode;
|
8243 | }
|
8244 | return normalizedStack;
|
8245 | }
|
8246 |
|
8247 | function formatTrace(trace) {
|
8248 | const logs = [];
|
8249 | trace.forEach((entry, i) => {
|
8250 | logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
|
8251 | });
|
8252 | return logs;
|
8253 | }
|
8254 | function formatTraceEntry({ vnode, recurseCount }) {
|
8255 | const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
8256 | const isRoot = vnode.component ? vnode.component.parent == null : false;
|
8257 | const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
|
8258 | const close = `>` + postfix;
|
8259 | return vnode.props
|
8260 | ? [open, ...formatProps(vnode.props), close]
|
8261 | : [open + close];
|
8262 | }
|
8263 |
|
8264 | function formatProps(props) {
|
8265 | const res = [];
|
8266 | const keys = Object.keys(props);
|
8267 | keys.slice(0, 3).forEach(key => {
|
8268 | res.push(...formatProp(key, props[key]));
|
8269 | });
|
8270 | if (keys.length > 3) {
|
8271 | res.push(` ...`);
|
8272 | }
|
8273 | return res;
|
8274 | }
|
8275 |
|
8276 | function formatProp(key, value, raw) {
|
8277 | if (isString(value)) {
|
8278 | value = JSON.stringify(value);
|
8279 | return raw ? value : [`${key}=${value}`];
|
8280 | }
|
8281 | else if (typeof value === 'number' ||
|
8282 | typeof value === 'boolean' ||
|
8283 | value == null) {
|
8284 | return raw ? value : [`${key}=${value}`];
|
8285 | }
|
8286 | else if (isRef(value)) {
|
8287 | value = formatProp(key, toRaw(value.value), true);
|
8288 | return raw ? value : [`${key}=Ref<`, value, `>`];
|
8289 | }
|
8290 | else if (isFunction(value)) {
|
8291 | return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
8292 | }
|
8293 | else {
|
8294 | value = toRaw(value);
|
8295 | return raw ? value : [`${key}=`, value];
|
8296 | }
|
8297 | }
|
8298 |
|
8299 | const ErrorTypeStrings = {
|
8300 | ["sp" ]: 'serverPrefetch hook',
|
8301 | ["bc" ]: 'beforeCreate hook',
|
8302 | ["c" ]: 'created hook',
|
8303 | ["bm" ]: 'beforeMount hook',
|
8304 | ["m" ]: 'mounted hook',
|
8305 | ["bu" ]: 'beforeUpdate hook',
|
8306 | ["u" ]: 'updated',
|
8307 | ["bum" ]: 'beforeUnmount hook',
|
8308 | ["um" ]: 'unmounted hook',
|
8309 | ["a" ]: 'activated hook',
|
8310 | ["da" ]: 'deactivated hook',
|
8311 | ["ec" ]: 'errorCaptured hook',
|
8312 | ["rtc" ]: 'renderTracked hook',
|
8313 | ["rtg" ]: 'renderTriggered hook',
|
8314 | [0 ]: 'setup function',
|
8315 | [1 ]: 'render function',
|
8316 | [2 ]: 'watcher getter',
|
8317 | [3 ]: 'watcher callback',
|
8318 | [4 ]: 'watcher cleanup function',
|
8319 | [5 ]: 'native event handler',
|
8320 | [6 ]: 'component event handler',
|
8321 | [7 ]: 'vnode hook',
|
8322 | [8 ]: 'directive hook',
|
8323 | [9 ]: 'transition hook',
|
8324 | [10 ]: 'app errorHandler',
|
8325 | [11 ]: 'app warnHandler',
|
8326 | [12 ]: 'ref function',
|
8327 | [13 ]: 'async component loader',
|
8328 | [14 ]: 'scheduler flush. This is likely a Vue internals bug. ' +
|
8329 | 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next'
|
8330 | };
|
8331 | function callWithErrorHandling(fn, instance, type, args) {
|
8332 | let res;
|
8333 | try {
|
8334 | res = args ? fn(...args) : fn();
|
8335 | }
|
8336 | catch (err) {
|
8337 | handleError(err, instance, type);
|
8338 | }
|
8339 | return res;
|
8340 | }
|
8341 | function callWithAsyncErrorHandling(fn, instance, type, args) {
|
8342 | if (isFunction(fn)) {
|
8343 | const res = callWithErrorHandling(fn, instance, type, args);
|
8344 | if (res && isPromise(res)) {
|
8345 | res.catch(err => {
|
8346 | handleError(err, instance, type);
|
8347 | });
|
8348 | }
|
8349 | return res;
|
8350 | }
|
8351 | const values = [];
|
8352 | for (let i = 0; i < fn.length; i++) {
|
8353 | values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
8354 | }
|
8355 | return values;
|
8356 | }
|
8357 | function handleError(err, instance, type, throwInDev = true) {
|
8358 | const contextVNode = instance ? instance.vnode : null;
|
8359 | if (instance) {
|
8360 | let cur = instance.parent;
|
8361 |
|
8362 | const exposedInstance = instance.proxy;
|
8363 |
|
8364 | const errorInfo = ErrorTypeStrings[type] ;
|
8365 | while (cur) {
|
8366 | const errorCapturedHooks = cur.ec;
|
8367 | if (errorCapturedHooks) {
|
8368 | for (let i = 0; i < errorCapturedHooks.length; i++) {
|
8369 | if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
8370 | return;
|
8371 | }
|
8372 | }
|
8373 | }
|
8374 | cur = cur.parent;
|
8375 | }
|
8376 |
|
8377 | const appErrorHandler = instance.appContext.config.errorHandler;
|
8378 | if (appErrorHandler) {
|
8379 | callWithErrorHandling(appErrorHandler, null, 10 , [err, exposedInstance, errorInfo]);
|
8380 | return;
|
8381 | }
|
8382 | }
|
8383 | logError(err, type, contextVNode, throwInDev);
|
8384 | }
|
8385 | function logError(err, type, contextVNode, throwInDev = true) {
|
8386 | {
|
8387 | const info = ErrorTypeStrings[type];
|
8388 | if (contextVNode) {
|
8389 | pushWarningContext(contextVNode);
|
8390 | }
|
8391 | warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
8392 | if (contextVNode) {
|
8393 | popWarningContext();
|
8394 | }
|
8395 |
|
8396 | if (throwInDev) {
|
8397 | throw err;
|
8398 | }
|
8399 | else {
|
8400 | console.error(err);
|
8401 | }
|
8402 | }
|
8403 | }
|
8404 |
|
8405 | let isFlushing = false;
|
8406 | let isFlushPending = false;
|
8407 | const queue = [];
|
8408 | let flushIndex = 0;
|
8409 | const pendingPreFlushCbs = [];
|
8410 | let activePreFlushCbs = null;
|
8411 | let preFlushIndex = 0;
|
8412 | const pendingPostFlushCbs = [];
|
8413 | let activePostFlushCbs = null;
|
8414 | let postFlushIndex = 0;
|
8415 | const resolvedPromise = Promise.resolve();
|
8416 | let currentFlushPromise = null;
|
8417 | let currentPreFlushParentJob = null;
|
8418 | const RECURSION_LIMIT = 100;
|
8419 | function nextTick(fn) {
|
8420 | const p = currentFlushPromise || resolvedPromise;
|
8421 | return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
8422 | }
|
8423 |
|
8424 |
|
8425 |
|
8426 |
|
8427 | function findInsertionIndex(id) {
|
8428 |
|
8429 | let start = flushIndex + 1;
|
8430 | let end = queue.length;
|
8431 | while (start < end) {
|
8432 | const middle = (start + end) >>> 1;
|
8433 | const middleJobId = getId(queue[middle]);
|
8434 | middleJobId < id ? (start = middle + 1) : (end = middle);
|
8435 | }
|
8436 | return start;
|
8437 | }
|
8438 | function queueJob(job) {
|
8439 |
|
8440 |
|
8441 |
|
8442 |
|
8443 |
|
8444 |
|
8445 | if ((!queue.length ||
|
8446 | !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
|
8447 | job !== currentPreFlushParentJob) {
|
8448 | if (job.id == null) {
|
8449 | queue.push(job);
|
8450 | }
|
8451 | else {
|
8452 | queue.splice(findInsertionIndex(job.id), 0, job);
|
8453 | }
|
8454 | queueFlush();
|
8455 | }
|
8456 | }
|
8457 | function queueFlush() {
|
8458 | if (!isFlushing && !isFlushPending) {
|
8459 | isFlushPending = true;
|
8460 | currentFlushPromise = resolvedPromise.then(flushJobs);
|
8461 | }
|
8462 | }
|
8463 | function invalidateJob(job) {
|
8464 | const i = queue.indexOf(job);
|
8465 | if (i > flushIndex) {
|
8466 | queue.splice(i, 1);
|
8467 | }
|
8468 | }
|
8469 | function queueCb(cb, activeQueue, pendingQueue, index) {
|
8470 | if (!isArray(cb)) {
|
8471 | if (!activeQueue ||
|
8472 | !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
|
8473 | pendingQueue.push(cb);
|
8474 | }
|
8475 | }
|
8476 | else {
|
8477 |
|
8478 |
|
8479 |
|
8480 | pendingQueue.push(...cb);
|
8481 | }
|
8482 | queueFlush();
|
8483 | }
|
8484 | function queuePreFlushCb(cb) {
|
8485 | queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
|
8486 | }
|
8487 | function queuePostFlushCb(cb) {
|
8488 | queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
|
8489 | }
|
8490 | function flushPreFlushCbs(seen, parentJob = null) {
|
8491 | if (pendingPreFlushCbs.length) {
|
8492 | currentPreFlushParentJob = parentJob;
|
8493 | activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
|
8494 | pendingPreFlushCbs.length = 0;
|
8495 | {
|
8496 | seen = seen || new Map();
|
8497 | }
|
8498 | for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
|
8499 | if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
|
8500 | continue;
|
8501 | }
|
8502 | activePreFlushCbs[preFlushIndex]();
|
8503 | }
|
8504 | activePreFlushCbs = null;
|
8505 | preFlushIndex = 0;
|
8506 | currentPreFlushParentJob = null;
|
8507 |
|
8508 | flushPreFlushCbs(seen, parentJob);
|
8509 | }
|
8510 | }
|
8511 | function flushPostFlushCbs(seen) {
|
8512 | if (pendingPostFlushCbs.length) {
|
8513 | const deduped = [...new Set(pendingPostFlushCbs)];
|
8514 | pendingPostFlushCbs.length = 0;
|
8515 |
|
8516 | if (activePostFlushCbs) {
|
8517 | activePostFlushCbs.push(...deduped);
|
8518 | return;
|
8519 | }
|
8520 | activePostFlushCbs = deduped;
|
8521 | {
|
8522 | seen = seen || new Map();
|
8523 | }
|
8524 | activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
|
8525 | for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
8526 | if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
|
8527 | continue;
|
8528 | }
|
8529 | activePostFlushCbs[postFlushIndex]();
|
8530 | }
|
8531 | activePostFlushCbs = null;
|
8532 | postFlushIndex = 0;
|
8533 | }
|
8534 | }
|
8535 | const getId = (job) => job.id == null ? Infinity : job.id;
|
8536 | function flushJobs(seen) {
|
8537 | isFlushPending = false;
|
8538 | isFlushing = true;
|
8539 | {
|
8540 | seen = seen || new Map();
|
8541 | }
|
8542 | flushPreFlushCbs(seen);
|
8543 |
|
8544 |
|
8545 |
|
8546 |
|
8547 |
|
8548 |
|
8549 |
|
8550 | queue.sort((a, b) => getId(a) - getId(b));
|
8551 | try {
|
8552 | for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
8553 | const job = queue[flushIndex];
|
8554 | if (job && job.active !== false) {
|
8555 | if (true && checkRecursiveUpdates(seen, job)) {
|
8556 | continue;
|
8557 | }
|
8558 |
|
8559 | callWithErrorHandling(job, null, 14 );
|
8560 | }
|
8561 | }
|
8562 | }
|
8563 | finally {
|
8564 | flushIndex = 0;
|
8565 | queue.length = 0;
|
8566 | flushPostFlushCbs(seen);
|
8567 | isFlushing = false;
|
8568 | currentFlushPromise = null;
|
8569 |
|
8570 |
|
8571 | if (queue.length ||
|
8572 | pendingPreFlushCbs.length ||
|
8573 | pendingPostFlushCbs.length) {
|
8574 | flushJobs(seen);
|
8575 | }
|
8576 | }
|
8577 | }
|
8578 | function checkRecursiveUpdates(seen, fn) {
|
8579 | if (!seen.has(fn)) {
|
8580 | seen.set(fn, 1);
|
8581 | }
|
8582 | else {
|
8583 | const count = seen.get(fn);
|
8584 | if (count > RECURSION_LIMIT) {
|
8585 | const instance = fn.ownerInstance;
|
8586 | const componentName = instance && getComponentName(instance.type);
|
8587 | warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
|
8588 | `This means you have a reactive effect that is mutating its own ` +
|
8589 | `dependencies and thus recursively triggering itself. Possible sources ` +
|
8590 | `include component template, render function, updated hook or ` +
|
8591 | `watcher source function.`);
|
8592 | return true;
|
8593 | }
|
8594 | else {
|
8595 | seen.set(fn, count + 1);
|
8596 | }
|
8597 | }
|
8598 | }
|
8599 |
|
8600 |
|
8601 | function watchEffect(effect, options) {
|
8602 | return doWatch(effect, null, options);
|
8603 | }
|
8604 | function watchPostEffect(effect, options) {
|
8605 | return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
|
8606 | ));
|
8607 | }
|
8608 | function watchSyncEffect(effect, options) {
|
8609 | return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
|
8610 | ));
|
8611 | }
|
8612 |
|
8613 | const INITIAL_WATCHER_VALUE = {};
|
8614 |
|
8615 | function watch(source, cb, options) {
|
8616 | if (!isFunction(cb)) {
|
8617 | warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
|
8618 | `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
|
8619 | `supports \`watch(source, cb, options?) signature.`);
|
8620 | }
|
8621 | return doWatch(source, cb, options);
|
8622 | }
|
8623 | function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
|
8624 | if (!cb) {
|
8625 | if (immediate !== undefined) {
|
8626 | warn$1(`watch() "immediate" option is only respected when using the ` +
|
8627 | `watch(source, callback, options?) signature.`);
|
8628 | }
|
8629 | if (deep !== undefined) {
|
8630 | warn$1(`watch() "deep" option is only respected when using the ` +
|
8631 | `watch(source, callback, options?) signature.`);
|
8632 | }
|
8633 | }
|
8634 | const warnInvalidSource = (s) => {
|
8635 | warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
|
8636 | `a reactive object, or an array of these types.`);
|
8637 | };
|
8638 | const instance = currentInstance;
|
8639 | let getter;
|
8640 | let forceTrigger = false;
|
8641 | let isMultiSource = false;
|
8642 | if (isRef(source)) {
|
8643 | getter = () => source.value;
|
8644 | forceTrigger = !!source._shallow;
|
8645 | }
|
8646 | else if (isReactive(source)) {
|
8647 | getter = () => source;
|
8648 | deep = true;
|
8649 | }
|
8650 | else if (isArray(source)) {
|
8651 | isMultiSource = true;
|
8652 | forceTrigger = source.some(isReactive);
|
8653 | getter = () => source.map(s => {
|
8654 | if (isRef(s)) {
|
8655 | return s.value;
|
8656 | }
|
8657 | else if (isReactive(s)) {
|
8658 | return traverse(s);
|
8659 | }
|
8660 | else if (isFunction(s)) {
|
8661 | return callWithErrorHandling(s, instance, 2 );
|
8662 | }
|
8663 | else {
|
8664 | warnInvalidSource(s);
|
8665 | }
|
8666 | });
|
8667 | }
|
8668 | else if (isFunction(source)) {
|
8669 | if (cb) {
|
8670 |
|
8671 | getter = () => callWithErrorHandling(source, instance, 2 );
|
8672 | }
|
8673 | else {
|
8674 |
|
8675 | getter = () => {
|
8676 | if (instance && instance.isUnmounted) {
|
8677 | return;
|
8678 | }
|
8679 | if (cleanup) {
|
8680 | cleanup();
|
8681 | }
|
8682 | return callWithAsyncErrorHandling(source, instance, 3 , [onInvalidate]);
|
8683 | };
|
8684 | }
|
8685 | }
|
8686 | else {
|
8687 | getter = NOOP;
|
8688 | warnInvalidSource(source);
|
8689 | }
|
8690 | if (cb && deep) {
|
8691 | const baseGetter = getter;
|
8692 | getter = () => traverse(baseGetter());
|
8693 | }
|
8694 | let cleanup;
|
8695 | let onInvalidate = (fn) => {
|
8696 | cleanup = effect.onStop = () => {
|
8697 | callWithErrorHandling(fn, instance, 4 );
|
8698 | };
|
8699 | };
|
8700 | let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
|
8701 | const job = () => {
|
8702 | if (!effect.active) {
|
8703 | return;
|
8704 | }
|
8705 | if (cb) {
|
8706 |
|
8707 | const newValue = effect.run();
|
8708 | if (deep ||
|
8709 | forceTrigger ||
|
8710 | (isMultiSource
|
8711 | ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
|
8712 | : hasChanged(newValue, oldValue)) ||
|
8713 | (false )) {
|
8714 |
|
8715 | if (cleanup) {
|
8716 | cleanup();
|
8717 | }
|
8718 | callWithAsyncErrorHandling(cb, instance, 3 , [
|
8719 | newValue,
|
8720 |
|
8721 | oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
|
8722 | onInvalidate
|
8723 | ]);
|
8724 | oldValue = newValue;
|
8725 | }
|
8726 | }
|
8727 | else {
|
8728 |
|
8729 | effect.run();
|
8730 | }
|
8731 | };
|
8732 |
|
8733 |
|
8734 | job.allowRecurse = !!cb;
|
8735 | let scheduler;
|
8736 | if (flush === 'sync') {
|
8737 | scheduler = job;
|
8738 | }
|
8739 | else if (flush === 'post') {
|
8740 | scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
8741 | }
|
8742 | else {
|
8743 |
|
8744 | scheduler = () => {
|
8745 | if (!instance || instance.isMounted) {
|
8746 | queuePreFlushCb(job);
|
8747 | }
|
8748 | else {
|
8749 |
|
8750 |
|
8751 | job();
|
8752 | }
|
8753 | };
|
8754 | }
|
8755 | const effect = new ReactiveEffect(getter, scheduler);
|
8756 | {
|
8757 | effect.onTrack = onTrack;
|
8758 | effect.onTrigger = onTrigger;
|
8759 | }
|
8760 |
|
8761 | if (cb) {
|
8762 | if (immediate) {
|
8763 | job();
|
8764 | }
|
8765 | else {
|
8766 | oldValue = effect.run();
|
8767 | }
|
8768 | }
|
8769 | else if (flush === 'post') {
|
8770 | queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
|
8771 | }
|
8772 | else {
|
8773 | effect.run();
|
8774 | }
|
8775 | return () => {
|
8776 | effect.stop();
|
8777 | if (instance && instance.scope) {
|
8778 | remove(instance.scope.effects, effect);
|
8779 | }
|
8780 | };
|
8781 | }
|
8782 |
|
8783 | function instanceWatch(source, value, options) {
|
8784 | const publicThis = this.proxy;
|
8785 | const getter = isString(source)
|
8786 | ? source.includes('.')
|
8787 | ? createPathGetter(publicThis, source)
|
8788 | : () => publicThis[source]
|
8789 | : source.bind(publicThis, publicThis);
|
8790 | let cb;
|
8791 | if (isFunction(value)) {
|
8792 | cb = value;
|
8793 | }
|
8794 | else {
|
8795 | cb = value.handler;
|
8796 | options = value;
|
8797 | }
|
8798 | const cur = currentInstance;
|
8799 | setCurrentInstance(this);
|
8800 | const res = doWatch(getter, cb.bind(publicThis), options);
|
8801 | if (cur) {
|
8802 | setCurrentInstance(cur);
|
8803 | }
|
8804 | else {
|
8805 | unsetCurrentInstance();
|
8806 | }
|
8807 | return res;
|
8808 | }
|
8809 | function createPathGetter(ctx, path) {
|
8810 | const segments = path.split('.');
|
8811 | return () => {
|
8812 | let cur = ctx;
|
8813 | for (let i = 0; i < segments.length && cur; i++) {
|
8814 | cur = cur[segments[i]];
|
8815 | }
|
8816 | return cur;
|
8817 | };
|
8818 | }
|
8819 | function traverse(value, seen = new Set()) {
|
8820 | if (!isObject(value) || value["__v_skip" ]) {
|
8821 | return value;
|
8822 | }
|
8823 | seen = seen || new Set();
|
8824 | if (seen.has(value)) {
|
8825 | return value;
|
8826 | }
|
8827 | seen.add(value);
|
8828 | if (isRef(value)) {
|
8829 | traverse(value.value, seen);
|
8830 | }
|
8831 | else if (isArray(value)) {
|
8832 | for (let i = 0; i < value.length; i++) {
|
8833 | traverse(value[i], seen);
|
8834 | }
|
8835 | }
|
8836 | else if (isSet(value) || isMap(value)) {
|
8837 | value.forEach((v) => {
|
8838 | traverse(v, seen);
|
8839 | });
|
8840 | }
|
8841 | else if (isPlainObject(value)) {
|
8842 | for (const key in value) {
|
8843 | traverse(value[key], seen);
|
8844 | }
|
8845 | }
|
8846 | return value;
|
8847 | }
|
8848 |
|
8849 |
|
8850 | const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
|
8851 | `<script setup> of a single file component. Its arguments should be ` +
|
8852 | `compiled away and passing it at runtime has no effect.`);
|
8853 |
|
8854 | function defineProps() {
|
8855 | {
|
8856 | warnRuntimeUsage(`defineProps`);
|
8857 | }
|
8858 | return null;
|
8859 | }
|
8860 |
|
8861 | function defineEmits() {
|
8862 | {
|
8863 | warnRuntimeUsage(`defineEmits`);
|
8864 | }
|
8865 | return null;
|
8866 | }
|
8867 | |
8868 |
|
8869 |
|
8870 |
|
8871 |
|
8872 |
|
8873 |
|
8874 |
|
8875 |
|
8876 |
|
8877 |
|
8878 |
|
8879 | function defineExpose(exposed) {
|
8880 | {
|
8881 | warnRuntimeUsage(`defineExpose`);
|
8882 | }
|
8883 | }
|
8884 | |
8885 |
|
8886 |
|
8887 |
|
8888 |
|
8889 |
|
8890 |
|
8891 |
|
8892 |
|
8893 |
|
8894 |
|
8895 |
|
8896 |
|
8897 |
|
8898 |
|
8899 |
|
8900 |
|
8901 |
|
8902 | function withDefaults(props, defaults) {
|
8903 | {
|
8904 | warnRuntimeUsage(`withDefaults`);
|
8905 | }
|
8906 | return null;
|
8907 | }
|
8908 | function useSlots() {
|
8909 | return getContext().slots;
|
8910 | }
|
8911 | function useAttrs() {
|
8912 | return getContext().attrs;
|
8913 | }
|
8914 | function getContext() {
|
8915 | const i = getCurrentInstance();
|
8916 | if (!i) {
|
8917 | warn$1(`useContext() called without active instance.`);
|
8918 | }
|
8919 | return i.setupContext || (i.setupContext = createSetupContext(i));
|
8920 | }
|
8921 | |
8922 |
|
8923 |
|
8924 |
|
8925 |
|
8926 | function mergeDefaults(
|
8927 | // the base props is compiler-generated and guaranteed to be in this shape.
|
8928 | props, defaults) {
|
8929 | for (const key in defaults) {
|
8930 | const val = props[key];
|
8931 | if (val) {
|
8932 | val.default = defaults[key];
|
8933 | }
|
8934 | else if (val === null) {
|
8935 | props[key] = { default: defaults[key] };
|
8936 | }
|
8937 | else {
|
8938 | warn$1(`props default key "${key}" has no corresponding declaration.`);
|
8939 | }
|
8940 | }
|
8941 | return props;
|
8942 | }
|
8943 | |
8944 |
|
8945 |
|
8946 |
|
8947 |
|
8948 |
|
8949 |
|
8950 |
|
8951 |
|
8952 |
|
8953 |
|
8954 |
|
8955 |
|
8956 |
|
8957 |
|
8958 |
|
8959 |
|
8960 |
|
8961 | function withAsyncContext(getAwaitable) {
|
8962 | const ctx = getCurrentInstance();
|
8963 | if (!ctx) {
|
8964 | warn$1(`withAsyncContext called without active current instance. ` +
|
8965 | `This is likely a bug.`);
|
8966 | }
|
8967 | let awaitable = getAwaitable();
|
8968 | unsetCurrentInstance();
|
8969 | if (isPromise(awaitable)) {
|
8970 | awaitable = awaitable.catch(e => {
|
8971 | setCurrentInstance(ctx);
|
8972 | throw e;
|
8973 | });
|
8974 | }
|
8975 | return [awaitable, () => setCurrentInstance(ctx)];
|
8976 | }
|
8977 |
|
8978 |
|
8979 | function h(type, propsOrChildren, children) {
|
8980 | const l = arguments.length;
|
8981 | if (l === 2) {
|
8982 | if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
|
8983 |
|
8984 | if (isVNode(propsOrChildren)) {
|
8985 | return createVNode(type, null, [propsOrChildren]);
|
8986 | }
|
8987 |
|
8988 | return createVNode(type, propsOrChildren);
|
8989 | }
|
8990 | else {
|
8991 |
|
8992 | return createVNode(type, null, propsOrChildren);
|
8993 | }
|
8994 | }
|
8995 | else {
|
8996 | if (l > 3) {
|
8997 | children = Array.prototype.slice.call(arguments, 2);
|
8998 | }
|
8999 | else if (l === 3 && isVNode(children)) {
|
9000 | children = [children];
|
9001 | }
|
9002 | return createVNode(type, propsOrChildren, children);
|
9003 | }
|
9004 | }
|
9005 |
|
9006 | const ssrContextKey = Symbol(`ssrContext` );
|
9007 | const useSSRContext = () => {
|
9008 | {
|
9009 | warn$1(`useSSRContext() is not supported in the global build.`);
|
9010 | }
|
9011 | };
|
9012 |
|
9013 | function initCustomFormatter() {
|
9014 |
|
9015 | if (typeof window === 'undefined') {
|
9016 | return;
|
9017 | }
|
9018 | const vueStyle = { style: 'color:#3ba776' };
|
9019 | const numberStyle = { style: 'color:#0b1bc9' };
|
9020 | const stringStyle = { style: 'color:#b62e24' };
|
9021 | const keywordStyle = { style: 'color:#9d288c' };
|
9022 |
|
9023 |
|
9024 | const formatter = {
|
9025 | header(obj) {
|
9026 |
|
9027 | if (!isObject(obj)) {
|
9028 | return null;
|
9029 | }
|
9030 | if (obj.__isVue) {
|
9031 | return ['div', vueStyle, `VueInstance`];
|
9032 | }
|
9033 | else if (isRef(obj)) {
|
9034 | return [
|
9035 | 'div',
|
9036 | {},
|
9037 | ['span', vueStyle, genRefFlag(obj)],
|
9038 | '<',
|
9039 | formatValue(obj.value),
|
9040 | `>`
|
9041 | ];
|
9042 | }
|
9043 | else if (isReactive(obj)) {
|
9044 | return [
|
9045 | 'div',
|
9046 | {},
|
9047 | ['span', vueStyle, 'Reactive'],
|
9048 | '<',
|
9049 | formatValue(obj),
|
9050 | `>${isReadonly(obj) ? ` (readonly)` : ``}`
|
9051 | ];
|
9052 | }
|
9053 | else if (isReadonly(obj)) {
|
9054 | return [
|
9055 | 'div',
|
9056 | {},
|
9057 | ['span', vueStyle, 'Readonly'],
|
9058 | '<',
|
9059 | formatValue(obj),
|
9060 | '>'
|
9061 | ];
|
9062 | }
|
9063 | return null;
|
9064 | },
|
9065 | hasBody(obj) {
|
9066 | return obj && obj.__isVue;
|
9067 | },
|
9068 | body(obj) {
|
9069 | if (obj && obj.__isVue) {
|
9070 | return [
|
9071 | 'div',
|
9072 | {},
|
9073 | ...formatInstance(obj.$)
|
9074 | ];
|
9075 | }
|
9076 | }
|
9077 | };
|
9078 | function formatInstance(instance) {
|
9079 | const blocks = [];
|
9080 | if (instance.type.props && instance.props) {
|
9081 | blocks.push(createInstanceBlock('props', toRaw(instance.props)));
|
9082 | }
|
9083 | if (instance.setupState !== EMPTY_OBJ) {
|
9084 | blocks.push(createInstanceBlock('setup', instance.setupState));
|
9085 | }
|
9086 | if (instance.data !== EMPTY_OBJ) {
|
9087 | blocks.push(createInstanceBlock('data', toRaw(instance.data)));
|
9088 | }
|
9089 | const computed = extractKeys(instance, 'computed');
|
9090 | if (computed) {
|
9091 | blocks.push(createInstanceBlock('computed', computed));
|
9092 | }
|
9093 | const injected = extractKeys(instance, 'inject');
|
9094 | if (injected) {
|
9095 | blocks.push(createInstanceBlock('injected', injected));
|
9096 | }
|
9097 | blocks.push([
|
9098 | 'div',
|
9099 | {},
|
9100 | [
|
9101 | 'span',
|
9102 | {
|
9103 | style: keywordStyle.style + ';opacity:0.66'
|
9104 | },
|
9105 | '$ (internal): '
|
9106 | ],
|
9107 | ['object', { object: instance }]
|
9108 | ]);
|
9109 | return blocks;
|
9110 | }
|
9111 | function createInstanceBlock(type, target) {
|
9112 | target = extend({}, target);
|
9113 | if (!Object.keys(target).length) {
|
9114 | return ['span', {}];
|
9115 | }
|
9116 | return [
|
9117 | 'div',
|
9118 | { style: 'line-height:1.25em;margin-bottom:0.6em' },
|
9119 | [
|
9120 | 'div',
|
9121 | {
|
9122 | style: 'color:#476582'
|
9123 | },
|
9124 | type
|
9125 | ],
|
9126 | [
|
9127 | 'div',
|
9128 | {
|
9129 | style: 'padding-left:1.25em'
|
9130 | },
|
9131 | ...Object.keys(target).map(key => {
|
9132 | return [
|
9133 | 'div',
|
9134 | {},
|
9135 | ['span', keywordStyle, key + ': '],
|
9136 | formatValue(target[key], false)
|
9137 | ];
|
9138 | })
|
9139 | ]
|
9140 | ];
|
9141 | }
|
9142 | function formatValue(v, asRaw = true) {
|
9143 | if (typeof v === 'number') {
|
9144 | return ['span', numberStyle, v];
|
9145 | }
|
9146 | else if (typeof v === 'string') {
|
9147 | return ['span', stringStyle, JSON.stringify(v)];
|
9148 | }
|
9149 | else if (typeof v === 'boolean') {
|
9150 | return ['span', keywordStyle, v];
|
9151 | }
|
9152 | else if (isObject(v)) {
|
9153 | return ['object', { object: asRaw ? toRaw(v) : v }];
|
9154 | }
|
9155 | else {
|
9156 | return ['span', stringStyle, String(v)];
|
9157 | }
|
9158 | }
|
9159 | function extractKeys(instance, type) {
|
9160 | const Comp = instance.type;
|
9161 | if (isFunction(Comp)) {
|
9162 | return;
|
9163 | }
|
9164 | const extracted = {};
|
9165 | for (const key in instance.ctx) {
|
9166 | if (isKeyOfType(Comp, key, type)) {
|
9167 | extracted[key] = instance.ctx[key];
|
9168 | }
|
9169 | }
|
9170 | return extracted;
|
9171 | }
|
9172 | function isKeyOfType(Comp, key, type) {
|
9173 | const opts = Comp[type];
|
9174 | if ((isArray(opts) && opts.includes(key)) ||
|
9175 | (isObject(opts) && key in opts)) {
|
9176 | return true;
|
9177 | }
|
9178 | if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
|
9179 | return true;
|
9180 | }
|
9181 | if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
|
9182 | return true;
|
9183 | }
|
9184 | }
|
9185 | function genRefFlag(v) {
|
9186 | if (v._shallow) {
|
9187 | return `ShallowRef`;
|
9188 | }
|
9189 | if (v.effect) {
|
9190 | return `ComputedRef`;
|
9191 | }
|
9192 | return `Ref`;
|
9193 | }
|
9194 | if (window.devtoolsFormatters) {
|
9195 | window.devtoolsFormatters.push(formatter);
|
9196 | }
|
9197 | else {
|
9198 | window.devtoolsFormatters = [formatter];
|
9199 | }
|
9200 | }
|
9201 |
|
9202 | function withMemo(memo, render, cache, index) {
|
9203 | const cached = cache[index];
|
9204 | if (cached && isMemoSame(cached, memo)) {
|
9205 | return cached;
|
9206 | }
|
9207 | const ret = render();
|
9208 |
|
9209 | ret.memo = memo.slice();
|
9210 | return (cache[index] = ret);
|
9211 | }
|
9212 | function isMemoSame(cached, memo) {
|
9213 | const prev = cached.memo;
|
9214 | if (prev.length != memo.length) {
|
9215 | return false;
|
9216 | }
|
9217 | for (let i = 0; i < prev.length; i++) {
|
9218 | if (prev[i] !== memo[i]) {
|
9219 | return false;
|
9220 | }
|
9221 | }
|
9222 |
|
9223 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
9224 | currentBlock.push(cached);
|
9225 | }
|
9226 | return true;
|
9227 | }
|
9228 |
|
9229 |
|
9230 | const version = "3.2.10";
|
9231 | |
9232 |
|
9233 |
|
9234 |
|
9235 | const ssrUtils = (null);
|
9236 | |
9237 |
|
9238 |
|
9239 | const resolveFilter = null;
|
9240 | |
9241 |
|
9242 |
|
9243 | const compatUtils = (null);
|
9244 |
|
9245 | const svgNS = 'http://www.w3.org/2000/svg';
|
9246 | const doc = (typeof document !== 'undefined' ? document : null);
|
9247 | const staticTemplateCache = new Map();
|
9248 | const nodeOps = {
|
9249 | insert: (child, parent, anchor) => {
|
9250 | parent.insertBefore(child, anchor || null);
|
9251 | },
|
9252 | remove: child => {
|
9253 | const parent = child.parentNode;
|
9254 | if (parent) {
|
9255 | parent.removeChild(child);
|
9256 | }
|
9257 | },
|
9258 | createElement: (tag, isSVG, is, props) => {
|
9259 | const el = isSVG
|
9260 | ? doc.createElementNS(svgNS, tag)
|
9261 | : doc.createElement(tag, is ? { is } : undefined);
|
9262 | if (tag === 'select' && props && props.multiple != null) {
|
9263 | el.setAttribute('multiple', props.multiple);
|
9264 | }
|
9265 | return el;
|
9266 | },
|
9267 | createText: text => doc.createTextNode(text),
|
9268 | createComment: text => doc.createComment(text),
|
9269 | setText: (node, text) => {
|
9270 | node.nodeValue = text;
|
9271 | },
|
9272 | setElementText: (el, text) => {
|
9273 | el.textContent = text;
|
9274 | },
|
9275 | parentNode: node => node.parentNode,
|
9276 | nextSibling: node => node.nextSibling,
|
9277 | querySelector: selector => doc.querySelector(selector),
|
9278 | setScopeId(el, id) {
|
9279 | el.setAttribute(id, '');
|
9280 | },
|
9281 | cloneNode(el) {
|
9282 | const cloned = el.cloneNode(true);
|
9283 |
|
9284 |
|
9285 |
|
9286 |
|
9287 |
|
9288 |
|
9289 |
|
9290 |
|
9291 |
|
9292 | if (`_value` in el) {
|
9293 | cloned._value = el._value;
|
9294 | }
|
9295 | return cloned;
|
9296 | },
|
9297 |
|
9298 |
|
9299 |
|
9300 |
|
9301 | insertStaticContent(content, parent, anchor, isSVG) {
|
9302 |
|
9303 | const before = anchor ? anchor.previousSibling : parent.lastChild;
|
9304 | let template = staticTemplateCache.get(content);
|
9305 | if (!template) {
|
9306 | const t = doc.createElement('template');
|
9307 | t.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
|
9308 | template = t.content;
|
9309 | if (isSVG) {
|
9310 |
|
9311 | const wrapper = template.firstChild;
|
9312 | while (wrapper.firstChild) {
|
9313 | template.appendChild(wrapper.firstChild);
|
9314 | }
|
9315 | template.removeChild(wrapper);
|
9316 | }
|
9317 | staticTemplateCache.set(content, template);
|
9318 | }
|
9319 | parent.insertBefore(template.cloneNode(true), anchor);
|
9320 | return [
|
9321 |
|
9322 | before ? before.nextSibling : parent.firstChild,
|
9323 |
|
9324 | anchor ? anchor.previousSibling : parent.lastChild
|
9325 | ];
|
9326 | }
|
9327 | };
|
9328 |
|
9329 |
|
9330 |
|
9331 | function patchClass(el, value, isSVG) {
|
9332 |
|
9333 |
|
9334 |
|
9335 | const transitionClasses = el._vtc;
|
9336 | if (transitionClasses) {
|
9337 | value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
|
9338 | }
|
9339 | if (value == null) {
|
9340 | el.removeAttribute('class');
|
9341 | }
|
9342 | else if (isSVG) {
|
9343 | el.setAttribute('class', value);
|
9344 | }
|
9345 | else {
|
9346 | el.className = value;
|
9347 | }
|
9348 | }
|
9349 |
|
9350 | function patchStyle(el, prev, next) {
|
9351 | const style = el.style;
|
9352 | const currentDisplay = style.display;
|
9353 | if (!next) {
|
9354 | el.removeAttribute('style');
|
9355 | }
|
9356 | else if (isString(next)) {
|
9357 | if (prev !== next) {
|
9358 | style.cssText = next;
|
9359 | }
|
9360 | }
|
9361 | else {
|
9362 | for (const key in next) {
|
9363 | setStyle(style, key, next[key]);
|
9364 | }
|
9365 | if (prev && !isString(prev)) {
|
9366 | for (const key in prev) {
|
9367 | if (next[key] == null) {
|
9368 | setStyle(style, key, '');
|
9369 | }
|
9370 | }
|
9371 | }
|
9372 | }
|
9373 |
|
9374 |
|
9375 |
|
9376 | if ('_vod' in el) {
|
9377 | style.display = currentDisplay;
|
9378 | }
|
9379 | }
|
9380 | const importantRE = /\s*!important$/;
|
9381 | function setStyle(style, name, val) {
|
9382 | if (isArray(val)) {
|
9383 | val.forEach(v => setStyle(style, name, v));
|
9384 | }
|
9385 | else {
|
9386 | if (name.startsWith('--')) {
|
9387 |
|
9388 | style.setProperty(name, val);
|
9389 | }
|
9390 | else {
|
9391 | const prefixed = autoPrefix(style, name);
|
9392 | if (importantRE.test(val)) {
|
9393 |
|
9394 | style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
|
9395 | }
|
9396 | else {
|
9397 | style[prefixed] = val;
|
9398 | }
|
9399 | }
|
9400 | }
|
9401 | }
|
9402 | const prefixes = ['Webkit', 'Moz', 'ms'];
|
9403 | const prefixCache = {};
|
9404 | function autoPrefix(style, rawName) {
|
9405 | const cached = prefixCache[rawName];
|
9406 | if (cached) {
|
9407 | return cached;
|
9408 | }
|
9409 | let name = camelize(rawName);
|
9410 | if (name !== 'filter' && name in style) {
|
9411 | return (prefixCache[rawName] = name);
|
9412 | }
|
9413 | name = capitalize(name);
|
9414 | for (let i = 0; i < prefixes.length; i++) {
|
9415 | const prefixed = prefixes[i] + name;
|
9416 | if (prefixed in style) {
|
9417 | return (prefixCache[rawName] = prefixed);
|
9418 | }
|
9419 | }
|
9420 | return rawName;
|
9421 | }
|
9422 |
|
9423 | const xlinkNS = 'http://www.w3.org/1999/xlink';
|
9424 | function patchAttr(el, key, value, isSVG, instance) {
|
9425 | if (isSVG && key.startsWith('xlink:')) {
|
9426 | if (value == null) {
|
9427 | el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
9428 | }
|
9429 | else {
|
9430 | el.setAttributeNS(xlinkNS, key, value);
|
9431 | }
|
9432 | }
|
9433 | else {
|
9434 |
|
9435 |
|
9436 | const isBoolean = isSpecialBooleanAttr(key);
|
9437 | if (value == null || (isBoolean && !includeBooleanAttr(value))) {
|
9438 | el.removeAttribute(key);
|
9439 | }
|
9440 | else {
|
9441 | el.setAttribute(key, isBoolean ? '' : value);
|
9442 | }
|
9443 | }
|
9444 | }
|
9445 |
|
9446 |
|
9447 |
|
9448 | function patchDOMProp(el, key, value,
|
9449 | // the following args are passed only due to potential innerHTML/textContent
|
9450 |
|
9451 |
|
9452 | prevChildren, parentComponent, parentSuspense, unmountChildren) {
|
9453 | if (key === 'innerHTML' || key === 'textContent') {
|
9454 | if (prevChildren) {
|
9455 | unmountChildren(prevChildren, parentComponent, parentSuspense);
|
9456 | }
|
9457 | el[key] = value == null ? '' : value;
|
9458 | return;
|
9459 | }
|
9460 | if (key === 'value' && el.tagName !== 'PROGRESS') {
|
9461 |
|
9462 |
|
9463 | el._value = value;
|
9464 | const newValue = value == null ? '' : value;
|
9465 | if (el.value !== newValue) {
|
9466 | el.value = newValue;
|
9467 | }
|
9468 | if (value == null) {
|
9469 | el.removeAttribute(key);
|
9470 | }
|
9471 | return;
|
9472 | }
|
9473 | if (value === '' || value == null) {
|
9474 | const type = typeof el[key];
|
9475 | if (type === 'boolean') {
|
9476 |
|
9477 | el[key] = includeBooleanAttr(value);
|
9478 | return;
|
9479 | }
|
9480 | else if (value == null && type === 'string') {
|
9481 |
|
9482 | el[key] = '';
|
9483 | el.removeAttribute(key);
|
9484 | return;
|
9485 | }
|
9486 | else if (type === 'number') {
|
9487 |
|
9488 |
|
9489 | try {
|
9490 | el[key] = 0;
|
9491 | }
|
9492 | catch (_a) { }
|
9493 | el.removeAttribute(key);
|
9494 | return;
|
9495 | }
|
9496 | }
|
9497 |
|
9498 | try {
|
9499 | el[key] = value;
|
9500 | }
|
9501 | catch (e) {
|
9502 | {
|
9503 | warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
|
9504 | `value ${value} is invalid.`, e);
|
9505 | }
|
9506 | }
|
9507 | }
|
9508 |
|
9509 |
|
9510 | let _getNow = Date.now;
|
9511 | let skipTimestampCheck = false;
|
9512 | if (typeof window !== 'undefined') {
|
9513 |
|
9514 |
|
9515 |
|
9516 |
|
9517 | if (_getNow() > document.createEvent('Event').timeStamp) {
|
9518 |
|
9519 |
|
9520 |
|
9521 | _getNow = () => performance.now();
|
9522 | }
|
9523 |
|
9524 |
|
9525 | const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
|
9526 | skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
|
9527 | }
|
9528 |
|
9529 |
|
9530 | let cachedNow = 0;
|
9531 | const p = Promise.resolve();
|
9532 | const reset = () => {
|
9533 | cachedNow = 0;
|
9534 | };
|
9535 | const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
|
9536 | function addEventListener(el, event, handler, options) {
|
9537 | el.addEventListener(event, handler, options);
|
9538 | }
|
9539 | function removeEventListener(el, event, handler, options) {
|
9540 | el.removeEventListener(event, handler, options);
|
9541 | }
|
9542 | function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
9543 |
|
9544 | const invokers = el._vei || (el._vei = {});
|
9545 | const existingInvoker = invokers[rawName];
|
9546 | if (nextValue && existingInvoker) {
|
9547 |
|
9548 | existingInvoker.value = nextValue;
|
9549 | }
|
9550 | else {
|
9551 | const [name, options] = parseName(rawName);
|
9552 | if (nextValue) {
|
9553 |
|
9554 | const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
|
9555 | addEventListener(el, name, invoker, options);
|
9556 | }
|
9557 | else if (existingInvoker) {
|
9558 |
|
9559 | removeEventListener(el, name, existingInvoker, options);
|
9560 | invokers[rawName] = undefined;
|
9561 | }
|
9562 | }
|
9563 | }
|
9564 | const optionsModifierRE = /(?:Once|Passive|Capture)$/;
|
9565 | function parseName(name) {
|
9566 | let options;
|
9567 | if (optionsModifierRE.test(name)) {
|
9568 | options = {};
|
9569 | let m;
|
9570 | while ((m = name.match(optionsModifierRE))) {
|
9571 | name = name.slice(0, name.length - m[0].length);
|
9572 | options[m[0].toLowerCase()] = true;
|
9573 | }
|
9574 | }
|
9575 | return [hyphenate(name.slice(2)), options];
|
9576 | }
|
9577 | function createInvoker(initialValue, instance) {
|
9578 | const invoker = (e) => {
|
9579 |
|
9580 |
|
9581 |
|
9582 |
|
9583 |
|
9584 |
|
9585 | const timeStamp = e.timeStamp || _getNow();
|
9586 | if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
|
9587 | callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 , [e]);
|
9588 | }
|
9589 | };
|
9590 | invoker.value = initialValue;
|
9591 | invoker.attached = getNow();
|
9592 | return invoker;
|
9593 | }
|
9594 | function patchStopImmediatePropagation(e, value) {
|
9595 | if (isArray(value)) {
|
9596 | const originalStop = e.stopImmediatePropagation;
|
9597 | e.stopImmediatePropagation = () => {
|
9598 | originalStop.call(e);
|
9599 | e._stopped = true;
|
9600 | };
|
9601 | return value.map(fn => (e) => !e._stopped && fn(e));
|
9602 | }
|
9603 | else {
|
9604 | return value;
|
9605 | }
|
9606 | }
|
9607 |
|
9608 | const nativeOnRE = /^on[a-z]/;
|
9609 | const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
|
9610 | if (key === 'class') {
|
9611 | patchClass(el, nextValue, isSVG);
|
9612 | }
|
9613 | else if (key === 'style') {
|
9614 | patchStyle(el, prevValue, nextValue);
|
9615 | }
|
9616 | else if (isOn(key)) {
|
9617 |
|
9618 | if (!isModelListener(key)) {
|
9619 | patchEvent(el, key, prevValue, nextValue, parentComponent);
|
9620 | }
|
9621 | }
|
9622 | else if (key[0] === '.'
|
9623 | ? ((key = key.slice(1)), true)
|
9624 | : key[0] === '^'
|
9625 | ? ((key = key.slice(1)), false)
|
9626 | : shouldSetAsProp(el, key, nextValue, isSVG)) {
|
9627 | patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
|
9628 | }
|
9629 | else {
|
9630 |
|
9631 |
|
9632 |
|
9633 |
|
9634 | if (key === 'true-value') {
|
9635 | el._trueValue = nextValue;
|
9636 | }
|
9637 | else if (key === 'false-value') {
|
9638 | el._falseValue = nextValue;
|
9639 | }
|
9640 | patchAttr(el, key, nextValue, isSVG);
|
9641 | }
|
9642 | };
|
9643 | function shouldSetAsProp(el, key, value, isSVG) {
|
9644 | if (isSVG) {
|
9645 |
|
9646 |
|
9647 | if (key === 'innerHTML' || key === 'textContent') {
|
9648 | return true;
|
9649 | }
|
9650 |
|
9651 | if (key in el && nativeOnRE.test(key) && isFunction(value)) {
|
9652 | return true;
|
9653 | }
|
9654 | return false;
|
9655 | }
|
9656 |
|
9657 |
|
9658 |
|
9659 |
|
9660 |
|
9661 |
|
9662 | if (key === 'spellcheck' || key === 'draggable') {
|
9663 | return false;
|
9664 | }
|
9665 |
|
9666 |
|
9667 | if (key === 'form') {
|
9668 | return false;
|
9669 | }
|
9670 |
|
9671 | if (key === 'list' && el.tagName === 'INPUT') {
|
9672 | return false;
|
9673 | }
|
9674 |
|
9675 | if (key === 'type' && el.tagName === 'TEXTAREA') {
|
9676 | return false;
|
9677 | }
|
9678 |
|
9679 | if (nativeOnRE.test(key) && isString(value)) {
|
9680 | return false;
|
9681 | }
|
9682 | return key in el;
|
9683 | }
|
9684 |
|
9685 | function defineCustomElement(options, hydate) {
|
9686 | const Comp = defineComponent(options);
|
9687 | class VueCustomElement extends VueElement {
|
9688 | constructor(initialProps) {
|
9689 | super(Comp, initialProps, hydate);
|
9690 | }
|
9691 | }
|
9692 | VueCustomElement.def = Comp;
|
9693 | return VueCustomElement;
|
9694 | }
|
9695 | const defineSSRCustomElement = ((options) => {
|
9696 |
|
9697 | return defineCustomElement(options, hydrate);
|
9698 | });
|
9699 | const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
|
9700 | });
|
9701 | class VueElement extends BaseClass {
|
9702 | constructor(_def, _props = {}, hydrate) {
|
9703 | super();
|
9704 | this._def = _def;
|
9705 | this._props = _props;
|
9706 | |
9707 |
|
9708 |
|
9709 | this._instance = null;
|
9710 | this._connected = false;
|
9711 | this._resolved = false;
|
9712 | if (this.shadowRoot && hydrate) {
|
9713 | hydrate(this._createVNode(), this.shadowRoot);
|
9714 | }
|
9715 | else {
|
9716 | if (this.shadowRoot) {
|
9717 | warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
|
9718 | `defined as hydratable. Use \`defineSSRCustomElement\`.`);
|
9719 | }
|
9720 | this.attachShadow({ mode: 'open' });
|
9721 | }
|
9722 |
|
9723 | for (let i = 0; i < this.attributes.length; i++) {
|
9724 | this._setAttr(this.attributes[i].name);
|
9725 | }
|
9726 |
|
9727 | const observer = new MutationObserver(mutations => {
|
9728 | for (const m of mutations) {
|
9729 | this._setAttr(m.attributeName);
|
9730 | }
|
9731 | });
|
9732 | observer.observe(this, { attributes: true });
|
9733 | }
|
9734 | connectedCallback() {
|
9735 | this._connected = true;
|
9736 | if (!this._instance) {
|
9737 | this._resolveDef();
|
9738 | render(this._createVNode(), this.shadowRoot);
|
9739 | }
|
9740 | }
|
9741 | disconnectedCallback() {
|
9742 | this._connected = false;
|
9743 | nextTick(() => {
|
9744 | if (!this._connected) {
|
9745 | render(null, this.shadowRoot);
|
9746 | this._instance = null;
|
9747 | }
|
9748 | });
|
9749 | }
|
9750 | |
9751 |
|
9752 |
|
9753 | _resolveDef() {
|
9754 | if (this._resolved) {
|
9755 | return;
|
9756 | }
|
9757 | const resolve = (def) => {
|
9758 | this._resolved = true;
|
9759 |
|
9760 | for (const key of Object.keys(this)) {
|
9761 | if (key[0] !== '_') {
|
9762 | this._setProp(key, this[key]);
|
9763 | }
|
9764 | }
|
9765 | const { props, styles } = def;
|
9766 |
|
9767 | const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
|
9768 | for (const key of rawKeys.map(camelize)) {
|
9769 | Object.defineProperty(this, key, {
|
9770 | get() {
|
9771 | return this._getProp(key);
|
9772 | },
|
9773 | set(val) {
|
9774 | this._setProp(key, val);
|
9775 | }
|
9776 | });
|
9777 | }
|
9778 | this._applyStyles(styles);
|
9779 | };
|
9780 | const asyncDef = this._def.__asyncLoader;
|
9781 | if (asyncDef) {
|
9782 | asyncDef().then(resolve);
|
9783 | }
|
9784 | else {
|
9785 | resolve(this._def);
|
9786 | }
|
9787 | }
|
9788 | _setAttr(key) {
|
9789 | this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
|
9790 | }
|
9791 | |
9792 |
|
9793 |
|
9794 | _getProp(key) {
|
9795 | return this._props[key];
|
9796 | }
|
9797 | |
9798 |
|
9799 |
|
9800 | _setProp(key, val, shouldReflect = true) {
|
9801 | if (val !== this._props[key]) {
|
9802 | this._props[key] = val;
|
9803 | if (this._instance) {
|
9804 | render(this._createVNode(), this.shadowRoot);
|
9805 | }
|
9806 |
|
9807 | if (shouldReflect) {
|
9808 | if (val === true) {
|
9809 | this.setAttribute(hyphenate(key), '');
|
9810 | }
|
9811 | else if (typeof val === 'string' || typeof val === 'number') {
|
9812 | this.setAttribute(hyphenate(key), val + '');
|
9813 | }
|
9814 | else if (!val) {
|
9815 | this.removeAttribute(hyphenate(key));
|
9816 | }
|
9817 | }
|
9818 | }
|
9819 | }
|
9820 | _createVNode() {
|
9821 | const vnode = createVNode(this._def, extend({}, this._props));
|
9822 | if (!this._instance) {
|
9823 | vnode.ce = instance => {
|
9824 | this._instance = instance;
|
9825 | instance.isCE = true;
|
9826 |
|
9827 | {
|
9828 | instance.ceReload = newStyles => {
|
9829 |
|
9830 | if (this._styles) {
|
9831 | this._styles.forEach(s => this.shadowRoot.removeChild(s));
|
9832 | this._styles.length = 0;
|
9833 | }
|
9834 | this._applyStyles(newStyles);
|
9835 |
|
9836 |
|
9837 | if (!this._def.__asyncLoader) {
|
9838 |
|
9839 | this._instance = null;
|
9840 | render(this._createVNode(), this.shadowRoot);
|
9841 | }
|
9842 | };
|
9843 | }
|
9844 |
|
9845 | instance.emit = (event, ...args) => {
|
9846 | this.dispatchEvent(new CustomEvent(event, {
|
9847 | detail: args
|
9848 | }));
|
9849 | };
|
9850 |
|
9851 | let parent = this;
|
9852 | while ((parent =
|
9853 | parent && (parent.parentNode || parent.host))) {
|
9854 | if (parent instanceof VueElement) {
|
9855 | instance.parent = parent._instance;
|
9856 | break;
|
9857 | }
|
9858 | }
|
9859 | };
|
9860 | }
|
9861 | return vnode;
|
9862 | }
|
9863 | _applyStyles(styles) {
|
9864 | if (styles) {
|
9865 | styles.forEach(css => {
|
9866 | const s = document.createElement('style');
|
9867 | s.textContent = css;
|
9868 | this.shadowRoot.appendChild(s);
|
9869 |
|
9870 | {
|
9871 | (this._styles || (this._styles = [])).push(s);
|
9872 | }
|
9873 | });
|
9874 | }
|
9875 | }
|
9876 | }
|
9877 |
|
9878 | function useCssModule(name = '$style') {
|
9879 |
|
9880 | {
|
9881 | {
|
9882 | warn$1(`useCssModule() is not supported in the global build.`);
|
9883 | }
|
9884 | return EMPTY_OBJ;
|
9885 | }
|
9886 | }
|
9887 |
|
9888 | |
9889 |
|
9890 |
|
9891 |
|
9892 | function useCssVars(getter) {
|
9893 | const instance = getCurrentInstance();
|
9894 |
|
9895 | if (!instance) {
|
9896 | warn$1(`useCssVars is called without current active component instance.`);
|
9897 | return;
|
9898 | }
|
9899 | const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
|
9900 | watchPostEffect(setVars);
|
9901 | onMounted(() => {
|
9902 | const ob = new MutationObserver(setVars);
|
9903 | ob.observe(instance.subTree.el.parentNode, { childList: true });
|
9904 | onUnmounted(() => ob.disconnect());
|
9905 | });
|
9906 | }
|
9907 | function setVarsOnVNode(vnode, vars) {
|
9908 | if (vnode.shapeFlag & 128 ) {
|
9909 | const suspense = vnode.suspense;
|
9910 | vnode = suspense.activeBranch;
|
9911 | if (suspense.pendingBranch && !suspense.isHydrating) {
|
9912 | suspense.effects.push(() => {
|
9913 | setVarsOnVNode(suspense.activeBranch, vars);
|
9914 | });
|
9915 | }
|
9916 | }
|
9917 |
|
9918 | while (vnode.component) {
|
9919 | vnode = vnode.component.subTree;
|
9920 | }
|
9921 | if (vnode.shapeFlag & 1 && vnode.el) {
|
9922 | setVarsOnNode(vnode.el, vars);
|
9923 | }
|
9924 | else if (vnode.type === Fragment) {
|
9925 | vnode.children.forEach(c => setVarsOnVNode(c, vars));
|
9926 | }
|
9927 | else if (vnode.type === Static) {
|
9928 | let { el, anchor } = vnode;
|
9929 | while (el) {
|
9930 | setVarsOnNode(el, vars);
|
9931 | if (el === anchor)
|
9932 | break;
|
9933 | el = el.nextSibling;
|
9934 | }
|
9935 | }
|
9936 | }
|
9937 | function setVarsOnNode(el, vars) {
|
9938 | if (el.nodeType === 1) {
|
9939 | const style = el.style;
|
9940 | for (const key in vars) {
|
9941 | style.setProperty(`--${key}`, vars[key]);
|
9942 | }
|
9943 | }
|
9944 | }
|
9945 |
|
9946 | const TRANSITION = 'transition';
|
9947 | const ANIMATION = 'animation';
|
9948 |
|
9949 |
|
9950 | const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
|
9951 | Transition.displayName = 'Transition';
|
9952 | const DOMTransitionPropsValidators = {
|
9953 | name: String,
|
9954 | type: String,
|
9955 | css: {
|
9956 | type: Boolean,
|
9957 | default: true
|
9958 | },
|
9959 | duration: [String, Number, Object],
|
9960 | enterFromClass: String,
|
9961 | enterActiveClass: String,
|
9962 | enterToClass: String,
|
9963 | appearFromClass: String,
|
9964 | appearActiveClass: String,
|
9965 | appearToClass: String,
|
9966 | leaveFromClass: String,
|
9967 | leaveActiveClass: String,
|
9968 | leaveToClass: String
|
9969 | };
|
9970 | const TransitionPropsValidators = (Transition.props =
|
9971 | extend({}, BaseTransition.props, DOMTransitionPropsValidators));
|
9972 | |
9973 |
|
9974 |
|
9975 |
|
9976 | const callHook$1 = (hook, args = []) => {
|
9977 | if (isArray(hook)) {
|
9978 | hook.forEach(h => h(...args));
|
9979 | }
|
9980 | else if (hook) {
|
9981 | hook(...args);
|
9982 | }
|
9983 | };
|
9984 | |
9985 |
|
9986 |
|
9987 |
|
9988 | const hasExplicitCallback = (hook) => {
|
9989 | return hook
|
9990 | ? isArray(hook)
|
9991 | ? hook.some(h => h.length > 1)
|
9992 | : hook.length > 1
|
9993 | : false;
|
9994 | };
|
9995 | function resolveTransitionProps(rawProps) {
|
9996 | const baseProps = {};
|
9997 | for (const key in rawProps) {
|
9998 | if (!(key in DOMTransitionPropsValidators)) {
|
9999 | baseProps[key] = rawProps[key];
|
10000 | }
|
10001 | }
|
10002 | if (rawProps.css === false) {
|
10003 | return baseProps;
|
10004 | }
|
10005 | const { name = 'v', type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
|
10006 | const durations = normalizeDuration(duration);
|
10007 | const enterDuration = durations && durations[0];
|
10008 | const leaveDuration = durations && durations[1];
|
10009 | const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
|
10010 | const finishEnter = (el, isAppear, done) => {
|
10011 | removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
10012 | removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
|
10013 | done && done();
|
10014 | };
|
10015 | const finishLeave = (el, done) => {
|
10016 | removeTransitionClass(el, leaveToClass);
|
10017 | removeTransitionClass(el, leaveActiveClass);
|
10018 | done && done();
|
10019 | };
|
10020 | const makeEnterHook = (isAppear) => {
|
10021 | return (el, done) => {
|
10022 | const hook = isAppear ? onAppear : onEnter;
|
10023 | const resolve = () => finishEnter(el, isAppear, done);
|
10024 | callHook$1(hook, [el, resolve]);
|
10025 | nextFrame(() => {
|
10026 | removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
|
10027 | addTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
10028 | if (!hasExplicitCallback(hook)) {
|
10029 | whenTransitionEnds(el, type, enterDuration, resolve);
|
10030 | }
|
10031 | });
|
10032 | };
|
10033 | };
|
10034 | return extend(baseProps, {
|
10035 | onBeforeEnter(el) {
|
10036 | callHook$1(onBeforeEnter, [el]);
|
10037 | addTransitionClass(el, enterFromClass);
|
10038 | addTransitionClass(el, enterActiveClass);
|
10039 | },
|
10040 | onBeforeAppear(el) {
|
10041 | callHook$1(onBeforeAppear, [el]);
|
10042 | addTransitionClass(el, appearFromClass);
|
10043 | addTransitionClass(el, appearActiveClass);
|
10044 | },
|
10045 | onEnter: makeEnterHook(false),
|
10046 | onAppear: makeEnterHook(true),
|
10047 | onLeave(el, done) {
|
10048 | const resolve = () => finishLeave(el, done);
|
10049 | addTransitionClass(el, leaveFromClass);
|
10050 |
|
10051 | forceReflow();
|
10052 | addTransitionClass(el, leaveActiveClass);
|
10053 | nextFrame(() => {
|
10054 | removeTransitionClass(el, leaveFromClass);
|
10055 | addTransitionClass(el, leaveToClass);
|
10056 | if (!hasExplicitCallback(onLeave)) {
|
10057 | whenTransitionEnds(el, type, leaveDuration, resolve);
|
10058 | }
|
10059 | });
|
10060 | callHook$1(onLeave, [el, resolve]);
|
10061 | },
|
10062 | onEnterCancelled(el) {
|
10063 | finishEnter(el, false);
|
10064 | callHook$1(onEnterCancelled, [el]);
|
10065 | },
|
10066 | onAppearCancelled(el) {
|
10067 | finishEnter(el, true);
|
10068 | callHook$1(onAppearCancelled, [el]);
|
10069 | },
|
10070 | onLeaveCancelled(el) {
|
10071 | finishLeave(el);
|
10072 | callHook$1(onLeaveCancelled, [el]);
|
10073 | }
|
10074 | });
|
10075 | }
|
10076 | function normalizeDuration(duration) {
|
10077 | if (duration == null) {
|
10078 | return null;
|
10079 | }
|
10080 | else if (isObject(duration)) {
|
10081 | return [NumberOf(duration.enter), NumberOf(duration.leave)];
|
10082 | }
|
10083 | else {
|
10084 | const n = NumberOf(duration);
|
10085 | return [n, n];
|
10086 | }
|
10087 | }
|
10088 | function NumberOf(val) {
|
10089 | const res = toNumber(val);
|
10090 | validateDuration(res);
|
10091 | return res;
|
10092 | }
|
10093 | function validateDuration(val) {
|
10094 | if (typeof val !== 'number') {
|
10095 | warn$1(`<transition> explicit duration is not a valid number - ` +
|
10096 | `got ${JSON.stringify(val)}.`);
|
10097 | }
|
10098 | else if (isNaN(val)) {
|
10099 | warn$1(`<transition> explicit duration is NaN - ` +
|
10100 | 'the duration expression might be incorrect.');
|
10101 | }
|
10102 | }
|
10103 | function addTransitionClass(el, cls) {
|
10104 | cls.split(/\s+/).forEach(c => c && el.classList.add(c));
|
10105 | (el._vtc ||
|
10106 | (el._vtc = new Set())).add(cls);
|
10107 | }
|
10108 | function removeTransitionClass(el, cls) {
|
10109 | cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
|
10110 | const { _vtc } = el;
|
10111 | if (_vtc) {
|
10112 | _vtc.delete(cls);
|
10113 | if (!_vtc.size) {
|
10114 | el._vtc = undefined;
|
10115 | }
|
10116 | }
|
10117 | }
|
10118 | function nextFrame(cb) {
|
10119 | requestAnimationFrame(() => {
|
10120 | requestAnimationFrame(cb);
|
10121 | });
|
10122 | }
|
10123 | let endId = 0;
|
10124 | function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
|
10125 | const id = (el._endId = ++endId);
|
10126 | const resolveIfNotStale = () => {
|
10127 | if (id === el._endId) {
|
10128 | resolve();
|
10129 | }
|
10130 | };
|
10131 | if (explicitTimeout) {
|
10132 | return setTimeout(resolveIfNotStale, explicitTimeout);
|
10133 | }
|
10134 | const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
|
10135 | if (!type) {
|
10136 | return resolve();
|
10137 | }
|
10138 | const endEvent = type + 'end';
|
10139 | let ended = 0;
|
10140 | const end = () => {
|
10141 | el.removeEventListener(endEvent, onEnd);
|
10142 | resolveIfNotStale();
|
10143 | };
|
10144 | const onEnd = (e) => {
|
10145 | if (e.target === el && ++ended >= propCount) {
|
10146 | end();
|
10147 | }
|
10148 | };
|
10149 | setTimeout(() => {
|
10150 | if (ended < propCount) {
|
10151 | end();
|
10152 | }
|
10153 | }, timeout + 1);
|
10154 | el.addEventListener(endEvent, onEnd);
|
10155 | }
|
10156 | function getTransitionInfo(el, expectedType) {
|
10157 | const styles = window.getComputedStyle(el);
|
10158 |
|
10159 | const getStyleProperties = (key) => (styles[key] || '').split(', ');
|
10160 | const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
|
10161 | const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
|
10162 | const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
|
10163 | const animationDelays = getStyleProperties(ANIMATION + 'Delay');
|
10164 | const animationDurations = getStyleProperties(ANIMATION + 'Duration');
|
10165 | const animationTimeout = getTimeout(animationDelays, animationDurations);
|
10166 | let type = null;
|
10167 | let timeout = 0;
|
10168 | let propCount = 0;
|
10169 |
|
10170 | if (expectedType === TRANSITION) {
|
10171 | if (transitionTimeout > 0) {
|
10172 | type = TRANSITION;
|
10173 | timeout = transitionTimeout;
|
10174 | propCount = transitionDurations.length;
|
10175 | }
|
10176 | }
|
10177 | else if (expectedType === ANIMATION) {
|
10178 | if (animationTimeout > 0) {
|
10179 | type = ANIMATION;
|
10180 | timeout = animationTimeout;
|
10181 | propCount = animationDurations.length;
|
10182 | }
|
10183 | }
|
10184 | else {
|
10185 | timeout = Math.max(transitionTimeout, animationTimeout);
|
10186 | type =
|
10187 | timeout > 0
|
10188 | ? transitionTimeout > animationTimeout
|
10189 | ? TRANSITION
|
10190 | : ANIMATION
|
10191 | : null;
|
10192 | propCount = type
|
10193 | ? type === TRANSITION
|
10194 | ? transitionDurations.length
|
10195 | : animationDurations.length
|
10196 | : 0;
|
10197 | }
|
10198 | const hasTransform = type === TRANSITION &&
|
10199 | /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
|
10200 | return {
|
10201 | type,
|
10202 | timeout,
|
10203 | propCount,
|
10204 | hasTransform
|
10205 | };
|
10206 | }
|
10207 | function getTimeout(delays, durations) {
|
10208 | while (delays.length < durations.length) {
|
10209 | delays = delays.concat(delays);
|
10210 | }
|
10211 | return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
|
10212 | }
|
10213 |
|
10214 |
|
10215 |
|
10216 |
|
10217 | function toMs(s) {
|
10218 | return Number(s.slice(0, -1).replace(',', '.')) * 1000;
|
10219 | }
|
10220 |
|
10221 | function forceReflow() {
|
10222 | return document.body.offsetHeight;
|
10223 | }
|
10224 |
|
10225 | const positionMap = new WeakMap();
|
10226 | const newPositionMap = new WeakMap();
|
10227 | const TransitionGroupImpl = {
|
10228 | name: 'TransitionGroup',
|
10229 | props: extend({}, TransitionPropsValidators, {
|
10230 | tag: String,
|
10231 | moveClass: String
|
10232 | }),
|
10233 | setup(props, { slots }) {
|
10234 | const instance = getCurrentInstance();
|
10235 | const state = useTransitionState();
|
10236 | let prevChildren;
|
10237 | let children;
|
10238 | onUpdated(() => {
|
10239 |
|
10240 | if (!prevChildren.length) {
|
10241 | return;
|
10242 | }
|
10243 | const moveClass = props.moveClass || `${props.name || 'v'}-move`;
|
10244 | if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
|
10245 | return;
|
10246 | }
|
10247 |
|
10248 |
|
10249 | prevChildren.forEach(callPendingCbs);
|
10250 | prevChildren.forEach(recordPosition);
|
10251 | const movedChildren = prevChildren.filter(applyTranslation);
|
10252 |
|
10253 | forceReflow();
|
10254 | movedChildren.forEach(c => {
|
10255 | const el = c.el;
|
10256 | const style = el.style;
|
10257 | addTransitionClass(el, moveClass);
|
10258 | style.transform = style.webkitTransform = style.transitionDuration = '';
|
10259 | const cb = (el._moveCb = (e) => {
|
10260 | if (e && e.target !== el) {
|
10261 | return;
|
10262 | }
|
10263 | if (!e || /transform$/.test(e.propertyName)) {
|
10264 | el.removeEventListener('transitionend', cb);
|
10265 | el._moveCb = null;
|
10266 | removeTransitionClass(el, moveClass);
|
10267 | }
|
10268 | });
|
10269 | el.addEventListener('transitionend', cb);
|
10270 | });
|
10271 | });
|
10272 | return () => {
|
10273 | const rawProps = toRaw(props);
|
10274 | const cssTransitionProps = resolveTransitionProps(rawProps);
|
10275 | let tag = rawProps.tag || Fragment;
|
10276 | prevChildren = children;
|
10277 | children = slots.default ? getTransitionRawChildren(slots.default()) : [];
|
10278 | for (let i = 0; i < children.length; i++) {
|
10279 | const child = children[i];
|
10280 | if (child.key != null) {
|
10281 | setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
|
10282 | }
|
10283 | else {
|
10284 | warn$1(`<TransitionGroup> children must be keyed.`);
|
10285 | }
|
10286 | }
|
10287 | if (prevChildren) {
|
10288 | for (let i = 0; i < prevChildren.length; i++) {
|
10289 | const child = prevChildren[i];
|
10290 | setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
|
10291 | positionMap.set(child, child.el.getBoundingClientRect());
|
10292 | }
|
10293 | }
|
10294 | return createVNode(tag, null, children);
|
10295 | };
|
10296 | }
|
10297 | };
|
10298 | const TransitionGroup = TransitionGroupImpl;
|
10299 | function callPendingCbs(c) {
|
10300 | const el = c.el;
|
10301 | if (el._moveCb) {
|
10302 | el._moveCb();
|
10303 | }
|
10304 | if (el._enterCb) {
|
10305 | el._enterCb();
|
10306 | }
|
10307 | }
|
10308 | function recordPosition(c) {
|
10309 | newPositionMap.set(c, c.el.getBoundingClientRect());
|
10310 | }
|
10311 | function applyTranslation(c) {
|
10312 | const oldPos = positionMap.get(c);
|
10313 | const newPos = newPositionMap.get(c);
|
10314 | const dx = oldPos.left - newPos.left;
|
10315 | const dy = oldPos.top - newPos.top;
|
10316 | if (dx || dy) {
|
10317 | const s = c.el.style;
|
10318 | s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
|
10319 | s.transitionDuration = '0s';
|
10320 | return c;
|
10321 | }
|
10322 | }
|
10323 | function hasCSSTransform(el, root, moveClass) {
|
10324 |
|
10325 |
|
10326 |
|
10327 |
|
10328 |
|
10329 | const clone = el.cloneNode();
|
10330 | if (el._vtc) {
|
10331 | el._vtc.forEach(cls => {
|
10332 | cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
|
10333 | });
|
10334 | }
|
10335 | moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
|
10336 | clone.style.display = 'none';
|
10337 | const container = (root.nodeType === 1 ? root : root.parentNode);
|
10338 | container.appendChild(clone);
|
10339 | const { hasTransform } = getTransitionInfo(clone);
|
10340 | container.removeChild(clone);
|
10341 | return hasTransform;
|
10342 | }
|
10343 |
|
10344 | const getModelAssigner = (vnode) => {
|
10345 | const fn = vnode.props['onUpdate:modelValue'];
|
10346 | return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
|
10347 | };
|
10348 | function onCompositionStart(e) {
|
10349 | e.target.composing = true;
|
10350 | }
|
10351 | function onCompositionEnd(e) {
|
10352 | const target = e.target;
|
10353 | if (target.composing) {
|
10354 | target.composing = false;
|
10355 | trigger$1(target, 'input');
|
10356 | }
|
10357 | }
|
10358 | function trigger$1(el, type) {
|
10359 | const e = document.createEvent('HTMLEvents');
|
10360 | e.initEvent(type, true, true);
|
10361 | el.dispatchEvent(e);
|
10362 | }
|
10363 |
|
10364 |
|
10365 | const vModelText = {
|
10366 | created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
10367 | el._assign = getModelAssigner(vnode);
|
10368 | const castToNumber = number || (vnode.props && vnode.props.type === 'number');
|
10369 | addEventListener(el, lazy ? 'change' : 'input', e => {
|
10370 | if (e.target.composing)
|
10371 | return;
|
10372 | let domValue = el.value;
|
10373 | if (trim) {
|
10374 | domValue = domValue.trim();
|
10375 | }
|
10376 | else if (castToNumber) {
|
10377 | domValue = toNumber(domValue);
|
10378 | }
|
10379 | el._assign(domValue);
|
10380 | });
|
10381 | if (trim) {
|
10382 | addEventListener(el, 'change', () => {
|
10383 | el.value = el.value.trim();
|
10384 | });
|
10385 | }
|
10386 | if (!lazy) {
|
10387 | addEventListener(el, 'compositionstart', onCompositionStart);
|
10388 | addEventListener(el, 'compositionend', onCompositionEnd);
|
10389 |
|
10390 |
|
10391 |
|
10392 |
|
10393 | addEventListener(el, 'change', onCompositionEnd);
|
10394 | }
|
10395 | },
|
10396 |
|
10397 | mounted(el, { value }) {
|
10398 | el.value = value == null ? '' : value;
|
10399 | },
|
10400 | beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
|
10401 | el._assign = getModelAssigner(vnode);
|
10402 |
|
10403 | if (el.composing)
|
10404 | return;
|
10405 | if (document.activeElement === el) {
|
10406 | if (lazy) {
|
10407 | return;
|
10408 | }
|
10409 | if (trim && el.value.trim() === value) {
|
10410 | return;
|
10411 | }
|
10412 | if ((number || el.type === 'number') && toNumber(el.value) === value) {
|
10413 | return;
|
10414 | }
|
10415 | }
|
10416 | const newValue = value == null ? '' : value;
|
10417 | if (el.value !== newValue) {
|
10418 | el.value = newValue;
|
10419 | }
|
10420 | }
|
10421 | };
|
10422 | const vModelCheckbox = {
|
10423 |
|
10424 | deep: true,
|
10425 | created(el, _, vnode) {
|
10426 | el._assign = getModelAssigner(vnode);
|
10427 | addEventListener(el, 'change', () => {
|
10428 | const modelValue = el._modelValue;
|
10429 | const elementValue = getValue(el);
|
10430 | const checked = el.checked;
|
10431 | const assign = el._assign;
|
10432 | if (isArray(modelValue)) {
|
10433 | const index = looseIndexOf(modelValue, elementValue);
|
10434 | const found = index !== -1;
|
10435 | if (checked && !found) {
|
10436 | assign(modelValue.concat(elementValue));
|
10437 | }
|
10438 | else if (!checked && found) {
|
10439 | const filtered = [...modelValue];
|
10440 | filtered.splice(index, 1);
|
10441 | assign(filtered);
|
10442 | }
|
10443 | }
|
10444 | else if (isSet(modelValue)) {
|
10445 | const cloned = new Set(modelValue);
|
10446 | if (checked) {
|
10447 | cloned.add(elementValue);
|
10448 | }
|
10449 | else {
|
10450 | cloned.delete(elementValue);
|
10451 | }
|
10452 | assign(cloned);
|
10453 | }
|
10454 | else {
|
10455 | assign(getCheckboxValue(el, checked));
|
10456 | }
|
10457 | });
|
10458 | },
|
10459 |
|
10460 | mounted: setChecked,
|
10461 | beforeUpdate(el, binding, vnode) {
|
10462 | el._assign = getModelAssigner(vnode);
|
10463 | setChecked(el, binding, vnode);
|
10464 | }
|
10465 | };
|
10466 | function setChecked(el, { value, oldValue }, vnode) {
|
10467 | el._modelValue = value;
|
10468 | if (isArray(value)) {
|
10469 | el.checked = looseIndexOf(value, vnode.props.value) > -1;
|
10470 | }
|
10471 | else if (isSet(value)) {
|
10472 | el.checked = value.has(vnode.props.value);
|
10473 | }
|
10474 | else if (value !== oldValue) {
|
10475 | el.checked = looseEqual(value, getCheckboxValue(el, true));
|
10476 | }
|
10477 | }
|
10478 | const vModelRadio = {
|
10479 | created(el, { value }, vnode) {
|
10480 | el.checked = looseEqual(value, vnode.props.value);
|
10481 | el._assign = getModelAssigner(vnode);
|
10482 | addEventListener(el, 'change', () => {
|
10483 | el._assign(getValue(el));
|
10484 | });
|
10485 | },
|
10486 | beforeUpdate(el, { value, oldValue }, vnode) {
|
10487 | el._assign = getModelAssigner(vnode);
|
10488 | if (value !== oldValue) {
|
10489 | el.checked = looseEqual(value, vnode.props.value);
|
10490 | }
|
10491 | }
|
10492 | };
|
10493 | const vModelSelect = {
|
10494 |
|
10495 | deep: true,
|
10496 | created(el, { value, modifiers: { number } }, vnode) {
|
10497 | const isSetModel = isSet(value);
|
10498 | addEventListener(el, 'change', () => {
|
10499 | const selectedVal = Array.prototype.filter
|
10500 | .call(el.options, (o) => o.selected)
|
10501 | .map((o) => number ? toNumber(getValue(o)) : getValue(o));
|
10502 | el._assign(el.multiple
|
10503 | ? isSetModel
|
10504 | ? new Set(selectedVal)
|
10505 | : selectedVal
|
10506 | : selectedVal[0]);
|
10507 | });
|
10508 | el._assign = getModelAssigner(vnode);
|
10509 | },
|
10510 |
|
10511 |
|
10512 | mounted(el, { value }) {
|
10513 | setSelected(el, value);
|
10514 | },
|
10515 | beforeUpdate(el, _binding, vnode) {
|
10516 | el._assign = getModelAssigner(vnode);
|
10517 | },
|
10518 | updated(el, { value }) {
|
10519 | setSelected(el, value);
|
10520 | }
|
10521 | };
|
10522 | function setSelected(el, value) {
|
10523 | const isMultiple = el.multiple;
|
10524 | if (isMultiple && !isArray(value) && !isSet(value)) {
|
10525 | warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
|
10526 | `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
|
10527 | return;
|
10528 | }
|
10529 | for (let i = 0, l = el.options.length; i < l; i++) {
|
10530 | const option = el.options[i];
|
10531 | const optionValue = getValue(option);
|
10532 | if (isMultiple) {
|
10533 | if (isArray(value)) {
|
10534 | option.selected = looseIndexOf(value, optionValue) > -1;
|
10535 | }
|
10536 | else {
|
10537 | option.selected = value.has(optionValue);
|
10538 | }
|
10539 | }
|
10540 | else {
|
10541 | if (looseEqual(getValue(option), value)) {
|
10542 | if (el.selectedIndex !== i)
|
10543 | el.selectedIndex = i;
|
10544 | return;
|
10545 | }
|
10546 | }
|
10547 | }
|
10548 | if (!isMultiple && el.selectedIndex !== -1) {
|
10549 | el.selectedIndex = -1;
|
10550 | }
|
10551 | }
|
10552 |
|
10553 | function getValue(el) {
|
10554 | return '_value' in el ? el._value : el.value;
|
10555 | }
|
10556 |
|
10557 | function getCheckboxValue(el, checked) {
|
10558 | const key = checked ? '_trueValue' : '_falseValue';
|
10559 | return key in el ? el[key] : checked;
|
10560 | }
|
10561 | const vModelDynamic = {
|
10562 | created(el, binding, vnode) {
|
10563 | callModelHook(el, binding, vnode, null, 'created');
|
10564 | },
|
10565 | mounted(el, binding, vnode) {
|
10566 | callModelHook(el, binding, vnode, null, 'mounted');
|
10567 | },
|
10568 | beforeUpdate(el, binding, vnode, prevVNode) {
|
10569 | callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
|
10570 | },
|
10571 | updated(el, binding, vnode, prevVNode) {
|
10572 | callModelHook(el, binding, vnode, prevVNode, 'updated');
|
10573 | }
|
10574 | };
|
10575 | function callModelHook(el, binding, vnode, prevVNode, hook) {
|
10576 | let modelToUse;
|
10577 | switch (el.tagName) {
|
10578 | case 'SELECT':
|
10579 | modelToUse = vModelSelect;
|
10580 | break;
|
10581 | case 'TEXTAREA':
|
10582 | modelToUse = vModelText;
|
10583 | break;
|
10584 | default:
|
10585 | switch (vnode.props && vnode.props.type) {
|
10586 | case 'checkbox':
|
10587 | modelToUse = vModelCheckbox;
|
10588 | break;
|
10589 | case 'radio':
|
10590 | modelToUse = vModelRadio;
|
10591 | break;
|
10592 | default:
|
10593 | modelToUse = vModelText;
|
10594 | }
|
10595 | }
|
10596 | const fn = modelToUse[hook];
|
10597 | fn && fn(el, binding, vnode, prevVNode);
|
10598 | }
|
10599 |
|
10600 | const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
|
10601 | const modifierGuards = {
|
10602 | stop: e => e.stopPropagation(),
|
10603 | prevent: e => e.preventDefault(),
|
10604 | self: e => e.target !== e.currentTarget,
|
10605 | ctrl: e => !e.ctrlKey,
|
10606 | shift: e => !e.shiftKey,
|
10607 | alt: e => !e.altKey,
|
10608 | meta: e => !e.metaKey,
|
10609 | left: e => 'button' in e && e.button !== 0,
|
10610 | middle: e => 'button' in e && e.button !== 1,
|
10611 | right: e => 'button' in e && e.button !== 2,
|
10612 | exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
|
10613 | };
|
10614 | |
10615 |
|
10616 |
|
10617 | const withModifiers = (fn, modifiers) => {
|
10618 | return (event, ...args) => {
|
10619 | for (let i = 0; i < modifiers.length; i++) {
|
10620 | const guard = modifierGuards[modifiers[i]];
|
10621 | if (guard && guard(event, modifiers))
|
10622 | return;
|
10623 | }
|
10624 | return fn(event, ...args);
|
10625 | };
|
10626 | };
|
10627 |
|
10628 |
|
10629 | const keyNames = {
|
10630 | esc: 'escape',
|
10631 | space: ' ',
|
10632 | up: 'arrow-up',
|
10633 | left: 'arrow-left',
|
10634 | right: 'arrow-right',
|
10635 | down: 'arrow-down',
|
10636 | delete: 'backspace'
|
10637 | };
|
10638 | |
10639 |
|
10640 |
|
10641 | const withKeys = (fn, modifiers) => {
|
10642 | return (event) => {
|
10643 | if (!('key' in event)) {
|
10644 | return;
|
10645 | }
|
10646 | const eventKey = hyphenate(event.key);
|
10647 | if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
|
10648 | return fn(event);
|
10649 | }
|
10650 | };
|
10651 | };
|
10652 |
|
10653 | const vShow = {
|
10654 | beforeMount(el, { value }, { transition }) {
|
10655 | el._vod = el.style.display === 'none' ? '' : el.style.display;
|
10656 | if (transition && value) {
|
10657 | transition.beforeEnter(el);
|
10658 | }
|
10659 | else {
|
10660 | setDisplay(el, value);
|
10661 | }
|
10662 | },
|
10663 | mounted(el, { value }, { transition }) {
|
10664 | if (transition && value) {
|
10665 | transition.enter(el);
|
10666 | }
|
10667 | },
|
10668 | updated(el, { value, oldValue }, { transition }) {
|
10669 | if (!value === !oldValue)
|
10670 | return;
|
10671 | if (transition) {
|
10672 | if (value) {
|
10673 | transition.beforeEnter(el);
|
10674 | setDisplay(el, true);
|
10675 | transition.enter(el);
|
10676 | }
|
10677 | else {
|
10678 | transition.leave(el, () => {
|
10679 | setDisplay(el, false);
|
10680 | });
|
10681 | }
|
10682 | }
|
10683 | else {
|
10684 | setDisplay(el, value);
|
10685 | }
|
10686 | },
|
10687 | beforeUnmount(el, { value }) {
|
10688 | setDisplay(el, value);
|
10689 | }
|
10690 | };
|
10691 | function setDisplay(el, value) {
|
10692 | el.style.display = value ? el._vod : 'none';
|
10693 | }
|
10694 |
|
10695 | const rendererOptions = extend({ patchProp }, nodeOps);
|
10696 |
|
10697 |
|
10698 | let renderer;
|
10699 | let enabledHydration = false;
|
10700 | function ensureRenderer() {
|
10701 | return (renderer ||
|
10702 | (renderer = createRenderer(rendererOptions)));
|
10703 | }
|
10704 | function ensureHydrationRenderer() {
|
10705 | renderer = enabledHydration
|
10706 | ? renderer
|
10707 | : createHydrationRenderer(rendererOptions);
|
10708 | enabledHydration = true;
|
10709 | return renderer;
|
10710 | }
|
10711 |
|
10712 | const render = ((...args) => {
|
10713 | ensureRenderer().render(...args);
|
10714 | });
|
10715 | const hydrate = ((...args) => {
|
10716 | ensureHydrationRenderer().hydrate(...args);
|
10717 | });
|
10718 | const createApp = ((...args) => {
|
10719 | const app = ensureRenderer().createApp(...args);
|
10720 | {
|
10721 | injectNativeTagCheck(app);
|
10722 | injectCompilerOptionsCheck(app);
|
10723 | }
|
10724 | const { mount } = app;
|
10725 | app.mount = (containerOrSelector) => {
|
10726 | const container = normalizeContainer(containerOrSelector);
|
10727 | if (!container)
|
10728 | return;
|
10729 | const component = app._component;
|
10730 | if (!isFunction(component) && !component.render && !component.template) {
|
10731 |
|
10732 |
|
10733 |
|
10734 |
|
10735 | component.template = container.innerHTML;
|
10736 | }
|
10737 |
|
10738 | container.innerHTML = '';
|
10739 | const proxy = mount(container, false, container instanceof SVGElement);
|
10740 | if (container instanceof Element) {
|
10741 | container.removeAttribute('v-cloak');
|
10742 | container.setAttribute('data-v-app', '');
|
10743 | }
|
10744 | return proxy;
|
10745 | };
|
10746 | return app;
|
10747 | });
|
10748 | const createSSRApp = ((...args) => {
|
10749 | const app = ensureHydrationRenderer().createApp(...args);
|
10750 | {
|
10751 | injectNativeTagCheck(app);
|
10752 | injectCompilerOptionsCheck(app);
|
10753 | }
|
10754 | const { mount } = app;
|
10755 | app.mount = (containerOrSelector) => {
|
10756 | const container = normalizeContainer(containerOrSelector);
|
10757 | if (container) {
|
10758 | return mount(container, true, container instanceof SVGElement);
|
10759 | }
|
10760 | };
|
10761 | return app;
|
10762 | });
|
10763 | function injectNativeTagCheck(app) {
|
10764 |
|
10765 |
|
10766 | Object.defineProperty(app.config, 'isNativeTag', {
|
10767 | value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
|
10768 | writable: false
|
10769 | });
|
10770 | }
|
10771 |
|
10772 | function injectCompilerOptionsCheck(app) {
|
10773 | if (isRuntimeOnly()) {
|
10774 | const isCustomElement = app.config.isCustomElement;
|
10775 | Object.defineProperty(app.config, 'isCustomElement', {
|
10776 | get() {
|
10777 | return isCustomElement;
|
10778 | },
|
10779 | set() {
|
10780 | warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
|
10781 | `\`compilerOptions.isCustomElement\` instead.`);
|
10782 | }
|
10783 | });
|
10784 | const compilerOptions = app.config.compilerOptions;
|
10785 | const msg = `The \`compilerOptions\` config option is only respected when using ` +
|
10786 | `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
|
10787 | `Since you are using the runtime-only build, \`compilerOptions\` ` +
|
10788 | `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
|
10789 | `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
|
10790 | `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
|
10791 | `- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
|
10792 | Object.defineProperty(app.config, 'compilerOptions', {
|
10793 | get() {
|
10794 | warn$1(msg);
|
10795 | return compilerOptions;
|
10796 | },
|
10797 | set() {
|
10798 | warn$1(msg);
|
10799 | }
|
10800 | });
|
10801 | }
|
10802 | }
|
10803 | function normalizeContainer(container) {
|
10804 | if (isString(container)) {
|
10805 | const res = document.querySelector(container);
|
10806 | if (!res) {
|
10807 | warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
|
10808 | }
|
10809 | return res;
|
10810 | }
|
10811 | if (window.ShadowRoot &&
|
10812 | container instanceof window.ShadowRoot &&
|
10813 | container.mode === 'closed') {
|
10814 | warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
|
10815 | }
|
10816 | return container;
|
10817 | }
|
10818 |
|
10819 | function initDev() {
|
10820 | {
|
10821 | {
|
10822 | console.info(`You are running a development build of Vue.\n` +
|
10823 | `Make sure to use the production build (*.prod.js) when deploying for production.`);
|
10824 | }
|
10825 | initCustomFormatter();
|
10826 | }
|
10827 | }
|
10828 |
|
10829 |
|
10830 | {
|
10831 | initDev();
|
10832 | }
|
10833 | const compile$1 = () => {
|
10834 | {
|
10835 | warn$1(`Runtime compilation is not supported in this build of Vue.` +
|
10836 | (` Use "vue.global.js" instead.`
|
10837 | ) );
|
10838 | }
|
10839 | };
|
10840 |
|
10841 | exports.BaseTransition = BaseTransition;
|
10842 | exports.Comment = Comment;
|
10843 | exports.EffectScope = EffectScope;
|
10844 | exports.Fragment = Fragment;
|
10845 | exports.KeepAlive = KeepAlive;
|
10846 | exports.ReactiveEffect = ReactiveEffect;
|
10847 | exports.Static = Static;
|
10848 | exports.Suspense = Suspense;
|
10849 | exports.Teleport = Teleport;
|
10850 | exports.Text = Text;
|
10851 | exports.Transition = Transition;
|
10852 | exports.TransitionGroup = TransitionGroup;
|
10853 | exports.VueElement = VueElement;
|
10854 | exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
|
10855 | exports.callWithErrorHandling = callWithErrorHandling;
|
10856 | exports.camelize = camelize;
|
10857 | exports.capitalize = capitalize;
|
10858 | exports.cloneVNode = cloneVNode;
|
10859 | exports.compatUtils = compatUtils;
|
10860 | exports.compile = compile$1;
|
10861 | exports.computed = computed;
|
10862 | exports.createApp = createApp;
|
10863 | exports.createBlock = createBlock;
|
10864 | exports.createCommentVNode = createCommentVNode;
|
10865 | exports.createElementBlock = createElementBlock;
|
10866 | exports.createElementVNode = createBaseVNode;
|
10867 | exports.createHydrationRenderer = createHydrationRenderer;
|
10868 | exports.createRenderer = createRenderer;
|
10869 | exports.createSSRApp = createSSRApp;
|
10870 | exports.createSlots = createSlots;
|
10871 | exports.createStaticVNode = createStaticVNode;
|
10872 | exports.createTextVNode = createTextVNode;
|
10873 | exports.createVNode = createVNode;
|
10874 | exports.customRef = customRef;
|
10875 | exports.defineAsyncComponent = defineAsyncComponent;
|
10876 | exports.defineComponent = defineComponent;
|
10877 | exports.defineCustomElement = defineCustomElement;
|
10878 | exports.defineEmits = defineEmits;
|
10879 | exports.defineExpose = defineExpose;
|
10880 | exports.defineProps = defineProps;
|
10881 | exports.defineSSRCustomElement = defineSSRCustomElement;
|
10882 | exports.effect = effect;
|
10883 | exports.effectScope = effectScope;
|
10884 | exports.getCurrentInstance = getCurrentInstance;
|
10885 | exports.getCurrentScope = getCurrentScope;
|
10886 | exports.getTransitionRawChildren = getTransitionRawChildren;
|
10887 | exports.guardReactiveProps = guardReactiveProps;
|
10888 | exports.h = h;
|
10889 | exports.handleError = handleError;
|
10890 | exports.hydrate = hydrate;
|
10891 | exports.initCustomFormatter = initCustomFormatter;
|
10892 | exports.inject = inject;
|
10893 | exports.isMemoSame = isMemoSame;
|
10894 | exports.isProxy = isProxy;
|
10895 | exports.isReactive = isReactive;
|
10896 | exports.isReadonly = isReadonly;
|
10897 | exports.isRef = isRef;
|
10898 | exports.isRuntimeOnly = isRuntimeOnly;
|
10899 | exports.isVNode = isVNode;
|
10900 | exports.markRaw = markRaw;
|
10901 | exports.mergeDefaults = mergeDefaults;
|
10902 | exports.mergeProps = mergeProps;
|
10903 | exports.nextTick = nextTick;
|
10904 | exports.normalizeClass = normalizeClass;
|
10905 | exports.normalizeProps = normalizeProps;
|
10906 | exports.normalizeStyle = normalizeStyle;
|
10907 | exports.onActivated = onActivated;
|
10908 | exports.onBeforeMount = onBeforeMount;
|
10909 | exports.onBeforeUnmount = onBeforeUnmount;
|
10910 | exports.onBeforeUpdate = onBeforeUpdate;
|
10911 | exports.onDeactivated = onDeactivated;
|
10912 | exports.onErrorCaptured = onErrorCaptured;
|
10913 | exports.onMounted = onMounted;
|
10914 | exports.onRenderTracked = onRenderTracked;
|
10915 | exports.onRenderTriggered = onRenderTriggered;
|
10916 | exports.onScopeDispose = onScopeDispose;
|
10917 | exports.onServerPrefetch = onServerPrefetch;
|
10918 | exports.onUnmounted = onUnmounted;
|
10919 | exports.onUpdated = onUpdated;
|
10920 | exports.openBlock = openBlock;
|
10921 | exports.popScopeId = popScopeId;
|
10922 | exports.provide = provide;
|
10923 | exports.proxyRefs = proxyRefs;
|
10924 | exports.pushScopeId = pushScopeId;
|
10925 | exports.queuePostFlushCb = queuePostFlushCb;
|
10926 | exports.reactive = reactive;
|
10927 | exports.readonly = readonly;
|
10928 | exports.ref = ref;
|
10929 | exports.registerRuntimeCompiler = registerRuntimeCompiler;
|
10930 | exports.render = render;
|
10931 | exports.renderList = renderList;
|
10932 | exports.renderSlot = renderSlot;
|
10933 | exports.resolveComponent = resolveComponent;
|
10934 | exports.resolveDirective = resolveDirective;
|
10935 | exports.resolveDynamicComponent = resolveDynamicComponent;
|
10936 | exports.resolveFilter = resolveFilter;
|
10937 | exports.resolveTransitionHooks = resolveTransitionHooks;
|
10938 | exports.setBlockTracking = setBlockTracking;
|
10939 | exports.setDevtoolsHook = setDevtoolsHook;
|
10940 | exports.setTransitionHooks = setTransitionHooks;
|
10941 | exports.shallowReactive = shallowReactive;
|
10942 | exports.shallowReadonly = shallowReadonly;
|
10943 | exports.shallowRef = shallowRef;
|
10944 | exports.ssrContextKey = ssrContextKey;
|
10945 | exports.ssrUtils = ssrUtils;
|
10946 | exports.stop = stop;
|
10947 | exports.toDisplayString = toDisplayString;
|
10948 | exports.toHandlerKey = toHandlerKey;
|
10949 | exports.toHandlers = toHandlers;
|
10950 | exports.toRaw = toRaw;
|
10951 | exports.toRef = toRef;
|
10952 | exports.toRefs = toRefs;
|
10953 | exports.transformVNodeArgs = transformVNodeArgs;
|
10954 | exports.triggerRef = triggerRef;
|
10955 | exports.unref = unref;
|
10956 | exports.useAttrs = useAttrs;
|
10957 | exports.useCssModule = useCssModule;
|
10958 | exports.useCssVars = useCssVars;
|
10959 | exports.useSSRContext = useSSRContext;
|
10960 | exports.useSlots = useSlots;
|
10961 | exports.useTransitionState = useTransitionState;
|
10962 | exports.vModelCheckbox = vModelCheckbox;
|
10963 | exports.vModelDynamic = vModelDynamic;
|
10964 | exports.vModelRadio = vModelRadio;
|
10965 | exports.vModelSelect = vModelSelect;
|
10966 | exports.vModelText = vModelText;
|
10967 | exports.vShow = vShow;
|
10968 | exports.version = version;
|
10969 | exports.warn = warn$1;
|
10970 | exports.watch = watch;
|
10971 | exports.watchEffect = watchEffect;
|
10972 | exports.watchPostEffect = watchPostEffect;
|
10973 | exports.watchSyncEffect = watchSyncEffect;
|
10974 | exports.withAsyncContext = withAsyncContext;
|
10975 | exports.withCtx = withCtx;
|
10976 | exports.withDefaults = withDefaults;
|
10977 | exports.withDirectives = withDirectives;
|
10978 | exports.withKeys = withKeys;
|
10979 | exports.withMemo = withMemo;
|
10980 | exports.withModifiers = withModifiers;
|
10981 | exports.withScopeId = withScopeId;
|
10982 |
|
10983 | Object.defineProperty(exports, '__esModule', { value: true });
|
10984 |
|
10985 | return exports;
|
10986 |
|
10987 | }({}));
|