1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | function makeMap(str, expectsLowerCase) {
|
9 | const map = Object.create(null);
|
10 | const list = str.split(',');
|
11 | for (let i = 0; i < list.length; i++) {
|
12 | map[list[i]] = true;
|
13 | }
|
14 | return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
|
15 | }
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | const PatchFlagNames = {
|
21 | [1 ]: `TEXT`,
|
22 | [2 ]: `CLASS`,
|
23 | [4 ]: `STYLE`,
|
24 | [8 ]: `PROPS`,
|
25 | [16 ]: `FULL_PROPS`,
|
26 | [32 ]: `HYDRATE_EVENTS`,
|
27 | [64 ]: `STABLE_FRAGMENT`,
|
28 | [128 ]: `KEYED_FRAGMENT`,
|
29 | [256 ]: `UNKEYED_FRAGMENT`,
|
30 | [512 ]: `NEED_PATCH`,
|
31 | [1024 ]: `DYNAMIC_SLOTS`,
|
32 | [2048 ]: `DEV_ROOT_FRAGMENT`,
|
33 | [-1 ]: `HOISTED`,
|
34 | [-2 ]: `BAIL`
|
35 | };
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | const slotFlagsText = {
|
41 | [1 ]: 'STABLE',
|
42 | [2 ]: 'DYNAMIC',
|
43 | [3 ]: 'FORWARDED'
|
44 | };
|
45 |
|
46 | const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
|
47 | 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
|
48 | 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
|
49 | const isGloballyWhitelisted = makeMap(GLOBALS_WHITE_LISTED);
|
50 |
|
51 | const range = 2;
|
52 | function generateCodeFrame(source, start = 0, end = source.length) {
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | let lines = source.split(/(\r?\n)/);
|
58 |
|
59 | const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
60 | lines = lines.filter((_, idx) => idx % 2 === 0);
|
61 | let count = 0;
|
62 | const res = [];
|
63 | for (let i = 0; i < lines.length; i++) {
|
64 | count +=
|
65 | lines[i].length +
|
66 | ((newlineSequences[i] && newlineSequences[i].length) || 0);
|
67 | if (count >= start) {
|
68 | for (let j = i - range; j <= i + range || end > count; j++) {
|
69 | if (j < 0 || j >= lines.length)
|
70 | continue;
|
71 | const line = j + 1;
|
72 | res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
73 | const lineLength = lines[j].length;
|
74 | const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0;
|
75 | if (j === i) {
|
76 |
|
77 | const pad = start - (count - (lineLength + newLineSeqLength));
|
78 | const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
79 | res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
|
80 | }
|
81 | else if (j > i) {
|
82 | if (end > count) {
|
83 | const length = Math.max(Math.min(end - count, lineLength), 1);
|
84 | res.push(` | ` + '^'.repeat(length));
|
85 | }
|
86 | count += lineLength + newLineSeqLength;
|
87 | }
|
88 | }
|
89 | break;
|
90 | }
|
91 | }
|
92 | return res.join('\n');
|
93 | }
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
107 | const isSpecialBooleanAttr = makeMap(specialBooleanAttrs);
|
108 |
|
109 |
|
110 |
|
111 |
|
112 | function includeBooleanAttr(value) {
|
113 | return !!value || value === '';
|
114 | }
|
115 |
|
116 | function normalizeStyle(value) {
|
117 | if (isArray(value)) {
|
118 | const res = {};
|
119 | for (let i = 0; i < value.length; i++) {
|
120 | const item = value[i];
|
121 | const normalized = isString(item)
|
122 | ? parseStringStyle(item)
|
123 | : normalizeStyle(item);
|
124 | if (normalized) {
|
125 | for (const key in normalized) {
|
126 | res[key] = normalized[key];
|
127 | }
|
128 | }
|
129 | }
|
130 | return res;
|
131 | }
|
132 | else if (isString(value)) {
|
133 | return value;
|
134 | }
|
135 | else if (isObject(value)) {
|
136 | return value;
|
137 | }
|
138 | }
|
139 | const listDelimiterRE = /;(?![^(]*\))/g;
|
140 | const propertyDelimiterRE = /:(.+)/;
|
141 | function parseStringStyle(cssText) {
|
142 | const ret = {};
|
143 | cssText.split(listDelimiterRE).forEach(item => {
|
144 | if (item) {
|
145 | const tmp = item.split(propertyDelimiterRE);
|
146 | tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
147 | }
|
148 | });
|
149 | return ret;
|
150 | }
|
151 | function normalizeClass(value) {
|
152 | let res = '';
|
153 | if (isString(value)) {
|
154 | res = value;
|
155 | }
|
156 | else if (isArray(value)) {
|
157 | for (let i = 0; i < value.length; i++) {
|
158 | const normalized = normalizeClass(value[i]);
|
159 | if (normalized) {
|
160 | res += normalized + ' ';
|
161 | }
|
162 | }
|
163 | }
|
164 | else if (isObject(value)) {
|
165 | for (const name in value) {
|
166 | if (value[name]) {
|
167 | res += name + ' ';
|
168 | }
|
169 | }
|
170 | }
|
171 | return res.trim();
|
172 | }
|
173 | function normalizeProps(props) {
|
174 | if (!props)
|
175 | return null;
|
176 | let { class: klass, style } = props;
|
177 | if (klass && !isString(klass)) {
|
178 | props.class = normalizeClass(klass);
|
179 | }
|
180 | if (style) {
|
181 | props.style = normalizeStyle(style);
|
182 | }
|
183 | return props;
|
184 | }
|
185 |
|
186 |
|
187 |
|
188 | const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
|
189 | 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
|
190 | 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
|
191 | 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
|
192 | 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
|
193 | 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
|
194 | 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
|
195 | 'option,output,progress,select,textarea,details,dialog,menu,' +
|
196 | 'summary,template,blockquote,iframe,tfoot';
|
197 |
|
198 | const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
|
199 | 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
|
200 | 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
|
201 | 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
|
202 | 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
|
203 | 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
|
204 | 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
|
205 | 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
|
206 | 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
|
207 | 'text,textPath,title,tspan,unknown,use,view';
|
208 | const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';
|
209 | const isHTMLTag = makeMap(HTML_TAGS);
|
210 | const isSVGTag = makeMap(SVG_TAGS);
|
211 | const isVoidTag = makeMap(VOID_TAGS);
|
212 |
|
213 | function looseCompareArrays(a, b) {
|
214 | if (a.length !== b.length)
|
215 | return false;
|
216 | let equal = true;
|
217 | for (let i = 0; equal && i < a.length; i++) {
|
218 | equal = looseEqual(a[i], b[i]);
|
219 | }
|
220 | return equal;
|
221 | }
|
222 | function looseEqual(a, b) {
|
223 | if (a === b)
|
224 | return true;
|
225 | let aValidType = isDate(a);
|
226 | let bValidType = isDate(b);
|
227 | if (aValidType || bValidType) {
|
228 | return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
229 | }
|
230 | aValidType = isArray(a);
|
231 | bValidType = isArray(b);
|
232 | if (aValidType || bValidType) {
|
233 | return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
234 | }
|
235 | aValidType = isObject(a);
|
236 | bValidType = isObject(b);
|
237 | if (aValidType || bValidType) {
|
238 |
|
239 | if (!aValidType || !bValidType) {
|
240 | return false;
|
241 | }
|
242 | const aKeysCount = Object.keys(a).length;
|
243 | const bKeysCount = Object.keys(b).length;
|
244 | if (aKeysCount !== bKeysCount) {
|
245 | return false;
|
246 | }
|
247 | for (const key in a) {
|
248 | const aHasKey = a.hasOwnProperty(key);
|
249 | const bHasKey = b.hasOwnProperty(key);
|
250 | if ((aHasKey && !bHasKey) ||
|
251 | (!aHasKey && bHasKey) ||
|
252 | !looseEqual(a[key], b[key])) {
|
253 | return false;
|
254 | }
|
255 | }
|
256 | }
|
257 | return String(a) === String(b);
|
258 | }
|
259 | function looseIndexOf(arr, val) {
|
260 | return arr.findIndex(item => looseEqual(item, val));
|
261 | }
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 | const toDisplayString = (val) => {
|
268 | return val == null
|
269 | ? ''
|
270 | : isArray(val) ||
|
271 | (isObject(val) &&
|
272 | (val.toString === objectToString || !isFunction(val.toString)))
|
273 | ? JSON.stringify(val, replacer, 2)
|
274 | : String(val);
|
275 | };
|
276 | const replacer = (_key, val) => {
|
277 |
|
278 | if (val && val.__v_isRef) {
|
279 | return replacer(_key, val.value);
|
280 | }
|
281 | else if (isMap(val)) {
|
282 | return {
|
283 | [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
|
284 | entries[`${key} =>`] = val;
|
285 | return entries;
|
286 | }, {})
|
287 | };
|
288 | }
|
289 | else if (isSet(val)) {
|
290 | return {
|
291 | [`Set(${val.size})`]: [...val.values()]
|
292 | };
|
293 | }
|
294 | else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
|
295 | return String(val);
|
296 | }
|
297 | return val;
|
298 | };
|
299 |
|
300 | const EMPTY_OBJ = Object.freeze({})
|
301 | ;
|
302 | const EMPTY_ARR = Object.freeze([]) ;
|
303 | const NOOP = () => { };
|
304 |
|
305 |
|
306 |
|
307 | const NO = () => false;
|
308 | const onRE = /^on[^a-z]/;
|
309 | const isOn = (key) => onRE.test(key);
|
310 | const isModelListener = (key) => key.startsWith('onUpdate:');
|
311 | const extend = Object.assign;
|
312 | const remove = (arr, el) => {
|
313 | const i = arr.indexOf(el);
|
314 | if (i > -1) {
|
315 | arr.splice(i, 1);
|
316 | }
|
317 | };
|
318 | const hasOwnProperty = Object.prototype.hasOwnProperty;
|
319 | const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
320 | const isArray = Array.isArray;
|
321 | const isMap = (val) => toTypeString(val) === '[object Map]';
|
322 | const isSet = (val) => toTypeString(val) === '[object Set]';
|
323 | const isDate = (val) => val instanceof Date;
|
324 | const isFunction = (val) => typeof val === 'function';
|
325 | const isString = (val) => typeof val === 'string';
|
326 | const isSymbol = (val) => typeof val === 'symbol';
|
327 | const isObject = (val) => val !== null && typeof val === 'object';
|
328 | const isPromise = (val) => {
|
329 | return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
330 | };
|
331 | const objectToString = Object.prototype.toString;
|
332 | const toTypeString = (value) => objectToString.call(value);
|
333 | const toRawType = (value) => {
|
334 |
|
335 | return toTypeString(value).slice(8, -1);
|
336 | };
|
337 | const isPlainObject = (val) => toTypeString(val) === '[object Object]';
|
338 | const isIntegerKey = (key) => isString(key) &&
|
339 | key !== 'NaN' &&
|
340 | key[0] !== '-' &&
|
341 | '' + parseInt(key, 10) === key;
|
342 | const isReservedProp = makeMap(
|
343 |
|
344 | ',key,ref,' +
|
345 | 'onVnodeBeforeMount,onVnodeMounted,' +
|
346 | 'onVnodeBeforeUpdate,onVnodeUpdated,' +
|
347 | 'onVnodeBeforeUnmount,onVnodeUnmounted');
|
348 | const cacheStringFunction = (fn) => {
|
349 | const cache = Object.create(null);
|
350 | return ((str) => {
|
351 | const hit = cache[str];
|
352 | return hit || (cache[str] = fn(str));
|
353 | });
|
354 | };
|
355 | const camelizeRE = /-(\w)/g;
|
356 |
|
357 |
|
358 |
|
359 | const camelize = cacheStringFunction((str) => {
|
360 | return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
|
361 | });
|
362 | const hyphenateRE = /\B([A-Z])/g;
|
363 |
|
364 |
|
365 |
|
366 | const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
|
367 |
|
368 |
|
369 |
|
370 | const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
|
371 |
|
372 |
|
373 |
|
374 | const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
|
375 |
|
376 | const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
377 | const invokeArrayFns = (fns, arg) => {
|
378 | for (let i = 0; i < fns.length; i++) {
|
379 | fns[i](arg);
|
380 | }
|
381 | };
|
382 | const def = (obj, key, value) => {
|
383 | Object.defineProperty(obj, key, {
|
384 | configurable: true,
|
385 | enumerable: false,
|
386 | value
|
387 | });
|
388 | };
|
389 | const toNumber = (val) => {
|
390 | const n = parseFloat(val);
|
391 | return isNaN(n) ? val : n;
|
392 | };
|
393 | let _globalThis;
|
394 | const getGlobalThis = () => {
|
395 | return (_globalThis ||
|
396 | (_globalThis =
|
397 | typeof globalThis !== 'undefined'
|
398 | ? globalThis
|
399 | : typeof self !== 'undefined'
|
400 | ? self
|
401 | : typeof window !== 'undefined'
|
402 | ? window
|
403 | : typeof global !== 'undefined'
|
404 | ? global
|
405 | : {}));
|
406 | };
|
407 |
|
408 | function warn(msg, ...args) {
|
409 | console.warn(`[Vue warn] ${msg}`, ...args);
|
410 | }
|
411 |
|
412 | let activeEffectScope;
|
413 | const effectScopeStack = [];
|
414 | class EffectScope {
|
415 | constructor(detached = false) {
|
416 | this.active = true;
|
417 | this.effects = [];
|
418 | this.cleanups = [];
|
419 | if (!detached && activeEffectScope) {
|
420 | this.parent = activeEffectScope;
|
421 | this.index =
|
422 | (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
423 | }
|
424 | }
|
425 | run(fn) {
|
426 | if (this.active) {
|
427 | try {
|
428 | this.on();
|
429 | return fn();
|
430 | }
|
431 | finally {
|
432 | this.off();
|
433 | }
|
434 | }
|
435 | else {
|
436 | warn(`cannot run an inactive effect scope.`);
|
437 | }
|
438 | }
|
439 | on() {
|
440 | if (this.active) {
|
441 | effectScopeStack.push(this);
|
442 | activeEffectScope = this;
|
443 | }
|
444 | }
|
445 | off() {
|
446 | if (this.active) {
|
447 | effectScopeStack.pop();
|
448 | activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
|
449 | }
|
450 | }
|
451 | stop(fromParent) {
|
452 | if (this.active) {
|
453 | this.effects.forEach(e => e.stop());
|
454 | this.cleanups.forEach(cleanup => cleanup());
|
455 | if (this.scopes) {
|
456 | this.scopes.forEach(e => e.stop(true));
|
457 | }
|
458 |
|
459 | if (this.parent && !fromParent) {
|
460 |
|
461 | const last = this.parent.scopes.pop();
|
462 | if (last && last !== this) {
|
463 | this.parent.scopes[this.index] = last;
|
464 | last.index = this.index;
|
465 | }
|
466 | }
|
467 | this.active = false;
|
468 | }
|
469 | }
|
470 | }
|
471 | function effectScope(detached) {
|
472 | return new EffectScope(detached);
|
473 | }
|
474 | function recordEffectScope(effect, scope) {
|
475 | scope = scope || activeEffectScope;
|
476 | if (scope && scope.active) {
|
477 | scope.effects.push(effect);
|
478 | }
|
479 | }
|
480 | function getCurrentScope() {
|
481 | return activeEffectScope;
|
482 | }
|
483 | function onScopeDispose(fn) {
|
484 | if (activeEffectScope) {
|
485 | activeEffectScope.cleanups.push(fn);
|
486 | }
|
487 | else {
|
488 | warn(`onScopeDispose() is called when there is no active effect scope` +
|
489 | ` to be associated with.`);
|
490 | }
|
491 | }
|
492 |
|
493 | const createDep = (effects) => {
|
494 | const dep = new Set(effects);
|
495 | dep.w = 0;
|
496 | dep.n = 0;
|
497 | return dep;
|
498 | };
|
499 | const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
|
500 | const newTracked = (dep) => (dep.n & trackOpBit) > 0;
|
501 | const initDepMarkers = ({ deps }) => {
|
502 | if (deps.length) {
|
503 | for (let i = 0; i < deps.length; i++) {
|
504 | deps[i].w |= trackOpBit;
|
505 | }
|
506 | }
|
507 | };
|
508 | const finalizeDepMarkers = (effect) => {
|
509 | const { deps } = effect;
|
510 | if (deps.length) {
|
511 | let ptr = 0;
|
512 | for (let i = 0; i < deps.length; i++) {
|
513 | const dep = deps[i];
|
514 | if (wasTracked(dep) && !newTracked(dep)) {
|
515 | dep.delete(effect);
|
516 | }
|
517 | else {
|
518 | deps[ptr++] = dep;
|
519 | }
|
520 |
|
521 | dep.w &= ~trackOpBit;
|
522 | dep.n &= ~trackOpBit;
|
523 | }
|
524 | deps.length = ptr;
|
525 | }
|
526 | };
|
527 |
|
528 | const targetMap = new WeakMap();
|
529 |
|
530 | let effectTrackDepth = 0;
|
531 | let trackOpBit = 1;
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 | const maxMarkerBits = 30;
|
538 | const effectStack = [];
|
539 | let activeEffect;
|
540 | const ITERATE_KEY = Symbol('iterate' );
|
541 | const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
|
542 | class ReactiveEffect {
|
543 | constructor(fn, scheduler = null, scope) {
|
544 | this.fn = fn;
|
545 | this.scheduler = scheduler;
|
546 | this.active = true;
|
547 | this.deps = [];
|
548 | recordEffectScope(this, scope);
|
549 | }
|
550 | run() {
|
551 | if (!this.active) {
|
552 | return this.fn();
|
553 | }
|
554 | if (!effectStack.includes(this)) {
|
555 | try {
|
556 | effectStack.push((activeEffect = this));
|
557 | enableTracking();
|
558 | trackOpBit = 1 << ++effectTrackDepth;
|
559 | if (effectTrackDepth <= maxMarkerBits) {
|
560 | initDepMarkers(this);
|
561 | }
|
562 | else {
|
563 | cleanupEffect(this);
|
564 | }
|
565 | return this.fn();
|
566 | }
|
567 | finally {
|
568 | if (effectTrackDepth <= maxMarkerBits) {
|
569 | finalizeDepMarkers(this);
|
570 | }
|
571 | trackOpBit = 1 << --effectTrackDepth;
|
572 | resetTracking();
|
573 | effectStack.pop();
|
574 | const n = effectStack.length;
|
575 | activeEffect = n > 0 ? effectStack[n - 1] : undefined;
|
576 | }
|
577 | }
|
578 | }
|
579 | stop() {
|
580 | if (this.active) {
|
581 | cleanupEffect(this);
|
582 | if (this.onStop) {
|
583 | this.onStop();
|
584 | }
|
585 | this.active = false;
|
586 | }
|
587 | }
|
588 | }
|
589 | function cleanupEffect(effect) {
|
590 | const { deps } = effect;
|
591 | if (deps.length) {
|
592 | for (let i = 0; i < deps.length; i++) {
|
593 | deps[i].delete(effect);
|
594 | }
|
595 | deps.length = 0;
|
596 | }
|
597 | }
|
598 | function effect(fn, options) {
|
599 | if (fn.effect) {
|
600 | fn = fn.effect.fn;
|
601 | }
|
602 | const _effect = new ReactiveEffect(fn);
|
603 | if (options) {
|
604 | extend(_effect, options);
|
605 | if (options.scope)
|
606 | recordEffectScope(_effect, options.scope);
|
607 | }
|
608 | if (!options || !options.lazy) {
|
609 | _effect.run();
|
610 | }
|
611 | const runner = _effect.run.bind(_effect);
|
612 | runner.effect = _effect;
|
613 | return runner;
|
614 | }
|
615 | function stop(runner) {
|
616 | runner.effect.stop();
|
617 | }
|
618 | let shouldTrack = true;
|
619 | const trackStack = [];
|
620 | function pauseTracking() {
|
621 | trackStack.push(shouldTrack);
|
622 | shouldTrack = false;
|
623 | }
|
624 | function enableTracking() {
|
625 | trackStack.push(shouldTrack);
|
626 | shouldTrack = true;
|
627 | }
|
628 | function resetTracking() {
|
629 | const last = trackStack.pop();
|
630 | shouldTrack = last === undefined ? true : last;
|
631 | }
|
632 | function track(target, type, key) {
|
633 | if (!isTracking()) {
|
634 | return;
|
635 | }
|
636 | let depsMap = targetMap.get(target);
|
637 | if (!depsMap) {
|
638 | targetMap.set(target, (depsMap = new Map()));
|
639 | }
|
640 | let dep = depsMap.get(key);
|
641 | if (!dep) {
|
642 | depsMap.set(key, (dep = createDep()));
|
643 | }
|
644 | const eventInfo = { effect: activeEffect, target, type, key }
|
645 | ;
|
646 | trackEffects(dep, eventInfo);
|
647 | }
|
648 | function isTracking() {
|
649 | return shouldTrack && activeEffect !== undefined;
|
650 | }
|
651 | function trackEffects(dep, debuggerEventExtraInfo) {
|
652 | let shouldTrack = false;
|
653 | if (effectTrackDepth <= maxMarkerBits) {
|
654 | if (!newTracked(dep)) {
|
655 | dep.n |= trackOpBit;
|
656 | shouldTrack = !wasTracked(dep);
|
657 | }
|
658 | }
|
659 | else {
|
660 |
|
661 | shouldTrack = !dep.has(activeEffect);
|
662 | }
|
663 | if (shouldTrack) {
|
664 | dep.add(activeEffect);
|
665 | activeEffect.deps.push(dep);
|
666 | if (activeEffect.onTrack) {
|
667 | activeEffect.onTrack(Object.assign({
|
668 | effect: activeEffect
|
669 | }, debuggerEventExtraInfo));
|
670 | }
|
671 | }
|
672 | }
|
673 | function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
674 | const depsMap = targetMap.get(target);
|
675 | if (!depsMap) {
|
676 |
|
677 | return;
|
678 | }
|
679 | let deps = [];
|
680 | if (type === "clear" ) {
|
681 |
|
682 |
|
683 | deps = [...depsMap.values()];
|
684 | }
|
685 | else if (key === 'length' && isArray(target)) {
|
686 | depsMap.forEach((dep, key) => {
|
687 | if (key === 'length' || key >= newValue) {
|
688 | deps.push(dep);
|
689 | }
|
690 | });
|
691 | }
|
692 | else {
|
693 |
|
694 | if (key !== void 0) {
|
695 | deps.push(depsMap.get(key));
|
696 | }
|
697 |
|
698 | switch (type) {
|
699 | case "add" :
|
700 | if (!isArray(target)) {
|
701 | deps.push(depsMap.get(ITERATE_KEY));
|
702 | if (isMap(target)) {
|
703 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
704 | }
|
705 | }
|
706 | else if (isIntegerKey(key)) {
|
707 |
|
708 | deps.push(depsMap.get('length'));
|
709 | }
|
710 | break;
|
711 | case "delete" :
|
712 | if (!isArray(target)) {
|
713 | deps.push(depsMap.get(ITERATE_KEY));
|
714 | if (isMap(target)) {
|
715 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
716 | }
|
717 | }
|
718 | break;
|
719 | case "set" :
|
720 | if (isMap(target)) {
|
721 | deps.push(depsMap.get(ITERATE_KEY));
|
722 | }
|
723 | break;
|
724 | }
|
725 | }
|
726 | const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
|
727 | ;
|
728 | if (deps.length === 1) {
|
729 | if (deps[0]) {
|
730 | {
|
731 | triggerEffects(deps[0], eventInfo);
|
732 | }
|
733 | }
|
734 | }
|
735 | else {
|
736 | const effects = [];
|
737 | for (const dep of deps) {
|
738 | if (dep) {
|
739 | effects.push(...dep);
|
740 | }
|
741 | }
|
742 | {
|
743 | triggerEffects(createDep(effects), eventInfo);
|
744 | }
|
745 | }
|
746 | }
|
747 | function triggerEffects(dep, debuggerEventExtraInfo) {
|
748 |
|
749 | for (const effect of isArray(dep) ? dep : [...dep]) {
|
750 | if (effect !== activeEffect || effect.allowRecurse) {
|
751 | if (effect.onTrigger) {
|
752 | effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
|
753 | }
|
754 | if (effect.scheduler) {
|
755 | effect.scheduler();
|
756 | }
|
757 | else {
|
758 | effect.run();
|
759 | }
|
760 | }
|
761 | }
|
762 | }
|
763 |
|
764 | const isNonTrackableKeys = makeMap(`__proto__,__v_isRef,__isVue`);
|
765 | const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
|
766 | .map(key => Symbol[key])
|
767 | .filter(isSymbol));
|
768 | const get = /*#__PURE__*/ createGetter();
|
769 | const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
770 | const readonlyGet = /*#__PURE__*/ createGetter(true);
|
771 | const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
772 | const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
|
773 | function createArrayInstrumentations() {
|
774 | const instrumentations = {};
|
775 | ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
|
776 | instrumentations[key] = function (...args) {
|
777 | const arr = toRaw(this);
|
778 | for (let i = 0, l = this.length; i < l; i++) {
|
779 | track(arr, "get" , i + '');
|
780 | }
|
781 |
|
782 | const res = arr[key](...args);
|
783 | if (res === -1 || res === false) {
|
784 |
|
785 | return arr[key](...args.map(toRaw));
|
786 | }
|
787 | else {
|
788 | return res;
|
789 | }
|
790 | };
|
791 | });
|
792 | ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
|
793 | instrumentations[key] = function (...args) {
|
794 | pauseTracking();
|
795 | const res = toRaw(this)[key].apply(this, args);
|
796 | resetTracking();
|
797 | return res;
|
798 | };
|
799 | });
|
800 | return instrumentations;
|
801 | }
|
802 | function createGetter(isReadonly = false, shallow = false) {
|
803 | return function get(target, key, receiver) {
|
804 | if (key === "__v_isReactive" ) {
|
805 | return !isReadonly;
|
806 | }
|
807 | else if (key === "__v_isReadonly" ) {
|
808 | return isReadonly;
|
809 | }
|
810 | else if (key === "__v_raw" &&
|
811 | receiver ===
|
812 | (isReadonly
|
813 | ? shallow
|
814 | ? shallowReadonlyMap
|
815 | : readonlyMap
|
816 | : shallow
|
817 | ? shallowReactiveMap
|
818 | : reactiveMap).get(target)) {
|
819 | return target;
|
820 | }
|
821 | const targetIsArray = isArray(target);
|
822 | if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
823 | return Reflect.get(arrayInstrumentations, key, receiver);
|
824 | }
|
825 | const res = Reflect.get(target, key, receiver);
|
826 | if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
827 | return res;
|
828 | }
|
829 | if (!isReadonly) {
|
830 | track(target, "get" , key);
|
831 | }
|
832 | if (shallow) {
|
833 | return res;
|
834 | }
|
835 | if (isRef(res)) {
|
836 |
|
837 | const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
|
838 | return shouldUnwrap ? res.value : res;
|
839 | }
|
840 | if (isObject(res)) {
|
841 |
|
842 |
|
843 |
|
844 | return isReadonly ? readonly(res) : reactive(res);
|
845 | }
|
846 | return res;
|
847 | };
|
848 | }
|
849 | const set = /*#__PURE__*/ createSetter();
|
850 | const shallowSet = /*#__PURE__*/ createSetter(true);
|
851 | function createSetter(shallow = false) {
|
852 | return function set(target, key, value, receiver) {
|
853 | let oldValue = target[key];
|
854 | if (!shallow) {
|
855 | value = toRaw(value);
|
856 | oldValue = toRaw(oldValue);
|
857 | if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
858 | oldValue.value = value;
|
859 | return true;
|
860 | }
|
861 | }
|
862 | const hadKey = isArray(target) && isIntegerKey(key)
|
863 | ? Number(key) < target.length
|
864 | : hasOwn(target, key);
|
865 | const result = Reflect.set(target, key, value, receiver);
|
866 |
|
867 | if (target === toRaw(receiver)) {
|
868 | if (!hadKey) {
|
869 | trigger(target, "add" , key, value);
|
870 | }
|
871 | else if (hasChanged(value, oldValue)) {
|
872 | trigger(target, "set" , key, value, oldValue);
|
873 | }
|
874 | }
|
875 | return result;
|
876 | };
|
877 | }
|
878 | function deleteProperty(target, key) {
|
879 | const hadKey = hasOwn(target, key);
|
880 | const oldValue = target[key];
|
881 | const result = Reflect.deleteProperty(target, key);
|
882 | if (result && hadKey) {
|
883 | trigger(target, "delete" , key, undefined, oldValue);
|
884 | }
|
885 | return result;
|
886 | }
|
887 | function has(target, key) {
|
888 | const result = Reflect.has(target, key);
|
889 | if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
890 | track(target, "has" , key);
|
891 | }
|
892 | return result;
|
893 | }
|
894 | function ownKeys(target) {
|
895 | track(target, "iterate" , isArray(target) ? 'length' : ITERATE_KEY);
|
896 | return Reflect.ownKeys(target);
|
897 | }
|
898 | const mutableHandlers = {
|
899 | get,
|
900 | set,
|
901 | deleteProperty,
|
902 | has,
|
903 | ownKeys
|
904 | };
|
905 | const readonlyHandlers = {
|
906 | get: readonlyGet,
|
907 | set(target, key) {
|
908 | {
|
909 | console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
|
910 | }
|
911 | return true;
|
912 | },
|
913 | deleteProperty(target, key) {
|
914 | {
|
915 | console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
|
916 | }
|
917 | return true;
|
918 | }
|
919 | };
|
920 | const shallowReactiveHandlers = extend({}, mutableHandlers, {
|
921 | get: shallowGet,
|
922 | set: shallowSet
|
923 | });
|
924 | // Props handlers are special in the sense that it should not unwrap top-level
|
925 | // refs (in order to allow refs to be explicitly passed down), but should
|
926 | // retain the reactivity of the normal readonly object.
|
927 | const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
|
928 | get: shallowReadonlyGet
|
929 | });
|
930 |
|
931 | const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
932 | const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
933 | const toShallow = (value) => value;
|
934 | const getProto = (v) => Reflect.getPrototypeOf(v);
|
935 | function get$1(target, key, isReadonly = false, isShallow = false) {
|
936 |
|
937 |
|
938 | target = target["__v_raw" ];
|
939 | const rawTarget = toRaw(target);
|
940 | const rawKey = toRaw(key);
|
941 | if (key !== rawKey) {
|
942 | !isReadonly && track(rawTarget, "get" , key);
|
943 | }
|
944 | !isReadonly && track(rawTarget, "get" , rawKey);
|
945 | const { has } = getProto(rawTarget);
|
946 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
947 | if (has.call(rawTarget, key)) {
|
948 | return wrap(target.get(key));
|
949 | }
|
950 | else if (has.call(rawTarget, rawKey)) {
|
951 | return wrap(target.get(rawKey));
|
952 | }
|
953 | else if (target !== rawTarget) {
|
954 |
|
955 |
|
956 | target.get(key);
|
957 | }
|
958 | }
|
959 | function has$1(key, isReadonly = false) {
|
960 | const target = this["__v_raw" ];
|
961 | const rawTarget = toRaw(target);
|
962 | const rawKey = toRaw(key);
|
963 | if (key !== rawKey) {
|
964 | !isReadonly && track(rawTarget, "has" , key);
|
965 | }
|
966 | !isReadonly && track(rawTarget, "has" , rawKey);
|
967 | return key === rawKey
|
968 | ? target.has(key)
|
969 | : target.has(key) || target.has(rawKey);
|
970 | }
|
971 | function size(target, isReadonly = false) {
|
972 | target = target["__v_raw" ];
|
973 | !isReadonly && track(toRaw(target), "iterate" , ITERATE_KEY);
|
974 | return Reflect.get(target, 'size', target);
|
975 | }
|
976 | function add(value) {
|
977 | value = toRaw(value);
|
978 | const target = toRaw(this);
|
979 | const proto = getProto(target);
|
980 | const hadKey = proto.has.call(target, value);
|
981 | if (!hadKey) {
|
982 | target.add(value);
|
983 | trigger(target, "add" , value, value);
|
984 | }
|
985 | return this;
|
986 | }
|
987 | function set$1(key, value) {
|
988 | value = toRaw(value);
|
989 | const target = toRaw(this);
|
990 | const { has, get } = getProto(target);
|
991 | let hadKey = has.call(target, key);
|
992 | if (!hadKey) {
|
993 | key = toRaw(key);
|
994 | hadKey = has.call(target, key);
|
995 | }
|
996 | else {
|
997 | checkIdentityKeys(target, has, key);
|
998 | }
|
999 | const oldValue = get.call(target, key);
|
1000 | target.set(key, value);
|
1001 | if (!hadKey) {
|
1002 | trigger(target, "add" , key, value);
|
1003 | }
|
1004 | else if (hasChanged(value, oldValue)) {
|
1005 | trigger(target, "set" , key, value, oldValue);
|
1006 | }
|
1007 | return this;
|
1008 | }
|
1009 | function deleteEntry(key) {
|
1010 | const target = toRaw(this);
|
1011 | const { has, get } = getProto(target);
|
1012 | let hadKey = has.call(target, key);
|
1013 | if (!hadKey) {
|
1014 | key = toRaw(key);
|
1015 | hadKey = has.call(target, key);
|
1016 | }
|
1017 | else {
|
1018 | checkIdentityKeys(target, has, key);
|
1019 | }
|
1020 | const oldValue = get ? get.call(target, key) : undefined;
|
1021 | // forward the operation before queueing reactions
|
1022 | const result = target.delete(key);
|
1023 | if (hadKey) {
|
1024 | trigger(target, "delete" , key, undefined, oldValue);
|
1025 | }
|
1026 | return result;
|
1027 | }
|
1028 | function clear() {
|
1029 | const target = toRaw(this);
|
1030 | const hadItems = target.size !== 0;
|
1031 | const oldTarget = isMap(target)
|
1032 | ? new Map(target)
|
1033 | : new Set(target)
|
1034 | ;
|
1035 |
|
1036 | const result = target.clear();
|
1037 | if (hadItems) {
|
1038 | trigger(target, "clear" , undefined, undefined, oldTarget);
|
1039 | }
|
1040 | return result;
|
1041 | }
|
1042 | function createForEach(isReadonly, isShallow) {
|
1043 | return function forEach(callback, thisArg) {
|
1044 | const observed = this;
|
1045 | const target = observed["__v_raw" ];
|
1046 | const rawTarget = toRaw(target);
|
1047 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
1048 | !isReadonly && track(rawTarget, "iterate" , ITERATE_KEY);
|
1049 | return target.forEach((value, key) => {
|
1050 |
|
1051 |
|
1052 |
|
1053 | return callback.call(thisArg, wrap(value), wrap(key), observed);
|
1054 | });
|
1055 | };
|
1056 | }
|
1057 | function createIterableMethod(method, isReadonly, isShallow) {
|
1058 | return function (...args) {
|
1059 | const target = this["__v_raw" ];
|
1060 | const rawTarget = toRaw(target);
|
1061 | const targetIsMap = isMap(rawTarget);
|
1062 | const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
|
1063 | const isKeyOnly = method === 'keys' && targetIsMap;
|
1064 | const innerIterator = target[method](...args);
|
1065 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
1066 | !isReadonly &&
|
1067 | track(rawTarget, "iterate" , isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
|
1068 |
|
1069 |
|
1070 | return {
|
1071 |
|
1072 | next() {
|
1073 | const { value, done } = innerIterator.next();
|
1074 | return done
|
1075 | ? { value, done }
|
1076 | : {
|
1077 | value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
1078 | done
|
1079 | };
|
1080 | },
|
1081 |
|
1082 | [Symbol.iterator]() {
|
1083 | return this;
|
1084 | }
|
1085 | };
|
1086 | };
|
1087 | }
|
1088 | function createReadonlyMethod(type) {
|
1089 | return function (...args) {
|
1090 | {
|
1091 | const key = args[0] ? `on key "${args[0]}" ` : ``;
|
1092 | console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
|
1093 | }
|
1094 | return type === "delete" ? false : this;
|
1095 | };
|
1096 | }
|
1097 | function createInstrumentations() {
|
1098 | const mutableInstrumentations = {
|
1099 | get(key) {
|
1100 | return get$1(this, key);
|
1101 | },
|
1102 | get size() {
|
1103 | return size(this);
|
1104 | },
|
1105 | has: has$1,
|
1106 | add,
|
1107 | set: set$1,
|
1108 | delete: deleteEntry,
|
1109 | clear,
|
1110 | forEach: createForEach(false, false)
|
1111 | };
|
1112 | const shallowInstrumentations = {
|
1113 | get(key) {
|
1114 | return get$1(this, key, false, true);
|
1115 | },
|
1116 | get size() {
|
1117 | return size(this);
|
1118 | },
|
1119 | has: has$1,
|
1120 | add,
|
1121 | set: set$1,
|
1122 | delete: deleteEntry,
|
1123 | clear,
|
1124 | forEach: createForEach(false, true)
|
1125 | };
|
1126 | const readonlyInstrumentations = {
|
1127 | get(key) {
|
1128 | return get$1(this, key, true);
|
1129 | },
|
1130 | get size() {
|
1131 | return size(this, true);
|
1132 | },
|
1133 | has(key) {
|
1134 | return has$1.call(this, key, true);
|
1135 | },
|
1136 | add: createReadonlyMethod("add" ),
|
1137 | set: createReadonlyMethod("set" /* SET */),
|
1138 | delete: createReadonlyMethod("delete" /* DELETE */),
|
1139 | clear: createReadonlyMethod("clear" /* CLEAR */),
|
1140 | forEach: createForEach(true, false)
|
1141 | };
|
1142 | const shallowReadonlyInstrumentations = {
|
1143 | get(key) {
|
1144 | return get$1(this, key, true, true);
|
1145 | },
|
1146 | get size() {
|
1147 | return size(this, true);
|
1148 | },
|
1149 | has(key) {
|
1150 | return has$1.call(this, key, true);
|
1151 | },
|
1152 | add: createReadonlyMethod("add" ),
|
1153 | set: createReadonlyMethod("set" /* SET */),
|
1154 | delete: createReadonlyMethod("delete" /* DELETE */),
|
1155 | clear: createReadonlyMethod("clear" /* CLEAR */),
|
1156 | forEach: createForEach(true, true)
|
1157 | };
|
1158 | const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
|
1159 | iteratorMethods.forEach(method => {
|
1160 | mutableInstrumentations[method] = createIterableMethod(method, false, false);
|
1161 | readonlyInstrumentations[method] = createIterableMethod(method, true, false);
|
1162 | shallowInstrumentations[method] = createIterableMethod(method, false, true);
|
1163 | shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
|
1164 | });
|
1165 | return [
|
1166 | mutableInstrumentations,
|
1167 | readonlyInstrumentations,
|
1168 | shallowInstrumentations,
|
1169 | shallowReadonlyInstrumentations
|
1170 | ];
|
1171 | }
|
1172 | const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = createInstrumentations();
|
1173 | function createInstrumentationGetter(isReadonly, shallow) {
|
1174 | const instrumentations = shallow
|
1175 | ? isReadonly
|
1176 | ? shallowReadonlyInstrumentations
|
1177 | : shallowInstrumentations
|
1178 | : isReadonly
|
1179 | ? readonlyInstrumentations
|
1180 | : mutableInstrumentations;
|
1181 | return (target, key, receiver) => {
|
1182 | if (key === "__v_isReactive" ) {
|
1183 | return !isReadonly;
|
1184 | }
|
1185 | else if (key === "__v_isReadonly" ) {
|
1186 | return isReadonly;
|
1187 | }
|
1188 | else if (key === "__v_raw" ) {
|
1189 | return target;
|
1190 | }
|
1191 | return Reflect.get(hasOwn(instrumentations, key) && key in target
|
1192 | ? instrumentations
|
1193 | : target, key, receiver);
|
1194 | };
|
1195 | }
|
1196 | const mutableCollectionHandlers = {
|
1197 | get: /*#__PURE__*/ createInstrumentationGetter(false, false)
|
1198 | };
|
1199 | const shallowCollectionHandlers = {
|
1200 | get: /*#__PURE__*/ createInstrumentationGetter(false, true)
|
1201 | };
|
1202 | const readonlyCollectionHandlers = {
|
1203 | get: /*#__PURE__*/ createInstrumentationGetter(true, false)
|
1204 | };
|
1205 | const shallowReadonlyCollectionHandlers = {
|
1206 | get: /*#__PURE__*/ createInstrumentationGetter(true, true)
|
1207 | };
|
1208 | function checkIdentityKeys(target, has, key) {
|
1209 | const rawKey = toRaw(key);
|
1210 | if (rawKey !== key && has.call(target, rawKey)) {
|
1211 | const type = toRawType(target);
|
1212 | console.warn(`Reactive ${type} contains both the raw and reactive ` +
|
1213 | `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
|
1214 | `which can lead to inconsistencies. ` +
|
1215 | `Avoid differentiating between the raw and reactive versions ` +
|
1216 | `of an object and only use the reactive version if possible.`);
|
1217 | }
|
1218 | }
|
1219 |
|
1220 | const reactiveMap = new WeakMap();
|
1221 | const shallowReactiveMap = new WeakMap();
|
1222 | const readonlyMap = new WeakMap();
|
1223 | const shallowReadonlyMap = new WeakMap();
|
1224 | function targetTypeMap(rawType) {
|
1225 | switch (rawType) {
|
1226 | case 'Object':
|
1227 | case 'Array':
|
1228 | return 1 ;
|
1229 | case 'Map':
|
1230 | case 'Set':
|
1231 | case 'WeakMap':
|
1232 | case 'WeakSet':
|
1233 | return 2 ;
|
1234 | default:
|
1235 | return 0 ;
|
1236 | }
|
1237 | }
|
1238 | function getTargetType(value) {
|
1239 | return value["__v_skip" ] || !Object.isExtensible(value)
|
1240 | ? 0
|
1241 | : targetTypeMap(toRawType(value));
|
1242 | }
|
1243 | function reactive(target) {
|
1244 |
|
1245 | if (target && target["__v_isReadonly" ]) {
|
1246 | return target;
|
1247 | }
|
1248 | return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
1249 | }
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 | function shallowReactive(target) {
|
1256 | return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
|
1257 | }
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 | function readonly(target) {
|
1263 | return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
1264 | }
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 | function shallowReadonly(target) {
|
1272 | return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
1273 | }
|
1274 | function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
|
1275 | if (!isObject(target)) {
|
1276 | {
|
1277 | console.warn(`value cannot be made reactive: ${String(target)}`);
|
1278 | }
|
1279 | return target;
|
1280 | }
|
1281 |
|
1282 |
|
1283 | if (target["__v_raw" ] &&
|
1284 | !(isReadonly && target["__v_isReactive" ])) {
|
1285 | return target;
|
1286 | }
|
1287 |
|
1288 | const existingProxy = proxyMap.get(target);
|
1289 | if (existingProxy) {
|
1290 | return existingProxy;
|
1291 | }
|
1292 |
|
1293 | const targetType = getTargetType(target);
|
1294 | if (targetType === 0 ) {
|
1295 | return target;
|
1296 | }
|
1297 | const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
1298 | proxyMap.set(target, proxy);
|
1299 | return proxy;
|
1300 | }
|
1301 | function isReactive(value) {
|
1302 | if (isReadonly(value)) {
|
1303 | return isReactive(value["__v_raw" ]);
|
1304 | }
|
1305 | return !!(value && value["__v_isReactive" ]);
|
1306 | }
|
1307 | function isReadonly(value) {
|
1308 | return !!(value && value["__v_isReadonly" ]);
|
1309 | }
|
1310 | function isProxy(value) {
|
1311 | return isReactive(value) || isReadonly(value);
|
1312 | }
|
1313 | function toRaw(observed) {
|
1314 | const raw = observed && observed["__v_raw" ];
|
1315 | return raw ? toRaw(raw) : observed;
|
1316 | }
|
1317 | function markRaw(value) {
|
1318 | def(value, "__v_skip" , true);
|
1319 | return value;
|
1320 | }
|
1321 |
|
1322 | function trackRefValue(ref) {
|
1323 | if (isTracking()) {
|
1324 | ref = toRaw(ref);
|
1325 | if (!ref.dep) {
|
1326 | ref.dep = createDep();
|
1327 | }
|
1328 | {
|
1329 | trackEffects(ref.dep, {
|
1330 | target: ref,
|
1331 | type: "get" ,
|
1332 | key: 'value'
|
1333 | });
|
1334 | }
|
1335 | }
|
1336 | }
|
1337 | function triggerRefValue(ref, newVal) {
|
1338 | ref = toRaw(ref);
|
1339 | if (ref.dep) {
|
1340 | {
|
1341 | triggerEffects(ref.dep, {
|
1342 | target: ref,
|
1343 | type: "set" ,
|
1344 | key: 'value',
|
1345 | newValue: newVal
|
1346 | });
|
1347 | }
|
1348 | }
|
1349 | }
|
1350 | const convert = (val) => isObject(val) ? reactive(val) : val;
|
1351 | function isRef(r) {
|
1352 | return Boolean(r && r.__v_isRef === true);
|
1353 | }
|
1354 | function ref(value) {
|
1355 | return createRef(value, false);
|
1356 | }
|
1357 | function shallowRef(value) {
|
1358 | return createRef(value, true);
|
1359 | }
|
1360 | class RefImpl {
|
1361 | constructor(value, _shallow) {
|
1362 | this._shallow = _shallow;
|
1363 | this.dep = undefined;
|
1364 | this.__v_isRef = true;
|
1365 | this._rawValue = _shallow ? value : toRaw(value);
|
1366 | this._value = _shallow ? value : convert(value);
|
1367 | }
|
1368 | get value() {
|
1369 | trackRefValue(this);
|
1370 | return this._value;
|
1371 | }
|
1372 | set value(newVal) {
|
1373 | newVal = this._shallow ? newVal : toRaw(newVal);
|
1374 | if (hasChanged(newVal, this._rawValue)) {
|
1375 | this._rawValue = newVal;
|
1376 | this._value = this._shallow ? newVal : convert(newVal);
|
1377 | triggerRefValue(this, newVal);
|
1378 | }
|
1379 | }
|
1380 | }
|
1381 | function createRef(rawValue, shallow) {
|
1382 | if (isRef(rawValue)) {
|
1383 | return rawValue;
|
1384 | }
|
1385 | return new RefImpl(rawValue, shallow);
|
1386 | }
|
1387 | function triggerRef(ref) {
|
1388 | triggerRefValue(ref, ref.value );
|
1389 | }
|
1390 | function unref(ref) {
|
1391 | return isRef(ref) ? ref.value : ref;
|
1392 | }
|
1393 | const shallowUnwrapHandlers = {
|
1394 | get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
1395 | set: (target, key, value, receiver) => {
|
1396 | const oldValue = target[key];
|
1397 | if (isRef(oldValue) && !isRef(value)) {
|
1398 | oldValue.value = value;
|
1399 | return true;
|
1400 | }
|
1401 | else {
|
1402 | return Reflect.set(target, key, value, receiver);
|
1403 | }
|
1404 | }
|
1405 | };
|
1406 | function proxyRefs(objectWithRefs) {
|
1407 | return isReactive(objectWithRefs)
|
1408 | ? objectWithRefs
|
1409 | : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
1410 | }
|
1411 | class CustomRefImpl {
|
1412 | constructor(factory) {
|
1413 | this.dep = undefined;
|
1414 | this.__v_isRef = true;
|
1415 | const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
|
1416 | this._get = get;
|
1417 | this._set = set;
|
1418 | }
|
1419 | get value() {
|
1420 | return this._get();
|
1421 | }
|
1422 | set value(newVal) {
|
1423 | this._set(newVal);
|
1424 | }
|
1425 | }
|
1426 | function customRef(factory) {
|
1427 | return new CustomRefImpl(factory);
|
1428 | }
|
1429 | function toRefs(object) {
|
1430 | if (!isProxy(object)) {
|
1431 | console.warn(`toRefs() expects a reactive object but received a plain one.`);
|
1432 | }
|
1433 | const ret = isArray(object) ? new Array(object.length) : {};
|
1434 | for (const key in object) {
|
1435 | ret[key] = toRef(object, key);
|
1436 | }
|
1437 | return ret;
|
1438 | }
|
1439 | class ObjectRefImpl {
|
1440 | constructor(_object, _key) {
|
1441 | this._object = _object;
|
1442 | this._key = _key;
|
1443 | this.__v_isRef = true;
|
1444 | }
|
1445 | get value() {
|
1446 | return this._object[this._key];
|
1447 | }
|
1448 | set value(newVal) {
|
1449 | this._object[this._key] = newVal;
|
1450 | }
|
1451 | }
|
1452 | function toRef(object, key) {
|
1453 | const val = object[key];
|
1454 | return isRef(val) ? val : new ObjectRefImpl(object, key);
|
1455 | }
|
1456 |
|
1457 | class ComputedRefImpl {
|
1458 | constructor(getter, _setter, isReadonly) {
|
1459 | this._setter = _setter;
|
1460 | this.dep = undefined;
|
1461 | this._dirty = true;
|
1462 | this.__v_isRef = true;
|
1463 | this.effect = new ReactiveEffect(getter, () => {
|
1464 | if (!this._dirty) {
|
1465 | this._dirty = true;
|
1466 | triggerRefValue(this);
|
1467 | }
|
1468 | });
|
1469 | this["__v_isReadonly" ] = isReadonly;
|
1470 | }
|
1471 | get value() {
|
1472 |
|
1473 | const self = toRaw(this);
|
1474 | trackRefValue(self);
|
1475 | if (self._dirty) {
|
1476 | self._dirty = false;
|
1477 | self._value = self.effect.run();
|
1478 | }
|
1479 | return self._value;
|
1480 | }
|
1481 | set value(newValue) {
|
1482 | this._setter(newValue);
|
1483 | }
|
1484 | }
|
1485 | function computed(getterOrOptions, debugOptions) {
|
1486 | let getter;
|
1487 | let setter;
|
1488 | if (isFunction(getterOrOptions)) {
|
1489 | getter = getterOrOptions;
|
1490 | setter = () => {
|
1491 | console.warn('Write operation failed: computed value is readonly');
|
1492 | }
|
1493 | ;
|
1494 | }
|
1495 | else {
|
1496 | getter = getterOrOptions.get;
|
1497 | setter = getterOrOptions.set;
|
1498 | }
|
1499 | const cRef = new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
|
1500 | if (debugOptions) {
|
1501 | cRef.effect.onTrack = debugOptions.onTrack;
|
1502 | cRef.effect.onTrigger = debugOptions.onTrigger;
|
1503 | }
|
1504 | return cRef;
|
1505 | }
|
1506 |
|
1507 |
|
1508 | let isHmrUpdating = false;
|
1509 | const hmrDirtyComponents = new Set();
|
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 | {
|
1516 | const globalObject = typeof global !== 'undefined'
|
1517 | ? global
|
1518 | : typeof self !== 'undefined'
|
1519 | ? self
|
1520 | : typeof window !== 'undefined'
|
1521 | ? window
|
1522 | : {};
|
1523 | globalObject.__VUE_HMR_RUNTIME__ = {
|
1524 | createRecord: tryWrap(createRecord),
|
1525 | rerender: tryWrap(rerender),
|
1526 | reload: tryWrap(reload)
|
1527 | };
|
1528 | }
|
1529 | const map = new Map();
|
1530 | function registerHMR(instance) {
|
1531 | const id = instance.type.__hmrId;
|
1532 | let record = map.get(id);
|
1533 | if (!record) {
|
1534 | createRecord(id, instance.type);
|
1535 | record = map.get(id);
|
1536 | }
|
1537 | record.instances.add(instance);
|
1538 | }
|
1539 | function unregisterHMR(instance) {
|
1540 | map.get(instance.type.__hmrId).instances.delete(instance);
|
1541 | }
|
1542 | function createRecord(id, component) {
|
1543 | if (!component) {
|
1544 | warn$1(`HMR API usage is out of date.\n` +
|
1545 | `Please upgrade vue-loader/vite/rollup-plugin-vue or other relevant ` +
|
1546 | `dependency that handles Vue SFC compilation.`);
|
1547 | component = {};
|
1548 | }
|
1549 | if (map.has(id)) {
|
1550 | return false;
|
1551 | }
|
1552 | map.set(id, {
|
1553 | component: isClassComponent(component) ? component.__vccOpts : component,
|
1554 | instances: new Set()
|
1555 | });
|
1556 | return true;
|
1557 | }
|
1558 | function rerender(id, newRender) {
|
1559 | const record = map.get(id);
|
1560 | if (!record)
|
1561 | return;
|
1562 | if (newRender)
|
1563 | record.component.render = newRender;
|
1564 |
|
1565 |
|
1566 | Array.from(record.instances).forEach(instance => {
|
1567 | if (newRender) {
|
1568 | instance.render = newRender;
|
1569 | }
|
1570 | instance.renderCache = [];
|
1571 |
|
1572 | isHmrUpdating = true;
|
1573 | instance.update();
|
1574 | isHmrUpdating = false;
|
1575 | });
|
1576 | }
|
1577 | function reload(id, newComp) {
|
1578 | const record = map.get(id);
|
1579 | if (!record)
|
1580 | return;
|
1581 |
|
1582 |
|
1583 | const { component, instances } = record;
|
1584 | if (!hmrDirtyComponents.has(component)) {
|
1585 |
|
1586 | newComp = isClassComponent(newComp) ? newComp.__vccOpts : newComp;
|
1587 | extend(component, newComp);
|
1588 | for (const key in component) {
|
1589 | if (key !== '__file' && !(key in newComp)) {
|
1590 | delete component[key];
|
1591 | }
|
1592 | }
|
1593 |
|
1594 |
|
1595 | hmrDirtyComponents.add(component);
|
1596 |
|
1597 | queuePostFlushCb(() => {
|
1598 | hmrDirtyComponents.delete(component);
|
1599 | });
|
1600 | }
|
1601 | Array.from(instances).forEach(instance => {
|
1602 |
|
1603 | instance.appContext.optionsCache.delete(instance.type);
|
1604 | if (instance.ceReload) {
|
1605 |
|
1606 | hmrDirtyComponents.add(component);
|
1607 | instance.ceReload(newComp.styles);
|
1608 | hmrDirtyComponents.delete(component);
|
1609 | }
|
1610 | else if (instance.parent) {
|
1611 |
|
1612 |
|
1613 |
|
1614 | queueJob(instance.parent.update);
|
1615 |
|
1616 |
|
1617 | if (instance.parent.type.__asyncLoader &&
|
1618 | instance.parent.ceReload) {
|
1619 | instance.parent.ceReload(newComp.styles);
|
1620 | }
|
1621 | }
|
1622 | else if (instance.appContext.reload) {
|
1623 |
|
1624 | instance.appContext.reload();
|
1625 | }
|
1626 | else if (typeof window !== 'undefined') {
|
1627 |
|
1628 | window.location.reload();
|
1629 | }
|
1630 | else {
|
1631 | console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
|
1632 | }
|
1633 | });
|
1634 | }
|
1635 | function tryWrap(fn) {
|
1636 | return (id, arg) => {
|
1637 | try {
|
1638 | return fn(id, arg);
|
1639 | }
|
1640 | catch (e) {
|
1641 | console.error(e);
|
1642 | console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
|
1643 | `Full reload required.`);
|
1644 | }
|
1645 | };
|
1646 | }
|
1647 |
|
1648 | let devtools;
|
1649 | function setDevtoolsHook(hook) {
|
1650 | devtools = hook;
|
1651 | }
|
1652 | function devtoolsInitApp(app, version) {
|
1653 |
|
1654 | if (!devtools)
|
1655 | return;
|
1656 | devtools.emit("app:init" , app, version, {
|
1657 | Fragment,
|
1658 | Text,
|
1659 | Comment,
|
1660 | Static
|
1661 | });
|
1662 | }
|
1663 | function devtoolsUnmountApp(app) {
|
1664 | if (!devtools)
|
1665 | return;
|
1666 | devtools.emit("app:unmount" , app);
|
1667 | }
|
1668 | const devtoolsComponentAdded = createDevtoolsComponentHook("component:added" );
|
1669 | const devtoolsComponentUpdated =
|
1670 | createDevtoolsComponentHook("component:updated" );
|
1671 | const devtoolsComponentRemoved =
|
1672 | createDevtoolsComponentHook("component:removed" );
|
1673 | function createDevtoolsComponentHook(hook) {
|
1674 | return (component) => {
|
1675 | if (!devtools)
|
1676 | return;
|
1677 | devtools.emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
|
1678 | };
|
1679 | }
|
1680 | const devtoolsPerfStart = createDevtoolsPerformanceHook("perf:start" );
|
1681 | const devtoolsPerfEnd = createDevtoolsPerformanceHook("perf:end" );
|
1682 | function createDevtoolsPerformanceHook(hook) {
|
1683 | return (component, type, time) => {
|
1684 | if (!devtools)
|
1685 | return;
|
1686 | devtools.emit(hook, component.appContext.app, component.uid, component, type, time);
|
1687 | };
|
1688 | }
|
1689 | function devtoolsComponentEmit(component, event, params) {
|
1690 | if (!devtools)
|
1691 | return;
|
1692 | devtools.emit("component:emit" , component.appContext.app, component, event, params);
|
1693 | }
|
1694 |
|
1695 | const deprecationData = {
|
1696 | ["GLOBAL_MOUNT" ]: {
|
1697 | message: `The global app bootstrapping API has changed: vm.$mount() and the "el" ` +
|
1698 | `option have been removed. Use createApp(RootComponent).mount() instead.`,
|
1699 | link: `https://v3.vuejs.org/guide/migration/global-api.html#mounting-app-instance`
|
1700 | },
|
1701 | ["GLOBAL_MOUNT_CONTAINER" ]: {
|
1702 | message: `Vue detected directives on the mount container. ` +
|
1703 | `In Vue 3, the container is no longer considered part of the template ` +
|
1704 | `and will not be processed/replaced.`,
|
1705 | link: `https://v3.vuejs.org/guide/migration/mount-changes.html`
|
1706 | },
|
1707 | ["GLOBAL_EXTEND" ]: {
|
1708 | message: `Vue.extend() has been removed in Vue 3. ` +
|
1709 | `Use defineComponent() instead.`,
|
1710 | link: `https://v3.vuejs.org/api/global-api.html#definecomponent`
|
1711 | },
|
1712 | ["GLOBAL_PROTOTYPE" ]: {
|
1713 | message: `Vue.prototype is no longer available in Vue 3. ` +
|
1714 | `Use app.config.globalProperties instead.`,
|
1715 | link: `https://v3.vuejs.org/guide/migration/global-api.html#vue-prototype-replaced-by-config-globalproperties`
|
1716 | },
|
1717 | ["GLOBAL_SET" ]: {
|
1718 | message: `Vue.set() has been removed as it is no longer needed in Vue 3. ` +
|
1719 | `Simply use native JavaScript mutations.`
|
1720 | },
|
1721 | ["GLOBAL_DELETE" ]: {
|
1722 | message: `Vue.delete() has been removed as it is no longer needed in Vue 3. ` +
|
1723 | `Simply use native JavaScript mutations.`
|
1724 | },
|
1725 | ["GLOBAL_OBSERVABLE" ]: {
|
1726 | message: `Vue.observable() has been removed. ` +
|
1727 | `Use \`import { reactive } from "vue"\` from Composition API instead.`,
|
1728 | link: `https://v3.vuejs.org/api/basic-reactivity.html`
|
1729 | },
|
1730 | ["GLOBAL_PRIVATE_UTIL" ]: {
|
1731 | message: `Vue.util has been removed. Please refactor to avoid its usage ` +
|
1732 | `since it was an internal API even in Vue 2.`
|
1733 | },
|
1734 | ["CONFIG_SILENT" ]: {
|
1735 | message: `config.silent has been removed because it is not good practice to ` +
|
1736 | `intentionally suppress warnings. You can use your browser console's ` +
|
1737 | `filter features to focus on relevant messages.`
|
1738 | },
|
1739 | ["CONFIG_DEVTOOLS" ]: {
|
1740 | message: `config.devtools has been removed. To enable devtools for ` +
|
1741 | `production, configure the __VUE_PROD_DEVTOOLS__ compile-time flag.`,
|
1742 | link: `https://github.com/vuejs/vue-next/tree/master/packages/vue#bundler-build-feature-flags`
|
1743 | },
|
1744 | ["CONFIG_KEY_CODES" ]: {
|
1745 | message: `config.keyCodes has been removed. ` +
|
1746 | `In Vue 3, you can directly use the kebab-case key names as v-on modifiers.`,
|
1747 | link: `https://v3.vuejs.org/guide/migration/keycode-modifiers.html`
|
1748 | },
|
1749 | ["CONFIG_PRODUCTION_TIP" ]: {
|
1750 | message: `config.productionTip has been removed.`,
|
1751 | link: `https://v3.vuejs.org/guide/migration/global-api.html#config-productiontip-removed`
|
1752 | },
|
1753 | ["CONFIG_IGNORED_ELEMENTS" ]: {
|
1754 | message: () => {
|
1755 | let msg = `config.ignoredElements has been removed.`;
|
1756 | if (isRuntimeOnly()) {
|
1757 | msg += ` Pass the "isCustomElement" option to @vue/compiler-dom instead.`;
|
1758 | }
|
1759 | else {
|
1760 | msg += ` Use config.isCustomElement instead.`;
|
1761 | }
|
1762 | return msg;
|
1763 | },
|
1764 | link: `https://v3.vuejs.org/guide/migration/global-api.html#config-ignoredelements-is-now-config-iscustomelement`
|
1765 | },
|
1766 | ["CONFIG_WHITESPACE" ]: {
|
1767 |
|
1768 |
|
1769 | message: `Vue 3 compiler's whitespace option will default to "condense" instead of ` +
|
1770 | `"preserve". To suppress this warning, provide an explicit value for ` +
|
1771 | `\`config.compilerOptions.whitespace\`.`
|
1772 | },
|
1773 | ["CONFIG_OPTION_MERGE_STRATS" ]: {
|
1774 | message: `config.optionMergeStrategies no longer exposes internal strategies. ` +
|
1775 | `Use custom merge functions instead.`
|
1776 | },
|
1777 | ["INSTANCE_SET" ]: {
|
1778 | message: `vm.$set() has been removed as it is no longer needed in Vue 3. ` +
|
1779 | `Simply use native JavaScript mutations.`
|
1780 | },
|
1781 | ["INSTANCE_DELETE" ]: {
|
1782 | message: `vm.$delete() has been removed as it is no longer needed in Vue 3. ` +
|
1783 | `Simply use native JavaScript mutations.`
|
1784 | },
|
1785 | ["INSTANCE_DESTROY" ]: {
|
1786 | message: `vm.$destroy() has been removed. Use app.unmount() instead.`,
|
1787 | link: `https://v3.vuejs.org/api/application-api.html#unmount`
|
1788 | },
|
1789 | ["INSTANCE_EVENT_EMITTER" ]: {
|
1790 | message: `vm.$on/$once/$off() have been removed. ` +
|
1791 | `Use an external event emitter library instead.`,
|
1792 | link: `https://v3.vuejs.org/guide/migration/events-api.html`
|
1793 | },
|
1794 | ["INSTANCE_EVENT_HOOKS" ]: {
|
1795 | message: event => `"${event}" lifecycle events are no longer supported. From templates, ` +
|
1796 | `use the "vnode" prefix instead of "hook:". For example, @${event} ` +
|
1797 | `should be changed to @vnode-${event.slice(5)}. ` +
|
1798 | `From JavaScript, use Composition API to dynamically register lifecycle ` +
|
1799 | `hooks.`,
|
1800 | link: `https://v3.vuejs.org/guide/migration/vnode-lifecycle-events.html`
|
1801 | },
|
1802 | ["INSTANCE_CHILDREN" ]: {
|
1803 | message: `vm.$children has been removed. Consider refactoring your logic ` +
|
1804 | `to avoid relying on direct access to child components.`,
|
1805 | link: `https://v3.vuejs.org/guide/migration/children.html`
|
1806 | },
|
1807 | ["INSTANCE_LISTENERS" ]: {
|
1808 | message: `vm.$listeners has been removed. In Vue 3, parent v-on listeners are ` +
|
1809 | `included in vm.$attrs and it is no longer necessary to separately use ` +
|
1810 | `v-on="$listeners" if you are already using v-bind="$attrs". ` +
|
1811 | `(Note: the Vue 3 behavior only applies if this compat config is disabled)`,
|
1812 | link: `https://v3.vuejs.org/guide/migration/listeners-removed.html`
|
1813 | },
|
1814 | ["INSTANCE_SCOPED_SLOTS" ]: {
|
1815 | message: `vm.$scopedSlots has been removed. Use vm.$slots instead.`,
|
1816 | link: `https://v3.vuejs.org/guide/migration/slots-unification.html`
|
1817 | },
|
1818 | ["INSTANCE_ATTRS_CLASS_STYLE" ]: {
|
1819 | message: componentName => `Component <${componentName || 'Anonymous'}> has \`inheritAttrs: false\` but is ` +
|
1820 | `relying on class/style fallthrough from parent. In Vue 3, class/style ` +
|
1821 | `are now included in $attrs and will no longer fallthrough when ` +
|
1822 | `inheritAttrs is false. If you are already using v-bind="$attrs" on ` +
|
1823 | `component root it should render the same end result. ` +
|
1824 | `If you are binding $attrs to a non-root element and expecting ` +
|
1825 | `class/style to fallthrough on root, you will need to now manually bind ` +
|
1826 | `them on root via :class="$attrs.class".`,
|
1827 | link: `https://v3.vuejs.org/guide/migration/attrs-includes-class-style.html`
|
1828 | },
|
1829 | ["OPTIONS_DATA_FN" ]: {
|
1830 | message: `The "data" option can no longer be a plain object. ` +
|
1831 | `Always use a function.`,
|
1832 | link: `https://v3.vuejs.org/guide/migration/data-option.html`
|
1833 | },
|
1834 | ["OPTIONS_DATA_MERGE" ]: {
|
1835 | message: (key) => `Detected conflicting key "${key}" when merging data option values. ` +
|
1836 | `In Vue 3, data keys are merged shallowly and will override one another.`,
|
1837 | link: `https://v3.vuejs.org/guide/migration/data-option.html#mixin-merge-behavior-change`
|
1838 | },
|
1839 | ["OPTIONS_BEFORE_DESTROY" ]: {
|
1840 | message: `\`beforeDestroy\` has been renamed to \`beforeUnmount\`.`
|
1841 | },
|
1842 | ["OPTIONS_DESTROYED" ]: {
|
1843 | message: `\`destroyed\` has been renamed to \`unmounted\`.`
|
1844 | },
|
1845 | ["WATCH_ARRAY" ]: {
|
1846 | message: `"watch" option or vm.$watch on an array value will no longer ` +
|
1847 | `trigger on array mutation unless the "deep" option is specified. ` +
|
1848 | `If current usage is intended, you can disable the compat behavior and ` +
|
1849 | `suppress this warning with:` +
|
1850 | `\n\n configureCompat({ ${"WATCH_ARRAY" /* WATCH_ARRAY */}: false })\n`,
|
1851 | link: `https://v3.vuejs.org/guide/migration/watch.html`
|
1852 | },
|
1853 | ["PROPS_DEFAULT_THIS" ]: {
|
1854 | message: (key) => `props default value function no longer has access to "this". The compat ` +
|
1855 | `build only offers access to this.$options.` +
|
1856 | `(found in prop "${key}")`,
|
1857 | link: `https://v3.vuejs.org/guide/migration/props-default-this.html`
|
1858 | },
|
1859 | ["CUSTOM_DIR" ]: {
|
1860 | message: (legacyHook, newHook) => `Custom directive hook "${legacyHook}" has been removed. ` +
|
1861 | `Use "${newHook}" instead.`,
|
1862 | link: `https://v3.vuejs.org/guide/migration/custom-directives.html`
|
1863 | },
|
1864 | ["V_FOR_REF" ]: {
|
1865 | message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
|
1866 | `Consider using function refs or refactor to avoid ref usage altogether.`,
|
1867 | link: `https://v3.vuejs.org/guide/migration/array-refs.html`
|
1868 | },
|
1869 | ["V_ON_KEYCODE_MODIFIER" ]: {
|
1870 | message: `Using keyCode as v-on modifier is no longer supported. ` +
|
1871 | `Use kebab-case key name modifiers instead.`,
|
1872 | link: `https://v3.vuejs.org/guide/migration/keycode-modifiers.html`
|
1873 | },
|
1874 | ["ATTR_FALSE_VALUE" ]: {
|
1875 | message: (name) => `Attribute "${name}" with v-bind value \`false\` will render ` +
|
1876 | `${name}="false" instead of removing it in Vue 3. To remove the attribute, ` +
|
1877 | `use \`null\` or \`undefined\` instead. If the usage is intended, ` +
|
1878 | `you can disable the compat behavior and suppress this warning with:` +
|
1879 | `\n\n configureCompat({ ${"ATTR_FALSE_VALUE" /* ATTR_FALSE_VALUE */}: false })\n`,
|
1880 | link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html`
|
1881 | },
|
1882 | ["ATTR_ENUMERATED_COERCION" ]: {
|
1883 | message: (name, value, coerced) => `Enumerated attribute "${name}" with v-bind value \`${value}\` will ` +
|
1884 | `${value === null ? `be removed` : `render the value as-is`} instead of coercing the value to "${coerced}" in Vue 3. ` +
|
1885 | `Always use explicit "true" or "false" values for enumerated attributes. ` +
|
1886 | `If the usage is intended, ` +
|
1887 | `you can disable the compat behavior and suppress this warning with:` +
|
1888 | `\n\n configureCompat({ ${"ATTR_ENUMERATED_COERCION" /* ATTR_ENUMERATED_COERCION */}: false })\n`,
|
1889 | link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html`
|
1890 | },
|
1891 | ["TRANSITION_CLASSES" ]: {
|
1892 | message: ``
|
1893 | },
|
1894 | ["TRANSITION_GROUP_ROOT" ]: {
|
1895 | message: `<TransitionGroup> no longer renders a root <span> element by ` +
|
1896 | `default if no "tag" prop is specified. If you do not rely on the span ` +
|
1897 | `for styling, you can disable the compat behavior and suppress this ` +
|
1898 | `warning with:` +
|
1899 | `\n\n configureCompat({ ${"TRANSITION_GROUP_ROOT" /* TRANSITION_GROUP_ROOT */}: false })\n`,
|
1900 | link: `https://v3.vuejs.org/guide/migration/transition-group.html`
|
1901 | },
|
1902 | ["COMPONENT_ASYNC" ]: {
|
1903 | message: (comp) => {
|
1904 | const name = getComponentName(comp);
|
1905 | return (`Async component${name ? ` <${name}>` : `s`} should be explicitly created via \`defineAsyncComponent()\` ` +
|
1906 | `in Vue 3. Plain functions will be treated as functional components in ` +
|
1907 | `non-compat build. If you have already migrated all async component ` +
|
1908 | `usage and intend to use plain functions for functional components, ` +
|
1909 | `you can disable the compat behavior and suppress this ` +
|
1910 | `warning with:` +
|
1911 | `\n\n configureCompat({ ${"COMPONENT_ASYNC" /* COMPONENT_ASYNC */}: false })\n`);
|
1912 | },
|
1913 | link: `https://v3.vuejs.org/guide/migration/async-components.html`
|
1914 | },
|
1915 | ["COMPONENT_FUNCTIONAL" ]: {
|
1916 | message: (comp) => {
|
1917 | const name = getComponentName(comp);
|
1918 | return (`Functional component${name ? ` <${name}>` : `s`} should be defined as a plain function in Vue 3. The "functional" ` +
|
1919 | `option has been removed. NOTE: Before migrating to use plain ` +
|
1920 | `functions for functional components, first make sure that all async ` +
|
1921 | `components usage have been migrated and its compat behavior has ` +
|
1922 | `been disabled.`);
|
1923 | },
|
1924 | link: `https://v3.vuejs.org/guide/migration/functional-components.html`
|
1925 | },
|
1926 | ["COMPONENT_V_MODEL" ]: {
|
1927 | message: (comp) => {
|
1928 | const configMsg = `opt-in to ` +
|
1929 | `Vue 3 behavior on a per-component basis with \`compatConfig: { ${"COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */}: false }\`.`;
|
1930 | if (comp.props &&
|
1931 | (isArray(comp.props)
|
1932 | ? comp.props.includes('modelValue')
|
1933 | : hasOwn(comp.props, 'modelValue'))) {
|
1934 | return (`Component delcares "modelValue" prop, which is Vue 3 usage, but ` +
|
1935 | `is running under Vue 2 compat v-model behavior. You can ${configMsg}`);
|
1936 | }
|
1937 | return (`v-model usage on component has changed in Vue 3. Component that expects ` +
|
1938 | `to work with v-model should now use the "modelValue" prop and emit the ` +
|
1939 | `"update:modelValue" event. You can update the usage and then ${configMsg}`);
|
1940 | },
|
1941 | link: `https://v3.vuejs.org/guide/migration/v-model.html`
|
1942 | },
|
1943 | ["RENDER_FUNCTION" ]: {
|
1944 | message: `Vue 3's render function API has changed. ` +
|
1945 | `You can opt-in to the new API with:` +
|
1946 | `\n\n configureCompat({ ${"RENDER_FUNCTION" /* RENDER_FUNCTION */}: false })\n` +
|
1947 | `\n (This can also be done per-component via the "compatConfig" option.)`,
|
1948 | link: `https://v3.vuejs.org/guide/migration/render-function-api.html`
|
1949 | },
|
1950 | ["FILTERS" ]: {
|
1951 | message: `filters have been removed in Vue 3. ` +
|
1952 | `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
|
1953 | `Use method calls or computed properties instead.`,
|
1954 | link: `https://v3.vuejs.org/guide/migration/filters.html`
|
1955 | },
|
1956 | ["PRIVATE_APIS" ]: {
|
1957 | message: name => `"${name}" is a Vue 2 private API that no longer exists in Vue 3. ` +
|
1958 | `If you are seeing this warning only due to a dependency, you can ` +
|
1959 | `suppress this warning via { PRIVATE_APIS: 'supress-warning' }.`
|
1960 | }
|
1961 | };
|
1962 | const instanceWarned = Object.create(null);
|
1963 | const warnCount = Object.create(null);
|
1964 | function warnDeprecation(key, instance, ...args) {
|
1965 | instance = instance || getCurrentInstance();
|
1966 |
|
1967 | const config = getCompatConfigForKey(key, instance);
|
1968 | if (config === 'suppress-warning') {
|
1969 | return;
|
1970 | }
|
1971 | const dupKey = key + args.join('');
|
1972 | let compId = instance && formatComponentName(instance, instance.type);
|
1973 | if (compId === 'Anonymous' && instance) {
|
1974 | compId = instance.uid;
|
1975 | }
|
1976 |
|
1977 | const componentDupKey = dupKey + compId;
|
1978 | if (componentDupKey in instanceWarned) {
|
1979 | return;
|
1980 | }
|
1981 | instanceWarned[componentDupKey] = true;
|
1982 |
|
1983 |
|
1984 | if (dupKey in warnCount) {
|
1985 | warn$1(`(deprecation ${key}) (${++warnCount[dupKey] + 1})`);
|
1986 | return;
|
1987 | }
|
1988 | warnCount[dupKey] = 0;
|
1989 | const { message, link } = deprecationData[key];
|
1990 | warn$1(`(deprecation ${key}) ${typeof message === 'function' ? message(...args) : message}${link ? `\n Details: ${link}` : ``}`);
|
1991 | if (!isCompatEnabled(key, instance, true)) {
|
1992 | console.error(`^ The above deprecation's compat behavior is disabled and will likely ` +
|
1993 | `lead to runtime errors.`);
|
1994 | }
|
1995 | }
|
1996 | const globalCompatConfig = {
|
1997 | MODE: 2
|
1998 | };
|
1999 | function getCompatConfigForKey(key, instance) {
|
2000 | const instanceConfig = instance && instance.type.compatConfig;
|
2001 | if (instanceConfig && key in instanceConfig) {
|
2002 | return instanceConfig[key];
|
2003 | }
|
2004 | return globalCompatConfig[key];
|
2005 | }
|
2006 | function isCompatEnabled(key, instance, enableForBuiltIn = false) {
|
2007 |
|
2008 | if (!enableForBuiltIn && instance && instance.type.__isBuiltIn) {
|
2009 | return false;
|
2010 | }
|
2011 | const rawMode = getCompatConfigForKey('MODE', instance) || 2;
|
2012 | const val = getCompatConfigForKey(key, instance);
|
2013 | const mode = isFunction(rawMode)
|
2014 | ? rawMode(instance && instance.type)
|
2015 | : rawMode;
|
2016 | if (mode === 2) {
|
2017 | return val !== false;
|
2018 | }
|
2019 | else {
|
2020 | return val === true || val === 'suppress-warning';
|
2021 | }
|
2022 | }
|
2023 |
|
2024 | function emit(instance, event, ...rawArgs) {
|
2025 | const props = instance.vnode.props || EMPTY_OBJ;
|
2026 | {
|
2027 | const { emitsOptions, propsOptions: [propsOptions] } = instance;
|
2028 | if (emitsOptions) {
|
2029 | if (!(event in emitsOptions) &&
|
2030 | !(false )) {
|
2031 | if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
|
2032 | warn$1(`Component emitted event "${event}" but it is neither declared in ` +
|
2033 | `the emits option nor as an "${toHandlerKey(event)}" prop.`);
|
2034 | }
|
2035 | }
|
2036 | else {
|
2037 | const validator = emitsOptions[event];
|
2038 | if (isFunction(validator)) {
|
2039 | const isValid = validator(...rawArgs);
|
2040 | if (!isValid) {
|
2041 | warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
|
2042 | }
|
2043 | }
|
2044 | }
|
2045 | }
|
2046 | }
|
2047 | let args = rawArgs;
|
2048 | const isModelListener = event.startsWith('update:');
|
2049 |
|
2050 | const modelArg = isModelListener && event.slice(7);
|
2051 | if (modelArg && modelArg in props) {
|
2052 | const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
|
2053 | const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
|
2054 | if (trim) {
|
2055 | args = rawArgs.map(a => a.trim());
|
2056 | }
|
2057 | else if (number) {
|
2058 | args = rawArgs.map(toNumber);
|
2059 | }
|
2060 | }
|
2061 | {
|
2062 | devtoolsComponentEmit(instance, event, args);
|
2063 | }
|
2064 | {
|
2065 | const lowerCaseEvent = event.toLowerCase();
|
2066 | if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
|
2067 | warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
|
2068 | `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
|
2069 | `Note that HTML attributes are case-insensitive and you cannot use ` +
|
2070 | `v-on to listen to camelCase events when using in-DOM templates. ` +
|
2071 | `You should probably use "${hyphenate(event)}" instead of "${event}".`);
|
2072 | }
|
2073 | }
|
2074 | let handlerName;
|
2075 | let handler = props[(handlerName = toHandlerKey(event))] ||
|
2076 |
|
2077 | props[(handlerName = toHandlerKey(camelize(event)))];
|
2078 |
|
2079 |
|
2080 | if (!handler && isModelListener) {
|
2081 | handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
|
2082 | }
|
2083 | if (handler) {
|
2084 | callWithAsyncErrorHandling(handler, instance, 6 , args);
|
2085 | }
|
2086 | const onceHandler = props[handlerName + `Once`];
|
2087 | if (onceHandler) {
|
2088 | if (!instance.emitted) {
|
2089 | instance.emitted = {};
|
2090 | }
|
2091 | else if (instance.emitted[handlerName]) {
|
2092 | return;
|
2093 | }
|
2094 | instance.emitted[handlerName] = true;
|
2095 | callWithAsyncErrorHandling(onceHandler, instance, 6 , args);
|
2096 | }
|
2097 | }
|
2098 | function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
2099 | const cache = appContext.emitsCache;
|
2100 | const cached = cache.get(comp);
|
2101 | if (cached !== undefined) {
|
2102 | return cached;
|
2103 | }
|
2104 | const raw = comp.emits;
|
2105 | let normalized = {};
|
2106 |
|
2107 | let hasExtends = false;
|
2108 | if (!isFunction(comp)) {
|
2109 | const extendEmits = (raw) => {
|
2110 | const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
|
2111 | if (normalizedFromExtend) {
|
2112 | hasExtends = true;
|
2113 | extend(normalized, normalizedFromExtend);
|
2114 | }
|
2115 | };
|
2116 | if (!asMixin && appContext.mixins.length) {
|
2117 | appContext.mixins.forEach(extendEmits);
|
2118 | }
|
2119 | if (comp.extends) {
|
2120 | extendEmits(comp.extends);
|
2121 | }
|
2122 | if (comp.mixins) {
|
2123 | comp.mixins.forEach(extendEmits);
|
2124 | }
|
2125 | }
|
2126 | if (!raw && !hasExtends) {
|
2127 | cache.set(comp, null);
|
2128 | return null;
|
2129 | }
|
2130 | if (isArray(raw)) {
|
2131 | raw.forEach(key => (normalized[key] = null));
|
2132 | }
|
2133 | else {
|
2134 | extend(normalized, raw);
|
2135 | }
|
2136 | cache.set(comp, normalized);
|
2137 | return normalized;
|
2138 | }
|
2139 |
|
2140 |
|
2141 |
|
2142 | function isEmitListener(options, key) {
|
2143 | if (!options || !isOn(key)) {
|
2144 | return false;
|
2145 | }
|
2146 | key = key.slice(2).replace(/Once$/, '');
|
2147 | return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
|
2148 | hasOwn(options, hyphenate(key)) ||
|
2149 | hasOwn(options, key));
|
2150 | }
|
2151 |
|
2152 |
|
2153 |
|
2154 |
|
2155 |
|
2156 | let currentRenderingInstance = null;
|
2157 | let currentScopeId = null;
|
2158 |
|
2159 |
|
2160 |
|
2161 |
|
2162 |
|
2163 |
|
2164 |
|
2165 |
|
2166 |
|
2167 |
|
2168 | function setCurrentRenderingInstance(instance) {
|
2169 | const prev = currentRenderingInstance;
|
2170 | currentRenderingInstance = instance;
|
2171 | currentScopeId = (instance && instance.type.__scopeId) || null;
|
2172 | return prev;
|
2173 | }
|
2174 |
|
2175 |
|
2176 |
|
2177 |
|
2178 | function pushScopeId(id) {
|
2179 | currentScopeId = id;
|
2180 | }
|
2181 |
|
2182 |
|
2183 |
|
2184 |
|
2185 |
|
2186 | function popScopeId() {
|
2187 | currentScopeId = null;
|
2188 | }
|
2189 |
|
2190 |
|
2191 |
|
2192 |
|
2193 | const withScopeId = (_id) => withCtx;
|
2194 |
|
2195 |
|
2196 |
|
2197 |
|
2198 | function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
|
2199 | ) {
|
2200 | if (!ctx)
|
2201 | return fn;
|
2202 |
|
2203 | if (fn._n) {
|
2204 | return fn;
|
2205 | }
|
2206 | const renderFnWithContext = (...args) => {
|
2207 |
|
2208 |
|
2209 |
|
2210 |
|
2211 |
|
2212 | if (renderFnWithContext._d) {
|
2213 | setBlockTracking(-1);
|
2214 | }
|
2215 | const prevInstance = setCurrentRenderingInstance(ctx);
|
2216 | const res = fn(...args);
|
2217 | setCurrentRenderingInstance(prevInstance);
|
2218 | if (renderFnWithContext._d) {
|
2219 | setBlockTracking(1);
|
2220 | }
|
2221 | {
|
2222 | devtoolsComponentUpdated(ctx);
|
2223 | }
|
2224 | return res;
|
2225 | };
|
2226 |
|
2227 | renderFnWithContext._n = true;
|
2228 |
|
2229 |
|
2230 |
|
2231 | renderFnWithContext._c = true;
|
2232 |
|
2233 | renderFnWithContext._d = true;
|
2234 | return renderFnWithContext;
|
2235 | }
|
2236 |
|
2237 |
|
2238 |
|
2239 |
|
2240 |
|
2241 |
|
2242 | let accessedAttrs = false;
|
2243 | function markAttrsAccessed() {
|
2244 | accessedAttrs = true;
|
2245 | }
|
2246 | function renderComponentRoot(instance) {
|
2247 | const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
|
2248 | let result;
|
2249 | const prev = setCurrentRenderingInstance(instance);
|
2250 | {
|
2251 | accessedAttrs = false;
|
2252 | }
|
2253 | try {
|
2254 | let fallthroughAttrs;
|
2255 | if (vnode.shapeFlag & 4 ) {
|
2256 |
|
2257 |
|
2258 | const proxyToUse = withProxy || proxy;
|
2259 | result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
|
2260 | fallthroughAttrs = attrs;
|
2261 | }
|
2262 | else {
|
2263 |
|
2264 | const render = Component;
|
2265 |
|
2266 | if (true && attrs === props) {
|
2267 | markAttrsAccessed();
|
2268 | }
|
2269 | result = normalizeVNode(render.length > 1
|
2270 | ? render(props, true
|
2271 | ? {
|
2272 | get attrs() {
|
2273 | markAttrsAccessed();
|
2274 | return attrs;
|
2275 | },
|
2276 | slots,
|
2277 | emit
|
2278 | }
|
2279 | : { attrs, slots, emit })
|
2280 | : render(props, null ));
|
2281 | fallthroughAttrs = Component.props
|
2282 | ? attrs
|
2283 | : getFunctionalFallthrough(attrs);
|
2284 | }
|
2285 |
|
2286 |
|
2287 |
|
2288 | let root = result;
|
2289 | let setRoot = undefined;
|
2290 | if (true &&
|
2291 | result.patchFlag > 0 &&
|
2292 | result.patchFlag & 2048 ) {
|
2293 | ;
|
2294 | [root, setRoot] = getChildRoot(result);
|
2295 | }
|
2296 | if (fallthroughAttrs && inheritAttrs !== false) {
|
2297 | const keys = Object.keys(fallthroughAttrs);
|
2298 | const { shapeFlag } = root;
|
2299 | if (keys.length) {
|
2300 | if (shapeFlag & (1 | 6 )) {
|
2301 | if (propsOptions && keys.some(isModelListener)) {
|
2302 |
|
2303 |
|
2304 |
|
2305 |
|
2306 | fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
|
2307 | }
|
2308 | root = cloneVNode(root, fallthroughAttrs);
|
2309 | }
|
2310 | else if (true && !accessedAttrs && root.type !== Comment) {
|
2311 | const allAttrs = Object.keys(attrs);
|
2312 | const eventAttrs = [];
|
2313 | const extraAttrs = [];
|
2314 | for (let i = 0, l = allAttrs.length; i < l; i++) {
|
2315 | const key = allAttrs[i];
|
2316 | if (isOn(key)) {
|
2317 |
|
2318 | if (!isModelListener(key)) {
|
2319 |
|
2320 |
|
2321 | eventAttrs.push(key[2].toLowerCase() + key.slice(3));
|
2322 | }
|
2323 | }
|
2324 | else {
|
2325 | extraAttrs.push(key);
|
2326 | }
|
2327 | }
|
2328 | if (extraAttrs.length) {
|
2329 | warn$1(`Extraneous non-props attributes (` +
|
2330 | `${extraAttrs.join(', ')}) ` +
|
2331 | `were passed to component but could not be automatically inherited ` +
|
2332 | `because component renders fragment or text root nodes.`);
|
2333 | }
|
2334 | if (eventAttrs.length) {
|
2335 | warn$1(`Extraneous non-emits event listeners (` +
|
2336 | `${eventAttrs.join(', ')}) ` +
|
2337 | `were passed to component but could not be automatically inherited ` +
|
2338 | `because component renders fragment or text root nodes. ` +
|
2339 | `If the listener is intended to be a component custom event listener only, ` +
|
2340 | `declare it using the "emits" option.`);
|
2341 | }
|
2342 | }
|
2343 | }
|
2344 | }
|
2345 | if (false &&
|
2346 | isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" , instance) &&
|
2347 | vnode.shapeFlag & 4 &&
|
2348 | root.shapeFlag & (1 | 6 )) ;
|
2349 |
|
2350 | if (vnode.dirs) {
|
2351 | if (true && !isElementRoot(root)) {
|
2352 | warn$1(`Runtime directive used on component with non-element root node. ` +
|
2353 | `The directives will not function as intended.`);
|
2354 | }
|
2355 | root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
|
2356 | }
|
2357 |
|
2358 | if (vnode.transition) {
|
2359 | if (true && !isElementRoot(root)) {
|
2360 | warn$1(`Component inside <Transition> renders non-element root node ` +
|
2361 | `that cannot be animated.`);
|
2362 | }
|
2363 | root.transition = vnode.transition;
|
2364 | }
|
2365 | if (true && setRoot) {
|
2366 | setRoot(root);
|
2367 | }
|
2368 | else {
|
2369 | result = root;
|
2370 | }
|
2371 | }
|
2372 | catch (err) {
|
2373 | blockStack.length = 0;
|
2374 | handleError(err, instance, 1 );
|
2375 | result = createVNode(Comment);
|
2376 | }
|
2377 | setCurrentRenderingInstance(prev);
|
2378 | return result;
|
2379 | }
|
2380 |
|
2381 |
|
2382 |
|
2383 |
|
2384 |
|
2385 |
|
2386 | const getChildRoot = (vnode) => {
|
2387 | const rawChildren = vnode.children;
|
2388 | const dynamicChildren = vnode.dynamicChildren;
|
2389 | const childRoot = filterSingleRoot(rawChildren);
|
2390 | if (!childRoot) {
|
2391 | return [vnode, undefined];
|
2392 | }
|
2393 | const index = rawChildren.indexOf(childRoot);
|
2394 | const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
|
2395 | const setRoot = (updatedRoot) => {
|
2396 | rawChildren[index] = updatedRoot;
|
2397 | if (dynamicChildren) {
|
2398 | if (dynamicIndex > -1) {
|
2399 | dynamicChildren[dynamicIndex] = updatedRoot;
|
2400 | }
|
2401 | else if (updatedRoot.patchFlag > 0) {
|
2402 | vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
|
2403 | }
|
2404 | }
|
2405 | };
|
2406 | return [normalizeVNode(childRoot), setRoot];
|
2407 | };
|
2408 | function filterSingleRoot(children) {
|
2409 | let singleRoot;
|
2410 | for (let i = 0; i < children.length; i++) {
|
2411 | const child = children[i];
|
2412 | if (isVNode(child)) {
|
2413 |
|
2414 | if (child.type !== Comment || child.children === 'v-if') {
|
2415 | if (singleRoot) {
|
2416 |
|
2417 | return;
|
2418 | }
|
2419 | else {
|
2420 | singleRoot = child;
|
2421 | }
|
2422 | }
|
2423 | }
|
2424 | else {
|
2425 | return;
|
2426 | }
|
2427 | }
|
2428 | return singleRoot;
|
2429 | }
|
2430 | const getFunctionalFallthrough = (attrs) => {
|
2431 | let res;
|
2432 | for (const key in attrs) {
|
2433 | if (key === 'class' || key === 'style' || isOn(key)) {
|
2434 | (res || (res = {}))[key] = attrs[key];
|
2435 | }
|
2436 | }
|
2437 | return res;
|
2438 | };
|
2439 | const filterModelListeners = (attrs, props) => {
|
2440 | const res = {};
|
2441 | for (const key in attrs) {
|
2442 | if (!isModelListener(key) || !(key.slice(9) in props)) {
|
2443 | res[key] = attrs[key];
|
2444 | }
|
2445 | }
|
2446 | return res;
|
2447 | };
|
2448 | const isElementRoot = (vnode) => {
|
2449 | return (vnode.shapeFlag & (6 | 1 ) ||
|
2450 | vnode.type === Comment
|
2451 | );
|
2452 | };
|
2453 | function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
|
2454 | const { props: prevProps, children: prevChildren, component } = prevVNode;
|
2455 | const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
|
2456 | const emits = component.emitsOptions;
|
2457 |
|
2458 |
|
2459 |
|
2460 | if ((prevChildren || nextChildren) && isHmrUpdating) {
|
2461 | return true;
|
2462 | }
|
2463 |
|
2464 | if (nextVNode.dirs || nextVNode.transition) {
|
2465 | return true;
|
2466 | }
|
2467 | if (optimized && patchFlag >= 0) {
|
2468 | if (patchFlag & 1024 ) {
|
2469 |
|
2470 |
|
2471 | return true;
|
2472 | }
|
2473 | if (patchFlag & 16 ) {
|
2474 | if (!prevProps) {
|
2475 | return !!nextProps;
|
2476 | }
|
2477 |
|
2478 | return hasPropsChanged(prevProps, nextProps, emits);
|
2479 | }
|
2480 | else if (patchFlag & 8 ) {
|
2481 | const dynamicProps = nextVNode.dynamicProps;
|
2482 | for (let i = 0; i < dynamicProps.length; i++) {
|
2483 | const key = dynamicProps[i];
|
2484 | if (nextProps[key] !== prevProps[key] &&
|
2485 | !isEmitListener(emits, key)) {
|
2486 | return true;
|
2487 | }
|
2488 | }
|
2489 | }
|
2490 | }
|
2491 | else {
|
2492 |
|
2493 |
|
2494 | if (prevChildren || nextChildren) {
|
2495 | if (!nextChildren || !nextChildren.$stable) {
|
2496 | return true;
|
2497 | }
|
2498 | }
|
2499 | if (prevProps === nextProps) {
|
2500 | return false;
|
2501 | }
|
2502 | if (!prevProps) {
|
2503 | return !!nextProps;
|
2504 | }
|
2505 | if (!nextProps) {
|
2506 | return true;
|
2507 | }
|
2508 | return hasPropsChanged(prevProps, nextProps, emits);
|
2509 | }
|
2510 | return false;
|
2511 | }
|
2512 | function hasPropsChanged(prevProps, nextProps, emitsOptions) {
|
2513 | const nextKeys = Object.keys(nextProps);
|
2514 | if (nextKeys.length !== Object.keys(prevProps).length) {
|
2515 | return true;
|
2516 | }
|
2517 | for (let i = 0; i < nextKeys.length; i++) {
|
2518 | const key = nextKeys[i];
|
2519 | if (nextProps[key] !== prevProps[key] &&
|
2520 | !isEmitListener(emitsOptions, key)) {
|
2521 | return true;
|
2522 | }
|
2523 | }
|
2524 | return false;
|
2525 | }
|
2526 | function updateHOCHostEl({ vnode, parent }, el // HostNode
|
2527 | ) {
|
2528 | while (parent && parent.subTree === vnode) {
|
2529 | (vnode = parent.vnode).el = el;
|
2530 | parent = parent.parent;
|
2531 | }
|
2532 | }
|
2533 |
|
2534 | const isSuspense = (type) => type.__isSuspense;
|
2535 |
|
2536 |
|
2537 |
|
2538 | const SuspenseImpl = {
|
2539 | name: 'Suspense',
|
2540 |
|
2541 |
|
2542 |
|
2543 |
|
2544 | __isSuspense: true,
|
2545 | process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
|
2546 |
|
2547 | rendererInternals) {
|
2548 | if (n1 == null) {
|
2549 | mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
|
2550 | }
|
2551 | else {
|
2552 | patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
|
2553 | }
|
2554 | },
|
2555 | hydrate: hydrateSuspense,
|
2556 | create: createSuspenseBoundary,
|
2557 | normalize: normalizeSuspenseChildren
|
2558 | };
|
2559 |
|
2560 | const Suspense = (SuspenseImpl );
|
2561 | function triggerEvent(vnode, name) {
|
2562 | const eventListener = vnode.props && vnode.props[name];
|
2563 | if (isFunction(eventListener)) {
|
2564 | eventListener();
|
2565 | }
|
2566 | }
|
2567 | function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
|
2568 | const { p: patch, o: { createElement } } = rendererInternals;
|
2569 | const hiddenContainer = createElement('div');
|
2570 | const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
|
2571 |
|
2572 | patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
|
2573 |
|
2574 | if (suspense.deps > 0) {
|
2575 |
|
2576 |
|
2577 | triggerEvent(vnode, 'onPending');
|
2578 | triggerEvent(vnode, 'onFallback');
|
2579 |
|
2580 | patch(null, vnode.ssFallback, container, anchor, parentComponent, null,
|
2581 | isSVG, slotScopeIds);
|
2582 | setActiveBranch(suspense, vnode.ssFallback);
|
2583 | }
|
2584 | else {
|
2585 |
|
2586 | suspense.resolve();
|
2587 | }
|
2588 | }
|
2589 | function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
|
2590 | const suspense = (n2.suspense = n1.suspense);
|
2591 | suspense.vnode = n2;
|
2592 | n2.el = n1.el;
|
2593 | const newBranch = n2.ssContent;
|
2594 | const newFallback = n2.ssFallback;
|
2595 | const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
|
2596 | if (pendingBranch) {
|
2597 | suspense.pendingBranch = newBranch;
|
2598 | if (isSameVNodeType(newBranch, pendingBranch)) {
|
2599 |
|
2600 | patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2601 | if (suspense.deps <= 0) {
|
2602 | suspense.resolve();
|
2603 | }
|
2604 | else if (isInFallback) {
|
2605 | patch(activeBranch, newFallback, container, anchor, parentComponent, null,
|
2606 | isSVG, slotScopeIds, optimized);
|
2607 | setActiveBranch(suspense, newFallback);
|
2608 | }
|
2609 | }
|
2610 | else {
|
2611 |
|
2612 | suspense.pendingId++;
|
2613 | if (isHydrating) {
|
2614 |
|
2615 |
|
2616 |
|
2617 | suspense.isHydrating = false;
|
2618 | suspense.activeBranch = pendingBranch;
|
2619 | }
|
2620 | else {
|
2621 | unmount(pendingBranch, parentComponent, suspense);
|
2622 | }
|
2623 |
|
2624 |
|
2625 | suspense.deps = 0;
|
2626 |
|
2627 | suspense.effects.length = 0;
|
2628 |
|
2629 | suspense.hiddenContainer = createElement('div');
|
2630 | if (isInFallback) {
|
2631 |
|
2632 | patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2633 | if (suspense.deps <= 0) {
|
2634 | suspense.resolve();
|
2635 | }
|
2636 | else {
|
2637 | patch(activeBranch, newFallback, container, anchor, parentComponent, null,
|
2638 | isSVG, slotScopeIds, optimized);
|
2639 | setActiveBranch(suspense, newFallback);
|
2640 | }
|
2641 | }
|
2642 | else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2643 |
|
2644 | patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2645 |
|
2646 | suspense.resolve(true);
|
2647 | }
|
2648 | else {
|
2649 |
|
2650 | patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2651 | if (suspense.deps <= 0) {
|
2652 | suspense.resolve();
|
2653 | }
|
2654 | }
|
2655 | }
|
2656 | }
|
2657 | else {
|
2658 | if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2659 |
|
2660 | patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2661 | setActiveBranch(suspense, newBranch);
|
2662 | }
|
2663 | else {
|
2664 |
|
2665 |
|
2666 | triggerEvent(n2, 'onPending');
|
2667 |
|
2668 | suspense.pendingBranch = newBranch;
|
2669 | suspense.pendingId++;
|
2670 | patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2671 | if (suspense.deps <= 0) {
|
2672 |
|
2673 | suspense.resolve();
|
2674 | }
|
2675 | else {
|
2676 | const { timeout, pendingId } = suspense;
|
2677 | if (timeout > 0) {
|
2678 | setTimeout(() => {
|
2679 | if (suspense.pendingId === pendingId) {
|
2680 | suspense.fallback(newFallback);
|
2681 | }
|
2682 | }, timeout);
|
2683 | }
|
2684 | else if (timeout === 0) {
|
2685 | suspense.fallback(newFallback);
|
2686 | }
|
2687 | }
|
2688 | }
|
2689 | }
|
2690 | }
|
2691 | let hasWarned = false;
|
2692 | function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
|
2693 |
|
2694 | if (!hasWarned) {
|
2695 | hasWarned = true;
|
2696 |
|
2697 | console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
|
2698 | }
|
2699 | const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
|
2700 | const timeout = toNumber(vnode.props && vnode.props.timeout);
|
2701 | const suspense = {
|
2702 | vnode,
|
2703 | parent,
|
2704 | parentComponent,
|
2705 | isSVG,
|
2706 | container,
|
2707 | hiddenContainer,
|
2708 | anchor,
|
2709 | deps: 0,
|
2710 | pendingId: 0,
|
2711 | timeout: typeof timeout === 'number' ? timeout : -1,
|
2712 | activeBranch: null,
|
2713 | pendingBranch: null,
|
2714 | isInFallback: true,
|
2715 | isHydrating,
|
2716 | isUnmounted: false,
|
2717 | effects: [],
|
2718 | resolve(resume = false) {
|
2719 | {
|
2720 | if (!resume && !suspense.pendingBranch) {
|
2721 | throw new Error(`suspense.resolve() is called without a pending branch.`);
|
2722 | }
|
2723 | if (suspense.isUnmounted) {
|
2724 | throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
|
2725 | }
|
2726 | }
|
2727 | const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
|
2728 | if (suspense.isHydrating) {
|
2729 | suspense.isHydrating = false;
|
2730 | }
|
2731 | else if (!resume) {
|
2732 | const delayEnter = activeBranch &&
|
2733 | pendingBranch.transition &&
|
2734 | pendingBranch.transition.mode === 'out-in';
|
2735 | if (delayEnter) {
|
2736 | activeBranch.transition.afterLeave = () => {
|
2737 | if (pendingId === suspense.pendingId) {
|
2738 | move(pendingBranch, container, anchor, 0 );
|
2739 | }
|
2740 | };
|
2741 | }
|
2742 |
|
2743 | let { anchor } = suspense;
|
2744 |
|
2745 | if (activeBranch) {
|
2746 |
|
2747 |
|
2748 | anchor = next(activeBranch);
|
2749 | unmount(activeBranch, parentComponent, suspense, true);
|
2750 | }
|
2751 | if (!delayEnter) {
|
2752 |
|
2753 | move(pendingBranch, container, anchor, 0 );
|
2754 | }
|
2755 | }
|
2756 | setActiveBranch(suspense, pendingBranch);
|
2757 | suspense.pendingBranch = null;
|
2758 | suspense.isInFallback = false;
|
2759 |
|
2760 |
|
2761 | let parent = suspense.parent;
|
2762 | let hasUnresolvedAncestor = false;
|
2763 | while (parent) {
|
2764 | if (parent.pendingBranch) {
|
2765 |
|
2766 |
|
2767 | parent.effects.push(...effects);
|
2768 | hasUnresolvedAncestor = true;
|
2769 | break;
|
2770 | }
|
2771 | parent = parent.parent;
|
2772 | }
|
2773 |
|
2774 | if (!hasUnresolvedAncestor) {
|
2775 | queuePostFlushCb(effects);
|
2776 | }
|
2777 | suspense.effects = [];
|
2778 |
|
2779 | triggerEvent(vnode, 'onResolve');
|
2780 | },
|
2781 | fallback(fallbackVNode) {
|
2782 | if (!suspense.pendingBranch) {
|
2783 | return;
|
2784 | }
|
2785 | const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
|
2786 |
|
2787 | triggerEvent(vnode, 'onFallback');
|
2788 | const anchor = next(activeBranch);
|
2789 | const mountFallback = () => {
|
2790 | if (!suspense.isInFallback) {
|
2791 | return;
|
2792 | }
|
2793 |
|
2794 | patch(null, fallbackVNode, container, anchor, parentComponent, null,
|
2795 | isSVG, slotScopeIds, optimized);
|
2796 | setActiveBranch(suspense, fallbackVNode);
|
2797 | };
|
2798 | const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
|
2799 | if (delayEnter) {
|
2800 | activeBranch.transition.afterLeave = mountFallback;
|
2801 | }
|
2802 | suspense.isInFallback = true;
|
2803 |
|
2804 | unmount(activeBranch, parentComponent, null,
|
2805 | true
|
2806 | );
|
2807 | if (!delayEnter) {
|
2808 | mountFallback();
|
2809 | }
|
2810 | },
|
2811 | move(container, anchor, type) {
|
2812 | suspense.activeBranch &&
|
2813 | move(suspense.activeBranch, container, anchor, type);
|
2814 | suspense.container = container;
|
2815 | },
|
2816 | next() {
|
2817 | return suspense.activeBranch && next(suspense.activeBranch);
|
2818 | },
|
2819 | registerDep(instance, setupRenderEffect) {
|
2820 | const isInPendingSuspense = !!suspense.pendingBranch;
|
2821 | if (isInPendingSuspense) {
|
2822 | suspense.deps++;
|
2823 | }
|
2824 | const hydratedEl = instance.vnode.el;
|
2825 | instance
|
2826 | .asyncDep.catch(err => {
|
2827 | handleError(err, instance, 0 );
|
2828 | })
|
2829 | .then(asyncSetupResult => {
|
2830 |
|
2831 |
|
2832 | if (instance.isUnmounted ||
|
2833 | suspense.isUnmounted ||
|
2834 | suspense.pendingId !== instance.suspenseId) {
|
2835 | return;
|
2836 | }
|
2837 |
|
2838 | instance.asyncResolved = true;
|
2839 | const { vnode } = instance;
|
2840 | {
|
2841 | pushWarningContext(vnode);
|
2842 | }
|
2843 | handleSetupResult(instance, asyncSetupResult, false);
|
2844 | if (hydratedEl) {
|
2845 |
|
2846 |
|
2847 | vnode.el = hydratedEl;
|
2848 | }
|
2849 | const placeholder = !hydratedEl && instance.subTree.el;
|
2850 | setupRenderEffect(instance, vnode,
|
2851 |
|
2852 |
|
2853 |
|
2854 | parentNode(hydratedEl || instance.subTree.el),
|
2855 |
|
2856 |
|
2857 | hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
|
2858 | if (placeholder) {
|
2859 | remove(placeholder);
|
2860 | }
|
2861 | updateHOCHostEl(instance, vnode.el);
|
2862 | {
|
2863 | popWarningContext();
|
2864 | }
|
2865 |
|
2866 | if (isInPendingSuspense && --suspense.deps === 0) {
|
2867 | suspense.resolve();
|
2868 | }
|
2869 | });
|
2870 | },
|
2871 | unmount(parentSuspense, doRemove) {
|
2872 | suspense.isUnmounted = true;
|
2873 | if (suspense.activeBranch) {
|
2874 | unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
|
2875 | }
|
2876 | if (suspense.pendingBranch) {
|
2877 | unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
|
2878 | }
|
2879 | }
|
2880 | };
|
2881 | return suspense;
|
2882 | }
|
2883 | function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
|
2884 |
|
2885 | const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true ));
|
2886 |
|
2887 |
|
2888 |
|
2889 |
|
2890 |
|
2891 |
|
2892 | const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
|
2893 | if (suspense.deps === 0) {
|
2894 | suspense.resolve();
|
2895 | }
|
2896 | return result;
|
2897 |
|
2898 | }
|
2899 | function normalizeSuspenseChildren(vnode) {
|
2900 | const { shapeFlag, children } = vnode;
|
2901 | const isSlotChildren = shapeFlag & 32 ;
|
2902 | vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
|
2903 | vnode.ssFallback = isSlotChildren
|
2904 | ? normalizeSuspenseSlot(children.fallback)
|
2905 | : createVNode(Comment);
|
2906 | }
|
2907 | function normalizeSuspenseSlot(s) {
|
2908 | let block;
|
2909 | if (isFunction(s)) {
|
2910 | const isCompiledSlot = s._c;
|
2911 | if (isCompiledSlot) {
|
2912 |
|
2913 |
|
2914 |
|
2915 | s._d = false;
|
2916 | openBlock();
|
2917 | }
|
2918 | s = s();
|
2919 | if (isCompiledSlot) {
|
2920 | s._d = true;
|
2921 | block = currentBlock;
|
2922 | closeBlock();
|
2923 | }
|
2924 | }
|
2925 | if (isArray(s)) {
|
2926 | const singleChild = filterSingleRoot(s);
|
2927 | if (!singleChild) {
|
2928 | warn$1(`<Suspense> slots expect a single root node.`);
|
2929 | }
|
2930 | s = singleChild;
|
2931 | }
|
2932 | s = normalizeVNode(s);
|
2933 | if (block && !s.dynamicChildren) {
|
2934 | s.dynamicChildren = block.filter(c => c !== s);
|
2935 | }
|
2936 | return s;
|
2937 | }
|
2938 | function queueEffectWithSuspense(fn, suspense) {
|
2939 | if (suspense && suspense.pendingBranch) {
|
2940 | if (isArray(fn)) {
|
2941 | suspense.effects.push(...fn);
|
2942 | }
|
2943 | else {
|
2944 | suspense.effects.push(fn);
|
2945 | }
|
2946 | }
|
2947 | else {
|
2948 | queuePostFlushCb(fn);
|
2949 | }
|
2950 | }
|
2951 | function setActiveBranch(suspense, branch) {
|
2952 | suspense.activeBranch = branch;
|
2953 | const { vnode, parentComponent } = suspense;
|
2954 | const el = (vnode.el = branch.el);
|
2955 |
|
2956 |
|
2957 | if (parentComponent && parentComponent.subTree === vnode) {
|
2958 | parentComponent.vnode.el = el;
|
2959 | updateHOCHostEl(parentComponent, el);
|
2960 | }
|
2961 | }
|
2962 |
|
2963 | function provide(key, value) {
|
2964 | if (!currentInstance) {
|
2965 | {
|
2966 | warn$1(`provide() can only be used inside setup().`);
|
2967 | }
|
2968 | }
|
2969 | else {
|
2970 | let provides = currentInstance.provides;
|
2971 |
|
2972 |
|
2973 |
|
2974 |
|
2975 |
|
2976 | const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
2977 | if (parentProvides === provides) {
|
2978 | provides = currentInstance.provides = Object.create(parentProvides);
|
2979 | }
|
2980 |
|
2981 | provides[key] = value;
|
2982 | }
|
2983 | }
|
2984 | function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
2985 |
|
2986 |
|
2987 | const instance = currentInstance || currentRenderingInstance;
|
2988 | if (instance) {
|
2989 |
|
2990 |
|
2991 |
|
2992 | const provides = instance.parent == null
|
2993 | ? instance.vnode.appContext && instance.vnode.appContext.provides
|
2994 | : instance.parent.provides;
|
2995 | if (provides && key in provides) {
|
2996 |
|
2997 | return provides[key];
|
2998 | }
|
2999 | else if (arguments.length > 1) {
|
3000 | return treatDefaultAsFactory && isFunction(defaultValue)
|
3001 | ? defaultValue.call(instance.proxy)
|
3002 | : defaultValue;
|
3003 | }
|
3004 | else {
|
3005 | warn$1(`injection "${String(key)}" not found.`);
|
3006 | }
|
3007 | }
|
3008 | else {
|
3009 | warn$1(`inject() can only be used inside setup() or functional components.`);
|
3010 | }
|
3011 | }
|
3012 |
|
3013 | function useTransitionState() {
|
3014 | const state = {
|
3015 | isMounted: false,
|
3016 | isLeaving: false,
|
3017 | isUnmounting: false,
|
3018 | leavingVNodes: new Map()
|
3019 | };
|
3020 | onMounted(() => {
|
3021 | state.isMounted = true;
|
3022 | });
|
3023 | onBeforeUnmount(() => {
|
3024 | state.isUnmounting = true;
|
3025 | });
|
3026 | return state;
|
3027 | }
|
3028 | const TransitionHookValidator = [Function, Array];
|
3029 | const BaseTransitionImpl = {
|
3030 | name: `BaseTransition`,
|
3031 | props: {
|
3032 | mode: String,
|
3033 | appear: Boolean,
|
3034 | persisted: Boolean,
|
3035 |
|
3036 | onBeforeEnter: TransitionHookValidator,
|
3037 | onEnter: TransitionHookValidator,
|
3038 | onAfterEnter: TransitionHookValidator,
|
3039 | onEnterCancelled: TransitionHookValidator,
|
3040 |
|
3041 | onBeforeLeave: TransitionHookValidator,
|
3042 | onLeave: TransitionHookValidator,
|
3043 | onAfterLeave: TransitionHookValidator,
|
3044 | onLeaveCancelled: TransitionHookValidator,
|
3045 |
|
3046 | onBeforeAppear: TransitionHookValidator,
|
3047 | onAppear: TransitionHookValidator,
|
3048 | onAfterAppear: TransitionHookValidator,
|
3049 | onAppearCancelled: TransitionHookValidator
|
3050 | },
|
3051 | setup(props, { slots }) {
|
3052 | const instance = getCurrentInstance();
|
3053 | const state = useTransitionState();
|
3054 | let prevTransitionKey;
|
3055 | return () => {
|
3056 | const children = slots.default && getTransitionRawChildren(slots.default(), true);
|
3057 | if (!children || !children.length) {
|
3058 | return;
|
3059 | }
|
3060 |
|
3061 | if (children.length > 1) {
|
3062 | warn$1('<transition> can only be used on a single element or component. Use ' +
|
3063 | '<transition-group> for lists.');
|
3064 | }
|
3065 |
|
3066 |
|
3067 | const rawProps = toRaw(props);
|
3068 | const { mode } = rawProps;
|
3069 |
|
3070 | if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
|
3071 | warn$1(`invalid <transition> mode: ${mode}`);
|
3072 | }
|
3073 |
|
3074 | const child = children[0];
|
3075 | if (state.isLeaving) {
|
3076 | return emptyPlaceholder(child);
|
3077 | }
|
3078 |
|
3079 |
|
3080 | const innerChild = getKeepAliveChild(child);
|
3081 | if (!innerChild) {
|
3082 | return emptyPlaceholder(child);
|
3083 | }
|
3084 | const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
|
3085 | setTransitionHooks(innerChild, enterHooks);
|
3086 | const oldChild = instance.subTree;
|
3087 | const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
|
3088 | let transitionKeyChanged = false;
|
3089 | const { getTransitionKey } = innerChild.type;
|
3090 | if (getTransitionKey) {
|
3091 | const key = getTransitionKey();
|
3092 | if (prevTransitionKey === undefined) {
|
3093 | prevTransitionKey = key;
|
3094 | }
|
3095 | else if (key !== prevTransitionKey) {
|
3096 | prevTransitionKey = key;
|
3097 | transitionKeyChanged = true;
|
3098 | }
|
3099 | }
|
3100 |
|
3101 | if (oldInnerChild &&
|
3102 | oldInnerChild.type !== Comment &&
|
3103 | (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
|
3104 | const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
|
3105 |
|
3106 | setTransitionHooks(oldInnerChild, leavingHooks);
|
3107 |
|
3108 | if (mode === 'out-in') {
|
3109 | state.isLeaving = true;
|
3110 |
|
3111 | leavingHooks.afterLeave = () => {
|
3112 | state.isLeaving = false;
|
3113 | instance.update();
|
3114 | };
|
3115 | return emptyPlaceholder(child);
|
3116 | }
|
3117 | else if (mode === 'in-out' && innerChild.type !== Comment) {
|
3118 | leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
|
3119 | const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
|
3120 | leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
|
3121 |
|
3122 | el._leaveCb = () => {
|
3123 | earlyRemove();
|
3124 | el._leaveCb = undefined;
|
3125 | delete enterHooks.delayedLeave;
|
3126 | };
|
3127 | enterHooks.delayedLeave = delayedLeave;
|
3128 | };
|
3129 | }
|
3130 | }
|
3131 | return child;
|
3132 | };
|
3133 | }
|
3134 | };
|
3135 |
|
3136 |
|
3137 | const BaseTransition = BaseTransitionImpl;
|
3138 | function getLeavingNodesForType(state, vnode) {
|
3139 | const { leavingVNodes } = state;
|
3140 | let leavingVNodesCache = leavingVNodes.get(vnode.type);
|
3141 | if (!leavingVNodesCache) {
|
3142 | leavingVNodesCache = Object.create(null);
|
3143 | leavingVNodes.set(vnode.type, leavingVNodesCache);
|
3144 | }
|
3145 | return leavingVNodesCache;
|
3146 | }
|
3147 |
|
3148 |
|
3149 | function resolveTransitionHooks(vnode, props, state, instance) {
|
3150 | const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
|
3151 | const key = String(vnode.key);
|
3152 | const leavingVNodesCache = getLeavingNodesForType(state, vnode);
|
3153 | const callHook = (hook, args) => {
|
3154 | hook &&
|
3155 | callWithAsyncErrorHandling(hook, instance, 9 , args);
|
3156 | };
|
3157 | const hooks = {
|
3158 | mode,
|
3159 | persisted,
|
3160 | beforeEnter(el) {
|
3161 | let hook = onBeforeEnter;
|
3162 | if (!state.isMounted) {
|
3163 | if (appear) {
|
3164 | hook = onBeforeAppear || onBeforeEnter;
|
3165 | }
|
3166 | else {
|
3167 | return;
|
3168 | }
|
3169 | }
|
3170 |
|
3171 | if (el._leaveCb) {
|
3172 | el._leaveCb(true );
|
3173 | }
|
3174 |
|
3175 | const leavingVNode = leavingVNodesCache[key];
|
3176 | if (leavingVNode &&
|
3177 | isSameVNodeType(vnode, leavingVNode) &&
|
3178 | leavingVNode.el._leaveCb) {
|
3179 |
|
3180 | leavingVNode.el._leaveCb();
|
3181 | }
|
3182 | callHook(hook, [el]);
|
3183 | },
|
3184 | enter(el) {
|
3185 | let hook = onEnter;
|
3186 | let afterHook = onAfterEnter;
|
3187 | let cancelHook = onEnterCancelled;
|
3188 | if (!state.isMounted) {
|
3189 | if (appear) {
|
3190 | hook = onAppear || onEnter;
|
3191 | afterHook = onAfterAppear || onAfterEnter;
|
3192 | cancelHook = onAppearCancelled || onEnterCancelled;
|
3193 | }
|
3194 | else {
|
3195 | return;
|
3196 | }
|
3197 | }
|
3198 | let called = false;
|
3199 | const done = (el._enterCb = (cancelled) => {
|
3200 | if (called)
|
3201 | return;
|
3202 | called = true;
|
3203 | if (cancelled) {
|
3204 | callHook(cancelHook, [el]);
|
3205 | }
|
3206 | else {
|
3207 | callHook(afterHook, [el]);
|
3208 | }
|
3209 | if (hooks.delayedLeave) {
|
3210 | hooks.delayedLeave();
|
3211 | }
|
3212 | el._enterCb = undefined;
|
3213 | });
|
3214 | if (hook) {
|
3215 | hook(el, done);
|
3216 | if (hook.length <= 1) {
|
3217 | done();
|
3218 | }
|
3219 | }
|
3220 | else {
|
3221 | done();
|
3222 | }
|
3223 | },
|
3224 | leave(el, remove) {
|
3225 | const key = String(vnode.key);
|
3226 | if (el._enterCb) {
|
3227 | el._enterCb(true );
|
3228 | }
|
3229 | if (state.isUnmounting) {
|
3230 | return remove();
|
3231 | }
|
3232 | callHook(onBeforeLeave, [el]);
|
3233 | let called = false;
|
3234 | const done = (el._leaveCb = (cancelled) => {
|
3235 | if (called)
|
3236 | return;
|
3237 | called = true;
|
3238 | remove();
|
3239 | if (cancelled) {
|
3240 | callHook(onLeaveCancelled, [el]);
|
3241 | }
|
3242 | else {
|
3243 | callHook(onAfterLeave, [el]);
|
3244 | }
|
3245 | el._leaveCb = undefined;
|
3246 | if (leavingVNodesCache[key] === vnode) {
|
3247 | delete leavingVNodesCache[key];
|
3248 | }
|
3249 | });
|
3250 | leavingVNodesCache[key] = vnode;
|
3251 | if (onLeave) {
|
3252 | onLeave(el, done);
|
3253 | if (onLeave.length <= 1) {
|
3254 | done();
|
3255 | }
|
3256 | }
|
3257 | else {
|
3258 | done();
|
3259 | }
|
3260 | },
|
3261 | clone(vnode) {
|
3262 | return resolveTransitionHooks(vnode, props, state, instance);
|
3263 | }
|
3264 | };
|
3265 | return hooks;
|
3266 | }
|
3267 |
|
3268 |
|
3269 |
|
3270 |
|
3271 | function emptyPlaceholder(vnode) {
|
3272 | if (isKeepAlive(vnode)) {
|
3273 | vnode = cloneVNode(vnode);
|
3274 | vnode.children = null;
|
3275 | return vnode;
|
3276 | }
|
3277 | }
|
3278 | function getKeepAliveChild(vnode) {
|
3279 | return isKeepAlive(vnode)
|
3280 | ? vnode.children
|
3281 | ? vnode.children[0]
|
3282 | : undefined
|
3283 | : vnode;
|
3284 | }
|
3285 | function setTransitionHooks(vnode, hooks) {
|
3286 | if (vnode.shapeFlag & 6 && vnode.component) {
|
3287 | setTransitionHooks(vnode.component.subTree, hooks);
|
3288 | }
|
3289 | else if (vnode.shapeFlag & 128 ) {
|
3290 | vnode.ssContent.transition = hooks.clone(vnode.ssContent);
|
3291 | vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
|
3292 | }
|
3293 | else {
|
3294 | vnode.transition = hooks;
|
3295 | }
|
3296 | }
|
3297 | function getTransitionRawChildren(children, keepComment = false) {
|
3298 | let ret = [];
|
3299 | let keyedFragmentCount = 0;
|
3300 | for (let i = 0; i < children.length; i++) {
|
3301 | const child = children[i];
|
3302 |
|
3303 | if (child.type === Fragment) {
|
3304 | if (child.patchFlag & 128 )
|
3305 | keyedFragmentCount++;
|
3306 | ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
|
3307 | }
|
3308 |
|
3309 | else if (keepComment || child.type !== Comment) {
|
3310 | ret.push(child);
|
3311 | }
|
3312 | }
|
3313 |
|
3314 |
|
3315 |
|
3316 |
|
3317 | if (keyedFragmentCount > 1) {
|
3318 | for (let i = 0; i < ret.length; i++) {
|
3319 | ret[i].patchFlag = -2 ;
|
3320 | }
|
3321 | }
|
3322 | return ret;
|
3323 | }
|
3324 |
|
3325 |
|
3326 | function defineComponent(options) {
|
3327 | return isFunction(options) ? { setup: options, name: options.name } : options;
|
3328 | }
|
3329 |
|
3330 | const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
|
3331 | function defineAsyncComponent(source) {
|
3332 | if (isFunction(source)) {
|
3333 | source = { loader: source };
|
3334 | }
|
3335 | const { loader, loadingComponent, errorComponent, delay = 200, timeout,
|
3336 | suspensible = true, onError: userOnError } = source;
|
3337 | let pendingRequest = null;
|
3338 | let resolvedComp;
|
3339 | let retries = 0;
|
3340 | const retry = () => {
|
3341 | retries++;
|
3342 | pendingRequest = null;
|
3343 | return load();
|
3344 | };
|
3345 | const load = () => {
|
3346 | let thisRequest;
|
3347 | return (pendingRequest ||
|
3348 | (thisRequest = pendingRequest =
|
3349 | loader()
|
3350 | .catch(err => {
|
3351 | err = err instanceof Error ? err : new Error(String(err));
|
3352 | if (userOnError) {
|
3353 | return new Promise((resolve, reject) => {
|
3354 | const userRetry = () => resolve(retry());
|
3355 | const userFail = () => reject(err);
|
3356 | userOnError(err, userRetry, userFail, retries + 1);
|
3357 | });
|
3358 | }
|
3359 | else {
|
3360 | throw err;
|
3361 | }
|
3362 | })
|
3363 | .then((comp) => {
|
3364 | if (thisRequest !== pendingRequest && pendingRequest) {
|
3365 | return pendingRequest;
|
3366 | }
|
3367 | if (!comp) {
|
3368 | warn$1(`Async component loader resolved to undefined. ` +
|
3369 | `If you are using retry(), make sure to return its return value.`);
|
3370 | }
|
3371 |
|
3372 | if (comp &&
|
3373 | (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
|
3374 | comp = comp.default;
|
3375 | }
|
3376 | if (comp && !isObject(comp) && !isFunction(comp)) {
|
3377 | throw new Error(`Invalid async component load result: ${comp}`);
|
3378 | }
|
3379 | resolvedComp = comp;
|
3380 | return comp;
|
3381 | })));
|
3382 | };
|
3383 | return defineComponent({
|
3384 | name: 'AsyncComponentWrapper',
|
3385 | __asyncLoader: load,
|
3386 | get __asyncResolved() {
|
3387 | return resolvedComp;
|
3388 | },
|
3389 | setup() {
|
3390 | const instance = currentInstance;
|
3391 |
|
3392 | if (resolvedComp) {
|
3393 | return () => createInnerComp(resolvedComp, instance);
|
3394 | }
|
3395 | const onError = (err) => {
|
3396 | pendingRequest = null;
|
3397 | handleError(err, instance, 13 , !errorComponent );
|
3398 | };
|
3399 |
|
3400 | if ((suspensible && instance.suspense) ||
|
3401 | (false )) {
|
3402 | return load()
|
3403 | .then(comp => {
|
3404 | return () => createInnerComp(comp, instance);
|
3405 | })
|
3406 | .catch(err => {
|
3407 | onError(err);
|
3408 | return () => errorComponent
|
3409 | ? createVNode(errorComponent, {
|
3410 | error: err
|
3411 | })
|
3412 | : null;
|
3413 | });
|
3414 | }
|
3415 | const loaded = ref(false);
|
3416 | const error = ref();
|
3417 | const delayed = ref(!!delay);
|
3418 | if (delay) {
|
3419 | setTimeout(() => {
|
3420 | delayed.value = false;
|
3421 | }, delay);
|
3422 | }
|
3423 | if (timeout != null) {
|
3424 | setTimeout(() => {
|
3425 | if (!loaded.value && !error.value) {
|
3426 | const err = new Error(`Async component timed out after ${timeout}ms.`);
|
3427 | onError(err);
|
3428 | error.value = err;
|
3429 | }
|
3430 | }, timeout);
|
3431 | }
|
3432 | load()
|
3433 | .then(() => {
|
3434 | loaded.value = true;
|
3435 | if (instance.parent && isKeepAlive(instance.parent.vnode)) {
|
3436 |
|
3437 |
|
3438 | queueJob(instance.parent.update);
|
3439 | }
|
3440 | })
|
3441 | .catch(err => {
|
3442 | onError(err);
|
3443 | error.value = err;
|
3444 | });
|
3445 | return () => {
|
3446 | if (loaded.value && resolvedComp) {
|
3447 | return createInnerComp(resolvedComp, instance);
|
3448 | }
|
3449 | else if (error.value && errorComponent) {
|
3450 | return createVNode(errorComponent, {
|
3451 | error: error.value
|
3452 | });
|
3453 | }
|
3454 | else if (loadingComponent && !delayed.value) {
|
3455 | return createVNode(loadingComponent);
|
3456 | }
|
3457 | };
|
3458 | }
|
3459 | });
|
3460 | }
|
3461 | function createInnerComp(comp, { vnode: { ref, props, children } }) {
|
3462 | const vnode = createVNode(comp, props, children);
|
3463 |
|
3464 | vnode.ref = ref;
|
3465 | return vnode;
|
3466 | }
|
3467 |
|
3468 | const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
3469 | const KeepAliveImpl = {
|
3470 | name: `KeepAlive`,
|
3471 |
|
3472 |
|
3473 |
|
3474 | __isKeepAlive: true,
|
3475 | props: {
|
3476 | include: [String, RegExp, Array],
|
3477 | exclude: [String, RegExp, Array],
|
3478 | max: [String, Number]
|
3479 | },
|
3480 | setup(props, { slots }) {
|
3481 | const instance = getCurrentInstance();
|
3482 |
|
3483 |
|
3484 |
|
3485 |
|
3486 |
|
3487 | const sharedContext = instance.ctx;
|
3488 |
|
3489 |
|
3490 | if (!sharedContext.renderer) {
|
3491 | return slots.default;
|
3492 | }
|
3493 | const cache = new Map();
|
3494 | const keys = new Set();
|
3495 | let current = null;
|
3496 | {
|
3497 | instance.__v_cache = cache;
|
3498 | }
|
3499 | const parentSuspense = instance.suspense;
|
3500 | const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
|
3501 | const storageContainer = createElement('div');
|
3502 | sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
|
3503 | const instance = vnode.component;
|
3504 | move(vnode, container, anchor, 0 , parentSuspense);
|
3505 |
|
3506 | patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
|
3507 | queuePostRenderEffect(() => {
|
3508 | instance.isDeactivated = false;
|
3509 | if (instance.a) {
|
3510 | invokeArrayFns(instance.a);
|
3511 | }
|
3512 | const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
|
3513 | if (vnodeHook) {
|
3514 | invokeVNodeHook(vnodeHook, instance.parent, vnode);
|
3515 | }
|
3516 | }, parentSuspense);
|
3517 | {
|
3518 |
|
3519 | devtoolsComponentAdded(instance);
|
3520 | }
|
3521 | };
|
3522 | sharedContext.deactivate = (vnode) => {
|
3523 | const instance = vnode.component;
|
3524 | move(vnode, storageContainer, null, 1 , parentSuspense);
|
3525 | queuePostRenderEffect(() => {
|
3526 | if (instance.da) {
|
3527 | invokeArrayFns(instance.da);
|
3528 | }
|
3529 | const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
|
3530 | if (vnodeHook) {
|
3531 | invokeVNodeHook(vnodeHook, instance.parent, vnode);
|
3532 | }
|
3533 | instance.isDeactivated = true;
|
3534 | }, parentSuspense);
|
3535 | {
|
3536 |
|
3537 | devtoolsComponentAdded(instance);
|
3538 | }
|
3539 | };
|
3540 | function unmount(vnode) {
|
3541 |
|
3542 | resetShapeFlag(vnode);
|
3543 | _unmount(vnode, instance, parentSuspense);
|
3544 | }
|
3545 | function pruneCache(filter) {
|
3546 | cache.forEach((vnode, key) => {
|
3547 | const name = getComponentName(vnode.type);
|
3548 | if (name && (!filter || !filter(name))) {
|
3549 | pruneCacheEntry(key);
|
3550 | }
|
3551 | });
|
3552 | }
|
3553 | function pruneCacheEntry(key) {
|
3554 | const cached = cache.get(key);
|
3555 | if (!current || cached.type !== current.type) {
|
3556 | unmount(cached);
|
3557 | }
|
3558 | else if (current) {
|
3559 |
|
3560 |
|
3561 | resetShapeFlag(current);
|
3562 | }
|
3563 | cache.delete(key);
|
3564 | keys.delete(key);
|
3565 | }
|
3566 |
|
3567 | watch(() => [props.include, props.exclude], ([include, exclude]) => {
|
3568 | include && pruneCache(name => matches(include, name));
|
3569 | exclude && pruneCache(name => !matches(exclude, name));
|
3570 | },
|
3571 |
|
3572 | { flush: 'post', deep: true });
|
3573 |
|
3574 | let pendingCacheKey = null;
|
3575 | const cacheSubtree = () => {
|
3576 |
|
3577 | if (pendingCacheKey != null) {
|
3578 | cache.set(pendingCacheKey, getInnerChild(instance.subTree));
|
3579 | }
|
3580 | };
|
3581 | onMounted(cacheSubtree);
|
3582 | onUpdated(cacheSubtree);
|
3583 | onBeforeUnmount(() => {
|
3584 | cache.forEach(cached => {
|
3585 | const { subTree, suspense } = instance;
|
3586 | const vnode = getInnerChild(subTree);
|
3587 | if (cached.type === vnode.type) {
|
3588 |
|
3589 | resetShapeFlag(vnode);
|
3590 |
|
3591 | const da = vnode.component.da;
|
3592 | da && queuePostRenderEffect(da, suspense);
|
3593 | return;
|
3594 | }
|
3595 | unmount(cached);
|
3596 | });
|
3597 | });
|
3598 | return () => {
|
3599 | pendingCacheKey = null;
|
3600 | if (!slots.default) {
|
3601 | return null;
|
3602 | }
|
3603 | const children = slots.default();
|
3604 | const rawVNode = children[0];
|
3605 | if (children.length > 1) {
|
3606 | {
|
3607 | warn$1(`KeepAlive should contain exactly one component child.`);
|
3608 | }
|
3609 | current = null;
|
3610 | return children;
|
3611 | }
|
3612 | else if (!isVNode(rawVNode) ||
|
3613 | (!(rawVNode.shapeFlag & 4 ) &&
|
3614 | !(rawVNode.shapeFlag & 128 ))) {
|
3615 | current = null;
|
3616 | return rawVNode;
|
3617 | }
|
3618 | let vnode = getInnerChild(rawVNode);
|
3619 | const comp = vnode.type;
|
3620 |
|
3621 |
|
3622 | const name = getComponentName(isAsyncWrapper(vnode)
|
3623 | ? vnode.type.__asyncResolved || {}
|
3624 | : comp);
|
3625 | const { include, exclude, max } = props;
|
3626 | if ((include && (!name || !matches(include, name))) ||
|
3627 | (exclude && name && matches(exclude, name))) {
|
3628 | current = vnode;
|
3629 | return rawVNode;
|
3630 | }
|
3631 | const key = vnode.key == null ? comp : vnode.key;
|
3632 | const cachedVNode = cache.get(key);
|
3633 |
|
3634 | if (vnode.el) {
|
3635 | vnode = cloneVNode(vnode);
|
3636 | if (rawVNode.shapeFlag & 128 ) {
|
3637 | rawVNode.ssContent = vnode;
|
3638 | }
|
3639 | }
|
3640 |
|
3641 |
|
3642 |
|
3643 |
|
3644 |
|
3645 | pendingCacheKey = key;
|
3646 | if (cachedVNode) {
|
3647 |
|
3648 | vnode.el = cachedVNode.el;
|
3649 | vnode.component = cachedVNode.component;
|
3650 | if (vnode.transition) {
|
3651 |
|
3652 | setTransitionHooks(vnode, vnode.transition);
|
3653 | }
|
3654 |
|
3655 | vnode.shapeFlag |= 512 ;
|
3656 |
|
3657 | keys.delete(key);
|
3658 | keys.add(key);
|
3659 | }
|
3660 | else {
|
3661 | keys.add(key);
|
3662 |
|
3663 | if (max && keys.size > parseInt(max, 10)) {
|
3664 | pruneCacheEntry(keys.values().next().value);
|
3665 | }
|
3666 | }
|
3667 |
|
3668 | vnode.shapeFlag |= 256 ;
|
3669 | current = vnode;
|
3670 | return rawVNode;
|
3671 | };
|
3672 | }
|
3673 | };
|
3674 |
|
3675 |
|
3676 | const KeepAlive = KeepAliveImpl;
|
3677 | function matches(pattern, name) {
|
3678 | if (isArray(pattern)) {
|
3679 | return pattern.some((p) => matches(p, name));
|
3680 | }
|
3681 | else if (isString(pattern)) {
|
3682 | return pattern.split(',').indexOf(name) > -1;
|
3683 | }
|
3684 | else if (pattern.test) {
|
3685 | return pattern.test(name);
|
3686 | }
|
3687 |
|
3688 | return false;
|
3689 | }
|
3690 | function onActivated(hook, target) {
|
3691 | registerKeepAliveHook(hook, "a" , target);
|
3692 | }
|
3693 | function onDeactivated(hook, target) {
|
3694 | registerKeepAliveHook(hook, "da" , target);
|
3695 | }
|
3696 | function registerKeepAliveHook(hook, type, target = currentInstance) {
|
3697 |
|
3698 |
|
3699 |
|
3700 | const wrappedHook = hook.__wdc ||
|
3701 | (hook.__wdc = () => {
|
3702 |
|
3703 | let current = target;
|
3704 | while (current) {
|
3705 | if (current.isDeactivated) {
|
3706 | return;
|
3707 | }
|
3708 | current = current.parent;
|
3709 | }
|
3710 | hook();
|
3711 | });
|
3712 | injectHook(type, wrappedHook, target);
|
3713 |
|
3714 |
|
3715 |
|
3716 |
|
3717 |
|
3718 | if (target) {
|
3719 | let current = target.parent;
|
3720 | while (current && current.parent) {
|
3721 | if (isKeepAlive(current.parent.vnode)) {
|
3722 | injectToKeepAliveRoot(wrappedHook, type, target, current);
|
3723 | }
|
3724 | current = current.parent;
|
3725 | }
|
3726 | }
|
3727 | }
|
3728 | function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
|
3729 |
|
3730 |
|
3731 | const injected = injectHook(type, hook, keepAliveRoot, true );
|
3732 | onUnmounted(() => {
|
3733 | remove(keepAliveRoot[type], injected);
|
3734 | }, target);
|
3735 | }
|
3736 | function resetShapeFlag(vnode) {
|
3737 | let shapeFlag = vnode.shapeFlag;
|
3738 | if (shapeFlag & 256 ) {
|
3739 | shapeFlag -= 256 ;
|
3740 | }
|
3741 | if (shapeFlag & 512 ) {
|
3742 | shapeFlag -= 512 ;
|
3743 | }
|
3744 | vnode.shapeFlag = shapeFlag;
|
3745 | }
|
3746 | function getInnerChild(vnode) {
|
3747 | return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
|
3748 | }
|
3749 |
|
3750 | function injectHook(type, hook, target = currentInstance, prepend = false) {
|
3751 | if (target) {
|
3752 | const hooks = target[type] || (target[type] = []);
|
3753 |
|
3754 |
|
3755 |
|
3756 | const wrappedHook = hook.__weh ||
|
3757 | (hook.__weh = (...args) => {
|
3758 | if (target.isUnmounted) {
|
3759 | return;
|
3760 | }
|
3761 |
|
3762 |
|
3763 | pauseTracking();
|
3764 |
|
3765 |
|
3766 |
|
3767 | setCurrentInstance(target);
|
3768 | const res = callWithAsyncErrorHandling(hook, target, type, args);
|
3769 | unsetCurrentInstance();
|
3770 | resetTracking();
|
3771 | return res;
|
3772 | });
|
3773 | if (prepend) {
|
3774 | hooks.unshift(wrappedHook);
|
3775 | }
|
3776 | else {
|
3777 | hooks.push(wrappedHook);
|
3778 | }
|
3779 | return wrappedHook;
|
3780 | }
|
3781 | else {
|
3782 | const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
|
3783 | warn$1(`${apiName} is called when there is no active component instance to be ` +
|
3784 | `associated with. ` +
|
3785 | `Lifecycle injection APIs can only be used during execution of setup().` +
|
3786 | (` If you are using async setup(), make sure to register lifecycle ` +
|
3787 | `hooks before the first await statement.`
|
3788 | ));
|
3789 | }
|
3790 | }
|
3791 | const createHook = (lifecycle) => (hook, target = currentInstance) =>
|
3792 |
|
3793 | (!isInSSRComponentSetup || lifecycle === "sp" ) &&
|
3794 | injectHook(lifecycle, hook, target);
|
3795 | const onBeforeMount = createHook("bm" );
|
3796 | const onMounted = createHook("m" );
|
3797 | const onBeforeUpdate = createHook("bu" );
|
3798 | const onUpdated = createHook("u" );
|
3799 | const onBeforeUnmount = createHook("bum" );
|
3800 | const onUnmounted = createHook("um" );
|
3801 | const onServerPrefetch = createHook("sp" );
|
3802 | const onRenderTriggered = createHook("rtg" );
|
3803 | const onRenderTracked = createHook("rtc" );
|
3804 | function onErrorCaptured(hook, target = currentInstance) {
|
3805 | injectHook("ec" , hook, target);
|
3806 | }
|
3807 |
|
3808 | function createDuplicateChecker() {
|
3809 | const cache = Object.create(null);
|
3810 | return (type, key) => {
|
3811 | if (cache[key]) {
|
3812 | warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
|
3813 | }
|
3814 | else {
|
3815 | cache[key] = type;
|
3816 | }
|
3817 | };
|
3818 | }
|
3819 | let shouldCacheAccess = true;
|
3820 | function applyOptions(instance) {
|
3821 | const options = resolveMergedOptions(instance);
|
3822 | const publicThis = instance.proxy;
|
3823 | const ctx = instance.ctx;
|
3824 |
|
3825 | shouldCacheAccess = false;
|
3826 |
|
3827 |
|
3828 | if (options.beforeCreate) {
|
3829 | callHook(options.beforeCreate, instance, "bc" );
|
3830 | }
|
3831 | const {
|
3832 |
|
3833 | data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
|
3834 |
|
3835 | created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
|
3836 |
|
3837 | expose, inheritAttrs,
|
3838 |
|
3839 | components, directives, filters } = options;
|
3840 | const checkDuplicateProperties = createDuplicateChecker() ;
|
3841 | {
|
3842 | const [propsOptions] = instance.propsOptions;
|
3843 | if (propsOptions) {
|
3844 | for (const key in propsOptions) {
|
3845 | checkDuplicateProperties("Props" , key);
|
3846 | }
|
3847 | }
|
3848 | }
|
3849 |
|
3850 |
|
3851 |
|
3852 |
|
3853 |
|
3854 |
|
3855 |
|
3856 | if (injectOptions) {
|
3857 | resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
|
3858 | }
|
3859 | if (methods) {
|
3860 | for (const key in methods) {
|
3861 | const methodHandler = methods[key];
|
3862 | if (isFunction(methodHandler)) {
|
3863 |
|
3864 |
|
3865 |
|
3866 | {
|
3867 | Object.defineProperty(ctx, key, {
|
3868 | value: methodHandler.bind(publicThis),
|
3869 | configurable: true,
|
3870 | enumerable: true,
|
3871 | writable: true
|
3872 | });
|
3873 | }
|
3874 | {
|
3875 | checkDuplicateProperties("Methods" , key);
|
3876 | }
|
3877 | }
|
3878 | else {
|
3879 | warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
|
3880 | `Did you reference the function correctly?`);
|
3881 | }
|
3882 | }
|
3883 | }
|
3884 | if (dataOptions) {
|
3885 | if (!isFunction(dataOptions)) {
|
3886 | warn$1(`The data option must be a function. ` +
|
3887 | `Plain object usage is no longer supported.`);
|
3888 | }
|
3889 | const data = dataOptions.call(publicThis, publicThis);
|
3890 | if (isPromise(data)) {
|
3891 | warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
|
3892 | `intend to perform data fetching before component renders, use ` +
|
3893 | `async setup() + <Suspense>.`);
|
3894 | }
|
3895 | if (!isObject(data)) {
|
3896 | warn$1(`data() should return an object.`);
|
3897 | }
|
3898 | else {
|
3899 | instance.data = reactive(data);
|
3900 | {
|
3901 | for (const key in data) {
|
3902 | checkDuplicateProperties("Data" , key);
|
3903 |
|
3904 | if (key[0] !== '$' && key[0] !== '_') {
|
3905 | Object.defineProperty(ctx, key, {
|
3906 | configurable: true,
|
3907 | enumerable: true,
|
3908 | get: () => data[key],
|
3909 | set: NOOP
|
3910 | });
|
3911 | }
|
3912 | }
|
3913 | }
|
3914 | }
|
3915 | }
|
3916 | // state initialization complete at this point - start caching access
|
3917 | shouldCacheAccess = true;
|
3918 | if (computedOptions) {
|
3919 | for (const key in computedOptions) {
|
3920 | const opt = computedOptions[key];
|
3921 | const get = isFunction(opt)
|
3922 | ? opt.bind(publicThis, publicThis)
|
3923 | : isFunction(opt.get)
|
3924 | ? opt.get.bind(publicThis, publicThis)
|
3925 | : NOOP;
|
3926 | if (get === NOOP) {
|
3927 | warn$1(`Computed property "${key}" has no getter.`);
|
3928 | }
|
3929 | const set = !isFunction(opt) && isFunction(opt.set)
|
3930 | ? opt.set.bind(publicThis)
|
3931 | : () => {
|
3932 | warn$1(`Write operation failed: computed property "${key}" is readonly.`);
|
3933 | }
|
3934 | ;
|
3935 | const c = computed({
|
3936 | get,
|
3937 | set
|
3938 | });
|
3939 | Object.defineProperty(ctx, key, {
|
3940 | enumerable: true,
|
3941 | configurable: true,
|
3942 | get: () => c.value,
|
3943 | set: v => (c.value = v)
|
3944 | });
|
3945 | {
|
3946 | checkDuplicateProperties("Computed" , key);
|
3947 | }
|
3948 | }
|
3949 | }
|
3950 | if (watchOptions) {
|
3951 | for (const key in watchOptions) {
|
3952 | createWatcher(watchOptions[key], ctx, publicThis, key);
|
3953 | }
|
3954 | }
|
3955 | if (provideOptions) {
|
3956 | const provides = isFunction(provideOptions)
|
3957 | ? provideOptions.call(publicThis)
|
3958 | : provideOptions;
|
3959 | Reflect.ownKeys(provides).forEach(key => {
|
3960 | provide(key, provides[key]);
|
3961 | });
|
3962 | }
|
3963 | if (created) {
|
3964 | callHook(created, instance, "c" );
|
3965 | }
|
3966 | function registerLifecycleHook(register, hook) {
|
3967 | if (isArray(hook)) {
|
3968 | hook.forEach(_hook => register(_hook.bind(publicThis)));
|
3969 | }
|
3970 | else if (hook) {
|
3971 | register(hook.bind(publicThis));
|
3972 | }
|
3973 | }
|
3974 | registerLifecycleHook(onBeforeMount, beforeMount);
|
3975 | registerLifecycleHook(onMounted, mounted);
|
3976 | registerLifecycleHook(onBeforeUpdate, beforeUpdate);
|
3977 | registerLifecycleHook(onUpdated, updated);
|
3978 | registerLifecycleHook(onActivated, activated);
|
3979 | registerLifecycleHook(onDeactivated, deactivated);
|
3980 | registerLifecycleHook(onErrorCaptured, errorCaptured);
|
3981 | registerLifecycleHook(onRenderTracked, renderTracked);
|
3982 | registerLifecycleHook(onRenderTriggered, renderTriggered);
|
3983 | registerLifecycleHook(onBeforeUnmount, beforeUnmount);
|
3984 | registerLifecycleHook(onUnmounted, unmounted);
|
3985 | registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
3986 | if (isArray(expose)) {
|
3987 | if (expose.length) {
|
3988 | const exposed = instance.exposed || (instance.exposed = {});
|
3989 | expose.forEach(key => {
|
3990 | Object.defineProperty(exposed, key, {
|
3991 | get: () => publicThis[key],
|
3992 | set: val => (publicThis[key] = val)
|
3993 | });
|
3994 | });
|
3995 | }
|
3996 | else if (!instance.exposed) {
|
3997 | instance.exposed = {};
|
3998 | }
|
3999 | }
|
4000 |
|
4001 |
|
4002 | if (render && instance.render === NOOP) {
|
4003 | instance.render = render;
|
4004 | }
|
4005 | if (inheritAttrs != null) {
|
4006 | instance.inheritAttrs = inheritAttrs;
|
4007 | }
|
4008 |
|
4009 | if (components)
|
4010 | instance.components = components;
|
4011 | if (directives)
|
4012 | instance.directives = directives;
|
4013 | }
|
4014 | function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
|
4015 | if (isArray(injectOptions)) {
|
4016 | injectOptions = normalizeInject(injectOptions);
|
4017 | }
|
4018 | for (const key in injectOptions) {
|
4019 | const opt = injectOptions[key];
|
4020 | let injected;
|
4021 | if (isObject(opt)) {
|
4022 | if ('default' in opt) {
|
4023 | injected = inject(opt.from || key, opt.default, true );
|
4024 | }
|
4025 | else {
|
4026 | injected = inject(opt.from || key);
|
4027 | }
|
4028 | }
|
4029 | else {
|
4030 | injected = inject(opt);
|
4031 | }
|
4032 | if (isRef(injected)) {
|
4033 |
|
4034 | if (unwrapRef) {
|
4035 | Object.defineProperty(ctx, key, {
|
4036 | enumerable: true,
|
4037 | configurable: true,
|
4038 | get: () => injected.value,
|
4039 | set: v => (injected.value = v)
|
4040 | });
|
4041 | }
|
4042 | else {
|
4043 | {
|
4044 | warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
|
4045 | `and no longer needs \`.value\` in the next minor release. ` +
|
4046 | `To opt-in to the new behavior now, ` +
|
4047 | `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
|
4048 | `temporary and will not be needed in the future.)`);
|
4049 | }
|
4050 | ctx[key] = injected;
|
4051 | }
|
4052 | }
|
4053 | else {
|
4054 | ctx[key] = injected;
|
4055 | }
|
4056 | {
|
4057 | checkDuplicateProperties("Inject" , key);
|
4058 | }
|
4059 | }
|
4060 | }
|
4061 | function callHook(hook, instance, type) {
|
4062 | callWithAsyncErrorHandling(isArray(hook)
|
4063 | ? hook.map(h => h.bind(instance.proxy))
|
4064 | : hook.bind(instance.proxy), instance, type);
|
4065 | }
|
4066 | function createWatcher(raw, ctx, publicThis, key) {
|
4067 | const getter = key.includes('.')
|
4068 | ? createPathGetter(publicThis, key)
|
4069 | : () => publicThis[key];
|
4070 | if (isString(raw)) {
|
4071 | const handler = ctx[raw];
|
4072 | if (isFunction(handler)) {
|
4073 | watch(getter, handler);
|
4074 | }
|
4075 | else {
|
4076 | warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
|
4077 | }
|
4078 | }
|
4079 | else if (isFunction(raw)) {
|
4080 | watch(getter, raw.bind(publicThis));
|
4081 | }
|
4082 | else if (isObject(raw)) {
|
4083 | if (isArray(raw)) {
|
4084 | raw.forEach(r => createWatcher(r, ctx, publicThis, key));
|
4085 | }
|
4086 | else {
|
4087 | const handler = isFunction(raw.handler)
|
4088 | ? raw.handler.bind(publicThis)
|
4089 | : ctx[raw.handler];
|
4090 | if (isFunction(handler)) {
|
4091 | watch(getter, handler, raw);
|
4092 | }
|
4093 | else {
|
4094 | warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
|
4095 | }
|
4096 | }
|
4097 | }
|
4098 | else {
|
4099 | warn$1(`Invalid watch option: "${key}"`, raw);
|
4100 | }
|
4101 | }
|
4102 |
|
4103 |
|
4104 |
|
4105 |
|
4106 |
|
4107 | function resolveMergedOptions(instance) {
|
4108 | const base = instance.type;
|
4109 | const { mixins, extends: extendsOptions } = base;
|
4110 | const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
|
4111 | const cached = cache.get(base);
|
4112 | let resolved;
|
4113 | if (cached) {
|
4114 | resolved = cached;
|
4115 | }
|
4116 | else if (!globalMixins.length && !mixins && !extendsOptions) {
|
4117 | {
|
4118 | resolved = base;
|
4119 | }
|
4120 | }
|
4121 | else {
|
4122 | resolved = {};
|
4123 | if (globalMixins.length) {
|
4124 | globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
|
4125 | }
|
4126 | mergeOptions(resolved, base, optionMergeStrategies);
|
4127 | }
|
4128 | cache.set(base, resolved);
|
4129 | return resolved;
|
4130 | }
|
4131 | function mergeOptions(to, from, strats, asMixin = false) {
|
4132 | const { mixins, extends: extendsOptions } = from;
|
4133 | if (extendsOptions) {
|
4134 | mergeOptions(to, extendsOptions, strats, true);
|
4135 | }
|
4136 | if (mixins) {
|
4137 | mixins.forEach((m) => mergeOptions(to, m, strats, true));
|
4138 | }
|
4139 | for (const key in from) {
|
4140 | if (asMixin && key === 'expose') {
|
4141 | warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
|
4142 | `It should only be declared in the base component itself.`);
|
4143 | }
|
4144 | else {
|
4145 | const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
|
4146 | to[key] = strat ? strat(to[key], from[key]) : from[key];
|
4147 | }
|
4148 | }
|
4149 | return to;
|
4150 | }
|
4151 | const internalOptionMergeStrats = {
|
4152 | data: mergeDataFn,
|
4153 | props: mergeObjectOptions,
|
4154 | emits: mergeObjectOptions,
|
4155 |
|
4156 | methods: mergeObjectOptions,
|
4157 | computed: mergeObjectOptions,
|
4158 |
|
4159 | beforeCreate: mergeAsArray,
|
4160 | created: mergeAsArray,
|
4161 | beforeMount: mergeAsArray,
|
4162 | mounted: mergeAsArray,
|
4163 | beforeUpdate: mergeAsArray,
|
4164 | updated: mergeAsArray,
|
4165 | beforeDestroy: mergeAsArray,
|
4166 | beforeUnmount: mergeAsArray,
|
4167 | destroyed: mergeAsArray,
|
4168 | unmounted: mergeAsArray,
|
4169 | activated: mergeAsArray,
|
4170 | deactivated: mergeAsArray,
|
4171 | errorCaptured: mergeAsArray,
|
4172 | serverPrefetch: mergeAsArray,
|
4173 |
|
4174 | components: mergeObjectOptions,
|
4175 | directives: mergeObjectOptions,
|
4176 |
|
4177 | watch: mergeWatchOptions,
|
4178 |
|
4179 | provide: mergeDataFn,
|
4180 | inject: mergeInject
|
4181 | };
|
4182 | function mergeDataFn(to, from) {
|
4183 | if (!from) {
|
4184 | return to;
|
4185 | }
|
4186 | if (!to) {
|
4187 | return from;
|
4188 | }
|
4189 | return function mergedDataFn() {
|
4190 | return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
|
4191 | };
|
4192 | }
|
4193 | function mergeInject(to, from) {
|
4194 | return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
4195 | }
|
4196 | function normalizeInject(raw) {
|
4197 | if (isArray(raw)) {
|
4198 | const res = {};
|
4199 | for (let i = 0; i < raw.length; i++) {
|
4200 | res[raw[i]] = raw[i];
|
4201 | }
|
4202 | return res;
|
4203 | }
|
4204 | return raw;
|
4205 | }
|
4206 | function mergeAsArray(to, from) {
|
4207 | return to ? [...new Set([].concat(to, from))] : from;
|
4208 | }
|
4209 | function mergeObjectOptions(to, from) {
|
4210 | return to ? extend(extend(Object.create(null), to), from) : from;
|
4211 | }
|
4212 | function mergeWatchOptions(to, from) {
|
4213 | if (!to)
|
4214 | return from;
|
4215 | if (!from)
|
4216 | return to;
|
4217 | const merged = extend(Object.create(null), to);
|
4218 | for (const key in from) {
|
4219 | merged[key] = mergeAsArray(to[key], from[key]);
|
4220 | }
|
4221 | return merged;
|
4222 | }
|
4223 |
|
4224 | function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
|
4225 | isSSR = false) {
|
4226 | const props = {};
|
4227 | const attrs = {};
|
4228 | def(attrs, InternalObjectKey, 1);
|
4229 | instance.propsDefaults = Object.create(null);
|
4230 | setFullProps(instance, rawProps, props, attrs);
|
4231 |
|
4232 | for (const key in instance.propsOptions[0]) {
|
4233 | if (!(key in props)) {
|
4234 | props[key] = undefined;
|
4235 | }
|
4236 | }
|
4237 |
|
4238 | {
|
4239 | validateProps(rawProps || {}, props, instance);
|
4240 | }
|
4241 | if (isStateful) {
|
4242 |
|
4243 | instance.props = isSSR ? props : shallowReactive(props);
|
4244 | }
|
4245 | else {
|
4246 | if (!instance.type.props) {
|
4247 |
|
4248 | instance.props = attrs;
|
4249 | }
|
4250 | else {
|
4251 |
|
4252 | instance.props = props;
|
4253 | }
|
4254 | }
|
4255 | instance.attrs = attrs;
|
4256 | }
|
4257 | function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
4258 | const { props, attrs, vnode: { patchFlag } } = instance;
|
4259 | const rawCurrentProps = toRaw(props);
|
4260 | const [options] = instance.propsOptions;
|
4261 | let hasAttrsChanged = false;
|
4262 | if (
|
4263 |
|
4264 |
|
4265 |
|
4266 | !((instance.type.__hmrId ||
|
4267 | (instance.parent && instance.parent.type.__hmrId))) &&
|
4268 | (optimized || patchFlag > 0) &&
|
4269 | !(patchFlag & 16 )) {
|
4270 | if (patchFlag & 8 ) {
|
4271 |
|
4272 |
|
4273 | const propsToUpdate = instance.vnode.dynamicProps;
|
4274 | for (let i = 0; i < propsToUpdate.length; i++) {
|
4275 | let key = propsToUpdate[i];
|
4276 |
|
4277 | const value = rawProps[key];
|
4278 | if (options) {
|
4279 |
|
4280 |
|
4281 | if (hasOwn(attrs, key)) {
|
4282 | if (value !== attrs[key]) {
|
4283 | attrs[key] = value;
|
4284 | hasAttrsChanged = true;
|
4285 | }
|
4286 | }
|
4287 | else {
|
4288 | const camelizedKey = camelize(key);
|
4289 | props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false );
|
4290 | }
|
4291 | }
|
4292 | else {
|
4293 | if (value !== attrs[key]) {
|
4294 | attrs[key] = value;
|
4295 | hasAttrsChanged = true;
|
4296 | }
|
4297 | }
|
4298 | }
|
4299 | }
|
4300 | }
|
4301 | else {
|
4302 |
|
4303 | if (setFullProps(instance, rawProps, props, attrs)) {
|
4304 | hasAttrsChanged = true;
|
4305 | }
|
4306 |
|
4307 |
|
4308 | let kebabKey;
|
4309 | for (const key in rawCurrentProps) {
|
4310 | if (!rawProps ||
|
4311 |
|
4312 | (!hasOwn(rawProps, key) &&
|
4313 |
|
4314 |
|
4315 | ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
|
4316 | if (options) {
|
4317 | if (rawPrevProps &&
|
4318 |
|
4319 | (rawPrevProps[key] !== undefined ||
|
4320 |
|
4321 | rawPrevProps[kebabKey] !== undefined)) {
|
4322 | props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true );
|
4323 | }
|
4324 | }
|
4325 | else {
|
4326 | delete props[key];
|
4327 | }
|
4328 | }
|
4329 | }
|
4330 |
|
4331 |
|
4332 | if (attrs !== rawCurrentProps) {
|
4333 | for (const key in attrs) {
|
4334 | if (!rawProps || !hasOwn(rawProps, key)) {
|
4335 | delete attrs[key];
|
4336 | hasAttrsChanged = true;
|
4337 | }
|
4338 | }
|
4339 | }
|
4340 | }
|
4341 |
|
4342 | if (hasAttrsChanged) {
|
4343 | trigger(instance, "set" , '$attrs');
|
4344 | }
|
4345 | {
|
4346 | validateProps(rawProps || {}, props, instance);
|
4347 | }
|
4348 | }
|
4349 | function setFullProps(instance, rawProps, props, attrs) {
|
4350 | const [options, needCastKeys] = instance.propsOptions;
|
4351 | let hasAttrsChanged = false;
|
4352 | let rawCastValues;
|
4353 | if (rawProps) {
|
4354 | for (let key in rawProps) {
|
4355 |
|
4356 | if (isReservedProp(key)) {
|
4357 | continue;
|
4358 | }
|
4359 | const value = rawProps[key];
|
4360 |
|
4361 |
|
4362 | let camelKey;
|
4363 | if (options && hasOwn(options, (camelKey = camelize(key)))) {
|
4364 | if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
4365 | props[camelKey] = value;
|
4366 | }
|
4367 | else {
|
4368 | (rawCastValues || (rawCastValues = {}))[camelKey] = value;
|
4369 | }
|
4370 | }
|
4371 | else if (!isEmitListener(instance.emitsOptions, key)) {
|
4372 | if (value !== attrs[key]) {
|
4373 | attrs[key] = value;
|
4374 | hasAttrsChanged = true;
|
4375 | }
|
4376 | }
|
4377 | }
|
4378 | }
|
4379 | if (needCastKeys) {
|
4380 | const rawCurrentProps = toRaw(props);
|
4381 | const castValues = rawCastValues || EMPTY_OBJ;
|
4382 | for (let i = 0; i < needCastKeys.length; i++) {
|
4383 | const key = needCastKeys[i];
|
4384 | props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
|
4385 | }
|
4386 | }
|
4387 | return hasAttrsChanged;
|
4388 | }
|
4389 | function resolvePropValue(options, props, key, value, instance, isAbsent) {
|
4390 | const opt = options[key];
|
4391 | if (opt != null) {
|
4392 | const hasDefault = hasOwn(opt, 'default');
|
4393 |
|
4394 | if (hasDefault && value === undefined) {
|
4395 | const defaultValue = opt.default;
|
4396 | if (opt.type !== Function && isFunction(defaultValue)) {
|
4397 | const { propsDefaults } = instance;
|
4398 | if (key in propsDefaults) {
|
4399 | value = propsDefaults[key];
|
4400 | }
|
4401 | else {
|
4402 | setCurrentInstance(instance);
|
4403 | value = propsDefaults[key] = defaultValue.call(null, props);
|
4404 | unsetCurrentInstance();
|
4405 | }
|
4406 | }
|
4407 | else {
|
4408 | value = defaultValue;
|
4409 | }
|
4410 | }
|
4411 |
|
4412 | if (opt[0 ]) {
|
4413 | if (isAbsent && !hasDefault) {
|
4414 | value = false;
|
4415 | }
|
4416 | else if (opt[1 ] &&
|
4417 | (value === '' || value === hyphenate(key))) {
|
4418 | value = true;
|
4419 | }
|
4420 | }
|
4421 | }
|
4422 | return value;
|
4423 | }
|
4424 | function normalizePropsOptions(comp, appContext, asMixin = false) {
|
4425 | const cache = appContext.propsCache;
|
4426 | const cached = cache.get(comp);
|
4427 | if (cached) {
|
4428 | return cached;
|
4429 | }
|
4430 | const raw = comp.props;
|
4431 | const normalized = {};
|
4432 | const needCastKeys = [];
|
4433 |
|
4434 | let hasExtends = false;
|
4435 | if (!isFunction(comp)) {
|
4436 | const extendProps = (raw) => {
|
4437 | hasExtends = true;
|
4438 | const [props, keys] = normalizePropsOptions(raw, appContext, true);
|
4439 | extend(normalized, props);
|
4440 | if (keys)
|
4441 | needCastKeys.push(...keys);
|
4442 | };
|
4443 | if (!asMixin && appContext.mixins.length) {
|
4444 | appContext.mixins.forEach(extendProps);
|
4445 | }
|
4446 | if (comp.extends) {
|
4447 | extendProps(comp.extends);
|
4448 | }
|
4449 | if (comp.mixins) {
|
4450 | comp.mixins.forEach(extendProps);
|
4451 | }
|
4452 | }
|
4453 | if (!raw && !hasExtends) {
|
4454 | cache.set(comp, EMPTY_ARR);
|
4455 | return EMPTY_ARR;
|
4456 | }
|
4457 | if (isArray(raw)) {
|
4458 | for (let i = 0; i < raw.length; i++) {
|
4459 | if (!isString(raw[i])) {
|
4460 | warn$1(`props must be strings when using array syntax.`, raw[i]);
|
4461 | }
|
4462 | const normalizedKey = camelize(raw[i]);
|
4463 | if (validatePropName(normalizedKey)) {
|
4464 | normalized[normalizedKey] = EMPTY_OBJ;
|
4465 | }
|
4466 | }
|
4467 | }
|
4468 | else if (raw) {
|
4469 | if (!isObject(raw)) {
|
4470 | warn$1(`invalid props options`, raw);
|
4471 | }
|
4472 | for (const key in raw) {
|
4473 | const normalizedKey = camelize(key);
|
4474 | if (validatePropName(normalizedKey)) {
|
4475 | const opt = raw[key];
|
4476 | const prop = (normalized[normalizedKey] =
|
4477 | isArray(opt) || isFunction(opt) ? { type: opt } : opt);
|
4478 | if (prop) {
|
4479 | const booleanIndex = getTypeIndex(Boolean, prop.type);
|
4480 | const stringIndex = getTypeIndex(String, prop.type);
|
4481 | prop[0 ] = booleanIndex > -1;
|
4482 | prop[1 ] =
|
4483 | stringIndex < 0 || booleanIndex < stringIndex;
|
4484 |
|
4485 | if (booleanIndex > -1 || hasOwn(prop, 'default')) {
|
4486 | needCastKeys.push(normalizedKey);
|
4487 | }
|
4488 | }
|
4489 | }
|
4490 | }
|
4491 | }
|
4492 | const res = [normalized, needCastKeys];
|
4493 | cache.set(comp, res);
|
4494 | return res;
|
4495 | }
|
4496 | function validatePropName(key) {
|
4497 | if (key[0] !== '$') {
|
4498 | return true;
|
4499 | }
|
4500 | else {
|
4501 | warn$1(`Invalid prop name: "${key}" is a reserved property.`);
|
4502 | }
|
4503 | return false;
|
4504 | }
|
4505 |
|
4506 |
|
4507 | function getType(ctor) {
|
4508 | const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
|
4509 | return match ? match[1] : ctor === null ? 'null' : '';
|
4510 | }
|
4511 | function isSameType(a, b) {
|
4512 | return getType(a) === getType(b);
|
4513 | }
|
4514 | function getTypeIndex(type, expectedTypes) {
|
4515 | if (isArray(expectedTypes)) {
|
4516 | return expectedTypes.findIndex(t => isSameType(t, type));
|
4517 | }
|
4518 | else if (isFunction(expectedTypes)) {
|
4519 | return isSameType(expectedTypes, type) ? 0 : -1;
|
4520 | }
|
4521 | return -1;
|
4522 | }
|
4523 |
|
4524 |
|
4525 |
|
4526 | function validateProps(rawProps, props, instance) {
|
4527 | const resolvedValues = toRaw(props);
|
4528 | const options = instance.propsOptions[0];
|
4529 | for (const key in options) {
|
4530 | let opt = options[key];
|
4531 | if (opt == null)
|
4532 | continue;
|
4533 | validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
|
4534 | }
|
4535 | }
|
4536 |
|
4537 |
|
4538 |
|
4539 | function validateProp(name, value, prop, isAbsent) {
|
4540 | const { type, required, validator } = prop;
|
4541 |
|
4542 | if (required && isAbsent) {
|
4543 | warn$1('Missing required prop: "' + name + '"');
|
4544 | return;
|
4545 | }
|
4546 |
|
4547 | if (value == null && !prop.required) {
|
4548 | return;
|
4549 | }
|
4550 |
|
4551 | if (type != null && type !== true) {
|
4552 | let isValid = false;
|
4553 | const types = isArray(type) ? type : [type];
|
4554 | const expectedTypes = [];
|
4555 |
|
4556 | for (let i = 0; i < types.length && !isValid; i++) {
|
4557 | const { valid, expectedType } = assertType(value, types[i]);
|
4558 | expectedTypes.push(expectedType || '');
|
4559 | isValid = valid;
|
4560 | }
|
4561 | if (!isValid) {
|
4562 | warn$1(getInvalidTypeMessage(name, value, expectedTypes));
|
4563 | return;
|
4564 | }
|
4565 | }
|
4566 |
|
4567 | if (validator && !validator(value)) {
|
4568 | warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
|
4569 | }
|
4570 | }
|
4571 | const isSimpleType = makeMap('String,Number,Boolean,Function,Symbol,BigInt');
|
4572 |
|
4573 |
|
4574 |
|
4575 | function assertType(value, type) {
|
4576 | let valid;
|
4577 | const expectedType = getType(type);
|
4578 | if (isSimpleType(expectedType)) {
|
4579 | const t = typeof value;
|
4580 | valid = t === expectedType.toLowerCase();
|
4581 |
|
4582 | if (!valid && t === 'object') {
|
4583 | valid = value instanceof type;
|
4584 | }
|
4585 | }
|
4586 | else if (expectedType === 'Object') {
|
4587 | valid = isObject(value);
|
4588 | }
|
4589 | else if (expectedType === 'Array') {
|
4590 | valid = isArray(value);
|
4591 | }
|
4592 | else if (expectedType === 'null') {
|
4593 | valid = value === null;
|
4594 | }
|
4595 | else {
|
4596 | valid = value instanceof type;
|
4597 | }
|
4598 | return {
|
4599 | valid,
|
4600 | expectedType
|
4601 | };
|
4602 | }
|
4603 |
|
4604 |
|
4605 |
|
4606 | function getInvalidTypeMessage(name, value, expectedTypes) {
|
4607 | let message = `Invalid prop: type check failed for prop "${name}".` +
|
4608 | ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
|
4609 | const expectedType = expectedTypes[0];
|
4610 | const receivedType = toRawType(value);
|
4611 | const expectedValue = styleValue(value, expectedType);
|
4612 | const receivedValue = styleValue(value, receivedType);
|
4613 |
|
4614 | if (expectedTypes.length === 1 &&
|
4615 | isExplicable(expectedType) &&
|
4616 | !isBoolean(expectedType, receivedType)) {
|
4617 | message += ` with value ${expectedValue}`;
|
4618 | }
|
4619 | message += `, got ${receivedType} `;
|
4620 |
|
4621 | if (isExplicable(receivedType)) {
|
4622 | message += `with value ${receivedValue}.`;
|
4623 | }
|
4624 | return message;
|
4625 | }
|
4626 |
|
4627 |
|
4628 |
|
4629 | function styleValue(value, type) {
|
4630 | if (type === 'String') {
|
4631 | return `"${value}"`;
|
4632 | }
|
4633 | else if (type === 'Number') {
|
4634 | return `${Number(value)}`;
|
4635 | }
|
4636 | else {
|
4637 | return `${value}`;
|
4638 | }
|
4639 | }
|
4640 |
|
4641 |
|
4642 |
|
4643 | function isExplicable(type) {
|
4644 | const explicitTypes = ['string', 'number', 'boolean'];
|
4645 | return explicitTypes.some(elem => type.toLowerCase() === elem);
|
4646 | }
|
4647 |
|
4648 |
|
4649 |
|
4650 | function isBoolean(...args) {
|
4651 | return args.some(elem => elem.toLowerCase() === 'boolean');
|
4652 | }
|
4653 |
|
4654 | const isInternalKey = (key) => key[0] === '_' || key === '$stable';
|
4655 | const normalizeSlotValue = (value) => isArray(value)
|
4656 | ? value.map(normalizeVNode)
|
4657 | : [normalizeVNode(value)];
|
4658 | const normalizeSlot = (key, rawSlot, ctx) => {
|
4659 | const normalized = withCtx((...args) => {
|
4660 | if (currentInstance) {
|
4661 | warn$1(`Slot "${key}" invoked outside of the render function: ` +
|
4662 | `this will not track dependencies used in the slot. ` +
|
4663 | `Invoke the slot function inside the render function instead.`);
|
4664 | }
|
4665 | return normalizeSlotValue(rawSlot(...args));
|
4666 | }, ctx);
|
4667 | normalized._c = false;
|
4668 | return normalized;
|
4669 | };
|
4670 | const normalizeObjectSlots = (rawSlots, slots, instance) => {
|
4671 | const ctx = rawSlots._ctx;
|
4672 | for (const key in rawSlots) {
|
4673 | if (isInternalKey(key))
|
4674 | continue;
|
4675 | const value = rawSlots[key];
|
4676 | if (isFunction(value)) {
|
4677 | slots[key] = normalizeSlot(key, value, ctx);
|
4678 | }
|
4679 | else if (value != null) {
|
4680 | {
|
4681 | warn$1(`Non-function value encountered for slot "${key}". ` +
|
4682 | `Prefer function slots for better performance.`);
|
4683 | }
|
4684 | const normalized = normalizeSlotValue(value);
|
4685 | slots[key] = () => normalized;
|
4686 | }
|
4687 | }
|
4688 | };
|
4689 | const normalizeVNodeSlots = (instance, children) => {
|
4690 | if (!isKeepAlive(instance.vnode) &&
|
4691 | !(false )) {
|
4692 | warn$1(`Non-function value encountered for default slot. ` +
|
4693 | `Prefer function slots for better performance.`);
|
4694 | }
|
4695 | const normalized = normalizeSlotValue(children);
|
4696 | instance.slots.default = () => normalized;
|
4697 | };
|
4698 | const initSlots = (instance, children) => {
|
4699 | if (instance.vnode.shapeFlag & 32 ) {
|
4700 | const type = children._;
|
4701 | if (type) {
|
4702 |
|
4703 |
|
4704 | instance.slots = toRaw(children);
|
4705 |
|
4706 | def(children, '_', type);
|
4707 | }
|
4708 | else {
|
4709 | normalizeObjectSlots(children, (instance.slots = {}));
|
4710 | }
|
4711 | }
|
4712 | else {
|
4713 | instance.slots = {};
|
4714 | if (children) {
|
4715 | normalizeVNodeSlots(instance, children);
|
4716 | }
|
4717 | }
|
4718 | def(instance.slots, InternalObjectKey, 1);
|
4719 | };
|
4720 | const updateSlots = (instance, children, optimized) => {
|
4721 | const { vnode, slots } = instance;
|
4722 | let needDeletionCheck = true;
|
4723 | let deletionComparisonTarget = EMPTY_OBJ;
|
4724 | if (vnode.shapeFlag & 32 ) {
|
4725 | const type = children._;
|
4726 | if (type) {
|
4727 |
|
4728 | if (isHmrUpdating) {
|
4729 |
|
4730 |
|
4731 | extend(slots, children);
|
4732 | }
|
4733 | else if (optimized && type === 1 ) {
|
4734 |
|
4735 |
|
4736 | needDeletionCheck = false;
|
4737 | }
|
4738 | else {
|
4739 |
|
4740 |
|
4741 | extend(slots, children);
|
4742 |
|
4743 |
|
4744 |
|
4745 |
|
4746 | if (!optimized && type === 1 ) {
|
4747 | delete slots._;
|
4748 | }
|
4749 | }
|
4750 | }
|
4751 | else {
|
4752 | needDeletionCheck = !children.$stable;
|
4753 | normalizeObjectSlots(children, slots);
|
4754 | }
|
4755 | deletionComparisonTarget = children;
|
4756 | }
|
4757 | else if (children) {
|
4758 |
|
4759 | normalizeVNodeSlots(instance, children);
|
4760 | deletionComparisonTarget = { default: 1 };
|
4761 | }
|
4762 |
|
4763 | if (needDeletionCheck) {
|
4764 | for (const key in slots) {
|
4765 | if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
|
4766 | delete slots[key];
|
4767 | }
|
4768 | }
|
4769 | }
|
4770 | };
|
4771 |
|
4772 |
|
4773 |
|
4774 |
|
4775 |
|
4776 |
|
4777 |
|
4778 |
|
4779 |
|
4780 |
|
4781 |
|
4782 |
|
4783 |
|
4784 | const isBuiltInDirective = makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
|
4785 | function validateDirectiveName(name) {
|
4786 | if (isBuiltInDirective(name)) {
|
4787 | warn$1('Do not use built-in directive ids as custom directive id: ' + name);
|
4788 | }
|
4789 | }
|
4790 |
|
4791 |
|
4792 |
|
4793 | function withDirectives(vnode, directives) {
|
4794 | const internalInstance = currentRenderingInstance;
|
4795 | if (internalInstance === null) {
|
4796 | warn$1(`withDirectives can only be used inside render functions.`);
|
4797 | return vnode;
|
4798 | }
|
4799 | const instance = internalInstance.proxy;
|
4800 | const bindings = vnode.dirs || (vnode.dirs = []);
|
4801 | for (let i = 0; i < directives.length; i++) {
|
4802 | let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
|
4803 | if (isFunction(dir)) {
|
4804 | dir = {
|
4805 | mounted: dir,
|
4806 | updated: dir
|
4807 | };
|
4808 | }
|
4809 | if (dir.deep) {
|
4810 | traverse(value);
|
4811 | }
|
4812 | bindings.push({
|
4813 | dir,
|
4814 | instance,
|
4815 | value,
|
4816 | oldValue: void 0,
|
4817 | arg,
|
4818 | modifiers
|
4819 | });
|
4820 | }
|
4821 | return vnode;
|
4822 | }
|
4823 | function invokeDirectiveHook(vnode, prevVNode, instance, name) {
|
4824 | const bindings = vnode.dirs;
|
4825 | const oldBindings = prevVNode && prevVNode.dirs;
|
4826 | for (let i = 0; i < bindings.length; i++) {
|
4827 | const binding = bindings[i];
|
4828 | if (oldBindings) {
|
4829 | binding.oldValue = oldBindings[i].value;
|
4830 | }
|
4831 | let hook = binding.dir[name];
|
4832 | if (hook) {
|
4833 |
|
4834 |
|
4835 | pauseTracking();
|
4836 | callWithAsyncErrorHandling(hook, instance, 8 , [
|
4837 | vnode.el,
|
4838 | binding,
|
4839 | vnode,
|
4840 | prevVNode
|
4841 | ]);
|
4842 | resetTracking();
|
4843 | }
|
4844 | }
|
4845 | }
|
4846 |
|
4847 | function createAppContext() {
|
4848 | return {
|
4849 | app: null,
|
4850 | config: {
|
4851 | isNativeTag: NO,
|
4852 | performance: false,
|
4853 | globalProperties: {},
|
4854 | optionMergeStrategies: {},
|
4855 | errorHandler: undefined,
|
4856 | warnHandler: undefined,
|
4857 | compilerOptions: {}
|
4858 | },
|
4859 | mixins: [],
|
4860 | components: {},
|
4861 | directives: {},
|
4862 | provides: Object.create(null),
|
4863 | optionsCache: new WeakMap(),
|
4864 | propsCache: new WeakMap(),
|
4865 | emitsCache: new WeakMap()
|
4866 | };
|
4867 | }
|
4868 | let uid = 0;
|
4869 | function createAppAPI(render, hydrate) {
|
4870 | return function createApp(rootComponent, rootProps = null) {
|
4871 | if (rootProps != null && !isObject(rootProps)) {
|
4872 | warn$1(`root props passed to app.mount() must be an object.`);
|
4873 | rootProps = null;
|
4874 | }
|
4875 | const context = createAppContext();
|
4876 | const installedPlugins = new Set();
|
4877 | let isMounted = false;
|
4878 | const app = (context.app = {
|
4879 | _uid: uid++,
|
4880 | _component: rootComponent,
|
4881 | _props: rootProps,
|
4882 | _container: null,
|
4883 | _context: context,
|
4884 | _instance: null,
|
4885 | version,
|
4886 | get config() {
|
4887 | return context.config;
|
4888 | },
|
4889 | set config(v) {
|
4890 | {
|
4891 | warn$1(`app.config cannot be replaced. Modify individual options instead.`);
|
4892 | }
|
4893 | },
|
4894 | use(plugin, ...options) {
|
4895 | if (installedPlugins.has(plugin)) {
|
4896 | warn$1(`Plugin has already been applied to target app.`);
|
4897 | }
|
4898 | else if (plugin && isFunction(plugin.install)) {
|
4899 | installedPlugins.add(plugin);
|
4900 | plugin.install(app, ...options);
|
4901 | }
|
4902 | else if (isFunction(plugin)) {
|
4903 | installedPlugins.add(plugin);
|
4904 | plugin(app, ...options);
|
4905 | }
|
4906 | else {
|
4907 | warn$1(`A plugin must either be a function or an object with an "install" ` +
|
4908 | `function.`);
|
4909 | }
|
4910 | return app;
|
4911 | },
|
4912 | mixin(mixin) {
|
4913 | {
|
4914 | if (!context.mixins.includes(mixin)) {
|
4915 | context.mixins.push(mixin);
|
4916 | }
|
4917 | else {
|
4918 | warn$1('Mixin has already been applied to target app' +
|
4919 | (mixin.name ? `: ${mixin.name}` : ''));
|
4920 | }
|
4921 | }
|
4922 | return app;
|
4923 | },
|
4924 | component(name, component) {
|
4925 | {
|
4926 | validateComponentName(name, context.config);
|
4927 | }
|
4928 | if (!component) {
|
4929 | return context.components[name];
|
4930 | }
|
4931 | if (context.components[name]) {
|
4932 | warn$1(`Component "${name}" has already been registered in target app.`);
|
4933 | }
|
4934 | context.components[name] = component;
|
4935 | return app;
|
4936 | },
|
4937 | directive(name, directive) {
|
4938 | {
|
4939 | validateDirectiveName(name);
|
4940 | }
|
4941 | if (!directive) {
|
4942 | return context.directives[name];
|
4943 | }
|
4944 | if (context.directives[name]) {
|
4945 | warn$1(`Directive "${name}" has already been registered in target app.`);
|
4946 | }
|
4947 | context.directives[name] = directive;
|
4948 | return app;
|
4949 | },
|
4950 | mount(rootContainer, isHydrate, isSVG) {
|
4951 | if (!isMounted) {
|
4952 | const vnode = createVNode(rootComponent, rootProps);
|
4953 |
|
4954 |
|
4955 | vnode.appContext = context;
|
4956 |
|
4957 | {
|
4958 | context.reload = () => {
|
4959 | render(cloneVNode(vnode), rootContainer, isSVG);
|
4960 | };
|
4961 | }
|
4962 | if (isHydrate && hydrate) {
|
4963 | hydrate(vnode, rootContainer);
|
4964 | }
|
4965 | else {
|
4966 | render(vnode, rootContainer, isSVG);
|
4967 | }
|
4968 | isMounted = true;
|
4969 | app._container = rootContainer;
|
4970 | rootContainer.__vue_app__ = app;
|
4971 | {
|
4972 | app._instance = vnode.component;
|
4973 | devtoolsInitApp(app, version);
|
4974 | }
|
4975 | return vnode.component.proxy;
|
4976 | }
|
4977 | else {
|
4978 | warn$1(`App has already been mounted.\n` +
|
4979 | `If you want to remount the same app, move your app creation logic ` +
|
4980 | `into a factory function and create fresh app instances for each ` +
|
4981 | `mount - e.g. \`const createMyApp = () => createApp(App)\``);
|
4982 | }
|
4983 | },
|
4984 | unmount() {
|
4985 | if (isMounted) {
|
4986 | render(null, app._container);
|
4987 | {
|
4988 | app._instance = null;
|
4989 | devtoolsUnmountApp(app);
|
4990 | }
|
4991 | delete app._container.__vue_app__;
|
4992 | }
|
4993 | else {
|
4994 | warn$1(`Cannot unmount an app that is not mounted.`);
|
4995 | }
|
4996 | },
|
4997 | provide(key, value) {
|
4998 | if (key in context.provides) {
|
4999 | warn$1(`App already provides property with key "${String(key)}". ` +
|
5000 | `It will be overwritten with the new value.`);
|
5001 | }
|
5002 |
|
5003 |
|
5004 | context.provides[key] = value;
|
5005 | return app;
|
5006 | }
|
5007 | });
|
5008 | return app;
|
5009 | };
|
5010 | }
|
5011 |
|
5012 | let hasMismatch = false;
|
5013 | const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
|
5014 | const isComment = (node) => node.nodeType === 8 ;
|
5015 |
|
5016 |
|
5017 |
|
5018 |
|
5019 |
|
5020 | function createHydrationFunctions(rendererInternals) {
|
5021 | const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
|
5022 | const hydrate = (vnode, container) => {
|
5023 | if (!container.hasChildNodes()) {
|
5024 | warn$1(`Attempting to hydrate existing markup but container is empty. ` +
|
5025 | `Performing full mount instead.`);
|
5026 | patch(null, vnode, container);
|
5027 | flushPostFlushCbs();
|
5028 | return;
|
5029 | }
|
5030 | hasMismatch = false;
|
5031 | hydrateNode(container.firstChild, vnode, null, null, null);
|
5032 | flushPostFlushCbs();
|
5033 | if (hasMismatch && !false) {
|
5034 |
|
5035 | console.error(`Hydration completed but contains mismatches.`);
|
5036 | }
|
5037 | };
|
5038 | const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
|
5039 | const isFragmentStart = isComment(node) && node.data === '[';
|
5040 | const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
|
5041 | const { type, ref, shapeFlag } = vnode;
|
5042 | const domType = node.nodeType;
|
5043 | vnode.el = node;
|
5044 | let nextNode = null;
|
5045 | switch (type) {
|
5046 | case Text:
|
5047 | if (domType !== 3 ) {
|
5048 | nextNode = onMismatch();
|
5049 | }
|
5050 | else {
|
5051 | if (node.data !== vnode.children) {
|
5052 | hasMismatch = true;
|
5053 | warn$1(`Hydration text mismatch:` +
|
5054 | `\n- Client: ${JSON.stringify(node.data)}` +
|
5055 | `\n- Server: ${JSON.stringify(vnode.children)}`);
|
5056 | node.data = vnode.children;
|
5057 | }
|
5058 | nextNode = nextSibling(node);
|
5059 | }
|
5060 | break;
|
5061 | case Comment:
|
5062 | if (domType !== 8 || isFragmentStart) {
|
5063 | nextNode = onMismatch();
|
5064 | }
|
5065 | else {
|
5066 | nextNode = nextSibling(node);
|
5067 | }
|
5068 | break;
|
5069 | case Static:
|
5070 | if (domType !== 1 ) {
|
5071 | nextNode = onMismatch();
|
5072 | }
|
5073 | else {
|
5074 |
|
5075 | nextNode = node;
|
5076 |
|
5077 |
|
5078 | const needToAdoptContent = !vnode.children.length;
|
5079 | for (let i = 0; i < vnode.staticCount; i++) {
|
5080 | if (needToAdoptContent)
|
5081 | vnode.children += nextNode.outerHTML;
|
5082 | if (i === vnode.staticCount - 1) {
|
5083 | vnode.anchor = nextNode;
|
5084 | }
|
5085 | nextNode = nextSibling(nextNode);
|
5086 | }
|
5087 | return nextNode;
|
5088 | }
|
5089 | break;
|
5090 | case Fragment:
|
5091 | if (!isFragmentStart) {
|
5092 | nextNode = onMismatch();
|
5093 | }
|
5094 | else {
|
5095 | nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
|
5096 | }
|
5097 | break;
|
5098 | default:
|
5099 | if (shapeFlag & 1 ) {
|
5100 | if (domType !== 1 ||
|
5101 | vnode.type.toLowerCase() !==
|
5102 | node.tagName.toLowerCase()) {
|
5103 | nextNode = onMismatch();
|
5104 | }
|
5105 | else {
|
5106 | nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
|
5107 | }
|
5108 | }
|
5109 | else if (shapeFlag & 6 ) {
|
5110 |
|
5111 |
|
5112 |
|
5113 | vnode.slotScopeIds = slotScopeIds;
|
5114 | const container = parentNode(node);
|
5115 | mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
|
5116 |
|
5117 |
|
5118 |
|
5119 | nextNode = isFragmentStart
|
5120 | ? locateClosingAsyncAnchor(node)
|
5121 | : nextSibling(node);
|
5122 |
|
5123 |
|
5124 |
|
5125 |
|
5126 | if (isAsyncWrapper(vnode)) {
|
5127 | let subTree;
|
5128 | if (isFragmentStart) {
|
5129 | subTree = createVNode(Fragment);
|
5130 | subTree.anchor = nextNode
|
5131 | ? nextNode.previousSibling
|
5132 | : container.lastChild;
|
5133 | }
|
5134 | else {
|
5135 | subTree =
|
5136 | node.nodeType === 3 ? createTextVNode('') : createVNode('div');
|
5137 | }
|
5138 | subTree.el = node;
|
5139 | vnode.component.subTree = subTree;
|
5140 | }
|
5141 | }
|
5142 | else if (shapeFlag & 64 ) {
|
5143 | if (domType !== 8 ) {
|
5144 | nextNode = onMismatch();
|
5145 | }
|
5146 | else {
|
5147 | nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
|
5148 | }
|
5149 | }
|
5150 | else if (shapeFlag & 128 ) {
|
5151 | nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
|
5152 | }
|
5153 | else {
|
5154 | warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
|
5155 | }
|
5156 | }
|
5157 | if (ref != null) {
|
5158 | setRef(ref, null, parentSuspense, vnode);
|
5159 | }
|
5160 | return nextNode;
|
5161 | };
|
5162 | const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
5163 | optimized = optimized || !!vnode.dynamicChildren;
|
5164 | const { type, props, patchFlag, shapeFlag, dirs } = vnode;
|
5165 |
|
5166 |
|
5167 | const forcePatchValue = (type === 'input' && dirs) || type === 'option';
|
5168 |
|
5169 | if (forcePatchValue || patchFlag !== -1 ) {
|
5170 | if (dirs) {
|
5171 | invokeDirectiveHook(vnode, null, parentComponent, 'created');
|
5172 | }
|
5173 |
|
5174 | if (props) {
|
5175 | if (forcePatchValue ||
|
5176 | !optimized ||
|
5177 | patchFlag & (16 | 32 )) {
|
5178 | for (const key in props) {
|
5179 | if ((forcePatchValue && key.endsWith('value')) ||
|
5180 | (isOn(key) && !isReservedProp(key))) {
|
5181 | patchProp(el, key, null, props[key]);
|
5182 | }
|
5183 | }
|
5184 | }
|
5185 | else if (props.onClick) {
|
5186 |
|
5187 |
|
5188 | patchProp(el, 'onClick', null, props.onClick);
|
5189 | }
|
5190 | }
|
5191 |
|
5192 | let vnodeHooks;
|
5193 | if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
|
5194 | invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
5195 | }
|
5196 | if (dirs) {
|
5197 | invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
|
5198 | }
|
5199 | if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
|
5200 | queueEffectWithSuspense(() => {
|
5201 | vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
5202 | dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
|
5203 | }, parentSuspense);
|
5204 | }
|
5205 |
|
5206 | if (shapeFlag & 16 &&
|
5207 |
|
5208 | !(props && (props.innerHTML || props.textContent))) {
|
5209 | let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
|
5210 | let hasWarned = false;
|
5211 | while (next) {
|
5212 | hasMismatch = true;
|
5213 | if (!hasWarned) {
|
5214 | warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
|
5215 | `server rendered element contains more child nodes than client vdom.`);
|
5216 | hasWarned = true;
|
5217 | }
|
5218 |
|
5219 | const cur = next;
|
5220 | next = next.nextSibling;
|
5221 | remove(cur);
|
5222 | }
|
5223 | }
|
5224 | else if (shapeFlag & 8 ) {
|
5225 | if (el.textContent !== vnode.children) {
|
5226 | hasMismatch = true;
|
5227 | warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
|
5228 | `- Client: ${el.textContent}\n` +
|
5229 | `- Server: ${vnode.children}`);
|
5230 | el.textContent = vnode.children;
|
5231 | }
|
5232 | }
|
5233 | }
|
5234 | return el.nextSibling;
|
5235 | };
|
5236 | const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
5237 | optimized = optimized || !!parentVNode.dynamicChildren;
|
5238 | const children = parentVNode.children;
|
5239 | const l = children.length;
|
5240 | let hasWarned = false;
|
5241 | for (let i = 0; i < l; i++) {
|
5242 | const vnode = optimized
|
5243 | ? children[i]
|
5244 | : (children[i] = normalizeVNode(children[i]));
|
5245 | if (node) {
|
5246 | node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
|
5247 | }
|
5248 | else if (vnode.type === Text && !vnode.children) {
|
5249 | continue;
|
5250 | }
|
5251 | else {
|
5252 | hasMismatch = true;
|
5253 | if (!hasWarned) {
|
5254 | warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
|
5255 | `server rendered element contains fewer child nodes than client vdom.`);
|
5256 | hasWarned = true;
|
5257 | }
|
5258 |
|
5259 | patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
|
5260 | }
|
5261 | }
|
5262 | return node;
|
5263 | };
|
5264 | const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
5265 | const { slotScopeIds: fragmentSlotScopeIds } = vnode;
|
5266 | if (fragmentSlotScopeIds) {
|
5267 | slotScopeIds = slotScopeIds
|
5268 | ? slotScopeIds.concat(fragmentSlotScopeIds)
|
5269 | : fragmentSlotScopeIds;
|
5270 | }
|
5271 | const container = parentNode(node);
|
5272 | const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
|
5273 | if (next && isComment(next) && next.data === ']') {
|
5274 | return nextSibling((vnode.anchor = next));
|
5275 | }
|
5276 | else {
|
5277 |
|
5278 |
|
5279 | hasMismatch = true;
|
5280 |
|
5281 | insert((vnode.anchor = createComment(`]`)), container, next);
|
5282 | return next;
|
5283 | }
|
5284 | };
|
5285 | const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
|
5286 | hasMismatch = true;
|
5287 | warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3
|
5288 | ? `(text)`
|
5289 | : isComment(node) && node.data === '['
|
5290 | ? `(start of fragment)`
|
5291 | : ``);
|
5292 | vnode.el = null;
|
5293 | if (isFragment) {
|
5294 |
|
5295 | const end = locateClosingAsyncAnchor(node);
|
5296 | while (true) {
|
5297 | const next = nextSibling(node);
|
5298 | if (next && next !== end) {
|
5299 | remove(next);
|
5300 | }
|
5301 | else {
|
5302 | break;
|
5303 | }
|
5304 | }
|
5305 | }
|
5306 | const next = nextSibling(node);
|
5307 | const container = parentNode(node);
|
5308 | remove(node);
|
5309 | patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
|
5310 | return next;
|
5311 | };
|
5312 | const locateClosingAsyncAnchor = (node) => {
|
5313 | let match = 0;
|
5314 | while (node) {
|
5315 | node = nextSibling(node);
|
5316 | if (node && isComment(node)) {
|
5317 | if (node.data === '[')
|
5318 | match++;
|
5319 | if (node.data === ']') {
|
5320 | if (match === 0) {
|
5321 | return nextSibling(node);
|
5322 | }
|
5323 | else {
|
5324 | match--;
|
5325 | }
|
5326 | }
|
5327 | }
|
5328 | }
|
5329 | return node;
|
5330 | };
|
5331 | return [hydrate, hydrateNode];
|
5332 | }
|
5333 |
|
5334 | let supported;
|
5335 | let perf;
|
5336 | function startMeasure(instance, type) {
|
5337 | if (instance.appContext.config.performance && isSupported()) {
|
5338 | perf.mark(`vue-${type}-${instance.uid}`);
|
5339 | }
|
5340 | {
|
5341 | devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
|
5342 | }
|
5343 | }
|
5344 | function endMeasure(instance, type) {
|
5345 | if (instance.appContext.config.performance && isSupported()) {
|
5346 | const startTag = `vue-${type}-${instance.uid}`;
|
5347 | const endTag = startTag + `:end`;
|
5348 | perf.mark(endTag);
|
5349 | perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
|
5350 | perf.clearMarks(startTag);
|
5351 | perf.clearMarks(endTag);
|
5352 | }
|
5353 | {
|
5354 | devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
|
5355 | }
|
5356 | }
|
5357 | function isSupported() {
|
5358 | if (supported !== undefined) {
|
5359 | return supported;
|
5360 | }
|
5361 |
|
5362 | if (typeof window !== 'undefined' && window.performance) {
|
5363 | supported = true;
|
5364 | perf = window.performance;
|
5365 | }
|
5366 | else {
|
5367 | supported = false;
|
5368 | }
|
5369 |
|
5370 | return supported;
|
5371 | }
|
5372 |
|
5373 | const queuePostRenderEffect = queueEffectWithSuspense
|
5374 | ;
|
5375 |
|
5376 |
|
5377 |
|
5378 |
|
5379 |
|
5380 |
|
5381 |
|
5382 |
|
5383 |
|
5384 |
|
5385 |
|
5386 |
|
5387 |
|
5388 |
|
5389 |
|
5390 | function createRenderer(options) {
|
5391 | return baseCreateRenderer(options);
|
5392 | }
|
5393 |
|
5394 |
|
5395 |
|
5396 | function createHydrationRenderer(options) {
|
5397 | return baseCreateRenderer(options, createHydrationFunctions);
|
5398 | }
|
5399 |
|
5400 | function baseCreateRenderer(options, createHydrationFns) {
|
5401 | {
|
5402 | const target = getGlobalThis();
|
5403 | target.__VUE__ = true;
|
5404 | setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__);
|
5405 | }
|
5406 | 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;
|
5407 |
|
5408 |
|
5409 | const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
|
5410 | if (n1 === n2) {
|
5411 | return;
|
5412 | }
|
5413 |
|
5414 | if (n1 && !isSameVNodeType(n1, n2)) {
|
5415 | anchor = getNextHostNode(n1);
|
5416 | unmount(n1, parentComponent, parentSuspense, true);
|
5417 | n1 = null;
|
5418 | }
|
5419 | if (n2.patchFlag === -2 ) {
|
5420 | optimized = false;
|
5421 | n2.dynamicChildren = null;
|
5422 | }
|
5423 | const { type, ref, shapeFlag } = n2;
|
5424 | switch (type) {
|
5425 | case Text:
|
5426 | processText(n1, n2, container, anchor);
|
5427 | break;
|
5428 | case Comment:
|
5429 | processCommentNode(n1, n2, container, anchor);
|
5430 | break;
|
5431 | case Static:
|
5432 | if (n1 == null) {
|
5433 | mountStaticNode(n2, container, anchor, isSVG);
|
5434 | }
|
5435 | else {
|
5436 | patchStaticNode(n1, n2, container, isSVG);
|
5437 | }
|
5438 | break;
|
5439 | case Fragment:
|
5440 | processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5441 | break;
|
5442 | default:
|
5443 | if (shapeFlag & 1 ) {
|
5444 | processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5445 | }
|
5446 | else if (shapeFlag & 6 ) {
|
5447 | processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5448 | }
|
5449 | else if (shapeFlag & 64 ) {
|
5450 | type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
|
5451 | }
|
5452 | else if (shapeFlag & 128 ) {
|
5453 | type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
|
5454 | }
|
5455 | else {
|
5456 | warn$1('Invalid VNode type:', type, `(${typeof type})`);
|
5457 | }
|
5458 | }
|
5459 |
|
5460 | if (ref != null && parentComponent) {
|
5461 | setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
|
5462 | }
|
5463 | };
|
5464 | const processText = (n1, n2, container, anchor) => {
|
5465 | if (n1 == null) {
|
5466 | hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
|
5467 | }
|
5468 | else {
|
5469 | const el = (n2.el = n1.el);
|
5470 | if (n2.children !== n1.children) {
|
5471 | hostSetText(el, n2.children);
|
5472 | }
|
5473 | }
|
5474 | };
|
5475 | const processCommentNode = (n1, n2, container, anchor) => {
|
5476 | if (n1 == null) {
|
5477 | hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
|
5478 | }
|
5479 | else {
|
5480 |
|
5481 | n2.el = n1.el;
|
5482 | }
|
5483 | };
|
5484 | const mountStaticNode = (n2, container, anchor, isSVG) => {
|
5485 | [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
|
5486 | };
|
5487 | |
5488 |
|
5489 |
|
5490 | const patchStaticNode = (n1, n2, container, isSVG) => {
|
5491 |
|
5492 | if (n2.children !== n1.children) {
|
5493 | const anchor = hostNextSibling(n1.anchor);
|
5494 |
|
5495 | removeStaticNode(n1);
|
5496 | [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
|
5497 | }
|
5498 | else {
|
5499 | n2.el = n1.el;
|
5500 | n2.anchor = n1.anchor;
|
5501 | }
|
5502 | };
|
5503 | const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
|
5504 | let next;
|
5505 | while (el && el !== anchor) {
|
5506 | next = hostNextSibling(el);
|
5507 | hostInsert(el, container, nextSibling);
|
5508 | el = next;
|
5509 | }
|
5510 | hostInsert(anchor, container, nextSibling);
|
5511 | };
|
5512 | const removeStaticNode = ({ el, anchor }) => {
|
5513 | let next;
|
5514 | while (el && el !== anchor) {
|
5515 | next = hostNextSibling(el);
|
5516 | hostRemove(el);
|
5517 | el = next;
|
5518 | }
|
5519 | hostRemove(anchor);
|
5520 | };
|
5521 | const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5522 | isSVG = isSVG || n2.type === 'svg';
|
5523 | if (n1 == null) {
|
5524 | mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5525 | }
|
5526 | else {
|
5527 | patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5528 | }
|
5529 | };
|
5530 | const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5531 | let el;
|
5532 | let vnodeHook;
|
5533 | const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
|
5534 | {
|
5535 | el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
|
5536 |
|
5537 |
|
5538 | if (shapeFlag & 8 ) {
|
5539 | hostSetElementText(el, vnode.children);
|
5540 | }
|
5541 | else if (shapeFlag & 16 ) {
|
5542 | mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
|
5543 | }
|
5544 | if (dirs) {
|
5545 | invokeDirectiveHook(vnode, null, parentComponent, 'created');
|
5546 | }
|
5547 |
|
5548 | if (props) {
|
5549 | for (const key in props) {
|
5550 | if (key !== 'value' && !isReservedProp(key)) {
|
5551 | hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
|
5552 | }
|
5553 | }
|
5554 | |
5555 |
|
5556 |
|
5557 |
|
5558 |
|
5559 |
|
5560 |
|
5561 |
|
5562 |
|
5563 | if ('value' in props) {
|
5564 | hostPatchProp(el, 'value', null, props.value);
|
5565 | }
|
5566 | if ((vnodeHook = props.onVnodeBeforeMount)) {
|
5567 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
5568 | }
|
5569 | }
|
5570 |
|
5571 | setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
|
5572 | }
|
5573 | {
|
5574 | Object.defineProperty(el, '__vnode', {
|
5575 | value: vnode,
|
5576 | enumerable: false
|
5577 | });
|
5578 | Object.defineProperty(el, '__vueParentComponent', {
|
5579 | value: parentComponent,
|
5580 | enumerable: false
|
5581 | });
|
5582 | }
|
5583 | if (dirs) {
|
5584 | invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
|
5585 | }
|
5586 |
|
5587 |
|
5588 | const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
|
5589 | transition &&
|
5590 | !transition.persisted;
|
5591 | if (needCallTransitionHooks) {
|
5592 | transition.beforeEnter(el);
|
5593 | }
|
5594 | hostInsert(el, container, anchor);
|
5595 | if ((vnodeHook = props && props.onVnodeMounted) ||
|
5596 | needCallTransitionHooks ||
|
5597 | dirs) {
|
5598 | queuePostRenderEffect(() => {
|
5599 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
5600 | needCallTransitionHooks && transition.enter(el);
|
5601 | dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
|
5602 | }, parentSuspense);
|
5603 | }
|
5604 | };
|
5605 | const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
|
5606 | if (scopeId) {
|
5607 | hostSetScopeId(el, scopeId);
|
5608 | }
|
5609 | if (slotScopeIds) {
|
5610 | for (let i = 0; i < slotScopeIds.length; i++) {
|
5611 | hostSetScopeId(el, slotScopeIds[i]);
|
5612 | }
|
5613 | }
|
5614 | if (parentComponent) {
|
5615 | let subTree = parentComponent.subTree;
|
5616 | if (subTree.patchFlag > 0 &&
|
5617 | subTree.patchFlag & 2048 ) {
|
5618 | subTree =
|
5619 | filterSingleRoot(subTree.children) || subTree;
|
5620 | }
|
5621 | if (vnode === subTree) {
|
5622 | const parentVNode = parentComponent.vnode;
|
5623 | setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
|
5624 | }
|
5625 | }
|
5626 | };
|
5627 | const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
|
5628 | for (let i = start; i < children.length; i++) {
|
5629 | const child = (children[i] = optimized
|
5630 | ? cloneIfMounted(children[i])
|
5631 | : normalizeVNode(children[i]));
|
5632 | patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5633 | }
|
5634 | };
|
5635 | const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5636 | const el = (n2.el = n1.el);
|
5637 | let { patchFlag, dynamicChildren, dirs } = n2;
|
5638 |
|
5639 |
|
5640 | patchFlag |= n1.patchFlag & 16 ;
|
5641 | const oldProps = n1.props || EMPTY_OBJ;
|
5642 | const newProps = n2.props || EMPTY_OBJ;
|
5643 | let vnodeHook;
|
5644 | if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
|
5645 | invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
5646 | }
|
5647 | if (dirs) {
|
5648 | invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
|
5649 | }
|
5650 | if (isHmrUpdating) {
|
5651 |
|
5652 | patchFlag = 0;
|
5653 | optimized = false;
|
5654 | dynamicChildren = null;
|
5655 | }
|
5656 | const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
|
5657 | if (dynamicChildren) {
|
5658 | patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
|
5659 | if (parentComponent && parentComponent.type.__hmrId) {
|
5660 | traverseStaticChildren(n1, n2);
|
5661 | }
|
5662 | }
|
5663 | else if (!optimized) {
|
5664 |
|
5665 | patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
|
5666 | }
|
5667 | if (patchFlag > 0) {
|
5668 |
|
5669 |
|
5670 |
|
5671 |
|
5672 | if (patchFlag & 16 ) {
|
5673 |
|
5674 | patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
|
5675 | }
|
5676 | else {
|
5677 |
|
5678 |
|
5679 | if (patchFlag & 2 ) {
|
5680 | if (oldProps.class !== newProps.class) {
|
5681 | hostPatchProp(el, 'class', null, newProps.class, isSVG);
|
5682 | }
|
5683 | }
|
5684 |
|
5685 |
|
5686 | if (patchFlag & 4 ) {
|
5687 | hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
|
5688 | }
|
5689 |
|
5690 |
|
5691 |
|
5692 |
|
5693 |
|
5694 |
|
5695 | if (patchFlag & 8 ) {
|
5696 |
|
5697 | const propsToUpdate = n2.dynamicProps;
|
5698 | for (let i = 0; i < propsToUpdate.length; i++) {
|
5699 | const key = propsToUpdate[i];
|
5700 | const prev = oldProps[key];
|
5701 | const next = newProps[key];
|
5702 |
|
5703 | if (next !== prev || key === 'value') {
|
5704 | hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
|
5705 | }
|
5706 | }
|
5707 | }
|
5708 | }
|
5709 |
|
5710 |
|
5711 | if (patchFlag & 1 ) {
|
5712 | if (n1.children !== n2.children) {
|
5713 | hostSetElementText(el, n2.children);
|
5714 | }
|
5715 | }
|
5716 | }
|
5717 | else if (!optimized && dynamicChildren == null) {
|
5718 |
|
5719 | patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
|
5720 | }
|
5721 | if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
|
5722 | queuePostRenderEffect(() => {
|
5723 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
5724 | dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
|
5725 | }, parentSuspense);
|
5726 | }
|
5727 | };
|
5728 |
|
5729 | const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
|
5730 | for (let i = 0; i < newChildren.length; i++) {
|
5731 | const oldVNode = oldChildren[i];
|
5732 | const newVNode = newChildren[i];
|
5733 |
|
5734 | const container =
|
5735 |
|
5736 |
|
5737 | oldVNode.el &&
|
5738 |
|
5739 |
|
5740 | (oldVNode.type === Fragment ||
|
5741 |
|
5742 |
|
5743 | !isSameVNodeType(oldVNode, newVNode) ||
|
5744 |
|
5745 | oldVNode.shapeFlag & (6 | 64 ))
|
5746 | ? hostParentNode(oldVNode.el)
|
5747 | :
|
5748 |
|
5749 | fallbackContainer;
|
5750 | patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
|
5751 | }
|
5752 | };
|
5753 | const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
|
5754 | if (oldProps !== newProps) {
|
5755 | for (const key in newProps) {
|
5756 |
|
5757 | if (isReservedProp(key))
|
5758 | continue;
|
5759 | const next = newProps[key];
|
5760 | const prev = oldProps[key];
|
5761 |
|
5762 | if (next !== prev && key !== 'value') {
|
5763 | hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
|
5764 | }
|
5765 | }
|
5766 | if (oldProps !== EMPTY_OBJ) {
|
5767 | for (const key in oldProps) {
|
5768 | if (!isReservedProp(key) && !(key in newProps)) {
|
5769 | hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
|
5770 | }
|
5771 | }
|
5772 | }
|
5773 | if ('value' in newProps) {
|
5774 | hostPatchProp(el, 'value', oldProps.value, newProps.value);
|
5775 | }
|
5776 | }
|
5777 | };
|
5778 | const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5779 | const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
|
5780 | const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
|
5781 | let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
|
5782 | if (isHmrUpdating) {
|
5783 |
|
5784 | patchFlag = 0;
|
5785 | optimized = false;
|
5786 | dynamicChildren = null;
|
5787 | }
|
5788 |
|
5789 | if (fragmentSlotScopeIds) {
|
5790 | slotScopeIds = slotScopeIds
|
5791 | ? slotScopeIds.concat(fragmentSlotScopeIds)
|
5792 | : fragmentSlotScopeIds;
|
5793 | }
|
5794 | if (n1 == null) {
|
5795 | hostInsert(fragmentStartAnchor, container, anchor);
|
5796 | hostInsert(fragmentEndAnchor, container, anchor);
|
5797 |
|
5798 |
|
5799 |
|
5800 | mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5801 | }
|
5802 | else {
|
5803 | if (patchFlag > 0 &&
|
5804 | patchFlag & 64 &&
|
5805 | dynamicChildren &&
|
5806 |
|
5807 |
|
5808 | n1.dynamicChildren) {
|
5809 |
|
5810 |
|
5811 | patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
|
5812 | if (parentComponent && parentComponent.type.__hmrId) {
|
5813 | traverseStaticChildren(n1, n2);
|
5814 | }
|
5815 | else if (
|
5816 |
|
5817 |
|
5818 |
|
5819 |
|
5820 | n2.key != null ||
|
5821 | (parentComponent && n2 === parentComponent.subTree)) {
|
5822 | traverseStaticChildren(n1, n2, true );
|
5823 | }
|
5824 | }
|
5825 | else {
|
5826 |
|
5827 |
|
5828 |
|
5829 |
|
5830 | patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5831 | }
|
5832 | }
|
5833 | };
|
5834 | const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5835 | n2.slotScopeIds = slotScopeIds;
|
5836 | if (n1 == null) {
|
5837 | if (n2.shapeFlag & 512 ) {
|
5838 | parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
|
5839 | }
|
5840 | else {
|
5841 | mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
|
5842 | }
|
5843 | }
|
5844 | else {
|
5845 | updateComponent(n1, n2, optimized);
|
5846 | }
|
5847 | };
|
5848 | const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
|
5849 | const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
|
5850 | if (instance.type.__hmrId) {
|
5851 | registerHMR(instance);
|
5852 | }
|
5853 | {
|
5854 | pushWarningContext(initialVNode);
|
5855 | startMeasure(instance, `mount`);
|
5856 | }
|
5857 |
|
5858 | if (isKeepAlive(initialVNode)) {
|
5859 | instance.ctx.renderer = internals;
|
5860 | }
|
5861 |
|
5862 | {
|
5863 | {
|
5864 | startMeasure(instance, `init`);
|
5865 | }
|
5866 | setupComponent(instance);
|
5867 | {
|
5868 | endMeasure(instance, `init`);
|
5869 | }
|
5870 | }
|
5871 |
|
5872 |
|
5873 | if (instance.asyncDep) {
|
5874 | parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
|
5875 |
|
5876 |
|
5877 | if (!initialVNode.el) {
|
5878 | const placeholder = (instance.subTree = createVNode(Comment));
|
5879 | processCommentNode(null, placeholder, container, anchor);
|
5880 | }
|
5881 | return;
|
5882 | }
|
5883 | setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
|
5884 | {
|
5885 | popWarningContext();
|
5886 | endMeasure(instance, `mount`);
|
5887 | }
|
5888 | };
|
5889 | const updateComponent = (n1, n2, optimized) => {
|
5890 | const instance = (n2.component = n1.component);
|
5891 | if (shouldUpdateComponent(n1, n2, optimized)) {
|
5892 | if (instance.asyncDep &&
|
5893 | !instance.asyncResolved) {
|
5894 |
|
5895 |
|
5896 | {
|
5897 | pushWarningContext(n2);
|
5898 | }
|
5899 | updateComponentPreRender(instance, n2, optimized);
|
5900 | {
|
5901 | popWarningContext();
|
5902 | }
|
5903 | return;
|
5904 | }
|
5905 | else {
|
5906 |
|
5907 | instance.next = n2;
|
5908 |
|
5909 |
|
5910 | invalidateJob(instance.update);
|
5911 |
|
5912 | instance.update();
|
5913 | }
|
5914 | }
|
5915 | else {
|
5916 |
|
5917 | n2.component = n1.component;
|
5918 | n2.el = n1.el;
|
5919 | instance.vnode = n2;
|
5920 | }
|
5921 | };
|
5922 | const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
|
5923 | const componentUpdateFn = () => {
|
5924 | if (!instance.isMounted) {
|
5925 | let vnodeHook;
|
5926 | const { el, props } = initialVNode;
|
5927 | const { bm, m, parent } = instance;
|
5928 | const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
|
5929 | effect.allowRecurse = false;
|
5930 |
|
5931 | if (bm) {
|
5932 | invokeArrayFns(bm);
|
5933 | }
|
5934 |
|
5935 | if (!isAsyncWrapperVNode &&
|
5936 | (vnodeHook = props && props.onVnodeBeforeMount)) {
|
5937 | invokeVNodeHook(vnodeHook, parent, initialVNode);
|
5938 | }
|
5939 | effect.allowRecurse = true;
|
5940 | if (el && hydrateNode) {
|
5941 |
|
5942 | const hydrateSubTree = () => {
|
5943 | {
|
5944 | startMeasure(instance, `render`);
|
5945 | }
|
5946 | instance.subTree = renderComponentRoot(instance);
|
5947 | {
|
5948 | endMeasure(instance, `render`);
|
5949 | }
|
5950 | {
|
5951 | startMeasure(instance, `hydrate`);
|
5952 | }
|
5953 | hydrateNode(el, instance.subTree, instance, parentSuspense, null);
|
5954 | {
|
5955 | endMeasure(instance, `hydrate`);
|
5956 | }
|
5957 | };
|
5958 | if (isAsyncWrapperVNode) {
|
5959 | initialVNode.type.__asyncLoader().then(
|
5960 |
|
5961 |
|
5962 |
|
5963 |
|
5964 | () => !instance.isUnmounted && hydrateSubTree());
|
5965 | }
|
5966 | else {
|
5967 | hydrateSubTree();
|
5968 | }
|
5969 | }
|
5970 | else {
|
5971 | {
|
5972 | startMeasure(instance, `render`);
|
5973 | }
|
5974 | const subTree = (instance.subTree = renderComponentRoot(instance));
|
5975 | {
|
5976 | endMeasure(instance, `render`);
|
5977 | }
|
5978 | {
|
5979 | startMeasure(instance, `patch`);
|
5980 | }
|
5981 | patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
|
5982 | {
|
5983 | endMeasure(instance, `patch`);
|
5984 | }
|
5985 | initialVNode.el = subTree.el;
|
5986 | }
|
5987 |
|
5988 | if (m) {
|
5989 | queuePostRenderEffect(m, parentSuspense);
|
5990 | }
|
5991 |
|
5992 | if (!isAsyncWrapperVNode &&
|
5993 | (vnodeHook = props && props.onVnodeMounted)) {
|
5994 | const scopedInitialVNode = initialVNode;
|
5995 | queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
|
5996 | }
|
5997 |
|
5998 |
|
5999 |
|
6000 | if (initialVNode.shapeFlag & 256 ) {
|
6001 | instance.a && queuePostRenderEffect(instance.a, parentSuspense);
|
6002 | }
|
6003 | instance.isMounted = true;
|
6004 | {
|
6005 | devtoolsComponentAdded(instance);
|
6006 | }
|
6007 |
|
6008 | initialVNode = container = anchor = null;
|
6009 | }
|
6010 | else {
|
6011 |
|
6012 |
|
6013 |
|
6014 | let { next, bu, u, parent, vnode } = instance;
|
6015 | let originNext = next;
|
6016 | let vnodeHook;
|
6017 | {
|
6018 | pushWarningContext(next || instance.vnode);
|
6019 | }
|
6020 |
|
6021 | effect.allowRecurse = false;
|
6022 | if (next) {
|
6023 | next.el = vnode.el;
|
6024 | updateComponentPreRender(instance, next, optimized);
|
6025 | }
|
6026 | else {
|
6027 | next = vnode;
|
6028 | }
|
6029 |
|
6030 | if (bu) {
|
6031 | invokeArrayFns(bu);
|
6032 | }
|
6033 |
|
6034 | if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
|
6035 | invokeVNodeHook(vnodeHook, parent, next, vnode);
|
6036 | }
|
6037 | effect.allowRecurse = true;
|
6038 |
|
6039 | {
|
6040 | startMeasure(instance, `render`);
|
6041 | }
|
6042 | const nextTree = renderComponentRoot(instance);
|
6043 | {
|
6044 | endMeasure(instance, `render`);
|
6045 | }
|
6046 | const prevTree = instance.subTree;
|
6047 | instance.subTree = nextTree;
|
6048 | {
|
6049 | startMeasure(instance, `patch`);
|
6050 | }
|
6051 | patch(prevTree, nextTree,
|
6052 |
|
6053 | hostParentNode(prevTree.el),
|
6054 |
|
6055 | getNextHostNode(prevTree), instance, parentSuspense, isSVG);
|
6056 | {
|
6057 | endMeasure(instance, `patch`);
|
6058 | }
|
6059 | next.el = nextTree.el;
|
6060 | if (originNext === null) {
|
6061 |
|
6062 |
|
6063 |
|
6064 | updateHOCHostEl(instance, nextTree.el);
|
6065 | }
|
6066 |
|
6067 | if (u) {
|
6068 | queuePostRenderEffect(u, parentSuspense);
|
6069 | }
|
6070 |
|
6071 | if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
|
6072 | queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
|
6073 | }
|
6074 | {
|
6075 | devtoolsComponentUpdated(instance);
|
6076 | }
|
6077 | {
|
6078 | popWarningContext();
|
6079 | }
|
6080 | }
|
6081 | };
|
6082 |
|
6083 | const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope
|
6084 | );
|
6085 | const update = (instance.update = effect.run.bind(effect));
|
6086 | update.id = instance.uid;
|
6087 |
|
6088 |
|
6089 | effect.allowRecurse = update.allowRecurse = true;
|
6090 | {
|
6091 | effect.onTrack = instance.rtc
|
6092 | ? e => invokeArrayFns(instance.rtc, e)
|
6093 | : void 0;
|
6094 | effect.onTrigger = instance.rtg
|
6095 | ? e => invokeArrayFns(instance.rtg, e)
|
6096 | : void 0;
|
6097 |
|
6098 | update.ownerInstance = instance;
|
6099 | }
|
6100 | update();
|
6101 | };
|
6102 | const updateComponentPreRender = (instance, nextVNode, optimized) => {
|
6103 | nextVNode.component = instance;
|
6104 | const prevProps = instance.vnode.props;
|
6105 | instance.vnode = nextVNode;
|
6106 | instance.next = null;
|
6107 | updateProps(instance, nextVNode.props, prevProps, optimized);
|
6108 | updateSlots(instance, nextVNode.children, optimized);
|
6109 | pauseTracking();
|
6110 |
|
6111 |
|
6112 | flushPreFlushCbs(undefined, instance.update);
|
6113 | resetTracking();
|
6114 | };
|
6115 | const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
|
6116 | const c1 = n1 && n1.children;
|
6117 | const prevShapeFlag = n1 ? n1.shapeFlag : 0;
|
6118 | const c2 = n2.children;
|
6119 | const { patchFlag, shapeFlag } = n2;
|
6120 |
|
6121 | if (patchFlag > 0) {
|
6122 | if (patchFlag & 128 ) {
|
6123 |
|
6124 |
|
6125 | patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6126 | return;
|
6127 | }
|
6128 | else if (patchFlag & 256 ) {
|
6129 |
|
6130 | patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6131 | return;
|
6132 | }
|
6133 | }
|
6134 |
|
6135 | if (shapeFlag & 8 ) {
|
6136 |
|
6137 | if (prevShapeFlag & 16 ) {
|
6138 | unmountChildren(c1, parentComponent, parentSuspense);
|
6139 | }
|
6140 | if (c2 !== c1) {
|
6141 | hostSetElementText(container, c2);
|
6142 | }
|
6143 | }
|
6144 | else {
|
6145 | if (prevShapeFlag & 16 ) {
|
6146 |
|
6147 | if (shapeFlag & 16 ) {
|
6148 |
|
6149 | patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6150 | }
|
6151 | else {
|
6152 |
|
6153 | unmountChildren(c1, parentComponent, parentSuspense, true);
|
6154 | }
|
6155 | }
|
6156 | else {
|
6157 |
|
6158 |
|
6159 | if (prevShapeFlag & 8 ) {
|
6160 | hostSetElementText(container, '');
|
6161 | }
|
6162 |
|
6163 | if (shapeFlag & 16 ) {
|
6164 | mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6165 | }
|
6166 | }
|
6167 | }
|
6168 | };
|
6169 | const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
6170 | c1 = c1 || EMPTY_ARR;
|
6171 | c2 = c2 || EMPTY_ARR;
|
6172 | const oldLength = c1.length;
|
6173 | const newLength = c2.length;
|
6174 | const commonLength = Math.min(oldLength, newLength);
|
6175 | let i;
|
6176 | for (i = 0; i < commonLength; i++) {
|
6177 | const nextChild = (c2[i] = optimized
|
6178 | ? cloneIfMounted(c2[i])
|
6179 | : normalizeVNode(c2[i]));
|
6180 | patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6181 | }
|
6182 | if (oldLength > newLength) {
|
6183 |
|
6184 | unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
|
6185 | }
|
6186 | else {
|
6187 |
|
6188 | mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
|
6189 | }
|
6190 | };
|
6191 |
|
6192 | const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
6193 | let i = 0;
|
6194 | const l2 = c2.length;
|
6195 | let e1 = c1.length - 1;
|
6196 | let e2 = l2 - 1;
|
6197 |
|
6198 |
|
6199 |
|
6200 | while (i <= e1 && i <= e2) {
|
6201 | const n1 = c1[i];
|
6202 | const n2 = (c2[i] = optimized
|
6203 | ? cloneIfMounted(c2[i])
|
6204 | : normalizeVNode(c2[i]));
|
6205 | if (isSameVNodeType(n1, n2)) {
|
6206 | patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6207 | }
|
6208 | else {
|
6209 | break;
|
6210 | }
|
6211 | i++;
|
6212 | }
|
6213 |
|
6214 |
|
6215 |
|
6216 | while (i <= e1 && i <= e2) {
|
6217 | const n1 = c1[e1];
|
6218 | const n2 = (c2[e2] = optimized
|
6219 | ? cloneIfMounted(c2[e2])
|
6220 | : normalizeVNode(c2[e2]));
|
6221 | if (isSameVNodeType(n1, n2)) {
|
6222 | patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6223 | }
|
6224 | else {
|
6225 | break;
|
6226 | }
|
6227 | e1--;
|
6228 | e2--;
|
6229 | }
|
6230 |
|
6231 |
|
6232 |
|
6233 |
|
6234 |
|
6235 |
|
6236 |
|
6237 | if (i > e1) {
|
6238 | if (i <= e2) {
|
6239 | const nextPos = e2 + 1;
|
6240 | const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
|
6241 | while (i <= e2) {
|
6242 | patch(null, (c2[i] = optimized
|
6243 | ? cloneIfMounted(c2[i])
|
6244 | : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6245 | i++;
|
6246 | }
|
6247 | }
|
6248 | }
|
6249 |
|
6250 |
|
6251 |
|
6252 |
|
6253 |
|
6254 |
|
6255 |
|
6256 | else if (i > e2) {
|
6257 | while (i <= e1) {
|
6258 | unmount(c1[i], parentComponent, parentSuspense, true);
|
6259 | i++;
|
6260 | }
|
6261 | }
|
6262 |
|
6263 |
|
6264 |
|
6265 |
|
6266 | else {
|
6267 | const s1 = i;
|
6268 | const s2 = i;
|
6269 |
|
6270 | const keyToNewIndexMap = new Map();
|
6271 | for (i = s2; i <= e2; i++) {
|
6272 | const nextChild = (c2[i] = optimized
|
6273 | ? cloneIfMounted(c2[i])
|
6274 | : normalizeVNode(c2[i]));
|
6275 | if (nextChild.key != null) {
|
6276 | if (keyToNewIndexMap.has(nextChild.key)) {
|
6277 | warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
|
6278 | }
|
6279 | keyToNewIndexMap.set(nextChild.key, i);
|
6280 | }
|
6281 | }
|
6282 |
|
6283 |
|
6284 | let j;
|
6285 | let patched = 0;
|
6286 | const toBePatched = e2 - s2 + 1;
|
6287 | let moved = false;
|
6288 |
|
6289 | let maxNewIndexSoFar = 0;
|
6290 |
|
6291 |
|
6292 |
|
6293 |
|
6294 |
|
6295 | const newIndexToOldIndexMap = new Array(toBePatched);
|
6296 | for (i = 0; i < toBePatched; i++)
|
6297 | newIndexToOldIndexMap[i] = 0;
|
6298 | for (i = s1; i <= e1; i++) {
|
6299 | const prevChild = c1[i];
|
6300 | if (patched >= toBePatched) {
|
6301 |
|
6302 | unmount(prevChild, parentComponent, parentSuspense, true);
|
6303 | continue;
|
6304 | }
|
6305 | let newIndex;
|
6306 | if (prevChild.key != null) {
|
6307 | newIndex = keyToNewIndexMap.get(prevChild.key);
|
6308 | }
|
6309 | else {
|
6310 |
|
6311 | for (j = s2; j <= e2; j++) {
|
6312 | if (newIndexToOldIndexMap[j - s2] === 0 &&
|
6313 | isSameVNodeType(prevChild, c2[j])) {
|
6314 | newIndex = j;
|
6315 | break;
|
6316 | }
|
6317 | }
|
6318 | }
|
6319 | if (newIndex === undefined) {
|
6320 | unmount(prevChild, parentComponent, parentSuspense, true);
|
6321 | }
|
6322 | else {
|
6323 | newIndexToOldIndexMap[newIndex - s2] = i + 1;
|
6324 | if (newIndex >= maxNewIndexSoFar) {
|
6325 | maxNewIndexSoFar = newIndex;
|
6326 | }
|
6327 | else {
|
6328 | moved = true;
|
6329 | }
|
6330 | patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6331 | patched++;
|
6332 | }
|
6333 | }
|
6334 |
|
6335 |
|
6336 | const increasingNewIndexSequence = moved
|
6337 | ? getSequence(newIndexToOldIndexMap)
|
6338 | : EMPTY_ARR;
|
6339 | j = increasingNewIndexSequence.length - 1;
|
6340 |
|
6341 | for (i = toBePatched - 1; i >= 0; i--) {
|
6342 | const nextIndex = s2 + i;
|
6343 | const nextChild = c2[nextIndex];
|
6344 | const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
|
6345 | if (newIndexToOldIndexMap[i] === 0) {
|
6346 |
|
6347 | patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6348 | }
|
6349 | else if (moved) {
|
6350 |
|
6351 |
|
6352 |
|
6353 | if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
6354 | move(nextChild, container, anchor, 2 );
|
6355 | }
|
6356 | else {
|
6357 | j--;
|
6358 | }
|
6359 | }
|
6360 | }
|
6361 | }
|
6362 | };
|
6363 | const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
|
6364 | const { el, type, transition, children, shapeFlag } = vnode;
|
6365 | if (shapeFlag & 6 ) {
|
6366 | move(vnode.component.subTree, container, anchor, moveType);
|
6367 | return;
|
6368 | }
|
6369 | if (shapeFlag & 128 ) {
|
6370 | vnode.suspense.move(container, anchor, moveType);
|
6371 | return;
|
6372 | }
|
6373 | if (shapeFlag & 64 ) {
|
6374 | type.move(vnode, container, anchor, internals);
|
6375 | return;
|
6376 | }
|
6377 | if (type === Fragment) {
|
6378 | hostInsert(el, container, anchor);
|
6379 | for (let i = 0; i < children.length; i++) {
|
6380 | move(children[i], container, anchor, moveType);
|
6381 | }
|
6382 | hostInsert(vnode.anchor, container, anchor);
|
6383 | return;
|
6384 | }
|
6385 | if (type === Static) {
|
6386 | moveStaticNode(vnode, container, anchor);
|
6387 | return;
|
6388 | }
|
6389 |
|
6390 | const needTransition = moveType !== 2 &&
|
6391 | shapeFlag & 1 &&
|
6392 | transition;
|
6393 | if (needTransition) {
|
6394 | if (moveType === 0 ) {
|
6395 | transition.beforeEnter(el);
|
6396 | hostInsert(el, container, anchor);
|
6397 | queuePostRenderEffect(() => transition.enter(el), parentSuspense);
|
6398 | }
|
6399 | else {
|
6400 | const { leave, delayLeave, afterLeave } = transition;
|
6401 | const remove = () => hostInsert(el, container, anchor);
|
6402 | const performLeave = () => {
|
6403 | leave(el, () => {
|
6404 | remove();
|
6405 | afterLeave && afterLeave();
|
6406 | });
|
6407 | };
|
6408 | if (delayLeave) {
|
6409 | delayLeave(el, remove, performLeave);
|
6410 | }
|
6411 | else {
|
6412 | performLeave();
|
6413 | }
|
6414 | }
|
6415 | }
|
6416 | else {
|
6417 | hostInsert(el, container, anchor);
|
6418 | }
|
6419 | };
|
6420 | const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
|
6421 | const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
|
6422 |
|
6423 | if (ref != null) {
|
6424 | setRef(ref, null, parentSuspense, vnode, true);
|
6425 | }
|
6426 | if (shapeFlag & 256 ) {
|
6427 | parentComponent.ctx.deactivate(vnode);
|
6428 | return;
|
6429 | }
|
6430 | const shouldInvokeDirs = shapeFlag & 1 && dirs;
|
6431 | const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
|
6432 | let vnodeHook;
|
6433 | if (shouldInvokeVnodeHook &&
|
6434 | (vnodeHook = props && props.onVnodeBeforeUnmount)) {
|
6435 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
6436 | }
|
6437 | if (shapeFlag & 6 ) {
|
6438 | unmountComponent(vnode.component, parentSuspense, doRemove);
|
6439 | }
|
6440 | else {
|
6441 | if (shapeFlag & 128 ) {
|
6442 | vnode.suspense.unmount(parentSuspense, doRemove);
|
6443 | return;
|
6444 | }
|
6445 | if (shouldInvokeDirs) {
|
6446 | invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
|
6447 | }
|
6448 | if (shapeFlag & 64 ) {
|
6449 | vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
|
6450 | }
|
6451 | else if (dynamicChildren &&
|
6452 |
|
6453 | (type !== Fragment ||
|
6454 | (patchFlag > 0 && patchFlag & 64 ))) {
|
6455 |
|
6456 | unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
|
6457 | }
|
6458 | else if ((type === Fragment &&
|
6459 | patchFlag &
|
6460 | (128 | 256 )) ||
|
6461 | (!optimized && shapeFlag & 16 )) {
|
6462 | unmountChildren(children, parentComponent, parentSuspense);
|
6463 | }
|
6464 | if (doRemove) {
|
6465 | remove(vnode);
|
6466 | }
|
6467 | }
|
6468 | if ((shouldInvokeVnodeHook &&
|
6469 | (vnodeHook = props && props.onVnodeUnmounted)) ||
|
6470 | shouldInvokeDirs) {
|
6471 | queuePostRenderEffect(() => {
|
6472 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
6473 | shouldInvokeDirs &&
|
6474 | invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
|
6475 | }, parentSuspense);
|
6476 | }
|
6477 | };
|
6478 | const remove = vnode => {
|
6479 | const { type, el, anchor, transition } = vnode;
|
6480 | if (type === Fragment) {
|
6481 | removeFragment(el, anchor);
|
6482 | return;
|
6483 | }
|
6484 | if (type === Static) {
|
6485 | removeStaticNode(vnode);
|
6486 | return;
|
6487 | }
|
6488 | const performRemove = () => {
|
6489 | hostRemove(el);
|
6490 | if (transition && !transition.persisted && transition.afterLeave) {
|
6491 | transition.afterLeave();
|
6492 | }
|
6493 | };
|
6494 | if (vnode.shapeFlag & 1 &&
|
6495 | transition &&
|
6496 | !transition.persisted) {
|
6497 | const { leave, delayLeave } = transition;
|
6498 | const performLeave = () => leave(el, performRemove);
|
6499 | if (delayLeave) {
|
6500 | delayLeave(vnode.el, performRemove, performLeave);
|
6501 | }
|
6502 | else {
|
6503 | performLeave();
|
6504 | }
|
6505 | }
|
6506 | else {
|
6507 | performRemove();
|
6508 | }
|
6509 | };
|
6510 | const removeFragment = (cur, end) => {
|
6511 |
|
6512 |
|
6513 | let next;
|
6514 | while (cur !== end) {
|
6515 | next = hostNextSibling(cur);
|
6516 | hostRemove(cur);
|
6517 | cur = next;
|
6518 | }
|
6519 | hostRemove(end);
|
6520 | };
|
6521 | const unmountComponent = (instance, parentSuspense, doRemove) => {
|
6522 | if (instance.type.__hmrId) {
|
6523 | unregisterHMR(instance);
|
6524 | }
|
6525 | const { bum, scope, update, subTree, um } = instance;
|
6526 |
|
6527 | if (bum) {
|
6528 | invokeArrayFns(bum);
|
6529 | }
|
6530 |
|
6531 | scope.stop();
|
6532 |
|
6533 |
|
6534 | if (update) {
|
6535 |
|
6536 | update.active = false;
|
6537 | unmount(subTree, instance, parentSuspense, doRemove);
|
6538 | }
|
6539 |
|
6540 | if (um) {
|
6541 | queuePostRenderEffect(um, parentSuspense);
|
6542 | }
|
6543 | queuePostRenderEffect(() => {
|
6544 | instance.isUnmounted = true;
|
6545 | }, parentSuspense);
|
6546 |
|
6547 |
|
6548 |
|
6549 | if (parentSuspense &&
|
6550 | parentSuspense.pendingBranch &&
|
6551 | !parentSuspense.isUnmounted &&
|
6552 | instance.asyncDep &&
|
6553 | !instance.asyncResolved &&
|
6554 | instance.suspenseId === parentSuspense.pendingId) {
|
6555 | parentSuspense.deps--;
|
6556 | if (parentSuspense.deps === 0) {
|
6557 | parentSuspense.resolve();
|
6558 | }
|
6559 | }
|
6560 | {
|
6561 | devtoolsComponentRemoved(instance);
|
6562 | }
|
6563 | };
|
6564 | const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
|
6565 | for (let i = start; i < children.length; i++) {
|
6566 | unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
|
6567 | }
|
6568 | };
|
6569 | const getNextHostNode = vnode => {
|
6570 | if (vnode.shapeFlag & 6 ) {
|
6571 | return getNextHostNode(vnode.component.subTree);
|
6572 | }
|
6573 | if (vnode.shapeFlag & 128 ) {
|
6574 | return vnode.suspense.next();
|
6575 | }
|
6576 | return hostNextSibling((vnode.anchor || vnode.el));
|
6577 | };
|
6578 | const render = (vnode, container, isSVG) => {
|
6579 | if (vnode == null) {
|
6580 | if (container._vnode) {
|
6581 | unmount(container._vnode, null, null, true);
|
6582 | }
|
6583 | }
|
6584 | else {
|
6585 | patch(container._vnode || null, vnode, container, null, null, null, isSVG);
|
6586 | }
|
6587 | flushPostFlushCbs();
|
6588 | container._vnode = vnode;
|
6589 | };
|
6590 | const internals = {
|
6591 | p: patch,
|
6592 | um: unmount,
|
6593 | m: move,
|
6594 | r: remove,
|
6595 | mt: mountComponent,
|
6596 | mc: mountChildren,
|
6597 | pc: patchChildren,
|
6598 | pbc: patchBlockChildren,
|
6599 | n: getNextHostNode,
|
6600 | o: options
|
6601 | };
|
6602 | let hydrate;
|
6603 | let hydrateNode;
|
6604 | if (createHydrationFns) {
|
6605 | [hydrate, hydrateNode] = createHydrationFns(internals);
|
6606 | }
|
6607 | return {
|
6608 | render,
|
6609 | hydrate,
|
6610 | createApp: createAppAPI(render, hydrate)
|
6611 | };
|
6612 | }
|
6613 | function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
|
6614 | if (isArray(rawRef)) {
|
6615 | rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
|
6616 | return;
|
6617 | }
|
6618 | if (isAsyncWrapper(vnode) && !isUnmount) {
|
6619 |
|
6620 |
|
6621 | return;
|
6622 | }
|
6623 | const refValue = vnode.shapeFlag & 4
|
6624 | ? getExposeProxy(vnode.component) || vnode.component.proxy
|
6625 | : vnode.el;
|
6626 | const value = isUnmount ? null : refValue;
|
6627 | const { i: owner, r: ref } = rawRef;
|
6628 | if (!owner) {
|
6629 | warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
|
6630 | `A vnode with ref must be created inside the render function.`);
|
6631 | return;
|
6632 | }
|
6633 | const oldRef = oldRawRef && oldRawRef.r;
|
6634 | const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
|
6635 | const setupState = owner.setupState;
|
6636 |
|
6637 | if (oldRef != null && oldRef !== ref) {
|
6638 | if (isString(oldRef)) {
|
6639 | refs[oldRef] = null;
|
6640 | if (hasOwn(setupState, oldRef)) {
|
6641 | setupState[oldRef] = null;
|
6642 | }
|
6643 | }
|
6644 | else if (isRef(oldRef)) {
|
6645 | oldRef.value = null;
|
6646 | }
|
6647 | }
|
6648 | if (isString(ref)) {
|
6649 | const doSet = () => {
|
6650 | {
|
6651 | refs[ref] = value;
|
6652 | }
|
6653 | if (hasOwn(setupState, ref)) {
|
6654 | setupState[ref] = value;
|
6655 | }
|
6656 | };
|
6657 |
|
6658 |
|
6659 |
|
6660 | if (value) {
|
6661 | doSet.id = -1;
|
6662 | queuePostRenderEffect(doSet, parentSuspense);
|
6663 | }
|
6664 | else {
|
6665 | doSet();
|
6666 | }
|
6667 | }
|
6668 | else if (isRef(ref)) {
|
6669 | const doSet = () => {
|
6670 | ref.value = value;
|
6671 | };
|
6672 | if (value) {
|
6673 | doSet.id = -1;
|
6674 | queuePostRenderEffect(doSet, parentSuspense);
|
6675 | }
|
6676 | else {
|
6677 | doSet();
|
6678 | }
|
6679 | }
|
6680 | else if (isFunction(ref)) {
|
6681 | callWithErrorHandling(ref, owner, 12 , [value, refs]);
|
6682 | }
|
6683 | else {
|
6684 | warn$1('Invalid template ref type:', value, `(${typeof value})`);
|
6685 | }
|
6686 | }
|
6687 | function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
6688 | callWithAsyncErrorHandling(hook, instance, 7 , [
|
6689 | vnode,
|
6690 | prevVNode
|
6691 | ]);
|
6692 | }
|
6693 |
|
6694 |
|
6695 |
|
6696 |
|
6697 |
|
6698 |
|
6699 |
|
6700 |
|
6701 |
|
6702 |
|
6703 |
|
6704 | function traverseStaticChildren(n1, n2, shallow = false) {
|
6705 | const ch1 = n1.children;
|
6706 | const ch2 = n2.children;
|
6707 | if (isArray(ch1) && isArray(ch2)) {
|
6708 | for (let i = 0; i < ch1.length; i++) {
|
6709 |
|
6710 |
|
6711 | const c1 = ch1[i];
|
6712 | let c2 = ch2[i];
|
6713 | if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
|
6714 | if (c2.patchFlag <= 0 || c2.patchFlag === 32 ) {
|
6715 | c2 = ch2[i] = cloneIfMounted(ch2[i]);
|
6716 | c2.el = c1.el;
|
6717 | }
|
6718 | if (!shallow)
|
6719 | traverseStaticChildren(c1, c2);
|
6720 | }
|
6721 |
|
6722 |
|
6723 | if (c2.type === Comment && !c2.el) {
|
6724 | c2.el = c1.el;
|
6725 | }
|
6726 | }
|
6727 | }
|
6728 | }
|
6729 |
|
6730 | function getSequence(arr) {
|
6731 | const p = arr.slice();
|
6732 | const result = [0];
|
6733 | let i, j, u, v, c;
|
6734 | const len = arr.length;
|
6735 | for (i = 0; i < len; i++) {
|
6736 | const arrI = arr[i];
|
6737 | if (arrI !== 0) {
|
6738 | j = result[result.length - 1];
|
6739 | if (arr[j] < arrI) {
|
6740 | p[i] = j;
|
6741 | result.push(i);
|
6742 | continue;
|
6743 | }
|
6744 | u = 0;
|
6745 | v = result.length - 1;
|
6746 | while (u < v) {
|
6747 | c = (u + v) >> 1;
|
6748 | if (arr[result[c]] < arrI) {
|
6749 | u = c + 1;
|
6750 | }
|
6751 | else {
|
6752 | v = c;
|
6753 | }
|
6754 | }
|
6755 | if (arrI < arr[result[u]]) {
|
6756 | if (u > 0) {
|
6757 | p[i] = result[u - 1];
|
6758 | }
|
6759 | result[u] = i;
|
6760 | }
|
6761 | }
|
6762 | }
|
6763 | u = result.length;
|
6764 | v = result[u - 1];
|
6765 | while (u-- > 0) {
|
6766 | result[u] = v;
|
6767 | v = p[v];
|
6768 | }
|
6769 | return result;
|
6770 | }
|
6771 |
|
6772 | const isTeleport = (type) => type.__isTeleport;
|
6773 | const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
|
6774 | const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
|
6775 | const resolveTarget = (props, select) => {
|
6776 | const targetSelector = props && props.to;
|
6777 | if (isString(targetSelector)) {
|
6778 | if (!select) {
|
6779 | warn$1(`Current renderer does not support string target for Teleports. ` +
|
6780 | `(missing querySelector renderer option)`);
|
6781 | return null;
|
6782 | }
|
6783 | else {
|
6784 | const target = select(targetSelector);
|
6785 | if (!target) {
|
6786 | warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
|
6787 | `Note the target element must exist before the component is mounted - ` +
|
6788 | `i.e. the target cannot be rendered by the component itself, and ` +
|
6789 | `ideally should be outside of the entire Vue component tree.`);
|
6790 | }
|
6791 | return target;
|
6792 | }
|
6793 | }
|
6794 | else {
|
6795 | if (!targetSelector && !isTeleportDisabled(props)) {
|
6796 | warn$1(`Invalid Teleport target: ${targetSelector}`);
|
6797 | }
|
6798 | return targetSelector;
|
6799 | }
|
6800 | };
|
6801 | const TeleportImpl = {
|
6802 | __isTeleport: true,
|
6803 | process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
|
6804 | const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
|
6805 | const disabled = isTeleportDisabled(n2.props);
|
6806 | let { shapeFlag, children, dynamicChildren } = n2;
|
6807 |
|
6808 |
|
6809 | if (isHmrUpdating) {
|
6810 | optimized = false;
|
6811 | dynamicChildren = null;
|
6812 | }
|
6813 | if (n1 == null) {
|
6814 |
|
6815 | const placeholder = (n2.el = createComment('teleport start')
|
6816 | );
|
6817 | const mainAnchor = (n2.anchor = createComment('teleport end')
|
6818 | );
|
6819 | insert(placeholder, container, anchor);
|
6820 | insert(mainAnchor, container, anchor);
|
6821 | const target = (n2.target = resolveTarget(n2.props, querySelector));
|
6822 | const targetAnchor = (n2.targetAnchor = createText(''));
|
6823 | if (target) {
|
6824 | insert(targetAnchor, target);
|
6825 |
|
6826 | isSVG = isSVG || isTargetSVG(target);
|
6827 | }
|
6828 | else if (!disabled) {
|
6829 | warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
|
6830 | }
|
6831 | const mount = (container, anchor) => {
|
6832 |
|
6833 |
|
6834 | if (shapeFlag & 16 ) {
|
6835 | mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6836 | }
|
6837 | };
|
6838 | if (disabled) {
|
6839 | mount(container, mainAnchor);
|
6840 | }
|
6841 | else if (target) {
|
6842 | mount(target, targetAnchor);
|
6843 | }
|
6844 | }
|
6845 | else {
|
6846 |
|
6847 | n2.el = n1.el;
|
6848 | const mainAnchor = (n2.anchor = n1.anchor);
|
6849 | const target = (n2.target = n1.target);
|
6850 | const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
|
6851 | const wasDisabled = isTeleportDisabled(n1.props);
|
6852 | const currentContainer = wasDisabled ? container : target;
|
6853 | const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
|
6854 | isSVG = isSVG || isTargetSVG(target);
|
6855 | if (dynamicChildren) {
|
6856 |
|
6857 | patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
|
6858 |
|
6859 |
|
6860 |
|
6861 | traverseStaticChildren(n1, n2, true);
|
6862 | }
|
6863 | else if (!optimized) {
|
6864 | patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
|
6865 | }
|
6866 | if (disabled) {
|
6867 | if (!wasDisabled) {
|
6868 |
|
6869 |
|
6870 | moveTeleport(n2, container, mainAnchor, internals, 1 );
|
6871 | }
|
6872 | }
|
6873 | else {
|
6874 |
|
6875 | if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
|
6876 | const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
|
6877 | if (nextTarget) {
|
6878 | moveTeleport(n2, nextTarget, null, internals, 0 );
|
6879 | }
|
6880 | else {
|
6881 | warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
|
6882 | }
|
6883 | }
|
6884 | else if (wasDisabled) {
|
6885 |
|
6886 |
|
6887 | moveTeleport(n2, target, targetAnchor, internals, 1 );
|
6888 | }
|
6889 | }
|
6890 | }
|
6891 | },
|
6892 | remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
|
6893 | const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
|
6894 | if (target) {
|
6895 | hostRemove(targetAnchor);
|
6896 | }
|
6897 |
|
6898 | if (doRemove || !isTeleportDisabled(props)) {
|
6899 | hostRemove(anchor);
|
6900 | if (shapeFlag & 16 ) {
|
6901 | for (let i = 0; i < children.length; i++) {
|
6902 | const child = children[i];
|
6903 | unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
|
6904 | }
|
6905 | }
|
6906 | }
|
6907 | },
|
6908 | move: moveTeleport,
|
6909 | hydrate: hydrateTeleport
|
6910 | };
|
6911 | function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
|
6912 |
|
6913 | if (moveType === 0 ) {
|
6914 | insert(vnode.targetAnchor, container, parentAnchor);
|
6915 | }
|
6916 | const { el, anchor, shapeFlag, children, props } = vnode;
|
6917 | const isReorder = moveType === 2 ;
|
6918 |
|
6919 | if (isReorder) {
|
6920 | insert(el, container, parentAnchor);
|
6921 | }
|
6922 |
|
6923 |
|
6924 |
|
6925 | if (!isReorder || isTeleportDisabled(props)) {
|
6926 |
|
6927 | if (shapeFlag & 16 ) {
|
6928 | for (let i = 0; i < children.length; i++) {
|
6929 | move(children[i], container, parentAnchor, 2 );
|
6930 | }
|
6931 | }
|
6932 | }
|
6933 |
|
6934 | if (isReorder) {
|
6935 | insert(anchor, container, parentAnchor);
|
6936 | }
|
6937 | }
|
6938 | function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
|
6939 | const target = (vnode.target = resolveTarget(vnode.props, querySelector));
|
6940 | if (target) {
|
6941 |
|
6942 |
|
6943 | const targetNode = target._lpa || target.firstChild;
|
6944 | if (vnode.shapeFlag & 16 ) {
|
6945 | if (isTeleportDisabled(vnode.props)) {
|
6946 | vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
|
6947 | vnode.targetAnchor = targetNode;
|
6948 | }
|
6949 | else {
|
6950 | vnode.anchor = nextSibling(node);
|
6951 | vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
|
6952 | }
|
6953 | target._lpa =
|
6954 | vnode.targetAnchor && nextSibling(vnode.targetAnchor);
|
6955 | }
|
6956 | }
|
6957 | return vnode.anchor && nextSibling(vnode.anchor);
|
6958 | }
|
6959 |
|
6960 | const Teleport = TeleportImpl;
|
6961 |
|
6962 | const COMPONENTS = 'components';
|
6963 | const DIRECTIVES = 'directives';
|
6964 |
|
6965 |
|
6966 |
|
6967 | function resolveComponent(name, maybeSelfReference) {
|
6968 | return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
6969 | }
|
6970 | const NULL_DYNAMIC_COMPONENT = Symbol();
|
6971 |
|
6972 |
|
6973 |
|
6974 | function resolveDynamicComponent(component) {
|
6975 | if (isString(component)) {
|
6976 | return resolveAsset(COMPONENTS, component, false) || component;
|
6977 | }
|
6978 | else {
|
6979 |
|
6980 | return (component || NULL_DYNAMIC_COMPONENT);
|
6981 | }
|
6982 | }
|
6983 |
|
6984 |
|
6985 |
|
6986 | function resolveDirective(name) {
|
6987 | return resolveAsset(DIRECTIVES, name);
|
6988 | }
|
6989 |
|
6990 | function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
6991 | const instance = currentRenderingInstance || currentInstance;
|
6992 | if (instance) {
|
6993 | const Component = instance.type;
|
6994 |
|
6995 | if (type === COMPONENTS) {
|
6996 | const selfName = getComponentName(Component);
|
6997 | if (selfName &&
|
6998 | (selfName === name ||
|
6999 | selfName === camelize(name) ||
|
7000 | selfName === capitalize(camelize(name)))) {
|
7001 | return Component;
|
7002 | }
|
7003 | }
|
7004 | const res =
|
7005 |
|
7006 |
|
7007 | resolve(instance[type] || Component[type], name) ||
|
7008 |
|
7009 | resolve(instance.appContext[type], name);
|
7010 | if (!res && maybeSelfReference) {
|
7011 |
|
7012 | return Component;
|
7013 | }
|
7014 | if (warnMissing && !res) {
|
7015 | warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
|
7016 | }
|
7017 | return res;
|
7018 | }
|
7019 | else {
|
7020 | warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
|
7021 | `can only be used in render() or setup().`);
|
7022 | }
|
7023 | }
|
7024 | function resolve(registry, name) {
|
7025 | return (registry &&
|
7026 | (registry[name] ||
|
7027 | registry[camelize(name)] ||
|
7028 | registry[capitalize(camelize(name))]));
|
7029 | }
|
7030 |
|
7031 | const Fragment = Symbol('Fragment' );
|
7032 | const Text = Symbol('Text' );
|
7033 | const Comment = Symbol('Comment' );
|
7034 | const Static = Symbol('Static' );
|
7035 |
|
7036 |
|
7037 |
|
7038 |
|
7039 |
|
7040 | const blockStack = [];
|
7041 | let currentBlock = null;
|
7042 |
|
7043 |
|
7044 |
|
7045 |
|
7046 |
|
7047 |
|
7048 |
|
7049 |
|
7050 |
|
7051 |
|
7052 |
|
7053 |
|
7054 |
|
7055 |
|
7056 |
|
7057 |
|
7058 | function openBlock(disableTracking = false) {
|
7059 | blockStack.push((currentBlock = disableTracking ? null : []));
|
7060 | }
|
7061 | function closeBlock() {
|
7062 | blockStack.pop();
|
7063 | currentBlock = blockStack[blockStack.length - 1] || null;
|
7064 | }
|
7065 |
|
7066 |
|
7067 |
|
7068 |
|
7069 | let isBlockTreeEnabled = 1;
|
7070 |
|
7071 |
|
7072 |
|
7073 |
|
7074 |
|
7075 |
|
7076 |
|
7077 |
|
7078 |
|
7079 |
|
7080 |
|
7081 |
|
7082 |
|
7083 |
|
7084 |
|
7085 |
|
7086 | function setBlockTracking(value) {
|
7087 | isBlockTreeEnabled += value;
|
7088 | }
|
7089 | function setupBlock(vnode) {
|
7090 |
|
7091 | vnode.dynamicChildren =
|
7092 | isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
|
7093 |
|
7094 | closeBlock();
|
7095 |
|
7096 |
|
7097 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
7098 | currentBlock.push(vnode);
|
7099 | }
|
7100 | return vnode;
|
7101 | }
|
7102 |
|
7103 |
|
7104 |
|
7105 | function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
|
7106 | return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true ));
|
7107 | }
|
7108 |
|
7109 |
|
7110 |
|
7111 |
|
7112 |
|
7113 |
|
7114 |
|
7115 | function createBlock(type, props, children, patchFlag, dynamicProps) {
|
7116 | return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true ));
|
7117 | }
|
7118 | function isVNode(value) {
|
7119 | return value ? value.__v_isVNode === true : false;
|
7120 | }
|
7121 | function isSameVNodeType(n1, n2) {
|
7122 | if (n2.shapeFlag & 6 &&
|
7123 | hmrDirtyComponents.has(n2.type)) {
|
7124 |
|
7125 | return false;
|
7126 | }
|
7127 | return n1.type === n2.type && n1.key === n2.key;
|
7128 | }
|
7129 | let vnodeArgsTransformer;
|
7130 |
|
7131 |
|
7132 |
|
7133 |
|
7134 |
|
7135 |
|
7136 | function transformVNodeArgs(transformer) {
|
7137 | vnodeArgsTransformer = transformer;
|
7138 | }
|
7139 | const createVNodeWithArgsTransform = (...args) => {
|
7140 | return _createVNode(...(vnodeArgsTransformer
|
7141 | ? vnodeArgsTransformer(args, currentRenderingInstance)
|
7142 | : args));
|
7143 | };
|
7144 | const InternalObjectKey = `__vInternal`;
|
7145 | const normalizeKey = ({ key }) => key != null ? key : null;
|
7146 | const normalizeRef = ({ ref }) => {
|
7147 | return (ref != null
|
7148 | ? isString(ref) || isRef(ref) || isFunction(ref)
|
7149 | ? { i: currentRenderingInstance, r: ref }
|
7150 | : ref
|
7151 | : null);
|
7152 | };
|
7153 | function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
|
7154 | const vnode = {
|
7155 | __v_isVNode: true,
|
7156 | __v_skip: true,
|
7157 | type,
|
7158 | props,
|
7159 | key: props && normalizeKey(props),
|
7160 | ref: props && normalizeRef(props),
|
7161 | scopeId: currentScopeId,
|
7162 | slotScopeIds: null,
|
7163 | children,
|
7164 | component: null,
|
7165 | suspense: null,
|
7166 | ssContent: null,
|
7167 | ssFallback: null,
|
7168 | dirs: null,
|
7169 | transition: null,
|
7170 | el: null,
|
7171 | anchor: null,
|
7172 | target: null,
|
7173 | targetAnchor: null,
|
7174 | staticCount: 0,
|
7175 | shapeFlag,
|
7176 | patchFlag,
|
7177 | dynamicProps,
|
7178 | dynamicChildren: null,
|
7179 | appContext: null
|
7180 | };
|
7181 | if (needFullChildrenNormalization) {
|
7182 | normalizeChildren(vnode, children);
|
7183 |
|
7184 | if (shapeFlag & 128 ) {
|
7185 | type.normalize(vnode);
|
7186 | }
|
7187 | }
|
7188 | else if (children) {
|
7189 |
|
7190 |
|
7191 | vnode.shapeFlag |= isString(children)
|
7192 | ? 8
|
7193 | : 16 ;
|
7194 | }
|
7195 |
|
7196 | if (vnode.key !== vnode.key) {
|
7197 | warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
7198 | }
|
7199 |
|
7200 | if (isBlockTreeEnabled > 0 &&
|
7201 |
|
7202 | !isBlockNode &&
|
7203 |
|
7204 | currentBlock &&
|
7205 |
|
7206 |
|
7207 |
|
7208 |
|
7209 | (vnode.patchFlag > 0 || shapeFlag & 6 ) &&
|
7210 |
|
7211 |
|
7212 | vnode.patchFlag !== 32 ) {
|
7213 | currentBlock.push(vnode);
|
7214 | }
|
7215 | return vnode;
|
7216 | }
|
7217 | const createVNode = (createVNodeWithArgsTransform );
|
7218 | function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
7219 | if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
7220 | if (!type) {
|
7221 | warn$1(`Invalid vnode type when creating vnode: ${type}.`);
|
7222 | }
|
7223 | type = Comment;
|
7224 | }
|
7225 | if (isVNode(type)) {
|
7226 |
|
7227 |
|
7228 |
|
7229 | const cloned = cloneVNode(type, props, true );
|
7230 | if (children) {
|
7231 | normalizeChildren(cloned, children);
|
7232 | }
|
7233 | return cloned;
|
7234 | }
|
7235 |
|
7236 | if (isClassComponent(type)) {
|
7237 | type = type.__vccOpts;
|
7238 | }
|
7239 |
|
7240 | if (props) {
|
7241 |
|
7242 | props = guardReactiveProps(props);
|
7243 | let { class: klass, style } = props;
|
7244 | if (klass && !isString(klass)) {
|
7245 | props.class = normalizeClass(klass);
|
7246 | }
|
7247 | if (isObject(style)) {
|
7248 |
|
7249 |
|
7250 | if (isProxy(style) && !isArray(style)) {
|
7251 | style = extend({}, style);
|
7252 | }
|
7253 | props.style = normalizeStyle(style);
|
7254 | }
|
7255 | }
|
7256 |
|
7257 | const shapeFlag = isString(type)
|
7258 | ? 1
|
7259 | : isSuspense(type)
|
7260 | ? 128
|
7261 | : isTeleport(type)
|
7262 | ? 64
|
7263 | : isObject(type)
|
7264 | ? 4
|
7265 | : isFunction(type)
|
7266 | ? 2
|
7267 | : 0;
|
7268 | if (shapeFlag & 4 && isProxy(type)) {
|
7269 | type = toRaw(type);
|
7270 | warn$1(`Vue received a Component which was made a reactive object. This can ` +
|
7271 | `lead to unnecessary performance overhead, and should be avoided by ` +
|
7272 | `marking the component with \`markRaw\` or using \`shallowRef\` ` +
|
7273 | `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
|
7274 | }
|
7275 | return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
|
7276 | }
|
7277 | function guardReactiveProps(props) {
|
7278 | if (!props)
|
7279 | return null;
|
7280 | return isProxy(props) || InternalObjectKey in props
|
7281 | ? extend({}, props)
|
7282 | : props;
|
7283 | }
|
7284 | function cloneVNode(vnode, extraProps, mergeRef = false) {
|
7285 |
|
7286 |
|
7287 | const { props, ref, patchFlag, children } = vnode;
|
7288 | const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
|
7289 | const cloned = {
|
7290 | __v_isVNode: true,
|
7291 | __v_skip: true,
|
7292 | type: vnode.type,
|
7293 | props: mergedProps,
|
7294 | key: mergedProps && normalizeKey(mergedProps),
|
7295 | ref: extraProps && extraProps.ref
|
7296 | ?
|
7297 |
|
7298 |
|
7299 | mergeRef && ref
|
7300 | ? isArray(ref)
|
7301 | ? ref.concat(normalizeRef(extraProps))
|
7302 | : [ref, normalizeRef(extraProps)]
|
7303 | : normalizeRef(extraProps)
|
7304 | : ref,
|
7305 | scopeId: vnode.scopeId,
|
7306 | slotScopeIds: vnode.slotScopeIds,
|
7307 | children: patchFlag === -1 && isArray(children)
|
7308 | ? children.map(deepCloneVNode)
|
7309 | : children,
|
7310 | target: vnode.target,
|
7311 | targetAnchor: vnode.targetAnchor,
|
7312 | staticCount: vnode.staticCount,
|
7313 | shapeFlag: vnode.shapeFlag,
|
7314 |
|
7315 |
|
7316 |
|
7317 |
|
7318 | patchFlag: extraProps && vnode.type !== Fragment
|
7319 | ? patchFlag === -1
|
7320 | ? 16
|
7321 | : patchFlag | 16
|
7322 | : patchFlag,
|
7323 | dynamicProps: vnode.dynamicProps,
|
7324 | dynamicChildren: vnode.dynamicChildren,
|
7325 | appContext: vnode.appContext,
|
7326 | dirs: vnode.dirs,
|
7327 | transition: vnode.transition,
|
7328 |
|
7329 |
|
7330 |
|
7331 |
|
7332 | component: vnode.component,
|
7333 | suspense: vnode.suspense,
|
7334 | ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
7335 | ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
7336 | el: vnode.el,
|
7337 | anchor: vnode.anchor
|
7338 | };
|
7339 | return cloned;
|
7340 | }
|
7341 |
|
7342 |
|
7343 |
|
7344 |
|
7345 | function deepCloneVNode(vnode) {
|
7346 | const cloned = cloneVNode(vnode);
|
7347 | if (isArray(vnode.children)) {
|
7348 | cloned.children = vnode.children.map(deepCloneVNode);
|
7349 | }
|
7350 | return cloned;
|
7351 | }
|
7352 |
|
7353 |
|
7354 |
|
7355 | function createTextVNode(text = ' ', flag = 0) {
|
7356 | return createVNode(Text, null, text, flag);
|
7357 | }
|
7358 |
|
7359 |
|
7360 |
|
7361 | function createStaticVNode(content, numberOfNodes) {
|
7362 |
|
7363 |
|
7364 | const vnode = createVNode(Static, null, content);
|
7365 | vnode.staticCount = numberOfNodes;
|
7366 | return vnode;
|
7367 | }
|
7368 |
|
7369 |
|
7370 |
|
7371 | function createCommentVNode(text = '',
|
7372 | // when used as the v-else branch, the comment node must be created as a
|
7373 | // block to ensure correct updates.
|
7374 | asBlock = false) {
|
7375 | return asBlock
|
7376 | ? (openBlock(), createBlock(Comment, null, text))
|
7377 | : createVNode(Comment, null, text);
|
7378 | }
|
7379 | function normalizeVNode(child) {
|
7380 | if (child == null || typeof child === 'boolean') {
|
7381 |
|
7382 | return createVNode(Comment);
|
7383 | }
|
7384 | else if (isArray(child)) {
|
7385 |
|
7386 | return createVNode(Fragment, null,
|
7387 |
|
7388 | child.slice());
|
7389 | }
|
7390 | else if (typeof child === 'object') {
|
7391 |
|
7392 |
|
7393 | return cloneIfMounted(child);
|
7394 | }
|
7395 | else {
|
7396 |
|
7397 | return createVNode(Text, null, String(child));
|
7398 | }
|
7399 | }
|
7400 |
|
7401 | function cloneIfMounted(child) {
|
7402 | return child.el === null || child.memo ? child : cloneVNode(child);
|
7403 | }
|
7404 | function normalizeChildren(vnode, children) {
|
7405 | let type = 0;
|
7406 | const { shapeFlag } = vnode;
|
7407 | if (children == null) {
|
7408 | children = null;
|
7409 | }
|
7410 | else if (isArray(children)) {
|
7411 | type = 16 ;
|
7412 | }
|
7413 | else if (typeof children === 'object') {
|
7414 | if (shapeFlag & (1 | 64 )) {
|
7415 |
|
7416 | const slot = children.default;
|
7417 | if (slot) {
|
7418 |
|
7419 | slot._c && (slot._d = false);
|
7420 | normalizeChildren(vnode, slot());
|
7421 | slot._c && (slot._d = true);
|
7422 | }
|
7423 | return;
|
7424 | }
|
7425 | else {
|
7426 | type = 32 ;
|
7427 | const slotFlag = children._;
|
7428 | if (!slotFlag && !(InternalObjectKey in children)) {
|
7429 | children._ctx = currentRenderingInstance;
|
7430 | }
|
7431 | else if (slotFlag === 3 && currentRenderingInstance) {
|
7432 |
|
7433 |
|
7434 | if (currentRenderingInstance.slots._ === 1 ) {
|
7435 | children._ = 1 ;
|
7436 | }
|
7437 | else {
|
7438 | children._ = 2 ;
|
7439 | vnode.patchFlag |= 1024 ;
|
7440 | }
|
7441 | }
|
7442 | }
|
7443 | }
|
7444 | else if (isFunction(children)) {
|
7445 | children = { default: children, _ctx: currentRenderingInstance };
|
7446 | type = 32 ;
|
7447 | }
|
7448 | else {
|
7449 | children = String(children);
|
7450 |
|
7451 | if (shapeFlag & 64 ) {
|
7452 | type = 16 ;
|
7453 | children = [createTextVNode(children)];
|
7454 | }
|
7455 | else {
|
7456 | type = 8 ;
|
7457 | }
|
7458 | }
|
7459 | vnode.children = children;
|
7460 | vnode.shapeFlag |= type;
|
7461 | }
|
7462 | function mergeProps(...args) {
|
7463 | const ret = {};
|
7464 | for (let i = 0; i < args.length; i++) {
|
7465 | const toMerge = args[i];
|
7466 | for (const key in toMerge) {
|
7467 | if (key === 'class') {
|
7468 | if (ret.class !== toMerge.class) {
|
7469 | ret.class = normalizeClass([ret.class, toMerge.class]);
|
7470 | }
|
7471 | }
|
7472 | else if (key === 'style') {
|
7473 | ret.style = normalizeStyle([ret.style, toMerge.style]);
|
7474 | }
|
7475 | else if (isOn(key)) {
|
7476 | const existing = ret[key];
|
7477 | const incoming = toMerge[key];
|
7478 | if (existing !== incoming) {
|
7479 | ret[key] = existing
|
7480 | ? [].concat(existing, incoming)
|
7481 | : incoming;
|
7482 | }
|
7483 | }
|
7484 | else if (key !== '') {
|
7485 | ret[key] = toMerge[key];
|
7486 | }
|
7487 | }
|
7488 | }
|
7489 | return ret;
|
7490 | }
|
7491 |
|
7492 |
|
7493 |
|
7494 |
|
7495 | function renderList(source, renderItem, cache, index) {
|
7496 | let ret;
|
7497 | const cached = (cache && cache[index]);
|
7498 | if (isArray(source) || isString(source)) {
|
7499 | ret = new Array(source.length);
|
7500 | for (let i = 0, l = source.length; i < l; i++) {
|
7501 | ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
|
7502 | }
|
7503 | }
|
7504 | else if (typeof source === 'number') {
|
7505 | if (!Number.isInteger(source)) {
|
7506 | warn$1(`The v-for range expect an integer value but got ${source}.`);
|
7507 | return [];
|
7508 | }
|
7509 | ret = new Array(source);
|
7510 | for (let i = 0; i < source; i++) {
|
7511 | ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
|
7512 | }
|
7513 | }
|
7514 | else if (isObject(source)) {
|
7515 | if (source[Symbol.iterator]) {
|
7516 | ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
|
7517 | }
|
7518 | else {
|
7519 | const keys = Object.keys(source);
|
7520 | ret = new Array(keys.length);
|
7521 | for (let i = 0, l = keys.length; i < l; i++) {
|
7522 | const key = keys[i];
|
7523 | ret[i] = renderItem(source[key], key, i, cached && cached[i]);
|
7524 | }
|
7525 | }
|
7526 | }
|
7527 | else {
|
7528 | ret = [];
|
7529 | }
|
7530 | if (cache) {
|
7531 | cache[index] = ret;
|
7532 | }
|
7533 | return ret;
|
7534 | }
|
7535 |
|
7536 |
|
7537 |
|
7538 |
|
7539 |
|
7540 | function createSlots(slots, dynamicSlots) {
|
7541 | for (let i = 0; i < dynamicSlots.length; i++) {
|
7542 | const slot = dynamicSlots[i];
|
7543 |
|
7544 | if (isArray(slot)) {
|
7545 | for (let j = 0; j < slot.length; j++) {
|
7546 | slots[slot[j].name] = slot[j].fn;
|
7547 | }
|
7548 | }
|
7549 | else if (slot) {
|
7550 |
|
7551 | slots[slot.name] = slot.fn;
|
7552 | }
|
7553 | }
|
7554 | return slots;
|
7555 | }
|
7556 |
|
7557 |
|
7558 |
|
7559 |
|
7560 |
|
7561 | function renderSlot(slots, name, props = {},
|
7562 | // this is not a user-facing function, so the fallback is always generated by
|
7563 | // the compiler and guaranteed to be a function returning an array
|
7564 | fallback, noSlotted) {
|
7565 | if (currentRenderingInstance.isCE) {
|
7566 | return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
|
7567 | }
|
7568 | let slot = slots[name];
|
7569 | if (slot && slot.length > 1) {
|
7570 | warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
|
7571 | `function. You need to mark this component with $dynamic-slots in the ` +
|
7572 | `parent template.`);
|
7573 | slot = () => [];
|
7574 | }
|
7575 |
|
7576 |
|
7577 |
|
7578 |
|
7579 | if (slot && slot._c) {
|
7580 | slot._d = false;
|
7581 | }
|
7582 | openBlock();
|
7583 | const validSlotContent = slot && ensureValidVNode(slot(props));
|
7584 | const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1
|
7585 | ? 64
|
7586 | : -2 );
|
7587 | if (!noSlotted && rendered.scopeId) {
|
7588 | rendered.slotScopeIds = [rendered.scopeId + '-s'];
|
7589 | }
|
7590 | if (slot && slot._c) {
|
7591 | slot._d = true;
|
7592 | }
|
7593 | return rendered;
|
7594 | }
|
7595 | function ensureValidVNode(vnodes) {
|
7596 | return vnodes.some(child => {
|
7597 | if (!isVNode(child))
|
7598 | return true;
|
7599 | if (child.type === Comment)
|
7600 | return false;
|
7601 | if (child.type === Fragment &&
|
7602 | !ensureValidVNode(child.children))
|
7603 | return false;
|
7604 | return true;
|
7605 | })
|
7606 | ? vnodes
|
7607 | : null;
|
7608 | }
|
7609 |
|
7610 |
|
7611 |
|
7612 |
|
7613 |
|
7614 | function toHandlers(obj) {
|
7615 | const ret = {};
|
7616 | if (!isObject(obj)) {
|
7617 | warn$1(`v-on with no argument expects an object value.`);
|
7618 | return ret;
|
7619 | }
|
7620 | for (const key in obj) {
|
7621 | ret[toHandlerKey(key)] = obj[key];
|
7622 | }
|
7623 | return ret;
|
7624 | }
|
7625 |
|
7626 |
|
7627 |
|
7628 |
|
7629 |
|
7630 |
|
7631 | const getPublicInstance = (i) => {
|
7632 | if (!i)
|
7633 | return null;
|
7634 | if (isStatefulComponent(i))
|
7635 | return getExposeProxy(i) || i.proxy;
|
7636 | return getPublicInstance(i.parent);
|
7637 | };
|
7638 | const publicPropertiesMap = extend(Object.create(null), {
|
7639 | $: i => i,
|
7640 | $el: i => i.vnode.el,
|
7641 | $data: i => i.data,
|
7642 | $props: i => (shallowReadonly(i.props) ),
|
7643 | $attrs: i => (shallowReadonly(i.attrs) ),
|
7644 | $slots: i => (shallowReadonly(i.slots) ),
|
7645 | $refs: i => (shallowReadonly(i.refs) ),
|
7646 | $parent: i => getPublicInstance(i.parent),
|
7647 | $root: i => getPublicInstance(i.root),
|
7648 | $emit: i => i.emit,
|
7649 | $options: i => (resolveMergedOptions(i) ),
|
7650 | $forceUpdate: i => () => queueJob(i.update),
|
7651 | $nextTick: i => nextTick.bind(i.proxy),
|
7652 | $watch: i => (instanceWatch.bind(i) )
|
7653 | });
|
7654 | const PublicInstanceProxyHandlers = {
|
7655 | get({ _: instance }, key) {
|
7656 | const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
7657 |
|
7658 | if (key === '__isVue') {
|
7659 | return true;
|
7660 | }
|
7661 |
|
7662 |
|
7663 |
|
7664 |
|
7665 | if (setupState !== EMPTY_OBJ &&
|
7666 | setupState.__isScriptSetup &&
|
7667 | hasOwn(setupState, key)) {
|
7668 | return setupState[key];
|
7669 | }
|
7670 |
|
7671 |
|
7672 |
|
7673 |
|
7674 |
|
7675 |
|
7676 | let normalizedProps;
|
7677 | if (key[0] !== '$') {
|
7678 | const n = accessCache[key];
|
7679 | if (n !== undefined) {
|
7680 | switch (n) {
|
7681 | case 0 :
|
7682 | return setupState[key];
|
7683 | case 1 :
|
7684 | return data[key];
|
7685 | case 3 :
|
7686 | return ctx[key];
|
7687 | case 2 :
|
7688 | return props[key];
|
7689 |
|
7690 | }
|
7691 | }
|
7692 | else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
|
7693 | accessCache[key] = 0 ;
|
7694 | return setupState[key];
|
7695 | }
|
7696 | else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
7697 | accessCache[key] = 1 ;
|
7698 | return data[key];
|
7699 | }
|
7700 | else if (
|
7701 |
|
7702 |
|
7703 | (normalizedProps = instance.propsOptions[0]) &&
|
7704 | hasOwn(normalizedProps, key)) {
|
7705 | accessCache[key] = 2 ;
|
7706 | return props[key];
|
7707 | }
|
7708 | else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
7709 | accessCache[key] = 3 ;
|
7710 | return ctx[key];
|
7711 | }
|
7712 | else if (shouldCacheAccess) {
|
7713 | accessCache[key] = 4 ;
|
7714 | }
|
7715 | }
|
7716 | const publicGetter = publicPropertiesMap[key];
|
7717 | let cssModule, globalProperties;
|
7718 |
|
7719 | if (publicGetter) {
|
7720 | if (key === '$attrs') {
|
7721 | track(instance, "get" , key);
|
7722 | markAttrsAccessed();
|
7723 | }
|
7724 | return publicGetter(instance);
|
7725 | }
|
7726 | else if (
|
7727 |
|
7728 | (cssModule = type.__cssModules) &&
|
7729 | (cssModule = cssModule[key])) {
|
7730 | return cssModule;
|
7731 | }
|
7732 | else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
7733 |
|
7734 | accessCache[key] = 3 ;
|
7735 | return ctx[key];
|
7736 | }
|
7737 | else if (
|
7738 |
|
7739 | ((globalProperties = appContext.config.globalProperties),
|
7740 | hasOwn(globalProperties, key))) {
|
7741 | {
|
7742 | return globalProperties[key];
|
7743 | }
|
7744 | }
|
7745 | else if (currentRenderingInstance &&
|
7746 | (!isString(key) ||
|
7747 |
|
7748 |
|
7749 | key.indexOf('__v') !== 0)) {
|
7750 | if (data !== EMPTY_OBJ &&
|
7751 | (key[0] === '$' || key[0] === '_') &&
|
7752 | hasOwn(data, key)) {
|
7753 | warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
|
7754 | `character ("$" or "_") and is not proxied on the render context.`);
|
7755 | }
|
7756 | else if (instance === currentRenderingInstance) {
|
7757 | warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
|
7758 | `but is not defined on instance.`);
|
7759 | }
|
7760 | }
|
7761 | },
|
7762 | set({ _: instance }, key, value) {
|
7763 | const { data, setupState, ctx } = instance;
|
7764 | if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
|
7765 | setupState[key] = value;
|
7766 | }
|
7767 | else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
7768 | data[key] = value;
|
7769 | }
|
7770 | else if (hasOwn(instance.props, key)) {
|
7771 | warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
|
7772 | return false;
|
7773 | }
|
7774 | if (key[0] === '$' && key.slice(1) in instance) {
|
7775 | warn$1(`Attempting to mutate public property "${key}". ` +
|
7776 | `Properties starting with $ are reserved and readonly.`, instance);
|
7777 | return false;
|
7778 | }
|
7779 | else {
|
7780 | if (key in instance.appContext.config.globalProperties) {
|
7781 | Object.defineProperty(ctx, key, {
|
7782 | enumerable: true,
|
7783 | configurable: true,
|
7784 | value
|
7785 | });
|
7786 | }
|
7787 | else {
|
7788 | ctx[key] = value;
|
7789 | }
|
7790 | }
|
7791 | return true;
|
7792 | },
|
7793 | has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
|
7794 | let normalizedProps;
|
7795 | return (accessCache[key] !== undefined ||
|
7796 | (data !== EMPTY_OBJ && hasOwn(data, key)) ||
|
7797 | (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
|
7798 | ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
|
7799 | hasOwn(ctx, key) ||
|
7800 | hasOwn(publicPropertiesMap, key) ||
|
7801 | hasOwn(appContext.config.globalProperties, key));
|
7802 | }
|
7803 | };
|
7804 | {
|
7805 | PublicInstanceProxyHandlers.ownKeys = (target) => {
|
7806 | warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
|
7807 | `The keys will be empty in production mode to avoid performance overhead.`);
|
7808 | return Reflect.ownKeys(target);
|
7809 | };
|
7810 | }
|
7811 | const RuntimeCompiledPublicInstanceProxyHandlers = extend({}, PublicInstanceProxyHandlers, {
|
7812 | get(target, key) {
|
7813 |
|
7814 | if (key === Symbol.unscopables) {
|
7815 | return;
|
7816 | }
|
7817 | return PublicInstanceProxyHandlers.get(target, key, target);
|
7818 | },
|
7819 | has(_, key) {
|
7820 | const has = key[0] !== '_' && !isGloballyWhitelisted(key);
|
7821 | if (!has && PublicInstanceProxyHandlers.has(_, key)) {
|
7822 | warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
|
7823 | }
|
7824 | return has;
|
7825 | }
|
7826 | });
|
7827 |
|
7828 |
|
7829 |
|
7830 |
|
7831 | function createDevRenderContext(instance) {
|
7832 | const target = {};
|
7833 |
|
7834 | Object.defineProperty(target, `_`, {
|
7835 | configurable: true,
|
7836 | enumerable: false,
|
7837 | get: () => instance
|
7838 | });
|
7839 | // expose public properties
|
7840 | Object.keys(publicPropertiesMap).forEach(key => {
|
7841 | Object.defineProperty(target, key, {
|
7842 | configurable: true,
|
7843 | enumerable: false,
|
7844 | get: () => publicPropertiesMap[key](instance),
|
7845 | // intercepted by the proxy so no need for implementation,
|
7846 | // but needed to prevent set errors
|
7847 | set: NOOP
|
7848 | });
|
7849 | });
|
7850 | return target;
|
7851 | }
|
7852 | // dev only
|
7853 | function exposePropsOnRenderContext(instance) {
|
7854 | const { ctx, propsOptions: [propsOptions] } = instance;
|
7855 | if (propsOptions) {
|
7856 | Object.keys(propsOptions).forEach(key => {
|
7857 | Object.defineProperty(ctx, key, {
|
7858 | enumerable: true,
|
7859 | configurable: true,
|
7860 | get: () => instance.props[key],
|
7861 | set: NOOP
|
7862 | });
|
7863 | });
|
7864 | }
|
7865 | }
|
7866 | // dev only
|
7867 | function exposeSetupStateOnRenderContext(instance) {
|
7868 | const { ctx, setupState } = instance;
|
7869 | Object.keys(toRaw(setupState)).forEach(key => {
|
7870 | if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
|
7871 | warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
|
7872 | `which are reserved prefixes for Vue internals.`);
|
7873 | return;
|
7874 | }
|
7875 | Object.defineProperty(ctx, key, {
|
7876 | enumerable: true,
|
7877 | configurable: true,
|
7878 | get: () => setupState[key],
|
7879 | set: NOOP
|
7880 | });
|
7881 | });
|
7882 | }
|
7883 |
|
7884 | const emptyAppContext = createAppContext();
|
7885 | let uid$1 = 0;
|
7886 | function createComponentInstance(vnode, parent, suspense) {
|
7887 | const type = vnode.type;
|
7888 |
|
7889 | const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
7890 | const instance = {
|
7891 | uid: uid$1++,
|
7892 | vnode,
|
7893 | type,
|
7894 | parent,
|
7895 | appContext,
|
7896 | root: null,
|
7897 | next: null,
|
7898 | subTree: null,
|
7899 | update: null,
|
7900 | scope: new EffectScope(true ),
|
7901 | render: null,
|
7902 | proxy: null,
|
7903 | exposed: null,
|
7904 | exposeProxy: null,
|
7905 | withProxy: null,
|
7906 | provides: parent ? parent.provides : Object.create(appContext.provides),
|
7907 | accessCache: null,
|
7908 | renderCache: [],
|
7909 |
|
7910 | components: null,
|
7911 | directives: null,
|
7912 |
|
7913 | propsOptions: normalizePropsOptions(type, appContext),
|
7914 | emitsOptions: normalizeEmitsOptions(type, appContext),
|
7915 |
|
7916 | emit: null,
|
7917 | emitted: null,
|
7918 |
|
7919 | propsDefaults: EMPTY_OBJ,
|
7920 |
|
7921 | inheritAttrs: type.inheritAttrs,
|
7922 |
|
7923 | ctx: EMPTY_OBJ,
|
7924 | data: EMPTY_OBJ,
|
7925 | props: EMPTY_OBJ,
|
7926 | attrs: EMPTY_OBJ,
|
7927 | slots: EMPTY_OBJ,
|
7928 | refs: EMPTY_OBJ,
|
7929 | setupState: EMPTY_OBJ,
|
7930 | setupContext: null,
|
7931 |
|
7932 | suspense,
|
7933 | suspenseId: suspense ? suspense.pendingId : 0,
|
7934 | asyncDep: null,
|
7935 | asyncResolved: false,
|
7936 |
|
7937 |
|
7938 | isMounted: false,
|
7939 | isUnmounted: false,
|
7940 | isDeactivated: false,
|
7941 | bc: null,
|
7942 | c: null,
|
7943 | bm: null,
|
7944 | m: null,
|
7945 | bu: null,
|
7946 | u: null,
|
7947 | um: null,
|
7948 | bum: null,
|
7949 | da: null,
|
7950 | a: null,
|
7951 | rtg: null,
|
7952 | rtc: null,
|
7953 | ec: null,
|
7954 | sp: null
|
7955 | };
|
7956 | {
|
7957 | instance.ctx = createDevRenderContext(instance);
|
7958 | }
|
7959 | instance.root = parent ? parent.root : instance;
|
7960 | instance.emit = emit.bind(null, instance);
|
7961 |
|
7962 | if (vnode.ce) {
|
7963 | vnode.ce(instance);
|
7964 | }
|
7965 | return instance;
|
7966 | }
|
7967 | let currentInstance = null;
|
7968 | const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
7969 | const setCurrentInstance = (instance) => {
|
7970 | currentInstance = instance;
|
7971 | instance.scope.on();
|
7972 | };
|
7973 | const unsetCurrentInstance = () => {
|
7974 | currentInstance && currentInstance.scope.off();
|
7975 | currentInstance = null;
|
7976 | };
|
7977 | const isBuiltInTag = makeMap('slot,component');
|
7978 | function validateComponentName(name, config) {
|
7979 | const appIsNativeTag = config.isNativeTag || NO;
|
7980 | if (isBuiltInTag(name) || appIsNativeTag(name)) {
|
7981 | warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
|
7982 | }
|
7983 | }
|
7984 | function isStatefulComponent(instance) {
|
7985 | return instance.vnode.shapeFlag & 4 ;
|
7986 | }
|
7987 | let isInSSRComponentSetup = false;
|
7988 | function setupComponent(instance, isSSR = false) {
|
7989 | isInSSRComponentSetup = isSSR;
|
7990 | const { props, children } = instance.vnode;
|
7991 | const isStateful = isStatefulComponent(instance);
|
7992 | initProps(instance, props, isStateful, isSSR);
|
7993 | initSlots(instance, children);
|
7994 | const setupResult = isStateful
|
7995 | ? setupStatefulComponent(instance, isSSR)
|
7996 | : undefined;
|
7997 | isInSSRComponentSetup = false;
|
7998 | return setupResult;
|
7999 | }
|
8000 | function setupStatefulComponent(instance, isSSR) {
|
8001 | const Component = instance.type;
|
8002 | {
|
8003 | if (Component.name) {
|
8004 | validateComponentName(Component.name, instance.appContext.config);
|
8005 | }
|
8006 | if (Component.components) {
|
8007 | const names = Object.keys(Component.components);
|
8008 | for (let i = 0; i < names.length; i++) {
|
8009 | validateComponentName(names[i], instance.appContext.config);
|
8010 | }
|
8011 | }
|
8012 | if (Component.directives) {
|
8013 | const names = Object.keys(Component.directives);
|
8014 | for (let i = 0; i < names.length; i++) {
|
8015 | validateDirectiveName(names[i]);
|
8016 | }
|
8017 | }
|
8018 | if (Component.compilerOptions && isRuntimeOnly()) {
|
8019 | warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
|
8020 | `includes the runtime compiler. Since you are using a runtime-only ` +
|
8021 | `build, the options should be passed via your build tool config instead.`);
|
8022 | }
|
8023 | }
|
8024 |
|
8025 | instance.accessCache = Object.create(null);
|
8026 |
|
8027 |
|
8028 | instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
|
8029 | {
|
8030 | exposePropsOnRenderContext(instance);
|
8031 | }
|
8032 |
|
8033 | const { setup } = Component;
|
8034 | if (setup) {
|
8035 | const setupContext = (instance.setupContext =
|
8036 | setup.length > 1 ? createSetupContext(instance) : null);
|
8037 | setCurrentInstance(instance);
|
8038 | pauseTracking();
|
8039 | const setupResult = callWithErrorHandling(setup, instance, 0 , [shallowReadonly(instance.props) , setupContext]);
|
8040 | resetTracking();
|
8041 | unsetCurrentInstance();
|
8042 | if (isPromise(setupResult)) {
|
8043 | setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
|
8044 | if (isSSR) {
|
8045 |
|
8046 | return setupResult
|
8047 | .then((resolvedResult) => {
|
8048 | handleSetupResult(instance, resolvedResult, isSSR);
|
8049 | })
|
8050 | .catch(e => {
|
8051 | handleError(e, instance, 0 );
|
8052 | });
|
8053 | }
|
8054 | else {
|
8055 |
|
8056 |
|
8057 | instance.asyncDep = setupResult;
|
8058 | }
|
8059 | }
|
8060 | else {
|
8061 | handleSetupResult(instance, setupResult, isSSR);
|
8062 | }
|
8063 | }
|
8064 | else {
|
8065 | finishComponentSetup(instance, isSSR);
|
8066 | }
|
8067 | }
|
8068 | function handleSetupResult(instance, setupResult, isSSR) {
|
8069 | if (isFunction(setupResult)) {
|
8070 |
|
8071 | {
|
8072 | instance.render = setupResult;
|
8073 | }
|
8074 | }
|
8075 | else if (isObject(setupResult)) {
|
8076 | if (isVNode(setupResult)) {
|
8077 | warn$1(`setup() should not return VNodes directly - ` +
|
8078 | `return a render function instead.`);
|
8079 | }
|
8080 |
|
8081 |
|
8082 | {
|
8083 | instance.devtoolsRawSetupState = setupResult;
|
8084 | }
|
8085 | instance.setupState = proxyRefs(setupResult);
|
8086 | {
|
8087 | exposeSetupStateOnRenderContext(instance);
|
8088 | }
|
8089 | }
|
8090 | else if (setupResult !== undefined) {
|
8091 | warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
|
8092 | }
|
8093 | finishComponentSetup(instance, isSSR);
|
8094 | }
|
8095 | let compile;
|
8096 | let installWithProxy;
|
8097 |
|
8098 |
|
8099 |
|
8100 |
|
8101 | function registerRuntimeCompiler(_compile) {
|
8102 | compile = _compile;
|
8103 | installWithProxy = i => {
|
8104 | if (i.render._rc) {
|
8105 | i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
|
8106 | }
|
8107 | };
|
8108 | }
|
8109 |
|
8110 | const isRuntimeOnly = () => !compile;
|
8111 | function finishComponentSetup(instance, isSSR, skipOptions) {
|
8112 | const Component = instance.type;
|
8113 |
|
8114 | if (!instance.render) {
|
8115 |
|
8116 | if (compile && !Component.render) {
|
8117 | const template = Component.template;
|
8118 | if (template) {
|
8119 | {
|
8120 | startMeasure(instance, `compile`);
|
8121 | }
|
8122 | const { isCustomElement, compilerOptions } = instance.appContext.config;
|
8123 | const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
8124 | const finalCompilerOptions = extend(extend({
|
8125 | isCustomElement,
|
8126 | delimiters
|
8127 | }, compilerOptions), componentCompilerOptions);
|
8128 | Component.render = compile(template, finalCompilerOptions);
|
8129 | {
|
8130 | endMeasure(instance, `compile`);
|
8131 | }
|
8132 | }
|
8133 | }
|
8134 | instance.render = (Component.render || NOOP);
|
8135 |
|
8136 |
|
8137 |
|
8138 | if (installWithProxy) {
|
8139 | installWithProxy(instance);
|
8140 | }
|
8141 | }
|
8142 |
|
8143 | {
|
8144 | setCurrentInstance(instance);
|
8145 | pauseTracking();
|
8146 | applyOptions(instance);
|
8147 | resetTracking();
|
8148 | unsetCurrentInstance();
|
8149 | }
|
8150 |
|
8151 |
|
8152 | if (!Component.render && instance.render === NOOP && !isSSR) {
|
8153 |
|
8154 | if (!compile && Component.template) {
|
8155 | warn$1(`Component provided template option but ` +
|
8156 | `runtime compilation is not supported in this build of Vue.` +
|
8157 | (` Use "vue.esm-browser.js" instead.`
|
8158 | ) );
|
8159 | }
|
8160 | else {
|
8161 | warn$1(`Component is missing template or render function.`);
|
8162 | }
|
8163 | }
|
8164 | }
|
8165 | function createAttrsProxy(instance) {
|
8166 | return new Proxy(instance.attrs, {
|
8167 | get(target, key) {
|
8168 | markAttrsAccessed();
|
8169 | track(instance, "get" , '$attrs');
|
8170 | return target[key];
|
8171 | },
|
8172 | set() {
|
8173 | warn$1(`setupContext.attrs is readonly.`);
|
8174 | return false;
|
8175 | },
|
8176 | deleteProperty() {
|
8177 | warn$1(`setupContext.attrs is readonly.`);
|
8178 | return false;
|
8179 | }
|
8180 | }
|
8181 | );
|
8182 | }
|
8183 | function createSetupContext(instance) {
|
8184 | const expose = exposed => {
|
8185 | if (instance.exposed) {
|
8186 | warn$1(`expose() should be called only once per setup().`);
|
8187 | }
|
8188 | instance.exposed = exposed || {};
|
8189 | };
|
8190 | let attrs;
|
8191 | {
|
8192 |
|
8193 |
|
8194 | return Object.freeze({
|
8195 | get attrs() {
|
8196 | return attrs || (attrs = createAttrsProxy(instance));
|
8197 | },
|
8198 | get slots() {
|
8199 | return shallowReadonly(instance.slots);
|
8200 | },
|
8201 | get emit() {
|
8202 | return (event, ...args) => instance.emit(event, ...args);
|
8203 | },
|
8204 | expose
|
8205 | });
|
8206 | }
|
8207 | }
|
8208 | function getExposeProxy(instance) {
|
8209 | if (instance.exposed) {
|
8210 | return (instance.exposeProxy ||
|
8211 | (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
8212 | get(target, key) {
|
8213 | if (key in target) {
|
8214 | return target[key];
|
8215 | }
|
8216 | else if (key in publicPropertiesMap) {
|
8217 | return publicPropertiesMap[key](instance);
|
8218 | }
|
8219 | }
|
8220 | })));
|
8221 | }
|
8222 | }
|
8223 | const classifyRE = /(?:^|[-_])(\w)/g;
|
8224 | const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
|
8225 | function getComponentName(Component) {
|
8226 | return isFunction(Component)
|
8227 | ? Component.displayName || Component.name
|
8228 | : Component.name;
|
8229 | }
|
8230 |
|
8231 | function formatComponentName(instance, Component, isRoot = false) {
|
8232 | let name = getComponentName(Component);
|
8233 | if (!name && Component.__file) {
|
8234 | const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
8235 | if (match) {
|
8236 | name = match[1];
|
8237 | }
|
8238 | }
|
8239 | if (!name && instance && instance.parent) {
|
8240 |
|
8241 | const inferFromRegistry = (registry) => {
|
8242 | for (const key in registry) {
|
8243 | if (registry[key] === Component) {
|
8244 | return key;
|
8245 | }
|
8246 | }
|
8247 | };
|
8248 | name =
|
8249 | inferFromRegistry(instance.components ||
|
8250 | instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
|
8251 | }
|
8252 | return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
8253 | }
|
8254 | function isClassComponent(value) {
|
8255 | return isFunction(value) && '__vccOpts' in value;
|
8256 | }
|
8257 |
|
8258 | const stack = [];
|
8259 | function pushWarningContext(vnode) {
|
8260 | stack.push(vnode);
|
8261 | }
|
8262 | function popWarningContext() {
|
8263 | stack.pop();
|
8264 | }
|
8265 | function warn$1(msg, ...args) {
|
8266 |
|
8267 |
|
8268 | pauseTracking();
|
8269 | const instance = stack.length ? stack[stack.length - 1].component : null;
|
8270 | const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
8271 | const trace = getComponentTrace();
|
8272 | if (appWarnHandler) {
|
8273 | callWithErrorHandling(appWarnHandler, instance, 11 , [
|
8274 | msg + args.join(''),
|
8275 | instance && instance.proxy,
|
8276 | trace
|
8277 | .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
|
8278 | .join('\n'),
|
8279 | trace
|
8280 | ]);
|
8281 | }
|
8282 | else {
|
8283 | const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
8284 |
|
8285 | if (trace.length &&
|
8286 |
|
8287 | !false) {
|
8288 | warnArgs.push(`\n`, ...formatTrace(trace));
|
8289 | }
|
8290 | console.warn(...warnArgs);
|
8291 | }
|
8292 | resetTracking();
|
8293 | }
|
8294 | function getComponentTrace() {
|
8295 | let currentVNode = stack[stack.length - 1];
|
8296 | if (!currentVNode) {
|
8297 | return [];
|
8298 | }
|
8299 |
|
8300 |
|
8301 |
|
8302 | const normalizedStack = [];
|
8303 | while (currentVNode) {
|
8304 | const last = normalizedStack[0];
|
8305 | if (last && last.vnode === currentVNode) {
|
8306 | last.recurseCount++;
|
8307 | }
|
8308 | else {
|
8309 | normalizedStack.push({
|
8310 | vnode: currentVNode,
|
8311 | recurseCount: 0
|
8312 | });
|
8313 | }
|
8314 | const parentInstance = currentVNode.component && currentVNode.component.parent;
|
8315 | currentVNode = parentInstance && parentInstance.vnode;
|
8316 | }
|
8317 | return normalizedStack;
|
8318 | }
|
8319 |
|
8320 | function formatTrace(trace) {
|
8321 | const logs = [];
|
8322 | trace.forEach((entry, i) => {
|
8323 | logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
|
8324 | });
|
8325 | return logs;
|
8326 | }
|
8327 | function formatTraceEntry({ vnode, recurseCount }) {
|
8328 | const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
8329 | const isRoot = vnode.component ? vnode.component.parent == null : false;
|
8330 | const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
|
8331 | const close = `>` + postfix;
|
8332 | return vnode.props
|
8333 | ? [open, ...formatProps(vnode.props), close]
|
8334 | : [open + close];
|
8335 | }
|
8336 |
|
8337 | function formatProps(props) {
|
8338 | const res = [];
|
8339 | const keys = Object.keys(props);
|
8340 | keys.slice(0, 3).forEach(key => {
|
8341 | res.push(...formatProp(key, props[key]));
|
8342 | });
|
8343 | if (keys.length > 3) {
|
8344 | res.push(` ...`);
|
8345 | }
|
8346 | return res;
|
8347 | }
|
8348 |
|
8349 | function formatProp(key, value, raw) {
|
8350 | if (isString(value)) {
|
8351 | value = JSON.stringify(value);
|
8352 | return raw ? value : [`${key}=${value}`];
|
8353 | }
|
8354 | else if (typeof value === 'number' ||
|
8355 | typeof value === 'boolean' ||
|
8356 | value == null) {
|
8357 | return raw ? value : [`${key}=${value}`];
|
8358 | }
|
8359 | else if (isRef(value)) {
|
8360 | value = formatProp(key, toRaw(value.value), true);
|
8361 | return raw ? value : [`${key}=Ref<`, value, `>`];
|
8362 | }
|
8363 | else if (isFunction(value)) {
|
8364 | return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
8365 | }
|
8366 | else {
|
8367 | value = toRaw(value);
|
8368 | return raw ? value : [`${key}=`, value];
|
8369 | }
|
8370 | }
|
8371 |
|
8372 | const ErrorTypeStrings = {
|
8373 | ["sp" ]: 'serverPrefetch hook',
|
8374 | ["bc" ]: 'beforeCreate hook',
|
8375 | ["c" ]: 'created hook',
|
8376 | ["bm" ]: 'beforeMount hook',
|
8377 | ["m" ]: 'mounted hook',
|
8378 | ["bu" ]: 'beforeUpdate hook',
|
8379 | ["u" ]: 'updated',
|
8380 | ["bum" ]: 'beforeUnmount hook',
|
8381 | ["um" ]: 'unmounted hook',
|
8382 | ["a" ]: 'activated hook',
|
8383 | ["da" ]: 'deactivated hook',
|
8384 | ["ec" ]: 'errorCaptured hook',
|
8385 | ["rtc" ]: 'renderTracked hook',
|
8386 | ["rtg" ]: 'renderTriggered hook',
|
8387 | [0 ]: 'setup function',
|
8388 | [1 ]: 'render function',
|
8389 | [2 ]: 'watcher getter',
|
8390 | [3 ]: 'watcher callback',
|
8391 | [4 ]: 'watcher cleanup function',
|
8392 | [5 ]: 'native event handler',
|
8393 | [6 ]: 'component event handler',
|
8394 | [7 ]: 'vnode hook',
|
8395 | [8 ]: 'directive hook',
|
8396 | [9 ]: 'transition hook',
|
8397 | [10 ]: 'app errorHandler',
|
8398 | [11 ]: 'app warnHandler',
|
8399 | [12 ]: 'ref function',
|
8400 | [13 ]: 'async component loader',
|
8401 | [14 ]: 'scheduler flush. This is likely a Vue internals bug. ' +
|
8402 | 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next'
|
8403 | };
|
8404 | function callWithErrorHandling(fn, instance, type, args) {
|
8405 | let res;
|
8406 | try {
|
8407 | res = args ? fn(...args) : fn();
|
8408 | }
|
8409 | catch (err) {
|
8410 | handleError(err, instance, type);
|
8411 | }
|
8412 | return res;
|
8413 | }
|
8414 | function callWithAsyncErrorHandling(fn, instance, type, args) {
|
8415 | if (isFunction(fn)) {
|
8416 | const res = callWithErrorHandling(fn, instance, type, args);
|
8417 | if (res && isPromise(res)) {
|
8418 | res.catch(err => {
|
8419 | handleError(err, instance, type);
|
8420 | });
|
8421 | }
|
8422 | return res;
|
8423 | }
|
8424 | const values = [];
|
8425 | for (let i = 0; i < fn.length; i++) {
|
8426 | values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
8427 | }
|
8428 | return values;
|
8429 | }
|
8430 | function handleError(err, instance, type, throwInDev = true) {
|
8431 | const contextVNode = instance ? instance.vnode : null;
|
8432 | if (instance) {
|
8433 | let cur = instance.parent;
|
8434 |
|
8435 | const exposedInstance = instance.proxy;
|
8436 |
|
8437 | const errorInfo = ErrorTypeStrings[type] ;
|
8438 | while (cur) {
|
8439 | const errorCapturedHooks = cur.ec;
|
8440 | if (errorCapturedHooks) {
|
8441 | for (let i = 0; i < errorCapturedHooks.length; i++) {
|
8442 | if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
8443 | return;
|
8444 | }
|
8445 | }
|
8446 | }
|
8447 | cur = cur.parent;
|
8448 | }
|
8449 |
|
8450 | const appErrorHandler = instance.appContext.config.errorHandler;
|
8451 | if (appErrorHandler) {
|
8452 | callWithErrorHandling(appErrorHandler, null, 10 , [err, exposedInstance, errorInfo]);
|
8453 | return;
|
8454 | }
|
8455 | }
|
8456 | logError(err, type, contextVNode, throwInDev);
|
8457 | }
|
8458 | function logError(err, type, contextVNode, throwInDev = true) {
|
8459 | {
|
8460 | const info = ErrorTypeStrings[type];
|
8461 | if (contextVNode) {
|
8462 | pushWarningContext(contextVNode);
|
8463 | }
|
8464 | warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
8465 | if (contextVNode) {
|
8466 | popWarningContext();
|
8467 | }
|
8468 |
|
8469 | if (throwInDev) {
|
8470 | throw err;
|
8471 | }
|
8472 | else {
|
8473 | console.error(err);
|
8474 | }
|
8475 | }
|
8476 | }
|
8477 |
|
8478 | let isFlushing = false;
|
8479 | let isFlushPending = false;
|
8480 | const queue = [];
|
8481 | let flushIndex = 0;
|
8482 | const pendingPreFlushCbs = [];
|
8483 | let activePreFlushCbs = null;
|
8484 | let preFlushIndex = 0;
|
8485 | const pendingPostFlushCbs = [];
|
8486 | let activePostFlushCbs = null;
|
8487 | let postFlushIndex = 0;
|
8488 | const resolvedPromise = Promise.resolve();
|
8489 | let currentFlushPromise = null;
|
8490 | let currentPreFlushParentJob = null;
|
8491 | const RECURSION_LIMIT = 100;
|
8492 | function nextTick(fn) {
|
8493 | const p = currentFlushPromise || resolvedPromise;
|
8494 | return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
8495 | }
|
8496 |
|
8497 |
|
8498 |
|
8499 |
|
8500 | function findInsertionIndex(id) {
|
8501 |
|
8502 | let start = flushIndex + 1;
|
8503 | let end = queue.length;
|
8504 | while (start < end) {
|
8505 | const middle = (start + end) >>> 1;
|
8506 | const middleJobId = getId(queue[middle]);
|
8507 | middleJobId < id ? (start = middle + 1) : (end = middle);
|
8508 | }
|
8509 | return start;
|
8510 | }
|
8511 | function queueJob(job) {
|
8512 |
|
8513 |
|
8514 |
|
8515 |
|
8516 |
|
8517 |
|
8518 | if ((!queue.length ||
|
8519 | !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
|
8520 | job !== currentPreFlushParentJob) {
|
8521 | if (job.id == null) {
|
8522 | queue.push(job);
|
8523 | }
|
8524 | else {
|
8525 | queue.splice(findInsertionIndex(job.id), 0, job);
|
8526 | }
|
8527 | queueFlush();
|
8528 | }
|
8529 | }
|
8530 | function queueFlush() {
|
8531 | if (!isFlushing && !isFlushPending) {
|
8532 | isFlushPending = true;
|
8533 | currentFlushPromise = resolvedPromise.then(flushJobs);
|
8534 | }
|
8535 | }
|
8536 | function invalidateJob(job) {
|
8537 | const i = queue.indexOf(job);
|
8538 | if (i > flushIndex) {
|
8539 | queue.splice(i, 1);
|
8540 | }
|
8541 | }
|
8542 | function queueCb(cb, activeQueue, pendingQueue, index) {
|
8543 | if (!isArray(cb)) {
|
8544 | if (!activeQueue ||
|
8545 | !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
|
8546 | pendingQueue.push(cb);
|
8547 | }
|
8548 | }
|
8549 | else {
|
8550 |
|
8551 |
|
8552 |
|
8553 | pendingQueue.push(...cb);
|
8554 | }
|
8555 | queueFlush();
|
8556 | }
|
8557 | function queuePreFlushCb(cb) {
|
8558 | queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
|
8559 | }
|
8560 | function queuePostFlushCb(cb) {
|
8561 | queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
|
8562 | }
|
8563 | function flushPreFlushCbs(seen, parentJob = null) {
|
8564 | if (pendingPreFlushCbs.length) {
|
8565 | currentPreFlushParentJob = parentJob;
|
8566 | activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
|
8567 | pendingPreFlushCbs.length = 0;
|
8568 | {
|
8569 | seen = seen || new Map();
|
8570 | }
|
8571 | for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
|
8572 | if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
|
8573 | continue;
|
8574 | }
|
8575 | activePreFlushCbs[preFlushIndex]();
|
8576 | }
|
8577 | activePreFlushCbs = null;
|
8578 | preFlushIndex = 0;
|
8579 | currentPreFlushParentJob = null;
|
8580 |
|
8581 | flushPreFlushCbs(seen, parentJob);
|
8582 | }
|
8583 | }
|
8584 | function flushPostFlushCbs(seen) {
|
8585 | if (pendingPostFlushCbs.length) {
|
8586 | const deduped = [...new Set(pendingPostFlushCbs)];
|
8587 | pendingPostFlushCbs.length = 0;
|
8588 |
|
8589 | if (activePostFlushCbs) {
|
8590 | activePostFlushCbs.push(...deduped);
|
8591 | return;
|
8592 | }
|
8593 | activePostFlushCbs = deduped;
|
8594 | {
|
8595 | seen = seen || new Map();
|
8596 | }
|
8597 | activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
|
8598 | for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
8599 | if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
|
8600 | continue;
|
8601 | }
|
8602 | activePostFlushCbs[postFlushIndex]();
|
8603 | }
|
8604 | activePostFlushCbs = null;
|
8605 | postFlushIndex = 0;
|
8606 | }
|
8607 | }
|
8608 | const getId = (job) => job.id == null ? Infinity : job.id;
|
8609 | function flushJobs(seen) {
|
8610 | isFlushPending = false;
|
8611 | isFlushing = true;
|
8612 | {
|
8613 | seen = seen || new Map();
|
8614 | }
|
8615 | flushPreFlushCbs(seen);
|
8616 |
|
8617 |
|
8618 |
|
8619 |
|
8620 |
|
8621 |
|
8622 |
|
8623 | queue.sort((a, b) => getId(a) - getId(b));
|
8624 | try {
|
8625 | for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
8626 | const job = queue[flushIndex];
|
8627 | if (job && job.active !== false) {
|
8628 | if (true && checkRecursiveUpdates(seen, job)) {
|
8629 | continue;
|
8630 | }
|
8631 |
|
8632 | callWithErrorHandling(job, null, 14 );
|
8633 | }
|
8634 | }
|
8635 | }
|
8636 | finally {
|
8637 | flushIndex = 0;
|
8638 | queue.length = 0;
|
8639 | flushPostFlushCbs(seen);
|
8640 | isFlushing = false;
|
8641 | currentFlushPromise = null;
|
8642 |
|
8643 |
|
8644 | if (queue.length ||
|
8645 | pendingPreFlushCbs.length ||
|
8646 | pendingPostFlushCbs.length) {
|
8647 | flushJobs(seen);
|
8648 | }
|
8649 | }
|
8650 | }
|
8651 | function checkRecursiveUpdates(seen, fn) {
|
8652 | if (!seen.has(fn)) {
|
8653 | seen.set(fn, 1);
|
8654 | }
|
8655 | else {
|
8656 | const count = seen.get(fn);
|
8657 | if (count > RECURSION_LIMIT) {
|
8658 | const instance = fn.ownerInstance;
|
8659 | const componentName = instance && getComponentName(instance.type);
|
8660 | warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
|
8661 | `This means you have a reactive effect that is mutating its own ` +
|
8662 | `dependencies and thus recursively triggering itself. Possible sources ` +
|
8663 | `include component template, render function, updated hook or ` +
|
8664 | `watcher source function.`);
|
8665 | return true;
|
8666 | }
|
8667 | else {
|
8668 | seen.set(fn, count + 1);
|
8669 | }
|
8670 | }
|
8671 | }
|
8672 |
|
8673 |
|
8674 | function watchEffect(effect, options) {
|
8675 | return doWatch(effect, null, options);
|
8676 | }
|
8677 | function watchPostEffect(effect, options) {
|
8678 | return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
|
8679 | ));
|
8680 | }
|
8681 | function watchSyncEffect(effect, options) {
|
8682 | return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
|
8683 | ));
|
8684 | }
|
8685 |
|
8686 | const INITIAL_WATCHER_VALUE = {};
|
8687 |
|
8688 | function watch(source, cb, options) {
|
8689 | if (!isFunction(cb)) {
|
8690 | warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
|
8691 | `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
|
8692 | `supports \`watch(source, cb, options?) signature.`);
|
8693 | }
|
8694 | return doWatch(source, cb, options);
|
8695 | }
|
8696 | function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
|
8697 | if (!cb) {
|
8698 | if (immediate !== undefined) {
|
8699 | warn$1(`watch() "immediate" option is only respected when using the ` +
|
8700 | `watch(source, callback, options?) signature.`);
|
8701 | }
|
8702 | if (deep !== undefined) {
|
8703 | warn$1(`watch() "deep" option is only respected when using the ` +
|
8704 | `watch(source, callback, options?) signature.`);
|
8705 | }
|
8706 | }
|
8707 | const warnInvalidSource = (s) => {
|
8708 | warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
|
8709 | `a reactive object, or an array of these types.`);
|
8710 | };
|
8711 | const instance = currentInstance;
|
8712 | let getter;
|
8713 | let forceTrigger = false;
|
8714 | let isMultiSource = false;
|
8715 | if (isRef(source)) {
|
8716 | getter = () => source.value;
|
8717 | forceTrigger = !!source._shallow;
|
8718 | }
|
8719 | else if (isReactive(source)) {
|
8720 | getter = () => source;
|
8721 | deep = true;
|
8722 | }
|
8723 | else if (isArray(source)) {
|
8724 | isMultiSource = true;
|
8725 | forceTrigger = source.some(isReactive);
|
8726 | getter = () => source.map(s => {
|
8727 | if (isRef(s)) {
|
8728 | return s.value;
|
8729 | }
|
8730 | else if (isReactive(s)) {
|
8731 | return traverse(s);
|
8732 | }
|
8733 | else if (isFunction(s)) {
|
8734 | return callWithErrorHandling(s, instance, 2 );
|
8735 | }
|
8736 | else {
|
8737 | warnInvalidSource(s);
|
8738 | }
|
8739 | });
|
8740 | }
|
8741 | else if (isFunction(source)) {
|
8742 | if (cb) {
|
8743 |
|
8744 | getter = () => callWithErrorHandling(source, instance, 2 );
|
8745 | }
|
8746 | else {
|
8747 |
|
8748 | getter = () => {
|
8749 | if (instance && instance.isUnmounted) {
|
8750 | return;
|
8751 | }
|
8752 | if (cleanup) {
|
8753 | cleanup();
|
8754 | }
|
8755 | return callWithAsyncErrorHandling(source, instance, 3 , [onInvalidate]);
|
8756 | };
|
8757 | }
|
8758 | }
|
8759 | else {
|
8760 | getter = NOOP;
|
8761 | warnInvalidSource(source);
|
8762 | }
|
8763 | if (cb && deep) {
|
8764 | const baseGetter = getter;
|
8765 | getter = () => traverse(baseGetter());
|
8766 | }
|
8767 | let cleanup;
|
8768 | let onInvalidate = (fn) => {
|
8769 | cleanup = effect.onStop = () => {
|
8770 | callWithErrorHandling(fn, instance, 4 );
|
8771 | };
|
8772 | };
|
8773 | let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
|
8774 | const job = () => {
|
8775 | if (!effect.active) {
|
8776 | return;
|
8777 | }
|
8778 | if (cb) {
|
8779 |
|
8780 | const newValue = effect.run();
|
8781 | if (deep ||
|
8782 | forceTrigger ||
|
8783 | (isMultiSource
|
8784 | ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
|
8785 | : hasChanged(newValue, oldValue)) ||
|
8786 | (false )) {
|
8787 |
|
8788 | if (cleanup) {
|
8789 | cleanup();
|
8790 | }
|
8791 | callWithAsyncErrorHandling(cb, instance, 3 , [
|
8792 | newValue,
|
8793 |
|
8794 | oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
|
8795 | onInvalidate
|
8796 | ]);
|
8797 | oldValue = newValue;
|
8798 | }
|
8799 | }
|
8800 | else {
|
8801 |
|
8802 | effect.run();
|
8803 | }
|
8804 | };
|
8805 |
|
8806 |
|
8807 | job.allowRecurse = !!cb;
|
8808 | let scheduler;
|
8809 | if (flush === 'sync') {
|
8810 | scheduler = job;
|
8811 | }
|
8812 | else if (flush === 'post') {
|
8813 | scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
8814 | }
|
8815 | else {
|
8816 |
|
8817 | scheduler = () => {
|
8818 | if (!instance || instance.isMounted) {
|
8819 | queuePreFlushCb(job);
|
8820 | }
|
8821 | else {
|
8822 |
|
8823 |
|
8824 | job();
|
8825 | }
|
8826 | };
|
8827 | }
|
8828 | const effect = new ReactiveEffect(getter, scheduler);
|
8829 | {
|
8830 | effect.onTrack = onTrack;
|
8831 | effect.onTrigger = onTrigger;
|
8832 | }
|
8833 |
|
8834 | if (cb) {
|
8835 | if (immediate) {
|
8836 | job();
|
8837 | }
|
8838 | else {
|
8839 | oldValue = effect.run();
|
8840 | }
|
8841 | }
|
8842 | else if (flush === 'post') {
|
8843 | queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
|
8844 | }
|
8845 | else {
|
8846 | effect.run();
|
8847 | }
|
8848 | return () => {
|
8849 | effect.stop();
|
8850 | if (instance && instance.scope) {
|
8851 | remove(instance.scope.effects, effect);
|
8852 | }
|
8853 | };
|
8854 | }
|
8855 |
|
8856 | function instanceWatch(source, value, options) {
|
8857 | const publicThis = this.proxy;
|
8858 | const getter = isString(source)
|
8859 | ? source.includes('.')
|
8860 | ? createPathGetter(publicThis, source)
|
8861 | : () => publicThis[source]
|
8862 | : source.bind(publicThis, publicThis);
|
8863 | let cb;
|
8864 | if (isFunction(value)) {
|
8865 | cb = value;
|
8866 | }
|
8867 | else {
|
8868 | cb = value.handler;
|
8869 | options = value;
|
8870 | }
|
8871 | const cur = currentInstance;
|
8872 | setCurrentInstance(this);
|
8873 | const res = doWatch(getter, cb.bind(publicThis), options);
|
8874 | if (cur) {
|
8875 | setCurrentInstance(cur);
|
8876 | }
|
8877 | else {
|
8878 | unsetCurrentInstance();
|
8879 | }
|
8880 | return res;
|
8881 | }
|
8882 | function createPathGetter(ctx, path) {
|
8883 | const segments = path.split('.');
|
8884 | return () => {
|
8885 | let cur = ctx;
|
8886 | for (let i = 0; i < segments.length && cur; i++) {
|
8887 | cur = cur[segments[i]];
|
8888 | }
|
8889 | return cur;
|
8890 | };
|
8891 | }
|
8892 | function traverse(value, seen = new Set()) {
|
8893 | if (!isObject(value) || value["__v_skip" ]) {
|
8894 | return value;
|
8895 | }
|
8896 | seen = seen || new Set();
|
8897 | if (seen.has(value)) {
|
8898 | return value;
|
8899 | }
|
8900 | seen.add(value);
|
8901 | if (isRef(value)) {
|
8902 | traverse(value.value, seen);
|
8903 | }
|
8904 | else if (isArray(value)) {
|
8905 | for (let i = 0; i < value.length; i++) {
|
8906 | traverse(value[i], seen);
|
8907 | }
|
8908 | }
|
8909 | else if (isSet(value) || isMap(value)) {
|
8910 | value.forEach((v) => {
|
8911 | traverse(v, seen);
|
8912 | });
|
8913 | }
|
8914 | else if (isPlainObject(value)) {
|
8915 | for (const key in value) {
|
8916 | traverse(value[key], seen);
|
8917 | }
|
8918 | }
|
8919 | return value;
|
8920 | }
|
8921 |
|
8922 |
|
8923 | const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
|
8924 | `<script setup> of a single file component. Its arguments should be ` +
|
8925 | `compiled away and passing it at runtime has no effect.`);
|
8926 |
|
8927 | function defineProps() {
|
8928 | {
|
8929 | warnRuntimeUsage(`defineProps`);
|
8930 | }
|
8931 | return null;
|
8932 | }
|
8933 |
|
8934 | function defineEmits() {
|
8935 | {
|
8936 | warnRuntimeUsage(`defineEmits`);
|
8937 | }
|
8938 | return null;
|
8939 | }
|
8940 |
|
8941 |
|
8942 |
|
8943 |
|
8944 |
|
8945 |
|
8946 |
|
8947 |
|
8948 |
|
8949 |
|
8950 |
|
8951 |
|
8952 | function defineExpose(exposed) {
|
8953 | {
|
8954 | warnRuntimeUsage(`defineExpose`);
|
8955 | }
|
8956 | }
|
8957 |
|
8958 |
|
8959 |
|
8960 |
|
8961 |
|
8962 |
|
8963 |
|
8964 |
|
8965 |
|
8966 |
|
8967 |
|
8968 |
|
8969 |
|
8970 |
|
8971 |
|
8972 |
|
8973 |
|
8974 |
|
8975 | function withDefaults(props, defaults) {
|
8976 | {
|
8977 | warnRuntimeUsage(`withDefaults`);
|
8978 | }
|
8979 | return null;
|
8980 | }
|
8981 | function useSlots() {
|
8982 | return getContext().slots;
|
8983 | }
|
8984 | function useAttrs() {
|
8985 | return getContext().attrs;
|
8986 | }
|
8987 | function getContext() {
|
8988 | const i = getCurrentInstance();
|
8989 | if (!i) {
|
8990 | warn$1(`useContext() called without active instance.`);
|
8991 | }
|
8992 | return i.setupContext || (i.setupContext = createSetupContext(i));
|
8993 | }
|
8994 |
|
8995 |
|
8996 |
|
8997 |
|
8998 |
|
8999 | function mergeDefaults(
|
9000 | // the base props is compiler-generated and guaranteed to be in this shape.
|
9001 | props, defaults) {
|
9002 | for (const key in defaults) {
|
9003 | const val = props[key];
|
9004 | if (val) {
|
9005 | val.default = defaults[key];
|
9006 | }
|
9007 | else if (val === null) {
|
9008 | props[key] = { default: defaults[key] };
|
9009 | }
|
9010 | else {
|
9011 | warn$1(`props default key "${key}" has no corresponding declaration.`);
|
9012 | }
|
9013 | }
|
9014 | return props;
|
9015 | }
|
9016 |
|
9017 |
|
9018 |
|
9019 |
|
9020 |
|
9021 |
|
9022 |
|
9023 |
|
9024 |
|
9025 |
|
9026 |
|
9027 |
|
9028 |
|
9029 |
|
9030 |
|
9031 |
|
9032 |
|
9033 |
|
9034 | function withAsyncContext(getAwaitable) {
|
9035 | const ctx = getCurrentInstance();
|
9036 | if (!ctx) {
|
9037 | warn$1(`withAsyncContext called without active current instance. ` +
|
9038 | `This is likely a bug.`);
|
9039 | }
|
9040 | let awaitable = getAwaitable();
|
9041 | unsetCurrentInstance();
|
9042 | if (isPromise(awaitable)) {
|
9043 | awaitable = awaitable.catch(e => {
|
9044 | setCurrentInstance(ctx);
|
9045 | throw e;
|
9046 | });
|
9047 | }
|
9048 | return [awaitable, () => setCurrentInstance(ctx)];
|
9049 | }
|
9050 |
|
9051 |
|
9052 | function h(type, propsOrChildren, children) {
|
9053 | const l = arguments.length;
|
9054 | if (l === 2) {
|
9055 | if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
|
9056 |
|
9057 | if (isVNode(propsOrChildren)) {
|
9058 | return createVNode(type, null, [propsOrChildren]);
|
9059 | }
|
9060 |
|
9061 | return createVNode(type, propsOrChildren);
|
9062 | }
|
9063 | else {
|
9064 |
|
9065 | return createVNode(type, null, propsOrChildren);
|
9066 | }
|
9067 | }
|
9068 | else {
|
9069 | if (l > 3) {
|
9070 | children = Array.prototype.slice.call(arguments, 2);
|
9071 | }
|
9072 | else if (l === 3 && isVNode(children)) {
|
9073 | children = [children];
|
9074 | }
|
9075 | return createVNode(type, propsOrChildren, children);
|
9076 | }
|
9077 | }
|
9078 |
|
9079 | const ssrContextKey = Symbol(`ssrContext` );
|
9080 | const useSSRContext = () => {
|
9081 | {
|
9082 | const ctx = inject(ssrContextKey);
|
9083 | if (!ctx) {
|
9084 | warn$1(`Server rendering context not provided. Make sure to only call ` +
|
9085 | `useSSRContext() conditionally in the server build.`);
|
9086 | }
|
9087 | return ctx;
|
9088 | }
|
9089 | };
|
9090 |
|
9091 | function initCustomFormatter() {
|
9092 |
|
9093 | if (typeof window === 'undefined') {
|
9094 | return;
|
9095 | }
|
9096 | const vueStyle = { style: 'color:#3ba776' };
|
9097 | const numberStyle = { style: 'color:#0b1bc9' };
|
9098 | const stringStyle = { style: 'color:#b62e24' };
|
9099 | const keywordStyle = { style: 'color:#9d288c' };
|
9100 |
|
9101 |
|
9102 | const formatter = {
|
9103 | header(obj) {
|
9104 |
|
9105 | if (!isObject(obj)) {
|
9106 | return null;
|
9107 | }
|
9108 | if (obj.__isVue) {
|
9109 | return ['div', vueStyle, `VueInstance`];
|
9110 | }
|
9111 | else if (isRef(obj)) {
|
9112 | return [
|
9113 | 'div',
|
9114 | {},
|
9115 | ['span', vueStyle, genRefFlag(obj)],
|
9116 | '<',
|
9117 | formatValue(obj.value),
|
9118 | `>`
|
9119 | ];
|
9120 | }
|
9121 | else if (isReactive(obj)) {
|
9122 | return [
|
9123 | 'div',
|
9124 | {},
|
9125 | ['span', vueStyle, 'Reactive'],
|
9126 | '<',
|
9127 | formatValue(obj),
|
9128 | `>${isReadonly(obj) ? ` (readonly)` : ``}`
|
9129 | ];
|
9130 | }
|
9131 | else if (isReadonly(obj)) {
|
9132 | return [
|
9133 | 'div',
|
9134 | {},
|
9135 | ['span', vueStyle, 'Readonly'],
|
9136 | '<',
|
9137 | formatValue(obj),
|
9138 | '>'
|
9139 | ];
|
9140 | }
|
9141 | return null;
|
9142 | },
|
9143 | hasBody(obj) {
|
9144 | return obj && obj.__isVue;
|
9145 | },
|
9146 | body(obj) {
|
9147 | if (obj && obj.__isVue) {
|
9148 | return [
|
9149 | 'div',
|
9150 | {},
|
9151 | ...formatInstance(obj.$)
|
9152 | ];
|
9153 | }
|
9154 | }
|
9155 | };
|
9156 | function formatInstance(instance) {
|
9157 | const blocks = [];
|
9158 | if (instance.type.props && instance.props) {
|
9159 | blocks.push(createInstanceBlock('props', toRaw(instance.props)));
|
9160 | }
|
9161 | if (instance.setupState !== EMPTY_OBJ) {
|
9162 | blocks.push(createInstanceBlock('setup', instance.setupState));
|
9163 | }
|
9164 | if (instance.data !== EMPTY_OBJ) {
|
9165 | blocks.push(createInstanceBlock('data', toRaw(instance.data)));
|
9166 | }
|
9167 | const computed = extractKeys(instance, 'computed');
|
9168 | if (computed) {
|
9169 | blocks.push(createInstanceBlock('computed', computed));
|
9170 | }
|
9171 | const injected = extractKeys(instance, 'inject');
|
9172 | if (injected) {
|
9173 | blocks.push(createInstanceBlock('injected', injected));
|
9174 | }
|
9175 | blocks.push([
|
9176 | 'div',
|
9177 | {},
|
9178 | [
|
9179 | 'span',
|
9180 | {
|
9181 | style: keywordStyle.style + ';opacity:0.66'
|
9182 | },
|
9183 | '$ (internal): '
|
9184 | ],
|
9185 | ['object', { object: instance }]
|
9186 | ]);
|
9187 | return blocks;
|
9188 | }
|
9189 | function createInstanceBlock(type, target) {
|
9190 | target = extend({}, target);
|
9191 | if (!Object.keys(target).length) {
|
9192 | return ['span', {}];
|
9193 | }
|
9194 | return [
|
9195 | 'div',
|
9196 | { style: 'line-height:1.25em;margin-bottom:0.6em' },
|
9197 | [
|
9198 | 'div',
|
9199 | {
|
9200 | style: 'color:#476582'
|
9201 | },
|
9202 | type
|
9203 | ],
|
9204 | [
|
9205 | 'div',
|
9206 | {
|
9207 | style: 'padding-left:1.25em'
|
9208 | },
|
9209 | ...Object.keys(target).map(key => {
|
9210 | return [
|
9211 | 'div',
|
9212 | {},
|
9213 | ['span', keywordStyle, key + ': '],
|
9214 | formatValue(target[key], false)
|
9215 | ];
|
9216 | })
|
9217 | ]
|
9218 | ];
|
9219 | }
|
9220 | function formatValue(v, asRaw = true) {
|
9221 | if (typeof v === 'number') {
|
9222 | return ['span', numberStyle, v];
|
9223 | }
|
9224 | else if (typeof v === 'string') {
|
9225 | return ['span', stringStyle, JSON.stringify(v)];
|
9226 | }
|
9227 | else if (typeof v === 'boolean') {
|
9228 | return ['span', keywordStyle, v];
|
9229 | }
|
9230 | else if (isObject(v)) {
|
9231 | return ['object', { object: asRaw ? toRaw(v) : v }];
|
9232 | }
|
9233 | else {
|
9234 | return ['span', stringStyle, String(v)];
|
9235 | }
|
9236 | }
|
9237 | function extractKeys(instance, type) {
|
9238 | const Comp = instance.type;
|
9239 | if (isFunction(Comp)) {
|
9240 | return;
|
9241 | }
|
9242 | const extracted = {};
|
9243 | for (const key in instance.ctx) {
|
9244 | if (isKeyOfType(Comp, key, type)) {
|
9245 | extracted[key] = instance.ctx[key];
|
9246 | }
|
9247 | }
|
9248 | return extracted;
|
9249 | }
|
9250 | function isKeyOfType(Comp, key, type) {
|
9251 | const opts = Comp[type];
|
9252 | if ((isArray(opts) && opts.includes(key)) ||
|
9253 | (isObject(opts) && key in opts)) {
|
9254 | return true;
|
9255 | }
|
9256 | if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
|
9257 | return true;
|
9258 | }
|
9259 | if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
|
9260 | return true;
|
9261 | }
|
9262 | }
|
9263 | function genRefFlag(v) {
|
9264 | if (v._shallow) {
|
9265 | return `ShallowRef`;
|
9266 | }
|
9267 | if (v.effect) {
|
9268 | return `ComputedRef`;
|
9269 | }
|
9270 | return `Ref`;
|
9271 | }
|
9272 | if (window.devtoolsFormatters) {
|
9273 | window.devtoolsFormatters.push(formatter);
|
9274 | }
|
9275 | else {
|
9276 | window.devtoolsFormatters = [formatter];
|
9277 | }
|
9278 | }
|
9279 |
|
9280 | function withMemo(memo, render, cache, index) {
|
9281 | const cached = cache[index];
|
9282 | if (cached && isMemoSame(cached, memo)) {
|
9283 | return cached;
|
9284 | }
|
9285 | const ret = render();
|
9286 |
|
9287 | ret.memo = memo.slice();
|
9288 | return (cache[index] = ret);
|
9289 | }
|
9290 | function isMemoSame(cached, memo) {
|
9291 | const prev = cached.memo;
|
9292 | if (prev.length != memo.length) {
|
9293 | return false;
|
9294 | }
|
9295 | for (let i = 0; i < prev.length; i++) {
|
9296 | if (prev[i] !== memo[i]) {
|
9297 | return false;
|
9298 | }
|
9299 | }
|
9300 |
|
9301 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
9302 | currentBlock.push(cached);
|
9303 | }
|
9304 | return true;
|
9305 | }
|
9306 |
|
9307 |
|
9308 | const version = "3.2.10";
|
9309 |
|
9310 |
|
9311 |
|
9312 |
|
9313 | const ssrUtils = (null);
|
9314 |
|
9315 |
|
9316 |
|
9317 | const resolveFilter = null;
|
9318 |
|
9319 |
|
9320 |
|
9321 | const compatUtils = (null);
|
9322 |
|
9323 | const svgNS = 'http://www.w3.org/2000/svg';
|
9324 | const doc = (typeof document !== 'undefined' ? document : null);
|
9325 | const staticTemplateCache = new Map();
|
9326 | const nodeOps = {
|
9327 | insert: (child, parent, anchor) => {
|
9328 | parent.insertBefore(child, anchor || null);
|
9329 | },
|
9330 | remove: child => {
|
9331 | const parent = child.parentNode;
|
9332 | if (parent) {
|
9333 | parent.removeChild(child);
|
9334 | }
|
9335 | },
|
9336 | createElement: (tag, isSVG, is, props) => {
|
9337 | const el = isSVG
|
9338 | ? doc.createElementNS(svgNS, tag)
|
9339 | : doc.createElement(tag, is ? { is } : undefined);
|
9340 | if (tag === 'select' && props && props.multiple != null) {
|
9341 | el.setAttribute('multiple', props.multiple);
|
9342 | }
|
9343 | return el;
|
9344 | },
|
9345 | createText: text => doc.createTextNode(text),
|
9346 | createComment: text => doc.createComment(text),
|
9347 | setText: (node, text) => {
|
9348 | node.nodeValue = text;
|
9349 | },
|
9350 | setElementText: (el, text) => {
|
9351 | el.textContent = text;
|
9352 | },
|
9353 | parentNode: node => node.parentNode,
|
9354 | nextSibling: node => node.nextSibling,
|
9355 | querySelector: selector => doc.querySelector(selector),
|
9356 | setScopeId(el, id) {
|
9357 | el.setAttribute(id, '');
|
9358 | },
|
9359 | cloneNode(el) {
|
9360 | const cloned = el.cloneNode(true);
|
9361 |
|
9362 |
|
9363 |
|
9364 |
|
9365 |
|
9366 |
|
9367 |
|
9368 |
|
9369 |
|
9370 | if (`_value` in el) {
|
9371 | cloned._value = el._value;
|
9372 | }
|
9373 | return cloned;
|
9374 | },
|
9375 |
|
9376 |
|
9377 |
|
9378 |
|
9379 | insertStaticContent(content, parent, anchor, isSVG) {
|
9380 |
|
9381 | const before = anchor ? anchor.previousSibling : parent.lastChild;
|
9382 | let template = staticTemplateCache.get(content);
|
9383 | if (!template) {
|
9384 | const t = doc.createElement('template');
|
9385 | t.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
|
9386 | template = t.content;
|
9387 | if (isSVG) {
|
9388 |
|
9389 | const wrapper = template.firstChild;
|
9390 | while (wrapper.firstChild) {
|
9391 | template.appendChild(wrapper.firstChild);
|
9392 | }
|
9393 | template.removeChild(wrapper);
|
9394 | }
|
9395 | staticTemplateCache.set(content, template);
|
9396 | }
|
9397 | parent.insertBefore(template.cloneNode(true), anchor);
|
9398 | return [
|
9399 |
|
9400 | before ? before.nextSibling : parent.firstChild,
|
9401 |
|
9402 | anchor ? anchor.previousSibling : parent.lastChild
|
9403 | ];
|
9404 | }
|
9405 | };
|
9406 |
|
9407 |
|
9408 |
|
9409 | function patchClass(el, value, isSVG) {
|
9410 |
|
9411 |
|
9412 |
|
9413 | const transitionClasses = el._vtc;
|
9414 | if (transitionClasses) {
|
9415 | value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
|
9416 | }
|
9417 | if (value == null) {
|
9418 | el.removeAttribute('class');
|
9419 | }
|
9420 | else if (isSVG) {
|
9421 | el.setAttribute('class', value);
|
9422 | }
|
9423 | else {
|
9424 | el.className = value;
|
9425 | }
|
9426 | }
|
9427 |
|
9428 | function patchStyle(el, prev, next) {
|
9429 | const style = el.style;
|
9430 | const currentDisplay = style.display;
|
9431 | if (!next) {
|
9432 | el.removeAttribute('style');
|
9433 | }
|
9434 | else if (isString(next)) {
|
9435 | if (prev !== next) {
|
9436 | style.cssText = next;
|
9437 | }
|
9438 | }
|
9439 | else {
|
9440 | for (const key in next) {
|
9441 | setStyle(style, key, next[key]);
|
9442 | }
|
9443 | if (prev && !isString(prev)) {
|
9444 | for (const key in prev) {
|
9445 | if (next[key] == null) {
|
9446 | setStyle(style, key, '');
|
9447 | }
|
9448 | }
|
9449 | }
|
9450 | }
|
9451 |
|
9452 |
|
9453 |
|
9454 | if ('_vod' in el) {
|
9455 | style.display = currentDisplay;
|
9456 | }
|
9457 | }
|
9458 | const importantRE = /\s*!important$/;
|
9459 | function setStyle(style, name, val) {
|
9460 | if (isArray(val)) {
|
9461 | val.forEach(v => setStyle(style, name, v));
|
9462 | }
|
9463 | else {
|
9464 | if (name.startsWith('--')) {
|
9465 |
|
9466 | style.setProperty(name, val);
|
9467 | }
|
9468 | else {
|
9469 | const prefixed = autoPrefix(style, name);
|
9470 | if (importantRE.test(val)) {
|
9471 |
|
9472 | style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
|
9473 | }
|
9474 | else {
|
9475 | style[prefixed] = val;
|
9476 | }
|
9477 | }
|
9478 | }
|
9479 | }
|
9480 | const prefixes = ['Webkit', 'Moz', 'ms'];
|
9481 | const prefixCache = {};
|
9482 | function autoPrefix(style, rawName) {
|
9483 | const cached = prefixCache[rawName];
|
9484 | if (cached) {
|
9485 | return cached;
|
9486 | }
|
9487 | let name = camelize(rawName);
|
9488 | if (name !== 'filter' && name in style) {
|
9489 | return (prefixCache[rawName] = name);
|
9490 | }
|
9491 | name = capitalize(name);
|
9492 | for (let i = 0; i < prefixes.length; i++) {
|
9493 | const prefixed = prefixes[i] + name;
|
9494 | if (prefixed in style) {
|
9495 | return (prefixCache[rawName] = prefixed);
|
9496 | }
|
9497 | }
|
9498 | return rawName;
|
9499 | }
|
9500 |
|
9501 | const xlinkNS = 'http://www.w3.org/1999/xlink';
|
9502 | function patchAttr(el, key, value, isSVG, instance) {
|
9503 | if (isSVG && key.startsWith('xlink:')) {
|
9504 | if (value == null) {
|
9505 | el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
9506 | }
|
9507 | else {
|
9508 | el.setAttributeNS(xlinkNS, key, value);
|
9509 | }
|
9510 | }
|
9511 | else {
|
9512 |
|
9513 |
|
9514 | const isBoolean = isSpecialBooleanAttr(key);
|
9515 | if (value == null || (isBoolean && !includeBooleanAttr(value))) {
|
9516 | el.removeAttribute(key);
|
9517 | }
|
9518 | else {
|
9519 | el.setAttribute(key, isBoolean ? '' : value);
|
9520 | }
|
9521 | }
|
9522 | }
|
9523 |
|
9524 |
|
9525 |
|
9526 | function patchDOMProp(el, key, value,
|
9527 | // the following args are passed only due to potential innerHTML/textContent
|
9528 |
|
9529 |
|
9530 | prevChildren, parentComponent, parentSuspense, unmountChildren) {
|
9531 | if (key === 'innerHTML' || key === 'textContent') {
|
9532 | if (prevChildren) {
|
9533 | unmountChildren(prevChildren, parentComponent, parentSuspense);
|
9534 | }
|
9535 | el[key] = value == null ? '' : value;
|
9536 | return;
|
9537 | }
|
9538 | if (key === 'value' && el.tagName !== 'PROGRESS') {
|
9539 |
|
9540 |
|
9541 | el._value = value;
|
9542 | const newValue = value == null ? '' : value;
|
9543 | if (el.value !== newValue) {
|
9544 | el.value = newValue;
|
9545 | }
|
9546 | if (value == null) {
|
9547 | el.removeAttribute(key);
|
9548 | }
|
9549 | return;
|
9550 | }
|
9551 | if (value === '' || value == null) {
|
9552 | const type = typeof el[key];
|
9553 | if (type === 'boolean') {
|
9554 |
|
9555 | el[key] = includeBooleanAttr(value);
|
9556 | return;
|
9557 | }
|
9558 | else if (value == null && type === 'string') {
|
9559 |
|
9560 | el[key] = '';
|
9561 | el.removeAttribute(key);
|
9562 | return;
|
9563 | }
|
9564 | else if (type === 'number') {
|
9565 |
|
9566 |
|
9567 | try {
|
9568 | el[key] = 0;
|
9569 | }
|
9570 | catch (_a) { }
|
9571 | el.removeAttribute(key);
|
9572 | return;
|
9573 | }
|
9574 | }
|
9575 |
|
9576 | try {
|
9577 | el[key] = value;
|
9578 | }
|
9579 | catch (e) {
|
9580 | {
|
9581 | warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
|
9582 | `value ${value} is invalid.`, e);
|
9583 | }
|
9584 | }
|
9585 | }
|
9586 |
|
9587 |
|
9588 | let _getNow = Date.now;
|
9589 | let skipTimestampCheck = false;
|
9590 | if (typeof window !== 'undefined') {
|
9591 |
|
9592 |
|
9593 |
|
9594 |
|
9595 | if (_getNow() > document.createEvent('Event').timeStamp) {
|
9596 |
|
9597 |
|
9598 |
|
9599 | _getNow = () => performance.now();
|
9600 | }
|
9601 |
|
9602 |
|
9603 | const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
|
9604 | skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
|
9605 | }
|
9606 |
|
9607 |
|
9608 | let cachedNow = 0;
|
9609 | const p = Promise.resolve();
|
9610 | const reset = () => {
|
9611 | cachedNow = 0;
|
9612 | };
|
9613 | const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
|
9614 | function addEventListener(el, event, handler, options) {
|
9615 | el.addEventListener(event, handler, options);
|
9616 | }
|
9617 | function removeEventListener(el, event, handler, options) {
|
9618 | el.removeEventListener(event, handler, options);
|
9619 | }
|
9620 | function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
9621 |
|
9622 | const invokers = el._vei || (el._vei = {});
|
9623 | const existingInvoker = invokers[rawName];
|
9624 | if (nextValue && existingInvoker) {
|
9625 |
|
9626 | existingInvoker.value = nextValue;
|
9627 | }
|
9628 | else {
|
9629 | const [name, options] = parseName(rawName);
|
9630 | if (nextValue) {
|
9631 |
|
9632 | const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
|
9633 | addEventListener(el, name, invoker, options);
|
9634 | }
|
9635 | else if (existingInvoker) {
|
9636 |
|
9637 | removeEventListener(el, name, existingInvoker, options);
|
9638 | invokers[rawName] = undefined;
|
9639 | }
|
9640 | }
|
9641 | }
|
9642 | const optionsModifierRE = /(?:Once|Passive|Capture)$/;
|
9643 | function parseName(name) {
|
9644 | let options;
|
9645 | if (optionsModifierRE.test(name)) {
|
9646 | options = {};
|
9647 | let m;
|
9648 | while ((m = name.match(optionsModifierRE))) {
|
9649 | name = name.slice(0, name.length - m[0].length);
|
9650 | options[m[0].toLowerCase()] = true;
|
9651 | }
|
9652 | }
|
9653 | return [hyphenate(name.slice(2)), options];
|
9654 | }
|
9655 | function createInvoker(initialValue, instance) {
|
9656 | const invoker = (e) => {
|
9657 |
|
9658 |
|
9659 |
|
9660 |
|
9661 |
|
9662 |
|
9663 | const timeStamp = e.timeStamp || _getNow();
|
9664 | if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
|
9665 | callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 , [e]);
|
9666 | }
|
9667 | };
|
9668 | invoker.value = initialValue;
|
9669 | invoker.attached = getNow();
|
9670 | return invoker;
|
9671 | }
|
9672 | function patchStopImmediatePropagation(e, value) {
|
9673 | if (isArray(value)) {
|
9674 | const originalStop = e.stopImmediatePropagation;
|
9675 | e.stopImmediatePropagation = () => {
|
9676 | originalStop.call(e);
|
9677 | e._stopped = true;
|
9678 | };
|
9679 | return value.map(fn => (e) => !e._stopped && fn(e));
|
9680 | }
|
9681 | else {
|
9682 | return value;
|
9683 | }
|
9684 | }
|
9685 |
|
9686 | const nativeOnRE = /^on[a-z]/;
|
9687 | const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
|
9688 | if (key === 'class') {
|
9689 | patchClass(el, nextValue, isSVG);
|
9690 | }
|
9691 | else if (key === 'style') {
|
9692 | patchStyle(el, prevValue, nextValue);
|
9693 | }
|
9694 | else if (isOn(key)) {
|
9695 |
|
9696 | if (!isModelListener(key)) {
|
9697 | patchEvent(el, key, prevValue, nextValue, parentComponent);
|
9698 | }
|
9699 | }
|
9700 | else if (key[0] === '.'
|
9701 | ? ((key = key.slice(1)), true)
|
9702 | : key[0] === '^'
|
9703 | ? ((key = key.slice(1)), false)
|
9704 | : shouldSetAsProp(el, key, nextValue, isSVG)) {
|
9705 | patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
|
9706 | }
|
9707 | else {
|
9708 |
|
9709 |
|
9710 |
|
9711 |
|
9712 | if (key === 'true-value') {
|
9713 | el._trueValue = nextValue;
|
9714 | }
|
9715 | else if (key === 'false-value') {
|
9716 | el._falseValue = nextValue;
|
9717 | }
|
9718 | patchAttr(el, key, nextValue, isSVG);
|
9719 | }
|
9720 | };
|
9721 | function shouldSetAsProp(el, key, value, isSVG) {
|
9722 | if (isSVG) {
|
9723 |
|
9724 |
|
9725 | if (key === 'innerHTML' || key === 'textContent') {
|
9726 | return true;
|
9727 | }
|
9728 |
|
9729 | if (key in el && nativeOnRE.test(key) && isFunction(value)) {
|
9730 | return true;
|
9731 | }
|
9732 | return false;
|
9733 | }
|
9734 |
|
9735 |
|
9736 |
|
9737 |
|
9738 |
|
9739 |
|
9740 | if (key === 'spellcheck' || key === 'draggable') {
|
9741 | return false;
|
9742 | }
|
9743 |
|
9744 |
|
9745 | if (key === 'form') {
|
9746 | return false;
|
9747 | }
|
9748 |
|
9749 | if (key === 'list' && el.tagName === 'INPUT') {
|
9750 | return false;
|
9751 | }
|
9752 |
|
9753 | if (key === 'type' && el.tagName === 'TEXTAREA') {
|
9754 | return false;
|
9755 | }
|
9756 |
|
9757 | if (nativeOnRE.test(key) && isString(value)) {
|
9758 | return false;
|
9759 | }
|
9760 | return key in el;
|
9761 | }
|
9762 |
|
9763 | function defineCustomElement(options, hydate) {
|
9764 | const Comp = defineComponent(options);
|
9765 | class VueCustomElement extends VueElement {
|
9766 | constructor(initialProps) {
|
9767 | super(Comp, initialProps, hydate);
|
9768 | }
|
9769 | }
|
9770 | VueCustomElement.def = Comp;
|
9771 | return VueCustomElement;
|
9772 | }
|
9773 | const defineSSRCustomElement = ((options) => {
|
9774 |
|
9775 | return defineCustomElement(options, hydrate);
|
9776 | });
|
9777 | const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
|
9778 | });
|
9779 | class VueElement extends BaseClass {
|
9780 | constructor(_def, _props = {}, hydrate) {
|
9781 | super();
|
9782 | this._def = _def;
|
9783 | this._props = _props;
|
9784 | |
9785 |
|
9786 |
|
9787 | this._instance = null;
|
9788 | this._connected = false;
|
9789 | this._resolved = false;
|
9790 | if (this.shadowRoot && hydrate) {
|
9791 | hydrate(this._createVNode(), this.shadowRoot);
|
9792 | }
|
9793 | else {
|
9794 | if (this.shadowRoot) {
|
9795 | warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
|
9796 | `defined as hydratable. Use \`defineSSRCustomElement\`.`);
|
9797 | }
|
9798 | this.attachShadow({ mode: 'open' });
|
9799 | }
|
9800 |
|
9801 | for (let i = 0; i < this.attributes.length; i++) {
|
9802 | this._setAttr(this.attributes[i].name);
|
9803 | }
|
9804 |
|
9805 | const observer = new MutationObserver(mutations => {
|
9806 | for (const m of mutations) {
|
9807 | this._setAttr(m.attributeName);
|
9808 | }
|
9809 | });
|
9810 | observer.observe(this, { attributes: true });
|
9811 | }
|
9812 | connectedCallback() {
|
9813 | this._connected = true;
|
9814 | if (!this._instance) {
|
9815 | this._resolveDef();
|
9816 | render(this._createVNode(), this.shadowRoot);
|
9817 | }
|
9818 | }
|
9819 | disconnectedCallback() {
|
9820 | this._connected = false;
|
9821 | nextTick(() => {
|
9822 | if (!this._connected) {
|
9823 | render(null, this.shadowRoot);
|
9824 | this._instance = null;
|
9825 | }
|
9826 | });
|
9827 | }
|
9828 | |
9829 |
|
9830 |
|
9831 | _resolveDef() {
|
9832 | if (this._resolved) {
|
9833 | return;
|
9834 | }
|
9835 | const resolve = (def) => {
|
9836 | this._resolved = true;
|
9837 |
|
9838 | for (const key of Object.keys(this)) {
|
9839 | if (key[0] !== '_') {
|
9840 | this._setProp(key, this[key]);
|
9841 | }
|
9842 | }
|
9843 | const { props, styles } = def;
|
9844 |
|
9845 | const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
|
9846 | for (const key of rawKeys.map(camelize)) {
|
9847 | Object.defineProperty(this, key, {
|
9848 | get() {
|
9849 | return this._getProp(key);
|
9850 | },
|
9851 | set(val) {
|
9852 | this._setProp(key, val);
|
9853 | }
|
9854 | });
|
9855 | }
|
9856 | this._applyStyles(styles);
|
9857 | };
|
9858 | const asyncDef = this._def.__asyncLoader;
|
9859 | if (asyncDef) {
|
9860 | asyncDef().then(resolve);
|
9861 | }
|
9862 | else {
|
9863 | resolve(this._def);
|
9864 | }
|
9865 | }
|
9866 | _setAttr(key) {
|
9867 | this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
|
9868 | }
|
9869 | |
9870 |
|
9871 |
|
9872 | _getProp(key) {
|
9873 | return this._props[key];
|
9874 | }
|
9875 | |
9876 |
|
9877 |
|
9878 | _setProp(key, val, shouldReflect = true) {
|
9879 | if (val !== this._props[key]) {
|
9880 | this._props[key] = val;
|
9881 | if (this._instance) {
|
9882 | render(this._createVNode(), this.shadowRoot);
|
9883 | }
|
9884 |
|
9885 | if (shouldReflect) {
|
9886 | if (val === true) {
|
9887 | this.setAttribute(hyphenate(key), '');
|
9888 | }
|
9889 | else if (typeof val === 'string' || typeof val === 'number') {
|
9890 | this.setAttribute(hyphenate(key), val + '');
|
9891 | }
|
9892 | else if (!val) {
|
9893 | this.removeAttribute(hyphenate(key));
|
9894 | }
|
9895 | }
|
9896 | }
|
9897 | }
|
9898 | _createVNode() {
|
9899 | const vnode = createVNode(this._def, extend({}, this._props));
|
9900 | if (!this._instance) {
|
9901 | vnode.ce = instance => {
|
9902 | this._instance = instance;
|
9903 | instance.isCE = true;
|
9904 |
|
9905 | {
|
9906 | instance.ceReload = newStyles => {
|
9907 |
|
9908 | if (this._styles) {
|
9909 | this._styles.forEach(s => this.shadowRoot.removeChild(s));
|
9910 | this._styles.length = 0;
|
9911 | }
|
9912 | this._applyStyles(newStyles);
|
9913 |
|
9914 |
|
9915 | if (!this._def.__asyncLoader) {
|
9916 |
|
9917 | this._instance = null;
|
9918 | render(this._createVNode(), this.shadowRoot);
|
9919 | }
|
9920 | };
|
9921 | }
|
9922 |
|
9923 | instance.emit = (event, ...args) => {
|
9924 | this.dispatchEvent(new CustomEvent(event, {
|
9925 | detail: args
|
9926 | }));
|
9927 | };
|
9928 |
|
9929 | let parent = this;
|
9930 | while ((parent =
|
9931 | parent && (parent.parentNode || parent.host))) {
|
9932 | if (parent instanceof VueElement) {
|
9933 | instance.parent = parent._instance;
|
9934 | break;
|
9935 | }
|
9936 | }
|
9937 | };
|
9938 | }
|
9939 | return vnode;
|
9940 | }
|
9941 | _applyStyles(styles) {
|
9942 | if (styles) {
|
9943 | styles.forEach(css => {
|
9944 | const s = document.createElement('style');
|
9945 | s.textContent = css;
|
9946 | this.shadowRoot.appendChild(s);
|
9947 |
|
9948 | {
|
9949 | (this._styles || (this._styles = [])).push(s);
|
9950 | }
|
9951 | });
|
9952 | }
|
9953 | }
|
9954 | }
|
9955 |
|
9956 | function useCssModule(name = '$style') {
|
9957 |
|
9958 | {
|
9959 | const instance = getCurrentInstance();
|
9960 | if (!instance) {
|
9961 | warn$1(`useCssModule must be called inside setup()`);
|
9962 | return EMPTY_OBJ;
|
9963 | }
|
9964 | const modules = instance.type.__cssModules;
|
9965 | if (!modules) {
|
9966 | warn$1(`Current instance does not have CSS modules injected.`);
|
9967 | return EMPTY_OBJ;
|
9968 | }
|
9969 | const mod = modules[name];
|
9970 | if (!mod) {
|
9971 | warn$1(`Current instance does not have CSS module named "${name}".`);
|
9972 | return EMPTY_OBJ;
|
9973 | }
|
9974 | return mod;
|
9975 | }
|
9976 | }
|
9977 |
|
9978 |
|
9979 |
|
9980 |
|
9981 |
|
9982 | function useCssVars(getter) {
|
9983 | const instance = getCurrentInstance();
|
9984 |
|
9985 | if (!instance) {
|
9986 | warn$1(`useCssVars is called without current active component instance.`);
|
9987 | return;
|
9988 | }
|
9989 | const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
|
9990 | watchPostEffect(setVars);
|
9991 | onMounted(() => {
|
9992 | const ob = new MutationObserver(setVars);
|
9993 | ob.observe(instance.subTree.el.parentNode, { childList: true });
|
9994 | onUnmounted(() => ob.disconnect());
|
9995 | });
|
9996 | }
|
9997 | function setVarsOnVNode(vnode, vars) {
|
9998 | if (vnode.shapeFlag & 128 ) {
|
9999 | const suspense = vnode.suspense;
|
10000 | vnode = suspense.activeBranch;
|
10001 | if (suspense.pendingBranch && !suspense.isHydrating) {
|
10002 | suspense.effects.push(() => {
|
10003 | setVarsOnVNode(suspense.activeBranch, vars);
|
10004 | });
|
10005 | }
|
10006 | }
|
10007 |
|
10008 | while (vnode.component) {
|
10009 | vnode = vnode.component.subTree;
|
10010 | }
|
10011 | if (vnode.shapeFlag & 1 && vnode.el) {
|
10012 | setVarsOnNode(vnode.el, vars);
|
10013 | }
|
10014 | else if (vnode.type === Fragment) {
|
10015 | vnode.children.forEach(c => setVarsOnVNode(c, vars));
|
10016 | }
|
10017 | else if (vnode.type === Static) {
|
10018 | let { el, anchor } = vnode;
|
10019 | while (el) {
|
10020 | setVarsOnNode(el, vars);
|
10021 | if (el === anchor)
|
10022 | break;
|
10023 | el = el.nextSibling;
|
10024 | }
|
10025 | }
|
10026 | }
|
10027 | function setVarsOnNode(el, vars) {
|
10028 | if (el.nodeType === 1) {
|
10029 | const style = el.style;
|
10030 | for (const key in vars) {
|
10031 | style.setProperty(`--${key}`, vars[key]);
|
10032 | }
|
10033 | }
|
10034 | }
|
10035 |
|
10036 | const TRANSITION = 'transition';
|
10037 | const ANIMATION = 'animation';
|
10038 |
|
10039 |
|
10040 | const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
|
10041 | Transition.displayName = 'Transition';
|
10042 | const DOMTransitionPropsValidators = {
|
10043 | name: String,
|
10044 | type: String,
|
10045 | css: {
|
10046 | type: Boolean,
|
10047 | default: true
|
10048 | },
|
10049 | duration: [String, Number, Object],
|
10050 | enterFromClass: String,
|
10051 | enterActiveClass: String,
|
10052 | enterToClass: String,
|
10053 | appearFromClass: String,
|
10054 | appearActiveClass: String,
|
10055 | appearToClass: String,
|
10056 | leaveFromClass: String,
|
10057 | leaveActiveClass: String,
|
10058 | leaveToClass: String
|
10059 | };
|
10060 | const TransitionPropsValidators = (Transition.props =
|
10061 | extend({}, BaseTransition.props, DOMTransitionPropsValidators));
|
10062 |
|
10063 |
|
10064 |
|
10065 |
|
10066 | const callHook$1 = (hook, args = []) => {
|
10067 | if (isArray(hook)) {
|
10068 | hook.forEach(h => h(...args));
|
10069 | }
|
10070 | else if (hook) {
|
10071 | hook(...args);
|
10072 | }
|
10073 | };
|
10074 |
|
10075 |
|
10076 |
|
10077 |
|
10078 | const hasExplicitCallback = (hook) => {
|
10079 | return hook
|
10080 | ? isArray(hook)
|
10081 | ? hook.some(h => h.length > 1)
|
10082 | : hook.length > 1
|
10083 | : false;
|
10084 | };
|
10085 | function resolveTransitionProps(rawProps) {
|
10086 | const baseProps = {};
|
10087 | for (const key in rawProps) {
|
10088 | if (!(key in DOMTransitionPropsValidators)) {
|
10089 | baseProps[key] = rawProps[key];
|
10090 | }
|
10091 | }
|
10092 | if (rawProps.css === false) {
|
10093 | return baseProps;
|
10094 | }
|
10095 | 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;
|
10096 | const durations = normalizeDuration(duration);
|
10097 | const enterDuration = durations && durations[0];
|
10098 | const leaveDuration = durations && durations[1];
|
10099 | const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
|
10100 | const finishEnter = (el, isAppear, done) => {
|
10101 | removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
10102 | removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
|
10103 | done && done();
|
10104 | };
|
10105 | const finishLeave = (el, done) => {
|
10106 | removeTransitionClass(el, leaveToClass);
|
10107 | removeTransitionClass(el, leaveActiveClass);
|
10108 | done && done();
|
10109 | };
|
10110 | const makeEnterHook = (isAppear) => {
|
10111 | return (el, done) => {
|
10112 | const hook = isAppear ? onAppear : onEnter;
|
10113 | const resolve = () => finishEnter(el, isAppear, done);
|
10114 | callHook$1(hook, [el, resolve]);
|
10115 | nextFrame(() => {
|
10116 | removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
|
10117 | addTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
10118 | if (!hasExplicitCallback(hook)) {
|
10119 | whenTransitionEnds(el, type, enterDuration, resolve);
|
10120 | }
|
10121 | });
|
10122 | };
|
10123 | };
|
10124 | return extend(baseProps, {
|
10125 | onBeforeEnter(el) {
|
10126 | callHook$1(onBeforeEnter, [el]);
|
10127 | addTransitionClass(el, enterFromClass);
|
10128 | addTransitionClass(el, enterActiveClass);
|
10129 | },
|
10130 | onBeforeAppear(el) {
|
10131 | callHook$1(onBeforeAppear, [el]);
|
10132 | addTransitionClass(el, appearFromClass);
|
10133 | addTransitionClass(el, appearActiveClass);
|
10134 | },
|
10135 | onEnter: makeEnterHook(false),
|
10136 | onAppear: makeEnterHook(true),
|
10137 | onLeave(el, done) {
|
10138 | const resolve = () => finishLeave(el, done);
|
10139 | addTransitionClass(el, leaveFromClass);
|
10140 |
|
10141 | forceReflow();
|
10142 | addTransitionClass(el, leaveActiveClass);
|
10143 | nextFrame(() => {
|
10144 | removeTransitionClass(el, leaveFromClass);
|
10145 | addTransitionClass(el, leaveToClass);
|
10146 | if (!hasExplicitCallback(onLeave)) {
|
10147 | whenTransitionEnds(el, type, leaveDuration, resolve);
|
10148 | }
|
10149 | });
|
10150 | callHook$1(onLeave, [el, resolve]);
|
10151 | },
|
10152 | onEnterCancelled(el) {
|
10153 | finishEnter(el, false);
|
10154 | callHook$1(onEnterCancelled, [el]);
|
10155 | },
|
10156 | onAppearCancelled(el) {
|
10157 | finishEnter(el, true);
|
10158 | callHook$1(onAppearCancelled, [el]);
|
10159 | },
|
10160 | onLeaveCancelled(el) {
|
10161 | finishLeave(el);
|
10162 | callHook$1(onLeaveCancelled, [el]);
|
10163 | }
|
10164 | });
|
10165 | }
|
10166 | function normalizeDuration(duration) {
|
10167 | if (duration == null) {
|
10168 | return null;
|
10169 | }
|
10170 | else if (isObject(duration)) {
|
10171 | return [NumberOf(duration.enter), NumberOf(duration.leave)];
|
10172 | }
|
10173 | else {
|
10174 | const n = NumberOf(duration);
|
10175 | return [n, n];
|
10176 | }
|
10177 | }
|
10178 | function NumberOf(val) {
|
10179 | const res = toNumber(val);
|
10180 | validateDuration(res);
|
10181 | return res;
|
10182 | }
|
10183 | function validateDuration(val) {
|
10184 | if (typeof val !== 'number') {
|
10185 | warn$1(`<transition> explicit duration is not a valid number - ` +
|
10186 | `got ${JSON.stringify(val)}.`);
|
10187 | }
|
10188 | else if (isNaN(val)) {
|
10189 | warn$1(`<transition> explicit duration is NaN - ` +
|
10190 | 'the duration expression might be incorrect.');
|
10191 | }
|
10192 | }
|
10193 | function addTransitionClass(el, cls) {
|
10194 | cls.split(/\s+/).forEach(c => c && el.classList.add(c));
|
10195 | (el._vtc ||
|
10196 | (el._vtc = new Set())).add(cls);
|
10197 | }
|
10198 | function removeTransitionClass(el, cls) {
|
10199 | cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
|
10200 | const { _vtc } = el;
|
10201 | if (_vtc) {
|
10202 | _vtc.delete(cls);
|
10203 | if (!_vtc.size) {
|
10204 | el._vtc = undefined;
|
10205 | }
|
10206 | }
|
10207 | }
|
10208 | function nextFrame(cb) {
|
10209 | requestAnimationFrame(() => {
|
10210 | requestAnimationFrame(cb);
|
10211 | });
|
10212 | }
|
10213 | let endId = 0;
|
10214 | function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
|
10215 | const id = (el._endId = ++endId);
|
10216 | const resolveIfNotStale = () => {
|
10217 | if (id === el._endId) {
|
10218 | resolve();
|
10219 | }
|
10220 | };
|
10221 | if (explicitTimeout) {
|
10222 | return setTimeout(resolveIfNotStale, explicitTimeout);
|
10223 | }
|
10224 | const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
|
10225 | if (!type) {
|
10226 | return resolve();
|
10227 | }
|
10228 | const endEvent = type + 'end';
|
10229 | let ended = 0;
|
10230 | const end = () => {
|
10231 | el.removeEventListener(endEvent, onEnd);
|
10232 | resolveIfNotStale();
|
10233 | };
|
10234 | const onEnd = (e) => {
|
10235 | if (e.target === el && ++ended >= propCount) {
|
10236 | end();
|
10237 | }
|
10238 | };
|
10239 | setTimeout(() => {
|
10240 | if (ended < propCount) {
|
10241 | end();
|
10242 | }
|
10243 | }, timeout + 1);
|
10244 | el.addEventListener(endEvent, onEnd);
|
10245 | }
|
10246 | function getTransitionInfo(el, expectedType) {
|
10247 | const styles = window.getComputedStyle(el);
|
10248 |
|
10249 | const getStyleProperties = (key) => (styles[key] || '').split(', ');
|
10250 | const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
|
10251 | const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
|
10252 | const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
|
10253 | const animationDelays = getStyleProperties(ANIMATION + 'Delay');
|
10254 | const animationDurations = getStyleProperties(ANIMATION + 'Duration');
|
10255 | const animationTimeout = getTimeout(animationDelays, animationDurations);
|
10256 | let type = null;
|
10257 | let timeout = 0;
|
10258 | let propCount = 0;
|
10259 |
|
10260 | if (expectedType === TRANSITION) {
|
10261 | if (transitionTimeout > 0) {
|
10262 | type = TRANSITION;
|
10263 | timeout = transitionTimeout;
|
10264 | propCount = transitionDurations.length;
|
10265 | }
|
10266 | }
|
10267 | else if (expectedType === ANIMATION) {
|
10268 | if (animationTimeout > 0) {
|
10269 | type = ANIMATION;
|
10270 | timeout = animationTimeout;
|
10271 | propCount = animationDurations.length;
|
10272 | }
|
10273 | }
|
10274 | else {
|
10275 | timeout = Math.max(transitionTimeout, animationTimeout);
|
10276 | type =
|
10277 | timeout > 0
|
10278 | ? transitionTimeout > animationTimeout
|
10279 | ? TRANSITION
|
10280 | : ANIMATION
|
10281 | : null;
|
10282 | propCount = type
|
10283 | ? type === TRANSITION
|
10284 | ? transitionDurations.length
|
10285 | : animationDurations.length
|
10286 | : 0;
|
10287 | }
|
10288 | const hasTransform = type === TRANSITION &&
|
10289 | /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
|
10290 | return {
|
10291 | type,
|
10292 | timeout,
|
10293 | propCount,
|
10294 | hasTransform
|
10295 | };
|
10296 | }
|
10297 | function getTimeout(delays, durations) {
|
10298 | while (delays.length < durations.length) {
|
10299 | delays = delays.concat(delays);
|
10300 | }
|
10301 | return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
|
10302 | }
|
10303 |
|
10304 |
|
10305 |
|
10306 |
|
10307 | function toMs(s) {
|
10308 | return Number(s.slice(0, -1).replace(',', '.')) * 1000;
|
10309 | }
|
10310 |
|
10311 | function forceReflow() {
|
10312 | return document.body.offsetHeight;
|
10313 | }
|
10314 |
|
10315 | const positionMap = new WeakMap();
|
10316 | const newPositionMap = new WeakMap();
|
10317 | const TransitionGroupImpl = {
|
10318 | name: 'TransitionGroup',
|
10319 | props: extend({}, TransitionPropsValidators, {
|
10320 | tag: String,
|
10321 | moveClass: String
|
10322 | }),
|
10323 | setup(props, { slots }) {
|
10324 | const instance = getCurrentInstance();
|
10325 | const state = useTransitionState();
|
10326 | let prevChildren;
|
10327 | let children;
|
10328 | onUpdated(() => {
|
10329 |
|
10330 | if (!prevChildren.length) {
|
10331 | return;
|
10332 | }
|
10333 | const moveClass = props.moveClass || `${props.name || 'v'}-move`;
|
10334 | if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
|
10335 | return;
|
10336 | }
|
10337 |
|
10338 |
|
10339 | prevChildren.forEach(callPendingCbs);
|
10340 | prevChildren.forEach(recordPosition);
|
10341 | const movedChildren = prevChildren.filter(applyTranslation);
|
10342 |
|
10343 | forceReflow();
|
10344 | movedChildren.forEach(c => {
|
10345 | const el = c.el;
|
10346 | const style = el.style;
|
10347 | addTransitionClass(el, moveClass);
|
10348 | style.transform = style.webkitTransform = style.transitionDuration = '';
|
10349 | const cb = (el._moveCb = (e) => {
|
10350 | if (e && e.target !== el) {
|
10351 | return;
|
10352 | }
|
10353 | if (!e || /transform$/.test(e.propertyName)) {
|
10354 | el.removeEventListener('transitionend', cb);
|
10355 | el._moveCb = null;
|
10356 | removeTransitionClass(el, moveClass);
|
10357 | }
|
10358 | });
|
10359 | el.addEventListener('transitionend', cb);
|
10360 | });
|
10361 | });
|
10362 | return () => {
|
10363 | const rawProps = toRaw(props);
|
10364 | const cssTransitionProps = resolveTransitionProps(rawProps);
|
10365 | let tag = rawProps.tag || Fragment;
|
10366 | prevChildren = children;
|
10367 | children = slots.default ? getTransitionRawChildren(slots.default()) : [];
|
10368 | for (let i = 0; i < children.length; i++) {
|
10369 | const child = children[i];
|
10370 | if (child.key != null) {
|
10371 | setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
|
10372 | }
|
10373 | else {
|
10374 | warn$1(`<TransitionGroup> children must be keyed.`);
|
10375 | }
|
10376 | }
|
10377 | if (prevChildren) {
|
10378 | for (let i = 0; i < prevChildren.length; i++) {
|
10379 | const child = prevChildren[i];
|
10380 | setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
|
10381 | positionMap.set(child, child.el.getBoundingClientRect());
|
10382 | }
|
10383 | }
|
10384 | return createVNode(tag, null, children);
|
10385 | };
|
10386 | }
|
10387 | };
|
10388 | const TransitionGroup = TransitionGroupImpl;
|
10389 | function callPendingCbs(c) {
|
10390 | const el = c.el;
|
10391 | if (el._moveCb) {
|
10392 | el._moveCb();
|
10393 | }
|
10394 | if (el._enterCb) {
|
10395 | el._enterCb();
|
10396 | }
|
10397 | }
|
10398 | function recordPosition(c) {
|
10399 | newPositionMap.set(c, c.el.getBoundingClientRect());
|
10400 | }
|
10401 | function applyTranslation(c) {
|
10402 | const oldPos = positionMap.get(c);
|
10403 | const newPos = newPositionMap.get(c);
|
10404 | const dx = oldPos.left - newPos.left;
|
10405 | const dy = oldPos.top - newPos.top;
|
10406 | if (dx || dy) {
|
10407 | const s = c.el.style;
|
10408 | s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
|
10409 | s.transitionDuration = '0s';
|
10410 | return c;
|
10411 | }
|
10412 | }
|
10413 | function hasCSSTransform(el, root, moveClass) {
|
10414 |
|
10415 |
|
10416 |
|
10417 |
|
10418 |
|
10419 | const clone = el.cloneNode();
|
10420 | if (el._vtc) {
|
10421 | el._vtc.forEach(cls => {
|
10422 | cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
|
10423 | });
|
10424 | }
|
10425 | moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
|
10426 | clone.style.display = 'none';
|
10427 | const container = (root.nodeType === 1 ? root : root.parentNode);
|
10428 | container.appendChild(clone);
|
10429 | const { hasTransform } = getTransitionInfo(clone);
|
10430 | container.removeChild(clone);
|
10431 | return hasTransform;
|
10432 | }
|
10433 |
|
10434 | const getModelAssigner = (vnode) => {
|
10435 | const fn = vnode.props['onUpdate:modelValue'];
|
10436 | return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
|
10437 | };
|
10438 | function onCompositionStart(e) {
|
10439 | e.target.composing = true;
|
10440 | }
|
10441 | function onCompositionEnd(e) {
|
10442 | const target = e.target;
|
10443 | if (target.composing) {
|
10444 | target.composing = false;
|
10445 | trigger$1(target, 'input');
|
10446 | }
|
10447 | }
|
10448 | function trigger$1(el, type) {
|
10449 | const e = document.createEvent('HTMLEvents');
|
10450 | e.initEvent(type, true, true);
|
10451 | el.dispatchEvent(e);
|
10452 | }
|
10453 |
|
10454 |
|
10455 | const vModelText = {
|
10456 | created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
10457 | el._assign = getModelAssigner(vnode);
|
10458 | const castToNumber = number || (vnode.props && vnode.props.type === 'number');
|
10459 | addEventListener(el, lazy ? 'change' : 'input', e => {
|
10460 | if (e.target.composing)
|
10461 | return;
|
10462 | let domValue = el.value;
|
10463 | if (trim) {
|
10464 | domValue = domValue.trim();
|
10465 | }
|
10466 | else if (castToNumber) {
|
10467 | domValue = toNumber(domValue);
|
10468 | }
|
10469 | el._assign(domValue);
|
10470 | });
|
10471 | if (trim) {
|
10472 | addEventListener(el, 'change', () => {
|
10473 | el.value = el.value.trim();
|
10474 | });
|
10475 | }
|
10476 | if (!lazy) {
|
10477 | addEventListener(el, 'compositionstart', onCompositionStart);
|
10478 | addEventListener(el, 'compositionend', onCompositionEnd);
|
10479 |
|
10480 |
|
10481 |
|
10482 |
|
10483 | addEventListener(el, 'change', onCompositionEnd);
|
10484 | }
|
10485 | },
|
10486 |
|
10487 | mounted(el, { value }) {
|
10488 | el.value = value == null ? '' : value;
|
10489 | },
|
10490 | beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
|
10491 | el._assign = getModelAssigner(vnode);
|
10492 |
|
10493 | if (el.composing)
|
10494 | return;
|
10495 | if (document.activeElement === el) {
|
10496 | if (lazy) {
|
10497 | return;
|
10498 | }
|
10499 | if (trim && el.value.trim() === value) {
|
10500 | return;
|
10501 | }
|
10502 | if ((number || el.type === 'number') && toNumber(el.value) === value) {
|
10503 | return;
|
10504 | }
|
10505 | }
|
10506 | const newValue = value == null ? '' : value;
|
10507 | if (el.value !== newValue) {
|
10508 | el.value = newValue;
|
10509 | }
|
10510 | }
|
10511 | };
|
10512 | const vModelCheckbox = {
|
10513 |
|
10514 | deep: true,
|
10515 | created(el, _, vnode) {
|
10516 | el._assign = getModelAssigner(vnode);
|
10517 | addEventListener(el, 'change', () => {
|
10518 | const modelValue = el._modelValue;
|
10519 | const elementValue = getValue(el);
|
10520 | const checked = el.checked;
|
10521 | const assign = el._assign;
|
10522 | if (isArray(modelValue)) {
|
10523 | const index = looseIndexOf(modelValue, elementValue);
|
10524 | const found = index !== -1;
|
10525 | if (checked && !found) {
|
10526 | assign(modelValue.concat(elementValue));
|
10527 | }
|
10528 | else if (!checked && found) {
|
10529 | const filtered = [...modelValue];
|
10530 | filtered.splice(index, 1);
|
10531 | assign(filtered);
|
10532 | }
|
10533 | }
|
10534 | else if (isSet(modelValue)) {
|
10535 | const cloned = new Set(modelValue);
|
10536 | if (checked) {
|
10537 | cloned.add(elementValue);
|
10538 | }
|
10539 | else {
|
10540 | cloned.delete(elementValue);
|
10541 | }
|
10542 | assign(cloned);
|
10543 | }
|
10544 | else {
|
10545 | assign(getCheckboxValue(el, checked));
|
10546 | }
|
10547 | });
|
10548 | },
|
10549 |
|
10550 | mounted: setChecked,
|
10551 | beforeUpdate(el, binding, vnode) {
|
10552 | el._assign = getModelAssigner(vnode);
|
10553 | setChecked(el, binding, vnode);
|
10554 | }
|
10555 | };
|
10556 | function setChecked(el, { value, oldValue }, vnode) {
|
10557 | el._modelValue = value;
|
10558 | if (isArray(value)) {
|
10559 | el.checked = looseIndexOf(value, vnode.props.value) > -1;
|
10560 | }
|
10561 | else if (isSet(value)) {
|
10562 | el.checked = value.has(vnode.props.value);
|
10563 | }
|
10564 | else if (value !== oldValue) {
|
10565 | el.checked = looseEqual(value, getCheckboxValue(el, true));
|
10566 | }
|
10567 | }
|
10568 | const vModelRadio = {
|
10569 | created(el, { value }, vnode) {
|
10570 | el.checked = looseEqual(value, vnode.props.value);
|
10571 | el._assign = getModelAssigner(vnode);
|
10572 | addEventListener(el, 'change', () => {
|
10573 | el._assign(getValue(el));
|
10574 | });
|
10575 | },
|
10576 | beforeUpdate(el, { value, oldValue }, vnode) {
|
10577 | el._assign = getModelAssigner(vnode);
|
10578 | if (value !== oldValue) {
|
10579 | el.checked = looseEqual(value, vnode.props.value);
|
10580 | }
|
10581 | }
|
10582 | };
|
10583 | const vModelSelect = {
|
10584 |
|
10585 | deep: true,
|
10586 | created(el, { value, modifiers: { number } }, vnode) {
|
10587 | const isSetModel = isSet(value);
|
10588 | addEventListener(el, 'change', () => {
|
10589 | const selectedVal = Array.prototype.filter
|
10590 | .call(el.options, (o) => o.selected)
|
10591 | .map((o) => number ? toNumber(getValue(o)) : getValue(o));
|
10592 | el._assign(el.multiple
|
10593 | ? isSetModel
|
10594 | ? new Set(selectedVal)
|
10595 | : selectedVal
|
10596 | : selectedVal[0]);
|
10597 | });
|
10598 | el._assign = getModelAssigner(vnode);
|
10599 | },
|
10600 |
|
10601 |
|
10602 | mounted(el, { value }) {
|
10603 | setSelected(el, value);
|
10604 | },
|
10605 | beforeUpdate(el, _binding, vnode) {
|
10606 | el._assign = getModelAssigner(vnode);
|
10607 | },
|
10608 | updated(el, { value }) {
|
10609 | setSelected(el, value);
|
10610 | }
|
10611 | };
|
10612 | function setSelected(el, value) {
|
10613 | const isMultiple = el.multiple;
|
10614 | if (isMultiple && !isArray(value) && !isSet(value)) {
|
10615 | warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
|
10616 | `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
|
10617 | return;
|
10618 | }
|
10619 | for (let i = 0, l = el.options.length; i < l; i++) {
|
10620 | const option = el.options[i];
|
10621 | const optionValue = getValue(option);
|
10622 | if (isMultiple) {
|
10623 | if (isArray(value)) {
|
10624 | option.selected = looseIndexOf(value, optionValue) > -1;
|
10625 | }
|
10626 | else {
|
10627 | option.selected = value.has(optionValue);
|
10628 | }
|
10629 | }
|
10630 | else {
|
10631 | if (looseEqual(getValue(option), value)) {
|
10632 | if (el.selectedIndex !== i)
|
10633 | el.selectedIndex = i;
|
10634 | return;
|
10635 | }
|
10636 | }
|
10637 | }
|
10638 | if (!isMultiple && el.selectedIndex !== -1) {
|
10639 | el.selectedIndex = -1;
|
10640 | }
|
10641 | }
|
10642 |
|
10643 | function getValue(el) {
|
10644 | return '_value' in el ? el._value : el.value;
|
10645 | }
|
10646 |
|
10647 | function getCheckboxValue(el, checked) {
|
10648 | const key = checked ? '_trueValue' : '_falseValue';
|
10649 | return key in el ? el[key] : checked;
|
10650 | }
|
10651 | const vModelDynamic = {
|
10652 | created(el, binding, vnode) {
|
10653 | callModelHook(el, binding, vnode, null, 'created');
|
10654 | },
|
10655 | mounted(el, binding, vnode) {
|
10656 | callModelHook(el, binding, vnode, null, 'mounted');
|
10657 | },
|
10658 | beforeUpdate(el, binding, vnode, prevVNode) {
|
10659 | callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
|
10660 | },
|
10661 | updated(el, binding, vnode, prevVNode) {
|
10662 | callModelHook(el, binding, vnode, prevVNode, 'updated');
|
10663 | }
|
10664 | };
|
10665 | function callModelHook(el, binding, vnode, prevVNode, hook) {
|
10666 | let modelToUse;
|
10667 | switch (el.tagName) {
|
10668 | case 'SELECT':
|
10669 | modelToUse = vModelSelect;
|
10670 | break;
|
10671 | case 'TEXTAREA':
|
10672 | modelToUse = vModelText;
|
10673 | break;
|
10674 | default:
|
10675 | switch (vnode.props && vnode.props.type) {
|
10676 | case 'checkbox':
|
10677 | modelToUse = vModelCheckbox;
|
10678 | break;
|
10679 | case 'radio':
|
10680 | modelToUse = vModelRadio;
|
10681 | break;
|
10682 | default:
|
10683 | modelToUse = vModelText;
|
10684 | }
|
10685 | }
|
10686 | const fn = modelToUse[hook];
|
10687 | fn && fn(el, binding, vnode, prevVNode);
|
10688 | }
|
10689 |
|
10690 | const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
|
10691 | const modifierGuards = {
|
10692 | stop: e => e.stopPropagation(),
|
10693 | prevent: e => e.preventDefault(),
|
10694 | self: e => e.target !== e.currentTarget,
|
10695 | ctrl: e => !e.ctrlKey,
|
10696 | shift: e => !e.shiftKey,
|
10697 | alt: e => !e.altKey,
|
10698 | meta: e => !e.metaKey,
|
10699 | left: e => 'button' in e && e.button !== 0,
|
10700 | middle: e => 'button' in e && e.button !== 1,
|
10701 | right: e => 'button' in e && e.button !== 2,
|
10702 | exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
|
10703 | };
|
10704 |
|
10705 |
|
10706 |
|
10707 | const withModifiers = (fn, modifiers) => {
|
10708 | return (event, ...args) => {
|
10709 | for (let i = 0; i < modifiers.length; i++) {
|
10710 | const guard = modifierGuards[modifiers[i]];
|
10711 | if (guard && guard(event, modifiers))
|
10712 | return;
|
10713 | }
|
10714 | return fn(event, ...args);
|
10715 | };
|
10716 | };
|
10717 |
|
10718 |
|
10719 | const keyNames = {
|
10720 | esc: 'escape',
|
10721 | space: ' ',
|
10722 | up: 'arrow-up',
|
10723 | left: 'arrow-left',
|
10724 | right: 'arrow-right',
|
10725 | down: 'arrow-down',
|
10726 | delete: 'backspace'
|
10727 | };
|
10728 |
|
10729 |
|
10730 |
|
10731 | const withKeys = (fn, modifiers) => {
|
10732 | return (event) => {
|
10733 | if (!('key' in event)) {
|
10734 | return;
|
10735 | }
|
10736 | const eventKey = hyphenate(event.key);
|
10737 | if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
|
10738 | return fn(event);
|
10739 | }
|
10740 | };
|
10741 | };
|
10742 |
|
10743 | const vShow = {
|
10744 | beforeMount(el, { value }, { transition }) {
|
10745 | el._vod = el.style.display === 'none' ? '' : el.style.display;
|
10746 | if (transition && value) {
|
10747 | transition.beforeEnter(el);
|
10748 | }
|
10749 | else {
|
10750 | setDisplay(el, value);
|
10751 | }
|
10752 | },
|
10753 | mounted(el, { value }, { transition }) {
|
10754 | if (transition && value) {
|
10755 | transition.enter(el);
|
10756 | }
|
10757 | },
|
10758 | updated(el, { value, oldValue }, { transition }) {
|
10759 | if (!value === !oldValue)
|
10760 | return;
|
10761 | if (transition) {
|
10762 | if (value) {
|
10763 | transition.beforeEnter(el);
|
10764 | setDisplay(el, true);
|
10765 | transition.enter(el);
|
10766 | }
|
10767 | else {
|
10768 | transition.leave(el, () => {
|
10769 | setDisplay(el, false);
|
10770 | });
|
10771 | }
|
10772 | }
|
10773 | else {
|
10774 | setDisplay(el, value);
|
10775 | }
|
10776 | },
|
10777 | beforeUnmount(el, { value }) {
|
10778 | setDisplay(el, value);
|
10779 | }
|
10780 | };
|
10781 | function setDisplay(el, value) {
|
10782 | el.style.display = value ? el._vod : 'none';
|
10783 | }
|
10784 |
|
10785 | const rendererOptions = extend({ patchProp }, nodeOps);
|
10786 |
|
10787 |
|
10788 | let renderer;
|
10789 | let enabledHydration = false;
|
10790 | function ensureRenderer() {
|
10791 | return (renderer ||
|
10792 | (renderer = createRenderer(rendererOptions)));
|
10793 | }
|
10794 | function ensureHydrationRenderer() {
|
10795 | renderer = enabledHydration
|
10796 | ? renderer
|
10797 | : createHydrationRenderer(rendererOptions);
|
10798 | enabledHydration = true;
|
10799 | return renderer;
|
10800 | }
|
10801 |
|
10802 | const render = ((...args) => {
|
10803 | ensureRenderer().render(...args);
|
10804 | });
|
10805 | const hydrate = ((...args) => {
|
10806 | ensureHydrationRenderer().hydrate(...args);
|
10807 | });
|
10808 | const createApp = ((...args) => {
|
10809 | const app = ensureRenderer().createApp(...args);
|
10810 | {
|
10811 | injectNativeTagCheck(app);
|
10812 | injectCompilerOptionsCheck(app);
|
10813 | }
|
10814 | const { mount } = app;
|
10815 | app.mount = (containerOrSelector) => {
|
10816 | const container = normalizeContainer(containerOrSelector);
|
10817 | if (!container)
|
10818 | return;
|
10819 | const component = app._component;
|
10820 | if (!isFunction(component) && !component.render && !component.template) {
|
10821 |
|
10822 |
|
10823 |
|
10824 |
|
10825 | component.template = container.innerHTML;
|
10826 | }
|
10827 |
|
10828 | container.innerHTML = '';
|
10829 | const proxy = mount(container, false, container instanceof SVGElement);
|
10830 | if (container instanceof Element) {
|
10831 | container.removeAttribute('v-cloak');
|
10832 | container.setAttribute('data-v-app', '');
|
10833 | }
|
10834 | return proxy;
|
10835 | };
|
10836 | return app;
|
10837 | });
|
10838 | const createSSRApp = ((...args) => {
|
10839 | const app = ensureHydrationRenderer().createApp(...args);
|
10840 | {
|
10841 | injectNativeTagCheck(app);
|
10842 | injectCompilerOptionsCheck(app);
|
10843 | }
|
10844 | const { mount } = app;
|
10845 | app.mount = (containerOrSelector) => {
|
10846 | const container = normalizeContainer(containerOrSelector);
|
10847 | if (container) {
|
10848 | return mount(container, true, container instanceof SVGElement);
|
10849 | }
|
10850 | };
|
10851 | return app;
|
10852 | });
|
10853 | function injectNativeTagCheck(app) {
|
10854 |
|
10855 |
|
10856 | Object.defineProperty(app.config, 'isNativeTag', {
|
10857 | value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
|
10858 | writable: false
|
10859 | });
|
10860 | }
|
10861 |
|
10862 | function injectCompilerOptionsCheck(app) {
|
10863 | if (isRuntimeOnly()) {
|
10864 | const isCustomElement = app.config.isCustomElement;
|
10865 | Object.defineProperty(app.config, 'isCustomElement', {
|
10866 | get() {
|
10867 | return isCustomElement;
|
10868 | },
|
10869 | set() {
|
10870 | warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
|
10871 | `\`compilerOptions.isCustomElement\` instead.`);
|
10872 | }
|
10873 | });
|
10874 | const compilerOptions = app.config.compilerOptions;
|
10875 | const msg = `The \`compilerOptions\` config option is only respected when using ` +
|
10876 | `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
|
10877 | `Since you are using the runtime-only build, \`compilerOptions\` ` +
|
10878 | `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
|
10879 | `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
|
10880 | `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
|
10881 | `- 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`;
|
10882 | Object.defineProperty(app.config, 'compilerOptions', {
|
10883 | get() {
|
10884 | warn$1(msg);
|
10885 | return compilerOptions;
|
10886 | },
|
10887 | set() {
|
10888 | warn$1(msg);
|
10889 | }
|
10890 | });
|
10891 | }
|
10892 | }
|
10893 | function normalizeContainer(container) {
|
10894 | if (isString(container)) {
|
10895 | const res = document.querySelector(container);
|
10896 | if (!res) {
|
10897 | warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
|
10898 | }
|
10899 | return res;
|
10900 | }
|
10901 | if (window.ShadowRoot &&
|
10902 | container instanceof window.ShadowRoot &&
|
10903 | container.mode === 'closed') {
|
10904 | warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
|
10905 | }
|
10906 | return container;
|
10907 | }
|
10908 |
|
10909 | var runtimeDom = Object.freeze({
|
10910 | __proto__: null,
|
10911 | render: render,
|
10912 | hydrate: hydrate,
|
10913 | createApp: createApp,
|
10914 | createSSRApp: createSSRApp,
|
10915 | defineCustomElement: defineCustomElement,
|
10916 | defineSSRCustomElement: defineSSRCustomElement,
|
10917 | VueElement: VueElement,
|
10918 | useCssModule: useCssModule,
|
10919 | useCssVars: useCssVars,
|
10920 | Transition: Transition,
|
10921 | TransitionGroup: TransitionGroup,
|
10922 | vModelText: vModelText,
|
10923 | vModelCheckbox: vModelCheckbox,
|
10924 | vModelRadio: vModelRadio,
|
10925 | vModelSelect: vModelSelect,
|
10926 | vModelDynamic: vModelDynamic,
|
10927 | withModifiers: withModifiers,
|
10928 | withKeys: withKeys,
|
10929 | vShow: vShow,
|
10930 | computed: computed,
|
10931 | reactive: reactive,
|
10932 | ref: ref,
|
10933 | readonly: readonly,
|
10934 | unref: unref,
|
10935 | proxyRefs: proxyRefs,
|
10936 | isRef: isRef,
|
10937 | toRef: toRef,
|
10938 | toRefs: toRefs,
|
10939 | isProxy: isProxy,
|
10940 | isReactive: isReactive,
|
10941 | isReadonly: isReadonly,
|
10942 | customRef: customRef,
|
10943 | triggerRef: triggerRef,
|
10944 | shallowRef: shallowRef,
|
10945 | shallowReactive: shallowReactive,
|
10946 | shallowReadonly: shallowReadonly,
|
10947 | markRaw: markRaw,
|
10948 | toRaw: toRaw,
|
10949 | effect: effect,
|
10950 | stop: stop,
|
10951 | ReactiveEffect: ReactiveEffect,
|
10952 | effectScope: effectScope,
|
10953 | EffectScope: EffectScope,
|
10954 | getCurrentScope: getCurrentScope,
|
10955 | onScopeDispose: onScopeDispose,
|
10956 | watch: watch,
|
10957 | watchEffect: watchEffect,
|
10958 | watchPostEffect: watchPostEffect,
|
10959 | watchSyncEffect: watchSyncEffect,
|
10960 | onBeforeMount: onBeforeMount,
|
10961 | onMounted: onMounted,
|
10962 | onBeforeUpdate: onBeforeUpdate,
|
10963 | onUpdated: onUpdated,
|
10964 | onBeforeUnmount: onBeforeUnmount,
|
10965 | onUnmounted: onUnmounted,
|
10966 | onActivated: onActivated,
|
10967 | onDeactivated: onDeactivated,
|
10968 | onRenderTracked: onRenderTracked,
|
10969 | onRenderTriggered: onRenderTriggered,
|
10970 | onErrorCaptured: onErrorCaptured,
|
10971 | onServerPrefetch: onServerPrefetch,
|
10972 | provide: provide,
|
10973 | inject: inject,
|
10974 | nextTick: nextTick,
|
10975 | defineComponent: defineComponent,
|
10976 | defineAsyncComponent: defineAsyncComponent,
|
10977 | useAttrs: useAttrs,
|
10978 | useSlots: useSlots,
|
10979 | defineProps: defineProps,
|
10980 | defineEmits: defineEmits,
|
10981 | defineExpose: defineExpose,
|
10982 | withDefaults: withDefaults,
|
10983 | mergeDefaults: mergeDefaults,
|
10984 | withAsyncContext: withAsyncContext,
|
10985 | getCurrentInstance: getCurrentInstance,
|
10986 | h: h,
|
10987 | createVNode: createVNode,
|
10988 | cloneVNode: cloneVNode,
|
10989 | mergeProps: mergeProps,
|
10990 | isVNode: isVNode,
|
10991 | Fragment: Fragment,
|
10992 | Text: Text,
|
10993 | Comment: Comment,
|
10994 | Static: Static,
|
10995 | Teleport: Teleport,
|
10996 | Suspense: Suspense,
|
10997 | KeepAlive: KeepAlive,
|
10998 | BaseTransition: BaseTransition,
|
10999 | withDirectives: withDirectives,
|
11000 | useSSRContext: useSSRContext,
|
11001 | ssrContextKey: ssrContextKey,
|
11002 | createRenderer: createRenderer,
|
11003 | createHydrationRenderer: createHydrationRenderer,
|
11004 | queuePostFlushCb: queuePostFlushCb,
|
11005 | warn: warn$1,
|
11006 | handleError: handleError,
|
11007 | callWithErrorHandling: callWithErrorHandling,
|
11008 | callWithAsyncErrorHandling: callWithAsyncErrorHandling,
|
11009 | resolveComponent: resolveComponent,
|
11010 | resolveDirective: resolveDirective,
|
11011 | resolveDynamicComponent: resolveDynamicComponent,
|
11012 | registerRuntimeCompiler: registerRuntimeCompiler,
|
11013 | isRuntimeOnly: isRuntimeOnly,
|
11014 | useTransitionState: useTransitionState,
|
11015 | resolveTransitionHooks: resolveTransitionHooks,
|
11016 | setTransitionHooks: setTransitionHooks,
|
11017 | getTransitionRawChildren: getTransitionRawChildren,
|
11018 | initCustomFormatter: initCustomFormatter,
|
11019 | get devtools () { return devtools; },
|
11020 | setDevtoolsHook: setDevtoolsHook,
|
11021 | withCtx: withCtx,
|
11022 | pushScopeId: pushScopeId,
|
11023 | popScopeId: popScopeId,
|
11024 | withScopeId: withScopeId,
|
11025 | renderList: renderList,
|
11026 | toHandlers: toHandlers,
|
11027 | renderSlot: renderSlot,
|
11028 | createSlots: createSlots,
|
11029 | withMemo: withMemo,
|
11030 | isMemoSame: isMemoSame,
|
11031 | openBlock: openBlock,
|
11032 | createBlock: createBlock,
|
11033 | setBlockTracking: setBlockTracking,
|
11034 | createTextVNode: createTextVNode,
|
11035 | createCommentVNode: createCommentVNode,
|
11036 | createStaticVNode: createStaticVNode,
|
11037 | createElementVNode: createBaseVNode,
|
11038 | createElementBlock: createElementBlock,
|
11039 | guardReactiveProps: guardReactiveProps,
|
11040 | toDisplayString: toDisplayString,
|
11041 | camelize: camelize,
|
11042 | capitalize: capitalize,
|
11043 | toHandlerKey: toHandlerKey,
|
11044 | normalizeProps: normalizeProps,
|
11045 | normalizeClass: normalizeClass,
|
11046 | normalizeStyle: normalizeStyle,
|
11047 | transformVNodeArgs: transformVNodeArgs,
|
11048 | version: version,
|
11049 | ssrUtils: ssrUtils,
|
11050 | resolveFilter: resolveFilter,
|
11051 | compatUtils: compatUtils
|
11052 | });
|
11053 |
|
11054 | function initDev() {
|
11055 | {
|
11056 | {
|
11057 | console.info(`You are running a development build of Vue.\n` +
|
11058 | `Make sure to use the production build (*.prod.js) when deploying for production.`);
|
11059 | }
|
11060 | initCustomFormatter();
|
11061 | }
|
11062 | }
|
11063 |
|
11064 | function defaultOnError(error) {
|
11065 | throw error;
|
11066 | }
|
11067 | function defaultOnWarn(msg) {
|
11068 | console.warn(`[Vue warn] ${msg.message}`);
|
11069 | }
|
11070 | function createCompilerError(code, loc, messages, additionalMessage) {
|
11071 | const msg = (messages || errorMessages)[code] + (additionalMessage || ``)
|
11072 | ;
|
11073 | const error = new SyntaxError(String(msg));
|
11074 | error.code = code;
|
11075 | error.loc = loc;
|
11076 | return error;
|
11077 | }
|
11078 | const errorMessages = {
|
11079 |
|
11080 | [0 ]: 'Illegal comment.',
|
11081 | [1 ]: 'CDATA section is allowed only in XML context.',
|
11082 | [2 ]: 'Duplicate attribute.',
|
11083 | [3 ]: 'End tag cannot have attributes.',
|
11084 | [4 ]: "Illegal '/' in tags.",
|
11085 | [5 ]: 'Unexpected EOF in tag.',
|
11086 | [6 ]: 'Unexpected EOF in CDATA section.',
|
11087 | [7 ]: 'Unexpected EOF in comment.',
|
11088 | [8 ]: 'Unexpected EOF in script.',
|
11089 | [9 ]: 'Unexpected EOF in tag.',
|
11090 | [10 ]: 'Incorrectly closed comment.',
|
11091 | [11 ]: 'Incorrectly opened comment.',
|
11092 | [12 ]: "Illegal tag name. Use '<' to print '<'.",
|
11093 | [13 ]: 'Attribute value was expected.',
|
11094 | [14 ]: 'End tag name was expected.',
|
11095 | [15 ]: 'Whitespace was expected.',
|
11096 | [16 ]: "Unexpected '<!--' in comment.",
|
11097 | [17 ]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
|
11098 | [18 ]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
|
11099 | [19 ]: "Attribute name cannot start with '='.",
|
11100 | [21 ]: "'<?' is allowed only in XML context.",
|
11101 | [20 ]: `Unexpected null character.`,
|
11102 | [22 ]: "Illegal '/' in tags.",
|
11103 |
|
11104 | [23 ]: 'Invalid end tag.',
|
11105 | [24 ]: 'Element is missing end tag.',
|
11106 | [25 ]: 'Interpolation end sign was not found.',
|
11107 | [27 ]: 'End bracket for dynamic directive argument was not found. ' +
|
11108 | 'Note that dynamic directive argument cannot contain spaces.',
|
11109 | [26 ]: 'Legal directive name was expected.',
|
11110 |
|
11111 | [28 ]: `v-if/v-else-if is missing expression.`,
|
11112 | [29 ]: `v-if/else branches must use unique keys.`,
|
11113 | [30 ]: `v-else/v-else-if has no adjacent v-if.`,
|
11114 | [31 ]: `v-for is missing expression.`,
|
11115 | [32 ]: `v-for has invalid expression.`,
|
11116 | [33 ]: `<template v-for> key should be placed on the <template> tag.`,
|
11117 | [34 ]: `v-bind is missing expression.`,
|
11118 | [35 ]: `v-on is missing expression.`,
|
11119 | [36 ]: `Unexpected custom directive on <slot> outlet.`,
|
11120 | [37 ]: `Mixed v-slot usage on both the component and nested <template>.` +
|
11121 | `When there are multiple named slots, all slots should use <template> ` +
|
11122 | `syntax to avoid scope ambiguity.`,
|
11123 | [38 ]: `Duplicate slot names found. `,
|
11124 | [39 ]: `Extraneous children found when component already has explicitly named ` +
|
11125 | `default slot. These children will be ignored.`,
|
11126 | [40 ]: `v-slot can only be used on components or <template> tags.`,
|
11127 | [41 ]: `v-model is missing expression.`,
|
11128 | [42 ]: `v-model value must be a valid JavaScript member expression.`,
|
11129 | [43 ]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
11130 | [44 ]: `Error parsing JavaScript expression: `,
|
11131 | [45 ]: `<KeepAlive> expects exactly one child component.`,
|
11132 |
|
11133 | [46 ]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
11134 | [47 ]: `ES module mode is not supported in this build of compiler.`,
|
11135 | [48 ]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
11136 | [49 ]: `"scopeId" option is only supported in module mode.`,
|
11137 |
|
11138 | [50 ]: ``
|
11139 | };
|
11140 |
|
11141 | const FRAGMENT = Symbol(`Fragment` );
|
11142 | const TELEPORT = Symbol(`Teleport` );
|
11143 | const SUSPENSE = Symbol(`Suspense` );
|
11144 | const KEEP_ALIVE = Symbol(`KeepAlive` );
|
11145 | const BASE_TRANSITION = Symbol(`BaseTransition` );
|
11146 | const OPEN_BLOCK = Symbol(`openBlock` );
|
11147 | const CREATE_BLOCK = Symbol(`createBlock` );
|
11148 | const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
|
11149 | const CREATE_VNODE = Symbol(`createVNode` );
|
11150 | const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
|
11151 | const CREATE_COMMENT = Symbol(`createCommentVNode` );
|
11152 | const CREATE_TEXT = Symbol(`createTextVNode` );
|
11153 | const CREATE_STATIC = Symbol(`createStaticVNode` );
|
11154 | const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
|
11155 | const RESOLVE_DYNAMIC_COMPONENT = Symbol(`resolveDynamicComponent` );
|
11156 | const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
|
11157 | const RESOLVE_FILTER = Symbol(`resolveFilter` );
|
11158 | const WITH_DIRECTIVES = Symbol(`withDirectives` );
|
11159 | const RENDER_LIST = Symbol(`renderList` );
|
11160 | const RENDER_SLOT = Symbol(`renderSlot` );
|
11161 | const CREATE_SLOTS = Symbol(`createSlots` );
|
11162 | const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
|
11163 | const MERGE_PROPS = Symbol(`mergeProps` );
|
11164 | const NORMALIZE_CLASS = Symbol(`normalizeClass` );
|
11165 | const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
|
11166 | const NORMALIZE_PROPS = Symbol(`normalizeProps` );
|
11167 | const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
|
11168 | const TO_HANDLERS = Symbol(`toHandlers` );
|
11169 | const CAMELIZE = Symbol(`camelize` );
|
11170 | const CAPITALIZE = Symbol(`capitalize` );
|
11171 | const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
|
11172 | const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
|
11173 | const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
|
11174 | const POP_SCOPE_ID = Symbol(`popScopeId` );
|
11175 | const WITH_CTX = Symbol(`withCtx` );
|
11176 | const UNREF = Symbol(`unref` );
|
11177 | const IS_REF = Symbol(`isRef` );
|
11178 | const WITH_MEMO = Symbol(`withMemo` );
|
11179 | const IS_MEMO_SAME = Symbol(`isMemoSame` );
|
11180 |
|
11181 |
|
11182 |
|
11183 | const helperNameMap = {
|
11184 | [FRAGMENT]: `Fragment`,
|
11185 | [TELEPORT]: `Teleport`,
|
11186 | [SUSPENSE]: `Suspense`,
|
11187 | [KEEP_ALIVE]: `KeepAlive`,
|
11188 | [BASE_TRANSITION]: `BaseTransition`,
|
11189 | [OPEN_BLOCK]: `openBlock`,
|
11190 | [CREATE_BLOCK]: `createBlock`,
|
11191 | [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
|
11192 | [CREATE_VNODE]: `createVNode`,
|
11193 | [CREATE_ELEMENT_VNODE]: `createElementVNode`,
|
11194 | [CREATE_COMMENT]: `createCommentVNode`,
|
11195 | [CREATE_TEXT]: `createTextVNode`,
|
11196 | [CREATE_STATIC]: `createStaticVNode`,
|
11197 | [RESOLVE_COMPONENT]: `resolveComponent`,
|
11198 | [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
|
11199 | [RESOLVE_DIRECTIVE]: `resolveDirective`,
|
11200 | [RESOLVE_FILTER]: `resolveFilter`,
|
11201 | [WITH_DIRECTIVES]: `withDirectives`,
|
11202 | [RENDER_LIST]: `renderList`,
|
11203 | [RENDER_SLOT]: `renderSlot`,
|
11204 | [CREATE_SLOTS]: `createSlots`,
|
11205 | [TO_DISPLAY_STRING]: `toDisplayString`,
|
11206 | [MERGE_PROPS]: `mergeProps`,
|
11207 | [NORMALIZE_CLASS]: `normalizeClass`,
|
11208 | [NORMALIZE_STYLE]: `normalizeStyle`,
|
11209 | [NORMALIZE_PROPS]: `normalizeProps`,
|
11210 | [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
|
11211 | [TO_HANDLERS]: `toHandlers`,
|
11212 | [CAMELIZE]: `camelize`,
|
11213 | [CAPITALIZE]: `capitalize`,
|
11214 | [TO_HANDLER_KEY]: `toHandlerKey`,
|
11215 | [SET_BLOCK_TRACKING]: `setBlockTracking`,
|
11216 | [PUSH_SCOPE_ID]: `pushScopeId`,
|
11217 | [POP_SCOPE_ID]: `popScopeId`,
|
11218 | [WITH_CTX]: `withCtx`,
|
11219 | [UNREF]: `unref`,
|
11220 | [IS_REF]: `isRef`,
|
11221 | [WITH_MEMO]: `withMemo`,
|
11222 | [IS_MEMO_SAME]: `isMemoSame`
|
11223 | };
|
11224 | function registerRuntimeHelpers(helpers) {
|
11225 | Object.getOwnPropertySymbols(helpers).forEach(s => {
|
11226 | helperNameMap[s] = helpers[s];
|
11227 | });
|
11228 | }
|
11229 |
|
11230 |
|
11231 |
|
11232 |
|
11233 |
|
11234 | const locStub = {
|
11235 | source: '',
|
11236 | start: { line: 1, column: 1, offset: 0 },
|
11237 | end: { line: 1, column: 1, offset: 0 }
|
11238 | };
|
11239 | function createRoot(children, loc = locStub) {
|
11240 | return {
|
11241 | type: 0 ,
|
11242 | children,
|
11243 | helpers: [],
|
11244 | components: [],
|
11245 | directives: [],
|
11246 | hoists: [],
|
11247 | imports: [],
|
11248 | cached: 0,
|
11249 | temps: 0,
|
11250 | codegenNode: undefined,
|
11251 | loc
|
11252 | };
|
11253 | }
|
11254 | function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
|
11255 | if (context) {
|
11256 | if (isBlock) {
|
11257 | context.helper(OPEN_BLOCK);
|
11258 | context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
|
11259 | }
|
11260 | else {
|
11261 | context.helper(getVNodeHelper(context.inSSR, isComponent));
|
11262 | }
|
11263 | if (directives) {
|
11264 | context.helper(WITH_DIRECTIVES);
|
11265 | }
|
11266 | }
|
11267 | return {
|
11268 | type: 13 ,
|
11269 | tag,
|
11270 | props,
|
11271 | children,
|
11272 | patchFlag,
|
11273 | dynamicProps,
|
11274 | directives,
|
11275 | isBlock,
|
11276 | disableTracking,
|
11277 | isComponent,
|
11278 | loc
|
11279 | };
|
11280 | }
|
11281 | function createArrayExpression(elements, loc = locStub) {
|
11282 | return {
|
11283 | type: 17 ,
|
11284 | loc,
|
11285 | elements
|
11286 | };
|
11287 | }
|
11288 | function createObjectExpression(properties, loc = locStub) {
|
11289 | return {
|
11290 | type: 15 ,
|
11291 | loc,
|
11292 | properties
|
11293 | };
|
11294 | }
|
11295 | function createObjectProperty(key, value) {
|
11296 | return {
|
11297 | type: 16 ,
|
11298 | loc: locStub,
|
11299 | key: isString(key) ? createSimpleExpression(key, true) : key,
|
11300 | value
|
11301 | };
|
11302 | }
|
11303 | function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* NOT_CONSTANT */) {
|
11304 | return {
|
11305 | type: 4 ,
|
11306 | loc,
|
11307 | content,
|
11308 | isStatic,
|
11309 | constType: isStatic ? 3 : constType
|
11310 | };
|
11311 | }
|
11312 | function createCompoundExpression(children, loc = locStub) {
|
11313 | return {
|
11314 | type: 8 ,
|
11315 | loc,
|
11316 | children
|
11317 | };
|
11318 | }
|
11319 | function createCallExpression(callee, args = [], loc = locStub) {
|
11320 | return {
|
11321 | type: 14 ,
|
11322 | loc,
|
11323 | callee,
|
11324 | arguments: args
|
11325 | };
|
11326 | }
|
11327 | function createFunctionExpression(params, returns = undefined, newline = false, isSlot = false, loc = locStub) {
|
11328 | return {
|
11329 | type: 18 ,
|
11330 | params,
|
11331 | returns,
|
11332 | newline,
|
11333 | isSlot,
|
11334 | loc
|
11335 | };
|
11336 | }
|
11337 | function createConditionalExpression(test, consequent, alternate, newline = true) {
|
11338 | return {
|
11339 | type: 19 ,
|
11340 | test,
|
11341 | consequent,
|
11342 | alternate,
|
11343 | newline,
|
11344 | loc: locStub
|
11345 | };
|
11346 | }
|
11347 | function createCacheExpression(index, value, isVNode = false) {
|
11348 | return {
|
11349 | type: 20 ,
|
11350 | index,
|
11351 | value,
|
11352 | isVNode,
|
11353 | loc: locStub
|
11354 | };
|
11355 | }
|
11356 | function createBlockStatement(body) {
|
11357 | return {
|
11358 | type: 21 ,
|
11359 | body,
|
11360 | loc: locStub
|
11361 | };
|
11362 | }
|
11363 |
|
11364 | const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
11365 | const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
|
11366 | function isCoreComponent(tag) {
|
11367 | if (isBuiltInType(tag, 'Teleport')) {
|
11368 | return TELEPORT;
|
11369 | }
|
11370 | else if (isBuiltInType(tag, 'Suspense')) {
|
11371 | return SUSPENSE;
|
11372 | }
|
11373 | else if (isBuiltInType(tag, 'KeepAlive')) {
|
11374 | return KEEP_ALIVE;
|
11375 | }
|
11376 | else if (isBuiltInType(tag, 'BaseTransition')) {
|
11377 | return BASE_TRANSITION;
|
11378 | }
|
11379 | }
|
11380 | const nonIdentifierRE = /^\d|[^\$\w]/;
|
11381 | const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
11382 | const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
11383 | const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
11384 | const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
|
11385 |
|
11386 |
|
11387 |
|
11388 |
|
11389 |
|
11390 |
|
11391 | const isMemberExpression = (path) => {
|
11392 |
|
11393 | path = path.trim().replace(whitespaceRE, s => s.trim());
|
11394 | let state = 0 ;
|
11395 | let stateStack = [];
|
11396 | let currentOpenBracketCount = 0;
|
11397 | let currentOpenParensCount = 0;
|
11398 | let currentStringType = null;
|
11399 | for (let i = 0; i < path.length; i++) {
|
11400 | const char = path.charAt(i);
|
11401 | switch (state) {
|
11402 | case 0 :
|
11403 | if (char === '[') {
|
11404 | stateStack.push(state);
|
11405 | state = 1 ;
|
11406 | currentOpenBracketCount++;
|
11407 | }
|
11408 | else if (char === '(') {
|
11409 | stateStack.push(state);
|
11410 | state = 2 ;
|
11411 | currentOpenParensCount++;
|
11412 | }
|
11413 | else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
|
11414 | return false;
|
11415 | }
|
11416 | break;
|
11417 | case 1 :
|
11418 | if (char === `'` || char === `"` || char === '`') {
|
11419 | stateStack.push(state);
|
11420 | state = 3 ;
|
11421 | currentStringType = char;
|
11422 | }
|
11423 | else if (char === `[`) {
|
11424 | currentOpenBracketCount++;
|
11425 | }
|
11426 | else if (char === `]`) {
|
11427 | if (!--currentOpenBracketCount) {
|
11428 | state = stateStack.pop();
|
11429 | }
|
11430 | }
|
11431 | break;
|
11432 | case 2 :
|
11433 | if (char === `'` || char === `"` || char === '`') {
|
11434 | stateStack.push(state);
|
11435 | state = 3 ;
|
11436 | currentStringType = char;
|
11437 | }
|
11438 | else if (char === `(`) {
|
11439 | currentOpenParensCount++;
|
11440 | }
|
11441 | else if (char === `)`) {
|
11442 |
|
11443 | if (i === path.length - 1) {
|
11444 | return false;
|
11445 | }
|
11446 | if (!--currentOpenParensCount) {
|
11447 | state = stateStack.pop();
|
11448 | }
|
11449 | }
|
11450 | break;
|
11451 | case 3 :
|
11452 | if (char === currentStringType) {
|
11453 | state = stateStack.pop();
|
11454 | currentStringType = null;
|
11455 | }
|
11456 | break;
|
11457 | }
|
11458 | }
|
11459 | return !currentOpenBracketCount && !currentOpenParensCount;
|
11460 | };
|
11461 | function getInnerRange(loc, offset, length) {
|
11462 | const source = loc.source.substr(offset, length);
|
11463 | const newLoc = {
|
11464 | source,
|
11465 | start: advancePositionWithClone(loc.start, loc.source, offset),
|
11466 | end: loc.end
|
11467 | };
|
11468 | if (length != null) {
|
11469 | newLoc.end = advancePositionWithClone(loc.start, loc.source, offset + length);
|
11470 | }
|
11471 | return newLoc;
|
11472 | }
|
11473 | function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
|
11474 | return advancePositionWithMutation(extend({}, pos), source, numberOfCharacters);
|
11475 | }
|
11476 |
|
11477 |
|
11478 | function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
|
11479 | let linesCount = 0;
|
11480 | let lastNewLinePos = -1;
|
11481 | for (let i = 0; i < numberOfCharacters; i++) {
|
11482 | if (source.charCodeAt(i) === 10 ) {
|
11483 | linesCount++;
|
11484 | lastNewLinePos = i;
|
11485 | }
|
11486 | }
|
11487 | pos.offset += numberOfCharacters;
|
11488 | pos.line += linesCount;
|
11489 | pos.column =
|
11490 | lastNewLinePos === -1
|
11491 | ? pos.column + numberOfCharacters
|
11492 | : numberOfCharacters - lastNewLinePos;
|
11493 | return pos;
|
11494 | }
|
11495 | function assert(condition, msg) {
|
11496 |
|
11497 | if (!condition) {
|
11498 | throw new Error(msg || `unexpected compiler condition`);
|
11499 | }
|
11500 | }
|
11501 | function findDir(node, name, allowEmpty = false) {
|
11502 | for (let i = 0; i < node.props.length; i++) {
|
11503 | const p = node.props[i];
|
11504 | if (p.type === 7 &&
|
11505 | (allowEmpty || p.exp) &&
|
11506 | (isString(name) ? p.name === name : name.test(p.name))) {
|
11507 | return p;
|
11508 | }
|
11509 | }
|
11510 | }
|
11511 | function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
11512 | for (let i = 0; i < node.props.length; i++) {
|
11513 | const p = node.props[i];
|
11514 | if (p.type === 6 ) {
|
11515 | if (dynamicOnly)
|
11516 | continue;
|
11517 | if (p.name === name && (p.value || allowEmpty)) {
|
11518 | return p;
|
11519 | }
|
11520 | }
|
11521 | else if (p.name === 'bind' &&
|
11522 | (p.exp || allowEmpty) &&
|
11523 | isBindKey(p.arg, name)) {
|
11524 | return p;
|
11525 | }
|
11526 | }
|
11527 | }
|
11528 | function isBindKey(arg, name) {
|
11529 | return !!(arg && isStaticExp(arg) && arg.content === name);
|
11530 | }
|
11531 | function hasDynamicKeyVBind(node) {
|
11532 | return node.props.some(p => p.type === 7 &&
|
11533 | p.name === 'bind' &&
|
11534 | (!p.arg ||
|
11535 | p.arg.type !== 4 ||
|
11536 | !p.arg.isStatic)
|
11537 | );
|
11538 | }
|
11539 | function isText(node) {
|
11540 | return node.type === 5 || node.type === 2 ;
|
11541 | }
|
11542 | function isVSlot(p) {
|
11543 | return p.type === 7 && p.name === 'slot';
|
11544 | }
|
11545 | function isTemplateNode(node) {
|
11546 | return (node.type === 1 && node.tagType === 3 );
|
11547 | }
|
11548 | function isSlotOutlet(node) {
|
11549 | return node.type === 1 && node.tagType === 2 ;
|
11550 | }
|
11551 | function getVNodeHelper(ssr, isComponent) {
|
11552 | return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
11553 | }
|
11554 | function getVNodeBlockHelper(ssr, isComponent) {
|
11555 | return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
|
11556 | }
|
11557 | const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
11558 | function getUnnormalizedProps(props, callPath = []) {
|
11559 | if (props &&
|
11560 | !isString(props) &&
|
11561 | props.type === 14 ) {
|
11562 | const callee = props.callee;
|
11563 | if (!isString(callee) && propsHelperSet.has(callee)) {
|
11564 | return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
|
11565 | }
|
11566 | }
|
11567 | return [props, callPath];
|
11568 | }
|
11569 | function injectProp(node, prop, context) {
|
11570 | let propsWithInjection;
|
11571 | const originalProps = node.type === 13 ? node.props : node.arguments[2];
|
11572 | |
11573 |
|
11574 |
|
11575 |
|
11576 |
|
11577 |
|
11578 |
|
11579 |
|
11580 | let props = originalProps;
|
11581 | let callPath = [];
|
11582 | let parentCall;
|
11583 | if (props &&
|
11584 | !isString(props) &&
|
11585 | props.type === 14 ) {
|
11586 | const ret = getUnnormalizedProps(props);
|
11587 | props = ret[0];
|
11588 | callPath = ret[1];
|
11589 | parentCall = callPath[callPath.length - 1];
|
11590 | }
|
11591 | if (props == null || isString(props)) {
|
11592 | propsWithInjection = createObjectExpression([prop]);
|
11593 | }
|
11594 | else if (props.type === 14 ) {
|
11595 |
|
11596 |
|
11597 |
|
11598 | const first = props.arguments[0];
|
11599 | if (!isString(first) && first.type === 15 ) {
|
11600 | first.properties.unshift(prop);
|
11601 | }
|
11602 | else {
|
11603 | if (props.callee === TO_HANDLERS) {
|
11604 |
|
11605 | propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
|
11606 | createObjectExpression([prop]),
|
11607 | props
|
11608 | ]);
|
11609 | }
|
11610 | else {
|
11611 | props.arguments.unshift(createObjectExpression([prop]));
|
11612 | }
|
11613 | }
|
11614 | !propsWithInjection && (propsWithInjection = props);
|
11615 | }
|
11616 | else if (props.type === 15 ) {
|
11617 | let alreadyExists = false;
|
11618 |
|
11619 | if (prop.key.type === 4 ) {
|
11620 | const propKeyName = prop.key.content;
|
11621 | alreadyExists = props.properties.some(p => p.key.type === 4 &&
|
11622 | p.key.content === propKeyName);
|
11623 | }
|
11624 | if (!alreadyExists) {
|
11625 | props.properties.unshift(prop);
|
11626 | }
|
11627 | propsWithInjection = props;
|
11628 | }
|
11629 | else {
|
11630 |
|
11631 | propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
|
11632 | createObjectExpression([prop]),
|
11633 | props
|
11634 | ]);
|
11635 |
|
11636 |
|
11637 |
|
11638 | if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
|
11639 | parentCall = callPath[callPath.length - 2];
|
11640 | }
|
11641 | }
|
11642 | if (node.type === 13 ) {
|
11643 | if (parentCall) {
|
11644 | parentCall.arguments[0] = propsWithInjection;
|
11645 | }
|
11646 | else {
|
11647 | node.props = propsWithInjection;
|
11648 | }
|
11649 | }
|
11650 | else {
|
11651 | if (parentCall) {
|
11652 | parentCall.arguments[0] = propsWithInjection;
|
11653 | }
|
11654 | else {
|
11655 | node.arguments[2] = propsWithInjection;
|
11656 | }
|
11657 | }
|
11658 | }
|
11659 | function toValidAssetId(name, type) {
|
11660 |
|
11661 | return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
|
11662 | return searchValue === '-' ? '_' : name.charCodeAt(replaceValue).toString();
|
11663 | })}`;
|
11664 | }
|
11665 | function getMemoedVNodeCall(node) {
|
11666 | if (node.type === 14 && node.callee === WITH_MEMO) {
|
11667 | return node.arguments[1].returns;
|
11668 | }
|
11669 | else {
|
11670 | return node;
|
11671 | }
|
11672 | }
|
11673 | function makeBlock(node, { helper, removeHelper, inSSR }) {
|
11674 | if (!node.isBlock) {
|
11675 | node.isBlock = true;
|
11676 | removeHelper(getVNodeHelper(inSSR, node.isComponent));
|
11677 | helper(OPEN_BLOCK);
|
11678 | helper(getVNodeBlockHelper(inSSR, node.isComponent));
|
11679 | }
|
11680 | }
|
11681 |
|
11682 | const deprecationData$1 = {
|
11683 | ["COMPILER_IS_ON_ELEMENT" ]: {
|
11684 | message: `Platform-native elements with "is" prop will no longer be ` +
|
11685 | `treated as components in Vue 3 unless the "is" value is explicitly ` +
|
11686 | `prefixed with "vue:".`,
|
11687 | link: `https://v3.vuejs.org/guide/migration/custom-elements-interop.html`
|
11688 | },
|
11689 | ["COMPILER_V_BIND_SYNC" ]: {
|
11690 | message: key => `.sync modifier for v-bind has been removed. Use v-model with ` +
|
11691 | `argument instead. \`v-bind:${key}.sync\` should be changed to ` +
|
11692 | `\`v-model:${key}\`.`,
|
11693 | link: `https://v3.vuejs.org/guide/migration/v-model.html`
|
11694 | },
|
11695 | ["COMPILER_V_BIND_PROP" ]: {
|
11696 | message: `.prop modifier for v-bind has been removed and no longer necessary. ` +
|
11697 | `Vue 3 will automatically set a binding as DOM property when appropriate.`
|
11698 | },
|
11699 | ["COMPILER_V_BIND_OBJECT_ORDER" ]: {
|
11700 | message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript ` +
|
11701 | `object spread: it will now overwrite an existing non-mergeable attribute ` +
|
11702 | `that appears before v-bind in the case of conflict. ` +
|
11703 | `To retain 2.x behavior, move v-bind to make it the first attribute. ` +
|
11704 | `You can also suppress this warning if the usage is intended.`,
|
11705 | link: `https://v3.vuejs.org/guide/migration/v-bind.html`
|
11706 | },
|
11707 | ["COMPILER_V_ON_NATIVE" ]: {
|
11708 | message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
11709 | link: `https://v3.vuejs.org/guide/migration/v-on-native-modifier-removed.html`
|
11710 | },
|
11711 | ["COMPILER_V_IF_V_FOR_PRECEDENCE" ]: {
|
11712 | message: `v-if / v-for precedence when used on the same element has changed ` +
|
11713 | `in Vue 3: v-if now takes higher precedence and will no longer have ` +
|
11714 | `access to v-for scope variables. It is best to avoid the ambiguity ` +
|
11715 | `with <template> tags or use a computed property that filters v-for ` +
|
11716 | `data source.`,
|
11717 | link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
|
11718 | },
|
11719 | ["COMPILER_V_FOR_REF" ]: {
|
11720 | message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
|
11721 | `Consider using function refs or refactor to avoid ref usage altogether.`,
|
11722 | link: `https://v3.vuejs.org/guide/migration/array-refs.html`
|
11723 | },
|
11724 | ["COMPILER_NATIVE_TEMPLATE" ]: {
|
11725 | message: `<template> with no special directives will render as a native template ` +
|
11726 | `element instead of its inner content in Vue 3.`
|
11727 | },
|
11728 | ["COMPILER_INLINE_TEMPLATE" ]: {
|
11729 | message: `"inline-template" has been removed in Vue 3.`,
|
11730 | link: `https://v3.vuejs.org/guide/migration/inline-template-attribute.html`
|
11731 | },
|
11732 | ["COMPILER_FILTER" ]: {
|
11733 | message: `filters have been removed in Vue 3. ` +
|
11734 | `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
|
11735 | `Use method calls or computed properties instead.`,
|
11736 | link: `https://v3.vuejs.org/guide/migration/filters.html`
|
11737 | }
|
11738 | };
|
11739 | function getCompatValue(key, context) {
|
11740 | const config = context.options
|
11741 | ? context.options.compatConfig
|
11742 | : context.compatConfig;
|
11743 | const value = config && config[key];
|
11744 | if (key === 'MODE') {
|
11745 | return value || 3;
|
11746 | }
|
11747 | else {
|
11748 | return value;
|
11749 | }
|
11750 | }
|
11751 | function isCompatEnabled$1(key, context) {
|
11752 | const mode = getCompatValue('MODE', context);
|
11753 | const value = getCompatValue(key, context);
|
11754 |
|
11755 |
|
11756 | return mode === 3 ? value === true : value !== false;
|
11757 | }
|
11758 | function checkCompatEnabled(key, context, loc, ...args) {
|
11759 | const enabled = isCompatEnabled$1(key, context);
|
11760 | if (enabled) {
|
11761 | warnDeprecation$1(key, context, loc, ...args);
|
11762 | }
|
11763 | return enabled;
|
11764 | }
|
11765 | function warnDeprecation$1(key, context, loc, ...args) {
|
11766 | const val = getCompatValue(key, context);
|
11767 | if (val === 'suppress-warning') {
|
11768 | return;
|
11769 | }
|
11770 | const { message, link } = deprecationData$1[key];
|
11771 | const msg = `(deprecation ${key}) ${typeof message === 'function' ? message(...args) : message}${link ? `\n Details: ${link}` : ``}`;
|
11772 | const err = new SyntaxError(msg);
|
11773 | err.code = key;
|
11774 | if (loc)
|
11775 | err.loc = loc;
|
11776 | context.onWarn(err);
|
11777 | }
|
11778 |
|
11779 |
|
11780 |
|
11781 |
|
11782 | const decodeRE = /&(gt|lt|amp|apos|quot);/g;
|
11783 | const decodeMap = {
|
11784 | gt: '>',
|
11785 | lt: '<',
|
11786 | amp: '&',
|
11787 | apos: "'",
|
11788 | quot: '"'
|
11789 | };
|
11790 | const defaultParserOptions = {
|
11791 | delimiters: [`{{`, `}}`],
|
11792 | getNamespace: () => 0 ,
|
11793 | getTextMode: () => 0 ,
|
11794 | isVoidTag: NO,
|
11795 | isPreTag: NO,
|
11796 | isCustomElement: NO,
|
11797 | decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
|
11798 | onError: defaultOnError,
|
11799 | onWarn: defaultOnWarn,
|
11800 | comments: true
|
11801 | };
|
11802 | function baseParse(content, options = {}) {
|
11803 | const context = createParserContext(content, options);
|
11804 | const start = getCursor(context);
|
11805 | return createRoot(parseChildren(context, 0 , []), getSelection(context, start));
|
11806 | }
|
11807 | function createParserContext(content, rawOptions) {
|
11808 | const options = extend({}, defaultParserOptions);
|
11809 | let key;
|
11810 | for (key in rawOptions) {
|
11811 |
|
11812 | options[key] =
|
11813 | rawOptions[key] === undefined
|
11814 | ? defaultParserOptions[key]
|
11815 | : rawOptions[key];
|
11816 | }
|
11817 | return {
|
11818 | options,
|
11819 | column: 1,
|
11820 | line: 1,
|
11821 | offset: 0,
|
11822 | originalSource: content,
|
11823 | source: content,
|
11824 | inPre: false,
|
11825 | inVPre: false,
|
11826 | onWarn: options.onWarn
|
11827 | };
|
11828 | }
|
11829 | function parseChildren(context, mode, ancestors) {
|
11830 | const parent = last(ancestors);
|
11831 | const ns = parent ? parent.ns : 0 ;
|
11832 | const nodes = [];
|
11833 | while (!isEnd(context, mode, ancestors)) {
|
11834 | const s = context.source;
|
11835 | let node = undefined;
|
11836 | if (mode === 0 || mode === 1 ) {
|
11837 | if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
|
11838 |
|
11839 | node = parseInterpolation(context, mode);
|
11840 | }
|
11841 | else if (mode === 0 && s[0] === '<') {
|
11842 |
|
11843 | if (s.length === 1) {
|
11844 | emitError(context, 5 , 1);
|
11845 | }
|
11846 | else if (s[1] === '!') {
|
11847 |
|
11848 | if (startsWith(s, '<!--')) {
|
11849 | node = parseComment(context);
|
11850 | }
|
11851 | else if (startsWith(s, '<!DOCTYPE')) {
|
11852 |
|
11853 | node = parseBogusComment(context);
|
11854 | }
|
11855 | else if (startsWith(s, '<![CDATA[')) {
|
11856 | if (ns !== 0 ) {
|
11857 | node = parseCDATA(context, ancestors);
|
11858 | }
|
11859 | else {
|
11860 | emitError(context, 1 );
|
11861 | node = parseBogusComment(context);
|
11862 | }
|
11863 | }
|
11864 | else {
|
11865 | emitError(context, 11 );
|
11866 | node = parseBogusComment(context);
|
11867 | }
|
11868 | }
|
11869 | else if (s[1] === '/') {
|
11870 |
|
11871 | if (s.length === 2) {
|
11872 | emitError(context, 5 , 2);
|
11873 | }
|
11874 | else if (s[2] === '>') {
|
11875 | emitError(context, 14 , 2);
|
11876 | advanceBy(context, 3);
|
11877 | continue;
|
11878 | }
|
11879 | else if (/[a-z]/i.test(s[2])) {
|
11880 | emitError(context, 23 );
|
11881 | parseTag(context, 1 , parent);
|
11882 | continue;
|
11883 | }
|
11884 | else {
|
11885 | emitError(context, 12 , 2);
|
11886 | node = parseBogusComment(context);
|
11887 | }
|
11888 | }
|
11889 | else if (/[a-z]/i.test(s[1])) {
|
11890 | node = parseElement(context, ancestors);
|
11891 | }
|
11892 | else if (s[1] === '?') {
|
11893 | emitError(context, 21 , 1);
|
11894 | node = parseBogusComment(context);
|
11895 | }
|
11896 | else {
|
11897 | emitError(context, 12 , 1);
|
11898 | }
|
11899 | }
|
11900 | }
|
11901 | if (!node) {
|
11902 | node = parseText(context, mode);
|
11903 | }
|
11904 | if (isArray(node)) {
|
11905 | for (let i = 0; i < node.length; i++) {
|
11906 | pushNode(nodes, node[i]);
|
11907 | }
|
11908 | }
|
11909 | else {
|
11910 | pushNode(nodes, node);
|
11911 | }
|
11912 | }
|
11913 |
|
11914 | let removedWhitespace = false;
|
11915 | if (mode !== 2 && mode !== 1 ) {
|
11916 | const shouldCondense = context.options.whitespace !== 'preserve';
|
11917 | for (let i = 0; i < nodes.length; i++) {
|
11918 | const node = nodes[i];
|
11919 | if (!context.inPre && node.type === 2 ) {
|
11920 | if (!/[^\t\r\n\f ]/.test(node.content)) {
|
11921 | const prev = nodes[i - 1];
|
11922 | const next = nodes[i + 1];
|
11923 |
|
11924 |
|
11925 |
|
11926 |
|
11927 | if (!prev ||
|
11928 | !next ||
|
11929 | (shouldCondense &&
|
11930 | (prev.type === 3 ||
|
11931 | next.type === 3 ||
|
11932 | (prev.type === 1 &&
|
11933 | next.type === 1 &&
|
11934 | /[\r\n]/.test(node.content))))) {
|
11935 | removedWhitespace = true;
|
11936 | nodes[i] = null;
|
11937 | }
|
11938 | else {
|
11939 |
|
11940 | node.content = ' ';
|
11941 | }
|
11942 | }
|
11943 | else if (shouldCondense) {
|
11944 |
|
11945 |
|
11946 | node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
|
11947 | }
|
11948 | }
|
11949 |
|
11950 | else if (node.type === 3 && !context.options.comments) {
|
11951 | removedWhitespace = true;
|
11952 | nodes[i] = null;
|
11953 | }
|
11954 | }
|
11955 | if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
|
11956 |
|
11957 |
|
11958 | const first = nodes[0];
|
11959 | if (first && first.type === 2 ) {
|
11960 | first.content = first.content.replace(/^\r?\n/, '');
|
11961 | }
|
11962 | }
|
11963 | }
|
11964 | return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
11965 | }
|
11966 | function pushNode(nodes, node) {
|
11967 | if (node.type === 2 ) {
|
11968 | const prev = last(nodes);
|
11969 |
|
11970 |
|
11971 | if (prev &&
|
11972 | prev.type === 2 &&
|
11973 | prev.loc.end.offset === node.loc.start.offset) {
|
11974 | prev.content += node.content;
|
11975 | prev.loc.end = node.loc.end;
|
11976 | prev.loc.source += node.loc.source;
|
11977 | return;
|
11978 | }
|
11979 | }
|
11980 | nodes.push(node);
|
11981 | }
|
11982 | function parseCDATA(context, ancestors) {
|
11983 | advanceBy(context, 9);
|
11984 | const nodes = parseChildren(context, 3 , ancestors);
|
11985 | if (context.source.length === 0) {
|
11986 | emitError(context, 6 );
|
11987 | }
|
11988 | else {
|
11989 | advanceBy(context, 3);
|
11990 | }
|
11991 | return nodes;
|
11992 | }
|
11993 | function parseComment(context) {
|
11994 | const start = getCursor(context);
|
11995 | let content;
|
11996 |
|
11997 | const match = /--(\!)?>/.exec(context.source);
|
11998 | if (!match) {
|
11999 | content = context.source.slice(4);
|
12000 | advanceBy(context, context.source.length);
|
12001 | emitError(context, 7 );
|
12002 | }
|
12003 | else {
|
12004 | if (match.index <= 3) {
|
12005 | emitError(context, 0 );
|
12006 | }
|
12007 | if (match[1]) {
|
12008 | emitError(context, 10 );
|
12009 | }
|
12010 | content = context.source.slice(4, match.index);
|
12011 |
|
12012 | const s = context.source.slice(0, match.index);
|
12013 | let prevIndex = 1, nestedIndex = 0;
|
12014 | while ((nestedIndex = s.indexOf('<!--', prevIndex)) !== -1) {
|
12015 | advanceBy(context, nestedIndex - prevIndex + 1);
|
12016 | if (nestedIndex + 4 < s.length) {
|
12017 | emitError(context, 16 );
|
12018 | }
|
12019 | prevIndex = nestedIndex + 1;
|
12020 | }
|
12021 | advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
12022 | }
|
12023 | return {
|
12024 | type: 3 ,
|
12025 | content,
|
12026 | loc: getSelection(context, start)
|
12027 | };
|
12028 | }
|
12029 | function parseBogusComment(context) {
|
12030 | const start = getCursor(context);
|
12031 | const contentStart = context.source[1] === '?' ? 1 : 2;
|
12032 | let content;
|
12033 | const closeIndex = context.source.indexOf('>');
|
12034 | if (closeIndex === -1) {
|
12035 | content = context.source.slice(contentStart);
|
12036 | advanceBy(context, context.source.length);
|
12037 | }
|
12038 | else {
|
12039 | content = context.source.slice(contentStart, closeIndex);
|
12040 | advanceBy(context, closeIndex + 1);
|
12041 | }
|
12042 | return {
|
12043 | type: 3 ,
|
12044 | content,
|
12045 | loc: getSelection(context, start)
|
12046 | };
|
12047 | }
|
12048 | function parseElement(context, ancestors) {
|
12049 |
|
12050 | const wasInPre = context.inPre;
|
12051 | const wasInVPre = context.inVPre;
|
12052 | const parent = last(ancestors);
|
12053 | const element = parseTag(context, 0 , parent);
|
12054 | const isPreBoundary = context.inPre && !wasInPre;
|
12055 | const isVPreBoundary = context.inVPre && !wasInVPre;
|
12056 | if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
|
12057 |
|
12058 | if (isPreBoundary) {
|
12059 | context.inPre = false;
|
12060 | }
|
12061 | if (isVPreBoundary) {
|
12062 | context.inVPre = false;
|
12063 | }
|
12064 | return element;
|
12065 | }
|
12066 |
|
12067 | ancestors.push(element);
|
12068 | const mode = context.options.getTextMode(element, parent);
|
12069 | const children = parseChildren(context, mode, ancestors);
|
12070 | ancestors.pop();
|
12071 | element.children = children;
|
12072 |
|
12073 | if (startsWithEndTagOpen(context.source, element.tag)) {
|
12074 | parseTag(context, 1 , parent);
|
12075 | }
|
12076 | else {
|
12077 | emitError(context, 24 , 0, element.loc.start);
|
12078 | if (context.source.length === 0 && element.tag.toLowerCase() === 'script') {
|
12079 | const first = children[0];
|
12080 | if (first && startsWith(first.loc.source, '<!--')) {
|
12081 | emitError(context, 8 );
|
12082 | }
|
12083 | }
|
12084 | }
|
12085 | element.loc = getSelection(context, element.loc.start);
|
12086 | if (isPreBoundary) {
|
12087 | context.inPre = false;
|
12088 | }
|
12089 | if (isVPreBoundary) {
|
12090 | context.inVPre = false;
|
12091 | }
|
12092 | return element;
|
12093 | }
|
12094 | const isSpecialTemplateDirective = makeMap(`if,else,else-if,for,slot`);
|
12095 | function parseTag(context, type, parent) {
|
12096 |
|
12097 | const start = getCursor(context);
|
12098 | const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
|
12099 | const tag = match[1];
|
12100 | const ns = context.options.getNamespace(tag, parent);
|
12101 | advanceBy(context, match[0].length);
|
12102 | advanceSpaces(context);
|
12103 |
|
12104 | const cursor = getCursor(context);
|
12105 | const currentSource = context.source;
|
12106 |
|
12107 | if (context.options.isPreTag(tag)) {
|
12108 | context.inPre = true;
|
12109 | }
|
12110 |
|
12111 | let props = parseAttributes(context, type);
|
12112 |
|
12113 | if (type === 0 &&
|
12114 | !context.inVPre &&
|
12115 | props.some(p => p.type === 7 && p.name === 'pre')) {
|
12116 | context.inVPre = true;
|
12117 |
|
12118 | extend(context, cursor);
|
12119 | context.source = currentSource;
|
12120 |
|
12121 | props = parseAttributes(context, type).filter(p => p.name !== 'v-pre');
|
12122 | }
|
12123 |
|
12124 | let isSelfClosing = false;
|
12125 | if (context.source.length === 0) {
|
12126 | emitError(context, 9 );
|
12127 | }
|
12128 | else {
|
12129 | isSelfClosing = startsWith(context.source, '/>');
|
12130 | if (type === 1 && isSelfClosing) {
|
12131 | emitError(context, 4 );
|
12132 | }
|
12133 | advanceBy(context, isSelfClosing ? 2 : 1);
|
12134 | }
|
12135 | if (type === 1 ) {
|
12136 | return;
|
12137 | }
|
12138 | let tagType = 0 ;
|
12139 | if (!context.inVPre) {
|
12140 | if (tag === 'slot') {
|
12141 | tagType = 2 ;
|
12142 | }
|
12143 | else if (tag === 'template') {
|
12144 | if (props.some(p => p.type === 7 && isSpecialTemplateDirective(p.name))) {
|
12145 | tagType = 3 ;
|
12146 | }
|
12147 | }
|
12148 | else if (isComponent(tag, props, context)) {
|
12149 | tagType = 1 ;
|
12150 | }
|
12151 | }
|
12152 | return {
|
12153 | type: 1 ,
|
12154 | ns,
|
12155 | tag,
|
12156 | tagType,
|
12157 | props,
|
12158 | isSelfClosing,
|
12159 | children: [],
|
12160 | loc: getSelection(context, start),
|
12161 | codegenNode: undefined
|
12162 | };
|
12163 | }
|
12164 | function isComponent(tag, props, context) {
|
12165 | const options = context.options;
|
12166 | if (options.isCustomElement(tag)) {
|
12167 | return false;
|
12168 | }
|
12169 | if (tag === 'component' ||
|
12170 | /^[A-Z]/.test(tag) ||
|
12171 | isCoreComponent(tag) ||
|
12172 | (options.isBuiltInComponent && options.isBuiltInComponent(tag)) ||
|
12173 | (options.isNativeTag && !options.isNativeTag(tag))) {
|
12174 | return true;
|
12175 | }
|
12176 |
|
12177 |
|
12178 | for (let i = 0; i < props.length; i++) {
|
12179 | const p = props[i];
|
12180 | if (p.type === 6 ) {
|
12181 | if (p.name === 'is' && p.value) {
|
12182 | if (p.value.content.startsWith('vue:')) {
|
12183 | return true;
|
12184 | }
|
12185 | }
|
12186 | }
|
12187 | else {
|
12188 |
|
12189 |
|
12190 | if (p.name === 'is') {
|
12191 | return true;
|
12192 | }
|
12193 | else if (
|
12194 |
|
12195 | p.name === 'bind' &&
|
12196 | isBindKey(p.arg, 'is') &&
|
12197 | false &&
|
12198 | checkCompatEnabled("COMPILER_IS_ON_ELEMENT" , context, p.loc)) {
|
12199 | return true;
|
12200 | }
|
12201 | }
|
12202 | }
|
12203 | }
|
12204 | function parseAttributes(context, type) {
|
12205 | const props = [];
|
12206 | const attributeNames = new Set();
|
12207 | while (context.source.length > 0 &&
|
12208 | !startsWith(context.source, '>') &&
|
12209 | !startsWith(context.source, '/>')) {
|
12210 | if (startsWith(context.source, '/')) {
|
12211 | emitError(context, 22 );
|
12212 | advanceBy(context, 1);
|
12213 | advanceSpaces(context);
|
12214 | continue;
|
12215 | }
|
12216 | if (type === 1 ) {
|
12217 | emitError(context, 3 );
|
12218 | }
|
12219 | const attr = parseAttribute(context, attributeNames);
|
12220 |
|
12221 |
|
12222 | if (attr.type === 6 &&
|
12223 | attr.value &&
|
12224 | attr.name === 'class') {
|
12225 | attr.value.content = attr.value.content.replace(/\s+/g, ' ').trim();
|
12226 | }
|
12227 | if (type === 0 ) {
|
12228 | props.push(attr);
|
12229 | }
|
12230 | if (/^[^\t\r\n\f />]/.test(context.source)) {
|
12231 | emitError(context, 15 );
|
12232 | }
|
12233 | advanceSpaces(context);
|
12234 | }
|
12235 | return props;
|
12236 | }
|
12237 | function parseAttribute(context, nameSet) {
|
12238 |
|
12239 | const start = getCursor(context);
|
12240 | const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
|
12241 | const name = match[0];
|
12242 | if (nameSet.has(name)) {
|
12243 | emitError(context, 2 );
|
12244 | }
|
12245 | nameSet.add(name);
|
12246 | if (name[0] === '=') {
|
12247 | emitError(context, 19 );
|
12248 | }
|
12249 | {
|
12250 | const pattern = /["'<]/g;
|
12251 | let m;
|
12252 | while ((m = pattern.exec(name))) {
|
12253 | emitError(context, 17 , m.index);
|
12254 | }
|
12255 | }
|
12256 | advanceBy(context, name.length);
|
12257 |
|
12258 | let value = undefined;
|
12259 | if (/^[\t\r\n\f ]*=/.test(context.source)) {
|
12260 | advanceSpaces(context);
|
12261 | advanceBy(context, 1);
|
12262 | advanceSpaces(context);
|
12263 | value = parseAttributeValue(context);
|
12264 | if (!value) {
|
12265 | emitError(context, 13 );
|
12266 | }
|
12267 | }
|
12268 | const loc = getSelection(context, start);
|
12269 | if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
|
12270 | const match = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(name);
|
12271 | let isPropShorthand = startsWith(name, '.');
|
12272 | let dirName = match[1] ||
|
12273 | (isPropShorthand || startsWith(name, ':')
|
12274 | ? 'bind'
|
12275 | : startsWith(name, '@')
|
12276 | ? 'on'
|
12277 | : 'slot');
|
12278 | let arg;
|
12279 | if (match[2]) {
|
12280 | const isSlot = dirName === 'slot';
|
12281 | const startOffset = name.lastIndexOf(match[2]);
|
12282 | const loc = getSelection(context, getNewPosition(context, start, startOffset), getNewPosition(context, start, startOffset + match[2].length + ((isSlot && match[3]) || '').length));
|
12283 | let content = match[2];
|
12284 | let isStatic = true;
|
12285 | if (content.startsWith('[')) {
|
12286 | isStatic = false;
|
12287 | if (!content.endsWith(']')) {
|
12288 | emitError(context, 27 );
|
12289 | content = content.substr(1);
|
12290 | }
|
12291 | else {
|
12292 | content = content.substr(1, content.length - 2);
|
12293 | }
|
12294 | }
|
12295 | else if (isSlot) {
|
12296 |
|
12297 |
|
12298 |
|
12299 | content += match[3] || '';
|
12300 | }
|
12301 | arg = {
|
12302 | type: 4 ,
|
12303 | content,
|
12304 | isStatic,
|
12305 | constType: isStatic
|
12306 | ? 3
|
12307 | : 0 ,
|
12308 | loc
|
12309 | };
|
12310 | }
|
12311 | if (value && value.isQuoted) {
|
12312 | const valueLoc = value.loc;
|
12313 | valueLoc.start.offset++;
|
12314 | valueLoc.start.column++;
|
12315 | valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
|
12316 | valueLoc.source = valueLoc.source.slice(1, -1);
|
12317 | }
|
12318 | const modifiers = match[3] ? match[3].substr(1).split('.') : [];
|
12319 | if (isPropShorthand)
|
12320 | modifiers.push('prop');
|
12321 | return {
|
12322 | type: 7 ,
|
12323 | name: dirName,
|
12324 | exp: value && {
|
12325 | type: 4 ,
|
12326 | content: value.content,
|
12327 | isStatic: false,
|
12328 |
|
12329 |
|
12330 | constType: 0 ,
|
12331 | loc: value.loc
|
12332 | },
|
12333 | arg,
|
12334 | modifiers,
|
12335 | loc
|
12336 | };
|
12337 | }
|
12338 |
|
12339 | if (!context.inVPre && startsWith(name, 'v-')) {
|
12340 | emitError(context, 26 );
|
12341 | }
|
12342 | return {
|
12343 | type: 6 ,
|
12344 | name,
|
12345 | value: value && {
|
12346 | type: 2 ,
|
12347 | content: value.content,
|
12348 | loc: value.loc
|
12349 | },
|
12350 | loc
|
12351 | };
|
12352 | }
|
12353 | function parseAttributeValue(context) {
|
12354 | const start = getCursor(context);
|
12355 | let content;
|
12356 | const quote = context.source[0];
|
12357 | const isQuoted = quote === `"` || quote === `'`;
|
12358 | if (isQuoted) {
|
12359 |
|
12360 | advanceBy(context, 1);
|
12361 | const endIndex = context.source.indexOf(quote);
|
12362 | if (endIndex === -1) {
|
12363 | content = parseTextData(context, context.source.length, 4 );
|
12364 | }
|
12365 | else {
|
12366 | content = parseTextData(context, endIndex, 4 );
|
12367 | advanceBy(context, 1);
|
12368 | }
|
12369 | }
|
12370 | else {
|
12371 |
|
12372 | const match = /^[^\t\r\n\f >]+/.exec(context.source);
|
12373 | if (!match) {
|
12374 | return undefined;
|
12375 | }
|
12376 | const unexpectedChars = /["'<=`]/g;
|
12377 | let m;
|
12378 | while ((m = unexpectedChars.exec(match[0]))) {
|
12379 | emitError(context, 18 , m.index);
|
12380 | }
|
12381 | content = parseTextData(context, match[0].length, 4 );
|
12382 | }
|
12383 | return { content, isQuoted, loc: getSelection(context, start) };
|
12384 | }
|
12385 | function parseInterpolation(context, mode) {
|
12386 | const [open, close] = context.options.delimiters;
|
12387 | const closeIndex = context.source.indexOf(close, open.length);
|
12388 | if (closeIndex === -1) {
|
12389 | emitError(context, 25 );
|
12390 | return undefined;
|
12391 | }
|
12392 | const start = getCursor(context);
|
12393 | advanceBy(context, open.length);
|
12394 | const innerStart = getCursor(context);
|
12395 | const innerEnd = getCursor(context);
|
12396 | const rawContentLength = closeIndex - open.length;
|
12397 | const rawContent = context.source.slice(0, rawContentLength);
|
12398 | const preTrimContent = parseTextData(context, rawContentLength, mode);
|
12399 | const content = preTrimContent.trim();
|
12400 | const startOffset = preTrimContent.indexOf(content);
|
12401 | if (startOffset > 0) {
|
12402 | advancePositionWithMutation(innerStart, rawContent, startOffset);
|
12403 | }
|
12404 | const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
|
12405 | advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
12406 | advanceBy(context, close.length);
|
12407 | return {
|
12408 | type: 5 ,
|
12409 | content: {
|
12410 | type: 4 ,
|
12411 | isStatic: false,
|
12412 |
|
12413 | constType: 0 ,
|
12414 | content,
|
12415 | loc: getSelection(context, innerStart, innerEnd)
|
12416 | },
|
12417 | loc: getSelection(context, start)
|
12418 | };
|
12419 | }
|
12420 | function parseText(context, mode) {
|
12421 | const endTokens = mode === 3 ? [']]>'] : ['<', context.options.delimiters[0]];
|
12422 | let endIndex = context.source.length;
|
12423 | for (let i = 0; i < endTokens.length; i++) {
|
12424 | const index = context.source.indexOf(endTokens[i], 1);
|
12425 | if (index !== -1 && endIndex > index) {
|
12426 | endIndex = index;
|
12427 | }
|
12428 | }
|
12429 | const start = getCursor(context);
|
12430 | const content = parseTextData(context, endIndex, mode);
|
12431 | return {
|
12432 | type: 2 ,
|
12433 | content,
|
12434 | loc: getSelection(context, start)
|
12435 | };
|
12436 | }
|
12437 |
|
12438 |
|
12439 |
|
12440 |
|
12441 | function parseTextData(context, length, mode) {
|
12442 | const rawText = context.source.slice(0, length);
|
12443 | advanceBy(context, length);
|
12444 | if (mode === 2 ||
|
12445 | mode === 3 ||
|
12446 | rawText.indexOf('&') === -1) {
|
12447 | return rawText;
|
12448 | }
|
12449 | else {
|
12450 |
|
12451 | return context.options.decodeEntities(rawText, mode === 4 );
|
12452 | }
|
12453 | }
|
12454 | function getCursor(context) {
|
12455 | const { column, line, offset } = context;
|
12456 | return { column, line, offset };
|
12457 | }
|
12458 | function getSelection(context, start, end) {
|
12459 | end = end || getCursor(context);
|
12460 | return {
|
12461 | start,
|
12462 | end,
|
12463 | source: context.originalSource.slice(start.offset, end.offset)
|
12464 | };
|
12465 | }
|
12466 | function last(xs) {
|
12467 | return xs[xs.length - 1];
|
12468 | }
|
12469 | function startsWith(source, searchString) {
|
12470 | return source.startsWith(searchString);
|
12471 | }
|
12472 | function advanceBy(context, numberOfCharacters) {
|
12473 | const { source } = context;
|
12474 | advancePositionWithMutation(context, source, numberOfCharacters);
|
12475 | context.source = source.slice(numberOfCharacters);
|
12476 | }
|
12477 | function advanceSpaces(context) {
|
12478 | const match = /^[\t\r\n\f ]+/.exec(context.source);
|
12479 | if (match) {
|
12480 | advanceBy(context, match[0].length);
|
12481 | }
|
12482 | }
|
12483 | function getNewPosition(context, start, numberOfCharacters) {
|
12484 | return advancePositionWithClone(start, context.originalSource.slice(start.offset, numberOfCharacters), numberOfCharacters);
|
12485 | }
|
12486 | function emitError(context, code, offset, loc = getCursor(context)) {
|
12487 | if (offset) {
|
12488 | loc.offset += offset;
|
12489 | loc.column += offset;
|
12490 | }
|
12491 | context.options.onError(createCompilerError(code, {
|
12492 | start: loc,
|
12493 | end: loc,
|
12494 | source: ''
|
12495 | }));
|
12496 | }
|
12497 | function isEnd(context, mode, ancestors) {
|
12498 | const s = context.source;
|
12499 | switch (mode) {
|
12500 | case 0 :
|
12501 | if (startsWith(s, '</')) {
|
12502 |
|
12503 | for (let i = ancestors.length - 1; i >= 0; --i) {
|
12504 | if (startsWithEndTagOpen(s, ancestors[i].tag)) {
|
12505 | return true;
|
12506 | }
|
12507 | }
|
12508 | }
|
12509 | break;
|
12510 | case 1 :
|
12511 | case 2 : {
|
12512 | const parent = last(ancestors);
|
12513 | if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
12514 | return true;
|
12515 | }
|
12516 | break;
|
12517 | }
|
12518 | case 3 :
|
12519 | if (startsWith(s, ']]>')) {
|
12520 | return true;
|
12521 | }
|
12522 | break;
|
12523 | }
|
12524 | return !s;
|
12525 | }
|
12526 | function startsWithEndTagOpen(source, tag) {
|
12527 | return (startsWith(source, '</') &&
|
12528 | source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
|
12529 | /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
|
12530 | }
|
12531 |
|
12532 | function hoistStatic(root, context) {
|
12533 | walk(root, context,
|
12534 |
|
12535 |
|
12536 | isSingleElementRoot(root, root.children[0]));
|
12537 | }
|
12538 | function isSingleElementRoot(root, child) {
|
12539 | const { children } = root;
|
12540 | return (children.length === 1 &&
|
12541 | child.type === 1 &&
|
12542 | !isSlotOutlet(child));
|
12543 | }
|
12544 | function walk(node, context, doNotHoistNode = false) {
|
12545 |
|
12546 |
|
12547 |
|
12548 |
|
12549 |
|
12550 |
|
12551 |
|
12552 |
|
12553 | let canStringify = true;
|
12554 | const { children } = node;
|
12555 | const originalCount = children.length;
|
12556 | let hoistedCount = 0;
|
12557 | for (let i = 0; i < children.length; i++) {
|
12558 | const child = children[i];
|
12559 |
|
12560 | if (child.type === 1 &&
|
12561 | child.tagType === 0 ) {
|
12562 | const constantType = doNotHoistNode
|
12563 | ? 0
|
12564 | : getConstantType(child, context);
|
12565 | if (constantType > 0 ) {
|
12566 | if (constantType < 3 ) {
|
12567 | canStringify = false;
|
12568 | }
|
12569 | if (constantType >= 2 ) {
|
12570 | child.codegenNode.patchFlag =
|
12571 | -1 + (` /* HOISTED */` );
|
12572 | child.codegenNode = context.hoist(child.codegenNode);
|
12573 | hoistedCount++;
|
12574 | continue;
|
12575 | }
|
12576 | }
|
12577 | else {
|
12578 |
|
12579 |
|
12580 | const codegenNode = child.codegenNode;
|
12581 | if (codegenNode.type === 13 ) {
|
12582 | const flag = getPatchFlag(codegenNode);
|
12583 | if ((!flag ||
|
12584 | flag === 512 ||
|
12585 | flag === 1 ) &&
|
12586 | getGeneratedPropsConstantType(child, context) >=
|
12587 | 2 ) {
|
12588 | const props = getNodeProps(child);
|
12589 | if (props) {
|
12590 | codegenNode.props = context.hoist(props);
|
12591 | }
|
12592 | }
|
12593 | if (codegenNode.dynamicProps) {
|
12594 | codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
|
12595 | }
|
12596 | }
|
12597 | }
|
12598 | }
|
12599 | else if (child.type === 12 ) {
|
12600 | const contentType = getConstantType(child.content, context);
|
12601 | if (contentType > 0) {
|
12602 | if (contentType < 3 ) {
|
12603 | canStringify = false;
|
12604 | }
|
12605 | if (contentType >= 2 ) {
|
12606 | child.codegenNode = context.hoist(child.codegenNode);
|
12607 | hoistedCount++;
|
12608 | }
|
12609 | }
|
12610 | }
|
12611 |
|
12612 | if (child.type === 1 ) {
|
12613 | const isComponent = child.tagType === 1 ;
|
12614 | if (isComponent) {
|
12615 | context.scopes.vSlot++;
|
12616 | }
|
12617 | walk(child, context);
|
12618 | if (isComponent) {
|
12619 | context.scopes.vSlot--;
|
12620 | }
|
12621 | }
|
12622 | else if (child.type === 11 ) {
|
12623 |
|
12624 | walk(child, context, child.children.length === 1);
|
12625 | }
|
12626 | else if (child.type === 9 ) {
|
12627 | for (let i = 0; i < child.branches.length; i++) {
|
12628 |
|
12629 | walk(child.branches[i], context, child.branches[i].children.length === 1);
|
12630 | }
|
12631 | }
|
12632 | }
|
12633 | if (canStringify && hoistedCount && context.transformHoist) {
|
12634 | context.transformHoist(children, context, node);
|
12635 | }
|
12636 |
|
12637 | if (hoistedCount &&
|
12638 | hoistedCount === originalCount &&
|
12639 | node.type === 1 &&
|
12640 | node.tagType === 0 &&
|
12641 | node.codegenNode &&
|
12642 | node.codegenNode.type === 13 &&
|
12643 | isArray(node.codegenNode.children)) {
|
12644 | node.codegenNode.children = context.hoist(createArrayExpression(node.codegenNode.children));
|
12645 | }
|
12646 | }
|
12647 | function getConstantType(node, context) {
|
12648 | const { constantCache } = context;
|
12649 | switch (node.type) {
|
12650 | case 1 :
|
12651 | if (node.tagType !== 0 ) {
|
12652 | return 0 ;
|
12653 | }
|
12654 | const cached = constantCache.get(node);
|
12655 | if (cached !== undefined) {
|
12656 | return cached;
|
12657 | }
|
12658 | const codegenNode = node.codegenNode;
|
12659 | if (codegenNode.type !== 13 ) {
|
12660 | return 0 ;
|
12661 | }
|
12662 | const flag = getPatchFlag(codegenNode);
|
12663 | if (!flag) {
|
12664 | let returnType = 3 ;
|
12665 |
|
12666 |
|
12667 |
|
12668 |
|
12669 |
|
12670 | const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
12671 | if (generatedPropsType === 0 ) {
|
12672 | constantCache.set(node, 0 );
|
12673 | return 0 ;
|
12674 | }
|
12675 | if (generatedPropsType < returnType) {
|
12676 | returnType = generatedPropsType;
|
12677 | }
|
12678 |
|
12679 | for (let i = 0; i < node.children.length; i++) {
|
12680 | const childType = getConstantType(node.children[i], context);
|
12681 | if (childType === 0 ) {
|
12682 | constantCache.set(node, 0 );
|
12683 | return 0 ;
|
12684 | }
|
12685 | if (childType < returnType) {
|
12686 | returnType = childType;
|
12687 | }
|
12688 | }
|
12689 |
|
12690 |
|
12691 |
|
12692 |
|
12693 | if (returnType > 1 ) {
|
12694 | for (let i = 0; i < node.props.length; i++) {
|
12695 | const p = node.props[i];
|
12696 | if (p.type === 7 && p.name === 'bind' && p.exp) {
|
12697 | const expType = getConstantType(p.exp, context);
|
12698 | if (expType === 0 ) {
|
12699 | constantCache.set(node, 0 );
|
12700 | return 0 ;
|
12701 | }
|
12702 | if (expType < returnType) {
|
12703 | returnType = expType;
|
12704 | }
|
12705 | }
|
12706 | }
|
12707 | }
|
12708 |
|
12709 |
|
12710 |
|
12711 | if (codegenNode.isBlock) {
|
12712 | context.removeHelper(OPEN_BLOCK);
|
12713 | context.removeHelper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent));
|
12714 | codegenNode.isBlock = false;
|
12715 | context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
|
12716 | }
|
12717 | constantCache.set(node, returnType);
|
12718 | return returnType;
|
12719 | }
|
12720 | else {
|
12721 | constantCache.set(node, 0 );
|
12722 | return 0 ;
|
12723 | }
|
12724 | case 2 :
|
12725 | case 3 :
|
12726 | return 3 ;
|
12727 | case 9 :
|
12728 | case 11 :
|
12729 | case 10 :
|
12730 | return 0 ;
|
12731 | case 5 :
|
12732 | case 12 :
|
12733 | return getConstantType(node.content, context);
|
12734 | case 4 :
|
12735 | return node.constType;
|
12736 | case 8 :
|
12737 | let returnType = 3 ;
|
12738 | for (let i = 0; i < node.children.length; i++) {
|
12739 | const child = node.children[i];
|
12740 | if (isString(child) || isSymbol(child)) {
|
12741 | continue;
|
12742 | }
|
12743 | const childType = getConstantType(child, context);
|
12744 | if (childType === 0 ) {
|
12745 | return 0 ;
|
12746 | }
|
12747 | else if (childType < returnType) {
|
12748 | returnType = childType;
|
12749 | }
|
12750 | }
|
12751 | return returnType;
|
12752 | default:
|
12753 | return 0 ;
|
12754 | }
|
12755 | }
|
12756 | const allowHoistedHelperSet = new Set([
|
12757 | NORMALIZE_CLASS,
|
12758 | NORMALIZE_STYLE,
|
12759 | NORMALIZE_PROPS,
|
12760 | GUARD_REACTIVE_PROPS
|
12761 | ]);
|
12762 | function getConstantTypeOfHelperCall(value, context) {
|
12763 | if (value.type === 14 &&
|
12764 | !isString(value.callee) &&
|
12765 | allowHoistedHelperSet.has(value.callee)) {
|
12766 | const arg = value.arguments[0];
|
12767 | if (arg.type === 4 ) {
|
12768 | return getConstantType(arg, context);
|
12769 | }
|
12770 | else if (arg.type === 14 ) {
|
12771 |
|
12772 | return getConstantTypeOfHelperCall(arg, context);
|
12773 | }
|
12774 | }
|
12775 | return 0 ;
|
12776 | }
|
12777 | function getGeneratedPropsConstantType(node, context) {
|
12778 | let returnType = 3 ;
|
12779 | const props = getNodeProps(node);
|
12780 | if (props && props.type === 15 ) {
|
12781 | const { properties } = props;
|
12782 | for (let i = 0; i < properties.length; i++) {
|
12783 | const { key, value } = properties[i];
|
12784 | const keyType = getConstantType(key, context);
|
12785 | if (keyType === 0 ) {
|
12786 | return keyType;
|
12787 | }
|
12788 | if (keyType < returnType) {
|
12789 | returnType = keyType;
|
12790 | }
|
12791 | let valueType;
|
12792 | if (value.type === 4 ) {
|
12793 | valueType = getConstantType(value, context);
|
12794 | }
|
12795 | else if (value.type === 14 ) {
|
12796 |
|
12797 |
|
12798 |
|
12799 | valueType = getConstantTypeOfHelperCall(value, context);
|
12800 | }
|
12801 | else {
|
12802 | valueType = 0 ;
|
12803 | }
|
12804 | if (valueType === 0 ) {
|
12805 | return valueType;
|
12806 | }
|
12807 | if (valueType < returnType) {
|
12808 | returnType = valueType;
|
12809 | }
|
12810 | }
|
12811 | }
|
12812 | return returnType;
|
12813 | }
|
12814 | function getNodeProps(node) {
|
12815 | const codegenNode = node.codegenNode;
|
12816 | if (codegenNode.type === 13 ) {
|
12817 | return codegenNode.props;
|
12818 | }
|
12819 | }
|
12820 | function getPatchFlag(node) {
|
12821 | const flag = node.patchFlag;
|
12822 | return flag ? parseInt(flag, 10) : undefined;
|
12823 | }
|
12824 |
|
12825 | function createTransformContext(root, { filename = '', prefixIdentifiers = false, hoistStatic = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
|
12826 | const nameMatch = filename.replace(/\?.*$/, '').match(/([^/\\]+)\.\w+$/);
|
12827 | const context = {
|
12828 |
|
12829 | selfName: nameMatch && capitalize(camelize(nameMatch[1])),
|
12830 | prefixIdentifiers,
|
12831 | hoistStatic,
|
12832 | cacheHandlers,
|
12833 | nodeTransforms,
|
12834 | directiveTransforms,
|
12835 | transformHoist,
|
12836 | isBuiltInComponent,
|
12837 | isCustomElement,
|
12838 | expressionPlugins,
|
12839 | scopeId,
|
12840 | slotted,
|
12841 | ssr,
|
12842 | inSSR,
|
12843 | ssrCssVars,
|
12844 | bindingMetadata,
|
12845 | inline,
|
12846 | isTS,
|
12847 | onError,
|
12848 | onWarn,
|
12849 | compatConfig,
|
12850 |
|
12851 | root,
|
12852 | helpers: new Map(),
|
12853 | components: new Set(),
|
12854 | directives: new Set(),
|
12855 | hoists: [],
|
12856 | imports: [],
|
12857 | constantCache: new Map(),
|
12858 | temps: 0,
|
12859 | cached: 0,
|
12860 | identifiers: Object.create(null),
|
12861 | scopes: {
|
12862 | vFor: 0,
|
12863 | vSlot: 0,
|
12864 | vPre: 0,
|
12865 | vOnce: 0
|
12866 | },
|
12867 | parent: null,
|
12868 | currentNode: root,
|
12869 | childIndex: 0,
|
12870 | inVOnce: false,
|
12871 |
|
12872 | helper(name) {
|
12873 | const count = context.helpers.get(name) || 0;
|
12874 | context.helpers.set(name, count + 1);
|
12875 | return name;
|
12876 | },
|
12877 | removeHelper(name) {
|
12878 | const count = context.helpers.get(name);
|
12879 | if (count) {
|
12880 | const currentCount = count - 1;
|
12881 | if (!currentCount) {
|
12882 | context.helpers.delete(name);
|
12883 | }
|
12884 | else {
|
12885 | context.helpers.set(name, currentCount);
|
12886 | }
|
12887 | }
|
12888 | },
|
12889 | helperString(name) {
|
12890 | return `_${helperNameMap[context.helper(name)]}`;
|
12891 | },
|
12892 | replaceNode(node) {
|
12893 |
|
12894 | {
|
12895 | if (!context.currentNode) {
|
12896 | throw new Error(`Node being replaced is already removed.`);
|
12897 | }
|
12898 | if (!context.parent) {
|
12899 | throw new Error(`Cannot replace root node.`);
|
12900 | }
|
12901 | }
|
12902 | context.parent.children[context.childIndex] = context.currentNode = node;
|
12903 | },
|
12904 | removeNode(node) {
|
12905 | if (!context.parent) {
|
12906 | throw new Error(`Cannot remove root node.`);
|
12907 | }
|
12908 | const list = context.parent.children;
|
12909 | const removalIndex = node
|
12910 | ? list.indexOf(node)
|
12911 | : context.currentNode
|
12912 | ? context.childIndex
|
12913 | : -1;
|
12914 |
|
12915 | if (removalIndex < 0) {
|
12916 | throw new Error(`node being removed is not a child of current parent`);
|
12917 | }
|
12918 | if (!node || node === context.currentNode) {
|
12919 |
|
12920 | context.currentNode = null;
|
12921 | context.onNodeRemoved();
|
12922 | }
|
12923 | else {
|
12924 |
|
12925 | if (context.childIndex > removalIndex) {
|
12926 | context.childIndex--;
|
12927 | context.onNodeRemoved();
|
12928 | }
|
12929 | }
|
12930 | context.parent.children.splice(removalIndex, 1);
|
12931 | },
|
12932 | onNodeRemoved: () => { },
|
12933 | addIdentifiers(exp) {
|
12934 | },
|
12935 | removeIdentifiers(exp) {
|
12936 | },
|
12937 | hoist(exp) {
|
12938 | if (isString(exp))
|
12939 | exp = createSimpleExpression(exp);
|
12940 | context.hoists.push(exp);
|
12941 | const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 );
|
12942 | identifier.hoisted = exp;
|
12943 | return identifier;
|
12944 | },
|
12945 | cache(exp, isVNode = false) {
|
12946 | return createCacheExpression(context.cached++, exp, isVNode);
|
12947 | }
|
12948 | };
|
12949 | return context;
|
12950 | }
|
12951 | function transform(root, options) {
|
12952 | const context = createTransformContext(root, options);
|
12953 | traverseNode(root, context);
|
12954 | if (options.hoistStatic) {
|
12955 | hoistStatic(root, context);
|
12956 | }
|
12957 | if (!options.ssr) {
|
12958 | createRootCodegen(root, context);
|
12959 | }
|
12960 |
|
12961 | root.helpers = [...context.helpers.keys()];
|
12962 | root.components = [...context.components];
|
12963 | root.directives = [...context.directives];
|
12964 | root.imports = context.imports;
|
12965 | root.hoists = context.hoists;
|
12966 | root.temps = context.temps;
|
12967 | root.cached = context.cached;
|
12968 | }
|
12969 | function createRootCodegen(root, context) {
|
12970 | const { helper } = context;
|
12971 | const { children } = root;
|
12972 | if (children.length === 1) {
|
12973 | const child = children[0];
|
12974 |
|
12975 | if (isSingleElementRoot(root, child) && child.codegenNode) {
|
12976 |
|
12977 |
|
12978 | const codegenNode = child.codegenNode;
|
12979 | if (codegenNode.type === 13 ) {
|
12980 | makeBlock(codegenNode, context);
|
12981 | }
|
12982 | root.codegenNode = codegenNode;
|
12983 | }
|
12984 | else {
|
12985 |
|
12986 |
|
12987 |
|
12988 | root.codegenNode = child;
|
12989 | }
|
12990 | }
|
12991 | else if (children.length > 1) {
|
12992 |
|
12993 | let patchFlag = 64 ;
|
12994 | let patchFlagText = PatchFlagNames[64 ];
|
12995 |
|
12996 |
|
12997 | if (children.filter(c => c.type !== 3 ).length === 1) {
|
12998 | patchFlag |= 2048 ;
|
12999 | patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
13000 | }
|
13001 | root.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, root.children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, undefined, false );
|
13002 | }
|
13003 | else ;
|
13004 | }
|
13005 | function traverseChildren(parent, context) {
|
13006 | let i = 0;
|
13007 | const nodeRemoved = () => {
|
13008 | i--;
|
13009 | };
|
13010 | for (; i < parent.children.length; i++) {
|
13011 | const child = parent.children[i];
|
13012 | if (isString(child))
|
13013 | continue;
|
13014 | context.parent = parent;
|
13015 | context.childIndex = i;
|
13016 | context.onNodeRemoved = nodeRemoved;
|
13017 | traverseNode(child, context);
|
13018 | }
|
13019 | }
|
13020 | function traverseNode(node, context) {
|
13021 | context.currentNode = node;
|
13022 |
|
13023 | const { nodeTransforms } = context;
|
13024 | const exitFns = [];
|
13025 | for (let i = 0; i < nodeTransforms.length; i++) {
|
13026 | const onExit = nodeTransforms[i](node, context);
|
13027 | if (onExit) {
|
13028 | if (isArray(onExit)) {
|
13029 | exitFns.push(...onExit);
|
13030 | }
|
13031 | else {
|
13032 | exitFns.push(onExit);
|
13033 | }
|
13034 | }
|
13035 | if (!context.currentNode) {
|
13036 |
|
13037 | return;
|
13038 | }
|
13039 | else {
|
13040 |
|
13041 | node = context.currentNode;
|
13042 | }
|
13043 | }
|
13044 | switch (node.type) {
|
13045 | case 3 :
|
13046 | if (!context.ssr) {
|
13047 |
|
13048 |
|
13049 | context.helper(CREATE_COMMENT);
|
13050 | }
|
13051 | break;
|
13052 | case 5 :
|
13053 |
|
13054 | if (!context.ssr) {
|
13055 | context.helper(TO_DISPLAY_STRING);
|
13056 | }
|
13057 | break;
|
13058 |
|
13059 | case 9 :
|
13060 | for (let i = 0; i < node.branches.length; i++) {
|
13061 | traverseNode(node.branches[i], context);
|
13062 | }
|
13063 | break;
|
13064 | case 10 :
|
13065 | case 11 :
|
13066 | case 1 :
|
13067 | case 0 :
|
13068 | traverseChildren(node, context);
|
13069 | break;
|
13070 | }
|
13071 |
|
13072 | context.currentNode = node;
|
13073 | let i = exitFns.length;
|
13074 | while (i--) {
|
13075 | exitFns[i]();
|
13076 | }
|
13077 | }
|
13078 | function createStructuralDirectiveTransform(name, fn) {
|
13079 | const matches = isString(name)
|
13080 | ? (n) => n === name
|
13081 | : (n) => name.test(n);
|
13082 | return (node, context) => {
|
13083 | if (node.type === 1 ) {
|
13084 | const { props } = node;
|
13085 |
|
13086 |
|
13087 | if (node.tagType === 3 && props.some(isVSlot)) {
|
13088 | return;
|
13089 | }
|
13090 | const exitFns = [];
|
13091 | for (let i = 0; i < props.length; i++) {
|
13092 | const prop = props[i];
|
13093 | if (prop.type === 7 && matches(prop.name)) {
|
13094 |
|
13095 |
|
13096 |
|
13097 | props.splice(i, 1);
|
13098 | i--;
|
13099 | const onExit = fn(node, prop, context);
|
13100 | if (onExit)
|
13101 | exitFns.push(onExit);
|
13102 | }
|
13103 | }
|
13104 | return exitFns;
|
13105 | }
|
13106 | };
|
13107 | }
|
13108 |
|
13109 | const PURE_ANNOTATION = `/*#__PURE__*/`;
|
13110 | function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssr = false, isTS = false, inSSR = false }) {
|
13111 | const context = {
|
13112 | mode,
|
13113 | prefixIdentifiers,
|
13114 | sourceMap,
|
13115 | filename,
|
13116 | scopeId,
|
13117 | optimizeImports,
|
13118 | runtimeGlobalName,
|
13119 | runtimeModuleName,
|
13120 | ssr,
|
13121 | isTS,
|
13122 | inSSR,
|
13123 | source: ast.loc.source,
|
13124 | code: ``,
|
13125 | column: 1,
|
13126 | line: 1,
|
13127 | offset: 0,
|
13128 | indentLevel: 0,
|
13129 | pure: false,
|
13130 | map: undefined,
|
13131 | helper(key) {
|
13132 | return `_${helperNameMap[key]}`;
|
13133 | },
|
13134 | push(code, node) {
|
13135 | context.code += code;
|
13136 | },
|
13137 | indent() {
|
13138 | newline(++context.indentLevel);
|
13139 | },
|
13140 | deindent(withoutNewLine = false) {
|
13141 | if (withoutNewLine) {
|
13142 | --context.indentLevel;
|
13143 | }
|
13144 | else {
|
13145 | newline(--context.indentLevel);
|
13146 | }
|
13147 | },
|
13148 | newline() {
|
13149 | newline(context.indentLevel);
|
13150 | }
|
13151 | };
|
13152 | function newline(n) {
|
13153 | context.push('\n' + ` `.repeat(n));
|
13154 | }
|
13155 | return context;
|
13156 | }
|
13157 | function generate(ast, options = {}) {
|
13158 | const context = createCodegenContext(ast, options);
|
13159 | if (options.onContextCreated)
|
13160 | options.onContextCreated(context);
|
13161 | const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
|
13162 | const hasHelpers = ast.helpers.length > 0;
|
13163 | const useWithBlock = !prefixIdentifiers && mode !== 'module';
|
13164 |
|
13165 |
|
13166 |
|
13167 | const preambleContext = context;
|
13168 | {
|
13169 | genFunctionPreamble(ast, preambleContext);
|
13170 | }
|
13171 |
|
13172 | const functionName = ssr ? `ssrRender` : `render`;
|
13173 | const args = ssr ? ['_ctx', '_push', '_parent', '_attrs'] : ['_ctx', '_cache'];
|
13174 | const signature = args.join(', ');
|
13175 | {
|
13176 | push(`function ${functionName}(${signature}) {`);
|
13177 | }
|
13178 | indent();
|
13179 | if (useWithBlock) {
|
13180 | push(`with (_ctx) {`);
|
13181 | indent();
|
13182 |
|
13183 |
|
13184 | if (hasHelpers) {
|
13185 | push(`const { ${ast.helpers
|
13186 | .map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
|
13187 | .join(', ')} } = _Vue`);
|
13188 | push(`\n`);
|
13189 | newline();
|
13190 | }
|
13191 | }
|
13192 |
|
13193 | if (ast.components.length) {
|
13194 | genAssets(ast.components, 'component', context);
|
13195 | if (ast.directives.length || ast.temps > 0) {
|
13196 | newline();
|
13197 | }
|
13198 | }
|
13199 | if (ast.directives.length) {
|
13200 | genAssets(ast.directives, 'directive', context);
|
13201 | if (ast.temps > 0) {
|
13202 | newline();
|
13203 | }
|
13204 | }
|
13205 | if (ast.temps > 0) {
|
13206 | push(`let `);
|
13207 | for (let i = 0; i < ast.temps; i++) {
|
13208 | push(`${i > 0 ? `, ` : ``}_temp${i}`);
|
13209 | }
|
13210 | }
|
13211 | if (ast.components.length || ast.directives.length || ast.temps) {
|
13212 | push(`\n`);
|
13213 | newline();
|
13214 | }
|
13215 |
|
13216 | if (!ssr) {
|
13217 | push(`return `);
|
13218 | }
|
13219 | if (ast.codegenNode) {
|
13220 | genNode(ast.codegenNode, context);
|
13221 | }
|
13222 | else {
|
13223 | push(`null`);
|
13224 | }
|
13225 | if (useWithBlock) {
|
13226 | deindent();
|
13227 | push(`}`);
|
13228 | }
|
13229 | deindent();
|
13230 | push(`}`);
|
13231 | return {
|
13232 | ast,
|
13233 | code: context.code,
|
13234 | preamble: ``,
|
13235 |
|
13236 | map: context.map ? context.map.toJSON() : undefined
|
13237 | };
|
13238 | }
|
13239 | function genFunctionPreamble(ast, context) {
|
13240 | const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName } = context;
|
13241 | const VueBinding = runtimeGlobalName;
|
13242 | const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
13243 |
|
13244 |
|
13245 |
|
13246 |
|
13247 | if (ast.helpers.length > 0) {
|
13248 | {
|
13249 |
|
13250 |
|
13251 | push(`const _Vue = ${VueBinding}\n`);
|
13252 |
|
13253 |
|
13254 |
|
13255 | if (ast.hoists.length) {
|
13256 | const staticHelpers = [
|
13257 | CREATE_VNODE,
|
13258 | CREATE_ELEMENT_VNODE,
|
13259 | CREATE_COMMENT,
|
13260 | CREATE_TEXT,
|
13261 | CREATE_STATIC
|
13262 | ]
|
13263 | .filter(helper => ast.helpers.includes(helper))
|
13264 | .map(aliasHelper)
|
13265 | .join(', ');
|
13266 | push(`const { ${staticHelpers} } = _Vue\n`);
|
13267 | }
|
13268 | }
|
13269 | }
|
13270 | genHoists(ast.hoists, context);
|
13271 | newline();
|
13272 | push(`return `);
|
13273 | }
|
13274 | function genAssets(assets, type, { helper, push, newline, isTS }) {
|
13275 | const resolver = helper(type === 'component'
|
13276 | ? RESOLVE_COMPONENT
|
13277 | : RESOLVE_DIRECTIVE);
|
13278 | for (let i = 0; i < assets.length; i++) {
|
13279 | let id = assets[i];
|
13280 |
|
13281 | const maybeSelfReference = id.endsWith('__self');
|
13282 | if (maybeSelfReference) {
|
13283 | id = id.slice(0, -6);
|
13284 | }
|
13285 | push(`const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`);
|
13286 | if (i < assets.length - 1) {
|
13287 | newline();
|
13288 | }
|
13289 | }
|
13290 | }
|
13291 | function genHoists(hoists, context) {
|
13292 | if (!hoists.length) {
|
13293 | return;
|
13294 | }
|
13295 | context.pure = true;
|
13296 | const { push, newline, helper, scopeId, mode } = context;
|
13297 | newline();
|
13298 | hoists.forEach((exp, i) => {
|
13299 | if (exp) {
|
13300 | push(`const _hoisted_${i + 1} = `);
|
13301 | genNode(exp, context);
|
13302 | newline();
|
13303 | }
|
13304 | });
|
13305 | context.pure = false;
|
13306 | }
|
13307 | function isText$1(n) {
|
13308 | return (isString(n) ||
|
13309 | n.type === 4 ||
|
13310 | n.type === 2 ||
|
13311 | n.type === 5 ||
|
13312 | n.type === 8 );
|
13313 | }
|
13314 | function genNodeListAsArray(nodes, context) {
|
13315 | const multilines = nodes.length > 3 ||
|
13316 | (nodes.some(n => isArray(n) || !isText$1(n)));
|
13317 | context.push(`[`);
|
13318 | multilines && context.indent();
|
13319 | genNodeList(nodes, context, multilines);
|
13320 | multilines && context.deindent();
|
13321 | context.push(`]`);
|
13322 | }
|
13323 | function genNodeList(nodes, context, multilines = false, comma = true) {
|
13324 | const { push, newline } = context;
|
13325 | for (let i = 0; i < nodes.length; i++) {
|
13326 | const node = nodes[i];
|
13327 | if (isString(node)) {
|
13328 | push(node);
|
13329 | }
|
13330 | else if (isArray(node)) {
|
13331 | genNodeListAsArray(node, context);
|
13332 | }
|
13333 | else {
|
13334 | genNode(node, context);
|
13335 | }
|
13336 | if (i < nodes.length - 1) {
|
13337 | if (multilines) {
|
13338 | comma && push(',');
|
13339 | newline();
|
13340 | }
|
13341 | else {
|
13342 | comma && push(', ');
|
13343 | }
|
13344 | }
|
13345 | }
|
13346 | }
|
13347 | function genNode(node, context) {
|
13348 | if (isString(node)) {
|
13349 | context.push(node);
|
13350 | return;
|
13351 | }
|
13352 | if (isSymbol(node)) {
|
13353 | context.push(context.helper(node));
|
13354 | return;
|
13355 | }
|
13356 | switch (node.type) {
|
13357 | case 1 :
|
13358 | case 9 :
|
13359 | case 11 :
|
13360 | assert(node.codegenNode != null, `Codegen node is missing for element/if/for node. ` +
|
13361 | `Apply appropriate transforms first.`);
|
13362 | genNode(node.codegenNode, context);
|
13363 | break;
|
13364 | case 2 :
|
13365 | genText(node, context);
|
13366 | break;
|
13367 | case 4 :
|
13368 | genExpression(node, context);
|
13369 | break;
|
13370 | case 5 :
|
13371 | genInterpolation(node, context);
|
13372 | break;
|
13373 | case 12 :
|
13374 | genNode(node.codegenNode, context);
|
13375 | break;
|
13376 | case 8 :
|
13377 | genCompoundExpression(node, context);
|
13378 | break;
|
13379 | case 3 :
|
13380 | genComment(node, context);
|
13381 | break;
|
13382 | case 13 :
|
13383 | genVNodeCall(node, context);
|
13384 | break;
|
13385 | case 14 :
|
13386 | genCallExpression(node, context);
|
13387 | break;
|
13388 | case 15 :
|
13389 | genObjectExpression(node, context);
|
13390 | break;
|
13391 | case 17 :
|
13392 | genArrayExpression(node, context);
|
13393 | break;
|
13394 | case 18 :
|
13395 | genFunctionExpression(node, context);
|
13396 | break;
|
13397 | case 19 :
|
13398 | genConditionalExpression(node, context);
|
13399 | break;
|
13400 | case 20 :
|
13401 | genCacheExpression(node, context);
|
13402 | break;
|
13403 | case 21 :
|
13404 | genNodeList(node.body, context, true, false);
|
13405 | break;
|
13406 |
|
13407 | case 22 :
|
13408 | break;
|
13409 | case 23 :
|
13410 | break;
|
13411 | case 24 :
|
13412 | break;
|
13413 | case 25 :
|
13414 | break;
|
13415 | case 26 :
|
13416 | break;
|
13417 |
|
13418 | case 10 :
|
13419 |
|
13420 | break;
|
13421 | default:
|
13422 | {
|
13423 | assert(false, `unhandled codegen node type: ${node.type}`);
|
13424 |
|
13425 | const exhaustiveCheck = node;
|
13426 | return exhaustiveCheck;
|
13427 | }
|
13428 | }
|
13429 | }
|
13430 | function genText(node, context) {
|
13431 | context.push(JSON.stringify(node.content), node);
|
13432 | }
|
13433 | function genExpression(node, context) {
|
13434 | const { content, isStatic } = node;
|
13435 | context.push(isStatic ? JSON.stringify(content) : content, node);
|
13436 | }
|
13437 | function genInterpolation(node, context) {
|
13438 | const { push, helper, pure } = context;
|
13439 | if (pure)
|
13440 | push(PURE_ANNOTATION);
|
13441 | push(`${helper(TO_DISPLAY_STRING)}(`);
|
13442 | genNode(node.content, context);
|
13443 | push(`)`);
|
13444 | }
|
13445 | function genCompoundExpression(node, context) {
|
13446 | for (let i = 0; i < node.children.length; i++) {
|
13447 | const child = node.children[i];
|
13448 | if (isString(child)) {
|
13449 | context.push(child);
|
13450 | }
|
13451 | else {
|
13452 | genNode(child, context);
|
13453 | }
|
13454 | }
|
13455 | }
|
13456 | function genExpressionAsPropertyKey(node, context) {
|
13457 | const { push } = context;
|
13458 | if (node.type === 8 ) {
|
13459 | push(`[`);
|
13460 | genCompoundExpression(node, context);
|
13461 | push(`]`);
|
13462 | }
|
13463 | else if (node.isStatic) {
|
13464 |
|
13465 | const text = isSimpleIdentifier(node.content)
|
13466 | ? node.content
|
13467 | : JSON.stringify(node.content);
|
13468 | push(text, node);
|
13469 | }
|
13470 | else {
|
13471 | push(`[${node.content}]`, node);
|
13472 | }
|
13473 | }
|
13474 | function genComment(node, context) {
|
13475 | const { push, helper, pure } = context;
|
13476 | if (pure) {
|
13477 | push(PURE_ANNOTATION);
|
13478 | }
|
13479 | push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
|
13480 | }
|
13481 | function genVNodeCall(node, context) {
|
13482 | const { push, helper, pure } = context;
|
13483 | const { tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent } = node;
|
13484 | if (directives) {
|
13485 | push(helper(WITH_DIRECTIVES) + `(`);
|
13486 | }
|
13487 | if (isBlock) {
|
13488 | push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
|
13489 | }
|
13490 | if (pure) {
|
13491 | push(PURE_ANNOTATION);
|
13492 | }
|
13493 | const callHelper = isBlock
|
13494 | ? getVNodeBlockHelper(context.inSSR, isComponent)
|
13495 | : getVNodeHelper(context.inSSR, isComponent);
|
13496 | push(helper(callHelper) + `(`, node);
|
13497 | genNodeList(genNullableArgs([tag, props, children, patchFlag, dynamicProps]), context);
|
13498 | push(`)`);
|
13499 | if (isBlock) {
|
13500 | push(`)`);
|
13501 | }
|
13502 | if (directives) {
|
13503 | push(`, `);
|
13504 | genNode(directives, context);
|
13505 | push(`)`);
|
13506 | }
|
13507 | }
|
13508 | function genNullableArgs(args) {
|
13509 | let i = args.length;
|
13510 | while (i--) {
|
13511 | if (args[i] != null)
|
13512 | break;
|
13513 | }
|
13514 | return args.slice(0, i + 1).map(arg => arg || `null`);
|
13515 | }
|
13516 |
|
13517 | function genCallExpression(node, context) {
|
13518 | const { push, helper, pure } = context;
|
13519 | const callee = isString(node.callee) ? node.callee : helper(node.callee);
|
13520 | if (pure) {
|
13521 | push(PURE_ANNOTATION);
|
13522 | }
|
13523 | push(callee + `(`, node);
|
13524 | genNodeList(node.arguments, context);
|
13525 | push(`)`);
|
13526 | }
|
13527 | function genObjectExpression(node, context) {
|
13528 | const { push, indent, deindent, newline } = context;
|
13529 | const { properties } = node;
|
13530 | if (!properties.length) {
|
13531 | push(`{}`, node);
|
13532 | return;
|
13533 | }
|
13534 | const multilines = properties.length > 1 ||
|
13535 | (properties.some(p => p.value.type !== 4 ));
|
13536 | push(multilines ? `{` : `{ `);
|
13537 | multilines && indent();
|
13538 | for (let i = 0; i < properties.length; i++) {
|
13539 | const { key, value } = properties[i];
|
13540 |
|
13541 | genExpressionAsPropertyKey(key, context);
|
13542 | push(`: `);
|
13543 |
|
13544 | genNode(value, context);
|
13545 | if (i < properties.length - 1) {
|
13546 |
|
13547 | push(`,`);
|
13548 | newline();
|
13549 | }
|
13550 | }
|
13551 | multilines && deindent();
|
13552 | push(multilines ? `}` : ` }`);
|
13553 | }
|
13554 | function genArrayExpression(node, context) {
|
13555 | genNodeListAsArray(node.elements, context);
|
13556 | }
|
13557 | function genFunctionExpression(node, context) {
|
13558 | const { push, indent, deindent } = context;
|
13559 | const { params, returns, body, newline, isSlot } = node;
|
13560 | if (isSlot) {
|
13561 |
|
13562 | push(`_${helperNameMap[WITH_CTX]}(`);
|
13563 | }
|
13564 | push(`(`, node);
|
13565 | if (isArray(params)) {
|
13566 | genNodeList(params, context);
|
13567 | }
|
13568 | else if (params) {
|
13569 | genNode(params, context);
|
13570 | }
|
13571 | push(`) => `);
|
13572 | if (newline || body) {
|
13573 | push(`{`);
|
13574 | indent();
|
13575 | }
|
13576 | if (returns) {
|
13577 | if (newline) {
|
13578 | push(`return `);
|
13579 | }
|
13580 | if (isArray(returns)) {
|
13581 | genNodeListAsArray(returns, context);
|
13582 | }
|
13583 | else {
|
13584 | genNode(returns, context);
|
13585 | }
|
13586 | }
|
13587 | else if (body) {
|
13588 | genNode(body, context);
|
13589 | }
|
13590 | if (newline || body) {
|
13591 | deindent();
|
13592 | push(`}`);
|
13593 | }
|
13594 | if (isSlot) {
|
13595 | push(`)`);
|
13596 | }
|
13597 | }
|
13598 | function genConditionalExpression(node, context) {
|
13599 | const { test, consequent, alternate, newline: needNewline } = node;
|
13600 | const { push, indent, deindent, newline } = context;
|
13601 | if (test.type === 4 ) {
|
13602 | const needsParens = !isSimpleIdentifier(test.content);
|
13603 | needsParens && push(`(`);
|
13604 | genExpression(test, context);
|
13605 | needsParens && push(`)`);
|
13606 | }
|
13607 | else {
|
13608 | push(`(`);
|
13609 | genNode(test, context);
|
13610 | push(`)`);
|
13611 | }
|
13612 | needNewline && indent();
|
13613 | context.indentLevel++;
|
13614 | needNewline || push(` `);
|
13615 | push(`? `);
|
13616 | genNode(consequent, context);
|
13617 | context.indentLevel--;
|
13618 | needNewline && newline();
|
13619 | needNewline || push(` `);
|
13620 | push(`: `);
|
13621 | const isNested = alternate.type === 19 ;
|
13622 | if (!isNested) {
|
13623 | context.indentLevel++;
|
13624 | }
|
13625 | genNode(alternate, context);
|
13626 | if (!isNested) {
|
13627 | context.indentLevel--;
|
13628 | }
|
13629 | needNewline && deindent(true );
|
13630 | }
|
13631 | function genCacheExpression(node, context) {
|
13632 | const { push, helper, indent, deindent, newline } = context;
|
13633 | push(`_cache[${node.index}] || (`);
|
13634 | if (node.isVNode) {
|
13635 | indent();
|
13636 | push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
|
13637 | newline();
|
13638 | }
|
13639 | push(`_cache[${node.index}] = `);
|
13640 | genNode(node.value, context);
|
13641 | if (node.isVNode) {
|
13642 | push(`,`);
|
13643 | newline();
|
13644 | push(`${helper(SET_BLOCK_TRACKING)}(1),`);
|
13645 | newline();
|
13646 | push(`_cache[${node.index}]`);
|
13647 | deindent();
|
13648 | }
|
13649 | push(`)`);
|
13650 | }
|
13651 |
|
13652 |
|
13653 |
|
13654 | const prohibitedKeywordRE = new RegExp('\\b' +
|
13655 | ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
|
13656 | 'super,throw,while,yield,delete,export,import,return,switch,default,' +
|
13657 | 'extends,finally,continue,debugger,function,arguments,typeof,void')
|
13658 | .split(',')
|
13659 | .join('\\b|\\b') +
|
13660 | '\\b');
|
13661 |
|
13662 | const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
|
13663 |
|
13664 |
|
13665 |
|
13666 |
|
13667 |
|
13668 | function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
|
13669 | const exp = node.content;
|
13670 |
|
13671 |
|
13672 | if (!exp.trim()) {
|
13673 | return;
|
13674 | }
|
13675 | try {
|
13676 | new Function(asRawStatements
|
13677 | ? ` ${exp} `
|
13678 | : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`);
|
13679 | }
|
13680 | catch (e) {
|
13681 | let message = e.message;
|
13682 | const keywordMatch = exp
|
13683 | .replace(stripStringRE, '')
|
13684 | .match(prohibitedKeywordRE);
|
13685 | if (keywordMatch) {
|
13686 | message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
|
13687 | }
|
13688 | context.onError(createCompilerError(44 , node.loc, undefined, message));
|
13689 | }
|
13690 | }
|
13691 |
|
13692 | const transformExpression = (node, context) => {
|
13693 | if (node.type === 5 ) {
|
13694 | node.content = processExpression(node.content, context);
|
13695 | }
|
13696 | else if (node.type === 1 ) {
|
13697 |
|
13698 | for (let i = 0; i < node.props.length; i++) {
|
13699 | const dir = node.props[i];
|
13700 |
|
13701 | if (dir.type === 7 && dir.name !== 'for') {
|
13702 | const exp = dir.exp;
|
13703 | const arg = dir.arg;
|
13704 |
|
13705 |
|
13706 | if (exp &&
|
13707 | exp.type === 4 &&
|
13708 | !(dir.name === 'on' && arg)) {
|
13709 | dir.exp = processExpression(exp, context,
|
13710 |
|
13711 | dir.name === 'slot');
|
13712 | }
|
13713 | if (arg && arg.type === 4 && !arg.isStatic) {
|
13714 | dir.arg = processExpression(arg, context);
|
13715 | }
|
13716 | }
|
13717 | }
|
13718 | }
|
13719 | };
|
13720 |
|
13721 |
|
13722 |
|
13723 | function processExpression(node, context,
|
13724 | // some expressions like v-slot props & v-for aliases should be parsed as
|
13725 | // function params
|
13726 | asParams = false,
|
13727 | // v-on handler values may contain multiple statements
|
13728 | asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
13729 | {
|
13730 | {
|
13731 |
|
13732 | validateBrowserExpression(node, context, asParams, asRawStatements);
|
13733 | }
|
13734 | return node;
|
13735 | }
|
13736 | }
|
13737 |
|
13738 | const transformIf = createStructuralDirectiveTransform(/^(if|else|else-if)$/, (node, dir, context) => {
|
13739 | return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
13740 |
|
13741 |
|
13742 |
|
13743 | const siblings = context.parent.children;
|
13744 | let i = siblings.indexOf(ifNode);
|
13745 | let key = 0;
|
13746 | while (i-- >= 0) {
|
13747 | const sibling = siblings[i];
|
13748 | if (sibling && sibling.type === 9 ) {
|
13749 | key += sibling.branches.length;
|
13750 | }
|
13751 | }
|
13752 |
|
13753 |
|
13754 | return () => {
|
13755 | if (isRoot) {
|
13756 | ifNode.codegenNode = createCodegenNodeForBranch(branch, key, context);
|
13757 | }
|
13758 | else {
|
13759 |
|
13760 | const parentCondition = getParentCondition(ifNode.codegenNode);
|
13761 | parentCondition.alternate = createCodegenNodeForBranch(branch, key + ifNode.branches.length - 1, context);
|
13762 | }
|
13763 | };
|
13764 | });
|
13765 | });
|
13766 |
|
13767 | function processIf(node, dir, context, processCodegen) {
|
13768 | if (dir.name !== 'else' &&
|
13769 | (!dir.exp || !dir.exp.content.trim())) {
|
13770 | const loc = dir.exp ? dir.exp.loc : node.loc;
|
13771 | context.onError(createCompilerError(28 , dir.loc));
|
13772 | dir.exp = createSimpleExpression(`true`, false, loc);
|
13773 | }
|
13774 | if (dir.exp) {
|
13775 | validateBrowserExpression(dir.exp, context);
|
13776 | }
|
13777 | if (dir.name === 'if') {
|
13778 | const branch = createIfBranch(node, dir);
|
13779 | const ifNode = {
|
13780 | type: 9 ,
|
13781 | loc: node.loc,
|
13782 | branches: [branch]
|
13783 | };
|
13784 | context.replaceNode(ifNode);
|
13785 | if (processCodegen) {
|
13786 | return processCodegen(ifNode, branch, true);
|
13787 | }
|
13788 | }
|
13789 | else {
|
13790 |
|
13791 | const siblings = context.parent.children;
|
13792 | const comments = [];
|
13793 | let i = siblings.indexOf(node);
|
13794 | while (i-- >= -1) {
|
13795 | const sibling = siblings[i];
|
13796 | if (sibling && sibling.type === 3 ) {
|
13797 | context.removeNode(sibling);
|
13798 | comments.unshift(sibling);
|
13799 | continue;
|
13800 | }
|
13801 | if (sibling &&
|
13802 | sibling.type === 2 &&
|
13803 | !sibling.content.trim().length) {
|
13804 | context.removeNode(sibling);
|
13805 | continue;
|
13806 | }
|
13807 | if (sibling && sibling.type === 9 ) {
|
13808 |
|
13809 | context.removeNode();
|
13810 | const branch = createIfBranch(node, dir);
|
13811 | if (comments.length &&
|
13812 |
|
13813 | !(context.parent &&
|
13814 | context.parent.type === 1 &&
|
13815 | isBuiltInType(context.parent.tag, 'transition'))) {
|
13816 | branch.children = [...comments, ...branch.children];
|
13817 | }
|
13818 |
|
13819 | {
|
13820 | const key = branch.userKey;
|
13821 | if (key) {
|
13822 | sibling.branches.forEach(({ userKey }) => {
|
13823 | if (isSameKey(userKey, key)) {
|
13824 | context.onError(createCompilerError(29 , branch.userKey.loc));
|
13825 | }
|
13826 | });
|
13827 | }
|
13828 | }
|
13829 | sibling.branches.push(branch);
|
13830 | const onExit = processCodegen && processCodegen(sibling, branch, false);
|
13831 |
|
13832 |
|
13833 | traverseNode(branch, context);
|
13834 |
|
13835 | if (onExit)
|
13836 | onExit();
|
13837 |
|
13838 |
|
13839 | context.currentNode = null;
|
13840 | }
|
13841 | else {
|
13842 | context.onError(createCompilerError(30 , node.loc));
|
13843 | }
|
13844 | break;
|
13845 | }
|
13846 | }
|
13847 | }
|
13848 | function createIfBranch(node, dir) {
|
13849 | return {
|
13850 | type: 10 ,
|
13851 | loc: node.loc,
|
13852 | condition: dir.name === 'else' ? undefined : dir.exp,
|
13853 | children: node.tagType === 3 && !findDir(node, 'for')
|
13854 | ? node.children
|
13855 | : [node],
|
13856 | userKey: findProp(node, `key`)
|
13857 | };
|
13858 | }
|
13859 | function createCodegenNodeForBranch(branch, keyIndex, context) {
|
13860 | if (branch.condition) {
|
13861 | return createConditionalExpression(branch.condition, createChildrenCodegenNode(branch, keyIndex, context),
|
13862 |
|
13863 |
|
13864 | createCallExpression(context.helper(CREATE_COMMENT), [
|
13865 | '"v-if"' ,
|
13866 | 'true'
|
13867 | ]));
|
13868 | }
|
13869 | else {
|
13870 | return createChildrenCodegenNode(branch, keyIndex, context);
|
13871 | }
|
13872 | }
|
13873 | function createChildrenCodegenNode(branch, keyIndex, context) {
|
13874 | const { helper } = context;
|
13875 | const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 ));
|
13876 | const { children } = branch;
|
13877 | const firstChild = children[0];
|
13878 | const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 ;
|
13879 | if (needFragmentWrapper) {
|
13880 | if (children.length === 1 && firstChild.type === 11 ) {
|
13881 |
|
13882 | const vnodeCall = firstChild.codegenNode;
|
13883 | injectProp(vnodeCall, keyProperty, context);
|
13884 | return vnodeCall;
|
13885 | }
|
13886 | else {
|
13887 | let patchFlag = 64 ;
|
13888 | let patchFlagText = PatchFlagNames[64 ];
|
13889 |
|
13890 |
|
13891 | if (children.filter(c => c.type !== 3 ).length === 1) {
|
13892 | patchFlag |= 2048 ;
|
13893 | patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
13894 | }
|
13895 | return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, false, false , branch.loc);
|
13896 | }
|
13897 | }
|
13898 | else {
|
13899 | const ret = firstChild.codegenNode;
|
13900 | const vnodeCall = getMemoedVNodeCall(ret);
|
13901 |
|
13902 | if (vnodeCall.type === 13 ) {
|
13903 | makeBlock(vnodeCall, context);
|
13904 | }
|
13905 |
|
13906 | injectProp(vnodeCall, keyProperty, context);
|
13907 | return ret;
|
13908 | }
|
13909 | }
|
13910 | function isSameKey(a, b) {
|
13911 | if (!a || a.type !== b.type) {
|
13912 | return false;
|
13913 | }
|
13914 | if (a.type === 6 ) {
|
13915 | if (a.value.content !== b.value.content) {
|
13916 | return false;
|
13917 | }
|
13918 | }
|
13919 | else {
|
13920 |
|
13921 | const exp = a.exp;
|
13922 | const branchExp = b.exp;
|
13923 | if (exp.type !== branchExp.type) {
|
13924 | return false;
|
13925 | }
|
13926 | if (exp.type !== 4 ||
|
13927 | exp.isStatic !== branchExp.isStatic ||
|
13928 | exp.content !== branchExp.content) {
|
13929 | return false;
|
13930 | }
|
13931 | }
|
13932 | return true;
|
13933 | }
|
13934 | function getParentCondition(node) {
|
13935 | while (true) {
|
13936 | if (node.type === 19 ) {
|
13937 | if (node.alternate.type === 19 ) {
|
13938 | node = node.alternate;
|
13939 | }
|
13940 | else {
|
13941 | return node;
|
13942 | }
|
13943 | }
|
13944 | else if (node.type === 20 ) {
|
13945 | node = node.value;
|
13946 | }
|
13947 | }
|
13948 | }
|
13949 |
|
13950 | const transformFor = createStructuralDirectiveTransform('for', (node, dir, context) => {
|
13951 | const { helper, removeHelper } = context;
|
13952 | return processFor(node, dir, context, forNode => {
|
13953 |
|
13954 |
|
13955 | const renderExp = createCallExpression(helper(RENDER_LIST), [
|
13956 | forNode.source
|
13957 | ]);
|
13958 | const memo = findDir(node, 'memo');
|
13959 | const keyProp = findProp(node, `key`);
|
13960 | const keyExp = keyProp &&
|
13961 | (keyProp.type === 6
|
13962 | ? createSimpleExpression(keyProp.value.content, true)
|
13963 | : keyProp.exp);
|
13964 | const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
13965 | const isStableFragment = forNode.source.type === 4 &&
|
13966 | forNode.source.constType > 0 ;
|
13967 | const fragmentFlag = isStableFragment
|
13968 | ? 64
|
13969 | : keyProp
|
13970 | ? 128
|
13971 | : 256 ;
|
13972 | forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, renderExp, fragmentFlag +
|
13973 | (` /* ${PatchFlagNames[fragmentFlag]} */` ), undefined, undefined, true , !isStableFragment , false , node.loc);
|
13974 | return () => {
|
13975 |
|
13976 | let childBlock;
|
13977 | const isTemplate = isTemplateNode(node);
|
13978 | const { children } = forNode;
|
13979 |
|
13980 | if (isTemplate) {
|
13981 | node.children.some(c => {
|
13982 | if (c.type === 1 ) {
|
13983 | const key = findProp(c, 'key');
|
13984 | if (key) {
|
13985 | context.onError(createCompilerError(33 , key.loc));
|
13986 | return true;
|
13987 | }
|
13988 | }
|
13989 | });
|
13990 | }
|
13991 | const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 ;
|
13992 | const slotOutlet = isSlotOutlet(node)
|
13993 | ? node
|
13994 | : isTemplate &&
|
13995 | node.children.length === 1 &&
|
13996 | isSlotOutlet(node.children[0])
|
13997 | ? node.children[0]
|
13998 | : null;
|
13999 | if (slotOutlet) {
|
14000 |
|
14001 | childBlock = slotOutlet.codegenNode;
|
14002 | if (isTemplate && keyProperty) {
|
14003 |
|
14004 |
|
14005 |
|
14006 | injectProp(childBlock, keyProperty, context);
|
14007 | }
|
14008 | }
|
14009 | else if (needFragmentWrapper) {
|
14010 |
|
14011 |
|
14012 | childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 +
|
14013 | (` /* ${PatchFlagNames[64 /* STABLE_FRAGMENT */]} */`
|
14014 | ), undefined, undefined, true, undefined, false );
|
14015 | }
|
14016 | else {
|
14017 |
|
14018 |
|
14019 | childBlock = children[0]
|
14020 | .codegenNode;
|
14021 | if (isTemplate && keyProperty) {
|
14022 | injectProp(childBlock, keyProperty, context);
|
14023 | }
|
14024 | if (childBlock.isBlock !== !isStableFragment) {
|
14025 | if (childBlock.isBlock) {
|
14026 |
|
14027 | removeHelper(OPEN_BLOCK);
|
14028 | removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
14029 | }
|
14030 | else {
|
14031 |
|
14032 | removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
14033 | }
|
14034 | }
|
14035 | childBlock.isBlock = !isStableFragment;
|
14036 | if (childBlock.isBlock) {
|
14037 | helper(OPEN_BLOCK);
|
14038 | helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
14039 | }
|
14040 | else {
|
14041 | helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
14042 | }
|
14043 | }
|
14044 | if (memo) {
|
14045 | const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [
|
14046 | createSimpleExpression(`_cached`)
|
14047 | ]));
|
14048 | loop.body = createBlockStatement([
|
14049 | createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
|
14050 | createCompoundExpression([
|
14051 | `if (_cached`,
|
14052 | ...(keyExp ? [` && _cached.key === `, keyExp] : []),
|
14053 | ` && ${context.helperString(IS_MEMO_SAME)}(_cached, _memo)) return _cached`
|
14054 | ]),
|
14055 | createCompoundExpression([`const _item = `, childBlock]),
|
14056 | createSimpleExpression(`_item.memo = _memo`),
|
14057 | createSimpleExpression(`return _item`)
|
14058 | ]);
|
14059 | renderExp.arguments.push(loop, createSimpleExpression(`_cache`), createSimpleExpression(String(context.cached++)));
|
14060 | }
|
14061 | else {
|
14062 | renderExp.arguments.push(createFunctionExpression(createForLoopParams(forNode.parseResult), childBlock, true ));
|
14063 | }
|
14064 | };
|
14065 | });
|
14066 | });
|
14067 |
|
14068 | function processFor(node, dir, context, processCodegen) {
|
14069 | if (!dir.exp) {
|
14070 | context.onError(createCompilerError(31 , dir.loc));
|
14071 | return;
|
14072 | }
|
14073 | const parseResult = parseForExpression(
|
14074 |
|
14075 |
|
14076 | dir.exp, context);
|
14077 | if (!parseResult) {
|
14078 | context.onError(createCompilerError(32 , dir.loc));
|
14079 | return;
|
14080 | }
|
14081 | const { addIdentifiers, removeIdentifiers, scopes } = context;
|
14082 | const { source, value, key, index } = parseResult;
|
14083 | const forNode = {
|
14084 | type: 11 ,
|
14085 | loc: dir.loc,
|
14086 | source,
|
14087 | valueAlias: value,
|
14088 | keyAlias: key,
|
14089 | objectIndexAlias: index,
|
14090 | parseResult,
|
14091 | children: isTemplateNode(node) ? node.children : [node]
|
14092 | };
|
14093 | context.replaceNode(forNode);
|
14094 |
|
14095 | scopes.vFor++;
|
14096 | const onExit = processCodegen && processCodegen(forNode);
|
14097 | return () => {
|
14098 | scopes.vFor--;
|
14099 | if (onExit)
|
14100 | onExit();
|
14101 | };
|
14102 | }
|
14103 | const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
14104 |
|
14105 |
|
14106 | const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
14107 | const stripParensRE = /^\(|\)$/g;
|
14108 | function parseForExpression(input, context) {
|
14109 | const loc = input.loc;
|
14110 | const exp = input.content;
|
14111 | const inMatch = exp.match(forAliasRE);
|
14112 | if (!inMatch)
|
14113 | return;
|
14114 | const [, LHS, RHS] = inMatch;
|
14115 | const result = {
|
14116 | source: createAliasExpression(loc, RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
14117 | value: undefined,
|
14118 | key: undefined,
|
14119 | index: undefined
|
14120 | };
|
14121 | {
|
14122 | validateBrowserExpression(result.source, context);
|
14123 | }
|
14124 | let valueContent = LHS.trim().replace(stripParensRE, '').trim();
|
14125 | const trimmedOffset = LHS.indexOf(valueContent);
|
14126 | const iteratorMatch = valueContent.match(forIteratorRE);
|
14127 | if (iteratorMatch) {
|
14128 | valueContent = valueContent.replace(forIteratorRE, '').trim();
|
14129 | const keyContent = iteratorMatch[1].trim();
|
14130 | let keyOffset;
|
14131 | if (keyContent) {
|
14132 | keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
14133 | result.key = createAliasExpression(loc, keyContent, keyOffset);
|
14134 | {
|
14135 | validateBrowserExpression(result.key, context, true);
|
14136 | }
|
14137 | }
|
14138 | if (iteratorMatch[2]) {
|
14139 | const indexContent = iteratorMatch[2].trim();
|
14140 | if (indexContent) {
|
14141 | result.index = createAliasExpression(loc, indexContent, exp.indexOf(indexContent, result.key
|
14142 | ? keyOffset + keyContent.length
|
14143 | : trimmedOffset + valueContent.length));
|
14144 | {
|
14145 | validateBrowserExpression(result.index, context, true);
|
14146 | }
|
14147 | }
|
14148 | }
|
14149 | }
|
14150 | if (valueContent) {
|
14151 | result.value = createAliasExpression(loc, valueContent, trimmedOffset);
|
14152 | {
|
14153 | validateBrowserExpression(result.value, context, true);
|
14154 | }
|
14155 | }
|
14156 | return result;
|
14157 | }
|
14158 | function createAliasExpression(range, content, offset) {
|
14159 | return createSimpleExpression(content, false, getInnerRange(range, offset, content.length));
|
14160 | }
|
14161 | function createForLoopParams({ value, key, index }, memoArgs = []) {
|
14162 | return createParamsList([value, key, index, ...memoArgs]);
|
14163 | }
|
14164 | function createParamsList(args) {
|
14165 | let i = args.length;
|
14166 | while (i--) {
|
14167 | if (args[i])
|
14168 | break;
|
14169 | }
|
14170 | return args
|
14171 | .slice(0, i + 1)
|
14172 | .map((arg, i) => arg || createSimpleExpression(`_`.repeat(i + 1), false));
|
14173 | }
|
14174 |
|
14175 | const defaultFallback = createSimpleExpression(`undefined`, false);
|
14176 |
|
14177 |
|
14178 |
|
14179 |
|
14180 |
|
14181 |
|
14182 |
|
14183 | const trackSlotScopes = (node, context) => {
|
14184 | if (node.type === 1 &&
|
14185 | (node.tagType === 1 ||
|
14186 | node.tagType === 3 )) {
|
14187 |
|
14188 |
|
14189 | const vSlot = findDir(node, 'slot');
|
14190 | if (vSlot) {
|
14191 | vSlot.exp;
|
14192 | context.scopes.vSlot++;
|
14193 | return () => {
|
14194 | context.scopes.vSlot--;
|
14195 | };
|
14196 | }
|
14197 | }
|
14198 | };
|
14199 | const buildClientSlotFn = (props, children, loc) => createFunctionExpression(props, children, false , true , children.length ? children[0].loc : loc);
|
14200 |
|
14201 |
|
14202 | function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
14203 | context.helper(WITH_CTX);
|
14204 | const { children, loc } = node;
|
14205 | const slotsProperties = [];
|
14206 | const dynamicSlots = [];
|
14207 |
|
14208 |
|
14209 | let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
|
14210 |
|
14211 |
|
14212 | const onComponentSlot = findDir(node, 'slot', true);
|
14213 | if (onComponentSlot) {
|
14214 | const { arg, exp } = onComponentSlot;
|
14215 | if (arg && !isStaticExp(arg)) {
|
14216 | hasDynamicSlots = true;
|
14217 | }
|
14218 | slotsProperties.push(createObjectProperty(arg || createSimpleExpression('default', true), buildSlotFn(exp, children, loc)));
|
14219 | }
|
14220 |
|
14221 |
|
14222 | let hasTemplateSlots = false;
|
14223 | let hasNamedDefaultSlot = false;
|
14224 | const implicitDefaultChildren = [];
|
14225 | const seenSlotNames = new Set();
|
14226 | for (let i = 0; i < children.length; i++) {
|
14227 | const slotElement = children[i];
|
14228 | let slotDir;
|
14229 | if (!isTemplateNode(slotElement) ||
|
14230 | !(slotDir = findDir(slotElement, 'slot', true))) {
|
14231 |
|
14232 | if (slotElement.type !== 3 ) {
|
14233 | implicitDefaultChildren.push(slotElement);
|
14234 | }
|
14235 | continue;
|
14236 | }
|
14237 | if (onComponentSlot) {
|
14238 |
|
14239 | context.onError(createCompilerError(37 , slotDir.loc));
|
14240 | break;
|
14241 | }
|
14242 | hasTemplateSlots = true;
|
14243 | const { children: slotChildren, loc: slotLoc } = slotElement;
|
14244 | const { arg: slotName = createSimpleExpression(`default`, true), exp: slotProps, loc: dirLoc } = slotDir;
|
14245 |
|
14246 | let staticSlotName;
|
14247 | if (isStaticExp(slotName)) {
|
14248 | staticSlotName = slotName ? slotName.content : `default`;
|
14249 | }
|
14250 | else {
|
14251 | hasDynamicSlots = true;
|
14252 | }
|
14253 | const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
|
14254 |
|
14255 | let vIf;
|
14256 | let vElse;
|
14257 | let vFor;
|
14258 | if ((vIf = findDir(slotElement, 'if'))) {
|
14259 | hasDynamicSlots = true;
|
14260 | dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback));
|
14261 | }
|
14262 | else if ((vElse = findDir(slotElement, /^else(-if)?$/, true ))) {
|
14263 |
|
14264 | let j = i;
|
14265 | let prev;
|
14266 | while (j--) {
|
14267 | prev = children[j];
|
14268 | if (prev.type !== 3 ) {
|
14269 | break;
|
14270 | }
|
14271 | }
|
14272 | if (prev && isTemplateNode(prev) && findDir(prev, 'if')) {
|
14273 |
|
14274 | children.splice(i, 1);
|
14275 | i--;
|
14276 |
|
14277 | let conditional = dynamicSlots[dynamicSlots.length - 1];
|
14278 | while (conditional.alternate.type === 19 ) {
|
14279 | conditional = conditional.alternate;
|
14280 | }
|
14281 | conditional.alternate = vElse.exp
|
14282 | ? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback)
|
14283 | : buildDynamicSlot(slotName, slotFunction);
|
14284 | }
|
14285 | else {
|
14286 | context.onError(createCompilerError(30 , vElse.loc));
|
14287 | }
|
14288 | }
|
14289 | else if ((vFor = findDir(slotElement, 'for'))) {
|
14290 | hasDynamicSlots = true;
|
14291 | const parseResult = vFor.parseResult ||
|
14292 | parseForExpression(vFor.exp, context);
|
14293 | if (parseResult) {
|
14294 |
|
14295 |
|
14296 | dynamicSlots.push(createCallExpression(context.helper(RENDER_LIST), [
|
14297 | parseResult.source,
|
14298 | createFunctionExpression(createForLoopParams(parseResult), buildDynamicSlot(slotName, slotFunction), true )
|
14299 | ]));
|
14300 | }
|
14301 | else {
|
14302 | context.onError(createCompilerError(32 , vFor.loc));
|
14303 | }
|
14304 | }
|
14305 | else {
|
14306 |
|
14307 | if (staticSlotName) {
|
14308 | if (seenSlotNames.has(staticSlotName)) {
|
14309 | context.onError(createCompilerError(38 , dirLoc));
|
14310 | continue;
|
14311 | }
|
14312 | seenSlotNames.add(staticSlotName);
|
14313 | if (staticSlotName === 'default') {
|
14314 | hasNamedDefaultSlot = true;
|
14315 | }
|
14316 | }
|
14317 | slotsProperties.push(createObjectProperty(slotName, slotFunction));
|
14318 | }
|
14319 | }
|
14320 | if (!onComponentSlot) {
|
14321 | const buildDefaultSlotProperty = (props, children) => {
|
14322 | const fn = buildSlotFn(props, children, loc);
|
14323 | return createObjectProperty(`default`, fn);
|
14324 | };
|
14325 | if (!hasTemplateSlots) {
|
14326 |
|
14327 | slotsProperties.push(buildDefaultSlotProperty(undefined, children));
|
14328 | }
|
14329 | else if (implicitDefaultChildren.length &&
|
14330 |
|
14331 |
|
14332 |
|
14333 | implicitDefaultChildren.some(node => isNonWhitespaceContent(node))) {
|
14334 |
|
14335 | if (hasNamedDefaultSlot) {
|
14336 | context.onError(createCompilerError(39 , implicitDefaultChildren[0].loc));
|
14337 | }
|
14338 | else {
|
14339 | slotsProperties.push(buildDefaultSlotProperty(undefined, implicitDefaultChildren));
|
14340 | }
|
14341 | }
|
14342 | }
|
14343 | const slotFlag = hasDynamicSlots
|
14344 | ? 2
|
14345 | : hasForwardedSlots(node.children)
|
14346 | ? 3
|
14347 | : 1 ;
|
14348 | let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`,
|
14349 |
|
14350 |
|
14351 | createSimpleExpression(slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ), false))), loc);
|
14352 | if (dynamicSlots.length) {
|
14353 | slots = createCallExpression(context.helper(CREATE_SLOTS), [
|
14354 | slots,
|
14355 | createArrayExpression(dynamicSlots)
|
14356 | ]);
|
14357 | }
|
14358 | return {
|
14359 | slots,
|
14360 | hasDynamicSlots
|
14361 | };
|
14362 | }
|
14363 | function buildDynamicSlot(name, fn) {
|
14364 | return createObjectExpression([
|
14365 | createObjectProperty(`name`, name),
|
14366 | createObjectProperty(`fn`, fn)
|
14367 | ]);
|
14368 | }
|
14369 | function hasForwardedSlots(children) {
|
14370 | for (let i = 0; i < children.length; i++) {
|
14371 | const child = children[i];
|
14372 | switch (child.type) {
|
14373 | case 1 :
|
14374 | if (child.tagType === 2 ||
|
14375 | hasForwardedSlots(child.children)) {
|
14376 | return true;
|
14377 | }
|
14378 | break;
|
14379 | case 9 :
|
14380 | if (hasForwardedSlots(child.branches))
|
14381 | return true;
|
14382 | break;
|
14383 | case 10 :
|
14384 | case 11 :
|
14385 | if (hasForwardedSlots(child.children))
|
14386 | return true;
|
14387 | break;
|
14388 | }
|
14389 | }
|
14390 | return false;
|
14391 | }
|
14392 | function isNonWhitespaceContent(node) {
|
14393 | if (node.type !== 2 && node.type !== 12 )
|
14394 | return true;
|
14395 | return node.type === 2
|
14396 | ? !!node.content.trim()
|
14397 | : isNonWhitespaceContent(node.content);
|
14398 | }
|
14399 |
|
14400 |
|
14401 |
|
14402 | const directiveImportMap = new WeakMap();
|
14403 |
|
14404 | const transformElement = (node, context) => {
|
14405 |
|
14406 |
|
14407 | return function postTransformElement() {
|
14408 | node = context.currentNode;
|
14409 | if (!(node.type === 1 &&
|
14410 | (node.tagType === 0 ||
|
14411 | node.tagType === 1 ))) {
|
14412 | return;
|
14413 | }
|
14414 | const { tag, props } = node;
|
14415 | const isComponent = node.tagType === 1 ;
|
14416 |
|
14417 |
|
14418 | let vnodeTag = isComponent
|
14419 | ? resolveComponentType(node, context)
|
14420 | : `"${tag}"`;
|
14421 | const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
|
14422 | let vnodeProps;
|
14423 | let vnodeChildren;
|
14424 | let vnodePatchFlag;
|
14425 | let patchFlag = 0;
|
14426 | let vnodeDynamicProps;
|
14427 | let dynamicPropNames;
|
14428 | let vnodeDirectives;
|
14429 | let shouldUseBlock =
|
14430 |
|
14431 | isDynamicComponent ||
|
14432 | vnodeTag === TELEPORT ||
|
14433 | vnodeTag === SUSPENSE ||
|
14434 | (!isComponent &&
|
14435 |
|
14436 |
|
14437 |
|
14438 |
|
14439 | (tag === 'svg' ||
|
14440 | tag === 'foreignObject' ||
|
14441 |
|
14442 | findProp(node, 'key', true)));
|
14443 |
|
14444 | if (props.length > 0) {
|
14445 | const propsBuildResult = buildProps(node, context);
|
14446 | vnodeProps = propsBuildResult.props;
|
14447 | patchFlag = propsBuildResult.patchFlag;
|
14448 | dynamicPropNames = propsBuildResult.dynamicPropNames;
|
14449 | const directives = propsBuildResult.directives;
|
14450 | vnodeDirectives =
|
14451 | directives && directives.length
|
14452 | ? createArrayExpression(directives.map(dir => buildDirectiveArgs(dir, context)))
|
14453 | : undefined;
|
14454 | }
|
14455 |
|
14456 | if (node.children.length > 0) {
|
14457 | if (vnodeTag === KEEP_ALIVE) {
|
14458 |
|
14459 |
|
14460 |
|
14461 |
|
14462 |
|
14463 |
|
14464 | shouldUseBlock = true;
|
14465 |
|
14466 | patchFlag |= 1024 ;
|
14467 | if (node.children.length > 1) {
|
14468 | context.onError(createCompilerError(45 , {
|
14469 | start: node.children[0].loc.start,
|
14470 | end: node.children[node.children.length - 1].loc.end,
|
14471 | source: ''
|
14472 | }));
|
14473 | }
|
14474 | }
|
14475 | const shouldBuildAsSlots = isComponent &&
|
14476 |
|
14477 | vnodeTag !== TELEPORT &&
|
14478 |
|
14479 | vnodeTag !== KEEP_ALIVE;
|
14480 | if (shouldBuildAsSlots) {
|
14481 | const { slots, hasDynamicSlots } = buildSlots(node, context);
|
14482 | vnodeChildren = slots;
|
14483 | if (hasDynamicSlots) {
|
14484 | patchFlag |= 1024 ;
|
14485 | }
|
14486 | }
|
14487 | else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
|
14488 | const child = node.children[0];
|
14489 | const type = child.type;
|
14490 |
|
14491 | const hasDynamicTextChild = type === 5 ||
|
14492 | type === 8 ;
|
14493 | if (hasDynamicTextChild &&
|
14494 | getConstantType(child, context) === 0 ) {
|
14495 | patchFlag |= 1 ;
|
14496 | }
|
14497 |
|
14498 |
|
14499 | if (hasDynamicTextChild || type === 2 ) {
|
14500 | vnodeChildren = child;
|
14501 | }
|
14502 | else {
|
14503 | vnodeChildren = node.children;
|
14504 | }
|
14505 | }
|
14506 | else {
|
14507 | vnodeChildren = node.children;
|
14508 | }
|
14509 | }
|
14510 |
|
14511 | if (patchFlag !== 0) {
|
14512 | {
|
14513 | if (patchFlag < 0) {
|
14514 |
|
14515 | vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
|
14516 | }
|
14517 | else {
|
14518 |
|
14519 | const flagNames = Object.keys(PatchFlagNames)
|
14520 | .map(Number)
|
14521 | .filter(n => n > 0 && patchFlag & n)
|
14522 | .map(n => PatchFlagNames[n])
|
14523 | .join(`, `);
|
14524 | vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
|
14525 | }
|
14526 | }
|
14527 | if (dynamicPropNames && dynamicPropNames.length) {
|
14528 | vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
|
14529 | }
|
14530 | }
|
14531 | node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, vnodePatchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false , isComponent, node.loc);
|
14532 | };
|
14533 | };
|
14534 | function resolveComponentType(node, context, ssr = false) {
|
14535 | let { tag } = node;
|
14536 |
|
14537 | const isExplicitDynamic = isComponentTag(tag);
|
14538 | const isProp = findProp(node, 'is');
|
14539 | if (isProp) {
|
14540 | if (isExplicitDynamic ||
|
14541 | (false )) {
|
14542 | const exp = isProp.type === 6
|
14543 | ? isProp.value && createSimpleExpression(isProp.value.content, true)
|
14544 | : isProp.exp;
|
14545 | if (exp) {
|
14546 | return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
14547 | exp
|
14548 | ]);
|
14549 | }
|
14550 | }
|
14551 | else if (isProp.type === 6 &&
|
14552 | isProp.value.content.startsWith('vue:')) {
|
14553 |
|
14554 |
|
14555 |
|
14556 |
|
14557 | tag = isProp.value.content.slice(4);
|
14558 | }
|
14559 | }
|
14560 |
|
14561 | const isDir = !isExplicitDynamic && findDir(node, 'is');
|
14562 | if (isDir && isDir.exp) {
|
14563 | return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
14564 | isDir.exp
|
14565 | ]);
|
14566 | }
|
14567 |
|
14568 | const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
14569 | if (builtIn) {
|
14570 |
|
14571 |
|
14572 | if (!ssr)
|
14573 | context.helper(builtIn);
|
14574 | return builtIn;
|
14575 | }
|
14576 |
|
14577 | context.helper(RESOLVE_COMPONENT);
|
14578 | context.components.add(tag);
|
14579 | return toValidAssetId(tag, `component`);
|
14580 | }
|
14581 | function buildProps(node, context, props = node.props, ssr = false) {
|
14582 | const { tag, loc: elementLoc } = node;
|
14583 | const isComponent = node.tagType === 1 ;
|
14584 | let properties = [];
|
14585 | const mergeArgs = [];
|
14586 | const runtimeDirectives = [];
|
14587 |
|
14588 | let patchFlag = 0;
|
14589 | let hasRef = false;
|
14590 | let hasClassBinding = false;
|
14591 | let hasStyleBinding = false;
|
14592 | let hasHydrationEventBinding = false;
|
14593 | let hasDynamicKeys = false;
|
14594 | let hasVnodeHook = false;
|
14595 | const dynamicPropNames = [];
|
14596 | const analyzePatchFlag = ({ key, value }) => {
|
14597 | if (isStaticExp(key)) {
|
14598 | const name = key.content;
|
14599 | const isEventHandler = isOn(name);
|
14600 | if (!isComponent &&
|
14601 | isEventHandler &&
|
14602 |
|
14603 |
|
14604 | name.toLowerCase() !== 'onclick' &&
|
14605 |
|
14606 | name !== 'onUpdate:modelValue' &&
|
14607 |
|
14608 | !isReservedProp(name)) {
|
14609 | hasHydrationEventBinding = true;
|
14610 | }
|
14611 | if (isEventHandler && isReservedProp(name)) {
|
14612 | hasVnodeHook = true;
|
14613 | }
|
14614 | if (value.type === 20 ||
|
14615 | ((value.type === 4 ||
|
14616 | value.type === 8 ) &&
|
14617 | getConstantType(value, context) > 0)) {
|
14618 |
|
14619 | return;
|
14620 | }
|
14621 | if (name === 'ref') {
|
14622 | hasRef = true;
|
14623 | }
|
14624 | else if (name === 'class') {
|
14625 | hasClassBinding = true;
|
14626 | }
|
14627 | else if (name === 'style') {
|
14628 | hasStyleBinding = true;
|
14629 | }
|
14630 | else if (name !== 'key' && !dynamicPropNames.includes(name)) {
|
14631 | dynamicPropNames.push(name);
|
14632 | }
|
14633 |
|
14634 | if (isComponent &&
|
14635 | (name === 'class' || name === 'style') &&
|
14636 | !dynamicPropNames.includes(name)) {
|
14637 | dynamicPropNames.push(name);
|
14638 | }
|
14639 | }
|
14640 | else {
|
14641 | hasDynamicKeys = true;
|
14642 | }
|
14643 | };
|
14644 | for (let i = 0; i < props.length; i++) {
|
14645 |
|
14646 | const prop = props[i];
|
14647 | if (prop.type === 6 ) {
|
14648 | const { loc, name, value } = prop;
|
14649 | let valueNode = createSimpleExpression(value ? value.content : '', true, value ? value.loc : loc);
|
14650 | if (name === 'ref') {
|
14651 | hasRef = true;
|
14652 | }
|
14653 |
|
14654 | if (name === 'is' &&
|
14655 | (isComponentTag(tag) ||
|
14656 | (value && value.content.startsWith('vue:')) ||
|
14657 | (false ))) {
|
14658 | continue;
|
14659 | }
|
14660 | properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), valueNode));
|
14661 | }
|
14662 | else {
|
14663 |
|
14664 | const { name, arg, exp, loc } = prop;
|
14665 | const isVBind = name === 'bind';
|
14666 | const isVOn = name === 'on';
|
14667 |
|
14668 | if (name === 'slot') {
|
14669 | if (!isComponent) {
|
14670 | context.onError(createCompilerError(40 , loc));
|
14671 | }
|
14672 | continue;
|
14673 | }
|
14674 |
|
14675 | if (name === 'once' || name === 'memo') {
|
14676 | continue;
|
14677 | }
|
14678 |
|
14679 | if (name === 'is' ||
|
14680 | (isVBind &&
|
14681 | isBindKey(arg, 'is') &&
|
14682 | (isComponentTag(tag) ||
|
14683 | (false )))) {
|
14684 | continue;
|
14685 | }
|
14686 |
|
14687 | if (isVOn && ssr) {
|
14688 | continue;
|
14689 | }
|
14690 |
|
14691 | if (!arg && (isVBind || isVOn)) {
|
14692 | hasDynamicKeys = true;
|
14693 | if (exp) {
|
14694 | if (properties.length) {
|
14695 | mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
|
14696 | properties = [];
|
14697 | }
|
14698 | if (isVBind) {
|
14699 | mergeArgs.push(exp);
|
14700 | }
|
14701 | else {
|
14702 |
|
14703 | mergeArgs.push({
|
14704 | type: 14 ,
|
14705 | loc,
|
14706 | callee: context.helper(TO_HANDLERS),
|
14707 | arguments: [exp]
|
14708 | });
|
14709 | }
|
14710 | }
|
14711 | else {
|
14712 | context.onError(createCompilerError(isVBind
|
14713 | ? 34
|
14714 | : 35 , loc));
|
14715 | }
|
14716 | continue;
|
14717 | }
|
14718 | const directiveTransform = context.directiveTransforms[name];
|
14719 | if (directiveTransform) {
|
14720 |
|
14721 | const { props, needRuntime } = directiveTransform(prop, node, context);
|
14722 | !ssr && props.forEach(analyzePatchFlag);
|
14723 | properties.push(...props);
|
14724 | if (needRuntime) {
|
14725 | runtimeDirectives.push(prop);
|
14726 | if (isSymbol(needRuntime)) {
|
14727 | directiveImportMap.set(prop, needRuntime);
|
14728 | }
|
14729 | }
|
14730 | }
|
14731 | else {
|
14732 |
|
14733 | runtimeDirectives.push(prop);
|
14734 | }
|
14735 | }
|
14736 | }
|
14737 | let propsExpression = undefined;
|
14738 |
|
14739 | if (mergeArgs.length) {
|
14740 | if (properties.length) {
|
14741 | mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
|
14742 | }
|
14743 | if (mergeArgs.length > 1) {
|
14744 | propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
|
14745 | }
|
14746 | else {
|
14747 |
|
14748 | propsExpression = mergeArgs[0];
|
14749 | }
|
14750 | }
|
14751 | else if (properties.length) {
|
14752 | propsExpression = createObjectExpression(dedupeProperties(properties), elementLoc);
|
14753 | }
|
14754 |
|
14755 | if (hasDynamicKeys) {
|
14756 | patchFlag |= 16 ;
|
14757 | }
|
14758 | else {
|
14759 | if (hasClassBinding && !isComponent) {
|
14760 | patchFlag |= 2 ;
|
14761 | }
|
14762 | if (hasStyleBinding && !isComponent) {
|
14763 | patchFlag |= 4 ;
|
14764 | }
|
14765 | if (dynamicPropNames.length) {
|
14766 | patchFlag |= 8 ;
|
14767 | }
|
14768 | if (hasHydrationEventBinding) {
|
14769 | patchFlag |= 32 ;
|
14770 | }
|
14771 | }
|
14772 | if ((patchFlag === 0 || patchFlag === 32 ) &&
|
14773 | (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
|
14774 | patchFlag |= 512 ;
|
14775 | }
|
14776 |
|
14777 | if (!context.inSSR && propsExpression) {
|
14778 | switch (propsExpression.type) {
|
14779 | case 15 :
|
14780 |
|
14781 |
|
14782 | let classKeyIndex = -1;
|
14783 | let styleKeyIndex = -1;
|
14784 | let hasDynamicKey = false;
|
14785 | for (let i = 0; i < propsExpression.properties.length; i++) {
|
14786 | const key = propsExpression.properties[i].key;
|
14787 | if (isStaticExp(key)) {
|
14788 | if (key.content === 'class') {
|
14789 | classKeyIndex = i;
|
14790 | }
|
14791 | else if (key.content === 'style') {
|
14792 | styleKeyIndex = i;
|
14793 | }
|
14794 | }
|
14795 | else if (!key.isHandlerKey) {
|
14796 | hasDynamicKey = true;
|
14797 | }
|
14798 | }
|
14799 | const classProp = propsExpression.properties[classKeyIndex];
|
14800 | const styleProp = propsExpression.properties[styleKeyIndex];
|
14801 |
|
14802 | if (!hasDynamicKey) {
|
14803 | if (classProp && !isStaticExp(classProp.value)) {
|
14804 | classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
|
14805 | }
|
14806 | if (styleProp &&
|
14807 | !isStaticExp(styleProp.value) &&
|
14808 |
|
14809 |
|
14810 | (hasStyleBinding ||
|
14811 |
|
14812 |
|
14813 | styleProp.value.type === 17 )) {
|
14814 | styleProp.value = createCallExpression(context.helper(NORMALIZE_STYLE), [styleProp.value]);
|
14815 | }
|
14816 | }
|
14817 | else {
|
14818 |
|
14819 | propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
|
14820 | }
|
14821 | break;
|
14822 | case 14 :
|
14823 |
|
14824 | break;
|
14825 | default:
|
14826 |
|
14827 | propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [
|
14828 | createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
|
14829 | propsExpression
|
14830 | ])
|
14831 | ]);
|
14832 | break;
|
14833 | }
|
14834 | }
|
14835 | return {
|
14836 | props: propsExpression,
|
14837 | directives: runtimeDirectives,
|
14838 | patchFlag,
|
14839 | dynamicPropNames
|
14840 | };
|
14841 | }
|
14842 |
|
14843 |
|
14844 |
|
14845 |
|
14846 |
|
14847 |
|
14848 | function dedupeProperties(properties) {
|
14849 | const knownProps = new Map();
|
14850 | const deduped = [];
|
14851 | for (let i = 0; i < properties.length; i++) {
|
14852 | const prop = properties[i];
|
14853 |
|
14854 | if (prop.key.type === 8 || !prop.key.isStatic) {
|
14855 | deduped.push(prop);
|
14856 | continue;
|
14857 | }
|
14858 | const name = prop.key.content;
|
14859 | const existing = knownProps.get(name);
|
14860 | if (existing) {
|
14861 | if (name === 'style' || name === 'class' || name.startsWith('on')) {
|
14862 | mergeAsArray$1(existing, prop);
|
14863 | }
|
14864 |
|
14865 | }
|
14866 | else {
|
14867 | knownProps.set(name, prop);
|
14868 | deduped.push(prop);
|
14869 | }
|
14870 | }
|
14871 | return deduped;
|
14872 | }
|
14873 | function mergeAsArray$1(existing, incoming) {
|
14874 | if (existing.value.type === 17 ) {
|
14875 | existing.value.elements.push(incoming.value);
|
14876 | }
|
14877 | else {
|
14878 | existing.value = createArrayExpression([existing.value, incoming.value], existing.loc);
|
14879 | }
|
14880 | }
|
14881 | function buildDirectiveArgs(dir, context) {
|
14882 | const dirArgs = [];
|
14883 | const runtime = directiveImportMap.get(dir);
|
14884 | if (runtime) {
|
14885 |
|
14886 | dirArgs.push(context.helperString(runtime));
|
14887 | }
|
14888 | else {
|
14889 | {
|
14890 |
|
14891 | context.helper(RESOLVE_DIRECTIVE);
|
14892 | context.directives.add(dir.name);
|
14893 | dirArgs.push(toValidAssetId(dir.name, `directive`));
|
14894 | }
|
14895 | }
|
14896 | const { loc } = dir;
|
14897 | if (dir.exp)
|
14898 | dirArgs.push(dir.exp);
|
14899 | if (dir.arg) {
|
14900 | if (!dir.exp) {
|
14901 | dirArgs.push(`void 0`);
|
14902 | }
|
14903 | dirArgs.push(dir.arg);
|
14904 | }
|
14905 | if (Object.keys(dir.modifiers).length) {
|
14906 | if (!dir.arg) {
|
14907 | if (!dir.exp) {
|
14908 | dirArgs.push(`void 0`);
|
14909 | }
|
14910 | dirArgs.push(`void 0`);
|
14911 | }
|
14912 | const trueExpression = createSimpleExpression(`true`, false, loc);
|
14913 | dirArgs.push(createObjectExpression(dir.modifiers.map(modifier => createObjectProperty(modifier, trueExpression)), loc));
|
14914 | }
|
14915 | return createArrayExpression(dirArgs, dir.loc);
|
14916 | }
|
14917 | function stringifyDynamicPropNames(props) {
|
14918 | let propsNamesString = `[`;
|
14919 | for (let i = 0, l = props.length; i < l; i++) {
|
14920 | propsNamesString += JSON.stringify(props[i]);
|
14921 | if (i < l - 1)
|
14922 | propsNamesString += ', ';
|
14923 | }
|
14924 | return propsNamesString + `]`;
|
14925 | }
|
14926 | function isComponentTag(tag) {
|
14927 | return tag[0].toLowerCase() + tag.slice(1) === 'component';
|
14928 | }
|
14929 |
|
14930 | const transformSlotOutlet = (node, context) => {
|
14931 | if (isSlotOutlet(node)) {
|
14932 | const { children, loc } = node;
|
14933 | const { slotName, slotProps } = processSlotOutlet(node, context);
|
14934 | const slotArgs = [
|
14935 | context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
|
14936 | slotName
|
14937 | ];
|
14938 | if (slotProps) {
|
14939 | slotArgs.push(slotProps);
|
14940 | }
|
14941 | if (children.length) {
|
14942 | if (!slotProps) {
|
14943 | slotArgs.push(`{}`);
|
14944 | }
|
14945 | slotArgs.push(createFunctionExpression([], children, false, false, loc));
|
14946 | }
|
14947 | if (context.scopeId && !context.slotted) {
|
14948 | if (!slotProps) {
|
14949 | slotArgs.push(`{}`);
|
14950 | }
|
14951 | if (!children.length) {
|
14952 | slotArgs.push(`undefined`);
|
14953 | }
|
14954 | slotArgs.push(`true`);
|
14955 | }
|
14956 | node.codegenNode = createCallExpression(context.helper(RENDER_SLOT), slotArgs, loc);
|
14957 | }
|
14958 | };
|
14959 | function processSlotOutlet(node, context) {
|
14960 | let slotName = `"default"`;
|
14961 | let slotProps = undefined;
|
14962 | const nonNameProps = [];
|
14963 | for (let i = 0; i < node.props.length; i++) {
|
14964 | const p = node.props[i];
|
14965 | if (p.type === 6 ) {
|
14966 | if (p.value) {
|
14967 | if (p.name === 'name') {
|
14968 | slotName = JSON.stringify(p.value.content);
|
14969 | }
|
14970 | else {
|
14971 | p.name = camelize(p.name);
|
14972 | nonNameProps.push(p);
|
14973 | }
|
14974 | }
|
14975 | }
|
14976 | else {
|
14977 | if (p.name === 'bind' && isBindKey(p.arg, 'name')) {
|
14978 | if (p.exp)
|
14979 | slotName = p.exp;
|
14980 | }
|
14981 | else {
|
14982 | if (p.name === 'bind' && p.arg && isStaticExp(p.arg)) {
|
14983 | p.arg.content = camelize(p.arg.content);
|
14984 | }
|
14985 | nonNameProps.push(p);
|
14986 | }
|
14987 | }
|
14988 | }
|
14989 | if (nonNameProps.length > 0) {
|
14990 | const { props, directives } = buildProps(node, context, nonNameProps);
|
14991 | slotProps = props;
|
14992 | if (directives.length) {
|
14993 | context.onError(createCompilerError(36 , directives[0].loc));
|
14994 | }
|
14995 | }
|
14996 | return {
|
14997 | slotName,
|
14998 | slotProps
|
14999 | };
|
15000 | }
|
15001 |
|
15002 | const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^\s*function(?:\s+[\w$]+)?\s*\(/;
|
15003 | const transformOn = (dir, node, context, augmentor) => {
|
15004 | const { loc, modifiers, arg } = dir;
|
15005 | if (!dir.exp && !modifiers.length) {
|
15006 | context.onError(createCompilerError(35 , loc));
|
15007 | }
|
15008 | let eventName;
|
15009 | if (arg.type === 4 ) {
|
15010 | if (arg.isStatic) {
|
15011 | const rawName = arg.content;
|
15012 |
|
15013 | eventName = createSimpleExpression(toHandlerKey(camelize(rawName)), true, arg.loc);
|
15014 | }
|
15015 | else {
|
15016 |
|
15017 | eventName = createCompoundExpression([
|
15018 | `${context.helperString(TO_HANDLER_KEY)}(`,
|
15019 | arg,
|
15020 | `)`
|
15021 | ]);
|
15022 | }
|
15023 | }
|
15024 | else {
|
15025 |
|
15026 | eventName = arg;
|
15027 | eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
|
15028 | eventName.children.push(`)`);
|
15029 | }
|
15030 |
|
15031 | let exp = dir.exp;
|
15032 | if (exp && !exp.content.trim()) {
|
15033 | exp = undefined;
|
15034 | }
|
15035 | let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
|
15036 | if (exp) {
|
15037 | const isMemberExp = isMemberExpression(exp.content);
|
15038 | const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
|
15039 | const hasMultipleStatements = exp.content.includes(`;`);
|
15040 | {
|
15041 | validateBrowserExpression(exp, context, false, hasMultipleStatements);
|
15042 | }
|
15043 | if (isInlineStatement || (shouldCache && isMemberExp)) {
|
15044 |
|
15045 | exp = createCompoundExpression([
|
15046 | `${isInlineStatement
|
15047 | ? `$event`
|
15048 | : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
|
15049 | exp,
|
15050 | hasMultipleStatements ? `}` : `)`
|
15051 | ]);
|
15052 | }
|
15053 | }
|
15054 | let ret = {
|
15055 | props: [
|
15056 | createObjectProperty(eventName, exp || createSimpleExpression(`() => {}`, false, loc))
|
15057 | ]
|
15058 | };
|
15059 |
|
15060 | if (augmentor) {
|
15061 | ret = augmentor(ret);
|
15062 | }
|
15063 | if (shouldCache) {
|
15064 |
|
15065 |
|
15066 |
|
15067 | ret.props[0].value = context.cache(ret.props[0].value);
|
15068 | }
|
15069 |
|
15070 | ret.props.forEach(p => (p.key.isHandlerKey = true));
|
15071 | return ret;
|
15072 | };
|
15073 |
|
15074 |
|
15075 |
|
15076 |
|
15077 | const transformBind = (dir, _node, context) => {
|
15078 | const { exp, modifiers, loc } = dir;
|
15079 | const arg = dir.arg;
|
15080 | if (arg.type !== 4 ) {
|
15081 | arg.children.unshift(`(`);
|
15082 | arg.children.push(`) || ""`);
|
15083 | }
|
15084 | else if (!arg.isStatic) {
|
15085 | arg.content = `${arg.content} || ""`;
|
15086 | }
|
15087 |
|
15088 | if (modifiers.includes('camel')) {
|
15089 | if (arg.type === 4 ) {
|
15090 | if (arg.isStatic) {
|
15091 | arg.content = camelize(arg.content);
|
15092 | }
|
15093 | else {
|
15094 | arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
15095 | }
|
15096 | }
|
15097 | else {
|
15098 | arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
15099 | arg.children.push(`)`);
|
15100 | }
|
15101 | }
|
15102 | if (!context.inSSR) {
|
15103 | if (modifiers.includes('prop')) {
|
15104 | injectPrefix(arg, '.');
|
15105 | }
|
15106 | if (modifiers.includes('attr')) {
|
15107 | injectPrefix(arg, '^');
|
15108 | }
|
15109 | }
|
15110 | if (!exp ||
|
15111 | (exp.type === 4 && !exp.content.trim())) {
|
15112 | context.onError(createCompilerError(34 , loc));
|
15113 | return {
|
15114 | props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
|
15115 | };
|
15116 | }
|
15117 | return {
|
15118 | props: [createObjectProperty(arg, exp)]
|
15119 | };
|
15120 | };
|
15121 | const injectPrefix = (arg, prefix) => {
|
15122 | if (arg.type === 4 ) {
|
15123 | if (arg.isStatic) {
|
15124 | arg.content = prefix + arg.content;
|
15125 | }
|
15126 | else {
|
15127 | arg.content = `\`${prefix}\${${arg.content}}\``;
|
15128 | }
|
15129 | }
|
15130 | else {
|
15131 | arg.children.unshift(`'${prefix}' + (`);
|
15132 | arg.children.push(`)`);
|
15133 | }
|
15134 | };
|
15135 |
|
15136 |
|
15137 |
|
15138 | const transformText = (node, context) => {
|
15139 | if (node.type === 0 ||
|
15140 | node.type === 1 ||
|
15141 | node.type === 11 ||
|
15142 | node.type === 10 ) {
|
15143 |
|
15144 |
|
15145 | return () => {
|
15146 | const children = node.children;
|
15147 | let currentContainer = undefined;
|
15148 | let hasText = false;
|
15149 | for (let i = 0; i < children.length; i++) {
|
15150 | const child = children[i];
|
15151 | if (isText(child)) {
|
15152 | hasText = true;
|
15153 | for (let j = i + 1; j < children.length; j++) {
|
15154 | const next = children[j];
|
15155 | if (isText(next)) {
|
15156 | if (!currentContainer) {
|
15157 | currentContainer = children[i] = {
|
15158 | type: 8 ,
|
15159 | loc: child.loc,
|
15160 | children: [child]
|
15161 | };
|
15162 | }
|
15163 |
|
15164 | currentContainer.children.push(` + `, next);
|
15165 | children.splice(j, 1);
|
15166 | j--;
|
15167 | }
|
15168 | else {
|
15169 | currentContainer = undefined;
|
15170 | break;
|
15171 | }
|
15172 | }
|
15173 | }
|
15174 | }
|
15175 | if (!hasText ||
|
15176 |
|
15177 |
|
15178 |
|
15179 |
|
15180 | (children.length === 1 &&
|
15181 | (node.type === 0 ||
|
15182 | (node.type === 1 &&
|
15183 | node.tagType === 0 &&
|
15184 |
|
15185 |
|
15186 |
|
15187 |
|
15188 |
|
15189 | !node.props.find(p => p.type === 7 &&
|
15190 | !context.directiveTransforms[p.name]) &&
|
15191 |
|
15192 |
|
15193 |
|
15194 | !(false ))))) {
|
15195 | return;
|
15196 | }
|
15197 |
|
15198 |
|
15199 | for (let i = 0; i < children.length; i++) {
|
15200 | const child = children[i];
|
15201 | if (isText(child) || child.type === 8 ) {
|
15202 | const callArgs = [];
|
15203 |
|
15204 |
|
15205 | if (child.type !== 2 || child.content !== ' ') {
|
15206 | callArgs.push(child);
|
15207 | }
|
15208 |
|
15209 | if (!context.ssr &&
|
15210 | getConstantType(child, context) === 0 ) {
|
15211 | callArgs.push(1 +
|
15212 | (` /* ${PatchFlagNames[1 /* TEXT */]} */` ));
|
15213 | }
|
15214 | children[i] = {
|
15215 | type: 12 ,
|
15216 | content: child,
|
15217 | loc: child.loc,
|
15218 | codegenNode: createCallExpression(context.helper(CREATE_TEXT), callArgs)
|
15219 | };
|
15220 | }
|
15221 | }
|
15222 | };
|
15223 | }
|
15224 | };
|
15225 |
|
15226 | const seen = new WeakSet();
|
15227 | const transformOnce = (node, context) => {
|
15228 | if (node.type === 1 && findDir(node, 'once', true)) {
|
15229 | if (seen.has(node) || context.inVOnce) {
|
15230 | return;
|
15231 | }
|
15232 | seen.add(node);
|
15233 | context.inVOnce = true;
|
15234 | context.helper(SET_BLOCK_TRACKING);
|
15235 | return () => {
|
15236 | context.inVOnce = false;
|
15237 | const cur = context.currentNode;
|
15238 | if (cur.codegenNode) {
|
15239 | cur.codegenNode = context.cache(cur.codegenNode, true );
|
15240 | }
|
15241 | };
|
15242 | }
|
15243 | };
|
15244 |
|
15245 | const transformModel = (dir, node, context) => {
|
15246 | const { exp, arg } = dir;
|
15247 | if (!exp) {
|
15248 | context.onError(createCompilerError(41 , dir.loc));
|
15249 | return createTransformProps();
|
15250 | }
|
15251 | const rawExp = exp.loc.source;
|
15252 | const expString = exp.type === 4 ? exp.content : rawExp;
|
15253 |
|
15254 |
|
15255 | context.bindingMetadata[rawExp];
|
15256 | const maybeRef = !true ;
|
15257 | if (!expString.trim() || (!isMemberExpression(expString) && !maybeRef)) {
|
15258 | context.onError(createCompilerError(42 , exp.loc));
|
15259 | return createTransformProps();
|
15260 | }
|
15261 | const propName = arg ? arg : createSimpleExpression('modelValue', true);
|
15262 | const eventName = arg
|
15263 | ? isStaticExp(arg)
|
15264 | ? `onUpdate:${arg.content}`
|
15265 | : createCompoundExpression(['"onUpdate:" + ', arg])
|
15266 | : `onUpdate:modelValue`;
|
15267 | let assignmentExp;
|
15268 | const eventArg = context.isTS ? `($event: any)` : `$event`;
|
15269 | {
|
15270 | assignmentExp = createCompoundExpression([
|
15271 | `${eventArg} => (`,
|
15272 | exp,
|
15273 | ` = $event)`
|
15274 | ]);
|
15275 | }
|
15276 | const props = [
|
15277 |
|
15278 | createObjectProperty(propName, dir.exp),
|
15279 |
|
15280 | createObjectProperty(eventName, assignmentExp)
|
15281 | ];
|
15282 |
|
15283 | if (dir.modifiers.length && node.tagType === 1 ) {
|
15284 | const modifiers = dir.modifiers
|
15285 | .map(m => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`)
|
15286 | .join(`, `);
|
15287 | const modifiersKey = arg
|
15288 | ? isStaticExp(arg)
|
15289 | ? `${arg.content}Modifiers`
|
15290 | : createCompoundExpression([arg, ' + "Modifiers"'])
|
15291 | : `modelModifiers`;
|
15292 | props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 )));
|
15293 | }
|
15294 | return createTransformProps(props);
|
15295 | };
|
15296 | function createTransformProps(props = []) {
|
15297 | return { props };
|
15298 | }
|
15299 |
|
15300 | const seen$1 = new WeakSet();
|
15301 | const transformMemo = (node, context) => {
|
15302 | if (node.type === 1 ) {
|
15303 | const dir = findDir(node, 'memo');
|
15304 | if (!dir || seen$1.has(node)) {
|
15305 | return;
|
15306 | }
|
15307 | seen$1.add(node);
|
15308 | return () => {
|
15309 | const codegenNode = node.codegenNode ||
|
15310 | context.currentNode.codegenNode;
|
15311 | if (codegenNode && codegenNode.type === 13 ) {
|
15312 |
|
15313 | if (node.tagType !== 1 ) {
|
15314 | makeBlock(codegenNode, context);
|
15315 | }
|
15316 | node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
15317 | dir.exp,
|
15318 | createFunctionExpression(undefined, codegenNode),
|
15319 | `_cache`,
|
15320 | String(context.cached++)
|
15321 | ]);
|
15322 | }
|
15323 | };
|
15324 | }
|
15325 | };
|
15326 |
|
15327 | function getBaseTransformPreset(prefixIdentifiers) {
|
15328 | return [
|
15329 | [
|
15330 | transformOnce,
|
15331 | transformIf,
|
15332 | transformMemo,
|
15333 | transformFor,
|
15334 | ...([]),
|
15335 | ...([transformExpression]
|
15336 | ),
|
15337 | transformSlotOutlet,
|
15338 | transformElement,
|
15339 | trackSlotScopes,
|
15340 | transformText
|
15341 | ],
|
15342 | {
|
15343 | on: transformOn,
|
15344 | bind: transformBind,
|
15345 | model: transformModel
|
15346 | }
|
15347 | ];
|
15348 | }
|
15349 |
|
15350 |
|
15351 | function baseCompile(template, options = {}) {
|
15352 | const onError = options.onError || defaultOnError;
|
15353 | const isModuleMode = options.mode === 'module';
|
15354 |
|
15355 | {
|
15356 | if (options.prefixIdentifiers === true) {
|
15357 | onError(createCompilerError(46 ));
|
15358 | }
|
15359 | else if (isModuleMode) {
|
15360 | onError(createCompilerError(47 ));
|
15361 | }
|
15362 | }
|
15363 | const prefixIdentifiers = !true ;
|
15364 | if (options.cacheHandlers) {
|
15365 | onError(createCompilerError(48 ));
|
15366 | }
|
15367 | if (options.scopeId && !isModuleMode) {
|
15368 | onError(createCompilerError(49 ));
|
15369 | }
|
15370 | const ast = isString(template) ? baseParse(template, options) : template;
|
15371 | const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
15372 | transform(ast, extend({}, options, {
|
15373 | prefixIdentifiers,
|
15374 | nodeTransforms: [
|
15375 | ...nodeTransforms,
|
15376 | ...(options.nodeTransforms || [])
|
15377 | ],
|
15378 | directiveTransforms: extend({}, directiveTransforms, options.directiveTransforms || {}
|
15379 | )
|
15380 | }));
|
15381 | return generate(ast, extend({}, options, {
|
15382 | prefixIdentifiers
|
15383 | }));
|
15384 | }
|
15385 |
|
15386 | const noopDirectiveTransform = () => ({ props: [] });
|
15387 |
|
15388 | const V_MODEL_RADIO = Symbol(`vModelRadio` );
|
15389 | const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
|
15390 | const V_MODEL_TEXT = Symbol(`vModelText` );
|
15391 | const V_MODEL_SELECT = Symbol(`vModelSelect` );
|
15392 | const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
|
15393 | const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
|
15394 | const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
|
15395 | const V_SHOW = Symbol(`vShow` );
|
15396 | const TRANSITION$1 = Symbol(`Transition` );
|
15397 | const TRANSITION_GROUP = Symbol(`TransitionGroup` );
|
15398 | registerRuntimeHelpers({
|
15399 | [V_MODEL_RADIO]: `vModelRadio`,
|
15400 | [V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
15401 | [V_MODEL_TEXT]: `vModelText`,
|
15402 | [V_MODEL_SELECT]: `vModelSelect`,
|
15403 | [V_MODEL_DYNAMIC]: `vModelDynamic`,
|
15404 | [V_ON_WITH_MODIFIERS]: `withModifiers`,
|
15405 | [V_ON_WITH_KEYS]: `withKeys`,
|
15406 | [V_SHOW]: `vShow`,
|
15407 | [TRANSITION$1]: `Transition`,
|
15408 | [TRANSITION_GROUP]: `TransitionGroup`
|
15409 | });
|
15410 |
|
15411 |
|
15412 | let decoder;
|
15413 | function decodeHtmlBrowser(raw, asAttr = false) {
|
15414 | if (!decoder) {
|
15415 | decoder = document.createElement('div');
|
15416 | }
|
15417 | if (asAttr) {
|
15418 | decoder.innerHTML = `<div foo="${raw.replace(/"/g, '"')}">`;
|
15419 | return decoder.children[0].getAttribute('foo');
|
15420 | }
|
15421 | else {
|
15422 | decoder.innerHTML = raw;
|
15423 | return decoder.textContent;
|
15424 | }
|
15425 | }
|
15426 |
|
15427 | const isRawTextContainer = makeMap('style,iframe,script,noscript', true);
|
15428 | const parserOptions = {
|
15429 | isVoidTag,
|
15430 | isNativeTag: tag => isHTMLTag(tag) || isSVGTag(tag),
|
15431 | isPreTag: tag => tag === 'pre',
|
15432 | decodeEntities: decodeHtmlBrowser ,
|
15433 | isBuiltInComponent: (tag) => {
|
15434 | if (isBuiltInType(tag, `Transition`)) {
|
15435 | return TRANSITION$1;
|
15436 | }
|
15437 | else if (isBuiltInType(tag, `TransitionGroup`)) {
|
15438 | return TRANSITION_GROUP;
|
15439 | }
|
15440 | },
|
15441 |
|
15442 | getNamespace(tag, parent) {
|
15443 | let ns = parent ? parent.ns : 0 ;
|
15444 | if (parent && ns === 2 ) {
|
15445 | if (parent.tag === 'annotation-xml') {
|
15446 | if (tag === 'svg') {
|
15447 | return 1 ;
|
15448 | }
|
15449 | if (parent.props.some(a => a.type === 6 &&
|
15450 | a.name === 'encoding' &&
|
15451 | a.value != null &&
|
15452 | (a.value.content === 'text/html' ||
|
15453 | a.value.content === 'application/xhtml+xml'))) {
|
15454 | ns = 0 ;
|
15455 | }
|
15456 | }
|
15457 | else if (/^m(?:[ions]|text)$/.test(parent.tag) &&
|
15458 | tag !== 'mglyph' &&
|
15459 | tag !== 'malignmark') {
|
15460 | ns = 0 ;
|
15461 | }
|
15462 | }
|
15463 | else if (parent && ns === 1 ) {
|
15464 | if (parent.tag === 'foreignObject' ||
|
15465 | parent.tag === 'desc' ||
|
15466 | parent.tag === 'title') {
|
15467 | ns = 0 ;
|
15468 | }
|
15469 | }
|
15470 | if (ns === 0 ) {
|
15471 | if (tag === 'svg') {
|
15472 | return 1 ;
|
15473 | }
|
15474 | if (tag === 'math') {
|
15475 | return 2 ;
|
15476 | }
|
15477 | }
|
15478 | return ns;
|
15479 | },
|
15480 |
|
15481 | getTextMode({ tag, ns }) {
|
15482 | if (ns === 0 ) {
|
15483 | if (tag === 'textarea' || tag === 'title') {
|
15484 | return 1 ;
|
15485 | }
|
15486 | if (isRawTextContainer(tag)) {
|
15487 | return 2 ;
|
15488 | }
|
15489 | }
|
15490 | return 0 ;
|
15491 | }
|
15492 | };
|
15493 |
|
15494 |
|
15495 |
|
15496 |
|
15497 |
|
15498 |
|
15499 |
|
15500 | const transformStyle = node => {
|
15501 | if (node.type === 1 ) {
|
15502 | node.props.forEach((p, i) => {
|
15503 | if (p.type === 6 && p.name === 'style' && p.value) {
|
15504 |
|
15505 | node.props[i] = {
|
15506 | type: 7 ,
|
15507 | name: `bind`,
|
15508 | arg: createSimpleExpression(`style`, true, p.loc),
|
15509 | exp: parseInlineCSS(p.value.content, p.loc),
|
15510 | modifiers: [],
|
15511 | loc: p.loc
|
15512 | };
|
15513 | }
|
15514 | });
|
15515 | }
|
15516 | };
|
15517 | const parseInlineCSS = (cssText, loc) => {
|
15518 | const normalized = parseStringStyle(cssText);
|
15519 | return createSimpleExpression(JSON.stringify(normalized), false, loc, 3 );
|
15520 | };
|
15521 |
|
15522 | function createDOMCompilerError(code, loc) {
|
15523 | return createCompilerError(code, loc, DOMErrorMessages );
|
15524 | }
|
15525 | const DOMErrorMessages = {
|
15526 | [50 ]: `v-html is missing expression.`,
|
15527 | [51 ]: `v-html will override element children.`,
|
15528 | [52 ]: `v-text is missing expression.`,
|
15529 | [53 ]: `v-text will override element children.`,
|
15530 | [54 ]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
15531 | [55 ]: `v-model argument is not supported on plain elements.`,
|
15532 | [56 ]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
15533 | [57 ]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
15534 | [58 ]: `v-show is missing expression.`,
|
15535 | [59 ]: `<Transition> expects exactly one child element or component.`,
|
15536 | [60 ]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
15537 | };
|
15538 |
|
15539 | const transformVHtml = (dir, node, context) => {
|
15540 | const { exp, loc } = dir;
|
15541 | if (!exp) {
|
15542 | context.onError(createDOMCompilerError(50 , loc));
|
15543 | }
|
15544 | if (node.children.length) {
|
15545 | context.onError(createDOMCompilerError(51 , loc));
|
15546 | node.children.length = 0;
|
15547 | }
|
15548 | return {
|
15549 | props: [
|
15550 | createObjectProperty(createSimpleExpression(`innerHTML`, true, loc), exp || createSimpleExpression('', true))
|
15551 | ]
|
15552 | };
|
15553 | };
|
15554 |
|
15555 | const transformVText = (dir, node, context) => {
|
15556 | const { exp, loc } = dir;
|
15557 | if (!exp) {
|
15558 | context.onError(createDOMCompilerError(52 , loc));
|
15559 | }
|
15560 | if (node.children.length) {
|
15561 | context.onError(createDOMCompilerError(53 , loc));
|
15562 | node.children.length = 0;
|
15563 | }
|
15564 | return {
|
15565 | props: [
|
15566 | createObjectProperty(createSimpleExpression(`textContent`, true), exp
|
15567 | ? createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc)
|
15568 | : createSimpleExpression('', true))
|
15569 | ]
|
15570 | };
|
15571 | };
|
15572 |
|
15573 | const transformModel$1 = (dir, node, context) => {
|
15574 | const baseResult = transformModel(dir, node, context);
|
15575 |
|
15576 | if (!baseResult.props.length || node.tagType === 1 ) {
|
15577 | return baseResult;
|
15578 | }
|
15579 | if (dir.arg) {
|
15580 | context.onError(createDOMCompilerError(55 , dir.arg.loc));
|
15581 | }
|
15582 | function checkDuplicatedValue() {
|
15583 | const value = findProp(node, 'value');
|
15584 | if (value) {
|
15585 | context.onError(createDOMCompilerError(57 , value.loc));
|
15586 | }
|
15587 | }
|
15588 | const { tag } = node;
|
15589 | const isCustomElement = context.isCustomElement(tag);
|
15590 | if (tag === 'input' ||
|
15591 | tag === 'textarea' ||
|
15592 | tag === 'select' ||
|
15593 | isCustomElement) {
|
15594 | let directiveToUse = V_MODEL_TEXT;
|
15595 | let isInvalidType = false;
|
15596 | if (tag === 'input' || isCustomElement) {
|
15597 | const type = findProp(node, `type`);
|
15598 | if (type) {
|
15599 | if (type.type === 7 ) {
|
15600 |
|
15601 | directiveToUse = V_MODEL_DYNAMIC;
|
15602 | }
|
15603 | else if (type.value) {
|
15604 | switch (type.value.content) {
|
15605 | case 'radio':
|
15606 | directiveToUse = V_MODEL_RADIO;
|
15607 | break;
|
15608 | case 'checkbox':
|
15609 | directiveToUse = V_MODEL_CHECKBOX;
|
15610 | break;
|
15611 | case 'file':
|
15612 | isInvalidType = true;
|
15613 | context.onError(createDOMCompilerError(56 , dir.loc));
|
15614 | break;
|
15615 | default:
|
15616 |
|
15617 | checkDuplicatedValue();
|
15618 | break;
|
15619 | }
|
15620 | }
|
15621 | }
|
15622 | else if (hasDynamicKeyVBind(node)) {
|
15623 |
|
15624 |
|
15625 | directiveToUse = V_MODEL_DYNAMIC;
|
15626 | }
|
15627 | else {
|
15628 |
|
15629 | checkDuplicatedValue();
|
15630 | }
|
15631 | }
|
15632 | else if (tag === 'select') {
|
15633 | directiveToUse = V_MODEL_SELECT;
|
15634 | }
|
15635 | else {
|
15636 |
|
15637 | checkDuplicatedValue();
|
15638 | }
|
15639 |
|
15640 |
|
15641 |
|
15642 | if (!isInvalidType) {
|
15643 | baseResult.needRuntime = context.helper(directiveToUse);
|
15644 | }
|
15645 | }
|
15646 | else {
|
15647 | context.onError(createDOMCompilerError(54 , dir.loc));
|
15648 | }
|
15649 |
|
15650 |
|
15651 | baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 &&
|
15652 | p.key.content === 'modelValue'));
|
15653 | return baseResult;
|
15654 | };
|
15655 |
|
15656 | const isEventOptionModifier = makeMap(`passive,once,capture`);
|
15657 | const isNonKeyModifier = makeMap(
|
15658 |
|
15659 | `stop,prevent,self,` +
|
15660 |
|
15661 | `ctrl,shift,alt,meta,exact,` +
|
15662 |
|
15663 | `middle`);
|
15664 |
|
15665 | const maybeKeyModifier = makeMap('left,right');
|
15666 | const isKeyboardEvent = makeMap(`onkeyup,onkeydown,onkeypress`, true);
|
15667 | const resolveModifiers = (key, modifiers, context, loc) => {
|
15668 | const keyModifiers = [];
|
15669 | const nonKeyModifiers = [];
|
15670 | const eventOptionModifiers = [];
|
15671 | for (let i = 0; i < modifiers.length; i++) {
|
15672 | const modifier = modifiers[i];
|
15673 | if (isEventOptionModifier(modifier)) {
|
15674 |
|
15675 |
|
15676 | eventOptionModifiers.push(modifier);
|
15677 | }
|
15678 | else {
|
15679 |
|
15680 | if (maybeKeyModifier(modifier)) {
|
15681 | if (isStaticExp(key)) {
|
15682 | if (isKeyboardEvent(key.content)) {
|
15683 | keyModifiers.push(modifier);
|
15684 | }
|
15685 | else {
|
15686 | nonKeyModifiers.push(modifier);
|
15687 | }
|
15688 | }
|
15689 | else {
|
15690 | keyModifiers.push(modifier);
|
15691 | nonKeyModifiers.push(modifier);
|
15692 | }
|
15693 | }
|
15694 | else {
|
15695 | if (isNonKeyModifier(modifier)) {
|
15696 | nonKeyModifiers.push(modifier);
|
15697 | }
|
15698 | else {
|
15699 | keyModifiers.push(modifier);
|
15700 | }
|
15701 | }
|
15702 | }
|
15703 | }
|
15704 | return {
|
15705 | keyModifiers,
|
15706 | nonKeyModifiers,
|
15707 | eventOptionModifiers
|
15708 | };
|
15709 | };
|
15710 | const transformClick = (key, event) => {
|
15711 | const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === 'onclick';
|
15712 | return isStaticClick
|
15713 | ? createSimpleExpression(event, true)
|
15714 | : key.type !== 4
|
15715 | ? createCompoundExpression([
|
15716 | `(`,
|
15717 | key,
|
15718 | `) === "onClick" ? "${event}" : (`,
|
15719 | key,
|
15720 | `)`
|
15721 | ])
|
15722 | : key;
|
15723 | };
|
15724 | const transformOn$1 = (dir, node, context) => {
|
15725 | return transformOn(dir, node, context, baseResult => {
|
15726 | const { modifiers } = dir;
|
15727 | if (!modifiers.length)
|
15728 | return baseResult;
|
15729 | let { key, value: handlerExp } = baseResult.props[0];
|
15730 | const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
15731 |
|
15732 | if (nonKeyModifiers.includes('right')) {
|
15733 | key = transformClick(key, `onContextmenu`);
|
15734 | }
|
15735 | if (nonKeyModifiers.includes('middle')) {
|
15736 | key = transformClick(key, `onMouseup`);
|
15737 | }
|
15738 | if (nonKeyModifiers.length) {
|
15739 | handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
|
15740 | handlerExp,
|
15741 | JSON.stringify(nonKeyModifiers)
|
15742 | ]);
|
15743 | }
|
15744 | if (keyModifiers.length &&
|
15745 |
|
15746 | (!isStaticExp(key) || isKeyboardEvent(key.content))) {
|
15747 | handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
15748 | handlerExp,
|
15749 | JSON.stringify(keyModifiers)
|
15750 | ]);
|
15751 | }
|
15752 | if (eventOptionModifiers.length) {
|
15753 | const modifierPostfix = eventOptionModifiers.map(capitalize).join('');
|
15754 | key = isStaticExp(key)
|
15755 | ? createSimpleExpression(`${key.content}${modifierPostfix}`, true)
|
15756 | : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
15757 | }
|
15758 | return {
|
15759 | props: [createObjectProperty(key, handlerExp)]
|
15760 | };
|
15761 | });
|
15762 | };
|
15763 |
|
15764 | const transformShow = (dir, node, context) => {
|
15765 | const { exp, loc } = dir;
|
15766 | if (!exp) {
|
15767 | context.onError(createDOMCompilerError(58 , loc));
|
15768 | }
|
15769 | return {
|
15770 | props: [],
|
15771 | needRuntime: context.helper(V_SHOW)
|
15772 | };
|
15773 | };
|
15774 |
|
15775 | const warnTransitionChildren = (node, context) => {
|
15776 | if (node.type === 1 &&
|
15777 | node.tagType === 1 ) {
|
15778 | const component = context.isBuiltInComponent(node.tag);
|
15779 | if (component === TRANSITION$1) {
|
15780 | return () => {
|
15781 | if (node.children.length && hasMultipleChildren(node)) {
|
15782 | context.onError(createDOMCompilerError(59 , {
|
15783 | start: node.children[0].loc.start,
|
15784 | end: node.children[node.children.length - 1].loc.end,
|
15785 | source: ''
|
15786 | }));
|
15787 | }
|
15788 | };
|
15789 | }
|
15790 | }
|
15791 | };
|
15792 | function hasMultipleChildren(node) {
|
15793 |
|
15794 | const children = (node.children = node.children.filter(c => c.type !== 3 ));
|
15795 | const child = children[0];
|
15796 | return (children.length !== 1 ||
|
15797 | child.type === 11 ||
|
15798 | (child.type === 9 && child.branches.some(hasMultipleChildren)));
|
15799 | }
|
15800 |
|
15801 | const ignoreSideEffectTags = (node, context) => {
|
15802 | if (node.type === 1 &&
|
15803 | node.tagType === 0 &&
|
15804 | (node.tag === 'script' || node.tag === 'style')) {
|
15805 | context.onError(createDOMCompilerError(60 , node.loc));
|
15806 | context.removeNode();
|
15807 | }
|
15808 | };
|
15809 |
|
15810 | const DOMNodeTransforms = [
|
15811 | transformStyle,
|
15812 | ...([warnTransitionChildren] )
|
15813 | ];
|
15814 | const DOMDirectiveTransforms = {
|
15815 | cloak: noopDirectiveTransform,
|
15816 | html: transformVHtml,
|
15817 | text: transformVText,
|
15818 | model: transformModel$1,
|
15819 | on: transformOn$1,
|
15820 | show: transformShow
|
15821 | };
|
15822 | function compile$1(template, options = {}) {
|
15823 | return baseCompile(template, extend({}, parserOptions, options, {
|
15824 | nodeTransforms: [
|
15825 |
|
15826 |
|
15827 |
|
15828 | ignoreSideEffectTags,
|
15829 | ...DOMNodeTransforms,
|
15830 | ...(options.nodeTransforms || [])
|
15831 | ],
|
15832 | directiveTransforms: extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
|
15833 | transformHoist: null
|
15834 | }));
|
15835 | }
|
15836 |
|
15837 |
|
15838 | {
|
15839 | initDev();
|
15840 | }
|
15841 | const compileCache = Object.create(null);
|
15842 | function compileToFunction(template, options) {
|
15843 | if (!isString(template)) {
|
15844 | if (template.nodeType) {
|
15845 | template = template.innerHTML;
|
15846 | }
|
15847 | else {
|
15848 | warn$1(`invalid template option: `, template);
|
15849 | return NOOP;
|
15850 | }
|
15851 | }
|
15852 | const key = template;
|
15853 | const cached = compileCache[key];
|
15854 | if (cached) {
|
15855 | return cached;
|
15856 | }
|
15857 | if (template[0] === '#') {
|
15858 | const el = document.querySelector(template);
|
15859 | if (!el) {
|
15860 | warn$1(`Template element not found or is empty: ${template}`);
|
15861 | }
|
15862 |
|
15863 |
|
15864 |
|
15865 |
|
15866 | template = el ? el.innerHTML : ``;
|
15867 | }
|
15868 | const { code } = compile$1(template, extend({
|
15869 | hoistStatic: true,
|
15870 | onError: onError ,
|
15871 | onWarn: e => onError(e, true)
|
15872 | }, options));
|
15873 | function onError(err, asWarning = false) {
|
15874 | const message = asWarning
|
15875 | ? err.message
|
15876 | : `Template compilation error: ${err.message}`;
|
15877 | const codeFrame = err.loc &&
|
15878 | generateCodeFrame(template, err.loc.start.offset, err.loc.end.offset);
|
15879 | warn$1(codeFrame ? `${message}\n${codeFrame}` : message);
|
15880 | }
|
15881 |
|
15882 |
|
15883 |
|
15884 |
|
15885 | const render = (new Function('Vue', code)(runtimeDom));
|
15886 | render._rc = true;
|
15887 | return (compileCache[key] = render);
|
15888 | }
|
15889 | registerRuntimeCompiler(compileToFunction);
|
15890 |
|
15891 | export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compileToFunction as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineProps, defineSSRCustomElement, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };
|